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

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 (141) hide show
  1. package/account.d.ts +91 -0
  2. package/account.d.ts.map +1 -0
  3. package/account.js +158 -0
  4. package/account.js.map +1 -0
  5. package/amount.d.ts +8 -0
  6. package/amount.d.ts.map +1 -0
  7. package/amount.js +24 -0
  8. package/amount.js.map +1 -0
  9. package/app.d.ts +108 -0
  10. package/app.d.ts.map +1 -0
  11. package/app.js +423 -0
  12. package/app.js.map +1 -0
  13. package/application-client.d.ts +10 -0
  14. package/application-client.d.ts.map +1 -0
  15. package/application-client.js +15 -0
  16. package/application-client.js.map +1 -0
  17. package/deploy-app.d.ts +93 -0
  18. package/deploy-app.d.ts.map +1 -0
  19. package/deploy-app.js +410 -0
  20. package/deploy-app.js.map +1 -0
  21. package/index.d.ts +14 -0
  22. package/index.d.ts.map +1 -0
  23. package/index.js +5 -2
  24. package/index.js.map +1 -0
  25. package/indexer-lookup.d.ts +31 -0
  26. package/indexer-lookup.d.ts.map +1 -0
  27. package/indexer-lookup.js +96 -0
  28. package/indexer-lookup.js.map +1 -0
  29. package/localnet.d.ts +54 -0
  30. package/localnet.d.ts.map +1 -0
  31. package/localnet.js +121 -0
  32. package/localnet.js.map +1 -0
  33. package/network-client.d.ts +93 -0
  34. package/network-client.d.ts.map +1 -0
  35. package/network-client.js +182 -0
  36. package/network-client.js.map +1 -0
  37. package/package.json +3 -3
  38. package/testing/account.d.ts +14 -0
  39. package/testing/account.d.ts.map +1 -0
  40. package/testing/account.js +31 -0
  41. package/testing/account.js.map +1 -0
  42. package/testing/fixtures/algokit-log-capture-fixture.d.ts +19 -0
  43. package/testing/fixtures/algokit-log-capture-fixture.d.ts.map +1 -0
  44. package/testing/fixtures/algokit-log-capture-fixture.js +43 -0
  45. package/testing/fixtures/algokit-log-capture-fixture.js.map +1 -0
  46. package/testing/fixtures/algorand-fixture.d.ts +20 -0
  47. package/testing/fixtures/algorand-fixture.d.ts.map +1 -0
  48. package/testing/fixtures/algorand-fixture.js +49 -0
  49. package/testing/fixtures/algorand-fixture.js.map +1 -0
  50. package/testing/fixtures/index.d.ts +3 -0
  51. package/testing/fixtures/index.d.ts.map +1 -0
  52. package/testing/fixtures/index.js +19 -0
  53. package/testing/fixtures/index.js.map +1 -0
  54. package/testing/index.d.ts +6 -0
  55. package/testing/index.d.ts.map +1 -0
  56. package/testing/index.js +22 -0
  57. package/testing/index.js.map +1 -0
  58. package/testing/indexer.d.ts +12 -0
  59. package/testing/indexer.d.ts.map +1 -0
  60. package/testing/indexer.js +39 -0
  61. package/testing/indexer.js.map +1 -0
  62. package/testing/test-logger.d.ts +39 -0
  63. package/testing/test-logger.d.ts.map +1 -0
  64. package/testing/test-logger.js +69 -0
  65. package/testing/test-logger.js.map +1 -0
  66. package/testing/transaction-logger.d.ts +29 -0
  67. package/testing/transaction-logger.d.ts.map +1 -0
  68. package/testing/transaction-logger.js +71 -0
  69. package/testing/transaction-logger.js.map +1 -0
  70. package/transaction.d.ts +80 -0
  71. package/transaction.d.ts.map +1 -0
  72. package/transaction.js +256 -0
  73. package/transaction.js.map +1 -0
  74. package/transfer.d.ts +21 -0
  75. package/transfer.d.ts.map +1 -0
  76. package/transfer.js +65 -0
  77. package/transfer.js.map +1 -0
  78. package/types/account.d.ts +52 -0
  79. package/types/account.d.ts.map +1 -0
  80. package/types/account.js +86 -0
  81. package/types/account.js.map +1 -0
  82. package/types/algo-http-client-with-retry.d.ts +14 -0
  83. package/types/algo-http-client-with-retry.d.ts.map +1 -0
  84. package/types/algo-http-client-with-retry.js +62 -0
  85. package/types/algo-http-client-with-retry.js.map +1 -0
  86. package/types/algod.d.ts +137 -0
  87. package/types/algod.d.ts.map +1 -0
  88. package/types/algod.js +3 -0
  89. package/types/algod.js.map +1 -0
  90. package/types/amount.d.ts +20 -0
  91. package/types/amount.d.ts.map +1 -0
  92. package/types/amount.js +37 -0
  93. package/types/amount.js.map +1 -0
  94. package/types/app.d.ts +279 -0
  95. package/types/app.d.ts.map +1 -0
  96. package/types/app.js +32 -0
  97. package/types/app.js.map +1 -0
  98. package/types/application-client.d.ts +229 -0
  99. package/types/application-client.d.ts.map +1 -0
  100. package/types/application-client.js +470 -0
  101. package/types/application-client.js.map +1 -0
  102. package/types/appspec.d.ts +77 -0
  103. package/types/appspec.d.ts.map +1 -0
  104. package/types/appspec.js +15 -0
  105. package/types/appspec.js.map +1 -0
  106. package/types/config.d.ts +15 -0
  107. package/types/config.d.ts.map +1 -0
  108. package/types/config.js +27 -0
  109. package/types/config.js.map +1 -0
  110. package/types/indexer.d.ts +313 -0
  111. package/types/indexer.d.ts.map +1 -0
  112. package/types/indexer.js +25 -0
  113. package/types/indexer.js.map +1 -0
  114. package/types/logging.d.ts +13 -0
  115. package/types/logging.d.ts.map +1 -0
  116. package/types/logging.js +27 -0
  117. package/types/logging.js.map +1 -0
  118. package/types/logic-error.d.ts +33 -0
  119. package/types/logic-error.d.ts.map +1 -0
  120. package/types/logic-error.js +46 -0
  121. package/types/logic-error.js.map +1 -0
  122. package/types/network-client.d.ts +11 -0
  123. package/types/network-client.d.ts.map +1 -0
  124. package/types/network-client.js +3 -0
  125. package/types/network-client.js.map +1 -0
  126. package/types/testing.d.ts +89 -0
  127. package/types/testing.d.ts.map +1 -0
  128. package/types/testing.js +3 -0
  129. package/types/testing.js.map +1 -0
  130. package/types/transaction.d.ts +67 -0
  131. package/types/transaction.d.ts.map +1 -0
  132. package/types/transaction.js +3 -0
  133. package/types/transaction.js.map +1 -0
  134. package/types/transfer.d.ts +32 -0
  135. package/types/transfer.d.ts.map +1 -0
  136. package/types/transfer.js +3 -0
  137. package/types/transfer.js.map +1 -0
  138. package/types/urlTokenBaseHTTPClient.d.ts +41 -0
  139. package/types/urlTokenBaseHTTPClient.d.ts.map +1 -0
  140. package/types/urlTokenBaseHTTPClient.js +151 -0
  141. package/types/urlTokenBaseHTTPClient.js.map +1 -0
