chore(transaction):added `Transaction.observe()`

dev
neeboo 5 years ago
parent f113cac157
commit bdb233fe4f
  1. 40
      README.md
  2. 14
      package.json
  3. 14
      packages/harmony-transaction/src/transaction.ts
  4. 1
      packages/harmony-utils/src/chain.ts

@ -24,6 +24,19 @@ yarn add tslib
```
# Start hacking
1. install `lerna` and `typescript` globally
```bash
yarn global add lerna && yarn global add typescript
```
2. bootstrap repostory
```bash
yarn bootstrap
```
# Packages
1. [@harmony-js/core](https://github.com/FireStack-Lab/Harmony-sdk-core/tree/master/packages/harmony-core)
@ -35,22 +48,23 @@ yarn add tslib
7. [@harmony-js/contract](https://github.com/FireStack-Lab/Harmony-sdk-core/tree/master/packages/harmony-contract)
# Manually Build
1. make sure you have latest `node.js` and `yarn` installed
# Manually Build/bundle
There are two ways building
1. building the `es5` version bundled javascript for each sub-packages, which can be run in Browser directly.
2. git clone
```bash
git clone git@github.com:FireStack-Lab/Harmony-sdk-core.git
cd Harmony-sdk-core
```
```bash
yarn dist
```
All files are exported in `/dist` folder
3. cleanup and build
```bash
yarn global add lerna && yarn install && lerna bootstrap && lerna link && yarn dist
```
2. build `umd` and `esm` version javascript for each sub-packages, which can be accessed by `import` or `require`
```bash
yarn bundle
```
All files are exported in `packages/dist` folder, use `**.esm.js` or `**.umd.js` format
# Examples

@ -5,18 +5,16 @@
"packages/*"
],
"scripts": {
"packages:cleanBrowser": "gulp cleanBrowser",
"packages:cleanServer": "gulp cleanServer",
"packages:browser": "yarn packages:cleanBrowser && rollup --c scripts/rollup/bundleBrowser.js",
"packages:bundler": "yarn packages:cleanServer && yarn build:ts && ts-node -P scripts/tsconfig.json scripts/bundle.ts",
"dist": "yarn packages:bundler && rm -rf dist && cross-env NODE_ENV=production webpack --config webpack.config.js",
"bootstrap": "lerna bootstrap",
"build": "yarn build:proto && yarn build:ts",
"bootstrap": "lerna bootstrap && yarn build:ts",
"build:": "yarn build:ts && yarn build:test && yarn build:e2e",
"build:ts": "tsc -b tsconfig.json",
"build:test":"tsc -b tsconfig.test.json",
"build:e2e":"tsc -b tsconfig.e2e.json",
"bundle": "ts-node -P scripts/tsconfig.json scripts/bundle.ts umd,esm",
"clean": "lerna clean --yes && lerna run clean && rimraf includes",
"clean": "lerna clean --yes && lerna run clean && rimraf includes && yarn packages:clean",
"dist": "yarn packages:bundler && rm -rf dist && cross-env NODE_ENV=production webpack --config webpack.config.js",
"packages:clean": "gulp cleanServer",
"packages:bundler": "yarn packages:clean && yarn build:ts && ts-node -P scripts/tsconfig.json scripts/bundle.ts",
"schema": "ts-node -P scripts/tsconfig.json scripts/typings/schema.ts core",
"test": "cross-env TEST_ENV=unit jest -c scripts/jest/jest.config.js --rootDir=.",
"test:src": "cross-env NODE_ENV=test jest --config ./scripts/jest/jest.src.config.js --silent --runInBand --no-cache",

@ -264,6 +264,20 @@ class Transaction {
return this.getTxStatus() === TxStatus.CONFIRMED;
}
observed() {
try {
if (this.emitter.resolve) {
this.emitter.resolve(this);
}
} catch (error) {
if (this.emitter.reject) {
this.emitter.reject(error);
}
throw error;
}
return this.emitter;
}
async sendTransaction(): Promise<[Transaction, string]> {
// TODO: we use eth RPC setting for now, incase we have other params, we should add here
if (this.txnHash === 'tx' || this.txnHash === undefined) {

@ -15,6 +15,7 @@ export const enum ChainID {
EtcMainnet = 61,
EtcTestnet = 62,
Geth = 1337,
Ganache = 0,
}
export abstract class HarmonyCore {

Loading…
Cancel
Save