Skip to content

Commit

Permalink
Merge branch 'master' into pxrl/tokenCleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
pxrl authored Mar 26, 2024
2 parents 884e6ff + 3be0a92 commit 5112490
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/clients/bridges/BaseAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,13 +292,18 @@ export abstract class BaseAdapter {
simMode: boolean
): Promise<TransactionResponse> {
assert(this.isSupportedToken(l1Token), `Token ${l1Token} is not supported`);
const tokenSymbol = matchTokenSymbol(l1Token, this.hubChainId)[0];
const [srcChain, dstChain] = [getNetworkName(this.hubChainId), getNetworkName(this.chainId)];
const message = `💌⭐️ Bridging tokens from ${srcChain} to ${dstChain}.`;
const _txnRequest: AugmentedTransaction = {
contract,
chainId: this.hubChainId,
method,
args,
gasLimitMultiplier,
value: msgValue,
message,
mrkdwn: `Sent ${formatUnitsForToken(tokenSymbol, amount)} ${tokenSymbol} to chain ${dstChain}.`,
};
const { reason, succeed, transaction: txnRequest } = (await this.txnClient.simulate([_txnRequest]))[0];
const { contract: targetContract, ...txnRequestData } = txnRequest;
Expand All @@ -308,8 +313,6 @@ export abstract class BaseAdapter {
throw new Error(`${message} (${reason})`);
}

const tokenSymbol = matchTokenSymbol(l1Token, this.hubChainId)[0];
const message = `💌⭐️ Bridging tokens from ${this.hubChainId} to ${this.chainId}`;
this.logger.debug({
at: `${this.getName()}#_sendTokenToTargetChain`,
message,
Expand All @@ -318,17 +321,17 @@ export abstract class BaseAdapter {
amount,
contract: contract.address,
txnRequestData,
mrkdwn: `Sent ${formatUnitsForToken(tokenSymbol, amount)} ${tokenSymbol} to chain ${this.chainId}`,
});
if (simMode) {
this.logger.debug({
at: `${this.getName()}#_sendTokenToTargetChain`,
message: "Simulation result",
succeed,
...txnRequest,
});
return { hash: ZERO_ADDRESS } as TransactionResponse;
}
return (await this.txnClient.submit(this.hubChainId, [{ ...txnRequest, message }]))[0];
return (await this.txnClient.submit(this.hubChainId, [{ ...txnRequest }]))[0];
}

async _wrapEthIfAboveThreshold(
Expand Down

0 comments on commit 5112490

Please sign in to comment.