|
|
|
@ -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}; |
|
|
|
|