Compare commits

..

1 Commits

Author SHA1 Message Date
dependabot[bot] 5e4500640d
Bump decode-uri-component from 0.2.0 to 0.2.2 2 years ago
  1. 47
      README.md
  2. 4
      RELEASE.md
  3. 12
      TYPEDOC.md
  4. 68
      e2e/src/blockchain.e2e.ts
  5. 18
      e2e/src/harmony.ts
  6. 84
      e2e/src/transaction.e2e.ts
  7. 152
      e2e/src/txn_rpc.e2e.ts
  8. 12
      e2e/tsconfig.json
  9. 16
      gulpfile.js
  10. 885
      package-lock.json
  11. 6
      package.json
  12. 16
      packages/README.md
  13. 0
      packages/harmony-account/LICENSE
  14. 36
      packages/harmony-account/README.md
  15. 38
      packages/harmony-account/guide.ts
  16. 16
      packages/harmony-account/package.json
  17. 34
      packages/harmony-account/src/account.ts
  18. 16
      packages/harmony-account/src/hdnode.ts
  19. 2
      packages/harmony-account/src/index.ts
  20. 2
      packages/harmony-account/src/types.ts
  21. 14
      packages/harmony-account/src/utils.ts
  22. 30
      packages/harmony-account/src/wallet.ts
  23. 8
      packages/harmony-account/test/testAccount.test.ts
  24. 10
      packages/harmony-account/tsconfig.json
  25. 0
      packages/harmony-account/tsconfig.test.json
  26. 8
      packages/harmony-contract/Counter.json
  27. 0
      packages/harmony-contract/LICENSE
  28. 56
      packages/harmony-contract/README.md
  29. 14
      packages/harmony-contract/package.json
  30. 62
      packages/harmony-contract/src/abi/abiCoder.ts
  31. 6
      packages/harmony-contract/src/abi/api.ts
  32. 2
      packages/harmony-contract/src/abi/index.ts
  33. 6
      packages/harmony-contract/src/abi/utils.ts
  34. 8
      packages/harmony-contract/src/contract.ts
  35. 4
      packages/harmony-contract/src/contractFactory.ts
  36. 4
      packages/harmony-contract/src/events/event.ts
  37. 4
      packages/harmony-contract/src/events/eventFactory.ts
  38. 2
      packages/harmony-contract/src/index.ts
  39. 12
      packages/harmony-contract/src/methods/method.ts
  40. 2
      packages/harmony-contract/src/methods/methodFactory.ts
  41. 4
      packages/harmony-contract/src/models/AbiItemModel.ts
  42. 2
      packages/harmony-contract/src/models/AbiModel.ts
  43. 2
      packages/harmony-contract/src/models/types.ts
  44. 2
      packages/harmony-contract/src/utils/decoder.ts
  45. 4
      packages/harmony-contract/src/utils/encoder.ts
  46. 6
      packages/harmony-contract/src/utils/formatter.ts
  47. 4
      packages/harmony-contract/src/utils/mapper.ts
  48. 2
      packages/harmony-contract/src/utils/options.ts
  49. 2
      packages/harmony-contract/src/utils/status.ts
  50. 4
      packages/harmony-contract/test/abiCoder.test.ts
  51. 0
      packages/harmony-contract/test/fixtures/abiv2.ts
  52. 10
      packages/harmony-contract/tsconfig.json
  53. 0
      packages/harmony-contract/tsconfig.test.json
  54. 0
      packages/harmony-core/LICENSE
  55. 48
      packages/harmony-core/README.md
  56. 18
      packages/harmony-core/package.json
  57. 186
      packages/harmony-core/src/blockchain.ts
  58. 68
      packages/harmony-core/src/harmony.ts
  59. 32
      packages/harmony-core/src/harmonyExtension.ts
  60. 6
      packages/harmony-core/src/index.ts
  61. 34
      packages/harmony-core/src/truffleProvider.ts
  62. 31
      packages/harmony-core/src/types.ts
  63. 38
      packages/harmony-core/src/util.ts
  64. 2
      packages/harmony-core/test/blockchain.test.ts
  65. 16
      packages/harmony-core/tsconfig.json
  66. 0
      packages/harmony-core/tsconfig.test.json
  67. 0
      packages/harmony-crypto/LICENSE
  68. 16
      packages/harmony-crypto/README.md
  69. 14
      packages/harmony-crypto/package-lock.json
  70. 6
      packages/harmony-crypto/package.json
  71. 54
      packages/harmony-crypto/src/address.ts
  72. 12
      packages/harmony-crypto/src/bech32.ts
  73. 2
      packages/harmony-crypto/src/bytes.ts
  74. 18
      packages/harmony-crypto/src/errors.ts
  75. 2
      packages/harmony-crypto/src/index.ts
  76. 2
      packages/harmony-crypto/src/keccak256.ts
  77. 4
      packages/harmony-crypto/src/keyTool.ts
  78. 4
      packages/harmony-crypto/src/keystore.ts
  79. 2
      packages/harmony-crypto/src/random.ts
  80. 2
      packages/harmony-crypto/src/rlp.ts
  81. 0
      packages/harmony-crypto/src/signature.ts
  82. 2
      packages/harmony-crypto/src/types.ts
  83. 12
      packages/harmony-crypto/test/address.test.ts
  84. 0
      packages/harmony-crypto/test/bytes.test.ts
  85. 0
      packages/harmony-crypto/test/fixtures/hashes.json
  86. 0
      packages/harmony-crypto/test/fixtures/rlpcoder.json
  87. 0
      packages/harmony-crypto/test/keccak256.test.ts
  88. 2
      packages/harmony-crypto/test/keyTool.test.ts
  89. 0
      packages/harmony-crypto/test/keystore.test.ts
  90. 0
      packages/harmony-crypto/test/rlp.test.ts
  91. 0
      packages/harmony-crypto/test/tsconfig.json
  92. 2
      packages/harmony-crypto/tsconfig.json
  93. 0
      packages/harmony-crypto/tsconfig.test.json
  94. 0
      packages/harmony-network/LICENSE
  95. 12
      packages/harmony-network/README.md
  96. 6
      packages/harmony-network/package.json
  97. 2
      packages/harmony-network/src/index.ts
  98. 20
      packages/harmony-network/src/messenger/messenger.ts
  99. 4
      packages/harmony-network/src/messenger/responseMiddleware.ts
  100. 2
      packages/harmony-network/src/providers/baseProvider.ts
  101. Some files were not shown because too many files have changed in this diff Show More

