Skip to content

Commit

Permalink
fix(provider): getTransferTx and getWithdrawTx non-eth-based chain
Browse files Browse the repository at this point in the history
  • Loading branch information
petarTxFusion authored and danijelTxFusion committed May 23, 2024
1 parent 9bb8880 commit fc19131
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,14 @@ export function JsonRpcApiProvider<
overrides?: ethers.Overrides;
}): Promise<EthersTransactionRequest> {
const {...tx} = transaction;
if (isAddressEq(tx.token, LEGACY_ETH_ADDRESS)) {
tx.token = ETH_ADDRESS_IN_CONTRACTS;
const isEthBasedChain = await this.isEthBasedChain()

// In case of Ether on non Ether based chain it should get l2 Ether address,
// and in case of base token it should use L2_BASE_TOKEN_ADDRESS
if (isAddressEq(tx.token, LEGACY_ETH_ADDRESS) && !isEthBasedChain){
tx.token = await this.l2TokenAddress(ETH_ADDRESS_IN_CONTRACTS);
} else if (await this.isBaseToken(tx.token)){
tx.token = L2_BASE_TOKEN_ADDRESS;
}

if (
Expand Down Expand Up @@ -693,14 +699,20 @@ export function JsonRpcApiProvider<
overrides?: ethers.Overrides;
}): Promise<EthersTransactionRequest> {
const {...tx} = transaction;
const isEthBasedChain = await this.isEthBasedChain()

// In case of Ether on non Ether based chain it should get l2 Ether address,
// and in case of base token it should use L2_BASE_TOKEN_ADDRESS
if (tx.token && isAddressEq(tx.token, LEGACY_ETH_ADDRESS) && !isEthBasedChain){
tx.token = await this.l2TokenAddress(ETH_ADDRESS_IN_CONTRACTS);
} else if (!tx.token || await this.isBaseToken(tx.token)){
tx.token = L2_BASE_TOKEN_ADDRESS;
}

tx.overrides ??= {};
tx.overrides.from ??= tx.from;

if (
!tx.token ||
isAddressEq(tx.token, LEGACY_ETH_ADDRESS) ||
(await this.isBaseToken(tx.token))
) {
if (isETH(tx.token)) {
if (tx.paymasterParams) {
return {
...tx.overrides,
Expand Down

0 comments on commit fc19131

Please sign in to comment.