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

@ -1,39 +1,22 @@
# Harmony JavaScript SDK # Woop JavaScript SDK
[![npm version](https://img.shields.io/npm/v/@harmony-js/core.svg?style=flat-square)](https://www.npmjs.com/package/@harmony-js/core) [![npm version](https://img.shields.io/npm/v/@woop-js/core.svg?style=flat-square)](https://www.npmjs.com/package/@woop-js/core)
[![Build Status](https://travis-ci.com/FireStack-Lab/Harmony-sdk-core.svg?branch=master)](https://travis-ci.com/FireStack-Lab/Harmony-sdk-core) [![Build Status](https://travis-ci.com/FireStack-Lab/Woop-sdk-core.svg?branch=master)](https://travis-ci.com/FireStack-Lab/Woop-sdk-core)
This is the Harmony Javascript SDK which provides an easier way to interact with Harmony blockchain. This is the Woop Javascript SDK which provides an easier way to interact with Woop 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. [@harmony-js/core](https://github.com/harmony-one/sdk/tree/master/packages/harmony-core) 1. [@woop-js/core](https://github.com/woop-chain/sdk/tree/master/packages/woop-core)
2. [@harmony-js/account](https://github.com/harmony-one/sdk/tree/master/packages/harmony-account) 2. [@woop-js/account](https://github.com/woop-chain/sdk/tree/master/packages/woop-account)
3. [@harmony-js/crypto](https://github.com/harmony-one/sdk/tree/master/packages/harmony-crypto) 3. [@woop-js/crypto](https://github.com/woop-chain/sdk/tree/master/packages/woop-crypto)
4. [@harmony-js/network](https://github.com/harmony-one/sdk/tree/master/packages/harmony-network) 4. [@woop-js/network](https://github.com/woop-chain/sdk/tree/master/packages/woop-network)
5. [@harmony-js/utils](https://github.com/harmony-one/sdk/tree/master/packages/harmony-utils) 5. [@woop-js/utils](https://github.com/woop-chain/sdk/tree/master/packages/woop-utils)
6. [@harmony-js/transaction](https://github.com/harmony-one/sdk/tree/master/packages/harmony-transaction) 6. [@woop-js/transaction](https://github.com/woop-chain/sdk/tree/master/packages/woop-transaction)
7. [@harmony-js/contract](https://github.com/harmony-one/sdk/tree/master/packages/harmony-contract) 7. [@woop-js/contract](https://github.com/woop-chain/sdk/tree/master/packages/woop-contract)
8. [@harmony-js/staking](https://github.com/harmony-one/sdk/tree/master/packages/harmony-staking) 8. [@woop-js/staking](https://github.com/woop-chain/sdk/tree/master/packages/woop-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
@ -52,10 +35,10 @@ This library works on both nodejs and browser. Please use it according to your u
```bash ```bash
# npm # npm
npm install @harmony-js/core@next npm install @woop-js/core@next
# yarn # yarn
yarn add @harmony-js/core@next yarn add @woop-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
@ -94,7 +77,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 harmony node locally, follow the instructions: https://github.com/harmony-one/harmony 1. Run woop node locally, follow the instructions: https://github.com/woop-chain/woop
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 @harmony-js/core@next npm install @woop-js/core@next
``` ```
@ -60,7 +60,7 @@ This will change the release version of current npm packages to the latest versi
For example. For example.
```bash ```bash
npm install @harmony-js/core npm install @woop-js/core
``` ```

@ -1,6 +1,6 @@
# Harmony JS-SDK Documentation # Woop JS-SDK Documentation
## [CLICK ME!!](https://harmony-js-sdk-doc.s3-us-west-1.amazonaws.com/index.html) to see the documentation ## [CLICK ME!!](https://woop-js-sdk-doc.s3-us-west-1.amazonaws.com/index.html) to see the documentation
# metaDocumentation # 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 Harmony_SDK_Doc --readme ../README.md $ npx typedoc --out ./build ../packages/ --ignoreCompilerErrors --theme default --name Woop_SDK_Doc --readme ../README.md
``` ```
### See the generated doc at local ### 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 (harmony core only!) ## Step 2: Deploy on AWS (woop 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://harmony-js-sdk-doc aws s3 mb s3://woop-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://harmony-js-sdk-doc** > **s3://woop-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 { harmony, checkCalledMethod } from './harmony'; import { woop, checkCalledMethod } from './woop';
import demoAccounts from '../fixtures/testAccount.json'; import demoAccounts from '../fixtures/testAccount.json';
import { RPCMethod } from '@harmony-js/network'; import { RPCMethod } from '@woop-js/network';
const bc = harmony.blockchain; const bc = woop.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(harmony.utils.isHex(peerCount.result)).toEqual(true); expect(woop.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 hmy_protocolVersion', async () => { it('should test wiki_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(harmony.utils.isHex(protocolVersion.result)).toEqual(true); expect(woop.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 hmy_blockNumber', async () => { it('should test wiki_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(harmony.utils.isHex(res.result)).toEqual(true); expect(woop.utils.isHex(res.result)).toEqual(true);
expect(checkCalledMethod(0, RPCMethod.BlockNumber)).toEqual(true); expect(checkCalledMethod(0, RPCMethod.BlockNumber)).toEqual(true);
}); });
it('should test hmy_getBlockByNumber', async () => { it('should test wiki_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(harmony.utils.isHex(size)).toEqual(true); expect(woop.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(harmony.utils.isHex(res2.result.size)).toEqual(true); expect(woop.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 hmy_getBlockByHash', async () => { it('should test wiki_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(harmony.utils.isHex(res.result.size)).toEqual(true); expect(woop.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 hmy_getBalance', async () => { it('should test wiki_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(harmony.utils.isHex(balance.result)).toEqual(true); expect(woop.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 harmony.utils.validateArgs( return woop.utils.validateArgs(
data, data,
{ {
difficulty: [harmony.utils.isNumber], difficulty: [woop.utils.isNumber],
// tslint:disable-next-line: no-shadowed-variable // tslint:disable-next-line: no-shadowed-variable
extraData: [(data: any) => data === '0x' || harmony.utils.isHex(data)], extraData: [(data: any) => data === '0x' || woop.utils.isHex(data)],
gasLimit: [harmony.utils.isHex], gasLimit: [woop.utils.isHex],
gasUsed: [harmony.utils.isHex], gasUsed: [woop.utils.isHex],
hash: [harmony.utils.isHash], hash: [woop.utils.isHash],
logsBloom: [harmony.utils.isHex], logsBloom: [woop.utils.isHex],
miner: [harmony.utils.isBech32Address], miner: [woop.utils.isBech32Address],
mixHash: [harmony.utils.isHash], mixHash: [woop.utils.isHash],
nonce: [harmony.utils.isNumber], nonce: [woop.utils.isNumber],
number: [harmony.utils.isHex], number: [woop.utils.isHex],
parentHash: [harmony.utils.isHash], parentHash: [woop.utils.isHash],
receiptsRoot: [harmony.utils.isHash], receiptsRoot: [woop.utils.isHash],
size: [harmony.utils.isHex], size: [woop.utils.isHex],
stateRoot: [harmony.utils.isHash], stateRoot: [woop.utils.isHash],
timestamp: [harmony.utils.isHex], timestamp: [woop.utils.isHex],
transactionsRoot: [harmony.utils.isHash], transactionsRoot: [woop.utils.isHash],
uncles: [harmony.utils.isArray], uncles: [woop.utils.isArray],
}, },
{ transactions: [harmony.utils.isArray] }, { transactions: [woop.utils.isArray] },
); );
} }

@ -1,12 +1,12 @@
import fetch from 'jest-fetch-mock'; import fetch from 'jest-fetch-mock';
import { harmony, checkCalledMethod } from './harmony'; import { woop, checkCalledMethod } from './woop';
// tslint:disable-next-line: no-implicit-dependencies // tslint:disable-next-line: no-implicit-dependencies
import { Transaction, TxStatus } from '@harmony-js/transaction'; import { Transaction, TxStatus } from '@woop-js/transaction';
// tslint:disable-next-line: no-implicit-dependencies // tslint:disable-next-line: no-implicit-dependencies
import { isHash, numberToHex } from '@harmony-js/utils'; import { isHash, numberToHex } from '@woop-js/utils';
import txnJsons from '../fixtures/transactions.json'; import txnJsons from '../fixtures/transactions.json';
import demoAccounts from '../fixtures/testAccount.json'; import demoAccounts from '../fixtures/testAccount.json';
import { RPCMethod } from '@harmony-js/network'; import { RPCMethod } from '@woop-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 = harmony.transactions.newTx(); const newTxn = woop.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: harmony.crypto.getAddress(receiver.Address).bech32, to: woop.crypto.getAddress(receiver.Address).bech32,
value: '0x64', value: '0x64',
gasLimit: '210000', gasLimit: '210000',
gasPrice: new harmony.utils.Unit('100').asGwei().toWei(), gasPrice: new woop.utils.Unit('100').asGwei().toWei(),
}; };
const txn = harmony.transactions.newTx(txnObject); const txn = woop.transactions.newTx(txnObject);
signed = await harmony.wallet.signTransaction(txn, undefined, undefined, false); signed = await woop.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(harmony.utils.isHash(id)).toEqual(true); expect(woop.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": harmony.utils.numberToHex(2), "blockNumber": woop.utils.numberToHex(2),
"from": harmony.wallet.accounts[0], "from": woop.wallet.accounts[0],
"gasUsed": harmony.utils.numberToHex(5), "gasUsed": woop.utils.numberToHex(5),
"cumulativeGasUsed": harmony.utils.numberToHex(5), "cumulativeGasUsed": woop.utils.numberToHex(5),
"logs": [], "logs": [],
"logsBloom": harmony.utils.numberToHex(5), "logsBloom": woop.utils.numberToHex(5),
"shardID": 0, "shardID": 0,
"to": demoAccounts.Accounts[3].Address, "to": demoAccounts.Accounts[3].Address,
"transactionHash": "0x8c26EFdb6e4cAC6F8BeACE59F52fd95beD4Bfbfa8fF30F4a7cEd511fE5f869d9", "transactionHash": "0x8c26EFdb6e4cAC6F8BeACE59F52fd95beD4Bfbfa8fF30F4a7cEd511fE5f869d9",
"transactionIndex": harmony.utils.numberToHex(10), "transactionIndex": woop.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: harmony.crypto.getAddress(receiver.Address).bech32, to: woop.crypto.getAddress(receiver.Address).bech32,
value: new harmony.utils.Unit('100').asGwei().toWei(), value: new woop.utils.Unit('100').asGwei().toWei(),
gasLimit: new harmony.utils.Unit('210000').asWei().toWei(), gasLimit: new woop.utils.Unit('210000').asWei().toWei(),
gasPrice: new harmony.utils.Unit('100').asGwei().toWei(), gasPrice: new woop.utils.Unit('100').asGwei().toWei(),
}; };
const txn = harmony.transactions.newTx(txnObject); const txn = woop.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 harmony.wallet.signTransaction(txn, undefined, undefined, false); const txnSigned = await woop.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": harmony.utils.numberToHex(2), "blockNumber": woop.utils.numberToHex(2),
"from": harmony.wallet.accounts[0], "from": woop.wallet.accounts[0],
"gasUsed": harmony.utils.numberToHex(5), "gasUsed": woop.utils.numberToHex(5),
"cumulativeGasUsed": harmony.utils.numberToHex(5), "cumulativeGasUsed": woop.utils.numberToHex(5),
"logs": [], "logs": [],
"logsBloom": harmony.utils.numberToHex(5), "logsBloom": woop.utils.numberToHex(5),
"shardID": 0, "shardID": 0,
"to": demoAccounts.Accounts[3].Address, "to": demoAccounts.Accounts[3].Address,
"transactionHash": "0x8c26EFdb6e4cAC6F8BeACE59F52fd95beD4Bfbfa8fF30F4a7cEd511fE5f869d9", "transactionHash": "0x8c26EFdb6e4cAC6F8BeACE59F52fd95beD4Bfbfa8fF30F4a7cEd511fE5f869d9",
"transactionIndex": harmony.utils.numberToHex(10), "transactionIndex": woop.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 harmony.utils.validateArgs( return woop.utils.validateArgs(
data, data,
{ {
blockHash: [harmony.utils.isHash], blockHash: [woop.utils.isHash],
blockNumber: [harmony.utils.isHex], blockNumber: [woop.utils.isHex],
contractAddress: [ contractAddress: [
// tslint:disable-next-line: no-shadowed-variable // tslint:disable-next-line: no-shadowed-variable
(data: any) => data === null || harmony.utils.isValidAddress, (data: any) => data === null || woop.utils.isValidAddress,
], ],
cumulativeGasUsed: [harmony.utils.isHex], cumulativeGasUsed: [woop.utils.isHex],
from: [harmony.utils.isValidAddress], from: [woop.utils.isValidAddress],
gasUsed: [harmony.utils.isHex], gasUsed: [woop.utils.isHex],
logs: [harmony.utils.isArray], logs: [woop.utils.isArray],
logsBloom: [harmony.utils.isHex], logsBloom: [woop.utils.isHex],
shardID: [harmony.utils.isNumber], shardID: [woop.utils.isNumber],
// tslint:disable-next-line: no-shadowed-variable // tslint:disable-next-line: no-shadowed-variable
to: [(data: any) => data === '0x' || harmony.utils.isValidAddress], to: [(data: any) => data === '0x' || woop.utils.isValidAddress],
transactionHash: [harmony.utils.isHash], transactionHash: [woop.utils.isHash],
transactionIndex: [harmony.utils.isHex], transactionIndex: [woop.utils.isHex],
}, },
{ root: [harmony.utils.isHash] }, { root: [woop.utils.isHash] },
); );
} }

@ -1,9 +1,9 @@
import fetch from 'jest-fetch-mock'; import fetch from 'jest-fetch-mock';
import { harmony, checkCalledMethod } from './harmony'; import { woop, checkCalledMethod } from './woop';
import txnJsons from '../fixtures/transactions.json'; import txnJsons from '../fixtures/transactions.json';
import { RPCMethod } from '@harmony-js/network'; import { RPCMethod } from '@woop-js/network';
const messenger = harmony.messenger; const messenger = woop.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 hmy_sendRawTransaction', async () => { it('should test wiki_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('hmy_sendRawTransaction', transactions[index].rawTransaction); const sent = await messenger.send('wiki_sendRawTransaction', transactions[index].rawTransaction);
expect(harmony.utils.isHash(sent.result)).toEqual(true); expect(woop.utils.isHash(sent.result)).toEqual(true);
txnHashesFixtures.push(sent.result); txnHashesFixtures.push(sent.result);
expect(checkCalledMethod(index, 'hmy_sendRawTransaction')).toEqual(true); expect(checkCalledMethod(index, 'wiki_sendRawTransaction')).toEqual(true);
} }
}); });
it('should test hmy_getTransactionByHash', async () => { it('should test wiki_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": harmony.utils.numberToHex(index), "blockNumber": woop.utils.numberToHex(index),
"transactionIndex": harmony.utils.numberToHex(index), "transactionIndex": woop.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": harmony.utils.numberToHex(index), "v": woop.utils.numberToHex(index),
"r": harmony.utils.numberToHex(index), "r": woop.utils.numberToHex(index),
"s": harmony.utils.numberToHex(index), "s": woop.utils.numberToHex(index),
} }
}) })
); );
const txnDetail = await harmony.blockchain.getTransactionByHash({ const txnDetail = await woop.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 hmy_getTransactionByBlockHashAndIndex', async () => { it('should test wiki_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 = harmony.utils.numberToHex(index); let expectedTransactionIndex: string = woop.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": harmony.utils.numberToHex(index), "blockNumber": woop.utils.numberToHex(index),
"transactionIndex": harmony.utils.numberToHex(index), "transactionIndex": woop.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": harmony.utils.numberToHex(index), "v": woop.utils.numberToHex(index),
"r": harmony.utils.numberToHex(index), "r": woop.utils.numberToHex(index),
"s": harmony.utils.numberToHex(index), "s": woop.utils.numberToHex(index),
} }
})); }));
}); });
const transactionInfo: TransactionInfo = transactionInfoList[index]; const transactionInfo: TransactionInfo = transactionInfoList[index];
const txnDetail: any = await harmony.blockchain.getTransactionByBlockHashAndIndex({ const txnDetail: any = await woop.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 hmy_getTransactionByBlockNumberAndIndex', async () => { it('should test wiki_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 = harmony.utils.numberToHex(index); let expectedBlockNumber: string = woop.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 = harmony.utils.numberToHex(index); let expectedTransactionIndex: string = woop.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": harmony.utils.numberToHex(index), "blockNumber": woop.utils.numberToHex(index),
"transactionIndex": harmony.utils.numberToHex(index), "transactionIndex": woop.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": harmony.utils.numberToHex(index), "v": woop.utils.numberToHex(index),
"r": harmony.utils.numberToHex(index), "r": woop.utils.numberToHex(index),
"s": harmony.utils.numberToHex(index), "s": woop.utils.numberToHex(index),
} }
})); }));
}); });
const transactionInfo: TransactionInfo = transactionInfoList[index]; const transactionInfo: TransactionInfo = transactionInfoList[index];
const txnDetail: any = await harmony.blockchain.getTransactionByBlockNumberAndIndex({ const txnDetail: any = await woop.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 hmy_getTransactionCountByHash', async () => { it('should test wiki_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 harmony.blockchain.getBlockTransactionCountByHash({ const txnCount: any = await woop.blockchain.getBlockTransactionCountByHash({
blockHash: transactionInfo.blockHash, blockHash: transactionInfo.blockHash,
}); });
expect(checkCalledMethod(0, RPCMethod.GetBlockTransactionCountByHash)).toEqual(true); expect(checkCalledMethod(0, RPCMethod.GetBlockTransactionCountByHash)).toEqual(true);
expect(harmony.utils.isHex(txnCount.result)).toEqual(true); expect(woop.utils.isHex(txnCount.result)).toEqual(true);
} }
}); });
it('should test hmy_getTransactionCountByNumber', async () => { it('should test wiki_getTransactionCountByNumber', async () => {
for (const some of transactionInfoList) { 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 harmony.blockchain.getBlockTransactionCountByNumber({ const txnCount: any = await woop.blockchain.getBlockTransactionCountByNumber({
blockNumber: transactionInfo.blockNumber, blockNumber: transactionInfo.blockNumber,
}); });
expect(checkCalledMethod(0, RPCMethod.GetBlockTransactionCountByNumber)).toEqual(true); expect(checkCalledMethod(0, RPCMethod.GetBlockTransactionCountByNumber)).toEqual(true);
expect(harmony.utils.isHex(txnCount.result)).toEqual(true); expect(woop.utils.isHex(txnCount.result)).toEqual(true);
} }
}); });
it('should test hmy_getTransactionReceipt', async () => { it('should test wiki_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": harmony.utils.numberToHex(index), "blockNumber": woop.utils.numberToHex(index),
"from": transactions[index].senderAddress, "from": transactions[index].senderAddress,
"gasUsed": harmony.utils.numberToHex(index), "gasUsed": woop.utils.numberToHex(index),
"cumulativeGasUsed": harmony.utils.numberToHex(index), "cumulativeGasUsed": woop.utils.numberToHex(index),
"logs": [], "logs": [],
"logsBloom": harmony.utils.numberToHex(index), "logsBloom": woop.utils.numberToHex(index),
"shardID": 0, "shardID": 0,
"to": transactions[index].receiverAddress, "to": transactions[index].receiverAddress,
"transactionHash": hashes[index], "transactionHash": hashes[index],
"transactionIndex": harmony.utils.numberToHex(index), "transactionIndex": woop.utils.numberToHex(index),
"blockHash": blockHashes[index] "blockHash": blockHashes[index]
} }
}) })
); );
const receipt: any = await harmony.blockchain.getTransactionReceipt({ const receipt: any = await woop.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(harmony.crypto.getAddress(receipt.result.from).checksum).toEqual( expect(woop.crypto.getAddress(receipt.result.from).checksum).toEqual(
transactions[index].senderAddress, transactions[index].senderAddress,
); );
expect(harmony.crypto.getAddress(receipt.result.to).checksum).toEqual( expect(woop.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 hmy_getTransactionCount', async () => { it('should test wiki_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 harmony.blockchain.getTransactionCount({ const nonce: any = await woop.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 harmony.utils.validateArgs( return woop.utils.validateArgs(
data, data,
{ {
blockHash: [harmony.utils.isHash], blockHash: [woop.utils.isHash],
blockNumber: [harmony.utils.isHex], blockNumber: [woop.utils.isHex],
// tslint:disable-next-line: no-shadowed-variable // tslint:disable-next-line: no-shadowed-variable
from: [harmony.utils.isValidAddress], from: [woop.utils.isValidAddress],
gas: [harmony.utils.isHex], gas: [woop.utils.isHex],
gasPrice: [harmony.utils.isHex], gasPrice: [woop.utils.isHex],
hash: [harmony.utils.isHash], hash: [woop.utils.isHash],
// tslint:disable-next-line: no-shadowed-variable // tslint:disable-next-line: no-shadowed-variable
input: [(data: any) => data === '0x' || harmony.utils.isHex(data)], input: [(data: any) => data === '0x' || woop.utils.isHex(data)],
nonce: [harmony.utils.isHex], nonce: [woop.utils.isHex],
// tslint:disable-next-line: no-shadowed-variable // tslint:disable-next-line: no-shadowed-variable
to: [(data: any) => data === '0x' || harmony.utils.isValidAddress(data)], to: [(data: any) => data === '0x' || woop.utils.isValidAddress(data)],
transactionIndex: [harmony.utils.isHex], transactionIndex: [woop.utils.isHex],
value: [harmony.utils.isHex], value: [woop.utils.isHex],
v: [harmony.utils.isHex], v: [woop.utils.isHex],
r: [harmony.utils.isHex], r: [woop.utils.isHex],
s: [harmony.utils.isHex], s: [woop.utils.isHex],
}, },
{}, {},
); );
} }
function checkTransactionReceipt(data: any) { function checkTransactionReceipt(data: any) {
return harmony.utils.validateArgs( return woop.utils.validateArgs(
data, data,
{ {
blockNumber: [harmony.utils.isHex], blockNumber: [woop.utils.isHex],
contractAddress: [ contractAddress: [
// tslint:disable-next-line: no-shadowed-variable // tslint:disable-next-line: no-shadowed-variable
(data: any) => data === null || harmony.utils.isValidAddress, (data: any) => data === null || woop.utils.isValidAddress,
], ],
cumulativeGasUsed: [harmony.utils.isHex], cumulativeGasUsed: [woop.utils.isHex],
from: [harmony.utils.isValidAddress], from: [woop.utils.isValidAddress],
gasUsed: [harmony.utils.isHex], gasUsed: [woop.utils.isHex],
logs: [harmony.utils.isArray], logs: [woop.utils.isArray],
logsBloom: [harmony.utils.isHex], logsBloom: [woop.utils.isHex],
shardID: [harmony.utils.isNumber], shardID: [woop.utils.isNumber],
// tslint:disable-next-line: no-shadowed-variable // tslint:disable-next-line: no-shadowed-variable
to: [(data: any) => data === '0x' || harmony.utils.isValidAddress], to: [(data: any) => data === '0x' || woop.utils.isValidAddress],
transactionHash: [harmony.utils.isHash], transactionHash: [woop.utils.isHash],
transactionIndex: [harmony.utils.isHex], transactionIndex: [woop.utils.isHex],
}, },
{ blockHash: [harmony.utils.isHash], root: [harmony.utils.isHash] }, { blockHash: [woop.utils.isHash], root: [woop.utils.isHash] },
); );
} }

@ -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 { Harmony } from '@harmony-js/core'; import { Woop } from '@woop-js/core';
// tslint:disable-next-line: no-implicit-dependencies // tslint:disable-next-line: no-implicit-dependencies
import { ChainType } from '@harmony-js/utils'; import { ChainType } from '@woop-js/utils';
// tslint:disable-next-line: no-implicit-dependencies // tslint:disable-next-line: no-implicit-dependencies
import { Account } from '@harmony-js/account'; import { Account } from '@woop-js/account';
const CHAIN_ID: number = 2; const CHAIN_ID: number = 2;
const CHAIN_TYPE: string = 'hmy'; const CHAIN_TYPE: string = 'wiki';
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.Harmony; let chainType: ChainType = ChainType.Woop;
if (CHAIN_TYPE === 'hmy') { if (CHAIN_TYPE === 'wiki') {
chainType = ChainType.Harmony; chainType = ChainType.Woop;
} else if (CHAIN_TYPE === 'eth') { } else if (CHAIN_TYPE === 'eth') {
chainType = ChainType.Ethereum; chainType = ChainType.Ethereum;
} }
export const harmony: Harmony = new Harmony(HTTP_PROVIDER, { export const woop: Woop = new Woop(HTTP_PROVIDER, {
chainId: CHAIN_ID, chainId: CHAIN_ID,
chainType, chainType,
chainUrl: HTTP_PROVIDER, chainUrl: HTTP_PROVIDER,
}); });
export const myAccount: Account = harmony.wallet.addByPrivateKey( export const myAccount: Account = woop.wallet.addByPrivateKey(
GENESIS_PRIV_KEY, GENESIS_PRIV_KEY,
); );

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

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

288
package-lock.json generated

@ -1,14 +1,14 @@
{ {
"name": "harmony-sdk-core", "name": "woop-sdk-core",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "harmony-sdk-core", "name": "woop-sdk-core",
"license": "MIT", "license": "MIT",
"workspaces": ["packages/*"], "workspaces": ["packages/*"],
"dependencies": { "dependencies": {
"@harmony-js/core": "^0.1.36", "@woop-js/core": "^0.1.36",
"tslib": "^1.10.0", "tslib": "^1.10.0",
"typedoc-plugin-internal-external": "^2.1.1" "typedoc-plugin-internal-external": "^2.1.1"
}, },
@ -1806,36 +1806,36 @@
"integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==",
"dev": true "dev": true
}, },
"node_modules/@harmony-js/account": { "node_modules/@woop-js/account": {
"resolved": "packages/harmony-account", "resolved": "packages/woop-account",
"link": true "link": true
}, },
"node_modules/@harmony-js/contract": { "node_modules/@woop-js/contract": {
"resolved": "packages/harmony-contract", "resolved": "packages/woop-contract",
"link": true "link": true
}, },
"node_modules/@harmony-js/core": { "node_modules/@woop-js/core": {
"resolved": "packages/harmony-core", "resolved": "packages/woop-core",
"link": true "link": true
}, },
"node_modules/@harmony-js/crypto": { "node_modules/@woop-js/crypto": {
"resolved": "packages/harmony-crypto", "resolved": "packages/woop-crypto",
"link": true "link": true
}, },
"node_modules/@harmony-js/network": { "node_modules/@woop-js/network": {
"resolved": "packages/harmony-network", "resolved": "packages/woop-network",
"link": true "link": true
}, },
"node_modules/@harmony-js/staking": { "node_modules/@woop-js/staking": {
"resolved": "packages/harmony-staking", "resolved": "packages/woop-staking",
"link": true "link": true
}, },
"node_modules/@harmony-js/transaction": { "node_modules/@woop-js/transaction": {
"resolved": "packages/harmony-transaction", "resolved": "packages/woop-transaction",
"link": true "link": true
}, },
"node_modules/@harmony-js/utils": { "node_modules/@woop-js/utils": {
"resolved": "packages/harmony-utils", "resolved": "packages/woop-utils",
"link": true "link": true
}, },
"node_modules/@jest/types": { "node_modules/@jest/types": {
@ -24276,78 +24276,78 @@
"node": ">=4" "node": ">=4"
} }
}, },
"packages/harmony-account": { "packages/woop-account": {
"name": "@harmony-js/account", "name": "@woop-js/account",
"version": "0.1.57", "version": "0.1.57",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@harmony-js/core": "0.1.57", "@woop-js/core": "0.1.57",
"@harmony-js/crypto": "0.1.56", "@woop-js/crypto": "0.1.56",
"@harmony-js/network": "0.1.56", "@woop-js/network": "0.1.56",
"@harmony-js/staking": "0.1.56", "@woop-js/staking": "0.1.56",
"@harmony-js/transaction": "0.1.56", "@woop-js/transaction": "0.1.56",
"@harmony-js/utils": "0.1.56" "@woop-js/utils": "0.1.56"
} }
}, },
"packages/harmony-contract": { "packages/woop-contract": {
"name": "@harmony-js/contract", "name": "@woop-js/contract",
"version": "0.1.56", "version": "0.1.56",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@harmony-js/account": "0.1.56", "@woop-js/account": "0.1.56",
"@harmony-js/crypto": "0.1.56", "@woop-js/crypto": "0.1.56",
"@harmony-js/network": "0.1.56", "@woop-js/network": "0.1.56",
"@harmony-js/transaction": "0.1.56", "@woop-js/transaction": "0.1.56",
"@harmony-js/utils": "0.1.56" "@woop-js/utils": "0.1.56"
} }
}, },
"packages/harmony-contract/node_modules/@harmony-js/account": { "packages/woop-contract/node_modules/@woop-js/account": {
"version": "0.1.56", "version": "0.1.56",
"resolved": "https://registry.npmjs.org/@harmony-js/account/-/account-0.1.56.tgz", "resolved": "https://registry.npmjs.org/@woop-js/account/-/account-0.1.56.tgz",
"integrity": "sha512-VX3+NAirUxxowAc2QBuKEpHSN0XGYHqogYIf63XGFfg2BACS3RdN/tkJTzPPyIPejEKC3yDylm5c+8NzmsOjhQ==", "integrity": "sha512-VX3+NAirUxxowAc2QBuKEpHSN0XGYHqogYIf63XGFfg2BACS3RdN/tkJTzPPyIPejEKC3yDylm5c+8NzmsOjhQ==",
"dependencies": { "dependencies": {
"@harmony-js/core": "0.1.56", "@woop-js/core": "0.1.56",
"@harmony-js/crypto": "0.1.56", "@woop-js/crypto": "0.1.56",
"@harmony-js/network": "0.1.56", "@woop-js/network": "0.1.56",
"@harmony-js/staking": "0.1.56", "@woop-js/staking": "0.1.56",
"@harmony-js/transaction": "0.1.56", "@woop-js/transaction": "0.1.56",
"@harmony-js/utils": "0.1.56" "@woop-js/utils": "0.1.56"
} }
}, },
"packages/harmony-contract/node_modules/@harmony-js/core": { "packages/woop-contract/node_modules/@woop-js/core": {
"version": "0.1.56", "version": "0.1.56",
"resolved": "https://registry.npmjs.org/@harmony-js/core/-/core-0.1.56.tgz", "resolved": "https://registry.npmjs.org/@woop-js/core/-/core-0.1.56.tgz",
"integrity": "sha512-mYVIewX2oL0PHZJU64HD65M/QMA756d19MosATRqbfj8MLLgdMdTuXHF525NWDRxBiYlSh6BGSNJakNbtq8g3Q==", "integrity": "sha512-mYVIewX2oL0PHZJU64HD65M/QMA756d19MosATRqbfj8MLLgdMdTuXHF525NWDRxBiYlSh6BGSNJakNbtq8g3Q==",
"dependencies": { "dependencies": {
"@harmony-js/account": "0.1.56", "@woop-js/account": "0.1.56",
"@harmony-js/contract": "0.1.56", "@woop-js/contract": "0.1.56",
"@harmony-js/crypto": "0.1.56", "@woop-js/crypto": "0.1.56",
"@harmony-js/network": "0.1.56", "@woop-js/network": "0.1.56",
"@harmony-js/staking": "0.1.56", "@woop-js/staking": "0.1.56",
"@harmony-js/transaction": "0.1.56", "@woop-js/transaction": "0.1.56",
"@harmony-js/utils": "0.1.56" "@woop-js/utils": "0.1.56"
} }
}, },
"packages/harmony-core": { "packages/woop-core": {
"name": "@harmony-js/core", "name": "@woop-js/core",
"version": "0.1.57", "version": "0.1.57",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@harmony-js/account": "0.1.57", "@woop-js/account": "0.1.57",
"@harmony-js/contract": "0.1.56", "@woop-js/contract": "0.1.56",
"@harmony-js/crypto": "0.1.56", "@woop-js/crypto": "0.1.56",
"@harmony-js/network": "0.1.56", "@woop-js/network": "0.1.56",
"@harmony-js/staking": "0.1.56", "@woop-js/staking": "0.1.56",
"@harmony-js/transaction": "0.1.56", "@woop-js/transaction": "0.1.56",
"@harmony-js/utils": "0.1.56" "@woop-js/utils": "0.1.56"
} }
}, },
"packages/harmony-crypto": { "packages/woop-crypto": {
"name": "@harmony-js/crypto", "name": "@woop-js/crypto",
"version": "0.1.56", "version": "0.1.56",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@harmony-js/utils": "0.1.56", "@woop-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",
@ -24360,18 +24360,18 @@
"uuid": "^3.3.2" "uuid": "^3.3.2"
} }
}, },
"packages/harmony-network": { "packages/woop-network": {
"name": "@harmony-js/network", "name": "@woop-js/network",
"version": "0.1.56", "version": "0.1.56",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@harmony-js/utils": "0.1.56", "@woop-js/utils": "0.1.56",
"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"
} }
}, },
"packages/harmony-network/node_modules/cross-fetch": { "packages/woop-network/node_modules/cross-fetch": {
"version": "3.1.5", "version": "3.1.5",
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.5.tgz", "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.5.tgz",
"integrity": "sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw==", "integrity": "sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw==",
@ -24379,7 +24379,7 @@
"node-fetch": "2.6.7" "node-fetch": "2.6.7"
} }
}, },
"packages/harmony-network/node_modules/node-fetch": { "packages/woop-network/node_modules/node-fetch": {
"version": "2.6.7", "version": "2.6.7",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz",
"integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==",
@ -24398,17 +24398,17 @@
} }
} }
}, },
"packages/harmony-network/node_modules/tr46": { "packages/woop-network/node_modules/tr46": {
"version": "0.0.3", "version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="
}, },
"packages/harmony-network/node_modules/webidl-conversions": { "packages/woop-network/node_modules/webidl-conversions": {
"version": "3.0.1", "version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ=="
}, },
"packages/harmony-network/node_modules/whatwg-url": { "packages/woop-network/node_modules/whatwg-url": {
"version": "5.0.0", "version": "5.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
@ -24417,30 +24417,30 @@
"webidl-conversions": "^3.0.0" "webidl-conversions": "^3.0.0"
} }
}, },
"packages/harmony-staking": { "packages/woop-staking": {
"name": "@harmony-js/staking", "name": "@woop-js/staking",
"version": "0.1.56", "version": "0.1.56",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@harmony-js/crypto": "0.1.56", "@woop-js/crypto": "0.1.56",
"@harmony-js/network": "0.1.56", "@woop-js/network": "0.1.56",
"@harmony-js/transaction": "0.1.56", "@woop-js/transaction": "0.1.56",
"@harmony-js/utils": "0.1.56", "@woop-js/utils": "0.1.56",
"text-encoding": "^0.7.0" "text-encoding": "^0.7.0"
} }
}, },
"packages/harmony-transaction": { "packages/woop-transaction": {
"name": "@harmony-js/transaction", "name": "@woop-js/transaction",
"version": "0.1.56", "version": "0.1.56",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@harmony-js/crypto": "0.1.56", "@woop-js/crypto": "0.1.56",
"@harmony-js/network": "0.1.56", "@woop-js/network": "0.1.56",
"@harmony-js/utils": "0.1.56" "@woop-js/utils": "0.1.56"
} }
}, },
"packages/harmony-utils": { "packages/woop-utils": {
"name": "@harmony-js/utils", "name": "@woop-js/utils",
"version": "0.1.56", "version": "0.1.56",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
@ -25935,72 +25935,72 @@
} }
} }
}, },
"@harmony-js/account": { "@woop-js/account": {
"version": "file:packages/harmony-account", "version": "file:packages/woop-account",
"requires": { "requires": {
"@harmony-js/core": "0.1.57", "@woop-js/core": "0.1.57",
"@harmony-js/crypto": "0.1.56", "@woop-js/crypto": "0.1.56",
"@harmony-js/network": "0.1.56", "@woop-js/network": "0.1.56",
"@harmony-js/staking": "0.1.56", "@woop-js/staking": "0.1.56",
"@harmony-js/transaction": "0.1.56", "@woop-js/transaction": "0.1.56",
"@harmony-js/utils": "0.1.56" "@woop-js/utils": "0.1.56"
} }
}, },
"@harmony-js/contract": { "@woop-js/contract": {
"version": "file:packages/harmony-contract", "version": "file:packages/woop-contract",
"requires": { "requires": {
"@harmony-js/account": "0.1.56", "@woop-js/account": "0.1.56",
"@harmony-js/crypto": "0.1.56", "@woop-js/crypto": "0.1.56",
"@harmony-js/network": "0.1.56", "@woop-js/network": "0.1.56",
"@harmony-js/transaction": "0.1.56", "@woop-js/transaction": "0.1.56",
"@harmony-js/utils": "0.1.56" "@woop-js/utils": "0.1.56"
}, },
"dependencies": { "dependencies": {
"@harmony-js/account": { "@woop-js/account": {
"version": "0.1.56", "version": "0.1.56",
"resolved": "https://registry.npmjs.org/@harmony-js/account/-/account-0.1.56.tgz", "resolved": "https://registry.npmjs.org/@woop-js/account/-/account-0.1.56.tgz",
"integrity": "sha512-VX3+NAirUxxowAc2QBuKEpHSN0XGYHqogYIf63XGFfg2BACS3RdN/tkJTzPPyIPejEKC3yDylm5c+8NzmsOjhQ==", "integrity": "sha512-VX3+NAirUxxowAc2QBuKEpHSN0XGYHqogYIf63XGFfg2BACS3RdN/tkJTzPPyIPejEKC3yDylm5c+8NzmsOjhQ==",
"requires": { "requires": {
"@harmony-js/core": "0.1.56", "@woop-js/core": "0.1.56",
"@harmony-js/crypto": "0.1.56", "@woop-js/crypto": "0.1.56",
"@harmony-js/network": "0.1.56", "@woop-js/network": "0.1.56",
"@harmony-js/staking": "0.1.56", "@woop-js/staking": "0.1.56",
"@harmony-js/transaction": "0.1.56", "@woop-js/transaction": "0.1.56",
"@harmony-js/utils": "0.1.56" "@woop-js/utils": "0.1.56"
} }
}, },
"@harmony-js/core": { "@woop-js/core": {
"version": "0.1.56", "version": "0.1.56",
"resolved": "https://registry.npmjs.org/@harmony-js/core/-/core-0.1.56.tgz", "resolved": "https://registry.npmjs.org/@woop-js/core/-/core-0.1.56.tgz",
"integrity": "sha512-mYVIewX2oL0PHZJU64HD65M/QMA756d19MosATRqbfj8MLLgdMdTuXHF525NWDRxBiYlSh6BGSNJakNbtq8g3Q==", "integrity": "sha512-mYVIewX2oL0PHZJU64HD65M/QMA756d19MosATRqbfj8MLLgdMdTuXHF525NWDRxBiYlSh6BGSNJakNbtq8g3Q==",
"requires": { "requires": {
"@harmony-js/account": "0.1.56", "@woop-js/account": "0.1.56",
"@harmony-js/contract": "0.1.56", "@woop-js/contract": "0.1.56",
"@harmony-js/crypto": "0.1.56", "@woop-js/crypto": "0.1.56",
"@harmony-js/network": "0.1.56", "@woop-js/network": "0.1.56",
"@harmony-js/staking": "0.1.56", "@woop-js/staking": "0.1.56",
"@harmony-js/transaction": "0.1.56", "@woop-js/transaction": "0.1.56",
"@harmony-js/utils": "0.1.56" "@woop-js/utils": "0.1.56"
} }
} }
} }
}, },
"@harmony-js/core": { "@woop-js/core": {
"version": "file:packages/harmony-core", "version": "file:packages/woop-core",
"requires": { "requires": {
"@harmony-js/account": "0.1.57", "@woop-js/account": "0.1.57",
"@harmony-js/contract": "0.1.56", "@woop-js/contract": "0.1.56",
"@harmony-js/crypto": "0.1.56", "@woop-js/crypto": "0.1.56",
"@harmony-js/network": "0.1.56", "@woop-js/network": "0.1.56",
"@harmony-js/staking": "0.1.56", "@woop-js/staking": "0.1.56",
"@harmony-js/transaction": "0.1.56", "@woop-js/transaction": "0.1.56",
"@harmony-js/utils": "0.1.56" "@woop-js/utils": "0.1.56"
} }
}, },
"@harmony-js/crypto": { "@woop-js/crypto": {
"version": "file:packages/harmony-crypto", "version": "file:packages/woop-crypto",
"requires": { "requires": {
"@harmony-js/utils": "0.1.56", "@woop-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",
@ -26013,10 +26013,10 @@
"uuid": "^3.3.2" "uuid": "^3.3.2"
} }
}, },
"@harmony-js/network": { "@woop-js/network": {
"version": "file:packages/harmony-network", "version": "file:packages/woop-network",
"requires": { "requires": {
"@harmony-js/utils": "0.1.56", "@woop-js/utils": "0.1.56",
"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"
@ -26059,26 +26059,26 @@
} }
} }
}, },
"@harmony-js/staking": { "@woop-js/staking": {
"version": "file:packages/harmony-staking", "version": "file:packages/woop-staking",
"requires": { "requires": {
"@harmony-js/crypto": "0.1.56", "@woop-js/crypto": "0.1.56",
"@harmony-js/network": "0.1.56", "@woop-js/network": "0.1.56",
"@harmony-js/transaction": "0.1.56", "@woop-js/transaction": "0.1.56",
"@harmony-js/utils": "0.1.56", "@woop-js/utils": "0.1.56",
"text-encoding": "^0.7.0" "text-encoding": "^0.7.0"
} }
}, },
"@harmony-js/transaction": { "@woop-js/transaction": {
"version": "file:packages/harmony-transaction", "version": "file:packages/woop-transaction",
"requires": { "requires": {
"@harmony-js/crypto": "0.1.56", "@woop-js/crypto": "0.1.56",
"@harmony-js/network": "0.1.56", "@woop-js/network": "0.1.56",
"@harmony-js/utils": "0.1.56" "@woop-js/utils": "0.1.56"
} }
}, },
"@harmony-js/utils": { "@woop-js/utils": {
"version": "file:packages/harmony-utils", "version": "file:packages/woop-utils",
"requires": { "requires": {
"@types/bn.js": "^4.11.3", "@types/bn.js": "^4.11.3",
"bn.js": "^4.11.8" "bn.js": "^4.11.8"

@ -1,5 +1,5 @@
{ {
"description": "Root repository for the harmony-sdk-core", "description": "Root repository for the woop-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": "harmony-sdk-core", "name": "woop-sdk-core",
"dependencies": { "dependencies": {
"@harmony-js/core": "^0.1.36", "@woop-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. [@harmony-js/core](https://github.com/harmony-one/sdk/tree/master/packages/harmony-core) 1. [@woop-js/core](https://github.com/woop-chain/sdk/tree/master/packages/woop-core)
2. [@harmony-js/account](https://github.com/harmony-one/sdk/tree/master/packages/harmony-account) 2. [@woop-js/account](https://github.com/woop-chain/sdk/tree/master/packages/woop-account)
3. [@harmony-js/crypto](https://github.com/harmony-one/sdk/tree/master/packages/harmony-crypto) 3. [@woop-js/crypto](https://github.com/woop-chain/sdk/tree/master/packages/woop-crypto)
4. [@harmony-js/network](https://github.com/harmony-one/sdk/tree/master/packages/harmony-network) 4. [@woop-js/network](https://github.com/woop-chain/sdk/tree/master/packages/woop-network)
5. [@harmony-js/utils](https://github.com/harmony-one/sdk/tree/master/packages/harmony-utils) 5. [@woop-js/utils](https://github.com/woop-chain/sdk/tree/master/packages/woop-utils)
6. [@harmony-js/transaction](https://github.com/harmony-one/sdk/tree/master/packages/harmony-transaction) 6. [@woop-js/transaction](https://github.com/woop-chain/sdk/tree/master/packages/woop-transaction)
7. [@harmony-js/contract](https://github.com/harmony-one/sdk/tree/master/packages/harmony-contract) 7. [@woop-js/contract](https://github.com/woop-chain/sdk/tree/master/packages/woop-contract)
8. [@harmony-js/staking](https://github.com/harmony-one/sdk/tree/master/packages/harmony-staking) 8. [@woop-js/staking](https://github.com/woop-chain/sdk/tree/master/packages/woop-staking)
<mark>Package level documentation and examples are inside each package</mark> <mark>Package level documentation and examples are inside each package</mark>

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

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

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

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

@ -1,136 +0,0 @@
/**
# @harmony-js/network
This package provides a collection of apis to create messengers (HTTP, WebSocket) to connect to blockchain networks.
## Installation
```
npm install @harmony-js/network
```
## Usage
```javascript
const { Messenger, HttpProvider, WSProvider } = require('@harmony-js/network');
const { ChainID, ChainType } = require('@harmony-js/utils');
const testnetHTTP = 'https://api.s0.b.hmny.io';
const testnetWS = 'wss://ws.s0.b.hmny.io';
const localHTTP = 'http://localhost:9500/';
const localWS = 'http://localhost:9800/';
const http = new HttpProvider(testnetHTTP); // for local use localHTTP
const ws = new WSProvider(testnetWS); // for local use testnetWS
const customHTTPMessenger = new Messenger(http, ChainType.Harmony, ChainID.HmyTestnet); // for local ChainID.HmyLocal
const customWSMessenger = new Messenger(ws, ChainType.Harmony, ChainID.HmyTestnet); // for local ChainID.HmyLocal
```
*
* @packageDocumentation
* @module harmony-network
*/
/**@ignore */
export enum RPCMethod {
// 1. hmy_getBlockByHash
GetBlockByHash = 'hmy_getBlockByHash',
// 2. hmy_getBlockByNumber
GetBlockByNumber = 'hmy_getBlockByNumber',
// 3. hmy_getBlockTransactionCountByHash
GetBlockTransactionCountByHash = 'hmy_getBlockTransactionCountByHash',
// 4. hmy_getBlockTransactionCountByNumber
GetBlockTransactionCountByNumber = 'hmy_getBlockTransactionCountByNumber',
// 5. hmy_getCode
GetCode = 'hmy_getCode',
// 6. hmy_getTransactionByBlockHashAndIndex
GetTransactionByBlockHashAndIndex = 'hmy_getTransactionByBlockHashAndIndex',
// 7. hmy_getTransactionByBlockNumberAndIndex
GetTransactionByBlockNumberAndIndex = 'hmy_getTransactionByBlockNumberAndIndex',
// 8. hmy_getTransactionByHash
GetTransactionByHash = 'hmy_getTransactionByHash',
GetTransactionReceipt = 'hmy_getTransactionReceipt',
GetCXReceiptByHash = 'hmy_getCXReceiptByHash',
// 9. hmy_syncing
Syncing = 'hmy_syncing',
// 10. net_peerCount
PeerCount = 'net_peerCount',
// 11. hmy_getBalance
GetBalance = 'hmy_getBalance',
// 12. hmy_getStorageAt
GetStorageAt = 'hmy_getStorageAt',
// 13. hmy_getTransactionCount
GetTransactionCount = 'hmy_getTransactionCount',
// 14. hmy_sendTransaction
SendTransaction = 'hmy_sendTransaction',
// 15. hmy_sendRawTransaction
SendRawTransaction = 'hmy_sendRawTransaction',
// 16. hmy_subscribe
Subscribe = 'hmy_subscribe',
// 17. hmy_getlogs
GetPastLogs = 'hmy_getLogs',
// 18. hmy_getWork
GetWork = 'hmy_getWork',
// 19. hmy_submitWork
// SubmitWork = 'hmy_submitWork',
// 20. hmy_getProof
GetProof = 'hmy_getProof',
// 21, hmy_getFilterChanges
GetFilterChanges = 'hmy_getFilterChanges',
// 22. hmy_newPendingTransactionFilter
NewPendingTransactionFilter = 'hmy_newPendingTransactionFilter',
// 23. hmy_newBlockFilter
NewBlockFilter = 'hmy_newBlockFilter',
// 24. hmy_newFilter
NewFilter = 'hmy_newFilter',
// 25. hmy_call
Call = 'hmy_call',
// 26. hmy_estimateGas
EstimateGas = 'hmy_estimateGas',
// 27. hmy_gasPrice
GasPrice = 'hmy_gasPrice',
// 28. hmy_blockNumber
BlockNumber = 'hmy_blockNumber',
// 29. hmy_unsubscribe
UnSubscribe = 'hmy_unsubscribe',
// 30. net_version
NetVersion = 'net_version',
// 31. hmy_protocolVersion
ProtocolVersion = 'hmy_protocolVersion',
// 32. hmy_getShardingStructure
GetShardingStructure = 'hmy_getShardingStructure',
// 33. hmy_sendRawStakingTransaction
SendRawStakingTransaction = 'hmy_sendRawStakingTransaction',
// 34. hmy_getAccountNonce
GetAccountNonce = 'hmy_getAccountNonce',
// 35. hmy_getBlocks
GetBlocks = 'hmy_getBlocks',
}
/**@ignore */
export enum RPCErrorCode {
// Standard JSON-RPC 2.0 errors
// RPC_INVALID_REQUEST is internally mapped to HTTP_BAD_REQUEST (400).
// It should not be used for application-layer errors.
RPC_INVALID_REQUEST = -32600,
// RPC_METHOD_NOT_FOUND is internally mapped to HTTP_NOT_FOUND (404).
// It should not be used for application-layer errors.
RPC_METHOD_NOT_FOUND = -32601,
RPC_INVALID_PARAMS = -32602,
// RPC_INTERNAL_ERROR should only be used for genuine errors in bitcoind
// (for example datadir corruption).
RPC_INTERNAL_ERROR = -32603,
RPC_PARSE_ERROR = -32700,
// General application defined errors
RPC_MISC_ERROR = -1, // std::exception thrown in command handling
RPC_TYPE_ERROR = -3, // Unexpected type was passed as parameter
RPC_INVALID_ADDRESS_OR_KEY = -5, // Invalid address or key
RPC_INVALID_PARAMETER = -8, // Invalid, missing or duplicate parameter
RPC_DATABASE_ERROR = -20, // Database error
RPC_DESERIALIZATION_ERROR = -22, // Error parsing or validating structure in raw format
RPC_VERIFY_ERROR = -25, // General error during transaction or block submission
RPC_VERIFY_REJECTED = -26, // Transaction or block was rejected by network rules
RPC_IN_WARMUP = -28, // Client still warming up
RPC_METHOD_DEPRECATED = -32, // RPC method is deprecated
}

@ -1,11 +1,11 @@
# @harmony-js/account # @woop-js/account
This package provides a collection of apis to create accounts and wallets and sign using them. A wallet can hold multiple accounts and account is associated with a unique `one` address. This package also provides facilies to manage account keys. 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 @harmony-js/account npm install @woop-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.Harmony, ChainType.Woop,
ChainID.HmyTestnet, ChainID.WikiTestnet,
), ),
); );
``` ```
@ -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.Harmony, ChainType.Woop,
ChainID.HmyTestnet, ChainID.WikiTestnet,
); );
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.Harmony, ChainType.Woop,
ChainID.HmyTestnet, ChainID.WikiTestnet,
), ),
); );
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.Harmony, ChainType.Woop,
ChainID.HmyTestnet, ChainID.WikiTestnet,
), ),
); );
const { TransactionFactory } = require('@harmony-js/transaction'); const { TransactionFactory } = require('@woop-js/transaction');
const { Unit } = require('@harmony-js/utils'); const { Unit } = require('@woop-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('@harmony-js/account') const { Wallet } = require('@woop-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.Harmony, ChainType.Woop,
ChainID.HmyTestnet, ChainID.WikiTestnet,
), ),
); );
``` ```
@ -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.Harmony, ChainType.Woop,
ChainID.HmyTestnet, ChainID.WikiTestnet,
), ),
); );
``` ```
@ -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 = 'harmony-one'; const passphrase = 'woop-chain';
wallet.createAccount(passphrase).then(account => { wallet.createAccount(passphrase).then(account => {
console.log(account.bech32Address); console.log(account.bech32Address);
}); });

