@@ -892,10 +892,10 @@ export class ContractEncoder {
892
892
* select an overload by other means. For enums you may also specify the
893
893
* enum type as documented in [[encodeTransaction]].
894
894
*
895
- * @param abisOrName The ABI entries for the overloads, or the name of the
896
- * function. Note that if you are inputting ABI entries, they must be
897
- * for functions, not constructors. The entries must be ones associated
898
- * with this contract.
895
+ * @param abisOrNameOrSig The ABI entries for the overloads, or the name or
896
+ * full signature of the function. Note that if you are inputting ABI
897
+ * entries, they must be for functions, not constructors. The entries must
898
+ * be ones associated with this contract.
899
899
* @param inputs An array of the inputs to the transaction. May include a
900
900
* transaction options argument on the end if the `allowOptions` flag is
901
901
* set.
@@ -904,11 +904,11 @@ export class ContractEncoder {
904
904
* [[Resolution]] object.
905
905
*/
906
906
public async resolveAndWrap (
907
- abisOrName : Abi . FunctionEntry [ ] | string ,
907
+ abisOrNameOrSig : Abi . FunctionEntry [ ] | string ,
908
908
inputs : unknown [ ] ,
909
909
options : Types . ResolveOptions = { }
910
910
) : Promise < Codec . Wrap . Resolution > {
911
- const abis = this . getAbis ( abisOrName ) ;
911
+ const abis = this . getAbis ( abisOrNameOrSig ) ;
912
912
const methods = abis . map ( abi => this . getMethod ( abi ) ) ;
913
913
//note we can't just write abis.map(this.getMethod)
914
914
//because this would be undefined inside of it... I could
@@ -1251,22 +1251,22 @@ export class ContractEncoder {
1251
1251
* In addition, input may also be given as a
1252
1252
* [[Format.Values.OptionsValue|OptionsValue]].
1253
1253
*
1254
- * @param abisOrName The ABI entries for the overloads, or the name of the
1255
- * function. Note that if you are inputting ABI entries, they must be
1256
- * for functions, not constructors. The entries must be ones associated
1257
- * with this contract.
1254
+ * @param abisOrNameOrSig The ABI entries for the overloads, or the name
1255
+ * or full signature of the function. Note that if you are inputting ABI
1256
+ * entries, they must be for functions, not constructors. The entries must
1257
+ * be ones associated with this contract.
1258
1258
* @param input The value to be interpreted. This can take a number of
1259
1259
* forms depending on the data type, as documented above.
1260
1260
* @return An object with a `tx` field, holding the transaction options,
1261
1261
* including the encoded `data`, and an `abi` field, indicating which
1262
1262
* ABI entry was used for encoding.
1263
1263
*/
1264
1264
public async encodeTransaction (
1265
- abisOrName : Abi . FunctionEntry [ ] | string ,
1265
+ abisOrNameOrSig : Abi . FunctionEntry [ ] | string ,
1266
1266
inputs : unknown [ ] ,
1267
1267
options : Types . ResolveOptions = { }
1268
1268
) : Promise < Types . TxAndAbi > {
1269
- const abis = this . getAbis ( abisOrName ) ;
1269
+ const abis = this . getAbis ( abisOrNameOrSig ) ;
1270
1270
const methods = abis . map ( abi => this . getMethod ( abi ) ) ;
1271
1271
//note we can't just write abis.map(this.getMethod)
1272
1272
//because this would be undefined inside of it... I could
@@ -1307,21 +1307,23 @@ export class ContractEncoder {
1307
1307
}
1308
1308
1309
1309
private getAbis (
1310
- abisOrName : Abi . FunctionEntry [ ] | string
1310
+ abisOrNameOrSig : Abi . FunctionEntry [ ] | string
1311
1311
) : Abi . FunctionEntry [ ] {
1312
1312
const abis : Abi . FunctionEntry [ ] =
1313
- typeof abisOrName === "string"
1313
+ typeof abisOrNameOrSig === "string"
1314
1314
? this . abi . filter (
1315
1315
( abi ) : abi is Abi . FunctionEntry =>
1316
- abi . type === "function" && abi . name === abisOrName
1316
+ abi . type === "function" &&
1317
+ ( abi . name === abisOrNameOrSig ||
1318
+ Codec . AbiData . Utils . abiSignature ( abi ) === abisOrNameOrSig )
1317
1319
)
1318
- : abisOrName ;
1319
- if ( typeof abisOrName === "string" && abis . length === 0 ) {
1320
+ : abisOrNameOrSig ;
1321
+ if ( typeof abisOrNameOrSig === "string" && abis . length === 0 ) {
1320
1322
//we don't throw this if the input was an empty list of ABIs
1321
1323
//rather than a name... the user knew what they were doing if they
1322
1324
//did that :P
1323
1325
throw new NoFunctionByThatNameError (
1324
- abisOrName ,
1326
+ abisOrNameOrSig ,
1325
1327
this . contract . contractName
1326
1328
) ;
1327
1329
}
@@ -1513,12 +1515,12 @@ export class ContractInstanceEncoder {
1513
1515
* transaction option, it will be recognized but ignored.
1514
1516
*/
1515
1517
public async encodeTransaction (
1516
- abisOrName : Abi . FunctionEntry [ ] | string ,
1518
+ abisOrNameOrSig : Abi . FunctionEntry [ ] | string ,
1517
1519
inputs : unknown [ ] ,
1518
1520
options : Types . ResolveOptions = { }
1519
1521
) : Promise < Types . TxAndAbi > {
1520
1522
const encoded = await this . contractEncoder . encodeTransaction (
1521
- abisOrName ,
1523
+ abisOrNameOrSig ,
1522
1524
inputs ,
1523
1525
options
1524
1526
) ;
0 commit comments