@@ -108,12 +108,13 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
108108
109109 #exec = ( messageOrId : AbiMessage | string | number , { gasLimit = BN_ZERO , storageDepositLimit = null , value = BN_ZERO } : ContractOptions , params : unknown [ ] ) : SubmittableExtrinsic < ApiType > => {
110110 const hasStorageDeposit = this . api . tx . contracts . call . meta . args . length === 5 ;
111-
111+ const gas = this . #getGas( gasLimit ) ;
112+ const encParams = this . abi . findMessage ( messageOrId ) . toU8a ( params ) ;
112113 const tx = hasStorageDeposit
113- ? this . api . tx . contracts . call ( this . address , value , this . #getGas ( gasLimit ) , storageDepositLimit , this . abi . findMessage ( messageOrId ) . toU8a ( params ) )
114+ ? this . api . tx . contracts . call ( this . address , value , gas , storageDepositLimit , encParams )
114115 // eslint-disable-next-line @typescript-eslint/ban-ts-comment
115116 // @ts -ignore old style without storage deposit
116- : this . api . tx . contracts . call ( this . address , value , this . #getGas ( gasLimit ) , this . abi . findMessage ( messageOrId ) . toU8a ( params ) ) ;
117+ : this . api . tx . contracts . call ( this . address , value , gas , encParams ) ;
117118
118119 return tx . withResultTransform ( ( result : ISubmittableResult ) =>
119120 // ContractEmitted is the current generation, ContractExecution is the previous generation
@@ -142,11 +143,12 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
142143 // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
143144 send : this . _decorateMethod ( ( origin : string | AccountId | Uint8Array ) => {
144145 const hasStorageDeposit = this . api . tx . contracts . call . meta . args . length === 5 ;
146+ const inputData = message . toU8a ( params ) ;
145147 const rpc = hasStorageDeposit
146- ? this . api . rx . rpc . contracts . call ( { dest : this . address , gasLimit : this . #getGas( gasLimit , true ) , inputData : message . toU8a ( params ) , origin, storageDepositLimit, value } )
147- : this . api . rx . rpc . contracts . call ( { dest : this . address , gasLimit : this . #getGas( gasLimit , true ) , inputData : message . toU8a ( params ) , origin, value } ) ;
148+ ? this . api . rx . rpc . contracts . call ( { dest : this . address , gasLimit : this . #getGas( gasLimit , true ) , inputData, origin, storageDepositLimit, value } )
149+ : this . api . rx . rpc . contracts . call ( { dest : this . address , gasLimit : this . #getGas( gasLimit , true ) , inputData, origin, value } ) ;
148150
149- const mapFn = ( { debugMessage, gasConsumed, gasRequired, result } : ContractExecResult ) : ContractCallOutcome => ( {
151+ const mapFn = ( { debugMessage, gasConsumed, gasRequired, result, storageDeposit } : ContractExecResult ) : ContractCallOutcome => ( {
150152 debugMessage,
151153 gasConsumed,
152154 gasRequired : gasRequired && ! gasRequired . isZero ( )
@@ -155,12 +157,12 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
155157 output : result . isOk && message . returnType
156158 ? this . abi . registry . createTypeUnsafe ( message . returnType . lookupName || message . returnType . type , [ result . asOk . data . toU8a ( true ) ] , { isPedantic : true } )
157159 : null ,
158- result
160+ result,
161+ storageDeposit
159162 } ) ;
160163
161164 return rpc . pipe ( map ( mapFn ) ) ;
162- }
163- )
165+ } )
164166 } ;
165167 } ;
166168}
0 commit comments