@ -1,12 +1,12 @@
/** /**
# @harmony-js/account # @woop-js/account
This package provides a collection of apis to create accounts and wallets and sign using them. A wallet can hold multiple accounts and account is associated with a unique `one` address. This package also provides facilies to manage account keys. 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 @harmony-js/account npm install @woop-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.Harmony, * ChainType.Woop,
* ChainID.HmyTestnet, * ChainID.WikiTestnet,
* ), * ),
* ); * );
``` ```
@ -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.Harmony, * ChainType.Woop,
* ChainID.HmyTestnet, * ChainID.WikiTestnet,
* ); * );
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.Harmony, * ChainType.Woop,
* ChainID.HmyTestnet, * ChainID.WikiTestnet,
* ), * ),
* ); * );
* 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.Harmony, * ChainType.Woop,
* ChainID.HmyTestnet, * ChainID.WikiTestnet,
* ), * ),
* ); * );
* const { TransactionFactory } = require('@harmony-js/transaction'); * const { TransactionFactory } = require('@woop-js/transaction');
* const { Unit } = require('@harmony-js/utils'); * const { Unit } = require('@woop-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('@harmony-js/account') * const { Wallet } = require('@woop-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.Harmony, * ChainType.Woop,
* ChainID.HmyTestnet, * ChainID.WikiTestnet,
* ), * ),
* ); * );
``` ```
@ -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.Harmony, * ChainType.Woop,
* ChainID.HmyTestnet, * ChainID.WikiTestnet,
* ), * ),
* ); * );
``` ```
@ -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 = 'harmony-one'; * const passphrase = 'woop-chain';
* 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 harmony-account * @module woop-account
*/ */
/**@ignore */ /**@ignore */

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

