Code Monkey home page Code Monkey logo

caver-js's Introduction

No Maintenance Intended

NO LONGER MAINTAINED

Important

Since the launch of Kaia Blockchain this repository has been parked in favour of the new open-source projects in Kaia's Github. Contributors have now moved there continuing with massive open-source contributions to our blockchain ecosystem. A big thank you to everyone who has contributed to this repository.

For future development and contributions, please refer to the new kaia repository.

For more information about Klaytn's chain merge with Finschia blockchain please refer to the launching of Kaia blockchain - kaia.io.


Go Report Card CircleCI codecov GoDoc Gitter

Klaytn

Official golang implementation of the Klaytn protocol. Please visit KlaytnDocs for more details on Klaytn design, node operation guides and application development resources.

Building from Sources

Building the Klaytn node binaries as well as utility tools, such as kcn, kpn, ken, kbn, kscn, kspn, ksen, kgen, homi and abigen requires both a Go (version 1.14.1 or later) and a C compiler. You can install them using your favorite package manager. Once the dependencies are installed, run

make all (or make {kcn, kpn, ken, kbn, kscn, kspn, ksen, kgen, homi, abigen})

Executables

After successful build, executable binaries are installed at build/bin/.

Command Description
kcn The CLI client for Klaytn Consensus Node. Run kcn --help for command-line flags.
kpn The CLI client for Klaytn Proxy Node. Run kpn --help for command-line flags.
ken The CLI client for Klaytn Endpoint Node, which is the entry point into the Klaytn network (main-, test- or private net). It can be used by other processes as a gateway into the Klaytn network via JSON RPC endpoints exposed on top of HTTP, WebSocket, gRPC, and/or IPC transports. Run ken --help for command-line flags.
kscn The CLI client for Klaytn ServiceChain Consensus Node. Run kscn --help for command-line flags.
kspn The CLI client for Klaytn ServiceChain Proxy Node. Run kspn --help for command-line flags.
ksen The CLI client for Klaytn ServiceChain Endpoint Node. Run ksen --help for command-line flags.
kbn The CLI client for Klaytn Bootnode. Run kbn --help for command-line flags.
kgen The CLI client for Klaytn Nodekey Generation Tool. Run kgen --help for command-line flags.
homi The CLI client for Klaytn Helper Tool to generate initialization files. Run homi --help for command-line flags.
abigen Source code generator to convert Klaytn contract definitions into easy to use, compile-time type-safe Go packages.

Both kcn and ken are capable of running as a full node (default) or an archive node (retaining all historical state).

Running a Core Cell

Core Cell (CC) is a set of one consensus node (CN) and one or more proxy nodes (PNs). Core Cell plays a role of generating blocks in the Klaytn network. We recommend to visit the CC Operation Guide for the details of CC bootstrapping process.

Running an Endpoint Node

Endpoint Node (EN) is an entry point from the outside of the network in order to interact with the Klaytn network. Currently, two official networks are available: Testnet and Mainnet (legacy names: Baobab and Cypress). Please visit the official EN Operation Guide.

Running a Service Chain Node

Service chain node is a node for Service Chain which is an auxiliary blockchain independent from the main chain tailored for individual service requiring special node configurations, customized security levels, and scalability for high throughput services. Service Chain expands and augments Klaytn by providing a data integrity mechanism and supporting token transfers between different chains. Although the service chain feature is under development, we provide the operation guide for testing purposes. Please visit the official document Service Chain Operation Guide. Furthermore, for those who are interested in the Klaytn Service Chain, please check out Klaytn - Scaling Solutions.

License

The Klaytn library (i.e. all code outside of the cmd directory) is licensed under the GNU Lesser General Public License v3.0, also included in our repository in the COPYING.LESSER file.

The Klaytn binaries (i.e. all code inside of the cmd directory) is licensed under the GNU General Public License v3.0, also included in our repository in the COPYING file.

Contributing

As an open source project, Klaytn always welcomes your contribution. Please read our CONTRIBUTING.md for a walk-through of the contribution process.

caver-js's People

Contributors

aeharvlee avatar ayo-klaytn avatar barslev avatar danhumphry avatar dependabot[bot] avatar ehnuje avatar frontalnh avatar fuhaha avatar godtaehee avatar hyunsooda avatar iv0rish avatar jaychoi1736 avatar jeonghonah avatar jimni1222 avatar jongsic avatar jthcast avatar junhoyeo avatar kaikookim avatar kjeom avatar kjhman21 avatar narendracode avatar neoofklaytn avatar nohkwak avatar rlaace423 avatar securekim avatar skqksh avatar sotatek-hautran3 avatar sotatek-tinnnguyen avatar whoisxx avatar yugasun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

caver-js's Issues

CI failure

Describe the bug
CI is failed due to invalid version string.

How to reproduce
CI failed.

Expected behavior
If npm test is successful, CI should passed.

Attachments
If applicable, add data, logs or screenshots to help explain your problem.

Environment (please complete the following information)

  • caver-js 1.0.0
  • macOS/10.14.5
  • node.js 10.15.3

Additional context

Conflict babel-polyfill with multiple babel-polyfill

