@@ -12,7 +12,7 @@ use primitives::{
1212use crate :: {
1313 ESTIMATION_GAS_BUDGET , SUI_COIN_TYPE ,
1414 gas_budget:: GAS_BUDGET_MULTIPLIER ,
15- models:: { SuiCoin , SuiObject } ,
15+ models:: { Coin , OwnedCoins , SuiObject } ,
1616} ;
1717use crate :: {
1818 provider:: preload_mapper:: { map_transaction_data, map_transaction_rate_rates} ,
@@ -27,13 +27,13 @@ impl ChainTransactionLoad for SuiClient {
2727 }
2828
2929 async fn get_transaction_load ( & self , input : TransactionLoadInput ) -> Result < TransactionLoadData , Box < dyn Error + Sync + Send > > {
30- let ( gas_coins , coins , objects) = self . get_coins_for_input_type ( input. sender_address . as_str ( ) , input. input_type . clone ( ) ) . await ?;
30+ let ( sui_coins , token_coins , objects) = self . get_coins_for_input_type ( input. sender_address . as_str ( ) , input. input_type . clone ( ) ) . await ?;
3131
32- let estimate_bytes = map_transaction_data ( input. clone ( ) , gas_coins . clone ( ) , coins . clone ( ) , objects. clone ( ) , ESTIMATION_GAS_BUDGET ) ?;
32+ let estimate_bytes = map_transaction_data ( input. clone ( ) , sui_coins . clone ( ) , token_coins . clone ( ) , objects. clone ( ) , ESTIMATION_GAS_BUDGET ) ?;
3333 let fee = self . estimate_fee ( & estimate_bytes, & input. gas_price , input. is_max_value ) . await ?;
3434
3535 let message_bytes = match estimated_gas_budget ( & input. input_type , & fee) ? {
36- Some ( budget) => map_transaction_data ( input, gas_coins , coins , objects, budget) ?,
36+ Some ( budget) => map_transaction_data ( input, sui_coins , token_coins , objects, budget) ?,
3737 None => estimate_bytes,
3838 } ;
3939
@@ -75,27 +75,27 @@ impl SuiClient {
7575 & self ,
7676 address : & str ,
7777 input_type : TransactionInputType ,
78- ) -> Result < ( Vec < SuiCoin > , Vec < SuiCoin > , Vec < SuiObject > ) , Box < dyn Error + Send + Sync > > {
78+ ) -> Result < ( OwnedCoins < Coin > , Option < OwnedCoins < Coin > > , Vec < SuiObject > ) , Box < dyn Error + Send + Sync > > {
7979 match input_type {
8080 TransactionInputType :: Transfer ( asset) => match asset. id . token_id {
81- None => Ok ( ( self . get_coins ( address, SUI_COIN_TYPE ) . await ?, Vec :: new ( ) , Vec :: new ( ) ) ) ,
81+ None => Ok ( ( self . get_coins ( address, SUI_COIN_TYPE ) . await ?, None , Vec :: new ( ) ) ) ,
8282 Some ( token_id) => {
83- let ( gas_coins, coins ) = futures:: try_join!( self . get_coins( address, SUI_COIN_TYPE ) , self . get_coins( address, & token_id) ) ?;
84- Ok ( ( gas_coins, coins , Vec :: new ( ) ) )
83+ let ( gas_coins, token_coins ) = futures:: try_join!( self . get_coins( address, SUI_COIN_TYPE ) , self . get_coins( address, & token_id) ) ?;
84+ Ok ( ( gas_coins, Some ( token_coins ) , Vec :: new ( ) ) )
8585 }
8686 } ,
8787 TransactionInputType :: Stake ( _, stake_type) => match stake_type {
88- StakeType :: Stake ( _) => Ok ( ( self . get_coins ( address, SUI_COIN_TYPE ) . await ?, Vec :: new ( ) , Vec :: new ( ) ) ) ,
88+ StakeType :: Stake ( _) => Ok ( ( self . get_coins ( address, SUI_COIN_TYPE ) . await ?, None , Vec :: new ( ) ) ) ,
8989 StakeType :: Unstake ( delegation) => {
9090 let ( gas_coins, staked_object) = futures:: try_join!( self . get_coins( address, SUI_COIN_TYPE ) , self . get_object( delegation. base. delegation_id. clone( ) ) ) ?;
91- Ok ( ( gas_coins, Vec :: new ( ) , vec ! [ staked_object] ) )
91+ Ok ( ( gas_coins, None , vec ! [ staked_object] ) )
9292 }
9393 StakeType :: Redelegate ( _) | StakeType :: Rewards ( _) | StakeType :: Withdraw ( _) | StakeType :: Freeze ( _) | StakeType :: Unfreeze ( _) => {
9494 Err ( "Unsupported stake type for Sui" . into ( ) )
9595 }
9696 } ,
97- TransactionInputType :: Swap ( _, _, _) => Ok ( ( Vec :: new ( ) , Vec :: new ( ) , Vec :: new ( ) ) ) ,
98- TransactionInputType :: Generic ( _, _, _) => Ok ( ( Vec :: new ( ) , Vec :: new ( ) , Vec :: new ( ) ) ) ,
97+ TransactionInputType :: Swap ( _, _, _) => Ok ( ( OwnedCoins :: default ( ) , None , Vec :: new ( ) ) ) ,
98+ TransactionInputType :: Generic ( _, _, _) => Ok ( ( OwnedCoins :: default ( ) , None , Vec :: new ( ) ) ) ,
9999 TransactionInputType :: TransferNft ( _, _) | TransactionInputType :: Account ( _, _) => Err ( "Unsupported transaction type for Sui" . into ( ) ) ,
100100 _ => Err ( "Unsupported transaction type for Sui" . into ( ) ) ,
101101 }
0 commit comments