@@ -29,6 +29,15 @@ const mockNativeSwapFromToken = {
2929 networkId : NetworkId [ 'op-mainnet' ] ,
3030}
3131
32+ const mockCeloSwapFromToken = {
33+ tokenId : 'celo-mainnet:native' ,
34+ isNative : true ,
35+ amount : '1' ,
36+ decimals : 18 ,
37+ networkId : NetworkId [ 'celo-mainnet' ] ,
38+ address : '0x471EcE3750Da237f93B8E339c536989b8978a438' as Address ,
39+ }
40+
3241const mockErc20SwapFromToken = {
3342 tokenId : 'arbitrum-one:0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0' ,
3443 isNative : false ,
@@ -128,6 +137,51 @@ describe('prepareSwapTransactions', () => {
128137 )
129138 } )
130139
140+ it ( 'prepares swap transaction from celo native token' , async ( ) => {
141+ const { transactions, dataProps } = await prepareSwapTransactions ( {
142+ networkId : NetworkId [ 'arbitrum-one' ] ,
143+ walletAddress : '0x2b8441ef13333ffa955c9ea5ab5b3692da95260d' ,
144+ swapFromToken : mockCeloSwapFromToken ,
145+ swapToTokenAddress : '0x724dc807b04555b71ed48a6896b6f41593b8c637' ,
146+ postHook : mockPostHook ,
147+ } )
148+
149+ expect ( transactions ) . toHaveLength ( 2 )
150+ expect ( dataProps ) . toEqual ( { swapTransaction } )
151+ expect ( transactions [ 0 ] ) . toEqual ( {
152+ networkId : NetworkId [ 'celo-mainnet' ] ,
153+ from : mockWalletAddress ,
154+ to : '0x471EcE3750Da237f93B8E339c536989b8978a438' ,
155+ data : expect . any ( String ) ,
156+ } )
157+ expect ( transactions [ 1 ] ) . toEqual ( {
158+ networkId : NetworkId [ 'celo-mainnet' ] ,
159+ from : mockWalletAddress ,
160+ to : '0x12345678' ,
161+ data : '0xswapdata' ,
162+ value : 111n ,
163+ gas : 14196n ,
164+ estimatedGasUse : 12211n ,
165+ } )
166+ expect ( got . post ) . toHaveBeenCalledWith (
167+ 'https://api.mainnet.valora.xyz/getSwapQuote' ,
168+ {
169+ json : {
170+ buyToken : '0x724dc807b04555b71ed48a6896b6f41593b8c637' ,
171+ buyIsNative : false ,
172+ buyNetworkId : NetworkId [ 'arbitrum-one' ] ,
173+ sellToken : '0x471EcE3750Da237f93B8E339c536989b8978a438' ,
174+ sellIsNative : true ,
175+ sellNetworkId : NetworkId [ 'celo-mainnet' ] ,
176+ sellAmount : ( 1e18 ) . toString ( ) ,
177+ slippagePercentage : '1' ,
178+ postHook : mockPostHook ,
179+ userAddress : mockWalletAddress ,
180+ } ,
181+ } ,
182+ )
183+ } )
184+
131185 it ( 'prepares swap transaction from erc20 token with network id not set and swap has non simulated gas' , async ( ) => {
132186 mockGotPostJson . mockResolvedValueOnce ( {
133187 unvalidatedSwapTransaction : {
0 commit comments