From 327d8988dc289ddefd6c2eee8fbe31634d8183a2 Mon Sep 17 00:00:00 2001 From: Mark Tyneway Date: Wed, 23 Sep 2020 19:16:48 -0700 Subject: [PATCH 1/4] provider: wip format txresponse --- packages/provider/src/app/provider.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/provider/src/app/provider.ts b/packages/provider/src/app/provider.ts index f59526469f1c..473cd0fbfbf5 100644 --- a/packages/provider/src/app/provider.ts +++ b/packages/provider/src/app/provider.ts @@ -52,6 +52,17 @@ export class OptimismProvider extends JsonRpcProvider { tx.from = verifyMessage(hash, sig) return tx } + + // TODO(mark): debugging help + const formatTxResponse = this.formatter.transactionResponse + this.formatter.transactionResponse = (transaction) => { + const tx = formatTxResponse(transaction) + tx.type = transaction.type + tx.queueOrigin = transaction.queueOrigin + tx.l1MessageSender = transaction.l1MessageSender + console.log(tx) + return tx + } } public get ethereum() { @@ -72,6 +83,10 @@ export class OptimismProvider extends JsonRpcProvider { ) } + public async getTransaction(transactionHash: string | Promise) { + return super.getTransaction(transactionHash) + } + // `send` takes the literal RPC method name. The signer cannot use this // codepath, it is for querying an optimism node. public async send(method: string, params: any[]): Promise { From c88ad28459fa79033529c2651289f2824725f92c Mon Sep 17 00:00:00 2001 From: Mark Tyneway Date: Wed, 23 Sep 2020 20:10:04 -0700 Subject: [PATCH 2/4] provider: update formatter --- packages/provider/src/app/provider.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/provider/src/app/provider.ts b/packages/provider/src/app/provider.ts index 473cd0fbfbf5..aad3ca84954f 100644 --- a/packages/provider/src/app/provider.ts +++ b/packages/provider/src/app/provider.ts @@ -43,24 +43,22 @@ export class OptimismProvider extends JsonRpcProvider { this._ethersType = 'Provider' // Handle properly deriving "from" on the transaction - const format = this.formatter.transaction + const format = this.formatter.transaction.bind(this.formatter) this.formatter.transaction = (transaction) => { const tx = format(transaction) const sig = joinSignature(tx as SignatureLike) const hash = utils.sighashEthSign(tx) - // need to concat and hash with tx.from = verifyMessage(hash, sig) return tx } - // TODO(mark): debugging help - const formatTxResponse = this.formatter.transactionResponse + // Handle additional data sent from RPC + const formatTxResponse = this.formatter.transactionResponse.bind(this.formatter) this.formatter.transactionResponse = (transaction) => { - const tx = formatTxResponse(transaction) + const tx = formatTxResponse(transaction) as any tx.type = transaction.type tx.queueOrigin = transaction.queueOrigin tx.l1MessageSender = transaction.l1MessageSender - console.log(tx) return tx } } From 3ab160ca4d0dae8b6507827eaace9e7e0aafb351 Mon Sep 17 00:00:00 2001 From: Mark Tyneway Date: Wed, 23 Sep 2020 20:11:20 -0700 Subject: [PATCH 3/4] provider: lint --- packages/provider/src/app/provider.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/provider/src/app/provider.ts b/packages/provider/src/app/provider.ts index aad3ca84954f..51578a30c12e 100644 --- a/packages/provider/src/app/provider.ts +++ b/packages/provider/src/app/provider.ts @@ -53,7 +53,9 @@ export class OptimismProvider extends JsonRpcProvider { } // Handle additional data sent from RPC - const formatTxResponse = this.formatter.transactionResponse.bind(this.formatter) + const formatTxResponse = this.formatter.transactionResponse.bind( + this.formatter + ) this.formatter.transactionResponse = (transaction) => { const tx = formatTxResponse(transaction) as any tx.type = transaction.type From bbc31ecc82b8279c59d2860ace8793d97a317537 Mon Sep 17 00:00:00 2001 From: Mark Tyneway Date: Wed, 23 Sep 2020 20:12:16 -0700 Subject: [PATCH 4/4] provider: clean up --- packages/provider/src/app/provider.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/provider/src/app/provider.ts b/packages/provider/src/app/provider.ts index 51578a30c12e..25a94d34dd29 100644 --- a/packages/provider/src/app/provider.ts +++ b/packages/provider/src/app/provider.ts @@ -83,10 +83,6 @@ export class OptimismProvider extends JsonRpcProvider { ) } - public async getTransaction(transactionHash: string | Promise) { - return super.getTransaction(transactionHash) - } - // `send` takes the literal RPC method name. The signer cannot use this // codepath, it is for querying an optimism node. public async send(method: string, params: any[]): Promise {