├── .babelrc ├── .circleci ├── config.yml └── version.sh ├── .eslintignore ├── .eslintrc.js ├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── ---bug-report.md │ ├── ---enhancement.md │ └── --questions-and-others.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── CLA.yml │ └── CodeQL.yml ├── .gitignore ├── .gitmodules ├── .npmignore ├── .prettierignore ├── .prettierrc.js ├── CONTRIBUTING.md ├── Changelog.md ├── Dockerfile ├── LICENSE ├── README.md ├── TERMS-OF-USE.md ├── assets └── logo │ └── caver-js.png ├── breakingChanges.md ├── caver-cli ├── index.js └── package.json ├── cli.js ├── index.js ├── jsdoc.json ├── package-lock.json ├── package.json ├── packages ├── caver-abi │ ├── README.md │ ├── package.json │ └── src │ │ └── index.js ├── caver-account │ ├── package.json │ └── src │ │ ├── accountKey │ │ ├── accountKeyDecoder.js │ │ ├── accountKeyFail.js │ │ ├── accountKeyHelper.js │ │ ├── accountKeyLegacy.js │ │ ├── accountKeyPublic.js │ │ ├── accountKeyRoleBased.js │ │ ├── accountKeyWeightedMultiSig.js │ │ ├── weightedMultiSigOptions.js │ │ └── weightedPublicKey.js │ │ └── index.js ├── caver-contract │ ├── package.json │ └── src │ │ └── index.js ├── caver-core-helpers │ ├── package.json │ └── src │ │ ├── constants.js │ │ ├── errors.js │ │ ├── formatters.js │ │ ├── index.js │ │ ├── payloadTransformer.js │ │ └── validateFunction.js ├── caver-core-method │ ├── package.json │ └── src │ │ └── index.js ├── caver-core-requestmanager │ ├── caver-providers-http │ │ ├── package.json │ │ └── src │ │ │ └── index.js │ ├── caver-providers-ipc │ │ ├── package.json │ │ └── src │ │ │ └── index.js │ ├── caver-providers-ws │ │ ├── package.json │ │ └── src │ │ │ ├── helpers.js │ │ │ └── index.js │ ├── package.json │ └── src │ │ ├── batch.js │ │ ├── index.js │ │ └── jsonrpc.js ├── caver-core-subscriptions │ ├── package.json │ └── src │ │ ├── index.js │ │ └── subscription.js ├── caver-core │ ├── package.json │ └── src │ │ └── index.js ├── caver-ipfs │ ├── package.json │ └── src │ │ └── index.js ├── caver-kct │ ├── package.json │ └── src │ │ ├── index.js │ │ ├── kctHelper.js │ │ ├── kip13.js │ │ ├── kip17.js │ │ ├── kip17Token.sol │ │ ├── kip37.js │ │ ├── kip37Token.sol │ │ └── kip7.js ├── caver-klay │ ├── caver-klay-accounts │ │ ├── package.json │ │ └── src │ │ │ ├── account │ │ │ ├── account.js │ │ │ └── accountForUpdate.js │ │ │ ├── accountKey │ │ │ ├── accountKeyEnum.js │ │ │ ├── accountKeyMultiSig.js │ │ │ ├── accountKeyPublic.js │ │ │ └── accountKeyRoleBased.js │ │ │ ├── index.js │ │ │ ├── makeRawTransaction.js │ │ │ └── transactionType │ │ │ ├── account.js │ │ │ ├── cancel.js │ │ │ ├── contract.js │ │ │ ├── index.js │ │ │ ├── legacy.js │ │ │ ├── serviceChain.js │ │ │ └── valueTransfer.js │ ├── caver-klay-personal │ │ ├── package.json │ │ └── src │ │ │ └── index.js │ ├── package.json │ └── src │ │ ├── getNetworkType.js │ │ └── index.js ├── caver-middleware │ ├── package.json │ └── src │ │ ├── builtins │ │ ├── fileLogger.js │ │ ├── index.js │ │ ├── rpcFilter.js │ │ └── timeMeasure.js │ │ └── index.js ├── caver-net │ ├── package.json │ └── src │ │ └── index.js ├── caver-rpc │ ├── package.json │ └── src │ │ ├── governance.js │ │ ├── index.js │ │ ├── klay.js │ │ └── net.js ├── caver-rtm │ ├── package.json │ └── src │ │ └── index.js ├── caver-transaction │ ├── package.json │ └── src │ │ ├── index.js │ │ ├── transactionDecoder │ │ └── transactionDecoder.js │ │ ├── transactionHasher │ │ └── transactionHasher.js │ │ ├── transactionHelper │ │ └── transactionHelper.js │ │ ├── transactionTypes │ │ ├── abstractFeeDelegatedTransaction.js │ │ ├── abstractFeeDelegatedWithRatioTransaction.js │ │ ├── abstractTransaction.js │ │ ├── accountUpdate │ │ │ ├── accountUpdate.js │ │ │ ├── feeDelegatedAccountUpdate.js │ │ │ └── feeDelegatedAccountUpdateWithRatio.js │ │ ├── cancel │ │ │ ├── cancel.js │ │ │ ├── feeDelegatedCancel.js │ │ │ └── feeDelegatedCancelWithRatio.js │ │ ├── chainDataAnchoring │ │ │ ├── chainDataAnchoring.js │ │ │ ├── feeDelegatedChainDataAnchoring.js │ │ │ └── feeDelegatedChainDataAnchoringWithRatio.js │ │ ├── ethereumTypedTransaction │ │ │ ├── ethereumAccessList.js │ │ │ └── ethereumDynamicFee.js │ │ ├── legacyTransaction │ │ │ └── legacyTransaction.js │ │ ├── smartContractDeploy │ │ │ ├── feeDelegatedSmartContractDeploy.js │ │ │ ├── feeDelegatedSmartContractDeployWithRatio.js │ │ │ └── smartContractDeploy.js │ │ ├── smartContractExecution │ │ │ ├── feeDelegatedSmartContractExecution.js │ │ │ ├── feeDelegatedSmartContractExecutionWithRatio.js │ │ │ └── smartContractExecution.js │ │ ├── valueTransfer │ │ │ ├── feeDelegatedValueTransfer.js │ │ │ ├── feeDelegatedValueTransferWithRatio.js │ │ │ └── valueTransfer.js │ │ ├── valueTransferMemo │ │ │ ├── feeDelegatedValueTransferMemo.js │ │ │ ├── feeDelegatedValueTransferMemoWithRatio.js │ │ │ └── valueTransferMemo.js │ │ └── wrappers │ │ │ ├── accountUpdateWrapper.js │ │ │ ├── cancelWrapper.js │ │ │ ├── chainDataAnchoringWrapper.js │ │ │ ├── ethereumAccessListWrapper.js │ │ │ ├── ethereumDynamicFeeWrapper.js │ │ │ ├── feeDelegatedAccountUpdateWithRatioWrapper.js │ │ │ ├── feeDelegatedAccountUpdateWrapper.js │ │ │ ├── feeDelegatedCancelWithRatioWrapper.js │ │ │ ├── feeDelegatedCancelWrapper.js │ │ │ ├── feeDelegatedChainDataAnchoringWithRatioWrapper.js │ │ │ ├── feeDelegatedChainDataAnchoringWrapper.js │ │ │ ├── feeDelegatedSmartContractDeployWithRatioWrapper.js │ │ │ ├── feeDelegatedSmartContractDeployWrapper.js │ │ │ ├── feeDelegatedSmartContractExecutionWithRatioWrapper.js │ │ │ ├── feeDelegatedSmartContractExecutionWrapper.js │ │ │ ├── feeDelegatedValueTransferMemoWithRatioWrapper.js │ │ │ ├── feeDelegatedValueTransferMemoWrapper.js │ │ │ ├── feeDelegatedValueTransferWithRatioWrapper.js │ │ │ ├── feeDelegatedValueTransferWrapper.js │ │ │ ├── legacyTransactionWrapper.js │ │ │ ├── smartContractDeployWrapper.js │ │ │ ├── smartContractExecutionWrapper.js │ │ │ ├── valueTransferMemoWrapper.js │ │ │ └── valueTransferWrapper.js │ │ └── utils │ │ ├── accessList.js │ │ └── accessTuple.js ├── caver-utils │ ├── iban │ │ ├── package.json │ │ └── src │ │ │ └── index.js │ ├── package.json │ ├── promievent │ │ ├── package.json │ │ └── src │ │ │ └── index.js │ ├── randomhex │ │ ├── browser.js │ │ ├── crypto.js │ │ └── index.js │ └── src │ │ ├── index.js │ │ ├── soliditySha3.js │ │ └── utils.js ├── caver-validator │ ├── package.json │ └── src │ │ └── index.js └── caver-wallet │ ├── package.json │ └── src │ ├── index.js │ └── keyring │ ├── keyringFactory.js │ ├── keyringHelper.js │ ├── multipleKeyring.js │ ├── privateKey.js │ ├── roleBasedKeyring.js │ ├── signatureData.js │ └── singleKeyring.js ├── release_rc.sh ├── rpc.json ├── test ├── abi.decodeLog.js ├── abi.decodeParameter.js ├── abi.encodeParameter.js ├── accountLib.js ├── accounts.privateKeyToPublicKey.js ├── accounts.recover.js ├── accounts.signTransaction.js ├── compressionPublicKey.js ├── confirmationListener.js ├── conformanceTest.js ├── contract.once.js ├── contract.setWallet.js ├── contractError.js ├── contractInstance.js ├── contractOverloading.js ├── createTest.js ├── decodeFunctionCall.js ├── decodeTransaction.js ├── defaultAccount.js ├── defaultBlock.js ├── dynamicBaseFee.js ├── encodeContractDeploy.js ├── estimateComputationCost.js ├── eventEmitter.js ├── extendedChai.js ├── getBlock.js ├── getBlockTransactionCount.js ├── getBlockWithConsensusInfo.js ├── getChainId.js ├── getCommittee.js ├── getCommitteeSize.js ├── getCouncil.js ├── getCouncilSize.js ├── getNetworkType.js ├── getNodeInfo.js ├── getPastLogs.js ├── getStorageAt.js ├── getTransaction.js ├── getTransactionCount.js ├── getTransactionFromBlock.js ├── getTransactionReceipt.js ├── getValidators.js ├── hashMessage.js ├── iban.createIndirect.js ├── iban.fromAddress.js ├── iban.isValid.js ├── iban.toAddress.js ├── intTest.js ├── invalidResponse.js ├── ipfsTest.js ├── isContractDeployment.js ├── isValidPrivateKey.js ├── methodErrorHandling.js ├── middlewareFeature.js ├── multiProviderTest.js ├── mutatedInstanceMethod.js ├── networkRPCMethods.js ├── packages │ ├── caver.abi.js │ ├── caver.account.accountKey.js │ ├── caver.account.js │ ├── caver.contract.js │ ├── caver.kct.kip37.js │ ├── caver.klay.KIP17.js │ ├── caver.klay.KIP7.js │ ├── caver.klay.accounts.js │ ├── caver.klay.net.js │ ├── caver.rpc.js │ ├── caver.transaction │ │ ├── accountUpdate.js │ │ ├── cancel.js │ │ ├── caver.transaction.js │ │ ├── chainDataAnchoring.js │ │ ├── ethereumAccessList.js │ │ ├── ethereumDynamicFee.js │ │ ├── feeDelegatedAccountUpdate.js │ │ ├── feeDelegatedAccountUpdateWithRatio.js │ │ ├── feeDelegatedCancel.js │ │ ├── feeDelegatedCancelWIthRatio.js │ │ ├── feeDelegatedChainDataAnchoring.js │ │ ├── feeDelegatedChainDataAnchoringWithRatio.js │ │ ├── feeDelegatedSmartContractDeploy.js │ │ ├── feeDelegatedSmartContractDeployWithRatio.js │ │ ├── feeDelegatedSmartContractExecution.js │ │ ├── feeDelegatedSmartContractExecutionWithRatio.js │ │ ├── feeDelegatedValueTransfer.js │ │ ├── feeDelegatedValueTransferMemo.js │ │ ├── feeDelegatedValueTransferMemoWithRatio.js │ │ ├── feeDelegatedValueTransferWithRatio.js │ │ ├── legacyTransaction.js │ │ ├── smartContractDeploy.js │ │ ├── smartContractExecution.js │ │ ├── transactionSamples.js │ │ ├── valueTransfer.js │ │ └── valueTransferMemo.js │ ├── caver.utils.js │ ├── caver.validator.js │ ├── caver.wallet.js │ ├── caver.wallet.keyring.js │ ├── setting.js │ └── utils.js ├── parseAccountKey.js ├── personal.js ├── predefinedBlockNumber.js ├── privateKeyToAccount.js ├── randomHex.js ├── reconnectTest.js ├── scenarioTest │ ├── accountKeyMultiSig.js │ ├── accountKeyPublic.js │ └── accountKeyRoleBased.js ├── sendSignedTransaction.js ├── sendTransactionBalance.js ├── sendTransactionCallback.js ├── setContractOptions.js ├── setNonceWithPendingTag.js ├── setProvider.js ├── setRequestManager.js ├── setWrongValueToDefaultBlock.js ├── sha3.js ├── sign.js ├── signWithMultiSig.js ├── subscription.js ├── supportsSubscriptions.js ├── test-web │ ├── .eslintrc_template.js │ ├── .gitignore │ ├── config-overrides.js │ ├── cypress.json │ ├── cypress │ │ ├── integration │ │ │ └── webEnvTest.spec.js │ │ ├── plugins │ │ │ └── index.js │ │ └── support │ │ │ ├── commands.js │ │ │ └── index.js │ ├── package-lock.json │ ├── package.json │ ├── prepareWebTest.sh │ ├── public │ │ ├── index.html │ │ └── manifest.json │ ├── src │ │ ├── App.js │ │ ├── index.js │ │ └── setupTests.js │ └── terminateTest.sh ├── testHttpHeader.js ├── testWebsocket.js ├── testrpc.js ├── toChecksumAddress.js ├── transactionType │ ├── accountUpdate.js │ ├── cancelTransaction.js │ ├── contractDeploy.js │ ├── contractExecution.js │ ├── feeDelegatedAccountUpdate.js │ ├── feeDelegatedAccountUpdateWithRatio.js │ ├── feeDelegatedCancelTransaction.js │ ├── feeDelegatedCancelTransactionWithRatio.js │ ├── feeDelegatedContractDeploy.js │ ├── feeDelegatedContractDeployWithRatio.js │ ├── feeDelegatedContractExecution.js │ ├── feeDelegatedContractExecutionWithRatio.js │ ├── feeDelegatedValueTransfer.js │ ├── feeDelegatedValueTransferMemo.js │ ├── feeDelegatedValueTransferMemoWithRatio.js │ ├── feeDelegatedValueTransferWithRatio.js │ ├── legacyTransaction.js │ ├── serializationTest.js │ ├── valueTransfer.js │ └── valueTransferWithMemo.js ├── tupleTest.js ├── unitMap.js ├── useMultipleCaverInstances.js ├── walletDefaultName.js └── wrapErrorToHelperErrors.js ├── tsconfig.json ├── turndown.js ├── types ├── index.d.ts ├── packages │ ├── caver-abi │ │ └── src │ │ │ └── index.d.ts │ ├── caver-account │ │ └── src │ │ │ ├── accountKey │ │ │ ├── accountKeyDecoder.d.ts │ │ │ ├── accountKeyFail.d.ts │ │ │ ├── accountKeyHelper.d.ts │ │ │ ├── accountKeyLegacy.d.ts │ │ │ ├── accountKeyPublic.d.ts │ │ │ ├── accountKeyRoleBased.d.ts │ │ │ ├── accountKeyWeightedMultiSig.d.ts │ │ │ ├── weightedMultiSigOptions.d.ts │ │ │ └── weightedPublicKey.d.ts │ │ │ └── index.d.ts │ ├── caver-contract │ │ └── src │ │ │ └── index.d.ts │ ├── caver-core-helpers │ │ └── src │ │ │ ├── constants.d.ts │ │ │ ├── errors.d.ts │ │ │ ├── formatters.d.ts │ │ │ ├── index.d.ts │ │ │ ├── payloadTransformer.d.ts │ │ │ └── validateFunction.d.ts │ ├── caver-core-method │ │ └── src │ │ │ └── index.d.ts │ ├── caver-core-requestmanager │ │ ├── caver-providers-http │ │ │ └── src │ │ │ │ └── index.d.ts │ │ ├── caver-providers-ipc │ │ │ └── src │ │ │ │ └── index.d.ts │ │ ├── caver-providers-ws │ │ │ └── src │ │ │ │ ├── helpers.d.ts │ │ │ │ └── index.d.ts │ │ └── src │ │ │ ├── index.d.ts │ │ │ └── jsonrpc.d.ts │ ├── caver-core-subscriptions │ │ └── src │ │ │ └── index.d.ts │ ├── caver-core │ │ └── src │ │ │ └── index.d.ts │ ├── caver-ipfs │ │ └── src │ │ │ └── index.d.ts │ ├── caver-kct │ │ └── src │ │ │ ├── index.d.ts │ │ │ ├── kip13.d.ts │ │ │ ├── kip17.d.ts │ │ │ ├── kip37.d.ts │ │ │ └── kip7.d.ts │ ├── caver-klay │ │ ├── caver-klay-accounts │ │ │ └── src │ │ │ │ ├── account │ │ │ │ ├── account.d.ts │ │ │ │ └── accountKeyForUpdate.d.ts │ │ │ │ ├── accountKey │ │ │ │ ├── accountKeyEnum.d.ts │ │ │ │ ├── accountKeyMultiSig.d.ts │ │ │ │ ├── accountKeyPublic.d.ts │ │ │ │ └── accountKeyRoleBased.d.ts │ │ │ │ └── index.d.ts │ │ ├── caver-klay-personal │ │ │ └── src │ │ │ │ └── index.d.ts │ │ └── src │ │ │ └── index.d.ts │ ├── caver-middleware │ │ └── src │ │ │ ├── builtins │ │ │ ├── fileLogger.d.ts │ │ │ ├── index.d.ts │ │ │ ├── rpcFilter.d.ts │ │ │ └── timeMeasure.d.ts │ │ │ └── index.d.ts │ ├── caver-net │ │ └── src │ │ │ └── index.d.ts │ ├── caver-rpc │ │ └── src │ │ │ ├── governance.d.ts │ │ │ ├── index.d.ts │ │ │ ├── klay.d.ts │ │ │ └── net.d.ts │ ├── caver-rtm │ │ └── src │ │ │ └── index.d.ts │ ├── caver-transaction │ │ └── src │ │ │ ├── index.d.ts │ │ │ ├── transactionDecoder │ │ │ └── transactionDecoder.d.ts │ │ │ ├── transactionHasher │ │ │ └── transactionHasher.d.ts │ │ │ ├── transactionHelper │ │ │ └── transactionHelper.d.ts │ │ │ ├── transactionTypes │ │ │ ├── abstractFeeDelegatedTransaction.d.ts │ │ │ ├── abstractFeeDelegatedWithRatioTransaction.d.ts │ │ │ ├── abstractTransaction.d.ts │ │ │ ├── accountUpdate │ │ │ │ ├── accountUpdate.d.ts │ │ │ │ ├── feeDelegatedAccountUpdate.d.ts │ │ │ │ └── feeDelegatedAccountUpdateWithRatio.d.ts │ │ │ ├── cancel │ │ │ │ ├── cancel.d.ts │ │ │ │ ├── feeDelegatedCancel.d.ts │ │ │ │ └── feeDelegatedCancelWithRatio.d.ts │ │ │ ├── chainDataAnchoring │ │ │ │ ├── chainDataAnchoring.d.ts │ │ │ │ ├── feeDelegatedChainDataAnchoring.d.ts │ │ │ │ └── feeDelegatedChainDataAnchoringWithRatio.d.ts │ │ │ ├── ethereumTypedTransaction │ │ │ │ ├── ethereumAccessList.d.ts │ │ │ │ └── ethereumDynamicFee.d.ts │ │ │ ├── legacyTransaction │ │ │ │ └── legacyTransaction.d.ts │ │ │ ├── smartContractDeploy │ │ │ │ ├── feeDelegatedSmartContractDeploy.d.ts │ │ │ │ ├── feeDelegatedSmartContractDeployWithRatio.d.ts │ │ │ │ └── smartContractDeploy.d.ts │ │ │ ├── smartContractExecution │ │ │ │ ├── feeDelegatedSmartContractExecution.d.ts │ │ │ │ ├── feeDelegatedSmartContractExecutionWithRatio.d.ts │ │ │ │ └── smartContractExecution.d.ts │ │ │ ├── valueTransfer │ │ │ │ ├── feeDelegatedValueTransfer.d.ts │ │ │ │ ├── feeDelegatedValueTransferWithRatio.d.ts │ │ │ │ └── valueTransfer.d.ts │ │ │ ├── valueTransferMemo │ │ │ │ ├── feeDelegatedValueTransferMemo.d.ts │ │ │ │ ├── feeDelegatedValueTransferMemoWithRatio.d.ts │ │ │ │ └── valueTransferMemo.d.ts │ │ │ └── wrappers │ │ │ │ └── transactionWrappers.d.ts │ │ │ └── utils │ │ │ ├── accessList.d.ts │ │ │ └── accessTuple.d.ts │ ├── caver-utils │ │ └── src │ │ │ └── index.d.ts │ ├── caver-validator │ │ └── src │ │ │ └── index.d.ts │ └── caver-wallet │ │ └── src │ │ ├── index.d.ts │ │ └── keyring │ │ ├── keyringFactory.d.ts │ │ ├── keyringHelper.d.ts │ │ ├── multipleKeyring.d.ts │ │ ├── privateKey.d.ts │ │ ├── roleBasedKeyring.d.ts │ │ ├── signatureData.d.ts │ │ └── singleKeyring.d.ts ├── test │ ├── abi-test.ts │ ├── account-test.ts │ ├── caver-test.ts │ ├── contract-test.ts │ ├── ipfs-test.ts │ ├── kct-test.ts │ ├── rpc-test.ts │ ├── transaction-test.ts │ ├── utils-test.ts │ ├── validator-test.ts │ └── wallet-test.ts ├── tsconfig.json └── tslint.json ├── webpack.config.js └── webpack.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["@babel/preset-env"], 3 | "plugins": ["@babel/plugin-external-helpers", "@babel/plugin-transform-runtime"] 4 | } 5 | -------------------------------------------------------------------------------- /.circleci/version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #take version from package.json 4 | if [ -f package.json ]; then 5 | version_package=$(awk '/version/ {gsub("\"",""); print $2}' package.json | tr -d ',') 6 | echo $version_package 7 | else 8 | echo "package.json not exist" 9 | fi 10 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.swp 3 | */**/*un~ 4 | *un~ 5 | */**/.DS_Store 6 | npm-debug.log 7 | .npm/ 8 | node_modules/ 9 | .idea/ 10 | .npm/ 11 | .vscode/ 12 | package-lock.json 13 | .git 14 | dist/* 15 | caver-cli 16 | test/test-web/* 17 | out/* -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['airbnb', 'prettier'], 3 | env: { 4 | commonjs: true, 5 | node: true, 6 | mocha: true, 7 | }, 8 | parser: '@babel/eslint-parser', 9 | parserOptions: { 10 | ecmaVersion: 8, 11 | requireConfigFile: false, 12 | }, 13 | plugins: ['prettier'], 14 | rules: { 15 | 'prettier/prettier': ['error'], 16 | radix: 0, 17 | eqeqeq: 0, 18 | 'new-cap': 0, 19 | 'no-empty': 0, 20 | 'no-console': 0, 21 | 'no-bitwise': 0, 22 | 'func-names': 0, 23 | 'no-continue': 0, 24 | 'no-plusplus': 0, 25 | 'no-sequences': 0, 26 | 'default-case': 0, 27 | 'guard-for-in': 0, 28 | 'prefer-spread': 0, 29 | 'global-require': 0, 30 | 'no-await-in-loop': 0, 31 | 'no-control-regex': 0, 32 | 'object-shorthand': 0, 33 | 'no-return-assign': 0, 34 | 'consistent-return': 0, 35 | 'no-nested-ternary': 0, 36 | 'no-param-reassign': 0, 37 | 'prefer-rest-params': 0, 38 | 'no-use-before-define': 0, 39 | 'no-restricted-syntax': 0, 40 | 'no-underscore-dangle': 0, 41 | 'prefer-destructuring': 0, 42 | 'no-case-declarations': 0, 43 | 'no-restricted-globals': 0, 44 | 'array-callback-return': 0, 45 | 'no-unused-expressions': 0, 46 | 'import/no-dynamic-require': 0, 47 | 'import/no-extraneous-dependencies': 0, 48 | 'no-loop-func': 0, 49 | 'react/destructuring-assignment': 0, 50 | 'no-proto': 1, 51 | 'prefer-const': 1, 52 | 'no-multi-assign': 1, 53 | 'class-methods-use-this': 1, 54 | 'import/no-unresolved': 1, 55 | }, 56 | } 57 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # This is a comment. 2 | # Each line is a file pattern followed by one or more owners. 3 | 4 | # These owners will be the default owners for everything in 5 | # the repo. Unless a later match takes precedence, 6 | # @global-owner1 and @global-owner2 will be requested for 7 | # review when someone opens a pull request. 8 | #* @global-owner1 @global-owner2 9 | * @jimni1222 @nohkwak @JayChoi1736 @kjeom @kjhman21 10 | 11 | # Order is important; the last matching pattern takes the most 12 | # precedence. When someone opens a pull request that only 13 | # modifies JS files, only @js-owner and not the global 14 | # owner(s) will be requested for a review. 15 | #*.js @js-owner 16 | 17 | # You can also use email addresses if you prefer. They'll be 18 | # used to look up users just like we do for commit author 19 | # emails. 20 | #*.go docs@example.com 21 | 22 | # In this example, @doctocat owns any files in the build/logs 23 | # directory at the root of the repository and any of its 24 | # subdirectories. 25 | #/build/logs/ @doctocat 26 | 27 | # The `docs/*` pattern will match files like 28 | # `docs/getting-started.md` but not further nested files like 29 | # `docs/build-app/troubleshooting.md`. 30 | #docs/* docs@example.com 31 | 32 | # In this example, @octocat owns any file in an apps directory 33 | # anywhere in your repository. 34 | #apps/ @octocat 35 | 36 | # In this example, @doctocat owns any file in the `/docs` 37 | # directory in the root of your repository. 38 | #/docs/ @doctocat 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/---bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\U0001F41C Bug report" 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **How to reproduce** 14 | Steps to reproduce the behavior: 15 | 16 | **Expected behavior** 17 | A clear and concise description of what you expected to happen. 18 | 19 | **Attachments** 20 | If applicable, add data, logs or screenshots to help explain your problem. 21 | 22 | **Environment (please complete the following information)** 23 | - caver-js version or git revision that exhibits the issue 24 | - OS and its version [e.g. macOS/10.14] 25 | 26 | **Additional context** 27 | Add any other context about the problem here. 28 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/---enhancement.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\U0001F9E9 Enhancement" 3 | about: Suggest an improvement idea for this project 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/--questions-and-others.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "❓ Questions and Others" 3 | about: Questions regarding caver-js or other issues not related to bug nor feature 4 | request 5 | title: '' 6 | labels: '' 7 | assignees: '' 8 | 9 | --- 10 | 11 | Freely describe your questions or issues here. 12 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Proposed changes 2 | 3 | - Describe your changes to communicate to the maintainers why we should accept this pull request. 4 | - If it fixes a bug or resolves a feature request, be sure to link to that issue. 5 | 6 | ## Types of changes 7 | 8 | Please put an x in the boxes related to your change. 9 | 10 | - [ ] Bugfix 11 | - [ ] New feature or enhancement 12 | - [ ] Others 13 | 14 | ## Checklist 15 | 16 | *Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.* 17 | 18 | - [ ] I have read the [CONTRIBUTING GUIDELINES](https://github.com/klaytn/caver-js/blob/master/CONTRIBUTING.md) doc 19 | - [ ] I have signed the [CLA](https://cla-assistant.io/klaytn/caver-js) 20 | - [ ] Lint and unit tests pass locally with my changes 21 | - [ ] I have added tests that prove my fix is effective or that my feature works 22 | - [ ] I have added necessary documentation (if appropriate) 23 | - [ ] Any dependent changes have been merged and published in downstream modules 24 | 25 | ## Related issues 26 | 27 | - Please leave the issue numbers or links related to this PR here. 28 | 29 | ## Further comments 30 | 31 | If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc... 32 | -------------------------------------------------------------------------------- /.github/workflows/CLA.yml: -------------------------------------------------------------------------------- 1 | name: "CLA Assistant" 2 | on: 3 | issue_comment: 4 | types: [created] 5 | pull_request_target: 6 | types: [opened, closed, synchronize] 7 | 8 | jobs: 9 | CLAssistant: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: "CLA Assistant" 13 | if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target' 14 | uses: cla-assistant/github-action@v2.1.3-beta 15 | env: 16 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 17 | PERSONAL_ACCESS_TOKEN: ${{ secrets.CLA_PERSONAL_ACCESS_TOKEN }} 18 | with: 19 | path-to-signatures: "${{ github.event.repository.name }}/signatures/version1/cla.json" 20 | path-to-document: "https://gist.github.com/e78f99e1c527225637e269cff1bc7e49" # Klaytn Gist 21 | branch: "master" 22 | allowlist: dependabot[bot] 23 | remote-repository-name: ${{ secrets.CLA_REPOSITORY }} 24 | -------------------------------------------------------------------------------- /.github/workflows/CodeQL.yml: -------------------------------------------------------------------------------- 1 | name: "Code Scanning - Action" 2 | 3 | on: 4 | pull_request: 5 | branches: [dev, master] 6 | types: [opened, synchronize] 7 | 8 | jobs: 9 | CodeQL-Build: 10 | # CodeQL runs on ubuntu-latest, windows-latest, and macos-latest 11 | runs-on: ubuntu-latest 12 | 13 | permissions: 14 | # required for all workflows 15 | security-events: write 16 | 17 | # only required for workflows in private repositories 18 | actions: read 19 | contents: read 20 | 21 | steps: 22 | - name: Checkout repository 23 | uses: actions/checkout@v3 24 | 25 | # Initializes the CodeQL tools for scanning. 26 | - name: Initialize CodeQL 27 | uses: github/codeql-action/init@v2 28 | with: 29 | languages: javascript 30 | # Override language selection by uncommenting this and choosing your languages 31 | # with: 32 | # languages: go, javascript, csharp, python, cpp, java 33 | 34 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 35 | # If this step fails, then you should remove it and run the build manually (see below). 36 | # - name: Autobuild 37 | # uses: github/codeql-action/autobuild@v2 38 | 39 | # ℹ️ Command-line programs to run using the OS shell. 40 | # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun 41 | 42 | # ✏️ If the Autobuild fails above, remove it and uncomment the following 43 | # three lines and modify them (or add more) to build your code if your 44 | # project uses a compiled language 45 | 46 | #- run: | 47 | # make bootstrap 48 | # make release 49 | 50 | - name: Perform CodeQL Analysis 51 | uses: github/codeql-action/analyze@v2 52 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.swp 3 | */**/*un~ 4 | *un~ 5 | */**/.DS_Store 6 | npm-debug.log 7 | .npm/ 8 | /coverage 9 | /tmp 10 | node_modules 11 | .idea/ 12 | .npm/ 13 | .vscode/ 14 | /packages/**/lib/* 15 | /.nyc_output 16 | .git 17 | dist/* 18 | .env 19 | out/* 20 | test.js -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "caver-conformance-tests"] 2 | path = caver-conformance-tests 3 | url = https://github.com/ground-x/caver-conformance-tests.git 4 | branch = dev 5 | [submodule "test/klaytn-integration-tests"] 6 | path = test/klaytn-integration-tests 7 | url = https://github.com/klaytn/klaytn-integration-tests 8 | branch = 0811 9 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.swp 3 | */**/*un~ 4 | *un~ 5 | */**/.DS_Store 6 | npm-debug.log 7 | .npm/ 8 | /coverage 9 | /tmp 10 | node_modules 11 | .idea/ 12 | .npm/ 13 | .vscode/ 14 | /packages/**/lib/* 15 | /.nyc_output 16 | package-lock.json 17 | .git 18 | !dist/* -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | *.json 2 | *.md 3 | *.html -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | semi: false, 3 | printWidth: 140, 4 | singleQuote: true, 5 | arrowParens: 'avoid', 6 | bracketSpacing: true, 7 | tabWidth: 4, 8 | trailingComma: 'es5', 9 | } 10 | -------------------------------------------------------------------------------- /Changelog.md: -------------------------------------------------------------------------------- 1 | ## 0.0.1 2 | - Declare rpc call's `inputFormatter`, `outputFormatter`, `transformPayload` as a string type. 3 | - Move long rpc call list on `eth` to `rpc.js`(newly added) 4 | - extends `formatters.js` module by adding `toChecksumAddress`, `numberToHex` functions from `utils` 5 | - extends `formatters.js` module by importing `payloadTransformer.js` file. 6 | - Moves `promievent`, `iban` modules to `utils` 7 | - Moves `abi`, `accounts`, `contract`, `personal` modules to `eth` 8 | - Moves `httpProvider`, `wsProvider`, `ipcProvider` modules to `requestManager` 9 | - Moves `index.js`(main file) to root folder. 10 | - Remove `shh`(whisper), `bzz`(swarm) modules. 11 | - Remove `inputFormatter: [null]` structures on rpc.js (Doesn't need to have a inputFormatter when it actually doesn't need it.) 12 | - Additional check logic(`_.isEmpty(this.inputFormatter)`) for `formatInput` logic in `core-method` 13 | - Add `toBoolean` function in `formatters` 14 | - Solves `Failed to check for transaction receipt` error. 15 | 16 | ## 0.0.1h 17 | - Change `rpc.js` to `rpc.json`. 18 | - Add property `hexCall` for rpc call. (It can covers parameter dynamically according to parameter type.) 19 | - Add `isHexParameter` function in `utils` 20 | - cli list support 21 | 22 | ## 0.0.1i 23 | - Removed `extend.js` 24 | - Removed `givenProvider.js` 25 | - Removed `addProviders` function in caver-core 26 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:carbon 2 | # FROM node:dubnium 3 | # FROM node:erbium 4 | 5 | # make app directory 6 | WORKDIR /usr/src/app 7 | 8 | # use wild card to copy both of package.json and package-lock.json 9 | COPY package*.json ./ 10 | 11 | # install app dependencies 12 | RUN npm install && \ 13 | npm install -g mocha@6.2.2 14 | # install solc 15 | RUN curl -o /usr/bin/solc -fL https://github.com/ethereum/solidity/releases/download/v0.5.6/solc-static-linux \ 16 | && chmod u+x /usr/bin/solc 17 | 18 | # add app source 19 | COPY . . 20 | 21 | CMD [ "npm", "test" ] 22 | -------------------------------------------------------------------------------- /assets/logo/caver-js.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klaytn/caver-js/d7345e275a47002a99fbb469684212ea6de2d336/assets/logo/caver-js.png -------------------------------------------------------------------------------- /caver-cli/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "caver-cli", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "cli.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "Klaytn Team", 10 | "license": "LGPL-3.0", 11 | "dependencies": { 12 | "chalk": "^2.4.1", 13 | "figlet": "^1.2.0", 14 | "inquirer": "^6.0.0", 15 | "json-format": "^1.0.1", 16 | "lodash": "^4.17.15" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /cli.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | require('./caver-cli') 20 | -------------------------------------------------------------------------------- /jsdoc.json: -------------------------------------------------------------------------------- 1 | { 2 | "tags": { 3 | "allowUnknownTags": true 4 | }, 5 | "source": { 6 | "include": ["./index.js", "./packages"], 7 | "includePattern": ".js$", 8 | "exclude": [ 9 | "./docs", 10 | "./packages/caver-core/*", 11 | "./packages/caver-core-helpers", 12 | "./packages/caver-core-method", 13 | "./packages/caver-core-requestmanager", 14 | "./packages/caver-middleware", 15 | "./packages/caver-rtm" 16 | ], 17 | "excludePattern": "(node_modules/|docs)" 18 | }, 19 | "plugins": [ 20 | "plugins/markdown", 21 | "node_modules/jsdoc-typeof-plugin" 22 | ], 23 | "opts": { 24 | "template": "node_modules/docdash", 25 | "encoding": "utf8", 26 | "destination": "./out", 27 | "recurse": true, 28 | "verbose": true 29 | }, 30 | "templates": { 31 | "cleverLinks": false, 32 | "monospaceLinks": false, 33 | "default": { 34 | "outputSourceFiles": false 35 | } 36 | }, 37 | "docdash": { 38 | "static": false, 39 | "sort": false 40 | }, 41 | "markdown": { 42 | "idInHeadings": true, 43 | "hardwrap": true, 44 | "excludeTags": ["author","file","date","authors"] 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /packages/caver-abi/README.md: -------------------------------------------------------------------------------- 1 | # caver-klay-abi 2 | 3 | This is a sub package of [caver-js][repo] 4 | 5 | This is the abi package to be used in the `caver-klay` package. 6 | Please read the [documentation][docs] for more. 7 | 8 | ## Installation 9 | 10 | ### Node.js 11 | 12 | ```bash 13 | npm install caver-klay-abi 14 | ``` 15 | 16 | ### In the Browser 17 | 18 | Build running the following in the [caver-js][repo] repository: 19 | 20 | ```bash 21 | npm run-script build-all 22 | ``` 23 | 24 | Then include `dist/caver-klay-abi.js` in your html file. 25 | This will expose the `caverKlayAbi` object on the window object. 26 | 27 | 28 | ## Usage 29 | 30 | ```js 31 | // in node.js 32 | var caverKlayAbi = require('caver-klay-abi'); 33 | 34 | caverKlayAbi.encodeFunctionSignature('myMethod(uint256,string)'); 35 | > '0x24ee0097' 36 | ``` 37 | -------------------------------------------------------------------------------- /packages/caver-abi/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "caver-abi", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "Klaytn Team", 10 | "license": "LGPL-3.0" 11 | } 12 | -------------------------------------------------------------------------------- /packages/caver-account/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "caver-account", 3 | "version": "1.0.0", 4 | "description": "This is a sub package of [caver-js][repo]", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "Klaytn Team", 10 | "license": "LGPL-3.0" 11 | } 12 | -------------------------------------------------------------------------------- /packages/caver-contract/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "caver-contract", 3 | "version": "1.0.0", 4 | "description": "This is a sub package of [caver-js][repo]", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "Klaytn Team", 10 | "license": "LGPL-3.0" 11 | } 12 | -------------------------------------------------------------------------------- /packages/caver-core-helpers/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "caver-core-helpers", 3 | "version": "1.0.0", 4 | "description": "This is a sub package of [caver-js][repo]", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "Klaytn Team", 10 | "license": "LGPL-3.0" 11 | } 12 | -------------------------------------------------------------------------------- /packages/caver-core-helpers/src/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | Modifications copyright 2018 The caver-js Authors 3 | This file is part of web3.js. 4 | 5 | web3.js is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | web3.js is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with web3.js. If not, see . 17 | 18 | This file is derived from web3.js/packages/web3-core-helpers/src/index.js (2019/06/12). 19 | Modified and improved for the caver-js development. 20 | */ 21 | /** 22 | * @file index.js 23 | * @author Fabian Vogelsteller 24 | * @date 2017 25 | */ 26 | 27 | const errors = require('./errors') 28 | const formatters = require('./formatters') 29 | const payloadTransformer = require('./payloadTransformer') 30 | const constants = require('./constants') 31 | const validateFunction = require('./validateFunction') 32 | 33 | module.exports = { 34 | errors, 35 | formatters, 36 | payloadTransformer, 37 | constants, 38 | validateFunction, 39 | } 40 | -------------------------------------------------------------------------------- /packages/caver-core-helpers/src/payloadTransformer.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | function reversePayload(payload) { 20 | payload.params.reverse() 21 | return payload 22 | } 23 | 24 | module.exports = { 25 | reversePayload, 26 | } 27 | -------------------------------------------------------------------------------- /packages/caver-core-method/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "caver-core-method", 3 | "version": "1.0.0", 4 | "description": "This is a sub package of [caver-js][repo]", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "Klaytn Team", 10 | "license": "LGPL-3.0" 11 | } 12 | -------------------------------------------------------------------------------- /packages/caver-core-requestmanager/caver-providers-http/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "caver-providers-http", 3 | "version": "1.0.0", 4 | "description": "*This is a sub package of [caver-js][repo]*", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "Klaytn Team", 10 | "license": "LGPL-3.0" 11 | } 12 | -------------------------------------------------------------------------------- /packages/caver-core-requestmanager/caver-providers-ipc/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "caver-providers-ipc", 3 | "version": "1.0.0", 4 | "description": "This is a sub package of [caver-js][repo]", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "Klaytn Team", 10 | "license": "LGPL-3.0" 11 | } 12 | -------------------------------------------------------------------------------- /packages/caver-core-requestmanager/caver-providers-ws/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "caver-providers-ws", 3 | "version": "1.0.0", 4 | "description": "This is a sub package of [caver-js][repo]", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "Klaytn Team", 10 | "license": "LGPL-3.0" 11 | } 12 | -------------------------------------------------------------------------------- /packages/caver-core-requestmanager/caver-providers-ws/src/helpers.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-undef */ 2 | /* eslint-disable no-shadow */ 3 | const isNode = Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]' 4 | const isRN = typeof navigator !== 'undefined' && navigator.product === 'ReactNative' 5 | 6 | let _btoa = null 7 | let helpers = null 8 | if (isNode || isRN) { 9 | _btoa = function(str) { 10 | return Buffer.from(str).toString('base64') 11 | } 12 | const url = require('url') 13 | if (url.URL) { 14 | // Use the new Node 6+ API for parsing URLs that supports username/password 15 | const newURL = url.URL 16 | helpers = function(url) { 17 | return new newURL(url) 18 | } 19 | } else { 20 | // Web3 supports Node.js 5, so fall back to the legacy URL API if necessary 21 | helpers = require('url').parse 22 | } 23 | } else { 24 | _btoa = btoa.bind(window) 25 | helpers = function(url) { 26 | return new URL(url) 27 | } 28 | } 29 | 30 | module.exports = { 31 | parseURL: helpers, 32 | btoa: _btoa, 33 | } 34 | -------------------------------------------------------------------------------- /packages/caver-core-requestmanager/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "caver-core-requestmanager", 3 | "version": "1.0.0", 4 | "description": "This is a sub package of [caver-js][repo]", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "Klaytn Team", 10 | "license": "LGPL-3.0" 11 | } 12 | -------------------------------------------------------------------------------- /packages/caver-core-subscriptions/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "caver-core-subscriptions", 3 | "version": "1.0.0", 4 | "description": "This is a sub package of [caver-js][repo]", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "Klaytn Team", 10 | "license": "LGPL-3.0" 11 | } 12 | -------------------------------------------------------------------------------- /packages/caver-core/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "caver-core", 3 | "version": "1.0.0", 4 | "description": "This is a sub package of [caver-js][repo]", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "Klaytn Team", 10 | "license": "LGPL-3.0" 11 | } 12 | -------------------------------------------------------------------------------- /packages/caver-ipfs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "caver-ipfs", 3 | "version": "1.0.0", 4 | "description": "This is a sub package of [caver-js][repo]", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "Klaytn Team", 10 | "license": "LGPL-3.0" 11 | } 12 | -------------------------------------------------------------------------------- /packages/caver-kct/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "caver-kct", 3 | "version": "1.0.0", 4 | "description": "This is a sub package of [caver-js][repo]", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "Klaytn Team", 10 | "license": "LGPL-3.0" 11 | } 12 | -------------------------------------------------------------------------------- /packages/caver-klay/caver-klay-accounts/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "caver-klay-accounts", 3 | "version": "1.0.0", 4 | "description": "This is a sub package of [caver-js][repo]", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "Klaytn Team", 10 | "license": "LGPL-3.0" 11 | } 12 | -------------------------------------------------------------------------------- /packages/caver-klay/caver-klay-accounts/src/accountKey/accountKeyEnum.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | module.exports = { 20 | AccountKeyEnum: { 21 | ACCOUNT_KEY_PUBLIC: 'AccountKeyPublic', 22 | ACCOUNT_KEY_MULTISIG: 'AccountKeyMultiSig', 23 | ACCOUNT_KEY_ROLEBASED: 'AccountKeyRoleBased', 24 | }, 25 | } 26 | -------------------------------------------------------------------------------- /packages/caver-klay/caver-klay-accounts/src/accountKey/accountKeyPublic.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | const AccountKeyEnum = require('./accountKeyEnum').AccountKeyEnum 20 | 21 | class AccountKeyPublic { 22 | constructor(key) { 23 | if (key instanceof AccountKeyPublic) key = key.keys 24 | 25 | if (typeof key !== 'string') throw new Error('To create AccountKeyPublic, a private key strings is required.') 26 | this._key = key 27 | this.type = AccountKeyEnum.ACCOUNT_KEY_PUBLIC 28 | } 29 | 30 | get defaultKey() { 31 | return this._key 32 | } 33 | 34 | get keys() { 35 | return this._key 36 | } 37 | 38 | get transactionKey() { 39 | return this._key 40 | } 41 | 42 | get updateKey() { 43 | return this._key 44 | } 45 | 46 | get feePayerKey() { 47 | return this._key 48 | } 49 | 50 | toPublicKey(toPublicKeyFunc) { 51 | return toPublicKeyFunc(this._key) 52 | } 53 | 54 | update(key) { 55 | this._key = key.keys 56 | } 57 | } 58 | 59 | module.exports = AccountKeyPublic 60 | -------------------------------------------------------------------------------- /packages/caver-klay/caver-klay-accounts/src/transactionType/legacy.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | const RLP = require('eth-lib/lib/rlp') 20 | const Bytes = require('eth-lib/lib/bytes') 21 | 22 | function rlpEncodeForLegacyTransaction(transaction) { 23 | return RLP.encode([ 24 | Bytes.fromNat(transaction.nonce), 25 | Bytes.fromNat(transaction.gasPrice), 26 | Bytes.fromNat(transaction.gas), 27 | transaction.to.toLowerCase(), 28 | Bytes.fromNat(transaction.value || '0x0'), 29 | transaction.data, 30 | Bytes.fromNat(transaction.chainId || '0x1'), 31 | '0x', 32 | '0x', 33 | ]) 34 | } 35 | 36 | module.exports = { 37 | rlpEncodeForLegacyTransaction, 38 | } 39 | -------------------------------------------------------------------------------- /packages/caver-klay/caver-klay-accounts/src/transactionType/serviceChain.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | const RLP = require('eth-lib/lib/rlp') 20 | const Bytes = require('eth-lib/lib/bytes') 21 | const helpers = require('../../../../caver-core-helpers') 22 | 23 | const { CHAIN_DATA_ANCHORING_TYPE_TAG } = helpers.constants 24 | 25 | function rlpEncodeForChainDataAnchoring(transaction) { 26 | return RLP.encode([ 27 | RLP.encode([ 28 | CHAIN_DATA_ANCHORING_TYPE_TAG, 29 | Bytes.fromNat(transaction.nonce), 30 | Bytes.fromNat(transaction.gasPrice), 31 | Bytes.fromNat(transaction.gas), 32 | transaction.from.toLowerCase(), 33 | Bytes.fromNat(transaction.data), 34 | ]), 35 | Bytes.fromNat(transaction.chainId || '0x1'), 36 | '0x', 37 | '0x', 38 | ]) 39 | } 40 | 41 | module.exports = { 42 | rlpEncodeForChainDataAnchoring, 43 | } 44 | -------------------------------------------------------------------------------- /packages/caver-klay/caver-klay-personal/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "caver-klay-personal", 3 | "version": "1.0.0", 4 | "description": "This is a sub package of [caver-js][repo]", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "Klaytn Team", 10 | "license": "LGPL-3.0" 11 | } 12 | -------------------------------------------------------------------------------- /packages/caver-klay/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "caver-klay", 3 | "version": "1.0.0", 4 | "description": "This is a sub package of [caver-js][repo]", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "Klaytn Team", 10 | "license": "LGPL-3.0" 11 | } 12 | -------------------------------------------------------------------------------- /packages/caver-middleware/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "caver-middleware", 3 | "version": "1.0.0", 4 | "description": "This is a sub package of [caver-js][repo]", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "Klaytn Team", 10 | "license": "LGPL-3.0" 11 | } 12 | -------------------------------------------------------------------------------- /packages/caver-middleware/src/builtins/fileLogger.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | // const fs = typeof window !== 'object' && require('fs') || {} 20 | const fs = {} 21 | 22 | const DEFAULT_FILE_PATH = './' 23 | const DEFAULT_FILE_NAME = 'rpcLogs' 24 | const DEFAULT_FILE_EXTENSION = 'log' 25 | 26 | const guaranteeFilePath = filePath => { 27 | return filePath.slice(-1) !== '/' ? `${filePath}/` : filePath 28 | } 29 | 30 | const appendToFile = (filePath, contents) => { 31 | fs.appendFileSync(filePath, `${contents}\n`, err => { 32 | if (err) throw err 33 | }) 34 | } 35 | 36 | const fileLogger = (options = {}) => (data, next) => { 37 | if (typeof options !== 'object') { 38 | throw Error('file logger must take an object type argument.') 39 | } 40 | 41 | options.path = guaranteeFilePath(options.path) || DEFAULT_FILE_PATH 42 | options.name = options.name || DEFAULT_FILE_NAME 43 | options.extension = options.extension || DEFAULT_FILE_EXTENSION 44 | 45 | const fileName = `${options.path}${options.name}.${options.extension}` 46 | 47 | // Add timestamp for RPC request || response. 48 | data.timestamp = new Date().getTime() 49 | 50 | appendToFile(fileName, JSON.stringify(data)) 51 | 52 | next() 53 | } 54 | 55 | module.exports = fileLogger 56 | -------------------------------------------------------------------------------- /packages/caver-middleware/src/builtins/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | const fileLogger = require('./fileLogger') 20 | const rpcFilter = require('./rpcFilter') 21 | const timeMeasure = require('./timeMeasure') 22 | 23 | module.exports = { 24 | fileLogger, 25 | rpcFilter, 26 | timeMeasure, 27 | } 28 | -------------------------------------------------------------------------------- /packages/caver-middleware/src/builtins/rpcFilter.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | const rpcFilter = (filterColl, filterOption = 'include') => { 20 | if (!Array.isArray(filterColl)) { 21 | throw Error('rpcFilter only takes an array for first argument') 22 | } 23 | 24 | // For filterColl indexing. (Since Array traversing is slower than Object) 25 | filterColl = filterColl.reduce((acc, cur) => { 26 | acc[cur] = cur 27 | return acc 28 | }, {}) 29 | 30 | return (data, next) => { 31 | if (filterOption === 'include') { 32 | if (!filterColl[data.method]) return 33 | next(data) 34 | } else if (filterOption === 'exclude') { 35 | if (!filterColl[data.method]) next(data) 36 | } 37 | } 38 | } 39 | 40 | module.exports = rpcFilter 41 | -------------------------------------------------------------------------------- /packages/caver-middleware/src/builtins/timeMeasure.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | const timeMeasure = (memoize => () => (data, next, bypass) => { 20 | if (!memoize[data.id]) { 21 | memoize[data.id] = new Date().getTime() 22 | bypass() 23 | return 24 | } 25 | 26 | memoize[data.id] = new Date().getTime() - memoize[data.id] 27 | console.log(`request '${data.id}' takes an ${memoize[data.id]} milliseconds for responding. : ${data.method}`) 28 | next( 29 | Object.assign(data, { 30 | timeTakes: memoize[data.id], 31 | }) 32 | ) 33 | })({}) 34 | 35 | module.exports = timeMeasure 36 | -------------------------------------------------------------------------------- /packages/caver-net/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "caver-net", 3 | "version": "1.0.0", 4 | "description": "This is a sub package of [caver-js][repo]", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "Klaytn Team", 10 | "license": "LGPL-3.0" 11 | } 12 | -------------------------------------------------------------------------------- /packages/caver-net/src/index.js: -------------------------------------------------------------------------------- 1 | /* 2 | Modifications copyright 2018 The caver-js Authors 3 | This file is part of web3.js. 4 | 5 | web3.js is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | web3.js is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with web3.js. If not, see . 17 | 18 | This file is derived from web3.js/packages/web3-net/src/index.js (2019/06/12). 19 | Modified and improved for the caver-js development. 20 | */ 21 | /** 22 | * @file index.js 23 | * @author Fabian Vogelsteller 24 | * @date 2017 25 | */ 26 | 27 | const core = require('../../caver-core') 28 | const rpc = require('../../caver-rtm').rpc 29 | const Method = require('../../caver-core-method') 30 | 31 | const Net = function Net(...args) { 32 | const _this = this 33 | 34 | core.packageInit(this, args) 35 | const rpcCalls = [rpc.net.getId, rpc.net.isListening, rpc.net.getPeerCount, rpc.net.peerCountByType] 36 | rpcCalls.forEach(function(method) { 37 | method = new Method(method) 38 | method.attachToObject(_this) 39 | method.setRequestManager(_this._requestManager) 40 | }) 41 | } 42 | 43 | module.exports = Net 44 | -------------------------------------------------------------------------------- /packages/caver-rpc/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "caver-rpc", 3 | "version": "1.0.0", 4 | "description": "This is a sub package of [caver-js][repo]", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "Klaytn Team", 10 | "license": "LGPL-3.0" 11 | } 12 | -------------------------------------------------------------------------------- /packages/caver-rtm/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "caver-rtm", 3 | "version": "1.0.0", 4 | "main": "src/index.js", 5 | "scripts": { 6 | "test": "echo \"Error: no test specified\" && exit 1" 7 | }, 8 | "author": "Klaytn Team", 9 | "license": "LGPL-3.0" 10 | } 11 | -------------------------------------------------------------------------------- /packages/caver-transaction/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "caver-transaction", 3 | "version": "1.0.0", 4 | "main": "src/index.js", 5 | "scripts": { 6 | "test": "echo \"Error: no test specified\" && exit 1" 7 | }, 8 | "author": "Klaytn Team", 9 | "license": "LGPL-3.0" 10 | } 11 | -------------------------------------------------------------------------------- /packages/caver-transaction/src/transactionHasher/transactionHasher.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | const Hash = require('eth-lib/lib/hash') 20 | 21 | class TransactionHasher { 22 | static getHashForSignature(transaction) { 23 | const rlpEncoded = transaction.getRLPEncodingForSignature() 24 | return Hash.keccak256(rlpEncoded) 25 | } 26 | 27 | static getHashForFeePayerSignature(transaction) { 28 | const rlpEncoded = transaction.getRLPEncodingForFeePayerSignature() 29 | return Hash.keccak256(rlpEncoded) 30 | } 31 | } 32 | 33 | module.exports = TransactionHasher 34 | -------------------------------------------------------------------------------- /packages/caver-transaction/src/transactionTypes/wrappers/cancelWrapper.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | const Cancel = require('../cancel/cancel') 20 | 21 | /** 22 | * Represents a cancel transaction wrapper. 23 | * @class 24 | * @hideconstructor 25 | */ 26 | class CancelWrapper { 27 | /** 28 | * Creates a cancel transaction wrapper. 29 | * The wrapper plays an intermediate role for calling static functions of each transaction type in `caver.transaction`. 30 | * @constructor 31 | * @param {object} _klaytnCall - An object includes klay rpc calls. 32 | */ 33 | constructor(klaytnCall) { 34 | this.klaytnCall = klaytnCall 35 | } 36 | 37 | /** 38 | * Calls `Cancel.create`. 39 | * 40 | * @param {object} obj - An object defines fields to create a tx. 41 | * @return {string} An RLP-encoded transaction string. 42 | */ 43 | create(obj) { 44 | return Cancel.create(obj, this.klaytnCall) 45 | } 46 | 47 | /** 48 | * Calls `CancelMemo.decode`. 49 | * 50 | * @param {string} encoded - RLP-encoded string. 51 | * @return {string} CancelMemo instance. 52 | */ 53 | decode(encoded) { 54 | return Cancel.decode(encoded, this.klaytnCall) 55 | } 56 | } 57 | 58 | module.exports = CancelWrapper 59 | -------------------------------------------------------------------------------- /packages/caver-utils/iban/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "iban", 3 | "version": "1.0.0", 4 | "description": "This is a sub package of [caver-js][repo]", 5 | "main": "src/index.js", 6 | "dependencies": {}, 7 | "devDependencies": {}, 8 | "scripts": { 9 | "test": "echo \"Error: no test specified\" && exit 1" 10 | }, 11 | "author": "Klaytn Team", 12 | "license": "LGPL-3.0" 13 | } 14 | -------------------------------------------------------------------------------- /packages/caver-utils/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "caver-utils", 3 | "version": "1.0.0", 4 | "description": "This is a sub package of [caver-js][repo]", 5 | "main": "src/index.js", 6 | "dependencies": {}, 7 | "devDependencies": {}, 8 | "scripts": { 9 | "test": "echo \"Error: no test specified\" && exit 1" 10 | }, 11 | "author": "Klaytn Team", 12 | "license": "LGPL-3.0" 13 | } 14 | -------------------------------------------------------------------------------- /packages/caver-utils/promievent/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "caver-promievent", 3 | "version": "1.0.0", 4 | "description": "Combine promise with eventemitter", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "Klaytn Team", 10 | "license": "LGPL-3.0" 11 | } 12 | -------------------------------------------------------------------------------- /packages/caver-utils/randomhex/browser.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | /* eslint-disable no-undef */ 20 | module.exports = window.crypto 21 | -------------------------------------------------------------------------------- /packages/caver-utils/randomhex/crypto.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | module.exports = require('crypto') 20 | -------------------------------------------------------------------------------- /packages/caver-validator/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "caver-validator", 3 | "version": "1.0.0", 4 | "description": "This is a sub package of [caver-js][repo]", 5 | "main": "src/index.js", 6 | "dependencies": {}, 7 | "devDependencies": {}, 8 | "scripts": { 9 | "test": "echo \"Error: no test specified\" && exit 1" 10 | }, 11 | "author": "Klaytn Team", 12 | "license": "LGPL-3.0" 13 | } 14 | -------------------------------------------------------------------------------- /packages/caver-wallet/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "caver-wallet", 3 | "version": "1.0.0", 4 | "description": "This is a sub package of [caver-js][repo]", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "Klaytn Team", 10 | "license": "LGPL-3.0" 11 | } 12 | -------------------------------------------------------------------------------- /release_rc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Fetch tags from upstream first 4 | git fetch -t git@github.com:klaytn/caver-js.git 5 | 6 | VERSION=$(cat package.json | jq -r '.["version"]') 7 | echo "Trying to tag v$VERSION" 8 | git tag | grep "$VERSION\$" 9 | if [ $? -eq 0 ]; then 10 | echo "$VERSION is found in git tag!!! You should upgrade version number first!!!" 11 | echo "Exiting..." 12 | exit 1 13 | fi 14 | 15 | PREV_RCVERSION_FULL=`git tag | grep "$VERSION" | sort | tail -1` 16 | RCSUFFIX="1" 17 | if [ ! -z "$PREV_RCVERSION_FULL" ]; then 18 | RCSUFFIX=$(echo "${PREV_RCVERSION_FULL##*.}"+1 | bc) 19 | fi 20 | 21 | RCVERSION="v$VERSION-rc.$RCSUFFIX" 22 | echo "tagging $RCVERSION" 23 | 24 | git tag $RCVERSION 25 | git push upstream $RCVERSION 26 | -------------------------------------------------------------------------------- /test/accounts.signTransaction.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | const { expect } = require('./extendedChai') 20 | 21 | const Caver = require('../index') 22 | const testRPCURL = require('./testrpc') 23 | 24 | const caver = new Caver(testRPCURL) 25 | 26 | describe('caver.klay.accounts.signTransaction', () => { 27 | it('CAVERJS-UNIT-TX-001 : should be rejected when data field is missing for contract creation tx', () => { 28 | const testAccount = caver.klay.accounts.wallet.add(caver.klay.accounts.create()) 29 | 30 | const tx = { 31 | value: '1000000000', 32 | gas: 2000000, 33 | } 34 | 35 | expect(caver.klay.accounts.signTransaction(tx, testAccount.transactionKey)).to.eventually.rejected 36 | }) 37 | }) 38 | -------------------------------------------------------------------------------- /test/eventEmitter.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | const { expect } = require('chai') 20 | const testRPCURL = require('./testrpc') 21 | 22 | const Caver = require('../index') 23 | 24 | const caver = new Caver(testRPCURL) 25 | 26 | let senderPrvKey 27 | let senderAddress 28 | let receiver 29 | 30 | before(() => { 31 | senderPrvKey = 32 | process.env.privateKey && String(process.env.privateKey).indexOf('0x') === -1 33 | ? `0x${process.env.privateKey}` 34 | : process.env.privateKey 35 | 36 | caver.klay.accounts.wallet.add(senderPrvKey) 37 | senderAddress = caver.klay.accounts.privateKeyToAccount(senderPrvKey).address 38 | 39 | receiver = caver.klay.accounts.wallet.add(caver.klay.accounts.create()) 40 | }) 41 | 42 | describe('eventEmitter with transactionHash', () => { 43 | it('CAVERJS-UNIT-ETC-048: transactionHash event is called only with transactionHash.', () => { 44 | caver.klay 45 | .sendTransaction({ 46 | from: senderAddress, 47 | to: receiver.address, 48 | value: 1, 49 | gas: 900000, 50 | }) 51 | .on('transactionHash', hash => expect(typeof hash).to.equals('string')) 52 | }).timeout(10000) 53 | }) 54 | -------------------------------------------------------------------------------- /test/extendedChai.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | const chai = require('chai') 20 | const chaiAsPromised = require('chai-as-promised') 21 | 22 | chai.use(chaiAsPromised) 23 | 24 | module.exports = chai 25 | -------------------------------------------------------------------------------- /test/getBlock.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | const { expect } = require('chai') 20 | const Caver = require('../index') 21 | const testRPCURL = require('./testrpc') 22 | 23 | const caver = new Caver(testRPCURL) 24 | 25 | describe('get block', () => { 26 | it('should have specific property', async () => { 27 | const blockInfo = await caver.klay.getBlock(1) 28 | expect(blockInfo.receiptsRoot).to.exist 29 | }) 30 | 31 | it('should return error when calling on non-existent block', done => { 32 | caver.klay.getBlockNumber().then(currentBlockNumber => { 33 | const queryBlockNumber = currentBlockNumber + 10000 34 | caver.klay 35 | .getBlock(queryBlockNumber) 36 | .then(() => { 37 | done(false) 38 | }) 39 | .catch(err => { 40 | expect(err).to.be.null 41 | done() 42 | }) 43 | }) 44 | }) 45 | }) 46 | -------------------------------------------------------------------------------- /test/getBlockTransactionCount.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | const { expect } = require('chai') 20 | 21 | const Caver = require('../index') 22 | const testRPCURL = require('./testrpc') 23 | 24 | const caver = new Caver(testRPCURL) 25 | 26 | describe('get block transaction count', () => { 27 | it('should not throw an error with "earliest" parameter', async () => { 28 | const blockTransactionCount = await caver.klay.getBlockTransactionCount('earliest') 29 | expect(blockTransactionCount).to.exist 30 | }) 31 | 32 | it('should not throw an error with "genesis" parameter', async () => { 33 | const blockTransactionCount = await caver.klay.getBlockTransactionCount('genesis') 34 | expect(blockTransactionCount).to.exist 35 | }) 36 | 37 | it('should not throw an error with "latest" parameter', async () => { 38 | const blockTransactionCount = await caver.klay.getBlockTransactionCount('latest') 39 | expect(blockTransactionCount).to.exist 40 | }) 41 | 42 | it('should not throw an error with "pending" parameter', async () => { 43 | const blockTransactionCount = await caver.klay.getBlockTransactionCount('pending') 44 | expect(blockTransactionCount).to.exist 45 | }) 46 | }) 47 | -------------------------------------------------------------------------------- /test/getChainId.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | const { expect } = require('./extendedChai') 20 | const Caver = require('../index') 21 | const testRPCURL = require('./testrpc') 22 | 23 | describe('caver.klay.net.getChainId', () => { 24 | it('Should return number type chain id', async () => { 25 | const caver = new Caver(testRPCURL) 26 | const chainId = await caver.klay.getChainId() 27 | expect(chainId).be.a('number') 28 | }) 29 | }).timeout(20000) 30 | -------------------------------------------------------------------------------- /test/getCouncil.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | const { expect } = require('./extendedChai') 20 | 21 | const testRPCURL = require('./testrpc') 22 | 23 | const Caver = require('../index') 24 | 25 | const caver = new Caver(testRPCURL) 26 | 27 | describe('getCouncil from Node', () => { 28 | it('should throw an error on "pending" tag', done => { 29 | caver.klay 30 | .getCouncil('pending') 31 | .then(() => done(false)) 32 | .catch(() => done()) 33 | }) 34 | 35 | it('council should not be an empty on "latest" tag', async () => { 36 | const council = await caver.klay.getCouncil('latest') 37 | expect(council).not.to.be.empty 38 | }) 39 | 40 | it('council should not be an empty on "earliest" tag', async () => { 41 | const council = await caver.klay.getCouncil('earliest') 42 | expect(council).not.to.be.empty 43 | }) 44 | 45 | it('council should not be an empty on "genesis" tag', async () => { 46 | const council = await caver.klay.getCouncil('genesis') 47 | expect(council).not.to.be.empty 48 | }) 49 | 50 | it('could be called without parameters', async () => { 51 | const council = await caver.klay.getCouncil() 52 | expect(council).not.to.be.empty 53 | }) 54 | }) 55 | -------------------------------------------------------------------------------- /test/getNodeInfo.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | const { expect } = require('./extendedChai') 20 | 21 | const testRPCURL = require('./testrpc') 22 | 23 | const Caver = require('../index') 24 | 25 | describe('getNodeInfo from Node', () => { 26 | it('CAVERJS-UNIT-ETC-042: should return valid value', () => { 27 | const caver = new Caver(testRPCURL) 28 | expect(() => caver.klay.getNodeInfo()).not.to.throws() 29 | }) 30 | }) 31 | -------------------------------------------------------------------------------- /test/getPastLogs.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | const Caver = require('../index') 20 | const testRPCURL = require('./testrpc') 21 | 22 | describe('getPastLogs', () => { 23 | it('should contain id and removed field', async () => { 24 | const caver = new Caver(testRPCURL) 25 | 26 | caver.klay.getPastLogs({ 27 | fromBlock: '0x0', 28 | address: '0x9aa91c689248b0111dc756d7d505af4c2ff6be1b', 29 | }) 30 | }) 31 | 32 | it('should not throw an error with number type `fromBlock`', async () => { 33 | const caver = new Caver(testRPCURL) 34 | 35 | caver.klay.getPastLogs({ 36 | fromBlock: 1, 37 | address: '0x9aa91c689248b0111dc756d7d505af4c2ff6be1b', 38 | }) 39 | }) 40 | 41 | it('should not throw an error with number type `toBlock`', async () => { 42 | const caver = new Caver(testRPCURL) 43 | 44 | caver.klay.getPastLogs({ 45 | toBlock: 1000, 46 | address: '0x9aa91c689248b0111dc756d7d505af4c2ff6be1b', 47 | }) 48 | }).timeout(100000) 49 | }) 50 | -------------------------------------------------------------------------------- /test/getStorageAt.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | const { expect } = require('chai') 20 | const Caver = require('../index') 21 | 22 | describe('get storage at', () => { 23 | it('should not throw an error with string type parameter', async () => { 24 | const caver = new Caver('http://aspen.klaytn.com') 25 | const stroageInfo = await caver.klay.getStorageAt('0x9e6df5dbc96b2d4f5bee35fd99d832361360c82a', '1') 26 | expect(stroageInfo).to.exist 27 | }) 28 | 29 | it('should not throw an error with number type parameter', async () => { 30 | const caver = new Caver('http://aspen.klaytn.com') 31 | const stroageInfo = await caver.klay.getStorageAt('0x9e6df5dbc96b2d4f5bee35fd99d832361360c82a', 1) 32 | expect(stroageInfo).to.exist 33 | }) 34 | }) 35 | -------------------------------------------------------------------------------- /test/getTransactionCount.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | const { expect } = require('chai') 20 | const Caver = require('../index') 21 | const testRPCURL = require('./testrpc') 22 | 23 | const caver = new Caver(testRPCURL) 24 | 25 | describe('get transaction count', () => { 26 | it('should not throw an error with "genesis" default block', async () => { 27 | const cnt = await caver.klay.getTransactionCount(caver.klay.accounts.create().address, 'genesis') 28 | expect(cnt).to.be.a('number') 29 | }) 30 | 31 | it('should not throw an error with "earliest" default block', async () => { 32 | const cnt = await caver.klay.getTransactionCount(caver.klay.accounts.create().address, 'earliest') 33 | expect(cnt).to.be.a('number') 34 | }) 35 | 36 | it('should not throw an error with "latest" default block', async () => { 37 | const cnt = await caver.klay.getTransactionCount(caver.klay.accounts.create().address, 'latest') 38 | expect(cnt).to.be.a('number') 39 | }) 40 | 41 | it('should not throw an error with "pending" default block', async () => { 42 | const cnt = await caver.klay.getTransactionCount(caver.klay.accounts.create().address, 'pending') 43 | expect(cnt).to.be.a('number') 44 | }) 45 | }) 46 | -------------------------------------------------------------------------------- /test/getValidators.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | const { expect } = require('chai') 20 | const Caver = require('../index') 21 | const testRPCURL = require('./testrpc') 22 | 23 | let caver 24 | beforeEach(() => { 25 | caver = new Caver(testRPCURL) 26 | }) 27 | 28 | describe('get validators', () => { 29 | it('getValidators should throw error.', () => { 30 | expect(() => caver.klay.getValidators()).to.throw('caver.klay.getValidators is not a function') 31 | }) 32 | }) 33 | -------------------------------------------------------------------------------- /test/hashMessage.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | const { expect } = require('./extendedChai') 20 | 21 | const Caver = require('../index') 22 | const testRPCURL = require('./testrpc') 23 | 24 | describe('caver.klay.accounts.hashMessage', () => { 25 | it('CAVERJS-UNIT-ETC-003 : should have same value with utf8ToHex', async () => { 26 | const caver = new Caver(testRPCURL) 27 | 28 | const rawStringHashed = caver.klay.accounts.hashMessage('Hello World') 29 | const hexStringHashed = caver.klay.accounts.hashMessage(caver.utils.utf8ToHex('Hello World')) 30 | expect(rawStringHashed).to.equal(hexStringHashed) 31 | }) 32 | 33 | it('CAVERJS-UNIT-ETC-004 : should have same value with caver.utils.sha3 containing prefix message', () => { 34 | const caver = new Caver(testRPCURL) 35 | 36 | const rawMessage = 'Hello World' 37 | const rawStringHashed = caver.klay.accounts.hashMessage(rawMessage) 38 | const sha3StringHashed = caver.utils.sha3(`\x19Klaytn Signed Message:\n${rawMessage.length}${rawMessage}`) 39 | 40 | expect(rawStringHashed).to.equal(sha3StringHashed) 41 | }) 42 | }) 43 | -------------------------------------------------------------------------------- /test/iban.createIndirect.js: -------------------------------------------------------------------------------- 1 | /* 2 | Modifications copyright 2018 The caver-js Authors 3 | This file is part of the web3.js library. 4 | 5 | The web3.js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The web3.js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the web3.js. If not, see . 17 | 18 | This file is derived from web3.js/test/iban.createIndirect.js (2019/06/12). 19 | Modified and improved for the caver-js development. 20 | */ 21 | 22 | const chai = require('chai') 23 | const Iban = require('../packages/caver-utils/iban/src/index') 24 | 25 | const assert = chai.assert 26 | 27 | const tests = [{ institution: 'XREG', identifier: 'GAVOFYORK', expected: 'XE81ETHXREGGAVOFYORK' }] 28 | 29 | describe('caver-utils/iban/src/index', function() { 30 | describe('createIndirect', function() { 31 | tests.forEach(function(test) { 32 | it(`CAVERJS-UNIT-ETC-005 : shoud create indirect iban: ${test.expected}`, function() { 33 | assert.deepEqual( 34 | Iban.createIndirect({ 35 | institution: test.institution, 36 | identifier: test.identifier, 37 | }), 38 | new Iban(test.expected) 39 | ) 40 | }) 41 | }) 42 | }) 43 | }) 44 | -------------------------------------------------------------------------------- /test/iban.toAddress.js: -------------------------------------------------------------------------------- 1 | /* 2 | Modifications copyright 2018 The caver-js Authors 3 | This file is part of the web3.js library. 4 | 5 | The web3.js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The web3.js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the web3.js. If not, see . 17 | 18 | This file is derived from web3.js/test/iban.toAddress.js (2019/06/12). 19 | Modified and improved for the caver-js development. 20 | */ 21 | 22 | const chai = require('chai') 23 | const Iban = require('../packages/caver-utils/iban/src/index') 24 | 25 | const assert = chai.assert 26 | 27 | const tests = [{ direct: 'XE7338O073KYGTWWZN0F2WZ0R8PX5ZPPZS', address: '0x00c5496aEe77C1bA1f0854206A26DdA82a81D6D8' }] 28 | 29 | describe('caver-utils/iban', function() { 30 | describe('toAddress', function() { 31 | tests.forEach(function(test) { 32 | it(`CAVERJS-UNIT-ETC-008 : shoud transform iban to address: ${test.address}`, function() { 33 | const iban = new Iban(test.direct) 34 | assert.deepEqual(iban.toAddress(), test.address) 35 | }) 36 | }) 37 | }) 38 | }) 39 | -------------------------------------------------------------------------------- /test/multiProviderTest.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | const Caver = require('../index') 20 | const { expect } = require('./extendedChai') 21 | 22 | const host1URL = 'http://random1.test.host:8551/' 23 | const host1 = new Caver(host1URL) 24 | const host2URL = 'https://random2.test.host:8651/' 25 | const host2 = new Caver(host2URL) 26 | 27 | describe('Test multi provider', () => { 28 | it('CAVERJS-UNIT-ETC-077: For each provider, the request must be processed using its own requestManager.', async () => { 29 | expect(host1.klay.currentProvider.host).to.equals(host1URL) 30 | expect(host1.klay.net.currentProvider.host).to.equals(host1URL) 31 | expect(host1.klay.personal.currentProvider.host).to.equals(host1URL) 32 | expect(host1.klay.Contract.currentProvider.host).to.equals(host1URL) 33 | expect(host1.klay.accounts.currentProvider.host).to.equals(host1URL) 34 | 35 | expect(host2.klay.currentProvider.host).to.equals(host2URL) 36 | expect(host2.klay.net.currentProvider.host).to.equals(host2URL) 37 | expect(host2.klay.personal.currentProvider.host).to.equals(host2URL) 38 | expect(host2.klay.Contract.currentProvider.host).to.equals(host2URL) 39 | expect(host2.klay.accounts.currentProvider.host).to.equals(host2URL) 40 | }).timeout(10000) 41 | }) 42 | -------------------------------------------------------------------------------- /test/mutatedInstanceMethod.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | const { expect } = require('chai') 20 | 21 | const testRPCURL = require('./testrpc') 22 | const Caver = require('../index') 23 | 24 | describe('MutatedInstance', () => { 25 | it('should be different method provider host', done => { 26 | const caver1 = new Caver('http://www.naver.com') 27 | 28 | const caver2 = new Caver(testRPCURL) 29 | 30 | expect(caver1.klay.getBlockNumber.method.requestManager.provider.host).to.not.eql( 31 | caver2.klay.getBlockNumber.method.requestManager.provider.host 32 | ) 33 | done() 34 | }) 35 | 36 | it('should be different method provider object', done => { 37 | const caver1 = new Caver('http://www.naver.com') 38 | 39 | const caver2 = new Caver(testRPCURL) 40 | 41 | expect(caver1.klay.getBlockNumber.method.requestManager.provider).to.not.eql( 42 | caver2.klay.getBlockNumber.method.requestManager.provider 43 | ) 44 | done() 45 | }) 46 | }) 47 | -------------------------------------------------------------------------------- /test/networkRPCMethods.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | const { expect } = require('./extendedChai') 20 | const Caver = require('../index') 21 | const testRPCURL = require('./testrpc') 22 | 23 | describe('caver.klay.net', () => { 24 | it('caver.klay.net.getId should return number type network id', done => { 25 | const caver = new Caver(testRPCURL) 26 | 27 | caver.klay.net.getId().then(res => { 28 | expect(res).be.a('number') 29 | done() 30 | }) 31 | }) 32 | 33 | it('caver.klay.net.getPeerCount should return number type peer count', done => { 34 | const caver = new Caver(testRPCURL) 35 | caver.klay.net.getPeerCount().then(res => { 36 | expect(res).be.a('number') 37 | done() 38 | }) 39 | }) 40 | }).timeout(20000) 41 | -------------------------------------------------------------------------------- /test/packages/setting.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | const setting = { 20 | networkId: 1001, 21 | peerCount: 2, 22 | gas: 900000, 23 | gasPrice: 25000000000, 24 | fromAddress: '0x11d54a1ad94909e234a39a3e8d9ff169ba3d0941', 25 | toAddress: '0x30d8d4217145ba3f6cde24ec28c64c9120f2bdfb', 26 | } 27 | 28 | module.exports = setting 29 | -------------------------------------------------------------------------------- /test/predefinedBlockNumber.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | const { expect } = require('chai') 20 | 21 | const testRPCURL = require('./testrpc') 22 | 23 | const Caver = require('../index') 24 | 25 | const caver = new Caver(testRPCURL) 26 | 27 | describe('Predefined block number', () => { 28 | it('genesis', async () => { 29 | caver.klay.defaultBlock = 'genesis' 30 | const { address } = caver.klay.accounts.create() 31 | expect(await caver.klay.getTransactionCount(address)).to.exist 32 | }) 33 | 34 | it('latest', async () => { 35 | caver.klay.defaultBlock = 'latest' 36 | const { address } = caver.klay.accounts.create() 37 | expect(await caver.klay.getTransactionCount(address)).to.exist 38 | }) 39 | 40 | it('earliest', async () => { 41 | caver.klay.defaultBlock = 'earliest' 42 | const { address } = caver.klay.accounts.create() 43 | expect(await caver.klay.getTransactionCount(address)).to.exist 44 | }) 45 | 46 | it('pending', async () => { 47 | caver.klay.defaultBlock = 'pending' 48 | const { address } = caver.klay.accounts.create() 49 | expect(await caver.klay.getTransactionCount(address)).to.exist 50 | }) 51 | }) 52 | -------------------------------------------------------------------------------- /test/randomHex.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | const { expect } = require('./extendedChai') 20 | 21 | const Caver = require('../index') 22 | const testRPCURL = require('./testrpc') 23 | 24 | describe('utils.randomHex', () => { 25 | it('CAVERJS-UNIT-ETC-009 : Should throw an error with out of range size', async () => { 26 | const caver = new Caver(testRPCURL) 27 | 28 | const tooLowSize = -1 29 | const tooHighSize = 65537 30 | 31 | expect(() => caver.utils.randomHex(tooLowSize)).throw() 32 | expect(() => caver.utils.randomHex(tooHighSize)).throw() 33 | }) 34 | }) 35 | -------------------------------------------------------------------------------- /test/supportsSubscriptions.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2019 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | const { expect } = require('./extendedChai') 20 | 21 | const testRPCURL = require('./testrpc') 22 | const websocketURL = require('./testWebsocket') 23 | 24 | const Caver = require('../index') 25 | 26 | describe('supportsSubscriptions from Providers', () => { 27 | it('CAVERJS-UNIT-ETC-095: HttpProvider should return false', () => { 28 | const caver = new Caver(testRPCURL) 29 | expect(caver.klay.currentProvider.supportsSubscriptions()).to.be.false 30 | }) 31 | 32 | it('CAVERJS-UNIT-ETC-096: WebSocketProvider should return true', () => { 33 | const caver = new Caver(websocketURL) 34 | expect(caver.klay.currentProvider.supportsSubscriptions()).to.be.true 35 | caver.currentProvider.connection.close() 36 | }) 37 | }) 38 | -------------------------------------------------------------------------------- /test/test-web/.eslintrc_template.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['react-app', 'react-app/jest'], 3 | } 4 | -------------------------------------------------------------------------------- /test/test-web/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | yarn.lock 8 | 9 | # testing 10 | /coverage 11 | 12 | # production 13 | /build 14 | 15 | # misc 16 | .DS_Store 17 | .env.local 18 | .env.development.local 19 | .env.test.local 20 | .env.production.local 21 | 22 | npm-debug.log* 23 | yarn-debug.log* 24 | yarn-error.log* 25 | 26 | /public/caver.min.js 27 | 28 | .eslintrc.js 29 | src/testrpc.js -------------------------------------------------------------------------------- /test/test-web/config-overrides.js: -------------------------------------------------------------------------------- 1 | const webpack = require('webpack') 2 | module.exports = function override(config, env) { 3 | config.resolve.fallback = { 4 | fs: false, 5 | net: false, 6 | crypto: require.resolve('crypto-browserify'), 7 | http: require.resolve('stream-http'), 8 | https: require.resolve('https-browserify'), 9 | os: require.resolve('os-browserify/browser'), 10 | buffer: require.resolve('buffer'), 11 | stream: require.resolve('stream-browserify'), 12 | constants: require.resolve('constants-browserify'), 13 | } 14 | config.plugins.push( 15 | new webpack.ProvidePlugin({ 16 | process: 'process/browser', 17 | Buffer: ['buffer', 'Buffer'], 18 | }), 19 | ) 20 | 21 | return config 22 | } 23 | -------------------------------------------------------------------------------- /test/test-web/cypress.json: -------------------------------------------------------------------------------- 1 | { 2 | "video": false 3 | } 4 | -------------------------------------------------------------------------------- /test/test-web/cypress/integration/webEnvTest.spec.js: -------------------------------------------------------------------------------- 1 | describe('executing test scenario on the localhost:3000', () => { 2 | beforeEach(() => { 3 | cy.visit('http://localhost:3000') 4 | }) 5 | 6 | it('get block number test via caver-js bundle', (done) => { 7 | cy.get('[id="success"]', { timeout: 10000 }).should('be.visible') 8 | cy.get('[id="blockNumber"]').then(ele => { 9 | const innerHTML = ele.text() 10 | const blockNumber = innerHTML.split(': ')[innerHTML.split(': ').length-1] 11 | expect(blockNumber).not.to.be.undefined 12 | expect(blockNumber).not.to.equal('0x') 13 | expect(blockNumber.includes('0x')).to.be.true 14 | done() 15 | }) 16 | }) 17 | 18 | it('get block number test via react component', (done) => { 19 | cy.get('[id="blockNumberInReactComponent"]', { timeout: 10000 }).should('be.visible') 20 | cy.get('[id="blockNumberInReactComponent"]').then(ele => { 21 | const blockNumber = ele.text() 22 | expect(blockNumber).not.to.equal(-1) 23 | done() 24 | }) 25 | }) 26 | }) -------------------------------------------------------------------------------- /test/test-web/cypress/plugins/index.js: -------------------------------------------------------------------------------- 1 | /// 2 | // *********************************************************** 3 | // This example plugins/index.js can be used to load plugins 4 | // 5 | // You can change the location of this file or turn off loading 6 | // the plugins file with the 'pluginsFile' configuration option. 7 | // 8 | // You can read more here: 9 | // https://on.cypress.io/plugins-guide 10 | // *********************************************************** 11 | 12 | // This function is called when a project is opened or re-opened (e.g. due to 13 | // the project's config changing) 14 | 15 | /** 16 | * @type {Cypress.PluginConfig} 17 | */ 18 | module.exports = (on, config) => { 19 | // `on` is used to hook into various events Cypress emits 20 | // `config` is the resolved Cypress config 21 | } 22 | -------------------------------------------------------------------------------- /test/test-web/cypress/support/commands.js: -------------------------------------------------------------------------------- 1 | // *********************************************** 2 | // This example commands.js shows you how to 3 | // create various custom commands and overwrite 4 | // existing commands. 5 | // 6 | // For more comprehensive examples of custom 7 | // commands please read more here: 8 | // https://on.cypress.io/custom-commands 9 | // *********************************************** 10 | // 11 | // 12 | // -- This is a parent command -- 13 | // Cypress.Commands.add('login', (email, password) => { ... }) 14 | // 15 | // 16 | // -- This is a child command -- 17 | // Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) 18 | // 19 | // 20 | // -- This is a dual command -- 21 | // Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) 22 | // 23 | // 24 | // -- This will overwrite an existing command -- 25 | // Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) 26 | -------------------------------------------------------------------------------- /test/test-web/cypress/support/index.js: -------------------------------------------------------------------------------- 1 | // *********************************************************** 2 | // This example support/index.js is processed and 3 | // loaded automatically before your test files. 4 | // 5 | // This is a great place to put global configuration and 6 | // behavior that modifies Cypress. 7 | // 8 | // You can change the location of this file or turn off 9 | // automatically serving support files with the 10 | // 'supportFile' configuration option. 11 | // 12 | // You can read more here: 13 | // https://on.cypress.io/configuration 14 | // *********************************************************** 15 | 16 | // Import commands.js using ES2015 syntax: 17 | import './commands' 18 | 19 | // Alternatively you can use CommonJS syntax: 20 | // require('./commands') 21 | -------------------------------------------------------------------------------- /test/test-web/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test-web", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^5.11.4", 7 | "caver-js": "file:../..", 8 | "constants-browserify": "^1.0.0", 9 | "crypto-browserify": "^3.12.0", 10 | "https-browserify": "^1.0.0", 11 | "os": "^0.1.2", 12 | "react": "^17.0.2", 13 | "react-app-rewired": "^2.1.11", 14 | "react-dom": "^17.0.2", 15 | "react-scripts": "^5.0.0", 16 | "stream-browserify": "^3.0.0", 17 | "stream-http": "^3.2.0", 18 | "web-vitals": "^1.0.1" 19 | }, 20 | "scripts": { 21 | "start": "react-app-rewired start", 22 | "build": "react-app-rewired build", 23 | "test": "npm run testWatch -- --watchAll=false", 24 | "testWatch": "react-app-rewired test --env=jest-environment-jsdom-sixteen", 25 | "eject": "react-app-rewired eject", 26 | "cypress:open": "cypress open", 27 | "cypress:run": "cypress run" 28 | }, 29 | "browserslist": { 30 | "production": [ 31 | ">0.2%", 32 | "not dead", 33 | "not op_mini all" 34 | ], 35 | "development": [ 36 | "last 1 chrome version", 37 | "last 1 firefox version", 38 | "last 1 safari version" 39 | ] 40 | }, 41 | "devDependencies": { 42 | "cypress": "^7.0.0", 43 | "pm2": "^5.2.2" 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /test/test-web/prepareWebTest.sh: -------------------------------------------------------------------------------- 1 | # Copy the bundle file to inject in HTML file (This will overwrite caver.min.js) 2 | cp ../../dist/caver.min.js ./public/caver.min.js 3 | 4 | # Copy the test configuration file 5 | DEV_URL=${EN_RPC_URL_DEV} 6 | if [ "${DEV_URL}" = "" ]; then 7 | ENV_FILE="../../.env" 8 | DEV_ENV=$(grep ${ENV_FILE} -e "EN_RPC_URL_DEV=") 9 | DEV_URL=${DEV_ENV//"EN_RPC_URL_DEV="/""} 10 | else 11 | DEV_URL="'${DEV_URL}'" 12 | fi 13 | 14 | # install modules 15 | rm -rf node_modules package-lock.json 16 | npm install 17 | 18 | # Copy the configuration file for eslint (To avoid eslint config conflict with outer project) 19 | cp .eslintrc_template.js .eslintrc.js 20 | 21 | # Make dev url file and replace `testrpc` string in index.html file 22 | echo module.exports=${DEV_URL} > ./src/testrpc.js 23 | sed -i' ' "s/testrpc/${DEV_URL/\/\//\\/\\/}/g" ./public/index.html 24 | 25 | # Prepare to test (background running) 26 | ./node_modules/pm2/bin/pm2 --name BundleTest start npm -- start -------------------------------------------------------------------------------- /test/test-web/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /test/test-web/src/App.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | const Caver = require('caver-js'); 3 | const testRPC = require('./testrpc'); 4 | const caver = new Caver(testRPC); 5 | 6 | class App extends React.Component { 7 | constructor(props) { 8 | super(props); 9 | 10 | this._isMounted = false; 11 | this.state = { 12 | blockNumber: -1, 13 | }; 14 | } 15 | 16 | async getBlockNumber() { 17 | try { 18 | const bn = await caver.rpc.klay.getBlockNumber() 19 | if (this._isMounted) this.setState({ blockNumber: caver.utils.hexToNumber(bn) }); 20 | return Promise.resolve() 21 | }catch(e) { 22 | return Promise.reject(e) 23 | } 24 | } 25 | 26 | componentDidMount() { 27 | this._isMounted = true; 28 | this.getBlockNumber() 29 | } 30 | 31 | componentWillUnmount() { 32 | this._isMounted = false; 33 | } 34 | 35 | render() { 36 | return ( 37 |
38 |
39 |

