@algorandfoundation/algokit-utils 7.0.0-beta.6 → 7.0.0-beta.7
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.
- package/app.d.ts +6 -6
- package/app.js +6 -6
- package/app.js.map +1 -1
- package/app.mjs +6 -6
- package/app.mjs.map +1 -1
- package/asset.d.ts +3 -3
- package/asset.js +3 -3
- package/asset.js.map +1 -1
- package/asset.mjs +3 -3
- package/asset.mjs.map +1 -1
- package/package.json +1 -1
- package/testing/fixtures/algorand-fixture.js +1 -1
- package/testing/fixtures/algorand-fixture.js.map +1 -1
- package/testing/fixtures/algorand-fixture.mjs +1 -1
- package/testing/fixtures/algorand-fixture.mjs.map +1 -1
- package/transaction/legacy-bridge.d.ts +3 -3
- package/transaction/legacy-bridge.js.map +1 -1
- package/transaction/legacy-bridge.mjs.map +1 -1
- package/transaction/transaction.d.ts +1 -3
- package/transaction/transaction.js +17 -11
- package/transaction/transaction.js.map +1 -1
- package/transaction/transaction.mjs +17 -11
- package/transaction/transaction.mjs.map +1 -1
- package/transfer/transfer-algos.d.ts +1 -1
- package/transfer/transfer-algos.js +1 -1
- package/transfer/transfer-algos.js.map +1 -1
- package/transfer/transfer-algos.mjs +1 -1
- package/transfer/transfer-algos.mjs.map +1 -1
- package/transfer/transfer.d.ts +1 -1
- package/transfer/transfer.js +1 -1
- package/transfer/transfer.js.map +1 -1
- package/transfer/transfer.mjs +1 -1
- package/transfer/transfer.mjs.map +1 -1
- package/types/account-manager.d.ts +13 -4
- package/types/account-manager.js +17 -3
- package/types/account-manager.js.map +1 -1
- package/types/account-manager.mjs +17 -3
- package/types/account-manager.mjs.map +1 -1
- package/types/algorand-client-interface.d.ts +1 -1
- package/types/algorand-client-transaction-creator.d.ts +30 -30
- package/types/algorand-client-transaction-creator.js +30 -30
- package/types/algorand-client-transaction-creator.js.map +1 -1
- package/types/algorand-client-transaction-creator.mjs +30 -30
- package/types/algorand-client-transaction-creator.mjs.map +1 -1
- package/types/algorand-client-transaction-sender.d.ts +18 -18
- package/types/algorand-client-transaction-sender.js +1 -1
- package/types/algorand-client-transaction-sender.js.map +1 -1
- package/types/algorand-client-transaction-sender.mjs +1 -1
- package/types/algorand-client-transaction-sender.mjs.map +1 -1
- package/types/algorand-client.d.ts +8 -8
- package/types/algorand-client.js +8 -8
- package/types/algorand-client.js.map +1 -1
- package/types/algorand-client.mjs +8 -8
- package/types/algorand-client.mjs.map +1 -1
- package/types/app-arc56.d.ts +60 -37
- package/types/app-arc56.js +37 -16
- package/types/app-arc56.js.map +1 -1
- package/types/app-arc56.mjs +37 -16
- package/types/app-arc56.mjs.map +1 -1
- package/types/app-client.d.ts +101 -78
- package/types/app-client.js +145 -84
- package/types/app-client.js.map +1 -1
- package/types/app-client.mjs +145 -84
- package/types/app-client.mjs.map +1 -1
- package/types/app-deployer.d.ts +2 -2
- package/types/app-deployer.js +24 -24
- package/types/app-deployer.js.map +1 -1
- package/types/app-deployer.mjs +24 -24
- package/types/app-deployer.mjs.map +1 -1
- package/types/app-factory.d.ts +141 -86
- package/types/app-factory.js +106 -34
- package/types/app-factory.js.map +1 -1
- package/types/app-factory.mjs +107 -35
- package/types/app-factory.mjs.map +1 -1
- package/types/app-spec.js +15 -9
- package/types/app-spec.js.map +1 -1
- package/types/app-spec.mjs +15 -9
- package/types/app-spec.mjs.map +1 -1
- package/types/asset-manager.d.ts +3 -3
- package/types/asset-manager.js +2 -2
- package/types/asset-manager.js.map +1 -1
- package/types/asset-manager.mjs +2 -2
- package/types/asset-manager.mjs.map +1 -1
- package/types/client-manager.d.ts +30 -8
- package/types/client-manager.js +6 -0
- package/types/client-manager.js.map +1 -1
- package/types/client-manager.mjs +6 -0
- package/types/client-manager.mjs.map +1 -1
- package/types/composer.d.ts +29 -4
- package/types/composer.js +24 -7
- package/types/composer.js.map +1 -1
- package/types/composer.mjs +24 -7
- package/types/composer.mjs.map +1 -1
- package/types/kmd-account-manager.js +1 -1
- package/types/kmd-account-manager.js.map +1 -1
- package/types/kmd-account-manager.mjs +1 -1
- package/types/kmd-account-manager.mjs.map +1 -1
- package/types/transaction.d.ts +4 -6
package/types/asset-manager.mjs
CHANGED
|
@@ -103,7 +103,7 @@ class AssetManager {
|
|
|
103
103
|
assetId: BigInt(assetId),
|
|
104
104
|
});
|
|
105
105
|
}
|
|
106
|
-
const result = await composer.
|
|
106
|
+
const result = await composer.send(options);
|
|
107
107
|
Config.getLogger(options?.suppressLog).info(`Successfully opted in ${account} for assets ${assetGroup.join(', ')} with transaction IDs ${result.txIds.join(', ')}` +
|
|
108
108
|
`\n Grouped under ${result.groupId} in round ${result.confirmations?.[0]?.confirmedRound}.`);
|
|
109
109
|
assetGroup.forEach((assetId, index) => {
|
|
@@ -162,7 +162,7 @@ class AssetManager {
|
|
|
162
162
|
assetId: BigInt(assetId),
|
|
163
163
|
});
|
|
164
164
|
}
|
|
165
|
-
const result = await composer.
|
|
165
|
+
const result = await composer.send(options);
|
|
166
166
|
Config.getLogger(options?.suppressLog).info(`Successfully opted ${account} out of assets ${assetGroup.join(', ')} with transaction IDs ${result.txIds.join(', ')}` +
|
|
167
167
|
`\n Grouped under ${result.groupId} in round ${result.confirmations?.[0]?.confirmedRound}.`);
|
|
168
168
|
assetGroup.forEach((assetId, index) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asset-manager.mjs","sources":["../../src/types/asset-manager.ts"],"sourcesContent":["import algosdk from 'algosdk'\nimport { Config } from '../config'\nimport { chunkArray } from '../util'\nimport { AccountAssetInformation, TransactionSignerAccount } from './account'\nimport AlgoKitComposer, { CommonTransactionParams, MAX_TRANSACTION_GROUP_SIZE } from './composer'\nimport { ExecuteParams } from './transaction'\nimport AssetModel = algosdk.modelsv2.Asset\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: () => AlgoKitComposer\n\n /**\n * Create a new asset manager.\n * @param algod An algod client\n * @param newGroup A function that creates a new `AlgoKitComposer` transaction group\n * @example Create a new asset manager\n * ```typescript\n * const assetManager = new AssetManager(algod, () => new AlgoKitComposer({algod, () => signer, () => suggestedParams}))\n * ```\n */\n constructor(algod: algosdk.Algodv2, newGroup: () => AlgoKitComposer) {\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 = AssetModel.from_obj_for_encoding(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 | TransactionSignerAccount, assetId: bigint): Promise<AccountAssetInformation> {\n const info = await this._algod.accountAssetInformation(typeof sender === 'string' ? sender : sender.addr, Number(assetId)).do()\n\n return {\n assetId: BigInt(assetId),\n balance: BigInt(info['asset-holding']['amount']),\n frozen: info['asset-holding']['is-frozen'] === 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 | TransactionSignerAccount,\n assetIds: bigint[],\n options?: Omit<CommonTransactionParams, 'sender'> & ExecuteParams,\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: typeof account === 'string' ? account : account.addr,\n assetId: BigInt(assetId),\n })\n }\n\n const result = await composer.execute(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 | TransactionSignerAccount,\n assetIds: bigint[],\n options?: Omit<CommonTransactionParams, 'sender'> &\n ExecuteParams & {\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 const sender = typeof account === 'string' ? account : account.addr\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(sender, 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 ${sender}${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,\n assetId: BigInt(assetId),\n })\n }\n\n const result = await composer.execute(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":";;;;;AAMA,IAAO,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAA;AAmI1C;MACa,YAAY,CAAA;AAIvB;;;;;;;;AAQG;IACH,WAAY,CAAA,KAAsB,EAAE,QAA+B,EAAA;AACjE,QAAA,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;AACnB,QAAA,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAA;KAC1B;AAED;;;;;;;;;;AAUG;IACI,MAAM,OAAO,CAAC,OAAe,EAAA;QAClC,MAAM,KAAK,GAAG,UAAU,CAAC,qBAAqB,CAAC,MAAM,IAAI,CAAC,MAAM,C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M,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,CAAA;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,CAAA;AAChF,aAAC,CAAC,CAAA;SACH;AAED,QAAA,OAAO,OAAO,CAAA;KACf;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"asset-manager.mjs","sources":["../../src/types/asset-manager.ts"],"sourcesContent":["import algosdk from 'algosdk'\nimport { Config } from '../config'\nimport { chunkArray } from '../util'\nimport { AccountAssetInformation, TransactionSignerAccount } from './account'\nimport AlgoKitComposer, { CommonTransactionParams, MAX_TRANSACTION_GROUP_SIZE } from './composer'\nimport { SendParams } from './transaction'\nimport AssetModel = algosdk.modelsv2.Asset\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: () => AlgoKitComposer\n\n /**\n * Create a new asset manager.\n * @param algod An algod client\n * @param newGroup A function that creates a new `AlgoKitComposer` transaction group\n * @example Create a new asset manager\n * ```typescript\n * const assetManager = new AssetManager(algod, () => new AlgoKitComposer({algod, () => signer, () => suggestedParams}))\n * ```\n */\n constructor(algod: algosdk.Algodv2, newGroup: () => AlgoKitComposer) {\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 = AssetModel.from_obj_for_encoding(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 | TransactionSignerAccount, assetId: bigint): Promise<AccountAssetInformation> {\n const info = await this._algod.accountAssetInformation(typeof sender === 'string' ? sender : sender.addr, Number(assetId)).do()\n\n return {\n assetId: BigInt(assetId),\n balance: BigInt(info['asset-holding']['amount']),\n frozen: info['asset-holding']['is-frozen'] === 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 | TransactionSignerAccount,\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: typeof account === 'string' ? account : account.addr,\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 | TransactionSignerAccount,\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 const sender = typeof account === 'string' ? account : account.addr\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(sender, 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 ${sender}${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,\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":";;;;;AAMA,IAAO,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAA;AAmI1C;MACa,YAAY,CAAA;AAIvB;;;;;;;;AAQG;IACH,WAAY,CAAA,KAAsB,EAAE,QAA+B,EAAA;AACjE,QAAA,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;AACnB,QAAA,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAA;KAC1B;AAED;;;;;;;;;;AAUG;IACI,MAAM,OAAO,CAAC,OAAe,EAAA;QAClC,MAAM,KAAK,GAAG,UAAU,CAAC,qBAAqB,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;QAEpG,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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AAa,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;AAChF,aAAC,CAAC,CAAA;SACH;AAED,QAAA,OAAO,OAAO,CAAA;KACf;AACF;;;;"}
|
|
@@ -18,6 +18,22 @@ export interface AlgoSdkClients {
|
|
|
18
18
|
/** Optional KMD client, see https://developer.algorand.org/docs/rest-apis/kmd/ */
|
|
19
19
|
kmd?: algosdk.Kmd;
|
|
20
20
|
}
|
|
21
|
+
/** Params to get an app factory from `ClientManager`. */
|
|
22
|
+
export type ClientAppFactoryParams = Expand<Omit<AppFactoryParams, 'algorand'>>;
|
|
23
|
+
/** Params to get an app client by creator address and name from `ClientManager`. */
|
|
24
|
+
export type ClientResolveAppClientByCreatorAndNameParams = Expand<Omit<ResolveAppClientByCreatorAndName, 'algorand'>>;
|
|
25
|
+
/** Params to get an app client by ID from `ClientManager`. */
|
|
26
|
+
export type ClientAppClientParams = Expand<Omit<AppClientParams, 'algorand'>>;
|
|
27
|
+
/** Params to get an app client by network from `ClientManager`. */
|
|
28
|
+
export type ClientAppClientByNetworkParams = Expand<Omit<AppClientParams, 'algorand' | 'appId'>>;
|
|
29
|
+
/** Params to get a typed app client by creator address and name from `ClientManager`. */
|
|
30
|
+
export type ClientTypedAppClientByCreatorAndNameParams = Expand<Omit<ResolveAppClientByCreatorAndName, 'algorand' | 'appSpec'>>;
|
|
31
|
+
/** Params to get a typed app client by ID from `ClientManager`. */
|
|
32
|
+
export type ClientTypedAppClientParams = Expand<Omit<AppClientParams, 'algorand' | 'appSpec'>>;
|
|
33
|
+
/** Params to get a typed app client by network from `ClientManager`. */
|
|
34
|
+
export type ClientTypedAppClientByNetworkParams = Expand<Omit<AppClientParams, 'algorand' | 'appSpec' | 'appId'>>;
|
|
35
|
+
/** Params to get a typed app factory from `ClientManager`. */
|
|
36
|
+
export type ClientTypedAppFactoryParams = Expand<Omit<AppFactoryParams, 'algorand' | 'appSpec'>>;
|
|
21
37
|
/** Exposes access to various API clients. */
|
|
22
38
|
export declare class ClientManager {
|
|
23
39
|
private _algod;
|
|
@@ -139,32 +155,36 @@ export declare class ClientManager {
|
|
|
139
155
|
* })
|
|
140
156
|
* ```
|
|
141
157
|
*/
|
|
142
|
-
getAppFactory(params:
|
|
158
|
+
getAppFactory(params: ClientAppFactoryParams): AppFactory;
|
|
143
159
|
/**
|
|
144
160
|
* Returns a new `AppClient` client for managing calls and state for an ARC-32/ARC-56 app.
|
|
145
161
|
* This method resolves the app ID by looking up the creator address and name
|
|
146
162
|
* using AlgoKit app deployment semantics (i.e. looking for the app creation transaction note).
|
|
147
163
|
* @param params The parameters to create the app client
|
|
148
164
|
* @example Basic
|
|
165
|
+
* ```typescript
|
|
149
166
|
* const appClient = algorand.client.getAppClientByCreatorAndName({
|
|
150
167
|
* appSpec: '{/* ARC-56 or ARC-32 compatible JSON *\}',
|
|
151
168
|
* // appId resolved by looking for app ID of named app by this creator
|
|
152
169
|
* creatorAddress: 'CREATORADDRESS',
|
|
153
170
|
* })
|
|
171
|
+
* ```
|
|
154
172
|
* @returns The `AppClient`
|
|
155
173
|
*/
|
|
156
|
-
getAppClientByCreatorAndName(params:
|
|
174
|
+
getAppClientByCreatorAndName(params: ClientResolveAppClientByCreatorAndNameParams): Promise<AppClient>;
|
|
157
175
|
/**
|
|
158
176
|
* Returns a new `AppClient` client for managing calls and state for an ARC-32/ARC-56 app.
|
|
159
177
|
* @param params The parameters to create the app client
|
|
160
178
|
* @example Basic
|
|
179
|
+
* ```typescript
|
|
161
180
|
* const appClient = algorand.client.getAppClientById({
|
|
162
181
|
* appSpec: '{/* ARC-56 or ARC-32 compatible JSON *\}',
|
|
163
182
|
* appId: 12345n,
|
|
164
183
|
* })
|
|
184
|
+
* ```
|
|
165
185
|
* @returns The `AppClient`
|
|
166
186
|
*/
|
|
167
|
-
getAppClientById(params:
|
|
187
|
+
getAppClientById(params: ClientAppClientParams): AppClient;
|
|
168
188
|
/**
|
|
169
189
|
* Returns a new `AppClient` client for managing calls and state for an ARC-56 app.
|
|
170
190
|
* This method resolves the app ID for the current network based on
|
|
@@ -173,13 +193,15 @@ export declare class ClientManager {
|
|
|
173
193
|
* If no IDs are in the app spec or the network isn't recognised, an error is thrown.
|
|
174
194
|
* @param params The parameters to create the app client
|
|
175
195
|
* @example Basic
|
|
196
|
+
* ```typescript
|
|
176
197
|
* const appClient = algorand.client.getAppClientByNetwork({
|
|
177
198
|
* appSpec: '{/* ARC-56 or ARC-32 compatible JSON *\}',
|
|
178
199
|
* // appId resolved by using ARC-56 spec to find app ID for current network
|
|
179
200
|
* })
|
|
201
|
+
* ```
|
|
180
202
|
* @returns The `AppClient`
|
|
181
203
|
*/
|
|
182
|
-
getAppClientByNetwork(params:
|
|
204
|
+
getAppClientByNetwork(params: ClientAppClientByNetworkParams): Promise<AppClient>;
|
|
183
205
|
/**
|
|
184
206
|
* Returns a new typed client, resolving the app by creator address and name.
|
|
185
207
|
* @param typedClient The typed client type to use
|
|
@@ -201,7 +223,7 @@ export declare class ClientManager {
|
|
|
201
223
|
* ```
|
|
202
224
|
* @returns The typed client instance
|
|
203
225
|
*/
|
|
204
|
-
getTypedAppClientByCreatorAndName<TClient extends TypedAppClient<InstanceType<TClient>>>(typedClient: TClient, params:
|
|
226
|
+
getTypedAppClientByCreatorAndName<TClient extends TypedAppClient<InstanceType<TClient>>>(typedClient: TClient, params: ClientTypedAppClientByCreatorAndNameParams): Promise<InstanceType<TClient>>;
|
|
205
227
|
/**
|
|
206
228
|
* Returns a new typed client, resolving the app by app ID.
|
|
207
229
|
* @param typedClient The typed client type to use
|
|
@@ -215,7 +237,7 @@ export declare class ClientManager {
|
|
|
215
237
|
* ```
|
|
216
238
|
* @returns The typed client instance
|
|
217
239
|
*/
|
|
218
|
-
getTypedAppClientById<TClient extends TypedAppClient<InstanceType<TClient>>>(typedClient: TClient, params:
|
|
240
|
+
getTypedAppClientById<TClient extends TypedAppClient<InstanceType<TClient>>>(typedClient: TClient, params: ClientTypedAppClientParams): InstanceType<TClient>;
|
|
219
241
|
/**
|
|
220
242
|
* Returns a new typed client, resolves the app ID for the current network based on
|
|
221
243
|
* pre-determined network-specific app IDs specified in the ARC-56 app spec.
|
|
@@ -231,7 +253,7 @@ export declare class ClientManager {
|
|
|
231
253
|
* ```
|
|
232
254
|
* @returns The typed client instance
|
|
233
255
|
*/
|
|
234
|
-
getTypedAppClientByNetwork<TClient extends TypedAppClient<InstanceType<TClient>>>(typedClient: TClient, params?:
|
|
256
|
+
getTypedAppClientByNetwork<TClient extends TypedAppClient<InstanceType<TClient>>>(typedClient: TClient, params?: ClientTypedAppClientByNetworkParams): Promise<InstanceType<TClient>>;
|
|
235
257
|
/**
|
|
236
258
|
* Returns a new typed app factory.
|
|
237
259
|
* @param typedFactory The typed factory type to use
|
|
@@ -244,7 +266,7 @@ export declare class ClientManager {
|
|
|
244
266
|
* ```
|
|
245
267
|
* @returns The typed client instance
|
|
246
268
|
*/
|
|
247
|
-
getTypedAppFactory<TClient>(typedFactory: TypedAppFactory<TClient>, params?:
|
|
269
|
+
getTypedAppFactory<TClient>(typedFactory: TypedAppFactory<TClient>, params?: ClientTypedAppFactoryParams): TClient;
|
|
248
270
|
/**
|
|
249
271
|
* Retrieve client configurations from environment variables when defined or get defaults (expects to be called from a Node.js environment)
|
|
250
272
|
*
|
package/types/client-manager.js
CHANGED
|
@@ -186,11 +186,13 @@ class ClientManager {
|
|
|
186
186
|
* using AlgoKit app deployment semantics (i.e. looking for the app creation transaction note).
|
|
187
187
|
* @param params The parameters to create the app client
|
|
188
188
|
* @example Basic
|
|
189
|
+
* ```typescript
|
|
189
190
|
* const appClient = algorand.client.getAppClientByCreatorAndName({
|
|
190
191
|
* appSpec: '{/* ARC-56 or ARC-32 compatible JSON *\}',
|
|
191
192
|
* // appId resolved by looking for app ID of named app by this creator
|
|
192
193
|
* creatorAddress: 'CREATORADDRESS',
|
|
193
194
|
* })
|
|
195
|
+
* ```
|
|
194
196
|
* @returns The `AppClient`
|
|
195
197
|
*/
|
|
196
198
|
getAppClientByCreatorAndName(params) {
|
|
@@ -206,10 +208,12 @@ class ClientManager {
|
|
|
206
208
|
* Returns a new `AppClient` client for managing calls and state for an ARC-32/ARC-56 app.
|
|
207
209
|
* @param params The parameters to create the app client
|
|
208
210
|
* @example Basic
|
|
211
|
+
* ```typescript
|
|
209
212
|
* const appClient = algorand.client.getAppClientById({
|
|
210
213
|
* appSpec: '{/* ARC-56 or ARC-32 compatible JSON *\}',
|
|
211
214
|
* appId: 12345n,
|
|
212
215
|
* })
|
|
216
|
+
* ```
|
|
213
217
|
* @returns The `AppClient`
|
|
214
218
|
*/
|
|
215
219
|
getAppClientById(params) {
|
|
@@ -226,10 +230,12 @@ class ClientManager {
|
|
|
226
230
|
* If no IDs are in the app spec or the network isn't recognised, an error is thrown.
|
|
227
231
|
* @param params The parameters to create the app client
|
|
228
232
|
* @example Basic
|
|
233
|
+
* ```typescript
|
|
229
234
|
* const appClient = algorand.client.getAppClientByNetwork({
|
|
230
235
|
* appSpec: '{/* ARC-56 or ARC-32 compatible JSON *\}',
|
|
231
236
|
* // appId resolved by using ARC-56 spec to find app ID for current network
|
|
232
237
|
* })
|
|
238
|
+
* ```
|
|
233
239
|
* @returns The `AppClient`
|
|
234
240
|
*/
|
|
235
241
|
async getAppClientByNetwork(params) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-manager.js","sources":["../../src/types/client-manager.ts"],"sourcesContent":["import algosdk from 'algosdk'\nimport { SuggestedParamsWithMinFee } from 'algosdk/dist/types/types/transactions/base'\nimport { AlgoHttpClientWithRetry } from './algo-http-client-with-retry'\nimport { AlgorandClientInterface } from './algorand-client-interface'\nimport { AppClient, AppClientParams, ResolveAppClientByCreatorAndName } from './app-client'\nimport { AppFactory, AppFactoryParams } from './app-factory'\nimport { TestNetDispenserApiClient, TestNetDispenserApiClientParams } from './dispenser-client'\nimport { Expand } from './expand'\nimport { AlgoClientConfig, AlgoConfig, NetworkDetails, genesisIdIsLocalNet } from './network-client'\nimport Kmd = algosdk.Kmd\nimport Indexer = algosdk.Indexer\nimport Algodv2 = algosdk.Algodv2\nimport IntDecoding = algosdk.IntDecoding\n\n/** Clients from algosdk that interact with the official Algorand APIs */\nexport interface AlgoSdkClients {\n /** Algod client, see https://developer.algorand.org/docs/rest-apis/algod/ */\n algod: algosdk.Algodv2\n /** Optional indexer client, see https://developer.algorand.org/docs/rest-apis/indexer/ */\n indexer?: algosdk.Indexer\n /** Optional KMD client, see https://developer.algorand.org/docs/rest-apis/kmd/ */\n kmd?: algosdk.Kmd\n}\n\n/** Exposes access to various API clients. */\nexport class ClientManager {\n private _algod: algosdk.Algodv2\n private _indexer?: algosdk.Indexer\n private _kmd?: algosdk.Kmd\n private _algorand?: AlgorandClientInterface\n\n /**\n * algosdk clients or config for interacting with the official Algorand APIs.\n * @param clientsOrConfig The clients or config to use\n * @example Algod client only\n * ```typescript\n * const clientManager = new ClientManager({ algod: algodClient })\n * ```\n * @example All clients\n * ```typescript\n * const clientManager = new ClientManager({ algod: algodClient, indexer: indexerClient, kmd: kmdClient })\n * ```\n * @example Algod config only\n * ```typescript\n * const clientManager = new ClientManager({ algodConfig })\n * ```\n * @example All client configs\n * ```typescript\n * const clientManager = new ClientManager({ algodConfig, indexerConfig, kmdConfig })\n * ```\n */\n constructor(clientsOrConfig: AlgoConfig | AlgoSdkClients, algorandClient?: AlgorandClientInterface) {\n const _clients =\n 'algod' in clientsOrConfig\n ? clientsOrConfig\n : {\n algod: ClientManager.getAlgodClient(clientsOrConfig.algodConfig),\n indexer: clientsOrConfig.indexerConfig ? ClientManager.getIndexerClient(clientsOrConfig.indexerConfig) : undefined,\n kmd: clientsOrConfig.kmdConfig ? ClientManager.getKmdClient(clientsOrConfig.kmdConfig) : undefined,\n }\n this._algod = _clients.algod\n this._indexer = _clients.indexer\n this._kmd = _clients.kmd\n this._algorand = algorandClient\n }\n\n /** Returns an algosdk Algod API client. */\n public get algod(): algosdk.Algodv2 {\n return this._algod\n }\n\n /** Returns an algosdk Indexer API client or throws an error if it's not been provided. */\n public get indexer(): algosdk.Indexer {\n if (!this._indexer) throw new Error('Attempt to use Indexer client in AlgoKit instance with no Indexer configured')\n return this._indexer\n }\n\n /** Returns an algosdk Indexer API client or `undefined` if it's not been provided. */\n public get indexerIfPresent(): algosdk.Indexer | undefined {\n return this._indexer\n }\n\n /** Returns an algosdk KMD API client or throws an error if it's not been provided. */\n public get kmd(): algosdk.Kmd {\n if (!this._kmd) throw new Error('Attempt to use Kmd client in AlgoKit instance with no Kmd configured')\n return this._kmd\n }\n\n private _getNetworkPromise: Promise<SuggestedParamsWithMinFee> | undefined\n /**\n * Get details about the current network.\n * @example Getting genesis ID\n * ```typescript\n * const network = await networkClient.network()\n * const genesisId = network.genesisId\n * ```\n * @returns The current network details\n */\n public async network(): Promise<NetworkDetails> {\n if (!this._getNetworkPromise) {\n this._getNetworkPromise = this._algod.getTransactionParams().do()\n }\n\n const params = await this._getNetworkPromise\n return {\n isTestNet: ['testnet-v1.0', 'testnet-v1', 'testnet'].includes(params.genesisID),\n isMainNet: ['mainnet-v1.0', 'mainnet-v1', 'mainnet'].includes(params.genesisID),\n isLocalNet: ClientManager.genesisIdIsLocalNet(params.genesisID),\n genesisId: params.genesisID,\n genesisHash: params.genesisHash,\n }\n }\n\n /**\n * Returns true if the given network genesisId is associated with a LocalNet network.\n * @param genesisId The network genesis ID\n * @returns Whether the given genesis ID is associated with a LocalNet network\n */\n public static genesisIdIsLocalNet(genesisId: string) {\n return genesisIdIsLocalNet(genesisId)\n }\n\n /**\n * Returns true if the current network is LocalNet.\n * @returns True if the current network is LocalNet.\n */\n public async isLocalNet() {\n return (await this.network()).isLocalNet\n }\n\n /**\n * Returns true if the current network is TestNet.\n * @returns True if the current network is TestNet.\n */\n public async isTestNet() {\n return (await this.network()).isTestNet\n }\n\n /**\n * Returns true if the current network is MainNet.\n * @returns True if the current network is MainNet.\n */\n public async isMainNet() {\n return (await this.network()).isMainNet\n }\n\n /**\n * Returns a TestNet Dispenser API client.\n *\n * Refer to [docs](https://github.com/algorandfoundation/algokit/blob/main/docs/testnet_api.md) on guidance to obtain an access token.\n *\n * @param params An object containing parameters for the TestNetDispenserApiClient class.\n * @example\n * const client = clientManager.getTestNetDispenser(\n * {\n * authToken: 'your_auth_token',\n * requestTimeout: 15,\n * }\n * )\n *\n * @returns An instance of the TestNetDispenserApiClient class.\n */\n public getTestNetDispenser(params: TestNetDispenserApiClientParams) {\n return new TestNetDispenserApiClient(params)\n }\n\n /**\n * Returns a TestNet Dispenser API client, loading the auth token from `process.env.ALGOKIT_DISPENSER_ACCESS_TOKEN`.\n *\n * Refer to [docs](https://github.com/algorandfoundation/algokit/blob/main/docs/testnet_api.md) on guidance to obtain an access token.\n *\n * @param params An object containing parameters for the TestNetDispenserApiClient class.\n * @example\n * const client = clientManager.getTestNetDispenserFromEnvironment(\n * {\n * requestTimeout: 15,\n * }\n * )\n *\n * @returns An instance of the TestNetDispenserApiClient class.\n */\n public getTestNetDispenserFromEnvironment(params?: Omit<TestNetDispenserApiClientParams, 'authToken'>) {\n return new TestNetDispenserApiClient(params ? { ...params, authToken: '' } : undefined)\n }\n\n /**\n * Returns a new `AppFactory` client\n * @example Basic example\n * ```typescript\n * const factory = algorand.client.getAppFactory({\n * appSpec: '{/* ARC-56 or ARC-32 compatible JSON *\\/}',\n * })\n * ```\n * @example Advanced example\n * ```typescript\n * const factory = algorand.client.getAppFactory({\n * appSpec: parsedAppSpec_AppSpec_or_Arc56Contract,\n * defaultSender: \"SENDERADDRESS\",\n * appName: \"OverriddenAppName\",\n * version: \"2.0.0\",\n * updatable: true,\n * deletable: false,\n * deployTimeParams: { ONE: 1, TWO: 'value' }\n * })\n * ```\n */\n public getAppFactory(params: Expand<Omit<AppFactoryParams, 'algorand'>>) {\n if (!this._algorand) {\n throw new Error('Attempt to get app factory from a ClientManager without an Algorand client')\n }\n\n return new AppFactory({ ...params, algorand: this._algorand })\n }\n\n /**\n * Returns a new `AppClient` client for managing calls and state for an ARC-32/ARC-56 app.\n * This method resolves the app ID by looking up the creator address and name\n * using AlgoKit app deployment semantics (i.e. looking for the app creation transaction note).\n * @param params The parameters to create the app client\n * @example Basic\n * const appClient = algorand.client.getAppClientByCreatorAndName({\n * appSpec: '{/* ARC-56 or ARC-32 compatible JSON *\\}',\n * // appId resolved by looking for app ID of named app by this creator\n * creatorAddress: 'CREATORADDRESS',\n * })\n * @returns The `AppClient`\n */\n public getAppClientByCreatorAndName(params: Expand<Omit<ResolveAppClientByCreatorAndName, 'algorand'>>) {\n if (!this._algorand) {\n throw new Error('Attempt to get app client from a ClientManager without an Algorand client')\n }\n\n return AppClient.fromCreatorAndName({\n ...params,\n algorand: this._algorand,\n })\n }\n\n /**\n * Returns a new `AppClient` client for managing calls and state for an ARC-32/ARC-56 app.\n * @param params The parameters to create the app client\n * @example Basic\n * const appClient = algorand.client.getAppClientById({\n * appSpec: '{/* ARC-56 or ARC-32 compatible JSON *\\}',\n * appId: 12345n,\n * })\n * @returns The `AppClient`\n */\n public getAppClientById(params: Expand<Omit<AppClientParams, 'algorand'>>) {\n if (!this._algorand) {\n throw new Error('Attempt to get app client from a ClientManager without an Algorand client')\n }\n return new AppClient({ ...params, algorand: this._algorand })\n }\n\n /**\n * Returns a new `AppClient` client for managing calls and state for an ARC-56 app.\n * This method resolves the app ID for the current network based on\n * pre-determined network-specific app IDs specified in the ARC-56 app spec.\n *\n * If no IDs are in the app spec or the network isn't recognised, an error is thrown.\n * @param params The parameters to create the app client\n * @example Basic\n * const appClient = algorand.client.getAppClientByNetwork({\n * appSpec: '{/* ARC-56 or ARC-32 compatible JSON *\\}',\n * // appId resolved by using ARC-56 spec to find app ID for current network\n * })\n * @returns The `AppClient`\n */\n public async getAppClientByNetwork(params: Expand<Omit<AppClientParams, 'algorand' | 'appId'>>) {\n if (!this._algorand) {\n throw new Error('Attempt to get app client from a ClientManager without an Algorand client')\n }\n return AppClient.fromNetwork({ ...params, algorand: this._algorand })\n }\n\n /**\n * Returns a new typed client, resolving the app by creator address and name.\n * @param typedClient The typed client type to use\n * @param params The params to resolve the app by creator address and name\n * @example Use name in ARC-32 / ARC-56 app spec\n * ```typescript\n * const appClient = algorand.client.getTypedAppClientByCreatorAndName(MyContractClient, {\n * creatorAddress: \"CREATORADDRESS\",\n * defaultSender: alice,\n * })\n * ```\n * @example Specify name\n * ```typescript\n * const appClient = algorand.client.getTypedAppClientByCreatorAndName(MyContractClient, {\n * creatorAddress: \"CREATORADDRESS\",\n * name: \"contract-name\",\n * defaultSender: alice,\n * })\n * ```\n * @returns The typed client instance\n */\n public async getTypedAppClientByCreatorAndName<TClient extends TypedAppClient<InstanceType<TClient>>>(\n typedClient: TClient,\n params: Expand<Omit<ResolveAppClientByCreatorAndName, 'algorand' | 'appSpec'>>,\n ) {\n if (!this._algorand) {\n throw new Error('Attempt to get app client from a ClientManager without an Algorand client')\n }\n\n return typedClient.fromCreatorAndName({ ...params, algorand: this._algorand })\n }\n\n /**\n * Returns a new typed client, resolving the app by app ID.\n * @param typedClient The typed client type to use\n * @param params The params to resolve the app by ID\n * @example\n * ```typescript\n * const appClient = algorand.client.getTypedAppClientById(MyContractClient, {\n * appId: 12345n,\n * defaultSender: alice,\n * })\n * ```\n * @returns The typed client instance\n */\n public getTypedAppClientById<TClient extends TypedAppClient<InstanceType<TClient>>>(\n typedClient: TClient,\n params: Expand<Omit<AppClientParams, 'algorand' | 'appSpec'>>,\n ) {\n if (!this._algorand) {\n throw new Error('Attempt to get app client from a ClientManager without an Algorand client')\n }\n\n return new typedClient({ ...params, algorand: this._algorand })\n }\n\n /**\n * Returns a new typed client, resolves the app ID for the current network based on\n * pre-determined network-specific app IDs specified in the ARC-56 app spec.\n *\n * If no IDs are in the app spec or the network isn't recognised, an error is thrown.\n * @param typedClient The typed client type to use\n * @param params The params to resolve the app by network\n * @example\n * ```typescript\n * const appClient = algorand.client.getTypedAppClientByNetwork(MyContractClient, {\n * defaultSender: alice,\n * })\n * ```\n * @returns The typed client instance\n */\n public getTypedAppClientByNetwork<TClient extends TypedAppClient<InstanceType<TClient>>>(\n typedClient: TClient,\n params?: Expand<Omit<AppClientParams, 'algorand' | 'appSpec' | 'appId'>>,\n ) {\n if (!this._algorand) {\n throw new Error('Attempt to get app client from a ClientManager without an Algorand client')\n }\n\n return typedClient.fromNetwork({ ...params, algorand: this._algorand })\n }\n\n /**\n * Returns a new typed app factory.\n * @param typedFactory The typed factory type to use\n * @param params The params to resolve the factory by\n * @example\n * ```typescript\n * const appFactory = algorand.client.getTypedAppFactory(MyContractClient, {\n * sender: alice,\n * })\n * ```\n * @returns The typed client instance\n */\n public getTypedAppFactory<TClient>(\n typedFactory: TypedAppFactory<TClient>,\n params?: Expand<Omit<AppFactoryParams, 'algorand' | 'appSpec'>>,\n ) {\n if (!this._algorand) {\n throw new Error('Attempt to get app factory from a ClientManager without an Algorand client')\n }\n\n return new typedFactory({ ...params, algorand: this._algorand })\n }\n\n /**\n * Retrieve client configurations from environment variables when defined or get defaults (expects to be called from a Node.js environment)\n *\n * If both `process.env.INDEXER_SERVER` and `process.env.ALGOD_SERVER` is defined it will use both along with optional `process.env.ALGOD_PORT`, `process.env.ALGOD_TOKEN`, `process.env.INDEXER_PORT` and `process.env.INDEXER_TOKEN`.\n *\n * If only `process.env.ALGOD_SERVER` is defined it will use this along with optional `process.env.ALGOD_PORT` and `process.env.ALGOD_TOKEN` and leave indexer as `undefined`.\n *\n * If only `process.env.INDEXER_SERVER` is defined it will use the default (LocalNet) configuration for both algod and indexer.\n *\n * It will return a KMD configuration that uses `process.env.KMD_PORT` (or port 4002) if `process.env.ALGOD_SERVER` is defined,\n * otherwise it will use the default LocalNet config unless it detects testnet or mainnet.\n * @example\n * ```typescript\n * const config = ClientManager.getConfigFromEnvironmentOrLocalNet()\n * ```\n * @returns The config for algod, indexer and kmd\n */\n public static getConfigFromEnvironmentOrLocalNet(): AlgoConfig {\n if (!process || !process.env) {\n throw new Error('Attempt to get default client configuration from a non Node.js context; supply the config instead')\n }\n const [algodConfig, indexerConfig, kmdConfig] = process.env.ALGOD_SERVER\n ? [\n ClientManager.getAlgodConfigFromEnvironment(),\n process.env.INDEXER_SERVER ? ClientManager.getIndexerConfigFromEnvironment() : undefined,\n !process.env.ALGOD_SERVER.includes('mainnet') && !process.env.ALGOD_SERVER.includes('testnet')\n ? { ...ClientManager.getAlgodConfigFromEnvironment(), port: process?.env?.KMD_PORT ?? '4002' }\n : undefined,\n ]\n : [\n ClientManager.getDefaultLocalNetConfig('algod'),\n ClientManager.getDefaultLocalNetConfig('indexer'),\n ClientManager.getDefaultLocalNetConfig('kmd'),\n ]\n\n return {\n algodConfig,\n indexerConfig,\n kmdConfig,\n }\n }\n\n /** Retrieve the algod configuration from environment variables (expects to be called from a Node.js environment)\n *\n * Expects `process.env.ALGOD_SERVER` to be defined, and you can also specify `process.env.ALGOD_PORT` and `process.env.ALGOD_TOKEN`.\n */\n public static getAlgodConfigFromEnvironment(): AlgoClientConfig {\n if (!process || !process.env) {\n throw new Error('Attempt to get default algod configuration from a non Node.js context; supply the config instead')\n }\n\n if (!process.env.ALGOD_SERVER) {\n throw new Error('Attempt to get default algod configuration without specifying ALGOD_SERVER in the environment variables')\n }\n\n return {\n server: process.env.ALGOD_SERVER,\n port: process.env.ALGOD_PORT,\n token: process.env.ALGOD_TOKEN,\n }\n }\n\n /**\n * Retrieve the indexer configuration from environment variables (expects to be called from a Node.js environment).\n *\n * Expects `process.env.INDEXER_SERVER` to be defined, and you can also specify `process.env.INDEXER_PORT` and `process.env.INDEXER_TOKEN`.\n */\n public static getIndexerConfigFromEnvironment(): AlgoClientConfig {\n if (!process || !process.env) {\n throw new Error('Attempt to get default indexer configuration from a non Node.js context; supply the config instead')\n }\n\n if (!process.env.INDEXER_SERVER) {\n throw new Error('Attempt to get default indexer configuration without specifying INDEXER_SERVER in the environment variables')\n }\n\n return {\n server: process.env.INDEXER_SERVER,\n port: process.env.INDEXER_PORT,\n token: process.env.INDEXER_TOKEN,\n }\n }\n\n /** Returns the Algorand configuration to point to the free tier of the AlgoNode service.\n *\n * @param network Which network to connect to - TestNet or MainNet\n * @param config Which algod config to return - Algod or Indexer\n */\n public static getAlgoNodeConfig(network: 'testnet' | 'mainnet', config: 'algod' | 'indexer'): AlgoClientConfig {\n return {\n server: `https://${network}-${config === 'algod' ? 'api' : 'idx'}.algonode.cloud/`,\n port: 443,\n }\n }\n\n /** Returns the Algorand configuration to point to the default LocalNet.\n *\n * @param configOrPort Which algod config to return - algod, kmd, or indexer OR a port number\n */\n public static getDefaultLocalNetConfig(configOrPort: 'algod' | 'indexer' | 'kmd' | number): AlgoClientConfig {\n return {\n server: `http://localhost`,\n port: configOrPort === 'algod' ? 4001 : configOrPort === 'indexer' ? 8980 : configOrPort === 'kmd' ? 4002 : configOrPort,\n token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',\n }\n }\n\n /**\n * Returns an algod SDK client that automatically retries on idempotent calls.\n *\n * @param config The config of the client\n * @example AlgoNode (testnet)\n * ```typescript\n * const algod = ClientManager.getAlgodClient(ClientManager.getAlgoNodeConfig('testnet', 'algod'))\n * await algod.healthCheck().do()\n * ```\n * @example AlgoNode (mainnet)\n * ```typescript\n * const algod = ClientManager.getAlgodClient(ClientManager.getAlgoNodeConfig('mainnet', 'algod'))\n * await algod.healthCheck().do()\n * ```\n * @example Custom (e.g. default LocalNet)\n * ```typescript\n * const algod = ClientManager.getAlgodClient({server: 'http://localhost', port: '4001', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'})\n * await algod.healthCheck().do()\n * ```\n */\n public static getAlgodClient(config: AlgoClientConfig): Algodv2 {\n const { token, server, port } = config\n const tokenHeader = typeof token === 'string' ? { 'X-Algo-API-Token': token } : token ?? {}\n const httpClientWithRetry = new AlgoHttpClientWithRetry(tokenHeader, server, port)\n return new algosdk.Algodv2(httpClientWithRetry, server)\n }\n\n /**\n * Returns an algod SDK client that automatically retries on idempotent calls loaded from environment variables (expects to be called from a Node.js environment).\n *\n * @example\n * ```typescript\n * // Uses process.env.ALGOD_SERVER, process.env.ALGOD_PORT and process.env.ALGOD_TOKEN\n * const algod = ClientManager.getAlgodClientFromEnvironment()\n * await algod.healthCheck().do()\n * ```\n */\n public static getAlgodClientFromEnvironment(): Algodv2 {\n return ClientManager.getAlgodClient(ClientManager.getAlgodConfigFromEnvironment())\n }\n\n /**\n * Returns an indexer SDK client that automatically retries on idempotent calls\n *\n * @param config The config of the client\n * @param overrideIntDecoding Override the default int decoding for responses, uses MIXED by default to avoid lost precision for big integers\n * @example AlgoNode (testnet)\n * ```typescript\n * const indexer = ClientManager.getIndexerClient(ClientManager.getAlgoNodeConfig('testnet', 'indexer'))\n * await indexer.makeHealthCheck().do()\n * ```\n * @example AlgoNode (mainnet)\n * ```typescript\n * const indexer = ClientManager.getIndexerClient(ClientManager.getAlgoNodeConfig('mainnet', 'indexer'))\n * await indexer.makeHealthCheck().do()\n * ```\n * @example Custom (e.g. default LocalNet, although we recommend loading this into a .env and using the Default option instead)\n * ```typescript\n * const indexer = ClientManager.getIndexerClient({server: 'http://localhost', port: '8980', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'})\n * await indexer.makeHealthCheck().do()\n * ```\n * @example Override int decoding for responses\n * ```typescript\n * const indexer = ClientManager.getIndexerClient(config, IntDecoding.BIGINT)\n * ```\n */\n public static getIndexerClient(config: AlgoClientConfig, overrideIntDecoding?: IntDecoding): Indexer {\n const { token, server, port } = config\n const tokenHeader = typeof token === 'string' ? { 'X-Indexer-API-Token': token } : token ?? {}\n const httpClientWithRetry = new AlgoHttpClientWithRetry(tokenHeader, server, port)\n const indexer = new Indexer(httpClientWithRetry)\n // Use mixed int decoding by default so bigints don't have lost precision\n indexer.setIntEncoding(overrideIntDecoding ?? IntDecoding.MIXED)\n return indexer\n }\n\n /**\n * Returns an indexer SDK client that automatically retries on idempotent calls loaded from environment variables (expects to be called from a Node.js environment).\n *\n * @param overrideIntDecoding Override the default int decoding for responses, uses MIXED by default to avoid lost precision for big integers\n * @example\n *\n * ```typescript\n * // Uses process.env.INDEXER_SERVER, process.env.INDEXER_PORT and process.env.INDEXER_TOKEN\n * const indexer = ClientManager.getIndexerClientFromEnvironment()\n * await indexer.makeHealthCheck().do()\n * ```\n */\n public static getIndexerClientFromEnvironment(overrideIntDecoding?: IntDecoding): Indexer {\n return ClientManager.getIndexerClient(ClientManager.getIndexerConfigFromEnvironment(), overrideIntDecoding)\n }\n\n /**\n * Returns a KMD SDK client.\n *\n * KMD client allows you to export private keys, which is useful to (for instance) get the default account in a LocalNet network.\n *\n * @param config The config for the client\n * @example Custom (e.g. default LocalNet, although we recommend loading this into a .env and using the Default option instead)\n * ```typescript\n * const kmd = ClientManager.getKmdClient({server: 'http://localhost', port: '4002', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'})\n * ```\n */\n public static getKmdClient(config: AlgoClientConfig): Kmd {\n const { token, server, port } = config\n return new Kmd(token as string, server, port)\n }\n\n /**\n * Returns a KMD SDK client that automatically retries on idempotent calls loaded from environment variables (expects to be called from a Node.js environment).\n *\n * @example\n * ```typescript\n * // Uses process.env.ALGOD_SERVER, process.env.KMD_PORT (or if not specified: port 4002) and process.env.ALGOD_TOKEN\n * const kmd = ClientManager.getKmdClientFromEnvironment()\n * ```\n */\n public static getKmdClientFromEnvironment(): Kmd {\n // We can only use Kmd on the LocalNet otherwise it's not exposed so this makes some assumptions\n // (e.g. same token and server as algod and port 4002 by default)\n return ClientManager.getKmdClient({ ...ClientManager.getAlgodConfigFromEnvironment(), port: process?.env?.KMD_PORT ?? '4002' })\n }\n}\n\n/**\n * Interface to identify a typed client that can be used to interact with an application.\n */\nexport interface TypedAppClient<TClient> {\n new (params: Omit<AppClientParams, 'appSpec'>): TClient\n fromNetwork(params: Omit<AppClientParams, 'appId' | 'appSpec'>): Promise<TClient>\n fromCreatorAndName(params: Omit<ResolveAppClientByCreatorAndName, 'appSpec'>): Promise<TClient>\n}\n\n/**\n * Interface to identify a typed factory that can be used to create and deploy an application.\n */\nexport interface TypedAppFactory<TClient> {\n new (params: Omit<AppFactoryParams, 'appSpec'>): TClient\n}\n"],"names":["genesisIdIsLocalNet","TestNetDispenserApiClient","AppFactory","AppClient","AlgoHttpClientWithRetry"],"mappings":";;;;;;;;;AASA,IAAO,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;AACxB,IAAO,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;AAEhC,IAAO,WAAW,GAAG,OAAO,CAAC,WAAW,CAAA;AAYxC;MACa,aAAa,CAAA;AAMxB;;;;;;;;;;;;;;;;;;;AAmBG;IACH,WAAY,CAAA,eAA4C,EAAE,cAAwC,EAAA;AAChG,QAAA,MAAM,QAAQ,GACZ,OAAO,IAAI,eAAe;AACxB,cAAE,eAAe;AACjB,cAAE;gBACE,KAAK,EAAE,aAAa,CAAC,cAAc,CAAC,eAAe,CAAC,WAAW,CAAC;AAChE,gBAAA,OAAO,EAAE,eAAe,CAAC,aAAa,GAAG,aAAa,CAAC,gBAAgB,CAAC,eAAe,CAAC,aAAa,CAAC,GAAG,SAAS;AAClH,gBAAA,GAAG,EAAE,eAAe,CAAC,SAAS,GAAG,aAAa,CAAC,YAAY,CAAC,eAAe,CAAC,SAAS,CAAC,GAAG,SAAS;aACnG,CAAA;AACP,QAAA,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAA;AAC5B,QAAA,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAA;AAChC,QAAA,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAA;AACxB,QAAA,IAAI,CAAC,SAAS,GAAG,cAAc,CAAA;KAChC;;AAGD,IAAA,IAAW,KAAK,GAAA;QACd,OAAO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OAAO,gBAAgB,CAAC,MAAwB,EAAE,mBAAiC,EAAA;QACxF,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAA;QACtC,MAAM,WAAW,GAAG,OAAO,KAAK,KAAK,QAAQ,GAAG,EAAE,qBAAqB,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,EAAE,CAAA;QAC9F,MAAM,mBAAmB,GAAG,IAAIA,qDAAuB,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,CAAC,CAAA;AAClF,QAAA,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,mBAAmB,CAAC,CAAA;;QAEhD,OAAO,CAAC,cAAc,CAAC,mBAAmB,IAAI,WAAW,CAAC,KAAK,CAAC,CAAA;AAChE,QAAA,OAAO,OAAO,CAAA;KACf;AAED;;;;;;;;;;;AAWG;IACI,OAAO,+BAA+B,CAAC,mBAAiC,EAAA;QAC7E,OAAO,aAAa,CAAC,gBAAgB,CAAC,aAAa,CAAC,+BAA+B,EAAE,EAAE,mBAAmB,CAAC,CAAA;KAC5G;AAED;;;;;;;;;;AAUG;IACI,OAAO,YAAY,CAAC,MAAwB,EAAA;QACjD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAA;QACtC,OAAO,IAAI,GAAG,CAAC,KAAe,EAAE,MAAM,EAAE,IAAI,CAAC,CAAA;KAC9C;AAED;;;;;;;;AAQG;AACI,IAAA,OAAO,2BAA2B,GAAA;;;QAGvC,OAAO,aAAa,CAAC,YAAY,CAAC,EAAE,GAAG,aAAa,CAAC,6BAA6B,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,IAAI,MAAM,EAAE,CAAC,CAAA;KAChI;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"client-manager.js","sources":["../../src/types/client-manager.ts"],"sourcesContent":["import algosdk from 'algosdk'\nimport { SuggestedParamsWithMinFee } from 'algosdk/dist/types/types/transactions/base'\nimport { AlgoHttpClientWithRetry } from './algo-http-client-with-retry'\nimport { AlgorandClientInterface } from './algorand-client-interface'\nimport { AppClient, AppClientParams, ResolveAppClientByCreatorAndName } from './app-client'\nimport { AppFactory, AppFactoryParams } from './app-factory'\nimport { TestNetDispenserApiClient, TestNetDispenserApiClientParams } from './dispenser-client'\nimport { Expand } from './expand'\nimport { AlgoClientConfig, AlgoConfig, NetworkDetails, genesisIdIsLocalNet } from './network-client'\nimport Kmd = algosdk.Kmd\nimport Indexer = algosdk.Indexer\nimport Algodv2 = algosdk.Algodv2\nimport IntDecoding = algosdk.IntDecoding\n\n/** Clients from algosdk that interact with the official Algorand APIs */\nexport interface AlgoSdkClients {\n /** Algod client, see https://developer.algorand.org/docs/rest-apis/algod/ */\n algod: algosdk.Algodv2\n /** Optional indexer client, see https://developer.algorand.org/docs/rest-apis/indexer/ */\n indexer?: algosdk.Indexer\n /** Optional KMD client, see https://developer.algorand.org/docs/rest-apis/kmd/ */\n kmd?: algosdk.Kmd\n}\n\n/** Params to get an app factory from `ClientManager`. */\nexport type ClientAppFactoryParams = Expand<Omit<AppFactoryParams, 'algorand'>>\n\n/** Params to get an app client by creator address and name from `ClientManager`. */\nexport type ClientResolveAppClientByCreatorAndNameParams = Expand<Omit<ResolveAppClientByCreatorAndName, 'algorand'>>\n\n/** Params to get an app client by ID from `ClientManager`. */\nexport type ClientAppClientParams = Expand<Omit<AppClientParams, 'algorand'>>\n\n/** Params to get an app client by network from `ClientManager`. */\nexport type ClientAppClientByNetworkParams = Expand<Omit<AppClientParams, 'algorand' | 'appId'>>\n\n/** Params to get a typed app client by creator address and name from `ClientManager`. */\nexport type ClientTypedAppClientByCreatorAndNameParams = Expand<Omit<ResolveAppClientByCreatorAndName, 'algorand' | 'appSpec'>>\n\n/** Params to get a typed app client by ID from `ClientManager`. */\nexport type ClientTypedAppClientParams = Expand<Omit<AppClientParams, 'algorand' | 'appSpec'>>\n\n/** Params to get a typed app client by network from `ClientManager`. */\nexport type ClientTypedAppClientByNetworkParams = Expand<Omit<AppClientParams, 'algorand' | 'appSpec' | 'appId'>>\n\n/** Params to get a typed app factory from `ClientManager`. */\nexport type ClientTypedAppFactoryParams = Expand<Omit<AppFactoryParams, 'algorand' | 'appSpec'>>\n\n/** Exposes access to various API clients. */\nexport class ClientManager {\n private _algod: algosdk.Algodv2\n private _indexer?: algosdk.Indexer\n private _kmd?: algosdk.Kmd\n private _algorand?: AlgorandClientInterface\n\n /**\n * algosdk clients or config for interacting with the official Algorand APIs.\n * @param clientsOrConfig The clients or config to use\n * @example Algod client only\n * ```typescript\n * const clientManager = new ClientManager({ algod: algodClient })\n * ```\n * @example All clients\n * ```typescript\n * const clientManager = new ClientManager({ algod: algodClient, indexer: indexerClient, kmd: kmdClient })\n * ```\n * @example Algod config only\n * ```typescript\n * const clientManager = new ClientManager({ algodConfig })\n * ```\n * @example All client configs\n * ```typescript\n * const clientManager = new ClientManager({ algodConfig, indexerConfig, kmdConfig })\n * ```\n */\n constructor(clientsOrConfig: AlgoConfig | AlgoSdkClients, algorandClient?: AlgorandClientInterface) {\n const _clients =\n 'algod' in clientsOrConfig\n ? clientsOrConfig\n : {\n algod: ClientManager.getAlgodClient(clientsOrConfig.algodConfig),\n indexer: clientsOrConfig.indexerConfig ? ClientManager.getIndexerClient(clientsOrConfig.indexerConfig) : undefined,\n kmd: clientsOrConfig.kmdConfig ? ClientManager.getKmdClient(clientsOrConfig.kmdConfig) : undefined,\n }\n this._algod = _clients.algod\n this._indexer = _clients.indexer\n this._kmd = _clients.kmd\n this._algorand = algorandClient\n }\n\n /** Returns an algosdk Algod API client. */\n public get algod(): algosdk.Algodv2 {\n return this._algod\n }\n\n /** Returns an algosdk Indexer API client or throws an error if it's not been provided. */\n public get indexer(): algosdk.Indexer {\n if (!this._indexer) throw new Error('Attempt to use Indexer client in AlgoKit instance with no Indexer configured')\n return this._indexer\n }\n\n /** Returns an algosdk Indexer API client or `undefined` if it's not been provided. */\n public get indexerIfPresent(): algosdk.Indexer | undefined {\n return this._indexer\n }\n\n /** Returns an algosdk KMD API client or throws an error if it's not been provided. */\n public get kmd(): algosdk.Kmd {\n if (!this._kmd) throw new Error('Attempt to use Kmd client in AlgoKit instance with no Kmd configured')\n return this._kmd\n }\n\n private _getNetworkPromise: Promise<SuggestedParamsWithMinFee> | undefined\n /**\n * Get details about the current network.\n * @example Getting genesis ID\n * ```typescript\n * const network = await networkClient.network()\n * const genesisId = network.genesisId\n * ```\n * @returns The current network details\n */\n public async network(): Promise<NetworkDetails> {\n if (!this._getNetworkPromise) {\n this._getNetworkPromise = this._algod.getTransactionParams().do()\n }\n\n const params = await this._getNetworkPromise\n return {\n isTestNet: ['testnet-v1.0', 'testnet-v1', 'testnet'].includes(params.genesisID),\n isMainNet: ['mainnet-v1.0', 'mainnet-v1', 'mainnet'].includes(params.genesisID),\n isLocalNet: ClientManager.genesisIdIsLocalNet(params.genesisID),\n genesisId: params.genesisID,\n genesisHash: params.genesisHash,\n }\n }\n\n /**\n * Returns true if the given network genesisId is associated with a LocalNet network.\n * @param genesisId The network genesis ID\n * @returns Whether the given genesis ID is associated with a LocalNet network\n */\n public static genesisIdIsLocalNet(genesisId: string) {\n return genesisIdIsLocalNet(genesisId)\n }\n\n /**\n * Returns true if the current network is LocalNet.\n * @returns True if the current network is LocalNet.\n */\n public async isLocalNet() {\n return (await this.network()).isLocalNet\n }\n\n /**\n * Returns true if the current network is TestNet.\n * @returns True if the current network is TestNet.\n */\n public async isTestNet() {\n return (await this.network()).isTestNet\n }\n\n /**\n * Returns true if the current network is MainNet.\n * @returns True if the current network is MainNet.\n */\n public async isMainNet() {\n return (await this.network()).isMainNet\n }\n\n /**\n * Returns a TestNet Dispenser API client.\n *\n * Refer to [docs](https://github.com/algorandfoundation/algokit/blob/main/docs/testnet_api.md) on guidance to obtain an access token.\n *\n * @param params An object containing parameters for the TestNetDispenserApiClient class.\n * @example\n * const client = clientManager.getTestNetDispenser(\n * {\n * authToken: 'your_auth_token',\n * requestTimeout: 15,\n * }\n * )\n *\n * @returns An instance of the TestNetDispenserApiClient class.\n */\n public getTestNetDispenser(params: TestNetDispenserApiClientParams) {\n return new TestNetDispenserApiClient(params)\n }\n\n /**\n * Returns a TestNet Dispenser API client, loading the auth token from `process.env.ALGOKIT_DISPENSER_ACCESS_TOKEN`.\n *\n * Refer to [docs](https://github.com/algorandfoundation/algokit/blob/main/docs/testnet_api.md) on guidance to obtain an access token.\n *\n * @param params An object containing parameters for the TestNetDispenserApiClient class.\n * @example\n * const client = clientManager.getTestNetDispenserFromEnvironment(\n * {\n * requestTimeout: 15,\n * }\n * )\n *\n * @returns An instance of the TestNetDispenserApiClient class.\n */\n public getTestNetDispenserFromEnvironment(params?: Omit<TestNetDispenserApiClientParams, 'authToken'>) {\n return new TestNetDispenserApiClient(params ? { ...params, authToken: '' } : undefined)\n }\n\n /**\n * Returns a new `AppFactory` client\n * @example Basic example\n * ```typescript\n * const factory = algorand.client.getAppFactory({\n * appSpec: '{/* ARC-56 or ARC-32 compatible JSON *\\/}',\n * })\n * ```\n * @example Advanced example\n * ```typescript\n * const factory = algorand.client.getAppFactory({\n * appSpec: parsedAppSpec_AppSpec_or_Arc56Contract,\n * defaultSender: \"SENDERADDRESS\",\n * appName: \"OverriddenAppName\",\n * version: \"2.0.0\",\n * updatable: true,\n * deletable: false,\n * deployTimeParams: { ONE: 1, TWO: 'value' }\n * })\n * ```\n */\n public getAppFactory(params: ClientAppFactoryParams) {\n if (!this._algorand) {\n throw new Error('Attempt to get app factory from a ClientManager without an Algorand client')\n }\n\n return new AppFactory({ ...params, algorand: this._algorand })\n }\n\n /**\n * Returns a new `AppClient` client for managing calls and state for an ARC-32/ARC-56 app.\n * This method resolves the app ID by looking up the creator address and name\n * using AlgoKit app deployment semantics (i.e. looking for the app creation transaction note).\n * @param params The parameters to create the app client\n * @example Basic\n * ```typescript\n * const appClient = algorand.client.getAppClientByCreatorAndName({\n * appSpec: '{/* ARC-56 or ARC-32 compatible JSON *\\}',\n * // appId resolved by looking for app ID of named app by this creator\n * creatorAddress: 'CREATORADDRESS',\n * })\n * ```\n * @returns The `AppClient`\n */\n public getAppClientByCreatorAndName(params: ClientResolveAppClientByCreatorAndNameParams) {\n if (!this._algorand) {\n throw new Error('Attempt to get app client from a ClientManager without an Algorand client')\n }\n\n return AppClient.fromCreatorAndName({\n ...params,\n algorand: this._algorand,\n })\n }\n\n /**\n * Returns a new `AppClient` client for managing calls and state for an ARC-32/ARC-56 app.\n * @param params The parameters to create the app client\n * @example Basic\n * ```typescript\n * const appClient = algorand.client.getAppClientById({\n * appSpec: '{/* ARC-56 or ARC-32 compatible JSON *\\}',\n * appId: 12345n,\n * })\n * ```\n * @returns The `AppClient`\n */\n public getAppClientById(params: ClientAppClientParams) {\n if (!this._algorand) {\n throw new Error('Attempt to get app client from a ClientManager without an Algorand client')\n }\n return new AppClient({ ...params, algorand: this._algorand })\n }\n\n /**\n * Returns a new `AppClient` client for managing calls and state for an ARC-56 app.\n * This method resolves the app ID for the current network based on\n * pre-determined network-specific app IDs specified in the ARC-56 app spec.\n *\n * If no IDs are in the app spec or the network isn't recognised, an error is thrown.\n * @param params The parameters to create the app client\n * @example Basic\n * ```typescript\n * const appClient = algorand.client.getAppClientByNetwork({\n * appSpec: '{/* ARC-56 or ARC-32 compatible JSON *\\}',\n * // appId resolved by using ARC-56 spec to find app ID for current network\n * })\n * ```\n * @returns The `AppClient`\n */\n public async getAppClientByNetwork(params: ClientAppClientByNetworkParams) {\n if (!this._algorand) {\n throw new Error('Attempt to get app client from a ClientManager without an Algorand client')\n }\n return AppClient.fromNetwork({ ...params, algorand: this._algorand })\n }\n\n /**\n * Returns a new typed client, resolving the app by creator address and name.\n * @param typedClient The typed client type to use\n * @param params The params to resolve the app by creator address and name\n * @example Use name in ARC-32 / ARC-56 app spec\n * ```typescript\n * const appClient = algorand.client.getTypedAppClientByCreatorAndName(MyContractClient, {\n * creatorAddress: \"CREATORADDRESS\",\n * defaultSender: alice,\n * })\n * ```\n * @example Specify name\n * ```typescript\n * const appClient = algorand.client.getTypedAppClientByCreatorAndName(MyContractClient, {\n * creatorAddress: \"CREATORADDRESS\",\n * name: \"contract-name\",\n * defaultSender: alice,\n * })\n * ```\n * @returns The typed client instance\n */\n public async getTypedAppClientByCreatorAndName<TClient extends TypedAppClient<InstanceType<TClient>>>(\n typedClient: TClient,\n params: ClientTypedAppClientByCreatorAndNameParams,\n ) {\n if (!this._algorand) {\n throw new Error('Attempt to get app client from a ClientManager without an Algorand client')\n }\n\n return typedClient.fromCreatorAndName({ ...params, algorand: this._algorand })\n }\n\n /**\n * Returns a new typed client, resolving the app by app ID.\n * @param typedClient The typed client type to use\n * @param params The params to resolve the app by ID\n * @example\n * ```typescript\n * const appClient = algorand.client.getTypedAppClientById(MyContractClient, {\n * appId: 12345n,\n * defaultSender: alice,\n * })\n * ```\n * @returns The typed client instance\n */\n public getTypedAppClientById<TClient extends TypedAppClient<InstanceType<TClient>>>(\n typedClient: TClient,\n params: ClientTypedAppClientParams,\n ) {\n if (!this._algorand) {\n throw new Error('Attempt to get app client from a ClientManager without an Algorand client')\n }\n\n return new typedClient({ ...params, algorand: this._algorand })\n }\n\n /**\n * Returns a new typed client, resolves the app ID for the current network based on\n * pre-determined network-specific app IDs specified in the ARC-56 app spec.\n *\n * If no IDs are in the app spec or the network isn't recognised, an error is thrown.\n * @param typedClient The typed client type to use\n * @param params The params to resolve the app by network\n * @example\n * ```typescript\n * const appClient = algorand.client.getTypedAppClientByNetwork(MyContractClient, {\n * defaultSender: alice,\n * })\n * ```\n * @returns The typed client instance\n */\n public getTypedAppClientByNetwork<TClient extends TypedAppClient<InstanceType<TClient>>>(\n typedClient: TClient,\n params?: ClientTypedAppClientByNetworkParams,\n ) {\n if (!this._algorand) {\n throw new Error('Attempt to get app client from a ClientManager without an Algorand client')\n }\n\n return typedClient.fromNetwork({ ...params, algorand: this._algorand })\n }\n\n /**\n * Returns a new typed app factory.\n * @param typedFactory The typed factory type to use\n * @param params The params to resolve the factory by\n * @example\n * ```typescript\n * const appFactory = algorand.client.getTypedAppFactory(MyContractClient, {\n * sender: alice,\n * })\n * ```\n * @returns The typed client instance\n */\n public getTypedAppFactory<TClient>(typedFactory: TypedAppFactory<TClient>, params?: ClientTypedAppFactoryParams) {\n if (!this._algorand) {\n throw new Error('Attempt to get app factory from a ClientManager without an Algorand client')\n }\n\n return new typedFactory({ ...params, algorand: this._algorand })\n }\n\n /**\n * Retrieve client configurations from environment variables when defined or get defaults (expects to be called from a Node.js environment)\n *\n * If both `process.env.INDEXER_SERVER` and `process.env.ALGOD_SERVER` is defined it will use both along with optional `process.env.ALGOD_PORT`, `process.env.ALGOD_TOKEN`, `process.env.INDEXER_PORT` and `process.env.INDEXER_TOKEN`.\n *\n * If only `process.env.ALGOD_SERVER` is defined it will use this along with optional `process.env.ALGOD_PORT` and `process.env.ALGOD_TOKEN` and leave indexer as `undefined`.\n *\n * If only `process.env.INDEXER_SERVER` is defined it will use the default (LocalNet) configuration for both algod and indexer.\n *\n * It will return a KMD configuration that uses `process.env.KMD_PORT` (or port 4002) if `process.env.ALGOD_SERVER` is defined,\n * otherwise it will use the default LocalNet config unless it detects testnet or mainnet.\n * @example\n * ```typescript\n * const config = ClientManager.getConfigFromEnvironmentOrLocalNet()\n * ```\n * @returns The config for algod, indexer and kmd\n */\n public static getConfigFromEnvironmentOrLocalNet(): AlgoConfig {\n if (!process || !process.env) {\n throw new Error('Attempt to get default client configuration from a non Node.js context; supply the config instead')\n }\n const [algodConfig, indexerConfig, kmdConfig] = process.env.ALGOD_SERVER\n ? [\n ClientManager.getAlgodConfigFromEnvironment(),\n process.env.INDEXER_SERVER ? ClientManager.getIndexerConfigFromEnvironment() : undefined,\n !process.env.ALGOD_SERVER.includes('mainnet') && !process.env.ALGOD_SERVER.includes('testnet')\n ? { ...ClientManager.getAlgodConfigFromEnvironment(), port: process?.env?.KMD_PORT ?? '4002' }\n : undefined,\n ]\n : [\n ClientManager.getDefaultLocalNetConfig('algod'),\n ClientManager.getDefaultLocalNetConfig('indexer'),\n ClientManager.getDefaultLocalNetConfig('kmd'),\n ]\n\n return {\n algodConfig,\n indexerConfig,\n kmdConfig,\n }\n }\n\n /** Retrieve the algod configuration from environment variables (expects to be called from a Node.js environment)\n *\n * Expects `process.env.ALGOD_SERVER` to be defined, and you can also specify `process.env.ALGOD_PORT` and `process.env.ALGOD_TOKEN`.\n */\n public static getAlgodConfigFromEnvironment(): AlgoClientConfig {\n if (!process || !process.env) {\n throw new Error('Attempt to get default algod configuration from a non Node.js context; supply the config instead')\n }\n\n if (!process.env.ALGOD_SERVER) {\n throw new Error('Attempt to get default algod configuration without specifying ALGOD_SERVER in the environment variables')\n }\n\n return {\n server: process.env.ALGOD_SERVER,\n port: process.env.ALGOD_PORT,\n token: process.env.ALGOD_TOKEN,\n }\n }\n\n /**\n * Retrieve the indexer configuration from environment variables (expects to be called from a Node.js environment).\n *\n * Expects `process.env.INDEXER_SERVER` to be defined, and you can also specify `process.env.INDEXER_PORT` and `process.env.INDEXER_TOKEN`.\n */\n public static getIndexerConfigFromEnvironment(): AlgoClientConfig {\n if (!process || !process.env) {\n throw new Error('Attempt to get default indexer configuration from a non Node.js context; supply the config instead')\n }\n\n if (!process.env.INDEXER_SERVER) {\n throw new Error('Attempt to get default indexer configuration without specifying INDEXER_SERVER in the environment variables')\n }\n\n return {\n server: process.env.INDEXER_SERVER,\n port: process.env.INDEXER_PORT,\n token: process.env.INDEXER_TOKEN,\n }\n }\n\n /** Returns the Algorand configuration to point to the free tier of the AlgoNode service.\n *\n * @param network Which network to connect to - TestNet or MainNet\n * @param config Which algod config to return - Algod or Indexer\n */\n public static getAlgoNodeConfig(network: 'testnet' | 'mainnet', config: 'algod' | 'indexer'): AlgoClientConfig {\n return {\n server: `https://${network}-${config === 'algod' ? 'api' : 'idx'}.algonode.cloud/`,\n port: 443,\n }\n }\n\n /** Returns the Algorand configuration to point to the default LocalNet.\n *\n * @param configOrPort Which algod config to return - algod, kmd, or indexer OR a port number\n */\n public static getDefaultLocalNetConfig(configOrPort: 'algod' | 'indexer' | 'kmd' | number): AlgoClientConfig {\n return {\n server: `http://localhost`,\n port: configOrPort === 'algod' ? 4001 : configOrPort === 'indexer' ? 8980 : configOrPort === 'kmd' ? 4002 : configOrPort,\n token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',\n }\n }\n\n /**\n * Returns an algod SDK client that automatically retries on idempotent calls.\n *\n * @param config The config of the client\n * @example AlgoNode (testnet)\n * ```typescript\n * const algod = ClientManager.getAlgodClient(ClientManager.getAlgoNodeConfig('testnet', 'algod'))\n * await algod.healthCheck().do()\n * ```\n * @example AlgoNode (mainnet)\n * ```typescript\n * const algod = ClientManager.getAlgodClient(ClientManager.getAlgoNodeConfig('mainnet', 'algod'))\n * await algod.healthCheck().do()\n * ```\n * @example Custom (e.g. default LocalNet)\n * ```typescript\n * const algod = ClientManager.getAlgodClient({server: 'http://localhost', port: '4001', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'})\n * await algod.healthCheck().do()\n * ```\n */\n public static getAlgodClient(config: AlgoClientConfig): Algodv2 {\n const { token, server, port } = config\n const tokenHeader = typeof token === 'string' ? { 'X-Algo-API-Token': token } : token ?? {}\n const httpClientWithRetry = new AlgoHttpClientWithRetry(tokenHeader, server, port)\n return new algosdk.Algodv2(httpClientWithRetry, server)\n }\n\n /**\n * Returns an algod SDK client that automatically retries on idempotent calls loaded from environment variables (expects to be called from a Node.js environment).\n *\n * @example\n * ```typescript\n * // Uses process.env.ALGOD_SERVER, process.env.ALGOD_PORT and process.env.ALGOD_TOKEN\n * const algod = ClientManager.getAlgodClientFromEnvironment()\n * await algod.healthCheck().do()\n * ```\n */\n public static getAlgodClientFromEnvironment(): Algodv2 {\n return ClientManager.getAlgodClient(ClientManager.getAlgodConfigFromEnvironment())\n }\n\n /**\n * Returns an indexer SDK client that automatically retries on idempotent calls\n *\n * @param config The config of the client\n * @param overrideIntDecoding Override the default int decoding for responses, uses MIXED by default to avoid lost precision for big integers\n * @example AlgoNode (testnet)\n * ```typescript\n * const indexer = ClientManager.getIndexerClient(ClientManager.getAlgoNodeConfig('testnet', 'indexer'))\n * await indexer.makeHealthCheck().do()\n * ```\n * @example AlgoNode (mainnet)\n * ```typescript\n * const indexer = ClientManager.getIndexerClient(ClientManager.getAlgoNodeConfig('mainnet', 'indexer'))\n * await indexer.makeHealthCheck().do()\n * ```\n * @example Custom (e.g. default LocalNet, although we recommend loading this into a .env and using the Default option instead)\n * ```typescript\n * const indexer = ClientManager.getIndexerClient({server: 'http://localhost', port: '8980', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'})\n * await indexer.makeHealthCheck().do()\n * ```\n * @example Override int decoding for responses\n * ```typescript\n * const indexer = ClientManager.getIndexerClient(config, IntDecoding.BIGINT)\n * ```\n */\n public static getIndexerClient(config: AlgoClientConfig, overrideIntDecoding?: IntDecoding): Indexer {\n const { token, server, port } = config\n const tokenHeader = typeof token === 'string' ? { 'X-Indexer-API-Token': token } : token ?? {}\n const httpClientWithRetry = new AlgoHttpClientWithRetry(tokenHeader, server, port)\n const indexer = new Indexer(httpClientWithRetry)\n // Use mixed int decoding by default so bigints don't have lost precision\n indexer.setIntEncoding(overrideIntDecoding ?? IntDecoding.MIXED)\n return indexer\n }\n\n /**\n * Returns an indexer SDK client that automatically retries on idempotent calls loaded from environment variables (expects to be called from a Node.js environment).\n *\n * @param overrideIntDecoding Override the default int decoding for responses, uses MIXED by default to avoid lost precision for big integers\n * @example\n *\n * ```typescript\n * // Uses process.env.INDEXER_SERVER, process.env.INDEXER_PORT and process.env.INDEXER_TOKEN\n * const indexer = ClientManager.getIndexerClientFromEnvironment()\n * await indexer.makeHealthCheck().do()\n * ```\n */\n public static getIndexerClientFromEnvironment(overrideIntDecoding?: IntDecoding): Indexer {\n return ClientManager.getIndexerClient(ClientManager.getIndexerConfigFromEnvironment(), overrideIntDecoding)\n }\n\n /**\n * Returns a KMD SDK client.\n *\n * KMD client allows you to export private keys, which is useful to (for instance) get the default account in a LocalNet network.\n *\n * @param config The config for the client\n * @example Custom (e.g. default LocalNet, although we recommend loading this into a .env and using the Default option instead)\n * ```typescript\n * const kmd = ClientManager.getKmdClient({server: 'http://localhost', port: '4002', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'})\n * ```\n */\n public static getKmdClient(config: AlgoClientConfig): Kmd {\n const { token, server, port } = config\n return new Kmd(token as string, server, port)\n }\n\n /**\n * Returns a KMD SDK client that automatically retries on idempotent calls loaded from environment variables (expects to be called from a Node.js environment).\n *\n * @example\n * ```typescript\n * // Uses process.env.ALGOD_SERVER, process.env.KMD_PORT (or if not specified: port 4002) and process.env.ALGOD_TOKEN\n * const kmd = ClientManager.getKmdClientFromEnvironment()\n * ```\n */\n public static getKmdClientFromEnvironment(): Kmd {\n // We can only use Kmd on the LocalNet otherwise it's not exposed so this makes some assumptions\n // (e.g. same token and server as algod and port 4002 by default)\n return ClientManager.getKmdClient({ ...ClientManager.getAlgodConfigFromEnvironment(), port: process?.env?.KMD_PORT ?? '4002' })\n }\n}\n\n/**\n * Interface to identify a typed client that can be used to interact with an application.\n */\nexport interface TypedAppClient<TClient> {\n new (params: Omit<AppClientParams, 'appSpec'>): TClient\n fromNetwork(params: Omit<AppClientParams, 'appId' | 'appSpec'>): Promise<TClient>\n fromCreatorAndName(params: Omit<ResolveAppClientByCreatorAndName, 'appSpec'>): Promise<TClient>\n}\n\n/**\n * Interface to identify a typed factory that can be used to create and deploy an application.\n */\nexport interface TypedAppFactory<TClient> {\n new (params: Omit<AppFactoryParams, 'appSpec'>): TClient\n}\n"],"names":["genesisIdIsLocalNet","TestNetDispenserApiClient","AppFactory","AppClient","AlgoHttpClientWithRetry"],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AAM,EAAE,IAAI,CAAC,CAAA;AAClF,QAAA,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,mBAAmB,CAAC,CAAA;;QAEhD,OAAO,CAAC,cAAc,CAAC,mBAAmB,IAAI,WAAW,CAAC,KAAK,CAAC,CAAA;AAChE,QAAA,OAAO,OAAO,CAAA;KACf;AAED;;;;;;;;;;;AAWG;IACI,OAAO,+BAA+B,CAAC,mBAAiC,EAAA;QAC7E,OAAO,aAAa,CAAC,gBAAgB,CAAC,aAAa,CAAC,+BAA+B,EAAE,EAAE,mBAAmB,CAAC,CAAA;KAC5G;AAED;;;;;;;;;;AAUG;IACI,OAAO,YAAY,CAAC,MAAwB,EAAA;QACjD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAA;QACtC,OAAO,IAAI,GAAG,CAAC,KAAe,EAAE,MAAM,EAAE,IAAI,CAAC,CAAA;KAC9C;AAED;;;;;;;;AAQG;AACI,IAAA,OAAO,2BAA2B,GAAA;;;QAGvC,OAAO,aAAa,CAAC,YAAY,CAAC,EAAE,GAAG,aAAa,CAAC,6BAA6B,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,IAAI,MAAM,EAAE,CAAC,CAAA;KAChI;AACF;;;;"}
|
package/types/client-manager.mjs
CHANGED
|
@@ -184,11 +184,13 @@ class ClientManager {
|
|
|
184
184
|
* using AlgoKit app deployment semantics (i.e. looking for the app creation transaction note).
|
|
185
185
|
* @param params The parameters to create the app client
|
|
186
186
|
* @example Basic
|
|
187
|
+
* ```typescript
|
|
187
188
|
* const appClient = algorand.client.getAppClientByCreatorAndName({
|
|
188
189
|
* appSpec: '{/* ARC-56 or ARC-32 compatible JSON *\}',
|
|
189
190
|
* // appId resolved by looking for app ID of named app by this creator
|
|
190
191
|
* creatorAddress: 'CREATORADDRESS',
|
|
191
192
|
* })
|
|
193
|
+
* ```
|
|
192
194
|
* @returns The `AppClient`
|
|
193
195
|
*/
|
|
194
196
|
getAppClientByCreatorAndName(params) {
|
|
@@ -204,10 +206,12 @@ class ClientManager {
|
|
|
204
206
|
* Returns a new `AppClient` client for managing calls and state for an ARC-32/ARC-56 app.
|
|
205
207
|
* @param params The parameters to create the app client
|
|
206
208
|
* @example Basic
|
|
209
|
+
* ```typescript
|
|
207
210
|
* const appClient = algorand.client.getAppClientById({
|
|
208
211
|
* appSpec: '{/* ARC-56 or ARC-32 compatible JSON *\}',
|
|
209
212
|
* appId: 12345n,
|
|
210
213
|
* })
|
|
214
|
+
* ```
|
|
211
215
|
* @returns The `AppClient`
|
|
212
216
|
*/
|
|
213
217
|
getAppClientById(params) {
|
|
@@ -224,10 +228,12 @@ class ClientManager {
|
|
|
224
228
|
* If no IDs are in the app spec or the network isn't recognised, an error is thrown.
|
|
225
229
|
* @param params The parameters to create the app client
|
|
226
230
|
* @example Basic
|
|
231
|
+
* ```typescript
|
|
227
232
|
* const appClient = algorand.client.getAppClientByNetwork({
|
|
228
233
|
* appSpec: '{/* ARC-56 or ARC-32 compatible JSON *\}',
|
|
229
234
|
* // appId resolved by using ARC-56 spec to find app ID for current network
|
|
230
235
|
* })
|
|
236
|
+
* ```
|
|
231
237
|
* @returns The `AppClient`
|
|
232
238
|
*/
|
|
233
239
|
async getAppClientByNetwork(params) {
|