Describe the bug
In caver-js babel-polyfill is used as a global.
So, if other application or web site use babel-polyfill, then conflict is occured.

How to reproduce
Using caver-js with extention or web page which include babel-polyfill

Expected behavior
No conflict, no warning.

Attachments
If applicable, add data, logs or screenshots to help explain your problem.

Environment (please complete the following information)

  • caver-js v1.0.1-rc.6
  • macOS/10.14

Additional context
Add any other context about the problem here.

Upgrade version of websocket

Is your request related to a problem? Please describe.
The webSocket used in caver-js uses a version that is forked into personal github repository rather than being listed in npm.
This is causing an error in CircleCI, and will modify the dependency to use the version of the webSocket library that comes in npm.

Describe the solution you'd like
Modify the dependency to use the latest version of npm.
(https://www.npmjs.com/package/websocket)

Describe alternatives you've considered
Modify the dependency to use a version closer to the latest version of npm.

Additional context
OpenZeppelin/openzeppelin-sdk#929
web3/web3.js#2863
web3/web3.js@b27eff4

Change error message

Is your request related to a problem? Please describe.
Change error message with wallet.add

Describe the solution you'd like
Account is existed -> Account exists

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Error when contract call via Contract instance with account in Node.

Describe the bug
When use Contract instance to call contract with account in Node, "Error: Only Legacy transactions can be signed on a Klaytn node!" error is occured.

How to reproduce
// imoprt key and unlock the account in Node.
await caver.klay.personal.importRawKey(senderPrvKey, 'passphrase')
await caver.klay.personal.unlockAccount(senderAddress, 'passphrase')

// Call contract with Contract instacne
const contractInst = new caver.klay.Contract(helloContractABI)
contractInst.options.address = contractAddress
const execReceipt = await contractInst.methods.say().send({
from: senderAddress,
gas: 30000,
})

Expected behavior
Without error, contract has to be called.

Attachments
If applicable, add data, logs or screenshots to help explain your problem.

Environment (please complete the following information)

  • caver-js v1.0.1-rc.7
  • macOS/10.14

Additional context
Add any other context about the problem here.

webpack scrypt.js: Critical dependency: the request of a dependency is an expression

Describe the bug
A warning is issued to build vue-app using 'carver-js v1.2.1'

How to reproduce

Expected behavior

Attachments
**** LOG ****
WARNING Compiled with 1 warnings
warning in ./node_modules/caver-js/packages/caver-klay/caver-klay-accounts/src/scrypt.js

Critical dependency: the request of a dependency is an expression

Environment (please complete the following information)
caver-js v1.2.1
node v10.16.3
webpack v4.40.2

  • OS and its version [windows10]

Additional context

There was the same problem with web3.js.
The problem that occurred in v1.2.1 appears to have disappeared since v1.2.2
Please check the link.
web3/web3.js#3018

Implement decode transaction

Is your request related to a problem? Please describe.
Decode transaction from rawTransaction.

Describe the solution you'd like
caver.klay.decodeTransaction should return result of decode transaction.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Multi provider problem with caver.klay.net

Describe the bug
If you create and use multiple Caver instances, you may see a phenomenon that seems to be overwritten by the last instance created.

How to reproduce
This phenomenon can be reproduced by using the rpc call of caver.klay.net.
For example, please refer to below.

const Caver = require('../index')
const baobab = new Caver('https://api.baobab.klaytn.net:8651/')
const cypress = new Caver('https://api.cypress.klaytn.net:8651/')
console.log(await baobab.klay.net.getId()) // 8217
console.log(await cypress.klay.net.getId()) // 8217

Expected behavior
The network id of Baobab testnet is 1001.
And network id of Cypress network is 8217.

Attachments
If applicable, add data, logs or screenshots to help explain your problem.

Environment (please complete the following information)

  • caver-js v1.0.1-rc.5
  • macOS/10.14
  • node v10.15.3

Additional context
Add any other context about the problem here.

Adding test code for setting nonce with pending tag

Is your request related to a problem? Please describe.
When set nonce to transaction, caver-js use 'pending' tag with caver.klay.getTransactionCount.
This setting nonce logic is used with three functions named signTransaction, feePayerSignTransaction and getRawTransactionWithSignatures.

But for now test code is existed only for signTransaction.
So test codes are needed for other functions.

Describe the solution you'd like
Adding test code for setting nonce with pending tag.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

What's the rules to add test case

When I want to add some test case between '...-ETC-097' and '...-ETC-098'

how should I mark test name

example

describe('caver.utils.randomHex', () => {
    context('CAVERJS-UNIT-ETC-097: input: valid value', () => {
          // some test codes
        })
    })

    context('CAVERJS-UNIT-ETC-098: input: invalid value', () => {
          // some test codes
    })
})

