@algorandfoundation/algokit-utils 1.0.0-beta.8 → 1.0.0-beta.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/account.d.ts +87 -0
  2. package/account.d.ts.map +1 -0
  3. package/account.js +144 -0
  4. package/account.js.map +1 -0
  5. package/algo-amount.d.ts +18 -0
  6. package/algo-amount.d.ts.map +1 -0
  7. package/algo-amount.js +31 -0
  8. package/algo-amount.js.map +1 -0
  9. package/algo-http-client-with-retry.d.ts +14 -0
  10. package/algo-http-client-with-retry.d.ts.map +1 -0
  11. package/algo-http-client-with-retry.js +62 -0
  12. package/algo-http-client-with-retry.js.map +1 -0
  13. package/app.d.ts +189 -0
  14. package/app.d.ts.map +1 -0
  15. package/app.js +265 -0
  16. package/app.js.map +1 -0
  17. package/application-client.d.ts +113 -0
  18. package/application-client.d.ts.map +1 -0
  19. package/application-client.js +258 -0
  20. package/application-client.js.map +1 -0
  21. package/config.d.ts +27 -0
  22. package/config.d.ts.map +1 -0
  23. package/config.js +46 -0
  24. package/config.js.map +1 -0
  25. package/deploy-app.d.ts +164 -0
  26. package/deploy-app.d.ts.map +1 -0
  27. package/deploy-app.js +419 -0
  28. package/deploy-app.js.map +1 -0
  29. package/index.d.ts +12 -0
  30. package/index.d.ts.map +1 -0
  31. package/index.js.map +1 -0
  32. package/indexer-lookup.d.ts +31 -0
  33. package/indexer-lookup.d.ts.map +1 -0
  34. package/indexer-lookup.js +96 -0
  35. package/indexer-lookup.js.map +1 -0
  36. package/localnet.d.ts +54 -0
  37. package/localnet.d.ts.map +1 -0
  38. package/localnet.js +121 -0
  39. package/localnet.js.map +1 -0
  40. package/network-client.d.ts +102 -0
  41. package/network-client.d.ts.map +1 -0
  42. package/network-client.js +182 -0
  43. package/network-client.js.map +1 -0
  44. package/package.json +2 -2
  45. package/transaction.d.ts +157 -0
  46. package/transaction.d.ts.map +1 -0
  47. package/transaction.js +306 -0
  48. package/transaction.js.map +1 -0
  49. package/transfer.d.ts +24 -0
  50. package/transfer.d.ts.map +1 -0
  51. package/transfer.js +33 -0
  52. package/transfer.js.map +1 -0
  53. package/types/algod.d.ts +124 -0
  54. package/types/algod.d.ts.map +1 -0
  55. package/types/algod.js +3 -0
  56. package/types/algod.js.map +1 -0
  57. package/types/appspec.d.ts +78 -0
  58. package/types/appspec.d.ts.map +1 -0
  59. package/types/appspec.js +15 -0
  60. package/types/appspec.js.map +1 -0
  61. package/types/indexer.d.ts +314 -0
  62. package/types/indexer.d.ts.map +1 -0
  63. package/types/indexer.js +25 -0
  64. package/types/indexer.js.map +1 -0
  65. package/urlTokenBaseHTTPClient.d.ts +41 -0
  66. package/urlTokenBaseHTTPClient.d.ts.map +1 -0
  67. package/urlTokenBaseHTTPClient.js +151 -0
  68. package/urlTokenBaseHTTPClient.js.map +1 -0