@ -1,6 +1,6 @@
/** /**
* @packageDocumentation * @packageDocumentation
* @module harmony-account * @module woop-account
* *
*/ */
@ -15,7 +15,7 @@ import {
Keystore, Keystore,
Signature, Signature,
getAddress, getAddress,
} from '@harmony-js/crypto'; } from '@woop-js/crypto';
import { import {
isPrivateKey, isPrivateKey,
@ -23,10 +23,10 @@ import {
hexToNumber, hexToNumber,
AddressSuffix, AddressSuffix,
ChainType, ChainType,
} from '@harmony-js/utils'; } from '@woop-js/utils';
import { Transaction, RLPSign } from '@harmony-js/transaction'; import { Transaction, RLPSign } from '@woop-js/transaction';
import { StakingTransaction } from '@harmony-js/staking'; import { StakingTransaction } from '@woop-js/staking';
import { Messenger, RPCMethod } from '@harmony-js/network'; import { Messenger, RPCMethod } from '@woop-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('@harmony-js/account'); * const { Account } = require('@woop-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('@harmony-js/network'); * const { HttpProvider, Messenger } = require('@woop-js/network');
* const { ChainType, ChainID } = require('@harmony-js/utils'); * const { ChainType, ChainID } = require('@woop-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.Harmony, // if you are connected to Harmony's blockchain * ChainType.Woop, // if you are connected to Woop's blockchain
* ChainID.HmyLocal, // check if the chainId is correct * ChainID.WikiLocal, // 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.Harmony this.messenger.chainPrefix === ChainType.Woop
? 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.Harmony this.messenger.chainPrefix === ChainType.Woop
? 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.Harmony this.messenger.chainPrefix === ChainType.Woop
? 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.Harmony this.messenger.chainPrefix === ChainType.Woop
? 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.Harmony, // if you are connected to Harmony's blockchain * ChainType.Woop, // if you are connected to Woop's blockchain
* ChainID.HmyLocal, // check if the chainId is correct * ChainID.WikiLocal, // 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 harmony-account * @module woop-account
*/ */
import { bip39, hdkey, getAddress, BN, Signature } from '@harmony-js/crypto'; import { bip39, hdkey, getAddress, BN, Signature } from '@woop-js/crypto';
import { import {
HDPath, HDPath,
// defineReadOnly, // defineReadOnly,
@ -14,9 +14,9 @@ import {
Unit, Unit,
isHex, isHex,
hexToNumber, hexToNumber,
} from '@harmony-js/utils'; } from '@woop-js/utils';
import { Messenger, HttpProvider, WSProvider, RPCMethod } from '@harmony-js/network'; import { Messenger, HttpProvider, WSProvider, RPCMethod } from '@woop-js/network';
import { Transaction, TxStatus, TransasctionReceipt } from '@harmony-js/transaction'; import { Transaction, TxStatus, TransasctionReceipt } from '@woop-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.Harmony, chainType: ChainType = ChainType.Woop,
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.Harmony ? HDPath : `m/44'/60'/0'/0/`; this.path = chainType === ChainType.Woop ? 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'],
'hmy', 'wiki',
this.shardID, this.shardID,
); );

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

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

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

@ -1,13 +1,13 @@
/** /**
* @packageDocumentation * @packageDocumentation
* @module harmony-account * @module woop-account
*/ */
import { bip39, hdkey, EncryptOptions, getAddress, generatePrivateKey } from '@harmony-js/crypto'; import { bip39, hdkey, EncryptOptions, getAddress, generatePrivateKey } from '@woop-js/crypto';
import { Messenger } from '@harmony-js/network'; import { Messenger } from '@woop-js/network';
import { isPrivateKey, isAddress, ChainType } from '@harmony-js/utils'; import { isPrivateKey, isAddress, ChainType } from '@woop-js/utils';
import { Transaction } from '@harmony-js/transaction'; import { Transaction } from '@woop-js/transaction';
import { StakingTransaction } from '@harmony-js/staking'; import { StakingTransaction } from '@woop-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('@harmony-js/account'); * const { Wallet } = require('@woop-js/account');
* const { HttpProvider, Messenger } = require('@harmony-js/network'); * const { HttpProvider, Messenger } = require('@woop-js/network');
* const { ChainType, ChainID } = require('@harmony-js/utils'); * const { ChainType, ChainID } = require('@woop-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.Harmony, // if you are connected to Harmony's blockchain * ChainType.Woop, // if you are connected to Woop's blockchain
* ChainID.HmyLocal, // check if the chainId is correct * ChainID.WikiLocal, // 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 Harmony's settings // TODO:hdkey should apply to Woop's settings
const path = this.messenger.chainType === ChainType.Harmony ? '1023' : '60'; const path = this.messenger.chainType === ChainType.Woop ? '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.Harmony, // if you are connected to Harmony's blockchain * ChainType.Woop, // if you are connected to Woop's blockchain
* ChainID.HmyLocal, // check if the chainId is correct * ChainID.WikiLocal, // 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 harmony-account * @module woop-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 '@harmony-js/network'; import { HttpProvider, Messenger } from '@woop-js/network';
import { ChainType, ChainID } from '@harmony-js/utils'; import { ChainType, ChainID } from '@woop-js/utils';
const provider = new HttpProvider('http://localhost:9500'); const provider = new HttpProvider('http://localhost:9500');
const messenger = new Messenger(provider, ChainType.Harmony, ChainID.HmyLocal); const messenger = new Messenger(provider, ChainType.Woop, ChainID.WikiLocal);
describe('test account', () => { 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": "../harmony-crypto" }, { "path": "../woop-crypto" },
{ "path": "../harmony-utils" }, { "path": "../woop-utils" },
{ "path": "../harmony-transaction" }, { "path": "../woop-transaction" },
{ "path": "../harmony-staking" }, { "path": "../woop-staking" },
{ "path": "../harmony-network" } { "path": "../woop-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/harmony-one/counter/contracts/Counter.sol\":\"Counter\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"/Users/gupadhyaya/go/src/github.com/harmony-one/counter/contracts/Counter.sol\":{\"keccak256\":\"0x082839c98df1285d97e56f9ccdb4cd52d6723ab394356acc6d618d96bbd7e60e\",\"urls\":[\"bzz-raw://fd2b8a231c2fadcd0e60787a92a6e9df1b962684329f2dd13560857572d36168\",\"dweb:/ipfs/QmRmp9NK2mZk5GGfkK5b33HsaY2jz8B6uWpUYij7K9RW3r\"]}},\"version\":1}", "metadata": "{\"compiler\":{\"version\":\"0.5.16+commit.9c3226ce\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"inc\",\"type\":\"address\"}],\"name\":\"DecrementedBy\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"inc\",\"type\":\"address\"}],\"name\":\"IncrementedBy\",\"type\":\"event\"},{\"constant\":false,\"inputs\":[],\"name\":\"decrementCounter\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getCount\",\"outputs\":[{\"internalType\":\"int256\",\"name\":\"\",\"type\":\"int256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"incrementCounter\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/Users/gupadhyaya/go/src/github.com/woop-chain/counter/contracts/Counter.sol\":\"Counter\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"/Users/gupadhyaya/go/src/github.com/woop-chain/counter/contracts/Counter.sol\":{\"keccak256\":\"0x082839c98df1285d97e56f9ccdb4cd52d6723ab394356acc6d618d96bbd7e60e\",\"urls\":[\"bzz-raw://fd2b8a231c2fadcd0e60787a92a6e9df1b962684329f2dd13560857572d36168\",\"dweb:/ipfs/QmRmp9NK2mZk5GGfkK5b33HsaY2jz8B6uWpUYij7K9RW3r\"]}},\"version\":1}",
"bytecode": "0x60806040526000805534801561001457600080fd5b506101a0806100246000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c80635b34b96614610046578063a87d942c14610050578063f5c5ad831461006e575b600080fd5b61004e610078565b005b6100586100ed565b6040518082815260200191505060405180910390f35b6100766100f6565b005b600160008082825401925050819055507f064b1e66d8d787e36504c45aac3405f69335030ab8dc365a34919de13b61799c33604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a1565b60008054905090565b600160008082825403925050819055507f102d4e03b331a68eaffb991d44063c4452a0b6b650d8fb74b6932d8bd856f1c133604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a156fea265627a7a72315820963135863e1328fe0c11fedc623e29e097902650e6976e7650a1577c1086fc6a64736f6c63430005100032", "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/harmony-one/counter/contracts/Counter.sol", "sourcePath": "/Users/gupadhyaya/go/src/github.com/woop-chain/counter/contracts/Counter.sol",
"ast": { "ast": {
"absolutePath": "/Users/gupadhyaya/go/src/github.com/harmony-one/counter/contracts/Counter.sol", "absolutePath": "/Users/gupadhyaya/go/src/github.com/woop-chain/counter/contracts/Counter.sol",
"exportedSymbols": { "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/harmony-one/counter/contracts/Counter.sol", "absolutePath": "/Users/gupadhyaya/go/src/github.com/woop-chain/counter/contracts/Counter.sol",
"exportedSymbols": { "exportedSymbols": {
"Counter": [47] "Counter": [47]
}, },

@ -1,27 +1,27 @@
# @harmony-js/contract # @woop-js/contract
This package provides a collection of apis to create, deploy, and interact with smart contracts. In Harmony, smart contracts all fully EVM compatible and the formats and terminologies match 1-to-1 with EVM smart contracts. This package provides a collection of apis to create, deploy, and interact with smart contracts. In Woop, smart contracts all fully EVM compatible and the formats and terminologies match 1-to-1 with EVM smart contracts.
## Installation ## Installation
``` ```
npm install @harmony-js/contract npm install @woop-js/contract
``` ```
## Usage ## Usage
Deploying a contract using `contractConstructor` Deploying a contract using `contractConstructor`
```javascript ```javascript
const { ContractFactory } = require('@harmony-js/contract'); const { ContractFactory } = require('@woop-js/contract');
const { Wallet } = require('@harmony-js/account'); const { Wallet } = require('@woop-js/account');
const { Messenger, HttpProvider } = require('@harmony-js/network'); const { Messenger, HttpProvider } = require('@woop-js/network');
const { ChainID, ChainType, hexToNumber } = require('@harmony-js/utils'); const { ChainID, ChainType, hexToNumber } = require('@woop-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.Harmony, ChainType.Woop,
ChainID.HmyTestnet, ChainID.WikiTestnet,
), ),
); );
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 { Harmony } = require("@harmony-js/core"); const { Woop } = require("@woop-js/core");
const { ChainID, ChainType } = require("@harmony-js/utils"); const { ChainID, ChainType } = require("@woop-js/utils");
const hmy = new Harmony("https://api.s0.b.hmny.io", { const wiki = new Woop("https://api.s0.b.hmny.io", {
chainType: ChainType.Harmony, chainType: ChainType.Woop,
chainId: ChainID.HmyTestnet, chainId: ChainID.WikiTestnet,
}); });
const contractJson = require("./Counter.json"); const contractJson = require("./Counter.json");
const contractAddr = "0x19f64050e6b2d376e52AC426E366c49EEb0724B1"; const contractAddr = "0x19f64050e6b2d376e52AC426E366c49EEb0724B1";
const contract = hmy.contracts.createContract(contractJson.abi, contractAddr); const contract = wiki.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('@harmony-js/contract'); const { ContractFactory } = require('@woop-js/contract');
const { Wallet } = require('@harmony-js/account'); const { Wallet } = require('@woop-js/account');
const { Messenger, HttpProvider } = require('@harmony-js/network'); const { Messenger, HttpProvider } = require('@woop-js/network');
const { ChainID, ChainType, hexToNumber } = require('@harmony-js/utils'); const { ChainID, ChainType, hexToNumber } = require('@woop-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.Harmony, ChainType.Woop,
ChainID.HmyTestnet, ChainID.WikiTestnet,
)); ));
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. Harmony uses 1 Gwei gas price and gas limit of 21000 by default. Use the estimate gas api to correctly set the gas limit. Call contract read-only methods. Woop uses 1 Gwei gas price and gas limit of 21000 by default. Use the estimate gas api to correctly set the gas limit.
```javascript ```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('@harmony-js/contract'); const { ContractFactory } = require('@woop-js/contract');
const { Wallet } = require('@harmony-js/account'); const { Wallet } = require('@woop-js/account');
const { Messenger, WSProvider } = require('@harmony-js/network'); const { Messenger, WSProvider } = require('@woop-js/network');
const { ChainID, ChainType, hexToNumber } = require('@harmony-js/utils'); const { ChainID, ChainType, hexToNumber } = require('@woop-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.Harmony, ChainType.Woop,
ChainID.HmyTestnet, ChainID.WikiTestnet,
), ),
); );
const factory = new ContractFactory(wallet); const factory = new ContractFactory(wallet);