describe('caver.utils.isBN', () => {
    context('CAVERJS-UNIT-ETC-099: input: BN type', () => {
          // some test codes
    })

Modify intTest for applying modification of caver.klay.Contract

Describe the bug
Solidity test of intTest does not work due to changes in Contract package.

How to reproduce
Operate INT-SOL test.

Expected behavior
Testing without error.

Attachments
If applicable, add data, logs or screenshots to help explain your problem.

Environment (please complete the following information)

  • caver-js v1.0.1-rc.10
  • macOS/10.14

Additional context
Add any other context about the problem here.

Bug when recovering rawTransaction created with trimLeadingZeroed signature.

Describe the bug

This bug is related to recoverTransaction in caver-js.
The signature (v, r, s) used to create the rawTransaction is used in the form of even lengths with the leading zeros removed.
However, recoverTransaction does not handle this case.

How to reproduce

The specific circumstances under which the error may occur are described below.
const txObj = {
from: '0x13b0d8316F0c3cE0C3C51Ebb586A14d7d90112fD',
nonce: '0x0',
to: '0x30d8d4217145ba3f6cde24ec28c64c9120f2bdfb',
gas: 900000,
gasPrice: 25000000000,
value: '0x1',
chainId: 10000,
}
await caver.klay.accounts.signTransaction(txObj, '0x72d72a46401220f08ccb1b17b550feb816840f2f8ce86361e7ee54ac7a9ee6d8')

=> signature
0x432ad3d8f602c9654878c7b8709313654b198fb0633a91787eaa250da5de9c41005b661bbe725bbbb359c5bca3413d38e8df92a76f9112cf9f4105116206e6104e44
=> [v, r, s]
[ '0x4e44',
'0x432ad3d8f602c9654878c7b8709313654b198fb0633a91787eaa250da5de9c41',
'0x005b661bbe725bbbb359c5bca3413d38e8df92a76f9112cf9f4105116206e610' ]
=> rawTransaction
0xf866808505d21dba00830dbba09430d8d4217145ba3f6cde24ec28c64c9120f2bdfb0180824e44a0432ad3d8f602c9654878c7b8709313654b198fb0633a91787eaa250da5de9c419f5b661bbe725bbbb359c5bca3413d38e8df92a76f9112cf9f4105116206e610

caver.klay.accounts.recoverTransaction(result.rawTransaction)
=> '0x94DA8E88375FAF099Fced88E390a70Ff0d3E89Af'

Expected behavior

caver.klay.accounts.recoverTransaction(result.rawTransaction) has to return '0x13b0d8316F0c3cE0C3C51Ebb586A14d7d90112fD'

Attachments
If applicable, add data, logs or screenshots to help explain your problem.

Environment (please complete the following information)

  • caver-js v1.0.0
  • macOS/10.14
  • node v10.15.3

Additional context
Add any other context about the problem here.

Implicit library behavior for defining a web socket

https://github.com/klaytn/caver-js/blob/master/packages/caver-core-method/src/index.js#L512 here, the library refers to the presence or absence of the .on method from the provider and thereby determines whether the provider is a web socket or not. But since the provider is an external class, we cannot guarantee that even the HTTP provider will not have this method, because everyone can override it.

For example, metamask adds this method so that even for an HTTP provider it is possible to provide subscriptions by wrapping interval requests into a subscription.

It seems to us that this behavior is not obvious and can lead to unexpected results.

Link in README.md file

Describe the bug
The Klaytn Docs directory is changed, so links in README.md file should be edited.

How to reproduce
Markdown file link is broken

Expected behavior
Connect to valid Klaytn Docs page

Attachments
If applicable, add data, logs or screenshots to help explain your problem.

Environment (please complete the following information)

  • caver-js 1.0.0
  • macOS 10.14.5
  • node v10.15.3

Additional context
Add any other context about the problem here.

Implementation of decompression public key method

Is your request related to a problem? Please describe.
When the RLP-encoded transaction is decoded via caver.klay.decodeTransaction, the compressed public key is returned.
We need a function that can convert it to an uncompressed public key.

Describe the solution you'd like
Implementation of decompress public key function in caver.utils

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Include dist files to npm

Is your request related to a problem? Please describe.
In caver-js library, dist files are not included yet.
For convinience, including dist files to npm caver-js libraray is better.

Describe the solution you'd like
Include dist files to npm.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Wrong error message on malformed transaction

Describe the bug

 Error: Only Legacy transactions can be signed on a Klaytn node!

How to reproduce
There are two ways to reproduce this bug:

  • Works perfrect with attached code (may occurs an error since the account does not have any KLAY)
  • Case1: Change feePayer to feePayer: '0xad7c07eab1e56fbbb976fd5377e5088ec5528cd9'
  • Case2: Uncomment //gasPrice: '999999999999999',

Expected behavior
The error message should indicate exactly what went wrong.

Attachments

"caver-js": {
      "version": "1.2.0",
const Caver = require('caver-js');

const caver = new Caver('https://api.baobab.klaytn.net:8651/');
const cred = require('./cred.json');

caver.klay.getNodeInfo().then(console.log);

caver.klay.accounts.wallet.add('0x5849a0f62008833b708af0bf4886e5deec0ea51bb405bf02a7ed79d4c43e5797');
caver.klay.accounts.wallet.add({
    address: "0x48649c3beb3e5abf532b0626ce72c27cb64e012f",
    privateKey: "0x7b04975dea529019127697fb267a72e2bb3c26c3e85ae358864baa84a2b56d47"
});

const contract = new caver.klay.Contract(require('./abi.json'), '0xcd7589F4641B6d7f7f9ab08bA1d4fB5985658A0a', {
    from: cred.address,
    gasPrice: '25000000000'
});


async function createTx(tx) {
    const account = caver.klay.accounts.wallet[0];
    tx.from = account.address;
    console.log(account.address);
    const signed = await account.signTransaction(tx);
    console.log(signed);
    return signed.rawTransaction;
}

async function test() {
    const input = contract.methods.voteMob("test", 0, 0).encodeABI();
    const tx = await createTx({
        type: 'FEE_DELEGATED_SMART_CONTRACT_EXECUTION',
        to: '0xcd7589F4641B6d7f7f9ab08bA1d4fB5985658A0a',
        //gasPrice: '999999999999999',
        value: '0',
        data: input,
        gas: 900000
    });

    const resp = await caver.klay.sendTransaction({
        senderRawTransaction: tx.toString(),
        feePayer: '0x48649c3beb3e5abf532b0626ce72c27cb64e012f',
    });

    console.log(resp);
}

test();

Why don't you replace Underscore to Lodash.

Is your request related to a problem? Please describe.

  • To increase performance of project

Describe the solution you'd like

Describe alternatives you've considered

  • Import lodash than underscore
  • migration methods
  • check testcases

Additional context

  • Lodash is normaly bigger than Underscore, but I think It's not problem on this project
  • In my test Lodash is faster than Underscore
  • Lots of update are in Lodash
  • I wonder your opinion

wallet.add does not work properly on fee delegation account.

Describe the bug
caver.klay.accounts.wallet.add(PRIVATE_KEY) does not work with fee delegation account.

How to reproduce
Steps to reproduce the behavior:

Expected behavior
Both method should work or throw the proper exception.

Attachments

This may not work

caver.klay.accounts.wallet.add('SOME_FEE_DELEGATION_KEY');

This should work

caver.klay.accounts.wallet.add({
  address: 'ADDR',
  privateKey: 'SOME_FEE_DELEGATION_KEY'
});

Modify getNetworkType logic with Klaytn network type

Describe the bug
Now caver.klay.net.getNetworkType() return Ethereum network type such as 'morden, 'ropsten', 'rinkeby', 'koven'.
So modify 'getNetworkType' function to return Klaytn network type.

How to reproduce
caver.klay.net.getNetworkType().then(console.log)

Expected behavior
Return 'cypress' or 'baobab' or 'private' depends on chain id and genesis hash.

Attachments
If applicable, add data, logs or screenshots to help explain your problem.

Environment (please complete the following information)

  • caver-js v1.0.1-rc.3
  • macOS/10.14
  • node v10.15.3

Additional context
Add any other context about the problem here.

Handling http provider response is null

Describe the bug
If you do not set timeout when using http-provider in caver-js, you will not get a response back if the response of the request is null.
If you set the timeout value but the response is null, TIMEOUT ERROR is returned.
If the response is null, the logic must be modified to return the corresponding error.

How to reproduce

  1. Import caver-js module
    const Caver = require('./index')
  2. Set host url with not Klaytn Node
    const caver = new Caver('http://localhost:8551/')
  3. Send request
    caver.klay.getNodeInfo()
    .then((ret)=>console.log(ret))
    .catch((e)=>{console.log(e)})

Expected behavior
Return invalid response error (Error: Invalid response: null)

Attachments
If applicable, add data, logs or screenshots to help explain your problem.

Environment (please complete the following information)

  • caver-js v1.0.0
  • macOS/10.14.5
  • node v.10.15.3

Additional context

Enable circle-ci

Is your request related to a problem? Please describe.
Currently, circle-ci is not employed for caver-js.

Describe the solution you'd like
Add .circle-ci/config.yml.
For now, it has only two functions

  1. Executes npm test when a commit is pushed.
  2. Publish to npm when a tag is pushed.

Describe alternatives you've considered
No other CIs are considered.

Additional context

SendTransaction with callback

Describe the bug
When defining a callback and passing it as a parameter to sendTransaction, the callback is called twice as a result of the signTransaction and the transaction hash.

How to reproduce
You can reproduce it by calling sendTransaction with the callback parameter.

Expected behavior
The callback should be called only once with the transaction hash.

Attachments
If applicable, add data, logs or screenshots to help explain your problem.

Environment (please complete the following information)

  • caver-js v1.1.2
  • macOS/10.14

Additional context
This error is caused by passing a callback to fix a bug where there was no response when signTransaciton encountered an error when calling sendTransaction.
When executing sendTransaction, the result value of calling callback is not the result of signTransaction. Therefore, it should be implemented by logic that calls callback separately when error occurs without passing callback.

Implement util functions related with hex prefix

Is your request related to a problem? Please describe.
isHexPrefixed, addHexPrefix, stripHexPrefix
Those functions need to be support by caver.utils

Describe the solution you'd like
Implement isHexPrefixed, addHexPrefix, stripHexPrefix functions at utils package

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Implement toBuffer function in caver utils

Is your request related to a problem? Please describe.
Implement toBuffer function in caver.utils

Describe the solution you'd like
Depends on input's type, toBuffer function should convert input to Buffer correctly.

Describe alternatives you've considered
Use another library?

Additional context
Add any other context or screenshots about the feature request here.

CI test failed with timeout sometimes

Is your request related to a problem? Please describe.
CI test failed sometimes because of timeout.

Describe the solution you'd like
Set timeout to feePayerSignTransaction test codes.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

setProvider cannnot set currentProvider properly

Describe the bug
If the provider is set with setProvider, the currentProvider will not apply.

How to reproduce
Steps to reproduce the behavior:
const caver = new Caver()
caver.klay.setProvider(new Caver.providers.HttpProvider('https://api.baobab.klaytn.net:8651/'))
caver.klay.currentProvider // this will be null still

Expected behavior
When setProvider, currentProvider has to be set

Attachments
If applicable, add data, logs or screenshots to help explain your problem.

Environment (please complete the following information)

  • caver-js v1.1.2-rc.1
  • macOS/10.14

Additional context
Add any other context about the problem here.

Include dist folder in npm

Is your request related to a problem? Please describe.
When install caver-js, there is not dist folder which includes build files.

Describe the solution you'd like
Include build files in npm

Describe alternatives you've considered
Guide 'npm run build' seperately

Additional context
Add any other context or screenshots about the feature request here.

isContractDeployment bug

Describe the bug
With current condition check, account update transaction will be discriminated contract deploy transaction.
This happen because of 'coverInitialTxValue' funciton.

How to reproduce
Make acocunt update transaction and try to send.

Expected behavior
Account update transaction should be operated without error.

Attachments
If applicable, add data, logs or screenshots to help explain your problem.

Environment (please complete the following information)

  • caver-js v1.0.1-rc.7 (only in 7f6ebe3 commit after v1.0.1-rc.7)
  • macOS/10.14

Additional context
Add any other context about the problem here.

Error: Cannot find module 'semver'

Describe the bug
can not find moudle semver.

error message.

internal/modules/cjs/loader.js:797
    throw err;
    ^

Error: Cannot find module 'semver'
Require stack:
- /Users/**/Desktop/test/node_modules/caver-js/packages/caver-klay/caver-klay-accounts/src/scrypt.js
- /Users/**/Desktop/test/node_modules/caver-js/packages/caver-klay/caver-klay-accounts/src/index.js
- /Users/**/Desktop/test/node_modules/caver-js/packages/caver-klay/src/index.js
- /Users/**/Desktop/test/node_modules/caver-js/index.js
- /Users/**/Desktop/test/test.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:794:15)
    at Function.Module._load (internal/modules/cjs/loader.js:687:27)
    at Module.require (internal/modules/cjs/loader.js:849:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/Users/kiheon/Desktop/test-event-logs/node_modules/caver-js/packages/caver-klay/caver-klay-accounts/src/scrypt.js:30:18)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Module.require (internal/modules/cjs/loader.js:849:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/**/Desktop/test/node_modules/caver-js/packages/caver-klay/caver-klay-accounts/src/scrypt.js',
    '/Users/**/Desktop/test/node_modules/caver-js/packages/caver-klay/caver-klay-accounts/src/index.js',
    '/Users/**/Desktop/test/node_modules/caver-js/packages/caver-klay/src/index.js',
    '/Users/**/Desktop/test/node_modules/caver-js/index.js',
    '/Users/**/Desktop/test/test.js'
  ]
}

How to reproduce
Steps to reproduce the behavior:

const Caver = require('caver-js')

const caver = new Caver('https://api.baobab.klaytn.net:8651/')

caver.klay.getTransaction('0x2d26f602cfbb4c662931592bf2c4ee18d29f09683be5b9e8d589ff935fca0b97')
  .then(console.log);

Environment (please complete the following information)

  • nodejs : 12.13.0
  • caver-js : 1.2.0
  • os : mac 10.14.6

Additional context

It works well after I install semver.

npm i --S semver

I think it should be added semver to package.json in caver-js.

EventEmitter with 'transactionHash'

Describe the bug
If you do a 'sendTransaction' and add a listener for 'transactionHash' via eventEmitter, the transactionHash event is called twice.
This is called once for the object resulting from signTransaction, and once for transactionHash.

How to reproduce
Submit the transaction and print the result using eventEmitter.
caver.klay.sendTransaction(transactionObject).on('transactionHash', console.log)

Expected behavior
The event must be called once with transactionHash.

Attachments
If applicable, add data, logs or screenshots to help explain your problem.

Environment (please complete the following information)

  • caver-js v1.0.1-rc.3
  • macOS/10.14
  • node v10.15.3

Additional context
Add any other context about the problem here.

Version up with eventemitter3

Is your request related to a problem? Please describe.
Caver-js is using the v1.1.1 version of eventemitter3.
Update eventemitter3 to the latest version (v4.0.0).
In the release notes of eventemitter3, the distribution for performance improvement was done after version 1.1.1.

Describe the solution you'd like
Update eventemitter3 version to 4.0.0.

Describe alternatives you've considered
Update to the version close with latest version.

Additional context

web3.js also updated version of eventemitter3 before, but it did not seem to update because of vulnerability issue in particular.
Note that we will leave the link below.
web3/web3.js@48ccfcb?diff=unified
web3/web3.js#2905

npm install fail on node v13.2.0

Describe the bug

  • npm install fail on node v13.2.0

How to reproduce

  • command line : npm install caver-js

Expected behavior

  • should work on node v13.2.0

Attachments

> [email protected] install /usr/src/app/node_modules/keccak
> npm run rebuild || echo "Keccak bindings compilation fail. Pure JS implementation will be used."


> [email protected] rebuild /usr/src/app/node_modules/keccak
> node-gyp rebuild

make: Entering directory '/usr/src/app/node_modules/keccak/build'
  CXX(target) Release/obj.target/keccak/src/addon.o
../src/addon.cc: In static member function 'static Nan::NAN_METHOD_RETURN_TYPE KeccakWrapper::Initialize(Nan::NAN_METHOD_ARGS_TYPE)':
../src/addon.cc:37:47: error: no matching function for call to 'v8::Value::IntegerValue()'
     unsigned int rate = info[0]->IntegerValue();
                                               ^
In file included from /root/.cache/node-gyp/13.2.0/include/node/node.h:63:0,
                 from ../src/addon.cc:1:
/root/.cache/node-gyp/13.2.0/include/node/v8.h:2774:40: note: candidate: v8::Maybe<long int> v8::Value::IntegerValue(v8::Local<v8::Context>) const
   V8_WARN_UNUSED_RESULT Maybe<int64_t> IntegerValue(
                                        ^~~~~~~~~~~~
/root/.cache/node-gyp/13.2.0/include/node/v8.h:2774:40: note:   candidate expects 1 argument, 0 provided
../src/addon.cc:38:51: error: no matching function for call to 'v8::Value::IntegerValue()'
     unsigned int capacity = info[1]->IntegerValue();
                                                   ^
In file included from /root/.cache/node-gyp/13.2.0/include/node/node.h:63:0,
                 from ../src/addon.cc:1:
/root/.cache/node-gyp/13.2.0/include/node/v8.h:2774:40: note: candidate: v8::Maybe<long int> v8::Value::IntegerValue(v8::Local<v8::Context>) const
   V8_WARN_UNUSED_RESULT Maybe<int64_t> IntegerValue(
                                        ^~~~~~~~~~~~
/root/.cache/node-gyp/13.2.0/include/node/v8.h:2774:40: note:   candidate expects 1 argument, 0 provided
../src/addon.cc: In static member function 'static Nan::NAN_METHOD_RETURN_TYPE KeccakWrapper::AbsorbLastFewBits(Nan::NAN_METHOD_ARGS_TYPE)':
../src/addon.cc:56:48: error: no matching function for call to 'v8::Value::IntegerValue()'
     unsigned char bits = info[0]->IntegerValue();
                                                ^
In file included from /root/.cache/node-gyp/13.2.0/include/node/node.h:63:0,
                 from ../src/addon.cc:1:
/root/.cache/node-gyp/13.2.0/include/node/v8.h:2774:40: note: candidate: v8::Maybe<long int> v8::Value::IntegerValue(v8::Local<v8::Context>) const
   V8_WARN_UNUSED_RESULT Maybe<int64_t> IntegerValue(
                                        ^~~~~~~~~~~~
/root/.cache/node-gyp/13.2.0/include/node/v8.h:2774:40: note:   candidate expects 1 argument, 0 provided
../src/addon.cc: In static member function 'static Nan::NAN_METHOD_RETURN_TYPE KeccakWrapper::Squeeze(Nan::NAN_METHOD_ARGS_TYPE)':
../src/addon.cc:64:43: error: no matching function for call to 'v8::Value::IntegerValue()'
     size_t length = info[0]->IntegerValue();
                                           ^
In file included from /root/.cache/node-gyp/13.2.0/include/node/node.h:63:0,
                 from ../src/addon.cc:1:
/root/.cache/node-gyp/13.2.0/include/node/v8.h:2774:40: note: candidate: v8::Maybe<long int> v8::Value::IntegerValue(v8::Local<v8::Context>) const
   V8_WARN_UNUSED_RESULT Maybe<int64_t> IntegerValue(
                                        ^~~~~~~~~~~~
/root/.cache/node-gyp/13.2.0/include/node/v8.h:2774:40: note:   candidate expects 1 argument, 0 provided
../src/addon.cc: In static member function 'static Nan::NAN_METHOD_RETURN_TYPE KeccakWrapper::Copy(Nan::NAN_METHOD_ARGS_TYPE)':
../src/addon.cc:75:82: error: no matching function for call to 'v8::Value::ToObject()'
     KeccakWrapper* to = Nan::ObjectWrap::Unwrap<KeccakWrapper>(info[0]->ToObject());
                                                                                  ^
In file included from /root/.cache/node-gyp/13.2.0/include/node/node.h:63:0,
                 from ../src/addon.cc:1:
/root/.cache/node-gyp/13.2.0/include/node/v8.h:2754:44: note: candidate: v8::MaybeLocal<v8::Object> v8::Value::ToObject(v8::Local<v8::Context>) const
   V8_WARN_UNUSED_RESULT MaybeLocal<Object> ToObject(
                                            ^~~~~~~~
/root/.cache/node-gyp/13.2.0/include/node/v8.h:2754:44: note:   candidate expects 1 argument, 0 provided
keccak.target.mk:127: recipe for target 'Release/obj.target/keccak/src/addon.o' failed
make: Leaving directory '/usr/src/app/node_modules/keccak/build'
make: *** [Release/obj.target/keccak/src/addon.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:270:12)
gyp ERR! System Linux 4.9.184-linuxkit
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/src/app/node_modules/keccak
gyp ERR! node -v v13.2.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] rebuild: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] rebuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-12-02T01_00_06_241Z-debug.log
Keccak bindings compilation fail. Pure JS implementation will be used.

> [email protected] install /usr/src/app/node_modules/secp256k1
> npm run rebuild || echo "Secp256k1 bindings compilation fail. Pure JS implementation will be used."


> [email protected] rebuild /usr/src/app/node_modules/secp256k1
> node-gyp rebuild

make: Entering directory '/usr/src/app/node_modules/secp256k1/build'
  CXX(target) Release/obj.target/secp256k1/src/addon.o
  CXX(target) Release/obj.target/secp256k1/src/privatekey.o
../src/privatekey.cc: In function 'Nan::NAN_METHOD_RETURN_TYPE privateKeyNegate(Nan::NAN_METHOD_ARGS_TYPE)':
../src/privatekey.cc:73:61: warning: ignoring return value of 'int secp256k1_ec_privkey_negate(const secp256k1_context*, unsigned char*)', declared with attribute warn_unused_result [-Wunused-result]
   secp256k1_ec_privkey_negate(secp256k1ctx, &private_key[0]);
                                                             ^
  CXX(target) Release/obj.target/secp256k1/src/publickey.o
  CXX(target) Release/obj.target/secp256k1/src/signature.o
  CXX(target) Release/obj.target/secp256k1/src/ecdsa.o
  CXX(target) Release/obj.target/secp256k1/src/ecdh.o
  CC(target) Release/obj.target/secp256k1/src/secp256k1-src/src/secp256k1.o
  CC(target) Release/obj.target/secp256k1/src/secp256k1-src/contrib/lax_der_parsing.o
  CC(target) Release/obj.target/secp256k1/src/secp256k1-src/contrib/lax_der_privatekey_parsing.o
  SOLINK_MODULE(target) Release/obj.target/secp256k1.node
  COPY Release/secp256k1.node
make: Leaving directory '/usr/src/app/node_modules/secp256k1/build'

> [email protected] install /usr/src/app/node_modules/websocket
> (node-gyp rebuild 2> builderror.log) || (exit 0)

make: Entering directory '/usr/src/app/node_modules/websocket/build'
  CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
bufferutil.target.mk:110: recipe for target 'Release/obj.target/bufferutil/src/bufferutil.o' failed
make: Leaving directory '/usr/src/app/node_modules/websocket/build'
npm WARN [email protected] No description
npm WARN [email protected] No repository field.

Environment (please complete the following information)

  • caver-js : ^1.2.1
  • Dockerfile : FROM node:13.2.0

Additional context

caver.klay.decodeTransaction cannot handling multi signatures

Describe the bug
caver.klay.decodeTransaction cannot handling multi signatures

How to reproduce
Try to decode transaction which has multi signatures

Expected behavior
Return result of decoding which has multi signatures

Attachments
If applicable, add data, logs or screenshots to help explain your problem.

Environment (please complete the following information)

  • caver-js v1.1.2-rc.1
  • macOS/10.14

Additional context
Add any other context about the problem here.

Replace deprecated new Buffer

Is your request related to a problem? Please describe.
new Buffer is deprecated and unsafe.

Describe the solution you'd like
So replace new Buffer to Buffer.from

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

http timeout options

Is your request related to a problem? Please describe.
I've been testing caver.getBlock function.
It does not respond when it requests many times quickly or at the same time.

const Caver = require('caver-js');

const cluster = require('cluster');
const { cpus } = require('os');

const TESTNET = 'https://api.baobab.klaytn.net:8651';

const caver = new Caver(TESTNET);

const LIMIT = 10000;
const CHUNCK_SIZE = 100;

const getTransactions = count => {
  return async () => {
    if (count >= LIMIT) {
      console.log('done');
      process.exit(0)
    }
    let tasks = Array.from({ length: CHUNCK_SIZE }, (v, k) => count + 1).map(
      blockNumber => caver.klay.getBlock(blockNumber, true),
    );

    console.log('from blocknumber :', count + 1);
    const results = await Promise.all(tasks);
    console.log('to blocknumber :', count + CHUNCK_SIZE);

    count += CHUNCK_SIZE;

    // process.nextTick(getTransactions(count)); // Test with nextTick
  };
};

if (cluster.isMaster) {
  cpus().forEach(() => {
    cluster.fork();
  });
} else {
  let count = 0;
  // getTransactions(count)(); // Test with nextTick
  setInterval(getTransactions(count), 10); // test with setInterval
}

I tested with "nextTick" and "setInterval". When "CHUNK SIZE" becomes large, "caver.klay.getBlock" does not respond.

Describe the solution you'd like
In my opinion, the simple way for now is that just pass timeout options when create Caver instance If there is no reason why "httpProvider" should not have "timeout" option.

before

// test.js
const caver = new Caver(TESTNET); 

p = new this.providers.HttpProvider(p);

after

// test.js
const caver = new Caver(TESTNET, {timeout: 1000}); // pass timeout.

// index.js
p = new this.providers.HttpProvider(p, net); // pass net.

Describe alternatives you've considered
consider to change http provider request library "xhr2-cookies" to others.

Additional context
Add any other context or screenshots about the feature request here.

Klaytn docs link

Describe the bug
In README.md file, link connected to count BApp is broken.

How to reproduce
In README.md file, click link to [count App]

Expected behavior
No error with page.

Attachments
If applicable, add data, logs or screenshots to help explain your problem.

Environment (please complete the following information)

  • caver-js v1.0.1-rc.8
  • macOS/10.14

Additional context
Add any other context about the problem here.

Use contract instance with account in Node.

Describe the bug
When use caver.klay.Contract instance to deploy or execute smart contract via account in Node, if there is accounts in caver.klay.accounts.wallet, "Only Legacy transactions can be signed on a Klaytn node!" error is occured.

How to reproduce

  1. Add account in caver.klay.accounts.wallet
  2. Add account in Klaytn Node
  3. Try to deploy smart contract via caver.klay.Contract instance with account in Node as a from

Expected behavior
Without error, deployment should be operated.

Attachments
If applicable, add data, logs or screenshots to help explain your problem.

Environment (please complete the following information)

  • caver-js v1.0.1-rc.8
  • macOS/10.14

Additional context
Add any other context about the problem here.

stripHexPrefix sometimes not working properly

Describe the bug
Sometimes the expected result with the stripHexPrefix function is different.

How to reproduce
caver.utils.stripHexPrefix('0x2de402c403eef2b7bdb39d2988e929117304e82f577d98bff6f8bf07ba08200e0x000x2dbe5e9c134afbbda42c04c94ae630a59cfd0672')

0x2de402c403eef2b7bdb39d2988e929117304e82f577d98bff6f8bf07ba08200e0x000x2dbe5e9c134afbbda42c04c94ae630a59cfd0672

Expected behavior
caver.utils.stripHexPrefix('0x2de402c403eef2b7bdb39d2988e929117304e82f577d98bff6f8bf07ba08200e0x000x2dbe5e9c134afbbda42c04c94ae630a59cfd0672')

2de402c403eef2b7bdb39d2988e929117304e82f577d98bff6f8bf07ba08200e0x000x2dbe5e9c134afbbda42c04c94ae630a59cfd0672

Attachments
If applicable, add data, logs or screenshots to help explain your problem.

Environment (please complete the following information)

  • caver-js v1.1.2
  • macOS/10.14

Additional context
Add any other context about the problem here.

Build fail with Circle CI at build step

Describe the bug
I added build step in workflow_publish, but there is no install step in there.
So "sh: 1: gulp: not found" error is occured.

How to reproduce
Try to publish caver-js module through circle ci.

Expected behavior
caver-js can be published successfully without error.

Attachments
If applicable, add data, logs or screenshots to help explain your problem.

Environment (please complete the following information)

  • caver-js v1.0.1-rc.10
  • macOS/10.14

Additional context
Error in Circle CI

#!/bin/bash -eo pipefail
npm run build

[email protected] build /home/circleci/repo
gulp default

sh: 1: gulp: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] build: gulp default
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR! /home/circleci/.npm/_logs/2019-08-13T05_17_41_347Z-debug.log
Exited with code 1

Support various type of AccountKey in caver-js

Is your request related to a problem? Please describe.
There are many account key types with Klaytn network.(https://docs.klaytn.com/klaytn/design/accounts#account-key)

The caver-js also can support those keys.

Describe the solution you'd like
Implement new structures and function for those.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Remove dependency of scrypt.js

Is your request related to a problem? Please describe.
Remove dependency of scrypt.js

Describe the solution you'd like
Replace scrypt.js to scryptsy

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Omit the step of getting information that is not needed when feePayer signs.

Is your request related to a problem? Please describe.
When feePayer signs, if there is no chainId, nonce and gasPrice information, the caver requests the Klaytn Node for information and sets the transaction object based on the value received. However, since the information actually used when signing feePayer is chainId, nonce and gasPrice are unnecessary information.

So if feePayer signs, it would be nice to separate the logic so that only chainId is used.

Describe the solution you'd like
Separate the logic so that only chainId is used for signing with feePayer.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Describe recommeded Node version.

Is your request related to a problem? Please describe.
I received feedback to specify the recommended node version.

Describe the solution you'd like
Describe recommeded Node version in README.md file.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
This contents has to be added to Klaytn Docs too.

How can I set config for test

To test caver-js, it needs some env-config to use like 'process.env.privateKey'

Please explain how to set config them

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.