@algorandfoundation/algokit-utils 10.0.0-alpha.21 → 10.0.0-alpha.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"abi-type.mjs","names":["childTypes: ABIType[]","bitSize: number","precision: number","encodedBytes: Uint8Array","typeStrings: string[]","heads: Uint8Array[]","tails: Uint8Array[]","values: ABIValue[]","childType: ABIType","length: number","structName: string","structFields: ABIStructField[]","dynamicSegments: Segment[]","valuePartitions: (Uint8Array | null)[]","result: Uint8Array[]","tupleStrings: string[]"],"sources":["../../../../packages/abi/src/abi-type.ts"],"sourcesContent":["import {\n Address,\n BOOL_FALSE_BYTE,\n BOOL_TRUE_BYTE,\n LENGTH_ENCODE_BYTE_SIZE,\n PUBLIC_KEY_BYTE_LENGTH,\n concatArrays,\n} from '@algorandfoundation/algokit-common'\nimport type { ABIStructValue, ABIValue } from './abi-value'\nimport { StructField } from './arc56-contract'\nimport { bigIntToBytes, bytesToBigInt } from './bigint'\n\nconst STATIC_ARRAY_REGEX = /^([a-z\\d[\\](),]+)\\[(0|[1-9][\\d]*)]$/\nconst UFIXED_REGEX = /^ufixed([1-9][\\d]*)x([1-9][\\d]*)$/\nconst MAX_LEN = 2 ** 16 - 1\n\n/**\n * Information about a single field in a struct\n */\nexport type ABIStructField = {\n /** The name of the struct field */\n name: string\n /** The type of the struct field's value */\n type: ABIType | ABIStructField[]\n}\n\ninterface Segment {\n left: number\n right: number\n}\n\n/**\n * Represents an Algorand ABI type for encoding and decoding values as defined in [ARC-0004](https://arc.algorand.foundation/ARCs/arc-0004#types).\n *\n * This is the abstract base class for all ABI types.\n */\nexport abstract class ABIType {\n /**\n * Returns the ARC-4 type name string representation.\n * @returns The ARC-4 type string\n */\n abstract get name(): string\n\n /**\n * Returns a user-friendly display name for this type.\n * @returns The display name for this type\n */\n get displayName(): string {\n return this.name\n }\n\n /**\n * Returns the ARC-4 type name string representation.\n * @returns The ARC-4 type string\n */\n toString(): string {\n return this.name\n }\n\n /**\n * Checks if this ABI type is equal to another.\n * @param other The other ABI type to compare with\n * @returns True if the types are equal, false otherwise\n */\n abstract equals(other: ABIType): boolean\n\n /**\n * Checks if this ABI type is dynamic (variable-length).\n * @returns True if the type is dynamic, false otherwise\n */\n abstract isDynamic(): boolean\n\n /**\n * Gets the byte length of the encoded type for static types.\n * @returns The number of bytes needed to encode this type\n * @throws Error if the type is dynamic\n */\n abstract byteLen(): number\n\n /**\n * Encodes a value according to this ABI type.\n * @param value The value to encode\n * @returns The encoded bytes\n */\n abstract encode(value: ABIValue): Uint8Array\n\n /**\n * Decodes bytes according to this ABI type.\n * @param bytes The bytes to decode\n * @returns The decoded value\n */\n abstract decode(bytes: Uint8Array): ABIValue\n\n /**\n * Creates an ABI type from an ARC-4 type string.\n * @param str The ARC-4 type string (e.g., \"uint256\", \"bool\", \"(uint8,address)\")\n * @returns The corresponding ABI type\n */\n static from(str: string): ABIType {\n if (str.endsWith('[]')) {\n const childType = ABIType.from(str.slice(0, str.length - 2))\n return new ABIArrayDynamicType(childType)\n }\n if (str.endsWith(']')) {\n const stringMatches = str.match(STATIC_ARRAY_REGEX)\n if (!stringMatches || stringMatches.length !== 3) {\n throw new Error(`Malformed static array string: ${str}`)\n }\n const arrayLengthStr = stringMatches[2]\n const arrayLength = parseInt(arrayLengthStr, 10)\n if (arrayLength > MAX_LEN) {\n throw new Error(`Array length exceeds limit ${MAX_LEN}`)\n }\n const childType = ABIType.from(stringMatches[1])\n return new ABIArrayStaticType(childType, arrayLength)\n }\n if (str.startsWith('uint')) {\n const digitsOnly = (s: string) => [...s].every((c) => '0123456789'.includes(c))\n const typeSizeStr = str.slice(4, str.length)\n if (!digitsOnly(typeSizeStr)) {\n throw new Error(`Malformed uint string: ${typeSizeStr}`)\n }\n const bitSize = parseInt(typeSizeStr, 10)\n if (bitSize > MAX_LEN) {\n throw new Error(`Malformed uint string: ${bitSize}`)\n }\n return new ABIUintType(bitSize)\n }\n if (str === 'byte') {\n return new ABIByteType()\n }\n if (str.startsWith('ufixed')) {\n const stringMatches = str.match(UFIXED_REGEX)\n if (!stringMatches || stringMatches.length !== 3) {\n throw new Error(`Malformed ufixed type: ${str}`)\n }\n const bitSize = parseInt(stringMatches[1], 10)\n const precision = parseInt(stringMatches[2], 10)\n return new ABIUfixedType(bitSize, precision)\n }\n if (str === 'bool') {\n return new ABIBoolType()\n }\n if (str === 'address') {\n return new ABIAddressType()\n }\n if (str === 'string') {\n return new ABIStringType()\n }\n if (str.length >= 2 && str[0] === '(' && str[str.length - 1] === ')') {\n const tupleContent = parseTupleContent(str.slice(1, str.length - 1))\n const childTypes: ABIType[] = []\n for (let i = 0; i < tupleContent.length; i++) {\n const ti = ABIType.from(tupleContent[i])\n childTypes.push(ti)\n }\n return new ABITupleType(childTypes)\n }\n throw new Error(`Cannot convert a string ${str} to an ABI type`)\n }\n}\n\n// ============================================================================\n// Primitive Types\n// ============================================================================\n\n/**\n * An unsigned integer ABI type of a specific bit size.\n */\nexport class ABIUintType extends ABIType {\n /**\n * Creates a new unsigned integer type.\n * @param bitSize The bit size (must be a multiple of 8, between 8 and 512)\n */\n constructor(public readonly bitSize: number) {\n super()\n if (bitSize % 8 !== 0 || bitSize < 8 || bitSize > 512) {\n throw new Error(`Unsupported uint type bitSize: ${bitSize}`)\n }\n }\n\n get name(): string {\n return `uint${this.bitSize}`\n }\n\n equals(other: ABIType): boolean {\n return other instanceof ABIUintType && this.bitSize === other.bitSize\n }\n\n isDynamic(): boolean {\n return false\n }\n\n byteLen(): number {\n return this.bitSize / 8\n }\n\n encode(value: ABIValue): Uint8Array {\n if (typeof value !== 'bigint' && typeof value !== 'number') {\n throw new Error(`Cannot encode value as ${this.name}: ${value}`)\n }\n\n if (value >= BigInt(2 ** this.bitSize) || value < BigInt(0)) {\n throw new Error(`${value} is not a non-negative int or too big to fit in size ${this.name}`)\n }\n if (typeof value === 'number' && !Number.isSafeInteger(value)) {\n throw new Error(`${value} should be converted into a BigInt before it is encoded`)\n }\n return bigIntToBytes(value, this.bitSize / 8)\n }\n\n decode(bytes: Uint8Array): ABIValue {\n if (bytes.length !== this.bitSize / 8) {\n throw new Error(`Byte string must correspond to a ${this.name}`)\n }\n const value = bytesToBigInt(bytes)\n return this.bitSize < 53 ? Number(value) : value\n }\n}\n\n/**\n * A fixed-point number ABI type of a specific bit size and precision.\n */\nexport class ABIUfixedType extends ABIType {\n /**\n * Creates a new fixed-point type.\n * @param bitSize The bit size (must be a multiple of 8, between 8 and 512)\n * @param precision The decimal precision (must be between 1 and 160)\n */\n constructor(\n public readonly bitSize: number,\n public readonly precision: number,\n ) {\n super()\n if (bitSize % 8 !== 0 || bitSize < 8 || bitSize > 512) {\n throw new Error(`Unsupported ufixed type bitSize: ${bitSize}`)\n }\n if (precision > 160 || precision < 1) {\n throw new Error(`Unsupported ufixed type precision: ${precision}`)\n }\n }\n\n get name(): string {\n return `ufixed${this.bitSize}x${this.precision}`\n }\n\n equals(other: ABIType): boolean {\n return other instanceof ABIUfixedType && this.bitSize === other.bitSize && this.precision === other.precision\n }\n\n isDynamic(): boolean {\n return false\n }\n\n byteLen(): number {\n return this.bitSize / 8\n }\n\n encode(value: ABIValue): Uint8Array {\n if (typeof value !== 'bigint' && typeof value !== 'number') {\n throw new Error(`Cannot encode value as ${this.name}: ${value}`)\n }\n if (value >= BigInt(2 ** this.bitSize) || value < BigInt(0)) {\n throw new Error(`${value} is not a non-negative int or too big to fit in size ${this.name}`)\n }\n if (typeof value === 'number' && !Number.isSafeInteger(value)) {\n throw new Error(`${value} should be converted into a BigInt before it is encoded`)\n }\n return bigIntToBytes(value, this.bitSize / 8)\n }\n\n decode(bytes: Uint8Array): ABIValue {\n if (bytes.length !== this.bitSize / 8) {\n throw new Error(`Byte string must correspond to a ${this.name}`)\n }\n const value = bytesToBigInt(bytes)\n return this.bitSize < 53 ? Number(value) : value\n }\n}\n\n/**\n * An Algorand address ABI type.\n */\nexport class ABIAddressType extends ABIType {\n get name(): string {\n return 'address'\n }\n\n equals(other: ABIType): boolean {\n return other instanceof ABIAddressType\n }\n\n isDynamic(): boolean {\n return false\n }\n\n byteLen(): number {\n return PUBLIC_KEY_BYTE_LENGTH\n }\n\n encode(value: ABIValue): Uint8Array {\n if (typeof value === 'string') {\n return Address.fromString(value).publicKey\n }\n\n if (value instanceof Address) {\n return value.publicKey\n }\n\n if (value instanceof Uint8Array && value.length === 32) {\n return value\n }\n\n throw new Error(`Cannot encode value as address: ${value}`)\n }\n\n decode(bytes: Uint8Array): string {\n return new Address(bytes).toString()\n }\n}\n\n/**\n * A boolean ABI type.\n */\nexport class ABIBoolType extends ABIType {\n get name(): string {\n return 'bool'\n }\n\n equals(other: ABIType): boolean {\n return other instanceof ABIBoolType\n }\n\n isDynamic(): boolean {\n return false\n }\n\n byteLen(): number {\n return 1\n }\n\n encode(value: ABIValue): Uint8Array {\n if (typeof value !== 'boolean') {\n throw new Error(`Cannot encode value as bool: ${value}`)\n }\n\n return value ? new Uint8Array([0x80]) : new Uint8Array([0x00])\n }\n\n decode(bytes: Uint8Array): ABIValue {\n if (bytes.length !== 1) {\n throw new Error(`Expected 1 byte for bool, got ${bytes.length}`)\n }\n\n return (bytes[0] & 0x80) !== 0\n }\n}\n\n/**\n * A single byte ABI type.\n */\nexport class ABIByteType extends ABIType {\n get name(): string {\n return 'byte'\n }\n\n equals(other: ABIType): boolean {\n return other instanceof ABIByteType\n }\n\n isDynamic(): boolean {\n return false\n }\n\n byteLen(): number {\n return 1\n }\n\n encode(value: ABIValue): Uint8Array {\n if (typeof value !== 'number' && typeof value !== 'bigint') {\n throw new Error(`Cannot encode value as byte: ${value}`)\n }\n const numberValue = typeof value === 'bigint' ? Number(value) : value\n if (value < 0 || value > 255) {\n throw new Error(`Byte value must be between 0 and 255, got ${numberValue}`)\n }\n\n return new Uint8Array([numberValue])\n }\n\n decode(bytes: Uint8Array): ABIValue {\n if (bytes.length !== 1) {\n throw new Error(`Expected 1 byte for byte type, got ${bytes.length}`)\n }\n\n return bytes[0]\n }\n}\n\n/**\n * A dynamic-length string ABI type.\n */\nexport class ABIStringType extends ABIType {\n get name(): string {\n return 'string'\n }\n\n equals(other: ABIType): boolean {\n return other instanceof ABIStringType\n }\n\n isDynamic(): boolean {\n return true\n }\n\n byteLen(): number {\n throw new Error(`Failed to get size, string is a dynamic type`)\n }\n\n encode(value: ABIValue): Uint8Array {\n if (typeof value !== 'string' && !(value instanceof Uint8Array)) {\n throw new Error(`Cannot encode value as string: ${value}`)\n }\n\n let encodedBytes: Uint8Array\n if (typeof value === 'string') {\n encodedBytes = new TextEncoder().encode(value)\n } else {\n encodedBytes = value\n }\n const encodedLength = bigIntToBytes(encodedBytes.length, LENGTH_ENCODE_BYTE_SIZE)\n const mergedBytes = new Uint8Array(encodedBytes.length + LENGTH_ENCODE_BYTE_SIZE)\n mergedBytes.set(encodedLength)\n mergedBytes.set(encodedBytes, LENGTH_ENCODE_BYTE_SIZE)\n return mergedBytes\n }\n\n decode(bytes: Uint8Array): ABIValue {\n if (bytes.length < LENGTH_ENCODE_BYTE_SIZE) {\n throw new Error(\n `Byte string is too short to be decoded. Actual length is ${bytes.length}, but expected at least ${LENGTH_ENCODE_BYTE_SIZE}`,\n )\n }\n const view = new DataView(bytes.buffer, bytes.byteOffset, LENGTH_ENCODE_BYTE_SIZE)\n const byteLength = view.getUint16(0)\n const byteValue = bytes.slice(LENGTH_ENCODE_BYTE_SIZE, bytes.length)\n if (byteLength !== byteValue.length) {\n throw new Error(`String length bytes do not match the actual length of string. Expected ${byteLength}, got ${byteValue.length}`)\n }\n return new TextDecoder('utf-8').decode(byteValue)\n }\n}\n\n// ============================================================================\n// Collection Types\n// ============================================================================\n\n/**\n * A tuple ABI type containing other ABI types.\n */\nexport class ABITupleType extends ABIType {\n /**\n * Creates a new tuple type.\n * @param childTypes The types of the tuple elements\n */\n constructor(public readonly childTypes: ABIType[]) {\n super()\n if (childTypes.length > MAX_LEN) {\n throw new Error(`Tuple has too many child types: ${childTypes.length}`)\n }\n }\n\n get name(): string {\n const typeStrings: string[] = []\n for (let i = 0; i < this.childTypes.length; i++) {\n typeStrings[i] = this.childTypes[i].name\n }\n return `(${typeStrings.join(',')})`\n }\n\n equals(other: ABIType): boolean {\n if (!(other instanceof ABITupleType)) return false\n if (this.childTypes.length !== other.childTypes.length) return false\n return this.childTypes.every((t, i) => t.equals(other.childTypes[i]))\n }\n\n isDynamic(): boolean {\n return this.childTypes.some((c) => c.isDynamic())\n }\n\n byteLen(): number {\n let size = 0\n let i = 0\n while (i < this.childTypes.length) {\n const childType = this.childTypes[i]\n if (childType instanceof ABIBoolType) {\n const sequenceEndIndex = findBoolSequenceEnd(this.childTypes, i)\n const boolCount = sequenceEndIndex - i + 1\n size += Math.ceil(boolCount / 8)\n i = sequenceEndIndex + 1\n } else {\n size += childType.byteLen()\n i++\n }\n }\n return size\n }\n\n encode(value: ABIValue): Uint8Array {\n if (!Array.isArray(value) && !(value instanceof Uint8Array)) {\n throw new Error(`Cannot encode value as ${this.toString()}: ${value}`)\n }\n\n const values = Array.from(value)\n\n if (this.childTypes.length !== values.length) {\n throw new Error('Mismatch lengths between the values and types')\n }\n\n const heads: Uint8Array[] = []\n const tails: Uint8Array[] = []\n const isDynamicIndex = new Map<number, boolean>()\n let abiTypesCursor = 0\n\n while (abiTypesCursor < this.childTypes.length) {\n const childType = this.childTypes[abiTypesCursor]\n\n if (childType.isDynamic()) {\n isDynamicIndex.set(heads.length, true)\n heads.push(new Uint8Array(2)) // Placeholder for dynamic offset\n tails.push(childType.encode(values[abiTypesCursor]))\n } else {\n if (childType instanceof ABIBoolType) {\n const boolSequenceEndIndex = findBoolSequenceEnd(this.childTypes, abiTypesCursor)\n const boolValues = values.slice(abiTypesCursor, boolSequenceEndIndex + 1)\n const compressedBool = compressBools(boolValues)\n heads.push(new Uint8Array([compressedBool]))\n abiTypesCursor = boolSequenceEndIndex\n } else {\n heads.push(childType.encode(values[abiTypesCursor]))\n }\n isDynamicIndex.set(abiTypesCursor, false)\n tails.push(new Uint8Array(0))\n }\n abiTypesCursor += 1\n }\n\n const headLength = heads.reduce((sum, head) => sum + head.length, 0)\n let tailLength = 0\n\n for (let i = 0; i < heads.length; i++) {\n if (isDynamicIndex.get(i)) {\n const headValue = headLength + tailLength\n if (headValue > 0xffff) {\n throw new Error(`Value ${headValue} cannot fit in u16`)\n }\n heads[i] = new Uint8Array([(headValue >> 8) & 0xff, headValue & 0xff])\n }\n tailLength += tails[i].length\n }\n\n const totalLength = heads.reduce((sum, head) => sum + head.length, 0) + tails.reduce((sum, tail) => sum + tail.length, 0)\n const result = new Uint8Array(totalLength)\n let offset = 0\n\n for (const head of heads) {\n result.set(head, offset)\n offset += head.length\n }\n\n for (const tail of tails) {\n result.set(tail, offset)\n offset += tail.length\n }\n\n return result\n }\n\n decode(bytes: Uint8Array): ABIValue[] {\n const valuePartitions = extractValues(this.childTypes, bytes)\n const values: ABIValue[] = []\n\n for (let i = 0; i < this.childTypes.length; i++) {\n const childType = this.childTypes[i]\n const valuePartition = valuePartitions[i]\n const childValue = childType.decode(valuePartition)\n values.push(childValue)\n }\n\n return values\n }\n}\n\n/**\n * A static-length array ABI type.\n */\nexport class ABIArrayStaticType extends ABIType {\n /**\n * Creates a new static array type.\n * @param childType The type of the array elements\n * @param length The fixed length of the array\n */\n constructor(\n public readonly childType: ABIType,\n public readonly length: number,\n ) {\n super()\n if (length < 0 || length > MAX_LEN) {\n throw new Error(`Invalid static array length: ${length}`)\n }\n }\n\n get name(): string {\n return `${this.childType.name}[${this.length}]`\n }\n\n equals(other: ABIType): boolean {\n return other instanceof ABIArrayStaticType && this.childType.equals(other.childType) && this.length === other.length\n }\n\n isDynamic(): boolean {\n return this.childType.isDynamic()\n }\n\n byteLen(): number {\n if (this.childType instanceof ABIBoolType) {\n return Math.ceil(this.length / 8)\n }\n return this.childType.byteLen() * this.length\n }\n\n /**\n * Converts this static array type to an equivalent tuple type.\n * @returns The equivalent tuple type\n */\n toABITupleType(): ABITupleType {\n return new ABITupleType(Array(this.length).fill(this.childType))\n }\n\n encode(value: ABIValue): Uint8Array {\n if (!Array.isArray(value) && !(value instanceof Uint8Array)) {\n throw new Error(`Cannot encode value as ${this.name}: ${value}`)\n }\n if (value.length !== this.length) {\n throw new Error(`Value array does not match static array length. Expected ${this.length}, got ${value.length}`)\n }\n const convertedTuple = this.toABITupleType()\n return convertedTuple.encode(value)\n }\n\n decode(bytes: Uint8Array): ABIValue[] | Uint8Array {\n const convertedTuple = this.toABITupleType()\n const decoded = convertedTuple.decode(bytes)\n\n // Convert byte arrays to Uint8Array\n if (this.childType instanceof ABIByteType && Array.isArray(decoded)) {\n return new Uint8Array(decoded as number[])\n }\n\n return decoded\n }\n}\n\n/**\n * A dynamic-length array ABI type.\n */\nexport class ABIArrayDynamicType extends ABIType {\n /**\n * Creates a new dynamic array type.\n * @param childType The type of the array elements\n */\n constructor(public readonly childType: ABIType) {\n super()\n }\n\n get name(): string {\n return `${this.childType.name}[]`\n }\n\n equals(other: ABIType): boolean {\n return other instanceof ABIArrayDynamicType && this.childType.equals(other.childType)\n }\n\n isDynamic(): boolean {\n return true\n }\n\n byteLen(): number {\n throw new Error(`Failed to get size, dynamic array is a dynamic type`)\n }\n\n /**\n * Converts this dynamic array type to an equivalent tuple type of a given length.\n * @param length The number of elements\n * @returns The equivalent tuple type\n */\n toABITupleType(length: number): ABITupleType {\n return new ABITupleType(Array(length).fill(this.childType))\n }\n\n encode(value: ABIValue): Uint8Array {\n if (!Array.isArray(value) && !(value instanceof Uint8Array)) {\n throw new Error(`Cannot encode value as ${this.name}: ${value}`)\n }\n const convertedTuple = this.toABITupleType(value.length)\n const encodedTuple = convertedTuple.encode(value)\n const encodedLength = bigIntToBytes(convertedTuple.childTypes.length, LENGTH_ENCODE_BYTE_SIZE)\n return concatArrays(encodedLength, encodedTuple)\n }\n\n decode(bytes: Uint8Array): ABIValue[] | Uint8Array {\n const view = new DataView(bytes.buffer, 0, LENGTH_ENCODE_BYTE_SIZE)\n const byteLength = view.getUint16(0)\n const convertedTuple = this.toABITupleType(byteLength)\n const decoded = convertedTuple.decode(bytes.slice(LENGTH_ENCODE_BYTE_SIZE, bytes.length))\n\n // Convert byte arrays to Uint8Array\n if (this.childType instanceof ABIByteType && Array.isArray(decoded)) {\n return new Uint8Array(decoded as number[])\n }\n\n return decoded\n }\n}\n\n/**\n * A struct ABI type with named fields.\n */\nexport class ABIStructType extends ABIType {\n /**\n * Creates a new struct type.\n * @param structName The name of the struct\n * @param structFields The fields of the struct\n */\n constructor(\n public readonly structName: string,\n public readonly structFields: ABIStructField[],\n ) {\n super()\n }\n\n get name(): string {\n const tupleType = this.toABITupleType()\n return tupleType.name\n }\n\n get displayName(): string {\n return this.structName\n }\n\n equals(other: ABIType): boolean {\n if (!(other instanceof ABIStructType)) return false\n if (this.structName !== other.structName) return false\n if (this.structFields.length !== other.structFields.length) return false\n return this.structFields.every((f, i) => {\n const otherField = other.structFields[i]\n if (f.name !== otherField.name) return false\n if (Array.isArray(f.type) && Array.isArray(otherField.type)) {\n return JSON.stringify(f.type) === JSON.stringify(otherField.type)\n }\n if (f.type instanceof ABIType && otherField.type instanceof ABIType) {\n return f.type.equals(otherField.type)\n }\n return false\n })\n }\n\n isDynamic(): boolean {\n const tupleType = this.toABITupleType()\n return tupleType.isDynamic()\n }\n\n byteLen(): number {\n const tupleType = this.toABITupleType()\n return tupleType.byteLen()\n }\n\n /**\n * Converts this struct type to an equivalent tuple type.\n * @returns The equivalent tuple type\n */\n toABITupleType(): ABITupleType {\n const getABITupleTypeFromABIStructFields = (fields: ABIStructField[]): ABITupleType => {\n const childTypes = fields.map((field) =>\n Array.isArray(field.type)\n ? getABITupleTypeFromABIStructFields(field.type)\n : field.type instanceof ABIStructType\n ? field.type.toABITupleType()\n : field.type,\n )\n return new ABITupleType(childTypes)\n }\n\n return getABITupleTypeFromABIStructFields(this.structFields)\n }\n\n /**\n * Creates an ABIStructType from struct name and struct definitions.\n * @param structName The name of the struct\n * @param structs A record of struct definitions\n * @returns The struct type\n */\n static fromStruct(structName: string, structs: Record<string, StructField[]>): ABIStructType {\n const getStructFieldType = (structFieldType: string | StructField[]): ABIType | ABIStructField[] => {\n // When the input is an array of struct fields\n if (Array.isArray(structFieldType)) {\n return structFieldType.map((structField) => ({\n name: structField.name,\n type: getStructFieldType(structField.type),\n }))\n }\n\n // When the input is a name of another struct\n if (structs[structFieldType]) {\n return ABIStructType.fromStruct(structFieldType, structs)\n }\n\n // When the input in an ABI type name\n return ABIType.from(structFieldType)\n }\n\n if (!structs[structName]) throw new Error('Struct not found')\n\n const fields = structs[structName]\n return new ABIStructType(\n structName,\n fields.map((f) => ({\n name: f.name,\n type: getStructFieldType(f.type),\n })),\n )\n }\n\n encode(value: ABIValue): Uint8Array {\n if (value instanceof Uint8Array || value instanceof Address || typeof value !== 'object') {\n throw new Error(`Cannot encode value as ${this.name}: ${value}`)\n }\n\n const tupleType = this.toABITupleType()\n if (Array.isArray(value)) {\n return tupleType.encode(value)\n }\n\n const tupleValue = this.getTupleValueFromStructValue(value)\n return tupleType.encode(tupleValue)\n }\n\n decode(bytes: Uint8Array): ABIStructValue {\n const tupleType = this.toABITupleType()\n const tupleValue = tupleType.decode(bytes)\n return this.getStructValueFromTupleValue(tupleValue)\n }\n\n private getTupleValueFromStructValue(structValue: ABIStructValue): ABIValue[] {\n const getTupleValueFromStructFields = (structFields: ABIStructField[], values: ABIValue[]): ABIValue[] => {\n return structFields.map(({ type }, index) => {\n // if type is an array of fields, treat as unnamed struct\n if (Array.isArray(type)) {\n const value = values[index] as ABIStructValue\n return getTupleValueFromStructFields(type, Object.values(value))\n }\n // if type is struct, treat as struct\n if (type instanceof ABIStructType) {\n const value = values[index] as ABIStructValue\n return getTupleValueFromStructFields(type.structFields, Object.values(value))\n }\n return values[index]\n })\n }\n\n return getTupleValueFromStructFields(this.structFields, Object.values(structValue))\n }\n\n private getStructValueFromTupleValue(tupleValue: ABIValue[]): ABIStructValue {\n const getStructFieldValues = (structFields: ABIStructField[], values: ABIValue[]): ABIStructValue => {\n return Object.fromEntries(\n structFields.map(({ name, type }, index) => {\n // When the type is an array of fields, the value must be tuple\n if (Array.isArray(type)) {\n const value = values[index] as ABIValue[]\n return [name, getStructFieldValues(type, value)]\n }\n // When the type is a struct, the value must be tuple\n if (type instanceof ABIStructType) {\n const value = values[index] as ABIValue[]\n return [name, getStructFieldValues(type.structFields, value)]\n }\n return [name, values[index]]\n }),\n )\n }\n\n return getStructFieldValues(this.structFields, tupleValue)\n }\n}\n\n// ============================================================================\n// Helper Functions\n// ============================================================================\n\nfunction compressBools(values: ABIValue[]): number {\n if (values.length > 8) {\n throw new Error(`Expected no more than 8 bool values, received ${values.length}`)\n }\n\n let result = 0\n for (let i = 0; i < values.length; i++) {\n if (typeof values[i] !== 'boolean') {\n throw new Error('Expected all values to be boolean')\n }\n if (values[i]) {\n result |= 1 << (7 - i)\n }\n }\n\n return result\n}\n\nfunction findBoolSequenceEnd(abiTypes: ABIType[], currentIndex: number): number {\n let cursor = currentIndex\n while (cursor < abiTypes.length) {\n if (abiTypes[cursor] instanceof ABIBoolType) {\n if (cursor - currentIndex + 1 === 8 || cursor === abiTypes.length - 1) {\n return cursor\n }\n cursor++\n } else {\n return cursor - 1\n }\n }\n return cursor - 1\n}\n\nfunction extractValues(abiTypes: ABIType[], bytes: Uint8Array): Uint8Array[] {\n const dynamicSegments: Segment[] = []\n const valuePartitions: (Uint8Array | null)[] = []\n let bytesCursor = 0\n let abiTypesCursor = 0\n\n while (abiTypesCursor < abiTypes.length) {\n const childType = abiTypes[abiTypesCursor]\n\n if (childType.isDynamic()) {\n if (bytes.length - bytesCursor < LENGTH_ENCODE_BYTE_SIZE) {\n throw new Error('Byte array is too short to be decoded')\n }\n\n const dynamicIndex = (bytes[bytesCursor] << 8) | bytes[bytesCursor + 1]\n\n if (dynamicSegments.length > 0) {\n const lastSegment = dynamicSegments[dynamicSegments.length - 1]\n if (dynamicIndex < lastSegment.left) {\n throw new Error('Dynamic index segment miscalculation: left is greater than right index')\n }\n lastSegment.right = dynamicIndex\n }\n\n dynamicSegments.push({ left: dynamicIndex, right: 0 })\n valuePartitions.push(null)\n bytesCursor += LENGTH_ENCODE_BYTE_SIZE\n } else {\n if (childType instanceof ABIBoolType) {\n const boolSequenceEndIndex = findBoolSequenceEnd(abiTypes, abiTypesCursor)\n for (let j = 0; j <= boolSequenceEndIndex - abiTypesCursor; j++) {\n const boolMask = BOOL_TRUE_BYTE >> j\n if ((bytes[bytesCursor] & boolMask) > 0) {\n valuePartitions.push(new Uint8Array([BOOL_TRUE_BYTE]))\n } else {\n valuePartitions.push(new Uint8Array([BOOL_FALSE_BYTE]))\n }\n }\n abiTypesCursor = boolSequenceEndIndex\n bytesCursor += 1\n } else {\n const childTypeSize = childType.byteLen()\n if (bytesCursor + childTypeSize > bytes.length) {\n throw new Error(\n `Index out of bounds, trying to access bytes[${bytesCursor}..${bytesCursor + childTypeSize}] but slice has length ${bytes.length}`,\n )\n }\n valuePartitions.push(bytes.slice(bytesCursor, bytesCursor + childTypeSize))\n bytesCursor += childTypeSize\n }\n }\n\n if (abiTypesCursor !== abiTypes.length - 1 && bytesCursor >= bytes.length) {\n throw new Error('Input bytes not enough to decode')\n }\n abiTypesCursor += 1\n }\n\n if (dynamicSegments.length > 0) {\n const lastSegment = dynamicSegments[dynamicSegments.length - 1]\n lastSegment.right = bytes.length\n } else if (bytesCursor < bytes.length) {\n throw new Error('Input bytes not fully consumed')\n }\n\n for (let i = 0; i < dynamicSegments.length; i++) {\n const segment = dynamicSegments[i]\n if (segment.left > segment.right) {\n throw new Error('Dynamic segment should display a [l, r] space with l <= r')\n }\n if (i !== dynamicSegments.length - 1 && segment.right !== dynamicSegments[i + 1].left) {\n throw new Error('Dynamic segments should be consecutive')\n }\n }\n\n let segmentIndex = 0\n for (let i = 0; i < abiTypes.length; i++) {\n const childType = abiTypes[i]\n if (childType.isDynamic()) {\n valuePartitions[i] = bytes.slice(dynamicSegments[segmentIndex].left, dynamicSegments[segmentIndex].right)\n segmentIndex += 1\n }\n }\n\n const result: Uint8Array[] = []\n for (let i = 0; i < valuePartitions.length; i++) {\n const partition = valuePartitions[i]\n if (partition === null) {\n throw new Error(`Value partition at index ${i} is None`)\n }\n result.push(partition)\n }\n\n return result\n}\n\nexport function parseTupleContent(content: string): string[] {\n if (content === '') {\n return []\n }\n\n if (content.startsWith(',')) {\n throw new Error('The content should not start with comma')\n }\n if (content.endsWith(',')) {\n throw new Error('The content should not end with comma')\n }\n if (content.includes(',,')) {\n throw new Error('The content should not have consecutive commas')\n }\n\n const tupleStrings: string[] = []\n let depth = 0\n let word = ''\n\n for (const ch of content) {\n word += ch\n if (ch === '(') {\n depth += 1\n } else if (ch === ')') {\n depth -= 1\n } else if (ch === ',' && depth === 0) {\n word = word.slice(0, -1) // Remove the comma\n tupleStrings.push(word)\n word = ''\n }\n }\n\n if (word !== '') {\n tupleStrings.push(word)\n }\n\n if (depth !== 0) {\n throw new Error('The content has mismatched parentheses')\n }\n\n return tupleStrings\n}\n"],"mappings":";;;;;;AAYA,MAAM,qBAAqB;AAC3B,MAAM,eAAe;AACrB,MAAM,UAAU,KAAK,KAAK;;;;;;AAsB1B,IAAsB,UAAtB,MAAsB,QAAQ;;;;;CAW5B,IAAI,cAAsB;AACxB,SAAO,KAAK;;;;;;CAOd,WAAmB;AACjB,SAAO,KAAK;;;;;;;CA0Cd,OAAO,KAAK,KAAsB;AAChC,MAAI,IAAI,SAAS,KAAK,CAEpB,QAAO,IAAI,oBADO,QAAQ,KAAK,IAAI,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC,CACnB;AAE3C,MAAI,IAAI,SAAS,IAAI,EAAE;GACrB,MAAM,gBAAgB,IAAI,MAAM,mBAAmB;AACnD,OAAI,CAAC,iBAAiB,cAAc,WAAW,EAC7C,OAAM,IAAI,MAAM,kCAAkC,MAAM;GAE1D,MAAM,iBAAiB,cAAc;GACrC,MAAM,cAAc,SAAS,gBAAgB,GAAG;AAChD,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AClC,MAAI,cAAc,KAChB,OAAM,IAAI,MAAM,4BAA4B,EAAE,UAAU;AAE1D,SAAO,KAAK,UAAU;;AAGxB,QAAO;;AAGT,SAAgB,kBAAkB,SAA2B;AAC3D,KAAI,YAAY,GACd,QAAO,EAAE;AAGX,KAAI,QAAQ,WAAW,IAAI,CACzB,OAAM,IAAI,MAAM,0CAA0C;AAE5D,KAAI,QAAQ,SAAS,IAAI,CACvB,OAAM,IAAI,MAAM,wCAAwC;AAE1D,KAAI,QAAQ,SAAS,KAAK,CACxB,OAAM,IAAI,MAAM,iDAAiD;CAGnE,MAAMC,eAAyB,EAAE;CACjC,IAAI,QAAQ;CACZ,IAAI,OAAO;AAEX,MAAK,MAAM,MAAM,SAAS;AACxB,UAAQ;AACR,MAAI,OAAO,IACT,UAAS;WACA,OAAO,IAChB,UAAS;WACA,OAAO,OAAO,UAAU,GAAG;AACpC,UAAO,KAAK,MAAM,GAAG,GAAG;AACxB,gBAAa,KAAK,KAAK;AACvB,UAAO;;;AAIX,KAAI,SAAS,GACX,cAAa,KAAK,KAAK;AAGzB,KAAI,UAAU,EACZ,OAAM,IAAI,MAAM,yCAAyC;AAG3D,QAAO"}
1
+ {"version":3,"file":"abi-type.mjs","names":["childTypes: ABIType[]","bitSize: number","precision: number","encodedBytes: Uint8Array","typeStrings: string[]","heads: Uint8Array[]","tails: Uint8Array[]","values: ABIValue[]","childType: ABIType","length: number","structName: string","structFields: ABIStructField[]","dynamicSegments: Segment[]","valuePartitions: (Uint8Array | null)[]","result: Uint8Array[]","tupleStrings: string[]"],"sources":["../../../../packages/abi/src/abi-type.ts"],"sourcesContent":["import {\n Address,\n BOOL_FALSE_BYTE,\n BOOL_TRUE_BYTE,\n LENGTH_ENCODE_BYTE_SIZE,\n PUBLIC_KEY_BYTE_LENGTH,\n concatArrays,\n} from '@algorandfoundation/algokit-common'\nimport type { ABIStructValue, ABIValue } from './abi-value'\nimport { StructField } from './arc56-contract'\nimport { bigIntToBytes, bytesToBigInt } from './bigint'\nimport { getStructValueFromTupleValue, getTupleValueFromStructValue } from './utils'\n\nconst STATIC_ARRAY_REGEX = /^([a-z\\d[\\](),]+)\\[(0|[1-9][\\d]*)]$/\nconst UFIXED_REGEX = /^ufixed([1-9][\\d]*)x([1-9][\\d]*)$/\nconst MAX_LEN = 2 ** 16 - 1\n\n/**\n * Information about a single field in a struct\n */\nexport type ABIStructField = {\n /** The name of the struct field */\n name: string\n /** The type of the struct field's value */\n type: ABIType | ABIStructField[]\n}\n\ninterface Segment {\n left: number\n right: number\n}\n\n/**\n * Represents an Algorand ABI type for encoding and decoding values as defined in [ARC-0004](https://arc.algorand.foundation/ARCs/arc-0004#types).\n *\n * This is the abstract base class for all ABI types.\n */\nexport abstract class ABIType {\n /**\n * Returns the ARC-4 type name string representation.\n * @returns The ARC-4 type string\n */\n abstract get name(): string\n\n /**\n * Returns a user-friendly display name for this type.\n * @returns The display name for this type\n */\n get displayName(): string {\n return this.name\n }\n\n /**\n * Returns the ARC-4 type name string representation.\n * @returns The ARC-4 type string\n */\n toString(): string {\n return this.name\n }\n\n /**\n * Checks if this ABI type is equal to another.\n * @param other The other ABI type to compare with\n * @returns True if the types are equal, false otherwise\n */\n abstract equals(other: ABIType): boolean\n\n /**\n * Checks if this ABI type is dynamic (variable-length).\n * @returns True if the type is dynamic, false otherwise\n */\n abstract isDynamic(): boolean\n\n /**\n * Gets the byte length of the encoded type for static types.\n * @returns The number of bytes needed to encode this type\n * @throws Error if the type is dynamic\n */\n abstract byteLen(): number\n\n /**\n * Encodes a value according to this ABI type.\n * @param value The value to encode\n * @returns The encoded bytes\n */\n abstract encode(value: ABIValue): Uint8Array\n\n /**\n * Decodes bytes according to this ABI type.\n * @param bytes The bytes to decode\n * @returns The decoded value\n */\n abstract decode(bytes: Uint8Array): ABIValue\n\n /**\n * Creates an ABI type from an ARC-4 type string.\n * @param str The ARC-4 type string (e.g., \"uint256\", \"bool\", \"(uint8,address)\")\n * @returns The corresponding ABI type\n */\n static from(str: string): ABIType {\n if (str.endsWith('[]')) {\n const childType = ABIType.from(str.slice(0, str.length - 2))\n return new ABIArrayDynamicType(childType)\n }\n if (str.endsWith(']')) {\n const stringMatches = str.match(STATIC_ARRAY_REGEX)\n if (!stringMatches || stringMatches.length !== 3) {\n throw new Error(`Malformed static array string: ${str}`)\n }\n const arrayLengthStr = stringMatches[2]\n const arrayLength = parseInt(arrayLengthStr, 10)\n if (arrayLength > MAX_LEN) {\n throw new Error(`Array length exceeds limit ${MAX_LEN}`)\n }\n const childType = ABIType.from(stringMatches[1])\n return new ABIArrayStaticType(childType, arrayLength)\n }\n if (str.startsWith('uint')) {\n const digitsOnly = (s: string) => [...s].every((c) => '0123456789'.includes(c))\n const typeSizeStr = str.slice(4, str.length)\n if (!digitsOnly(typeSizeStr)) {\n throw new Error(`Malformed uint string: ${typeSizeStr}`)\n }\n const bitSize = parseInt(typeSizeStr, 10)\n if (bitSize > MAX_LEN) {\n throw new Error(`Malformed uint string: ${bitSize}`)\n }\n return new ABIUintType(bitSize)\n }\n if (str === 'byte') {\n return new ABIByteType()\n }\n if (str.startsWith('ufixed')) {\n const stringMatches = str.match(UFIXED_REGEX)\n if (!stringMatches || stringMatches.length !== 3) {\n throw new Error(`Malformed ufixed type: ${str}`)\n }\n const bitSize = parseInt(stringMatches[1], 10)\n const precision = parseInt(stringMatches[2], 10)\n return new ABIUfixedType(bitSize, precision)\n }\n if (str === 'bool') {\n return new ABIBoolType()\n }\n if (str === 'address') {\n return new ABIAddressType()\n }\n if (str === 'string') {\n return new ABIStringType()\n }\n if (str.length >= 2 && str[0] === '(' && str[str.length - 1] === ')') {\n const tupleContent = parseTupleContent(str.slice(1, str.length - 1))\n const childTypes: ABIType[] = []\n for (let i = 0; i < tupleContent.length; i++) {\n const ti = ABIType.from(tupleContent[i])\n childTypes.push(ti)\n }\n return new ABITupleType(childTypes)\n }\n throw new Error(`Cannot convert a string ${str} to an ABI type`)\n }\n}\n\n// ============================================================================\n// Primitive Types\n// ============================================================================\n\n/**\n * An unsigned integer ABI type of a specific bit size.\n */\nexport class ABIUintType extends ABIType {\n /**\n * Creates a new unsigned integer type.\n * @param bitSize The bit size (must be a multiple of 8, between 8 and 512)\n */\n constructor(public readonly bitSize: number) {\n super()\n if (bitSize % 8 !== 0 || bitSize < 8 || bitSize > 512) {\n throw new Error(`Unsupported uint type bitSize: ${bitSize}`)\n }\n }\n\n get name(): string {\n return `uint${this.bitSize}`\n }\n\n equals(other: ABIType): boolean {\n return other instanceof ABIUintType && this.bitSize === other.bitSize\n }\n\n isDynamic(): boolean {\n return false\n }\n\n byteLen(): number {\n return this.bitSize / 8\n }\n\n encode(value: ABIValue): Uint8Array {\n if (typeof value !== 'bigint' && typeof value !== 'number') {\n throw new Error(`Cannot encode value as ${this.name}: ${value}`)\n }\n\n if (value >= BigInt(2 ** this.bitSize) || value < BigInt(0)) {\n throw new Error(`${value} is not a non-negative int or too big to fit in size ${this.name}`)\n }\n if (typeof value === 'number' && !Number.isSafeInteger(value)) {\n throw new Error(`${value} should be converted into a BigInt before it is encoded`)\n }\n return bigIntToBytes(value, this.bitSize / 8)\n }\n\n decode(bytes: Uint8Array): ABIValue {\n if (bytes.length !== this.bitSize / 8) {\n throw new Error(`Byte string must correspond to a ${this.name}`)\n }\n const value = bytesToBigInt(bytes)\n return this.bitSize < 53 ? Number(value) : value\n }\n}\n\n/**\n * A fixed-point number ABI type of a specific bit size and precision.\n */\nexport class ABIUfixedType extends ABIType {\n /**\n * Creates a new fixed-point type.\n * @param bitSize The bit size (must be a multiple of 8, between 8 and 512)\n * @param precision The decimal precision (must be between 1 and 160)\n */\n constructor(\n public readonly bitSize: number,\n public readonly precision: number,\n ) {\n super()\n if (bitSize % 8 !== 0 || bitSize < 8 || bitSize > 512) {\n throw new Error(`Unsupported ufixed type bitSize: ${bitSize}`)\n }\n if (precision > 160 || precision < 1) {\n throw new Error(`Unsupported ufixed type precision: ${precision}`)\n }\n }\n\n get name(): string {\n return `ufixed${this.bitSize}x${this.precision}`\n }\n\n equals(other: ABIType): boolean {\n return other instanceof ABIUfixedType && this.bitSize === other.bitSize && this.precision === other.precision\n }\n\n isDynamic(): boolean {\n return false\n }\n\n byteLen(): number {\n return this.bitSize / 8\n }\n\n encode(value: ABIValue): Uint8Array {\n if (typeof value !== 'bigint' && typeof value !== 'number') {\n throw new Error(`Cannot encode value as ${this.name}: ${value}`)\n }\n if (value >= BigInt(2 ** this.bitSize) || value < BigInt(0)) {\n throw new Error(`${value} is not a non-negative int or too big to fit in size ${this.name}`)\n }\n if (typeof value === 'number' && !Number.isSafeInteger(value)) {\n throw new Error(`${value} should be converted into a BigInt before it is encoded`)\n }\n return bigIntToBytes(value, this.bitSize / 8)\n }\n\n decode(bytes: Uint8Array): ABIValue {\n if (bytes.length !== this.bitSize / 8) {\n throw new Error(`Byte string must correspond to a ${this.name}`)\n }\n const value = bytesToBigInt(bytes)\n return this.bitSize < 53 ? Number(value) : value\n }\n}\n\n/**\n * An Algorand address ABI type.\n */\nexport class ABIAddressType extends ABIType {\n get name(): string {\n return 'address'\n }\n\n equals(other: ABIType): boolean {\n return other instanceof ABIAddressType\n }\n\n isDynamic(): boolean {\n return false\n }\n\n byteLen(): number {\n return PUBLIC_KEY_BYTE_LENGTH\n }\n\n encode(value: ABIValue): Uint8Array {\n if (typeof value === 'string') {\n return Address.fromString(value).publicKey\n }\n\n if (value instanceof Address) {\n return value.publicKey\n }\n\n if (value instanceof Uint8Array && value.length === 32) {\n return value\n }\n\n throw new Error(`Cannot encode value as address: ${value}`)\n }\n\n decode(bytes: Uint8Array): string {\n return new Address(bytes).toString()\n }\n}\n\n/**\n * A boolean ABI type.\n */\nexport class ABIBoolType extends ABIType {\n get name(): string {\n return 'bool'\n }\n\n equals(other: ABIType): boolean {\n return other instanceof ABIBoolType\n }\n\n isDynamic(): boolean {\n return false\n }\n\n byteLen(): number {\n return 1\n }\n\n encode(value: ABIValue): Uint8Array {\n if (typeof value !== 'boolean') {\n throw new Error(`Cannot encode value as bool: ${value}`)\n }\n\n return value ? new Uint8Array([0x80]) : new Uint8Array([0x00])\n }\n\n decode(bytes: Uint8Array): ABIValue {\n if (bytes.length !== 1) {\n throw new Error(`Expected 1 byte for bool, got ${bytes.length}`)\n }\n\n return (bytes[0] & 0x80) !== 0\n }\n}\n\n/**\n * A single byte ABI type.\n */\nexport class ABIByteType extends ABIType {\n get name(): string {\n return 'byte'\n }\n\n equals(other: ABIType): boolean {\n return other instanceof ABIByteType\n }\n\n isDynamic(): boolean {\n return false\n }\n\n byteLen(): number {\n return 1\n }\n\n encode(value: ABIValue): Uint8Array {\n if (typeof value !== 'number' && typeof value !== 'bigint') {\n throw new Error(`Cannot encode value as byte: ${value}`)\n }\n const numberValue = typeof value === 'bigint' ? Number(value) : value\n if (value < 0 || value > 255) {\n throw new Error(`Byte value must be between 0 and 255, got ${numberValue}`)\n }\n\n return new Uint8Array([numberValue])\n }\n\n decode(bytes: Uint8Array): ABIValue {\n if (bytes.length !== 1) {\n throw new Error(`Expected 1 byte for byte type, got ${bytes.length}`)\n }\n\n return bytes[0]\n }\n}\n\n/**\n * A dynamic-length string ABI type.\n */\nexport class ABIStringType extends ABIType {\n get name(): string {\n return 'string'\n }\n\n equals(other: ABIType): boolean {\n return other instanceof ABIStringType\n }\n\n isDynamic(): boolean {\n return true\n }\n\n byteLen(): number {\n throw new Error(`Failed to get size, string is a dynamic type`)\n }\n\n encode(value: ABIValue): Uint8Array {\n if (typeof value !== 'string' && !(value instanceof Uint8Array)) {\n throw new Error(`Cannot encode value as string: ${value}`)\n }\n\n let encodedBytes: Uint8Array\n if (typeof value === 'string') {\n encodedBytes = new TextEncoder().encode(value)\n } else {\n encodedBytes = value\n }\n const encodedLength = bigIntToBytes(encodedBytes.length, LENGTH_ENCODE_BYTE_SIZE)\n const mergedBytes = new Uint8Array(encodedBytes.length + LENGTH_ENCODE_BYTE_SIZE)\n mergedBytes.set(encodedLength)\n mergedBytes.set(encodedBytes, LENGTH_ENCODE_BYTE_SIZE)\n return mergedBytes\n }\n\n decode(bytes: Uint8Array): ABIValue {\n if (bytes.length < LENGTH_ENCODE_BYTE_SIZE) {\n throw new Error(\n `Byte string is too short to be decoded. Actual length is ${bytes.length}, but expected at least ${LENGTH_ENCODE_BYTE_SIZE}`,\n )\n }\n const view = new DataView(bytes.buffer, bytes.byteOffset, LENGTH_ENCODE_BYTE_SIZE)\n const byteLength = view.getUint16(0)\n const byteValue = bytes.slice(LENGTH_ENCODE_BYTE_SIZE, bytes.length)\n if (byteLength !== byteValue.length) {\n throw new Error(`String length bytes do not match the actual length of string. Expected ${byteLength}, got ${byteValue.length}`)\n }\n return new TextDecoder('utf-8').decode(byteValue)\n }\n}\n\n// ============================================================================\n// Collection Types\n// ============================================================================\n\n/**\n * A tuple ABI type containing other ABI types.\n */\nexport class ABITupleType extends ABIType {\n /**\n * Creates a new tuple type.\n * @param childTypes The types of the tuple elements\n */\n constructor(public readonly childTypes: ABIType[]) {\n super()\n if (childTypes.length > MAX_LEN) {\n throw new Error(`Tuple has too many child types: ${childTypes.length}`)\n }\n }\n\n get name(): string {\n const typeStrings: string[] = []\n for (let i = 0; i < this.childTypes.length; i++) {\n typeStrings[i] = this.childTypes[i].name\n }\n return `(${typeStrings.join(',')})`\n }\n\n equals(other: ABIType): boolean {\n if (!(other instanceof ABITupleType)) return false\n if (this.childTypes.length !== other.childTypes.length) return false\n return this.childTypes.every((t, i) => t.equals(other.childTypes[i]))\n }\n\n isDynamic(): boolean {\n return this.childTypes.some((c) => c.isDynamic())\n }\n\n byteLen(): number {\n let size = 0\n let i = 0\n while (i < this.childTypes.length) {\n const childType = this.childTypes[i]\n if (childType instanceof ABIBoolType) {\n const sequenceEndIndex = findBoolSequenceEnd(this.childTypes, i)\n const boolCount = sequenceEndIndex - i + 1\n size += Math.ceil(boolCount / 8)\n i = sequenceEndIndex + 1\n } else {\n size += childType.byteLen()\n i++\n }\n }\n return size\n }\n\n encode(value: ABIValue): Uint8Array {\n if (!Array.isArray(value) && !(value instanceof Uint8Array)) {\n throw new Error(`Cannot encode value as ${this.toString()}: ${value}`)\n }\n\n const values = Array.from(value)\n\n if (this.childTypes.length !== values.length) {\n throw new Error('Mismatch lengths between the values and types')\n }\n\n const heads: Uint8Array[] = []\n const tails: Uint8Array[] = []\n const isDynamicIndex = new Map<number, boolean>()\n let abiTypesCursor = 0\n\n while (abiTypesCursor < this.childTypes.length) {\n const childType = this.childTypes[abiTypesCursor]\n\n if (childType.isDynamic()) {\n isDynamicIndex.set(heads.length, true)\n heads.push(new Uint8Array(2)) // Placeholder for dynamic offset\n tails.push(childType.encode(values[abiTypesCursor]))\n } else {\n if (childType instanceof ABIBoolType) {\n const boolSequenceEndIndex = findBoolSequenceEnd(this.childTypes, abiTypesCursor)\n const boolValues = values.slice(abiTypesCursor, boolSequenceEndIndex + 1)\n const compressedBool = compressBools(boolValues)\n heads.push(new Uint8Array([compressedBool]))\n abiTypesCursor = boolSequenceEndIndex\n } else {\n heads.push(childType.encode(values[abiTypesCursor]))\n }\n isDynamicIndex.set(abiTypesCursor, false)\n tails.push(new Uint8Array(0))\n }\n abiTypesCursor += 1\n }\n\n const headLength = heads.reduce((sum, head) => sum + head.length, 0)\n let tailLength = 0\n\n for (let i = 0; i < heads.length; i++) {\n if (isDynamicIndex.get(i)) {\n const headValue = headLength + tailLength\n if (headValue > 0xffff) {\n throw new Error(`Value ${headValue} cannot fit in u16`)\n }\n heads[i] = new Uint8Array([(headValue >> 8) & 0xff, headValue & 0xff])\n }\n tailLength += tails[i].length\n }\n\n const totalLength = heads.reduce((sum, head) => sum + head.length, 0) + tails.reduce((sum, tail) => sum + tail.length, 0)\n const result = new Uint8Array(totalLength)\n let offset = 0\n\n for (const head of heads) {\n result.set(head, offset)\n offset += head.length\n }\n\n for (const tail of tails) {\n result.set(tail, offset)\n offset += tail.length\n }\n\n return result\n }\n\n decode(bytes: Uint8Array): ABIValue[] {\n const valuePartitions = extractValues(this.childTypes, bytes)\n const values: ABIValue[] = []\n\n for (let i = 0; i < this.childTypes.length; i++) {\n const childType = this.childTypes[i]\n const valuePartition = valuePartitions[i]\n const childValue = childType.decode(valuePartition)\n values.push(childValue)\n }\n\n return values\n }\n}\n\n/**\n * A static-length array ABI type.\n */\nexport class ABIArrayStaticType extends ABIType {\n /**\n * Creates a new static array type.\n * @param childType The type of the array elements\n * @param length The fixed length of the array\n */\n constructor(\n public readonly childType: ABIType,\n public readonly length: number,\n ) {\n super()\n if (length < 0 || length > MAX_LEN) {\n throw new Error(`Invalid static array length: ${length}`)\n }\n }\n\n get name(): string {\n return `${this.childType.name}[${this.length}]`\n }\n\n equals(other: ABIType): boolean {\n return other instanceof ABIArrayStaticType && this.childType.equals(other.childType) && this.length === other.length\n }\n\n isDynamic(): boolean {\n return this.childType.isDynamic()\n }\n\n byteLen(): number {\n if (this.childType instanceof ABIBoolType) {\n return Math.ceil(this.length / 8)\n }\n return this.childType.byteLen() * this.length\n }\n\n /**\n * Converts this static array type to an equivalent tuple type.\n * @returns The equivalent tuple type\n */\n toABITupleType(): ABITupleType {\n return new ABITupleType(Array(this.length).fill(this.childType))\n }\n\n encode(value: ABIValue): Uint8Array {\n if (!Array.isArray(value) && !(value instanceof Uint8Array)) {\n throw new Error(`Cannot encode value as ${this.name}: ${value}`)\n }\n if (value.length !== this.length) {\n throw new Error(`Value array does not match static array length. Expected ${this.length}, got ${value.length}`)\n }\n const convertedTuple = this.toABITupleType()\n return convertedTuple.encode(value)\n }\n\n decode(bytes: Uint8Array): ABIValue[] | Uint8Array {\n const convertedTuple = this.toABITupleType()\n const decoded = convertedTuple.decode(bytes)\n\n // Convert byte arrays to Uint8Array\n if (this.childType instanceof ABIByteType && Array.isArray(decoded)) {\n return new Uint8Array(decoded as number[])\n }\n\n return decoded\n }\n}\n\n/**\n * A dynamic-length array ABI type.\n */\nexport class ABIArrayDynamicType extends ABIType {\n /**\n * Creates a new dynamic array type.\n * @param childType The type of the array elements\n */\n constructor(public readonly childType: ABIType) {\n super()\n }\n\n get name(): string {\n return `${this.childType.name}[]`\n }\n\n equals(other: ABIType): boolean {\n return other instanceof ABIArrayDynamicType && this.childType.equals(other.childType)\n }\n\n isDynamic(): boolean {\n return true\n }\n\n byteLen(): number {\n throw new Error(`Failed to get size, dynamic array is a dynamic type`)\n }\n\n /**\n * Converts this dynamic array type to an equivalent tuple type of a given length.\n * @param length The number of elements\n * @returns The equivalent tuple type\n */\n toABITupleType(length: number): ABITupleType {\n return new ABITupleType(Array(length).fill(this.childType))\n }\n\n encode(value: ABIValue): Uint8Array {\n if (!Array.isArray(value) && !(value instanceof Uint8Array)) {\n throw new Error(`Cannot encode value as ${this.name}: ${value}`)\n }\n const convertedTuple = this.toABITupleType(value.length)\n const encodedTuple = convertedTuple.encode(value)\n const encodedLength = bigIntToBytes(convertedTuple.childTypes.length, LENGTH_ENCODE_BYTE_SIZE)\n return concatArrays(encodedLength, encodedTuple)\n }\n\n decode(bytes: Uint8Array): ABIValue[] | Uint8Array {\n const view = new DataView(bytes.buffer, 0, LENGTH_ENCODE_BYTE_SIZE)\n const byteLength = view.getUint16(0)\n const convertedTuple = this.toABITupleType(byteLength)\n const decoded = convertedTuple.decode(bytes.slice(LENGTH_ENCODE_BYTE_SIZE, bytes.length))\n\n // Convert byte arrays to Uint8Array\n if (this.childType instanceof ABIByteType && Array.isArray(decoded)) {\n return new Uint8Array(decoded as number[])\n }\n\n return decoded\n }\n}\n\n/**\n * A struct ABI type with named fields.\n */\nexport class ABIStructType extends ABIType {\n /**\n * Creates a new struct type.\n * @param structName The name of the struct\n * @param structFields The fields of the struct\n */\n constructor(\n public readonly structName: string,\n public readonly structFields: ABIStructField[],\n ) {\n super()\n }\n\n get name(): string {\n const tupleType = this.toABITupleType()\n return tupleType.name\n }\n\n get displayName(): string {\n return this.structName\n }\n\n equals(other: ABIType): boolean {\n if (!(other instanceof ABIStructType)) return false\n if (this.structName !== other.structName) return false\n if (this.structFields.length !== other.structFields.length) return false\n return this.structFields.every((f, i) => {\n const otherField = other.structFields[i]\n if (f.name !== otherField.name) return false\n if (Array.isArray(f.type) && Array.isArray(otherField.type)) {\n return JSON.stringify(f.type) === JSON.stringify(otherField.type)\n }\n if (f.type instanceof ABIType && otherField.type instanceof ABIType) {\n return f.type.equals(otherField.type)\n }\n return false\n })\n }\n\n isDynamic(): boolean {\n const tupleType = this.toABITupleType()\n return tupleType.isDynamic()\n }\n\n byteLen(): number {\n const tupleType = this.toABITupleType()\n return tupleType.byteLen()\n }\n\n /**\n * Converts this struct type to an equivalent tuple type.\n * @returns The equivalent tuple type\n */\n toABITupleType(): ABITupleType {\n const getABITupleTypeFromABIStructFields = (fields: ABIStructField[]): ABITupleType => {\n const childTypes = fields.map((field) =>\n Array.isArray(field.type)\n ? getABITupleTypeFromABIStructFields(field.type)\n : field.type instanceof ABIStructType\n ? field.type.toABITupleType()\n : field.type,\n )\n return new ABITupleType(childTypes)\n }\n\n return getABITupleTypeFromABIStructFields(this.structFields)\n }\n\n /**\n * Creates an ABIStructType from struct name and struct definitions.\n * @param structName The name of the struct\n * @param structs A record of struct definitions\n * @returns The struct type\n */\n static fromStruct(structName: string, structs: Record<string, StructField[]>): ABIStructType {\n const getStructFieldType = (structFieldType: string | StructField[]): ABIType | ABIStructField[] => {\n // When the input is an array of struct fields\n if (Array.isArray(structFieldType)) {\n return structFieldType.map((structField) => ({\n name: structField.name,\n type: getStructFieldType(structField.type),\n }))\n }\n\n // When the input is a name of another struct\n if (structs[structFieldType]) {\n return ABIStructType.fromStruct(structFieldType, structs)\n }\n\n // When the input in an ABI type name\n return ABIType.from(structFieldType)\n }\n\n if (!structs[structName]) throw new Error('Struct not found')\n\n const fields = structs[structName]\n return new ABIStructType(\n structName,\n fields.map((f) => ({\n name: f.name,\n type: getStructFieldType(f.type),\n })),\n )\n }\n\n encode(value: ABIValue): Uint8Array {\n if (value instanceof Uint8Array || value instanceof Address || typeof value !== 'object') {\n throw new Error(`Cannot encode value as ${this.name}: ${value}`)\n }\n\n const tupleType = this.toABITupleType()\n if (Array.isArray(value)) {\n return tupleType.encode(value)\n }\n\n const tupleValue = getTupleValueFromStructValue(this, value)\n return tupleType.encode(tupleValue)\n }\n\n decode(bytes: Uint8Array): ABIStructValue {\n const tupleType = this.toABITupleType()\n const tupleValue = tupleType.decode(bytes)\n return getStructValueFromTupleValue(this, tupleValue)\n }\n}\n\n// ============================================================================\n// Helper Functions\n// ============================================================================\n\nfunction compressBools(values: ABIValue[]): number {\n if (values.length > 8) {\n throw new Error(`Expected no more than 8 bool values, received ${values.length}`)\n }\n\n let result = 0\n for (let i = 0; i < values.length; i++) {\n if (typeof values[i] !== 'boolean') {\n throw new Error('Expected all values to be boolean')\n }\n if (values[i]) {\n result |= 1 << (7 - i)\n }\n }\n\n return result\n}\n\nfunction findBoolSequenceEnd(abiTypes: ABIType[], currentIndex: number): number {\n let cursor = currentIndex\n while (cursor < abiTypes.length) {\n if (abiTypes[cursor] instanceof ABIBoolType) {\n if (cursor - currentIndex + 1 === 8 || cursor === abiTypes.length - 1) {\n return cursor\n }\n cursor++\n } else {\n return cursor - 1\n }\n }\n return cursor - 1\n}\n\nfunction extractValues(abiTypes: ABIType[], bytes: Uint8Array): Uint8Array[] {\n const dynamicSegments: Segment[] = []\n const valuePartitions: (Uint8Array | null)[] = []\n let bytesCursor = 0\n let abiTypesCursor = 0\n\n while (abiTypesCursor < abiTypes.length) {\n const childType = abiTypes[abiTypesCursor]\n\n if (childType.isDynamic()) {\n if (bytes.length - bytesCursor < LENGTH_ENCODE_BYTE_SIZE) {\n throw new Error('Byte array is too short to be decoded')\n }\n\n const dynamicIndex = (bytes[bytesCursor] << 8) | bytes[bytesCursor + 1]\n\n if (dynamicSegments.length > 0) {\n const lastSegment = dynamicSegments[dynamicSegments.length - 1]\n if (dynamicIndex < lastSegment.left) {\n throw new Error('Dynamic index segment miscalculation: left is greater than right index')\n }\n lastSegment.right = dynamicIndex\n }\n\n dynamicSegments.push({ left: dynamicIndex, right: 0 })\n valuePartitions.push(null)\n bytesCursor += LENGTH_ENCODE_BYTE_SIZE\n } else {\n if (childType instanceof ABIBoolType) {\n const boolSequenceEndIndex = findBoolSequenceEnd(abiTypes, abiTypesCursor)\n for (let j = 0; j <= boolSequenceEndIndex - abiTypesCursor; j++) {\n const boolMask = BOOL_TRUE_BYTE >> j\n if ((bytes[bytesCursor] & boolMask) > 0) {\n valuePartitions.push(new Uint8Array([BOOL_TRUE_BYTE]))\n } else {\n valuePartitions.push(new Uint8Array([BOOL_FALSE_BYTE]))\n }\n }\n abiTypesCursor = boolSequenceEndIndex\n bytesCursor += 1\n } else {\n const childTypeSize = childType.byteLen()\n if (bytesCursor + childTypeSize > bytes.length) {\n throw new Error(\n `Index out of bounds, trying to access bytes[${bytesCursor}..${bytesCursor + childTypeSize}] but slice has length ${bytes.length}`,\n )\n }\n valuePartitions.push(bytes.slice(bytesCursor, bytesCursor + childTypeSize))\n bytesCursor += childTypeSize\n }\n }\n\n if (abiTypesCursor !== abiTypes.length - 1 && bytesCursor >= bytes.length) {\n throw new Error('Input bytes not enough to decode')\n }\n abiTypesCursor += 1\n }\n\n if (dynamicSegments.length > 0) {\n const lastSegment = dynamicSegments[dynamicSegments.length - 1]\n lastSegment.right = bytes.length\n } else if (bytesCursor < bytes.length) {\n throw new Error('Input bytes not fully consumed')\n }\n\n for (let i = 0; i < dynamicSegments.length; i++) {\n const segment = dynamicSegments[i]\n if (segment.left > segment.right) {\n throw new Error('Dynamic segment should display a [l, r] space with l <= r')\n }\n if (i !== dynamicSegments.length - 1 && segment.right !== dynamicSegments[i + 1].left) {\n throw new Error('Dynamic segments should be consecutive')\n }\n }\n\n let segmentIndex = 0\n for (let i = 0; i < abiTypes.length; i++) {\n const childType = abiTypes[i]\n if (childType.isDynamic()) {\n valuePartitions[i] = bytes.slice(dynamicSegments[segmentIndex].left, dynamicSegments[segmentIndex].right)\n segmentIndex += 1\n }\n }\n\n const result: Uint8Array[] = []\n for (let i = 0; i < valuePartitions.length; i++) {\n const partition = valuePartitions[i]\n if (partition === null) {\n throw new Error(`Value partition at index ${i} is None`)\n }\n result.push(partition)\n }\n\n return result\n}\n\nexport function parseTupleContent(content: string): string[] {\n if (content === '') {\n return []\n }\n\n if (content.startsWith(',')) {\n throw new Error('The content should not start with comma')\n }\n if (content.endsWith(',')) {\n throw new Error('The content should not end with comma')\n }\n if (content.includes(',,')) {\n throw new Error('The content should not have consecutive commas')\n }\n\n const tupleStrings: string[] = []\n let depth = 0\n let word = ''\n\n for (const ch of content) {\n word += ch\n if (ch === '(') {\n depth += 1\n } else if (ch === ')') {\n depth -= 1\n } else if (ch === ',' && depth === 0) {\n word = word.slice(0, -1) // Remove the comma\n tupleStrings.push(word)\n word = ''\n }\n }\n\n if (word !== '') {\n tupleStrings.push(word)\n }\n\n if (depth !== 0) {\n throw new Error('The content has mismatched parentheses')\n }\n\n return tupleStrings\n}\n"],"mappings":";;;;;;;AAaA,MAAM,qBAAqB;AAC3B,MAAM,eAAe;AACrB,MAAM,UAAU,KAAK,KAAK;;;;;;AAsB1B,IAAsB,UAAtB,MAAsB,QAAQ;;;;;CAW5B,IAAI,cAAsB;AACxB,SAAO,KAAK;;;;;;CAOd,WAAmB;AACjB,SAAO,KAAK;;;;;;;CA0Cd,OAAO,KAAK,KAAsB;AAChC,MAAI,IAAI,SAAS,KAAK,CAEpB,QAAO,IAAI,oBADO,QAAQ,KAAK,IAAI,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC,CACnB;AAE3C,MAAI,IAAI,SAAS,IAAI,EAAE;GACrB,MAAM,gBAAgB,IAAI,MAAM,mBAAmB;AACnD,OAAI,CAAC,iBAAiB,cAAc,WAAW,EAC7C,OAAM,IAAI,MAAM,kCAAkC,MAAM;GAE1D,MAAM,iBAAiB,cAAc;GACrC,MAAM,cAAc,SAAS,gBAAgB,GAAG;AAChD,OAAI,cAAc,QAChB,OAAM,IAAI,MAAM,8BAA8B,UAAU;AAG1D,UAAO,IAAI,mBADO,QAAQ,KAAK,cAAc,GAAG,EACP,YAAY;;AAEvD,MAAI,IAAI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C,KADkB,SAAS,GACb,WAAW,EAAE;AACzB,kBAAgB,KAAK,MAAM,MAAM,gBAAgB,cAAc,MAAM,gBAAgB,cAAc,MAAM;AACzG,kBAAgB;;CAIpB,MAAMC,SAAuB,EAAE;AAC/B,MAAK,IAAI,IAAI,GAAG,IAAI,gBAAgB,QAAQ,KAAK;EAC/C,MAAM,YAAY,gBAAgB;AAClC,MAAI,cAAc,KAChB,OAAM,IAAI,MAAM,4BAA4B,EAAE,UAAU;AAE1D,SAAO,KAAK,UAAU;;AAGxB,QAAO;;AAGT,SAAgB,kBAAkB,SAA2B;AAC3D,KAAI,YAAY,GACd,QAAO,EAAE;AAGX,KAAI,QAAQ,WAAW,IAAI,CACzB,OAAM,IAAI,MAAM,0CAA0C;AAE5D,KAAI,QAAQ,SAAS,IAAI,CACvB,OAAM,IAAI,MAAM,wCAAwC;AAE1D,KAAI,QAAQ,SAAS,KAAK,CACxB,OAAM,IAAI,MAAM,iDAAiD;CAGnE,MAAMC,eAAyB,EAAE;CACjC,IAAI,QAAQ;CACZ,IAAI,OAAO;AAEX,MAAK,MAAM,MAAM,SAAS;AACxB,UAAQ;AACR,MAAI,OAAO,IACT,UAAS;WACA,OAAO,IAChB,UAAS;WACA,OAAO,OAAO,UAAU,GAAG;AACpC,UAAO,KAAK,MAAM,GAAG,GAAG;AACxB,gBAAa,KAAK,KAAK;AACvB,UAAO;;;AAIX,KAAI,SAAS,GACX,cAAa,KAAK,KAAK;AAGzB,KAAI,UAAU,EACZ,OAAM,IAAI,MAAM,yCAAyC;AAG3D,QAAO"}
@@ -0,0 +1,22 @@
1
+ import { ABIStructValue, ABIValue } from "./abi-value.js";
2
+ import { ABIStructType } from "./abi-type.js";
3
+
4
+ //#region packages/abi/src/utils.d.ts
5
+
6
+ /**
7
+ * Converts a struct value (object with named fields) to a tuple value (array).
8
+ * @param structType The struct type definition
9
+ * @param structValue The struct value to convert
10
+ * @returns The equivalent tuple value
11
+ */
12
+ declare function getTupleValueFromStructValue(structType: ABIStructType, structValue: ABIStructValue): ABIValue[];
13
+ /**
14
+ * Converts a tuple value (array) to a struct value (object with named fields).
15
+ * @param structType The struct type definition
16
+ * @param tupleValue The tuple value to convert
17
+ * @returns The equivalent struct value
18
+ */
19
+ declare function getStructValueFromTupleValue(structType: ABIStructType, tupleValue: ABIValue[]): ABIStructValue;
20
+ //#endregion
21
+ export { getStructValueFromTupleValue, getTupleValueFromStructValue };
22
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1,57 @@
1
+
2
+ //#region packages/abi/src/utils.ts
3
+ /**
4
+ * Checks if a type is an ABIStructType by checking for the structFields property.
5
+ */
6
+ function isABIStructType(type) {
7
+ return !Array.isArray(type) && "structFields" in type;
8
+ }
9
+ /**
10
+ * Converts a struct value (object with named fields) to a tuple value (array).
11
+ * @param structType The struct type definition
12
+ * @param structValue The struct value to convert
13
+ * @returns The equivalent tuple value
14
+ */
15
+ function getTupleValueFromStructValue(structType, structValue) {
16
+ const getTupleValueFromStructFields = (structFields, values) => {
17
+ return structFields.map(({ type }, index) => {
18
+ if (Array.isArray(type)) {
19
+ const value = values[index];
20
+ return getTupleValueFromStructFields(type, Object.values(value));
21
+ }
22
+ if (isABIStructType(type)) {
23
+ const value = values[index];
24
+ return getTupleValueFromStructFields(type.structFields, Object.values(value));
25
+ }
26
+ return values[index];
27
+ });
28
+ };
29
+ return getTupleValueFromStructFields(structType.structFields, Object.values(structValue));
30
+ }
31
+ /**
32
+ * Converts a tuple value (array) to a struct value (object with named fields).
33
+ * @param structType The struct type definition
34
+ * @param tupleValue The tuple value to convert
35
+ * @returns The equivalent struct value
36
+ */
37
+ function getStructValueFromTupleValue(structType, tupleValue) {
38
+ const getStructFieldValues = (structFields, values) => {
39
+ return Object.fromEntries(structFields.map(({ name, type }, index) => {
40
+ if (Array.isArray(type)) {
41
+ const value = values[index];
42
+ return [name, getStructFieldValues(type, value)];
43
+ }
44
+ if (isABIStructType(type)) {
45
+ const value = values[index];
46
+ return [name, getStructFieldValues(type.structFields, value)];
47
+ }
48
+ return [name, values[index]];
49
+ }));
50
+ };
51
+ return getStructFieldValues(structType.structFields, tupleValue);
52
+ }
53
+
54
+ //#endregion
55
+ exports.getStructValueFromTupleValue = getStructValueFromTupleValue;
56
+ exports.getTupleValueFromStructValue = getTupleValueFromStructValue;
57
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","names":[],"sources":["../../../../packages/abi/src/utils.ts"],"sourcesContent":["import type { ABIStructField, ABIStructType, ABIType } from './abi-type'\nimport type { ABIStructValue, ABIValue } from './abi-value'\n\n/**\n * Checks if a type is an ABIStructType by checking for the structFields property.\n */\nfunction isABIStructType(type: ABIType | ABIStructField[]): type is ABIStructType {\n return !Array.isArray(type) && 'structFields' in type\n}\n\n/**\n * Converts a struct value (object with named fields) to a tuple value (array).\n * @param structType The struct type definition\n * @param structValue The struct value to convert\n * @returns The equivalent tuple value\n */\nexport function getTupleValueFromStructValue(structType: ABIStructType, structValue: ABIStructValue): ABIValue[] {\n const getTupleValueFromStructFields = (structFields: ABIStructField[], values: ABIValue[]): ABIValue[] => {\n return structFields.map(({ type }, index) => {\n // if type is an array of fields, treat as unnamed struct\n if (Array.isArray(type)) {\n const value = values[index] as ABIStructValue\n return getTupleValueFromStructFields(type, Object.values(value))\n }\n // if type is struct, treat as struct\n if (isABIStructType(type)) {\n const value = values[index] as ABIStructValue\n return getTupleValueFromStructFields(type.structFields, Object.values(value))\n }\n return values[index]\n })\n }\n\n return getTupleValueFromStructFields(structType.structFields, Object.values(structValue))\n}\n\n/**\n * Converts a tuple value (array) to a struct value (object with named fields).\n * @param structType The struct type definition\n * @param tupleValue The tuple value to convert\n * @returns The equivalent struct value\n */\nexport function getStructValueFromTupleValue(structType: ABIStructType, tupleValue: ABIValue[]): ABIStructValue {\n const getStructFieldValues = (structFields: ABIStructField[], values: ABIValue[]): ABIStructValue => {\n return Object.fromEntries(\n structFields.map(({ name, type }, index) => {\n // When the type is an array of fields, the value must be tuple\n if (Array.isArray(type)) {\n const value = values[index] as ABIValue[]\n return [name, getStructFieldValues(type, value)]\n }\n // When the type is a struct, the value must be tuple\n if (isABIStructType(type)) {\n const value = values[index] as ABIValue[]\n return [name, getStructFieldValues(type.structFields, value)]\n }\n return [name, values[index]]\n }),\n )\n }\n\n return getStructFieldValues(structType.structFields, tupleValue)\n}\n"],"mappings":";;;;;AAMA,SAAS,gBAAgB,MAAyD;AAChF,QAAO,CAAC,MAAM,QAAQ,KAAK,IAAI,kBAAkB;;;;;;;;AASnD,SAAgB,6BAA6B,YAA2B,aAAyC;CAC/G,MAAM,iCAAiC,cAAgC,WAAmC;AACxG,SAAO,aAAa,KAAK,EAAE,QAAQ,UAAU;AAE3C,OAAI,MAAM,QAAQ,KAAK,EAAE;IACvB,MAAM,QAAQ,OAAO;AACrB,WAAO,8BAA8B,MAAM,OAAO,OAAO,MAAM,CAAC;;AAGlE,OAAI,gBAAgB,KAAK,EAAE;IACzB,MAAM,QAAQ,OAAO;AACrB,WAAO,8BAA8B,KAAK,cAAc,OAAO,OAAO,MAAM,CAAC;;AAE/E,UAAO,OAAO;IACd;;AAGJ,QAAO,8BAA8B,WAAW,cAAc,OAAO,OAAO,YAAY,CAAC;;;;;;;;AAS3F,SAAgB,6BAA6B,YAA2B,YAAwC;CAC9G,MAAM,wBAAwB,cAAgC,WAAuC;AACnG,SAAO,OAAO,YACZ,aAAa,KAAK,EAAE,MAAM,QAAQ,UAAU;AAE1C,OAAI,MAAM,QAAQ,KAAK,EAAE;IACvB,MAAM,QAAQ,OAAO;AACrB,WAAO,CAAC,MAAM,qBAAqB,MAAM,MAAM,CAAC;;AAGlD,OAAI,gBAAgB,KAAK,EAAE;IACzB,MAAM,QAAQ,OAAO;AACrB,WAAO,CAAC,MAAM,qBAAqB,KAAK,cAAc,MAAM,CAAC;;AAE/D,UAAO,CAAC,MAAM,OAAO,OAAO;IAC5B,CACH;;AAGH,QAAO,qBAAqB,WAAW,cAAc,WAAW"}
@@ -0,0 +1,55 @@
1
+ //#region packages/abi/src/utils.ts
2
+ /**
3
+ * Checks if a type is an ABIStructType by checking for the structFields property.
4
+ */
5
+ function isABIStructType(type) {
6
+ return !Array.isArray(type) && "structFields" in type;
7
+ }
8
+ /**
9
+ * Converts a struct value (object with named fields) to a tuple value (array).
10
+ * @param structType The struct type definition
11
+ * @param structValue The struct value to convert
12
+ * @returns The equivalent tuple value
13
+ */
14
+ function getTupleValueFromStructValue(structType, structValue) {
15
+ const getTupleValueFromStructFields = (structFields, values) => {
16
+ return structFields.map(({ type }, index) => {
17
+ if (Array.isArray(type)) {
18
+ const value = values[index];
19
+ return getTupleValueFromStructFields(type, Object.values(value));
20
+ }
21
+ if (isABIStructType(type)) {
22
+ const value = values[index];
23
+ return getTupleValueFromStructFields(type.structFields, Object.values(value));
24
+ }
25
+ return values[index];
26
+ });
27
+ };
28
+ return getTupleValueFromStructFields(structType.structFields, Object.values(structValue));
29
+ }
30
+ /**
31
+ * Converts a tuple value (array) to a struct value (object with named fields).
32
+ * @param structType The struct type definition
33
+ * @param tupleValue The tuple value to convert
34
+ * @returns The equivalent struct value
35
+ */
36
+ function getStructValueFromTupleValue(structType, tupleValue) {
37
+ const getStructFieldValues = (structFields, values) => {
38
+ return Object.fromEntries(structFields.map(({ name, type }, index) => {
39
+ if (Array.isArray(type)) {
40
+ const value = values[index];
41
+ return [name, getStructFieldValues(type, value)];
42
+ }
43
+ if (isABIStructType(type)) {
44
+ const value = values[index];
45
+ return [name, getStructFieldValues(type.structFields, value)];
46
+ }
47
+ return [name, values[index]];
48
+ }));
49
+ };
50
+ return getStructFieldValues(structType.structFields, tupleValue);
51
+ }
52
+
53
+ //#endregion
54
+ export { getStructValueFromTupleValue, getTupleValueFromStructValue };
55
+ //# sourceMappingURL=utils.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.mjs","names":[],"sources":["../../../../packages/abi/src/utils.ts"],"sourcesContent":["import type { ABIStructField, ABIStructType, ABIType } from './abi-type'\nimport type { ABIStructValue, ABIValue } from './abi-value'\n\n/**\n * Checks if a type is an ABIStructType by checking for the structFields property.\n */\nfunction isABIStructType(type: ABIType | ABIStructField[]): type is ABIStructType {\n return !Array.isArray(type) && 'structFields' in type\n}\n\n/**\n * Converts a struct value (object with named fields) to a tuple value (array).\n * @param structType The struct type definition\n * @param structValue The struct value to convert\n * @returns The equivalent tuple value\n */\nexport function getTupleValueFromStructValue(structType: ABIStructType, structValue: ABIStructValue): ABIValue[] {\n const getTupleValueFromStructFields = (structFields: ABIStructField[], values: ABIValue[]): ABIValue[] => {\n return structFields.map(({ type }, index) => {\n // if type is an array of fields, treat as unnamed struct\n if (Array.isArray(type)) {\n const value = values[index] as ABIStructValue\n return getTupleValueFromStructFields(type, Object.values(value))\n }\n // if type is struct, treat as struct\n if (isABIStructType(type)) {\n const value = values[index] as ABIStructValue\n return getTupleValueFromStructFields(type.structFields, Object.values(value))\n }\n return values[index]\n })\n }\n\n return getTupleValueFromStructFields(structType.structFields, Object.values(structValue))\n}\n\n/**\n * Converts a tuple value (array) to a struct value (object with named fields).\n * @param structType The struct type definition\n * @param tupleValue The tuple value to convert\n * @returns The equivalent struct value\n */\nexport function getStructValueFromTupleValue(structType: ABIStructType, tupleValue: ABIValue[]): ABIStructValue {\n const getStructFieldValues = (structFields: ABIStructField[], values: ABIValue[]): ABIStructValue => {\n return Object.fromEntries(\n structFields.map(({ name, type }, index) => {\n // When the type is an array of fields, the value must be tuple\n if (Array.isArray(type)) {\n const value = values[index] as ABIValue[]\n return [name, getStructFieldValues(type, value)]\n }\n // When the type is a struct, the value must be tuple\n if (isABIStructType(type)) {\n const value = values[index] as ABIValue[]\n return [name, getStructFieldValues(type.structFields, value)]\n }\n return [name, values[index]]\n }),\n )\n }\n\n return getStructFieldValues(structType.structFields, tupleValue)\n}\n"],"mappings":";;;;AAMA,SAAS,gBAAgB,MAAyD;AAChF,QAAO,CAAC,MAAM,QAAQ,KAAK,IAAI,kBAAkB;;;;;;;;AASnD,SAAgB,6BAA6B,YAA2B,aAAyC;CAC/G,MAAM,iCAAiC,cAAgC,WAAmC;AACxG,SAAO,aAAa,KAAK,EAAE,QAAQ,UAAU;AAE3C,OAAI,MAAM,QAAQ,KAAK,EAAE;IACvB,MAAM,QAAQ,OAAO;AACrB,WAAO,8BAA8B,MAAM,OAAO,OAAO,MAAM,CAAC;;AAGlE,OAAI,gBAAgB,KAAK,EAAE;IACzB,MAAM,QAAQ,OAAO;AACrB,WAAO,8BAA8B,KAAK,cAAc,OAAO,OAAO,MAAM,CAAC;;AAE/E,UAAO,OAAO;IACd;;AAGJ,QAAO,8BAA8B,WAAW,cAAc,OAAO,OAAO,YAAY,CAAC;;;;;;;;AAS3F,SAAgB,6BAA6B,YAA2B,YAAwC;CAC9G,MAAM,wBAAwB,cAAgC,WAAuC;AACnG,SAAO,OAAO,YACZ,aAAa,KAAK,EAAE,MAAM,QAAQ,UAAU;AAE1C,OAAI,MAAM,QAAQ,KAAK,EAAE;IACvB,MAAM,QAAQ,OAAO;AACrB,WAAO,CAAC,MAAM,qBAAqB,MAAM,MAAM,CAAC;;AAGlD,OAAI,gBAAgB,KAAK,EAAE;IACzB,MAAM,QAAQ,OAAO;AACrB,WAAO,CAAC,MAAM,qBAAqB,KAAK,cAAc,MAAM,CAAC;;AAE/D,UAAO,CAAC,MAAM,OAAO,OAAO;IAC5B,CACH;;AAGH,QAAO,qBAAqB,WAAW,cAAc,WAAW"}
@@ -348,8 +348,8 @@ declare class AlgorandClientTransactionCreator {
348
348
  * @returns The application create transaction
349
349
  */
350
350
  appCreate: (params: {
351
+ signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
351
352
  sender: SendingAddress;
352
- signer?: TransactionSigner | AddressWithTransactionSigner | undefined;
353
353
  rekeyTo?: ReadableAddress | undefined;
354
354
  note?: string | Uint8Array | undefined;
355
355
  lease?: string | Uint8Array | undefined;
@@ -417,7 +417,7 @@ declare class AlgorandClientTransactionCreator {
417
417
  */
418
418
  appUpdate: (params: {
419
419
  sender: SendingAddress;
420
- signer?: TransactionSigner | AddressWithTransactionSigner | undefined;
420
+ signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
421
421
  rekeyTo?: ReadableAddress | undefined;
422
422
  note?: string | Uint8Array | undefined;
423
423
  lease?: string | Uint8Array | undefined;
@@ -568,9 +568,8 @@ declare class AlgorandClientTransactionCreator {
568
568
  * @returns The application ABI method create transaction
569
569
  */
570
570
  appCreateMethodCall: (params: {
571
- appId?: 0 | undefined;
571
+ signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
572
572
  sender: SendingAddress;
573
- signer?: TransactionSigner | AddressWithTransactionSigner | undefined;
574
573
  rekeyTo?: ReadableAddress | undefined;
575
574
  note?: string | Uint8Array | undefined;
576
575
  lease?: string | Uint8Array | undefined;
@@ -580,6 +579,7 @@ declare class AlgorandClientTransactionCreator {
580
579
  validityWindow?: number | bigint | undefined;
581
580
  firstValidRound?: bigint | undefined;
582
581
  lastValidRound?: bigint | undefined;
582
+ appId?: 0 | undefined;
583
583
  onComplete?: OnApplicationComplete.NoOp | OnApplicationComplete.OptIn | OnApplicationComplete.CloseOut | OnApplicationComplete.UpdateApplication | OnApplicationComplete.DeleteApplication | undefined;
584
584
  accountReferences?: ReadableAddress[] | undefined;
585
585
  appReferences?: bigint[] | undefined;
@@ -587,8 +587,6 @@ declare class AlgorandClientTransactionCreator {
587
587
  boxReferences?: (BoxReference | BoxIdentifier)[] | undefined;
588
588
  accessReferences?: ResourceReference[] | undefined;
589
589
  rejectVersion?: number | undefined;
590
- approvalProgram: string | Uint8Array;
591
- clearStateProgram: string | Uint8Array;
592
590
  schema?: {
593
591
  globalInts: number;
594
592
  globalByteSlices: number;
@@ -596,10 +594,12 @@ declare class AlgorandClientTransactionCreator {
596
594
  localByteSlices: number;
597
595
  } | undefined;
598
596
  extraProgramPages?: number | undefined;
597
+ approvalProgram: string | Uint8Array;
598
+ clearStateProgram: string | Uint8Array;
599
599
  method: ABIMethod;
600
- args?: (Transaction | Promise<Transaction> | ABIValue | TransactionWithSigner | AppMethodCall<{
600
+ args?: (Transaction | ABIValue | TransactionWithSigner | AppMethodCall<{
601
+ signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
601
602
  sender: SendingAddress;
602
- signer?: TransactionSigner | AddressWithTransactionSigner | undefined;
603
603
  rekeyTo?: ReadableAddress | undefined;
604
604
  note?: string | Uint8Array | undefined;
605
605
  lease?: string | Uint8Array | undefined;
@@ -627,9 +627,9 @@ declare class AlgorandClientTransactionCreator {
627
627
  localByteSlices: number;
628
628
  } | undefined;
629
629
  extraProgramPages?: number | undefined;
630
- }> | AppMethodCall<{
630
+ }> | Promise<Transaction> | AppMethodCall<{
631
631
  sender: SendingAddress;
632
- signer?: TransactionSigner | AddressWithTransactionSigner | undefined;
632
+ signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
633
633
  rekeyTo?: ReadableAddress | undefined;
634
634
  note?: string | Uint8Array | undefined;
635
635
  lease?: string | Uint8Array | undefined;
@@ -702,9 +702,8 @@ declare class AlgorandClientTransactionCreator {
702
702
  * @returns The application ABI method update transaction
703
703
  */
704
704
  appUpdateMethodCall: (params: {
705
- appId: bigint;
705
+ signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
706
706
  sender: SendingAddress;
707
- signer?: TransactionSigner | AddressWithTransactionSigner | undefined;
708
707
  rekeyTo?: ReadableAddress | undefined;
709
708
  note?: string | Uint8Array | undefined;
710
709
  lease?: string | Uint8Array | undefined;
@@ -714,6 +713,7 @@ declare class AlgorandClientTransactionCreator {
714
713
  validityWindow?: number | bigint | undefined;
715
714
  firstValidRound?: bigint | undefined;
716
715
  lastValidRound?: bigint | undefined;
716
+ appId: bigint;
717
717
  onComplete?: OnApplicationComplete.UpdateApplication | undefined;
718
718
  accountReferences?: ReadableAddress[] | undefined;
719
719
  appReferences?: bigint[] | undefined;
@@ -724,9 +724,9 @@ declare class AlgorandClientTransactionCreator {
724
724
  approvalProgram: string | Uint8Array;
725
725
  clearStateProgram: string | Uint8Array;
726
726
  method: ABIMethod;
727
- args?: (Transaction | Promise<Transaction> | ABIValue | TransactionWithSigner | AppMethodCall<{
727
+ args?: (Transaction | ABIValue | TransactionWithSigner | AppMethodCall<{
728
+ signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
728
729
  sender: SendingAddress;
729
- signer?: TransactionSigner | AddressWithTransactionSigner | undefined;
730
730
  rekeyTo?: ReadableAddress | undefined;
731
731
  note?: string | Uint8Array | undefined;
732
732
  lease?: string | Uint8Array | undefined;
@@ -754,9 +754,9 @@ declare class AlgorandClientTransactionCreator {
754
754
  localByteSlices: number;
755
755
  } | undefined;
756
756
  extraProgramPages?: number | undefined;
757
- }> | AppMethodCall<{
757
+ }> | Promise<Transaction> | AppMethodCall<{
758
758
  sender: SendingAddress;
759
- signer?: TransactionSigner | AddressWithTransactionSigner | undefined;
759
+ signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
760
760
  rekeyTo?: ReadableAddress | undefined;
761
761
  note?: string | Uint8Array | undefined;
762
762
  lease?: string | Uint8Array | undefined;
@@ -827,9 +827,8 @@ declare class AlgorandClientTransactionCreator {
827
827
  * @returns The application ABI method delete transaction
828
828
  */
829
829
  appDeleteMethodCall: (params: {
830
- appId: bigint;
830
+ signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
831
831
  sender: SendingAddress;
832
- signer?: TransactionSigner | AddressWithTransactionSigner | undefined;
833
832
  rekeyTo?: ReadableAddress | undefined;
834
833
  note?: string | Uint8Array | undefined;
835
834
  lease?: string | Uint8Array | undefined;
@@ -839,6 +838,7 @@ declare class AlgorandClientTransactionCreator {
839
838
  validityWindow?: number | bigint | undefined;
840
839
  firstValidRound?: bigint | undefined;
841
840
  lastValidRound?: bigint | undefined;
841
+ appId: bigint;
842
842
  onComplete?: OnApplicationComplete.DeleteApplication | undefined;
843
843
  accountReferences?: ReadableAddress[] | undefined;
844
844
  appReferences?: bigint[] | undefined;
@@ -847,9 +847,9 @@ declare class AlgorandClientTransactionCreator {
847
847
  accessReferences?: ResourceReference[] | undefined;
848
848
  rejectVersion?: number | undefined;
849
849
  method: ABIMethod;
850
- args?: (Transaction | Promise<Transaction> | ABIValue | TransactionWithSigner | AppMethodCall<{
850
+ args?: (Transaction | ABIValue | TransactionWithSigner | AppMethodCall<{
851
+ signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
851
852
  sender: SendingAddress;
852
- signer?: TransactionSigner | AddressWithTransactionSigner | undefined;
853
853
  rekeyTo?: ReadableAddress | undefined;
854
854
  note?: string | Uint8Array | undefined;
855
855
  lease?: string | Uint8Array | undefined;
@@ -877,9 +877,9 @@ declare class AlgorandClientTransactionCreator {
877
877
  localByteSlices: number;
878
878
  } | undefined;
879
879
  extraProgramPages?: number | undefined;
880
- }> | AppMethodCall<{
880
+ }> | Promise<Transaction> | AppMethodCall<{
881
881
  sender: SendingAddress;
882
- signer?: TransactionSigner | AddressWithTransactionSigner | undefined;
882
+ signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
883
883
  rekeyTo?: ReadableAddress | undefined;
884
884
  note?: string | Uint8Array | undefined;
885
885
  lease?: string | Uint8Array | undefined;
@@ -950,9 +950,8 @@ declare class AlgorandClientTransactionCreator {
950
950
  * @returns The application ABI method call transaction
951
951
  */
952
952
  appCallMethodCall: (params: {
953
- appId: bigint;
953
+ signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
954
954
  sender: SendingAddress;
955
- signer?: TransactionSigner | AddressWithTransactionSigner | undefined;
956
955
  rekeyTo?: ReadableAddress | undefined;
957
956
  note?: string | Uint8Array | undefined;
958
957
  lease?: string | Uint8Array | undefined;
@@ -962,6 +961,7 @@ declare class AlgorandClientTransactionCreator {
962
961
  validityWindow?: number | bigint | undefined;
963
962
  firstValidRound?: bigint | undefined;
964
963
  lastValidRound?: bigint | undefined;
964
+ appId: bigint;
965
965
  onComplete?: OnApplicationComplete.NoOp | OnApplicationComplete.OptIn | OnApplicationComplete.CloseOut | OnApplicationComplete.DeleteApplication | undefined;
966
966
  accountReferences?: ReadableAddress[] | undefined;
967
967
  appReferences?: bigint[] | undefined;
@@ -970,9 +970,9 @@ declare class AlgorandClientTransactionCreator {
970
970
  accessReferences?: ResourceReference[] | undefined;
971
971
  rejectVersion?: number | undefined;
972
972
  method: ABIMethod;
973
- args?: (Transaction | Promise<Transaction> | ABIValue | TransactionWithSigner | AppMethodCall<{
973
+ args?: (Transaction | ABIValue | TransactionWithSigner | AppMethodCall<{
974
+ signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
974
975
  sender: SendingAddress;
975
- signer?: TransactionSigner | AddressWithTransactionSigner | undefined;
976
976
  rekeyTo?: ReadableAddress | undefined;
977
977
  note?: string | Uint8Array | undefined;
978
978
  lease?: string | Uint8Array | undefined;
@@ -1000,9 +1000,9 @@ declare class AlgorandClientTransactionCreator {
1000
1000
  localByteSlices: number;
1001
1001
  } | undefined;
1002
1002
  extraProgramPages?: number | undefined;
1003
- }> | AppMethodCall<{
1003
+ }> | Promise<Transaction> | AppMethodCall<{
1004
1004
  sender: SendingAddress;
1005
- signer?: TransactionSigner | AddressWithTransactionSigner | undefined;
1005
+ signer?: AddressWithTransactionSigner | TransactionSigner | undefined;
1006
1006
  rekeyTo?: ReadableAddress | undefined;
1007
1007
  note?: string | Uint8Array | undefined;
1008
1008
  lease?: string | Uint8Array | undefined;