@ -1,7 +1,7 @@
{ {
"name": "@harmony-js/contract", "name": "@woop-js/contract",
"version": "0.1.58", "version": "0.1.58",
"description": "contract libraries for harmony", "description": "contract libraries for woop",
"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": {
"@harmony-js/account": "0.1.58", "@woop-js/account": "0.1.58",
"@harmony-js/crypto": "0.1.58", "@woop-js/crypto": "0.1.58",
"@harmony-js/network": "0.1.58", "@woop-js/network": "0.1.58",
"@harmony-js/transaction": "0.1.58", "@woop-js/transaction": "0.1.58",
"@harmony-js/utils": "0.1.58" "@woop-js/utils": "0.1.58"
}, },
"gitHead": "56606e9365721729a490c27d6a294e0daf90fbdf" "gitHead": "56606e9365721729a490c27d6a294e0daf90fbdf"
} }

@ -1,28 +1,28 @@
/** /**
# @harmony-js/contract # @woop-js/contract
This package provides a collection of apis to create, deploy, and interact with smart contracts. In Harmony, smart contracts all fully EVM compatible and the formats and terminologies match 1-to-1 with EVM smart contracts. This package provides a collection of apis to create, deploy, and interact with smart contracts. In Woop, smart contracts all fully EVM compatible and the formats and terminologies match 1-to-1 with EVM smart contracts.
## Installation ## Installation
``` ```
npm install @harmony-js/contract npm install @woop-js/contract
``` ```
## Usage ## Usage
Deploying a contract using `contractConstructor` Deploying a contract using `contractConstructor`
```javascript ```javascript
const { ContractFactory } = require('@harmony-js/contract'); const { ContractFactory } = require('@woop-js/contract');
const { Wallet } = require('@harmony-js/account'); const { Wallet } = require('@woop-js/account');
const { Messenger, HttpProvider } = require('@harmony-js/network'); const { Messenger, HttpProvider } = require('@woop-js/network');
const { ChainID, ChainType, hexToNumber } = require('@harmony-js/utils'); const { ChainID, ChainType, hexToNumber } = require('@woop-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.Harmony, * ChainType.Woop,
* ChainID.HmyTestnet, * ChainID.WikiTestnet,
* ), * ),
* ); * );
* 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 { Harmony } = require("@harmony-js/core"); * const { Woop } = require("@woop-js/core");
* const { ChainID, ChainType } = require("@harmony-js/utils"); * const { ChainID, ChainType } = require("@woop-js/utils");
* const hmy = new Harmony("https://api.s0.b.hmny.io", { * const wiki = new Woop("https://api.s0.b.hmny.io", {
* chainType: ChainType.Harmony, * chainType: ChainType.Woop,
* chainId: ChainID.HmyTestnet, * chainId: ChainID.WikiTestnet,
* }); * });
const contractJson = require("./Counter.json"); const contractJson = require("./Counter.json");
const contractAddr = "0x19f64050e6b2d376e52AC426E366c49EEb0724B1"; const contractAddr = "0x19f64050e6b2d376e52AC426E366c49EEb0724B1";
const contract = hmy.contracts.createContract(contractJson.abi, contractAddr); const contract = wiki.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('@harmony-js/contract'); const { ContractFactory } = require('@woop-js/contract');
const { Wallet } = require('@harmony-js/account'); const { Wallet } = require('@woop-js/account');
const { Messenger, HttpProvider } = require('@harmony-js/network'); const { Messenger, HttpProvider } = require('@woop-js/network');
const { ChainID, ChainType, hexToNumber } = require('@harmony-js/utils'); const { ChainID, ChainType, hexToNumber } = require('@woop-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.Harmony, * ChainType.Woop,
* ChainID.HmyTestnet, * ChainID.WikiTestnet,
* )); * ));
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. Harmony uses 1 Gwei gas price and gas limit of 21000 by default. Use the estimate gas api to correctly set the gas limit. Call contract read-only methods. Woop uses 1 Gwei gas price and gas limit of 21000 by default. Use the estimate gas api to correctly set the gas limit.
```javascript ```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('@harmony-js/contract'); * const { ContractFactory } = require('@woop-js/contract');
* const { Wallet } = require('@harmony-js/account'); * const { Wallet } = require('@woop-js/account');
* const { Messenger, WSProvider } = require('@harmony-js/network'); * const { Messenger, WSProvider } = require('@woop-js/network');
* const { ChainID, ChainType, hexToNumber } = require('@harmony-js/utils'); * const { ChainID, ChainType, hexToNumber } = require('@woop-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.Harmony, * ChainType.Woop,
* ChainID.HmyTestnet, * ChainID.WikiTestnet,
* ), * ),
* ); * );
* 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 harmony-contract * @module woop-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 '@harmony-js/crypto'; } from '@woop-js/crypto';
import { hexToBN, defineReadOnly } from '@harmony-js/utils'; import { hexToBN, defineReadOnly } from '@woop-js/utils';
/** @hidden */ /** @hidden */
const NegativeOne: BN = new BN(-1); const NegativeOne: BN = new BN(-1);