package/account.d.ts ADDED
@@ -0,0 +1,91 @@
1
+ import algosdk, { Account, Algodv2, Kmd, MultisigMetadata, TransactionSigner } from 'algosdk';
2
+ import { MultisigAccount, SigningAccount, TransactionSignerAccount } from './types/account';
3
+ import { AlgoAmount } from './types/amount';
4
+ /**
5
+ * Returns an account wrapper that supports partial or full multisig signing.
6
+ * @param multisigParams The parameters that define the multisig account
7
+ * @param signingAccounts The signers that are currently present
8
+ * @returns A multisig account wrapper
9
+ */
10
+ export declare function multisigAccount(multisigParams: MultisigMetadata, signingAccounts: (Account | SigningAccount)[]): MultisigAccount;
11
+ /**
12
+ * Returns an account wrapper that supports a rekeyed account.
13
+ * @param account The account, with private key loaded, that is signing
14
+ * @param sender The address of the rekeyed account that will act as a sender
15
+ * @returns The @see SigningAccount wrapper
16
+ */
17
+ export declare function rekeyedAccount(account: Account, sender: string): SigningAccount;
18
+ /**
19
+ * Returns an account wrapper that supports a transaction signer with associated sender address.
20
+ * @param signer The transaction signer
21
+ * @param sender The address of sender account
22
+ * @returns The @see SigningAccount wrapper
23
+ */
24
+ export declare function transactionSignerAccount(signer: TransactionSigner, sender: string): TransactionSignerAccount;
25
+ /** Returns an Algorand account with secret key loaded (i.e. that can sign transactions) by taking the mnemonic secret.
26
+ *
27
+ * This is a wrapper around algosdk.mnemonicToSecretKey to provide a more friendly/obvious name.
28
+ *
29
+ * @param mnemonicSecret The mnemonic secret representing the private key of an account; **Note: Be careful how the mnemonic is handled**,
30
+ * never commit it into source control and ideally load it from the environment (ideally via a secret storage service) rather than the file system.
31
+ */
32
+ export declare function mnemonicAccount(mnemonicSecret: string): Account;
33
+ /** Returns a new, random Algorand account with secret key loaded.
34
+ *
35
+ * This is a wrapper around algosdk.generateAccount to provide a more friendly/obvious name.
36
+ *
37
+ */
38
+ export declare function randomAccount(): Account;
39
+ /**
40
+ * Returns an Algorand account with private key loaded by convention based on the given name identifier.
41
+ *
42
+ * Note: This function expects to run in a Node.js environment.
43
+ *
44
+ * ## Convention:
45
+ * * **Non-LocalNet:** will load process.env['\{NAME\}_MNEMONIC'] as a mnemonic secret; **Note: Be careful how the mnemonic is handled**,
46
+ * never commit it into source control and ideally load it via a secret storage service rather than the file system.
47
+ * If process.env['\{NAME\}_SENDER'] is defined then it will use that for the sender address (i.e. to support rekeyed accounts)
48
+ * * **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
49
+ *
50
+ * 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).
51
+ *
52
+ * @example Default
53
+ *
54
+ * 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:
55
+ * ```typescript
56
+ * const account = await getAccount('ACCOUNT', algod)
57
+ * ```
58
+ *
59
+ * 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.
60
+ *
61
+ * @param account The details of the account to get, wither the name identifier (string) or an object with:
62
+ * * `name`: The name identifier of the account
63
+ * * `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}
64
+ * @param algod An algod client
65
+ * @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}
66
+ * @returns The requested account with private key loaded from the environment variables or when targeting LocalNet from KMD (idempotently creating and funding the account)
67
+ */
68
+ export declare function getAccount(account: {
69
+ name: string;
70
+ fundWith?: AlgoAmount;
71
+ } | string, algod: Algodv2, kmdClient?: Kmd): Promise<Account | SigningAccount>;
72
+ /** Returns an account's address as a byte array
73
+ *
74
+ * @param account Either an account (with private key loaded) or the string address of an account
75
+ */
76
+ export declare function getAccountAddressAsUint8Array(account: Account | string): Uint8Array;
77
+ /** Returns the string address of an Algorand account from a base64 encoded version of the underlying byte array of the address public key
78
+ *
79
+ * @param addressEncodedInB64 The base64 encoded version of the underlying byte array of the address public key
80
+ */
81
+ export declare function getAccountAddressAsString(addressEncodedInB64: string): string;
82
+ /** Returns an account (with private key loaded) that can act as a dispenser
83
+ *
84
+ * If running on Sandbox then it will return the default dispenser account automatically,
85
+ * otherwise it will load the account mnemonic stored in process.env.DISPENSER_MNEMONIC @see {getAccount}
86
+ *
87
+ * @param algod An algod client
88
+ * @param kmd A KMD client, if not specified then a default KMD client will be loaded from environment variables @see {getAlgoKmdClient}
89
+ */
90
+ export declare function getDispenserAccount(algod: Algodv2, kmd?: Kmd): Promise<algosdk.Account | SigningAccount>;
91
+ //# 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,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAI7F,OAAO,EAAqB,eAAe,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAA;AAC9G,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE3C;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,cAAc,EAAE,gBAAgB,EAAE,eAAe,EAAE,CAAC,OAAO,GAAG,cAAc,CAAC,EAAE,mBAE9G;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAE9D;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,GAAG,wBAAwB,CAE5G;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAG/D;AAED;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAGvC;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;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,cAEtE;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,mBAAmB,EAAE,MAAM,GAAG,MAAM,CAE7E;AAED;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,GAAG,6CAIlE"}
package/account.js ADDED
@@ -0,0 +1,158 @@
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.getAccount = exports.randomAccount = exports.mnemonicAccount = exports.transactionSignerAccount = exports.rekeyedAccount = exports.multisigAccount = void 0;
7
+ const algosdk_1 = __importDefault(require("algosdk"));
8
+ const _1 = require("./");
9
+ const localnet_1 = require("./localnet");
10
+ const network_client_1 = require("./network-client");
11
+ const account_1 = require("./types/account");
12
+ /**
13
+ * Returns an account wrapper that supports partial or full multisig signing.
14
+ * @param multisigParams The parameters that define the multisig account
15
+ * @param signingAccounts The signers that are currently present
16
+ * @returns A multisig account wrapper
17
+ */
18
+ function multisigAccount(multisigParams, signingAccounts) {
19
+ return new account_1.MultisigAccount(multisigParams, signingAccounts);
20
+ }
21
+ exports.multisigAccount = multisigAccount;
22
+ /**
23
+ * Returns an account wrapper that supports a rekeyed account.
24
+ * @param account The account, with private key loaded, that is signing
25
+ * @param sender The address of the rekeyed account that will act as a sender
26
+ * @returns The @see SigningAccount wrapper
27
+ */
28
+ function rekeyedAccount(account, sender) {
29
+ return new account_1.SigningAccount(account, sender);
30
+ }
31
+ exports.rekeyedAccount = rekeyedAccount;
32
+ /**
33
+ * Returns an account wrapper that supports a transaction signer with associated sender address.
34
+ * @param signer The transaction signer
35
+ * @param sender The address of sender account
36
+ * @returns The @see SigningAccount wrapper
37
+ */
38
+ function transactionSignerAccount(signer, sender) {
39
+ return { addr: sender, signer };
40
+ }
41
+ exports.transactionSignerAccount = transactionSignerAccount;
42
+ /** Returns an Algorand account with secret key loaded (i.e. that can sign transactions) by taking the mnemonic secret.
43
+ *
44
+ * This is a wrapper around algosdk.mnemonicToSecretKey to provide a more friendly/obvious name.
45
+ *
46
+ * @param mnemonicSecret The mnemonic secret representing the private key of an account; **Note: Be careful how the mnemonic is handled**,
47
+ * never commit it into source control and ideally load it from the environment (ideally via a secret storage service) rather than the file system.
48
+ */
49
+ function mnemonicAccount(mnemonicSecret) {
50
+ // This method is confusingly named, so this function provides a more dev friendly "wrapper" name
51
+ return algosdk_1.default.mnemonicToSecretKey(mnemonicSecret);
52
+ }
53
+ exports.mnemonicAccount = mnemonicAccount;
54
+ /** Returns a new, random Algorand account with secret key loaded.
55
+ *
56
+ * This is a wrapper around algosdk.generateAccount to provide a more friendly/obvious name.
57
+ *
58
+ */
59
+ function randomAccount() {
60
+ // This method is confusingly named, so this function provides a more dev friendly "wrapper" name
61
+ return algosdk_1.default.generateAccount();
62
+ }
63
+ exports.randomAccount = randomAccount;
64
+ /**
65
+ * Returns an Algorand account with private key loaded by convention based on the given name identifier.
66
+ *
67
+ * Note: This function expects to run in a Node.js environment.
68
+ *
69
+ * ## Convention:
70
+ * * **Non-LocalNet:** will load process.env['\{NAME\}_MNEMONIC'] as a mnemonic secret; **Note: Be careful how the mnemonic is handled**,
71
+ * never commit it into source control and ideally load it via a secret storage service rather than the file system.
72
+ * If process.env['\{NAME\}_SENDER'] is defined then it will use that for the sender address (i.e. to support rekeyed accounts)
73
+ * * **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
74
+ *
75
+ * 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).
76
+ *
77
+ * @example Default
78
+ *
79
+ * 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:
80
+ * ```typescript
81
+ * const account = await getAccount('ACCOUNT', algod)
82
+ * ```
83
+ *
84
+ * 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.
85
+ *
86
+ * @param account The details of the account to get, wither the name identifier (string) or an object with:
87
+ * * `name`: The name identifier of the account
88
+ * * `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}
89
+ * @param algod An algod client
90
+ * @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}
91
+ * @returns The requested account with private key loaded from the environment variables or when targeting LocalNet from KMD (idempotently creating and funding the account)
92
+ */
93
+ async function getAccount(account, algod, kmdClient) {
94
+ let name;
95
+ let fundWith = undefined;
96
+ if (typeof account === 'string') {
97
+ name = account;
98
+ }
99
+ else {
100
+ name = account.name;
101
+ fundWith = account.fundWith;
102
+ }
103
+ if (!process || !process.env) {
104
+ throw new Error('Attempt to get account with private key from a non Node.js context; not supported!');
105
+ }
106
+ const envKey = `${name.toUpperCase()}_MNEMONIC`;
107
+ if (process.env[envKey]) {
108
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
109
+ const signer = mnemonicAccount(process.env[envKey]);
110
+ const senderKey = `${name.toUpperCase()}_SENDER`;
111
+ if (process.env[senderKey]) {
112
+ _1.Config.logger.debug(`Using rekeyed account ${signer.addr} for sender ${process.env[senderKey]} for ${name} account`);
113
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
114
+ return new account_1.SigningAccount(signer, process.env[senderKey]);
115
+ }
116
+ else {
117
+ return signer;
118
+ }
119
+ }
120
+ if (await (0, network_client_1.isLocalNet)(algod)) {
121
+ const account = await (0, localnet_1.getOrCreateKmdWalletAccount)({ name, fundWith }, algod, kmdClient);
122
+ process.env[envKey] = algosdk_1.default.secretKeyToMnemonic(account.sk);
123
+ return account;
124
+ }
125
+ throw `Missing environment variable ${envKey} when looking for account ${name}`;
126
+ }
127
+ exports.getAccount = getAccount;
128
+ /** Returns an account's address as a byte array
129
+ *
130
+ * @param account Either an account (with private key loaded) or the string address of an account
131
+ */
132
+ function getAccountAddressAsUint8Array(account) {
133
+ return algosdk_1.default.decodeAddress(typeof account === 'string' ? account : account.addr).publicKey;
134
+ }
135
+ exports.getAccountAddressAsUint8Array = getAccountAddressAsUint8Array;
136
+ /** Returns the string address of an Algorand account from a base64 encoded version of the underlying byte array of the address public key
137
+ *
138
+ * @param addressEncodedInB64 The base64 encoded version of the underlying byte array of the address public key
139
+ */
140
+ function getAccountAddressAsString(addressEncodedInB64) {
141
+ return algosdk_1.default.encodeAddress(Buffer.from(addressEncodedInB64, 'base64'));
142
+ }
143
+ exports.getAccountAddressAsString = getAccountAddressAsString;
144
+ /** Returns an account (with private key loaded) that can act as a dispenser
145
+ *
146
+ * If running on Sandbox then it will return the default dispenser account automatically,
147
+ * otherwise it will load the account mnemonic stored in process.env.DISPENSER_MNEMONIC @see {getAccount}
148
+ *
149
+ * @param algod An algod client
150
+ * @param kmd A KMD client, if not specified then a default KMD client will be loaded from environment variables @see {getAlgoKmdClient}
151
+ */
152
+ async function getDispenserAccount(algod, kmd) {
153
+ // 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
154
+ const canFundFromDefaultAccount = await (0, network_client_1.isLocalNet)(algod);
155
+ return canFundFromDefaultAccount ? await (0, localnet_1.getLocalNetDispenserAccount)(algod, kmd) : await getAccount(account_1.DISPENSER_ACCOUNT, algod);
156
+ }
157
+ exports.getDispenserAccount = getDispenserAccount;
158
+ //# 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,sDAA6F;AAC7F,yBAA2B;AAC3B,yCAAqF;AACrF,qDAA6C;AAC7C,6CAA8G;AAG9G;;;;;GAKG;AACH,SAAgB,eAAe,CAAC,cAAgC,EAAE,eAA6C;IAC7G,OAAO,IAAI,yBAAe,CAAC,cAAc,EAAE,eAAe,CAAC,CAAA;AAC7D,CAAC;AAFD,0CAEC;AAED;;;;;GAKG;AACH,SAAgB,cAAc,CAAC,OAAgB,EAAE,MAAc;IAC7D,OAAO,IAAI,wBAAc,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;AAC5C,CAAC;AAFD,wCAEC;AAED;;;;;GAKG;AACH,SAAgB,wBAAwB,CAAC,MAAyB,EAAE,MAAc;IAChF,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAA;AACjC,CAAC;AAFD,4DAEC;AAED;;;;;;GAMG;AACH,SAAgB,eAAe,CAAC,cAAsB;IACpD,iGAAiG;IACjG,OAAO,iBAAO,CAAC,mBAAmB,CAAC,cAAc,CAAC,CAAA;AACpD,CAAC;AAHD,0CAGC;AAED;;;;GAIG;AACH,SAAgB,aAAa;IAC3B,iGAAiG;IACjG,OAAO,iBAAO,CAAC,eAAe,EAAE,CAAA;AAClC,CAAC;AAHD,sCAGC;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,CA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6BAA6B,CAAC,OAAyB;IACrE,OAAO,iBAAO,CAAC,aAAa,CAAC,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,SAAS,CAAA;AAC9F,CAAC;AAFD,sEAEC;AAED;;;GAGG;AACH,SAAgB,yBAAyB,CAAC,mBAA2B;IACnE,OAAO,iBAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,mBAAmB,EAAE,QAAQ,CAAC,CAAC,CAAA;AAC1E,CAAC;AAFD,8DAEC;AAED;;;;;;;GAOG;AACI,KAAK,UAAU,mBAAmB,CAAC,KAAc,EAAE,GAAS;IACjE,6LAA6L;IAC7L,MAAM,yBAAyB,GAAG,MAAM,IAAA,2BAAU,EAAC,KAAK,CAAC,CAAA;IACzD,OAAO,yBAAyB,CAAC,CAAC,CAAC,MAAM,IAAA,sCAA2B,EAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,UAAU,CAAC,2BAAiB,EAAE,KAAK,CAAC,CAAA;AAC/H,CAAC;AAJD,kDAIC"}
package/amount.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { AlgoAmount } from './types/amount';
2
+ /** Returns an amount of Algos using @see AlgoAmount */
3
+ export declare const algos: (algos: number) => AlgoAmount;
4
+ /** Returns an amount of µAlgos using @see AlgoAmount */
5
+ export declare const microAlgos: (microAlgos: number) => AlgoAmount;
6
+ /** Returns an amount of µAlgos to cover standard fees for the given number of transactions using @see AlgoAmount */
7
+ export declare const transactionFees: (numberOfTransactions: number) => AlgoAmount;
8
+ //# sourceMappingURL=amount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"amount.d.ts","sourceRoot":"","sources":["../src/amount.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE3C,uDAAuD;AACvD,eAAO,MAAM,KAAK,UAAW,MAAM,eAElC,CAAA;AAED,wDAAwD;AACxD,eAAO,MAAM,UAAU,eAAgB,MAAM,eAE5C,CAAA;AAED,oHAAoH;AACpH,eAAO,MAAM,eAAe,yBAA0B,MAAM,eAE3D,CAAA"}
package/amount.js ADDED
@@ -0,0 +1,24 @@
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.transactionFees = exports.microAlgos = exports.algos = void 0;
7
+ const algosdk_1 = __importDefault(require("algosdk"));
8
+ const amount_1 = require("./types/amount");
9
+ /** Returns an amount of Algos using @see AlgoAmount */
10
+ const algos = (algos) => {
11
+ return amount_1.AlgoAmount.Algos(algos);
12
+ };
13
+ exports.algos = algos;
14
+ /** Returns an amount of µAlgos using @see AlgoAmount */
15
+ const microAlgos = (microAlgos) => {
16
+ return amount_1.AlgoAmount.MicroAlgos(microAlgos);
17
+ };
18
+ exports.microAlgos = microAlgos;
19
+ /** Returns an amount of µAlgos to cover standard fees for the given number of transactions using @see AlgoAmount */
20
+ const transactionFees = (numberOfTransactions) => {
21
+ return amount_1.AlgoAmount.MicroAlgos(numberOfTransactions * algosdk_1.default.ALGORAND_MIN_TX_FEE);
22
+ };
23
+ exports.transactionFees = transactionFees;
24
+ //# sourceMappingURL=amount.js.map
package/amount.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"amount.js","sourceRoot":"","sources":["../src/amount.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA6B;AAC7B,2CAA2C;AAE3C,uDAAuD;AAChD,MAAM,KAAK,GAAG,CAAC,KAAa,EAAE,EAAE;IACrC,OAAO,mBAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;AAChC,CAAC,CAAA;AAFY,QAAA,KAAK,SAEjB;AAED,wDAAwD;AACjD,MAAM,UAAU,GAAG,CAAC,UAAkB,EAAE,EAAE;IAC/C,OAAO,mBAAU,CAAC,UAAU,CAAC,UAAU,CAAC,CAAA;AAC1C,CAAC,CAAA;AAFY,QAAA,UAAU,cAEtB;AAED,oHAAoH;AAC7G,MAAM,eAAe,GAAG,CAAC,oBAA4B,EAAE,EAAE;IAC9D,OAAO,mBAAU,CAAC,UAAU,CAAC,oBAAoB,GAAG,iBAAO,CAAC,mBAAmB,CAAC,CAAA;AAClF,CAAC,CAAA;AAFY,QAAA,eAAe,mBAE3B"}
package/app.d.ts ADDED
@@ -0,0 +1,108 @@
1
+ import algosdk, { ABIValue, Algodv2 } from 'algosdk';
2
+ import { ApplicationResponse, EvalDelta, PendingTransactionResponse, TealValue } from './types/algod';
3
+ import { ABIReturn, AppCallArgs, AppCallParams, AppCallTransactionResult, AppCompilationResult, AppReference, AppState, BoxName, BoxValueRequestParams, BoxValuesRequestParams, CompiledTeal, CreateAppParams, UpdateAppParams } from './types/app';
4
+ import { SendTransactionFrom } from './types/transaction';
5
+ /**
6
+ * Creates a smart contract app, returns the details of the created app.
7
+ * @param create The parameters to create the app with
8
+ * @param algod An algod client
9
+ * @returns The details of the created app, or the transaction to create it if `skipSending`
10
+ */
11
+ export declare function createApp(create: CreateAppParams, algod: Algodv2): Promise<Partial<AppCompilationResult> & AppCallTransactionResult & AppReference>;
12
+ /**
13
+ * Updates a smart contract app.
14
+ * @param update The parameters to update the app with
15
+ * @param algod An algod client
16
+ * @returns The transaction
17
+ */
18
+ export declare function updateApp(update: UpdateAppParams, algod: Algodv2): Promise<Partial<AppCompilationResult> & AppCallTransactionResult>;
19
+ /**
20
+ * Issues a call to a given app.
21
+ * @param call The call details.
22
+ * @param algod An algod client
23
+ * @returns The result of the call
24
+ */
25
+ export declare function callApp(call: AppCallParams, algod: Algodv2): Promise<AppCallTransactionResult>;
26
+ export declare function getABIReturn(args?: AppCallArgs, confirmation?: PendingTransactionResponse): ABIReturn | undefined;
27
+ /**
28
+ * Returns the current global state values for the given app ID
29
+ * @param appId The ID of the app return global state for
30
+ * @param algod An algod client instance
31
+ * @returns The current global state
32
+ */
33
+ export declare function getAppGlobalState(appId: number, algod: Algodv2): Promise<AppState>;
34
+ /**
35
+ * Returns the current global state values for the given app ID and account
36
+ * @param appId The ID of the app return global state for
37
+ * @param account Either the string address of an account or an account object for the account to get local state for the given app
38
+ * @param algod An algod client instance
39
+ * @returns The current local state for the given (app, account) combination
40
+ */
41
+ export declare function getAppLocalState(appId: number, account: string | SendTransactionFrom, algod: Algodv2): Promise<AppState>;
42
+ /**
43
+ * Returns the names of the boxes for the given app.
44
+ * @param appId The ID of the app return box names for
45
+ * @param algod An algod client instance
46
+ * @returns The current box names
47
+ */
48
+ export declare function getAppBoxNames(appId: number, algod: Algodv2): Promise<BoxName[]>;
49
+ /**
50
+ * Returns the value of the given box name for the given app.
51
+ * @param appId The ID of the app return box names for
52
+ * @param boxName The name of the box to return either as a string, binary array or @see BoxName
53
+ * @param algod An algod client instance
54
+ * @returns The current box value as a byte array
55
+ */
56
+ export declare function getAppBoxValue(appId: number, boxName: string | Uint8Array | BoxName, algod: Algodv2): Promise<Uint8Array>;
57
+ /**
58
+ * Returns the value of the given box names for the given app.
59
+ * @param appId The ID of the app return box names for
60
+ * @param boxNames The names of the boxes to return either as a string, binary array or @see BoxName
61
+ * @param algod An algod client instance
62
+ * @returns The current box values as a byte array in the same order as the passed in box names
63
+ */
64
+ export declare function getAppBoxValues(appId: number, boxNames: (string | Uint8Array | BoxName)[], algod: Algodv2): Promise<Uint8Array[]>;
65
+ /**
66
+ * Returns the value of the given box name for the given app decoded based on the given ABI type.
67
+ * @param request The parameters for the box value request
68
+ * @param algod An algod client instance
69
+ * @returns The current box value as an ABI value
70
+ */
71
+ export declare function getAppBoxValueFromABIType(request: BoxValueRequestParams, algod: Algodv2): Promise<ABIValue>;
72
+ /**
73
+ * Returns the value of the given box names for the given app decoded based on the given ABI type.
74
+ * @param request The parameters for the box value request
75
+ * @param algod An algod client instance
76
+ * @returns The current box values as an ABI value in the same order as the passed in box names
77
+ */
78
+ export declare function getAppBoxValuesFromABIType(request: BoxValuesRequestParams, algod: Algodv2): Promise<ABIValue[]>;
79
+ export declare function decodeAppState(state: {
80
+ key: string;
81
+ value: TealValue | EvalDelta;
82
+ }[]): AppState;
83
+ /** Returns the app args ready to load onto an app @see {Transaction} object */
84
+ export declare function getAppArgsForTransaction(args?: AppCallArgs): {
85
+ accounts: string[] | undefined;
86
+ appArgs: Uint8Array[] | undefined;
87
+ boxes: algosdk.BoxReference[] | undefined;
88
+ foreignApps: number[] | undefined;
89
+ foreignAssets: number[] | undefined;
90
+ lease: Uint8Array | undefined;
91
+ } | undefined;
92
+ /**
93
+ * Gets the current data for the given app from algod.
94
+ *
95
+ * @param appId The id of the app
96
+ * @param algod An algod client
97
+ * @returns The data about the app
98
+ */
99
+ export declare function getAppByIndex(appId: number, algod: Algodv2): Promise<ApplicationResponse>;
100
+ /**
101
+ * Compiles the given TEAL using algod and returns the result.
102
+ *
103
+ * @param algod An algod client
104
+ * @param tealCode The TEAL code
105
+ * @returns The information about the compiled file
106
+ */
107
+ export declare function compileTeal(tealCode: string, algod: Algodv2): Promise<CompiledTeal>;
108
+ //# 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,EAEd,QAAQ,EACR,OAAO,EAMR,MAAM,SAAS,CAAA;AAIhB,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,0BAA0B,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACrG,OAAO,EACL,SAAS,EAET,WAAW,EACX,aAAa,EACb,wBAAwB,EACxB,oBAAoB,EACpB,YAAY,EACZ,QAAQ,EAER,OAAO,EACP,qBAAqB,EACrB,sBAAsB,EACtB,YAAY,EACZ,eAAe,EACf,eAAe,EAChB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAEzD;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