1
- import { evm , getContractInstance , getContractAddress , contracts } from "../../../helpers" ;
1
+ import { evm , getContractInstance , getContractAddress , contracts , getChainInfo } from "../../../helpers" ;
2
2
import { TokenRouter } from "../../../contract-bindings" ;
3
- import { circle , toChain } from "@wormhole-foundation/sdk-base" ;
3
+ import { circle , toChain , toChainId } from "@wormhole-foundation/sdk-base" ;
4
4
import { toUniversal } from "@wormhole-foundation/sdk-definitions" ;
5
+ import { getTokenRouterProgram } from "../../../helpers/solana" ;
6
+ import { Connection } from "@solana/web3.js" ;
5
7
6
8
evm . runOnEvms ( "cross-registration-token-router" , async ( chain , _ , log ) => {
7
9
const tokenRouterAddress = getContractAddress ( "TokenRouterProxy" , chain . chainId ) ;
@@ -10,11 +12,12 @@ evm.runOnEvms("cross-registration-token-router", async (chain, _, log) => {
10
12
11
13
for ( const router of deployedTokenRouters ) {
12
14
const circleDomain = circle . toCircleChainId ( chain . network , toChain ( router . chainId ) ) ;
13
- // TODO: handle Solana registrations correctly in regards to mintRecipient
14
15
const routerChain = toChain ( router . chainId ) ;
16
+ const routerAddress = toUniversal ( routerChain , router . address ) . toString ( ) ;
17
+ const mintRecipient = routerChain === "Solana" ? getSolanaMintRecipient ( ) : routerAddress ;
15
18
const endpoint = {
16
- router : toUniversal ( routerChain , router . address ) . toString ( ) ,
17
- mintRecipient : toUniversal ( routerChain , router . address ) . toString ( )
19
+ router : routerAddress ,
20
+ mintRecipient
18
21
} ;
19
22
20
23
if ( router . chainId === 0 )
@@ -33,3 +36,13 @@ evm.runOnEvms("cross-registration-token-router", async (chain, _, log) => {
33
36
log ( `Router endpoint added for chainId ${ router . chainId } ` ) ;
34
37
}
35
38
} ) ;
39
+
40
+
41
+ function getSolanaMintRecipient ( ) : string {
42
+ const chain = "Solana" ;
43
+ const chainInfo = getChainInfo ( toChainId ( chain ) ) ;
44
+ const connection = new Connection ( chainInfo . rpc , chainInfo . commitmentLevel || "confirmed" ) ;
45
+ const tokenRouter = getTokenRouterProgram ( connection ) ;
46
+
47
+ return toUniversal ( chain , tokenRouter . custodianAddress ( ) . toBytes ( ) ) . toString ( ) ;
48
+ }
0 commit comments