package/account.d.ts ADDED
@@ -0,0 +1,87 @@
1
+ import algosdk, { Account, Algodv2, Kmd } from 'algosdk';
2
+ import { AlgoAmount } from './algo-amount';
3
+ import { SigningAccount } from './transaction';
4
+ /**
5
+ * The account name identifier used for fund dispensing in test environments
6
+ */
7
+ export declare const DISPENSER_ACCOUNT = "DISPENSER";
8
+ /** Returns an Algorand account with secret key loaded (i.e. that can sign transactions) by taking the mnemonic secret.
9
+ *
10
+ * This is a wrapper around algosdk.mnemonicToSecretKey to provide a more friendly/obvious name.
11
+ *
12
+ * @param mnemonicSecret The mnemonic secret representing the private key of an account; **Note: Be careful how the mnemonic is handled**,
13
+ * never commit it into source control and ideally load it from the environment (ideally via a secret storage service) rather than the file system.
14
+ */
15
+ export declare function getAccountFromMnemonic(mnemonicSecret: string): Account;
16
+ /**
17
+ * Returns an Algorand account with private key loaded by convention based on the given name identifier.
18
+ *
19
+ * Note: This function expects to run in a Node.js environment.
20
+ *
21
+ * ## Convention:
22
+ * * **Non-LocalNet:** will load process.env['{NAME}_MNEMONIC'] as a mnemonic secret; **Note: Be careful how the mnemonic is handled**,
23
+ * never commit it into source control and ideally load it via a secret storage service rather than the file system.
24
+ * If process.env['{NAME}_SENDER'] is defined then it will use that for the sender address (i.e. to support rekeyed accounts)
25
+ * * **LocalNet:** will load the account from a KMD wallet called {NAME} and if that wallet doesn't exist it will create it and fund the account for you
26
+ *
27
+ * This allows you to write code that will work seamlessly in production and local development (LocalNet) without manual config locally (including when you reset the LocalNet).
28
+ *
29
+ * @example Default
30
+ *
31
+ * If you have a mnemonic secret loaded into `process.env.ACCOUNT_MNEMONIC` then you can call the following to get that private key loaded into an account object:
32
+ * ```
33
+ * const account = await getAccount('ACCOUNT', algod)
34
+ * ```
35
+ *
36
+ * If that code runs against LocalNet then a wallet called `ACCOUNT` will automatically be created with an account that is automatically funded with 1000 (default) ALGOs from the default LocalNet dispenser.
37
+ *
38
+ * @param account The details of the account to get, wither the name identifier (string) or an object with:
39
+ * * `name`: The name identifier of the account
40
+ * * `fundWith`: The amount to fund the account with it it gets created (when targeting LocalNet), if not specified then 1000 Algos will be funded from the dispenser account @see {getDispenserAccount}
41
+ * @param algod An algod client
42
+ * @param kmdClient An optional KMD client to use to create an account (when targeting LocalNet), if not specified then a default KMD client will be loaded from environment variables @see {getAlgoKmdClient}
43
+ * @returns The requested account with private key loaded from the environment variables or when targeting LocalNet from KMD (idempotently creating and funding the account)
44
+ */
45
+ export declare function getAccount(account: {
46
+ name: string;
47
+ fundWith?: AlgoAmount;
48
+ } | string, algod: Algodv2, kmdClient?: Kmd): Promise<Account | SigningAccount>;
49
+ /**
50
+ * Parameters for the getTestAccount function.
51
+ */
52
+ interface GetTestAccountParams {
53
+ /** Initial funds to ensure the account has */
54
+ initialFunds: AlgoAmount;
55
+ /** Whether to suppress the log (which includes a mnemonic) or not (default: do not supress the log) */
56
+ suppressLog?: boolean;
57
+ }
58
+ /**
59
+ * Creates an ephemeral Algorand account for the purposes of testing.
60
+ * Returns a newly created random test account that is funded from the dispenser @see {getDispenserAccount}
61
+ * DO NOT USE THIS TO CREATE A MAINNET ACCOUNT!
62
+ * Note: By default this will log the mnemonic of the account.
63
+ * @param param0 The config for the test account to generate
64
+ * @param algod An algod client
65
+ * @returns The account, with private key loaded
66
+ */
67
+ export declare function getTestAccount({ suppressLog, initialFunds }: GetTestAccountParams, algod: Algodv2): Promise<Account>;
68
+ /** Returns an account's address as a byte array
69
+ *
70
+ * @param account Either an account (with private key loaded) or the string address of an account
71
+ */
72
+ export declare function getAccountAddressAsUint8Array(account: Account | string): Uint8Array;
73
+ /** Returns the string address of an Algorand account from a base64 encoded version of the underlying byte array of the address public key
74
+ *
75
+ * @param addressEncodedInB64 The base64 encoded version of the underlying byte array of the address public key
76
+ */
77
+ export declare function getAccountAddressAsString(addressEncodedInB64: string): string;
78
+ /** Returns an account (with private key loaded) that can act as a dispenser
79
+ *
80
+ * If running on Sandbox then it will return the default dispenser account automatically,
81
+ * otherwise it will load the account mnemonic stored in process.env.DISPENSER_MNEMONIC @see {getAccount}
82
+ *
83
+ * @param algod An algod client
84
+ */
85
+ export declare function getDispenserAccount(algod: Algodv2): Promise<algosdk.Account | SigningAccount>;
86
+ export {};
87
+ //# sourceMappingURL=account.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAI1C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAG9C;;GAEG;AACH,eAAO,MAAM,iBAAiB,cAAc,CAAA;AAE5C;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAGtE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,UAAU,CAC9B,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,UAAU,CAAA;CAAE,GAAG,MAAM,EACzD,KAAK,EAAE,OAAO,EACd,SAAS,CAAC,EAAE,GAAG,GACd,OAAO,CAAC,OAAO,GAAG,cAAc,CAAC,CAmCnC;AAED;;GAEG;AACH,UAAU,oBAAoB;IAC5B,8CAA8C;IAC9C,YAAY,EAAE,UAAU,CAAA;IACxB,uGAAuG;IACvG,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB;AAED;;;;;;;;GAQG;AACH,wBAAsB,cAAc,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,EAAE,oBAAoB,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAmB1H;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,cAEtE;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,mBAAmB,EAAE,MAAM,GAAG,MAAM,CAE7E;AAED;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,OAAO,6CAIvD"}
package/account.js ADDED
@@ -0,0 +1,144 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getDispenserAccount = exports.getAccountAddressAsString = exports.getAccountAddressAsUint8Array = exports.getTestAccount = exports.getAccount = exports.getAccountFromMnemonic = exports.DISPENSER_ACCOUNT = void 0;
7
+ const algosdk_1 = __importDefault(require("algosdk"));
8
+ const config_1 = require("./config");
9
+ const localnet_1 = require("./localnet");
10
+ const network_client_1 = require("./network-client");
11
+ const transaction_1 = require("./transaction");
12
+ const transfer_1 = require("./transfer");
13
+ /**
14
+ * The account name identifier used for fund dispensing in test environments
15
+ */
16
+ exports.DISPENSER_ACCOUNT = 'DISPENSER';
17
+ /** Returns an Algorand account with secret key loaded (i.e. that can sign transactions) by taking the mnemonic secret.
18
+ *
19
+ * This is a wrapper around algosdk.mnemonicToSecretKey to provide a more friendly/obvious name.
20
+ *
21
+ * @param mnemonicSecret The mnemonic secret representing the private key of an account; **Note: Be careful how the mnemonic is handled**,
22
+ * never commit it into source control and ideally load it from the environment (ideally via a secret storage service) rather than the file system.
23
+ */
24
+ function getAccountFromMnemonic(mnemonicSecret) {
25
+ // This method is confusingly named, so this function provides a more dev friendly "wrapper" name
26
+ return algosdk_1.default.mnemonicToSecretKey(mnemonicSecret);
27
+ }
28
+ exports.getAccountFromMnemonic = getAccountFromMnemonic;
29
+ /**
30
+ * Returns an Algorand account with private key loaded by convention based on the given name identifier.
31
+ *
32
+ * Note: This function expects to run in a Node.js environment.
33
+ *
34
+ * ## Convention:
35
+ * * **Non-LocalNet:** will load process.env['{NAME}_MNEMONIC'] as a mnemonic secret; **Note: Be careful how the mnemonic is handled**,
36
+ * never commit it into source control and ideally load it via a secret storage service rather than the file system.
37
+ * If process.env['{NAME}_SENDER'] is defined then it will use that for the sender address (i.e. to support rekeyed accounts)
38
+ * * **LocalNet:** will load the account from a KMD wallet called {NAME} and if that wallet doesn't exist it will create it and fund the account for you
39
+ *
40
+ * This allows you to write code that will work seamlessly in production and local development (LocalNet) without manual config locally (including when you reset the LocalNet).
41
+ *
42
+ * @example Default
43
+ *
44
+ * If you have a mnemonic secret loaded into `process.env.ACCOUNT_MNEMONIC` then you can call the following to get that private key loaded into an account object:
45
+ * ```
46
+ * const account = await getAccount('ACCOUNT', algod)
47
+ * ```
48
+ *
49
+ * If that code runs against LocalNet then a wallet called `ACCOUNT` will automatically be created with an account that is automatically funded with 1000 (default) ALGOs from the default LocalNet dispenser.
50
+ *
51
+ * @param account The details of the account to get, wither the name identifier (string) or an object with:
52
+ * * `name`: The name identifier of the account
53
+ * * `fundWith`: The amount to fund the account with it it gets created (when targeting LocalNet), if not specified then 1000 Algos will be funded from the dispenser account @see {getDispenserAccount}
54
+ * @param algod An algod client
55
+ * @param kmdClient An optional KMD client to use to create an account (when targeting LocalNet), if not specified then a default KMD client will be loaded from environment variables @see {getAlgoKmdClient}
56
+ * @returns The requested account with private key loaded from the environment variables or when targeting LocalNet from KMD (idempotently creating and funding the account)
57
+ */
58
+ async function getAccount(account, algod, kmdClient) {
59
+ let name;
60
+ let fundWith = undefined;
61
+ if (typeof account === 'string') {
62
+ name = account;
63
+ }
64
+ else {
65
+ name = account.name;
66
+ fundWith = account.fundWith;
67
+ }
68
+ if (!process || !process.env) {
69
+ throw new Error('Attempt to get account with private key from a non Node.js context; not supported!');
70
+ }
71
+ const envKey = `${name.toUpperCase()}_MNEMONIC`;
72
+ if (process.env[envKey]) {
73
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
74
+ const signer = getAccountFromMnemonic(process.env[envKey]);
75
+ const senderKey = `${name.toUpperCase()}_SENDER`;
76
+ if (process.env[senderKey]) {
77
+ config_1.AlgoKitConfig.logger.debug(`Using rekeyed account ${signer.addr} for sender ${process.env[senderKey]} for ${name} account`);
78
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
79
+ return new transaction_1.SigningAccount(signer, process.env[senderKey]);
80
+ }
81
+ else {
82
+ return signer;
83
+ }
84
+ }
85
+ if (await (0, network_client_1.isLocalNet)(algod)) {
86
+ const account = await (0, localnet_1.getOrCreateKmdWalletAccount)({ name, fundWith }, algod, kmdClient);
87
+ process.env[envKey] = algosdk_1.default.secretKeyToMnemonic(account.sk);
88
+ return account;
89
+ }
90
+ throw `Missing environment variable ${envKey} when looking for account ${name}`;
91
+ }
92
+ exports.getAccount = getAccount;
93
+ /**
94
+ * Creates an ephemeral Algorand account for the purposes of testing.
95
+ * Returns a newly created random test account that is funded from the dispenser @see {getDispenserAccount}
96
+ * DO NOT USE THIS TO CREATE A MAINNET ACCOUNT!
97
+ * Note: By default this will log the mnemonic of the account.
98
+ * @param param0 The config for the test account to generate
99
+ * @param algod An algod client
100
+ * @returns The account, with private key loaded
101
+ */
102
+ async function getTestAccount({ suppressLog, initialFunds }, algod) {
103
+ const account = algosdk_1.default.generateAccount();
104
+ config_1.AlgoKitConfig.getLogger(suppressLog).info(`New test account created with address '${account.addr}' and mnemonic '${algosdk_1.default.secretKeyToMnemonic(account.sk)}'.`);
105
+ // If we are running against LocalNet we can use the default account within it
106
+ // otherwise use an automation account specified via environment variables and ensure it's populated with ALGOs
107
+ const canFundFromDefaultAccount = await (0, network_client_1.isLocalNet)(algod);
108
+ const dispenser = canFundFromDefaultAccount ? await (0, localnet_1.getLocalNetDispenserAccount)(algod) : await getAccount(exports.DISPENSER_ACCOUNT, algod);
109
+ await (0, transfer_1.transferAlgos)({ from: dispenser, to: account.addr, amount: initialFunds, note: 'Funding test account', suppressLog }, algod);
110
+ const accountInfo = await algod.accountInformation(account.addr).do();
111
+ config_1.AlgoKitConfig.getLogger(suppressLog).info('Test account funded; account balance: %d µAlgos', accountInfo.amount);
112
+ return account;
113
+ }
114
+ exports.getTestAccount = getTestAccount;
115
+ /** Returns an account's address as a byte array
116
+ *
117
+ * @param account Either an account (with private key loaded) or the string address of an account
118
+ */
119
+ function getAccountAddressAsUint8Array(account) {
120
+ return algosdk_1.default.decodeAddress(typeof account === 'string' ? account : account.addr).publicKey;
121
+ }
122
+ exports.getAccountAddressAsUint8Array = getAccountAddressAsUint8Array;
123
+ /** Returns the string address of an Algorand account from a base64 encoded version of the underlying byte array of the address public key
124
+ *
125
+ * @param addressEncodedInB64 The base64 encoded version of the underlying byte array of the address public key
126
+ */
127
+ function getAccountAddressAsString(addressEncodedInB64) {
128
+ return algosdk_1.default.encodeAddress(Buffer.from(addressEncodedInB64, 'base64'));
129
+ }
130
+ exports.getAccountAddressAsString = getAccountAddressAsString;
131
+ /** Returns an account (with private key loaded) that can act as a dispenser
132
+ *
133
+ * If running on Sandbox then it will return the default dispenser account automatically,
134
+ * otherwise it will load the account mnemonic stored in process.env.DISPENSER_MNEMONIC @see {getAccount}
135
+ *
136
+ * @param algod An algod client
137
+ */
138
+ async function getDispenserAccount(algod) {
139
+ // If we are running against a sandbox we can use the default account within it, otherwise use an automation account specified via environment variables and ensure it's populated with ALGOs
140
+ const canFundFromDefaultAccount = await (0, network_client_1.isLocalNet)(algod);
141
+ return canFundFromDefaultAccount ? await (0, localnet_1.getLocalNetDispenserAccount)(algod) : await getAccount(exports.DISPENSER_ACCOUNT, algod);
142
+ }
143
+ exports.getDispenserAccount = getDispenserAccount;
144
+ //# sourceMappingURL=account.js.map
package/account.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account.js","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAwD;AAExD,qCAAwC;AACxC,yCAAqF;AACrF,qDAA6C;AAC7C,+CAA8C;AAC9C,yCAA0C;AAE1C;;GAEG;AACU,QAAA,iBAAiB,GAAG,WAAW,CAAA;AAE5C;;;;;;GAMG;AACH,SAAgB,sBAAsB,CAAC,cAAsB;IAC3D,iGAAiG;IACjG,OAAO,iBAAO,CAAC,mBAAmB,CAAC,cAAc,CAAC,CAAA;AACpD,CAAC;AAHD,wDAGC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACI,KAAK,UAAU,UAAU,CAC9B,OAAyD,EACzD,KAAc,EACd,SAAe;IAEf,IAAI,IAAY,CAAA;IAChB,IAAI,QAAQ,GAA2B,SAAS,CAAA;IAChD,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;QAC/B,IAAI,GAAG,OAAO,CAAA;KACf;SAAM;QACL,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;QACnB,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAA;KAC5B;IAED,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE;QAC5B,MAAM,IAAI,KAAK,CAAC,oFAAoF,CAAC,CAAA;KACtG;IAED,MAAM,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,EAAE,WAAW,CAAA;IAC/C,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE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;IACzD,OAAO,yBAAyB,CAAC,CAAC,CAAC,MAAM,IAAA,sCAA2B,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,UAAU,CAAC,yBAAiB,EAAE,KAAK,CAAC,CAAA;AAC1H,CAAC;AAJD,kDAIC"}
@@ -0,0 +1,18 @@
1
+ /** Wrapper class to ensure safe, explicit conversion between µAlgos, Algos and numbers */
2
+ export declare class AlgoAmount {
3
+ private amountInMicroAlgos;
4
+ /** Return the amount as a number in µAlgos */
5
+ get microAlgos(): number;
6
+ /** Return the amount as a number in Algos */
7
+ get algos(): number;
8
+ constructor(amount: {
9
+ algos: number;
10
+ } | {
11
+ microAlgos: number;
12
+ });
13
+ /** Create a @see {AlgoAmount} object representing the given number of Algos */
14
+ static Algos(amount: number): AlgoAmount;
15
+ /** Create a @see {AlgoAmount} object representing the given number of µAlgos */
16
+ static MicroAlgos(amount: number): AlgoAmount;
17
+ }
18
+ //# sourceMappingURL=algo-amount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"algo-amount.d.ts","sourceRoot":"","sources":["../src/algo-amount.ts"],"names":[],"mappings":"AAEA,0FAA0F;AAC1F,qBAAa,UAAU;IACrB,OAAO,CAAC,kBAAkB,CAAA;IAE1B,8CAA8C;IAC9C,IAAI,UAAU,WAEb;IAED,6CAA6C;IAC7C,IAAI,KAAK,WAER;gBAEW,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE;IAI9D,+EAA+E;IAC/E,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM;IAI3B,gFAAgF;IAChF,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM;CAGjC"}
package/algo-amount.js ADDED
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.AlgoAmount = void 0;
7
+ const algosdk_1 = __importDefault(require("algosdk"));
8
+ /** Wrapper class to ensure safe, explicit conversion between µAlgos, Algos and numbers */
9
+ class AlgoAmount {
10
+ /** Return the amount as a number in µAlgos */
11
+ get microAlgos() {
12
+ return this.amountInMicroAlgos;
13
+ }
14
+ /** Return the amount as a number in Algos */
15
+ get algos() {
16
+ return algosdk_1.default.microalgosToAlgos(this.amountInMicroAlgos);
17
+ }
18
+ constructor(amount) {
19
+ this.amountInMicroAlgos = 'microAlgos' in amount ? amount.microAlgos : algosdk_1.default.algosToMicroalgos(amount.algos);
20
+ }
21
+ /** Create a @see {AlgoAmount} object representing the given number of Algos */
22
+ static Algos(amount) {
23
+ return new AlgoAmount({ algos: amount });
24
+ }
25
+ /** Create a @see {AlgoAmount} object representing the given number of µAlgos */
26
+ static MicroAlgos(amount) {
27
+ return new AlgoAmount({ microAlgos: amount });
28
+ }
29
+ }
30
+ exports.AlgoAmount = AlgoAmount;
31
+ //# sourceMappingURL=algo-amount.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"algo-amount.js","sourceRoot":"","sources":["../src/algo-amount.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA6B;AAE7B,0FAA0F;AAC1F,MAAa,UAAU;IAGrB,8CAA8C;IAC9C,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,kBAAkB,CAAA;IAChC,CAAC;IAED,6CAA6C;IAC7C,IAAI,KAAK;QACP,OAAO,iBAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;IAC3D,CAAC;IAED,YAAY,MAAkD;QAC5D,IAAI,CAAC,kBAAkB,GAAG,YAAY,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,iBAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IAChH,CAAC;IAED,+EAA+E;IAC/E,MAAM,CAAC,KAAK,CAAC,MAAc;QACzB,OAAO,IAAI,UAAU,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAA;IAC1C,CAAC;IAED,gFAAgF;IAChF,MAAM,CAAC,UAAU,CAAC,MAAc;QAC9B,OAAO,IAAI,UAAU,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAA;IAC/C,CAAC;CACF;AA1BD,gCA0BC"}
@@ -0,0 +1,14 @@
1
+ import { BaseHTTPClientResponse, Query } from 'algosdk/dist/types/client/baseHTTPClient';
2
+ import { URLTokenBaseHTTPClient } from './urlTokenBaseHTTPClient';
3
+ /** A HTTP Client that wraps the Algorand SDK HTTP Client with retries */
4
+ export declare class AlgoHttpClientWithRetry extends URLTokenBaseHTTPClient {
5
+ private static readonly MAX_TRIES;
6
+ private static readonly MAX_BACKOFF_MS;
7
+ private static readonly RETRY_STATUS_CODES;
8
+ private static readonly RETRY_ERROR_CODES;
9
+ private callWithRetry;
10
+ get(relativePath: string, query?: Query<string>, requestHeaders?: Record<string, string>): Promise<BaseHTTPClientResponse>;
11
+ post(relativePath: string, data: Uint8Array, query?: Query<string>, requestHeaders?: Record<string, string>): Promise<BaseHTTPClientResponse>;
12
+ delete(relativePath: string, data: Uint8Array, query?: Query<string>, requestHeaders?: Record<string, string>): Promise<BaseHTTPClientResponse>;
13
+ }
14
+ //# sourceMappingURL=algo-http-client-with-retry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"algo-http-client-with-retry.d.ts","sourceRoot":"","sources":["../src/algo-http-client-with-retry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,KAAK,EAAE,MAAM,0CAA0C,CAAA;AAExF,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AAEjE,yEAAyE;AACzE,qBAAa,uBAAwB,SAAQ,sBAAsB;IACjE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAI;IACrC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAQ;IAI9C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAsC;IAChF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAUxC;YAEa,aAAa;IA6BrB,GAAG,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,cAAc,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAI9H,IAAI,CACR,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,UAAU,EAChB,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,EACrB,cAAc,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GAC1C,OAAO,CAAC,sBAAsB,CAAC;IAI5B,MAAM,CACV,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,UAAU,EAChB,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,EACrB,cAAc,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GAC1C,OAAO,CAAC,sBAAsB,CAAC;CAGnC"}
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AlgoHttpClientWithRetry = void 0;
4
+ const config_1 = require("./config");
5
+ const urlTokenBaseHTTPClient_1 = require("./urlTokenBaseHTTPClient");
6
+ /** A HTTP Client that wraps the Algorand SDK HTTP Client with retries */
7
+ class AlgoHttpClientWithRetry extends urlTokenBaseHTTPClient_1.URLTokenBaseHTTPClient {
8
+ async callWithRetry(func) {
9
+ let response;
10
+ let numTries = 1;
11
+ do {
12
+ try {
13
+ response = await func();
14
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
+ }
16
+ catch (err) {
17
+ if (numTries >= AlgoHttpClientWithRetry.MAX_TRIES) {
18
+ throw err;
19
+ }
20
+ // Only retry for one of the hardcoded conditions
21
+ if (!(AlgoHttpClientWithRetry.RETRY_ERROR_CODES.includes(err.code) || AlgoHttpClientWithRetry.RETRY_STATUS_CODES.includes(err.status))) {
22
+ throw err;
23
+ }
24
+ // Retry immediately the first time, then exponentially backoff.
25
+ const delayTimeMs = numTries == 1 ? 0 : Math.min(1000 * Math.pow(2, numTries - 1), AlgoHttpClientWithRetry.MAX_BACKOFF_MS);
26
+ if (delayTimeMs > 0) {
27
+ await new Promise((r) => setTimeout(r, delayTimeMs));
28
+ }
29
+ config_1.AlgoKitConfig.logger.warn(`algosdk request failed ${numTries} times. Retrying in ${delayTimeMs}ms: ${err}`);
30
+ }
31
+ } while (!response && ++numTries <= AlgoHttpClientWithRetry.MAX_TRIES);
32
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
33
+ return response;
34
+ }
35
+ async get(relativePath, query, requestHeaders = {}) {
36
+ return await this.callWithRetry(() => super.get(relativePath, query, requestHeaders));
37
+ }
38
+ async post(relativePath, data, query, requestHeaders = {}) {
39
+ return await this.callWithRetry(() => super.post(relativePath, data, query, requestHeaders));
40
+ }
41
+ async delete(relativePath, data, query, requestHeaders = {}) {
42
+ return await this.callWithRetry(() => super.delete(relativePath, data, query, requestHeaders));
43
+ }
44
+ }
45
+ exports.AlgoHttpClientWithRetry = AlgoHttpClientWithRetry;
46
+ AlgoHttpClientWithRetry.MAX_TRIES = 5;
47
+ AlgoHttpClientWithRetry.MAX_BACKOFF_MS = 10000;
48
+ // These lists come from https://visionmedia.github.io/superagent/#retrying-requests
49
+ // which is the underlying library used by algosdk - but the CloudFlare specific 52X status codes have been removed
50
+ AlgoHttpClientWithRetry.RETRY_STATUS_CODES = [408, 413, 429, 500, 502, 503, 504];
51
+ AlgoHttpClientWithRetry.RETRY_ERROR_CODES = [
52
+ 'ETIMEDOUT',
53
+ 'ECONNRESET',
54
+ 'EADDRINUSE',
55
+ 'ECONNREFUSED',
56
+ 'EPIPE',
57
+ 'ENOTFOUND',
58
+ 'ENETUNREACH',
59
+ 'EAI_AGAIN',
60
+ 'EPROTO', // We get this intermittently with AlgoNode API
61
+ ];
62
+ //# sourceMappingURL=algo-http-client-with-retry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"algo-http-client-with-retry.js","sourceRoot":"","sources":["../src/algo-http-client-with-retry.ts"],"names":[],"mappings":";;;AACA,qCAAwC;AACxC,qEAAiE;AAEjE,yEAAyE;AACzE,MAAa,uBAAwB,SAAQ,+CAAsB;IAmBzD,KAAK,CAAC,aAAa,CAAC,IAA2C;QACrE,IAAI,QAA4C,CAAA;QAChD,IAAI,QAAQ,GAAG,CAAC,CAAA;QAChB,GAAG;YACD,IAAI;gBACF,QAAQ,GAAG,MAAM,IAAI,EAAE,CAAA;gBACvB,8DAA8D;aAC/D;YAAC,OAAO,GAAQ,EAAE;gBACjB,IAAI,QAAQ,IAAI,uBAAuB,CAAC,SAAS,EAAE;oBACjD,MAAM,GAAG,CAAA;iBACV;gBACD,iDAAiD;gBACjD,IACE,CAAC,CAAC,uBAAuB,CAAC,iBAAiB,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,uBAAuB,CAAC,kBAAkB,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAClI;oBACA,MAAM,GAAG,CAAA;iBACV;gBACD,gEAAgE;gBAChE,MAAM,WAAW,GAAG,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,GAAG,CAAC,CAAC,EAAE,uBAAuB,CAAC,cAAc,CAAC,CAAA;gBAC1H,IAAI,WAAW,GAAG,CAAC,EAAE;oBACnB,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAA;iBACrD;gBACD,sBAAa,CAAC,MAAM,CAAC,IAAI,CA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ACX,QAAQ,EAAE,+CAA+C;CAC1D,CAAA"}
package/app.d.ts ADDED
@@ -0,0 +1,189 @@
1
+ import algosdk, { ABIArgument, ABIMethod, ABIMethodParams, ABIValue, Address, Algodv2, SuggestedParams } from 'algosdk';
2
+ import { SendTransactionFrom, SendTransactionParams, SendTransactionResult, TransactionNote } from './transaction';
3
+ import { ApplicationResponse, PendingTransactionResponse } from './types/algod';
4
+ /** The maximum number of bytes in an app code page */
5
+ export declare const APP_PAGE_MAX_SIZE = 2048;
6
+ /** First 4 bytes of SHA-512/256 hash of "return" */
7
+ export declare const ABI_RETURN_PREFIX: Uint8Array;
8
+ /** Information about an Algorand app */
9
+ export interface AppReference {
10
+ /** The index of the app */
11
+ appIndex: number;
12
+ /** The Algorand address of the account associated with the app */
13
+ appAddress: string;
14
+ }
15
+ /**
16
+ * A grouping of the app ID and name of the box in an Uint8Array
17
+ */
18
+ export interface BoxReference {
19
+ /**
20
+ * A unique application index
21
+ */
22
+ appIndex: number;
23
+ /**
24
+ * Name of box to reference
25
+ */
26
+ name: Uint8Array | string;
27
+ }
28
+ /**
29
+ * App call args with raw values (minus some processing like encoding strings as binary)
30
+ */
31
+ export interface RawAppCallArgs {
32
+ /** The address of any accounts to load in */
33
+ accounts?: (string | Address)[];
34
+ /** Any application arguments to pass through */
35
+ appArgs?: (Uint8Array | string)[];
36
+ /** Any box references to load */
37
+ boxes?: BoxReference[];
38
+ /** IDs of any apps to load into the foreignApps array */
39
+ apps?: number[];
40
+ /** IDs of any assets to load into the foreignAssets array */
41
+ assets?: number[];
42
+ /** The optional lease for the transaction */
43
+ lease?: string | Uint8Array;
44
+ }
45
+ /**
46
+ * App call args for an ABI call
47
+ */
48
+ export interface ABIAppCallArgs {
49
+ /** The ABI method to call, either:
50
+ * * {method_name e.g. `hello`}; or
51
+ * * {method_signature e.g. `hello(string)string`} */
52
+ method: ABIMethodParams | ABIMethod;
53
+ /** The ABI args to pass in */
54
+ args: ABIArgument[];
55
+ /** The optional lease for the transaction */
56
+ lease?: string | Uint8Array;
57
+ }
58
+ /** Arguments to pass to an app call either:
59
+ * * The raw app call values to pass through into the transaction (after processing); or
60
+ * * An ABI method definition (method and args)
61
+ **/
62
+ export type AppCallArgs = RawAppCallArgs | ABIAppCallArgs;
63
+ /** Base interface for common data passed to an app create or update. */
64
+ interface CreateOrUpdateAppParams extends SendTransactionParams {
65
+ /** The account (with private key loaded) that will send the µALGOs */
66
+ from: SendTransactionFrom;
67
+ /** The approval program as raw teal (string) or compiled teal, base 64 encoded as a byte array (Uint8Array) */
68
+ approvalProgram: Uint8Array | string;
69
+ /** The clear state program as raw teal (string) or compiled teal, base 64 encoded as a byte array (Uint8Array) */
70
+ clearStateProgram: Uint8Array | string;
71
+ /** Optional transaction parameters */
72
+ transactionParams?: SuggestedParams;
73
+ /** The (optional) transaction note */
74
+ note?: TransactionNote;
75
+ /** The arguments passed in to the app call */
76
+ args?: AppCallArgs;
77
+ }
78
+ /** Parameters that are passed in when creating an app. */
79
+ export interface CreateAppParams extends CreateOrUpdateAppParams {
80
+ /** The storage schema to request for the created app */
81
+ schema: AppStorageSchema;
82
+ }
83
+ /** Parameters that are passed in when updating an app. */
84
+ export interface UpdateAppParams extends CreateOrUpdateAppParams {
85
+ /** The index of the app to update */
86
+ appIndex: number;
87
+ }
88
+ export interface AppCallParams extends SendTransactionParams {
89
+ /** The index of the app to call */
90
+ appIndex: number;
91
+ /** The type of call, everything except create (@see {createApp} ) and update (@see {updateApp} ) */
92
+ callType: 'optin' | 'closeout' | 'clearstate' | 'delete' | 'normal';
93
+ /** The account to make the call from */
94
+ from: SendTransactionFrom;
95
+ /** Optional transaction parameters */
96
+ transactionParams?: SuggestedParams;
97
+ /** The (optional) transaction note */
98
+ note?: TransactionNote;
99
+ /** The arguments passed in to the app call */
100
+ args?: AppCallArgs;
101
+ }
102
+ /** Parameters representing the storage schema of an app. */
103
+ export interface AppStorageSchema {
104
+ /** Restricts number of ints in per-user local state */
105
+ localInts: number;
106
+ /** Restricts number of byte slices in per-user local state */
107
+ localByteSlices: number;
108
+ /** Restricts number of ints in global state */
109
+ globalInts: number;
110
+ /** Restricts number of byte slices in global state */
111
+ globalByteSlices: number;
112
+ /** Any extra pages that are needed for the smart contract; if left blank then the right number of pages will be calculated based on the teal code size */
113
+ extraPages?: number;
114
+ }
115
+ /** Information about a compiled teal program */
116
+ export interface CompiledTeal {
117
+ /** Original TEAL code */
118
+ teal: string;
119
+ /** The compiled code */
120
+ compiled: string;
121
+ /** The has returned by the compiler */
122
+ compiledHash: string;
123
+ /** The base64 encoded code as a byte array */
124
+ compiledBase64ToBytes: Uint8Array;
125
+ }
126
+ /** Result from calling an app */
127
+ export interface AppCallTransactionResult extends SendTransactionResult {
128
+ /** If an ABI method was called the processed return value */
129
+ return?: ABIReturn;
130
+ }
131
+ /** The return value of an ABI method call */
132
+ export type ABIReturn = {
133
+ rawReturnValue: Uint8Array;
134
+ returnValue: ABIValue;
135
+ decodeError: undefined;
136
+ } | {
137
+ rawReturnValue: undefined;
138
+ returnValue: undefined;
139
+ decodeError: Error;
140
+ };
141
+ /**
142
+ * Creates a smart contract app, returns the details of the created app.
143
+ * @param create The parameters to create the app with
144
+ * @param algod An algod client
145
+ * @returns The details of the created app, or the transaction to create it if `skipSending`
146
+ */
147
+ export declare function createApp(create: CreateAppParams, algod: Algodv2): Promise<AppCallTransactionResult & AppReference>;
148
+ /**
149
+ * Updates a smart contract app.
150
+ * @param update The parameters to update the app with
151
+ * @param algod An algod client
152
+ * @returns The transaction
153
+ */
154
+ export declare function updateApp(update: UpdateAppParams, algod: Algodv2): Promise<AppCallTransactionResult>;
155
+ /**
156
+ * Issues a call to a given app.
157
+ * @param call The call details.
158
+ * @param algod An algod client
159
+ * @returns The result of the call
160
+ */
161
+ export declare function callApp(call: AppCallParams, algod: Algodv2): Promise<AppCallTransactionResult>;
162
+ export declare function getABIReturn(args?: AppCallArgs, confirmation?: PendingTransactionResponse): ABIReturn | undefined;
163
+ /** Returns the app args ready to load onto an app @see {Transaction} object */
164
+ export declare function getAppArgsForTransaction(args?: AppCallArgs): {
165
+ accounts: string[] | undefined;
166
+ appArgs: Uint8Array[] | undefined;
167
+ boxes: algosdk.BoxReference[] | undefined;
168
+ foreignApps: number[] | undefined;
169
+ foreignAssets: number[] | undefined;
170
+ lease: Uint8Array | undefined;
171
+ } | undefined;
172
+ /**
173
+ * Gets the current data for the given app from algod.
174
+ *
175
+ * @param appIndex The index of the app
176
+ * @param algod An algod client
177
+ * @returns The data about the app
178
+ */
179
+ export declare function getAppByIndex(appIndex: number, algod: Algodv2): Promise<ApplicationResponse>;
180
+ /**
181
+ * Compiles the given TEAL using algod and returns the result.
182
+ *
183
+ * @param algod An algod client
184
+ * @param tealCode The TEAL code
185
+ * @returns The information about the compiled file
186
+ */
187
+ export declare function compileTeal(tealCode: string, algod: Algodv2): Promise<CompiledTeal>;
188
+ export {};
189
+ //# sourceMappingURL=app.d.ts.map
package/app.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EACd,WAAW,EACX,SAAS,EACT,eAAe,EACf,QAAQ,EACR,OAAO,EACP,OAAO,EAIP,eAAe,EAEhB,MAAM,SAAS,CAAA;AAGhB,OAAO,EAKL,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EAChB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAA;AAE/E,sDAAsD;AACtD,eAAO,MAAM,iBAAiB,OAAO,CAAA;AACrC,oDAAoD;AACpD,eAAO,MAAM,iBAAiB,YAAqC,CAAA;AAEnE,wCAAwC;AACxC,MAAM,WAAW,YAAY;IAC3B,2BAA2B;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,kEAAkE;IAClE,UAAU,EAAE,MAAM,CAAA;CACnB;AAED;;GAEG;AACH,MAAM,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