@ -1,12 +1,12 @@
/** /**
* @packageDocumentation * @packageDocumentation
* @module harmony-contract * @module woop-contract
* @hidden * @hidden
*/ */
import { AbiCoder as ABICoder, ParamType, toUtf8Bytes } from './abiCoder'; import { AbiCoder as ABICoder, ParamType, toUtf8Bytes } from './abiCoder';
import { isObject, isArray } from '@harmony-js/utils'; import { isObject, isArray } from '@woop-js/utils';
import { keccak256, Arrayish } from '@harmony-js/crypto'; import { keccak256, Arrayish } from '@woop-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 harmony-contract * @module woop-contract
* @hidden * @hidden
*/ */

@ -1,11 +1,11 @@
/** /**
* @packageDocumentation * @packageDocumentation
* @module harmony-contract * @module woop-contract
* @hidden * @hidden
*/ */
import { isObject, isArray } from '@harmony-js/utils'; import { isObject, isArray } from '@woop-js/utils';
import { BN } from '@harmony-js/crypto'; import { BN } from '@woop-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 harmony-contract * @module woop-contract
* *
*/ */
import { Wallet } from '@harmony-js/account'; import { Wallet } from '@woop-js/account';
import { Messenger } from '@harmony-js/network'; import { Messenger } from '@woop-js/network';
import { Transaction } from '@harmony-js/transaction'; import { Transaction } from '@woop-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 harmony-contract * @module woop-contract
*/ */
import { Wallet } from '@harmony-js/account'; import { Wallet } from '@woop-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 harmony-contract * @module woop-contract
*/ */
import { LogSub } from '@harmony-js/network'; import { LogSub } from '@woop-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 harmony-contract * @module woop-contract
* @hidden * @hidden
*/ */
import { isArray } from '@harmony-js/utils'; import { isArray } from '@woop-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 harmony-contract * @module woop-contract
* @hidden * @hidden
*/ */

