Skip to content

Commit

Permalink
chore: add js docs example
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasaric committed Sep 13, 2024
1 parent dddd65a commit 936f0b8
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/utils/calldata/requestParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,48 @@ function parseCalldataValue(
* @param structs - structs from abi
* @param enums - enums from abi
* @return {string | string[]} - parsed arguments in format that contract is expecting
*
* @example
* const abiEntry = { name: 'test', type: 'struct' };
* const abiStructs: AbiStructs = {
* struct: {
* members: [
* {
* name: 'test_name',
* type: 'test_type',
* offset: 1,
* },
* ],
* size: 2,
* name: 'cairo__struct',
* type: 'struct',
* },
* };
*
* const abiEnums: AbiEnums = {
* enum: {
* variants: [
* {
* name: 'test_name',
* type: 'cairo_struct_variant',
* offset: 1,
* },
* ],
* size: 2,
* name: 'test_cairo',
* type: 'enum',
* },
* };
*
* const args = [{ test_name: 'test' }];
* const argsIterator = args[Symbol.iterator]();
* const parsedField = parseCalldataField(
* argsIterator,
* abiEntry,
* abiStructs,
* abiEnums
* );
* // parsedField === ['1952805748']
*/
export function parseCalldataField(
argsIterator: Iterator<any>,
Expand Down

0 comments on commit 936f0b8

Please sign in to comment.