@algorandfoundation/algokit-utils 8.2.0-beta.2 → 8.2.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/package.json +3 -2
  2. package/types/account-manager.d.ts +33 -18
  3. package/types/account-manager.js +33 -18
  4. package/types/account-manager.js.map +1 -1
  5. package/types/account-manager.mjs +33 -18
  6. package/types/account-manager.mjs.map +1 -1
  7. package/types/account.d.ts +5 -0
  8. package/types/account.js +5 -0
  9. package/types/account.js.map +1 -1
  10. package/types/account.mjs +5 -0
  11. package/types/account.mjs.map +1 -1
  12. package/types/algorand-client-transaction-creator.d.ts +103 -70
  13. package/types/algorand-client-transaction-creator.js +103 -70
  14. package/types/algorand-client-transaction-creator.js.map +1 -1
  15. package/types/algorand-client-transaction-creator.mjs +103 -70
  16. package/types/algorand-client-transaction-creator.mjs.map +1 -1
  17. package/types/algorand-client-transaction-sender.d.ts +107 -20
  18. package/types/algorand-client-transaction-sender.js +107 -21
  19. package/types/algorand-client-transaction-sender.js.map +1 -1
  20. package/types/algorand-client-transaction-sender.mjs +107 -21
  21. package/types/algorand-client-transaction-sender.mjs.map +1 -1
  22. package/types/algorand-client.d.ts +108 -24
  23. package/types/algorand-client.js +107 -23
  24. package/types/algorand-client.js.map +1 -1
  25. package/types/algorand-client.mjs +107 -23
  26. package/types/algorand-client.mjs.map +1 -1
  27. package/types/amount.d.ts +10 -0
  28. package/types/amount.js +10 -0
  29. package/types/amount.js.map +1 -1
  30. package/types/amount.mjs +10 -0
  31. package/types/amount.mjs.map +1 -1
  32. package/types/app-client.d.ts +128 -8
  33. package/types/app-client.js +128 -8
  34. package/types/app-client.js.map +1 -1
  35. package/types/app-client.mjs +128 -8
  36. package/types/app-client.mjs.map +1 -1
  37. package/types/app-deployer.d.ts +33 -1
  38. package/types/app-deployer.js +33 -1
  39. package/types/app-deployer.js.map +1 -1
  40. package/types/app-deployer.mjs +33 -1
  41. package/types/app-deployer.mjs.map +1 -1
  42. package/types/app-factory.d.ts +74 -4
  43. package/types/app-factory.js +74 -4
  44. package/types/app-factory.js.map +1 -1
  45. package/types/app-factory.mjs +74 -4
  46. package/types/app-factory.mjs.map +1 -1
  47. package/types/app-manager.d.ts +64 -0
  48. package/types/app-manager.js +64 -0
  49. package/types/app-manager.js.map +1 -1
  50. package/types/app-manager.mjs +64 -0
  51. package/types/app-manager.mjs.map +1 -1
  52. package/types/app-spec.d.ts +9 -0
  53. package/types/app-spec.js +9 -0
  54. package/types/app-spec.js.map +1 -1
  55. package/types/app-spec.mjs +9 -0
  56. package/types/app-spec.mjs.map +1 -1
  57. package/types/asset-manager.d.ts +5 -5
  58. package/types/asset-manager.js +5 -5
  59. package/types/asset-manager.js.map +1 -1
  60. package/types/asset-manager.mjs +5 -5
  61. package/types/asset-manager.mjs.map +1 -1
  62. package/types/client-manager.d.ts +79 -18
  63. package/types/client-manager.js +79 -18
  64. package/types/client-manager.js.map +1 -1
  65. package/types/client-manager.mjs +79 -18
  66. package/types/client-manager.mjs.map +1 -1
  67. package/types/composer.d.ts +599 -1
  68. package/types/composer.js +575 -1
  69. package/types/composer.js.map +1 -1
  70. package/types/composer.mjs +575 -1
  71. package/types/composer.mjs.map +1 -1
@@ -1,6 +1,15 @@
1
1
  import algosdk from 'algosdk';
2
2
 
3
3
  var ABIMethod = algosdk.ABIMethod;
