Skip to content

Commit a3818ba

Browse files
authored
bug fixies (#620)
* hash aptos addresses * move logic into Aptos address type * dont hash if no module * do aptos hashing inside tokenTransfer * bugfix: only check for WETH on same chain
1 parent 6375ddd commit a3818ba

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

platforms/evm/protocols/tokenBridge/src/tokenBridge.ts

+21-18
Original file line numberDiff line numberDiff line change
@@ -270,26 +270,29 @@ export class EvmTokenBridge<N extends Network, C extends EvmChains>
270270
);
271271
}
272272

273-
const wrappedNativeAddr = await this.tokenBridge.WETH();
274-
const tokenAddr = new EvmAddress(vaa.payload.token.address).unwrap();
275-
if (tokenAddr === wrappedNativeAddr && unwrapNative) {
276-
const txReq =
277-
await this.tokenBridge.completeTransferAndUnwrapETH.populateTransaction(
278-
serialize(vaa),
273+
if (vaa.payload.token.chain === this.chain) {
274+
const wrappedNativeAddr = await this.tokenBridge.WETH();
275+
const tokenAddr = new EvmAddress(vaa.payload.token.address).unwrap();
276+
if (tokenAddr === wrappedNativeAddr && unwrapNative) {
277+
const txReq =
278+
await this.tokenBridge.completeTransferAndUnwrapETH.populateTransaction(
279+
serialize(vaa),
280+
);
281+
yield this.createUnsignedTx(
282+
addFrom(txReq, senderAddr),
283+
'TokenBridge.completeTransferAndUnwrapETH',
279284
);
280-
yield this.createUnsignedTx(
281-
addFrom(txReq, senderAddr),
282-
'TokenBridge.completeTransferAndUnwrapETH',
283-
);
284-
} else {
285-
const txReq = await this.tokenBridge.completeTransfer.populateTransaction(
286-
serialize(vaa),
287-
);
288-
yield this.createUnsignedTx(
289-
addFrom(txReq, senderAddr),
290-
'TokenBridge.completeTransfer',
291-
);
285+
return;
286+
}
292287
}
288+
289+
const txReq = await this.tokenBridge.completeTransfer.populateTransaction(
290+
serialize(vaa),
291+
);
292+
yield this.createUnsignedTx(
293+
addFrom(txReq, senderAddr),
294+
'TokenBridge.completeTransfer',
295+
);
293296
}
294297

295298
async getWrappedNative() {

0 commit comments

Comments
 (0)