@ -1,13 +1,13 @@
/** /**
* @packageDocumentation * @packageDocumentation
* @module harmony-contract * @module woop-contract
*/ */
import { Wallet } from '@harmony-js/account'; import { Wallet } from '@woop-js/account';
import { TransactionFactory, Transaction, TxStatus } from '@harmony-js/transaction'; import { TransactionFactory, Transaction, TxStatus } from '@woop-js/transaction';
import { RPCMethod, getResultForData, Emitter } from '@harmony-js/network'; import { RPCMethod, getResultForData, Emitter } from '@woop-js/network';
import { hexToBN, Unit } from '@harmony-js/utils'; import { hexToBN, Unit } from '@woop-js/utils';
import { getAddress } from '@harmony-js/crypto'; import { getAddress } from '@woop-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 harmony-contract * @module woop-contract
* @hidden * @hidden
*/ */

@ -1,10 +1,10 @@
/** /**
* @packageDocumentation * @packageDocumentation
* @module harmony-contract * @module woop-contract
* @hidden * @hidden
*/ */
import { isArray } from '@harmony-js/utils'; import { isArray } from '@woop-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 harmony-contract * @module woop-contract
* @hidden * @hidden
*/ */

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

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

@ -1,10 +1,10 @@
/** /**
* @packageDocumentation * @packageDocumentation
* @module harmony-contract * @module woop-contract
* @hidden * @hidden
*/ */
import { isArray } from '@harmony-js/utils'; import { isArray } from '@woop-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 harmony-contract * @module woop-contract
* @hidden * @hidden
*/ */
import { hexlify, isHexString, keccak256, toChecksumAddress } from '@harmony-js/crypto'; import { hexlify, isHexString, keccak256, toChecksumAddress } from '@woop-js/crypto';
import { import {
numberToHex, numberToHex,
isArray, isArray,
@ -12,7 +12,7 @@ import {
isString, isString,
isAddress, isAddress,
hexToBN, hexToBN,
} from '@harmony-js/utils'; } from '@woop-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 harmony-contract * @module woop-contract
* @hidden * @hidden
*/ */
import { isArray } from '@harmony-js/utils'; import { isArray } from '@woop-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 harmony-contract * @module woop-contract
* @hidden * @hidden
*/ */

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

@ -4,8 +4,8 @@
*/ */
import { AbiCoder } from '../src/abi/abiCoder'; import { AbiCoder } from '../src/abi/abiCoder';
import { BN } from '@harmony-js/crypto'; import { BN } from '@woop-js/crypto';
import { isArray } from '@harmony-js/utils'; import { isArray } from '@woop-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": "../harmony-account"}, {"path": "../woop-account"},
{"path": "../harmony-crypto"}, {"path": "../woop-crypto"},
{"path": "../harmony-utils"}, {"path": "../woop-utils"},
{"path": "../harmony-transaction"}, {"path": "../woop-transaction"},
{"path": "../harmony-network"} {"path": "../woop-network"}
] ]
} }

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

@ -1,7 +1,7 @@
{ {
"name": "@harmony-js/account", "name": "@woop-js/core",
"version": "0.1.58", "version": "0.1.58",
"description": "account and wallet for harmony", "description": "woop 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,12 +18,13 @@
"author": "neeboo@firestack.one", "author": "neeboo@firestack.one",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@harmony-js/core": "0.1.58", "@woop-js/account": "0.1.58",
"@harmony-js/crypto": "0.1.58", "@woop-js/contract": "0.1.58",
"@harmony-js/network": "0.1.58", "@woop-js/crypto": "0.1.58",
"@harmony-js/staking": "0.1.58", "@woop-js/network": "0.1.58",
"@harmony-js/transaction": "0.1.58", "@woop-js/staking": "0.1.58",
"@harmony-js/utils": "0.1.58" "@woop-js/transaction": "0.1.58",
"@woop-js/utils": "0.1.58"
}, },
"gitHead": "56606e9365721729a490c27d6a294e0daf90fbdf" "gitHead": "56606e9365721729a490c27d6a294e0daf90fbdf"
} }

@ -1,20 +1,20 @@
/** /**
# @harmony-js/core # @woop-js/core
This package provides a collection of apis to interact with Harmony blockchain. This package provides a collection of apis to interact with Woop blockchain.
## Installation ## Installation
``` ```
npm install @harmony-js/core npm install @woop-js/core
``` ```
## Usage ## Usage
Create a Harmony instance connecting to testnet Create a Woop instance connecting to testnet
```javascript ```javascript
* const { Harmony } = require('@harmony-js/core'); * const { Woop } = require('@woop-js/core');
* const { * const {
* ChainID, * ChainID,
* ChainType, * ChainType,
@ -23,20 +23,20 @@ Create a Harmony instance connecting to testnet
* fromWei, * fromWei,
* Units, * Units,
* Unit, * Unit,
* } = require('@harmony-js/utils'); * } = require('@woop-js/utils');
* const hmy = new Harmony( * const wiki = new Woop(
* 'https://api.s0.b.hmny.io/', * 'https://api.s0.b.hmny.io/',
* { * {
* chainType: ChainType.Harmony, * chainType: ChainType.Woop,
* chainId: ChainID.HmyTestnet, * chainId: ChainID.WikiTestnet,
* }, * },
* ); * );
``` ```
Getting balance of account `one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7` Getting balance of account `one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7`
```javascript ```javascript
* hmy.blockchain * wiki.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
* hmy.blockchain.getBlockNumber().then((response) => { * wiki.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
* hmy.blockchain * wiki.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
* hmy.blockchain * wiki.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
* hmy.blockchain * wiki.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
* hmy.blockchain * wiki.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
* hmy.blockchain * wiki.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
* hmy.blockchain * wiki.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
* hmy.blockchain * wiki.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
* hmy.blockchain.getShardingStructure().then((response) => { * wiki.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
* hmy.wallet.addByPrivateKey('45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e'); * wiki.wallet.addByPrivateKey('45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e');
* async function transfer() { * async function transfer() {
* const txn = hmy.transactions.newTx({ * const txn = wiki.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 hmy.utils.Unit('1').asGwei().toWei(), * gasPrice: new wiki.utils.Unit('1').asGwei().toWei(),
* }); * });
* // sign the transaction use wallet; * // sign the transaction use wallet;
* const signedTxn = await hmy.wallet.signTransaction(txn); * const signedTxn = await wiki.wallet.signTransaction(txn);
* const txnHash = await hmy.blockchain.sendTransaction(signedTxn); * const txnHash = await wiki.blockchain.sendTransaction(signedTxn);
* console.log(txnHash.result); * console.log(txnHash.result);
* } * }
@ -165,7 +165,7 @@ Transferring funds using `sendTransaction`
``` ```
* *
* @packageDocumentation * @packageDocumentation
* @module harmony-core * @module woop-core
*/ */
import { import {
@ -177,19 +177,19 @@ import {
NewHeaders, NewHeaders,
LogSub, LogSub,
Syncing, Syncing,
} from '@harmony-js/network'; } from '@woop-js/network';
import { import {
assertObject, assertObject,
AssertType, AssertType,
// HarmonyCore, // WoopCore,
DefaultBlockParams, DefaultBlockParams,
} from '@harmony-js/utils'; } from '@woop-js/utils';
import { getAddress } from '@harmony-js/crypto'; import { getAddress } from '@woop-js/crypto';
import { Transaction } from '@harmony-js/transaction'; import { Transaction } from '@woop-js/transaction';
import { StakingTransaction } from '@harmony-js/staking'; import { StakingTransaction } from '@woop-js/staking';
class Blockchain { class Blockchain {
/** /**
@ -241,7 +241,7 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* hmy.blockchain.getBalance({ * wiki.blockchain.getBalance({
* address: 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7', * address: 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7',
* blockNumber: 'latest' * blockNumber: 'latest'
* }).then(value => { * }).then(value => {
@ -287,7 +287,7 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* hmy.blockchain.getBlockNumber().then((value) => { * wiki.blockchain.getBlockNumber().then((value) => {
* console.log(value.result); * console.log(value.result);
* }); * });
* ``` * ```
@ -312,7 +312,7 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* hmy.blockchain.getBlockByHash({ * wiki.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
* hmy.blockchain.getBlockByNumber({ * wiki.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
* hmy.blockchain.getBlocks({ * wiki.blockchain.getBlocks({
* from: '0x89', * from: '0x89',
* to: '0x89', * to: '0x89',
* }).then((value) => { * }).then((value) => {
@ -442,7 +442,7 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* hmy.blockchain.getBlockTransactionCountByHash({ * wiki.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
* hmy.blockchain.getBlockTransactionCountByNumber({ * wiki.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
* hmy.blockchain.getTransactionByBlockHashAndIndex({ * wiki.blockchain.getTransactionByBlockHashAndIndex({
* blockHash: '0x4142514a238157e7fe57b9d54abedb33943507fa15b3799954c273a12705ced1', * blockHash: '0x4142514a238157e7fe57b9d54abedb33943507fa15b3799954c273a12705ced1',
* index: '0x0' * index: '0x0'
* }).then((value) => { * }).then((value) => {
@ -556,7 +556,7 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* hmy.blockchain.getTransactionByBlockNumberAndIndex({ * wiki.blockchain.getTransactionByBlockNumberAndIndex({
* blockNumber: '0x2403C', * blockNumber: '0x2403C',
* index: '0x0' * index: '0x0'
* }).then((value) => { * }).then((value) => {
@ -596,7 +596,7 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* hmy.blockchain.getTransactionByHash({ * wiki.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
* hmy.blockchain.getTransactionReceipt({ * wiki.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
* hmy.blockchain.getCxReceiptByHash({ * wiki.blockchain.getCxReceiptByHash({
* txnHash: '0x7fae9252fbda68d718e610bc10cf2b5c6a9cafb42d4a6b9d6e392c77d587b9ea', * txnHash: '0x7fae9252fbda68d718e610bc10cf2b5c6a9cafb42d4a6b9d6e392c77d587b9ea',
* shardID: 1, * shardID: 1,
* }).then((value) => { * }).then((value) => {
@ -701,7 +701,7 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* hmy.blockchain.getCode({ * wiki.blockchain.getCode({
* address: '0x08AE1abFE01aEA60a47663bCe0794eCCD5763c19', * address: '0x08AE1abFE01aEA60a47663bCe0794eCCD5763c19',
* blockNumber: 'latest' * blockNumber: 'latest'
* }).then((value) => { * }).then((value) => {
@ -740,7 +740,7 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* hmy.blockchain.net_peerCount().then((value) => { * wiki.blockchain.net_peerCount().then((value) => {
* console.log(value.result); * console.log(value.result);
* }); * });
* ``` * ```
@ -759,7 +759,7 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* hmy.blockchain.net_version().then((value) => { * wiki.blockchain.net_version().then((value) => {
* console.log(value.result); * console.log(value.result);
* }); * });
* ``` * ```
@ -778,7 +778,7 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* hmy.blockchain.getProtocolVersion().then((value) => { * wiki.blockchain.getProtocolVersion().then((value) => {
* console.log(value.result); * console.log(value.result);
* }); * });
* ``` * ```
@ -803,7 +803,7 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* hmy.blockchain.getStorageAt({ * wiki.blockchain.getStorageAt({
* address: 'one1d0kw95t6kkljmkk9vu0zv25jraut8ngv5vrs5g', * address: 'one1d0kw95t6kkljmkk9vu0zv25jraut8ngv5vrs5g',
* position: '0x0' * position: '0x0'
* }).then((value) => { * }).then((value) => {
@ -847,7 +847,7 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* hmy.blockchain.getTransactionCount({ * wiki.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
* hmy.blockchain.getShardingStructure().then((value) => { * wiki.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';
* hmy.wallet.addByPrivateKey(privateKey); * wiki.wallet.addByPrivateKey(privateKey);
* *
* async function transfer() { * async function transfer() {
* const txn = hmy.transactions.newTx({ * const txn = wiki.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 hmy.utils.Unit('100').asGwei().toWei(), * gasPrice: new wiki.utils.Unit('100').asGwei().toWei(),
* }); * });
* *
* // sign the transaction use wallet; * // sign the transaction use wallet;
* const signedTxn = await hmy.wallet.signTransaction(txn); * const signedTxn = await wiki.wallet.signTransaction(txn);
* const txnHash = await hmy.blockchain.sendTransaction(signedTxn); * const txnHash = await wiki.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';
* hmy.wallet.addByPrivateKey(privateKey); * wiki.wallet.addByPrivateKey(privateKey);
* *
* async function transfer() { * async function transfer() {
* const txn = hmy.transactions.newTx({ * const txn = wiki.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 hmy.utils.Unit('100').asGwei().toWei(), * gasPrice: new wiki.utils.Unit('100').asGwei().toWei(),
* }); * });
* *
* // sign the transaction use wallet; * // sign the transaction use wallet;
* const signedTxn = await hmy.wallet.signTransaction(txn); * const signedTxn = await wiki.wallet.signTransaction(txn);
* recovered = signedTxn.recover(signedTxn.rawTransaction); * recovered = signedTxn.recover(signedTxn.rawTransaction);
* *
* const txnHash = await hmy.blockchain.sendRawTransaction(recovered); * const txnHash = await wiki.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';
* hmy.wallet.addByPrivateKey(privateKey); * wiki.wallet.addByPrivateKey(privateKey);
* *
* async function transfer() { * async function transfer() {
* const txn = hmy.transactions.newTx({ * const txn = wiki.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 hmy.utils.Unit('100').asGwei().toWei(), * gasPrice: new wiki.utils.Unit('100').asGwei().toWei(),
* }); * });
* *
* // sign the transaction use wallet; * // sign the transaction use wallet;
* const signedTxn = await hmy.wallet.signTransaction(txn); * const signedTxn = await wiki.wallet.signTransaction(txn);
* const txnHash = await hmy.blockchain.createObservedTransaction(signedTxn); * const txnHash = await wiki.blockchain.createObservedTransaction(signedTxn);
* console.log(txnHash); * console.log(txnHash);
* } * }
* *
@ -1108,12 +1108,12 @@ class Blockchain {
* *
* @warning * @warning
* ``` * ```
* At present, this function hmy_estimateGas is not implement yet, will Coming soon!!! * At present, this function wiki_estimateGas is not implement yet, will Coming soon!!!
* ``` * ```
* *
* @example * @example
* ```javascript * ```javascript
* hmy.blockchain.estimateGas({ * wiki.blockchain.estimateGas({
* to: 'one1d0kw95t6kkljmkk9vu0zv25jraut8ngv5vrs5g', * to: 'one1d0kw95t6kkljmkk9vu0zv25jraut8ngv5vrs5g',
* data: '0xc6888fa10000000000000000000000000000000000000000000000000000000000000003' * data: '0xc6888fa10000000000000000000000000000000000000000000000000000000000000003'
* }).then((value) => { * }).then((value) => {
@ -1152,7 +1152,7 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* hmy.blockchain.gasPrice().then((value) => { * wiki.blockchain.gasPrice().then((value) => {
* console.log(value); * console.log(value);
* }); * });
* ``` * ```
@ -1177,7 +1177,7 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* hmy.blockchain.call({ * wiki.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 hmy = new Harmony( * const wiki = new Woop(
* // rpc url * // rpc url
* 'ws://api.s0.b.hmny.io/', * 'ws://api.s0.b.hmny.io/',
* { * {
* // chainType set to Harmony * // chainType set to Woop
* chainType: ChainType.Harmony, * chainType: ChainType.Woop,
* // chainType set to HmyLocal * // chainType set to WikiLocal
* chainId: ChainID.HmyLocal, * chainId: ChainID.WikiLocal,
* }, * },
* ); * );
* *
* const tmp = hmy.blockchain.newPendingTransactions(); * const tmp = wiki.blockchain.newPendingTransactions();
* console.log(tmp) * console.log(tmp)
* ``` * ```
*/ */
@ -1238,18 +1238,18 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* const hmy = new Harmony( * const wiki = new Woop(
* // rpc url * // rpc url
* 'ws://api.s0.b.hmny.io/', * 'ws://api.s0.b.hmny.io/',
* { * {
* // chainType set to Harmony * // chainType set to Woop
* chainType: ChainType.Harmony, * chainType: ChainType.Woop,
* // chainType set to HmyLocal * // chainType set to WikiLocal
* chainId: ChainID.HmyLocal, * chainId: ChainID.WikiLocal,
* }, * },
* ); * );
* *
* const tmp = hmy.blockchain.newBlockHeaders(); * const tmp = wiki.blockchain.newBlockHeaders();
* console.log(tmp) * console.log(tmp)
* ``` * ```
*/ */
@ -1267,18 +1267,18 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* const hmy = new Harmony( * const wiki = new Woop(
* // rpc url * // rpc url
* 'ws://api.s0.b.hmny.io/', * 'ws://api.s0.b.hmny.io/',
* { * {
* // chainType set to Harmony * // chainType set to Woop
* chainType: ChainType.Harmony, * chainType: ChainType.Woop,
* // chainType set to HmyLocal * // chainType set to WikiLocal
* chainId: ChainID.HmyLocal, * chainId: ChainID.WikiLocal,
* }, * },
* ); * );
* *
* const tmp = hmy.blockchain.syncing(); * const tmp = wiki.blockchain.syncing();
* console.log(tmp) * console.log(tmp)
* ``` * ```
*/ */
@ -1296,18 +1296,18 @@ class Blockchain {
* *
* @example * @example
* ```javascript * ```javascript
* const hmy = new Harmony( * const wiki = new Woop(
* // rpc url * // rpc url
* 'ws://api.s0.b.hmny.io/', * 'ws://api.s0.b.hmny.io/',
* { * {
* // chainType set to Harmony * // chainType set to Woop
* chainType: ChainType.Harmony, * chainType: ChainType.Woop,
* // chainType set to HmyLocal * // chainType set to WikiLocal
* chainId: ChainID.HmyLocal, * chainId: ChainID.WikiLocal,
* }, * },
* ); * );
* *
* const tmp = hmy.blockchain.logs({ * const tmp = wiki.blockchain.logs({
* from: '0x12' * from: '0x12'
* }); * });
* console.log(tmp) * console.log(tmp)

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

@ -1,6 +1,6 @@
/** /**
* @packageDocumentation * @packageDocumentation
* @module harmony-core * @module woop-core
* @hidden * @hidden
*/ */
@ -9,11 +9,11 @@ import {
WSProvider, WSProvider,
RPCRequestPayload, RPCRequestPayload,
ResponseMiddleware, ResponseMiddleware,
} from '@harmony-js/network'; } from '@woop-js/network';
import { ChainID, ChainType, Unit, isBech32Address } from '@harmony-js/utils'; import { ChainID, ChainType, Unit, isBech32Address } from '@woop-js/utils';
import { HDNode } from '@harmony-js/account'; import { HDNode } from '@woop-js/account';
import { fromBech32, HRP } from '@harmony-js/crypto'; import { fromBech32, HRP } from '@woop-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.Harmony, chainType: ChainType.Woop,
chainId: ChainID.HmyLocal, chainId: ChainID.WikiLocal,
}, },
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 'hmy_accounts': { case 'wiki_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 'hmy_sendTransaction': { case 'wiki_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: 'hmy_sendRawTransaction', method: 'wiki_sendRawTransaction',
params: [rawTxn], params: [rawTxn],
jsonrpc: '2.0', jsonrpc: '2.0',
}, },
@ -106,11 +106,11 @@ export class TruffleProvider extends HDNode {
// break; // break;
} }
case 'hmy_getTransactionReceipt': { case 'wiki_getTransactionReceipt': {
const result = await this.provider.send( const result = await this.provider.send(
{ {
id, id,
method: 'hmy_getTransactionReceipt', method: 'wiki_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: `Harmony/${packageInfo.version}/@harmony-js`, result: `Woop/${packageInfo.version}/@woop-js`,
id, id,
jsonrpc: '2.0', jsonrpc: '2.0',
}); });
return { return {
result: `Harmony/${packageInfo.version}/@harmony-js`, result: `Woop/${packageInfo.version}/@woop-js`,
id, id,
jsonrpc: '2.0', jsonrpc: '2.0',
}; };
} }
case 'hmy_getBlockByNumber': { case 'wiki_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: {
// hmy_getBlockByNumber // wiki_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', 'hmy'); newMethod = method.replace('eth', 'wiki');
} }
args[0].method = newMethod; args[0].method = newMethod;

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

