@@ -20,14 +20,6 @@ class Stargate(Flare):
2020 # Flare Network (endpointID: 30295)
2121 FLARE_ENDPOINT_ID : Final [int ] = 30295
2222
23- # Stargate OFT Token Addresses on Flare
24- STARGATE_ETH : Final [str ] = "0x8e8539e4CcD69123c623a106773F2b0cbbc58746"
25- STARGATE_USDC : Final [str ] = "0x77C71633C34C3784ede189d74223122422492a0f"
26- STARGATE_USDT : Final [str ] = "0x1C10CC06DC6D35970d1D53B2A23c76ef370d4135"
27-
28- TOKEN_MESSAGING : Final [str ] = "0x45d417612e177672958dC0537C45a8f8d754Ac2E"
29- TREASURER : Final [str ] = "0x090194F1EEDc134A680e3b488aBB2D212dba8c01"
30-
3123 # Common Destination Chains
3224 CHAINS : Final [dict [str , int ]] = {
3325 "ethereum" : 30101 ,
@@ -44,6 +36,7 @@ class Stargate(Flare):
4436
4537 def __init__ (self , settings : EcosystemSettings ) -> None :
4638 super ().__init__ (settings )
39+ self .settings = settings
4740
4841 @classmethod
4942 async def create (cls , settings : EcosystemSettings ) -> "Self" :
@@ -63,12 +56,28 @@ async def create(cls, settings: EcosystemSettings) -> "Self":
6356 instance = cls (settings )
6457 logger .info ("Initializing Stargate bridge connector..." )
6558 try :
59+ # Verify addresses are configured
60+ contracts = (
61+ settings .contracts .coston2
62+ if settings .is_testnet
63+ else settings .contracts .flare
64+ )
65+ if not all (
66+ [
67+ contracts .stargate_token_messaging ,
68+ contracts .stargate_treasurer ,
69+ contracts .stargate_eth_oft ,
70+ contracts .stargate_usdc_oft ,
71+ contracts .stargate_usdt_oft ,
72+ ]
73+ ):
74+ msg = "Stargate contract addresses not configured in settings"
75+ raise StargateError (msg )
76+
6677 logger .debug (
6778 "Stargate connector initialized" ,
6879 endpoint_id = cls .FLARE_ENDPOINT_ID ,
69- eth_oft = cls .STARGATE_ETH ,
70- usdc_oft = cls .STARGATE_USDC ,
71- usdt_oft = cls .STARGATE_USDT ,
80+ network = "testnet" if settings .is_testnet else "mainnet" ,
7281 )
7382 return instance # noqa: TRY300
7483 except Exception as e :
@@ -94,13 +103,19 @@ def get_oft_address(self, token: str) -> str:
94103 >>> print(f"USDC OFT: {oft_addr}")
95104
96105 """
106+ contracts = (
107+ self .settings .contracts .coston2
108+ if self .settings .is_testnet
109+ else self .settings .contracts .flare
110+ )
111+
97112 token_upper = token .upper ()
98113 if token_upper == "ETH" :
99- return self . STARGATE_ETH
114+ return str ( contracts . stargate_eth_oft )
100115 if token_upper == "USDC" :
101- return self . STARGATE_USDC
116+ return str ( contracts . stargate_usdc_oft )
102117 if token_upper == "USDT" :
103- return self . STARGATE_USDT
118+ return str ( contracts . stargate_usdt_oft )
104119 msg = f"Unsupported token: { token } . Supported: ETH, USDC, USDT"
105120 raise StargateError (msg )
106121
@@ -168,11 +183,16 @@ def get_bridge_info(self) -> dict[str, str | int | list[str]]:
168183 >>> print(f"Flare endpoint: {info['endpoint_id']}")
169184
170185 """
186+ contracts = (
187+ self .settings .contracts .coston2
188+ if self .settings .is_testnet
189+ else self .settings .contracts .flare
190+ )
171191 return { # pyright: ignore[reportReturnType]
172192 "network" : "Flare" ,
173193 "endpoint_id" : self .FLARE_ENDPOINT_ID ,
174- "token_messaging" : self . TOKEN_MESSAGING ,
175- "treasurer" : self . TREASURER ,
194+ "token_messaging" : str ( contracts . stargate_token_messaging ) ,
195+ "treasurer" : str ( contracts . stargate_treasurer ) ,
176196 "supported_tokens" : self .get_supported_tokens (),
177197 "supported_chains" : self .get_supported_chains (),
178198 }
0 commit comments