diff --git a/ALGOSDK.md b/ALGOSDK.md deleted file mode 100644 index 5585273..0000000 --- a/ALGOSDK.md +++ /dev/null @@ -1,17 +0,0 @@ -# Algorand Javascript SDK Dependency Info - -This package depends on the unreleased version 3.0.0 branch of the Algorand Javascript SDK: https://github.com/algorand/js-algorand-sdk/tree/3.0.0 - -Because of this, we have vendored the SDK code directly into this repository in the `algosdk` directory. This code was taken from commit `d52784019343077cc8cb6a3e8c9f8ce34ad3d509`. - -In order to satisfy the dependencies of `algosdk`, these additional packages were added as direct dependencies: - -- `algo-msgpack-with-bigint` -- `hi-base32` -- `js-sha256` -- `js-sha3` -- `js-sha512` -- `tweetnacl` -- `vlq` - -Once v3 of `algosdk` has been released, we can remove the vendored code and the additional dependencies and replaced it with an actual dependency on `algosdk`. diff --git a/README.md b/README.md index 9626321..7240110 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # AVM Debugger +![GitHub Actions Workflow](https://github.com/algorand/avm-debugger/actions/workflows/ci.yml/badge.svg) +[![npm version](https://badge.fury.io/js/avm-debug-adapter.svg)](https://www.npmjs.com/package/avm-debug-adapter) + ## Summary This repo contains an AVM debugger which adheres to the [Debug Adapter Protocol](https://microsoft.github.io/debug-adapter-protocol/). diff --git a/algosdk/abi/abi_type.d.ts b/algosdk/abi/abi_type.d.ts deleted file mode 100644 index 1837f0a..0000000 --- a/algosdk/abi/abi_type.d.ts +++ /dev/null @@ -1,102 +0,0 @@ -export declare const MAX_LEN: number; -export declare const ADDR_BYTE_SIZE = 32; -export declare const SINGLE_BYTE_SIZE = 1; -export declare const SINGLE_BOOL_SIZE = 1; -export declare const LENGTH_ENCODE_BYTE_SIZE = 2; -export declare type ABIValue = boolean | number | bigint | string | Uint8Array | ABIValue[]; -export declare abstract class ABIType { - abstract toString(): string; - abstract equals(other: ABIType): boolean; - abstract isDynamic(): boolean; - abstract byteLen(): number; - abstract encode(value: ABIValue): Uint8Array; - abstract decode(byteString: Uint8Array): ABIValue; - static from(str: string): ABIType; -} -export declare class ABIUintType extends ABIType { - bitSize: number; - constructor(size: number); - toString(): string; - equals(other: ABIType): boolean; - isDynamic(): boolean; - byteLen(): number; - encode(value: ABIValue): Uint8Array; - decode(byteString: Uint8Array): bigint; -} -export declare class ABIUfixedType extends ABIType { - bitSize: number; - precision: number; - constructor(size: number, denominator: number); - toString(): string; - equals(other: ABIType): boolean; - isDynamic(): boolean; - byteLen(): number; - encode(value: ABIValue): Uint8Array; - decode(byteString: Uint8Array): bigint; -} -export declare class ABIAddressType extends ABIType { - toString(): string; - equals(other: ABIType): boolean; - isDynamic(): boolean; - byteLen(): number; - encode(value: ABIValue): Uint8Array; - decode(byteString: Uint8Array): string; -} -export declare class ABIBoolType extends ABIType { - toString(): string; - equals(other: ABIType): boolean; - isDynamic(): boolean; - byteLen(): number; - encode(value: ABIValue): Uint8Array; - decode(byteString: Uint8Array): boolean; -} -export declare class ABIByteType extends ABIType { - toString(): string; - equals(other: ABIType): boolean; - isDynamic(): boolean; - byteLen(): number; - encode(value: ABIValue): Uint8Array; - decode(byteString: Uint8Array): number; -} -export declare class ABIStringType extends ABIType { - toString(): string; - equals(other: ABIType): boolean; - isDynamic(): boolean; - byteLen(): never; - encode(value: ABIValue): Uint8Array; - decode(byteString: Uint8Array): string; -} -export declare class ABIArrayStaticType extends ABIType { - childType: ABIType; - staticLength: number; - constructor(argType: ABIType, arrayLength: number); - toString(): string; - equals(other: ABIType): boolean; - isDynamic(): boolean; - byteLen(): number; - encode(value: ABIValue): Uint8Array; - decode(byteString: Uint8Array): ABIValue[]; - toABITupleType(): ABITupleType; -} -export declare class ABIArrayDynamicType extends ABIType { - childType: ABIType; - constructor(argType: ABIType); - toString(): string; - equals(other: ABIType): boolean; - isDynamic(): boolean; - byteLen(): never; - encode(value: ABIValue): Uint8Array; - decode(byteString: Uint8Array): ABIValue[]; - toABITupleType(length: number): ABITupleType; -} -export declare class ABITupleType extends ABIType { - childTypes: ABIType[]; - constructor(argTypes: ABIType[]); - toString(): string; - equals(other: ABIType): boolean; - isDynamic(): boolean; - byteLen(): number; - encode(value: ABIValue): Uint8Array; - decode(byteString: Uint8Array): ABIValue[]; - static parseTupleContent(str: string): string[]; -} diff --git a/algosdk/abi/abi_type.js b/algosdk/abi/abi_type.js deleted file mode 100644 index d34bf42..0000000 --- a/algosdk/abi/abi_type.js +++ /dev/null @@ -1,700 +0,0 @@ -"use strict"; -/* eslint-disable no-bitwise */ -/* eslint-disable no-use-before-define */ -/* eslint-disable class-methods-use-this */ -Object.defineProperty(exports, "__esModule", { value: true }); -exports.ABITupleType = exports.ABIArrayDynamicType = exports.ABIArrayStaticType = exports.ABIStringType = exports.ABIByteType = exports.ABIBoolType = exports.ABIAddressType = exports.ABIUfixedType = exports.ABIUintType = exports.ABIType = exports.LENGTH_ENCODE_BYTE_SIZE = exports.SINGLE_BOOL_SIZE = exports.SINGLE_BYTE_SIZE = exports.ADDR_BYTE_SIZE = exports.MAX_LEN = void 0; -/** - //ABI-Types: uint: An N-bit unsigned integer (8 <= N <= 512 and N % 8 = 0). - // | byte (alias for uint8) - // | ufixed x (8 <= N <= 512, N % 8 = 0, and 0 < M <= 160) - // | bool - // | address (alias for byte[32]) - // | [] - // | [] - // | string - // | (T1, ..., Tn) -*/ -const address_1 = require("../encoding/address"); -const bigint_1 = require("../encoding/bigint"); -const utils_1 = require("../utils/utils"); -exports.MAX_LEN = 2 ** 16 - 1; -exports.ADDR_BYTE_SIZE = 32; -exports.SINGLE_BYTE_SIZE = 1; -exports.SINGLE_BOOL_SIZE = 1; -exports.LENGTH_ENCODE_BYTE_SIZE = 2; -const staticArrayRegexp = /^([a-z\d[\](),]+)\[(0|[1-9][\d]*)]$/; -const ufixedRegexp = /^ufixed([1-9][\d]*)x([1-9][\d]*)$/; -class ABIType { - // De-serializes the ABI type from a string using the ABI specs - static from(str) { - if (str.endsWith('[]')) { - const arrayArgType = ABIType.from(str.slice(0, str.length - 2)); - return new ABIArrayDynamicType(arrayArgType); - } - if (str.endsWith(']')) { - const stringMatches = str.match(staticArrayRegexp); - // Match the string itself, array element type, then array length - if (stringMatches.length !== 3) { - throw new Error(`malformed static array string: ${str}`); - } - // Parse static array using regex - const arrayLengthStr = stringMatches[2]; - const arrayLength = parseInt(arrayLengthStr, 10); - if (arrayLength > exports.MAX_LEN) { - throw new Error(`array length exceeds limit ${exports.MAX_LEN}`); - } - // Parse the array element type - const arrayType = ABIType.from(stringMatches[1]); - return new ABIArrayStaticType(arrayType, arrayLength); - } - if (str.startsWith('uint')) { - // Checks if the parsed number contains only digits, no whitespaces - const digitsOnly = (string) => [...string].every((c) => '0123456789'.includes(c)); - const typeSizeStr = str.slice(4, str.length); - if (!digitsOnly(typeSizeStr)) { - throw new Error(`malformed uint string: ${typeSizeStr}`); - } - const typeSize = parseInt(typeSizeStr, 10); - if (typeSize > exports.MAX_LEN) { - throw new Error(`malformed uint string: ${typeSize}`); - } - return new ABIUintType(typeSize); - } - if (str === 'byte') { - return new ABIByteType(); - } - if (str.startsWith('ufixed')) { - const stringMatches = str.match(ufixedRegexp); - if (stringMatches.length !== 3) { - throw new Error(`malformed ufixed type: ${str}`); - } - const ufixedSize = parseInt(stringMatches[1], 10); - const ufixedPrecision = parseInt(stringMatches[2], 10); - return new ABIUfixedType(ufixedSize, ufixedPrecision); - } - if (str === 'bool') { - return new ABIBoolType(); - } - if (str === 'address') { - return new ABIAddressType(); - } - if (str === 'string') { - return new ABIStringType(); - } - if (str.length >= 2 && str[0] === '(' && str[str.length - 1] === ')') { - const tupleContent = ABITupleType.parseTupleContent(str.slice(1, str.length - 1)); - const tupleTypes = []; - for (let i = 0; i < tupleContent.length; i++) { - const ti = ABIType.from(tupleContent[i]); - tupleTypes.push(ti); - } - return new ABITupleType(tupleTypes); - } - throw new Error(`cannot convert a string ${str} to an ABI type`); - } -} -exports.ABIType = ABIType; -class ABIUintType extends ABIType { - constructor(size) { - super(); - if (size % 8 !== 0 || size < 8 || size > 512) { - throw new Error(`unsupported uint type bitSize: ${size}`); - } - this.bitSize = size; - } - toString() { - return `uint${this.bitSize}`; - } - equals(other) { - return other instanceof ABIUintType && this.bitSize === other.bitSize; - } - isDynamic() { - return false; - } - byteLen() { - return this.bitSize / 8; - } - encode(value) { - if (typeof value !== 'bigint' && typeof value !== 'number') { - throw new Error(`Cannot encode value as uint${this.bitSize}: ${value}`); - } - if (value >= BigInt(2 ** this.bitSize) || value < BigInt(0)) { - throw new Error(`${value} is not a non-negative int or too big to fit in size uint${this.bitSize}`); - } - if (typeof value === 'number' && !Number.isSafeInteger(value)) { - throw new Error(`${value} should be converted into a BigInt before it is encoded`); - } - return (0, bigint_1.bigIntToBytes)(value, this.bitSize / 8); - } - decode(byteString) { - if (byteString.length !== this.bitSize / 8) { - throw new Error(`byte string must correspond to a uint${this.bitSize}`); - } - return (0, bigint_1.bytesToBigInt)(byteString); - } -} -exports.ABIUintType = ABIUintType; -class ABIUfixedType extends ABIType { - constructor(size, denominator) { - super(); - if (size % 8 !== 0 || size < 8 || size > 512) { - throw new Error(`unsupported ufixed type bitSize: ${size}`); - } - if (denominator > 160 || denominator < 1) { - throw new Error(`unsupported ufixed type precision: ${denominator}`); - } - this.bitSize = size; - this.precision = denominator; - } - toString() { - return `ufixed${this.bitSize}x${this.precision}`; - } - equals(other) { - return (other instanceof ABIUfixedType && - this.bitSize === other.bitSize && - this.precision === other.precision); - } - isDynamic() { - return false; - } - byteLen() { - return this.bitSize / 8; - } - encode(value) { - if (typeof value !== 'bigint' && typeof value !== 'number') { - throw new Error(`Cannot encode value as ${this.toString()}: ${value}`); - } - if (value >= BigInt(2 ** this.bitSize) || value < BigInt(0)) { - throw new Error(`${value} is not a non-negative int or too big to fit in size ${this.toString()}`); - } - if (typeof value === 'number' && !Number.isSafeInteger(value)) { - throw new Error(`${value} should be converted into a BigInt before it is encoded`); - } - return (0, bigint_1.bigIntToBytes)(value, this.bitSize / 8); - } - decode(byteString) { - if (byteString.length !== this.bitSize / 8) { - throw new Error(`byte string must correspond to a ${this.toString()}`); - } - return (0, bigint_1.bytesToBigInt)(byteString); - } -} -exports.ABIUfixedType = ABIUfixedType; -class ABIAddressType extends ABIType { - toString() { - return 'address'; - } - equals(other) { - return other instanceof ABIAddressType; - } - isDynamic() { - return false; - } - byteLen() { - return exports.ADDR_BYTE_SIZE; - } - encode(value) { - if (typeof value !== 'string' && !(value instanceof Uint8Array)) { - throw new Error(`Cannot encode value as ${this.toString()}: ${value}`); - } - if (typeof value === 'string') { - const decodedAddress = (0, address_1.decodeAddress)(value); - return decodedAddress.publicKey; - } - // Return the address if it is already in bytes - if (value.byteLength !== 32) { - throw new Error(`byte string must be 32 bytes long for an address`); - } - return value; - } - decode(byteString) { - if (byteString.byteLength !== 32) { - throw new Error(`byte string must be 32 bytes long for an address`); - } - return (0, address_1.encodeAddress)(byteString); - } -} -exports.ABIAddressType = ABIAddressType; -class ABIBoolType extends ABIType { - toString() { - return 'bool'; - } - equals(other) { - return other instanceof ABIBoolType; - } - isDynamic() { - return false; - } - byteLen() { - return exports.SINGLE_BOOL_SIZE; - } - encode(value) { - if (typeof value !== 'boolean') { - throw new Error(`Cannot encode value as bool: ${value}`); - } - if (value) { - return new Uint8Array([128]); - } - return new Uint8Array([0]); - } - decode(byteString) { - if (byteString.byteLength !== 1) { - throw new Error(`bool string must be 1 byte long`); - } - const value = byteString[0]; - if (value === 128) { - return true; - } - if (value === 0) { - return false; - } - throw new Error(`boolean could not be decoded from the byte string`); - } -} -exports.ABIBoolType = ABIBoolType; -class ABIByteType extends ABIType { - toString() { - return 'byte'; - } - equals(other) { - return other instanceof ABIByteType; - } - isDynamic() { - return false; - } - byteLen() { - return exports.SINGLE_BYTE_SIZE; - } - encode(value) { - if (typeof value !== 'number' && typeof value !== 'bigint') { - throw new Error(`Cannot encode value as byte: ${value}`); - } - if (typeof value === 'bigint') { - // eslint-disable-next-line no-param-reassign - value = Number(value); - } - if (value < 0 || value > 255) { - throw new Error(`${value} cannot be encoded into a byte`); - } - return new Uint8Array([value]); - } - decode(byteString) { - if (byteString.byteLength !== 1) { - throw new Error(`byte string must be 1 byte long`); - } - return byteString[0]; - } -} -exports.ABIByteType = ABIByteType; -class ABIStringType extends ABIType { - toString() { - return 'string'; - } - equals(other) { - return other instanceof ABIStringType; - } - isDynamic() { - return true; - } - byteLen() { - throw new Error(`${this.toString()} is a dynamic type`); - } - encode(value) { - if (typeof value !== 'string' && !(value instanceof Uint8Array)) { - throw new Error(`Cannot encode value as string: ${value}`); - } - let encodedBytes; - if (typeof value === 'string') { - encodedBytes = new TextEncoder().encode(value); - } - else { - encodedBytes = value; - } - const encodedLength = (0, bigint_1.bigIntToBytes)(encodedBytes.length, exports.LENGTH_ENCODE_BYTE_SIZE); - const mergedBytes = new Uint8Array(encodedBytes.length + exports.LENGTH_ENCODE_BYTE_SIZE); - mergedBytes.set(encodedLength); - mergedBytes.set(encodedBytes, exports.LENGTH_ENCODE_BYTE_SIZE); - return mergedBytes; - } - decode(byteString) { - if (byteString.length < exports.LENGTH_ENCODE_BYTE_SIZE) { - throw new Error(`byte string is too short to be decoded. Actual length is ${byteString.length}, but expected at least ${exports.LENGTH_ENCODE_BYTE_SIZE}`); - } - const view = new DataView(byteString.buffer, byteString.byteOffset, exports.LENGTH_ENCODE_BYTE_SIZE); - const byteLength = view.getUint16(0); - const byteValue = byteString.slice(exports.LENGTH_ENCODE_BYTE_SIZE, byteString.length); - if (byteLength !== byteValue.length) { - throw new Error(`string length bytes do not match the actual length of string. Expected ${byteLength}, got ${byteValue.length}`); - } - return new TextDecoder('utf-8').decode(byteValue); - } -} -exports.ABIStringType = ABIStringType; -class ABIArrayStaticType extends ABIType { - constructor(argType, arrayLength) { - super(); - if (arrayLength < 0) { - throw new Error(`static array must have a non negative length: ${arrayLength}`); - } - this.childType = argType; - this.staticLength = arrayLength; - } - toString() { - return `${this.childType.toString()}[${this.staticLength}]`; - } - equals(other) { - return (other instanceof ABIArrayStaticType && - this.staticLength === other.staticLength && - this.childType.equals(other.childType)); - } - isDynamic() { - return this.childType.isDynamic(); - } - byteLen() { - if (this.childType.constructor === ABIBoolType) { - return Math.ceil(this.staticLength / 8); - } - return this.staticLength * this.childType.byteLen(); - } - encode(value) { - if (!Array.isArray(value) && !(value instanceof Uint8Array)) { - throw new Error(`Cannot encode value as ${this.toString()}: ${value}`); - } - if (value.length !== this.staticLength) { - throw new Error(`Value array does not match static array length. Expected ${this.staticLength}, got ${value.length}`); - } - const convertedTuple = this.toABITupleType(); - return convertedTuple.encode(value); - } - decode(byteString) { - const convertedTuple = this.toABITupleType(); - return convertedTuple.decode(byteString); - } - toABITupleType() { - return new ABITupleType(Array(this.staticLength).fill(this.childType)); - } -} -exports.ABIArrayStaticType = ABIArrayStaticType; -class ABIArrayDynamicType extends ABIType { - constructor(argType) { - super(); - this.childType = argType; - } - toString() { - return `${this.childType.toString()}[]`; - } - equals(other) { - return (other instanceof ABIArrayDynamicType && - this.childType.equals(other.childType)); - } - isDynamic() { - return true; - } - byteLen() { - throw new Error(`${this.toString()} is a dynamic type`); - } - encode(value) { - if (!Array.isArray(value) && !(value instanceof Uint8Array)) { - throw new Error(`Cannot encode value as ${this.toString()}: ${value}`); - } - const convertedTuple = this.toABITupleType(value.length); - const encodedTuple = convertedTuple.encode(value); - const encodedLength = (0, bigint_1.bigIntToBytes)(convertedTuple.childTypes.length, exports.LENGTH_ENCODE_BYTE_SIZE); - const mergedBytes = (0, utils_1.concatArrays)(encodedLength, encodedTuple); - return mergedBytes; - } - decode(byteString) { - const view = new DataView(byteString.buffer, 0, exports.LENGTH_ENCODE_BYTE_SIZE); - const byteLength = view.getUint16(0); - const convertedTuple = this.toABITupleType(byteLength); - return convertedTuple.decode(byteString.slice(exports.LENGTH_ENCODE_BYTE_SIZE, byteString.length)); - } - toABITupleType(length) { - return new ABITupleType(Array(length).fill(this.childType)); - } -} -exports.ABIArrayDynamicType = ABIArrayDynamicType; -class ABITupleType extends ABIType { - constructor(argTypes) { - super(); - if (argTypes.length >= exports.MAX_LEN) { - throw new Error('tuple type child type number larger than maximum uint16 error'); - } - this.childTypes = argTypes; - } - toString() { - const typeStrings = []; - for (let i = 0; i < this.childTypes.length; i++) { - typeStrings[i] = this.childTypes[i].toString(); - } - return `(${typeStrings.join(',')})`; - } - equals(other) { - return (other instanceof ABITupleType && - this.childTypes.length === other.childTypes.length && - this.childTypes.every((child, index) => child.equals(other.childTypes[index]))); - } - isDynamic() { - const isDynamic = (child) => child.isDynamic(); - return this.childTypes.some(isDynamic); - } - byteLen() { - let size = 0; - for (let i = 0; i < this.childTypes.length; i++) { - if (this.childTypes[i].constructor === ABIBoolType) { - const after = findBoolLR(this.childTypes, i, 1); - const boolNum = after + 1; - i += after; - size += Math.trunc((boolNum + 7) / 8); - } - else { - const childByteSize = this.childTypes[i].byteLen(); - size += childByteSize; - } - } - return size; - } - encode(value) { - if (!Array.isArray(value) && !(value instanceof Uint8Array)) { - throw new Error(`Cannot encode value as ${this.toString()}: ${value}`); - } - const values = Array.from(value); - if (value.length > exports.MAX_LEN) { - throw new Error('length of tuple array should not exceed a uint16'); - } - const tupleTypes = this.childTypes; - const heads = []; - const tails = []; - const isDynamicIndex = new Map(); - let i = 0; - while (i < tupleTypes.length) { - const tupleType = tupleTypes[i]; - if (tupleType.isDynamic()) { - // Head is not pre-determined for dynamic types; store a placeholder for now - isDynamicIndex.set(heads.length, true); - heads.push(new Uint8Array([0, 0])); - tails.push(tupleType.encode(values[i])); - } - else { - if (tupleType.constructor === ABIBoolType) { - const before = findBoolLR(tupleTypes, i, -1); - let after = findBoolLR(tupleTypes, i, 1); - // Pack bytes to heads and tails - if (before % 8 !== 0) { - throw new Error('expected before index should have number of bool mod 8 equal 0'); - } - after = Math.min(7, after); - const compressedInt = compressMultipleBool(values.slice(i, i + after + 1)); - heads.push((0, bigint_1.bigIntToBytes)(compressedInt, 1)); - i += after; - } - else { - const encodedTupleValue = tupleType.encode(values[i]); - heads.push(encodedTupleValue); - } - isDynamicIndex.set(i, false); - tails.push(new Uint8Array()); - } - i += 1; - } - // Adjust head lengths for dynamic types - let headLength = 0; - for (const headElement of heads) { - headLength += headElement.length; - } - // encode any placeholders for dynamic types - let tailLength = 0; - for (let j = 0; j < heads.length; j++) { - if (isDynamicIndex.get(j)) { - const headValue = headLength + tailLength; - if (headValue > exports.MAX_LEN) { - throw new Error(`byte length of ${headValue} should not exceed a uint16`); - } - heads[j] = (0, bigint_1.bigIntToBytes)(headValue, exports.LENGTH_ENCODE_BYTE_SIZE); - } - tailLength += tails[j].length; - } - return (0, utils_1.concatArrays)(...heads, ...tails); - } - decode(byteString) { - const tupleTypes = this.childTypes; - const dynamicSegments = []; - const valuePartition = []; - let i = 0; - let iterIndex = 0; - const view = new DataView(byteString.buffer); - while (i < tupleTypes.length) { - const tupleType = tupleTypes[i]; - if (tupleType.isDynamic()) { - if (byteString.slice(iterIndex, byteString.length).length < - exports.LENGTH_ENCODE_BYTE_SIZE) { - throw new Error('dynamic type in tuple is too short to be decoded'); - } - // Since LENGTH_ENCODE_BYTE_SIZE is 2 and indices are at most 2 bytes, - // we can use getUint16 using the iterIndex offset. - const dynamicIndex = view.getUint16(iterIndex); - if (dynamicSegments.length > 0) { - dynamicSegments[dynamicSegments.length - 1].right = dynamicIndex; - // Check that right side of segment is greater than the left side - if (dynamicIndex < dynamicSegments[dynamicSegments.length - 1].left) { - throw new Error('dynamic index segment miscalculation: left is greater than right index'); - } - } - // Since we do not know where the current dynamic element ends, put a placeholder and update later - const seg = { - left: dynamicIndex, - right: -1, - }; - dynamicSegments.push(seg); - valuePartition.push(null); - iterIndex += exports.LENGTH_ENCODE_BYTE_SIZE; - } - else { - // eslint-disable-next-line no-lonely-if - if (tupleType.constructor === ABIBoolType) { - const before = findBoolLR(this.childTypes, i, -1); - let after = findBoolLR(this.childTypes, i, 1); - if (before % 8 !== 0) { - throw new Error('expected before bool number mod 8 === 0'); - } - after = Math.min(7, after); - // Parse bool in a byte to multiple byte strings - for (let boolIndex = 0; boolIndex <= after; boolIndex++) { - const boolMask = 0x80 >> boolIndex; - if ((byteString[iterIndex] & boolMask) > 0) { - valuePartition.push(new Uint8Array([128])); - } - else { - valuePartition.push(new Uint8Array([0])); - } - } - i += after; - iterIndex += 1; - } - else { - const currLen = tupleType.byteLen(); - valuePartition.push(byteString.slice(iterIndex, iterIndex + currLen)); - iterIndex += currLen; - } - } - if (i !== tupleTypes.length - 1 && iterIndex >= byteString.length) { - throw new Error('input byte not enough to decode'); - } - i += 1; - } - if (dynamicSegments.length > 0) { - dynamicSegments[dynamicSegments.length - 1].right = byteString.length; - iterIndex = byteString.length; - } - if (iterIndex < byteString.length) { - throw new Error('input byte not fully consumed'); - } - // Check segment indices are valid - // If the dynamic segment are not consecutive and well-ordered, we return error - for (let j = 0; j < dynamicSegments.length; j++) { - const seg = dynamicSegments[j]; - if (seg.left > seg.right) { - throw new Error('dynamic segment should display a [l, r] space with l <= r'); - } - if (j !== dynamicSegments.length - 1 && - seg.right !== dynamicSegments[j + 1].left) { - throw new Error('dynamic segment should be consecutive'); - } - } - // Check dynamic element partitions - let segIndex = 0; - for (let j = 0; j < tupleTypes.length; j++) { - if (tupleTypes[j].isDynamic()) { - valuePartition[j] = byteString.slice(dynamicSegments[segIndex].left, dynamicSegments[segIndex].right); - segIndex += 1; - } - } - // Decode each tuple element - const returnValues = []; - for (let j = 0; j < tupleTypes.length; j++) { - const valueTi = tupleTypes[j].decode(valuePartition[j]); - returnValues.push(valueTi); - } - return returnValues; - } - static parseTupleContent(str) { - if (str.length === 0) { - return []; - } - if (str.endsWith(',') || str.startsWith(',')) { - throw new Error('tuple string should not start with comma'); - } - if (str.includes(',,')) { - throw new Error('tuple string should not have consecutive commas'); - } - const tupleStrings = []; - let depth = 0; - let word = ''; - for (const char of str) { - word += char; - if (char === '(') { - depth += 1; - } - else if (char === ')') { - depth -= 1; - } - else if (char === ',') { - // If the comma is at depth 0, then append the word as token. - if (depth === 0) { - tupleStrings.push(word.slice(0, word.length - 1)); - word = ''; - } - } - } - if (word.length !== 0) { - tupleStrings.push(word); - } - if (depth !== 0) { - throw new Error('tuple string has mismatched parentheses'); - } - return tupleStrings; - } -} -exports.ABITupleType = ABITupleType; -// compressMultipleBool compresses consecutive bool values into a byte in ABI tuple / array value. -function compressMultipleBool(valueList) { - let res = 0; - if (valueList.length > 8) { - throw new Error('value list passed in should be no greater than length 8'); - } - for (let i = 0; i < valueList.length; i++) { - const boolVal = valueList[i]; - if (typeof boolVal !== 'boolean') { - throw new Error('non-boolean values cannot be compressed into a byte'); - } - if (boolVal) { - res |= 1 << (7 - i); - } - } - return res; -} -// Assume that the current index on the list of type is an ABI bool type. -// It returns the difference between the current index and the index of the furthest consecutive Bool type. -function findBoolLR(typeList, index, delta) { - let until = 0; - while (true) { - const curr = index + delta * until; - if (typeList[curr].constructor === ABIBoolType) { - if (curr !== typeList.length - 1 && delta === 1) { - until += 1; - } - else if (curr > 0 && delta === -1) { - until += 1; - } - else { - break; - } - } - else { - until -= 1; - break; - } - } - return until; -} diff --git a/algosdk/abi/contract.d.ts b/algosdk/abi/contract.d.ts deleted file mode 100644 index 4ce250c..0000000 --- a/algosdk/abi/contract.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { ABIMethod, ABIMethodParams } from './method'; -export interface ABIContractNetworkInfo { - appID: number; -} -export interface ABIContractNetworks { - [network: string]: ABIContractNetworkInfo; -} -export interface ABIContractParams { - name: string; - desc?: string; - networks?: ABIContractNetworks; - methods: ABIMethodParams[]; -} -export declare class ABIContract { - readonly name: string; - readonly description?: string; - readonly networks: ABIContractNetworks; - readonly methods: ABIMethod[]; - constructor(params: ABIContractParams); - toJSON(): ABIContractParams; - getMethodByName(name: string): ABIMethod; -} diff --git a/algosdk/abi/contract.js b/algosdk/abi/contract.js deleted file mode 100644 index ba09cfc..0000000 --- a/algosdk/abi/contract.js +++ /dev/null @@ -1,29 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.ABIContract = void 0; -const method_1 = require("./method"); -class ABIContract { - constructor(params) { - if (typeof params.name !== 'string' || - !Array.isArray(params.methods) || - (params.networks && typeof params.networks !== 'object')) { - throw new Error('Invalid ABIContract parameters'); - } - this.name = params.name; - this.description = params.desc; - this.networks = params.networks ? { ...params.networks } : {}; - this.methods = params.methods.map((method) => new method_1.ABIMethod(method)); - } - toJSON() { - return { - name: this.name, - desc: this.description, - networks: this.networks, - methods: this.methods.map((method) => method.toJSON()), - }; - } - getMethodByName(name) { - return (0, method_1.getMethodByName)(this.methods, name); - } -} -exports.ABIContract = ABIContract; diff --git a/algosdk/abi/index.d.ts b/algosdk/abi/index.d.ts deleted file mode 100644 index 01c18da..0000000 --- a/algosdk/abi/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from './abi_type'; -export * from './contract'; -export * from './interface'; -export * from './method'; -export * from './transaction'; -export * from './reference'; diff --git a/algosdk/abi/index.js b/algosdk/abi/index.js deleted file mode 100644 index f552070..0000000 --- a/algosdk/abi/index.js +++ /dev/null @@ -1,22 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -__exportStar(require("./abi_type"), exports); -__exportStar(require("./contract"), exports); -__exportStar(require("./interface"), exports); -__exportStar(require("./method"), exports); -__exportStar(require("./transaction"), exports); -__exportStar(require("./reference"), exports); diff --git a/algosdk/abi/interface.d.ts b/algosdk/abi/interface.d.ts deleted file mode 100644 index 782fe5c..0000000 --- a/algosdk/abi/interface.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { ABIMethod, ABIMethodParams } from './method'; -export interface ABIInterfaceParams { - name: string; - desc?: string; - methods: ABIMethodParams[]; -} -export declare class ABIInterface { - readonly name: string; - readonly description?: string; - readonly methods: ABIMethod[]; - constructor(params: ABIInterfaceParams); - toJSON(): ABIInterfaceParams; - getMethodByName(name: string): ABIMethod; -} diff --git a/algosdk/abi/interface.js b/algosdk/abi/interface.js deleted file mode 100644 index 36e9f21..0000000 --- a/algosdk/abi/interface.js +++ /dev/null @@ -1,25 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.ABIInterface = void 0; -const method_1 = require("./method"); -class ABIInterface { - constructor(params) { - if (typeof params.name !== 'string' || !Array.isArray(params.methods)) { - throw new Error('Invalid ABIInterface parameters'); - } - this.name = params.name; - this.description = params.desc; - this.methods = params.methods.map((method) => new method_1.ABIMethod(method)); - } - toJSON() { - return { - name: this.name, - desc: this.description, - methods: this.methods.map((method) => method.toJSON()), - }; - } - getMethodByName(name) { - return (0, method_1.getMethodByName)(this.methods, name); - } -} -exports.ABIInterface = ABIInterface; diff --git a/algosdk/abi/method.d.ts b/algosdk/abi/method.d.ts deleted file mode 100644 index 95fdba7..0000000 --- a/algosdk/abi/method.d.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { ABIType } from './abi_type'; -import { ABITransactionType } from './transaction'; -import { ABIReferenceType } from './reference'; -export interface ABIMethodArgParams { - type: string; - name?: string; - desc?: string; -} -export interface ABIMethodReturnParams { - type: string; - desc?: string; -} -export interface ABIMethodParams { - name: string; - desc?: string; - args: ABIMethodArgParams[]; - returns: ABIMethodReturnParams; -} -export declare type ABIArgumentType = ABIType | ABITransactionType | ABIReferenceType; -export declare type ABIReturnType = ABIType | 'void'; -export declare class ABIMethod { - readonly name: string; - readonly description?: string; - readonly args: Array<{ - type: ABIArgumentType; - name?: string; - description?: string; - }>; - readonly returns: { - type: ABIReturnType; - description?: string; - }; - constructor(params: ABIMethodParams); - getSignature(): string; - getSelector(): Uint8Array; - txnCount(): number; - toJSON(): ABIMethodParams; - static fromSignature(signature: string): ABIMethod; -} -export declare function getMethodByName(methods: ABIMethod[], name: string): ABIMethod; diff --git a/algosdk/abi/method.js b/algosdk/abi/method.js deleted file mode 100644 index ffd6da2..0000000 --- a/algosdk/abi/method.js +++ /dev/null @@ -1,128 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.getMethodByName = exports.ABIMethod = void 0; -const naclWrappers_1 = require("../nacl/naclWrappers"); -const abi_type_1 = require("./abi_type"); -const transaction_1 = require("./transaction"); -const reference_1 = require("./reference"); -function parseMethodSignature(signature) { - const argsStart = signature.indexOf('('); - if (argsStart === -1) { - throw new Error(`Invalid method signature: ${signature}`); - } - let argsEnd = -1; - let depth = 0; - for (let i = argsStart; i < signature.length; i++) { - const char = signature[i]; - if (char === '(') { - depth += 1; - } - else if (char === ')') { - if (depth === 0) { - // unpaired parenthesis - break; - } - depth -= 1; - if (depth === 0) { - argsEnd = i; - break; - } - } - } - if (argsEnd === -1) { - throw new Error(`Invalid method signature: ${signature}`); - } - return { - name: signature.slice(0, argsStart), - args: abi_type_1.ABITupleType.parseTupleContent(signature.slice(argsStart + 1, argsEnd)), - returns: signature.slice(argsEnd + 1), - }; -} -class ABIMethod { - constructor(params) { - if (typeof params.name !== 'string' || - typeof params.returns !== 'object' || - !Array.isArray(params.args)) { - throw new Error('Invalid ABIMethod parameters'); - } - this.name = params.name; - this.description = params.desc; - this.args = params.args.map(({ type, name, desc }) => { - if ((0, transaction_1.abiTypeIsTransaction)(type) || (0, reference_1.abiTypeIsReference)(type)) { - return { - type, - name, - description: desc, - }; - } - return { - type: abi_type_1.ABIType.from(type), - name, - description: desc, - }; - }); - this.returns = { - type: params.returns.type === 'void' - ? params.returns.type - : abi_type_1.ABIType.from(params.returns.type), - description: params.returns.desc, - }; - } - getSignature() { - const args = this.args.map((arg) => arg.type.toString()).join(','); - const returns = this.returns.type.toString(); - return `${this.name}(${args})${returns}`; - } - getSelector() { - const hash = (0, naclWrappers_1.genericHash)(this.getSignature()); - return new Uint8Array(hash.slice(0, 4)); - } - txnCount() { - let count = 1; - for (const arg of this.args) { - if (typeof arg.type === 'string' && (0, transaction_1.abiTypeIsTransaction)(arg.type)) { - count += 1; - } - } - return count; - } - toJSON() { - return { - name: this.name, - desc: this.description, - args: this.args.map(({ type, name, description }) => ({ - type: type.toString(), - name, - desc: description, - })), - returns: { - type: this.returns.type.toString(), - desc: this.returns.description, - }, - }; - } - static fromSignature(signature) { - const { name, args, returns } = parseMethodSignature(signature); - return new ABIMethod({ - name, - args: args.map((arg) => ({ type: arg })), - returns: { type: returns }, - }); - } -} -exports.ABIMethod = ABIMethod; -function getMethodByName(methods, name) { - if (methods === null || - !Array.isArray(methods) || - !methods.every((item) => item instanceof ABIMethod)) - throw new Error('Methods list provided is null or not the correct type'); - const filteredMethods = methods.filter((m) => m.name === name); - if (filteredMethods.length > 1) - throw new Error(`found ${filteredMethods.length} methods with the same name ${filteredMethods - .map((m) => m.getSignature()) - .join(',')}`); - if (filteredMethods.length === 0) - throw new Error(`found 0 methods with the name ${name}`); - return filteredMethods[0]; -} -exports.getMethodByName = getMethodByName; diff --git a/algosdk/abi/reference.d.ts b/algosdk/abi/reference.d.ts deleted file mode 100644 index 8829e8f..0000000 --- a/algosdk/abi/reference.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -export declare enum ABIReferenceType { - /** - * Account reference type - */ - account = "account", - /** - * Application reference type - */ - application = "application", - /** - * Asset reference type - */ - asset = "asset" -} -export declare function abiTypeIsReference(type: any): type is ABIReferenceType; diff --git a/algosdk/abi/reference.js b/algosdk/abi/reference.js deleted file mode 100644 index 9ceeba6..0000000 --- a/algosdk/abi/reference.js +++ /dev/null @@ -1,24 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.abiTypeIsReference = exports.ABIReferenceType = void 0; -var ABIReferenceType; -(function (ABIReferenceType) { - /** - * Account reference type - */ - ABIReferenceType["account"] = "account"; - /** - * Application reference type - */ - ABIReferenceType["application"] = "application"; - /** - * Asset reference type - */ - ABIReferenceType["asset"] = "asset"; -})(ABIReferenceType = exports.ABIReferenceType || (exports.ABIReferenceType = {})); -function abiTypeIsReference(type) { - return (type === ABIReferenceType.account || - type === ABIReferenceType.application || - type === ABIReferenceType.asset); -} -exports.abiTypeIsReference = abiTypeIsReference; diff --git a/algosdk/abi/transaction.d.ts b/algosdk/abi/transaction.d.ts deleted file mode 100644 index 309bc92..0000000 --- a/algosdk/abi/transaction.d.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { Transaction } from '../transaction'; -export declare enum ABITransactionType { - /** - * Any transaction type - */ - any = "txn", - /** - * Payment transaction type - */ - pay = "pay", - /** - * Key registration transaction type - */ - keyreg = "keyreg", - /** - * Asset configuration transaction type - */ - acfg = "acfg", - /** - * Asset transfer transaction type - */ - axfer = "axfer", - /** - * Asset freeze transaction type - */ - afrz = "afrz", - /** - * Application transaction type - */ - appl = "appl" -} -export declare function abiTypeIsTransaction(type: any): type is ABITransactionType; -export declare function abiCheckTransactionType(type: ABITransactionType, txn: Transaction): boolean; diff --git a/algosdk/abi/transaction.js b/algosdk/abi/transaction.js deleted file mode 100644 index 0e9bc30..0000000 --- a/algosdk/abi/transaction.js +++ /dev/null @@ -1,51 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.abiCheckTransactionType = exports.abiTypeIsTransaction = exports.ABITransactionType = void 0; -var ABITransactionType; -(function (ABITransactionType) { - /** - * Any transaction type - */ - ABITransactionType["any"] = "txn"; - /** - * Payment transaction type - */ - ABITransactionType["pay"] = "pay"; - /** - * Key registration transaction type - */ - ABITransactionType["keyreg"] = "keyreg"; - /** - * Asset configuration transaction type - */ - ABITransactionType["acfg"] = "acfg"; - /** - * Asset transfer transaction type - */ - ABITransactionType["axfer"] = "axfer"; - /** - * Asset freeze transaction type - */ - ABITransactionType["afrz"] = "afrz"; - /** - * Application transaction type - */ - ABITransactionType["appl"] = "appl"; -})(ABITransactionType = exports.ABITransactionType || (exports.ABITransactionType = {})); -function abiTypeIsTransaction(type) { - return (type === ABITransactionType.any || - type === ABITransactionType.pay || - type === ABITransactionType.keyreg || - type === ABITransactionType.acfg || - type === ABITransactionType.axfer || - type === ABITransactionType.afrz || - type === ABITransactionType.appl); -} -exports.abiTypeIsTransaction = abiTypeIsTransaction; -function abiCheckTransactionType(type, txn) { - if (type === ABITransactionType.any) { - return true; - } - return txn.type && txn.type.toString() === type.toString(); -} -exports.abiCheckTransactionType = abiCheckTransactionType; diff --git a/algosdk/account.d.ts b/algosdk/account.d.ts deleted file mode 100644 index 5c9f40e..0000000 --- a/algosdk/account.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import Account from './types/account'; -/** - * generateAccount returns a new Algorand address and its corresponding secret key - */ -export default function generateAccount(): Account; diff --git a/algosdk/account.js b/algosdk/account.js deleted file mode 100644 index ac4edbe..0000000 --- a/algosdk/account.js +++ /dev/null @@ -1,36 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const nacl = __importStar(require("./nacl/naclWrappers")); -const address = __importStar(require("./encoding/address")); -/** - * generateAccount returns a new Algorand address and its corresponding secret key - */ -function generateAccount() { - const keys = nacl.keyPair(); - const encodedPk = address.encodeAddress(keys.publicKey); - return { addr: encodedPk, sk: keys.secretKey }; -} -exports.default = generateAccount; diff --git a/algosdk/bid.d.ts b/algosdk/bid.d.ts deleted file mode 100644 index c2e30fd..0000000 --- a/algosdk/bid.d.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { Address } from './types/address'; -interface BidStorageStructure { - bidderKey: Address; - bidAmount: number; - bidID: number; - auctionKey: Address; - auctionID: number; - maxPrice: number; -} -export declare type BidOptions = Omit & { - bidderKey: string; - auctionKey: string; -}; -/** - * Bid enables construction of Algorand Auctions Bids - * */ -export default class Bid implements BidStorageStructure { - name: string; - tag: Uint8Array; - bidderKey: Address; - bidAmount: number; - bidID: number; - auctionKey: Address; - auctionID: number; - maxPrice: number; - constructor({ bidderKey, bidAmount, bidID, auctionKey, auctionID, maxPrice, }: BidOptions); - get_obj_for_encoding(): { - bidder: Uint8Array; - cur: number; - price: number; - id: number; - auc: Uint8Array; - aid: number; - }; - signBid(sk: Uint8Array): Uint8Array; -} -export {}; diff --git a/algosdk/bid.js b/algosdk/bid.js deleted file mode 100644 index aa299c7..0000000 --- a/algosdk/bid.js +++ /dev/null @@ -1,81 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const address = __importStar(require("./encoding/address")); -const encoding = __importStar(require("./encoding/encoding")); -const nacl = __importStar(require("./nacl/naclWrappers")); -const utils = __importStar(require("./utils/utils")); -/** - * Bid enables construction of Algorand Auctions Bids - * */ -class Bid { - constructor({ bidderKey, bidAmount, bidID, auctionKey, auctionID, maxPrice, }) { - this.name = 'Bid'; - this.tag = Uint8Array.from([97, 66]); // "aB" - const decodedBidderKey = address.decodeAddress(bidderKey); - const decodedAuctionKey = address.decodeAddress(auctionKey); - if (!Number.isSafeInteger(bidAmount) || bidAmount < 0) - throw Error('Bid amount must be positive and 2^53-1'); - if (!Number.isSafeInteger(bidID) || bidID < 0) - throw Error('BidID must be positive and 2^53-1'); - if (!Number.isSafeInteger(auctionID) || auctionID < 0) - throw Error('auctionID must be positive'); - Object.assign(this, { - bidderKey: decodedBidderKey, - bidAmount, - bidID, - auctionKey: decodedAuctionKey, - auctionID, - maxPrice, - }); - } - // eslint-disable-next-line camelcase - get_obj_for_encoding() { - return { - bidder: this.bidderKey.publicKey, - cur: this.bidAmount, - price: this.maxPrice, - id: this.bidID, - auc: this.auctionKey.publicKey, - aid: this.auctionID, - }; - } - signBid(sk) { - const encodedMsg = encoding.encode(this.get_obj_for_encoding()); - const toBeSigned = utils.concatArrays(this.tag, encodedMsg); - const sig = nacl.sign(toBeSigned, sk); - // construct signed message - const sBid = { - sig, - bid: this.get_obj_for_encoding(), - }; - const note = { - t: 'b', - b: sBid, - }; - return new Uint8Array(encoding.encode(note)); - } -} -exports.default = Bid; diff --git a/algosdk/boxStorage.d.ts b/algosdk/boxStorage.d.ts deleted file mode 100644 index 6316022..0000000 --- a/algosdk/boxStorage.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { EncodedBoxReference } from './types'; -import { BoxReference } from './types/transactions/base'; -/** - * translateBoxReferences translates an array of BoxReferences with app IDs - * into an array of EncodedBoxReferences with foreign indices. - */ -export declare function translateBoxReferences(references: BoxReference[] | undefined, foreignApps: number[], appIndex: number): EncodedBoxReference[]; diff --git a/algosdk/boxStorage.js b/algosdk/boxStorage.js deleted file mode 100644 index 86bd7e6..0000000 --- a/algosdk/boxStorage.js +++ /dev/null @@ -1,32 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.translateBoxReferences = void 0; -function translateBoxReference(reference, foreignApps, appIndex) { - const referenceId = reference.appIndex; - const referenceName = reference.name; - const isOwnReference = referenceId === 0 || referenceId === appIndex; - let index = 0; - if (foreignApps != null) { - // Foreign apps start from index 1; index 0 is its own app ID. - index = foreignApps.indexOf(referenceId) + 1; - } - // Check if the app referenced is itself after checking the foreign apps array. - // If index is zero, then the app ID was not found in the foreign apps array - // or the foreign apps array was null. - if (index === 0 && !isOwnReference) { - // Error if the app is trying to reference a foreign app that was not in - // its own foreign apps array. - throw new Error(`Box ref with appId ${referenceId} not in foreign-apps`); - } - return { i: index, n: referenceName }; -} -/** - * translateBoxReferences translates an array of BoxReferences with app IDs - * into an array of EncodedBoxReferences with foreign indices. - */ -function translateBoxReferences(references, foreignApps, appIndex) { - if (references == null) - return []; - return references.map((bx) => translateBoxReference(bx, foreignApps, appIndex)); -} -exports.translateBoxReferences = translateBoxReferences; diff --git a/algosdk/client/baseHTTPClient.d.ts b/algosdk/client/baseHTTPClient.d.ts deleted file mode 100644 index 11d2d75..0000000 --- a/algosdk/client/baseHTTPClient.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -export declare type Query = { - format?: F; - [key: string]: any; -}; -export interface BaseHTTPClientResponse { - body: Uint8Array; - status: number; - headers: Record; -} -/** - * BaseHTTPClientError is the interface that errors thrown - * by methods of BaseHTTPClient should be using - */ -export interface BaseHTTPClientError { - response: BaseHTTPClientResponse; -} -/** - * BaseHTTPClient is an interface abstracting the queries that can be - * made to an algod/indexer endpoint. - * The SDK normally uses the URLTokenBaseHTTPClient implementation. - * But when used via wallets, the wallet may provide a different object - * satisfying the HTTPClient interface. This is useful to allow - * wallets to provide access to paid API services without leaking - * the secret tokens/URLs. - * - * Note that post and delete also have an optional query parameter - * This is to allow future extension where post and delete may have queries - * Currently however HTTPClient does not make use of it - * - * Compared to HTTPClient, BaseHTTPClient does not deal with serialization/deserialization - * Everything is already string/Uint8Array - * and all the headers (including Accept/Content-Type) are assumed to be provided - * - * In case of non-200 status, all methods must throw an error of type - * BaseHTTPClientError - */ -export interface BaseHTTPClient { - get(relativePath: string, query?: Query, requestHeaders?: Record): Promise; - post(relativePath: string, data: Uint8Array, query?: Query, requestHeaders?: Record): Promise; - delete(relativePath: string, data: Uint8Array, query?: Query, requestHeaders?: Record): Promise; -} diff --git a/algosdk/client/baseHTTPClient.js b/algosdk/client/baseHTTPClient.js deleted file mode 100644 index c8ad2e5..0000000 --- a/algosdk/client/baseHTTPClient.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/algosdk/client/client.d.ts b/algosdk/client/client.d.ts deleted file mode 100644 index 2d40cf0..0000000 --- a/algosdk/client/client.d.ts +++ /dev/null @@ -1,83 +0,0 @@ -import * as utils from '../utils/utils'; -import { BaseHTTPClient, Query } from './baseHTTPClient'; -import { TokenHeader } from './urlTokenBaseHTTPClient'; -export interface HTTPClientResponse { - body: Uint8Array | any; - text?: string; - headers: Record; - status: number; - ok: boolean; -} -/** - * HTTPClient is a wrapper around a BaseHTTPClient - * It takes care of setting the proper "Accept" header and of - * decoding the JSON outputs. - */ -export default class HTTPClient { - private bc; - /** - * Construct an HTTPClient from a BaseHTTPClient - * @param bc - the BaseHTTPClient used - */ - constructor(bc: BaseHTTPClient); - /** - * Construct an HTTPClient from a URL (baseServer+port) and a token - */ - constructor(tokenHeader: TokenHeader, baseServer: string, port?: string | number, defaultHeaders?: Record); - /** - * Parse JSON using either the built-in JSON.parse or utils.parseJSON - * depending on whether jsonOptions are provided or not - * - * @param text - JSON data - * @param status - Status of the response (used in case parseJSON fails) - * @param jsonOptions - Options object to use to decode JSON responses. See - * utils.parseJSON for the options available. - */ - static parseJSON(text: string, status: number, jsonOptions?: utils.JSONOptions): any; - /** - * Serialize the data according to the requestHeaders - * Assumes that requestHeaders contain a key "content-type" - * If the content-type is "application/json", data is JSON serialized - * Otherwise, data needs to be either an UTF-8 string that is converted to an Uint8Array - * or an Uint8Array - * @private - */ - private static serializeData; - /** - * Convert a BaseHTTPClientResponse into a full HTTPClientResponse - * Parse the body in - * Modifies in place res and return the result - */ - private static prepareResponse; - /** - * Prepare an error with a response - * (the type of errors BaseHTTPClient are supposed to throw) - * by adding the status and preparing the internal response - * @private - */ - private static prepareResponseError; - /** - * Send a GET request. - * @param relativePath - The path of the request. - * @param query - An object containing the query parameters of the request. - * @param requestHeaders - An object containing additional request headers to use. - * @param jsonOptions - Options object to use to decode JSON responses. See - * utils.parseJSON for the options available. - * @param parseBody - An optional boolean indicating whether the response body should be parsed - * or not. - * @returns Response object. - */ - get(relativePath: string, query?: Query, requestHeaders?: Record, jsonOptions?: utils.JSONOptions, parseBody?: boolean): Promise; - /** - * Send a POST request. - * If no content-type present, adds the header "content-type: application/json" - * and data is serialized in JSON (if not empty) - */ - post(relativePath: string, data: any, query?: Query, requestHeaders?: Record, parseBody?: boolean): Promise; - /** - * Send a DELETE request. - * If no content-type present, adds the header "content-type: application/json" - * and data is serialized in JSON (if not empty) - */ - delete(relativePath: string, data: any, requestHeaders?: Record, parseBody?: boolean): Promise; -} diff --git a/algosdk/client/client.js b/algosdk/client/client.js deleted file mode 100644 index 0adc89c..0000000 --- a/algosdk/client/client.js +++ /dev/null @@ -1,221 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const utils = __importStar(require("../utils/utils")); -const urlTokenBaseHTTPClient_1 = require("./urlTokenBaseHTTPClient"); -/** - * Remove falsy values or values with a length of 0 from an object. - */ -function removeFalsyOrEmpty(obj) { - for (const key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key)) { - // eslint-disable-next-line no-param-reassign - if (!obj[key] || obj[key].length === 0) - delete obj[key]; - } - } - return obj; -} -/** - * Create a new object with lower-case keys - * See https://codereview.stackexchange.com/a/162418 - * Used to ensure all headers are lower-case and to work more easily with them - */ -function tolowerCaseKeys(o) { - /* eslint-disable no-param-reassign,no-return-assign,no-sequences */ - return Object.keys(o).reduce((c, k) => ((c[k.toLowerCase()] = o[k]), c), {}); - /* eslint-enable no-param-reassign,no-return-assign,no-sequences */ -} -/** - * getAcceptFormat returns the correct Accept header depending on the - * requested format. - */ -function getAcceptFormat(query) { - if (query !== undefined && - Object.prototype.hasOwnProperty.call(query, 'format')) { - switch (query.format) { - case 'msgpack': - return 'application/msgpack'; - case 'json': - default: - return 'application/json'; - } - } - else - return 'application/json'; -} -/** - * HTTPClient is a wrapper around a BaseHTTPClient - * It takes care of setting the proper "Accept" header and of - * decoding the JSON outputs. - */ -class HTTPClient { - constructor(bcOrTokenHeader, baseServer, port, defaultHeaders = {}) { - if (baseServer !== undefined) { - this.bc = new urlTokenBaseHTTPClient_1.URLTokenBaseHTTPClient(bcOrTokenHeader, baseServer, port, defaultHeaders); - } - else { - this.bc = bcOrTokenHeader; - } - } - /** - * Parse JSON using either the built-in JSON.parse or utils.parseJSON - * depending on whether jsonOptions are provided or not - * - * @param text - JSON data - * @param status - Status of the response (used in case parseJSON fails) - * @param jsonOptions - Options object to use to decode JSON responses. See - * utils.parseJSON for the options available. - */ - static parseJSON(text, status, jsonOptions = {}) { - try { - if (Object.keys(jsonOptions).length === 0) { - return text && JSON.parse(text); - } - return text && utils.parseJSON(text, jsonOptions); - } - catch (err_) { - const err = err_; - // return the raw response if the response parsing fails - err.rawResponse = text || null; - // return the http status code if the response parsing fails - err.statusCode = status; - throw err; - } - } - /** - * Serialize the data according to the requestHeaders - * Assumes that requestHeaders contain a key "content-type" - * If the content-type is "application/json", data is JSON serialized - * Otherwise, data needs to be either an UTF-8 string that is converted to an Uint8Array - * or an Uint8Array - * @private - */ - static serializeData(data, requestHeaders) { - if (!data) { - return new Uint8Array(0); // empty Uint8Array - } - if (requestHeaders['content-type'] === 'application/json') { - return new TextEncoder().encode(JSON.stringify(data)); - } - if (typeof data === 'string') { - return new TextEncoder().encode(data); - } - if (data instanceof Uint8Array) { - return data; - } - throw new Error('provided data is neither a string nor a Uint8Array and content-type is not application/json'); - } - /** - * Convert a BaseHTTPClientResponse into a full HTTPClientResponse - * Parse the body in - * Modifies in place res and return the result - */ - static prepareResponse(res, format, parseBody, jsonOptions = {}) { - let { body } = res; - let text; - if (format !== 'application/msgpack') { - text = (body && new TextDecoder().decode(body)) || ''; - } - if (parseBody && format === 'application/json') { - body = HTTPClient.parseJSON(text, res.status, jsonOptions); - } - return { - ...res, - body, - text, - ok: Math.trunc(res.status / 100) === 2, - }; - } - /** - * Prepare an error with a response - * (the type of errors BaseHTTPClient are supposed to throw) - * by adding the status and preparing the internal response - * @private - */ - static prepareResponseError(err) { - if (err.response) { - // eslint-disable-next-line no-param-reassign - err.response = HTTPClient.prepareResponse(err.response, 'application/json', true); - // eslint-disable-next-line no-param-reassign - err.status = err.response.status; - } - return err; - } - /** - * Send a GET request. - * @param relativePath - The path of the request. - * @param query - An object containing the query parameters of the request. - * @param requestHeaders - An object containing additional request headers to use. - * @param jsonOptions - Options object to use to decode JSON responses. See - * utils.parseJSON for the options available. - * @param parseBody - An optional boolean indicating whether the response body should be parsed - * or not. - * @returns Response object. - */ - async get(relativePath, query, requestHeaders = {}, jsonOptions = {}, parseBody = true) { - const format = getAcceptFormat(query); - const fullHeaders = { ...requestHeaders, accept: format }; - try { - const res = await this.bc.get(relativePath, removeFalsyOrEmpty(query), fullHeaders); - return HTTPClient.prepareResponse(res, format, parseBody, jsonOptions); - } - catch (err) { - throw HTTPClient.prepareResponseError(err); - } - } - /** - * Send a POST request. - * If no content-type present, adds the header "content-type: application/json" - * and data is serialized in JSON (if not empty) - */ - async post(relativePath, data, query, requestHeaders = {}, parseBody = true) { - const fullHeaders = { - 'content-type': 'application/json', - ...tolowerCaseKeys(requestHeaders), - }; - try { - const res = await this.bc.post(relativePath, HTTPClient.serializeData(data, fullHeaders), query, fullHeaders); - return HTTPClient.prepareResponse(res, 'application/json', parseBody); - } - catch (err) { - throw HTTPClient.prepareResponseError(err); - } - } - /** - * Send a DELETE request. - * If no content-type present, adds the header "content-type: application/json" - * and data is serialized in JSON (if not empty) - */ - async delete(relativePath, data, requestHeaders = {}, parseBody = true) { - const fullHeaders = { - 'content-type': 'application/json', - ...tolowerCaseKeys(requestHeaders), - }; - const res = await this.bc.delete(relativePath, HTTPClient.serializeData(data, fullHeaders), undefined, fullHeaders); - return HTTPClient.prepareResponse(res, 'application/json', parseBody); - } -} -exports.default = HTTPClient; diff --git a/algosdk/client/kmd.d.ts b/algosdk/client/kmd.d.ts deleted file mode 100644 index 3cc820e..0000000 --- a/algosdk/client/kmd.d.ts +++ /dev/null @@ -1,196 +0,0 @@ -import * as txn from '../transaction'; -import { CustomTokenHeader, KMDTokenHeader } from './urlTokenBaseHTTPClient'; -import ServiceClient from './v2/serviceClient'; -export default class Kmd extends ServiceClient { - constructor(token: string | KMDTokenHeader | CustomTokenHeader, baseServer?: string, port?: string | number, headers?: {}); - /** - * version returns a VersionResponse containing a list of kmd API versions supported by this running kmd instance. - */ - versions(): Promise; - /** - * listWallets returns a ListWalletsResponse containing the list of wallets known to kmd. Using a wallet ID - * returned from this endpoint, you can initialize a wallet handle with client.InitWalletHandle - */ - listWallets(): Promise; - /** - * createWallet creates a wallet with the specified name, password, driver, - * and master derivation key. If the master derivation key is blank, one is - * generated internally to kmd. CreateWallet returns a CreateWalletResponse - * containing information about the new wallet. - * @param walletName - * @param walletPassword - * @param walletDriverName - * @param walletMDK - */ - createWallet(walletName: string, walletPassword: string, walletMDK?: Uint8Array, walletDriverName?: string): Promise; - /** - * initWalletHandle accepts a wallet ID and a wallet password, and returns an - * initWalletHandleResponse containing a wallet handle token. This wallet - * handle token can be used for subsequent operations on this wallet, like key - * generation, transaction signing, etc.. WalletHandleTokens expire after a - * configurable number of seconds, and must be renewed periodically with - * RenewWalletHandle. It is good practice to call ReleaseWalletHandle when - * you're done interacting with this wallet. - * @param walletID - * @param walletPassword - */ - initWalletHandle(walletID: string, walletPassword: string): Promise; - /** - * releaseWalletHandle invalidates the passed wallet handle token, making - * it unusuable for subsequent wallet operations. - * @param walletHandle - */ - releaseWalletHandle(walletHandle: string): Promise; - /** - * renewWalletHandle accepts a wallet handle and attempts to renew it, moving - * the expiration time to some number of seconds in the future. It returns a - * RenewWalletHandleResponse containing the walletHandle and the number of - * seconds until expiration - * @param walletHandle - */ - renewWalletHandle(walletHandle: string): Promise; - /** - * renameWallet accepts a wallet ID, wallet password, and a new wallet name, - * and renames the underlying wallet. - * @param walletID - * @param walletPassword - * @param newWalletName - */ - renameWallet(walletID: string, walletPassword: string, newWalletName: string): Promise; - /** - * getWallet accepts a wallet handle and returns high level information about - * this wallet in a GetWalletResponse. - * @param walletHandle - */ - getWallet(walletHandle: string): Promise; - /** - * exportMasterDerivationKey accepts a wallet handle and a wallet password, and - * returns an ExportMasterDerivationKeyResponse containing the master - * derivation key. This key can be used as an argument to CreateWallet in - * order to recover the keys generated by this wallet. The master derivation - * key can be encoded as a sequence of words using the mnemonic library, and - * @param walletHandle - * @param walletPassword - */ - exportMasterDerivationKey(walletHandle: string, walletPassword: string): Promise<{ - master_derivation_key: Uint8Array; - }>; - /** - * importKey accepts a wallet handle and an ed25519 private key, and imports - * the key into the wallet. It returns an ImportKeyResponse containing the - * address corresponding to this private key. - * @param walletHandle - * @param secretKey - */ - importKey(walletHandle: string, secretKey: Uint8Array): Promise; - /** - * exportKey accepts a wallet handle, wallet password, and address, and returns - * an ExportKeyResponse containing the ed25519 private key corresponding to the - * address stored in the wallet. - * @param walletHandle - * @param walletPassword - * @param addr - */ - exportKey(walletHandle: string, walletPassword: string, addr: string): Promise<{ - private_key: Uint8Array; - }>; - /** - * generateKey accepts a wallet handle, and then generates the next key in the - * wallet using its internal master derivation key. Two wallets with the same - * master derivation key will generate the same sequence of keys. - * @param walletHandle - */ - generateKey(walletHandle: string): Promise; - /** - * deleteKey accepts a wallet handle, wallet password, and address, and deletes - * the information about this address from the wallet (including address and - * secret key). If DeleteKey is called on a key generated using GenerateKey, - * the same key will not be generated again. However, if a wallet is recovered - * using the master derivation key, a key generated in this way can be - * recovered. - * @param walletHandle - * @param walletPassword - * @param addr - */ - deleteKey(walletHandle: string, walletPassword: string, addr: string): Promise; - /** - * ListKeys accepts a wallet handle and returns a ListKeysResponse containing - * all of the addresses for which this wallet contains secret keys. - * @param walletHandle - */ - listKeys(walletHandle: string): Promise; - /** - * signTransaction accepts a wallet handle, wallet password, and a transaction, - * and returns and SignTransactionResponse containing an encoded, signed - * transaction. The transaction is signed using the key corresponding to the - * Sender field. - * @param walletHandle - * @param walletPassword - * @param transaction - */ - signTransaction(walletHandle: string, walletPassword: string, transaction: txn.TransactionLike): Promise; - /** - * signTransactionWithSpecificPublicKey accepts a wallet handle, wallet password, a transaction, and a public key, - * and returns and SignTransactionResponse containing an encoded, signed - * transaction. The transaction is signed using the key corresponding to the - * publicKey arg. - * @param walletHandle - * @param walletPassword - * @param transaction - * @param publicKey - sign the txn with the key corresponding to publicKey (used for working with a rekeyed addr) - */ - signTransactionWithSpecificPublicKey(walletHandle: string, walletPassword: string, transaction: txn.TransactionLike, publicKey: Uint8Array | string): Promise; - /** - * listMultisig accepts a wallet handle and returns a ListMultisigResponse - * containing the multisig addresses whose preimages are stored in this wallet. - * A preimage is the information needed to reconstruct this multisig address, - * including multisig version information, threshold information, and a list - * of public keys. - * @param walletHandle - */ - listMultisig(walletHandle: string): Promise; - /** - * importMultisig accepts a wallet handle and the information required to - * generate a multisig address. It derives this address, and stores all of the - * information within the wallet. It returns a ImportMultisigResponse with the - * derived address. - * @param walletHandle - * @param version - * @param threshold - * @param pks - */ - importMultisig(walletHandle: string, version: number, threshold: number, pks: string[]): Promise; - /** - * exportMultisig accepts a wallet handle, wallet password, and multisig - * address, and returns an ExportMultisigResponse containing the stored - * multisig preimage. The preimage contains all of the information necessary - * to derive the multisig address, including version, threshold, and a list of - * public keys. - * @param walletHandle - * @param walletPassword - * @param addr - */ - exportMultisig(walletHandle: string, addr: string): Promise; - /** - * signMultisigTransaction accepts a wallet handle, wallet password, - * transaction, public key (*not* an address), and an optional partial - * MultisigSig. It looks up the secret key corresponding to the public key, and - * returns a SignMultisigTransactionResponse containing a MultisigSig with a - * signature by the secret key included. - * @param walletHandle - * @param pw - * @param tx - * @param pk - * @param partial - */ - signMultisigTransaction(walletHandle: string, pw: string, transaction: txn.TransactionLike, pk: Uint8Array | string, partial: string): Promise; - /** - * deleteMultisig accepts a wallet handle, wallet password, and multisig - * address, and deletes the information about this multisig address from the - * wallet (including address and secret key). - * @param walletHandle - * @param walletPassword - * @param addr - */ - deleteMultisig(walletHandle: string, walletPassword: string, addr: string): Promise; -} diff --git a/algosdk/client/kmd.js b/algosdk/client/kmd.js deleted file mode 100644 index b1a8018..0000000 --- a/algosdk/client/kmd.js +++ /dev/null @@ -1,384 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const binarydata_1 = require("../encoding/binarydata"); -const txn = __importStar(require("../transaction")); -const serviceClient_1 = __importDefault(require("./v2/serviceClient")); -class Kmd extends serviceClient_1.default { - constructor(token, baseServer = 'http://127.0.0.1', port = 7833, headers = {}) { - super('X-KMD-API-Token', token, baseServer, port, headers); - } - /** - * version returns a VersionResponse containing a list of kmd API versions supported by this running kmd instance. - */ - async versions() { - const res = await this.c.get('/versions'); - return res.body; - } - /** - * listWallets returns a ListWalletsResponse containing the list of wallets known to kmd. Using a wallet ID - * returned from this endpoint, you can initialize a wallet handle with client.InitWalletHandle - */ - async listWallets() { - const res = await this.c.get('/v1/wallets'); - return res.body; - } - /** - * createWallet creates a wallet with the specified name, password, driver, - * and master derivation key. If the master derivation key is blank, one is - * generated internally to kmd. CreateWallet returns a CreateWalletResponse - * containing information about the new wallet. - * @param walletName - * @param walletPassword - * @param walletDriverName - * @param walletMDK - */ - async createWallet(walletName, walletPassword, walletMDK = new Uint8Array(), walletDriverName = 'sqlite') { - const req = { - wallet_name: walletName, - wallet_driver_name: walletDriverName, - wallet_password: walletPassword, - master_derivation_key: (0, binarydata_1.bytesToBase64)(walletMDK), - }; - const res = await this.c.post('/v1/wallet', req); - return res.body; - } - /** - * initWalletHandle accepts a wallet ID and a wallet password, and returns an - * initWalletHandleResponse containing a wallet handle token. This wallet - * handle token can be used for subsequent operations on this wallet, like key - * generation, transaction signing, etc.. WalletHandleTokens expire after a - * configurable number of seconds, and must be renewed periodically with - * RenewWalletHandle. It is good practice to call ReleaseWalletHandle when - * you're done interacting with this wallet. - * @param walletID - * @param walletPassword - */ - async initWalletHandle(walletID, walletPassword) { - const req = { - wallet_id: walletID, - wallet_password: walletPassword, - }; - const res = await this.c.post('/v1/wallet/init', req); - return res.body; - } - /** - * releaseWalletHandle invalidates the passed wallet handle token, making - * it unusuable for subsequent wallet operations. - * @param walletHandle - */ - async releaseWalletHandle(walletHandle) { - const req = { - wallet_handle_token: walletHandle, - }; - const res = await this.c.post('/v1/wallet/release', req); - return res.body; - } - /** - * renewWalletHandle accepts a wallet handle and attempts to renew it, moving - * the expiration time to some number of seconds in the future. It returns a - * RenewWalletHandleResponse containing the walletHandle and the number of - * seconds until expiration - * @param walletHandle - */ - async renewWalletHandle(walletHandle) { - const req = { - wallet_handle_token: walletHandle, - }; - const res = await this.c.post('/v1/wallet/renew', req); - return res.body; - } - /** - * renameWallet accepts a wallet ID, wallet password, and a new wallet name, - * and renames the underlying wallet. - * @param walletID - * @param walletPassword - * @param newWalletName - */ - async renameWallet(walletID, walletPassword, newWalletName) { - const req = { - wallet_id: walletID, - wallet_password: walletPassword, - wallet_name: newWalletName, - }; - const res = await this.c.post('/v1/wallet/rename', req); - return res.body; - } - /** - * getWallet accepts a wallet handle and returns high level information about - * this wallet in a GetWalletResponse. - * @param walletHandle - */ - async getWallet(walletHandle) { - const req = { - wallet_handle_token: walletHandle, - }; - const res = await this.c.post('/v1/wallet/info', req); - return res.body; - } - /** - * exportMasterDerivationKey accepts a wallet handle and a wallet password, and - * returns an ExportMasterDerivationKeyResponse containing the master - * derivation key. This key can be used as an argument to CreateWallet in - * order to recover the keys generated by this wallet. The master derivation - * key can be encoded as a sequence of words using the mnemonic library, and - * @param walletHandle - * @param walletPassword - */ - async exportMasterDerivationKey(walletHandle, walletPassword) { - const req = { - wallet_handle_token: walletHandle, - wallet_password: walletPassword, - }; - const res = await this.c.post('/v1/master-key/export', req); - return { - master_derivation_key: (0, binarydata_1.base64ToBytes)(res.body.master_derivation_key), - }; - } - /** - * importKey accepts a wallet handle and an ed25519 private key, and imports - * the key into the wallet. It returns an ImportKeyResponse containing the - * address corresponding to this private key. - * @param walletHandle - * @param secretKey - */ - async importKey(walletHandle, secretKey) { - const req = { - wallet_handle_token: walletHandle, - private_key: (0, binarydata_1.bytesToBase64)(secretKey), - }; - const res = await this.c.post('/v1/key/import', req); - return res.body; - } - /** - * exportKey accepts a wallet handle, wallet password, and address, and returns - * an ExportKeyResponse containing the ed25519 private key corresponding to the - * address stored in the wallet. - * @param walletHandle - * @param walletPassword - * @param addr - */ - async exportKey(walletHandle, walletPassword, addr) { - const req = { - wallet_handle_token: walletHandle, - address: addr, - wallet_password: walletPassword, - }; - const res = await this.c.post('/v1/key/export', req); - return { private_key: (0, binarydata_1.base64ToBytes)(res.body.private_key) }; - } - /** - * generateKey accepts a wallet handle, and then generates the next key in the - * wallet using its internal master derivation key. Two wallets with the same - * master derivation key will generate the same sequence of keys. - * @param walletHandle - */ - async generateKey(walletHandle) { - const req = { - wallet_handle_token: walletHandle, - display_mnemonic: false, - }; - const res = await this.c.post('/v1/key', req); - return res.body; - } - /** - * deleteKey accepts a wallet handle, wallet password, and address, and deletes - * the information about this address from the wallet (including address and - * secret key). If DeleteKey is called on a key generated using GenerateKey, - * the same key will not be generated again. However, if a wallet is recovered - * using the master derivation key, a key generated in this way can be - * recovered. - * @param walletHandle - * @param walletPassword - * @param addr - */ - async deleteKey(walletHandle, walletPassword, addr) { - const req = { - wallet_handle_token: walletHandle, - address: addr, - wallet_password: walletPassword, - }; - const res = await this.c.delete('/v1/key', req); - return res.body; - } - /** - * ListKeys accepts a wallet handle and returns a ListKeysResponse containing - * all of the addresses for which this wallet contains secret keys. - * @param walletHandle - */ - async listKeys(walletHandle) { - const req = { - wallet_handle_token: walletHandle, - }; - const res = await this.c.post('/v1/key/list', req); - return res.body; - } - /** - * signTransaction accepts a wallet handle, wallet password, and a transaction, - * and returns and SignTransactionResponse containing an encoded, signed - * transaction. The transaction is signed using the key corresponding to the - * Sender field. - * @param walletHandle - * @param walletPassword - * @param transaction - */ - async signTransaction(walletHandle, walletPassword, transaction) { - const tx = txn.instantiateTxnIfNeeded(transaction); - const req = { - wallet_handle_token: walletHandle, - wallet_password: walletPassword, - transaction: (0, binarydata_1.bytesToBase64)(tx.toByte()), - }; - const res = await this.c.post('/v1/transaction/sign', req); - if (res.status === 200) { - return (0, binarydata_1.base64ToBytes)(res.body.signed_transaction); - } - return res.body; - } - /** - * signTransactionWithSpecificPublicKey accepts a wallet handle, wallet password, a transaction, and a public key, - * and returns and SignTransactionResponse containing an encoded, signed - * transaction. The transaction is signed using the key corresponding to the - * publicKey arg. - * @param walletHandle - * @param walletPassword - * @param transaction - * @param publicKey - sign the txn with the key corresponding to publicKey (used for working with a rekeyed addr) - */ - async signTransactionWithSpecificPublicKey(walletHandle, walletPassword, transaction, publicKey) { - const tx = txn.instantiateTxnIfNeeded(transaction); - const pk = (0, binarydata_1.coerceToBytes)(publicKey); - const req = { - wallet_handle_token: walletHandle, - wallet_password: walletPassword, - transaction: (0, binarydata_1.bytesToBase64)(tx.toByte()), - public_key: (0, binarydata_1.bytesToBase64)(pk), - }; - const res = await this.c.post('/v1/transaction/sign', req); - if (res.status === 200) { - return (0, binarydata_1.base64ToBytes)(res.body.signed_transaction); - } - return res.body; - } - /** - * listMultisig accepts a wallet handle and returns a ListMultisigResponse - * containing the multisig addresses whose preimages are stored in this wallet. - * A preimage is the information needed to reconstruct this multisig address, - * including multisig version information, threshold information, and a list - * of public keys. - * @param walletHandle - */ - async listMultisig(walletHandle) { - const req = { - wallet_handle_token: walletHandle, - }; - const res = await this.c.post('/v1/multisig/list', req); - return res.body; - } - /** - * importMultisig accepts a wallet handle and the information required to - * generate a multisig address. It derives this address, and stores all of the - * information within the wallet. It returns a ImportMultisigResponse with the - * derived address. - * @param walletHandle - * @param version - * @param threshold - * @param pks - */ - async importMultisig(walletHandle, version, threshold, pks) { - const req = { - wallet_handle_token: walletHandle, - multisig_version: version, - threshold, - pks, - }; - const res = await this.c.post('/v1/multisig/import', req); - return res.body; - } - /** - * exportMultisig accepts a wallet handle, wallet password, and multisig - * address, and returns an ExportMultisigResponse containing the stored - * multisig preimage. The preimage contains all of the information necessary - * to derive the multisig address, including version, threshold, and a list of - * public keys. - * @param walletHandle - * @param walletPassword - * @param addr - */ - async exportMultisig(walletHandle, addr) { - const req = { - wallet_handle_token: walletHandle, - address: addr, - }; - const res = await this.c.post('/v1/multisig/export', req); - return res.body; - } - /** - * signMultisigTransaction accepts a wallet handle, wallet password, - * transaction, public key (*not* an address), and an optional partial - * MultisigSig. It looks up the secret key corresponding to the public key, and - * returns a SignMultisigTransactionResponse containing a MultisigSig with a - * signature by the secret key included. - * @param walletHandle - * @param pw - * @param tx - * @param pk - * @param partial - */ - async signMultisigTransaction(walletHandle, pw, transaction, pk, partial) { - const tx = txn.instantiateTxnIfNeeded(transaction); - const pubkey = (0, binarydata_1.coerceToBytes)(pk); - const req = { - wallet_handle_token: walletHandle, - transaction: (0, binarydata_1.bytesToBase64)(tx.toByte()), - public_key: (0, binarydata_1.bytesToBase64)(pubkey), - partial_multisig: partial, - wallet_password: pw, - }; - const res = await this.c.post('/v1/multisig/sign', req); - return res.body; - } - /** - * deleteMultisig accepts a wallet handle, wallet password, and multisig - * address, and deletes the information about this multisig address from the - * wallet (including address and secret key). - * @param walletHandle - * @param walletPassword - * @param addr - */ - async deleteMultisig(walletHandle, walletPassword, addr) { - const req = { - wallet_handle_token: walletHandle, - address: addr, - wallet_password: walletPassword, - }; - const res = await this.c.delete('/v1/multisig', req); - return res.body; - } -} -exports.default = Kmd; diff --git a/algosdk/client/urlTokenBaseHTTPClient.d.ts b/algosdk/client/urlTokenBaseHTTPClient.d.ts deleted file mode 100644 index ca289ee..0000000 --- a/algosdk/client/urlTokenBaseHTTPClient.d.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { BaseHTTPClient, BaseHTTPClientResponse, Query } from './baseHTTPClient'; -export interface AlgodTokenHeader { - 'X-Algo-API-Token': string; -} -export interface IndexerTokenHeader { - 'X-Indexer-API-Token': string; -} -export interface KMDTokenHeader { - 'X-KMD-API-Token': string; -} -export interface CustomTokenHeader { - [headerName: string]: string; -} -export declare type TokenHeader = AlgodTokenHeader | IndexerTokenHeader | KMDTokenHeader | CustomTokenHeader; -/** - * Implementation of BaseHTTPClient that uses a URL and a token - * and make the REST queries using fetch. - * This is the default implementation of BaseHTTPClient. - */ -export declare class URLTokenBaseHTTPClient implements BaseHTTPClient { - private defaultHeaders; - private readonly baseURL; - private readonly tokenHeader; - constructor(tokenHeader: TokenHeader, baseServer: string, port?: string | number, defaultHeaders?: Record); - /** - * Compute the URL for a path relative to the instance's address - * @param relativePath - A path string - * @param query - An optional key-value object of query parameters to add to the URL. If the - * relativePath already has query parameters on it, the additional parameters defined here will - * be added to the URL without modifying those (unless a key collision occurs). - * @returns A URL string - */ - private getURL; - private static formatFetchResponseHeaders; - private static checkHttpError; - private static formatFetchResponse; - get(relativePath: string, query?: Query, requestHeaders?: Record): Promise; - post(relativePath: string, data: Uint8Array, query?: Query, requestHeaders?: Record): Promise; - delete(relativePath: string, data: Uint8Array, query?: Query, requestHeaders?: Record): Promise; -} diff --git a/algosdk/client/urlTokenBaseHTTPClient.js b/algosdk/client/urlTokenBaseHTTPClient.js deleted file mode 100644 index 10be5df..0000000 --- a/algosdk/client/urlTokenBaseHTTPClient.js +++ /dev/null @@ -1,145 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.URLTokenBaseHTTPClient = void 0; -class URLTokenBaseHTTPError extends Error { - constructor(message, response) { - super(message); - this.response = response; - this.name = 'URLTokenBaseHTTPError'; - this.response = response; - } -} -/** - * Implementation of BaseHTTPClient that uses a URL and a token - * and make the REST queries using fetch. - * This is the default implementation of BaseHTTPClient. - */ -class URLTokenBaseHTTPClient { - constructor(tokenHeader, baseServer, port, defaultHeaders = {}) { - this.defaultHeaders = defaultHeaders; - // Append a trailing slash so we can use relative paths. Without the trailing - // slash, the last path segment will be replaced by the relative path. See - // usage in `addressWithPath`. - const fixedBaseServer = baseServer.endsWith('/') - ? baseServer - : `${baseServer}/`; - const baseServerURL = new URL(fixedBaseServer); - if (typeof port !== 'undefined') { - baseServerURL.port = port.toString(); - } - if (baseServerURL.protocol.length === 0) { - throw new Error('Invalid base server URL, protocol must be defined.'); - } - this.baseURL = baseServerURL; - this.tokenHeader = tokenHeader; - } - /** - * Compute the URL for a path relative to the instance's address - * @param relativePath - A path string - * @param query - An optional key-value object of query parameters to add to the URL. If the - * relativePath already has query parameters on it, the additional parameters defined here will - * be added to the URL without modifying those (unless a key collision occurs). - * @returns A URL string - */ - getURL(relativePath, query) { - let fixedRelativePath; - if (relativePath.startsWith('./')) { - fixedRelativePath = relativePath; - } - else if (relativePath.startsWith('/')) { - fixedRelativePath = `.${relativePath}`; - } - else { - fixedRelativePath = `./${relativePath}`; - } - const address = new URL(fixedRelativePath, this.baseURL); - if (query) { - for (const [key, value] of Object.entries(query)) { - address.searchParams.set(key, value); - } - } - return address.toString(); - } - static formatFetchResponseHeaders(headers) { - const headersObj = {}; - headers.forEach((key, value) => { - headersObj[key] = value; - }); - return headersObj; - } - static async checkHttpError(res) { - if (res.ok) { - return; - } - let body = null; - let bodyErrorMessage = null; - try { - body = new Uint8Array(await res.arrayBuffer()); - const decoded = JSON.parse(new TextDecoder().decode(body)); - if (decoded.message) { - bodyErrorMessage = decoded.message; - } - } - catch (_) { - // ignore any error that happened while we are parsing the error response - } - let message = `Network request error. Received status ${res.status} (${res.statusText})`; - if (bodyErrorMessage) { - message += `: ${bodyErrorMessage}`; - } - throw new URLTokenBaseHTTPError(message, { - body, - status: res.status, - headers: URLTokenBaseHTTPClient.formatFetchResponseHeaders(res.headers), - }); - } - static async formatFetchResponse(res) { - await this.checkHttpError(res); - return { - body: new Uint8Array(await res.arrayBuffer()), - status: res.status, - headers: URLTokenBaseHTTPClient.formatFetchResponseHeaders(res.headers), - }; - } - async get(relativePath, query, requestHeaders = {}) { - // Expand headers for use in fetch - const headers = { - ...this.tokenHeader, - ...this.defaultHeaders, - ...requestHeaders, - }; - const res = await fetch(this.getURL(relativePath, query), { - headers, - }); - return URLTokenBaseHTTPClient.formatFetchResponse(res); - } - async post(relativePath, data, query, requestHeaders = {}) { - // Expand headers for use in fetch - const headers = { - ...this.tokenHeader, - ...this.defaultHeaders, - ...requestHeaders, - }; - const res = await fetch(this.getURL(relativePath, query), { - method: 'POST', - body: data, - headers, - }); - return URLTokenBaseHTTPClient.formatFetchResponse(res); - } - async delete(relativePath, data, query, requestHeaders = {}) { - // Expand headers for use in fetch - const headers = { - ...this.tokenHeader, - ...this.defaultHeaders, - ...requestHeaders, - }; - const res = await fetch(this.getURL(relativePath, query), { - method: 'DELETE', - body: data, - headers, - }); - return URLTokenBaseHTTPClient.formatFetchResponse(res); - } -} -exports.URLTokenBaseHTTPClient = URLTokenBaseHTTPClient; diff --git a/algosdk/client/v2/algod/accountApplicationInformation.d.ts b/algosdk/client/v2/algod/accountApplicationInformation.d.ts deleted file mode 100644 index be6b2dd..0000000 --- a/algosdk/client/v2/algod/accountApplicationInformation.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; -import { AccountApplicationResponse } from './models/types'; -export default class AccountApplicationInformation extends JSONRequest> { - private account; - private applicationID; - constructor(c: HTTPClient, intDecoding: IntDecoding, account: string, applicationID: number); - path(): string; - prepare(body: Record): AccountApplicationResponse; -} diff --git a/algosdk/client/v2/algod/accountApplicationInformation.js b/algosdk/client/v2/algod/accountApplicationInformation.js deleted file mode 100644 index a238eaf..0000000 --- a/algosdk/client/v2/algod/accountApplicationInformation.js +++ /dev/null @@ -1,24 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -const types_1 = require("./models/types"); -class AccountApplicationInformation extends jsonrequest_1.default { - constructor(c, intDecoding, account, applicationID) { - super(c, intDecoding); - this.account = account; - this.applicationID = applicationID; - this.account = account; - this.applicationID = applicationID; - } - path() { - return `/v2/accounts/${this.account}/applications/${this.applicationID}`; - } - // eslint-disable-next-line class-methods-use-this - prepare(body) { - return types_1.AccountApplicationResponse.from_obj_for_encoding(body); - } -} -exports.default = AccountApplicationInformation; diff --git a/algosdk/client/v2/algod/accountAssetInformation.d.ts b/algosdk/client/v2/algod/accountAssetInformation.d.ts deleted file mode 100644 index ade3b19..0000000 --- a/algosdk/client/v2/algod/accountAssetInformation.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; -import { AccountAssetResponse } from './models/types'; -export default class AccountAssetInformation extends JSONRequest> { - private account; - private assetID; - constructor(c: HTTPClient, intDecoding: IntDecoding, account: string, assetID: number); - path(): string; - prepare(body: Record): AccountAssetResponse; -} diff --git a/algosdk/client/v2/algod/accountAssetInformation.js b/algosdk/client/v2/algod/accountAssetInformation.js deleted file mode 100644 index 72df0f9..0000000 --- a/algosdk/client/v2/algod/accountAssetInformation.js +++ /dev/null @@ -1,24 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -const types_1 = require("./models/types"); -class AccountAssetInformation extends jsonrequest_1.default { - constructor(c, intDecoding, account, assetID) { - super(c, intDecoding); - this.account = account; - this.assetID = assetID; - this.account = account; - this.assetID = assetID; - } - path() { - return `/v2/accounts/${this.account}/assets/${this.assetID}`; - } - // eslint-disable-next-line class-methods-use-this - prepare(body) { - return types_1.AccountAssetResponse.from_obj_for_encoding(body); - } -} -exports.default = AccountAssetInformation; diff --git a/algosdk/client/v2/algod/accountInformation.d.ts b/algosdk/client/v2/algod/accountInformation.d.ts deleted file mode 100644 index 350a120..0000000 --- a/algosdk/client/v2/algod/accountInformation.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; -import { Account } from './models/types'; -export default class AccountInformation extends JSONRequest> { - private account; - constructor(c: HTTPClient, intDecoding: IntDecoding, account: string); - path(): string; - /** - * Exclude assets and application data from results - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountInfo = await algodClient.accountInformation(address) - * .exclude('all') - * .do(); - * ``` - * - * @param round - * @category query - */ - exclude(exclude: string): this; - prepare(body: Record): Account; -} diff --git a/algosdk/client/v2/algod/accountInformation.js b/algosdk/client/v2/algod/accountInformation.js deleted file mode 100644 index 250c169..0000000 --- a/algosdk/client/v2/algod/accountInformation.js +++ /dev/null @@ -1,40 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -const types_1 = require("./models/types"); -class AccountInformation extends jsonrequest_1.default { - constructor(c, intDecoding, account) { - super(c, intDecoding); - this.account = account; - this.account = account; - } - path() { - return `/v2/accounts/${this.account}`; - } - /** - * Exclude assets and application data from results - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountInfo = await algodClient.accountInformation(address) - * .exclude('all') - * .do(); - * ``` - * - * @param round - * @category query - */ - exclude(exclude) { - this.query.exclude = exclude; - return this; - } - // eslint-disable-next-line class-methods-use-this - prepare(body) { - return types_1.Account.from_obj_for_encoding(body); - } -} -exports.default = AccountInformation; diff --git a/algosdk/client/v2/algod/algod.d.ts b/algosdk/client/v2/algod/algod.d.ts deleted file mode 100644 index 0ca27b3..0000000 --- a/algosdk/client/v2/algod/algod.d.ts +++ /dev/null @@ -1,665 +0,0 @@ -import ServiceClient from '../serviceClient'; -import * as modelsv2 from './models/types'; -import AccountInformation from './accountInformation'; -import AccountAssetInformation from './accountAssetInformation'; -import AccountApplicationInformation from './accountApplicationInformation'; -import Block from './block'; -import Compile from './compile'; -import Dryrun from './dryrun'; -import Genesis from './genesis'; -import GetAssetByID from './getAssetByID'; -import GetApplicationByID from './getApplicationByID'; -import GetBlockHash from './getBlockHash'; -import GetBlockTxids from './getBlockTxids'; -import GetApplicationBoxByName from './getApplicationBoxByName'; -import GetApplicationBoxes from './getApplicationBoxes'; -import HealthCheck from './healthCheck'; -import PendingTransactionInformation from './pendingTransactionInformation'; -import PendingTransactions from './pendingTransactions'; -import PendingTransactionsByAddress from './pendingTransactionsByAddress'; -import GetTransactionProof from './getTransactionProof'; -import SendRawTransaction from './sendRawTransaction'; -import Status from './status'; -import StatusAfterBlock from './statusAfterBlock'; -import SuggestedParams from './suggestedParams'; -import Supply from './supply'; -import Versions from './versions'; -import { BaseHTTPClient } from '../../baseHTTPClient'; -import { AlgodTokenHeader, CustomTokenHeader } from '../../urlTokenBaseHTTPClient'; -import LightBlockHeaderProof from './lightBlockHeaderProof'; -import StateProof from './stateproof'; -import SetSyncRound from './setSyncRound'; -import GetSyncRound from './getSyncRound'; -import SetBlockOffsetTimestamp from './setBlockOffsetTimestamp'; -import GetBlockOffsetTimestamp from './getBlockOffsetTimestamp'; -import Disassemble from './disassemble'; -import SimulateRawTransactions from './simulateTransaction'; -import Ready from './ready'; -import UnsetSyncRound from './unsetSyncRound'; -import GetLedgerStateDeltaForTransactionGroup from './getLedgerStateDeltaForTransactionGroup'; -import GetLedgerStateDelta from './getLedgerStateDelta'; -import GetTransactionGroupLedgerStateDeltasForRound from './getTransactionGroupLedgerStateDeltasForRound'; -/** - * Algod client connects an application to the Algorand blockchain. The algod client requires a valid algod REST endpoint IP address and algod token from an Algorand node that is connected to the network you plan to interact with. - * - * Algod is the main Algorand process for handling the blockchain. Messages between nodes are processed, the protocol steps are executed, and the blocks are written to disk. The algod process also exposes a REST API server that developers can use to communicate with the node and the network. Algod uses the data directory for storage and configuration information. - * - * #### Relevant Information - * [How do I obtain an algod address and token?](https://developer.algorand.org/docs/archive/build-apps/setup/?from_query=algod#how-do-i-obtain-an-algod-address-and-token) - * - * [Run Algod in Postman OAS3](https://developer.algorand.org/docs/rest-apis/restendpoints/?from_query=algod#algod-indexer-and-kmd-rest-endpoints) - */ -export default class AlgodClient extends ServiceClient { - /** - * Create an AlgodClient from - * * either a token, baseServer, port, and optional headers - * * or a base client server for interoperability with external dApp wallets - * - * #### Example - * ```typescript - * const token = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; - * const server = "http://localhost"; - * const port = 4001; - * const algodClient = new algosdk.Algodv2(token, server, port); - * ``` - * @remarks - * The above configuration is for a sandbox private network. - * For applications on production, you are encouraged to run your own node, or use an Algorand REST API provider with a dedicated API key. - * - * @param tokenOrBaseClient - The algod token from the Algorand node you are interacting with - * @param baseServer - REST endpoint - * @param port - Port number if specifically configured by the server - * @param headers - Optional headers - */ - constructor(tokenOrBaseClient: string | AlgodTokenHeader | CustomTokenHeader | BaseHTTPClient, baseServer: string, port?: string | number, headers?: Record); - /** - * Returns OK if healthy. - * - * #### Example - * ```typescript - * const health = await algodClient.healthCheck().do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-health) - * @category GET - */ - healthCheck(): HealthCheck; - /** - * Retrieves the supported API versions, binary build versions, and genesis information. - * - * #### Example - * ```typescript - * const versionsDetails = await algodClient.versionsCheck().do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-versions) - * @category GET - */ - versionsCheck(): Versions; - /** - * Broadcasts a raw transaction to the network. - * - * #### Example - * ```typescript - * const { txId } = await algodClient.sendRawTransaction(signedTxns).do(); - * const result = await waitForConfirmation(algodClient, txid, 3); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#post-v2transactions) - * - * @remarks - * Often used with {@linkcode waitForConfirmation} - * @param stxOrStxs - Signed transactions - * @category POST - */ - sendRawTransaction(stxOrStxs: Uint8Array | Uint8Array[]): SendRawTransaction; - /** - * Returns the given account's status, balance and spendable amounts. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountInfo = await algodClient.accountInformation(address).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2accountsaddress) - * @param account - The address of the account to look up. - * @category GET - */ - accountInformation(account: string): AccountInformation; - /** - * Returns the given account's asset information for a specific asset. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const index = 60553466; - * const accountAssetInfo = await algodClient.accountAssetInformation(address, index).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2accountsaddress) - * @param account - The address of the account to look up. - * @param index - The asset ID to look up. - * @category GET - */ - accountAssetInformation(account: string, index: number): AccountAssetInformation; - /** - * Returns the given account's application information for a specific application. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const index = 60553466; - * const accountInfo = await algodClient.accountApplicationInformation(address, index).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2accountsaddress) - * @param account - The address of the account to look up. - * @param index - The application ID to look up. - * @category GET - */ - accountApplicationInformation(account: string, index: number): AccountApplicationInformation; - /** - * Gets the block info for the given round. - * - * #### Example - * ```typescript - * const roundNumber = 18038133; - * const block = await algodClient.block(roundNumber).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2blocksround) - * @param roundNumber - The round number of the block to get. - * @category GET - */ - block(roundNumber: number): Block; - /** - * Get the block hash for the block on the given round. - * - * #### Example - * ```typescript - * const roundNumber = 18038133; - * const block = await algodClient.getBlockHash(roundNumber).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2blocksroundhash) - * @param roundNumber - The round number of the block to get. - * @category GET - */ - getBlockHash(roundNumber: number): GetBlockHash; - /** - * Get the top level transaction IDs for the block on the given round. - * - * #### Example - * ```typescript - * const roundNumber = 18038133; - * const block = await algodClient.getBlockTxids(roundNumber).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2blocksroundtxids) - * @param roundNumber - The round number of the block to get. - * @category GET - */ - getBlockTxids(roundNumber: number): GetBlockTxids; - /** - * Returns the transaction information for a specific pending transaction. - * - * #### Example - * ```typescript - * const txId = "DRJS6R745A7GFVMXEXWP4TGVDGKW7VILFTA7HC2BR2GRLHNY5CTA"; - * const pending = await algodClient.pendingTransactionInformation(txId).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2transactionspendingtxid) - * - * @remarks - *

- * There are several cases when this might succeed: - * - transaction committed (committed round > 0) - * - transaction still in the pool (committed round = 0, pool error = "") - * - transaction removed from pool due to error (committed round = 0, pool error != "") - * - * Or the transaction may have happened sufficiently long ago that the node no longer remembers it, and this will return an error. - * - * @param txid - The TxID string of the pending transaction to look up. - * @category GET - */ - pendingTransactionInformation(txid: string): PendingTransactionInformation; - /** - * Returns the list of pending transactions in the pool, sorted by priority, in decreasing order, truncated at the end at MAX. - * If MAX = 0, returns all pending transactions. - * - * #### Example 1 - * ```typescript - * const pendingTxns = await algodClient.pendingTransactionsInformation().do(); - * ``` - * - * #### Example 2 - * ```typescript - * const maxTxns = 5; - * const pendingTxns = await algodClient - * .pendingTransactionsInformation() - * .max(maxTxns) - * .do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2transactionspending) - * @category GET - */ - pendingTransactionsInformation(): PendingTransactions; - /** - * Returns the list of pending transactions sent by the address, sorted by priority, in decreasing order, truncated at the end at MAX. - * If MAX = 0, returns all pending transactions. - * - * #### Example 1 - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const pendingTxnsByAddr = await algodClient.pendingTransactionByAddress(address).do(); - * ``` - * - * #### Example 2 - * ```typescript - * const maxTxns = 5; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const pendingTxns = await algodClient - * .pendingTransactionByAddress(address) - * .max(maxTxns) - * .do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2accountsaddresstransactionspending) - * @param address - The address of the sender. - * @category GET - */ - pendingTransactionByAddress(address: string): PendingTransactionsByAddress; - /** - * Retrieves the StatusResponse from the running node. - * - * #### Example - * ```typescript - * const status = await algodClient.status().do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2status) - * @category GET - */ - status(): Status; - /** - * Waits for a specific round to occur then returns the `StatusResponse` for that round. - * - * #### Example - * ```typescript - * const round = 18038133; - * const statusAfterBlock = await algodClient.statusAfterBlock(round).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2statuswait-for-block-afterround) - * @param round - The number of the round to wait for. - * @category GET - */ - statusAfterBlock(round: number): StatusAfterBlock; - /** - * Returns the common needed parameters for a new transaction. - * - * #### Example - * ```typescript - * const suggestedParams = await algodClient.getTransactionParams().do(); - * const amountInMicroAlgos = algosdk.algosToMicroalgos(2); // 2 Algos - * const unsignedTxn = algosdk.makePaymentTxnWithSuggestedParamsFromObject({ - * sender: senderAddress, - * receiver: receiverAddress, - * amount: amountInMicroAlgos, - * suggestedParams: suggestedParams, - * }); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2transactionsparams) - * - * @remarks - * Often used with - * {@linkcode makePaymentTxnWithSuggestedParamsFromObject}, {@linkcode algosToMicroalgos} - * @category GET - */ - getTransactionParams(): SuggestedParams; - /** - * Returns the supply details for the specified node's ledger. - * - * #### Example - * ```typescript - * const supplyDetails = await algodClient.supply().do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2ledgersupply) - * @category GET - */ - supply(): Supply; - /** - * Compiles TEAL source code to binary, returns base64 encoded program bytes and base32 SHA512_256 hash of program bytes (Address style). - * - * #### Example - * ```typescript - * const source = "TEAL SOURCE CODE"; - * const compiledSmartContract = await algodClient.compile(source).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#post-v2tealcompile) - * @remarks - * This endpoint is only enabled when a node's configuration file sets `EnableDeveloperAPI` to true. - * @param source - * @category POST - */ - compile(source: string | Uint8Array): Compile; - /** - * Given the program bytes, return the TEAL source code in plain text. - * - * #### Example - * ```typescript - * const bytecode = "TEAL bytecode"; - * const disassembledSource = await algodClient.disassemble(bytecode).do(); - * ``` - * - * @remarks This endpoint is only enabled when a node's configuration file sets EnableDeveloperAPI to true. - * @param source - */ - disassemble(source: string | Uint8Array): Disassemble; - /** - * Provides debugging information for a transaction (or group). - * - * Executes TEAL program(s) in context and returns debugging information about the execution. This endpoint is only enabled when a node's configureation file sets `EnableDeveloperAPI` to true. - * - * #### Example - * ```typescript - * const dryRunResult = await algodClient.dryrun(dr).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#post-v2tealdryrun) - * @param dr - * @category POST - */ - dryrun(dr: modelsv2.DryrunRequest): Dryrun; - /** - * Given an asset ID, return asset information including creator, name, total supply and - * special addresses. - * - * #### Example - * ```typescript - * const asset_id = 163650; - * const asset = await algodClient.getAssetByID(asset_id).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2assetsasset-id) - * @param index - The asset ID to look up. - * @category GET - */ - getAssetByID(index: number): GetAssetByID; - /** - * Given an application ID, return the application information including creator, approval - * and clear programs, global and local schemas, and global state. - * - * #### Example - * ```typescript - * const index = 60553466; - * const app = await algodClient.getApplicationByID(index).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2applicationsapplication-id) - * @param index - The application ID to look up. - * @category GET - */ - getApplicationByID(index: number): GetApplicationByID; - /** - * Given an application ID and the box name (key), return the value stored in the box. - * - * #### Example - * ```typescript - * const index = 60553466; - * const boxName = Buffer.from("foo"); - * const boxResponse = await algodClient.getApplicationBoxByName(index, boxName).do(); - * const boxValue = boxResponse.value; - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2applicationsapplication-idbox) - * @param index - The application ID to look up. - * @category GET - */ - getApplicationBoxByName(index: number, boxName: Uint8Array): GetApplicationBoxByName; - /** - * Given an application ID, return all the box names associated with the app. - * - * #### Example - * ```typescript - * const index = 60553466; - * const boxesResponse = await algodClient.getApplicationBoxes(index).max(3).do(); - * const boxNames = boxesResponse.boxes.map(box => box.name); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2applicationsapplication-idboxes) - * @param index - The application ID to look up. - * @category GET - */ - getApplicationBoxes(index: number): GetApplicationBoxes; - /** - * Returns the entire genesis file. - * - * #### Example - * ```typescript - * const genesis = await algodClient.genesis().do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-genesis) - * @category GET - */ - genesis(): Genesis; - /** - * Returns a Merkle proof for a given transaction in a block. - * - * #### Example - * ```typescript - * const round = 18038133; - * const txId = "MEUOC4RQJB23CQZRFRKYEI6WBO73VTTPST5A7B3S5OKBUY6LFUDA"; - * const proof = await algodClient.getTransactionProof(round, txId).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2blocksroundtransactionstxidproof) - * @param round - The round in which the transaction appears. - * @param txID - The transaction ID for which to generate a proof. - * @category GET - */ - getTransactionProof(round: number, txID: string): GetTransactionProof; - /** - * Gets a proof for a given light block header inside a state proof commitment. - * - * #### Example - * ```typescript - * const round = 11111111; - * const lightBlockHeaderProof = await algodClient.getLightBlockHeaderProof(round).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/v2#get-v2blocksroundlightheaderproof) - * @param round - */ - getLightBlockHeaderProof(round: number): LightBlockHeaderProof; - /** - * Gets a state proof that covers a given round. - * - * #### Example - * ```typescript - * const round = 11111111; - * const stateProof = await algodClient.getStateProof(round).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/v2#get-v2stateproofsround) - * @param round - */ - getStateProof(round: number): StateProof; - /** - * Simulate a list of a signed transaction objects being sent to the network. - * - * #### Example - * ```typescript - * const txn1 = algosdk.makePaymentTxnWithSuggestedParamsFromObject(txn1Params); - * const txn2 = algosdk.makePaymentTxnWithSuggestedParamsFromObject(txn2Params); - * const txgroup = algosdk.assignGroupID([txn1, txn2]); - * - * // Actually sign the first transaction - * const signedTxn1 = txgroup[0].signTxn(senderSk).blob; - * // Simulate does not require signed transactions -- use this method to encode an unsigned transaction - * const signedTxn2 = algosdk.encodeUnsignedSimulateTransaction(txgroup[1]); - * - * const resp = await client.simulateRawTransactions([signedTxn1, signedTxn2]).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#post-v2transactionssimulate) - * @param stxOrStxs - * @category POST - */ - simulateRawTransactions(stxOrStxs: Uint8Array | Uint8Array[]): SimulateRawTransactions; - /** - * Simulate transactions being sent to the network. - * - * #### Example - * ```typescript - * const txn1 = algosdk.makePaymentTxnWithSuggestedParamsFromObject(txn1Params); - * const txn2 = algosdk.makePaymentTxnWithSuggestedParamsFromObject(txn2Params); - * const txgroup = algosdk.assignGroupID([txn1, txn2]); - * - * // Actually sign the first transaction - * const signedTxn1 = txgroup[0].signTxn(senderSk).blob; - * // Simulate does not require signed transactions -- use this method to encode an unsigned transaction - * const signedTxn2 = algosdk.encodeUnsignedSimulateTransaction(txgroup[1]); - * - * const request = new modelsv2.SimulateRequest({ - * txnGroups: [ - * new modelsv2.SimulateRequestTransactionGroup({ - * // Must decode the signed txn bytes into an object - * txns: [algosdk.decodeObj(signedTxn1), algosdk.decodeObj(signedTxn2)] - * }), - * ], - * }); - * const resp = await client.simulateRawTransactions(request).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#post-v2transactionssimulate) - * @param request - * @category POST - */ - simulateTransactions(request: modelsv2.SimulateRequest): SimulateRawTransactions; - /** - * Set the offset (in seconds) applied to the block timestamp when creating new blocks in devmode. - * - * #### Example - * ```typesecript - * const offset = 60 - * await client.setBlockOffsetTimestamp(offset).do(); - * ``` - * - [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#post-v2devmodeblocksoffsetoffset) - * @param offset - * @category POST - */ - setBlockOffsetTimestamp(offset: number): SetBlockOffsetTimestamp; - /** - * Get the offset (in seconds) applied to the block timestamp when creating new blocks in devmode. - * - * #### Example - * ```typesecript - * const currentOffset = await client.getBlockOffsetTimestamp().do(); - * ``` - * - [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2devmodeblocksoffset) - * @category GET - */ - getBlockOffsetTimestamp(): GetBlockOffsetTimestamp; - /** - * Set the sync round on the ledger (algod must have EnableFollowMode: true), restricting catchup. - * - * #### Example - * ```typesecript - * const round = 10000 - * await client.setSyncRound(round).do(); - * ``` - * - [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#post-v2ledgersyncround) - * @param round - * @category POST - */ - setSyncRound(round: number): SetSyncRound; - /** - * Un-Set the sync round on the ledger (algod must have EnableFollowMode: true), removing the restriction on catchup. - * - * #### Example - * ```typesecript - * await client.unsetSyncRound().do(); - * ``` - * - [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#delete-v2ledgersync) - * @category DELETE - */ - unsetSyncRound(): UnsetSyncRound; - /** - * Get the current sync round on the ledger (algod must have EnableFollowMode: true). - * - * #### Example - * ```typesecript - * const currentSyncRound = await client.getSyncRound().do(); - * ``` - * - [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2ledgersync) - * @category GET - */ - getSyncRound(): GetSyncRound; - /** - * Ready check which returns 200 OK if algod is healthy and caught up - * - * #### Example - * ```typesecript - * await client.ready().do(); - * ``` - * - [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-ready) - * @category GET - */ - ready(): Ready; - /** - * GetLedgerStateDeltaForTransactionGroup returns the ledger delta for the txn group identified by id - * - * #### Example - * ```typescript - * const id = "ABC123"; - * await client.getLedgerStateDeltaForTransactionGroup(id).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2deltastxngroupid) - * @param id txn ID or group ID to be searched for - * @category GET - */ - getLedgerStateDeltaForTransactionGroup(id: string): GetLedgerStateDeltaForTransactionGroup; - /** - * GetLedgerStateDelta returns the ledger delta for the entire round - * - * #### Example - * ```typescript - * const round = 12345; - * await client.getLedgerStateDelta(round).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2deltasround) - * @param round the round number to be searched for - * @category GET - */ - getLedgerStateDelta(round: number): GetLedgerStateDelta; - /** - * GetTransactionGroupLedgerStateDeltasForRound returns all ledger deltas for txn groups in the provided round - * - * #### Example - * ```typescript - * const round = 12345; - * await client.getTransactionGroupLedgerStateDeltasForRound(round).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2deltasroundtxngroup) - * @param round the round number to be searched for - * @category GET - */ - getTransactionGroupLedgerStateDeltasForRound(round: number): GetTransactionGroupLedgerStateDeltasForRound; -} diff --git a/algosdk/client/v2/algod/algod.js b/algosdk/client/v2/algod/algod.js deleted file mode 100644 index 1de9067..0000000 --- a/algosdk/client/v2/algod/algod.js +++ /dev/null @@ -1,787 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const serviceClient_1 = __importDefault(require("../serviceClient")); -const modelsv2 = __importStar(require("./models/types")); -const accountInformation_1 = __importDefault(require("./accountInformation")); -const accountAssetInformation_1 = __importDefault(require("./accountAssetInformation")); -const accountApplicationInformation_1 = __importDefault(require("./accountApplicationInformation")); -const block_1 = __importDefault(require("./block")); -const compile_1 = __importDefault(require("./compile")); -const dryrun_1 = __importDefault(require("./dryrun")); -const genesis_1 = __importDefault(require("./genesis")); -const getAssetByID_1 = __importDefault(require("./getAssetByID")); -const getApplicationByID_1 = __importDefault(require("./getApplicationByID")); -const getBlockHash_1 = __importDefault(require("./getBlockHash")); -const getBlockTxids_1 = __importDefault(require("./getBlockTxids")); -const getApplicationBoxByName_1 = __importDefault(require("./getApplicationBoxByName")); -const getApplicationBoxes_1 = __importDefault(require("./getApplicationBoxes")); -const healthCheck_1 = __importDefault(require("./healthCheck")); -const pendingTransactionInformation_1 = __importDefault(require("./pendingTransactionInformation")); -const pendingTransactions_1 = __importDefault(require("./pendingTransactions")); -const pendingTransactionsByAddress_1 = __importDefault(require("./pendingTransactionsByAddress")); -const getTransactionProof_1 = __importDefault(require("./getTransactionProof")); -const sendRawTransaction_1 = __importDefault(require("./sendRawTransaction")); -const status_1 = __importDefault(require("./status")); -const statusAfterBlock_1 = __importDefault(require("./statusAfterBlock")); -const suggestedParams_1 = __importDefault(require("./suggestedParams")); -const supply_1 = __importDefault(require("./supply")); -const versions_1 = __importDefault(require("./versions")); -const lightBlockHeaderProof_1 = __importDefault(require("./lightBlockHeaderProof")); -const stateproof_1 = __importDefault(require("./stateproof")); -const setSyncRound_1 = __importDefault(require("./setSyncRound")); -const getSyncRound_1 = __importDefault(require("./getSyncRound")); -const setBlockOffsetTimestamp_1 = __importDefault(require("./setBlockOffsetTimestamp")); -const getBlockOffsetTimestamp_1 = __importDefault(require("./getBlockOffsetTimestamp")); -const disassemble_1 = __importDefault(require("./disassemble")); -const simulateTransaction_1 = __importDefault(require("./simulateTransaction")); -const encoding = __importStar(require("../../../encoding/encoding")); -const ready_1 = __importDefault(require("./ready")); -const unsetSyncRound_1 = __importDefault(require("./unsetSyncRound")); -const getLedgerStateDeltaForTransactionGroup_1 = __importDefault(require("./getLedgerStateDeltaForTransactionGroup")); -const getLedgerStateDelta_1 = __importDefault(require("./getLedgerStateDelta")); -const getTransactionGroupLedgerStateDeltasForRound_1 = __importDefault(require("./getTransactionGroupLedgerStateDeltasForRound")); -/** - * Algod client connects an application to the Algorand blockchain. The algod client requires a valid algod REST endpoint IP address and algod token from an Algorand node that is connected to the network you plan to interact with. - * - * Algod is the main Algorand process for handling the blockchain. Messages between nodes are processed, the protocol steps are executed, and the blocks are written to disk. The algod process also exposes a REST API server that developers can use to communicate with the node and the network. Algod uses the data directory for storage and configuration information. - * - * #### Relevant Information - * [How do I obtain an algod address and token?](https://developer.algorand.org/docs/archive/build-apps/setup/?from_query=algod#how-do-i-obtain-an-algod-address-and-token) - * - * [Run Algod in Postman OAS3](https://developer.algorand.org/docs/rest-apis/restendpoints/?from_query=algod#algod-indexer-and-kmd-rest-endpoints) - */ -class AlgodClient extends serviceClient_1.default { - /** - * Create an AlgodClient from - * * either a token, baseServer, port, and optional headers - * * or a base client server for interoperability with external dApp wallets - * - * #### Example - * ```typescript - * const token = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; - * const server = "http://localhost"; - * const port = 4001; - * const algodClient = new algosdk.Algodv2(token, server, port); - * ``` - * @remarks - * The above configuration is for a sandbox private network. - * For applications on production, you are encouraged to run your own node, or use an Algorand REST API provider with a dedicated API key. - * - * @param tokenOrBaseClient - The algod token from the Algorand node you are interacting with - * @param baseServer - REST endpoint - * @param port - Port number if specifically configured by the server - * @param headers - Optional headers - */ - constructor(tokenOrBaseClient, baseServer, port, headers = {}) { - super('X-Algo-API-Token', tokenOrBaseClient, baseServer, port, headers); - } - /** - * Returns OK if healthy. - * - * #### Example - * ```typescript - * const health = await algodClient.healthCheck().do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-health) - * @category GET - */ - healthCheck() { - return new healthCheck_1.default(this.c); - } - /** - * Retrieves the supported API versions, binary build versions, and genesis information. - * - * #### Example - * ```typescript - * const versionsDetails = await algodClient.versionsCheck().do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-versions) - * @category GET - */ - versionsCheck() { - return new versions_1.default(this.c); - } - /** - * Broadcasts a raw transaction to the network. - * - * #### Example - * ```typescript - * const { txId } = await algodClient.sendRawTransaction(signedTxns).do(); - * const result = await waitForConfirmation(algodClient, txid, 3); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#post-v2transactions) - * - * @remarks - * Often used with {@linkcode waitForConfirmation} - * @param stxOrStxs - Signed transactions - * @category POST - */ - sendRawTransaction(stxOrStxs) { - return new sendRawTransaction_1.default(this.c, stxOrStxs); - } - /** - * Returns the given account's status, balance and spendable amounts. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountInfo = await algodClient.accountInformation(address).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2accountsaddress) - * @param account - The address of the account to look up. - * @category GET - */ - accountInformation(account) { - return new accountInformation_1.default(this.c, this.intDecoding, account); - } - /** - * Returns the given account's asset information for a specific asset. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const index = 60553466; - * const accountAssetInfo = await algodClient.accountAssetInformation(address, index).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2accountsaddress) - * @param account - The address of the account to look up. - * @param index - The asset ID to look up. - * @category GET - */ - accountAssetInformation(account, index) { - return new accountAssetInformation_1.default(this.c, this.intDecoding, account, index); - } - /** - * Returns the given account's application information for a specific application. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const index = 60553466; - * const accountInfo = await algodClient.accountApplicationInformation(address, index).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2accountsaddress) - * @param account - The address of the account to look up. - * @param index - The application ID to look up. - * @category GET - */ - accountApplicationInformation(account, index) { - return new accountApplicationInformation_1.default(this.c, this.intDecoding, account, index); - } - /** - * Gets the block info for the given round. - * - * #### Example - * ```typescript - * const roundNumber = 18038133; - * const block = await algodClient.block(roundNumber).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2blocksround) - * @param roundNumber - The round number of the block to get. - * @category GET - */ - block(roundNumber) { - return new block_1.default(this.c, roundNumber); - } - /** - * Get the block hash for the block on the given round. - * - * #### Example - * ```typescript - * const roundNumber = 18038133; - * const block = await algodClient.getBlockHash(roundNumber).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2blocksroundhash) - * @param roundNumber - The round number of the block to get. - * @category GET - */ - getBlockHash(roundNumber) { - return new getBlockHash_1.default(this.c, this.intDecoding, roundNumber); - } - /** - * Get the top level transaction IDs for the block on the given round. - * - * #### Example - * ```typescript - * const roundNumber = 18038133; - * const block = await algodClient.getBlockTxids(roundNumber).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2blocksroundtxids) - * @param roundNumber - The round number of the block to get. - * @category GET - */ - getBlockTxids(roundNumber) { - return new getBlockTxids_1.default(this.c, this.intDecoding, roundNumber); - } - /** - * Returns the transaction information for a specific pending transaction. - * - * #### Example - * ```typescript - * const txId = "DRJS6R745A7GFVMXEXWP4TGVDGKW7VILFTA7HC2BR2GRLHNY5CTA"; - * const pending = await algodClient.pendingTransactionInformation(txId).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2transactionspendingtxid) - * - * @remarks - *

- * There are several cases when this might succeed: - * - transaction committed (committed round > 0) - * - transaction still in the pool (committed round = 0, pool error = "") - * - transaction removed from pool due to error (committed round = 0, pool error != "") - * - * Or the transaction may have happened sufficiently long ago that the node no longer remembers it, and this will return an error. - * - * @param txid - The TxID string of the pending transaction to look up. - * @category GET - */ - pendingTransactionInformation(txid) { - return new pendingTransactionInformation_1.default(this.c, txid); - } - /** - * Returns the list of pending transactions in the pool, sorted by priority, in decreasing order, truncated at the end at MAX. - * If MAX = 0, returns all pending transactions. - * - * #### Example 1 - * ```typescript - * const pendingTxns = await algodClient.pendingTransactionsInformation().do(); - * ``` - * - * #### Example 2 - * ```typescript - * const maxTxns = 5; - * const pendingTxns = await algodClient - * .pendingTransactionsInformation() - * .max(maxTxns) - * .do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2transactionspending) - * @category GET - */ - pendingTransactionsInformation() { - return new pendingTransactions_1.default(this.c); - } - /** - * Returns the list of pending transactions sent by the address, sorted by priority, in decreasing order, truncated at the end at MAX. - * If MAX = 0, returns all pending transactions. - * - * #### Example 1 - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const pendingTxnsByAddr = await algodClient.pendingTransactionByAddress(address).do(); - * ``` - * - * #### Example 2 - * ```typescript - * const maxTxns = 5; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const pendingTxns = await algodClient - * .pendingTransactionByAddress(address) - * .max(maxTxns) - * .do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2accountsaddresstransactionspending) - * @param address - The address of the sender. - * @category GET - */ - pendingTransactionByAddress(address) { - return new pendingTransactionsByAddress_1.default(this.c, address); - } - /** - * Retrieves the StatusResponse from the running node. - * - * #### Example - * ```typescript - * const status = await algodClient.status().do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2status) - * @category GET - */ - status() { - return new status_1.default(this.c, this.intDecoding); - } - /** - * Waits for a specific round to occur then returns the `StatusResponse` for that round. - * - * #### Example - * ```typescript - * const round = 18038133; - * const statusAfterBlock = await algodClient.statusAfterBlock(round).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2statuswait-for-block-afterround) - * @param round - The number of the round to wait for. - * @category GET - */ - statusAfterBlock(round) { - return new statusAfterBlock_1.default(this.c, this.intDecoding, round); - } - /** - * Returns the common needed parameters for a new transaction. - * - * #### Example - * ```typescript - * const suggestedParams = await algodClient.getTransactionParams().do(); - * const amountInMicroAlgos = algosdk.algosToMicroalgos(2); // 2 Algos - * const unsignedTxn = algosdk.makePaymentTxnWithSuggestedParamsFromObject({ - * sender: senderAddress, - * receiver: receiverAddress, - * amount: amountInMicroAlgos, - * suggestedParams: suggestedParams, - * }); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2transactionsparams) - * - * @remarks - * Often used with - * {@linkcode makePaymentTxnWithSuggestedParamsFromObject}, {@linkcode algosToMicroalgos} - * @category GET - */ - getTransactionParams() { - return new suggestedParams_1.default(this.c); - } - /** - * Returns the supply details for the specified node's ledger. - * - * #### Example - * ```typescript - * const supplyDetails = await algodClient.supply().do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2ledgersupply) - * @category GET - */ - supply() { - return new supply_1.default(this.c, this.intDecoding); - } - /** - * Compiles TEAL source code to binary, returns base64 encoded program bytes and base32 SHA512_256 hash of program bytes (Address style). - * - * #### Example - * ```typescript - * const source = "TEAL SOURCE CODE"; - * const compiledSmartContract = await algodClient.compile(source).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#post-v2tealcompile) - * @remarks - * This endpoint is only enabled when a node's configuration file sets `EnableDeveloperAPI` to true. - * @param source - * @category POST - */ - compile(source) { - return new compile_1.default(this.c, source); - } - /** - * Given the program bytes, return the TEAL source code in plain text. - * - * #### Example - * ```typescript - * const bytecode = "TEAL bytecode"; - * const disassembledSource = await algodClient.disassemble(bytecode).do(); - * ``` - * - * @remarks This endpoint is only enabled when a node's configuration file sets EnableDeveloperAPI to true. - * @param source - */ - disassemble(source) { - return new disassemble_1.default(this.c, source); - } - /** - * Provides debugging information for a transaction (or group). - * - * Executes TEAL program(s) in context and returns debugging information about the execution. This endpoint is only enabled when a node's configureation file sets `EnableDeveloperAPI` to true. - * - * #### Example - * ```typescript - * const dryRunResult = await algodClient.dryrun(dr).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#post-v2tealdryrun) - * @param dr - * @category POST - */ - dryrun(dr) { - return new dryrun_1.default(this.c, dr); - } - /** - * Given an asset ID, return asset information including creator, name, total supply and - * special addresses. - * - * #### Example - * ```typescript - * const asset_id = 163650; - * const asset = await algodClient.getAssetByID(asset_id).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2assetsasset-id) - * @param index - The asset ID to look up. - * @category GET - */ - getAssetByID(index) { - return new getAssetByID_1.default(this.c, this.intDecoding, index); - } - /** - * Given an application ID, return the application information including creator, approval - * and clear programs, global and local schemas, and global state. - * - * #### Example - * ```typescript - * const index = 60553466; - * const app = await algodClient.getApplicationByID(index).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2applicationsapplication-id) - * @param index - The application ID to look up. - * @category GET - */ - getApplicationByID(index) { - return new getApplicationByID_1.default(this.c, this.intDecoding, index); - } - /** - * Given an application ID and the box name (key), return the value stored in the box. - * - * #### Example - * ```typescript - * const index = 60553466; - * const boxName = Buffer.from("foo"); - * const boxResponse = await algodClient.getApplicationBoxByName(index, boxName).do(); - * const boxValue = boxResponse.value; - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2applicationsapplication-idbox) - * @param index - The application ID to look up. - * @category GET - */ - getApplicationBoxByName(index, boxName) { - return new getApplicationBoxByName_1.default(this.c, this.intDecoding, index, boxName); - } - /** - * Given an application ID, return all the box names associated with the app. - * - * #### Example - * ```typescript - * const index = 60553466; - * const boxesResponse = await algodClient.getApplicationBoxes(index).max(3).do(); - * const boxNames = boxesResponse.boxes.map(box => box.name); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2applicationsapplication-idboxes) - * @param index - The application ID to look up. - * @category GET - */ - getApplicationBoxes(index) { - return new getApplicationBoxes_1.default(this.c, this.intDecoding, index); - } - /** - * Returns the entire genesis file. - * - * #### Example - * ```typescript - * const genesis = await algodClient.genesis().do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-genesis) - * @category GET - */ - genesis() { - return new genesis_1.default(this.c, this.intDecoding); - } - /** - * Returns a Merkle proof for a given transaction in a block. - * - * #### Example - * ```typescript - * const round = 18038133; - * const txId = "MEUOC4RQJB23CQZRFRKYEI6WBO73VTTPST5A7B3S5OKBUY6LFUDA"; - * const proof = await algodClient.getTransactionProof(round, txId).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2blocksroundtransactionstxidproof) - * @param round - The round in which the transaction appears. - * @param txID - The transaction ID for which to generate a proof. - * @category GET - */ - getTransactionProof(round, txID) { - return new getTransactionProof_1.default(this.c, this.intDecoding, round, txID); - } - /** - * Gets a proof for a given light block header inside a state proof commitment. - * - * #### Example - * ```typescript - * const round = 11111111; - * const lightBlockHeaderProof = await algodClient.getLightBlockHeaderProof(round).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/v2#get-v2blocksroundlightheaderproof) - * @param round - */ - getLightBlockHeaderProof(round) { - return new lightBlockHeaderProof_1.default(this.c, this.intDecoding, round); - } - /** - * Gets a state proof that covers a given round. - * - * #### Example - * ```typescript - * const round = 11111111; - * const stateProof = await algodClient.getStateProof(round).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/v2#get-v2stateproofsround) - * @param round - */ - getStateProof(round) { - return new stateproof_1.default(this.c, this.intDecoding, round); - } - /** - * Simulate a list of a signed transaction objects being sent to the network. - * - * #### Example - * ```typescript - * const txn1 = algosdk.makePaymentTxnWithSuggestedParamsFromObject(txn1Params); - * const txn2 = algosdk.makePaymentTxnWithSuggestedParamsFromObject(txn2Params); - * const txgroup = algosdk.assignGroupID([txn1, txn2]); - * - * // Actually sign the first transaction - * const signedTxn1 = txgroup[0].signTxn(senderSk).blob; - * // Simulate does not require signed transactions -- use this method to encode an unsigned transaction - * const signedTxn2 = algosdk.encodeUnsignedSimulateTransaction(txgroup[1]); - * - * const resp = await client.simulateRawTransactions([signedTxn1, signedTxn2]).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#post-v2transactionssimulate) - * @param stxOrStxs - * @category POST - */ - simulateRawTransactions(stxOrStxs) { - const txnObjects = []; - if (Array.isArray(stxOrStxs)) { - for (const stxn of stxOrStxs) { - txnObjects.push(encoding.decode(stxn)); - } - } - else { - txnObjects.push(encoding.decode(stxOrStxs)); - } - const request = new modelsv2.SimulateRequest({ - txnGroups: [ - new modelsv2.SimulateRequestTransactionGroup({ - txns: txnObjects, - }), - ], - }); - return this.simulateTransactions(request); - } - /** - * Simulate transactions being sent to the network. - * - * #### Example - * ```typescript - * const txn1 = algosdk.makePaymentTxnWithSuggestedParamsFromObject(txn1Params); - * const txn2 = algosdk.makePaymentTxnWithSuggestedParamsFromObject(txn2Params); - * const txgroup = algosdk.assignGroupID([txn1, txn2]); - * - * // Actually sign the first transaction - * const signedTxn1 = txgroup[0].signTxn(senderSk).blob; - * // Simulate does not require signed transactions -- use this method to encode an unsigned transaction - * const signedTxn2 = algosdk.encodeUnsignedSimulateTransaction(txgroup[1]); - * - * const request = new modelsv2.SimulateRequest({ - * txnGroups: [ - * new modelsv2.SimulateRequestTransactionGroup({ - * // Must decode the signed txn bytes into an object - * txns: [algosdk.decodeObj(signedTxn1), algosdk.decodeObj(signedTxn2)] - * }), - * ], - * }); - * const resp = await client.simulateRawTransactions(request).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#post-v2transactionssimulate) - * @param request - * @category POST - */ - simulateTransactions(request) { - return new simulateTransaction_1.default(this.c, request); - } - /** - * Set the offset (in seconds) applied to the block timestamp when creating new blocks in devmode. - * - * #### Example - * ```typesecript - * const offset = 60 - * await client.setBlockOffsetTimestamp(offset).do(); - * ``` - * - [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#post-v2devmodeblocksoffsetoffset) - * @param offset - * @category POST - */ - setBlockOffsetTimestamp(offset) { - return new setBlockOffsetTimestamp_1.default(this.c, this.intDecoding, offset); - } - /** - * Get the offset (in seconds) applied to the block timestamp when creating new blocks in devmode. - * - * #### Example - * ```typesecript - * const currentOffset = await client.getBlockOffsetTimestamp().do(); - * ``` - * - [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2devmodeblocksoffset) - * @category GET - */ - getBlockOffsetTimestamp() { - return new getBlockOffsetTimestamp_1.default(this.c, this.intDecoding); - } - /** - * Set the sync round on the ledger (algod must have EnableFollowMode: true), restricting catchup. - * - * #### Example - * ```typesecript - * const round = 10000 - * await client.setSyncRound(round).do(); - * ``` - * - [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#post-v2ledgersyncround) - * @param round - * @category POST - */ - setSyncRound(round) { - return new setSyncRound_1.default(this.c, this.intDecoding, round); - } - /** - * Un-Set the sync round on the ledger (algod must have EnableFollowMode: true), removing the restriction on catchup. - * - * #### Example - * ```typesecript - * await client.unsetSyncRound().do(); - * ``` - * - [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#delete-v2ledgersync) - * @category DELETE - */ - unsetSyncRound() { - return new unsetSyncRound_1.default(this.c, this.intDecoding); - } - /** - * Get the current sync round on the ledger (algod must have EnableFollowMode: true). - * - * #### Example - * ```typesecript - * const currentSyncRound = await client.getSyncRound().do(); - * ``` - * - [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2ledgersync) - * @category GET - */ - getSyncRound() { - return new getSyncRound_1.default(this.c, this.intDecoding); - } - /** - * Ready check which returns 200 OK if algod is healthy and caught up - * - * #### Example - * ```typesecript - * await client.ready().do(); - * ``` - * - [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-ready) - * @category GET - */ - ready() { - return new ready_1.default(this.c, this.intDecoding); - } - /** - * GetLedgerStateDeltaForTransactionGroup returns the ledger delta for the txn group identified by id - * - * #### Example - * ```typescript - * const id = "ABC123"; - * await client.getLedgerStateDeltaForTransactionGroup(id).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2deltastxngroupid) - * @param id txn ID or group ID to be searched for - * @category GET - */ - getLedgerStateDeltaForTransactionGroup(id) { - return new getLedgerStateDeltaForTransactionGroup_1.default(this.c, this.intDecoding, id); - } - /** - * GetLedgerStateDelta returns the ledger delta for the entire round - * - * #### Example - * ```typescript - * const round = 12345; - * await client.getLedgerStateDelta(round).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2deltasround) - * @param round the round number to be searched for - * @category GET - */ - getLedgerStateDelta(round) { - return new getLedgerStateDelta_1.default(this.c, this.intDecoding, round); - } - /** - * GetTransactionGroupLedgerStateDeltasForRound returns all ledger deltas for txn groups in the provided round - * - * #### Example - * ```typescript - * const round = 12345; - * await client.getTransactionGroupLedgerStateDeltasForRound(round).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2deltasroundtxngroup) - * @param round the round number to be searched for - * @category GET - */ - getTransactionGroupLedgerStateDeltasForRound(round) { - return new getTransactionGroupLedgerStateDeltasForRound_1.default(this.c, this.intDecoding, round); - } -} -exports.default = AlgodClient; diff --git a/algosdk/client/v2/algod/block.d.ts b/algosdk/client/v2/algod/block.d.ts deleted file mode 100644 index f4ec6ba..0000000 --- a/algosdk/client/v2/algod/block.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import HTTPClient from '../../client'; -import { BlockResponse } from './models/types'; -/** - * block gets the block info for the given round. this call may block - */ -export default class Block extends JSONRequest { - private round; - constructor(c: HTTPClient, roundNumber: number); - path(): string; - prepare(body: Uint8Array): BlockResponse; -} diff --git a/algosdk/client/v2/algod/block.js b/algosdk/client/v2/algod/block.js deleted file mode 100644 index fd6ca86..0000000 --- a/algosdk/client/v2/algod/block.js +++ /dev/null @@ -1,52 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const encoding = __importStar(require("../../../encoding/encoding")); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -const types_1 = require("./models/types"); -/** - * block gets the block info for the given round. this call may block - */ -class Block extends jsonrequest_1.default { - constructor(c, roundNumber) { - super(c); - this.round = roundNumber; - this.query = { format: 'msgpack' }; - } - path() { - return `/v2/blocks/${this.round}`; - } - // eslint-disable-next-line class-methods-use-this - prepare(body) { - if (body && body.byteLength > 0) { - return types_1.BlockResponse.from_obj_for_encoding(encoding.decode(body)); - } - return undefined; - } -} -exports.default = Block; diff --git a/algosdk/client/v2/algod/compile.d.ts b/algosdk/client/v2/algod/compile.d.ts deleted file mode 100644 index a8e6f4f..0000000 --- a/algosdk/client/v2/algod/compile.d.ts +++ /dev/null @@ -1,23 +0,0 @@ -import HTTPClient from '../../client'; -import { CompileResponse } from './models/types'; -import JSONRequest from '../jsonrequest'; -/** - * Sets the default header (if not previously set) - * @param headers - A headers object - */ -export declare function setHeaders(headers?: {}): {}; -/** - * Executes compile - */ -export default class Compile extends JSONRequest> { - private source; - constructor(c: HTTPClient, source: string | Uint8Array); - path(): string; - sourcemap(map?: boolean): this; - /** - * Executes compile - * @param headers - A headers object - */ - do(headers?: {}): Promise; - prepare(body: Record): CompileResponse; -} diff --git a/algosdk/client/v2/algod/compile.js b/algosdk/client/v2/algod/compile.js deleted file mode 100644 index 7c0ff0b..0000000 --- a/algosdk/client/v2/algod/compile.js +++ /dev/null @@ -1,54 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.setHeaders = void 0; -const binarydata_1 = require("../../../encoding/binarydata"); -const types_1 = require("./models/types"); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -/** - * Sets the default header (if not previously set) - * @param headers - A headers object - */ -function setHeaders(headers = {}) { - let hdrs = headers; - if (Object.keys(hdrs).every((key) => key.toLowerCase() !== 'content-type')) { - hdrs = { ...headers }; - hdrs['Content-Type'] = 'text/plain'; - } - return hdrs; -} -exports.setHeaders = setHeaders; -/** - * Executes compile - */ -class Compile extends jsonrequest_1.default { - constructor(c, source) { - super(c); - this.source = source; - this.source = source; - } - // eslint-disable-next-line class-methods-use-this - path() { - return `/v2/teal/compile`; - } - sourcemap(map = true) { - this.query.sourcemap = map; - return this; - } - /** - * Executes compile - * @param headers - A headers object - */ - async do(headers = {}) { - const txHeaders = setHeaders(headers); - const res = await this.c.post(this.path(), (0, binarydata_1.coerceToBytes)(this.source), this.query, txHeaders); - return res.body; - } - // eslint-disable-next-line class-methods-use-this - prepare(body) { - return types_1.CompileResponse.from_obj_for_encoding(body); - } -} -exports.default = Compile; diff --git a/algosdk/client/v2/algod/disassemble.d.ts b/algosdk/client/v2/algod/disassemble.d.ts deleted file mode 100644 index ee111a5..0000000 --- a/algosdk/client/v2/algod/disassemble.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -import HTTPClient from '../../client'; -import { DisassembleResponse } from './models/types'; -import JSONRequest from '../jsonrequest'; -/** - * Sets the default header (if not previously set) - * @param headers - A headers object - */ -export declare function setHeaders(headers?: {}): {}; -/** - * Executes disassemble - */ -export default class Disassemble extends JSONRequest> { - private source; - constructor(c: HTTPClient, source: string | Uint8Array); - path(): string; - /** - * Executes disassemble - * @param headers - A headers object - */ - do(headers?: {}): Promise; - prepare(body: Record): DisassembleResponse; -} diff --git a/algosdk/client/v2/algod/disassemble.js b/algosdk/client/v2/algod/disassemble.js deleted file mode 100644 index e6b12db..0000000 --- a/algosdk/client/v2/algod/disassemble.js +++ /dev/null @@ -1,50 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.setHeaders = void 0; -const binarydata_1 = require("../../../encoding/binarydata"); -const types_1 = require("./models/types"); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -/** - * Sets the default header (if not previously set) - * @param headers - A headers object - */ -function setHeaders(headers = {}) { - let hdrs = headers; - if (Object.keys(hdrs).every((key) => key.toLowerCase() !== 'content-type')) { - hdrs = { ...headers }; - hdrs['Content-Type'] = 'text/plain'; - } - return hdrs; -} -exports.setHeaders = setHeaders; -/** - * Executes disassemble - */ -class Disassemble extends jsonrequest_1.default { - constructor(c, source) { - super(c); - this.source = source; - this.source = source; - } - // eslint-disable-next-line class-methods-use-this - path() { - return `/v2/teal/disassemble`; - } - /** - * Executes disassemble - * @param headers - A headers object - */ - async do(headers = {}) { - const txHeaders = setHeaders(headers); - const res = await this.c.post(this.path(), (0, binarydata_1.coerceToBytes)(this.source), this.query, txHeaders); - return res.body; - } - // eslint-disable-next-line class-methods-use-this - prepare(body) { - return types_1.DisassembleResponse.from_obj_for_encoding(body); - } -} -exports.default = Disassemble; diff --git a/algosdk/client/v2/algod/dryrun.d.ts b/algosdk/client/v2/algod/dryrun.d.ts deleted file mode 100644 index af5f9ff..0000000 --- a/algosdk/client/v2/algod/dryrun.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -import HTTPClient from '../../client'; -import JSONRequest from '../jsonrequest'; -import { DryrunResponse } from './models/types'; -import * as modelsv2 from './models/types'; -export default class Dryrun extends JSONRequest> { - private blob; - constructor(c: HTTPClient, dr: modelsv2.DryrunRequest); - path(): string; - /** - * Executes dryrun - * @param headers - A headers object - */ - do(headers?: {}): Promise; - prepare(body: Record): DryrunResponse; -} diff --git a/algosdk/client/v2/algod/dryrun.js b/algosdk/client/v2/algod/dryrun.js deleted file mode 100644 index ce26b0e..0000000 --- a/algosdk/client/v2/algod/dryrun.js +++ /dev/null @@ -1,56 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const encoding = __importStar(require("../../../encoding/encoding")); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -const compile_1 = require("./compile"); -const types_1 = require("./models/types"); -class Dryrun extends jsonrequest_1.default { - constructor(c, dr) { - super(c); - this.blob = encoding.encode(dr.get_obj_for_encoding(true)); - } - // eslint-disable-next-line class-methods-use-this - path() { - return '/v2/teal/dryrun'; - } - /** - * Executes dryrun - * @param headers - A headers object - */ - async do(headers = {}) { - const txHeaders = (0, compile_1.setHeaders)(headers); - const res = await this.c.post(this.path(), this.blob, null, txHeaders); - return this.prepare(res.body); - } - // eslint-disable-next-line class-methods-use-this - prepare(body) { - return types_1.DryrunResponse.from_obj_for_encoding(body); - } -} -exports.default = Dryrun; diff --git a/algosdk/client/v2/algod/genesis.d.ts b/algosdk/client/v2/algod/genesis.d.ts deleted file mode 100644 index de084d2..0000000 --- a/algosdk/client/v2/algod/genesis.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -import JSONRequest from '../jsonrequest'; -export default class Genesis extends JSONRequest { - path(): string; -} diff --git a/algosdk/client/v2/algod/genesis.js b/algosdk/client/v2/algod/genesis.js deleted file mode 100644 index 92d8af4..0000000 --- a/algosdk/client/v2/algod/genesis.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -class Genesis extends jsonrequest_1.default { - // eslint-disable-next-line class-methods-use-this - path() { - return '/genesis'; - } -} -exports.default = Genesis; diff --git a/algosdk/client/v2/algod/getApplicationBoxByName.d.ts b/algosdk/client/v2/algod/getApplicationBoxByName.d.ts deleted file mode 100644 index ca0a476..0000000 --- a/algosdk/client/v2/algod/getApplicationBoxByName.d.ts +++ /dev/null @@ -1,28 +0,0 @@ -import IntDecoding from '../../../types/intDecoding'; -import HTTPClient from '../../client'; -import JSONRequest from '../jsonrequest'; -import { Box } from './models/types'; -/** - * Given an application ID and the box name (key), return the value stored in the box. - * - * #### Example - * ```typescript - * const index = 60553466; - * const boxName = Buffer.from("foo"); - * const boxResponse = await algodClient.getApplicationBoxByName(index, boxName).do(); - * const boxValue = boxResponse.value; - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2applicationsapplication-idbox) - * @param index - The application ID to look up. - * @category GET - */ -export default class GetApplicationBoxByName extends JSONRequest> { - private index; - constructor(c: HTTPClient, intDecoding: IntDecoding, index: number, name: Uint8Array); - /** - * @returns `/v2/applications/${index}/box` - */ - path(): string; - prepare(body: Record): Box; -} diff --git a/algosdk/client/v2/algod/getApplicationBoxByName.js b/algosdk/client/v2/algod/getApplicationBoxByName.js deleted file mode 100644 index 31285f8..0000000 --- a/algosdk/client/v2/algod/getApplicationBoxByName.js +++ /dev/null @@ -1,44 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const binarydata_1 = require("../../../encoding/binarydata"); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -const types_1 = require("./models/types"); -/** - * Given an application ID and the box name (key), return the value stored in the box. - * - * #### Example - * ```typescript - * const index = 60553466; - * const boxName = Buffer.from("foo"); - * const boxResponse = await algodClient.getApplicationBoxByName(index, boxName).do(); - * const boxValue = boxResponse.value; - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2applicationsapplication-idbox) - * @param index - The application ID to look up. - * @category GET - */ -class GetApplicationBoxByName extends jsonrequest_1.default { - constructor(c, intDecoding, index, name) { - super(c, intDecoding); - this.index = index; - this.index = index; - // Encode name in base64 format and append the encoding prefix. - const encodedName = (0, binarydata_1.bytesToBase64)(name); - this.query.name = encodeURI(`b64:${encodedName}`); - } - /** - * @returns `/v2/applications/${index}/box` - */ - path() { - return `/v2/applications/${this.index}/box`; - } - // eslint-disable-next-line class-methods-use-this - prepare(body) { - return types_1.Box.from_obj_for_encoding(body); - } -} -exports.default = GetApplicationBoxByName; diff --git a/algosdk/client/v2/algod/getApplicationBoxes.d.ts b/algosdk/client/v2/algod/getApplicationBoxes.d.ts deleted file mode 100644 index dff284c..0000000 --- a/algosdk/client/v2/algod/getApplicationBoxes.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; -import { BoxesResponse } from './models/types'; -/** - * Given an application ID, return all the box names associated with the app. - * - * #### Example - * ```typescript - * const index = 60553466; - * const boxesResponse = await algodClient.getApplicationBoxes(index).max(3).do(); - * const boxNames = boxesResponse.boxes.map(box => box.name); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2applicationsapplication-idboxes) - * @param index - The application ID to look up. - * @category GET - */ -export default class GetApplicationBoxes extends JSONRequest> { - private index; - constructor(c: HTTPClient, intDecoding: IntDecoding, index: number); - /** - * @returns `/v2/applications/${index}/boxes` - */ - path(): string; - /** - * Limit results for pagination. - * - * #### Example - * ```typescript - * const maxResults = 20; - * const boxesResult = await algodClient - * .GetApplicationBoxes(1234) - * .limit(maxResults) - * .do(); - * ``` - * - * @param limit - maximum number of results to return. - * @category query - */ - max(max: number): this; - prepare(body: Record): BoxesResponse; -} diff --git a/algosdk/client/v2/algod/getApplicationBoxes.js b/algosdk/client/v2/algod/getApplicationBoxes.js deleted file mode 100644 index 52a1e62..0000000 --- a/algosdk/client/v2/algod/getApplicationBoxes.js +++ /dev/null @@ -1,59 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -const types_1 = require("./models/types"); -/** - * Given an application ID, return all the box names associated with the app. - * - * #### Example - * ```typescript - * const index = 60553466; - * const boxesResponse = await algodClient.getApplicationBoxes(index).max(3).do(); - * const boxNames = boxesResponse.boxes.map(box => box.name); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2applicationsapplication-idboxes) - * @param index - The application ID to look up. - * @category GET - */ -class GetApplicationBoxes extends jsonrequest_1.default { - constructor(c, intDecoding, index) { - super(c, intDecoding); - this.index = index; - this.index = index; - this.query.max = 0; - } - /** - * @returns `/v2/applications/${index}/boxes` - */ - path() { - return `/v2/applications/${this.index}/boxes`; - } - /** - * Limit results for pagination. - * - * #### Example - * ```typescript - * const maxResults = 20; - * const boxesResult = await algodClient - * .GetApplicationBoxes(1234) - * .limit(maxResults) - * .do(); - * ``` - * - * @param limit - maximum number of results to return. - * @category query - */ - max(max) { - this.query.max = max; - return this; - } - // eslint-disable-next-line class-methods-use-this - prepare(body) { - return types_1.BoxesResponse.from_obj_for_encoding(body); - } -} -exports.default = GetApplicationBoxes; diff --git a/algosdk/client/v2/algod/getApplicationByID.d.ts b/algosdk/client/v2/algod/getApplicationByID.d.ts deleted file mode 100644 index 74070e8..0000000 --- a/algosdk/client/v2/algod/getApplicationByID.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; -import { Application } from './models/types'; -export default class GetApplicationByID extends JSONRequest> { - private index; - constructor(c: HTTPClient, intDecoding: IntDecoding, index: number); - path(): string; - prepare(body: Record): Application; -} diff --git a/algosdk/client/v2/algod/getApplicationByID.js b/algosdk/client/v2/algod/getApplicationByID.js deleted file mode 100644 index 53fdec2..0000000 --- a/algosdk/client/v2/algod/getApplicationByID.js +++ /dev/null @@ -1,22 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -const types_1 = require("./models/types"); -class GetApplicationByID extends jsonrequest_1.default { - constructor(c, intDecoding, index) { - super(c, intDecoding); - this.index = index; - this.index = index; - } - path() { - return `/v2/applications/${this.index}`; - } - // eslint-disable-next-line class-methods-use-this - prepare(body) { - return types_1.Application.from_obj_for_encoding(body); - } -} -exports.default = GetApplicationByID; diff --git a/algosdk/client/v2/algod/getAssetByID.d.ts b/algosdk/client/v2/algod/getAssetByID.d.ts deleted file mode 100644 index 02f68f1..0000000 --- a/algosdk/client/v2/algod/getAssetByID.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; -import { Asset } from './models/types'; -export default class GetAssetByID extends JSONRequest> { - private index; - constructor(c: HTTPClient, intDecoding: IntDecoding, index: number); - path(): string; - prepare(body: Record): Asset; -} diff --git a/algosdk/client/v2/algod/getAssetByID.js b/algosdk/client/v2/algod/getAssetByID.js deleted file mode 100644 index 28281ac..0000000 --- a/algosdk/client/v2/algod/getAssetByID.js +++ /dev/null @@ -1,22 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -const types_1 = require("./models/types"); -class GetAssetByID extends jsonrequest_1.default { - constructor(c, intDecoding, index) { - super(c, intDecoding); - this.index = index; - this.index = index; - } - path() { - return `/v2/assets/${this.index}`; - } - // eslint-disable-next-line class-methods-use-this - prepare(body) { - return types_1.Asset.from_obj_for_encoding(body); - } -} -exports.default = GetAssetByID; diff --git a/algosdk/client/v2/algod/getBlockHash.d.ts b/algosdk/client/v2/algod/getBlockHash.d.ts deleted file mode 100644 index 22d1c5d..0000000 --- a/algosdk/client/v2/algod/getBlockHash.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; -import { BlockHashResponse } from './models/types'; -export default class GetBlockHash extends JSONRequest> { - round: number | bigint; - constructor(c: HTTPClient, intDecoding: IntDecoding, roundNumber: number); - path(): string; - prepare(body: Record): BlockHashResponse; -} diff --git a/algosdk/client/v2/algod/getBlockHash.js b/algosdk/client/v2/algod/getBlockHash.js deleted file mode 100644 index 34c15ba..0000000 --- a/algosdk/client/v2/algod/getBlockHash.js +++ /dev/null @@ -1,21 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -const types_1 = require("./models/types"); -class GetBlockHash extends jsonrequest_1.default { - constructor(c, intDecoding, roundNumber) { - super(c, intDecoding); - this.round = roundNumber; - } - path() { - return `/v2/blocks/${this.round}/hash`; - } - // eslint-disable-next-line class-methods-use-this - prepare(body) { - return types_1.BlockHashResponse.from_obj_for_encoding(body); - } -} -exports.default = GetBlockHash; diff --git a/algosdk/client/v2/algod/getBlockOffsetTimestamp.d.ts b/algosdk/client/v2/algod/getBlockOffsetTimestamp.d.ts deleted file mode 100644 index d2c633f..0000000 --- a/algosdk/client/v2/algod/getBlockOffsetTimestamp.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import { GetBlockTimeStampOffsetResponse } from './models/types'; -export default class GetBlockOffsetTimestamp extends JSONRequest> { - path(): string; - prepare(body: Record): GetBlockTimeStampOffsetResponse; -} diff --git a/algosdk/client/v2/algod/getBlockOffsetTimestamp.js b/algosdk/client/v2/algod/getBlockOffsetTimestamp.js deleted file mode 100644 index 7ec7511..0000000 --- a/algosdk/client/v2/algod/getBlockOffsetTimestamp.js +++ /dev/null @@ -1,18 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -const types_1 = require("./models/types"); -class GetBlockOffsetTimestamp extends jsonrequest_1.default { - // eslint-disable-next-line class-methods-use-this - path() { - return `/v2/devmode/blocks/offset`; - } - // eslint-disable-next-line class-methods-use-this - prepare(body) { - return types_1.GetBlockTimeStampOffsetResponse.from_obj_for_encoding(body); - } -} -exports.default = GetBlockOffsetTimestamp; diff --git a/algosdk/client/v2/algod/getBlockTxids.d.ts b/algosdk/client/v2/algod/getBlockTxids.d.ts deleted file mode 100644 index 9210b82..0000000 --- a/algosdk/client/v2/algod/getBlockTxids.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; -export default class GetBlockTxids extends JSONRequest { - round: number; - constructor(c: HTTPClient, intDecoding: IntDecoding, roundNumber: number); - path(): string; -} diff --git a/algosdk/client/v2/algod/getBlockTxids.js b/algosdk/client/v2/algod/getBlockTxids.js deleted file mode 100644 index 604da1f..0000000 --- a/algosdk/client/v2/algod/getBlockTxids.js +++ /dev/null @@ -1,18 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -class GetBlockTxids extends jsonrequest_1.default { - constructor(c, intDecoding, roundNumber) { - super(c, intDecoding); - if (!Number.isInteger(roundNumber)) - throw Error('roundNumber should be an integer'); - this.round = roundNumber; - } - path() { - return `/v2/blocks/${this.round}/txids`; - } -} -exports.default = GetBlockTxids; diff --git a/algosdk/client/v2/algod/getLedgerStateDelta.d.ts b/algosdk/client/v2/algod/getLedgerStateDelta.d.ts deleted file mode 100644 index 7c5a5ca..0000000 --- a/algosdk/client/v2/algod/getLedgerStateDelta.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; -export default class GetLedgerStateDelta extends JSONRequest { - private round; - constructor(c: HTTPClient, intDecoding: IntDecoding, round: number); - path(): string; -} diff --git a/algosdk/client/v2/algod/getLedgerStateDelta.js b/algosdk/client/v2/algod/getLedgerStateDelta.js deleted file mode 100644 index 2972a9c..0000000 --- a/algosdk/client/v2/algod/getLedgerStateDelta.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -class GetLedgerStateDelta extends jsonrequest_1.default { - constructor(c, intDecoding, round) { - super(c, intDecoding); - this.round = round; - this.round = round; - this.query = { format: 'json' }; - } - // eslint-disable-next-line class-methods-use-this - path() { - return `/v2/deltas/${this.round}`; - } -} -exports.default = GetLedgerStateDelta; diff --git a/algosdk/client/v2/algod/getLedgerStateDeltaForTransactionGroup.d.ts b/algosdk/client/v2/algod/getLedgerStateDeltaForTransactionGroup.d.ts deleted file mode 100644 index 9238150..0000000 --- a/algosdk/client/v2/algod/getLedgerStateDeltaForTransactionGroup.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; -export default class GetLedgerStateDeltaForTransactionGroup extends JSONRequest { - private id; - constructor(c: HTTPClient, intDecoding: IntDecoding, id: string); - path(): string; -} diff --git a/algosdk/client/v2/algod/getLedgerStateDeltaForTransactionGroup.js b/algosdk/client/v2/algod/getLedgerStateDeltaForTransactionGroup.js deleted file mode 100644 index f968f08..0000000 --- a/algosdk/client/v2/algod/getLedgerStateDeltaForTransactionGroup.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -class GetLedgerStateDeltaForTransactionGroup extends jsonrequest_1.default { - constructor(c, intDecoding, id) { - super(c, intDecoding); - this.id = id; - this.id = id; - this.query = { format: 'json' }; - } - // eslint-disable-next-line class-methods-use-this - path() { - return `/v2/deltas/txn/group/${this.id}`; - } -} -exports.default = GetLedgerStateDeltaForTransactionGroup; diff --git a/algosdk/client/v2/algod/getSyncRound.d.ts b/algosdk/client/v2/algod/getSyncRound.d.ts deleted file mode 100644 index 881ce0c..0000000 --- a/algosdk/client/v2/algod/getSyncRound.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import { GetSyncRoundResponse } from './models/types'; -export default class GetSyncRound extends JSONRequest> { - path(): string; - prepare(body: Record): GetSyncRoundResponse; -} diff --git a/algosdk/client/v2/algod/getSyncRound.js b/algosdk/client/v2/algod/getSyncRound.js deleted file mode 100644 index 5ae1b0d..0000000 --- a/algosdk/client/v2/algod/getSyncRound.js +++ /dev/null @@ -1,18 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -const types_1 = require("./models/types"); -class GetSyncRound extends jsonrequest_1.default { - // eslint-disable-next-line class-methods-use-this - path() { - return `/v2/ledger/sync`; - } - // eslint-disable-next-line class-methods-use-this - prepare(body) { - return types_1.GetSyncRoundResponse.from_obj_for_encoding(body); - } -} -exports.default = GetSyncRound; diff --git a/algosdk/client/v2/algod/getTransactionGroupLedgerStateDeltasForRound.d.ts b/algosdk/client/v2/algod/getTransactionGroupLedgerStateDeltasForRound.d.ts deleted file mode 100644 index 4ad4284..0000000 --- a/algosdk/client/v2/algod/getTransactionGroupLedgerStateDeltasForRound.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import { TransactionGroupLedgerStateDeltasForRoundResponse } from './models/types'; -import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; -export default class GetTransactionGroupLedgerStateDeltasForRound extends JSONRequest> { - private round; - constructor(c: HTTPClient, intDecoding: IntDecoding, round: number); - path(): string; - prepare(body: Record): TransactionGroupLedgerStateDeltasForRoundResponse; -} diff --git a/algosdk/client/v2/algod/getTransactionGroupLedgerStateDeltasForRound.js b/algosdk/client/v2/algod/getTransactionGroupLedgerStateDeltasForRound.js deleted file mode 100644 index c7aa3f5..0000000 --- a/algosdk/client/v2/algod/getTransactionGroupLedgerStateDeltasForRound.js +++ /dev/null @@ -1,24 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -const types_1 = require("./models/types"); -class GetTransactionGroupLedgerStateDeltasForRound extends jsonrequest_1.default { - constructor(c, intDecoding, round) { - super(c, intDecoding); - this.round = round; - this.round = round; - this.query = { format: 'json' }; - } - // eslint-disable-next-line class-methods-use-this - path() { - return `/v2/deltas/${this.round}/txn/group`; - } - // eslint-disable-next-line class-methods-use-this - prepare(body) { - return types_1.TransactionGroupLedgerStateDeltasForRoundResponse.from_obj_for_encoding(body); - } -} -exports.default = GetTransactionGroupLedgerStateDeltasForRound; diff --git a/algosdk/client/v2/algod/getTransactionProof.d.ts b/algosdk/client/v2/algod/getTransactionProof.d.ts deleted file mode 100644 index c9e0189..0000000 --- a/algosdk/client/v2/algod/getTransactionProof.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; -import { TransactionProofResponse } from './models/types'; -export default class GetTransactionProof extends JSONRequest> { - private round; - private txID; - constructor(c: HTTPClient, intDecoding: IntDecoding, round: number, txID: string); - path(): string; - /** - * Exclude assets and application data from results - * The type of hash function used to create the proof, must be one of: "sha512_256", "sha256" - * - * #### Example - * ```typescript - * const hashType = "sha256"; - * const round = 123456; - * const txId = "abc123; - * const txProof = await algodClient.getTransactionProof(round, txId) - * .hashType(hashType) - * .do(); - * ``` - * - * @param hashType - * @category query - */ - hashType(hashType: string): this; - prepare(body: Record): TransactionProofResponse; -} diff --git a/algosdk/client/v2/algod/getTransactionProof.js b/algosdk/client/v2/algod/getTransactionProof.js deleted file mode 100644 index 9db1cfe..0000000 --- a/algosdk/client/v2/algod/getTransactionProof.js +++ /dev/null @@ -1,45 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -const types_1 = require("./models/types"); -class GetTransactionProof extends jsonrequest_1.default { - constructor(c, intDecoding, round, txID) { - super(c, intDecoding); - this.round = round; - this.txID = txID; - this.round = round; - this.txID = txID; - } - path() { - return `/v2/blocks/${this.round}/transactions/${this.txID}/proof`; - } - /** - * Exclude assets and application data from results - * The type of hash function used to create the proof, must be one of: "sha512_256", "sha256" - * - * #### Example - * ```typescript - * const hashType = "sha256"; - * const round = 123456; - * const txId = "abc123; - * const txProof = await algodClient.getTransactionProof(round, txId) - * .hashType(hashType) - * .do(); - * ``` - * - * @param hashType - * @category query - */ - hashType(hashType) { - this.query.hashtype = hashType; - return this; - } - // eslint-disable-next-line class-methods-use-this - prepare(body) { - return types_1.TransactionProofResponse.from_obj_for_encoding(body); - } -} -exports.default = GetTransactionProof; diff --git a/algosdk/client/v2/algod/healthCheck.d.ts b/algosdk/client/v2/algod/healthCheck.d.ts deleted file mode 100644 index d7b73ef..0000000 --- a/algosdk/client/v2/algod/healthCheck.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import JSONRequest from '../jsonrequest'; -/** - * healthCheck returns an empty object iff the node is running - */ -export default class HealthCheck extends JSONRequest { - path(): string; - do(headers?: {}): Promise<{}>; -} diff --git a/algosdk/client/v2/algod/healthCheck.js b/algosdk/client/v2/algod/healthCheck.js deleted file mode 100644 index 1945be6..0000000 --- a/algosdk/client/v2/algod/healthCheck.js +++ /dev/null @@ -1,23 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -/** - * healthCheck returns an empty object iff the node is running - */ -class HealthCheck extends jsonrequest_1.default { - // eslint-disable-next-line class-methods-use-this - path() { - return '/health'; - } - async do(headers = {}) { - const res = await this.c.get(this.path(), {}, headers); - if (!res.ok) { - throw new Error(`Health response: ${res.status}`); - } - return {}; - } -} -exports.default = HealthCheck; diff --git a/algosdk/client/v2/algod/lightBlockHeaderProof.d.ts b/algosdk/client/v2/algod/lightBlockHeaderProof.d.ts deleted file mode 100644 index 5c40b4c..0000000 --- a/algosdk/client/v2/algod/lightBlockHeaderProof.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; -import { LightBlockHeaderProof as LBHP } from './models/types'; -export default class LightBlockHeaderProof extends JSONRequest> { - private round; - constructor(c: HTTPClient, intDecoding: IntDecoding, round: number); - path(): string; - prepare(body: Record): LBHP; -} diff --git a/algosdk/client/v2/algod/lightBlockHeaderProof.js b/algosdk/client/v2/algod/lightBlockHeaderProof.js deleted file mode 100644 index b7f5814..0000000 --- a/algosdk/client/v2/algod/lightBlockHeaderProof.js +++ /dev/null @@ -1,22 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -const types_1 = require("./models/types"); -class LightBlockHeaderProof extends jsonrequest_1.default { - constructor(c, intDecoding, round) { - super(c, intDecoding); - this.round = round; - this.round = round; - } - path() { - return `/v2/blocks/${this.round}/lightheader/proof`; - } - // eslint-disable-next-line class-methods-use-this - prepare(body) { - return types_1.LightBlockHeaderProof.from_obj_for_encoding(body); - } -} -exports.default = LightBlockHeaderProof; diff --git a/algosdk/client/v2/algod/models/types.d.ts b/algosdk/client/v2/algod/models/types.d.ts deleted file mode 100644 index 16d8796..0000000 --- a/algosdk/client/v2/algod/models/types.d.ts +++ /dev/null @@ -1,2660 +0,0 @@ -/** - * NOTICE: This file was generated. Editing this file manually is not recommended. - */ -import BlockHeader from '../../../../types/blockHeader'; -import { EncodedSignedTransaction } from '../../../../types/transactions/encoded'; -import BaseModel from '../../basemodel'; -/** - * Account information at a given round. - * Definition: - * data/basics/userBalance.go : AccountData - */ -export declare class Account extends BaseModel { - /** - * the account public key - */ - address: string; - /** - * (algo) total number of MicroAlgos in the account - */ - amount: number | bigint; - /** - * specifies the amount of MicroAlgos in the account, without the pending rewards. - */ - amountWithoutPendingRewards: number | bigint; - /** - * MicroAlgo balance required by the account. - * The requirement grows based on asset and application usage. - */ - minBalance: number | bigint; - /** - * amount of MicroAlgos of pending rewards in this account. - */ - pendingRewards: number | bigint; - /** - * (ern) total rewards of MicroAlgos the account has received, including pending - * rewards. - */ - rewards: number | bigint; - /** - * The round for which this information is relevant. - */ - round: number | bigint; - /** - * (onl) delegation status of the account's MicroAlgos - * * Offline - indicates that the associated account is delegated. - * * Online - indicates that the associated account used as part of the delegation - * pool. - * * NotParticipating - indicates that the associated account is neither a - * delegator nor a delegate. - */ - status: string; - /** - * The count of all applications that have been opted in, equivalent to the count - * of application local data (AppLocalState objects) stored in this account. - */ - totalAppsOptedIn: number | bigint; - /** - * The count of all assets that have been opted in, equivalent to the count of - * AssetHolding objects held by this account. - */ - totalAssetsOptedIn: number | bigint; - /** - * The count of all apps (AppParams objects) created by this account. - */ - totalCreatedApps: number | bigint; - /** - * The count of all assets (AssetParams objects) created by this account. - */ - totalCreatedAssets: number | bigint; - /** - * (appl) applications local data stored in this account. - * Note the raw object uses `map[int] -> AppLocalState` for this type. - */ - appsLocalState?: ApplicationLocalState[]; - /** - * (teap) the sum of all extra application program pages for this account. - */ - appsTotalExtraPages?: number | bigint; - /** - * (tsch) stores the sum of all of the local schemas and global schemas in this - * account. - * Note: the raw account uses `StateSchema` for this type. - */ - appsTotalSchema?: ApplicationStateSchema; - /** - * (asset) assets held by this account. - * Note the raw object uses `map[int] -> AssetHolding` for this type. - */ - assets?: AssetHolding[]; - /** - * (spend) the address against which signing should be checked. If empty, the - * address of the current account is used. This field can be updated in any - * transaction by setting the RekeyTo field. - */ - authAddr?: string; - /** - * (appp) parameters of applications created by this account including app global - * data. - * Note: the raw account uses `map[int] -> AppParams` for this type. - */ - createdApps?: Application[]; - /** - * (apar) parameters of assets created by this account. - * Note: the raw account uses `map[int] -> Asset` for this type. - */ - createdAssets?: Asset[]; - /** - * AccountParticipation describes the parameters used by this account in consensus - * protocol. - */ - participation?: AccountParticipation; - /** - * (ebase) used as part of the rewards computation. Only applicable to accounts - * which are participating. - */ - rewardBase?: number | bigint; - /** - * Indicates what type of signature is used by this account, must be one of: - * * sig - * * msig - * * lsig - */ - sigType?: string; - /** - * (tbxb) The total number of bytes used by this account's app's box keys and - * values. - */ - totalBoxBytes?: number | bigint; - /** - * (tbx) The number of existing boxes created by this account's app. - */ - totalBoxes?: number | bigint; - /** - * Creates a new `Account` object. - * @param address - the account public key - * @param amount - (algo) total number of MicroAlgos in the account - * @param amountWithoutPendingRewards - specifies the amount of MicroAlgos in the account, without the pending rewards. - * @param minBalance - MicroAlgo balance required by the account. - * The requirement grows based on asset and application usage. - * @param pendingRewards - amount of MicroAlgos of pending rewards in this account. - * @param rewards - (ern) total rewards of MicroAlgos the account has received, including pending - * rewards. - * @param round - The round for which this information is relevant. - * @param status - (onl) delegation status of the account's MicroAlgos - * * Offline - indicates that the associated account is delegated. - * * Online - indicates that the associated account used as part of the delegation - * pool. - * * NotParticipating - indicates that the associated account is neither a - * delegator nor a delegate. - * @param totalAppsOptedIn - The count of all applications that have been opted in, equivalent to the count - * of application local data (AppLocalState objects) stored in this account. - * @param totalAssetsOptedIn - The count of all assets that have been opted in, equivalent to the count of - * AssetHolding objects held by this account. - * @param totalCreatedApps - The count of all apps (AppParams objects) created by this account. - * @param totalCreatedAssets - The count of all assets (AssetParams objects) created by this account. - * @param appsLocalState - (appl) applications local data stored in this account. - * Note the raw object uses `map[int] -> AppLocalState` for this type. - * @param appsTotalExtraPages - (teap) the sum of all extra application program pages for this account. - * @param appsTotalSchema - (tsch) stores the sum of all of the local schemas and global schemas in this - * account. - * Note: the raw account uses `StateSchema` for this type. - * @param assets - (asset) assets held by this account. - * Note the raw object uses `map[int] -> AssetHolding` for this type. - * @param authAddr - (spend) the address against which signing should be checked. If empty, the - * address of the current account is used. This field can be updated in any - * transaction by setting the RekeyTo field. - * @param createdApps - (appp) parameters of applications created by this account including app global - * data. - * Note: the raw account uses `map[int] -> AppParams` for this type. - * @param createdAssets - (apar) parameters of assets created by this account. - * Note: the raw account uses `map[int] -> Asset` for this type. - * @param participation - AccountParticipation describes the parameters used by this account in consensus - * protocol. - * @param rewardBase - (ebase) used as part of the rewards computation. Only applicable to accounts - * which are participating. - * @param sigType - Indicates what type of signature is used by this account, must be one of: - * * sig - * * msig - * * lsig - * @param totalBoxBytes - (tbxb) The total number of bytes used by this account's app's box keys and - * values. - * @param totalBoxes - (tbx) The number of existing boxes created by this account's app. - */ - constructor({ address, amount, amountWithoutPendingRewards, minBalance, pendingRewards, rewards, round, status, totalAppsOptedIn, totalAssetsOptedIn, totalCreatedApps, totalCreatedAssets, appsLocalState, appsTotalExtraPages, appsTotalSchema, assets, authAddr, createdApps, createdAssets, participation, rewardBase, sigType, totalBoxBytes, totalBoxes, }: { - address: string; - amount: number | bigint; - amountWithoutPendingRewards: number | bigint; - minBalance: number | bigint; - pendingRewards: number | bigint; - rewards: number | bigint; - round: number | bigint; - status: string; - totalAppsOptedIn: number | bigint; - totalAssetsOptedIn: number | bigint; - totalCreatedApps: number | bigint; - totalCreatedAssets: number | bigint; - appsLocalState?: ApplicationLocalState[]; - appsTotalExtraPages?: number | bigint; - appsTotalSchema?: ApplicationStateSchema; - assets?: AssetHolding[]; - authAddr?: string; - createdApps?: Application[]; - createdAssets?: Asset[]; - participation?: AccountParticipation; - rewardBase?: number | bigint; - sigType?: string; - totalBoxBytes?: number | bigint; - totalBoxes?: number | bigint; - }); - static from_obj_for_encoding(data: Record): Account; -} -/** - * AccountApplicationResponse describes the account's application local state and - * global state (AppLocalState and AppParams, if either exists) for a specific - * application ID. Global state will only be returned if the provided address is - * the application's creator. - */ -export declare class AccountApplicationResponse extends BaseModel { - /** - * The round for which this information is relevant. - */ - round: number | bigint; - /** - * (appl) the application local data stored in this account. - * The raw account uses `AppLocalState` for this type. - */ - appLocalState?: ApplicationLocalState; - /** - * (appp) parameters of the application created by this account including app - * global data. - * The raw account uses `AppParams` for this type. - */ - createdApp?: ApplicationParams; - /** - * Creates a new `AccountApplicationResponse` object. - * @param round - The round for which this information is relevant. - * @param appLocalState - (appl) the application local data stored in this account. - * The raw account uses `AppLocalState` for this type. - * @param createdApp - (appp) parameters of the application created by this account including app - * global data. - * The raw account uses `AppParams` for this type. - */ - constructor({ round, appLocalState, createdApp, }: { - round: number | bigint; - appLocalState?: ApplicationLocalState; - createdApp?: ApplicationParams; - }); - static from_obj_for_encoding(data: Record): AccountApplicationResponse; -} -/** - * AccountAssetResponse describes the account's asset holding and asset parameters - * (if either exist) for a specific asset ID. Asset parameters will only be - * returned if the provided address is the asset's creator. - */ -export declare class AccountAssetResponse extends BaseModel { - /** - * The round for which this information is relevant. - */ - round: number | bigint; - /** - * (asset) Details about the asset held by this account. - * The raw account uses `AssetHolding` for this type. - */ - assetHolding?: AssetHolding; - /** - * (apar) parameters of the asset created by this account. - * The raw account uses `AssetParams` for this type. - */ - createdAsset?: AssetParams; - /** - * Creates a new `AccountAssetResponse` object. - * @param round - The round for which this information is relevant. - * @param assetHolding - (asset) Details about the asset held by this account. - * The raw account uses `AssetHolding` for this type. - * @param createdAsset - (apar) parameters of the asset created by this account. - * The raw account uses `AssetParams` for this type. - */ - constructor({ round, assetHolding, createdAsset, }: { - round: number | bigint; - assetHolding?: AssetHolding; - createdAsset?: AssetParams; - }); - static from_obj_for_encoding(data: Record): AccountAssetResponse; -} -/** - * AccountParticipation describes the parameters used by this account in consensus - * protocol. - */ -export declare class AccountParticipation extends BaseModel { - /** - * (sel) Selection public key (if any) currently registered for this round. - */ - selectionParticipationKey: Uint8Array; - /** - * (voteFst) First round for which this participation is valid. - */ - voteFirstValid: number | bigint; - /** - * (voteKD) Number of subkeys in each batch of participation keys. - */ - voteKeyDilution: number | bigint; - /** - * (voteLst) Last round for which this participation is valid. - */ - voteLastValid: number | bigint; - /** - * (vote) root participation public key (if any) currently registered for this - * round. - */ - voteParticipationKey: Uint8Array; - /** - * (stprf) Root of the state proof key (if any) - */ - stateProofKey?: Uint8Array; - /** - * Creates a new `AccountParticipation` object. - * @param selectionParticipationKey - (sel) Selection public key (if any) currently registered for this round. - * @param voteFirstValid - (voteFst) First round for which this participation is valid. - * @param voteKeyDilution - (voteKD) Number of subkeys in each batch of participation keys. - * @param voteLastValid - (voteLst) Last round for which this participation is valid. - * @param voteParticipationKey - (vote) root participation public key (if any) currently registered for this - * round. - * @param stateProofKey - (stprf) Root of the state proof key (if any) - */ - constructor({ selectionParticipationKey, voteFirstValid, voteKeyDilution, voteLastValid, voteParticipationKey, stateProofKey, }: { - selectionParticipationKey: string | Uint8Array; - voteFirstValid: number | bigint; - voteKeyDilution: number | bigint; - voteLastValid: number | bigint; - voteParticipationKey: string | Uint8Array; - stateProofKey?: string | Uint8Array; - }); - static from_obj_for_encoding(data: Record): AccountParticipation; -} -/** - * Application state delta. - */ -export declare class AccountStateDelta extends BaseModel { - address: string; - /** - * Application state delta. - */ - delta: EvalDeltaKeyValue[]; - /** - * Creates a new `AccountStateDelta` object. - * @param address - - * @param delta - Application state delta. - */ - constructor({ address, delta, }: { - address: string; - delta: EvalDeltaKeyValue[]; - }); - static from_obj_for_encoding(data: Record): AccountStateDelta; -} -/** - * Application index and its parameters - */ -export declare class Application extends BaseModel { - /** - * (appidx) application index. - */ - id: number | bigint; - /** - * (appparams) application parameters. - */ - params: ApplicationParams; - /** - * Creates a new `Application` object. - * @param id - (appidx) application index. - * @param params - (appparams) application parameters. - */ - constructor({ id, params, }: { - id: number | bigint; - params: ApplicationParams; - }); - static from_obj_for_encoding(data: Record): Application; -} -/** - * An application's initial global/local/box states that were accessed during - * simulation. - */ -export declare class ApplicationInitialStates extends BaseModel { - /** - * Application index. - */ - id: number | bigint; - /** - * An application's global/local/box state. - */ - appBoxes?: ApplicationKVStorage; - /** - * An application's global/local/box state. - */ - appGlobals?: ApplicationKVStorage; - /** - * An application's initial local states tied to different accounts. - */ - appLocals?: ApplicationKVStorage[]; - /** - * Creates a new `ApplicationInitialStates` object. - * @param id - Application index. - * @param appBoxes - An application's global/local/box state. - * @param appGlobals - An application's global/local/box state. - * @param appLocals - An application's initial local states tied to different accounts. - */ - constructor({ id, appBoxes, appGlobals, appLocals, }: { - id: number | bigint; - appBoxes?: ApplicationKVStorage; - appGlobals?: ApplicationKVStorage; - appLocals?: ApplicationKVStorage[]; - }); - static from_obj_for_encoding(data: Record): ApplicationInitialStates; -} -/** - * An application's global/local/box state. - */ -export declare class ApplicationKVStorage extends BaseModel { - /** - * Key-Value pairs representing application states. - */ - kvs: AvmKeyValue[]; - /** - * The address of the account associated with the local state. - */ - account?: string; - /** - * Creates a new `ApplicationKVStorage` object. - * @param kvs - Key-Value pairs representing application states. - * @param account - The address of the account associated with the local state. - */ - constructor({ kvs, account }: { - kvs: AvmKeyValue[]; - account?: string; - }); - static from_obj_for_encoding(data: Record): ApplicationKVStorage; -} -/** - * References an account's local state for an application. - */ -export declare class ApplicationLocalReference extends BaseModel { - /** - * Address of the account with the local state. - */ - account: string; - /** - * Application ID of the local state application. - */ - app: number | bigint; - /** - * Creates a new `ApplicationLocalReference` object. - * @param account - Address of the account with the local state. - * @param app - Application ID of the local state application. - */ - constructor({ account, app }: { - account: string; - app: number | bigint; - }); - static from_obj_for_encoding(data: Record): ApplicationLocalReference; -} -/** - * Stores local state associated with an application. - */ -export declare class ApplicationLocalState extends BaseModel { - /** - * The application which this local state is for. - */ - id: number | bigint; - /** - * (hsch) schema. - */ - schema: ApplicationStateSchema; - /** - * (tkv) storage. - */ - keyValue?: TealKeyValue[]; - /** - * Creates a new `ApplicationLocalState` object. - * @param id - The application which this local state is for. - * @param schema - (hsch) schema. - * @param keyValue - (tkv) storage. - */ - constructor({ id, schema, keyValue, }: { - id: number | bigint; - schema: ApplicationStateSchema; - keyValue?: TealKeyValue[]; - }); - static from_obj_for_encoding(data: Record): ApplicationLocalState; -} -/** - * Stores the global information associated with an application. - */ -export declare class ApplicationParams extends BaseModel { - /** - * (approv) approval program. - */ - approvalProgram: Uint8Array; - /** - * (clearp) approval program. - */ - clearStateProgram: Uint8Array; - /** - * The address that created this application. This is the address where the - * parameters and global state for this application can be found. - */ - creator: string; - /** - * (epp) the amount of extra program pages available to this app. - */ - extraProgramPages?: number | bigint; - /** - * (gs) global state - */ - globalState?: TealKeyValue[]; - /** - * (gsch) global schema - */ - globalStateSchema?: ApplicationStateSchema; - /** - * (lsch) local schema - */ - localStateSchema?: ApplicationStateSchema; - /** - * Creates a new `ApplicationParams` object. - * @param approvalProgram - (approv) approval program. - * @param clearStateProgram - (clearp) approval program. - * @param creator - The address that created this application. This is the address where the - * parameters and global state for this application can be found. - * @param extraProgramPages - (epp) the amount of extra program pages available to this app. - * @param globalState - (gs) global state - * @param globalStateSchema - (gsch) global schema - * @param localStateSchema - (lsch) local schema - */ - constructor({ approvalProgram, clearStateProgram, creator, extraProgramPages, globalState, globalStateSchema, localStateSchema, }: { - approvalProgram: string | Uint8Array; - clearStateProgram: string | Uint8Array; - creator: string; - extraProgramPages?: number | bigint; - globalState?: TealKeyValue[]; - globalStateSchema?: ApplicationStateSchema; - localStateSchema?: ApplicationStateSchema; - }); - static from_obj_for_encoding(data: Record): ApplicationParams; -} -/** - * An operation against an application's global/local/box state. - */ -export declare class ApplicationStateOperation extends BaseModel { - /** - * Type of application state. Value `g` is **global state**, `l` is **local - * state**, `b` is **boxes**. - */ - appStateType: string; - /** - * The key (name) of the global/local/box state. - */ - key: Uint8Array; - /** - * Operation type. Value `w` is **write**, `d` is **delete**. - */ - operation: string; - /** - * For local state changes, the address of the account associated with the local - * state. - */ - account?: string; - /** - * Represents an AVM value. - */ - newValue?: AvmValue; - /** - * Creates a new `ApplicationStateOperation` object. - * @param appStateType - Type of application state. Value `g` is **global state**, `l` is **local - * state**, `b` is **boxes**. - * @param key - The key (name) of the global/local/box state. - * @param operation - Operation type. Value `w` is **write**, `d` is **delete**. - * @param account - For local state changes, the address of the account associated with the local - * state. - * @param newValue - Represents an AVM value. - */ - constructor({ appStateType, key, operation, account, newValue, }: { - appStateType: string; - key: string | Uint8Array; - operation: string; - account?: string; - newValue?: AvmValue; - }); - static from_obj_for_encoding(data: Record): ApplicationStateOperation; -} -/** - * Specifies maximums on the number of each type that may be stored. - */ -export declare class ApplicationStateSchema extends BaseModel { - /** - * (nui) num of uints. - */ - numUint: number | bigint; - /** - * (nbs) num of byte slices. - */ - numByteSlice: number | bigint; - /** - * Creates a new `ApplicationStateSchema` object. - * @param numUint - (nui) num of uints. - * @param numByteSlice - (nbs) num of byte slices. - */ - constructor({ numUint, numByteSlice, }: { - numUint: number | bigint; - numByteSlice: number | bigint; - }); - static from_obj_for_encoding(data: Record): ApplicationStateSchema; -} -/** - * Specifies both the unique identifier and the parameters for an asset - */ -export declare class Asset extends BaseModel { - /** - * unique asset identifier - */ - index: number | bigint; - /** - * AssetParams specifies the parameters for an asset. - * (apar) when part of an AssetConfig transaction. - * Definition: - * data/transactions/asset.go : AssetParams - */ - params: AssetParams; - /** - * Creates a new `Asset` object. - * @param index - unique asset identifier - * @param params - AssetParams specifies the parameters for an asset. - * (apar) when part of an AssetConfig transaction. - * Definition: - * data/transactions/asset.go : AssetParams - */ - constructor({ index, params, }: { - index: number | bigint; - params: AssetParams; - }); - static from_obj_for_encoding(data: Record): Asset; -} -/** - * Describes an asset held by an account. - * Definition: - * data/basics/userBalance.go : AssetHolding - */ -export declare class AssetHolding extends BaseModel { - /** - * (a) number of units held. - */ - amount: number | bigint; - /** - * Asset ID of the holding. - */ - assetId: number | bigint; - /** - * (f) whether or not the holding is frozen. - */ - isFrozen: boolean; - /** - * Creates a new `AssetHolding` object. - * @param amount - (a) number of units held. - * @param assetId - Asset ID of the holding. - * @param isFrozen - (f) whether or not the holding is frozen. - */ - constructor({ amount, assetId, isFrozen, }: { - amount: number | bigint; - assetId: number | bigint; - isFrozen: boolean; - }); - static from_obj_for_encoding(data: Record): AssetHolding; -} -/** - * References an asset held by an account. - */ -export declare class AssetHoldingReference extends BaseModel { - /** - * Address of the account holding the asset. - */ - account: string; - /** - * Asset ID of the holding. - */ - asset: number | bigint; - /** - * Creates a new `AssetHoldingReference` object. - * @param account - Address of the account holding the asset. - * @param asset - Asset ID of the holding. - */ - constructor({ account, asset }: { - account: string; - asset: number | bigint; - }); - static from_obj_for_encoding(data: Record): AssetHoldingReference; -} -/** - * AssetParams specifies the parameters for an asset. - * (apar) when part of an AssetConfig transaction. - * Definition: - * data/transactions/asset.go : AssetParams - */ -export declare class AssetParams extends BaseModel { - /** - * The address that created this asset. This is the address where the parameters - * for this asset can be found, and also the address where unwanted asset units can - * be sent in the worst case. - */ - creator: string; - /** - * (dc) The number of digits to use after the decimal point when displaying this - * asset. If 0, the asset is not divisible. If 1, the base unit of the asset is in - * tenths. If 2, the base unit of the asset is in hundredths, and so on. This value - * must be between 0 and 19 (inclusive). - */ - decimals: number | bigint; - /** - * (t) The total number of units of this asset. - */ - total: number | bigint; - /** - * (c) Address of account used to clawback holdings of this asset. If empty, - * clawback is not permitted. - */ - clawback?: string; - /** - * (df) Whether holdings of this asset are frozen by default. - */ - defaultFrozen?: boolean; - /** - * (f) Address of account used to freeze holdings of this asset. If empty, freezing - * is not permitted. - */ - freeze?: string; - /** - * (m) Address of account used to manage the keys of this asset and to destroy it. - */ - manager?: string; - /** - * (am) A commitment to some unspecified asset metadata. The format of this - * metadata is up to the application. - */ - metadataHash?: Uint8Array; - /** - * (an) Name of this asset, as supplied by the creator. Included only when the - * asset name is composed of printable utf-8 characters. - */ - name?: string; - /** - * Base64 encoded name of this asset, as supplied by the creator. - */ - nameB64?: Uint8Array; - /** - * (r) Address of account holding reserve (non-minted) units of this asset. - */ - reserve?: string; - /** - * (un) Name of a unit of this asset, as supplied by the creator. Included only - * when the name of a unit of this asset is composed of printable utf-8 characters. - */ - unitName?: string; - /** - * Base64 encoded name of a unit of this asset, as supplied by the creator. - */ - unitNameB64?: Uint8Array; - /** - * (au) URL where more information about the asset can be retrieved. Included only - * when the URL is composed of printable utf-8 characters. - */ - url?: string; - /** - * Base64 encoded URL where more information about the asset can be retrieved. - */ - urlB64?: Uint8Array; - /** - * Creates a new `AssetParams` object. - * @param creator - The address that created this asset. This is the address where the parameters - * for this asset can be found, and also the address where unwanted asset units can - * be sent in the worst case. - * @param decimals - (dc) The number of digits to use after the decimal point when displaying this - * asset. If 0, the asset is not divisible. If 1, the base unit of the asset is in - * tenths. If 2, the base unit of the asset is in hundredths, and so on. This value - * must be between 0 and 19 (inclusive). - * @param total - (t) The total number of units of this asset. - * @param clawback - (c) Address of account used to clawback holdings of this asset. If empty, - * clawback is not permitted. - * @param defaultFrozen - (df) Whether holdings of this asset are frozen by default. - * @param freeze - (f) Address of account used to freeze holdings of this asset. If empty, freezing - * is not permitted. - * @param manager - (m) Address of account used to manage the keys of this asset and to destroy it. - * @param metadataHash - (am) A commitment to some unspecified asset metadata. The format of this - * metadata is up to the application. - * @param name - (an) Name of this asset, as supplied by the creator. Included only when the - * asset name is composed of printable utf-8 characters. - * @param nameB64 - Base64 encoded name of this asset, as supplied by the creator. - * @param reserve - (r) Address of account holding reserve (non-minted) units of this asset. - * @param unitName - (un) Name of a unit of this asset, as supplied by the creator. Included only - * when the name of a unit of this asset is composed of printable utf-8 characters. - * @param unitNameB64 - Base64 encoded name of a unit of this asset, as supplied by the creator. - * @param url - (au) URL where more information about the asset can be retrieved. Included only - * when the URL is composed of printable utf-8 characters. - * @param urlB64 - Base64 encoded URL where more information about the asset can be retrieved. - */ - constructor({ creator, decimals, total, clawback, defaultFrozen, freeze, manager, metadataHash, name, nameB64, reserve, unitName, unitNameB64, url, urlB64, }: { - creator: string; - decimals: number | bigint; - total: number | bigint; - clawback?: string; - defaultFrozen?: boolean; - freeze?: string; - manager?: string; - metadataHash?: string | Uint8Array; - name?: string; - nameB64?: string | Uint8Array; - reserve?: string; - unitName?: string; - unitNameB64?: string | Uint8Array; - url?: string; - urlB64?: string | Uint8Array; - }); - static from_obj_for_encoding(data: Record): AssetParams; -} -/** - * Represents an AVM key-value pair in an application store. - */ -export declare class AvmKeyValue extends BaseModel { - key: Uint8Array; - /** - * Represents an AVM value. - */ - value: AvmValue; - /** - * Creates a new `AvmKeyValue` object. - * @param key - - * @param value - Represents an AVM value. - */ - constructor({ key, value }: { - key: string | Uint8Array; - value: AvmValue; - }); - static from_obj_for_encoding(data: Record): AvmKeyValue; -} -/** - * Represents an AVM value. - */ -export declare class AvmValue extends BaseModel { - /** - * value type. Value `1` refers to **bytes**, value `2` refers to **uint64** - */ - type: number | bigint; - /** - * bytes value. - */ - bytes?: Uint8Array; - /** - * uint value. - */ - uint?: number | bigint; - /** - * Creates a new `AvmValue` object. - * @param type - value type. Value `1` refers to **bytes**, value `2` refers to **uint64** - * @param bytes - bytes value. - * @param uint - uint value. - */ - constructor({ type, bytes, uint, }: { - type: number | bigint; - bytes?: string | Uint8Array; - uint?: number | bigint; - }); - static from_obj_for_encoding(data: Record): AvmValue; -} -/** - * Hash of a block header. - */ -export declare class BlockHashResponse extends BaseModel { - /** - * Block header hash. - */ - blockhash: string; - /** - * Creates a new `BlockHashResponse` object. - * @param blockhash - Block header hash. - */ - constructor({ blockhash }: { - blockhash: string; - }); - static from_obj_for_encoding(data: Record): BlockHashResponse; -} -/** - * Encoded block object. - */ -export declare class BlockResponse extends BaseModel { - /** - * Block header data. - */ - block: BlockHeader; - /** - * Optional certificate object. This is only included when the format is set to - * message pack. - */ - cert?: Record; - /** - * Creates a new `BlockResponse` object. - * @param block - Block header data. - * @param cert - Optional certificate object. This is only included when the format is set to - * message pack. - */ - constructor({ block, cert, }: { - block: BlockHeader; - cert?: Record; - }); - static from_obj_for_encoding(data: Record): BlockResponse; -} -/** - * Top level transaction IDs in a block. - */ -export declare class BlockTxidsResponse extends BaseModel { - /** - * Block transaction IDs. - */ - blocktxids: string[]; - /** - * Creates a new `BlockTxidsResponse` object. - * @param blocktxids - Block transaction IDs. - */ - constructor({ blocktxids }: { - blocktxids: string[]; - }); - static from_obj_for_encoding(data: Record): BlockTxidsResponse; -} -/** - * Box name and its content. - */ -export declare class Box extends BaseModel { - /** - * (name) box name, base64 encoded - */ - name: Uint8Array; - /** - * The round for which this information is relevant - */ - round: number | bigint; - /** - * (value) box value, base64 encoded. - */ - value: Uint8Array; - /** - * Creates a new `Box` object. - * @param name - (name) box name, base64 encoded - * @param round - The round for which this information is relevant - * @param value - (value) box value, base64 encoded. - */ - constructor({ name, round, value, }: { - name: string | Uint8Array; - round: number | bigint; - value: string | Uint8Array; - }); - static from_obj_for_encoding(data: Record): Box; -} -/** - * Box descriptor describes a Box. - */ -export declare class BoxDescriptor extends BaseModel { - /** - * Base64 encoded box name - */ - name: Uint8Array; - /** - * Creates a new `BoxDescriptor` object. - * @param name - Base64 encoded box name - */ - constructor({ name }: { - name: string | Uint8Array; - }); - static from_obj_for_encoding(data: Record): BoxDescriptor; -} -/** - * References a box of an application. - */ -export declare class BoxReference extends BaseModel { - /** - * Application ID which this box belongs to - */ - app: number | bigint; - /** - * Base64 encoded box name - */ - name: Uint8Array; - /** - * Creates a new `BoxReference` object. - * @param app - Application ID which this box belongs to - * @param name - Base64 encoded box name - */ - constructor({ app, name, }: { - app: number | bigint; - name: string | Uint8Array; - }); - static from_obj_for_encoding(data: Record): BoxReference; -} -/** - * Box names of an application - */ -export declare class BoxesResponse extends BaseModel { - boxes: BoxDescriptor[]; - /** - * Creates a new `BoxesResponse` object. - * @param boxes - - */ - constructor({ boxes }: { - boxes: BoxDescriptor[]; - }); - static from_obj_for_encoding(data: Record): BoxesResponse; -} -export declare class BuildVersion extends BaseModel { - branch: string; - buildNumber: number | bigint; - channel: string; - commitHash: string; - major: number | bigint; - minor: number | bigint; - /** - * Creates a new `BuildVersion` object. - * @param branch - - * @param buildNumber - - * @param channel - - * @param commitHash - - * @param major - - * @param minor - - */ - constructor({ branch, buildNumber, channel, commitHash, major, minor, }: { - branch: string; - buildNumber: number | bigint; - channel: string; - commitHash: string; - major: number | bigint; - minor: number | bigint; - }); - static from_obj_for_encoding(data: Record): BuildVersion; -} -/** - * Teal compile Result - */ -export declare class CompileResponse extends BaseModel { - /** - * base32 SHA512_256 of program bytes (Address style) - */ - hash: string; - /** - * base64 encoded program bytes - */ - result: string; - /** - * JSON of the source map - */ - sourcemap?: Record; - /** - * Creates a new `CompileResponse` object. - * @param hash - base32 SHA512_256 of program bytes (Address style) - * @param result - base64 encoded program bytes - * @param sourcemap - JSON of the source map - */ - constructor({ hash, result, sourcemap, }: { - hash: string; - result: string; - sourcemap?: Record; - }); - static from_obj_for_encoding(data: Record): CompileResponse; -} -/** - * Teal disassembly Result - */ -export declare class DisassembleResponse extends BaseModel { - /** - * disassembled Teal code - */ - result: string; - /** - * Creates a new `DisassembleResponse` object. - * @param result - disassembled Teal code - */ - constructor({ result }: { - result: string; - }); - static from_obj_for_encoding(data: Record): DisassembleResponse; -} -/** - * Request data type for dryrun endpoint. Given the Transactions and simulated - * ledger state upload, run TEAL scripts and return debugging information. - */ -export declare class DryrunRequest extends BaseModel { - accounts: Account[]; - apps: Application[]; - /** - * LatestTimestamp is available to some TEAL scripts. Defaults to the latest - * confirmed timestamp this algod is attached to. - */ - latestTimestamp: number | bigint; - /** - * ProtocolVersion specifies a specific version string to operate under, otherwise - * whatever the current protocol of the network this algod is running in. - */ - protocolVersion: string; - /** - * Round is available to some TEAL scripts. Defaults to the current round on the - * network this algod is attached to. - */ - round: number | bigint; - sources: DryrunSource[]; - txns: EncodedSignedTransaction[]; - /** - * Creates a new `DryrunRequest` object. - * @param accounts - - * @param apps - - * @param latestTimestamp - LatestTimestamp is available to some TEAL scripts. Defaults to the latest - * confirmed timestamp this algod is attached to. - * @param protocolVersion - ProtocolVersion specifies a specific version string to operate under, otherwise - * whatever the current protocol of the network this algod is running in. - * @param round - Round is available to some TEAL scripts. Defaults to the current round on the - * network this algod is attached to. - * @param sources - - * @param txns - - */ - constructor({ accounts, apps, latestTimestamp, protocolVersion, round, sources, txns, }: { - accounts: Account[]; - apps: Application[]; - latestTimestamp: number | bigint; - protocolVersion: string; - round: number | bigint; - sources: DryrunSource[]; - txns: EncodedSignedTransaction[]; - }); - static from_obj_for_encoding(data: Record): DryrunRequest; -} -/** - * DryrunResponse contains per-txn debug information from a dryrun. - */ -export declare class DryrunResponse extends BaseModel { - error: string; - /** - * Protocol version is the protocol version Dryrun was operated under. - */ - protocolVersion: string; - txns: DryrunTxnResult[]; - /** - * Creates a new `DryrunResponse` object. - * @param error - - * @param protocolVersion - Protocol version is the protocol version Dryrun was operated under. - * @param txns - - */ - constructor({ error, protocolVersion, txns, }: { - error: string; - protocolVersion: string; - txns: DryrunTxnResult[]; - }); - static from_obj_for_encoding(data: Record): DryrunResponse; -} -/** - * DryrunSource is TEAL source text that gets uploaded, compiled, and inserted into - * transactions or application state. - */ -export declare class DryrunSource extends BaseModel { - /** - * FieldName is what kind of sources this is. If lsig then it goes into the - * transactions[this.TxnIndex].LogicSig. If approv or clearp it goes into the - * Approval Program or Clear State Program of application[this.AppIndex]. - */ - fieldName: string; - source: string; - txnIndex: number | bigint; - appIndex: number | bigint; - /** - * Creates a new `DryrunSource` object. - * @param fieldName - FieldName is what kind of sources this is. If lsig then it goes into the - * transactions[this.TxnIndex].LogicSig. If approv or clearp it goes into the - * Approval Program or Clear State Program of application[this.AppIndex]. - * @param source - - * @param txnIndex - - * @param appIndex - - */ - constructor({ fieldName, source, txnIndex, appIndex, }: { - fieldName: string; - source: string; - txnIndex: number | bigint; - appIndex: number | bigint; - }); - static from_obj_for_encoding(data: Record): DryrunSource; -} -/** - * Stores the TEAL eval step data - */ -export declare class DryrunState extends BaseModel { - /** - * Line number - */ - line: number | bigint; - /** - * Program counter - */ - pc: number | bigint; - stack: TealValue[]; - /** - * Evaluation error if any - */ - error?: string; - scratch?: TealValue[]; - /** - * Creates a new `DryrunState` object. - * @param line - Line number - * @param pc - Program counter - * @param stack - - * @param error - Evaluation error if any - * @param scratch - - */ - constructor({ line, pc, stack, error, scratch, }: { - line: number | bigint; - pc: number | bigint; - stack: TealValue[]; - error?: string; - scratch?: TealValue[]; - }); - static from_obj_for_encoding(data: Record): DryrunState; -} -/** - * DryrunTxnResult contains any LogicSig or ApplicationCall program debug - * information and state updates from a dryrun. - */ -export declare class DryrunTxnResult extends BaseModel { - /** - * Disassembled program line by line. - */ - disassembly: string[]; - appCallMessages?: string[]; - appCallTrace?: DryrunState[]; - /** - * Budget added during execution of app call transaction. - */ - budgetAdded?: number | bigint; - /** - * Budget consumed during execution of app call transaction. - */ - budgetConsumed?: number | bigint; - /** - * Application state delta. - */ - globalDelta?: EvalDeltaKeyValue[]; - localDeltas?: AccountStateDelta[]; - /** - * Disassembled lsig program line by line. - */ - logicSigDisassembly?: string[]; - logicSigMessages?: string[]; - logicSigTrace?: DryrunState[]; - logs?: Uint8Array[]; - /** - * Creates a new `DryrunTxnResult` object. - * @param disassembly - Disassembled program line by line. - * @param appCallMessages - - * @param appCallTrace - - * @param budgetAdded - Budget added during execution of app call transaction. - * @param budgetConsumed - Budget consumed during execution of app call transaction. - * @param globalDelta - Application state delta. - * @param localDeltas - - * @param logicSigDisassembly - Disassembled lsig program line by line. - * @param logicSigMessages - - * @param logicSigTrace - - * @param logs - - */ - constructor({ disassembly, appCallMessages, appCallTrace, budgetAdded, budgetConsumed, globalDelta, localDeltas, logicSigDisassembly, logicSigMessages, logicSigTrace, logs, }: { - disassembly: string[]; - appCallMessages?: string[]; - appCallTrace?: DryrunState[]; - budgetAdded?: number | bigint; - budgetConsumed?: number | bigint; - globalDelta?: EvalDeltaKeyValue[]; - localDeltas?: AccountStateDelta[]; - logicSigDisassembly?: string[]; - logicSigMessages?: string[]; - logicSigTrace?: DryrunState[]; - logs?: Uint8Array[]; - }); - static from_obj_for_encoding(data: Record): DryrunTxnResult; -} -/** - * An error response with optional data field. - */ -export declare class ErrorResponse extends BaseModel { - message: string; - data?: Record; - /** - * Creates a new `ErrorResponse` object. - * @param message - - * @param data - - */ - constructor({ message, data, }: { - message: string; - data?: Record; - }); - static from_obj_for_encoding(data: Record): ErrorResponse; -} -/** - * Represents a TEAL value delta. - */ -export declare class EvalDelta extends BaseModel { - /** - * (at) delta action. - */ - action: number | bigint; - /** - * (bs) bytes value. - */ - bytes?: string; - /** - * (ui) uint value. - */ - uint?: number | bigint; - /** - * Creates a new `EvalDelta` object. - * @param action - (at) delta action. - * @param bytes - (bs) bytes value. - * @param uint - (ui) uint value. - */ - constructor({ action, bytes, uint, }: { - action: number | bigint; - bytes?: string; - uint?: number | bigint; - }); - static from_obj_for_encoding(data: Record): EvalDelta; -} -/** - * Key-value pairs for StateDelta. - */ -export declare class EvalDeltaKeyValue extends BaseModel { - key: string; - /** - * Represents a TEAL value delta. - */ - value: EvalDelta; - /** - * Creates a new `EvalDeltaKeyValue` object. - * @param key - - * @param value - Represents a TEAL value delta. - */ - constructor({ key, value }: { - key: string; - value: EvalDelta; - }); - static from_obj_for_encoding(data: Record): EvalDeltaKeyValue; -} -/** - * Response containing the timestamp offset in seconds - */ -export declare class GetBlockTimeStampOffsetResponse extends BaseModel { - /** - * Timestamp offset in seconds. - */ - offset: number | bigint; - /** - * Creates a new `GetBlockTimeStampOffsetResponse` object. - * @param offset - Timestamp offset in seconds. - */ - constructor({ offset }: { - offset: number | bigint; - }); - static from_obj_for_encoding(data: Record): GetBlockTimeStampOffsetResponse; -} -/** - * Response containing the ledger's minimum sync round - */ -export declare class GetSyncRoundResponse extends BaseModel { - /** - * The minimum sync round for the ledger. - */ - round: number | bigint; - /** - * Creates a new `GetSyncRoundResponse` object. - * @param round - The minimum sync round for the ledger. - */ - constructor({ round }: { - round: number | bigint; - }); - static from_obj_for_encoding(data: Record): GetSyncRoundResponse; -} -/** - * A single Delta containing the key, the previous value and the current value for - * a single round. - */ -export declare class KvDelta extends BaseModel { - /** - * The key, base64 encoded. - */ - key?: Uint8Array; - /** - * The new value of the KV store entry, base64 encoded. - */ - value?: Uint8Array; - /** - * Creates a new `KvDelta` object. - * @param key - The key, base64 encoded. - * @param value - The new value of the KV store entry, base64 encoded. - */ - constructor({ key, value, }: { - key?: string | Uint8Array; - value?: string | Uint8Array; - }); - static from_obj_for_encoding(data: Record): KvDelta; -} -/** - * Contains a ledger delta for a single transaction group - */ -export declare class LedgerStateDeltaForTransactionGroup extends BaseModel { - /** - * Ledger StateDelta object - */ - delta: Record; - ids: string[]; - /** - * Creates a new `LedgerStateDeltaForTransactionGroup` object. - * @param delta - Ledger StateDelta object - * @param ids - - */ - constructor({ delta, ids }: { - delta: Record; - ids: string[]; - }); - static from_obj_for_encoding(data: Record): LedgerStateDeltaForTransactionGroup; -} -/** - * Proof of membership and position of a light block header. - */ -export declare class LightBlockHeaderProof extends BaseModel { - /** - * The index of the light block header in the vector commitment tree - */ - index: number | bigint; - /** - * The encoded proof. - */ - proof: Uint8Array; - /** - * Represents the depth of the tree that is being proven, i.e. the number of edges - * from a leaf to the root. - */ - treedepth: number | bigint; - /** - * Creates a new `LightBlockHeaderProof` object. - * @param index - The index of the light block header in the vector commitment tree - * @param proof - The encoded proof. - * @param treedepth - Represents the depth of the tree that is being proven, i.e. the number of edges - * from a leaf to the root. - */ - constructor({ index, proof, treedepth, }: { - index: number | bigint; - proof: string | Uint8Array; - treedepth: number | bigint; - }); - static from_obj_for_encoding(data: Record): LightBlockHeaderProof; -} -/** - * - */ -export declare class NodeStatusResponse extends BaseModel { - /** - * CatchupTime in nanoseconds - */ - catchupTime: number | bigint; - /** - * LastRound indicates the last round seen - */ - lastRound: number | bigint; - /** - * LastVersion indicates the last consensus version supported - */ - lastVersion: string; - /** - * NextVersion of consensus protocol to use - */ - nextVersion: string; - /** - * NextVersionRound is the round at which the next consensus version will apply - */ - nextVersionRound: number | bigint; - /** - * NextVersionSupported indicates whether the next consensus version is supported - * by this node - */ - nextVersionSupported: boolean; - /** - * StoppedAtUnsupportedRound indicates that the node does not support the new - * rounds and has stopped making progress - */ - stoppedAtUnsupportedRound: boolean; - /** - * TimeSinceLastRound in nanoseconds - */ - timeSinceLastRound: number | bigint; - /** - * The current catchpoint that is being caught up to - */ - catchpoint?: string; - /** - * The number of blocks that have already been obtained by the node as part of the - * catchup - */ - catchpointAcquiredBlocks?: number | bigint; - /** - * The number of accounts from the current catchpoint that have been processed so - * far as part of the catchup - */ - catchpointProcessedAccounts?: number | bigint; - /** - * The number of key-values (KVs) from the current catchpoint that have been - * processed so far as part of the catchup - */ - catchpointProcessedKvs?: number | bigint; - /** - * The total number of accounts included in the current catchpoint - */ - catchpointTotalAccounts?: number | bigint; - /** - * The total number of blocks that are required to complete the current catchpoint - * catchup - */ - catchpointTotalBlocks?: number | bigint; - /** - * The total number of key-values (KVs) included in the current catchpoint - */ - catchpointTotalKvs?: number | bigint; - /** - * The number of accounts from the current catchpoint that have been verified so - * far as part of the catchup - */ - catchpointVerifiedAccounts?: number | bigint; - /** - * The number of key-values (KVs) from the current catchpoint that have been - * verified so far as part of the catchup - */ - catchpointVerifiedKvs?: number | bigint; - /** - * The last catchpoint seen by the node - */ - lastCatchpoint?: string; - /** - * Upgrade delay - */ - upgradeDelay?: number | bigint; - /** - * Next protocol round - */ - upgradeNextProtocolVoteBefore?: number | bigint; - /** - * No votes cast for consensus upgrade - */ - upgradeNoVotes?: number | bigint; - /** - * This node's upgrade vote - */ - upgradeNodeVote?: boolean; - /** - * Total voting rounds for current upgrade - */ - upgradeVoteRounds?: number | bigint; - /** - * Total votes cast for consensus upgrade - */ - upgradeVotes?: number | bigint; - /** - * Yes votes required for consensus upgrade - */ - upgradeVotesRequired?: number | bigint; - /** - * Yes votes cast for consensus upgrade - */ - upgradeYesVotes?: number | bigint; - /** - * Creates a new `NodeStatusResponse` object. - * @param catchupTime - CatchupTime in nanoseconds - * @param lastRound - LastRound indicates the last round seen - * @param lastVersion - LastVersion indicates the last consensus version supported - * @param nextVersion - NextVersion of consensus protocol to use - * @param nextVersionRound - NextVersionRound is the round at which the next consensus version will apply - * @param nextVersionSupported - NextVersionSupported indicates whether the next consensus version is supported - * by this node - * @param stoppedAtUnsupportedRound - StoppedAtUnsupportedRound indicates that the node does not support the new - * rounds and has stopped making progress - * @param timeSinceLastRound - TimeSinceLastRound in nanoseconds - * @param catchpoint - The current catchpoint that is being caught up to - * @param catchpointAcquiredBlocks - The number of blocks that have already been obtained by the node as part of the - * catchup - * @param catchpointProcessedAccounts - The number of accounts from the current catchpoint that have been processed so - * far as part of the catchup - * @param catchpointProcessedKvs - The number of key-values (KVs) from the current catchpoint that have been - * processed so far as part of the catchup - * @param catchpointTotalAccounts - The total number of accounts included in the current catchpoint - * @param catchpointTotalBlocks - The total number of blocks that are required to complete the current catchpoint - * catchup - * @param catchpointTotalKvs - The total number of key-values (KVs) included in the current catchpoint - * @param catchpointVerifiedAccounts - The number of accounts from the current catchpoint that have been verified so - * far as part of the catchup - * @param catchpointVerifiedKvs - The number of key-values (KVs) from the current catchpoint that have been - * verified so far as part of the catchup - * @param lastCatchpoint - The last catchpoint seen by the node - * @param upgradeDelay - Upgrade delay - * @param upgradeNextProtocolVoteBefore - Next protocol round - * @param upgradeNoVotes - No votes cast for consensus upgrade - * @param upgradeNodeVote - This node's upgrade vote - * @param upgradeVoteRounds - Total voting rounds for current upgrade - * @param upgradeVotes - Total votes cast for consensus upgrade - * @param upgradeVotesRequired - Yes votes required for consensus upgrade - * @param upgradeYesVotes - Yes votes cast for consensus upgrade - */ - constructor({ catchupTime, lastRound, lastVersion, nextVersion, nextVersionRound, nextVersionSupported, stoppedAtUnsupportedRound, timeSinceLastRound, catchpoint, catchpointAcquiredBlocks, catchpointProcessedAccounts, catchpointProcessedKvs, catchpointTotalAccounts, catchpointTotalBlocks, catchpointTotalKvs, catchpointVerifiedAccounts, catchpointVerifiedKvs, lastCatchpoint, upgradeDelay, upgradeNextProtocolVoteBefore, upgradeNoVotes, upgradeNodeVote, upgradeVoteRounds, upgradeVotes, upgradeVotesRequired, upgradeYesVotes, }: { - catchupTime: number | bigint; - lastRound: number | bigint; - lastVersion: string; - nextVersion: string; - nextVersionRound: number | bigint; - nextVersionSupported: boolean; - stoppedAtUnsupportedRound: boolean; - timeSinceLastRound: number | bigint; - catchpoint?: string; - catchpointAcquiredBlocks?: number | bigint; - catchpointProcessedAccounts?: number | bigint; - catchpointProcessedKvs?: number | bigint; - catchpointTotalAccounts?: number | bigint; - catchpointTotalBlocks?: number | bigint; - catchpointTotalKvs?: number | bigint; - catchpointVerifiedAccounts?: number | bigint; - catchpointVerifiedKvs?: number | bigint; - lastCatchpoint?: string; - upgradeDelay?: number | bigint; - upgradeNextProtocolVoteBefore?: number | bigint; - upgradeNoVotes?: number | bigint; - upgradeNodeVote?: boolean; - upgradeVoteRounds?: number | bigint; - upgradeVotes?: number | bigint; - upgradeVotesRequired?: number | bigint; - upgradeYesVotes?: number | bigint; - }); - static from_obj_for_encoding(data: Record): NodeStatusResponse; -} -/** - * Details about a pending transaction. If the transaction was recently confirmed, - * includes confirmation details like the round and reward details. - */ -export declare class PendingTransactionResponse extends BaseModel { - /** - * Indicates that the transaction was kicked out of this node's transaction pool - * (and specifies why that happened). An empty string indicates the transaction - * wasn't kicked out of this node's txpool due to an error. - */ - poolError: string; - /** - * The raw signed transaction. - */ - txn: EncodedSignedTransaction; - /** - * The application index if the transaction was found and it created an - * application. - */ - applicationIndex?: number | bigint; - /** - * The number of the asset's unit that were transferred to the close-to address. - */ - assetClosingAmount?: number | bigint; - /** - * The asset index if the transaction was found and it created an asset. - */ - assetIndex?: number | bigint; - /** - * Rewards in microalgos applied to the close remainder to account. - */ - closeRewards?: number | bigint; - /** - * Closing amount for the transaction. - */ - closingAmount?: number | bigint; - /** - * The round where this transaction was confirmed, if present. - */ - confirmedRound?: number | bigint; - /** - * Global state key/value changes for the application being executed by this - * transaction. - */ - globalStateDelta?: EvalDeltaKeyValue[]; - /** - * Inner transactions produced by application execution. - */ - innerTxns?: PendingTransactionResponse[]; - /** - * Local state key/value changes for the application being executed by this - * transaction. - */ - localStateDelta?: AccountStateDelta[]; - /** - * Logs for the application being executed by this transaction. - */ - logs?: Uint8Array[]; - /** - * Rewards in microalgos applied to the receiver account. - */ - receiverRewards?: number | bigint; - /** - * Rewards in microalgos applied to the sender account. - */ - senderRewards?: number | bigint; - /** - * Creates a new `PendingTransactionResponse` object. - * @param poolError - Indicates that the transaction was kicked out of this node's transaction pool - * (and specifies why that happened). An empty string indicates the transaction - * wasn't kicked out of this node's txpool due to an error. - * @param txn - The raw signed transaction. - * @param applicationIndex - The application index if the transaction was found and it created an - * application. - * @param assetClosingAmount - The number of the asset's unit that were transferred to the close-to address. - * @param assetIndex - The asset index if the transaction was found and it created an asset. - * @param closeRewards - Rewards in microalgos applied to the close remainder to account. - * @param closingAmount - Closing amount for the transaction. - * @param confirmedRound - The round where this transaction was confirmed, if present. - * @param globalStateDelta - Global state key/value changes for the application being executed by this - * transaction. - * @param innerTxns - Inner transactions produced by application execution. - * @param localStateDelta - Local state key/value changes for the application being executed by this - * transaction. - * @param logs - Logs for the application being executed by this transaction. - * @param receiverRewards - Rewards in microalgos applied to the receiver account. - * @param senderRewards - Rewards in microalgos applied to the sender account. - */ - constructor({ poolError, txn, applicationIndex, assetClosingAmount, assetIndex, closeRewards, closingAmount, confirmedRound, globalStateDelta, innerTxns, localStateDelta, logs, receiverRewards, senderRewards, }: { - poolError: string; - txn: EncodedSignedTransaction; - applicationIndex?: number | bigint; - assetClosingAmount?: number | bigint; - assetIndex?: number | bigint; - closeRewards?: number | bigint; - closingAmount?: number | bigint; - confirmedRound?: number | bigint; - globalStateDelta?: EvalDeltaKeyValue[]; - innerTxns?: PendingTransactionResponse[]; - localStateDelta?: AccountStateDelta[]; - logs?: Uint8Array[]; - receiverRewards?: number | bigint; - senderRewards?: number | bigint; - }); - static from_obj_for_encoding(data: Record): PendingTransactionResponse; -} -/** - * A potentially truncated list of transactions currently in the node's transaction - * pool. You can compute whether or not the list is truncated if the number of - * elements in the **top-transactions** array is fewer than **total-transactions**. - */ -export declare class PendingTransactionsResponse extends BaseModel { - /** - * An array of signed transaction objects. - */ - topTransactions: EncodedSignedTransaction[]; - /** - * Total number of transactions in the pool. - */ - totalTransactions: number | bigint; - /** - * Creates a new `PendingTransactionsResponse` object. - * @param topTransactions - An array of signed transaction objects. - * @param totalTransactions - Total number of transactions in the pool. - */ - constructor({ topTransactions, totalTransactions, }: { - topTransactions: EncodedSignedTransaction[]; - totalTransactions: number | bigint; - }); - static from_obj_for_encoding(data: Record): PendingTransactionsResponse; -} -/** - * Transaction ID of the submission. - */ -export declare class PostTransactionsResponse extends BaseModel { - /** - * encoding of the transaction hash. - */ - txid: string; - /** - * Creates a new `PostTransactionsResponse` object. - * @param txid - encoding of the transaction hash. - */ - constructor({ txid }: { - txid: string; - }); - static from_obj_for_encoding(data: Record): PostTransactionsResponse; -} -/** - * A write operation into a scratch slot. - */ -export declare class ScratchChange extends BaseModel { - /** - * Represents an AVM value. - */ - newValue: AvmValue; - /** - * The scratch slot written. - */ - slot: number | bigint; - /** - * Creates a new `ScratchChange` object. - * @param newValue - Represents an AVM value. - * @param slot - The scratch slot written. - */ - constructor({ newValue, slot, }: { - newValue: AvmValue; - slot: number | bigint; - }); - static from_obj_for_encoding(data: Record): ScratchChange; -} -/** - * Initial states of resources that were accessed during simulation. - */ -export declare class SimulateInitialStates extends BaseModel { - /** - * The initial states of accessed application before simulation. The order of this - * array is arbitrary. - */ - appInitialStates?: ApplicationInitialStates[]; - /** - * Creates a new `SimulateInitialStates` object. - * @param appInitialStates - The initial states of accessed application before simulation. The order of this - * array is arbitrary. - */ - constructor({ appInitialStates, }: { - appInitialStates?: ApplicationInitialStates[]; - }); - static from_obj_for_encoding(data: Record): SimulateInitialStates; -} -/** - * Request type for simulation endpoint. - */ -export declare class SimulateRequest extends BaseModel { - /** - * The transaction groups to simulate. - */ - txnGroups: SimulateRequestTransactionGroup[]; - /** - * Allows transactions without signatures to be simulated as if they had correct - * signatures. - */ - allowEmptySignatures?: boolean; - /** - * Lifts limits on log opcode usage during simulation. - */ - allowMoreLogging?: boolean; - /** - * Allows access to unnamed resources during simulation. - */ - allowUnnamedResources?: boolean; - /** - * An object that configures simulation execution trace. - */ - execTraceConfig?: SimulateTraceConfig; - /** - * Applies extra opcode budget during simulation for each transaction group. - */ - extraOpcodeBudget?: number | bigint; - /** - * If provided, specifies the round preceding the simulation. State changes through - * this round will be used to run this simulation. Usually only the 4 most recent - * rounds will be available (controlled by the node config value MaxAcctLookback). - * If not specified, defaults to the latest available round. - */ - round?: number | bigint; - /** - * Creates a new `SimulateRequest` object. - * @param txnGroups - The transaction groups to simulate. - * @param allowEmptySignatures - Allows transactions without signatures to be simulated as if they had correct - * signatures. - * @param allowMoreLogging - Lifts limits on log opcode usage during simulation. - * @param allowUnnamedResources - Allows access to unnamed resources during simulation. - * @param execTraceConfig - An object that configures simulation execution trace. - * @param extraOpcodeBudget - Applies extra opcode budget during simulation for each transaction group. - * @param round - If provided, specifies the round preceding the simulation. State changes through - * this round will be used to run this simulation. Usually only the 4 most recent - * rounds will be available (controlled by the node config value MaxAcctLookback). - * If not specified, defaults to the latest available round. - */ - constructor({ txnGroups, allowEmptySignatures, allowMoreLogging, allowUnnamedResources, execTraceConfig, extraOpcodeBudget, round, }: { - txnGroups: SimulateRequestTransactionGroup[]; - allowEmptySignatures?: boolean; - allowMoreLogging?: boolean; - allowUnnamedResources?: boolean; - execTraceConfig?: SimulateTraceConfig; - extraOpcodeBudget?: number | bigint; - round?: number | bigint; - }); - static from_obj_for_encoding(data: Record): SimulateRequest; -} -/** - * A transaction group to simulate. - */ -export declare class SimulateRequestTransactionGroup extends BaseModel { - /** - * An atomic transaction group. - */ - txns: EncodedSignedTransaction[]; - /** - * Creates a new `SimulateRequestTransactionGroup` object. - * @param txns - An atomic transaction group. - */ - constructor({ txns }: { - txns: EncodedSignedTransaction[]; - }); - static from_obj_for_encoding(data: Record): SimulateRequestTransactionGroup; -} -/** - * Result of a transaction group simulation. - */ -export declare class SimulateResponse extends BaseModel { - /** - * The round immediately preceding this simulation. State changes through this - * round were used to run this simulation. - */ - lastRound: number | bigint; - /** - * A result object for each transaction group that was simulated. - */ - txnGroups: SimulateTransactionGroupResult[]; - /** - * The version of this response object. - */ - version: number | bigint; - /** - * The set of parameters and limits override during simulation. If this set of - * parameters is present, then evaluation parameters may differ from standard - * evaluation in certain ways. - */ - evalOverrides?: SimulationEvalOverrides; - /** - * An object that configures simulation execution trace. - */ - execTraceConfig?: SimulateTraceConfig; - /** - * Initial states of resources that were accessed during simulation. - */ - initialStates?: SimulateInitialStates; - /** - * Creates a new `SimulateResponse` object. - * @param lastRound - The round immediately preceding this simulation. State changes through this - * round were used to run this simulation. - * @param txnGroups - A result object for each transaction group that was simulated. - * @param version - The version of this response object. - * @param evalOverrides - The set of parameters and limits override during simulation. If this set of - * parameters is present, then evaluation parameters may differ from standard - * evaluation in certain ways. - * @param execTraceConfig - An object that configures simulation execution trace. - * @param initialStates - Initial states of resources that were accessed during simulation. - */ - constructor({ lastRound, txnGroups, version, evalOverrides, execTraceConfig, initialStates, }: { - lastRound: number | bigint; - txnGroups: SimulateTransactionGroupResult[]; - version: number | bigint; - evalOverrides?: SimulationEvalOverrides; - execTraceConfig?: SimulateTraceConfig; - initialStates?: SimulateInitialStates; - }); - static from_obj_for_encoding(data: Record): SimulateResponse; -} -/** - * An object that configures simulation execution trace. - */ -export declare class SimulateTraceConfig extends BaseModel { - /** - * A boolean option for opting in execution trace features simulation endpoint. - */ - enable?: boolean; - /** - * A boolean option enabling returning scratch slot changes together with execution - * trace during simulation. - */ - scratchChange?: boolean; - /** - * A boolean option enabling returning stack changes together with execution trace - * during simulation. - */ - stackChange?: boolean; - /** - * A boolean option enabling returning application state changes (global, local, - * and box changes) with the execution trace during simulation. - */ - stateChange?: boolean; - /** - * Creates a new `SimulateTraceConfig` object. - * @param enable - A boolean option for opting in execution trace features simulation endpoint. - * @param scratchChange - A boolean option enabling returning scratch slot changes together with execution - * trace during simulation. - * @param stackChange - A boolean option enabling returning stack changes together with execution trace - * during simulation. - * @param stateChange - A boolean option enabling returning application state changes (global, local, - * and box changes) with the execution trace during simulation. - */ - constructor({ enable, scratchChange, stackChange, stateChange, }: { - enable?: boolean; - scratchChange?: boolean; - stackChange?: boolean; - stateChange?: boolean; - }); - static from_obj_for_encoding(data: Record): SimulateTraceConfig; -} -/** - * Simulation result for an atomic transaction group - */ -export declare class SimulateTransactionGroupResult extends BaseModel { - /** - * Simulation result for individual transactions - */ - txnResults: SimulateTransactionResult[]; - /** - * Total budget added during execution of app calls in the transaction group. - */ - appBudgetAdded?: number | bigint; - /** - * Total budget consumed during execution of app calls in the transaction group. - */ - appBudgetConsumed?: number | bigint; - /** - * If present, indicates which transaction in this group caused the failure. This - * array represents the path to the failing transaction. Indexes are zero based, - * the first element indicates the top-level transaction, and successive elements - * indicate deeper inner transactions. - */ - failedAt?: (number | bigint)[]; - /** - * If present, indicates that the transaction group failed and specifies why that - * happened - */ - failureMessage?: string; - /** - * These are resources that were accessed by this group that would normally have - * caused failure, but were allowed in simulation. Depending on where this object - * is in the response, the unnamed resources it contains may or may not qualify for - * group resource sharing. If this is a field in SimulateTransactionGroupResult, - * the resources do qualify, but if this is a field in SimulateTransactionResult, - * they do not qualify. In order to make this group valid for actual submission, - * resources that qualify for group sharing can be made available by any - * transaction of the group; otherwise, resources must be placed in the same - * transaction which accessed them. - */ - unnamedResourcesAccessed?: SimulateUnnamedResourcesAccessed; - /** - * Creates a new `SimulateTransactionGroupResult` object. - * @param txnResults - Simulation result for individual transactions - * @param appBudgetAdded - Total budget added during execution of app calls in the transaction group. - * @param appBudgetConsumed - Total budget consumed during execution of app calls in the transaction group. - * @param failedAt - If present, indicates which transaction in this group caused the failure. This - * array represents the path to the failing transaction. Indexes are zero based, - * the first element indicates the top-level transaction, and successive elements - * indicate deeper inner transactions. - * @param failureMessage - If present, indicates that the transaction group failed and specifies why that - * happened - * @param unnamedResourcesAccessed - These are resources that were accessed by this group that would normally have - * caused failure, but were allowed in simulation. Depending on where this object - * is in the response, the unnamed resources it contains may or may not qualify for - * group resource sharing. If this is a field in SimulateTransactionGroupResult, - * the resources do qualify, but if this is a field in SimulateTransactionResult, - * they do not qualify. In order to make this group valid for actual submission, - * resources that qualify for group sharing can be made available by any - * transaction of the group; otherwise, resources must be placed in the same - * transaction which accessed them. - */ - constructor({ txnResults, appBudgetAdded, appBudgetConsumed, failedAt, failureMessage, unnamedResourcesAccessed, }: { - txnResults: SimulateTransactionResult[]; - appBudgetAdded?: number | bigint; - appBudgetConsumed?: number | bigint; - failedAt?: (number | bigint)[]; - failureMessage?: string; - unnamedResourcesAccessed?: SimulateUnnamedResourcesAccessed; - }); - static from_obj_for_encoding(data: Record): SimulateTransactionGroupResult; -} -/** - * Simulation result for an individual transaction - */ -export declare class SimulateTransactionResult extends BaseModel { - /** - * Details about a pending transaction. If the transaction was recently confirmed, - * includes confirmation details like the round and reward details. - */ - txnResult: PendingTransactionResponse; - /** - * Budget used during execution of an app call transaction. This value includes - * budged used by inner app calls spawned by this transaction. - */ - appBudgetConsumed?: number | bigint; - /** - * The execution trace of calling an app or a logic sig, containing the inner app - * call trace in a recursive way. - */ - execTrace?: SimulationTransactionExecTrace; - /** - * Budget used during execution of a logic sig transaction. - */ - logicSigBudgetConsumed?: number | bigint; - /** - * These are resources that were accessed by this group that would normally have - * caused failure, but were allowed in simulation. Depending on where this object - * is in the response, the unnamed resources it contains may or may not qualify for - * group resource sharing. If this is a field in SimulateTransactionGroupResult, - * the resources do qualify, but if this is a field in SimulateTransactionResult, - * they do not qualify. In order to make this group valid for actual submission, - * resources that qualify for group sharing can be made available by any - * transaction of the group; otherwise, resources must be placed in the same - * transaction which accessed them. - */ - unnamedResourcesAccessed?: SimulateUnnamedResourcesAccessed; - /** - * Creates a new `SimulateTransactionResult` object. - * @param txnResult - Details about a pending transaction. If the transaction was recently confirmed, - * includes confirmation details like the round and reward details. - * @param appBudgetConsumed - Budget used during execution of an app call transaction. This value includes - * budged used by inner app calls spawned by this transaction. - * @param execTrace - The execution trace of calling an app or a logic sig, containing the inner app - * call trace in a recursive way. - * @param logicSigBudgetConsumed - Budget used during execution of a logic sig transaction. - * @param unnamedResourcesAccessed - These are resources that were accessed by this group that would normally have - * caused failure, but were allowed in simulation. Depending on where this object - * is in the response, the unnamed resources it contains may or may not qualify for - * group resource sharing. If this is a field in SimulateTransactionGroupResult, - * the resources do qualify, but if this is a field in SimulateTransactionResult, - * they do not qualify. In order to make this group valid for actual submission, - * resources that qualify for group sharing can be made available by any - * transaction of the group; otherwise, resources must be placed in the same - * transaction which accessed them. - */ - constructor({ txnResult, appBudgetConsumed, execTrace, logicSigBudgetConsumed, unnamedResourcesAccessed, }: { - txnResult: PendingTransactionResponse; - appBudgetConsumed?: number | bigint; - execTrace?: SimulationTransactionExecTrace; - logicSigBudgetConsumed?: number | bigint; - unnamedResourcesAccessed?: SimulateUnnamedResourcesAccessed; - }); - static from_obj_for_encoding(data: Record): SimulateTransactionResult; -} -/** - * These are resources that were accessed by this group that would normally have - * caused failure, but were allowed in simulation. Depending on where this object - * is in the response, the unnamed resources it contains may or may not qualify for - * group resource sharing. If this is a field in SimulateTransactionGroupResult, - * the resources do qualify, but if this is a field in SimulateTransactionResult, - * they do not qualify. In order to make this group valid for actual submission, - * resources that qualify for group sharing can be made available by any - * transaction of the group; otherwise, resources must be placed in the same - * transaction which accessed them. - */ -export declare class SimulateUnnamedResourcesAccessed extends BaseModel { - /** - * The unnamed accounts that were referenced. The order of this array is arbitrary. - */ - accounts?: string[]; - /** - * The unnamed application local states that were referenced. The order of this - * array is arbitrary. - */ - appLocals?: ApplicationLocalReference[]; - /** - * The unnamed applications that were referenced. The order of this array is - * arbitrary. - */ - apps?: (number | bigint)[]; - /** - * The unnamed asset holdings that were referenced. The order of this array is - * arbitrary. - */ - assetHoldings?: AssetHoldingReference[]; - /** - * The unnamed assets that were referenced. The order of this array is arbitrary. - */ - assets?: (number | bigint)[]; - /** - * The unnamed boxes that were referenced. The order of this array is arbitrary. - */ - boxes?: BoxReference[]; - /** - * The number of extra box references used to increase the IO budget. This is in - * addition to the references defined in the input transaction group and any - * referenced to unnamed boxes. - */ - extraBoxRefs?: number | bigint; - /** - * Creates a new `SimulateUnnamedResourcesAccessed` object. - * @param accounts - The unnamed accounts that were referenced. The order of this array is arbitrary. - * @param appLocals - The unnamed application local states that were referenced. The order of this - * array is arbitrary. - * @param apps - The unnamed applications that were referenced. The order of this array is - * arbitrary. - * @param assetHoldings - The unnamed asset holdings that were referenced. The order of this array is - * arbitrary. - * @param assets - The unnamed assets that were referenced. The order of this array is arbitrary. - * @param boxes - The unnamed boxes that were referenced. The order of this array is arbitrary. - * @param extraBoxRefs - The number of extra box references used to increase the IO budget. This is in - * addition to the references defined in the input transaction group and any - * referenced to unnamed boxes. - */ - constructor({ accounts, appLocals, apps, assetHoldings, assets, boxes, extraBoxRefs, }: { - accounts?: string[]; - appLocals?: ApplicationLocalReference[]; - apps?: (number | bigint)[]; - assetHoldings?: AssetHoldingReference[]; - assets?: (number | bigint)[]; - boxes?: BoxReference[]; - extraBoxRefs?: number | bigint; - }); - static from_obj_for_encoding(data: Record): SimulateUnnamedResourcesAccessed; -} -/** - * The set of parameters and limits override during simulation. If this set of - * parameters is present, then evaluation parameters may differ from standard - * evaluation in certain ways. - */ -export declare class SimulationEvalOverrides extends BaseModel { - /** - * If true, transactions without signatures are allowed and simulated as if they - * were properly signed. - */ - allowEmptySignatures?: boolean; - /** - * If true, allows access to unnamed resources during simulation. - */ - allowUnnamedResources?: boolean; - /** - * The extra opcode budget added to each transaction group during simulation - */ - extraOpcodeBudget?: number | bigint; - /** - * The maximum log calls one can make during simulation - */ - maxLogCalls?: number | bigint; - /** - * The maximum byte number to log during simulation - */ - maxLogSize?: number | bigint; - /** - * Creates a new `SimulationEvalOverrides` object. - * @param allowEmptySignatures - If true, transactions without signatures are allowed and simulated as if they - * were properly signed. - * @param allowUnnamedResources - If true, allows access to unnamed resources during simulation. - * @param extraOpcodeBudget - The extra opcode budget added to each transaction group during simulation - * @param maxLogCalls - The maximum log calls one can make during simulation - * @param maxLogSize - The maximum byte number to log during simulation - */ - constructor({ allowEmptySignatures, allowUnnamedResources, extraOpcodeBudget, maxLogCalls, maxLogSize, }: { - allowEmptySignatures?: boolean; - allowUnnamedResources?: boolean; - extraOpcodeBudget?: number | bigint; - maxLogCalls?: number | bigint; - maxLogSize?: number | bigint; - }); - static from_obj_for_encoding(data: Record): SimulationEvalOverrides; -} -/** - * The set of trace information and effect from evaluating a single opcode. - */ -export declare class SimulationOpcodeTraceUnit extends BaseModel { - /** - * The program counter of the current opcode being evaluated. - */ - pc: number | bigint; - /** - * The writes into scratch slots. - */ - scratchChanges?: ScratchChange[]; - /** - * The indexes of the traces for inner transactions spawned by this opcode, if any. - */ - spawnedInners?: (number | bigint)[]; - /** - * The values added by this opcode to the stack. - */ - stackAdditions?: AvmValue[]; - /** - * The number of deleted stack values by this opcode. - */ - stackPopCount?: number | bigint; - /** - * The operations against the current application's states. - */ - stateChanges?: ApplicationStateOperation[]; - /** - * Creates a new `SimulationOpcodeTraceUnit` object. - * @param pc - The program counter of the current opcode being evaluated. - * @param scratchChanges - The writes into scratch slots. - * @param spawnedInners - The indexes of the traces for inner transactions spawned by this opcode, if any. - * @param stackAdditions - The values added by this opcode to the stack. - * @param stackPopCount - The number of deleted stack values by this opcode. - * @param stateChanges - The operations against the current application's states. - */ - constructor({ pc, scratchChanges, spawnedInners, stackAdditions, stackPopCount, stateChanges, }: { - pc: number | bigint; - scratchChanges?: ScratchChange[]; - spawnedInners?: (number | bigint)[]; - stackAdditions?: AvmValue[]; - stackPopCount?: number | bigint; - stateChanges?: ApplicationStateOperation[]; - }); - static from_obj_for_encoding(data: Record): SimulationOpcodeTraceUnit; -} -/** - * The execution trace of calling an app or a logic sig, containing the inner app - * call trace in a recursive way. - */ -export declare class SimulationTransactionExecTrace extends BaseModel { - /** - * SHA512_256 hash digest of the approval program executed in transaction. - */ - approvalProgramHash?: Uint8Array; - /** - * Program trace that contains a trace of opcode effects in an approval program. - */ - approvalProgramTrace?: SimulationOpcodeTraceUnit[]; - /** - * SHA512_256 hash digest of the clear state program executed in transaction. - */ - clearStateProgramHash?: Uint8Array; - /** - * Program trace that contains a trace of opcode effects in a clear state program. - */ - clearStateProgramTrace?: SimulationOpcodeTraceUnit[]; - /** - * If true, indicates that the clear state program failed and any persistent state - * changes it produced should be reverted once the program exits. - */ - clearStateRollback?: boolean; - /** - * The error message explaining why the clear state program failed. This field will - * only be populated if clear-state-rollback is true and the failure was due to an - * execution error. - */ - clearStateRollbackError?: string; - /** - * An array of SimulationTransactionExecTrace representing the execution trace of - * any inner transactions executed. - */ - innerTrace?: SimulationTransactionExecTrace[]; - /** - * SHA512_256 hash digest of the logic sig executed in transaction. - */ - logicSigHash?: Uint8Array; - /** - * Program trace that contains a trace of opcode effects in a logic sig. - */ - logicSigTrace?: SimulationOpcodeTraceUnit[]; - /** - * Creates a new `SimulationTransactionExecTrace` object. - * @param approvalProgramHash - SHA512_256 hash digest of the approval program executed in transaction. - * @param approvalProgramTrace - Program trace that contains a trace of opcode effects in an approval program. - * @param clearStateProgramHash - SHA512_256 hash digest of the clear state program executed in transaction. - * @param clearStateProgramTrace - Program trace that contains a trace of opcode effects in a clear state program. - * @param clearStateRollback - If true, indicates that the clear state program failed and any persistent state - * changes it produced should be reverted once the program exits. - * @param clearStateRollbackError - The error message explaining why the clear state program failed. This field will - * only be populated if clear-state-rollback is true and the failure was due to an - * execution error. - * @param innerTrace - An array of SimulationTransactionExecTrace representing the execution trace of - * any inner transactions executed. - * @param logicSigHash - SHA512_256 hash digest of the logic sig executed in transaction. - * @param logicSigTrace - Program trace that contains a trace of opcode effects in a logic sig. - */ - constructor({ approvalProgramHash, approvalProgramTrace, clearStateProgramHash, clearStateProgramTrace, clearStateRollback, clearStateRollbackError, innerTrace, logicSigHash, logicSigTrace, }: { - approvalProgramHash?: string | Uint8Array; - approvalProgramTrace?: SimulationOpcodeTraceUnit[]; - clearStateProgramHash?: string | Uint8Array; - clearStateProgramTrace?: SimulationOpcodeTraceUnit[]; - clearStateRollback?: boolean; - clearStateRollbackError?: string; - innerTrace?: SimulationTransactionExecTrace[]; - logicSigHash?: string | Uint8Array; - logicSigTrace?: SimulationOpcodeTraceUnit[]; - }); - static from_obj_for_encoding(data: Record): SimulationTransactionExecTrace; -} -/** - * Represents a state proof and its corresponding message - */ -export declare class StateProof extends BaseModel { - /** - * Represents the message that the state proofs are attesting to. - */ - message: StateProofMessage; - /** - * The encoded StateProof for the message. - */ - stateproof: Uint8Array; - /** - * Creates a new `StateProof` object. - * @param message - Represents the message that the state proofs are attesting to. - * @param stateproof - The encoded StateProof for the message. - */ - constructor({ message, stateproof, }: { - message: StateProofMessage; - stateproof: string | Uint8Array; - }); - static from_obj_for_encoding(data: Record): StateProof; -} -/** - * Represents the message that the state proofs are attesting to. - */ -export declare class StateProofMessage extends BaseModel { - /** - * The vector commitment root on all light block headers within a state proof - * interval. - */ - blockheaderscommitment: Uint8Array; - /** - * The first round the message attests to. - */ - firstattestedround: number | bigint; - /** - * The last round the message attests to. - */ - lastattestedround: number | bigint; - /** - * An integer value representing the natural log of the proven weight with 16 bits - * of precision. This value would be used to verify the next state proof. - */ - lnprovenweight: number | bigint; - /** - * The vector commitment root of the top N accounts to sign the next StateProof. - */ - voterscommitment: Uint8Array; - /** - * Creates a new `StateProofMessage` object. - * @param blockheaderscommitment - The vector commitment root on all light block headers within a state proof - * interval. - * @param firstattestedround - The first round the message attests to. - * @param lastattestedround - The last round the message attests to. - * @param lnprovenweight - An integer value representing the natural log of the proven weight with 16 bits - * of precision. This value would be used to verify the next state proof. - * @param voterscommitment - The vector commitment root of the top N accounts to sign the next StateProof. - */ - constructor({ blockheaderscommitment, firstattestedround, lastattestedround, lnprovenweight, voterscommitment, }: { - blockheaderscommitment: string | Uint8Array; - firstattestedround: number | bigint; - lastattestedround: number | bigint; - lnprovenweight: number | bigint; - voterscommitment: string | Uint8Array; - }); - static from_obj_for_encoding(data: Record): StateProofMessage; -} -/** - * Supply represents the current supply of MicroAlgos in the system. - */ -export declare class SupplyResponse extends BaseModel { - /** - * Round - */ - currentRound: number | bigint; - /** - * OnlineMoney - */ - onlineMoney: number | bigint; - /** - * TotalMoney - */ - totalMoney: number | bigint; - /** - * Creates a new `SupplyResponse` object. - * @param currentRound - Round - * @param onlineMoney - OnlineMoney - * @param totalMoney - TotalMoney - */ - constructor({ currentRound, onlineMoney, totalMoney, }: { - currentRound: number | bigint; - onlineMoney: number | bigint; - totalMoney: number | bigint; - }); - static from_obj_for_encoding(data: Record): SupplyResponse; -} -/** - * Represents a key-value pair in an application store. - */ -export declare class TealKeyValue extends BaseModel { - key: string; - /** - * Represents a TEAL value. - */ - value: TealValue; - /** - * Creates a new `TealKeyValue` object. - * @param key - - * @param value - Represents a TEAL value. - */ - constructor({ key, value }: { - key: string; - value: TealValue; - }); - static from_obj_for_encoding(data: Record): TealKeyValue; -} -/** - * Represents a TEAL value. - */ -export declare class TealValue extends BaseModel { - /** - * (tt) value type. Value `1` refers to **bytes**, value `2` refers to **uint** - */ - type: number | bigint; - /** - * (tb) bytes value. - */ - bytes: string; - /** - * (ui) uint value. - */ - uint: number | bigint; - /** - * Creates a new `TealValue` object. - * @param type - (tt) value type. Value `1` refers to **bytes**, value `2` refers to **uint** - * @param bytes - (tb) bytes value. - * @param uint - (ui) uint value. - */ - constructor({ type, bytes, uint, }: { - type: number | bigint; - bytes: string; - uint: number | bigint; - }); - static from_obj_for_encoding(data: Record): TealValue; -} -/** - * Response containing all ledger state deltas for transaction groups, with their - * associated Ids, in a single round. - */ -export declare class TransactionGroupLedgerStateDeltasForRoundResponse extends BaseModel { - deltas: LedgerStateDeltaForTransactionGroup[]; - /** - * Creates a new `TransactionGroupLedgerStateDeltasForRoundResponse` object. - * @param deltas - - */ - constructor({ deltas }: { - deltas: LedgerStateDeltaForTransactionGroup[]; - }); - static from_obj_for_encoding(data: Record): TransactionGroupLedgerStateDeltasForRoundResponse; -} -/** - * TransactionParams contains the parameters that help a client construct a new - * transaction. - */ -export declare class TransactionParametersResponse extends BaseModel { - /** - * ConsensusVersion indicates the consensus protocol version - * as of LastRound. - */ - consensusVersion: string; - /** - * Fee is the suggested transaction fee - * Fee is in units of micro-Algos per byte. - * Fee may fall to zero but transactions must still have a fee of - * at least MinTxnFee for the current network protocol. - */ - fee: number | bigint; - /** - * GenesisHash is the hash of the genesis block. - */ - genesisHash: Uint8Array; - /** - * GenesisID is an ID listed in the genesis block. - */ - genesisId: string; - /** - * LastRound indicates the last round seen - */ - lastRound: number | bigint; - /** - * The minimum transaction fee (not per byte) required for the - * txn to validate for the current network protocol. - */ - minFee: number | bigint; - /** - * Creates a new `TransactionParametersResponse` object. - * @param consensusVersion - ConsensusVersion indicates the consensus protocol version - * as of LastRound. - * @param fee - Fee is the suggested transaction fee - * Fee is in units of micro-Algos per byte. - * Fee may fall to zero but transactions must still have a fee of - * at least MinTxnFee for the current network protocol. - * @param genesisHash - GenesisHash is the hash of the genesis block. - * @param genesisId - GenesisID is an ID listed in the genesis block. - * @param lastRound - LastRound indicates the last round seen - * @param minFee - The minimum transaction fee (not per byte) required for the - * txn to validate for the current network protocol. - */ - constructor({ consensusVersion, fee, genesisHash, genesisId, lastRound, minFee, }: { - consensusVersion: string; - fee: number | bigint; - genesisHash: string | Uint8Array; - genesisId: string; - lastRound: number | bigint; - minFee: number | bigint; - }); - static from_obj_for_encoding(data: Record): TransactionParametersResponse; -} -/** - * Proof of transaction in a block. - */ -export declare class TransactionProofResponse extends BaseModel { - /** - * Index of the transaction in the block's payset. - */ - idx: number | bigint; - /** - * Proof of transaction membership. - */ - proof: Uint8Array; - /** - * Hash of SignedTxnInBlock for verifying proof. - */ - stibhash: Uint8Array; - /** - * Represents the depth of the tree that is being proven, i.e. the number of edges - * from a leaf to the root. - */ - treedepth: number | bigint; - /** - * The type of hash function used to create the proof, must be one of: - * * sha512_256 - * * sha256 - */ - hashtype?: string; - /** - * Creates a new `TransactionProofResponse` object. - * @param idx - Index of the transaction in the block's payset. - * @param proof - Proof of transaction membership. - * @param stibhash - Hash of SignedTxnInBlock for verifying proof. - * @param treedepth - Represents the depth of the tree that is being proven, i.e. the number of edges - * from a leaf to the root. - * @param hashtype - The type of hash function used to create the proof, must be one of: - * * sha512_256 - * * sha256 - */ - constructor({ idx, proof, stibhash, treedepth, hashtype, }: { - idx: number | bigint; - proof: string | Uint8Array; - stibhash: string | Uint8Array; - treedepth: number | bigint; - hashtype?: string; - }); - static from_obj_for_encoding(data: Record): TransactionProofResponse; -} -/** - * algod version information. - */ -export declare class Version extends BaseModel { - build: BuildVersion; - genesisHashB64: Uint8Array; - genesisId: string; - versions: string[]; - /** - * Creates a new `Version` object. - * @param build - - * @param genesisHashB64 - - * @param genesisId - - * @param versions - - */ - constructor({ build, genesisHashB64, genesisId, versions, }: { - build: BuildVersion; - genesisHashB64: string | Uint8Array; - genesisId: string; - versions: string[]; - }); - static from_obj_for_encoding(data: Record): Version; -} diff --git a/algosdk/client/v2/algod/models/types.js b/algosdk/client/v2/algod/models/types.js deleted file mode 100644 index e2e4ddd..0000000 --- a/algosdk/client/v2/algod/models/types.js +++ /dev/null @@ -1,3175 +0,0 @@ -"use strict"; -/** - * NOTICE: This file was generated. Editing this file manually is not recommended. - */ -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.SimulateRequestTransactionGroup = exports.SimulateRequest = exports.SimulateInitialStates = exports.ScratchChange = exports.PostTransactionsResponse = exports.PendingTransactionsResponse = exports.PendingTransactionResponse = exports.NodeStatusResponse = exports.LightBlockHeaderProof = exports.LedgerStateDeltaForTransactionGroup = exports.KvDelta = exports.GetSyncRoundResponse = exports.GetBlockTimeStampOffsetResponse = exports.EvalDeltaKeyValue = exports.EvalDelta = exports.ErrorResponse = exports.DryrunTxnResult = exports.DryrunState = exports.DryrunSource = exports.DryrunResponse = exports.DryrunRequest = exports.DisassembleResponse = exports.CompileResponse = exports.BuildVersion = exports.BoxesResponse = exports.BoxReference = exports.BoxDescriptor = exports.Box = exports.BlockTxidsResponse = exports.BlockResponse = exports.BlockHashResponse = exports.AvmValue = exports.AvmKeyValue = exports.AssetParams = exports.AssetHoldingReference = exports.AssetHolding = exports.Asset = exports.ApplicationStateSchema = exports.ApplicationStateOperation = exports.ApplicationParams = exports.ApplicationLocalState = exports.ApplicationLocalReference = exports.ApplicationKVStorage = exports.ApplicationInitialStates = exports.Application = exports.AccountStateDelta = exports.AccountParticipation = exports.AccountAssetResponse = exports.AccountApplicationResponse = exports.Account = void 0; -exports.Version = exports.TransactionProofResponse = exports.TransactionParametersResponse = exports.TransactionGroupLedgerStateDeltasForRoundResponse = exports.TealValue = exports.TealKeyValue = exports.SupplyResponse = exports.StateProofMessage = exports.StateProof = exports.SimulationTransactionExecTrace = exports.SimulationOpcodeTraceUnit = exports.SimulationEvalOverrides = exports.SimulateUnnamedResourcesAccessed = exports.SimulateTransactionResult = exports.SimulateTransactionGroupResult = exports.SimulateTraceConfig = exports.SimulateResponse = void 0; -/* eslint-disable no-use-before-define */ -const binarydata_1 = require("../../../../encoding/binarydata"); -const basemodel_1 = __importDefault(require("../../basemodel")); -/** - * Account information at a given round. - * Definition: - * data/basics/userBalance.go : AccountData - */ -class Account extends basemodel_1.default { - /** - * Creates a new `Account` object. - * @param address - the account public key - * @param amount - (algo) total number of MicroAlgos in the account - * @param amountWithoutPendingRewards - specifies the amount of MicroAlgos in the account, without the pending rewards. - * @param minBalance - MicroAlgo balance required by the account. - * The requirement grows based on asset and application usage. - * @param pendingRewards - amount of MicroAlgos of pending rewards in this account. - * @param rewards - (ern) total rewards of MicroAlgos the account has received, including pending - * rewards. - * @param round - The round for which this information is relevant. - * @param status - (onl) delegation status of the account's MicroAlgos - * * Offline - indicates that the associated account is delegated. - * * Online - indicates that the associated account used as part of the delegation - * pool. - * * NotParticipating - indicates that the associated account is neither a - * delegator nor a delegate. - * @param totalAppsOptedIn - The count of all applications that have been opted in, equivalent to the count - * of application local data (AppLocalState objects) stored in this account. - * @param totalAssetsOptedIn - The count of all assets that have been opted in, equivalent to the count of - * AssetHolding objects held by this account. - * @param totalCreatedApps - The count of all apps (AppParams objects) created by this account. - * @param totalCreatedAssets - The count of all assets (AssetParams objects) created by this account. - * @param appsLocalState - (appl) applications local data stored in this account. - * Note the raw object uses `map[int] -> AppLocalState` for this type. - * @param appsTotalExtraPages - (teap) the sum of all extra application program pages for this account. - * @param appsTotalSchema - (tsch) stores the sum of all of the local schemas and global schemas in this - * account. - * Note: the raw account uses `StateSchema` for this type. - * @param assets - (asset) assets held by this account. - * Note the raw object uses `map[int] -> AssetHolding` for this type. - * @param authAddr - (spend) the address against which signing should be checked. If empty, the - * address of the current account is used. This field can be updated in any - * transaction by setting the RekeyTo field. - * @param createdApps - (appp) parameters of applications created by this account including app global - * data. - * Note: the raw account uses `map[int] -> AppParams` for this type. - * @param createdAssets - (apar) parameters of assets created by this account. - * Note: the raw account uses `map[int] -> Asset` for this type. - * @param participation - AccountParticipation describes the parameters used by this account in consensus - * protocol. - * @param rewardBase - (ebase) used as part of the rewards computation. Only applicable to accounts - * which are participating. - * @param sigType - Indicates what type of signature is used by this account, must be one of: - * * sig - * * msig - * * lsig - * @param totalBoxBytes - (tbxb) The total number of bytes used by this account's app's box keys and - * values. - * @param totalBoxes - (tbx) The number of existing boxes created by this account's app. - */ - constructor({ address, amount, amountWithoutPendingRewards, minBalance, pendingRewards, rewards, round, status, totalAppsOptedIn, totalAssetsOptedIn, totalCreatedApps, totalCreatedAssets, appsLocalState, appsTotalExtraPages, appsTotalSchema, assets, authAddr, createdApps, createdAssets, participation, rewardBase, sigType, totalBoxBytes, totalBoxes, }) { - super(); - this.address = address; - this.amount = amount; - this.amountWithoutPendingRewards = amountWithoutPendingRewards; - this.minBalance = minBalance; - this.pendingRewards = pendingRewards; - this.rewards = rewards; - this.round = round; - this.status = status; - this.totalAppsOptedIn = totalAppsOptedIn; - this.totalAssetsOptedIn = totalAssetsOptedIn; - this.totalCreatedApps = totalCreatedApps; - this.totalCreatedAssets = totalCreatedAssets; - this.appsLocalState = appsLocalState; - this.appsTotalExtraPages = appsTotalExtraPages; - this.appsTotalSchema = appsTotalSchema; - this.assets = assets; - this.authAddr = authAddr; - this.createdApps = createdApps; - this.createdAssets = createdAssets; - this.participation = participation; - this.rewardBase = rewardBase; - this.sigType = sigType; - this.totalBoxBytes = totalBoxBytes; - this.totalBoxes = totalBoxes; - this.attribute_map = { - address: 'address', - amount: 'amount', - amountWithoutPendingRewards: 'amount-without-pending-rewards', - minBalance: 'min-balance', - pendingRewards: 'pending-rewards', - rewards: 'rewards', - round: 'round', - status: 'status', - totalAppsOptedIn: 'total-apps-opted-in', - totalAssetsOptedIn: 'total-assets-opted-in', - totalCreatedApps: 'total-created-apps', - totalCreatedAssets: 'total-created-assets', - appsLocalState: 'apps-local-state', - appsTotalExtraPages: 'apps-total-extra-pages', - appsTotalSchema: 'apps-total-schema', - assets: 'assets', - authAddr: 'auth-addr', - createdApps: 'created-apps', - createdAssets: 'created-assets', - participation: 'participation', - rewardBase: 'reward-base', - sigType: 'sig-type', - totalBoxBytes: 'total-box-bytes', - totalBoxes: 'total-boxes', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['address'] === 'undefined') - throw new Error(`Response is missing required field 'address': ${data}`); - if (typeof data['amount'] === 'undefined') - throw new Error(`Response is missing required field 'amount': ${data}`); - if (typeof data['amount-without-pending-rewards'] === 'undefined') - throw new Error(`Response is missing required field 'amount-without-pending-rewards': ${data}`); - if (typeof data['min-balance'] === 'undefined') - throw new Error(`Response is missing required field 'min-balance': ${data}`); - if (typeof data['pending-rewards'] === 'undefined') - throw new Error(`Response is missing required field 'pending-rewards': ${data}`); - if (typeof data['rewards'] === 'undefined') - throw new Error(`Response is missing required field 'rewards': ${data}`); - if (typeof data['round'] === 'undefined') - throw new Error(`Response is missing required field 'round': ${data}`); - if (typeof data['status'] === 'undefined') - throw new Error(`Response is missing required field 'status': ${data}`); - if (typeof data['total-apps-opted-in'] === 'undefined') - throw new Error(`Response is missing required field 'total-apps-opted-in': ${data}`); - if (typeof data['total-assets-opted-in'] === 'undefined') - throw new Error(`Response is missing required field 'total-assets-opted-in': ${data}`); - if (typeof data['total-created-apps'] === 'undefined') - throw new Error(`Response is missing required field 'total-created-apps': ${data}`); - if (typeof data['total-created-assets'] === 'undefined') - throw new Error(`Response is missing required field 'total-created-assets': ${data}`); - return new Account({ - address: data['address'], - amount: data['amount'], - amountWithoutPendingRewards: data['amount-without-pending-rewards'], - minBalance: data['min-balance'], - pendingRewards: data['pending-rewards'], - rewards: data['rewards'], - round: data['round'], - status: data['status'], - totalAppsOptedIn: data['total-apps-opted-in'], - totalAssetsOptedIn: data['total-assets-opted-in'], - totalCreatedApps: data['total-created-apps'], - totalCreatedAssets: data['total-created-assets'], - appsLocalState: typeof data['apps-local-state'] !== 'undefined' - ? data['apps-local-state'].map(ApplicationLocalState.from_obj_for_encoding) - : undefined, - appsTotalExtraPages: data['apps-total-extra-pages'], - appsTotalSchema: typeof data['apps-total-schema'] !== 'undefined' - ? ApplicationStateSchema.from_obj_for_encoding(data['apps-total-schema']) - : undefined, - assets: typeof data['assets'] !== 'undefined' - ? data['assets'].map(AssetHolding.from_obj_for_encoding) - : undefined, - authAddr: data['auth-addr'], - createdApps: typeof data['created-apps'] !== 'undefined' - ? data['created-apps'].map(Application.from_obj_for_encoding) - : undefined, - createdAssets: typeof data['created-assets'] !== 'undefined' - ? data['created-assets'].map(Asset.from_obj_for_encoding) - : undefined, - participation: typeof data['participation'] !== 'undefined' - ? AccountParticipation.from_obj_for_encoding(data['participation']) - : undefined, - rewardBase: data['reward-base'], - sigType: data['sig-type'], - totalBoxBytes: data['total-box-bytes'], - totalBoxes: data['total-boxes'], - }); - /* eslint-enable dot-notation */ - } -} -exports.Account = Account; -/** - * AccountApplicationResponse describes the account's application local state and - * global state (AppLocalState and AppParams, if either exists) for a specific - * application ID. Global state will only be returned if the provided address is - * the application's creator. - */ -class AccountApplicationResponse extends basemodel_1.default { - /** - * Creates a new `AccountApplicationResponse` object. - * @param round - The round for which this information is relevant. - * @param appLocalState - (appl) the application local data stored in this account. - * The raw account uses `AppLocalState` for this type. - * @param createdApp - (appp) parameters of the application created by this account including app - * global data. - * The raw account uses `AppParams` for this type. - */ - constructor({ round, appLocalState, createdApp, }) { - super(); - this.round = round; - this.appLocalState = appLocalState; - this.createdApp = createdApp; - this.attribute_map = { - round: 'round', - appLocalState: 'app-local-state', - createdApp: 'created-app', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['round'] === 'undefined') - throw new Error(`Response is missing required field 'round': ${data}`); - return new AccountApplicationResponse({ - round: data['round'], - appLocalState: typeof data['app-local-state'] !== 'undefined' - ? ApplicationLocalState.from_obj_for_encoding(data['app-local-state']) - : undefined, - createdApp: typeof data['created-app'] !== 'undefined' - ? ApplicationParams.from_obj_for_encoding(data['created-app']) - : undefined, - }); - /* eslint-enable dot-notation */ - } -} -exports.AccountApplicationResponse = AccountApplicationResponse; -/** - * AccountAssetResponse describes the account's asset holding and asset parameters - * (if either exist) for a specific asset ID. Asset parameters will only be - * returned if the provided address is the asset's creator. - */ -class AccountAssetResponse extends basemodel_1.default { - /** - * Creates a new `AccountAssetResponse` object. - * @param round - The round for which this information is relevant. - * @param assetHolding - (asset) Details about the asset held by this account. - * The raw account uses `AssetHolding` for this type. - * @param createdAsset - (apar) parameters of the asset created by this account. - * The raw account uses `AssetParams` for this type. - */ - constructor({ round, assetHolding, createdAsset, }) { - super(); - this.round = round; - this.assetHolding = assetHolding; - this.createdAsset = createdAsset; - this.attribute_map = { - round: 'round', - assetHolding: 'asset-holding', - createdAsset: 'created-asset', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['round'] === 'undefined') - throw new Error(`Response is missing required field 'round': ${data}`); - return new AccountAssetResponse({ - round: data['round'], - assetHolding: typeof data['asset-holding'] !== 'undefined' - ? AssetHolding.from_obj_for_encoding(data['asset-holding']) - : undefined, - createdAsset: typeof data['created-asset'] !== 'undefined' - ? AssetParams.from_obj_for_encoding(data['created-asset']) - : undefined, - }); - /* eslint-enable dot-notation */ - } -} -exports.AccountAssetResponse = AccountAssetResponse; -/** - * AccountParticipation describes the parameters used by this account in consensus - * protocol. - */ -class AccountParticipation extends basemodel_1.default { - /** - * Creates a new `AccountParticipation` object. - * @param selectionParticipationKey - (sel) Selection public key (if any) currently registered for this round. - * @param voteFirstValid - (voteFst) First round for which this participation is valid. - * @param voteKeyDilution - (voteKD) Number of subkeys in each batch of participation keys. - * @param voteLastValid - (voteLst) Last round for which this participation is valid. - * @param voteParticipationKey - (vote) root participation public key (if any) currently registered for this - * round. - * @param stateProofKey - (stprf) Root of the state proof key (if any) - */ - constructor({ selectionParticipationKey, voteFirstValid, voteKeyDilution, voteLastValid, voteParticipationKey, stateProofKey, }) { - super(); - this.selectionParticipationKey = - typeof selectionParticipationKey === 'string' - ? (0, binarydata_1.base64ToBytes)(selectionParticipationKey) - : selectionParticipationKey; - this.voteFirstValid = voteFirstValid; - this.voteKeyDilution = voteKeyDilution; - this.voteLastValid = voteLastValid; - this.voteParticipationKey = - typeof voteParticipationKey === 'string' - ? (0, binarydata_1.base64ToBytes)(voteParticipationKey) - : voteParticipationKey; - this.stateProofKey = - typeof stateProofKey === 'string' - ? (0, binarydata_1.base64ToBytes)(stateProofKey) - : stateProofKey; - this.attribute_map = { - selectionParticipationKey: 'selection-participation-key', - voteFirstValid: 'vote-first-valid', - voteKeyDilution: 'vote-key-dilution', - voteLastValid: 'vote-last-valid', - voteParticipationKey: 'vote-participation-key', - stateProofKey: 'state-proof-key', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['selection-participation-key'] === 'undefined') - throw new Error(`Response is missing required field 'selection-participation-key': ${data}`); - if (typeof data['vote-first-valid'] === 'undefined') - throw new Error(`Response is missing required field 'vote-first-valid': ${data}`); - if (typeof data['vote-key-dilution'] === 'undefined') - throw new Error(`Response is missing required field 'vote-key-dilution': ${data}`); - if (typeof data['vote-last-valid'] === 'undefined') - throw new Error(`Response is missing required field 'vote-last-valid': ${data}`); - if (typeof data['vote-participation-key'] === 'undefined') - throw new Error(`Response is missing required field 'vote-participation-key': ${data}`); - return new AccountParticipation({ - selectionParticipationKey: data['selection-participation-key'], - voteFirstValid: data['vote-first-valid'], - voteKeyDilution: data['vote-key-dilution'], - voteLastValid: data['vote-last-valid'], - voteParticipationKey: data['vote-participation-key'], - stateProofKey: data['state-proof-key'], - }); - /* eslint-enable dot-notation */ - } -} -exports.AccountParticipation = AccountParticipation; -/** - * Application state delta. - */ -class AccountStateDelta extends basemodel_1.default { - /** - * Creates a new `AccountStateDelta` object. - * @param address - - * @param delta - Application state delta. - */ - constructor({ address, delta, }) { - super(); - this.address = address; - this.delta = delta; - this.attribute_map = { - address: 'address', - delta: 'delta', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['address'] === 'undefined') - throw new Error(`Response is missing required field 'address': ${data}`); - if (!Array.isArray(data['delta'])) - throw new Error(`Response is missing required array field 'delta': ${data}`); - return new AccountStateDelta({ - address: data['address'], - delta: data['delta'].map(EvalDeltaKeyValue.from_obj_for_encoding), - }); - /* eslint-enable dot-notation */ - } -} -exports.AccountStateDelta = AccountStateDelta; -/** - * Application index and its parameters - */ -class Application extends basemodel_1.default { - /** - * Creates a new `Application` object. - * @param id - (appidx) application index. - * @param params - (appparams) application parameters. - */ - constructor({ id, params, }) { - super(); - this.id = id; - this.params = params; - this.attribute_map = { - id: 'id', - params: 'params', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['id'] === 'undefined') - throw new Error(`Response is missing required field 'id': ${data}`); - if (typeof data['params'] === 'undefined') - throw new Error(`Response is missing required field 'params': ${data}`); - return new Application({ - id: data['id'], - params: ApplicationParams.from_obj_for_encoding(data['params']), - }); - /* eslint-enable dot-notation */ - } -} -exports.Application = Application; -/** - * An application's initial global/local/box states that were accessed during - * simulation. - */ -class ApplicationInitialStates extends basemodel_1.default { - /** - * Creates a new `ApplicationInitialStates` object. - * @param id - Application index. - * @param appBoxes - An application's global/local/box state. - * @param appGlobals - An application's global/local/box state. - * @param appLocals - An application's initial local states tied to different accounts. - */ - constructor({ id, appBoxes, appGlobals, appLocals, }) { - super(); - this.id = id; - this.appBoxes = appBoxes; - this.appGlobals = appGlobals; - this.appLocals = appLocals; - this.attribute_map = { - id: 'id', - appBoxes: 'app-boxes', - appGlobals: 'app-globals', - appLocals: 'app-locals', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['id'] === 'undefined') - throw new Error(`Response is missing required field 'id': ${data}`); - return new ApplicationInitialStates({ - id: data['id'], - appBoxes: typeof data['app-boxes'] !== 'undefined' - ? ApplicationKVStorage.from_obj_for_encoding(data['app-boxes']) - : undefined, - appGlobals: typeof data['app-globals'] !== 'undefined' - ? ApplicationKVStorage.from_obj_for_encoding(data['app-globals']) - : undefined, - appLocals: typeof data['app-locals'] !== 'undefined' - ? data['app-locals'].map(ApplicationKVStorage.from_obj_for_encoding) - : undefined, - }); - /* eslint-enable dot-notation */ - } -} -exports.ApplicationInitialStates = ApplicationInitialStates; -/** - * An application's global/local/box state. - */ -class ApplicationKVStorage extends basemodel_1.default { - /** - * Creates a new `ApplicationKVStorage` object. - * @param kvs - Key-Value pairs representing application states. - * @param account - The address of the account associated with the local state. - */ - constructor({ kvs, account }) { - super(); - this.kvs = kvs; - this.account = account; - this.attribute_map = { - kvs: 'kvs', - account: 'account', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (!Array.isArray(data['kvs'])) - throw new Error(`Response is missing required array field 'kvs': ${data}`); - return new ApplicationKVStorage({ - kvs: data['kvs'].map(AvmKeyValue.from_obj_for_encoding), - account: data['account'], - }); - /* eslint-enable dot-notation */ - } -} -exports.ApplicationKVStorage = ApplicationKVStorage; -/** - * References an account's local state for an application. - */ -class ApplicationLocalReference extends basemodel_1.default { - /** - * Creates a new `ApplicationLocalReference` object. - * @param account - Address of the account with the local state. - * @param app - Application ID of the local state application. - */ - constructor({ account, app }) { - super(); - this.account = account; - this.app = app; - this.attribute_map = { - account: 'account', - app: 'app', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['account'] === 'undefined') - throw new Error(`Response is missing required field 'account': ${data}`); - if (typeof data['app'] === 'undefined') - throw new Error(`Response is missing required field 'app': ${data}`); - return new ApplicationLocalReference({ - account: data['account'], - app: data['app'], - }); - /* eslint-enable dot-notation */ - } -} -exports.ApplicationLocalReference = ApplicationLocalReference; -/** - * Stores local state associated with an application. - */ -class ApplicationLocalState extends basemodel_1.default { - /** - * Creates a new `ApplicationLocalState` object. - * @param id - The application which this local state is for. - * @param schema - (hsch) schema. - * @param keyValue - (tkv) storage. - */ - constructor({ id, schema, keyValue, }) { - super(); - this.id = id; - this.schema = schema; - this.keyValue = keyValue; - this.attribute_map = { - id: 'id', - schema: 'schema', - keyValue: 'key-value', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['id'] === 'undefined') - throw new Error(`Response is missing required field 'id': ${data}`); - if (typeof data['schema'] === 'undefined') - throw new Error(`Response is missing required field 'schema': ${data}`); - return new ApplicationLocalState({ - id: data['id'], - schema: ApplicationStateSchema.from_obj_for_encoding(data['schema']), - keyValue: typeof data['key-value'] !== 'undefined' - ? data['key-value'].map(TealKeyValue.from_obj_for_encoding) - : undefined, - }); - /* eslint-enable dot-notation */ - } -} -exports.ApplicationLocalState = ApplicationLocalState; -/** - * Stores the global information associated with an application. - */ -class ApplicationParams extends basemodel_1.default { - /** - * Creates a new `ApplicationParams` object. - * @param approvalProgram - (approv) approval program. - * @param clearStateProgram - (clearp) approval program. - * @param creator - The address that created this application. This is the address where the - * parameters and global state for this application can be found. - * @param extraProgramPages - (epp) the amount of extra program pages available to this app. - * @param globalState - (gs) global state - * @param globalStateSchema - (gsch) global schema - * @param localStateSchema - (lsch) local schema - */ - constructor({ approvalProgram, clearStateProgram, creator, extraProgramPages, globalState, globalStateSchema, localStateSchema, }) { - super(); - this.approvalProgram = - typeof approvalProgram === 'string' - ? (0, binarydata_1.base64ToBytes)(approvalProgram) - : approvalProgram; - this.clearStateProgram = - typeof clearStateProgram === 'string' - ? (0, binarydata_1.base64ToBytes)(clearStateProgram) - : clearStateProgram; - this.creator = creator; - this.extraProgramPages = extraProgramPages; - this.globalState = globalState; - this.globalStateSchema = globalStateSchema; - this.localStateSchema = localStateSchema; - this.attribute_map = { - approvalProgram: 'approval-program', - clearStateProgram: 'clear-state-program', - creator: 'creator', - extraProgramPages: 'extra-program-pages', - globalState: 'global-state', - globalStateSchema: 'global-state-schema', - localStateSchema: 'local-state-schema', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['approval-program'] === 'undefined') - throw new Error(`Response is missing required field 'approval-program': ${data}`); - if (typeof data['clear-state-program'] === 'undefined') - throw new Error(`Response is missing required field 'clear-state-program': ${data}`); - if (typeof data['creator'] === 'undefined') - throw new Error(`Response is missing required field 'creator': ${data}`); - return new ApplicationParams({ - approvalProgram: data['approval-program'], - clearStateProgram: data['clear-state-program'], - creator: data['creator'], - extraProgramPages: data['extra-program-pages'], - globalState: typeof data['global-state'] !== 'undefined' - ? data['global-state'].map(TealKeyValue.from_obj_for_encoding) - : undefined, - globalStateSchema: typeof data['global-state-schema'] !== 'undefined' - ? ApplicationStateSchema.from_obj_for_encoding(data['global-state-schema']) - : undefined, - localStateSchema: typeof data['local-state-schema'] !== 'undefined' - ? ApplicationStateSchema.from_obj_for_encoding(data['local-state-schema']) - : undefined, - }); - /* eslint-enable dot-notation */ - } -} -exports.ApplicationParams = ApplicationParams; -/** - * An operation against an application's global/local/box state. - */ -class ApplicationStateOperation extends basemodel_1.default { - /** - * Creates a new `ApplicationStateOperation` object. - * @param appStateType - Type of application state. Value `g` is **global state**, `l` is **local - * state**, `b` is **boxes**. - * @param key - The key (name) of the global/local/box state. - * @param operation - Operation type. Value `w` is **write**, `d` is **delete**. - * @param account - For local state changes, the address of the account associated with the local - * state. - * @param newValue - Represents an AVM value. - */ - constructor({ appStateType, key, operation, account, newValue, }) { - super(); - this.appStateType = appStateType; - this.key = typeof key === 'string' ? (0, binarydata_1.base64ToBytes)(key) : key; - this.operation = operation; - this.account = account; - this.newValue = newValue; - this.attribute_map = { - appStateType: 'app-state-type', - key: 'key', - operation: 'operation', - account: 'account', - newValue: 'new-value', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['app-state-type'] === 'undefined') - throw new Error(`Response is missing required field 'app-state-type': ${data}`); - if (typeof data['key'] === 'undefined') - throw new Error(`Response is missing required field 'key': ${data}`); - if (typeof data['operation'] === 'undefined') - throw new Error(`Response is missing required field 'operation': ${data}`); - return new ApplicationStateOperation({ - appStateType: data['app-state-type'], - key: data['key'], - operation: data['operation'], - account: data['account'], - newValue: typeof data['new-value'] !== 'undefined' - ? AvmValue.from_obj_for_encoding(data['new-value']) - : undefined, - }); - /* eslint-enable dot-notation */ - } -} -exports.ApplicationStateOperation = ApplicationStateOperation; -/** - * Specifies maximums on the number of each type that may be stored. - */ -class ApplicationStateSchema extends basemodel_1.default { - /** - * Creates a new `ApplicationStateSchema` object. - * @param numUint - (nui) num of uints. - * @param numByteSlice - (nbs) num of byte slices. - */ - constructor({ numUint, numByteSlice, }) { - super(); - this.numUint = numUint; - this.numByteSlice = numByteSlice; - this.attribute_map = { - numUint: 'num-uint', - numByteSlice: 'num-byte-slice', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['num-uint'] === 'undefined') - throw new Error(`Response is missing required field 'num-uint': ${data}`); - if (typeof data['num-byte-slice'] === 'undefined') - throw new Error(`Response is missing required field 'num-byte-slice': ${data}`); - return new ApplicationStateSchema({ - numUint: data['num-uint'], - numByteSlice: data['num-byte-slice'], - }); - /* eslint-enable dot-notation */ - } -} -exports.ApplicationStateSchema = ApplicationStateSchema; -/** - * Specifies both the unique identifier and the parameters for an asset - */ -class Asset extends basemodel_1.default { - /** - * Creates a new `Asset` object. - * @param index - unique asset identifier - * @param params - AssetParams specifies the parameters for an asset. - * (apar) when part of an AssetConfig transaction. - * Definition: - * data/transactions/asset.go : AssetParams - */ - constructor({ index, params, }) { - super(); - this.index = index; - this.params = params; - this.attribute_map = { - index: 'index', - params: 'params', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['index'] === 'undefined') - throw new Error(`Response is missing required field 'index': ${data}`); - if (typeof data['params'] === 'undefined') - throw new Error(`Response is missing required field 'params': ${data}`); - return new Asset({ - index: data['index'], - params: AssetParams.from_obj_for_encoding(data['params']), - }); - /* eslint-enable dot-notation */ - } -} -exports.Asset = Asset; -/** - * Describes an asset held by an account. - * Definition: - * data/basics/userBalance.go : AssetHolding - */ -class AssetHolding extends basemodel_1.default { - /** - * Creates a new `AssetHolding` object. - * @param amount - (a) number of units held. - * @param assetId - Asset ID of the holding. - * @param isFrozen - (f) whether or not the holding is frozen. - */ - constructor({ amount, assetId, isFrozen, }) { - super(); - this.amount = amount; - this.assetId = assetId; - this.isFrozen = isFrozen; - this.attribute_map = { - amount: 'amount', - assetId: 'asset-id', - isFrozen: 'is-frozen', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['amount'] === 'undefined') - throw new Error(`Response is missing required field 'amount': ${data}`); - if (typeof data['asset-id'] === 'undefined') - throw new Error(`Response is missing required field 'asset-id': ${data}`); - if (typeof data['is-frozen'] === 'undefined') - throw new Error(`Response is missing required field 'is-frozen': ${data}`); - return new AssetHolding({ - amount: data['amount'], - assetId: data['asset-id'], - isFrozen: data['is-frozen'], - }); - /* eslint-enable dot-notation */ - } -} -exports.AssetHolding = AssetHolding; -/** - * References an asset held by an account. - */ -class AssetHoldingReference extends basemodel_1.default { - /** - * Creates a new `AssetHoldingReference` object. - * @param account - Address of the account holding the asset. - * @param asset - Asset ID of the holding. - */ - constructor({ account, asset }) { - super(); - this.account = account; - this.asset = asset; - this.attribute_map = { - account: 'account', - asset: 'asset', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['account'] === 'undefined') - throw new Error(`Response is missing required field 'account': ${data}`); - if (typeof data['asset'] === 'undefined') - throw new Error(`Response is missing required field 'asset': ${data}`); - return new AssetHoldingReference({ - account: data['account'], - asset: data['asset'], - }); - /* eslint-enable dot-notation */ - } -} -exports.AssetHoldingReference = AssetHoldingReference; -/** - * AssetParams specifies the parameters for an asset. - * (apar) when part of an AssetConfig transaction. - * Definition: - * data/transactions/asset.go : AssetParams - */ -class AssetParams extends basemodel_1.default { - /** - * Creates a new `AssetParams` object. - * @param creator - The address that created this asset. This is the address where the parameters - * for this asset can be found, and also the address where unwanted asset units can - * be sent in the worst case. - * @param decimals - (dc) The number of digits to use after the decimal point when displaying this - * asset. If 0, the asset is not divisible. If 1, the base unit of the asset is in - * tenths. If 2, the base unit of the asset is in hundredths, and so on. This value - * must be between 0 and 19 (inclusive). - * @param total - (t) The total number of units of this asset. - * @param clawback - (c) Address of account used to clawback holdings of this asset. If empty, - * clawback is not permitted. - * @param defaultFrozen - (df) Whether holdings of this asset are frozen by default. - * @param freeze - (f) Address of account used to freeze holdings of this asset. If empty, freezing - * is not permitted. - * @param manager - (m) Address of account used to manage the keys of this asset and to destroy it. - * @param metadataHash - (am) A commitment to some unspecified asset metadata. The format of this - * metadata is up to the application. - * @param name - (an) Name of this asset, as supplied by the creator. Included only when the - * asset name is composed of printable utf-8 characters. - * @param nameB64 - Base64 encoded name of this asset, as supplied by the creator. - * @param reserve - (r) Address of account holding reserve (non-minted) units of this asset. - * @param unitName - (un) Name of a unit of this asset, as supplied by the creator. Included only - * when the name of a unit of this asset is composed of printable utf-8 characters. - * @param unitNameB64 - Base64 encoded name of a unit of this asset, as supplied by the creator. - * @param url - (au) URL where more information about the asset can be retrieved. Included only - * when the URL is composed of printable utf-8 characters. - * @param urlB64 - Base64 encoded URL where more information about the asset can be retrieved. - */ - constructor({ creator, decimals, total, clawback, defaultFrozen, freeze, manager, metadataHash, name, nameB64, reserve, unitName, unitNameB64, url, urlB64, }) { - super(); - this.creator = creator; - this.decimals = decimals; - this.total = total; - this.clawback = clawback; - this.defaultFrozen = defaultFrozen; - this.freeze = freeze; - this.manager = manager; - this.metadataHash = - typeof metadataHash === 'string' - ? (0, binarydata_1.base64ToBytes)(metadataHash) - : metadataHash; - this.name = name; - this.nameB64 = - typeof nameB64 === 'string' ? (0, binarydata_1.base64ToBytes)(nameB64) : nameB64; - this.reserve = reserve; - this.unitName = unitName; - this.unitNameB64 = - typeof unitNameB64 === 'string' - ? (0, binarydata_1.base64ToBytes)(unitNameB64) - : unitNameB64; - this.url = url; - this.urlB64 = typeof urlB64 === 'string' ? (0, binarydata_1.base64ToBytes)(urlB64) : urlB64; - this.attribute_map = { - creator: 'creator', - decimals: 'decimals', - total: 'total', - clawback: 'clawback', - defaultFrozen: 'default-frozen', - freeze: 'freeze', - manager: 'manager', - metadataHash: 'metadata-hash', - name: 'name', - nameB64: 'name-b64', - reserve: 'reserve', - unitName: 'unit-name', - unitNameB64: 'unit-name-b64', - url: 'url', - urlB64: 'url-b64', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['creator'] === 'undefined') - throw new Error(`Response is missing required field 'creator': ${data}`); - if (typeof data['decimals'] === 'undefined') - throw new Error(`Response is missing required field 'decimals': ${data}`); - if (typeof data['total'] === 'undefined') - throw new Error(`Response is missing required field 'total': ${data}`); - return new AssetParams({ - creator: data['creator'], - decimals: data['decimals'], - total: data['total'], - clawback: data['clawback'], - defaultFrozen: data['default-frozen'], - freeze: data['freeze'], - manager: data['manager'], - metadataHash: data['metadata-hash'], - name: data['name'], - nameB64: data['name-b64'], - reserve: data['reserve'], - unitName: data['unit-name'], - unitNameB64: data['unit-name-b64'], - url: data['url'], - urlB64: data['url-b64'], - }); - /* eslint-enable dot-notation */ - } -} -exports.AssetParams = AssetParams; -/** - * Represents an AVM key-value pair in an application store. - */ -class AvmKeyValue extends basemodel_1.default { - /** - * Creates a new `AvmKeyValue` object. - * @param key - - * @param value - Represents an AVM value. - */ - constructor({ key, value }) { - super(); - this.key = typeof key === 'string' ? (0, binarydata_1.base64ToBytes)(key) : key; - this.value = value; - this.attribute_map = { - key: 'key', - value: 'value', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['key'] === 'undefined') - throw new Error(`Response is missing required field 'key': ${data}`); - if (typeof data['value'] === 'undefined') - throw new Error(`Response is missing required field 'value': ${data}`); - return new AvmKeyValue({ - key: data['key'], - value: AvmValue.from_obj_for_encoding(data['value']), - }); - /* eslint-enable dot-notation */ - } -} -exports.AvmKeyValue = AvmKeyValue; -/** - * Represents an AVM value. - */ -class AvmValue extends basemodel_1.default { - /** - * Creates a new `AvmValue` object. - * @param type - value type. Value `1` refers to **bytes**, value `2` refers to **uint64** - * @param bytes - bytes value. - * @param uint - uint value. - */ - constructor({ type, bytes, uint, }) { - super(); - this.type = type; - this.bytes = typeof bytes === 'string' ? (0, binarydata_1.base64ToBytes)(bytes) : bytes; - this.uint = uint; - this.attribute_map = { - type: 'type', - bytes: 'bytes', - uint: 'uint', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['type'] === 'undefined') - throw new Error(`Response is missing required field 'type': ${data}`); - return new AvmValue({ - type: data['type'], - bytes: data['bytes'], - uint: data['uint'], - }); - /* eslint-enable dot-notation */ - } -} -exports.AvmValue = AvmValue; -/** - * Hash of a block header. - */ -class BlockHashResponse extends basemodel_1.default { - /** - * Creates a new `BlockHashResponse` object. - * @param blockhash - Block header hash. - */ - constructor({ blockhash }) { - super(); - this.blockhash = blockhash; - this.attribute_map = { - blockhash: 'blockHash', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['blockHash'] === 'undefined') - throw new Error(`Response is missing required field 'blockHash': ${data}`); - return new BlockHashResponse({ - blockhash: data['blockHash'], - }); - /* eslint-enable dot-notation */ - } -} -exports.BlockHashResponse = BlockHashResponse; -/** - * Encoded block object. - */ -class BlockResponse extends basemodel_1.default { - /** - * Creates a new `BlockResponse` object. - * @param block - Block header data. - * @param cert - Optional certificate object. This is only included when the format is set to - * message pack. - */ - constructor({ block, cert, }) { - super(); - this.block = block; - this.cert = cert; - this.attribute_map = { - block: 'block', - cert: 'cert', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['block'] === 'undefined') - throw new Error(`Response is missing required field 'block': ${data}`); - return new BlockResponse({ - block: data['block'], - cert: data['cert'], - }); - /* eslint-enable dot-notation */ - } -} -exports.BlockResponse = BlockResponse; -/** - * Top level transaction IDs in a block. - */ -class BlockTxidsResponse extends basemodel_1.default { - /** - * Creates a new `BlockTxidsResponse` object. - * @param blocktxids - Block transaction IDs. - */ - constructor({ blocktxids }) { - super(); - this.blocktxids = blocktxids; - this.attribute_map = { - blocktxids: 'blockTxids', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (!Array.isArray(data['blockTxids'])) - throw new Error(`Response is missing required array field 'blockTxids': ${data}`); - return new BlockTxidsResponse({ - blocktxids: data['blockTxids'], - }); - /* eslint-enable dot-notation */ - } -} -exports.BlockTxidsResponse = BlockTxidsResponse; -/** - * Box name and its content. - */ -class Box extends basemodel_1.default { - /** - * Creates a new `Box` object. - * @param name - (name) box name, base64 encoded - * @param round - The round for which this information is relevant - * @param value - (value) box value, base64 encoded. - */ - constructor({ name, round, value, }) { - super(); - this.name = typeof name === 'string' ? (0, binarydata_1.base64ToBytes)(name) : name; - this.round = round; - this.value = typeof value === 'string' ? (0, binarydata_1.base64ToBytes)(value) : value; - this.attribute_map = { - name: 'name', - round: 'round', - value: 'value', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['name'] === 'undefined') - throw new Error(`Response is missing required field 'name': ${data}`); - if (typeof data['round'] === 'undefined') - throw new Error(`Response is missing required field 'round': ${data}`); - if (typeof data['value'] === 'undefined') - throw new Error(`Response is missing required field 'value': ${data}`); - return new Box({ - name: data['name'], - round: data['round'], - value: data['value'], - }); - /* eslint-enable dot-notation */ - } -} -exports.Box = Box; -/** - * Box descriptor describes a Box. - */ -class BoxDescriptor extends basemodel_1.default { - /** - * Creates a new `BoxDescriptor` object. - * @param name - Base64 encoded box name - */ - constructor({ name }) { - super(); - this.name = typeof name === 'string' ? (0, binarydata_1.base64ToBytes)(name) : name; - this.attribute_map = { - name: 'name', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['name'] === 'undefined') - throw new Error(`Response is missing required field 'name': ${data}`); - return new BoxDescriptor({ - name: data['name'], - }); - /* eslint-enable dot-notation */ - } -} -exports.BoxDescriptor = BoxDescriptor; -/** - * References a box of an application. - */ -class BoxReference extends basemodel_1.default { - /** - * Creates a new `BoxReference` object. - * @param app - Application ID which this box belongs to - * @param name - Base64 encoded box name - */ - constructor({ app, name, }) { - super(); - this.app = app; - this.name = typeof name === 'string' ? (0, binarydata_1.base64ToBytes)(name) : name; - this.attribute_map = { - app: 'app', - name: 'name', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['app'] === 'undefined') - throw new Error(`Response is missing required field 'app': ${data}`); - if (typeof data['name'] === 'undefined') - throw new Error(`Response is missing required field 'name': ${data}`); - return new BoxReference({ - app: data['app'], - name: data['name'], - }); - /* eslint-enable dot-notation */ - } -} -exports.BoxReference = BoxReference; -/** - * Box names of an application - */ -class BoxesResponse extends basemodel_1.default { - /** - * Creates a new `BoxesResponse` object. - * @param boxes - - */ - constructor({ boxes }) { - super(); - this.boxes = boxes; - this.attribute_map = { - boxes: 'boxes', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (!Array.isArray(data['boxes'])) - throw new Error(`Response is missing required array field 'boxes': ${data}`); - return new BoxesResponse({ - boxes: data['boxes'].map(BoxDescriptor.from_obj_for_encoding), - }); - /* eslint-enable dot-notation */ - } -} -exports.BoxesResponse = BoxesResponse; -class BuildVersion extends basemodel_1.default { - /** - * Creates a new `BuildVersion` object. - * @param branch - - * @param buildNumber - - * @param channel - - * @param commitHash - - * @param major - - * @param minor - - */ - constructor({ branch, buildNumber, channel, commitHash, major, minor, }) { - super(); - this.branch = branch; - this.buildNumber = buildNumber; - this.channel = channel; - this.commitHash = commitHash; - this.major = major; - this.minor = minor; - this.attribute_map = { - branch: 'branch', - buildNumber: 'build_number', - channel: 'channel', - commitHash: 'commit_hash', - major: 'major', - minor: 'minor', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['branch'] === 'undefined') - throw new Error(`Response is missing required field 'branch': ${data}`); - if (typeof data['build_number'] === 'undefined') - throw new Error(`Response is missing required field 'build_number': ${data}`); - if (typeof data['channel'] === 'undefined') - throw new Error(`Response is missing required field 'channel': ${data}`); - if (typeof data['commit_hash'] === 'undefined') - throw new Error(`Response is missing required field 'commit_hash': ${data}`); - if (typeof data['major'] === 'undefined') - throw new Error(`Response is missing required field 'major': ${data}`); - if (typeof data['minor'] === 'undefined') - throw new Error(`Response is missing required field 'minor': ${data}`); - return new BuildVersion({ - branch: data['branch'], - buildNumber: data['build_number'], - channel: data['channel'], - commitHash: data['commit_hash'], - major: data['major'], - minor: data['minor'], - }); - /* eslint-enable dot-notation */ - } -} -exports.BuildVersion = BuildVersion; -/** - * Teal compile Result - */ -class CompileResponse extends basemodel_1.default { - /** - * Creates a new `CompileResponse` object. - * @param hash - base32 SHA512_256 of program bytes (Address style) - * @param result - base64 encoded program bytes - * @param sourcemap - JSON of the source map - */ - constructor({ hash, result, sourcemap, }) { - super(); - this.hash = hash; - this.result = result; - this.sourcemap = sourcemap; - this.attribute_map = { - hash: 'hash', - result: 'result', - sourcemap: 'sourcemap', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['hash'] === 'undefined') - throw new Error(`Response is missing required field 'hash': ${data}`); - if (typeof data['result'] === 'undefined') - throw new Error(`Response is missing required field 'result': ${data}`); - return new CompileResponse({ - hash: data['hash'], - result: data['result'], - sourcemap: data['sourcemap'], - }); - /* eslint-enable dot-notation */ - } -} -exports.CompileResponse = CompileResponse; -/** - * Teal disassembly Result - */ -class DisassembleResponse extends basemodel_1.default { - /** - * Creates a new `DisassembleResponse` object. - * @param result - disassembled Teal code - */ - constructor({ result }) { - super(); - this.result = result; - this.attribute_map = { - result: 'result', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['result'] === 'undefined') - throw new Error(`Response is missing required field 'result': ${data}`); - return new DisassembleResponse({ - result: data['result'], - }); - /* eslint-enable dot-notation */ - } -} -exports.DisassembleResponse = DisassembleResponse; -/** - * Request data type for dryrun endpoint. Given the Transactions and simulated - * ledger state upload, run TEAL scripts and return debugging information. - */ -class DryrunRequest extends basemodel_1.default { - /** - * Creates a new `DryrunRequest` object. - * @param accounts - - * @param apps - - * @param latestTimestamp - LatestTimestamp is available to some TEAL scripts. Defaults to the latest - * confirmed timestamp this algod is attached to. - * @param protocolVersion - ProtocolVersion specifies a specific version string to operate under, otherwise - * whatever the current protocol of the network this algod is running in. - * @param round - Round is available to some TEAL scripts. Defaults to the current round on the - * network this algod is attached to. - * @param sources - - * @param txns - - */ - constructor({ accounts, apps, latestTimestamp, protocolVersion, round, sources, txns, }) { - super(); - this.accounts = accounts; - this.apps = apps; - this.latestTimestamp = latestTimestamp; - this.protocolVersion = protocolVersion; - this.round = round; - this.sources = sources; - this.txns = txns; - this.attribute_map = { - accounts: 'accounts', - apps: 'apps', - latestTimestamp: 'latest-timestamp', - protocolVersion: 'protocol-version', - round: 'round', - sources: 'sources', - txns: 'txns', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (!Array.isArray(data['accounts'])) - throw new Error(`Response is missing required array field 'accounts': ${data}`); - if (!Array.isArray(data['apps'])) - throw new Error(`Response is missing required array field 'apps': ${data}`); - if (typeof data['latest-timestamp'] === 'undefined') - throw new Error(`Response is missing required field 'latest-timestamp': ${data}`); - if (typeof data['protocol-version'] === 'undefined') - throw new Error(`Response is missing required field 'protocol-version': ${data}`); - if (typeof data['round'] === 'undefined') - throw new Error(`Response is missing required field 'round': ${data}`); - if (!Array.isArray(data['sources'])) - throw new Error(`Response is missing required array field 'sources': ${data}`); - if (!Array.isArray(data['txns'])) - throw new Error(`Response is missing required array field 'txns': ${data}`); - return new DryrunRequest({ - accounts: data['accounts'].map(Account.from_obj_for_encoding), - apps: data['apps'].map(Application.from_obj_for_encoding), - latestTimestamp: data['latest-timestamp'], - protocolVersion: data['protocol-version'], - round: data['round'], - sources: data['sources'].map(DryrunSource.from_obj_for_encoding), - txns: data['txns'], - }); - /* eslint-enable dot-notation */ - } -} -exports.DryrunRequest = DryrunRequest; -/** - * DryrunResponse contains per-txn debug information from a dryrun. - */ -class DryrunResponse extends basemodel_1.default { - /** - * Creates a new `DryrunResponse` object. - * @param error - - * @param protocolVersion - Protocol version is the protocol version Dryrun was operated under. - * @param txns - - */ - constructor({ error, protocolVersion, txns, }) { - super(); - this.error = error; - this.protocolVersion = protocolVersion; - this.txns = txns; - this.attribute_map = { - error: 'error', - protocolVersion: 'protocol-version', - txns: 'txns', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['error'] === 'undefined') - throw new Error(`Response is missing required field 'error': ${data}`); - if (typeof data['protocol-version'] === 'undefined') - throw new Error(`Response is missing required field 'protocol-version': ${data}`); - if (!Array.isArray(data['txns'])) - throw new Error(`Response is missing required array field 'txns': ${data}`); - return new DryrunResponse({ - error: data['error'], - protocolVersion: data['protocol-version'], - txns: data['txns'].map(DryrunTxnResult.from_obj_for_encoding), - }); - /* eslint-enable dot-notation */ - } -} -exports.DryrunResponse = DryrunResponse; -/** - * DryrunSource is TEAL source text that gets uploaded, compiled, and inserted into - * transactions or application state. - */ -class DryrunSource extends basemodel_1.default { - /** - * Creates a new `DryrunSource` object. - * @param fieldName - FieldName is what kind of sources this is. If lsig then it goes into the - * transactions[this.TxnIndex].LogicSig. If approv or clearp it goes into the - * Approval Program or Clear State Program of application[this.AppIndex]. - * @param source - - * @param txnIndex - - * @param appIndex - - */ - constructor({ fieldName, source, txnIndex, appIndex, }) { - super(); - this.fieldName = fieldName; - this.source = source; - this.txnIndex = txnIndex; - this.appIndex = appIndex; - this.attribute_map = { - fieldName: 'field-name', - source: 'source', - txnIndex: 'txn-index', - appIndex: 'app-index', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['field-name'] === 'undefined') - throw new Error(`Response is missing required field 'field-name': ${data}`); - if (typeof data['source'] === 'undefined') - throw new Error(`Response is missing required field 'source': ${data}`); - if (typeof data['txn-index'] === 'undefined') - throw new Error(`Response is missing required field 'txn-index': ${data}`); - if (typeof data['app-index'] === 'undefined') - throw new Error(`Response is missing required field 'app-index': ${data}`); - return new DryrunSource({ - fieldName: data['field-name'], - source: data['source'], - txnIndex: data['txn-index'], - appIndex: data['app-index'], - }); - /* eslint-enable dot-notation */ - } -} -exports.DryrunSource = DryrunSource; -/** - * Stores the TEAL eval step data - */ -class DryrunState extends basemodel_1.default { - /** - * Creates a new `DryrunState` object. - * @param line - Line number - * @param pc - Program counter - * @param stack - - * @param error - Evaluation error if any - * @param scratch - - */ - constructor({ line, pc, stack, error, scratch, }) { - super(); - this.line = line; - this.pc = pc; - this.stack = stack; - this.error = error; - this.scratch = scratch; - this.attribute_map = { - line: 'line', - pc: 'pc', - stack: 'stack', - error: 'error', - scratch: 'scratch', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['line'] === 'undefined') - throw new Error(`Response is missing required field 'line': ${data}`); - if (typeof data['pc'] === 'undefined') - throw new Error(`Response is missing required field 'pc': ${data}`); - if (!Array.isArray(data['stack'])) - throw new Error(`Response is missing required array field 'stack': ${data}`); - return new DryrunState({ - line: data['line'], - pc: data['pc'], - stack: data['stack'].map(TealValue.from_obj_for_encoding), - error: data['error'], - scratch: typeof data['scratch'] !== 'undefined' - ? data['scratch'].map(TealValue.from_obj_for_encoding) - : undefined, - }); - /* eslint-enable dot-notation */ - } -} -exports.DryrunState = DryrunState; -/** - * DryrunTxnResult contains any LogicSig or ApplicationCall program debug - * information and state updates from a dryrun. - */ -class DryrunTxnResult extends basemodel_1.default { - /** - * Creates a new `DryrunTxnResult` object. - * @param disassembly - Disassembled program line by line. - * @param appCallMessages - - * @param appCallTrace - - * @param budgetAdded - Budget added during execution of app call transaction. - * @param budgetConsumed - Budget consumed during execution of app call transaction. - * @param globalDelta - Application state delta. - * @param localDeltas - - * @param logicSigDisassembly - Disassembled lsig program line by line. - * @param logicSigMessages - - * @param logicSigTrace - - * @param logs - - */ - constructor({ disassembly, appCallMessages, appCallTrace, budgetAdded, budgetConsumed, globalDelta, localDeltas, logicSigDisassembly, logicSigMessages, logicSigTrace, logs, }) { - super(); - this.disassembly = disassembly; - this.appCallMessages = appCallMessages; - this.appCallTrace = appCallTrace; - this.budgetAdded = budgetAdded; - this.budgetConsumed = budgetConsumed; - this.globalDelta = globalDelta; - this.localDeltas = localDeltas; - this.logicSigDisassembly = logicSigDisassembly; - this.logicSigMessages = logicSigMessages; - this.logicSigTrace = logicSigTrace; - this.logs = logs; - this.attribute_map = { - disassembly: 'disassembly', - appCallMessages: 'app-call-messages', - appCallTrace: 'app-call-trace', - budgetAdded: 'budget-added', - budgetConsumed: 'budget-consumed', - globalDelta: 'global-delta', - localDeltas: 'local-deltas', - logicSigDisassembly: 'logic-sig-disassembly', - logicSigMessages: 'logic-sig-messages', - logicSigTrace: 'logic-sig-trace', - logs: 'logs', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (!Array.isArray(data['disassembly'])) - throw new Error(`Response is missing required array field 'disassembly': ${data}`); - return new DryrunTxnResult({ - disassembly: data['disassembly'], - appCallMessages: data['app-call-messages'], - appCallTrace: typeof data['app-call-trace'] !== 'undefined' - ? data['app-call-trace'].map(DryrunState.from_obj_for_encoding) - : undefined, - budgetAdded: data['budget-added'], - budgetConsumed: data['budget-consumed'], - globalDelta: typeof data['global-delta'] !== 'undefined' - ? data['global-delta'].map(EvalDeltaKeyValue.from_obj_for_encoding) - : undefined, - localDeltas: typeof data['local-deltas'] !== 'undefined' - ? data['local-deltas'].map(AccountStateDelta.from_obj_for_encoding) - : undefined, - logicSigDisassembly: data['logic-sig-disassembly'], - logicSigMessages: data['logic-sig-messages'], - logicSigTrace: typeof data['logic-sig-trace'] !== 'undefined' - ? data['logic-sig-trace'].map(DryrunState.from_obj_for_encoding) - : undefined, - logs: data['logs'], - }); - /* eslint-enable dot-notation */ - } -} -exports.DryrunTxnResult = DryrunTxnResult; -/** - * An error response with optional data field. - */ -class ErrorResponse extends basemodel_1.default { - /** - * Creates a new `ErrorResponse` object. - * @param message - - * @param data - - */ - constructor({ message, data, }) { - super(); - this.message = message; - this.data = data; - this.attribute_map = { - message: 'message', - data: 'data', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['message'] === 'undefined') - throw new Error(`Response is missing required field 'message': ${data}`); - return new ErrorResponse({ - message: data['message'], - data: data['data'], - }); - /* eslint-enable dot-notation */ - } -} -exports.ErrorResponse = ErrorResponse; -/** - * Represents a TEAL value delta. - */ -class EvalDelta extends basemodel_1.default { - /** - * Creates a new `EvalDelta` object. - * @param action - (at) delta action. - * @param bytes - (bs) bytes value. - * @param uint - (ui) uint value. - */ - constructor({ action, bytes, uint, }) { - super(); - this.action = action; - this.bytes = bytes; - this.uint = uint; - this.attribute_map = { - action: 'action', - bytes: 'bytes', - uint: 'uint', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['action'] === 'undefined') - throw new Error(`Response is missing required field 'action': ${data}`); - return new EvalDelta({ - action: data['action'], - bytes: data['bytes'], - uint: data['uint'], - }); - /* eslint-enable dot-notation */ - } -} -exports.EvalDelta = EvalDelta; -/** - * Key-value pairs for StateDelta. - */ -class EvalDeltaKeyValue extends basemodel_1.default { - /** - * Creates a new `EvalDeltaKeyValue` object. - * @param key - - * @param value - Represents a TEAL value delta. - */ - constructor({ key, value }) { - super(); - this.key = key; - this.value = value; - this.attribute_map = { - key: 'key', - value: 'value', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['key'] === 'undefined') - throw new Error(`Response is missing required field 'key': ${data}`); - if (typeof data['value'] === 'undefined') - throw new Error(`Response is missing required field 'value': ${data}`); - return new EvalDeltaKeyValue({ - key: data['key'], - value: EvalDelta.from_obj_for_encoding(data['value']), - }); - /* eslint-enable dot-notation */ - } -} -exports.EvalDeltaKeyValue = EvalDeltaKeyValue; -/** - * Response containing the timestamp offset in seconds - */ -class GetBlockTimeStampOffsetResponse extends basemodel_1.default { - /** - * Creates a new `GetBlockTimeStampOffsetResponse` object. - * @param offset - Timestamp offset in seconds. - */ - constructor({ offset }) { - super(); - this.offset = offset; - this.attribute_map = { - offset: 'offset', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['offset'] === 'undefined') - throw new Error(`Response is missing required field 'offset': ${data}`); - return new GetBlockTimeStampOffsetResponse({ - offset: data['offset'], - }); - /* eslint-enable dot-notation */ - } -} -exports.GetBlockTimeStampOffsetResponse = GetBlockTimeStampOffsetResponse; -/** - * Response containing the ledger's minimum sync round - */ -class GetSyncRoundResponse extends basemodel_1.default { - /** - * Creates a new `GetSyncRoundResponse` object. - * @param round - The minimum sync round for the ledger. - */ - constructor({ round }) { - super(); - this.round = round; - this.attribute_map = { - round: 'round', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['round'] === 'undefined') - throw new Error(`Response is missing required field 'round': ${data}`); - return new GetSyncRoundResponse({ - round: data['round'], - }); - /* eslint-enable dot-notation */ - } -} -exports.GetSyncRoundResponse = GetSyncRoundResponse; -/** - * A single Delta containing the key, the previous value and the current value for - * a single round. - */ -class KvDelta extends basemodel_1.default { - /** - * Creates a new `KvDelta` object. - * @param key - The key, base64 encoded. - * @param value - The new value of the KV store entry, base64 encoded. - */ - constructor({ key, value, }) { - super(); - this.key = typeof key === 'string' ? (0, binarydata_1.base64ToBytes)(key) : key; - this.value = typeof value === 'string' ? (0, binarydata_1.base64ToBytes)(value) : value; - this.attribute_map = { - key: 'key', - value: 'value', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - return new KvDelta({ - key: data['key'], - value: data['value'], - }); - /* eslint-enable dot-notation */ - } -} -exports.KvDelta = KvDelta; -/** - * Contains a ledger delta for a single transaction group - */ -class LedgerStateDeltaForTransactionGroup extends basemodel_1.default { - /** - * Creates a new `LedgerStateDeltaForTransactionGroup` object. - * @param delta - Ledger StateDelta object - * @param ids - - */ - constructor({ delta, ids }) { - super(); - this.delta = delta; - this.ids = ids; - this.attribute_map = { - delta: 'Delta', - ids: 'Ids', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['Delta'] === 'undefined') - throw new Error(`Response is missing required field 'Delta': ${data}`); - if (!Array.isArray(data['Ids'])) - throw new Error(`Response is missing required array field 'Ids': ${data}`); - return new LedgerStateDeltaForTransactionGroup({ - delta: data['Delta'], - ids: data['Ids'], - }); - /* eslint-enable dot-notation */ - } -} -exports.LedgerStateDeltaForTransactionGroup = LedgerStateDeltaForTransactionGroup; -/** - * Proof of membership and position of a light block header. - */ -class LightBlockHeaderProof extends basemodel_1.default { - /** - * Creates a new `LightBlockHeaderProof` object. - * @param index - The index of the light block header in the vector commitment tree - * @param proof - The encoded proof. - * @param treedepth - Represents the depth of the tree that is being proven, i.e. the number of edges - * from a leaf to the root. - */ - constructor({ index, proof, treedepth, }) { - super(); - this.index = index; - this.proof = typeof proof === 'string' ? (0, binarydata_1.base64ToBytes)(proof) : proof; - this.treedepth = treedepth; - this.attribute_map = { - index: 'index', - proof: 'proof', - treedepth: 'treedepth', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['index'] === 'undefined') - throw new Error(`Response is missing required field 'index': ${data}`); - if (typeof data['proof'] === 'undefined') - throw new Error(`Response is missing required field 'proof': ${data}`); - if (typeof data['treedepth'] === 'undefined') - throw new Error(`Response is missing required field 'treedepth': ${data}`); - return new LightBlockHeaderProof({ - index: data['index'], - proof: data['proof'], - treedepth: data['treedepth'], - }); - /* eslint-enable dot-notation */ - } -} -exports.LightBlockHeaderProof = LightBlockHeaderProof; -/** - * - */ -class NodeStatusResponse extends basemodel_1.default { - /** - * Creates a new `NodeStatusResponse` object. - * @param catchupTime - CatchupTime in nanoseconds - * @param lastRound - LastRound indicates the last round seen - * @param lastVersion - LastVersion indicates the last consensus version supported - * @param nextVersion - NextVersion of consensus protocol to use - * @param nextVersionRound - NextVersionRound is the round at which the next consensus version will apply - * @param nextVersionSupported - NextVersionSupported indicates whether the next consensus version is supported - * by this node - * @param stoppedAtUnsupportedRound - StoppedAtUnsupportedRound indicates that the node does not support the new - * rounds and has stopped making progress - * @param timeSinceLastRound - TimeSinceLastRound in nanoseconds - * @param catchpoint - The current catchpoint that is being caught up to - * @param catchpointAcquiredBlocks - The number of blocks that have already been obtained by the node as part of the - * catchup - * @param catchpointProcessedAccounts - The number of accounts from the current catchpoint that have been processed so - * far as part of the catchup - * @param catchpointProcessedKvs - The number of key-values (KVs) from the current catchpoint that have been - * processed so far as part of the catchup - * @param catchpointTotalAccounts - The total number of accounts included in the current catchpoint - * @param catchpointTotalBlocks - The total number of blocks that are required to complete the current catchpoint - * catchup - * @param catchpointTotalKvs - The total number of key-values (KVs) included in the current catchpoint - * @param catchpointVerifiedAccounts - The number of accounts from the current catchpoint that have been verified so - * far as part of the catchup - * @param catchpointVerifiedKvs - The number of key-values (KVs) from the current catchpoint that have been - * verified so far as part of the catchup - * @param lastCatchpoint - The last catchpoint seen by the node - * @param upgradeDelay - Upgrade delay - * @param upgradeNextProtocolVoteBefore - Next protocol round - * @param upgradeNoVotes - No votes cast for consensus upgrade - * @param upgradeNodeVote - This node's upgrade vote - * @param upgradeVoteRounds - Total voting rounds for current upgrade - * @param upgradeVotes - Total votes cast for consensus upgrade - * @param upgradeVotesRequired - Yes votes required for consensus upgrade - * @param upgradeYesVotes - Yes votes cast for consensus upgrade - */ - constructor({ catchupTime, lastRound, lastVersion, nextVersion, nextVersionRound, nextVersionSupported, stoppedAtUnsupportedRound, timeSinceLastRound, catchpoint, catchpointAcquiredBlocks, catchpointProcessedAccounts, catchpointProcessedKvs, catchpointTotalAccounts, catchpointTotalBlocks, catchpointTotalKvs, catchpointVerifiedAccounts, catchpointVerifiedKvs, lastCatchpoint, upgradeDelay, upgradeNextProtocolVoteBefore, upgradeNoVotes, upgradeNodeVote, upgradeVoteRounds, upgradeVotes, upgradeVotesRequired, upgradeYesVotes, }) { - super(); - this.catchupTime = catchupTime; - this.lastRound = lastRound; - this.lastVersion = lastVersion; - this.nextVersion = nextVersion; - this.nextVersionRound = nextVersionRound; - this.nextVersionSupported = nextVersionSupported; - this.stoppedAtUnsupportedRound = stoppedAtUnsupportedRound; - this.timeSinceLastRound = timeSinceLastRound; - this.catchpoint = catchpoint; - this.catchpointAcquiredBlocks = catchpointAcquiredBlocks; - this.catchpointProcessedAccounts = catchpointProcessedAccounts; - this.catchpointProcessedKvs = catchpointProcessedKvs; - this.catchpointTotalAccounts = catchpointTotalAccounts; - this.catchpointTotalBlocks = catchpointTotalBlocks; - this.catchpointTotalKvs = catchpointTotalKvs; - this.catchpointVerifiedAccounts = catchpointVerifiedAccounts; - this.catchpointVerifiedKvs = catchpointVerifiedKvs; - this.lastCatchpoint = lastCatchpoint; - this.upgradeDelay = upgradeDelay; - this.upgradeNextProtocolVoteBefore = upgradeNextProtocolVoteBefore; - this.upgradeNoVotes = upgradeNoVotes; - this.upgradeNodeVote = upgradeNodeVote; - this.upgradeVoteRounds = upgradeVoteRounds; - this.upgradeVotes = upgradeVotes; - this.upgradeVotesRequired = upgradeVotesRequired; - this.upgradeYesVotes = upgradeYesVotes; - this.attribute_map = { - catchupTime: 'catchup-time', - lastRound: 'last-round', - lastVersion: 'last-version', - nextVersion: 'next-version', - nextVersionRound: 'next-version-round', - nextVersionSupported: 'next-version-supported', - stoppedAtUnsupportedRound: 'stopped-at-unsupported-round', - timeSinceLastRound: 'time-since-last-round', - catchpoint: 'catchpoint', - catchpointAcquiredBlocks: 'catchpoint-acquired-blocks', - catchpointProcessedAccounts: 'catchpoint-processed-accounts', - catchpointProcessedKvs: 'catchpoint-processed-kvs', - catchpointTotalAccounts: 'catchpoint-total-accounts', - catchpointTotalBlocks: 'catchpoint-total-blocks', - catchpointTotalKvs: 'catchpoint-total-kvs', - catchpointVerifiedAccounts: 'catchpoint-verified-accounts', - catchpointVerifiedKvs: 'catchpoint-verified-kvs', - lastCatchpoint: 'last-catchpoint', - upgradeDelay: 'upgrade-delay', - upgradeNextProtocolVoteBefore: 'upgrade-next-protocol-vote-before', - upgradeNoVotes: 'upgrade-no-votes', - upgradeNodeVote: 'upgrade-node-vote', - upgradeVoteRounds: 'upgrade-vote-rounds', - upgradeVotes: 'upgrade-votes', - upgradeVotesRequired: 'upgrade-votes-required', - upgradeYesVotes: 'upgrade-yes-votes', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['catchup-time'] === 'undefined') - throw new Error(`Response is missing required field 'catchup-time': ${data}`); - if (typeof data['last-round'] === 'undefined') - throw new Error(`Response is missing required field 'last-round': ${data}`); - if (typeof data['last-version'] === 'undefined') - throw new Error(`Response is missing required field 'last-version': ${data}`); - if (typeof data['next-version'] === 'undefined') - throw new Error(`Response is missing required field 'next-version': ${data}`); - if (typeof data['next-version-round'] === 'undefined') - throw new Error(`Response is missing required field 'next-version-round': ${data}`); - if (typeof data['next-version-supported'] === 'undefined') - throw new Error(`Response is missing required field 'next-version-supported': ${data}`); - if (typeof data['stopped-at-unsupported-round'] === 'undefined') - throw new Error(`Response is missing required field 'stopped-at-unsupported-round': ${data}`); - if (typeof data['time-since-last-round'] === 'undefined') - throw new Error(`Response is missing required field 'time-since-last-round': ${data}`); - return new NodeStatusResponse({ - catchupTime: data['catchup-time'], - lastRound: data['last-round'], - lastVersion: data['last-version'], - nextVersion: data['next-version'], - nextVersionRound: data['next-version-round'], - nextVersionSupported: data['next-version-supported'], - stoppedAtUnsupportedRound: data['stopped-at-unsupported-round'], - timeSinceLastRound: data['time-since-last-round'], - catchpoint: data['catchpoint'], - catchpointAcquiredBlocks: data['catchpoint-acquired-blocks'], - catchpointProcessedAccounts: data['catchpoint-processed-accounts'], - catchpointProcessedKvs: data['catchpoint-processed-kvs'], - catchpointTotalAccounts: data['catchpoint-total-accounts'], - catchpointTotalBlocks: data['catchpoint-total-blocks'], - catchpointTotalKvs: data['catchpoint-total-kvs'], - catchpointVerifiedAccounts: data['catchpoint-verified-accounts'], - catchpointVerifiedKvs: data['catchpoint-verified-kvs'], - lastCatchpoint: data['last-catchpoint'], - upgradeDelay: data['upgrade-delay'], - upgradeNextProtocolVoteBefore: data['upgrade-next-protocol-vote-before'], - upgradeNoVotes: data['upgrade-no-votes'], - upgradeNodeVote: data['upgrade-node-vote'], - upgradeVoteRounds: data['upgrade-vote-rounds'], - upgradeVotes: data['upgrade-votes'], - upgradeVotesRequired: data['upgrade-votes-required'], - upgradeYesVotes: data['upgrade-yes-votes'], - }); - /* eslint-enable dot-notation */ - } -} -exports.NodeStatusResponse = NodeStatusResponse; -/** - * Details about a pending transaction. If the transaction was recently confirmed, - * includes confirmation details like the round and reward details. - */ -class PendingTransactionResponse extends basemodel_1.default { - /** - * Creates a new `PendingTransactionResponse` object. - * @param poolError - Indicates that the transaction was kicked out of this node's transaction pool - * (and specifies why that happened). An empty string indicates the transaction - * wasn't kicked out of this node's txpool due to an error. - * @param txn - The raw signed transaction. - * @param applicationIndex - The application index if the transaction was found and it created an - * application. - * @param assetClosingAmount - The number of the asset's unit that were transferred to the close-to address. - * @param assetIndex - The asset index if the transaction was found and it created an asset. - * @param closeRewards - Rewards in microalgos applied to the close remainder to account. - * @param closingAmount - Closing amount for the transaction. - * @param confirmedRound - The round where this transaction was confirmed, if present. - * @param globalStateDelta - Global state key/value changes for the application being executed by this - * transaction. - * @param innerTxns - Inner transactions produced by application execution. - * @param localStateDelta - Local state key/value changes for the application being executed by this - * transaction. - * @param logs - Logs for the application being executed by this transaction. - * @param receiverRewards - Rewards in microalgos applied to the receiver account. - * @param senderRewards - Rewards in microalgos applied to the sender account. - */ - constructor({ poolError, txn, applicationIndex, assetClosingAmount, assetIndex, closeRewards, closingAmount, confirmedRound, globalStateDelta, innerTxns, localStateDelta, logs, receiverRewards, senderRewards, }) { - super(); - this.poolError = poolError; - this.txn = txn; - this.applicationIndex = applicationIndex; - this.assetClosingAmount = assetClosingAmount; - this.assetIndex = assetIndex; - this.closeRewards = closeRewards; - this.closingAmount = closingAmount; - this.confirmedRound = confirmedRound; - this.globalStateDelta = globalStateDelta; - this.innerTxns = innerTxns; - this.localStateDelta = localStateDelta; - this.logs = logs; - this.receiverRewards = receiverRewards; - this.senderRewards = senderRewards; - this.attribute_map = { - poolError: 'pool-error', - txn: 'txn', - applicationIndex: 'application-index', - assetClosingAmount: 'asset-closing-amount', - assetIndex: 'asset-index', - closeRewards: 'close-rewards', - closingAmount: 'closing-amount', - confirmedRound: 'confirmed-round', - globalStateDelta: 'global-state-delta', - innerTxns: 'inner-txns', - localStateDelta: 'local-state-delta', - logs: 'logs', - receiverRewards: 'receiver-rewards', - senderRewards: 'sender-rewards', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['pool-error'] === 'undefined') - throw new Error(`Response is missing required field 'pool-error': ${data}`); - if (typeof data['txn'] === 'undefined') - throw new Error(`Response is missing required field 'txn': ${data}`); - return new PendingTransactionResponse({ - poolError: data['pool-error'], - txn: data['txn'], - applicationIndex: data['application-index'], - assetClosingAmount: data['asset-closing-amount'], - assetIndex: data['asset-index'], - closeRewards: data['close-rewards'], - closingAmount: data['closing-amount'], - confirmedRound: data['confirmed-round'], - globalStateDelta: typeof data['global-state-delta'] !== 'undefined' - ? data['global-state-delta'].map(EvalDeltaKeyValue.from_obj_for_encoding) - : undefined, - innerTxns: typeof data['inner-txns'] !== 'undefined' - ? data['inner-txns'].map(PendingTransactionResponse.from_obj_for_encoding) - : undefined, - localStateDelta: typeof data['local-state-delta'] !== 'undefined' - ? data['local-state-delta'].map(AccountStateDelta.from_obj_for_encoding) - : undefined, - logs: data['logs'], - receiverRewards: data['receiver-rewards'], - senderRewards: data['sender-rewards'], - }); - /* eslint-enable dot-notation */ - } -} -exports.PendingTransactionResponse = PendingTransactionResponse; -/** - * A potentially truncated list of transactions currently in the node's transaction - * pool. You can compute whether or not the list is truncated if the number of - * elements in the **top-transactions** array is fewer than **total-transactions**. - */ -class PendingTransactionsResponse extends basemodel_1.default { - /** - * Creates a new `PendingTransactionsResponse` object. - * @param topTransactions - An array of signed transaction objects. - * @param totalTransactions - Total number of transactions in the pool. - */ - constructor({ topTransactions, totalTransactions, }) { - super(); - this.topTransactions = topTransactions; - this.totalTransactions = totalTransactions; - this.attribute_map = { - topTransactions: 'top-transactions', - totalTransactions: 'total-transactions', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (!Array.isArray(data['top-transactions'])) - throw new Error(`Response is missing required array field 'top-transactions': ${data}`); - if (typeof data['total-transactions'] === 'undefined') - throw new Error(`Response is missing required field 'total-transactions': ${data}`); - return new PendingTransactionsResponse({ - topTransactions: data['top-transactions'], - totalTransactions: data['total-transactions'], - }); - /* eslint-enable dot-notation */ - } -} -exports.PendingTransactionsResponse = PendingTransactionsResponse; -/** - * Transaction ID of the submission. - */ -class PostTransactionsResponse extends basemodel_1.default { - /** - * Creates a new `PostTransactionsResponse` object. - * @param txid - encoding of the transaction hash. - */ - constructor({ txid }) { - super(); - this.txid = txid; - this.attribute_map = { - txid: 'txId', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['txId'] === 'undefined') - throw new Error(`Response is missing required field 'txId': ${data}`); - return new PostTransactionsResponse({ - txid: data['txId'], - }); - /* eslint-enable dot-notation */ - } -} -exports.PostTransactionsResponse = PostTransactionsResponse; -/** - * A write operation into a scratch slot. - */ -class ScratchChange extends basemodel_1.default { - /** - * Creates a new `ScratchChange` object. - * @param newValue - Represents an AVM value. - * @param slot - The scratch slot written. - */ - constructor({ newValue, slot, }) { - super(); - this.newValue = newValue; - this.slot = slot; - this.attribute_map = { - newValue: 'new-value', - slot: 'slot', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['new-value'] === 'undefined') - throw new Error(`Response is missing required field 'new-value': ${data}`); - if (typeof data['slot'] === 'undefined') - throw new Error(`Response is missing required field 'slot': ${data}`); - return new ScratchChange({ - newValue: AvmValue.from_obj_for_encoding(data['new-value']), - slot: data['slot'], - }); - /* eslint-enable dot-notation */ - } -} -exports.ScratchChange = ScratchChange; -/** - * Initial states of resources that were accessed during simulation. - */ -class SimulateInitialStates extends basemodel_1.default { - /** - * Creates a new `SimulateInitialStates` object. - * @param appInitialStates - The initial states of accessed application before simulation. The order of this - * array is arbitrary. - */ - constructor({ appInitialStates, }) { - super(); - this.appInitialStates = appInitialStates; - this.attribute_map = { - appInitialStates: 'app-initial-states', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - return new SimulateInitialStates({ - appInitialStates: typeof data['app-initial-states'] !== 'undefined' - ? data['app-initial-states'].map(ApplicationInitialStates.from_obj_for_encoding) - : undefined, - }); - /* eslint-enable dot-notation */ - } -} -exports.SimulateInitialStates = SimulateInitialStates; -/** - * Request type for simulation endpoint. - */ -class SimulateRequest extends basemodel_1.default { - /** - * Creates a new `SimulateRequest` object. - * @param txnGroups - The transaction groups to simulate. - * @param allowEmptySignatures - Allows transactions without signatures to be simulated as if they had correct - * signatures. - * @param allowMoreLogging - Lifts limits on log opcode usage during simulation. - * @param allowUnnamedResources - Allows access to unnamed resources during simulation. - * @param execTraceConfig - An object that configures simulation execution trace. - * @param extraOpcodeBudget - Applies extra opcode budget during simulation for each transaction group. - * @param round - If provided, specifies the round preceding the simulation. State changes through - * this round will be used to run this simulation. Usually only the 4 most recent - * rounds will be available (controlled by the node config value MaxAcctLookback). - * If not specified, defaults to the latest available round. - */ - constructor({ txnGroups, allowEmptySignatures, allowMoreLogging, allowUnnamedResources, execTraceConfig, extraOpcodeBudget, round, }) { - super(); - this.txnGroups = txnGroups; - this.allowEmptySignatures = allowEmptySignatures; - this.allowMoreLogging = allowMoreLogging; - this.allowUnnamedResources = allowUnnamedResources; - this.execTraceConfig = execTraceConfig; - this.extraOpcodeBudget = extraOpcodeBudget; - this.round = round; - this.attribute_map = { - txnGroups: 'txn-groups', - allowEmptySignatures: 'allow-empty-signatures', - allowMoreLogging: 'allow-more-logging', - allowUnnamedResources: 'allow-unnamed-resources', - execTraceConfig: 'exec-trace-config', - extraOpcodeBudget: 'extra-opcode-budget', - round: 'round', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (!Array.isArray(data['txn-groups'])) - throw new Error(`Response is missing required array field 'txn-groups': ${data}`); - return new SimulateRequest({ - txnGroups: data['txn-groups'].map(SimulateRequestTransactionGroup.from_obj_for_encoding), - allowEmptySignatures: data['allow-empty-signatures'], - allowMoreLogging: data['allow-more-logging'], - allowUnnamedResources: data['allow-unnamed-resources'], - execTraceConfig: typeof data['exec-trace-config'] !== 'undefined' - ? SimulateTraceConfig.from_obj_for_encoding(data['exec-trace-config']) - : undefined, - extraOpcodeBudget: data['extra-opcode-budget'], - round: data['round'], - }); - /* eslint-enable dot-notation */ - } -} -exports.SimulateRequest = SimulateRequest; -/** - * A transaction group to simulate. - */ -class SimulateRequestTransactionGroup extends basemodel_1.default { - /** - * Creates a new `SimulateRequestTransactionGroup` object. - * @param txns - An atomic transaction group. - */ - constructor({ txns }) { - super(); - this.txns = txns; - this.attribute_map = { - txns: 'txns', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (!Array.isArray(data['txns'])) - throw new Error(`Response is missing required array field 'txns': ${data}`); - return new SimulateRequestTransactionGroup({ - txns: data['txns'], - }); - /* eslint-enable dot-notation */ - } -} -exports.SimulateRequestTransactionGroup = SimulateRequestTransactionGroup; -/** - * Result of a transaction group simulation. - */ -class SimulateResponse extends basemodel_1.default { - /** - * Creates a new `SimulateResponse` object. - * @param lastRound - The round immediately preceding this simulation. State changes through this - * round were used to run this simulation. - * @param txnGroups - A result object for each transaction group that was simulated. - * @param version - The version of this response object. - * @param evalOverrides - The set of parameters and limits override during simulation. If this set of - * parameters is present, then evaluation parameters may differ from standard - * evaluation in certain ways. - * @param execTraceConfig - An object that configures simulation execution trace. - * @param initialStates - Initial states of resources that were accessed during simulation. - */ - constructor({ lastRound, txnGroups, version, evalOverrides, execTraceConfig, initialStates, }) { - super(); - this.lastRound = lastRound; - this.txnGroups = txnGroups; - this.version = version; - this.evalOverrides = evalOverrides; - this.execTraceConfig = execTraceConfig; - this.initialStates = initialStates; - this.attribute_map = { - lastRound: 'last-round', - txnGroups: 'txn-groups', - version: 'version', - evalOverrides: 'eval-overrides', - execTraceConfig: 'exec-trace-config', - initialStates: 'initial-states', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['last-round'] === 'undefined') - throw new Error(`Response is missing required field 'last-round': ${data}`); - if (!Array.isArray(data['txn-groups'])) - throw new Error(`Response is missing required array field 'txn-groups': ${data}`); - if (typeof data['version'] === 'undefined') - throw new Error(`Response is missing required field 'version': ${data}`); - return new SimulateResponse({ - lastRound: data['last-round'], - txnGroups: data['txn-groups'].map(SimulateTransactionGroupResult.from_obj_for_encoding), - version: data['version'], - evalOverrides: typeof data['eval-overrides'] !== 'undefined' - ? SimulationEvalOverrides.from_obj_for_encoding(data['eval-overrides']) - : undefined, - execTraceConfig: typeof data['exec-trace-config'] !== 'undefined' - ? SimulateTraceConfig.from_obj_for_encoding(data['exec-trace-config']) - : undefined, - initialStates: typeof data['initial-states'] !== 'undefined' - ? SimulateInitialStates.from_obj_for_encoding(data['initial-states']) - : undefined, - }); - /* eslint-enable dot-notation */ - } -} -exports.SimulateResponse = SimulateResponse; -/** - * An object that configures simulation execution trace. - */ -class SimulateTraceConfig extends basemodel_1.default { - /** - * Creates a new `SimulateTraceConfig` object. - * @param enable - A boolean option for opting in execution trace features simulation endpoint. - * @param scratchChange - A boolean option enabling returning scratch slot changes together with execution - * trace during simulation. - * @param stackChange - A boolean option enabling returning stack changes together with execution trace - * during simulation. - * @param stateChange - A boolean option enabling returning application state changes (global, local, - * and box changes) with the execution trace during simulation. - */ - constructor({ enable, scratchChange, stackChange, stateChange, }) { - super(); - this.enable = enable; - this.scratchChange = scratchChange; - this.stackChange = stackChange; - this.stateChange = stateChange; - this.attribute_map = { - enable: 'enable', - scratchChange: 'scratch-change', - stackChange: 'stack-change', - stateChange: 'state-change', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - return new SimulateTraceConfig({ - enable: data['enable'], - scratchChange: data['scratch-change'], - stackChange: data['stack-change'], - stateChange: data['state-change'], - }); - /* eslint-enable dot-notation */ - } -} -exports.SimulateTraceConfig = SimulateTraceConfig; -/** - * Simulation result for an atomic transaction group - */ -class SimulateTransactionGroupResult extends basemodel_1.default { - /** - * Creates a new `SimulateTransactionGroupResult` object. - * @param txnResults - Simulation result for individual transactions - * @param appBudgetAdded - Total budget added during execution of app calls in the transaction group. - * @param appBudgetConsumed - Total budget consumed during execution of app calls in the transaction group. - * @param failedAt - If present, indicates which transaction in this group caused the failure. This - * array represents the path to the failing transaction. Indexes are zero based, - * the first element indicates the top-level transaction, and successive elements - * indicate deeper inner transactions. - * @param failureMessage - If present, indicates that the transaction group failed and specifies why that - * happened - * @param unnamedResourcesAccessed - These are resources that were accessed by this group that would normally have - * caused failure, but were allowed in simulation. Depending on where this object - * is in the response, the unnamed resources it contains may or may not qualify for - * group resource sharing. If this is a field in SimulateTransactionGroupResult, - * the resources do qualify, but if this is a field in SimulateTransactionResult, - * they do not qualify. In order to make this group valid for actual submission, - * resources that qualify for group sharing can be made available by any - * transaction of the group; otherwise, resources must be placed in the same - * transaction which accessed them. - */ - constructor({ txnResults, appBudgetAdded, appBudgetConsumed, failedAt, failureMessage, unnamedResourcesAccessed, }) { - super(); - this.txnResults = txnResults; - this.appBudgetAdded = appBudgetAdded; - this.appBudgetConsumed = appBudgetConsumed; - this.failedAt = failedAt; - this.failureMessage = failureMessage; - this.unnamedResourcesAccessed = unnamedResourcesAccessed; - this.attribute_map = { - txnResults: 'txn-results', - appBudgetAdded: 'app-budget-added', - appBudgetConsumed: 'app-budget-consumed', - failedAt: 'failed-at', - failureMessage: 'failure-message', - unnamedResourcesAccessed: 'unnamed-resources-accessed', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (!Array.isArray(data['txn-results'])) - throw new Error(`Response is missing required array field 'txn-results': ${data}`); - return new SimulateTransactionGroupResult({ - txnResults: data['txn-results'].map(SimulateTransactionResult.from_obj_for_encoding), - appBudgetAdded: data['app-budget-added'], - appBudgetConsumed: data['app-budget-consumed'], - failedAt: data['failed-at'], - failureMessage: data['failure-message'], - unnamedResourcesAccessed: typeof data['unnamed-resources-accessed'] !== 'undefined' - ? SimulateUnnamedResourcesAccessed.from_obj_for_encoding(data['unnamed-resources-accessed']) - : undefined, - }); - /* eslint-enable dot-notation */ - } -} -exports.SimulateTransactionGroupResult = SimulateTransactionGroupResult; -/** - * Simulation result for an individual transaction - */ -class SimulateTransactionResult extends basemodel_1.default { - /** - * Creates a new `SimulateTransactionResult` object. - * @param txnResult - Details about a pending transaction. If the transaction was recently confirmed, - * includes confirmation details like the round and reward details. - * @param appBudgetConsumed - Budget used during execution of an app call transaction. This value includes - * budged used by inner app calls spawned by this transaction. - * @param execTrace - The execution trace of calling an app or a logic sig, containing the inner app - * call trace in a recursive way. - * @param logicSigBudgetConsumed - Budget used during execution of a logic sig transaction. - * @param unnamedResourcesAccessed - These are resources that were accessed by this group that would normally have - * caused failure, but were allowed in simulation. Depending on where this object - * is in the response, the unnamed resources it contains may or may not qualify for - * group resource sharing. If this is a field in SimulateTransactionGroupResult, - * the resources do qualify, but if this is a field in SimulateTransactionResult, - * they do not qualify. In order to make this group valid for actual submission, - * resources that qualify for group sharing can be made available by any - * transaction of the group; otherwise, resources must be placed in the same - * transaction which accessed them. - */ - constructor({ txnResult, appBudgetConsumed, execTrace, logicSigBudgetConsumed, unnamedResourcesAccessed, }) { - super(); - this.txnResult = txnResult; - this.appBudgetConsumed = appBudgetConsumed; - this.execTrace = execTrace; - this.logicSigBudgetConsumed = logicSigBudgetConsumed; - this.unnamedResourcesAccessed = unnamedResourcesAccessed; - this.attribute_map = { - txnResult: 'txn-result', - appBudgetConsumed: 'app-budget-consumed', - execTrace: 'exec-trace', - logicSigBudgetConsumed: 'logic-sig-budget-consumed', - unnamedResourcesAccessed: 'unnamed-resources-accessed', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['txn-result'] === 'undefined') - throw new Error(`Response is missing required field 'txn-result': ${data}`); - return new SimulateTransactionResult({ - txnResult: PendingTransactionResponse.from_obj_for_encoding(data['txn-result']), - appBudgetConsumed: data['app-budget-consumed'], - execTrace: typeof data['exec-trace'] !== 'undefined' - ? SimulationTransactionExecTrace.from_obj_for_encoding(data['exec-trace']) - : undefined, - logicSigBudgetConsumed: data['logic-sig-budget-consumed'], - unnamedResourcesAccessed: typeof data['unnamed-resources-accessed'] !== 'undefined' - ? SimulateUnnamedResourcesAccessed.from_obj_for_encoding(data['unnamed-resources-accessed']) - : undefined, - }); - /* eslint-enable dot-notation */ - } -} -exports.SimulateTransactionResult = SimulateTransactionResult; -/** - * These are resources that were accessed by this group that would normally have - * caused failure, but were allowed in simulation. Depending on where this object - * is in the response, the unnamed resources it contains may or may not qualify for - * group resource sharing. If this is a field in SimulateTransactionGroupResult, - * the resources do qualify, but if this is a field in SimulateTransactionResult, - * they do not qualify. In order to make this group valid for actual submission, - * resources that qualify for group sharing can be made available by any - * transaction of the group; otherwise, resources must be placed in the same - * transaction which accessed them. - */ -class SimulateUnnamedResourcesAccessed extends basemodel_1.default { - /** - * Creates a new `SimulateUnnamedResourcesAccessed` object. - * @param accounts - The unnamed accounts that were referenced. The order of this array is arbitrary. - * @param appLocals - The unnamed application local states that were referenced. The order of this - * array is arbitrary. - * @param apps - The unnamed applications that were referenced. The order of this array is - * arbitrary. - * @param assetHoldings - The unnamed asset holdings that were referenced. The order of this array is - * arbitrary. - * @param assets - The unnamed assets that were referenced. The order of this array is arbitrary. - * @param boxes - The unnamed boxes that were referenced. The order of this array is arbitrary. - * @param extraBoxRefs - The number of extra box references used to increase the IO budget. This is in - * addition to the references defined in the input transaction group and any - * referenced to unnamed boxes. - */ - constructor({ accounts, appLocals, apps, assetHoldings, assets, boxes, extraBoxRefs, }) { - super(); - this.accounts = accounts; - this.appLocals = appLocals; - this.apps = apps; - this.assetHoldings = assetHoldings; - this.assets = assets; - this.boxes = boxes; - this.extraBoxRefs = extraBoxRefs; - this.attribute_map = { - accounts: 'accounts', - appLocals: 'app-locals', - apps: 'apps', - assetHoldings: 'asset-holdings', - assets: 'assets', - boxes: 'boxes', - extraBoxRefs: 'extra-box-refs', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - return new SimulateUnnamedResourcesAccessed({ - accounts: data['accounts'], - appLocals: typeof data['app-locals'] !== 'undefined' - ? data['app-locals'].map(ApplicationLocalReference.from_obj_for_encoding) - : undefined, - apps: data['apps'], - assetHoldings: typeof data['asset-holdings'] !== 'undefined' - ? data['asset-holdings'].map(AssetHoldingReference.from_obj_for_encoding) - : undefined, - assets: data['assets'], - boxes: typeof data['boxes'] !== 'undefined' - ? data['boxes'].map(BoxReference.from_obj_for_encoding) - : undefined, - extraBoxRefs: data['extra-box-refs'], - }); - /* eslint-enable dot-notation */ - } -} -exports.SimulateUnnamedResourcesAccessed = SimulateUnnamedResourcesAccessed; -/** - * The set of parameters and limits override during simulation. If this set of - * parameters is present, then evaluation parameters may differ from standard - * evaluation in certain ways. - */ -class SimulationEvalOverrides extends basemodel_1.default { - /** - * Creates a new `SimulationEvalOverrides` object. - * @param allowEmptySignatures - If true, transactions without signatures are allowed and simulated as if they - * were properly signed. - * @param allowUnnamedResources - If true, allows access to unnamed resources during simulation. - * @param extraOpcodeBudget - The extra opcode budget added to each transaction group during simulation - * @param maxLogCalls - The maximum log calls one can make during simulation - * @param maxLogSize - The maximum byte number to log during simulation - */ - constructor({ allowEmptySignatures, allowUnnamedResources, extraOpcodeBudget, maxLogCalls, maxLogSize, }) { - super(); - this.allowEmptySignatures = allowEmptySignatures; - this.allowUnnamedResources = allowUnnamedResources; - this.extraOpcodeBudget = extraOpcodeBudget; - this.maxLogCalls = maxLogCalls; - this.maxLogSize = maxLogSize; - this.attribute_map = { - allowEmptySignatures: 'allow-empty-signatures', - allowUnnamedResources: 'allow-unnamed-resources', - extraOpcodeBudget: 'extra-opcode-budget', - maxLogCalls: 'max-log-calls', - maxLogSize: 'max-log-size', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - return new SimulationEvalOverrides({ - allowEmptySignatures: data['allow-empty-signatures'], - allowUnnamedResources: data['allow-unnamed-resources'], - extraOpcodeBudget: data['extra-opcode-budget'], - maxLogCalls: data['max-log-calls'], - maxLogSize: data['max-log-size'], - }); - /* eslint-enable dot-notation */ - } -} -exports.SimulationEvalOverrides = SimulationEvalOverrides; -/** - * The set of trace information and effect from evaluating a single opcode. - */ -class SimulationOpcodeTraceUnit extends basemodel_1.default { - /** - * Creates a new `SimulationOpcodeTraceUnit` object. - * @param pc - The program counter of the current opcode being evaluated. - * @param scratchChanges - The writes into scratch slots. - * @param spawnedInners - The indexes of the traces for inner transactions spawned by this opcode, if any. - * @param stackAdditions - The values added by this opcode to the stack. - * @param stackPopCount - The number of deleted stack values by this opcode. - * @param stateChanges - The operations against the current application's states. - */ - constructor({ pc, scratchChanges, spawnedInners, stackAdditions, stackPopCount, stateChanges, }) { - super(); - this.pc = pc; - this.scratchChanges = scratchChanges; - this.spawnedInners = spawnedInners; - this.stackAdditions = stackAdditions; - this.stackPopCount = stackPopCount; - this.stateChanges = stateChanges; - this.attribute_map = { - pc: 'pc', - scratchChanges: 'scratch-changes', - spawnedInners: 'spawned-inners', - stackAdditions: 'stack-additions', - stackPopCount: 'stack-pop-count', - stateChanges: 'state-changes', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['pc'] === 'undefined') - throw new Error(`Response is missing required field 'pc': ${data}`); - return new SimulationOpcodeTraceUnit({ - pc: data['pc'], - scratchChanges: typeof data['scratch-changes'] !== 'undefined' - ? data['scratch-changes'].map(ScratchChange.from_obj_for_encoding) - : undefined, - spawnedInners: data['spawned-inners'], - stackAdditions: typeof data['stack-additions'] !== 'undefined' - ? data['stack-additions'].map(AvmValue.from_obj_for_encoding) - : undefined, - stackPopCount: data['stack-pop-count'], - stateChanges: typeof data['state-changes'] !== 'undefined' - ? data['state-changes'].map(ApplicationStateOperation.from_obj_for_encoding) - : undefined, - }); - /* eslint-enable dot-notation */ - } -} -exports.SimulationOpcodeTraceUnit = SimulationOpcodeTraceUnit; -/** - * The execution trace of calling an app or a logic sig, containing the inner app - * call trace in a recursive way. - */ -class SimulationTransactionExecTrace extends basemodel_1.default { - /** - * Creates a new `SimulationTransactionExecTrace` object. - * @param approvalProgramHash - SHA512_256 hash digest of the approval program executed in transaction. - * @param approvalProgramTrace - Program trace that contains a trace of opcode effects in an approval program. - * @param clearStateProgramHash - SHA512_256 hash digest of the clear state program executed in transaction. - * @param clearStateProgramTrace - Program trace that contains a trace of opcode effects in a clear state program. - * @param clearStateRollback - If true, indicates that the clear state program failed and any persistent state - * changes it produced should be reverted once the program exits. - * @param clearStateRollbackError - The error message explaining why the clear state program failed. This field will - * only be populated if clear-state-rollback is true and the failure was due to an - * execution error. - * @param innerTrace - An array of SimulationTransactionExecTrace representing the execution trace of - * any inner transactions executed. - * @param logicSigHash - SHA512_256 hash digest of the logic sig executed in transaction. - * @param logicSigTrace - Program trace that contains a trace of opcode effects in a logic sig. - */ - constructor({ approvalProgramHash, approvalProgramTrace, clearStateProgramHash, clearStateProgramTrace, clearStateRollback, clearStateRollbackError, innerTrace, logicSigHash, logicSigTrace, }) { - super(); - this.approvalProgramHash = - typeof approvalProgramHash === 'string' - ? (0, binarydata_1.base64ToBytes)(approvalProgramHash) - : approvalProgramHash; - this.approvalProgramTrace = approvalProgramTrace; - this.clearStateProgramHash = - typeof clearStateProgramHash === 'string' - ? (0, binarydata_1.base64ToBytes)(clearStateProgramHash) - : clearStateProgramHash; - this.clearStateProgramTrace = clearStateProgramTrace; - this.clearStateRollback = clearStateRollback; - this.clearStateRollbackError = clearStateRollbackError; - this.innerTrace = innerTrace; - this.logicSigHash = - typeof logicSigHash === 'string' - ? (0, binarydata_1.base64ToBytes)(logicSigHash) - : logicSigHash; - this.logicSigTrace = logicSigTrace; - this.attribute_map = { - approvalProgramHash: 'approval-program-hash', - approvalProgramTrace: 'approval-program-trace', - clearStateProgramHash: 'clear-state-program-hash', - clearStateProgramTrace: 'clear-state-program-trace', - clearStateRollback: 'clear-state-rollback', - clearStateRollbackError: 'clear-state-rollback-error', - innerTrace: 'inner-trace', - logicSigHash: 'logic-sig-hash', - logicSigTrace: 'logic-sig-trace', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - return new SimulationTransactionExecTrace({ - approvalProgramHash: data['approval-program-hash'], - approvalProgramTrace: typeof data['approval-program-trace'] !== 'undefined' - ? data['approval-program-trace'].map(SimulationOpcodeTraceUnit.from_obj_for_encoding) - : undefined, - clearStateProgramHash: data['clear-state-program-hash'], - clearStateProgramTrace: typeof data['clear-state-program-trace'] !== 'undefined' - ? data['clear-state-program-trace'].map(SimulationOpcodeTraceUnit.from_obj_for_encoding) - : undefined, - clearStateRollback: data['clear-state-rollback'], - clearStateRollbackError: data['clear-state-rollback-error'], - innerTrace: typeof data['inner-trace'] !== 'undefined' - ? data['inner-trace'].map(SimulationTransactionExecTrace.from_obj_for_encoding) - : undefined, - logicSigHash: data['logic-sig-hash'], - logicSigTrace: typeof data['logic-sig-trace'] !== 'undefined' - ? data['logic-sig-trace'].map(SimulationOpcodeTraceUnit.from_obj_for_encoding) - : undefined, - }); - /* eslint-enable dot-notation */ - } -} -exports.SimulationTransactionExecTrace = SimulationTransactionExecTrace; -/** - * Represents a state proof and its corresponding message - */ -class StateProof extends basemodel_1.default { - /** - * Creates a new `StateProof` object. - * @param message - Represents the message that the state proofs are attesting to. - * @param stateproof - The encoded StateProof for the message. - */ - constructor({ message, stateproof, }) { - super(); - this.message = message; - this.stateproof = - typeof stateproof === 'string' ? (0, binarydata_1.base64ToBytes)(stateproof) : stateproof; - this.attribute_map = { - message: 'Message', - stateproof: 'StateProof', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['Message'] === 'undefined') - throw new Error(`Response is missing required field 'Message': ${data}`); - if (typeof data['StateProof'] === 'undefined') - throw new Error(`Response is missing required field 'StateProof': ${data}`); - return new StateProof({ - message: StateProofMessage.from_obj_for_encoding(data['Message']), - stateproof: data['StateProof'], - }); - /* eslint-enable dot-notation */ - } -} -exports.StateProof = StateProof; -/** - * Represents the message that the state proofs are attesting to. - */ -class StateProofMessage extends basemodel_1.default { - /** - * Creates a new `StateProofMessage` object. - * @param blockheaderscommitment - The vector commitment root on all light block headers within a state proof - * interval. - * @param firstattestedround - The first round the message attests to. - * @param lastattestedround - The last round the message attests to. - * @param lnprovenweight - An integer value representing the natural log of the proven weight with 16 bits - * of precision. This value would be used to verify the next state proof. - * @param voterscommitment - The vector commitment root of the top N accounts to sign the next StateProof. - */ - constructor({ blockheaderscommitment, firstattestedround, lastattestedround, lnprovenweight, voterscommitment, }) { - super(); - this.blockheaderscommitment = - typeof blockheaderscommitment === 'string' - ? (0, binarydata_1.base64ToBytes)(blockheaderscommitment) - : blockheaderscommitment; - this.firstattestedround = firstattestedround; - this.lastattestedround = lastattestedround; - this.lnprovenweight = lnprovenweight; - this.voterscommitment = - typeof voterscommitment === 'string' - ? (0, binarydata_1.base64ToBytes)(voterscommitment) - : voterscommitment; - this.attribute_map = { - blockheaderscommitment: 'BlockHeadersCommitment', - firstattestedround: 'FirstAttestedRound', - lastattestedround: 'LastAttestedRound', - lnprovenweight: 'LnProvenWeight', - voterscommitment: 'VotersCommitment', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['BlockHeadersCommitment'] === 'undefined') - throw new Error(`Response is missing required field 'BlockHeadersCommitment': ${data}`); - if (typeof data['FirstAttestedRound'] === 'undefined') - throw new Error(`Response is missing required field 'FirstAttestedRound': ${data}`); - if (typeof data['LastAttestedRound'] === 'undefined') - throw new Error(`Response is missing required field 'LastAttestedRound': ${data}`); - if (typeof data['LnProvenWeight'] === 'undefined') - throw new Error(`Response is missing required field 'LnProvenWeight': ${data}`); - if (typeof data['VotersCommitment'] === 'undefined') - throw new Error(`Response is missing required field 'VotersCommitment': ${data}`); - return new StateProofMessage({ - blockheaderscommitment: data['BlockHeadersCommitment'], - firstattestedround: data['FirstAttestedRound'], - lastattestedround: data['LastAttestedRound'], - lnprovenweight: data['LnProvenWeight'], - voterscommitment: data['VotersCommitment'], - }); - /* eslint-enable dot-notation */ - } -} -exports.StateProofMessage = StateProofMessage; -/** - * Supply represents the current supply of MicroAlgos in the system. - */ -class SupplyResponse extends basemodel_1.default { - /** - * Creates a new `SupplyResponse` object. - * @param currentRound - Round - * @param onlineMoney - OnlineMoney - * @param totalMoney - TotalMoney - */ - constructor({ currentRound, onlineMoney, totalMoney, }) { - super(); - this.currentRound = currentRound; - this.onlineMoney = onlineMoney; - this.totalMoney = totalMoney; - this.attribute_map = { - currentRound: 'current_round', - onlineMoney: 'online-money', - totalMoney: 'total-money', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['current_round'] === 'undefined') - throw new Error(`Response is missing required field 'current_round': ${data}`); - if (typeof data['online-money'] === 'undefined') - throw new Error(`Response is missing required field 'online-money': ${data}`); - if (typeof data['total-money'] === 'undefined') - throw new Error(`Response is missing required field 'total-money': ${data}`); - return new SupplyResponse({ - currentRound: data['current_round'], - onlineMoney: data['online-money'], - totalMoney: data['total-money'], - }); - /* eslint-enable dot-notation */ - } -} -exports.SupplyResponse = SupplyResponse; -/** - * Represents a key-value pair in an application store. - */ -class TealKeyValue extends basemodel_1.default { - /** - * Creates a new `TealKeyValue` object. - * @param key - - * @param value - Represents a TEAL value. - */ - constructor({ key, value }) { - super(); - this.key = key; - this.value = value; - this.attribute_map = { - key: 'key', - value: 'value', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['key'] === 'undefined') - throw new Error(`Response is missing required field 'key': ${data}`); - if (typeof data['value'] === 'undefined') - throw new Error(`Response is missing required field 'value': ${data}`); - return new TealKeyValue({ - key: data['key'], - value: TealValue.from_obj_for_encoding(data['value']), - }); - /* eslint-enable dot-notation */ - } -} -exports.TealKeyValue = TealKeyValue; -/** - * Represents a TEAL value. - */ -class TealValue extends basemodel_1.default { - /** - * Creates a new `TealValue` object. - * @param type - (tt) value type. Value `1` refers to **bytes**, value `2` refers to **uint** - * @param bytes - (tb) bytes value. - * @param uint - (ui) uint value. - */ - constructor({ type, bytes, uint, }) { - super(); - this.type = type; - this.bytes = bytes; - this.uint = uint; - this.attribute_map = { - type: 'type', - bytes: 'bytes', - uint: 'uint', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['type'] === 'undefined') - throw new Error(`Response is missing required field 'type': ${data}`); - if (typeof data['bytes'] === 'undefined') - throw new Error(`Response is missing required field 'bytes': ${data}`); - if (typeof data['uint'] === 'undefined') - throw new Error(`Response is missing required field 'uint': ${data}`); - return new TealValue({ - type: data['type'], - bytes: data['bytes'], - uint: data['uint'], - }); - /* eslint-enable dot-notation */ - } -} -exports.TealValue = TealValue; -/** - * Response containing all ledger state deltas for transaction groups, with their - * associated Ids, in a single round. - */ -class TransactionGroupLedgerStateDeltasForRoundResponse extends basemodel_1.default { - /** - * Creates a new `TransactionGroupLedgerStateDeltasForRoundResponse` object. - * @param deltas - - */ - constructor({ deltas }) { - super(); - this.deltas = deltas; - this.attribute_map = { - deltas: 'Deltas', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (!Array.isArray(data['Deltas'])) - throw new Error(`Response is missing required array field 'Deltas': ${data}`); - return new TransactionGroupLedgerStateDeltasForRoundResponse({ - deltas: data['Deltas'].map(LedgerStateDeltaForTransactionGroup.from_obj_for_encoding), - }); - /* eslint-enable dot-notation */ - } -} -exports.TransactionGroupLedgerStateDeltasForRoundResponse = TransactionGroupLedgerStateDeltasForRoundResponse; -/** - * TransactionParams contains the parameters that help a client construct a new - * transaction. - */ -class TransactionParametersResponse extends basemodel_1.default { - /** - * Creates a new `TransactionParametersResponse` object. - * @param consensusVersion - ConsensusVersion indicates the consensus protocol version - * as of LastRound. - * @param fee - Fee is the suggested transaction fee - * Fee is in units of micro-Algos per byte. - * Fee may fall to zero but transactions must still have a fee of - * at least MinTxnFee for the current network protocol. - * @param genesisHash - GenesisHash is the hash of the genesis block. - * @param genesisId - GenesisID is an ID listed in the genesis block. - * @param lastRound - LastRound indicates the last round seen - * @param minFee - The minimum transaction fee (not per byte) required for the - * txn to validate for the current network protocol. - */ - constructor({ consensusVersion, fee, genesisHash, genesisId, lastRound, minFee, }) { - super(); - this.consensusVersion = consensusVersion; - this.fee = fee; - this.genesisHash = - typeof genesisHash === 'string' - ? (0, binarydata_1.base64ToBytes)(genesisHash) - : genesisHash; - this.genesisId = genesisId; - this.lastRound = lastRound; - this.minFee = minFee; - this.attribute_map = { - consensusVersion: 'consensus-version', - fee: 'fee', - genesisHash: 'genesis-hash', - genesisId: 'genesis-id', - lastRound: 'last-round', - minFee: 'min-fee', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['consensus-version'] === 'undefined') - throw new Error(`Response is missing required field 'consensus-version': ${data}`); - if (typeof data['fee'] === 'undefined') - throw new Error(`Response is missing required field 'fee': ${data}`); - if (typeof data['genesis-hash'] === 'undefined') - throw new Error(`Response is missing required field 'genesis-hash': ${data}`); - if (typeof data['genesis-id'] === 'undefined') - throw new Error(`Response is missing required field 'genesis-id': ${data}`); - if (typeof data['last-round'] === 'undefined') - throw new Error(`Response is missing required field 'last-round': ${data}`); - if (typeof data['min-fee'] === 'undefined') - throw new Error(`Response is missing required field 'min-fee': ${data}`); - return new TransactionParametersResponse({ - consensusVersion: data['consensus-version'], - fee: data['fee'], - genesisHash: data['genesis-hash'], - genesisId: data['genesis-id'], - lastRound: data['last-round'], - minFee: data['min-fee'], - }); - /* eslint-enable dot-notation */ - } -} -exports.TransactionParametersResponse = TransactionParametersResponse; -/** - * Proof of transaction in a block. - */ -class TransactionProofResponse extends basemodel_1.default { - /** - * Creates a new `TransactionProofResponse` object. - * @param idx - Index of the transaction in the block's payset. - * @param proof - Proof of transaction membership. - * @param stibhash - Hash of SignedTxnInBlock for verifying proof. - * @param treedepth - Represents the depth of the tree that is being proven, i.e. the number of edges - * from a leaf to the root. - * @param hashtype - The type of hash function used to create the proof, must be one of: - * * sha512_256 - * * sha256 - */ - constructor({ idx, proof, stibhash, treedepth, hashtype, }) { - super(); - this.idx = idx; - this.proof = typeof proof === 'string' ? (0, binarydata_1.base64ToBytes)(proof) : proof; - this.stibhash = - typeof stibhash === 'string' ? (0, binarydata_1.base64ToBytes)(stibhash) : stibhash; - this.treedepth = treedepth; - this.hashtype = hashtype; - this.attribute_map = { - idx: 'idx', - proof: 'proof', - stibhash: 'stibhash', - treedepth: 'treedepth', - hashtype: 'hashtype', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['idx'] === 'undefined') - throw new Error(`Response is missing required field 'idx': ${data}`); - if (typeof data['proof'] === 'undefined') - throw new Error(`Response is missing required field 'proof': ${data}`); - if (typeof data['stibhash'] === 'undefined') - throw new Error(`Response is missing required field 'stibhash': ${data}`); - if (typeof data['treedepth'] === 'undefined') - throw new Error(`Response is missing required field 'treedepth': ${data}`); - return new TransactionProofResponse({ - idx: data['idx'], - proof: data['proof'], - stibhash: data['stibhash'], - treedepth: data['treedepth'], - hashtype: data['hashtype'], - }); - /* eslint-enable dot-notation */ - } -} -exports.TransactionProofResponse = TransactionProofResponse; -/** - * algod version information. - */ -class Version extends basemodel_1.default { - /** - * Creates a new `Version` object. - * @param build - - * @param genesisHashB64 - - * @param genesisId - - * @param versions - - */ - constructor({ build, genesisHashB64, genesisId, versions, }) { - super(); - this.build = build; - this.genesisHashB64 = - typeof genesisHashB64 === 'string' - ? (0, binarydata_1.base64ToBytes)(genesisHashB64) - : genesisHashB64; - this.genesisId = genesisId; - this.versions = versions; - this.attribute_map = { - build: 'build', - genesisHashB64: 'genesis_hash_b64', - genesisId: 'genesis_id', - versions: 'versions', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['build'] === 'undefined') - throw new Error(`Response is missing required field 'build': ${data}`); - if (typeof data['genesis_hash_b64'] === 'undefined') - throw new Error(`Response is missing required field 'genesis_hash_b64': ${data}`); - if (typeof data['genesis_id'] === 'undefined') - throw new Error(`Response is missing required field 'genesis_id': ${data}`); - if (!Array.isArray(data['versions'])) - throw new Error(`Response is missing required array field 'versions': ${data}`); - return new Version({ - build: BuildVersion.from_obj_for_encoding(data['build']), - genesisHashB64: data['genesis_hash_b64'], - genesisId: data['genesis_id'], - versions: data['versions'], - }); - /* eslint-enable dot-notation */ - } -} -exports.Version = Version; diff --git a/algosdk/client/v2/algod/pendingTransactionInformation.d.ts b/algosdk/client/v2/algod/pendingTransactionInformation.d.ts deleted file mode 100644 index a20c8b8..0000000 --- a/algosdk/client/v2/algod/pendingTransactionInformation.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import HTTPClient from '../../client'; -import { PendingTransactionResponse } from './models/types'; -/** - * returns the transaction information for a specific txid of a pending transaction - */ -export default class PendingTransactionInformation extends JSONRequest { - private txid; - constructor(c: HTTPClient, txid: string); - prepare(body: Uint8Array): PendingTransactionResponse; - path(): string; - max(max: number): this; -} diff --git a/algosdk/client/v2/algod/pendingTransactionInformation.js b/algosdk/client/v2/algod/pendingTransactionInformation.js deleted file mode 100644 index 1e4fa5c..0000000 --- a/algosdk/client/v2/algod/pendingTransactionInformation.js +++ /dev/null @@ -1,58 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -const encoding = __importStar(require("../../../encoding/encoding")); -const types_1 = require("./models/types"); -/** - * returns the transaction information for a specific txid of a pending transaction - */ -class PendingTransactionInformation extends jsonrequest_1.default { - constructor(c, txid) { - super(c); - this.txid = txid; - this.txid = txid; - this.query.format = 'msgpack'; - } - // eslint-disable-next-line class-methods-use-this - prepare(body) { - if (body && body.byteLength > 0) { - return types_1.PendingTransactionResponse.from_obj_for_encoding(encoding.decode(body)); - } - return undefined; - } - path() { - return `/v2/transactions/pending/${this.txid}`; - } - // max sets the maximum number of txs to return - max(max) { - this.query.max = max; - return this; - } -} -exports.default = PendingTransactionInformation; diff --git a/algosdk/client/v2/algod/pendingTransactions.d.ts b/algosdk/client/v2/algod/pendingTransactions.d.ts deleted file mode 100644 index f74376b..0000000 --- a/algosdk/client/v2/algod/pendingTransactions.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import HTTPClient from '../../client'; -import { PendingTransactionsResponse } from './models/types'; -/** - * pendingTransactionsInformation returns transactions that are pending in the pool - */ -export default class PendingTransactions extends JSONRequest { - constructor(c: HTTPClient); - path(): string; - prepare(body: Uint8Array): PendingTransactionsResponse; - max(max: number): this; -} diff --git a/algosdk/client/v2/algod/pendingTransactions.js b/algosdk/client/v2/algod/pendingTransactions.js deleted file mode 100644 index 212b019..0000000 --- a/algosdk/client/v2/algod/pendingTransactions.js +++ /dev/null @@ -1,57 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -const encoding = __importStar(require("../../../encoding/encoding")); -const types_1 = require("./models/types"); -/** - * pendingTransactionsInformation returns transactions that are pending in the pool - */ -class PendingTransactions extends jsonrequest_1.default { - constructor(c) { - super(c); - this.query.format = 'msgpack'; - } - /* eslint-disable class-methods-use-this */ - path() { - return '/v2/transactions/pending'; - } - prepare(body) { - if (body && body.byteLength > 0) { - return types_1.PendingTransactionsResponse.from_obj_for_encoding(encoding.decode(body)); - } - return undefined; - } - /* eslint-enable class-methods-use-this */ - // max sets the maximum number of txs to return - max(max) { - this.query.max = max; - return this; - } -} -exports.default = PendingTransactions; diff --git a/algosdk/client/v2/algod/pendingTransactionsByAddress.d.ts b/algosdk/client/v2/algod/pendingTransactionsByAddress.d.ts deleted file mode 100644 index 29fd1ef..0000000 --- a/algosdk/client/v2/algod/pendingTransactionsByAddress.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import HTTPClient from '../../client'; -import { PendingTransactionsResponse } from './models/types'; -/** - * returns all transactions for a PK [addr] in the [first, last] rounds range. - */ -export default class PendingTransactionsByAddress extends JSONRequest { - private address; - constructor(c: HTTPClient, address: string); - prepare(body: Uint8Array): PendingTransactionsResponse; - path(): string; - max(max: number): this; -} diff --git a/algosdk/client/v2/algod/pendingTransactionsByAddress.js b/algosdk/client/v2/algod/pendingTransactionsByAddress.js deleted file mode 100644 index 712264f..0000000 --- a/algosdk/client/v2/algod/pendingTransactionsByAddress.js +++ /dev/null @@ -1,58 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -const encoding = __importStar(require("../../../encoding/encoding")); -const types_1 = require("./models/types"); -/** - * returns all transactions for a PK [addr] in the [first, last] rounds range. - */ -class PendingTransactionsByAddress extends jsonrequest_1.default { - constructor(c, address) { - super(c); - this.address = address; - this.address = address; - this.query.format = 'msgpack'; - } - // eslint-disable-next-line class-methods-use-this - prepare(body) { - if (body && body.byteLength > 0) { - return types_1.PendingTransactionsResponse.from_obj_for_encoding(encoding.decode(body)); - } - return undefined; - } - path() { - return `/v2/accounts/${this.address}/transactions/pending`; - } - // max sets the maximum number of txs to return - max(max) { - this.query.max = max; - return this; - } -} -exports.default = PendingTransactionsByAddress; diff --git a/algosdk/client/v2/algod/ready.d.ts b/algosdk/client/v2/algod/ready.d.ts deleted file mode 100644 index 40adbf7..0000000 --- a/algosdk/client/v2/algod/ready.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -import JSONRequest from '../jsonrequest'; -export default class Ready extends JSONRequest { - path(): string; -} diff --git a/algosdk/client/v2/algod/ready.js b/algosdk/client/v2/algod/ready.js deleted file mode 100644 index 023a5fb..0000000 --- a/algosdk/client/v2/algod/ready.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -class Ready extends jsonrequest_1.default { - // eslint-disable-next-line class-methods-use-this - path() { - return `/ready`; - } -} -exports.default = Ready; diff --git a/algosdk/client/v2/algod/sendRawTransaction.d.ts b/algosdk/client/v2/algod/sendRawTransaction.d.ts deleted file mode 100644 index 48586be..0000000 --- a/algosdk/client/v2/algod/sendRawTransaction.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { PostTransactionsResponse } from './models/types'; -import HTTPClient from '../../client'; -import JSONRequest from '../jsonrequest'; -/** - * Sets the default header (if not previously set) for sending a raw - * transaction. - * @param headers - A headers object - */ -export declare function setSendTransactionHeaders(headers?: {}): {}; -/** - * broadcasts the passed signed txns to the network - */ -export default class SendRawTransaction extends JSONRequest> { - private txnBytesToPost; - constructor(c: HTTPClient, stxOrStxs: Uint8Array | Uint8Array[]); - path(): string; - do(headers?: {}): Promise; - prepare(body: Record): PostTransactionsResponse; -} diff --git a/algosdk/client/v2/algod/sendRawTransaction.js b/algosdk/client/v2/algod/sendRawTransaction.js deleted file mode 100644 index 899cda3..0000000 --- a/algosdk/client/v2/algod/sendRawTransaction.js +++ /dev/null @@ -1,60 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.setSendTransactionHeaders = void 0; -const utils_1 = require("../../../utils/utils"); -const types_1 = require("./models/types"); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -/** - * Sets the default header (if not previously set) for sending a raw - * transaction. - * @param headers - A headers object - */ -function setSendTransactionHeaders(headers = {}) { - let hdrs = headers; - if (Object.keys(hdrs).every((key) => key.toLowerCase() !== 'content-type')) { - hdrs = { ...headers }; - hdrs['Content-Type'] = 'application/x-binary'; - } - return hdrs; -} -exports.setSendTransactionHeaders = setSendTransactionHeaders; -function isByteArray(array) { - return array && array.byteLength !== undefined; -} -/** - * broadcasts the passed signed txns to the network - */ -class SendRawTransaction extends jsonrequest_1.default { - constructor(c, stxOrStxs) { - super(c); - let forPosting = stxOrStxs; - if (Array.isArray(stxOrStxs)) { - if (!stxOrStxs.every(isByteArray)) { - throw new TypeError('Array elements must be byte arrays'); - } - // Flatten into a single Uint8Array - forPosting = (0, utils_1.concatArrays)(...stxOrStxs); - } - else if (!isByteArray(forPosting)) { - throw new TypeError('Argument must be byte array'); - } - this.txnBytesToPost = forPosting; - } - // eslint-disable-next-line class-methods-use-this - path() { - return '/v2/transactions'; - } - async do(headers = {}) { - const txHeaders = setSendTransactionHeaders(headers); - const res = await this.c.post(this.path(), this.txnBytesToPost, null, txHeaders); - return this.prepare(res.body); - } - // eslint-disable-next-line class-methods-use-this - prepare(body) { - return types_1.PostTransactionsResponse.from_obj_for_encoding(body); - } -} -exports.default = SendRawTransaction; diff --git a/algosdk/client/v2/algod/setBlockOffsetTimestamp.d.ts b/algosdk/client/v2/algod/setBlockOffsetTimestamp.d.ts deleted file mode 100644 index 91a9d7f..0000000 --- a/algosdk/client/v2/algod/setBlockOffsetTimestamp.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; -export default class SetBlockOffsetTimestamp extends JSONRequest { - private offset; - constructor(c: HTTPClient, intDecoding: IntDecoding, offset: number); - path(): string; - do(headers?: {}): Promise; -} diff --git a/algosdk/client/v2/algod/setBlockOffsetTimestamp.js b/algosdk/client/v2/algod/setBlockOffsetTimestamp.js deleted file mode 100644 index f455ee7..0000000 --- a/algosdk/client/v2/algod/setBlockOffsetTimestamp.js +++ /dev/null @@ -1,21 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -class SetBlockOffsetTimestamp extends jsonrequest_1.default { - constructor(c, intDecoding, offset) { - super(c, intDecoding); - this.offset = offset; - this.offset = offset; - } - path() { - return `/v2/devmode/blocks/offset/${this.offset}`; - } - async do(headers = {}) { - const res = await this.c.post(this.path(), null, null, headers); - return res.body; - } -} -exports.default = SetBlockOffsetTimestamp; diff --git a/algosdk/client/v2/algod/setSyncRound.d.ts b/algosdk/client/v2/algod/setSyncRound.d.ts deleted file mode 100644 index 96e3260..0000000 --- a/algosdk/client/v2/algod/setSyncRound.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; -export default class SetSyncRound extends JSONRequest { - private round; - constructor(c: HTTPClient, intDecoding: IntDecoding, round: number); - path(): string; - do(headers?: {}): Promise; -} diff --git a/algosdk/client/v2/algod/setSyncRound.js b/algosdk/client/v2/algod/setSyncRound.js deleted file mode 100644 index 4b5d413..0000000 --- a/algosdk/client/v2/algod/setSyncRound.js +++ /dev/null @@ -1,21 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -class SetSyncRound extends jsonrequest_1.default { - constructor(c, intDecoding, round) { - super(c, intDecoding); - this.round = round; - this.round = round; - } - path() { - return `/v2/ledger/sync/${this.round}`; - } - async do(headers = {}) { - const res = await this.c.post(this.path(), null, null, headers); - return res.body; - } -} -exports.default = SetSyncRound; diff --git a/algosdk/client/v2/algod/simulateTransaction.d.ts b/algosdk/client/v2/algod/simulateTransaction.d.ts deleted file mode 100644 index 5bdb07b..0000000 --- a/algosdk/client/v2/algod/simulateTransaction.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -import HTTPClient from '../../client'; -import JSONRequest from '../jsonrequest'; -import { SimulateRequest, SimulateResponse } from './models/types'; -/** - * Sets the default header (if not previously set) for simulating a raw - * transaction. - * @param headers - A headers object - */ -export declare function setSimulateTransactionsHeaders(headers?: {}): {}; -/** - * Simulates signed txns. - */ -export default class SimulateRawTransactions extends JSONRequest { - private requestBytes; - constructor(c: HTTPClient, request: SimulateRequest); - path(): string; - do(headers?: {}): Promise; - prepare(body: Uint8Array): SimulateResponse; -} diff --git a/algosdk/client/v2/algod/simulateTransaction.js b/algosdk/client/v2/algod/simulateTransaction.js deleted file mode 100644 index 219087b..0000000 --- a/algosdk/client/v2/algod/simulateTransaction.js +++ /dev/null @@ -1,71 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.setSimulateTransactionsHeaders = void 0; -const encoding = __importStar(require("../../../encoding/encoding")); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -const types_1 = require("./models/types"); -/** - * Sets the default header (if not previously set) for simulating a raw - * transaction. - * @param headers - A headers object - */ -function setSimulateTransactionsHeaders(headers = {}) { - let hdrs = headers; - if (Object.keys(hdrs).every((key) => key.toLowerCase() !== 'content-type')) { - hdrs = { ...headers }; - hdrs['Content-Type'] = 'application/msgpack'; - } - return hdrs; -} -exports.setSimulateTransactionsHeaders = setSimulateTransactionsHeaders; -/** - * Simulates signed txns. - */ -class SimulateRawTransactions extends jsonrequest_1.default { - constructor(c, request) { - super(c); - this.query.format = 'msgpack'; - this.requestBytes = encoding.rawEncode(request.get_obj_for_encoding(true)); - } - // eslint-disable-next-line class-methods-use-this - path() { - return '/v2/transactions/simulate'; - } - async do(headers = {}) { - const txHeaders = setSimulateTransactionsHeaders(headers); - const res = await this.c.post(this.path(), this.requestBytes, this.query, txHeaders, false); - return this.prepare(res.body); - } - // eslint-disable-next-line class-methods-use-this - prepare(body) { - const decoded = encoding.decode(body); - return types_1.SimulateResponse.from_obj_for_encoding(decoded); - } -} -exports.default = SimulateRawTransactions; diff --git a/algosdk/client/v2/algod/stateproof.d.ts b/algosdk/client/v2/algod/stateproof.d.ts deleted file mode 100644 index df4efb1..0000000 --- a/algosdk/client/v2/algod/stateproof.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; -import { StateProof as SP } from './models/types'; -export default class StateProof extends JSONRequest> { - private round; - constructor(c: HTTPClient, intDecoding: IntDecoding, round: number); - path(): string; - prepare(body: Record): SP; -} diff --git a/algosdk/client/v2/algod/stateproof.js b/algosdk/client/v2/algod/stateproof.js deleted file mode 100644 index 4e38e51..0000000 --- a/algosdk/client/v2/algod/stateproof.js +++ /dev/null @@ -1,22 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -const types_1 = require("./models/types"); -class StateProof extends jsonrequest_1.default { - constructor(c, intDecoding, round) { - super(c, intDecoding); - this.round = round; - this.round = round; - } - path() { - return `/v2/stateproofs/${this.round}`; - } - // eslint-disable-next-line class-methods-use-this - prepare(body) { - return types_1.StateProof.from_obj_for_encoding(body); - } -} -exports.default = StateProof; diff --git a/algosdk/client/v2/algod/status.d.ts b/algosdk/client/v2/algod/status.d.ts deleted file mode 100644 index b283b31..0000000 --- a/algosdk/client/v2/algod/status.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import { NodeStatusResponse } from './models/types'; -export default class Status extends JSONRequest> { - path(): string; - prepare(body: Record): NodeStatusResponse; -} diff --git a/algosdk/client/v2/algod/status.js b/algosdk/client/v2/algod/status.js deleted file mode 100644 index 2ef0b46..0000000 --- a/algosdk/client/v2/algod/status.js +++ /dev/null @@ -1,18 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -const types_1 = require("./models/types"); -class Status extends jsonrequest_1.default { - // eslint-disable-next-line class-methods-use-this - path() { - return '/v2/status'; - } - // eslint-disable-next-line class-methods-use-this - prepare(body) { - return types_1.NodeStatusResponse.from_obj_for_encoding(body); - } -} -exports.default = Status; diff --git a/algosdk/client/v2/algod/statusAfterBlock.d.ts b/algosdk/client/v2/algod/statusAfterBlock.d.ts deleted file mode 100644 index df29d74..0000000 --- a/algosdk/client/v2/algod/statusAfterBlock.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; -import { NodeStatusResponse } from './models/types'; -export default class StatusAfterBlock extends JSONRequest> { - private round; - constructor(c: HTTPClient, intDecoding: IntDecoding, round: number); - path(): string; - prepare(body: Record): NodeStatusResponse; -} diff --git a/algosdk/client/v2/algod/statusAfterBlock.js b/algosdk/client/v2/algod/statusAfterBlock.js deleted file mode 100644 index 2bc1daf..0000000 --- a/algosdk/client/v2/algod/statusAfterBlock.js +++ /dev/null @@ -1,24 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -const types_1 = require("./models/types"); -class StatusAfterBlock extends jsonrequest_1.default { - constructor(c, intDecoding, round) { - super(c, intDecoding); - this.round = round; - if (!Number.isInteger(round)) - throw Error('round should be an integer'); - this.round = round; - } - path() { - return `/v2/status/wait-for-block-after/${this.round}`; - } - // eslint-disable-next-line class-methods-use-this - prepare(body) { - return types_1.NodeStatusResponse.from_obj_for_encoding(body); - } -} -exports.default = StatusAfterBlock; diff --git a/algosdk/client/v2/algod/suggestedParams.d.ts b/algosdk/client/v2/algod/suggestedParams.d.ts deleted file mode 100644 index 54ed4f6..0000000 --- a/algosdk/client/v2/algod/suggestedParams.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import { SuggestedParamsWithMinFee } from '../../../types/transactions/base'; -/** - * Returns the common needed parameters for a new transaction, in a format the transaction builder expects - */ -export default class SuggestedParamsRequest extends JSONRequest> { - path(): string; - prepare(body: Record): SuggestedParamsWithMinFee; -} diff --git a/algosdk/client/v2/algod/suggestedParams.js b/algosdk/client/v2/algod/suggestedParams.js deleted file mode 100644 index 8bff096..0000000 --- a/algosdk/client/v2/algod/suggestedParams.js +++ /dev/null @@ -1,27 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -/** - * Returns the common needed parameters for a new transaction, in a format the transaction builder expects - */ -class SuggestedParamsRequest extends jsonrequest_1.default { - /* eslint-disable class-methods-use-this */ - path() { - return '/v2/transactions/params'; - } - prepare(body) { - return { - flatFee: false, - fee: body.fee, - firstValid: body['last-round'], - lastValid: body['last-round'] + 1000, - genesisID: body['genesis-id'], - genesisHash: body['genesis-hash'], - minFee: body['min-fee'], - }; - } -} -exports.default = SuggestedParamsRequest; diff --git a/algosdk/client/v2/algod/supply.d.ts b/algosdk/client/v2/algod/supply.d.ts deleted file mode 100644 index f6b4342..0000000 --- a/algosdk/client/v2/algod/supply.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import { SupplyResponse } from './models/types'; -export default class Supply extends JSONRequest> { - path(): string; - prepare(body: Record): SupplyResponse; -} diff --git a/algosdk/client/v2/algod/supply.js b/algosdk/client/v2/algod/supply.js deleted file mode 100644 index 15e5032..0000000 --- a/algosdk/client/v2/algod/supply.js +++ /dev/null @@ -1,18 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -const types_1 = require("./models/types"); -class Supply extends jsonrequest_1.default { - // eslint-disable-next-line class-methods-use-this - path() { - return '/v2/ledger/supply'; - } - // eslint-disable-next-line class-methods-use-this - prepare(body) { - return types_1.SupplyResponse.from_obj_for_encoding(body); - } -} -exports.default = Supply; diff --git a/algosdk/client/v2/algod/unsetSyncRound.d.ts b/algosdk/client/v2/algod/unsetSyncRound.d.ts deleted file mode 100644 index 7c3f95b..0000000 --- a/algosdk/client/v2/algod/unsetSyncRound.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -import JSONRequest from '../jsonrequest'; -export default class UnsetSyncRound extends JSONRequest { - path(): string; - do(headers?: {}): Promise; -} diff --git a/algosdk/client/v2/algod/unsetSyncRound.js b/algosdk/client/v2/algod/unsetSyncRound.js deleted file mode 100644 index 4f28869..0000000 --- a/algosdk/client/v2/algod/unsetSyncRound.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -class UnsetSyncRound extends jsonrequest_1.default { - // eslint-disable-next-line class-methods-use-this - path() { - return `/v2/ledger/sync`; - } - async do(headers = {}) { - const res = await this.c.delete(this.path(), headers); - return res.body; - } -} -exports.default = UnsetSyncRound; diff --git a/algosdk/client/v2/algod/versions.d.ts b/algosdk/client/v2/algod/versions.d.ts deleted file mode 100644 index 50e5e22..0000000 --- a/algosdk/client/v2/algod/versions.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import { Version } from './models/types'; -/** - * retrieves the VersionResponse from the running node - */ -export default class Versions extends JSONRequest> { - path(): string; - prepare(body: Record): Version; -} diff --git a/algosdk/client/v2/algod/versions.js b/algosdk/client/v2/algod/versions.js deleted file mode 100644 index cce8c5a..0000000 --- a/algosdk/client/v2/algod/versions.js +++ /dev/null @@ -1,21 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -const types_1 = require("./models/types"); -/** - * retrieves the VersionResponse from the running node - */ -class Versions extends jsonrequest_1.default { - // eslint-disable-next-line class-methods-use-this - path() { - return '/versions'; - } - // eslint-disable-next-line class-methods-use-this - prepare(body) { - return types_1.Version.from_obj_for_encoding(body); - } -} -exports.default = Versions; diff --git a/algosdk/client/v2/basemodel.d.ts b/algosdk/client/v2/basemodel.d.ts deleted file mode 100644 index 147b106..0000000 --- a/algosdk/client/v2/basemodel.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Base class for models - */ -export default class BaseModel { - attribute_map: Record; - /** - * Get an object ready for encoding to either JSON or msgpack. - * @param binary - Use true to indicate that the encoding can handle raw binary objects - * (Uint8Arrays). Use false to indicate that raw binary objects should be converted to base64 - * strings. True should be used for objects that will be encoded with msgpack, and false should - * be used for objects that will be encoded with JSON. - */ - get_obj_for_encoding(binary?: boolean): Record; -} diff --git a/algosdk/client/v2/basemodel.js b/algosdk/client/v2/basemodel.js deleted file mode 100644 index f1b5a07..0000000 --- a/algosdk/client/v2/basemodel.js +++ /dev/null @@ -1,66 +0,0 @@ -"use strict"; -/** - * Base class for models - */ -Object.defineProperty(exports, "__esModule", { value: true }); -const binarydata_1 = require("../../encoding/binarydata"); -/* eslint-disable no-underscore-dangle,camelcase */ -function _is_primitive(val) { - /* eslint-enable no-underscore-dangle,camelcase */ - return (val === undefined || - val == null || - (typeof val !== 'object' && typeof val !== 'function')); -} -function _get_obj_for_encoding(val, binary) { - /* eslint-enable no-underscore-dangle,camelcase,no-redeclare,no-unused-vars */ - let targetPropValue; - if (val instanceof Uint8Array) { - targetPropValue = binary ? val : (0, binarydata_1.bytesToBase64)(val); - } - else if (typeof val.get_obj_for_encoding === 'function') { - targetPropValue = val.get_obj_for_encoding(binary); - } - else if (Array.isArray(val)) { - targetPropValue = []; - for (const elem of val) { - targetPropValue.push(_get_obj_for_encoding(elem, binary)); - } - } - else if (typeof val === 'object') { - const obj = {}; - for (const prop of Object.keys(val)) { - obj[prop] = _get_obj_for_encoding(val[prop], binary); - } - targetPropValue = obj; - } - else if (_is_primitive(val)) { - targetPropValue = val; - } - else { - throw new Error(`Unsupported value: ${String(val)}`); - } - return targetPropValue; -} -class BaseModel { - /** - * Get an object ready for encoding to either JSON or msgpack. - * @param binary - Use true to indicate that the encoding can handle raw binary objects - * (Uint8Arrays). Use false to indicate that raw binary objects should be converted to base64 - * strings. True should be used for objects that will be encoded with msgpack, and false should - * be used for objects that will be encoded with JSON. - */ - get_obj_for_encoding(binary = false) { - /* eslint-enable no-underscore-dangle,camelcase */ - const obj = {}; - for (const prop of Object.keys(this.attribute_map)) { - const name = this.attribute_map[prop]; - const value = this[prop]; - if (typeof value !== 'undefined') { - obj[name] = - value === null ? null : _get_obj_for_encoding(value, binary); - } - } - return obj; - } -} -exports.default = BaseModel; diff --git a/algosdk/client/v2/indexer/indexer.d.ts b/algosdk/client/v2/indexer/indexer.d.ts deleted file mode 100644 index 42350fe..0000000 --- a/algosdk/client/v2/indexer/indexer.d.ts +++ /dev/null @@ -1,348 +0,0 @@ -import ServiceClient from '../serviceClient'; -import MakeHealthCheck from './makeHealthCheck'; -import LookupAssetBalances from './lookupAssetBalances'; -import LookupAssetTransactions from './lookupAssetTransactions'; -import LookupAccountTransactions from './lookupAccountTransactions'; -import LookupBlock from './lookupBlock'; -import LookupTransactionByID from './lookupTransactionByID'; -import LookupAccountByID from './lookupAccountByID'; -import LookupAccountAssets from './lookupAccountAssets'; -import LookupAccountCreatedAssets from './lookupAccountCreatedAssets'; -import LookupAccountAppLocalStates from './lookupAccountAppLocalStates'; -import LookupAccountCreatedApplications from './lookupAccountCreatedApplications'; -import LookupAssetByID from './lookupAssetByID'; -import LookupApplications from './lookupApplications'; -import LookupApplicationLogs from './lookupApplicationLogs'; -import LookupApplicationBoxByIDandName from './lookupApplicationBoxByIDandName'; -import SearchAccounts from './searchAccounts'; -import SearchForTransactions from './searchForTransactions'; -import SearchForAssets from './searchForAssets'; -import SearchForApplications from './searchForApplications'; -import SearchForApplicationBoxes from './searchForApplicationBoxes'; -import { BaseHTTPClient } from '../../baseHTTPClient'; -import { CustomTokenHeader, IndexerTokenHeader } from '../../urlTokenBaseHTTPClient'; -/** - * The Indexer provides a REST API interface of API calls to support searching the Algorand Blockchain. - * - * The Indexer REST APIs retrieve the blockchain data from a PostgreSQL compatible database that must be populated. - * - * This database is populated using the same indexer instance or a separate instance of the indexer which must connect to the algod process of a running Algorand node to read block data. - * - * This node must also be an Archival node to make searching the entire blockchain possible. - * - * #### Relevant Information - * [Learn more about Indexer](https://developer.algorand.org/docs/get-details/indexer/) - * - * [Run Indexer in Postman OAS3](https://developer.algorand.org/docs/rest-apis/restendpoints/#algod-indexer-and-kmd-rest-endpoints) - */ -export default class IndexerClient extends ServiceClient { - /** - * Create an IndexerClient from - * * either a token, baseServer, port, and optional headers - * * or a base client server for interoperability with external dApp wallets - * - * #### Example - * ```typescript - * const token = ""; - * const server = "http://localhost"; - * const port = 8980; - * const indexerClient = new algosdk.Indexer(token, server, port); - * ``` - * @remarks - * The above configuration is for a sandbox private network. - * For applications on production, you are encouraged to run your own node with indexer, or use an Algorand REST API provider with a dedicated API key. - * - * @param tokenOrBaseClient - The API token for the Indexer API - * @param baseServer - REST endpoint - * @param port - Port number if specifically configured by the server - * @param headers - Optional headers - */ - constructor(tokenOrBaseClient: string | IndexerTokenHeader | CustomTokenHeader | BaseHTTPClient, baseServer?: string, port?: string | number, headers?: Record); - /** - * Returns the health object for the service. - * Returns 200 if healthy. - * - * #### Example - * ```typescript - * const health = await indexerClient.makeHealthCheck().do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-health) - * @category GET - */ - makeHealthCheck(): MakeHealthCheck; - /** - * Returns the list of accounts who hold the given asset and their balance. - * - * #### Example - * ```typescript - * const assetId = 163650; - * const assetBalances = await indexerClient.lookupAssetBalances(assetId).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2assetsasset-idbalances) - * @param index - The asset ID to look up. - * @category GET - */ - lookupAssetBalances(index: number): LookupAssetBalances; - /** - * Returns transactions relating to the given asset. - * - * #### Example - * ```typescript - * const assetId = 163650; - * const assetTxns = await indexerClient.lookupAssetTransactions(assetId).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2assetsasset-idtransactions) - * @param index - The asset ID to look up. - * @category GET - */ - lookupAssetTransactions(index: number): LookupAssetTransactions; - /** - * Returns transactions relating to the given account. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountTxns = await indexerClient.lookupAccountTransactions(address).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2accountsaccount-idtransactions) - * @param account - The address of the account. - * @category GET - */ - lookupAccountTransactions(account: string): LookupAccountTransactions; - /** - * Returns the block for the passed round. - * - * #### Example - * ```typescript - * const targetBlock = 18309917; - * const blockInfo = await indexerClient.lookupBlock(targetBlock).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2blocksround-number) - * @param round - The number of the round to look up. - * @category GET - */ - lookupBlock(round: number): LookupBlock; - /** - * Returns information about the given transaction. - * - * #### Example - * ```typescript - * const txnId = "MEUOC4RQJB23CQZRFRKYEI6WBO73VTTPST5A7B3S5OKBUY6LFUDA"; - * const txnInfo = await indexerClient.lookupTransactionByID(txnId).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2transactionstxid) - * @param txID - The ID of the transaction to look up. - * @category GET - */ - lookupTransactionByID(txID: string): LookupTransactionByID; - /** - * Returns information about the given account. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountInfo = await indexerClient.lookupAccountByID(address).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2accountsaccount-id) - * @param account - The address of the account to look up. - * @category GET - */ - lookupAccountByID(account: string): LookupAccountByID; - /** - * Returns asset about the given account. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountAssets = await indexerClient.lookupAccountAssets(address).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2accountsaccount-idassets) - * @param account - The address of the account to look up. - * @category GET - */ - lookupAccountAssets(account: string): LookupAccountAssets; - /** - * Returns asset information created by the given account. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountCreatedAssets = await indexerClient.lookupAccountCreatedAssets(address).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2accountsaccount-idcreated-assets) - * @param account - The address of the account to look up. - * @category GET - */ - lookupAccountCreatedAssets(account: string): LookupAccountCreatedAssets; - /** - * Returns application local state about the given account. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountAppLocalStates = await indexerClient.lookupAccountAppLocalStates(address).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2accountsaccount-idapps-local-state) - * @param account - The address of the account to look up. - * @category GET - */ - lookupAccountAppLocalStates(account: string): LookupAccountAppLocalStates; - /** - * Returns application information created by the given account. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountCreatedApps = await indexerClient.lookupAccountCreatedApplications(address).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2accountsaccount-idcreated-applications) - * @param account - The address of the account to look up. - * @category GET - */ - lookupAccountCreatedApplications(account: string): LookupAccountCreatedApplications; - /** - * Returns information about the passed asset. - * - * #### Example - * ```typescript - * const assetId = 163650; - * const assetInfo = await indexerClient.lookupAssetByID(assetId).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2assetsasset-id) - * @param index - The ID of the asset ot look up. - * @category GET - */ - lookupAssetByID(index: number): LookupAssetByID; - /** - * Returns information about the passed application. - * - * #### Example - * ```typescript - * const appId = 60553466; - * const appInfo = await indexerClient.lookupApplications(appId).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2applicationsapplication-id) - * @param index - The ID of the application to look up. - * @category GET - */ - lookupApplications(index: number): LookupApplications; - /** - * Returns log messages generated by the passed in application. - * - * #### Example - * ```typescript - * const appId = 60553466; - * const appLogs = await indexerClient.lookupApplicationLogs(appId).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2applicationsapplication-idlogs) - * @param appID - The ID of the application which generated the logs. - * @category GET - */ - lookupApplicationLogs(appID: number): LookupApplicationLogs; - /** - * Returns information about indexed accounts. - * - * #### Example - * ```typescript - * const accounts = await indexerClient.searchAccounts().do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2accounts) - * @category GET - */ - searchAccounts(): SearchAccounts; - /** - * Returns information about indexed transactions. - * - * #### Example - * ```typescript - * const txns = await indexerClient.searchForTransactions().do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2transactions) - * @category GET - */ - searchForTransactions(): SearchForTransactions; - /** - * Returns information about indexed assets. - * - * #### Example - * ```typescript - * const assets = await indexerClient.searchForAssets().do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2assets) - * @category GET - */ - searchForAssets(): SearchForAssets; - /** - * Returns information about indexed applications. - * - * #### Example - * ```typescript - * const apps = await indexerClient.searchForApplications().do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2applications) - * @category GET - */ - searchForApplications(): SearchForApplications; - /** - * Returns information about indexed application boxes. - * - * #### Example - * ```typescript - * const maxResults = 20; - * const appID = 1234; - * - * const responsePage1 = await indexerClient - * .searchForApplicationBoxes(appID) - * .limit(maxResults) - * .do(); - * const boxNamesPage1 = responsePage1.boxes.map(box => box.name); - * - * const responsePage2 = await indexerClient - * .searchForApplicationBoxes(appID) - * .limit(maxResults) - * .nextToken(responsePage1.nextToken) - * .do(); - * const boxNamesPage2 = responsePage2.boxes.map(box => box.name); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2applicationsapplication-idboxes) - * @param appID - The ID of the application with boxes. - * @category GET - */ - searchForApplicationBoxes(appID: number): SearchForApplicationBoxes; - /** - * Returns information about the application box given its name. - * - * #### Example - * ```typescript - * const boxName = Buffer.from("foo"); - * const boxResponse = await indexerClient - * .LookupApplicationBoxByIDandName(1234, boxName) - * .do(); - * const boxValue = boxResponse.value; - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2applicationsapplication-idbox) - * @param appID - The ID of the application with boxes. - * @category GET - */ - lookupApplicationBoxByIDandName(appID: number, boxName: Uint8Array): LookupApplicationBoxByIDandName; -} diff --git a/algosdk/client/v2/indexer/indexer.js b/algosdk/client/v2/indexer/indexer.js deleted file mode 100644 index 1571e86..0000000 --- a/algosdk/client/v2/indexer/indexer.js +++ /dev/null @@ -1,394 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const serviceClient_1 = __importDefault(require("../serviceClient")); -const makeHealthCheck_1 = __importDefault(require("./makeHealthCheck")); -const lookupAssetBalances_1 = __importDefault(require("./lookupAssetBalances")); -const lookupAssetTransactions_1 = __importDefault(require("./lookupAssetTransactions")); -const lookupAccountTransactions_1 = __importDefault(require("./lookupAccountTransactions")); -const lookupBlock_1 = __importDefault(require("./lookupBlock")); -const lookupTransactionByID_1 = __importDefault(require("./lookupTransactionByID")); -const lookupAccountByID_1 = __importDefault(require("./lookupAccountByID")); -const lookupAccountAssets_1 = __importDefault(require("./lookupAccountAssets")); -const lookupAccountCreatedAssets_1 = __importDefault(require("./lookupAccountCreatedAssets")); -const lookupAccountAppLocalStates_1 = __importDefault(require("./lookupAccountAppLocalStates")); -const lookupAccountCreatedApplications_1 = __importDefault(require("./lookupAccountCreatedApplications")); -const lookupAssetByID_1 = __importDefault(require("./lookupAssetByID")); -const lookupApplications_1 = __importDefault(require("./lookupApplications")); -const lookupApplicationLogs_1 = __importDefault(require("./lookupApplicationLogs")); -const lookupApplicationBoxByIDandName_1 = __importDefault(require("./lookupApplicationBoxByIDandName")); -const searchAccounts_1 = __importDefault(require("./searchAccounts")); -const searchForTransactions_1 = __importDefault(require("./searchForTransactions")); -const searchForAssets_1 = __importDefault(require("./searchForAssets")); -const searchForApplications_1 = __importDefault(require("./searchForApplications")); -const searchForApplicationBoxes_1 = __importDefault(require("./searchForApplicationBoxes")); -/** - * The Indexer provides a REST API interface of API calls to support searching the Algorand Blockchain. - * - * The Indexer REST APIs retrieve the blockchain data from a PostgreSQL compatible database that must be populated. - * - * This database is populated using the same indexer instance or a separate instance of the indexer which must connect to the algod process of a running Algorand node to read block data. - * - * This node must also be an Archival node to make searching the entire blockchain possible. - * - * #### Relevant Information - * [Learn more about Indexer](https://developer.algorand.org/docs/get-details/indexer/) - * - * [Run Indexer in Postman OAS3](https://developer.algorand.org/docs/rest-apis/restendpoints/#algod-indexer-and-kmd-rest-endpoints) - */ -class IndexerClient extends serviceClient_1.default { - /** - * Create an IndexerClient from - * * either a token, baseServer, port, and optional headers - * * or a base client server for interoperability with external dApp wallets - * - * #### Example - * ```typescript - * const token = ""; - * const server = "http://localhost"; - * const port = 8980; - * const indexerClient = new algosdk.Indexer(token, server, port); - * ``` - * @remarks - * The above configuration is for a sandbox private network. - * For applications on production, you are encouraged to run your own node with indexer, or use an Algorand REST API provider with a dedicated API key. - * - * @param tokenOrBaseClient - The API token for the Indexer API - * @param baseServer - REST endpoint - * @param port - Port number if specifically configured by the server - * @param headers - Optional headers - */ - constructor(tokenOrBaseClient, baseServer = 'http://127.0.0.1', port = 8080, headers = {}) { - super('X-Indexer-API-Token', tokenOrBaseClient, baseServer, port, headers); - } - /** - * Returns the health object for the service. - * Returns 200 if healthy. - * - * #### Example - * ```typescript - * const health = await indexerClient.makeHealthCheck().do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-health) - * @category GET - */ - makeHealthCheck() { - return new makeHealthCheck_1.default(this.c, this.intDecoding); - } - /** - * Returns the list of accounts who hold the given asset and their balance. - * - * #### Example - * ```typescript - * const assetId = 163650; - * const assetBalances = await indexerClient.lookupAssetBalances(assetId).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2assetsasset-idbalances) - * @param index - The asset ID to look up. - * @category GET - */ - lookupAssetBalances(index) { - return new lookupAssetBalances_1.default(this.c, this.intDecoding, index); - } - /** - * Returns transactions relating to the given asset. - * - * #### Example - * ```typescript - * const assetId = 163650; - * const assetTxns = await indexerClient.lookupAssetTransactions(assetId).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2assetsasset-idtransactions) - * @param index - The asset ID to look up. - * @category GET - */ - lookupAssetTransactions(index) { - return new lookupAssetTransactions_1.default(this.c, this.intDecoding, index); - } - /** - * Returns transactions relating to the given account. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountTxns = await indexerClient.lookupAccountTransactions(address).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2accountsaccount-idtransactions) - * @param account - The address of the account. - * @category GET - */ - lookupAccountTransactions(account) { - return new lookupAccountTransactions_1.default(this.c, this.intDecoding, account); - } - /** - * Returns the block for the passed round. - * - * #### Example - * ```typescript - * const targetBlock = 18309917; - * const blockInfo = await indexerClient.lookupBlock(targetBlock).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2blocksround-number) - * @param round - The number of the round to look up. - * @category GET - */ - lookupBlock(round) { - return new lookupBlock_1.default(this.c, this.intDecoding, round); - } - /** - * Returns information about the given transaction. - * - * #### Example - * ```typescript - * const txnId = "MEUOC4RQJB23CQZRFRKYEI6WBO73VTTPST5A7B3S5OKBUY6LFUDA"; - * const txnInfo = await indexerClient.lookupTransactionByID(txnId).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2transactionstxid) - * @param txID - The ID of the transaction to look up. - * @category GET - */ - lookupTransactionByID(txID) { - return new lookupTransactionByID_1.default(this.c, this.intDecoding, txID); - } - /** - * Returns information about the given account. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountInfo = await indexerClient.lookupAccountByID(address).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2accountsaccount-id) - * @param account - The address of the account to look up. - * @category GET - */ - lookupAccountByID(account) { - return new lookupAccountByID_1.default(this.c, this.intDecoding, account); - } - /** - * Returns asset about the given account. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountAssets = await indexerClient.lookupAccountAssets(address).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2accountsaccount-idassets) - * @param account - The address of the account to look up. - * @category GET - */ - lookupAccountAssets(account) { - return new lookupAccountAssets_1.default(this.c, this.intDecoding, account); - } - /** - * Returns asset information created by the given account. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountCreatedAssets = await indexerClient.lookupAccountCreatedAssets(address).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2accountsaccount-idcreated-assets) - * @param account - The address of the account to look up. - * @category GET - */ - lookupAccountCreatedAssets(account) { - return new lookupAccountCreatedAssets_1.default(this.c, this.intDecoding, account); - } - /** - * Returns application local state about the given account. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountAppLocalStates = await indexerClient.lookupAccountAppLocalStates(address).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2accountsaccount-idapps-local-state) - * @param account - The address of the account to look up. - * @category GET - */ - lookupAccountAppLocalStates(account) { - return new lookupAccountAppLocalStates_1.default(this.c, this.intDecoding, account); - } - /** - * Returns application information created by the given account. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountCreatedApps = await indexerClient.lookupAccountCreatedApplications(address).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2accountsaccount-idcreated-applications) - * @param account - The address of the account to look up. - * @category GET - */ - lookupAccountCreatedApplications(account) { - return new lookupAccountCreatedApplications_1.default(this.c, this.intDecoding, account); - } - /** - * Returns information about the passed asset. - * - * #### Example - * ```typescript - * const assetId = 163650; - * const assetInfo = await indexerClient.lookupAssetByID(assetId).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2assetsasset-id) - * @param index - The ID of the asset ot look up. - * @category GET - */ - lookupAssetByID(index) { - return new lookupAssetByID_1.default(this.c, this.intDecoding, index); - } - /** - * Returns information about the passed application. - * - * #### Example - * ```typescript - * const appId = 60553466; - * const appInfo = await indexerClient.lookupApplications(appId).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2applicationsapplication-id) - * @param index - The ID of the application to look up. - * @category GET - */ - lookupApplications(index) { - return new lookupApplications_1.default(this.c, this.intDecoding, index); - } - /** - * Returns log messages generated by the passed in application. - * - * #### Example - * ```typescript - * const appId = 60553466; - * const appLogs = await indexerClient.lookupApplicationLogs(appId).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2applicationsapplication-idlogs) - * @param appID - The ID of the application which generated the logs. - * @category GET - */ - lookupApplicationLogs(appID) { - return new lookupApplicationLogs_1.default(this.c, this.intDecoding, appID); - } - /** - * Returns information about indexed accounts. - * - * #### Example - * ```typescript - * const accounts = await indexerClient.searchAccounts().do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2accounts) - * @category GET - */ - searchAccounts() { - return new searchAccounts_1.default(this.c, this.intDecoding); - } - /** - * Returns information about indexed transactions. - * - * #### Example - * ```typescript - * const txns = await indexerClient.searchForTransactions().do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2transactions) - * @category GET - */ - searchForTransactions() { - return new searchForTransactions_1.default(this.c, this.intDecoding); - } - /** - * Returns information about indexed assets. - * - * #### Example - * ```typescript - * const assets = await indexerClient.searchForAssets().do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2assets) - * @category GET - */ - searchForAssets() { - return new searchForAssets_1.default(this.c, this.intDecoding); - } - /** - * Returns information about indexed applications. - * - * #### Example - * ```typescript - * const apps = await indexerClient.searchForApplications().do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2applications) - * @category GET - */ - searchForApplications() { - return new searchForApplications_1.default(this.c, this.intDecoding); - } - /** - * Returns information about indexed application boxes. - * - * #### Example - * ```typescript - * const maxResults = 20; - * const appID = 1234; - * - * const responsePage1 = await indexerClient - * .searchForApplicationBoxes(appID) - * .limit(maxResults) - * .do(); - * const boxNamesPage1 = responsePage1.boxes.map(box => box.name); - * - * const responsePage2 = await indexerClient - * .searchForApplicationBoxes(appID) - * .limit(maxResults) - * .nextToken(responsePage1.nextToken) - * .do(); - * const boxNamesPage2 = responsePage2.boxes.map(box => box.name); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2applicationsapplication-idboxes) - * @param appID - The ID of the application with boxes. - * @category GET - */ - searchForApplicationBoxes(appID) { - return new searchForApplicationBoxes_1.default(this.c, this.intDecoding, appID); - } - /** - * Returns information about the application box given its name. - * - * #### Example - * ```typescript - * const boxName = Buffer.from("foo"); - * const boxResponse = await indexerClient - * .LookupApplicationBoxByIDandName(1234, boxName) - * .do(); - * const boxValue = boxResponse.value; - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2applicationsapplication-idbox) - * @param appID - The ID of the application with boxes. - * @category GET - */ - lookupApplicationBoxByIDandName(appID, boxName) { - return new lookupApplicationBoxByIDandName_1.default(this.c, this.intDecoding, appID, boxName); - } -} -exports.default = IndexerClient; diff --git a/algosdk/client/v2/indexer/lookupAccountAppLocalStates.d.ts b/algosdk/client/v2/indexer/lookupAccountAppLocalStates.d.ts deleted file mode 100644 index 9b13147..0000000 --- a/algosdk/client/v2/indexer/lookupAccountAppLocalStates.d.ts +++ /dev/null @@ -1,110 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; -export default class LookupAccountAppLocalStates extends JSONRequest { - private account; - /** - * Returns application local state about the given account. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountAppLocalStates = await indexerClient.lookupAccountAppLocalStates(address).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2accountsaccount-idapps-local-state) - * @param account - The address of the account to look up. - * @category GET - */ - constructor(c: HTTPClient, intDecoding: IntDecoding, account: string); - /** - * @returns `/v2/accounts/${account}/apps-local-state` - */ - path(): string; - /** - * Add a limit for filter. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const maxResults = 20; - * const accountAssets = await indexerClient - * .lookupAccountAppLocalStates(address) - * .limit(maxResults) - * .do(); - * ``` - * - * @param limit - maximum number of results to return. - * @category query - */ - limit(limit: number): this; - /** - * Specify round to filter with. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const targetBlock = 18309917; - * const accountAssets = await indexerClient - * .lookupAccountAppLocalStates(address) - * .round(targetBlock) - * .do(); - * ``` - * @param round - * @category query - */ - round(round: number): this; - /** - * Specify the next page of results. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const maxResults = 20; - * - * const accountAssetsPage1 = await indexerClient - * .lookupAccountAppLocalStates(address) - * .limit(maxResults) - * .do(); - * - * const accountAssetsPage2 = await indexerClient - * .lookupAccountAppLocalStates(address) - * .limit(maxResults) - * .next(accountAssetsPage1["next-token"]) - * .do(); - * ``` - * @param nextToken - provided by the previous results. - */ - nextToken(nextToken: string): this; - /** - * Include all items including closed accounts, deleted applications, destroyed assets, opted-out asset holdings, and closed-out application localstates - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountAssets = await indexerClient - * .lookupAccountAppLocalStates(address) - * .includeAll(false) - * .do(); - * ``` - * @param value - * @category query - */ - includeAll(value?: boolean): this; - /** - * Specify an applicationID to search for. - * - * #### Example - * ```typescript - * const applicationID = 163650; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountApplications = await indexerClient - * .lookupAccountAppLocalStates(address) - * .applicationID(applicationID) - * .do(); - * ``` - * @param index - the applicationID - * @category query - */ - applicationID(index: number): this; -} diff --git a/algosdk/client/v2/indexer/lookupAccountAppLocalStates.js b/algosdk/client/v2/indexer/lookupAccountAppLocalStates.js deleted file mode 100644 index c094aac..0000000 --- a/algosdk/client/v2/indexer/lookupAccountAppLocalStates.js +++ /dev/null @@ -1,134 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -class LookupAccountAppLocalStates extends jsonrequest_1.default { - /** - * Returns application local state about the given account. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountAppLocalStates = await indexerClient.lookupAccountAppLocalStates(address).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2accountsaccount-idapps-local-state) - * @param account - The address of the account to look up. - * @category GET - */ - constructor(c, intDecoding, account) { - super(c, intDecoding); - this.account = account; - this.account = account; - } - /** - * @returns `/v2/accounts/${account}/apps-local-state` - */ - path() { - return `/v2/accounts/${this.account}/apps-local-state`; - } - /** - * Add a limit for filter. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const maxResults = 20; - * const accountAssets = await indexerClient - * .lookupAccountAppLocalStates(address) - * .limit(maxResults) - * .do(); - * ``` - * - * @param limit - maximum number of results to return. - * @category query - */ - limit(limit) { - this.query.limit = limit; - return this; - } - /** - * Specify round to filter with. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const targetBlock = 18309917; - * const accountAssets = await indexerClient - * .lookupAccountAppLocalStates(address) - * .round(targetBlock) - * .do(); - * ``` - * @param round - * @category query - */ - round(round) { - this.query.round = round; - return this; - } - /** - * Specify the next page of results. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const maxResults = 20; - * - * const accountAssetsPage1 = await indexerClient - * .lookupAccountAppLocalStates(address) - * .limit(maxResults) - * .do(); - * - * const accountAssetsPage2 = await indexerClient - * .lookupAccountAppLocalStates(address) - * .limit(maxResults) - * .next(accountAssetsPage1["next-token"]) - * .do(); - * ``` - * @param nextToken - provided by the previous results. - */ - nextToken(nextToken) { - this.query.next = nextToken; - return this; - } - /** - * Include all items including closed accounts, deleted applications, destroyed assets, opted-out asset holdings, and closed-out application localstates - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountAssets = await indexerClient - * .lookupAccountAppLocalStates(address) - * .includeAll(false) - * .do(); - * ``` - * @param value - * @category query - */ - includeAll(value = true) { - this.query['include-all'] = value; - return this; - } - /** - * Specify an applicationID to search for. - * - * #### Example - * ```typescript - * const applicationID = 163650; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountApplications = await indexerClient - * .lookupAccountAppLocalStates(address) - * .applicationID(applicationID) - * .do(); - * ``` - * @param index - the applicationID - * @category query - */ - applicationID(index) { - this.query['application-id'] = index; - return this; - } -} -exports.default = LookupAccountAppLocalStates; diff --git a/algosdk/client/v2/indexer/lookupAccountAssets.d.ts b/algosdk/client/v2/indexer/lookupAccountAssets.d.ts deleted file mode 100644 index dfe090a..0000000 --- a/algosdk/client/v2/indexer/lookupAccountAssets.d.ts +++ /dev/null @@ -1,111 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; -export default class LookupAccountAssets extends JSONRequest { - private account; - /** - * Returns asset about the given account. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountAssets = await indexerClient.lookupAccountAssets(address).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2accountsaccount-idassets) - * @param account - The address of the account to look up. - * @category GET - */ - constructor(c: HTTPClient, intDecoding: IntDecoding, account: string); - /** - * @returns `/v2/accounts/${account}/assets` - */ - path(): string; - /** - * Add a limit for filter. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const maxResults = 20; - * const accountAssets = await indexerClient - * .lookupAccountAssets(address) - * .limit(maxResults) - * .do(); - * ``` - * - * @param limit - maximum number of results to return. - * @category query - */ - limit(limit: number): this; - /** - * Specify round to filter with. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const targetBlock = 18309917; - * const accountAssets = await indexerClient - * .lookupAccountAssets(address) - * .round(targetBlock) - * .do(); - * ``` - * @param round - * @category query - */ - round(round: number): this; - /** - * Specify the next page of results. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const maxResults = 20; - * - * const accountAssetsPage1 = await indexerClient - * .lookupAccountAssets(address) - * .limit(maxResults) - * .do(); - * - * const accountAssetsPage2 = await indexerClient - * .lookupAccountAssets(address) - * .limit(maxResults) - * .next(accountAssetsPage1["next-token"]) - * .do(); - * ``` - * @param nextToken - provided by the previous results. - * @category query - */ - nextToken(nextToken: string): this; - /** - * Include all items including closed accounts, deleted applications, destroyed assets, opted-out asset holdings, and closed-out application localstates - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountAssets = await indexerClient - * .lookupAccountAssets(address) - * .includeAll(false) - * .do(); - * ``` - * @param value - * @category query - */ - includeAll(value?: boolean): this; - /** - * Specify an assetID to search for. - * - * #### Example - * ```typescript - * const assetId = 163650; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const assetAssets = await indexerClient - * .lookupAccountAssets(address) - * .assetId(assetId) - * .do(); - * ``` - * @param index - the assetID - * @category query - */ - assetId(index: number): this; -} diff --git a/algosdk/client/v2/indexer/lookupAccountAssets.js b/algosdk/client/v2/indexer/lookupAccountAssets.js deleted file mode 100644 index 5c2963f..0000000 --- a/algosdk/client/v2/indexer/lookupAccountAssets.js +++ /dev/null @@ -1,135 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -class LookupAccountAssets extends jsonrequest_1.default { - /** - * Returns asset about the given account. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountAssets = await indexerClient.lookupAccountAssets(address).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2accountsaccount-idassets) - * @param account - The address of the account to look up. - * @category GET - */ - constructor(c, intDecoding, account) { - super(c, intDecoding); - this.account = account; - this.account = account; - } - /** - * @returns `/v2/accounts/${account}/assets` - */ - path() { - return `/v2/accounts/${this.account}/assets`; - } - /** - * Add a limit for filter. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const maxResults = 20; - * const accountAssets = await indexerClient - * .lookupAccountAssets(address) - * .limit(maxResults) - * .do(); - * ``` - * - * @param limit - maximum number of results to return. - * @category query - */ - limit(limit) { - this.query.limit = limit; - return this; - } - /** - * Specify round to filter with. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const targetBlock = 18309917; - * const accountAssets = await indexerClient - * .lookupAccountAssets(address) - * .round(targetBlock) - * .do(); - * ``` - * @param round - * @category query - */ - round(round) { - this.query.round = round; - return this; - } - /** - * Specify the next page of results. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const maxResults = 20; - * - * const accountAssetsPage1 = await indexerClient - * .lookupAccountAssets(address) - * .limit(maxResults) - * .do(); - * - * const accountAssetsPage2 = await indexerClient - * .lookupAccountAssets(address) - * .limit(maxResults) - * .next(accountAssetsPage1["next-token"]) - * .do(); - * ``` - * @param nextToken - provided by the previous results. - * @category query - */ - nextToken(nextToken) { - this.query.next = nextToken; - return this; - } - /** - * Include all items including closed accounts, deleted applications, destroyed assets, opted-out asset holdings, and closed-out application localstates - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountAssets = await indexerClient - * .lookupAccountAssets(address) - * .includeAll(false) - * .do(); - * ``` - * @param value - * @category query - */ - includeAll(value = true) { - this.query['include-all'] = value; - return this; - } - /** - * Specify an assetID to search for. - * - * #### Example - * ```typescript - * const assetId = 163650; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const assetAssets = await indexerClient - * .lookupAccountAssets(address) - * .assetId(assetId) - * .do(); - * ``` - * @param index - the assetID - * @category query - */ - assetId(index) { - this.query['asset-id'] = index; - return this; - } -} -exports.default = LookupAccountAssets; diff --git a/algosdk/client/v2/indexer/lookupAccountByID.d.ts b/algosdk/client/v2/indexer/lookupAccountByID.d.ts deleted file mode 100644 index c8320e0..0000000 --- a/algosdk/client/v2/indexer/lookupAccountByID.d.ts +++ /dev/null @@ -1,87 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; -export default class LookupAccountByID extends JSONRequest { - private account; - /** - * Returns information about the given account. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountInfo = await indexerClient.lookupAccountByID(address).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2accountsaccount-id) - * @param account - The address of the account to look up. - * @category GET - */ - constructor(c: HTTPClient, intDecoding: IntDecoding, account: string); - /** - * @returns `/v2/accounts/${account}` - */ - path(): string; - /** - * Specify round to filter with. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const targetBlock = 18309917; - * const accountInfo = await indexerClient - * .lookupAccountByID(address) - * .round(targetBlock) - * .do(); - * ``` - * @param round - */ - round(round: number): this; - /** - * Include all items including closed accounts, deleted applications, destroyed assets, opted-out asset holdings, and closed-out application localstates. - * - * #### Example 1 - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountInfo = await indexerClient - * .lookupAccountByID(address) - * .includeAll(false) - * .do(); - * ``` - * - * #### Example 2 - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountInfo = await indexerClient - * .lookupAccountByID(address) - * .includeAll() - * .do(); - * ``` - * @param value - */ - includeAll(value?: boolean): this; - /** - * Exclude additional items such as asset holdings, application local data stored for this account, asset parameters created by this account, and application parameters created by this account. - * - * #### Example 1 - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountInfo = await indexerClient - * .lookupAccountByID(address) - * .exclude("all") - * .do(); - * ``` - * - * #### Example 2 - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountInfo = await indexerClient - * .lookupAccountByID(address) - * .exclude("assets,created-assets") - * .do(); - * ``` - * @remarks By default, it behaves as exclude=none - * @param exclude - Array of `all`, `assets`, `created-assets`, `apps-local-state`, `created-apps`, `none` - * @category query - */ - exclude(exclude: string): this; -} diff --git a/algosdk/client/v2/indexer/lookupAccountByID.js b/algosdk/client/v2/indexer/lookupAccountByID.js deleted file mode 100644 index bbb2749..0000000 --- a/algosdk/client/v2/indexer/lookupAccountByID.js +++ /dev/null @@ -1,105 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -class LookupAccountByID extends jsonrequest_1.default { - /** - * Returns information about the given account. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountInfo = await indexerClient.lookupAccountByID(address).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2accountsaccount-id) - * @param account - The address of the account to look up. - * @category GET - */ - constructor(c, intDecoding, account) { - super(c, intDecoding); - this.account = account; - this.account = account; - } - /** - * @returns `/v2/accounts/${account}` - */ - path() { - return `/v2/accounts/${this.account}`; - } - /** - * Specify round to filter with. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const targetBlock = 18309917; - * const accountInfo = await indexerClient - * .lookupAccountByID(address) - * .round(targetBlock) - * .do(); - * ``` - * @param round - */ - round(round) { - this.query.round = round; - return this; - } - /** - * Include all items including closed accounts, deleted applications, destroyed assets, opted-out asset holdings, and closed-out application localstates. - * - * #### Example 1 - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountInfo = await indexerClient - * .lookupAccountByID(address) - * .includeAll(false) - * .do(); - * ``` - * - * #### Example 2 - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountInfo = await indexerClient - * .lookupAccountByID(address) - * .includeAll() - * .do(); - * ``` - * @param value - */ - includeAll(value = true) { - this.query['include-all'] = value; - return this; - } - /** - * Exclude additional items such as asset holdings, application local data stored for this account, asset parameters created by this account, and application parameters created by this account. - * - * #### Example 1 - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountInfo = await indexerClient - * .lookupAccountByID(address) - * .exclude("all") - * .do(); - * ``` - * - * #### Example 2 - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountInfo = await indexerClient - * .lookupAccountByID(address) - * .exclude("assets,created-assets") - * .do(); - * ``` - * @remarks By default, it behaves as exclude=none - * @param exclude - Array of `all`, `assets`, `created-assets`, `apps-local-state`, `created-apps`, `none` - * @category query - */ - exclude(exclude) { - this.query.exclude = exclude; - return this; - } -} -exports.default = LookupAccountByID; diff --git a/algosdk/client/v2/indexer/lookupAccountCreatedApplications.d.ts b/algosdk/client/v2/indexer/lookupAccountCreatedApplications.d.ts deleted file mode 100644 index 4da6d49..0000000 --- a/algosdk/client/v2/indexer/lookupAccountCreatedApplications.d.ts +++ /dev/null @@ -1,111 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; -export default class LookupAccountCreatedApplications extends JSONRequest { - private account; - /** - * Returns application information created by the given account. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountCreatedApps = await indexerClient.lookupAccountCreatedApplications(address).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2accountsaccount-idcreated-applications) - * @param account - The address of the account to look up. - * @category GET - */ - constructor(c: HTTPClient, intDecoding: IntDecoding, account: string); - /** - * @returns `/v2/accounts/${account}/created-applications` - */ - path(): string; - /** - * Add a limit for filter. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const maxResults = 20; - * const accountAssets = await indexerClient - * .lookupAccountCreatedApplications(address) - * .limit(maxResults) - * .do(); - * ``` - * - * @param limit - maximum number of results to return. - * @category query - */ - limit(limit: number): this; - /** - * Specify round to filter with. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const targetBlock = 18309917; - * const accountAssets = await indexerClient - * .lookupAccountCreatedApplications(address) - * .round(targetBlock) - * .do(); - * ``` - * @param round - * @category query - */ - round(round: number): this; - /** - * Specify the next page of results. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const maxResults = 20; - * - * const accountAssetsPage1 = await indexerClient - * .lookupAccountCreatedApplications(address) - * .limit(maxResults) - * .do(); - * - * const accountAssetsPage2 = await indexerClient - * .lookupAccountCreatedApplications(address) - * .limit(maxResults) - * .next(accountAssetsPage1["next-token"]) - * .do(); - * ``` - * @param nextToken - provided by the previous results. - * @category query - */ - nextToken(nextToken: string): this; - /** - * Include all items including closed accounts, deleted applications, destroyed assets, opted-out asset holdings, and closed-out application localstates - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountAssets = await indexerClient - * .lookupAccountCreatedApplications(address) - * .includeAll(false) - * .do(); - * ``` - * @param value - * @category query - */ - includeAll(value?: boolean): this; - /** - * Specify an applicationID to search for. - * - * #### Example - * ```typescript - * const applicationID = 163650; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountApplications = await indexerClient - * .lookupAccountAppLocalStates(address) - * .applicationID(applicationID) - * .do(); - * ``` - * @param index - the applicationID - * @category query - */ - applicationID(index: number): this; -} diff --git a/algosdk/client/v2/indexer/lookupAccountCreatedApplications.js b/algosdk/client/v2/indexer/lookupAccountCreatedApplications.js deleted file mode 100644 index 949027d..0000000 --- a/algosdk/client/v2/indexer/lookupAccountCreatedApplications.js +++ /dev/null @@ -1,135 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -class LookupAccountCreatedApplications extends jsonrequest_1.default { - /** - * Returns application information created by the given account. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountCreatedApps = await indexerClient.lookupAccountCreatedApplications(address).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2accountsaccount-idcreated-applications) - * @param account - The address of the account to look up. - * @category GET - */ - constructor(c, intDecoding, account) { - super(c, intDecoding); - this.account = account; - this.account = account; - } - /** - * @returns `/v2/accounts/${account}/created-applications` - */ - path() { - return `/v2/accounts/${this.account}/created-applications`; - } - /** - * Add a limit for filter. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const maxResults = 20; - * const accountAssets = await indexerClient - * .lookupAccountCreatedApplications(address) - * .limit(maxResults) - * .do(); - * ``` - * - * @param limit - maximum number of results to return. - * @category query - */ - limit(limit) { - this.query.limit = limit; - return this; - } - /** - * Specify round to filter with. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const targetBlock = 18309917; - * const accountAssets = await indexerClient - * .lookupAccountCreatedApplications(address) - * .round(targetBlock) - * .do(); - * ``` - * @param round - * @category query - */ - round(round) { - this.query.round = round; - return this; - } - /** - * Specify the next page of results. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const maxResults = 20; - * - * const accountAssetsPage1 = await indexerClient - * .lookupAccountCreatedApplications(address) - * .limit(maxResults) - * .do(); - * - * const accountAssetsPage2 = await indexerClient - * .lookupAccountCreatedApplications(address) - * .limit(maxResults) - * .next(accountAssetsPage1["next-token"]) - * .do(); - * ``` - * @param nextToken - provided by the previous results. - * @category query - */ - nextToken(nextToken) { - this.query.next = nextToken; - return this; - } - /** - * Include all items including closed accounts, deleted applications, destroyed assets, opted-out asset holdings, and closed-out application localstates - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountAssets = await indexerClient - * .lookupAccountCreatedApplications(address) - * .includeAll(false) - * .do(); - * ``` - * @param value - * @category query - */ - includeAll(value = true) { - this.query['include-all'] = value; - return this; - } - /** - * Specify an applicationID to search for. - * - * #### Example - * ```typescript - * const applicationID = 163650; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountApplications = await indexerClient - * .lookupAccountAppLocalStates(address) - * .applicationID(applicationID) - * .do(); - * ``` - * @param index - the applicationID - * @category query - */ - applicationID(index) { - this.query['application-id'] = index; - return this; - } -} -exports.default = LookupAccountCreatedApplications; diff --git a/algosdk/client/v2/indexer/lookupAccountCreatedAssets.d.ts b/algosdk/client/v2/indexer/lookupAccountCreatedAssets.d.ts deleted file mode 100644 index b71cbb7..0000000 --- a/algosdk/client/v2/indexer/lookupAccountCreatedAssets.d.ts +++ /dev/null @@ -1,112 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; -export default class LookupAccountCreatedAssets extends JSONRequest { - private account; - /** - * Returns asset information created by the given account. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountCreatedAssets = await indexerClient.lookupAccountCreatedAssets(address).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2accountsaccount-idcreated-assets) - * @param account - The address of the account to look up. - * @category GET - */ - constructor(c: HTTPClient, intDecoding: IntDecoding, account: string); - /** - * @returns `/v2/accounts/${account}/created-assets` - */ - path(): string; - /** - * Add a limit for filter. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const maxResults = 20; - * const accountAssets = await indexerClient - * .lookupAccountCreatedAssets(address) - * .limit(maxResults) - * .do(); - * ``` - * - * @param limit - maximum number of results to return. - * @category query - */ - limit(limit: number): this; - /** - * Specify round to filter with. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const targetBlock = 18309917; - * const accountAssets = await indexerClient - * .lookupAccountCreatedAssets(address) - * .round(targetBlock) - * .do(); - * ``` - * @param round - * @category query - */ - round(round: number): this; - /** - * Specify the next page of results. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const maxResults = 20; - * - * const accountAssetsPage1 = await indexerClient - * .lookupAccountCreatedAssets(address) - * .limit(maxResults) - * .do(); - * ``` - * - * const accountAssetsPage2 = await indexerClient - * .lookupAccountCreatedAssets(address) - * .limit(maxResults) - * .next(accountAssetsPage1["next-token"]) - * .do(); - * ``` - * @param nextToken - provided by the previous results. - * @category query - */ - nextToken(nextToken: string): this; - /** - * Include all items including closed accounts, deleted applications, destroyed assets, opted-out asset holdings, and closed-out application localstates - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountAssets = await indexerClient - * .lookupAccountCreatedAssets(address) - * .includeAll(false) - * .do(); - * ``` - * @param value - * @category query - */ - includeAll(value?: boolean): this; - /** - * Specify an assetID to search for. - * - * #### Example - * ```typescript - * const assetID = 163650; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const assetAssets = await indexerClient - * .lookupAccountCreatedAssets(address) - * .assetID(assetID) - * .do(); - * ``` - * @param index - the assetID - * @category query - */ - assetID(index: number): this; -} diff --git a/algosdk/client/v2/indexer/lookupAccountCreatedAssets.js b/algosdk/client/v2/indexer/lookupAccountCreatedAssets.js deleted file mode 100644 index ec244c4..0000000 --- a/algosdk/client/v2/indexer/lookupAccountCreatedAssets.js +++ /dev/null @@ -1,136 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -class LookupAccountCreatedAssets extends jsonrequest_1.default { - /** - * Returns asset information created by the given account. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountCreatedAssets = await indexerClient.lookupAccountCreatedAssets(address).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2accountsaccount-idcreated-assets) - * @param account - The address of the account to look up. - * @category GET - */ - constructor(c, intDecoding, account) { - super(c, intDecoding); - this.account = account; - this.account = account; - } - /** - * @returns `/v2/accounts/${account}/created-assets` - */ - path() { - return `/v2/accounts/${this.account}/created-assets`; - } - /** - * Add a limit for filter. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const maxResults = 20; - * const accountAssets = await indexerClient - * .lookupAccountCreatedAssets(address) - * .limit(maxResults) - * .do(); - * ``` - * - * @param limit - maximum number of results to return. - * @category query - */ - limit(limit) { - this.query.limit = limit; - return this; - } - /** - * Specify round to filter with. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const targetBlock = 18309917; - * const accountAssets = await indexerClient - * .lookupAccountCreatedAssets(address) - * .round(targetBlock) - * .do(); - * ``` - * @param round - * @category query - */ - round(round) { - this.query.round = round; - return this; - } - /** - * Specify the next page of results. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const maxResults = 20; - * - * const accountAssetsPage1 = await indexerClient - * .lookupAccountCreatedAssets(address) - * .limit(maxResults) - * .do(); - * ``` - * - * const accountAssetsPage2 = await indexerClient - * .lookupAccountCreatedAssets(address) - * .limit(maxResults) - * .next(accountAssetsPage1["next-token"]) - * .do(); - * ``` - * @param nextToken - provided by the previous results. - * @category query - */ - nextToken(nextToken) { - this.query.next = nextToken; - return this; - } - /** - * Include all items including closed accounts, deleted applications, destroyed assets, opted-out asset holdings, and closed-out application localstates - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountAssets = await indexerClient - * .lookupAccountCreatedAssets(address) - * .includeAll(false) - * .do(); - * ``` - * @param value - * @category query - */ - includeAll(value = true) { - this.query['include-all'] = value; - return this; - } - /** - * Specify an assetID to search for. - * - * #### Example - * ```typescript - * const assetID = 163650; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const assetAssets = await indexerClient - * .lookupAccountCreatedAssets(address) - * .assetID(assetID) - * .do(); - * ``` - * @param index - the assetID - * @category query - */ - assetID(index) { - this.query['asset-id'] = index; - return this; - } -} -exports.default = LookupAccountCreatedAssets; diff --git a/algosdk/client/v2/indexer/lookupAccountTransactions.d.ts b/algosdk/client/v2/indexer/lookupAccountTransactions.d.ts deleted file mode 100644 index 03fb54e..0000000 --- a/algosdk/client/v2/indexer/lookupAccountTransactions.d.ts +++ /dev/null @@ -1,315 +0,0 @@ -import IntDecoding from '../../../types/intDecoding'; -import HTTPClient from '../../client'; -import JSONRequest from '../jsonrequest'; -/** - * Accept base64 string or Uint8Array and output base64 string - * @param data - Base64 string or Uint8Array - * @returns The inputted base64 string, or a base64 string representation of the Uint8Array - */ -export declare function base64StringFunnel(data: Uint8Array | string): string; -export default class LookupAccountTransactions extends JSONRequest { - private account; - /** - * Returns transactions relating to the given account. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountTxns = await indexerClient.lookupAccountTransactions(address).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2accountsaccount-idtransactions) - * @param account - The address of the account. - */ - constructor(c: HTTPClient, intDecoding: IntDecoding, account: string); - /** - * @returns `/v2/accounts/${account}/transactions` - */ - path(): string; - /** - * Specifies a prefix which must be contained in the note field. - * - * #### Example - * ```typescript - * const notePrefixBase64Encoded = "Y3JlYXRl"; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountTxns = await indexerClient - * .lookupAccountTransactions(address) - * .notePrefix(notePrefixBase64Encoded) - * .do(); - * ``` - * - * @param prefix - base64 string or uint8array - * @category query - */ - notePrefix(prefix: Uint8Array | string): this; - /** - * Type of transaction to filter with. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountTxns = await indexerClient - * .lookupAccountTransactions(address) - * .txType("appl") - * .do(); - * ``` - * - * @param type - one of `pay`, `keyreg`, `acfg`, `axfer`, `afrz`, `appl`, `stpf` - * @category query - */ - txType(type: string): this; - /** - * Type of signature to filter with. - * - sig: Standard - * - msig: MultiSig - * - lsig: LogicSig - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountTxns = await indexerClient - * .lookupAccountTransactions(address) - * .sigType("msig") - * .do(); - * ``` - * - * @param type - one of `sig`, `msig`, `lsig` - * @category query - */ - sigType(type: string): this; - /** - * Lookup the specific transaction by ID. - * - * #### Example - * ```typescript - * const txId = "MEUOC4RQJB23CQZRFRKYEI6WBO73VTTPST5A7B3S5OKBUY6LFUDA"; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountTxns = await indexerClient - * .lookupAccountTransactions(address) - * .txid(txId) - * .do(); - * ``` - * @remarks Alternatively, use `indexerClient.lookupTransactionByID(txnId).do()` - * @param txid - * @category query - */ - txid(txid: string): this; - /** - * Include results for the specified round. - * - * #### Example - * ```typescript - * const targetBlock = 18309917; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountTxns = await indexerClient - * .lookupAccountTransactions(address) - * .round(targetBlock) - * .do(); - * ``` - * - * @param round - * @category query - */ - round(round: number): this; - /** - * Include results at or after the specified min-round. - * - * #### Example - * ```typescript - * const minRound = 18309917; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountTxns = await indexerClient - * .lookupAccountTransactions(address) - * .minRound(minRound) - * .do(); - * ``` - * - * @param round - * @category query - */ - minRound(round: number): this; - /** - * Include results at or before the specified max-round. - * - * #### Example - * ```typescript - * const maxRound = 18309917; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountTxns = await indexerClient - * .lookupAccountTransactions(address) - * .maxRound(maxRound) - * .do(); - * ``` - * - * @param round - * @category query - */ - maxRound(round: number): this; - /** - * Asset ID to filter with. - * - * #### Example - * ```typescript - * const assetID = 163650; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountTxns = await indexerClient - * .lookupAccountTransactions(address) - * .assetID(assetID) - * .do(); - * ``` - * - * @param id - * @category query - */ - assetID(id: number): this; - /** - * Maximum number of results to return. - * - * #### Example - * ```typescript - * const maxResults = 25; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountTxns = await indexerClient - * .lookupAccountTransactions(address) - * .limit(maxResults) - * .do(); - * ``` - * - * @param limit - * @category query - */ - limit(limit: number): this; - /** - * Include results before the given time. - * - * #### Example - * ```typescript - * const beforeTime = "2022-02-02T20:20:22.02Z"; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountTxns = await indexerClient - * .lookupAccountTransactions(address) - * .beforeTime(beforeTime) - * .do(); - * ``` - * - * @param before - rfc3339 string - * @category query - */ - beforeTime(before: string): this; - /** - * Include results after the given time. - * - * #### Example - * ```typescript - * const afterTime = "2022-10-21T00:00:11.55Z"; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountTxns = await indexerClient - * .lookupAccountTransactions(address) - * .afterTime(afterTime) - * .do(); - * ``` - * - * @param after - rfc3339 string - * @category query - */ - afterTime(after: string): this; - /** - * Filtered results should have an amount greater than this value, as int, representing microAlgos, unless an asset-id is provided, in which case units are in the asset's units. - * - * #### Example 1 - * ```typescript - * const minBalance = 300000; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountTxns = await indexerClient - * .lookupAccountTransactions(address) - * .currencyGreaterThan(minBalance - 1) - * .do(); - * ``` - * - * #### Example 2 - * ```typescript - * const assetID = 163650; - * const minBalance = 300000; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountTxns = await indexerClient - * .lookupAccountTransactions(address) - * .assetID(assetID) - * .currencyGreaterThan(minBalance - 1) - * .do(); - * ``` - * - * @param greater - * @category query - */ - currencyGreaterThan(greater: number): this; - /** - * Filtered results should have an amount less than this value, as int, representing microAlgos, unless an asset-id is provided, in which case units are in the asset's units. - * - * #### Example 1 - * ```typescript - * const maxBalance = 500000; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountTxns = await indexerClient - * .lookupAccountTransactions(address) - * .currencyLessThan(maxBalance + 1) - * .do(); - * ``` - * - * #### Example 2 - * ```typescript - * const assetID = 163650; - * const maxBalance = 500000; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountTxns = await indexerClient - * .lookupAccountTransactions(address) - * .assetID(assetID) - * .currencyLessThan(maxBalance + 1) - * .do(); - * ``` - * - * @param lesser - * @category query - */ - currencyLessThan(lesser: number): this; - /** - * The next page of results. Use the next token provided by the previous results. - * - * #### Example - * ```typescript - * const maxResults = 25; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * - * const accountTxnsPage1 = await indexerClient - * .lookupAccountTransactions(address) - * .limit(maxResults) - * .do(); - * - * const accountTxnsPage2 = await indexerClient - * .lookupAccountTransactions(address) - * .limit(maxResults) - * .nextToken(accountTxnsPage1["next-token"]) - * .do(); - * ``` - * - * @param nextToken - provided by the previous results. - * @category query - */ - nextToken(nextToken: string): this; - /** - * Whether or not to include rekeying transactions. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountTxns = await indexerClient - * .lookupAccountTransactions(address) - * .rekeyTo(false) - * .do(); - * ``` - * - * @param rekeyTo - * @category query - */ - rekeyTo(rekeyTo: boolean): this; -} diff --git a/algosdk/client/v2/indexer/lookupAccountTransactions.js b/algosdk/client/v2/indexer/lookupAccountTransactions.js deleted file mode 100644 index 3094bef..0000000 --- a/algosdk/client/v2/indexer/lookupAccountTransactions.js +++ /dev/null @@ -1,378 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.base64StringFunnel = void 0; -const binarydata_1 = require("../../../encoding/binarydata"); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -/** - * Accept base64 string or Uint8Array and output base64 string - * @param data - Base64 string or Uint8Array - * @returns The inputted base64 string, or a base64 string representation of the Uint8Array - */ -function base64StringFunnel(data) { - if (typeof data === 'string') { - return data; - } - return (0, binarydata_1.bytesToBase64)(data); -} -exports.base64StringFunnel = base64StringFunnel; -class LookupAccountTransactions extends jsonrequest_1.default { - /** - * Returns transactions relating to the given account. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountTxns = await indexerClient.lookupAccountTransactions(address).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2accountsaccount-idtransactions) - * @param account - The address of the account. - */ - constructor(c, intDecoding, account) { - super(c, intDecoding); - this.account = account; - this.account = account; - } - /** - * @returns `/v2/accounts/${account}/transactions` - */ - path() { - return `/v2/accounts/${this.account}/transactions`; - } - /** - * Specifies a prefix which must be contained in the note field. - * - * #### Example - * ```typescript - * const notePrefixBase64Encoded = "Y3JlYXRl"; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountTxns = await indexerClient - * .lookupAccountTransactions(address) - * .notePrefix(notePrefixBase64Encoded) - * .do(); - * ``` - * - * @param prefix - base64 string or uint8array - * @category query - */ - notePrefix(prefix) { - this.query['note-prefix'] = base64StringFunnel(prefix); - return this; - } - /** - * Type of transaction to filter with. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountTxns = await indexerClient - * .lookupAccountTransactions(address) - * .txType("appl") - * .do(); - * ``` - * - * @param type - one of `pay`, `keyreg`, `acfg`, `axfer`, `afrz`, `appl`, `stpf` - * @category query - */ - txType(type) { - this.query['tx-type'] = type; - return this; - } - /** - * Type of signature to filter with. - * - sig: Standard - * - msig: MultiSig - * - lsig: LogicSig - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountTxns = await indexerClient - * .lookupAccountTransactions(address) - * .sigType("msig") - * .do(); - * ``` - * - * @param type - one of `sig`, `msig`, `lsig` - * @category query - */ - sigType(type) { - this.query['sig-type'] = type; - return this; - } - /** - * Lookup the specific transaction by ID. - * - * #### Example - * ```typescript - * const txId = "MEUOC4RQJB23CQZRFRKYEI6WBO73VTTPST5A7B3S5OKBUY6LFUDA"; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountTxns = await indexerClient - * .lookupAccountTransactions(address) - * .txid(txId) - * .do(); - * ``` - * @remarks Alternatively, use `indexerClient.lookupTransactionByID(txnId).do()` - * @param txid - * @category query - */ - txid(txid) { - this.query.txid = txid; - return this; - } - /** - * Include results for the specified round. - * - * #### Example - * ```typescript - * const targetBlock = 18309917; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountTxns = await indexerClient - * .lookupAccountTransactions(address) - * .round(targetBlock) - * .do(); - * ``` - * - * @param round - * @category query - */ - round(round) { - this.query.round = round; - return this; - } - /** - * Include results at or after the specified min-round. - * - * #### Example - * ```typescript - * const minRound = 18309917; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountTxns = await indexerClient - * .lookupAccountTransactions(address) - * .minRound(minRound) - * .do(); - * ``` - * - * @param round - * @category query - */ - minRound(round) { - this.query['min-round'] = round; - return this; - } - /** - * Include results at or before the specified max-round. - * - * #### Example - * ```typescript - * const maxRound = 18309917; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountTxns = await indexerClient - * .lookupAccountTransactions(address) - * .maxRound(maxRound) - * .do(); - * ``` - * - * @param round - * @category query - */ - maxRound(round) { - this.query['max-round'] = round; - return this; - } - /** - * Asset ID to filter with. - * - * #### Example - * ```typescript - * const assetID = 163650; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountTxns = await indexerClient - * .lookupAccountTransactions(address) - * .assetID(assetID) - * .do(); - * ``` - * - * @param id - * @category query - */ - assetID(id) { - this.query['asset-id'] = id; - return this; - } - /** - * Maximum number of results to return. - * - * #### Example - * ```typescript - * const maxResults = 25; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountTxns = await indexerClient - * .lookupAccountTransactions(address) - * .limit(maxResults) - * .do(); - * ``` - * - * @param limit - * @category query - */ - limit(limit) { - this.query.limit = limit; - return this; - } - /** - * Include results before the given time. - * - * #### Example - * ```typescript - * const beforeTime = "2022-02-02T20:20:22.02Z"; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountTxns = await indexerClient - * .lookupAccountTransactions(address) - * .beforeTime(beforeTime) - * .do(); - * ``` - * - * @param before - rfc3339 string - * @category query - */ - beforeTime(before) { - this.query['before-time'] = before; - return this; - } - /** - * Include results after the given time. - * - * #### Example - * ```typescript - * const afterTime = "2022-10-21T00:00:11.55Z"; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountTxns = await indexerClient - * .lookupAccountTransactions(address) - * .afterTime(afterTime) - * .do(); - * ``` - * - * @param after - rfc3339 string - * @category query - */ - afterTime(after) { - this.query['after-time'] = after; - return this; - } - /** - * Filtered results should have an amount greater than this value, as int, representing microAlgos, unless an asset-id is provided, in which case units are in the asset's units. - * - * #### Example 1 - * ```typescript - * const minBalance = 300000; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountTxns = await indexerClient - * .lookupAccountTransactions(address) - * .currencyGreaterThan(minBalance - 1) - * .do(); - * ``` - * - * #### Example 2 - * ```typescript - * const assetID = 163650; - * const minBalance = 300000; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountTxns = await indexerClient - * .lookupAccountTransactions(address) - * .assetID(assetID) - * .currencyGreaterThan(minBalance - 1) - * .do(); - * ``` - * - * @param greater - * @category query - */ - currencyGreaterThan(greater) { - // We convert the following to a string for now to correctly include zero values in request parameters. - this.query['currency-greater-than'] = greater.toString(); - return this; - } - /** - * Filtered results should have an amount less than this value, as int, representing microAlgos, unless an asset-id is provided, in which case units are in the asset's units. - * - * #### Example 1 - * ```typescript - * const maxBalance = 500000; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountTxns = await indexerClient - * .lookupAccountTransactions(address) - * .currencyLessThan(maxBalance + 1) - * .do(); - * ``` - * - * #### Example 2 - * ```typescript - * const assetID = 163650; - * const maxBalance = 500000; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountTxns = await indexerClient - * .lookupAccountTransactions(address) - * .assetID(assetID) - * .currencyLessThan(maxBalance + 1) - * .do(); - * ``` - * - * @param lesser - * @category query - */ - currencyLessThan(lesser) { - this.query['currency-less-than'] = lesser; - return this; - } - /** - * The next page of results. Use the next token provided by the previous results. - * - * #### Example - * ```typescript - * const maxResults = 25; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * - * const accountTxnsPage1 = await indexerClient - * .lookupAccountTransactions(address) - * .limit(maxResults) - * .do(); - * - * const accountTxnsPage2 = await indexerClient - * .lookupAccountTransactions(address) - * .limit(maxResults) - * .nextToken(accountTxnsPage1["next-token"]) - * .do(); - * ``` - * - * @param nextToken - provided by the previous results. - * @category query - */ - nextToken(nextToken) { - this.query.next = nextToken; - return this; - } - /** - * Whether or not to include rekeying transactions. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accountTxns = await indexerClient - * .lookupAccountTransactions(address) - * .rekeyTo(false) - * .do(); - * ``` - * - * @param rekeyTo - * @category query - */ - rekeyTo(rekeyTo) { - this.query['rekey-to'] = rekeyTo; - return this; - } -} -exports.default = LookupAccountTransactions; diff --git a/algosdk/client/v2/indexer/lookupApplicationBoxByIDandName.d.ts b/algosdk/client/v2/indexer/lookupApplicationBoxByIDandName.d.ts deleted file mode 100644 index 137f642..0000000 --- a/algosdk/client/v2/indexer/lookupApplicationBoxByIDandName.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -import IntDecoding from '../../../types/intDecoding'; -import HTTPClient from '../../client'; -import JSONRequest from '../jsonrequest'; -import { Box } from './models/types'; -export default class LookupApplicationBoxByIDandName extends JSONRequest> { - private index; - /** - * Returns information about indexed application boxes. - * - * #### Example - * ```typescript - * const boxName = Buffer.from("foo"); - * const boxResponse = await indexerClient - * .LookupApplicationBoxByIDandName(1234, boxName) - * .do(); - * const boxValue = boxResponse.value; - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2applicationsapplication-idbox) - * @oaram index - application index. - * @category GET - */ - constructor(c: HTTPClient, intDecoding: IntDecoding, index: number, boxName: Uint8Array); - /** - * @returns `/v2/applications/${index}/box` - */ - path(): string; - prepare(body: Record): Box; -} diff --git a/algosdk/client/v2/indexer/lookupApplicationBoxByIDandName.js b/algosdk/client/v2/indexer/lookupApplicationBoxByIDandName.js deleted file mode 100644 index f4369dd..0000000 --- a/algosdk/client/v2/indexer/lookupApplicationBoxByIDandName.js +++ /dev/null @@ -1,45 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const binarydata_1 = require("../../../encoding/binarydata"); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -const types_1 = require("./models/types"); -class LookupApplicationBoxByIDandName extends jsonrequest_1.default { - /** - * Returns information about indexed application boxes. - * - * #### Example - * ```typescript - * const boxName = Buffer.from("foo"); - * const boxResponse = await indexerClient - * .LookupApplicationBoxByIDandName(1234, boxName) - * .do(); - * const boxValue = boxResponse.value; - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2applicationsapplication-idbox) - * @oaram index - application index. - * @category GET - */ - constructor(c, intDecoding, index, boxName) { - super(c, intDecoding); - this.index = index; - this.index = index; - // Encode query in base64 format and append the encoding prefix. - const encodedName = (0, binarydata_1.bytesToBase64)(boxName); - this.query.name = encodeURI(`b64:${encodedName}`); - } - /** - * @returns `/v2/applications/${index}/box` - */ - path() { - return `/v2/applications/${this.index}/box`; - } - // eslint-disable-next-line class-methods-use-this - prepare(body) { - return types_1.Box.from_obj_for_encoding(body); - } -} -exports.default = LookupApplicationBoxByIDandName; diff --git a/algosdk/client/v2/indexer/lookupApplicationLogs.d.ts b/algosdk/client/v2/indexer/lookupApplicationLogs.d.ts deleted file mode 100644 index f9860b7..0000000 --- a/algosdk/client/v2/indexer/lookupApplicationLogs.d.ts +++ /dev/null @@ -1,126 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; -export default class LookupApplicationLogs extends JSONRequest { - private appID; - /** - * Returns log messages generated by the passed in application. - * - * #### Example - * ```typescript - * const appId = 60553466; - * const appLogs = await indexerClient.lookupApplicationLogs(appId).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2applicationsapplication-idlogs) - * @param appID - The ID of the application which generated the logs. - * @category GET - */ - constructor(c: HTTPClient, intDecoding: IntDecoding, appID: number); - /** - * @returns `/v2/applications/${appID}/logs` - */ - path(): string; - /** - * Limit results for pagination. - * - * #### Example - * ```typescript - * const maxResults = 20; - * const appLogs = await indexerClient - * .lookupApplicationLogs(appId) - * .limit(maxResults) - * .do(); - * ``` - * - * @param limit - maximum number of results to return. - */ - limit(limit: number): this; - /** - * Include results at or after the specified min-round. - * - * #### Example - * ```typescript - * const minRound = 18309917; - * const appLogs = await indexerClient - * .lookupApplicationLogs(appId) - * .minRound(minRound) - * .do(); - * ``` - * - * @param round - * @category query - */ - minRound(round: number): this; - /** - * Include results at or before the specified max-round. - * - * #### Example - * ```typescript - * const maxRound = 18309917; - * const appLogs = await indexerClient - * .lookupApplicationLogs(appId) - * .maxRound(maxRound) - * .do(); - * ``` - * - * @param round - * @category query - */ - maxRound(round: number): this; - /** - * The next page of results. - * - * #### Example - * ```typescript - * const maxResults = 25; - * - * const appLogsPage1 = await indexerClient - * .lookupApplicationLogs(appId) - * .limit(maxResults) - * .do(); - * - * const appLogsPage2 = await indexerClient - * .lookupApplicationLogs(appId) - * .limit(maxResults) - * .nextToken(appLogsPage1["next-token"]) - * .do(); - * ``` - * - * @param nextToken - provided by the previous results. - * @category query - */ - nextToken(nextToken: string): this; - /** - * Only include transactions with this sender address. - * - * #### Example - * ```typescript - * const sender = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const appLogs = await indexerClient - * .lookupApplicationLogs(appId) - * .sender(sender) - * .do(); - * ``` - * - * @param senderAddress - * @category query - */ - sender(senderAddress: string): this; - /** - * Lookup the specific transaction by ID. - * - * #### Example - * ```typescript - * const txId = "MEUOC4RQJB23CQZRFRKYEI6WBO73VTTPST5A7B3S5OKBUY6LFUDA"; - * const appLogs = await indexerClient - * .lookupApplicationLogs(appId) - * .txid(txId) - * .do(); - * ``` - * - * @param txid - * @category query - */ - txid(txid: string): this; -} diff --git a/algosdk/client/v2/indexer/lookupApplicationLogs.js b/algosdk/client/v2/indexer/lookupApplicationLogs.js deleted file mode 100644 index 5e1b07a..0000000 --- a/algosdk/client/v2/indexer/lookupApplicationLogs.js +++ /dev/null @@ -1,153 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -class LookupApplicationLogs extends jsonrequest_1.default { - /** - * Returns log messages generated by the passed in application. - * - * #### Example - * ```typescript - * const appId = 60553466; - * const appLogs = await indexerClient.lookupApplicationLogs(appId).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2applicationsapplication-idlogs) - * @param appID - The ID of the application which generated the logs. - * @category GET - */ - constructor(c, intDecoding, appID) { - super(c, intDecoding); - this.appID = appID; - this.appID = appID; - } - /** - * @returns `/v2/applications/${appID}/logs` - */ - path() { - return `/v2/applications/${this.appID}/logs`; - } - /** - * Limit results for pagination. - * - * #### Example - * ```typescript - * const maxResults = 20; - * const appLogs = await indexerClient - * .lookupApplicationLogs(appId) - * .limit(maxResults) - * .do(); - * ``` - * - * @param limit - maximum number of results to return. - */ - limit(limit) { - this.query.limit = limit; - return this; - } - /** - * Include results at or after the specified min-round. - * - * #### Example - * ```typescript - * const minRound = 18309917; - * const appLogs = await indexerClient - * .lookupApplicationLogs(appId) - * .minRound(minRound) - * .do(); - * ``` - * - * @param round - * @category query - */ - minRound(round) { - this.query['min-round'] = round; - return this; - } - /** - * Include results at or before the specified max-round. - * - * #### Example - * ```typescript - * const maxRound = 18309917; - * const appLogs = await indexerClient - * .lookupApplicationLogs(appId) - * .maxRound(maxRound) - * .do(); - * ``` - * - * @param round - * @category query - */ - maxRound(round) { - this.query['max-round'] = round; - return this; - } - /** - * The next page of results. - * - * #### Example - * ```typescript - * const maxResults = 25; - * - * const appLogsPage1 = await indexerClient - * .lookupApplicationLogs(appId) - * .limit(maxResults) - * .do(); - * - * const appLogsPage2 = await indexerClient - * .lookupApplicationLogs(appId) - * .limit(maxResults) - * .nextToken(appLogsPage1["next-token"]) - * .do(); - * ``` - * - * @param nextToken - provided by the previous results. - * @category query - */ - nextToken(nextToken) { - this.query.next = nextToken; - return this; - } - /** - * Only include transactions with this sender address. - * - * #### Example - * ```typescript - * const sender = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const appLogs = await indexerClient - * .lookupApplicationLogs(appId) - * .sender(sender) - * .do(); - * ``` - * - * @param senderAddress - * @category query - */ - sender(senderAddress) { - this.query['sender-address'] = senderAddress; - return this; - } - /** - * Lookup the specific transaction by ID. - * - * #### Example - * ```typescript - * const txId = "MEUOC4RQJB23CQZRFRKYEI6WBO73VTTPST5A7B3S5OKBUY6LFUDA"; - * const appLogs = await indexerClient - * .lookupApplicationLogs(appId) - * .txid(txId) - * .do(); - * ``` - * - * @param txid - * @category query - */ - txid(txid) { - this.query.txid = txid; - return this; - } -} -exports.default = LookupApplicationLogs; diff --git a/algosdk/client/v2/indexer/lookupApplications.d.ts b/algosdk/client/v2/indexer/lookupApplications.d.ts deleted file mode 100644 index 398c1dd..0000000 --- a/algosdk/client/v2/indexer/lookupApplications.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; -export default class LookupApplications extends JSONRequest { - private index; - /** - * Returns information about the passed application. - * - * #### Example - * ```typescript - * const appId = 60553466; - * const appInfo = await indexerClient.lookupApplications(appId).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2applicationsapplication-id) - * @param index - The ID of the application to look up. - * @category GET - */ - constructor(c: HTTPClient, intDecoding: IntDecoding, index: number); - /** - * @returns `/v2/applications/${index}` - */ - path(): string; - /** - * Includes all items including closed accounts, deleted applications, destroyed assets, opted-out asset holdings, and closed-out application localstates - * - * #### Example 1 - * ```typescript - * const appId = 60553466; - * const appInfo = await indexerClient - * .lookupApplications(appId) - * .includeAll(false) - * .do(); - * ``` - * - * #### Example 2 - * ```typescript - * const appId = 60553466; - * const appInfo = await indexerClient - * .lookupApplications(appId) - * .includeAll() - * .do(); - * ``` - * - * @param value - default true when called without passing a value - * @category query - */ - includeAll(value?: boolean): this; -} diff --git a/algosdk/client/v2/indexer/lookupApplications.js b/algosdk/client/v2/indexer/lookupApplications.js deleted file mode 100644 index 334b166..0000000 --- a/algosdk/client/v2/indexer/lookupApplications.js +++ /dev/null @@ -1,61 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -class LookupApplications extends jsonrequest_1.default { - /** - * Returns information about the passed application. - * - * #### Example - * ```typescript - * const appId = 60553466; - * const appInfo = await indexerClient.lookupApplications(appId).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2applicationsapplication-id) - * @param index - The ID of the application to look up. - * @category GET - */ - constructor(c, intDecoding, index) { - super(c, intDecoding); - this.index = index; - this.index = index; - } - /** - * @returns `/v2/applications/${index}` - */ - path() { - return `/v2/applications/${this.index}`; - } - /** - * Includes all items including closed accounts, deleted applications, destroyed assets, opted-out asset holdings, and closed-out application localstates - * - * #### Example 1 - * ```typescript - * const appId = 60553466; - * const appInfo = await indexerClient - * .lookupApplications(appId) - * .includeAll(false) - * .do(); - * ``` - * - * #### Example 2 - * ```typescript - * const appId = 60553466; - * const appInfo = await indexerClient - * .lookupApplications(appId) - * .includeAll() - * .do(); - * ``` - * - * @param value - default true when called without passing a value - * @category query - */ - includeAll(value = true) { - this.query['include-all'] = value; - return this; - } -} -exports.default = LookupApplications; diff --git a/algosdk/client/v2/indexer/lookupAssetBalances.d.ts b/algosdk/client/v2/indexer/lookupAssetBalances.d.ts deleted file mode 100644 index f49a687..0000000 --- a/algosdk/client/v2/indexer/lookupAssetBalances.d.ts +++ /dev/null @@ -1,120 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; -export default class LookupAssetBalances extends JSONRequest { - private index; - /** - * Returns the list of accounts which hold the given asset and their balance. - * - * #### Example - * ```typescript - * const assetId = 163650; - * const assetBalances = await indexerClient.lookupAssetBalances(assetId).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2assetsasset-idbalances) - * @param index - The asset ID to look up. - */ - constructor(c: HTTPClient, intDecoding: IntDecoding, index: number); - /** - * @returns `/v2/assets/${index}/balances` - */ - path(): string; - /** - * Limit results for pagination. - * - * #### Example - * ```typescript - * const assetId = 163650; - * const maxResults = 20; - * const assetBalances = await indexerClient - * .lookupAssetBalances(assetId) - * .limit(maxResults) - * .do(); - * ``` - * - * @param limit - maximum number of results to return. - * @category query - */ - limit(limit: number): this; - /** - * Filtered results should have an asset balance greater than this value. - * - * #### Example - * ```typescript - * const assetId = 163650; - * const minBalance = 1000000; - * const assetBalances = await indexerClient - * .lookupAssetBalances(assetId) - * .currencyGreaterThan(minBalance) - * .do(); - * ``` - * @param greater - * @category query - */ - currencyGreaterThan(greater: number): this; - /** - * Filtered results should have an asset balance less than this value. - * - * #### Example - * ```typescript - * const assetId = 163650; - * const maxBalance = 2000000; - * const assetBalances = await indexerClient - * .lookupAssetBalances(assetId) - * .currencyLessThan(maxBalance) - * .do(); - * ``` - * @param lesser - * @category query - */ - currencyLessThan(lesser: number): this; - /** - * Specify the next page of results. - * - * #### Example - * ```typescript - * const assetId = 163650; - * const maxResults = 20; - * - * const assetBalancesPage1 = await indexerClient - * .lookupAssetBalances(assetId) - * .limit(maxResults) - * .do(); - * - * const assetBalancesPage2 = await indexerClient - * .lookupAssetBalances(assetId) - * .limit(maxResults) - * .nextToken(assetBalancesPage1["next-token"]) - * .do(); - * ``` - * @param nextToken - provided by the previous results. - * @category query - */ - nextToken(nextToken: string): this; - /** - * Include all items including closed accounts, deleted applications, destroyed assets, opted-out asset holdings, and closed-out application localstates. - * - * #### Example 1 - * ```typescript - * const assetId = 163650; - * const assetBalances = await indexerClient - * .lookupAssetBalances(assetId) - * .includeAll(false) - * .do(); - * ``` - * - * #### Example 2 - * ```typescript - * const assetId = 163650; - * const assetBalances = await indexerClient - * .lookupAssetBalances(assetId) - * .includeAll() - * .do(); - * ``` - * - * @param value - * @category query - */ - includeAll(value?: boolean): this; -} diff --git a/algosdk/client/v2/indexer/lookupAssetBalances.js b/algosdk/client/v2/indexer/lookupAssetBalances.js deleted file mode 100644 index f0407bb..0000000 --- a/algosdk/client/v2/indexer/lookupAssetBalances.js +++ /dev/null @@ -1,145 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -class LookupAssetBalances extends jsonrequest_1.default { - /** - * Returns the list of accounts which hold the given asset and their balance. - * - * #### Example - * ```typescript - * const assetId = 163650; - * const assetBalances = await indexerClient.lookupAssetBalances(assetId).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2assetsasset-idbalances) - * @param index - The asset ID to look up. - */ - constructor(c, intDecoding, index) { - super(c, intDecoding); - this.index = index; - this.index = index; - } - /** - * @returns `/v2/assets/${index}/balances` - */ - path() { - return `/v2/assets/${this.index}/balances`; - } - /** - * Limit results for pagination. - * - * #### Example - * ```typescript - * const assetId = 163650; - * const maxResults = 20; - * const assetBalances = await indexerClient - * .lookupAssetBalances(assetId) - * .limit(maxResults) - * .do(); - * ``` - * - * @param limit - maximum number of results to return. - * @category query - */ - limit(limit) { - this.query.limit = limit; - return this; - } - /** - * Filtered results should have an asset balance greater than this value. - * - * #### Example - * ```typescript - * const assetId = 163650; - * const minBalance = 1000000; - * const assetBalances = await indexerClient - * .lookupAssetBalances(assetId) - * .currencyGreaterThan(minBalance) - * .do(); - * ``` - * @param greater - * @category query - */ - currencyGreaterThan(greater) { - // We convert the following to a string for now to correctly include zero values in request parameters. - this.query['currency-greater-than'] = greater.toString(); - return this; - } - /** - * Filtered results should have an asset balance less than this value. - * - * #### Example - * ```typescript - * const assetId = 163650; - * const maxBalance = 2000000; - * const assetBalances = await indexerClient - * .lookupAssetBalances(assetId) - * .currencyLessThan(maxBalance) - * .do(); - * ``` - * @param lesser - * @category query - */ - currencyLessThan(lesser) { - this.query['currency-less-than'] = lesser; - return this; - } - /** - * Specify the next page of results. - * - * #### Example - * ```typescript - * const assetId = 163650; - * const maxResults = 20; - * - * const assetBalancesPage1 = await indexerClient - * .lookupAssetBalances(assetId) - * .limit(maxResults) - * .do(); - * - * const assetBalancesPage2 = await indexerClient - * .lookupAssetBalances(assetId) - * .limit(maxResults) - * .nextToken(assetBalancesPage1["next-token"]) - * .do(); - * ``` - * @param nextToken - provided by the previous results. - * @category query - */ - nextToken(nextToken) { - this.query.next = nextToken; - return this; - } - /** - * Include all items including closed accounts, deleted applications, destroyed assets, opted-out asset holdings, and closed-out application localstates. - * - * #### Example 1 - * ```typescript - * const assetId = 163650; - * const assetBalances = await indexerClient - * .lookupAssetBalances(assetId) - * .includeAll(false) - * .do(); - * ``` - * - * #### Example 2 - * ```typescript - * const assetId = 163650; - * const assetBalances = await indexerClient - * .lookupAssetBalances(assetId) - * .includeAll() - * .do(); - * ``` - * - * @param value - * @category query - */ - includeAll(value = true) { - this.query['include-all'] = value; - return this; - } -} -exports.default = LookupAssetBalances; diff --git a/algosdk/client/v2/indexer/lookupAssetByID.d.ts b/algosdk/client/v2/indexer/lookupAssetByID.d.ts deleted file mode 100644 index 82198e8..0000000 --- a/algosdk/client/v2/indexer/lookupAssetByID.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; -export default class LookupAssetByID extends JSONRequest { - private index; - /** - * Returns asset information of the queried asset. - * - * #### Example - * ```typescript - * const assetId = 163650; - * const assetInfo = await indexerClient.lookupAssetByID(assetId).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2assetsasset-id) - * @param index - The asset ID to look up. - */ - constructor(c: HTTPClient, intDecoding: IntDecoding, index: number); - /** - * @returns `/v2/assets/${index}` - */ - path(): string; - /** - * Includes all items including closed accounts, deleted applications, destroyed assets, opted-out asset holdings, and closed-out application localstates - * - * #### Example 1 - * ```typescript - * const assetId = 163650; - * const assetInfo = await indexerClient - * .lookupAssetByID(assetId) - * .includeAll(false) - * .do(); - * ``` - * - * #### Example 2 - * ```typescript - * const assetId = 163650; - * const assetInfo = await indexerClient - * .lookupAssetByID(assetId) - * .includeAll() - * .do(); - * ``` - * - * @param value - default true when called without passing a value - * @category query - */ - includeAll(value?: boolean): this; -} diff --git a/algosdk/client/v2/indexer/lookupAssetByID.js b/algosdk/client/v2/indexer/lookupAssetByID.js deleted file mode 100644 index fc19e61..0000000 --- a/algosdk/client/v2/indexer/lookupAssetByID.js +++ /dev/null @@ -1,60 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -class LookupAssetByID extends jsonrequest_1.default { - /** - * Returns asset information of the queried asset. - * - * #### Example - * ```typescript - * const assetId = 163650; - * const assetInfo = await indexerClient.lookupAssetByID(assetId).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2assetsasset-id) - * @param index - The asset ID to look up. - */ - constructor(c, intDecoding, index) { - super(c, intDecoding); - this.index = index; - this.index = index; - } - /** - * @returns `/v2/assets/${index}` - */ - path() { - return `/v2/assets/${this.index}`; - } - /** - * Includes all items including closed accounts, deleted applications, destroyed assets, opted-out asset holdings, and closed-out application localstates - * - * #### Example 1 - * ```typescript - * const assetId = 163650; - * const assetInfo = await indexerClient - * .lookupAssetByID(assetId) - * .includeAll(false) - * .do(); - * ``` - * - * #### Example 2 - * ```typescript - * const assetId = 163650; - * const assetInfo = await indexerClient - * .lookupAssetByID(assetId) - * .includeAll() - * .do(); - * ``` - * - * @param value - default true when called without passing a value - * @category query - */ - includeAll(value = true) { - this.query['include-all'] = value; - return this; - } -} -exports.default = LookupAssetByID; diff --git a/algosdk/client/v2/indexer/lookupAssetTransactions.d.ts b/algosdk/client/v2/indexer/lookupAssetTransactions.d.ts deleted file mode 100644 index e678e25..0000000 --- a/algosdk/client/v2/indexer/lookupAssetTransactions.d.ts +++ /dev/null @@ -1,320 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; -export default class LookupAssetTransactions extends JSONRequest { - private index; - /** - * Returns transactions relating to the given asset. - * - * #### Example - * ```typescript - * const assetId = 163650; - * const assetTxns = await indexerClient.lookupAssetTransactions(assetId).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2assetsasset-idtransactions) - * @param index - The asset ID to look up. - */ - constructor(c: HTTPClient, intDecoding: IntDecoding, index: number); - /** - * @returns `/v2/assets/${index}/transactions` - */ - path(): string; - /** - * Specifies a prefix which must be contained in the note field. - * - * #### Example - * ```typescript - * const notePrefixBase64Encoded = "Y3JlYXRl"; - * const assetId = 163650; - * const assetTxns = await indexerClient - * .lookupAssetTransactions(assetId) - * .notePrefix(notePrefixBase64Encoded) - * .do(); - * ``` - * - * @param prefix - base64 string or uint8array - * @category query - */ - notePrefix(prefix: Uint8Array | string): this; - /** - * Type of transaction to filter with. - * - * #### Example - * ```typescript - * const assetId = 163650; - * const assetTxns = await indexerClient - * .lookupAssetTransactions(assetId) - * .txType("axfer") - * .do(); - * ``` - * - * @param type - one of `pay`, `keyreg`, `acfg`, `axfer`, `afrz`, `appl` - * @category query - */ - txType(type: string): this; - /** - * Type of signature to filter with. - * - sig: Standard - * - msig: MultiSig - * - lsig: LogicSig - * - * #### Example - * ```typescript - * const assetId = 163650; - * const assetTxns = await indexerClient - * .lookupAssetTransactions(assetId) - * .sigType("lsig") - * .do(); - * ``` - * - * @param type - one of `sig`, `msig`, `lsig` - * @category query - */ - sigType(type: string): this; - /** - * Lookup the specific transaction by ID. - * - * #### Example - * ```typescript - * const txId = "MEUOC4RQJB23CQZRFRKYEI6WBO73VTTPST5A7B3S5OKBUY6LFUDA"; - * const assetId = 163650; - * const assetTxns = await indexerClient - * .lookupAssetTransactions(assetId) - * .txid(txId) - * .do(); - * ``` - * - * @param txid - * @category query - */ - txid(txid: string): this; - /** - * Include results for the specified round. - * - * #### Example - * ```typescript - * const targetBlock = 18309917; - * const assetId = 163650; - * const assetTxns = await indexerClient - * .lookupAssetTransactions(assetId) - * .round(targetBlock) - * .do(); - * ``` - * - * @param round - * @category query - */ - round(round: number): this; - /** - * Include results at or after the specified min-round. - * - * #### Example - * ```typescript - * const minRound = 18309917; - * const assetId = 163650; - * const assetTxns = await indexerClient - * .lookupAssetTransactions(assetId) - * .minRound(minRound) - * .do(); - * ``` - * - * @param round - * @category query - */ - minRound(round: number): this; - /** - * Include results at or before the specified max-round. - * - * #### Example - * ```typescript - * const maxRound = 18309917; - * const assetId = 163650; - * const assetTxns = await indexerClient - * .lookupAssetTransactions(assetId) - * .maxRound(maxRound) - * .do(); - * ``` - * - * @param round - * @category query - */ - maxRound(round: number): this; - /** - * Maximum number of results to return. - * - * #### Example - * ```typescript - * const maxResults = 25; - * const assetId = 163650; - * const assetTxns = await indexerClient - * .lookupAssetTransactions(assetId) - * .limit(maxResults) - * .do(); - * ``` - * - * @param limit - * @category query - */ - limit(limit: number): this; - /** - * Include results before the given time. - * - * #### Example - * ```typescript - * const beforeTime = "2022-02-02T20:20:22.02Z"; - * const assetId = 163650; - * const assetTxns = await indexerClient - * .lookupAssetTransactions(assetId) - * .beforeTime(beforeTime) - * .do(); - * ``` - * - * @param before - rfc3339 string - * @category query - */ - beforeTime(before: string): this; - /** - * Include results after the given time. - * - * #### Example - * ```typescript - * const afterTime = "2022-10-21T00:00:11.55Z"; - * const assetId = 163650; - * const assetTxns = await indexerClient - * .lookupAssetTransactions(assetId) - * .afterTime(afterTime) - * .do(); - * ``` - * - * @param after - rfc3339 string - * @category query - */ - afterTime(after: string): this; - /** - * Filtered results should have an amount greater than this value, as int, representing asset units. - * - * #### Example - * ```typescript - * const minBalance = 300000; - * const assetId = 163650; - * const assetTxns = await indexerClient - * .lookupAssetTransactions(assetId) - * .currencyGreaterThan(minBalance - 1) - * .do(); - * ``` - * - * @param greater - * @category query - */ - currencyGreaterThan(greater: number): this; - /** - * Filtered results should have an amount less than this value, as int, representing asset units. - * - * #### Example - * ```typescript - * const maxBalance = 500000; - * const assetId = 163650; - * const assetTxns = await indexerClient - * .lookupAssetTransactions(assetId) - * .currencyLessThan(maxBalance + 1) - * .do(); - * ``` - * - * @param lesser - * @category query - */ - currencyLessThan(lesser: number): this; - /** - * Combined with address, defines what address to filter on, as string. - * - * #### Example - * ```typescript - * const assetId = 163650; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const role = "sender"; - * const assetTxns = await indexerClient - * .lookupAssetTransactions(assetId) - * .address(address) - * .addressRole(role) - * .do(); - * ``` - * - * @param role - one of `sender`, `receiver`, `freeze-target` - * @category query - */ - addressRole(role: string): this; - /** - * Only include transactions with this address in one of the transaction fields. - * - * #### Example - * ```typescript - * const assetId = 163650; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const assetTxns = await indexerClient - * .lookupAssetTransactions(assetId) - * .address(address) - * .do(); - * ``` - * - * @param address - * @category query - */ - address(address: string): this; - /** - * Whether or not to consider the `close-to` field as a receiver when filtering transactions, as bool. Set to `true` to ignore `close-to`. - * - * #### Example - * ```typescript - * const assetId = 163650; - * const assetTxns = await indexerClient - * .lookupAssetTransactions(assetId) - * .excludeCloseTo(true) - * .do(); - * ``` - * - * @param exclude - * @category query - */ - excludeCloseTo(exclude: boolean): this; - /** - * The next page of results. - * - * #### Example - * ```typescript - * const maxResults = 25; - * const assetId = 163650; - * - * const assetTxnsPage1 = await indexerClient - * .lookupAssetTransactions(assetId) - * .limit(maxResults) - * .do(); - * - * const assetTxnsPage2 = await indexerClient - * .lookupAssetTransactions(assetId) - * .limit(maxResults) - * .nextToken(assetTxnsPage1["next-token"]) - * .do(); - * ``` - * - * @param nextToken - provided by the previous results. - * @category query - */ - nextToken(nextToken: string): this; - /** - * Whether or not to include rekeying transactions. - * - * #### Example - * ```typescript - * const assetId = 163650; - * const assetTxns = await indexerClient - * .lookupAssetTransactions(assetId) - * .rekeyTo(false) - * .do(); - * ``` - * - * @param rekeyTo - * @category query - */ - rekeyTo(rekeyTo: boolean): this; -} diff --git a/algosdk/client/v2/indexer/lookupAssetTransactions.js b/algosdk/client/v2/indexer/lookupAssetTransactions.js deleted file mode 100644 index bac560e..0000000 --- a/algosdk/client/v2/indexer/lookupAssetTransactions.js +++ /dev/null @@ -1,382 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -const lookupAccountTransactions_1 = require("./lookupAccountTransactions"); -class LookupAssetTransactions extends jsonrequest_1.default { - /** - * Returns transactions relating to the given asset. - * - * #### Example - * ```typescript - * const assetId = 163650; - * const assetTxns = await indexerClient.lookupAssetTransactions(assetId).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2assetsasset-idtransactions) - * @param index - The asset ID to look up. - */ - constructor(c, intDecoding, index) { - super(c, intDecoding); - this.index = index; - this.index = index; - } - /** - * @returns `/v2/assets/${index}/transactions` - */ - path() { - return `/v2/assets/${this.index}/transactions`; - } - /** - * Specifies a prefix which must be contained in the note field. - * - * #### Example - * ```typescript - * const notePrefixBase64Encoded = "Y3JlYXRl"; - * const assetId = 163650; - * const assetTxns = await indexerClient - * .lookupAssetTransactions(assetId) - * .notePrefix(notePrefixBase64Encoded) - * .do(); - * ``` - * - * @param prefix - base64 string or uint8array - * @category query - */ - notePrefix(prefix) { - this.query['note-prefix'] = (0, lookupAccountTransactions_1.base64StringFunnel)(prefix); - return this; - } - /** - * Type of transaction to filter with. - * - * #### Example - * ```typescript - * const assetId = 163650; - * const assetTxns = await indexerClient - * .lookupAssetTransactions(assetId) - * .txType("axfer") - * .do(); - * ``` - * - * @param type - one of `pay`, `keyreg`, `acfg`, `axfer`, `afrz`, `appl` - * @category query - */ - txType(type) { - this.query['tx-type'] = type; - return this; - } - /** - * Type of signature to filter with. - * - sig: Standard - * - msig: MultiSig - * - lsig: LogicSig - * - * #### Example - * ```typescript - * const assetId = 163650; - * const assetTxns = await indexerClient - * .lookupAssetTransactions(assetId) - * .sigType("lsig") - * .do(); - * ``` - * - * @param type - one of `sig`, `msig`, `lsig` - * @category query - */ - sigType(type) { - this.query['sig-type'] = type; - return this; - } - /** - * Lookup the specific transaction by ID. - * - * #### Example - * ```typescript - * const txId = "MEUOC4RQJB23CQZRFRKYEI6WBO73VTTPST5A7B3S5OKBUY6LFUDA"; - * const assetId = 163650; - * const assetTxns = await indexerClient - * .lookupAssetTransactions(assetId) - * .txid(txId) - * .do(); - * ``` - * - * @param txid - * @category query - */ - txid(txid) { - this.query.txid = txid; - return this; - } - /** - * Include results for the specified round. - * - * #### Example - * ```typescript - * const targetBlock = 18309917; - * const assetId = 163650; - * const assetTxns = await indexerClient - * .lookupAssetTransactions(assetId) - * .round(targetBlock) - * .do(); - * ``` - * - * @param round - * @category query - */ - round(round) { - this.query.round = round; - return this; - } - /** - * Include results at or after the specified min-round. - * - * #### Example - * ```typescript - * const minRound = 18309917; - * const assetId = 163650; - * const assetTxns = await indexerClient - * .lookupAssetTransactions(assetId) - * .minRound(minRound) - * .do(); - * ``` - * - * @param round - * @category query - */ - minRound(round) { - this.query['min-round'] = round; - return this; - } - /** - * Include results at or before the specified max-round. - * - * #### Example - * ```typescript - * const maxRound = 18309917; - * const assetId = 163650; - * const assetTxns = await indexerClient - * .lookupAssetTransactions(assetId) - * .maxRound(maxRound) - * .do(); - * ``` - * - * @param round - * @category query - */ - maxRound(round) { - this.query['max-round'] = round; - return this; - } - /** - * Maximum number of results to return. - * - * #### Example - * ```typescript - * const maxResults = 25; - * const assetId = 163650; - * const assetTxns = await indexerClient - * .lookupAssetTransactions(assetId) - * .limit(maxResults) - * .do(); - * ``` - * - * @param limit - * @category query - */ - limit(limit) { - this.query.limit = limit; - return this; - } - /** - * Include results before the given time. - * - * #### Example - * ```typescript - * const beforeTime = "2022-02-02T20:20:22.02Z"; - * const assetId = 163650; - * const assetTxns = await indexerClient - * .lookupAssetTransactions(assetId) - * .beforeTime(beforeTime) - * .do(); - * ``` - * - * @param before - rfc3339 string - * @category query - */ - beforeTime(before) { - this.query['before-time'] = before; - return this; - } - /** - * Include results after the given time. - * - * #### Example - * ```typescript - * const afterTime = "2022-10-21T00:00:11.55Z"; - * const assetId = 163650; - * const assetTxns = await indexerClient - * .lookupAssetTransactions(assetId) - * .afterTime(afterTime) - * .do(); - * ``` - * - * @param after - rfc3339 string - * @category query - */ - afterTime(after) { - this.query['after-time'] = after; - return this; - } - /** - * Filtered results should have an amount greater than this value, as int, representing asset units. - * - * #### Example - * ```typescript - * const minBalance = 300000; - * const assetId = 163650; - * const assetTxns = await indexerClient - * .lookupAssetTransactions(assetId) - * .currencyGreaterThan(minBalance - 1) - * .do(); - * ``` - * - * @param greater - * @category query - */ - currencyGreaterThan(greater) { - // We convert the following to a string for now to correctly include zero values in request parameters. - this.query['currency-greater-than'] = greater.toString(); - return this; - } - /** - * Filtered results should have an amount less than this value, as int, representing asset units. - * - * #### Example - * ```typescript - * const maxBalance = 500000; - * const assetId = 163650; - * const assetTxns = await indexerClient - * .lookupAssetTransactions(assetId) - * .currencyLessThan(maxBalance + 1) - * .do(); - * ``` - * - * @param lesser - * @category query - */ - currencyLessThan(lesser) { - this.query['currency-less-than'] = lesser; - return this; - } - /** - * Combined with address, defines what address to filter on, as string. - * - * #### Example - * ```typescript - * const assetId = 163650; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const role = "sender"; - * const assetTxns = await indexerClient - * .lookupAssetTransactions(assetId) - * .address(address) - * .addressRole(role) - * .do(); - * ``` - * - * @param role - one of `sender`, `receiver`, `freeze-target` - * @category query - */ - addressRole(role) { - this.query['address-role'] = role; - return this; - } - /** - * Only include transactions with this address in one of the transaction fields. - * - * #### Example - * ```typescript - * const assetId = 163650; - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const assetTxns = await indexerClient - * .lookupAssetTransactions(assetId) - * .address(address) - * .do(); - * ``` - * - * @param address - * @category query - */ - address(address) { - this.query.address = address; - return this; - } - /** - * Whether or not to consider the `close-to` field as a receiver when filtering transactions, as bool. Set to `true` to ignore `close-to`. - * - * #### Example - * ```typescript - * const assetId = 163650; - * const assetTxns = await indexerClient - * .lookupAssetTransactions(assetId) - * .excludeCloseTo(true) - * .do(); - * ``` - * - * @param exclude - * @category query - */ - excludeCloseTo(exclude) { - this.query['exclude-close-to'] = exclude; - return this; - } - /** - * The next page of results. - * - * #### Example - * ```typescript - * const maxResults = 25; - * const assetId = 163650; - * - * const assetTxnsPage1 = await indexerClient - * .lookupAssetTransactions(assetId) - * .limit(maxResults) - * .do(); - * - * const assetTxnsPage2 = await indexerClient - * .lookupAssetTransactions(assetId) - * .limit(maxResults) - * .nextToken(assetTxnsPage1["next-token"]) - * .do(); - * ``` - * - * @param nextToken - provided by the previous results. - * @category query - */ - nextToken(nextToken) { - this.query.next = nextToken; - return this; - } - /** - * Whether or not to include rekeying transactions. - * - * #### Example - * ```typescript - * const assetId = 163650; - * const assetTxns = await indexerClient - * .lookupAssetTransactions(assetId) - * .rekeyTo(false) - * .do(); - * ``` - * - * @param rekeyTo - * @category query - */ - rekeyTo(rekeyTo) { - this.query['rekey-to'] = rekeyTo; - return this; - } -} -exports.default = LookupAssetTransactions; diff --git a/algosdk/client/v2/indexer/lookupBlock.d.ts b/algosdk/client/v2/indexer/lookupBlock.d.ts deleted file mode 100644 index 42ebd0b..0000000 --- a/algosdk/client/v2/indexer/lookupBlock.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; -export default class LookupBlock extends JSONRequest { - private round; - /** - * Returns the block for the passed round. - * - * #### Example - * ```typescript - * const targetBlock = 18309917; - * const blockInfo = await indexerClient.lookupBlock(targetBlock).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2blocksround-number) - * @param round - The number of the round to look up. - * @category GET - */ - constructor(c: HTTPClient, intDecoding: IntDecoding, round: number); - /** - * @returns `/v2/blocks/${round}` - */ - path(): string; - /** - * Header only flag. When this is set to true, returned block does not contain the - * transactions. - */ - headerOnly(headerOnly: boolean): this; -} diff --git a/algosdk/client/v2/indexer/lookupBlock.js b/algosdk/client/v2/indexer/lookupBlock.js deleted file mode 100644 index a45caa3..0000000 --- a/algosdk/client/v2/indexer/lookupBlock.js +++ /dev/null @@ -1,41 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -class LookupBlock extends jsonrequest_1.default { - /** - * Returns the block for the passed round. - * - * #### Example - * ```typescript - * const targetBlock = 18309917; - * const blockInfo = await indexerClient.lookupBlock(targetBlock).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2blocksround-number) - * @param round - The number of the round to look up. - * @category GET - */ - constructor(c, intDecoding, round) { - super(c, intDecoding); - this.round = round; - this.round = round; - } - /** - * @returns `/v2/blocks/${round}` - */ - path() { - return `/v2/blocks/${this.round}`; - } - /** - * Header only flag. When this is set to true, returned block does not contain the - * transactions. - */ - headerOnly(headerOnly) { - this.query['header-only'] = headerOnly; - return this; - } -} -exports.default = LookupBlock; diff --git a/algosdk/client/v2/indexer/lookupTransactionByID.d.ts b/algosdk/client/v2/indexer/lookupTransactionByID.d.ts deleted file mode 100644 index bac1860..0000000 --- a/algosdk/client/v2/indexer/lookupTransactionByID.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; -export default class LookupTransactionByID extends JSONRequest { - private txID; - /** - * Returns information about the given transaction. - * - * #### Example - * ```typescript - * const txnId = "MEUOC4RQJB23CQZRFRKYEI6WBO73VTTPST5A7B3S5OKBUY6LFUDA"; - * const txnInfo = await indexerClient.lookupTransactionByID(txnId).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2transactionstxid) - * @param txID - The ID of the transaction to look up. - * @category GET - */ - constructor(c: HTTPClient, intDecoding: IntDecoding, txID: string); - /** - * @returns `/v2/transactions/${txID}` - */ - path(): string; -} diff --git a/algosdk/client/v2/indexer/lookupTransactionByID.js b/algosdk/client/v2/indexer/lookupTransactionByID.js deleted file mode 100644 index 81b3ffb..0000000 --- a/algosdk/client/v2/indexer/lookupTransactionByID.js +++ /dev/null @@ -1,33 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -class LookupTransactionByID extends jsonrequest_1.default { - /** - * Returns information about the given transaction. - * - * #### Example - * ```typescript - * const txnId = "MEUOC4RQJB23CQZRFRKYEI6WBO73VTTPST5A7B3S5OKBUY6LFUDA"; - * const txnInfo = await indexerClient.lookupTransactionByID(txnId).do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2transactionstxid) - * @param txID - The ID of the transaction to look up. - * @category GET - */ - constructor(c, intDecoding, txID) { - super(c, intDecoding); - this.txID = txID; - this.txID = txID; - } - /** - * @returns `/v2/transactions/${txID}` - */ - path() { - return `/v2/transactions/${this.txID}`; - } -} -exports.default = LookupTransactionByID; diff --git a/algosdk/client/v2/indexer/makeHealthCheck.d.ts b/algosdk/client/v2/indexer/makeHealthCheck.d.ts deleted file mode 100644 index fc4afa0..0000000 --- a/algosdk/client/v2/indexer/makeHealthCheck.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -import JSONRequest from '../jsonrequest'; -/** - * Returns the health object for the service. - * Returns 200 if healthy. - * - * #### Example - * ```typescript - * const health = await indexerClient.makeHealthCheck().do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-health) - * @category GET - */ -export default class MakeHealthCheck extends JSONRequest { - /** - * @returns `/health` - */ - path(): string; -} diff --git a/algosdk/client/v2/indexer/makeHealthCheck.js b/algosdk/client/v2/indexer/makeHealthCheck.js deleted file mode 100644 index 222c829..0000000 --- a/algosdk/client/v2/indexer/makeHealthCheck.js +++ /dev/null @@ -1,28 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -/** - * Returns the health object for the service. - * Returns 200 if healthy. - * - * #### Example - * ```typescript - * const health = await indexerClient.makeHealthCheck().do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-health) - * @category GET - */ -class MakeHealthCheck extends jsonrequest_1.default { - /** - * @returns `/health` - */ - // eslint-disable-next-line class-methods-use-this - path() { - return '/health'; - } -} -exports.default = MakeHealthCheck; diff --git a/algosdk/client/v2/indexer/models/types.d.ts b/algosdk/client/v2/indexer/models/types.d.ts deleted file mode 100644 index 1398ab5..0000000 --- a/algosdk/client/v2/indexer/models/types.d.ts +++ /dev/null @@ -1,2695 +0,0 @@ -/** - * NOTICE: This file was generated. Editing this file manually is not recommended. - */ -import BaseModel from '../../basemodel'; -/** - * Account information at a given round. - * Definition: - * data/basics/userBalance.go : AccountData - */ -export declare class Account extends BaseModel { - /** - * the account public key - */ - address: string; - /** - * (algo) total number of MicroAlgos in the account - */ - amount: number | bigint; - /** - * specifies the amount of MicroAlgos in the account, without the pending rewards. - */ - amountWithoutPendingRewards: number | bigint; - /** - * amount of MicroAlgos of pending rewards in this account. - */ - pendingRewards: number | bigint; - /** - * (ern) total rewards of MicroAlgos the account has received, including pending - * rewards. - */ - rewards: number | bigint; - /** - * The round for which this information is relevant. - */ - round: number | bigint; - /** - * (onl) delegation status of the account's MicroAlgos - * * Offline - indicates that the associated account is delegated. - * * Online - indicates that the associated account used as part of the delegation - * pool. - * * NotParticipating - indicates that the associated account is neither a - * delegator nor a delegate. - */ - status: string; - /** - * The count of all applications that have been opted in, equivalent to the count - * of application local data (AppLocalState objects) stored in this account. - */ - totalAppsOptedIn: number | bigint; - /** - * The count of all assets that have been opted in, equivalent to the count of - * AssetHolding objects held by this account. - */ - totalAssetsOptedIn: number | bigint; - /** - * For app-accounts only. The total number of bytes allocated for the keys and - * values of boxes which belong to the associated application. - */ - totalBoxBytes: number | bigint; - /** - * For app-accounts only. The total number of boxes which belong to the associated - * application. - */ - totalBoxes: number | bigint; - /** - * The count of all apps (AppParams objects) created by this account. - */ - totalCreatedApps: number | bigint; - /** - * The count of all assets (AssetParams objects) created by this account. - */ - totalCreatedAssets: number | bigint; - /** - * (appl) applications local data stored in this account. - * Note the raw object uses `map[int] -> AppLocalState` for this type. - */ - appsLocalState?: ApplicationLocalState[]; - /** - * (teap) the sum of all extra application program pages for this account. - */ - appsTotalExtraPages?: number | bigint; - /** - * (tsch) stores the sum of all of the local schemas and global schemas in this - * account. - * Note: the raw account uses `StateSchema` for this type. - */ - appsTotalSchema?: ApplicationStateSchema; - /** - * (asset) assets held by this account. - * Note the raw object uses `map[int] -> AssetHolding` for this type. - */ - assets?: AssetHolding[]; - /** - * (spend) the address against which signing should be checked. If empty, the - * address of the current account is used. This field can be updated in any - * transaction by setting the RekeyTo field. - */ - authAddr?: string; - /** - * Round during which this account was most recently closed. - */ - closedAtRound?: number | bigint; - /** - * (appp) parameters of applications created by this account including app global - * data. - * Note: the raw account uses `map[int] -> AppParams` for this type. - */ - createdApps?: Application[]; - /** - * (apar) parameters of assets created by this account. - * Note: the raw account uses `map[int] -> Asset` for this type. - */ - createdAssets?: Asset[]; - /** - * Round during which this account first appeared in a transaction. - */ - createdAtRound?: number | bigint; - /** - * Whether or not this account is currently closed. - */ - deleted?: boolean; - /** - * AccountParticipation describes the parameters used by this account in consensus - * protocol. - */ - participation?: AccountParticipation; - /** - * (ebase) used as part of the rewards computation. Only applicable to accounts - * which are participating. - */ - rewardBase?: number | bigint; - /** - * Indicates what type of signature is used by this account, must be one of: - * * sig - * * msig - * * lsig - * * or null if unknown - */ - sigType?: string; - /** - * Creates a new `Account` object. - * @param address - the account public key - * @param amount - (algo) total number of MicroAlgos in the account - * @param amountWithoutPendingRewards - specifies the amount of MicroAlgos in the account, without the pending rewards. - * @param pendingRewards - amount of MicroAlgos of pending rewards in this account. - * @param rewards - (ern) total rewards of MicroAlgos the account has received, including pending - * rewards. - * @param round - The round for which this information is relevant. - * @param status - (onl) delegation status of the account's MicroAlgos - * * Offline - indicates that the associated account is delegated. - * * Online - indicates that the associated account used as part of the delegation - * pool. - * * NotParticipating - indicates that the associated account is neither a - * delegator nor a delegate. - * @param totalAppsOptedIn - The count of all applications that have been opted in, equivalent to the count - * of application local data (AppLocalState objects) stored in this account. - * @param totalAssetsOptedIn - The count of all assets that have been opted in, equivalent to the count of - * AssetHolding objects held by this account. - * @param totalBoxBytes - For app-accounts only. The total number of bytes allocated for the keys and - * values of boxes which belong to the associated application. - * @param totalBoxes - For app-accounts only. The total number of boxes which belong to the associated - * application. - * @param totalCreatedApps - The count of all apps (AppParams objects) created by this account. - * @param totalCreatedAssets - The count of all assets (AssetParams objects) created by this account. - * @param appsLocalState - (appl) applications local data stored in this account. - * Note the raw object uses `map[int] -> AppLocalState` for this type. - * @param appsTotalExtraPages - (teap) the sum of all extra application program pages for this account. - * @param appsTotalSchema - (tsch) stores the sum of all of the local schemas and global schemas in this - * account. - * Note: the raw account uses `StateSchema` for this type. - * @param assets - (asset) assets held by this account. - * Note the raw object uses `map[int] -> AssetHolding` for this type. - * @param authAddr - (spend) the address against which signing should be checked. If empty, the - * address of the current account is used. This field can be updated in any - * transaction by setting the RekeyTo field. - * @param closedAtRound - Round during which this account was most recently closed. - * @param createdApps - (appp) parameters of applications created by this account including app global - * data. - * Note: the raw account uses `map[int] -> AppParams` for this type. - * @param createdAssets - (apar) parameters of assets created by this account. - * Note: the raw account uses `map[int] -> Asset` for this type. - * @param createdAtRound - Round during which this account first appeared in a transaction. - * @param deleted - Whether or not this account is currently closed. - * @param participation - AccountParticipation describes the parameters used by this account in consensus - * protocol. - * @param rewardBase - (ebase) used as part of the rewards computation. Only applicable to accounts - * which are participating. - * @param sigType - Indicates what type of signature is used by this account, must be one of: - * * sig - * * msig - * * lsig - * * or null if unknown - */ - constructor({ address, amount, amountWithoutPendingRewards, pendingRewards, rewards, round, status, totalAppsOptedIn, totalAssetsOptedIn, totalBoxBytes, totalBoxes, totalCreatedApps, totalCreatedAssets, appsLocalState, appsTotalExtraPages, appsTotalSchema, assets, authAddr, closedAtRound, createdApps, createdAssets, createdAtRound, deleted, participation, rewardBase, sigType, }: { - address: string; - amount: number | bigint; - amountWithoutPendingRewards: number | bigint; - pendingRewards: number | bigint; - rewards: number | bigint; - round: number | bigint; - status: string; - totalAppsOptedIn: number | bigint; - totalAssetsOptedIn: number | bigint; - totalBoxBytes: number | bigint; - totalBoxes: number | bigint; - totalCreatedApps: number | bigint; - totalCreatedAssets: number | bigint; - appsLocalState?: ApplicationLocalState[]; - appsTotalExtraPages?: number | bigint; - appsTotalSchema?: ApplicationStateSchema; - assets?: AssetHolding[]; - authAddr?: string; - closedAtRound?: number | bigint; - createdApps?: Application[]; - createdAssets?: Asset[]; - createdAtRound?: number | bigint; - deleted?: boolean; - participation?: AccountParticipation; - rewardBase?: number | bigint; - sigType?: string; - }); - static from_obj_for_encoding(data: Record): Account; -} -/** - * AccountParticipation describes the parameters used by this account in consensus - * protocol. - */ -export declare class AccountParticipation extends BaseModel { - /** - * (sel) Selection public key (if any) currently registered for this round. - */ - selectionParticipationKey: Uint8Array; - /** - * (voteFst) First round for which this participation is valid. - */ - voteFirstValid: number | bigint; - /** - * (voteKD) Number of subkeys in each batch of participation keys. - */ - voteKeyDilution: number | bigint; - /** - * (voteLst) Last round for which this participation is valid. - */ - voteLastValid: number | bigint; - /** - * (vote) root participation public key (if any) currently registered for this - * round. - */ - voteParticipationKey: Uint8Array; - /** - * (stprf) Root of the state proof key (if any) - */ - stateProofKey?: Uint8Array; - /** - * Creates a new `AccountParticipation` object. - * @param selectionParticipationKey - (sel) Selection public key (if any) currently registered for this round. - * @param voteFirstValid - (voteFst) First round for which this participation is valid. - * @param voteKeyDilution - (voteKD) Number of subkeys in each batch of participation keys. - * @param voteLastValid - (voteLst) Last round for which this participation is valid. - * @param voteParticipationKey - (vote) root participation public key (if any) currently registered for this - * round. - * @param stateProofKey - (stprf) Root of the state proof key (if any) - */ - constructor({ selectionParticipationKey, voteFirstValid, voteKeyDilution, voteLastValid, voteParticipationKey, stateProofKey, }: { - selectionParticipationKey: string | Uint8Array; - voteFirstValid: number | bigint; - voteKeyDilution: number | bigint; - voteLastValid: number | bigint; - voteParticipationKey: string | Uint8Array; - stateProofKey?: string | Uint8Array; - }); - static from_obj_for_encoding(data: Record): AccountParticipation; -} -/** - * - */ -export declare class AccountResponse extends BaseModel { - /** - * Account information at a given round. - * Definition: - * data/basics/userBalance.go : AccountData - */ - account: Account; - /** - * Round at which the results were computed. - */ - currentRound: number | bigint; - /** - * Creates a new `AccountResponse` object. - * @param account - Account information at a given round. - * Definition: - * data/basics/userBalance.go : AccountData - * @param currentRound - Round at which the results were computed. - */ - constructor({ account, currentRound, }: { - account: Account; - currentRound: number | bigint; - }); - static from_obj_for_encoding(data: Record): AccountResponse; -} -/** - * Application state delta. - */ -export declare class AccountStateDelta extends BaseModel { - address: string; - /** - * Application state delta. - */ - delta: EvalDeltaKeyValue[]; - /** - * Creates a new `AccountStateDelta` object. - * @param address - - * @param delta - Application state delta. - */ - constructor({ address, delta, }: { - address: string; - delta: EvalDeltaKeyValue[]; - }); - static from_obj_for_encoding(data: Record): AccountStateDelta; -} -/** - * - */ -export declare class AccountsResponse extends BaseModel { - accounts: Account[]; - /** - * Round at which the results were computed. - */ - currentRound: number | bigint; - /** - * Used for pagination, when making another request provide this token with the - * next parameter. - */ - nextToken?: string; - /** - * Creates a new `AccountsResponse` object. - * @param accounts - - * @param currentRound - Round at which the results were computed. - * @param nextToken - Used for pagination, when making another request provide this token with the - * next parameter. - */ - constructor({ accounts, currentRound, nextToken, }: { - accounts: Account[]; - currentRound: number | bigint; - nextToken?: string; - }); - static from_obj_for_encoding(data: Record): AccountsResponse; -} -/** - * Application index and its parameters - */ -export declare class Application extends BaseModel { - /** - * (appidx) application index. - */ - id: number | bigint; - /** - * (appparams) application parameters. - */ - params: ApplicationParams; - /** - * Round when this application was created. - */ - createdAtRound?: number | bigint; - /** - * Whether or not this application is currently deleted. - */ - deleted?: boolean; - /** - * Round when this application was deleted. - */ - deletedAtRound?: number | bigint; - /** - * Creates a new `Application` object. - * @param id - (appidx) application index. - * @param params - (appparams) application parameters. - * @param createdAtRound - Round when this application was created. - * @param deleted - Whether or not this application is currently deleted. - * @param deletedAtRound - Round when this application was deleted. - */ - constructor({ id, params, createdAtRound, deleted, deletedAtRound, }: { - id: number | bigint; - params: ApplicationParams; - createdAtRound?: number | bigint; - deleted?: boolean; - deletedAtRound?: number | bigint; - }); - static from_obj_for_encoding(data: Record): Application; -} -/** - * Stores local state associated with an application. - */ -export declare class ApplicationLocalState extends BaseModel { - /** - * The application which this local state is for. - */ - id: number | bigint; - /** - * (hsch) schema. - */ - schema: ApplicationStateSchema; - /** - * Round when account closed out of the application. - */ - closedOutAtRound?: number | bigint; - /** - * Whether or not the application local state is currently deleted from its - * account. - */ - deleted?: boolean; - /** - * (tkv) storage. - */ - keyValue?: TealKeyValue[]; - /** - * Round when the account opted into the application. - */ - optedInAtRound?: number | bigint; - /** - * Creates a new `ApplicationLocalState` object. - * @param id - The application which this local state is for. - * @param schema - (hsch) schema. - * @param closedOutAtRound - Round when account closed out of the application. - * @param deleted - Whether or not the application local state is currently deleted from its - * account. - * @param keyValue - (tkv) storage. - * @param optedInAtRound - Round when the account opted into the application. - */ - constructor({ id, schema, closedOutAtRound, deleted, keyValue, optedInAtRound, }: { - id: number | bigint; - schema: ApplicationStateSchema; - closedOutAtRound?: number | bigint; - deleted?: boolean; - keyValue?: TealKeyValue[]; - optedInAtRound?: number | bigint; - }); - static from_obj_for_encoding(data: Record): ApplicationLocalState; -} -/** - * - */ -export declare class ApplicationLocalStatesResponse extends BaseModel { - appsLocalStates: ApplicationLocalState[]; - /** - * Round at which the results were computed. - */ - currentRound: number | bigint; - /** - * Used for pagination, when making another request provide this token with the - * next parameter. - */ - nextToken?: string; - /** - * Creates a new `ApplicationLocalStatesResponse` object. - * @param appsLocalStates - - * @param currentRound - Round at which the results were computed. - * @param nextToken - Used for pagination, when making another request provide this token with the - * next parameter. - */ - constructor({ appsLocalStates, currentRound, nextToken, }: { - appsLocalStates: ApplicationLocalState[]; - currentRound: number | bigint; - nextToken?: string; - }); - static from_obj_for_encoding(data: Record): ApplicationLocalStatesResponse; -} -/** - * Stores the global information associated with an application. - */ -export declare class ApplicationLogData extends BaseModel { - /** - * (lg) Logs for the application being executed by the transaction. - */ - logs: Uint8Array[]; - /** - * Transaction ID - */ - txid: string; - /** - * Creates a new `ApplicationLogData` object. - * @param logs - (lg) Logs for the application being executed by the transaction. - * @param txid - Transaction ID - */ - constructor({ logs, txid }: { - logs: Uint8Array[]; - txid: string; - }); - static from_obj_for_encoding(data: Record): ApplicationLogData; -} -/** - * - */ -export declare class ApplicationLogsResponse extends BaseModel { - /** - * (appidx) application index. - */ - applicationId: number | bigint; - /** - * Round at which the results were computed. - */ - currentRound: number | bigint; - logData?: ApplicationLogData[]; - /** - * Used for pagination, when making another request provide this token with the - * next parameter. - */ - nextToken?: string; - /** - * Creates a new `ApplicationLogsResponse` object. - * @param applicationId - (appidx) application index. - * @param currentRound - Round at which the results were computed. - * @param logData - - * @param nextToken - Used for pagination, when making another request provide this token with the - * next parameter. - */ - constructor({ applicationId, currentRound, logData, nextToken, }: { - applicationId: number | bigint; - currentRound: number | bigint; - logData?: ApplicationLogData[]; - nextToken?: string; - }); - static from_obj_for_encoding(data: Record): ApplicationLogsResponse; -} -/** - * Stores the global information associated with an application. - */ -export declare class ApplicationParams extends BaseModel { - /** - * (approv) approval program. - */ - approvalProgram: Uint8Array; - /** - * (clearp) approval program. - */ - clearStateProgram: Uint8Array; - /** - * The address that created this application. This is the address where the - * parameters and global state for this application can be found. - */ - creator?: string; - /** - * (epp) the amount of extra program pages available to this app. - */ - extraProgramPages?: number | bigint; - /** - * [\gs) global schema - */ - globalState?: TealKeyValue[]; - /** - * [\gsch) global schema - */ - globalStateSchema?: ApplicationStateSchema; - /** - * [\lsch) local schema - */ - localStateSchema?: ApplicationStateSchema; - /** - * Creates a new `ApplicationParams` object. - * @param approvalProgram - (approv) approval program. - * @param clearStateProgram - (clearp) approval program. - * @param creator - The address that created this application. This is the address where the - * parameters and global state for this application can be found. - * @param extraProgramPages - (epp) the amount of extra program pages available to this app. - * @param globalState - [\gs) global schema - * @param globalStateSchema - [\gsch) global schema - * @param localStateSchema - [\lsch) local schema - */ - constructor({ approvalProgram, clearStateProgram, creator, extraProgramPages, globalState, globalStateSchema, localStateSchema, }: { - approvalProgram: string | Uint8Array; - clearStateProgram: string | Uint8Array; - creator?: string; - extraProgramPages?: number | bigint; - globalState?: TealKeyValue[]; - globalStateSchema?: ApplicationStateSchema; - localStateSchema?: ApplicationStateSchema; - }); - static from_obj_for_encoding(data: Record): ApplicationParams; -} -/** - * - */ -export declare class ApplicationResponse extends BaseModel { - /** - * Round at which the results were computed. - */ - currentRound: number | bigint; - /** - * Application index and its parameters - */ - application?: Application; - /** - * Creates a new `ApplicationResponse` object. - * @param currentRound - Round at which the results were computed. - * @param application - Application index and its parameters - */ - constructor({ currentRound, application, }: { - currentRound: number | bigint; - application?: Application; - }); - static from_obj_for_encoding(data: Record): ApplicationResponse; -} -/** - * Specifies maximums on the number of each type that may be stored. - */ -export declare class ApplicationStateSchema extends BaseModel { - /** - * (nbs) num of byte slices. - */ - numByteSlice: number | bigint; - /** - * (nui) num of uints. - */ - numUint: number | bigint; - /** - * Creates a new `ApplicationStateSchema` object. - * @param numByteSlice - (nbs) num of byte slices. - * @param numUint - (nui) num of uints. - */ - constructor({ numByteSlice, numUint, }: { - numByteSlice: number | bigint; - numUint: number | bigint; - }); - static from_obj_for_encoding(data: Record): ApplicationStateSchema; -} -/** - * - */ -export declare class ApplicationsResponse extends BaseModel { - applications: Application[]; - /** - * Round at which the results were computed. - */ - currentRound: number | bigint; - /** - * Used for pagination, when making another request provide this token with the - * next parameter. - */ - nextToken?: string; - /** - * Creates a new `ApplicationsResponse` object. - * @param applications - - * @param currentRound - Round at which the results were computed. - * @param nextToken - Used for pagination, when making another request provide this token with the - * next parameter. - */ - constructor({ applications, currentRound, nextToken, }: { - applications: Application[]; - currentRound: number | bigint; - nextToken?: string; - }); - static from_obj_for_encoding(data: Record): ApplicationsResponse; -} -/** - * Specifies both the unique identifier and the parameters for an asset - */ -export declare class Asset extends BaseModel { - /** - * unique asset identifier - */ - index: number | bigint; - /** - * AssetParams specifies the parameters for an asset. - * (apar) when part of an AssetConfig transaction. - * Definition: - * data/transactions/asset.go : AssetParams - */ - params: AssetParams; - /** - * Round during which this asset was created. - */ - createdAtRound?: number | bigint; - /** - * Whether or not this asset is currently deleted. - */ - deleted?: boolean; - /** - * Round during which this asset was destroyed. - */ - destroyedAtRound?: number | bigint; - /** - * Creates a new `Asset` object. - * @param index - unique asset identifier - * @param params - AssetParams specifies the parameters for an asset. - * (apar) when part of an AssetConfig transaction. - * Definition: - * data/transactions/asset.go : AssetParams - * @param createdAtRound - Round during which this asset was created. - * @param deleted - Whether or not this asset is currently deleted. - * @param destroyedAtRound - Round during which this asset was destroyed. - */ - constructor({ index, params, createdAtRound, deleted, destroyedAtRound, }: { - index: number | bigint; - params: AssetParams; - createdAtRound?: number | bigint; - deleted?: boolean; - destroyedAtRound?: number | bigint; - }); - static from_obj_for_encoding(data: Record): Asset; -} -/** - * - */ -export declare class AssetBalancesResponse extends BaseModel { - balances: MiniAssetHolding[]; - /** - * Round at which the results were computed. - */ - currentRound: number | bigint; - /** - * Used for pagination, when making another request provide this token with the - * next parameter. - */ - nextToken?: string; - /** - * Creates a new `AssetBalancesResponse` object. - * @param balances - - * @param currentRound - Round at which the results were computed. - * @param nextToken - Used for pagination, when making another request provide this token with the - * next parameter. - */ - constructor({ balances, currentRound, nextToken, }: { - balances: MiniAssetHolding[]; - currentRound: number | bigint; - nextToken?: string; - }); - static from_obj_for_encoding(data: Record): AssetBalancesResponse; -} -/** - * Describes an asset held by an account. - * Definition: - * data/basics/userBalance.go : AssetHolding - */ -export declare class AssetHolding extends BaseModel { - /** - * (a) number of units held. - */ - amount: number | bigint; - /** - * Asset ID of the holding. - */ - assetId: number | bigint; - /** - * (f) whether or not the holding is frozen. - */ - isFrozen: boolean; - /** - * Whether or not the asset holding is currently deleted from its account. - */ - deleted?: boolean; - /** - * Round during which the account opted into this asset holding. - */ - optedInAtRound?: number | bigint; - /** - * Round during which the account opted out of this asset holding. - */ - optedOutAtRound?: number | bigint; - /** - * Creates a new `AssetHolding` object. - * @param amount - (a) number of units held. - * @param assetId - Asset ID of the holding. - * @param isFrozen - (f) whether or not the holding is frozen. - * @param deleted - Whether or not the asset holding is currently deleted from its account. - * @param optedInAtRound - Round during which the account opted into this asset holding. - * @param optedOutAtRound - Round during which the account opted out of this asset holding. - */ - constructor({ amount, assetId, isFrozen, deleted, optedInAtRound, optedOutAtRound, }: { - amount: number | bigint; - assetId: number | bigint; - isFrozen: boolean; - deleted?: boolean; - optedInAtRound?: number | bigint; - optedOutAtRound?: number | bigint; - }); - static from_obj_for_encoding(data: Record): AssetHolding; -} -/** - * - */ -export declare class AssetHoldingsResponse extends BaseModel { - assets: AssetHolding[]; - /** - * Round at which the results were computed. - */ - currentRound: number | bigint; - /** - * Used for pagination, when making another request provide this token with the - * next parameter. - */ - nextToken?: string; - /** - * Creates a new `AssetHoldingsResponse` object. - * @param assets - - * @param currentRound - Round at which the results were computed. - * @param nextToken - Used for pagination, when making another request provide this token with the - * next parameter. - */ - constructor({ assets, currentRound, nextToken, }: { - assets: AssetHolding[]; - currentRound: number | bigint; - nextToken?: string; - }); - static from_obj_for_encoding(data: Record): AssetHoldingsResponse; -} -/** - * AssetParams specifies the parameters for an asset. - * (apar) when part of an AssetConfig transaction. - * Definition: - * data/transactions/asset.go : AssetParams - */ -export declare class AssetParams extends BaseModel { - /** - * The address that created this asset. This is the address where the parameters - * for this asset can be found, and also the address where unwanted asset units can - * be sent in the worst case. - */ - creator: string; - /** - * (dc) The number of digits to use after the decimal point when displaying this - * asset. If 0, the asset is not divisible. If 1, the base unit of the asset is in - * tenths. If 2, the base unit of the asset is in hundredths, and so on. This value - * must be between 0 and 19 (inclusive). - */ - decimals: number | bigint; - /** - * (t) The total number of units of this asset. - */ - total: number | bigint; - /** - * (c) Address of account used to clawback holdings of this asset. If empty, - * clawback is not permitted. - */ - clawback?: string; - /** - * (df) Whether holdings of this asset are frozen by default. - */ - defaultFrozen?: boolean; - /** - * (f) Address of account used to freeze holdings of this asset. If empty, freezing - * is not permitted. - */ - freeze?: string; - /** - * (m) Address of account used to manage the keys of this asset and to destroy it. - */ - manager?: string; - /** - * (am) A commitment to some unspecified asset metadata. The format of this - * metadata is up to the application. - */ - metadataHash?: Uint8Array; - /** - * (an) Name of this asset, as supplied by the creator. Included only when the - * asset name is composed of printable utf-8 characters. - */ - name?: string; - /** - * Base64 encoded name of this asset, as supplied by the creator. - */ - nameB64?: Uint8Array; - /** - * (r) Address of account holding reserve (non-minted) units of this asset. - */ - reserve?: string; - /** - * (un) Name of a unit of this asset, as supplied by the creator. Included only - * when the name of a unit of this asset is composed of printable utf-8 characters. - */ - unitName?: string; - /** - * Base64 encoded name of a unit of this asset, as supplied by the creator. - */ - unitNameB64?: Uint8Array; - /** - * (au) URL where more information about the asset can be retrieved. Included only - * when the URL is composed of printable utf-8 characters. - */ - url?: string; - /** - * Base64 encoded URL where more information about the asset can be retrieved. - */ - urlB64?: Uint8Array; - /** - * Creates a new `AssetParams` object. - * @param creator - The address that created this asset. This is the address where the parameters - * for this asset can be found, and also the address where unwanted asset units can - * be sent in the worst case. - * @param decimals - (dc) The number of digits to use after the decimal point when displaying this - * asset. If 0, the asset is not divisible. If 1, the base unit of the asset is in - * tenths. If 2, the base unit of the asset is in hundredths, and so on. This value - * must be between 0 and 19 (inclusive). - * @param total - (t) The total number of units of this asset. - * @param clawback - (c) Address of account used to clawback holdings of this asset. If empty, - * clawback is not permitted. - * @param defaultFrozen - (df) Whether holdings of this asset are frozen by default. - * @param freeze - (f) Address of account used to freeze holdings of this asset. If empty, freezing - * is not permitted. - * @param manager - (m) Address of account used to manage the keys of this asset and to destroy it. - * @param metadataHash - (am) A commitment to some unspecified asset metadata. The format of this - * metadata is up to the application. - * @param name - (an) Name of this asset, as supplied by the creator. Included only when the - * asset name is composed of printable utf-8 characters. - * @param nameB64 - Base64 encoded name of this asset, as supplied by the creator. - * @param reserve - (r) Address of account holding reserve (non-minted) units of this asset. - * @param unitName - (un) Name of a unit of this asset, as supplied by the creator. Included only - * when the name of a unit of this asset is composed of printable utf-8 characters. - * @param unitNameB64 - Base64 encoded name of a unit of this asset, as supplied by the creator. - * @param url - (au) URL where more information about the asset can be retrieved. Included only - * when the URL is composed of printable utf-8 characters. - * @param urlB64 - Base64 encoded URL where more information about the asset can be retrieved. - */ - constructor({ creator, decimals, total, clawback, defaultFrozen, freeze, manager, metadataHash, name, nameB64, reserve, unitName, unitNameB64, url, urlB64, }: { - creator: string; - decimals: number | bigint; - total: number | bigint; - clawback?: string; - defaultFrozen?: boolean; - freeze?: string; - manager?: string; - metadataHash?: string | Uint8Array; - name?: string; - nameB64?: string | Uint8Array; - reserve?: string; - unitName?: string; - unitNameB64?: string | Uint8Array; - url?: string; - urlB64?: string | Uint8Array; - }); - static from_obj_for_encoding(data: Record): AssetParams; -} -/** - * - */ -export declare class AssetResponse extends BaseModel { - /** - * Specifies both the unique identifier and the parameters for an asset - */ - asset: Asset; - /** - * Round at which the results were computed. - */ - currentRound: number | bigint; - /** - * Creates a new `AssetResponse` object. - * @param asset - Specifies both the unique identifier and the parameters for an asset - * @param currentRound - Round at which the results were computed. - */ - constructor({ asset, currentRound, }: { - asset: Asset; - currentRound: number | bigint; - }); - static from_obj_for_encoding(data: Record): AssetResponse; -} -/** - * - */ -export declare class AssetsResponse extends BaseModel { - assets: Asset[]; - /** - * Round at which the results were computed. - */ - currentRound: number | bigint; - /** - * Used for pagination, when making another request provide this token with the - * next parameter. - */ - nextToken?: string; - /** - * Creates a new `AssetsResponse` object. - * @param assets - - * @param currentRound - Round at which the results were computed. - * @param nextToken - Used for pagination, when making another request provide this token with the - * next parameter. - */ - constructor({ assets, currentRound, nextToken, }: { - assets: Asset[]; - currentRound: number | bigint; - nextToken?: string; - }); - static from_obj_for_encoding(data: Record): AssetsResponse; -} -/** - * Block information. - * Definition: - * data/bookkeeping/block.go : Block - */ -export declare class Block extends BaseModel { - /** - * (gh) hash to which this block belongs. - */ - genesisHash: Uint8Array; - /** - * (gen) ID to which this block belongs. - */ - genesisId: string; - /** - * (prev) Previous block hash. - */ - previousBlockHash: Uint8Array; - /** - * (rnd) Current round on which this block was appended to the chain. - */ - round: number | bigint; - /** - * (seed) Sortition seed. - */ - seed: Uint8Array; - /** - * (ts) Block creation timestamp in seconds since eposh - */ - timestamp: number | bigint; - /** - * (txn) TransactionsRoot authenticates the set of transactions appearing in the - * block. More specifically, it's the root of a merkle tree whose leaves are the - * block's Txids, in lexicographic order. For the empty block, it's 0. Note that - * the TxnRoot does not authenticate the signatures on the transactions, only the - * transactions themselves. Two blocks with the same transactions but in a - * different order and with different signatures will have the same TxnRoot. - */ - transactionsRoot: Uint8Array; - /** - * (txn256) TransactionsRootSHA256 is an auxiliary TransactionRoot, built using a - * vector commitment instead of a merkle tree, and SHA256 hash function instead of - * the default SHA512_256. This commitment can be used on environments where only - * the SHA256 function exists. - */ - transactionsRootSha256: Uint8Array; - /** - * Participation account data that needs to be checked/acted on by the network. - */ - participationUpdates?: ParticipationUpdates; - /** - * Fields relating to rewards, - */ - rewards?: BlockRewards; - /** - * Tracks the status of state proofs. - */ - stateProofTracking?: StateProofTracking[]; - /** - * (txns) list of transactions corresponding to a given round. - */ - transactions?: Transaction[]; - /** - * (tc) TxnCounter counts the number of transactions committed in the ledger, from - * the time at which support for this feature was introduced. - * Specifically, TxnCounter is the number of the next transaction that will be - * committed after this block. It is 0 when no transactions have ever been - * committed (since TxnCounter started being supported). - */ - txnCounter?: number | bigint; - /** - * Fields relating to a protocol upgrade. - */ - upgradeState?: BlockUpgradeState; - /** - * Fields relating to voting for a protocol upgrade. - */ - upgradeVote?: BlockUpgradeVote; - /** - * Creates a new `Block` object. - * @param genesisHash - (gh) hash to which this block belongs. - * @param genesisId - (gen) ID to which this block belongs. - * @param previousBlockHash - (prev) Previous block hash. - * @param round - (rnd) Current round on which this block was appended to the chain. - * @param seed - (seed) Sortition seed. - * @param timestamp - (ts) Block creation timestamp in seconds since eposh - * @param transactionsRoot - (txn) TransactionsRoot authenticates the set of transactions appearing in the - * block. More specifically, it's the root of a merkle tree whose leaves are the - * block's Txids, in lexicographic order. For the empty block, it's 0. Note that - * the TxnRoot does not authenticate the signatures on the transactions, only the - * transactions themselves. Two blocks with the same transactions but in a - * different order and with different signatures will have the same TxnRoot. - * @param transactionsRootSha256 - (txn256) TransactionsRootSHA256 is an auxiliary TransactionRoot, built using a - * vector commitment instead of a merkle tree, and SHA256 hash function instead of - * the default SHA512_256. This commitment can be used on environments where only - * the SHA256 function exists. - * @param participationUpdates - Participation account data that needs to be checked/acted on by the network. - * @param rewards - Fields relating to rewards, - * @param stateProofTracking - Tracks the status of state proofs. - * @param transactions - (txns) list of transactions corresponding to a given round. - * @param txnCounter - (tc) TxnCounter counts the number of transactions committed in the ledger, from - * the time at which support for this feature was introduced. - * Specifically, TxnCounter is the number of the next transaction that will be - * committed after this block. It is 0 when no transactions have ever been - * committed (since TxnCounter started being supported). - * @param upgradeState - Fields relating to a protocol upgrade. - * @param upgradeVote - Fields relating to voting for a protocol upgrade. - */ - constructor({ genesisHash, genesisId, previousBlockHash, round, seed, timestamp, transactionsRoot, transactionsRootSha256, participationUpdates, rewards, stateProofTracking, transactions, txnCounter, upgradeState, upgradeVote, }: { - genesisHash: string | Uint8Array; - genesisId: string; - previousBlockHash: string | Uint8Array; - round: number | bigint; - seed: string | Uint8Array; - timestamp: number | bigint; - transactionsRoot: string | Uint8Array; - transactionsRootSha256: string | Uint8Array; - participationUpdates?: ParticipationUpdates; - rewards?: BlockRewards; - stateProofTracking?: StateProofTracking[]; - transactions?: Transaction[]; - txnCounter?: number | bigint; - upgradeState?: BlockUpgradeState; - upgradeVote?: BlockUpgradeVote; - }); - static from_obj_for_encoding(data: Record): Block; -} -/** - * Fields relating to rewards, - */ -export declare class BlockRewards extends BaseModel { - /** - * (fees) accepts transaction fees, it can only spend to the incentive pool. - */ - feeSink: string; - /** - * (rwcalr) number of leftover MicroAlgos after the distribution of rewards-rate - * MicroAlgos for every reward unit in the next round. - */ - rewardsCalculationRound: number | bigint; - /** - * (earn) How many rewards, in MicroAlgos, have been distributed to each RewardUnit - * of MicroAlgos since genesis. - */ - rewardsLevel: number | bigint; - /** - * (rwd) accepts periodic injections from the fee-sink and continually - * redistributes them as rewards. - */ - rewardsPool: string; - /** - * (rate) Number of new MicroAlgos added to the participation stake from rewards at - * the next round. - */ - rewardsRate: number | bigint; - /** - * (frac) Number of leftover MicroAlgos after the distribution of - * RewardsRate/rewardUnits MicroAlgos for every reward unit in the next round. - */ - rewardsResidue: number | bigint; - /** - * Creates a new `BlockRewards` object. - * @param feeSink - (fees) accepts transaction fees, it can only spend to the incentive pool. - * @param rewardsCalculationRound - (rwcalr) number of leftover MicroAlgos after the distribution of rewards-rate - * MicroAlgos for every reward unit in the next round. - * @param rewardsLevel - (earn) How many rewards, in MicroAlgos, have been distributed to each RewardUnit - * of MicroAlgos since genesis. - * @param rewardsPool - (rwd) accepts periodic injections from the fee-sink and continually - * redistributes them as rewards. - * @param rewardsRate - (rate) Number of new MicroAlgos added to the participation stake from rewards at - * the next round. - * @param rewardsResidue - (frac) Number of leftover MicroAlgos after the distribution of - * RewardsRate/rewardUnits MicroAlgos for every reward unit in the next round. - */ - constructor({ feeSink, rewardsCalculationRound, rewardsLevel, rewardsPool, rewardsRate, rewardsResidue, }: { - feeSink: string; - rewardsCalculationRound: number | bigint; - rewardsLevel: number | bigint; - rewardsPool: string; - rewardsRate: number | bigint; - rewardsResidue: number | bigint; - }); - static from_obj_for_encoding(data: Record): BlockRewards; -} -/** - * Fields relating to a protocol upgrade. - */ -export declare class BlockUpgradeState extends BaseModel { - /** - * (proto) The current protocol version. - */ - currentProtocol: string; - /** - * (nextproto) The next proposed protocol version. - */ - nextProtocol?: string; - /** - * (nextyes) Number of blocks which approved the protocol upgrade. - */ - nextProtocolApprovals?: number | bigint; - /** - * (nextswitch) Round on which the protocol upgrade will take effect. - */ - nextProtocolSwitchOn?: number | bigint; - /** - * (nextbefore) Deadline round for this protocol upgrade (No votes will be consider - * after this round). - */ - nextProtocolVoteBefore?: number | bigint; - /** - * Creates a new `BlockUpgradeState` object. - * @param currentProtocol - (proto) The current protocol version. - * @param nextProtocol - (nextproto) The next proposed protocol version. - * @param nextProtocolApprovals - (nextyes) Number of blocks which approved the protocol upgrade. - * @param nextProtocolSwitchOn - (nextswitch) Round on which the protocol upgrade will take effect. - * @param nextProtocolVoteBefore - (nextbefore) Deadline round for this protocol upgrade (No votes will be consider - * after this round). - */ - constructor({ currentProtocol, nextProtocol, nextProtocolApprovals, nextProtocolSwitchOn, nextProtocolVoteBefore, }: { - currentProtocol: string; - nextProtocol?: string; - nextProtocolApprovals?: number | bigint; - nextProtocolSwitchOn?: number | bigint; - nextProtocolVoteBefore?: number | bigint; - }); - static from_obj_for_encoding(data: Record): BlockUpgradeState; -} -/** - * Fields relating to voting for a protocol upgrade. - */ -export declare class BlockUpgradeVote extends BaseModel { - /** - * (upgradeyes) Indicates a yes vote for the current proposal. - */ - upgradeApprove?: boolean; - /** - * (upgradedelay) Indicates the time between acceptance and execution. - */ - upgradeDelay?: number | bigint; - /** - * (upgradeprop) Indicates a proposed upgrade. - */ - upgradePropose?: string; - /** - * Creates a new `BlockUpgradeVote` object. - * @param upgradeApprove - (upgradeyes) Indicates a yes vote for the current proposal. - * @param upgradeDelay - (upgradedelay) Indicates the time between acceptance and execution. - * @param upgradePropose - (upgradeprop) Indicates a proposed upgrade. - */ - constructor({ upgradeApprove, upgradeDelay, upgradePropose, }: { - upgradeApprove?: boolean; - upgradeDelay?: number | bigint; - upgradePropose?: string; - }); - static from_obj_for_encoding(data: Record): BlockUpgradeVote; -} -/** - * Box name and its content. - */ -export declare class Box extends BaseModel { - /** - * (name) box name, base64 encoded - */ - name: Uint8Array; - /** - * The round for which this information is relevant - */ - round: number | bigint; - /** - * (value) box value, base64 encoded. - */ - value: Uint8Array; - /** - * Creates a new `Box` object. - * @param name - (name) box name, base64 encoded - * @param round - The round for which this information is relevant - * @param value - (value) box value, base64 encoded. - */ - constructor({ name, round, value, }: { - name: string | Uint8Array; - round: number | bigint; - value: string | Uint8Array; - }); - static from_obj_for_encoding(data: Record): Box; -} -/** - * Box descriptor describes an app box without a value. - */ -export declare class BoxDescriptor extends BaseModel { - /** - * Base64 encoded box name - */ - name: Uint8Array; - /** - * Creates a new `BoxDescriptor` object. - * @param name - Base64 encoded box name - */ - constructor({ name }: { - name: string | Uint8Array; - }); - static from_obj_for_encoding(data: Record): BoxDescriptor; -} -/** - * Box names of an application - */ -export declare class BoxesResponse extends BaseModel { - /** - * (appidx) application index. - */ - applicationId: number | bigint; - boxes: BoxDescriptor[]; - /** - * Used for pagination, when making another request provide this token with the - * next parameter. - */ - nextToken?: string; - /** - * Creates a new `BoxesResponse` object. - * @param applicationId - (appidx) application index. - * @param boxes - - * @param nextToken - Used for pagination, when making another request provide this token with the - * next parameter. - */ - constructor({ applicationId, boxes, nextToken, }: { - applicationId: number | bigint; - boxes: BoxDescriptor[]; - nextToken?: string; - }); - static from_obj_for_encoding(data: Record): BoxesResponse; -} -/** - * Response for errors - */ -export declare class ErrorResponse extends BaseModel { - message: string; - data?: Record; - /** - * Creates a new `ErrorResponse` object. - * @param message - - * @param data - - */ - constructor({ message, data, }: { - message: string; - data?: Record; - }); - static from_obj_for_encoding(data: Record): ErrorResponse; -} -/** - * Represents a TEAL value delta. - */ -export declare class EvalDelta extends BaseModel { - /** - * (at) delta action. - */ - action: number | bigint; - /** - * (bs) bytes value. - */ - bytes?: string; - /** - * (ui) uint value. - */ - uint?: number | bigint; - /** - * Creates a new `EvalDelta` object. - * @param action - (at) delta action. - * @param bytes - (bs) bytes value. - * @param uint - (ui) uint value. - */ - constructor({ action, bytes, uint, }: { - action: number | bigint; - bytes?: string; - uint?: number | bigint; - }); - static from_obj_for_encoding(data: Record): EvalDelta; -} -/** - * Key-value pairs for StateDelta. - */ -export declare class EvalDeltaKeyValue extends BaseModel { - key: string; - /** - * Represents a TEAL value delta. - */ - value: EvalDelta; - /** - * Creates a new `EvalDeltaKeyValue` object. - * @param key - - * @param value - Represents a TEAL value delta. - */ - constructor({ key, value }: { - key: string; - value: EvalDelta; - }); - static from_obj_for_encoding(data: Record): EvalDeltaKeyValue; -} -export declare class HashFactory extends BaseModel { - /** - * (t) - */ - hashType?: number | bigint; - /** - * Creates a new `HashFactory` object. - * @param hashType - (t) - */ - constructor({ hashType }: { - hashType?: number | bigint; - }); - static from_obj_for_encoding(data: Record): HashFactory; -} -/** - * A health check response. - */ -export declare class HealthCheck extends BaseModel { - dbAvailable: boolean; - isMigrating: boolean; - message: string; - round: number | bigint; - /** - * Current version. - */ - version: string; - data?: Record; - errors?: string[]; - /** - * Creates a new `HealthCheck` object. - * @param dbAvailable - - * @param isMigrating - - * @param message - - * @param round - - * @param version - Current version. - * @param data - - * @param errors - - */ - constructor({ dbAvailable, isMigrating, message, round, version, data, errors, }: { - dbAvailable: boolean; - isMigrating: boolean; - message: string; - round: number | bigint; - version: string; - data?: Record; - errors?: string[]; - }); - static from_obj_for_encoding(data: Record): HealthCheck; -} -export declare class IndexerStateProofMessage extends BaseModel { - /** - * (b) - */ - blockHeadersCommitment?: Uint8Array; - /** - * (f) - */ - firstAttestedRound?: number | bigint; - /** - * (l) - */ - latestAttestedRound?: number | bigint; - /** - * (P) - */ - lnProvenWeight?: number | bigint; - /** - * (v) - */ - votersCommitment?: Uint8Array; - /** - * Creates a new `IndexerStateProofMessage` object. - * @param blockHeadersCommitment - (b) - * @param firstAttestedRound - (f) - * @param latestAttestedRound - (l) - * @param lnProvenWeight - (P) - * @param votersCommitment - (v) - */ - constructor({ blockHeadersCommitment, firstAttestedRound, latestAttestedRound, lnProvenWeight, votersCommitment, }: { - blockHeadersCommitment?: string | Uint8Array; - firstAttestedRound?: number | bigint; - latestAttestedRound?: number | bigint; - lnProvenWeight?: number | bigint; - votersCommitment?: string | Uint8Array; - }); - static from_obj_for_encoding(data: Record): IndexerStateProofMessage; -} -export declare class MerkleArrayProof extends BaseModel { - hashFactory?: HashFactory; - /** - * (pth) - */ - path?: Uint8Array[]; - /** - * (td) - */ - treeDepth?: number | bigint; - /** - * Creates a new `MerkleArrayProof` object. - * @param hashFactory - - * @param path - (pth) - * @param treeDepth - (td) - */ - constructor({ hashFactory, path, treeDepth, }: { - hashFactory?: HashFactory; - path?: Uint8Array[]; - treeDepth?: number | bigint; - }); - static from_obj_for_encoding(data: Record): MerkleArrayProof; -} -/** - * A simplified version of AssetHolding - */ -export declare class MiniAssetHolding extends BaseModel { - address: string; - amount: number | bigint; - isFrozen: boolean; - /** - * Whether or not this asset holding is currently deleted from its account. - */ - deleted?: boolean; - /** - * Round during which the account opted into the asset. - */ - optedInAtRound?: number | bigint; - /** - * Round during which the account opted out of the asset. - */ - optedOutAtRound?: number | bigint; - /** - * Creates a new `MiniAssetHolding` object. - * @param address - - * @param amount - - * @param isFrozen - - * @param deleted - Whether or not this asset holding is currently deleted from its account. - * @param optedInAtRound - Round during which the account opted into the asset. - * @param optedOutAtRound - Round during which the account opted out of the asset. - */ - constructor({ address, amount, isFrozen, deleted, optedInAtRound, optedOutAtRound, }: { - address: string; - amount: number | bigint; - isFrozen: boolean; - deleted?: boolean; - optedInAtRound?: number | bigint; - optedOutAtRound?: number | bigint; - }); - static from_obj_for_encoding(data: Record): MiniAssetHolding; -} -/** - * Participation account data that needs to be checked/acted on by the network. - */ -export declare class ParticipationUpdates extends BaseModel { - /** - * (partupdrmv) a list of online accounts that needs to be converted to offline - * since their participation key expired. - */ - expiredParticipationAccounts?: string[]; - /** - * Creates a new `ParticipationUpdates` object. - * @param expiredParticipationAccounts - (partupdrmv) a list of online accounts that needs to be converted to offline - * since their participation key expired. - */ - constructor({ expiredParticipationAccounts, }: { - expiredParticipationAccounts?: string[]; - }); - static from_obj_for_encoding(data: Record): ParticipationUpdates; -} -/** - * (sp) represents a state proof. - * Definition: - * crypto/stateproof/structs.go : StateProof - */ -export declare class StateProofFields extends BaseModel { - /** - * (P) - */ - partProofs?: MerkleArrayProof; - /** - * (pr) Sequence of reveal positions. - */ - positionsToReveal?: (number | bigint)[]; - /** - * (r) Note that this is actually stored as a map[uint64] - Reveal in the actual - * msgp - */ - reveals?: StateProofReveal[]; - /** - * (v) Salt version of the merkle signature. - */ - saltVersion?: number | bigint; - /** - * (c) - */ - sigCommit?: Uint8Array; - /** - * (S) - */ - sigProofs?: MerkleArrayProof; - /** - * (w) - */ - signedWeight?: number | bigint; - /** - * Creates a new `StateProofFields` object. - * @param partProofs - (P) - * @param positionsToReveal - (pr) Sequence of reveal positions. - * @param reveals - (r) Note that this is actually stored as a map[uint64] - Reveal in the actual - * msgp - * @param saltVersion - (v) Salt version of the merkle signature. - * @param sigCommit - (c) - * @param sigProofs - (S) - * @param signedWeight - (w) - */ - constructor({ partProofs, positionsToReveal, reveals, saltVersion, sigCommit, sigProofs, signedWeight, }: { - partProofs?: MerkleArrayProof; - positionsToReveal?: (number | bigint)[]; - reveals?: StateProofReveal[]; - saltVersion?: number | bigint; - sigCommit?: string | Uint8Array; - sigProofs?: MerkleArrayProof; - signedWeight?: number | bigint; - }); - static from_obj_for_encoding(data: Record): StateProofFields; -} -export declare class StateProofParticipant extends BaseModel { - /** - * (p) - */ - verifier?: StateProofVerifier; - /** - * (w) - */ - weight?: number | bigint; - /** - * Creates a new `StateProofParticipant` object. - * @param verifier - (p) - * @param weight - (w) - */ - constructor({ verifier, weight, }: { - verifier?: StateProofVerifier; - weight?: number | bigint; - }); - static from_obj_for_encoding(data: Record): StateProofParticipant; -} -export declare class StateProofReveal extends BaseModel { - /** - * (p) - */ - participant?: StateProofParticipant; - /** - * The position in the signature and participants arrays corresponding to this - * entry. - */ - position?: number | bigint; - /** - * (s) - */ - sigSlot?: StateProofSigSlot; - /** - * Creates a new `StateProofReveal` object. - * @param participant - (p) - * @param position - The position in the signature and participants arrays corresponding to this - * entry. - * @param sigSlot - (s) - */ - constructor({ participant, position, sigSlot, }: { - participant?: StateProofParticipant; - position?: number | bigint; - sigSlot?: StateProofSigSlot; - }); - static from_obj_for_encoding(data: Record): StateProofReveal; -} -export declare class StateProofSigSlot extends BaseModel { - /** - * (l) The total weight of signatures in the lower-numbered slots. - */ - lowerSigWeight?: number | bigint; - signature?: StateProofSignature; - /** - * Creates a new `StateProofSigSlot` object. - * @param lowerSigWeight - (l) The total weight of signatures in the lower-numbered slots. - * @param signature - - */ - constructor({ lowerSigWeight, signature, }: { - lowerSigWeight?: number | bigint; - signature?: StateProofSignature; - }); - static from_obj_for_encoding(data: Record): StateProofSigSlot; -} -export declare class StateProofSignature extends BaseModel { - falconSignature?: Uint8Array; - merkleArrayIndex?: number | bigint; - proof?: MerkleArrayProof; - /** - * (vkey) - */ - verifyingKey?: Uint8Array; - /** - * Creates a new `StateProofSignature` object. - * @param falconSignature - - * @param merkleArrayIndex - - * @param proof - - * @param verifyingKey - (vkey) - */ - constructor({ falconSignature, merkleArrayIndex, proof, verifyingKey, }: { - falconSignature?: string | Uint8Array; - merkleArrayIndex?: number | bigint; - proof?: MerkleArrayProof; - verifyingKey?: string | Uint8Array; - }); - static from_obj_for_encoding(data: Record): StateProofSignature; -} -export declare class StateProofTracking extends BaseModel { - /** - * (n) Next round for which we will accept a state proof transaction. - */ - nextRound?: number | bigint; - /** - * (t) The total number of microalgos held by the online accounts during the - * StateProof round. - */ - onlineTotalWeight?: number | bigint; - /** - * State Proof Type. Note the raw object uses map with this as key. - */ - type?: number | bigint; - /** - * (v) Root of a vector commitment containing online accounts that will help sign - * the proof. - */ - votersCommitment?: Uint8Array; - /** - * Creates a new `StateProofTracking` object. - * @param nextRound - (n) Next round for which we will accept a state proof transaction. - * @param onlineTotalWeight - (t) The total number of microalgos held by the online accounts during the - * StateProof round. - * @param type - State Proof Type. Note the raw object uses map with this as key. - * @param votersCommitment - (v) Root of a vector commitment containing online accounts that will help sign - * the proof. - */ - constructor({ nextRound, onlineTotalWeight, type, votersCommitment, }: { - nextRound?: number | bigint; - onlineTotalWeight?: number | bigint; - type?: number | bigint; - votersCommitment?: string | Uint8Array; - }); - static from_obj_for_encoding(data: Record): StateProofTracking; -} -export declare class StateProofVerifier extends BaseModel { - /** - * (cmt) Represents the root of the vector commitment tree. - */ - commitment?: Uint8Array; - /** - * (lf) Key lifetime. - */ - keyLifetime?: number | bigint; - /** - * Creates a new `StateProofVerifier` object. - * @param commitment - (cmt) Represents the root of the vector commitment tree. - * @param keyLifetime - (lf) Key lifetime. - */ - constructor({ commitment, keyLifetime, }: { - commitment?: string | Uint8Array; - keyLifetime?: number | bigint; - }); - static from_obj_for_encoding(data: Record): StateProofVerifier; -} -/** - * Represents a (apls) local-state or (apgs) global-state schema. These schemas - * determine how much storage may be used in a local-state or global-state for an - * application. The more space used, the larger minimum balance must be maintained - * in the account holding the data. - */ -export declare class StateSchema extends BaseModel { - /** - * Maximum number of TEAL byte slices that may be stored in the key/value store. - */ - numByteSlice: number | bigint; - /** - * Maximum number of TEAL uints that may be stored in the key/value store. - */ - numUint: number | bigint; - /** - * Creates a new `StateSchema` object. - * @param numByteSlice - Maximum number of TEAL byte slices that may be stored in the key/value store. - * @param numUint - Maximum number of TEAL uints that may be stored in the key/value store. - */ - constructor({ numByteSlice, numUint, }: { - numByteSlice: number | bigint; - numUint: number | bigint; - }); - static from_obj_for_encoding(data: Record): StateSchema; -} -/** - * Represents a key-value pair in an application store. - */ -export declare class TealKeyValue extends BaseModel { - key: string; - /** - * Represents a TEAL value. - */ - value: TealValue; - /** - * Creates a new `TealKeyValue` object. - * @param key - - * @param value - Represents a TEAL value. - */ - constructor({ key, value }: { - key: string; - value: TealValue; - }); - static from_obj_for_encoding(data: Record): TealKeyValue; -} -/** - * Represents a TEAL value. - */ -export declare class TealValue extends BaseModel { - /** - * (tb) bytes value. - */ - bytes: string; - /** - * (tt) value type. Value `1` refers to **bytes**, value `2` refers to **uint** - */ - type: number | bigint; - /** - * (ui) uint value. - */ - uint: number | bigint; - /** - * Creates a new `TealValue` object. - * @param bytes - (tb) bytes value. - * @param type - (tt) value type. Value `1` refers to **bytes**, value `2` refers to **uint** - * @param uint - (ui) uint value. - */ - constructor({ bytes, type, uint, }: { - bytes: string; - type: number | bigint; - uint: number | bigint; - }); - static from_obj_for_encoding(data: Record): TealValue; -} -/** - * Contains all fields common to all transactions and serves as an envelope to all - * transactions type. Represents both regular and inner transactions. - * Definition: - * data/transactions/signedtxn.go : SignedTxn - * data/transactions/transaction.go : Transaction - */ -export declare class Transaction extends BaseModel { - /** - * (fee) Transaction fee. - */ - fee: number | bigint; - /** - * (fv) First valid round for this transaction. - */ - firstValid: number | bigint; - /** - * (lv) Last valid round for this transaction. - */ - lastValid: number | bigint; - /** - * (snd) Sender's address. - */ - sender: string; - /** - * Fields for application transactions. - * Definition: - * data/transactions/application.go : ApplicationCallTxnFields - */ - applicationTransaction?: TransactionApplication; - /** - * Fields for asset allocation, re-configuration, and destruction. - * A zero value for asset-id indicates asset creation. - * A zero value for the params indicates asset destruction. - * Definition: - * data/transactions/asset.go : AssetConfigTxnFields - */ - assetConfigTransaction?: TransactionAssetConfig; - /** - * Fields for an asset freeze transaction. - * Definition: - * data/transactions/asset.go : AssetFreezeTxnFields - */ - assetFreezeTransaction?: TransactionAssetFreeze; - /** - * Fields for an asset transfer transaction. - * Definition: - * data/transactions/asset.go : AssetTransferTxnFields - */ - assetTransferTransaction?: TransactionAssetTransfer; - /** - * (sgnr) this is included with signed transactions when the signing address does - * not equal the sender. The backend can use this to ensure that auth addr is equal - * to the accounts auth addr. - */ - authAddr?: string; - /** - * (rc) rewards applied to close-remainder-to account. - */ - closeRewards?: number | bigint; - /** - * (ca) closing amount for transaction. - */ - closingAmount?: number | bigint; - /** - * Round when the transaction was confirmed. - */ - confirmedRound?: number | bigint; - /** - * Specifies an application index (ID) if an application was created with this - * transaction. - */ - createdApplicationIndex?: number | bigint; - /** - * Specifies an asset index (ID) if an asset was created with this transaction. - */ - createdAssetIndex?: number | bigint; - /** - * (gh) Hash of genesis block. - */ - genesisHash?: Uint8Array; - /** - * (gen) genesis block ID. - */ - genesisId?: string; - /** - * (gd) Global state key/value changes for the application being executed by this - * transaction. - */ - globalStateDelta?: EvalDeltaKeyValue[]; - /** - * (grp) Base64 encoded byte array of a sha512/256 digest. When present indicates - * that this transaction is part of a transaction group and the value is the - * sha512/256 hash of the transactions in that group. - */ - group?: Uint8Array; - /** - * Transaction ID - */ - id?: string; - /** - * Inner transactions produced by application execution. - */ - innerTxns?: Transaction[]; - /** - * Offset into the round where this transaction was confirmed. - */ - intraRoundOffset?: number | bigint; - /** - * Fields for a keyreg transaction. - * Definition: - * data/transactions/keyreg.go : KeyregTxnFields - */ - keyregTransaction?: TransactionKeyreg; - /** - * (lx) Base64 encoded 32-byte array. Lease enforces mutual exclusion of - * transactions. If this field is nonzero, then once the transaction is confirmed, - * it acquires the lease identified by the (Sender, Lease) pair of the transaction - * until the LastValid round passes. While this transaction possesses the lease, no - * other transaction specifying this lease can be confirmed. - */ - lease?: Uint8Array; - /** - * (ld) Local state key/value changes for the application being executed by this - * transaction. - */ - localStateDelta?: AccountStateDelta[]; - /** - * (lg) Logs for the application being executed by this transaction. - */ - logs?: Uint8Array[]; - /** - * (note) Free form data. - */ - note?: Uint8Array; - /** - * Fields for a payment transaction. - * Definition: - * data/transactions/payment.go : PaymentTxnFields - */ - paymentTransaction?: TransactionPayment; - /** - * (rr) rewards applied to receiver account. - */ - receiverRewards?: number | bigint; - /** - * (rekey) when included in a valid transaction, the accounts auth addr will be - * updated with this value and future signatures must be signed with the key - * represented by this address. - */ - rekeyTo?: string; - /** - * Time when the block this transaction is in was confirmed. - */ - roundTime?: number | bigint; - /** - * (rs) rewards applied to sender account. - */ - senderRewards?: number | bigint; - /** - * Validation signature associated with some data. Only one of the signatures - * should be provided. - */ - signature?: TransactionSignature; - /** - * Fields for a state proof transaction. - * Definition: - * data/transactions/stateproof.go : StateProofTxnFields - */ - stateProofTransaction?: TransactionStateProof; - /** - * (type) Indicates what type of transaction this is. Different types have - * different fields. - * Valid types, and where their fields are stored: - * * (pay) payment-transaction - * * (keyreg) keyreg-transaction - * * (acfg) asset-config-transaction - * * (axfer) asset-transfer-transaction - * * (afrz) asset-freeze-transaction - * * (appl) application-transaction - * * (stpf) state-proof-transaction - */ - txType?: string; - /** - * Creates a new `Transaction` object. - * @param fee - (fee) Transaction fee. - * @param firstValid - (fv) First valid round for this transaction. - * @param lastValid - (lv) Last valid round for this transaction. - * @param sender - (snd) Sender's address. - * @param applicationTransaction - Fields for application transactions. - * Definition: - * data/transactions/application.go : ApplicationCallTxnFields - * @param assetConfigTransaction - Fields for asset allocation, re-configuration, and destruction. - * A zero value for asset-id indicates asset creation. - * A zero value for the params indicates asset destruction. - * Definition: - * data/transactions/asset.go : AssetConfigTxnFields - * @param assetFreezeTransaction - Fields for an asset freeze transaction. - * Definition: - * data/transactions/asset.go : AssetFreezeTxnFields - * @param assetTransferTransaction - Fields for an asset transfer transaction. - * Definition: - * data/transactions/asset.go : AssetTransferTxnFields - * @param authAddr - (sgnr) this is included with signed transactions when the signing address does - * not equal the sender. The backend can use this to ensure that auth addr is equal - * to the accounts auth addr. - * @param closeRewards - (rc) rewards applied to close-remainder-to account. - * @param closingAmount - (ca) closing amount for transaction. - * @param confirmedRound - Round when the transaction was confirmed. - * @param createdApplicationIndex - Specifies an application index (ID) if an application was created with this - * transaction. - * @param createdAssetIndex - Specifies an asset index (ID) if an asset was created with this transaction. - * @param genesisHash - (gh) Hash of genesis block. - * @param genesisId - (gen) genesis block ID. - * @param globalStateDelta - (gd) Global state key/value changes for the application being executed by this - * transaction. - * @param group - (grp) Base64 encoded byte array of a sha512/256 digest. When present indicates - * that this transaction is part of a transaction group and the value is the - * sha512/256 hash of the transactions in that group. - * @param id - Transaction ID - * @param innerTxns - Inner transactions produced by application execution. - * @param intraRoundOffset - Offset into the round where this transaction was confirmed. - * @param keyregTransaction - Fields for a keyreg transaction. - * Definition: - * data/transactions/keyreg.go : KeyregTxnFields - * @param lease - (lx) Base64 encoded 32-byte array. Lease enforces mutual exclusion of - * transactions. If this field is nonzero, then once the transaction is confirmed, - * it acquires the lease identified by the (Sender, Lease) pair of the transaction - * until the LastValid round passes. While this transaction possesses the lease, no - * other transaction specifying this lease can be confirmed. - * @param localStateDelta - (ld) Local state key/value changes for the application being executed by this - * transaction. - * @param logs - (lg) Logs for the application being executed by this transaction. - * @param note - (note) Free form data. - * @param paymentTransaction - Fields for a payment transaction. - * Definition: - * data/transactions/payment.go : PaymentTxnFields - * @param receiverRewards - (rr) rewards applied to receiver account. - * @param rekeyTo - (rekey) when included in a valid transaction, the accounts auth addr will be - * updated with this value and future signatures must be signed with the key - * represented by this address. - * @param roundTime - Time when the block this transaction is in was confirmed. - * @param senderRewards - (rs) rewards applied to sender account. - * @param signature - Validation signature associated with some data. Only one of the signatures - * should be provided. - * @param stateProofTransaction - Fields for a state proof transaction. - * Definition: - * data/transactions/stateproof.go : StateProofTxnFields - * @param txType - (type) Indicates what type of transaction this is. Different types have - * different fields. - * Valid types, and where their fields are stored: - * * (pay) payment-transaction - * * (keyreg) keyreg-transaction - * * (acfg) asset-config-transaction - * * (axfer) asset-transfer-transaction - * * (afrz) asset-freeze-transaction - * * (appl) application-transaction - * * (stpf) state-proof-transaction - */ - constructor({ fee, firstValid, lastValid, sender, applicationTransaction, assetConfigTransaction, assetFreezeTransaction, assetTransferTransaction, authAddr, closeRewards, closingAmount, confirmedRound, createdApplicationIndex, createdAssetIndex, genesisHash, genesisId, globalStateDelta, group, id, innerTxns, intraRoundOffset, keyregTransaction, lease, localStateDelta, logs, note, paymentTransaction, receiverRewards, rekeyTo, roundTime, senderRewards, signature, stateProofTransaction, txType, }: { - fee: number | bigint; - firstValid: number | bigint; - lastValid: number | bigint; - sender: string; - applicationTransaction?: TransactionApplication; - assetConfigTransaction?: TransactionAssetConfig; - assetFreezeTransaction?: TransactionAssetFreeze; - assetTransferTransaction?: TransactionAssetTransfer; - authAddr?: string; - closeRewards?: number | bigint; - closingAmount?: number | bigint; - confirmedRound?: number | bigint; - createdApplicationIndex?: number | bigint; - createdAssetIndex?: number | bigint; - genesisHash?: string | Uint8Array; - genesisId?: string; - globalStateDelta?: EvalDeltaKeyValue[]; - group?: string | Uint8Array; - id?: string; - innerTxns?: Transaction[]; - intraRoundOffset?: number | bigint; - keyregTransaction?: TransactionKeyreg; - lease?: string | Uint8Array; - localStateDelta?: AccountStateDelta[]; - logs?: Uint8Array[]; - note?: string | Uint8Array; - paymentTransaction?: TransactionPayment; - receiverRewards?: number | bigint; - rekeyTo?: string; - roundTime?: number | bigint; - senderRewards?: number | bigint; - signature?: TransactionSignature; - stateProofTransaction?: TransactionStateProof; - txType?: string; - }); - static from_obj_for_encoding(data: Record): Transaction; -} -/** - * Fields for application transactions. - * Definition: - * data/transactions/application.go : ApplicationCallTxnFields - */ -export declare class TransactionApplication extends BaseModel { - /** - * (apid) ID of the application being configured or empty if creating. - */ - applicationId: number | bigint; - /** - * (apat) List of accounts in addition to the sender that may be accessed from the - * application's approval-program and clear-state-program. - */ - accounts?: string[]; - /** - * (apaa) transaction specific arguments accessed from the application's - * approval-program and clear-state-program. - */ - applicationArgs?: Uint8Array[]; - /** - * (apap) Logic executed for every application transaction, except when - * on-completion is set to "clear". It can read and write global state for the - * application, as well as account-specific local state. Approval programs may - * reject the transaction. - */ - approvalProgram?: Uint8Array; - /** - * (apsu) Logic executed for application transactions with on-completion set to - * "clear". It can read and write global state for the application, as well as - * account-specific local state. Clear state programs cannot reject the - * transaction. - */ - clearStateProgram?: Uint8Array; - /** - * (epp) specifies the additional app program len requested in pages. - */ - extraProgramPages?: number | bigint; - /** - * (apfa) Lists the applications in addition to the application-id whose global - * states may be accessed by this application's approval-program and - * clear-state-program. The access is read-only. - */ - foreignApps?: (number | bigint)[]; - /** - * (apas) lists the assets whose parameters may be accessed by this application's - * ApprovalProgram and ClearStateProgram. The access is read-only. - */ - foreignAssets?: (number | bigint)[]; - /** - * Represents a (apls) local-state or (apgs) global-state schema. These schemas - * determine how much storage may be used in a local-state or global-state for an - * application. The more space used, the larger minimum balance must be maintained - * in the account holding the data. - */ - globalStateSchema?: StateSchema; - /** - * Represents a (apls) local-state or (apgs) global-state schema. These schemas - * determine how much storage may be used in a local-state or global-state for an - * application. The more space used, the larger minimum balance must be maintained - * in the account holding the data. - */ - localStateSchema?: StateSchema; - /** - * (apan) defines the what additional actions occur with the transaction. - * Valid types: - * * noop - * * optin - * * closeout - * * clear - * * update - * * update - * * delete - */ - onCompletion?: string; - /** - * Creates a new `TransactionApplication` object. - * @param applicationId - (apid) ID of the application being configured or empty if creating. - * @param accounts - (apat) List of accounts in addition to the sender that may be accessed from the - * application's approval-program and clear-state-program. - * @param applicationArgs - (apaa) transaction specific arguments accessed from the application's - * approval-program and clear-state-program. - * @param approvalProgram - (apap) Logic executed for every application transaction, except when - * on-completion is set to "clear". It can read and write global state for the - * application, as well as account-specific local state. Approval programs may - * reject the transaction. - * @param clearStateProgram - (apsu) Logic executed for application transactions with on-completion set to - * "clear". It can read and write global state for the application, as well as - * account-specific local state. Clear state programs cannot reject the - * transaction. - * @param extraProgramPages - (epp) specifies the additional app program len requested in pages. - * @param foreignApps - (apfa) Lists the applications in addition to the application-id whose global - * states may be accessed by this application's approval-program and - * clear-state-program. The access is read-only. - * @param foreignAssets - (apas) lists the assets whose parameters may be accessed by this application's - * ApprovalProgram and ClearStateProgram. The access is read-only. - * @param globalStateSchema - Represents a (apls) local-state or (apgs) global-state schema. These schemas - * determine how much storage may be used in a local-state or global-state for an - * application. The more space used, the larger minimum balance must be maintained - * in the account holding the data. - * @param localStateSchema - Represents a (apls) local-state or (apgs) global-state schema. These schemas - * determine how much storage may be used in a local-state or global-state for an - * application. The more space used, the larger minimum balance must be maintained - * in the account holding the data. - * @param onCompletion - (apan) defines the what additional actions occur with the transaction. - * Valid types: - * * noop - * * optin - * * closeout - * * clear - * * update - * * update - * * delete - */ - constructor({ applicationId, accounts, applicationArgs, approvalProgram, clearStateProgram, extraProgramPages, foreignApps, foreignAssets, globalStateSchema, localStateSchema, onCompletion, }: { - applicationId: number | bigint; - accounts?: string[]; - applicationArgs?: Uint8Array[]; - approvalProgram?: string | Uint8Array; - clearStateProgram?: string | Uint8Array; - extraProgramPages?: number | bigint; - foreignApps?: (number | bigint)[]; - foreignAssets?: (number | bigint)[]; - globalStateSchema?: StateSchema; - localStateSchema?: StateSchema; - onCompletion?: string; - }); - static from_obj_for_encoding(data: Record): TransactionApplication; -} -/** - * Fields for asset allocation, re-configuration, and destruction. - * A zero value for asset-id indicates asset creation. - * A zero value for the params indicates asset destruction. - * Definition: - * data/transactions/asset.go : AssetConfigTxnFields - */ -export declare class TransactionAssetConfig extends BaseModel { - /** - * (xaid) ID of the asset being configured or empty if creating. - */ - assetId?: number | bigint; - /** - * AssetParams specifies the parameters for an asset. - * (apar) when part of an AssetConfig transaction. - * Definition: - * data/transactions/asset.go : AssetParams - */ - params?: AssetParams; - /** - * Creates a new `TransactionAssetConfig` object. - * @param assetId - (xaid) ID of the asset being configured or empty if creating. - * @param params - AssetParams specifies the parameters for an asset. - * (apar) when part of an AssetConfig transaction. - * Definition: - * data/transactions/asset.go : AssetParams - */ - constructor({ assetId, params, }: { - assetId?: number | bigint; - params?: AssetParams; - }); - static from_obj_for_encoding(data: Record): TransactionAssetConfig; -} -/** - * Fields for an asset freeze transaction. - * Definition: - * data/transactions/asset.go : AssetFreezeTxnFields - */ -export declare class TransactionAssetFreeze extends BaseModel { - /** - * (fadd) Address of the account whose asset is being frozen or thawed. - */ - address: string; - /** - * (faid) ID of the asset being frozen or thawed. - */ - assetId: number | bigint; - /** - * (afrz) The new freeze status. - */ - newFreezeStatus: boolean; - /** - * Creates a new `TransactionAssetFreeze` object. - * @param address - (fadd) Address of the account whose asset is being frozen or thawed. - * @param assetId - (faid) ID of the asset being frozen or thawed. - * @param newFreezeStatus - (afrz) The new freeze status. - */ - constructor({ address, assetId, newFreezeStatus, }: { - address: string; - assetId: number | bigint; - newFreezeStatus: boolean; - }); - static from_obj_for_encoding(data: Record): TransactionAssetFreeze; -} -/** - * Fields for an asset transfer transaction. - * Definition: - * data/transactions/asset.go : AssetTransferTxnFields - */ -export declare class TransactionAssetTransfer extends BaseModel { - /** - * (aamt) Amount of asset to transfer. A zero amount transferred to self allocates - * that asset in the account's Assets map. - */ - amount: number | bigint; - /** - * (xaid) ID of the asset being transferred. - */ - assetId: number | bigint; - /** - * (arcv) Recipient address of the transfer. - */ - receiver: string; - /** - * Number of assets transferred to the close-to account as part of the transaction. - */ - closeAmount?: number | bigint; - /** - * (aclose) Indicates that the asset should be removed from the account's Assets - * map, and specifies where the remaining asset holdings should be transferred. - * It's always valid to transfer remaining asset holdings to the creator account. - */ - closeTo?: string; - /** - * (asnd) The effective sender during a clawback transactions. If this is not a - * zero value, the real transaction sender must be the Clawback address from the - * AssetParams. - */ - sender?: string; - /** - * Creates a new `TransactionAssetTransfer` object. - * @param amount - (aamt) Amount of asset to transfer. A zero amount transferred to self allocates - * that asset in the account's Assets map. - * @param assetId - (xaid) ID of the asset being transferred. - * @param receiver - (arcv) Recipient address of the transfer. - * @param closeAmount - Number of assets transferred to the close-to account as part of the transaction. - * @param closeTo - (aclose) Indicates that the asset should be removed from the account's Assets - * map, and specifies where the remaining asset holdings should be transferred. - * It's always valid to transfer remaining asset holdings to the creator account. - * @param sender - (asnd) The effective sender during a clawback transactions. If this is not a - * zero value, the real transaction sender must be the Clawback address from the - * AssetParams. - */ - constructor({ amount, assetId, receiver, closeAmount, closeTo, sender, }: { - amount: number | bigint; - assetId: number | bigint; - receiver: string; - closeAmount?: number | bigint; - closeTo?: string; - sender?: string; - }); - static from_obj_for_encoding(data: Record): TransactionAssetTransfer; -} -/** - * Fields for a keyreg transaction. - * Definition: - * data/transactions/keyreg.go : KeyregTxnFields - */ -export declare class TransactionKeyreg extends BaseModel { - /** - * (nonpart) Mark the account as participating or non-participating. - */ - nonParticipation?: boolean; - /** - * (selkey) Public key used with the Verified Random Function (VRF) result during - * committee selection. - */ - selectionParticipationKey?: Uint8Array; - /** - * (sprfkey) State proof key used in key registration transactions. - */ - stateProofKey?: Uint8Array; - /** - * (votefst) First round this participation key is valid. - */ - voteFirstValid?: number | bigint; - /** - * (votekd) Number of subkeys in each batch of participation keys. - */ - voteKeyDilution?: number | bigint; - /** - * (votelst) Last round this participation key is valid. - */ - voteLastValid?: number | bigint; - /** - * (votekey) Participation public key used in key registration transactions. - */ - voteParticipationKey?: Uint8Array; - /** - * Creates a new `TransactionKeyreg` object. - * @param nonParticipation - (nonpart) Mark the account as participating or non-participating. - * @param selectionParticipationKey - (selkey) Public key used with the Verified Random Function (VRF) result during - * committee selection. - * @param stateProofKey - (sprfkey) State proof key used in key registration transactions. - * @param voteFirstValid - (votefst) First round this participation key is valid. - * @param voteKeyDilution - (votekd) Number of subkeys in each batch of participation keys. - * @param voteLastValid - (votelst) Last round this participation key is valid. - * @param voteParticipationKey - (votekey) Participation public key used in key registration transactions. - */ - constructor({ nonParticipation, selectionParticipationKey, stateProofKey, voteFirstValid, voteKeyDilution, voteLastValid, voteParticipationKey, }: { - nonParticipation?: boolean; - selectionParticipationKey?: string | Uint8Array; - stateProofKey?: string | Uint8Array; - voteFirstValid?: number | bigint; - voteKeyDilution?: number | bigint; - voteLastValid?: number | bigint; - voteParticipationKey?: string | Uint8Array; - }); - static from_obj_for_encoding(data: Record): TransactionKeyreg; -} -/** - * Fields for a payment transaction. - * Definition: - * data/transactions/payment.go : PaymentTxnFields - */ -export declare class TransactionPayment extends BaseModel { - /** - * (amt) number of MicroAlgos intended to be transferred. - */ - amount: number | bigint; - /** - * (rcv) receiver's address. - */ - receiver: string; - /** - * Number of MicroAlgos that were sent to the close-remainder-to address when - * closing the sender account. - */ - closeAmount?: number | bigint; - /** - * (close) when set, indicates that the sending account should be closed and all - * remaining funds be transferred to this address. - */ - closeRemainderTo?: string; - /** - * Creates a new `TransactionPayment` object. - * @param amount - (amt) number of MicroAlgos intended to be transferred. - * @param receiver - (rcv) receiver's address. - * @param closeAmount - Number of MicroAlgos that were sent to the close-remainder-to address when - * closing the sender account. - * @param closeRemainderTo - (close) when set, indicates that the sending account should be closed and all - * remaining funds be transferred to this address. - */ - constructor({ amount, receiver, closeAmount, closeRemainderTo, }: { - amount: number | bigint; - receiver: string; - closeAmount?: number | bigint; - closeRemainderTo?: string; - }); - static from_obj_for_encoding(data: Record): TransactionPayment; -} -/** - * - */ -export declare class TransactionResponse extends BaseModel { - /** - * Round at which the results were computed. - */ - currentRound: number | bigint; - /** - * Contains all fields common to all transactions and serves as an envelope to all - * transactions type. Represents both regular and inner transactions. - * Definition: - * data/transactions/signedtxn.go : SignedTxn - * data/transactions/transaction.go : Transaction - */ - transaction: Transaction; - /** - * Creates a new `TransactionResponse` object. - * @param currentRound - Round at which the results were computed. - * @param transaction - Contains all fields common to all transactions and serves as an envelope to all - * transactions type. Represents both regular and inner transactions. - * Definition: - * data/transactions/signedtxn.go : SignedTxn - * data/transactions/transaction.go : Transaction - */ - constructor({ currentRound, transaction, }: { - currentRound: number | bigint; - transaction: Transaction; - }); - static from_obj_for_encoding(data: Record): TransactionResponse; -} -/** - * Validation signature associated with some data. Only one of the signatures - * should be provided. - */ -export declare class TransactionSignature extends BaseModel { - /** - * (lsig) Programatic transaction signature. - * Definition: - * data/transactions/logicsig.go - */ - logicsig?: TransactionSignatureLogicsig; - /** - * (msig) structure holding multiple subsignatures. - * Definition: - * crypto/multisig.go : MultisigSig - */ - multisig?: TransactionSignatureMultisig; - /** - * (sig) Standard ed25519 signature. - */ - sig?: Uint8Array; - /** - * Creates a new `TransactionSignature` object. - * @param logicsig - (lsig) Programatic transaction signature. - * Definition: - * data/transactions/logicsig.go - * @param multisig - (msig) structure holding multiple subsignatures. - * Definition: - * crypto/multisig.go : MultisigSig - * @param sig - (sig) Standard ed25519 signature. - */ - constructor({ logicsig, multisig, sig, }: { - logicsig?: TransactionSignatureLogicsig; - multisig?: TransactionSignatureMultisig; - sig?: string | Uint8Array; - }); - static from_obj_for_encoding(data: Record): TransactionSignature; -} -/** - * (lsig) Programatic transaction signature. - * Definition: - * data/transactions/logicsig.go - */ -export declare class TransactionSignatureLogicsig extends BaseModel { - /** - * (l) Program signed by a signature or multi signature, or hashed to be the - * address of ana ccount. Base64 encoded TEAL program. - */ - logic: Uint8Array; - /** - * (arg) Logic arguments, base64 encoded. - */ - args?: Uint8Array[]; - /** - * (msig) structure holding multiple subsignatures. - * Definition: - * crypto/multisig.go : MultisigSig - */ - multisigSignature?: TransactionSignatureMultisig; - /** - * (sig) ed25519 signature. - */ - signature?: Uint8Array; - /** - * Creates a new `TransactionSignatureLogicsig` object. - * @param logic - (l) Program signed by a signature or multi signature, or hashed to be the - * address of ana ccount. Base64 encoded TEAL program. - * @param args - (arg) Logic arguments, base64 encoded. - * @param multisigSignature - (msig) structure holding multiple subsignatures. - * Definition: - * crypto/multisig.go : MultisigSig - * @param signature - (sig) ed25519 signature. - */ - constructor({ logic, args, multisigSignature, signature, }: { - logic: string | Uint8Array; - args?: Uint8Array[]; - multisigSignature?: TransactionSignatureMultisig; - signature?: string | Uint8Array; - }); - static from_obj_for_encoding(data: Record): TransactionSignatureLogicsig; -} -/** - * (msig) structure holding multiple subsignatures. - * Definition: - * crypto/multisig.go : MultisigSig - */ -export declare class TransactionSignatureMultisig extends BaseModel { - /** - * (subsig) holds pairs of public key and signatures. - */ - subsignature?: TransactionSignatureMultisigSubsignature[]; - /** - * (thr) - */ - threshold?: number | bigint; - /** - * (v) - */ - version?: number | bigint; - /** - * Creates a new `TransactionSignatureMultisig` object. - * @param subsignature - (subsig) holds pairs of public key and signatures. - * @param threshold - (thr) - * @param version - (v) - */ - constructor({ subsignature, threshold, version, }: { - subsignature?: TransactionSignatureMultisigSubsignature[]; - threshold?: number | bigint; - version?: number | bigint; - }); - static from_obj_for_encoding(data: Record): TransactionSignatureMultisig; -} -export declare class TransactionSignatureMultisigSubsignature extends BaseModel { - /** - * (pk) - */ - publicKey?: Uint8Array; - /** - * (s) - */ - signature?: Uint8Array; - /** - * Creates a new `TransactionSignatureMultisigSubsignature` object. - * @param publicKey - (pk) - * @param signature - (s) - */ - constructor({ publicKey, signature, }: { - publicKey?: string | Uint8Array; - signature?: string | Uint8Array; - }); - static from_obj_for_encoding(data: Record): TransactionSignatureMultisigSubsignature; -} -/** - * Fields for a state proof transaction. - * Definition: - * data/transactions/stateproof.go : StateProofTxnFields - */ -export declare class TransactionStateProof extends BaseModel { - /** - * (spmsg) - */ - message?: IndexerStateProofMessage; - /** - * (sp) represents a state proof. - * Definition: - * crypto/stateproof/structs.go : StateProof - */ - stateProof?: StateProofFields; - /** - * (sptype) Type of the state proof. Integer representing an entry defined in - * protocol/stateproof.go - */ - stateProofType?: number | bigint; - /** - * Creates a new `TransactionStateProof` object. - * @param message - (spmsg) - * @param stateProof - (sp) represents a state proof. - * Definition: - * crypto/stateproof/structs.go : StateProof - * @param stateProofType - (sptype) Type of the state proof. Integer representing an entry defined in - * protocol/stateproof.go - */ - constructor({ message, stateProof, stateProofType, }: { - message?: IndexerStateProofMessage; - stateProof?: StateProofFields; - stateProofType?: number | bigint; - }); - static from_obj_for_encoding(data: Record): TransactionStateProof; -} -/** - * - */ -export declare class TransactionsResponse extends BaseModel { - /** - * Round at which the results were computed. - */ - currentRound: number | bigint; - transactions: Transaction[]; - /** - * Used for pagination, when making another request provide this token with the - * next parameter. - */ - nextToken?: string; - /** - * Creates a new `TransactionsResponse` object. - * @param currentRound - Round at which the results were computed. - * @param transactions - - * @param nextToken - Used for pagination, when making another request provide this token with the - * next parameter. - */ - constructor({ currentRound, transactions, nextToken, }: { - currentRound: number | bigint; - transactions: Transaction[]; - nextToken?: string; - }); - static from_obj_for_encoding(data: Record): TransactionsResponse; -} diff --git a/algosdk/client/v2/indexer/models/types.js b/algosdk/client/v2/indexer/models/types.js deleted file mode 100644 index d02e5df..0000000 --- a/algosdk/client/v2/indexer/models/types.js +++ /dev/null @@ -1,3041 +0,0 @@ -"use strict"; -/** - * NOTICE: This file was generated. Editing this file manually is not recommended. - */ -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.TransactionAssetConfig = exports.TransactionApplication = exports.Transaction = exports.TealValue = exports.TealKeyValue = exports.StateSchema = exports.StateProofVerifier = exports.StateProofTracking = exports.StateProofSignature = exports.StateProofSigSlot = exports.StateProofReveal = exports.StateProofParticipant = exports.StateProofFields = exports.ParticipationUpdates = exports.MiniAssetHolding = exports.MerkleArrayProof = exports.IndexerStateProofMessage = exports.HealthCheck = exports.HashFactory = exports.EvalDeltaKeyValue = exports.EvalDelta = exports.ErrorResponse = exports.BoxesResponse = exports.BoxDescriptor = exports.Box = exports.BlockUpgradeVote = exports.BlockUpgradeState = exports.BlockRewards = exports.Block = exports.AssetsResponse = exports.AssetResponse = exports.AssetParams = exports.AssetHoldingsResponse = exports.AssetHolding = exports.AssetBalancesResponse = exports.Asset = exports.ApplicationsResponse = exports.ApplicationStateSchema = exports.ApplicationResponse = exports.ApplicationParams = exports.ApplicationLogsResponse = exports.ApplicationLogData = exports.ApplicationLocalStatesResponse = exports.ApplicationLocalState = exports.Application = exports.AccountsResponse = exports.AccountStateDelta = exports.AccountResponse = exports.AccountParticipation = exports.Account = void 0; -exports.TransactionsResponse = exports.TransactionStateProof = exports.TransactionSignatureMultisigSubsignature = exports.TransactionSignatureMultisig = exports.TransactionSignatureLogicsig = exports.TransactionSignature = exports.TransactionResponse = exports.TransactionPayment = exports.TransactionKeyreg = exports.TransactionAssetTransfer = exports.TransactionAssetFreeze = void 0; -/* eslint-disable no-use-before-define */ -const binarydata_1 = require("../../../../encoding/binarydata"); -const basemodel_1 = __importDefault(require("../../basemodel")); -/** - * Account information at a given round. - * Definition: - * data/basics/userBalance.go : AccountData - */ -class Account extends basemodel_1.default { - /** - * Creates a new `Account` object. - * @param address - the account public key - * @param amount - (algo) total number of MicroAlgos in the account - * @param amountWithoutPendingRewards - specifies the amount of MicroAlgos in the account, without the pending rewards. - * @param pendingRewards - amount of MicroAlgos of pending rewards in this account. - * @param rewards - (ern) total rewards of MicroAlgos the account has received, including pending - * rewards. - * @param round - The round for which this information is relevant. - * @param status - (onl) delegation status of the account's MicroAlgos - * * Offline - indicates that the associated account is delegated. - * * Online - indicates that the associated account used as part of the delegation - * pool. - * * NotParticipating - indicates that the associated account is neither a - * delegator nor a delegate. - * @param totalAppsOptedIn - The count of all applications that have been opted in, equivalent to the count - * of application local data (AppLocalState objects) stored in this account. - * @param totalAssetsOptedIn - The count of all assets that have been opted in, equivalent to the count of - * AssetHolding objects held by this account. - * @param totalBoxBytes - For app-accounts only. The total number of bytes allocated for the keys and - * values of boxes which belong to the associated application. - * @param totalBoxes - For app-accounts only. The total number of boxes which belong to the associated - * application. - * @param totalCreatedApps - The count of all apps (AppParams objects) created by this account. - * @param totalCreatedAssets - The count of all assets (AssetParams objects) created by this account. - * @param appsLocalState - (appl) applications local data stored in this account. - * Note the raw object uses `map[int] -> AppLocalState` for this type. - * @param appsTotalExtraPages - (teap) the sum of all extra application program pages for this account. - * @param appsTotalSchema - (tsch) stores the sum of all of the local schemas and global schemas in this - * account. - * Note: the raw account uses `StateSchema` for this type. - * @param assets - (asset) assets held by this account. - * Note the raw object uses `map[int] -> AssetHolding` for this type. - * @param authAddr - (spend) the address against which signing should be checked. If empty, the - * address of the current account is used. This field can be updated in any - * transaction by setting the RekeyTo field. - * @param closedAtRound - Round during which this account was most recently closed. - * @param createdApps - (appp) parameters of applications created by this account including app global - * data. - * Note: the raw account uses `map[int] -> AppParams` for this type. - * @param createdAssets - (apar) parameters of assets created by this account. - * Note: the raw account uses `map[int] -> Asset` for this type. - * @param createdAtRound - Round during which this account first appeared in a transaction. - * @param deleted - Whether or not this account is currently closed. - * @param participation - AccountParticipation describes the parameters used by this account in consensus - * protocol. - * @param rewardBase - (ebase) used as part of the rewards computation. Only applicable to accounts - * which are participating. - * @param sigType - Indicates what type of signature is used by this account, must be one of: - * * sig - * * msig - * * lsig - * * or null if unknown - */ - constructor({ address, amount, amountWithoutPendingRewards, pendingRewards, rewards, round, status, totalAppsOptedIn, totalAssetsOptedIn, totalBoxBytes, totalBoxes, totalCreatedApps, totalCreatedAssets, appsLocalState, appsTotalExtraPages, appsTotalSchema, assets, authAddr, closedAtRound, createdApps, createdAssets, createdAtRound, deleted, participation, rewardBase, sigType, }) { - super(); - this.address = address; - this.amount = amount; - this.amountWithoutPendingRewards = amountWithoutPendingRewards; - this.pendingRewards = pendingRewards; - this.rewards = rewards; - this.round = round; - this.status = status; - this.totalAppsOptedIn = totalAppsOptedIn; - this.totalAssetsOptedIn = totalAssetsOptedIn; - this.totalBoxBytes = totalBoxBytes; - this.totalBoxes = totalBoxes; - this.totalCreatedApps = totalCreatedApps; - this.totalCreatedAssets = totalCreatedAssets; - this.appsLocalState = appsLocalState; - this.appsTotalExtraPages = appsTotalExtraPages; - this.appsTotalSchema = appsTotalSchema; - this.assets = assets; - this.authAddr = authAddr; - this.closedAtRound = closedAtRound; - this.createdApps = createdApps; - this.createdAssets = createdAssets; - this.createdAtRound = createdAtRound; - this.deleted = deleted; - this.participation = participation; - this.rewardBase = rewardBase; - this.sigType = sigType; - this.attribute_map = { - address: 'address', - amount: 'amount', - amountWithoutPendingRewards: 'amount-without-pending-rewards', - pendingRewards: 'pending-rewards', - rewards: 'rewards', - round: 'round', - status: 'status', - totalAppsOptedIn: 'total-apps-opted-in', - totalAssetsOptedIn: 'total-assets-opted-in', - totalBoxBytes: 'total-box-bytes', - totalBoxes: 'total-boxes', - totalCreatedApps: 'total-created-apps', - totalCreatedAssets: 'total-created-assets', - appsLocalState: 'apps-local-state', - appsTotalExtraPages: 'apps-total-extra-pages', - appsTotalSchema: 'apps-total-schema', - assets: 'assets', - authAddr: 'auth-addr', - closedAtRound: 'closed-at-round', - createdApps: 'created-apps', - createdAssets: 'created-assets', - createdAtRound: 'created-at-round', - deleted: 'deleted', - participation: 'participation', - rewardBase: 'reward-base', - sigType: 'sig-type', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['address'] === 'undefined') - throw new Error(`Response is missing required field 'address': ${data}`); - if (typeof data['amount'] === 'undefined') - throw new Error(`Response is missing required field 'amount': ${data}`); - if (typeof data['amount-without-pending-rewards'] === 'undefined') - throw new Error(`Response is missing required field 'amount-without-pending-rewards': ${data}`); - if (typeof data['pending-rewards'] === 'undefined') - throw new Error(`Response is missing required field 'pending-rewards': ${data}`); - if (typeof data['rewards'] === 'undefined') - throw new Error(`Response is missing required field 'rewards': ${data}`); - if (typeof data['round'] === 'undefined') - throw new Error(`Response is missing required field 'round': ${data}`); - if (typeof data['status'] === 'undefined') - throw new Error(`Response is missing required field 'status': ${data}`); - if (typeof data['total-apps-opted-in'] === 'undefined') - throw new Error(`Response is missing required field 'total-apps-opted-in': ${data}`); - if (typeof data['total-assets-opted-in'] === 'undefined') - throw new Error(`Response is missing required field 'total-assets-opted-in': ${data}`); - if (typeof data['total-box-bytes'] === 'undefined') - throw new Error(`Response is missing required field 'total-box-bytes': ${data}`); - if (typeof data['total-boxes'] === 'undefined') - throw new Error(`Response is missing required field 'total-boxes': ${data}`); - if (typeof data['total-created-apps'] === 'undefined') - throw new Error(`Response is missing required field 'total-created-apps': ${data}`); - if (typeof data['total-created-assets'] === 'undefined') - throw new Error(`Response is missing required field 'total-created-assets': ${data}`); - return new Account({ - address: data['address'], - amount: data['amount'], - amountWithoutPendingRewards: data['amount-without-pending-rewards'], - pendingRewards: data['pending-rewards'], - rewards: data['rewards'], - round: data['round'], - status: data['status'], - totalAppsOptedIn: data['total-apps-opted-in'], - totalAssetsOptedIn: data['total-assets-opted-in'], - totalBoxBytes: data['total-box-bytes'], - totalBoxes: data['total-boxes'], - totalCreatedApps: data['total-created-apps'], - totalCreatedAssets: data['total-created-assets'], - appsLocalState: typeof data['apps-local-state'] !== 'undefined' - ? data['apps-local-state'].map(ApplicationLocalState.from_obj_for_encoding) - : undefined, - appsTotalExtraPages: data['apps-total-extra-pages'], - appsTotalSchema: typeof data['apps-total-schema'] !== 'undefined' - ? ApplicationStateSchema.from_obj_for_encoding(data['apps-total-schema']) - : undefined, - assets: typeof data['assets'] !== 'undefined' - ? data['assets'].map(AssetHolding.from_obj_for_encoding) - : undefined, - authAddr: data['auth-addr'], - closedAtRound: data['closed-at-round'], - createdApps: typeof data['created-apps'] !== 'undefined' - ? data['created-apps'].map(Application.from_obj_for_encoding) - : undefined, - createdAssets: typeof data['created-assets'] !== 'undefined' - ? data['created-assets'].map(Asset.from_obj_for_encoding) - : undefined, - createdAtRound: data['created-at-round'], - deleted: data['deleted'], - participation: typeof data['participation'] !== 'undefined' - ? AccountParticipation.from_obj_for_encoding(data['participation']) - : undefined, - rewardBase: data['reward-base'], - sigType: data['sig-type'], - }); - /* eslint-enable dot-notation */ - } -} -exports.Account = Account; -/** - * AccountParticipation describes the parameters used by this account in consensus - * protocol. - */ -class AccountParticipation extends basemodel_1.default { - /** - * Creates a new `AccountParticipation` object. - * @param selectionParticipationKey - (sel) Selection public key (if any) currently registered for this round. - * @param voteFirstValid - (voteFst) First round for which this participation is valid. - * @param voteKeyDilution - (voteKD) Number of subkeys in each batch of participation keys. - * @param voteLastValid - (voteLst) Last round for which this participation is valid. - * @param voteParticipationKey - (vote) root participation public key (if any) currently registered for this - * round. - * @param stateProofKey - (stprf) Root of the state proof key (if any) - */ - constructor({ selectionParticipationKey, voteFirstValid, voteKeyDilution, voteLastValid, voteParticipationKey, stateProofKey, }) { - super(); - this.selectionParticipationKey = - typeof selectionParticipationKey === 'string' - ? (0, binarydata_1.base64ToBytes)(selectionParticipationKey) - : selectionParticipationKey; - this.voteFirstValid = voteFirstValid; - this.voteKeyDilution = voteKeyDilution; - this.voteLastValid = voteLastValid; - this.voteParticipationKey = - typeof voteParticipationKey === 'string' - ? (0, binarydata_1.base64ToBytes)(voteParticipationKey) - : voteParticipationKey; - this.stateProofKey = - typeof stateProofKey === 'string' - ? (0, binarydata_1.base64ToBytes)(stateProofKey) - : stateProofKey; - this.attribute_map = { - selectionParticipationKey: 'selection-participation-key', - voteFirstValid: 'vote-first-valid', - voteKeyDilution: 'vote-key-dilution', - voteLastValid: 'vote-last-valid', - voteParticipationKey: 'vote-participation-key', - stateProofKey: 'state-proof-key', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['selection-participation-key'] === 'undefined') - throw new Error(`Response is missing required field 'selection-participation-key': ${data}`); - if (typeof data['vote-first-valid'] === 'undefined') - throw new Error(`Response is missing required field 'vote-first-valid': ${data}`); - if (typeof data['vote-key-dilution'] === 'undefined') - throw new Error(`Response is missing required field 'vote-key-dilution': ${data}`); - if (typeof data['vote-last-valid'] === 'undefined') - throw new Error(`Response is missing required field 'vote-last-valid': ${data}`); - if (typeof data['vote-participation-key'] === 'undefined') - throw new Error(`Response is missing required field 'vote-participation-key': ${data}`); - return new AccountParticipation({ - selectionParticipationKey: data['selection-participation-key'], - voteFirstValid: data['vote-first-valid'], - voteKeyDilution: data['vote-key-dilution'], - voteLastValid: data['vote-last-valid'], - voteParticipationKey: data['vote-participation-key'], - stateProofKey: data['state-proof-key'], - }); - /* eslint-enable dot-notation */ - } -} -exports.AccountParticipation = AccountParticipation; -/** - * - */ -class AccountResponse extends basemodel_1.default { - /** - * Creates a new `AccountResponse` object. - * @param account - Account information at a given round. - * Definition: - * data/basics/userBalance.go : AccountData - * @param currentRound - Round at which the results were computed. - */ - constructor({ account, currentRound, }) { - super(); - this.account = account; - this.currentRound = currentRound; - this.attribute_map = { - account: 'account', - currentRound: 'current-round', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['account'] === 'undefined') - throw new Error(`Response is missing required field 'account': ${data}`); - if (typeof data['current-round'] === 'undefined') - throw new Error(`Response is missing required field 'current-round': ${data}`); - return new AccountResponse({ - account: Account.from_obj_for_encoding(data['account']), - currentRound: data['current-round'], - }); - /* eslint-enable dot-notation */ - } -} -exports.AccountResponse = AccountResponse; -/** - * Application state delta. - */ -class AccountStateDelta extends basemodel_1.default { - /** - * Creates a new `AccountStateDelta` object. - * @param address - - * @param delta - Application state delta. - */ - constructor({ address, delta, }) { - super(); - this.address = address; - this.delta = delta; - this.attribute_map = { - address: 'address', - delta: 'delta', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['address'] === 'undefined') - throw new Error(`Response is missing required field 'address': ${data}`); - if (!Array.isArray(data['delta'])) - throw new Error(`Response is missing required array field 'delta': ${data}`); - return new AccountStateDelta({ - address: data['address'], - delta: data['delta'].map(EvalDeltaKeyValue.from_obj_for_encoding), - }); - /* eslint-enable dot-notation */ - } -} -exports.AccountStateDelta = AccountStateDelta; -/** - * - */ -class AccountsResponse extends basemodel_1.default { - /** - * Creates a new `AccountsResponse` object. - * @param accounts - - * @param currentRound - Round at which the results were computed. - * @param nextToken - Used for pagination, when making another request provide this token with the - * next parameter. - */ - constructor({ accounts, currentRound, nextToken, }) { - super(); - this.accounts = accounts; - this.currentRound = currentRound; - this.nextToken = nextToken; - this.attribute_map = { - accounts: 'accounts', - currentRound: 'current-round', - nextToken: 'next-token', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (!Array.isArray(data['accounts'])) - throw new Error(`Response is missing required array field 'accounts': ${data}`); - if (typeof data['current-round'] === 'undefined') - throw new Error(`Response is missing required field 'current-round': ${data}`); - return new AccountsResponse({ - accounts: data['accounts'].map(Account.from_obj_for_encoding), - currentRound: data['current-round'], - nextToken: data['next-token'], - }); - /* eslint-enable dot-notation */ - } -} -exports.AccountsResponse = AccountsResponse; -/** - * Application index and its parameters - */ -class Application extends basemodel_1.default { - /** - * Creates a new `Application` object. - * @param id - (appidx) application index. - * @param params - (appparams) application parameters. - * @param createdAtRound - Round when this application was created. - * @param deleted - Whether or not this application is currently deleted. - * @param deletedAtRound - Round when this application was deleted. - */ - constructor({ id, params, createdAtRound, deleted, deletedAtRound, }) { - super(); - this.id = id; - this.params = params; - this.createdAtRound = createdAtRound; - this.deleted = deleted; - this.deletedAtRound = deletedAtRound; - this.attribute_map = { - id: 'id', - params: 'params', - createdAtRound: 'created-at-round', - deleted: 'deleted', - deletedAtRound: 'deleted-at-round', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['id'] === 'undefined') - throw new Error(`Response is missing required field 'id': ${data}`); - if (typeof data['params'] === 'undefined') - throw new Error(`Response is missing required field 'params': ${data}`); - return new Application({ - id: data['id'], - params: ApplicationParams.from_obj_for_encoding(data['params']), - createdAtRound: data['created-at-round'], - deleted: data['deleted'], - deletedAtRound: data['deleted-at-round'], - }); - /* eslint-enable dot-notation */ - } -} -exports.Application = Application; -/** - * Stores local state associated with an application. - */ -class ApplicationLocalState extends basemodel_1.default { - /** - * Creates a new `ApplicationLocalState` object. - * @param id - The application which this local state is for. - * @param schema - (hsch) schema. - * @param closedOutAtRound - Round when account closed out of the application. - * @param deleted - Whether or not the application local state is currently deleted from its - * account. - * @param keyValue - (tkv) storage. - * @param optedInAtRound - Round when the account opted into the application. - */ - constructor({ id, schema, closedOutAtRound, deleted, keyValue, optedInAtRound, }) { - super(); - this.id = id; - this.schema = schema; - this.closedOutAtRound = closedOutAtRound; - this.deleted = deleted; - this.keyValue = keyValue; - this.optedInAtRound = optedInAtRound; - this.attribute_map = { - id: 'id', - schema: 'schema', - closedOutAtRound: 'closed-out-at-round', - deleted: 'deleted', - keyValue: 'key-value', - optedInAtRound: 'opted-in-at-round', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['id'] === 'undefined') - throw new Error(`Response is missing required field 'id': ${data}`); - if (typeof data['schema'] === 'undefined') - throw new Error(`Response is missing required field 'schema': ${data}`); - return new ApplicationLocalState({ - id: data['id'], - schema: ApplicationStateSchema.from_obj_for_encoding(data['schema']), - closedOutAtRound: data['closed-out-at-round'], - deleted: data['deleted'], - keyValue: typeof data['key-value'] !== 'undefined' - ? data['key-value'].map(TealKeyValue.from_obj_for_encoding) - : undefined, - optedInAtRound: data['opted-in-at-round'], - }); - /* eslint-enable dot-notation */ - } -} -exports.ApplicationLocalState = ApplicationLocalState; -/** - * - */ -class ApplicationLocalStatesResponse extends basemodel_1.default { - /** - * Creates a new `ApplicationLocalStatesResponse` object. - * @param appsLocalStates - - * @param currentRound - Round at which the results were computed. - * @param nextToken - Used for pagination, when making another request provide this token with the - * next parameter. - */ - constructor({ appsLocalStates, currentRound, nextToken, }) { - super(); - this.appsLocalStates = appsLocalStates; - this.currentRound = currentRound; - this.nextToken = nextToken; - this.attribute_map = { - appsLocalStates: 'apps-local-states', - currentRound: 'current-round', - nextToken: 'next-token', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (!Array.isArray(data['apps-local-states'])) - throw new Error(`Response is missing required array field 'apps-local-states': ${data}`); - if (typeof data['current-round'] === 'undefined') - throw new Error(`Response is missing required field 'current-round': ${data}`); - return new ApplicationLocalStatesResponse({ - appsLocalStates: data['apps-local-states'].map(ApplicationLocalState.from_obj_for_encoding), - currentRound: data['current-round'], - nextToken: data['next-token'], - }); - /* eslint-enable dot-notation */ - } -} -exports.ApplicationLocalStatesResponse = ApplicationLocalStatesResponse; -/** - * Stores the global information associated with an application. - */ -class ApplicationLogData extends basemodel_1.default { - /** - * Creates a new `ApplicationLogData` object. - * @param logs - (lg) Logs for the application being executed by the transaction. - * @param txid - Transaction ID - */ - constructor({ logs, txid }) { - super(); - this.logs = logs; - this.txid = txid; - this.attribute_map = { - logs: 'logs', - txid: 'txid', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (!Array.isArray(data['logs'])) - throw new Error(`Response is missing required array field 'logs': ${data}`); - if (typeof data['txid'] === 'undefined') - throw new Error(`Response is missing required field 'txid': ${data}`); - return new ApplicationLogData({ - logs: data['logs'], - txid: data['txid'], - }); - /* eslint-enable dot-notation */ - } -} -exports.ApplicationLogData = ApplicationLogData; -/** - * - */ -class ApplicationLogsResponse extends basemodel_1.default { - /** - * Creates a new `ApplicationLogsResponse` object. - * @param applicationId - (appidx) application index. - * @param currentRound - Round at which the results were computed. - * @param logData - - * @param nextToken - Used for pagination, when making another request provide this token with the - * next parameter. - */ - constructor({ applicationId, currentRound, logData, nextToken, }) { - super(); - this.applicationId = applicationId; - this.currentRound = currentRound; - this.logData = logData; - this.nextToken = nextToken; - this.attribute_map = { - applicationId: 'application-id', - currentRound: 'current-round', - logData: 'log-data', - nextToken: 'next-token', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['application-id'] === 'undefined') - throw new Error(`Response is missing required field 'application-id': ${data}`); - if (typeof data['current-round'] === 'undefined') - throw new Error(`Response is missing required field 'current-round': ${data}`); - return new ApplicationLogsResponse({ - applicationId: data['application-id'], - currentRound: data['current-round'], - logData: typeof data['log-data'] !== 'undefined' - ? data['log-data'].map(ApplicationLogData.from_obj_for_encoding) - : undefined, - nextToken: data['next-token'], - }); - /* eslint-enable dot-notation */ - } -} -exports.ApplicationLogsResponse = ApplicationLogsResponse; -/** - * Stores the global information associated with an application. - */ -class ApplicationParams extends basemodel_1.default { - /** - * Creates a new `ApplicationParams` object. - * @param approvalProgram - (approv) approval program. - * @param clearStateProgram - (clearp) approval program. - * @param creator - The address that created this application. This is the address where the - * parameters and global state for this application can be found. - * @param extraProgramPages - (epp) the amount of extra program pages available to this app. - * @param globalState - [\gs) global schema - * @param globalStateSchema - [\gsch) global schema - * @param localStateSchema - [\lsch) local schema - */ - constructor({ approvalProgram, clearStateProgram, creator, extraProgramPages, globalState, globalStateSchema, localStateSchema, }) { - super(); - this.approvalProgram = - typeof approvalProgram === 'string' - ? (0, binarydata_1.base64ToBytes)(approvalProgram) - : approvalProgram; - this.clearStateProgram = - typeof clearStateProgram === 'string' - ? (0, binarydata_1.base64ToBytes)(clearStateProgram) - : clearStateProgram; - this.creator = creator; - this.extraProgramPages = extraProgramPages; - this.globalState = globalState; - this.globalStateSchema = globalStateSchema; - this.localStateSchema = localStateSchema; - this.attribute_map = { - approvalProgram: 'approval-program', - clearStateProgram: 'clear-state-program', - creator: 'creator', - extraProgramPages: 'extra-program-pages', - globalState: 'global-state', - globalStateSchema: 'global-state-schema', - localStateSchema: 'local-state-schema', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['approval-program'] === 'undefined') - throw new Error(`Response is missing required field 'approval-program': ${data}`); - if (typeof data['clear-state-program'] === 'undefined') - throw new Error(`Response is missing required field 'clear-state-program': ${data}`); - return new ApplicationParams({ - approvalProgram: data['approval-program'], - clearStateProgram: data['clear-state-program'], - creator: data['creator'], - extraProgramPages: data['extra-program-pages'], - globalState: typeof data['global-state'] !== 'undefined' - ? data['global-state'].map(TealKeyValue.from_obj_for_encoding) - : undefined, - globalStateSchema: typeof data['global-state-schema'] !== 'undefined' - ? ApplicationStateSchema.from_obj_for_encoding(data['global-state-schema']) - : undefined, - localStateSchema: typeof data['local-state-schema'] !== 'undefined' - ? ApplicationStateSchema.from_obj_for_encoding(data['local-state-schema']) - : undefined, - }); - /* eslint-enable dot-notation */ - } -} -exports.ApplicationParams = ApplicationParams; -/** - * - */ -class ApplicationResponse extends basemodel_1.default { - /** - * Creates a new `ApplicationResponse` object. - * @param currentRound - Round at which the results were computed. - * @param application - Application index and its parameters - */ - constructor({ currentRound, application, }) { - super(); - this.currentRound = currentRound; - this.application = application; - this.attribute_map = { - currentRound: 'current-round', - application: 'application', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['current-round'] === 'undefined') - throw new Error(`Response is missing required field 'current-round': ${data}`); - return new ApplicationResponse({ - currentRound: data['current-round'], - application: typeof data['application'] !== 'undefined' - ? Application.from_obj_for_encoding(data['application']) - : undefined, - }); - /* eslint-enable dot-notation */ - } -} -exports.ApplicationResponse = ApplicationResponse; -/** - * Specifies maximums on the number of each type that may be stored. - */ -class ApplicationStateSchema extends basemodel_1.default { - /** - * Creates a new `ApplicationStateSchema` object. - * @param numByteSlice - (nbs) num of byte slices. - * @param numUint - (nui) num of uints. - */ - constructor({ numByteSlice, numUint, }) { - super(); - this.numByteSlice = numByteSlice; - this.numUint = numUint; - this.attribute_map = { - numByteSlice: 'num-byte-slice', - numUint: 'num-uint', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['num-byte-slice'] === 'undefined') - throw new Error(`Response is missing required field 'num-byte-slice': ${data}`); - if (typeof data['num-uint'] === 'undefined') - throw new Error(`Response is missing required field 'num-uint': ${data}`); - return new ApplicationStateSchema({ - numByteSlice: data['num-byte-slice'], - numUint: data['num-uint'], - }); - /* eslint-enable dot-notation */ - } -} -exports.ApplicationStateSchema = ApplicationStateSchema; -/** - * - */ -class ApplicationsResponse extends basemodel_1.default { - /** - * Creates a new `ApplicationsResponse` object. - * @param applications - - * @param currentRound - Round at which the results were computed. - * @param nextToken - Used for pagination, when making another request provide this token with the - * next parameter. - */ - constructor({ applications, currentRound, nextToken, }) { - super(); - this.applications = applications; - this.currentRound = currentRound; - this.nextToken = nextToken; - this.attribute_map = { - applications: 'applications', - currentRound: 'current-round', - nextToken: 'next-token', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (!Array.isArray(data['applications'])) - throw new Error(`Response is missing required array field 'applications': ${data}`); - if (typeof data['current-round'] === 'undefined') - throw new Error(`Response is missing required field 'current-round': ${data}`); - return new ApplicationsResponse({ - applications: data['applications'].map(Application.from_obj_for_encoding), - currentRound: data['current-round'], - nextToken: data['next-token'], - }); - /* eslint-enable dot-notation */ - } -} -exports.ApplicationsResponse = ApplicationsResponse; -/** - * Specifies both the unique identifier and the parameters for an asset - */ -class Asset extends basemodel_1.default { - /** - * Creates a new `Asset` object. - * @param index - unique asset identifier - * @param params - AssetParams specifies the parameters for an asset. - * (apar) when part of an AssetConfig transaction. - * Definition: - * data/transactions/asset.go : AssetParams - * @param createdAtRound - Round during which this asset was created. - * @param deleted - Whether or not this asset is currently deleted. - * @param destroyedAtRound - Round during which this asset was destroyed. - */ - constructor({ index, params, createdAtRound, deleted, destroyedAtRound, }) { - super(); - this.index = index; - this.params = params; - this.createdAtRound = createdAtRound; - this.deleted = deleted; - this.destroyedAtRound = destroyedAtRound; - this.attribute_map = { - index: 'index', - params: 'params', - createdAtRound: 'created-at-round', - deleted: 'deleted', - destroyedAtRound: 'destroyed-at-round', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['index'] === 'undefined') - throw new Error(`Response is missing required field 'index': ${data}`); - if (typeof data['params'] === 'undefined') - throw new Error(`Response is missing required field 'params': ${data}`); - return new Asset({ - index: data['index'], - params: AssetParams.from_obj_for_encoding(data['params']), - createdAtRound: data['created-at-round'], - deleted: data['deleted'], - destroyedAtRound: data['destroyed-at-round'], - }); - /* eslint-enable dot-notation */ - } -} -exports.Asset = Asset; -/** - * - */ -class AssetBalancesResponse extends basemodel_1.default { - /** - * Creates a new `AssetBalancesResponse` object. - * @param balances - - * @param currentRound - Round at which the results were computed. - * @param nextToken - Used for pagination, when making another request provide this token with the - * next parameter. - */ - constructor({ balances, currentRound, nextToken, }) { - super(); - this.balances = balances; - this.currentRound = currentRound; - this.nextToken = nextToken; - this.attribute_map = { - balances: 'balances', - currentRound: 'current-round', - nextToken: 'next-token', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (!Array.isArray(data['balances'])) - throw new Error(`Response is missing required array field 'balances': ${data}`); - if (typeof data['current-round'] === 'undefined') - throw new Error(`Response is missing required field 'current-round': ${data}`); - return new AssetBalancesResponse({ - balances: data['balances'].map(MiniAssetHolding.from_obj_for_encoding), - currentRound: data['current-round'], - nextToken: data['next-token'], - }); - /* eslint-enable dot-notation */ - } -} -exports.AssetBalancesResponse = AssetBalancesResponse; -/** - * Describes an asset held by an account. - * Definition: - * data/basics/userBalance.go : AssetHolding - */ -class AssetHolding extends basemodel_1.default { - /** - * Creates a new `AssetHolding` object. - * @param amount - (a) number of units held. - * @param assetId - Asset ID of the holding. - * @param isFrozen - (f) whether or not the holding is frozen. - * @param deleted - Whether or not the asset holding is currently deleted from its account. - * @param optedInAtRound - Round during which the account opted into this asset holding. - * @param optedOutAtRound - Round during which the account opted out of this asset holding. - */ - constructor({ amount, assetId, isFrozen, deleted, optedInAtRound, optedOutAtRound, }) { - super(); - this.amount = amount; - this.assetId = assetId; - this.isFrozen = isFrozen; - this.deleted = deleted; - this.optedInAtRound = optedInAtRound; - this.optedOutAtRound = optedOutAtRound; - this.attribute_map = { - amount: 'amount', - assetId: 'asset-id', - isFrozen: 'is-frozen', - deleted: 'deleted', - optedInAtRound: 'opted-in-at-round', - optedOutAtRound: 'opted-out-at-round', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['amount'] === 'undefined') - throw new Error(`Response is missing required field 'amount': ${data}`); - if (typeof data['asset-id'] === 'undefined') - throw new Error(`Response is missing required field 'asset-id': ${data}`); - if (typeof data['is-frozen'] === 'undefined') - throw new Error(`Response is missing required field 'is-frozen': ${data}`); - return new AssetHolding({ - amount: data['amount'], - assetId: data['asset-id'], - isFrozen: data['is-frozen'], - deleted: data['deleted'], - optedInAtRound: data['opted-in-at-round'], - optedOutAtRound: data['opted-out-at-round'], - }); - /* eslint-enable dot-notation */ - } -} -exports.AssetHolding = AssetHolding; -/** - * - */ -class AssetHoldingsResponse extends basemodel_1.default { - /** - * Creates a new `AssetHoldingsResponse` object. - * @param assets - - * @param currentRound - Round at which the results were computed. - * @param nextToken - Used for pagination, when making another request provide this token with the - * next parameter. - */ - constructor({ assets, currentRound, nextToken, }) { - super(); - this.assets = assets; - this.currentRound = currentRound; - this.nextToken = nextToken; - this.attribute_map = { - assets: 'assets', - currentRound: 'current-round', - nextToken: 'next-token', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (!Array.isArray(data['assets'])) - throw new Error(`Response is missing required array field 'assets': ${data}`); - if (typeof data['current-round'] === 'undefined') - throw new Error(`Response is missing required field 'current-round': ${data}`); - return new AssetHoldingsResponse({ - assets: data['assets'].map(AssetHolding.from_obj_for_encoding), - currentRound: data['current-round'], - nextToken: data['next-token'], - }); - /* eslint-enable dot-notation */ - } -} -exports.AssetHoldingsResponse = AssetHoldingsResponse; -/** - * AssetParams specifies the parameters for an asset. - * (apar) when part of an AssetConfig transaction. - * Definition: - * data/transactions/asset.go : AssetParams - */ -class AssetParams extends basemodel_1.default { - /** - * Creates a new `AssetParams` object. - * @param creator - The address that created this asset. This is the address where the parameters - * for this asset can be found, and also the address where unwanted asset units can - * be sent in the worst case. - * @param decimals - (dc) The number of digits to use after the decimal point when displaying this - * asset. If 0, the asset is not divisible. If 1, the base unit of the asset is in - * tenths. If 2, the base unit of the asset is in hundredths, and so on. This value - * must be between 0 and 19 (inclusive). - * @param total - (t) The total number of units of this asset. - * @param clawback - (c) Address of account used to clawback holdings of this asset. If empty, - * clawback is not permitted. - * @param defaultFrozen - (df) Whether holdings of this asset are frozen by default. - * @param freeze - (f) Address of account used to freeze holdings of this asset. If empty, freezing - * is not permitted. - * @param manager - (m) Address of account used to manage the keys of this asset and to destroy it. - * @param metadataHash - (am) A commitment to some unspecified asset metadata. The format of this - * metadata is up to the application. - * @param name - (an) Name of this asset, as supplied by the creator. Included only when the - * asset name is composed of printable utf-8 characters. - * @param nameB64 - Base64 encoded name of this asset, as supplied by the creator. - * @param reserve - (r) Address of account holding reserve (non-minted) units of this asset. - * @param unitName - (un) Name of a unit of this asset, as supplied by the creator. Included only - * when the name of a unit of this asset is composed of printable utf-8 characters. - * @param unitNameB64 - Base64 encoded name of a unit of this asset, as supplied by the creator. - * @param url - (au) URL where more information about the asset can be retrieved. Included only - * when the URL is composed of printable utf-8 characters. - * @param urlB64 - Base64 encoded URL where more information about the asset can be retrieved. - */ - constructor({ creator, decimals, total, clawback, defaultFrozen, freeze, manager, metadataHash, name, nameB64, reserve, unitName, unitNameB64, url, urlB64, }) { - super(); - this.creator = creator; - this.decimals = decimals; - this.total = total; - this.clawback = clawback; - this.defaultFrozen = defaultFrozen; - this.freeze = freeze; - this.manager = manager; - this.metadataHash = - typeof metadataHash === 'string' - ? (0, binarydata_1.base64ToBytes)(metadataHash) - : metadataHash; - this.name = name; - this.nameB64 = - typeof nameB64 === 'string' ? (0, binarydata_1.base64ToBytes)(nameB64) : nameB64; - this.reserve = reserve; - this.unitName = unitName; - this.unitNameB64 = - typeof unitNameB64 === 'string' - ? (0, binarydata_1.base64ToBytes)(unitNameB64) - : unitNameB64; - this.url = url; - this.urlB64 = typeof urlB64 === 'string' ? (0, binarydata_1.base64ToBytes)(urlB64) : urlB64; - this.attribute_map = { - creator: 'creator', - decimals: 'decimals', - total: 'total', - clawback: 'clawback', - defaultFrozen: 'default-frozen', - freeze: 'freeze', - manager: 'manager', - metadataHash: 'metadata-hash', - name: 'name', - nameB64: 'name-b64', - reserve: 'reserve', - unitName: 'unit-name', - unitNameB64: 'unit-name-b64', - url: 'url', - urlB64: 'url-b64', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['creator'] === 'undefined') - throw new Error(`Response is missing required field 'creator': ${data}`); - if (typeof data['decimals'] === 'undefined') - throw new Error(`Response is missing required field 'decimals': ${data}`); - if (typeof data['total'] === 'undefined') - throw new Error(`Response is missing required field 'total': ${data}`); - return new AssetParams({ - creator: data['creator'], - decimals: data['decimals'], - total: data['total'], - clawback: data['clawback'], - defaultFrozen: data['default-frozen'], - freeze: data['freeze'], - manager: data['manager'], - metadataHash: data['metadata-hash'], - name: data['name'], - nameB64: data['name-b64'], - reserve: data['reserve'], - unitName: data['unit-name'], - unitNameB64: data['unit-name-b64'], - url: data['url'], - urlB64: data['url-b64'], - }); - /* eslint-enable dot-notation */ - } -} -exports.AssetParams = AssetParams; -/** - * - */ -class AssetResponse extends basemodel_1.default { - /** - * Creates a new `AssetResponse` object. - * @param asset - Specifies both the unique identifier and the parameters for an asset - * @param currentRound - Round at which the results were computed. - */ - constructor({ asset, currentRound, }) { - super(); - this.asset = asset; - this.currentRound = currentRound; - this.attribute_map = { - asset: 'asset', - currentRound: 'current-round', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['asset'] === 'undefined') - throw new Error(`Response is missing required field 'asset': ${data}`); - if (typeof data['current-round'] === 'undefined') - throw new Error(`Response is missing required field 'current-round': ${data}`); - return new AssetResponse({ - asset: Asset.from_obj_for_encoding(data['asset']), - currentRound: data['current-round'], - }); - /* eslint-enable dot-notation */ - } -} -exports.AssetResponse = AssetResponse; -/** - * - */ -class AssetsResponse extends basemodel_1.default { - /** - * Creates a new `AssetsResponse` object. - * @param assets - - * @param currentRound - Round at which the results were computed. - * @param nextToken - Used for pagination, when making another request provide this token with the - * next parameter. - */ - constructor({ assets, currentRound, nextToken, }) { - super(); - this.assets = assets; - this.currentRound = currentRound; - this.nextToken = nextToken; - this.attribute_map = { - assets: 'assets', - currentRound: 'current-round', - nextToken: 'next-token', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (!Array.isArray(data['assets'])) - throw new Error(`Response is missing required array field 'assets': ${data}`); - if (typeof data['current-round'] === 'undefined') - throw new Error(`Response is missing required field 'current-round': ${data}`); - return new AssetsResponse({ - assets: data['assets'].map(Asset.from_obj_for_encoding), - currentRound: data['current-round'], - nextToken: data['next-token'], - }); - /* eslint-enable dot-notation */ - } -} -exports.AssetsResponse = AssetsResponse; -/** - * Block information. - * Definition: - * data/bookkeeping/block.go : Block - */ -class Block extends basemodel_1.default { - /** - * Creates a new `Block` object. - * @param genesisHash - (gh) hash to which this block belongs. - * @param genesisId - (gen) ID to which this block belongs. - * @param previousBlockHash - (prev) Previous block hash. - * @param round - (rnd) Current round on which this block was appended to the chain. - * @param seed - (seed) Sortition seed. - * @param timestamp - (ts) Block creation timestamp in seconds since eposh - * @param transactionsRoot - (txn) TransactionsRoot authenticates the set of transactions appearing in the - * block. More specifically, it's the root of a merkle tree whose leaves are the - * block's Txids, in lexicographic order. For the empty block, it's 0. Note that - * the TxnRoot does not authenticate the signatures on the transactions, only the - * transactions themselves. Two blocks with the same transactions but in a - * different order and with different signatures will have the same TxnRoot. - * @param transactionsRootSha256 - (txn256) TransactionsRootSHA256 is an auxiliary TransactionRoot, built using a - * vector commitment instead of a merkle tree, and SHA256 hash function instead of - * the default SHA512_256. This commitment can be used on environments where only - * the SHA256 function exists. - * @param participationUpdates - Participation account data that needs to be checked/acted on by the network. - * @param rewards - Fields relating to rewards, - * @param stateProofTracking - Tracks the status of state proofs. - * @param transactions - (txns) list of transactions corresponding to a given round. - * @param txnCounter - (tc) TxnCounter counts the number of transactions committed in the ledger, from - * the time at which support for this feature was introduced. - * Specifically, TxnCounter is the number of the next transaction that will be - * committed after this block. It is 0 when no transactions have ever been - * committed (since TxnCounter started being supported). - * @param upgradeState - Fields relating to a protocol upgrade. - * @param upgradeVote - Fields relating to voting for a protocol upgrade. - */ - constructor({ genesisHash, genesisId, previousBlockHash, round, seed, timestamp, transactionsRoot, transactionsRootSha256, participationUpdates, rewards, stateProofTracking, transactions, txnCounter, upgradeState, upgradeVote, }) { - super(); - this.genesisHash = - typeof genesisHash === 'string' - ? (0, binarydata_1.base64ToBytes)(genesisHash) - : genesisHash; - this.genesisId = genesisId; - this.previousBlockHash = - typeof previousBlockHash === 'string' - ? (0, binarydata_1.base64ToBytes)(previousBlockHash) - : previousBlockHash; - this.round = round; - this.seed = typeof seed === 'string' ? (0, binarydata_1.base64ToBytes)(seed) : seed; - this.timestamp = timestamp; - this.transactionsRoot = - typeof transactionsRoot === 'string' - ? (0, binarydata_1.base64ToBytes)(transactionsRoot) - : transactionsRoot; - this.transactionsRootSha256 = - typeof transactionsRootSha256 === 'string' - ? (0, binarydata_1.base64ToBytes)(transactionsRootSha256) - : transactionsRootSha256; - this.participationUpdates = participationUpdates; - this.rewards = rewards; - this.stateProofTracking = stateProofTracking; - this.transactions = transactions; - this.txnCounter = txnCounter; - this.upgradeState = upgradeState; - this.upgradeVote = upgradeVote; - this.attribute_map = { - genesisHash: 'genesis-hash', - genesisId: 'genesis-id', - previousBlockHash: 'previous-block-hash', - round: 'round', - seed: 'seed', - timestamp: 'timestamp', - transactionsRoot: 'transactions-root', - transactionsRootSha256: 'transactions-root-sha256', - participationUpdates: 'participation-updates', - rewards: 'rewards', - stateProofTracking: 'state-proof-tracking', - transactions: 'transactions', - txnCounter: 'txn-counter', - upgradeState: 'upgrade-state', - upgradeVote: 'upgrade-vote', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['genesis-hash'] === 'undefined') - throw new Error(`Response is missing required field 'genesis-hash': ${data}`); - if (typeof data['genesis-id'] === 'undefined') - throw new Error(`Response is missing required field 'genesis-id': ${data}`); - if (typeof data['previous-block-hash'] === 'undefined') - throw new Error(`Response is missing required field 'previous-block-hash': ${data}`); - if (typeof data['round'] === 'undefined') - throw new Error(`Response is missing required field 'round': ${data}`); - if (typeof data['seed'] === 'undefined') - throw new Error(`Response is missing required field 'seed': ${data}`); - if (typeof data['timestamp'] === 'undefined') - throw new Error(`Response is missing required field 'timestamp': ${data}`); - if (typeof data['transactions-root'] === 'undefined') - throw new Error(`Response is missing required field 'transactions-root': ${data}`); - if (typeof data['transactions-root-sha256'] === 'undefined') - throw new Error(`Response is missing required field 'transactions-root-sha256': ${data}`); - return new Block({ - genesisHash: data['genesis-hash'], - genesisId: data['genesis-id'], - previousBlockHash: data['previous-block-hash'], - round: data['round'], - seed: data['seed'], - timestamp: data['timestamp'], - transactionsRoot: data['transactions-root'], - transactionsRootSha256: data['transactions-root-sha256'], - participationUpdates: typeof data['participation-updates'] !== 'undefined' - ? ParticipationUpdates.from_obj_for_encoding(data['participation-updates']) - : undefined, - rewards: typeof data['rewards'] !== 'undefined' - ? BlockRewards.from_obj_for_encoding(data['rewards']) - : undefined, - stateProofTracking: typeof data['state-proof-tracking'] !== 'undefined' - ? data['state-proof-tracking'].map(StateProofTracking.from_obj_for_encoding) - : undefined, - transactions: typeof data['transactions'] !== 'undefined' - ? data['transactions'].map(Transaction.from_obj_for_encoding) - : undefined, - txnCounter: data['txn-counter'], - upgradeState: typeof data['upgrade-state'] !== 'undefined' - ? BlockUpgradeState.from_obj_for_encoding(data['upgrade-state']) - : undefined, - upgradeVote: typeof data['upgrade-vote'] !== 'undefined' - ? BlockUpgradeVote.from_obj_for_encoding(data['upgrade-vote']) - : undefined, - }); - /* eslint-enable dot-notation */ - } -} -exports.Block = Block; -/** - * Fields relating to rewards, - */ -class BlockRewards extends basemodel_1.default { - /** - * Creates a new `BlockRewards` object. - * @param feeSink - (fees) accepts transaction fees, it can only spend to the incentive pool. - * @param rewardsCalculationRound - (rwcalr) number of leftover MicroAlgos after the distribution of rewards-rate - * MicroAlgos for every reward unit in the next round. - * @param rewardsLevel - (earn) How many rewards, in MicroAlgos, have been distributed to each RewardUnit - * of MicroAlgos since genesis. - * @param rewardsPool - (rwd) accepts periodic injections from the fee-sink and continually - * redistributes them as rewards. - * @param rewardsRate - (rate) Number of new MicroAlgos added to the participation stake from rewards at - * the next round. - * @param rewardsResidue - (frac) Number of leftover MicroAlgos after the distribution of - * RewardsRate/rewardUnits MicroAlgos for every reward unit in the next round. - */ - constructor({ feeSink, rewardsCalculationRound, rewardsLevel, rewardsPool, rewardsRate, rewardsResidue, }) { - super(); - this.feeSink = feeSink; - this.rewardsCalculationRound = rewardsCalculationRound; - this.rewardsLevel = rewardsLevel; - this.rewardsPool = rewardsPool; - this.rewardsRate = rewardsRate; - this.rewardsResidue = rewardsResidue; - this.attribute_map = { - feeSink: 'fee-sink', - rewardsCalculationRound: 'rewards-calculation-round', - rewardsLevel: 'rewards-level', - rewardsPool: 'rewards-pool', - rewardsRate: 'rewards-rate', - rewardsResidue: 'rewards-residue', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['fee-sink'] === 'undefined') - throw new Error(`Response is missing required field 'fee-sink': ${data}`); - if (typeof data['rewards-calculation-round'] === 'undefined') - throw new Error(`Response is missing required field 'rewards-calculation-round': ${data}`); - if (typeof data['rewards-level'] === 'undefined') - throw new Error(`Response is missing required field 'rewards-level': ${data}`); - if (typeof data['rewards-pool'] === 'undefined') - throw new Error(`Response is missing required field 'rewards-pool': ${data}`); - if (typeof data['rewards-rate'] === 'undefined') - throw new Error(`Response is missing required field 'rewards-rate': ${data}`); - if (typeof data['rewards-residue'] === 'undefined') - throw new Error(`Response is missing required field 'rewards-residue': ${data}`); - return new BlockRewards({ - feeSink: data['fee-sink'], - rewardsCalculationRound: data['rewards-calculation-round'], - rewardsLevel: data['rewards-level'], - rewardsPool: data['rewards-pool'], - rewardsRate: data['rewards-rate'], - rewardsResidue: data['rewards-residue'], - }); - /* eslint-enable dot-notation */ - } -} -exports.BlockRewards = BlockRewards; -/** - * Fields relating to a protocol upgrade. - */ -class BlockUpgradeState extends basemodel_1.default { - /** - * Creates a new `BlockUpgradeState` object. - * @param currentProtocol - (proto) The current protocol version. - * @param nextProtocol - (nextproto) The next proposed protocol version. - * @param nextProtocolApprovals - (nextyes) Number of blocks which approved the protocol upgrade. - * @param nextProtocolSwitchOn - (nextswitch) Round on which the protocol upgrade will take effect. - * @param nextProtocolVoteBefore - (nextbefore) Deadline round for this protocol upgrade (No votes will be consider - * after this round). - */ - constructor({ currentProtocol, nextProtocol, nextProtocolApprovals, nextProtocolSwitchOn, nextProtocolVoteBefore, }) { - super(); - this.currentProtocol = currentProtocol; - this.nextProtocol = nextProtocol; - this.nextProtocolApprovals = nextProtocolApprovals; - this.nextProtocolSwitchOn = nextProtocolSwitchOn; - this.nextProtocolVoteBefore = nextProtocolVoteBefore; - this.attribute_map = { - currentProtocol: 'current-protocol', - nextProtocol: 'next-protocol', - nextProtocolApprovals: 'next-protocol-approvals', - nextProtocolSwitchOn: 'next-protocol-switch-on', - nextProtocolVoteBefore: 'next-protocol-vote-before', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['current-protocol'] === 'undefined') - throw new Error(`Response is missing required field 'current-protocol': ${data}`); - return new BlockUpgradeState({ - currentProtocol: data['current-protocol'], - nextProtocol: data['next-protocol'], - nextProtocolApprovals: data['next-protocol-approvals'], - nextProtocolSwitchOn: data['next-protocol-switch-on'], - nextProtocolVoteBefore: data['next-protocol-vote-before'], - }); - /* eslint-enable dot-notation */ - } -} -exports.BlockUpgradeState = BlockUpgradeState; -/** - * Fields relating to voting for a protocol upgrade. - */ -class BlockUpgradeVote extends basemodel_1.default { - /** - * Creates a new `BlockUpgradeVote` object. - * @param upgradeApprove - (upgradeyes) Indicates a yes vote for the current proposal. - * @param upgradeDelay - (upgradedelay) Indicates the time between acceptance and execution. - * @param upgradePropose - (upgradeprop) Indicates a proposed upgrade. - */ - constructor({ upgradeApprove, upgradeDelay, upgradePropose, }) { - super(); - this.upgradeApprove = upgradeApprove; - this.upgradeDelay = upgradeDelay; - this.upgradePropose = upgradePropose; - this.attribute_map = { - upgradeApprove: 'upgrade-approve', - upgradeDelay: 'upgrade-delay', - upgradePropose: 'upgrade-propose', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - return new BlockUpgradeVote({ - upgradeApprove: data['upgrade-approve'], - upgradeDelay: data['upgrade-delay'], - upgradePropose: data['upgrade-propose'], - }); - /* eslint-enable dot-notation */ - } -} -exports.BlockUpgradeVote = BlockUpgradeVote; -/** - * Box name and its content. - */ -class Box extends basemodel_1.default { - /** - * Creates a new `Box` object. - * @param name - (name) box name, base64 encoded - * @param round - The round for which this information is relevant - * @param value - (value) box value, base64 encoded. - */ - constructor({ name, round, value, }) { - super(); - this.name = typeof name === 'string' ? (0, binarydata_1.base64ToBytes)(name) : name; - this.round = round; - this.value = typeof value === 'string' ? (0, binarydata_1.base64ToBytes)(value) : value; - this.attribute_map = { - name: 'name', - round: 'round', - value: 'value', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['name'] === 'undefined') - throw new Error(`Response is missing required field 'name': ${data}`); - if (typeof data['round'] === 'undefined') - throw new Error(`Response is missing required field 'round': ${data}`); - if (typeof data['value'] === 'undefined') - throw new Error(`Response is missing required field 'value': ${data}`); - return new Box({ - name: data['name'], - round: data['round'], - value: data['value'], - }); - /* eslint-enable dot-notation */ - } -} -exports.Box = Box; -/** - * Box descriptor describes an app box without a value. - */ -class BoxDescriptor extends basemodel_1.default { - /** - * Creates a new `BoxDescriptor` object. - * @param name - Base64 encoded box name - */ - constructor({ name }) { - super(); - this.name = typeof name === 'string' ? (0, binarydata_1.base64ToBytes)(name) : name; - this.attribute_map = { - name: 'name', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['name'] === 'undefined') - throw new Error(`Response is missing required field 'name': ${data}`); - return new BoxDescriptor({ - name: data['name'], - }); - /* eslint-enable dot-notation */ - } -} -exports.BoxDescriptor = BoxDescriptor; -/** - * Box names of an application - */ -class BoxesResponse extends basemodel_1.default { - /** - * Creates a new `BoxesResponse` object. - * @param applicationId - (appidx) application index. - * @param boxes - - * @param nextToken - Used for pagination, when making another request provide this token with the - * next parameter. - */ - constructor({ applicationId, boxes, nextToken, }) { - super(); - this.applicationId = applicationId; - this.boxes = boxes; - this.nextToken = nextToken; - this.attribute_map = { - applicationId: 'application-id', - boxes: 'boxes', - nextToken: 'next-token', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['application-id'] === 'undefined') - throw new Error(`Response is missing required field 'application-id': ${data}`); - if (!Array.isArray(data['boxes'])) - throw new Error(`Response is missing required array field 'boxes': ${data}`); - return new BoxesResponse({ - applicationId: data['application-id'], - boxes: data['boxes'].map(BoxDescriptor.from_obj_for_encoding), - nextToken: data['next-token'], - }); - /* eslint-enable dot-notation */ - } -} -exports.BoxesResponse = BoxesResponse; -/** - * Response for errors - */ -class ErrorResponse extends basemodel_1.default { - /** - * Creates a new `ErrorResponse` object. - * @param message - - * @param data - - */ - constructor({ message, data, }) { - super(); - this.message = message; - this.data = data; - this.attribute_map = { - message: 'message', - data: 'data', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['message'] === 'undefined') - throw new Error(`Response is missing required field 'message': ${data}`); - return new ErrorResponse({ - message: data['message'], - data: data['data'], - }); - /* eslint-enable dot-notation */ - } -} -exports.ErrorResponse = ErrorResponse; -/** - * Represents a TEAL value delta. - */ -class EvalDelta extends basemodel_1.default { - /** - * Creates a new `EvalDelta` object. - * @param action - (at) delta action. - * @param bytes - (bs) bytes value. - * @param uint - (ui) uint value. - */ - constructor({ action, bytes, uint, }) { - super(); - this.action = action; - this.bytes = bytes; - this.uint = uint; - this.attribute_map = { - action: 'action', - bytes: 'bytes', - uint: 'uint', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['action'] === 'undefined') - throw new Error(`Response is missing required field 'action': ${data}`); - return new EvalDelta({ - action: data['action'], - bytes: data['bytes'], - uint: data['uint'], - }); - /* eslint-enable dot-notation */ - } -} -exports.EvalDelta = EvalDelta; -/** - * Key-value pairs for StateDelta. - */ -class EvalDeltaKeyValue extends basemodel_1.default { - /** - * Creates a new `EvalDeltaKeyValue` object. - * @param key - - * @param value - Represents a TEAL value delta. - */ - constructor({ key, value }) { - super(); - this.key = key; - this.value = value; - this.attribute_map = { - key: 'key', - value: 'value', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['key'] === 'undefined') - throw new Error(`Response is missing required field 'key': ${data}`); - if (typeof data['value'] === 'undefined') - throw new Error(`Response is missing required field 'value': ${data}`); - return new EvalDeltaKeyValue({ - key: data['key'], - value: EvalDelta.from_obj_for_encoding(data['value']), - }); - /* eslint-enable dot-notation */ - } -} -exports.EvalDeltaKeyValue = EvalDeltaKeyValue; -class HashFactory extends basemodel_1.default { - /** - * Creates a new `HashFactory` object. - * @param hashType - (t) - */ - constructor({ hashType }) { - super(); - this.hashType = hashType; - this.attribute_map = { - hashType: 'hash-type', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - return new HashFactory({ - hashType: data['hash-type'], - }); - /* eslint-enable dot-notation */ - } -} -exports.HashFactory = HashFactory; -/** - * A health check response. - */ -class HealthCheck extends basemodel_1.default { - /** - * Creates a new `HealthCheck` object. - * @param dbAvailable - - * @param isMigrating - - * @param message - - * @param round - - * @param version - Current version. - * @param data - - * @param errors - - */ - constructor({ dbAvailable, isMigrating, message, round, version, data, errors, }) { - super(); - this.dbAvailable = dbAvailable; - this.isMigrating = isMigrating; - this.message = message; - this.round = round; - this.version = version; - this.data = data; - this.errors = errors; - this.attribute_map = { - dbAvailable: 'db-available', - isMigrating: 'is-migrating', - message: 'message', - round: 'round', - version: 'version', - data: 'data', - errors: 'errors', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['db-available'] === 'undefined') - throw new Error(`Response is missing required field 'db-available': ${data}`); - if (typeof data['is-migrating'] === 'undefined') - throw new Error(`Response is missing required field 'is-migrating': ${data}`); - if (typeof data['message'] === 'undefined') - throw new Error(`Response is missing required field 'message': ${data}`); - if (typeof data['round'] === 'undefined') - throw new Error(`Response is missing required field 'round': ${data}`); - if (typeof data['version'] === 'undefined') - throw new Error(`Response is missing required field 'version': ${data}`); - return new HealthCheck({ - dbAvailable: data['db-available'], - isMigrating: data['is-migrating'], - message: data['message'], - round: data['round'], - version: data['version'], - data: data['data'], - errors: data['errors'], - }); - /* eslint-enable dot-notation */ - } -} -exports.HealthCheck = HealthCheck; -class IndexerStateProofMessage extends basemodel_1.default { - /** - * Creates a new `IndexerStateProofMessage` object. - * @param blockHeadersCommitment - (b) - * @param firstAttestedRound - (f) - * @param latestAttestedRound - (l) - * @param lnProvenWeight - (P) - * @param votersCommitment - (v) - */ - constructor({ blockHeadersCommitment, firstAttestedRound, latestAttestedRound, lnProvenWeight, votersCommitment, }) { - super(); - this.blockHeadersCommitment = - typeof blockHeadersCommitment === 'string' - ? (0, binarydata_1.base64ToBytes)(blockHeadersCommitment) - : blockHeadersCommitment; - this.firstAttestedRound = firstAttestedRound; - this.latestAttestedRound = latestAttestedRound; - this.lnProvenWeight = lnProvenWeight; - this.votersCommitment = - typeof votersCommitment === 'string' - ? (0, binarydata_1.base64ToBytes)(votersCommitment) - : votersCommitment; - this.attribute_map = { - blockHeadersCommitment: 'block-headers-commitment', - firstAttestedRound: 'first-attested-round', - latestAttestedRound: 'latest-attested-round', - lnProvenWeight: 'ln-proven-weight', - votersCommitment: 'voters-commitment', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - return new IndexerStateProofMessage({ - blockHeadersCommitment: data['block-headers-commitment'], - firstAttestedRound: data['first-attested-round'], - latestAttestedRound: data['latest-attested-round'], - lnProvenWeight: data['ln-proven-weight'], - votersCommitment: data['voters-commitment'], - }); - /* eslint-enable dot-notation */ - } -} -exports.IndexerStateProofMessage = IndexerStateProofMessage; -class MerkleArrayProof extends basemodel_1.default { - /** - * Creates a new `MerkleArrayProof` object. - * @param hashFactory - - * @param path - (pth) - * @param treeDepth - (td) - */ - constructor({ hashFactory, path, treeDepth, }) { - super(); - this.hashFactory = hashFactory; - this.path = path; - this.treeDepth = treeDepth; - this.attribute_map = { - hashFactory: 'hash-factory', - path: 'path', - treeDepth: 'tree-depth', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - return new MerkleArrayProof({ - hashFactory: typeof data['hash-factory'] !== 'undefined' - ? HashFactory.from_obj_for_encoding(data['hash-factory']) - : undefined, - path: data['path'], - treeDepth: data['tree-depth'], - }); - /* eslint-enable dot-notation */ - } -} -exports.MerkleArrayProof = MerkleArrayProof; -/** - * A simplified version of AssetHolding - */ -class MiniAssetHolding extends basemodel_1.default { - /** - * Creates a new `MiniAssetHolding` object. - * @param address - - * @param amount - - * @param isFrozen - - * @param deleted - Whether or not this asset holding is currently deleted from its account. - * @param optedInAtRound - Round during which the account opted into the asset. - * @param optedOutAtRound - Round during which the account opted out of the asset. - */ - constructor({ address, amount, isFrozen, deleted, optedInAtRound, optedOutAtRound, }) { - super(); - this.address = address; - this.amount = amount; - this.isFrozen = isFrozen; - this.deleted = deleted; - this.optedInAtRound = optedInAtRound; - this.optedOutAtRound = optedOutAtRound; - this.attribute_map = { - address: 'address', - amount: 'amount', - isFrozen: 'is-frozen', - deleted: 'deleted', - optedInAtRound: 'opted-in-at-round', - optedOutAtRound: 'opted-out-at-round', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['address'] === 'undefined') - throw new Error(`Response is missing required field 'address': ${data}`); - if (typeof data['amount'] === 'undefined') - throw new Error(`Response is missing required field 'amount': ${data}`); - if (typeof data['is-frozen'] === 'undefined') - throw new Error(`Response is missing required field 'is-frozen': ${data}`); - return new MiniAssetHolding({ - address: data['address'], - amount: data['amount'], - isFrozen: data['is-frozen'], - deleted: data['deleted'], - optedInAtRound: data['opted-in-at-round'], - optedOutAtRound: data['opted-out-at-round'], - }); - /* eslint-enable dot-notation */ - } -} -exports.MiniAssetHolding = MiniAssetHolding; -/** - * Participation account data that needs to be checked/acted on by the network. - */ -class ParticipationUpdates extends basemodel_1.default { - /** - * Creates a new `ParticipationUpdates` object. - * @param expiredParticipationAccounts - (partupdrmv) a list of online accounts that needs to be converted to offline - * since their participation key expired. - */ - constructor({ expiredParticipationAccounts, }) { - super(); - this.expiredParticipationAccounts = expiredParticipationAccounts; - this.attribute_map = { - expiredParticipationAccounts: 'expired-participation-accounts', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - return new ParticipationUpdates({ - expiredParticipationAccounts: data['expired-participation-accounts'], - }); - /* eslint-enable dot-notation */ - } -} -exports.ParticipationUpdates = ParticipationUpdates; -/** - * (sp) represents a state proof. - * Definition: - * crypto/stateproof/structs.go : StateProof - */ -class StateProofFields extends basemodel_1.default { - /** - * Creates a new `StateProofFields` object. - * @param partProofs - (P) - * @param positionsToReveal - (pr) Sequence of reveal positions. - * @param reveals - (r) Note that this is actually stored as a map[uint64] - Reveal in the actual - * msgp - * @param saltVersion - (v) Salt version of the merkle signature. - * @param sigCommit - (c) - * @param sigProofs - (S) - * @param signedWeight - (w) - */ - constructor({ partProofs, positionsToReveal, reveals, saltVersion, sigCommit, sigProofs, signedWeight, }) { - super(); - this.partProofs = partProofs; - this.positionsToReveal = positionsToReveal; - this.reveals = reveals; - this.saltVersion = saltVersion; - this.sigCommit = - typeof sigCommit === 'string' ? (0, binarydata_1.base64ToBytes)(sigCommit) : sigCommit; - this.sigProofs = sigProofs; - this.signedWeight = signedWeight; - this.attribute_map = { - partProofs: 'part-proofs', - positionsToReveal: 'positions-to-reveal', - reveals: 'reveals', - saltVersion: 'salt-version', - sigCommit: 'sig-commit', - sigProofs: 'sig-proofs', - signedWeight: 'signed-weight', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - return new StateProofFields({ - partProofs: typeof data['part-proofs'] !== 'undefined' - ? MerkleArrayProof.from_obj_for_encoding(data['part-proofs']) - : undefined, - positionsToReveal: data['positions-to-reveal'], - reveals: typeof data['reveals'] !== 'undefined' - ? data['reveals'].map(StateProofReveal.from_obj_for_encoding) - : undefined, - saltVersion: data['salt-version'], - sigCommit: data['sig-commit'], - sigProofs: typeof data['sig-proofs'] !== 'undefined' - ? MerkleArrayProof.from_obj_for_encoding(data['sig-proofs']) - : undefined, - signedWeight: data['signed-weight'], - }); - /* eslint-enable dot-notation */ - } -} -exports.StateProofFields = StateProofFields; -class StateProofParticipant extends basemodel_1.default { - /** - * Creates a new `StateProofParticipant` object. - * @param verifier - (p) - * @param weight - (w) - */ - constructor({ verifier, weight, }) { - super(); - this.verifier = verifier; - this.weight = weight; - this.attribute_map = { - verifier: 'verifier', - weight: 'weight', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - return new StateProofParticipant({ - verifier: typeof data['verifier'] !== 'undefined' - ? StateProofVerifier.from_obj_for_encoding(data['verifier']) - : undefined, - weight: data['weight'], - }); - /* eslint-enable dot-notation */ - } -} -exports.StateProofParticipant = StateProofParticipant; -class StateProofReveal extends basemodel_1.default { - /** - * Creates a new `StateProofReveal` object. - * @param participant - (p) - * @param position - The position in the signature and participants arrays corresponding to this - * entry. - * @param sigSlot - (s) - */ - constructor({ participant, position, sigSlot, }) { - super(); - this.participant = participant; - this.position = position; - this.sigSlot = sigSlot; - this.attribute_map = { - participant: 'participant', - position: 'position', - sigSlot: 'sig-slot', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - return new StateProofReveal({ - participant: typeof data['participant'] !== 'undefined' - ? StateProofParticipant.from_obj_for_encoding(data['participant']) - : undefined, - position: data['position'], - sigSlot: typeof data['sig-slot'] !== 'undefined' - ? StateProofSigSlot.from_obj_for_encoding(data['sig-slot']) - : undefined, - }); - /* eslint-enable dot-notation */ - } -} -exports.StateProofReveal = StateProofReveal; -class StateProofSigSlot extends basemodel_1.default { - /** - * Creates a new `StateProofSigSlot` object. - * @param lowerSigWeight - (l) The total weight of signatures in the lower-numbered slots. - * @param signature - - */ - constructor({ lowerSigWeight, signature, }) { - super(); - this.lowerSigWeight = lowerSigWeight; - this.signature = signature; - this.attribute_map = { - lowerSigWeight: 'lower-sig-weight', - signature: 'signature', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - return new StateProofSigSlot({ - lowerSigWeight: data['lower-sig-weight'], - signature: typeof data['signature'] !== 'undefined' - ? StateProofSignature.from_obj_for_encoding(data['signature']) - : undefined, - }); - /* eslint-enable dot-notation */ - } -} -exports.StateProofSigSlot = StateProofSigSlot; -class StateProofSignature extends basemodel_1.default { - /** - * Creates a new `StateProofSignature` object. - * @param falconSignature - - * @param merkleArrayIndex - - * @param proof - - * @param verifyingKey - (vkey) - */ - constructor({ falconSignature, merkleArrayIndex, proof, verifyingKey, }) { - super(); - this.falconSignature = - typeof falconSignature === 'string' - ? (0, binarydata_1.base64ToBytes)(falconSignature) - : falconSignature; - this.merkleArrayIndex = merkleArrayIndex; - this.proof = proof; - this.verifyingKey = - typeof verifyingKey === 'string' - ? (0, binarydata_1.base64ToBytes)(verifyingKey) - : verifyingKey; - this.attribute_map = { - falconSignature: 'falcon-signature', - merkleArrayIndex: 'merkle-array-index', - proof: 'proof', - verifyingKey: 'verifying-key', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - return new StateProofSignature({ - falconSignature: data['falcon-signature'], - merkleArrayIndex: data['merkle-array-index'], - proof: typeof data['proof'] !== 'undefined' - ? MerkleArrayProof.from_obj_for_encoding(data['proof']) - : undefined, - verifyingKey: data['verifying-key'], - }); - /* eslint-enable dot-notation */ - } -} -exports.StateProofSignature = StateProofSignature; -class StateProofTracking extends basemodel_1.default { - /** - * Creates a new `StateProofTracking` object. - * @param nextRound - (n) Next round for which we will accept a state proof transaction. - * @param onlineTotalWeight - (t) The total number of microalgos held by the online accounts during the - * StateProof round. - * @param type - State Proof Type. Note the raw object uses map with this as key. - * @param votersCommitment - (v) Root of a vector commitment containing online accounts that will help sign - * the proof. - */ - constructor({ nextRound, onlineTotalWeight, type, votersCommitment, }) { - super(); - this.nextRound = nextRound; - this.onlineTotalWeight = onlineTotalWeight; - this.type = type; - this.votersCommitment = - typeof votersCommitment === 'string' - ? (0, binarydata_1.base64ToBytes)(votersCommitment) - : votersCommitment; - this.attribute_map = { - nextRound: 'next-round', - onlineTotalWeight: 'online-total-weight', - type: 'type', - votersCommitment: 'voters-commitment', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - return new StateProofTracking({ - nextRound: data['next-round'], - onlineTotalWeight: data['online-total-weight'], - type: data['type'], - votersCommitment: data['voters-commitment'], - }); - /* eslint-enable dot-notation */ - } -} -exports.StateProofTracking = StateProofTracking; -class StateProofVerifier extends basemodel_1.default { - /** - * Creates a new `StateProofVerifier` object. - * @param commitment - (cmt) Represents the root of the vector commitment tree. - * @param keyLifetime - (lf) Key lifetime. - */ - constructor({ commitment, keyLifetime, }) { - super(); - this.commitment = - typeof commitment === 'string' ? (0, binarydata_1.base64ToBytes)(commitment) : commitment; - this.keyLifetime = keyLifetime; - this.attribute_map = { - commitment: 'commitment', - keyLifetime: 'key-lifetime', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - return new StateProofVerifier({ - commitment: data['commitment'], - keyLifetime: data['key-lifetime'], - }); - /* eslint-enable dot-notation */ - } -} -exports.StateProofVerifier = StateProofVerifier; -/** - * Represents a (apls) local-state or (apgs) global-state schema. These schemas - * determine how much storage may be used in a local-state or global-state for an - * application. The more space used, the larger minimum balance must be maintained - * in the account holding the data. - */ -class StateSchema extends basemodel_1.default { - /** - * Creates a new `StateSchema` object. - * @param numByteSlice - Maximum number of TEAL byte slices that may be stored in the key/value store. - * @param numUint - Maximum number of TEAL uints that may be stored in the key/value store. - */ - constructor({ numByteSlice, numUint, }) { - super(); - this.numByteSlice = numByteSlice; - this.numUint = numUint; - this.attribute_map = { - numByteSlice: 'num-byte-slice', - numUint: 'num-uint', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['num-byte-slice'] === 'undefined') - throw new Error(`Response is missing required field 'num-byte-slice': ${data}`); - if (typeof data['num-uint'] === 'undefined') - throw new Error(`Response is missing required field 'num-uint': ${data}`); - return new StateSchema({ - numByteSlice: data['num-byte-slice'], - numUint: data['num-uint'], - }); - /* eslint-enable dot-notation */ - } -} -exports.StateSchema = StateSchema; -/** - * Represents a key-value pair in an application store. - */ -class TealKeyValue extends basemodel_1.default { - /** - * Creates a new `TealKeyValue` object. - * @param key - - * @param value - Represents a TEAL value. - */ - constructor({ key, value }) { - super(); - this.key = key; - this.value = value; - this.attribute_map = { - key: 'key', - value: 'value', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['key'] === 'undefined') - throw new Error(`Response is missing required field 'key': ${data}`); - if (typeof data['value'] === 'undefined') - throw new Error(`Response is missing required field 'value': ${data}`); - return new TealKeyValue({ - key: data['key'], - value: TealValue.from_obj_for_encoding(data['value']), - }); - /* eslint-enable dot-notation */ - } -} -exports.TealKeyValue = TealKeyValue; -/** - * Represents a TEAL value. - */ -class TealValue extends basemodel_1.default { - /** - * Creates a new `TealValue` object. - * @param bytes - (tb) bytes value. - * @param type - (tt) value type. Value `1` refers to **bytes**, value `2` refers to **uint** - * @param uint - (ui) uint value. - */ - constructor({ bytes, type, uint, }) { - super(); - this.bytes = bytes; - this.type = type; - this.uint = uint; - this.attribute_map = { - bytes: 'bytes', - type: 'type', - uint: 'uint', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['bytes'] === 'undefined') - throw new Error(`Response is missing required field 'bytes': ${data}`); - if (typeof data['type'] === 'undefined') - throw new Error(`Response is missing required field 'type': ${data}`); - if (typeof data['uint'] === 'undefined') - throw new Error(`Response is missing required field 'uint': ${data}`); - return new TealValue({ - bytes: data['bytes'], - type: data['type'], - uint: data['uint'], - }); - /* eslint-enable dot-notation */ - } -} -exports.TealValue = TealValue; -/** - * Contains all fields common to all transactions and serves as an envelope to all - * transactions type. Represents both regular and inner transactions. - * Definition: - * data/transactions/signedtxn.go : SignedTxn - * data/transactions/transaction.go : Transaction - */ -class Transaction extends basemodel_1.default { - /** - * Creates a new `Transaction` object. - * @param fee - (fee) Transaction fee. - * @param firstValid - (fv) First valid round for this transaction. - * @param lastValid - (lv) Last valid round for this transaction. - * @param sender - (snd) Sender's address. - * @param applicationTransaction - Fields for application transactions. - * Definition: - * data/transactions/application.go : ApplicationCallTxnFields - * @param assetConfigTransaction - Fields for asset allocation, re-configuration, and destruction. - * A zero value for asset-id indicates asset creation. - * A zero value for the params indicates asset destruction. - * Definition: - * data/transactions/asset.go : AssetConfigTxnFields - * @param assetFreezeTransaction - Fields for an asset freeze transaction. - * Definition: - * data/transactions/asset.go : AssetFreezeTxnFields - * @param assetTransferTransaction - Fields for an asset transfer transaction. - * Definition: - * data/transactions/asset.go : AssetTransferTxnFields - * @param authAddr - (sgnr) this is included with signed transactions when the signing address does - * not equal the sender. The backend can use this to ensure that auth addr is equal - * to the accounts auth addr. - * @param closeRewards - (rc) rewards applied to close-remainder-to account. - * @param closingAmount - (ca) closing amount for transaction. - * @param confirmedRound - Round when the transaction was confirmed. - * @param createdApplicationIndex - Specifies an application index (ID) if an application was created with this - * transaction. - * @param createdAssetIndex - Specifies an asset index (ID) if an asset was created with this transaction. - * @param genesisHash - (gh) Hash of genesis block. - * @param genesisId - (gen) genesis block ID. - * @param globalStateDelta - (gd) Global state key/value changes for the application being executed by this - * transaction. - * @param group - (grp) Base64 encoded byte array of a sha512/256 digest. When present indicates - * that this transaction is part of a transaction group and the value is the - * sha512/256 hash of the transactions in that group. - * @param id - Transaction ID - * @param innerTxns - Inner transactions produced by application execution. - * @param intraRoundOffset - Offset into the round where this transaction was confirmed. - * @param keyregTransaction - Fields for a keyreg transaction. - * Definition: - * data/transactions/keyreg.go : KeyregTxnFields - * @param lease - (lx) Base64 encoded 32-byte array. Lease enforces mutual exclusion of - * transactions. If this field is nonzero, then once the transaction is confirmed, - * it acquires the lease identified by the (Sender, Lease) pair of the transaction - * until the LastValid round passes. While this transaction possesses the lease, no - * other transaction specifying this lease can be confirmed. - * @param localStateDelta - (ld) Local state key/value changes for the application being executed by this - * transaction. - * @param logs - (lg) Logs for the application being executed by this transaction. - * @param note - (note) Free form data. - * @param paymentTransaction - Fields for a payment transaction. - * Definition: - * data/transactions/payment.go : PaymentTxnFields - * @param receiverRewards - (rr) rewards applied to receiver account. - * @param rekeyTo - (rekey) when included in a valid transaction, the accounts auth addr will be - * updated with this value and future signatures must be signed with the key - * represented by this address. - * @param roundTime - Time when the block this transaction is in was confirmed. - * @param senderRewards - (rs) rewards applied to sender account. - * @param signature - Validation signature associated with some data. Only one of the signatures - * should be provided. - * @param stateProofTransaction - Fields for a state proof transaction. - * Definition: - * data/transactions/stateproof.go : StateProofTxnFields - * @param txType - (type) Indicates what type of transaction this is. Different types have - * different fields. - * Valid types, and where their fields are stored: - * * (pay) payment-transaction - * * (keyreg) keyreg-transaction - * * (acfg) asset-config-transaction - * * (axfer) asset-transfer-transaction - * * (afrz) asset-freeze-transaction - * * (appl) application-transaction - * * (stpf) state-proof-transaction - */ - constructor({ fee, firstValid, lastValid, sender, applicationTransaction, assetConfigTransaction, assetFreezeTransaction, assetTransferTransaction, authAddr, closeRewards, closingAmount, confirmedRound, createdApplicationIndex, createdAssetIndex, genesisHash, genesisId, globalStateDelta, group, id, innerTxns, intraRoundOffset, keyregTransaction, lease, localStateDelta, logs, note, paymentTransaction, receiverRewards, rekeyTo, roundTime, senderRewards, signature, stateProofTransaction, txType, }) { - super(); - this.fee = fee; - this.firstValid = firstValid; - this.lastValid = lastValid; - this.sender = sender; - this.applicationTransaction = applicationTransaction; - this.assetConfigTransaction = assetConfigTransaction; - this.assetFreezeTransaction = assetFreezeTransaction; - this.assetTransferTransaction = assetTransferTransaction; - this.authAddr = authAddr; - this.closeRewards = closeRewards; - this.closingAmount = closingAmount; - this.confirmedRound = confirmedRound; - this.createdApplicationIndex = createdApplicationIndex; - this.createdAssetIndex = createdAssetIndex; - this.genesisHash = - typeof genesisHash === 'string' - ? (0, binarydata_1.base64ToBytes)(genesisHash) - : genesisHash; - this.genesisId = genesisId; - this.globalStateDelta = globalStateDelta; - this.group = typeof group === 'string' ? (0, binarydata_1.base64ToBytes)(group) : group; - this.id = id; - this.innerTxns = innerTxns; - this.intraRoundOffset = intraRoundOffset; - this.keyregTransaction = keyregTransaction; - this.lease = typeof lease === 'string' ? (0, binarydata_1.base64ToBytes)(lease) : lease; - this.localStateDelta = localStateDelta; - this.logs = logs; - this.note = typeof note === 'string' ? (0, binarydata_1.base64ToBytes)(note) : note; - this.paymentTransaction = paymentTransaction; - this.receiverRewards = receiverRewards; - this.rekeyTo = rekeyTo; - this.roundTime = roundTime; - this.senderRewards = senderRewards; - this.signature = signature; - this.stateProofTransaction = stateProofTransaction; - this.txType = txType; - this.attribute_map = { - fee: 'fee', - firstValid: 'first-valid', - lastValid: 'last-valid', - sender: 'sender', - applicationTransaction: 'application-transaction', - assetConfigTransaction: 'asset-config-transaction', - assetFreezeTransaction: 'asset-freeze-transaction', - assetTransferTransaction: 'asset-transfer-transaction', - authAddr: 'auth-addr', - closeRewards: 'close-rewards', - closingAmount: 'closing-amount', - confirmedRound: 'confirmed-round', - createdApplicationIndex: 'created-application-index', - createdAssetIndex: 'created-asset-index', - genesisHash: 'genesis-hash', - genesisId: 'genesis-id', - globalStateDelta: 'global-state-delta', - group: 'group', - id: 'id', - innerTxns: 'inner-txns', - intraRoundOffset: 'intra-round-offset', - keyregTransaction: 'keyreg-transaction', - lease: 'lease', - localStateDelta: 'local-state-delta', - logs: 'logs', - note: 'note', - paymentTransaction: 'payment-transaction', - receiverRewards: 'receiver-rewards', - rekeyTo: 'rekey-to', - roundTime: 'round-time', - senderRewards: 'sender-rewards', - signature: 'signature', - stateProofTransaction: 'state-proof-transaction', - txType: 'tx-type', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['fee'] === 'undefined') - throw new Error(`Response is missing required field 'fee': ${data}`); - if (typeof data['first-valid'] === 'undefined') - throw new Error(`Response is missing required field 'first-valid': ${data}`); - if (typeof data['last-valid'] === 'undefined') - throw new Error(`Response is missing required field 'last-valid': ${data}`); - if (typeof data['sender'] === 'undefined') - throw new Error(`Response is missing required field 'sender': ${data}`); - return new Transaction({ - fee: data['fee'], - firstValid: data['first-valid'], - lastValid: data['last-valid'], - sender: data['sender'], - applicationTransaction: typeof data['application-transaction'] !== 'undefined' - ? TransactionApplication.from_obj_for_encoding(data['application-transaction']) - : undefined, - assetConfigTransaction: typeof data['asset-config-transaction'] !== 'undefined' - ? TransactionAssetConfig.from_obj_for_encoding(data['asset-config-transaction']) - : undefined, - assetFreezeTransaction: typeof data['asset-freeze-transaction'] !== 'undefined' - ? TransactionAssetFreeze.from_obj_for_encoding(data['asset-freeze-transaction']) - : undefined, - assetTransferTransaction: typeof data['asset-transfer-transaction'] !== 'undefined' - ? TransactionAssetTransfer.from_obj_for_encoding(data['asset-transfer-transaction']) - : undefined, - authAddr: data['auth-addr'], - closeRewards: data['close-rewards'], - closingAmount: data['closing-amount'], - confirmedRound: data['confirmed-round'], - createdApplicationIndex: data['created-application-index'], - createdAssetIndex: data['created-asset-index'], - genesisHash: data['genesis-hash'], - genesisId: data['genesis-id'], - globalStateDelta: typeof data['global-state-delta'] !== 'undefined' - ? data['global-state-delta'].map(EvalDeltaKeyValue.from_obj_for_encoding) - : undefined, - group: data['group'], - id: data['id'], - innerTxns: typeof data['inner-txns'] !== 'undefined' - ? data['inner-txns'].map(Transaction.from_obj_for_encoding) - : undefined, - intraRoundOffset: data['intra-round-offset'], - keyregTransaction: typeof data['keyreg-transaction'] !== 'undefined' - ? TransactionKeyreg.from_obj_for_encoding(data['keyreg-transaction']) - : undefined, - lease: data['lease'], - localStateDelta: typeof data['local-state-delta'] !== 'undefined' - ? data['local-state-delta'].map(AccountStateDelta.from_obj_for_encoding) - : undefined, - logs: data['logs'], - note: data['note'], - paymentTransaction: typeof data['payment-transaction'] !== 'undefined' - ? TransactionPayment.from_obj_for_encoding(data['payment-transaction']) - : undefined, - receiverRewards: data['receiver-rewards'], - rekeyTo: data['rekey-to'], - roundTime: data['round-time'], - senderRewards: data['sender-rewards'], - signature: typeof data['signature'] !== 'undefined' - ? TransactionSignature.from_obj_for_encoding(data['signature']) - : undefined, - stateProofTransaction: typeof data['state-proof-transaction'] !== 'undefined' - ? TransactionStateProof.from_obj_for_encoding(data['state-proof-transaction']) - : undefined, - txType: data['tx-type'], - }); - /* eslint-enable dot-notation */ - } -} -exports.Transaction = Transaction; -/** - * Fields for application transactions. - * Definition: - * data/transactions/application.go : ApplicationCallTxnFields - */ -class TransactionApplication extends basemodel_1.default { - /** - * Creates a new `TransactionApplication` object. - * @param applicationId - (apid) ID of the application being configured or empty if creating. - * @param accounts - (apat) List of accounts in addition to the sender that may be accessed from the - * application's approval-program and clear-state-program. - * @param applicationArgs - (apaa) transaction specific arguments accessed from the application's - * approval-program and clear-state-program. - * @param approvalProgram - (apap) Logic executed for every application transaction, except when - * on-completion is set to "clear". It can read and write global state for the - * application, as well as account-specific local state. Approval programs may - * reject the transaction. - * @param clearStateProgram - (apsu) Logic executed for application transactions with on-completion set to - * "clear". It can read and write global state for the application, as well as - * account-specific local state. Clear state programs cannot reject the - * transaction. - * @param extraProgramPages - (epp) specifies the additional app program len requested in pages. - * @param foreignApps - (apfa) Lists the applications in addition to the application-id whose global - * states may be accessed by this application's approval-program and - * clear-state-program. The access is read-only. - * @param foreignAssets - (apas) lists the assets whose parameters may be accessed by this application's - * ApprovalProgram and ClearStateProgram. The access is read-only. - * @param globalStateSchema - Represents a (apls) local-state or (apgs) global-state schema. These schemas - * determine how much storage may be used in a local-state or global-state for an - * application. The more space used, the larger minimum balance must be maintained - * in the account holding the data. - * @param localStateSchema - Represents a (apls) local-state or (apgs) global-state schema. These schemas - * determine how much storage may be used in a local-state or global-state for an - * application. The more space used, the larger minimum balance must be maintained - * in the account holding the data. - * @param onCompletion - (apan) defines the what additional actions occur with the transaction. - * Valid types: - * * noop - * * optin - * * closeout - * * clear - * * update - * * update - * * delete - */ - constructor({ applicationId, accounts, applicationArgs, approvalProgram, clearStateProgram, extraProgramPages, foreignApps, foreignAssets, globalStateSchema, localStateSchema, onCompletion, }) { - super(); - this.applicationId = applicationId; - this.accounts = accounts; - this.applicationArgs = applicationArgs; - this.approvalProgram = - typeof approvalProgram === 'string' - ? (0, binarydata_1.base64ToBytes)(approvalProgram) - : approvalProgram; - this.clearStateProgram = - typeof clearStateProgram === 'string' - ? (0, binarydata_1.base64ToBytes)(clearStateProgram) - : clearStateProgram; - this.extraProgramPages = extraProgramPages; - this.foreignApps = foreignApps; - this.foreignAssets = foreignAssets; - this.globalStateSchema = globalStateSchema; - this.localStateSchema = localStateSchema; - this.onCompletion = onCompletion; - this.attribute_map = { - applicationId: 'application-id', - accounts: 'accounts', - applicationArgs: 'application-args', - approvalProgram: 'approval-program', - clearStateProgram: 'clear-state-program', - extraProgramPages: 'extra-program-pages', - foreignApps: 'foreign-apps', - foreignAssets: 'foreign-assets', - globalStateSchema: 'global-state-schema', - localStateSchema: 'local-state-schema', - onCompletion: 'on-completion', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['application-id'] === 'undefined') - throw new Error(`Response is missing required field 'application-id': ${data}`); - return new TransactionApplication({ - applicationId: data['application-id'], - accounts: data['accounts'], - applicationArgs: data['application-args'], - approvalProgram: data['approval-program'], - clearStateProgram: data['clear-state-program'], - extraProgramPages: data['extra-program-pages'], - foreignApps: data['foreign-apps'], - foreignAssets: data['foreign-assets'], - globalStateSchema: typeof data['global-state-schema'] !== 'undefined' - ? StateSchema.from_obj_for_encoding(data['global-state-schema']) - : undefined, - localStateSchema: typeof data['local-state-schema'] !== 'undefined' - ? StateSchema.from_obj_for_encoding(data['local-state-schema']) - : undefined, - onCompletion: data['on-completion'], - }); - /* eslint-enable dot-notation */ - } -} -exports.TransactionApplication = TransactionApplication; -/** - * Fields for asset allocation, re-configuration, and destruction. - * A zero value for asset-id indicates asset creation. - * A zero value for the params indicates asset destruction. - * Definition: - * data/transactions/asset.go : AssetConfigTxnFields - */ -class TransactionAssetConfig extends basemodel_1.default { - /** - * Creates a new `TransactionAssetConfig` object. - * @param assetId - (xaid) ID of the asset being configured or empty if creating. - * @param params - AssetParams specifies the parameters for an asset. - * (apar) when part of an AssetConfig transaction. - * Definition: - * data/transactions/asset.go : AssetParams - */ - constructor({ assetId, params, }) { - super(); - this.assetId = assetId; - this.params = params; - this.attribute_map = { - assetId: 'asset-id', - params: 'params', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - return new TransactionAssetConfig({ - assetId: data['asset-id'], - params: typeof data['params'] !== 'undefined' - ? AssetParams.from_obj_for_encoding(data['params']) - : undefined, - }); - /* eslint-enable dot-notation */ - } -} -exports.TransactionAssetConfig = TransactionAssetConfig; -/** - * Fields for an asset freeze transaction. - * Definition: - * data/transactions/asset.go : AssetFreezeTxnFields - */ -class TransactionAssetFreeze extends basemodel_1.default { - /** - * Creates a new `TransactionAssetFreeze` object. - * @param address - (fadd) Address of the account whose asset is being frozen or thawed. - * @param assetId - (faid) ID of the asset being frozen or thawed. - * @param newFreezeStatus - (afrz) The new freeze status. - */ - constructor({ address, assetId, newFreezeStatus, }) { - super(); - this.address = address; - this.assetId = assetId; - this.newFreezeStatus = newFreezeStatus; - this.attribute_map = { - address: 'address', - assetId: 'asset-id', - newFreezeStatus: 'new-freeze-status', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['address'] === 'undefined') - throw new Error(`Response is missing required field 'address': ${data}`); - if (typeof data['asset-id'] === 'undefined') - throw new Error(`Response is missing required field 'asset-id': ${data}`); - if (typeof data['new-freeze-status'] === 'undefined') - throw new Error(`Response is missing required field 'new-freeze-status': ${data}`); - return new TransactionAssetFreeze({ - address: data['address'], - assetId: data['asset-id'], - newFreezeStatus: data['new-freeze-status'], - }); - /* eslint-enable dot-notation */ - } -} -exports.TransactionAssetFreeze = TransactionAssetFreeze; -/** - * Fields for an asset transfer transaction. - * Definition: - * data/transactions/asset.go : AssetTransferTxnFields - */ -class TransactionAssetTransfer extends basemodel_1.default { - /** - * Creates a new `TransactionAssetTransfer` object. - * @param amount - (aamt) Amount of asset to transfer. A zero amount transferred to self allocates - * that asset in the account's Assets map. - * @param assetId - (xaid) ID of the asset being transferred. - * @param receiver - (arcv) Recipient address of the transfer. - * @param closeAmount - Number of assets transferred to the close-to account as part of the transaction. - * @param closeTo - (aclose) Indicates that the asset should be removed from the account's Assets - * map, and specifies where the remaining asset holdings should be transferred. - * It's always valid to transfer remaining asset holdings to the creator account. - * @param sender - (asnd) The effective sender during a clawback transactions. If this is not a - * zero value, the real transaction sender must be the Clawback address from the - * AssetParams. - */ - constructor({ amount, assetId, receiver, closeAmount, closeTo, sender, }) { - super(); - this.amount = amount; - this.assetId = assetId; - this.receiver = receiver; - this.closeAmount = closeAmount; - this.closeTo = closeTo; - this.sender = sender; - this.attribute_map = { - amount: 'amount', - assetId: 'asset-id', - receiver: 'receiver', - closeAmount: 'close-amount', - closeTo: 'close-to', - sender: 'sender', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['amount'] === 'undefined') - throw new Error(`Response is missing required field 'amount': ${data}`); - if (typeof data['asset-id'] === 'undefined') - throw new Error(`Response is missing required field 'asset-id': ${data}`); - if (typeof data['receiver'] === 'undefined') - throw new Error(`Response is missing required field 'receiver': ${data}`); - return new TransactionAssetTransfer({ - amount: data['amount'], - assetId: data['asset-id'], - receiver: data['receiver'], - closeAmount: data['close-amount'], - closeTo: data['close-to'], - sender: data['sender'], - }); - /* eslint-enable dot-notation */ - } -} -exports.TransactionAssetTransfer = TransactionAssetTransfer; -/** - * Fields for a keyreg transaction. - * Definition: - * data/transactions/keyreg.go : KeyregTxnFields - */ -class TransactionKeyreg extends basemodel_1.default { - /** - * Creates a new `TransactionKeyreg` object. - * @param nonParticipation - (nonpart) Mark the account as participating or non-participating. - * @param selectionParticipationKey - (selkey) Public key used with the Verified Random Function (VRF) result during - * committee selection. - * @param stateProofKey - (sprfkey) State proof key used in key registration transactions. - * @param voteFirstValid - (votefst) First round this participation key is valid. - * @param voteKeyDilution - (votekd) Number of subkeys in each batch of participation keys. - * @param voteLastValid - (votelst) Last round this participation key is valid. - * @param voteParticipationKey - (votekey) Participation public key used in key registration transactions. - */ - constructor({ nonParticipation, selectionParticipationKey, stateProofKey, voteFirstValid, voteKeyDilution, voteLastValid, voteParticipationKey, }) { - super(); - this.nonParticipation = nonParticipation; - this.selectionParticipationKey = - typeof selectionParticipationKey === 'string' - ? (0, binarydata_1.base64ToBytes)(selectionParticipationKey) - : selectionParticipationKey; - this.stateProofKey = - typeof stateProofKey === 'string' - ? (0, binarydata_1.base64ToBytes)(stateProofKey) - : stateProofKey; - this.voteFirstValid = voteFirstValid; - this.voteKeyDilution = voteKeyDilution; - this.voteLastValid = voteLastValid; - this.voteParticipationKey = - typeof voteParticipationKey === 'string' - ? (0, binarydata_1.base64ToBytes)(voteParticipationKey) - : voteParticipationKey; - this.attribute_map = { - nonParticipation: 'non-participation', - selectionParticipationKey: 'selection-participation-key', - stateProofKey: 'state-proof-key', - voteFirstValid: 'vote-first-valid', - voteKeyDilution: 'vote-key-dilution', - voteLastValid: 'vote-last-valid', - voteParticipationKey: 'vote-participation-key', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - return new TransactionKeyreg({ - nonParticipation: data['non-participation'], - selectionParticipationKey: data['selection-participation-key'], - stateProofKey: data['state-proof-key'], - voteFirstValid: data['vote-first-valid'], - voteKeyDilution: data['vote-key-dilution'], - voteLastValid: data['vote-last-valid'], - voteParticipationKey: data['vote-participation-key'], - }); - /* eslint-enable dot-notation */ - } -} -exports.TransactionKeyreg = TransactionKeyreg; -/** - * Fields for a payment transaction. - * Definition: - * data/transactions/payment.go : PaymentTxnFields - */ -class TransactionPayment extends basemodel_1.default { - /** - * Creates a new `TransactionPayment` object. - * @param amount - (amt) number of MicroAlgos intended to be transferred. - * @param receiver - (rcv) receiver's address. - * @param closeAmount - Number of MicroAlgos that were sent to the close-remainder-to address when - * closing the sender account. - * @param closeRemainderTo - (close) when set, indicates that the sending account should be closed and all - * remaining funds be transferred to this address. - */ - constructor({ amount, receiver, closeAmount, closeRemainderTo, }) { - super(); - this.amount = amount; - this.receiver = receiver; - this.closeAmount = closeAmount; - this.closeRemainderTo = closeRemainderTo; - this.attribute_map = { - amount: 'amount', - receiver: 'receiver', - closeAmount: 'close-amount', - closeRemainderTo: 'close-remainder-to', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['amount'] === 'undefined') - throw new Error(`Response is missing required field 'amount': ${data}`); - if (typeof data['receiver'] === 'undefined') - throw new Error(`Response is missing required field 'receiver': ${data}`); - return new TransactionPayment({ - amount: data['amount'], - receiver: data['receiver'], - closeAmount: data['close-amount'], - closeRemainderTo: data['close-remainder-to'], - }); - /* eslint-enable dot-notation */ - } -} -exports.TransactionPayment = TransactionPayment; -/** - * - */ -class TransactionResponse extends basemodel_1.default { - /** - * Creates a new `TransactionResponse` object. - * @param currentRound - Round at which the results were computed. - * @param transaction - Contains all fields common to all transactions and serves as an envelope to all - * transactions type. Represents both regular and inner transactions. - * Definition: - * data/transactions/signedtxn.go : SignedTxn - * data/transactions/transaction.go : Transaction - */ - constructor({ currentRound, transaction, }) { - super(); - this.currentRound = currentRound; - this.transaction = transaction; - this.attribute_map = { - currentRound: 'current-round', - transaction: 'transaction', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['current-round'] === 'undefined') - throw new Error(`Response is missing required field 'current-round': ${data}`); - if (typeof data['transaction'] === 'undefined') - throw new Error(`Response is missing required field 'transaction': ${data}`); - return new TransactionResponse({ - currentRound: data['current-round'], - transaction: Transaction.from_obj_for_encoding(data['transaction']), - }); - /* eslint-enable dot-notation */ - } -} -exports.TransactionResponse = TransactionResponse; -/** - * Validation signature associated with some data. Only one of the signatures - * should be provided. - */ -class TransactionSignature extends basemodel_1.default { - /** - * Creates a new `TransactionSignature` object. - * @param logicsig - (lsig) Programatic transaction signature. - * Definition: - * data/transactions/logicsig.go - * @param multisig - (msig) structure holding multiple subsignatures. - * Definition: - * crypto/multisig.go : MultisigSig - * @param sig - (sig) Standard ed25519 signature. - */ - constructor({ logicsig, multisig, sig, }) { - super(); - this.logicsig = logicsig; - this.multisig = multisig; - this.sig = typeof sig === 'string' ? (0, binarydata_1.base64ToBytes)(sig) : sig; - this.attribute_map = { - logicsig: 'logicsig', - multisig: 'multisig', - sig: 'sig', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - return new TransactionSignature({ - logicsig: typeof data['logicsig'] !== 'undefined' - ? TransactionSignatureLogicsig.from_obj_for_encoding(data['logicsig']) - : undefined, - multisig: typeof data['multisig'] !== 'undefined' - ? TransactionSignatureMultisig.from_obj_for_encoding(data['multisig']) - : undefined, - sig: data['sig'], - }); - /* eslint-enable dot-notation */ - } -} -exports.TransactionSignature = TransactionSignature; -/** - * (lsig) Programatic transaction signature. - * Definition: - * data/transactions/logicsig.go - */ -class TransactionSignatureLogicsig extends basemodel_1.default { - /** - * Creates a new `TransactionSignatureLogicsig` object. - * @param logic - (l) Program signed by a signature or multi signature, or hashed to be the - * address of ana ccount. Base64 encoded TEAL program. - * @param args - (arg) Logic arguments, base64 encoded. - * @param multisigSignature - (msig) structure holding multiple subsignatures. - * Definition: - * crypto/multisig.go : MultisigSig - * @param signature - (sig) ed25519 signature. - */ - constructor({ logic, args, multisigSignature, signature, }) { - super(); - this.logic = typeof logic === 'string' ? (0, binarydata_1.base64ToBytes)(logic) : logic; - this.args = args; - this.multisigSignature = multisigSignature; - this.signature = - typeof signature === 'string' ? (0, binarydata_1.base64ToBytes)(signature) : signature; - this.attribute_map = { - logic: 'logic', - args: 'args', - multisigSignature: 'multisig-signature', - signature: 'signature', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['logic'] === 'undefined') - throw new Error(`Response is missing required field 'logic': ${data}`); - return new TransactionSignatureLogicsig({ - logic: data['logic'], - args: data['args'], - multisigSignature: typeof data['multisig-signature'] !== 'undefined' - ? TransactionSignatureMultisig.from_obj_for_encoding(data['multisig-signature']) - : undefined, - signature: data['signature'], - }); - /* eslint-enable dot-notation */ - } -} -exports.TransactionSignatureLogicsig = TransactionSignatureLogicsig; -/** - * (msig) structure holding multiple subsignatures. - * Definition: - * crypto/multisig.go : MultisigSig - */ -class TransactionSignatureMultisig extends basemodel_1.default { - /** - * Creates a new `TransactionSignatureMultisig` object. - * @param subsignature - (subsig) holds pairs of public key and signatures. - * @param threshold - (thr) - * @param version - (v) - */ - constructor({ subsignature, threshold, version, }) { - super(); - this.subsignature = subsignature; - this.threshold = threshold; - this.version = version; - this.attribute_map = { - subsignature: 'subsignature', - threshold: 'threshold', - version: 'version', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - return new TransactionSignatureMultisig({ - subsignature: typeof data['subsignature'] !== 'undefined' - ? data['subsignature'].map(TransactionSignatureMultisigSubsignature.from_obj_for_encoding) - : undefined, - threshold: data['threshold'], - version: data['version'], - }); - /* eslint-enable dot-notation */ - } -} -exports.TransactionSignatureMultisig = TransactionSignatureMultisig; -class TransactionSignatureMultisigSubsignature extends basemodel_1.default { - /** - * Creates a new `TransactionSignatureMultisigSubsignature` object. - * @param publicKey - (pk) - * @param signature - (s) - */ - constructor({ publicKey, signature, }) { - super(); - this.publicKey = - typeof publicKey === 'string' ? (0, binarydata_1.base64ToBytes)(publicKey) : publicKey; - this.signature = - typeof signature === 'string' ? (0, binarydata_1.base64ToBytes)(signature) : signature; - this.attribute_map = { - publicKey: 'public-key', - signature: 'signature', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - return new TransactionSignatureMultisigSubsignature({ - publicKey: data['public-key'], - signature: data['signature'], - }); - /* eslint-enable dot-notation */ - } -} -exports.TransactionSignatureMultisigSubsignature = TransactionSignatureMultisigSubsignature; -/** - * Fields for a state proof transaction. - * Definition: - * data/transactions/stateproof.go : StateProofTxnFields - */ -class TransactionStateProof extends basemodel_1.default { - /** - * Creates a new `TransactionStateProof` object. - * @param message - (spmsg) - * @param stateProof - (sp) represents a state proof. - * Definition: - * crypto/stateproof/structs.go : StateProof - * @param stateProofType - (sptype) Type of the state proof. Integer representing an entry defined in - * protocol/stateproof.go - */ - constructor({ message, stateProof, stateProofType, }) { - super(); - this.message = message; - this.stateProof = stateProof; - this.stateProofType = stateProofType; - this.attribute_map = { - message: 'message', - stateProof: 'state-proof', - stateProofType: 'state-proof-type', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - return new TransactionStateProof({ - message: typeof data['message'] !== 'undefined' - ? IndexerStateProofMessage.from_obj_for_encoding(data['message']) - : undefined, - stateProof: typeof data['state-proof'] !== 'undefined' - ? StateProofFields.from_obj_for_encoding(data['state-proof']) - : undefined, - stateProofType: data['state-proof-type'], - }); - /* eslint-enable dot-notation */ - } -} -exports.TransactionStateProof = TransactionStateProof; -/** - * - */ -class TransactionsResponse extends basemodel_1.default { - /** - * Creates a new `TransactionsResponse` object. - * @param currentRound - Round at which the results were computed. - * @param transactions - - * @param nextToken - Used for pagination, when making another request provide this token with the - * next parameter. - */ - constructor({ currentRound, transactions, nextToken, }) { - super(); - this.currentRound = currentRound; - this.transactions = transactions; - this.nextToken = nextToken; - this.attribute_map = { - currentRound: 'current-round', - transactions: 'transactions', - nextToken: 'next-token', - }; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(data) { - /* eslint-disable dot-notation */ - if (typeof data['current-round'] === 'undefined') - throw new Error(`Response is missing required field 'current-round': ${data}`); - if (!Array.isArray(data['transactions'])) - throw new Error(`Response is missing required array field 'transactions': ${data}`); - return new TransactionsResponse({ - currentRound: data['current-round'], - transactions: data['transactions'].map(Transaction.from_obj_for_encoding), - nextToken: data['next-token'], - }); - /* eslint-enable dot-notation */ - } -} -exports.TransactionsResponse = TransactionsResponse; diff --git a/algosdk/client/v2/indexer/searchAccounts.d.ts b/algosdk/client/v2/indexer/searchAccounts.d.ts deleted file mode 100644 index eba8599..0000000 --- a/algosdk/client/v2/indexer/searchAccounts.d.ts +++ /dev/null @@ -1,224 +0,0 @@ -import JSONRequest from '../jsonrequest'; -/** - * Returns information about indexed accounts. - * - * #### Example - * ```typescript - * const accounts = await indexerClient.searchAccounts().do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2accounts) - * @category GET - */ -export default class SearchAccounts extends JSONRequest { - /** - * @returns `/v2/accounts` - */ - path(): string; - /** - * Filtered results should have an amount greater than this value, as int, representing microAlgos, unless an asset-id is provided, in which case units are in the asset's units. - * - * #### Example 1 - * ```typescript - * const minBalance = 300000; - * const accounts = await indexerClient - * .searchAccounts() - * .currencyGreaterThan(minBalance - 1) - * .do(); - * ``` - * - * #### Example 2 - * ```typescript - * const assetID = 163650; - * const minBalance = 300000; - * const accounts = await indexerClient - * .searchAccounts() - * .assetID(assetID) - * .currencyGreaterThan(minBalance - 1) - * .do(); - * ``` - * @remarks - * If you are looking for accounts with the currency amount greater than 0, simply construct the query without `currencyGreaterThan` because it doesn't accept `-1`, and passing the `0` `currency-greater-than` value would exclude accounts with a 0 amount. - * - * @param greater - * @category query - */ - currencyGreaterThan(greater: number): this; - /** - * Filtered results should have an amount less than this value, as int, representing microAlgos, unless an asset-id is provided, in which case units are in the asset's units. - * - * #### Example 1 - * ```typescript - * const maxBalance = 500000; - * const accounts = await indexerClient - * .searchAccounts() - * .currencyLessThan(maxBalance + 1) - * .do(); - * ``` - * - * #### Example 2 - * ```typescript - * const assetID = 163650; - * const maxBalance = 500000; - * const accounts = await indexerClient - * .searchAccounts() - * .assetID(assetID) - * .currencyLessThan(maxBalance + 1) - * .do(); - * ``` - * - * @param lesser - * @category query - */ - currencyLessThan(lesser: number): this; - /** - * Maximum number of results to return. - * - * #### Example - * ```typescript - * const maxResults = 25; - * const accounts = await indexerClient - * .searchAccounts() - * .limit(maxResults) - * .do(); - * ``` - * - * @param limit - * @category query - */ - limit(limit: number): this; - /** - * Asset ID to filter with. - * - * #### Example - * ```typescript - * const assetID = 163650; - * const accounts = await indexerClient - * .searchAccounts() - * .assetID(assetID) - * .do(); - * ``` - * - * @param id - * @category query - */ - assetID(id: number): this; - /** - * The next page of results. - * - * #### Example - * ```typescript - * const maxResults = 25; - * - * const accountsPage1 = await indexerClient - * .searchAccounts() - * .limit(maxResults) - * .do(); - * - * const accountsPage2 = await indexerClient - * .searchAccounts() - * .limit(maxResults) - * .nextToken(accountsPage1["next-token"]) - * .do(); - * ``` - * - * @param nextToken - provided by the previous results - * @category query - */ - nextToken(nextToken: string): this; - /** - * Include results for the specified round. - * - * #### Example - * ```typescript - * const targetBlock = 18309917; - * const accounts = await indexerClient - * .searchAccounts() - * .round(targetBlock) - * .do(); - * ``` - * @remarks For performance reasons, this parameter may be disabled on some configurations. - * @param round - * @category query - */ - round(round: number): this; - /** - * Include accounts that use this spending key. - * - * #### Example - * ```typescript - * const authAddr = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accounts = await indexerClient - * .searchAccounts() - * .authAddr(authAddr) - * .do(); - * ``` - * - * @param authAddr - */ - authAddr(authAddr: string): this; - /** - * Filter for this application. - * - * #### Example - * ```typescript - * const appId = 60553466; - * const accounts = await indexerClient - * .searchAccounts() - * .applicationID(appId) - * .do(); - * ``` - * - * @param applicationID - * @category query - */ - applicationID(applicationID: number): this; - /** - * Includes all items including closed accounts, deleted applications, destroyed assets, opted-out asset holdings, and closed-out application localstates - * - * #### Example 1 - * ```typescript - * const assetId = 163650; - * const accounts = await indexerClient - * .searchAccounts() - * .includeAll(false) - * .do(); - * ``` - * - * #### Example 2 - * ```typescript - * const assetId = 163650; - * const accounts = await indexerClient - * .searchAccounts() - * .includeAll() - * .do(); - * ``` - * - * @param value - default true when called without passing a value - * @category query - */ - includeAll(value?: boolean): this; - /** - * Exclude additional items such as asset holdings, application local data stored for this account, asset parameters created by this account, and application parameters created by this account. - * - * #### Example 1 - * ```typescript - * const accounts = await indexerClient - * .searchAccounts() - * .exclude("all") - * .do(); - * ``` - * - * #### Example 2 - * ```typescript - * const accounts = await indexerClient - * .searchAccounts() - * .exclude("assets,created-assets") - * .do(); - * ``` - * @remarks By default, it behaves as exclude=none - * @param exclude - Array of `all`, `assets`, `created-assets`, `apps-local-state`, `created-apps`, `none` - * @category query - */ - exclude(exclude: string): this; -} diff --git a/algosdk/client/v2/indexer/searchAccounts.js b/algosdk/client/v2/indexer/searchAccounts.js deleted file mode 100644 index 9beddc1..0000000 --- a/algosdk/client/v2/indexer/searchAccounts.js +++ /dev/null @@ -1,264 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -/** - * Returns information about indexed accounts. - * - * #### Example - * ```typescript - * const accounts = await indexerClient.searchAccounts().do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2accounts) - * @category GET - */ -class SearchAccounts extends jsonrequest_1.default { - /** - * @returns `/v2/accounts` - */ - // eslint-disable-next-line class-methods-use-this - path() { - return '/v2/accounts'; - } - /** - * Filtered results should have an amount greater than this value, as int, representing microAlgos, unless an asset-id is provided, in which case units are in the asset's units. - * - * #### Example 1 - * ```typescript - * const minBalance = 300000; - * const accounts = await indexerClient - * .searchAccounts() - * .currencyGreaterThan(minBalance - 1) - * .do(); - * ``` - * - * #### Example 2 - * ```typescript - * const assetID = 163650; - * const minBalance = 300000; - * const accounts = await indexerClient - * .searchAccounts() - * .assetID(assetID) - * .currencyGreaterThan(minBalance - 1) - * .do(); - * ``` - * @remarks - * If you are looking for accounts with the currency amount greater than 0, simply construct the query without `currencyGreaterThan` because it doesn't accept `-1`, and passing the `0` `currency-greater-than` value would exclude accounts with a 0 amount. - * - * @param greater - * @category query - */ - currencyGreaterThan(greater) { - // We convert the following to a string for now to correctly include zero values in request parameters. - this.query['currency-greater-than'] = greater.toString(); - return this; - } - /** - * Filtered results should have an amount less than this value, as int, representing microAlgos, unless an asset-id is provided, in which case units are in the asset's units. - * - * #### Example 1 - * ```typescript - * const maxBalance = 500000; - * const accounts = await indexerClient - * .searchAccounts() - * .currencyLessThan(maxBalance + 1) - * .do(); - * ``` - * - * #### Example 2 - * ```typescript - * const assetID = 163650; - * const maxBalance = 500000; - * const accounts = await indexerClient - * .searchAccounts() - * .assetID(assetID) - * .currencyLessThan(maxBalance + 1) - * .do(); - * ``` - * - * @param lesser - * @category query - */ - currencyLessThan(lesser) { - this.query['currency-less-than'] = lesser; - return this; - } - /** - * Maximum number of results to return. - * - * #### Example - * ```typescript - * const maxResults = 25; - * const accounts = await indexerClient - * .searchAccounts() - * .limit(maxResults) - * .do(); - * ``` - * - * @param limit - * @category query - */ - limit(limit) { - this.query.limit = limit; - return this; - } - /** - * Asset ID to filter with. - * - * #### Example - * ```typescript - * const assetID = 163650; - * const accounts = await indexerClient - * .searchAccounts() - * .assetID(assetID) - * .do(); - * ``` - * - * @param id - * @category query - */ - assetID(id) { - this.query['asset-id'] = id; - return this; - } - /** - * The next page of results. - * - * #### Example - * ```typescript - * const maxResults = 25; - * - * const accountsPage1 = await indexerClient - * .searchAccounts() - * .limit(maxResults) - * .do(); - * - * const accountsPage2 = await indexerClient - * .searchAccounts() - * .limit(maxResults) - * .nextToken(accountsPage1["next-token"]) - * .do(); - * ``` - * - * @param nextToken - provided by the previous results - * @category query - */ - nextToken(nextToken) { - this.query.next = nextToken; - return this; - } - /** - * Include results for the specified round. - * - * #### Example - * ```typescript - * const targetBlock = 18309917; - * const accounts = await indexerClient - * .searchAccounts() - * .round(targetBlock) - * .do(); - * ``` - * @remarks For performance reasons, this parameter may be disabled on some configurations. - * @param round - * @category query - */ - round(round) { - this.query.round = round; - return this; - } - /** - * Include accounts that use this spending key. - * - * #### Example - * ```typescript - * const authAddr = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const accounts = await indexerClient - * .searchAccounts() - * .authAddr(authAddr) - * .do(); - * ``` - * - * @param authAddr - */ - authAddr(authAddr) { - this.query['auth-addr'] = authAddr; - return this; - } - /** - * Filter for this application. - * - * #### Example - * ```typescript - * const appId = 60553466; - * const accounts = await indexerClient - * .searchAccounts() - * .applicationID(appId) - * .do(); - * ``` - * - * @param applicationID - * @category query - */ - applicationID(applicationID) { - this.query['application-id'] = applicationID; - return this; - } - /** - * Includes all items including closed accounts, deleted applications, destroyed assets, opted-out asset holdings, and closed-out application localstates - * - * #### Example 1 - * ```typescript - * const assetId = 163650; - * const accounts = await indexerClient - * .searchAccounts() - * .includeAll(false) - * .do(); - * ``` - * - * #### Example 2 - * ```typescript - * const assetId = 163650; - * const accounts = await indexerClient - * .searchAccounts() - * .includeAll() - * .do(); - * ``` - * - * @param value - default true when called without passing a value - * @category query - */ - includeAll(value = true) { - this.query['include-all'] = value; - return this; - } - /** - * Exclude additional items such as asset holdings, application local data stored for this account, asset parameters created by this account, and application parameters created by this account. - * - * #### Example 1 - * ```typescript - * const accounts = await indexerClient - * .searchAccounts() - * .exclude("all") - * .do(); - * ``` - * - * #### Example 2 - * ```typescript - * const accounts = await indexerClient - * .searchAccounts() - * .exclude("assets,created-assets") - * .do(); - * ``` - * @remarks By default, it behaves as exclude=none - * @param exclude - Array of `all`, `assets`, `created-assets`, `apps-local-state`, `created-apps`, `none` - * @category query - */ - exclude(exclude) { - this.query.exclude = exclude; - return this; - } -} -exports.default = SearchAccounts; diff --git a/algosdk/client/v2/indexer/searchForApplicationBoxes.d.ts b/algosdk/client/v2/indexer/searchForApplicationBoxes.d.ts deleted file mode 100644 index 7c8c74a..0000000 --- a/algosdk/client/v2/indexer/searchForApplicationBoxes.d.ts +++ /dev/null @@ -1,80 +0,0 @@ -import JSONRequest from '../jsonrequest'; -import HTTPClient from '../../client'; -import IntDecoding from '../../../types/intDecoding'; -import { BoxesResponse } from './models/types'; -export default class SearchForApplicationBoxes extends JSONRequest> { - private index; - /** - * Returns information about indexed application boxes. - * - * #### Example - * ```typescript - * const maxResults = 20; - * const appID = 1234; - * - * const responsePage1 = await indexerClient - * .searchForApplicationBoxes(appID) - * .limit(maxResults) - * .do(); - * const boxNamesPage1 = responsePage1.boxes.map(box => box.name); - * - * const responsePage2 = await indexerClient - * .searchForApplicationBoxes(appID) - * .limit(maxResults) - * .nextToken(responsePage1.nextToken) - * .do(); - * const boxNamesPage2 = responsePage2.boxes.map(box => box.name); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2applicationsapplication-idboxes) - * @oaram index - application index. - * @category GET - */ - constructor(c: HTTPClient, intDecoding: IntDecoding, index: number); - /** - * @returns `/v2/applications/${index}/boxes` - */ - path(): string; - /** - * Specify the next page of results. - * - * #### Example - * ```typescript - * const maxResults = 20; - * const appID = 1234; - * - * const responsePage1 = await indexerClient - * .searchForApplicationBoxes(appID) - * .limit(maxResults) - * .do(); - * const boxNamesPage1 = responsePage1.boxes.map(box => box.name); - * - * const responsePage2 = await indexerClient - * .searchForApplicationBoxes(appID) - * .limit(maxResults) - * .nextToken(responsePage1.nextToken) - * .do(); - * const boxNamesPage2 = responsePage2.boxes.map(box => box.name); - * ``` - * @param nextToken - provided by the previous results. - * @category query - */ - nextToken(next: string): this; - /** - * Limit results for pagination. - * - * #### Example - * ```typescript - * const maxResults = 20; - * const boxesResponse = await indexerClient - * .searchForApplicationBoxes(1234) - * .limit(maxResults) - * .do(); - * ``` - * - * @param limit - maximum number of results to return. - * @category query - */ - limit(limit: number): this; - prepare(body: Record): BoxesResponse; -} diff --git a/algosdk/client/v2/indexer/searchForApplicationBoxes.js b/algosdk/client/v2/indexer/searchForApplicationBoxes.js deleted file mode 100644 index 5c44d24..0000000 --- a/algosdk/client/v2/indexer/searchForApplicationBoxes.js +++ /dev/null @@ -1,98 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -const types_1 = require("./models/types"); -class SearchForApplicationBoxes extends jsonrequest_1.default { - /** - * Returns information about indexed application boxes. - * - * #### Example - * ```typescript - * const maxResults = 20; - * const appID = 1234; - * - * const responsePage1 = await indexerClient - * .searchForApplicationBoxes(appID) - * .limit(maxResults) - * .do(); - * const boxNamesPage1 = responsePage1.boxes.map(box => box.name); - * - * const responsePage2 = await indexerClient - * .searchForApplicationBoxes(appID) - * .limit(maxResults) - * .nextToken(responsePage1.nextToken) - * .do(); - * const boxNamesPage2 = responsePage2.boxes.map(box => box.name); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2applicationsapplication-idboxes) - * @oaram index - application index. - * @category GET - */ - constructor(c, intDecoding, index) { - super(c, intDecoding); - this.index = index; - this.index = index; - } - /** - * @returns `/v2/applications/${index}/boxes` - */ - path() { - return `/v2/applications/${this.index}/boxes`; - } - /** - * Specify the next page of results. - * - * #### Example - * ```typescript - * const maxResults = 20; - * const appID = 1234; - * - * const responsePage1 = await indexerClient - * .searchForApplicationBoxes(appID) - * .limit(maxResults) - * .do(); - * const boxNamesPage1 = responsePage1.boxes.map(box => box.name); - * - * const responsePage2 = await indexerClient - * .searchForApplicationBoxes(appID) - * .limit(maxResults) - * .nextToken(responsePage1.nextToken) - * .do(); - * const boxNamesPage2 = responsePage2.boxes.map(box => box.name); - * ``` - * @param nextToken - provided by the previous results. - * @category query - */ - nextToken(next) { - this.query.next = next; - return this; - } - /** - * Limit results for pagination. - * - * #### Example - * ```typescript - * const maxResults = 20; - * const boxesResponse = await indexerClient - * .searchForApplicationBoxes(1234) - * .limit(maxResults) - * .do(); - * ``` - * - * @param limit - maximum number of results to return. - * @category query - */ - limit(limit) { - this.query.limit = limit; - return this; - } - // eslint-disable-next-line class-methods-use-this - prepare(body) { - return types_1.BoxesResponse.from_obj_for_encoding(body); - } -} -exports.default = SearchForApplicationBoxes; diff --git a/algosdk/client/v2/indexer/searchForApplications.d.ts b/algosdk/client/v2/indexer/searchForApplications.d.ts deleted file mode 100644 index 155efb3..0000000 --- a/algosdk/client/v2/indexer/searchForApplications.d.ts +++ /dev/null @@ -1,110 +0,0 @@ -import JSONRequest from '../jsonrequest'; -/** - * Returns information about indexed applications. - * - * #### Example - * ```typescript - * const apps = await indexerClient.searchForApplications().do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2applications) - * @category GET - */ -export default class SearchForApplications extends JSONRequest { - /** - * @returns `/v2/applications` - */ - path(): string; - /** - * Application ID for filter, as int - * - * #### Example - * ```typescript - * const appId = 60553466; - * const apps = await indexerClient - * .searchForApplications() - * .index(appId) - * .do(); - * ``` - * @remarks Alternatively, use `indexerClient.lookupApplications(appId).do()` - * @param index - * @category query - */ - index(index: number): this; - /** - * Creator for filter, as string - * - * #### Example - * ```typescript - * const creator = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const apps = await indexerClient - * .searchForApplications() - * .creator(creator) - * .do(); - * ``` - * @param creator - * @category query - */ - creator(creator: string): this; - /** - * Specify the next page of results. - * - * #### Example - * ```typescript - * const maxResults = 20; - * - * const appsPage1 = await indexerClient - * .searchForApplications() - * .limit(maxResults) - * .do(); - * - * const appsPage2 = await indexerClient - * .searchForApplications() - * .limit(maxResults) - * .nextToken(appsPage1["next-token"]) - * .do(); - * ``` - * @param nextToken - provided by the previous results. - * @category query - */ - nextToken(next: string): this; - /** - * Limit results for pagination. - * - * #### Example - * ```typescript - * const maxResults = 20; - * const apps = await indexerClient - * .searchForApplications() - * .limit(maxResults) - * .do(); - * ``` - * - * @param limit - maximum number of results to return. - * @category query - */ - limit(limit: number): this; - /** - * Includes all items including closed accounts, deleted applications, destroyed assets, opted-out asset holdings, and closed-out application localstates - * - * #### Example 1 - * ```typescript - * const apps = await indexerClient - * .searchForApplications() - * .includeAll(false) - * .do(); - * ``` - * - * #### Example 2 - * ```typescript - * const apps = await indexerClient - * .searchForApplications() - * .includeAll() - * .do(); - * ``` - * - * @param value - default true when called without passing a value - * @category query - */ - includeAll(value?: boolean): this; -} diff --git a/algosdk/client/v2/indexer/searchForApplications.js b/algosdk/client/v2/indexer/searchForApplications.js deleted file mode 100644 index c09dfc9..0000000 --- a/algosdk/client/v2/indexer/searchForApplications.js +++ /dev/null @@ -1,134 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -/** - * Returns information about indexed applications. - * - * #### Example - * ```typescript - * const apps = await indexerClient.searchForApplications().do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2applications) - * @category GET - */ -class SearchForApplications extends jsonrequest_1.default { - /** - * @returns `/v2/applications` - */ - // eslint-disable-next-line class-methods-use-this - path() { - return '/v2/applications'; - } - /** - * Application ID for filter, as int - * - * #### Example - * ```typescript - * const appId = 60553466; - * const apps = await indexerClient - * .searchForApplications() - * .index(appId) - * .do(); - * ``` - * @remarks Alternatively, use `indexerClient.lookupApplications(appId).do()` - * @param index - * @category query - */ - index(index) { - this.query['application-id'] = index; - return this; - } - /** - * Creator for filter, as string - * - * #### Example - * ```typescript - * const creator = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const apps = await indexerClient - * .searchForApplications() - * .creator(creator) - * .do(); - * ``` - * @param creator - * @category query - */ - creator(creator) { - this.query.creator = creator; - return this; - } - /** - * Specify the next page of results. - * - * #### Example - * ```typescript - * const maxResults = 20; - * - * const appsPage1 = await indexerClient - * .searchForApplications() - * .limit(maxResults) - * .do(); - * - * const appsPage2 = await indexerClient - * .searchForApplications() - * .limit(maxResults) - * .nextToken(appsPage1["next-token"]) - * .do(); - * ``` - * @param nextToken - provided by the previous results. - * @category query - */ - nextToken(next) { - this.query.next = next; - return this; - } - /** - * Limit results for pagination. - * - * #### Example - * ```typescript - * const maxResults = 20; - * const apps = await indexerClient - * .searchForApplications() - * .limit(maxResults) - * .do(); - * ``` - * - * @param limit - maximum number of results to return. - * @category query - */ - limit(limit) { - this.query.limit = limit; - return this; - } - /** - * Includes all items including closed accounts, deleted applications, destroyed assets, opted-out asset holdings, and closed-out application localstates - * - * #### Example 1 - * ```typescript - * const apps = await indexerClient - * .searchForApplications() - * .includeAll(false) - * .do(); - * ``` - * - * #### Example 2 - * ```typescript - * const apps = await indexerClient - * .searchForApplications() - * .includeAll() - * .do(); - * ``` - * - * @param value - default true when called without passing a value - * @category query - */ - includeAll(value = true) { - this.query['include-all'] = value; - return this; - } -} -exports.default = SearchForApplications; diff --git a/algosdk/client/v2/indexer/searchForAssets.d.ts b/algosdk/client/v2/indexer/searchForAssets.d.ts deleted file mode 100644 index ec69435..0000000 --- a/algosdk/client/v2/indexer/searchForAssets.d.ts +++ /dev/null @@ -1,143 +0,0 @@ -import JSONRequest from '../jsonrequest'; -/** - * Returns information about indexed assets. - * - * #### Example - * ```typescript - * const assets = await indexerClient.searchForAssets().do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2assets) - * @category GET - */ -export default class SearchForAssets extends JSONRequest { - /** - * @returns `/v2/assets` - */ - path(): string; - /** - * Limit results for pagination. - * - * #### Example - * ```typescript - * const maxResults = 20; - * const assets = await indexerClient - * .searchForAssets() - * .limit(maxResults) - * .do(); - * ``` - * - * @param limit - maximum number of results to return. - * @category query - */ - limit(limit: number): this; - /** - * Filter just assets with the given creator address. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const assets = await indexerClient - * .searchForAssets() - * .creator(address) - * .do(); - * ``` - * - * @param creator - * @category query - */ - creator(creator: string): this; - /** - * Filter just assets with the given name. - * - * #### Example - * ```typescript - * const name = "Test Token"; - * const assets = await indexerClient - * .searchForAssets() - * .name(name) - * .do(); - * ``` - * - * @param name - * @category query - */ - name(name: string): this; - /** - * Filter just assets with the given unit. - * - * #### Example - * ```typescript - * const unit = "test"; - * const assets = await indexerClient - * .searchForAssets() - * .unit(unit) - * .do(); - * ``` - * - * @param unit - * @category query - */ - unit(unit: string): this; - /** - * Asset ID for filter, as int. - * - * #### Example - * ```typescript - * const assetId = 163650; - * const assets = await indexerClient - * .searchForAssets() - * .index(assetId) - * .do(); - * ``` - * @remarks Alternatively, use `indexerClient.lookupAssetByID(assetId).do();` - * @param index - * @category query - */ - index(index: number): this; - /** - * Specify the next page of results. - * - * #### Example - * ```typescript - * const maxResults = 20; - * - * const assetsPage1 = await indexerClient - * .searchForAssets() - * .limit(maxResults) - * .do(); - * - * const assetsPage2 = await indexerClient - * .searchForAssets() - * .limit(maxResults) - * .nextToken(assetsPage1["next-token"]) - * .do(); - * ``` - * @param nextToken - provided by the previous results. - * @category query - */ - nextToken(nextToken: string): this; - /** - * Includes all items including closed accounts, deleted applications, destroyed assets, opted-out asset holdings, and closed-out application localstates - * - * #### Example 1 - * ```typescript - * const assets = await indexerClient - * .searchForAssets() - * .includeAll(false) - * .do(); - * ``` - * - * #### Example 2 - * ```typescript - * const assets = await indexerClient - * .searchForAssets() - * .includeAll() - * .do(); - * ``` - * - * @param value - default true when called without passing a value - * @category query - */ - includeAll(value?: boolean): this; -} diff --git a/algosdk/client/v2/indexer/searchForAssets.js b/algosdk/client/v2/indexer/searchForAssets.js deleted file mode 100644 index 9295b3d..0000000 --- a/algosdk/client/v2/indexer/searchForAssets.js +++ /dev/null @@ -1,173 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -/** - * Returns information about indexed assets. - * - * #### Example - * ```typescript - * const assets = await indexerClient.searchForAssets().do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2assets) - * @category GET - */ -class SearchForAssets extends jsonrequest_1.default { - /** - * @returns `/v2/assets` - */ - // eslint-disable-next-line class-methods-use-this - path() { - return '/v2/assets'; - } - /** - * Limit results for pagination. - * - * #### Example - * ```typescript - * const maxResults = 20; - * const assets = await indexerClient - * .searchForAssets() - * .limit(maxResults) - * .do(); - * ``` - * - * @param limit - maximum number of results to return. - * @category query - */ - limit(limit) { - this.query.limit = limit; - return this; - } - /** - * Filter just assets with the given creator address. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const assets = await indexerClient - * .searchForAssets() - * .creator(address) - * .do(); - * ``` - * - * @param creator - * @category query - */ - creator(creator) { - this.query.creator = creator; - return this; - } - /** - * Filter just assets with the given name. - * - * #### Example - * ```typescript - * const name = "Test Token"; - * const assets = await indexerClient - * .searchForAssets() - * .name(name) - * .do(); - * ``` - * - * @param name - * @category query - */ - name(name) { - this.query.name = name; - return this; - } - /** - * Filter just assets with the given unit. - * - * #### Example - * ```typescript - * const unit = "test"; - * const assets = await indexerClient - * .searchForAssets() - * .unit(unit) - * .do(); - * ``` - * - * @param unit - * @category query - */ - unit(unit) { - this.query.unit = unit; - return this; - } - /** - * Asset ID for filter, as int. - * - * #### Example - * ```typescript - * const assetId = 163650; - * const assets = await indexerClient - * .searchForAssets() - * .index(assetId) - * .do(); - * ``` - * @remarks Alternatively, use `indexerClient.lookupAssetByID(assetId).do();` - * @param index - * @category query - */ - index(index) { - this.query['asset-id'] = index; - return this; - } - /** - * Specify the next page of results. - * - * #### Example - * ```typescript - * const maxResults = 20; - * - * const assetsPage1 = await indexerClient - * .searchForAssets() - * .limit(maxResults) - * .do(); - * - * const assetsPage2 = await indexerClient - * .searchForAssets() - * .limit(maxResults) - * .nextToken(assetsPage1["next-token"]) - * .do(); - * ``` - * @param nextToken - provided by the previous results. - * @category query - */ - nextToken(nextToken) { - this.query.next = nextToken; - return this; - } - /** - * Includes all items including closed accounts, deleted applications, destroyed assets, opted-out asset holdings, and closed-out application localstates - * - * #### Example 1 - * ```typescript - * const assets = await indexerClient - * .searchForAssets() - * .includeAll(false) - * .do(); - * ``` - * - * #### Example 2 - * ```typescript - * const assets = await indexerClient - * .searchForAssets() - * .includeAll() - * .do(); - * ``` - * - * @param value - default true when called without passing a value - * @category query - */ - includeAll(value = true) { - this.query['include-all'] = value; - return this; - } -} -exports.default = SearchForAssets; diff --git a/algosdk/client/v2/indexer/searchForTransactions.d.ts b/algosdk/client/v2/indexer/searchForTransactions.d.ts deleted file mode 100644 index 4f53987..0000000 --- a/algosdk/client/v2/indexer/searchForTransactions.d.ts +++ /dev/null @@ -1,352 +0,0 @@ -import JSONRequest from '../jsonrequest'; -/** - * Returns information about indexed transactions. - * - * #### Example - * ```typescript - * const txns = await indexerClient.searchForTransactions().do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2transactions) - * @category GET - */ -export default class SearchForTransactions extends JSONRequest { - /** - * @returns `/v2/transactions` - */ - path(): string; - /** - * Specifies a prefix which must be contained in the note field. - * - * #### Example - * ```typescript - * const notePrefixBase64Encoded = "Y3JlYXRl"; - * const txns = await indexerClient - * .searchForTransactions() - * .notePrefix(notePrefixBase64Encoded) - * .do(); - * ``` - * - * @param prefix - base64 string or uint8array - * @category query - */ - notePrefix(prefix: Uint8Array | string): this; - /** - * Type of transaction to filter with. - * - * #### Example - * ```typescript - * const txns = await indexerClient - * .searchForTransactions() - * .txType("keyreg") - * .do(); - * ``` - * - * @param type - one of `pay`, `keyreg`, `acfg`, `axfer`, `afrz`, `appl`, `stpf` - * @category query - */ - txType(type: string): this; - /** - * Type of signature to filter with. - * - sig: Standard - * - msig: MultiSig - * - lsig: LogicSig - * - * #### Example - * ```typescript - * const txns = await indexerClient - * .searchForTransactions() - * .sigType("sig") - * .do(); - * ``` - * - * @param type - one of `sig`, `msig`, `lsig` - * @category query - */ - sigType(type: string): this; - /** - * Lookup the specific transaction by ID. - * - * #### Example - * ```typescript - * const txId = "MEUOC4RQJB23CQZRFRKYEI6WBO73VTTPST5A7B3S5OKBUY6LFUDA"; - * const txns = await indexerClient - * .searchForTransactions() - * .txid(txId) - * .do(); - * ``` - * @remarks Alternatively, use `indexerClient.lookupTransactionByID(txnId).do()` - * @param txid - * @category query - */ - txid(txid: string): this; - /** - * Include results for the specified round. - * - * #### Example - * ```typescript - * const targetBlock = 18309917; - * const txns = await indexerClient - * .searchForTransactions() - * .round(targetBlock) - * .do(); - * ``` - * @remarks Alternatively, use `indexerClient.lookupBlock(targetBlock).do()` - * @param round - * @category query - */ - round(round: number): this; - /** - * Include results at or after the specified min-round. - * - * #### Example - * ```typescript - * const minRound = 18309917; - * const txns = await indexerClient - * .searchForTransactions() - * .minRound(minRound) - * .do(); - * ``` - * - * @param round - * @category query - */ - minRound(round: number): this; - /** - * Include results at or before the specified max-round. - * - * #### Example - * ```typescript - * const maxRound = 18309917; - * const txns = await indexerClient - * .searchForTransactions() - * .maxRound(maxRound) - * .do(); - * ``` - * - * @param round - * @category query - */ - maxRound(round: number): this; - /** - * Asset ID to filter with. - * - * #### Example - * ```typescript - * const assetID = 163650; - * const txns = await indexerClient - * .searchForTransactions() - * .assetID(assetID) - * .do(); - * ``` - * @remarks Alternatively, use `indexerClient.lookupAssetTransactions(assetId).do()` - * @param id - * @category query - */ - assetID(id: number): this; - /** - * Maximum number of results to return. - * - * #### Example - * ```typescript - * const maxResults = 25; - * const txns = await indexerClient - * .searchForTransactions() - * .limit(maxResults) - * .do(); - * ``` - * - * @param limit - * @category query - */ - limit(limit: number): this; - /** - * Include results before the given time. - * - * #### Example - * ```typescript - * const beforeTime = "2022-02-02T20:20:22.02Z"; - * const txns = await indexerClient - * .searchForTransactions() - * .beforeTime(beforeTime) - * .do(); - * ``` - * - * @param before - rfc3339 string - * @category query - */ - beforeTime(before: string): this; - /** - * Include results after the given time. - * - * #### Example - * ```typescript - * const afterTime = "2022-10-21T00:00:11.55Z"; - * const txns = await indexerClient - * .searchForTransactions() - * .afterTime(afterTime) - * .do(); - * ``` - * - * @param after - rfc3339 string - * @category query - */ - afterTime(after: string): this; - /** - * Combined with address, defines what address to filter on, as string. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const role = "freeze-target"; - * const txns = await indexerClient - * .searchForTransactions() - * .address(address) - * .addressRole(role) - * .do(); - * ``` - * - * @param role - one of `sender`, `receiver`, `freeze-target` - * @category query - */ - addressRole(role: string): this; - /** - * Only include transactions with this address in one of the transaction fields. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const txns = await indexerClient - * .searchForTransactions() - * .address(address) - * .do(); - * ``` - * @remarks Alternatively, use `indexerClient.lookupAccountTransactions(address).do()` - * @param address - * @category query - */ - address(address: string): this; - /** - * Whether or not to consider the `close-to` field as a receiver when filtering transactions, as bool. Set to `true` to ignore `close-to`. - * - * #### Example - * ```typescript - * const txns = await indexerClient - * .searchForTransactions() - * .excludeCloseTo(true) - * .do(); - * ``` - * - * @param exclude - * @category query - */ - excludeCloseTo(exclude: boolean): this; - /** - * The next page of results. - * - * #### Example - * ```typescript - * const maxResults = 25; - * - * const txnsPage1 = await indexerClient - * .searchForTransactions() - * .limit(maxResults) - * .do(); - * - * const txnsPage2 = await indexerClient - * .searchForTransactions() - * .limit(maxResults) - * .nextToken(txnsPage1["next-token"]) - * .do(); - * ``` - * - * @param nextToken - provided by the previous results - * @category query - */ - nextToken(nextToken: string): this; - /** - * Whether or not to include rekeying transactions. - * - * #### Example - * ```typescript - * const txns = await indexerClient - * .searchForTransactions() - * .rekeyTo(false) - * .do(); - * ``` - * - * @param rekeyTo - * @category query - */ - rekeyTo(rekeyTo: boolean): this; - /** - * Filter for this application. - * - * #### Example - * ```typescript - * const appId = 60553466; - * const txns = await indexerClient - * .searchForTransactions() - * .applicationID(appId) - * .do(); - * ``` - * - * @param applicationID - * @category query - */ - applicationID(applicationID: number): this; - /** - * Filtered results should have an amount greater than this value, as int, representing microAlgos, unless an asset-id is provided, in which case units are in the asset's units. - * - * #### Example 1 - * ```typescript - * const minBalance = 300000; - * const txns = await indexerClient - * .searchForTransactions() - * .currencyGreaterThan(minBalance - 1) - * .do(); - * ``` - * - * #### Example 2 - * ```typescript - * const assetID = 163650; - * const minBalance = 300000; - * const txns = await indexerClient - * .searchForTransactions() - * .assetID(assetID) - * .currencyGreaterThan(minBalance - 1) - * .do(); - * ``` - * - * @param greater - * @category query - */ - currencyGreaterThan(greater: number): this; - /** - * Filtered results should have an amount less than this value, as int, representing microAlgos, unless an asset-id is provided, in which case units are in the asset's units. - * - * #### Example 1 - * ```typescript - * const maxBalance = 500000; - * const txns = await indexerClient - * .searchForTransactions() - * .currencyLessThan(maxBalance + 1) - * .do(); - * ``` - * - * #### Example 2 - * ```typescript - * const assetID = 163650; - * const maxBalance = 500000; - * const txns = await indexerClient - * .searchForTransactions() - * .assetID(assetID) - * .currencyLessThan(maxBalance + 1) - * .do(); - * ``` - * - * @param lesser - * @category query - */ - currencyLessThan(lesser: number): this; -} diff --git a/algosdk/client/v2/indexer/searchForTransactions.js b/algosdk/client/v2/indexer/searchForTransactions.js deleted file mode 100644 index e6e2366..0000000 --- a/algosdk/client/v2/indexer/searchForTransactions.js +++ /dev/null @@ -1,420 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const jsonrequest_1 = __importDefault(require("../jsonrequest")); -const lookupAccountTransactions_1 = require("./lookupAccountTransactions"); -/** - * Returns information about indexed transactions. - * - * #### Example - * ```typescript - * const txns = await indexerClient.searchForTransactions().do(); - * ``` - * - * [Response data schema details](https://developer.algorand.org/docs/rest-apis/indexer/#get-v2transactions) - * @category GET - */ -class SearchForTransactions extends jsonrequest_1.default { - /** - * @returns `/v2/transactions` - */ - // eslint-disable-next-line class-methods-use-this - path() { - return '/v2/transactions'; - } - /** - * Specifies a prefix which must be contained in the note field. - * - * #### Example - * ```typescript - * const notePrefixBase64Encoded = "Y3JlYXRl"; - * const txns = await indexerClient - * .searchForTransactions() - * .notePrefix(notePrefixBase64Encoded) - * .do(); - * ``` - * - * @param prefix - base64 string or uint8array - * @category query - */ - notePrefix(prefix) { - this.query['note-prefix'] = (0, lookupAccountTransactions_1.base64StringFunnel)(prefix); - return this; - } - /** - * Type of transaction to filter with. - * - * #### Example - * ```typescript - * const txns = await indexerClient - * .searchForTransactions() - * .txType("keyreg") - * .do(); - * ``` - * - * @param type - one of `pay`, `keyreg`, `acfg`, `axfer`, `afrz`, `appl`, `stpf` - * @category query - */ - txType(type) { - this.query['tx-type'] = type; - return this; - } - /** - * Type of signature to filter with. - * - sig: Standard - * - msig: MultiSig - * - lsig: LogicSig - * - * #### Example - * ```typescript - * const txns = await indexerClient - * .searchForTransactions() - * .sigType("sig") - * .do(); - * ``` - * - * @param type - one of `sig`, `msig`, `lsig` - * @category query - */ - sigType(type) { - this.query['sig-type'] = type; - return this; - } - /** - * Lookup the specific transaction by ID. - * - * #### Example - * ```typescript - * const txId = "MEUOC4RQJB23CQZRFRKYEI6WBO73VTTPST5A7B3S5OKBUY6LFUDA"; - * const txns = await indexerClient - * .searchForTransactions() - * .txid(txId) - * .do(); - * ``` - * @remarks Alternatively, use `indexerClient.lookupTransactionByID(txnId).do()` - * @param txid - * @category query - */ - txid(txid) { - this.query.txid = txid; - return this; - } - /** - * Include results for the specified round. - * - * #### Example - * ```typescript - * const targetBlock = 18309917; - * const txns = await indexerClient - * .searchForTransactions() - * .round(targetBlock) - * .do(); - * ``` - * @remarks Alternatively, use `indexerClient.lookupBlock(targetBlock).do()` - * @param round - * @category query - */ - round(round) { - this.query.round = round; - return this; - } - /** - * Include results at or after the specified min-round. - * - * #### Example - * ```typescript - * const minRound = 18309917; - * const txns = await indexerClient - * .searchForTransactions() - * .minRound(minRound) - * .do(); - * ``` - * - * @param round - * @category query - */ - minRound(round) { - this.query['min-round'] = round; - return this; - } - /** - * Include results at or before the specified max-round. - * - * #### Example - * ```typescript - * const maxRound = 18309917; - * const txns = await indexerClient - * .searchForTransactions() - * .maxRound(maxRound) - * .do(); - * ``` - * - * @param round - * @category query - */ - maxRound(round) { - this.query['max-round'] = round; - return this; - } - /** - * Asset ID to filter with. - * - * #### Example - * ```typescript - * const assetID = 163650; - * const txns = await indexerClient - * .searchForTransactions() - * .assetID(assetID) - * .do(); - * ``` - * @remarks Alternatively, use `indexerClient.lookupAssetTransactions(assetId).do()` - * @param id - * @category query - */ - assetID(id) { - this.query['asset-id'] = id; - return this; - } - /** - * Maximum number of results to return. - * - * #### Example - * ```typescript - * const maxResults = 25; - * const txns = await indexerClient - * .searchForTransactions() - * .limit(maxResults) - * .do(); - * ``` - * - * @param limit - * @category query - */ - limit(limit) { - this.query.limit = limit; - return this; - } - /** - * Include results before the given time. - * - * #### Example - * ```typescript - * const beforeTime = "2022-02-02T20:20:22.02Z"; - * const txns = await indexerClient - * .searchForTransactions() - * .beforeTime(beforeTime) - * .do(); - * ``` - * - * @param before - rfc3339 string - * @category query - */ - beforeTime(before) { - this.query['before-time'] = before; - return this; - } - /** - * Include results after the given time. - * - * #### Example - * ```typescript - * const afterTime = "2022-10-21T00:00:11.55Z"; - * const txns = await indexerClient - * .searchForTransactions() - * .afterTime(afterTime) - * .do(); - * ``` - * - * @param after - rfc3339 string - * @category query - */ - afterTime(after) { - this.query['after-time'] = after; - return this; - } - /** - * Combined with address, defines what address to filter on, as string. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const role = "freeze-target"; - * const txns = await indexerClient - * .searchForTransactions() - * .address(address) - * .addressRole(role) - * .do(); - * ``` - * - * @param role - one of `sender`, `receiver`, `freeze-target` - * @category query - */ - addressRole(role) { - this.query['address-role'] = role; - return this; - } - /** - * Only include transactions with this address in one of the transaction fields. - * - * #### Example - * ```typescript - * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA"; - * const txns = await indexerClient - * .searchForTransactions() - * .address(address) - * .do(); - * ``` - * @remarks Alternatively, use `indexerClient.lookupAccountTransactions(address).do()` - * @param address - * @category query - */ - address(address) { - this.query.address = address; - return this; - } - /** - * Whether or not to consider the `close-to` field as a receiver when filtering transactions, as bool. Set to `true` to ignore `close-to`. - * - * #### Example - * ```typescript - * const txns = await indexerClient - * .searchForTransactions() - * .excludeCloseTo(true) - * .do(); - * ``` - * - * @param exclude - * @category query - */ - excludeCloseTo(exclude) { - this.query['exclude-close-to'] = exclude; - return this; - } - /** - * The next page of results. - * - * #### Example - * ```typescript - * const maxResults = 25; - * - * const txnsPage1 = await indexerClient - * .searchForTransactions() - * .limit(maxResults) - * .do(); - * - * const txnsPage2 = await indexerClient - * .searchForTransactions() - * .limit(maxResults) - * .nextToken(txnsPage1["next-token"]) - * .do(); - * ``` - * - * @param nextToken - provided by the previous results - * @category query - */ - nextToken(nextToken) { - this.query.next = nextToken; - return this; - } - /** - * Whether or not to include rekeying transactions. - * - * #### Example - * ```typescript - * const txns = await indexerClient - * .searchForTransactions() - * .rekeyTo(false) - * .do(); - * ``` - * - * @param rekeyTo - * @category query - */ - rekeyTo(rekeyTo) { - this.query['rekey-to'] = rekeyTo; - return this; - } - /** - * Filter for this application. - * - * #### Example - * ```typescript - * const appId = 60553466; - * const txns = await indexerClient - * .searchForTransactions() - * .applicationID(appId) - * .do(); - * ``` - * - * @param applicationID - * @category query - */ - applicationID(applicationID) { - this.query['application-id'] = applicationID; - return this; - } - /** - * Filtered results should have an amount greater than this value, as int, representing microAlgos, unless an asset-id is provided, in which case units are in the asset's units. - * - * #### Example 1 - * ```typescript - * const minBalance = 300000; - * const txns = await indexerClient - * .searchForTransactions() - * .currencyGreaterThan(minBalance - 1) - * .do(); - * ``` - * - * #### Example 2 - * ```typescript - * const assetID = 163650; - * const minBalance = 300000; - * const txns = await indexerClient - * .searchForTransactions() - * .assetID(assetID) - * .currencyGreaterThan(minBalance - 1) - * .do(); - * ``` - * - * @param greater - * @category query - */ - currencyGreaterThan(greater) { - // We convert the following to a string for now to correctly include zero values in request parameters. - this.query['currency-greater-than'] = greater.toString(); - return this; - } - /** - * Filtered results should have an amount less than this value, as int, representing microAlgos, unless an asset-id is provided, in which case units are in the asset's units. - * - * #### Example 1 - * ```typescript - * const maxBalance = 500000; - * const txns = await indexerClient - * .searchForTransactions() - * .currencyLessThan(maxBalance + 1) - * .do(); - * ``` - * - * #### Example 2 - * ```typescript - * const assetID = 163650; - * const maxBalance = 500000; - * const txns = await indexerClient - * .searchForTransactions() - * .assetID(assetID) - * .currencyLessThan(maxBalance + 1) - * .do(); - * ``` - * - * @param lesser - * @category query - */ - currencyLessThan(lesser) { - this.query['currency-less-than'] = lesser; - return this; - } -} -exports.default = SearchForTransactions; diff --git a/algosdk/client/v2/jsonrequest.d.ts b/algosdk/client/v2/jsonrequest.d.ts deleted file mode 100644 index 1742eb9..0000000 --- a/algosdk/client/v2/jsonrequest.d.ts +++ /dev/null @@ -1,66 +0,0 @@ -import HTTPClient from '../client'; -import IntDecoding from '../../types/intDecoding'; -/** - * Base abstract class for JSON requests. - * - * Data: The type returned from the `do()` method - * - * Body: The structure of the response's body - */ -export default abstract class JSONRequest, Body = Data | Uint8Array> { - c: HTTPClient; - query: Record; - intDecoding: IntDecoding; - /** - * @param client - HTTPClient object. - * @param intDecoding - The method to use - * for decoding integers from this request's response. See the setIntDecoding method for more - * details. - */ - constructor(client: HTTPClient, intDecoding?: IntDecoding); - /** - * @returns The path of this request. - * @category JSONRequest - */ - abstract path(): string; - /** - * Prepare a JSON response before returning it. - * - * Use this method to change and restructure response - * data as needed after receiving it from the `do()` method. - * @param body - Response body received - * @category JSONRequest - */ - prepare(body: Body): Data; - /** - * Execute the request. - * @param headers - Additional headers to send in the request. Optional. - * @returns A promise which resolves to the parsed response data. - * @category JSONRequest - */ - do(headers?: Record): Promise; - /** - * Execute the request, but do not process the response data in any way. - * @param headers - Additional headers to send in the request. Optional. - * @returns A promise which resolves to the raw response data, exactly as returned by the server. - * @category JSONRequest - */ - doRaw(headers?: Record): Promise; - /** - * Configure how integers in this request's JSON response will be decoded. - * - * The options are: - * * "default": Integers will be decoded according to JSON.parse, meaning they will all be - * Numbers and any values greater than Number.MAX_SAFE_INTEGER will lose precision. - * * "safe": All integers will be decoded as Numbers, but if any values are greater than - * Number.MAX_SAFE_INTEGER an error will be thrown. - * * "mixed": Integers will be decoded as Numbers if they are less than or equal to - * Number.MAX_SAFE_INTEGER, otherwise they will be decoded as BigInts. - * * "bigint": All integers will be decoded as BigInts. - * - * @param method - The method to use when parsing the - * response for this request. Must be one of "default", "safe", "mixed", or "bigint". - * @category JSONRequest - */ - setIntDecoding(method: IntDecoding): this; -} diff --git a/algosdk/client/v2/jsonrequest.js b/algosdk/client/v2/jsonrequest.js deleted file mode 100644 index cf2b0ed..0000000 --- a/algosdk/client/v2/jsonrequest.js +++ /dev/null @@ -1,88 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const intDecoding_1 = __importDefault(require("../../types/intDecoding")); -/** - * Base abstract class for JSON requests. - * - * Data: The type returned from the `do()` method - * - * Body: The structure of the response's body - */ -class JSONRequest { - /** - * @param client - HTTPClient object. - * @param intDecoding - The method to use - * for decoding integers from this request's response. See the setIntDecoding method for more - * details. - */ - constructor(client, intDecoding) { - this.c = client; - this.query = {}; - this.intDecoding = intDecoding || intDecoding_1.default.DEFAULT; - } - /** - * Prepare a JSON response before returning it. - * - * Use this method to change and restructure response - * data as needed after receiving it from the `do()` method. - * @param body - Response body received - * @category JSONRequest - */ - // eslint-disable-next-line class-methods-use-this - prepare(body) { - return body; - } - /** - * Execute the request. - * @param headers - Additional headers to send in the request. Optional. - * @returns A promise which resolves to the parsed response data. - * @category JSONRequest - */ - async do(headers = {}) { - const jsonOptions = {}; - if (this.intDecoding !== 'default') { - jsonOptions.intDecoding = this.intDecoding; - } - const res = await this.c.get(this.path(), this.query, headers, jsonOptions); - return this.prepare(res.body); - } - /** - * Execute the request, but do not process the response data in any way. - * @param headers - Additional headers to send in the request. Optional. - * @returns A promise which resolves to the raw response data, exactly as returned by the server. - * @category JSONRequest - */ - async doRaw(headers = {}) { - const res = await this.c.get(this.path(), this.query, headers, {}, false); - return res.body; - } - /** - * Configure how integers in this request's JSON response will be decoded. - * - * The options are: - * * "default": Integers will be decoded according to JSON.parse, meaning they will all be - * Numbers and any values greater than Number.MAX_SAFE_INTEGER will lose precision. - * * "safe": All integers will be decoded as Numbers, but if any values are greater than - * Number.MAX_SAFE_INTEGER an error will be thrown. - * * "mixed": Integers will be decoded as Numbers if they are less than or equal to - * Number.MAX_SAFE_INTEGER, otherwise they will be decoded as BigInts. - * * "bigint": All integers will be decoded as BigInts. - * - * @param method - The method to use when parsing the - * response for this request. Must be one of "default", "safe", "mixed", or "bigint". - * @category JSONRequest - */ - setIntDecoding(method) { - if (method !== 'default' && - method !== 'safe' && - method !== 'mixed' && - method !== 'bigint') - throw new Error(`Invalid method for int decoding: ${method}`); - this.intDecoding = method; - return this; - } -} -exports.default = JSONRequest; diff --git a/algosdk/client/v2/serviceClient.d.ts b/algosdk/client/v2/serviceClient.d.ts deleted file mode 100644 index 99d671b..0000000 --- a/algosdk/client/v2/serviceClient.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -import HTTPClient from '../client'; -import IntDecoding from '../../types/intDecoding'; -import { BaseHTTPClient } from '../baseHTTPClient'; -import { TokenHeader } from '../urlTokenBaseHTTPClient'; -export declare type TokenHeaderIdentifier = 'X-Indexer-API-Token' | 'X-KMD-API-Token' | 'X-Algo-API-Token' | string; -/** - * Abstract service client to encapsulate shared AlgodClient and IndexerClient logic - */ -export default abstract class ServiceClient { - /** @ignore */ - c: HTTPClient; - /** @ignore */ - intDecoding: IntDecoding; - constructor(tokenHeaderIdentifier: TokenHeaderIdentifier, tokenHeaderOrStrOrBaseClient: string | TokenHeader | BaseHTTPClient, baseServer: string, port?: string | number, defaultHeaders?: Record); - /** - * Set the default int decoding method for all JSON requests this client creates. - * @param method - \{"default" | "safe" | "mixed" | "bigint"\} method The method to use when parsing the - * response for request. Must be one of "default", "safe", "mixed", or "bigint". See - * JSONRequest.setIntDecoding for more details about what each method does. - */ - setIntEncoding(method: IntDecoding): void; - /** - * Get the default int decoding method for all JSON requests this client creates. - */ - getIntEncoding(): IntDecoding; -} diff --git a/algosdk/client/v2/serviceClient.js b/algosdk/client/v2/serviceClient.js deleted file mode 100644 index b0430b3..0000000 --- a/algosdk/client/v2/serviceClient.js +++ /dev/null @@ -1,63 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const client_1 = __importDefault(require("../client")); -const intDecoding_1 = __importDefault(require("../../types/intDecoding")); -/** - * Convert a token string to a token header - * @param token - The token string - * @param headerIdentifier - An identifier for the token header - */ -function convertTokenStringToTokenHeader(headerIdentifier, token = '') { - const tokenHeader = {}; - if (token === '') { - return tokenHeader; - } - tokenHeader[headerIdentifier] = token; - return tokenHeader; -} -function isBaseHTTPClient(tbc) { - return typeof tbc.get === 'function'; -} -/** - * Abstract service client to encapsulate shared AlgodClient and IndexerClient logic - */ -class ServiceClient { - constructor(tokenHeaderIdentifier, tokenHeaderOrStrOrBaseClient, baseServer, port, defaultHeaders = {}) { - if (isBaseHTTPClient(tokenHeaderOrStrOrBaseClient)) { - // we are using a base client - this.c = new client_1.default(tokenHeaderOrStrOrBaseClient); - } - else { - // Accept token header as string or object - // - workaround to allow backwards compatibility for multiple headers - let tokenHeader; - if (typeof tokenHeaderOrStrOrBaseClient === 'string') { - tokenHeader = convertTokenStringToTokenHeader(tokenHeaderIdentifier, tokenHeaderOrStrOrBaseClient); - } - else { - tokenHeader = tokenHeaderOrStrOrBaseClient; - } - this.c = new client_1.default(tokenHeader, baseServer, port, defaultHeaders); - } - this.intDecoding = intDecoding_1.default.DEFAULT; - } - /** - * Set the default int decoding method for all JSON requests this client creates. - * @param method - \{"default" | "safe" | "mixed" | "bigint"\} method The method to use when parsing the - * response for request. Must be one of "default", "safe", "mixed", or "bigint". See - * JSONRequest.setIntDecoding for more details about what each method does. - */ - setIntEncoding(method) { - this.intDecoding = method; - } - /** - * Get the default int decoding method for all JSON requests this client creates. - */ - getIntEncoding() { - return this.intDecoding; - } -} -exports.default = ServiceClient; diff --git a/algosdk/composer.d.ts b/algosdk/composer.d.ts deleted file mode 100644 index b65674a..0000000 --- a/algosdk/composer.d.ts +++ /dev/null @@ -1,204 +0,0 @@ -import { ABIMethod, ABIValue } from './abi'; -import Algodv2 from './client/v2/algod/algod'; -import { SimulateRequest, PendingTransactionResponse, SimulateResponse } from './client/v2/algod/models/types'; -import { TransactionSigner, TransactionWithSigner } from './signer'; -import { BoxReference, OnApplicationComplete, SuggestedParams } from './types/transactions/base'; -export declare type ABIArgument = ABIValue | TransactionWithSigner; -/** Represents the output from a successful ABI method call. */ -export interface ABIResult { - /** The TxID of the transaction that invoked the ABI method call. */ - txID: string; - /** - * The raw bytes of the return value from the ABI method call. This will be empty if the method - * does not return a value (return type "void"). - */ - rawReturnValue: Uint8Array; - /** - * The method that was called for this result - */ - method: ABIMethod; - /** - * The return value from the ABI method call. This will be undefined if the method does not return - * a value (return type "void"), or if the SDK was unable to decode the returned value. - */ - returnValue?: ABIValue; - /** If the SDK was unable to decode a return value, the error will be here. */ - decodeError?: Error; - /** The pending transaction information from the method transaction */ - txInfo?: PendingTransactionResponse; -} -export declare enum AtomicTransactionComposerStatus { - /** The atomic group is still under construction. */ - BUILDING = 0, - /** The atomic group has been finalized, but not yet signed. */ - BUILT = 1, - /** The atomic group has been finalized and signed, but not yet submitted to the network. */ - SIGNED = 2, - /** The atomic group has been finalized, signed, and submitted to the network. */ - SUBMITTED = 3, - /** The atomic group has been finalized, signed, submitted, and successfully committed to a block. */ - COMMITTED = 4 -} -/** A class used to construct and execute atomic transaction groups */ -export declare class AtomicTransactionComposer { - /** The maximum size of an atomic transaction group. */ - static MAX_GROUP_SIZE: number; - private status; - private transactions; - private methodCalls; - private signedTxns; - private txIDs; - /** - * Get the status of this composer's transaction group. - */ - getStatus(): AtomicTransactionComposerStatus; - /** - * Get the number of transactions currently in this atomic group. - */ - count(): number; - /** - * Create a new composer with the same underlying transactions. The new composer's status will be - * BUILDING, so additional transactions may be added to it. - */ - clone(): AtomicTransactionComposer; - /** - * Add a transaction to this atomic group. - * - * An error will be thrown if the transaction has a nonzero group ID, the composer's status is - * not BUILDING, or if adding this transaction causes the current group to exceed MAX_GROUP_SIZE. - */ - addTransaction(txnAndSigner: TransactionWithSigner): void; - /** - * Add a smart contract method call to this atomic group. - * - * An error will be thrown if the composer's status is not BUILDING, if adding this transaction - * causes the current group to exceed MAX_GROUP_SIZE, or if the provided arguments are invalid - * for the given method. - */ - addMethodCall({ appID, method, methodArgs, sender, suggestedParams, onComplete, approvalProgram, clearProgram, numGlobalInts, numGlobalByteSlices, numLocalInts, numLocalByteSlices, extraPages, appAccounts, appForeignApps, appForeignAssets, boxes, note, lease, rekeyTo, signer, }: { - /** The ID of the smart contract to call. Set this to 0 to indicate an application creation call. */ - appID: number; - /** The method to call on the smart contract */ - method: ABIMethod; - /** The arguments to include in the method call. If omitted, no arguments will be passed to the method. */ - methodArgs?: ABIArgument[]; - /** The address of the sender of this application call */ - sender: string; - /** Transactions params to use for this application call */ - suggestedParams: SuggestedParams; - /** The OnComplete action to take for this application call. If omitted, OnApplicationComplete.NoOpOC will be used. */ - onComplete?: OnApplicationComplete; - /** The approval program for this application call. Only set this if this is an application creation call, or if onComplete is OnApplicationComplete.UpdateApplicationOC */ - approvalProgram?: Uint8Array; - /** The clear program for this application call. Only set this if this is an application creation call, or if onComplete is OnApplicationComplete.UpdateApplicationOC */ - clearProgram?: Uint8Array; - /** The global integer schema size. Only set this if this is an application creation call. */ - numGlobalInts?: number; - /** The global byte slice schema size. Only set this if this is an application creation call. */ - numGlobalByteSlices?: number; - /** The local integer schema size. Only set this if this is an application creation call. */ - numLocalInts?: number; - /** The local byte slice schema size. Only set this if this is an application creation call. */ - numLocalByteSlices?: number; - /** The number of extra pages to allocate for the application's programs. Only set this if this is an application creation call. If omitted, defaults to 0. */ - extraPages?: number; - /** Array of Address strings that represent external accounts supplied to this application. If accounts are provided here, the accounts specified in the method args will appear after these. */ - appAccounts?: string[]; - /** Array of App ID numbers that represent external apps supplied to this application. If apps are provided here, the apps specified in the method args will appear after these. */ - appForeignApps?: number[]; - /** Array of Asset ID numbers that represent external assets supplied to this application. If assets are provided here, the assets specified in the method args will appear after these. */ - appForeignAssets?: number[]; - /** The box references for this application call */ - boxes?: BoxReference[]; - /** The note value for this application call */ - note?: Uint8Array; - /** The lease value for this application call */ - lease?: Uint8Array; - /** If provided, the address that the sender will be rekeyed to at the conclusion of this application call */ - rekeyTo?: string; - /** A transaction signer that can authorize this application call from sender */ - signer: TransactionSigner; - }): void; - /** - * Finalize the transaction group and returned the finalized transactions. - * - * The composer's status will be at least BUILT after executing this method. - */ - buildGroup(): TransactionWithSigner[]; - /** - * Obtain signatures for each transaction in this group. If signatures have already been obtained, - * this method will return cached versions of the signatures. - * - * The composer's status will be at least SIGNED after executing this method. - * - * An error will be thrown if signing any of the transactions fails. - * - * @returns A promise that resolves to an array of signed transactions. - */ - gatherSignatures(): Promise; - /** - * Send the transaction group to the network, but don't wait for it to be committed to a block. An - * error will be thrown if submission fails. - * - * The composer's status must be SUBMITTED or lower before calling this method. If submission is - * successful, this composer's status will update to SUBMITTED. - * - * Note: a group can only be submitted again if it fails. - * - * @param client - An Algodv2 client - * - * @returns A promise that, upon success, resolves to a list of TxIDs of the submitted transactions. - */ - submit(client: Algodv2): Promise; - /** - * Simulates the transaction group in the network. - * - * The composer will try to sign any transactions in the group, then simulate - * the results. - * Simulating the group will not change the composer's status. - * - * @param client - An Algodv2 client - * @param request - SimulateRequest with options in simulation. - * If provided, the request's transaction group will be overrwritten by the composer's group, - * only simulation related options will be used. - * - * @returns A promise that, upon success, resolves to an object containing an - * array of results containing one element for each method call transaction - * in this group (ABIResult[]) and the SimulateResponse object. - */ - simulate(client: Algodv2, request?: SimulateRequest): Promise<{ - methodResults: ABIResult[]; - simulateResponse: SimulateResponse; - }>; - /** - * Send the transaction group to the network and wait until it's committed to a block. An error - * will be thrown if submission or execution fails. - * - * The composer's status must be SUBMITTED or lower before calling this method, since execution is - * only allowed once. If submission is successful, this composer's status will update to SUBMITTED. - * If the execution is also successful, this composer's status will update to COMMITTED. - * - * Note: a group can only be submitted again if it fails. - * - * @param client - An Algodv2 client - * @param waitRounds - The maximum number of rounds to wait for transaction confirmation - * - * @returns A promise that, upon success, resolves to an object containing the confirmed round for - * this transaction, the txIDs of the submitted transactions, and an array of results containing - * one element for each method call transaction in this group. - */ - execute(client: Algodv2, waitRounds: number): Promise<{ - confirmedRound: number; - txIDs: string[]; - methodResults: ABIResult[]; - }>; - /** - * Parses a single ABI Method transaction log into a ABI result object. - * - * @param method - * @param methodResult - * @param pendingInfo - * @returns An ABIResult object - */ - static parseMethodResponse(method: ABIMethod, methodResult: ABIResult, pendingInfo: PendingTransactionResponse): ABIResult; -} diff --git a/algosdk/composer.js b/algosdk/composer.js deleted file mode 100644 index 214e2be..0000000 --- a/algosdk/composer.js +++ /dev/null @@ -1,532 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.AtomicTransactionComposer = exports.AtomicTransactionComposerStatus = void 0; -const abi_1 = require("./abi"); -const types_1 = require("./client/v2/algod/models/types"); -const encoding = __importStar(require("./encoding/encoding")); -const group_1 = require("./group"); -const makeTxn_1 = require("./makeTxn"); -const signer_1 = require("./signer"); -const transaction_1 = require("./transaction"); -const base_1 = require("./types/transactions/base"); -const utils_1 = require("./utils/utils"); -const wait_1 = require("./wait"); -// First 4 bytes of SHA-512/256 hash of "return" -const RETURN_PREFIX = new Uint8Array([21, 31, 124, 117]); -// The maximum number of arguments for an application call transaction -const MAX_APP_ARGS = 16; -var AtomicTransactionComposerStatus; -(function (AtomicTransactionComposerStatus) { - /** The atomic group is still under construction. */ - AtomicTransactionComposerStatus[AtomicTransactionComposerStatus["BUILDING"] = 0] = "BUILDING"; - /** The atomic group has been finalized, but not yet signed. */ - AtomicTransactionComposerStatus[AtomicTransactionComposerStatus["BUILT"] = 1] = "BUILT"; - /** The atomic group has been finalized and signed, but not yet submitted to the network. */ - AtomicTransactionComposerStatus[AtomicTransactionComposerStatus["SIGNED"] = 2] = "SIGNED"; - /** The atomic group has been finalized, signed, and submitted to the network. */ - AtomicTransactionComposerStatus[AtomicTransactionComposerStatus["SUBMITTED"] = 3] = "SUBMITTED"; - /** The atomic group has been finalized, signed, submitted, and successfully committed to a block. */ - AtomicTransactionComposerStatus[AtomicTransactionComposerStatus["COMMITTED"] = 4] = "COMMITTED"; -})(AtomicTransactionComposerStatus = exports.AtomicTransactionComposerStatus || (exports.AtomicTransactionComposerStatus = {})); -/** - * Add a value to an application call's foreign array. The addition will be as compact as possible, - * and this function will return an index that can be used to reference `valueToAdd` in `array`. - * - * @param valueToAdd - The value to add to the array. If this value is already present in the array, - * it will not be added again. Instead, the existing index will be returned. - * @param array - The existing foreign array. This input may be modified to append `valueToAdd`. - * @param zeroValue - If provided, this value indicated two things: the 0 value is special for this - * array, so all indexes into `array` must start at 1; additionally, if `valueToAdd` equals - * `zeroValue`, then `valueToAdd` will not be added to the array, and instead the 0 indexes will - * be returned. - * @returns An index that can be used to reference `valueToAdd` in `array`. - */ -function populateForeignArray(valueToAdd, array, zeroValue) { - if (zeroValue != null && valueToAdd === zeroValue) { - return 0; - } - const offset = zeroValue == null ? 0 : 1; - for (let i = 0; i < array.length; i++) { - if (valueToAdd === array[i]) { - return i + offset; - } - } - array.push(valueToAdd); - return array.length - 1 + offset; -} -/** A class used to construct and execute atomic transaction groups */ -class AtomicTransactionComposer { - constructor() { - this.status = AtomicTransactionComposerStatus.BUILDING; - this.transactions = []; - this.methodCalls = new Map(); - this.signedTxns = []; - this.txIDs = []; - } - /** - * Get the status of this composer's transaction group. - */ - getStatus() { - return this.status; - } - /** - * Get the number of transactions currently in this atomic group. - */ - count() { - return this.transactions.length; - } - /** - * Create a new composer with the same underlying transactions. The new composer's status will be - * BUILDING, so additional transactions may be added to it. - */ - clone() { - const theClone = new AtomicTransactionComposer(); - theClone.transactions = this.transactions.map(({ txn, signer }) => ({ - // not quite a deep copy, but good enough for our purposes (modifying txn.group in buildGroup) - txn: transaction_1.Transaction.from_obj_for_encoding({ - ...txn.get_obj_for_encoding(), - // erase the group ID - grp: undefined, - }), - signer, - })); - theClone.methodCalls = new Map(this.methodCalls); - return theClone; - } - /** - * Add a transaction to this atomic group. - * - * An error will be thrown if the transaction has a nonzero group ID, the composer's status is - * not BUILDING, or if adding this transaction causes the current group to exceed MAX_GROUP_SIZE. - */ - addTransaction(txnAndSigner) { - if (this.status !== AtomicTransactionComposerStatus.BUILDING) { - throw new Error('Cannot add transactions when composer status is not BUILDING'); - } - if (this.transactions.length === AtomicTransactionComposer.MAX_GROUP_SIZE) { - throw new Error(`Adding an additional transaction exceeds the maximum atomic group size of ${AtomicTransactionComposer.MAX_GROUP_SIZE}`); - } - if (txnAndSigner.txn.group && txnAndSigner.txn.group.some((v) => v !== 0)) { - throw new Error('Cannot add a transaction with nonzero group ID'); - } - this.transactions.push(txnAndSigner); - } - /** - * Add a smart contract method call to this atomic group. - * - * An error will be thrown if the composer's status is not BUILDING, if adding this transaction - * causes the current group to exceed MAX_GROUP_SIZE, or if the provided arguments are invalid - * for the given method. - */ - addMethodCall({ appID, method, methodArgs, sender, suggestedParams, onComplete, approvalProgram, clearProgram, numGlobalInts, numGlobalByteSlices, numLocalInts, numLocalByteSlices, extraPages, appAccounts, appForeignApps, appForeignAssets, boxes, note, lease, rekeyTo, signer, }) { - if (this.status !== AtomicTransactionComposerStatus.BUILDING) { - throw new Error('Cannot add transactions when composer status is not BUILDING'); - } - if (this.transactions.length + method.txnCount() > - AtomicTransactionComposer.MAX_GROUP_SIZE) { - throw new Error(`Adding additional transactions exceeds the maximum atomic group size of ${AtomicTransactionComposer.MAX_GROUP_SIZE}`); - } - if (appID === 0) { - if (approvalProgram == null || - clearProgram == null || - numGlobalInts == null || - numGlobalByteSlices == null || - numLocalInts == null || - numLocalByteSlices == null) { - throw new Error('One of the following required parameters for application creation is missing: approvalProgram, clearProgram, numGlobalInts, numGlobalByteSlices, numLocalInts, numLocalByteSlices'); - } - } - else if (onComplete === base_1.OnApplicationComplete.UpdateApplicationOC) { - if (approvalProgram == null || clearProgram == null) { - throw new Error('One of the following required parameters for OnApplicationComplete.UpdateApplicationOC is missing: approvalProgram, clearProgram'); - } - if (numGlobalInts != null || - numGlobalByteSlices != null || - numLocalInts != null || - numLocalByteSlices != null || - extraPages != null) { - throw new Error('One of the following application creation parameters were set on a non-creation call: numGlobalInts, numGlobalByteSlices, numLocalInts, numLocalByteSlices, extraPages'); - } - } - else if (approvalProgram != null || - clearProgram != null || - numGlobalInts != null || - numGlobalByteSlices != null || - numLocalInts != null || - numLocalByteSlices != null || - extraPages != null) { - throw new Error('One of the following application creation parameters were set on a non-creation call: approvalProgram, clearProgram, numGlobalInts, numGlobalByteSlices, numLocalInts, numLocalByteSlices, extraPages'); - } - if (methodArgs == null) { - // eslint-disable-next-line no-param-reassign - methodArgs = []; - } - if (methodArgs.length !== method.args.length) { - throw new Error(`Incorrect number of method arguments. Expected ${method.args.length}, got ${methodArgs.length}`); - } - let basicArgTypes = []; - let basicArgValues = []; - const txnArgs = []; - const refArgTypes = []; - const refArgValues = []; - const refArgIndexToBasicArgIndex = new Map(); - // TODO: Box encoding for ABI - const boxReferences = !boxes ? [] : boxes; - for (let i = 0; i < methodArgs.length; i++) { - let argType = method.args[i].type; - const argValue = methodArgs[i]; - if ((0, abi_1.abiTypeIsTransaction)(argType)) { - if (!(0, signer_1.isTransactionWithSigner)(argValue) || - !(0, abi_1.abiCheckTransactionType)(argType, argValue.txn)) { - throw new Error(`Expected ${argType} TransactionWithSigner for argument at index ${i}`); - } - if (argValue.txn.group && argValue.txn.group.some((v) => v !== 0)) { - throw new Error('Cannot add a transaction with nonzero group ID'); - } - txnArgs.push(argValue); - continue; - } - if ((0, signer_1.isTransactionWithSigner)(argValue)) { - throw new Error(`Expected non-transaction value for argument at index ${i}`); - } - if ((0, abi_1.abiTypeIsReference)(argType)) { - refArgIndexToBasicArgIndex.set(refArgTypes.length, basicArgTypes.length); - refArgTypes.push(argType); - refArgValues.push(argValue); - // treat the reference as a uint8 for encoding purposes - argType = new abi_1.ABIUintType(8); - } - if (typeof argType === 'string') { - throw new Error(`Unknown ABI type: ${argType}`); - } - basicArgTypes.push(argType); - basicArgValues.push(argValue); - } - const resolvedRefIndexes = []; - const foreignAccounts = appAccounts == null ? [] : appAccounts.slice(); - const foreignApps = appForeignApps == null ? [] : appForeignApps.slice(); - const foreignAssets = appForeignAssets == null ? [] : appForeignAssets.slice(); - for (let i = 0; i < refArgTypes.length; i++) { - const refType = refArgTypes[i]; - const refValue = refArgValues[i]; - let resolved = 0; - switch (refType) { - case abi_1.ABIReferenceType.account: { - const addressType = new abi_1.ABIAddressType(); - const address = addressType.decode(addressType.encode(refValue)); - resolved = populateForeignArray(address, foreignAccounts, sender); - break; - } - case abi_1.ABIReferenceType.application: { - const uint64Type = new abi_1.ABIUintType(64); - const refAppID = uint64Type.decode(uint64Type.encode(refValue)); - if (refAppID > Number.MAX_SAFE_INTEGER) { - throw new Error(`Expected safe integer for application value, got ${refAppID}`); - } - resolved = populateForeignArray(Number(refAppID), foreignApps, appID); - break; - } - case abi_1.ABIReferenceType.asset: { - const uint64Type = new abi_1.ABIUintType(64); - const refAssetID = uint64Type.decode(uint64Type.encode(refValue)); - if (refAssetID > Number.MAX_SAFE_INTEGER) { - throw new Error(`Expected safe integer for asset value, got ${refAssetID}`); - } - resolved = populateForeignArray(Number(refAssetID), foreignAssets); - break; - } - default: - throw new Error(`Unknown reference type: ${refType}`); - } - resolvedRefIndexes.push(resolved); - } - for (let i = 0; i < resolvedRefIndexes.length; i++) { - const basicArgIndex = refArgIndexToBasicArgIndex.get(i); - basicArgValues[basicArgIndex] = resolvedRefIndexes[i]; - } - if (basicArgTypes.length > MAX_APP_ARGS - 1) { - const lastArgTupleTypes = basicArgTypes.slice(MAX_APP_ARGS - 2); - const lastArgTupleValues = basicArgValues.slice(MAX_APP_ARGS - 2); - basicArgTypes = basicArgTypes.slice(0, MAX_APP_ARGS - 2); - basicArgValues = basicArgValues.slice(0, MAX_APP_ARGS - 2); - basicArgTypes.push(new abi_1.ABITupleType(lastArgTupleTypes)); - basicArgValues.push(lastArgTupleValues); - } - const appArgsEncoded = [method.getSelector()]; - for (let i = 0; i < basicArgTypes.length; i++) { - appArgsEncoded.push(basicArgTypes[i].encode(basicArgValues[i])); - } - const appCall = { - txn: (0, makeTxn_1.makeApplicationCallTxnFromObject)({ - sender, - appIndex: appID, - appArgs: appArgsEncoded, - accounts: foreignAccounts, - foreignApps, - foreignAssets, - boxes: boxReferences, - onComplete: onComplete == null ? base_1.OnApplicationComplete.NoOpOC : onComplete, - approvalProgram, - clearProgram, - numGlobalInts, - numGlobalByteSlices, - numLocalInts, - numLocalByteSlices, - extraPages, - lease, - note, - rekeyTo, - suggestedParams, - }), - signer, - }; - this.transactions.push(...txnArgs, appCall); - this.methodCalls.set(this.transactions.length - 1, method); - } - /** - * Finalize the transaction group and returned the finalized transactions. - * - * The composer's status will be at least BUILT after executing this method. - */ - buildGroup() { - if (this.status === AtomicTransactionComposerStatus.BUILDING) { - if (this.transactions.length === 0) { - throw new Error('Cannot build a group with 0 transactions'); - } - if (this.transactions.length > 1) { - (0, group_1.assignGroupID)(this.transactions.map((txnWithSigner) => txnWithSigner.txn)); - } - this.status = AtomicTransactionComposerStatus.BUILT; - } - return this.transactions; - } - /** - * Obtain signatures for each transaction in this group. If signatures have already been obtained, - * this method will return cached versions of the signatures. - * - * The composer's status will be at least SIGNED after executing this method. - * - * An error will be thrown if signing any of the transactions fails. - * - * @returns A promise that resolves to an array of signed transactions. - */ - async gatherSignatures() { - if (this.status >= AtomicTransactionComposerStatus.SIGNED) { - return this.signedTxns; - } - // retrieve built transactions and verify status is BUILT - const txnsWithSigners = this.buildGroup(); - const txnGroup = txnsWithSigners.map((txnWithSigner) => txnWithSigner.txn); - const indexesPerSigner = new Map(); - for (let i = 0; i < txnsWithSigners.length; i++) { - const { signer } = txnsWithSigners[i]; - if (!indexesPerSigner.has(signer)) { - indexesPerSigner.set(signer, []); - } - indexesPerSigner.get(signer).push(i); - } - const orderedSigners = Array.from(indexesPerSigner); - const batchedSigs = await Promise.all(orderedSigners.map(([signer, indexes]) => signer(txnGroup, indexes))); - const signedTxns = txnsWithSigners.map(() => null); - for (let signerIndex = 0; signerIndex < orderedSigners.length; signerIndex++) { - const indexes = orderedSigners[signerIndex][1]; - const sigs = batchedSigs[signerIndex]; - for (let i = 0; i < indexes.length; i++) { - signedTxns[indexes[i]] = sigs[i]; - } - } - if (!signedTxns.every((sig) => sig != null)) { - throw new Error(`Missing signatures. Got ${signedTxns}`); - } - const txIDs = signedTxns.map((stxn, index) => { - try { - return (0, transaction_1.decodeSignedTransaction)(stxn).txn.txID(); - } - catch (err) { - throw new Error(`Cannot decode signed transaction at index ${index}. ${err}`); - } - }); - this.signedTxns = signedTxns; - this.txIDs = txIDs; - this.status = AtomicTransactionComposerStatus.SIGNED; - return signedTxns; - } - /** - * Send the transaction group to the network, but don't wait for it to be committed to a block. An - * error will be thrown if submission fails. - * - * The composer's status must be SUBMITTED or lower before calling this method. If submission is - * successful, this composer's status will update to SUBMITTED. - * - * Note: a group can only be submitted again if it fails. - * - * @param client - An Algodv2 client - * - * @returns A promise that, upon success, resolves to a list of TxIDs of the submitted transactions. - */ - async submit(client) { - if (this.status > AtomicTransactionComposerStatus.SUBMITTED) { - throw new Error('Transaction group cannot be resubmitted'); - } - const stxns = await this.gatherSignatures(); - await client.sendRawTransaction(stxns).do(); - this.status = AtomicTransactionComposerStatus.SUBMITTED; - return this.txIDs; - } - /** - * Simulates the transaction group in the network. - * - * The composer will try to sign any transactions in the group, then simulate - * the results. - * Simulating the group will not change the composer's status. - * - * @param client - An Algodv2 client - * @param request - SimulateRequest with options in simulation. - * If provided, the request's transaction group will be overrwritten by the composer's group, - * only simulation related options will be used. - * - * @returns A promise that, upon success, resolves to an object containing an - * array of results containing one element for each method call transaction - * in this group (ABIResult[]) and the SimulateResponse object. - */ - async simulate(client, request) { - if (this.status > AtomicTransactionComposerStatus.SUBMITTED) { - throw new Error('Simulated Transaction group has already been submitted to the network'); - } - const stxns = await this.gatherSignatures(); - const txnObjects = stxns.map((stxn) => encoding.decode(stxn)); - const currentRequest = request == null ? new types_1.SimulateRequest({ txnGroups: [] }) : request; - currentRequest.txnGroups = [ - new types_1.SimulateRequestTransactionGroup({ - txns: txnObjects, - }), - ]; - const simulateResponse = await client - .simulateTransactions(currentRequest) - .do(); - // Parse method response - const methodResults = []; - for (const [txnIndex, method] of this.methodCalls) { - const txID = this.txIDs[txnIndex]; - const pendingInfo = simulateResponse.txnGroups[0].txnResults[txnIndex].txnResult; - const methodResult = { - txID, - rawReturnValue: new Uint8Array(), - method, - }; - methodResults.push(AtomicTransactionComposer.parseMethodResponse(method, methodResult, pendingInfo)); - } - return { methodResults, simulateResponse }; - } - /** - * Send the transaction group to the network and wait until it's committed to a block. An error - * will be thrown if submission or execution fails. - * - * The composer's status must be SUBMITTED or lower before calling this method, since execution is - * only allowed once. If submission is successful, this composer's status will update to SUBMITTED. - * If the execution is also successful, this composer's status will update to COMMITTED. - * - * Note: a group can only be submitted again if it fails. - * - * @param client - An Algodv2 client - * @param waitRounds - The maximum number of rounds to wait for transaction confirmation - * - * @returns A promise that, upon success, resolves to an object containing the confirmed round for - * this transaction, the txIDs of the submitted transactions, and an array of results containing - * one element for each method call transaction in this group. - */ - async execute(client, waitRounds) { - if (this.status === AtomicTransactionComposerStatus.COMMITTED) { - throw new Error('Transaction group has already been executed successfully'); - } - const txIDs = await this.submit(client); - this.status = AtomicTransactionComposerStatus.SUBMITTED; - const firstMethodCallIndex = this.transactions.findIndex((_, index) => this.methodCalls.has(index)); - const indexToWaitFor = firstMethodCallIndex === -1 ? 0 : firstMethodCallIndex; - const confirmedTxnInfo = await (0, wait_1.waitForConfirmation)(client, txIDs[indexToWaitFor], waitRounds); - this.status = AtomicTransactionComposerStatus.COMMITTED; - const confirmedRound = Number(confirmedTxnInfo.confirmedRound); - const methodResults = []; - for (const [txnIndex, method] of this.methodCalls) { - const txID = txIDs[txnIndex]; - let methodResult = { - txID, - rawReturnValue: new Uint8Array(), - method, - }; - try { - const pendingInfo = txnIndex === firstMethodCallIndex - ? confirmedTxnInfo - : // eslint-disable-next-line no-await-in-loop - await client.pendingTransactionInformation(txID).do(); - methodResult = AtomicTransactionComposer.parseMethodResponse(method, methodResult, pendingInfo); - } - catch (err) { - methodResult.decodeError = err; - } - methodResults.push(methodResult); - } - return { - confirmedRound, - txIDs, - methodResults, - }; - } - /** - * Parses a single ABI Method transaction log into a ABI result object. - * - * @param method - * @param methodResult - * @param pendingInfo - * @returns An ABIResult object - */ - static parseMethodResponse(method, methodResult, pendingInfo) { - const returnedResult = methodResult; - try { - returnedResult.txInfo = pendingInfo; - if (method.returns.type !== 'void') { - const logs = pendingInfo.logs || []; - if (logs.length === 0) { - throw new Error(`App call transaction did not log a return value ${JSON.stringify(pendingInfo)}`); - } - const lastLog = logs[logs.length - 1]; - if (lastLog.byteLength < 4 || - !(0, utils_1.arrayEqual)(lastLog.slice(0, 4), RETURN_PREFIX)) { - throw new Error(`App call transaction did not log a ABI return value ${JSON.stringify(pendingInfo)}`); - } - returnedResult.rawReturnValue = new Uint8Array(lastLog.slice(4)); - returnedResult.returnValue = method.returns.type.decode(methodResult.rawReturnValue); - } - } - catch (err) { - returnedResult.decodeError = err; - } - return returnedResult; - } -} -exports.AtomicTransactionComposer = AtomicTransactionComposer; -/** The maximum size of an atomic transaction group. */ -AtomicTransactionComposer.MAX_GROUP_SIZE = 16; diff --git a/algosdk/convert.d.ts b/algosdk/convert.d.ts deleted file mode 100644 index 4398714..0000000 --- a/algosdk/convert.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -export declare const INVALID_MICROALGOS_ERROR_MSG = "Microalgos should be positive and less than 2^53 - 1."; -/** - * microalgosToAlgos converts microalgos to algos - * @param microalgos - number - * @returns number - */ -export declare function microalgosToAlgos(microalgos: number): number; -/** - * algosToMicroalgos converts algos to microalgos - * @param algos - number - * @returns number - */ -export declare function algosToMicroalgos(algos: number): number; diff --git a/algosdk/convert.js b/algosdk/convert.js deleted file mode 100644 index eabbec5..0000000 --- a/algosdk/convert.js +++ /dev/null @@ -1,27 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.algosToMicroalgos = exports.microalgosToAlgos = exports.INVALID_MICROALGOS_ERROR_MSG = void 0; -const MICROALGOS_TO_ALGOS_RATIO = 1e6; -exports.INVALID_MICROALGOS_ERROR_MSG = 'Microalgos should be positive and less than 2^53 - 1.'; -/** - * microalgosToAlgos converts microalgos to algos - * @param microalgos - number - * @returns number - */ -function microalgosToAlgos(microalgos) { - if (microalgos < 0 || !Number.isSafeInteger(microalgos)) { - throw new Error(exports.INVALID_MICROALGOS_ERROR_MSG); - } - return microalgos / MICROALGOS_TO_ALGOS_RATIO; -} -exports.microalgosToAlgos = microalgosToAlgos; -/** - * algosToMicroalgos converts algos to microalgos - * @param algos - number - * @returns number - */ -function algosToMicroalgos(algos) { - const microalgos = algos * MICROALGOS_TO_ALGOS_RATIO; - return Math.round(microalgos); -} -exports.algosToMicroalgos = algosToMicroalgos; diff --git a/algosdk/dryrun.d.ts b/algosdk/dryrun.d.ts deleted file mode 100644 index 6bd4a46..0000000 --- a/algosdk/dryrun.d.ts +++ /dev/null @@ -1,102 +0,0 @@ -import AlgodClient from './client/v2/algod/algod'; -import { AccountStateDelta, DryrunRequest, DryrunSource, EvalDeltaKeyValue, TealValue } from './client/v2/algod/models/types'; -import { SignedTransaction } from './transaction'; -/** - * createDryrun takes an Algod Client (from algod.AlgodV2Client) and an array of Signed Transactions - * from (transaction.SignedTransaction) and creates a DryrunRequest object with relevant balances - * @param client - the AlgodClient to make requests against - * @param txns - the array of SignedTransaction to use for generating the DryrunRequest object - * @param protocolVersion - the string representing the protocol version to use - * @param latestTimestamp - the timestamp - * @param round - the round available to some TEAL scripts. Defaults to the current round on the network. - * @param sources - TEAL source text that gets uploaded, compiled, and inserted into transactions or application state. - * @returns the DryrunRequest object constructed from the SignedTransactions passed - */ -export declare function createDryrun({ client, txns, protocolVersion, latestTimestamp, round, sources, }: { - client: AlgodClient; - txns: SignedTransaction[]; - protocolVersion?: string; - latestTimestamp?: number | bigint; - round?: number | bigint; - sources?: DryrunSource[]; -}): Promise; -interface StackValueResponse { - type: number; - bytes: string; - uint: number; -} -declare class DryrunStackValue { - type: number; - bytes: string; - uint: number; - constructor(sv: StackValueResponse); - toString(): string; -} -interface DryrunTraceLineResponse { - error: string; - line: number; - pc: number; - scratch: TealValue[]; - stack: StackValueResponse[]; -} -declare class DryrunTraceLine { - error: string; - line: number; - pc: number; - scratch: TealValue[]; - stack: DryrunStackValue[]; - constructor(line: DryrunTraceLineResponse); -} -declare class DryrunTrace { - trace: DryrunTraceLine[]; - constructor(t: DryrunTraceLineResponse[]); -} -interface DryrunTransactionResultResponse { - disassembly: string[]; - appCallMessages: string[] | undefined; - localDeltas: AccountStateDelta[] | undefined; - globalDelta: EvalDeltaKeyValue[] | undefined; - cost: number | undefined; - logicSigMessages: string[] | undefined; - logicSigDisassembly: string[] | undefined; - logs: string[] | undefined; - appCallTrace: DryrunTrace | undefined; - logicSigTrace: DryrunTrace | undefined; -} -interface StackPrinterConfig { - maxValueWidth: number | undefined; - topOfStackFirst: boolean | undefined; -} -declare class DryrunTransactionResult { - disassembly: string[]; - appCallMessages: string[] | undefined; - localDeltas: AccountStateDelta[] | undefined; - globalDelta: EvalDeltaKeyValue[] | undefined; - cost: number | undefined; - logicSigMessages: string[] | undefined; - logicSigDisassembly: string[] | undefined; - logs: string[] | undefined; - appCallTrace: DryrunTrace | undefined; - logicSigTrace: DryrunTrace | undefined; - required: string[]; - optionals: string[]; - traces: string[]; - constructor(dtr: DryrunTransactionResultResponse); - appCallRejected(): boolean; - logicSigRejected(): boolean; - static trace(drt: DryrunTrace, disassembly: string[], spc: StackPrinterConfig): string; - appTrace(spc?: StackPrinterConfig): string; - lsigTrace(spc?: StackPrinterConfig): string; -} -interface DryrunResultResponse { - ['error']: string; - ['protocol-version']: string; - ['txns']: DryrunTransactionResultResponse[]; -} -export declare class DryrunResult { - error: string; - protocolVersion: string; - txns: DryrunTransactionResult[]; - constructor(drrResp: DryrunResultResponse); -} -export {}; diff --git a/algosdk/dryrun.js b/algosdk/dryrun.js deleted file mode 100644 index 29304fc..0000000 --- a/algosdk/dryrun.js +++ /dev/null @@ -1,299 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.DryrunResult = exports.createDryrun = void 0; -const types_1 = require("./client/v2/algod/models/types"); -const address_1 = require("./encoding/address"); -const binarydata_1 = require("./encoding/binarydata"); -const transactions_1 = require("./types/transactions"); -const defaultAppId = 1380011588; -const defaultMaxWidth = 30; -/** - * createDryrun takes an Algod Client (from algod.AlgodV2Client) and an array of Signed Transactions - * from (transaction.SignedTransaction) and creates a DryrunRequest object with relevant balances - * @param client - the AlgodClient to make requests against - * @param txns - the array of SignedTransaction to use for generating the DryrunRequest object - * @param protocolVersion - the string representing the protocol version to use - * @param latestTimestamp - the timestamp - * @param round - the round available to some TEAL scripts. Defaults to the current round on the network. - * @param sources - TEAL source text that gets uploaded, compiled, and inserted into transactions or application state. - * @returns the DryrunRequest object constructed from the SignedTransactions passed - */ -async function createDryrun({ client, txns, protocolVersion, latestTimestamp, round, sources, }) { - const appInfos = []; - const acctInfos = []; - const apps = []; - const assets = []; - const accts = []; - for (const t of txns) { - if (t.txn.type === transactions_1.TransactionType.appl) { - accts.push((0, address_1.encodeAddress)(t.txn.sender.publicKey)); - if (t.txn.appAccounts) - accts.push(...t.txn.appAccounts.map((a) => (0, address_1.encodeAddress)(a.publicKey))); - if (t.txn.appForeignApps) { - apps.push(...t.txn.appForeignApps); - accts.push(...t.txn.appForeignApps.map((aidx) => (0, address_1.getApplicationAddress)(aidx))); - } - if (t.txn.appForeignAssets) - assets.push(...t.txn.appForeignAssets); - // Create application, - if (t.txn.appIndex === undefined || t.txn.appIndex === 0) { - appInfos.push(new types_1.Application({ - id: defaultAppId, - params: new types_1.ApplicationParams({ - creator: (0, address_1.encodeAddress)(t.txn.sender.publicKey), - approvalProgram: t.txn.appApprovalProgram, - clearStateProgram: t.txn.appClearProgram, - localStateSchema: new types_1.ApplicationStateSchema({ - numUint: t.txn.appLocalInts, - numByteSlice: t.txn.appLocalByteSlices, - }), - globalStateSchema: new types_1.ApplicationStateSchema({ - numUint: t.txn.appGlobalInts, - numByteSlice: t.txn.appGlobalByteSlices, - }), - }), - })); - } - else { - apps.push(t.txn.appIndex); - accts.push((0, address_1.getApplicationAddress)(t.txn.appIndex)); - } - } - } - // Dedupe and add creator to accts array - const assetPromises = []; - for (const assetId of [...new Set(assets)]) { - assetPromises.push(client - .getAssetByID(assetId) - .do() - .then((assetInfo) => { - accts.push(assetInfo.params.creator); - })); - } - // Wait for assets to finish since we append to accts array - await Promise.all(assetPromises); - // Dedupe and get app info for all apps - const appPromises = []; - for (const appId of [...new Set(apps)]) { - appPromises.push(client - .getApplicationByID(appId) - .do() - .then((appInfo) => { - appInfos.push(appInfo); - accts.push(appInfo.params.creator); - })); - } - await Promise.all(appPromises); - const acctPromises = []; - for (const acct of [...new Set(accts)]) { - acctPromises.push(client - .accountInformation(acct) - .do() - .then((acctInfo) => { - acctInfos.push(acctInfo); - })); - } - await Promise.all(acctPromises); - return new types_1.DryrunRequest({ - txns: txns.map((st) => ({ ...st, txn: st.txn.get_obj_for_encoding() })), - accounts: acctInfos, - apps: appInfos, - latestTimestamp, - round, - protocolVersion, - sources, - }); -} -exports.createDryrun = createDryrun; -class DryrunStackValue { - constructor(sv) { - this.type = 0; - this.bytes = ''; - this.uint = 0; - this.type = sv.type; - this.bytes = sv.bytes; - this.uint = sv.uint; - } - toString() { - if (this.type === 1) { - return `0x${(0, binarydata_1.bytesToHex)((0, binarydata_1.base64ToBytes)(this.bytes))}`; - } - return this.uint.toString(); - } -} -class DryrunTraceLine { - constructor(line) { - this.error = ''; - this.line = 0; - this.pc = 0; - this.scratch = []; - this.stack = []; - this.error = line.error === undefined ? '' : line.error; - this.line = line.line; - this.pc = line.pc; - this.scratch = line.scratch; - this.stack = line.stack.map((sv) => new DryrunStackValue(sv)); - } -} -class DryrunTrace { - constructor(t) { - this.trace = []; - if (t == null) - return; - this.trace = t.map((line) => new DryrunTraceLine(line)); - } -} -function truncate(str, maxValueWidth) { - if (str.length > maxValueWidth && maxValueWidth > 0) { - return `${str.slice(0, maxValueWidth)}...`; - } - return str; -} -function scratchToString(prevScratch, currScratch) { - if (currScratch.length === 0) - return ''; - let newScratchIdx = null; - for (let idx = 0; idx < currScratch.length; idx++) { - if (idx > prevScratch.length) { - newScratchIdx = idx; - continue; - } - if (JSON.stringify(prevScratch[idx]) !== JSON.stringify(currScratch[idx])) { - newScratchIdx = idx; - } - } - if (newScratchIdx == null) - return ''; - const newScratch = currScratch[newScratchIdx]; - if (newScratch.bytes.length > 0) { - return `${newScratchIdx} = 0x${(0, binarydata_1.bytesToHex)((0, binarydata_1.base64ToBytes)(newScratch.bytes))}`; - } - return `${newScratchIdx} = ${newScratch.uint.toString()}`; -} -function stackToString(stack, reverse) { - const svs = reverse ? stack.reverse() : stack; - return `[${svs - .map((sv) => { - switch (sv.type) { - case 1: - return `0x${(0, binarydata_1.bytesToHex)((0, binarydata_1.base64ToBytes)(sv.bytes))}`; - case 2: - return `${sv.uint.toString()}`; - default: - return ''; - } - }) - .join(', ')}]`; -} -class DryrunTransactionResult { - constructor(dtr) { - this.disassembly = []; - this.appCallMessages = []; - this.localDeltas = []; - this.globalDelta = []; - this.cost = 0; - this.logicSigMessages = []; - this.logicSigDisassembly = []; - this.logs = []; - this.appCallTrace = undefined; - this.logicSigTrace = undefined; - this.required = ['disassembly']; - this.optionals = [ - 'app-call-messages', - 'local-deltas', - 'global-delta', - 'cost', - 'logic-sig-messages', - 'logic-sig-disassembly', - 'logs', - ]; - this.traces = ['app-call-trace', 'logic-sig-trace']; - this.disassembly = dtr.disassembly; - this.appCallMessages = dtr['app-call-messages']; - this.localDeltas = dtr['local-deltas']; - this.globalDelta = dtr['global-delta']; - this.cost = dtr.cost; - this.logicSigMessages = dtr['logic-sig-messages']; - this.logicSigDisassembly = dtr['logic-sig-disassembly']; - this.logs = dtr.logs; - this.appCallTrace = new DryrunTrace(dtr['app-call-trace']); - this.logicSigTrace = new DryrunTrace(dtr['logic-sig-trace']); - } - appCallRejected() { - return (this.appCallMessages !== undefined && - this.appCallMessages.includes('REJECT')); - } - logicSigRejected() { - return (this.logicSigMessages !== undefined && - this.logicSigMessages.includes('REJECT')); - } - static trace(drt, disassembly, spc) { - const maxWidth = spc.maxValueWidth || defaultMaxWidth; - // Create the array of arrays, each sub array contains N columns - const lines = [['pc#', 'ln#', 'source', 'scratch', 'stack']]; - for (let idx = 0; idx < drt.trace.length; idx++) { - const { line, error, pc, scratch, stack } = drt.trace[idx]; - const currScratch = scratch !== undefined ? scratch : []; - const prevScratch = idx > 0 && drt.trace[idx - 1].scratch !== undefined - ? drt.trace[idx - 1].scratch - : []; - const src = error === '' ? disassembly[line] : `!! ${error} !!`; - lines.push([ - pc.toString().padEnd(3, ' '), - line.toString().padEnd(3, ' '), - truncate(src, maxWidth), - truncate(scratchToString(prevScratch, currScratch), maxWidth), - truncate(stackToString(stack, spc.topOfStackFirst), maxWidth), - ]); - } - // Get the max length for each column - const maxLengths = lines.reduce((prev, curr) => { - const newVal = new Array(lines[0].length).fill(0); - for (let idx = 0; idx < prev.length; idx++) { - newVal[idx] = - curr[idx].length > prev[idx] ? curr[idx].length : prev[idx]; - } - return newVal; - }, new Array(lines[0].length).fill(0)); - return `${lines - .map((line) => line - .map((v, idx) => v.padEnd(maxLengths[idx] + 1, ' ')) - .join('|') - .trim()) - .join('\n')}\n`; - } - appTrace(spc) { - if (this.appCallTrace === undefined || !this.disassembly) - return ''; - let conf = spc; - if (spc === undefined) - conf = { - maxValueWidth: defaultMaxWidth, - topOfStackFirst: false, - }; - return DryrunTransactionResult.trace(this.appCallTrace, this.disassembly, conf); - } - lsigTrace(spc) { - if (this.logicSigTrace === undefined || - this.logicSigDisassembly === undefined) - return ''; - let conf = spc; - if (spc === undefined) - conf = { - maxValueWidth: defaultMaxWidth, - topOfStackFirst: true, - }; - return DryrunTransactionResult.trace(this.logicSigTrace, this.logicSigDisassembly, conf); - } -} -class DryrunResult { - constructor(drrResp) { - this.error = ''; - this.protocolVersion = ''; - this.txns = []; - this.error = drrResp.error; - this.protocolVersion = drrResp['protocol-version']; - this.txns = drrResp.txns.map((txn) => new DryrunTransactionResult(txn)); - } -} -exports.DryrunResult = DryrunResult; diff --git a/algosdk/encoding/address.d.ts b/algosdk/encoding/address.d.ts deleted file mode 100644 index 89a295e..0000000 --- a/algosdk/encoding/address.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { Address } from '../types/address'; -import { MultisigMetadata } from '../types/multisig'; -export declare const ALGORAND_ZERO_ADDRESS_STRING = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY5HFKQ"; -export declare const MALFORMED_ADDRESS_ERROR_MSG = "address seems to be malformed"; -export declare const CHECKSUM_ADDRESS_ERROR_MSG = "wrong checksum for address"; -export declare const INVALID_MSIG_VERSION_ERROR_MSG = "invalid multisig version"; -export declare const INVALID_MSIG_THRESHOLD_ERROR_MSG = "bad multisig threshold"; -export declare const INVALID_MSIG_PK_ERROR_MSG = "bad multisig public key - wrong length"; -export declare const UNEXPECTED_PK_LEN_ERROR_MSG = "nacl public key length is not 32 bytes"; -/** - * decodeAddress takes an Algorand address in string form and decodes it into a Uint8Array. - * @param address - an Algorand address with checksum. - * @returns the decoded form of the address's public key and checksum - */ -export declare function decodeAddress(address: string): Address; -/** - * isValidAddress checks if a string is a valid Algorand address. - * @param address - an Algorand address with checksum. - * @returns true if valid, false otherwise - */ -export declare function isValidAddress(address: string): boolean; -/** - * encodeAddress takes an Algorand address as a Uint8Array and encodes it into a string with checksum. - * @param address - a raw Algorand address - * @returns the address and checksum encoded as a string. - */ -export declare function encodeAddress(address: Uint8Array): string; -/** - * fromMultisigPreImg takes multisig parameters and returns a 32 byte typed array public key, - * representing an address that identifies the "exact group, version, and public keys" that are required for signing. - * Hash("MultisigAddr" || version uint8 || threshold uint8 || PK1 || PK2 || ...) - * Encoding this output yields a human readable address. - * @param version - multisig version - * @param threshold - multisig threshold - * @param pks - array of typed array public keys - */ -export declare function fromMultisigPreImg({ version, threshold, pks, }: Omit & { - pks: Uint8Array[]; -}): Uint8Array; -/** - * fromMultisigPreImgAddrs takes multisig parameters and returns a human readable Algorand address. - * This is equivalent to fromMultisigPreImg, but interfaces with encoded addresses. - * @param version - multisig version - * @param threshold - multisig threshold - * @param addrs - array of encoded addresses - */ -export declare function fromMultisigPreImgAddrs({ version, threshold, addrs, }: { - version: number; - threshold: number; - addrs: string[]; -}): string; -/** - * Get the escrow address of an application. - * @param appID - The ID of the application. - * @returns The address corresponding to that application's escrow account. - */ -export declare function getApplicationAddress(appID: number | bigint): string; diff --git a/algosdk/encoding/address.js b/algosdk/encoding/address.js deleted file mode 100644 index 639c4d4..0000000 --- a/algosdk/encoding/address.js +++ /dev/null @@ -1,179 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.getApplicationAddress = exports.fromMultisigPreImgAddrs = exports.fromMultisigPreImg = exports.encodeAddress = exports.isValidAddress = exports.decodeAddress = exports.UNEXPECTED_PK_LEN_ERROR_MSG = exports.INVALID_MSIG_PK_ERROR_MSG = exports.INVALID_MSIG_THRESHOLD_ERROR_MSG = exports.INVALID_MSIG_VERSION_ERROR_MSG = exports.CHECKSUM_ADDRESS_ERROR_MSG = exports.MALFORMED_ADDRESS_ERROR_MSG = exports.ALGORAND_ZERO_ADDRESS_STRING = void 0; -const hi_base32_1 = __importDefault(require("hi-base32")); -const nacl = __importStar(require("../nacl/naclWrappers")); -const utils = __importStar(require("../utils/utils")); -const uint64_1 = require("./uint64"); -const ALGORAND_ADDRESS_BYTE_LENGTH = 36; -const ALGORAND_CHECKSUM_BYTE_LENGTH = 4; -const ALGORAND_ADDRESS_LENGTH = 58; -exports.ALGORAND_ZERO_ADDRESS_STRING = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY5HFKQ'; -// Convert "MultisigAddr" UTF-8 to byte array -const MULTISIG_PREIMG2ADDR_PREFIX = new Uint8Array([ - 77, - 117, - 108, - 116, - 105, - 115, - 105, - 103, - 65, - 100, - 100, - 114, -]); -const APP_ID_PREFIX = new TextEncoder().encode('appID'); -exports.MALFORMED_ADDRESS_ERROR_MSG = 'address seems to be malformed'; -exports.CHECKSUM_ADDRESS_ERROR_MSG = 'wrong checksum for address'; -exports.INVALID_MSIG_VERSION_ERROR_MSG = 'invalid multisig version'; -exports.INVALID_MSIG_THRESHOLD_ERROR_MSG = 'bad multisig threshold'; -exports.INVALID_MSIG_PK_ERROR_MSG = 'bad multisig public key - wrong length'; -exports.UNEXPECTED_PK_LEN_ERROR_MSG = 'nacl public key length is not 32 bytes'; -/** - * decodeAddress takes an Algorand address in string form and decodes it into a Uint8Array. - * @param address - an Algorand address with checksum. - * @returns the decoded form of the address's public key and checksum - */ -function decodeAddress(address) { - if (typeof address !== 'string' || address.length !== ALGORAND_ADDRESS_LENGTH) - throw new Error(exports.MALFORMED_ADDRESS_ERROR_MSG); - // try to decode - const decoded = hi_base32_1.default.decode.asBytes(address.toString()); - // Sanity check - if (decoded.length !== ALGORAND_ADDRESS_BYTE_LENGTH) - throw new Error(exports.MALFORMED_ADDRESS_ERROR_MSG); - // Find publickey and checksum - const pk = new Uint8Array(decoded.slice(0, ALGORAND_ADDRESS_BYTE_LENGTH - ALGORAND_CHECKSUM_BYTE_LENGTH)); - const cs = new Uint8Array(decoded.slice(nacl.PUBLIC_KEY_LENGTH, ALGORAND_ADDRESS_BYTE_LENGTH)); - // Compute checksum - const checksum = nacl - .genericHash(pk) - .slice(nacl.HASH_BYTES_LENGTH - ALGORAND_CHECKSUM_BYTE_LENGTH, nacl.HASH_BYTES_LENGTH); - // Check if the checksum and the address are equal - if (!utils.arrayEqual(checksum, cs)) - throw new Error(exports.CHECKSUM_ADDRESS_ERROR_MSG); - return { publicKey: pk, checksum: cs }; -} -exports.decodeAddress = decodeAddress; -/** - * isValidAddress checks if a string is a valid Algorand address. - * @param address - an Algorand address with checksum. - * @returns true if valid, false otherwise - */ -function isValidAddress(address) { - // Try to decode - try { - decodeAddress(address); - } - catch (e) { - return false; - } - return true; -} -exports.isValidAddress = isValidAddress; -/** - * encodeAddress takes an Algorand address as a Uint8Array and encodes it into a string with checksum. - * @param address - a raw Algorand address - * @returns the address and checksum encoded as a string. - */ -function encodeAddress(address) { - // Check address length - if (address.length !== - ALGORAND_ADDRESS_BYTE_LENGTH - ALGORAND_CHECKSUM_BYTE_LENGTH) - throw new Error(`${exports.MALFORMED_ADDRESS_ERROR_MSG}: ${address}, length ${address.length}`); - // compute checksum - const checksum = nacl - .genericHash(address) - .slice(nacl.PUBLIC_KEY_LENGTH - ALGORAND_CHECKSUM_BYTE_LENGTH, nacl.PUBLIC_KEY_LENGTH); - const addr = hi_base32_1.default.encode(utils.concatArrays(address, checksum)); - return addr.toString().slice(0, ALGORAND_ADDRESS_LENGTH); // removing the extra '====' -} -exports.encodeAddress = encodeAddress; -/** - * fromMultisigPreImg takes multisig parameters and returns a 32 byte typed array public key, - * representing an address that identifies the "exact group, version, and public keys" that are required for signing. - * Hash("MultisigAddr" || version uint8 || threshold uint8 || PK1 || PK2 || ...) - * Encoding this output yields a human readable address. - * @param version - multisig version - * @param threshold - multisig threshold - * @param pks - array of typed array public keys - */ -function fromMultisigPreImg({ version, threshold, pks, }) { - if (version !== 1 || version > 255 || version < 0) { - // ^ a tad redundant, but in case in the future version != 1, still check for uint8 - throw new Error(exports.INVALID_MSIG_VERSION_ERROR_MSG); - } - if (threshold === 0 || - pks.length === 0 || - threshold > pks.length || - threshold > 255) { - throw new Error(exports.INVALID_MSIG_THRESHOLD_ERROR_MSG); - } - const pkLen = ALGORAND_ADDRESS_BYTE_LENGTH - ALGORAND_CHECKSUM_BYTE_LENGTH; - if (pkLen !== nacl.PUBLIC_KEY_LENGTH) { - throw new Error(exports.UNEXPECTED_PK_LEN_ERROR_MSG); - } - const merged = new Uint8Array(MULTISIG_PREIMG2ADDR_PREFIX.length + 2 + pkLen * pks.length); - merged.set(MULTISIG_PREIMG2ADDR_PREFIX, 0); - merged.set([version], MULTISIG_PREIMG2ADDR_PREFIX.length); - merged.set([threshold], MULTISIG_PREIMG2ADDR_PREFIX.length + 1); - for (let i = 0; i < pks.length; i++) { - if (pks[i].length !== pkLen) { - throw new Error(exports.INVALID_MSIG_PK_ERROR_MSG); - } - merged.set(pks[i], MULTISIG_PREIMG2ADDR_PREFIX.length + 2 + i * pkLen); - } - return new Uint8Array(nacl.genericHash(merged)); -} -exports.fromMultisigPreImg = fromMultisigPreImg; -/** - * fromMultisigPreImgAddrs takes multisig parameters and returns a human readable Algorand address. - * This is equivalent to fromMultisigPreImg, but interfaces with encoded addresses. - * @param version - multisig version - * @param threshold - multisig threshold - * @param addrs - array of encoded addresses - */ -function fromMultisigPreImgAddrs({ version, threshold, addrs, }) { - const pks = addrs.map((addr) => decodeAddress(addr).publicKey); - return encodeAddress(fromMultisigPreImg({ version, threshold, pks })); -} -exports.fromMultisigPreImgAddrs = fromMultisigPreImgAddrs; -/** - * Get the escrow address of an application. - * @param appID - The ID of the application. - * @returns The address corresponding to that application's escrow account. - */ -function getApplicationAddress(appID) { - const toBeSigned = utils.concatArrays(APP_ID_PREFIX, (0, uint64_1.encodeUint64)(appID)); - const hash = nacl.genericHash(toBeSigned); - return encodeAddress(new Uint8Array(hash)); -} -exports.getApplicationAddress = getApplicationAddress; diff --git a/algosdk/encoding/bigint.d.ts b/algosdk/encoding/bigint.d.ts deleted file mode 100644 index e02e439..0000000 --- a/algosdk/encoding/bigint.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * bigIntToBytes converts a BigInt to a big-endian Uint8Array for encoding. - * @param bi - The bigint to convert. - * @param size - The size of the resulting byte array. - * @returns A byte array containing the big-endian encoding of the input bigint - */ -export declare function bigIntToBytes(bi: bigint | number, size: number): Uint8Array; -/** - * bytesToBigInt produces a bigint from a binary representation. - * - * @param bytes - The Uint8Array to convert. - * @returns The bigint that was encoded in the input data. - */ -export declare function bytesToBigInt(bytes: Uint8Array): bigint; diff --git a/algosdk/encoding/bigint.js b/algosdk/encoding/bigint.js deleted file mode 100644 index f149b87..0000000 --- a/algosdk/encoding/bigint.js +++ /dev/null @@ -1,37 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.bytesToBigInt = exports.bigIntToBytes = void 0; -/** - * bigIntToBytes converts a BigInt to a big-endian Uint8Array for encoding. - * @param bi - The bigint to convert. - * @param size - The size of the resulting byte array. - * @returns A byte array containing the big-endian encoding of the input bigint - */ -function bigIntToBytes(bi, size) { - let hex = bi.toString(16); - // Pad the hex with zeros so it matches the size in bytes - if (hex.length !== size * 2) { - hex = hex.padStart(size * 2, '0'); - } - const byteArray = new Uint8Array(hex.length / 2); - for (let i = 0, j = 0; i < hex.length / 2; i++, j += 2) { - byteArray[i] = parseInt(hex.slice(j, j + 2), 16); - } - return byteArray; -} -exports.bigIntToBytes = bigIntToBytes; -/** - * bytesToBigInt produces a bigint from a binary representation. - * - * @param bytes - The Uint8Array to convert. - * @returns The bigint that was encoded in the input data. - */ -function bytesToBigInt(bytes) { - let res = BigInt(0); - const buf = new DataView(bytes.buffer, bytes.byteOffset); - for (let i = 0; i < bytes.length; i++) { - res = BigInt(Number(buf.getUint8(i))) + res * BigInt(256); - } - return res; -} -exports.bytesToBigInt = bytesToBigInt; diff --git a/algosdk/encoding/binarydata.d.ts b/algosdk/encoding/binarydata.d.ts deleted file mode 100644 index 7c29bd0..0000000 --- a/algosdk/encoding/binarydata.d.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Convert a base64 string to a Uint8Array for Node.js and browser environments. - * @returns A Uint8Array - */ -export declare function base64ToBytes(base64String: string): Uint8Array; -/** - * Decode a base64 string for Node.js and browser environments. - * @returns A decoded string - */ -export declare function base64ToString(base64String: string): string; -/** - * Convert a Uint8Array to a base64 string for Node.js and browser environments. - * @returns A base64 string - */ -export declare function bytesToBase64(byteArray: Uint8Array): string; -/** - * Returns a Uint8Array given an input string or Uint8Array. - * @returns A base64 string - */ -export declare function coerceToBytes(input: Uint8Array | string): Uint8Array; -/** - * Convert a Uint8Array to a hex string for Node.js and browser environments. - * @returns A hex string - */ -export declare function bytesToHex(byteArray: Uint8Array): string; -/** - * Convert a hex string to Uint8Array for Node.js and browser environments. - * @returns A Uint8Array - */ -export declare function hexToBytes(hexString: string): Uint8Array; diff --git a/algosdk/encoding/binarydata.js b/algosdk/encoding/binarydata.js deleted file mode 100644 index a249a56..0000000 --- a/algosdk/encoding/binarydata.js +++ /dev/null @@ -1,85 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.hexToBytes = exports.bytesToHex = exports.coerceToBytes = exports.bytesToBase64 = exports.base64ToString = exports.base64ToBytes = void 0; -const utils_1 = require("../utils/utils"); -/** - * Convert a base64 string to a Uint8Array for Node.js and browser environments. - * @returns A Uint8Array - */ -function base64ToBytes(base64String) { - if ((0, utils_1.isNode)()) { - return new Uint8Array(Buffer.from(base64String, 'base64')); - } - /* eslint-env browser */ - const binString = atob(base64String); - return Uint8Array.from(binString, (m) => m.codePointAt(0)); -} -exports.base64ToBytes = base64ToBytes; -/** - * Decode a base64 string for Node.js and browser environments. - * @returns A decoded string - */ -function base64ToString(base64String) { - if ((0, utils_1.isNode)()) { - return Buffer.from(base64String, 'base64').toString(); - } - const binString = base64ToBytes(base64String); - return new TextDecoder().decode(binString); -} -exports.base64ToString = base64ToString; -/** - * Convert a Uint8Array to a base64 string for Node.js and browser environments. - * @returns A base64 string - */ -function bytesToBase64(byteArray) { - if ((0, utils_1.isNode)()) { - return Buffer.from(byteArray).toString('base64'); - } - /* eslint-env browser */ - const binString = Array.from(byteArray, (x) => String.fromCodePoint(x)).join(''); - return btoa(binString); -} -exports.bytesToBase64 = bytesToBase64; -/** - * Returns a Uint8Array given an input string or Uint8Array. - * @returns A base64 string - */ -function coerceToBytes(input) { - if (typeof input === 'string') { - return new TextEncoder().encode(input); - } - return input; -} -exports.coerceToBytes = coerceToBytes; -/** - * Convert a Uint8Array to a hex string for Node.js and browser environments. - * @returns A hex string - */ -function bytesToHex(byteArray) { - if ((0, utils_1.isNode)()) { - return Buffer.from(byteArray).toString('hex'); - } - return Array.from(byteArray) - .map((i) => i.toString(16).padStart(2, '0')) - .join(''); -} -exports.bytesToHex = bytesToHex; -/** - * Convert a hex string to Uint8Array for Node.js and browser environments. - * @returns A Uint8Array - */ -function hexToBytes(hexString) { - if ((0, utils_1.isNode)()) { - return Buffer.from(hexString, 'hex'); - } - let hex = hexString; - if (hexString.length % 2 !== 0) { - hex = hexString.padStart(1, '0'); - } - const byteArray = new Uint8Array(hex.length / 2); - for (let i = 0; i < hex.length / 2; i++) { - byteArray[i] = parseInt(hex.slice(2 * i, 2 * i + 2), 16); - } - return byteArray; -} -exports.hexToBytes = hexToBytes; diff --git a/algosdk/encoding/encoding.d.ts b/algosdk/encoding/encoding.d.ts deleted file mode 100644 index 662dffc..0000000 --- a/algosdk/encoding/encoding.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * This file is a wrapper of msgpack.js. - * The wrapper was written in order to ensure correct encoding of Algorand Transaction and other formats. - * In particular, it matches go-algorand blockchain client, written in go (https://www.github.com/algorand/go-algorand. - * Algorand's msgpack encoding follows to following rules - - * 1. Every integer must be encoded to the smallest type possible (0-255-\>8bit, 256-65535-\>16bit, etx) - * 2. All fields names must be sorted - * 3. All empty and 0 fields should be omitted - * 4. Every positive number must be encoded as uint - * 5. Binary blob should be used for binary data and string for strings - * */ -export declare const ERROR_CONTAINS_EMPTY_STRING = "The object contains empty or 0 values. First empty or 0 value encountered during encoding: "; -/** - * rawEncode encodes objects using msgpack, regardless of whether there are - * empty or 0 value fields. - * @param obj - a dictionary to be encoded. May or may not contain empty or 0 values. - * @returns msgpack representation of the object - */ -export declare function rawEncode(obj: Record): Uint8Array; -/** - * encode encodes objects using msgpack - * @param obj - a dictionary to be encoded. Must not contain empty or 0 values. - * @returns msgpack representation of the object - * @throws Error containing ERROR_CONTAINS_EMPTY_STRING if the object contains empty or zero values - */ -export declare function encode(obj: Record): Uint8Array; -export declare function decode(buffer: ArrayLike): unknown; diff --git a/algosdk/encoding/encoding.js b/algosdk/encoding/encoding.js deleted file mode 100644 index af5a8dd..0000000 --- a/algosdk/encoding/encoding.js +++ /dev/null @@ -1,88 +0,0 @@ -"use strict"; -/** - * This file is a wrapper of msgpack.js. - * The wrapper was written in order to ensure correct encoding of Algorand Transaction and other formats. - * In particular, it matches go-algorand blockchain client, written in go (https://www.github.com/algorand/go-algorand. - * Algorand's msgpack encoding follows to following rules - - * 1. Every integer must be encoded to the smallest type possible (0-255-\>8bit, 256-65535-\>16bit, etx) - * 2. All fields names must be sorted - * 3. All empty and 0 fields should be omitted - * 4. Every positive number must be encoded as uint - * 5. Binary blob should be used for binary data and string for strings - * */ -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.decode = exports.encode = exports.rawEncode = exports.ERROR_CONTAINS_EMPTY_STRING = void 0; -const msgpack = __importStar(require("algo-msgpack-with-bigint")); -// Errors -exports.ERROR_CONTAINS_EMPTY_STRING = 'The object contains empty or 0 values. First empty or 0 value encountered during encoding: '; -/** - * containsEmpty returns true if any of the object's values are empty, false otherwise. - * Empty arrays considered empty - * @param obj - The object to check - * @returns \{true, empty key\} if contains empty, \{false, undefined\} otherwise - */ -function containsEmpty(obj) { - for (const key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key)) { - if (!obj[key] || obj[key].length === 0) { - return { containsEmpty: true, firstEmptyKey: key }; - } - } - } - return { containsEmpty: false, firstEmptyKey: undefined }; -} -/** - * rawEncode encodes objects using msgpack, regardless of whether there are - * empty or 0 value fields. - * @param obj - a dictionary to be encoded. May or may not contain empty or 0 values. - * @returns msgpack representation of the object - */ -function rawEncode(obj) { - // enable the canonical option - const options = { sortKeys: true }; - return msgpack.encode(obj, options); -} -exports.rawEncode = rawEncode; -/** - * encode encodes objects using msgpack - * @param obj - a dictionary to be encoded. Must not contain empty or 0 values. - * @returns msgpack representation of the object - * @throws Error containing ERROR_CONTAINS_EMPTY_STRING if the object contains empty or zero values - */ -function encode(obj) { - // Check for empty values - const emptyCheck = containsEmpty(obj); - if (emptyCheck.containsEmpty) { - throw new Error(exports.ERROR_CONTAINS_EMPTY_STRING + emptyCheck.firstEmptyKey); - } - // enable the canonical option - return rawEncode(obj); -} -exports.encode = encode; -function decode(buffer) { - return msgpack.decode(buffer); -} -exports.decode = decode; diff --git a/algosdk/encoding/uint64.d.ts b/algosdk/encoding/uint64.d.ts deleted file mode 100644 index a10c16d..0000000 --- a/algosdk/encoding/uint64.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * encodeUint64 converts an integer to its binary representation. - * @param num - The number to convert. This must be an unsigned integer less than - * 2^64. - * @returns An 8-byte typed array containing the big-endian encoding of the input - * integer. - */ -export declare function encodeUint64(num: number | bigint): Uint8Array; -/** - * decodeUint64 produces an integer from a binary representation. - * @param data - An typed array containing the big-endian encoding of an unsigned integer - * less than 2^64. This array must be at most 8 bytes long. - * @param decodingMode - Configure how the integer will be - * decoded. - * - * The options are: - * * "safe": The integer will be decoded as a Number, but if it is greater than - * Number.MAX_SAFE_INTEGER an error will be thrown. - * * "mixed": The integer will be decoded as a Number if it is less than or equal to - * Number.MAX_SAFE_INTEGER, otherwise it will be decoded as a BigInt. - * * "bigint": The integer will always be decoded as a BigInt. - * - * Defaults to "safe" if not included. - * @returns The integer that was encoded in the input data. The return type will - * be determined by the parameter decodingMode. - */ -export declare function decodeUint64(data: Uint8Array, decodingMode: 'safe'): number; -export declare function decodeUint64(data: Uint8Array, decodingMode: 'mixed'): number | bigint; -export declare function decodeUint64(data: Uint8Array, decodingMode: 'bigint'): bigint; diff --git a/algosdk/encoding/uint64.js b/algosdk/encoding/uint64.js deleted file mode 100644 index fcca978..0000000 --- a/algosdk/encoding/uint64.js +++ /dev/null @@ -1,53 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.decodeUint64 = exports.encodeUint64 = void 0; -const utils_1 = require("../utils/utils"); -// NOTE: at the moment we specifically do not use Buffer.writeBigUInt64BE and -// Buffer.readBigUInt64BE. This is because projects using webpack v4 -// automatically include an old version of the npm `buffer` package (v4.9.2 at -// the time of writing), and this old version does not have these methods. -/** - * encodeUint64 converts an integer to its binary representation. - * @param num - The number to convert. This must be an unsigned integer less than - * 2^64. - * @returns An 8-byte typed array containing the big-endian encoding of the input - * integer. - */ -function encodeUint64(num) { - const isInteger = typeof num === 'bigint' || Number.isInteger(num); - if (!isInteger || num < 0 || num > BigInt('0xffffffffffffffff')) { - throw new Error('Input is not a 64-bit unsigned integer'); - } - const encoding = new Uint8Array(8); - const view = new DataView(encoding.buffer); - view.setBigUint64(0, BigInt(num)); - return encoding; -} -exports.encodeUint64 = encodeUint64; -function decodeUint64(data, decodingMode = 'safe') { - if (decodingMode !== 'safe' && - decodingMode !== 'mixed' && - decodingMode !== 'bigint') { - throw new Error(`Unknown decodingMode option: ${decodingMode}`); - } - if (data.byteLength === 0 || data.byteLength > 8) { - throw new Error(`Data has unacceptable length. Expected length is between 1 and 8, got ${data.byteLength}`); - } - // insert 0s at the beginning if data is smaller than 8 bytes - const padding = new Uint8Array(8 - data.byteLength); - const encoding = (0, utils_1.concatArrays)(padding, data); - const view = new DataView(encoding.buffer); - const num = view.getBigUint64(0); - const isBig = num > BigInt(Number.MAX_SAFE_INTEGER); - if (decodingMode === 'safe') { - if (isBig) { - throw new Error(`Integer exceeds maximum safe integer: ${num.toString()}. Try decoding with "mixed" or "safe" decodingMode.`); - } - return Number(num); - } - if (decodingMode === 'mixed' && !isBig) { - return Number(num); - } - return num; -} -exports.decodeUint64 = decodeUint64; diff --git a/algosdk/group.d.ts b/algosdk/group.d.ts deleted file mode 100644 index 4881a01..0000000 --- a/algosdk/group.d.ts +++ /dev/null @@ -1,30 +0,0 @@ -import * as txnBuilder from './transaction'; -interface EncodedTxGroup { - txlist: Uint8Array[]; -} -/** - * Aux class for group id calculation of a group of transactions - */ -export declare class TxGroup { - name: string; - tag: Uint8Array; - txGroupHashes: Uint8Array[]; - constructor(hashes: Uint8Array[]); - get_obj_for_encoding(): EncodedTxGroup; - static from_obj_for_encoding(txgroupForEnc: EncodedTxGroup): any; - toByte(): Uint8Array; -} -/** - * computeGroupID returns group ID for a group of transactions - * @param txns - array of transactions (every element is a dict or Transaction) - * @returns Uint8Array - */ -export declare function computeGroupID(txns: txnBuilder.TransactionLike[]): Uint8Array; -/** - * assignGroupID assigns group id to a given list of unsigned transactions - * @param txns - array of transactions (every element is a dict or Transaction) - * @param sender - optional sender address specifying which transaction return - * @returns possible list of matching transactions - */ -export declare function assignGroupID(txns: txnBuilder.TransactionLike[], sender?: string): txnBuilder.Transaction[]; -export default TxGroup; diff --git a/algosdk/group.js b/algosdk/group.js deleted file mode 100644 index 16e8475..0000000 --- a/algosdk/group.js +++ /dev/null @@ -1,106 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.assignGroupID = exports.computeGroupID = exports.TxGroup = void 0; -const txnBuilder = __importStar(require("./transaction")); -const nacl = __importStar(require("./nacl/naclWrappers")); -const encoding = __importStar(require("./encoding/encoding")); -const address = __importStar(require("./encoding/address")); -const utils = __importStar(require("./utils/utils")); -const ALGORAND_MAX_TX_GROUP_SIZE = 16; -/** - * Aux class for group id calculation of a group of transactions - */ -class TxGroup { - constructor(hashes) { - this.name = 'Transaction group'; - this.tag = new TextEncoder().encode('TG'); - if (hashes.length > ALGORAND_MAX_TX_GROUP_SIZE) { - const errorMsg = `${hashes.length.toString()} transactions grouped together but max group size is ${ALGORAND_MAX_TX_GROUP_SIZE.toString()}`; - throw Error(errorMsg); - } - this.txGroupHashes = hashes; - } - // eslint-disable-next-line camelcase - get_obj_for_encoding() { - const txgroup = { - txlist: this.txGroupHashes, - }; - return txgroup; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(txgroupForEnc) { - const txn = Object.create(this.prototype); - txn.name = 'Transaction group'; - txn.tag = new TextEncoder().encode('TG'); - txn.txGroupHashes = []; - for (const hash of txgroupForEnc.txlist) { - txn.txGroupHashes.push(hash); - } - return txn; - } - toByte() { - return encoding.encode(this.get_obj_for_encoding()); - } -} -exports.TxGroup = TxGroup; -/** - * computeGroupID returns group ID for a group of transactions - * @param txns - array of transactions (every element is a dict or Transaction) - * @returns Uint8Array - */ -function computeGroupID(txns) { - const hashes = []; - for (const txn of txns) { - const tx = txnBuilder.instantiateTxnIfNeeded(txn); - hashes.push(tx.rawTxID()); - } - const txgroup = new TxGroup(hashes); - const bytes = txgroup.toByte(); - const toBeHashed = utils.concatArrays(txgroup.tag, bytes); - const gid = nacl.genericHash(toBeHashed); - return Uint8Array.from(gid); -} -exports.computeGroupID = computeGroupID; -/** - * assignGroupID assigns group id to a given list of unsigned transactions - * @param txns - array of transactions (every element is a dict or Transaction) - * @param sender - optional sender address specifying which transaction return - * @returns possible list of matching transactions - */ -function assignGroupID(txns, sender) { - const gid = computeGroupID(txns); - const result = []; - for (const txn of txns) { - const tx = txnBuilder.instantiateTxnIfNeeded(txn); - if (!sender || address.encodeAddress(tx.sender.publicKey) === sender) { - tx.group = gid; - result.push(tx); - } - } - return result; -} -exports.assignGroupID = assignGroupID; -exports.default = TxGroup; diff --git a/algosdk/index.d.ts b/algosdk/index.d.ts deleted file mode 100644 index 62293a7..0000000 --- a/algosdk/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -import * as algosdk from './main'; -export * from './main'; -export default algosdk; diff --git a/algosdk/index.js b/algosdk/index.js deleted file mode 100644 index 3200e13..0000000 --- a/algosdk/index.js +++ /dev/null @@ -1,31 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const algosdk = __importStar(require("./main")); -__exportStar(require("./main"), exports); -exports.default = algosdk; diff --git a/algosdk/logic/sourcemap.d.ts b/algosdk/logic/sourcemap.d.ts deleted file mode 100644 index 7616245..0000000 --- a/algosdk/logic/sourcemap.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Represents a location in a source file. - */ -export interface SourceLocation { - line: number; - column: number; - sourceIndex: number; - nameIndex?: number; -} -/** - * Represents the location of a specific PC in a source line. - */ -export interface PcLineLocation { - pc: number; - column: number; - nameIndex?: number; -} -/** - * Contains a mapping from TEAL program PC to source file location. - */ -export declare class ProgramSourceMap { - readonly version: number; - /** - * A list of original sources used by the "mappings" entry. - */ - readonly sources: string[]; - /** - * A list of symbol names used by the "mappings" entry. - */ - readonly names: string[]; - /** - * A string with the encoded mapping data. - */ - readonly mappings: string; - private pcToLocation; - private sourceAndLineToPc; - constructor({ version, sources, names, mappings, }: { - version: number; - sources: string[]; - names: string[]; - mappings: string; - }); - getPcs(): number[]; - getLocationForPc(pc: number): SourceLocation | undefined; - getPcsOnSourceLine(sourceIndex: number, line: number): PcLineLocation[]; -} diff --git a/algosdk/logic/sourcemap.js b/algosdk/logic/sourcemap.js deleted file mode 100644 index 591094a..0000000 --- a/algosdk/logic/sourcemap.js +++ /dev/null @@ -1,97 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.ProgramSourceMap = void 0; -const vlq = __importStar(require("vlq")); -/** - * Contains a mapping from TEAL program PC to source file location. - */ -class ProgramSourceMap { - constructor({ version, sources, names, mappings, }) { - this.version = version; - this.sources = sources; - this.names = names; - this.mappings = mappings; - if (this.version !== 3) - throw new Error(`Only version 3 is supported, got ${this.version}`); - if (this.mappings === undefined) - throw new Error('mapping undefined, cannot build source map without `mapping`'); - const pcList = this.mappings.split(';').map(vlq.decode); - this.pcToLocation = new Map(); - this.sourceAndLineToPc = new Map(); - const lastLocation = { - line: 0, - column: 0, - sourceIndex: 0, - nameIndex: 0, - }; - for (const [pc, data] of pcList.entries()) { - if (data.length < 4) - continue; - const nameDelta = data.length > 4 ? data[4] : undefined; - const [, sourceDelta, lineDelta, columnDelta] = data; - lastLocation.sourceIndex += sourceDelta; - lastLocation.line += lineDelta; - lastLocation.column += columnDelta; - if (typeof nameDelta !== 'undefined') { - lastLocation.nameIndex += nameDelta; - } - const sourceAndLineKey = `${lastLocation.sourceIndex}:${lastLocation.line}`; - let pcsForSourceAndLine = this.sourceAndLineToPc.get(sourceAndLineKey); - if (pcsForSourceAndLine === undefined) { - pcsForSourceAndLine = []; - this.sourceAndLineToPc.set(sourceAndLineKey, pcsForSourceAndLine); - } - const pcInLine = { - pc, - column: lastLocation.column, - }; - const pcLocation = { - line: lastLocation.line, - column: lastLocation.column, - sourceIndex: lastLocation.sourceIndex, - }; - if (typeof nameDelta !== 'undefined') { - pcInLine.nameIndex = lastLocation.nameIndex; - pcLocation.nameIndex = lastLocation.nameIndex; - } - pcsForSourceAndLine.push(pcInLine); - this.pcToLocation.set(pc, pcLocation); - } - } - getPcs() { - return Array.from(this.pcToLocation.keys()); - } - getLocationForPc(pc) { - return this.pcToLocation.get(pc); - } - getPcsOnSourceLine(sourceIndex, line) { - const pcs = this.sourceAndLineToPc.get(`${sourceIndex}:${line}`); - if (pcs === undefined) - return []; - return pcs; - } -} -exports.ProgramSourceMap = ProgramSourceMap; diff --git a/algosdk/logicsig.d.ts b/algosdk/logicsig.d.ts deleted file mode 100644 index f08c3b7..0000000 --- a/algosdk/logicsig.d.ts +++ /dev/null @@ -1,190 +0,0 @@ -import * as txnBuilder from './transaction'; -import { EncodedLogicSig, EncodedLogicSigAccount, EncodedMultisig } from './types/transactions/encoded'; -import { MultisigMetadata } from './types/multisig'; -interface LogicSigStorageStructure { - logic: Uint8Array; - args: Uint8Array[]; - sig?: Uint8Array; - msig?: EncodedMultisig; -} -/** sanityCheckProgram performs heuristic program validation: - * check if passed in bytes are Algorand address or is B64 encoded, rather than Teal bytes - * - * @param program - Program bytes to check - */ -export declare function sanityCheckProgram(program: Uint8Array): void; -/** - LogicSig implementation - - LogicSig cannot sign transactions in all cases. Instead, use LogicSigAccount as a safe, general purpose signing mechanism. Since LogicSig does not track the provided signature's public key, LogicSig cannot sign transactions when delegated to a non-multisig account _and_ the sender is not the delegating account. - */ -export declare class LogicSig implements LogicSigStorageStructure { - tag: Uint8Array; - logic: Uint8Array; - args: Uint8Array[]; - sig?: Uint8Array; - msig?: EncodedMultisig; - constructor(program: Uint8Array, programArgs?: Array | null); - get_obj_for_encoding(): EncodedLogicSig; - static from_obj_for_encoding(encoded: EncodedLogicSig): LogicSig; - /** - * Performs signature verification - * @param publicKey - Verification key (derived from sender address or escrow address) - */ - verify(publicKey: Uint8Array): boolean; - /** - * Compute hash of the logic sig program (that is the same as escrow account address) as string address - * @returns String representation of the address - */ - address(): string; - /** - * Creates signature (if no msig provided) or multi signature otherwise - * @param secretKey - Secret key to sign with - * @param msig - Multisig account as \{version, threshold, addrs\} - */ - sign(secretKey: Uint8Array, msig?: MultisigMetadata): void; - /** - * Appends a signature to multi signature - * @param secretKey - Secret key to sign with - */ - appendToMultisig(secretKey: Uint8Array): void; - signProgram(secretKey: Uint8Array): Uint8Array; - singleSignMultisig(secretKey: Uint8Array, msig: EncodedMultisig): [sig: Uint8Array, index: number]; - toByte(): Uint8Array; - static fromByte(encoded: ArrayLike): LogicSig; -} -/** - * Represents an account that can sign with a LogicSig program. - */ -export declare class LogicSigAccount { - lsig: LogicSig; - sigkey?: Uint8Array; - /** - * Create a new LogicSigAccount. By default this will create an escrow - * LogicSig account. Call `sign` or `signMultisig` on the newly created - * LogicSigAccount to make it a delegated account. - * - * @param program - The compiled TEAL program which contains the logic for - * this LogicSig. - * @param args - An optional array of arguments for the program. - */ - constructor(program: Uint8Array, args?: Array | null); - get_obj_for_encoding(): EncodedLogicSigAccount; - static from_obj_for_encoding(encoded: EncodedLogicSigAccount): LogicSigAccount; - /** - * Encode this object into msgpack. - */ - toByte(): Uint8Array; - /** - * Decode a msgpack object into a LogicSigAccount. - * @param encoded - The encoded LogicSigAccount. - */ - static fromByte(encoded: ArrayLike): LogicSigAccount; - /** - * Check if this LogicSigAccount has been delegated to another account with a - * signature. - * - * Note this function only checks for the presence of a delegation signature. - * To verify the delegation signature, use `verify`. - */ - isDelegated(): boolean; - /** - * Verifies this LogicSig's program and signatures. - * @returns true if and only if the LogicSig program and signatures are valid. - */ - verify(): boolean; - /** - * Get the address of this LogicSigAccount. - * - * If the LogicSig is delegated to another account, this will return the - * address of that account. - * - * If the LogicSig is not delegated to another account, this will return an - * escrow address that is the hash of the LogicSig's program code. - */ - address(): string; - /** - * Turns this LogicSigAccount into a delegated LogicSig. This type of LogicSig - * has the authority to sign transactions on behalf of another account, called - * the delegating account. Use this function if the delegating account is a - * multisig account. - * - * @param msig - The multisig delegating account - * @param secretKey - The secret key of one of the members of the delegating - * multisig account. Use `appendToMultisig` to add additional signatures - * from other members. - */ - signMultisig(msig: MultisigMetadata, secretKey: Uint8Array): void; - /** - * Adds an additional signature from a member of the delegating multisig - * account. - * - * @param secretKey - The secret key of one of the members of the delegating - * multisig account. - */ - appendToMultisig(secretKey: Uint8Array): void; - /** - * Turns this LogicSigAccount into a delegated LogicSig. This type of LogicSig - * has the authority to sign transactions on behalf of another account, called - * the delegating account. If the delegating account is a multisig account, - * use `signMultisig` instead. - * - * @param secretKey - The secret key of the delegating account. - */ - sign(secretKey: Uint8Array): void; -} -/** - * signLogicSigTransactionObject takes a transaction and a LogicSig object and - * returns a signed transaction. - * - * @param txn - The transaction to sign. - * @param lsigObject - The LogicSig object that will sign the transaction. - * - * @returns Object containing txID and blob representing signed transaction. - */ -export declare function signLogicSigTransactionObject(txn: txnBuilder.Transaction, lsigObject: LogicSig | LogicSigAccount): { - txID: string; - blob: Uint8Array; -}; -/** - * signLogicSigTransaction takes a transaction and a LogicSig object and returns - * a signed transaction. - * - * @param txn - The transaction to sign. - * @param lsigObject - The LogicSig object that will sign the transaction. - * - * @returns Object containing txID and blob representing signed transaction. - * @throws error on failure - */ -export declare function signLogicSigTransaction(txn: txnBuilder.TransactionLike, lsigObject: LogicSig | LogicSigAccount): { - txID: string; - blob: Uint8Array; -}; -/** - * logicSigFromByte accepts encoded logic sig bytes and attempts to call logicsig.fromByte on it, - * returning the result - */ -export declare function logicSigFromByte(encoded: Uint8Array): LogicSig; -/** - * tealSign creates a signature compatible with ed25519verify opcode from program hash - * @param sk - Uint8Array with secret key - * @param data - Uint8Array with data to sign - * @param programHash - string representation of teal program hash (= contract address for LogicSigs) - */ -export declare function tealSign(sk: Uint8Array, data: Uint8Array, programHash: string): Uint8Array; -/** - * verifyTealSign verifies a signature as would the ed25519verify opcode - * @param data - Uint8Array with original signed data - * @param programHash - string representation of teal program hash (= contract address for LogicSigs) - * @param sig - uint8array with the signature to verify (produced by tealSign/tealSignFromProgram) - * @param pk - uint8array with public key to verify against - */ -export declare function verifyTealSign(data: Uint8Array, programHash: string, sig: Uint8Array, pk: Uint8Array): boolean; -/** - * tealSignFromProgram creates a signature compatible with ed25519verify opcode from raw program bytes - * @param sk - uint8array with secret key - * @param data - Uint8Array with data to sign - * @param program - Uint8Array with teal program - */ -export declare function tealSignFromProgram(sk: Uint8Array, data: Uint8Array, program: Uint8Array): Uint8Array; -export {}; diff --git a/algosdk/logicsig.js b/algosdk/logicsig.js deleted file mode 100644 index 85452db..0000000 --- a/algosdk/logicsig.js +++ /dev/null @@ -1,449 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.tealSignFromProgram = exports.verifyTealSign = exports.tealSign = exports.logicSigFromByte = exports.signLogicSigTransaction = exports.signLogicSigTransactionObject = exports.LogicSigAccount = exports.LogicSig = exports.sanityCheckProgram = void 0; -const nacl = __importStar(require("./nacl/naclWrappers")); -const address = __importStar(require("./encoding/address")); -const encoding = __importStar(require("./encoding/encoding")); -const multisig_1 = require("./multisig"); -const utils = __importStar(require("./utils/utils")); -const txnBuilder = __importStar(require("./transaction")); -const address_1 = require("./encoding/address"); -// base64regex is the regex to test for base64 strings -const base64regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/; -/** sanityCheckProgram performs heuristic program validation: - * check if passed in bytes are Algorand address or is B64 encoded, rather than Teal bytes - * - * @param program - Program bytes to check - */ -function sanityCheckProgram(program) { - if (!program || program.length === 0) - throw new Error('empty program'); - const lineBreakOrd = '\n'.charCodeAt(0); - const blankSpaceOrd = ' '.charCodeAt(0); - const tildeOrd = '~'.charCodeAt(0); - const isPrintable = (x) => blankSpaceOrd <= x && x <= tildeOrd; - const isAsciiPrintable = program.every((x) => x === lineBreakOrd || isPrintable(x)); - if (isAsciiPrintable) { - const programStr = new TextDecoder().decode(program); - if ((0, address_1.isValidAddress)(programStr)) - throw new Error('requesting program bytes, get Algorand address'); - if (base64regex.test(programStr)) - throw new Error('program should not be b64 encoded'); - throw new Error('program bytes are all ASCII printable characters, not looking like Teal byte code'); - } -} -exports.sanityCheckProgram = sanityCheckProgram; -/** - LogicSig implementation - - LogicSig cannot sign transactions in all cases. Instead, use LogicSigAccount as a safe, general purpose signing mechanism. Since LogicSig does not track the provided signature's public key, LogicSig cannot sign transactions when delegated to a non-multisig account _and_ the sender is not the delegating account. - */ -class LogicSig { - constructor(program, programArgs) { - this.tag = new TextEncoder().encode('Program'); - if (programArgs && - (!Array.isArray(programArgs) || - !programArgs.every((arg) => arg.constructor === Uint8Array))) { - throw new TypeError('Invalid arguments'); - } - let args; - if (programArgs != null) - args = programArgs.map((arg) => new Uint8Array(arg)); - sanityCheckProgram(program); - this.logic = program; - this.args = args; - this.sig = undefined; - this.msig = undefined; - } - // eslint-disable-next-line camelcase - get_obj_for_encoding() { - const obj = { - l: this.logic, - }; - if (this.args) { - obj.arg = this.args; - } - if (this.sig) { - obj.sig = this.sig; - } - else if (this.msig) { - obj.msig = this.msig; - } - return obj; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(encoded) { - const lsig = new LogicSig(encoded.l, encoded.arg); - lsig.sig = encoded.sig; - lsig.msig = encoded.msig; - return lsig; - } - /** - * Performs signature verification - * @param publicKey - Verification key (derived from sender address or escrow address) - */ - verify(publicKey) { - if (this.sig && this.msig) { - return false; - } - try { - sanityCheckProgram(this.logic); - } - catch (e) { - return false; - } - const toBeSigned = utils.concatArrays(this.tag, this.logic); - if (!this.sig && !this.msig) { - const hash = nacl.genericHash(toBeSigned); - return utils.arrayEqual(hash, publicKey); - } - if (this.sig) { - return nacl.verify(toBeSigned, this.sig, publicKey); - } - return (0, multisig_1.verifyMultisig)(toBeSigned, this.msig, publicKey); - } - /** - * Compute hash of the logic sig program (that is the same as escrow account address) as string address - * @returns String representation of the address - */ - address() { - const toBeSigned = utils.concatArrays(this.tag, this.logic); - const hash = nacl.genericHash(toBeSigned); - return address.encodeAddress(new Uint8Array(hash)); - } - /** - * Creates signature (if no msig provided) or multi signature otherwise - * @param secretKey - Secret key to sign with - * @param msig - Multisig account as \{version, threshold, addrs\} - */ - sign(secretKey, msig) { - if (msig == null) { - this.sig = this.signProgram(secretKey); - } - else { - const subsigs = msig.addrs.map((addr) => ({ - pk: address.decodeAddress(addr).publicKey, - })); - this.msig = { - v: msig.version, - thr: msig.threshold, - subsig: subsigs, - }; - const [sig, index] = this.singleSignMultisig(secretKey, this.msig); - this.msig.subsig[index].s = sig; - } - } - /** - * Appends a signature to multi signature - * @param secretKey - Secret key to sign with - */ - appendToMultisig(secretKey) { - if (this.msig === undefined) { - throw new Error('no multisig present'); - } - const [sig, index] = this.singleSignMultisig(secretKey, this.msig); - this.msig.subsig[index].s = sig; - } - signProgram(secretKey) { - const toBeSigned = utils.concatArrays(this.tag, this.logic); - const sig = nacl.sign(toBeSigned, secretKey); - return sig; - } - singleSignMultisig(secretKey, msig) { - let index = -1; - const myPk = nacl.keyPairFromSecretKey(secretKey).publicKey; - for (let i = 0; i < msig.subsig.length; i++) { - const { pk } = msig.subsig[i]; - if (utils.arrayEqual(pk, myPk)) { - index = i; - break; - } - } - if (index === -1) { - throw new Error('invalid secret key'); - } - const sig = this.signProgram(secretKey); - return [sig, index]; - } - toByte() { - return encoding.encode(this.get_obj_for_encoding()); - } - static fromByte(encoded) { - const decodedObj = encoding.decode(encoded); - return LogicSig.from_obj_for_encoding(decodedObj); - } -} -exports.LogicSig = LogicSig; -/** - * Represents an account that can sign with a LogicSig program. - */ -class LogicSigAccount { - /** - * Create a new LogicSigAccount. By default this will create an escrow - * LogicSig account. Call `sign` or `signMultisig` on the newly created - * LogicSigAccount to make it a delegated account. - * - * @param program - The compiled TEAL program which contains the logic for - * this LogicSig. - * @param args - An optional array of arguments for the program. - */ - constructor(program, args) { - this.lsig = new LogicSig(program, args); - this.sigkey = undefined; - } - // eslint-disable-next-line camelcase - get_obj_for_encoding() { - const obj = { - lsig: this.lsig.get_obj_for_encoding(), - }; - if (this.sigkey) { - obj.sigkey = this.sigkey; - } - return obj; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(encoded) { - const lsigAccount = new LogicSigAccount(encoded.lsig.l, encoded.lsig.arg); - lsigAccount.lsig = LogicSig.from_obj_for_encoding(encoded.lsig); - lsigAccount.sigkey = encoded.sigkey; - return lsigAccount; - } - /** - * Encode this object into msgpack. - */ - toByte() { - return encoding.encode(this.get_obj_for_encoding()); - } - /** - * Decode a msgpack object into a LogicSigAccount. - * @param encoded - The encoded LogicSigAccount. - */ - static fromByte(encoded) { - const decodedObj = encoding.decode(encoded); - return LogicSigAccount.from_obj_for_encoding(decodedObj); - } - /** - * Check if this LogicSigAccount has been delegated to another account with a - * signature. - * - * Note this function only checks for the presence of a delegation signature. - * To verify the delegation signature, use `verify`. - */ - isDelegated() { - return !!(this.lsig.sig || this.lsig.msig); - } - /** - * Verifies this LogicSig's program and signatures. - * @returns true if and only if the LogicSig program and signatures are valid. - */ - verify() { - const addr = this.address(); - return this.lsig.verify(address.decodeAddress(addr).publicKey); - } - /** - * Get the address of this LogicSigAccount. - * - * If the LogicSig is delegated to another account, this will return the - * address of that account. - * - * If the LogicSig is not delegated to another account, this will return an - * escrow address that is the hash of the LogicSig's program code. - */ - address() { - if (this.lsig.sig && this.lsig.msig) { - throw new Error('LogicSig has too many signatures. At most one of sig or msig may be present'); - } - if (this.lsig.sig) { - if (!this.sigkey) { - throw new Error('Signing key for delegated account is missing'); - } - return address.encodeAddress(this.sigkey); - } - if (this.lsig.msig) { - const msigMetadata = { - version: this.lsig.msig.v, - threshold: this.lsig.msig.thr, - pks: this.lsig.msig.subsig.map((subsig) => subsig.pk), - }; - return address.encodeAddress(address.fromMultisigPreImg(msigMetadata)); - } - return this.lsig.address(); - } - /** - * Turns this LogicSigAccount into a delegated LogicSig. This type of LogicSig - * has the authority to sign transactions on behalf of another account, called - * the delegating account. Use this function if the delegating account is a - * multisig account. - * - * @param msig - The multisig delegating account - * @param secretKey - The secret key of one of the members of the delegating - * multisig account. Use `appendToMultisig` to add additional signatures - * from other members. - */ - signMultisig(msig, secretKey) { - this.lsig.sign(secretKey, msig); - } - /** - * Adds an additional signature from a member of the delegating multisig - * account. - * - * @param secretKey - The secret key of one of the members of the delegating - * multisig account. - */ - appendToMultisig(secretKey) { - this.lsig.appendToMultisig(secretKey); - } - /** - * Turns this LogicSigAccount into a delegated LogicSig. This type of LogicSig - * has the authority to sign transactions on behalf of another account, called - * the delegating account. If the delegating account is a multisig account, - * use `signMultisig` instead. - * - * @param secretKey - The secret key of the delegating account. - */ - sign(secretKey) { - this.lsig.sign(secretKey); - this.sigkey = nacl.keyPairFromSecretKey(secretKey).publicKey; - } -} -exports.LogicSigAccount = LogicSigAccount; -function signLogicSigTransactionWithAddress(txn, lsig, lsigAddress) { - if (!lsig.verify(lsigAddress)) { - throw new Error('Logic signature verification failed. Ensure the program and signature are valid.'); - } - const signedTxn = { - lsig: lsig.get_obj_for_encoding(), - txn: txn.get_obj_for_encoding(), - }; - if (!nacl.bytesEqual(lsigAddress, txn.sender.publicKey)) { - signedTxn.sgnr = lsigAddress; - } - return { - txID: txn.txID().toString(), - blob: encoding.encode(signedTxn), - }; -} -/** - * signLogicSigTransactionObject takes a transaction and a LogicSig object and - * returns a signed transaction. - * - * @param txn - The transaction to sign. - * @param lsigObject - The LogicSig object that will sign the transaction. - * - * @returns Object containing txID and blob representing signed transaction. - */ -function signLogicSigTransactionObject(txn, lsigObject) { - let lsig; - let lsigAddress; - if (lsigObject instanceof LogicSigAccount) { - lsig = lsigObject.lsig; - lsigAddress = address.decodeAddress(lsigObject.address()).publicKey; - } - else { - lsig = lsigObject; - if (lsig.sig) { - // For a LogicSig with a non-multisig delegating account, we cannot derive - // the address of that account from only its signature, so assume the - // delegating account is the sender. If that's not the case, the signing - // will fail. - lsigAddress = txn.sender.publicKey; - } - else if (lsig.msig) { - const msigMetadata = { - version: lsig.msig.v, - threshold: lsig.msig.thr, - pks: lsig.msig.subsig.map((subsig) => subsig.pk), - }; - lsigAddress = address.fromMultisigPreImg(msigMetadata); - } - else { - lsigAddress = address.decodeAddress(lsig.address()).publicKey; - } - } - return signLogicSigTransactionWithAddress(txn, lsig, lsigAddress); -} -exports.signLogicSigTransactionObject = signLogicSigTransactionObject; -/** - * signLogicSigTransaction takes a transaction and a LogicSig object and returns - * a signed transaction. - * - * @param txn - The transaction to sign. - * @param lsigObject - The LogicSig object that will sign the transaction. - * - * @returns Object containing txID and blob representing signed transaction. - * @throws error on failure - */ -function signLogicSigTransaction(txn, lsigObject) { - const algoTxn = txnBuilder.instantiateTxnIfNeeded(txn); - return signLogicSigTransactionObject(algoTxn, lsigObject); -} -exports.signLogicSigTransaction = signLogicSigTransaction; -/** - * logicSigFromByte accepts encoded logic sig bytes and attempts to call logicsig.fromByte on it, - * returning the result - */ -function logicSigFromByte(encoded) { - return LogicSig.fromByte(encoded); -} -exports.logicSigFromByte = logicSigFromByte; -const SIGN_PROGRAM_DATA_PREFIX = new TextEncoder().encode('ProgData'); -/** - * tealSign creates a signature compatible with ed25519verify opcode from program hash - * @param sk - Uint8Array with secret key - * @param data - Uint8Array with data to sign - * @param programHash - string representation of teal program hash (= contract address for LogicSigs) - */ -function tealSign(sk, data, programHash) { - const parts = utils.concatArrays(address.decodeAddress(programHash).publicKey, data); - const toBeSigned = utils.concatArrays(SIGN_PROGRAM_DATA_PREFIX, parts); - return nacl.sign(toBeSigned, sk); -} -exports.tealSign = tealSign; -/** - * verifyTealSign verifies a signature as would the ed25519verify opcode - * @param data - Uint8Array with original signed data - * @param programHash - string representation of teal program hash (= contract address for LogicSigs) - * @param sig - uint8array with the signature to verify (produced by tealSign/tealSignFromProgram) - * @param pk - uint8array with public key to verify against - */ -function verifyTealSign(data, programHash, sig, pk) { - const parts = utils.concatArrays(address.decodeAddress(programHash).publicKey, data); - const toBeSigned = utils.concatArrays(SIGN_PROGRAM_DATA_PREFIX, parts); - return nacl.verify(toBeSigned, sig, pk); -} -exports.verifyTealSign = verifyTealSign; -/** - * tealSignFromProgram creates a signature compatible with ed25519verify opcode from raw program bytes - * @param sk - uint8array with secret key - * @param data - Uint8Array with data to sign - * @param program - Uint8Array with teal program - */ -function tealSignFromProgram(sk, data, program) { - const lsig = new LogicSig(program); - const contractAddress = lsig.address(); - return tealSign(sk, data, contractAddress); -} -exports.tealSignFromProgram = tealSignFromProgram; diff --git a/algosdk/main.d.ts b/algosdk/main.d.ts deleted file mode 100644 index 4229fef..0000000 --- a/algosdk/main.d.ts +++ /dev/null @@ -1,90 +0,0 @@ -import * as txnBuilder from './transaction'; -import { BidOptions } from './bid'; -export declare const MULTISIG_BAD_SENDER_ERROR_MSG = "The transaction sender address and multisig preimage do not match."; -/** - * signTransaction takes an object with either payment or key registration fields and - * a secret key and returns a signed blob. - * - * Payment transaction fields: from, to, amount, fee, firstValid, lastValid, genesisHash, - * note(optional), GenesisID(optional), closeRemainderTo(optional) - * - * Key registration fields: fee, firstValid, lastValid, voteKey, selectionKey, voteFirst, - * voteLast, voteKeyDilution, genesisHash, note(optional), GenesisID(optional) - * - * If flatFee is not set and the final calculated fee is lower than the protocol minimum fee, the fee will be increased to match the minimum. - * @param txn - object with either payment or key registration fields - * @param sk - Algorand Secret Key - * @returns object contains the binary signed transaction and its txID - */ -export declare function signTransaction(txn: txnBuilder.TransactionLike, sk: Uint8Array): { - txID: string; - blob: Uint8Array; -}; -/** - * signBid takes an object with the following fields: bidder key, bid amount, max price, bid ID, auctionKey, auction ID, - * and a secret key and returns a signed blob to be inserted into a transaction Algorand note field. - * @param bid - Algorand Bid - * @param sk - Algorand secret key - * @returns Uint8Array binary signed bid - */ -export declare function signBid(bid: BidOptions, sk: Uint8Array): Uint8Array; -/** - * signBytes takes arbitrary bytes and a secret key, prepends the bytes with "MX" for domain separation, signs the bytes - * with the private key, and returns the signature. - * @param bytes - Uint8array - * @param sk - Algorand secret key - * @returns binary signature - */ -export declare function signBytes(bytes: Uint8Array, sk: Uint8Array): Uint8Array; -/** - * verifyBytes takes array of bytes, an address, and a signature and verifies if the signature is correct for the public - * key and the bytes (the bytes should have been signed with "MX" prepended for domain separation). - * @param bytes - Uint8Array - * @param signature - binary signature - * @param addr - string address - * @returns bool - */ -export declare function verifyBytes(bytes: Uint8Array, signature: Uint8Array, addr: string): boolean; -/** - * encodeObj takes a javascript object and returns its msgpack encoding - * Note that the encoding sorts the fields alphabetically - * @param o - js obj - * @returns Uint8Array binary representation - */ -export declare function encodeObj(o: Record): Uint8Array; -/** - * decodeObj takes a Uint8Array and returns its javascript obj - * @param o - Uint8Array to decode - * @returns object - */ -export declare function decodeObj(o: ArrayLike): unknown; -export declare const ERROR_MULTISIG_BAD_SENDER: Error; -export declare const ERROR_INVALID_MICROALGOS: Error; -export { default as Algodv2 } from './client/v2/algod/algod'; -export { default as Kmd } from './client/kmd'; -export { default as IntDecoding } from './types/intDecoding'; -export { default as Account } from './types/account'; -export { default as Indexer } from './client/v2/indexer/indexer'; -export { BaseHTTPClient, BaseHTTPClientResponse, BaseHTTPClientError, } from './client/baseHTTPClient'; -export { AlgodTokenHeader, IndexerTokenHeader, KMDTokenHeader, CustomTokenHeader, TokenHeader, } from './client/urlTokenBaseHTTPClient'; -export { waitForConfirmation } from './wait'; -export { isValidAddress, encodeAddress, decodeAddress, getApplicationAddress, } from './encoding/address'; -export { bytesToBigInt, bigIntToBytes } from './encoding/bigint'; -export { base64ToBytes, base64ToString, bytesToBase64, bytesToHex, hexToBytes, } from './encoding/binarydata'; -export { encodeUint64, decodeUint64 } from './encoding/uint64'; -export { default as generateAccount } from './account'; -export * as modelsv2 from './client/v2/algod/models/types'; -export * as indexerModels from './client/v2/indexer/models/types'; -export { mnemonicToMasterDerivationKey, masterDerivationKeyToMnemonic, secretKeyToMnemonic, mnemonicToSecretKey, seedFromMnemonic, mnemonicFromSeed, } from './mnemonic/mnemonic'; -export { microalgosToAlgos, algosToMicroalgos, INVALID_MICROALGOS_ERROR_MSG, } from './convert'; -export { computeGroupID, assignGroupID } from './group'; -export { LogicSig, LogicSigAccount, signLogicSigTransaction, signLogicSigTransactionObject, logicSigFromByte, tealSign, tealSignFromProgram, verifyTealSign, } from './logicsig'; -export { signMultisigTransaction, mergeMultisigTransactions, appendSignMultisigTransaction, createMultisigTransaction, appendSignRawMultisigSignature, verifyMultisig, multisigAddress, } from './multisig'; -export { ProgramSourceMap, SourceLocation, PcLineLocation, } from './logic/sourcemap'; -export * from './dryrun'; -export * from './makeTxn'; -export * from './transaction'; -export * from './signer'; -export * from './composer'; -export * from './types'; -export * from './abi'; diff --git a/algosdk/main.js b/algosdk/main.js deleted file mode 100644 index eda72e8..0000000 --- a/algosdk/main.js +++ /dev/null @@ -1,203 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.signMultisigTransaction = exports.verifyTealSign = exports.tealSignFromProgram = exports.tealSign = exports.logicSigFromByte = exports.signLogicSigTransactionObject = exports.signLogicSigTransaction = exports.LogicSigAccount = exports.LogicSig = exports.assignGroupID = exports.computeGroupID = exports.INVALID_MICROALGOS_ERROR_MSG = exports.algosToMicroalgos = exports.microalgosToAlgos = exports.mnemonicFromSeed = exports.seedFromMnemonic = exports.mnemonicToSecretKey = exports.secretKeyToMnemonic = exports.masterDerivationKeyToMnemonic = exports.mnemonicToMasterDerivationKey = exports.indexerModels = exports.modelsv2 = exports.generateAccount = exports.decodeUint64 = exports.encodeUint64 = exports.hexToBytes = exports.bytesToHex = exports.bytesToBase64 = exports.base64ToString = exports.base64ToBytes = exports.bigIntToBytes = exports.bytesToBigInt = exports.getApplicationAddress = exports.decodeAddress = exports.encodeAddress = exports.isValidAddress = exports.waitForConfirmation = exports.Indexer = exports.IntDecoding = exports.Kmd = exports.Algodv2 = exports.ERROR_INVALID_MICROALGOS = exports.ERROR_MULTISIG_BAD_SENDER = exports.decodeObj = exports.encodeObj = exports.verifyBytes = exports.signBytes = exports.signBid = exports.signTransaction = exports.MULTISIG_BAD_SENDER_ERROR_MSG = void 0; -exports.ProgramSourceMap = exports.multisigAddress = exports.verifyMultisig = exports.appendSignRawMultisigSignature = exports.createMultisigTransaction = exports.appendSignMultisigTransaction = exports.mergeMultisigTransactions = void 0; -const nacl = __importStar(require("./nacl/naclWrappers")); -const address = __importStar(require("./encoding/address")); -const encoding = __importStar(require("./encoding/encoding")); -const txnBuilder = __importStar(require("./transaction")); -const bid_1 = __importDefault(require("./bid")); -const convert = __importStar(require("./convert")); -const utils = __importStar(require("./utils/utils")); -const SIGN_BYTES_PREFIX = Uint8Array.from([77, 88]); // "MX" -// Errors -exports.MULTISIG_BAD_SENDER_ERROR_MSG = 'The transaction sender address and multisig preimage do not match.'; -/** - * signTransaction takes an object with either payment or key registration fields and - * a secret key and returns a signed blob. - * - * Payment transaction fields: from, to, amount, fee, firstValid, lastValid, genesisHash, - * note(optional), GenesisID(optional), closeRemainderTo(optional) - * - * Key registration fields: fee, firstValid, lastValid, voteKey, selectionKey, voteFirst, - * voteLast, voteKeyDilution, genesisHash, note(optional), GenesisID(optional) - * - * If flatFee is not set and the final calculated fee is lower than the protocol minimum fee, the fee will be increased to match the minimum. - * @param txn - object with either payment or key registration fields - * @param sk - Algorand Secret Key - * @returns object contains the binary signed transaction and its txID - */ -function signTransaction(txn, sk) { - if (typeof txn.sender === 'undefined') { - // Get pk from sk if no sender specified - const key = nacl.keyPairFromSecretKey(sk); - // eslint-disable-next-line no-param-reassign - txn.sender = address.encodeAddress(key.publicKey); - } - const algoTxn = txnBuilder.instantiateTxnIfNeeded(txn); - return { - txID: algoTxn.txID().toString(), - blob: algoTxn.signTxn(sk), - }; -} -exports.signTransaction = signTransaction; -/** - * signBid takes an object with the following fields: bidder key, bid amount, max price, bid ID, auctionKey, auction ID, - * and a secret key and returns a signed blob to be inserted into a transaction Algorand note field. - * @param bid - Algorand Bid - * @param sk - Algorand secret key - * @returns Uint8Array binary signed bid - */ -function signBid(bid, sk) { - const signedBid = new bid_1.default(bid); - return signedBid.signBid(sk); -} -exports.signBid = signBid; -/** - * signBytes takes arbitrary bytes and a secret key, prepends the bytes with "MX" for domain separation, signs the bytes - * with the private key, and returns the signature. - * @param bytes - Uint8array - * @param sk - Algorand secret key - * @returns binary signature - */ -function signBytes(bytes, sk) { - const toBeSigned = utils.concatArrays(SIGN_BYTES_PREFIX, bytes); - const sig = nacl.sign(toBeSigned, sk); - return sig; -} -exports.signBytes = signBytes; -/** - * verifyBytes takes array of bytes, an address, and a signature and verifies if the signature is correct for the public - * key and the bytes (the bytes should have been signed with "MX" prepended for domain separation). - * @param bytes - Uint8Array - * @param signature - binary signature - * @param addr - string address - * @returns bool - */ -function verifyBytes(bytes, signature, addr) { - const toBeVerified = utils.concatArrays(SIGN_BYTES_PREFIX, bytes); - const pk = address.decodeAddress(addr).publicKey; - return nacl.verify(toBeVerified, signature, pk); -} -exports.verifyBytes = verifyBytes; -/** - * encodeObj takes a javascript object and returns its msgpack encoding - * Note that the encoding sorts the fields alphabetically - * @param o - js obj - * @returns Uint8Array binary representation - */ -function encodeObj(o) { - return new Uint8Array(encoding.encode(o)); -} -exports.encodeObj = encodeObj; -/** - * decodeObj takes a Uint8Array and returns its javascript obj - * @param o - Uint8Array to decode - * @returns object - */ -function decodeObj(o) { - return encoding.decode(o); -} -exports.decodeObj = decodeObj; -exports.ERROR_MULTISIG_BAD_SENDER = new Error(exports.MULTISIG_BAD_SENDER_ERROR_MSG); -exports.ERROR_INVALID_MICROALGOS = new Error(convert.INVALID_MICROALGOS_ERROR_MSG); -var algod_1 = require("./client/v2/algod/algod"); -Object.defineProperty(exports, "Algodv2", { enumerable: true, get: function () { return __importDefault(algod_1).default; } }); -var kmd_1 = require("./client/kmd"); -Object.defineProperty(exports, "Kmd", { enumerable: true, get: function () { return __importDefault(kmd_1).default; } }); -var intDecoding_1 = require("./types/intDecoding"); -Object.defineProperty(exports, "IntDecoding", { enumerable: true, get: function () { return __importDefault(intDecoding_1).default; } }); -var indexer_1 = require("./client/v2/indexer/indexer"); -Object.defineProperty(exports, "Indexer", { enumerable: true, get: function () { return __importDefault(indexer_1).default; } }); -var wait_1 = require("./wait"); -Object.defineProperty(exports, "waitForConfirmation", { enumerable: true, get: function () { return wait_1.waitForConfirmation; } }); -var address_1 = require("./encoding/address"); -Object.defineProperty(exports, "isValidAddress", { enumerable: true, get: function () { return address_1.isValidAddress; } }); -Object.defineProperty(exports, "encodeAddress", { enumerable: true, get: function () { return address_1.encodeAddress; } }); -Object.defineProperty(exports, "decodeAddress", { enumerable: true, get: function () { return address_1.decodeAddress; } }); -Object.defineProperty(exports, "getApplicationAddress", { enumerable: true, get: function () { return address_1.getApplicationAddress; } }); -var bigint_1 = require("./encoding/bigint"); -Object.defineProperty(exports, "bytesToBigInt", { enumerable: true, get: function () { return bigint_1.bytesToBigInt; } }); -Object.defineProperty(exports, "bigIntToBytes", { enumerable: true, get: function () { return bigint_1.bigIntToBytes; } }); -var binarydata_1 = require("./encoding/binarydata"); -Object.defineProperty(exports, "base64ToBytes", { enumerable: true, get: function () { return binarydata_1.base64ToBytes; } }); -Object.defineProperty(exports, "base64ToString", { enumerable: true, get: function () { return binarydata_1.base64ToString; } }); -Object.defineProperty(exports, "bytesToBase64", { enumerable: true, get: function () { return binarydata_1.bytesToBase64; } }); -Object.defineProperty(exports, "bytesToHex", { enumerable: true, get: function () { return binarydata_1.bytesToHex; } }); -Object.defineProperty(exports, "hexToBytes", { enumerable: true, get: function () { return binarydata_1.hexToBytes; } }); -var uint64_1 = require("./encoding/uint64"); -Object.defineProperty(exports, "encodeUint64", { enumerable: true, get: function () { return uint64_1.encodeUint64; } }); -Object.defineProperty(exports, "decodeUint64", { enumerable: true, get: function () { return uint64_1.decodeUint64; } }); -var account_1 = require("./account"); -Object.defineProperty(exports, "generateAccount", { enumerable: true, get: function () { return __importDefault(account_1).default; } }); -exports.modelsv2 = __importStar(require("./client/v2/algod/models/types")); -exports.indexerModels = __importStar(require("./client/v2/indexer/models/types")); -var mnemonic_1 = require("./mnemonic/mnemonic"); -Object.defineProperty(exports, "mnemonicToMasterDerivationKey", { enumerable: true, get: function () { return mnemonic_1.mnemonicToMasterDerivationKey; } }); -Object.defineProperty(exports, "masterDerivationKeyToMnemonic", { enumerable: true, get: function () { return mnemonic_1.masterDerivationKeyToMnemonic; } }); -Object.defineProperty(exports, "secretKeyToMnemonic", { enumerable: true, get: function () { return mnemonic_1.secretKeyToMnemonic; } }); -Object.defineProperty(exports, "mnemonicToSecretKey", { enumerable: true, get: function () { return mnemonic_1.mnemonicToSecretKey; } }); -Object.defineProperty(exports, "seedFromMnemonic", { enumerable: true, get: function () { return mnemonic_1.seedFromMnemonic; } }); -Object.defineProperty(exports, "mnemonicFromSeed", { enumerable: true, get: function () { return mnemonic_1.mnemonicFromSeed; } }); -var convert_1 = require("./convert"); -Object.defineProperty(exports, "microalgosToAlgos", { enumerable: true, get: function () { return convert_1.microalgosToAlgos; } }); -Object.defineProperty(exports, "algosToMicroalgos", { enumerable: true, get: function () { return convert_1.algosToMicroalgos; } }); -Object.defineProperty(exports, "INVALID_MICROALGOS_ERROR_MSG", { enumerable: true, get: function () { return convert_1.INVALID_MICROALGOS_ERROR_MSG; } }); -var group_1 = require("./group"); -Object.defineProperty(exports, "computeGroupID", { enumerable: true, get: function () { return group_1.computeGroupID; } }); -Object.defineProperty(exports, "assignGroupID", { enumerable: true, get: function () { return group_1.assignGroupID; } }); -var logicsig_1 = require("./logicsig"); -Object.defineProperty(exports, "LogicSig", { enumerable: true, get: function () { return logicsig_1.LogicSig; } }); -Object.defineProperty(exports, "LogicSigAccount", { enumerable: true, get: function () { return logicsig_1.LogicSigAccount; } }); -Object.defineProperty(exports, "signLogicSigTransaction", { enumerable: true, get: function () { return logicsig_1.signLogicSigTransaction; } }); -Object.defineProperty(exports, "signLogicSigTransactionObject", { enumerable: true, get: function () { return logicsig_1.signLogicSigTransactionObject; } }); -Object.defineProperty(exports, "logicSigFromByte", { enumerable: true, get: function () { return logicsig_1.logicSigFromByte; } }); -Object.defineProperty(exports, "tealSign", { enumerable: true, get: function () { return logicsig_1.tealSign; } }); -Object.defineProperty(exports, "tealSignFromProgram", { enumerable: true, get: function () { return logicsig_1.tealSignFromProgram; } }); -Object.defineProperty(exports, "verifyTealSign", { enumerable: true, get: function () { return logicsig_1.verifyTealSign; } }); -var multisig_1 = require("./multisig"); -Object.defineProperty(exports, "signMultisigTransaction", { enumerable: true, get: function () { return multisig_1.signMultisigTransaction; } }); -Object.defineProperty(exports, "mergeMultisigTransactions", { enumerable: true, get: function () { return multisig_1.mergeMultisigTransactions; } }); -Object.defineProperty(exports, "appendSignMultisigTransaction", { enumerable: true, get: function () { return multisig_1.appendSignMultisigTransaction; } }); -Object.defineProperty(exports, "createMultisigTransaction", { enumerable: true, get: function () { return multisig_1.createMultisigTransaction; } }); -Object.defineProperty(exports, "appendSignRawMultisigSignature", { enumerable: true, get: function () { return multisig_1.appendSignRawMultisigSignature; } }); -Object.defineProperty(exports, "verifyMultisig", { enumerable: true, get: function () { return multisig_1.verifyMultisig; } }); -Object.defineProperty(exports, "multisigAddress", { enumerable: true, get: function () { return multisig_1.multisigAddress; } }); -var sourcemap_1 = require("./logic/sourcemap"); -Object.defineProperty(exports, "ProgramSourceMap", { enumerable: true, get: function () { return sourcemap_1.ProgramSourceMap; } }); -__exportStar(require("./dryrun"), exports); -__exportStar(require("./makeTxn"), exports); -__exportStar(require("./transaction"), exports); -__exportStar(require("./signer"), exports); -__exportStar(require("./composer"), exports); -__exportStar(require("./types"), exports); -__exportStar(require("./abi"), exports); diff --git a/algosdk/makeTxn.d.ts b/algosdk/makeTxn.d.ts deleted file mode 100644 index 6fc3a3f..0000000 --- a/algosdk/makeTxn.d.ts +++ /dev/null @@ -1,424 +0,0 @@ -import * as txnBuilder from './transaction'; -import { PaymentTxn, KeyRegistrationTxn, MustHaveSuggestedParams, AssetCreateTxn, AssetConfigTxn, AssetDestroyTxn, AssetFreezeTxn, AssetTransferTxn, AppCreateTxn, AppUpdateTxn, AppDeleteTxn, AppOptInTxn, AppCloseOutTxn, AppClearStateTxn, AppNoOpTxn } from './types/transactions'; -import { RenameProperties, RenameProperty, Expand } from './types/utils'; -/** - * makePaymentTxnWithSuggestedParams takes payment arguments and returns a Transaction object - * @param sender - string representation of Algorand address of sender - * @param receiver - string representation of Algorand address of recipient - * @param amount - integer amount to send, in microAlgos - * @param closeRemainderTo - optionally close out remaining account balance to this account, represented as string rep of Algorand address - * @param note - uint8array of arbitrary data for sender to store - * @param suggestedParams - a dict holding common-to-all-txns args: - * fee - integer fee per byte, in microAlgos. for a flat fee, set flatFee to true - * flatFee - bool optionally set this to true to specify fee as microalgos-per-txn - * If true, txn fee may fall below the ALGORAND_MIN_TX_FEE - * firstValid - integer first protocol round on which this txn is valid - * lastValid - integer last protocol round on which this txn is valid - * genesisHash - string specifies hash genesis block of network in use - * genesisID - string specifies genesis ID of network in use - * @param rekeyTo - rekeyTo address, optional - */ -export declare function makePaymentTxnWithSuggestedParams(sender: PaymentTxn['sender'], receiver: PaymentTxn['receiver'], amount: PaymentTxn['amount'], closeRemainderTo: PaymentTxn['closeRemainderTo'], note: PaymentTxn['note'], suggestedParams: MustHaveSuggestedParams['suggestedParams'], rekeyTo?: PaymentTxn['rekeyTo']): txnBuilder.Transaction; -export declare function makePaymentTxnWithSuggestedParamsFromObject(o: Expand, 'rekeyTo', 'rekeyTo'>, 'sender' | 'receiver' | 'amount' | 'closeRemainderTo' | 'note' | 'suggestedParams' | 'rekeyTo'>>): txnBuilder.Transaction; -/** - * makeKeyRegistrationTxnWithSuggestedParams takes key registration arguments and returns a Transaction object for - * that key registration operation - * - * @param sender - string representation of Algorand address of sender - * @param note - uint8array of arbitrary data for sender to store - * @param voteKey - voting key. for key deregistration, leave undefined - * @param selectionKey - selection key. for key deregistration, leave undefined - * @param voteFirst - first round on which voteKey is valid - * @param voteLast - last round on which voteKey is valid - * @param voteKeyDilution - integer - * @param suggestedParams - a dict holding common-to-all-txns args: - * fee - integer fee per byte, in microAlgos. for a flat fee, set flatFee to true - * flatFee - bool optionally set this to true to specify fee as microalgos-per-txn - * If true, txn fee may fall below the ALGORAND_MIN_TX_FEE - * firstValid - integer first protocol round on which this txn is valid - * lastValid - integer last protocol round on which this txn is valid - * genesisHash - string specifies hash genesis block of network in use - * genesisID - string specifies genesis ID of network in use - * @param rekeyTo - rekeyTo address, optional - * @param nonParticipation - configure whether the address wants to stop participating. If true, - * voteKey, selectionKey, voteFirst, voteLast, and voteKeyDilution must be undefined. - * @param stateProofKey - state proof key. for key deregistration, leave undefined - */ -export declare function makeKeyRegistrationTxnWithSuggestedParams(sender: KeyRegistrationTxn['sender'], note: KeyRegistrationTxn['note'], voteKey: KeyRegistrationTxn['voteKey'], selectionKey: KeyRegistrationTxn['selectionKey'], voteFirst: KeyRegistrationTxn['voteFirst'], voteLast: KeyRegistrationTxn['voteLast'], voteKeyDilution: KeyRegistrationTxn['voteKeyDilution'], suggestedParams: MustHaveSuggestedParams['suggestedParams'], rekeyTo?: KeyRegistrationTxn['rekeyTo'], nonParticipation?: false, stateProofKey?: KeyRegistrationTxn['stateProofKey']): txnBuilder.Transaction; -export declare function makeKeyRegistrationTxnWithSuggestedParams(sender: KeyRegistrationTxn['sender'], note: KeyRegistrationTxn['note'], voteKey: undefined, selectionKey: undefined, voteFirst: undefined, voteLast: undefined, voteKeyDilution: undefined, suggestedParams: MustHaveSuggestedParams['suggestedParams'], rekeyTo?: KeyRegistrationTxn['rekeyTo'], nonParticipation?: true, stateProofKey?: undefined): txnBuilder.Transaction; -export declare function makeKeyRegistrationTxnWithSuggestedParamsFromObject(o: Expand, 'rekeyTo', 'rekeyTo'>, 'sender' | 'note' | 'voteKey' | 'selectionKey' | 'stateProofKey' | 'voteFirst' | 'voteLast' | 'voteKeyDilution' | 'suggestedParams' | 'rekeyTo'> & { - nonParticipation?: false; -}>): txnBuilder.Transaction; -export declare function makeKeyRegistrationTxnWithSuggestedParamsFromObject(o: Expand, 'rekeyTo', 'rekeyTo'>, 'sender' | 'note' | 'suggestedParams' | 'rekeyTo' | 'nonParticipation'>>): txnBuilder.Transaction; -/** makeAssetCreateTxnWithSuggestedParams takes asset creation arguments and returns a Transaction object - * for creating that asset - * - * @param sender - string representation of Algorand address of sender - * @param note - uint8array of arbitrary data for sender to store - * @param total - integer total supply of the asset - * @param decimals - integer number of decimals for asset unit calculation - * @param defaultFrozen - boolean whether asset accounts should default to being frozen - * @param manager - string representation of Algorand address in charge of reserve, freeze, clawback, destruction, etc - * @param reserve - string representation of Algorand address representing asset reserve - * @param freeze - string representation of Algorand address with power to freeze/unfreeze asset holdings - * @param clawback - string representation of Algorand address with power to revoke asset holdings - * @param unitName - string units name for this asset - * @param assetName - string name for this asset - * @param assetURL - string URL relating to this asset - * @param assetMetadataHash - Uint8Array or UTF-8 string representation of a hash commitment with respect to the asset. Must be exactly 32 bytes long. - * @param suggestedParams - a dict holding common-to-all-txns args: - * fee - integer fee per byte, in microAlgos. for a flat fee, set flatFee to true - * flatFee - bool optionally set this to true to specify fee as microalgos-per-txn - * If true, txn fee may fall below the ALGORAND_MIN_TX_FEE - * firstValid - integer first protocol round on which this txn is valid - * lastValid - integer last protocol round on which this txn is valid - * genesisHash - string specifies hash genesis block of network in use - * genesisID - string specifies genesis ID of network in use - * @param rekeyTo - rekeyTo address, optional - */ -export declare function makeAssetCreateTxnWithSuggestedParams(sender: AssetCreateTxn['sender'], note: AssetCreateTxn['note'], total: AssetCreateTxn['assetTotal'], decimals: AssetCreateTxn['assetDecimals'], defaultFrozen: AssetCreateTxn['assetDefaultFrozen'], manager: AssetCreateTxn['assetManager'], reserve: AssetCreateTxn['assetReserve'], freeze: AssetCreateTxn['assetFreeze'], clawback: AssetCreateTxn['assetClawback'], unitName: AssetCreateTxn['assetUnitName'], assetName: AssetCreateTxn['assetName'], assetURL: AssetCreateTxn['assetURL'], assetMetadataHash: AssetCreateTxn['assetMetadataHash'] | undefined, suggestedParams: MustHaveSuggestedParams['suggestedParams'], rekeyTo?: AssetCreateTxn['rekeyTo']): txnBuilder.Transaction; -export declare function makeAssetCreateTxnWithSuggestedParamsFromObject(o: Expand, { - rekeyTo: 'rekeyTo'; - assetTotal: 'total'; - assetDecimals: 'decimals'; - assetDefaultFrozen: 'defaultFrozen'; - assetManager: 'manager'; - assetReserve: 'reserve'; - assetFreeze: 'freeze'; - assetClawback: 'clawback'; - assetUnitName: 'unitName'; -}>, 'sender' | 'note' | 'total' | 'decimals' | 'defaultFrozen' | 'manager' | 'reserve' | 'freeze' | 'clawback' | 'unitName' | 'assetName' | 'assetURL' | 'assetMetadataHash' | 'suggestedParams' | 'rekeyTo'>>): txnBuilder.Transaction; -/** makeAssetConfigTxnWithSuggestedParams can be issued by the asset manager to change the manager, reserve, freeze, or clawback - * you must respecify existing addresses to keep them the same; leaving a field blank is the same as turning - * that feature off for this asset - * - * @param sender - string representation of Algorand address of sender - * @param note - uint8array of arbitrary data for sender to store - * @param assetIndex - int asset index uniquely specifying the asset - * @param manager - string representation of new asset manager Algorand address - * @param reserve - string representation of new reserve Algorand address - * @param freeze - string representation of new freeze manager Algorand address - * @param clawback - string representation of new revocation manager Algorand address - * @param suggestedParams - a dict holding common-to-all-txns args: - * fee - integer fee per byte, in microAlgos. for a flat fee, set flatFee to true - * flatFee - bool optionally set this to true to specify fee as microalgos-per-txn - * If true, txn fee may fall below the ALGORAND_MIN_TX_FEE - * firstValid - integer first protocol round on which this txn is valid - * lastValid - integer last protocol round on which this txn is valid - * genesisHash - string specifies hash genesis block of network in use - * genesisID - string specifies genesis ID of network in use - * @param rekeyTo - rekeyTo address, optional - * @param strictEmptyAddressChecking - boolean - throw an error if any of manager, reserve, freeze, or clawback are undefined. optional, defaults to true. - */ -export declare function makeAssetConfigTxnWithSuggestedParams(sender: AssetConfigTxn['sender'], note: AssetConfigTxn['note'], assetIndex: AssetConfigTxn['assetIndex'], manager: AssetConfigTxn['assetManager'], reserve: AssetConfigTxn['assetReserve'], freeze: AssetConfigTxn['assetFreeze'], clawback: AssetConfigTxn['assetClawback'], suggestedParams: MustHaveSuggestedParams['suggestedParams'], rekeyTo?: AssetConfigTxn['rekeyTo'], strictEmptyAddressChecking?: boolean): txnBuilder.Transaction; -export declare function makeAssetConfigTxnWithSuggestedParamsFromObject(o: Expand, { - rekeyTo: 'rekeyTo'; - assetManager: 'manager'; - assetReserve: 'reserve'; - assetFreeze: 'freeze'; - assetClawback: 'clawback'; -}>, 'sender' | 'note' | 'assetIndex' | 'manager' | 'reserve' | 'freeze' | 'clawback' | 'suggestedParams' | 'rekeyTo'> & { - strictEmptyAddressChecking: boolean; -}>): txnBuilder.Transaction; -/** makeAssetDestroyTxnWithSuggestedParams will allow the asset's manager to remove this asset from the ledger, so long - * as all outstanding assets are held by the creator. - * - * @param sender - string representation of Algorand address of sender - * @param note - uint8array of arbitrary data for sender to store - * @param assetIndex - int asset index uniquely specifying the asset - * @param suggestedParams - a dict holding common-to-all-txns args: - * fee - integer fee per byte, in microAlgos. for a flat fee, set flatFee to true - * flatFee - bool optionally set this to true to specify fee as microalgos-per-txn - * If true, txn fee may fall below the ALGORAND_MIN_TX_FEE - * firstValid - integer first protocol round on which this txn is valid - * lastValid - integer last protocol round on which this txn is valid - * genesisHash - string specifies hash genesis block of network in use - * genesisID - string specifies genesis ID of network in use - * @param rekeyTo - rekeyTo address, optional - */ -export declare function makeAssetDestroyTxnWithSuggestedParams(sender: AssetDestroyTxn['sender'], note: AssetDestroyTxn['note'], assetIndex: AssetDestroyTxn['assetIndex'], suggestedParams: MustHaveSuggestedParams['suggestedParams'], rekeyTo?: AssetDestroyTxn['rekeyTo']): txnBuilder.Transaction; -export declare function makeAssetDestroyTxnWithSuggestedParamsFromObject(o: Expand, 'rekeyTo', 'rekeyTo'>, 'sender' | 'note' | 'assetIndex' | 'suggestedParams' | 'rekeyTo'>>): txnBuilder.Transaction; -/** makeAssetFreezeTxnWithSuggestedParams will allow the asset's freeze manager to freeze or un-freeze an account, - * blocking or allowing asset transfers to and from the targeted account. - * - * @param sender - string representation of Algorand address of sender - * @param note - uint8array of arbitrary data for sender to store - * @param assetIndex - int asset index uniquely specifying the asset - * @param freezeTarget - string representation of Algorand address being frozen or unfrozen - * @param assetFrozen - true if freezeTarget should be frozen, false if freezeTarget should be allowed to transact - * @param suggestedParams - a dict holding common-to-all-txns args: - * fee - integer fee per byte, in microAlgos. for a flat fee, set flatFee to true - * flatFee - bool optionally set this to true to specify fee as microalgos-per-txn - * If true, txn fee may fall below the ALGORAND_MIN_TX_FEE - * firstValid - integer first protocol round on which this txn is valid - * lastValid - integer last protocol round on which this txn is valid - * genesisHash - string specifies hash genesis block of network in use - * genesisID - string specifies genesis ID of network in use - * @param rekeyTo - rekeyTo address, optional - */ -export declare function makeAssetFreezeTxnWithSuggestedParams(sender: AssetFreezeTxn['sender'], note: AssetFreezeTxn['note'], assetIndex: AssetFreezeTxn['assetIndex'], freezeTarget: AssetFreezeTxn['freezeAccount'], assetFrozen: AssetFreezeTxn['assetFrozen'], suggestedParams: MustHaveSuggestedParams['suggestedParams'], rekeyTo?: AssetFreezeTxn['rekeyTo']): txnBuilder.Transaction; -export declare function makeAssetFreezeTxnWithSuggestedParamsFromObject(o: Expand, { - freezeAccount: 'freezeTarget'; - rekeyTo: 'rekeyTo'; -}>, 'sender' | 'note' | 'assetIndex' | 'freezeTarget' | 'assetFrozen' | 'suggestedParams' | 'rekeyTo'>>): txnBuilder.Transaction; -/** makeAssetTransferTxnWithSuggestedParams allows for the creation of an asset transfer transaction. - * Special case: to begin accepting assets, set amount=0 and sender=receiver. - * - * @param sender - string representation of Algorand address of sender - * @param receiver - string representation of Algorand address of asset recipient - * @param closeRemainderTo - optional - string representation of Algorand address - if provided, - * send all remaining assets after transfer to the "closeRemainderTo" address and close "sender"'s asset holdings - * @param assetSender - optional - string representation of Algorand address - if provided, - * and if "sender" is the asset's revocation manager, then deduct from "assetSender" rather than "sender" - * @param amount - integer amount of assets to send - * @param note - uint8array of arbitrary data for sender to store - * @param assetIndex - int asset index uniquely specifying the asset - * @param suggestedParams - a dict holding common-to-all-txns args: - * fee - integer fee per byte, in microAlgos. for a flat fee, set flatFee to true - * flatFee - bool optionally set this to true to specify fee as microalgos-per-txn - * If true, txn fee may fall below the ALGORAND_MIN_TX_FEE - * * flatFee - bool optionally set this to true to specify fee as microalgos-per-txn - * If true, txn fee may fall below the ALGORAND_MIN_TX_FEE - * firstValid - integer first protocol round on which this txn is valid - * lastValid - integer last protocol round on which this txn is valid - * genesisHash - string specifies hash genesis block of network in use - * genesisID - string specifies genesis ID of network in use - * @param rekeyTo - rekeyTo address, optional - */ -export declare function makeAssetTransferTxnWithSuggestedParams(sender: AssetTransferTxn['sender'], receiver: AssetTransferTxn['receiver'], closeRemainderTo: AssetTransferTxn['closeRemainderTo'], assetSender: AssetTransferTxn['assetSender'], amount: AssetTransferTxn['amount'], note: AssetTransferTxn['note'], assetIndex: AssetTransferTxn['assetIndex'], suggestedParams: MustHaveSuggestedParams['suggestedParams'], rekeyTo?: AssetTransferTxn['rekeyTo']): txnBuilder.Transaction; -export declare function makeAssetTransferTxnWithSuggestedParamsFromObject(o: Expand, { - assetSender: 'assetSender'; - rekeyTo: 'rekeyTo'; -}>, 'sender' | 'receiver' | 'closeRemainderTo' | 'assetSender' | 'amount' | 'note' | 'assetIndex' | 'suggestedParams' | 'rekeyTo'>>): txnBuilder.Transaction; -/** - * Make a transaction that will create an application. - * @param sender - address of sender - * @param suggestedParams - a dict holding common-to-all-txns args: - * fee - integer fee per byte, in microAlgos. for a flat fee, set flatFee to true - * flatFee - bool optionally set this to true to specify fee as microalgos-per-txn - * If true, txn fee may fall below the ALGORAND_MIN_TX_FEE - * firstValid - integer first protocol round on which this txn is valid - * lastValid - integer last protocol round on which this txn is valid - * genesisHash - string specifies hash genesis block of network in use - * genesisID - string specifies genesis ID of network in use - * @param onComplete - algosdk.OnApplicationComplete, what application should do once the program is done being run - * @param approvalProgram - Uint8Array, the compiled TEAL that approves a transaction - * @param clearProgram - Uint8Array, the compiled TEAL that runs when clearing state - * @param numLocalInts - restricts number of ints in per-user local state - * @param numLocalByteSlices - restricts number of byte slices in per-user local state - * @param numGlobalInts - restricts number of ints in global state - * @param numGlobalByteSlices - restricts number of byte slices in global state - * @param appArgs - Array of Uint8Array, any additional arguments to the application - * @param accounts - Array of Address strings, any additional accounts to supply to the application - * @param foreignApps - Array of int, any other apps used by the application, identified by index - * @param foreignAssets - Array of int, any assets used by the application, identified by index - * @param note - Arbitrary data for sender to store - * @param lease - Lease a transaction - * @param rekeyTo - String representation of the Algorand address that will be used to authorize all future transactions - * @param extraPages - integer extra pages of memory to rent on creation of application - * @param boxes - Array of BoxReference, app ID and name of box to be accessed - */ -export declare function makeApplicationCreateTxn(sender: AppCreateTxn['sender'], suggestedParams: MustHaveSuggestedParams['suggestedParams'], onComplete: AppCreateTxn['appOnComplete'], approvalProgram: AppCreateTxn['appApprovalProgram'], clearProgram: AppCreateTxn['appClearProgram'], numLocalInts: AppCreateTxn['appLocalInts'], numLocalByteSlices: AppCreateTxn['appLocalByteSlices'], numGlobalInts: AppCreateTxn['appGlobalInts'], numGlobalByteSlices: AppCreateTxn['appGlobalByteSlices'], appArgs?: AppCreateTxn['appArgs'], accounts?: AppCreateTxn['appAccounts'], foreignApps?: AppCreateTxn['appForeignApps'], foreignAssets?: AppCreateTxn['appForeignAssets'], note?: AppCreateTxn['note'], lease?: AppCreateTxn['lease'], rekeyTo?: AppCreateTxn['rekeyTo'], extraPages?: AppCreateTxn['extraPages'], boxes?: AppCreateTxn['boxes']): txnBuilder.Transaction; -export declare function makeApplicationCreateTxnFromObject(o: Expand, { - appOnComplete: 'onComplete'; - appApprovalProgram: 'approvalProgram'; - appClearProgram: 'clearProgram'; - appLocalInts: 'numLocalInts'; - appLocalByteSlices: 'numLocalByteSlices'; - appGlobalInts: 'numGlobalInts'; - appGlobalByteSlices: 'numGlobalByteSlices'; - appAccounts: 'accounts'; - appForeignApps: 'foreignApps'; - appForeignAssets: 'foreignAssets'; - rekeyTo: 'rekeyTo'; -}>, 'sender' | 'suggestedParams' | 'onComplete' | 'approvalProgram' | 'clearProgram' | 'numLocalInts' | 'numLocalByteSlices' | 'numGlobalInts' | 'numGlobalByteSlices' | 'appArgs' | 'accounts' | 'foreignApps' | 'foreignAssets' | 'boxes' | 'note' | 'lease' | 'rekeyTo' | 'extraPages'>>): txnBuilder.Transaction; -/** - * Make a transaction that changes an application's approval and clear programs - * @param sender - address of sender - * @param suggestedParams - a dict holding common-to-all-txns args: - * fee - integer fee per byte, in microAlgos. for a flat fee, set flatFee to true - * flatFee - bool optionally set this to true to specify fee as microalgos-per-txn - * If true, txn fee may fall below the ALGORAND_MIN_TX_FEE - * firstValid - integer first protocol round on which this txn is valid - * lastValid - integer last protocol round on which this txn is valid - * genesisHash - string specifies hash genesis block of network in use - * genesisID - string specifies genesis ID of network in use - * @param appIndex - the ID of the app to be updated - * @param approvalProgram - Uint8Array, the compiled TEAL that approves a transaction - * @param clearProgram - Uint8Array, the compiled TEAL that runs when clearing state - * @param appArgs - Array of Uint8Array, any additional arguments to the application - * @param accounts - Array of Address strings, any additional accounts to supply to the application - * @param foreignApps - Array of int, any other apps used by the application, identified by index - * @param foreignAssets - Array of int, any assets used by the application, identified by index - * @param note - Arbitrary data for sender to store - * @param lease - Lease a transaction - * @param rekeyTo - String representation of the Algorand address that will be used to authorize all future transactions - * @param boxes - Array of BoxReference, app ID and name of box to be accessed - */ -export declare function makeApplicationUpdateTxn(sender: AppUpdateTxn['sender'], suggestedParams: MustHaveSuggestedParams['suggestedParams'], appIndex: AppUpdateTxn['appIndex'], approvalProgram: AppUpdateTxn['appApprovalProgram'], clearProgram: AppUpdateTxn['appClearProgram'], appArgs?: AppUpdateTxn['appArgs'], accounts?: AppUpdateTxn['appAccounts'], foreignApps?: AppUpdateTxn['appForeignApps'], foreignAssets?: AppUpdateTxn['appForeignAssets'], note?: AppUpdateTxn['note'], lease?: AppUpdateTxn['lease'], rekeyTo?: AppUpdateTxn['rekeyTo'], boxes?: AppUpdateTxn['boxes']): txnBuilder.Transaction; -export declare function makeApplicationUpdateTxnFromObject(o: Expand, { - appApprovalProgram: 'approvalProgram'; - appClearProgram: 'clearProgram'; - appAccounts: 'accounts'; - appForeignApps: 'foreignApps'; - appForeignAssets: 'foreignAssets'; - rekeyTo: 'rekeyTo'; -}>, 'sender' | 'suggestedParams' | 'appIndex' | 'approvalProgram' | 'clearProgram' | 'appArgs' | 'accounts' | 'foreignApps' | 'foreignAssets' | 'boxes' | 'note' | 'lease' | 'rekeyTo'>>): txnBuilder.Transaction; -/** - * Make a transaction that deletes an application - * @param sender - address of sender - * @param suggestedParams - a dict holding common-to-all-txns args: - * fee - integer fee per byte, in microAlgos. for a flat fee, set flatFee to true - * flatFee - bool optionally set this to true to specify fee as microalgos-per-txn - * If true, txn fee may fall below the ALGORAND_MIN_TX_FEE - * firstValid - integer first protocol round on which this txn is valid - * lastValid - integer last protocol round on which this txn is valid - * genesisHash - string specifies hash genesis block of network in use - * genesisID - string specifies genesis ID of network in use - * @param appIndex - the ID of the app to be deleted - * @param appArgs - Array of Uint8Array, any additional arguments to the application - * @param accounts - Array of Address strings, any additional accounts to supply to the application - * @param foreignApps - Array of int, any other apps used by the application, identified by index - * @param foreignAssets - Array of int, any assets used by the application, identified by index - * @param note - Arbitrary data for sender to store - * @param lease - Lease a transaction - * @param rekeyTo - String representation of the Algorand address that will be used to authorize all future transactions - * @param boxes - Array of BoxReference, app ID and name of box to be accessed - */ -export declare function makeApplicationDeleteTxn(sender: AppDeleteTxn['sender'], suggestedParams: MustHaveSuggestedParams['suggestedParams'], appIndex: AppDeleteTxn['appIndex'], appArgs?: AppDeleteTxn['appArgs'], accounts?: AppDeleteTxn['appAccounts'], foreignApps?: AppDeleteTxn['appForeignApps'], foreignAssets?: AppDeleteTxn['appForeignAssets'], note?: AppDeleteTxn['note'], lease?: AppDeleteTxn['lease'], rekeyTo?: AppDeleteTxn['rekeyTo'], boxes?: AppDeleteTxn['boxes']): txnBuilder.Transaction; -export declare function makeApplicationDeleteTxnFromObject(o: Expand, { - appAccounts: 'accounts'; - appForeignApps: 'foreignApps'; - appForeignAssets: 'foreignAssets'; - rekeyTo: 'rekeyTo'; -}>, 'sender' | 'suggestedParams' | 'appIndex' | 'appArgs' | 'accounts' | 'foreignApps' | 'foreignAssets' | 'boxes' | 'note' | 'lease' | 'rekeyTo'>>): txnBuilder.Transaction; -/** - * Make a transaction that opts in to use an application - * @param sender - address of sender - * @param suggestedParams - a dict holding common-to-all-txns args: - * fee - integer fee per byte, in microAlgos. for a flat fee, set flatFee to true - * flatFee - bool optionally set this to true to specify fee as microalgos-per-txn - * If true, txn fee may fall below the ALGORAND_MIN_TX_FEE - * firstValid - integer first protocol round on which this txn is valid - * lastValid - integer last protocol round on which this txn is valid - * genesisHash - string specifies hash genesis block of network in use - * genesisID - string specifies genesis ID of network in use - * @param appIndex - the ID of the app to join - * @param appArgs - Array of Uint8Array, any additional arguments to the application - * @param accounts - Array of Address strings, any additional accounts to supply to the application - * @param foreignApps - Array of int, any other apps used by the application, identified by index - * @param foreignAssets - Array of int, any assets used by the application, identified by index - * @param note - Arbitrary data for sender to store - * @param lease - Lease a transaction - * @param rekeyTo - String representation of the Algorand address that will be used to authorize all future transactions - * @param boxes - Array of BoxReference, app ID and name of box to be accessed - */ -export declare function makeApplicationOptInTxn(sender: AppOptInTxn['sender'], suggestedParams: MustHaveSuggestedParams['suggestedParams'], appIndex: AppOptInTxn['appIndex'], appArgs?: AppOptInTxn['appArgs'], accounts?: AppOptInTxn['appAccounts'], foreignApps?: AppOptInTxn['appForeignApps'], foreignAssets?: AppOptInTxn['appForeignAssets'], note?: AppOptInTxn['note'], lease?: AppOptInTxn['lease'], rekeyTo?: AppOptInTxn['rekeyTo'], boxes?: AppOptInTxn['boxes']): txnBuilder.Transaction; -export declare function makeApplicationOptInTxnFromObject(o: Expand, { - appAccounts: 'accounts'; - appForeignApps: 'foreignApps'; - appForeignAssets: 'foreignAssets'; - rekeyTo: 'rekeyTo'; -}>, 'sender' | 'suggestedParams' | 'appIndex' | 'appArgs' | 'accounts' | 'foreignApps' | 'foreignAssets' | 'boxes' | 'note' | 'lease' | 'rekeyTo'>>): txnBuilder.Transaction; -/** - * Make a transaction that closes out a user's state in an application - * @param sender - address of sender - * @param suggestedParams - a dict holding common-to-all-txns args: - * fee - integer fee per byte, in microAlgos. for a flat fee, set flatFee to true - * flatFee - bool optionally set this to true to specify fee as microalgos-per-txn - * If true, txn fee may fall below the ALGORAND_MIN_TX_FEE - * firstValid - integer first protocol round on which this txn is valid - * lastValid - integer last protocol round on which this txn is valid - * genesisHash - string specifies hash genesis block of network in use - * genesisID - string specifies genesis ID of network in use - * @param appIndex - the ID of the app to use - * @param appArgs - Array of Uint8Array, any additional arguments to the application - * @param accounts - Array of Address strings, any additional accounts to supply to the application - * @param foreignApps - Array of int, any other apps used by the application, identified by index - * @param foreignAssets - Array of int, any assets used by the application, identified by index - * @param note - Arbitrary data for sender to store - * @param lease - Lease a transaction - * @param rekeyTo - String representation of the Algorand address that will be used to authorize all future transactions - * @param boxes - Array of BoxReference, app ID and name of box to be accessed - */ -export declare function makeApplicationCloseOutTxn(sender: AppCloseOutTxn['sender'], suggestedParams: MustHaveSuggestedParams['suggestedParams'], appIndex: AppCloseOutTxn['appIndex'], appArgs?: AppCloseOutTxn['appArgs'], accounts?: AppCloseOutTxn['appAccounts'], foreignApps?: AppCloseOutTxn['appForeignApps'], foreignAssets?: AppCloseOutTxn['appForeignAssets'], note?: AppCloseOutTxn['note'], lease?: AppCloseOutTxn['lease'], rekeyTo?: AppCloseOutTxn['rekeyTo'], boxes?: AppCloseOutTxn['boxes']): txnBuilder.Transaction; -export declare function makeApplicationCloseOutTxnFromObject(o: Expand, { - appAccounts: 'accounts'; - appForeignApps: 'foreignApps'; - appForeignAssets: 'foreignAssets'; - rekeyTo: 'rekeyTo'; -}>, 'sender' | 'suggestedParams' | 'appIndex' | 'appArgs' | 'accounts' | 'foreignApps' | 'foreignAssets' | 'boxes' | 'note' | 'lease' | 'rekeyTo'>>): txnBuilder.Transaction; -/** - * Make a transaction that clears a user's state in an application - * @param sender - address of sender - * @param suggestedParams - a dict holding common-to-all-txns args: - * fee - integer fee per byte, in microAlgos. for a flat fee, set flatFee to true - * flatFee - bool optionally set this to true to specify fee as microalgos-per-txn - * If true, txn fee may fall below the ALGORAND_MIN_TX_FEE - * firstValid - integer first protocol round on which this txn is valid - * lastValid - integer last protocol round on which this txn is valid - * genesisHash - string specifies hash genesis block of network in use - * genesisID - string specifies genesis ID of network in use - * @param appIndex - the ID of the app to use - * @param appArgs - Array of Uint8Array, any additional arguments to the application - * @param accounts - Array of Address strings, any additional accounts to supply to the application - * @param foreignApps - Array of int, any other apps used by the application, identified by index - * @param foreignAssets - Array of int, any assets used by the application, identified by index - * @param note - Arbitrary data for sender to store - * @param lease - Lease a transaction - * @param rekeyTo - String representation of the Algorand address that will be used to authorize all future transactions - * @param boxes - Array of BoxReference, app ID and name of box to be accessed - */ -export declare function makeApplicationClearStateTxn(sender: AppClearStateTxn['sender'], suggestedParams: MustHaveSuggestedParams['suggestedParams'], appIndex: AppClearStateTxn['appIndex'], appArgs?: AppClearStateTxn['appArgs'], accounts?: AppClearStateTxn['appAccounts'], foreignApps?: AppClearStateTxn['appForeignApps'], foreignAssets?: AppClearStateTxn['appForeignAssets'], note?: AppClearStateTxn['note'], lease?: AppClearStateTxn['lease'], rekeyTo?: AppClearStateTxn['rekeyTo'], boxes?: AppClearStateTxn['boxes']): txnBuilder.Transaction; -export declare function makeApplicationClearStateTxnFromObject(o: Expand, { - appAccounts: 'accounts'; - appForeignApps: 'foreignApps'; - appForeignAssets: 'foreignAssets'; - rekeyTo: 'rekeyTo'; -}>, 'sender' | 'suggestedParams' | 'appIndex' | 'appArgs' | 'accounts' | 'foreignApps' | 'foreignAssets' | 'boxes' | 'note' | 'lease' | 'rekeyTo'>>): txnBuilder.Transaction; -/** - * Make a transaction that just calls an application, doing nothing on completion - * @param sender - address of sender - * @param suggestedParams - a dict holding common-to-all-txns args: - * fee - integer fee per byte, in microAlgos. for a flat fee, set flatFee to true - * flatFee - bool optionally set this to true to specify fee as microalgos-per-txn - * If true, txn fee may fall below the ALGORAND_MIN_TX_FEE - * firstValid - integer first protocol round on which this txn is valid - * lastValid - integer last protocol round on which this txn is valid - * genesisHash - string specifies hash genesis block of network in use - * genesisID - string specifies genesis ID of network in use - * @param appIndex - the ID of the app to use - * @param appArgs - Array of Uint8Array, any additional arguments to the application - * @param accounts - Array of Address strings, any additional accounts to supply to the application - * @param foreignApps - Array of int, any other apps used by the application, identified by index - * @param foreignAssets - Array of int, any assets used by the application, identified by index - * @param note - Arbitrary data for sender to store - * @param lease - Lease a transaction - * @param rekeyTo - String representation of the Algorand address that will be used to authorize all future transactions - * @param boxes - Array of BoxReference, app ID and name of box to be accessed - */ -export declare function makeApplicationNoOpTxn(sender: AppNoOpTxn['sender'], suggestedParams: MustHaveSuggestedParams['suggestedParams'], appIndex: AppNoOpTxn['appIndex'], appArgs?: AppNoOpTxn['appArgs'], accounts?: AppNoOpTxn['appAccounts'], foreignApps?: AppNoOpTxn['appForeignApps'], foreignAssets?: AppNoOpTxn['appForeignAssets'], note?: AppNoOpTxn['note'], lease?: AppNoOpTxn['lease'], rekeyTo?: AppNoOpTxn['rekeyTo'], boxes?: AppNoOpTxn['boxes']): txnBuilder.Transaction; -export declare function makeApplicationNoOpTxnFromObject(o: Expand, { - appAccounts: 'accounts'; - appForeignApps: 'foreignApps'; - appForeignAssets: 'foreignAssets'; - rekeyTo: 'rekeyTo'; -}>, 'sender' | 'suggestedParams' | 'appIndex' | 'appArgs' | 'accounts' | 'foreignApps' | 'foreignAssets' | 'boxes' | 'note' | 'lease' | 'rekeyTo'>>): txnBuilder.Transaction; -export { OnApplicationComplete } from './types/transactions/base'; -/** - * Generic function for creating any application call transaction. - */ -export declare function makeApplicationCallTxnFromObject(options: Expand, { - appOnComplete: 'onComplete'; - appAccounts: 'accounts'; - appForeignApps: 'foreignApps'; - appForeignAssets: 'foreignAssets'; - rekeyTo: 'rekeyTo'; -}>, 'sender' | 'suggestedParams' | 'appIndex' | 'onComplete' | 'appArgs' | 'accounts' | 'foreignApps' | 'foreignAssets' | 'boxes' | 'note' | 'lease' | 'rekeyTo' | 'extraPages'> & Partial, { - appApprovalProgram: 'approvalProgram'; - appClearProgram: 'clearProgram'; - appLocalInts: 'numLocalInts'; - appLocalByteSlices: 'numLocalByteSlices'; - appGlobalInts: 'numGlobalInts'; - appGlobalByteSlices: 'numGlobalByteSlices'; -}>, 'approvalProgram' | 'clearProgram' | 'numLocalInts' | 'numLocalByteSlices' | 'numGlobalInts' | 'numGlobalByteSlices'>>>): txnBuilder.Transaction; diff --git a/algosdk/makeTxn.js b/algosdk/makeTxn.js deleted file mode 100644 index 89803c7..0000000 --- a/algosdk/makeTxn.js +++ /dev/null @@ -1,669 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.makeApplicationCallTxnFromObject = exports.OnApplicationComplete = exports.makeApplicationNoOpTxnFromObject = exports.makeApplicationNoOpTxn = exports.makeApplicationClearStateTxnFromObject = exports.makeApplicationClearStateTxn = exports.makeApplicationCloseOutTxnFromObject = exports.makeApplicationCloseOutTxn = exports.makeApplicationOptInTxnFromObject = exports.makeApplicationOptInTxn = exports.makeApplicationDeleteTxnFromObject = exports.makeApplicationDeleteTxn = exports.makeApplicationUpdateTxnFromObject = exports.makeApplicationUpdateTxn = exports.makeApplicationCreateTxnFromObject = exports.makeApplicationCreateTxn = exports.makeAssetTransferTxnWithSuggestedParamsFromObject = exports.makeAssetTransferTxnWithSuggestedParams = exports.makeAssetFreezeTxnWithSuggestedParamsFromObject = exports.makeAssetFreezeTxnWithSuggestedParams = exports.makeAssetDestroyTxnWithSuggestedParamsFromObject = exports.makeAssetDestroyTxnWithSuggestedParams = exports.makeAssetConfigTxnWithSuggestedParamsFromObject = exports.makeAssetConfigTxnWithSuggestedParams = exports.makeAssetCreateTxnWithSuggestedParamsFromObject = exports.makeAssetCreateTxnWithSuggestedParams = exports.makeKeyRegistrationTxnWithSuggestedParamsFromObject = exports.makeKeyRegistrationTxnWithSuggestedParams = exports.makePaymentTxnWithSuggestedParamsFromObject = exports.makePaymentTxnWithSuggestedParams = void 0; -const txnBuilder = __importStar(require("./transaction")); -const base_1 = require("./types/transactions/base"); -const transactions_1 = require("./types/transactions"); -/** - * makePaymentTxnWithSuggestedParams takes payment arguments and returns a Transaction object - * @param sender - string representation of Algorand address of sender - * @param receiver - string representation of Algorand address of recipient - * @param amount - integer amount to send, in microAlgos - * @param closeRemainderTo - optionally close out remaining account balance to this account, represented as string rep of Algorand address - * @param note - uint8array of arbitrary data for sender to store - * @param suggestedParams - a dict holding common-to-all-txns args: - * fee - integer fee per byte, in microAlgos. for a flat fee, set flatFee to true - * flatFee - bool optionally set this to true to specify fee as microalgos-per-txn - * If true, txn fee may fall below the ALGORAND_MIN_TX_FEE - * firstValid - integer first protocol round on which this txn is valid - * lastValid - integer last protocol round on which this txn is valid - * genesisHash - string specifies hash genesis block of network in use - * genesisID - string specifies genesis ID of network in use - * @param rekeyTo - rekeyTo address, optional - */ -function makePaymentTxnWithSuggestedParams(sender, receiver, amount, closeRemainderTo, note, suggestedParams, rekeyTo) { - const o = { - sender, - receiver, - amount, - closeRemainderTo, - note, - suggestedParams, - type: transactions_1.TransactionType.pay, - rekeyTo, - }; - return new txnBuilder.Transaction(o); -} -exports.makePaymentTxnWithSuggestedParams = makePaymentTxnWithSuggestedParams; -// helper for above makePaymentTxnWithSuggestedParams, instead accepting an arguments object -function makePaymentTxnWithSuggestedParamsFromObject(o) { - return makePaymentTxnWithSuggestedParams(o.sender, o.receiver, o.amount, o.closeRemainderTo, o.note, o.suggestedParams, o.rekeyTo); -} -exports.makePaymentTxnWithSuggestedParamsFromObject = makePaymentTxnWithSuggestedParamsFromObject; -function makeKeyRegistrationTxnWithSuggestedParams(sender, note, voteKey, selectionKey, voteFirst, voteLast, voteKeyDilution, suggestedParams, rekeyTo, nonParticipation = false, stateProofKey = undefined) { - const o = { - sender, - note, - voteKey, - selectionKey, - voteFirst, - voteLast, - voteKeyDilution, - suggestedParams, - type: transactions_1.TransactionType.keyreg, - rekeyTo, - nonParticipation, - stateProofKey, - }; - return new txnBuilder.Transaction(o); -} -exports.makeKeyRegistrationTxnWithSuggestedParams = makeKeyRegistrationTxnWithSuggestedParams; -function makeKeyRegistrationTxnWithSuggestedParamsFromObject(o) { - return makeKeyRegistrationTxnWithSuggestedParams(o.sender, o.note, o.voteKey, o.selectionKey, o.voteFirst, o.voteLast, o.voteKeyDilution, o.suggestedParams, o.rekeyTo, o.nonParticipation, o.stateProofKey); -} -exports.makeKeyRegistrationTxnWithSuggestedParamsFromObject = makeKeyRegistrationTxnWithSuggestedParamsFromObject; -/** makeAssetCreateTxnWithSuggestedParams takes asset creation arguments and returns a Transaction object - * for creating that asset - * - * @param sender - string representation of Algorand address of sender - * @param note - uint8array of arbitrary data for sender to store - * @param total - integer total supply of the asset - * @param decimals - integer number of decimals for asset unit calculation - * @param defaultFrozen - boolean whether asset accounts should default to being frozen - * @param manager - string representation of Algorand address in charge of reserve, freeze, clawback, destruction, etc - * @param reserve - string representation of Algorand address representing asset reserve - * @param freeze - string representation of Algorand address with power to freeze/unfreeze asset holdings - * @param clawback - string representation of Algorand address with power to revoke asset holdings - * @param unitName - string units name for this asset - * @param assetName - string name for this asset - * @param assetURL - string URL relating to this asset - * @param assetMetadataHash - Uint8Array or UTF-8 string representation of a hash commitment with respect to the asset. Must be exactly 32 bytes long. - * @param suggestedParams - a dict holding common-to-all-txns args: - * fee - integer fee per byte, in microAlgos. for a flat fee, set flatFee to true - * flatFee - bool optionally set this to true to specify fee as microalgos-per-txn - * If true, txn fee may fall below the ALGORAND_MIN_TX_FEE - * firstValid - integer first protocol round on which this txn is valid - * lastValid - integer last protocol round on which this txn is valid - * genesisHash - string specifies hash genesis block of network in use - * genesisID - string specifies genesis ID of network in use - * @param rekeyTo - rekeyTo address, optional - */ -function makeAssetCreateTxnWithSuggestedParams(sender, note, total, decimals, defaultFrozen, manager, reserve, freeze, clawback, unitName, assetName, assetURL, assetMetadataHash, suggestedParams, rekeyTo) { - const o = { - sender, - note, - suggestedParams, - assetTotal: total, - assetDecimals: decimals, - assetDefaultFrozen: defaultFrozen, - assetUnitName: unitName, - assetName, - assetURL, - assetMetadataHash, - assetManager: manager, - assetReserve: reserve, - assetFreeze: freeze, - assetClawback: clawback, - type: transactions_1.TransactionType.acfg, - rekeyTo, - }; - return new txnBuilder.Transaction(o); -} -exports.makeAssetCreateTxnWithSuggestedParams = makeAssetCreateTxnWithSuggestedParams; -// helper for above makeAssetCreateTxnWithSuggestedParams, instead accepting an arguments object -function makeAssetCreateTxnWithSuggestedParamsFromObject(o) { - return makeAssetCreateTxnWithSuggestedParams(o.sender, o.note, o.total, o.decimals, o.defaultFrozen, o.manager, o.reserve, o.freeze, o.clawback, o.unitName, o.assetName, o.assetURL, o.assetMetadataHash, o.suggestedParams, o.rekeyTo); -} -exports.makeAssetCreateTxnWithSuggestedParamsFromObject = makeAssetCreateTxnWithSuggestedParamsFromObject; -/** makeAssetConfigTxnWithSuggestedParams can be issued by the asset manager to change the manager, reserve, freeze, or clawback - * you must respecify existing addresses to keep them the same; leaving a field blank is the same as turning - * that feature off for this asset - * - * @param sender - string representation of Algorand address of sender - * @param note - uint8array of arbitrary data for sender to store - * @param assetIndex - int asset index uniquely specifying the asset - * @param manager - string representation of new asset manager Algorand address - * @param reserve - string representation of new reserve Algorand address - * @param freeze - string representation of new freeze manager Algorand address - * @param clawback - string representation of new revocation manager Algorand address - * @param suggestedParams - a dict holding common-to-all-txns args: - * fee - integer fee per byte, in microAlgos. for a flat fee, set flatFee to true - * flatFee - bool optionally set this to true to specify fee as microalgos-per-txn - * If true, txn fee may fall below the ALGORAND_MIN_TX_FEE - * firstValid - integer first protocol round on which this txn is valid - * lastValid - integer last protocol round on which this txn is valid - * genesisHash - string specifies hash genesis block of network in use - * genesisID - string specifies genesis ID of network in use - * @param rekeyTo - rekeyTo address, optional - * @param strictEmptyAddressChecking - boolean - throw an error if any of manager, reserve, freeze, or clawback are undefined. optional, defaults to true. - */ -function makeAssetConfigTxnWithSuggestedParams(sender, note, assetIndex, manager, reserve, freeze, clawback, suggestedParams, rekeyTo, strictEmptyAddressChecking = true) { - if (strictEmptyAddressChecking && - (manager === undefined || - reserve === undefined || - freeze === undefined || - clawback === undefined)) { - throw Error('strict empty address checking was turned on, but at least one empty address was provided'); - } - const o = { - sender, - suggestedParams, - assetIndex, - assetManager: manager, - assetReserve: reserve, - assetFreeze: freeze, - assetClawback: clawback, - type: transactions_1.TransactionType.acfg, - note, - rekeyTo, - }; - return new txnBuilder.Transaction(o); -} -exports.makeAssetConfigTxnWithSuggestedParams = makeAssetConfigTxnWithSuggestedParams; -// helper for above makeAssetConfigTxnWithSuggestedParams, instead accepting an arguments object -function makeAssetConfigTxnWithSuggestedParamsFromObject(o) { - return makeAssetConfigTxnWithSuggestedParams(o.sender, o.note, o.assetIndex, o.manager, o.reserve, o.freeze, o.clawback, o.suggestedParams, o.rekeyTo, o.strictEmptyAddressChecking); -} -exports.makeAssetConfigTxnWithSuggestedParamsFromObject = makeAssetConfigTxnWithSuggestedParamsFromObject; -/** makeAssetDestroyTxnWithSuggestedParams will allow the asset's manager to remove this asset from the ledger, so long - * as all outstanding assets are held by the creator. - * - * @param sender - string representation of Algorand address of sender - * @param note - uint8array of arbitrary data for sender to store - * @param assetIndex - int asset index uniquely specifying the asset - * @param suggestedParams - a dict holding common-to-all-txns args: - * fee - integer fee per byte, in microAlgos. for a flat fee, set flatFee to true - * flatFee - bool optionally set this to true to specify fee as microalgos-per-txn - * If true, txn fee may fall below the ALGORAND_MIN_TX_FEE - * firstValid - integer first protocol round on which this txn is valid - * lastValid - integer last protocol round on which this txn is valid - * genesisHash - string specifies hash genesis block of network in use - * genesisID - string specifies genesis ID of network in use - * @param rekeyTo - rekeyTo address, optional - */ -function makeAssetDestroyTxnWithSuggestedParams(sender, note, assetIndex, suggestedParams, rekeyTo) { - const o = { - sender, - suggestedParams, - assetIndex, - type: transactions_1.TransactionType.acfg, - note, - rekeyTo, - }; - return new txnBuilder.Transaction(o); -} -exports.makeAssetDestroyTxnWithSuggestedParams = makeAssetDestroyTxnWithSuggestedParams; -// helper for above makeAssetDestroyTxnWithSuggestedParams, instead accepting an arguments object -function makeAssetDestroyTxnWithSuggestedParamsFromObject(o) { - return makeAssetDestroyTxnWithSuggestedParams(o.sender, o.note, o.assetIndex, o.suggestedParams, o.rekeyTo); -} -exports.makeAssetDestroyTxnWithSuggestedParamsFromObject = makeAssetDestroyTxnWithSuggestedParamsFromObject; -/** makeAssetFreezeTxnWithSuggestedParams will allow the asset's freeze manager to freeze or un-freeze an account, - * blocking or allowing asset transfers to and from the targeted account. - * - * @param sender - string representation of Algorand address of sender - * @param note - uint8array of arbitrary data for sender to store - * @param assetIndex - int asset index uniquely specifying the asset - * @param freezeTarget - string representation of Algorand address being frozen or unfrozen - * @param assetFrozen - true if freezeTarget should be frozen, false if freezeTarget should be allowed to transact - * @param suggestedParams - a dict holding common-to-all-txns args: - * fee - integer fee per byte, in microAlgos. for a flat fee, set flatFee to true - * flatFee - bool optionally set this to true to specify fee as microalgos-per-txn - * If true, txn fee may fall below the ALGORAND_MIN_TX_FEE - * firstValid - integer first protocol round on which this txn is valid - * lastValid - integer last protocol round on which this txn is valid - * genesisHash - string specifies hash genesis block of network in use - * genesisID - string specifies genesis ID of network in use - * @param rekeyTo - rekeyTo address, optional - */ -function makeAssetFreezeTxnWithSuggestedParams(sender, note, assetIndex, freezeTarget, assetFrozen, suggestedParams, rekeyTo) { - const o = { - sender, - type: transactions_1.TransactionType.afrz, - freezeAccount: freezeTarget, - assetIndex, - assetFrozen, - note, - suggestedParams, - rekeyTo, - }; - return new txnBuilder.Transaction(o); -} -exports.makeAssetFreezeTxnWithSuggestedParams = makeAssetFreezeTxnWithSuggestedParams; -// helper for above makeAssetFreezeTxnWithSuggestedParams, instead accepting an arguments object -function makeAssetFreezeTxnWithSuggestedParamsFromObject(o) { - return makeAssetFreezeTxnWithSuggestedParams(o.sender, o.note, o.assetIndex, o.freezeTarget, o.assetFrozen, o.suggestedParams, o.rekeyTo); -} -exports.makeAssetFreezeTxnWithSuggestedParamsFromObject = makeAssetFreezeTxnWithSuggestedParamsFromObject; -/** makeAssetTransferTxnWithSuggestedParams allows for the creation of an asset transfer transaction. - * Special case: to begin accepting assets, set amount=0 and sender=receiver. - * - * @param sender - string representation of Algorand address of sender - * @param receiver - string representation of Algorand address of asset recipient - * @param closeRemainderTo - optional - string representation of Algorand address - if provided, - * send all remaining assets after transfer to the "closeRemainderTo" address and close "sender"'s asset holdings - * @param assetSender - optional - string representation of Algorand address - if provided, - * and if "sender" is the asset's revocation manager, then deduct from "assetSender" rather than "sender" - * @param amount - integer amount of assets to send - * @param note - uint8array of arbitrary data for sender to store - * @param assetIndex - int asset index uniquely specifying the asset - * @param suggestedParams - a dict holding common-to-all-txns args: - * fee - integer fee per byte, in microAlgos. for a flat fee, set flatFee to true - * flatFee - bool optionally set this to true to specify fee as microalgos-per-txn - * If true, txn fee may fall below the ALGORAND_MIN_TX_FEE - * * flatFee - bool optionally set this to true to specify fee as microalgos-per-txn - * If true, txn fee may fall below the ALGORAND_MIN_TX_FEE - * firstValid - integer first protocol round on which this txn is valid - * lastValid - integer last protocol round on which this txn is valid - * genesisHash - string specifies hash genesis block of network in use - * genesisID - string specifies genesis ID of network in use - * @param rekeyTo - rekeyTo address, optional - */ -function makeAssetTransferTxnWithSuggestedParams(sender, receiver, closeRemainderTo, assetSender, amount, note, assetIndex, suggestedParams, rekeyTo) { - const o = { - type: transactions_1.TransactionType.axfer, - sender, - receiver, - amount, - suggestedParams, - assetIndex, - note, - assetSender, - closeRemainderTo, - rekeyTo, - }; - return new txnBuilder.Transaction(o); -} -exports.makeAssetTransferTxnWithSuggestedParams = makeAssetTransferTxnWithSuggestedParams; -// helper for above makeAssetTransferTxnWithSuggestedParams, instead accepting an arguments object -function makeAssetTransferTxnWithSuggestedParamsFromObject(o) { - return makeAssetTransferTxnWithSuggestedParams(o.sender, o.receiver, o.closeRemainderTo, o.assetSender, o.amount, o.note, o.assetIndex, o.suggestedParams, o.rekeyTo); -} -exports.makeAssetTransferTxnWithSuggestedParamsFromObject = makeAssetTransferTxnWithSuggestedParamsFromObject; -/** - * Make a transaction that will create an application. - * @param sender - address of sender - * @param suggestedParams - a dict holding common-to-all-txns args: - * fee - integer fee per byte, in microAlgos. for a flat fee, set flatFee to true - * flatFee - bool optionally set this to true to specify fee as microalgos-per-txn - * If true, txn fee may fall below the ALGORAND_MIN_TX_FEE - * firstValid - integer first protocol round on which this txn is valid - * lastValid - integer last protocol round on which this txn is valid - * genesisHash - string specifies hash genesis block of network in use - * genesisID - string specifies genesis ID of network in use - * @param onComplete - algosdk.OnApplicationComplete, what application should do once the program is done being run - * @param approvalProgram - Uint8Array, the compiled TEAL that approves a transaction - * @param clearProgram - Uint8Array, the compiled TEAL that runs when clearing state - * @param numLocalInts - restricts number of ints in per-user local state - * @param numLocalByteSlices - restricts number of byte slices in per-user local state - * @param numGlobalInts - restricts number of ints in global state - * @param numGlobalByteSlices - restricts number of byte slices in global state - * @param appArgs - Array of Uint8Array, any additional arguments to the application - * @param accounts - Array of Address strings, any additional accounts to supply to the application - * @param foreignApps - Array of int, any other apps used by the application, identified by index - * @param foreignAssets - Array of int, any assets used by the application, identified by index - * @param note - Arbitrary data for sender to store - * @param lease - Lease a transaction - * @param rekeyTo - String representation of the Algorand address that will be used to authorize all future transactions - * @param extraPages - integer extra pages of memory to rent on creation of application - * @param boxes - Array of BoxReference, app ID and name of box to be accessed - */ -function makeApplicationCreateTxn(sender, suggestedParams, onComplete, approvalProgram, clearProgram, numLocalInts, numLocalByteSlices, numGlobalInts, numGlobalByteSlices, appArgs, accounts, foreignApps, foreignAssets, note, lease, rekeyTo, extraPages, boxes) { - const o = { - type: transactions_1.TransactionType.appl, - sender, - suggestedParams, - appIndex: 0, - appOnComplete: onComplete, - appLocalInts: numLocalInts, - appLocalByteSlices: numLocalByteSlices, - appGlobalInts: numGlobalInts, - appGlobalByteSlices: numGlobalByteSlices, - appApprovalProgram: approvalProgram, - appClearProgram: clearProgram, - appArgs, - appAccounts: accounts, - appForeignApps: foreignApps, - appForeignAssets: foreignAssets, - boxes, - note, - lease, - rekeyTo, - extraPages, - }; - return new txnBuilder.Transaction(o); -} -exports.makeApplicationCreateTxn = makeApplicationCreateTxn; -// helper for above makeApplicationCreateTxn, instead accepting an arguments object -function makeApplicationCreateTxnFromObject(o) { - return makeApplicationCreateTxn(o.sender, o.suggestedParams, o.onComplete, o.approvalProgram, o.clearProgram, o.numLocalInts, o.numLocalByteSlices, o.numGlobalInts, o.numGlobalByteSlices, o.appArgs, o.accounts, o.foreignApps, o.foreignAssets, o.note, o.lease, o.rekeyTo, o.extraPages, o.boxes); -} -exports.makeApplicationCreateTxnFromObject = makeApplicationCreateTxnFromObject; -/** - * Make a transaction that changes an application's approval and clear programs - * @param sender - address of sender - * @param suggestedParams - a dict holding common-to-all-txns args: - * fee - integer fee per byte, in microAlgos. for a flat fee, set flatFee to true - * flatFee - bool optionally set this to true to specify fee as microalgos-per-txn - * If true, txn fee may fall below the ALGORAND_MIN_TX_FEE - * firstValid - integer first protocol round on which this txn is valid - * lastValid - integer last protocol round on which this txn is valid - * genesisHash - string specifies hash genesis block of network in use - * genesisID - string specifies genesis ID of network in use - * @param appIndex - the ID of the app to be updated - * @param approvalProgram - Uint8Array, the compiled TEAL that approves a transaction - * @param clearProgram - Uint8Array, the compiled TEAL that runs when clearing state - * @param appArgs - Array of Uint8Array, any additional arguments to the application - * @param accounts - Array of Address strings, any additional accounts to supply to the application - * @param foreignApps - Array of int, any other apps used by the application, identified by index - * @param foreignAssets - Array of int, any assets used by the application, identified by index - * @param note - Arbitrary data for sender to store - * @param lease - Lease a transaction - * @param rekeyTo - String representation of the Algorand address that will be used to authorize all future transactions - * @param boxes - Array of BoxReference, app ID and name of box to be accessed - */ -function makeApplicationUpdateTxn(sender, suggestedParams, appIndex, approvalProgram, clearProgram, appArgs, accounts, foreignApps, foreignAssets, note, lease, rekeyTo, boxes) { - const o = { - type: transactions_1.TransactionType.appl, - sender, - suggestedParams, - appIndex, - appApprovalProgram: approvalProgram, - appOnComplete: base_1.OnApplicationComplete.UpdateApplicationOC, - appClearProgram: clearProgram, - appArgs, - appAccounts: accounts, - appForeignApps: foreignApps, - appForeignAssets: foreignAssets, - boxes, - note, - lease, - rekeyTo, - }; - return new txnBuilder.Transaction(o); -} -exports.makeApplicationUpdateTxn = makeApplicationUpdateTxn; -// helper for above makeApplicationUpdateTxn, instead accepting an arguments object -function makeApplicationUpdateTxnFromObject(o) { - return makeApplicationUpdateTxn(o.sender, o.suggestedParams, o.appIndex, o.approvalProgram, o.clearProgram, o.appArgs, o.accounts, o.foreignApps, o.foreignAssets, o.note, o.lease, o.rekeyTo, o.boxes); -} -exports.makeApplicationUpdateTxnFromObject = makeApplicationUpdateTxnFromObject; -/** - * Make a transaction that deletes an application - * @param sender - address of sender - * @param suggestedParams - a dict holding common-to-all-txns args: - * fee - integer fee per byte, in microAlgos. for a flat fee, set flatFee to true - * flatFee - bool optionally set this to true to specify fee as microalgos-per-txn - * If true, txn fee may fall below the ALGORAND_MIN_TX_FEE - * firstValid - integer first protocol round on which this txn is valid - * lastValid - integer last protocol round on which this txn is valid - * genesisHash - string specifies hash genesis block of network in use - * genesisID - string specifies genesis ID of network in use - * @param appIndex - the ID of the app to be deleted - * @param appArgs - Array of Uint8Array, any additional arguments to the application - * @param accounts - Array of Address strings, any additional accounts to supply to the application - * @param foreignApps - Array of int, any other apps used by the application, identified by index - * @param foreignAssets - Array of int, any assets used by the application, identified by index - * @param note - Arbitrary data for sender to store - * @param lease - Lease a transaction - * @param rekeyTo - String representation of the Algorand address that will be used to authorize all future transactions - * @param boxes - Array of BoxReference, app ID and name of box to be accessed - */ -function makeApplicationDeleteTxn(sender, suggestedParams, appIndex, appArgs, accounts, foreignApps, foreignAssets, note, lease, rekeyTo, boxes) { - const o = { - type: transactions_1.TransactionType.appl, - sender, - suggestedParams, - appIndex, - appOnComplete: base_1.OnApplicationComplete.DeleteApplicationOC, - appArgs, - appAccounts: accounts, - appForeignApps: foreignApps, - appForeignAssets: foreignAssets, - boxes, - note, - lease, - rekeyTo, - }; - return new txnBuilder.Transaction(o); -} -exports.makeApplicationDeleteTxn = makeApplicationDeleteTxn; -// helper for above makeApplicationDeleteTxn, instead accepting an arguments object -function makeApplicationDeleteTxnFromObject(o) { - return makeApplicationDeleteTxn(o.sender, o.suggestedParams, o.appIndex, o.appArgs, o.accounts, o.foreignApps, o.foreignAssets, o.note, o.lease, o.rekeyTo, o.boxes); -} -exports.makeApplicationDeleteTxnFromObject = makeApplicationDeleteTxnFromObject; -/** - * Make a transaction that opts in to use an application - * @param sender - address of sender - * @param suggestedParams - a dict holding common-to-all-txns args: - * fee - integer fee per byte, in microAlgos. for a flat fee, set flatFee to true - * flatFee - bool optionally set this to true to specify fee as microalgos-per-txn - * If true, txn fee may fall below the ALGORAND_MIN_TX_FEE - * firstValid - integer first protocol round on which this txn is valid - * lastValid - integer last protocol round on which this txn is valid - * genesisHash - string specifies hash genesis block of network in use - * genesisID - string specifies genesis ID of network in use - * @param appIndex - the ID of the app to join - * @param appArgs - Array of Uint8Array, any additional arguments to the application - * @param accounts - Array of Address strings, any additional accounts to supply to the application - * @param foreignApps - Array of int, any other apps used by the application, identified by index - * @param foreignAssets - Array of int, any assets used by the application, identified by index - * @param note - Arbitrary data for sender to store - * @param lease - Lease a transaction - * @param rekeyTo - String representation of the Algorand address that will be used to authorize all future transactions - * @param boxes - Array of BoxReference, app ID and name of box to be accessed - */ -function makeApplicationOptInTxn(sender, suggestedParams, appIndex, appArgs, accounts, foreignApps, foreignAssets, note, lease, rekeyTo, boxes) { - const o = { - type: transactions_1.TransactionType.appl, - sender, - suggestedParams, - appIndex, - appOnComplete: base_1.OnApplicationComplete.OptInOC, - appArgs, - appAccounts: accounts, - appForeignApps: foreignApps, - appForeignAssets: foreignAssets, - boxes, - note, - lease, - rekeyTo, - }; - return new txnBuilder.Transaction(o); -} -exports.makeApplicationOptInTxn = makeApplicationOptInTxn; -// helper for above makeApplicationOptInTxn, instead accepting an argument object -function makeApplicationOptInTxnFromObject(o) { - return makeApplicationOptInTxn(o.sender, o.suggestedParams, o.appIndex, o.appArgs, o.accounts, o.foreignApps, o.foreignAssets, o.note, o.lease, o.rekeyTo, o.boxes); -} -exports.makeApplicationOptInTxnFromObject = makeApplicationOptInTxnFromObject; -/** - * Make a transaction that closes out a user's state in an application - * @param sender - address of sender - * @param suggestedParams - a dict holding common-to-all-txns args: - * fee - integer fee per byte, in microAlgos. for a flat fee, set flatFee to true - * flatFee - bool optionally set this to true to specify fee as microalgos-per-txn - * If true, txn fee may fall below the ALGORAND_MIN_TX_FEE - * firstValid - integer first protocol round on which this txn is valid - * lastValid - integer last protocol round on which this txn is valid - * genesisHash - string specifies hash genesis block of network in use - * genesisID - string specifies genesis ID of network in use - * @param appIndex - the ID of the app to use - * @param appArgs - Array of Uint8Array, any additional arguments to the application - * @param accounts - Array of Address strings, any additional accounts to supply to the application - * @param foreignApps - Array of int, any other apps used by the application, identified by index - * @param foreignAssets - Array of int, any assets used by the application, identified by index - * @param note - Arbitrary data for sender to store - * @param lease - Lease a transaction - * @param rekeyTo - String representation of the Algorand address that will be used to authorize all future transactions - * @param boxes - Array of BoxReference, app ID and name of box to be accessed - */ -function makeApplicationCloseOutTxn(sender, suggestedParams, appIndex, appArgs, accounts, foreignApps, foreignAssets, note, lease, rekeyTo, boxes) { - const o = { - type: transactions_1.TransactionType.appl, - sender, - suggestedParams, - appIndex, - appOnComplete: base_1.OnApplicationComplete.CloseOutOC, - appArgs, - appAccounts: accounts, - appForeignApps: foreignApps, - appForeignAssets: foreignAssets, - boxes, - note, - lease, - rekeyTo, - }; - return new txnBuilder.Transaction(o); -} -exports.makeApplicationCloseOutTxn = makeApplicationCloseOutTxn; -// helper for above makeApplicationCloseOutTxn, instead accepting an argument object -function makeApplicationCloseOutTxnFromObject(o) { - return makeApplicationCloseOutTxn(o.sender, o.suggestedParams, o.appIndex, o.appArgs, o.accounts, o.foreignApps, o.foreignAssets, o.note, o.lease, o.rekeyTo, o.boxes); -} -exports.makeApplicationCloseOutTxnFromObject = makeApplicationCloseOutTxnFromObject; -/** - * Make a transaction that clears a user's state in an application - * @param sender - address of sender - * @param suggestedParams - a dict holding common-to-all-txns args: - * fee - integer fee per byte, in microAlgos. for a flat fee, set flatFee to true - * flatFee - bool optionally set this to true to specify fee as microalgos-per-txn - * If true, txn fee may fall below the ALGORAND_MIN_TX_FEE - * firstValid - integer first protocol round on which this txn is valid - * lastValid - integer last protocol round on which this txn is valid - * genesisHash - string specifies hash genesis block of network in use - * genesisID - string specifies genesis ID of network in use - * @param appIndex - the ID of the app to use - * @param appArgs - Array of Uint8Array, any additional arguments to the application - * @param accounts - Array of Address strings, any additional accounts to supply to the application - * @param foreignApps - Array of int, any other apps used by the application, identified by index - * @param foreignAssets - Array of int, any assets used by the application, identified by index - * @param note - Arbitrary data for sender to store - * @param lease - Lease a transaction - * @param rekeyTo - String representation of the Algorand address that will be used to authorize all future transactions - * @param boxes - Array of BoxReference, app ID and name of box to be accessed - */ -function makeApplicationClearStateTxn(sender, suggestedParams, appIndex, appArgs, accounts, foreignApps, foreignAssets, note, lease, rekeyTo, boxes) { - const o = { - type: transactions_1.TransactionType.appl, - sender, - suggestedParams, - appIndex, - appOnComplete: base_1.OnApplicationComplete.ClearStateOC, - appArgs, - appAccounts: accounts, - appForeignApps: foreignApps, - appForeignAssets: foreignAssets, - boxes, - note, - lease, - rekeyTo, - }; - return new txnBuilder.Transaction(o); -} -exports.makeApplicationClearStateTxn = makeApplicationClearStateTxn; -// helper for above makeApplicationClearStateTxn, instead accepting an argument object -function makeApplicationClearStateTxnFromObject(o) { - return makeApplicationClearStateTxn(o.sender, o.suggestedParams, o.appIndex, o.appArgs, o.accounts, o.foreignApps, o.foreignAssets, o.note, o.lease, o.rekeyTo, o.boxes); -} -exports.makeApplicationClearStateTxnFromObject = makeApplicationClearStateTxnFromObject; -/** - * Make a transaction that just calls an application, doing nothing on completion - * @param sender - address of sender - * @param suggestedParams - a dict holding common-to-all-txns args: - * fee - integer fee per byte, in microAlgos. for a flat fee, set flatFee to true - * flatFee - bool optionally set this to true to specify fee as microalgos-per-txn - * If true, txn fee may fall below the ALGORAND_MIN_TX_FEE - * firstValid - integer first protocol round on which this txn is valid - * lastValid - integer last protocol round on which this txn is valid - * genesisHash - string specifies hash genesis block of network in use - * genesisID - string specifies genesis ID of network in use - * @param appIndex - the ID of the app to use - * @param appArgs - Array of Uint8Array, any additional arguments to the application - * @param accounts - Array of Address strings, any additional accounts to supply to the application - * @param foreignApps - Array of int, any other apps used by the application, identified by index - * @param foreignAssets - Array of int, any assets used by the application, identified by index - * @param note - Arbitrary data for sender to store - * @param lease - Lease a transaction - * @param rekeyTo - String representation of the Algorand address that will be used to authorize all future transactions - * @param boxes - Array of BoxReference, app ID and name of box to be accessed - */ -function makeApplicationNoOpTxn(sender, suggestedParams, appIndex, appArgs, accounts, foreignApps, foreignAssets, note, lease, rekeyTo, boxes) { - const o = { - type: transactions_1.TransactionType.appl, - sender, - suggestedParams, - appIndex, - appOnComplete: base_1.OnApplicationComplete.NoOpOC, - appArgs, - appAccounts: accounts, - appForeignApps: foreignApps, - appForeignAssets: foreignAssets, - boxes, - note, - lease, - rekeyTo, - }; - return new txnBuilder.Transaction(o); -} -exports.makeApplicationNoOpTxn = makeApplicationNoOpTxn; -// helper for above makeApplicationNoOpTxn, instead accepting an argument object -function makeApplicationNoOpTxnFromObject(o) { - return makeApplicationNoOpTxn(o.sender, o.suggestedParams, o.appIndex, o.appArgs, o.accounts, o.foreignApps, o.foreignAssets, o.note, o.lease, o.rekeyTo, o.boxes); -} -exports.makeApplicationNoOpTxnFromObject = makeApplicationNoOpTxnFromObject; -var base_2 = require("./types/transactions/base"); -Object.defineProperty(exports, "OnApplicationComplete", { enumerable: true, get: function () { return base_2.OnApplicationComplete; } }); -/** - * Generic function for creating any application call transaction. - */ -function makeApplicationCallTxnFromObject(options) { - const o = { - type: transactions_1.TransactionType.appl, - sender: options.sender, - suggestedParams: options.suggestedParams, - appIndex: options.appIndex, - appOnComplete: options.onComplete, - appLocalInts: options.numLocalInts, - appLocalByteSlices: options.numLocalByteSlices, - appGlobalInts: options.numGlobalInts, - appGlobalByteSlices: options.numGlobalByteSlices, - appApprovalProgram: options.approvalProgram, - appClearProgram: options.clearProgram, - appArgs: options.appArgs, - appAccounts: options.accounts, - appForeignApps: options.foreignApps, - appForeignAssets: options.foreignAssets, - boxes: options.boxes, - note: options.note, - lease: options.lease, - rekeyTo: options.rekeyTo, - extraPages: options.extraPages, - }; - return new txnBuilder.Transaction(o); -} -exports.makeApplicationCallTxnFromObject = makeApplicationCallTxnFromObject; diff --git a/algosdk/mnemonic/mnemonic.d.ts b/algosdk/mnemonic/mnemonic.d.ts deleted file mode 100644 index 8f452c5..0000000 --- a/algosdk/mnemonic/mnemonic.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -import Account from '../types/account'; -export declare const FAIL_TO_DECODE_MNEMONIC_ERROR_MSG = "failed to decode mnemonic"; -export declare const NOT_IN_WORDS_LIST_ERROR_MSG = "the mnemonic contains a word that is not in the wordlist"; -/** - * mnemonicFromSeed converts a 32-byte key into a 25 word mnemonic. The generated mnemonic includes a checksum. - * Each word in the mnemonic represents 11 bits of data, and the last 11 bits are reserved for the checksum. - * @param seed - 32 bytes long seed - * @returns 25 words mnemonic - */ -export declare function mnemonicFromSeed(seed: Uint8Array): string; -/** - * seedFromMnemonic converts a mnemonic generated using this library into the source key used to create it. - * It returns an error if the passed mnemonic has an incorrect checksum, if the number of words is unexpected, or if one - * of the passed words is not found in the words list. - * @param mnemonic - 25 words mnemonic - * @returns 32 bytes long seed - */ -export declare function seedFromMnemonic(mnemonic: string): Uint8Array; -/** - * mnemonicToSecretKey takes a mnemonic string and returns the corresponding Algorand address and its secret key. - * @param mn - 25 words Algorand mnemonic - * @throws error if fails to decode the mnemonic - */ -export declare function mnemonicToSecretKey(mn: string): Account; -/** - * secretKeyToMnemonic takes an Algorand secret key and returns the corresponding mnemonic. - * @param sk - Algorand secret key - * @returns Secret key's associated mnemonic - */ -export declare function secretKeyToMnemonic(sk: Uint8Array): string; -/** - * mnemonicToMasterDerivationKey takes a mnemonic string and returns the corresponding master derivation key. - * @param mn - 25 words Algorand mnemonic - * @returns Uint8Array - * @throws error if fails to decode the mnemonic - */ -export declare function mnemonicToMasterDerivationKey(mn: string): Uint8Array; -/** - * masterDerivationKeyToMnemonic takes a master derivation key and returns the corresponding mnemonic. - * @param mdk - Uint8Array - * @returns string mnemonic - */ -export declare function masterDerivationKeyToMnemonic(mdk: Uint8Array): string; diff --git a/algosdk/mnemonic/mnemonic.js b/algosdk/mnemonic/mnemonic.js deleted file mode 100644 index f0cbed8..0000000 --- a/algosdk/mnemonic/mnemonic.js +++ /dev/null @@ -1,190 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.masterDerivationKeyToMnemonic = exports.mnemonicToMasterDerivationKey = exports.secretKeyToMnemonic = exports.mnemonicToSecretKey = exports.seedFromMnemonic = exports.mnemonicFromSeed = exports.NOT_IN_WORDS_LIST_ERROR_MSG = exports.FAIL_TO_DECODE_MNEMONIC_ERROR_MSG = void 0; -/* eslint-disable no-bitwise */ -const english_1 = __importDefault(require("./wordlists/english")); -const nacl = __importStar(require("../nacl/naclWrappers")); -const address = __importStar(require("../encoding/address")); -exports.FAIL_TO_DECODE_MNEMONIC_ERROR_MSG = 'failed to decode mnemonic'; -exports.NOT_IN_WORDS_LIST_ERROR_MSG = 'the mnemonic contains a word that is not in the wordlist'; -// https://stackoverflow.com/a/51452614 -function toUint11Array(buffer8) { - const buffer11 = []; - let acc = 0; - let accBits = 0; - function add(octet) { - acc |= octet << accBits; - accBits += 8; - if (accBits >= 11) { - buffer11.push(acc & 0x7ff); - acc >>= 11; - accBits -= 11; - } - } - function flush() { - if (accBits) { - buffer11.push(acc); - } - } - buffer8.forEach(add); - flush(); - return buffer11; -} -function applyWords(nums) { - return nums.map((n) => english_1.default[n]); -} -function computeChecksum(seed) { - const hashBuffer = nacl.genericHash(seed); - const uint11Hash = toUint11Array(hashBuffer); - const words = applyWords(uint11Hash); - return words[0]; -} -/** - * mnemonicFromSeed converts a 32-byte key into a 25 word mnemonic. The generated mnemonic includes a checksum. - * Each word in the mnemonic represents 11 bits of data, and the last 11 bits are reserved for the checksum. - * @param seed - 32 bytes long seed - * @returns 25 words mnemonic - */ -function mnemonicFromSeed(seed) { - // Sanity length check - if (seed.length !== nacl.SEED_BTYES_LENGTH) { - throw new RangeError(`Seed length must be ${nacl.SEED_BTYES_LENGTH}`); - } - const uint11Array = toUint11Array(seed); - const words = applyWords(uint11Array); - const checksumWord = computeChecksum(seed); - return `${words.join(' ')} ${checksumWord}`; -} -exports.mnemonicFromSeed = mnemonicFromSeed; -// from Uint11Array -// https://stackoverflow.com/a/51452614 -function toUint8Array(buffer11) { - const buffer8 = []; - let acc = 0; - let accBits = 0; - function add(ui11) { - acc |= ui11 << accBits; - accBits += 11; - while (accBits >= 8) { - buffer8.push(acc & 0xff); - acc >>= 8; - accBits -= 8; - } - } - function flush() { - if (accBits) { - buffer8.push(acc); - } - } - buffer11.forEach(add); - flush(); - return new Uint8Array(buffer8); -} -/** - * seedFromMnemonic converts a mnemonic generated using this library into the source key used to create it. - * It returns an error if the passed mnemonic has an incorrect checksum, if the number of words is unexpected, or if one - * of the passed words is not found in the words list. - * @param mnemonic - 25 words mnemonic - * @returns 32 bytes long seed - */ -function seedFromMnemonic(mnemonic) { - const words = mnemonic.split(' '); - const key = words.slice(0, 24); - // Check that all words are in list - for (const w of key) { - if (english_1.default.indexOf(w) === -1) - throw new Error(exports.NOT_IN_WORDS_LIST_ERROR_MSG); - } - const checksum = words[words.length - 1]; - const uint11Array = key.map((word) => english_1.default.indexOf(word)); - // Convert the key to uint8Array - let uint8Array = toUint8Array(uint11Array); - // We need to chop the last byte - - // the short explanation - Since 256 is not divisible by 11, we have an extra 0x0 byte. - // The longer explanation - When splitting the 256 bits to chunks of 11, we get 23 words and a left over of 3 bits. - // This left gets padded with another 8 bits to the create the 24th word. - // While converting back to byte array, our new 264 bits array is divisible by 8 but the last byte is just the padding. - // check that we have 33 bytes long array as expected - if (uint8Array.length !== 33) - throw new Error(exports.FAIL_TO_DECODE_MNEMONIC_ERROR_MSG); - // check that the last byte is actually 0x0 - if (uint8Array[uint8Array.length - 1] !== 0x0) - throw new Error(exports.FAIL_TO_DECODE_MNEMONIC_ERROR_MSG); - // chop it ! - uint8Array = uint8Array.slice(0, uint8Array.length - 1); - // compute checksum - const cs = computeChecksum(uint8Array); - // success! - if (cs === checksum) - return uint8Array; - throw new Error(exports.FAIL_TO_DECODE_MNEMONIC_ERROR_MSG); -} -exports.seedFromMnemonic = seedFromMnemonic; -/** - * mnemonicToSecretKey takes a mnemonic string and returns the corresponding Algorand address and its secret key. - * @param mn - 25 words Algorand mnemonic - * @throws error if fails to decode the mnemonic - */ -function mnemonicToSecretKey(mn) { - const seed = seedFromMnemonic(mn); - const keys = nacl.keyPairFromSeed(seed); - const encodedPk = address.encodeAddress(keys.publicKey); - return { addr: encodedPk, sk: keys.secretKey }; -} -exports.mnemonicToSecretKey = mnemonicToSecretKey; -/** - * secretKeyToMnemonic takes an Algorand secret key and returns the corresponding mnemonic. - * @param sk - Algorand secret key - * @returns Secret key's associated mnemonic - */ -function secretKeyToMnemonic(sk) { - // get the seed from the sk - const seed = sk.slice(0, nacl.SEED_BTYES_LENGTH); - return mnemonicFromSeed(seed); -} -exports.secretKeyToMnemonic = secretKeyToMnemonic; -/** - * mnemonicToMasterDerivationKey takes a mnemonic string and returns the corresponding master derivation key. - * @param mn - 25 words Algorand mnemonic - * @returns Uint8Array - * @throws error if fails to decode the mnemonic - */ -function mnemonicToMasterDerivationKey(mn) { - return seedFromMnemonic(mn); -} -exports.mnemonicToMasterDerivationKey = mnemonicToMasterDerivationKey; -/** - * masterDerivationKeyToMnemonic takes a master derivation key and returns the corresponding mnemonic. - * @param mdk - Uint8Array - * @returns string mnemonic - */ -function masterDerivationKeyToMnemonic(mdk) { - return mnemonicFromSeed(mdk); -} -exports.masterDerivationKeyToMnemonic = masterDerivationKeyToMnemonic; diff --git a/algosdk/mnemonic/wordlists/english.d.ts b/algosdk/mnemonic/wordlists/english.d.ts deleted file mode 100644 index b7f889f..0000000 --- a/algosdk/mnemonic/wordlists/english.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -declare const english: string[]; -export default english; diff --git a/algosdk/mnemonic/wordlists/english.js b/algosdk/mnemonic/wordlists/english.js deleted file mode 100644 index 5be36bd..0000000 --- a/algosdk/mnemonic/wordlists/english.js +++ /dev/null @@ -1,2053 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const english = [ - 'abandon', - 'ability', - 'able', - 'about', - 'above', - 'absent', - 'absorb', - 'abstract', - 'absurd', - 'abuse', - 'access', - 'accident', - 'account', - 'accuse', - 'achieve', - 'acid', - 'acoustic', - 'acquire', - 'across', - 'act', - 'action', - 'actor', - 'actress', - 'actual', - 'adapt', - 'add', - 'addict', - 'address', - 'adjust', - 'admit', - 'adult', - 'advance', - 'advice', - 'aerobic', - 'affair', - 'afford', - 'afraid', - 'again', - 'age', - 'agent', - 'agree', - 'ahead', - 'aim', - 'air', - 'airport', - 'aisle', - 'alarm', - 'album', - 'alcohol', - 'alert', - 'alien', - 'all', - 'alley', - 'allow', - 'almost', - 'alone', - 'alpha', - 'already', - 'also', - 'alter', - 'always', - 'amateur', - 'amazing', - 'among', - 'amount', - 'amused', - 'analyst', - 'anchor', - 'ancient', - 'anger', - 'angle', - 'angry', - 'animal', - 'ankle', - 'announce', - 'annual', - 'another', - 'answer', - 'antenna', - 'antique', - 'anxiety', - 'any', - 'apart', - 'apology', - 'appear', - 'apple', - 'approve', - 'april', - 'arch', - 'arctic', - 'area', - 'arena', - 'argue', - 'arm', - 'armed', - 'armor', - 'army', - 'around', - 'arrange', - 'arrest', - 'arrive', - 'arrow', - 'art', - 'artefact', - 'artist', - 'artwork', - 'ask', - 'aspect', - 'assault', - 'asset', - 'assist', - 'assume', - 'asthma', - 'athlete', - 'atom', - 'attack', - 'attend', - 'attitude', - 'attract', - 'auction', - 'audit', - 'august', - 'aunt', - 'author', - 'auto', - 'autumn', - 'average', - 'avocado', - 'avoid', - 'awake', - 'aware', - 'away', - 'awesome', - 'awful', - 'awkward', - 'axis', - 'baby', - 'bachelor', - 'bacon', - 'badge', - 'bag', - 'balance', - 'balcony', - 'ball', - 'bamboo', - 'banana', - 'banner', - 'bar', - 'barely', - 'bargain', - 'barrel', - 'base', - 'basic', - 'basket', - 'battle', - 'beach', - 'bean', - 'beauty', - 'because', - 'become', - 'beef', - 'before', - 'begin', - 'behave', - 'behind', - 'believe', - 'below', - 'belt', - 'bench', - 'benefit', - 'best', - 'betray', - 'better', - 'between', - 'beyond', - 'bicycle', - 'bid', - 'bike', - 'bind', - 'biology', - 'bird', - 'birth', - 'bitter', - 'black', - 'blade', - 'blame', - 'blanket', - 'blast', - 'bleak', - 'bless', - 'blind', - 'blood', - 'blossom', - 'blouse', - 'blue', - 'blur', - 'blush', - 'board', - 'boat', - 'body', - 'boil', - 'bomb', - 'bone', - 'bonus', - 'book', - 'boost', - 'border', - 'boring', - 'borrow', - 'boss', - 'bottom', - 'bounce', - 'box', - 'boy', - 'bracket', - 'brain', - 'brand', - 'brass', - 'brave', - 'bread', - 'breeze', - 'brick', - 'bridge', - 'brief', - 'bright', - 'bring', - 'brisk', - 'broccoli', - 'broken', - 'bronze', - 'broom', - 'brother', - 'brown', - 'brush', - 'bubble', - 'buddy', - 'budget', - 'buffalo', - 'build', - 'bulb', - 'bulk', - 'bullet', - 'bundle', - 'bunker', - 'burden', - 'burger', - 'burst', - 'bus', - 'business', - 'busy', - 'butter', - 'buyer', - 'buzz', - 'cabbage', - 'cabin', - 'cable', - 'cactus', - 'cage', - 'cake', - 'call', - 'calm', - 'camera', - 'camp', - 'can', - 'canal', - 'cancel', - 'candy', - 'cannon', - 'canoe', - 'canvas', - 'canyon', - 'capable', - 'capital', - 'captain', - 'car', - 'carbon', - 'card', - 'cargo', - 'carpet', - 'carry', - 'cart', - 'case', - 'cash', - 'casino', - 'castle', - 'casual', - 'cat', - 'catalog', - 'catch', - 'category', - 'cattle', - 'caught', - 'cause', - 'caution', - 'cave', - 'ceiling', - 'celery', - 'cement', - 'census', - 'century', - 'cereal', - 'certain', - 'chair', - 'chalk', - 'champion', - 'change', - 'chaos', - 'chapter', - 'charge', - 'chase', - 'chat', - 'cheap', - 'check', - 'cheese', - 'chef', - 'cherry', - 'chest', - 'chicken', - 'chief', - 'child', - 'chimney', - 'choice', - 'choose', - 'chronic', - 'chuckle', - 'chunk', - 'churn', - 'cigar', - 'cinnamon', - 'circle', - 'citizen', - 'city', - 'civil', - 'claim', - 'clap', - 'clarify', - 'claw', - 'clay', - 'clean', - 'clerk', - 'clever', - 'click', - 'client', - 'cliff', - 'climb', - 'clinic', - 'clip', - 'clock', - 'clog', - 'close', - 'cloth', - 'cloud', - 'clown', - 'club', - 'clump', - 'cluster', - 'clutch', - 'coach', - 'coast', - 'coconut', - 'code', - 'coffee', - 'coil', - 'coin', - 'collect', - 'color', - 'column', - 'combine', - 'come', - 'comfort', - 'comic', - 'common', - 'company', - 'concert', - 'conduct', - 'confirm', - 'congress', - 'connect', - 'consider', - 'control', - 'convince', - 'cook', - 'cool', - 'copper', - 'copy', - 'coral', - 'core', - 'corn', - 'correct', - 'cost', - 'cotton', - 'couch', - 'country', - 'couple', - 'course', - 'cousin', - 'cover', - 'coyote', - 'crack', - 'cradle', - 'craft', - 'cram', - 'crane', - 'crash', - 'crater', - 'crawl', - 'crazy', - 'cream', - 'credit', - 'creek', - 'crew', - 'cricket', - 'crime', - 'crisp', - 'critic', - 'crop', - 'cross', - 'crouch', - 'crowd', - 'crucial', - 'cruel', - 'cruise', - 'crumble', - 'crunch', - 'crush', - 'cry', - 'crystal', - 'cube', - 'culture', - 'cup', - 'cupboard', - 'curious', - 'current', - 'curtain', - 'curve', - 'cushion', - 'custom', - 'cute', - 'cycle', - 'dad', - 'damage', - 'damp', - 'dance', - 'danger', - 'daring', - 'dash', - 'daughter', - 'dawn', - 'day', - 'deal', - 'debate', - 'debris', - 'decade', - 'december', - 'decide', - 'decline', - 'decorate', - 'decrease', - 'deer', - 'defense', - 'define', - 'defy', - 'degree', - 'delay', - 'deliver', - 'demand', - 'demise', - 'denial', - 'dentist', - 'deny', - 'depart', - 'depend', - 'deposit', - 'depth', - 'deputy', - 'derive', - 'describe', - 'desert', - 'design', - 'desk', - 'despair', - 'destroy', - 'detail', - 'detect', - 'develop', - 'device', - 'devote', - 'diagram', - 'dial', - 'diamond', - 'diary', - 'dice', - 'diesel', - 'diet', - 'differ', - 'digital', - 'dignity', - 'dilemma', - 'dinner', - 'dinosaur', - 'direct', - 'dirt', - 'disagree', - 'discover', - 'disease', - 'dish', - 'dismiss', - 'disorder', - 'display', - 'distance', - 'divert', - 'divide', - 'divorce', - 'dizzy', - 'doctor', - 'document', - 'dog', - 'doll', - 'dolphin', - 'domain', - 'donate', - 'donkey', - 'donor', - 'door', - 'dose', - 'double', - 'dove', - 'draft', - 'dragon', - 'drama', - 'drastic', - 'draw', - 'dream', - 'dress', - 'drift', - 'drill', - 'drink', - 'drip', - 'drive', - 'drop', - 'drum', - 'dry', - 'duck', - 'dumb', - 'dune', - 'during', - 'dust', - 'dutch', - 'duty', - 'dwarf', - 'dynamic', - 'eager', - 'eagle', - 'early', - 'earn', - 'earth', - 'easily', - 'east', - 'easy', - 'echo', - 'ecology', - 'economy', - 'edge', - 'edit', - 'educate', - 'effort', - 'egg', - 'eight', - 'either', - 'elbow', - 'elder', - 'electric', - 'elegant', - 'element', - 'elephant', - 'elevator', - 'elite', - 'else', - 'embark', - 'embody', - 'embrace', - 'emerge', - 'emotion', - 'employ', - 'empower', - 'empty', - 'enable', - 'enact', - 'end', - 'endless', - 'endorse', - 'enemy', - 'energy', - 'enforce', - 'engage', - 'engine', - 'enhance', - 'enjoy', - 'enlist', - 'enough', - 'enrich', - 'enroll', - 'ensure', - 'enter', - 'entire', - 'entry', - 'envelope', - 'episode', - 'equal', - 'equip', - 'era', - 'erase', - 'erode', - 'erosion', - 'error', - 'erupt', - 'escape', - 'essay', - 'essence', - 'estate', - 'eternal', - 'ethics', - 'evidence', - 'evil', - 'evoke', - 'evolve', - 'exact', - 'example', - 'excess', - 'exchange', - 'excite', - 'exclude', - 'excuse', - 'execute', - 'exercise', - 'exhaust', - 'exhibit', - 'exile', - 'exist', - 'exit', - 'exotic', - 'expand', - 'expect', - 'expire', - 'explain', - 'expose', - 'express', - 'extend', - 'extra', - 'eye', - 'eyebrow', - 'fabric', - 'face', - 'faculty', - 'fade', - 'faint', - 'faith', - 'fall', - 'false', - 'fame', - 'family', - 'famous', - 'fan', - 'fancy', - 'fantasy', - 'farm', - 'fashion', - 'fat', - 'fatal', - 'father', - 'fatigue', - 'fault', - 'favorite', - 'feature', - 'february', - 'federal', - 'fee', - 'feed', - 'feel', - 'female', - 'fence', - 'festival', - 'fetch', - 'fever', - 'few', - 'fiber', - 'fiction', - 'field', - 'figure', - 'file', - 'film', - 'filter', - 'final', - 'find', - 'fine', - 'finger', - 'finish', - 'fire', - 'firm', - 'first', - 'fiscal', - 'fish', - 'fit', - 'fitness', - 'fix', - 'flag', - 'flame', - 'flash', - 'flat', - 'flavor', - 'flee', - 'flight', - 'flip', - 'float', - 'flock', - 'floor', - 'flower', - 'fluid', - 'flush', - 'fly', - 'foam', - 'focus', - 'fog', - 'foil', - 'fold', - 'follow', - 'food', - 'foot', - 'force', - 'forest', - 'forget', - 'fork', - 'fortune', - 'forum', - 'forward', - 'fossil', - 'foster', - 'found', - 'fox', - 'fragile', - 'frame', - 'frequent', - 'fresh', - 'friend', - 'fringe', - 'frog', - 'front', - 'frost', - 'frown', - 'frozen', - 'fruit', - 'fuel', - 'fun', - 'funny', - 'furnace', - 'fury', - 'future', - 'gadget', - 'gain', - 'galaxy', - 'gallery', - 'game', - 'gap', - 'garage', - 'garbage', - 'garden', - 'garlic', - 'garment', - 'gas', - 'gasp', - 'gate', - 'gather', - 'gauge', - 'gaze', - 'general', - 'genius', - 'genre', - 'gentle', - 'genuine', - 'gesture', - 'ghost', - 'giant', - 'gift', - 'giggle', - 'ginger', - 'giraffe', - 'girl', - 'give', - 'glad', - 'glance', - 'glare', - 'glass', - 'glide', - 'glimpse', - 'globe', - 'gloom', - 'glory', - 'glove', - 'glow', - 'glue', - 'goat', - 'goddess', - 'gold', - 'good', - 'goose', - 'gorilla', - 'gospel', - 'gossip', - 'govern', - 'gown', - 'grab', - 'grace', - 'grain', - 'grant', - 'grape', - 'grass', - 'gravity', - 'great', - 'green', - 'grid', - 'grief', - 'grit', - 'grocery', - 'group', - 'grow', - 'grunt', - 'guard', - 'guess', - 'guide', - 'guilt', - 'guitar', - 'gun', - 'gym', - 'habit', - 'hair', - 'half', - 'hammer', - 'hamster', - 'hand', - 'happy', - 'harbor', - 'hard', - 'harsh', - 'harvest', - 'hat', - 'have', - 'hawk', - 'hazard', - 'head', - 'health', - 'heart', - 'heavy', - 'hedgehog', - 'height', - 'hello', - 'helmet', - 'help', - 'hen', - 'hero', - 'hidden', - 'high', - 'hill', - 'hint', - 'hip', - 'hire', - 'history', - 'hobby', - 'hockey', - 'hold', - 'hole', - 'holiday', - 'hollow', - 'home', - 'honey', - 'hood', - 'hope', - 'horn', - 'horror', - 'horse', - 'hospital', - 'host', - 'hotel', - 'hour', - 'hover', - 'hub', - 'huge', - 'human', - 'humble', - 'humor', - 'hundred', - 'hungry', - 'hunt', - 'hurdle', - 'hurry', - 'hurt', - 'husband', - 'hybrid', - 'ice', - 'icon', - 'idea', - 'identify', - 'idle', - 'ignore', - 'ill', - 'illegal', - 'illness', - 'image', - 'imitate', - 'immense', - 'immune', - 'impact', - 'impose', - 'improve', - 'impulse', - 'inch', - 'include', - 'income', - 'increase', - 'index', - 'indicate', - 'indoor', - 'industry', - 'infant', - 'inflict', - 'inform', - 'inhale', - 'inherit', - 'initial', - 'inject', - 'injury', - 'inmate', - 'inner', - 'innocent', - 'input', - 'inquiry', - 'insane', - 'insect', - 'inside', - 'inspire', - 'install', - 'intact', - 'interest', - 'into', - 'invest', - 'invite', - 'involve', - 'iron', - 'island', - 'isolate', - 'issue', - 'item', - 'ivory', - 'jacket', - 'jaguar', - 'jar', - 'jazz', - 'jealous', - 'jeans', - 'jelly', - 'jewel', - 'job', - 'join', - 'joke', - 'journey', - 'joy', - 'judge', - 'juice', - 'jump', - 'jungle', - 'junior', - 'junk', - 'just', - 'kangaroo', - 'keen', - 'keep', - 'ketchup', - 'key', - 'kick', - 'kid', - 'kidney', - 'kind', - 'kingdom', - 'kiss', - 'kit', - 'kitchen', - 'kite', - 'kitten', - 'kiwi', - 'knee', - 'knife', - 'knock', - 'know', - 'lab', - 'label', - 'labor', - 'ladder', - 'lady', - 'lake', - 'lamp', - 'language', - 'laptop', - 'large', - 'later', - 'latin', - 'laugh', - 'laundry', - 'lava', - 'law', - 'lawn', - 'lawsuit', - 'layer', - 'lazy', - 'leader', - 'leaf', - 'learn', - 'leave', - 'lecture', - 'left', - 'leg', - 'legal', - 'legend', - 'leisure', - 'lemon', - 'lend', - 'length', - 'lens', - 'leopard', - 'lesson', - 'letter', - 'level', - 'liar', - 'liberty', - 'library', - 'license', - 'life', - 'lift', - 'light', - 'like', - 'limb', - 'limit', - 'link', - 'lion', - 'liquid', - 'list', - 'little', - 'live', - 'lizard', - 'load', - 'loan', - 'lobster', - 'local', - 'lock', - 'logic', - 'lonely', - 'long', - 'loop', - 'lottery', - 'loud', - 'lounge', - 'love', - 'loyal', - 'lucky', - 'luggage', - 'lumber', - 'lunar', - 'lunch', - 'luxury', - 'lyrics', - 'machine', - 'mad', - 'magic', - 'magnet', - 'maid', - 'mail', - 'main', - 'major', - 'make', - 'mammal', - 'man', - 'manage', - 'mandate', - 'mango', - 'mansion', - 'manual', - 'maple', - 'marble', - 'march', - 'margin', - 'marine', - 'market', - 'marriage', - 'mask', - 'mass', - 'master', - 'match', - 'material', - 'math', - 'matrix', - 'matter', - 'maximum', - 'maze', - 'meadow', - 'mean', - 'measure', - 'meat', - 'mechanic', - 'medal', - 'media', - 'melody', - 'melt', - 'member', - 'memory', - 'mention', - 'menu', - 'mercy', - 'merge', - 'merit', - 'merry', - 'mesh', - 'message', - 'metal', - 'method', - 'middle', - 'midnight', - 'milk', - 'million', - 'mimic', - 'mind', - 'minimum', - 'minor', - 'minute', - 'miracle', - 'mirror', - 'misery', - 'miss', - 'mistake', - 'mix', - 'mixed', - 'mixture', - 'mobile', - 'model', - 'modify', - 'mom', - 'moment', - 'monitor', - 'monkey', - 'monster', - 'month', - 'moon', - 'moral', - 'more', - 'morning', - 'mosquito', - 'mother', - 'motion', - 'motor', - 'mountain', - 'mouse', - 'move', - 'movie', - 'much', - 'muffin', - 'mule', - 'multiply', - 'muscle', - 'museum', - 'mushroom', - 'music', - 'must', - 'mutual', - 'myself', - 'mystery', - 'myth', - 'naive', - 'name', - 'napkin', - 'narrow', - 'nasty', - 'nation', - 'nature', - 'near', - 'neck', - 'need', - 'negative', - 'neglect', - 'neither', - 'nephew', - 'nerve', - 'nest', - 'net', - 'network', - 'neutral', - 'never', - 'news', - 'next', - 'nice', - 'night', - 'noble', - 'noise', - 'nominee', - 'noodle', - 'normal', - 'north', - 'nose', - 'notable', - 'note', - 'nothing', - 'notice', - 'novel', - 'now', - 'nuclear', - 'number', - 'nurse', - 'nut', - 'oak', - 'obey', - 'object', - 'oblige', - 'obscure', - 'observe', - 'obtain', - 'obvious', - 'occur', - 'ocean', - 'october', - 'odor', - 'off', - 'offer', - 'office', - 'often', - 'oil', - 'okay', - 'old', - 'olive', - 'olympic', - 'omit', - 'once', - 'one', - 'onion', - 'online', - 'only', - 'open', - 'opera', - 'opinion', - 'oppose', - 'option', - 'orange', - 'orbit', - 'orchard', - 'order', - 'ordinary', - 'organ', - 'orient', - 'original', - 'orphan', - 'ostrich', - 'other', - 'outdoor', - 'outer', - 'output', - 'outside', - 'oval', - 'oven', - 'over', - 'own', - 'owner', - 'oxygen', - 'oyster', - 'ozone', - 'pact', - 'paddle', - 'page', - 'pair', - 'palace', - 'palm', - 'panda', - 'panel', - 'panic', - 'panther', - 'paper', - 'parade', - 'parent', - 'park', - 'parrot', - 'party', - 'pass', - 'patch', - 'path', - 'patient', - 'patrol', - 'pattern', - 'pause', - 'pave', - 'payment', - 'peace', - 'peanut', - 'pear', - 'peasant', - 'pelican', - 'pen', - 'penalty', - 'pencil', - 'people', - 'pepper', - 'perfect', - 'permit', - 'person', - 'pet', - 'phone', - 'photo', - 'phrase', - 'physical', - 'piano', - 'picnic', - 'picture', - 'piece', - 'pig', - 'pigeon', - 'pill', - 'pilot', - 'pink', - 'pioneer', - 'pipe', - 'pistol', - 'pitch', - 'pizza', - 'place', - 'planet', - 'plastic', - 'plate', - 'play', - 'please', - 'pledge', - 'pluck', - 'plug', - 'plunge', - 'poem', - 'poet', - 'point', - 'polar', - 'pole', - 'police', - 'pond', - 'pony', - 'pool', - 'popular', - 'portion', - 'position', - 'possible', - 'post', - 'potato', - 'pottery', - 'poverty', - 'powder', - 'power', - 'practice', - 'praise', - 'predict', - 'prefer', - 'prepare', - 'present', - 'pretty', - 'prevent', - 'price', - 'pride', - 'primary', - 'print', - 'priority', - 'prison', - 'private', - 'prize', - 'problem', - 'process', - 'produce', - 'profit', - 'program', - 'project', - 'promote', - 'proof', - 'property', - 'prosper', - 'protect', - 'proud', - 'provide', - 'public', - 'pudding', - 'pull', - 'pulp', - 'pulse', - 'pumpkin', - 'punch', - 'pupil', - 'puppy', - 'purchase', - 'purity', - 'purpose', - 'purse', - 'push', - 'put', - 'puzzle', - 'pyramid', - 'quality', - 'quantum', - 'quarter', - 'question', - 'quick', - 'quit', - 'quiz', - 'quote', - 'rabbit', - 'raccoon', - 'race', - 'rack', - 'radar', - 'radio', - 'rail', - 'rain', - 'raise', - 'rally', - 'ramp', - 'ranch', - 'random', - 'range', - 'rapid', - 'rare', - 'rate', - 'rather', - 'raven', - 'raw', - 'razor', - 'ready', - 'real', - 'reason', - 'rebel', - 'rebuild', - 'recall', - 'receive', - 'recipe', - 'record', - 'recycle', - 'reduce', - 'reflect', - 'reform', - 'refuse', - 'region', - 'regret', - 'regular', - 'reject', - 'relax', - 'release', - 'relief', - 'rely', - 'remain', - 'remember', - 'remind', - 'remove', - 'render', - 'renew', - 'rent', - 'reopen', - 'repair', - 'repeat', - 'replace', - 'report', - 'require', - 'rescue', - 'resemble', - 'resist', - 'resource', - 'response', - 'result', - 'retire', - 'retreat', - 'return', - 'reunion', - 'reveal', - 'review', - 'reward', - 'rhythm', - 'rib', - 'ribbon', - 'rice', - 'rich', - 'ride', - 'ridge', - 'rifle', - 'right', - 'rigid', - 'ring', - 'riot', - 'ripple', - 'risk', - 'ritual', - 'rival', - 'river', - 'road', - 'roast', - 'robot', - 'robust', - 'rocket', - 'romance', - 'roof', - 'rookie', - 'room', - 'rose', - 'rotate', - 'rough', - 'round', - 'route', - 'royal', - 'rubber', - 'rude', - 'rug', - 'rule', - 'run', - 'runway', - 'rural', - 'sad', - 'saddle', - 'sadness', - 'safe', - 'sail', - 'salad', - 'salmon', - 'salon', - 'salt', - 'salute', - 'same', - 'sample', - 'sand', - 'satisfy', - 'satoshi', - 'sauce', - 'sausage', - 'save', - 'say', - 'scale', - 'scan', - 'scare', - 'scatter', - 'scene', - 'scheme', - 'school', - 'science', - 'scissors', - 'scorpion', - 'scout', - 'scrap', - 'screen', - 'script', - 'scrub', - 'sea', - 'search', - 'season', - 'seat', - 'second', - 'secret', - 'section', - 'security', - 'seed', - 'seek', - 'segment', - 'select', - 'sell', - 'seminar', - 'senior', - 'sense', - 'sentence', - 'series', - 'service', - 'session', - 'settle', - 'setup', - 'seven', - 'shadow', - 'shaft', - 'shallow', - 'share', - 'shed', - 'shell', - 'sheriff', - 'shield', - 'shift', - 'shine', - 'ship', - 'shiver', - 'shock', - 'shoe', - 'shoot', - 'shop', - 'short', - 'shoulder', - 'shove', - 'shrimp', - 'shrug', - 'shuffle', - 'shy', - 'sibling', - 'sick', - 'side', - 'siege', - 'sight', - 'sign', - 'silent', - 'silk', - 'silly', - 'silver', - 'similar', - 'simple', - 'since', - 'sing', - 'siren', - 'sister', - 'situate', - 'six', - 'size', - 'skate', - 'sketch', - 'ski', - 'skill', - 'skin', - 'skirt', - 'skull', - 'slab', - 'slam', - 'sleep', - 'slender', - 'slice', - 'slide', - 'slight', - 'slim', - 'slogan', - 'slot', - 'slow', - 'slush', - 'small', - 'smart', - 'smile', - 'smoke', - 'smooth', - 'snack', - 'snake', - 'snap', - 'sniff', - 'snow', - 'soap', - 'soccer', - 'social', - 'sock', - 'soda', - 'soft', - 'solar', - 'soldier', - 'solid', - 'solution', - 'solve', - 'someone', - 'song', - 'soon', - 'sorry', - 'sort', - 'soul', - 'sound', - 'soup', - 'source', - 'south', - 'space', - 'spare', - 'spatial', - 'spawn', - 'speak', - 'special', - 'speed', - 'spell', - 'spend', - 'sphere', - 'spice', - 'spider', - 'spike', - 'spin', - 'spirit', - 'split', - 'spoil', - 'sponsor', - 'spoon', - 'sport', - 'spot', - 'spray', - 'spread', - 'spring', - 'spy', - 'square', - 'squeeze', - 'squirrel', - 'stable', - 'stadium', - 'staff', - 'stage', - 'stairs', - 'stamp', - 'stand', - 'start', - 'state', - 'stay', - 'steak', - 'steel', - 'stem', - 'step', - 'stereo', - 'stick', - 'still', - 'sting', - 'stock', - 'stomach', - 'stone', - 'stool', - 'story', - 'stove', - 'strategy', - 'street', - 'strike', - 'strong', - 'struggle', - 'student', - 'stuff', - 'stumble', - 'style', - 'subject', - 'submit', - 'subway', - 'success', - 'such', - 'sudden', - 'suffer', - 'sugar', - 'suggest', - 'suit', - 'summer', - 'sun', - 'sunny', - 'sunset', - 'super', - 'supply', - 'supreme', - 'sure', - 'surface', - 'surge', - 'surprise', - 'surround', - 'survey', - 'suspect', - 'sustain', - 'swallow', - 'swamp', - 'swap', - 'swarm', - 'swear', - 'sweet', - 'swift', - 'swim', - 'swing', - 'switch', - 'sword', - 'symbol', - 'symptom', - 'syrup', - 'system', - 'table', - 'tackle', - 'tag', - 'tail', - 'talent', - 'talk', - 'tank', - 'tape', - 'target', - 'task', - 'taste', - 'tattoo', - 'taxi', - 'teach', - 'team', - 'tell', - 'ten', - 'tenant', - 'tennis', - 'tent', - 'term', - 'test', - 'text', - 'thank', - 'that', - 'theme', - 'then', - 'theory', - 'there', - 'they', - 'thing', - 'this', - 'thought', - 'three', - 'thrive', - 'throw', - 'thumb', - 'thunder', - 'ticket', - 'tide', - 'tiger', - 'tilt', - 'timber', - 'time', - 'tiny', - 'tip', - 'tired', - 'tissue', - 'title', - 'toast', - 'tobacco', - 'today', - 'toddler', - 'toe', - 'together', - 'toilet', - 'token', - 'tomato', - 'tomorrow', - 'tone', - 'tongue', - 'tonight', - 'tool', - 'tooth', - 'top', - 'topic', - 'topple', - 'torch', - 'tornado', - 'tortoise', - 'toss', - 'total', - 'tourist', - 'toward', - 'tower', - 'town', - 'toy', - 'track', - 'trade', - 'traffic', - 'tragic', - 'train', - 'transfer', - 'trap', - 'trash', - 'travel', - 'tray', - 'treat', - 'tree', - 'trend', - 'trial', - 'tribe', - 'trick', - 'trigger', - 'trim', - 'trip', - 'trophy', - 'trouble', - 'truck', - 'true', - 'truly', - 'trumpet', - 'trust', - 'truth', - 'try', - 'tube', - 'tuition', - 'tumble', - 'tuna', - 'tunnel', - 'turkey', - 'turn', - 'turtle', - 'twelve', - 'twenty', - 'twice', - 'twin', - 'twist', - 'two', - 'type', - 'typical', - 'ugly', - 'umbrella', - 'unable', - 'unaware', - 'uncle', - 'uncover', - 'under', - 'undo', - 'unfair', - 'unfold', - 'unhappy', - 'uniform', - 'unique', - 'unit', - 'universe', - 'unknown', - 'unlock', - 'until', - 'unusual', - 'unveil', - 'update', - 'upgrade', - 'uphold', - 'upon', - 'upper', - 'upset', - 'urban', - 'urge', - 'usage', - 'use', - 'used', - 'useful', - 'useless', - 'usual', - 'utility', - 'vacant', - 'vacuum', - 'vague', - 'valid', - 'valley', - 'valve', - 'van', - 'vanish', - 'vapor', - 'various', - 'vast', - 'vault', - 'vehicle', - 'velvet', - 'vendor', - 'venture', - 'venue', - 'verb', - 'verify', - 'version', - 'very', - 'vessel', - 'veteran', - 'viable', - 'vibrant', - 'vicious', - 'victory', - 'video', - 'view', - 'village', - 'vintage', - 'violin', - 'virtual', - 'virus', - 'visa', - 'visit', - 'visual', - 'vital', - 'vivid', - 'vocal', - 'voice', - 'void', - 'volcano', - 'volume', - 'vote', - 'voyage', - 'wage', - 'wagon', - 'wait', - 'walk', - 'wall', - 'walnut', - 'want', - 'warfare', - 'warm', - 'warrior', - 'wash', - 'wasp', - 'waste', - 'water', - 'wave', - 'way', - 'wealth', - 'weapon', - 'wear', - 'weasel', - 'weather', - 'web', - 'wedding', - 'weekend', - 'weird', - 'welcome', - 'west', - 'wet', - 'whale', - 'what', - 'wheat', - 'wheel', - 'when', - 'where', - 'whip', - 'whisper', - 'wide', - 'width', - 'wife', - 'wild', - 'will', - 'win', - 'window', - 'wine', - 'wing', - 'wink', - 'winner', - 'winter', - 'wire', - 'wisdom', - 'wise', - 'wish', - 'witness', - 'wolf', - 'woman', - 'wonder', - 'wood', - 'wool', - 'word', - 'work', - 'world', - 'worry', - 'worth', - 'wrap', - 'wreck', - 'wrestle', - 'wrist', - 'write', - 'wrong', - 'yard', - 'year', - 'yellow', - 'you', - 'young', - 'youth', - 'zebra', - 'zero', - 'zone', - 'zoo', -]; -exports.default = english; diff --git a/algosdk/multisig.d.ts b/algosdk/multisig.d.ts deleted file mode 100644 index 9cc3c6d..0000000 --- a/algosdk/multisig.d.ts +++ /dev/null @@ -1,125 +0,0 @@ -import * as txnBuilder from './transaction'; -import { EncodedTransaction } from './types/transactions'; -import { MultisigMetadata } from './types/multisig'; -import { EncodedMultisig } from './types/transactions/encoded'; -/** - Utilities for manipulating multisig transaction blobs. - */ -export declare const MULTISIG_MERGE_LESSTHANTWO_ERROR_MSG = "Not enough multisig transactions to merge. Need at least two"; -export declare const MULTISIG_MERGE_MISMATCH_ERROR_MSG = "Cannot merge txs. txIDs differ"; -export declare const MULTISIG_MERGE_MISMATCH_AUTH_ADDR_MSG = "Cannot merge txs. Auth addrs differ"; -export declare const MULTISIG_MERGE_WRONG_PREIMAGE_ERROR_MSG = "Cannot merge txs. Multisig preimages differ"; -export declare const MULTISIG_MERGE_SIG_MISMATCH_ERROR_MSG = "Cannot merge txs. subsigs are mismatched."; -export declare const MULTISIG_NO_MUTATE_ERROR_MSG = "Cannot mutate a multisig field as it would invalidate all existing signatures."; -export declare const MULTISIG_USE_PARTIAL_SIGN_ERROR_MSG = "Cannot sign a multisig transaction using `signTxn`. Use `partialSignTxn` instead."; -export declare const MULTISIG_SIGNATURE_LENGTH_ERROR_MSG = "Cannot add multisig signature. Signature is not of the correct length."; -interface MultisigMetadataWithPks extends Omit { - pks: Uint8Array[]; -} -/** - * createMultisigTransaction creates a raw, unsigned multisig transaction blob. - * @param txn - the actual transaction. - * @param version - multisig version - * @param threshold - multisig threshold - * @param pks - ordered list of public keys in this multisig - * @returns encoded multisig blob - */ -export declare function createMultisigTransaction(txn: txnBuilder.Transaction, { version, threshold, addrs }: MultisigMetadata): Uint8Array; -/** - * MultisigTransaction is a Transaction that also supports creating partially-signed multisig transactions. - */ -export declare class MultisigTransaction extends txnBuilder.Transaction { - /** - * Override inherited method to throw an error, as mutating transactions are prohibited in this context - */ - addLease(): void; - /** - * Override inherited method to throw an error, as mutating transactions are prohibited in this context - */ - addRekey(): void; - /** - * Override inherited method to throw an error, as traditional signing is not allowed - */ - signTxn(sk: Uint8Array): Uint8Array; - /** - * partialSignTxn partially signs this transaction and returns a partially-signed multisig transaction, - * encoded with msgpack as a typed array. - * @param version - multisig version - * @param threshold - multisig threshold - * @param pks - multisig public key list, order is important. - * @param sk - an Algorand secret key to sign with. - * @returns an encoded, partially signed multisig transaction. - */ - partialSignTxn({ version, threshold, pks }: MultisigMetadataWithPks, sk: Uint8Array): Uint8Array; - /** - * partialSignWithMultisigSignature partially signs this transaction with an external raw multisig signature and returns - * a partially-signed multisig transaction, encoded with msgpack as a typed array. - * @param metadata - multisig metadata - * @param signerAddr - address of the signer - * @param signature - raw multisig signature - * @returns an encoded, partially signed multisig transaction. - */ - partialSignWithMultisigSignature(metadata: MultisigMetadataWithPks, signerAddr: string, signature: Uint8Array): Uint8Array; - static from_obj_for_encoding(txnForEnc: EncodedTransaction): MultisigTransaction; -} -/** - * mergeMultisigTransactions takes a list of multisig transaction blobs, and merges them. - * @param multisigTxnBlobs - a list of blobs representing encoded multisig txns - * @returns typed array msg-pack encoded multisig txn - */ -export declare function mergeMultisigTransactions(multisigTxnBlobs: Uint8Array[]): Uint8Array; -export declare function verifyMultisig(toBeVerified: Uint8Array, msig: EncodedMultisig, publicKey: Uint8Array): boolean; -/** - * signMultisigTransaction takes a raw transaction (see signTransaction), a multisig preimage, a secret key, and returns - * a multisig transaction, which is a blob representing a transaction and multisignature account preimage. The returned - * multisig txn can accumulate additional signatures through mergeMultisigTransactions or appendSignMultisigTransaction. - * @param txn - object with either payment or key registration fields - * @param version - multisig version - * @param threshold - multisig threshold - * @param addrs - a list of Algorand addresses representing possible signers for this multisig. Order is important. - * @param sk - Algorand secret key. The corresponding pk should be in the pre image. - * @returns object containing txID, and blob of partially signed multisig transaction (with multisig preimage information) - * If the final calculated fee is lower than the protocol minimum fee, the fee will be increased to match the minimum. - */ -export declare function signMultisigTransaction(txn: txnBuilder.TransactionLike, { version, threshold, addrs }: MultisigMetadata, sk: Uint8Array): { - txID: string; - blob: Uint8Array; -}; -/** - * appendSignMultisigTransaction takes a multisig transaction blob, and appends our signature to it. - * While we could derive public key preimagery from the partially-signed multisig transaction, - * we ask the caller to pass it back in, to ensure they know what they are signing. - * @param multisigTxnBlob - an encoded multisig txn. Supports non-payment txn types. - * @param version - multisig version - * @param threshold - multisig threshold - * @param addrs - a list of Algorand addresses representing possible signers for this multisig. Order is important. - * @param sk - Algorand secret key - * @returns object containing txID, and blob representing encoded multisig txn - */ -export declare function appendSignMultisigTransaction(multisigTxnBlob: Uint8Array, { version, threshold, addrs }: MultisigMetadata, sk: Uint8Array): { - txID: string; - blob: Uint8Array; -}; -/** - * appendMultisigTransactionSignature takes a multisig transaction blob, and appends a given raw signature to it. - * This makes it possible to compile a multisig signature using only raw signatures from external methods. - * @param multisigTxnBlob - an encoded multisig txn. Supports non-payment txn types. - * @param version - multisig version - * @param threshold - multisig threshold - * @param addrs - a list of Algorand addresses representing possible signers for this multisig. Order is important. - * @param signerAddr - address of the signer - * @param signature - raw multisig signature - * @returns object containing txID, and blob representing encoded multisig txn - */ -export declare function appendSignRawMultisigSignature(multisigTxnBlob: Uint8Array, { version, threshold, addrs }: MultisigMetadata, signerAddr: string, signature: Uint8Array): { - txID: string; - blob: Uint8Array; -}; -/** - * multisigAddress takes multisig metadata (preimage) and returns the corresponding human readable Algorand address. - * @param version - multisig version - * @param threshold - multisig threshold - * @param addrs - list of Algorand addresses - */ -export declare function multisigAddress({ version, threshold, addrs, }: MultisigMetadata): string; -export {}; diff --git a/algosdk/multisig.js b/algosdk/multisig.js deleted file mode 100644 index f720767..0000000 --- a/algosdk/multisig.js +++ /dev/null @@ -1,392 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.multisigAddress = exports.appendSignRawMultisigSignature = exports.appendSignMultisigTransaction = exports.signMultisigTransaction = exports.verifyMultisig = exports.mergeMultisigTransactions = exports.MultisigTransaction = exports.createMultisigTransaction = exports.MULTISIG_SIGNATURE_LENGTH_ERROR_MSG = exports.MULTISIG_USE_PARTIAL_SIGN_ERROR_MSG = exports.MULTISIG_NO_MUTATE_ERROR_MSG = exports.MULTISIG_MERGE_SIG_MISMATCH_ERROR_MSG = exports.MULTISIG_MERGE_WRONG_PREIMAGE_ERROR_MSG = exports.MULTISIG_MERGE_MISMATCH_AUTH_ADDR_MSG = exports.MULTISIG_MERGE_MISMATCH_ERROR_MSG = exports.MULTISIG_MERGE_LESSTHANTWO_ERROR_MSG = void 0; -const nacl = __importStar(require("./nacl/naclWrappers")); -const address = __importStar(require("./encoding/address")); -const encoding = __importStar(require("./encoding/encoding")); -const txnBuilder = __importStar(require("./transaction")); -const utils = __importStar(require("./utils/utils")); -/** - Utilities for manipulating multisig transaction blobs. - */ -exports.MULTISIG_MERGE_LESSTHANTWO_ERROR_MSG = 'Not enough multisig transactions to merge. Need at least two'; -exports.MULTISIG_MERGE_MISMATCH_ERROR_MSG = 'Cannot merge txs. txIDs differ'; -exports.MULTISIG_MERGE_MISMATCH_AUTH_ADDR_MSG = 'Cannot merge txs. Auth addrs differ'; -exports.MULTISIG_MERGE_WRONG_PREIMAGE_ERROR_MSG = 'Cannot merge txs. Multisig preimages differ'; -exports.MULTISIG_MERGE_SIG_MISMATCH_ERROR_MSG = 'Cannot merge txs. subsigs are mismatched.'; -const MULTISIG_KEY_NOT_EXIST_ERROR_MSG = 'Key does not exist'; -exports.MULTISIG_NO_MUTATE_ERROR_MSG = 'Cannot mutate a multisig field as it would invalidate all existing signatures.'; -exports.MULTISIG_USE_PARTIAL_SIGN_ERROR_MSG = 'Cannot sign a multisig transaction using `signTxn`. Use `partialSignTxn` instead.'; -exports.MULTISIG_SIGNATURE_LENGTH_ERROR_MSG = 'Cannot add multisig signature. Signature is not of the correct length.'; -/** - * createMultisigTransaction creates a raw, unsigned multisig transaction blob. - * @param txn - the actual transaction. - * @param version - multisig version - * @param threshold - multisig threshold - * @param pks - ordered list of public keys in this multisig - * @returns encoded multisig blob - */ -function createMultisigTransaction(txn, { version, threshold, addrs }) { - // construct the appendable multisigned transaction format - const pks = addrs.map((addr) => address.decodeAddress(addr).publicKey); - const subsigs = pks.map((pk) => ({ pk })); - const msig = { - v: version, - thr: threshold, - subsig: subsigs, - }; - const txnForEncoding = txn.get_obj_for_encoding(); - const signedTxn = { - msig, - txn: txnForEncoding, - }; - // if the address of this multisig is different from the transaction sender, - // we need to add the auth-addr field - const msigAddr = address.fromMultisigPreImg({ - version, - threshold, - pks, - }); - if (address.encodeAddress(txnForEncoding.snd) !== - address.encodeAddress(msigAddr)) { - signedTxn.sgnr = msigAddr; - } - return new Uint8Array(encoding.encode(signedTxn)); -} -exports.createMultisigTransaction = createMultisigTransaction; -/** - * createMultisigTransactionWithSignature creates a multisig transaction blob with an included signature. - * @param txn - the actual transaction to sign. - * @param rawSig - a Uint8Array raw signature of that transaction - * @param myPk - a public key that corresponds with rawSig - * @param version - multisig version - * @param threshold - multisig threshold - * @param pks - ordered list of public keys in this multisig - * @returns encoded multisig blob - */ -function createMultisigTransactionWithSignature(txn, { rawSig, myPk }, { version, threshold, pks }) { - // Create an empty encoded multisig transaction - const encodedMsig = createMultisigTransaction(txn, { - version, - threshold, - addrs: pks.map((pk) => address.encodeAddress(pk)), - }); - // note: this is not signed yet, but will be shortly - const signedTxn = encoding.decode(encodedMsig); - let keyExist = false; - // append the multisig signature to the corresponding public key in the multisig blob - signedTxn.msig.subsig.forEach((subsig, i) => { - if (nacl.bytesEqual(subsig.pk, myPk)) { - keyExist = true; - signedTxn.msig.subsig[i].s = rawSig; - } - }); - if (keyExist === false) { - throw new Error(MULTISIG_KEY_NOT_EXIST_ERROR_MSG); - } - // if the address of this multisig is different from the transaction sender, - // we need to add the auth-addr field - const msigAddr = address.fromMultisigPreImg({ - version, - threshold, - pks, - }); - if (address.encodeAddress(signedTxn.txn.snd) !== address.encodeAddress(msigAddr)) { - signedTxn.sgnr = msigAddr; - } - return new Uint8Array(encoding.encode(signedTxn)); -} -/** - * MultisigTransaction is a Transaction that also supports creating partially-signed multisig transactions. - */ -class MultisigTransaction extends txnBuilder.Transaction { - /* eslint-disable class-methods-use-this,@typescript-eslint/no-unused-vars,no-dupe-class-members */ - /** - * Override inherited method to throw an error, as mutating transactions are prohibited in this context - */ - addLease() { - throw new Error(exports.MULTISIG_NO_MUTATE_ERROR_MSG); - } - /** - * Override inherited method to throw an error, as mutating transactions are prohibited in this context - */ - addRekey() { - throw new Error(exports.MULTISIG_NO_MUTATE_ERROR_MSG); - } - signTxn(sk) { - throw new Error(exports.MULTISIG_USE_PARTIAL_SIGN_ERROR_MSG); - } - /* eslint-enable class-methods-use-this,@typescript-eslint/no-unused-vars,no-dupe-class-members */ - /** - * partialSignTxn partially signs this transaction and returns a partially-signed multisig transaction, - * encoded with msgpack as a typed array. - * @param version - multisig version - * @param threshold - multisig threshold - * @param pks - multisig public key list, order is important. - * @param sk - an Algorand secret key to sign with. - * @returns an encoded, partially signed multisig transaction. - */ - partialSignTxn({ version, threshold, pks }, sk) { - // get signature verifier - const myPk = nacl.keyPairFromSecretKey(sk).publicKey; - return createMultisigTransactionWithSignature(this, { rawSig: this.rawSignTxn(sk), myPk }, { version, threshold, pks }); - } - /** - * partialSignWithMultisigSignature partially signs this transaction with an external raw multisig signature and returns - * a partially-signed multisig transaction, encoded with msgpack as a typed array. - * @param metadata - multisig metadata - * @param signerAddr - address of the signer - * @param signature - raw multisig signature - * @returns an encoded, partially signed multisig transaction. - */ - partialSignWithMultisigSignature(metadata, signerAddr, signature) { - if (!nacl.isValidSignatureLength(signature.length)) { - throw new Error(exports.MULTISIG_SIGNATURE_LENGTH_ERROR_MSG); - } - return createMultisigTransactionWithSignature(this, { - rawSig: signature, - myPk: address.decodeAddress(signerAddr).publicKey, - }, metadata); - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(txnForEnc) { - return super.from_obj_for_encoding(txnForEnc); - } -} -exports.MultisigTransaction = MultisigTransaction; -/** - * mergeMultisigTransactions takes a list of multisig transaction blobs, and merges them. - * @param multisigTxnBlobs - a list of blobs representing encoded multisig txns - * @returns typed array msg-pack encoded multisig txn - */ -function mergeMultisigTransactions(multisigTxnBlobs) { - if (multisigTxnBlobs.length < 2) { - throw new Error(exports.MULTISIG_MERGE_LESSTHANTWO_ERROR_MSG); - } - const refSigTx = encoding.decode(multisigTxnBlobs[0]); - const refTxID = MultisigTransaction.from_obj_for_encoding(refSigTx.txn).txID(); - const refAuthAddr = refSigTx.sgnr - ? address.encodeAddress(refSigTx.sgnr) - : undefined; - const refPreImage = { - version: refSigTx.msig.v, - threshold: refSigTx.msig.thr, - pks: refSigTx.msig.subsig.map((subsig) => subsig.pk), - }; - const refMsigAddr = address.encodeAddress(address.fromMultisigPreImg(refPreImage)); - const newSubsigs = refSigTx.msig.subsig.map((sig) => ({ ...sig })); - for (let i = 1; i < multisigTxnBlobs.length; i++) { - const unisig = encoding.decode(multisigTxnBlobs[i]); - const unisigAlgoTxn = MultisigTransaction.from_obj_for_encoding(unisig.txn); - if (unisigAlgoTxn.txID() !== refTxID) { - throw new Error(exports.MULTISIG_MERGE_MISMATCH_ERROR_MSG); - } - const authAddr = unisig.sgnr - ? address.encodeAddress(unisig.sgnr) - : undefined; - if (refAuthAddr !== authAddr) { - throw new Error(exports.MULTISIG_MERGE_MISMATCH_AUTH_ADDR_MSG); - } - // check multisig has same preimage as reference - if (unisig.msig.subsig.length !== refSigTx.msig.subsig.length) { - throw new Error(exports.MULTISIG_MERGE_WRONG_PREIMAGE_ERROR_MSG); - } - const preimg = { - version: unisig.msig.v, - threshold: unisig.msig.thr, - pks: unisig.msig.subsig.map((subsig) => subsig.pk), - }; - const msgigAddr = address.encodeAddress(address.fromMultisigPreImg(preimg)); - if (refMsigAddr !== msgigAddr) { - throw new Error(exports.MULTISIG_MERGE_WRONG_PREIMAGE_ERROR_MSG); - } - // now, we can merge - unisig.msig.subsig.forEach((uniSubsig, index) => { - if (!uniSubsig.s) - return; - const current = newSubsigs[index]; - if (current.s && !utils.arrayEqual(uniSubsig.s, current.s)) { - // mismatch - throw new Error(exports.MULTISIG_MERGE_SIG_MISMATCH_ERROR_MSG); - } - current.s = uniSubsig.s; - }); - } - const msig = { - v: refSigTx.msig.v, - thr: refSigTx.msig.thr, - subsig: newSubsigs, - }; - const signedTxn = { - msig, - txn: refSigTx.txn, - }; - if (typeof refAuthAddr !== 'undefined') { - signedTxn.sgnr = address.decodeAddress(refAuthAddr).publicKey; - } - return new Uint8Array(encoding.encode(signedTxn)); -} -exports.mergeMultisigTransactions = mergeMultisigTransactions; -function verifyMultisig(toBeVerified, msig, publicKey) { - const version = msig.v; - const threshold = msig.thr; - const subsigs = msig.subsig; - const pks = subsigs.map((subsig) => subsig.pk); - if (msig.subsig.length < threshold) { - return false; - } - let pk; - try { - pk = address.fromMultisigPreImg({ version, threshold, pks }); - } - catch (e) { - return false; - } - if (!utils.arrayEqual(pk, publicKey)) { - return false; - } - let counter = 0; - for (const subsig of subsigs) { - if (subsig.s !== undefined) { - counter += 1; - } - } - if (counter < threshold) { - return false; - } - let verifiedCounter = 0; - for (const subsig of subsigs) { - if (subsig.s !== undefined) { - if (nacl.verify(toBeVerified, subsig.s, subsig.pk)) { - verifiedCounter += 1; - } - } - } - if (verifiedCounter < threshold) { - return false; - } - return true; -} -exports.verifyMultisig = verifyMultisig; -/** - * signMultisigTransaction takes a raw transaction (see signTransaction), a multisig preimage, a secret key, and returns - * a multisig transaction, which is a blob representing a transaction and multisignature account preimage. The returned - * multisig txn can accumulate additional signatures through mergeMultisigTransactions or appendSignMultisigTransaction. - * @param txn - object with either payment or key registration fields - * @param version - multisig version - * @param threshold - multisig threshold - * @param addrs - a list of Algorand addresses representing possible signers for this multisig. Order is important. - * @param sk - Algorand secret key. The corresponding pk should be in the pre image. - * @returns object containing txID, and blob of partially signed multisig transaction (with multisig preimage information) - * If the final calculated fee is lower than the protocol minimum fee, the fee will be increased to match the minimum. - */ -function signMultisigTransaction(txn, { version, threshold, addrs }, sk) { - // check that the from field matches the mSigPreImage. If from field is not populated, fill it in. - const expectedFromRaw = address.fromMultisigPreImgAddrs({ - version, - threshold, - addrs, - }); - if (!Object.prototype.hasOwnProperty.call(txn, 'sender')) { - // eslint-disable-next-line no-param-reassign - txn.sender = expectedFromRaw; - } - // build pks for partialSign - const pks = addrs.map((addr) => address.decodeAddress(addr).publicKey); - // `txn` needs to be handled differently if it's a constructed `Transaction` vs a dict of constructor args - const txnAlreadyBuilt = txn instanceof txnBuilder.Transaction; - let algoTxn; - let blob; - if (txnAlreadyBuilt) { - algoTxn = txn; - blob = MultisigTransaction.prototype.partialSignTxn.call(algoTxn, { version, threshold, pks }, sk); - } - else { - algoTxn = new MultisigTransaction(txn); - blob = algoTxn.partialSignTxn({ version, threshold, pks }, sk); - } - return { - txID: algoTxn.txID().toString(), - blob, - }; -} -exports.signMultisigTransaction = signMultisigTransaction; -/** - * appendSignMultisigTransaction takes a multisig transaction blob, and appends our signature to it. - * While we could derive public key preimagery from the partially-signed multisig transaction, - * we ask the caller to pass it back in, to ensure they know what they are signing. - * @param multisigTxnBlob - an encoded multisig txn. Supports non-payment txn types. - * @param version - multisig version - * @param threshold - multisig threshold - * @param addrs - a list of Algorand addresses representing possible signers for this multisig. Order is important. - * @param sk - Algorand secret key - * @returns object containing txID, and blob representing encoded multisig txn - */ -function appendSignMultisigTransaction(multisigTxnBlob, { version, threshold, addrs }, sk) { - const pks = addrs.map((addr) => address.decodeAddress(addr).publicKey); - // obtain underlying txn, sign it, and merge it - const multisigTxObj = encoding.decode(multisigTxnBlob); - const msigTxn = MultisigTransaction.from_obj_for_encoding(multisigTxObj.txn); - const partialSignedBlob = msigTxn.partialSignTxn({ version, threshold, pks }, sk); - return { - txID: msigTxn.txID().toString(), - blob: mergeMultisigTransactions([multisigTxnBlob, partialSignedBlob]), - }; -} -exports.appendSignMultisigTransaction = appendSignMultisigTransaction; -/** - * appendMultisigTransactionSignature takes a multisig transaction blob, and appends a given raw signature to it. - * This makes it possible to compile a multisig signature using only raw signatures from external methods. - * @param multisigTxnBlob - an encoded multisig txn. Supports non-payment txn types. - * @param version - multisig version - * @param threshold - multisig threshold - * @param addrs - a list of Algorand addresses representing possible signers for this multisig. Order is important. - * @param signerAddr - address of the signer - * @param signature - raw multisig signature - * @returns object containing txID, and blob representing encoded multisig txn - */ -function appendSignRawMultisigSignature(multisigTxnBlob, { version, threshold, addrs }, signerAddr, signature) { - const pks = addrs.map((addr) => address.decodeAddress(addr).publicKey); - // obtain underlying txn, sign it, and merge it - const multisigTxObj = encoding.decode(multisigTxnBlob); - const msigTxn = MultisigTransaction.from_obj_for_encoding(multisigTxObj.txn); - const partialSignedBlob = msigTxn.partialSignWithMultisigSignature({ version, threshold, pks }, signerAddr, signature); - return { - txID: msigTxn.txID().toString(), - blob: mergeMultisigTransactions([multisigTxnBlob, partialSignedBlob]), - }; -} -exports.appendSignRawMultisigSignature = appendSignRawMultisigSignature; -/** - * multisigAddress takes multisig metadata (preimage) and returns the corresponding human readable Algorand address. - * @param version - multisig version - * @param threshold - multisig threshold - * @param addrs - list of Algorand addresses - */ -function multisigAddress({ version, threshold, addrs, }) { - return address.fromMultisigPreImgAddrs({ version, threshold, addrs }); -} -exports.multisigAddress = multisigAddress; diff --git a/algosdk/nacl/naclWrappers.d.ts b/algosdk/nacl/naclWrappers.d.ts deleted file mode 100644 index 3c6ca96..0000000 --- a/algosdk/nacl/naclWrappers.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -import nacl from 'tweetnacl'; -import sha512 from 'js-sha512'; -export declare function genericHash(arr: sha512.Message): number[]; -export declare function randomBytes(length: number): Uint8Array; -export declare function keyPairFromSeed(seed: Uint8Array): nacl.SignKeyPair; -export declare function keyPair(): nacl.SignKeyPair; -export declare function isValidSignatureLength(len: number): boolean; -export declare function keyPairFromSecretKey(sk: Uint8Array): nacl.SignKeyPair; -export declare function sign(msg: Uint8Array, secretKey: Uint8Array): Uint8Array; -export declare function bytesEqual(a: Uint8Array, b: Uint8Array): boolean; -export declare function verify(message: Uint8Array, signature: Uint8Array, verifyKey: Uint8Array): boolean; -export declare const PUBLIC_KEY_LENGTH: number; -export declare const SECRET_KEY_LENGTH: number; -export declare const HASH_BYTES_LENGTH = 32; -export declare const SEED_BTYES_LENGTH = 32; diff --git a/algosdk/nacl/naclWrappers.js b/algosdk/nacl/naclWrappers.js deleted file mode 100644 index 3c47b8c..0000000 --- a/algosdk/nacl/naclWrappers.js +++ /dev/null @@ -1,54 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.SEED_BTYES_LENGTH = exports.HASH_BYTES_LENGTH = exports.SECRET_KEY_LENGTH = exports.PUBLIC_KEY_LENGTH = exports.verify = exports.bytesEqual = exports.sign = exports.keyPairFromSecretKey = exports.isValidSignatureLength = exports.keyPair = exports.keyPairFromSeed = exports.randomBytes = exports.genericHash = void 0; -const tweetnacl_1 = __importDefault(require("tweetnacl")); -const js_sha512_1 = __importDefault(require("js-sha512")); -const utils_1 = require("../utils/utils"); -function genericHash(arr) { - return js_sha512_1.default.sha512_256.array(arr); -} -exports.genericHash = genericHash; -function randomBytes(length) { - if ((0, utils_1.isReactNative)()) { - console.warn(`It looks like you're running in react-native. In order to perform common crypto operations you will need to polyfill common operations such as crypto.getRandomValues`); - } - return tweetnacl_1.default.randomBytes(length); -} -exports.randomBytes = randomBytes; -function keyPairFromSeed(seed) { - return tweetnacl_1.default.sign.keyPair.fromSeed(seed); -} -exports.keyPairFromSeed = keyPairFromSeed; -function keyPair() { - const seed = randomBytes(tweetnacl_1.default.box.secretKeyLength); - return keyPairFromSeed(seed); -} -exports.keyPair = keyPair; -function isValidSignatureLength(len) { - return len === tweetnacl_1.default.sign.signatureLength; -} -exports.isValidSignatureLength = isValidSignatureLength; -function keyPairFromSecretKey(sk) { - return tweetnacl_1.default.sign.keyPair.fromSecretKey(sk); -} -exports.keyPairFromSecretKey = keyPairFromSecretKey; -function sign(msg, secretKey) { - return tweetnacl_1.default.sign.detached(msg, secretKey); -} -exports.sign = sign; -function bytesEqual(a, b) { - return tweetnacl_1.default.verify(a, b); -} -exports.bytesEqual = bytesEqual; -function verify(message, signature, verifyKey) { - return tweetnacl_1.default.sign.detached.verify(message, signature, verifyKey); -} -exports.verify = verify; -// constants -exports.PUBLIC_KEY_LENGTH = tweetnacl_1.default.sign.publicKeyLength; -exports.SECRET_KEY_LENGTH = tweetnacl_1.default.sign.secretKeyLength; -exports.HASH_BYTES_LENGTH = 32; -exports.SEED_BTYES_LENGTH = 32; diff --git a/algosdk/signer.d.ts b/algosdk/signer.d.ts deleted file mode 100644 index 04339f5..0000000 --- a/algosdk/signer.d.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { Transaction } from './transaction'; -import Account from './types/account'; -import { LogicSigAccount } from './logicsig'; -import { MultisigMetadata } from './types/multisig'; -/** - * This type represents a function which can sign transactions from an atomic transaction group. - * @param txnGroup - The atomic group containing transactions to be signed - * @param indexesToSign - An array of indexes in the atomic transaction group that should be signed - * @returns A promise which resolves an array of encoded signed transactions. The length of the - * array will be the same as the length of indexesToSign, and each index i in the array - * corresponds to the signed transaction from txnGroup[indexesToSign[i]] - */ -export declare type TransactionSigner = (txnGroup: Transaction[], indexesToSign: number[]) => Promise; -/** - * Create a TransactionSigner that can sign transactions for the provided basic Account. - */ -export declare function makeBasicAccountTransactionSigner(account: Account): TransactionSigner; -/** - * Create a TransactionSigner that can sign transactions for the provided LogicSigAccount. - */ -export declare function makeLogicSigAccountTransactionSigner(account: LogicSigAccount): TransactionSigner; -/** - * Create a TransactionSigner that can sign transactions for the provided Multisig account. - * @param msig - The Multisig account metadata - * @param sks - An array of private keys belonging to the msig which should sign the transactions. - */ -export declare function makeMultiSigAccountTransactionSigner(msig: MultisigMetadata, sks: Uint8Array[]): TransactionSigner; -/** - * Create a makeEmptyTransactionSigner that does not specify any signer or - * signing capabilities. This should only be used to simulate transactions. - */ -export declare function makeEmptyTransactionSigner(): TransactionSigner; -/** Represents an unsigned transactions and a signer that can authorize that transaction. */ -export interface TransactionWithSigner { - /** An unsigned transaction */ - txn: Transaction; - /** A transaction signer that can authorize txn */ - signer: TransactionSigner; -} -/** - * Check if a value conforms to the TransactionWithSigner structure. - * @param value - The value to check. - * @returns True if an only if the value has the structure of a TransactionWithSigner. - */ -export declare function isTransactionWithSigner(value: any): value is TransactionWithSigner; diff --git a/algosdk/signer.js b/algosdk/signer.js deleted file mode 100644 index e70ab33..0000000 --- a/algosdk/signer.js +++ /dev/null @@ -1,86 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.isTransactionWithSigner = exports.makeEmptyTransactionSigner = exports.makeMultiSigAccountTransactionSigner = exports.makeLogicSigAccountTransactionSigner = exports.makeBasicAccountTransactionSigner = void 0; -const transaction_1 = require("./transaction"); -const logicsig_1 = require("./logicsig"); -const multisig_1 = require("./multisig"); -/** - * Create a TransactionSigner that can sign transactions for the provided basic Account. - */ -function makeBasicAccountTransactionSigner(account) { - return (txnGroup, indexesToSign) => { - const signed = []; - for (const index of indexesToSign) { - signed.push(txnGroup[index].signTxn(account.sk)); - } - return Promise.resolve(signed); - }; -} -exports.makeBasicAccountTransactionSigner = makeBasicAccountTransactionSigner; -/** - * Create a TransactionSigner that can sign transactions for the provided LogicSigAccount. - */ -function makeLogicSigAccountTransactionSigner(account) { - return (txnGroup, indexesToSign) => { - const signed = []; - for (const index of indexesToSign) { - const { blob } = (0, logicsig_1.signLogicSigTransactionObject)(txnGroup[index], account); - signed.push(blob); - } - return Promise.resolve(signed); - }; -} -exports.makeLogicSigAccountTransactionSigner = makeLogicSigAccountTransactionSigner; -/** - * Create a TransactionSigner that can sign transactions for the provided Multisig account. - * @param msig - The Multisig account metadata - * @param sks - An array of private keys belonging to the msig which should sign the transactions. - */ -function makeMultiSigAccountTransactionSigner(msig, sks) { - return (txnGroup, indexesToSign) => { - const signed = []; - for (const index of indexesToSign) { - const txn = txnGroup[index]; - const partialSigs = []; - for (const sk of sks) { - const { blob } = (0, multisig_1.signMultisigTransaction)(txn, msig, sk); - partialSigs.push(blob); - } - if (partialSigs.length > 1) { - signed.push((0, multisig_1.mergeMultisigTransactions)(partialSigs)); - } - else { - signed.push(partialSigs[0]); - } - } - return Promise.resolve(signed); - }; -} -exports.makeMultiSigAccountTransactionSigner = makeMultiSigAccountTransactionSigner; -/** - * Create a makeEmptyTransactionSigner that does not specify any signer or - * signing capabilities. This should only be used to simulate transactions. - */ -function makeEmptyTransactionSigner() { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - return (txnGroup, indexesToSign) => { - const unsigned = []; - for (const index of indexesToSign) { - unsigned.push((0, transaction_1.encodeUnsignedSimulateTransaction)(txnGroup[index])); - } - return Promise.resolve(unsigned); - }; -} -exports.makeEmptyTransactionSigner = makeEmptyTransactionSigner; -/** - * Check if a value conforms to the TransactionWithSigner structure. - * @param value - The value to check. - * @returns True if an only if the value has the structure of a TransactionWithSigner. - */ -function isTransactionWithSigner(value) { - return (typeof value === 'object' && - Object.keys(value).length === 2 && - typeof value.txn === 'object' && - typeof value.signer === 'function'); -} -exports.isTransactionWithSigner = isTransactionWithSigner; diff --git a/algosdk/transaction.d.ts b/algosdk/transaction.d.ts deleted file mode 100644 index 4b9d24a..0000000 --- a/algosdk/transaction.d.ts +++ /dev/null @@ -1,199 +0,0 @@ -import { Address } from './types/address'; -import AnyTransaction, { EncodedLogicSig, EncodedMultisig, EncodedTransaction } from './types/transactions'; -import { BoxReference, OnApplicationComplete, TransactionParams, TransactionType } from './types/transactions/base'; -export declare const ALGORAND_MIN_TX_FEE = 1000; -/** - * A modified version of the transaction params. Represents the internal structure that the Transaction class uses - * to store inputted transaction objects. - */ -interface TransactionStorageStructure extends Omit { - sender: string | Address; - receiver: string | Address; - fee: number; - amount: number | bigint; - firstValid: number; - lastValid: number; - note?: Uint8Array; - genesisID: string; - genesisHash: string | Uint8Array; - lease?: Uint8Array; - closeRemainderTo?: string | Address; - voteKey: string | Uint8Array; - selectionKey: string | Uint8Array; - stateProofKey: string | Uint8Array; - voteFirst: number; - voteLast: number; - voteKeyDilution: number; - assetIndex: number; - assetTotal: number | bigint; - assetDecimals: number; - assetDefaultFrozen: boolean; - assetManager: string | Address; - assetReserve: string | Address; - assetFreeze: string | Address; - assetClawback: string | Address; - assetUnitName: string; - assetName: string; - assetURL: string; - assetMetadataHash?: string | Uint8Array; - freezeAccount: string | Address; - assetFrozen: boolean; - assetSender?: string | Address; - appIndex: number; - appOnComplete: OnApplicationComplete; - appLocalInts: number; - appLocalByteSlices: number; - appGlobalInts: number; - appGlobalByteSlices: number; - appApprovalProgram: Uint8Array; - appClearProgram: Uint8Array; - appArgs?: Uint8Array[]; - appAccounts?: string[] | Address[]; - appForeignApps?: number[]; - appForeignAssets?: number[]; - type?: TransactionType; - flatFee: boolean; - rekeyTo?: string | Address; - nonParticipation?: boolean; - group?: Uint8Array; - extraPages?: number; - boxes?: BoxReference[]; - stateProofType?: number | bigint; - stateProof?: Uint8Array; - stateProofMessage?: Uint8Array; -} -/** - * Transaction enables construction of Algorand transactions - * */ -export declare class Transaction implements TransactionStorageStructure { - name: string; - tag: Uint8Array; - sender: Address; - receiver: Address; - fee: number; - amount: number | bigint; - firstValid: number; - lastValid: number; - note?: Uint8Array; - genesisID: string; - genesisHash: Uint8Array; - lease?: Uint8Array; - closeRemainderTo?: Address; - voteKey: Uint8Array; - selectionKey: Uint8Array; - stateProofKey: Uint8Array; - voteFirst: number; - voteLast: number; - voteKeyDilution: number; - assetIndex: number; - assetTotal: number | bigint; - assetDecimals: number; - assetDefaultFrozen: boolean; - assetManager: Address; - assetReserve: Address; - assetFreeze: Address; - assetClawback: Address; - assetUnitName: string; - assetName: string; - assetURL: string; - assetMetadataHash?: Uint8Array; - freezeAccount: Address; - assetFrozen: boolean; - assetSender?: Address; - appIndex: number; - appOnComplete: OnApplicationComplete; - appLocalInts: number; - appLocalByteSlices: number; - appGlobalInts: number; - appGlobalByteSlices: number; - appApprovalProgram: Uint8Array; - appClearProgram: Uint8Array; - appArgs?: Uint8Array[]; - appAccounts?: Address[]; - appForeignApps?: number[]; - appForeignAssets?: number[]; - boxes?: BoxReference[]; - type?: TransactionType; - flatFee: boolean; - rekeyTo?: Address; - nonParticipation?: boolean; - group?: Uint8Array; - extraPages?: number; - stateProofType?: number | bigint; - stateProof?: Uint8Array; - stateProofMessage?: Uint8Array; - constructor({ ...transaction }: AnyTransaction); - get_obj_for_encoding(): EncodedTransaction; - static from_obj_for_encoding(txnForEnc: EncodedTransaction): Transaction; - estimateSize(): number; - bytesToSign(): Uint8Array; - toByte(): Uint8Array; - rawSignTxn(sk: Uint8Array): Uint8Array; - signTxn(sk: Uint8Array): Uint8Array; - attachSignature(signerAddr: string, signature: Uint8Array): Uint8Array; - rawTxID(): Uint8Array; - txID(): string; - addLease(lease: Uint8Array, feePerByte?: number): void; - addRekey(rekeyTo: string, feePerByte?: number): void; - _getDictForDisplay(): TransactionStorageStructure & Record; - prettyPrint(): void; - toString(): string; -} -/** - * encodeUnsignedSimulateTransaction takes a txnBuilder.Transaction object, - * converts it into a SignedTransaction-like object, and converts it to a Buffer. - * - * Note: this function should only be used to simulate unsigned transactions. - * - * @param transactionObject - Transaction object to simulate. - */ -export declare function encodeUnsignedSimulateTransaction(transactionObject: Transaction): Uint8Array; -/** - * encodeUnsignedTransaction takes a completed txnBuilder.Transaction object, such as from the makeFoo - * family of transactions, and converts it to a Buffer - * @param transactionObject - the completed Transaction object - */ -export declare function encodeUnsignedTransaction(transactionObject: Transaction): Uint8Array; -/** - * decodeUnsignedTransaction takes a Uint8Array (as if from encodeUnsignedTransaction) and converts it to a txnBuilder.Transaction object - * @param transactionBuffer - the Uint8Array containing a transaction - */ -export declare function decodeUnsignedTransaction(transactionBuffer: ArrayLike): Transaction; -/** - * Object representing a transaction with a signature - */ -export interface SignedTransaction { - /** - * Transaction signature - */ - sig?: Uint8Array; - /** - * The transaction that was signed - */ - txn: Transaction; - /** - * Multisig structure - */ - msig?: EncodedMultisig; - /** - * Logic signature - */ - lsig?: EncodedLogicSig; - /** - * The signer, if signing with a different key than the Transaction type `sender` property indicates - */ - sgnr?: Uint8Array; -} -/** - * decodeSignedTransaction takes a Uint8Array (from transaction.signTxn) and converts it to an object - * containing the Transaction (txn), the signature (sig), and the auth-addr field if applicable (sgnr) - * @param transactionBuffer - the Uint8Array containing a transaction - * @returns containing a Transaction, the signature, and possibly an auth-addr field - */ -export declare function decodeSignedTransaction(transactionBuffer: Uint8Array): SignedTransaction; -/** - * Either a valid transaction object or an instance of the Transaction class - */ -export declare type TransactionLike = AnyTransaction | Transaction; -export declare function instantiateTxnIfNeeded(transactionLike: TransactionLike): Transaction; -export default Transaction; diff --git a/algosdk/transaction.js b/algosdk/transaction.js deleted file mode 100644 index 3392e39..0000000 --- a/algosdk/transaction.js +++ /dev/null @@ -1,1128 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.instantiateTxnIfNeeded = exports.decodeSignedTransaction = exports.decodeUnsignedTransaction = exports.encodeUnsignedTransaction = exports.encodeUnsignedSimulateTransaction = exports.Transaction = exports.ALGORAND_MIN_TX_FEE = void 0; -const hi_base32_1 = __importDefault(require("hi-base32")); -const boxStorage_1 = require("./boxStorage"); -const address = __importStar(require("./encoding/address")); -const binarydata_1 = require("./encoding/binarydata"); -const encoding = __importStar(require("./encoding/encoding")); -const nacl = __importStar(require("./nacl/naclWrappers")); -const base_1 = require("./types/transactions/base"); -const utils = __importStar(require("./utils/utils")); -const ALGORAND_TRANSACTION_LENGTH = 52; -exports.ALGORAND_MIN_TX_FEE = 1000; // version v5 -const ALGORAND_TRANSACTION_LEASE_LENGTH = 32; -const ALGORAND_MAX_ASSET_DECIMALS = 19; -const NUM_ADDL_BYTES_AFTER_SIGNING = 75; // NUM_ADDL_BYTES_AFTER_SIGNING is the number of bytes added to a txn after signing it -const ALGORAND_TRANSACTION_LEASE_LABEL_LENGTH = 5; -const ALGORAND_TRANSACTION_ADDRESS_LENGTH = 32; -const ALGORAND_TRANSACTION_REKEY_LABEL_LENGTH = 5; -const ASSET_METADATA_HASH_LENGTH = 32; -const KEYREG_VOTE_KEY_LENGTH = 32; -const KEYREG_SELECTION_KEY_LENGTH = 32; -const KEYREG_STATE_PROOF_KEY_LENGTH = 64; -function getKeyregKey(input, inputName, length) { - if (input == null) { - return undefined; - } - let inputAsBuffer; - if (typeof input === 'string') { - inputAsBuffer = (0, binarydata_1.base64ToBytes)(input); - } - else if (input.constructor === Uint8Array) { - inputAsBuffer = input; - } - if (inputAsBuffer == null || inputAsBuffer.byteLength !== length) { - throw Error(`${inputName} must be a ${length} byte Uint8Array or base64 string.`); - } - return inputAsBuffer; -} -/** - * Transaction enables construction of Algorand transactions - * */ -class Transaction { - constructor({ ...transaction }) { - this.name = 'Transaction'; - this.tag = new TextEncoder().encode('TX'); - // Populate defaults - /* eslint-disable no-param-reassign */ - const defaults = { - type: base_1.TransactionType.pay, - flatFee: false, - nonParticipation: false, - }; - // Default type - if (typeof transaction.type === 'undefined') { - transaction.type = defaults.type; - } - // Default flatFee - if (typeof transaction.flatFee === - 'undefined') { - transaction.flatFee = - defaults.flatFee; - } - // Default nonParticipation - if (transaction.type === base_1.TransactionType.keyreg && - typeof transaction.voteKey !== 'undefined' && - typeof transaction.nonParticipation === 'undefined') { - transaction.nonParticipation = defaults.nonParticipation; - } - /* eslint-enable no-param-reassign */ - // Move suggested parameters from its object to inline - if (transaction.suggestedParams !== undefined) { - // Create a temporary reference to the transaction object that has params inline and also as a suggested params object - // - Helpful for moving params from named object to inline - const reference = transaction; - reference.genesisHash = reference.suggestedParams.genesisHash; - reference.fee = reference.suggestedParams.fee; - if (reference.suggestedParams.flatFee !== undefined) - reference.flatFee = reference.suggestedParams.flatFee; - reference.firstValid = reference.suggestedParams.firstValid; - reference.lastValid = reference.suggestedParams.lastValid; - reference.genesisID = reference.suggestedParams.genesisID; - } - // At this point all suggestedParams have been moved to be inline, so we can reassign the transaction object type - // to one which is more useful as we prepare properties for storing - const txn = transaction; - txn.sender = address.decodeAddress(txn.sender); - if (txn.receiver !== undefined) - txn.receiver = address.decodeAddress(txn.receiver); - if (txn.closeRemainderTo !== undefined) - txn.closeRemainderTo = address.decodeAddress(txn.closeRemainderTo); - if (txn.assetManager !== undefined) - txn.assetManager = address.decodeAddress(txn.assetManager); - if (txn.assetReserve !== undefined) - txn.assetReserve = address.decodeAddress(txn.assetReserve); - if (txn.assetFreeze !== undefined) - txn.assetFreeze = address.decodeAddress(txn.assetFreeze); - if (txn.assetClawback !== undefined) - txn.assetClawback = address.decodeAddress(txn.assetClawback); - if (txn.assetSender !== undefined) - txn.assetSender = address.decodeAddress(txn.assetSender); - if (txn.freezeAccount !== undefined) - txn.freezeAccount = address.decodeAddress(txn.freezeAccount); - if (txn.rekeyTo !== undefined) - txn.rekeyTo = address.decodeAddress(txn.rekeyTo); - if (txn.genesisHash === undefined) - throw Error('genesis hash must be specified and in a base64 string.'); - txn.genesisHash = (0, binarydata_1.base64ToBytes)(txn.genesisHash); - if (txn.amount !== undefined && - (!(Number.isSafeInteger(txn.amount) || - (typeof txn.amount === 'bigint' && - txn.amount <= BigInt('0xffffffffffffffff'))) || - txn.amount < 0)) - throw Error('Amount must be a positive number and smaller than 2^64-1. If the number is larger than 2^53-1, use bigint.'); - if (!Number.isSafeInteger(txn.fee) || txn.fee < 0) - throw Error('fee must be a positive number and smaller than 2^53-1'); - if (!Number.isSafeInteger(txn.firstValid) || txn.firstValid < 0) - throw Error('firstValid must be a positive number'); - if (!Number.isSafeInteger(txn.lastValid) || txn.lastValid < 0) - throw Error('lastValid must be a positive number'); - if (txn.extraPages !== undefined && - (!Number.isInteger(txn.extraPages) || - txn.extraPages < 0 || - txn.extraPages > 3)) - throw Error('extraPages must be an Integer between and including 0 to 3'); - if (txn.assetTotal !== undefined && - (!(Number.isSafeInteger(txn.assetTotal) || - (typeof txn.assetTotal === 'bigint' && - txn.assetTotal <= BigInt('0xffffffffffffffff'))) || - txn.assetTotal < 0)) - throw Error('Total asset issuance must be a positive number and smaller than 2^64-1. If the number is larger than 2^53-1, use bigint.'); - if (txn.assetDecimals !== undefined && - (!Number.isSafeInteger(txn.assetDecimals) || - txn.assetDecimals < 0 || - txn.assetDecimals > ALGORAND_MAX_ASSET_DECIMALS)) - throw Error(`assetDecimals must be a positive number and smaller than ${ALGORAND_MAX_ASSET_DECIMALS.toString()}`); - if (txn.assetIndex !== undefined && - (!Number.isSafeInteger(txn.assetIndex) || txn.assetIndex < 0)) - throw Error('Asset index must be a positive number and smaller than 2^53-1'); - if (txn.appIndex !== undefined && - (!Number.isSafeInteger(txn.appIndex) || txn.appIndex < 0)) - throw Error('Application index must be a positive number and smaller than 2^53-1'); - if (txn.appLocalInts !== undefined && - (!Number.isSafeInteger(txn.appLocalInts) || txn.appLocalInts < 0)) - throw Error('Application local ints count must be a positive number and smaller than 2^53-1'); - if (txn.appLocalByteSlices !== undefined && - (!Number.isSafeInteger(txn.appLocalByteSlices) || - txn.appLocalByteSlices < 0)) - throw Error('Application local byte slices count must be a positive number and smaller than 2^53-1'); - if (txn.appGlobalInts !== undefined && - (!Number.isSafeInteger(txn.appGlobalInts) || txn.appGlobalInts < 0)) - throw Error('Application global ints count must be a positive number and smaller than 2^53-1'); - if (txn.appGlobalByteSlices !== undefined && - (!Number.isSafeInteger(txn.appGlobalByteSlices) || - txn.appGlobalByteSlices < 0)) - throw Error('Application global byte slices count must be a positive number and smaller than 2^53-1'); - if (txn.appApprovalProgram !== undefined) { - if (txn.appApprovalProgram.constructor !== Uint8Array) - throw Error('appApprovalProgram must be a Uint8Array.'); - } - if (txn.appClearProgram !== undefined) { - if (txn.appClearProgram.constructor !== Uint8Array) - throw Error('appClearProgram must be a Uint8Array.'); - } - if (txn.appArgs !== undefined) { - if (!Array.isArray(txn.appArgs)) - throw Error('appArgs must be an Array of Uint8Array.'); - txn.appArgs = txn.appArgs.slice(); - txn.appArgs.forEach((arg) => { - if (arg.constructor !== Uint8Array) - throw Error('each element of AppArgs must be a Uint8Array.'); - }); - } - else { - txn.appArgs = []; - } - if (txn.appAccounts !== undefined) { - if (!Array.isArray(txn.appAccounts)) - throw Error('appAccounts must be an Array of addresses.'); - txn.appAccounts = txn.appAccounts.map((addressAsString) => address.decodeAddress(addressAsString)); - } - if (txn.appForeignApps !== undefined) { - if (!Array.isArray(txn.appForeignApps)) - throw Error('appForeignApps must be an Array of integers.'); - txn.appForeignApps = txn.appForeignApps.slice(); - txn.appForeignApps.forEach((foreignAppIndex) => { - if (!Number.isSafeInteger(foreignAppIndex) || foreignAppIndex < 0) - throw Error('each foreign application index must be a positive number and smaller than 2^53-1'); - }); - } - if (txn.appForeignAssets !== undefined) { - if (!Array.isArray(txn.appForeignAssets)) - throw Error('appForeignAssets must be an Array of integers.'); - txn.appForeignAssets = txn.appForeignAssets.slice(); - txn.appForeignAssets.forEach((foreignAssetIndex) => { - if (!Number.isSafeInteger(foreignAssetIndex) || foreignAssetIndex < 0) - throw Error('each foreign asset index must be a positive number and smaller than 2^53-1'); - }); - } - if (txn.boxes !== undefined) { - if (!Array.isArray(txn.boxes)) - throw Error('boxes must be an Array of BoxReference.'); - txn.boxes = txn.boxes.slice(); - txn.boxes.forEach((box) => { - if (!Number.isSafeInteger(box.appIndex) || - box.name.constructor !== Uint8Array) - throw Error('box app index must be a number and name must be an Uint8Array.'); - }); - } - if (txn.assetMetadataHash !== undefined && - txn.assetMetadataHash.length !== 0) { - if (typeof txn.assetMetadataHash === 'string') { - txn.assetMetadataHash = new Uint8Array(new TextEncoder().encode(txn.assetMetadataHash)); - } - if (txn.assetMetadataHash.constructor !== Uint8Array || - txn.assetMetadataHash.byteLength !== ASSET_METADATA_HASH_LENGTH) { - throw Error(`assetMetadataHash must be a ${ASSET_METADATA_HASH_LENGTH} byte Uint8Array or string.`); - } - if (txn.assetMetadataHash.every((value) => value === 0)) { - // if hash contains all 0s, omit it - txn.assetMetadataHash = undefined; - } - } - else { - txn.assetMetadataHash = undefined; - } - if (txn.note !== undefined) { - if (txn.note.constructor !== Uint8Array) - throw Error('note must be a Uint8Array.'); - } - else { - txn.note = new Uint8Array(0); - } - if (txn.lease !== undefined) { - if (txn.lease.constructor !== Uint8Array) - throw Error('lease must be a Uint8Array.'); - if (txn.lease.length !== ALGORAND_TRANSACTION_LEASE_LENGTH) - throw Error(`lease must be of length ${ALGORAND_TRANSACTION_LEASE_LENGTH.toString()}.`); - if (txn.lease.every((value) => value === 0)) { - // if lease contains all 0s, omit it - txn.lease = new Uint8Array(0); - } - } - else { - txn.lease = new Uint8Array(0); - } - txn.voteKey = getKeyregKey(txn.voteKey, 'voteKey', KEYREG_VOTE_KEY_LENGTH); - txn.selectionKey = getKeyregKey(txn.selectionKey, 'selectionKey', KEYREG_SELECTION_KEY_LENGTH); - txn.stateProofKey = getKeyregKey(txn.stateProofKey, 'stateProofKey', KEYREG_STATE_PROOF_KEY_LENGTH); - // Checking non-participation key registration - if (txn.nonParticipation && - (txn.voteKey || - txn.selectionKey || - txn.voteFirst || - txn.stateProofKey || - txn.voteLast || - txn.voteKeyDilution)) { - throw new Error('nonParticipation is true but participation params are present.'); - } - // Checking online key registration - if (!txn.nonParticipation && - (txn.voteKey || - txn.selectionKey || - txn.stateProofKey || - txn.voteFirst || - txn.voteLast || - txn.voteKeyDilution) && - !(txn.voteKey && - txn.selectionKey && - txn.voteFirst && - txn.voteLast && - txn.voteKeyDilution) - // stateProofKey not included here for backwards compatibility - ) { - throw new Error('online key registration missing at least one of the following fields: ' + - 'voteKey, selectionKey, voteFirst, voteLast, voteKeyDilution'); - } - // The last option is an offline key registration where all the fields - // nonParticipation, voteKey, selectionKey, voteFirst, voteLast, voteKeyDilution - // are all undefined/false - // Remove unwanted properties and store transaction on instance - delete txn.suggestedParams; - Object.assign(this, utils.removeUndefinedProperties(txn)); - // Modify Fee - if (!txn.flatFee) { - this.fee *= this.estimateSize(); - // If suggested fee too small and will be rejected, set to min tx fee - if (this.fee < exports.ALGORAND_MIN_TX_FEE) { - this.fee = exports.ALGORAND_MIN_TX_FEE; - } - } - // say we are aware of groups - this.group = undefined; - // stpf fields - if (txn.stateProofType !== undefined && - (!Number.isSafeInteger(txn.stateProofType) || txn.stateProofType < 0)) - throw Error('State Proof type must be a positive number and smaller than 2^53-1'); - if (txn.stateProofMessage !== undefined) { - if (txn.stateProofMessage.constructor !== Uint8Array) - throw Error('stateProofMessage must be a Uint8Array.'); - } - else { - txn.stateProofMessage = new Uint8Array(0); - } - if (txn.stateProof !== undefined) { - if (txn.stateProof.constructor !== Uint8Array) - throw Error('stateProof must be a Uint8Array.'); - } - else { - txn.stateProof = new Uint8Array(0); - } - } - // eslint-disable-next-line camelcase - get_obj_for_encoding() { - if (this.type === 'pay') { - const txn = { - amt: this.amount, - fee: this.fee, - fv: this.firstValid, - lv: this.lastValid, - note: this.note, - snd: this.sender.publicKey, - type: 'pay', - gen: this.genesisID, - gh: this.genesisHash, - lx: this.lease, - grp: this.group, - }; - // parse close address - if (this.closeRemainderTo !== undefined && - address.encodeAddress(this.closeRemainderTo.publicKey) !== - address.ALGORAND_ZERO_ADDRESS_STRING) { - txn.close = this.closeRemainderTo.publicKey; - } - if (this.rekeyTo !== undefined) { - txn.rekey = this.rekeyTo.publicKey; - } - // allowed zero values - if (this.receiver !== undefined) - txn.rcv = this.receiver.publicKey; - if (!txn.note.length) - delete txn.note; - if (!txn.amt) - delete txn.amt; - if (!txn.fee) - delete txn.fee; - if (!txn.fv) - delete txn.fv; - if (!txn.gen) - delete txn.gen; - if (txn.grp === undefined) - delete txn.grp; - if (!txn.lx.length) - delete txn.lx; - if (!txn.rekey) - delete txn.rekey; - return txn; - } - if (this.type === 'keyreg') { - const txn = { - fee: this.fee, - fv: this.firstValid, - lv: this.lastValid, - note: this.note, - snd: this.sender.publicKey, - type: this.type, - gen: this.genesisID, - gh: this.genesisHash, - lx: this.lease, - grp: this.group, - votekey: this.voteKey, - selkey: this.selectionKey, - sprfkey: this.stateProofKey, - votefst: this.voteFirst, - votelst: this.voteLast, - votekd: this.voteKeyDilution, - }; - // allowed zero values - if (!txn.note.length) - delete txn.note; - if (!txn.lx.length) - delete txn.lx; - if (!txn.fee) - delete txn.fee; - if (!txn.fv) - delete txn.fv; - if (!txn.gen) - delete txn.gen; - if (txn.grp === undefined) - delete txn.grp; - if (this.rekeyTo !== undefined) { - txn.rekey = this.rekeyTo.publicKey; - } - if (this.nonParticipation) { - txn.nonpart = true; - } - if (!txn.selkey) - delete txn.selkey; - if (!txn.votekey) - delete txn.votekey; - if (!txn.sprfkey) - delete txn.sprfkey; - if (!txn.votefst) - delete txn.votefst; - if (!txn.votelst) - delete txn.votelst; - if (!txn.votekd) - delete txn.votekd; - return txn; - } - if (this.type === 'acfg') { - // asset creation, or asset reconfigure, or asset destruction - const txn = { - fee: this.fee, - fv: this.firstValid, - lv: this.lastValid, - note: this.note, - snd: this.sender.publicKey, - type: this.type, - gen: this.genesisID, - gh: this.genesisHash, - lx: this.lease, - grp: this.group, - caid: this.assetIndex, - apar: { - t: this.assetTotal, - df: this.assetDefaultFrozen, - dc: this.assetDecimals, - }, - }; - if (this.assetManager !== undefined) - txn.apar.m = this.assetManager.publicKey; - if (this.assetReserve !== undefined) - txn.apar.r = this.assetReserve.publicKey; - if (this.assetFreeze !== undefined) - txn.apar.f = this.assetFreeze.publicKey; - if (this.assetClawback !== undefined) - txn.apar.c = this.assetClawback.publicKey; - if (this.assetName !== undefined) - txn.apar.an = this.assetName; - if (this.assetUnitName !== undefined) - txn.apar.un = this.assetUnitName; - if (this.assetURL !== undefined) - txn.apar.au = this.assetURL; - if (this.assetMetadataHash !== undefined) - txn.apar.am = this.assetMetadataHash; - // allowed zero values - if (!txn.note.length) - delete txn.note; - if (!txn.lx.length) - delete txn.lx; - if (!txn.amt) - delete txn.amt; - if (!txn.fee) - delete txn.fee; - if (!txn.fv) - delete txn.fv; - if (!txn.gen) - delete txn.gen; - if (this.rekeyTo !== undefined) { - txn.rekey = this.rekeyTo.publicKey; - } - if (!txn.caid) - delete txn.caid; - if (!txn.apar.t && - !txn.apar.un && - !txn.apar.an && - !txn.apar.df && - !txn.apar.m && - !txn.apar.r && - !txn.apar.f && - !txn.apar.c && - !txn.apar.au && - !txn.apar.am && - !txn.apar.dc) { - delete txn.apar; - } - else { - if (!txn.apar.t) - delete txn.apar.t; - if (!txn.apar.dc) - delete txn.apar.dc; - if (!txn.apar.un) - delete txn.apar.un; - if (!txn.apar.an) - delete txn.apar.an; - if (!txn.apar.df) - delete txn.apar.df; - if (!txn.apar.m) - delete txn.apar.m; - if (!txn.apar.r) - delete txn.apar.r; - if (!txn.apar.f) - delete txn.apar.f; - if (!txn.apar.c) - delete txn.apar.c; - if (!txn.apar.au) - delete txn.apar.au; - if (!txn.apar.am) - delete txn.apar.am; - } - if (txn.grp === undefined) - delete txn.grp; - return txn; - } - if (this.type === 'axfer') { - // asset transfer, acceptance, revocation, mint, or burn - const txn = { - aamt: this.amount, - fee: this.fee, - fv: this.firstValid, - lv: this.lastValid, - note: this.note, - snd: this.sender.publicKey, - arcv: this.receiver.publicKey, - type: this.type, - gen: this.genesisID, - gh: this.genesisHash, - lx: this.lease, - grp: this.group, - xaid: this.assetIndex, - }; - if (this.closeRemainderTo !== undefined) - txn.aclose = this.closeRemainderTo.publicKey; - if (this.assetSender !== undefined) - txn.asnd = this.assetSender.publicKey; - // allowed zero values - if (!txn.note.length) - delete txn.note; - if (!txn.lx.length) - delete txn.lx; - if (!txn.aamt) - delete txn.aamt; - if (!txn.amt) - delete txn.amt; - if (!txn.fee) - delete txn.fee; - if (!txn.fv) - delete txn.fv; - if (!txn.gen) - delete txn.gen; - if (txn.grp === undefined) - delete txn.grp; - if (!txn.aclose) - delete txn.aclose; - if (!txn.asnd) - delete txn.asnd; - if (!txn.rekey) - delete txn.rekey; - if (this.rekeyTo !== undefined) { - txn.rekey = this.rekeyTo.publicKey; - } - return txn; - } - if (this.type === 'afrz') { - // asset freeze or unfreeze - const txn = { - fee: this.fee, - fv: this.firstValid, - lv: this.lastValid, - note: this.note, - snd: this.sender.publicKey, - type: this.type, - gen: this.genesisID, - gh: this.genesisHash, - lx: this.lease, - grp: this.group, - faid: this.assetIndex, - afrz: this.assetFrozen, - }; - if (this.freezeAccount !== undefined) - txn.fadd = this.freezeAccount.publicKey; - // allowed zero values - if (!txn.note.length) - delete txn.note; - if (!txn.lx.length) - delete txn.lx; - if (!txn.amt) - delete txn.amt; - if (!txn.fee) - delete txn.fee; - if (!txn.fv) - delete txn.fv; - if (!txn.gen) - delete txn.gen; - if (!txn.afrz) - delete txn.afrz; - if (txn.grp === undefined) - delete txn.grp; - if (this.rekeyTo !== undefined) { - txn.rekey = this.rekeyTo.publicKey; - } - return txn; - } - if (this.type === 'appl') { - // application call of some kind - const txn = { - fee: this.fee, - fv: this.firstValid, - lv: this.lastValid, - note: this.note, - snd: this.sender.publicKey, - type: this.type, - gen: this.genesisID, - gh: this.genesisHash, - lx: this.lease, - grp: this.group, - apid: this.appIndex, - apan: this.appOnComplete, - apls: { - nui: this.appLocalInts, - nbs: this.appLocalByteSlices, - }, - apgs: { - nui: this.appGlobalInts, - nbs: this.appGlobalByteSlices, - }, - apfa: this.appForeignApps, - apas: this.appForeignAssets, - apep: this.extraPages, - apbx: (0, boxStorage_1.translateBoxReferences)(this.boxes, this.appForeignApps, this.appIndex), - }; - if (this.rekeyTo !== undefined) { - txn.rekey = this.rekeyTo.publicKey; - } - if (this.appApprovalProgram !== undefined) { - txn.apap = this.appApprovalProgram; - } - if (this.appClearProgram !== undefined) { - txn.apsu = this.appClearProgram; - } - if (this.appArgs !== undefined) { - txn.apaa = this.appArgs; - } - if (this.appAccounts !== undefined) { - txn.apat = this.appAccounts.map((decodedAddress) => decodedAddress.publicKey); - } - // allowed zero values - if (!txn.note.length) - delete txn.note; - if (!txn.lx.length) - delete txn.lx; - if (!txn.amt) - delete txn.amt; - if (!txn.fee) - delete txn.fee; - if (!txn.fv) - delete txn.fv; - if (!txn.gen) - delete txn.gen; - if (!txn.apid) - delete txn.apid; - if (!txn.apls.nui) - delete txn.apls.nui; - if (!txn.apls.nbs) - delete txn.apls.nbs; - if (!txn.apls.nui && !txn.apls.nbs) - delete txn.apls; - if (!txn.apgs.nui) - delete txn.apgs.nui; - if (!txn.apgs.nbs) - delete txn.apgs.nbs; - if (!txn.apaa || !txn.apaa.length) - delete txn.apaa; - if (!txn.apgs.nui && !txn.apgs.nbs) - delete txn.apgs; - if (!txn.apap) - delete txn.apap; - if (!txn.apsu) - delete txn.apsu; - if (!txn.apan) - delete txn.apan; - if (!txn.apfa || !txn.apfa.length) - delete txn.apfa; - if (!txn.apas || !txn.apas.length) - delete txn.apas; - for (const box of txn.apbx) { - if (!box.i) - delete box.i; - if (!box.n || !box.n.length) - delete box.n; - } - if (!txn.apbx || !txn.apbx.length) - delete txn.apbx; - if (!txn.apat || !txn.apat.length) - delete txn.apat; - if (!txn.apep) - delete txn.apep; - if (txn.grp === undefined) - delete txn.grp; - return txn; - } - if (this.type === 'stpf') { - // state proof txn - const txn = { - fee: this.fee, - fv: this.firstValid, - lv: this.lastValid, - note: this.note, - snd: this.sender.publicKey, - type: this.type, - gen: this.genesisID, - gh: this.genesisHash, - lx: this.lease, - sptype: this.stateProofType, - spmsg: this.stateProofMessage, - sp: this.stateProof, - }; - // allowed zero values - if (!txn.sptype) - delete txn.sptype; - if (!txn.note.length) - delete txn.note; - if (!txn.lx.length) - delete txn.lx; - if (!txn.amt) - delete txn.amt; - if (!txn.fee) - delete txn.fee; - if (!txn.fv) - delete txn.fv; - if (!txn.gen) - delete txn.gen; - if (!txn.apid) - delete txn.apid; - if (!txn.apaa || !txn.apaa.length) - delete txn.apaa; - if (!txn.apap) - delete txn.apap; - if (!txn.apsu) - delete txn.apsu; - if (!txn.apan) - delete txn.apan; - if (!txn.apfa || !txn.apfa.length) - delete txn.apfa; - if (!txn.apas || !txn.apas.length) - delete txn.apas; - if (!txn.apat || !txn.apat.length) - delete txn.apat; - if (!txn.apep) - delete txn.apep; - if (txn.grp === undefined) - delete txn.grp; - return txn; - } - return undefined; - } - // eslint-disable-next-line camelcase - static from_obj_for_encoding(txnForEnc) { - const txn = Object.create(this.prototype); - txn.name = 'Transaction'; - txn.tag = new TextEncoder().encode('TX'); - txn.genesisID = txnForEnc.gen; - txn.genesisHash = txnForEnc.gh; - if (!(0, base_1.isTransactionType)(txnForEnc.type)) { - throw new Error(`Unrecognized transaction type: ${txnForEnc.type}`); - } - txn.type = txnForEnc.type; - txn.fee = txnForEnc.fee; - txn.firstValid = txnForEnc.fv; - txn.lastValid = txnForEnc.lv; - txn.note = new Uint8Array(txnForEnc.note); - txn.lease = new Uint8Array(txnForEnc.lx); - txn.sender = address.decodeAddress(address.encodeAddress(new Uint8Array(txnForEnc.snd))); - if (txnForEnc.grp !== undefined) - txn.group = txnForEnc.grp; - if (txnForEnc.rekey !== undefined) - txn.rekeyTo = address.decodeAddress(address.encodeAddress(new Uint8Array(txnForEnc.rekey))); - if (txnForEnc.type === 'pay') { - txn.amount = txnForEnc.amt; - txn.receiver = address.decodeAddress(address.encodeAddress(new Uint8Array(txnForEnc.rcv))); - if (txnForEnc.close !== undefined) - txn.closeRemainderTo = address.decodeAddress(address.encodeAddress(txnForEnc.close)); - } - else if (txnForEnc.type === 'keyreg') { - if (txnForEnc.votekey !== undefined) { - txn.voteKey = txnForEnc.votekey; - } - if (txnForEnc.selkey !== undefined) { - txn.selectionKey = txnForEnc.selkey; - } - if (txnForEnc.sprfkey !== undefined) { - txn.stateProofKey = txnForEnc.sprfkey; - } - if (txnForEnc.votekd !== undefined) { - txn.voteKeyDilution = txnForEnc.votekd; - } - if (txnForEnc.votefst !== undefined) { - txn.voteFirst = txnForEnc.votefst; - } - if (txnForEnc.votelst !== undefined) { - txn.voteLast = txnForEnc.votelst; - } - if (txnForEnc.nonpart !== undefined) { - txn.nonParticipation = txnForEnc.nonpart; - } - } - else if (txnForEnc.type === 'acfg') { - // asset creation, or asset reconfigure, or asset destruction - if (txnForEnc.caid !== undefined) { - txn.assetIndex = txnForEnc.caid; - } - if (txnForEnc.apar !== undefined) { - txn.assetTotal = txnForEnc.apar.t; - txn.assetDefaultFrozen = txnForEnc.apar.df; - if (txnForEnc.apar.dc !== undefined) - txn.assetDecimals = txnForEnc.apar.dc; - if (txnForEnc.apar.m !== undefined) - txn.assetManager = address.decodeAddress(address.encodeAddress(new Uint8Array(txnForEnc.apar.m))); - if (txnForEnc.apar.r !== undefined) - txn.assetReserve = address.decodeAddress(address.encodeAddress(new Uint8Array(txnForEnc.apar.r))); - if (txnForEnc.apar.f !== undefined) - txn.assetFreeze = address.decodeAddress(address.encodeAddress(new Uint8Array(txnForEnc.apar.f))); - if (txnForEnc.apar.c !== undefined) - txn.assetClawback = address.decodeAddress(address.encodeAddress(new Uint8Array(txnForEnc.apar.c))); - if (txnForEnc.apar.un !== undefined) - txn.assetUnitName = txnForEnc.apar.un; - if (txnForEnc.apar.an !== undefined) - txn.assetName = txnForEnc.apar.an; - if (txnForEnc.apar.au !== undefined) - txn.assetURL = txnForEnc.apar.au; - if (txnForEnc.apar.am !== undefined) - txn.assetMetadataHash = txnForEnc.apar.am; - } - } - else if (txnForEnc.type === 'axfer') { - // asset transfer, acceptance, revocation, mint, or burn - if (txnForEnc.xaid !== undefined) { - txn.assetIndex = txnForEnc.xaid; - } - if (txnForEnc.aamt !== undefined) - txn.amount = txnForEnc.aamt; - if (txnForEnc.aclose !== undefined) { - txn.closeRemainderTo = address.decodeAddress(address.encodeAddress(new Uint8Array(txnForEnc.aclose))); - } - if (txnForEnc.asnd !== undefined) { - txn.assetSender = address.decodeAddress(address.encodeAddress(new Uint8Array(txnForEnc.asnd))); - } - txn.receiver = address.decodeAddress(address.encodeAddress(new Uint8Array(txnForEnc.arcv))); - } - else if (txnForEnc.type === 'afrz') { - if (txnForEnc.afrz !== undefined) { - txn.assetFrozen = txnForEnc.afrz; - } - if (txnForEnc.faid !== undefined) { - txn.assetIndex = txnForEnc.faid; - } - txn.freezeAccount = address.decodeAddress(address.encodeAddress(new Uint8Array(txnForEnc.fadd))); - } - else if (txnForEnc.type === 'appl') { - if (txnForEnc.apid !== undefined) { - txn.appIndex = txnForEnc.apid; - } - if (txnForEnc.apan !== undefined) { - txn.appOnComplete = txnForEnc.apan; - } - if (txnForEnc.apls !== undefined) { - if (txnForEnc.apls.nui !== undefined) - txn.appLocalInts = txnForEnc.apls.nui; - if (txnForEnc.apls.nbs !== undefined) - txn.appLocalByteSlices = txnForEnc.apls.nbs; - } - if (txnForEnc.apgs !== undefined) { - if (txnForEnc.apgs.nui !== undefined) - txn.appGlobalInts = txnForEnc.apgs.nui; - if (txnForEnc.apgs.nbs !== undefined) - txn.appGlobalByteSlices = txnForEnc.apgs.nbs; - } - if (txnForEnc.apep !== undefined) { - txn.extraPages = txnForEnc.apep; - } - if (txnForEnc.apap !== undefined) { - txn.appApprovalProgram = new Uint8Array(txnForEnc.apap); - } - if (txnForEnc.apsu !== undefined) { - txn.appClearProgram = new Uint8Array(txnForEnc.apsu); - } - if (txnForEnc.apaa !== undefined) { - txn.appArgs = txnForEnc.apaa.map((arg) => new Uint8Array(arg)); - } - if (txnForEnc.apat !== undefined) { - txn.appAccounts = txnForEnc.apat.map((addressBytes) => address.decodeAddress(address.encodeAddress(new Uint8Array(addressBytes)))); - } - if (txnForEnc.apfa !== undefined) { - txn.appForeignApps = txnForEnc.apfa; - } - if (txnForEnc.apas !== undefined) { - txn.appForeignAssets = txnForEnc.apas; - } - if (txnForEnc.apbx !== undefined) { - txn.boxes = txnForEnc.apbx.map((box) => ({ - // We return 0 for the app ID so that it's guaranteed translateBoxReferences will - // translate the app index back to 0. If we instead returned the called app ID, - // translateBoxReferences would translate the app index to a nonzero value if the called - // app is also in the foreign app array. - appIndex: box.i ? txn.appForeignApps[box.i - 1] : 0, - name: box.n, - })); - } - } - else if (txnForEnc.type === 'stpf') { - if (txnForEnc.sptype !== undefined) { - txn.stateProofType = txnForEnc.sptype; - } - if (txnForEnc.sp !== undefined) { - txn.stateProof = txnForEnc.sp; - } - if (txnForEnc.spmsg !== undefined) { - txn.stateProofMessage = txnForEnc.spmsg; - } - } - return txn; - } - estimateSize() { - return this.toByte().length + NUM_ADDL_BYTES_AFTER_SIGNING; - } - bytesToSign() { - const encodedMsg = this.toByte(); - return utils.concatArrays(this.tag, encodedMsg); - } - toByte() { - return encoding.encode(this.get_obj_for_encoding()); - } - // returns the raw signature - rawSignTxn(sk) { - const toBeSigned = this.bytesToSign(); - const sig = nacl.sign(toBeSigned, sk); - return sig; - } - signTxn(sk) { - // construct signed message - const sTxn = { - sig: this.rawSignTxn(sk), - txn: this.get_obj_for_encoding(), - }; - // add AuthAddr if signing with a different key than sender indicates - const keypair = nacl.keyPairFromSecretKey(sk); - const pubKeyFromSk = keypair.publicKey; - if (address.encodeAddress(pubKeyFromSk) !== - address.encodeAddress(this.sender.publicKey)) { - sTxn.sgnr = pubKeyFromSk; - } - return new Uint8Array(encoding.encode(sTxn)); - } - attachSignature(signerAddr, signature) { - if (!nacl.isValidSignatureLength(signature.length)) { - throw new Error('Invalid signature length'); - } - const sTxn = { - sig: signature, - txn: this.get_obj_for_encoding(), - }; - // add AuthAddr if signing with a different key than From indicates - if (signerAddr !== address.encodeAddress(this.sender.publicKey)) { - const signerPublicKey = address.decodeAddress(signerAddr).publicKey; - sTxn.sgnr = signerPublicKey; - } - return new Uint8Array(encoding.encode(sTxn)); - } - rawTxID() { - const enMsg = this.toByte(); - const gh = utils.concatArrays(this.tag, enMsg); - return Uint8Array.from(nacl.genericHash(gh)); - } - txID() { - const hash = this.rawTxID(); - return hi_base32_1.default.encode(hash).slice(0, ALGORAND_TRANSACTION_LENGTH); - } - // add a lease to a transaction not yet having - // supply feePerByte to increment fee accordingly - addLease(lease, feePerByte = 0) { - let mutableLease; - if (lease !== undefined) { - if (lease.constructor !== Uint8Array) - throw Error('lease must be a Uint8Array.'); - if (lease.length !== ALGORAND_TRANSACTION_LEASE_LENGTH) - throw Error(`lease must be of length ${ALGORAND_TRANSACTION_LEASE_LENGTH.toString()}.`); - mutableLease = new Uint8Array(lease); - } - else { - mutableLease = new Uint8Array(0); - } - this.lease = mutableLease; - if (feePerByte !== 0) { - this.fee += - (ALGORAND_TRANSACTION_LEASE_LABEL_LENGTH + - ALGORAND_TRANSACTION_LEASE_LENGTH) * - feePerByte; - } - } - // add the rekey-to field to a transaction not yet having it - // supply feePerByte to increment fee accordingly - addRekey(rekeyTo, feePerByte = 0) { - if (rekeyTo !== undefined) { - this.rekeyTo = address.decodeAddress(rekeyTo); - } - if (feePerByte !== 0) { - this.fee += - (ALGORAND_TRANSACTION_REKEY_LABEL_LENGTH + - ALGORAND_TRANSACTION_ADDRESS_LENGTH) * - feePerByte; - } - } - // build display dict for prettyPrint and toString - // eslint-disable-next-line no-underscore-dangle - _getDictForDisplay() { - const forPrinting = { - ...this, - }; - forPrinting.tag = forPrinting.tag.toString(); - forPrinting.sender = address.encodeAddress(forPrinting.sender.publicKey); - if (forPrinting.receiver !== undefined) - forPrinting.receiver = address.encodeAddress(forPrinting.receiver.publicKey); - // things that need fixing: - if (forPrinting.freezeAccount !== undefined) - forPrinting.freezeAccount = address.encodeAddress(forPrinting.freezeAccount.publicKey); - if (forPrinting.closeRemainderTo !== undefined) - forPrinting.closeRemainderTo = address.encodeAddress(forPrinting.closeRemainderTo.publicKey); - if (forPrinting.assetManager !== undefined) - forPrinting.assetManager = address.encodeAddress(forPrinting.assetManager.publicKey); - if (forPrinting.assetReserve !== undefined) - forPrinting.assetReserve = address.encodeAddress(forPrinting.assetReserve.publicKey); - if (forPrinting.assetFreeze !== undefined) - forPrinting.assetFreeze = address.encodeAddress(forPrinting.assetFreeze.publicKey); - if (forPrinting.assetClawback !== undefined) - forPrinting.assetClawback = address.encodeAddress(forPrinting.assetClawback.publicKey); - if (forPrinting.assetSender !== undefined) - forPrinting.assetSender = address.encodeAddress(forPrinting.assetSender.publicKey); - if (forPrinting.rekeyTo !== undefined) - forPrinting.rekeyTo = address.encodeAddress(forPrinting.rekeyTo.publicKey); - if (typeof forPrinting.genesisHash !== 'string') - forPrinting.genesisHash = (0, binarydata_1.bytesToBase64)(forPrinting.genesisHash); - return forPrinting; - } - // pretty print the transaction to console - prettyPrint() { - // eslint-disable-next-line no-underscore-dangle,no-console - console.log(this._getDictForDisplay()); - } - // get string representation - toString() { - // eslint-disable-next-line no-underscore-dangle - return JSON.stringify(this._getDictForDisplay()); - } -} -exports.Transaction = Transaction; -/** - * encodeUnsignedSimulateTransaction takes a txnBuilder.Transaction object, - * converts it into a SignedTransaction-like object, and converts it to a Buffer. - * - * Note: this function should only be used to simulate unsigned transactions. - * - * @param transactionObject - Transaction object to simulate. - */ -function encodeUnsignedSimulateTransaction(transactionObject) { - const objToEncode = { - txn: transactionObject.get_obj_for_encoding(), - }; - return encoding.encode(objToEncode); -} -exports.encodeUnsignedSimulateTransaction = encodeUnsignedSimulateTransaction; -/** - * encodeUnsignedTransaction takes a completed txnBuilder.Transaction object, such as from the makeFoo - * family of transactions, and converts it to a Buffer - * @param transactionObject - the completed Transaction object - */ -function encodeUnsignedTransaction(transactionObject) { - const objToEncode = transactionObject.get_obj_for_encoding(); - return encoding.encode(objToEncode); -} -exports.encodeUnsignedTransaction = encodeUnsignedTransaction; -/** - * decodeUnsignedTransaction takes a Uint8Array (as if from encodeUnsignedTransaction) and converts it to a txnBuilder.Transaction object - * @param transactionBuffer - the Uint8Array containing a transaction - */ -function decodeUnsignedTransaction(transactionBuffer) { - const partlyDecodedObject = encoding.decode(transactionBuffer); - return Transaction.from_obj_for_encoding(partlyDecodedObject); -} -exports.decodeUnsignedTransaction = decodeUnsignedTransaction; -/** - * decodeSignedTransaction takes a Uint8Array (from transaction.signTxn) and converts it to an object - * containing the Transaction (txn), the signature (sig), and the auth-addr field if applicable (sgnr) - * @param transactionBuffer - the Uint8Array containing a transaction - * @returns containing a Transaction, the signature, and possibly an auth-addr field - */ -function decodeSignedTransaction(transactionBuffer) { - const stxnDecoded = encoding.decode(transactionBuffer); - const stxn = { - ...stxnDecoded, - txn: Transaction.from_obj_for_encoding(stxnDecoded.txn), - }; - return stxn; -} -exports.decodeSignedTransaction = decodeSignedTransaction; -function instantiateTxnIfNeeded(transactionLike) { - return transactionLike instanceof Transaction - ? transactionLike - : new Transaction(transactionLike); -} -exports.instantiateTxnIfNeeded = instantiateTxnIfNeeded; -exports.default = Transaction; diff --git a/algosdk/types/account.d.ts b/algosdk/types/account.d.ts deleted file mode 100644 index daadf9a..0000000 --- a/algosdk/types/account.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -/** - * An Algorand account object. - * - * Contains an Algorand address and secret key. - */ -export default interface Account { - /** - * Algorand address - */ - addr: string; - /** - * Secret key belonging to the Algorand address - */ - sk: Uint8Array; -} diff --git a/algosdk/types/account.js b/algosdk/types/account.js deleted file mode 100644 index c8ad2e5..0000000 --- a/algosdk/types/account.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/algosdk/types/address.d.ts b/algosdk/types/address.d.ts deleted file mode 100644 index 54b00d8..0000000 --- a/algosdk/types/address.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Decoded Algorand address. Includes public key and checksum. - */ -export interface Address { - publicKey: Uint8Array; - checksum: Uint8Array; -} diff --git a/algosdk/types/address.js b/algosdk/types/address.js deleted file mode 100644 index c8ad2e5..0000000 --- a/algosdk/types/address.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/algosdk/types/blockHeader.d.ts b/algosdk/types/blockHeader.d.ts deleted file mode 100644 index ca5d70d..0000000 --- a/algosdk/types/blockHeader.d.ts +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Represents the metadata and state of a block. - * - * For more information, refer to: https://github.com/algorand/go-algorand/blob/master/data/bookkeeping/block.go - */ -export default interface BlockHeader { - /** - * Transaction fees - */ - fees: string; - /** - * The number of leftover MicroAlgos after rewards distribution - */ - frac: number; - /** - * Genesis ID to which this block belongs - */ - gen: string; - /** - * Genesis hash to which this block belongs. - */ - gh: string; - /** - * The hash of the previous block - */ - prev: string; - /** - * Current protocol - */ - proto: string; - /** - * Rewards rate - */ - rate: number; - /** - * Round number - */ - rnd: number; - /** - * Rewards recalculation round - */ - rwcalr: number; - /** - * Rewards pool - */ - rwd: string; - /** - * Sortition seed - */ - seed: string; - /** - * Timestamp in seconds since epoch - */ - ts: number; - /** - * Transaction root SHA512_256 - */ - txn: string; - /** - * Transaction root SHA256 - */ - txn256: string; - /** - * StateProofTracking map of type to tracking data - */ - spt: Map; -} diff --git a/algosdk/types/blockHeader.js b/algosdk/types/blockHeader.js deleted file mode 100644 index c8ad2e5..0000000 --- a/algosdk/types/blockHeader.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/algosdk/types/index.d.ts b/algosdk/types/index.d.ts deleted file mode 100644 index d7657e8..0000000 --- a/algosdk/types/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './transactions'; -export * from './multisig'; -export * from './address'; diff --git a/algosdk/types/index.js b/algosdk/types/index.js deleted file mode 100644 index f46f68f..0000000 --- a/algosdk/types/index.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -__exportStar(require("./transactions"), exports); -__exportStar(require("./multisig"), exports); -__exportStar(require("./address"), exports); diff --git a/algosdk/types/intDecoding.d.ts b/algosdk/types/intDecoding.d.ts deleted file mode 100644 index 57a481b..0000000 --- a/algosdk/types/intDecoding.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Configure how integers in JSON response will be decoded. - */ -declare enum IntDecoding { - /** - * All integers will be decoded as Numbers, meaning any values greater than - * Number.MAX_SAFE_INTEGER will lose precision. - */ - DEFAULT = "default", - /** - * All integers will be decoded as Numbers, but if any values are greater than - * Number.MAX_SAFE_INTEGER an error will be thrown. - */ - SAFE = "safe", - /** - * Integers will be decoded as Numbers if they are less than or equal to - * Number.MAX_SAFE_INTEGER, otherwise they will be decoded as BigInts. - */ - MIXED = "mixed", - /** - * All integers will be decoded as BigInts. - */ - BIGINT = "bigint" -} -export default IntDecoding; diff --git a/algosdk/types/intDecoding.js b/algosdk/types/intDecoding.js deleted file mode 100644 index e3ec05c..0000000 --- a/algosdk/types/intDecoding.js +++ /dev/null @@ -1,28 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -/** - * Configure how integers in JSON response will be decoded. - */ -var IntDecoding; -(function (IntDecoding) { - /** - * All integers will be decoded as Numbers, meaning any values greater than - * Number.MAX_SAFE_INTEGER will lose precision. - */ - IntDecoding["DEFAULT"] = "default"; - /** - * All integers will be decoded as Numbers, but if any values are greater than - * Number.MAX_SAFE_INTEGER an error will be thrown. - */ - IntDecoding["SAFE"] = "safe"; - /** - * Integers will be decoded as Numbers if they are less than or equal to - * Number.MAX_SAFE_INTEGER, otherwise they will be decoded as BigInts. - */ - IntDecoding["MIXED"] = "mixed"; - /** - * All integers will be decoded as BigInts. - */ - IntDecoding["BIGINT"] = "bigint"; -})(IntDecoding || (IntDecoding = {})); -exports.default = IntDecoding; diff --git a/algosdk/types/multisig.d.ts b/algosdk/types/multisig.d.ts deleted file mode 100644 index e5f6a3a..0000000 --- a/algosdk/types/multisig.d.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Required options for creating a multisignature - * - * Documentation available at: https://developer.algorand.org/docs/features/transactions/signatures/#multisignatures - */ -export interface MultisigMetadata { - /** - * Multisig version - */ - version: number; - /** - * Multisig threshold value. Authorization requires a subset of signatures, - * equal to or greater than the threshold value. - */ - threshold: number; - /** - * A list of Algorand addresses representing possible signers for this multisig. Order is important. - */ - addrs: string[]; -} diff --git a/algosdk/types/multisig.js b/algosdk/types/multisig.js deleted file mode 100644 index c8ad2e5..0000000 --- a/algosdk/types/multisig.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/algosdk/types/transactions/application.d.ts b/algosdk/types/transactions/application.d.ts deleted file mode 100644 index 305b6af..0000000 --- a/algosdk/types/transactions/application.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { TransactionType, TransactionParams } from './base'; -import { ConstructTransaction } from './builder'; -declare type SpecificParametersForCreate = Pick; -interface OverwritesForCreate { - type?: TransactionType.appl; -} -export declare type ApplicationCreateTransaction = ConstructTransaction; -declare type SpecificParametersForUpdate = Pick; -interface OverwritesForUpdate { - type?: TransactionType.appl; -} -export declare type ApplicationUpdateTransaction = ConstructTransaction; -declare type SpecificParametersForDelete = Pick; -interface OverwritesForDelete { - type?: TransactionType.appl; -} -export declare type ApplicationDeleteTransaction = ConstructTransaction; -export declare type ApplicationOptInTransaction = ApplicationDeleteTransaction; -export declare type ApplicationCloseOutTransaction = ApplicationDeleteTransaction; -export declare type ApplicationClearStateTransaction = ApplicationDeleteTransaction; -export declare type ApplicationNoOpTransaction = ApplicationDeleteTransaction; -export {}; diff --git a/algosdk/types/transactions/application.js b/algosdk/types/transactions/application.js deleted file mode 100644 index c8ad2e5..0000000 --- a/algosdk/types/transactions/application.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/algosdk/types/transactions/asset.d.ts b/algosdk/types/transactions/asset.d.ts deleted file mode 100644 index 0901a43..0000000 --- a/algosdk/types/transactions/asset.d.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { TransactionType, TransactionParams } from './base'; -import { ConstructTransaction } from './builder'; -declare type SpecificParametersForCreate = Pick; -interface OverwritesForCreate { - type?: TransactionType.acfg; -} -export declare type AssetCreateTransaction = ConstructTransaction; -declare type SpecificParametersForConfig = Pick; -interface OverwritesForConfig { - type?: TransactionType.acfg; -} -export declare type AssetConfigurationTransaction = ConstructTransaction; -declare type SpecificParametersForDestroy = Pick; -interface OverwritesForDestroy { - type?: TransactionType.acfg; -} -export declare type AssetDestroyTransaction = ConstructTransaction; -declare type SpecificParametersForFreeze = Pick; -interface OverwritesForFreeze { - type?: TransactionType.afrz; -} -export declare type AssetFreezeTransaction = ConstructTransaction; -declare type SpecificParametersForTransfer = Pick; -interface OverwritesForTransfer { - type?: TransactionType.axfer; -} -export declare type AssetTransferTransaction = ConstructTransaction; -export {}; diff --git a/algosdk/types/transactions/asset.js b/algosdk/types/transactions/asset.js deleted file mode 100644 index c8ad2e5..0000000 --- a/algosdk/types/transactions/asset.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/algosdk/types/transactions/base.d.ts b/algosdk/types/transactions/base.d.ts deleted file mode 100644 index 723af42..0000000 --- a/algosdk/types/transactions/base.d.ts +++ /dev/null @@ -1,348 +0,0 @@ -/** - * Enum for application transaction types. - * - * The full list is available at https://developer.algorand.org/docs/reference/transactions/ - */ -export declare enum TransactionType { - /** - * Payment transaction - */ - pay = "pay", - /** - * Key registration transaction - */ - keyreg = "keyreg", - /** - * Asset configuration transaction - */ - acfg = "acfg", - /** - * Asset transfer transaction - */ - axfer = "axfer", - /** - * Asset freeze transaction - */ - afrz = "afrz", - /** - * Application transaction - */ - appl = "appl", - /** - * State proof transaction - */ - stpf = "stpf" -} -export declare function isTransactionType(s: string): s is TransactionType; -/** - * Enums for application transactions on-transaction-complete behavior - */ -export declare enum OnApplicationComplete { - /** - * NoOpOC indicates that an application transaction will simply call its - * ApprovalProgram - */ - NoOpOC = 0, - /** - * OptInOC indicates that an application transaction will allocate some - * LocalState for the application in the sender's account - */ - OptInOC = 1, - /** - * CloseOutOC indicates that an application transaction will deallocate - * some LocalState for the application from the user's account - */ - CloseOutOC = 2, - /** - * ClearStateOC is similar to CloseOutOC, but may never fail. This - * allows users to reclaim their minimum balance from an application - * they no longer wish to opt in to. - */ - ClearStateOC = 3, - /** - * UpdateApplicationOC indicates that an application transaction will - * update the ApprovalProgram and ClearStateProgram for the application - */ - UpdateApplicationOC = 4, - /** - * DeleteApplicationOC indicates that an application transaction will - * delete the AppParams for the application from the creator's balance - * record - */ - DeleteApplicationOC = 5 -} -/** - * A dict holding common-to-all-txns arguments - */ -export interface SuggestedParams { - /** - * Set this to true to specify fee as microalgos-per-txn - * If the final calculated fee is lower than the protocol minimum fee, the fee will be increased to match the minimum - */ - flatFee?: boolean; - /** - * Integer fee per byte, in microAlgos. For a flat fee, set flatFee to true - */ - fee: number; - /** - * First protocol round on which this txn is valid - */ - firstValid: number; - /** - * Last protocol round on which this txn is valid - */ - lastValid: number; - /** - * Specifies genesis ID of network in use - */ - genesisID: string; - /** - * Specifies hash genesis block of network in use - */ - genesisHash: string; -} -export declare type SuggestedParamsWithMinFee = SuggestedParams & { - /** - * Minimum fee (not per byte) required for the transaction to be confirmed - */ - minFee: number; -}; -/** - * A grouping of the app ID and name of the box in an Uint8Array - */ -export interface BoxReference { - /** - * A unique application index - */ - appIndex: number; - /** - * Name of box to reference - */ - name: Uint8Array; -} -/** - * A full list of all available transaction parameters - * - * The full documentation is available at: - * https://developer.algorand.org/docs/reference/transactions/#common-fields-header-and-type - */ -export interface TransactionParams { - /** - * String representation of Algorand address of sender - */ - sender: string; - /** - * String representation of Algorand address of recipient - */ - receiver: string; - /** - * Integer fee per byte, in microAlgos. For a flat fee, set flatFee to true - */ - fee: number; - /** - * Integer amount to send - */ - amount: number | bigint; - /** - * Integer first protocol round on which this txn is valid - */ - firstValid: number; - /** - * Integer last protocol round on which this txn is valid - */ - lastValid: number; - /** - * Arbitrary data for sender to store - */ - note?: Uint8Array; - /** - * Specifies genesis ID of network in use - */ - genesisID: string; - /** - * Specifies hash genesis block of network in use - */ - genesisHash: string; - /** - * Lease a transaction. The sender cannot send another txn with that same lease until the last round of original txn has passed - */ - lease?: Uint8Array; - /** - * Close out remaining account balance to this account - */ - closeRemainderTo?: string; - /** - * Voting key bytes. For key deregistration, leave undefined - */ - voteKey: Uint8Array | string; - /** - *Selection key bytes. For key deregistration, leave undefined - */ - selectionKey: Uint8Array | string; - /** - * State proof key bytes. For key deregistration, leave undefined - */ - stateProofKey: Uint8Array | string; - /** - * First round on which voteKey is valid - */ - voteFirst: number; - /** - * Last round on which voteKey is valid - */ - voteLast: number; - /** - * The dilution fo the 2-level participation key - */ - voteKeyDilution: number; - /** - * Asset index uniquely specifying the asset - */ - assetIndex: number; - /** - * Total supply of the asset - */ - assetTotal: number | bigint; - /** - * Integer number of decimals for asset unit calcuation - */ - assetDecimals: number; - /** - * Whether asset accounts should default to being frozen - */ - assetDefaultFrozen: boolean; - /** - * String representation of Algorand address in charge of reserve, freeze, clawback, destruction, etc. - */ - assetManager?: string; - /** - * String representation of Algorand address representing asset reserve - */ - assetReserve?: string; - /** - * String representation of Algorand address with power to freeze/unfreeze asset holdings - */ - assetFreeze?: string; - /** - * String representation of Algorand address with power to revoke asset holdings - */ - assetClawback?: string; - /** - * Unit name for this asset - */ - assetUnitName?: string; - /** - * Name for this asset - */ - assetName?: string; - /** - * URL relating to this asset - */ - assetURL?: string; - /** - * Uint8Array or UTF-8 string representation of a hash commitment with respect to the asset. Must be exactly 32 bytes long. - */ - assetMetadataHash?: Uint8Array | string; - /** - * String representation of Algorand address being frozen or unfrozen - */ - freezeAccount: string; - /** - * true if freezeTarget should be frozen, false if freezeTarget should be allowed to transact - */ - assetFrozen: boolean; - /** - * String representation of Algorand address – if provided, and if "sender" is - * the asset's revocation manager, then deduct from "assetSender" rather than "sender" - */ - assetSender?: string; - /** - * A unique application index - */ - appIndex: number; - /** - * What application should do once the program has been run - */ - appOnComplete: OnApplicationComplete; - /** - * Restricts number of ints in per-user local state - */ - appLocalInts: number; - /** - * Restricts number of byte slices in per-user local state - */ - appLocalByteSlices: number; - /** - * Restricts number of ints in global state - */ - appGlobalInts: number; - /** - * Restricts number of byte slices in global state - */ - appGlobalByteSlices: number; - /** - * The compiled TEAL that approves a transaction - */ - appApprovalProgram: Uint8Array; - /** - * The compiled TEAL program that runs when clearing state - */ - appClearProgram: Uint8Array; - /** - * Array of Uint8Array, any additional arguments to the application - */ - appArgs?: Uint8Array[]; - /** - * Array of Address strings, any additional accounts to supply to the application - */ - appAccounts?: string[]; - /** - * Array of int, any other apps used by the application, identified by index - */ - appForeignApps?: number[]; - /** - * Array of int, any assets used by the application, identified by index - */ - appForeignAssets?: number[]; - /** - * Transaction type - */ - type?: TransactionType; - /** - * Set this to true to specify fee as microalgos-per-txn. - * - * If the final calculated fee is lower than the protocol minimum fee, the fee will be increased to match the minimum - */ - flatFee?: boolean; - /** - * A dict holding common-to-all-txns arguments - */ - suggestedParams: SuggestedParams; - /** - * String representation of the Algorand address that will be used to authorize all future transactions - */ - rekeyTo?: string; - /** - * Set this value to true to mark this account as nonparticipating. - * - * All new Algorand accounts are participating by default. This means they earn rewards. - */ - nonParticipation?: boolean; - /** - * Int representing extra pages of memory to rent during an application create transaction. - */ - extraPages?: number; - /** - * A grouping of the app ID and name of the box in an Uint8Array - */ - boxes?: BoxReference[]; - stateProofType?: number | bigint; - /** - * Byte array containing the state proof. - */ - stateProof?: Uint8Array; - /** - * Byte array containing the state proof message. - */ - stateProofMessage?: Uint8Array; -} diff --git a/algosdk/types/transactions/base.js b/algosdk/types/transactions/base.js deleted file mode 100644 index dc44155..0000000 --- a/algosdk/types/transactions/base.js +++ /dev/null @@ -1,87 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.OnApplicationComplete = exports.isTransactionType = exports.TransactionType = void 0; -/** - * Enum for application transaction types. - * - * The full list is available at https://developer.algorand.org/docs/reference/transactions/ - */ -var TransactionType; -(function (TransactionType) { - /** - * Payment transaction - */ - TransactionType["pay"] = "pay"; - /** - * Key registration transaction - */ - TransactionType["keyreg"] = "keyreg"; - /** - * Asset configuration transaction - */ - TransactionType["acfg"] = "acfg"; - /** - * Asset transfer transaction - */ - TransactionType["axfer"] = "axfer"; - /** - * Asset freeze transaction - */ - TransactionType["afrz"] = "afrz"; - /** - * Application transaction - */ - TransactionType["appl"] = "appl"; - /** - * State proof transaction - */ - TransactionType["stpf"] = "stpf"; -})(TransactionType = exports.TransactionType || (exports.TransactionType = {})); -function isTransactionType(s) { - return (s === TransactionType.pay || - s === TransactionType.keyreg || - s === TransactionType.acfg || - s === TransactionType.axfer || - s === TransactionType.afrz || - s === TransactionType.appl || - s === TransactionType.stpf); -} -exports.isTransactionType = isTransactionType; -/** - * Enums for application transactions on-transaction-complete behavior - */ -var OnApplicationComplete; -(function (OnApplicationComplete) { - /** - * NoOpOC indicates that an application transaction will simply call its - * ApprovalProgram - */ - OnApplicationComplete[OnApplicationComplete["NoOpOC"] = 0] = "NoOpOC"; - /** - * OptInOC indicates that an application transaction will allocate some - * LocalState for the application in the sender's account - */ - OnApplicationComplete[OnApplicationComplete["OptInOC"] = 1] = "OptInOC"; - /** - * CloseOutOC indicates that an application transaction will deallocate - * some LocalState for the application from the user's account - */ - OnApplicationComplete[OnApplicationComplete["CloseOutOC"] = 2] = "CloseOutOC"; - /** - * ClearStateOC is similar to CloseOutOC, but may never fail. This - * allows users to reclaim their minimum balance from an application - * they no longer wish to opt in to. - */ - OnApplicationComplete[OnApplicationComplete["ClearStateOC"] = 3] = "ClearStateOC"; - /** - * UpdateApplicationOC indicates that an application transaction will - * update the ApprovalProgram and ClearStateProgram for the application - */ - OnApplicationComplete[OnApplicationComplete["UpdateApplicationOC"] = 4] = "UpdateApplicationOC"; - /** - * DeleteApplicationOC indicates that an application transaction will - * delete the AppParams for the application from the creator's balance - * record - */ - OnApplicationComplete[OnApplicationComplete["DeleteApplicationOC"] = 5] = "DeleteApplicationOC"; -})(OnApplicationComplete = exports.OnApplicationComplete || (exports.OnApplicationComplete = {})); diff --git a/algosdk/types/transactions/builder.d.ts b/algosdk/types/transactions/builder.d.ts deleted file mode 100644 index 9b04711..0000000 --- a/algosdk/types/transactions/builder.d.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { DistributiveOverwrite } from '../utils'; -import { TransactionParams, SuggestedParams } from './base'; -/** - * Transaction base with suggested params as object - */ -declare type TransactionBaseWithSuggestedParams = Pick; -/** - * Transaction base with suggested params included as parameters - */ -declare type TransactionBaseWithoutSuggestedParams = Pick; -/** - * Transaction common fields. - * - * Base transaction type that is extended for all other transaction types. - * Suggested params must be included, either as named object or included in the rest - * of the parameters. - */ -export declare type TransactionBase = TransactionBaseWithoutSuggestedParams | TransactionBaseWithSuggestedParams | (TransactionBaseWithSuggestedParams & TransactionBaseWithoutSuggestedParams); -/** - * Transaction builder type that accepts 2 generics: - * - A: Additional parameters on top of the base transaction parameters - * - O: A set of overwrites for transaction parameters - */ -export declare type ConstructTransaction = {}> = DistributiveOverwrite; -/** - * Only accept transaction objects that include suggestedParams as an object - */ -export declare type MustHaveSuggestedParams = Extract; -/** - * Only accept transaction objects that include suggestedParams inline instead of being - * enclosed in its own property - */ -export declare type MustHaveSuggestedParamsInline = Extract; -export default ConstructTransaction; diff --git a/algosdk/types/transactions/builder.js b/algosdk/types/transactions/builder.js deleted file mode 100644 index c8ad2e5..0000000 --- a/algosdk/types/transactions/builder.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/algosdk/types/transactions/encoded.d.ts b/algosdk/types/transactions/encoded.d.ts deleted file mode 100644 index 5fac2fd..0000000 --- a/algosdk/types/transactions/encoded.d.ts +++ /dev/null @@ -1,328 +0,0 @@ -/** - * Interfaces for the encoded transaction object. Every property is labelled with its associated Transaction type property - */ -export interface EncodedAssetParams { - /** - * assetTotal - */ - t: number | bigint; - /** - * assetDefaultFrozen - */ - df: boolean; - /** - * assetDecimals - */ - dc: number; - /** - * assetManager - */ - m?: Uint8Array; - /** - * assetReserve - */ - r?: Uint8Array; - /** - * assetFreeze - */ - f?: Uint8Array; - /** - * assetClawback - */ - c?: Uint8Array; - /** - * assetName - */ - an?: string; - /** - * assetUnitName - */ - un?: string; - /** - * assetURL - */ - au?: string; - /** - * assetMetadataHash - */ - am?: Uint8Array; -} -export interface EncodedLocalStateSchema { - /** - * appLocalInts - */ - nui: number; - /** - * appLocalByteSlices - */ - nbs: number; -} -export interface EncodedGlobalStateSchema { - /** - * appGlobalInts - */ - nui: number; - /** - * appGlobalByteSlices - */ - nbs: number; -} -export interface EncodedBoxReference { - /** - * index of the app ID in the foreign apps array - */ - i: number; - /** - * box name - */ - n: Uint8Array; -} -/** - * A rough structure for the encoded transaction object. Every property is labelled with its associated Transaction type property - */ -export interface EncodedTransaction { - /** - * fee - */ - fee?: number; - /** - * firstValid - */ - fv?: number; - /** - * lastValid - */ - lv: number; - /** - * note - */ - note?: Uint8Array; - /** - * sender - */ - snd: Uint8Array; - /** - * type - */ - type: string; - /** - * genesisID - */ - gen: string; - /** - * genesisHash - */ - gh: Uint8Array; - /** - * lease - */ - lx?: Uint8Array; - /** - * group - */ - grp?: Uint8Array; - /** - * amount - */ - amt?: number | bigint; - /** - * amount (but for asset transfers) - */ - aamt?: number | bigint; - /** - * closeRemainderTo - */ - close?: Uint8Array; - /** - * closeRemainderTo (but for asset transfers) - */ - aclose?: Uint8Array; - /** - * rekeyTo - */ - rekey?: Uint8Array; - /** - * receiver - */ - rcv?: Uint8Array; - /** - * receiver (but for asset transfers) - */ - arcv?: Uint8Array; - /** - * voteKey - */ - votekey?: Uint8Array; - /** - * selectionKey - */ - selkey?: Uint8Array; - /** - * stateProofKey - */ - sprfkey?: Uint8Array; - /** - * voteFirst - */ - votefst?: number; - /** - * voteLast - */ - votelst?: number; - /** - * voteKeyDilution - */ - votekd?: number; - /** - * nonParticipation - */ - nonpart?: boolean; - /** - * assetIndex - */ - caid?: number; - /** - * assetIndex (but for asset transfers) - */ - xaid?: number; - /** - * assetIndex (but for asset freezing/unfreezing) - */ - faid?: number; - /** - * assetFrozen - */ - afrz?: boolean; - /** - * freezeAccount - */ - fadd?: Uint8Array; - /** - * assetSender - */ - asnd?: Uint8Array; - /** - * See EncodedAssetParams type - */ - apar?: EncodedAssetParams; - /** - * appIndex - */ - apid?: number; - /** - * appOnComplete - */ - apan?: number; - /** - * See EncodedLocalStateSchema type - */ - apls?: EncodedLocalStateSchema; - /** - * See EncodedGlobalStateSchema type - */ - apgs?: EncodedGlobalStateSchema; - /** - * appForeignApps - */ - apfa?: number[]; - /** - * appForeignAssets - */ - apas?: number[]; - /** - * appApprovalProgram - */ - apap?: Uint8Array; - /** - * appClearProgram - */ - apsu?: Uint8Array; - /** - * appArgs - */ - apaa?: Uint8Array[]; - /** - * appAccounts - */ - apat?: Uint8Array[]; - /** - * extraPages - */ - apep?: number; - /** - * boxes - */ - apbx?: EncodedBoxReference[]; - sptype?: number | bigint; - /** - * stateProof - */ - sp?: Uint8Array; - /** - * stateProofMessage - */ - spmsg?: Uint8Array; -} -export interface EncodedSubsig { - /** - * The public key - */ - pk: Uint8Array; - /** - * The signature provided by the public key, if any - */ - s?: Uint8Array; -} -/** - * A rough structure for the encoded multi signature transaction object. - * Every property is labelled with its associated `MultisigMetadata` type property - */ -export interface EncodedMultisig { - /** - * version - */ - v: number; - /** - * threshold - */ - thr: number; - /** - * Subset of signatures. A threshold of `thr` signors is required. - */ - subsig: EncodedSubsig[]; -} -export interface EncodedLogicSig { - l: Uint8Array; - arg?: Uint8Array[]; - sig?: Uint8Array; - msig?: EncodedMultisig; -} -export interface EncodedLogicSigAccount { - lsig: EncodedLogicSig; - sigkey?: Uint8Array; -} -/** - * A structure for an encoded signed transaction object - */ -export interface EncodedSignedTransaction { - /** - * Transaction signature - */ - sig?: Uint8Array; - /** - * The transaction that was signed - */ - txn: EncodedTransaction; - /** - * Multisig structure - */ - msig?: EncodedMultisig; - /** - * Logic signature - */ - lsig?: EncodedLogicSig; - /** - * The signer, if signing with a different key than the Transaction type `sender` property indicates - */ - sgnr?: Uint8Array; -} diff --git a/algosdk/types/transactions/encoded.js b/algosdk/types/transactions/encoded.js deleted file mode 100644 index b050260..0000000 --- a/algosdk/types/transactions/encoded.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict"; -/** - * Interfaces for the encoded transaction object. Every property is labelled with its associated Transaction type property - */ -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/algosdk/types/transactions/index.d.ts b/algosdk/types/transactions/index.d.ts deleted file mode 100644 index 2d09f05..0000000 --- a/algosdk/types/transactions/index.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -import PaymentTxn from './payment'; -import KeyRegistrationTxn from './keyreg'; -import { AssetCreateTransaction as AssetCreateTxn, AssetConfigurationTransaction as AssetConfigTxn, AssetDestroyTransaction as AssetDestroyTxn, AssetFreezeTransaction as AssetFreezeTxn, AssetTransferTransaction as AssetTransferTxn } from './asset'; -import { ApplicationCreateTransaction as AppCreateTxn, ApplicationUpdateTransaction as AppUpdateTxn, ApplicationDeleteTransaction as AppDeleteTxn, ApplicationOptInTransaction as AppOptInTxn, ApplicationCloseOutTransaction as AppCloseOutTxn, ApplicationClearStateTransaction as AppClearStateTxn, ApplicationNoOpTransaction as AppNoOpTxn } from './application'; -import StateProofTxn from './stateproof'; -export { TransactionParams, TransactionType, SuggestedParams, BoxReference, } from './base'; -export { MustHaveSuggestedParams, MustHaveSuggestedParamsInline, } from './builder'; -export * from './encoded'; -export { default as PaymentTxn } from './payment'; -export { default as KeyRegistrationTxn } from './keyreg'; -export { AssetCreateTransaction as AssetCreateTxn, AssetConfigurationTransaction as AssetConfigTxn, AssetDestroyTransaction as AssetDestroyTxn, AssetFreezeTransaction as AssetFreezeTxn, AssetTransferTransaction as AssetTransferTxn, } from './asset'; -export { ApplicationCreateTransaction as AppCreateTxn, ApplicationUpdateTransaction as AppUpdateTxn, ApplicationDeleteTransaction as AppDeleteTxn, ApplicationOptInTransaction as AppOptInTxn, ApplicationCloseOutTransaction as AppCloseOutTxn, ApplicationClearStateTransaction as AppClearStateTxn, ApplicationNoOpTransaction as AppNoOpTxn, } from './application'; -export { default as StateProofTxn } from './stateproof'; -declare type AnyTransaction = PaymentTxn | KeyRegistrationTxn | AssetCreateTxn | AssetConfigTxn | AssetDestroyTxn | AssetFreezeTxn | AssetTransferTxn | AppCreateTxn | AppUpdateTxn | AppDeleteTxn | AppOptInTxn | AppCloseOutTxn | AppClearStateTxn | AppNoOpTxn | StateProofTxn; -export default AnyTransaction; diff --git a/algosdk/types/transactions/index.js b/algosdk/types/transactions/index.js deleted file mode 100644 index dc5eff0..0000000 --- a/algosdk/types/transactions/index.js +++ /dev/null @@ -1,21 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.TransactionType = void 0; -// Utilities -var base_1 = require("./base"); -Object.defineProperty(exports, "TransactionType", { enumerable: true, get: function () { return base_1.TransactionType; } }); -__exportStar(require("./encoded"), exports); diff --git a/algosdk/types/transactions/keyreg.d.ts b/algosdk/types/transactions/keyreg.d.ts deleted file mode 100644 index f9963b1..0000000 --- a/algosdk/types/transactions/keyreg.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { TransactionType, TransactionParams } from './base'; -import { ConstructTransaction } from './builder'; -declare type SpecificParameters = Pick; -interface Overwrites { - type?: TransactionType.keyreg; -} -declare type KeyRegistrationTransaction = ConstructTransaction; -export default KeyRegistrationTransaction; diff --git a/algosdk/types/transactions/keyreg.js b/algosdk/types/transactions/keyreg.js deleted file mode 100644 index c8ad2e5..0000000 --- a/algosdk/types/transactions/keyreg.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/algosdk/types/transactions/payment.d.ts b/algosdk/types/transactions/payment.d.ts deleted file mode 100644 index 2012b2d..0000000 --- a/algosdk/types/transactions/payment.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { TransactionType, TransactionParams } from './base'; -import { ConstructTransaction } from './builder'; -declare type SpecificParameters = Pick; -interface Overwrites { - type?: TransactionType.pay; -} -declare type PaymentTransaction = ConstructTransaction; -export default PaymentTransaction; diff --git a/algosdk/types/transactions/payment.js b/algosdk/types/transactions/payment.js deleted file mode 100644 index c8ad2e5..0000000 --- a/algosdk/types/transactions/payment.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/algosdk/types/transactions/stateproof.d.ts b/algosdk/types/transactions/stateproof.d.ts deleted file mode 100644 index 3c07144..0000000 --- a/algosdk/types/transactions/stateproof.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { TransactionType, TransactionParams } from './base'; -import { ConstructTransaction } from './builder'; -declare type SpecificParameters = Pick; -interface Overwrites { - type?: TransactionType.stpf; -} -declare type StateProofTransaction = ConstructTransaction; -export default StateProofTransaction; diff --git a/algosdk/types/transactions/stateproof.js b/algosdk/types/transactions/stateproof.js deleted file mode 100644 index c8ad2e5..0000000 --- a/algosdk/types/transactions/stateproof.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/algosdk/types/utils.d.ts b/algosdk/types/utils.d.ts deleted file mode 100644 index c5d1d29..0000000 --- a/algosdk/types/utils.d.ts +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Expands types for IntelliSense so they are more human readable - * See https://stackoverflow.com/a/69288824 - */ -export declare type Expand = T extends (...args: infer A) => infer R ? (...args: Expand) => Expand : T extends infer O ? { - [K in keyof O]: O[K]; -} : never; -/** - * Same as TypeScript's Pick, but will distribute the Pick over unions - */ -export declare type DistributivePick = T extends unknown ? Pick : never; -/** - * Overwrite a type with properties from another type - */ -export declare type Overwrite> = Pick> & U; -/** - * Same as Overwrite, but will distribute the Overwrite over unions - */ -export declare type DistributiveOverwrite> = T extends unknown ? Overwrite : never; -/** - * Mark certain keys as prohibited - */ -export declare type NeverAllow = { - [P in K]?: never; -}; -/** - * Rename a specific property of a type to another name - * - * Usage: RenameProperty\<\{ a: string \}, 'a', 'b'\> - * -\> \{ b: string \} - */ -export declare type RenameProperty = { - [P in keyof T as P extends K ? R : P]: T[P]; -}; -/** - * Rename multiple properties of one type to another name - * - * Usage: RenameProperties\<\{ a: string, b: number \}, \{ a: 'c', b: 'd' \}\> - * -\> \{ c: string, d: number \} - */ -export declare type RenameProperties = { - [P in keyof T as P extends keyof R ? R[P] : P]: T[P]; -}; diff --git a/algosdk/types/utils.js b/algosdk/types/utils.js deleted file mode 100644 index c8ad2e5..0000000 --- a/algosdk/types/utils.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/algosdk/utils/utils.d.ts b/algosdk/utils/utils.d.ts deleted file mode 100644 index 691c121..0000000 --- a/algosdk/utils/utils.d.ts +++ /dev/null @@ -1,52 +0,0 @@ -import IntDecoding from '../types/intDecoding'; -export interface JSONOptions { - intDecoding?: IntDecoding; -} -/** - * Parse JSON with additional options. - * @param str - The JSON string to parse. - * @param options - Options object to configure how integers in - * this request's JSON response will be decoded. Use the `intDecoding` - * property with one of the following options: - * - * * "default": All integers will be decoded as Numbers, meaning any values greater than - * Number.MAX_SAFE_INTEGER will lose precision. - * * "safe": All integers will be decoded as Numbers, but if any values are greater than - * Number.MAX_SAFE_INTEGER an error will be thrown. - * * "mixed": Integers will be decoded as Numbers if they are less than or equal to - * Number.MAX_SAFE_INTEGER, otherwise they will be decoded as BigInts. - * * "bigint": All integers will be decoded as BigInts. - * - * Defaults to "default" if not included. - */ -export declare function parseJSON(str: string, options?: JSONOptions): any; -/** - * ArrayEqual takes two arrays and return true if equal, false otherwise - */ -export declare function arrayEqual(a: ArrayLike, b: ArrayLike): boolean; -/** - * ConcatArrays takes n number arrays and returns a joint Uint8Array - * @param arrs - An arbitrary number of n array-like number list arguments - * @returns [a,b] - */ -export declare function concatArrays(...arrs: ArrayLike[]): Uint8Array; -/** - * Remove undefined properties from an object - * @param obj - An object, preferably one with some undefined properties - * @returns A copy of the object with undefined properties removed - */ -export declare function removeUndefinedProperties(obj: Record): { - [x: string]: any; - [x: number]: any; - [x: symbol]: any; -}; -/** - * Check whether the environment is Node.js (as opposed to the browser) - * @returns True if Node.js environment, false otherwise - */ -export declare function isNode(): boolean; -/** - * Check whether the environment is ReactNative - * @returns True if ReactNative, false otherwise - */ -export declare function isReactNative(): boolean; diff --git a/algosdk/utils/utils.js b/algosdk/utils/utils.js deleted file mode 100644 index 03f74f2..0000000 --- a/algosdk/utils/utils.js +++ /dev/null @@ -1,126 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.isReactNative = exports.isNode = exports.removeUndefinedProperties = exports.concatArrays = exports.arrayEqual = exports.parseJSON = void 0; -const json_bigint_1 = __importDefault(require("json-bigint")); -const intDecoding_1 = __importDefault(require("../types/intDecoding")); -const JSONbig = (0, json_bigint_1.default)({ - useNativeBigInt: true, - strict: true, -}); -/** - * Parse JSON with additional options. - * @param str - The JSON string to parse. - * @param options - Options object to configure how integers in - * this request's JSON response will be decoded. Use the `intDecoding` - * property with one of the following options: - * - * * "default": All integers will be decoded as Numbers, meaning any values greater than - * Number.MAX_SAFE_INTEGER will lose precision. - * * "safe": All integers will be decoded as Numbers, but if any values are greater than - * Number.MAX_SAFE_INTEGER an error will be thrown. - * * "mixed": Integers will be decoded as Numbers if they are less than or equal to - * Number.MAX_SAFE_INTEGER, otherwise they will be decoded as BigInts. - * * "bigint": All integers will be decoded as BigInts. - * - * Defaults to "default" if not included. - */ -function parseJSON(str, options) { - const intDecoding = options && options.intDecoding ? options.intDecoding : intDecoding_1.default.DEFAULT; - return JSONbig.parse(str, (_, value) => { - if (value != null && - typeof value === 'object' && - Object.getPrototypeOf(value) == null) { - // JSONbig.parse objects are created with Object.create(null) and thus have a null prototype - // let us remedy that - Object.setPrototypeOf(value, Object.prototype); - } - if (typeof value === 'bigint') { - if (intDecoding === 'safe' && value > Number.MAX_SAFE_INTEGER) { - throw new Error(`Integer exceeds maximum safe integer: ${value.toString()}. Try parsing with a different intDecoding option.`); - } - if (intDecoding === 'bigint' || - (intDecoding === 'mixed' && value > Number.MAX_SAFE_INTEGER)) { - return value; - } - // JSONbig.parse converts number to BigInts if they are >= 10**15. This is smaller than - // Number.MAX_SAFE_INTEGER, so we can convert some BigInts back to normal numbers. - return Number(value); - } - if (typeof value === 'number') { - if (intDecoding === 'bigint' && Number.isInteger(value)) { - return BigInt(value); - } - } - return value; - }); -} -exports.parseJSON = parseJSON; -/** - * ArrayEqual takes two arrays and return true if equal, false otherwise - */ -function arrayEqual(a, b) { - if (a.length !== b.length) { - return false; - } - return Array.from(a).every((val, i) => val === b[i]); -} -exports.arrayEqual = arrayEqual; -/** - * ConcatArrays takes n number arrays and returns a joint Uint8Array - * @param arrs - An arbitrary number of n array-like number list arguments - * @returns [a,b] - */ -function concatArrays(...arrs) { - const size = arrs.reduce((sum, arr) => sum + arr.length, 0); - const c = new Uint8Array(size); - let offset = 0; - for (let i = 0; i < arrs.length; i++) { - c.set(arrs[i], offset); - offset += arrs[i].length; - } - return c; -} -exports.concatArrays = concatArrays; -/** - * Remove undefined properties from an object - * @param obj - An object, preferably one with some undefined properties - * @returns A copy of the object with undefined properties removed - */ -function removeUndefinedProperties(obj) { - const mutableCopy = { ...obj }; - Object.keys(mutableCopy).forEach((key) => { - if (typeof mutableCopy[key] === 'undefined') - delete mutableCopy[key]; - }); - return mutableCopy; -} -exports.removeUndefinedProperties = removeUndefinedProperties; -/** - * Check whether the environment is Node.js (as opposed to the browser) - * @returns True if Node.js environment, false otherwise - */ -function isNode() { - return ( - // @ts-ignore - typeof process === 'object' && - // @ts-ignore - typeof process.versions === 'object' && - // @ts-ignore - typeof process.versions.node !== 'undefined'); -} -exports.isNode = isNode; -/** - * Check whether the environment is ReactNative - * @returns True if ReactNative, false otherwise - */ -function isReactNative() { - const { navigator } = globalThis; - if (typeof navigator === 'object' && navigator.product === 'ReactNative') { - return true; - } - return false; -} -exports.isReactNative = isReactNative; diff --git a/algosdk/wait.d.ts b/algosdk/wait.d.ts deleted file mode 100644 index 2498627..0000000 --- a/algosdk/wait.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -import Algodv2 from './client/v2/algod/algod'; -import { PendingTransactionResponse } from './client/v2/algod/models/types'; -/** - * Wait until a transaction has been confirmed or rejected by the network, or - * until 'waitRounds' number of rounds have passed. - * @param client - An Algodv2 client - * @param txid - The ID of the transaction to wait for. - * @param waitRounds - The maximum number of rounds to wait for. - * @returns A promise that, upon success, will resolve to the output of the - * `pendingTransactionInformation` call for the confirmed transaction. - */ -export declare function waitForConfirmation(client: Algodv2, txid: string, waitRounds: number): Promise; diff --git a/algosdk/wait.js b/algosdk/wait.js deleted file mode 100644 index 712427e..0000000 --- a/algosdk/wait.js +++ /dev/null @@ -1,52 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.waitForConfirmation = void 0; -/** - * Wait until a transaction has been confirmed or rejected by the network, or - * until 'waitRounds' number of rounds have passed. - * @param client - An Algodv2 client - * @param txid - The ID of the transaction to wait for. - * @param waitRounds - The maximum number of rounds to wait for. - * @returns A promise that, upon success, will resolve to the output of the - * `pendingTransactionInformation` call for the confirmed transaction. - */ -async function waitForConfirmation(client, txid, waitRounds) { - // Wait until the transaction is confirmed or rejected, or until 'waitRounds' - // number of rounds have passed. - const status = await client.status().do(); - if (typeof status === 'undefined') { - throw new Error('Unable to get node status'); - } - const startRound = Number(status.lastRound) + 1; - let currentRound = startRound; - /* eslint-disable no-await-in-loop */ - while (currentRound < startRound + waitRounds) { - let poolError = false; - try { - const pendingInfo = await client.pendingTransactionInformation(txid).do(); - if (pendingInfo.confirmedRound) { - // Got the completed Transaction - return pendingInfo; - } - if (pendingInfo.poolError) { - // If there was a pool error, then the transaction has been rejected - poolError = true; - throw new Error(`Transaction Rejected: ${pendingInfo.poolError}`); - } - } - catch (err) { - // Ignore errors from PendingTransactionInformation, since it may return 404 if the algod - // instance is behind a load balancer and the request goes to a different algod than the - // one we submitted the transaction to - if (poolError) { - // Rethrow error only if it's because the transaction was rejected - throw err; - } - } - await client.statusAfterBlock(currentRound).do(); - currentRound += 1; - } - /* eslint-enable no-await-in-loop */ - throw new Error(`Transaction not confirmed after ${waitRounds} rounds`); -} -exports.waitForConfirmation = waitForConfirmation; diff --git a/package-lock.json b/package-lock.json index fdb08d7..d3ef71f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,15 +10,8 @@ "license": "MIT", "dependencies": { "@vscode/debugadapter": "^1.64.0", - "algo-msgpack-with-bigint": "^2.1.1", - "await-notify": "^1.0.1", - "hi-base32": "^0.5.1", - "js-sha256": "^0.9.0", - "js-sha3": "^0.8.0", - "js-sha512": "^0.8.0", - "json-bigint": "^1.0.0", - "tweetnacl": "^1.0.3", - "vlq": "^2.0.4" + "algosdk": "^3.0.0-beta.1", + "await-notify": "^1.0.1" }, "bin": { "avm-debug-adapter": "out/src/cli.js" @@ -1319,12 +1312,30 @@ "url": "https://github.com/sponsors/epoberezkin" } }, - "node_modules/algo-msgpack-with-bigint": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/algo-msgpack-with-bigint/-/algo-msgpack-with-bigint-2.1.1.tgz", - "integrity": "sha512-F1tGh056XczEaEAqu7s+hlZUDWwOBT70Eq0lfMpBP2YguSQVyxRbprLq5rELXKQOyOaixTWYhMeMQMzP0U5FoQ==", + "node_modules/algorand-msgpack": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/algorand-msgpack/-/algorand-msgpack-1.1.0.tgz", + "integrity": "sha512-08k7pBQnkaUB5p+jL7f1TRaUIlTSDE0cesFu1mD7llLao+1cAhtvvZmGE3OnisTd0xOn118QMw74SRqddqaYvw==", "engines": { - "node": ">= 10" + "node": ">= 14" + } + }, + "node_modules/algosdk": { + "version": "3.0.0-beta.1", + "resolved": "https://registry.npmjs.org/algosdk/-/algosdk-3.0.0-beta.1.tgz", + "integrity": "sha512-45+F7zH+a3u2eRx7IaSaRl7BfyBej1IO9Fk/Rz7f1c+FhSCj/OxZoToGYAkr6OsJuL3KmJAnX4l3BQYOY/ddSA==", + "dependencies": { + "algorand-msgpack": "^1.1.0", + "hi-base32": "^0.5.1", + "js-sha256": "^0.9.0", + "js-sha3": "^0.8.0", + "js-sha512": "^0.8.0", + "json-bigint": "^1.0.0", + "tweetnacl": "^1.0.3", + "vlq": "^2.0.4" + }, + "engines": { + "node": ">=18.0.0" } }, "node_modules/ansi-colors": { diff --git a/package.json b/package.json index 33a5821..e294a38 100644 --- a/package.json +++ b/package.json @@ -46,11 +46,10 @@ }, "files": [ "out/src", - "out/algosdk", "src" ], "scripts": { - "compile": "shx rm -rf out && tsc -p ./ && shx cp -R algosdk out/algosdk", + "compile": "shx rm -rf out && tsc -p ./", "lint": "eslint src --ext ts", "typecheck": "tsc -p tsconfig.json --noEmit", "check-format": "prettier . --check", @@ -68,15 +67,8 @@ }, "dependencies": { "@vscode/debugadapter": "^1.64.0", - "algo-msgpack-with-bigint": "^2.1.1", - "await-notify": "^1.0.1", - "hi-base32": "^0.5.1", - "js-sha256": "^0.9.0", - "js-sha3": "^0.8.0", - "js-sha512": "^0.8.0", - "json-bigint": "^1.0.0", - "tweetnacl": "^1.0.3", - "vlq": "^2.0.4" + "algosdk": "^3.0.0-beta.1", + "await-notify": "^1.0.1" }, "devDependencies": { "@istanbuljs/nyc-config-typescript": "^1.0.2", diff --git a/sampleWorkspace/app-state-changes/box-simulate-response.json b/sampleWorkspace/app-state-changes/box-simulate-response.json index 94edb75..8e68928 100644 --- a/sampleWorkspace/app-state-changes/box-simulate-response.json +++ b/sampleWorkspace/app-state-changes/box-simulate-response.json @@ -24,7 +24,7 @@ "gen": "sandnet-v1", "gh": "LSfI/BB2PAth7oDeWEH/oYncUvwuhqkSVkvKxI5kd3I=", "lv": 1056, - "snd": "pYKxUMFyrKlVPWTkwgnI6LhrU9SsEWlQYO4srVQrzPE=", + "snd": "UWBLCUGBOKWKSVJ5MTSMECOI5C4GWU6UVQIWSUDA5YWK2VBLZTY577RWWE", "type": "appl" } } diff --git a/sampleWorkspace/app-state-changes/global-simulate-response.json b/sampleWorkspace/app-state-changes/global-simulate-response.json index eae878b..ca7f393 100644 --- a/sampleWorkspace/app-state-changes/global-simulate-response.json +++ b/sampleWorkspace/app-state-changes/global-simulate-response.json @@ -24,7 +24,7 @@ "gen": "sandnet-v1", "gh": "LSfI/BB2PAth7oDeWEH/oYncUvwuhqkSVkvKxI5kd3I=", "lv": 1048, - "snd": "54zalZwKNOYGxmz8XSAPhmaeXvOFrN5jZYadDledqng=", + "snd": "46GNVFM4BI2OMBWGNT6F2IAPQZTJ4XXTQWWN4Y3FQ2OQ4V45VJ4LISHIWY", "type": "appl" } }, diff --git a/sampleWorkspace/app-state-changes/local-simulate-response.json b/sampleWorkspace/app-state-changes/local-simulate-response.json index d62cd01..372ec60 100644 --- a/sampleWorkspace/app-state-changes/local-simulate-response.json +++ b/sampleWorkspace/app-state-changes/local-simulate-response.json @@ -24,7 +24,7 @@ "gen": "sandnet-v1", "gh": "LSfI/BB2PAth7oDeWEH/oYncUvwuhqkSVkvKxI5kd3I=", "lv": 1052, - "snd": "wZ0oB9HqKwGk6aHmjIEts1E/1Wyx7ltjR+nZZ6vwc+4=", + "snd": "YGOSQB6R5IVQDJHJUHTIZAJNWNIT7VLMWHXFWY2H5HMWPK7QOPXHELNPJ4", "type": "appl" } }, diff --git a/src/common/appState.ts b/src/common/appState.ts index 44b3059..7720c40 100644 --- a/src/common/appState.ts +++ b/src/common/appState.ts @@ -1,4 +1,4 @@ -import * as algosdk from '../../algosdk'; +import * as algosdk from 'algosdk'; import { ByteArrayMap } from './utils'; export class AppState { @@ -60,7 +60,7 @@ export class AppState { for (const { key, value } of appLocal.kvs) { map.set(key, value); } - state.localState.set(appLocal.account!, map); + state.localState.set(appLocal.account!.toString(), map); } if (initialState.appBoxes) { diff --git a/src/common/debugSession.ts b/src/common/debugSession.ts index 93cb266..71e7093 100644 --- a/src/common/debugSession.ts +++ b/src/common/debugSession.ts @@ -16,7 +16,7 @@ import { DebugProtocol } from '@vscode/debugprotocol'; import { AvmRuntime, IRuntimeBreakpoint } from './runtime'; import { ProgramStackFrame } from './traceReplayEngine'; import { Subject } from 'await-notify'; -import * as algosdk from '../../algosdk'; +import * as algosdk from 'algosdk'; import { FileAccessor } from './fileAccessor'; import { AvmDebuggingAssets, utf8Decode, limitArray } from './utils'; @@ -1202,12 +1202,12 @@ class ProgramStateScope { type OnChainStateScope = 'chain' | 'app'; class AppStateScope { - constructor(public readonly appID: number) {} + constructor(public readonly appID: bigint) {} } class AppSpecificStateScope { public readonly scope: 'global' | 'local' | 'box'; - public readonly appID: number; + public readonly appID: bigint; public readonly account?: string; public readonly property?: 'key' | 'value'; @@ -1218,7 +1218,7 @@ class AppSpecificStateScope { property, }: { scope: 'global' | 'local' | 'box'; - appID: number; + appID: bigint; account?: string; property?: 'key' | 'value'; }) { @@ -1290,7 +1290,7 @@ function evaluateNameToScope(name: string): [AvmValueScope, number | string] { } const newScope = new AppSpecificStateScope({ scope: scope, - appID: parseInt(appMatches[1], 10), + appID: BigInt(appMatches[1]), property, }); return [newScope, appMatches[3]]; @@ -1328,7 +1328,7 @@ function evaluateNameToScope(name: string): [AvmValueScope, number | string] { } const newScope = new AppSpecificStateScope({ scope: 'local', - appID: parseInt(appLocalMatches[1], 10), + appID: BigInt(appLocalMatches[1]), account, property, }); diff --git a/src/common/runtime.ts b/src/common/runtime.ts index ac76f81..42a227d 100644 --- a/src/common/runtime.ts +++ b/src/common/runtime.ts @@ -276,12 +276,12 @@ export class AvmRuntime extends EventEmitter { this.breakPoints.delete(normalizePathAndCasing(this.fileAccessor, path)); } - public getAppStateReferences(): number[] { + public getAppStateReferences(): bigint[] { const apps = Array.from(this.engine.initialAppState.keys()); - return apps.sort((a, b) => a - b); + return apps.sort((a, b) => Number(a - b)); } - public getAppLocalStateAccounts(appID: number): string[] { + public getAppLocalStateAccounts(appID: bigint): string[] { const app = this.engine.initialAppState.get(appID); if (!app) { return []; @@ -290,7 +290,7 @@ export class AvmRuntime extends EventEmitter { return accounts.sort(); } - public getAppState(appID: number): AppState { + public getAppState(appID: bigint): AppState { return this.engine.currentAppState.get(appID) || new AppState(); } diff --git a/src/common/traceReplayEngine.ts b/src/common/traceReplayEngine.ts index a80ecd2..ed53886 100644 --- a/src/common/traceReplayEngine.ts +++ b/src/common/traceReplayEngine.ts @@ -1,4 +1,4 @@ -import * as algosdk from '../../algosdk'; +import * as algosdk from 'algosdk'; import { AppState } from './appState'; import { ByteArrayMap, @@ -45,8 +45,8 @@ export class TraceReplayEngine { ProgramSourceDescriptor | undefined > = new ByteArrayMap(); - public initialAppState = new Map(); - public currentAppState = new Map(); + public initialAppState = new Map(); + public currentAppState = new Map(); public stack: TraceReplayStackFrame[] = []; @@ -65,7 +65,7 @@ export class TraceReplayEngine { for (const initialAppState of simulateResponse.initialStates ?.appInitialStates || []) { this.initialAppState.set( - Number(initialAppState.id), + initialAppState.id, AppState.fromAppInitialState(initialAppState), ); } @@ -141,11 +141,10 @@ export class TraceReplayEngine { programHash, ); - let appID = txnInfo.applicationIndex || txnInfo.txn.txn.apid; - if (typeof appID === 'undefined') { + const appID = + txnInfo.applicationIndex || txnInfo.txn.txn.applicationCall?.appIndex; + if (typeof appID === 'undefined' || appID === BigInt(0)) { throw new Error(`No appID for txn at path ${path}`); - } else { - appID = Number(appID); } let initialAppState = this.initialAppState.get(appID); @@ -157,9 +156,12 @@ export class TraceReplayEngine { for (const opcode of opcodes) { for (const stateChange of opcode.stateChanges || []) { if (stateChange.appStateType === 'l') { - const account = stateChange.account!; - if (!initialAppState.localState.has(account)) { - initialAppState.localState.set(account, new ByteArrayMap()); + const accountAddress = stateChange.account!.toString(); + if (!initialAppState.localState.has(accountAddress)) { + initialAppState.localState.set( + accountAddress, + new ByteArrayMap(), + ); } } } @@ -297,13 +299,15 @@ export class TopLevelTransactionGroupsFrame extends TraceReplayStackFrame { public sourceFile(): FrameSource { const individualGroups = this.response.txnGroups.map((group) => - group.txnResults.map( - (txnResult) => txnResult.txnResult.get_obj_for_encoding().txn, + group.txnResults.map((txnResult) => + algosdk.parseJSON(algosdk.encodeJSON(txnResult.txnResult.txn), { + intDecoding: algosdk.IntDecoding.BIGINT, + }), ), ); return { name: `transaction-groups.json`, - content: JSON.stringify(individualGroups, null, 2), + content: algosdk.stringifyJSON(individualGroups, undefined, 2), contentMimeType: 'application/json', }; } @@ -312,15 +316,19 @@ export class TopLevelTransactionGroupsFrame extends TraceReplayStackFrame { let lineOffset = 1; // For opening bracket for (let i = 0; i < this.index; i++) { for (const txnResult of this.response.txnGroups[i].txnResults) { - const displayedTxn = txnResult.txnResult.get_obj_for_encoding().txn; - lineOffset += JSON.stringify(displayedTxn, null, 2).split('\n').length; + const displayedTxn = txnResult.txnResult.txn; + lineOffset += algosdk + .encodeJSON(displayedTxn, { space: 2 }) + .split('\n').length; } lineOffset += 2; // For opening and closing brackets } let lineCount = 2; // For opening and closing brackets for (const txnResult of this.response.txnGroups[this.index].txnResults) { - const displayedTxn = txnResult.txnResult.get_obj_for_encoding().txn; - lineCount += JSON.stringify(displayedTxn, null, 2).split('\n').length; + const displayedTxn = txnResult.txnResult.txn; + lineCount += algosdk + .encodeJSON(displayedTxn, { space: 2 }) + .split('\n').length; } return { line: lineOffset, @@ -442,16 +450,20 @@ export class TransactionGroupStackFrame extends TraceReplayStackFrame { } } - const individualTxns = this.txnInfos.map( - (txnInfo) => txnInfo.get_obj_for_encoding().txn, + const individualTxns = this.txnInfos.map((txnInfo) => + algosdk.parseJSON(algosdk.encodeJSON(txnInfo.txn), { + intDecoding: algosdk.IntDecoding.BIGINT, + }), ); - this.sourceContent = JSON.stringify(individualTxns, null, 2); + this.sourceContent = algosdk.stringifyJSON(individualTxns, undefined, 2); let lineOffset = 1; // For opening bracket for (let i = 0; i < this.txnInfos.length; i++) { const txnInfo = this.txnInfos[i]; const txnTrace = this.txnTraces[i]; - const displayedTxn = txnInfo.get_obj_for_encoding().txn; - const displayTxnLines = JSON.stringify(displayedTxn, null, 2).split('\n'); + const displayedTxn = txnInfo.txn; + const displayTxnLines = algosdk + .encodeJSON(displayedTxn, { space: 2 }) + .split('\n'); const sourceLocation: TransactionSourceLocation = { line: lineOffset, lineEnd: lineOffset + displayTxnLines.length, @@ -737,24 +749,23 @@ export class ProgramStackFrame extends TraceReplayStackFrame { this.programType === 'logic sig' && typeof this.txnInfo.txn.lsig !== 'undefined' ) { - let lsigBytes = this.txnInfo.txn.lsig.l; - if (typeof lsigBytes === 'string') { - lsigBytes = algosdk.base64ToBytes(lsigBytes); - } + const lsigBytes = this.txnInfo.txn.lsig.logic; const lsigAccount = new algosdk.LogicSigAccount(lsigBytes); - this.logicSigAddress = lsigAccount.address(); + this.logicSigAddress = lsigAccount.address().toString(); } } - public currentAppID(): number | undefined { + public currentAppID(): bigint | undefined { if (this.programType === 'logic sig') { return undefined; } - if (typeof this.txnInfo.txn.txn.apid !== 'undefined') { - return Number(this.txnInfo.txn.txn.apid); + if (this.txnInfo.txn.txn.applicationCall?.appIndex) { + // Ignore 0 and undefined + return this.txnInfo.txn.txn.applicationCall.appIndex; } - if (typeof this.txnInfo.applicationIndex !== 'undefined') { - return Number(this.txnInfo.applicationIndex); + if (this.txnInfo.applicationIndex) { + // Ignore 0 and undefined + return this.txnInfo.applicationIndex; } return undefined; } @@ -916,7 +927,7 @@ export class ProgramStackFrame extends TraceReplayStackFrame { throw new Error(`Invalid scratch slot ${slot}`); } const newValue = scratchWrite.newValue; - if (Number(newValue.type) === 2 && !newValue.uint) { + if (newValue.type === 2 && !newValue.uint) { // When setting to 0, delete the entry, since 0 is the default. this.state.scratch.delete(slot); } else { @@ -946,16 +957,20 @@ export class ProgramStackFrame extends TraceReplayStackFrame { break; case 'l': if (stateChange.operation === 'w') { - const accountState = state.localState.get(stateChange.account!); + const accountState = state.localState.get( + stateChange.account!.toString(), + ); if (!accountState) { const newState = new ByteArrayMap(); newState.set(stateChange.key, stateChange.newValue!); - state.localState.set(stateChange.account!, newState); + state.localState.set(stateChange.account!.toString(), newState); } else { accountState.set(stateChange.key, stateChange.newValue!); } } else if (stateChange.operation === 'd') { - const accountState = state.localState.get(stateChange.account!); + const accountState = state.localState.get( + stateChange.account!.toString(), + ); if (accountState) { accountState.delete(stateChange.key); } diff --git a/src/common/utils.ts b/src/common/utils.ts index 768117c..99197db 100644 --- a/src/common/utils.ts +++ b/src/common/utils.ts @@ -1,5 +1,4 @@ -import * as JSONbigWithoutConfig from 'json-bigint'; -import * as algosdk from '../../algosdk'; +import * as algosdk from 'algosdk'; import { FileAccessor } from './fileAccessor'; /** @@ -59,19 +58,6 @@ export function limitArray( return array.slice(start, start + count); } -// TODO: replace with algosdk.parseJson once it is available in v3 -export function parseJsonWithBigints(json: string): any { - // Our tests wants this lib to be imported as `import * as JSONbig from 'json-bigint';`, - // but running this in vscode wants it to be imported as `import JSONbig from 'json-bigint';`. - // This is a hack to allow both. - let target = JSONbigWithoutConfig; - if (target.default) { - target = target.default; - } - const JSON_BIG = target({ useNativeBigInt: true, strict: true }); - return JSON_BIG.parse(json); -} - export class ByteArrayMap { private map: Map; @@ -290,21 +276,22 @@ export class AvmDebuggingAssets { ); let simulateResponse: algosdk.modelsv2.SimulateResponse; try { - const jsonPased = parseJsonWithBigints( - new TextDecoder().decode(rawSimulateTrace), + simulateResponse = algosdk.decodeJSON( + algosdk.bytesToString(rawSimulateTrace), + algosdk.modelsv2.SimulateResponse, ); - if (jsonPased.version !== 2) { + if (simulateResponse.version !== 2) { throw new Error( - `Unsupported simulate response version: ${jsonPased.version}`, + `Unsupported simulate response version: ${simulateResponse.version}`, ); } - simulateResponse = - algosdk.modelsv2.SimulateResponse.from_obj_for_encoding(jsonPased); if (!simulateResponse.execTraceConfig?.enable) { throw new Error( - `Simulate response does not contain trace data. execTraceConfig=${JSON.stringify( - simulateResponse.execTraceConfig, - )}`, + `Simulate response does not contain trace data. execTraceConfig=${ + simulateResponse.execTraceConfig + ? algosdk.encodeJSON(simulateResponse.execTraceConfig) + : simulateResponse.execTraceConfig + }`, ); } } catch (e) { diff --git a/tests/adapter.test.ts b/tests/adapter.test.ts index 8323632..7912b4f 100644 --- a/tests/adapter.test.ts +++ b/tests/adapter.test.ts @@ -1,6 +1,6 @@ import * as assert from 'assert'; import * as path from 'path'; -import * as algosdk from '../algosdk'; +import * as algosdk from 'algosdk'; import { DebugProtocol } from '@vscode/debugprotocol'; import { ByteArrayMap, normalizePathAndCasing } from '../src/common/utils'; import { nodeFileAccessor } from '../src/node'; @@ -254,12 +254,12 @@ describe('Debug Adapter Tests', () => { }, { name: 'transaction-group-0.json', - line: 19, + line: 29, column: 0, }, { name: 'transaction-group-0.json', - line: 23, + line: 19, column: 0, }, { @@ -269,7 +269,7 @@ describe('Debug Adapter Tests', () => { }, { name: 'transaction-group-0.json', - line: 34, + line: 45, column: 0, }, ]; @@ -506,7 +506,7 @@ describe('Debug Adapter Tests', () => { }, { name: 'transaction-group-0.json', - line: 19, + line: 29, column: 0, }, { @@ -553,7 +553,7 @@ describe('Debug Adapter Tests', () => { }, { name: 'transaction-group-0.json', - line: 23, + line: 19, column: 0, }, { @@ -617,7 +617,7 @@ describe('Debug Adapter Tests', () => { }, { name: 'transaction-group-0.json', - line: 34, + line: 45, column: 0, }, {