Skip to content

Commit

Permalink
Adaptations to be compatible with block explorers
Browse files Browse the repository at this point in the history
* Better docs on loom provider responses
* Improved interfaces on loom provider
* Do not throw when cant find getCode
* Improving block 0 handling
* Added strict mode that remove non standard variables
  • Loading branch information
eduardonunesp committed Mar 21, 2019
1 parent 479cd63 commit c84df0a
Show file tree
Hide file tree
Showing 6 changed files with 351 additions and 98 deletions.
2 changes: 1 addition & 1 deletion .travis_e2e_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -euxo pipefail

eval "$(GIMME_GO_VERSION=1.10.2 gimme)"

export BUILD_ID=build-762
export BUILD_ID=build-880

bash e2e_tests.sh

Expand Down
12 changes: 9 additions & 3 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,9 +443,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 @@ -641,8 +644,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
4 changes: 3 additions & 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 All @@ -217,5 +217,7 @@ export class WSRPCClient extends EventEmitter {
log('EVM Event arrived', msg)
this.emit(RPCClientEvent.EVMMessage, this.url, msg)
}

log('Non-Loom and Non-EVM event', msg)
}
}
Loading

0 comments on commit c84df0a

Please sign in to comment.