@@ -44,9 +44,8 @@ pub fn prepare_token_transfer(
4444 TokenWalletVersion :: Tip3 => {
4545 use crate :: utils:: token_wallets;
4646 let function = token_wallets:: transfer ( ) ;
47- let amount = to_uint128 ( & tokens, "amount" ) ?;
4847 let tokens = [
49- AbiValue :: uint ( 128 , amount ) . named ( "amount" ) ,
48+ AbiValue :: uint ( 128 , tokens . to_u128 ( ) . unwrap ( ) ) . named ( "amount" ) ,
5049 AbiValue :: address ( destination) . named ( "recipient" ) ,
5150 AbiValue :: uint ( 128 , INITIAL_BALANCE ) . named ( "deployWalletValue" ) ,
5251 AbiValue :: address ( send_gas_to) . named ( "remainingGasTo" ) ,
@@ -87,9 +86,8 @@ pub fn prepare_token_burn(
8786 use crate :: utils:: token_wallets;
8887
8988 let function = token_wallets:: burnable:: burn ( ) ;
90- let amount = to_uint128 ( & tokens, "amount" ) ?;
9189 let tokens = [
92- AbiValue :: uint ( 128 , amount ) . named ( "amount" ) ,
90+ AbiValue :: uint ( 128 , tokens . to_u128 ( ) . unwrap ( ) ) . named ( "amount" ) ,
9391 AbiValue :: address ( send_gas_to) . named ( "remainingGasTo" ) ,
9492 AbiValue :: address ( callback_to) . named ( "callbackTo" ) ,
9593 AbiValue :: Cell ( payload) . named ( "payload" ) ,
@@ -127,12 +125,11 @@ pub fn prepare_token_mint(
127125 TokenWalletVersion :: Tip3 => {
128126 use crate :: utils:: token_wallets;
129127 let function = token_wallets:: mint ( ) ;
130- let amount = to_uint128 ( & tokens, "amount" ) ?;
131- let deploy_wallet_value = to_uint128 ( & deploy_wallet_value, "deployWalletValue" ) ?;
132128 let tokens = [
133- AbiValue :: uint ( 128 , amount ) . named ( "amount" ) ,
129+ AbiValue :: uint ( 128 , tokens . to_u128 ( ) . unwrap ( ) ) . named ( "amount" ) ,
134130 AbiValue :: address ( recipient) . named ( "recipient" ) ,
135- AbiValue :: uint ( 128 , deploy_wallet_value) . named ( "deployWalletValue" ) ,
131+ AbiValue :: uint ( 128 , deploy_wallet_value. to_u128 ( ) . unwrap ( ) )
132+ . named ( "deployWalletValue" ) ,
136133 AbiValue :: address ( send_gas_to) . named ( "remainingGasTo" ) ,
137134 AbiValue :: Bool ( notify) . named ( "notify" ) ,
138135 AbiValue :: Cell ( payload) . named ( "payload" ) ,
@@ -231,16 +228,8 @@ pub fn get_root_token_version(
231228 Ok ( version)
232229}
233230
234- fn to_uint128 ( value : & BigUint , field : & ' static str ) -> Result < u128 > {
235- value
236- . to_u128 ( )
237- . ok_or_else ( || TokenWalletError :: InvalidUint128 ( field) . into ( ) )
238- }
239-
240231#[ derive( thiserror:: Error , Debug ) ]
241232enum TokenWalletError {
242233 #[ error( "not supported OldTip3v4 tokens" ) ]
243234 NotSupported ,
244- #[ error( "{0} does not fit into uint128" ) ]
245- InvalidUint128 ( & ' static str ) ,
246235}
0 commit comments