Skip to content

Commit

Permalink
Improve AciContractCallEncoder:decodeCall return type
Browse files Browse the repository at this point in the history
  • Loading branch information
davidyuk committed Nov 30, 2024
1 parent 6cb6f2b commit 7ba052a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/AciContractCallEncoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ class AciContractCallEncoder {
* const data = encoder.decodeCall('Test', 'test_string', 'cb_KxHwzCuVGyl3aG9vbHltb2x5zwMSnw==')
* console.log(`Decoded data: ${data}`)
* // Outputs:
* // Decoded data: ["whoolymoly"]
* // Decoded data: { functionId: "f0cc2b95", args: ["whoolymoly"] }
*
* @param {string} contract - The contract name as defined in the ACI.
* @param {string} funName - The function name as defined in the ACI.
* @param {string} data - Encoded calldata in canonical format.
* @returns {string} Decoded data
*/
decodeCall(contract, funName, data) {
const {types, _required} = this._typeResolver.getCallTypes(contract, funName)
const {types} = this._typeResolver.getCallTypes(contract, funName)
const calldataType = FateTypeCalldata(funName, types)

return this._byteArrayEncoder.decodeWithType(data, calldataType)
Expand Down
2 changes: 1 addition & 1 deletion src/api/AciContractCallEncoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class AciContractCallEncoder {
* const data = encoder.decodeCall('Test', 'test_string', 'cb_KxHwzCuVGyl3aG9vbHltb2x5zwMSnw==')
* console.log(`Decoded data: ${data}`)
* // Outputs:
* // Decoded data: ["whoolymoly"]
* // Decoded data: { functionId: "f0cc2b95", args: ["whoolymoly"] }
*
* @param {string} contract - The contract name as defined in the ACI.
* @param {string} funName - The function name as defined in the ACI.
Expand Down
5 changes: 4 additions & 1 deletion src/main.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ export class AciContractCallEncoder {

encodeCall(contract: string, funName: string, args: any[]): `cb_${string}`;

decodeCall(contract: string, funName: string, data: `cb_${string}`): any;
decodeCall(contract: string, funName: string, data: `cb_${string}`): {
functionId: string;
args: any[];
};

decodeResult(
contract: string,
Expand Down

0 comments on commit 7ba052a

Please sign in to comment.