feat(blockchain):update call

dev
neeboo 5 years ago
parent d3302931cc
commit a60a5f8a92
  1. 21
      README.md
  2. 2
      package.json
  3. 37
      packages/harmony-core/src/blockchain.ts

@ -27,6 +27,15 @@ yarn add tslib
* [harmony-sdk-examples](https://github.com/FireStack-Lab/harmony-sdk-examples)
# Packages
1. [@harmony-js/core](https://github.com/FireStack-Lab/Harmony-sdk-core/tree/master/packages/harmony-core)
2. [@harmony-js/account](https://github.com/FireStack-Lab/Harmony-sdk-core/tree/master/packages/harmony-account)
3. [@harmony-js/crypto](https://github.com/FireStack-Lab/Harmony-sdk-core/tree/master/packages/harmony-crypto)
4. [@harmony-js/network](https://github.com/FireStack-Lab/Harmony-sdk-core/tree/master/packages/harmony-network)
5. [@harmony-js/utils](https://github.com/FireStack-Lab/Harmony-sdk-core/tree/master/packages/harmony-utils)
6. [@harmony-js/transaction](https://github.com/FireStack-Lab/Harmony-sdk-core/tree/master/packages/harmony-transaction)
7. [@harmony-js/contract](https://github.com/FireStack-Lab/Harmony-sdk-core/tree/master/packages/harmony-contract)
# Hacking from source files
@ -48,18 +57,6 @@ yarn watch
- [E2E Tests](#E2E-tests)
# Packages
1. [@harmony-js/core](https://github.com/FireStack-Lab/Harmony-sdk-core/tree/master/packages/harmony-core)
2. [@harmony-js/account](https://github.com/FireStack-Lab/Harmony-sdk-core/tree/master/packages/harmony-account)
3. [@harmony-js/crypto](https://github.com/FireStack-Lab/Harmony-sdk-core/tree/master/packages/harmony-crypto)
4. [@harmony-js/network](https://github.com/FireStack-Lab/Harmony-sdk-core/tree/master/packages/harmony-network)
5. [@harmony-js/utils](https://github.com/FireStack-Lab/Harmony-sdk-core/tree/master/packages/harmony-utils)
6. [@harmony-js/transaction](https://github.com/FireStack-Lab/Harmony-sdk-core/tree/master/packages/harmony-transaction)
7. [@harmony-js/contract](https://github.com/FireStack-Lab/Harmony-sdk-core/tree/master/packages/harmony-contract)
# Manually Build/bundle
## Build

@ -7,7 +7,7 @@
"scripts": {
"bootstrap": "lerna bootstrap && yarn build:ts",
"watch":"yarn build:ts -w",
"build": "gulp cleanServer && gulp cleanUnexpected && yarn build:ts",
"build": "yarn packages:clean && yarn build:ts",
"build:ts": "tsc -b tsconfig.json",
"build:test":"tsc -b tsconfig.test.json",
"build:e2e":"tsc -b tsconfig.e2e.json",

@ -16,9 +16,9 @@ import {
DefaultBlockParams,
} from '@harmony-js/utils';
import { getAddress } from '@harmony-js/crypto';
import {getAddress} from '@harmony-js/crypto';
import { Transaction } from '@harmony-js/transaction';
import {Transaction} from '@harmony-js/transaction';
class Blockchain extends HarmonyCore {
messenger: Messenger;
@ -115,7 +115,7 @@ class Blockchain extends HarmonyCore {
@assertObject({
blockHash: ['isHash', AssertType.required],
})
async getBlockTransactionCountByHash({ blockHash }: { blockHash: string }) {
async getBlockTransactionCountByHash({blockHash}: {blockHash: string}) {
const result = await this.messenger.send(
RPCMethod.GetBlockTransactionCountByHash,
[blockHash],
@ -127,11 +127,7 @@ class Blockchain extends HarmonyCore {
@assertObject({
blockNumber: ['isBlockNumber', AssertType.required],
})
async getBlockTransactionCountByNumber({
blockNumber,
}: {
blockNumber: string;
}) {
async getBlockTransactionCountByNumber({blockNumber}: {blockNumber: string}) {
const result = await this.messenger.send(
RPCMethod.GetBlockTransactionCountByNumber,
[blockNumber],
@ -184,7 +180,7 @@ class Blockchain extends HarmonyCore {
@assertObject({
txnHash: ['isHash', AssertType.required],
})
async getTransactionByHash({ txnHash }: { txnHash: string }) {
async getTransactionByHash({txnHash}: {txnHash: string}) {
const result = await this.messenger.send(
RPCMethod.GetTransactionByHash,
[txnHash],
@ -199,7 +195,7 @@ class Blockchain extends HarmonyCore {
@assertObject({
txnHash: ['isString', AssertType.required],
})
async getTransactionReceipt({ txnHash }: { txnHash: string }) {
async getTransactionReceipt({txnHash}: {txnHash: string}) {
const result = await this.messenger.send(
RPCMethod.GetTransactionReceipt,
[txnHash],
@ -331,10 +327,10 @@ class Blockchain extends HarmonyCore {
to: ['isValidAddress', AssertType.optional],
data: ['isHex', AssertType.optional],
})
async estimateGas({ to, data }: { to: string; data: string }) {
async estimateGas({to, data}: {to: string; data: string}) {
const result = await this.messenger.send(
RPCMethod.EstimateGas,
[{ to: getAddress(to).checksum, data }],
[{to: getAddress(to).checksum, data}],
this.chainPrefix,
);
return this.getRpcResult(result);
@ -349,6 +345,21 @@ class Blockchain extends HarmonyCore {
return this.getRpcResult(result);
}
async call({
payload,
blockNumber = DefaultBlockParams.latest,
}: {
payload: any;
blockNumber?: string;
}) {
const result = await this.messenger.send(
RPCMethod.Call,
[payload, blockNumber],
this.chainPrefix,
);
return this.getRpcResult(result);
}
newPendingTransactions() {
if (this.messenger.provider instanceof WSProvider) {
return new NewPendingTransactions(this.messenger);
@ -382,4 +393,4 @@ class Blockchain extends HarmonyCore {
}
}
export { Blockchain };
export {Blockchain};

Loading…
Cancel
Save