Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Commit

Permalink
Merge pull request #383 from klaytn/release/v1.5.4
Browse files Browse the repository at this point in the history
[Master] release/v1.5.4 QA Sign-off
  • Loading branch information
jimni1222 authored Oct 29, 2020
2 parents 1baaaf7 + 20b8e4e commit c9d21fc
Show file tree
Hide file tree
Showing 10 changed files with 244 additions and 36 deletions.
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM node:erbium
FROM node:carbon
# FROM node:dubnium
# FROM node:erbium

# make app directory
WORKDIR /usr/src/app
Expand All @@ -8,7 +10,7 @@ COPY package*.json ./

# install app dependencies
RUN npm install && \
npm install -g mocha
npm install -g mocha@6.2.2
# install solc
RUN curl -o /usr/bin/solc -fL https://github.com/ethereum/solidity/releases/download/v0.5.6/solc-static-linux \
&& chmod u+x /usr/bin/solc
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ Testing in caver-js is implemented using the mocha testing framework. If you wan
- [mocha](https://mochajs.org/#installation)

**Note** caver-js can run on Node.js versions 8 and 10, and the recommended versions are:
- lts/carbon ([8.16.0](https://nodejs.org/dist/latest-v8.x/))
- lts/dubnium ([10.16.0](https://nodejs.org/dist/latest-v10.x/))
* lts/erbium ([12.18.0](https://nodejs.org/dist/latest-v12.x/))
- lts/carbon ([8.17.0](https://nodejs.org/dist/latest-v8.x/))
- lts/dubnium ([10.22.0](https://nodejs.org/dist/latest-v10.x/))
* lts/erbium ([12.19.0](https://nodejs.org/dist/latest-v12.x/))

If you are already using a different version of the node(for example, node v14), use the Node Version Manager([NVM](https://github.com/nvm-sh/nvm)) to install and use the version supported by caver-js.

Expand Down Expand Up @@ -197,6 +197,7 @@ The API lists of caver-js are described in folloinwg links:
* [caver.kct.kip7](https://docs.klaytn.com/bapp/sdk/caver-js/api-references/caver.kct/kip7)
* [caver.kct.kip17](https://docs.klaytn.com/bapp/sdk/caver-js/api-references/caver.kct/kip17)
* [caver.utils](https://docs.klaytn.com/bapp/sdk/caver-js/api-references/caver.utils)
* [caver.ipfs](https://docs.klaytn.com/bapp/sdk/caver-js/api-references/caver.ipfs)

Web3.js Similarity
=================
Expand Down
40 changes: 17 additions & 23 deletions TERMS-OF-USE.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,29 @@
# Terms of Use
# Software Terms Of Use

## 1. Your Use of Open Source Software
## 1. Purpose

We may make (but are not obligated to make) the source code of Klaytn Blockchain Network Platform ("Platform"), the software on the Platform, etc. for download as open source software. If you use this open source software, you agree to be bound by and comply with any license that applies to this open source software. You will not indicate that you are associated with us in connection with your use, modifications or distributions of this open source software.
The purpose of these Terms of Use (“Terms”) is to describe and define terms and conditions of users’ using open source software provided by Klaytn Pte. Ltd. (“Klaytn”)(“Software”). Users may easily and effectively utilize the Klaytn blockchain platform (“Platform”) by downloading the Software.

## 2. Services Provided on the Platform
## 2. Consent of the Terms

The Platform is a combination of peer-to-peer subnetworks of nodes transmitting transactions and blocks to execute value transfers and run smart contracts. The Core Cell Network ("CCN"), which is one of the subnetworks that constitute the Platform, verifies and executes transactions that occur on the Platform. The CCN is operated by Klaytn Governance Council, which is a collective group of Core Cell Operators, and Klaytn is not directly involved in any services that are provided in or individual transactions that occur on the Platform.
These Terms shall be applied to users installing and utilizing the Software including but not limited to user contents and further applied to users downloading and utilizing the Software from a third party webpage which is not operated by Klaytn. In this case, it is deemed to be acknowledged and agreed that users shall comply with and be bound by all licenses applied to or belong to the Software by users’ installing and using the Software.

## 3. Your Installation of BApp on the Platform
## 3. Services provided by the Software

Your use of open source software is free of charge. However, you may be required to pay a certain number of KLAY as a transaction fee in order to execute a transaction on the Platform, including the installation of the BApp on the Platform.
The Software provides users with services which enable them to interact with Klaytn blockchain and users may refer to details of such services at Klaytn docs (https://docs.klaytn.com/bapp/sdk/caver-js).

Once transaction is executed successfully and respective block generation is verified successfully by the Platform’s mechanism, the block is irreversibly stored in the blockchain. As such, your installation of the BApp and any other transactions on the Platform, as well as the submission of transaction fee is final and irrevocable.
## 4. Software use and installation

## 4. User Content
While users may install and use the Software free of charge, with respect to transactions during operating a BApp, certain amount of fee (or KLAY) may incur due to the Software’s using the Klaytn blockchain network in accordance with the network’s policy. Furthermore, Klaytn shall not limit or shall not be responsible for all activities/outcomes arising out of or in connection with users’ utilization of the Software. Klaytn does not provide with any express or implied representations or warranties regarding users’ installation and/or utilization of the Software.

If you or the users of your BApp post, upload, input, provide or submit any content on the Platform (collectively, your "User Content"), you must ensure that the User Content provided by you or the users of your BApp at that or at any other time is true, accurate, up to date and complete and that any User Content you or the users of your BApp post, upload, input, provide or submit via the Platform do not breach or infringe legal rights of any third party. To the extent that is technically possible, you agree to prevent, remove or block access of any User Content that you or the users of your BApp post, upload, input, provide or submit via the Platform that violate or may violate legal rights (such as rights of privacy and publicity) of others or any applicable laws or regulations. We do not own, control or endorse any User Content that is transmitted, stored or processed via the Platform or sent to us and we are not responsible or liable for any User Content. We make no assurance that any of Your Content will be secured or that such content will remain confidential.
## 5. Modification of the Terms

You are solely responsible and liable for all of your User Content and for your use of any interactive features, links or information or content on the Platform, and you represent and warrant that (i) you own all intellectual property rights (or have obtained all necessary permissions) to provide your User Content and to grant the licenses in these Terms of Use; (ii) your User Content will not violate any agreements or confidentiality obligations; and (iii) your User Content will not violate, infringe or misappropriate any intellectual property right or other proprietary right, including the right of publicity or privacy, of any person or entity.
If necessary, Klaytn may amend any terms and conditions of these Terms without prior notice to users. The amended Terms shall be effective as of the date when its posting at the root directory of the Github source repository (http://github.com/klaytn/caver-js). Klaytn recommends users to frequently check up the latest Terms as Klaytn does not notify such to an individual user.

You shall not include in User Content, or upload, transmit to or create or include in the Services environment any production data or any sensitive, proprietary, confidential or other data with particular data protection requirements such as personal data or personally identifiable information relating to an identified or identifiable natural person.
## 6. Liability for the use of Software

You are prohibited from using the Platform to post or transmit any threatening, libellous, defamatory, obscene, scandalous, inflammatory, pornographic or profane material, any material that is contrary to applicable local, federal, or international laws and regulations, or any material that could constitute or encourage unlawful conduct. You must ensure that your User Content do not include such materials. We may from time to time monitor or review material transmitted or posted using the Network, and we reserve the right to delete any material we deem inappropriate.

We are under no obligation to do so and assume no responsibility or liability arising from any material transmitted or posted using the Platform.

You understand that any information you or users of your BApp upload to the Platform will be distributed among the blockchain nodes and may not removable due to technical limitations of the blockchain technology.

You are entirely responsible for any and all activities that occur under your account or your BApp (if any). You agree to notify us immediately of any unauthorized use of your User Content, your BApp or account or any other breach of security. We will not be liable for any loss or damages that you may incur as a result of someone else using your User Content, your BApp or account, either with or without your knowledge. However, you could be held liable for losses incurred by us or another party due to someone else using your User Content, your BApp or account. You may not use anyone else’s User Content, your BApp or account at any time without the permission of such person or entity.

By posting, uploading, inputting, providing or submitting your User Content to the Platform, you grant to participants of the Platform and any necessary sub-licensees a non-exclusive, worldwide, perpetual, right and permission to use, reproduce, copy, edit, modify, translate, reformat, create derivative works from, distribute, transmit, publicly perform and publicly display your User Content and sub-license such rights to others.

If we have reason to believe that there is likely to be a breach of security, breach or misuse of the Platform or if you breach any of your obligations under these terms, we may suspend your use of the Platform at any time and for any reason.
Klaytn shall not limit or enforce any action against its provision, publication and/or input of the Software to users except for the cases where a relevant governmental authority requests and/or a certain applicable law dictate. Users shall ultimately be responsible for any and all activities/outcomes arising out of or in connection with the utilization of the Software and therefore Klaytn shall not be responsible for them.

Users shall be responsible for any and all unexpectable problems arising out of or in connection with users’ alteration or deletion of any code (including but not limited to licenses) of the Software which shall include any act which is any misuse of the network or violation of any social policies. Klaytn shall not be responsible for any problems brought by users’ errors and/or omissions when utilizing the Software.

With respect to users’ installation and utilization of the Software, it is deemed to be acknowledged and agreed that users understand and agree that any information including but not limited to users’ personal information may not be removable due to technical limitations of blockchain technology resulted from such information being distributed among klaytn blockchain nodes. Users shall be cautious and be careful to upload, create and/or transmit any personally verifiable information or important data. Klaytn shall not be responsible for any incorrect or wrongful transmission/publication of data.
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ const utils = require('./packages/caver-utils')
const formatters = require('./packages/caver-core-helpers').formatters
const helpers = require('./packages/caver-core-helpers')

const IPFS = require('./packages/caver-ipfs')

const { version } = require('./package.json')

function Caver(provider, net) {
Expand Down Expand Up @@ -77,6 +79,8 @@ function Caver(provider, net) {
this.rpc = new RPC(this)
this.middleware = middleware

this.ipfs = new IPFS()

// overwrite package setProvider
const setProvider = this.setProvider
this.setProvider = (p, n) => {
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "caver-js",
"version": "1.5.2",
"version": "1.5.4",
"description": "caver-js is a JavaScript API library that allows developers to interact with a Klaytn node",
"main": "index.js",
"scripts": {
"test": "npm run build && npm run transactionTest && mocha test/packages/caver.utils.js && mocha test/packages/caver.klay.net.js && npm run accountTest && npm run serTest && npm run walletTest",
"build-all": "gulp all",
"build": "./node_modules/.bin/webpack --mode production --entry ./webpack.js --output dist/caver.min.js",
"build": "./node_modules/.bin/webpack --mode production",
"lint": "./node_modules/.bin/eslint './**/*.js'",
"lintFix": "./node_modules/.bin/eslint './**/*.js' --fix",
"serTest": "mocha test/transactionType/serializationTest.js && mocha test/compressionPublicKey.js && mocha test/encodeContractDeploy.js && mocha test/parseAccountKey.js && mocha test/decodeTransaction.js",
Expand All @@ -30,6 +30,7 @@
"intFDRTest": "mocha --grep INT-FDR/ test/intTest.js",
"intSIGVALITest": "mocha --grep INT-SIGVALI/ test/intTest.js",
"intAPITest": "mocha --grep INT-API/ test/intTest.js",
"intSOLTest": "mocha --grep INT-SOL/00 test/intTest.js && mocha --grep INT-SOL/01 test/intTest.js && mocha --grep INT-SOL/02 test/intTest.js && mocha --grep INT-SOL/03 test/intTest.js && mocha --grep INT-SOL/04 test/intTest.js && mocha --grep INT-SOL/05 test/intTest.js && mocha --grep INT-SOL/06 test/intTest.js && mocha --grep INT-SOL/07 test/intTest.js && mocha --grep INT-SOL/08 test/intTest.js && mocha --grep INT-SOL/09 test/intTest.js && mocha --grep INT-SOL/1 test/intTest.js",
"cover": "npm run build && nyc --silent mocha test/packages/caver.utils.js && nyc --silent --no-clean mocha test/packages/caver.klay.net.js && npm run cover:serialization && npm run cover:wallet && npm run cover:report",
"cover:serialization": "nyc --silent --no-clean npm run serTest",
"cover:wallet": "nyc --silent --no-clean npm run walletTest",
Expand Down Expand Up @@ -67,8 +68,10 @@
"ethers": "^4.0.18",
"ethjs-unit": "0.1.6",
"eventemitter3": "4.0.0",
"ipfs-api": "^26.1.2",
"it-each": "^0.4.0",
"lodash": "^4.17.15",
"multihashes": "^3.0.1",
"node-fetch": "^2.2.0",
"number-to-bn": "1.7.0",
"oboe": "2.1.3",
Expand Down
12 changes: 12 additions & 0 deletions packages/caver-ipfs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "caver-ipfs",
"version": "1.0.0",
"description": "This is a sub package of [caver-js][repo]",
"main": "src/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Klaytn Team",
"license": "LGPL"
}

103 changes: 103 additions & 0 deletions packages/caver-ipfs/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/* eslint-disable class-methods-use-this */
/*
Copyright 2020 The caver-js Authors
This file is part of the caver-js library.
The caver-js library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
The caver-js library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the caver-js. If not, see <http://www.gnu.org/licenses/>.
*/

const fs = require('fs')
const IPFSAPI = require('ipfs-api')
const multihash = require('multihashes')

/**
* Representing a class for uploading and loading files to IPFS.
* @class
*/
class IPFS {
/**
* Create an IPFS.
* @param {string} host The host url.
* @param {number} port The port number to use.
* @param {boolean} ssl With or without SSL.
*/
constructor(host, port, ssl) {
if (host !== undefined && port !== undefined && ssl !== undefined) {
this.setIPFSNode(host, port, ssl)
}
}

/**
* sets a IPFS Node
*
* @param {string} host The host url.
* @param {number} port The port number to use.
* @param {boolean} ssl With or without SSL.
* @return {void}
*/
setIPFSNode(host, port, ssl) {
const protocol = ssl ? 'https' : 'http'
this.ipfs = new IPFSAPI({ host, port, protocol })
}

/**
* adds a file to IPFS
*
* @param {string} path The file path string.
* @return {string}
*/
async add(path) {
if (!this.ipfs) throw new Error(`Please set IPFS Node through 'caver.ipfs.setIPFSNode'.`)
const data = fs.readFileSync(path)
const ret = await this.ipfs.add(data)
return ret[0].hash
}

/**
* gets a file from IPFS
*
* @param {string} hash The file hash string.
* @return {Buffer}
*/
async get(hash) {
if (!this.ipfs) throw new Error(`Please set IPFS Node through 'caver.ipfs.setIPFSNode'.`)
const ret = await this.ipfs.cat(hash)
return ret
}

/**
* converts a hash to hex format.
*
* @param {string} hash The file hash string.
* @return {string}
*/
toHex(hash) {
const buf = multihash.fromB58String(hash)
return `0x${multihash.toHexString(buf)}`
}

/**
* converts from a hex format.
*
* @param {string} hash The file hash string in hex format.
* @return {string}
*/
fromHex(contentHash) {
const hex = contentHash.substring(2)
const buf = multihash.fromHexString(hex)
return multihash.toB58String(buf)
}
}

module.exports = IPFS
Loading

0 comments on commit c9d21fc

Please sign in to comment.