Klaytn BlockNumber

40 |

{this.state.blockNumber}

41 |
42 |
43 | ); 44 | } 45 | } 46 | 47 | export default App; 48 | -------------------------------------------------------------------------------- /test/test-web/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from './App'; 4 | 5 | ReactDOM.render( 6 | 7 | 8 | , 9 | document.getElementById('root') 10 | ); 11 | -------------------------------------------------------------------------------- /test/test-web/src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /test/test-web/terminateTest.sh: -------------------------------------------------------------------------------- 1 | ./node_modules/pm2/bin/pm2 delete BundleTest -------------------------------------------------------------------------------- /test/testWebsocket.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | const dotenv = require('dotenv') 20 | 21 | dotenv.config() 22 | 23 | const testWebsocketURL = process.env.EN_WS_URL_DEV || 'http://localhost:8552/' 24 | 25 | module.exports = testWebsocketURL 26 | -------------------------------------------------------------------------------- /test/testrpc.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | const dotenv = require('dotenv') 20 | 21 | dotenv.config() 22 | 23 | const testRPCURL = process.env.EN_RPC_URL_DEV || 'http://localhost:8551/' 24 | 25 | module.exports = testRPCURL 26 | -------------------------------------------------------------------------------- /test/toChecksumAddress.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | const { expect } = require('chai') 20 | const Caver = require('../index') 21 | const testRPCURL = require('./testrpc') 22 | 23 | describe('Checksum address', () => { 24 | it('CAVERJS-UNIT-ETC-016 : should convert to vaild checksum address', async () => { 25 | const caver = new Caver(testRPCURL) 26 | 27 | const address1 = '0xc1912fee45d61c87cc5ea59dae31190fffff232d' 28 | const address2 = '0XC1912FEE45D61C87CC5EA59DAE31190FFFFF232D' 29 | 30 | expect(caver.utils.toChecksumAddress(address1)).to.equal('0xc1912fEE45d61C87Cc5EA59DaE31190FFFFf232d') 31 | 32 | expect(caver.utils.toChecksumAddress(address2)).to.equal('0xc1912fEE45d61C87Cc5EA59DaE31190FFFFf232d') 33 | }) 34 | }) 35 | -------------------------------------------------------------------------------- /test/walletDefaultName.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | const { expect } = require('./extendedChai') 20 | 21 | const Caver = require('../index') 22 | const testRPCURL = require('./testrpc') 23 | 24 | describe('wallet instance default wallet name', () => { 25 | it('should return valid default wallet name', async () => { 26 | const caver = new Caver(testRPCURL) 27 | 28 | caver.klay.accounts.wallet.add(caver.klay.accounts.create()) 29 | 30 | expect(caver.klay.accounts.wallet.defaultKeyName).to.equal('caverjs_wallet') 31 | }) 32 | }) 33 | -------------------------------------------------------------------------------- /test/wrapErrorToHelperErrors.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2018 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | const { expect } = require('chai') 20 | const { errors } = require('../packages/caver-core-helpers') 21 | 22 | const testRPCURL = require('./testrpc') 23 | 24 | const Caver = require('../index') 25 | 26 | const caver = new Caver(testRPCURL) 27 | 28 | describe('wrap error to core-helper/errors', () => { 29 | it('should be thrown property missing error when "call" missing', done => { 30 | expect(() => new caver.Method({ name: 'hi' })).to.throw(errors.needNameCallPropertyToCreateMethod) 31 | done() 32 | }) 33 | 34 | it('should be thrown property missing error when "name" missing', done => { 35 | expect(() => new caver.Method({ call: 'hi' })).to.throw(errors.needNameCallPropertyToCreateMethod) 36 | done() 37 | }) 38 | 39 | it('should not be thrown property missing error when "name", "call" existing', done => { 40 | expect(() => new caver.Method({ name: 'hi', call: 'hi' })).not.to.throw(errors.needNameCallPropertyToCreateMethod) 41 | done() 42 | }) 43 | }) 44 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": ["./index.js", "./packages/**/*.js"], 3 | "compilerOptions": { 4 | "allowJs": true, 5 | "declaration": true, 6 | "emitDeclarationOnly": true, 7 | "target": "es6", 8 | "module": "commonjs", 9 | "moduleResolution": "node", 10 | "esModuleInterop": true, 11 | "skipLibCheck": true, 12 | "removeComments": true, 13 | "noImplicitAny": false, 14 | "noLib": false, 15 | "outDir": "types", 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /turndown.js: -------------------------------------------------------------------------------- 1 | const TurndownService = require('turndown') 2 | const fs = require('fs') 3 | 4 | const turndownService = new TurndownService() 5 | turndownService.remove('nav') 6 | 7 | // out directory will have HTML files which is generated from jsdoc 8 | const docsDirectory = `${__dirname}/out` 9 | const mdDirectory = `${docsDirectory}/md` 10 | 11 | const files = fs.readdirSync(docsDirectory) 12 | 13 | if (!fs.existsSync(mdDirectory)) fs.mkdirSync(mdDirectory) 14 | 15 | for (const file of files) { 16 | // Converts only HTML files 17 | if (!file.endsWith('.html') || file === 'index.html') continue 18 | 19 | // Converts a HTML file 20 | let markdown = turndownService.turndown(fs.readFileSync(`${docsDirectory}/${file}`).toString()) 21 | markdown = markdown.replace(/.html|_/g, '.md') 22 | 23 | // Writes a Markdown result to md file 24 | fs.writeFileSync(`${mdDirectory}/${file.replace('html', '')}md`, markdown) 25 | } 26 | -------------------------------------------------------------------------------- /types/packages/caver-abi/src/index.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { AbiInput, AbiItem } from '../../caver-utils/src' 17 | 18 | export interface Result { 19 | [k: string]: string | number 20 | __length__: number 21 | } 22 | 23 | export class ABI { 24 | decodeFunctionCall(abi: AbiItem, functionCall: string): Result 25 | decodeLog(inputs: AbiInput[], data: string, topics: string[]): Result 26 | decodeParameter(type: string | object, bytes: string): string 27 | decodeParameters(outputs: Array, bytes: string): Result 28 | encodeContractDeploy(jsonInterface: AbiItem[], bytecode: string, ...args: any[]): string 29 | encodeEventSignature(functionName: AbiItem | string): string 30 | encodeFunctionCall(jsonInterface: AbiItem, params: any): string 31 | encodeFunctionSignature(functionName: AbiItem | string): string 32 | encodeParameter(type: string | object, param: any): string 33 | encodeParameters(types: Array, params: any[]): string 34 | } 35 | -------------------------------------------------------------------------------- /types/packages/caver-account/src/accountKey/accountKeyDecoder.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { AccountKey } from '..' 17 | 18 | export interface AccountKeyDecoder { 19 | decode(rlpEncodedKey: string): AccountKey 20 | } 21 | -------------------------------------------------------------------------------- /types/packages/caver-account/src/accountKey/accountKeyFail.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { IAccountKey } from '..' 17 | export class AccountKeyFail implements IAccountKey { 18 | static decode(rlpEncodedKey: string): AccountKeyFail 19 | getRLPEncoding(): string 20 | } 21 | -------------------------------------------------------------------------------- /types/packages/caver-account/src/accountKey/accountKeyHelper.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { WeightedMultiSigOptions, WeightedMultiSigOptionsObject } from './weightedMultiSigOptions' 17 | 18 | export namespace ACCOUNT_KEY_TAG { 19 | const ACCOUNT_KEY_NIL_TAG: string 20 | const ACCOUNT_KEY_LEGACY_TAG: string 21 | const ACCOUNT_KEY_PUBLIC_TAG: string 22 | const ACCOUNT_KEY_FAIL_TAG: string 23 | const ACCOUNT_KEY_WEIGHTED_MULTISIG_TAG: string 24 | const ACCOUNT_KEY_ROLE_BASED_TAG: string 25 | } 26 | export function fillWeightedMultiSigOptionsForMultiSig( 27 | lengthOfKeys: number, 28 | options?: WeightedMultiSigOptions | WeightedMultiSigOptionsObject 29 | ): WeightedMultiSigOptions 30 | 31 | export function fillWeightedMultiSigOptionsForRoleBased( 32 | lengthOfKeys: number[], 33 | options?: WeightedMultiSigOptions[] | WeightedMultiSigOptionsObject[] 34 | ): WeightedMultiSigOptions[] 35 | -------------------------------------------------------------------------------- /types/packages/caver-account/src/accountKey/accountKeyLegacy.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { IAccountKey } from '..' 17 | export class AccountKeyLegacy implements IAccountKey { 18 | static decode(rlpEncodedKey: string): AccountKeyLegacy 19 | getRLPEncoding(): string 20 | } 21 | -------------------------------------------------------------------------------- /types/packages/caver-account/src/accountKey/accountKeyPublic.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { IAccountKey } from '..' 17 | 18 | export class AccountKeyPublic implements IAccountKey { 19 | static decode(rlpEncodedKey: string): AccountKeyPublic 20 | static fromXYPoint(x: string, y: string): AccountKeyPublic 21 | static fromPublicKey(pubKey: string): AccountKeyPublic 22 | 23 | constructor(publicKey: string) 24 | 25 | publicKey: string 26 | private _publicKey: string 27 | 28 | getRLPEncoding(): string 29 | getXYPoint(): string[] 30 | } 31 | -------------------------------------------------------------------------------- /types/packages/caver-account/src/accountKey/accountKeyRoleBased.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { IAccountKey } from '..' 17 | import { AccountKeyFail } from './accountKeyFail' 18 | import { AccountKeyLegacy } from './accountKeyLegacy' 19 | import { AccountKeyPublic } from './accountKeyPublic' 20 | import { AccountKeyWeightedMultiSig } from './accountKeyWeightedMultiSig' 21 | import { WeightedMultiSigOptions, WeightedMultiSigOptionsObject } from './weightedMultiSigOptions' 22 | 23 | export type AccountKeyRoleBasedRoleKeyType = AccountKeyLegacy | AccountKeyPublic | AccountKeyFail | AccountKeyWeightedMultiSig 24 | 25 | export class AccountKeyRoleBased implements IAccountKey { 26 | static decode(rlpEncodedKey: string): AccountKeyRoleBased 27 | static fromRoleBasedPublicKeysAndOptions( 28 | roleBasedPubArray: Array, 29 | options: Array 30 | ): AccountKeyRoleBased 31 | 32 | constructor(accountKeyArray: AccountKeyRoleBasedRoleKeyType[]) 33 | 34 | accountKeys: AccountKeyRoleBasedRoleKeyType[] 35 | private _accountKeys: AccountKeyRoleBasedRoleKeyType[] 36 | 37 | getRLPEncoding(): string 38 | } 39 | -------------------------------------------------------------------------------- /types/packages/caver-account/src/accountKey/accountKeyWeightedMultiSig.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { IAccountKey } from '..' 17 | import { WeightedPublicKey } from './weightedPublicKey' 18 | import { WeightedMultiSigOptions, WeightedMultiSigOptionsObject } from './weightedMultiSigOptions' 19 | 20 | export class AccountKeyWeightedMultiSig implements IAccountKey { 21 | static decode(rlpEncodedKey: string): AccountKeyWeightedMultiSig 22 | static fromPublicKeysAndOptions( 23 | publicKeyArray: string[], 24 | options?: WeightedMultiSigOptions | WeightedMultiSigOptionsObject 25 | ): AccountKeyWeightedMultiSig 26 | 27 | constructor(threshold: number, weightedPublicKeys: WeightedPublicKey[]) 28 | 29 | threshold: number 30 | weightedPublicKeys: WeightedPublicKey[] 31 | private _threshold: number 32 | private _weightedPublicKeys: WeightedPublicKey[] 33 | 34 | getRLPEncoding(): string 35 | } 36 | -------------------------------------------------------------------------------- /types/packages/caver-account/src/accountKey/weightedMultiSigOptions.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | export interface WeightedMultiSigOptionsObject { 17 | threshold?: number 18 | weights?: number[] 19 | weight?: number[] 20 | } 21 | 22 | export class WeightedMultiSigOptions { 23 | static fromObject(options: WeightedMultiSigOptionsObject): WeightedMultiSigOptions 24 | 25 | constructor(threshold: number, weights: number[]) 26 | 27 | threshold: number 28 | weights: number[] 29 | private _threshold: number 30 | private _weights: number[] 31 | 32 | isEmpty(): boolean 33 | } 34 | -------------------------------------------------------------------------------- /types/packages/caver-account/src/accountKey/weightedPublicKey.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | export class WeightedPublicKey { 17 | constructor(weight: number, publicKey: string) 18 | 19 | weight: number 20 | publicKey: string 21 | private _weight: number 22 | private _publicKey: string 23 | 24 | encodeToBytes(): string[] 25 | } 26 | -------------------------------------------------------------------------------- /types/packages/caver-core-helpers/src/payloadTransformer.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | export interface PayloadTransformer { 17 | reversePayload(payload: any): any 18 | } 19 | -------------------------------------------------------------------------------- /types/packages/caver-core-helpers/src/validateFunction.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import BigNumber from 'bignumber.js' 17 | import { Transaction } from '../../caver-transaction/src' 18 | import { DeprecatedTransactionObject } from '../../caver-klay/caver-klay-accounts/src' 19 | 20 | export interface ValidateFunction { 21 | validateParams(tx: DeprecatedTransactionObject | Transaction): Error 22 | validateTxType(txType: string): boolean 23 | validateCodeFormat(cf: string): boolean 24 | } 25 | -------------------------------------------------------------------------------- /types/packages/caver-core-requestmanager/caver-providers-http/src/index.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | import type { Agent as HTTPAgent } from 'http' 20 | import type { Agent as HTTPSAgent } from 'https' 21 | import { JsonRpcResponse } from '../../../caver-core-helpers/src' 22 | 23 | export interface HttpHeader { 24 | name: string 25 | value: string 26 | } 27 | 28 | export interface HttpProviderAgent { 29 | http?: HTTPAgent 30 | https?: HTTPSAgent 31 | } 32 | 33 | export interface HttpProviderOptions { 34 | withCredentials?: boolean 35 | timeout?: number 36 | headers?: HttpHeader[] 37 | agent?: HttpProviderAgent 38 | keepAlive?: boolean 39 | } 40 | 41 | export class HttpProvider { 42 | constructor(host: string, options?: HttpProviderOptions) 43 | 44 | host: string 45 | connected: boolean 46 | withCredentials?: boolean 47 | timeout: number 48 | headers?: HttpHeader[] 49 | agent?: HttpProviderAgent 50 | 51 | send(payload: object, callback?: (error: Error | null, result: JsonRpcResponse | undefined) => void): void 52 | supportsSubscriptions(): boolean 53 | disconnect(): boolean 54 | } 55 | -------------------------------------------------------------------------------- /types/packages/caver-core-requestmanager/caver-providers-ipc/src/index.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import * as net from 'net' 17 | import { JsonRpcPayload, JsonRpcResponse } from '../../../caver-core-helpers/src/index' 18 | 19 | export class IpcProvider { 20 | constructor(path: string, net: net.Server) 21 | 22 | responseCallbacks: object 23 | notificationCallbacks: Function[] 24 | path: string 25 | connected: boolean 26 | connection: any 27 | 28 | addDefaultEvents(): void 29 | supportsSubscriptions(): boolean 30 | send(payload: JsonRpcPayload, callback: (error: Error | null, result?: JsonRpcResponse) => void): void 31 | on(type: string, callback?: () => void): void 32 | once(type: string, callback?: () => void): void 33 | removeListener(type: string, callback?: () => void): void 34 | removeAllListeners(type: string): void 35 | reset(): void 36 | reconnect(): void 37 | } 38 | -------------------------------------------------------------------------------- /types/packages/caver-core-requestmanager/caver-providers-ws/src/helpers.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | declare let helpers: Function 20 | declare let _btoa: Function 21 | 22 | export { helpers as parseURL, _btoa as btoa } 23 | -------------------------------------------------------------------------------- /types/packages/caver-core-requestmanager/src/jsonrpc.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | import { JsonRpcPayload, JsonRpcResponse } from '../../caver-core-helpers/src' 20 | import { Method } from '../../caver-core-method/src' 21 | 22 | export interface Jsonrpc { 23 | toPayload(method: Method, params: any[]): JsonRpcPayload 24 | isValidResponse(response: JsonRpcResponse): boolean 25 | toBatchPayload(messages: Array<{ method: Method; params: any[] }>): JsonRpcPayload[] 26 | } 27 | -------------------------------------------------------------------------------- /types/packages/caver-ipfs/src/index.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | export class IPFS { 17 | constructor() 18 | constructor(host: string, port: number, ssl: boolean) 19 | 20 | setIPFSNode(host: string, port: number, ssl: boolean): void 21 | add(data: string | Buffer | ArrayBuffer): Promise 22 | get(hash: string): Promise 23 | toHex(hash: string): string 24 | fromHex(contentHash: string): string 25 | } 26 | -------------------------------------------------------------------------------- /types/packages/caver-kct/src/kip13.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { Contract } from '../../caver-contract/src' 17 | import { AbiItem } from '../../caver-utils/src' 18 | 19 | export class KIP13 extends Contract { 20 | static isImplementedKIP13Interface(contractAddress: string): Promise 21 | 22 | constructor(contractAddress: string, abi: AbiItem[]) 23 | 24 | sendQuery(interfaceId: string): Promise 25 | } 26 | -------------------------------------------------------------------------------- /types/packages/caver-klay/caver-klay-accounts/src/account/account.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { DeprecatedAccountKeyMultiSig } from '../accountKey/accountKeyMultiSig' 17 | import { DeprecatedAccountKeyPublic } from '../accountKey/accountKeyPublic' 18 | import { DeprecatedAccountKeyRoleBased, DeprecatedRoleBasedKeyObject } from '../accountKey/accountKeyRoleBased' 19 | 20 | export type DeprecatedAccountKey = DeprecatedAccountKeyPublic | DeprecatedAccountKeyMultiSig | DeprecatedAccountKeyRoleBased 21 | 22 | export class DeprecatedAccount { 23 | static fromObject(obj: { address: string; privateKey: string }): DeprecatedAccount 24 | static isAccountKey(accountKey: any): boolean 25 | 26 | constructor(address: string, accountKey: string | string[] | DeprecatedRoleBasedKeyObject) 27 | 28 | toPublicKey(toPublicKeyFunc: Function): string | string[] | DeprecatedRoleBasedKeyObject 29 | 30 | address: string 31 | accountKey: DeprecatedAccountKey 32 | readonly privateKey: string 33 | readonly keys: string 34 | readonly accountKeyType: string 35 | readonly transactionKey: string 36 | readonly updateKey: string 37 | readonly feePayerKey: string 38 | private _address: string 39 | private _accountKey: DeprecatedAccountKey 40 | } 41 | -------------------------------------------------------------------------------- /types/packages/caver-klay/caver-klay-accounts/src/account/accountKeyForUpdate.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { WeightedMultiSigOptionsObject } from '../../../../caver-account/src/accountKey/weightedMultiSigOptions' 17 | 18 | export interface MultiSigObject { 19 | threshold: number 20 | keys: { weight: number; publicKey: string } 21 | } 22 | 23 | export interface KeyForUpdateBaseObject { 24 | legacyKey?: boolean 25 | failKey?: boolean 26 | publicKey?: string 27 | multisig?: MultiSigObject 28 | } 29 | 30 | export interface KeyForUpdateObject extends KeyForUpdateBaseObject { 31 | legacyKey?: boolean 32 | failKey?: boolean 33 | publicKey?: string 34 | multisig?: MultiSigObject 35 | roleTransactionKey?: KeyForUpdateBaseObject 36 | roleAccountUpdateKey?: KeyForUpdateBaseObject 37 | roleFeePayerKey?: KeyForUpdateBaseObject 38 | } 39 | 40 | export class AccountForUpdate { 41 | constructor(address: string, keyForUpdate: string | string[] | object, options: WeightedMultiSigOptionsObject) 42 | 43 | address: string 44 | keyForUpdate: KeyForUpdateObject 45 | 46 | fillUpdateObject(updateObject: object): void 47 | } 48 | -------------------------------------------------------------------------------- /types/packages/caver-klay/caver-klay-accounts/src/accountKey/accountKeyEnum.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | export const AccountKeyEnum: { [key: string]: string } 17 | -------------------------------------------------------------------------------- /types/packages/caver-klay/caver-klay-accounts/src/accountKey/accountKeyMultiSig.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | export class DeprecatedAccountKeyMultiSig { 17 | constructor(keys: string[] | DeprecatedAccountKeyMultiSig) 18 | 19 | type: string 20 | 21 | toPublicKey(toPublicKeyFunc: Function): string[] 22 | update(keys: DeprecatedAccountKeyMultiSig): void 23 | 24 | keys: string[] 25 | readonly defaultKey: string 26 | readonly transactionKey: string[] 27 | readonly updateKey: string[] 28 | readonly feePayerKey: string[] 29 | private _keys: string[] 30 | } 31 | -------------------------------------------------------------------------------- /types/packages/caver-klay/caver-klay-accounts/src/accountKey/accountKeyPublic.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | export class DeprecatedAccountKeyPublic { 17 | constructor(key: string | DeprecatedAccountKeyPublic) 18 | 19 | type: string 20 | 21 | toPublicKey(toPublicKeyFunc: Function): string 22 | update(keys: DeprecatedAccountKeyPublic): void 23 | 24 | keys: string 25 | readonly defaultKey: string 26 | readonly transactionKey: string 27 | readonly updateKey: string 28 | readonly feePayerKey: string 29 | private _key: string 30 | } 31 | -------------------------------------------------------------------------------- /types/packages/caver-klay/caver-klay-accounts/src/accountKey/accountKeyRoleBased.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | export interface DeprecatedRoleBasedKeyObject { 17 | transactionKey?: string | string[] 18 | updateKey?: string | string[] 19 | feePayerKey?: string | string[] 20 | } 21 | 22 | export class DeprecatedAccountKeyRoleBased { 23 | constructor(keyObj: DeprecatedRoleBasedKeyObject | DeprecatedAccountKeyRoleBased) 24 | 25 | type: string 26 | 27 | toPublicKey(toPublicKeyFunc: Function): DeprecatedRoleBasedKeyObject 28 | update(keys: DeprecatedAccountKeyRoleBased): void 29 | 30 | transactionKey: string[] 31 | updateKey: string[] 32 | feePayerKey: string[] 33 | readonly keys: DeprecatedRoleBasedKeyObject 34 | readonly defaultKey: string 35 | private _transactionKey: string[] 36 | private _updateKey: string[] 37 | private _feePayerKey: string[] 38 | } 39 | -------------------------------------------------------------------------------- /types/packages/caver-klay/caver-klay-personal/src/index.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { DeprecatedNetRPC } from '../../../caver-net/src' 17 | import RpcCallToMethod from '../../../caver-rtm/src' 18 | import { BlockNumber } from '../../../caver-core/src' 19 | 20 | export class Personal { 21 | constructor(...args: any[]) 22 | 23 | net: DeprecatedNetRPC 24 | 25 | getAccounts: RpcCallToMethod['personal_listAccounts'] 26 | newAccount: RpcCallToMethod['personal_newAccount'] 27 | unlockAccount: RpcCallToMethod['personal_unlockAccount'] 28 | lockAccount: RpcCallToMethod['personal_lockAccount'] 29 | importRawKey: RpcCallToMethod['personal_importRawKey'] 30 | sendTransaction: RpcCallToMethod['personal_sendTransaction'] 31 | signTransaction: RpcCallToMethod['personal_signTransaction'] 32 | sign: RpcCallToMethod['personal_sign'] 33 | ecRecover: RpcCallToMethod['personal_ecRecover'] 34 | replaceRawKey: RpcCallToMethod['personal_replaceRawKey'] 35 | sendValueTransfer: RpcCallToMethod['personal_sendValueTransfer'] 36 | sendAccountUpdate: RpcCallToMethod['personal_sendAccountUpdate'] 37 | 38 | defaultAccount: string 39 | defaultBlock: BlockNumber 40 | private _defaultAccount: string 41 | private _defaultBlock: BlockNumber 42 | } 43 | -------------------------------------------------------------------------------- /types/packages/caver-middleware/src/builtins/fileLogger.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | export function fileLogger(options?: object): void 17 | -------------------------------------------------------------------------------- /types/packages/caver-middleware/src/builtins/index.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { fileLogger } from './fileLogger' 17 | import { rpcFilter } from './rpcFilter' 18 | import { timeMeasure } from './timeMeasure' 19 | 20 | export default interface Builtins { 21 | fileLogger: typeof fileLogger 22 | rpcFilter: typeof rpcFilter 23 | timeMeasure: typeof timeMeasure 24 | } 25 | -------------------------------------------------------------------------------- /types/packages/caver-middleware/src/builtins/rpcFilter.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | export function rpcFilter(filterColl: string[], filterOption?: string): (data: any, next: any) => void 17 | -------------------------------------------------------------------------------- /types/packages/caver-middleware/src/builtins/timeMeasure.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | export function timeMeasure(memoize: object): (data: object, next: any, bypass: Function) => void 17 | -------------------------------------------------------------------------------- /types/packages/caver-middleware/src/index.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import Builtins from './builtins' 17 | 18 | export interface JsonRPCPayloadObject { 19 | jsonrpc: string 20 | id: number 21 | method: Function 22 | params: any[] 23 | } 24 | 25 | export class Middleware { 26 | constructor() 27 | 28 | builtin: Builtins 29 | 30 | getMiddlewares(): Function[] 31 | registerMiddleware(middleware: Function): void 32 | applyMiddleware(data: JsonRPCPayloadObject, type: string, sendRequest?: Function): void 33 | } 34 | -------------------------------------------------------------------------------- /types/packages/caver-net/src/index.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | export class DeprecatedNetRPC { 20 | getNetworkType(callback?: (error: Error, returnValue: string) => void): Promise 21 | getId(callback?: (error: Error, id: number) => void): Promise 22 | isListening(callback?: (error: Error, listening: boolean) => void): Promise 23 | getPeerCount(callback?: (error: Error, peerCount: number) => void): Promise 24 | peerCountByType(callback?: (error: Error, peerCount: number) => void): Promise 25 | } 26 | -------------------------------------------------------------------------------- /types/packages/caver-rpc/src/index.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import * as net from 'net' 17 | import { Governance } from './governance' 18 | import { Klay } from './klay' 19 | import { Net } from './net' 20 | import { RequestManager, provider } from '../../caver-core-requestmanager/src' 21 | 22 | export * from './governance' 23 | export * from './klay' 24 | export * from './net' 25 | 26 | export class RPC { 27 | constructor(...args: any[]) 28 | 29 | setRequestManager(manager: RequestManager): boolean 30 | setProvider(p: provider, net?: net.Socket): void 31 | 32 | klay: Klay 33 | net: Net 34 | governance: Governance 35 | } 36 | -------------------------------------------------------------------------------- /types/packages/caver-rpc/src/net.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | 5 | The caver-js library is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | The caver-js library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the caver-js. If not, see . 17 | */ 18 | 19 | export interface PeerCountByType { 20 | en: number 21 | pn: number 22 | total: number 23 | } 24 | 25 | export class Net { 26 | constructor(...args: any[]) 27 | 28 | getNetworkId(callback?: (error: Error, result: string) => void): Promise 29 | getNetworkID(callback?: (error: Error, result: string) => void): Promise 30 | isListening(callback?: (error: Error, result: boolean) => void): Promise 31 | getPeerCount(callback?: (error: Error, result: string) => void): Promise 32 | getPeerCountByType(callback?: (error: Error, result: PeerCountByType) => void): Promise 33 | } 34 | -------------------------------------------------------------------------------- /types/packages/caver-transaction/src/transactionDecoder/transactionDecoder.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { Transaction } from '..' 17 | import { KlaytnCall } from '../../../caver-rpc/src/klay' 18 | 19 | export interface TransactionDecoder { 20 | decode(rlpEncoded: string, klaytnCall?: KlaytnCall): Transaction 21 | } 22 | -------------------------------------------------------------------------------- /types/packages/caver-transaction/src/transactionHasher/transactionHasher.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { Transaction } from '..' 17 | 18 | export interface TransactionHasher { 19 | getHashForSignature(transaction: Transaction): string 20 | getHashForFeePayerSignature(transaction: Transaction): string 21 | } 22 | -------------------------------------------------------------------------------- /types/packages/caver-transaction/src/transactionTypes/abstractFeeDelegatedTransaction.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { Keyring, SignatureData } from '../../../caver-wallet/src' 17 | import { AbstractTransaction, CreateTransactionObject } from './abstractTransaction' 18 | import { KlaytnCall } from '../../../caver-rpc/src/klay' 19 | 20 | export class AbstractFeeDelegatedTransaction extends AbstractTransaction { 21 | constructor(typeString: string, createTxObj: CreateTransactionObject, klaytnCall?: KlaytnCall) 22 | 23 | signAsFeePayer( 24 | key: string | Keyring, 25 | hasher?: (transaction: AbstractFeeDelegatedTransaction) => string 26 | ): Promise 27 | signAsFeePayer( 28 | key: string | Keyring, 29 | index: number, 30 | hasher?: (transaction: AbstractFeeDelegatedTransaction) => string 31 | ): Promise 32 | appendFeePayerSignatures(signatures: string[] | string[][] | SignatureData | SignatureData[]): void 33 | getRLPEncodingForFeePayerSignature(): string 34 | recoverFeePayerPublicKeys(): string[] 35 | 36 | feePayer: string 37 | feePayerSignatures: SignatureData[] 38 | private _feePayer: string 39 | private _feePayerSignatures: SignatureData[] 40 | } 41 | -------------------------------------------------------------------------------- /types/packages/caver-transaction/src/transactionTypes/abstractFeeDelegatedWithRatioTransaction.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { AbstractFeeDelegatedTransaction } from './abstractFeeDelegatedTransaction' 17 | import { CreateTransactionObject } from './abstractTransaction' 18 | import { KlaytnCall } from '../../../caver-rpc/src/klay' 19 | 20 | export class AbstractFeeDelegatedWithRatioTransaction extends AbstractFeeDelegatedTransaction { 21 | constructor(typeString: string, createTxObj: CreateTransactionObject, klaytnCall?: KlaytnCall) 22 | 23 | feeRatio: string 24 | private _feeRatio: string 25 | } 26 | -------------------------------------------------------------------------------- /types/packages/caver-transaction/src/transactionTypes/accountUpdate/accountUpdate.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { Account } from '../../../../caver-account/src' 17 | import { AbstractTransaction, CreateTransactionObject } from '../abstractTransaction' 18 | import { KlaytnCall } from '../../../../caver-rpc/src/klay' 19 | 20 | export class AccountUpdate extends AbstractTransaction { 21 | static create(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall): AccountUpdate 22 | static decode(rlpEncoded: string, klaytnCall?: KlaytnCall): AccountUpdate 23 | 24 | constructor(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall) 25 | 26 | getRLPEncoding(): string 27 | getCommonRLPEncodingForSignature(): string 28 | fillTransaction(): Promise 29 | validateOptionalValues(): void 30 | 31 | account: Account 32 | gasPrice: string 33 | private _account: Account 34 | private _gasPrice: string 35 | } 36 | -------------------------------------------------------------------------------- /types/packages/caver-transaction/src/transactionTypes/accountUpdate/feeDelegatedAccountUpdate.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { Account } from '../../../../caver-account/src' 17 | import { AbstractFeeDelegatedTransaction } from '../abstractFeeDelegatedTransaction' 18 | import { CreateTransactionObject } from '../abstractTransaction' 19 | import { KlaytnCall } from '../../../../caver-rpc/src/klay' 20 | 21 | export class FeeDelegatedAccountUpdate extends AbstractFeeDelegatedTransaction { 22 | static create(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall): FeeDelegatedAccountUpdate 23 | static decode(rlpEncoded: string, klaytnCall?: KlaytnCall): FeeDelegatedAccountUpdate 24 | 25 | constructor(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall) 26 | 27 | getRLPEncoding(): string 28 | getCommonRLPEncodingForSignature(): string 29 | fillTransaction(): Promise 30 | validateOptionalValues(): void 31 | 32 | account: Account 33 | gasPrice: string 34 | private _account: Account 35 | private _gasPrice: string 36 | } 37 | -------------------------------------------------------------------------------- /types/packages/caver-transaction/src/transactionTypes/accountUpdate/feeDelegatedAccountUpdateWithRatio.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { Account } from '../../../../caver-account/src' 17 | import { AbstractFeeDelegatedWithRatioTransaction } from '../abstractFeeDelegatedWithRatioTransaction' 18 | import { CreateTransactionObject } from '../abstractTransaction' 19 | import { KlaytnCall } from '../../../../caver-rpc/src/klay' 20 | 21 | export class FeeDelegatedAccountUpdateWithRatio extends AbstractFeeDelegatedWithRatioTransaction { 22 | static create(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall): FeeDelegatedAccountUpdateWithRatio 23 | static decode(rlpEncoded: string, klaytnCall?: KlaytnCall): FeeDelegatedAccountUpdateWithRatio 24 | 25 | constructor(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall) 26 | 27 | getRLPEncoding(): string 28 | getCommonRLPEncodingForSignature(): string 29 | fillTransaction(): Promise 30 | validateOptionalValues(): void 31 | 32 | account: Account 33 | gasPrice: string 34 | private _account: Account 35 | private _gasPrice: string 36 | } 37 | -------------------------------------------------------------------------------- /types/packages/caver-transaction/src/transactionTypes/cancel/cancel.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { AbstractTransaction, CreateTransactionObject } from '../abstractTransaction' 17 | import { KlaytnCall } from '../../../../caver-rpc/src/klay' 18 | 19 | export class Cancel extends AbstractTransaction { 20 | static create(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall): Cancel 21 | static decode(rlpEncoded: string, klaytnCall?: KlaytnCall): Cancel 22 | 23 | constructor(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall) 24 | 25 | getRLPEncoding(): string 26 | getCommonRLPEncodingForSignature(): string 27 | fillTransaction(): Promise 28 | validateOptionalValues(): void 29 | 30 | gasPrice: string 31 | private _gasPrice: string 32 | } 33 | -------------------------------------------------------------------------------- /types/packages/caver-transaction/src/transactionTypes/cancel/feeDelegatedCancel.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { AbstractFeeDelegatedTransaction } from '../abstractFeeDelegatedTransaction' 17 | import { CreateTransactionObject } from '../abstractTransaction' 18 | import { KlaytnCall } from '../../../../caver-rpc/src/klay' 19 | 20 | export class FeeDelegatedCancel extends AbstractFeeDelegatedTransaction { 21 | static create(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall): FeeDelegatedCancel 22 | static decode(rlpEncoded: string, klaytnCall?: KlaytnCall): FeeDelegatedCancel 23 | 24 | constructor(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall) 25 | 26 | getRLPEncoding(): string 27 | getCommonRLPEncodingForSignature(): string 28 | fillTransaction(): Promise 29 | validateOptionalValues(): void 30 | 31 | gasPrice: string 32 | private _gasPrice: string 33 | } 34 | -------------------------------------------------------------------------------- /types/packages/caver-transaction/src/transactionTypes/cancel/feeDelegatedCancelWithRatio.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { AbstractFeeDelegatedWithRatioTransaction } from '../abstractFeeDelegatedWithRatioTransaction' 17 | import { CreateTransactionObject } from '../abstractTransaction' 18 | import { KlaytnCall } from '../../../../caver-rpc/src/klay' 19 | 20 | export class FeeDelegatedCancelWithRatio extends AbstractFeeDelegatedWithRatioTransaction { 21 | static create(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall): FeeDelegatedCancelWithRatio 22 | static decode(rlpEncoded: string, klaytnCall?: KlaytnCall): FeeDelegatedCancelWithRatio 23 | 24 | constructor(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall) 25 | 26 | getRLPEncoding(): string 27 | getCommonRLPEncodingForSignature(): string 28 | fillTransaction(): Promise 29 | validateOptionalValues(): void 30 | 31 | gasPrice: string 32 | private _gasPrice: string 33 | } 34 | -------------------------------------------------------------------------------- /types/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/chainDataAnchoring.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { AbstractTransaction, CreateTransactionObject } from '../abstractTransaction' 17 | import { KlaytnCall } from '../../../../caver-rpc/src/klay' 18 | 19 | export class ChainDataAnchoring extends AbstractTransaction { 20 | static create(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall): ChainDataAnchoring 21 | static decode(rlpEncoded: string, klaytnCall?: KlaytnCall): ChainDataAnchoring 22 | 23 | constructor(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall) 24 | 25 | getRLPEncoding(): string 26 | getCommonRLPEncodingForSignature(): string 27 | fillTransaction(): Promise 28 | validateOptionalValues(): void 29 | 30 | input: string 31 | gasPrice: string 32 | private _input: string 33 | private _gasPrice: string 34 | } 35 | -------------------------------------------------------------------------------- /types/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/feeDelegatedChainDataAnchoring.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { AbstractFeeDelegatedTransaction } from '../abstractFeeDelegatedTransaction' 17 | import { CreateTransactionObject } from '../abstractTransaction' 18 | import { KlaytnCall } from '../../../../caver-rpc/src/klay' 19 | 20 | export class FeeDelegatedChainDataAnchoring extends AbstractFeeDelegatedTransaction { 21 | static create(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall): FeeDelegatedChainDataAnchoring 22 | static decode(rlpEncoded: string, klaytnCall?: KlaytnCall): FeeDelegatedChainDataAnchoring 23 | 24 | constructor(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall) 25 | 26 | getRLPEncoding(): string 27 | getCommonRLPEncodingForSignature(): string 28 | fillTransaction(): Promise 29 | validateOptionalValues(): void 30 | 31 | input: string 32 | gasPrice: string 33 | private _input: string 34 | private _gasPrice: string 35 | } 36 | -------------------------------------------------------------------------------- /types/packages/caver-transaction/src/transactionTypes/chainDataAnchoring/feeDelegatedChainDataAnchoringWithRatio.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { AbstractFeeDelegatedWithRatioTransaction } from '../abstractFeeDelegatedWithRatioTransaction' 17 | import { CreateTransactionObject } from '../abstractTransaction' 18 | import { KlaytnCall } from '../../../../caver-rpc/src/klay' 19 | 20 | export class FeeDelegatedChainDataAnchoringWithRatio extends AbstractFeeDelegatedWithRatioTransaction { 21 | static create(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall): FeeDelegatedChainDataAnchoringWithRatio 22 | static decode(rlpEncoded: string, klaytnCall?: KlaytnCall): FeeDelegatedChainDataAnchoringWithRatio 23 | 24 | constructor(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall) 25 | 26 | getRLPEncoding(): string 27 | getCommonRLPEncodingForSignature(): string 28 | fillTransaction(): Promise 29 | validateOptionalValues(): void 30 | 31 | input: string 32 | gasPrice: string 33 | private _input: string 34 | private _gasPrice: string 35 | } 36 | -------------------------------------------------------------------------------- /types/packages/caver-transaction/src/transactionTypes/legacyTransaction/legacyTransaction.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { AbstractTransaction, CreateTransactionObject } from '../abstractTransaction' 17 | import { SignatureData } from '../../../../caver-wallet/src/' 18 | import { KlaytnCall } from '../../../../caver-rpc/src/klay' 19 | 20 | export class LegacyTransaction extends AbstractTransaction { 21 | static create(createTxObj: CreateTransactionObject, klaytnCall?: KlaytnCall): LegacyTransaction 22 | static decode(rlpEncoded: string, klaytnCall?: KlaytnCall): LegacyTransaction 23 | 24 | constructor(createTxObj: CreateTransactionObject, klaytnCall?: KlaytnCall) 25 | 26 | appendSignatures(sig: string[] | string[][] | SignatureData | SignatureData[]): void 27 | getRLPEncoding(): string 28 | getRLPEncodingForSignature(): string 29 | getCommonRLPEncodingForSignature(): string 30 | recoverPublicKeys(): string[] 31 | fillTransaction(): Promise 32 | validateOptionalValues(): void 33 | 34 | to: string 35 | value: string 36 | input: string 37 | data: string 38 | gasPrice: string 39 | private _to: string 40 | private _value: string 41 | private _input: string 42 | private _data: string 43 | private _gasPrice: string 44 | } 45 | -------------------------------------------------------------------------------- /types/packages/caver-transaction/src/transactionTypes/smartContractDeploy/smartContractDeploy.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { AbstractTransaction, CreateTransactionObject } from '../abstractTransaction' 17 | import { KlaytnCall } from '../../../../caver-rpc/src/klay' 18 | 19 | export class SmartContractDeploy extends AbstractTransaction { 20 | static create(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall): SmartContractDeploy 21 | static decode(rlpEncoded: string, klaytnCall?: KlaytnCall): SmartContractDeploy 22 | 23 | constructor(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall) 24 | 25 | getRLPEncoding(): string 26 | getCommonRLPEncodingForSignature(): string 27 | fillTransaction(): Promise 28 | validateOptionalValues(): void 29 | 30 | to: string 31 | value: string 32 | input: string 33 | data: string 34 | humanReadable: boolean 35 | codeFormat: string 36 | gasPrice: string 37 | private _to: string 38 | private _value: string 39 | private _input: string 40 | private _data: string 41 | private _humanReadable: boolean 42 | private _codeFormat: string 43 | private _gasPrice: string 44 | } 45 | -------------------------------------------------------------------------------- /types/packages/caver-transaction/src/transactionTypes/smartContractExecution/feeDelegatedSmartContractExecution.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { AbstractFeeDelegatedTransaction } from '../abstractFeeDelegatedTransaction' 17 | import { CreateTransactionObject } from '../abstractTransaction' 18 | import { KlaytnCall } from '../../../../caver-rpc/src/klay' 19 | 20 | export class FeeDelegatedSmartContractExecution extends AbstractFeeDelegatedTransaction { 21 | static create(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall): FeeDelegatedSmartContractExecution 22 | static decode(rlpEncoded: string, klaytnCall?: KlaytnCall): FeeDelegatedSmartContractExecution 23 | 24 | constructor(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall) 25 | 26 | getRLPEncoding(): string 27 | getCommonRLPEncodingForSignature(): string 28 | fillTransaction(): Promise 29 | validateOptionalValues(): void 30 | 31 | to: string 32 | value: string 33 | input: string 34 | data: string 35 | gasPrice: string 36 | private _to: string 37 | private _value: string 38 | private _input: string 39 | private _data: string 40 | private _gasPrice: string 41 | } 42 | -------------------------------------------------------------------------------- /types/packages/caver-transaction/src/transactionTypes/smartContractExecution/feeDelegatedSmartContractExecutionWithRatio.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { AbstractFeeDelegatedWithRatioTransaction } from '../abstractFeeDelegatedWithRatioTransaction' 17 | import { CreateTransactionObject } from '../abstractTransaction' 18 | import { KlaytnCall } from '../../../../caver-rpc/src/klay' 19 | 20 | export class FeeDelegatedSmartContractExecutionWithRatio extends AbstractFeeDelegatedWithRatioTransaction { 21 | static create(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall): FeeDelegatedSmartContractExecutionWithRatio 22 | static decode(rlpEncoded: string, klaytnCall?: KlaytnCall): FeeDelegatedSmartContractExecutionWithRatio 23 | 24 | constructor(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall) 25 | 26 | getRLPEncoding(): string 27 | getCommonRLPEncodingForSignature(): string 28 | fillTransaction(): Promise 29 | validateOptionalValues(): void 30 | 31 | to: string 32 | value: string 33 | input: string 34 | data: string 35 | gasPrice: string 36 | private _to: string 37 | private _value: string 38 | private _input: string 39 | private _data: string 40 | private _gasPrice: string 41 | } 42 | -------------------------------------------------------------------------------- /types/packages/caver-transaction/src/transactionTypes/smartContractExecution/smartContractExecution.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { AbstractTransaction, CreateTransactionObject } from '../abstractTransaction' 17 | import { KlaytnCall } from '../../../../caver-rpc/src/klay' 18 | 19 | export class SmartContractExecution extends AbstractTransaction { 20 | static create(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall): SmartContractExecution 21 | static decode(rlpEncoded: string, klaytnCall?: KlaytnCall): SmartContractExecution 22 | 23 | constructor(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall) 24 | 25 | getRLPEncoding(): string 26 | getCommonRLPEncodingForSignature(): string 27 | fillTransaction(): Promise 28 | validateOptionalValues(): void 29 | 30 | to: string 31 | value: string 32 | input: string 33 | data: string 34 | gasPrice: string 35 | private _to: string 36 | private _value: string 37 | private _input: string 38 | private _data: string 39 | private _gasPrice: string 40 | } 41 | -------------------------------------------------------------------------------- /types/packages/caver-transaction/src/transactionTypes/valueTransfer/feeDelegatedValueTransfer.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { AbstractFeeDelegatedTransaction } from '../abstractFeeDelegatedTransaction' 17 | import { CreateTransactionObject } from '../abstractTransaction' 18 | import { KlaytnCall } from '../../../../caver-rpc/src/klay' 19 | 20 | export class FeeDelegatedValueTransfer extends AbstractFeeDelegatedTransaction { 21 | constructor(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall) 22 | 23 | static create(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall): FeeDelegatedValueTransfer 24 | static decode(rlpEncoded: string, klaytnCall?: KlaytnCall): FeeDelegatedValueTransfer 25 | getRLPEncoding(): string 26 | getCommonRLPEncodingForSignature(): string 27 | fillTransaction(): Promise 28 | validateOptionalValues(): void 29 | 30 | to: string 31 | value: string 32 | gasPrice: string 33 | private _to: string 34 | private _value: string 35 | private _gasPrice: string 36 | } 37 | -------------------------------------------------------------------------------- /types/packages/caver-transaction/src/transactionTypes/valueTransfer/feeDelegatedValueTransferWithRatio.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { AbstractFeeDelegatedWithRatioTransaction } from '../abstractFeeDelegatedWithRatioTransaction' 17 | import { CreateTransactionObject } from '../abstractTransaction' 18 | import { KlaytnCall } from '../../../../caver-rpc/src/klay' 19 | 20 | export class FeeDelegatedValueTransferWithRatio extends AbstractFeeDelegatedWithRatioTransaction { 21 | constructor(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall) 22 | 23 | static create(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall): FeeDelegatedValueTransferWithRatio 24 | static decode(rlpEncoded: string, klaytnCall?: KlaytnCall): FeeDelegatedValueTransferWithRatio 25 | getRLPEncoding(): string 26 | getCommonRLPEncodingForSignature(): string 27 | fillTransaction(): Promise 28 | validateOptionalValues(): void 29 | 30 | to: string 31 | value: string 32 | gasPrice: string 33 | private _to: string 34 | private _value: string 35 | private _gasPrice: string 36 | } 37 | -------------------------------------------------------------------------------- /types/packages/caver-transaction/src/transactionTypes/valueTransfer/valueTransfer.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { AbstractTransaction, CreateTransactionObject } from '../abstractTransaction' 17 | import { KlaytnCall } from '../../../../caver-rpc/src/klay' 18 | 19 | export class ValueTransfer extends AbstractTransaction { 20 | static create(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall): ValueTransfer 21 | static decode(rlpEncoded: string, klaytnCall?: KlaytnCall): ValueTransfer 22 | 23 | constructor(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall) 24 | 25 | getRLPEncoding(): string 26 | getCommonRLPEncodingForSignature(): string 27 | fillTransaction(): Promise 28 | validateOptionalValues(): void 29 | 30 | to: string 31 | value: string 32 | gasPrice: string 33 | private _to: string 34 | private _value: string 35 | private _gasPrice: string 36 | } 37 | -------------------------------------------------------------------------------- /types/packages/caver-transaction/src/transactionTypes/valueTransferMemo/feeDelegatedValueTransferMemo.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { AbstractFeeDelegatedTransaction } from '../abstractFeeDelegatedTransaction' 17 | import { CreateTransactionObject } from '../abstractTransaction' 18 | import { KlaytnCall } from '../../../../caver-rpc/src/klay' 19 | 20 | export class FeeDelegatedValueTransferMemo extends AbstractFeeDelegatedTransaction { 21 | static create(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall): FeeDelegatedValueTransferMemo 22 | static decode(rlpEncoded: string, klaytnCall?: KlaytnCall): FeeDelegatedValueTransferMemo 23 | 24 | constructor(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall) 25 | 26 | getRLPEncoding(): string 27 | getCommonRLPEncodingForSignature(): string 28 | fillTransaction(): Promise 29 | validateOptionalValues(): void 30 | 31 | to: string 32 | value: string 33 | input: string 34 | data: string 35 | gasPrice: string 36 | private _to: string 37 | private _value: string 38 | private _input: string 39 | private _data: string 40 | private _gasPrice: string 41 | } 42 | -------------------------------------------------------------------------------- /types/packages/caver-transaction/src/transactionTypes/valueTransferMemo/feeDelegatedValueTransferMemoWithRatio.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { AbstractFeeDelegatedWithRatioTransaction } from '../abstractFeeDelegatedWithRatioTransaction' 17 | import { CreateTransactionObject } from '../abstractTransaction' 18 | import { KlaytnCall } from '../../../../caver-rpc/src/klay' 19 | 20 | export class FeeDelegatedValueTransferMemoWithRatio extends AbstractFeeDelegatedWithRatioTransaction { 21 | static create(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall): FeeDelegatedValueTransferMemoWithRatio 22 | static decode(rlpEncoded: string, klaytnCall?: KlaytnCall): FeeDelegatedValueTransferMemoWithRatio 23 | 24 | constructor(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall) 25 | 26 | getRLPEncoding(): string 27 | getCommonRLPEncodingForSignature(): string 28 | fillTransaction(): Promise 29 | validateOptionalValues(): void 30 | 31 | to: string 32 | value: string 33 | input: string 34 | data: string 35 | gasPrice: string 36 | private _to: string 37 | private _value: string 38 | private _input: string 39 | private _data: string 40 | private _gasPrice: string 41 | } 42 | -------------------------------------------------------------------------------- /types/packages/caver-transaction/src/transactionTypes/valueTransferMemo/valueTransferMemo.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { AbstractTransaction, CreateTransactionObject } from '../abstractTransaction' 17 | import { KlaytnCall } from '../../../../caver-rpc/src/klay' 18 | 19 | export class ValueTransferMemo extends AbstractTransaction { 20 | static create(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall): ValueTransferMemo 21 | static decode(rlpEncoded: string, klaytnCall?: KlaytnCall): ValueTransferMemo 22 | 23 | constructor(createTxObj: string | CreateTransactionObject, klaytnCall?: KlaytnCall) 24 | 25 | getRLPEncoding(): string 26 | getCommonRLPEncodingForSignature(): string 27 | fillTransaction(): Promise 28 | validateOptionalValues(): void 29 | 30 | to: string 31 | value: string 32 | input: string 33 | data: string 34 | gasPrice: string 35 | private _to: string 36 | private _value: string 37 | private _input: string 38 | private _data: string 39 | private _gasPrice: string 40 | } 41 | -------------------------------------------------------------------------------- /types/packages/caver-transaction/src/utils/accessList.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { AccessTuple, AccessTupleObject, EncodedAccessTuple } from './accessTuple' 17 | 18 | export type AccessListObject = AccessTupleObject[] 19 | 20 | export interface AccessListResult { 21 | accessList: AccessListObject 22 | gasUsed: string 23 | error: string 24 | } 25 | 26 | export class AccessList extends Array { 27 | static create(items: AccessTuple[] | AccessTupleObject[]): AccessList 28 | static decode(encoded: string): AccessList 29 | 30 | encodeToBytes(): EncodedAccessTuple[] 31 | isEqual(acl: AccessList): boolean 32 | toObject(): AccessTupleObject[] 33 | } 34 | -------------------------------------------------------------------------------- /types/packages/caver-transaction/src/utils/accessTuple.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | export interface AccessTupleObject { 17 | address: string 18 | storageKeys: string[] 19 | } 20 | 21 | export type EncodedAccessTuple = Array 22 | 23 | export class AccessTuple { 24 | static create(address: string, storageKeys: string[]): AccessTuple 25 | 26 | constructor(address: string, storageKeys: string[]) 27 | 28 | address: string 29 | storageKeys: string[] 30 | private _address: string 31 | private _storageKeys: string[] 32 | 33 | encodeToByte(): EncodedAccessTuple 34 | isEqual(at: AccessTuple): boolean 35 | toObject(): AccessTupleObject 36 | } 37 | -------------------------------------------------------------------------------- /types/packages/caver-validator/src/index.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { KlaytnCall } from '../../caver-rpc/src/klay' 17 | import { AbstractTransaction, AbstractFeeDelegatedTransaction } from '../../caver-transaction/src' 18 | import { SignatureData } from '../../caver-wallet/src' 19 | 20 | export class Validator { 21 | constructor(klaytnCall: KlaytnCall) 22 | 23 | validateSignedMessage( 24 | message: string, 25 | signatures: string[] | string[][] | SignatureData | SignatureData[], 26 | address: string, 27 | isHashed?: boolean 28 | ): Promise 29 | validateTransaction(tx: AbstractTransaction): Promise 30 | validateSender(tx: AbstractTransaction): Promise 31 | validateFeePayer(tx: AbstractFeeDelegatedTransaction): Promise 32 | 33 | klaytnCall: KlaytnCall 34 | private _klaytnCall: KlaytnCall 35 | } 36 | -------------------------------------------------------------------------------- /types/packages/caver-wallet/src/keyring/keyringHelper.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | export const KEY_ROLE: { 17 | roleTransactionKey: 0 18 | 0: 'roleTransactionKey' 19 | roleAccountUpdateKey: 1 20 | 1: 'roleAccountUpdateKey' 21 | roleFeePayerKey: 2 22 | 2: 'roleFeePayerKey' 23 | roleLast: 3 24 | } 25 | 26 | export const MAXIMUM_KEY_NUM = 10 27 | -------------------------------------------------------------------------------- /types/packages/caver-wallet/src/keyring/multipleKeyring.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { SignedMessage } from '..' 17 | import { Account, WeightedMultiSigOptions, WeightedMultiSigOptionsObject } from '../../../caver-account/src' 18 | import { EncryptedKeystoreV4Json, EncryptionOptions } from '../../../caver-core/src' 19 | import { PrivateKey } from './privateKey' 20 | import { SignatureData } from './signatureData' 21 | 22 | export class MultipleKeyring { 23 | constructor(address: string, keys: string[] | PrivateKey[]) 24 | 25 | getPublicKey(compressed?: boolean): string[] 26 | copy(): MultipleKeyring 27 | sign(txSigHash: string, chainId: string | number, role: number, index?: number): SignatureData | SignatureData[] 28 | ecsign(hash: string, role: number, index?: number): SignatureData | SignatureData[] 29 | signMessage(message: string, role: number, index?: number): SignedMessage 30 | getKeyByRole(role: number): PrivateKey[] 31 | toAccount(options?: WeightedMultiSigOptions | WeightedMultiSigOptionsObject): Account 32 | encrypt(password: string, options?: EncryptionOptions): EncryptedKeystoreV4Json 33 | isDecoupled(): boolean 34 | 35 | type: string 36 | address: string 37 | keys: PrivateKey[] 38 | private _address: string 39 | private _keys: PrivateKey[] 40 | } 41 | -------------------------------------------------------------------------------- /types/packages/caver-wallet/src/keyring/privateKey.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import { SignatureData } from './signatureData' 17 | 18 | export class PrivateKey { 19 | constructor(key: string) 20 | 21 | sign(txSigHash: string, chainId?: string | number): SignatureData 22 | ecsign(hash: string): SignatureData 23 | signMessage(messageHash: string): SignatureData 24 | getPublicKey(compressed?: boolean): string 25 | getDerivedAddress(): string 26 | 27 | privateKey: string 28 | private _privateKey: string 29 | } 30 | -------------------------------------------------------------------------------- /types/packages/caver-wallet/src/keyring/signatureData.d.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | export class SignatureData { 17 | constructor(signature: string[] | SignatureData) 18 | 19 | emptySig: SignatureData 20 | 21 | isEmpty(): boolean 22 | encode(): string[] 23 | toString(): string 24 | isEqual(sig: SignatureData | SignatureData[]): boolean 25 | 26 | v: string 27 | V: string 28 | r: string 29 | R: string 30 | s: string 31 | S: string 32 | private _v: string 33 | private _V: string 34 | private _r: string 35 | private _R: string 36 | private _s: string 37 | private _S: string 38 | } 39 | -------------------------------------------------------------------------------- /types/test/ipfs-test.ts: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The caver-js Authors 3 | This file is part of the caver-js library. 4 | The caver-js library is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU Lesser General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | The caver-js library is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Lesser General Public License for more details. 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with the caver-js. If not, see . 14 | */ 15 | 16 | import Caver, { IPFS } from 'caver-js' 17 | 18 | const caver = new Caver() 19 | 20 | // $ExpectType IPFS 21 | caver.ipfs 22 | 23 | // $ExpectType typeof IPFS 24 | IPFS 25 | 26 | // $ExpectType IPFS 27 | let ipfs = new IPFS() 28 | // $ExpectType IPFS 29 | ipfs = new IPFS('ipfs.infura.io', 5001, true) 30 | 31 | // $ExpectType void 32 | ipfs.setIPFSNode('ipfs.infura.io', 5001, true) 33 | 34 | const testFileName = './ipfsTestFile.txt' 35 | 36 | // $ExpectType Promise 37 | ipfs.add(testFileName) 38 | // $ExpectType Promise 39 | ipfs.add(Buffer.from([])) 40 | // $ExpectType Promise 41 | ipfs.add(new ArrayBuffer(1)) 42 | 43 | // $ExpectType Promise 44 | ipfs.get('hash') 45 | 46 | // $ExpectType string 47 | ipfs.toHex('hash') 48 | 49 | // $ExpectType string 50 | ipfs.fromHex('hash') 51 | -------------------------------------------------------------------------------- /types/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "lib": ["es6"], 5 | "noImplicitAny": true, 6 | "noImplicitThis": true, 7 | "strictNullChecks": true, 8 | "strictFunctionTypes": true, 9 | "allowSyntheticDefaultImports": false, 10 | "baseUrl": ".", 11 | "paths": { 12 | "caver-js": ["."] 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /types/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "dtslint/dtslint.json", 3 | "rules": { 4 | "semicolon": false, 5 | "no-redundant-jsdoc": false, 6 | "unified-signatures": false, 7 | "interface-name": false, 8 | "ban-types": [false, [], ["Function"]], 9 | "adjacent-overload-signatures": false, 10 | "max-line-length": false 11 | } 12 | } -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | entry: './webpack.js', 3 | output: { 4 | filename: 'caver.min.js', 5 | path: `${__dirname}/dist`, 6 | }, 7 | resolve: { 8 | fallback: { 9 | fs: false, 10 | net: false, 11 | stream: require.resolve('stream-browserify'), 12 | crypto: require.resolve('crypto-browserify'), 13 | http: require.resolve('stream-http'), 14 | https: require.resolve('https-browserify'), 15 | os: require.resolve('os-browserify/browser'), 16 | constants: require.resolve('constants-browserify'), 17 | }, 18 | }, 19 | } 20 | -------------------------------------------------------------------------------- /webpack.js: -------------------------------------------------------------------------------- 1 | /* global window */ 2 | /* eslint no-undef: "error" */ 3 | 4 | window.Caver = require('./index') 5 | --------------------------------------------------------------------------------