@ -1,13 +1,13 @@
/** /**
* @packageDocumentation * @packageDocumentation
* @module harmony-core * @module woop-core
* @hidden * @hidden
*/ */
import { ChainType, ChainID, defaultConfig } from '@harmony-js/utils'; import { ChainType, ChainID, defaultConfig } from '@woop-js/utils';
import { Harmony } from './harmony'; import { Woop } from './woop';
export interface HarmonyConfig { export interface WoopConfig {
chainUrl?: string; chainUrl?: string;
chainType: ChainType; chainType: ChainType;
chainId: ChainID; chainId: ChainID;
@ -17,18 +17,18 @@ export interface HarmonyConfig {
// 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 harmony = new Harmony(url, { const woop = new Woop(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(harmony.messenger.provider); _web3.setProvider(woop.messenger.provider);
_web3.messenger = harmony.messenger; _web3.messenger = woop.messenger;
_web3.eth.getRpcResult = harmony.blockchain.getRpcResult; _web3.eth.getRpcResult = woop.blockchain.getRpcResult;
// map blockchain to eth // map blockchain to eth
const { blockchain } = harmony; const { blockchain } = woop;
_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 = harmony.messenger.subscribe; _web3.eth.subscribe = woop.messenger.subscribe;
// map accounts to _web3 // map accounts to _web3
_web3.accounts = harmony.wallet.accounts; _web3.accounts = woop.wallet.accounts;
_web3.eth.accounts.create = harmony.wallet.createAccount; _web3.eth.accounts.create = woop.wallet.createAccount;
_web3.eth.accounts.privateKeyToAccount = harmony.wallet.addByPrivateKey; _web3.eth.accounts.privateKeyToAccount = woop.wallet.addByPrivateKey;
_web3.eth.accounts.encrypt = async (privateKey: string, password: string) => { _web3.eth.accounts.encrypt = async (privateKey: string, password: string) => {
const newAcc = new harmony.Modules.Account(privateKey, harmony.messenger); const newAcc = new woop.Modules.Account(privateKey, woop.messenger);
const result = await newAcc.toFile(password); 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 harmony.Modules.Account(); const newAcc = new woop.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 = harmony.wallet.signTransaction; _web3.eth.accounts.signTransaction = woop.wallet.signTransaction;
// map transaction to web3 // map transaction to web3
_web3.eth.recoverTransaction = harmony.transactions.recover; _web3.eth.recoverTransaction = woop.transactions.recover;
// map contract to web3 // map contract to web3
_web3.eth.Contract = harmony.contracts.createContract; _web3.eth.Contract = woop.contracts.createContract;
_web3.utils = { ..._web3.utils, ...harmony.utils, ...harmony.crypto }; _web3.utils = { ..._web3.utils, ...woop.utils, ...woop.crypto };
} }

@ -1,20 +1,20 @@
/** /**
* @packageDocumentation * @packageDocumentation
* @module harmony-core * @module woop-core
*/ */
import * as crypto from '@harmony-js/crypto'; import * as crypto from '@woop-js/crypto';
import * as utils from '@harmony-js/utils'; import * as utils from '@woop-js/utils';
import { Provider, HttpProvider, Messenger, WSProvider, ShardingItem } from '@harmony-js/network'; import { Provider, HttpProvider, Messenger, WSProvider, ShardingItem } from '@woop-js/network';
import { TransactionFactory, Transaction } from '@harmony-js/transaction'; import { TransactionFactory, Transaction } from '@woop-js/transaction';
import { StakingTransaction, StakingFactory } from '@harmony-js/staking'; import { StakingTransaction, StakingFactory } from '@woop-js/staking';
import { ContractFactory, Contract } from '@harmony-js/contract'; import { ContractFactory, Contract } from '@woop-js/contract';
import { Wallet, Account } from '@harmony-js/account'; import { Wallet, Account } from '@woop-js/account';
import { Blockchain } from './blockchain'; import { Blockchain } from './blockchain';
import { HarmonyConfig } from './util'; import { WoopConfig } from './util';
export class Harmony extends utils.HarmonyCore { export class Woop extends utils.WoopCore {
/**@ignore*/ /**@ignore*/
Modules = { Modules = {
HttpProvider, HttpProvider,
@ -51,38 +51,38 @@ export class Harmony extends utils.HarmonyCore {
private provider: HttpProvider | WSProvider; private provider: HttpProvider | WSProvider;
/** /**
* Create a harmony instance * Create a woop instance
* *
* @param url The end-points of the hmy blockchain * @param url The end-points of the wiki blockchain
* @param config set up `ChainID` and `ChainType`, typically we can use the default values * @param config set up `ChainID` and `ChainType`, typically we can use the default values
* *
* @example * @example
* ``` * ```
* // import or require Harmony class * // import or require Woop class
* const { Harmony } = require('@harmony-js/core'); * const { Woop } = require('@woop-js/core');
* *
* // import or require settings * // import or require settings
* const { ChainID, ChainType } = require('@harmony-js/utils'); * const { ChainID, ChainType } = require('@woop-js/utils');
* *
* // Initialize the Harmony instance * // Initialize the Woop instance
* const hmy = new Harmony( * const wiki = new Woop(
* // 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 Harmony * // chainType set to Woop
* chainType: ChainType.Harmony, * chainType: ChainType.Woop,
* // chainType set to HmyLocal * // chainType set to WikiLocal
* chainId: ChainID.HmyLocal, * chainId: ChainID.WikiLocal,
* }, * },
* ); * );
* ``` * ```
*/ */
constructor( constructor(
url: string, url: string,
config: HarmonyConfig = { config: WoopConfig = {
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 Harmony extends utils.HarmonyCore {
* *
* @example * @example
* ```javascript * ```javascript
* const tmp = hmy.setProvider('http://localhost:9500'); * const tmp = wiki.setProvider('http://localhost:9500');
* ``` * ```
*/ */
public setProvider(provider: string | HttpProvider | WSProvider): void { public setProvider(provider: string | HttpProvider | WSProvider): void {
@ -139,16 +139,16 @@ export class Harmony extends utils.HarmonyCore {
EtcTestnet = 62, EtcTestnet = 62,
Geth = 1337, Geth = 1337,
Ganache = 0, Ganache = 0,
HmyMainnet = 1, WikiMainnet = 1,
HmyTestnet = 2, WikiTestnet = 2,
HmyLocal = 2, WikiLocal = 2,
HmyPangaea = 3 WikiPangaea = 3
* ``` * ```
* @param chainId * @param chainId
* *
* @example * @example
* ``` * ```
* hmy.setChainId(2); * wiki.setChainId(2);
* ``` * ```
*/ */
public setChainId(chainId: utils.ChainID) { public setChainId(chainId: utils.ChainID) {
@ -162,7 +162,7 @@ export class Harmony extends utils.HarmonyCore {
* *
* @example * @example
* ``` * ```
* hmy.setShardID(2); * wiki.setShardID(2);
* ``` * ```
*/ */
public setShardID(shardID: number) { public setShardID(shardID: number) {
@ -174,14 +174,14 @@ export class Harmony extends utils.HarmonyCore {
/** /**
* set the chainType * set the chainType
* *
* @param chainType `hmy` or `eth` * @param chainType `wiki` or `eth`
* *
* @example * @example
* ``` * ```
* // set chainType to hmy * // set chainType to wiki
* hmy.setChainType('hmy'); * wiki.setChainType('wiki');
* // set chainType to eth * // set chainType to eth
* hmy.setChainType('eth'); * wiki.setChainType('eth');
* ``` * ```
*/ */
public setChainType(chainType: utils.ChainType) { public setChainType(chainType: utils.ChainType) {
@ -197,7 +197,7 @@ export class Harmony extends utils.HarmonyCore {
* *
* @example * @example
* ```javascript * ```javascript
* hmy.shardingStructures([ * wiki.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 harmony-core * @module woop-core
*/ */
import { import {
@ -10,15 +10,15 @@ import {
Provider, Provider,
RPCMethod, RPCMethod,
ShardingItem, ShardingItem,
} from '@harmony-js/network'; } from '@woop-js/network';
import * as crypto from '@harmony-js/crypto'; import * as crypto from '@woop-js/crypto';
import * as utils from '@harmony-js/utils'; import * as utils from '@woop-js/utils';
import { Transaction, TransactionFactory } from '@harmony-js/transaction'; import { Transaction, TransactionFactory } from '@woop-js/transaction';
import { Blockchain } from './blockchain'; import { Blockchain } from './blockchain';
import { ContractFactory } from '@harmony-js/contract'; import { ContractFactory } from '@woop-js/contract';
import { HarmonyConfig } from './util'; import { WoopConfig } from './util';
/** @hidden */ /** @hidden */
export enum ExtensionType { export enum ExtensionType {
@ -55,7 +55,7 @@ export interface ExtensionInterface {
network: ExtensionNetwork; network: ExtensionNetwork;
} }
export class HarmonyExtension { export class WoopExtension {
/**@ignore*/ /**@ignore*/
extensionType: ExtensionType | null; extensionType: ExtensionType | null;
/**@ignore*/ /**@ignore*/
@ -87,17 +87,17 @@ export class HarmonyExtension {
* ```javascript * ```javascript
* // Using Mathwallet instance * // Using Mathwallet instance
* export const initEx = async() => { * export const initEx = async() => {
* hmyEx = new HarmonyExtension(window.harmony); * wikiEx = new WoopExtension(window.woop);
* } * }
* // Using OneWallet instance * // Using OneWallet instance
* export const initEx = async() => { * export const initEx = async() => {
* hmyEx = new HarmonyExtension(window.onewallet); * wikiEx = new WoopExtension(window.onewallet);
* } * }
* ``` * ```
*/ */
constructor( constructor(
wallet: ExtensionInterface, wallet: ExtensionInterface,
config: HarmonyConfig = { config: WoopConfig = {
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 HarmonyExtension {
* *
* @example * @example
* ```javascript * ```javascript
* const tmp = hmyEx.setProvider('http://localhost:9500'); * const tmp = wikiEx.setProvider('http://localhost:9500');
* ``` * ```
*/ */
public setProvider(provider: string | HttpProvider | WSProvider): void { public setProvider(provider: string | HttpProvider | WSProvider): void {
@ -143,7 +143,7 @@ export class HarmonyExtension {
* *
* @example * @example
* ``` * ```
* hmyEx.setShardID(2); * wikiEx.setShardID(2);
* ``` * ```
*/ */
public setShardID(shardID: number) { public setShardID(shardID: number) {
@ -205,7 +205,7 @@ export class HarmonyExtension {
* *
* @example * @example
* ```javascript * ```javascript
* const account = hmyEx.login(); * const account = wikiEx.login();
* console.log(account); * console.log(account);
* ``` * ```
*/ */
@ -220,7 +220,7 @@ export class HarmonyExtension {
* *
* @example * @example
* ```javascript * ```javascript
* hmyEx.logout(); * wikiEx.logout();
* ``` * ```
*/ */
public async logout() { public async logout() {
@ -234,7 +234,7 @@ export class HarmonyExtension {
* *
* @example * @example
* ```javascript * ```javascript
* hmyEx.shardingStructures([ * wikiEx.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",

@ -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 '@harmony-js/network'; import { HttpProvider, Messenger } from '@woop-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", "../woop-utils/src/core.ts"],
"references": [
{"path": "../woop-account"},
{"path": "../woop-crypto"},
{"path": "../woop-utils"},
{"path": "../woop-network"},
{"path": "../woop-transaction"},
{"path": "../woop-contract"}
]
}

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

@ -1,15 +1,15 @@
{ {
"name": "@harmony-js/crypto", "name": "@woop-js/crypto",
"version": "0.1.58", "version": "0.1.58",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@harmony-js/crypto", "name": "@woop-js/crypto",
"version": "0.1.56", "version": "0.1.56",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@harmony-js/utils": "0.1.56", "@woop-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/@harmony-js/utils": { "node_modules/@woop-js/utils": {
"version": "0.1.56", "version": "0.1.56",
"resolved": "https://registry.npmjs.org/@harmony-js/utils/-/utils-0.1.56.tgz", "resolved": "https://registry.npmjs.org/@woop-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": {
"@harmony-js/utils": { "@woop-js/utils": {
"version": "0.1.56", "version": "0.1.56",
"resolved": "https://registry.npmjs.org/@harmony-js/utils/-/utils-0.1.56.tgz", "resolved": "https://registry.npmjs.org/@woop-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": "@harmony-js/crypto", "name": "@woop-js/crypto",
"version": "0.1.58", "version": "0.1.58",
"description": "crypto libraries for harmony", "description": "crypto libraries for woop",
"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": {
"@harmony-js/utils": "0.1.58", "@woop-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 harmony-crypto * @module woop-crypto
*/ */
import { isAddress, isBech32Address, isBech32TestNetAddress } from '@harmony-js/utils'; import { isAddress, isBech32Address, isBech32TestNetAddress } from '@woop-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 { HarmonyAddress } = require('@harmony-js/crypto'); * const { WoopAddress } = require('@woop-js/crypto');
* *
* // Step 2: call functions * // Step 2: call functions
* const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7' * const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7'
* const res = HarmonyAddress.isValidBech32(addr); * const res = WoopAddress.isValidBech32(addr);
* console.log(res); * console.log(res);
* ``` * ```
*/ */
export class HarmonyAddress { export class WoopAddress {
/** /**
* @example * @example
* ``` * ```
* const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7' * const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7'
* const res = HarmonyAddress.isValidBech32(addr); * const res = WoopAddress.isValidBech32(addr);
* console.log(res); * console.log(res);
* ``` * ```
*/ */
static isValidBasic(str: string) { static isValidBasic(str: string) {
const toTest = new HarmonyAddress(str); const toTest = new WoopAddress(str);
return toTest.raw === toTest.basic; return toTest.raw === toTest.basic;
} }
@ -39,12 +39,12 @@ export class HarmonyAddress {
* @example * @example
* ``` * ```
* const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7' * const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7'
* const res = HarmonyAddress.isValidChecksum(addr); * const res = WoopAddress.isValidChecksum(addr);
* console.log(res); * console.log(res);
* ``` * ```
*/ */
static isValidChecksum(str: string) { static isValidChecksum(str: string) {
const toTest = new HarmonyAddress(str); const toTest = new WoopAddress(str);
return toTest.raw === toTest.checksum; return toTest.raw === toTest.checksum;
} }
@ -52,12 +52,12 @@ export class HarmonyAddress {
* @example * @example
* ``` * ```
* const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7' * const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7'
* const res = HarmonyAddress.isValidBech32(addr); * const res = WoopAddress.isValidBech32(addr);
* console.log(res); * console.log(res);
* ``` * ```
*/ */
static isValidBech32(str: string) { static isValidBech32(str: string) {
const toTest = new HarmonyAddress(str); const toTest = new WoopAddress(str);
return toTest.raw === toTest.bech32; return toTest.raw === toTest.bech32;
} }
@ -65,12 +65,12 @@ export class HarmonyAddress {
* @example * @example
* ``` * ```
* const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7' * const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7'
* const res = HarmonyAddress.isValidBech32TestNet(addr); * const res = WoopAddress.isValidBech32TestNet(addr);
* console.log(res); * console.log(res);
* ``` * ```
*/ */
static isValidBech32TestNet(str: string) { static isValidBech32TestNet(str: string) {
const toTest = new HarmonyAddress(str); const toTest = new WoopAddress(str);
return toTest.raw === toTest.bech32TestNet; return toTest.raw === toTest.bech32TestNet;
} }
@ -83,7 +83,7 @@ export class HarmonyAddress {
* @example * @example
* ``` * ```
* const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7' * const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7'
* const instance = new HarmonyAddress(addr); * const instance = new WoopAddress(addr);
* console.log(instance.basicHex); * console.log(instance.basicHex);
* ``` * ```
*/ */
@ -95,7 +95,7 @@ export class HarmonyAddress {
* @example * @example
* ``` * ```
* const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7' * const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7'
* const instance = new HarmonyAddress(addr); * const instance = new WoopAddress(addr);
* console.log(instance.checksum); * console.log(instance.checksum);
* ``` * ```
*/ */
@ -107,7 +107,7 @@ export class HarmonyAddress {
* @example * @example
* ``` * ```
* const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7' * const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7'
* const instance = new HarmonyAddress(addr); * const instance = new WoopAddress(addr);
* console.log(instance.bech32); * console.log(instance.bech32);
* ``` * ```
*/ */
@ -119,7 +119,7 @@ export class HarmonyAddress {
* @example * @example
* ``` * ```
* const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7' * const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7'
* const instance = new HarmonyAddress(addr); * const instance = new WoopAddress(addr);
* console.log(instance.bech32TestNet); * console.log(instance.bech32TestNet);
* ``` * ```
*/ */
@ -140,7 +140,7 @@ export class HarmonyAddress {
* @example * @example
* ``` * ```
* const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7' * const addr = 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7'
* const instance = new HarmonyAddress(addr); * const instance = new WoopAddress(addr);
* const res = instance.getBasic(addr); * const res = instance.getBasic(addr);
* console.log(res) * console.log(res)
* ``` * ```
@ -169,32 +169,32 @@ export class HarmonyAddress {
} }
/** /**
* Using this function to get Harmony format address * Using this function to get Woop format address
* *
* @param address * @param address
* *
* @example * @example
* ```javascript * ```javascript
* const { Harmony } = require('@harmony-js/core'); * const { Woop } = require('@woop-js/core');
* const { ChainID, ChainType } = require('@harmony-js/utils'); * const { ChainID, ChainType } = require('@woop-js/utils');
* const { randomBytes } = require('@harmony-js/crypto') * const { randomBytes } = require('@woop-js/crypto')
* *
* const hmy = new Harmony( * const wiki = new Woop(
* 'http://localhost:9500', * 'http://localhost:9500',
* { * {
* chainType: ChainType.Harmony, * chainType: ChainType.Woop,
* chainId: ChainID.HmyLocal, * chainId: ChainID.WikiLocal,
* }, * },
* ); * );
* *
* const bytes = randomBytes(20); * const bytes = randomBytes(20);
* const hAddress = hmy.crypto.getAddress(bytes); * const hAddress = wiki.crypto.getAddress(bytes);
* console.log(hAddress) * console.log(hAddress)
* ``` * ```
*/ */
export function getAddress(address: string) { export function getAddress(address: string) {
try { try {
return new HarmonyAddress(address); return new WoopAddress(address);
} catch (error) { } catch (error) {
throw error; throw error;
} }

@ -1,10 +1,10 @@
/** /**
* @packageDocumentation * @packageDocumentation
* @module harmony-crypto * @module woop-crypto
* @hidden * @hidden
*/ */
import { isAddress } from '@harmony-js/utils'; import { isAddress } from '@woop-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 Harmony bech32 addresses // HRP is the human-readable part of Woop 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 Harmony * bech32Encodes a canonical 20-byte Ethereum-style address as a bech32 Woop
* 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 Harmony address * @returns {string} 38 char bech32 bech32Encoded Woop 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 Harmony bech32 address * @param {string} address - a valid Woop 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 harmony-crypto * @module woop-crypto
* @hidden * @hidden
*/ */

@ -1,12 +1,12 @@
/** /**
# @harmony-js/crypto # @woop-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 @harmony-js/crypto npm install @woop-js/crypto
``` ```
## Usage ## Usage
@ -18,26 +18,26 @@ npm install @harmony-js/crypto
* randomBytes, * randomBytes,
* toBech32, * toBech32,
* fromBech32, * fromBech32,
* HarmonyAddress, * WoopAddress,
* generatePrivateKey, * generatePrivateKey,
* getPubkeyFromPrivateKey, * getPubkeyFromPrivateKey,
* getAddressFromPublicKey, * getAddressFromPublicKey,
* getAddressFromPrivateKey, * getAddressFromPrivateKey,
* encryptPhrase, * encryptPhrase,
* decryptPhrase * decryptPhrase
* } = require('@harmony-js/crypto'); * } = require('@woop-js/crypto');
* const { isPrivateKey, isAddress, isPublicKey } = require('@harmony-js/utils'); * const { isPrivateKey, isAddress, isPublicKey } = require('@woop-js/utils');
``` ```
Address apis Address apis
```javascript ```javascript
const bytes = randomBytes(20); const bytes = randomBytes(20);
const addr = new HarmonyAddress(bytes); const addr = new WoopAddress(bytes);
console.log(addr.checksum); console.log(addr.checksum);
console.log(addr.bech32); console.log(addr.bech32);
console.log(HarmonyAddress.isValidBech32(addr.bech32)); console.log(WoopAddress.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('@harmony-js/account'); * const { Wallet } = require('@woop-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 harmony-crypto * @module woop-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 harmony-crypto * @module woop-crypto
* @ignore * @ignore
*/ */

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

@ -1,6 +1,6 @@
/** /**
* @packageDocumentation * @packageDocumentation
* @module harmony-crypto * @module woop-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 '@harmony-js/utils'; import { isPrivateKey, strip0x, isAddress, isBech32Address } from '@woop-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 harmony-crypto * @module woop-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 '@harmony-js/utils'; import { isPrivateKey } from '@woop-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 harmony-crypto * @module woop-crypto
*/ */
/** /**

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

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

@ -3,7 +3,7 @@
* @ignore * @ignore
*/ */
import { getAddress, HarmonyAddress } from '../src/address'; import { getAddress, WoopAddress } 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 HarmonyAddress(bytes); const hAddress = new WoopAddress(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(HarmonyAddress.isValidBasic(bytes)).toEqual(true); expect(WoopAddress.isValidBasic(bytes)).toEqual(true);
expect(HarmonyAddress.isValidChecksum(checksum)).toEqual(true); expect(WoopAddress.isValidChecksum(checksum)).toEqual(true);
expect(HarmonyAddress.isValidBech32(bech32)).toEqual(true); expect(WoopAddress.isValidBech32(bech32)).toEqual(true);
expect(HarmonyAddress.isValidBech32TestNet(bech32Testnet)).toEqual(true); expect(WoopAddress.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 '@harmony-js/utils'; import { isPrivateKey, isAddress, isPublicKey } from '@woop-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": "../harmony-utils"}] "references": [{"path": "../woop-utils"}]
} }

@ -1,24 +1,24 @@
# @harmony-js/network # @woop-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 @harmony-js/network npm install @woop-js/network
``` ```
## Usage ## Usage
```javascript ```javascript
const { Messenger, HttpProvider, WSProvider } = require('@harmony-js/network'); const { Messenger, HttpProvider, WSProvider } = require('@woop-js/network');
const { ChainID, ChainType } = require('@harmony-js/utils'); const { ChainID, ChainType } = require('@woop-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.Harmony, ChainID.HmyTestnet); // for local ChainID.HmyLocal const customHTTPMessenger = new Messenger(http, ChainType.Woop, ChainID.WikiTestnet); // for local ChainID.WikiLocal
const customWSMessenger = new Messenger(ws, ChainType.Harmony, ChainID.HmyTestnet); // for local ChainID.HmyLocal const customWSMessenger = new Messenger(ws, ChainType.Woop, ChainID.WikiTestnet); // for local ChainID.WikiLocal
``` ```

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

Loading…
Cancel
Save