@ -1,22 +1,39 @@
# Woop JavaScript SDK # Harmony JavaScript SDK
[![npm version](https://img.shields.io/npm/v/@woop-js/core.svg?style=flat-square)](https://www.npmjs.com/package/@woop-js/core) [![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/Woop-sdk-core.svg?branch=master)](https://travis-ci.com/FireStack-Lab/Woop-sdk-core) [![Build Status](https://travis-ci.com/FireStack-Lab/Harmony-sdk-core.svg?branch=master)](https://travis-ci.com/FireStack-Lab/Harmony-sdk-core)
This is the Woop Javascript SDK which provides an easier way to interact with Woop blockchain. This is the Harmony Javascript SDK which provides an easier way to interact with Harmony blockchain.
Please read the [documentation](https://jssdk.doc.hmny.io/) for full API doc. 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. 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) 1. [@harmony-js/core](https://github.com/harmony-one/sdk/tree/master/packages/harmony-core)
2. [@woop-js/account](https://github.com/woop-chain/sdk/tree/master/packages/woop-account) 2. [@harmony-js/account](https://github.com/harmony-one/sdk/tree/master/packages/harmony-account)
3. [@woop-js/crypto](https://github.com/woop-chain/sdk/tree/master/packages/woop-crypto) 3. [@harmony-js/crypto](https://github.com/harmony-one/sdk/tree/master/packages/harmony-crypto)
4. [@woop-js/network](https://github.com/woop-chain/sdk/tree/master/packages/woop-network) 4. [@harmony-js/network](https://github.com/harmony-one/sdk/tree/master/packages/harmony-network)
5. [@woop-js/utils](https://github.com/woop-chain/sdk/tree/master/packages/woop-utils) 5. [@harmony-js/utils](https://github.com/harmony-one/sdk/tree/master/packages/harmony-utils)
6. [@woop-js/transaction](https://github.com/woop-chain/sdk/tree/master/packages/woop-transaction) 6. [@harmony-js/transaction](https://github.com/harmony-one/sdk/tree/master/packages/harmony-transaction)
7. [@woop-js/contract](https://github.com/woop-chain/sdk/tree/master/packages/woop-contract) 7. [@harmony-js/contract](https://github.com/harmony-one/sdk/tree/master/packages/harmony-contract)
8. [@woop-js/staking](https://github.com/woop-chain/sdk/tree/master/packages/woop-staking) 8. [@harmony-js/staking](https://github.com/harmony-one/sdk/tree/master/packages/harmony-staking)
# Examples
* [A Token Faucet Demo DApp](https://github.com/harmony-one/token-faucet-demo-dapp)
* [Hackathon DApps](https://docs.harmony.one/home/showcases/applications): DApps built during our internal hackathon
* [soccerplayers](https://github.com/gupadhyaya/soccerplayers), [onemoji](https://github.com/peekpi/onemoji), [harmonauts](https://github.com/ivorytowerdds/harmonauts), [good-one](https://github.com/harmony-one/dapp-demo-crowdfunding)
* [Cross-chain Apps](https://docs.harmony.one/home/showcases/crosschain) [the link contains code, demo, and more information]
* [DeFi Apps](https://docs.harmony.one/home/showcases/defi)
* [DevPost Hackathon Apps](https://docs.harmony.one/home/showcases/hackathons)
* Eth<>Harmony Bridge Components: [frontend](https://github.com/harmony-one/ethhmy-bridge.frontend), [backend](https://github.com/harmony-one/ethhmy-bridge.appengine), [smart contracts](https://github.com/harmony-one/ethhmy-bridge), [test scripts](https://github.com/harmony-one/ethhmy-bridge.tests)
* Eth<>Harmony bridge SDKs: [main sdk](https://github.com/harmony-one/ethhmy-bridge.sdk), [bridge UI widget](https://github.com/harmony-one/ethhmy-bridge.ui-sdk)
* Swoop Dex: [interface](https://github.com/harmony-one/swoop-interface), [cli](https://github.com/harmony-one/swoop-cli), [sdk](https://github.com/harmony-one/swoop-sdk), [deployment](https://github.com/harmony-one/swoop-deployment), [misc](https://github.com/harmony-one/swoop-misc), [lib](https://github.com/harmony-one/swoop-lib), [periphery](https://github.com/harmony-one/swoop-periphery), [core](https://github.com/harmony-one/swoop-core), [testing](https://github.com/harmony-one/swoop-testing), [utils](https://github.com/harmony-one/swoop-utils)
* [Iris Bridge](https://github.com/harmony-one/ethhmy-bridge-v2): inspired from near's rainbow bridge
* [Animoca's BeastQuest Game](https://github.com/harmony-one/BeastQuest)
* [Chainlink Testnet Integration Demo](https://github.com/harmony-one/chainlink-demo-project)
* [NFT Store DApp](https://github.com/harmony-one/nft-store)
* [old dapp-examples](https://github.com/harmony-one/dapp-examples): some of them may be outdated!
# Installation # Installation
@ -35,10 +52,10 @@ This library works on both nodejs and browser. Please use it according to your u
```bash ```bash
# npm # npm
npm install @woop-js/core@next npm install @harmony-js/core@next
# yarn # yarn
yarn add @woop-js/core@next yarn add @harmony-js/core@next
# tslib is required, we'd better install it as well # tslib is required, we'd better install it as well
npm install tslib npm install tslib
@ -77,7 +94,7 @@ yarn test:src
## e2e tests ## e2e tests
1. Remove the `'cross-fetch': 'jest-fetch-mock'` line from `scripts/jest/jest.e2e.config.js` 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. Run harmony node locally, follow the instructions: https://github.com/harmony-one/harmony
1. Wait for 1-2 mins, and run this: 1. Wait for 1-2 mins, and run this:
```bash ```bash
yarn build && yarn test:e2e 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. For example.
```bash ```bash
npm install @woop-js/core@next npm install @harmony-js/core@next
``` ```
@ -60,7 +60,7 @@ This will change the release version of current npm packages to the latest versi
For example. For example.
```bash ```bash
npm install @woop-js/core npm install @harmony-js/core
``` ```

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

@ -1,10 +1,10 @@
import fetch from 'jest-fetch-mock'; import fetch from 'jest-fetch-mock';
import { woop, checkCalledMethod } from './woop'; import { harmony, checkCalledMethod } from './harmony';
import demoAccounts from '../fixtures/testAccount.json'; import demoAccounts from '../fixtures/testAccount.json';
import { RPCMethod } from '@woop-js/network'; import { RPCMethod } from '@harmony-js/network';
const bc = woop.blockchain; const bc = harmony.blockchain;
const testAccount = demoAccounts.Accounts[1]; const testAccount = demoAccounts.Accounts[1];
@ -19,7 +19,7 @@ describe('e2e test blockchain', () => {
); );
const peerCount = await bc.net_peerCount(); const peerCount = await bc.net_peerCount();
expect(checkCalledMethod(0, RPCMethod.PeerCount)).toEqual(true); expect(checkCalledMethod(0, RPCMethod.PeerCount)).toEqual(true);
expect(woop.utils.isHex(peerCount.result)).toEqual(true); expect(harmony.utils.isHex(peerCount.result)).toEqual(true);
}); });
it('should test net_version', async () => { it('should test net_version', async () => {
@ -31,27 +31,27 @@ describe('e2e test blockchain', () => {
expect(netVersion.result).toEqual(`${versionNumber}`); expect(netVersion.result).toEqual(`${versionNumber}`);
expect(checkCalledMethod(0, RPCMethod.NetVersion)).toEqual(true); expect(checkCalledMethod(0, RPCMethod.NetVersion)).toEqual(true);
}); });
it('should test wiki_protocolVersion', async () => { it('should test hmy_protocolVersion', async () => {
fetch.mockResponseOnce( fetch.mockResponseOnce(
JSON.stringify({"jsonrpc": "2.0", "id": 1, "result": "0x10"}), JSON.stringify({"jsonrpc": "2.0", "id": 1, "result": "0x10"}),
); );
const protocolVersion = await bc.getProtocolVersion(); const protocolVersion = await bc.getProtocolVersion();
expect(woop.utils.isHex(protocolVersion.result)).toEqual(true); expect(harmony.utils.isHex(protocolVersion.result)).toEqual(true);
expect(checkCalledMethod(0, RPCMethod.ProtocolVersion)).toEqual(true); expect(checkCalledMethod(0, RPCMethod.ProtocolVersion)).toEqual(true);
}); });
// block chain info // block chain info
it('should test wiki_blockNumber', async () => { it('should test hmy_blockNumber', async () => {
fetch.mockResponseOnce( fetch.mockResponseOnce(
JSON.stringify({"jsonrpc": "2.0", "id": 1, "result": "0x10"}), JSON.stringify({"jsonrpc": "2.0", "id": 1, "result": "0x10"}),
); );
const res = await bc.getBlockNumber(); const res = await bc.getBlockNumber();
expect(res.responseType).toEqual('raw'); expect(res.responseType).toEqual('raw');
expect(woop.utils.isHex(res.result)).toEqual(true); expect(harmony.utils.isHex(res.result)).toEqual(true);
expect(checkCalledMethod(0, RPCMethod.BlockNumber)).toEqual(true); expect(checkCalledMethod(0, RPCMethod.BlockNumber)).toEqual(true);
}); });
it('should test wiki_getBlockByNumber', async () => { it('should test hmy_getBlockByNumber', async () => {
fetch.mockResponse( fetch.mockResponse(
JSON.stringify({ JSON.stringify({
"jsonrpc": "2.0", "jsonrpc": "2.0",
@ -80,11 +80,11 @@ describe('e2e test blockchain', () => {
const res = await bc.getBlockByNumber({ blockNumber: 'latest' }); const res = await bc.getBlockByNumber({ blockNumber: 'latest' });
const size = res.result.size; const size = res.result.size;
expect(res.responseType).toEqual('raw'); expect(res.responseType).toEqual('raw');
expect(woop.utils.isHex(size)).toEqual(true); expect(harmony.utils.isHex(size)).toEqual(true);
expect(checkBlockData(res.result)).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(res2.responseType).toEqual('raw');
expect(woop.utils.isHex(res2.result.size)).toEqual(true); expect(harmony.utils.isHex(res2.result.size)).toEqual(true);
expect(checkBlockData(res2.result)).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(res3.responseType).toEqual('raw');
@ -94,7 +94,7 @@ describe('e2e test blockchain', () => {
} }
}); });
it('should test wiki_getBlockByHash', async () => { it('should test hmy_getBlockByHash', async () => {
fetch.mockResponse( fetch.mockResponse(
JSON.stringify({ JSON.stringify({
"jsonrpc": "2.0", "jsonrpc": "2.0",
@ -124,46 +124,46 @@ describe('e2e test blockchain', () => {
const res = await bc.getBlockByHash({ blockHash: latestBlock.result.hash }); const res = await bc.getBlockByHash({ blockHash: latestBlock.result.hash });
expect(res.responseType).toEqual('raw'); expect(res.responseType).toEqual('raw');
expect(latestBlock.result.hash).toEqual(res.result.hash); expect(latestBlock.result.hash).toEqual(res.result.hash);
expect(woop.utils.isHex(res.result.size)).toEqual(true); expect(harmony.utils.isHex(res.result.size)).toEqual(true);
expect(checkBlockData(res.result)).toEqual(true); expect(checkBlockData(res.result)).toEqual(true);
expect(checkCalledMethod(0, RPCMethod.GetBlockByNumber)).toEqual(true); expect(checkCalledMethod(0, RPCMethod.GetBlockByNumber)).toEqual(true);
expect(checkCalledMethod(1, RPCMethod.GetBlockByHash)).toEqual(true); expect(checkCalledMethod(1, RPCMethod.GetBlockByHash)).toEqual(true);
}); });
// account related // account related
it('should test wiki_getBalance', async () => { it('should test hmy_getBalance', async () => {
fetch.mockResponseOnce( fetch.mockResponseOnce(
JSON.stringify({"jsonrpc": "2.0", "id": 1, "result": "0x10"}), JSON.stringify({"jsonrpc": "2.0", "id": 1, "result": "0x10"}),
); );
const balance = await bc.getBalance({ address: testAccount.Address }); const balance = await bc.getBalance({ address: testAccount.Address });
expect(woop.utils.isHex(balance.result)).toEqual(true); expect(harmony.utils.isHex(balance.result)).toEqual(true);
expect(checkCalledMethod(0, RPCMethod.GetBalance)).toEqual(true); expect(checkCalledMethod(0, RPCMethod.GetBalance)).toEqual(true);
}); });
}); });
function checkBlockData(data: any) { function checkBlockData(data: any) {
return woop.utils.validateArgs( return harmony.utils.validateArgs(
data, data,
{ {
difficulty: [woop.utils.isNumber], difficulty: [harmony.utils.isNumber],
// tslint:disable-next-line: no-shadowed-variable // tslint:disable-next-line: no-shadowed-variable
extraData: [(data: any) => data === '0x' || woop.utils.isHex(data)], extraData: [(data: any) => data === '0x' || harmony.utils.isHex(data)],
gasLimit: [woop.utils.isHex], gasLimit: [harmony.utils.isHex],
gasUsed: [woop.utils.isHex], gasUsed: [harmony.utils.isHex],
hash: [woop.utils.isHash], hash: [harmony.utils.isHash],
logsBloom: [woop.utils.isHex], logsBloom: [harmony.utils.isHex],
miner: [woop.utils.isBech32Address], miner: [harmony.utils.isBech32Address],
mixHash: [woop.utils.isHash], mixHash: [harmony.utils.isHash],
nonce: [woop.utils.isNumber], nonce: [harmony.utils.isNumber],
number: [woop.utils.isHex], number: [harmony.utils.isHex],
parentHash: [woop.utils.isHash], parentHash: [harmony.utils.isHash],
receiptsRoot: [woop.utils.isHash], receiptsRoot: [harmony.utils.isHash],
size: [woop.utils.isHex], size: [harmony.utils.isHex],
stateRoot: [woop.utils.isHash], stateRoot: [harmony.utils.isHash],
timestamp: [woop.utils.isHex], timestamp: [harmony.utils.isHex],
transactionsRoot: [woop.utils.isHash], transactionsRoot: [harmony.utils.isHash],
uncles: [woop.utils.isArray], uncles: [harmony.utils.isArray],
}, },
{ transactions: [woop.utils.isArray] }, { transactions: [harmony.utils.isArray] },
); );
} }

@ -1,31 +1,31 @@
import fetch from 'jest-fetch-mock'; import fetch from 'jest-fetch-mock';
// tslint:disable-next-line: no-implicit-dependencies // tslint:disable-next-line: no-implicit-dependencies
import { Woop } from '@woop-js/core'; import { Harmony } from '@harmony-js/core';
// tslint:disable-next-line: no-implicit-dependencies // tslint:disable-next-line: no-implicit-dependencies
import { ChainType } from '@woop-js/utils'; import { ChainType } from '@harmony-js/utils';
// tslint:disable-next-line: no-implicit-dependencies // tslint:disable-next-line: no-implicit-dependencies
import { Account } from '@woop-js/account'; import { Account } from '@harmony-js/account';
const CHAIN_ID: number = 2; const CHAIN_ID: number = 2;
const CHAIN_TYPE: string = 'wiki'; const CHAIN_TYPE: string = 'hmy';
const HTTP_PROVIDER: string = 'http://localhost:9500'; const HTTP_PROVIDER: string = 'http://localhost:9500';
const GENESIS_PRIV_KEY: string = '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e'; const GENESIS_PRIV_KEY: string = '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e';
let chainType: ChainType = ChainType.Woop; let chainType: ChainType = ChainType.Harmony;
if (CHAIN_TYPE === 'wiki') { if (CHAIN_TYPE === 'hmy') {
chainType = ChainType.Woop; chainType = ChainType.Harmony;
} else if (CHAIN_TYPE === 'eth') { } else if (CHAIN_TYPE === 'eth') {
chainType = ChainType.Ethereum; chainType = ChainType.Ethereum;
} }
export const woop: Woop = new Woop(HTTP_PROVIDER, { export const harmony: Harmony = new Harmony(HTTP_PROVIDER, {
chainId: CHAIN_ID, chainId: CHAIN_ID,
chainType, chainType,
chainUrl: HTTP_PROVIDER, chainUrl: HTTP_PROVIDER,
}); });
export const myAccount: Account = woop.wallet.addByPrivateKey( export const myAccount: Account = harmony.wallet.addByPrivateKey(
GENESIS_PRIV_KEY, GENESIS_PRIV_KEY,
); );

@ -1,12 +1,12 @@
import fetch from 'jest-fetch-mock'; import fetch from 'jest-fetch-mock';
import { woop, checkCalledMethod } from './woop'; import { harmony, checkCalledMethod } from './harmony';
// tslint:disable-next-line: no-implicit-dependencies // tslint:disable-next-line: no-implicit-dependencies
import { Transaction, TxStatus } from '@woop-js/transaction'; import { Transaction, TxStatus } from '@harmony-js/transaction';
// tslint:disable-next-line: no-implicit-dependencies // tslint:disable-next-line: no-implicit-dependencies
import { isHash, numberToHex } from '@woop-js/utils'; import { isHash, numberToHex } from '@harmony-js/utils';
import txnJsons from '../fixtures/transactions.json'; import txnJsons from '../fixtures/transactions.json';
import demoAccounts from '../fixtures/testAccount.json'; import demoAccounts from '../fixtures/testAccount.json';
import { RPCMethod } from '@woop-js/network'; import { RPCMethod } from '@harmony-js/network';
const receiver = demoAccounts.Accounts[3]; const receiver = demoAccounts.Accounts[3];
jest.useRealTimers(); jest.useRealTimers();
@ -23,7 +23,7 @@ describe('test Transaction using SDK', () => {
const txns = txnJsons.transactions; const txns = txnJsons.transactions;
// tslint:disable-next-line: prefer-for-of // tslint:disable-next-line: prefer-for-of
for (let i = 0; i < txns.length; i += 1) { for (let i = 0; i < txns.length; i += 1) {
const newTxn = woop.transactions.newTx(); const newTxn = harmony.transactions.newTx();
newTxn.recover(txns[i].rawTransaction); newTxn.recover(txns[i].rawTransaction);
expect(newTxn.txParams.from).toEqual(txns[i].senderAddress); expect(newTxn.txParams.from).toEqual(txns[i].senderAddress);
@ -36,14 +36,14 @@ describe('test Transaction using SDK', () => {
}); });
it('should test signTransaction', async () => { it('should test signTransaction', async () => {
const txnObject = { const txnObject = {
to: woop.crypto.getAddress(receiver.Address).bech32, to: harmony.crypto.getAddress(receiver.Address).bech32,
value: '0x64', value: '0x64',
gasLimit: '210000', gasLimit: '210000',
gasPrice: new woop.utils.Unit('100').asGwei().toWei(), gasPrice: new harmony.utils.Unit('100').asGwei().toWei(),
}; };
const txn = woop.transactions.newTx(txnObject); const txn = harmony.transactions.newTx(txnObject);
signed = await woop.wallet.signTransaction(txn, undefined, undefined, false); signed = await harmony.wallet.signTransaction(txn, undefined, undefined, false);
expect(signed.isSigned()).toEqual(true); expect(signed.isSigned()).toEqual(true);
}); });
@ -56,7 +56,7 @@ describe('test Transaction using SDK', () => {
); );
const [sentTxn, id] = await signed.sendTransaction(); const [sentTxn, id] = await signed.sendTransaction();
expect(sentTxn.isPending()).toEqual(true); expect(sentTxn.isPending()).toEqual(true);
expect(woop.utils.isHash(id)).toEqual(true); expect(harmony.utils.isHash(id)).toEqual(true);
expect(checkCalledMethod(0, RPCMethod.SendRawTransaction)).toEqual(true); expect(checkCalledMethod(0, RPCMethod.SendRawTransaction)).toEqual(true);
txId = id; txId = id;
sent = sentTxn; sent = sentTxn;
@ -77,16 +77,16 @@ describe('test Transaction using SDK', () => {
"id": 1, "id": 1,
"result": { "result": {
"contractAddress": null, "contractAddress": null,
"blockNumber": woop.utils.numberToHex(2), "blockNumber": harmony.utils.numberToHex(2),
"from": woop.wallet.accounts[0], "from": harmony.wallet.accounts[0],
"gasUsed": woop.utils.numberToHex(5), "gasUsed": harmony.utils.numberToHex(5),
"cumulativeGasUsed": woop.utils.numberToHex(5), "cumulativeGasUsed": harmony.utils.numberToHex(5),
"logs": [], "logs": [],
"logsBloom": woop.utils.numberToHex(5), "logsBloom": harmony.utils.numberToHex(5),
"shardID": 0, "shardID": 0,
"to": demoAccounts.Accounts[3].Address, "to": demoAccounts.Accounts[3].Address,
"transactionHash": "0x8c26EFdb6e4cAC6F8BeACE59F52fd95beD4Bfbfa8fF30F4a7cEd511fE5f869d9", "transactionHash": "0x8c26EFdb6e4cAC6F8BeACE59F52fd95beD4Bfbfa8fF30F4a7cEd511fE5f869d9",
"transactionIndex": woop.utils.numberToHex(10), "transactionIndex": harmony.utils.numberToHex(10),
"blockHash": "0xFECCCCBFd5AC71902BcfE65dDB0b88EEbbD15AD6cDAE7A9FAEb773bF827320fd", "blockHash": "0xFECCCCBFd5AC71902BcfE65dDB0b88EEbbD15AD6cDAE7A9FAEb773bF827320fd",
} }
}), }),
@ -107,13 +107,13 @@ describe('test Transaction using SDK', () => {
}); });
it('should test transaction observed events', async () => { it('should test transaction observed events', async () => {
const txnObject = { const txnObject = {
to: woop.crypto.getAddress(receiver.Address).bech32, to: harmony.crypto.getAddress(receiver.Address).bech32,
value: new woop.utils.Unit('100').asGwei().toWei(), value: new harmony.utils.Unit('100').asGwei().toWei(),
gasLimit: new woop.utils.Unit('210000').asWei().toWei(), gasLimit: new harmony.utils.Unit('210000').asWei().toWei(),
gasPrice: new woop.utils.Unit('100').asGwei().toWei(), gasPrice: new harmony.utils.Unit('100').asGwei().toWei(),
}; };
const txn = woop.transactions.newTx(txnObject); const txn = harmony.transactions.newTx(txnObject);
txn txn
.observed() .observed()
.on('transactionHash', (transactionHash) => { .on('transactionHash', (transactionHash) => {
@ -130,7 +130,7 @@ describe('test Transaction using SDK', () => {
.on('error', (error) => { .on('error', (error) => {
expect(error).toBeTruthy(); expect(error).toBeTruthy();
}); });
const txnSigned = await woop.wallet.signTransaction(txn, undefined, undefined, false); const txnSigned = await harmony.wallet.signTransaction(txn, undefined, undefined, false);
fetch.mockResponseOnce( fetch.mockResponseOnce(
JSON.stringify({ JSON.stringify({
"jsonrpc": "2.0", "id": 1, "jsonrpc": "2.0", "id": 1,
@ -156,16 +156,16 @@ describe('test Transaction using SDK', () => {
"id": 1, "id": 1,
"result": { "result": {
"contractAddress": null, "contractAddress": null,
"blockNumber": woop.utils.numberToHex(2), "blockNumber": harmony.utils.numberToHex(2),
"from": woop.wallet.accounts[0], "from": harmony.wallet.accounts[0],
"gasUsed": woop.utils.numberToHex(5), "gasUsed": harmony.utils.numberToHex(5),
"cumulativeGasUsed": woop.utils.numberToHex(5), "cumulativeGasUsed": harmony.utils.numberToHex(5),
"logs": [], "logs": [],
"logsBloom": woop.utils.numberToHex(5), "logsBloom": harmony.utils.numberToHex(5),
"shardID": 0, "shardID": 0,
"to": demoAccounts.Accounts[3].Address, "to": demoAccounts.Accounts[3].Address,
"transactionHash": "0x8c26EFdb6e4cAC6F8BeACE59F52fd95beD4Bfbfa8fF30F4a7cEd511fE5f869d9", "transactionHash": "0x8c26EFdb6e4cAC6F8BeACE59F52fd95beD4Bfbfa8fF30F4a7cEd511fE5f869d9",
"transactionIndex": woop.utils.numberToHex(10), "transactionIndex": harmony.utils.numberToHex(10),
"blockHash": "0xFECCCCBFd5AC71902BcfE65dDB0b88EEbbD15AD6cDAE7A9FAEb773bF827320fd", "blockHash": "0xFECCCCBFd5AC71902BcfE65dDB0b88EEbbD15AD6cDAE7A9FAEb773bF827320fd",
"status": "0x1", "status": "0x1",
} }
@ -181,27 +181,27 @@ describe('test Transaction using SDK', () => {
}); });
function checkTransactionReceipt(data: any) { function checkTransactionReceipt(data: any) {
return woop.utils.validateArgs( return harmony.utils.validateArgs(
data, data,
{ {
blockHash: [woop.utils.isHash], blockHash: [harmony.utils.isHash],
blockNumber: [woop.utils.isHex], blockNumber: [harmony.utils.isHex],
contractAddress: [ contractAddress: [
// tslint:disable-next-line: no-shadowed-variable // tslint:disable-next-line: no-shadowed-variable
(data: any) => data === null || woop.utils.isValidAddress, (data: any) => data === null || harmony.utils.isValidAddress,
], ],
cumulativeGasUsed: [woop.utils.isHex], cumulativeGasUsed: [harmony.utils.isHex],
from: [woop.utils.isValidAddress], from: [harmony.utils.isValidAddress],
gasUsed: [woop.utils.isHex], gasUsed: [harmony.utils.isHex],
logs: [woop.utils.isArray], logs: [harmony.utils.isArray],
logsBloom: [woop.utils.isHex], logsBloom: [harmony.utils.isHex],
shardID: [woop.utils.isNumber], shardID: [harmony.utils.isNumber],
// tslint:disable-next-line: no-shadowed-variable // tslint:disable-next-line: no-shadowed-variable
to: [(data: any) => data === '0x' || woop.utils.isValidAddress], to: [(data: any) => data === '0x' || harmony.utils.isValidAddress],
transactionHash: [woop.utils.isHash], transactionHash: [harmony.utils.isHash],
transactionIndex: [woop.utils.isHex], transactionIndex: [harmony.utils.isHex],
}, },
{ root: [woop.utils.isHash] }, { root: [harmony.utils.isHash] },
); );
} }

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

@ -9,11 +9,11 @@
}, },
"include": ["src", "../typings/**/*.d.ts", "fixtures"], "include": ["src", "../typings/**/*.d.ts", "fixtures"],
"references": [ "references": [
{ "path": "../packages/woop-account" }, { "path": "../packages/harmony-account" },
{ "path": "../packages/woop-crypto" }, { "path": "../packages/harmony-crypto" },
{ "path": "../packages/woop-utils" }, { "path": "../packages/harmony-utils" },
{ "path": "../packages/woop-network" }, { "path": "../packages/harmony-network" },
{ "path": "../packages/woop-transaction" }, { "path": "../packages/harmony-transaction" },
{ "path": "../packages/woop-contract" } { "path": "../packages/harmony-contract" }
] ]
} }

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

885
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -1,5 +1,5 @@
{ {
"description": "Root repository for the woop-sdk-core", "description": "Root repository for the harmony-sdk-core",
"private": true, "private": true,
"license": "MIT", "license": "MIT",
"workspaces": [ "workspaces": [
@ -140,9 +140,9 @@
"pre-commit": "pretty-quick --staged" "pre-commit": "pretty-quick --staged"
} }
}, },
"name": "woop-sdk-core", "name": "harmony-sdk-core",
"dependencies": { "dependencies": {
"@woop-js/core": "^0.1.36", "@harmony-js/core": "^0.1.36",
"tslib": "^2.4.0", "tslib": "^2.4.0",
"typedoc-plugin-internal-external": "^2.1.1" "typedoc-plugin-internal-external": "^2.1.1"
} }

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

@ -1,11 +1,11 @@
# @woop-js/account # @harmony-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. 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 ## Installation
``` ```
npm install @woop-js/account npm install @harmony-js/account
``` ```
## Usage ## Usage
@ -28,8 +28,8 @@ const account = new Account(
'45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e', '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e',
new Messenger( new Messenger(
new HttpProvider('https://api.s0.b.hmny.io'), new HttpProvider('https://api.s0.b.hmny.io'),
ChainType.Woop, ChainType.Harmony,
ChainID.WikiTestnet, ChainID.HmyTestnet,
), ),
); );
``` ```
@ -40,8 +40,8 @@ Creating account and setting custom messenger
const account = new Account(); const account = new Account();
const customMessenger = new Messenger( const customMessenger = new Messenger(
new HttpProvider('https://api.s0.b.hmny.io'), new HttpProvider('https://api.s0.b.hmny.io'),
ChainType.Woop, ChainType.Harmony,
ChainID.WikiTestnet, ChainID.HmyTestnet,
); );
account.setMessenger(customMessenger); account.setMessenger(customMessenger);
@ -72,8 +72,8 @@ const account = new Account(
'45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e', '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e',
new Messenger( new Messenger(
new HttpProvider('https://api.s0.b.hmny.io'), new HttpProvider('https://api.s0.b.hmny.io'),
ChainType.Woop, ChainType.Harmony,
ChainID.WikiTestnet, ChainID.HmyTestnet,
), ),
); );
account.getBalance().then(response => { account.getBalance().then(response => {
@ -88,12 +88,12 @@ const account = new Account(
'45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e', '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e',
new Messenger( new Messenger(
new HttpProvider('https://api.s0.b.hmny.io'), new HttpProvider('https://api.s0.b.hmny.io'),
ChainType.Woop, ChainType.Harmony,
ChainID.WikiTestnet, ChainID.HmyTestnet,
), ),
); );
const { TransactionFactory } = require('@woop-js/transaction'); const { TransactionFactory } = require('@harmony-js/transaction');
const { Unit } = require('@woop-js/utils'); const { Unit } = require('@harmony-js/utils');
const factory = new TransactionFactory(); const factory = new TransactionFactory();
const txn = factory.newTx({ 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 Creating an empty wallet
```javascript ```javascript
const { Wallet } = require('@woop-js/account') const { Wallet } = require('@harmony-js/account')
const wallet = new Wallet(); const wallet = new Wallet();
``` ```
@ -129,8 +129,8 @@ Setting a messenger to be used to send wallet transactions
wallet.setMessenger( wallet.setMessenger(
new Messenger( new Messenger(
new HttpProvider('https://api.s0.b.hmny.io'), new HttpProvider('https://api.s0.b.hmny.io'),
ChainType.Woop, ChainType.Harmony,
ChainID.WikiTestnet, ChainID.HmyTestnet,
), ),
); );
``` ```
@ -140,8 +140,8 @@ Create an empty wallet with messenger
const wallet = new Wallet( const wallet = new Wallet(
new Messenger( new Messenger(
new HttpProvider('https://api.s0.b.hmny.io'), new HttpProvider('https://api.s0.b.hmny.io'),
ChainType.Woop, ChainType.Harmony,
ChainID.WikiTestnet, ChainID.HmyTestnet,
), ),
); );
``` ```
@ -168,7 +168,7 @@ wallet.addByKeyStore(keystore, passphrase).then(account => {
Creating a new account using passphrase Creating a new account using passphrase
```javascript ```javascript
const passphrase = 'woop-chain'; const passphrase = 'harmony-one';
wallet.createAccount(passphrase).then(account => { wallet.createAccount(passphrase).then(account => {
console.log(account.bech32Address); console.log(account.bech32Address);
}); });

@ -1,12 +1,12 @@
/** /**
# @woop-js/account # @harmony-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. 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 ## Installation
``` ```
npm install @woop-js/account npm install @harmony-js/account
``` ```
## Usage ## Usage
@ -29,8 +29,8 @@ Creating account using private key and custom messenger
* '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e', * '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e',
* new Messenger( * new Messenger(
* new HttpProvider('https://api.s0.b.hmny.io'), * new HttpProvider('https://api.s0.b.hmny.io'),
* ChainType.Woop, * ChainType.Harmony,
* ChainID.WikiTestnet, * ChainID.HmyTestnet,
* ), * ),
* ); * );
``` ```
@ -41,8 +41,8 @@ Creating account and setting custom messenger
* const account = new Account(); * const account = new Account();
* const customMessenger = new Messenger( * const customMessenger = new Messenger(
* new HttpProvider('https://api.s0.b.hmny.io'), * new HttpProvider('https://api.s0.b.hmny.io'),
* ChainType.Woop, * ChainType.Harmony,
* ChainID.WikiTestnet, * ChainID.HmyTestnet,
* ); * );
account.setMessenger(customMessenger); account.setMessenger(customMessenger);
@ -73,8 +73,8 @@ Get the account balance
* '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e', * '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e',
* new Messenger( * new Messenger(
* new HttpProvider('https://api.s0.b.hmny.io'), * new HttpProvider('https://api.s0.b.hmny.io'),
* ChainType.Woop, * ChainType.Harmony,
* ChainID.WikiTestnet, * ChainID.HmyTestnet,
* ), * ),
* ); * );
* account.getBalance().then(response => { * account.getBalance().then(response => {
@ -89,12 +89,12 @@ Create a transaction and account, and sign it
* '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e', * '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e',
* new Messenger( * new Messenger(
* new HttpProvider('https://api.s0.b.hmny.io'), * new HttpProvider('https://api.s0.b.hmny.io'),
* ChainType.Woop, * ChainType.Harmony,
* ChainID.WikiTestnet, * ChainID.HmyTestnet,
* ), * ),
* ); * );
* const { TransactionFactory } = require('@woop-js/transaction'); * const { TransactionFactory } = require('@harmony-js/transaction');
* const { Unit } = require('@woop-js/utils'); * const { Unit } = require('@harmony-js/utils');
* const factory = new TransactionFactory(); * const factory = new TransactionFactory();
* const txn = factory.newTx({ * const txn = factory.newTx({
@ -121,7 +121,7 @@ A wallet represents user wallet that can hold one or more user accounts.
Creating an empty wallet Creating an empty wallet
```javascript ```javascript
* const { Wallet } = require('@woop-js/account') * const { Wallet } = require('@harmony-js/account')
* const wallet = new Wallet(); * const wallet = new Wallet();
``` ```
@ -130,8 +130,8 @@ Setting a messenger to be used to send wallet transactions
* wallet.setMessenger( * wallet.setMessenger(
* new Messenger( * new Messenger(
* new HttpProvider('https://api.s0.b.hmny.io'), * new HttpProvider('https://api.s0.b.hmny.io'),
* ChainType.Woop, * ChainType.Harmony,
* ChainID.WikiTestnet, * ChainID.HmyTestnet,
* ), * ),
* ); * );
``` ```
@ -141,8 +141,8 @@ Create an empty wallet with messenger
* const wallet = new Wallet( * const wallet = new Wallet(
* new Messenger( * new Messenger(
* new HttpProvider('https://api.s0.b.hmny.io'), * new HttpProvider('https://api.s0.b.hmny.io'),
* ChainType.Woop, * ChainType.Harmony,
* ChainID.WikiTestnet, * ChainID.HmyTestnet,
* ), * ),
* ); * );
``` ```
@ -169,7 +169,7 @@ Adding account using keystore file
Creating a new account using passphrase Creating a new account using passphrase
```javascript ```javascript
* const passphrase = 'woop-chain'; * const passphrase = 'harmony-one';
* wallet.createAccount(passphrase).then(account => { * wallet.createAccount(passphrase).then(account => {
* console.log(account.bech32Address); * console.log(account.bech32Address);
* }); * });
@ -211,7 +211,7 @@ Sign transaction using wallet, will sign the transaction using the wallet signer
Similarily staking transactions can be signed using `signStaking` api. Similarily staking transactions can be signed using `signStaking` api.
* *
* @packageDocumentation * @packageDocumentation
* @module woop-account * @module harmony-account
*/ */
/**@ignore */ /**@ignore */

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

@ -1,6 +1,6 @@
/** /**
* @packageDocumentation * @packageDocumentation
* @module woop-account * @module harmony-account
* *
*/ */
@ -15,7 +15,7 @@ import {
Keystore, Keystore,
Signature, Signature,
getAddress, getAddress,
} from '@woop-js/crypto'; } from '@harmony-js/crypto';
import { import {
isPrivateKey, isPrivateKey,
@ -23,10 +23,10 @@ import {
hexToNumber, hexToNumber,
AddressSuffix, AddressSuffix,
ChainType, ChainType,
} from '@woop-js/utils'; } from '@harmony-js/utils';
import { Transaction, RLPSign } from '@woop-js/transaction'; import { Transaction, RLPSign } from '@harmony-js/transaction';
import { StakingTransaction } from '@woop-js/staking'; import { StakingTransaction } from '@harmony-js/staking';
import { Messenger, RPCMethod } from '@woop-js/network'; import { Messenger, RPCMethod } from '@harmony-js/network';
import { Shards } from './types'; import { Shards } from './types';
import { defaultMessenger } from './utils'; import { defaultMessenger } from './utils';
@ -141,18 +141,18 @@ class Account {
* @example * @example
* ```javascript * ```javascript
* // import the Account class * // import the Account class
* const { Account } = require('@woop-js/account'); * const { Account } = require('@harmony-js/account');
* *
* // Messenger is optional, by default, we have a defaultMessenger * // Messenger is optional, by default, we have a defaultMessenger
* // If you like to change, you will import related package here. * // If you like to change, you will import related package here.
* const { HttpProvider, Messenger } = require('@woop-js/network'); * const { HttpProvider, Messenger } = require('@harmony-js/network');
* const { ChainType, ChainID } = require('@woop-js/utils'); * const { ChainType, ChainID } = require('@harmony-js/utils');
* *
* // create a custom messenger * // create a custom messenger
* const customMessenger = new Messenger( * const customMessenger = new Messenger(
* new HttpProvider('http://localhost:9500'), * new HttpProvider('http://localhost:9500'),
* ChainType.Woop, // if you are connected to Woop's blockchain * ChainType.Harmony, // if you are connected to Harmony's blockchain
* ChainID.WikiLocal, // check if the chainId is correct * ChainID.HmyLocal, // check if the chainId is correct
* ) * )
* *
* // setMessenger later * // setMessenger later
@ -306,7 +306,7 @@ class Account {
transaction.setParams({ transaction.setParams({
...transaction.txParams, ...transaction.txParams,
from: from:
this.messenger.chainPrefix === ChainType.Woop this.messenger.chainPrefix === ChainType.Harmony
? this.bech32Address ? this.bech32Address
: this.checksumAddress || '0x', : this.checksumAddress || '0x',
nonce: shardNonce, nonce: shardNonce,
@ -324,7 +324,7 @@ class Account {
signature, signature,
rawTransaction, rawTransaction,
from: from:
this.messenger.chainPrefix === ChainType.Woop this.messenger.chainPrefix === ChainType.Harmony
? this.bech32Address ? this.bech32Address
: this.checksumAddress || '0x', : this.checksumAddress || '0x',
}; };
@ -363,7 +363,7 @@ class Account {
blockNumber, blockNumber,
); );
staking.setFromAddress( staking.setFromAddress(
this.messenger.chainPrefix === ChainType.Woop this.messenger.chainPrefix === ChainType.Harmony
? this.bech32Address ? this.bech32Address
: this.checksumAddress || '0x', : this.checksumAddress || '0x',
); );
@ -375,7 +375,7 @@ class Account {
staking.setRawTransaction(rawTransaction); staking.setRawTransaction(rawTransaction);
staking.setSignature(signature); staking.setSignature(signature);
staking.setFromAddress( staking.setFromAddress(
this.messenger.chainPrefix === ChainType.Woop this.messenger.chainPrefix === ChainType.Harmony
? this.bech32Address ? this.bech32Address
: this.checksumAddress || '0x', : this.checksumAddress || '0x',
); );
@ -395,8 +395,8 @@ class Account {
* // create a custom messenger * // create a custom messenger
* const customMessenger = new Messenger( * const customMessenger = new Messenger(
* new HttpProvider('http://localhost:9500'), * new HttpProvider('http://localhost:9500'),
* ChainType.Woop, // if you are connected to Woop's blockchain * ChainType.Harmony, // if you are connected to Harmony's blockchain
* ChainID.WikiLocal, // check if the chainId is correct * ChainID.HmyLocal, // check if the chainId is correct
* ) * )
* *
* // to create an Account with random privateKey * // to create an Account with random privateKey

@ -1,9 +1,9 @@
/** /**
* @packageDocumentation * @packageDocumentation
* @module woop-account * @module harmony-account
*/ */
import { bip39, hdkey, getAddress, BN, Signature } from '@woop-js/crypto'; import { bip39, hdkey, getAddress, BN, Signature } from '@harmony-js/crypto';
import { import {
HDPath, HDPath,
// defineReadOnly, // defineReadOnly,
@ -14,9 +14,9 @@ import {
Unit, Unit,
isHex, isHex,
hexToNumber, hexToNumber,
} from '@woop-js/utils'; } from '@harmony-js/utils';
import { Messenger, HttpProvider, WSProvider, RPCMethod } from '@woop-js/network'; import { Messenger, HttpProvider, WSProvider, RPCMethod } from '@harmony-js/network';
import { Transaction, TxStatus, TransasctionReceipt } from '@woop-js/transaction'; import { Transaction, TxStatus, TransasctionReceipt } from '@harmony-js/transaction';
import { Account } from './account'; import { Account } from './account';
/** @hidden */ /** @hidden */
@ -81,7 +81,7 @@ export class HDNode {
index: number = 0, index: number = 0,
addressCount: number = 1, addressCount: number = 1,
shardID: number = 0, shardID: number = 0,
chainType: ChainType = ChainType.Woop, chainType: ChainType = ChainType.Harmony,
chainId: ChainID = ChainID.Default, chainId: ChainID = ChainID.Default,
gasLimit = '1000000', gasLimit = '1000000',
gasPrice = '2000000000', gasPrice = '2000000000',
@ -93,7 +93,7 @@ export class HDNode {
this.hdwallet = undefined; this.hdwallet = undefined;
this.addresses = []; this.addresses = [];
this.wallets = {}; this.wallets = {};
this.path = chainType === ChainType.Woop ? HDPath : `m/44'/60'/0'/0/`; this.path = chainType === ChainType.Harmony ? HDPath : `m/44'/60'/0'/0/`;
this.index = index; this.index = index;
this.addressCount = addressCount; this.addressCount = addressCount;
if (menmonic !== null && menmonic !== '') { if (menmonic !== null && menmonic !== '') {
@ -176,7 +176,7 @@ export class HDNode {
const accountNonce = await this.messenger.send( const accountNonce = await this.messenger.send(
RPCMethod.GetAccountNonce, RPCMethod.GetAccountNonce,
[from, 'latest'], [from, 'latest'],
'wiki', 'hmy',
this.shardID, this.shardID,
); );

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

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

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

@ -1,16 +1,16 @@
/** /**
* @packageDocumentation * @packageDocumentation
* @module woop-account * @module harmony-account
* @ignore * @ignore
*/ */
import fetch from 'jest-fetch-mock'; import fetch from 'jest-fetch-mock';
import { Account } from '../src/account'; import { Account } from '../src/account';
import { HttpProvider, Messenger } from '@woop-js/network'; import { HttpProvider, Messenger } from '@harmony-js/network';
import { ChainType, ChainID } from '@woop-js/utils'; import { ChainType, ChainID } from '@harmony-js/utils';
const provider = new HttpProvider('http://localhost:9500'); const provider = new HttpProvider('http://localhost:9500');
const messenger = new Messenger(provider, ChainType.Woop, ChainID.WikiLocal); const messenger = new Messenger(provider, ChainType.Harmony, ChainID.HmyLocal);
describe('test account', () => { describe('test account', () => {
it('test Account.getBalance returns object that implements Balance interface', () => { it('test Account.getBalance returns object that implements Balance interface', () => {

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

@ -61,15 +61,15 @@
"type": "function" "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/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}", "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}",
"bytecode": "0x60806040526000805534801561001457600080fd5b506101a0806100246000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80635b34b96614610046578063a87d942c14610050578063f5c5ad831461006e575b600080fd5b61004e610078565b005b6100586100ed565b6040518082815260200191505060405180910390f35b6100766100f6565b005b600160008082825401925050819055507f064b1e66d8d787e36504c45aac3405f69335030ab8dc365a34919de13b61799c33604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a1565b60008054905090565b600160008082825403925050819055507f102d4e03b331a68eaffb991d44063c4452a0b6b650d8fb74b6932d8bd856f1c133604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a156fea265627a7a72315820963135863e1328fe0c11fedc623e29e097902650e6976e7650a1577c1086fc6a64736f6c63430005100032", "bytecode": "0x60806040526000805534801561001457600080fd5b506101a0806100246000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80635b34b96614610046578063a87d942c14610050578063f5c5ad831461006e575b600080fd5b61004e610078565b005b6100586100ed565b6040518082815260200191505060405180910390f35b6100766100f6565b005b600160008082825401925050819055507f064b1e66d8d787e36504c45aac3405f69335030ab8dc365a34919de13b61799c33604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a1565b60008054905090565b600160008082825403925050819055507f102d4e03b331a68eaffb991d44063c4452a0b6b650d8fb74b6932d8bd856f1c133604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a156fea265627a7a72315820963135863e1328fe0c11fedc623e29e097902650e6976e7650a1577c1086fc6a64736f6c63430005100032",
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100415760003560e01c80635b34b96614610046578063a87d942c14610050578063f5c5ad831461006e575b600080fd5b61004e610078565b005b6100586100ed565b6040518082815260200191505060405180910390f35b6100766100f6565b005b600160008082825401925050819055507f064b1e66d8d787e36504c45aac3405f69335030ab8dc365a34919de13b61799c33604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a1565b60008054905090565b600160008082825403925050819055507f102d4e03b331a68eaffb991d44063c4452a0b6b650d8fb74b6932d8bd856f1c133604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a156fea265627a7a72315820963135863e1328fe0c11fedc623e29e097902650e6976e7650a1577c1086fc6a64736f6c63430005100032", "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;;;;;;;", "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", "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", "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/woop-chain/counter/contracts/Counter.sol", "sourcePath": "/Users/gupadhyaya/go/src/github.com/harmony-one/counter/contracts/Counter.sol",
"ast": { "ast": {
"absolutePath": "/Users/gupadhyaya/go/src/github.com/woop-chain/counter/contracts/Counter.sol", "absolutePath": "/Users/gupadhyaya/go/src/github.com/harmony-one/counter/contracts/Counter.sol",
"exportedSymbols": { "exportedSymbols": {
"Counter": [47] "Counter": [47]
}, },
@ -617,7 +617,7 @@
"src": "0:461:0" "src": "0:461:0"
}, },
"legacyAST": { "legacyAST": {
"absolutePath": "/Users/gupadhyaya/go/src/github.com/woop-chain/counter/contracts/Counter.sol", "absolutePath": "/Users/gupadhyaya/go/src/github.com/harmony-one/counter/contracts/Counter.sol",
"exportedSymbols": { "exportedSymbols": {
"Counter": [47] "Counter": [47]
}, },

@ -1,27 +1,27 @@
# @woop-js/contract # @harmony-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. 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.
## Installation ## Installation
``` ```
npm install @woop-js/contract npm install @harmony-js/contract
``` ```
## Usage ## Usage
Deploying a contract using `contractConstructor` Deploying a contract using `contractConstructor`
```javascript ```javascript
const { ContractFactory } = require('@woop-js/contract'); const { ContractFactory } = require('@harmony-js/contract');
const { Wallet } = require('@woop-js/account'); const { Wallet } = require('@harmony-js/account');
const { Messenger, HttpProvider } = require('@woop-js/network'); const { Messenger, HttpProvider } = require('@harmony-js/network');
const { ChainID, ChainType, hexToNumber } = require('@woop-js/utils'); const { ChainID, ChainType, hexToNumber } = require('@harmony-js/utils');
const wallet = new Wallet( const wallet = new Wallet(
new Messenger( new Messenger(
new HttpProvider('https://api.s0.b.hmny.io'), new HttpProvider('https://api.s0.b.hmny.io'),
ChainType.Woop, ChainType.Harmony,
ChainID.WikiTestnet, ChainID.HmyTestnet,
), ),
); );
const factory = new ContractFactory(wallet); 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 Loading a contract object using the contract json and contract address for interacting with it
```javascript ```javascript
const { Woop } = require("@woop-js/core"); const { Harmony } = require("@harmony-js/core");
const { ChainID, ChainType } = require("@woop-js/utils"); const { ChainID, ChainType } = require("@harmony-js/utils");
const wiki = new Woop("https://api.s0.b.hmny.io", { const hmy = new Harmony("https://api.s0.b.hmny.io", {
chainType: ChainType.Woop, chainType: ChainType.Harmony,
chainId: ChainID.WikiTestnet, chainId: ChainID.HmyTestnet,
}); });
const contractJson = require("./Counter.json"); const contractJson = require("./Counter.json");
const contractAddr = "0x19f64050e6b2d376e52AC426E366c49EEb0724B1"; const contractAddr = "0x19f64050e6b2d376e52AC426E366c49EEb0724B1";
const contract = wiki.contracts.createContract(contractJson.abi, contractAddr); const contract = hmy.contracts.createContract(contractJson.abi, contractAddr);
console.log(contract.methods); console.log(contract.methods);
``` ```
Directly loading contract using `ContractFactory` Directly loading contract using `ContractFactory`
```javascript ```javascript
const { ContractFactory } = require('@woop-js/contract'); const { ContractFactory } = require('@harmony-js/contract');
const { Wallet } = require('@woop-js/account'); const { Wallet } = require('@harmony-js/account');
const { Messenger, HttpProvider } = require('@woop-js/network'); const { Messenger, HttpProvider } = require('@harmony-js/network');
const { ChainID, ChainType, hexToNumber } = require('@woop-js/utils'); const { ChainID, ChainType, hexToNumber } = require('@harmony-js/utils');
const wallet = new Wallet(new Messenger( const wallet = new Wallet(new Messenger(
new HttpProvider('https://api.s0.b.hmny.io'), new HttpProvider('https://api.s0.b.hmny.io'),
ChainType.Woop, ChainType.Harmony,
ChainID.WikiTestnet, ChainID.HmyTestnet,
)); ));
const factory = new ContractFactory(wallet); const factory = new ContractFactory(wallet);
const contract = factory.createContract(contractJson.abi, contractAddr); const contract = factory.createContract(contractJson.abi, contractAddr);
@ -86,7 +86,7 @@ contract.methods.getCount().estimateGas(options1).then(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. 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.
```javascript ```javascript
const options1 = { gasPrice: '0x3B9ACA00' }; // gas price in hex corresponds to 1 Gwei or 1000000000 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 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. Subscribing to the contract events requires web socket based messenger.
```javascript ```javascript
const { ContractFactory } = require('@woop-js/contract'); const { ContractFactory } = require('@harmony-js/contract');
const { Wallet } = require('@woop-js/account'); const { Wallet } = require('@harmony-js/account');
const { Messenger, WSProvider } = require('@woop-js/network'); const { Messenger, WSProvider } = require('@harmony-js/network');
const { ChainID, ChainType, hexToNumber } = require('@woop-js/utils'); const { ChainID, ChainType, hexToNumber } = require('@harmony-js/utils');
const ws = new WSProvider('wss://ws.s0.b.hmny.io'); const ws = new WSProvider('wss://ws.s0.b.hmny.io');
const wallet = new Wallet( const wallet = new Wallet(
new Messenger( new Messenger(
ws, ws,
ChainType.Woop, ChainType.Harmony,
ChainID.WikiTestnet, ChainID.HmyTestnet,
), ),
); );
const factory = new ContractFactory(wallet); const factory = new ContractFactory(wallet);

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

@ -1,28 +1,28 @@
/** /**
# @woop-js/contract # @harmony-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. 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.
## Installation ## Installation
``` ```
npm install @woop-js/contract npm install @harmony-js/contract
``` ```
## Usage ## Usage
Deploying a contract using `contractConstructor` Deploying a contract using `contractConstructor`
```javascript ```javascript
const { ContractFactory } = require('@woop-js/contract'); const { ContractFactory } = require('@harmony-js/contract');
const { Wallet } = require('@woop-js/account'); const { Wallet } = require('@harmony-js/account');
const { Messenger, HttpProvider } = require('@woop-js/network'); const { Messenger, HttpProvider } = require('@harmony-js/network');
const { ChainID, ChainType, hexToNumber } = require('@woop-js/utils'); const { ChainID, ChainType, hexToNumber } = require('@harmony-js/utils');
* const wallet = new Wallet( * const wallet = new Wallet(
* new Messenger( * new Messenger(
* new HttpProvider('https://api.s0.b.hmny.io'), * new HttpProvider('https://api.s0.b.hmny.io'),
* ChainType.Woop, * ChainType.Harmony,
* ChainID.WikiTestnet, * ChainID.HmyTestnet,
* ), * ),
* ); * );
* const factory = new ContractFactory(wallet); * const factory = new ContractFactory(wallet);
@ -48,31 +48,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 Loading a contract object using the contract json and contract address for interacting with it
```javascript ```javascript
* const { Woop } = require("@woop-js/core"); * const { Harmony } = require("@harmony-js/core");
* const { ChainID, ChainType } = require("@woop-js/utils"); * const { ChainID, ChainType } = require("@harmony-js/utils");
* const wiki = new Woop("https://api.s0.b.hmny.io", { * const hmy = new Harmony("https://api.s0.b.hmny.io", {
* chainType: ChainType.Woop, * chainType: ChainType.Harmony,
* chainId: ChainID.WikiTestnet, * chainId: ChainID.HmyTestnet,
* }); * });
const contractJson = require("./Counter.json"); const contractJson = require("./Counter.json");
const contractAddr = "0x19f64050e6b2d376e52AC426E366c49EEb0724B1"; const contractAddr = "0x19f64050e6b2d376e52AC426E366c49EEb0724B1";
const contract = wiki.contracts.createContract(contractJson.abi, contractAddr); const contract = hmy.contracts.createContract(contractJson.abi, contractAddr);
console.log(contract.methods); console.log(contract.methods);
``` ```
Directly loading contract using `ContractFactory` Directly loading contract using `ContractFactory`
```javascript ```javascript
const { ContractFactory } = require('@woop-js/contract'); const { ContractFactory } = require('@harmony-js/contract');
const { Wallet } = require('@woop-js/account'); const { Wallet } = require('@harmony-js/account');
const { Messenger, HttpProvider } = require('@woop-js/network'); const { Messenger, HttpProvider } = require('@harmony-js/network');
const { ChainID, ChainType, hexToNumber } = require('@woop-js/utils'); const { ChainID, ChainType, hexToNumber } = require('@harmony-js/utils');
* const wallet = new Wallet(new Messenger( * const wallet = new Wallet(new Messenger(
* new HttpProvider('https://api.s0.b.hmny.io'), * new HttpProvider('https://api.s0.b.hmny.io'),
* ChainType.Woop, * ChainType.Harmony,
* ChainID.WikiTestnet, * ChainID.HmyTestnet,
* )); * ));
const factory = new ContractFactory(wallet); const factory = new ContractFactory(wallet);
const contract = factory.createContract(contractJson.abi, contractAddr); const contract = factory.createContract(contractJson.abi, contractAddr);
@ -87,7 +87,7 @@ Estimate gas for contract methods
* }); * });
``` ```
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. 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.
```javascript ```javascript
* const options1 = { gasPrice: '0x3B9ACA00' }; // gas price in hex corresponds to 1 Gwei or 1000000000 * 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 * let options2 = { gasPrice: 1000000000, gasLimit: 21000 }; // setting the default gas limit, but changing later based on estimate gas
@ -119,17 +119,17 @@ All the above apis can also be asynchronously executed using `async` and `await`
Subscribing to the contract events requires web socket based messenger. Subscribing to the contract events requires web socket based messenger.
```javascript ```javascript
* const { ContractFactory } = require('@woop-js/contract'); * const { ContractFactory } = require('@harmony-js/contract');
* const { Wallet } = require('@woop-js/account'); * const { Wallet } = require('@harmony-js/account');
* const { Messenger, WSProvider } = require('@woop-js/network'); * const { Messenger, WSProvider } = require('@harmony-js/network');
* const { ChainID, ChainType, hexToNumber } = require('@woop-js/utils'); * const { ChainID, ChainType, hexToNumber } = require('@harmony-js/utils');
* const ws = new WSProvider('wss://ws.s0.b.hmny.io'); * const ws = new WSProvider('wss://ws.s0.b.hmny.io');
* const wallet = new Wallet( * const wallet = new Wallet(
* new Messenger( * new Messenger(
* ws, * ws,
* ChainType.Woop, * ChainType.Harmony,
* ChainID.WikiTestnet, * ChainID.HmyTestnet,
* ), * ),
* ); * );
* const factory = new ContractFactory(wallet); * const factory = new ContractFactory(wallet);
@ -148,7 +148,7 @@ Subscribing to the contract events requires web socket based messenger.
``` ```
* *
* @packageDocumentation * @packageDocumentation
* @module woop-contract * @module harmony-contract
*/ */
// this file is mainly ported from `ethers.js`, but done some fixes // this file is mainly ported from `ethers.js`, but done some fixes
@ -171,8 +171,8 @@ import {
Arrayish, Arrayish,
checkNew, checkNew,
bytesPadRight, bytesPadRight,
} from '@woop-js/crypto'; } from '@harmony-js/crypto';
import { hexToBN, defineReadOnly } from '@woop-js/utils'; import { hexToBN, defineReadOnly } from '@harmony-js/utils';
/** @hidden */ /** @hidden */
const NegativeOne: BN = new BN(-1); const NegativeOne: BN = new BN(-1);

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

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

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

@ -1,12 +1,12 @@
/** /**
* @packageDocumentation * @packageDocumentation
* @module woop-contract * @module harmony-contract
* *
*/ */
import { Wallet } from '@woop-js/account'; import { Wallet } from '@harmony-js/account';
import { Messenger } from '@woop-js/network'; import { Messenger } from '@harmony-js/network';
import { Transaction } from '@woop-js/transaction'; import { Transaction } from '@harmony-js/transaction';
import { AbiCoder } from './abi/index'; import { AbiCoder } from './abi/index';
import { abiMapper } from './utils/mapper'; import { abiMapper } from './utils/mapper';
import { ContractOptions } from './utils/options'; import { ContractOptions } from './utils/options';

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

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

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

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

@ -1,13 +1,13 @@
/** /**
* @packageDocumentation * @packageDocumentation
* @module woop-contract * @module harmony-contract
*/ */
import { Wallet } from '@woop-js/account'; import { Wallet } from '@harmony-js/account';
import { TransactionFactory, Transaction, TxStatus } from '@woop-js/transaction'; import { TransactionFactory, Transaction, TxStatus } from '@harmony-js/transaction';
import { RPCMethod, getResultForData, Emitter } from '@woop-js/network'; import { RPCMethod, getResultForData, Emitter } from '@harmony-js/network';
import { hexToBN, Unit } from '@woop-js/utils'; import { hexToBN, Unit } from '@harmony-js/utils';
import { getAddress } from '@woop-js/crypto'; import { getAddress } from '@harmony-js/crypto';
import { AbiItemModel } from '../models/types'; import { AbiItemModel } from '../models/types';
import { Contract } from '../contract'; import { Contract } from '../contract';
import { methodEncoder } from '../utils/encoder'; import { methodEncoder } from '../utils/encoder';

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -1,20 +1,20 @@
/** /**
# @woop-js/core # @harmony-js/core
This package provides a collection of apis to interact with Woop blockchain. This package provides a collection of apis to interact with Harmony blockchain.
## Installation ## Installation
``` ```
npm install @woop-js/core npm install @harmony-js/core
``` ```
## Usage ## Usage
Create a Woop instance connecting to testnet Create a Harmony instance connecting to testnet
```javascript ```javascript
* const { Woop } = require('@woop-js/core'); * const { Harmony } = require('@harmony-js/core');
* const { * const {
* ChainID, * ChainID,
* ChainType, * ChainType,
@ -23,20 +23,20 @@ Create a Woop instance connecting to testnet
* fromWei, * fromWei,
* Units, * Units,
* Unit, * Unit,
* } = require('@woop-js/utils'); * } = require('@harmony-js/utils');
* const wiki = new Woop( * const hmy = new Harmony(
* 'https://api.s0.b.hmny.io/', * 'https://api.s0.b.hmny.io/',
* { * {
* chainType: ChainType.Woop, * chainType: ChainType.Harmony,
* chainId: ChainID.WikiTestnet, * chainId: ChainID.HmyTestnet,
* }, * },
* ); * );
``` ```
Getting balance of account `one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7` Getting balance of account `one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7`
```javascript ```javascript
* wiki.blockchain * hmy.blockchain
* .getBalance({ address: 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7' }) * .getBalance({ address: 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7' })
* .then((response) => { * .then((response) => {
* console.log('balance in ONEs: ' + fromWei(hexToNumber(response.result), Units.one)); * console.log('balance in ONEs: ' + fromWei(hexToNumber(response.result), Units.one));
@ -45,14 +45,14 @@ Getting balance of account `one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7`
Getting the latest block number Getting the latest block number
```javascript ```javascript
* wiki.blockchain.getBlockNumber().then((response) => { * hmy.blockchain.getBlockNumber().then((response) => {
* console.log('current block number: ' + hexToNumber(response.result)); * console.log('current block number: ' + hexToNumber(response.result));
* }); * });
``` ```
Getting the block using block hash Getting the block using block hash
```javascript ```javascript
* wiki.blockchain * hmy.blockchain
* .getBlockByHash({ * .getBlockByHash({
* blockHash: '0x08c46ae7249362a7d1f602d44c5a81f33ebdab6a7dcb6068f99610b57911aafd', * blockHash: '0x08c46ae7249362a7d1f602d44c5a81f33ebdab6a7dcb6068f99610b57911aafd',
* }) * })
@ -63,7 +63,7 @@ Getting the block using block hash
Getting the block using block number Getting the block using block number
```javascript ```javascript
* wiki.blockchain * hmy.blockchain
* .getBlockByNumber({ * .getBlockByNumber({
* blockNumber: numberToHex(422635), * blockNumber: numberToHex(422635),
* }) * })
@ -74,7 +74,7 @@ Getting the block using block number
Getting the transaction using hash Getting the transaction using hash
```javascript ```javascript
* wiki.blockchain * hmy.blockchain
* .getTransactionByHash({ * .getTransactionByHash({
* txnHash: '0x56c73eb993b18dc04baacec5c2e9d1292a090f6a978a4a1c461db5255fcbc831', * txnHash: '0x56c73eb993b18dc04baacec5c2e9d1292a090f6a978a4a1c461db5255fcbc831',
* }) * })
@ -85,7 +85,7 @@ Getting the transaction using hash
Getting the transaction receipt Getting the transaction receipt
```javascript ```javascript
* wiki.blockchain * hmy.blockchain
* .getTransactionReceipt({ * .getTransactionReceipt({
* txnHash: '0x56c73eb993b18dc04baacec5c2e9d1292a090f6a978a4a1c461db5255fcbc831', * txnHash: '0x56c73eb993b18dc04baacec5c2e9d1292a090f6a978a4a1c461db5255fcbc831',
* }) * })
@ -96,7 +96,7 @@ Getting the transaction receipt
Getting the cross-shard transaction receipt Getting the cross-shard transaction receipt
```javascript ```javascript
* wiki.blockchain * hmy.blockchain
* .getCxReceiptByHash({ * .getCxReceiptByHash({
* txnHash: '0xcd36a90ff5d5373285c2896ba7bbcd3f5324263c0cb8ecfb7cad2f5fc2fbdbda', * txnHash: '0xcd36a90ff5d5373285c2896ba7bbcd3f5324263c0cb8ecfb7cad2f5fc2fbdbda',
* shardID: 1, * shardID: 1,
@ -108,7 +108,7 @@ Getting the cross-shard transaction receipt
Getting the deployed smart contract code Getting the deployed smart contract code
```javascript ```javascript
* wiki.blockchain * hmy.blockchain
* .getCode({ * .getCode({
* address: '0x08AE1abFE01aEA60a47663bCe0794eCCD5763c19', * address: '0x08AE1abFE01aEA60a47663bCe0794eCCD5763c19',
* blockNumber: 'latest', * blockNumber: 'latest',
@ -120,7 +120,7 @@ Getting the deployed smart contract code
Getting the transaction count of an account Getting the transaction count of an account
```javascript ```javascript
* wiki.blockchain * hmy.blockchain
* .getTransactionCount({ * .getTransactionCount({
* address: 'one1pdv9lrdwl0rg5vglh4xtyrv3wjk3wsqket7zxy', * address: 'one1pdv9lrdwl0rg5vglh4xtyrv3wjk3wsqket7zxy',
* }) * })
@ -131,7 +131,7 @@ Getting the transaction count of an account
Getting the shard structure and details Getting the shard structure and details
```javascript ```javascript
* wiki.blockchain.getShardingStructure().then((response) => { * hmy.blockchain.getShardingStructure().then((response) => {
* console.log(response.result); * console.log(response.result);
* }); * });
``` ```
@ -139,10 +139,10 @@ Getting the shard structure and details
Transferring funds using `sendTransaction` Transferring funds using `sendTransaction`
```javascript ```javascript
// key corresponds to one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7, only has testnet balance // key corresponds to one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7, only has testnet balance
* wiki.wallet.addByPrivateKey('45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e'); * hmy.wallet.addByPrivateKey('45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e');
* async function transfer() { * async function transfer() {
* const txn = wiki.transactions.newTx({ * const txn = hmy.transactions.newTx({
* to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2', * to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2',
* value: new Unit(1).asOne().toWei(), * value: new Unit(1).asOne().toWei(),
* // gas limit, you can use string * // gas limit, you can use string
@ -152,12 +152,12 @@ Transferring funds using `sendTransaction`
* // send token to toShardID * // send token to toShardID
* toShardID: 0, * toShardID: 0,
* // gas Price, you can use Unit class, and use Gwei, then remember to use toWei(), which will be transformed to BN * // 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(), * gasPrice: new hmy.utils.Unit('1').asGwei().toWei(),
* }); * });
* // sign the transaction use wallet; * // sign the transaction use wallet;
* const signedTxn = await wiki.wallet.signTransaction(txn); * const signedTxn = await hmy.wallet.signTransaction(txn);
* const txnHash = await wiki.blockchain.sendTransaction(signedTxn); * const txnHash = await hmy.blockchain.sendTransaction(signedTxn);
* console.log(txnHash.result); * console.log(txnHash.result);
* } * }
@ -165,7 +165,7 @@ Transferring funds using `sendTransaction`
``` ```
* *
* @packageDocumentation * @packageDocumentation
* @module woop-core * @module harmony-core
*/ */
import { import {
@ -177,19 +177,19 @@ import {
NewHeaders, NewHeaders,
LogSub, LogSub,
Syncing, Syncing,
} from '@woop-js/network'; } from '@harmony-js/network';
import { import {
assertObject, assertObject,
AssertType, AssertType,
// WoopCore, // HarmonyCore,
DefaultBlockParams, DefaultBlockParams,
} from '@woop-js/utils'; } from '@harmony-js/utils';
import { getAddress } from '@woop-js/crypto'; import { getAddress } from '@harmony-js/crypto';
import { Transaction } from '@woop-js/transaction'; import { Transaction } from '@harmony-js/transaction';
import { StakingTransaction } from '@woop-js/staking'; import { StakingTransaction } from '@harmony-js/staking';
class Blockchain { class Blockchain {
/** /**
@ -241,7 +241,7 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* wiki.blockchain.getBalance({ * hmy.blockchain.getBalance({
* address: 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7', * address: 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7',
* blockNumber: 'latest' * blockNumber: 'latest'
* }).then(value => { * }).then(value => {
@ -287,7 +287,7 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* wiki.blockchain.getBlockNumber().then((value) => { * hmy.blockchain.getBlockNumber().then((value) => {
* console.log(value.result); * console.log(value.result);
* }); * });
* ``` * ```
@ -312,7 +312,7 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* wiki.blockchain.getBlockByHash({ * hmy.blockchain.getBlockByHash({
* blockHash: '0x9cd821b576efdff61280e8857ef218fb2cff8db0cf0fb27dfceef7237042b79e', * blockHash: '0x9cd821b576efdff61280e8857ef218fb2cff8db0cf0fb27dfceef7237042b79e',
* }).then((value) => { * }).then((value) => {
* console.log(value); * console.log(value);
@ -352,7 +352,7 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* wiki.blockchain.getBlockByNumber({ * hmy.blockchain.getBlockByNumber({
* blockNumber: '0x89', * blockNumber: '0x89',
* }).then((value) => { * }).then((value) => {
* console.log(value); * console.log(value);
@ -393,7 +393,7 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* wiki.blockchain.getBlocks({ * hmy.blockchain.getBlocks({
* from: '0x89', * from: '0x89',
* to: '0x89', * to: '0x89',
* }).then((value) => { * }).then((value) => {
@ -442,7 +442,7 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* wiki.blockchain.getBlockTransactionCountByHash({ * hmy.blockchain.getBlockTransactionCountByHash({
* blockHash: '0x4142514a238157e7fe57b9d54abedb33943507fa15b3799954c273a12705ced1' * blockHash: '0x4142514a238157e7fe57b9d54abedb33943507fa15b3799954c273a12705ced1'
* }).then((value) => { * }).then((value) => {
* console.log(value): * console.log(value):
@ -478,7 +478,7 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* wiki.blockchain.getBlockTransactionCountByNumber({ * hmy.blockchain.getBlockTransactionCountByNumber({
* blockNumber: '0x2403C' * blockNumber: '0x2403C'
* }).then((value) => { * }).then((value) => {
* console.log(value); * console.log(value);
@ -515,7 +515,7 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* wiki.blockchain.getTransactionByBlockHashAndIndex({ * hmy.blockchain.getTransactionByBlockHashAndIndex({
* blockHash: '0x4142514a238157e7fe57b9d54abedb33943507fa15b3799954c273a12705ced1', * blockHash: '0x4142514a238157e7fe57b9d54abedb33943507fa15b3799954c273a12705ced1',
* index: '0x0' * index: '0x0'
* }).then((value) => { * }).then((value) => {
@ -556,7 +556,7 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* wiki.blockchain.getTransactionByBlockNumberAndIndex({ * hmy.blockchain.getTransactionByBlockNumberAndIndex({
* blockNumber: '0x2403C', * blockNumber: '0x2403C',
* index: '0x0' * index: '0x0'
* }).then((value) => { * }).then((value) => {
@ -596,7 +596,7 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* wiki.blockchain.getTransactionByHash({ * hmy.blockchain.getTransactionByHash({
* txnHash: '0x146a0cf7e8da45b44194207c4e7785564527059483b765f9a04424554443b224' * txnHash: '0x146a0cf7e8da45b44194207c4e7785564527059483b765f9a04424554443b224'
* }).then((value) => { * }).then((value) => {
* console.log(value); * console.log(value);
@ -632,7 +632,7 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* wiki.blockchain.getTransactionReceipt({ * hmy.blockchain.getTransactionReceipt({
* txnHash: '0x146a0cf7e8da45b44194207c4e7785564527059483b765f9a04424554443b224' * txnHash: '0x146a0cf7e8da45b44194207c4e7785564527059483b765f9a04424554443b224'
* }).then((value) => { * }).then((value) => {
* console.log(value); * console.log(value);
@ -669,7 +669,7 @@ class Blockchain {
* @example * @example
* ```javascript * ```javascript
* // This transaction sends from shard 0 to shard 1 * // This transaction sends from shard 0 to shard 1
* wiki.blockchain.getCxReceiptByHash({ * hmy.blockchain.getCxReceiptByHash({
* txnHash: '0x7fae9252fbda68d718e610bc10cf2b5c6a9cafb42d4a6b9d6e392c77d587b9ea', * txnHash: '0x7fae9252fbda68d718e610bc10cf2b5c6a9cafb42d4a6b9d6e392c77d587b9ea',
* shardID: 1, * shardID: 1,
* }).then((value) => { * }).then((value) => {
@ -701,7 +701,7 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* wiki.blockchain.getCode({ * hmy.blockchain.getCode({
* address: '0x08AE1abFE01aEA60a47663bCe0794eCCD5763c19', * address: '0x08AE1abFE01aEA60a47663bCe0794eCCD5763c19',
* blockNumber: 'latest' * blockNumber: 'latest'
* }).then((value) => { * }).then((value) => {
@ -740,7 +740,7 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* wiki.blockchain.net_peerCount().then((value) => { * hmy.blockchain.net_peerCount().then((value) => {
* console.log(value.result); * console.log(value.result);
* }); * });
* ``` * ```
@ -759,7 +759,7 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* wiki.blockchain.net_version().then((value) => { * hmy.blockchain.net_version().then((value) => {
* console.log(value.result); * console.log(value.result);
* }); * });
* ``` * ```
@ -778,7 +778,7 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* wiki.blockchain.getProtocolVersion().then((value) => { * hmy.blockchain.getProtocolVersion().then((value) => {
* console.log(value.result); * console.log(value.result);
* }); * });
* ``` * ```
@ -803,7 +803,7 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* wiki.blockchain.getStorageAt({ * hmy.blockchain.getStorageAt({
* address: 'one1d0kw95t6kkljmkk9vu0zv25jraut8ngv5vrs5g', * address: 'one1d0kw95t6kkljmkk9vu0zv25jraut8ngv5vrs5g',
* position: '0x0' * position: '0x0'
* }).then((value) => { * }).then((value) => {
@ -847,7 +847,7 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* wiki.blockchain.getTransactionCount({ * hmy.blockchain.getTransactionCount({
* address: "one1d0kw95t6kkljmkk9vu0zv25jraut8ngv5vrs5g" * address: "one1d0kw95t6kkljmkk9vu0zv25jraut8ngv5vrs5g"
* }).then((value) => { * }).then((value) => {
* console.log(value.result); * console.log(value.result);
@ -884,7 +884,7 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* wiki.blockchain.getShardingStructure().then((value) => { * hmy.blockchain.getShardingStructure().then((value) => {
* console.log(value); * console.log(value);
* }); * });
* ``` * ```
@ -908,10 +908,10 @@ class Blockchain {
* ```javascript * ```javascript
* // add privateKey to wallet * // add privateKey to wallet
* const privateKey = '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e'; * const privateKey = '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e';
* wiki.wallet.addByPrivateKey(privateKey); * hmy.wallet.addByPrivateKey(privateKey);
* *
* async function transfer() { * async function transfer() {
* const txn = wiki.transactions.newTx({ * const txn = hmy.transactions.newTx({
* // token send to * // token send to
* to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2', * to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2',
* // amount to send * // amount to send
@ -923,12 +923,12 @@ class Blockchain {
* // send token to toShardID * // send token to toShardID
* toShardID: 0, * toShardID: 0,
* // gas Price, you can use Unit class, and use Gwei, then remember to use toWei(), which will be transformed to BN * // 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('100').asGwei().toWei(), * gasPrice: new hmy.utils.Unit('100').asGwei().toWei(),
* }); * });
* *
* // sign the transaction use wallet; * // sign the transaction use wallet;
* const signedTxn = await wiki.wallet.signTransaction(txn); * const signedTxn = await hmy.wallet.signTransaction(txn);
* const txnHash = await wiki.blockchain.sendTransaction(signedTxn); * const txnHash = await hmy.blockchain.sendTransaction(signedTxn);
* console.log(txnHash.result); * console.log(txnHash.result);
* } * }
* *
@ -960,10 +960,10 @@ class Blockchain {
* ```javascript * ```javascript
* // add privateKey to wallet * // add privateKey to wallet
* const privateKey = '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e'; * const privateKey = '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e';
* wiki.wallet.addByPrivateKey(privateKey); * hmy.wallet.addByPrivateKey(privateKey);
* *
* async function transfer() { * async function transfer() {
* const txn = wiki.transactions.newTx({ * const txn = hmy.transactions.newTx({
* // token send to * // token send to
* to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2', * to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2',
* // amount to send * // amount to send
@ -975,14 +975,14 @@ class Blockchain {
* // send token to toShardID * // send token to toShardID
* toShardID: 0, * toShardID: 0,
* // gas Price, you can use Unit class, and use Gwei, then remember to use toWei(), which will be transformed to BN * // 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('100').asGwei().toWei(), * gasPrice: new hmy.utils.Unit('100').asGwei().toWei(),
* }); * });
* *
* // sign the transaction use wallet; * // sign the transaction use wallet;
* const signedTxn = await wiki.wallet.signTransaction(txn); * const signedTxn = await hmy.wallet.signTransaction(txn);
* recovered = signedTxn.recover(signedTxn.rawTransaction); * recovered = signedTxn.recover(signedTxn.rawTransaction);
* *
* const txnHash = await wiki.blockchain.sendRawTransaction(recovered); * const txnHash = await hmy.blockchain.sendRawTransaction(recovered);
* console.log(txnHash); * console.log(txnHash);
* } * }
* *
@ -1009,10 +1009,10 @@ class Blockchain {
* ```javascript * ```javascript
* // add privateKey to wallet * // add privateKey to wallet
* const privateKey = '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e'; * const privateKey = '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e';
* wiki.wallet.addByPrivateKey(privateKey); * hmy.wallet.addByPrivateKey(privateKey);
* *
* async function transfer() { * async function transfer() {
* const txn = wiki.transactions.newTx({ * const txn = hmy.transactions.newTx({
* // token send to * // token send to
* to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2', * to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2',
* // amount to send * // amount to send
@ -1024,12 +1024,12 @@ class Blockchain {
* // send token to toShardID * // send token to toShardID
* toShardID: 0, * toShardID: 0,
* // gas Price, you can use Unit class, and use Gwei, then remember to use toWei(), which will be transformed to BN * // 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('100').asGwei().toWei(), * gasPrice: new hmy.utils.Unit('100').asGwei().toWei(),
* }); * });
* *
* // sign the transaction use wallet; * // sign the transaction use wallet;
* const signedTxn = await wiki.wallet.signTransaction(txn); * const signedTxn = await hmy.wallet.signTransaction(txn);
* const txnHash = await wiki.blockchain.createObservedTransaction(signedTxn); * const txnHash = await hmy.blockchain.createObservedTransaction(signedTxn);
* console.log(txnHash); * console.log(txnHash);
* } * }
* *
@ -1108,12 +1108,12 @@ class Blockchain {
* *
* @warning * @warning
* ``` * ```
* At present, this function wiki_estimateGas is not implement yet, will Coming soon!!! * At present, this function hmy_estimateGas is not implement yet, will Coming soon!!!
* ``` * ```
* *
* @example * @example
* ```javascript * ```javascript
* wiki.blockchain.estimateGas({ * hmy.blockchain.estimateGas({
* to: 'one1d0kw95t6kkljmkk9vu0zv25jraut8ngv5vrs5g', * to: 'one1d0kw95t6kkljmkk9vu0zv25jraut8ngv5vrs5g',
* data: '0xc6888fa10000000000000000000000000000000000000000000000000000000000000003' * data: '0xc6888fa10000000000000000000000000000000000000000000000000000000000000003'
* }).then((value) => { * }).then((value) => {
@ -1152,7 +1152,7 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* wiki.blockchain.gasPrice().then((value) => { * hmy.blockchain.gasPrice().then((value) => {
* console.log(value); * console.log(value);
* }); * });
* ``` * ```
@ -1177,7 +1177,7 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* wiki.blockchain.call({ * hmy.blockchain.call({
* to: "0x08AE1abFE01aEA60a47663bCe0794eCCD5763c19", * to: "0x08AE1abFE01aEA60a47663bCe0794eCCD5763c19",
* }).then((value) => { * }).then((value) => {
* console.log(value); * console.log(value);
@ -1209,18 +1209,18 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* const wiki = new Woop( * const hmy = new Harmony(
* // rpc url * // rpc url
* 'ws://api.s0.b.hmny.io/', * 'ws://api.s0.b.hmny.io/',
* { * {
* // chainType set to Woop * // chainType set to Harmony
* chainType: ChainType.Woop, * chainType: ChainType.Harmony,
* // chainType set to WikiLocal * // chainType set to HmyLocal
* chainId: ChainID.WikiLocal, * chainId: ChainID.HmyLocal,
* }, * },
* ); * );
* *
* const tmp = wiki.blockchain.newPendingTransactions(); * const tmp = hmy.blockchain.newPendingTransactions();
* console.log(tmp) * console.log(tmp)
* ``` * ```
*/ */
@ -1238,18 +1238,18 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* const wiki = new Woop( * const hmy = new Harmony(
* // rpc url * // rpc url
* 'ws://api.s0.b.hmny.io/', * 'ws://api.s0.b.hmny.io/',
* { * {
* // chainType set to Woop * // chainType set to Harmony
* chainType: ChainType.Woop, * chainType: ChainType.Harmony,
* // chainType set to WikiLocal * // chainType set to HmyLocal
* chainId: ChainID.WikiLocal, * chainId: ChainID.HmyLocal,
* }, * },
* ); * );
* *
* const tmp = wiki.blockchain.newBlockHeaders(); * const tmp = hmy.blockchain.newBlockHeaders();
* console.log(tmp) * console.log(tmp)
* ``` * ```
*/ */
@ -1267,18 +1267,18 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* const wiki = new Woop( * const hmy = new Harmony(
* // rpc url * // rpc url
* 'ws://api.s0.b.hmny.io/', * 'ws://api.s0.b.hmny.io/',
* { * {
* // chainType set to Woop * // chainType set to Harmony
* chainType: ChainType.Woop, * chainType: ChainType.Harmony,
* // chainType set to WikiLocal * // chainType set to HmyLocal
* chainId: ChainID.WikiLocal, * chainId: ChainID.HmyLocal,
* }, * },
* ); * );
* *
* const tmp = wiki.blockchain.syncing(); * const tmp = hmy.blockchain.syncing();
* console.log(tmp) * console.log(tmp)
* ``` * ```
*/ */
@ -1296,18 +1296,18 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* const wiki = new Woop( * const hmy = new Harmony(
* // rpc url * // rpc url
* 'ws://api.s0.b.hmny.io/', * 'ws://api.s0.b.hmny.io/',
* { * {
* // chainType set to Woop * // chainType set to Harmony
* chainType: ChainType.Woop, * chainType: ChainType.Harmony,
* // chainType set to WikiLocal * // chainType set to HmyLocal
* chainId: ChainID.WikiLocal, * chainId: ChainID.HmyLocal,
* }, * },
* ); * );
* *
* const tmp = wiki.blockchain.logs({ * const tmp = hmy.blockchain.logs({
* from: '0x12' * from: '0x12'
* }); * });
* console.log(tmp) * console.log(tmp)

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

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

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

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

@ -0,0 +1,31 @@
/**
* @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 enum UrlType {
http,
ws,
}
export interface HarmonySetting<T extends ChainType, I extends ChainID> {
type: T;
id: I;
}

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

@ -6,7 +6,7 @@
// tslint:disable-next-line: no-implicit-dependencies // tslint:disable-next-line: no-implicit-dependencies
import fetch from 'jest-fetch-mock'; import fetch from 'jest-fetch-mock';
import { Blockchain } from '../src/blockchain'; import { Blockchain } from '../src/blockchain';
import { HttpProvider, Messenger } from '@woop-js/network'; import { HttpProvider, Messenger } from '@harmony-js/network';
const provider = new HttpProvider('https://mock.com'); const provider = new HttpProvider('https://mock.com');
const messenger = new Messenger(provider); const messenger = new Messenger(provider);

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

@ -1,15 +1,15 @@
{ {
"name": "@woop-js/crypto", "name": "@harmony-js/crypto",
"version": "0.1.58", "version": "0.1.58",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@woop-js/crypto", "name": "@harmony-js/crypto",
"version": "0.1.56", "version": "0.1.56",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@woop-js/utils": "0.1.56", "@harmony-js/utils": "0.1.56",
"aes-js": "^3.1.2", "aes-js": "^3.1.2",
"bip39": "^2.5.0", "bip39": "^2.5.0",
"bn.js": "^4.11.8", "bn.js": "^4.11.8",
@ -22,9 +22,9 @@
"uuid": "^3.3.2" "uuid": "^3.3.2"
} }
}, },
"node_modules/@woop-js/utils": { "node_modules/@harmony-js/utils": {
"version": "0.1.56", "version": "0.1.56",
"resolved": "https://registry.npmjs.org/@woop-js/utils/-/utils-0.1.56.tgz", "resolved": "https://registry.npmjs.org/@harmony-js/utils/-/utils-0.1.56.tgz",
"integrity": "sha512-XoYYIMoK/mSxPkxFd25dY/wScIWWevoTrHoFdlFd8N7GWlilfdgQEF5vO+4BA6hyDJ4ryfdLnGc6W6Hz+5qs2A==", "integrity": "sha512-XoYYIMoK/mSxPkxFd25dY/wScIWWevoTrHoFdlFd8N7GWlilfdgQEF5vO+4BA6hyDJ4ryfdLnGc6W6Hz+5qs2A==",
"dependencies": { "dependencies": {
"@types/bn.js": "^4.11.3", "@types/bn.js": "^4.11.3",
@ -415,9 +415,9 @@
} }
}, },
"dependencies": { "dependencies": {
"@woop-js/utils": { "@harmony-js/utils": {
"version": "0.1.56", "version": "0.1.56",
"resolved": "https://registry.npmjs.org/@woop-js/utils/-/utils-0.1.56.tgz", "resolved": "https://registry.npmjs.org/@harmony-js/utils/-/utils-0.1.56.tgz",
"integrity": "sha512-XoYYIMoK/mSxPkxFd25dY/wScIWWevoTrHoFdlFd8N7GWlilfdgQEF5vO+4BA6hyDJ4ryfdLnGc6W6Hz+5qs2A==", "integrity": "sha512-XoYYIMoK/mSxPkxFd25dY/wScIWWevoTrHoFdlFd8N7GWlilfdgQEF5vO+4BA6hyDJ4ryfdLnGc6W6Hz+5qs2A==",
"requires": { "requires": {
"@types/bn.js": "^4.11.3", "@types/bn.js": "^4.11.3",

@ -1,7 +1,7 @@
{ {
"name": "@woop-js/crypto", "name": "@harmony-js/crypto",
"version": "0.1.58", "version": "0.1.58",
"description": "crypto libraries for woop", "description": "crypto libraries for harmony",
"main": "dist/index.js", "main": "dist/index.js",
"node": "dist/index.js", "node": "dist/index.js",
"browser": "dist/index.js", "browser": "dist/index.js",
@ -18,7 +18,7 @@
}, },
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@woop-js/utils": "0.1.58", "@harmony-js/utils": "0.1.58",
"aes-js": "^3.1.2", "aes-js": "^3.1.2",
"bip39": "^2.5.0", "bip39": "^2.5.0",
"bn.js": "^4.11.8", "bn.js": "^4.11.8",

@ -1,9 +1,9 @@
/** /**
* @packageDocumentation * @packageDocumentation
* @module woop-crypto * @module harmony-crypto
*/ */
import { isAddress, isBech32Address, isBech32TestNetAddress } from '@woop-js/utils'; import { isAddress, isBech32Address, isBech32TestNetAddress } from '@harmony-js/utils';
import { toChecksumAddress } from './keyTool'; import { toChecksumAddress } from './keyTool';
import { fromBech32, toBech32, HRP, tHRP } from './bech32'; import { fromBech32, toBech32, HRP, tHRP } from './bech32';
@ -13,25 +13,25 @@ import { fromBech32, toBech32, HRP, tHRP } from './bech32';
* *
* ``` * ```
* // Step 1: import the class * // Step 1: import the class
* const { WoopAddress } = require('@woop-js/crypto'); * const { HarmonyAddress } = require('@harmony-js/crypto');
* *
* // Step 2: call functions * // Step 2: call functions
* const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7' * const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7'
* const res = WoopAddress.isValidBech32(addr); * const res = HarmonyAddress.isValidBech32(addr);
* console.log(res); * console.log(res);
* ``` * ```
*/ */
export class WoopAddress { export class HarmonyAddress {
/** /**
* @example * @example
* ``` * ```
* const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7' * const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7'
* const res = WoopAddress.isValidBech32(addr); * const res = HarmonyAddress.isValidBech32(addr);
* console.log(res); * console.log(res);
* ``` * ```
*/ */
static isValidBasic(str: string) { static isValidBasic(str: string) {
const toTest = new WoopAddress(str); const toTest = new HarmonyAddress(str);
return toTest.raw === toTest.basic; return toTest.raw === toTest.basic;
} }
@ -39,12 +39,12 @@ export class WoopAddress {
* @example * @example
* ``` * ```
* const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7' * const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7'
* const res = WoopAddress.isValidChecksum(addr); * const res = HarmonyAddress.isValidChecksum(addr);
* console.log(res); * console.log(res);
* ``` * ```
*/ */
static isValidChecksum(str: string) { static isValidChecksum(str: string) {
const toTest = new WoopAddress(str); const toTest = new HarmonyAddress(str);
return toTest.raw === toTest.checksum; return toTest.raw === toTest.checksum;
} }
@ -52,12 +52,12 @@ export class WoopAddress {
* @example * @example
* ``` * ```
* const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7' * const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7'
* const res = WoopAddress.isValidBech32(addr); * const res = HarmonyAddress.isValidBech32(addr);
* console.log(res); * console.log(res);
* ``` * ```
*/ */
static isValidBech32(str: string) { static isValidBech32(str: string) {
const toTest = new WoopAddress(str); const toTest = new HarmonyAddress(str);
return toTest.raw === toTest.bech32; return toTest.raw === toTest.bech32;
} }
@ -65,12 +65,12 @@ export class WoopAddress {
* @example * @example
* ``` * ```
* const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7' * const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7'
* const res = WoopAddress.isValidBech32TestNet(addr); * const res = HarmonyAddress.isValidBech32TestNet(addr);
* console.log(res); * console.log(res);
* ``` * ```
*/ */
static isValidBech32TestNet(str: string) { static isValidBech32TestNet(str: string) {
const toTest = new WoopAddress(str); const toTest = new HarmonyAddress(str);
return toTest.raw === toTest.bech32TestNet; return toTest.raw === toTest.bech32TestNet;
} }
@ -83,7 +83,7 @@ export class WoopAddress {
* @example * @example
* ``` * ```
* const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7' * const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7'
* const instance = new WoopAddress(addr); * const instance = new HarmonyAddress(addr);
* console.log(instance.basicHex); * console.log(instance.basicHex);
* ``` * ```
*/ */
@ -95,7 +95,7 @@ export class WoopAddress {
* @example * @example
* ``` * ```
* const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7' * const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7'
* const instance = new WoopAddress(addr); * const instance = new HarmonyAddress(addr);
* console.log(instance.checksum); * console.log(instance.checksum);
* ``` * ```
*/ */
@ -107,7 +107,7 @@ export class WoopAddress {
* @example * @example
* ``` * ```
* const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7' * const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7'
* const instance = new WoopAddress(addr); * const instance = new HarmonyAddress(addr);
* console.log(instance.bech32); * console.log(instance.bech32);
* ``` * ```
*/ */
@ -119,7 +119,7 @@ export class WoopAddress {
* @example * @example
* ``` * ```
* const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7' * const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7'
* const instance = new WoopAddress(addr); * const instance = new HarmonyAddress(addr);
* console.log(instance.bech32TestNet); * console.log(instance.bech32TestNet);
* ``` * ```
*/ */
@ -140,7 +140,7 @@ export class WoopAddress {
* @example * @example
* ``` * ```
* const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7' * const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7'
* const instance = new WoopAddress(addr); * const instance = new HarmonyAddress(addr);
* const res = instance.getBasic(addr); * const res = instance.getBasic(addr);
* console.log(res) * console.log(res)
* ``` * ```
@ -169,32 +169,32 @@ export class WoopAddress {
} }
/** /**
* Using this function to get Woop format address * Using this function to get Harmony format address
* *
* @param address * @param address
* *
* @example * @example
* ```javascript * ```javascript
* const { Woop } = require('@woop-js/core'); * const { Harmony } = require('@harmony-js/core');
* const { ChainID, ChainType } = require('@woop-js/utils'); * const { ChainID, ChainType } = require('@harmony-js/utils');
* const { randomBytes } = require('@woop-js/crypto') * const { randomBytes } = require('@harmony-js/crypto')
* *
* const wiki = new Woop( * const hmy = new Harmony(
* 'http://localhost:9500', * 'http://localhost:9500',
* { * {
* chainType: ChainType.Woop, * chainType: ChainType.Harmony,
* chainId: ChainID.WikiLocal, * chainId: ChainID.HmyLocal,
* }, * },
* ); * );
* *
* const bytes = randomBytes(20); * const bytes = randomBytes(20);
* const hAddress = wiki.crypto.getAddress(bytes); * const hAddress = hmy.crypto.getAddress(bytes);
* console.log(hAddress) * console.log(hAddress)
* ``` * ```
*/ */
export function getAddress(address: string) { export function getAddress(address: string) {
try { try {
return new WoopAddress(address); return new HarmonyAddress(address);
} catch (error) { } catch (error) {
throw error; throw error;
} }

@ -1,10 +1,10 @@
/** /**
* @packageDocumentation * @packageDocumentation
* @module woop-crypto * @module harmony-crypto
* @hidden * @hidden
*/ */
import { isAddress } from '@woop-js/utils'; import { isAddress } from '@harmony-js/utils';
import { toChecksumAddress } from './keyTool'; import { toChecksumAddress } from './keyTool';
// This code is taken from https://github.com/sipa/bech32/tree/bdc264f84014c234e908d72026b7b780122be11f/ref/javascript // This code is taken from https://github.com/sipa/bech32/tree/bdc264f84014c234e908d72026b7b780122be11f/ref/javascript
@ -127,7 +127,7 @@ export const bech32Decode = (bechString: string) => {
return { hrp, data: Buffer.from(data.slice(0, data.length - 6)) }; return { hrp, data: Buffer.from(data.slice(0, data.length - 6)) };
}; };
// HRP is the human-readable part of Woop bech32 addresses // HRP is the human-readable part of Harmony bech32 addresses
export const HRP = 'one'; export const HRP = 'one';
export const tHRP = 'tone'; export const tHRP = 'tone';
@ -184,14 +184,14 @@ export const convertBits = (
/** /**
* toBech32Address * toBech32Address
* *
* bech32Encodes a canonical 20-byte Ethereum-style address as a bech32 Woop * bech32Encodes a canonical 20-byte Ethereum-style address as a bech32 Harmony
* address. * address.
* *
* The expected format is one1<address><checksum> where address and checksum * The expected format is one1<address><checksum> where address and checksum
* are the result of bech32 encoding a Buffer containing the address bytes. * are the result of bech32 encoding a Buffer containing the address bytes.
* *
* @param {string} 20 byte canonical address * @param {string} 20 byte canonical address
* @returns {string} 38 char bech32 bech32Encoded Woop address * @returns {string} 38 char bech32 bech32Encoded Harmony address
*/ */
export const toBech32 = (address: string, useHRP: string = HRP): string => { export const toBech32 = (address: string, useHRP: string = HRP): string => {
if (!isAddress(address)) { if (!isAddress(address)) {
@ -210,7 +210,7 @@ export const toBech32 = (address: string, useHRP: string = HRP): string => {
/** /**
* fromBech32Address * fromBech32Address
* *
* @param {string} address - a valid Woop bech32 address * @param {string} address - a valid Harmony bech32 address
* @returns {string} a canonical 20-byte Ethereum-style address * @returns {string} a canonical 20-byte Ethereum-style address
*/ */
export const fromBech32 = (address: string, useHRP: string = HRP): string => { export const fromBech32 = (address: string, useHRP: string = HRP): string => {

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

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

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

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

@ -1,6 +1,6 @@
/** /**
* @packageDocumentation * @packageDocumentation
* @module woop-crypto * @module harmony-crypto
*/ */
import elliptic from 'elliptic'; import elliptic from 'elliptic';
@ -9,7 +9,7 @@ import * as errors from './errors';
import { keccak256 } from './keccak256'; import { keccak256 } from './keccak256';
import { randomBytes } from './random'; import { randomBytes } from './random';
import { isPrivateKey, strip0x, isAddress, isBech32Address } from '@woop-js/utils'; import { isPrivateKey, strip0x, isAddress, isBech32Address } from '@harmony-js/utils';
import { fromBech32 } from './bech32'; import { fromBech32 } from './bech32';
import { encode } from './rlp'; import { encode } from './rlp';

@ -1,13 +1,13 @@
/** /**
* @packageDocumentation * @packageDocumentation
* @module woop-crypto * @module harmony-crypto
*/ */
import aes from 'aes-js'; import aes from 'aes-js';
import scrypt from 'scrypt.js'; import scrypt from 'scrypt.js';
import { pbkdf2Sync } from 'pbkdf2'; import { pbkdf2Sync } from 'pbkdf2';
import uuid from 'uuid'; import uuid from 'uuid';
import { isPrivateKey } from '@woop-js/utils'; import { isPrivateKey } from '@harmony-js/utils';
import { randomBytes } from './random'; import { randomBytes } from './random';
import { getAddressFromPrivateKey } from './keyTool'; import { getAddressFromPrivateKey } from './keyTool';
import { concat, hexToIntArray } from './bytes'; import { concat, hexToIntArray } from './bytes';

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

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

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

@ -3,7 +3,7 @@
* @ignore * @ignore
*/ */
import { getAddress, WoopAddress } from '../src/address'; import { getAddress, HarmonyAddress } from '../src/address';
import { randomBytes } from '../src/random'; import { randomBytes } from '../src/random';
import { toBech32, fromBech32, HRP, tHRP } from '../src/bech32'; import { toBech32, fromBech32, HRP, tHRP } from '../src/bech32';
import { toChecksumAddress, isValidChecksumAddress } from '../src/keyTool'; import { toChecksumAddress, isValidChecksumAddress } from '../src/keyTool';
@ -15,7 +15,7 @@ const bech32Testnet = toBech32(checksum, tHRP);
describe('test address', () => { describe('test address', () => {
it('should test HamonyAddress', () => { it('should test HamonyAddress', () => {
const hAddress = new WoopAddress(bytes); const hAddress = new HarmonyAddress(bytes);
expect(hAddress.basic).toEqual(bytes); expect(hAddress.basic).toEqual(bytes);
expect(hAddress.basicHex).toEqual(bytesWith0x); expect(hAddress.basicHex).toEqual(bytesWith0x);
expect(hAddress.checksum).toEqual(checksum); expect(hAddress.checksum).toEqual(checksum);
@ -30,10 +30,10 @@ describe('test address', () => {
expect(fromBech32(bech32, HRP)).toEqual(checksum); expect(fromBech32(bech32, HRP)).toEqual(checksum);
expect(fromBech32(bech32)).toEqual(checksum); expect(fromBech32(bech32)).toEqual(checksum);
expect(fromBech32(bech32Testnet, tHRP)).toEqual(checksum); expect(fromBech32(bech32Testnet, tHRP)).toEqual(checksum);
expect(WoopAddress.isValidBasic(bytes)).toEqual(true); expect(HarmonyAddress.isValidBasic(bytes)).toEqual(true);
expect(WoopAddress.isValidChecksum(checksum)).toEqual(true); expect(HarmonyAddress.isValidChecksum(checksum)).toEqual(true);
expect(WoopAddress.isValidBech32(bech32)).toEqual(true); expect(HarmonyAddress.isValidBech32(bech32)).toEqual(true);
expect(WoopAddress.isValidBech32TestNet(bech32Testnet)).toEqual(true); expect(HarmonyAddress.isValidBech32TestNet(bech32Testnet)).toEqual(true);
expect(isValidChecksumAddress(checksum)).toEqual(true); expect(isValidChecksumAddress(checksum)).toEqual(true);
try { try {
// tslint:disable-next-line: no-unused-expression // tslint:disable-next-line: no-unused-expression

@ -4,7 +4,7 @@
*/ */
import * as keys from '../src/keyTool'; import * as keys from '../src/keyTool';
import { isPrivateKey, isAddress, isPublicKey } from '@woop-js/utils'; import { isPrivateKey, isAddress, isPublicKey } from '@harmony-js/utils';
describe('test keyTools', () => { describe('test keyTools', () => {
it('test keygen', () => { it('test keygen', () => {

@ -5,5 +5,5 @@
"outDir": "dist" "outDir": "dist"
}, },
"include": ["src", "../../typings/**/*.d.ts"], "include": ["src", "../../typings/**/*.d.ts"],
"references": [{"path": "../woop-utils"}] "references": [{"path": "../harmony-utils"}]
} }

@ -1,24 +1,24 @@
# @woop-js/network # @harmony-js/network
This package provides a collection of apis to create messengers (HTTP, WebSocket) to connect to blockchain networks. This package provides a collection of apis to create messengers (HTTP, WebSocket) to connect to blockchain networks.
## Installation ## Installation
``` ```
npm install @woop-js/network npm install @harmony-js/network
``` ```
## Usage ## Usage
```javascript ```javascript
const { Messenger, HttpProvider, WSProvider } = require('@woop-js/network'); const { Messenger, HttpProvider, WSProvider } = require('@harmony-js/network');
const { ChainID, ChainType } = require('@woop-js/utils'); const { ChainID, ChainType } = require('@harmony-js/utils');
const testnetHTTP = 'https://api.s0.b.hmny.io'; const testnetHTTP = 'https://api.s0.b.hmny.io';
const testnetWS = 'wss://ws.s0.b.hmny.io'; const testnetWS = 'wss://ws.s0.b.hmny.io';
const localHTTP = 'http://localhost:9500/'; const localHTTP = 'http://localhost:9500/';
const localWS = 'http://localhost:9800/'; const localWS = 'http://localhost:9800/';
const http = new HttpProvider(testnetHTTP); // for local use localHTTP const http = new HttpProvider(testnetHTTP); // for local use localHTTP
const ws = new WSProvider(testnetWS); // for local use testnetWS const ws = new WSProvider(testnetWS); // for local use testnetWS
const customHTTPMessenger = new Messenger(http, ChainType.Woop, ChainID.WikiTestnet); // for local ChainID.WikiLocal const customHTTPMessenger = new Messenger(http, ChainType.Harmony, ChainID.HmyTestnet); // for local ChainID.HmyLocal
const customWSMessenger = new Messenger(ws, ChainType.Woop, ChainID.WikiTestnet); // for local ChainID.WikiLocal const customWSMessenger = new Messenger(ws, ChainType.Harmony, ChainID.HmyTestnet); // for local ChainID.HmyLocal
``` ```

@ -1,7 +1,7 @@
{ {
"name": "@woop-js/network", "name": "@harmony-js/network",
"version": "0.1.58", "version": "0.1.58",
"description": "network suites for woop", "description": "network suites for harmony",
"main": "dist/index.js", "main": "dist/index.js",
"node": "dist/index.js", "node": "dist/index.js",
"browser": "dist/index.js", "browser": "dist/index.js",
@ -18,7 +18,7 @@
"author": "neeboo@firestack.one", "author": "neeboo@firestack.one",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@woop-js/utils": "0.1.58", "@harmony-js/utils": "0.1.58",
"cross-fetch": "^3.0.2", "cross-fetch": "^3.0.2",
"mitt": "^1.2.0", "mitt": "^1.2.0",
"websocket": "^1.0.28" "websocket": "^1.0.28"

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

@ -1,9 +1,9 @@
/** /**
* @packageDocumentation * @packageDocumentation
* @module woop-network * @module harmony-network
*/ */
import { WoopCore, ChainType, isString, ChainID, defaultConfig } from '@woop-js/utils'; import { HarmonyCore, ChainType, isString, ChainID, defaultConfig } from '@harmony-js/utils';
import { JsonRpc } from '../rpcMethod/builder'; import { JsonRpc } from '../rpcMethod/builder';
import { ResponseMiddleware } from './responseMiddleware'; import { ResponseMiddleware } from './responseMiddleware';
import { HttpProvider } from '../providers/http'; import { HttpProvider } from '../providers/http';
@ -24,18 +24,18 @@ export interface ShardingProvider {
* ## How to Create a Massage * ## How to Create a Massage
* @example * @example
* ``` * ```
* const { HttpProvider, Messenger } = require('@woop-js/network'); * const { HttpProvider, Messenger } = require('@harmony-js/network');
* const { ChainType, ChainID } = require('@woop-js/utils'); * const { ChainType, ChainID } = require('@harmony-js/utils');
* *
* // create a custom messenger * // create a custom messenger
* const customMessenger = new Messenger( * const customMessenger = new Messenger(
* new HttpProvider('http://localhost:9500'), * new HttpProvider('http://localhost:9500'),
* ChainType.Woop, // if you are connected to Woop's blockchain * ChainType.Harmony, // if you are connected to Harmony's blockchain
* ChainID.WikiLocal, // check if the chainId is correct * ChainID.HmyLocal, // check if the chainId is correct
* ) * )
* ``` * ```
*/ */
class Messenger extends WoopCore { class Messenger extends HarmonyCore {
provider: HttpProvider | WSProvider; provider: HttpProvider | WSProvider;
config?: object; config?: object;
// tslint:disable-next-line: variable-name // tslint:disable-next-line: variable-name
@ -291,7 +291,7 @@ class Messenger extends WoopCore {
}; };
async setShardingProviders() { async setShardingProviders() {
if (this.chainPrefix !== ChainType.Woop) { if (this.chainPrefix !== ChainType.Harmony) {
return; return;
} }
try { try {
@ -318,7 +318,7 @@ class Messenger extends WoopCore {
/** /**
* @example * @example
* ``` * ```
* wiki.messenger.getShardProvider() * hmy.messenger.getShardProvider()
* ``` * ```
*/ */
getShardProvider(shardID: number): HttpProvider | WSProvider { getShardProvider(shardID: number): HttpProvider | WSProvider {
@ -334,7 +334,7 @@ class Messenger extends WoopCore {
/** /**
* @example * @example
* ``` * ```
* wiki.messenger.getCurrentShardID() * hmy.messenger.getCurrentShardID()
* ``` * ```
*/ */

@ -1,11 +1,11 @@
/** /**
* @packageDocumentation * @packageDocumentation
* @module woop-network * @module harmony-network
* @hidden * @hidden
*/ */
import { RPCResponseBody } from '../types'; import { RPCResponseBody } from '../types';
import { isObject } from '@woop-js/utils'; import { isObject } from '@harmony-js/utils';
/** /**
* @class ResponseMiddleware * @class ResponseMiddleware
* @description Response middleware of RPC * @description Response middleware of RPC

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

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

Loading…
Cancel
Save