Compare commits

...

84 Commits

Author SHA1 Message Date
nico 18da2be63d woop 8 months ago
Ganesha Upadhyaya d580e4a659
Delete .env 2 years ago
Ganesha Upadhyaya 5eddd0feb2 v0.1.58 2 years ago
Artem 71304c22ad
Replace scrypt-shim with scrypt.js; add test (#128) 2 years ago
Ganesha Upadhyaya 3c7061887f
Merge pull request #79 from harmony-one/dependabot/npm_and_yarn/y18n-3.2.2 4 years ago
Ganesha Upadhyaya e3d04c6383
Merge pull request #81 from vinyl704/patch-1 4 years ago
Ganesha Upadhyaya 0c7337918d
Merge pull request #82 from isaacadams/feature/add-get-blocks-rpc 4 years ago
Ganesha Upadhyaya e364c4ffea
Merge pull request #84 from polymorpher/fix-hd-node 4 years ago
Aaron Li baaa09e41f better hdnode constructor 4 years ago
Aaron Li f29f2586dd optionally generateMnemonic during HDNode creation; Fix a bug with setSigner 4 years ago
Isaac Adams 87d5f999ab from and to should be validated as block numbers 4 years ago
Isaac Adams 42d6400ee1 blockargs can be optional 4 years ago
Isaac Adams 75a7118e1b adding get blocks method based on API docs 4 years ago
vinyl704 9d13ab257c
fixed typo on line 121 4 years ago
dependabot[bot] 21be4e3fe3
Bump y18n from 3.2.1 to 3.2.2 4 years ago
Ganesha Upadhyaya 99a827782f v0.1.57 4 years ago
Ganesha Upadhyaya 2acbadf97a
Merge pull request #70 from SebastianJ/fix-nonce-hex-bug 4 years ago
Sebastian Johnsson 99bd7ad3d5 Fix OneWallet compatibility for nonces returned as numbers instead of hex 4 years ago
Ganesha Upadhyaya a60117ceac
Merge pull request #68 from harmony-one/dependabot/npm_and_yarn/ini-1.3.8 4 years ago
Ganesha Upadhyaya 4099a321f3
Update README.md 4 years ago
dependabot[bot] 6ab7227ef3
Bump ini from 1.3.5 to 1.3.8 4 years ago
Ganesha Upadhyaya 8f8e17fdae v0.1.56 4 years ago
Ganesha Upadhyaya 2762c8edbf audit fixes 4 years ago
Ganesha Upadhyaya 2a3ad781b6 add missing link 4 years ago
Ganesha Upadhyaya aea4ca0cc7 minor updates 4 years ago
Ganesha Upadhyaya 13c0830916 adding more examples and links 4 years ago
Ganesha Upadhyaya a7979a569f adding more examples 4 years ago
Ganesha Upadhyaya 1b6e351aa8 add token faucet app demo 4 years ago
PeekPI 6e2c1e7653
fixes issue: https://github.com/harmony-one/harmony/issues/3450 (#66) 4 years ago
peekpi d5feeb8d78 fixed testcase error 4 years ago
peekpi 4261bc15bb Merge remote-tracking branch 'origin/master' 4 years ago
peekpi 9aefc978f6 fixes issue: https://github.com/harmony-one/harmony/issues/3450 4 years ago
peekpi 95453ee2e7 handle integer result returned by 'hmy_getAccountNonce' 4 years ago
Ganesha Upadhyaya caa57d360d update latest docs url 4 years ago
Ganesha Upadhyaya bc2d3a6e8d remove .env and .env.sample 4 years ago
Ganesha Upadhyaya 73b97c7d07 removing examples, all of them are available inside package-level documentation 4 years ago
Ganesha Upadhyaya cc4872a9f9 update sdk api reference 4 years ago
Ganesha Upadhyaya c6fbf597a5
Merge pull request #61 from harmony-one/dependabot/npm_and_yarn/packages/harmony-contract/node-fetch-2.6.1 4 years ago
Ganesha Upadhyaya 995f6b8f40
Merge pull request #62 from harmony-one/dependabot/npm_and_yarn/packages/harmony-account/node-fetch-2.6.1 4 years ago
Ganesha Upadhyaya 6bcac8640e
Merge pull request #63 from harmony-one/dependabot/npm_and_yarn/packages/harmony-core/node-fetch-2.6.1 4 years ago
PeekPI cdf471b830
accept hex string as input of type 'uin256' (#64) 4 years ago
lixp f0e8056f84 accept hex string as input of type 'uin256' 4 years ago
lixp 1b977860ad Merge remote-tracking branch 'origin/master' 4 years ago
PeekPI 93393dc36c
use 'hmy_getAccountNonce' to update Nonce (#60) 4 years ago
Ganesha Upadhyaya aaf148c1af
Merge pull request #49 from harmony-one/dependabot/npm_and_yarn/packages/harmony-crypto/elliptic-6.5.3 4 years ago
dependabot[bot] f125047487
Bump node-fetch from 2.6.0 to 2.6.1 in /packages/harmony-contract 4 years ago
dependabot[bot] e4f72e293e
Bump node-fetch from 2.6.0 to 2.6.1 in /packages/harmony-account 4 years ago
dependabot[bot] 1c47f9c713
Bump node-fetch from 2.6.0 to 2.6.1 in /packages/harmony-core 4 years ago
Ganesha Upadhyaya 85e0e76dc0
Merge pull request #50 from harmony-one/dependabot/npm_and_yarn/elliptic-6.5.3 4 years ago
Ganesha Upadhyaya 7a8c0f9699
Merge pull request #53 from harmony-one/dependabot/npm_and_yarn/examples/elliptic-6.5.3 4 years ago
Ganesha Upadhyaya cda12363c9
Merge pull request #54 from harmony-one/dependabot/npm_and_yarn/packages/harmony-transaction/node-fetch-2.6.1 4 years ago
Ganesha Upadhyaya fb2fe2925b
Merge pull request #55 from harmony-one/dependabot/npm_and_yarn/packages/harmony-staking/node-fetch-2.6.1 4 years ago
lixp a7e248a433 Merge remote-tracking branch 'origin/master' 4 years ago
PeekPI 08d8f5aaf4
fixes #30 (#59) 4 years ago
lixp fd2481aa35 1. fixes #30 4 years ago
lixp cf6fd13b86 Merge remote-tracking branch 'origin/master' 4 years ago
PeekPI 794a590238
support 'fallback' and 'receive' of solidity (#51) 4 years ago
PeekPI cc4df6b24e
Merge branch 'master' into master 4 years ago
dependabot[bot] 43eb47107a
Bump elliptic from 6.5.2 to 6.5.3 4 years ago
dependabot[bot] 2a118ebb7f
Bump node-fetch from 2.6.0 to 2.6.1 in /packages/harmony-staking 4 years ago
dependabot[bot] c8e1e7503c
Bump elliptic from 6.5.2 to 6.5.3 in /packages/harmony-crypto 4 years ago
dependabot[bot] a81045946a
Bump node-fetch from 2.6.0 to 2.6.1 in /packages/harmony-transaction 4 years ago
dependabot[bot] 26e38e9e35
Bump elliptic from 6.5.2 to 6.5.3 in /examples 4 years ago
Ganesha Upadhyaya c49abc5691 v0.1.55 4 years ago
Ganesha Upadhyaya ca83e5477c
Merge pull request #52 from SebastianJ/expose-raw-abi 4 years ago
Sebastian Johnsson 14fb03f3f2 Expose the raw abi 4 years ago
lixp 40e0db00c5 Merge remote-tracking branch 'origin/master' 4 years ago
lixp 4e111973b9 support 'fallback' and 'receive' of solidity 4 years ago
Dennis Won 463cfdfb68 udpate package lock json files by running npm install 4 years ago
Dennis Won 4033b3f971 v0.1.54 4 years ago
Dennis Won 018c2626fe package-lock.json should not be ignored by gitignore 4 years ago
Dennis Won b63aae6bfb revert manual package.json versions bump 4 years ago
Ganesha Upadhyaya aa1b811830 Merge pull request #45 from peekpi/master 4 years ago
Jong Hyuck Won 2a1bcbbbbb
Merge pull request #48 from harmony-one/enum 4 years ago
Dennis Won e571c4bedc change const enums exports to enum 4 years ago
Jong Hyuck Won d34f347e9e
Merge pull request #47 from harmony-one/e2e 4 years ago
Dennis Won b6a9e4cc85 fix broken e2e test 4 years ago
lixp 6a0163eef4 Merge branch 'master' into methodcall 4 years ago
Ganesha Upadhyaya 7dd958349b
Merge pull request #42 from HiroKryptor/master 4 years ago
lixp 9aa0985993 if outputs of a contract method is empty, don't treat the etmpty return data as revert 4 years ago
lixp 7d5e968ce1 handle the revert message 4 years ago
Hiro 084bcbb5db
Add check id is hash in case RPCMethod return error 4 years ago
Hirokryptor 3bfe0deb4e Fix Uncaught (in promise) User rejected sign transaction request 4 years ago
lixp 0bf2f24333 1. accept ONE format address as contract method parameter 4 years ago
  1. 5
      .env
  2. 5
      .env.example
  3. 9
      .gitignore
  4. 2
      .travis.yml
  5. 42
      README.md
  6. 4
      RELEASE.md
  7. 12
      TYPEDOC.md
  8. 24
      e2e/fixtures/transactions.json
  9. 161
      e2e/src/blockchain.e2e.ts
  10. 29
      e2e/src/harmony.ts
  11. 147
      e2e/src/transaction.e2e.ts
  12. 282
      e2e/src/txn_rpc.e2e.ts
  13. 39
      e2e/src/woop.ts
  14. 16
      e2e/tsconfig.json
  15. 134
      examples/README.md
  16. 31
      examples/balance.js
  17. 45
      examples/import_keystore.js
  18. 14
      examples/package.json
  19. 79
      examples/staking_create.js
  20. 172
      examples/staking_delegate.js
  21. 74
      examples/staking_test.js
  22. 177
      examples/staking_transfer.js
  23. 173
      examples/staking_undelegate.js
  24. 31
      examples/test.js
  25. 40
      examples/test2.js
  26. 153
      examples/transfer.js
  27. 151
      examples/transfer_dev.js
  28. 137
      examples/transfer_local.js
  29. 16
      gulpfile.js
  30. 2
      lerna.json
  31. 1081
      log.txt
  32. 44661
      package-lock.json
  33. 20
      package.json
  34. 18
      packages/README.md
  35. 274
      packages/harmony-account/guide.ts
  36. 14
      packages/harmony-account/src/utils.ts
  37. 30
      packages/harmony-core/package.json
  38. 31
      packages/harmony-core/src/types.ts
  39. 16
      packages/harmony-core/tsconfig.json
  40. 126
      packages/harmony-network/src/rpcMethod/rpc.ts
  41. 135
      packages/harmony-transaction/src/types.ts
  42. 203
      packages/harmony-utils/src/chain.ts
  43. 0
      packages/woop-account/LICENSE
  44. 36
      packages/woop-account/README.md
  45. 218
      packages/woop-account/guide.ts
  46. 29
      packages/woop-account/package.json
  47. 111
      packages/woop-account/src/account.ts
  48. 31
      packages/woop-account/src/hdnode.ts
  49. 2
      packages/woop-account/src/index.ts
  50. 2
      packages/woop-account/src/types.ts
  51. 14
      packages/woop-account/src/utils.ts
  52. 30
      packages/woop-account/src/wallet.ts
  53. 19
      packages/woop-account/test/testAccount.test.ts
  54. 10
      packages/woop-account/tsconfig.json
  55. 0
      packages/woop-account/tsconfig.test.json
  56. 8
      packages/woop-contract/Counter.json
  57. 0
      packages/woop-contract/LICENSE
  58. 56
      packages/woop-contract/README.md
  59. 16
      packages/woop-contract/package.json
  60. 266
      packages/woop-contract/src/abi/abiCoder.ts
  61. 6
      packages/woop-contract/src/abi/api.ts
  62. 2
      packages/woop-contract/src/abi/index.ts
  63. 6
      packages/woop-contract/src/abi/utils.ts
  64. 17
      packages/woop-contract/src/contract.ts
  65. 4
      packages/woop-contract/src/contractFactory.ts
  66. 4
      packages/woop-contract/src/events/event.ts
  67. 4
      packages/woop-contract/src/events/eventFactory.ts
  68. 2
      packages/woop-contract/src/index.ts
  69. 164
      packages/woop-contract/src/methods/method.ts
  70. 10
      packages/woop-contract/src/methods/methodFactory.ts
  71. 4
      packages/woop-contract/src/models/AbiItemModel.ts
  72. 24
      packages/woop-contract/src/models/AbiModel.ts
  73. 2
      packages/woop-contract/src/models/types.ts
  74. 2
      packages/woop-contract/src/utils/decoder.ts
  75. 13
      packages/woop-contract/src/utils/encoder.ts
  76. 6
      packages/woop-contract/src/utils/formatter.ts
  77. 11
      packages/woop-contract/src/utils/mapper.ts
  78. 2
      packages/woop-contract/src/utils/options.ts
  79. 2
      packages/woop-contract/src/utils/status.ts
  80. 4
      packages/woop-contract/test/abiCoder.test.ts
  81. 0
      packages/woop-contract/test/fixtures/abiv2.ts
  82. 10
      packages/woop-contract/tsconfig.json
  83. 0
      packages/woop-contract/tsconfig.test.json
  84. 0
      packages/woop-core/LICENSE
  85. 48
      packages/woop-core/README.md
  86. 19
      packages/woop-core/package.json
  87. 430
      packages/woop-core/src/blockchain.ts
  88. 6
      packages/woop-core/src/index.ts
  89. 38
      packages/woop-core/src/truffleProvider.ts
  90. 31
      packages/woop-core/src/types.ts
  91. 38
      packages/woop-core/src/util.ts
  92. 68
      packages/woop-core/src/woop.ts
  93. 36
      packages/woop-core/src/woopExtension.ts
  94. 6
      packages/woop-core/test/blockchain.test.ts
  95. 16
      packages/woop-core/tsconfig.json
  96. 0
      packages/woop-core/tsconfig.test.json
  97. 0
      packages/woop-crypto/LICENSE
  98. 16
      packages/woop-crypto/README.md
  99. 782
      packages/woop-crypto/package-lock.json
  100. 10
      packages/woop-crypto/package.json
  101. Some files were not shown because too many files have changed in this diff Show More

@ -1,5 +0,0 @@
GENESIS_PRIV_KEY=45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e
HTTP_PROVIDER=http://localhost:9500
CHAIN_TYPE=hmy
CHAIN_ID=2

@ -1,5 +0,0 @@
GENESIS_PRIV_KEY=45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e
HTTP_PROVIDER=http://localhost:9500
CHAIN_TYPE=hmy
CHAIN_ID=2

9
.gitignore vendored

@ -5,12 +5,7 @@
*.tsbuildinfo
.vscode/
# package.json
package-lock.json
packages/*/package-lock.json
/packages/*/package-lock.json
# babel
packages/*/babel.rc
# lerna
@ -82,4 +77,4 @@ buck-out/
*.jsbundle
# Jest coverage
coverage/
coverage/

@ -2,7 +2,7 @@ language: node_js
sudo: true
dist: trusty
node_js:
- 10
- 16
branches:
except:
- /^v[0-9]/

@ -1,20 +1,23 @@
# Harmony JavaScript API
# Woop JavaScript SDK
[![npm version](https://img.shields.io/npm/v/@harmony-js/core.svg?style=flat-square)](https://www.npmjs.com/package/@harmony-js/core)
[![Build Status](https://travis-ci.com/FireStack-Lab/Harmony-sdk-core.svg?branch=master)](https://travis-ci.com/FireStack-Lab/Harmony-sdk-core)
[![npm version](https://img.shields.io/npm/v/@woop-js/core.svg?style=flat-square)](https://www.npmjs.com/package/@woop-js/core)
[![Build Status](https://travis-ci.com/FireStack-Lab/Woop-sdk-core.svg?branch=master)](https://travis-ci.com/FireStack-Lab/Woop-sdk-core)
This is the Harmony javascript library which provides an easier way to interact with Harmony's blockchain.
This is the Woop Javascript SDK which provides an easier way to interact with Woop blockchain.
This libraries contains a few packages.
Please read the [documentation](https://jssdk.doc.hmny.io/) for full API doc.
The SDK includes following packages with package-level documentation and examples inside each package.
1. [@woop-js/core](https://github.com/woop-chain/sdk/tree/master/packages/woop-core)
2. [@woop-js/account](https://github.com/woop-chain/sdk/tree/master/packages/woop-account)
3. [@woop-js/crypto](https://github.com/woop-chain/sdk/tree/master/packages/woop-crypto)
4. [@woop-js/network](https://github.com/woop-chain/sdk/tree/master/packages/woop-network)
5. [@woop-js/utils](https://github.com/woop-chain/sdk/tree/master/packages/woop-utils)
6. [@woop-js/transaction](https://github.com/woop-chain/sdk/tree/master/packages/woop-transaction)
7. [@woop-js/contract](https://github.com/woop-chain/sdk/tree/master/packages/woop-contract)
8. [@woop-js/staking](https://github.com/woop-chain/sdk/tree/master/packages/woop-staking)
1. [@harmony-js/core](https://github.com/harmony-one/sdk/tree/master/packages/harmony-core)
2. [@harmony-js/account](https://github.com/harmony-one/sdk/tree/master/packages/harmony-account)
3. [@harmony-js/crypto](https://github.com/harmony-one/sdk/tree/master/packages/harmony-crypto)
4. [@harmony-js/network](https://github.com/harmony-one/sdk/tree/master/packages/harmony-network)
5. [@harmony-js/utils](https://github.com/harmony-one/sdk/tree/master/packages/harmony-utils)
6. [@harmony-js/transaction](https://github.com/harmony-one/sdk/tree/master/packages/harmony-transaction)
7. [@harmony-js/contract](https://github.com/harmony-one/sdk/tree/master/packages/harmony-contract)
8. [@harmony-js/staking](https://github.com/harmony-one/sdk/tree/master/packages/harmony-contract)
# Installation
@ -32,10 +35,10 @@ This library works on both nodejs and browser. Please use it according to your u
```bash
# npm
npm install @harmony-js/core@next
npm install @woop-js/core@next
# yarn
yarn add @harmony-js/core@next
yarn add @woop-js/core@next
# tslib is required, we'd better install it as well
npm install tslib
@ -73,12 +76,9 @@ yarn test:src
```
## e2e tests
1. `.env` file defines configuration, edit if you have custom settings
2. Run harmony node locally, follow the instructions: https://github.com/harmony-one/harmony
3. Wait for 1-2 mins, and run this:
1. Remove the `'cross-fetch': 'jest-fetch-mock'` line from `scripts/jest/jest.e2e.config.js`
1. Run woop node locally, follow the instructions: https://github.com/woop-chain/woop
1. Wait for 1-2 mins, and run this:
```bash
yarn build && yarn test:e2e
```

@ -37,7 +37,7 @@ This will not change the release version of current npm packages(currently 0.0.7
For example.
```bash
npm install @harmony-js/core@next
npm install @woop-js/core@next
```
@ -60,7 +60,7 @@ This will change the release version of current npm packages to the latest versi
For example.
```bash
npm install @harmony-js/core
npm install @woop-js/core
```

@ -1,6 +1,6 @@
# Harmony JS-SDK Documentation
# Woop JS-SDK Documentation
## [CLICK ME!!](https://harmony-js-sdk-doc.s3-us-west-1.amazonaws.com/index.html) to see the documentation
## [CLICK ME!!](https://woop-js-sdk-doc.s3-us-west-1.amazonaws.com/index.html) to see the documentation
# metaDocumentation
## Summary
@ -38,14 +38,14 @@ $ npm install
### Generate HTML
```
$ cd docs
$ npx typedoc --out ./build ../packages/ --ignoreCompilerErrors --theme default --name Harmony_SDK_Doc --readme ../README.md
$ npx typedoc --out ./build ../packages/ --ignoreCompilerErrors --theme default --name Woop_SDK_Doc --readme ../README.md
```
### See the generated doc at local
>open the `index.html` under the path `sdk/docs/build/index.html`
## Step 2: Deploy on AWS (harmony core only!)
## Step 2: Deploy on AWS (woop core only!)
### Create an AWS s3 bucket
Actually, there are just two points needed!
@ -70,7 +70,7 @@ After that, use AWS CLI to do following
1. Create a Bucket
```
aws s3 mb s3://harmony-js-sdk-doc
aws s3 mb s3://woop-js-sdk-doc
```
2. List all buckets you have created
@ -87,7 +87,7 @@ Here is some explanations
> **./account**
> the path of folder which we want to upload
>
> **s3://harmony-js-sdk-doc**
> **s3://woop-js-sdk-doc**
> the bucket name on AWS S3
>
> **--grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers**

@ -110,5 +110,29 @@
"gasPrice": "0x174876e800",
"rawTransaction": "0xf8690985174876e8008252088080949d72989b68777a1f3ffd6f1db079f1928373ee52830f42408028a022efd1decb6e80e88fd33f5e189f48105acc72f7e302931221183f86ca8a7015a02001dee44471a5397a4579f733b3a13a86ba1d6c78ad3312187513d6a424f72b"
}
],
"hashes": [
"0x5aE91eCA3BF7CB97FCd1305bD6e030e24bda9bbfED3b8c741Efe808e8D4F95Ff",
"0xf4CA9DdED0bC36B5AFBCf4fC6De082DFd0F7FCFad1c2aFC1aF52d16d9Dbd733f",
"0x56C2408c5F58ac9aDFE824B7755f3b54CB0848c7A837Ea1CC5a0FdB521D4A1a2",
"0xACFD09AD729E0C9f23EC9eEf27CC68bA37D7EE9D53aABace2dDD42616Eb8351A",
"0xB8baee4EfB120254Afab3092c8Ccc458fF49eBda12ead9950CD39ac8Bb26D4C1",
"0x412D8DBF0BC3dCAf91A0339EEadd1EEB44b44cD0cEBFaea0d35656d31F96Dde9",
"0xbbeDcd6e4dCDef0c666C0C0c7914ba1E5617F8d57ddc40C32cCb31D4BC5CAfBF",
"0x6E008bEbC8F2CE750d208dbF987edEf7476DcFDF8Eb8607f3B3c2E1ce8675ba9",
"0x0Ff0AcBD45cdDf3A8A148eb2F4Fe6dBf74B422eabdD0766ba9284f0Fe8F6dc8a",
"0x7FDCEE6B5EEf5C3F82B2Ffe8a088E0d3d485bEbBcdBCac16ECCb9d1cbfe50c91"
],
"blockHashes": [
"0x9dD4e063d8cc7A6Fe74a0E3AC4feD5F84eB8Bdc4647Ba8DAd651FD1b4a3979cE",
"0xEF5F7D7ca60bE76c1Cc5aADD8DC9e1bC0F7a3BCD0EEDA6e9Cca0EACAd99BE3Bb",
"0x4261B409CCcDA3ab97aABCFe8dECCfd65D1aB9Bb536dD57Fdafd191FC6BbFbbc",
"0x1fb05a17794cAd1ac025469eA1Bf5af4F33f9bdbD3c0e14bCeca323BC5DF0EC3",
"0xEA405dB5dc0E7e2DB2CfdBf272DCeAf69E9CDa2DFD47229b38A3C5b7b9cc41fB",
"0xCC1ADfef1bb2E496A3BbDb181ec5c8EA047AE340FaD6fF4FeF3CCE452c1975B6",
"0x80dffAe15B6619Cc7aD74Bc132C1b29EFc38B8d8CAD1AfbDb9E37f7357E2EBe4",
"0x6BcB9858d8cCE9de2a6ECd6392A5eC712be9b4A79F6Cf84De8aa5ae9C04f60A8",
"0xB6De43A866dFcE1f7AA7DA0E8e9eb7Fe545cB6becF7cf5fdC564B22C4cBb72b9",
"0xc4b4CeAEAEadADfa8CbCcDeFdcBaBeF999dBF42D14C9AFEDd1de2956B571CebD"
]
}

@ -1,88 +1,169 @@
import {harmony} from './harmony';
import fetch from 'jest-fetch-mock';
import { woop, checkCalledMethod } from './woop';
import demoAccounts from '../fixtures/testAccount.json';
import { RPCMethod } from '@woop-js/network';
const bc = harmony.blockchain;
const bc = woop.blockchain;
const testAccount = demoAccounts.Accounts[1];
describe('e2e test blockchain', () => {
beforeEach(() => {
fetch.resetMocks();
});
// net_*
it('should test net_peerCount', async () => {
fetch.mockResponseOnce(
JSON.stringify({"jsonrpc": "2.0", "id": 1, "result": "0x0"}),
);
const peerCount = await bc.net_peerCount();
expect(harmony.utils.isHex(peerCount.result)).toEqual(true);
expect(checkCalledMethod(0, RPCMethod.PeerCount)).toEqual(true);
expect(woop.utils.isHex(peerCount.result)).toEqual(true);
});
it('should test net_version', async () => {
fetch.mockResponseOnce(
JSON.stringify({"jsonrpc": "2.0", "id": 1, "result": "5"}),
);
const netVersion = await bc.net_version();
const versionNumber = parseInt(netVersion.result as string, 10);
expect(netVersion.result).toEqual(`${versionNumber}`);
expect(checkCalledMethod(0, RPCMethod.NetVersion)).toEqual(true);
});
it('should test hmy_protocolVersion', async () => {
it('should test wiki_protocolVersion', async () => {
fetch.mockResponseOnce(
JSON.stringify({"jsonrpc": "2.0", "id": 1, "result": "0x10"}),
);
const protocolVersion = await bc.getProtocolVersion();
expect(harmony.utils.isHex(protocolVersion.result)).toEqual(true);
expect(woop.utils.isHex(protocolVersion.result)).toEqual(true);
expect(checkCalledMethod(0, RPCMethod.ProtocolVersion)).toEqual(true);
});
// block chain info
it('should test hmy_blockNumber', async () => {
it('should test wiki_blockNumber', async () => {
fetch.mockResponseOnce(
JSON.stringify({"jsonrpc": "2.0", "id": 1, "result": "0x10"}),
);
const res = await bc.getBlockNumber();
expect(res.responseType).toEqual('raw');
expect(harmony.utils.isHex(res.result)).toEqual(true);
expect(woop.utils.isHex(res.result)).toEqual(true);
expect(checkCalledMethod(0, RPCMethod.BlockNumber)).toEqual(true);
});
it('should test hmy_getBlockByNumber', async () => {
const res = await bc.getBlockByNumber({blockNumber: 'latest'});
it('should test wiki_getBlockByNumber', async () => {
fetch.mockResponse(
JSON.stringify({
"jsonrpc": "2.0",
"id": 1,
"result": {
"size": "0x1",
"difficulty": 5,
"extraData": "0x",
"gasLimit": "0x80",
"gasUsed": "0x40",
"hash": "0x8a3390ab500Fbca6514eB326d2fcD9B3BFCFbA7DA392593cB4885b8e3399a2D8",
"logsBloom": "0x0",
"miner": "one155jp2y76nazx8uw5sa94fr0m4s5aj8e5xm6fu3",
"mixHash": "0x3A7c1Ae14AfecFf55Da298F66b75F4FfB771c3EaBDeAa267FF33A77d4d0be220",
"nonce": 1,
"number": "0x1",
"parentHash": "0x7CebC07e456F0bCD09dbc9A6f271074d93E27B40A4C67Dcc402e6513e12B9aF9",
"receiptsRoot": "0x02B82e11eDC07775Dc6fCF706be2cdAF9165750Ea7bC1B3Eb48ea16Bb3072F4D",
"stateRoot": "0xAaDc89C8bA4e3fCfC140cFcc8D3efD3BE7a49ab31534A5a3F0E1DEA09aae0f4a",
"timestamp": "0x62c44c0a",
"transactionsRoot": "0xc4bfa888fDCC8ca70E2b0CcdCEcc2fF545acCC2D655Ba33DaF4aBc31cFDBd9Ac",
"uncles": []
}
}),
);
const res = await bc.getBlockByNumber({ blockNumber: 'latest' });
const size = res.result.size;
expect(res.responseType).toEqual('raw');
expect(harmony.utils.isHex(size)).toEqual(true);
expect(woop.utils.isHex(size)).toEqual(true);
expect(checkBlockData(res.result)).toEqual(true);
const res2 = await bc.getBlockByNumber({blockNumber: res.result.number});
const res2 = await bc.getBlockByNumber({ blockNumber: res.result.number });
expect(res2.responseType).toEqual('raw');
expect(harmony.utils.isHex(res2.result.size)).toEqual(true);
expect(woop.utils.isHex(res2.result.size)).toEqual(true);
expect(checkBlockData(res2.result)).toEqual(true);
const res3 = await bc.getBlockByNumber({returnObject: true});
const res3 = await bc.getBlockByNumber({ returnObject: true });
expect(res3.responseType).toEqual('raw');
expect(checkBlockData(res3.result)).toEqual(true);
for(let i = 0; i < 3; i++) {
expect(checkCalledMethod(i, RPCMethod.GetBlockByNumber)).toEqual(true);
}
});
it('should test hmy_getBlockByHash', async () => {
const latestBlock = await bc.getBlockByNumber({blockNumber: 'latest'});
const res = await bc.getBlockByHash({blockHash: latestBlock.result.hash});
it('should test wiki_getBlockByHash', async () => {
fetch.mockResponse(
JSON.stringify({
"jsonrpc": "2.0",
"id": 1,
"result": {
"size": "0x1",
"difficulty": 5,
"extraData": "0x",
"gasLimit": "0x80",
"gasUsed": "0x40",
"hash": "0x8a3390ab500Fbca6514eB326d2fcD9B3BFCFbA7DA392593cB4885b8e3399a2D8",
"logsBloom": "0x0",
"miner": "one155jp2y76nazx8uw5sa94fr0m4s5aj8e5xm6fu3",
"mixHash": "0x3A7c1Ae14AfecFf55Da298F66b75F4FfB771c3EaBDeAa267FF33A77d4d0be220",
"nonce": 1,
"number": "0x1",
"parentHash": "0x7CebC07e456F0bCD09dbc9A6f271074d93E27B40A4C67Dcc402e6513e12B9aF9",
"receiptsRoot": "0x02B82e11eDC07775Dc6fCF706be2cdAF9165750Ea7bC1B3Eb48ea16Bb3072F4D",
"stateRoot": "0xAaDc89C8bA4e3fCfC140cFcc8D3efD3BE7a49ab31534A5a3F0E1DEA09aae0f4a",
"timestamp": "0x62c44c0a",
"transactionsRoot": "0xc4bfa888fDCC8ca70E2b0CcdCEcc2fF545acCC2D655Ba33DaF4aBc31cFDBd9Ac",
"uncles": []
}
}),
);
const latestBlock = await bc.getBlockByNumber({ blockNumber: 'latest' });
const res = await bc.getBlockByHash({ blockHash: latestBlock.result.hash });
expect(res.responseType).toEqual('raw');
expect(latestBlock.result.hash).toEqual(res.result.hash);
expect(harmony.utils.isHex(res.result.size)).toEqual(true);
expect(woop.utils.isHex(res.result.size)).toEqual(true);
expect(checkBlockData(res.result)).toEqual(true);
expect(checkCalledMethod(0, RPCMethod.GetBlockByNumber)).toEqual(true);
expect(checkCalledMethod(1, RPCMethod.GetBlockByHash)).toEqual(true);
});
// account related
it('should test hmy_getBalance', async () => {
const balance = await bc.getBalance({address: testAccount.Address});
expect(harmony.utils.isHex(balance.result)).toEqual(true);
it('should test wiki_getBalance', async () => {
fetch.mockResponseOnce(
JSON.stringify({"jsonrpc": "2.0", "id": 1, "result": "0x10"}),
);
const balance = await bc.getBalance({ address: testAccount.Address });
expect(woop.utils.isHex(balance.result)).toEqual(true);
expect(checkCalledMethod(0, RPCMethod.GetBalance)).toEqual(true);
});
});
function checkBlockData(data: any) {
return harmony.utils.validateArgs(
return woop.utils.validateArgs(
data,
{
difficulty: [harmony.utils.isNumber],
difficulty: [woop.utils.isNumber],
// tslint:disable-next-line: no-shadowed-variable
extraData: [(data: any) => data === '0x' || harmony.utils.isHex(data)],
gasLimit: [harmony.utils.isHex],
gasUsed: [harmony.utils.isHex],
hash: [harmony.utils.isHash],
logsBloom: [harmony.utils.isHex],
miner: [harmony.utils.isAddress],
mixHash: [harmony.utils.isHash],
nonce: [harmony.utils.isNumber],
number: [harmony.utils.isHex],
parentHash: [harmony.utils.isHash],
receiptsRoot: [harmony.utils.isHash],
size: [harmony.utils.isHex],
stateRoot: [harmony.utils.isHash],
timestamp: [harmony.utils.isHex],
transactionsRoot: [harmony.utils.isHash],
uncles: [harmony.utils.isArray],
extraData: [(data: any) => data === '0x' || woop.utils.isHex(data)],
gasLimit: [woop.utils.isHex],
gasUsed: [woop.utils.isHex],
hash: [woop.utils.isHash],
logsBloom: [woop.utils.isHex],
miner: [woop.utils.isBech32Address],
mixHash: [woop.utils.isHash],
nonce: [woop.utils.isNumber],
number: [woop.utils.isHex],
parentHash: [woop.utils.isHash],
receiptsRoot: [woop.utils.isHash],
size: [woop.utils.isHex],
stateRoot: [woop.utils.isHash],
timestamp: [woop.utils.isHex],
transactionsRoot: [woop.utils.isHash],
uncles: [woop.utils.isArray],
},
{transactions: [harmony.utils.isArray]},
{ transactions: [woop.utils.isArray] },
);
}
}

@ -1,29 +0,0 @@
// tslint:disable-next-line: no-implicit-dependencies
import { Harmony } from '@harmony-js/core';
// tslint:disable-next-line: no-implicit-dependencies
import { ChainType } from '@harmony-js/utils';
// tslint:disable-next-line: no-implicit-dependencies
import { Account } from '@harmony-js/account';
const CHAIN_ID: number = parseInt(process.env.CHAIN_ID as string, 10);
const CHAIN_TYPE: string = process.env.CHAIN_TYPE as string;
const HTTP_PROVIDER: string = process.env.HTTP_PROVIDER as string;
const GENESIS_PRIV_KEY: string = process.env.GENESIS_PRIV_KEY as string;
let chainType: ChainType = ChainType.Harmony;
if (CHAIN_TYPE === 'hmy') {
chainType = ChainType.Harmony;
} else if (CHAIN_TYPE === 'eth') {
chainType = ChainType.Ethereum;
}
export const harmony: Harmony = new Harmony(HTTP_PROVIDER, {
chainId: CHAIN_ID,
chainType,
chainUrl: HTTP_PROVIDER,
});
export const myAccount: Account = harmony.wallet.addByPrivateKey(
GENESIS_PRIV_KEY,
);

@ -1,15 +1,20 @@
import { harmony } from './harmony';
import fetch from 'jest-fetch-mock';
import { woop, checkCalledMethod } from './woop';
// tslint:disable-next-line: no-implicit-dependencies
import { Transaction, TxStatus } from '@harmony-js/transaction';
import { Transaction, TxStatus } from '@woop-js/transaction';
// tslint:disable-next-line: no-implicit-dependencies
import { isHash, numberToHex } from '@harmony-js/utils';
import { isHash, numberToHex } from '@woop-js/utils';
import txnJsons from '../fixtures/transactions.json';
import demoAccounts from '../fixtures/testAccount.json';
import { RPCMethod } from '@woop-js/network';
const receiver = demoAccounts.Accounts[3];
jest.useRealTimers();
describe('test Transaction using SDK', () => {
beforeEach(() => {
fetch.resetMocks();
});
let signed: Transaction;
let sent: Transaction;
let txId: string;
@ -18,7 +23,7 @@ describe('test Transaction using SDK', () => {
const txns = txnJsons.transactions;
// tslint:disable-next-line: prefer-for-of
for (let i = 0; i < txns.length; i += 1) {
const newTxn = harmony.transactions.newTx();
const newTxn = woop.transactions.newTx();
newTxn.recover(txns[i].rawTransaction);
expect(newTxn.txParams.from).toEqual(txns[i].senderAddress);
@ -31,25 +36,63 @@ describe('test Transaction using SDK', () => {
});
it('should test signTransaction', async () => {
const txnObject = {
to: harmony.crypto.getAddress(receiver.Address).bech32,
to: woop.crypto.getAddress(receiver.Address).bech32,
value: '0x64',
gasLimit: '210000',
gasPrice: new harmony.utils.Unit('100').asGwei().toWei(),
gasPrice: new woop.utils.Unit('100').asGwei().toWei(),
};
const txn = harmony.transactions.newTx(txnObject);
signed = await harmony.wallet.signTransaction(txn);
const txn = woop.transactions.newTx(txnObject);
signed = await woop.wallet.signTransaction(txn, undefined, undefined, false);
expect(signed.isSigned()).toEqual(true);
});
it('should send transaction', async () => {
fetch.mockResponseOnce(
JSON.stringify({
"jsonrpc": "2.0", "id": 1,
"result": "0x323A2B2C81d8948E5109FC32f9d0e4e6d178d14cC732C8E0a7Af74E81C7653eA"
}),
);
const [sentTxn, id] = await signed.sendTransaction();
expect(sentTxn.isPending()).toEqual(true);
expect(harmony.utils.isHash(id)).toEqual(true);
expect(woop.utils.isHash(id)).toEqual(true);
expect(checkCalledMethod(0, RPCMethod.SendRawTransaction)).toEqual(true);
txId = id;
sent = sentTxn;
});
it('should confirm a transaction', async () => {
fetch.mockResponses(
[
JSON.stringify({"jsonrpc": "2.0", "id": 1, "result": "0x1"}),
{ status: 200 },
],
[
JSON.stringify({"jsonrpc": "2.0", "id": 1, "result": "0x2"}),
{ status: 200 },
],
[
JSON.stringify({
"jsonrpc": "2.0",
"id": 1,
"result": {
"contractAddress": null,
"blockNumber": woop.utils.numberToHex(2),
"from": woop.wallet.accounts[0],
"gasUsed": woop.utils.numberToHex(5),
"cumulativeGasUsed": woop.utils.numberToHex(5),
"logs": [],
"logsBloom": woop.utils.numberToHex(5),
"shardID": 0,
"to": demoAccounts.Accounts[3].Address,
"transactionHash": "0x8c26EFdb6e4cAC6F8BeACE59F52fd95beD4Bfbfa8fF30F4a7cEd511fE5f869d9",
"transactionIndex": woop.utils.numberToHex(10),
"blockHash": "0xFECCCCBFd5AC71902BcfE65dDB0b88EEbbD15AD6cDAE7A9FAEb773bF827320fd",
}
}),
{status: 200},
]
)
const toConfirm = await sent.confirm(txId, 20, 1000);
expect(toConfirm.receipt !== undefined).toEqual(true);
expect(checkTransactionReceipt(toConfirm.receipt)).toEqual(true);
@ -58,16 +101,19 @@ describe('test Transaction using SDK', () => {
} else if (toConfirm.isRejected()) {
expect(toConfirm.txStatus).toEqual(TxStatus.REJECTED);
}
expect(checkCalledMethod(0, RPCMethod.BlockNumber)).toEqual(true);
expect(checkCalledMethod(1, RPCMethod.BlockNumber)).toEqual(true);
expect(checkCalledMethod(2, RPCMethod.GetTransactionReceipt)).toEqual(true);
});
it('should test transaction observed events', async () => {
const txnObject = {
to: harmony.crypto.getAddress(receiver.Address).bech32,
value: new harmony.utils.Unit('100').asGwei().toWei(),
gasLimit: new harmony.utils.Unit('210000').asWei().toWei(),
gasPrice: new harmony.utils.Unit('100').asGwei().toWei(),
to: woop.crypto.getAddress(receiver.Address).bech32,
value: new woop.utils.Unit('100').asGwei().toWei(),
gasLimit: new woop.utils.Unit('210000').asWei().toWei(),
gasPrice: new woop.utils.Unit('100').asGwei().toWei(),
};
const txn = harmony.transactions.newTx(txnObject);
const txn = woop.transactions.newTx(txnObject);
txn
.observed()
.on('transactionHash', (transactionHash) => {
@ -84,35 +130,78 @@ describe('test Transaction using SDK', () => {
.on('error', (error) => {
expect(error).toBeTruthy();
});
const txnSigned = await harmony.wallet.signTransaction(txn);
const txnSigned = await woop.wallet.signTransaction(txn, undefined, undefined, false);
fetch.mockResponseOnce(
JSON.stringify({
"jsonrpc": "2.0", "id": 1,
"result": "0x323A2B2C81d8948E5109FC32f9d0e4e6d178d14cC732C8E0a7Af74E81C7653eA"
}),
);
const [txnSent, id] = await txnSigned.sendTransaction();
expect(txnSent.txStatus).toEqual(TxStatus.PENDING);
expect(checkCalledMethod(0, RPCMethod.SendRawTransaction)).toEqual(true);
console.log('Here');
fetch.mockResponses(
[
JSON.stringify({"jsonrpc": "2.0", "id": 1, "result": "0x1"}),
{ status: 200 },
],
[
JSON.stringify({"jsonrpc": "2.0", "id": 1, "result": "0x2"}),
{ status: 200 },
],
[
JSON.stringify({
"jsonrpc": "2.0",
"id": 1,
"result": {
"contractAddress": null,
"blockNumber": woop.utils.numberToHex(2),
"from": woop.wallet.accounts[0],
"gasUsed": woop.utils.numberToHex(5),
"cumulativeGasUsed": woop.utils.numberToHex(5),
"logs": [],
"logsBloom": woop.utils.numberToHex(5),
"shardID": 0,
"to": demoAccounts.Accounts[3].Address,
"transactionHash": "0x8c26EFdb6e4cAC6F8BeACE59F52fd95beD4Bfbfa8fF30F4a7cEd511fE5f869d9",
"transactionIndex": woop.utils.numberToHex(10),
"blockHash": "0xFECCCCBFd5AC71902BcfE65dDB0b88EEbbD15AD6cDAE7A9FAEb773bF827320fd",
"status": "0x1",
}
}),
{status: 200},
]
);
await txnSigned.confirm(id);
expect(checkCalledMethod(1, RPCMethod.BlockNumber)).toEqual(true);
expect(checkCalledMethod(2, RPCMethod.BlockNumber)).toEqual(true);
expect(checkCalledMethod(3, RPCMethod.GetTransactionReceipt)).toEqual(true);
});
});
function checkTransactionReceipt(data: any) {
return harmony.utils.validateArgs(
return woop.utils.validateArgs(
data,
{
blockHash: [harmony.utils.isHash],
blockNumber: [harmony.utils.isHex],
blockHash: [woop.utils.isHash],
blockNumber: [woop.utils.isHex],
contractAddress: [
// tslint:disable-next-line: no-shadowed-variable
(data: any) => data === null || harmony.utils.isValidAddress,
(data: any) => data === null || woop.utils.isValidAddress,
],
cumulativeGasUsed: [harmony.utils.isHex],
from: [harmony.utils.isValidAddress],
gasUsed: [harmony.utils.isHex],
logs: [harmony.utils.isArray],
logsBloom: [harmony.utils.isHex],
cumulativeGasUsed: [woop.utils.isHex],
from: [woop.utils.isValidAddress],
gasUsed: [woop.utils.isHex],
logs: [woop.utils.isArray],
logsBloom: [woop.utils.isHex],
shardID: [harmony.utils.isNumber],
shardID: [woop.utils.isNumber],
// tslint:disable-next-line: no-shadowed-variable
to: [(data: any) => data === '0x' || harmony.utils.isValidAddress],
transactionHash: [harmony.utils.isHash],
transactionIndex: [harmony.utils.isHex],
to: [(data: any) => data === '0x' || woop.utils.isValidAddress],
transactionHash: [woop.utils.isHash],
transactionIndex: [woop.utils.isHex],
},
{ root: [harmony.utils.isHash] },
{ root: [woop.utils.isHash] },
);
}

@ -1,7 +1,9 @@
import { harmony } from './harmony';
import fetch from 'jest-fetch-mock';
import { woop, checkCalledMethod } from './woop';
import txnJsons from '../fixtures/transactions.json';
import { RPCMethod } from '@woop-js/network';
const messenger = harmony.messenger;
const messenger = woop.messenger;
interface TransactionInfo {
blockHash: string;
@ -10,23 +12,53 @@ interface TransactionInfo {
}
describe('e2e test transactions by RPC Method', () => {
beforeEach(() => {
fetch.resetMocks();
});
const txnHashesFixtures: any = [];
const transactionInfoList: any = [];
const { transactions, hashes, blockHashes } = txnJsons;
// net_*
it('should test hmy_sendRawTransaction', async () => {
const { transactions } = txnJsons;
for (const txn of transactions) {
const sent = await messenger.send('hmy_sendRawTransaction', txn.rawTransaction);
expect(harmony.utils.isHash(sent.result)).toEqual(true);
it('should test wiki_sendRawTransaction', async () => {
for(let index = 0; index < transactions.length; index++) {
fetch.mockResponseOnce(
JSON.stringify({"jsonrpc": "2.0", "id": 1, "result": hashes[index]}),
);
const sent = await messenger.send('wiki_sendRawTransaction', transactions[index].rawTransaction);
expect(woop.utils.isHash(sent.result)).toEqual(true);
txnHashesFixtures.push(sent.result);
expect(checkCalledMethod(index, 'wiki_sendRawTransaction')).toEqual(true);
}
});
it('should test hmy_getTransactionByHash', async () => {
for (const txnHash of txnHashesFixtures) {
const txnDetail = await harmony.blockchain.getTransactionByHash({
txnHash,
it('should test wiki_getTransactionByHash', async () => {
for(let index: number = 0; index < txnHashesFixtures.length; index++) {
const txnHash = txnHashesFixtures[index];
fetch.mockResponseOnce(
JSON.stringify({
"jsonrpc": "2.0",
"id": 1,
"result": {
"hash": hashes[index],
"blockHash": blockHashes[index],
"blockNumber": woop.utils.numberToHex(index),
"transactionIndex": woop.utils.numberToHex(index),
"from": transactions[index].senderAddress,
"gas": transactions[index].gasLimit,
"gasPrice": transactions[index].gasPrice,
"input": "0x",
"nonce": transactions[index].nonce,
"to": transactions[index].receiverAddressBech32,
"value": transactions[index].value,
"v": woop.utils.numberToHex(index),
"r": woop.utils.numberToHex(index),
"s": woop.utils.numberToHex(index),
}
})
);
const txnDetail = await woop.blockchain.getTransactionByHash({
txnHash
});
expect(checkCalledMethod(index, RPCMethod.GetTransactionByHash)).toEqual(true);
if (txnDetail.result !== null) {
expect(checkTransactionDetail(txnDetail.result)).toEqual(true);
expect(txnDetail.result.hash).toEqual(txnHash);
@ -37,84 +69,194 @@ describe('e2e test transactions by RPC Method', () => {
index: txnDetail.result.transactionIndex,
};
transactionInfoList.push(transactionInfo);
} else {
fail(`txnDetail for ${txnHash} is null`);
}
}
});
it('should test hmy_getTransactionByBlockHashAndIndex', async () => {
for (const some of transactionInfoList) {
const transactionInfo: TransactionInfo = some;
const txnDetail: any = await harmony.blockchain.getTransactionByBlockHashAndIndex({
it('should test wiki_getTransactionByBlockHashAndIndex', async () => {
for (let index: number = 0; index < transactionInfoList.length; index++) {
fetch.mockResponseOnce((req) => {
if (!(Buffer.isBuffer(req.body))) {
fail("POST request body not a buffer");
}
const body: any = JSON.parse(req.body.toString());
// validate that the block hash is as expected
if (body.params[0] !== blockHashes[index]) {
fail(`Expected block hash ${blockHashes[index]} but got ${body.params[0]}`);
}
// validate that the transaction index is as expected
let expectedTransactionIndex: string = woop.utils.numberToHex(index);
if (expectedTransactionIndex !== body.params[1]) {
fail(`Expected transactionIndex ${expectedTransactionIndex} but got ${body.params[1]}`);
}
return Promise.resolve(JSON.stringify({
"jsonrpc": "2.0",
"id": 1,
"result": {
"hash": hashes[index],
"blockHash": blockHashes[index],
"blockNumber": woop.utils.numberToHex(index),
"transactionIndex": woop.utils.numberToHex(index),
"from": transactions[index].senderAddress,
"gas": transactions[index].gasLimit,
"gasPrice": transactions[index].gasPrice,
"input": "0x",
"nonce": transactions[index].nonce,
"to": transactions[index].receiverAddressBech32,
"value": transactions[index].value,
"v": woop.utils.numberToHex(index),
"r": woop.utils.numberToHex(index),
"s": woop.utils.numberToHex(index),
}
}));
});
const transactionInfo: TransactionInfo = transactionInfoList[index];
const txnDetail: any = await woop.blockchain.getTransactionByBlockHashAndIndex({
blockHash: transactionInfo.blockHash,
index: transactionInfo.index,
});
expect(checkCalledMethod(index, RPCMethod.GetTransactionByBlockHashAndIndex)).toEqual(true);
if (txnDetail.result !== null) {
expect(checkTransactionDetail(txnDetail.result)).toEqual(true);
expect(txnDetail.result.blockHash).toEqual(transactionInfo.blockHash);
expect(txnDetail.result.transactionIndex).toEqual(transactionInfo.index);
} else {
fail(`txnDetail for ${transactionInfo.blockHash}_${transactionInfo.index} is null`);
}
}
});
it('should test hmy_getTransactionByBlockNumberAndIndex', async () => {
for (const some of transactionInfoList) {
const transactionInfo: TransactionInfo = some;
const txnDetail: any = await harmony.blockchain.getTransactionByBlockNumberAndIndex({
it('should test wiki_getTransactionByBlockNumberAndIndex', async () => {
for (let index: number = 0; index < transactionInfoList.length; index++) {
fetch.mockResponseOnce((req) => {
if (!(Buffer.isBuffer(req.body))) {
fail("POST request body not a buffer");
}
const body: any = JSON.parse(req.body.toString());
// validate that the block number is as expected
let expectedBlockNumber: string = woop.utils.numberToHex(index);
if (body.params[0] !== expectedBlockNumber) {
fail(`Expected block number ${index} but got ${body.params[0]}`);
}
// validate that the transaction index is as expected
let expectedTransactionIndex: string = woop.utils.numberToHex(index);
if (expectedTransactionIndex !== body.params[1]) {
fail(`Expected transactionIndex ${expectedTransactionIndex} but got ${body.params[1]}`);
}
return Promise.resolve(JSON.stringify({
"jsonrpc": "2.0",
"id": 1,
"result": {
"hash": hashes[index],
"blockHash": blockHashes[index],
"blockNumber": woop.utils.numberToHex(index),
"transactionIndex": woop.utils.numberToHex(index),
"from": transactions[index].senderAddress,
"gas": transactions[index].gasLimit,
"gasPrice": transactions[index].gasPrice,
"input": "0x",
"nonce": transactions[index].nonce,
"to": transactions[index].receiverAddressBech32,
"value": transactions[index].value,
"v": woop.utils.numberToHex(index),
"r": woop.utils.numberToHex(index),
"s": woop.utils.numberToHex(index),
}
}));
});
const transactionInfo: TransactionInfo = transactionInfoList[index];
const txnDetail: any = await woop.blockchain.getTransactionByBlockNumberAndIndex({
blockNumber: transactionInfo.blockNumber,
index: transactionInfo.index,
});
expect(checkCalledMethod(index, RPCMethod.GetTransactionByBlockNumberAndIndex)).toEqual(true);
if (txnDetail.result !== null) {
expect(checkTransactionDetail(txnDetail.result)).toEqual(true);
expect(txnDetail.result.blockNumber).toEqual(transactionInfo.blockNumber);
expect(txnDetail.result.transactionIndex).toEqual(transactionInfo.index);
} else {
fail(`txnDetail for ${transactionInfo.blockNumber}_${transactionInfo.index} is null`);
}
}
});
it('should test hmy_getTransactionCountByHash', async () => {
it('should test wiki_getTransactionCountByHash', async () => {
for (const some of transactionInfoList) {
fetch.mockResponseOnce(
JSON.stringify({"jsonrpc": "2.0", "id": 1, "result": "0x1"}),
);
const transactionInfo: TransactionInfo = some;
const txnCount: any = await harmony.blockchain.getBlockTransactionCountByHash({
const txnCount: any = await woop.blockchain.getBlockTransactionCountByHash({
blockHash: transactionInfo.blockHash,
});
expect(harmony.utils.isHex(txnCount.result)).toEqual(true);
expect(checkCalledMethod(0, RPCMethod.GetBlockTransactionCountByHash)).toEqual(true);
expect(woop.utils.isHex(txnCount.result)).toEqual(true);
}
});
it('should test hmy_getTransactionCountByNumber', async () => {
it('should test wiki_getTransactionCountByNumber', async () => {
for (const some of transactionInfoList) {
fetch.mockResponseOnce(
JSON.stringify({"jsonrpc": "2.0", "id": 1, "result": "0x1"}),
);
const transactionInfo: TransactionInfo = some;
const txnCount: any = await harmony.blockchain.getBlockTransactionCountByNumber({
const txnCount: any = await woop.blockchain.getBlockTransactionCountByNumber({
blockNumber: transactionInfo.blockNumber,
});
expect(harmony.utils.isHex(txnCount.result)).toEqual(true);
expect(checkCalledMethod(0, RPCMethod.GetBlockTransactionCountByNumber)).toEqual(true);
expect(woop.utils.isHex(txnCount.result)).toEqual(true);
}
});
it('should test hmy_getTransactionReceipt', async () => {
const { transactions } = txnJsons;
it('should test wiki_getTransactionReceipt', async () => {
// tslint:disable-next-line: prefer-for-of
for (let i = 0; i < txnHashesFixtures.length; i += 1) {
const txnHash = txnHashesFixtures[i];
const receipt: any = await harmony.blockchain.getTransactionReceipt({
for (let index = 0; index < txnHashesFixtures.length; index += 1) {
const txnHash = txnHashesFixtures[index];
fetch.mockResponseOnce(
JSON.stringify({
"jsonrpc": "2.0",
"id": 1,
"result": {
"contractAddress": null,
"blockNumber": woop.utils.numberToHex(index),
"from": transactions[index].senderAddress,
"gasUsed": woop.utils.numberToHex(index),
"cumulativeGasUsed": woop.utils.numberToHex(index),
"logs": [],
"logsBloom": woop.utils.numberToHex(index),
"shardID": 0,
"to": transactions[index].receiverAddress,
"transactionHash": hashes[index],
"transactionIndex": woop.utils.numberToHex(index),
"blockHash": blockHashes[index]
}
})
);
const receipt: any = await woop.blockchain.getTransactionReceipt({
txnHash,
});
expect(checkCalledMethod(index, RPCMethod.GetTransactionReceipt)).toEqual(true);
if (receipt.result !== null) {
expect(checkTransactionReceipt(receipt.result)).toEqual(true);
expect(harmony.crypto.getAddress(receipt.result.from).checksum).toEqual(
transactions[i].senderAddress,
expect(woop.crypto.getAddress(receipt.result.from).checksum).toEqual(
transactions[index].senderAddress,
);
expect(harmony.crypto.getAddress(receipt.result.to).checksum).toEqual(
transactions[i].receiverAddress,
expect(woop.crypto.getAddress(receipt.result.to).checksum).toEqual(
transactions[index].receiverAddress,
);
expect(receipt.result.blockHash).toEqual(transactionInfoList[i].blockHash);
expect(receipt.result.blockNumber).toEqual(transactionInfoList[i].blockNumber);
expect(receipt.result.transactionIndex).toEqual(transactionInfoList[i].index);
expect(receipt.result.blockHash).toEqual(transactionInfoList[index].blockHash);
expect(receipt.result.blockNumber).toEqual(transactionInfoList[index].blockNumber);
expect(receipt.result.transactionIndex).toEqual(transactionInfoList[index].index);
} else {
fail(`receipt for ${txnHash} is null`);
}
}
});
it('should test hmy_getTransactionCount', async () => {
const { transactions } = txnJsons;
it('should test wiki_getTransactionCount', async () => {
for (let i = 0; i < transactionInfoList; i += 1) {
fetch.mockResponseOnce(
JSON.stringify({"jsonrpc": "2.0", "id": 1, "result": "0x1"}),
);
const transactionInfo: TransactionInfo = transactionInfoList[i];
const nonce: any = await harmony.blockchain.getTransactionCount({
const nonce: any = await woop.blockchain.getTransactionCount({
address: transactions[i].senderAddressBech32,
blockNumber: transactionInfo.blockNumber,
});
@ -124,52 +266,52 @@ describe('e2e test transactions by RPC Method', () => {
});
function checkTransactionDetail(data: any) {
return harmony.utils.validateArgs(
return woop.utils.validateArgs(
data,
{
blockHash: [harmony.utils.isHash],
blockNumber: [harmony.utils.isHex],
blockHash: [woop.utils.isHash],
blockNumber: [woop.utils.isHex],
// tslint:disable-next-line: no-shadowed-variable
from: [harmony.utils.isValidAddress],
gas: [harmony.utils.isHex],
gasPrice: [harmony.utils.isHex],
hash: [harmony.utils.isHash],
from: [woop.utils.isValidAddress],
gas: [woop.utils.isHex],
gasPrice: [woop.utils.isHex],
hash: [woop.utils.isHash],
// tslint:disable-next-line: no-shadowed-variable
input: [(data: any) => data === '0x' || harmony.utils.isHex(data)],
nonce: [harmony.utils.isHex],
input: [(data: any) => data === '0x' || woop.utils.isHex(data)],
nonce: [woop.utils.isHex],
// tslint:disable-next-line: no-shadowed-variable
to: [(data: any) => data === '0x' || harmony.utils.isValidAddress(data)],
transactionIndex: [harmony.utils.isHex],
value: [harmony.utils.isHex],
v: [harmony.utils.isHex],
r: [harmony.utils.isHex],
s: [harmony.utils.isHex],
to: [(data: any) => data === '0x' || woop.utils.isValidAddress(data)],
transactionIndex: [woop.utils.isHex],
value: [woop.utils.isHex],
v: [woop.utils.isHex],
r: [woop.utils.isHex],
s: [woop.utils.isHex],
},
{},
);
}
function checkTransactionReceipt(data: any) {
return harmony.utils.validateArgs(
return woop.utils.validateArgs(
data,
{
blockNumber: [harmony.utils.isHex],
blockNumber: [woop.utils.isHex],
contractAddress: [
// tslint:disable-next-line: no-shadowed-variable
(data: any) => data === null || harmony.utils.isValidAddress,
(data: any) => data === null || woop.utils.isValidAddress,
],
cumulativeGasUsed: [harmony.utils.isHex],
from: [harmony.utils.isValidAddress],
gasUsed: [harmony.utils.isHex],
logs: [harmony.utils.isArray],
logsBloom: [harmony.utils.isHex],
cumulativeGasUsed: [woop.utils.isHex],
from: [woop.utils.isValidAddress],
gasUsed: [woop.utils.isHex],
logs: [woop.utils.isArray],
logsBloom: [woop.utils.isHex],
shardID: [harmony.utils.isNumber],
shardID: [woop.utils.isNumber],
// tslint:disable-next-line: no-shadowed-variable
to: [(data: any) => data === '0x' || harmony.utils.isValidAddress],
transactionHash: [harmony.utils.isHash],
transactionIndex: [harmony.utils.isHex],
to: [(data: any) => data === '0x' || woop.utils.isValidAddress],
transactionHash: [woop.utils.isHash],
transactionIndex: [woop.utils.isHex],
},
{ blockHash: [harmony.utils.isHash], root: [harmony.utils.isHash] },
{ blockHash: [woop.utils.isHash], root: [woop.utils.isHash] },
);
}

@ -0,0 +1,39 @@
import fetch from 'jest-fetch-mock';
// tslint:disable-next-line: no-implicit-dependencies
import { Woop } from '@woop-js/core';
// tslint:disable-next-line: no-implicit-dependencies
import { ChainType } from '@woop-js/utils';
// tslint:disable-next-line: no-implicit-dependencies
import { Account } from '@woop-js/account';
const CHAIN_ID: number = 2;
const CHAIN_TYPE: string = 'wiki';
const HTTP_PROVIDER: string = 'http://localhost:9500';
const GENESIS_PRIV_KEY: string = '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e';
let chainType: ChainType = ChainType.Woop;
if (CHAIN_TYPE === 'wiki') {
chainType = ChainType.Woop;
} else if (CHAIN_TYPE === 'eth') {
chainType = ChainType.Ethereum;
}
export const woop: Woop = new Woop(HTTP_PROVIDER, {
chainId: CHAIN_ID,
chainType,
chainUrl: HTTP_PROVIDER,
});
export const myAccount: Account = woop.wallet.addByPrivateKey(
GENESIS_PRIV_KEY,
);
export function checkCalledMethod(i: number, s: string) {
let params: (string | undefined) = fetch.mock.calls[i][1]?.body?.toString();
if (params) {
let method: string = JSON.parse(params).method;
return method === s;
}
return false;
}

@ -3,15 +3,17 @@
"compilerOptions": {
"outDir": "dist",
"rootDir": "src",
"declarationDir": "dist"
"declarationDir": "dist",
"resolveJsonModule": true,
"esModuleInterop": true
},
"include": ["src", "../typings/**/*.d.ts", "fixtures"],
"references": [
{ "path": "../packages/harmony-account" },
{ "path": "../packages/harmony-crypto" },
{ "path": "../packages/harmony-utils" },
{ "path": "../packages/harmony-network" },
{ "path": "../packages/harmony-transaction" },
{ "path": "../packages/harmony-contract" }
{ "path": "../packages/woop-account" },
{ "path": "../packages/woop-crypto" },
{ "path": "../packages/woop-utils" },
{ "path": "../packages/woop-network" },
{ "path": "../packages/woop-transaction" },
{ "path": "../packages/woop-contract" }
]
}

@ -1,134 +0,0 @@
# Quick start
1. You need Harmony local testnet running.
instruction here:[harmony-one/harmony](https://github.com/harmony-one/harmony)
2. Run this example under nodejs enviorment.
```javascript
// import or require Harmony class
const { Harmony } = require('@harmony-js/core');
// import or require settings
const { ChainID, ChainType } = require('@harmony-js/utils');
// 1. initialize the Harmony instance
const harmony = new Harmony(
// rpc url
'http://localhost:9500',
{
// chainType set to Harmony
chainType: ChainType.Harmony,
// chainType set to HmyLocal
chainId: ChainID.HmyLocal,
},
);
// 2. get wallet ready
// specify the privateKey
const privateKey = '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e';
// add privateKey to wallet
const sender = harmony.wallet.addByPrivateKey(privateKey);
// 3. get sharding info
async function setSharding() {
// Harmony is a sharded blockchain, each endpoint have sharding structure,
// However sharding structure is different between mainnet, testnet and local testnet
// We need to get sharding info before doing cross-shard transaction
const res = await harmony.blockchain.getShardingStructure();
harmony.shardingStructures(res.result);
}
// 4. get transaction payload ready
async function transfer() {
// run set sharding first, if you want to make a cross-shard transaction
await setSharding();
const txn = harmony.transactions.newTx({
// token send to
to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2',
// amount to send
value: '10000',
// gas limit, you can use string
gasLimit: '210000',
// send token from shardID
shardID: 0,
// send token to toShardID
toShardID: 0,
// gas Price, you can use Unit class, and use Gwei, then remember to use toWei(), which will be transformed to BN
gasPrice: new harmony.utils.Unit('100').asGwei().toWei(),
});
// sign the transaction use wallet;
const signedTxn = await harmony.wallet.signTransaction(txn);
// Now you can use `Transaction.observed()` to listen events
signedTxn
.observed()
.on('transactionHash', (txnHash) => {
console.log('');
console.log('--- hash ---');
console.log('');
console.log(txnHash);
console.log('');
})
.on('receipt', (receipt) => {
console.log('');
console.log('--- receipt ---');
console.log('');
console.log(receipt);
console.log('');
})
.on('cxReceipt', (receipt) => {
console.log('');
console.log('--- cxReceipt ---');
console.log('');
console.log(receipt);
console.log('');
})
.on('error', (error) => {
console.log('');
console.log('--- error ---');
console.log('');
console.log(error);
console.log('');
});
// send the txn, get [Transaction, transactionHash] as result
const [sentTxn, txnHash] = await signedTxn.sendTransaction();
// to confirm the result if it is already there
const confiremdTxn = await sentTxn.confirm(txnHash);
// if the transactino is cross-shard transaction
if (!confiremdTxn.isCrossShard()) {
if (confiremdTxn.isConfirmed()) {
console.log('--- Result ---');
console.log('');
console.log('Normal transaction');
console.log(`${txnHash} is confirmed`);
console.log('');
process.exit();
}
}
if (confiremdTxn.isConfirmed() && confiremdTxn.isCxConfirmed()) {
console.log('--- Result ---');
console.log('');
console.log('Cross-Shard transaction');
console.log(`${txnHash} is confirmed`);
console.log('');
process.exit();
}
}
transfer();
```
# More examples
* [dapp-examples](https://github.com/harmony-one/dapp-examples)

@ -1,31 +0,0 @@
const { Harmony } = require('@harmony-js/core');
// import or require settings
const { ChainID, ChainType } = require('@harmony-js/utils');
const URL_TESTNET = `https://api.s0.b.hmny.io`;
const URL_MAINNET = `https://api.s0.t.hmny.io`;
// 1. initialize the Harmony instance
const harmony = new Harmony(
// rpc url
URL_TESTNET,
{
// chainType set to Harmony
chainType: ChainType.Harmony,
// chainType set to HmyLocal
chainId: ChainID.HmyTestnet,
},
);
harmony.blockchain
.getBalance({
address: `one1vjywuur8ckddmc4dsyx6qdgf590eu07ag9fg4a`,
})
.then((res) => {
console.log(new harmony.utils.Unit(res.result).asWei().toEther());
})
.catch((err) => {
console.log(err);
});

@ -1,45 +0,0 @@
// import the Account class
const { Account } = require('@harmony-js/account');
// suppose we have an account
const myPrivateKey = '0x831f0b3ff835d5ec4602878742fda25591b6d3bb2731366621ac83a05216bec8';
const myAccountWithMyPrivateKey = new Account(myPrivateKey);
// suppose we have a password, and we want to encrypt the account above
const myStrongPassword = '123';
async function encryptAndDecrypt(password) {
// we get the privateKey before encrypted as comparison
const unencryptedPrivateKey = myAccountWithMyPrivateKey.privateKey;
// export the account to keyStore string, which will make the privateKey encrpyted
const keyStoreFile = await myAccountWithMyPrivateKey.toFile(password);
// exported keyStoreFile
console.log({ keyStoreFile });
// see if the account is encrypted
console.log(`Is this account encrypted? \n ${myAccountWithMyPrivateKey.encrypted}`);
// keystore file should be equal to encrypted privateKey
console.log(
`Is privateKey equal to keyStore string? \n ${keyStoreFile ===
myAccountWithMyPrivateKey.privateKey}`,
);
}
encryptAndDecrypt(myStrongPassword);
// suppose we have keyStorefile, in this example, we just use same password and keystore string encrypted above
const someKeyStoreFile =
'{"version":3,"id":"38326265-6165-4961-a338-353063643962","address":"1cc87010760602a576455d6d2f03a3bf92d2c2ca","crypto":{"ciphertext":"a4ee9120b27ba66fb9d3fabd6372fa3a11060cf439a6a1777ced1e6253de8c29","cipherparams":{"iv":"c18772a882ac461fffd1971e9ec57861"},"cipher":"aes-128-ctr","kdf":"scrypt","kdfparams":{"salt":"da4efedeca407279be65e02fc94b7c4b7c74c3396447c71e659c74a73a5d9131","n":8192,"r":8,"p":1,"dklen":32},"mac":"547ee6616dcdf424273c113ceb00728ccdda17ff6449f2cb84a1a8352c87b4e6"}}';
async function importKeyStoreFileAndDecrypt(keyStoreFile, password) {
// import keyStore string and provide the password, remember to make a new Account first
const importedAccount = await Account.new().fromFile(keyStoreFile, password);
// the account should decypted which `Account.encrypted` is false
console.log(`Is this account encrypted? \n ${importedAccount.encrypted}`);
// see if the privatekey is equal to unencrypted one?
console.log(
`Is the account recovered from keystore? \n ${importedAccount.privateKey === myPrivateKey}`,
);
}
importKeyStoreFileAndDecrypt(someKeyStoreFile, myStrongPassword);

@ -1,14 +0,0 @@
{
"name": "example",
"version": "1.0.0",
"description": "",
"main": "test.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"@harmony-js/core": "^0.1.41"
}
}

@ -1,79 +0,0 @@
const { Harmony } = require('@harmony-js/core');
const { ChainID, ChainType } = require('@harmony-js/utils');
const {
StakingTransaction,
CreateValidator,
Delegate,
Undelegate,
CollectRewards,
StakingFactory,
} = require('@harmony-js/staking');
const harmony = new Harmony('http://localhost:9500', {
chainId: ChainID.HmyLocal,
chainType: ChainType.Harmony,
});
const stakingTxn = harmony.stakings
.createValidator({
validatorAddress: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
description: {
name: 'Alice',
identity: 'alice',
website: 'alice.harmony.one',
securityContact: 'Bob',
details: "Don't mess with me!!!",
},
commissionRate: {
rate: '0.1',
maxRate: '0.9',
maxChangeRate: '0.05',
},
minSelfDelegation: '0xa',
maxTotalDelegation: '0x0bb8',
slotPubKeys: [
'0xb9486167ab9087ab818dc4ce026edb5bf216863364c32e42df2af03c5ced1ad181e7d12f0e6dd5307a73b62247608611',
],
amount: '0x64',
})
.setTxParams({
nonce: '0x2',
gasPrice: '0x',
gasLimit: '0x64',
chainId: 0,
})
.build();
stakingTxn
.sendTransaction()
.then(([stakingTxn, res]) => {
console.log(res);
})
.catch((err) => {
console.log(err);
});
// const delegateMsg = Delegate({
// delegatorAddress: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
// validatorAddress: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
// amount: '0xa',
// });
// const stakingTxn = StakingTransaction({
// directive: '0x2',
// stakeMsg: delegateMsg,
// nonce: '0x2',
// gasPrice: '0x',
// gasLimit: '0x64',
// chainId: 0,
// from: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
// });
// stakingTxn
// .sendTransaction()
// .then((stakingTxn, res) => {
// console.log(res);
// })
// .catch((err) => {
// console.log(err);
// });

@ -1,172 +0,0 @@
const { Harmony } = require('@harmony-js/core');
const { ChainID, ChainType } = require('@harmony-js/utils');
const { Delegate, StakingTransaction, StakingFactory } = require('@harmony-js/staking'); //../packages/harmony-staking
const { TxStatus } = require('@harmony-js/transaction');
const LOCALNET = `http://localhost:9500`;
// 1. initialize the Harmony instance
const harmony = new Harmony(
// rpc url
LOCALNET,
{
// chainType set to Harmony
chainType: ChainType.Harmony,
// chainType set to HmyLocal
chainId: ChainID.HmyLocal,
},
);
// 2. get wallet ready
// one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65
// surge welcome lion goose gate consider taste injury health march debris kick
// add privateKey to wallet
const private = '63e35b761e9df0d50ddcdaa8e33c235b60c991bfed22925a12768b0c08ef822f';
// one1pdv9lrdwl0rg5vglh4xtyrv3wjk3wsqket7zxy
const sender = harmony.wallet.addByPrivateKey(private);
console.log(sender.address);
// const phrase =
// 'genius cable radar memory high catch blossom correct middle wish gentle
// fiscal';
// one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65
// surge welcome lion goose gate consider taste injury health march debris kick
// add privateKey to wallet
// const sender = harmony.wallet.addByMnemonic(phrase);
// let r =
// '0xf8f180f8a4940b585f8daefbc68a311fbd4cb20d9174ad174016f83885416c69636585616c69636591616c6963652e6861726d6f6e792e6f6e6583426f6295446f6e2774206d6573732077697468206d65212121ddc988016345785d8a0000c9880c7d713b49da0000c887b1a2bc2ec500000a820bb8f1b0b9486167ab9087ab818dc4ce026edb5bf216863364c32e42df2af03c5ced1ad181e7d12f0e6dd5307a73b6224760861164008080830927c028a064b1b835f5b70a72228920db24e44c0a57d954c1d3dcac3b33c79d9593f96191a05577fd05064a37043a33ff7febb67ab126a8e1f0b67c92b7cab793a87ddf2c82';
// const delegateMsg = new Delegate(
// 'one1pf75h0t4am90z8uv3y0dgunfqp4lj8wr3t5rsp', // from delegate command.
// 'one1pdv9lrdwl0rg5vglh4xtyrv3wjk3wsqket7zxy', // fd416cb87dcf8ed187e85545d7734a192fc8e976f5b540e9e21e896ec2bc25c3
// '0xde0b6b3a7640000', // 0x56BC75E2D63100000
// );
// // one12fuf7x9rgtdgqg7vgq0962c556m3p7afsxgvll;
// const stakingTxn = new StakingTransaction(
// '0x2',
// delegateMsg,
// '0x2',
// '0x',
// '0x0927c0',
// ChainID.HmyLocal,
// );
const stakingTxn = harmony.stakings
.delegate({
delegatorAddress: 'one1pf75h0t4am90z8uv3y0dgunfqp4lj8wr3t5rsp',
validatorAddress: 'one1pdv9lrdwl0rg5vglh4xtyrv3wjk3wsqket7zxy',
amount: '0xde0b6b3a7640000',
})
.setTxParams({ nonce: '0x2', gasPrice: '0x', gasLimit: '0x0927c0', chainId: ChainID.HmyLocal })
.build();
// 3. get sharding info
async function setSharding() {
// Harmony is a sharded blockchain, each endpoint have sharding structure,
// However sharding structure is different between mainnet, testnet and local
// testnet We need to get sharding info before doing cross-shard transaction
const res = await harmony.blockchain.getShardingStructure();
harmony.shardingStructures(res.result);
}
async function execute() {
await setSharding();
const signedTxn = await harmony.wallet.signStaking(stakingTxn);
signedTxn
.observed()
.on('transactionHash', (txnHash) => {
console.log('');
console.log('--- hash ---');
console.log('');
console.log(txnHash);
console.log('');
})
.on('receipt', (receipt) => {
console.log('');
console.log('--- receipt ---');
console.log('');
console.log(receipt);
console.log('');
})
.on('cxReceipt', (receipt) => {
console.log('');
console.log('--- cxReceipt ---');
console.log('');
console.log(receipt);
console.log('');
})
.on('error', (error) => {
console.log('');
console.log('--- error ---');
console.log('');
console.log(error);
console.log('');
});
// console.log(signedTxn);
const [sentTxn, txnHash] = await signedTxn.sendTransaction();
// signedTxn.sendTransaction()
// .then(res => {
// console.log(res);
// })
// .catch(err => {
// console.log(err);
// });
// to confirm the result if it is already there
// console.log(txnHash);
console.log(sentTxn);
const confiremdTxn = await sentTxn.confirm(txnHash);
// if the transactino is cross-shard transaction
if (confiremdTxn.isConfirmed()) {
console.log('--- Result ---');
console.log('');
console.log('Normal transaction');
console.log(`${txnHash} is confirmed`);
console.log('');
process.exit();
}
// if (confiremdTxn.isConfirmed() && confiremdTxn.isCxConfirmed()) {
// console.log('--- Result ---');
// console.log('');
// console.log('Cross-Shard transaction');
// console.log(`${txnHash} is confirmed`);
// console.log('');
// process.exit();
// }
}
execute();
// const delegateMsg = Delegate({
// delegatorAddress: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
// validatorAddress: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
// amount: '0xa',
// });
// const stakingTxn = StakingTransaction({
// directive: '0x2',
// stakeMsg: delegateMsg,
// nonce: '0x2',
// gasPrice: '0x',
// gasLimit: '0x64',
// chainId: 0,
// from: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
// });
// stakingTxn
// .sendTransaction()
// .then((stakingTxn, res) => {
// console.log(res);
// })
// .catch((err) => {
// console.log(err);
// });

@ -1,74 +0,0 @@
const { Harmony } = require('@harmony-js/core');
const { ChainID, ChainType } = require('@harmony-js/utils');
const { StakingFactory } = require('@harmony-js/staking');
const harmony = new Harmony('http://localhost:9500', {
chainId: ChainID.HmyLocal,
chainType: ChainType.Harmony,
});
const createMsg = {
validatorAddress: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
description: {
name: 'Alice',
identity: 'alice',
website: 'alice.harmony.one',
securityContact: 'Bob',
details: "Don't mess with me!!!",
},
commissionRate: {
rate: '0.1',
maxRate: '0.9',
maxChangeRate: '0.05',
},
minSelfDelegation: '0xa',
maxTotalDelegation: '0x0bb8',
slotPubKeys: [
'0xb9486167ab9087ab818dc4ce026edb5bf216863364c32e42df2af03c5ced1ad181e7d12f0e6dd5307a73b62247608611',
],
amount: '0x64',
};
const stakingTxn = harmony.stakings
.createValidator(createMsg)
.setTxParams({
nonce: '0x2',
gasPrice: '0x',
gasLimit: '0x64',
chainId: 0,
})
.build();
stakingTxn
.sendTransaction()
.then(([stakingTxn, res]) => {
console.log(res);
})
.catch((err) => {
console.log(err);
});
// const delegateMsg = Delegate({
// delegatorAddress: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
// validatorAddress: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
// amount: '0xa',
// });
// const stakingTxn = StakingTransaction({
// directive: '0x2',
// stakeMsg: delegateMsg,
// nonce: '0x2',
// gasPrice: '0x',
// gasLimit: '0x64',
// chainId: 0,
// from: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
// });
// stakingTxn
// .sendTransaction()
// .then((stakingTxn, res) => {
// console.log(res);
// })
// .catch((err) => {
// console.log(err);
// });

@ -1,177 +0,0 @@
const { Harmony } = require('@harmony-js/core');
const { ChainID, ChainType } = require('@harmony-js/utils');
const {
Description,
Decimal,
CommissionRate,
StakingTransaction,
CreateValidator,
} = require('@harmony-js/staking'); //../packages/harmony-staking
const { TxStatus } = require('@harmony-js/transaction');
const LOCALNET = `http://localhost:9500`;
// 1. initialize the Harmony instance
const harmony = new Harmony(
// rpc url
LOCALNET,
{
// chainType set to Harmony
chainType: ChainType.Harmony,
// chainType set to HmyLocal
chainId: ChainID.HmyLocal,
},
);
// 2. get wallet ready
// one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65
// surge welcome lion goose gate consider taste injury health march debris kick
// add privateKey to wallet
const private = 'fd416cb87dcf8ed187e85545d7734a192fc8e976f5b540e9e21e896ec2bc25c3';
const sender = harmony.wallet.addByPrivateKey(private);
// const phrase =
// 'genius cable radar memory high catch blossom correct middle wish gentle
// fiscal';
// one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65
// surge welcome lion goose gate consider taste injury health march debris kick
// add privateKey to wallet
// const sender = harmony.wallet.addByMnemonic(phrase);
const stakingTxn = harmony.stakings
.createValidator({
validatorAddress: 'one1pdv9lrdwl0rg5vglh4xtyrv3wjk3wsqket7zxy',
description: {
name: 'Alice',
identity: 'alice',
website: 'alice.harmony.one',
securityContact: 'Bob',
details: "Don't mess with me!!",
},
commissionRate: { rate: '0.1', maxRate: '0.9', maxChangeRate: '0.05' },
minSelfDelegation: '0x8AC7230489E80000',
maxTotalDelegation: '0xA2A15D09519BE00000',
slotPubKeys: [
'0xb9486167ab9087ab818dc4ce026edb5bf216863364c32e42df2af03c5ced1ad181e7d12f0e6dd5307a73b62247608611',
],
amount: '0x56BC75E2D63100000',
})
.setTxParams({
nonce: '0x2',
gasPrice: '0x',
gasLimit: '0x0927c0',
chainId: ChainID.HmyLocal,
})
.build();
// 3. get sharding info
async function setSharding() {
// Harmony is a sharded blockchain, each endpoint have sharding structure,
// However sharding structure is different between mainnet, testnet and local
// testnet We need to get sharding info before doing cross-shard transaction
const res = await harmony.blockchain.getShardingStructure();
harmony.shardingStructures(res.result);
}
async function execute() {
await setSharding();
const signedTxn = await harmony.wallet.signStaking(stakingTxn);
signedTxn
.observed()
.on('transactionHash', (txnHash) => {
console.log('');
console.log('--- hash ---');
console.log('');
console.log(txnHash);
console.log('');
})
.on('receipt', (receipt) => {
console.log('');
console.log('--- receipt ---');
console.log('');
console.log(receipt);
console.log('');
})
.on('cxReceipt', (receipt) => {
console.log('');
console.log('--- cxReceipt ---');
console.log('');
console.log(receipt);
console.log('');
})
.on('error', (error) => {
console.log('');
console.log('--- error ---');
console.log('');
console.log(error);
console.log('');
});
// console.log(signedTxn);
const [sentTxn, txnHash] = await signedTxn.sendTransaction();
// signedTxn
// .sendTransaction()
// .then((res) => {
// console.log(res);
// })
// .catch((err) => {
// console.log(err);
// });
// to confirm the result if it is already there
console.log(txnHash);
console.log(sentTxn);
const confiremdTxn = await sentTxn.confirm(txnHash);
// if the transactino is cross-shard transaction
// if (!confiremdTxn.isCrossShard()) {
if (confiremdTxn.isConfirmed()) {
console.log('--- Result ---');
console.log('');
console.log('Staking transaction');
console.log(`${txnHash} is confirmed`);
console.log('');
process.exit();
}
// }
// if (confiremdTxn.isConfirmed() && confiremdTxn.isCxConfirmed()) {
// console.log('--- Result ---');
// console.log('');
// console.log('Cross-Shard transaction');
// console.log(`${txnHash} is confirmed`);
// console.log('');
// process.exit();
// }
}
execute();
// const delegateMsg = Delegate({
// delegatorAddress: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
// validatorAddress: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
// amount: '0xa',
// });
// const stakingTxn = StakingTransaction({
// directive: '0x2',
// stakeMsg: delegateMsg,
// nonce: '0x2',
// gasPrice: '0x',
// gasLimit: '0x64',
// chainId: 0,
// from: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
// });
// stakingTxn
// .sendTransaction()
// .then((stakingTxn, res) => {
// console.log(res);
// })
// .catch((err) => {
// console.log(err);
// });

@ -1,173 +0,0 @@
const { Harmony } = require('@harmony-js/core');
const { ChainID, ChainType } = require('@harmony-js/utils');
const { Undelegate, StakingTransaction, StakingFactory } = require('@harmony-js/staking'); //../packages/harmony-staking
const { TxStatus } = require('@harmony-js/transaction');
const LOCALNET = `http://localhost:9500`;
// 1. initialize the Harmony instance
const harmony = new Harmony(
// rpc url
LOCALNET,
{
// chainType set to Harmony
chainType: ChainType.Harmony,
// chainType set to HmyLocal
chainId: ChainID.HmyLocal,
},
);
// 2. get wallet ready
// one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65
// surge welcome lion goose gate consider taste injury health march debris kick
// add privateKey to wallet
const private = '63e35b761e9df0d50ddcdaa8e33c235b60c991bfed22925a12768b0c08ef822f';
const sender = harmony.wallet.addByPrivateKey(private);
// const phrase =
// 'genius cable radar memory high catch blossom correct middle wish gentle
// fiscal';
// one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65
// surge welcome lion goose gate consider taste injury health march debris kick
// add privateKey to wallet
// const sender = harmony.wallet.addByMnemonic(phrase);
// let r =
// '0xf8f180f8a4940b585f8daefbc68a311fbd4cb20d9174ad174016f83885416c69636585616c69636591616c6963652e6861726d6f6e792e6f6e6583426f6295446f6e2774206d6573732077697468206d65212121ddc988016345785d8a0000c9880c7d713b49da0000c887b1a2bc2ec500000a820bb8f1b0b9486167ab9087ab818dc4ce026edb5bf216863364c32e42df2af03c5ced1ad181e7d12f0e6dd5307a73b6224760861164008080830927c028a064b1b835f5b70a72228920db24e44c0a57d954c1d3dcac3b33c79d9593f96191a05577fd05064a37043a33ff7febb67ab126a8e1f0b67c92b7cab793a87ddf2c82';
// const undelegateMsg = new Undelegate(
// 'one1pf75h0t4am90z8uv3y0dgunfqp4lj8wr3t5rsp', // signed should match this
// 'one1pdv9lrdwl0rg5vglh4xtyrv3wjk3wsqket7zxy',
// '0x16345785d8a0000',
// );
// const stakingTxn = new StakingTransaction(
// '0x3',
// undelegateMsg,
// '0x2',
// '0x',
// '0x0927c0',
// ChainID.HmyLocal,
// );
const stakingTxn = harmony.stakings
.undelegate({
delegatorAddress: 'one1pf75h0t4am90z8uv3y0dgunfqp4lj8wr3t5rsp',
validatorAddress: 'one1pdv9lrdwl0rg5vglh4xtyrv3wjk3wsqket7zxy',
amount: '0x16345785d8a0000',
})
.setTxParams({
nonce: '0x2',
gasPrice: '0x',
gasLimit: '0x0927c0',
chainId: ChainID.HmyLocal,
})
.build();
// 3. get sharding info
async function setSharding() {
// Harmony is a sharded blockchain, each endpoint have sharding structure,
// However sharding structure is different between mainnet, testnet and local
// testnet We need to get sharding info before doing cross-shard transaction
const res = await harmony.blockchain.getShardingStructure();
harmony.shardingStructures(res.result);
}
async function execute() {
await setSharding();
const signedTxn = await harmony.wallet.signStaking(stakingTxn);
signedTxn
.observed()
.on('transactionHash', (txnHash) => {
console.log('');
console.log('--- hash ---');
console.log('');
console.log(txnHash);
console.log('');
})
.on('receipt', (receipt) => {
console.log('');
console.log('--- receipt ---');
console.log('');
console.log(receipt);
console.log('');
})
.on('cxReceipt', (receipt) => {
console.log('');
console.log('--- cxReceipt ---');
console.log('');
console.log(receipt);
console.log('');
})
.on('error', (error) => {
console.log('');
console.log('--- error ---');
console.log('');
console.log(error);
console.log('');
});
// console.log(signedTxn);
const [sentTxn, txnHash] = await signedTxn.sendTransaction();
// signedTxn.sendTransaction()
// .then(res => {
// console.log(res);
// })
// .catch(err => {
// console.log(err);
// });
// to confirm the result if it is already there
// console.log(txnHash);
console.log(sentTxn);
const confiremdTxn = await sentTxn.confirm(txnHash);
// if the transactino is cross-shard transaction
if (confiremdTxn.isConfirmed()) {
console.log('--- Result ---');
console.log('');
console.log('Normal transaction');
console.log(`${txnHash} is confirmed`);
console.log('');
process.exit();
}
// if (confiremdTxn.isConfirmed() && confiremdTxn.isCxConfirmed()) {
// console.log('--- Result ---');
// console.log('');
// console.log('Cross-Shard transaction');
// console.log(`${txnHash} is confirmed`);
// console.log('');
// process.exit();
// }
}
execute();
// const delegateMsg = Delegate({
// delegatorAddress: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
// validatorAddress: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
// amount: '0xa',
// });
// const stakingTxn = StakingTransaction({
// directive: '0x2',
// stakeMsg: delegateMsg,
// nonce: '0x2',
// gasPrice: '0x',
// gasLimit: '0x64',
// chainId: 0,
// from: 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9',
// });
// stakingTxn
// .sendTransaction()
// .then((stakingTxn, res) => {
// console.log(res);
// })
// .catch((err) => {
// console.log(err);
// });

@ -1,31 +0,0 @@
const { Harmony } = require('@harmony-js/core');
const { ChainID, ChainType } = require('@harmony-js/utils');
const { encryptPhrase, decryptPhrase } = require('@harmony-js/crypto');
const harmony = new Harmony('http://localhost:9500', { chainId: 2, chainType: 'hmy' });
const myPhrase = harmony.wallet.newMnemonic();
const pwd = '1234';
async function encryptThePhrase(phrase, pass) {
const result = await encryptPhrase(phrase, pass);
return result;
}
async function decryptThePhrase(keystore, pass) {
const result = await decryptPhrase(keystore, pass);
return result;
}
async function phraseKeyStore() {
const keyStore = await encryptThePhrase(myPhrase, pwd);
const recoveredPhrase = await decryptThePhrase(JSON.parse(keyStore), pwd);
return { myPhrase, keyStore, recoveredPhrase };
}
phraseKeyStore().then((result) => {
const { myPhrase, keyStore, recoveredPhrase } = result;
harmony.wallet.addByMnemonic(myPhrase);
console.log({ myPhrase, keyStore, recoveredPhrase });
console.log(harmony.wallet);
});

@ -1,40 +0,0 @@
const { Harmony } = require('@harmony-js/core');
const { ChainID, ChainType } = require('@harmony-js/utils');
const {
randomBytes,
generatePrivateKey,
getAddress,
getAddressFromPrivateKey,
encryptPhrase,
decryptPhrase,
} = require('@harmony-js/crypto');
const harmony = new Harmony('http://localhost:9500', { chainId: 2, chainType: 'hmy' });
const myPhrase = harmony.wallet.newMnemonic();
const pwd = '1234';
async function encryptThePhrase(phrase, pass) {
const result = await encryptPhrase(phrase, pass);
return result;
}
async function decryptThePhrase(keystore, pass) {
const result = await decryptPhrase(keystore, pass);
return result;
}
async function phraseKeyStore() {
const keyStore = await encryptThePhrase(myPhrase, pwd);
const recoveredPhrase = await decryptThePhrase(JSON.parse(keyStore), pwd);
return { myPhrase, keyStore, recoveredPhrase };
}
phraseKeyStore().then((result) => {
const { myPhrase, keyStore, recoveredPhrase } = result;
const anotherPhrase = 'wall public vague under poem acid jaguar describe net scene sponsor neck';
harmony.wallet.addByMnemonic(myPhrase);
harmony.wallet.addByMnemonic(anotherPhrase);
console.log({ myPhrase, keyStore, recoveredPhrase });
console.log(harmony.wallet);
});

@ -1,153 +0,0 @@
// import or require Harmony class
const { Harmony } = require('@harmony-js/core');
// import or require settings
const { ChainID, ChainType } = require('@harmony-js/utils');
const URL_TESTNET = `https://api.s0.b.hmny.io`;
const URL_MAINNET = `https://api.s0.t.hmny.io`;
const URL_PANGAEA = 'https://api.s0.pga.hmny.io';
// 1. initialize the Harmony instance
const harmony = new Harmony(
// rpc url
URL_PANGAEA,
{
// chainType set to Harmony
chainType: ChainType.Harmony,
// chainType set to HmyLocal
chainId: ChainID.HmyPangaea,
},
);
// 2. get wallet ready
// one18n8e7472pg5fqvcfcr5hg0npquha24wsxmjheg
const phrase = 'genius cable radar memory high catch blossom correct middle wish gentle fiscal';
// const phrase =
// 'resemble rent deposit unique garment ripple burst negative else decorate menu theme';
// one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65
// surge welcome lion goose gate consider taste injury health march debris kick
// add privateKey to wallet
const privateKey = '63e35b761e9df0d50ddcdaa8e33c235b60c991bfed22925a12768b0c08ef822f';
const sender = harmony.wallet.addByMnemonic(phrase);
const sender2 = harmony.wallet.addByPrivateKey(privateKey);
harmony.wallet.setSigner(sender2.address);
console.log('sender2Address is : ', sender2.bech32Address);
// 3. get sharding info
async function setSharding() {
// Harmony is a sharded blockchain, each endpoint have sharding structure,
// However sharding structure is different between mainnet, testnet and local testnet
// We need to get sharding info before doing cross-shard transaction
const res = await harmony.blockchain.getShardingStructure();
harmony.shardingStructures(res.result);
}
// 4. get transaction payload ready
async function transfer(receiver) {
// run set sharding first, if you want to make a cross-shard transaction
await setSharding();
//1e18
const txn = harmony.transactions.newTx({
// token send to
to: receiver,
// amount to send
value: '100000000',
// gas limit, you can use string
gasLimit: '210000',
// send token from shardID
shardID: 0,
// send token to toShardID
toShardID: 1,
// gas Price, you can use Unit class, and use Gwei, then remember to use toWei(), which will be transformed to BN
gasPrice: new harmony.utils.Unit('10').asGwei().toWei(),
});
// sign the transaction use wallet;
// This will happen at the chrome extension.
const signedTxn = await harmony.wallet.signTransaction(txn);
// Now you can use `Transaction.observed()` to listen events
// Frontend received back the signedTxn and do the followings to Send transaction.
signedTxn
.observed()
.on('transactionHash', (txnHash) => {
console.log('');
console.log('--- hash ---');
console.log('');
console.log(txnHash);
console.log('');
})
.on('receipt', (receipt) => {
console.log('');
console.log('--- receipt ---');
console.log('');
console.log(receipt);
console.log('');
})
.on('cxReceipt', (receipt) => {
console.log('');
console.log('--- cxReceipt ---');
console.log('');
console.log(receipt);
console.log('');
})
.on('error', (error) => {
console.log('');
console.log('--- error ---');
console.log('');
console.log(error);
console.log('');
});
// send the txn, get [Transaction, transactionHash] as result
const [sentTxn, txnHash] = await signedTxn.sendTransaction();
// to confirm the result if it is already there
const confiremdTxn = await sentTxn.confirm(txnHash);
// if the transactino is cross-shard transaction
if (!confiremdTxn.isCrossShard()) {
if (confiremdTxn.isConfirmed()) {
console.log('--- Result ---');
console.log('');
console.log('Normal transaction');
console.log(`${txnHash} is confirmed`);
console.log('');
console.log('please see detail in explorer:');
console.log('');
console.log('https://explorer.harmony.one/#/tx/' + txnHash);
console.log('');
process.exit();
}
}
if (confiremdTxn.isConfirmed() && confiremdTxn.isCxConfirmed()) {
console.log('--- Result ---');
console.log('');
console.log('Cross-Shard transaction');
console.log(`${txnHash} is confirmed`);
console.log('');
console.log('please see detail in explorer:');
console.log('');
console.log('https://explorer.harmony.one/#/tx/' + txnHash);
console.log('');
process.exit();
}
}
// sending from one18n8e7472pg5fqvcfcr5hg0npquha24wsxmjheg to one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65
(async () => await transfer('one1pf75h0t4am90z8uv3y0dgunfqp4lj8wr3t5rsp'))();

@ -1,151 +0,0 @@
// import or require Harmony class
const { Harmony } = require('@harmony-js/core');
// import or require settings
const { ChainID, ChainType } = require('@harmony-js/utils');
// const URL_TESTNET = `https://api.s0.pga.hmny.io`;
const URL_MAINNET = `https://api.s0.t.hmny.io`;
// const LOCAL_TESTNET = `http://localhost:9500`;
const DEVNET = 'https://api.s0.pga.hmny.io';
// 1. initialize the Harmony instance
const harmony = new Harmony(
// rpc url
DEVNET,
{
// chainType set to Harmony
chainType: ChainType.Harmony,
// chainType set to HmyLocal
chainId: ChainID.HmyPangaea,
},
);
// 2. get wallet ready
// one18n8e7472pg5fqvcfcr5hg0npquha24wsxmjheg;
const phrase = 'genius cable radar memory high catch blossom correct middle wish gentle fiscal';
// one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65
// surge welcome lion goose gate consider taste injury health march debris kick
// add privateKey to wallet
// const sender = harmony.wallet.addByMnemonic(phrase);
// add privateKey to wallet
const private = '63e35b761e9df0d50ddcdaa8e33c235b60c991bfed22925a12768b0c08ef822f';
// one1pdv9lrdwl0rg5vglh4xtyrv3wjk3wsqket7zxy
const sender = harmony.wallet.addByPrivateKey(private);
// const sender = harmony.wallet.addByPrivateKey(
// 'fd416cb87dcf8ed187e85545d7734a192fc8e976f5b540e9e21e896ec2bc25c3',
// );
// 3. get sharding info
async function setSharding() {
// Harmony is a sharded blockchain, each endpoint have sharding structure,
// However sharding structure is different between mainnet, testnet and local testnet
// We need to get sharding info before doing cross-shard transaction
const res = await harmony.blockchain.getShardingStructure();
harmony.shardingStructures(res.result);
}
// 4. get transaction payload ready
async function transfer(receiver) {
// run set sharding first, if you want to make a cross-shard transaction
await setSharding();
//1e18
const txn = harmony.transactions.newTx({
// token send to
to: receiver,
// amount to send
value: '100000000000000000',
// gas limit, you can use string
gasLimit: '210000',
// send token from shardID
shardID: 0,
// send token to toShardID
toShardID: 0,
// gas Price, you can use Unit class, and use Gwei, then remember to use toWei(), which will be transformed to BN
gasPrice: new harmony.utils.Unit('100').asGwei().toWei(),
});
// sign the transaction use wallet;
// This will happen at the chrome extension.
const signedTxn = await harmony.wallet.signTransaction(txn);
// Now you can use `Transaction.observed()` to listen events
// Frontend received back the signedTxn and do the followings to Send transaction.
signedTxn
.observed()
.on('transactionHash', (txnHash) => {
console.log('');
console.log('--- hash ---');
console.log('');
console.log(txnHash);
console.log('');
})
.on('receipt', (receipt) => {
console.log('');
console.log('--- receipt ---');
console.log('');
console.log(receipt);
console.log('');
})
.on('cxReceipt', (receipt) => {
console.log('');
console.log('--- cxReceipt ---');
console.log('');
console.log(receipt);
console.log('');
})
.on('error', (error) => {
console.log('');
console.log('--- error ---');
console.log('');
console.log(error);
console.log('');
});
// send the txn, get [Transaction, transactionHash] as result
const [sentTxn, txnHash] = await signedTxn.sendTransaction();
// to confirm the result if it is already there
const confiremdTxn = await sentTxn.confirm(txnHash);
// if the transactino is cross-shard transaction
// if (!confiremdTxn.isCrossShard()) {
if (confiremdTxn.isConfirmed()) {
console.log('--- Result ---');
console.log('');
console.log('Normal transaction');
console.log(`${txnHash} is confirmed`);
console.log('');
console.log('please see detail in explorer:');
console.log('');
console.log('https://explorer.harmony.one/#/tx/' + txnHash);
console.log('');
process.exit();
}
// }
if (confiremdTxn.isConfirmed() && confiremdTxn.isCxConfirmed()) {
console.log('--- Result ---');
console.log('');
console.log('Cross-Shard transaction');
console.log(`${txnHash} is confirmed`);
console.log('');
console.log('please see detail in explorer:');
console.log('');
console.log('https://explorer.harmony.one/#/tx/' + txnHash);
console.log('');
process.exit();
}
}
// sending from one18n8e7472pg5fqvcfcr5hg0npquha24wsxmjheg to one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65
(async () => await transfer('one1pdv9lrdwl0rg5vglh4xtyrv3wjk3wsqket7zxy'))();

@ -1,137 +0,0 @@
// import or require Harmony class
const { Harmony } = require('@harmony-js/core');
// import or require settings
const { ChainID, ChainType } = require('@harmony-js/utils');
//const URL_TESTNET = `https://api.s0.b.hmny.io`;
const URL_TESTNET = `localhost:9500`;
const URL_MAINNET = `https://api.s0.t.hmny.io`;
// 1. initialize the Harmony instance
const harmony = new Harmony(
// rpc url
URL_TESTNET,
{
// chainType set to Harmony
chainType: ChainType.Harmony,
// chainType set to HmyLocal
chainId: ChainID.HmyTestnet,
},
);
// 2. get wallet ready
// one18n8e7472pg5fqvcfcr5hg0npquha24wsxmjheg
//const phrase = 'genius cable radar memory high catch blossom correct middle wish gentle fiscal';
// one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65
// surge welcome lion goose gate consider taste injury health march debris kick
// add privateKey to wallet
//const sender = harmony.wallet.addByMnemonic(phrase);
// add privateKey to wallet
const private = 'fd416cb87dcf8ed187e85545d7734a192fc8e976f5b540e9e21e896ec2bc25c3';
const sender = harmony.wallet.addByPrivateKey(private);
// 3. get sharding info
async function setSharding() {
// Harmony is a sharded blockchain, each endpoint have sharding structure,
// However sharding structure is different between mainnet, testnet and local testnet
// We need to get sharding info before doing cross-shard transaction
const res = await harmony.blockchain.getShardingStructure();
harmony.shardingStructures(res.result);
}
// 4. get transaction payload ready
async function transfer(receiver) {
// run set sharding first, if you want to make a cross-shard transaction
await setSharding();
//1e18
const txn = harmony.transactions.newTx({
// token send to
to: receiver,
// amount to send
value: '100000000000000000',
// gas limit, you can use string
gasLimit: '210000',
// send token from shardID
shardID: 0,
// send token to toShardID
toShardID: 0,
// gas Price, you can use Unit class, and use Gwei, then remember to use toWei(), which will be transformed to BN
gasPrice: new harmony.utils.Unit('100').asGwei().toWei(),
});
// sign the transaction use wallet;
// This will happen at the chrome extension.
const signedTxn = await harmony.wallet.signTransaction(txn);
// Now you can use `Transaction.observed()` to listen events
// Frontend received back the signedTxn and do the followings to Send transaction.
signedTxn
.observed()
.on('transactionHash', (txnHash) => {
console.log('');
console.log('--- hash ---');
console.log('');
console.log(txnHash);
console.log('');
})
.on('receipt', (receipt) => {
console.log('');
console.log('--- receipt ---');
console.log('');
console.log(receipt);
console.log('');
})
.on('cxReceipt', (receipt) => {
console.log('');
console.log('--- cxReceipt ---');
console.log('');
console.log(receipt);
console.log('');
})
.on('error', (error) => {
console.log('');
console.log('--- error ---');
console.log('');
console.log(error);
console.log('');
});
// send the txn, get [Transaction, transactionHash] as result
const [sentTxn, txnHash] = await signedTxn.sendTransaction();
// to confirm the result if it is already there
const confiremdTxn = await sentTxn.confirm(txnHash);
// if the transactino is cross-shard transaction
if (!confiremdTxn.isCrossShard()) {
if (confiremdTxn.isConfirmed()) {
console.log('--- Result ---');
console.log('');
console.log('Normal transaction');
console.log(`${txnHash} is confirmed`);
console.log('');
process.exit();
}
}
if (confiremdTxn.isConfirmed() && confiremdTxn.isCxConfirmed()) {
console.log('--- Result ---');
console.log('');
console.log('Cross-Shard transaction');
console.log(`${txnHash} is confirmed`);
console.log('');
process.exit();
}
}
// sending from one18n8e7472pg5fqvcfcr5hg0npquha24wsxmjheg to one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65
transfer('one1a2rhuaqjcvfu69met9sque2l3w5v9z6qcdcz65');

@ -4,14 +4,14 @@ const fs = require('fs');
const path = require('path');
const packages = [
'harmony-core',
'harmony-crypto',
'harmony-account',
'harmony-network',
'harmony-contract',
'harmony-utils',
'harmony-transaction',
'harmony-staking',
'woop-core',
'woop-crypto',
'woop-account',
'woop-network',
'woop-contract',
'woop-utils',
'woop-transaction',
'woop-staking',
];
task('cleanBrowser', async () => {

@ -2,5 +2,5 @@
"packages": ["packages/*"],
"npmClient": "yarn",
"useWorkspaces": true,
"version": "0.1.53"
"version": "0.1.58"
}

1081
log.txt

File diff suppressed because it is too large Load Diff

44661
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -1,5 +1,5 @@
{
"description": "Root repository for the harmony-sdk-core",
"description": "Root repository for the woop-sdk-core",
"private": true,
"license": "MIT",
"workspaces": [
@ -89,14 +89,14 @@
"dotenv": "^6.0.0",
"fancy-log": "^1.3.2",
"fbjs-scripts": "^0.8.3",
"ganache-cli": "^6.4.3",
"ganache-cli": "^6.12.1",
"glob": "^7.1.3",
"glob-parent": "^3.1.0",
"gulp": "^4.0.0",
"gulp-typedoc": "^2.2.2",
"husky": "^1.1.2",
"jest": "^23.4.2",
"jest-fetch-mock": "^1.6.6",
"jest-fetch-mock": "^3.0.3",
"jest-json-schema": "^2.0.1",
"jest-watch-typeahead": "^0.2.0",
"jsdoc": "^3.6.3",
@ -107,7 +107,7 @@
"pretty-quick": "^1.8.0",
"protobufjs": "^6.8.8",
"rimraf": "^2.6.2",
"rollup": "^0.66.6",
"rollup": "1.26.3",
"rollup-plugin-alias": "^1.4.0",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-commonjs": "^9.2.0",
@ -117,19 +117,19 @@
"rollup-plugin-node-builtins": "^2.1.2",
"rollup-plugin-node-globals": "^1.4.0",
"rollup-plugin-node-resolve": "^3.4.0",
"rollup-plugin-typescript2": "^0.17.1",
"rollup-plugin-typescript2": "^0.29.0",
"solc": "^0.5.8",
"terser-webpack-plugin": "^2.1.2",
"ts-jest": "^23.1.3",
"ts-node": "^7.0.1",
"tslib": "^1.11.1",
"tslib": "^2.4.0",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0",
"typedoc": "^0.17.0-3",
"typedoc-plugin-external-module-name": "^3.0.0",
"typedoc-plugin-no-inherit": "^1.1.10",
"typescript": "^3.8.3",
"typescript-json-schema": "^0.36.0",
"typescript-json-schema": "^0.43.0",
"webpack": "^4.20.2",
"webpack-command": "^0.4.1",
"webpack-node-externals": "^1.7.2",
@ -140,10 +140,10 @@
"pre-commit": "pretty-quick --staged"
}
},
"name": "harmony-sdk-core",
"name": "woop-sdk-core",
"dependencies": {
"@harmony-js/core": "^0.1.36",
"tslib": "^1.10.0",
"@woop-js/core": "^0.1.36",
"tslib": "^2.4.0",
"typedoc-plugin-internal-external": "^2.1.1"
}
}

@ -1,10 +1,12 @@
# Packages available are:
1. [@harmony-js/core](https://github.com/harmony-one/sdk/tree/master/packages/harmony-core)
2. [@harmony-js/account](https://github.com/harmony-one/sdk/tree/master/packages/harmony-account)
3. [@harmony-js/crypto](https://github.com/harmony-one/sdk/tree/master/packages/harmony-crypto)
4. [@harmony-js/network](https://github.com/harmony-one/sdk/tree/master/packages/harmony-network)
5. [@harmony-js/utils](https://github.com/harmony-one/sdk/tree/master/packages/harmony-utils)
6. [@harmony-js/transaction](https://github.com/harmony-one/sdk/tree/master/packages/harmony-transaction)
7. [@harmony-js/contract](https://github.com/harmony-one/sdk/tree/master/packages/harmony-contract)
8. [@harmony-js/staking](https://github.com/harmony-one/sdk/tree/master/packages/harmony-staking)
1. [@woop-js/core](https://github.com/woop-chain/sdk/tree/master/packages/woop-core)
2. [@woop-js/account](https://github.com/woop-chain/sdk/tree/master/packages/woop-account)
3. [@woop-js/crypto](https://github.com/woop-chain/sdk/tree/master/packages/woop-crypto)
4. [@woop-js/network](https://github.com/woop-chain/sdk/tree/master/packages/woop-network)
5. [@woop-js/utils](https://github.com/woop-chain/sdk/tree/master/packages/woop-utils)
6. [@woop-js/transaction](https://github.com/woop-chain/sdk/tree/master/packages/woop-transaction)
7. [@woop-js/contract](https://github.com/woop-chain/sdk/tree/master/packages/woop-contract)
8. [@woop-js/staking](https://github.com/woop-chain/sdk/tree/master/packages/woop-staking)
<mark>Package level documentation and examples are inside each package</mark>

@ -1,274 +0,0 @@
/**
## About This Package
`@harmony-js/account` is dealing with account related features.
Developers can use this package to:
- Create `Account` instance
- Create `Wallet` instance
- Sign `Transaction`
- Convert address format
- Manage `privateKey` or `mnemonic phrases` and do the `encrypt` and `decrypt` job
There are 2 main classes in this package, `Account` and `Wallet`.
- The `Account` class is basic instance that contains most features mentioned above.
- The `Wallet` class is class that stores all `Account` instance, you can do CRUD on it.
## Usage of Account
### Dependencies
- @harmony-js/network
- @harmony-js/staking
- @harmony-js/transaction
- @harmony-js/utils
### Examples
Create a random account
```javascript
// import the Account class
import {Account} from '@harmony-js/account'
// Messenger is optional, by default, we have a defaultMessenger
// If you like to change, you will import related package here.
import { HttpProvider, Messenger } from '@harmony-js/network';
import { ChainType, ChainID } from '@harmony-js/utils';
// create a custom messenger
const customMessenger = new Messenger(
new HttpProvider('http://localhost:9500'),
ChainType.Harmony, // if you are connected to Harmony's blockchain
ChainID.HmyLocal, // check if the chainId is correct
)
// to create an Account with random privateKey
// and you can setMessenger later
const randomAccount = new Account()
randomAccount.setMessenger(customMessenger)
// or you can set messenger on `new`
const randomAccountWithCustomMessenger = new Account(undefined, customMessenger)
// you can display the account
console.log({randomAccount,randomAccountWithCustomMessenger})
// or you can use static method to create an Account
const staticCreatedAccount = Account.new()
// but you have to set messenger manually after
staticCreatedAccount.setMessenger(customMessenger)
console.log({staticCreatedAccount})
```
### Import an existing privateKey to create Account
```typescript
// import the Account class
import {Account} from '@harmony-js/account'
// NOTED: Key with or without `0x` are accepted, makes no different
// NOTED: DO NOT import `mnemonic phrase` using `Account` class, use `Wallet` instead
const myPrivateKey = '0xe19d05c5452598e24caad4a0d85a49146f7be089515c905ae6a19e8a578a6930'
const myAccountWithMyPrivateKey = new Account(myPrivateKey)
// you can also import privateKey use static method
const myAccountWithMyPrivateKeyUsingStatic = Account.add(myPrivateKey)
console.log({ myAccountWithMyPrivateKey, myAccountWithMyPrivateKeyUsingStatic })
```
### Encrypt/Export keyStore file, Decrypt/Import keyStore file
```typescript
// import the Account class
import {Account} from '@harmony-js/account'
// suppose we have an account
const myPrivateKey = '0xe19d05c5452598e24caad4a0d85a49146f7be089515c905ae6a19e8a578a6930'
const myAccountWithMyPrivateKey = new Account(myPrivateKey)
// suppose we have a password, and we want to encrypt the account above
const myStrongPassword = '123'
async function encryptAndDecrypt(password) {
// we get the privateKey before encrypted as comparison
const unencryptedPrivateKey = myAccountWithMyPrivateKey.privateKey
// export the account to keyStore string, which will make the privateKey encrpyted
const keyStoreFile = await myAccountWithMyPrivateKey.toFile(password)
// exported keyStoreFile
console.log({ keyStoreFile })
// see if the account is encrypted
console.log(`Is this account encrypted? \n ${myAccountWithMyPrivateKey.encrypted}`)
// keystore file should be equal to encrypted privateKey
console.log(
`Is privateKey equal to keyStore string? \n ${keyStoreFile ===
myAccountWithMyPrivateKey.privateKey}`,
)
}
encryptAndDecrypt(myStrongPassword)
// suppose we have keyStorefile, in this example, we just use same password and keystore string encrypted above
const someKeyStoreFile =
'{"version":3,"id":"62326332-3139-4839-b534-656134623066","address":"1fe3da351d9fc0c4f02de5412ad7def8aee956c5","Crypto":{"ciphertext":"b86ab81682c9f5a35738ad9bd38cd9b46c1b852ef33f16dd83068f79e20d5531","cipherparams":{"iv":"44efb5a514f34968e92cafad80566487"},"cipher":"aes-128-ctr","kdf":"scrypt","kdfparams":{"salt":"d70ae1f311601562113f98c8ebe382f52a332dca1588886e5ea91e2f8a647134","n":8192,"r":8,"p":1,"dklen":32},"mac":"7b63e4e31a75a22b7091291bb58302655b738539ef3e30b30a7a7f170f6163ef"}}'
async function importKeyStoreFileAndDecrypt(keyStoreFile, password) {
// import keyStore string and provide the password, remember to make a new Account first
const importedAccount = await Account.new().fromFile(keyStoreFile, password)
// the account should decypted which `Account.encrypted` is false
console.log(`Is this account encrypted? \n ${importedAccount.encrypted}`)
// see if the privatekey is equal to unencrypted one?
console.log(
`Is the account recovered from keystore? \n ${importedAccount.privateKey === myPrivateKey}`,
)
}
importKeyStoreFileAndDecrypt(someKeyStoreFile, myStrongPassword)
```
### Address format getter
```typescript
// import the Account class
import {Account} from '@harmony-js/account'
// suppose we have an account
const myPrivateKey = '0xe19d05c5452598e24caad4a0d85a49146f7be089515c905ae6a19e8a578a6930'
const myAccountWithMyPrivateKey = new Account(myPrivateKey)
// Account.address is bytes20/base16 address
console.log(myAccountWithMyPrivateKey.address)
// Account.bech32Address is bech32 format address, in Harmony, it's `one1` prefixed
console.log(myAccountWithMyPrivateKey.bech32Address)
// Account.bech32TestNetAddress is bech32 format address, in Harmony, it's `tone1` prefixed, used in testnet
console.log(myAccountWithMyPrivateKey.bech32TestNetAddress)
// Account.checksumAddress is checksumed address from base16
console.log(myAccountWithMyPrivateKey.checksumAddress)
```
### Sign a transaction
```typescript
// import the Account class
import {Account} from '@harmony-js/account'
// import Transaction class from '@harmony-js/transaction'
import {Transaction} from '@harmony-js/transaction'
// Messenger is optional, by default, we have a defaultMessenger
// If you like to change, you will import related package here.
import { HttpProvider, Messenger } from '@harmony-js/network';
import { ChainType, ChainID, Unit } from '@harmony-js/utils';
// create a custom messenger
const customMessenger = new Messenger(
new HttpProvider('http://localhost:9500'),
ChainType.Harmony, // if you are connected to Harmony's blockchain
ChainID.HmyLocal, // check if the chainId is correct
)
// suppose we have an account
const myPrivateKey = '0xe19d05c5452598e24caad4a0d85a49146f7be089515c905ae6a19e8a578a6930'
const myAccountWithMyPrivateKey = new Account(myPrivateKey)
const txnObject = {
// token send to
to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2',
// amount to send
value: '1000000000000000000000',
// gas limit, you can use string or use BN value
gasLimit: '210000',
// send token from shardID
shardID: 0,
// send token to toShardID
toShardID: 0,
// gas Price, you can use Unit class, and use Gwei, then remember to use toWei(), which will be transformed to BN
gasPrice: new Unit('100').asGwei().toWei(),
// if you set nonce manually here, and remember, the `updateNonce` of `Account.signTransaction` should be set to false
nonce: 0,
};
const txn = new Transaction(txnObject, customMessenger);
async function signTheTxn() {
// Account.signTransaction(transaction: Transaction, updateNonce?: boolean, encodeMode?: string, blockNumber?: string): Promise<Transaction>
// If the 2nd parameter `updateNonce` is set to true, it will query and update account's nonce before it signs
const signedTxn = await myAccountWithMyPrivateKey.signTransaction(txn, false, 'rlp', 'latest');
// see if the transaction is signed
console.log(`\n see if transaction is signed: \n ${signedTxn.isSigned()} \n`);
// get the tranaction bytes
console.log(`\n the signed bytes is: \n ${signedTxn.getRawTransaction()} \n`);
return signTheTxn;
}
signTheTxn();
```
## Usage of Wallet
### Dependencies
- @harmony-js/crypto
- @harmony-js/network
- @harmony-js/staking
- @harmony-js/transaction
- @harmony-js/utils
```typescript
// constructor
const { Wallet } = require('@harmony-js/account');
const wallet = new Wallet(customMessenger);
// get signer
const wallet = new Wallet(customMessenger);
const key_1 = '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e';
console.log(wallet.addByPrivateKey(key_1));
console.log(wallet.signer)
// createAccount
console.log(wallet.accounts);
wallet.createAccount();
wallet.createAccount();
console.log(wallet.accounts);
// encryptAccount
const key_1 = '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e';
wallet.addByPrivateKey(key_1);
wallet.encryptAccount('one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7', '12345').then((value) => {
console.log(value);
})
// decrptAccount
const key_1 = '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e';
wallet.addByPrivateKey(key_1);
wallet.encryptAccount('one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7', '12345').then(() => {
wallet.decryptAccount('one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7', '12345').then((value) => {
console.log(value);
})
});
```
*
* @packageDocumentation
* @module harmony-account
*/
/**@ignore */
export interface README {}

@ -1,14 +0,0 @@
/**
* @packageDocumentation
* @module harmony-account
* @hidden
*/
import { HttpProvider, Messenger } from '@harmony-js/network';
import { ChainType, ChainID } from '@harmony-js/utils';
export const defaultMessenger = new Messenger(
new HttpProvider('http://localhost:9500'),
ChainType.Harmony,
ChainID.HmyLocal,
);

@ -1,30 +0,0 @@
{
"name": "@harmony-js/core",
"version": "0.1.53",
"description": "harmony core package",
"main": "dist/index.js",
"node": "dist/index.js",
"browser": "dist/index.js",
"module": "dist/index.esm.js",
"jsnext:main": "dist/index.esm.js",
"typings": "dist/index.d.ts",
"types": "dist/index.d.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"publishConfig": {
"access": "public"
},
"author": "neeboo@firestack.one",
"license": "MIT",
"dependencies": {
"@harmony-js/account": "0.1.53",
"@harmony-js/contract": "0.1.53",
"@harmony-js/crypto": "0.1.48",
"@harmony-js/network": "0.1.51",
"@harmony-js/staking": "0.1.51",
"@harmony-js/transaction": "0.1.51",
"@harmony-js/utils": "0.1.48"
},
"gitHead": "56606e9365721729a490c27d6a294e0daf90fbdf"
}

@ -1,31 +0,0 @@
/**
* @packageDocumentation
* @module harmony-core
* @hidden
*/
import { HttpProvider, Messenger } from '@harmony-js/network';
import { TransactionFactory, Transaction } from '@harmony-js/transaction';
import { Wallet, Account } from '@harmony-js/account';
import { ChainType, ChainID } from '@harmony-js/utils';
import { Blockchain } from './blockchain';
export interface HarmonyModule {
HttpProvider: HttpProvider;
Messenger: Messenger;
Blockchain: Blockchain;
TransactionFactory: TransactionFactory;
Wallet: Wallet;
Transaction: Transaction;
Account: Account;
}
export const enum UrlType {
http,
ws,
}
export interface HarmonySetting<T extends ChainType, I extends ChainID> {
type: T;
id: I;
}

@ -1,16 +0,0 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "dist"
},
"include": ["src", "../../typings/**/*.d.ts", "../harmony-utils/src/core.ts"],
"references": [
{"path": "../harmony-account"},
{"path": "../harmony-crypto"},
{"path": "../harmony-utils"},
{"path": "../harmony-network"},
{"path": "../harmony-transaction"},
{"path": "../harmony-contract"}
]
}

@ -1,126 +0,0 @@
/**
* ## About this package
*
* `@harmony-js/network` provides functions to handle messenger, providers and subscriptions...
*
* ## How to use this package
*
* ### 1. Create a Message
* ```javascript
* const { HttpProvider, Messenger } = require('@harmony-js/network');
* const { ChainType, ChainID } = require('@harmony-js/utils');
*
* // create a custom messenger
* const customMessenger = new Messenger(
* new HttpProvider('http://localhost:9500'),
* ChainType.Harmony, // if you are connected to Harmony's blockchain
* ChainID.HmyLocal, // check if the chainId is correct
* )
* ```
*
* @packageDocumentation
* @module harmony-network
*/
/**@ignore */
export const enum RPCMethod {
// 1. hmy_getBlockByHash
GetBlockByHash = 'hmy_getBlockByHash',
// 2. hmy_getBlockByNumber
GetBlockByNumber = 'hmy_getBlockByNumber',
// 3. hmy_getBlockTransactionCountByHash
GetBlockTransactionCountByHash = 'hmy_getBlockTransactionCountByHash',
// 4. hmy_getBlockTransactionCountByNumber
GetBlockTransactionCountByNumber = 'hmy_getBlockTransactionCountByNumber',
// 5. hmy_getCode
GetCode = 'hmy_getCode',
// 6. hmy_getTransactionByBlockHashAndIndex
GetTransactionByBlockHashAndIndex = 'hmy_getTransactionByBlockHashAndIndex',
// 7. hmy_getTransactionByBlockNumberAndIndex
GetTransactionByBlockNumberAndIndex = 'hmy_getTransactionByBlockNumberAndIndex',
// 8. hmy_getTransactionByHash
GetTransactionByHash = 'hmy_getTransactionByHash',
GetTransactionReceipt = 'hmy_getTransactionReceipt',
GetCXReceiptByHash = 'hmy_getCXReceiptByHash',
// 9. hmy_syncing
Syncing = 'hmy_syncing',
// 10. net_peerCount
PeerCount = 'net_peerCount',
// 11. hmy_getBalance
GetBalance = 'hmy_getBalance',
// 12. hmy_getStorageAt
GetStorageAt = 'hmy_getStorageAt',
// 13. hmy_getTransactionCount
GetTransactionCount = 'hmy_getTransactionCount',
// 14. hmy_sendTransaction
SendTransaction = 'hmy_sendTransaction',
// 15. hmy_sendRawTransaction
SendRawTransaction = 'hmy_sendRawTransaction',
// 16. hmy_subscribe
Subscribe = 'hmy_subscribe',
// 17. hmy_getlogs
GetPastLogs = 'hmy_getLogs',
// 18. hmy_getWork
GetWork = 'hmy_getWork',
// 19. hmy_submitWork
// SubmitWork = 'hmy_submitWork',
// 20. hmy_getProof
GetProof = 'hmy_getProof',
// 21, hmy_getFilterChanges
GetFilterChanges = 'hmy_getFilterChanges',
// 22. hmy_newPendingTransactionFilter
NewPendingTransactionFilter = 'hmy_newPendingTransactionFilter',
// 23. hmy_newBlockFilter
NewBlockFilter = 'hmy_newBlockFilter',
// 24. hmy_newFilter
NewFilter = 'hmy_newFilter',
// 25. hmy_call
Call = 'hmy_call',
// 26. hmy_estimateGas
EstimateGas = 'hmy_estimateGas',
// 27. hmy_gasPrice
GasPrice = 'hmy_gasPrice',
// 28. hmy_blockNumber
BlockNumber = 'hmy_blockNumber',
// 29. hmy_unsubscribe
UnSubscribe = 'hmy_unsubscribe',
// 30. net_version
NetVersion = 'net_version',
// 31. hmy_protocolVersion
ProtocolVersion = 'hmy_protocolVersion',
// 32. hmy_getShardingStructure
GetShardingStructure = 'hmy_getShardingStructure',
// 33. hmy_sendRawStakingTransaction
SendRawStakingTransaction = 'hmy_sendRawStakingTransaction',
}
/**@ignore */
export const enum RPCErrorCode {
// Standard JSON-RPC 2.0 errors
// RPC_INVALID_REQUEST is internally mapped to HTTP_BAD_REQUEST (400).
// It should not be used for application-layer errors.
RPC_INVALID_REQUEST = -32600,
// RPC_METHOD_NOT_FOUND is internally mapped to HTTP_NOT_FOUND (404).
// It should not be used for application-layer errors.
RPC_METHOD_NOT_FOUND = -32601,
RPC_INVALID_PARAMS = -32602,
// RPC_INTERNAL_ERROR should only be used for genuine errors in bitcoind
// (for example datadir corruption).
RPC_INTERNAL_ERROR = -32603,
RPC_PARSE_ERROR = -32700,
// General application defined errors
RPC_MISC_ERROR = -1, // std::exception thrown in command handling
RPC_TYPE_ERROR = -3, // Unexpected type was passed as parameter
RPC_INVALID_ADDRESS_OR_KEY = -5, // Invalid address or key
RPC_INVALID_PARAMETER = -8, // Invalid, missing or duplicate parameter
RPC_DATABASE_ERROR = -20, // Database error
RPC_DESERIALIZATION_ERROR = -22, // Error parsing or validating structure in raw format
RPC_VERIFY_ERROR = -25, // General error during transaction or block submission
RPC_VERIFY_REJECTED = -26, // Transaction or block was rejected by network rules
RPC_IN_WARMUP = -28, // Client still warming up
RPC_METHOD_DEPRECATED = -32, // RPC method is deprecated
}

@ -1,135 +0,0 @@
/**
* ## About this package
*
* `@harmony-js/transaction` provides the functions to build transactions
*
* Develop can use this package to:
* - build a transaction offline!
* - set params of transaction
* -
*
* ## How to use this package
* ### Step 1: create a Harmony Instance
* ```javascript
* const { Harmony } = require('@harmony-js/core');
* const { ChainID, ChainType } = require('@harmony-js/utils');
* const { BN } = require('@harmony-js/crypto');
*
* const hmy = new Harmony(
* 'http://localhost:9500',
* {
* chainType: ChainType.Harmony,
* chainId: ChainID.HmyLocal,
* },
* );
* ```
*
* ### Step 2: build a transaction
* ```javascript
* const txn = hmy.transactions.newTx({
* to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2',
* value: '10000',
* gasLimit: '210000',
* shardID: 0,
* toShardID: 0,
* gasPrice: new hmy.utils.Unit('100').asGwei().toWei(),
* });
* ```
*
* ## some important information
* Transaction Parameters
* ```java
* // interface TxParams
* id: string;
* from: string;
* to: string;
* nonce: number | string;
* gasLimit: number | string | BN;
* gasPrice: number | string | BN;
* shardID: number | string;
* toShardID: number | string;
* data: string;
* value: number | string | BN;
* chainId: number;
* rawTransaction: string;
* unsignedRawTransaction: string;
* signature: Signature;
* receipt?: TransasctionReceipt;
* ```
*
* Transaction Receipt
* ```java
* // interface TransasctionReceipt
* transactionHash: string;
* transactionIndex: string;
* blockHash: string;
* blockNumber: string; // 11
* from: string;
* to: string;
* gasUsed: string;
* cumulativeGasUsed: string; // 13244
* contractAddress?: string | null; // or null, if none was created
* logs: any[];
* logsBloom: string; // 256 byte bloom filter
* v: string;
* r: string;
* s: string;
* responseType?: string;
* byzantium?: boolean;
* status?: string; // post Byzantium will return `0x0` or `0x1`
* root?: string; // pre Byzantium will return `root`
* ```
*
* @packageDocumentation
* @module harmony-transaction
*/
import { BN, Signature } from '@harmony-js/crypto';
export interface TxParams {
id: string;
from: string;
to: string;
nonce: number | string;
gasLimit: number | string | BN;
gasPrice: number | string | BN;
shardID: number | string;
toShardID: number | string;
data: string;
value: number | string | BN;
chainId: number;
rawTransaction: string;
unsignedRawTransaction: string;
signature: Signature;
receipt?: TransasctionReceipt;
}
export const enum TxStatus {
NONE = 'NONE',
INTIALIZED = 'INITIALIZED',
SIGNED = 'SIGNED',
PENDING = 'PENDING',
CONFIRMED = 'CONFIRMED',
REJECTED = 'REJECTED',
}
export interface TransasctionReceipt {
transactionHash: string;
transactionIndex: string;
blockHash: string;
blockNumber: string; // 11
from: string;
to: string;
gasUsed: string;
cumulativeGasUsed: string; // 13244
contractAddress?: string | null; // or null, if none was created
logs: any[];
logsBloom: string; // 256 byte bloom filter
v: string;
r: string;
s: string;
responseType?: string;
byzantium?: boolean;
status?: string; // post Byzantium will return `0x0` or `0x1`
root?: string; // pre Byzantium will return `root`
}

@ -1,203 +0,0 @@
/**
* ## About this package
*
* `@harmony-js/util` provides utility functions for Harmony dapps and other `harmony-js` packages
*
* Develop can use this package to:
* - Transform the unit of token (fromWei, toWei...)
* - Convert variable to different type (hexToBN, numberToHex...)
* - Check validators information (isAddress, isPublicKey, isBlockNumber...)
*
* ## How to use this package
*
* ### Step 1: create a Harmony Instance
* ```javascript
* const { Harmony } = require('@harmony-js/core');
* const { ChainID, ChainType } = require('@harmony-js/utils');
* const { BN } = require('@harmony-js/crypto');
*
* const hmy = new Harmony(
* 'http://localhost:9500',
* {
* chainType: ChainType.Harmony,
* chainId: ChainID.HmyLocal,
* },
* );
* ```
*
* ### Step 2: Select and call functions
* Here are some examples:
*
* ```javascript
* // numberToString
* const num = 123;
* const str = hmy.utils.numberToString(num)
* console.log(str);
*
* // add0xToString
* const str = '12345';
* const expected = hmy.utils.add0xToString(str)
* console.log(expected);
*
* // fromWei
* const Wei = new BN('1000000000000000000');
* const expected = hmy.utils.fromWei(Wei, hmy.utils.Units.one);
* console.log(expected);
*
* // toWei
* const one = new BN('1');
* const expected = hmy.utils.toWei(one, hmy.utils.Units.one);
* const num = hmy.utils.numToStr(expected);
* console.log(num);
* ```
*
* ### Step 3: Using unit class to convet the token unit
* ```javascript
* // convert one to Gwei
* const one = new hmy.utils.Unit('1').asOne();
* const oneToGwei = one.toGwei();
* console.log(oneToGwei);
* ```
*
* ## Some Important consts and Enums
* ### Chain Type
* ```javascript
* Harmony = 'hmy',
* Ethereum = 'eth',
* ```
*
* ### Chain ID
* ```javascript
* Default = 0,
EthMainnet = 1,
Morden = 2,
Ropsten = 3,
Rinkeby = 4,
RootstockMainnet = 30,
RootstockTestnet = 31,
Kovan = 42,
EtcMainnet = 61,
EtcTestnet = 62,
Geth = 1337,
Ganache = 0,
HmyMainnet = 1,
HmyTestnet = 2,
HmyLocal = 2,
HmyPangaea = 3,
* ```
*
* ### Default Config
* ```javascript
* export const defaultConfig = {
* Default: {
* Chain_ID: ChainID.HmyLocal,
* Chain_Type: ChainType.Harmony,
* Chain_URL: 'http://localhost:9500',
* Network_ID: 'Local',
* },
* DefaultWS: {
* Chain_ID: ChainID.HmyLocal,
* Chain_Type: ChainType.Harmony,
* Chain_URL: 'ws://localhost:9800',
* Network_ID: 'LocalWS',
* },
* };
* ```
*
* ### Unit Map
* ```
* [Units.wei, '1'], // 1 wei
* [Units.Kwei, '1000'], // 1e3 wei
* [Units.Mwei, '1000000'], // 1e6 wei
* [Units.Gwei, '1000000000'], // 1e9 wei
* [Units.szabo, '1000000000000'], // 1e12 wei
* [Units.finney, '1000000000000000'], // 1e15 wei
* [Units.ether, '1000000000000000000'], // 1e18 wei
* [Units.one, '1000000000000000000'], // 1e18 wei
* [Units.Kether, '1000000000000000000000'], // 1e21 wei
* [Units.Mether, '1000000000000000000000000'], // 1e24 wei
* [Units.Gether, '1000000000000000000000000000'], // 1e27 wei
* [Units.Tether, '1000000000000000000000000000000'], // 1e30 wei
* ```
*
* @packageDocumentation
* @module harmony-utils
*/
export const enum ChainType {
Harmony = 'hmy',
Ethereum = 'eth',
}
export const enum ChainID {
Default = 0,
EthMainnet = 1,
Morden = 2,
Ropsten = 3,
Rinkeby = 4,
RootstockMainnet = 30,
RootstockTestnet = 31,
Kovan = 42,
EtcMainnet = 61,
EtcTestnet = 62,
Geth = 1337,
Ganache = 0,
HmyMainnet = 1,
HmyTestnet = 2,
HmyLocal = 2,
HmyPangaea = 3,
}
/** @hidden */
export const defaultConfig = {
Default: {
Chain_ID: ChainID.HmyLocal,
Chain_Type: ChainType.Harmony,
Chain_URL: 'http://localhost:9500',
Network_ID: 'Local',
},
DefaultWS: {
Chain_ID: ChainID.HmyLocal,
Chain_Type: ChainType.Harmony,
Chain_URL: 'ws://localhost:9800',
Network_ID: 'LocalWS',
},
};
/** @hidden */
export abstract class HarmonyCore {
chainType: ChainType;
chainId: ChainID;
constructor(chainType: ChainType, chainId: ChainID = defaultConfig.Default.Chain_ID) {
this.chainType = chainType;
this.chainId = chainId;
}
get chainPrefix(): string {
switch (this.chainType) {
case ChainType.Ethereum: {
return 'eth';
}
case ChainType.Harmony: {
return 'hmy';
}
default: {
return 'hmy';
}
}
}
get getChainId(): ChainID {
return this.chainId;
}
public setChainId(chainId: ChainID) {
this.chainId = chainId;
}
public setChainType(chainType: ChainType) {
this.chainType = chainType;
}
}
/** @hidden */
export const HDPath = `m/44'/1023'/0'/0/`;
/** @hidden */
export const AddressSuffix = '-';

@ -1,11 +1,11 @@
# @harmony-js/account
# @woop-js/account
This package provides a collection of apis to create accounts and wallets and sign using them. A wallet can hold multiple accounts and account is associated with a unique `one` address. This package also provides facilies to manage account keys.
## Installation
```
npm install @harmony-js/account
npm install @woop-js/account
```
## Usage
@ -28,8 +28,8 @@ const account = new Account(
'45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e',
new Messenger(
new HttpProvider('https://api.s0.b.hmny.io'),
ChainType.Harmony,
ChainID.HmyTestnet,
ChainType.Woop,
ChainID.WikiTestnet,
),
);
```
@ -40,8 +40,8 @@ Creating account and setting custom messenger
const account = new Account();
const customMessenger = new Messenger(
new HttpProvider('https://api.s0.b.hmny.io'),
ChainType.Harmony,
ChainID.HmyTestnet,
ChainType.Woop,
ChainID.WikiTestnet,
);
account.setMessenger(customMessenger);
@ -72,8 +72,8 @@ const account = new Account(
'45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e',
new Messenger(
new HttpProvider('https://api.s0.b.hmny.io'),
ChainType.Harmony,
ChainID.HmyTestnet,
ChainType.Woop,
ChainID.WikiTestnet,
),
);
account.getBalance().then(response => {
@ -88,12 +88,12 @@ const account = new Account(
'45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e',
new Messenger(
new HttpProvider('https://api.s0.b.hmny.io'),
ChainType.Harmony,
ChainID.HmyTestnet,
ChainType.Woop,
ChainID.WikiTestnet,
),
);
const { TransactionFactory } = require('@harmony-js/transaction');
const { Unit } = require('@harmony-js/utils');
const { TransactionFactory } = require('@woop-js/transaction');
const { Unit } = require('@woop-js/utils');
const factory = new TransactionFactory();
const txn = factory.newTx({
@ -120,7 +120,7 @@ A wallet represents user wallet that can hold one or more user accounts.
Creating an empty wallet
```javascript
const { Wallet } = require('@harmony-js/account')
const { Wallet } = require('@woop-js/account')
const wallet = new Wallet();
```
@ -129,8 +129,8 @@ Setting a messenger to be used to send wallet transactions
wallet.setMessenger(
new Messenger(
new HttpProvider('https://api.s0.b.hmny.io'),
ChainType.Harmony,
ChainID.HmyTestnet,
ChainType.Woop,
ChainID.WikiTestnet,
),
);
```
@ -140,8 +140,8 @@ Create an empty wallet with messenger
const wallet = new Wallet(
new Messenger(
new HttpProvider('https://api.s0.b.hmny.io'),
ChainType.Harmony,
ChainID.HmyTestnet,
ChainType.Woop,
ChainID.WikiTestnet,
),
);
```
@ -168,7 +168,7 @@ wallet.addByKeyStore(keystore, passphrase).then(account => {
Creating a new account using passphrase
```javascript
const passphrase = 'harmony-one';
const passphrase = 'woop-chain';
wallet.createAccount(passphrase).then(account => {
console.log(account.bech32Address);
});

@ -0,0 +1,218 @@
/**
# @woop-js/account
This package provides a collection of apis to create accounts and wallets and sign using them. A wallet can hold multiple accounts and account is associated with a unique `one` address. This package also provides facilies to manage account keys.
## Installation
```
npm install @woop-js/account
```
## Usage
Creating new account and display hex and bech32 (one) addresses
```javascript
const account = new Account(); // or const account = Account.new()
console.log(account.checksumAddress);
console.log(account.bech32Address);
```
Creating new account using private key
```javascript
const account = Account.add('45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e');
```
Creating account using private key and custom messenger
```javascript
* const account = new Account(
* '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e',
* new Messenger(
* new HttpProvider('https://api.s0.b.hmny.io'),
* ChainType.Woop,
* ChainID.WikiTestnet,
* ),
* );
```
Creating account and setting custom messenger
```javascript
// uses by default http://localhost:9500 as messenger
* const account = new Account();
* const customMessenger = new Messenger(
* new HttpProvider('https://api.s0.b.hmny.io'),
* ChainType.Woop,
* ChainID.WikiTestnet,
* );
account.setMessenger(customMessenger);
```
Storing the account data to keystore file
```javascript
* const passphrase = '';
* const account = new Account('45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e');
* account.toFile(passphrase).then(keystore => {
* console.log(keystore);
* });
```
Fetching account from keystore file
```javascript
* const passphrase = '';
* const keystore = '{"version":3,"id":"33363566-3564-4264-a638-363531666335","address":"7c41e0668b551f4f902cfaec05b5bdca68b124ce","crypto":{"ciphertext":"9b09380afb742838b32d9afc0ec1a3df35dbd7a41e3a160d08c07a4d0e79b855","cipherparams":{"iv":"1cd0e0522260eef055b9170f4825f4a0"},"cipher":"aes-128-ctr","kdf":"scrypt","kdfparams":{"salt":"bf35e36c45cccefcef73a4c900f41c682c94c28630d94d2d1f764760d245f30b","n":8192,"r":8,"p":1,"dklen":32},"mac":"25b4442972356bea02af57eba3b87803086d90b5e7657a57b528b89b1aa25f2f"}}';
* const account = new Account();
* account.fromFile(keystore, passphrase).then(account => {
* console.log(account.bech32Address);
* });
```
Get the account balance
```javascript
* const account = new Account(
* '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e',
* new Messenger(
* new HttpProvider('https://api.s0.b.hmny.io'),
* ChainType.Woop,
* ChainID.WikiTestnet,
* ),
* );
* account.getBalance().then(response => {
* console.log(response);
* });
```
outputs `{ balance: '9126943763247054940484', nonce: 45, shardID: 0 }`
Create a transaction and account, and sign it
```javascript
* const account = new Account(
* '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e',
* new Messenger(
* new HttpProvider('https://api.s0.b.hmny.io'),
* ChainType.Woop,
* ChainID.WikiTestnet,
* ),
* );
* const { TransactionFactory } = require('@woop-js/transaction');
* const { Unit } = require('@woop-js/utils');
* const factory = new TransactionFactory();
* const txn = factory.newTx({
* to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2',
* value: new Unit(1).asOne().toWei(),
* // gas limit, you can use string
* gasLimit: '21000',
* // send token from shardID
* shardID: 0,
* // send token to toShardID
* toShardID: 0,
* // gas Price, you can use Unit class, and use Gwei, then remember to use toWei(), which will be transformed to BN
* gasPrice: new Unit('1').asGwei().toWei(),
* });
* account.signTransaction(txn).then((signedTxn) => {
* console.log(signedTxn);
* });
```
Similarily staking transactions can be created and signed using account.
A wallet represents user wallet that can hold one or more user accounts.
Creating an empty wallet
```javascript
* const { Wallet } = require('@woop-js/account')
* const wallet = new Wallet();
```
Setting a messenger to be used to send wallet transactions
```javascript
* wallet.setMessenger(
* new Messenger(
* new HttpProvider('https://api.s0.b.hmny.io'),
* ChainType.Woop,
* ChainID.WikiTestnet,
* ),
* );
```
Create an empty wallet with messenger
```javascript
* const wallet = new Wallet(
* new Messenger(
* new HttpProvider('https://api.s0.b.hmny.io'),
* ChainType.Woop,
* ChainID.WikiTestnet,
* ),
* );
```
An account could be added to a wallet using different ways. Adding account using mnemonics
```javascript
const mnemonics = 'horse distance dry brother pretty manual chicken mushroom town swim prize clutch';
const account = wallet.addByMnemonic(mnemonics);
```
Adding account using private key
```javascript
const account = wallet.addByPrivateKey('0x676cd9773dd23a4c1d7f22767c61c7b6723cc6be37b078545f6e0e91433a23dd')
```
Adding account using keystore file
```javascript
* const keystore = '{"version":3,"id":"33363566-3564-4264-a638-363531666335","address":"7c41e0668b551f4f902cfaec05b5bdca68b124ce","crypto":{"ciphertext":"9b09380afb742838b32d9afc0ec1a3df35dbd7a41e3a160d08c07a4d0e79b855","cipherparams":{"iv":"1cd0e0522260eef055b9170f4825f4a0"},"cipher":"aes-128-ctr","kdf":"scrypt","kdfparams":{"salt":"bf35e36c45cccefcef73a4c900f41c682c94c28630d94d2d1f764760d245f30b","n":8192,"r":8,"p":1,"dklen":32},"mac":"25b4442972356bea02af57eba3b87803086d90b5e7657a57b528b89b1aa25f2f"}}';
* const passphrase = '';
* wallet.addByKeyStore(keystore, passphrase).then(account => {
* console.log(account.bech32Address);
* });
```
Creating a new account using passphrase
```javascript
* const passphrase = 'woop-chain';
* wallet.createAccount(passphrase).then(account => {
* console.log(account.bech32Address);
* });
```
Get all accounts in the wallet
```javascript
* wallet.accounts.forEach(addr => {
* const account = wallet.getAccount(addr);
* console.log(account.bech32Address);
* });
```
Set wallet signer when multiple accounts exists in the wallet
```javascript
wallet.setSigner(signerAddr);
```
Sign transaction using wallet, will sign the transaction using the wallet signer
```javascript
* const txn = factory.newTx({
* to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2',
* value: new Unit(1).asOne().toWei(),
* // gas limit, you can use string
* gasLimit: '21000',
* // send token from shardID
* shardID: 0,
* // send token to toShardID
* toShardID: 0,
* // gas Price, you can use Unit class, and use Gwei, then remember to use toWei(), which will be transformed to BN
* gasPrice: new Unit('1').asGwei().toWei(),
* });
* wallet.signTransaction(txn).then((signedTxn) => {
* console.log(signedTxn);
* });
```
Similarily staking transactions can be signed using `signStaking` api.
*
* @packageDocumentation
* @module woop-account
*/
/**@ignore */
export interface README {}

@ -0,0 +1,29 @@
{
"name": "@woop-js/account",
"version": "0.1.58",
"description": "account and wallet for woop",
"main": "dist/index.js",
"node": "dist/index.js",
"browser": "dist/index.js",
"module": "dist/index.esm.js",
"jsnext:main": "dist/index.esm.js",
"typings": "dist/index.d.ts",
"types": "dist/index.d.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"publishConfig": {
"access": "public"
},
"author": "neeboo@firestack.one",
"license": "MIT",
"dependencies": {
"@woop-js/core": "0.1.58",
"@woop-js/crypto": "0.1.58",
"@woop-js/network": "0.1.58",
"@woop-js/staking": "0.1.58",
"@woop-js/transaction": "0.1.58",
"@woop-js/utils": "0.1.58"
},
"gitHead": "56606e9365721729a490c27d6a294e0daf90fbdf"
}

@ -1,6 +1,6 @@
/**
* @packageDocumentation
* @module harmony-account
* @module woop-account
*
*/
@ -15,7 +15,7 @@ import {
Keystore,
Signature,
getAddress,
} from '@harmony-js/crypto';
} from '@woop-js/crypto';
import {
isPrivateKey,
@ -23,10 +23,10 @@ import {
hexToNumber,
AddressSuffix,
ChainType,
} from '@harmony-js/utils';
import { Transaction, RLPSign } from '@harmony-js/transaction';
import { StakingTransaction } from '@harmony-js/staking';
import { Messenger, RPCMethod } from '@harmony-js/network';
} from '@woop-js/utils';
import { Transaction, RLPSign } from '@woop-js/transaction';
import { StakingTransaction } from '@woop-js/staking';
import { Messenger, RPCMethod } from '@woop-js/network';
import { Shards } from './types';
import { defaultMessenger } from './utils';
@ -141,18 +141,18 @@ class Account {
* @example
* ```javascript
* // import the Account class
* const { Account } = require('@harmony-js/account');
* const { Account } = require('@woop-js/account');
*
* // Messenger is optional, by default, we have a defaultMessenger
* // If you like to change, you will import related package here.
* const { HttpProvider, Messenger } = require('@harmony-js/network');
* const { ChainType, ChainID } = require('@harmony-js/utils');
* const { HttpProvider, Messenger } = require('@woop-js/network');
* const { ChainType, ChainID } = require('@woop-js/utils');
*
* // create a custom messenger
* const customMessenger = new Messenger(
* new HttpProvider('http://localhost:9500'),
* ChainType.Harmony, // if you are connected to Harmony's blockchain
* ChainID.HmyLocal, // check if the chainId is correct
* ChainType.Woop, // if you are connected to Woop's blockchain
* ChainID.WikiLocal, // check if the chainId is correct
* )
*
* // setMessenger later
@ -299,30 +299,18 @@ class Account {
if (updateNonce) {
// await this.updateBalances(blockNumber);
const txShardID = transaction.txParams.shardID;
const shardBalanceObject = await this.getShardBalance(
const shardNonce = await this.getShardNonce(
typeof txShardID === 'string' ? Number.parseInt(txShardID, 10) : txShardID,
blockNumber,
);
if (shardBalanceObject !== undefined) {
const shardNonce = shardBalanceObject.nonce;
transaction.setParams({
...transaction.txParams,
from:
this.messenger.chainPrefix === ChainType.Harmony
? this.bech32Address
: this.checksumAddress || '0x',
nonce: shardNonce,
});
} else {
transaction.setParams({
...transaction.txParams,
from:
this.messenger.chainPrefix === ChainType.Harmony
? this.bech32Address
: this.checksumAddress || '0x',
nonce: 0,
});
}
transaction.setParams({
...transaction.txParams,
from:
this.messenger.chainPrefix === ChainType.Woop
? this.bech32Address
: this.checksumAddress || '0x',
nonce: shardNonce,
});
}
if (encodeMode === 'rlp') {
@ -336,7 +324,7 @@ class Account {
signature,
rawTransaction,
from:
this.messenger.chainPrefix === ChainType.Harmony
this.messenger.chainPrefix === ChainType.Woop
? this.bech32Address
: this.checksumAddress || '0x',
};
@ -370,27 +358,16 @@ class Account {
if (updateNonce) {
// await this.updateBalances(blockNumber);
const txShardID = shardID;
const shardBalanceObject = await this.getShardBalance(
const shardNonce = await this.getShardNonce(
typeof txShardID === 'string' ? Number.parseInt(txShardID, 10) : txShardID,
blockNumber,
);
if (shardBalanceObject !== undefined) {
const shardNonce = shardBalanceObject.nonce;
staking.setFromAddress(
this.messenger.chainPrefix === ChainType.Harmony
? this.bech32Address
: this.checksumAddress || '0x',
);
staking.setNonce(shardNonce);
} else {
staking.setFromAddress(
this.messenger.chainPrefix === ChainType.Harmony
? this.bech32Address
: this.checksumAddress || '0x',
);
staking.setNonce(0);
}
staking.setFromAddress(
this.messenger.chainPrefix === ChainType.Woop
? this.bech32Address
: this.checksumAddress || '0x',
);
staking.setNonce(shardNonce);
}
if (encodeMode === 'rlp') {
@ -398,7 +375,7 @@ class Account {
staking.setRawTransaction(rawTransaction);
staking.setSignature(signature);
staking.setFromAddress(
this.messenger.chainPrefix === ChainType.Harmony
this.messenger.chainPrefix === ChainType.Woop
? this.bech32Address
: this.checksumAddress || '0x',
);
@ -418,8 +395,8 @@ class Account {
* // create a custom messenger
* const customMessenger = new Messenger(
* new HttpProvider('http://localhost:9500'),
* ChainType.Harmony, // if you are connected to Harmony's blockchain
* ChainID.HmyLocal, // check if the chainId is correct
* ChainType.Woop, // if you are connected to Woop's blockchain
* ChainID.WikiLocal, // check if the chainId is correct
* )
*
* // to create an Account with random privateKey
@ -510,6 +487,32 @@ class Account {
};
}
/**
* Get the specific shard's nonce
*
* @param shardID `shardID` is binding with the endpoint, IGNORE it!
* @param blockNumber by default, it's `latest`
*
* @example
* ```
* account.getShardNonce().then((value) => {
* console.log(value);
* });
* ```
*/
async getShardNonce(shardID: number, blockNumber: string = 'latest') {
const nonce = await this.messenger.send(
RPCMethod.GetAccountNonce,
[this.address, blockNumber],
this.messenger.chainPrefix,
shardID,
);
if (nonce.isError()) {
throw nonce.error.message;
}
return nonce.result;
}
/**
* @function _new private method create Account
* @return {Account} Account instance

@ -1,9 +1,9 @@
/**
* @packageDocumentation
* @module harmony-account
* @module woop-account
*/
import { bip39, hdkey, getAddress, BN, Signature } from '@harmony-js/crypto';
import { bip39, hdkey, getAddress, BN, Signature } from '@woop-js/crypto';
import {
HDPath,
// defineReadOnly,
@ -14,9 +14,9 @@ import {
Unit,
isHex,
hexToNumber,
} from '@harmony-js/utils';
import { Messenger, HttpProvider, WSProvider } from '@harmony-js/network';
import { Transaction, TxStatus, TransasctionReceipt } from '@harmony-js/transaction';
} from '@woop-js/utils';
import { Messenger, HttpProvider, WSProvider, RPCMethod } from '@woop-js/network';
import { Transaction, TxStatus, TransasctionReceipt } from '@woop-js/transaction';
import { Account } from './account';
/** @hidden */
@ -81,7 +81,7 @@ export class HDNode {
index: number = 0,
addressCount: number = 1,
shardID: number = 0,
chainType: ChainType = ChainType.Harmony,
chainType: ChainType = ChainType.Woop,
chainId: ChainID = ChainID.Default,
gasLimit = '1000000',
gasPrice = '2000000000',
@ -93,10 +93,12 @@ export class HDNode {
this.hdwallet = undefined;
this.addresses = [];
this.wallets = {};
this.path = chainType === ChainType.Harmony ? HDPath : `m/44'/60'/0'/0/`;
this.path = chainType === ChainType.Woop ? HDPath : `m/44'/60'/0'/0/`;
this.index = index;
this.addressCount = addressCount;
this.getHdWallet(menmonic || HDNode.generateMnemonic());
if (menmonic !== null && menmonic !== '') {
this.getHdWallet(menmonic || HDNode.generateMnemonic());
}
this.gasLimit = gasLimit;
this.gasPrice = gasPrice;
}
@ -151,6 +153,7 @@ export class HDNode {
}
return this.addresses;
}
// tslint:disable-next-line: ban-types
getPrivateKey(address: string, cb?: Function) {
if (!cb) {
@ -166,13 +169,14 @@ export class HDNode {
cb(null, this.wallets[address].privateKey);
}
}
// tslint:disable-next-line: ban-types
async signTransaction(txParams: any | Web3TxPrams) {
const from: string = txParams.from ? getAddress(txParams.from).checksum : '0x';
const accountNonce = await this.messenger.send(
'hmy_getTransactionCount',
RPCMethod.GetAccountNonce,
[from, 'latest'],
'hmy',
'wiki',
this.shardID,
);
@ -211,7 +215,7 @@ export class HDNode {
const nonce =
txParams.nonce !== undefined && isHex(txParams.nonce)
? Number.parseInt(hexToNumber(txParams.nonce), 10)
: Number.parseInt(hexToNumber(accountNonce.result), 10);
: accountNonce.result;
const data = txParams.data !== undefined && isHex(txParams.data) ? txParams.data : '0x';
const prv = this.wallets[from].privateKey;
@ -238,6 +242,7 @@ export class HDNode {
return signed.getRawTransaction();
}
getAddress(idx?: number) {
if (!idx) {
return this.addresses[0];
@ -245,9 +250,11 @@ export class HDNode {
return this.addresses[idx];
}
}
getAddresses() {
return this.addresses;
}
addByPrivateKey(privateKey: string) {
const account = new Account(privateKey);
const addr = account.checksumAddress;
@ -258,7 +265,7 @@ export class HDNode {
setSigner(address: string) {
const foundIndex = this.addresses.findIndex((value) => value === address);
this.addresses.slice(foundIndex, foundIndex + 1);
this.addresses.splice(foundIndex, 1);
this.addresses.unshift(address);
}
}

@ -1,6 +1,6 @@
/**
* @packageDocumentation
* @module harmony-account
* @module woop-account
* @ignore
*/

@ -1,6 +1,6 @@
/**
* @packageDocumentation
* @module harmony-account
* @module woop-account
* @hidden
*/

@ -0,0 +1,14 @@
/**
* @packageDocumentation
* @module woop-account
* @hidden
*/
import { HttpProvider, Messenger } from '@woop-js/network';
import { ChainType, ChainID } from '@woop-js/utils';
export const defaultMessenger = new Messenger(
new HttpProvider('http://localhost:9500'),
ChainType.Woop,
ChainID.WikiLocal,
);

@ -1,13 +1,13 @@
/**
* @packageDocumentation
* @module harmony-account
* @module woop-account
*/
import { bip39, hdkey, EncryptOptions, getAddress, generatePrivateKey } from '@harmony-js/crypto';
import { Messenger } from '@harmony-js/network';
import { isPrivateKey, isAddress, ChainType } from '@harmony-js/utils';
import { Transaction } from '@harmony-js/transaction';
import { StakingTransaction } from '@harmony-js/staking';
import { bip39, hdkey, EncryptOptions, getAddress, generatePrivateKey } from '@woop-js/crypto';
import { Messenger } from '@woop-js/network';
import { isPrivateKey, isAddress, ChainType } from '@woop-js/utils';
import { Transaction } from '@woop-js/transaction';
import { StakingTransaction } from '@woop-js/staking';
import { Account } from './account';
import { defaultMessenger } from './utils';
@ -70,15 +70,15 @@ class Wallet {
/**
* @example
* ```
* const { Wallet } = require('@harmony-js/account');
* const { HttpProvider, Messenger } = require('@harmony-js/network');
* const { ChainType, ChainID } = require('@harmony-js/utils');
* const { Wallet } = require('@woop-js/account');
* const { HttpProvider, Messenger } = require('@woop-js/network');
* const { ChainType, ChainID } = require('@woop-js/utils');
*
* // create a custom messenger
* const customMessenger = new Messenger(
* new HttpProvider('http://localhost:9500'),
* ChainType.Harmony, // if you are connected to Harmony's blockchain
* ChainID.HmyLocal, // check if the chainId is correct
* ChainType.Woop, // if you are connected to Woop's blockchain
* ChainID.WikiLocal, // check if the chainId is correct
* )
*
* const wallet = new Wallet(customMessenger);
@ -116,8 +116,8 @@ class Wallet {
}
const seed = bip39.mnemonicToSeed(phrase);
const hdKey = hdkey.fromMasterSeed(seed);
// TODO:hdkey should apply to Harmony's settings
const path = this.messenger.chainType === ChainType.Harmony ? '1023' : '60';
// TODO:hdkey should apply to Woop's settings
const path = this.messenger.chainType === ChainType.Woop ? '1023' : '60';
const childKey = hdKey.derive(`m/44'/${path}'/0'/0/${index}`);
const privateKey = childKey.privateKey.toString('hex');
return this.addByPrivateKey(privateKey);
@ -316,8 +316,8 @@ class Wallet {
* ```javascript
* const customMessenger = new Messenger(
* new HttpProvider('https://api.s0.b.hmny.io'),
* ChainType.Harmony, // if you are connected to Harmony's blockchain
* ChainID.HmyLocal, // check if the chainId is correct
* ChainType.Woop, // if you are connected to Woop's blockchain
* ChainID.WikiLocal, // check if the chainId is correct
* )
* const wallet = new Wallet();
* wallet.setMessenger(customMessenger);

@ -1,18 +1,29 @@
/**
* @packageDocumentation
* @module harmony-account
* @module woop-account
* @ignore
*/
import fetch from 'jest-fetch-mock';
import { Account } from '../src/account';
import { HttpProvider, Messenger } from '@harmony-js/network';
import { ChainType, ChainID } from '@harmony-js/utils';
import { HttpProvider, Messenger } from '@woop-js/network';
import { ChainType, ChainID } from '@woop-js/utils';
const provider = new HttpProvider('http://localhost:9500');
const messenger = new Messenger(provider, ChainType.Harmony, ChainID.HmyLocal);
const messenger = new Messenger(provider, ChainType.Woop, ChainID.WikiLocal);
describe('test account', () => {
it('test Account.getBalance returns object that implements Balance interface', () => {
fetch.mockResponses(
[
JSON.stringify({"jsonrpc": "2.0", "id": 1, "result": "0x166c690f33421e"}),
{ status: 200 }
],
[
JSON.stringify({"jsonrpc": "2.0", "id": 1, "result": "0x106"}),
{ status: 200 }
]
);
const acc = Account.new();
acc.setMessenger(messenger);
acc.getBalance().then((res) => {

@ -6,10 +6,10 @@
},
"include": ["src", "../../typings/**/*.d.ts", "aaa.ts"],
"references": [
{ "path": "../harmony-crypto" },
{ "path": "../harmony-utils" },
{ "path": "../harmony-transaction" },
{ "path": "../harmony-staking" },
{ "path": "../harmony-network" }
{ "path": "../woop-crypto" },
{ "path": "../woop-utils" },
{ "path": "../woop-transaction" },
{ "path": "../woop-staking" },
{ "path": "../woop-network" }
]
}

@ -61,15 +61,15 @@
"type": "function"
}
],
"metadata": "{\"compiler\":{\"version\":\"0.5.16+commit.9c3226ce\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"inc\",\"type\":\"address\"}],\"name\":\"DecrementedBy\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"inc\",\"type\":\"address\"}],\"name\":\"IncrementedBy\",\"type\":\"event\"},{\"constant\":false,\"inputs\":[],\"name\":\"decrementCounter\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getCount\",\"outputs\":[{\"internalType\":\"int256\",\"name\":\"\",\"type\":\"int256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"incrementCounter\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/Users/gupadhyaya/go/src/github.com/harmony-one/counter/contracts/Counter.sol\":\"Counter\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"/Users/gupadhyaya/go/src/github.com/harmony-one/counter/contracts/Counter.sol\":{\"keccak256\":\"0x082839c98df1285d97e56f9ccdb4cd52d6723ab394356acc6d618d96bbd7e60e\",\"urls\":[\"bzz-raw://fd2b8a231c2fadcd0e60787a92a6e9df1b962684329f2dd13560857572d36168\",\"dweb:/ipfs/QmRmp9NK2mZk5GGfkK5b33HsaY2jz8B6uWpUYij7K9RW3r\"]}},\"version\":1}",
"metadata": "{\"compiler\":{\"version\":\"0.5.16+commit.9c3226ce\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"inc\",\"type\":\"address\"}],\"name\":\"DecrementedBy\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"inc\",\"type\":\"address\"}],\"name\":\"IncrementedBy\",\"type\":\"event\"},{\"constant\":false,\"inputs\":[],\"name\":\"decrementCounter\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getCount\",\"outputs\":[{\"internalType\":\"int256\",\"name\":\"\",\"type\":\"int256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"incrementCounter\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/Users/gupadhyaya/go/src/github.com/woop-chain/counter/contracts/Counter.sol\":\"Counter\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"/Users/gupadhyaya/go/src/github.com/woop-chain/counter/contracts/Counter.sol\":{\"keccak256\":\"0x082839c98df1285d97e56f9ccdb4cd52d6723ab394356acc6d618d96bbd7e60e\",\"urls\":[\"bzz-raw://fd2b8a231c2fadcd0e60787a92a6e9df1b962684329f2dd13560857572d36168\",\"dweb:/ipfs/QmRmp9NK2mZk5GGfkK5b33HsaY2jz8B6uWpUYij7K9RW3r\"]}},\"version\":1}",
"bytecode": "0x60806040526000805534801561001457600080fd5b506101a0806100246000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80635b34b96614610046578063a87d942c14610050578063f5c5ad831461006e575b600080fd5b61004e610078565b005b6100586100ed565b6040518082815260200191505060405180910390f35b6100766100f6565b005b600160008082825401925050819055507f064b1e66d8d787e36504c45aac3405f69335030ab8dc365a34919de13b61799c33604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a1565b60008054905090565b600160008082825403925050819055507f102d4e03b331a68eaffb991d44063c4452a0b6b650d8fb74b6932d8bd856f1c133604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a156fea265627a7a72315820963135863e1328fe0c11fedc623e29e097902650e6976e7650a1577c1086fc6a64736f6c63430005100032",
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100415760003560e01c80635b34b96614610046578063a87d942c14610050578063f5c5ad831461006e575b600080fd5b61004e610078565b005b6100586100ed565b6040518082815260200191505060405180910390f35b6100766100f6565b005b600160008082825401925050819055507f064b1e66d8d787e36504c45aac3405f69335030ab8dc365a34919de13b61799c33604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a1565b60008054905090565b600160008082825403925050819055507f102d4e03b331a68eaffb991d44063c4452a0b6b650d8fb74b6932d8bd856f1c133604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a156fea265627a7a72315820963135863e1328fe0c11fedc623e29e097902650e6976e7650a1577c1086fc6a64736f6c63430005100032",
"sourceMap": "34:426:0:-;;;80:1;57:24;;34:426;8:9:-1;5:2;;;30:1;27;20:12;5:2;34:426:0;;;;;;;",
"deployedSourceMap": "34:426:0:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;34:426:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;164:102;;;:::i;:::-;;380:78;;;:::i;:::-;;;;;;;;;;;;;;;;;;;272:102;;;:::i;:::-;;164;218:1;209:5;;:10;;;;;;;;;;;234:25;248:10;234:25;;;;;;;;;;;;;;;;;;;;;;164:102::o;380:78::-;421:6;446:5;;439:12;;380:78;:::o;272:102::-;326:1;317:5;;:10;;;;;;;;;;;342:25;356:10;342:25;;;;;;;;;;;;;;;;;;;;;;272:102::o",
"source": "pragma solidity >=0.4.21 <0.6.0;\n\ncontract Counter {\n int256 private count = 0;\n event IncrementedBy(address inc);\n event DecrementedBy(address inc);\n\n function incrementCounter() public {\n count += 1;\n emit IncrementedBy(msg.sender);\n }\n\n function decrementCounter() public {\n count -= 1;\n emit DecrementedBy(msg.sender);\n }\n\n function getCount() public view returns (int256) {\n return count;\n }\n}\n",
"sourcePath": "/Users/gupadhyaya/go/src/github.com/harmony-one/counter/contracts/Counter.sol",
"sourcePath": "/Users/gupadhyaya/go/src/github.com/woop-chain/counter/contracts/Counter.sol",
"ast": {
"absolutePath": "/Users/gupadhyaya/go/src/github.com/harmony-one/counter/contracts/Counter.sol",
"absolutePath": "/Users/gupadhyaya/go/src/github.com/woop-chain/counter/contracts/Counter.sol",
"exportedSymbols": {
"Counter": [47]
},
@ -617,7 +617,7 @@
"src": "0:461:0"
},
"legacyAST": {
"absolutePath": "/Users/gupadhyaya/go/src/github.com/harmony-one/counter/contracts/Counter.sol",
"absolutePath": "/Users/gupadhyaya/go/src/github.com/woop-chain/counter/contracts/Counter.sol",
"exportedSymbols": {
"Counter": [47]
},

@ -1,27 +1,27 @@
# @harmony-js/contract
# @woop-js/contract
This package provides a collection of apis to create, deploy, and interact with smart contracts. In Harmony, smart contracts all fully EVM compatible and the formats and terminologies match 1-to-1 with EVM smart contracts.
This package provides a collection of apis to create, deploy, and interact with smart contracts. In Woop, smart contracts all fully EVM compatible and the formats and terminologies match 1-to-1 with EVM smart contracts.
## Installation
```
npm install @harmony-js/contract
npm install @woop-js/contract
```
## Usage
Deploying a contract using `contractConstructor`
```javascript
const { ContractFactory } = require('@harmony-js/contract');
const { Wallet } = require('@harmony-js/account');
const { Messenger, HttpProvider } = require('@harmony-js/network');
const { ChainID, ChainType, hexToNumber } = require('@harmony-js/utils');
const { ContractFactory } = require('@woop-js/contract');
const { Wallet } = require('@woop-js/account');
const { Messenger, HttpProvider } = require('@woop-js/network');
const { ChainID, ChainType, hexToNumber } = require('@woop-js/utils');
const wallet = new Wallet(
new Messenger(
new HttpProvider('https://api.s0.b.hmny.io'),
ChainType.Harmony,
ChainID.HmyTestnet,
ChainType.Woop,
ChainID.WikiTestnet,
),
);
const factory = new ContractFactory(wallet);
@ -47,31 +47,31 @@ Instead of `contract.methods.contractConstructor`, `contract.deploy` could be us
Loading a contract object using the contract json and contract address for interacting with it
```javascript
const { Harmony } = require("@harmony-js/core");
const { ChainID, ChainType } = require("@harmony-js/utils");
const hmy = new Harmony("https://api.s0.b.hmny.io", {
chainType: ChainType.Harmony,
chainId: ChainID.HmyTestnet,
const { Woop } = require("@woop-js/core");
const { ChainID, ChainType } = require("@woop-js/utils");
const wiki = new Woop("https://api.s0.b.hmny.io", {
chainType: ChainType.Woop,
chainId: ChainID.WikiTestnet,
});
const contractJson = require("./Counter.json");
const contractAddr = "0x19f64050e6b2d376e52AC426E366c49EEb0724B1";
const contract = hmy.contracts.createContract(contractJson.abi, contractAddr);
const contract = wiki.contracts.createContract(contractJson.abi, contractAddr);
console.log(contract.methods);
```
Directly loading contract using `ContractFactory`
```javascript
const { ContractFactory } = require('@harmony-js/contract');
const { Wallet } = require('@harmony-js/account');
const { Messenger, HttpProvider } = require('@harmony-js/network');
const { ChainID, ChainType, hexToNumber } = require('@harmony-js/utils');
const { ContractFactory } = require('@woop-js/contract');
const { Wallet } = require('@woop-js/account');
const { Messenger, HttpProvider } = require('@woop-js/network');
const { ChainID, ChainType, hexToNumber } = require('@woop-js/utils');
const wallet = new Wallet(new Messenger(
new HttpProvider('https://api.s0.b.hmny.io'),
ChainType.Harmony,
ChainID.HmyTestnet,
ChainType.Woop,
ChainID.WikiTestnet,
));
const factory = new ContractFactory(wallet);
const contract = factory.createContract(contractJson.abi, contractAddr);
@ -86,7 +86,7 @@ contract.methods.getCount().estimateGas(options1).then(gas => {
});
```
Call contract read-only methods. Harmony uses 1 Gwei gas price and gas limit of 21000 by default. Use the estimate gas api to correctly set the gas limit.
Call contract read-only methods. Woop uses 1 Gwei gas price and gas limit of 21000 by default. Use the estimate gas api to correctly set the gas limit.
```javascript
const options1 = { gasPrice: '0x3B9ACA00' }; // gas price in hex corresponds to 1 Gwei or 1000000000
let options2 = { gasPrice: 1000000000, gasLimit: 21000 }; // setting the default gas limit, but changing later based on estimate gas
@ -118,17 +118,17 @@ All the above apis can also be asynchronously executed using `async` and `await`
Subscribing to the contract events requires web socket based messenger.
```javascript
const { ContractFactory } = require('@harmony-js/contract');
const { Wallet } = require('@harmony-js/account');
const { Messenger, WSProvider } = require('@harmony-js/network');
const { ChainID, ChainType, hexToNumber } = require('@harmony-js/utils');
const { ContractFactory } = require('@woop-js/contract');
const { Wallet } = require('@woop-js/account');
const { Messenger, WSProvider } = require('@woop-js/network');
const { ChainID, ChainType, hexToNumber } = require('@woop-js/utils');
const ws = new WSProvider('wss://ws.s0.b.hmny.io');
const wallet = new Wallet(
new Messenger(
ws,
ChainType.Harmony,
ChainID.HmyTestnet,
ChainType.Woop,
ChainID.WikiTestnet,
),
);
const factory = new ContractFactory(wallet);

@ -1,7 +1,7 @@
{
"name": "@harmony-js/contract",
"version": "0.1.53",
"description": "contract libraries for harmony",
"name": "@woop-js/contract",
"version": "0.1.58",
"description": "contract libraries for woop",
"main": "dist/index.js",
"node": "dist/index.js",
"browser": "dist/index.js",
@ -18,11 +18,11 @@
},
"license": "MIT",
"dependencies": {
"@harmony-js/account": "0.1.46",
"@harmony-js/crypto": "0.1.48",
"@harmony-js/network": "0.1.51",
"@harmony-js/transaction": "0.1.51",
"@harmony-js/utils": "0.1.48"
"@woop-js/account": "0.1.58",
"@woop-js/crypto": "0.1.58",
"@woop-js/network": "0.1.58",
"@woop-js/transaction": "0.1.58",
"@woop-js/utils": "0.1.58"
},
"gitHead": "56606e9365721729a490c27d6a294e0daf90fbdf"
}

@ -1,113 +1,154 @@
/**
* ## About this package
*
* `@harmony-js/contract` makes it easy to interact with smart contract on the Harmony Blockchain. This allows you to interact with smart contracts as if they were JavaScript objects.
*
* ## How to use this package
*
* ### Deploy a contract to blockchain
* ```javascript
* // Step 1: Use Solidity to build a sample contract instance
* contract Inbox {
* string public message;
* constructor() public {
* message = "hello";
* }
* function setMessage(string memory newMessage) public {
* message = newMessage;
* }
* }
*
* // Step 2: Use truffle to compile the contract
* $ truffle compile
*
* // Step 3: Use truffle to deploy the contract (by truffle)
* $ truffle migrate --network local --reset
* $ truffle migrate --network testnet --reset
* ```
* [Tutorial: using truffle to compile and deploy smart-contract](https://github.com/harmony-one/HRC/tree/master/examples/dapp_Lottery)
*
* ### Interact with the contract
* ```javascript
* // Step 1: create a harmony instance
* const { Harmony } = require('@harmony-js/core');
* const { ChainID, ChainType } = require('@harmony-js/utils');
* const hmy = new Harmony(
* // let's assume we deploy smart contract to this end-point URL
* 'https://api.s0.b.hmny.io'
* {
* chainType: ChainType.Harmony,
* chainId: ChainID.HmyLocal,
* }
* )
*
* // Step 2: get a contract instance
* const getContractInstance = (hmy, artifact) => {
* return hmy.contracts.createContract(artifact.abi, address);
* }
* const inbox = getContractInstance(hmy, inboxJson)
*
* // Step 3: interact with the instance
* // Example 1: methods.myMethod.call()
* const message = await inbox.methods.message().call();
* console.log(message);
*
* // Example 2: methods.myMethod.send()
* inbox.methods.setMessage('666').send({
* gasLimit: '1000001',
* gasPrice: new hmy.utils.Unit('10').asGwei().toWei(),
* });
* ```
*
* ### Integrate MathWallet
* Using MathWallet to sign Transaction
* ```javascript
* // Step 0: set up MathWallet extension on Chrome
*
* // Step 1: Create a harmonyExtension instance
* const { Harmony, HarmonyExtension } = require('@harmony-js/core');
* let hmyEx, ExContract;
* export const initExtension = async() => {
* hmyEx = await new HarmonyExtension(window.harmony);
*
* exContract = hmyEx.contracts.createContract(abi, address);
* return exContract;
* };
*
* // Step 2: interact with hmyEx instance
* // wait for hmy inject into window
* async componentDidMount() {
* ...
* await waitForInjected()
* ...
* }
* // Example: methods.myMethod.send()
* onSubmit = async event => {
* const exContract = await initExtension()
* await exContract.methods.Mymethod().send({
* value: new hmy.utils.Unit('1').asOne().toWei(),
* })
* }
*
* // wait for injected
* export const waitForInjected = () => new Promise((resolve) => {
* const check = () => {
* if (!window.harmony) setTimeout(check, 250);
* else resolve(window.harmony);
* }
* check();
* });
* ```
*
* ## [More Examples: HRC repo](https://github.com/harmony-one/HRC/tree/master/examples)
* - Lottery
* - HRC 20
* - HRC 721
* - Node-dao
* - Node-faucet
# @woop-js/contract
This package provides a collection of apis to create, deploy, and interact with smart contracts. In Woop, smart contracts all fully EVM compatible and the formats and terminologies match 1-to-1 with EVM smart contracts.
## Installation
```
npm install @woop-js/contract
```
## Usage
Deploying a contract using `contractConstructor`
```javascript
const { ContractFactory } = require('@woop-js/contract');
const { Wallet } = require('@woop-js/account');
const { Messenger, HttpProvider } = require('@woop-js/network');
const { ChainID, ChainType, hexToNumber } = require('@woop-js/utils');
* const wallet = new Wallet(
* new Messenger(
* new HttpProvider('https://api.s0.b.hmny.io'),
* ChainType.Woop,
* ChainID.WikiTestnet,
* ),
* );
* const factory = new ContractFactory(wallet);
* const contractJson = require("./Counter.json");
* const contract = factory.createContract(contractJson.abi);
* const options1 = { gasPrice: '0x3B9ACA00' }; // gas price in hex corresponds to 1 Gwei or 1000000000
* let options2 = { gasPrice: 1000000000, gasLimit: 21000 }; // setting the default gas limit, but changing later based on estimate gas
* const options3 = { data: contractJson.bytecode }; // contractConstructor needs contract bytecode to deploy
* contract.wallet.addByPrivateKey('1f054c21a0f57ebc402c00e14bd1707ddf45542d4ed9989933dbefc4ea96ca68');
* contract.methods.contractConstructor(options3).estimateGas(options1).then(gas => {
* options2 = {...options2, gasLimit: hexToNumber(gas)};
* contract.methods.contractConstructor(options3).send(options2).then(response => {
* console.log('contract deployed at ' + response.transaction.receipt.contractAddress);
* });
* });
```
Instead of `contract.methods.contractConstructor`, `contract.deploy` could be used and it will work.
Loading a contract object using the contract json and contract address for interacting with it
```javascript
* const { Woop } = require("@woop-js/core");
* const { ChainID, ChainType } = require("@woop-js/utils");
* const wiki = new Woop("https://api.s0.b.hmny.io", {
* chainType: ChainType.Woop,
* chainId: ChainID.WikiTestnet,
* });
const contractJson = require("./Counter.json");
const contractAddr = "0x19f64050e6b2d376e52AC426E366c49EEb0724B1";
const contract = wiki.contracts.createContract(contractJson.abi, contractAddr);
console.log(contract.methods);
```
Directly loading contract using `ContractFactory`
```javascript
const { ContractFactory } = require('@woop-js/contract');
const { Wallet } = require('@woop-js/account');
const { Messenger, HttpProvider } = require('@woop-js/network');
const { ChainID, ChainType, hexToNumber } = require('@woop-js/utils');
* const wallet = new Wallet(new Messenger(
* new HttpProvider('https://api.s0.b.hmny.io'),
* ChainType.Woop,
* ChainID.WikiTestnet,
* ));
const factory = new ContractFactory(wallet);
const contract = factory.createContract(contractJson.abi, contractAddr);
```
Estimate gas for contract methods
```javascript
* const options1 = { gasPrice: '0x3B9ACA00' }; // gas price in hex corresponds to 1 Gwei or 1000000000
* contract.methods.getCount().estimateGas(options1).then(gas => {
* console.log('gas required for getCount is ' + hexToNumber(gas));
* });
```
Call contract read-only methods. Woop uses 1 Gwei gas price and gas limit of 21000 by default. Use the estimate gas api to correctly set the gas limit.
```javascript
* const options1 = { gasPrice: '0x3B9ACA00' }; // gas price in hex corresponds to 1 Gwei or 1000000000
* let options2 = { gasPrice: 1000000000, gasLimit: 21000 }; // setting the default gas limit, but changing later based on estimate gas
* contract.methods.getCount().estimateGas(options1).then(gas => {
* options2 = {...options2, gasLimit: hexToNumber(gas)};
* contract.methods.getCount().call(options2).then(count => {
* console.log('counter value: ' + count);
* });
* });
```
Invoking contract modification methods using `send` api. Need to add a signing account to the contract wallet, otherwise `send` api will not work.
```javascript
* const options1 = { gasPrice: '0x3B9ACA00' }; // gas price in hex corresponds to 1 Gwei or 1000000000
* let options2 = { gasPrice: 1000000000, gasLimit: 21000 }; // setting the default gas limit, but changing later based on estimate gas
* contract.wallet.addByPrivateKey('1f054c21a0f57ebc402c00e14bd1707ddf45542d4ed9989933dbefc4ea96ca68');
* contract.methods.incrementCounter().estimateGas(options1).then(gas => {
* options2 = {...options2, gasLimit: hexToNumber(gas)};
* contract.methods.incrementCounter().send(options2).then(response => {
* console.log(response.transaction.receipt);
* });
* });
```
All the above apis can also be asynchronously executed using `async` and `await`.
Subscribing to the contract events requires web socket based messenger.
```javascript
* const { ContractFactory } = require('@woop-js/contract');
* const { Wallet } = require('@woop-js/account');
* const { Messenger, WSProvider } = require('@woop-js/network');
* const { ChainID, ChainType, hexToNumber } = require('@woop-js/utils');
* const ws = new WSProvider('wss://ws.s0.b.hmny.io');
* const wallet = new Wallet(
* new Messenger(
* ws,
* ChainType.Woop,
* ChainID.WikiTestnet,
* ),
* );
* const factory = new ContractFactory(wallet);
* const contractJson = require("./Counter.json");
* const contractAddr = '0x8ada52172abda19b9838eb00498a40952be6a019';
* const contract = factory.createContract(contractJson.abi, contractAddr);
* contract.events
* .IncrementedBy()
* .on('data', (event) => {
* console.log(event);
* })
* .on('error', console.error);
```
*
* @packageDocumentation
* @module harmony-contract
* @module woop-contract
*/
// this file is mainly ported from `ethers.js`, but done some fixes
@ -130,8 +171,8 @@ import {
Arrayish,
checkNew,
bytesPadRight,
} from '@harmony-js/crypto';
import { hexToBN, defineReadOnly } from '@harmony-js/utils';
} from '@woop-js/crypto';
import { hexToBN, defineReadOnly } from '@woop-js/utils';
/** @hidden */
const NegativeOne: BN = new BN(-1);
@ -683,7 +724,12 @@ class CoderNumber extends Coder {
encode(value: BN | number | string): Uint8Array {
let result;
try {
let v = new BN(value);
let v: BN;
if (typeof value == 'string' && value.startsWith('0x')) {
v = new BN(value.slice(2), 'hex');
} else {
v = new BN(value);
}
if (this.signed) {
let bounds = MaxUint256.maskn(this.size * 8 - 1);
if (v.gt(bounds)) {

@ -1,12 +1,12 @@
/**
* @packageDocumentation
* @module harmony-contract
* @module woop-contract
* @hidden
*/
import { AbiCoder as ABICoder, ParamType, toUtf8Bytes } from './abiCoder';
import { isObject, isArray } from '@harmony-js/utils';
import { keccak256, Arrayish } from '@harmony-js/crypto';
import { isObject, isArray } from '@woop-js/utils';
import { keccak256, Arrayish } from '@woop-js/crypto';
import { jsonInterfaceMethodToString, bnToString } from './utils';
export class AbiCoderClass {

@ -1,6 +1,6 @@
/**
* @packageDocumentation
* @module harmony-contract
* @module woop-contract
* @hidden
*/

@ -1,11 +1,11 @@
/**
* @packageDocumentation
* @module harmony-contract
* @module woop-contract
* @hidden
*/
import { isObject, isArray } from '@harmony-js/utils';
import { BN } from '@harmony-js/crypto';
import { isObject, isArray } from '@woop-js/utils';
import { BN } from '@woop-js/crypto';
export const jsonInterfaceMethodToString = (json: any): string => {
if (isObject(json) && json.name && json.name.includes('(')) {

@ -1,12 +1,12 @@
/**
* @packageDocumentation
* @module harmony-contract
* @module woop-contract
*
*/
import { Wallet } from '@harmony-js/account';
import { Messenger } from '@harmony-js/network';
import { Transaction } from '@harmony-js/transaction';
import { Wallet } from '@woop-js/account';
import { Messenger } from '@woop-js/network';
import { Transaction } from '@woop-js/transaction';
import { AbiCoder } from './abi/index';
import { abiMapper } from './utils/mapper';
import { ContractOptions } from './utils/options';
@ -20,6 +20,9 @@ import { ContractStatus } from './utils/status';
export class Contract {
methods: any;
events: any;
fallback: any = undefined;
receive: any = undefined;
abi: any = [];
abiModel: any | AbiModel;
abiCoder: AbiCoderClass;
options: ContractOptions | any;
@ -27,6 +30,8 @@ export class Contract {
transaction?: Transaction;
status: ContractStatus;
shardID: number;
errorFunc: string = 'Error(string)';
errorFuncSig: string;
constructor(
abi: any = [],
@ -36,6 +41,7 @@ export class Contract {
status: ContractStatus = ContractStatus.INITIALISED,
) {
// super();
this.abi = abi;
this.abiCoder = AbiCoder();
this.abiModel = abiMapper(abi, this.abiCoder);
this.options = options;
@ -47,6 +53,7 @@ export class Contract {
this.runMethodFactory();
this.runEventFactory();
this.status = status;
this.errorFuncSig = this.abiCoder.encodeFunctionSignature(this.errorFunc);
// tslint:disable-next-line: no-unused-expression
}
isInitialised() {
@ -111,7 +118,7 @@ export class Contract {
connect(wallet: Wallet): void {
this.wallet = wallet;
}
setMessegner(messenger: Messenger) {
setMessenger(messenger: Messenger) {
if (this.wallet instanceof Wallet) {
this.wallet.setMessenger(messenger);
} else {

@ -1,9 +1,9 @@
/**
* @packageDocumentation
* @module harmony-contract
* @module woop-contract
*/
import { Wallet } from '@harmony-js/account';
import { Wallet } from '@woop-js/account';
import { Contract } from './contract';
import { ContractOptions } from './utils/options';

@ -1,9 +1,9 @@
/**
* @packageDocumentation
* @module harmony-contract
* @module woop-contract
*/
import { LogSub } from '@harmony-js/network';
import { LogSub } from '@woop-js/network';
import { AbiItemModel } from '../models/types';
import { Contract } from '../contract';
import { decode as eventLogDecoder } from '../utils/decoder';

@ -1,10 +1,10 @@
/**
* @packageDocumentation
* @module harmony-contract
* @module woop-contract
* @hidden
*/
import { isArray } from '@harmony-js/utils';
import { isArray } from '@woop-js/utils';
import { AbiCoderClass } from '../abi/api';
import { AbiModel, AbiItemModel } from '../models/types';
import { Contract } from '../contract';

@ -1,6 +1,6 @@
/**
* @packageDocumentation
* @module harmony-contract
* @module woop-contract
* @hidden
*/

@ -1,20 +1,18 @@
/**
* @packageDocumentation
* @module harmony-contract
* @module woop-contract
*/
import { Wallet } from '@harmony-js/account';
import { TransactionFactory, Transaction, TxStatus } from '@harmony-js/transaction';
import { RPCMethod, getResultForData, Emitter } from '@harmony-js/network';
import { hexToNumber, hexToBN } from '@harmony-js/utils';
import { getAddress } from '@harmony-js/crypto';
import { Wallet } from '@woop-js/account';
import { TransactionFactory, Transaction, TxStatus } from '@woop-js/transaction';
import { RPCMethod, getResultForData, Emitter } from '@woop-js/network';
import { hexToBN, Unit } from '@woop-js/utils';
import { getAddress } from '@woop-js/crypto';
import { AbiItemModel } from '../models/types';
import { Contract } from '../contract';
import { methodEncoder } from '../utils/encoder';
import { ContractStatus } from '../utils/status';
// todo: have to judge if it is contractConstructor
export class ContractMethod {
contract: Contract;
params: any;
@ -36,8 +34,11 @@ export class ContractMethod {
this.callResponse = undefined;
}
send(params: any): Emitter {
if (params && !params.gasLimit) {
params.gasLimit = params.gas;
}
try {
let gasLimit: any;
let gasLimit: any = params.gasLimit; // change by estimateGas
const signTxs = () => {
this.transaction = this.transaction.map((tx: any) => {
return { ...tx, ...params, gasLimit };
@ -45,28 +46,30 @@ export class ContractMethod {
const waitConfirm: boolean = params && params.waitConfirm === false ? false : true;
const updateNonce: boolean = params && params.nonce !== undefined ? false : true;
this.signTransaction(updateNonce).then((signed) => {
this.sendTransaction(signed).then((sent) => {
const [txn, id] = sent;
this.transaction = txn;
this.contract.transaction = this.transaction;
if (waitConfirm) {
this.confirm(id).then(() => {
this.signTransaction(updateNonce)
.then((signed) => {
this.sendTransaction(signed).then((sent) => {
const [txn, id] = sent;
this.transaction = txn;
this.contract.transaction = this.transaction;
if (this.transaction.isRejected()) {
this.transaction.emitter.reject(id); // in this case, id is error message
} else if (waitConfirm) {
this.confirm(id).then(() => {
this.transaction.emitter.resolve(this.contract);
});
} else {
this.transaction.emitter.resolve(this.contract);
});
} else {
this.transaction.emitter.resolve(this.contract);
}
}
});
})
.catch((error) => {
this.transaction.emitter.reject(error);
});
});
};
// tslint:disable-next-line: prefer-conditional-expression
if (params !== undefined) {
gasLimit = params.gas || params.gasLimit;
}
if (gasLimit === undefined) {
this.estimateGas().then((gas) => {
this.estimateGas(params).then((gas) => {
gasLimit = hexToBN(gas);
signTxs();
});
@ -79,38 +82,20 @@ export class ContractMethod {
}
}
async call(options: any, blockNumber: any = 'latest') {
if (options && !options.gasLimit) {
options.gasLimit = options.gas;
}
try {
options = { ...this.contract.options, ...options };
const shardID =
options !== undefined && options.shardID !== undefined
? options.shardID
: this.contract.shardID;
const nonce = '0x0';
let gasLimit: any;
// tslint:disable-next-line: prefer-conditional-expression
if (options !== undefined) {
gasLimit = options.gas || options.gasLimit;
} else {
gasLimit = '21000000';
}
let from: string;
// tslint:disable-next-line: prefer-conditional-expression
if (this.wallet.signer) {
from = options && options.from ? options.from : this.wallet.signer.address;
} else {
from =
options && options.from ? options.from : '0x0000000000000000000000000000000000000000';
}
this.transaction = this.transaction.map((tx: any) => {
return {
...tx,
...options,
from: from || tx.from,
gasPrice: options ? options.gasPrice : tx.gasPrice,
gasLimit: gasLimit || tx.gasLimit,
nonce: Number.parseInt(hexToNumber(nonce), 10),
nonce: 0,
};
});
const keys: string[] = Object.keys(this.transaction.txPayload);
@ -173,36 +158,29 @@ export class ContractMethod {
}
}
async estimateGas(
params: {
from?: string;
to?: string;
gas?: string;
gasPrice?: string;
value?: string;
data?: string;
} = {},
) {
async estimateGas(options: any) {
try {
if (params.from === undefined && this.contract.options.from !== undefined) {
params.from = this.contract.options.from;
}
if (params.to === undefined && this.transaction.txParams.to !== undefined) {
params.to = this.transaction.txParams.to;
}
if (params.data === undefined) {
params.data = this.transaction.txParams.data;
interface Payload {
[key: string]: any;
}
if (params.gasPrice === undefined && this.contract.options.gasPrice !== undefined) {
params.gasPrice = this.contract.options.gasPrice;
const estPayload: Payload = {};
const txPayload: Payload = this.transaction.txPayload;
const keys: string[] = ['from', 'to', 'gasPrice', 'value', 'data'];
for (const key of keys) {
if (options && options[key]) {
estPayload[key] = options[key];
} else if (txPayload[key] !== '0x') {
estPayload[key] = txPayload[key];
}
}
if (this.methodKey === 'contractConstructor') {
delete params.to;
if (this.abiItem.isOfType('constructor')) {
delete estPayload.to;
}
const result = getResultForData(
// tslint:disable-line
await (<Wallet>this.wallet).messenger.send(RPCMethod.EstimateGas, [params]),
await (<Wallet>this.wallet).messenger.send(RPCMethod.EstimateGas, [estPayload]),
);
if (result.responseType === 'error') {
@ -246,7 +224,7 @@ export class ContractMethod {
'rlp',
'latest', // 'pending',
);
if (this.methodKey === 'contractConstructor') {
if (this.abiItem.isOfType('constructor')) {
this.contract.address = TransactionFactory.getContractAddress(signed);
}
this.contract.setStatus(ContractStatus.SIGNED);
@ -274,7 +252,7 @@ export class ContractMethod {
);
if (result.receipt && result.txStatus === TxStatus.CONFIRMED) {
if (this.methodKey === 'contractConstructor') {
if (this.abiItem.isOfType('constructor')) {
this.contract.setStatus(ContractStatus.DEPLOYED);
} else {
this.contract.setStatus(ContractStatus.CALLED);
@ -289,7 +267,7 @@ export class ContractMethod {
protected createTransaction() {
if (this.wallet.messenger) {
if (this.methodKey === 'contractConstructor') {
if (this.abiItem.isOfType('constructor')) {
// tslint:disable-next-line: no-string-literal
this.contract.data = this.params[0]['data'] || '0x';
@ -299,16 +277,19 @@ export class ContractMethod {
} else {
this.abiItem.contractMethodParameters = this.params || [];
}
const defaultOptions = {
gasLimit: new Unit(21000000).asWei().toWei(),
gasPrice: new Unit(1).asGwei().toWei(),
};
const txObject = {
...defaultOptions,
...this.contract.options,
...this.params[0],
to:
this.methodKey === 'contractConstructor'
? '0x'
: getAddress(this.contract.address).checksum,
to: this.abiItem.isOfType('constructor')
? '0x'
: getAddress(this.contract.address).checksum,
data: this.encodeABI(),
};
// tslint:disable-line
const result = new TransactionFactory((<Wallet>this.wallet).messenger).newTx(txObject);
@ -319,11 +300,32 @@ export class ContractMethod {
}
protected afterCall(response: any) {
if (!response || response === '0x') {
return null;
// length of `0x${methodSig}` is 2+4*2=10
if (response.length % 32 === 10 && response.startsWith(this.contract.errorFuncSig)) {
const errmsg = this.contract.abiCoder.decodeParameters(
[{ type: 'string' }],
'0x' + response.slice(10),
);
throw { revert: errmsg[0] };
}
if (
this.abiItem.isOfType('constructor') ||
this.abiItem.isOfType('fallback') ||
this.abiItem.isOfType('receive')
) {
return response;
}
const outputs = this.abiItem.getOutputs();
if (outputs.length === 0) {
// if outputs is empty, we can't know the call is revert or not
return response;
}
if (!response || response === '0x') {
// if outputs isn't empty, treat it as revert
throw { revert: response };
}
if (outputs.length > 1) {
return this.contract.abiCoder.decodeParameters(outputs, response);
}

@ -1,6 +1,6 @@
/**
* @packageDocumentation
* @module harmony-contract
* @module woop-contract
* @hidden
*/
@ -31,6 +31,14 @@ export class MethodFactory {
Object.assign(this.contract.methods, newObject);
});
if (this.abiModel.hasFallback()) {
this.contract.fallback = (calldata: string) =>
new ContractMethod('fallback', [calldata], this.abiModel.getFallback(), this.contract);
}
if (this.abiModel.hasReceive()) {
this.contract.receive = () =>
new ContractMethod('receive', [], this.abiModel.getReceive(), this.contract);
}
return this.contract;
}
/**

@ -1,10 +1,10 @@
/**
* @packageDocumentation
* @module harmony-contract
* @module woop-contract
* @hidden
*/
import { isArray } from '@harmony-js/utils';
import { isArray } from '@woop-js/utils';
import { AbiItemModel, AbiOutput, AbiInput } from './types';
export class AbiItem {

@ -1,6 +1,6 @@
/**
* @packageDocumentation
* @module harmony-contract
* @module woop-contract
* @hidden
*/
@ -33,6 +33,20 @@ export class AbiModel {
return false;
}
getFallback(): AbiItemModel | false {
if (this.hasFallback()) {
return this.abi.fallback;
}
return false;
}
getReceive(): AbiItemModel | false {
if (this.hasReceive()) {
return this.abi.receive;
}
return false;
}
getEvents(): AbiItemModel[] {
return this.abi.events;
}
@ -53,6 +67,14 @@ export class AbiModel {
return typeof this.abi.methods[name] !== 'undefined';
}
hasFallback(): boolean {
return typeof this.abi.fallback !== 'undefined';
}
hasReceive(): boolean {
return typeof this.abi.receive !== 'undefined';
}
hasEvent(name: string): boolean {
return typeof this.abi.events[name] !== 'undefined';
}

@ -1,6 +1,6 @@
/**
* @packageDocumentation
* @module harmony-contract
* @module woop-contract
* @hidden
*/

@ -1,6 +1,6 @@
/**
* @packageDocumentation
* @module harmony-contract
* @module woop-contract
* @hidden
*/

@ -1,10 +1,10 @@
/**
* @packageDocumentation
* @module harmony-contract
* @module woop-contract
* @hidden
*/
import { isArray } from '@harmony-js/utils';
import { isArray } from '@woop-js/utils';
import { AbiItemModel } from '../models/types';
import { AbiCoderClass } from '../abi/api';
@ -13,6 +13,15 @@ export const methodEncoder = (
abiItemModel: AbiItemModel,
deployData: string,
) => {
if (abiItemModel.isOfType('receive')) {
return undefined;
}
if (abiItemModel.isOfType('fallback')) {
return abiItemModel.contractMethodParameters.length
? abiItemModel.contractMethodParameters[0]
: undefined;
}
let encodedParameters = abiCoder.encodeParameters(
abiItemModel.getInputs(),
abiItemModel.contractMethodParameters,

@ -1,10 +1,10 @@
/**
* @packageDocumentation
* @module harmony-contract
* @module woop-contract
* @hidden
*/
import { hexlify, isHexString, keccak256, toChecksumAddress } from '@harmony-js/crypto';
import { hexlify, isHexString, keccak256, toChecksumAddress } from '@woop-js/crypto';
import {
numberToHex,
isArray,
@ -12,7 +12,7 @@ import {
isString,
isAddress,
hexToBN,
} from '@harmony-js/utils';
} from '@woop-js/utils';
import { toUtf8Bytes } from '../abi/abiCoder';
export const inputLogFormatter = (options: any) => {

@ -1,10 +1,10 @@
/**
* @packageDocumentation
* @module harmony-contract
* @module woop-contract
* @hidden
*/
import { isArray } from '@harmony-js/utils';
import { isArray } from '@woop-js/utils';
import { AbiItem } from '../models/AbiItemModel';
import { AbiModel } from '../models/AbiModel';
import { AbiItemModel } from '../models/types';
@ -15,6 +15,8 @@ export const abiMapper = (abi: any[], abiCoder: AbiCoderClass): AbiModel => {
const mappedAbiItems: any = {
methods: {},
events: {},
fallback: undefined,
receive: undefined,
};
let hasConstructor = false;
@ -70,6 +72,11 @@ export const abiMapper = (abi: any[], abiCoder: AbiCoderClass): AbiModel => {
mappedAbiItems.events[abiItem.funcName] = abiItemModel;
}
if (abiItem.type === 'fallback' || abiItem.type === 'receive') {
abiItem.signature = abiItem.type;
mappedAbiItems[abiItem.type] = new AbiItem(abiItem);
}
if (abiItem.type === 'constructor') {
abiItem.signature = abiItem.type;
// tslint:disable-next-line: no-string-literal

@ -1,6 +1,6 @@
/**
* @packageDocumentation
* @module harmony-contract
* @module woop-contract
* @hidden
*/

@ -1,6 +1,6 @@
/**
* @packageDocumentation
* @module harmony-contract
* @module woop-contract
* @hidden
*/

@ -4,8 +4,8 @@
*/
import { AbiCoder } from '../src/abi/abiCoder';
import { BN } from '@harmony-js/crypto';
import { isArray } from '@harmony-js/utils';
import { BN } from '@woop-js/crypto';
import { isArray } from '@woop-js/utils';
import { abis } from './fixtures/abiv2';
function getValues(object: any, format?: any, named?: any): any {

@ -6,10 +6,10 @@
},
"include": ["src", "../../typings/**/*.d.ts"],
"references": [
{"path": "../harmony-account"},
{"path": "../harmony-crypto"},
{"path": "../harmony-utils"},
{"path": "../harmony-transaction"},
{"path": "../harmony-network"}
{"path": "../woop-account"},
{"path": "../woop-crypto"},
{"path": "../woop-utils"},
{"path": "../woop-transaction"},
{"path": "../woop-network"}
]
}

@ -1,19 +1,19 @@
# @harmony-js/core
# @woop-js/core
This package provides a collection of apis to interact with Harmony blockchain.
This package provides a collection of apis to interact with Woop blockchain.
## Installation
```
npm install @harmony-js/core
npm install @woop-js/core
```
## Usage
Create a Harmony instance connecting to testnet
Create a Woop instance connecting to testnet
```javascript
const { Harmony } = require('@harmony-js/core');
const { Woop } = require('@woop-js/core');
const {
ChainID,
ChainType,
@ -22,20 +22,20 @@ const {
fromWei,
Units,
Unit,
} = require('@harmony-js/utils');
} = require('@woop-js/utils');
const hmy = new Harmony(
const wiki = new Woop(
'https://api.s0.b.hmny.io/',
{
chainType: ChainType.Harmony,
chainId: ChainID.HmyTestnet,
chainType: ChainType.Woop,
chainId: ChainID.WikiTestnet,
},
);
```
Getting balance of account `one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7`
```javascript
hmy.blockchain
wiki.blockchain
.getBalance({ address: 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7' })
.then((response) => {
console.log('balance in ONEs: ' + fromWei(hexToNumber(response.result), Units.one));
@ -44,14 +44,14 @@ hmy.blockchain
Getting the latest block number
```javascript
hmy.blockchain.getBlockNumber().then((response) => {
wiki.blockchain.getBlockNumber().then((response) => {
console.log('current block number: ' + hexToNumber(response.result));
});
```
Getting the block using block hash
```javascript
hmy.blockchain
wiki.blockchain
.getBlockByHash({
blockHash: '0x08c46ae7249362a7d1f602d44c5a81f33ebdab6a7dcb6068f99610b57911aafd',
})
@ -62,7 +62,7 @@ hmy.blockchain
Getting the block using block number
```javascript
hmy.blockchain
wiki.blockchain
.getBlockByNumber({
blockNumber: numberToHex(422635),
})
@ -73,7 +73,7 @@ hmy.blockchain
Getting the transaction using hash
```javascript
hmy.blockchain
wiki.blockchain
.getTransactionByHash({
txnHash: '0x56c73eb993b18dc04baacec5c2e9d1292a090f6a978a4a1c461db5255fcbc831',
})
@ -84,7 +84,7 @@ hmy.blockchain
Getting the transaction receipt
```javascript
hmy.blockchain
wiki.blockchain
.getTransactionReceipt({
txnHash: '0x56c73eb993b18dc04baacec5c2e9d1292a090f6a978a4a1c461db5255fcbc831',
})
@ -95,7 +95,7 @@ hmy.blockchain
Getting the cross-shard transaction receipt
```javascript
hmy.blockchain
wiki.blockchain
.getCxReceiptByHash({
txnHash: '0xcd36a90ff5d5373285c2896ba7bbcd3f5324263c0cb8ecfb7cad2f5fc2fbdbda',
shardID: 1,
@ -107,7 +107,7 @@ hmy.blockchain
Getting the deployed smart contract code
```javascript
hmy.blockchain
wiki.blockchain
.getCode({
address: '0x08AE1abFE01aEA60a47663bCe0794eCCD5763c19',
blockNumber: 'latest',
@ -119,7 +119,7 @@ hmy.blockchain
Getting the transaction count of an account
```javascript
hmy.blockchain
wiki.blockchain
.getTransactionCount({
address: 'one1pdv9lrdwl0rg5vglh4xtyrv3wjk3wsqket7zxy',
})
@ -130,7 +130,7 @@ hmy.blockchain
Getting the shard structure and details
```javascript
hmy.blockchain.getShardingStructure().then((response) => {
wiki.blockchain.getShardingStructure().then((response) => {
console.log(response.result);
});
```
@ -138,10 +138,10 @@ hmy.blockchain.getShardingStructure().then((response) => {
Transferring funds using `sendTransaction`
```javascript
// key corresponds to one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7, only has testnet balance
hmy.wallet.addByPrivateKey('45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e');
wiki.wallet.addByPrivateKey('45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e');
async function transfer() {
const txn = hmy.transactions.newTx({
const txn = wiki.transactions.newTx({
to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2',
value: new Unit(1).asOne().toWei(),
// gas limit, you can use string
@ -151,12 +151,12 @@ async function transfer() {
// send token to toShardID
toShardID: 0,
// gas Price, you can use Unit class, and use Gwei, then remember to use toWei(), which will be transformed to BN
gasPrice: new hmy.utils.Unit('1').asGwei().toWei(),
gasPrice: new wiki.utils.Unit('1').asGwei().toWei(),
});
// sign the transaction use wallet;
const signedTxn = await hmy.wallet.signTransaction(txn);
const txnHash = await hmy.blockchain.sendTransaction(signedTxn);
const signedTxn = await wiki.wallet.signTransaction(txn);
const txnHash = await wiki.blockchain.sendTransaction(signedTxn);
console.log(txnHash.result);
}

@ -1,7 +1,7 @@
{
"name": "@harmony-js/account",
"version": "0.1.53",
"description": "account and wallet for harmony",
"name": "@woop-js/core",
"version": "0.1.58",
"description": "woop core package",
"main": "dist/index.js",
"node": "dist/index.js",
"browser": "dist/index.js",
@ -18,12 +18,13 @@
"author": "neeboo@firestack.one",
"license": "MIT",
"dependencies": {
"@harmony-js/core": "0.1.53",
"@harmony-js/crypto": "0.1.48",
"@harmony-js/network": "0.1.51",
"@harmony-js/staking": "0.1.51",
"@harmony-js/transaction": "0.1.51",
"@harmony-js/utils": "0.1.48"
"@woop-js/account": "0.1.58",
"@woop-js/contract": "0.1.58",
"@woop-js/crypto": "0.1.58",
"@woop-js/network": "0.1.58",
"@woop-js/staking": "0.1.58",
"@woop-js/transaction": "0.1.58",
"@woop-js/utils": "0.1.58"
},
"gitHead": "56606e9365721729a490c27d6a294e0daf90fbdf"
}

@ -1,86 +1,171 @@
/**
* ## About this package
*
* `@harmony-js/core` is collection of modules to guide user to interacte with harmony blockchian.
*
* Develops can use this package to:
* - Create a `harmony` instance
* - Create a `harmonyExtension` instance, which support fo `MathWallet`
* - Get block and transaction by hash or blocknumber
* - Send transaction
* - Get balance of address
*
* ## How to use `@harmony-core`
* ### Dependencies
* - @harmony-js/core
* - @harmony-js/utils
*
* ### Step 1: Initialize the Harmony instance
* Before using harmony-core package, you should initialize the Harmony instance
* ```javascript
* // import or require Harmony class
* const { Harmony } = require('@harmony-js/core');
* // import or require settings
* const { ChainID, ChainType } = require('@harmony-js/utils');
*
* // initialize the Harmony instance
* const hmy = new Harmony(
* // rpc url
* 'https://api.s0.b.hmny.io/',
* {
* // chainType set to Harmony
* chainType: ChainType.Harmony,
* // chainType set to HmyLocal
* chainId: ChainID.HmyLocal,
* },
* );
* ```
*
* ### Step 2: Use the instance to call specific functions
* Example 1: get balance
* ```javascript
* // get balance
* hmy.blockchain.getBalance({
* address: 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7',
* blockNumber: 'latest'
* }).then((value) => {
* console.log(value.result);
* });
* ```
*
* Example 2: send transaction
* ```
* // add privateKey to wallet
* const privateKey = '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e';
* hmy.wallet.addByPrivateKey(privateKey);
*
* async function transfer() {
* const txn = hmy.transactions.newTx({
* // token send to
* to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2',
* // amount to send
* value: '10000',
* // gas limit, you can use string
* gasLimit: '210000',
* // send token from shardID
* shardID: 0,
* // send token to toShardID
* toShardID: 0,
* // gas Price, you can use Unit class, and use Gwei, then remember to use toWei(), which will be transformed to BN
* gasPrice: new hmy.utils.Unit('100').asGwei().toWei(),
* });
*
* // sign the transaction use wallet;
* const signedTxn = await hmy.wallet.signTransaction(txn);
* const txnHash = await hmy.blockchain.sendTransaction(signedTxn);
* console.log(txnHash.result);
* }
*
* transfer();
* ```
# @woop-js/core
This package provides a collection of apis to interact with Woop blockchain.
## Installation
```
npm install @woop-js/core
```
## Usage
Create a Woop instance connecting to testnet
```javascript
* const { Woop } = require('@woop-js/core');
* const {
* ChainID,
* ChainType,
* hexToNumber,
* numberToHex,
* fromWei,
* Units,
* Unit,
* } = require('@woop-js/utils');
* const wiki = new Woop(
* 'https://api.s0.b.hmny.io/',
* {
* chainType: ChainType.Woop,
* chainId: ChainID.WikiTestnet,
* },
* );
```
Getting balance of account `one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7`
```javascript
* wiki.blockchain
* .getBalance({ address: 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7' })
* .then((response) => {
* console.log('balance in ONEs: ' + fromWei(hexToNumber(response.result), Units.one));
* });
```
Getting the latest block number
```javascript
* wiki.blockchain.getBlockNumber().then((response) => {
* console.log('current block number: ' + hexToNumber(response.result));
* });
```
Getting the block using block hash
```javascript
* wiki.blockchain
* .getBlockByHash({
* blockHash: '0x08c46ae7249362a7d1f602d44c5a81f33ebdab6a7dcb6068f99610b57911aafd',
* })
* .then((response) => {
* console.log(response.result);
* });
```
Getting the block using block number
```javascript
* wiki.blockchain
* .getBlockByNumber({
* blockNumber: numberToHex(422635),
* })
* .then((response) => {
* console.log(response.result);
* });
```
Getting the transaction using hash
```javascript
* wiki.blockchain
* .getTransactionByHash({
* txnHash: '0x56c73eb993b18dc04baacec5c2e9d1292a090f6a978a4a1c461db5255fcbc831',
* })
* .then((response) => {
* console.log(response.result);
* });
```
Getting the transaction receipt
```javascript
* wiki.blockchain
* .getTransactionReceipt({
* txnHash: '0x56c73eb993b18dc04baacec5c2e9d1292a090f6a978a4a1c461db5255fcbc831',
* })
* .then((response) => {
* console.log(response.result);
* });
```
Getting the cross-shard transaction receipt
```javascript
* wiki.blockchain
* .getCxReceiptByHash({
* txnHash: '0xcd36a90ff5d5373285c2896ba7bbcd3f5324263c0cb8ecfb7cad2f5fc2fbdbda',
* shardID: 1,
* })
* .then((value) => {
* console.log(value.result);
* });
```
Getting the deployed smart contract code
```javascript
* wiki.blockchain
* .getCode({
* address: '0x08AE1abFE01aEA60a47663bCe0794eCCD5763c19',
* blockNumber: 'latest',
* })
* .then((response) => {
* console.log(response.result);
* });
```
Getting the transaction count of an account
```javascript
* wiki.blockchain
* .getTransactionCount({
* address: 'one1pdv9lrdwl0rg5vglh4xtyrv3wjk3wsqket7zxy',
* })
* .then((response) => {
* console.log(hexToNumber(response.result));
* });
```
Getting the shard structure and details
```javascript
* wiki.blockchain.getShardingStructure().then((response) => {
* console.log(response.result);
* });
```
Transferring funds using `sendTransaction`
```javascript
// key corresponds to one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7, only has testnet balance
* wiki.wallet.addByPrivateKey('45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e');
* async function transfer() {
* const txn = wiki.transactions.newTx({
* to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2',
* value: new Unit(1).asOne().toWei(),
* // gas limit, you can use string
* gasLimit: '21000',
* // send token from shardID
* shardID: 0,
* // send token to toShardID
* toShardID: 0,
* // gas Price, you can use Unit class, and use Gwei, then remember to use toWei(), which will be transformed to BN
* gasPrice: new wiki.utils.Unit('1').asGwei().toWei(),
* });
* // sign the transaction use wallet;
* const signedTxn = await wiki.wallet.signTransaction(txn);
* const txnHash = await wiki.blockchain.sendTransaction(signedTxn);
* console.log(txnHash.result);
* }
* transfer();
```
*
* @packageDocumentation
* @module harmony-core
* @module woop-core
*/
import {
@ -92,19 +177,19 @@ import {
NewHeaders,
LogSub,
Syncing,
} from '@harmony-js/network';
} from '@woop-js/network';
import {
assertObject,
AssertType,
// HarmonyCore,
// WoopCore,
DefaultBlockParams,
} from '@harmony-js/utils';
} from '@woop-js/utils';
import { getAddress } from '@harmony-js/crypto';
import { getAddress } from '@woop-js/crypto';
import { Transaction } from '@harmony-js/transaction';
import { StakingTransaction } from '@harmony-js/staking';
import { Transaction } from '@woop-js/transaction';
import { StakingTransaction } from '@woop-js/staking';
class Blockchain {
/**
@ -156,7 +241,7 @@ class Blockchain {
*
* @example
* ```javascript
* hmy.blockchain.getBalance({
* wiki.blockchain.getBalance({
* address: 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7',
* blockNumber: 'latest'
* }).then(value => {
@ -202,7 +287,7 @@ class Blockchain {
*
* @example
* ```javascript
* hmy.blockchain.getBlockNumber().then((value) => {
* wiki.blockchain.getBlockNumber().then((value) => {
* console.log(value.result);
* });
* ```
@ -227,7 +312,7 @@ class Blockchain {
*
* @example
* ```javascript
* hmy.blockchain.getBlockByHash({
* wiki.blockchain.getBlockByHash({
* blockHash: '0x9cd821b576efdff61280e8857ef218fb2cff8db0cf0fb27dfceef7237042b79e',
* }).then((value) => {
* console.log(value);
@ -267,7 +352,7 @@ class Blockchain {
*
* @example
* ```javascript
* hmy.blockchain.getBlockByNumber({
* wiki.blockchain.getBlockByNumber({
* blockNumber: '0x89',
* }).then((value) => {
* console.log(value);
@ -297,6 +382,57 @@ class Blockchain {
return this.getRpcResult(result);
}
/**
* Returns blocks in range [from; to]
*
* @param from starting block number in 0x format
* @param to ending block number in 0x format
* @param blockArgs optional args struct in json format (should be used just with { })
* @param shardID `shardID` is binding with the endpoint, IGNORE it!
* @returns `Promise` - An array of block objects
*
* @example
* ```javascript
* wiki.blockchain.getBlocks({
* from: '0x89',
* to: '0x89',
* }).then((value) => {
* console.log(value);
* });
* ```
*/
@assertObject({
from: ['isBlockNumber', AssertType.required],
to: ['isBlockNumber', AssertType.required],
blockArgs: ['isObject', AssertType.optional],
shardID: ['isNumber', AssertType.optional],
})
async getBlocks({
from,
to,
blockArgs = {
fullTx: false,
withSigners: false,
},
shardID = this.messenger.currentShard,
}: {
from: string;
to: string;
blockArgs?: {
fullTx: boolean;
withSigners: boolean;
};
shardID?: number;
}) {
const result = await this.messenger.send(
RPCMethod.GetBlocks,
[from, to, blockArgs],
this.messenger.chainPrefix,
shardID,
);
return this.getRpcResult(result);
}
/**
* Returns the number of transaction in a given block.
*
@ -306,7 +442,7 @@ class Blockchain {
*
* @example
* ```javascript
* hmy.blockchain.getBlockTransactionCountByHash({
* wiki.blockchain.getBlockTransactionCountByHash({
* blockHash: '0x4142514a238157e7fe57b9d54abedb33943507fa15b3799954c273a12705ced1'
* }).then((value) => {
* console.log(value):
@ -342,7 +478,7 @@ class Blockchain {
*
* @example
* ```javascript
* hmy.blockchain.getBlockTransactionCountByNumber({
* wiki.blockchain.getBlockTransactionCountByNumber({
* blockNumber: '0x2403C'
* }).then((value) => {
* console.log(value);
@ -379,7 +515,7 @@ class Blockchain {
*
* @example
* ```javascript
* hmy.blockchain.getTransactionByBlockHashAndIndex({
* wiki.blockchain.getTransactionByBlockHashAndIndex({
* blockHash: '0x4142514a238157e7fe57b9d54abedb33943507fa15b3799954c273a12705ced1',
* index: '0x0'
* }).then((value) => {
@ -420,7 +556,7 @@ class Blockchain {
*
* @example
* ```javascript
* hmy.blockchain.getTransactionByBlockNumberAndIndex({
* wiki.blockchain.getTransactionByBlockNumberAndIndex({
* blockNumber: '0x2403C',
* index: '0x0'
* }).then((value) => {
@ -460,7 +596,7 @@ class Blockchain {
*
* @example
* ```javascript
* hmy.blockchain.getTransactionByHash({
* wiki.blockchain.getTransactionByHash({
* txnHash: '0x146a0cf7e8da45b44194207c4e7785564527059483b765f9a04424554443b224'
* }).then((value) => {
* console.log(value);
@ -496,7 +632,7 @@ class Blockchain {
*
* @example
* ```javascript
* hmy.blockchain.getTransactionReceipt({
* wiki.blockchain.getTransactionReceipt({
* txnHash: '0x146a0cf7e8da45b44194207c4e7785564527059483b765f9a04424554443b224'
* }).then((value) => {
* console.log(value);
@ -533,7 +669,7 @@ class Blockchain {
* @example
* ```javascript
* // This transaction sends from shard 0 to shard 1
* hmy.blockchain.getCxReceiptByHash({
* wiki.blockchain.getCxReceiptByHash({
* txnHash: '0x7fae9252fbda68d718e610bc10cf2b5c6a9cafb42d4a6b9d6e392c77d587b9ea',
* shardID: 1,
* }).then((value) => {
@ -565,7 +701,7 @@ class Blockchain {
*
* @example
* ```javascript
* hmy.blockchain.getCode({
* wiki.blockchain.getCode({
* address: '0x08AE1abFE01aEA60a47663bCe0794eCCD5763c19',
* blockNumber: 'latest'
* }).then((value) => {
@ -604,7 +740,7 @@ class Blockchain {
*
* @example
* ```javascript
* hmy.blockchain.net_peerCount().then((value) => {
* wiki.blockchain.net_peerCount().then((value) => {
* console.log(value.result);
* });
* ```
@ -623,7 +759,7 @@ class Blockchain {
*
* @example
* ```javascript
* hmy.blockchain.net_version().then((value) => {
* wiki.blockchain.net_version().then((value) => {
* console.log(value.result);
* });
* ```
@ -642,7 +778,7 @@ class Blockchain {
*
* @example
* ```javascript
* hmy.blockchain.getProtocolVersion().then((value) => {
* wiki.blockchain.getProtocolVersion().then((value) => {
* console.log(value.result);
* });
* ```
@ -667,7 +803,7 @@ class Blockchain {
*
* @example
* ```javascript
* hmy.blockchain.getStorageAt({
* wiki.blockchain.getStorageAt({
* address: 'one1d0kw95t6kkljmkk9vu0zv25jraut8ngv5vrs5g',
* position: '0x0'
* }).then((value) => {
@ -711,7 +847,7 @@ class Blockchain {
*
* @example
* ```javascript
* hmy.blockchain.getTransactionCount({
* wiki.blockchain.getTransactionCount({
* address: "one1d0kw95t6kkljmkk9vu0zv25jraut8ngv5vrs5g"
* }).then((value) => {
* console.log(value.result);
@ -748,7 +884,7 @@ class Blockchain {
*
* @example
* ```javascript
* hmy.blockchain.getShardingStructure().then((value) => {
* wiki.blockchain.getShardingStructure().then((value) => {
* console.log(value);
* });
* ```
@ -772,10 +908,10 @@ class Blockchain {
* ```javascript
* // add privateKey to wallet
* const privateKey = '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e';
* hmy.wallet.addByPrivateKey(privateKey);
* wiki.wallet.addByPrivateKey(privateKey);
*
* async function transfer() {
* const txn = hmy.transactions.newTx({
* const txn = wiki.transactions.newTx({
* // token send to
* to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2',
* // amount to send
@ -787,12 +923,12 @@ class Blockchain {
* // send token to toShardID
* toShardID: 0,
* // gas Price, you can use Unit class, and use Gwei, then remember to use toWei(), which will be transformed to BN
* gasPrice: new hmy.utils.Unit('100').asGwei().toWei(),
* gasPrice: new wiki.utils.Unit('100').asGwei().toWei(),
* });
*
* // sign the transaction use wallet;
* const signedTxn = await hmy.wallet.signTransaction(txn);
* const txnHash = await hmy.blockchain.sendTransaction(signedTxn);
* const signedTxn = await wiki.wallet.signTransaction(txn);
* const txnHash = await wiki.blockchain.sendTransaction(signedTxn);
* console.log(txnHash.result);
* }
*
@ -824,10 +960,10 @@ class Blockchain {
* ```javascript
* // add privateKey to wallet
* const privateKey = '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e';
* hmy.wallet.addByPrivateKey(privateKey);
* wiki.wallet.addByPrivateKey(privateKey);
*
* async function transfer() {
* const txn = hmy.transactions.newTx({
* const txn = wiki.transactions.newTx({
* // token send to
* to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2',
* // amount to send
@ -839,14 +975,14 @@ class Blockchain {
* // send token to toShardID
* toShardID: 0,
* // gas Price, you can use Unit class, and use Gwei, then remember to use toWei(), which will be transformed to BN
* gasPrice: new hmy.utils.Unit('100').asGwei().toWei(),
* gasPrice: new wiki.utils.Unit('100').asGwei().toWei(),
* });
*
* // sign the transaction use wallet;
* const signedTxn = await hmy.wallet.signTransaction(txn);
* const signedTxn = await wiki.wallet.signTransaction(txn);
* recovered = signedTxn.recover(signedTxn.rawTransaction);
*
* const txnHash = await hmy.blockchain.sendRawTransaction(recovered);
* const txnHash = await wiki.blockchain.sendRawTransaction(recovered);
* console.log(txnHash);
* }
*
@ -873,10 +1009,10 @@ class Blockchain {
* ```javascript
* // add privateKey to wallet
* const privateKey = '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e';
* hmy.wallet.addByPrivateKey(privateKey);
* wiki.wallet.addByPrivateKey(privateKey);
*
* async function transfer() {
* const txn = hmy.transactions.newTx({
* const txn = wiki.transactions.newTx({
* // token send to
* to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2',
* // amount to send
@ -888,12 +1024,12 @@ class Blockchain {
* // send token to toShardID
* toShardID: 0,
* // gas Price, you can use Unit class, and use Gwei, then remember to use toWei(), which will be transformed to BN
* gasPrice: new hmy.utils.Unit('100').asGwei().toWei(),
* gasPrice: new wiki.utils.Unit('100').asGwei().toWei(),
* });
*
* // sign the transaction use wallet;
* const signedTxn = await hmy.wallet.signTransaction(txn);
* const txnHash = await hmy.blockchain.createObservedTransaction(signedTxn);
* const signedTxn = await wiki.wallet.signTransaction(txn);
* const txnHash = await wiki.blockchain.createObservedTransaction(signedTxn);
* console.log(txnHash);
* }
*
@ -972,12 +1108,12 @@ class Blockchain {
*
* @warning
* ```
* At present, this function hmy_estimateGas is not implement yet, will Coming soon!!!
* At present, this function wiki_estimateGas is not implement yet, will Coming soon!!!
* ```
*
* @example
* ```javascript
* hmy.blockchain.estimateGas({
* wiki.blockchain.estimateGas({
* to: 'one1d0kw95t6kkljmkk9vu0zv25jraut8ngv5vrs5g',
* data: '0xc6888fa10000000000000000000000000000000000000000000000000000000000000003'
* }).then((value) => {
@ -1016,7 +1152,7 @@ class Blockchain {
*
* @example
* ```javascript
* hmy.blockchain.gasPrice().then((value) => {
* wiki.blockchain.gasPrice().then((value) => {
* console.log(value);
* });
* ```
@ -1041,7 +1177,7 @@ class Blockchain {
*
* @example
* ```javascript
* hmy.blockchain.call({
* wiki.blockchain.call({
* to: "0x08AE1abFE01aEA60a47663bCe0794eCCD5763c19",
* }).then((value) => {
* console.log(value);
@ -1073,18 +1209,18 @@ class Blockchain {
*
* @example
* ```javascript
* const hmy = new Harmony(
* const wiki = new Woop(
* // rpc url
* 'ws://api.s0.b.hmny.io/',
* {
* // chainType set to Harmony
* chainType: ChainType.Harmony,
* // chainType set to HmyLocal
* chainId: ChainID.HmyLocal,
* // chainType set to Woop
* chainType: ChainType.Woop,
* // chainType set to WikiLocal
* chainId: ChainID.WikiLocal,
* },
* );
*
* const tmp = hmy.blockchain.newPendingTransactions();
* const tmp = wiki.blockchain.newPendingTransactions();
* console.log(tmp)
* ```
*/
@ -1102,18 +1238,18 @@ class Blockchain {
*
* @example
* ```javascript
* const hmy = new Harmony(
* const wiki = new Woop(
* // rpc url
* 'ws://api.s0.b.hmny.io/',
* {
* // chainType set to Harmony
* chainType: ChainType.Harmony,
* // chainType set to HmyLocal
* chainId: ChainID.HmyLocal,
* // chainType set to Woop
* chainType: ChainType.Woop,
* // chainType set to WikiLocal
* chainId: ChainID.WikiLocal,
* },
* );
*
* const tmp = hmy.blockchain.newBlockHeaders();
* const tmp = wiki.blockchain.newBlockHeaders();
* console.log(tmp)
* ```
*/
@ -1131,18 +1267,18 @@ class Blockchain {
*
* @example
* ```javascript
* const hmy = new Harmony(
* const wiki = new Woop(
* // rpc url
* 'ws://api.s0.b.hmny.io/',
* {
* // chainType set to Harmony
* chainType: ChainType.Harmony,
* // chainType set to HmyLocal
* chainId: ChainID.HmyLocal,
* // chainType set to Woop
* chainType: ChainType.Woop,
* // chainType set to WikiLocal
* chainId: ChainID.WikiLocal,
* },
* );
*
* const tmp = hmy.blockchain.syncing();
* const tmp = wiki.blockchain.syncing();
* console.log(tmp)
* ```
*/
@ -1160,18 +1296,18 @@ class Blockchain {
*
* @example
* ```javascript
* const hmy = new Harmony(
* const wiki = new Woop(
* // rpc url
* 'ws://api.s0.b.hmny.io/',
* {
* // chainType set to Harmony
* chainType: ChainType.Harmony,
* // chainType set to HmyLocal
* chainId: ChainID.HmyLocal,
* // chainType set to Woop
* chainType: ChainType.Woop,
* // chainType set to WikiLocal
* chainId: ChainID.WikiLocal,
* },
* );
*
* const tmp = hmy.blockchain.logs({
* const tmp = wiki.blockchain.logs({
* from: '0x12'
* });
* console.log(tmp)

@ -1,11 +1,11 @@
/**
* @packageDocumentation
* @module harmony-core
* @module woop-core
* @hidden
*/
export * from './harmony';
export * from './woop';
export * from './blockchain';
export * from './truffleProvider';
export * from './harmonyExtension';
export * from './woopExtension';
export * from './types';

@ -1,6 +1,6 @@
/**
* @packageDocumentation
* @module harmony-core
* @module woop-core
* @hidden
*/
@ -9,11 +9,11 @@ import {
WSProvider,
RPCRequestPayload,
ResponseMiddleware,
} from '@harmony-js/network';
} from '@woop-js/network';
import { ChainID, ChainType, Unit, isBech32Address } from '@harmony-js/utils';
import { HDNode } from '@harmony-js/account';
import { fromBech32, HRP } from '@harmony-js/crypto';
import { ChainID, ChainType, Unit, isBech32Address } from '@woop-js/utils';
import { HDNode } from '@woop-js/account';
import { fromBech32, HRP } from '@woop-js/crypto';
const packageInfo = { version: '1.0.0' };
@ -52,8 +52,8 @@ export class TruffleProvider extends HDNode {
},
chainOptions: ChainOptions = {
shardID: 0,
chainType: ChainType.Harmony,
chainId: ChainID.HmyLocal,
chainType: ChainType.Woop,
chainId: ChainID.WikiLocal,
},
transactionOptions: TransactionOptions = {
gasLimit: '10000000',
@ -76,7 +76,7 @@ export class TruffleProvider extends HDNode {
const { newArgs, id, params, newMethod, callback } = this.resolveArgs(...args);
switch (newMethod) {
case 'hmy_accounts': {
case 'wiki_accounts': {
const accounts = this.getAccounts();
callback(null, {
result: accounts,
@ -90,13 +90,13 @@ export class TruffleProvider extends HDNode {
};
// break;
}
case 'hmy_sendTransaction': {
case 'wiki_sendTransaction': {
const txObj = params[0];
const rawTxn = await this.signTransaction(txObj);
const result = await this.provider.send(
{
id,
method: 'hmy_sendRawTransaction',
method: 'wiki_sendRawTransaction',
params: [rawTxn],
jsonrpc: '2.0',
},
@ -106,11 +106,11 @@ export class TruffleProvider extends HDNode {
// break;
}
case 'hmy_getTransactionReceipt': {
case 'wiki_getTransactionReceipt': {
const result = await this.provider.send(
{
id,
method: 'hmy_getTransactionReceipt',
method: 'wiki_getTransactionReceipt',
params: [params[0]],
jsonrpc: '2.0',
},
@ -146,23 +146,27 @@ export class TruffleProvider extends HDNode {
}
case 'web3_clientVersion': {
callback(null, {
result: `Harmony/${packageInfo.version}/@harmony-js`,
result: `Woop/${packageInfo.version}/@woop-js`,
id,
jsonrpc: '2.0',
});
return {
result: `Harmony/${packageInfo.version}/@harmony-js`,
result: `Woop/${packageInfo.version}/@woop-js`,
id,
jsonrpc: '2.0',
};
}
case 'hmy_getBlockByNumber': {
case 'wiki_getBlockByNumber': {
const result = await this.provider.send(newArgs, (err: any, res: any) => {
try {
if (err) {
callback(err);
}
const response = this.resolveResult(res);
if (response.error) {
callback(response.error);
return;
}
if (
new Unit(response.result.gasLimit)
@ -187,7 +191,7 @@ export class TruffleProvider extends HDNode {
}
default: {
// hmy_getBlockByNumber
// wiki_getBlockByNumber
const result = await this.provider.send(
newArgs,
@ -209,7 +213,7 @@ export class TruffleProvider extends HDNode {
const params = args[0].params;
let newMethod: string = method;
if (method.startsWith('eth')) {
newMethod = method.replace('eth', 'hmy');
newMethod = method.replace('eth', 'wiki');
}
args[0].method = newMethod;

@ -0,0 +1,31 @@
/**
* @packageDocumentation
* @module woop-core
* @hidden
*/
import { HttpProvider, Messenger } from '@woop-js/network';
import { TransactionFactory, Transaction } from '@woop-js/transaction';
import { Wallet, Account } from '@woop-js/account';
import { ChainType, ChainID } from '@woop-js/utils';
import { Blockchain } from './blockchain';
export interface WoopModule {
HttpProvider: HttpProvider;
Messenger: Messenger;
Blockchain: Blockchain;
TransactionFactory: TransactionFactory;
Wallet: Wallet;
Transaction: Transaction;
Account: Account;
}
export enum UrlType {
http,
ws,
}
export interface WoopSetting<T extends ChainType, I extends ChainID> {
type: T;
id: I;
}

@ -1,13 +1,13 @@
/**
* @packageDocumentation
* @module harmony-core
* @module woop-core
* @hidden
*/
import { ChainType, ChainID, defaultConfig } from '@harmony-js/utils';
import { Harmony } from './harmony';
import { ChainType, ChainID, defaultConfig } from '@woop-js/utils';
import { Woop } from './woop';
export interface HarmonyConfig {
export interface WoopConfig {
chainUrl?: string;
chainType: ChainType;
chainId: ChainID;
@ -17,18 +17,18 @@ export interface HarmonyConfig {
// tslint:disable-next-line: variable-name
export function createWeb3(_web3: any) {
const url: string = _web3.currentProvider.url;
const harmony = new Harmony(url, {
const woop = new Woop(url, {
chainId: defaultConfig.Default.Chain_ID,
chainType: defaultConfig.Default.Chain_Type,
chainUrl: defaultConfig.Default.Chain_URL,
});
_web3.setProvider(harmony.messenger.provider);
_web3.messenger = harmony.messenger;
_web3.eth.getRpcResult = harmony.blockchain.getRpcResult;
_web3.setProvider(woop.messenger.provider);
_web3.messenger = woop.messenger;
_web3.eth.getRpcResult = woop.blockchain.getRpcResult;
// map blockchain to eth
const { blockchain } = harmony;
const { blockchain } = woop;
_web3.eth.getBlockNumber = () => blockchain.getBlockByNumber;
_web3.eth.getBalance = (address: string, blockNumber?: string) =>
blockchain.getBalance({ address, blockNumber });
@ -67,31 +67,31 @@ export function createWeb3(_web3: any) {
_web3.eth.logs = (options: any) => blockchain.logs(options);
// map subscribe to _web3
_web3.eth.subscribe = harmony.messenger.subscribe;
_web3.eth.subscribe = woop.messenger.subscribe;
// map accounts to _web3
_web3.accounts = harmony.wallet.accounts;
_web3.eth.accounts.create = harmony.wallet.createAccount;
_web3.eth.accounts.privateKeyToAccount = harmony.wallet.addByPrivateKey;
_web3.accounts = woop.wallet.accounts;
_web3.eth.accounts.create = woop.wallet.createAccount;
_web3.eth.accounts.privateKeyToAccount = woop.wallet.addByPrivateKey;
_web3.eth.accounts.encrypt = async (privateKey: string, password: string) => {
const newAcc = new harmony.Modules.Account(privateKey, harmony.messenger);
const newAcc = new woop.Modules.Account(privateKey, woop.messenger);
const result = await newAcc.toFile(password);
return result;
};
_web3.eth.accounts.decrypt = async (keystoreJsonV3: any, password: string) => {
const newAcc = new harmony.Modules.Account();
const newAcc = new woop.Modules.Account();
const result = await newAcc.fromFile(JSON.stringify(keystoreJsonV3), password);
return result;
};
_web3.eth.accounts.signTransaction = harmony.wallet.signTransaction;
_web3.eth.accounts.signTransaction = woop.wallet.signTransaction;
// map transaction to web3
_web3.eth.recoverTransaction = harmony.transactions.recover;
_web3.eth.recoverTransaction = woop.transactions.recover;
// map contract to web3
_web3.eth.Contract = harmony.contracts.createContract;
_web3.eth.Contract = woop.contracts.createContract;
_web3.utils = { ..._web3.utils, ...harmony.utils, ...harmony.crypto };
_web3.utils = { ..._web3.utils, ...woop.utils, ...woop.crypto };
}

@ -1,20 +1,20 @@
/**
* @packageDocumentation
* @module harmony-core
* @module woop-core
*/
import * as crypto from '@harmony-js/crypto';
import * as utils from '@harmony-js/utils';
import * as crypto from '@woop-js/crypto';
import * as utils from '@woop-js/utils';
import { Provider, HttpProvider, Messenger, WSProvider, ShardingItem } from '@harmony-js/network';
import { TransactionFactory, Transaction } from '@harmony-js/transaction';
import { StakingTransaction, StakingFactory } from '@harmony-js/staking';
import { ContractFactory, Contract } from '@harmony-js/contract';
import { Wallet, Account } from '@harmony-js/account';
import { Provider, HttpProvider, Messenger, WSProvider, ShardingItem } from '@woop-js/network';
import { TransactionFactory, Transaction } from '@woop-js/transaction';
import { StakingTransaction, StakingFactory } from '@woop-js/staking';
import { ContractFactory, Contract } from '@woop-js/contract';
import { Wallet, Account } from '@woop-js/account';
import { Blockchain } from './blockchain';
import { HarmonyConfig } from './util';
import { WoopConfig } from './util';
export class Harmony extends utils.HarmonyCore {
export class Woop extends utils.WoopCore {
/**@ignore*/
Modules = {
HttpProvider,
@ -51,38 +51,38 @@ export class Harmony extends utils.HarmonyCore {
private provider: HttpProvider | WSProvider;
/**
* Create a harmony instance
* Create a woop instance
*
* @param url The end-points of the hmy blockchain
* @param url The end-points of the wiki blockchain
* @param config set up `ChainID` and `ChainType`, typically we can use the default values
*
* @example
* ```
* // import or require Harmony class
* const { Harmony } = require('@harmony-js/core');
* // import or require Woop class
* const { Woop } = require('@woop-js/core');
*
* // import or require settings
* const { ChainID, ChainType } = require('@harmony-js/utils');
* const { ChainID, ChainType } = require('@woop-js/utils');
*
* // Initialize the Harmony instance
* const hmy = new Harmony(
* // Initialize the Woop instance
* const wiki = new Woop(
* // rpc url:
* // local: http://localhost:9500
* // testnet: https://api.s0.b.hmny.io/
* // mainnet: https://api.s0.t.hmny.io/
* 'http://localhost:9500',
* {
* // chainType set to Harmony
* chainType: ChainType.Harmony,
* // chainType set to HmyLocal
* chainId: ChainID.HmyLocal,
* // chainType set to Woop
* chainType: ChainType.Woop,
* // chainType set to WikiLocal
* chainId: ChainID.WikiLocal,
* },
* );
* ```
*/
constructor(
url: string,
config: HarmonyConfig = {
config: WoopConfig = {
chainId: utils.defaultConfig.Default.Chain_ID,
chainType: utils.defaultConfig.Default.Chain_Type,
},
@ -113,7 +113,7 @@ export class Harmony extends utils.HarmonyCore {
*
* @example
* ```javascript
* const tmp = hmy.setProvider('http://localhost:9500');
* const tmp = wiki.setProvider('http://localhost:9500');
* ```
*/
public setProvider(provider: string | HttpProvider | WSProvider): void {
@ -139,16 +139,16 @@ export class Harmony extends utils.HarmonyCore {
EtcTestnet = 62,
Geth = 1337,
Ganache = 0,
HmyMainnet = 1,
HmyTestnet = 2,
HmyLocal = 2,
HmyPangaea = 3
WikiMainnet = 1,
WikiTestnet = 2,
WikiLocal = 2,
WikiPangaea = 3
* ```
* @param chainId
*
* @example
* ```
* hmy.setChainId(2);
* wiki.setChainId(2);
* ```
*/
public setChainId(chainId: utils.ChainID) {
@ -162,7 +162,7 @@ export class Harmony extends utils.HarmonyCore {
*
* @example
* ```
* hmy.setShardID(2);
* wiki.setShardID(2);
* ```
*/
public setShardID(shardID: number) {
@ -174,14 +174,14 @@ export class Harmony extends utils.HarmonyCore {
/**
* set the chainType
*
* @param chainType `hmy` or `eth`
* @param chainType `wiki` or `eth`
*
* @example
* ```
* // set chainType to hmy
* hmy.setChainType('hmy');
* // set chainType to wiki
* wiki.setChainType('wiki');
* // set chainType to eth
* hmy.setChainType('eth');
* wiki.setChainType('eth');
* ```
*/
public setChainType(chainType: utils.ChainType) {
@ -197,7 +197,7 @@ export class Harmony extends utils.HarmonyCore {
*
* @example
* ```javascript
* hmy.shardingStructures([
* wiki.shardingStructures([
* {"current":true,"http":"http://127.0.0.1:9500",
* "shardID":0,"ws":"ws://127.0.0.1:9800"},
* {"current":false,"http":"http://127.0.0.1:9501",

@ -1,6 +1,6 @@
/**
* @packageDocumentation
* @module harmony-core
* @module woop-core
*/
import {
@ -10,15 +10,15 @@ import {
Provider,
RPCMethod,
ShardingItem,
} from '@harmony-js/network';
} from '@woop-js/network';
import * as crypto from '@harmony-js/crypto';
import * as utils from '@harmony-js/utils';
import * as crypto from '@woop-js/crypto';
import * as utils from '@woop-js/utils';
import { Transaction, TransactionFactory } from '@harmony-js/transaction';
import { Transaction, TransactionFactory } from '@woop-js/transaction';
import { Blockchain } from './blockchain';
import { ContractFactory } from '@harmony-js/contract';
import { HarmonyConfig } from './util';
import { ContractFactory } from '@woop-js/contract';
import { WoopConfig } from './util';
/** @hidden */
export enum ExtensionType {
@ -55,7 +55,7 @@ export interface ExtensionInterface {
network: ExtensionNetwork;
}
export class HarmonyExtension {
export class WoopExtension {
/**@ignore*/
extensionType: ExtensionType | null;
/**@ignore*/
@ -87,17 +87,17 @@ export class HarmonyExtension {
* ```javascript
* // Using Mathwallet instance
* export const initEx = async() => {
* hmyEx = new HarmonyExtension(window.harmony);
* wikiEx = new WoopExtension(window.woop);
* }
* // Using OneWallet instance
* export const initEx = async() => {
* hmyEx = new HarmonyExtension(window.onewallet);
* wikiEx = new WoopExtension(window.onewallet);
* }
* ```
*/
constructor(
wallet: ExtensionInterface,
config: HarmonyConfig = {
config: WoopConfig = {
chainId: utils.defaultConfig.Default.Chain_ID,
chainType: utils.defaultConfig.Default.Chain_Type,
},
@ -129,7 +129,7 @@ export class HarmonyExtension {
*
* @example
* ```javascript
* const tmp = hmyEx.setProvider('http://localhost:9500');
* const tmp = wikiEx.setProvider('http://localhost:9500');
* ```
*/
public setProvider(provider: string | HttpProvider | WSProvider): void {
@ -143,7 +143,7 @@ export class HarmonyExtension {
*
* @example
* ```
* hmyEx.setShardID(2);
* wikiEx.setShardID(2);
* ```
*/
public setShardID(shardID: number) {
@ -172,7 +172,7 @@ export class HarmonyExtension {
if (updateNonce) {
const nonce = await this.messenger.send(
RPCMethod.GetTransactionCount,
RPCMethod.GetAccountNonce,
[crypto.getAddress(extensionAccount.address).checksum, blockNumber],
this.messenger.chainPrefix,
typeof transaction.txParams.shardID === 'string'
@ -182,7 +182,7 @@ export class HarmonyExtension {
transaction.setParams({
...transaction.txParams,
from: crypto.getAddress(extensionAccount.address).bech32,
nonce: Number.parseInt(utils.hexToNumber(nonce.result), 10),
nonce: Number.parseInt(utils.isHex(nonce.result.toString()) ? utils.hexToNumber(nonce.result.toString()) : nonce.result.toString(), 10),
});
} else {
transaction.setParams({
@ -205,7 +205,7 @@ export class HarmonyExtension {
*
* @example
* ```javascript
* const account = hmyEx.login();
* const account = wikiEx.login();
* console.log(account);
* ```
*/
@ -220,7 +220,7 @@ export class HarmonyExtension {
*
* @example
* ```javascript
* hmyEx.logout();
* wikiEx.logout();
* ```
*/
public async logout() {
@ -234,7 +234,7 @@ export class HarmonyExtension {
*
* @example
* ```javascript
* hmyEx.shardingStructures([
* wikiEx.shardingStructures([
* {"current":true,"http":"http://127.0.0.1:9500",
* "shardID":0,"ws":"ws://127.0.0.1:9800"},
* {"current":false,"http":"http://127.0.0.1:9501",

@ -6,18 +6,18 @@
// tslint:disable-next-line: no-implicit-dependencies
import fetch from 'jest-fetch-mock';
import { Blockchain } from '../src/blockchain';
import { HttpProvider, Messenger } from '@harmony-js/network';
import { HttpProvider, Messenger } from '@woop-js/network';
const provider = new HttpProvider('https://mock.com');
const messenger = new Messenger(provider);
function runMocks(mockRpcResponse: any, repeat: number): void {
const mocks = [];
const mocks: any = [];
for (let i = 0; i < 5; i++) {
mocks.push(mockRpcResponse);
}
// tslint:disable-next-line: no-shadowed-variable
const responses = mocks.map((res) => [JSON.stringify(res)]);
const responses = mocks.map((res: any) => [JSON.stringify(res), {status: 200}]);
fetch.mockResponses(...responses);
}

@ -0,0 +1,16 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "dist"
},
"include": ["src", "../../typings/**/*.d.ts", "../woop-utils/src/core.ts"],
"references": [
{"path": "../woop-account"},
{"path": "../woop-crypto"},
{"path": "../woop-utils"},
{"path": "../woop-network"},
{"path": "../woop-transaction"},
{"path": "../woop-contract"}
]
}

@ -1,11 +1,11 @@
# @harmony-js/crypto
# @woop-js/crypto
This package provides a collection of apis related to address management, kestore, encoding, and encrypt/decrypt.
## Installation
```
npm install @harmony-js/crypto
npm install @woop-js/crypto
```
## Usage
@ -17,26 +17,26 @@ const {
randomBytes,
toBech32,
fromBech32,
HarmonyAddress,
WoopAddress,
generatePrivateKey,
getPubkeyFromPrivateKey,
getAddressFromPublicKey,
getAddressFromPrivateKey,
encryptPhrase,
decryptPhrase
} = require('@harmony-js/crypto');
const { isPrivateKey, isAddress, isPublicKey } = require('@harmony-js/utils');
} = require('@woop-js/crypto');
const { isPrivateKey, isAddress, isPublicKey } = require('@woop-js/utils');
```
Address apis
```javascript
const bytes = randomBytes(20);
const addr = new HarmonyAddress(bytes);
const addr = new WoopAddress(bytes);
console.log(addr.checksum);
console.log(addr.bech32);
console.log(HarmonyAddress.isValidBech32(addr.bech32));
console.log(WoopAddress.isValidBech32(addr.bech32));
```
RLP apis
@ -61,7 +61,7 @@ console.log(isAddress(addrPrv));
Encrypt/decrypt apis
```javascript
const { Wallet } = require('@harmony-js/account');
const { Wallet } = require('@woop-js/account');
const myPhrase = new Wallet().newMnemonic();
console.log(myPhrase);

@ -0,0 +1,782 @@
{
"name": "@woop-js/crypto",
"version": "0.1.58",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@woop-js/crypto",
"version": "0.1.56",
"license": "MIT",
"dependencies": {
"@woop-js/utils": "0.1.56",
"aes-js": "^3.1.2",
"bip39": "^2.5.0",
"bn.js": "^4.11.8",
"elliptic": "^6.4.1",
"hdkey": "^1.1.1",
"hmac-drbg": "^1.0.1",
"js-sha3": "^0.8.0",
"pbkdf2": "^3.0.17",
"scrypt.js": "^0.3.0",
"uuid": "^3.3.2"
}
},
"node_modules/@woop-js/utils": {
"version": "0.1.56",
"resolved": "https://registry.npmjs.org/@woop-js/utils/-/utils-0.1.56.tgz",
"integrity": "sha512-XoYYIMoK/mSxPkxFd25dY/wScIWWevoTrHoFdlFd8N7GWlilfdgQEF5vO+4BA6hyDJ4ryfdLnGc6W6Hz+5qs2A==",
"dependencies": {
"@types/bn.js": "^4.11.3",
"bn.js": "^4.11.8"
}
},
"node_modules/@types/bn.js": {
"version": "4.11.6",
"resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-4.11.6.tgz",
"integrity": "sha512-pqr857jrp2kPuO9uRjZ3PwnJTjoQy+fcdxvBTvHm6dkmEL9q+hDD/2j/0ELOBPtPnS8LjCX0gI9nbl8lVkadpg==",
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@types/node": {
"version": "14.11.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.11.2.tgz",
"integrity": "sha512-jiE3QIxJ8JLNcb1Ps6rDbysDhN4xa8DJJvuC9prr6w+1tIh+QAbYyNF3tyiZNLDBIuBCf4KEcV2UvQm/V60xfA=="
},
"node_modules/aes-js": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.1.2.tgz",
"integrity": "sha512-e5pEa2kBnBOgR4Y/p20pskXI74UEz7de8ZGVo58asOtvSVG5YAbJeELPZxOmt+Bnz3rX753YKhfIn4X4l1PPRQ=="
},
"node_modules/base-x": {
"version": "3.0.8",
"resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.8.tgz",
"integrity": "sha512-Rl/1AWP4J/zRrk54hhlxH4drNxPJXYUaKffODVI53/dAsV4t9fBxyxYKAVPU1XBHxYwOWP9h9H0hM2MVw4YfJA==",
"dependencies": {
"safe-buffer": "^5.0.1"
}
},
"node_modules/bindings": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz",
"integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==",
"dependencies": {
"file-uri-to-path": "1.0.0"
}
},
"node_modules/bip39": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/bip39/-/bip39-2.6.0.tgz",
"integrity": "sha512-RrnQRG2EgEoqO24ea+Q/fftuPUZLmrEM3qNhhGsA3PbaXaCW791LTzPuVyx/VprXQcTbPJ3K3UeTna8ZnVl2sg==",
"dependencies": {
"create-hash": "^1.1.0",
"pbkdf2": "^3.0.9",
"randombytes": "^2.0.1",
"safe-buffer": "^5.0.1",
"unorm": "^1.3.3"
}
},
"node_modules/bip66": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/bip66/-/bip66-1.1.5.tgz",
"integrity": "sha1-AfqHSHhcpwlV1QESF9GzE5lpyiI=",
"dependencies": {
"safe-buffer": "^5.0.1"
}
},
"node_modules/bn.js": {
"version": "4.11.8",
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz",
"integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA=="
},
"node_modules/brorand": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz",
"integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8="
},
"node_modules/browserify-aes": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz",
"integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==",
"dependencies": {
"buffer-xor": "^1.0.3",
"cipher-base": "^1.0.0",
"create-hash": "^1.1.0",
"evp_bytestokey": "^1.0.3",
"inherits": "^2.0.1",
"safe-buffer": "^5.0.1"
}
},
"node_modules/bs58": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz",
"integrity": "sha1-vhYedsNU9veIrkBx9j806MTwpCo=",
"dependencies": {
"base-x": "^3.0.2"
}
},
"node_modules/bs58check": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/bs58check/-/bs58check-2.1.2.tgz",
"integrity": "sha512-0TS1jicxdU09dwJMNZtVAfzPi6Q6QeN0pM1Fkzrjn+XYHvzMKPU3pHVpva+769iNVSfIYWf7LJ6WR+BuuMf8cA==",
"dependencies": {
"bs58": "^4.0.0",
"create-hash": "^1.1.0",
"safe-buffer": "^5.1.2"
}
},
"node_modules/buffer-xor": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz",
"integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk="
},
"node_modules/cipher-base": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz",
"integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==",
"dependencies": {
"inherits": "^2.0.1",
"safe-buffer": "^5.0.1"
}
},
"node_modules/create-hash": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz",
"integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==",
"dependencies": {
"cipher-base": "^1.0.1",
"inherits": "^2.0.1",
"md5.js": "^1.3.4",
"ripemd160": "^2.0.1",
"sha.js": "^2.4.0"
}
},
"node_modules/create-hmac": {
"version": "1.1.7",
"resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz",
"integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==",
"dependencies": {
"cipher-base": "^1.0.3",
"create-hash": "^1.1.0",
"inherits": "^2.0.1",
"ripemd160": "^2.0.0",
"safe-buffer": "^5.0.1",
"sha.js": "^2.4.8"
}
},
"node_modules/drbg.js": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/drbg.js/-/drbg.js-1.0.1.tgz",
"integrity": "sha1-Pja2xCs3BDgjzbwzLVjzHiRFSAs=",
"dependencies": {
"browserify-aes": "^1.0.6",
"create-hash": "^1.1.2",
"create-hmac": "^1.1.4"
},
"engines": {
"node": ">=0.10"
}
},
"node_modules/elliptic": {
"version": "6.5.3",
"resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.3.tgz",
"integrity": "sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==",
"dependencies": {
"bn.js": "^4.4.0",
"brorand": "^1.0.1",
"hash.js": "^1.0.0",
"hmac-drbg": "^1.0.0",
"inherits": "^2.0.1",
"minimalistic-assert": "^1.0.0",
"minimalistic-crypto-utils": "^1.0.0"
}
},
"node_modules/evp_bytestokey": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz",
"integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==",
"dependencies": {
"md5.js": "^1.3.4",
"safe-buffer": "^5.1.1"
}
},
"node_modules/file-uri-to-path": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
"integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw=="
},
"node_modules/hash-base": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.1.0.tgz",
"integrity": "sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA==",
"dependencies": {
"inherits": "^2.0.4",
"readable-stream": "^3.6.0",
"safe-buffer": "^5.2.0"
},
"engines": {
"node": ">=4"
}
},
"node_modules/hash.js": {
"version": "1.1.7",
"resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz",
"integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==",
"dependencies": {
"inherits": "^2.0.3",
"minimalistic-assert": "^1.0.1"
}
},
"node_modules/hdkey": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/hdkey/-/hdkey-1.1.2.tgz",
"integrity": "sha512-PTQ4VKu0oRnCrYfLp04iQZ7T2Cxz0UsEXYauk2j8eh6PJXCpbXuCFhOmtIFtbET0i3PMWmHN9J11gU8LEgUljQ==",
"dependencies": {
"bs58check": "^2.1.2",
"safe-buffer": "^5.1.1",
"secp256k1": "^3.0.1"
}
},
"node_modules/hmac-drbg": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz",
"integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=",
"dependencies": {
"hash.js": "^1.0.3",
"minimalistic-assert": "^1.0.0",
"minimalistic-crypto-utils": "^1.0.1"
}
},
"node_modules/inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
},
"node_modules/js-sha3": {
"version": "0.8.0",
"resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.8.0.tgz",
"integrity": "sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q=="
},
"node_modules/md5.js": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz",
"integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==",
"dependencies": {
"hash-base": "^3.0.0",
"inherits": "^2.0.1",
"safe-buffer": "^5.1.2"
}
},
"node_modules/minimalistic-assert": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz",
"integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A=="
},
"node_modules/minimalistic-crypto-utils": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz",
"integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo="
},
"node_modules/nan": {
"version": "2.14.1",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.14.1.tgz",
"integrity": "sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw=="
},
"node_modules/pbkdf2": {
"version": "3.0.17",
"resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.17.tgz",
"integrity": "sha512-U/il5MsrZp7mGg3mSQfn742na2T+1/vHDCG5/iTI3X9MKUuYUZVLQhyRsg06mCgDBTd57TxzgZt7P+fYfjRLtA==",
"dependencies": {
"create-hash": "^1.1.2",
"create-hmac": "^1.1.4",
"ripemd160": "^2.0.1",
"safe-buffer": "^5.0.1",
"sha.js": "^2.4.8"
},
"engines": {
"node": ">=0.12"
}
},
"node_modules/randombytes": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz",
"integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==",
"dependencies": {
"safe-buffer": "^5.1.0"
}
},
"node_modules/readable-stream": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",
"integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==",
"dependencies": {
"inherits": "^2.0.3",
"string_decoder": "^1.1.1",
"util-deprecate": "^1.0.1"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/ripemd160": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz",
"integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==",
"dependencies": {
"hash-base": "^3.0.0",
"inherits": "^2.0.1"
}
},
"node_modules/safe-buffer": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz",
"integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg=="
},
"node_modules/scrypt.js": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/scrypt.js/-/scrypt.js-0.3.0.tgz",
"integrity": "sha512-42LTc1nyFsyv/o0gcHtDztrn+aqpkaCNt5Qh7ATBZfhEZU7IC/0oT/qbBH+uRNoAPvs2fwiOId68FDEoSRA8/A==",
"dependencies": {
"scryptsy": "^1.2.1"
},
"optionalDependencies": {
"scrypt": "^6.0.2"
}
},
"node_modules/scryptsy": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/scryptsy/-/scryptsy-1.2.1.tgz",
"integrity": "sha512-aldIRgMozSJ/Gl6K6qmJZysRP82lz83Wb42vl4PWN8SaLFHIaOzLPc9nUUW2jQN88CuGm5q5HefJ9jZ3nWSmTw==",
"dependencies": {
"pbkdf2": "^3.0.3"
}
},
"node_modules/secp256k1": {
"version": "3.8.0",
"resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-3.8.0.tgz",
"integrity": "sha512-k5ke5avRZbtl9Tqx/SA7CbY3NF6Ro+Sj9cZxezFzuBlLDmyqPiL8hJJ+EmzD8Ig4LUDByHJ3/iPOVoRixs/hmw==",
"hasInstallScript": true,
"dependencies": {
"bindings": "^1.5.0",
"bip66": "^1.1.5",
"bn.js": "^4.11.8",
"create-hash": "^1.2.0",
"drbg.js": "^1.0.1",
"elliptic": "^6.5.2",
"nan": "^2.14.0",
"safe-buffer": "^5.1.2"
},
"engines": {
"node": ">=4.0.0"
}
},
"node_modules/sha.js": {
"version": "2.4.11",
"resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz",
"integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==",
"dependencies": {
"inherits": "^2.0.1",
"safe-buffer": "^5.0.1"
},
"bin": {
"sha.js": "bin.js"
}
},
"node_modules/string_decoder": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz",
"integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==",
"dependencies": {
"safe-buffer": "~5.2.0"
}
},
"node_modules/unorm": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/unorm/-/unorm-1.6.0.tgz",
"integrity": "sha512-b2/KCUlYZUeA7JFUuRJZPUtr4gZvBh7tavtv4fvk4+KV9pfGiR6CQAQAWl49ZpR3ts2dk4FYkP7EIgDJoiOLDA==",
"engines": {
"node": ">= 0.4.0"
}
},
"node_modules/util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
},
"node_modules/uuid": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
"deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.",
"bin": {
"uuid": "bin/uuid"
}
}
},
"dependencies": {
"@woop-js/utils": {
"version": "0.1.56",
"resolved": "https://registry.npmjs.org/@woop-js/utils/-/utils-0.1.56.tgz",
"integrity": "sha512-XoYYIMoK/mSxPkxFd25dY/wScIWWevoTrHoFdlFd8N7GWlilfdgQEF5vO+4BA6hyDJ4ryfdLnGc6W6Hz+5qs2A==",
"requires": {
"@types/bn.js": "^4.11.3",
"bn.js": "^4.11.8"
}
},
"@types/bn.js": {
"version": "4.11.6",
"resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-4.11.6.tgz",
"integrity": "sha512-pqr857jrp2kPuO9uRjZ3PwnJTjoQy+fcdxvBTvHm6dkmEL9q+hDD/2j/0ELOBPtPnS8LjCX0gI9nbl8lVkadpg==",
"requires": {
"@types/node": "*"
}
},
"@types/node": {
"version": "14.11.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.11.2.tgz",
"integrity": "sha512-jiE3QIxJ8JLNcb1Ps6rDbysDhN4xa8DJJvuC9prr6w+1tIh+QAbYyNF3tyiZNLDBIuBCf4KEcV2UvQm/V60xfA=="
},
"aes-js": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.1.2.tgz",
"integrity": "sha512-e5pEa2kBnBOgR4Y/p20pskXI74UEz7de8ZGVo58asOtvSVG5YAbJeELPZxOmt+Bnz3rX753YKhfIn4X4l1PPRQ=="
},
"base-x": {
"version": "3.0.8",
"resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.8.tgz",
"integrity": "sha512-Rl/1AWP4J/zRrk54hhlxH4drNxPJXYUaKffODVI53/dAsV4t9fBxyxYKAVPU1XBHxYwOWP9h9H0hM2MVw4YfJA==",
"requires": {
"safe-buffer": "^5.0.1"
}
},
"bindings": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz",
"integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==",
"requires": {
"file-uri-to-path": "1.0.0"
}
},
"bip39": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/bip39/-/bip39-2.6.0.tgz",
"integrity": "sha512-RrnQRG2EgEoqO24ea+Q/fftuPUZLmrEM3qNhhGsA3PbaXaCW791LTzPuVyx/VprXQcTbPJ3K3UeTna8ZnVl2sg==",
"requires": {
"create-hash": "^1.1.0",
"pbkdf2": "^3.0.9",
"randombytes": "^2.0.1",
"safe-buffer": "^5.0.1",
"unorm": "^1.3.3"
}
},
"bip66": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/bip66/-/bip66-1.1.5.tgz",
"integrity": "sha1-AfqHSHhcpwlV1QESF9GzE5lpyiI=",
"requires": {
"safe-buffer": "^5.0.1"
}
},
"bn.js": {
"version": "4.11.8",
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz",
"integrity": "sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA=="
},
"brorand": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz",
"integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8="
},
"browserify-aes": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz",
"integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==",
"requires": {
"buffer-xor": "^1.0.3",
"cipher-base": "^1.0.0",
"create-hash": "^1.1.0",
"evp_bytestokey": "^1.0.3",
"inherits": "^2.0.1",
"safe-buffer": "^5.0.1"
}
},
"bs58": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz",
"integrity": "sha1-vhYedsNU9veIrkBx9j806MTwpCo=",
"requires": {
"base-x": "^3.0.2"
}
},
"bs58check": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/bs58check/-/bs58check-2.1.2.tgz",
"integrity": "sha512-0TS1jicxdU09dwJMNZtVAfzPi6Q6QeN0pM1Fkzrjn+XYHvzMKPU3pHVpva+769iNVSfIYWf7LJ6WR+BuuMf8cA==",
"requires": {
"bs58": "^4.0.0",
"create-hash": "^1.1.0",
"safe-buffer": "^5.1.2"
}
},
"buffer-xor": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz",
"integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk="
},
"cipher-base": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz",
"integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==",
"requires": {
"inherits": "^2.0.1",
"safe-buffer": "^5.0.1"
}
},
"create-hash": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz",
"integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==",
"requires": {
"cipher-base": "^1.0.1",
"inherits": "^2.0.1",
"md5.js": "^1.3.4",
"ripemd160": "^2.0.1",
"sha.js": "^2.4.0"
}
},
"create-hmac": {
"version": "1.1.7",
"resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz",
"integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==",
"requires": {
"cipher-base": "^1.0.3",
"create-hash": "^1.1.0",
"inherits": "^2.0.1",
"ripemd160": "^2.0.0",
"safe-buffer": "^5.0.1",
"sha.js": "^2.4.8"
}
},
"drbg.js": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/drbg.js/-/drbg.js-1.0.1.tgz",
"integrity": "sha1-Pja2xCs3BDgjzbwzLVjzHiRFSAs=",
"requires": {
"browserify-aes": "^1.0.6",
"create-hash": "^1.1.2",
"create-hmac": "^1.1.4"
}
},
"elliptic": {
"version": "6.5.3",
"resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.3.tgz",
"integrity": "sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==",
"requires": {
"bn.js": "^4.4.0",
"brorand": "^1.0.1",
"hash.js": "^1.0.0",
"hmac-drbg": "^1.0.0",
"inherits": "^2.0.1",
"minimalistic-assert": "^1.0.0",
"minimalistic-crypto-utils": "^1.0.0"
}
},
"evp_bytestokey": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz",
"integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==",
"requires": {
"md5.js": "^1.3.4",
"safe-buffer": "^5.1.1"
}
},
"file-uri-to-path": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
"integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw=="
},
"hash-base": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.1.0.tgz",
"integrity": "sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA==",
"requires": {
"inherits": "^2.0.4",
"readable-stream": "^3.6.0",
"safe-buffer": "^5.2.0"
}
},
"hash.js": {
"version": "1.1.7",
"resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz",
"integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==",
"requires": {
"inherits": "^2.0.3",
"minimalistic-assert": "^1.0.1"
}
},
"hdkey": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/hdkey/-/hdkey-1.1.2.tgz",
"integrity": "sha512-PTQ4VKu0oRnCrYfLp04iQZ7T2Cxz0UsEXYauk2j8eh6PJXCpbXuCFhOmtIFtbET0i3PMWmHN9J11gU8LEgUljQ==",
"requires": {
"bs58check": "^2.1.2",
"safe-buffer": "^5.1.1",
"secp256k1": "^3.0.1"
}
},
"hmac-drbg": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz",
"integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=",
"requires": {
"hash.js": "^1.0.3",
"minimalistic-assert": "^1.0.0",
"minimalistic-crypto-utils": "^1.0.1"
}
},
"inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
},
"js-sha3": {
"version": "0.8.0",
"resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.8.0.tgz",
"integrity": "sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q=="
},
"md5.js": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz",
"integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==",
"requires": {
"hash-base": "^3.0.0",
"inherits": "^2.0.1",
"safe-buffer": "^5.1.2"
}
},
"minimalistic-assert": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz",
"integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A=="
},
"minimalistic-crypto-utils": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz",
"integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo="
},
"nan": {
"version": "2.14.1",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.14.1.tgz",
"integrity": "sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw=="
},
"pbkdf2": {
"version": "3.0.17",
"resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.17.tgz",
"integrity": "sha512-U/il5MsrZp7mGg3mSQfn742na2T+1/vHDCG5/iTI3X9MKUuYUZVLQhyRsg06mCgDBTd57TxzgZt7P+fYfjRLtA==",
"requires": {
"create-hash": "^1.1.2",
"create-hmac": "^1.1.4",
"ripemd160": "^2.0.1",
"safe-buffer": "^5.0.1",
"sha.js": "^2.4.8"
}
},
"randombytes": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz",
"integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==",
"requires": {
"safe-buffer": "^5.1.0"
}
},
"readable-stream": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",
"integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==",
"requires": {
"inherits": "^2.0.3",
"string_decoder": "^1.1.1",
"util-deprecate": "^1.0.1"
}
},
"ripemd160": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz",
"integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==",
"requires": {
"hash-base": "^3.0.0",
"inherits": "^2.0.1"
}
},
"safe-buffer": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz",
"integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg=="
},
"scrypt.js": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/scrypt.js/-/scrypt.js-0.3.0.tgz",
"integrity": "sha512-42LTc1nyFsyv/o0gcHtDztrn+aqpkaCNt5Qh7ATBZfhEZU7IC/0oT/qbBH+uRNoAPvs2fwiOId68FDEoSRA8/A==",
"requires": {
"scrypt": "^6.0.2",
"scryptsy": "^1.2.1"
}
},
"scryptsy": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/scryptsy/-/scryptsy-1.2.1.tgz",
"integrity": "sha512-aldIRgMozSJ/Gl6K6qmJZysRP82lz83Wb42vl4PWN8SaLFHIaOzLPc9nUUW2jQN88CuGm5q5HefJ9jZ3nWSmTw==",
"requires": {
"pbkdf2": "^3.0.3"
}
},
"secp256k1": {
"version": "3.8.0",
"resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-3.8.0.tgz",
"integrity": "sha512-k5ke5avRZbtl9Tqx/SA7CbY3NF6Ro+Sj9cZxezFzuBlLDmyqPiL8hJJ+EmzD8Ig4LUDByHJ3/iPOVoRixs/hmw==",
"requires": {
"bindings": "^1.5.0",
"bip66": "^1.1.5",
"bn.js": "^4.11.8",
"create-hash": "^1.2.0",
"drbg.js": "^1.0.1",
"elliptic": "^6.5.2",
"nan": "^2.14.0",
"safe-buffer": "^5.1.2"
}
},
"sha.js": {
"version": "2.4.11",
"resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz",
"integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==",
"requires": {
"inherits": "^2.0.1",
"safe-buffer": "^5.0.1"
}
},
"string_decoder": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz",
"integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==",
"requires": {
"safe-buffer": "~5.2.0"
}
},
"unorm": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/unorm/-/unorm-1.6.0.tgz",
"integrity": "sha512-b2/KCUlYZUeA7JFUuRJZPUtr4gZvBh7tavtv4fvk4+KV9pfGiR6CQAQAWl49ZpR3ts2dk4FYkP7EIgDJoiOLDA=="
},
"util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
},
"uuid": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A=="
}
}
}

@ -1,7 +1,7 @@
{
"name": "@harmony-js/crypto",
"version": "0.1.48",
"description": "crypto libraries for harmony",
"name": "@woop-js/crypto",
"version": "0.1.58",
"description": "crypto libraries for woop",
"main": "dist/index.js",
"node": "dist/index.js",
"browser": "dist/index.js",
@ -18,7 +18,7 @@
},
"license": "MIT",
"dependencies": {
"@harmony-js/utils": "0.1.48",
"@woop-js/utils": "0.1.58",
"aes-js": "^3.1.2",
"bip39": "^2.5.0",
"bn.js": "^4.11.8",
@ -27,7 +27,7 @@
"hmac-drbg": "^1.0.1",
"js-sha3": "^0.8.0",
"pbkdf2": "^3.0.17",
"scrypt-shim": "github:web3-js/scrypt-shim",
"scrypt.js": "^0.3.0",
"uuid": "^3.3.2"
},
"gitHead": "56606e9365721729a490c27d6a294e0daf90fbdf"

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save