File tree 2 files changed +28
-7
lines changed
2 files changed +28
-7
lines changed Original file line number Diff line number Diff line change 1
1
import type { Chain , Network } from "@wormhole-foundation/sdk-base" ;
2
2
import { amount , circle , contracts } from "@wormhole-foundation/sdk-base" ;
3
- import type {
4
- ChainAddress ,
5
- ChainContext ,
6
- CircleTransferDetails ,
7
- Signer ,
8
- TokenId ,
3
+ import {
4
+ isSameToken ,
5
+ type ChainAddress ,
6
+ type ChainContext ,
7
+ type CircleTransferDetails ,
8
+ type Signer ,
9
+ type TokenId ,
9
10
} from "@wormhole-foundation/sdk-definitions" ;
10
11
import { CircleTransfer } from "../../protocols/cctp/cctpTransfer.js" ;
11
12
import { TransferState } from "../../types.js" ;
@@ -85,6 +86,16 @@ export class AutomaticCCTPRoute<N extends Network>
85
86
fromChain : ChainContext < N > ,
86
87
toChain : ChainContext < N > ,
87
88
) : Promise < TokenId [ ] > {
89
+ // Ensure the source token is USDC
90
+ const sourceChainUsdcContract = circle . usdcContract . get ( fromChain . network , fromChain . chain ) ;
91
+ if ( ! sourceChainUsdcContract ) return [ ] ;
92
+ if ( ! isSameToken (
93
+ sourceToken ,
94
+ Wormhole . tokenId ( fromChain . chain , sourceChainUsdcContract ) ,
95
+ ) ) {
96
+ return [ ] ;
97
+ }
98
+
88
99
const { network, chain } = toChain ;
89
100
if ( ! circle . usdcContract . has ( network , chain ) ) return [ ] ;
90
101
return [ Wormhole . chainAddress ( chain , circle . usdcContract . get ( network , chain ) ! ) ] ;
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import type {
6
6
Signer ,
7
7
TokenId ,
8
8
} from "@wormhole-foundation/sdk-definitions" ;
9
- import { CircleBridge } from "@wormhole-foundation/sdk-definitions" ;
9
+ import { CircleBridge , isSameToken } from "@wormhole-foundation/sdk-definitions" ;
10
10
import { signSendWait } from "../../common.js" ;
11
11
import { CircleTransfer } from "../../protocols/cctp/cctpTransfer.js" ;
12
12
import type { TransferReceipt } from "../../types.js" ;
@@ -79,6 +79,16 @@ export class CCTPRoute<N extends Network>
79
79
fromChain : ChainContext < N > ,
80
80
toChain : ChainContext < N > ,
81
81
) : Promise < TokenId [ ] > {
82
+ // Ensure the source token is USDC
83
+ const sourceChainUsdcContract = circle . usdcContract . get ( fromChain . network , fromChain . chain ) ;
84
+ if ( ! sourceChainUsdcContract ) return [ ] ;
85
+ if ( ! isSameToken (
86
+ sourceToken ,
87
+ Wormhole . tokenId ( fromChain . chain , sourceChainUsdcContract ) ,
88
+ ) ) {
89
+ return [ ] ;
90
+ }
91
+
82
92
const { network, chain } = toChain ;
83
93
if ( ! circle . usdcContract . has ( network , chain ) ) return [ ] ;
84
94
return [ Wormhole . chainAddress ( chain , circle . usdcContract . get ( network , chain ) ! ) ] ;
You can’t perform that action at this time.
0 commit comments