From 18da2be63dd541a635d7b5f5dc749fb513219681 Mon Sep 17 00:00:00 2001 From: nico Date: Wed, 20 Mar 2024 15:03:56 -0500 Subject: [PATCH] woop --- README.md | 47 +-- RELEASE.md | 4 +- TYPEDOC.md | 12 +- e2e/src/blockchain.e2e.ts | 68 ++--- e2e/src/transaction.e2e.ts | 84 ++--- e2e/src/txn_rpc.e2e.ts | 152 ++++----- e2e/src/{harmony.ts => woop.ts} | 18 +- e2e/tsconfig.json | 12 +- gulpfile.js | 16 +- package-lock.json | 288 +++++++++--------- package.json | 6 +- packages/README.md | 16 +- packages/harmony-account/src/utils.ts | 14 - packages/harmony-core/package.json | 30 -- packages/harmony-core/src/types.ts | 31 -- packages/harmony-core/tsconfig.json | 16 - packages/harmony-network/src/rpcMethod/rpc.ts | 136 --------- .../{harmony-account => woop-account}/LICENSE | 0 .../README.md | 36 +-- .../guide.ts | 38 +-- packages/woop-account/package.json | 29 ++ .../src/account.ts | 34 +-- .../src/hdnode.ts | 16 +- .../src/index.ts | 2 +- .../src/types.ts | 2 +- packages/woop-account/src/utils.ts | 14 + .../src/wallet.ts | 30 +- .../test/testAccount.test.ts | 8 +- .../tsconfig.json | 10 +- .../tsconfig.test.json | 0 .../Counter.json | 8 +- .../LICENSE | 0 .../README.md | 56 ++-- .../package.json | 14 +- .../src/abi/abiCoder.ts | 62 ++-- .../src/abi/api.ts | 6 +- .../src/abi/index.ts | 2 +- .../src/abi/utils.ts | 6 +- .../src/contract.ts | 8 +- .../src/contractFactory.ts | 4 +- .../src/events/event.ts | 4 +- .../src/events/eventFactory.ts | 4 +- .../src/index.ts | 2 +- .../src/methods/method.ts | 12 +- .../src/methods/methodFactory.ts | 2 +- .../src/models/AbiItemModel.ts | 4 +- .../src/models/AbiModel.ts | 2 +- .../src/models/types.ts | 2 +- .../src/utils/decoder.ts | 2 +- .../src/utils/encoder.ts | 4 +- .../src/utils/formatter.ts | 6 +- .../src/utils/mapper.ts | 4 +- .../src/utils/options.ts | 2 +- .../src/utils/status.ts | 2 +- .../test/abiCoder.test.ts | 4 +- .../test/fixtures/abiv2.ts | 0 .../tsconfig.json | 10 +- .../tsconfig.test.json | 0 packages/{harmony-core => woop-core}/LICENSE | 0 .../{harmony-core => woop-core}/README.md | 48 +-- .../package.json | 17 +- .../src/blockchain.ts | 186 +++++------ .../{harmony-core => woop-core}/src/index.ts | 6 +- .../src/truffleProvider.ts | 34 +-- packages/woop-core/src/types.ts | 31 ++ .../{harmony-core => woop-core}/src/util.ts | 38 +-- .../src/harmony.ts => woop-core/src/woop.ts} | 68 ++--- .../src/woopExtension.ts} | 32 +- .../test/blockchain.test.ts | 2 +- packages/woop-core/tsconfig.json | 16 + .../tsconfig.test.json | 0 .../{harmony-crypto => woop-crypto}/LICENSE | 0 .../{harmony-crypto => woop-crypto}/README.md | 16 +- .../package-lock.json | 14 +- .../package.json | 6 +- .../src/address.ts | 54 ++-- .../src/bech32.ts | 12 +- .../src/bytes.ts | 2 +- .../src/errors.ts | 18 +- .../src/index.ts | 2 +- .../src/keccak256.ts | 2 +- .../src/keyTool.ts | 4 +- .../src/keystore.ts | 4 +- .../src/random.ts | 2 +- .../src/rlp.ts | 2 +- .../src/signature.ts | 0 .../src/types.ts | 2 +- .../test/address.test.ts | 12 +- .../test/bytes.test.ts | 0 .../test/fixtures/hashes.json | 0 .../test/fixtures/rlpcoder.json | 0 .../test/keccak256.test.ts | 0 .../test/keyTool.test.ts | 2 +- .../test/keystore.test.ts | 0 .../test/rlp.test.ts | 0 .../test/tsconfig.json | 0 .../tsconfig.json | 2 +- .../tsconfig.test.json | 0 .../{harmony-network => woop-network}/LICENSE | 0 .../README.md | 12 +- .../package.json | 6 +- .../src/index.ts | 2 +- .../src/messenger/messenger.ts | 20 +- .../src/messenger/responseMiddleware.ts | 4 +- .../src/providers/baseProvider.ts | 2 +- .../src/providers/baseSocket.ts | 4 +- .../src/providers/defaultFetcher.ts | 2 +- .../src/providers/emitter.ts | 2 +- .../src/providers/http.ts | 2 +- .../src/providers/provider.ts | 4 +- .../src/providers/ws.ts | 4 +- .../src/rpcMethod/builder.ts | 2 +- .../src/rpcMethod/net.ts | 2 +- packages/woop-network/src/rpcMethod/rpc.ts | 136 +++++++++ .../src/subscriptions/LogSub.ts | 2 +- .../src/subscriptions/NewHeadersSub.ts | 2 +- .../NewPendingTransactionsSub.ts | 2 +- .../src/subscriptions/Subscription.ts | 2 +- .../src/subscriptions/SyncingSub.ts | 2 +- .../src/tracker/baseTracker.ts | 4 +- .../src/tracker/pollingTracker.ts | 2 +- .../src/tracker/subscribeTracker.ts | 2 +- .../src/types.ts | 2 +- .../src/util.ts | 2 +- .../tsconfig.json | 2 +- .../tsconfig.test.json | 0 .../{harmony-staking => woop-staking}/LICENSE | 0 .../README.md | 30 +- .../package.json | 12 +- .../src/factory.ts | 10 +- .../src/index.ts | 2 +- .../src/stakingTransaction.ts | 40 +-- .../test/testSign.test.ts | 14 +- .../test/transactions.json | 4 +- .../test/tsconfig.json | 0 .../tsconfig.json | 8 +- .../tsconfig.test.json | 0 .../LICENSE | 0 .../README.md | 34 +-- .../package.json | 10 +- .../src/abstractTransaction.ts | 4 +- .../src/factory.ts | 14 +- .../src/index.ts | 2 +- .../src/shardingTransaction.ts | 6 +- .../src/transaction.ts | 16 +- .../src/transactionBase.ts | 18 +- .../src/types.ts | 38 +-- .../src/utils.ts | 10 +- .../test/testSend.test.ts | 14 +- .../test/testSign.test.ts | 30 +- .../test/transactions.fixture.json | 0 .../test/transactions.remake.fixture.json | 0 .../test/tsconfig.json | 0 .../tsconfig.json | 6 +- .../tsconfig.test.json | 0 .../{harmony-utils => woop-utils}/LICENSE | 0 .../{harmony-utils => woop-utils}/README.md | 12 +- .../package.json | 4 +- .../src/chain.ts | 40 +-- .../src/errors.ts | 0 .../src/index.ts | 2 +- .../src/tools.ts | 2 +- .../src/transformers.ts | 2 +- .../src/utils.ts | 2 +- .../src/validators.ts | 2 +- .../test/fixture.ts | 4 +- .../test/transformer.test.ts | 4 +- .../test/tsconfig.json | 0 .../test/validators.test.ts | 2 +- .../tsconfig.json | 0 .../tsconfig.test.json | 0 scripts/bundle.ts | 2 +- scripts/jest/jest.e2e.config.js | 12 +- scripts/jest/jest.src.config.js | 30 +- scripts/packagesTs.ts | 16 +- scripts/projects.ts | 2 +- scripts/typedoc/runner.js | 4 +- scripts/typings/schema.ts | 4 +- tsconfig.json | 18 +- tsconfig.test.json | 16 +- 180 files changed, 1374 insertions(+), 1391 deletions(-) rename e2e/src/{harmony.ts => woop.ts} (66%) delete mode 100644 packages/harmony-account/src/utils.ts delete mode 100644 packages/harmony-core/package.json delete mode 100644 packages/harmony-core/src/types.ts delete mode 100644 packages/harmony-core/tsconfig.json delete mode 100644 packages/harmony-network/src/rpcMethod/rpc.ts rename packages/{harmony-account => woop-account}/LICENSE (100%) rename packages/{harmony-account => woop-account}/README.md (91%) rename packages/{harmony-account => woop-account}/guide.ts (91%) create mode 100644 packages/woop-account/package.json rename packages/{harmony-account => woop-account}/src/account.ts (93%) rename packages/{harmony-account => woop-account}/src/hdnode.ts (94%) rename packages/{harmony-account => woop-account}/src/index.ts (86%) rename packages/{harmony-account => woop-account}/src/types.ts (90%) create mode 100644 packages/woop-account/src/utils.ts rename packages/{harmony-account => woop-account}/src/wallet.ts (93%) rename packages/{harmony-account => woop-account}/test/testAccount.test.ts (79%) rename packages/{harmony-account => woop-account}/tsconfig.json (50%) rename packages/{harmony-account => woop-account}/tsconfig.test.json (100%) rename packages/{harmony-contract => woop-contract}/Counter.json (98%) rename packages/{harmony-contract => woop-contract}/LICENSE (100%) rename packages/{harmony-contract => woop-contract}/README.md (71%) rename packages/{harmony-contract => woop-contract}/package.json (65%) rename packages/{harmony-contract => woop-contract}/src/abi/abiCoder.ts (96%) rename packages/{harmony-contract => woop-contract}/src/abi/api.ts (96%) rename packages/{harmony-contract => woop-contract}/src/abi/index.ts (88%) rename packages/{harmony-contract => woop-contract}/src/abi/utils.ts (93%) rename packages/{harmony-contract => woop-contract}/src/contract.ts (94%) rename packages/{harmony-contract => woop-contract}/src/contractFactory.ts (84%) rename packages/{harmony-contract => woop-contract}/src/events/event.ts (93%) rename packages/{harmony-contract => woop-contract}/src/events/eventFactory.ts (96%) rename packages/{harmony-contract => woop-contract}/src/index.ts (90%) rename packages/{harmony-contract => woop-contract}/src/methods/method.ts (96%) rename packages/{harmony-contract => woop-contract}/src/methods/methodFactory.ts (98%) rename packages/{harmony-contract => woop-contract}/src/models/AbiItemModel.ts (94%) rename packages/{harmony-contract => woop-contract}/src/models/AbiModel.ts (98%) rename packages/{harmony-contract => woop-contract}/src/models/types.ts (97%) rename packages/{harmony-contract => woop-contract}/src/utils/decoder.ts (96%) rename packages/{harmony-contract => woop-contract}/src/utils/encoder.ts (96%) rename packages/{harmony-contract => woop-contract}/src/utils/formatter.ts (97%) rename packages/{harmony-contract => woop-contract}/src/utils/mapper.ts (97%) rename packages/{harmony-contract => woop-contract}/src/utils/options.ts (93%) rename packages/{harmony-contract => woop-contract}/src/utils/status.ts (90%) rename packages/{harmony-contract => woop-contract}/test/abiCoder.test.ts (95%) rename packages/{harmony-contract => woop-contract}/test/fixtures/abiv2.ts (100%) rename packages/{harmony-contract => woop-contract}/tsconfig.json (50%) rename packages/{harmony-contract => woop-contract}/tsconfig.test.json (100%) rename packages/{harmony-core => woop-core}/LICENSE (100%) rename packages/{harmony-core => woop-core}/README.md (76%) rename packages/{harmony-account => woop-core}/package.json (62%) rename packages/{harmony-core => woop-core}/src/blockchain.ts (88%) rename packages/{harmony-core => woop-core}/src/index.ts (60%) rename packages/{harmony-core => woop-core}/src/truffleProvider.ts (88%) create mode 100644 packages/woop-core/src/types.ts rename packages/{harmony-core => woop-core}/src/util.ts (76%) rename packages/{harmony-core/src/harmony.ts => woop-core/src/woop.ts} (77%) rename packages/{harmony-core/src/harmonyExtension.ts => woop-core/src/woopExtension.ts} (90%) rename packages/{harmony-core => woop-core}/test/blockchain.test.ts (99%) create mode 100644 packages/woop-core/tsconfig.json rename packages/{harmony-core => woop-core}/tsconfig.test.json (100%) rename packages/{harmony-crypto => woop-crypto}/LICENSE (100%) rename packages/{harmony-crypto => woop-crypto}/README.md (79%) rename packages/{harmony-crypto => woop-crypto}/package-lock.json (98%) rename packages/{harmony-crypto => woop-crypto}/package.json (86%) rename packages/{harmony-crypto => woop-crypto}/src/address.ts (73%) rename packages/{harmony-crypto => woop-crypto}/src/bech32.ts (95%) rename packages/{harmony-crypto => woop-crypto}/src/bytes.ts (99%) rename packages/{harmony-crypto => woop-crypto}/src/errors.ts (95%) rename packages/{harmony-crypto => woop-crypto}/src/index.ts (94%) rename packages/{harmony-crypto => woop-crypto}/src/keccak256.ts (95%) rename packages/{harmony-crypto => woop-crypto}/src/keyTool.ts (99%) rename packages/{harmony-crypto => woop-crypto}/src/keystore.ts (98%) rename packages/{harmony-crypto => woop-crypto}/src/random.ts (96%) rename packages/{harmony-crypto => woop-crypto}/src/rlp.ts (99%) rename packages/{harmony-crypto => woop-crypto}/src/signature.ts (100%) rename packages/{harmony-crypto => woop-crypto}/src/types.ts (96%) rename packages/{harmony-crypto => woop-crypto}/test/address.test.ts (83%) rename packages/{harmony-crypto => woop-crypto}/test/bytes.test.ts (100%) rename packages/{harmony-crypto => woop-crypto}/test/fixtures/hashes.json (100%) rename packages/{harmony-crypto => woop-crypto}/test/fixtures/rlpcoder.json (100%) rename packages/{harmony-crypto => woop-crypto}/test/keccak256.test.ts (100%) rename packages/{harmony-crypto => woop-crypto}/test/keyTool.test.ts (93%) rename packages/{harmony-crypto => woop-crypto}/test/keystore.test.ts (100%) rename packages/{harmony-crypto => woop-crypto}/test/rlp.test.ts (100%) rename packages/{harmony-crypto => woop-crypto}/test/tsconfig.json (100%) rename packages/{harmony-crypto => woop-crypto}/tsconfig.json (77%) rename packages/{harmony-crypto => woop-crypto}/tsconfig.test.json (100%) rename packages/{harmony-network => woop-network}/LICENSE (100%) rename packages/{harmony-network => woop-network}/README.md (52%) rename packages/{harmony-network => woop-network}/package.json (83%) rename packages/{harmony-network => woop-network}/src/index.ts (97%) rename packages/{harmony-network => woop-network}/src/messenger/messenger.ts (94%) rename packages/{harmony-network => woop-network}/src/messenger/responseMiddleware.ts (94%) rename packages/{harmony-network => woop-network}/src/providers/baseProvider.ts (98%) rename packages/{harmony-network => woop-network}/src/providers/baseSocket.ts (97%) rename packages/{harmony-network => woop-network}/src/providers/defaultFetcher.ts (97%) rename packages/{harmony-network => woop-network}/src/providers/emitter.ts (98%) rename packages/{harmony-network => woop-network}/src/providers/http.ts (99%) rename packages/{harmony-network => woop-network}/src/providers/provider.ts (94%) rename packages/{harmony-network => woop-network}/src/providers/ws.ts (98%) rename packages/{harmony-network => woop-network}/src/rpcMethod/builder.ts (97%) rename packages/{harmony-network => woop-network}/src/rpcMethod/net.ts (97%) create mode 100644 packages/woop-network/src/rpcMethod/rpc.ts rename packages/{harmony-network => woop-network}/src/subscriptions/LogSub.ts (98%) rename packages/{harmony-network => woop-network}/src/subscriptions/NewHeadersSub.ts (94%) rename packages/{harmony-network => woop-network}/src/subscriptions/NewPendingTransactionsSub.ts (94%) rename packages/{harmony-network => woop-network}/src/subscriptions/Subscription.ts (98%) rename packages/{harmony-network => woop-network}/src/subscriptions/SyncingSub.ts (97%) rename packages/{harmony-network => woop-network}/src/tracker/baseTracker.ts (98%) rename packages/{harmony-network => woop-network}/src/tracker/pollingTracker.ts (99%) rename packages/{harmony-network => woop-network}/src/tracker/subscribeTracker.ts (98%) rename packages/{harmony-network => woop-network}/src/types.ts (97%) rename packages/{harmony-network => woop-network}/src/util.ts (96%) rename packages/{harmony-network => woop-network}/tsconfig.json (77%) rename packages/{harmony-network => woop-network}/tsconfig.test.json (100%) rename packages/{harmony-staking => woop-staking}/LICENSE (100%) rename packages/{harmony-staking => woop-staking}/README.md (73%) rename packages/{harmony-staking => woop-staking}/package.json (68%) rename packages/{harmony-staking => woop-staking}/src/factory.ts (95%) rename packages/{harmony-staking => woop-staking}/src/index.ts (80%) rename packages/{harmony-staking => woop-staking}/src/stakingTransaction.ts (93%) rename packages/{harmony-staking => woop-staking}/test/testSign.test.ts (97%) rename packages/{harmony-staking => woop-staking}/test/transactions.json (98%) rename packages/{harmony-staking => woop-staking}/test/tsconfig.json (100%) rename packages/{harmony-staking => woop-staking}/tsconfig.json (55%) rename packages/{harmony-staking => woop-staking}/tsconfig.test.json (100%) rename packages/{harmony-transaction => woop-transaction}/LICENSE (100%) rename packages/{harmony-transaction => woop-transaction}/README.md (79%) rename packages/{harmony-transaction => woop-transaction}/package.json (72%) rename packages/{harmony-transaction => woop-transaction}/src/abstractTransaction.ts (92%) rename packages/{harmony-transaction => woop-transaction}/src/factory.ts (86%) rename packages/{harmony-transaction => woop-transaction}/src/index.ts (89%) rename packages/{harmony-transaction => woop-transaction}/src/shardingTransaction.ts (90%) rename packages/{harmony-transaction => woop-transaction}/src/transaction.ts (95%) rename packages/{harmony-transaction => woop-transaction}/src/transactionBase.ts (96%) rename packages/{harmony-transaction => woop-transaction}/src/types.ts (82%) rename packages/{harmony-transaction => woop-transaction}/src/utils.ts (97%) rename packages/{harmony-transaction => woop-transaction}/test/testSend.test.ts (96%) rename packages/{harmony-transaction => woop-transaction}/test/testSign.test.ts (87%) rename packages/{harmony-transaction => woop-transaction}/test/transactions.fixture.json (100%) rename packages/{harmony-transaction => woop-transaction}/test/transactions.remake.fixture.json (100%) rename packages/{harmony-transaction => woop-transaction}/test/tsconfig.json (100%) rename packages/{harmony-transaction => woop-transaction}/tsconfig.json (64%) rename packages/{harmony-transaction => woop-transaction}/tsconfig.test.json (100%) rename packages/{harmony-utils => woop-utils}/LICENSE (100%) rename packages/{harmony-utils => woop-utils}/README.md (84%) rename packages/{harmony-utils => woop-utils}/package.json (89%) rename packages/{harmony-utils => woop-utils}/src/chain.ts (81%) rename packages/{harmony-utils => woop-utils}/src/errors.ts (100%) rename packages/{harmony-utils => woop-utils}/src/index.ts (87%) rename packages/{harmony-utils => woop-utils}/src/tools.ts (90%) rename packages/{harmony-utils => woop-utils}/src/transformers.ts (99%) rename packages/{harmony-utils => woop-utils}/src/utils.ts (99%) rename packages/{harmony-utils => woop-utils}/src/validators.ts (99%) rename packages/{harmony-utils => woop-utils}/test/fixture.ts (87%) rename packages/{harmony-utils => woop-utils}/test/transformer.test.ts (99%) rename packages/{harmony-utils => woop-utils}/test/tsconfig.json (100%) rename packages/{harmony-utils => woop-utils}/test/validators.test.ts (99%) rename packages/{harmony-utils => woop-utils}/tsconfig.json (100%) rename packages/{harmony-utils => woop-utils}/tsconfig.test.json (100%) diff --git a/README.md b/README.md index 4a8e505..1193d0f 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/RELEASE.md b/RELEASE.md index 6cb5fee..fc4e16c 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -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 ``` diff --git a/TYPEDOC.md b/TYPEDOC.md index c5a375a..9e36cd6 100644 --- a/TYPEDOC.md +++ b/TYPEDOC.md @@ -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** diff --git a/e2e/src/blockchain.e2e.ts b/e2e/src/blockchain.e2e.ts index d4b5be0..3034f04 100644 --- a/e2e/src/blockchain.e2e.ts +++ b/e2e/src/blockchain.e2e.ts @@ -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] }, ); } \ No newline at end of file diff --git a/e2e/src/transaction.e2e.ts b/e2e/src/transaction.e2e.ts index 1d9c329..11bcf61 100644 --- a/e2e/src/transaction.e2e.ts +++ b/e2e/src/transaction.e2e.ts @@ -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] }, ); } diff --git a/e2e/src/txn_rpc.e2e.ts b/e2e/src/txn_rpc.e2e.ts index 1706aba..7a86f20 100644 --- a/e2e/src/txn_rpc.e2e.ts +++ b/e2e/src/txn_rpc.e2e.ts @@ -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] }, ); } diff --git a/e2e/src/harmony.ts b/e2e/src/woop.ts similarity index 66% rename from e2e/src/harmony.ts rename to e2e/src/woop.ts index f3b973f..d3d7dec 100644 --- a/e2e/src/harmony.ts +++ b/e2e/src/woop.ts @@ -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, ); diff --git a/e2e/tsconfig.json b/e2e/tsconfig.json index f96f45f..3a1803e 100644 --- a/e2e/tsconfig.json +++ b/e2e/tsconfig.json @@ -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" } ] } diff --git a/gulpfile.js b/gulpfile.js index 067047e..df0c90f 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -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 () => { diff --git a/package-lock.json b/package-lock.json index 53eb214..b19a676 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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" diff --git a/package.json b/package.json index e980c2b..249b574 100644 --- a/package.json +++ b/package.json @@ -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" } diff --git a/packages/README.md b/packages/README.md index 214e0c6..d963752 100644 --- a/packages/README.md +++ b/packages/README.md @@ -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) Package level documentation and examples are inside each package \ No newline at end of file diff --git a/packages/harmony-account/src/utils.ts b/packages/harmony-account/src/utils.ts deleted file mode 100644 index 4715643..0000000 --- a/packages/harmony-account/src/utils.ts +++ /dev/null @@ -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, -); diff --git a/packages/harmony-core/package.json b/packages/harmony-core/package.json deleted file mode 100644 index 5e190ea..0000000 --- a/packages/harmony-core/package.json +++ /dev/null @@ -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" -} diff --git a/packages/harmony-core/src/types.ts b/packages/harmony-core/src/types.ts deleted file mode 100644 index 7b8ed38..0000000 --- a/packages/harmony-core/src/types.ts +++ /dev/null @@ -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 { - type: T; - id: I; -} diff --git a/packages/harmony-core/tsconfig.json b/packages/harmony-core/tsconfig.json deleted file mode 100644 index 031d04b..0000000 --- a/packages/harmony-core/tsconfig.json +++ /dev/null @@ -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"} - ] -} diff --git a/packages/harmony-network/src/rpcMethod/rpc.ts b/packages/harmony-network/src/rpcMethod/rpc.ts deleted file mode 100644 index 980f098..0000000 --- a/packages/harmony-network/src/rpcMethod/rpc.ts +++ /dev/null @@ -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 -} diff --git a/packages/harmony-account/LICENSE b/packages/woop-account/LICENSE similarity index 100% rename from packages/harmony-account/LICENSE rename to packages/woop-account/LICENSE diff --git a/packages/harmony-account/README.md b/packages/woop-account/README.md similarity index 91% rename from packages/harmony-account/README.md rename to packages/woop-account/README.md index c607003..204d024 100644 --- a/packages/harmony-account/README.md +++ b/packages/woop-account/README.md @@ -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); }); diff --git a/packages/harmony-account/guide.ts b/packages/woop-account/guide.ts similarity index 91% rename from packages/harmony-account/guide.ts rename to packages/woop-account/guide.ts index 220d4fe..3e3a843 100644 --- a/packages/harmony-account/guide.ts +++ b/packages/woop-account/guide.ts @@ -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 */ diff --git a/packages/woop-account/package.json b/packages/woop-account/package.json new file mode 100644 index 0000000..fde047e --- /dev/null +++ b/packages/woop-account/package.json @@ -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" +} diff --git a/packages/harmony-account/src/account.ts b/packages/woop-account/src/account.ts similarity index 93% rename from packages/harmony-account/src/account.ts rename to packages/woop-account/src/account.ts index 1e3cc6b..b94fdd7 100644 --- a/packages/harmony-account/src/account.ts +++ b/packages/woop-account/src/account.ts @@ -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 diff --git a/packages/harmony-account/src/hdnode.ts b/packages/woop-account/src/hdnode.ts similarity index 94% rename from packages/harmony-account/src/hdnode.ts rename to packages/woop-account/src/hdnode.ts index 5eed477..eae2ef8 100644 --- a/packages/harmony-account/src/hdnode.ts +++ b/packages/woop-account/src/hdnode.ts @@ -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, ); diff --git a/packages/harmony-account/src/index.ts b/packages/woop-account/src/index.ts similarity index 86% rename from packages/harmony-account/src/index.ts rename to packages/woop-account/src/index.ts index 0511d31..c2aed5a 100644 --- a/packages/harmony-account/src/index.ts +++ b/packages/woop-account/src/index.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-account + * @module woop-account * @ignore */ diff --git a/packages/harmony-account/src/types.ts b/packages/woop-account/src/types.ts similarity index 90% rename from packages/harmony-account/src/types.ts rename to packages/woop-account/src/types.ts index e7ecc32..b916cce 100644 --- a/packages/harmony-account/src/types.ts +++ b/packages/woop-account/src/types.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-account + * @module woop-account * @hidden */ diff --git a/packages/woop-account/src/utils.ts b/packages/woop-account/src/utils.ts new file mode 100644 index 0000000..bbd7d27 --- /dev/null +++ b/packages/woop-account/src/utils.ts @@ -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, +); diff --git a/packages/harmony-account/src/wallet.ts b/packages/woop-account/src/wallet.ts similarity index 93% rename from packages/harmony-account/src/wallet.ts rename to packages/woop-account/src/wallet.ts index faecdd7..d4a106a 100644 --- a/packages/harmony-account/src/wallet.ts +++ b/packages/woop-account/src/wallet.ts @@ -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); diff --git a/packages/harmony-account/test/testAccount.test.ts b/packages/woop-account/test/testAccount.test.ts similarity index 79% rename from packages/harmony-account/test/testAccount.test.ts rename to packages/woop-account/test/testAccount.test.ts index e7788ac..be3408b 100644 --- a/packages/harmony-account/test/testAccount.test.ts +++ b/packages/woop-account/test/testAccount.test.ts @@ -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', () => { diff --git a/packages/harmony-account/tsconfig.json b/packages/woop-account/tsconfig.json similarity index 50% rename from packages/harmony-account/tsconfig.json rename to packages/woop-account/tsconfig.json index 693e3f7..a665330 100644 --- a/packages/harmony-account/tsconfig.json +++ b/packages/woop-account/tsconfig.json @@ -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" } ] } diff --git a/packages/harmony-account/tsconfig.test.json b/packages/woop-account/tsconfig.test.json similarity index 100% rename from packages/harmony-account/tsconfig.test.json rename to packages/woop-account/tsconfig.test.json diff --git a/packages/harmony-contract/Counter.json b/packages/woop-contract/Counter.json similarity index 98% rename from packages/harmony-contract/Counter.json rename to packages/woop-contract/Counter.json index 0025a60..3136fac 100644 --- a/packages/harmony-contract/Counter.json +++ b/packages/woop-contract/Counter.json @@ -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] }, diff --git a/packages/harmony-contract/LICENSE b/packages/woop-contract/LICENSE similarity index 100% rename from packages/harmony-contract/LICENSE rename to packages/woop-contract/LICENSE diff --git a/packages/harmony-contract/README.md b/packages/woop-contract/README.md similarity index 71% rename from packages/harmony-contract/README.md rename to packages/woop-contract/README.md index eafb5a6..79162a7 100644 --- a/packages/harmony-contract/README.md +++ b/packages/woop-contract/README.md @@ -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); diff --git a/packages/harmony-contract/package.json b/packages/woop-contract/package.json similarity index 65% rename from packages/harmony-contract/package.json rename to packages/woop-contract/package.json index a6598fe..0cec9e4 100644 --- a/packages/harmony-contract/package.json +++ b/packages/woop-contract/package.json @@ -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" } diff --git a/packages/harmony-contract/src/abi/abiCoder.ts b/packages/woop-contract/src/abi/abiCoder.ts similarity index 96% rename from packages/harmony-contract/src/abi/abiCoder.ts rename to packages/woop-contract/src/abi/abiCoder.ts index efc910e..70cc3f8 100644 --- a/packages/harmony-contract/src/abi/abiCoder.ts +++ b/packages/woop-contract/src/abi/abiCoder.ts @@ -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); diff --git a/packages/harmony-contract/src/abi/api.ts b/packages/woop-contract/src/abi/api.ts similarity index 96% rename from packages/harmony-contract/src/abi/api.ts rename to packages/woop-contract/src/abi/api.ts index 9ec3cd5..966e7bf 100644 --- a/packages/harmony-contract/src/abi/api.ts +++ b/packages/woop-contract/src/abi/api.ts @@ -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 { diff --git a/packages/harmony-contract/src/abi/index.ts b/packages/woop-contract/src/abi/index.ts similarity index 88% rename from packages/harmony-contract/src/abi/index.ts rename to packages/woop-contract/src/abi/index.ts index e0d08dc..77f218a 100644 --- a/packages/harmony-contract/src/abi/index.ts +++ b/packages/woop-contract/src/abi/index.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-contract + * @module woop-contract * @hidden */ diff --git a/packages/harmony-contract/src/abi/utils.ts b/packages/woop-contract/src/abi/utils.ts similarity index 93% rename from packages/harmony-contract/src/abi/utils.ts rename to packages/woop-contract/src/abi/utils.ts index 5cab003..11975b0 100644 --- a/packages/harmony-contract/src/abi/utils.ts +++ b/packages/woop-contract/src/abi/utils.ts @@ -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('(')) { diff --git a/packages/harmony-contract/src/contract.ts b/packages/woop-contract/src/contract.ts similarity index 94% rename from packages/harmony-contract/src/contract.ts rename to packages/woop-contract/src/contract.ts index 67dd47a..c450137 100644 --- a/packages/harmony-contract/src/contract.ts +++ b/packages/woop-contract/src/contract.ts @@ -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'; diff --git a/packages/harmony-contract/src/contractFactory.ts b/packages/woop-contract/src/contractFactory.ts similarity index 84% rename from packages/harmony-contract/src/contractFactory.ts rename to packages/woop-contract/src/contractFactory.ts index 7231354..53301f6 100644 --- a/packages/harmony-contract/src/contractFactory.ts +++ b/packages/woop-contract/src/contractFactory.ts @@ -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'; diff --git a/packages/harmony-contract/src/events/event.ts b/packages/woop-contract/src/events/event.ts similarity index 93% rename from packages/harmony-contract/src/events/event.ts rename to packages/woop-contract/src/events/event.ts index d8dcd4e..7483665 100644 --- a/packages/harmony-contract/src/events/event.ts +++ b/packages/woop-contract/src/events/event.ts @@ -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'; diff --git a/packages/harmony-contract/src/events/eventFactory.ts b/packages/woop-contract/src/events/eventFactory.ts similarity index 96% rename from packages/harmony-contract/src/events/eventFactory.ts rename to packages/woop-contract/src/events/eventFactory.ts index bd74269..c02019b 100644 --- a/packages/harmony-contract/src/events/eventFactory.ts +++ b/packages/woop-contract/src/events/eventFactory.ts @@ -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'; diff --git a/packages/harmony-contract/src/index.ts b/packages/woop-contract/src/index.ts similarity index 90% rename from packages/harmony-contract/src/index.ts rename to packages/woop-contract/src/index.ts index e5d98fc..27a5462 100644 --- a/packages/harmony-contract/src/index.ts +++ b/packages/woop-contract/src/index.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-contract + * @module woop-contract * @hidden */ diff --git a/packages/harmony-contract/src/methods/method.ts b/packages/woop-contract/src/methods/method.ts similarity index 96% rename from packages/harmony-contract/src/methods/method.ts rename to packages/woop-contract/src/methods/method.ts index 546e5a9..ebfc173 100644 --- a/packages/harmony-contract/src/methods/method.ts +++ b/packages/woop-contract/src/methods/method.ts @@ -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'; diff --git a/packages/harmony-contract/src/methods/methodFactory.ts b/packages/woop-contract/src/methods/methodFactory.ts similarity index 98% rename from packages/harmony-contract/src/methods/methodFactory.ts rename to packages/woop-contract/src/methods/methodFactory.ts index d20be9c..2f3f789 100644 --- a/packages/harmony-contract/src/methods/methodFactory.ts +++ b/packages/woop-contract/src/methods/methodFactory.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-contract + * @module woop-contract * @hidden */ diff --git a/packages/harmony-contract/src/models/AbiItemModel.ts b/packages/woop-contract/src/models/AbiItemModel.ts similarity index 94% rename from packages/harmony-contract/src/models/AbiItemModel.ts rename to packages/woop-contract/src/models/AbiItemModel.ts index 0701a78..60dbd50 100644 --- a/packages/harmony-contract/src/models/AbiItemModel.ts +++ b/packages/woop-contract/src/models/AbiItemModel.ts @@ -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 { diff --git a/packages/harmony-contract/src/models/AbiModel.ts b/packages/woop-contract/src/models/AbiModel.ts similarity index 98% rename from packages/harmony-contract/src/models/AbiModel.ts rename to packages/woop-contract/src/models/AbiModel.ts index e17acf2..5b0f8c8 100644 --- a/packages/harmony-contract/src/models/AbiModel.ts +++ b/packages/woop-contract/src/models/AbiModel.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-contract + * @module woop-contract * @hidden */ diff --git a/packages/harmony-contract/src/models/types.ts b/packages/woop-contract/src/models/types.ts similarity index 97% rename from packages/harmony-contract/src/models/types.ts rename to packages/woop-contract/src/models/types.ts index 0648b6c..b6c539a 100644 --- a/packages/harmony-contract/src/models/types.ts +++ b/packages/woop-contract/src/models/types.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-contract + * @module woop-contract * @hidden */ diff --git a/packages/harmony-contract/src/utils/decoder.ts b/packages/woop-contract/src/utils/decoder.ts similarity index 96% rename from packages/harmony-contract/src/utils/decoder.ts rename to packages/woop-contract/src/utils/decoder.ts index abb2a9b..8c80ee2 100644 --- a/packages/harmony-contract/src/utils/decoder.ts +++ b/packages/woop-contract/src/utils/decoder.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-contract + * @module woop-contract * @hidden */ diff --git a/packages/harmony-contract/src/utils/encoder.ts b/packages/woop-contract/src/utils/encoder.ts similarity index 96% rename from packages/harmony-contract/src/utils/encoder.ts rename to packages/woop-contract/src/utils/encoder.ts index 14f0db2..a68a17e 100644 --- a/packages/harmony-contract/src/utils/encoder.ts +++ b/packages/woop-contract/src/utils/encoder.ts @@ -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'; diff --git a/packages/harmony-contract/src/utils/formatter.ts b/packages/woop-contract/src/utils/formatter.ts similarity index 97% rename from packages/harmony-contract/src/utils/formatter.ts rename to packages/woop-contract/src/utils/formatter.ts index 28ab72f..4363f67 100644 --- a/packages/harmony-contract/src/utils/formatter.ts +++ b/packages/woop-contract/src/utils/formatter.ts @@ -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) => { diff --git a/packages/harmony-contract/src/utils/mapper.ts b/packages/woop-contract/src/utils/mapper.ts similarity index 97% rename from packages/harmony-contract/src/utils/mapper.ts rename to packages/woop-contract/src/utils/mapper.ts index 3db0d3f..e809dd7 100644 --- a/packages/harmony-contract/src/utils/mapper.ts +++ b/packages/woop-contract/src/utils/mapper.ts @@ -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'; diff --git a/packages/harmony-contract/src/utils/options.ts b/packages/woop-contract/src/utils/options.ts similarity index 93% rename from packages/harmony-contract/src/utils/options.ts rename to packages/woop-contract/src/utils/options.ts index aa3d198..7432dbc 100644 --- a/packages/harmony-contract/src/utils/options.ts +++ b/packages/woop-contract/src/utils/options.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-contract + * @module woop-contract * @hidden */ diff --git a/packages/harmony-contract/src/utils/status.ts b/packages/woop-contract/src/utils/status.ts similarity index 90% rename from packages/harmony-contract/src/utils/status.ts rename to packages/woop-contract/src/utils/status.ts index d1625c8..93a7c6d 100644 --- a/packages/harmony-contract/src/utils/status.ts +++ b/packages/woop-contract/src/utils/status.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-contract + * @module woop-contract * @hidden */ diff --git a/packages/harmony-contract/test/abiCoder.test.ts b/packages/woop-contract/test/abiCoder.test.ts similarity index 95% rename from packages/harmony-contract/test/abiCoder.test.ts rename to packages/woop-contract/test/abiCoder.test.ts index 4bb1382..d2358c8 100644 --- a/packages/harmony-contract/test/abiCoder.test.ts +++ b/packages/woop-contract/test/abiCoder.test.ts @@ -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 { diff --git a/packages/harmony-contract/test/fixtures/abiv2.ts b/packages/woop-contract/test/fixtures/abiv2.ts similarity index 100% rename from packages/harmony-contract/test/fixtures/abiv2.ts rename to packages/woop-contract/test/fixtures/abiv2.ts diff --git a/packages/harmony-contract/tsconfig.json b/packages/woop-contract/tsconfig.json similarity index 50% rename from packages/harmony-contract/tsconfig.json rename to packages/woop-contract/tsconfig.json index b43ea95..4ea6b47 100644 --- a/packages/harmony-contract/tsconfig.json +++ b/packages/woop-contract/tsconfig.json @@ -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"} ] } diff --git a/packages/harmony-contract/tsconfig.test.json b/packages/woop-contract/tsconfig.test.json similarity index 100% rename from packages/harmony-contract/tsconfig.test.json rename to packages/woop-contract/tsconfig.test.json diff --git a/packages/harmony-core/LICENSE b/packages/woop-core/LICENSE similarity index 100% rename from packages/harmony-core/LICENSE rename to packages/woop-core/LICENSE diff --git a/packages/harmony-core/README.md b/packages/woop-core/README.md similarity index 76% rename from packages/harmony-core/README.md rename to packages/woop-core/README.md index f23d59f..a68ab2b 100644 --- a/packages/harmony-core/README.md +++ b/packages/woop-core/README.md @@ -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); } diff --git a/packages/harmony-account/package.json b/packages/woop-core/package.json similarity index 62% rename from packages/harmony-account/package.json rename to packages/woop-core/package.json index 99d231a..ff1d176 100644 --- a/packages/harmony-account/package.json +++ b/packages/woop-core/package.json @@ -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" } diff --git a/packages/harmony-core/src/blockchain.ts b/packages/woop-core/src/blockchain.ts similarity index 88% rename from packages/harmony-core/src/blockchain.ts rename to packages/woop-core/src/blockchain.ts index 87d75d5..65c97e9 100644 --- a/packages/harmony-core/src/blockchain.ts +++ b/packages/woop-core/src/blockchain.ts @@ -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) diff --git a/packages/harmony-core/src/index.ts b/packages/woop-core/src/index.ts similarity index 60% rename from packages/harmony-core/src/index.ts rename to packages/woop-core/src/index.ts index b4675b1..501c56b 100644 --- a/packages/harmony-core/src/index.ts +++ b/packages/woop-core/src/index.ts @@ -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'; diff --git a/packages/harmony-core/src/truffleProvider.ts b/packages/woop-core/src/truffleProvider.ts similarity index 88% rename from packages/harmony-core/src/truffleProvider.ts rename to packages/woop-core/src/truffleProvider.ts index b270d2a..9dfd95b 100644 --- a/packages/harmony-core/src/truffleProvider.ts +++ b/packages/woop-core/src/truffleProvider.ts @@ -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; diff --git a/packages/woop-core/src/types.ts b/packages/woop-core/src/types.ts new file mode 100644 index 0000000..b8e8783 --- /dev/null +++ b/packages/woop-core/src/types.ts @@ -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 { + type: T; + id: I; +} diff --git a/packages/harmony-core/src/util.ts b/packages/woop-core/src/util.ts similarity index 76% rename from packages/harmony-core/src/util.ts rename to packages/woop-core/src/util.ts index 2cf03e3..aac3da8 100644 --- a/packages/harmony-core/src/util.ts +++ b/packages/woop-core/src/util.ts @@ -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 }; } diff --git a/packages/harmony-core/src/harmony.ts b/packages/woop-core/src/woop.ts similarity index 77% rename from packages/harmony-core/src/harmony.ts rename to packages/woop-core/src/woop.ts index 7c47ee2..cab351d 100644 --- a/packages/harmony-core/src/harmony.ts +++ b/packages/woop-core/src/woop.ts @@ -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", diff --git a/packages/harmony-core/src/harmonyExtension.ts b/packages/woop-core/src/woopExtension.ts similarity index 90% rename from packages/harmony-core/src/harmonyExtension.ts rename to packages/woop-core/src/woopExtension.ts index 41f7b98..5fbd6d4 100644 --- a/packages/harmony-core/src/harmonyExtension.ts +++ b/packages/woop-core/src/woopExtension.ts @@ -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", diff --git a/packages/harmony-core/test/blockchain.test.ts b/packages/woop-core/test/blockchain.test.ts similarity index 99% rename from packages/harmony-core/test/blockchain.test.ts rename to packages/woop-core/test/blockchain.test.ts index abb7a14..f6240f8 100644 --- a/packages/harmony-core/test/blockchain.test.ts +++ b/packages/woop-core/test/blockchain.test.ts @@ -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); diff --git a/packages/woop-core/tsconfig.json b/packages/woop-core/tsconfig.json new file mode 100644 index 0000000..1f58be9 --- /dev/null +++ b/packages/woop-core/tsconfig.json @@ -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"} + ] +} diff --git a/packages/harmony-core/tsconfig.test.json b/packages/woop-core/tsconfig.test.json similarity index 100% rename from packages/harmony-core/tsconfig.test.json rename to packages/woop-core/tsconfig.test.json diff --git a/packages/harmony-crypto/LICENSE b/packages/woop-crypto/LICENSE similarity index 100% rename from packages/harmony-crypto/LICENSE rename to packages/woop-crypto/LICENSE diff --git a/packages/harmony-crypto/README.md b/packages/woop-crypto/README.md similarity index 79% rename from packages/harmony-crypto/README.md rename to packages/woop-crypto/README.md index b05beb0..81b6a25 100644 --- a/packages/harmony-crypto/README.md +++ b/packages/woop-crypto/README.md @@ -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); diff --git a/packages/harmony-crypto/package-lock.json b/packages/woop-crypto/package-lock.json similarity index 98% rename from packages/harmony-crypto/package-lock.json rename to packages/woop-crypto/package-lock.json index 75c110f..f385392 100644 --- a/packages/harmony-crypto/package-lock.json +++ b/packages/woop-crypto/package-lock.json @@ -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", diff --git a/packages/harmony-crypto/package.json b/packages/woop-crypto/package.json similarity index 86% rename from packages/harmony-crypto/package.json rename to packages/woop-crypto/package.json index b8a3cf2..b408be7 100644 --- a/packages/harmony-crypto/package.json +++ b/packages/woop-crypto/package.json @@ -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", diff --git a/packages/harmony-crypto/src/address.ts b/packages/woop-crypto/src/address.ts similarity index 73% rename from packages/harmony-crypto/src/address.ts rename to packages/woop-crypto/src/address.ts index aa5838c..af7fbb4 100644 --- a/packages/harmony-crypto/src/address.ts +++ b/packages/woop-crypto/src/address.ts @@ -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; } diff --git a/packages/harmony-crypto/src/bech32.ts b/packages/woop-crypto/src/bech32.ts similarity index 95% rename from packages/harmony-crypto/src/bech32.ts rename to packages/woop-crypto/src/bech32.ts index 0c15063..614247d 100644 --- a/packages/harmony-crypto/src/bech32.ts +++ b/packages/woop-crypto/src/bech32.ts @@ -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
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 => { diff --git a/packages/harmony-crypto/src/bytes.ts b/packages/woop-crypto/src/bytes.ts similarity index 99% rename from packages/harmony-crypto/src/bytes.ts rename to packages/woop-crypto/src/bytes.ts index eb8324e..55e935e 100644 --- a/packages/harmony-crypto/src/bytes.ts +++ b/packages/woop-crypto/src/bytes.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-crypto + * @module woop-crypto * @hidden */ diff --git a/packages/harmony-crypto/src/errors.ts b/packages/woop-crypto/src/errors.ts similarity index 95% rename from packages/harmony-crypto/src/errors.ts rename to packages/woop-crypto/src/errors.ts index 158ef1c..2276645 100644 --- a/packages/harmony-crypto/src/errors.ts +++ b/packages/woop-crypto/src/errors.ts @@ -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 diff --git a/packages/harmony-crypto/src/index.ts b/packages/woop-crypto/src/index.ts similarity index 94% rename from packages/harmony-crypto/src/index.ts rename to packages/woop-crypto/src/index.ts index 090373e..dd09bfb 100644 --- a/packages/harmony-crypto/src/index.ts +++ b/packages/woop-crypto/src/index.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-crypto + * @module woop-crypto * @ignore */ diff --git a/packages/harmony-crypto/src/keccak256.ts b/packages/woop-crypto/src/keccak256.ts similarity index 95% rename from packages/harmony-crypto/src/keccak256.ts rename to packages/woop-crypto/src/keccak256.ts index 01b095a..9795ac5 100644 --- a/packages/harmony-crypto/src/keccak256.ts +++ b/packages/woop-crypto/src/keccak256.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-crypto + * @module woop-crypto * @ignore */ diff --git a/packages/harmony-crypto/src/keyTool.ts b/packages/woop-crypto/src/keyTool.ts similarity index 99% rename from packages/harmony-crypto/src/keyTool.ts rename to packages/woop-crypto/src/keyTool.ts index 7bb1f91..3cd9b4b 100644 --- a/packages/harmony-crypto/src/keyTool.ts +++ b/packages/woop-crypto/src/keyTool.ts @@ -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'; diff --git a/packages/harmony-crypto/src/keystore.ts b/packages/woop-crypto/src/keystore.ts similarity index 98% rename from packages/harmony-crypto/src/keystore.ts rename to packages/woop-crypto/src/keystore.ts index 0a8eada..e061f35 100644 --- a/packages/harmony-crypto/src/keystore.ts +++ b/packages/woop-crypto/src/keystore.ts @@ -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'; diff --git a/packages/harmony-crypto/src/random.ts b/packages/woop-crypto/src/random.ts similarity index 96% rename from packages/harmony-crypto/src/random.ts rename to packages/woop-crypto/src/random.ts index 787f649..806db7a 100644 --- a/packages/harmony-crypto/src/random.ts +++ b/packages/woop-crypto/src/random.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-crypto + * @module woop-crypto */ /** diff --git a/packages/harmony-crypto/src/rlp.ts b/packages/woop-crypto/src/rlp.ts similarity index 99% rename from packages/harmony-crypto/src/rlp.ts rename to packages/woop-crypto/src/rlp.ts index 95ba9e7..c93842d 100644 --- a/packages/harmony-crypto/src/rlp.ts +++ b/packages/woop-crypto/src/rlp.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-crypto + * @module woop-crypto * @hidden */ diff --git a/packages/harmony-crypto/src/signature.ts b/packages/woop-crypto/src/signature.ts similarity index 100% rename from packages/harmony-crypto/src/signature.ts rename to packages/woop-crypto/src/signature.ts diff --git a/packages/harmony-crypto/src/types.ts b/packages/woop-crypto/src/types.ts similarity index 96% rename from packages/harmony-crypto/src/types.ts rename to packages/woop-crypto/src/types.ts index 900833a..454421b 100644 --- a/packages/harmony-crypto/src/types.ts +++ b/packages/woop-crypto/src/types.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-crypto + * @module woop-crypto * @ignore */ diff --git a/packages/harmony-crypto/test/address.test.ts b/packages/woop-crypto/test/address.test.ts similarity index 83% rename from packages/harmony-crypto/test/address.test.ts rename to packages/woop-crypto/test/address.test.ts index 93e1bd1..0ce6a7b 100644 --- a/packages/harmony-crypto/test/address.test.ts +++ b/packages/woop-crypto/test/address.test.ts @@ -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 diff --git a/packages/harmony-crypto/test/bytes.test.ts b/packages/woop-crypto/test/bytes.test.ts similarity index 100% rename from packages/harmony-crypto/test/bytes.test.ts rename to packages/woop-crypto/test/bytes.test.ts diff --git a/packages/harmony-crypto/test/fixtures/hashes.json b/packages/woop-crypto/test/fixtures/hashes.json similarity index 100% rename from packages/harmony-crypto/test/fixtures/hashes.json rename to packages/woop-crypto/test/fixtures/hashes.json diff --git a/packages/harmony-crypto/test/fixtures/rlpcoder.json b/packages/woop-crypto/test/fixtures/rlpcoder.json similarity index 100% rename from packages/harmony-crypto/test/fixtures/rlpcoder.json rename to packages/woop-crypto/test/fixtures/rlpcoder.json diff --git a/packages/harmony-crypto/test/keccak256.test.ts b/packages/woop-crypto/test/keccak256.test.ts similarity index 100% rename from packages/harmony-crypto/test/keccak256.test.ts rename to packages/woop-crypto/test/keccak256.test.ts diff --git a/packages/harmony-crypto/test/keyTool.test.ts b/packages/woop-crypto/test/keyTool.test.ts similarity index 93% rename from packages/harmony-crypto/test/keyTool.test.ts rename to packages/woop-crypto/test/keyTool.test.ts index d873069..4a9cd7d 100644 --- a/packages/harmony-crypto/test/keyTool.test.ts +++ b/packages/woop-crypto/test/keyTool.test.ts @@ -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', () => { diff --git a/packages/harmony-crypto/test/keystore.test.ts b/packages/woop-crypto/test/keystore.test.ts similarity index 100% rename from packages/harmony-crypto/test/keystore.test.ts rename to packages/woop-crypto/test/keystore.test.ts diff --git a/packages/harmony-crypto/test/rlp.test.ts b/packages/woop-crypto/test/rlp.test.ts similarity index 100% rename from packages/harmony-crypto/test/rlp.test.ts rename to packages/woop-crypto/test/rlp.test.ts diff --git a/packages/harmony-crypto/test/tsconfig.json b/packages/woop-crypto/test/tsconfig.json similarity index 100% rename from packages/harmony-crypto/test/tsconfig.json rename to packages/woop-crypto/test/tsconfig.json diff --git a/packages/harmony-crypto/tsconfig.json b/packages/woop-crypto/tsconfig.json similarity index 77% rename from packages/harmony-crypto/tsconfig.json rename to packages/woop-crypto/tsconfig.json index fac7fc2..6f80e28 100644 --- a/packages/harmony-crypto/tsconfig.json +++ b/packages/woop-crypto/tsconfig.json @@ -5,5 +5,5 @@ "outDir": "dist" }, "include": ["src", "../../typings/**/*.d.ts"], - "references": [{"path": "../harmony-utils"}] + "references": [{"path": "../woop-utils"}] } diff --git a/packages/harmony-crypto/tsconfig.test.json b/packages/woop-crypto/tsconfig.test.json similarity index 100% rename from packages/harmony-crypto/tsconfig.test.json rename to packages/woop-crypto/tsconfig.test.json diff --git a/packages/harmony-network/LICENSE b/packages/woop-network/LICENSE similarity index 100% rename from packages/harmony-network/LICENSE rename to packages/woop-network/LICENSE diff --git a/packages/harmony-network/README.md b/packages/woop-network/README.md similarity index 52% rename from packages/harmony-network/README.md rename to packages/woop-network/README.md index 5778a5f..ab2b900 100644 --- a/packages/harmony-network/README.md +++ b/packages/woop-network/README.md @@ -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 ``` \ No newline at end of file diff --git a/packages/harmony-network/package.json b/packages/woop-network/package.json similarity index 83% rename from packages/harmony-network/package.json rename to packages/woop-network/package.json index 73023a6..f926c3a 100644 --- a/packages/harmony-network/package.json +++ b/packages/woop-network/package.json @@ -1,7 +1,7 @@ { - "name": "@harmony-js/network", + "name": "@woop-js/network", "version": "0.1.58", - "description": "network suites for harmony", + "description": "network suites for woop", "main": "dist/index.js", "node": "dist/index.js", "browser": "dist/index.js", @@ -18,7 +18,7 @@ "author": "neeboo@firestack.one", "license": "MIT", "dependencies": { - "@harmony-js/utils": "0.1.58", + "@woop-js/utils": "0.1.58", "cross-fetch": "^3.0.2", "mitt": "^1.2.0", "websocket": "^1.0.28" diff --git a/packages/harmony-network/src/index.ts b/packages/woop-network/src/index.ts similarity index 97% rename from packages/harmony-network/src/index.ts rename to packages/woop-network/src/index.ts index 7d287e6..af59bfe 100644 --- a/packages/harmony-network/src/index.ts +++ b/packages/woop-network/src/index.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-network + * @module woop-network * @ignore */ diff --git a/packages/harmony-network/src/messenger/messenger.ts b/packages/woop-network/src/messenger/messenger.ts similarity index 94% rename from packages/harmony-network/src/messenger/messenger.ts rename to packages/woop-network/src/messenger/messenger.ts index 9fd3896..66ef050 100644 --- a/packages/harmony-network/src/messenger/messenger.ts +++ b/packages/woop-network/src/messenger/messenger.ts @@ -1,9 +1,9 @@ /** * @packageDocumentation - * @module harmony-network + * @module woop-network */ -import { HarmonyCore, ChainType, isString, ChainID, defaultConfig } from '@harmony-js/utils'; +import { WoopCore, ChainType, isString, ChainID, defaultConfig } from '@woop-js/utils'; import { JsonRpc } from '../rpcMethod/builder'; import { ResponseMiddleware } from './responseMiddleware'; import { HttpProvider } from '../providers/http'; @@ -24,18 +24,18 @@ export interface ShardingProvider { * ## How to Create a Massage * @example * ``` - * 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 * ) * ``` */ -class Messenger extends HarmonyCore { +class Messenger extends WoopCore { provider: HttpProvider | WSProvider; config?: object; // tslint:disable-next-line: variable-name @@ -291,7 +291,7 @@ class Messenger extends HarmonyCore { }; async setShardingProviders() { - if (this.chainPrefix !== ChainType.Harmony) { + if (this.chainPrefix !== ChainType.Woop) { return; } try { @@ -318,7 +318,7 @@ class Messenger extends HarmonyCore { /** * @example * ``` - * hmy.messenger.getShardProvider() + * wiki.messenger.getShardProvider() * ``` */ getShardProvider(shardID: number): HttpProvider | WSProvider { @@ -334,7 +334,7 @@ class Messenger extends HarmonyCore { /** * @example * ``` - * hmy.messenger.getCurrentShardID() + * wiki.messenger.getCurrentShardID() * ``` */ diff --git a/packages/harmony-network/src/messenger/responseMiddleware.ts b/packages/woop-network/src/messenger/responseMiddleware.ts similarity index 94% rename from packages/harmony-network/src/messenger/responseMiddleware.ts rename to packages/woop-network/src/messenger/responseMiddleware.ts index 7dffa15..0ea68af 100644 --- a/packages/harmony-network/src/messenger/responseMiddleware.ts +++ b/packages/woop-network/src/messenger/responseMiddleware.ts @@ -1,11 +1,11 @@ /** * @packageDocumentation - * @module harmony-network + * @module woop-network * @hidden */ import { RPCResponseBody } from '../types'; -import { isObject } from '@harmony-js/utils'; +import { isObject } from '@woop-js/utils'; /** * @class ResponseMiddleware * @description Response middleware of RPC diff --git a/packages/harmony-network/src/providers/baseProvider.ts b/packages/woop-network/src/providers/baseProvider.ts similarity index 98% rename from packages/harmony-network/src/providers/baseProvider.ts rename to packages/woop-network/src/providers/baseProvider.ts index 794ec91..ab604b8 100644 --- a/packages/harmony-network/src/providers/baseProvider.ts +++ b/packages/woop-network/src/providers/baseProvider.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-network + * @module woop-network * @hidden */ diff --git a/packages/harmony-network/src/providers/baseSocket.ts b/packages/woop-network/src/providers/baseSocket.ts similarity index 97% rename from packages/harmony-network/src/providers/baseSocket.ts rename to packages/woop-network/src/providers/baseSocket.ts index 96edf1f..32dc682 100644 --- a/packages/harmony-network/src/providers/baseSocket.ts +++ b/packages/woop-network/src/providers/baseSocket.ts @@ -1,10 +1,10 @@ /** * @packageDocumentation - * @module harmony-network + * @module woop-network * @hidden */ -import { isWs } from '@harmony-js/utils'; +import { isWs } from '@woop-js/utils'; import mitt from 'mitt'; import { BaseProvider } from './baseProvider'; diff --git a/packages/harmony-network/src/providers/defaultFetcher.ts b/packages/woop-network/src/providers/defaultFetcher.ts similarity index 97% rename from packages/harmony-network/src/providers/defaultFetcher.ts rename to packages/woop-network/src/providers/defaultFetcher.ts index bd7076a..90f41b2 100644 --- a/packages/harmony-network/src/providers/defaultFetcher.ts +++ b/packages/woop-network/src/providers/defaultFetcher.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-network + * @module woop-network * @hidden */ diff --git a/packages/harmony-network/src/providers/emitter.ts b/packages/woop-network/src/providers/emitter.ts similarity index 98% rename from packages/harmony-network/src/providers/emitter.ts rename to packages/woop-network/src/providers/emitter.ts index 9877f99..52c23c4 100644 --- a/packages/harmony-network/src/providers/emitter.ts +++ b/packages/woop-network/src/providers/emitter.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-network + * @module woop-network */ import mitt from 'mitt'; diff --git a/packages/harmony-network/src/providers/http.ts b/packages/woop-network/src/providers/http.ts similarity index 99% rename from packages/harmony-network/src/providers/http.ts rename to packages/woop-network/src/providers/http.ts index 404805d..59fa941 100644 --- a/packages/harmony-network/src/providers/http.ts +++ b/packages/woop-network/src/providers/http.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-network + * @module woop-network */ import { BaseProvider } from './baseProvider'; diff --git a/packages/harmony-network/src/providers/provider.ts b/packages/woop-network/src/providers/provider.ts similarity index 94% rename from packages/harmony-network/src/providers/provider.ts rename to packages/woop-network/src/providers/provider.ts index 296a502..4caa393 100644 --- a/packages/harmony-network/src/providers/provider.ts +++ b/packages/woop-network/src/providers/provider.ts @@ -1,11 +1,11 @@ /** * @packageDocumentation - * @module harmony-network + * @module woop-network */ import { HttpProvider } from './http'; import { WSProvider } from './ws'; -import { defaultConfig, isHttp, isWs } from '@harmony-js/utils'; +import { defaultConfig, isHttp, isWs } from '@woop-js/utils'; export enum ProviderType { http = 'http', diff --git a/packages/harmony-network/src/providers/ws.ts b/packages/woop-network/src/providers/ws.ts similarity index 98% rename from packages/harmony-network/src/providers/ws.ts rename to packages/woop-network/src/providers/ws.ts index 4035d8b..fb6934e 100644 --- a/packages/harmony-network/src/providers/ws.ts +++ b/packages/woop-network/src/providers/ws.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-network + * @module woop-network */ // TODO: implement Websocket Provider @@ -11,7 +11,7 @@ import { SocketState, // EmittType, } from './baseSocket'; -import { isWs, isObject, isArray } from '@harmony-js/utils'; +import { isWs, isObject, isArray } from '@woop-js/utils'; import { JsonRpc } from '../rpcMethod/builder'; import { composeMiddleware } from '../rpcMethod/net'; import { RPCRequestPayload } from '../types'; diff --git a/packages/harmony-network/src/rpcMethod/builder.ts b/packages/woop-network/src/rpcMethod/builder.ts similarity index 97% rename from packages/harmony-network/src/rpcMethod/builder.ts rename to packages/woop-network/src/rpcMethod/builder.ts index 4210335..0e356e1 100644 --- a/packages/harmony-network/src/rpcMethod/builder.ts +++ b/packages/woop-network/src/rpcMethod/builder.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-network + * @module woop-network * @hidden */ diff --git a/packages/harmony-network/src/rpcMethod/net.ts b/packages/woop-network/src/rpcMethod/net.ts similarity index 97% rename from packages/harmony-network/src/rpcMethod/net.ts rename to packages/woop-network/src/rpcMethod/net.ts index 656f084..8313edb 100644 --- a/packages/harmony-network/src/rpcMethod/net.ts +++ b/packages/woop-network/src/rpcMethod/net.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-network + * @module woop-network * @ignore */ diff --git a/packages/woop-network/src/rpcMethod/rpc.ts b/packages/woop-network/src/rpcMethod/rpc.ts new file mode 100644 index 0000000..4a2e28d --- /dev/null +++ b/packages/woop-network/src/rpcMethod/rpc.ts @@ -0,0 +1,136 @@ +/** + # @woop-js/network + +This package provides a collection of apis to create messengers (HTTP, WebSocket) to connect to blockchain networks. + +## Installation + +``` +npm install @woop-js/network +``` + +## Usage + +```javascript +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.Woop, ChainID.WikiTestnet); // for local ChainID.WikiLocal +const customWSMessenger = new Messenger(ws, ChainType.Woop, ChainID.WikiTestnet); // for local ChainID.WikiLocal +``` + * + * @packageDocumentation + * @module woop-network + */ + +/**@ignore */ +export enum RPCMethod { + // 1. wiki_getBlockByHash + GetBlockByHash = 'wiki_getBlockByHash', + // 2. wiki_getBlockByNumber + GetBlockByNumber = 'wiki_getBlockByNumber', + // 3. wiki_getBlockTransactionCountByHash + GetBlockTransactionCountByHash = 'wiki_getBlockTransactionCountByHash', + // 4. wiki_getBlockTransactionCountByNumber + GetBlockTransactionCountByNumber = 'wiki_getBlockTransactionCountByNumber', + // 5. wiki_getCode + GetCode = 'wiki_getCode', + // 6. wiki_getTransactionByBlockHashAndIndex + GetTransactionByBlockHashAndIndex = 'wiki_getTransactionByBlockHashAndIndex', + // 7. wiki_getTransactionByBlockNumberAndIndex + GetTransactionByBlockNumberAndIndex = 'wiki_getTransactionByBlockNumberAndIndex', + // 8. wiki_getTransactionByHash + GetTransactionByHash = 'wiki_getTransactionByHash', + + GetTransactionReceipt = 'wiki_getTransactionReceipt', + + GetCXReceiptByHash = 'wiki_getCXReceiptByHash', + // 9. wiki_syncing + Syncing = 'wiki_syncing', + // 10. net_peerCount + PeerCount = 'net_peerCount', + + // 11. wiki_getBalance + GetBalance = 'wiki_getBalance', + // 12. wiki_getStorageAt + GetStorageAt = 'wiki_getStorageAt', + // 13. wiki_getTransactionCount + GetTransactionCount = 'wiki_getTransactionCount', + // 14. wiki_sendTransaction + SendTransaction = 'wiki_sendTransaction', + // 15. wiki_sendRawTransaction + SendRawTransaction = 'wiki_sendRawTransaction', + // 16. wiki_subscribe + Subscribe = 'wiki_subscribe', + // 17. wiki_getlogs + GetPastLogs = 'wiki_getLogs', + // 18. wiki_getWork + GetWork = 'wiki_getWork', + // 19. wiki_submitWork + // SubmitWork = 'wiki_submitWork', + // 20. wiki_getProof + GetProof = 'wiki_getProof', + // 21, wiki_getFilterChanges + GetFilterChanges = 'wiki_getFilterChanges', + // 22. wiki_newPendingTransactionFilter + NewPendingTransactionFilter = 'wiki_newPendingTransactionFilter', + // 23. wiki_newBlockFilter + NewBlockFilter = 'wiki_newBlockFilter', + // 24. wiki_newFilter + NewFilter = 'wiki_newFilter', + // 25. wiki_call + Call = 'wiki_call', + // 26. wiki_estimateGas + EstimateGas = 'wiki_estimateGas', + // 27. wiki_gasPrice + GasPrice = 'wiki_gasPrice', + // 28. wiki_blockNumber + BlockNumber = 'wiki_blockNumber', + // 29. wiki_unsubscribe + UnSubscribe = 'wiki_unsubscribe', + // 30. net_version + NetVersion = 'net_version', + // 31. wiki_protocolVersion + ProtocolVersion = 'wiki_protocolVersion', + // 32. wiki_getShardingStructure + GetShardingStructure = 'wiki_getShardingStructure', + // 33. wiki_sendRawStakingTransaction + SendRawStakingTransaction = 'wiki_sendRawStakingTransaction', + // 34. wiki_getAccountNonce + GetAccountNonce = 'wiki_getAccountNonce', + // 35. wiki_getBlocks + GetBlocks = 'wiki_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 +} diff --git a/packages/harmony-network/src/subscriptions/LogSub.ts b/packages/woop-network/src/subscriptions/LogSub.ts similarity index 98% rename from packages/harmony-network/src/subscriptions/LogSub.ts rename to packages/woop-network/src/subscriptions/LogSub.ts index 07f2412..8ad56f4 100644 --- a/packages/harmony-network/src/subscriptions/LogSub.ts +++ b/packages/woop-network/src/subscriptions/LogSub.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-network + * @module woop-network */ import { Messenger } from '../messenger/messenger'; diff --git a/packages/harmony-network/src/subscriptions/NewHeadersSub.ts b/packages/woop-network/src/subscriptions/NewHeadersSub.ts similarity index 94% rename from packages/harmony-network/src/subscriptions/NewHeadersSub.ts rename to packages/woop-network/src/subscriptions/NewHeadersSub.ts index 42ea20e..04a40a8 100644 --- a/packages/harmony-network/src/subscriptions/NewHeadersSub.ts +++ b/packages/woop-network/src/subscriptions/NewHeadersSub.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-network + * @module woop-network */ import { Messenger } from '../messenger/messenger'; diff --git a/packages/harmony-network/src/subscriptions/NewPendingTransactionsSub.ts b/packages/woop-network/src/subscriptions/NewPendingTransactionsSub.ts similarity index 94% rename from packages/harmony-network/src/subscriptions/NewPendingTransactionsSub.ts rename to packages/woop-network/src/subscriptions/NewPendingTransactionsSub.ts index d04d39a..ae728f9 100644 --- a/packages/harmony-network/src/subscriptions/NewPendingTransactionsSub.ts +++ b/packages/woop-network/src/subscriptions/NewPendingTransactionsSub.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-network + * @module woop-network */ import { Messenger } from '../messenger/messenger'; diff --git a/packages/harmony-network/src/subscriptions/Subscription.ts b/packages/woop-network/src/subscriptions/Subscription.ts similarity index 98% rename from packages/harmony-network/src/subscriptions/Subscription.ts rename to packages/woop-network/src/subscriptions/Subscription.ts index 136a3c4..c671d7d 100644 --- a/packages/harmony-network/src/subscriptions/Subscription.ts +++ b/packages/woop-network/src/subscriptions/Subscription.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-network + * @module woop-network */ import { Messenger } from '../messenger/messenger'; diff --git a/packages/harmony-network/src/subscriptions/SyncingSub.ts b/packages/woop-network/src/subscriptions/SyncingSub.ts similarity index 97% rename from packages/harmony-network/src/subscriptions/SyncingSub.ts rename to packages/woop-network/src/subscriptions/SyncingSub.ts index be0601f..e7aaef6 100644 --- a/packages/harmony-network/src/subscriptions/SyncingSub.ts +++ b/packages/woop-network/src/subscriptions/SyncingSub.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-network + * @module woop-network * @hidden */ diff --git a/packages/harmony-network/src/tracker/baseTracker.ts b/packages/woop-network/src/tracker/baseTracker.ts similarity index 98% rename from packages/harmony-network/src/tracker/baseTracker.ts rename to packages/woop-network/src/tracker/baseTracker.ts index 59b15a0..7ac4120 100644 --- a/packages/harmony-network/src/tracker/baseTracker.ts +++ b/packages/woop-network/src/tracker/baseTracker.ts @@ -1,10 +1,10 @@ /** * @packageDocumentation - * @module harmony-network + * @module woop-network * @hidden */ -import { isHex, hexToNumber } from '@harmony-js/utils'; +import { isHex, hexToNumber } from '@woop-js/utils'; import { Emitter } from '../providers/emitter'; const sec = 1000; diff --git a/packages/harmony-network/src/tracker/pollingTracker.ts b/packages/woop-network/src/tracker/pollingTracker.ts similarity index 99% rename from packages/harmony-network/src/tracker/pollingTracker.ts rename to packages/woop-network/src/tracker/pollingTracker.ts index 5fc973a..9da471f 100644 --- a/packages/harmony-network/src/tracker/pollingTracker.ts +++ b/packages/woop-network/src/tracker/pollingTracker.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-network + * @module woop-network * @hidden */ diff --git a/packages/harmony-network/src/tracker/subscribeTracker.ts b/packages/woop-network/src/tracker/subscribeTracker.ts similarity index 98% rename from packages/harmony-network/src/tracker/subscribeTracker.ts rename to packages/woop-network/src/tracker/subscribeTracker.ts index 2ca9a03..a356e74 100644 --- a/packages/harmony-network/src/tracker/subscribeTracker.ts +++ b/packages/woop-network/src/tracker/subscribeTracker.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-network + * @module woop-network * @hidden */ diff --git a/packages/harmony-network/src/types.ts b/packages/woop-network/src/types.ts similarity index 97% rename from packages/harmony-network/src/types.ts rename to packages/woop-network/src/types.ts index 7d6b56f..547b735 100644 --- a/packages/harmony-network/src/types.ts +++ b/packages/woop-network/src/types.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-network + * @module woop-network * @ignore */ diff --git a/packages/harmony-network/src/util.ts b/packages/woop-network/src/util.ts similarity index 96% rename from packages/harmony-network/src/util.ts rename to packages/woop-network/src/util.ts index c87ac95..9e693d2 100644 --- a/packages/harmony-network/src/util.ts +++ b/packages/woop-network/src/util.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-network + * @module woop-network * @hidden */ diff --git a/packages/harmony-network/tsconfig.json b/packages/woop-network/tsconfig.json similarity index 77% rename from packages/harmony-network/tsconfig.json rename to packages/woop-network/tsconfig.json index fac7fc2..6f80e28 100644 --- a/packages/harmony-network/tsconfig.json +++ b/packages/woop-network/tsconfig.json @@ -5,5 +5,5 @@ "outDir": "dist" }, "include": ["src", "../../typings/**/*.d.ts"], - "references": [{"path": "../harmony-utils"}] + "references": [{"path": "../woop-utils"}] } diff --git a/packages/harmony-network/tsconfig.test.json b/packages/woop-network/tsconfig.test.json similarity index 100% rename from packages/harmony-network/tsconfig.test.json rename to packages/woop-network/tsconfig.test.json diff --git a/packages/harmony-staking/LICENSE b/packages/woop-staking/LICENSE similarity index 100% rename from packages/harmony-staking/LICENSE rename to packages/woop-staking/LICENSE diff --git a/packages/harmony-staking/README.md b/packages/woop-staking/README.md similarity index 73% rename from packages/harmony-staking/README.md rename to packages/woop-staking/README.md index 3134faa..e64ee69 100644 --- a/packages/harmony-staking/README.md +++ b/packages/woop-staking/README.md @@ -1,19 +1,19 @@ -# @harmony-js/staking +# @woop-js/staking This package provides a collection of apis to create, sign/send staking transaction, and receive confirm/receipt. ## Installation ``` -npm install @harmony-js/staking +npm install @woop-js/staking ``` ## 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,21 +22,21 @@ 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, }, ); ``` Below, examples show how to send delegate, undelegate, and collect rewards staking transactions. First, set the chainId, gasLimit, gasPrice for all subsequent staking transactions ```javascript -hmy.stakings.setTxParams({ +wiki.stakings.setTxParams({ gasLimit: 25000, - gasPrice: numberToHex(new hmy.utils.Unit('1').asGwei().toWei()), + gasPrice: numberToHex(new wiki.utils.Unit('1').asGwei().toWei()), chainId: 2 }); ``` @@ -44,7 +44,7 @@ hmy.stakings.setTxParams({ Create delegate staking transaction ```javascript -const delegate = hmy.stakings.delegate({ +const delegate = wiki.stakings.delegate({ delegatorAddress: 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7', validatorAddress: 'one1vfqqagdzz352mtvdl69v0hw953hm993n6v26yl', amount: numberToHex(new Unit(1000).asOne().toWei()) @@ -55,9 +55,9 @@ const delegateStakingTx = delegate.build(); Sign and send the delegate transaction and receive confirmation ```javascript // key corresponds to one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7, only has testnet balance -hmy.wallet.addByPrivateKey('45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e'); +wiki.wallet.addByPrivateKey('45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e'); -hmy.wallet.signStaking(delegateStakingTx).then(signedTxn => { +wiki.wallet.signStaking(delegateStakingTx).then(signedTxn => { signedTxn.sendTransaction().then(([tx, hash]) => { console.log(hash); signedTxn.confirm(hash).then(response => { @@ -70,7 +70,7 @@ hmy.wallet.signStaking(delegateStakingTx).then(signedTxn => { Similarily, undelegate and collect reward transactions can be composed, signed and sent Create undelegate staking transaction ```javascript -const undelegate = hmy.stakings.undelegate({ +const undelegate = wiki.stakings.undelegate({ delegatorAddress: 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7', validatorAddress: 'one1vfqqagdzz352mtvdl69v0hw953hm993n6v26yl', amount: numberToHex(new Unit(1000).asOne().toWei()) @@ -80,7 +80,7 @@ const undelegateStakingTx = undelegate.build(); Create collect rewards staking transaction ```javascript -const collectRewards = hmy.stakings.collectRewards({ +const collectRewards = wiki.stakings.collectRewards({ delegatorAddress: 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7' }); const collectRewardsStakingTx = collectRewards.build(); diff --git a/packages/harmony-staking/package.json b/packages/woop-staking/package.json similarity index 68% rename from packages/harmony-staking/package.json rename to packages/woop-staking/package.json index 46d312a..45b4c1e 100644 --- a/packages/harmony-staking/package.json +++ b/packages/woop-staking/package.json @@ -1,7 +1,7 @@ { - "name": "@harmony-js/staking", + "name": "@woop-js/staking", "version": "0.1.58", - "description": "staking transaction package for harmony", + "description": "staking transaction package for woop", "main": "dist/index.js", "node": "dist/index.js", "browser": "dist/index.js", @@ -18,10 +18,10 @@ "author": "", "license": "MIT", "dependencies": { - "@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/crypto": "0.1.58", + "@woop-js/network": "0.1.58", + "@woop-js/transaction": "0.1.58", + "@woop-js/utils": "0.1.58", "text-encoding": "^0.7.0" }, "gitHead": "56606e9365721729a490c27d6a294e0daf90fbdf" diff --git a/packages/harmony-staking/src/factory.ts b/packages/woop-staking/src/factory.ts similarity index 95% rename from packages/harmony-staking/src/factory.ts rename to packages/woop-staking/src/factory.ts index e4bd594..c681971 100644 --- a/packages/harmony-staking/src/factory.ts +++ b/packages/woop-staking/src/factory.ts @@ -1,10 +1,10 @@ /** * @packageDocumentation - * @module harmony-staking + * @module woop-staking */ -import { Messenger } from '@harmony-js/network'; -import { Signature } from '@harmony-js/crypto'; +import { Messenger } from '@woop-js/network'; +import { Signature } from '@woop-js/crypto'; import { Directive, @@ -18,8 +18,8 @@ import { Decimal, StakingTransaction, } from './stakingTransaction'; -import { Unit } from '@harmony-js/utils'; -import { TxStatus } from '@harmony-js/transaction'; +import { Unit } from '@woop-js/utils'; +import { TxStatus } from '@woop-js/transaction'; /** @hidden */ export interface DescriptionInterface { diff --git a/packages/harmony-staking/src/index.ts b/packages/woop-staking/src/index.ts similarity index 80% rename from packages/harmony-staking/src/index.ts rename to packages/woop-staking/src/index.ts index 6361471..a0d1e00 100644 --- a/packages/harmony-staking/src/index.ts +++ b/packages/woop-staking/src/index.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-staking + * @module woop-staking * @ignore */ diff --git a/packages/harmony-staking/src/stakingTransaction.ts b/packages/woop-staking/src/stakingTransaction.ts similarity index 93% rename from packages/harmony-staking/src/stakingTransaction.ts rename to packages/woop-staking/src/stakingTransaction.ts index 515bba9..14d506e 100644 --- a/packages/harmony-staking/src/stakingTransaction.ts +++ b/packages/woop-staking/src/stakingTransaction.ts @@ -1,20 +1,20 @@ /** - * # @harmony-js/staking + * # @woop-js/staking This package provides a collection of apis to create, sign/send staking transaction, and receive confirm/receipt. ## Installation ``` -npm install @harmony-js/staking +npm install @woop-js/staking ``` ## 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,21 +23,21 @@ 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, * }, * ); ``` Below, examples show how to send delegate, undelegate, and collect rewards staking transactions. First, set the chainId, gasLimit, gasPrice for all subsequent staking transactions ```javascript -* hmy.stakings.setTxParams({ +* wiki.stakings.setTxParams({ * gasLimit: 25000, -* gasPrice: numberToHex(new hmy.utils.Unit('1').asGwei().toWei()), +* gasPrice: numberToHex(new wiki.utils.Unit('1').asGwei().toWei()), * chainId: 2 * }); ``` @@ -45,7 +45,7 @@ Below, examples show how to send delegate, undelegate, and collect rewards staki Create delegate staking transaction ```javascript -* const delegate = hmy.stakings.delegate({ +* const delegate = wiki.stakings.delegate({ * delegatorAddress: 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7', * validatorAddress: 'one1vfqqagdzz352mtvdl69v0hw953hm993n6v26yl', * amount: numberToHex(new Unit(1000).asOne().toWei()) @@ -56,9 +56,9 @@ Create delegate staking transaction Sign and send the delegate transaction and receive confirmation ```javascript * // key corresponds to one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7, only has testnet balance -* hmy.wallet.addByPrivateKey('45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e'); +* wiki.wallet.addByPrivateKey('45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e'); -* hmy.wallet.signStaking(delegateStakingTx).then(signedTxn => { +* wiki.wallet.signStaking(delegateStakingTx).then(signedTxn => { * signedTxn.sendTransaction().then(([tx, hash]) => { * console.log(hash); * signedTxn.confirm(hash).then(response => { @@ -71,7 +71,7 @@ Sign and send the delegate transaction and receive confirmation Similarily, undelegate and collect reward transactions can be composed, signed and sent Create undelegate staking transaction ```javascript -* const undelegate = hmy.stakings.undelegate({ +* const undelegate = wiki.stakings.undelegate({ * delegatorAddress: 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7', * validatorAddress: 'one1vfqqagdzz352mtvdl69v0hw953hm993n6v26yl', * amount: numberToHex(new Unit(1000).asOne().toWei()) @@ -81,7 +81,7 @@ Create undelegate staking transaction Create collect rewards staking transaction ```javascript -* const collectRewards = hmy.stakings.collectRewards({ +* const collectRewards = wiki.stakings.collectRewards({ * delegatorAddress: 'one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7' * }); * const collectRewardsStakingTx = collectRewards.build(); @@ -89,7 +89,7 @@ Create collect rewards staking transaction Also, similar to normal transaction, signing and sending can be performed asynchronously. * @packageDocumentation - * @module harmony-staking + * @module woop-staking */ // tslint:disable: max-classes-per-file @@ -104,10 +104,10 @@ import { Signature, splitSignature, stripZeros, -} from '@harmony-js/crypto'; -import { Messenger, RPCMethod } from '@harmony-js/network'; -import { defaultMessenger, TransactionBase, TxStatus } from '@harmony-js/transaction'; -import { numberToHex, Unit } from '@harmony-js/utils'; +} from '@woop-js/crypto'; +import { Messenger, RPCMethod } from '@woop-js/network'; +import { defaultMessenger, TransactionBase, TxStatus } from '@woop-js/transaction'; +import { numberToHex, Unit } from '@woop-js/utils'; import { TextEncoder } from 'text-encoding'; /** @hidden */ diff --git a/packages/harmony-staking/test/testSign.test.ts b/packages/woop-staking/test/testSign.test.ts similarity index 97% rename from packages/harmony-staking/test/testSign.test.ts rename to packages/woop-staking/test/testSign.test.ts index 08f9d6e..8953c6d 100644 --- a/packages/harmony-staking/test/testSign.test.ts +++ b/packages/woop-staking/test/testSign.test.ts @@ -1,21 +1,21 @@ /** * @packageDocumentation - * @module harmony-staking + * @module woop-staking * @ignore */ -import { Wallet } from '@harmony-js/account'; -import { getAddressFromPrivateKey } from '@harmony-js/crypto'; -import { HttpProvider, Messenger } from '@harmony-js/network'; -import { ChainID, ChainType, isValidAddress } from '@harmony-js/utils'; +import { Wallet } from '@woop-js/account'; +import { getAddressFromPrivateKey } from '@woop-js/crypto'; +import { HttpProvider, Messenger } from '@woop-js/network'; +import { ChainID, ChainType, isValidAddress } from '@woop-js/utils'; // tslint:disable-next-line: no-implicit-dependencies import fetch from 'jest-fetch-mock'; const http = new HttpProvider('http://mock.com'); // const ws = new WSProvider('ws://mock.com'); -const msgHttp = new Messenger(http, ChainType.Harmony, ChainID.HmyLocal); -// const msgWs = new Messenger(ws, ChainType.Harmony, ChainID.HmyLocal); +const msgHttp = new Messenger(http, ChainType.Woop, ChainID.WikiLocal); +// const msgWs = new Messenger(ws, ChainType.Woop, ChainID.WikiLocal); const walletHttp = new Wallet(msgHttp); diff --git a/packages/harmony-staking/test/transactions.json b/packages/woop-staking/test/transactions.json similarity index 98% rename from packages/harmony-staking/test/transactions.json rename to packages/woop-staking/test/transactions.json index dc8c504..07fdc06 100644 --- a/packages/harmony-staking/test/transactions.json +++ b/packages/woop-staking/test/transactions.json @@ -6,7 +6,7 @@ "description": { "name": "Alice", "identity": "alice", - "website": "alice.harmony.one", + "website": "alice.wikiwoop.com", "securityContact": "Bob", "details": "Don't mess with me!!!" }, @@ -36,7 +36,7 @@ "description": { "name": "Alice", "identity": "alice", - "website": "alice.harmony.one", + "website": "alice.wikiwoop.com", "securityContact": "Bob", "details": "Don't mess with me!!!" }, diff --git a/packages/harmony-staking/test/tsconfig.json b/packages/woop-staking/test/tsconfig.json similarity index 100% rename from packages/harmony-staking/test/tsconfig.json rename to packages/woop-staking/test/tsconfig.json diff --git a/packages/harmony-staking/tsconfig.json b/packages/woop-staking/tsconfig.json similarity index 55% rename from packages/harmony-staking/tsconfig.json rename to packages/woop-staking/tsconfig.json index d9d0b6e..e77af44 100644 --- a/packages/harmony-staking/tsconfig.json +++ b/packages/woop-staking/tsconfig.json @@ -6,9 +6,9 @@ }, "include": ["src", "../../typings/**/*.d.ts"], "references": [ - { "path": "../harmony-utils" }, - { "path": "../harmony-crypto" }, - { "path": "../harmony-network" }, - { "path": "../harmony-transaction" } + { "path": "../woop-utils" }, + { "path": "../woop-crypto" }, + { "path": "../woop-network" }, + { "path": "../woop-transaction" } ] } diff --git a/packages/harmony-staking/tsconfig.test.json b/packages/woop-staking/tsconfig.test.json similarity index 100% rename from packages/harmony-staking/tsconfig.test.json rename to packages/woop-staking/tsconfig.test.json diff --git a/packages/harmony-transaction/LICENSE b/packages/woop-transaction/LICENSE similarity index 100% rename from packages/harmony-transaction/LICENSE rename to packages/woop-transaction/LICENSE diff --git a/packages/harmony-transaction/README.md b/packages/woop-transaction/README.md similarity index 79% rename from packages/harmony-transaction/README.md rename to packages/woop-transaction/README.md index bd84bd1..5ad0fef 100644 --- a/packages/harmony-transaction/README.md +++ b/packages/woop-transaction/README.md @@ -1,19 +1,19 @@ -# @harmony-js/transaction +# @woop-js/transaction This package provides a collection of apis to create, sign/send transaction, and receive confirm/receipt. ## Installation ``` -npm install @harmony-js/transaction +npm install @woop-js/transaction ``` ## 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, }, ); ``` Creating a new transaction using parameters ```javascript -const txn = hmy.transactions.newTx({ +const txn = wiki.transactions.newTx({ to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2', value: new Unit(1).asOne().toWei(), // gas limit, you can use string @@ -45,14 +45,14 @@ const txn = hmy.transactions.newTx({ // 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(), }); ``` Recovering transaction from raw transaction hash ```javascript const raw = '0xf86d21843b9aca00825208808094d6ba69da5b45ec98b53e3258d7de756a567b6763880de0b6b3a76400008028a0da8887719f377401963407fc1d82d2ab52404600cf7bea37c27bd2dfd7c86aaaa03c405b0843394442b303256a804bde835821a8a77bd88a2ced9ffdc8b0a409e9'; -const tx = hmy.transactions.recover(raw); +const tx = wiki.transactions.recover(raw); ``` Getting the RLP encoding of a transaction (rawTransaction), along with raw transaction field values that were encoded @@ -63,9 +63,9 @@ const [encoded, raw] = txn.getRLPUnsigned() Sign the transaction using a wallet and send the transaction, wait for confirmation and print receipt ```javascript // key corresponds to one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7, only has testnet balance -hmy.wallet.addByPrivateKey('45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e'); +wiki.wallet.addByPrivateKey('45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e'); -hmy.wallet.signTransaction(txn).then(signedTxn => { +wiki.wallet.signTransaction(txn).then(signedTxn => { signedTxn.sendTransaction().then(([tx, hash]) => { console.log('tx hash: ' + hash); signedTxn.confirm(hash).then(response => { @@ -78,9 +78,9 @@ hmy.wallet.signTransaction(txn).then(signedTxn => { Asynchronous transaction sign, send, and confirm ```javascript async function transfer() { - hmy.wallet.addByPrivateKey('45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e'); + wiki.wallet.addByPrivateKey('45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e'); - const signedTxn = await hmy.wallet.signTransaction(txn); + const signedTxn = await wiki.wallet.signTransaction(txn); signedTxn .observed() .on('transactionHash', (txnHash) => { @@ -126,7 +126,7 @@ async function transfer() { console.log(''); console.log('please see detail in explorer:'); console.log(''); - console.log('https://explorer.testnet.harmony.one/#/tx/' + txnHash); + console.log('https://testnet.wikiwoop.com/#/tx/' + txnHash); console.log(''); process.exit(); } @@ -139,7 +139,7 @@ async function transfer() { console.log(''); console.log('please see detail in explorer:'); console.log(''); - console.log('https://explorer.testnet.harmony.one/#/tx/' + txnHash); + console.log('https://testnet.wikiwoop.com/#/tx/' + txnHash); console.log(''); process.exit(); } diff --git a/packages/harmony-transaction/package.json b/packages/woop-transaction/package.json similarity index 72% rename from packages/harmony-transaction/package.json rename to packages/woop-transaction/package.json index 13b619b..f0de6c4 100644 --- a/packages/harmony-transaction/package.json +++ b/packages/woop-transaction/package.json @@ -1,7 +1,7 @@ { - "name": "@harmony-js/transaction", + "name": "@woop-js/transaction", "version": "0.1.58", - "description": "transaction package for harmony", + "description": "transaction package for woop", "main": "dist/index.js", "node": "dist/index.js", "browser": "dist/index.js", @@ -18,9 +18,9 @@ "author": "neeboo@firestack.one", "license": "MIT", "dependencies": { - "@harmony-js/crypto": "0.1.58", - "@harmony-js/network": "0.1.58", - "@harmony-js/utils": "0.1.58" + "@woop-js/crypto": "0.1.58", + "@woop-js/network": "0.1.58", + "@woop-js/utils": "0.1.58" }, "gitHead": "56606e9365721729a490c27d6a294e0daf90fbdf" } diff --git a/packages/harmony-transaction/src/abstractTransaction.ts b/packages/woop-transaction/src/abstractTransaction.ts similarity index 92% rename from packages/harmony-transaction/src/abstractTransaction.ts rename to packages/woop-transaction/src/abstractTransaction.ts index 5e0a288..88af4cc 100644 --- a/packages/harmony-transaction/src/abstractTransaction.ts +++ b/packages/woop-transaction/src/abstractTransaction.ts @@ -1,10 +1,10 @@ /** * @packageDocumentation - * @module harmony-transaction + * @module woop-transaction * @hidden */ -import { Messenger } from '@harmony-js/network'; +import { Messenger } from '@woop-js/network'; import { TxStatus } from './types'; export abstract class AbstractTransaction { diff --git a/packages/harmony-transaction/src/factory.ts b/packages/woop-transaction/src/factory.ts similarity index 86% rename from packages/harmony-transaction/src/factory.ts rename to packages/woop-transaction/src/factory.ts index b54db12..94184e9 100644 --- a/packages/harmony-transaction/src/factory.ts +++ b/packages/woop-transaction/src/factory.ts @@ -2,11 +2,11 @@ * ## hhahaha * * @packageDocumentation - * @module harmony-transaction + * @module woop-transaction */ -import { getContractAddress, getAddress } from '@harmony-js/crypto'; -import { Messenger } from '@harmony-js/network'; +import { getContractAddress, getAddress } from '@woop-js/crypto'; +import { Messenger } from '@woop-js/network'; import { Transaction } from './transaction'; import { ShardingTransaction } from './shardingTransaction'; import { TxParams, TxStatus } from './types'; @@ -41,13 +41,13 @@ export class TransactionFactory { * * @example * ```javascript - * const txn = hmy.transactions.newTx({ + * const txn = wiki.transactions.newTx({ * to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2', * value: '10000', * gasLimit: '210000', * shardID: 0, * toShardID: 0, - * gasPrice: new hmy.utils.Unit('100').asGwei().toWei(), + * gasPrice: new wiki.utils.Unit('100').asGwei().toWei(), * }); * ``` */ @@ -65,7 +65,7 @@ export class TransactionFactory { * * @example * ```javascript - * const cloneTxn = hmy.transactions.clone(txn); + * const cloneTxn = wiki.transactions.clone(txn); * console.log(cloneTxn) * ``` */ @@ -79,7 +79,7 @@ export class TransactionFactory { * ```javascript * txHash = '0xf8698085174876e8008252088080949d72989b68777a1f3ffd6f1db079f1928373ee52830186a08027a0ab8229ff5d5240948098f26372eaed9ab2e9be23e8594b08e358ca56a47f8ae9a0084e5c4d1fec496af444423d8a714f65c079260ff01a1be1de7005dd424adf44' * - * const recoverTx = hmy.transactions.recover(txHash); + * const recoverTx = wiki.transactions.recover(txHash); * console.log(recoverTx); * ``` */ diff --git a/packages/harmony-transaction/src/index.ts b/packages/woop-transaction/src/index.ts similarity index 89% rename from packages/harmony-transaction/src/index.ts rename to packages/woop-transaction/src/index.ts index ec7ef4c..a263e9f 100644 --- a/packages/harmony-transaction/src/index.ts +++ b/packages/woop-transaction/src/index.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-transaction + * @module woop-transaction * @hidden */ diff --git a/packages/harmony-transaction/src/shardingTransaction.ts b/packages/woop-transaction/src/shardingTransaction.ts similarity index 90% rename from packages/harmony-transaction/src/shardingTransaction.ts rename to packages/woop-transaction/src/shardingTransaction.ts index 4d60c3f..3219199 100644 --- a/packages/harmony-transaction/src/shardingTransaction.ts +++ b/packages/woop-transaction/src/shardingTransaction.ts @@ -1,11 +1,11 @@ /** * @packageDocumentation - * @module harmony-transaction + * @module woop-transaction * @hidden */ -import { Messenger } from '@harmony-js/network'; -import { AddressSuffix } from '@harmony-js/utils'; +import { Messenger } from '@woop-js/network'; +import { AddressSuffix } from '@woop-js/utils'; import { Transaction } from './transaction'; import { TxParams, TxStatus } from './types'; import { defaultMessenger } from './utils'; diff --git a/packages/harmony-transaction/src/transaction.ts b/packages/woop-transaction/src/transaction.ts similarity index 95% rename from packages/harmony-transaction/src/transaction.ts rename to packages/woop-transaction/src/transaction.ts index 402507c..cb9768e 100644 --- a/packages/harmony-transaction/src/transaction.ts +++ b/packages/woop-transaction/src/transaction.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-transaction + * @module woop-transaction */ import { @@ -11,9 +11,9 @@ import { stripZeros, Signature, splitSignature, -} from '@harmony-js/crypto'; -import { add0xToString, numberToHex, ChainType, Unit } from '@harmony-js/utils'; -import { Messenger, RPCMethod } from '@harmony-js/network'; +} from '@woop-js/crypto'; +import { add0xToString, numberToHex, ChainType, Unit } from '@woop-js/utils'; +import { Messenger, RPCMethod } from '@woop-js/network'; import { TxParams, TxStatus } from './types'; import { recover, @@ -132,7 +132,7 @@ class Transaction extends TransactionBase { // temp setting to be compatible with eth const fields = - this.messenger.chainType === ChainType.Harmony ? transactionFields : transactionFieldsETH; + this.messenger.chainType === ChainType.Woop ? transactionFields : transactionFieldsETH; fields.forEach((field: any) => { let value = (this.txParams)[field.name] || []; @@ -166,7 +166,7 @@ class Transaction extends TransactionBase { getRLPSigned(raw: any[], signature: Signature): string { // temp setting to be compatible with eth - const rawLength = this.messenger.chainType === ChainType.Harmony ? 11 : 9; + const rawLength = this.messenger.chainType === ChainType.Woop ? 11 : 9; const sig = splitSignature(signature); let v = 27 + (sig.recoveryParam || 0); if (raw.length === rawLength) { @@ -197,7 +197,7 @@ class Transaction extends TransactionBase { recover(rawTransaction: string): Transaction { // temp setting to be compatible with eth const recovered = - this.messenger.chainType === ChainType.Harmony + this.messenger.chainType === ChainType.Woop ? recover(rawTransaction) : recoverETH(rawTransaction); @@ -267,7 +267,7 @@ class Transaction extends TransactionBase { * gasLimit: '230000', * shardID: 1, * toShardID: 0, - * gasPrice: new hmy.utils.Unit('101').asGwei().toWei(), + * gasPrice: new wiki.utils.Unit('101').asGwei().toWei(), * signature: { * r: '0xd693b532a80fed6392b428604171fb32fdbf953728a3a7ecc7d4062b1652c042', * s: '0x24e9c602ac800b983b035700a14b23f78a253ab762deab5dc27e3555a750b354', diff --git a/packages/harmony-transaction/src/transactionBase.ts b/packages/woop-transaction/src/transactionBase.ts similarity index 96% rename from packages/harmony-transaction/src/transactionBase.ts rename to packages/woop-transaction/src/transactionBase.ts index a50b4fd..fcbb1e0 100644 --- a/packages/harmony-transaction/src/transactionBase.ts +++ b/packages/woop-transaction/src/transactionBase.ts @@ -1,12 +1,12 @@ /** * @packageDocumentation - * @module harmony-transaction + * @module woop-transaction * @hidden */ -import { BN, getAddress, HarmonyAddress } from '@harmony-js/crypto'; -import { hexToNumber } from '@harmony-js/utils'; -import { Messenger, RPCMethod, Emitter, HttpProvider, NewHeaders } from '@harmony-js/network'; +import { BN, getAddress, WoopAddress } from '@woop-js/crypto'; +import { hexToNumber } from '@woop-js/utils'; +import { Messenger, RPCMethod, Emitter, HttpProvider, NewHeaders } from '@woop-js/network'; import { TxStatus, TransasctionReceipt } from './types'; import { sleep, TransactionEvents } from './utils'; import { AbstractTransaction } from './abstractTransaction'; @@ -16,9 +16,9 @@ export class TransactionBase implements AbstractTransaction { if (address === '0x') { return '0x'; } else if ( - HarmonyAddress.isValidChecksum(address) || - HarmonyAddress.isValidBech32(address) || - HarmonyAddress.isValidBech32TestNet(address) + WoopAddress.isValidChecksum(address) || + WoopAddress.isValidBech32(address) || + WoopAddress.isValidBech32TestNet(address) ) { return getAddress(address).checksum; } else { @@ -224,7 +224,7 @@ export class TransactionBase implements AbstractTransaction { newHeads.then((p) => { p.onData(async (data: any) => { const blockNumber = - this.messenger.chainPrefix === 'hmy' + this.messenger.chainPrefix === 'wiki' ? data.params.result.Header.number : data.params.result.number; this.emitTrack({ @@ -418,7 +418,7 @@ export class TransactionBase implements AbstractTransaction { newHeads.then((p) => { p.onData(async (data: any) => { const blockNumber = - this.messenger.chainPrefix === 'hmy' + this.messenger.chainPrefix === 'wiki' ? data.params.result.Header.number : data.params.result.number; this.emitCxTrack({ diff --git a/packages/harmony-transaction/src/types.ts b/packages/woop-transaction/src/types.ts similarity index 82% rename from packages/harmony-transaction/src/types.ts rename to packages/woop-transaction/src/types.ts index 621a5fe..085561c 100644 --- a/packages/harmony-transaction/src/types.ts +++ b/packages/woop-transaction/src/types.ts @@ -1,20 +1,20 @@ /** - # @harmony-js/transaction + # @woop-js/transaction This package provides a collection of apis to create, sign/send transaction, and receive confirm/receipt. ## Installation ``` -npm install @harmony-js/transaction +npm install @woop-js/transaction ``` ## 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, * }, * ); ``` Creating a new transaction using parameters ```javascript -* const txn = hmy.transactions.newTx({ +* const txn = wiki.transactions.newTx({ * to: 'one166axnkjmghkf3df7xfvd0hn4dft8kemrza4cd2', * value: new Unit(1).asOne().toWei(), * // gas limit, you can use string @@ -46,14 +46,14 @@ Creating a new transaction using parameters * // 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(), * }); ``` Recovering transaction from raw transaction hash ```javascript * const raw = '0xf86d21843b9aca00825208808094d6ba69da5b45ec98b53e3258d7de756a567b6763880de0b6b3a76400008028a0da8887719f377401963407fc1d82d2ab52404600cf7bea37c27bd2dfd7c86aaaa03c405b0843394442b303256a804bde835821a8a77bd88a2ced9ffdc8b0a409e9'; -* const tx = hmy.transactions.recover(raw); +* const tx = wiki.transactions.recover(raw); ``` Getting the RLP encoding of a transaction (rawTransaction), along with raw transaction field values that were encoded @@ -64,9 +64,9 @@ Getting the RLP encoding of a transaction (rawTransaction), along with raw trans Sign the transaction using a wallet and send the transaction, wait for confirmation and print receipt ```javascript * // key corresponds to one103q7qe5t2505lypvltkqtddaef5tzfxwsse4z7, only has testnet balance -* hmy.wallet.addByPrivateKey('45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e'); +* wiki.wallet.addByPrivateKey('45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e'); -* hmy.wallet.signTransaction(txn).then(signedTxn => { +* wiki.wallet.signTransaction(txn).then(signedTxn => { * signedTxn.sendTransaction().then(([tx, hash]) => { * console.log('tx hash: ' + hash); * signedTxn.confirm(hash).then(response => { @@ -79,9 +79,9 @@ Sign the transaction using a wallet and send the transaction, wait for confirmat Asynchronous transaction sign, send, and confirm ```javascript * async function transfer() { -* hmy.wallet.addByPrivateKey('45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e'); +* wiki.wallet.addByPrivateKey('45e497bd45a9049bcb649016594489ac67b9f052a6cdf5cb74ee2427a60bf25e'); -* const signedTxn = await hmy.wallet.signTransaction(txn); +* const signedTxn = await wiki.wallet.signTransaction(txn); * signedTxn * .observed() * .on('transactionHash', (txnHash) => { @@ -127,7 +127,7 @@ Asynchronous transaction sign, send, and confirm * console.log(''); * console.log('please see detail in explorer:'); * console.log(''); -* console.log('https://explorer.testnet.harmony.one/#/tx/' + txnHash); +* console.log('https://explorer.testnet.woop.one/#/tx/' + txnHash); * console.log(''); * process.exit(); * } @@ -140,7 +140,7 @@ Asynchronous transaction sign, send, and confirm * console.log(''); * console.log('please see detail in explorer:'); * console.log(''); -* console.log('https://explorer.testnet.harmony.one/#/tx/' + txnHash); +* console.log('https://explorer.testnet.woop.one/#/tx/' + txnHash); * console.log(''); * process.exit(); * } @@ -149,10 +149,10 @@ Asynchronous transaction sign, send, and confirm ``` * * @packageDocumentation - * @module harmony-transaction + * @module woop-transaction */ -import { BN, Signature } from '@harmony-js/crypto'; +import { BN, Signature } from '@woop-js/crypto'; export interface TxParams { id: string; diff --git a/packages/harmony-transaction/src/utils.ts b/packages/woop-transaction/src/utils.ts similarity index 97% rename from packages/harmony-transaction/src/utils.ts rename to packages/woop-transaction/src/utils.ts index 9114436..a45d7fe 100644 --- a/packages/harmony-transaction/src/utils.ts +++ b/packages/woop-transaction/src/utils.ts @@ -1,10 +1,10 @@ /** * @packageDocumentation - * @module harmony-transaction + * @module woop-transaction * @hidden */ -import { hexToNumber, isHex, isAddress, strip0x, ChainType } from '@harmony-js/utils'; +import { hexToNumber, isHex, isAddress, strip0x, ChainType } from '@woop-js/utils'; import { decode, encode, @@ -16,8 +16,8 @@ import { Signature, getAddress, sign, -} from '@harmony-js/crypto'; -import { HttpProvider, Messenger } from '@harmony-js/network'; +} from '@woop-js/crypto'; +import { HttpProvider, Messenger } from '@woop-js/network'; import { TxParams } from './types'; import { Transaction } from './transaction'; @@ -261,7 +261,7 @@ export enum TransactionEvents { export const defaultMessenger = new Messenger( new HttpProvider('http://localhost:9500'), - ChainType.Harmony, + ChainType.Woop, ); export const RLPSign = (transaction: Transaction, prv: string): [Signature, string] => { diff --git a/packages/harmony-transaction/test/testSend.test.ts b/packages/woop-transaction/test/testSend.test.ts similarity index 96% rename from packages/harmony-transaction/test/testSend.test.ts rename to packages/woop-transaction/test/testSend.test.ts index fc9ae9a..b0b8be5 100644 --- a/packages/harmony-transaction/test/testSend.test.ts +++ b/packages/woop-transaction/test/testSend.test.ts @@ -1,15 +1,15 @@ /** * @packageDocumentation - * @module harmony-transaction + * @module woop-transaction * @ignore */ import { TransactionFactory, Transaction, TxStatus } from '../src'; // tslint:disable-next-line: no-implicit-dependencies -import { Wallet } from '@harmony-js/account'; -import { HttpProvider, Messenger } from '@harmony-js/network'; -import { ChainType, ChainID } from '@harmony-js/utils'; -import { toChecksumAddress, randomBytes } from '@harmony-js/crypto'; +import { Wallet } from '@woop-js/account'; +import { HttpProvider, Messenger } from '@woop-js/network'; +import { ChainType, ChainID } from '@woop-js/utils'; +import { toChecksumAddress, randomBytes } from '@woop-js/crypto'; // tslint:disable-next-line: no-implicit-dependencies import fetch from 'jest-fetch-mock'; @@ -18,8 +18,8 @@ const http = new HttpProvider('http://mock.com'); const addr = toChecksumAddress('0x' + randomBytes(20)); -const msgHttp = new Messenger(http, ChainType.Harmony, ChainID.HmyLocal); -// const msgWs = new Messenger(ws, ChainType.Harmony, ChainID.HmyLocal); +const msgHttp = new Messenger(http, ChainType.Woop, ChainID.WikiLocal); +// const msgWs = new Messenger(ws, ChainType.Woop, ChainID.WikiLocal); const walletHttp = new Wallet(msgHttp); // const walletWs = new Wallet(msgWs); diff --git a/packages/harmony-transaction/test/testSign.test.ts b/packages/woop-transaction/test/testSign.test.ts similarity index 87% rename from packages/harmony-transaction/test/testSign.test.ts rename to packages/woop-transaction/test/testSign.test.ts index be90f07..39cb2b8 100644 --- a/packages/harmony-transaction/test/testSign.test.ts +++ b/packages/woop-transaction/test/testSign.test.ts @@ -1,15 +1,15 @@ /** * @packageDocumentation - * @module harmony-transaction + * @module woop-transaction * @ignore */ import { Transaction } from '../src/transaction'; import { RLPSign } from '../src/utils'; import { TxStatus } from '../src/types'; -import { HttpProvider, Messenger } from '@harmony-js/network'; -import { isAddress, ChainType, hexToBN, ChainID, isValidAddress } from '@harmony-js/utils'; -import { getAddressFromPrivateKey, getAddress } from '@harmony-js/crypto'; +import { HttpProvider, Messenger } from '@woop-js/network'; +import { isAddress, ChainType, hexToBN, ChainID, isValidAddress } from '@woop-js/utils'; +import { getAddressFromPrivateKey, getAddress } from '@woop-js/crypto'; import txnVectors from './transactions.fixture.json'; import reTxnVectors from './transactions.remake.fixture.json'; @@ -48,8 +48,8 @@ describe('test sign tranction', () => { } }); - it('should test sign transaction with Harmony settings', () => { - const hmyMessenger = new Messenger(provider, ChainType.Harmony, ChainID.Default); + it('should test sign transaction with Woop settings', () => { + const wikiMessenger = new Messenger(provider, ChainType.Woop, ChainID.Default); // tslint:disable-next-line: prefer-for-of for (let i = 0; i < reTxnVectors.length; i += 1) { const vector: any = reTxnVectors[i]; @@ -79,10 +79,10 @@ describe('test sign tranction', () => { data: vector.data, nonce: vector.nonce, }, - hmyMessenger, + wikiMessenger, TxStatus.INTIALIZED, ); - transaction.setMessenger(hmyMessenger); + transaction.setMessenger(wikiMessenger); const unsigned = transaction.getRLPUnsigned(); @@ -127,13 +127,13 @@ describe('test sign tranction', () => { expect(transaction.txParams.from.toLowerCase()).toEqual(vector.accountAddress.toLowerCase()); } }); - it('should test recover from HarmonySignedTransaction', () => { - const hmyMessenger = new Messenger(provider, ChainType.Harmony, ChainID.Default); + it('should test recover from WoopSignedTransaction', () => { + const wikiMessenger = new Messenger(provider, ChainType.Woop, ChainID.Default); // tslint:disable-next-line: prefer-for-of for (let i = 0; i < reTxnVectors.length; i += 1) { const vector = reTxnVectors[i]; - const factory = new TransactionFactory(hmyMessenger); - factory.setMessenger(hmyMessenger); + const factory = new TransactionFactory(wikiMessenger); + factory.setMessenger(wikiMessenger); const transaction: Transaction = factory.recover(vector.signedTransaction); if (vector.gasLimit && vector.gasLimit !== '0x') { @@ -166,9 +166,9 @@ describe('test sign tranction', () => { } }); it('should test transactionFactory', () => { - const hmyMessenger = new Messenger(provider, ChainType.Harmony, ChainID.Default); - const factory = new TransactionFactory(hmyMessenger); - factory.setMessenger(hmyMessenger); + const wikiMessenger = new Messenger(provider, ChainType.Woop, ChainID.Default); + const factory = new TransactionFactory(wikiMessenger); + factory.setMessenger(wikiMessenger); const txn = factory.newTx({}); expect(txn.getRLPUnsigned()[0]).toBeTruthy(); const txn2 = factory.newTx({}, true); diff --git a/packages/harmony-transaction/test/transactions.fixture.json b/packages/woop-transaction/test/transactions.fixture.json similarity index 100% rename from packages/harmony-transaction/test/transactions.fixture.json rename to packages/woop-transaction/test/transactions.fixture.json diff --git a/packages/harmony-transaction/test/transactions.remake.fixture.json b/packages/woop-transaction/test/transactions.remake.fixture.json similarity index 100% rename from packages/harmony-transaction/test/transactions.remake.fixture.json rename to packages/woop-transaction/test/transactions.remake.fixture.json diff --git a/packages/harmony-transaction/test/tsconfig.json b/packages/woop-transaction/test/tsconfig.json similarity index 100% rename from packages/harmony-transaction/test/tsconfig.json rename to packages/woop-transaction/test/tsconfig.json diff --git a/packages/harmony-transaction/tsconfig.json b/packages/woop-transaction/tsconfig.json similarity index 64% rename from packages/harmony-transaction/tsconfig.json rename to packages/woop-transaction/tsconfig.json index e0c32e9..55593ec 100644 --- a/packages/harmony-transaction/tsconfig.json +++ b/packages/woop-transaction/tsconfig.json @@ -6,8 +6,8 @@ }, "include": ["src", "../../typings/**/*.d.ts"], "references": [ - {"path": "../harmony-utils"}, - {"path": "../harmony-crypto"}, - {"path": "../harmony-network"} + {"path": "../woop-utils"}, + {"path": "../woop-crypto"}, + {"path": "../woop-network"} ] } diff --git a/packages/harmony-transaction/tsconfig.test.json b/packages/woop-transaction/tsconfig.test.json similarity index 100% rename from packages/harmony-transaction/tsconfig.test.json rename to packages/woop-transaction/tsconfig.test.json diff --git a/packages/harmony-utils/LICENSE b/packages/woop-utils/LICENSE similarity index 100% rename from packages/harmony-utils/LICENSE rename to packages/woop-utils/LICENSE diff --git a/packages/harmony-utils/README.md b/packages/woop-utils/README.md similarity index 84% rename from packages/harmony-utils/README.md rename to packages/woop-utils/README.md index aefbbb2..345db45 100644 --- a/packages/harmony-utils/README.md +++ b/packages/woop-utils/README.md @@ -1,18 +1,18 @@ -# @harmony-js/utils +# @woop-js/utils This package provides a collection of utility apis for unit conversions like `fromWei`, `toWei`, `hexToNumber`, `numberToHex`, `isAddress`, etc. ## Installation ``` -npm install @harmony-js/utils +npm install @woop-js/utils ``` ## Usage Available units ``` -const { Units } = require('@harmony-js/utils'); +const { Units } = require('@woop-js/utils'); [Units.wei, '1'], // 1 wei [Units.Kwei, '1000'], // 1e3 wei @@ -30,8 +30,8 @@ const { Units } = require('@harmony-js/utils'); Converting between different units ```javascript -const { Units, Unit, numberToString, add0xToString, fromWei, toWei, numToStr} = require('@harmony-js/utils'); -const { BN } = require('@harmony-js/crypto'); +const { Units, Unit, numberToString, add0xToString, fromWei, toWei, numToStr} = require('@woop-js/utils'); +const { BN } = require('@woop-js/crypto'); const one = new Unit('1').asOne(); const oneToGwei = one.toGwei(); @@ -54,7 +54,7 @@ console.log(expected); // toWei const one = new BN('1'); -const expected = toWei(one, hmy.utils.Units.one); +const expected = toWei(one, wiki.utils.Units.one); const num = numToStr(expected); console.log(num); ``` \ No newline at end of file diff --git a/packages/harmony-utils/package.json b/packages/woop-utils/package.json similarity index 89% rename from packages/harmony-utils/package.json rename to packages/woop-utils/package.json index 84b8606..95452c1 100644 --- a/packages/harmony-utils/package.json +++ b/packages/woop-utils/package.json @@ -1,7 +1,7 @@ { - "name": "@harmony-js/utils", + "name": "@woop-js/utils", "version": "0.1.58", - "description": "utils for harmony", + "description": "utils for woop", "main": "dist/index.js", "node": "dist/index.js", "browser": "dist/index.js", diff --git a/packages/harmony-utils/src/chain.ts b/packages/woop-utils/src/chain.ts similarity index 81% rename from packages/harmony-utils/src/chain.ts rename to packages/woop-utils/src/chain.ts index 34ed53d..abfd514 100644 --- a/packages/harmony-utils/src/chain.ts +++ b/packages/woop-utils/src/chain.ts @@ -1,19 +1,19 @@ /** - # @harmony-js/utils + # @woop-js/utils This package provides a collection of utility apis for unit conversions like `fromWei`, `toWei`, `hexToNumber`, `numberToHex`, `isAddress`, etc. ## Installation ``` -npm install @harmony-js/utils +npm install @woop-js/utils ``` ## Usage Available units ``` -const { Units } = require('@harmony-js/utils'); +const { Units } = require('@woop-js/utils'); [Units.wei, '1'], // 1 wei [Units.Kwei, '1000'], // 1e3 wei @@ -31,8 +31,8 @@ const { Units } = require('@harmony-js/utils'); Converting between different units ```javascript -const { Units, Unit, numberToString, add0xToString, fromWei, toWei, numToStr} = require('@harmony-js/utils'); -const { BN } = require('@harmony-js/crypto'); +const { Units, Unit, numberToString, add0xToString, fromWei, toWei, numToStr} = require('@woop-js/utils'); +const { BN } = require('@woop-js/crypto'); const one = new Unit('1').asOne(); const oneToGwei = one.toGwei(); @@ -55,17 +55,17 @@ console.log(expected); // toWei const one = new BN('1'); -const expected = toWei(one, hmy.utils.Units.one); +const expected = toWei(one, wiki.utils.Units.one); const num = numToStr(expected); console.log(num); ``` * * @packageDocumentation - * @module harmony-utils + * @module woop-utils */ export enum ChainType { - Harmony = 'hmy', + Woop = 'wiki', Ethereum = 'eth', } @@ -82,30 +82,30 @@ export enum ChainID { EtcTestnet = 62, Geth = 1337, Ganache = 0, - HmyMainnet = 1, - HmyTestnet = 2, - HmyLocal = 2, - HmyPangaea = 3, + WikiMainnet = 1, + WikiTestnet = 2, + WikiLocal = 2, + WikiPangaea = 3, } /** @hidden */ export const defaultConfig = { Default: { - Chain_ID: ChainID.HmyLocal, - Chain_Type: ChainType.Harmony, + Chain_ID: ChainID.WikiLocal, + Chain_Type: ChainType.Woop, Chain_URL: 'http://localhost:9500', Network_ID: 'Local', }, DefaultWS: { - Chain_ID: ChainID.HmyLocal, - Chain_Type: ChainType.Harmony, + Chain_ID: ChainID.WikiLocal, + Chain_Type: ChainType.Woop, Chain_URL: 'ws://localhost:9800', Network_ID: 'LocalWS', }, }; /** @hidden */ -export abstract class HarmonyCore { +export abstract class WoopCore { chainType: ChainType; chainId: ChainID; constructor(chainType: ChainType, chainId: ChainID = defaultConfig.Default.Chain_ID) { @@ -117,11 +117,11 @@ export abstract class HarmonyCore { case ChainType.Ethereum: { return 'eth'; } - case ChainType.Harmony: { - return 'hmy'; + case ChainType.Woop: { + return 'wiki'; } default: { - return 'hmy'; + return 'wiki'; } } } diff --git a/packages/harmony-utils/src/errors.ts b/packages/woop-utils/src/errors.ts similarity index 100% rename from packages/harmony-utils/src/errors.ts rename to packages/woop-utils/src/errors.ts diff --git a/packages/harmony-utils/src/index.ts b/packages/woop-utils/src/index.ts similarity index 87% rename from packages/harmony-utils/src/index.ts rename to packages/woop-utils/src/index.ts index f3094ce..0929bf3 100644 --- a/packages/harmony-utils/src/index.ts +++ b/packages/woop-utils/src/index.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-utils + * @module woop-utils * @ignore */ diff --git a/packages/harmony-utils/src/tools.ts b/packages/woop-utils/src/tools.ts similarity index 90% rename from packages/harmony-utils/src/tools.ts rename to packages/woop-utils/src/tools.ts index d60283d..3a77bda 100644 --- a/packages/harmony-utils/src/tools.ts +++ b/packages/woop-utils/src/tools.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-utils + * @module woop-utils * @hidden */ diff --git a/packages/harmony-utils/src/transformers.ts b/packages/woop-utils/src/transformers.ts similarity index 99% rename from packages/harmony-utils/src/transformers.ts rename to packages/woop-utils/src/transformers.ts index 5ba83df..5a18802 100644 --- a/packages/harmony-utils/src/transformers.ts +++ b/packages/woop-utils/src/transformers.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-utils + * @module woop-utils */ import BN from 'bn.js'; diff --git a/packages/harmony-utils/src/utils.ts b/packages/woop-utils/src/utils.ts similarity index 99% rename from packages/harmony-utils/src/utils.ts rename to packages/woop-utils/src/utils.ts index dcb82b5..5ebdb49 100644 --- a/packages/harmony-utils/src/utils.ts +++ b/packages/woop-utils/src/utils.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-utils + * @module woop-utils */ import { diff --git a/packages/harmony-utils/src/validators.ts b/packages/woop-utils/src/validators.ts similarity index 99% rename from packages/harmony-utils/src/validators.ts rename to packages/woop-utils/src/validators.ts index c1732c5..21b5448 100644 --- a/packages/harmony-utils/src/validators.ts +++ b/packages/woop-utils/src/validators.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-utils + * @module woop-utils */ export const isKeyString = (keyString: string, lengh: number): boolean => { diff --git a/packages/harmony-utils/test/fixture.ts b/packages/woop-utils/test/fixture.ts similarity index 87% rename from packages/harmony-utils/test/fixture.ts rename to packages/woop-utils/test/fixture.ts index 6706b41..dbb6e91 100644 --- a/packages/harmony-utils/test/fixture.ts +++ b/packages/woop-utils/test/fixture.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-utils + * @module woop-utils * @ignore */ @@ -10,7 +10,7 @@ export const basicType = { zero: 0, float: 0.1, text: 'testString', - jsonString: '{"name":"@harmony-js/utils","version":"0.0.48","description":"utils for harmony"}', + jsonString: '{"name":"@woop-js/utils","version":"0.0.48","description":"utils for woop"}', hexNumber: 0x123, hexString: '0x123', bool: true, diff --git a/packages/harmony-utils/test/transformer.test.ts b/packages/woop-utils/test/transformer.test.ts similarity index 99% rename from packages/harmony-utils/test/transformer.test.ts rename to packages/woop-utils/test/transformer.test.ts index 1790ea4..a3fa0f7 100644 --- a/packages/harmony-utils/test/transformer.test.ts +++ b/packages/woop-utils/test/transformer.test.ts @@ -1,10 +1,10 @@ /** * @packageDocumentation - * @module harmony-utils + * @module woop-utils * @ignore */ -import { BN } from '@harmony-js/crypto'; +import { BN } from '@woop-js/crypto'; import * as transformers from '../src/transformers'; describe('test transformers', () => { diff --git a/packages/harmony-utils/test/tsconfig.json b/packages/woop-utils/test/tsconfig.json similarity index 100% rename from packages/harmony-utils/test/tsconfig.json rename to packages/woop-utils/test/tsconfig.json diff --git a/packages/harmony-utils/test/validators.test.ts b/packages/woop-utils/test/validators.test.ts similarity index 99% rename from packages/harmony-utils/test/validators.test.ts rename to packages/woop-utils/test/validators.test.ts index 463f6e2..78f6f5c 100644 --- a/packages/harmony-utils/test/validators.test.ts +++ b/packages/woop-utils/test/validators.test.ts @@ -1,6 +1,6 @@ /** * @packageDocumentation - * @module harmony-utils + * @module woop-utils * @ignore */ diff --git a/packages/harmony-utils/tsconfig.json b/packages/woop-utils/tsconfig.json similarity index 100% rename from packages/harmony-utils/tsconfig.json rename to packages/woop-utils/tsconfig.json diff --git a/packages/harmony-utils/tsconfig.test.json b/packages/woop-utils/tsconfig.test.json similarity index 100% rename from packages/harmony-utils/tsconfig.test.json rename to packages/woop-utils/tsconfig.test.json diff --git a/scripts/bundle.ts b/scripts/bundle.ts index 95a06b3..3a8e94b 100644 --- a/scripts/bundle.ts +++ b/scripts/bundle.ts @@ -30,7 +30,7 @@ function getKeys(p) { const { dependencies } = JSON.parse(data); - // .filter((d) => !/harmony/.test(d)) + // .filter((d) => !/woop/.test(d)) const keys = dependencies ? Object.keys(dependencies) : []; return keys; } diff --git a/scripts/jest/jest.e2e.config.js b/scripts/jest/jest.e2e.config.js index d72f830..26b1d4a 100644 --- a/scripts/jest/jest.e2e.config.js +++ b/scripts/jest/jest.e2e.config.js @@ -2,7 +2,7 @@ const baseConfig = require('./jest.src.config'); module.exports = { ...baseConfig, moduleNameMapper: { - '^@harmony-js/(.*)$': '/packages/harmony-$1/src/index.ts', + '^@woop-js/(.*)$': '/packages/woop-$1/src/index.ts', 'cross-fetch': 'jest-fetch-mock', }, setupTestFrameworkScriptFile: '/scripts/jest/jest.framework-setup.js', @@ -16,11 +16,11 @@ module.exports = { }, }, collectCoverageFrom: [ - // 'packages/!(harmony-core)/src/**/*.ts', - 'packages/harmony-core/src/**/*.ts', - 'packages/harmony-utils/src/**/*.ts', - 'packages/harmony-crypto/src/**/*.ts', - 'packages/harmony-transaction/src/**/*.ts', + // 'packages/!(woop-core)/src/**/*.ts', + 'packages/woop-core/src/**/*.ts', + 'packages/woop-utils/src/**/*.ts', + 'packages/woop-crypto/src/**/*.ts', + 'packages/woop-transaction/src/**/*.ts', ], automock: false, }; diff --git a/scripts/jest/jest.src.config.js b/scripts/jest/jest.src.config.js index 769922b..28fd8e2 100644 --- a/scripts/jest/jest.src.config.js +++ b/scripts/jest/jest.src.config.js @@ -11,14 +11,14 @@ const config = { }, testMatch: [ // '/packages/**/test/?(*.)+(spec|test).js', - '/packages/harmony-core/test/?(*.)+(spec|test).ts', - '/packages/harmony-account/test/?(*.)+(spec|test).ts', - '/packages/harmony-network/test/?(*.)+(spec|test).ts', - '/packages/harmony-crypto/test/?(*.)+(spec|test).ts', - '/packages/harmony-contract/test/?(*.)+(spec|test).ts', - '/packages/harmony-transaction/test/?(*.)+(spec|test).ts', - '/packages/harmony-staking/test/?(*.)+(spec|test).ts', - '/packages/harmony-utils/test/?(*.)+(spec|test).ts', + '/packages/woop-core/test/?(*.)+(spec|test).ts', + '/packages/woop-account/test/?(*.)+(spec|test).ts', + '/packages/woop-network/test/?(*.)+(spec|test).ts', + '/packages/woop-crypto/test/?(*.)+(spec|test).ts', + '/packages/woop-contract/test/?(*.)+(spec|test).ts', + '/packages/woop-transaction/test/?(*.)+(spec|test).ts', + '/packages/woop-staking/test/?(*.)+(spec|test).ts', + '/packages/woop-utils/test/?(*.)+(spec|test).ts', ], moduleDirectories: ['src', 'node_modules'], moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], @@ -37,13 +37,13 @@ const config = { rootDir: process.cwd(), roots: ['/packages', '/scripts', '/e2e'], collectCoverageFrom: [ - // 'packages/!(harmony-core)/src/**/*.ts', - 'packages/harmony-core/src/**/*.ts', - 'packages/harmony-utils/src/**/*.ts', - 'packages/harmony-crypto/src/**/*.ts', - 'packages/harmony-transaction/src/**/*.ts', - 'packages/harmony-staking/src/**/*.ts', - 'packages/harmony-contract/src/**/*.ts', + // 'packages/!(woop-core)/src/**/*.ts', + 'packages/woop-core/src/**/*.ts', + 'packages/woop-utils/src/**/*.ts', + 'packages/woop-crypto/src/**/*.ts', + 'packages/woop-transaction/src/**/*.ts', + 'packages/woop-staking/src/**/*.ts', + 'packages/woop-contract/src/**/*.ts', ], // timers: 'fake', setupFiles: ['/scripts/jest/jest.setup.js'], diff --git a/scripts/packagesTs.ts b/scripts/packagesTs.ts index 630aed9..9a97510 100644 --- a/scripts/packagesTs.ts +++ b/scripts/packagesTs.ts @@ -1,12 +1,12 @@ const packages = [ - 'harmony-utils', - 'harmony-crypto', - 'harmony-account', - 'harmony-network', - 'harmony-transaction', - 'harmony-staking', - 'harmony-contract', - 'harmony-core', + 'woop-utils', + 'woop-crypto', + 'woop-account', + 'woop-network', + 'woop-transaction', + 'woop-staking', + 'woop-contract', + 'woop-core', ]; export { packages }; diff --git a/scripts/projects.ts b/scripts/projects.ts index bfdfe5a..6ed480e 100644 --- a/scripts/projects.ts +++ b/scripts/projects.ts @@ -65,7 +65,7 @@ export const projects = fs const pkgGlobalName = camelCase(pkgName); const pkgPath = path.join(packagesPath, p); const pkgSrc = path.join(pkgPath, 'src'); - const pkgScopedName = `@harmony-js/${p.replace('harmony-', '')}`; + const pkgScopedName = `@woop-js/${p.replace('woop-', '')}`; const pkgDist = path.join(pkgPath, 'dist'); const pkgUmd = path.join(pkgDist, 'index.umd.js'); diff --git a/scripts/typedoc/runner.js b/scripts/typedoc/runner.js index 28db06c..813855e 100644 --- a/scripts/typedoc/runner.js +++ b/scripts/typedoc/runner.js @@ -30,10 +30,10 @@ const files = [...app.expandInputFiles([pkgSrc])]; const nameArray = pkgPath.split('/'); const index = nameArray.findIndex( - (value) => value.startsWith('harmony') && !value.startsWith('harmony-js'), + (value) => value.startsWith('woop') && !value.startsWith('woop-js'), ); -const docPath = nameArray[index]; //.replace('harmony-', ''); +const docPath = nameArray[index]; //.replace('woop-', ''); // const project = app.convert(); const outputDir = `${pkgPath}/doc/${target}`; diff --git a/scripts/typings/schema.ts b/scripts/typings/schema.ts index 428dd92..022a31e 100644 --- a/scripts/typings/schema.ts +++ b/scripts/typings/schema.ts @@ -17,8 +17,8 @@ async function generateSchemas() { // @ts-ignore .filter((pkg) => { return ( - pkg !== 'harmony-' && - outputs.indexOf(pkg.replace('harmony-', '')) !== -1 + pkg !== 'woop-' && + outputs.indexOf(pkg.replace('woop-', '')) !== -1 ); }) .forEach((pkg) => { diff --git a/tsconfig.json b/tsconfig.json index 5af3c4f..515f93e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,14 +1,14 @@ { "files": [], "references": [ - { "path": "packages/harmony-utils" }, - { "path": "packages/harmony-crypto" }, - { "path": "packages/harmony-network" }, - { "path": "packages/harmony-transaction" }, - { "path": "packages/harmony-staking" }, - { "path": "packages/harmony-account" }, - { "path": "packages/harmony-contract" }, - { "path": "packages/harmony-core" } + { "path": "packages/woop-utils" }, + { "path": "packages/woop-crypto" }, + { "path": "packages/woop-network" }, + { "path": "packages/woop-transaction" }, + { "path": "packages/woop-staking" }, + { "path": "packages/woop-account" }, + { "path": "packages/woop-contract" }, + { "path": "packages/woop-core" } ], - "toc": ["harmony-account", "harmony-core"] + "toc": ["woop-account", "woop-core"] } diff --git a/tsconfig.test.json b/tsconfig.test.json index 1b9b855..45718ce 100644 --- a/tsconfig.test.json +++ b/tsconfig.test.json @@ -3,13 +3,13 @@ "files": [], "include": ["./typings/**/*.d.ts"], "references": [ - { "path": "packages/harmony-utils" }, - { "path": "packages/harmony-crypto" }, - { "path": "packages/harmony-network" }, - { "path": "packages/harmony-transaction" }, - { "path": "packages/harmony-staking" }, - { "path": "packages/harmony-account" }, - { "path": "packages/harmony-contract" }, - { "path": "packages/harmony-core" } + { "path": "packages/woop-utils" }, + { "path": "packages/woop-crypto" }, + { "path": "packages/woop-network" }, + { "path": "packages/woop-transaction" }, + { "path": "packages/woop-staking" }, + { "path": "packages/woop-account" }, + { "path": "packages/woop-contract" }, + { "path": "packages/woop-core" } ] }