4
+ /**
5
+ * Converts an ARC-32 Application Specification to an ARC-56 Contract
6
+ * @param appSpec The ARC-32 Application Specification
7
+ * @returns The ARC-56 Contract
8
+ * @example
9
+ * ```typescript
10
+ * const arc56AppSpec = arc32ToArc56(arc32AppSpec)
11
+ * ```
12
+ */
4
13
  function arc32ToArc56(appSpec) {
5
14
  const arc32Structs = Object.values(appSpec.hints).flatMap((hint) => Object.entries(hint.structs ?? {}));
6
15
  const structs = Object.fromEntries(arc32Structs.map(([_, struct]) => {
@@ -1 +1 @@
1
- {"version":3,"file":"app-spec.mjs","sources":["../../src/types/app-spec.ts"],"sourcesContent":["import algosdk from 'algosdk'\nimport { Arc56Contract, Method as Arc56Method, StorageKey, StructField } from './app-arc56'\nimport ABIContractParams = algosdk.ABIContractParams\nimport ABIMethodParams = algosdk.ABIMethodParams\nimport ABIMethod = algosdk.ABIMethod\n\nexport function arc32ToArc56(appSpec: AppSpec): Arc56Contract {\n const arc32Structs = Object.values(appSpec.hints).flatMap((hint) => Object.entries(hint.structs ?? {}))\n const structs = Object.fromEntries(\n arc32Structs.map(([_, struct]) => {\n const fields = struct.elements.map((e) => ({ name: e[0], type: e[1] }))\n return [struct.name, fields]\n }),\n ) satisfies { [structName: string]: StructField[] }\n const hint = (m: ABIMethodParams) => appSpec.hints[new ABIMethod(m).getSignature()] as Hint | undefined\n const actions = (m: ABIMethodParams, type: 'CREATE' | 'CALL') => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain\n return hint(m)?.call_config !== undefined ? callConfigToActions(hint(m)?.call_config!, type) : []\n }\n const bareActions = (type: 'CREATE' | 'CALL') => {\n return callConfigToActions(appSpec.bare_call_config, type)\n }\n const callConfigToActions = (c: CallConfig, type: 'CREATE' | 'CALL') => {\n const actions: ('NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication')[] = []\n if (c.close_out && ['ALL', type].includes(c.close_out)) actions.push('CloseOut')\n if (c.delete_application && ['ALL', type].includes(c.delete_application)) actions.push('DeleteApplication')\n if (c.no_op && ['ALL', type].includes(c.no_op)) actions.push('NoOp')\n if (c.opt_in && ['ALL', type].includes(c.opt_in)) actions.push('OptIn')\n if (c.update_application && ['ALL', type].includes(c.update_application)) actions.push('UpdateApplication')\n return actions\n }\n const getDefaultArgValue = (\n type: string,\n defaultArg: DefaultArgument | undefined,\n ): Arc56Contract['methods'][0]['args'][0]['defaultValue'] => {\n if (!defaultArg) return undefined\n\n if (defaultArg.source === 'abi-method') {\n return {\n source: 'method',\n data: defaultArg.data.name,\n }\n }\n\n return {\n source: defaultArg.source === 'constant' ? 'literal' : defaultArg.source === 'global-state' ? 'global' : 'local',\n data: Buffer.from(\n typeof defaultArg.data === 'number' ? algosdk.ABIType.from('uint64').encode(defaultArg.data) : defaultArg.data,\n ).toString('base64'),\n type: type === 'string' ? 'AVMString' : type,\n }\n }\n\n return {\n arcs: [],\n name: appSpec.contract.name,\n desc: appSpec.contract.desc,\n structs: structs,\n methods: appSpec.contract.methods.map(\n (m) =>\n ({\n name: m.name,\n desc: m.desc,\n args: m.args.map((a) => ({\n name: a.name,\n type: a.type,\n desc: a.desc,\n struct: a.name ? hint(m)?.structs?.[a.name]?.name : undefined,\n defaultValue: getDefaultArgValue(a.type, !a.name ? undefined : hint(m)?.default_arguments?.[a.name]),\n })),\n returns: {\n type: m.returns.type,\n desc: m.returns.desc,\n struct: hint(m)?.structs?.output?.name,\n },\n events: [],\n readonly: hint(m)?.read_only,\n actions: {\n create: actions(m, 'CREATE') as Arc56Method['actions']['create'],\n call: actions(m, 'CALL'),\n },\n }) satisfies Arc56Method,\n ),\n state: {\n schema: {\n global: {\n ints: appSpec.state.global.num_uints,\n bytes: appSpec.state.global.num_byte_slices,\n },\n local: {\n ints: appSpec.state.local.num_uints,\n bytes: appSpec.state.local.num_byte_slices,\n },\n },\n keys: {\n global: Object.fromEntries(\n Object.entries(appSpec.schema.global.declared).map((s) => [\n s[0],\n {\n key: Buffer.from(s[1].key, 'utf-8').toString('base64'),\n keyType: 'AVMString',\n valueType: s[1].type === 'uint64' ? 'AVMUint64' : 'AVMBytes',\n desc: s[1].descr,\n } satisfies StorageKey,\n ]),\n ),\n local: Object.fromEntries(\n Object.entries(appSpec.schema.local.declared).map((s) => [\n s[0],\n {\n key: Buffer.from(s[1].key, 'utf-8').toString('base64'),\n keyType: 'AVMString',\n valueType: s[1].type === 'uint64' ? 'AVMUint64' : 'AVMBytes',\n desc: s[1].descr,\n } satisfies StorageKey,\n ]),\n ),\n box: {},\n },\n maps: {\n global: {},\n local: {},\n box: {},\n },\n },\n source: appSpec.source,\n bareActions: {\n create: bareActions('CREATE') as unknown as Arc56Contract['bareActions']['create'],\n call: bareActions('CALL'),\n },\n byteCode: undefined,\n compilerInfo: undefined,\n events: undefined,\n networks: undefined,\n scratchVariables: undefined,\n sourceInfo: undefined,\n templateVariables: undefined,\n } satisfies Arc56Contract\n}\n\n/** An ARC-0032 Application Specification see https://github.com/algorandfoundation/ARCs/pull/150 */\nexport interface AppSpec {\n /** Method call hints */\n hints: HintSpec\n /** The TEAL source */\n source: AppSources\n /** The ABI-0004 contract definition see https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0004.md */\n contract: ABIContractParams\n /** The values that make up the local and global state */\n schema: SchemaSpec\n /** The rolled-up schema allocation values for local and global state */\n state: StateSchemaSpec\n /** The config of all BARE calls (i.e. non ABI calls with no args) */\n bare_call_config: CallConfig\n}\n\n/** A lookup of encoded method call spec to hint */\nexport type HintSpec = Record<string, Hint>\n\n/** The TEAL source of a contract */\nexport interface AppSources {\n /** The TEAL source of the approval program */\n approval: string\n /** The TEAL source of the clear program */\n clear: string\n}\n\n/** The various call configs:\n * * `NEVER`: Will not be called\n * * `CALL`: Can be called during a non-create call i.e. app id != 0\n * * `CREATE`: Can be called during a create call i.e. app id = 0\n * * `ALL`: Can be during a create OR non-create call\n **/\nexport type CallConfigValue = 'NEVER' | 'CALL' | 'CREATE' | 'ALL'\n\n/** Call configuration for a method */\nexport interface CallConfig {\n /** NoOp call config */\n no_op?: CallConfigValue\n /** Opt-in call config */\n opt_in?: CallConfigValue\n /** Close out call config */\n close_out?: CallConfigValue\n /** Update call config */\n update_application?: CallConfigValue\n /** Delete call config */\n delete_application?: CallConfigValue\n}\n\n/** Hint information for a given method call to allow client generation */\nexport interface Hint {\n /** Any user-defined struct/tuple types used in the method call, keyed by parameter name or `output` for return type */\n structs?: Record<string, Struct>\n read_only?: boolean\n default_arguments?: Record<string, DefaultArgument>\n call_config: CallConfig\n}\n\n/** The name of a field */\nexport type FieldName = string\n\n/** The string name of an ABI type */\nexport type ABIType = string\n\n/** The elements of the struct/tuple: `FieldName`, `ABIType` */\nexport type StructElement = [FieldName, ABIType]\n\n/** A user-defined struct/tuple type */\nexport interface Struct {\n /** The name of the type */\n name: string\n /** The elements (in order) that make up the struct/tuple */\n elements: StructElement[]\n}\n\n/**\n * Defines a strategy for obtaining a default value for a given ABI arg.\n */\nexport type DefaultArgument =\n | {\n /**\n * The default value should be fetched by invoking an ABI method\n */\n source: 'abi-method'\n data: ABIMethodParams\n }\n | {\n /**\n * The default value should be fetched from global state\n */\n source: 'global-state'\n /**\n * The key of the state variable\n */\n data: string\n }\n | {\n /**\n * The default value should be fetched from the local state of the sender user\n */\n source: 'local-state'\n /**\n * The key of the state variable\n */\n data: string\n }\n | {\n /**\n * The default value is a constant.\n */\n source: 'constant'\n /**\n * The static default value to use.\n */\n data: string | number\n }\n\n/** AVM data type */\nexport type AVMType = 'uint64' | 'bytes'\n\n/** Declared schema value specification */\nexport interface DeclaredSchemaValueSpec {\n /** The type of value */\n type: AVMType\n /** The name of the key */\n key: string\n /** A description of the variable */\n descr?: string\n /** Whether or not the value is set statically (at create time only) or dynamically */\n static?: boolean\n}\n\n/** Reserved schema value specification */\nexport interface ReservedSchemaValueSpec {\n /** The type of value */\n type: AVMType\n /** The description of the reserved storage space */\n descr: string\n /** The maximum number of slots to reserve */\n max_keys: number\n}\n\n/** The schema for global and local storage */\nexport interface SchemaSpec {\n /** The local storage schema */\n local: Schema\n /** The global storage schema */\n global: Schema\n}\n\n/** The storage schema definition */\nexport interface Schema {\n /** Declared storage schema */\n declared: Record<string, DeclaredSchemaValueSpec>\n /** Reserved storage schema */\n reserved: Record<string, ReservedSchemaValueSpec>\n}\n\n/** The rolled-up schema allocation specification for local and global state */\nexport interface StateSchemaSpec {\n /** Global storage spec */\n global: StateSchema\n /** Local storage spec */\n local: StateSchema\n}\n\n/** Schema spec summary for global or local storage */\nexport type StateSchema = {\n /** Number of uint slots */\n num_uints: number\n /** Number of byte slots */\n num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AAA,YAAY,EAAE,SAAS;AACvB,QAAA,MAAM,EAAE,SAAS;AACjB,QAAA,QAAQ,EAAE,SAAS;AACnB,QAAA,gBAAgB,EAAE,SAAS;AAC3B,QAAA,UAAU,EAAE,SAAS;AACrB,QAAA,iBAAiB,EAAE,SAAS;KACL;AAC3B;;;;"}
1
+ {"version":3,"file":"app-spec.mjs","sources":["../../src/types/app-spec.ts"],"sourcesContent":["import algosdk from 'algosdk'\nimport { Arc56Contract, Method as Arc56Method, StorageKey, StructField } from './app-arc56'\nimport ABIContractParams = algosdk.ABIContractParams\nimport ABIMethodParams = algosdk.ABIMethodParams\nimport ABIMethod = algosdk.ABIMethod\n\n/**\n * Converts an ARC-32 Application Specification to an ARC-56 Contract\n * @param appSpec The ARC-32 Application Specification\n * @returns The ARC-56 Contract\n * @example\n * ```typescript\n * const arc56AppSpec = arc32ToArc56(arc32AppSpec)\n * ```\n */\nexport function arc32ToArc56(appSpec: AppSpec): Arc56Contract {\n const arc32Structs = Object.values(appSpec.hints).flatMap((hint) => Object.entries(hint.structs ?? {}))\n const structs = Object.fromEntries(\n arc32Structs.map(([_, struct]) => {\n const fields = struct.elements.map((e) => ({ name: e[0], type: e[1] }))\n return [struct.name, fields]\n }),\n ) satisfies { [structName: string]: StructField[] }\n const hint = (m: ABIMethodParams) => appSpec.hints[new ABIMethod(m).getSignature()] as Hint | undefined\n const actions = (m: ABIMethodParams, type: 'CREATE' | 'CALL') => {\n // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain\n return hint(m)?.call_config !== undefined ? callConfigToActions(hint(m)?.call_config!, type) : []\n }\n const bareActions = (type: 'CREATE' | 'CALL') => {\n return callConfigToActions(appSpec.bare_call_config, type)\n }\n const callConfigToActions = (c: CallConfig, type: 'CREATE' | 'CALL') => {\n const actions: ('NoOp' | 'OptIn' | 'CloseOut' | 'ClearState' | 'UpdateApplication' | 'DeleteApplication')[] = []\n if (c.close_out && ['ALL', type].includes(c.close_out)) actions.push('CloseOut')\n if (c.delete_application && ['ALL', type].includes(c.delete_application)) actions.push('DeleteApplication')\n if (c.no_op && ['ALL', type].includes(c.no_op)) actions.push('NoOp')\n if (c.opt_in && ['ALL', type].includes(c.opt_in)) actions.push('OptIn')\n if (c.update_application && ['ALL', type].includes(c.update_application)) actions.push('UpdateApplication')\n return actions\n }\n const getDefaultArgValue = (\n type: string,\n defaultArg: DefaultArgument | undefined,\n ): Arc56Contract['methods'][0]['args'][0]['defaultValue'] => {\n if (!defaultArg) return undefined\n\n if (defaultArg.source === 'abi-method') {\n return {\n source: 'method',\n data: defaultArg.data.name,\n }\n }\n\n return {\n source: defaultArg.source === 'constant' ? 'literal' : defaultArg.source === 'global-state' ? 'global' : 'local',\n data: Buffer.from(\n typeof defaultArg.data === 'number' ? algosdk.ABIType.from('uint64').encode(defaultArg.data) : defaultArg.data,\n ).toString('base64'),\n type: type === 'string' ? 'AVMString' : type,\n }\n }\n\n return {\n arcs: [],\n name: appSpec.contract.name,\n desc: appSpec.contract.desc,\n structs: structs,\n methods: appSpec.contract.methods.map(\n (m) =>\n ({\n name: m.name,\n desc: m.desc,\n args: m.args.map((a) => ({\n name: a.name,\n type: a.type,\n desc: a.desc,\n struct: a.name ? hint(m)?.structs?.[a.name]?.name : undefined,\n defaultValue: getDefaultArgValue(a.type, !a.name ? undefined : hint(m)?.default_arguments?.[a.name]),\n })),\n returns: {\n type: m.returns.type,\n desc: m.returns.desc,\n struct: hint(m)?.structs?.output?.name,\n },\n events: [],\n readonly: hint(m)?.read_only,\n actions: {\n create: actions(m, 'CREATE') as Arc56Method['actions']['create'],\n call: actions(m, 'CALL'),\n },\n }) satisfies Arc56Method,\n ),\n state: {\n schema: {\n global: {\n ints: appSpec.state.global.num_uints,\n bytes: appSpec.state.global.num_byte_slices,\n },\n local: {\n ints: appSpec.state.local.num_uints,\n bytes: appSpec.state.local.num_byte_slices,\n },\n },\n keys: {\n global: Object.fromEntries(\n Object.entries(appSpec.schema.global.declared).map((s) => [\n s[0],\n {\n key: Buffer.from(s[1].key, 'utf-8').toString('base64'),\n keyType: 'AVMString',\n valueType: s[1].type === 'uint64' ? 'AVMUint64' : 'AVMBytes',\n desc: s[1].descr,\n } satisfies StorageKey,\n ]),\n ),\n local: Object.fromEntries(\n Object.entries(appSpec.schema.local.declared).map((s) => [\n s[0],\n {\n key: Buffer.from(s[1].key, 'utf-8').toString('base64'),\n keyType: 'AVMString',\n valueType: s[1].type === 'uint64' ? 'AVMUint64' : 'AVMBytes',\n desc: s[1].descr,\n } satisfies StorageKey,\n ]),\n ),\n box: {},\n },\n maps: {\n global: {},\n local: {},\n box: {},\n },\n },\n source: appSpec.source,\n bareActions: {\n create: bareActions('CREATE') as unknown as Arc56Contract['bareActions']['create'],\n call: bareActions('CALL'),\n },\n byteCode: undefined,\n compilerInfo: undefined,\n events: undefined,\n networks: undefined,\n scratchVariables: undefined,\n sourceInfo: undefined,\n templateVariables: undefined,\n } satisfies Arc56Contract\n}\n\n/** An ARC-0032 Application Specification see https://github.com/algorandfoundation/ARCs/pull/150 */\nexport interface AppSpec {\n /** Method call hints */\n hints: HintSpec\n /** The TEAL source */\n source: AppSources\n /** The ABI-0004 contract definition see https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0004.md */\n contract: ABIContractParams\n /** The values that make up the local and global state */\n schema: SchemaSpec\n /** The rolled-up schema allocation values for local and global state */\n state: StateSchemaSpec\n /** The config of all BARE calls (i.e. non ABI calls with no args) */\n bare_call_config: CallConfig\n}\n\n/** A lookup of encoded method call spec to hint */\nexport type HintSpec = Record<string, Hint>\n\n/** The TEAL source of a contract */\nexport interface AppSources {\n /** The TEAL source of the approval program */\n approval: string\n /** The TEAL source of the clear program */\n clear: string\n}\n\n/** The various call configs:\n * * `NEVER`: Will not be called\n * * `CALL`: Can be called during a non-create call i.e. app id != 0\n * * `CREATE`: Can be called during a create call i.e. app id = 0\n * * `ALL`: Can be during a create OR non-create call\n **/\nexport type CallConfigValue = 'NEVER' | 'CALL' | 'CREATE' | 'ALL'\n\n/** Call configuration for a method */\nexport interface CallConfig {\n /** NoOp call config */\n no_op?: CallConfigValue\n /** Opt-in call config */\n opt_in?: CallConfigValue\n /** Close out call config */\n close_out?: CallConfigValue\n /** Update call config */\n update_application?: CallConfigValue\n /** Delete call config */\n delete_application?: CallConfigValue\n}\n\n/** Hint information for a given method call to allow client generation */\nexport interface Hint {\n /** Any user-defined struct/tuple types used in the method call, keyed by parameter name or `output` for return type */\n structs?: Record<string, Struct>\n read_only?: boolean\n default_arguments?: Record<string, DefaultArgument>\n call_config: CallConfig\n}\n\n/** The name of a field */\nexport type FieldName = string\n\n/** The string name of an ABI type */\nexport type ABIType = string\n\n/** The elements of the struct/tuple: `FieldName`, `ABIType` */\nexport type StructElement = [FieldName, ABIType]\n\n/** A user-defined struct/tuple type */\nexport interface Struct {\n /** The name of the type */\n name: string\n /** The elements (in order) that make up the struct/tuple */\n elements: StructElement[]\n}\n\n/**\n * Defines a strategy for obtaining a default value for a given ABI arg.\n */\nexport type DefaultArgument =\n | {\n /**\n * The default value should be fetched by invoking an ABI method\n */\n source: 'abi-method'\n data: ABIMethodParams\n }\n | {\n /**\n * The default value should be fetched from global state\n */\n source: 'global-state'\n /**\n * The key of the state variable\n */\n data: string\n }\n | {\n /**\n * The default value should be fetched from the local state of the sender user\n */\n source: 'local-state'\n /**\n * The key of the state variable\n */\n data: string\n }\n | {\n /**\n * The default value is a constant.\n */\n source: 'constant'\n /**\n * The static default value to use.\n */\n data: string | number\n }\n\n/** AVM data type */\nexport type AVMType = 'uint64' | 'bytes'\n\n/** Declared schema value specification */\nexport interface DeclaredSchemaValueSpec {\n /** The type of value */\n type: AVMType\n /** The name of the key */\n key: string\n /** A description of the variable */\n descr?: string\n /** Whether or not the value is set statically (at create time only) or dynamically */\n static?: boolean\n}\n\n/** Reserved schema value specification */\nexport interface ReservedSchemaValueSpec {\n /** The type of value */\n type: AVMType\n /** The description of the reserved storage space */\n descr: string\n /** The maximum number of slots to reserve */\n max_keys: number\n}\n\n/** The schema for global and local storage */\nexport interface SchemaSpec {\n /** The local storage schema */\n local: Schema\n /** The global storage schema */\n global: Schema\n}\n\n/** The storage schema definition */\nexport interface Schema {\n /** Declared storage schema */\n declared: Record<string, DeclaredSchemaValueSpec>\n /** Reserved storage schema */\n reserved: Record<string, ReservedSchemaValueSpec>\n}\n\n/** The rolled-up schema allocation specification for local and global state */\nexport interface StateSchemaSpec {\n /** Global storage spec */\n global: StateSchema\n /** Local storage spec */\n local: StateSchema\n}\n\n/** Schema spec summary for global or local storage */\nexport type StateSchema = {\n /** Number of uint slots */\n num_uints: number\n /** Number of byte slots */\n num_byte_slices: number\n}\n"],"names":[],"mappings":";;AAIA,IAAO,SAAS,GAAG,OAAO,CAAC,SAAS;AAEpC;;;;;;;;AAQG;AACG,SAAU,YAAY,CAAC,OAAgB,EAAA;AAC3C,IAAA,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;AACvG,IAAA,MAAM,OAAO,GAAG,MAAM,CAAC,WAAW,CAChC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,KAAI;AAC/B,QAAA,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AACvE,QAAA,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC;KAC7B,CAAC,CAC+C;IACnD,MAAM,IAAI,GAAG,CAAC,CAAkB,KAAK,OAAO,CAAC,KAAK,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC,YAAY,EAAE,CAAqB;AACvG,IAAA,MAA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;AACvB,iBAAA,CAAC,CACH;AACD,gBAAA,GAAG,EAAE,EAAE;AACR,aAAA;AACD,YAAA,IAAI,EAAE;AACJ,gBAAA,MAAM,EAAE,EAAE;AACV,gBAAA,KAAK,EAAE,EAAE;AACT,gBAAA,GAAG,EAAE,EAAE;AACR,aAAA;AACF,SAAA;QACD,MAAM,EAAE,OAAO,CAAC,MAAM;AACtB,QAAA,WAAW,EAAE;AACX,YAAA,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAsD;AAClF,YAAA,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC;AAC1B,SAAA;AACD,QAAA,QAAQ,EAAE,SAAS;AACnB,QAAA,YAAY,EAAE,SAAS;AACvB,QAAA,MAAM,EAAE,SAAS;AACjB,QAAA,QAAQ,EAAE,SAAS;AACnB,QAAA,gBAAgB,EAAE,SAAS;AAC3B,QAAA,UAAU,EAAE,SAAS;AACrB,QAAA,iBAAiB,EAAE,SAAS;KACL;AAC3B;;;;"}
@@ -147,7 +147,7 @@ export declare class AssetManager {
147
147
  * ```typescript
148
148
  * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA";
149
149
  * const assetId = 123345n;
150
- * const accountInfo = await algorand.asset.getAccountInformation(address, assetId);
150
+ * const accountInfo = await assetManager.getAccountInformation(address, assetId);
151
151
  * ```
152
152
  *
153
153
  * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2accountsaddressassetsasset-id)
@@ -167,9 +167,9 @@ export declare class AssetManager {
167
167
  * @example Example using AlgorandClient
168
168
  * ```typescript
169
169
  * // Basic example
170
- * algorand.asset.bulkOptIn("ACCOUNTADDRESS", [12345n, 67890n])
170
+ * assetManager.bulkOptIn("ACCOUNTADDRESS", [12345n, 67890n])
171
171
  * // With configuration
172
- * algorand.asset.bulkOptIn("ACCOUNTADDRESS", [12345n, 67890n], { maxFee: (1000).microAlgo(), suppressLog: true })
172
+ * assetManager.bulkOptIn("ACCOUNTADDRESS", [12345n, 67890n], { maxFee: (1000).microAlgo(), suppressLog: true })
173
173
  * ```
174
174
  * @returns An array of records matching asset ID to transaction ID of the opt in
175
175
  */
@@ -185,9 +185,9 @@ export declare class AssetManager {
185
185
  * @example Example using AlgorandClient
186
186
  * ```typescript
187
187
  * // Basic example
188
- * algorand.asset.bulkOptOut("ACCOUNTADDRESS", [12345n, 67890n])
188
+ * assetManager.bulkOptOut("ACCOUNTADDRESS", [12345n, 67890n])
189
189
  * // With configuration
190
- * algorand.asset.bulkOptOut("ACCOUNTADDRESS", [12345n, 67890n], { ensureZeroBalance: true, maxFee: (1000).microAlgo(), suppressLog: true })
190
+ * assetManager.bulkOptOut("ACCOUNTADDRESS", [12345n, 67890n], { ensureZeroBalance: true, maxFee: (1000).microAlgo(), suppressLog: true })
191
191
  * ```
192
192
  * @returns An array of records matching asset ID to transaction ID of the opt in
193
193
  */
@@ -58,7 +58,7 @@ class AssetManager {
58
58
  * ```typescript
59
59
  * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA";
60
60
  * const assetId = 123345n;
61
- * const accountInfo = await algorand.asset.getAccountInformation(address, assetId);
61
+ * const accountInfo = await assetManager.getAccountInformation(address, assetId);
62
62
  * ```
63
63
  *
64
64
  * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2accountsaddressassetsasset-id)
@@ -86,9 +86,9 @@ class AssetManager {
86
86
  * @example Example using AlgorandClient
87
87
  * ```typescript
88
88
  * // Basic example
89
- * algorand.asset.bulkOptIn("ACCOUNTADDRESS", [12345n, 67890n])
89
+ * assetManager.bulkOptIn("ACCOUNTADDRESS", [12345n, 67890n])
90
90
  * // With configuration
91
- * algorand.asset.bulkOptIn("ACCOUNTADDRESS", [12345n, 67890n], { maxFee: (1000).microAlgo(), suppressLog: true })
91
+ * assetManager.bulkOptIn("ACCOUNTADDRESS", [12345n, 67890n], { maxFee: (1000).microAlgo(), suppressLog: true })
92
92
  * ```
93
93
  * @returns An array of records matching asset ID to transaction ID of the opt in
94
94
  */
@@ -123,9 +123,9 @@ class AssetManager {
123
123
  * @example Example using AlgorandClient
124
124
  * ```typescript
125
125
  * // Basic example
126
- * algorand.asset.bulkOptOut("ACCOUNTADDRESS", [12345n, 67890n])
126
+ * assetManager.bulkOptOut("ACCOUNTADDRESS", [12345n, 67890n])
127
127
  * // With configuration
128
- * algorand.asset.bulkOptOut("ACCOUNTADDRESS", [12345n, 67890n], { ensureZeroBalance: true, maxFee: (1000).microAlgo(), suppressLog: true })
128
+ * assetManager.bulkOptOut("ACCOUNTADDRESS", [12345n, 67890n], { ensureZeroBalance: true, maxFee: (1000).microAlgo(), suppressLog: true })
129
129
  * ```
130
130
  * @returns An array of records matching asset ID to transaction ID of the opt in
131
131
  */
@@ -1 +1 @@
1
- {"version":3,"file":"asset-manager.js","sources":["../../src/types/asset-manager.ts"],"sourcesContent":["import algosdk, { Address } from 'algosdk'\nimport { Config } from '../config'\nimport { chunkArray } from '../util'\nimport { AccountAssetInformation } from './account'\nimport { CommonTransactionParams, MAX_TRANSACTION_GROUP_SIZE, TransactionComposer } from './composer'\nimport { SendParams } from './transaction'\n\n/** Individual result from performing a bulk opt-in or bulk opt-out for an account against a series of assets. */\nexport interface BulkAssetOptInOutResult {\n /** The ID of the asset opted into / out of */\n assetId: bigint\n /** The transaction ID of the resulting opt in / out */\n transactionId: string\n}\n\n/** Information about an asset. */\nexport interface AssetInformation {\n /** The ID of the asset. */\n assetId: bigint\n\n /** The address of the account that created the asset.\n *\n * This is the address where the parameters for this asset can be found,\n * and also the address where unwanted asset units can be sent when\n * closing out an asset position and opting-out of the asset.\n */\n creator: string\n\n /** The total amount of the smallest divisible (decimal) units that were created of the asset.\n *\n * For example, if `decimals` is, say, 2, then for every 100 `total` there is 1 whole unit.\n */\n total: bigint\n\n /** The amount of decimal places the asset was created with.\n *\n * * If 0, the asset is not divisible;\n * * If 1, the base unit of the asset is in tenths;\n * * If 2, the base unit of the asset is in hundredths;\n * * If 3, the base unit of the asset is in thousandths;\n * * and so on up to 19 decimal places.\n */\n decimals: number\n\n /** Whether the asset was frozen by default for all accounts.\n *\n * If `true` then for anyone apart from the creator to hold the\n * asset it needs to be unfrozen per account using an asset freeze\n * transaction from the `freeze` account.\n */\n defaultFrozen?: boolean\n\n /** The address of the optional account that can manage the configuration of the asset and destroy it.\n *\n * If not set the asset is permanently immutable.\n */\n manager?: string\n\n /**\n * The address of the optional account that holds the reserve (uncirculated supply) units of the asset.\n *\n * This address has no specific authority in the protocol itself and is informational only.\n *\n * Some standards like [ARC-19](https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0019.md)\n * rely on this field to hold meaningful data.\n *\n * It can be used in the case where you want to signal to holders of your asset that the uncirculated units\n * of the asset reside in an account that is different from the default creator account.\n *\n * If not set the field is permanently empty.\n */\n reserve?: string\n\n /**\n * The address of the optional account that can be used to freeze or unfreeze holdings of this asset for any account.\n *\n * If empty, freezing is not permitted.\n *\n * If not set the field is permanently empty.\n */\n freeze?: string\n\n /**\n * The address of the optional account that can clawback holdings of this asset from any account.\n *\n * The clawback account has the ability to **unconditionally take assets from any account**.\n *\n * If empty, clawback is not permitted.\n *\n * If not set the field is permanently empty.\n */\n clawback?: string\n\n /** The optional name of the unit of this asset (e.g. ticker name).\n *\n * Max size is 8 bytes.\n */\n unitName?: string\n\n /** The optional name of the unit of this asset (e.g. ticker name).\n *\n * Max size is 8 bytes.\n */\n unitNameAsBytes?: Uint8Array\n\n /** The optional name of the asset.\n *\n * Max size is 32 bytes.\n */\n assetName?: string\n\n /** The optional name of the asset.\n *\n * Max size is 32 bytes.\n */\n assetNameAsBytes?: Uint8Array\n\n /** Optional URL where more information about the asset can be retrieved (e.g. metadata).\n *\n * Max size is 96 bytes.\n */\n url?: string\n\n /** Optional URL where more information about the asset can be retrieved (e.g. metadata).\n *\n * Max size is 96 bytes.\n */\n urlAsBytes?: Uint8Array\n\n /** 32-byte hash of some metadata that is relevant to the asset and/or asset holders.\n *\n * The format of this metadata is up to the application.\n */\n metadataHash?: Uint8Array\n}\n\n/** Allows management of asset information. */\nexport class AssetManager {\n private _algod: algosdk.Algodv2\n private _newGroup: () => TransactionComposer\n\n /**\n * Create a new asset manager.\n * @param algod An algod client\n * @param newGroup A function that creates a new `TransactionComposer` transaction group\n * @example Create a new asset manager\n * ```typescript\n * const assetManager = new AssetManager(algod, () => new TransactionComposer({algod, () => signer, () => suggestedParams}))\n * ```\n */\n constructor(algod: algosdk.Algodv2, newGroup: () => TransactionComposer) {\n this._algod = algod\n this._newGroup = newGroup\n }\n\n /**\n * Returns the current asset information for the asset with the given ID.\n *\n * @example\n * ```typescript\n * const assetInfo = await assetManager.getById(12353n);\n * ```\n *\n * @param assetId The ID of the asset\n * @returns The asset information\n */\n public async getById(assetId: bigint): Promise<AssetInformation> {\n const asset = await this._algod.getAssetByID(Number(assetId)).do()\n\n return {\n assetId: BigInt(asset.index),\n total: BigInt(asset.params.total),\n decimals: Number(asset.params.decimals),\n assetName: asset.params.name,\n assetNameAsBytes: asset.params.nameB64,\n unitName: asset.params.unitName,\n unitNameAsBytes: asset.params.unitNameB64,\n url: asset.params.url,\n urlAsBytes: asset.params.urlB64,\n creator: asset.params.creator,\n manager: asset.params.manager,\n clawback: asset.params.clawback,\n freeze: asset.params.freeze,\n reserve: asset.params.reserve,\n defaultFrozen: asset.params.defaultFrozen,\n metadataHash: asset.params.metadataHash,\n }\n }\n\n /**\n * Returns the given sender account's asset holding for a given asset.\n *\n * @example\n * ```typescript\n * const address = \"XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA\";\n * const assetId = 123345n;\n * const accountInfo = await algorand.asset.getAccountInformation(address, assetId);\n * ```\n *\n * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2accountsaddressassetsasset-id)\n * @param sender The address of the sender/account to look up\n * @param assetId The ID of the asset to return a holding for\n * @returns The account asset holding information\n */\n public async getAccountInformation(sender: string | Address, assetId: bigint): Promise<AccountAssetInformation> {\n const info = await this._algod.accountAssetInformation(sender, Number(assetId)).do()\n\n return {\n assetId: BigInt(assetId),\n balance: BigInt(info.assetHolding?.amount ?? 0),\n frozen: info.assetHolding?.isFrozen === true,\n round: BigInt(info['round']),\n }\n }\n\n /**\n * Opt an account in to a list of Algorand Standard Assets.\n *\n * Transactions will be sent in batches of 16 as transaction groups.\n *\n * @param account The account to opt-in\n * @param assetIds The list of asset IDs to opt-in to\n * @param options Any parameters to control the transaction or execution of the transaction\n * @example Example using AlgorandClient\n * ```typescript\n * // Basic example\n * algorand.asset.bulkOptIn(\"ACCOUNTADDRESS\", [12345n, 67890n])\n * // With configuration\n * algorand.asset.bulkOptIn(\"ACCOUNTADDRESS\", [12345n, 67890n], { maxFee: (1000).microAlgo(), suppressLog: true })\n * ```\n * @returns An array of records matching asset ID to transaction ID of the opt in\n */\n async bulkOptIn(\n account: string | Address,\n assetIds: bigint[],\n options?: Omit<CommonTransactionParams, 'sender'> & SendParams,\n ): Promise<BulkAssetOptInOutResult[]> {\n const results: BulkAssetOptInOutResult[] = []\n\n for (const assetGroup of chunkArray(assetIds, MAX_TRANSACTION_GROUP_SIZE)) {\n const composer = this._newGroup()\n\n for (const assetId of assetGroup) {\n composer.addAssetOptIn({\n ...options,\n sender: account,\n assetId: BigInt(assetId),\n })\n }\n\n const result = await composer.send(options)\n\n Config.getLogger(options?.suppressLog).info(\n `Successfully opted in ${account} for assets ${assetGroup.join(', ')} with transaction IDs ${result.txIds.join(', ')}` +\n `\\n Grouped under ${result.groupId} in round ${result.confirmations?.[0]?.confirmedRound}.`,\n )\n\n assetGroup.forEach((assetId, index) => {\n results.push({ assetId: BigInt(assetId), transactionId: result.txIds[index] })\n })\n }\n\n return results\n }\n\n /**\n * Opt an account out of a list of Algorand Standard Assets.\n *\n * Transactions will be sent in batches of 16 as transaction groups.\n *\n * @param account The account to opt-in\n * @param assetIds The list of asset IDs to opt-out of\n * @param options Any parameters to control the transaction or execution of the transaction\n * @example Example using AlgorandClient\n * ```typescript\n * // Basic example\n * algorand.asset.bulkOptOut(\"ACCOUNTADDRESS\", [12345n, 67890n])\n * // With configuration\n * algorand.asset.bulkOptOut(\"ACCOUNTADDRESS\", [12345n, 67890n], { ensureZeroBalance: true, maxFee: (1000).microAlgo(), suppressLog: true })\n * ```\n * @returns An array of records matching asset ID to transaction ID of the opt in\n */\n async bulkOptOut(\n account: string | Address,\n assetIds: bigint[],\n options?: Omit<CommonTransactionParams, 'sender'> &\n SendParams & {\n /** Whether or not to check if the account has a zero balance for each asset first or not.\n *\n * Defaults to `true`.\n *\n * If this is set to `true` and the account has an asset balance it will throw an error.\n *\n * If this is set to `false` and the account has an asset balance it will lose those assets to the asset creator.\n */\n ensureZeroBalance?: boolean\n },\n ): Promise<BulkAssetOptInOutResult[]> {\n const results: BulkAssetOptInOutResult[] = []\n\n for (const assetGroup of chunkArray(assetIds, MAX_TRANSACTION_GROUP_SIZE)) {\n const composer = this._newGroup()\n\n const notOptedInAssetIds: bigint[] = []\n const nonZeroBalanceAssetIds: bigint[] = []\n for (const assetId of assetGroup) {\n if (options?.ensureZeroBalance !== false) {\n try {\n const accountAssetInfo = await this.getAccountInformation(account, assetId)\n if (accountAssetInfo.balance !== 0n) {\n nonZeroBalanceAssetIds.push(BigInt(assetId))\n }\n } catch {\n notOptedInAssetIds.push(BigInt(assetId))\n }\n }\n }\n\n if (notOptedInAssetIds.length > 0 || nonZeroBalanceAssetIds.length > 0) {\n throw new Error(\n `Account ${account}${notOptedInAssetIds.length > 0 ? ` is not opted-in to Asset${notOptedInAssetIds.length > 1 ? 's' : ''} ${notOptedInAssetIds.join(', ')}` : ''}${\n nonZeroBalanceAssetIds.length > 0\n ? ` has non-zero balance for Asset${nonZeroBalanceAssetIds.length > 1 ? 's' : ''} ${nonZeroBalanceAssetIds.join(', ')}`\n : ''\n }; can't opt-out.`,\n )\n }\n\n for (const assetId of assetGroup) {\n composer.addAssetOptOut({\n ...options,\n creator: (await this.getById(BigInt(assetId))).creator,\n sender: account,\n assetId: BigInt(assetId),\n })\n }\n\n const result = await composer.send(options)\n\n Config.getLogger(options?.suppressLog).info(\n `Successfully opted ${account} out of assets ${assetGroup.join(', ')} with transaction IDs ${result.txIds.join(', ')}` +\n `\\n Grouped under ${result.groupId} in round ${result.confirmations?.[0]?.confirmedRound}.`,\n )\n\n assetGroup.forEach((assetId, index) => {\n results.push({ assetId: BigInt(assetId), transactionId: result.txIds[index] })\n })\n }\n\n return results\n }\n}\n"],"names":["chunkArray","MAX_TRANSACTION_GROUP_SIZE","Config"],"mappings":";;;;;;AAwIA;MACa,YAAY,CAAA;AAIvB;;;;;;;;AAQG;IACH,WAAY,CAAA,KAAsB,EAAE,QAAmC,EAAA;AACrE,QAAA,IAAI,CAAC,MAAM,GAAG,KAAK;AACnB,QAAA,IAAI,CAAC,SAAS,GAAG,QAAQ;;AAG3B;;;;;;;;;;AAUG;IACI,MAAM,OAAO,CAAC,OAAe,EAAA;AAClC,QAAA,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QAElE,OAAO;AACL,YAAA,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC;YAC5B,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;YACjC,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC;AACvC,YAAA,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,IAAI;AAC5B,YAAA,gBAAgB,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO;AACtC,YAAA,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,QAAQ;AAC/B,YAAA,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,WAAW;AACzC,YAAA,GAAG,EAAE,KAAK,CAAC,MAAM,CAA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OAAO,EAAE,MAAM,CAAC,OAAO,CAAC;AACzB,iBAAA,CAAC;;YAGJ,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC;AAE3C,YAAAC,aAAM,CAAC,SAAS,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,IAAI,CACzC,CAAsB,mBAAA,EAAA,OAAO,CAAkB,eAAA,EAAA,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,sBAAA,EAAyB,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAE,CAAA;AACpH,gBAAA,CAAA,kBAAA,EAAqB,MAAM,CAAC,OAAO,CAAA,UAAA,EAAa,MAAM,CAAC,aAAa,GAAG,CAAC,CAAC,EAAE,cAAc,CAAA,CAAA,CAAG,CAC/F;YAED,UAAU,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,KAAK,KAAI;gBACpC,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE,aAAa,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;AAChF,aAAC,CAAC;;AAGJ,QAAA,OAAO,OAAO;;AAEjB;;;;"}
1
+ {"version":3,"file":"asset-manager.js","sources":["../../src/types/asset-manager.ts"],"sourcesContent":["import algosdk, { Address } from 'algosdk'\nimport { Config } from '../config'\nimport { chunkArray } from '../util'\nimport { AccountAssetInformation } from './account'\nimport { CommonTransactionParams, MAX_TRANSACTION_GROUP_SIZE, TransactionComposer } from './composer'\nimport { SendParams } from './transaction'\n\n/** Individual result from performing a bulk opt-in or bulk opt-out for an account against a series of assets. */\nexport interface BulkAssetOptInOutResult {\n /** The ID of the asset opted into / out of */\n assetId: bigint\n /** The transaction ID of the resulting opt in / out */\n transactionId: string\n}\n\n/** Information about an asset. */\nexport interface AssetInformation {\n /** The ID of the asset. */\n assetId: bigint\n\n /** The address of the account that created the asset.\n *\n * This is the address where the parameters for this asset can be found,\n * and also the address where unwanted asset units can be sent when\n * closing out an asset position and opting-out of the asset.\n */\n creator: string\n\n /** The total amount of the smallest divisible (decimal) units that were created of the asset.\n *\n * For example, if `decimals` is, say, 2, then for every 100 `total` there is 1 whole unit.\n */\n total: bigint\n\n /** The amount of decimal places the asset was created with.\n *\n * * If 0, the asset is not divisible;\n * * If 1, the base unit of the asset is in tenths;\n * * If 2, the base unit of the asset is in hundredths;\n * * If 3, the base unit of the asset is in thousandths;\n * * and so on up to 19 decimal places.\n */\n decimals: number\n\n /** Whether the asset was frozen by default for all accounts.\n *\n * If `true` then for anyone apart from the creator to hold the\n * asset it needs to be unfrozen per account using an asset freeze\n * transaction from the `freeze` account.\n */\n defaultFrozen?: boolean\n\n /** The address of the optional account that can manage the configuration of the asset and destroy it.\n *\n * If not set the asset is permanently immutable.\n */\n manager?: string\n\n /**\n * The address of the optional account that holds the reserve (uncirculated supply) units of the asset.\n *\n * This address has no specific authority in the protocol itself and is informational only.\n *\n * Some standards like [ARC-19](https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0019.md)\n * rely on this field to hold meaningful data.\n *\n * It can be used in the case where you want to signal to holders of your asset that the uncirculated units\n * of the asset reside in an account that is different from the default creator account.\n *\n * If not set the field is permanently empty.\n */\n reserve?: string\n\n /**\n * The address of the optional account that can be used to freeze or unfreeze holdings of this asset for any account.\n *\n * If empty, freezing is not permitted.\n *\n * If not set the field is permanently empty.\n */\n freeze?: string\n\n /**\n * The address of the optional account that can clawback holdings of this asset from any account.\n *\n * The clawback account has the ability to **unconditionally take assets from any account**.\n *\n * If empty, clawback is not permitted.\n *\n * If not set the field is permanently empty.\n */\n clawback?: string\n\n /** The optional name of the unit of this asset (e.g. ticker name).\n *\n * Max size is 8 bytes.\n */\n unitName?: string\n\n /** The optional name of the unit of this asset (e.g. ticker name).\n *\n * Max size is 8 bytes.\n */\n unitNameAsBytes?: Uint8Array\n\n /** The optional name of the asset.\n *\n * Max size is 32 bytes.\n */\n assetName?: string\n\n /** The optional name of the asset.\n *\n * Max size is 32 bytes.\n */\n assetNameAsBytes?: Uint8Array\n\n /** Optional URL where more information about the asset can be retrieved (e.g. metadata).\n *\n * Max size is 96 bytes.\n */\n url?: string\n\n /** Optional URL where more information about the asset can be retrieved (e.g. metadata).\n *\n * Max size is 96 bytes.\n */\n urlAsBytes?: Uint8Array\n\n /** 32-byte hash of some metadata that is relevant to the asset and/or asset holders.\n *\n * The format of this metadata is up to the application.\n */\n metadataHash?: Uint8Array\n}\n\n/** Allows management of asset information. */\nexport class AssetManager {\n private _algod: algosdk.Algodv2\n private _newGroup: () => TransactionComposer\n\n /**\n * Create a new asset manager.\n * @param algod An algod client\n * @param newGroup A function that creates a new `TransactionComposer` transaction group\n * @example Create a new asset manager\n * ```typescript\n * const assetManager = new AssetManager(algod, () => new TransactionComposer({algod, () => signer, () => suggestedParams}))\n * ```\n */\n constructor(algod: algosdk.Algodv2, newGroup: () => TransactionComposer) {\n this._algod = algod\n this._newGroup = newGroup\n }\n\n /**\n * Returns the current asset information for the asset with the given ID.\n *\n * @example\n * ```typescript\n * const assetInfo = await assetManager.getById(12353n);\n * ```\n *\n * @param assetId The ID of the asset\n * @returns The asset information\n */\n public async getById(assetId: bigint): Promise<AssetInformation> {\n const asset = await this._algod.getAssetByID(Number(assetId)).do()\n\n return {\n assetId: BigInt(asset.index),\n total: BigInt(asset.params.total),\n decimals: Number(asset.params.decimals),\n assetName: asset.params.name,\n assetNameAsBytes: asset.params.nameB64,\n unitName: asset.params.unitName,\n unitNameAsBytes: asset.params.unitNameB64,\n url: asset.params.url,\n urlAsBytes: asset.params.urlB64,\n creator: asset.params.creator,\n manager: asset.params.manager,\n clawback: asset.params.clawback,\n freeze: asset.params.freeze,\n reserve: asset.params.reserve,\n defaultFrozen: asset.params.defaultFrozen,\n metadataHash: asset.params.metadataHash,\n }\n }\n\n /**\n * Returns the given sender account's asset holding for a given asset.\n *\n * @example\n * ```typescript\n * const address = \"XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA\";\n * const assetId = 123345n;\n * const accountInfo = await assetManager.getAccountInformation(address, assetId);\n * ```\n *\n * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2accountsaddressassetsasset-id)\n * @param sender The address of the sender/account to look up\n * @param assetId The ID of the asset to return a holding for\n * @returns The account asset holding information\n */\n public async getAccountInformation(sender: string | Address, assetId: bigint): Promise<AccountAssetInformation> {\n const info = await this._algod.accountAssetInformation(sender, Number(assetId)).do()\n\n return {\n assetId: BigInt(assetId),\n balance: BigInt(info.assetHolding?.amount ?? 0),\n frozen: info.assetHolding?.isFrozen === true,\n round: BigInt(info['round']),\n }\n }\n\n /**\n * Opt an account in to a list of Algorand Standard Assets.\n *\n * Transactions will be sent in batches of 16 as transaction groups.\n *\n * @param account The account to opt-in\n * @param assetIds The list of asset IDs to opt-in to\n * @param options Any parameters to control the transaction or execution of the transaction\n * @example Example using AlgorandClient\n * ```typescript\n * // Basic example\n * assetManager.bulkOptIn(\"ACCOUNTADDRESS\", [12345n, 67890n])\n * // With configuration\n * assetManager.bulkOptIn(\"ACCOUNTADDRESS\", [12345n, 67890n], { maxFee: (1000).microAlgo(), suppressLog: true })\n * ```\n * @returns An array of records matching asset ID to transaction ID of the opt in\n */\n async bulkOptIn(\n account: string | Address,\n assetIds: bigint[],\n options?: Omit<CommonTransactionParams, 'sender'> & SendParams,\n ): Promise<BulkAssetOptInOutResult[]> {\n const results: BulkAssetOptInOutResult[] = []\n\n for (const assetGroup of chunkArray(assetIds, MAX_TRANSACTION_GROUP_SIZE)) {\n const composer = this._newGroup()\n\n for (const assetId of assetGroup) {\n composer.addAssetOptIn({\n ...options,\n sender: account,\n assetId: BigInt(assetId),\n })\n }\n\n const result = await composer.send(options)\n\n Config.getLogger(options?.suppressLog).info(\n `Successfully opted in ${account} for assets ${assetGroup.join(', ')} with transaction IDs ${result.txIds.join(', ')}` +\n `\\n Grouped under ${result.groupId} in round ${result.confirmations?.[0]?.confirmedRound}.`,\n )\n\n assetGroup.forEach((assetId, index) => {\n results.push({ assetId: BigInt(assetId), transactionId: result.txIds[index] })\n })\n }\n\n return results\n }\n\n /**\n * Opt an account out of a list of Algorand Standard Assets.\n *\n * Transactions will be sent in batches of 16 as transaction groups.\n *\n * @param account The account to opt-in\n * @param assetIds The list of asset IDs to opt-out of\n * @param options Any parameters to control the transaction or execution of the transaction\n * @example Example using AlgorandClient\n * ```typescript\n * // Basic example\n * assetManager.bulkOptOut(\"ACCOUNTADDRESS\", [12345n, 67890n])\n * // With configuration\n * assetManager.bulkOptOut(\"ACCOUNTADDRESS\", [12345n, 67890n], { ensureZeroBalance: true, maxFee: (1000).microAlgo(), suppressLog: true })\n * ```\n * @returns An array of records matching asset ID to transaction ID of the opt in\n */\n async bulkOptOut(\n account: string | Address,\n assetIds: bigint[],\n options?: Omit<CommonTransactionParams, 'sender'> &\n SendParams & {\n /** Whether or not to check if the account has a zero balance for each asset first or not.\n *\n * Defaults to `true`.\n *\n * If this is set to `true` and the account has an asset balance it will throw an error.\n *\n * If this is set to `false` and the account has an asset balance it will lose those assets to the asset creator.\n */\n ensureZeroBalance?: boolean\n },\n ): Promise<BulkAssetOptInOutResult[]> {\n const results: BulkAssetOptInOutResult[] = []\n\n for (const assetGroup of chunkArray(assetIds, MAX_TRANSACTION_GROUP_SIZE)) {\n const composer = this._newGroup()\n\n const notOptedInAssetIds: bigint[] = []\n const nonZeroBalanceAssetIds: bigint[] = []\n for (const assetId of assetGroup) {\n if (options?.ensureZeroBalance !== false) {\n try {\n const accountAssetInfo = await this.getAccountInformation(account, assetId)\n if (accountAssetInfo.balance !== 0n) {\n nonZeroBalanceAssetIds.push(BigInt(assetId))\n }\n } catch {\n notOptedInAssetIds.push(BigInt(assetId))\n }\n }\n }\n\n if (notOptedInAssetIds.length > 0 || nonZeroBalanceAssetIds.length > 0) {\n throw new Error(\n `Account ${account}${notOptedInAssetIds.length > 0 ? ` is not opted-in to Asset${notOptedInAssetIds.length > 1 ? 's' : ''} ${notOptedInAssetIds.join(', ')}` : ''}${\n nonZeroBalanceAssetIds.length > 0\n ? ` has non-zero balance for Asset${nonZeroBalanceAssetIds.length > 1 ? 's' : ''} ${nonZeroBalanceAssetIds.join(', ')}`\n : ''\n }; can't opt-out.`,\n )\n }\n\n for (const assetId of assetGroup) {\n composer.addAssetOptOut({\n ...options,\n creator: (await this.getById(BigInt(assetId))).creator,\n sender: account,\n assetId: BigInt(assetId),\n })\n }\n\n const result = await composer.send(options)\n\n Config.getLogger(options?.suppressLog).info(\n `Successfully opted ${account} out of assets ${assetGroup.join(', ')} with transaction IDs ${result.txIds.join(', ')}` +\n `\\n Grouped under ${result.groupId} in round ${result.confirmations?.[0]?.confirmedRound}.`,\n )\n\n assetGroup.forEach((assetId, index) => {\n results.push({ assetId: BigInt(assetId), transactionId: result.txIds[index] })\n })\n }\n\n return results\n }\n}\n"],"names":["chunkArray","MAX_TRANSACTION_GROUP_SIZE","Config"],"mappings":";;;;;;AAwIA;MACa,YAAY,CAAA;AAIvB;;;;;;;;AAQG;IACH,WAAY,CAAA,KAAsB,EAAE,QAAmC,EAAA;AACrE,QAAA,IAAI,CAAC,MAAM,GAAG,KAAK;AACnB,QAAA,IAAI,CAAC,SAAS,GAAG,QAAQ;;AAG3B;;;;;;;;;;AAUG;IACI,MAAM,OAAO,CAAC,OAAe,EAAA;AAClC,QAAA,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QAElE,OAAO;AACL,YAAA,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC;YAC5B,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;YACjC,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC;AACvC,YAAA,SAAS,EAAE,KAAK,CAAC,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MAAM,OAAO,IAAI,UAAU,EAAE;gBAChC,QAAQ,CAAC,cAAc,CAAC;AACtB,oBAAA,GAAG,OAAO;AACV,oBAAA,OAAO,EAAE,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,OAAO;AACtD,oBAAA,MAAM,EAAE,OAAO;AACf,oBAAA,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC;AACzB,iBAAA,CAAC;;YAGJ,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC;AAE3C,YAAAC,aAAM,CAAC,SAAS,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,IAAI,CACzC,CAAsB,mBAAA,EAAA,OAAO,CAAkB,eAAA,EAAA,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,sBAAA,EAAyB,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAE,CAAA;AACpH,gBAAA,CAAA,kBAAA,EAAqB,MAAM,CAAC,OAAO,CAAA,UAAA,EAAa,MAAM,CAAC,aAAa,GAAG,CAAC,CAAC,EAAE,cAAc,CAAA,CAAA,CAAG,CAC/F;YAED,UAAU,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,KAAK,KAAI;gBACpC,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE,aAAa,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;AAChF,aAAC,CAAC;;AAGJ,QAAA,OAAO,OAAO;;AAEjB;;;;"}
@@ -56,7 +56,7 @@ class AssetManager {
56
56
  * ```typescript
57
57
  * const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA";
58
58
  * const assetId = 123345n;
59
- * const accountInfo = await algorand.asset.getAccountInformation(address, assetId);
59
+ * const accountInfo = await assetManager.getAccountInformation(address, assetId);
60
60
  * ```
61
61
  *
62
62
  * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2accountsaddressassetsasset-id)
@@ -84,9 +84,9 @@ class AssetManager {
84
84
  * @example Example using AlgorandClient
85
85
  * ```typescript
86
86
  * // Basic example
87
- * algorand.asset.bulkOptIn("ACCOUNTADDRESS", [12345n, 67890n])
87
+ * assetManager.bulkOptIn("ACCOUNTADDRESS", [12345n, 67890n])
88
88
  * // With configuration
89
- * algorand.asset.bulkOptIn("ACCOUNTADDRESS", [12345n, 67890n], { maxFee: (1000).microAlgo(), suppressLog: true })
89
+ * assetManager.bulkOptIn("ACCOUNTADDRESS", [12345n, 67890n], { maxFee: (1000).microAlgo(), suppressLog: true })
90
90
  * ```
91
91
  * @returns An array of records matching asset ID to transaction ID of the opt in
92
92
  */
@@ -121,9 +121,9 @@ class AssetManager {
121
121
  * @example Example using AlgorandClient
122
122
  * ```typescript
123
123
  * // Basic example
124
- * algorand.asset.bulkOptOut("ACCOUNTADDRESS", [12345n, 67890n])
124
+ * assetManager.bulkOptOut("ACCOUNTADDRESS", [12345n, 67890n])
125
125
  * // With configuration
126
- * algorand.asset.bulkOptOut("ACCOUNTADDRESS", [12345n, 67890n], { ensureZeroBalance: true, maxFee: (1000).microAlgo(), suppressLog: true })
126
+ * assetManager.bulkOptOut("ACCOUNTADDRESS", [12345n, 67890n], { ensureZeroBalance: true, maxFee: (1000).microAlgo(), suppressLog: true })
127
127
  * ```
128
128
  * @returns An array of records matching asset ID to transaction ID of the opt in
129
129
  */
@@ -1 +1 @@
1
- {"version":3,"file":"asset-manager.mjs","sources":["../../src/types/asset-manager.ts"],"sourcesContent":["import algosdk, { Address } from 'algosdk'\nimport { Config } from '../config'\nimport { chunkArray } from '../util'\nimport { AccountAssetInformation } from './account'\nimport { CommonTransactionParams, MAX_TRANSACTION_GROUP_SIZE, TransactionComposer } from './composer'\nimport { SendParams } from './transaction'\n\n/** Individual result from performing a bulk opt-in or bulk opt-out for an account against a series of assets. */\nexport interface BulkAssetOptInOutResult {\n /** The ID of the asset opted into / out of */\n assetId: bigint\n /** The transaction ID of the resulting opt in / out */\n transactionId: string\n}\n\n/** Information about an asset. */\nexport interface AssetInformation {\n /** The ID of the asset. */\n assetId: bigint\n\n /** The address of the account that created the asset.\n *\n * This is the address where the parameters for this asset can be found,\n * and also the address where unwanted asset units can be sent when\n * closing out an asset position and opting-out of the asset.\n */\n creator: string\n\n /** The total amount of the smallest divisible (decimal) units that were created of the asset.\n *\n * For example, if `decimals` is, say, 2, then for every 100 `total` there is 1 whole unit.\n */\n total: bigint\n\n /** The amount of decimal places the asset was created with.\n *\n * * If 0, the asset is not divisible;\n * * If 1, the base unit of the asset is in tenths;\n * * If 2, the base unit of the asset is in hundredths;\n * * If 3, the base unit of the asset is in thousandths;\n * * and so on up to 19 decimal places.\n */\n decimals: number\n\n /** Whether the asset was frozen by default for all accounts.\n *\n * If `true` then for anyone apart from the creator to hold the\n * asset it needs to be unfrozen per account using an asset freeze\n * transaction from the `freeze` account.\n */\n defaultFrozen?: boolean\n\n /** The address of the optional account that can manage the configuration of the asset and destroy it.\n *\n * If not set the asset is permanently immutable.\n */\n manager?: string\n\n /**\n * The address of the optional account that holds the reserve (uncirculated supply) units of the asset.\n *\n * This address has no specific authority in the protocol itself and is informational only.\n *\n * Some standards like [ARC-19](https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0019.md)\n * rely on this field to hold meaningful data.\n *\n * It can be used in the case where you want to signal to holders of your asset that the uncirculated units\n * of the asset reside in an account that is different from the default creator account.\n *\n * If not set the field is permanently empty.\n */\n reserve?: string\n\n /**\n * The address of the optional account that can be used to freeze or unfreeze holdings of this asset for any account.\n *\n * If empty, freezing is not permitted.\n *\n * If not set the field is permanently empty.\n */\n freeze?: string\n\n /**\n * The address of the optional account that can clawback holdings of this asset from any account.\n *\n * The clawback account has the ability to **unconditionally take assets from any account**.\n *\n * If empty, clawback is not permitted.\n *\n * If not set the field is permanently empty.\n */\n clawback?: string\n\n /** The optional name of the unit of this asset (e.g. ticker name).\n *\n * Max size is 8 bytes.\n */\n unitName?: string\n\n /** The optional name of the unit of this asset (e.g. ticker name).\n *\n * Max size is 8 bytes.\n */\n unitNameAsBytes?: Uint8Array\n\n /** The optional name of the asset.\n *\n * Max size is 32 bytes.\n */\n assetName?: string\n\n /** The optional name of the asset.\n *\n * Max size is 32 bytes.\n */\n assetNameAsBytes?: Uint8Array\n\n /** Optional URL where more information about the asset can be retrieved (e.g. metadata).\n *\n * Max size is 96 bytes.\n */\n url?: string\n\n /** Optional URL where more information about the asset can be retrieved (e.g. metadata).\n *\n * Max size is 96 bytes.\n */\n urlAsBytes?: Uint8Array\n\n /** 32-byte hash of some metadata that is relevant to the asset and/or asset holders.\n *\n * The format of this metadata is up to the application.\n */\n metadataHash?: Uint8Array\n}\n\n/** Allows management of asset information. */\nexport class AssetManager {\n private _algod: algosdk.Algodv2\n private _newGroup: () => TransactionComposer\n\n /**\n * Create a new asset manager.\n * @param algod An algod client\n * @param newGroup A function that creates a new `TransactionComposer` transaction group\n * @example Create a new asset manager\n * ```typescript\n * const assetManager = new AssetManager(algod, () => new TransactionComposer({algod, () => signer, () => suggestedParams}))\n * ```\n */\n constructor(algod: algosdk.Algodv2, newGroup: () => TransactionComposer) {\n this._algod = algod\n this._newGroup = newGroup\n }\n\n /**\n * Returns the current asset information for the asset with the given ID.\n *\n * @example\n * ```typescript\n * const assetInfo = await assetManager.getById(12353n);\n * ```\n *\n * @param assetId The ID of the asset\n * @returns The asset information\n */\n public async getById(assetId: bigint): Promise<AssetInformation> {\n const asset = await this._algod.getAssetByID(Number(assetId)).do()\n\n return {\n assetId: BigInt(asset.index),\n total: BigInt(asset.params.total),\n decimals: Number(asset.params.decimals),\n assetName: asset.params.name,\n assetNameAsBytes: asset.params.nameB64,\n unitName: asset.params.unitName,\n unitNameAsBytes: asset.params.unitNameB64,\n url: asset.params.url,\n urlAsBytes: asset.params.urlB64,\n creator: asset.params.creator,\n manager: asset.params.manager,\n clawback: asset.params.clawback,\n freeze: asset.params.freeze,\n reserve: asset.params.reserve,\n defaultFrozen: asset.params.defaultFrozen,\n metadataHash: asset.params.metadataHash,\n }\n }\n\n /**\n * Returns the given sender account's asset holding for a given asset.\n *\n * @example\n * ```typescript\n * const address = \"XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA\";\n * const assetId = 123345n;\n * const accountInfo = await algorand.asset.getAccountInformation(address, assetId);\n * ```\n *\n * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2accountsaddressassetsasset-id)\n * @param sender The address of the sender/account to look up\n * @param assetId The ID of the asset to return a holding for\n * @returns The account asset holding information\n */\n public async getAccountInformation(sender: string | Address, assetId: bigint): Promise<AccountAssetInformation> {\n const info = await this._algod.accountAssetInformation(sender, Number(assetId)).do()\n\n return {\n assetId: BigInt(assetId),\n balance: BigInt(info.assetHolding?.amount ?? 0),\n frozen: info.assetHolding?.isFrozen === true,\n round: BigInt(info['round']),\n }\n }\n\n /**\n * Opt an account in to a list of Algorand Standard Assets.\n *\n * Transactions will be sent in batches of 16 as transaction groups.\n *\n * @param account The account to opt-in\n * @param assetIds The list of asset IDs to opt-in to\n * @param options Any parameters to control the transaction or execution of the transaction\n * @example Example using AlgorandClient\n * ```typescript\n * // Basic example\n * algorand.asset.bulkOptIn(\"ACCOUNTADDRESS\", [12345n, 67890n])\n * // With configuration\n * algorand.asset.bulkOptIn(\"ACCOUNTADDRESS\", [12345n, 67890n], { maxFee: (1000).microAlgo(), suppressLog: true })\n * ```\n * @returns An array of records matching asset ID to transaction ID of the opt in\n */\n async bulkOptIn(\n account: string | Address,\n assetIds: bigint[],\n options?: Omit<CommonTransactionParams, 'sender'> & SendParams,\n ): Promise<BulkAssetOptInOutResult[]> {\n const results: BulkAssetOptInOutResult[] = []\n\n for (const assetGroup of chunkArray(assetIds, MAX_TRANSACTION_GROUP_SIZE)) {\n const composer = this._newGroup()\n\n for (const assetId of assetGroup) {\n composer.addAssetOptIn({\n ...options,\n sender: account,\n assetId: BigInt(assetId),\n })\n }\n\n const result = await composer.send(options)\n\n Config.getLogger(options?.suppressLog).info(\n `Successfully opted in ${account} for assets ${assetGroup.join(', ')} with transaction IDs ${result.txIds.join(', ')}` +\n `\\n Grouped under ${result.groupId} in round ${result.confirmations?.[0]?.confirmedRound}.`,\n )\n\n assetGroup.forEach((assetId, index) => {\n results.push({ assetId: BigInt(assetId), transactionId: result.txIds[index] })\n })\n }\n\n return results\n }\n\n /**\n * Opt an account out of a list of Algorand Standard Assets.\n *\n * Transactions will be sent in batches of 16 as transaction groups.\n *\n * @param account The account to opt-in\n * @param assetIds The list of asset IDs to opt-out of\n * @param options Any parameters to control the transaction or execution of the transaction\n * @example Example using AlgorandClient\n * ```typescript\n * // Basic example\n * algorand.asset.bulkOptOut(\"ACCOUNTADDRESS\", [12345n, 67890n])\n * // With configuration\n * algorand.asset.bulkOptOut(\"ACCOUNTADDRESS\", [12345n, 67890n], { ensureZeroBalance: true, maxFee: (1000).microAlgo(), suppressLog: true })\n * ```\n * @returns An array of records matching asset ID to transaction ID of the opt in\n */\n async bulkOptOut(\n account: string | Address,\n assetIds: bigint[],\n options?: Omit<CommonTransactionParams, 'sender'> &\n SendParams & {\n /** Whether or not to check if the account has a zero balance for each asset first or not.\n *\n * Defaults to `true`.\n *\n * If this is set to `true` and the account has an asset balance it will throw an error.\n *\n * If this is set to `false` and the account has an asset balance it will lose those assets to the asset creator.\n */\n ensureZeroBalance?: boolean\n },\n ): Promise<BulkAssetOptInOutResult[]> {\n const results: BulkAssetOptInOutResult[] = []\n\n for (const assetGroup of chunkArray(assetIds, MAX_TRANSACTION_GROUP_SIZE)) {\n const composer = this._newGroup()\n\n const notOptedInAssetIds: bigint[] = []\n const nonZeroBalanceAssetIds: bigint[] = []\n for (const assetId of assetGroup) {\n if (options?.ensureZeroBalance !== false) {\n try {\n const accountAssetInfo = await this.getAccountInformation(account, assetId)\n if (accountAssetInfo.balance !== 0n) {\n nonZeroBalanceAssetIds.push(BigInt(assetId))\n }\n } catch {\n notOptedInAssetIds.push(BigInt(assetId))\n }\n }\n }\n\n if (notOptedInAssetIds.length > 0 || nonZeroBalanceAssetIds.length > 0) {\n throw new Error(\n `Account ${account}${notOptedInAssetIds.length > 0 ? ` is not opted-in to Asset${notOptedInAssetIds.length > 1 ? 's' : ''} ${notOptedInAssetIds.join(', ')}` : ''}${\n nonZeroBalanceAssetIds.length > 0\n ? ` has non-zero balance for Asset${nonZeroBalanceAssetIds.length > 1 ? 's' : ''} ${nonZeroBalanceAssetIds.join(', ')}`\n : ''\n }; can't opt-out.`,\n )\n }\n\n for (const assetId of assetGroup) {\n composer.addAssetOptOut({\n ...options,\n creator: (await this.getById(BigInt(assetId))).creator,\n sender: account,\n assetId: BigInt(assetId),\n })\n }\n\n const result = await composer.send(options)\n\n Config.getLogger(options?.suppressLog).info(\n `Successfully opted ${account} out of assets ${assetGroup.join(', ')} with transaction IDs ${result.txIds.join(', ')}` +\n `\\n Grouped under ${result.groupId} in round ${result.confirmations?.[0]?.confirmedRound}.`,\n )\n\n assetGroup.forEach((assetId, index) => {\n results.push({ assetId: BigInt(assetId), transactionId: result.txIds[index] })\n })\n }\n\n return results\n }\n}\n"],"names":[],"mappings":";;;;AAwIA;MACa,YAAY,CAAA;AAIvB;;;;;;;;AAQG;IACH,WAAY,CAAA,KAAsB,EAAE,QAAmC,EAAA;AACrE,QAAA,IAAI,CAAC,MAAM,GAAG,KAAK;AACnB,QAAA,IAAI,CAAC,SAAS,GAAG,QAAQ;;AAG3B;;;;;;;;;;AAUG;IACI,MAAM,OAAO,CAAC,OAAe,EAAA;AAClC,QAAA,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QAElE,OAAO;AACL,YAAA,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC;YAC5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k, { Address } from 'algosdk'\nimport { Config } from '../config'\nimport { chunkArray } from '../util'\nimport { AccountAssetInformation } from './account'\nimport { CommonTransactionParams, MAX_TRANSACTION_GROUP_SIZE, TransactionComposer } from './composer'\nimport { SendParams } from './transaction'\n\n/** Individual result from performing a bulk opt-in or bulk opt-out for an account against a series of assets. */\nexport interface BulkAssetOptInOutResult {\n /** The ID of the asset opted into / out of */\n assetId: bigint\n /** The transaction ID of the resulting opt in / out */\n transactionId: string\n}\n\n/** Information about an asset. */\nexport interface AssetInformation {\n /** The ID of the asset. */\n assetId: bigint\n\n /** The address of the account that created the asset.\n *\n * This is the address where the parameters for this asset can be found,\n * and also the address where unwanted asset units can be sent when\n * closing out an asset position and opting-out of the asset.\n */\n creator: string\n\n /** The total amount of the smallest divisible (decimal) units that were created of the asset.\n *\n * For example, if `decimals` is, say, 2, then for every 100 `total` there is 1 whole unit.\n */\n total: bigint\n\n /** The amount of decimal places the asset was created with.\n *\n * * If 0, the asset is not divisible;\n * * If 1, the base unit of the asset is in tenths;\n * * If 2, the base unit of the asset is in hundredths;\n * * If 3, the base unit of the asset is in thousandths;\n * * and so on up to 19 decimal places.\n */\n decimals: number\n\n /** Whether the asset was frozen by default for all accounts.\n *\n * If `true` then for anyone apart from the creator to hold the\n * asset it needs to be unfrozen per account using an asset freeze\n * transaction from the `freeze` account.\n */\n defaultFrozen?: boolean\n\n /** The address of the optional account that can manage the configuration of the asset and destroy it.\n *\n * If not set the asset is permanently immutable.\n */\n manager?: string\n\n /**\n * The address of the optional account that holds the reserve (uncirculated supply) units of the asset.\n *\n * This address has no specific authority in the protocol itself and is informational only.\n *\n * Some standards like [ARC-19](https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0019.md)\n * rely on this field to hold meaningful data.\n *\n * It can be used in the case where you want to signal to holders of your asset that the uncirculated units\n * of the asset reside in an account that is different from the default creator account.\n *\n * If not set the field is permanently empty.\n */\n reserve?: string\n\n /**\n * The address of the optional account that can be used to freeze or unfreeze holdings of this asset for any account.\n *\n * If empty, freezing is not permitted.\n *\n * If not set the field is permanently empty.\n */\n freeze?: string\n\n /**\n * The address of the optional account that can clawback holdings of this asset from any account.\n *\n * The clawback account has the ability to **unconditionally take assets from any account**.\n *\n * If empty, clawback is not permitted.\n *\n * If not set the field is permanently empty.\n */\n clawback?: string\n\n /** The optional name of the unit of this asset (e.g. ticker name).\n *\n * Max size is 8 bytes.\n */\n unitName?: string\n\n /** The optional name of the unit of this asset (e.g. ticker name).\n *\n * Max size is 8 bytes.\n */\n unitNameAsBytes?: Uint8Array\n\n /** The optional name of the asset.\n *\n * Max size is 32 bytes.\n */\n assetName?: string\n\n /** The optional name of the asset.\n *\n * Max size is 32 bytes.\n */\n assetNameAsBytes?: Uint8Array\n\n /** Optional URL where more information about the asset can be retrieved (e.g. metadata).\n *\n * Max size is 96 bytes.\n */\n url?: string\n\n /** Optional URL where more information about the asset can be retrieved (e.g. metadata).\n *\n * Max size is 96 bytes.\n */\n urlAsBytes?: Uint8Array\n\n /** 32-byte hash of some metadata that is relevant to the asset and/or asset holders.\n *\n * The format of this metadata is up to the application.\n */\n metadataHash?: Uint8Array\n}\n\n/** Allows management of asset information. */\nexport class AssetManager {\n private _algod: algosdk.Algodv2\n private _newGroup: () => TransactionComposer\n\n /**\n * Create a new asset manager.\n * @param algod An algod client\n * @param newGroup A function that creates a new `TransactionComposer` transaction group\n * @example Create a new asset manager\n * ```typescript\n * const assetManager = new AssetManager(algod, () => new TransactionComposer({algod, () => signer, () => suggestedParams}))\n * ```\n */\n constructor(algod: algosdk.Algodv2, newGroup: () => TransactionComposer) {\n this._algod = algod\n this._newGroup = newGroup\n }\n\n /**\n * Returns the current asset information for the asset with the given ID.\n *\n * @example\n * ```typescript\n * const assetInfo = await assetManager.getById(12353n);\n * ```\n *\n * @param assetId The ID of the asset\n * @returns The asset information\n */\n public async getById(assetId: bigint): Promise<AssetInformation> {\n const asset = await this._algod.getAssetByID(Number(assetId)).do()\n\n return {\n assetId: BigInt(asset.index),\n total: BigInt(asset.params.total),\n decimals: Number(asset.params.decimals),\n assetName: asset.params.name,\n assetNameAsBytes: asset.params.nameB64,\n unitName: asset.params.unitName,\n unitNameAsBytes: asset.params.unitNameB64,\n url: asset.params.url,\n urlAsBytes: asset.params.urlB64,\n creator: asset.params.creator,\n manager: asset.params.manager,\n clawback: asset.params.clawback,\n freeze: asset.params.freeze,\n reserve: asset.params.reserve,\n defaultFrozen: asset.params.defaultFrozen,\n metadataHash: asset.params.metadataHash,\n }\n }\n\n /**\n * Returns the given sender account's asset holding for a given asset.\n *\n * @example\n * ```typescript\n * const address = \"XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA\";\n * const assetId = 123345n;\n * const accountInfo = await assetManager.getAccountInformation(address, assetId);\n * ```\n *\n * [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2accountsaddressassetsasset-id)\n * @param sender The address of the sender/account to look up\n * @param assetId The ID of the asset to return a holding for\n * @returns The account asset holding information\n */\n public async getAccountInformation(sender: string | Address, assetId: bigint): Promise<AccountAssetInformation> {\n const info = await this._algod.accountAssetInformation(sender, Number(assetId)).do()\n\n return {\n assetId: BigInt(assetId),\n balance: BigInt(info.assetHolding?.amount ?? 0),\n frozen: info.assetHolding?.isFrozen === true,\n round: BigInt(info['round']),\n }\n }\n\n /**\n * Opt an account in to a list of Algorand Standard Assets.\n *\n * Transactions will be sent in batches of 16 as transaction groups.\n *\n * @param account The account to opt-in\n * @param assetIds The list of asset IDs to opt-in to\n * @param options Any parameters to control the transaction or execution of the transaction\n * @example Example using AlgorandClient\n * ```typescript\n * // Basic example\n * assetManager.bulkOptIn(\"ACCOUNTADDRESS\", [12345n, 67890n])\n * // With configuration\n * assetManager.bulkOptIn(\"ACCOUNTADDRESS\", [12345n, 67890n], { maxFee: (1000).microAlgo(), suppressLog: true })\n * ```\n * @returns An array of records matching asset ID to transaction ID of the opt in\n */\n async bulkOptIn(\n account: string | Address,\n assetIds: bigint[],\n options?: Omit<CommonTransactionParams, 'sender'> & SendParams,\n ): Promise<BulkAssetOptInOutResult[]> {\n const results: BulkAssetOptInOutResult[] = []\n\n for (const assetGroup of chunkArray(assetIds, MAX_TRANSACTION_GROUP_SIZE)) {\n const composer = this._newGroup()\n\n for (const assetId of assetGroup) {\n composer.addAssetOptIn({\n ...options,\n sender: account,\n assetId: BigInt(assetId),\n })\n }\n\n const result = await composer.send(options)\n\n Config.getLogger(options?.suppressLog).info(\n `Successfully opted in ${account} for assets ${assetGroup.join(', ')} with transaction IDs ${result.txIds.join(', ')}` +\n `\\n Grouped under ${result.groupId} in round ${result.confirmations?.[0]?.confirmedRound}.`,\n )\n\n assetGroup.forEach((assetId, index) => {\n results.push({ assetId: BigInt(assetId), transactionId: result.txIds[index] })\n })\n }\n\n return results\n }\n\n /**\n * Opt an account out of a list of Algorand Standard Assets.\n *\n * Transactions will be sent in batches of 16 as transaction groups.\n *\n * @param account The account to opt-in\n * @param assetIds The list of asset IDs to opt-out of\n * @param options Any parameters to control the transaction or execution of the transaction\n * @example Example using AlgorandClient\n * ```typescript\n * // Basic example\n * assetManager.bulkOptOut(\"ACCOUNTADDRESS\", [12345n, 67890n])\n * // With configuration\n * assetManager.bulkOptOut(\"ACCOUNTADDRESS\", [12345n, 67890n], { ensureZeroBalance: true, maxFee: (1000).microAlgo(), suppressLog: true })\n * ```\n * @returns An array of records matching asset ID to transaction ID of the opt in\n */\n async bulkOptOut(\n account: string | Address,\n assetIds: bigint[],\n options?: Omit<CommonTransactionParams, 'sender'> &\n SendParams & {\n /** Whether or not to check if the account has a zero balance for each asset first or not.\n *\n * Defaults to `true`.\n *\n * If this is set to `true` and the account has an asset balance it will throw an error.\n *\n * If this is set to `false` and the account has an asset balance it will lose those assets to the asset creator.\n */\n ensureZeroBalance?: boolean\n },\n ): Promise<BulkAssetOptInOutResult[]> {\n const results: BulkAssetOptInOutResult[] = []\n\n for (const assetGroup of chunkArray(assetIds, MAX_TRANSACTION_GROUP_SIZE)) {\n const composer = this._newGroup()\n\n const notOptedInAssetIds: bigint[] = []\n const nonZeroBalanceAssetIds: bigint[] = []\n for (const assetId of assetGroup) {\n if (options?.ensureZeroBalance !== false) {\n try {\n const accountAssetInfo = await this.getAccountInformation(account, assetId)\n if (accountAssetInfo.balance !== 0n) {\n nonZeroBalanceAssetIds.push(BigInt(assetId))\n }\n } catch {\n notOptedInAssetIds.push(BigInt(assetId))\n }\n }\n }\n\n if (notOptedInAssetIds.length > 0 || nonZeroBalanceAssetIds.length > 0) {\n throw new Error(\n `Account ${account}${notOptedInAssetIds.length > 0 ? ` is not opted-in to Asset${notOptedInAssetIds.length > 1 ? 's' : ''} ${notOptedInAssetIds.join(', ')}` : ''}${\n nonZeroBalanceAssetIds.length > 0\n ? ` has non-zero balance for Asset${nonZeroBalanceAssetIds.length > 1 ? 's' : ''} ${nonZeroBalanceAssetIds.join(', ')}`\n : ''\n }; can't opt-out.`,\n )\n }\n\n for (const assetId of assetGroup) {\n composer.addAssetOptOut({\n ...options,\n creator: (await this.getById(BigInt(assetId))).creator,\n sender: account,\n assetId: BigInt(assetId),\n })\n }\n\n const result = await composer.send(options)\n\n Config.getLogger(options?.suppressLog).info(\n `Successfully opted ${account} out of assets ${assetGroup.join(', ')} with transaction IDs ${result.txIds.join(', ')}` +\n `\\n Grouped under ${result.groupId} in round ${result.confirmations?.[0]?.confirmedRound}.`,\n )\n\n assetGroup.forEach((assetId, index) => {\n results.push({ assetId: BigInt(assetId), transactionId: result.txIds[index] })\n })\n }\n\n return results\n }\n}\n"],"names":[],"mappings":";;;;AAwIA;MACa,YAAY,CAAA;AAIvB;;;;;;;;AAQG;IACH,WAAY,CAAA,KAAsB,EAAE,QAAmC,EAAA;AACrE,QAAA,IAAI,CAAC,MAAM,GAAG,KAAK;AACnB,QAAA,IAAI,CAAC,SAAS,GAAG,QAAQ;;AAG3B;;;;;;;;;;AAUG;IACI,MAAM,OAAO,CAAC,OAAe,EAAA;AAClC,Q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