@0xsequence/relayer
Advanced tools
Comparing version 0.16.0 to 0.18.0
# @0xsequence/relayer | ||
## 0.18.0 | ||
### Minor Changes | ||
- relayer improvements and pending transaction handling | ||
### Patch Changes | ||
- Updated dependencies [undefined] | ||
- @0xsequence/abi@0.18.0 | ||
- @0xsequence/chaind@0.18.0 | ||
- @0xsequence/config@0.18.0 | ||
- @0xsequence/transactions@0.18.0 | ||
- @0xsequence/utils@0.18.0 | ||
## 0.16.0 | ||
@@ -4,0 +19,0 @@ |
@@ -187,2 +187,7 @@ 'use strict'; | ||
return this.signer.sendTransaction(txRequest); | ||
} // TODO: Implement by monitoring wallet events | ||
wait(metaTxnId, timeout) { | ||
throw new Error('Method not implemented.'); | ||
} | ||
@@ -413,13 +418,15 @@ | ||
class RpcRelayer extends BaseRelayer { | ||
constructor(relayerSerivceUrl, bundleDeploy = true, provider, waitForReceipt = true) { | ||
constructor(relayerSerivceUrl, bundleDeploy = true, provider) { | ||
super(bundleDeploy, provider); | ||
this.service = void 0; | ||
this.waitForReceipt = void 0; | ||
this.service = new RelayerService(relayerSerivceUrl, fetchPonyfill__default['default']().fetch); | ||
this.waitForReceipt = waitForReceipt; | ||
} | ||
async waitReceipt(metaTxHash, wait = 500) { | ||
async waitReceipt(metaTxnHash, wait = 500) { | ||
if (typeof metaTxnHash !== 'string') { | ||
return this.waitReceipt(transactions.computeMetaTxnHash(config.addressOf(metaTxnHash.config, metaTxnHash.context), metaTxnHash.chainId, ...metaTxnHash.transactions)); | ||
} | ||
let result = await this.service.getMetaTxnReceipt({ | ||
metaTxID: metaTxHash | ||
metaTxID: metaTxnHash | ||
}); | ||
@@ -430,3 +437,3 @@ | ||
result = await this.service.getMetaTxnReceipt({ | ||
metaTxID: metaTxHash | ||
metaTxID: metaTxnHash | ||
}); | ||
@@ -476,3 +483,3 @@ } // "FAILED" is reserved for when the tx is invalid and never dispatched by remote relayer | ||
const tokenFee = await this.service.tokenFee(); | ||
utils$1.logger.info(`[rpc-relayer/gasRefundOptions] using token fee ${tokenFee}`); // No gas refund required | ||
utils$1.logger.info(`[rpc-relayer/gasRefundOptions] using token fee ${JSON.stringify(tokenFee)}`); // No gas refund required | ||
@@ -526,4 +533,2 @@ if (!tokenFee.isFee || tokenFee.fee === ethers.ethers.constants.AddressZero) { | ||
async relay(signedTxs) { | ||
var _this = this; | ||
utils$1.logger.info(`[rpc-relayer/relay] relaying signed meta-transactions ${JSON.stringify(signedTxs)}`); | ||
@@ -537,3 +542,3 @@ | ||
const prep = await this.prepareTransactions(signedTxs.config, signedTxs.context, signedTxs.signature, ...signedTxs.transactions); | ||
const result = this.service.sendMetaTxn({ | ||
const metaTxn = await this.service.sendMetaTxn({ | ||
call: { | ||
@@ -544,34 +549,22 @@ contract: prep.to, | ||
}); | ||
utils$1.logger.warn(`[rpc-relayer/relay] got relay result ${JSON.stringify(result)}`); | ||
utils$1.logger.warn(`[rpc-relayer/relay] got relay result ${JSON.stringify(metaTxn)}`); | ||
return this.wait(signedTxs); | ||
} | ||
const waitReceipt = async function waitReceipt() { | ||
const hash = (await result).txnHash; | ||
const receipt = (await _this.waitReceipt(hash)).receipt; | ||
const txReceipt = JSON.parse(receipt.txnReceipt); | ||
return { | ||
blockHash: txReceipt.blockHash, | ||
blockNumber: ethers.ethers.BigNumber.from(txReceipt.blockNumber).toNumber(), | ||
confirmations: 1, | ||
from: config.addressOf(signedTxs.config, signedTxs.context), | ||
hash: txReceipt.transactionHash, | ||
raw: receipt.txnReceipt, | ||
wait: async function (confirmations) { | ||
return _this.provider.waitForTransaction(txReceipt.transactionHash, confirmations); | ||
} | ||
}; | ||
}; | ||
async wait(metaTxnHash, wait = 500) { | ||
var _this = this; | ||
if (this.waitForReceipt) { | ||
return waitReceipt(); | ||
} | ||
const { | ||
receipt | ||
} = await this.waitReceipt(metaTxnHash, wait); | ||
const txReceipt = JSON.parse(receipt.txnReceipt); | ||
return { | ||
from: config.addressOf(signedTxs.config, signedTxs.context), | ||
raw: (await result).toString(), | ||
hash: (await result).txnHash, | ||
waitForReceipt: waitReceipt, | ||
blockHash: txReceipt.blockHash, | ||
blockNumber: ethers.ethers.BigNumber.from(txReceipt.blockNumber).toNumber(), | ||
confirmations: 1, | ||
from: typeof metaTxnHash === 'string' ? undefined : config.addressOf(metaTxnHash.config, metaTxnHash.context), | ||
hash: txReceipt.transactionHash, | ||
raw: receipt.txnReceipt, | ||
wait: async function (confirmations) { | ||
const receipt = await waitReceipt(); | ||
utils$1.logger.info(`[rpc-relayer/relay] got meta-transaction receipt ${JSON.stringify(receipt)}`); | ||
return receipt.wait(confirmations); | ||
return _this.provider.waitForTransaction(txReceipt.transactionHash, confirmations); | ||
} | ||
@@ -578,0 +571,0 @@ }; |
@@ -187,2 +187,7 @@ 'use strict'; | ||
return this.signer.sendTransaction(txRequest); | ||
} // TODO: Implement by monitoring wallet events | ||
wait(metaTxnId, timeout) { | ||
throw new Error('Method not implemented.'); | ||
} | ||
@@ -413,13 +418,15 @@ | ||
class RpcRelayer extends BaseRelayer { | ||
constructor(relayerSerivceUrl, bundleDeploy = true, provider, waitForReceipt = true) { | ||
constructor(relayerSerivceUrl, bundleDeploy = true, provider) { | ||
super(bundleDeploy, provider); | ||
this.service = void 0; | ||
this.waitForReceipt = void 0; | ||
this.service = new RelayerService(relayerSerivceUrl, fetchPonyfill__default['default']().fetch); | ||
this.waitForReceipt = waitForReceipt; | ||
} | ||
async waitReceipt(metaTxHash, wait = 500) { | ||
async waitReceipt(metaTxnHash, wait = 500) { | ||
if (typeof metaTxnHash !== 'string') { | ||
return this.waitReceipt(transactions.computeMetaTxnHash(config.addressOf(metaTxnHash.config, metaTxnHash.context), metaTxnHash.chainId, ...metaTxnHash.transactions)); | ||
} | ||
let result = await this.service.getMetaTxnReceipt({ | ||
metaTxID: metaTxHash | ||
metaTxID: metaTxnHash | ||
}); | ||
@@ -430,3 +437,3 @@ | ||
result = await this.service.getMetaTxnReceipt({ | ||
metaTxID: metaTxHash | ||
metaTxID: metaTxnHash | ||
}); | ||
@@ -476,3 +483,3 @@ } // "FAILED" is reserved for when the tx is invalid and never dispatched by remote relayer | ||
const tokenFee = await this.service.tokenFee(); | ||
utils$1.logger.info(`[rpc-relayer/gasRefundOptions] using token fee ${tokenFee}`); // No gas refund required | ||
utils$1.logger.info(`[rpc-relayer/gasRefundOptions] using token fee ${JSON.stringify(tokenFee)}`); // No gas refund required | ||
@@ -526,4 +533,2 @@ if (!tokenFee.isFee || tokenFee.fee === ethers.ethers.constants.AddressZero) { | ||
async relay(signedTxs) { | ||
var _this = this; | ||
utils$1.logger.info(`[rpc-relayer/relay] relaying signed meta-transactions ${JSON.stringify(signedTxs)}`); | ||
@@ -537,3 +542,3 @@ | ||
const prep = await this.prepareTransactions(signedTxs.config, signedTxs.context, signedTxs.signature, ...signedTxs.transactions); | ||
const result = this.service.sendMetaTxn({ | ||
const metaTxn = await this.service.sendMetaTxn({ | ||
call: { | ||
@@ -544,34 +549,22 @@ contract: prep.to, | ||
}); | ||
utils$1.logger.warn(`[rpc-relayer/relay] got relay result ${JSON.stringify(result)}`); | ||
utils$1.logger.warn(`[rpc-relayer/relay] got relay result ${JSON.stringify(metaTxn)}`); | ||
return this.wait(signedTxs); | ||
} | ||
const waitReceipt = async function waitReceipt() { | ||
const hash = (await result).txnHash; | ||
const receipt = (await _this.waitReceipt(hash)).receipt; | ||
const txReceipt = JSON.parse(receipt.txnReceipt); | ||
return { | ||
blockHash: txReceipt.blockHash, | ||
blockNumber: ethers.ethers.BigNumber.from(txReceipt.blockNumber).toNumber(), | ||
confirmations: 1, | ||
from: config.addressOf(signedTxs.config, signedTxs.context), | ||
hash: txReceipt.transactionHash, | ||
raw: receipt.txnReceipt, | ||
wait: async function (confirmations) { | ||
return _this.provider.waitForTransaction(txReceipt.transactionHash, confirmations); | ||
} | ||
}; | ||
}; | ||
async wait(metaTxnHash, wait = 500) { | ||
var _this = this; | ||
if (this.waitForReceipt) { | ||
return waitReceipt(); | ||
} | ||
const { | ||
receipt | ||
} = await this.waitReceipt(metaTxnHash, wait); | ||
const txReceipt = JSON.parse(receipt.txnReceipt); | ||
return { | ||
from: config.addressOf(signedTxs.config, signedTxs.context), | ||
raw: (await result).toString(), | ||
hash: (await result).txnHash, | ||
waitForReceipt: waitReceipt, | ||
blockHash: txReceipt.blockHash, | ||
blockNumber: ethers.ethers.BigNumber.from(txReceipt.blockNumber).toNumber(), | ||
confirmations: 1, | ||
from: typeof metaTxnHash === 'string' ? undefined : config.addressOf(metaTxnHash.config, metaTxnHash.context), | ||
hash: txReceipt.transactionHash, | ||
raw: receipt.txnReceipt, | ||
wait: async function (confirmations) { | ||
const receipt = await waitReceipt(); | ||
utils$1.logger.info(`[rpc-relayer/relay] got meta-transaction receipt ${JSON.stringify(receipt)}`); | ||
return receipt.wait(confirmations); | ||
return _this.provider.waitForTransaction(txReceipt.transactionHash, confirmations); | ||
} | ||
@@ -578,0 +571,0 @@ }; |
@@ -5,3 +5,3 @@ import { ethers } from 'ethers'; | ||
import { Interface } from 'ethers/lib/utils'; | ||
import { sequenceTxAbiEncode, readSequenceNonce, appendNonce, MetaTransactionsType } from '@0xsequence/transactions'; | ||
import { sequenceTxAbiEncode, readSequenceNonce, computeMetaTxnHash, appendNonce, MetaTransactionsType } from '@0xsequence/transactions'; | ||
import fetchPonyfill from 'fetch-ponyfill'; | ||
@@ -180,2 +180,7 @@ import { logger } from '@0xsequence/utils'; | ||
return this.signer.sendTransaction(txRequest); | ||
} // TODO: Implement by monitoring wallet events | ||
wait(metaTxnId, timeout) { | ||
throw new Error('Method not implemented.'); | ||
} | ||
@@ -406,13 +411,15 @@ | ||
class RpcRelayer extends BaseRelayer { | ||
constructor(relayerSerivceUrl, bundleDeploy = true, provider, waitForReceipt = true) { | ||
constructor(relayerSerivceUrl, bundleDeploy = true, provider) { | ||
super(bundleDeploy, provider); | ||
this.service = void 0; | ||
this.waitForReceipt = void 0; | ||
this.service = new RelayerService(relayerSerivceUrl, fetchPonyfill().fetch); | ||
this.waitForReceipt = waitForReceipt; | ||
} | ||
async waitReceipt(metaTxHash, wait = 500) { | ||
async waitReceipt(metaTxnHash, wait = 500) { | ||
if (typeof metaTxnHash !== 'string') { | ||
return this.waitReceipt(computeMetaTxnHash(addressOf(metaTxnHash.config, metaTxnHash.context), metaTxnHash.chainId, ...metaTxnHash.transactions)); | ||
} | ||
let result = await this.service.getMetaTxnReceipt({ | ||
metaTxID: metaTxHash | ||
metaTxID: metaTxnHash | ||
}); | ||
@@ -423,3 +430,3 @@ | ||
result = await this.service.getMetaTxnReceipt({ | ||
metaTxID: metaTxHash | ||
metaTxID: metaTxnHash | ||
}); | ||
@@ -469,3 +476,3 @@ } // "FAILED" is reserved for when the tx is invalid and never dispatched by remote relayer | ||
const tokenFee = await this.service.tokenFee(); | ||
logger.info(`[rpc-relayer/gasRefundOptions] using token fee ${tokenFee}`); // No gas refund required | ||
logger.info(`[rpc-relayer/gasRefundOptions] using token fee ${JSON.stringify(tokenFee)}`); // No gas refund required | ||
@@ -519,4 +526,2 @@ if (!tokenFee.isFee || tokenFee.fee === ethers.constants.AddressZero) { | ||
async relay(signedTxs) { | ||
var _this = this; | ||
logger.info(`[rpc-relayer/relay] relaying signed meta-transactions ${JSON.stringify(signedTxs)}`); | ||
@@ -530,3 +535,3 @@ | ||
const prep = await this.prepareTransactions(signedTxs.config, signedTxs.context, signedTxs.signature, ...signedTxs.transactions); | ||
const result = this.service.sendMetaTxn({ | ||
const metaTxn = await this.service.sendMetaTxn({ | ||
call: { | ||
@@ -537,34 +542,22 @@ contract: prep.to, | ||
}); | ||
logger.warn(`[rpc-relayer/relay] got relay result ${JSON.stringify(result)}`); | ||
logger.warn(`[rpc-relayer/relay] got relay result ${JSON.stringify(metaTxn)}`); | ||
return this.wait(signedTxs); | ||
} | ||
const waitReceipt = async function waitReceipt() { | ||
const hash = (await result).txnHash; | ||
const receipt = (await _this.waitReceipt(hash)).receipt; | ||
const txReceipt = JSON.parse(receipt.txnReceipt); | ||
return { | ||
blockHash: txReceipt.blockHash, | ||
blockNumber: ethers.BigNumber.from(txReceipt.blockNumber).toNumber(), | ||
confirmations: 1, | ||
from: addressOf(signedTxs.config, signedTxs.context), | ||
hash: txReceipt.transactionHash, | ||
raw: receipt.txnReceipt, | ||
wait: async function (confirmations) { | ||
return _this.provider.waitForTransaction(txReceipt.transactionHash, confirmations); | ||
} | ||
}; | ||
}; | ||
async wait(metaTxnHash, wait = 500) { | ||
var _this = this; | ||
if (this.waitForReceipt) { | ||
return waitReceipt(); | ||
} | ||
const { | ||
receipt | ||
} = await this.waitReceipt(metaTxnHash, wait); | ||
const txReceipt = JSON.parse(receipt.txnReceipt); | ||
return { | ||
from: addressOf(signedTxs.config, signedTxs.context), | ||
raw: (await result).toString(), | ||
hash: (await result).txnHash, | ||
waitForReceipt: waitReceipt, | ||
blockHash: txReceipt.blockHash, | ||
blockNumber: ethers.BigNumber.from(txReceipt.blockNumber).toNumber(), | ||
confirmations: 1, | ||
from: typeof metaTxnHash === 'string' ? undefined : addressOf(metaTxnHash.config, metaTxnHash.context), | ||
hash: txReceipt.transactionHash, | ||
raw: receipt.txnReceipt, | ||
wait: async function (confirmations) { | ||
const receipt = await waitReceipt(); | ||
logger.info(`[rpc-relayer/relay] got meta-transaction receipt ${JSON.stringify(receipt)}`); | ||
return receipt.wait(confirmations); | ||
return _this.provider.waitForTransaction(txReceipt.transactionHash, confirmations); | ||
} | ||
@@ -571,0 +564,0 @@ }; |
@@ -10,2 +10,3 @@ import { providers } from 'ethers'; | ||
relay(signedTxs: SignedTransactions): Promise<providers.TransactionResponse>; | ||
wait(metaTxnId: string | SignedTransactions, timeout: number): Promise<providers.TransactionResponse>; | ||
} | ||
@@ -12,0 +13,0 @@ export { LocalRelayer } from './local-relayer'; |
@@ -16,2 +16,3 @@ import { TransactionResponse, BlockTag } from '@ethersproject/providers'; | ||
relay(signedTxs: SignedTransactions): Promise<TransactionResponse>; | ||
wait(metaTxnId: string | SignedTransactions, timeout: number): Promise<TransactionResponse>; | ||
} |
@@ -11,12 +11,9 @@ import { TransactionResponse, Provider, BlockTag } from '@ethersproject/providers'; | ||
private readonly service; | ||
waitForReceipt: boolean; | ||
constructor(relayerSerivceUrl: string, bundleDeploy?: boolean, provider?: Provider, waitForReceipt?: boolean); | ||
waitReceipt(metaTxHash: string, wait?: number): Promise<proto.GetMetaTxnReceiptReturn>; | ||
constructor(relayerSerivceUrl: string, bundleDeploy?: boolean, provider?: Provider); | ||
waitReceipt(metaTxnHash: string | SignedTransactions, wait?: number): Promise<proto.GetMetaTxnReceiptReturn>; | ||
estimateGasLimits(config: WalletConfig, context: WalletContext, ...transactions: Transaction[]): Promise<Transaction[]>; | ||
gasRefundOptions(config: WalletConfig, context: WalletContext, ...transactions: Transaction[]): Promise<Transaction[][]>; | ||
getNonce(config: WalletConfig, context: WalletContext, space?: number, blockTag?: BlockTag): Promise<number>; | ||
relay(signedTxs: SignedTransactions): Promise<PendingTransactionResponse>; | ||
relay(signedTxs: SignedTransactions): Promise<TransactionResponse>; | ||
wait(metaTxnHash: string | SignedTransactions, wait?: number): Promise<TransactionResponse>; | ||
} | ||
export declare type PendingTransactionResponse = TransactionResponse & { | ||
waitForReceipt?: () => Promise<TransactionResponse>; | ||
}; |
{ | ||
"name": "@0xsequence/relayer", | ||
"version": "0.16.0", | ||
"version": "0.18.0", | ||
"description": "relayer sub-package for Sequence", | ||
@@ -16,7 +16,7 @@ "repository": "https://github.com/0xsequence/sequence.js/tree/master/packages/relayer", | ||
"dependencies": { | ||
"@0xsequence/abi": "^0.16.0", | ||
"@0xsequence/chaind": "^0.16.0", | ||
"@0xsequence/config": "^0.16.0", | ||
"@0xsequence/transactions": "^0.16.0", | ||
"@0xsequence/utils": "^0.16.0", | ||
"@0xsequence/abi": "^0.18.0", | ||
"@0xsequence/chaind": "^0.18.0", | ||
"@0xsequence/config": "^0.18.0", | ||
"@0xsequence/transactions": "^0.18.0", | ||
"@0xsequence/utils": "^0.18.0", | ||
"ethers": "^5.0.32", | ||
@@ -23,0 +23,0 @@ "fetch-ponyfill": "^7.1.0" |
@@ -30,2 +30,4 @@ import { providers } from 'ethers' | ||
// wait for transaction confirmation | ||
wait(metaTxnId: string | SignedTransactions, timeout: number): Promise<providers.TransactionResponse> | ||
} | ||
@@ -32,0 +34,0 @@ |
@@ -119,2 +119,7 @@ import { TransactionResponse, BlockTag } from '@ethersproject/providers' | ||
} | ||
// TODO: Implement by monitoring wallet events | ||
wait(metaTxnId: string | SignedTransactions, timeout: number): Promise<TransactionResponse> { | ||
throw new Error('Method not implemented.') | ||
} | ||
} |
import { TransactionResponse, Provider, BlockTag } from '@ethersproject/providers' | ||
import { ethers } from 'ethers' | ||
import fetchPonyfill from 'fetch-ponyfill' | ||
import { Transaction, TransactionEncoded, readSequenceNonce, appendNonce, MetaTransactionsType, sequenceTxAbiEncode, SignedTransactions } from '@0xsequence/transactions' | ||
import { | ||
Transaction, | ||
TransactionEncoded, | ||
readSequenceNonce, | ||
appendNonce, | ||
MetaTransactionsType, | ||
sequenceTxAbiEncode, | ||
SignedTransactions, | ||
computeMetaTxnHash | ||
} from '@0xsequence/transactions' | ||
import { BaseRelayer } from '../base-relayer' | ||
@@ -16,24 +25,20 @@ import { Relayer } from '..' | ||
private readonly service: proto.RelayerService | ||
public waitForReceipt: boolean | ||
constructor( | ||
relayerSerivceUrl: string, | ||
bundleDeploy: boolean = true, | ||
provider?: Provider, | ||
waitForReceipt: boolean = true | ||
) { | ||
constructor(relayerSerivceUrl: string, bundleDeploy: boolean = true, provider?: Provider) { | ||
super(bundleDeploy, provider) | ||
this.service = new proto.RelayerService(relayerSerivceUrl, fetchPonyfill().fetch) | ||
this.waitForReceipt = waitForReceipt | ||
} | ||
async waitReceipt( | ||
metaTxHash: string, | ||
wait: number = 500 | ||
) { | ||
let result = await this.service.getMetaTxnReceipt({ metaTxID: metaTxHash }) | ||
async waitReceipt(metaTxnHash: string | SignedTransactions, wait: number = 500): Promise<proto.GetMetaTxnReceiptReturn> { | ||
if (typeof metaTxnHash !== 'string') { | ||
return this.waitReceipt( | ||
computeMetaTxnHash(addressOf(metaTxnHash.config, metaTxnHash.context), metaTxnHash.chainId, ...metaTxnHash.transactions) | ||
) | ||
} | ||
let result = await this.service.getMetaTxnReceipt({ metaTxID: metaTxnHash }) | ||
while ((!result.receipt.txnReceipt || result.receipt.txnReceipt === 'null') && result.receipt.status === 'UNKNOWN') { | ||
await new Promise(r => setTimeout(r, wait)) | ||
result = await this.service.getMetaTxnReceipt({ metaTxID: metaTxHash }) | ||
result = await this.service.getMetaTxnReceipt({ metaTxID: metaTxnHash }) | ||
} | ||
@@ -49,7 +54,3 @@ | ||
async estimateGasLimits( | ||
config: WalletConfig, | ||
context: WalletContext, | ||
...transactions: Transaction[] | ||
): Promise<Transaction[]> { | ||
async estimateGasLimits(config: WalletConfig, context: WalletContext, ...transactions: Transaction[]): Promise<Transaction[]> { | ||
logger.info(`[rpc-relayer/estimateGasLimits] estimate gas limits request ${JSON.stringify(transactions)}`) | ||
@@ -88,7 +89,3 @@ | ||
async gasRefundOptions( | ||
config: WalletConfig, | ||
context: WalletContext, | ||
...transactions: Transaction[] | ||
): Promise<Transaction[][]> { | ||
async gasRefundOptions(config: WalletConfig, context: WalletContext, ...transactions: Transaction[]): Promise<Transaction[][]> { | ||
// chaind only supports refunds on a single token | ||
@@ -98,3 +95,3 @@ // TODO: Add compatiblity for different refund options | ||
logger.info(`[rpc-relayer/gasRefundOptions] using token fee ${tokenFee}`) | ||
logger.info(`[rpc-relayer/gasRefundOptions] using token fee ${JSON.stringify(tokenFee)}`) | ||
@@ -124,12 +121,16 @@ // No gas refund required | ||
if (prevNonce === undefined) { | ||
decoded = res.options.map(option => coder.decode([MetaTransactionsType], option)[0].map((txn: TransactionEncoded) => ({ | ||
...txn, | ||
to: txn.target | ||
}))) | ||
decoded = res.options.map(option => | ||
coder.decode([MetaTransactionsType], option)[0].map((txn: TransactionEncoded) => ({ | ||
...txn, | ||
to: txn.target | ||
})) | ||
) | ||
} else { | ||
decoded = res.options.map(option => coder.decode([MetaTransactionsType], option)[0].map((txn: TransactionEncoded) => ({ | ||
...txn, | ||
to: txn.target, | ||
nonce: prevNonce | ||
}))) | ||
decoded = res.options.map(option => | ||
coder.decode([MetaTransactionsType], option)[0].map((txn: TransactionEncoded) => ({ | ||
...txn, | ||
to: txn.target, | ||
nonce: prevNonce | ||
})) | ||
) | ||
} | ||
@@ -142,8 +143,3 @@ | ||
async getNonce( | ||
config: WalletConfig, | ||
context: WalletContext, | ||
space?: number, | ||
blockTag?: BlockTag | ||
): Promise<number> { | ||
async getNonce(config: WalletConfig, context: WalletContext, space?: number, blockTag?: BlockTag): Promise<number> { | ||
const addr = addressOf(config, context) | ||
@@ -157,3 +153,3 @@ logger.info(`[rpc-relayer/getNonce] get nonce for wallet ${addr} space: ${space}`) | ||
async relay(signedTxs: SignedTransactions): Promise<PendingTransactionResponse> { | ||
async relay(signedTxs: SignedTransactions): Promise<TransactionResponse> { | ||
logger.info(`[rpc-relayer/relay] relaying signed meta-transactions ${JSON.stringify(signedTxs)}`) | ||
@@ -166,4 +162,9 @@ | ||
const prep = await this.prepareTransactions(signedTxs.config, signedTxs.context, signedTxs.signature, ...signedTxs.transactions) | ||
const result = this.service.sendMetaTxn({ | ||
const prep = await this.prepareTransactions( | ||
signedTxs.config, | ||
signedTxs.context, | ||
signedTxs.signature, | ||
...signedTxs.transactions | ||
) | ||
const metaTxn = await this.service.sendMetaTxn({ | ||
call: { | ||
@@ -175,42 +176,23 @@ contract: prep.to, | ||
logger.warn(`[rpc-relayer/relay] got relay result ${JSON.stringify(result)}`) | ||
logger.warn(`[rpc-relayer/relay] got relay result ${JSON.stringify(metaTxn)}`) | ||
const waitReceipt = async () => { | ||
const hash = (await result).txnHash | ||
const receipt = (await this.waitReceipt(hash)).receipt | ||
const txReceipt = JSON.parse(receipt.txnReceipt) as RelayerTxReceipt | ||
return this.wait(signedTxs) | ||
} | ||
return { | ||
blockHash: txReceipt.blockHash, | ||
blockNumber: ethers.BigNumber.from(txReceipt.blockNumber).toNumber(), | ||
confirmations: 1, | ||
from: addressOf(signedTxs.config, signedTxs.context), | ||
hash: txReceipt.transactionHash, | ||
raw: receipt.txnReceipt, | ||
wait: async (confirmations?: number) => this.provider!.waitForTransaction(txReceipt.transactionHash, confirmations) | ||
} as TransactionResponse | ||
} | ||
async wait(metaTxnHash: string | SignedTransactions, wait: number = 500): Promise<TransactionResponse> { | ||
const { receipt } = await this.waitReceipt(metaTxnHash, wait) | ||
const txReceipt = JSON.parse(receipt.txnReceipt) as RelayerTxReceipt | ||
if (this.waitForReceipt) { | ||
return waitReceipt() | ||
} | ||
return { | ||
from: addressOf(signedTxs.config, signedTxs.context), | ||
raw: (await result).toString(), | ||
hash: (await result).txnHash, | ||
waitForReceipt: waitReceipt, | ||
wait: async (confirmations?: number) => { | ||
const receipt = await waitReceipt() | ||
logger.info(`[rpc-relayer/relay] got meta-transaction receipt ${JSON.stringify(receipt)}`) | ||
return receipt.wait(confirmations) | ||
} | ||
} as PendingTransactionResponse | ||
blockHash: txReceipt.blockHash, | ||
blockNumber: ethers.BigNumber.from(txReceipt.blockNumber).toNumber(), | ||
confirmations: 1, | ||
from: typeof metaTxnHash === 'string' ? undefined : addressOf(metaTxnHash.config, metaTxnHash.context), | ||
hash: txReceipt.transactionHash, | ||
raw: receipt.txnReceipt, | ||
wait: async (confirmations?: number) => this.provider!.waitForTransaction(txReceipt.transactionHash, confirmations) | ||
} as TransactionResponse | ||
} | ||
} | ||
export type PendingTransactionResponse = TransactionResponse & { | ||
waitForReceipt?: () => Promise<TransactionResponse> | ||
} | ||
type RelayerTxReceipt = { | ||
@@ -232,3 +214,3 @@ blockHash: string | ||
transactionIndex: string | ||
}[], | ||
}[] | ||
logsBloom: string | ||
@@ -235,0 +217,0 @@ root: string |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
103783
2421
+ Added@0xsequence/abi@0.18.0(transitive)
+ Added@0xsequence/chaind@0.18.0(transitive)
+ Added@0xsequence/config@0.18.0(transitive)
+ Added@0xsequence/network@0.18.0(transitive)
+ Added@0xsequence/transactions@0.18.0(transitive)
+ Added@0xsequence/utils@0.18.0(transitive)
- Removed@0xsequence/abi@0.16.0(transitive)
- Removed@0xsequence/chaind@0.16.0(transitive)
- Removed@0xsequence/config@0.16.0(transitive)
- Removed@0xsequence/network@0.16.0(transitive)
- Removed@0xsequence/transactions@0.16.0(transitive)
- Removed@0xsequence/utils@0.16.0(transitive)
Updated@0xsequence/abi@^0.18.0
Updated@0xsequence/chaind@^0.18.0
Updated@0xsequence/config@^0.18.0
Updated@0xsequence/utils@^0.18.0