@@ -19,7 +19,7 @@ export class CustomTransaction extends Transaction {
1919 private _functionName : string ;
2020 private _typeArguments : string [ ] = [ ] ;
2121 private _functionArguments : Array < EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes > = [ ] ;
22- private _entryFunctionAbi ? : EntryFunctionABI ;
22+ private _entryFunctionAbi : EntryFunctionABI ;
2323
2424 constructor ( coinConfig : Readonly < CoinConfig > ) {
2525 super ( coinConfig ) ;
@@ -34,11 +34,13 @@ export class CustomTransaction extends Transaction {
3434 setCustomTransactionParams ( params : CustomTransactionParams ) : void {
3535 this . validateModuleName ( params . moduleName ) ;
3636 this . validateFunctionName ( params . functionName ) ;
37+ this . validateAbi ( params . abi ) ;
3738
3839 this . _moduleName = params . moduleName ;
3940 this . _functionName = params . functionName ;
4041 this . _typeArguments = params . typeArguments || [ ] ;
4142 this . _functionArguments = params . functionArguments || [ ] ;
43+ this . _entryFunctionAbi = params . abi ;
4244 }
4345
4446 /**
@@ -122,6 +124,7 @@ export class CustomTransaction extends Transaction {
122124 functionName : this . _functionName || '' ,
123125 typeArguments : this . _typeArguments ,
124126 functionArguments : this . _functionArguments ,
127+ abi : this . _entryFunctionAbi ,
125128 } ;
126129 }
127130
@@ -207,4 +210,24 @@ export class CustomTransaction extends Transaction {
207210
208211 return fullName as `${string } ::${string } ::${string } `;
209212 }
213+
214+ /**
215+ * Validate ABI structure and provide helpful error messages
216+ *
217+ * @param {EntryFunctionABI } abi - The ABI to validate
218+ * @throws {Error } If ABI format is invalid
219+ */
220+ private validateAbi ( abi : EntryFunctionABI ) : void {
221+ if ( ! abi || typeof abi !== 'object' ) {
222+ throw new Error ( 'ABI must be a valid EntryFunctionABI object' ) ;
223+ }
224+
225+ if ( ! Array . isArray ( abi . typeParameters ) ) {
226+ throw new Error ( 'ABI must have a typeParameters array. Use [] if the function has no type parameters' ) ;
227+ }
228+
229+ if ( ! Array . isArray ( abi . parameters ) ) {
230+ throw new Error ( 'ABI must have a parameters array containing TypeTag objects for each function parameter' ) ;
231+ }
232+ }
210233}
0 commit comments