Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO-NOT-MERGE] Better loom compatibility with JSON RPC specification for Ethereum #242

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
1 change: 1 addition & 0 deletions e2e_support/loom.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ChainID: 'default'
QueryServerHost: "tcp://0.0.0.0:9999"
RegistryVersion: 2
ReceiptsVersion: 2
enlight marked this conversation as resolved.
Show resolved Hide resolved
LogDestination: 'file://loom2.log'
EVMAccountsEnabled: true
TransferGateway:
Expand Down
12 changes: 9 additions & 3 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,9 +448,12 @@ export class Client extends EventEmitter {
* @param txHash Transaction hash returned by call transaction.
* @return EvmTxReceipt The corresponding transaction receipt.
*/
async getEvmTxReceiptAsync(txHash: Uint8Array): Promise<EvmTxReceipt | null> {
async getEvmTxReceiptAsync(txHashArr: Uint8Array): Promise<EvmTxReceipt | null> {
const txHash = Uint8ArrayToB64(txHashArr)
debugLog(`Get EVM receipt for ${txHash}`)

const result = await this._readClient.sendAsync<string>('evmtxreceipt', {
txHash: Uint8ArrayToB64(txHash)
txHash
})
if (result) {
return EvmTxReceipt.deserializeBinary(bufferToProtobufBytes(B64ToUint8Array(result)))
Expand Down Expand Up @@ -646,8 +649,11 @@ export class Client extends EventEmitter {
hashHexStr: string,
full: boolean = true
): Promise<EthBlockInfo | null> {
const hash = Buffer.from(hashHexStr.slice(2), 'hex').toString('base64')
debugLog(`Evm block by hash ${hash}`)

const result = await this._readClient.sendAsync<string>('getevmblockbyhash', {
hash: Buffer.from(hashHexStr.slice(2), 'hex').toString('base64'),
hash,
full
})
if (result) {
Expand Down
2 changes: 1 addition & 1 deletion src/internal/ws-rpc-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export class WSRPCClient extends EventEmitter {
*/
async sendAsync<T>(method: string, params: object | any[]): Promise<T> {
await this.ensureConnectionAsync()
log(`Sending RPC msg to ${this.url}, method ${method}`)
log(`Sending RPC msg to ${this.url}, method ${method} with params ${JSON.stringify(params)}`)
return this._client.call<T>(method, params, this.requestTimeout)
}

Expand Down
Loading