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)
[![Build Status](https://travis-ci.com/FireStack-Lab/Harmony-sdk-core.svg?branch=master)](https://travis-ci.com/FireStack-Lab/Harmony-sdk-core)
[![npm version](https://img.shields.io/npm/v/@woop-js/core.svg?style=flat-square)](https://www.npmjs.com/package/@woop-js/core)
[![Build Status](https://travis-ci.com/FireStack-Lab/Woop-sdk-core.svg?branch=master)](https://travis-ci.com/FireStack-Lab/Woop-sdk-core)
This is the Harmony Javascript 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.
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)
2. [@harmony-js/account](https://github.com/harmony-one/sdk/tree/master/packages/harmony-account)
3. [@harmony-js/crypto](https://github.com/harmony-one/sdk/tree/master/packages/harmony-crypto)
4. [@harmony-js/network](https://github.com/harmony-one/sdk/tree/master/packages/harmony-network)
5. [@harmony-js/utils](https://github.com/harmony-one/sdk/tree/master/packages/harmony-utils)
6. [@harmony-js/transaction](https://github.com/harmony-one/sdk/tree/master/packages/harmony-transaction)
7. [@harmony-js/contract](https://github.com/harmony-one/sdk/tree/master/packages/harmony-contract)
8. [@harmony-js/staking](https://github.com/harmony-one/sdk/tree/master/packages/harmony-staking)
# 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!
1. [@woop-js/core](https://github.com/woop-chain/sdk/tree/master/packages/woop-core)
2. [@woop-js/account](https://github.com/woop-chain/sdk/tree/master/packages/woop-account)
3. [@woop-js/crypto](https://github.com/woop-chain/sdk/tree/master/packages/woop-crypto)
4. [@woop-js/network](https://github.com/woop-chain/sdk/tree/master/packages/woop-network)
5. [@woop-js/utils](https://github.com/woop-chain/sdk/tree/master/packages/woop-utils)
6. [@woop-js/transaction](https://github.com/woop-chain/sdk/tree/master/packages/woop-transaction)
7. [@woop-js/contract](https://github.com/woop-chain/sdk/tree/master/packages/woop-contract)
8. [@woop-js/staking](https://github.com/woop-chain/sdk/tree/master/packages/woop-staking)
# Installation
@ -52,10 +35,10 @@ This library works on both nodejs and browser. Please use it according to your u
```bash
# npm
npm install @harmony-js/core@next
npm install @woop-js/core@next
# yarn
yarn add @harmony-js/core@next
yarn add @woop-js/core@next
# tslib is required, we'd better install it as well
npm install tslib
@ -94,7 +77,7 @@ yarn test:src
## e2e tests
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:
```bash
yarn build && yarn test:e2e

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

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

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

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

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

@ -1,31 +1,31 @@
import fetch from 'jest-fetch-mock';
// 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
import { ChainType } from '@harmony-js/utils';
import { ChainType } from '@woop-js/utils';
// 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_TYPE: string = 'hmy';
const CHAIN_TYPE: string = 'wiki';
const HTTP_PROVIDER: string = 'http://localhost:9500';
const GENESIS_PRIV_KEY: string = '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e';
let chainType: ChainType = ChainType.Harmony;
let chainType: ChainType = ChainType.Woop;
if (CHAIN_TYPE === 'hmy') {
chainType = ChainType.Harmony;
if (CHAIN_TYPE === 'wiki') {
chainType = ChainType.Woop;
} else if (CHAIN_TYPE === 'eth') {
chainType = ChainType.Ethereum;
}
export const harmony: Harmony = new Harmony(HTTP_PROVIDER, {
export const woop: Woop = new Woop(HTTP_PROVIDER, {
chainId: CHAIN_ID,
chainType,
chainUrl: HTTP_PROVIDER,
});
export const myAccount: Account = harmony.wallet.addByPrivateKey(
export const myAccount: Account = woop.wallet.addByPrivateKey(
GENESIS_PRIV_KEY,
);

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

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

288
package-lock.json generated

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

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

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

@ -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.
## Installation
```
npm install @harmony-js/account
npm install @woop-js/account
```
## Usage
@ -29,8 +29,8 @@ Creating account using private key and custom messenger
* '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e',
* new Messenger(
* new HttpProvider('https://api.s0.b.hmny.io'),
* ChainType.Harmony,
* ChainID.HmyTestnet,
* ChainType.Woop,
* ChainID.WikiTestnet,
* ),
* );
```
@ -41,8 +41,8 @@ Creating account and setting custom messenger
* const account = new Account();
* const customMessenger = new Messenger(
* new HttpProvider('https://api.s0.b.hmny.io'),
* ChainType.Harmony,
* ChainID.HmyTestnet,
* ChainType.Woop,
* ChainID.WikiTestnet,
* );
account.setMessenger(customMessenger);
@ -73,8 +73,8 @@ Get the account balance
* '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e',
* new Messenger(
* new HttpProvider('https://api.s0.b.hmny.io'),
* ChainType.Harmony,
* ChainID.HmyTestnet,
* ChainType.Woop,
* ChainID.WikiTestnet,
* ),
* );
* account.getBalance().then(response => {
@ -89,12 +89,12 @@ Create a transaction and account, and sign it
* '45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e',
* new Messenger(
* new HttpProvider('https://api.s0.b.hmny.io'),
* ChainType.Harmony,
* ChainID.HmyTestnet,
* ChainType.Woop,
* ChainID.WikiTestnet,
* ),
* );
* const { TransactionFactory } = require('@harmony-js/transaction');
* const { Unit } = require('@harmony-js/utils');
* const { TransactionFactory } = require('@woop-js/transaction');
* const { Unit } = require('@woop-js/utils');
* const factory = new TransactionFactory();
* const txn = factory.newTx({
@ -121,7 +121,7 @@ A wallet represents user wallet that can hold one or more user accounts.
Creating an empty wallet
```javascript
* const { Wallet } = require('@harmony-js/account')
* const { Wallet } = require('@woop-js/account')
* const wallet = new Wallet();
```
@ -130,8 +130,8 @@ Setting a messenger to be used to send wallet transactions
* wallet.setMessenger(
* new Messenger(
* new HttpProvider('https://api.s0.b.hmny.io'),
* ChainType.Harmony,
* ChainID.HmyTestnet,
* ChainType.Woop,
* ChainID.WikiTestnet,
* ),
* );
```
@ -141,8 +141,8 @@ Create an empty wallet with messenger
* const wallet = new Wallet(
* new Messenger(
* new HttpProvider('https://api.s0.b.hmny.io'),
* ChainType.Harmony,
* ChainID.HmyTestnet,
* ChainType.Woop,
* ChainID.WikiTestnet,
* ),
* );
```
@ -169,7 +169,7 @@ Adding account using keystore file
Creating a new account using passphrase
```javascript
* const passphrase = 'harmony-one';
* const passphrase = 'woop-chain';
* wallet.createAccount(passphrase).then(account => {
* 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.
*
* @packageDocumentation
* @module harmony-account
* @module woop-account
*/
/**@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
* @module harmony-account
* @module woop-account
*
*/
@ -15,7 +15,7 @@ import {
Keystore,
Signature,
getAddress,
} from '@harmony-js/crypto';
} from '@woop-js/crypto';
import {
isPrivateKey,
@ -23,10 +23,10 @@ import {
hexToNumber,
AddressSuffix,
ChainType,
} from '@harmony-js/utils';
import { Transaction, RLPSign } from '@harmony-js/transaction';
import { StakingTransaction } from '@harmony-js/staking';
import { Messenger, RPCMethod } from '@harmony-js/network';
} from '@woop-js/utils';
import { Transaction, RLPSign } from '@woop-js/transaction';
import { StakingTransaction } from '@woop-js/staking';
import { Messenger, RPCMethod } from '@woop-js/network';
import { Shards } from './types';
import { defaultMessenger } from './utils';
@ -141,18 +141,18 @@ class Account {
* @example
* ```javascript
* // import the Account class
* const { Account } = require('@harmony-js/account');
* const { Account } = require('@woop-js/account');
*
* // Messenger is optional, by default, we have a defaultMessenger
* // If you like to change, you will import related package here.
* const { HttpProvider, Messenger } = require('@harmony-js/network');
* const { ChainType, ChainID } = require('@harmony-js/utils');
* const { HttpProvider, Messenger } = require('@woop-js/network');
* const { ChainType, ChainID } = require('@woop-js/utils');
*
* // create a custom messenger
* const customMessenger = new Messenger(
* new HttpProvider('http://localhost:9500'),
* ChainType.Harmony, // if you are connected to Harmony's blockchain
* ChainID.HmyLocal, // check if the chainId is correct
* ChainType.Woop, // if you are connected to Woop's blockchain
* ChainID.WikiLocal, // check if the chainId is correct
* )
*
* // setMessenger later
@ -306,7 +306,7 @@ class Account {
transaction.setParams({
...transaction.txParams,
from:
this.messenger.chainPrefix === ChainType.Harmony
this.messenger.chainPrefix === ChainType.Woop
? this.bech32Address
: this.checksumAddress || '0x',
nonce: shardNonce,
@ -324,7 +324,7 @@ class Account {
signature,
rawTransaction,
from:
this.messenger.chainPrefix === ChainType.Harmony
this.messenger.chainPrefix === ChainType.Woop
? this.bech32Address
: this.checksumAddress || '0x',
};
@ -363,7 +363,7 @@ class Account {
blockNumber,
);
staking.setFromAddress(
this.messenger.chainPrefix === ChainType.Harmony
this.messenger.chainPrefix === ChainType.Woop
? this.bech32Address
: this.checksumAddress || '0x',
);
@ -375,7 +375,7 @@ class Account {
staking.setRawTransaction(rawTransaction);
staking.setSignature(signature);
staking.setFromAddress(
this.messenger.chainPrefix === ChainType.Harmony
this.messenger.chainPrefix === ChainType.Woop
? this.bech32Address
: this.checksumAddress || '0x',
);
@ -395,8 +395,8 @@ class Account {
* // create a custom messenger
* const customMessenger = new Messenger(
* new HttpProvider('http://localhost:9500'),
* ChainType.Harmony, // if you are connected to Harmony's blockchain
* ChainID.HmyLocal, // check if the chainId is correct
* ChainType.Woop, // if you are connected to Woop's blockchain
* ChainID.WikiLocal, // check if the chainId is correct
* )
*
* // to create an Account with random privateKey

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

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

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

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

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

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

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

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

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

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

@ -1,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
```
npm install @harmony-js/contract
npm install @woop-js/contract
```
## Usage
Deploying a contract using `contractConstructor`
```javascript
const { ContractFactory } = require('@harmony-js/contract');
const { Wallet } = require('@harmony-js/account');
const { Messenger, HttpProvider } = require('@harmony-js/network');
const { ChainID, ChainType, hexToNumber } = require('@harmony-js/utils');
const { ContractFactory } = require('@woop-js/contract');
const { Wallet } = require('@woop-js/account');
const { Messenger, HttpProvider } = require('@woop-js/network');
const { ChainID, ChainType, hexToNumber } = require('@woop-js/utils');
* const wallet = new Wallet(
* new Messenger(
* new HttpProvider('https://api.s0.b.hmny.io'),
* ChainType.Harmony,
* ChainID.HmyTestnet,
* ChainType.Woop,
* ChainID.WikiTestnet,
* ),
* );
* const factory = new ContractFactory(wallet);
@ -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
```javascript
* const { Harmony } = require("@harmony-js/core");
* const { ChainID, ChainType } = require("@harmony-js/utils");
* const hmy = new Harmony("https://api.s0.b.hmny.io", {
* chainType: ChainType.Harmony,
* chainId: ChainID.HmyTestnet,
* const { Woop } = require("@woop-js/core");
* const { ChainID, ChainType } = require("@woop-js/utils");
* const wiki = new Woop("https://api.s0.b.hmny.io", {
* chainType: ChainType.Woop,
* chainId: ChainID.WikiTestnet,
* });
const contractJson = require("./Counter.json");
const contractAddr = "0x19f64050e6b2d376e52AC426E366c49EEb0724B1";
const contract = hmy.contracts.createContract(contractJson.abi, contractAddr);
const contract = wiki.contracts.createContract(contractJson.abi, contractAddr);
console.log(contract.methods);
```
Directly loading contract using `ContractFactory`
```javascript
const { ContractFactory } = require('@harmony-js/contract');
const { Wallet } = require('@harmony-js/account');
const { Messenger, HttpProvider } = require('@harmony-js/network');
const { ChainID, ChainType, hexToNumber } = require('@harmony-js/utils');
const { ContractFactory } = require('@woop-js/contract');
const { Wallet } = require('@woop-js/account');
const { Messenger, HttpProvider } = require('@woop-js/network');
const { ChainID, ChainType, hexToNumber } = require('@woop-js/utils');
* const wallet = new Wallet(new Messenger(
* new HttpProvider('https://api.s0.b.hmny.io'),
* ChainType.Harmony,
* ChainID.HmyTestnet,
* ChainType.Woop,
* ChainID.WikiTestnet,
* ));
const factory = new ContractFactory(wallet);
const contract = factory.createContract(contractJson.abi, contractAddr);
@ -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
* 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
@ -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.
```javascript
* const { ContractFactory } = require('@harmony-js/contract');
* const { Wallet } = require('@harmony-js/account');
* const { Messenger, WSProvider } = require('@harmony-js/network');
* const { ChainID, ChainType, hexToNumber } = require('@harmony-js/utils');
* const { ContractFactory } = require('@woop-js/contract');
* const { Wallet } = require('@woop-js/account');
* const { Messenger, WSProvider } = require('@woop-js/network');
* const { ChainID, ChainType, hexToNumber } = require('@woop-js/utils');
* const ws = new WSProvider('wss://ws.s0.b.hmny.io');
* const wallet = new Wallet(
* new Messenger(
* ws,
* ChainType.Harmony,
* ChainID.HmyTestnet,
* ChainType.Woop,
* ChainID.WikiTestnet,
* ),
* );
* const factory = new ContractFactory(wallet);
@ -148,7 +148,7 @@ Subscribing to the contract events requires web socket based messenger.
```
*
* @packageDocumentation
* @module harmony-contract
* @module woop-contract
*/
// this file is mainly ported from `ethers.js`, but done some fixes
@ -171,8 +171,8 @@ import {
Arrayish,
checkNew,
bytesPadRight,
} from '@harmony-js/crypto';
import { hexToBN, defineReadOnly } from '@harmony-js/utils';
} from '@woop-js/crypto';
import { hexToBN, defineReadOnly } from '@woop-js/utils';
/** @hidden */
const NegativeOne: BN = new BN(-1);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -1,15 +1,15 @@
{
"name": "@harmony-js/crypto",
"name": "@woop-js/crypto",
"version": "0.1.58",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@harmony-js/crypto",
"name": "@woop-js/crypto",
"version": "0.1.56",
"license": "MIT",
"dependencies": {
"@harmony-js/utils": "0.1.56",
"@woop-js/utils": "0.1.56",
"aes-js": "^3.1.2",
"bip39": "^2.5.0",
"bn.js": "^4.11.8",
@ -22,9 +22,9 @@
"uuid": "^3.3.2"
}
},
"node_modules/@harmony-js/utils": {
"node_modules/@woop-js/utils": {
"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==",
"dependencies": {
"@types/bn.js": "^4.11.3",
@ -415,9 +415,9 @@
}
},
"dependencies": {
"@harmony-js/utils": {
"@woop-js/utils": {
"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==",
"requires": {
"@types/bn.js": "^4.11.3",

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

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

@ -1,10 +1,10 @@
/**
* @packageDocumentation
* @module harmony-crypto
* @module woop-crypto
* @hidden
*/
import { isAddress } from '@harmony-js/utils';
import { isAddress } from '@woop-js/utils';
import { toChecksumAddress } from './keyTool';
// 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)) };
};
// 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 tHRP = 'tone';
@ -184,14 +184,14 @@ export const convertBits = (
/**
* 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.
*
* The expected format is one1<address><checksum> where address and checksum
* are the result of bech32 encoding a Buffer containing the address bytes.
*
* @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 => {
if (!isAddress(address)) {
@ -210,7 +210,7 @@ export const toBech32 = (address: string, useHRP: string = HRP): string => {
/**
* 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
*/
export const fromBech32 = (address: string, useHRP: string = HRP): string => {

@ -1,6 +1,6 @@
/**
* @packageDocumentation
* @module harmony-crypto
* @module woop-crypto
* @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.
## Installation
```
npm install @harmony-js/crypto
npm install @woop-js/crypto
```
## Usage
@ -18,26 +18,26 @@ npm install @harmony-js/crypto
* randomBytes,
* toBech32,
* fromBech32,
* HarmonyAddress,
* WoopAddress,
* generatePrivateKey,
* getPubkeyFromPrivateKey,
* getAddressFromPublicKey,
* getAddressFromPrivateKey,
* encryptPhrase,
* decryptPhrase
* } = require('@harmony-js/crypto');
* const { isPrivateKey, isAddress, isPublicKey } = require('@harmony-js/utils');
* } = require('@woop-js/crypto');
* const { isPrivateKey, isAddress, isPublicKey } = require('@woop-js/utils');
```
Address apis
```javascript
const bytes = randomBytes(20);
const addr = new HarmonyAddress(bytes);
const addr = new WoopAddress(bytes);
console.log(addr.checksum);
console.log(addr.bech32);
console.log(HarmonyAddress.isValidBech32(addr.bech32));
console.log(WoopAddress.isValidBech32(addr.bech32));
```
RLP apis
@ -62,7 +62,7 @@ console.log(isAddress(addrPrv));
Encrypt/decrypt apis
```javascript
* const { Wallet } = require('@harmony-js/account');
* const { Wallet } = require('@woop-js/account');
* const myPhrase = new Wallet().newMnemonic();
* console.log(myPhrase);
@ -76,7 +76,7 @@ Encrypt/decrypt apis
```
*
* @packageDocumentation
* @module harmony-crypto
* @module woop-crypto
*/
// This file is ported from ether.js/src.ts/errors.ts

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

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

@ -1,6 +1,6 @@
/**
* @packageDocumentation
* @module harmony-crypto
* @module woop-crypto
*/
import elliptic from 'elliptic';
@ -9,7 +9,7 @@ import * as errors from './errors';
import { keccak256 } from './keccak256';
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 { encode } from './rlp';

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

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

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

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

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

@ -4,7 +4,7 @@
*/
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', () => {
it('test keygen', () => {

@ -5,5 +5,5 @@
"outDir": "dist"
},
"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.
## Installation
```
npm install @harmony-js/network
npm install @woop-js/network
```
## Usage
```javascript
const { Messenger, HttpProvider, WSProvider } = require('@harmony-js/network');
const { ChainID, ChainType } = require('@harmony-js/utils');
const { Messenger, HttpProvider, WSProvider } = require('@woop-js/network');
const { ChainID, ChainType } = require('@woop-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
const customHTTPMessenger = new Messenger(http, ChainType.Woop, ChainID.WikiTestnet); // for local ChainID.WikiLocal
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