@algorandfoundation/algokit-utils 0.1.0 → 1.0.0-beta.10

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 (137) hide show
  1. package/account.d.ts +85 -0
  2. package/account.d.ts.map +1 -0
  3. package/account.js +148 -0
  4. package/account.js.map +1 -0
  5. package/amount.d.ts +6 -0
  6. package/amount.d.ts.map +1 -0
  7. package/amount.js +15 -0
  8. package/amount.js.map +1 -0
  9. package/app.d.ts +51 -0
  10. package/app.d.ts.map +1 -0
  11. package/app.js +265 -0
  12. package/app.js.map +1 -0
  13. package/application-client.d.ts +11 -0
  14. package/application-client.d.ts.map +1 -0
  15. package/application-client.js +16 -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 +407 -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 +31 -0
  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 +15 -14
  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 +83 -0
  71. package/transaction.d.ts.map +1 -0
  72. package/transaction.js +240 -0
  73. package/transaction.js.map +1 -0
  74. package/transfer.d.ts +11 -0
  75. package/transfer.d.ts.map +1 -0
  76. package/transfer.js +33 -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 +123 -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 +18 -0
  91. package/types/amount.d.ts.map +1 -0
  92. package/types/amount.js +31 -0
  93. package/types/amount.js.map +1 -0
  94. package/types/app.d.ts +222 -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 +120 -0
  99. package/types/application-client.d.ts.map +1 -0
  100. package/types/application-client.js +266 -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/network-client.d.ts +11 -0
  119. package/types/network-client.d.ts.map +1 -0
  120. package/types/network-client.js +3 -0
  121. package/types/network-client.js.map +1 -0
  122. package/types/testing.d.ts +89 -0
  123. package/types/testing.d.ts.map +1 -0
  124. package/types/testing.js +3 -0
  125. package/types/testing.js.map +1 -0
  126. package/types/transaction.d.ts +51 -0
  127. package/types/transaction.d.ts.map +1 -0
  128. package/types/transaction.js +3 -0
  129. package/types/transaction.js.map +1 -0
  130. package/types/transfer.d.ts +16 -0
  131. package/types/transfer.d.ts.map +1 -0
  132. package/types/transfer.js +3 -0
  133. package/types/transfer.js.map +1 -0
  134. package/types/urlTokenBaseHTTPClient.d.ts +41 -0
  135. package/types/urlTokenBaseHTTPClient.d.ts.map +1 -0
  136. package/types/urlTokenBaseHTTPClient.js +151 -0
  137. package/types/urlTokenBaseHTTPClient.js.map +1 -0
package/account.d.ts ADDED
@@ -0,0 +1,85 @@
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
+ /**
34
+ * Returns an Algorand account with private key loaded by convention based on the given name identifier.
35
+ *
36
+ * Note: This function expects to run in a Node.js environment.
37
+ *
38
+ * ## Convention:
39
+ * * **Non-LocalNet:** will load process.env['\{NAME\}_MNEMONIC'] as a mnemonic secret; **Note: Be careful how the mnemonic is handled**,
40
+ * never commit it into source control and ideally load it via a secret storage service rather than the file system.
41
+ * If process.env['\{NAME\}_SENDER'] is defined then it will use that for the sender address (i.e. to support rekeyed accounts)
42
+ * * **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
43
+ *
44
+ * 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).
45
+ *
46
+ * @example Default
47
+ *
48
+ * 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:
49
+ * ```typescript
50
+ * const account = await getAccount('ACCOUNT', algod)
51
+ * ```
52
+ *
53
+ * 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.
54
+ *
55
+ * @param account The details of the account to get, wither the name identifier (string) or an object with:
56
+ * * `name`: The name identifier of the account
57
+ * * `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}
58
+ * @param algod An algod client
59
+ * @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}
60
+ * @returns The requested account with private key loaded from the environment variables or when targeting LocalNet from KMD (idempotently creating and funding the account)
61
+ */
62
+ export declare function getAccount(account: {
63
+ name: string;
64
+ fundWith?: AlgoAmount;
65
+ } | string, algod: Algodv2, kmdClient?: Kmd): Promise<Account | SigningAccount>;
66
+ /** Returns an account's address as a byte array
67
+ *
68
+ * @param account Either an account (with private key loaded) or the string address of an account
69
+ */
70
+ export declare function getAccountAddressAsUint8Array(account: Account | string): Uint8Array;
71
+ /** Returns the string address of an Algorand account from a base64 encoded version of the underlying byte array of the address public key
72
+ *
73
+ * @param addressEncodedInB64 The base64 encoded version of the underlying byte array of the address public key
74
+ */
75
+ export declare function getAccountAddressAsString(addressEncodedInB64: string): string;
76
+ /** Returns an account (with private key loaded) that can act as a dispenser
77
+ *
78
+ * If running on Sandbox then it will return the default dispenser account automatically,
79
+ * otherwise it will load the account mnemonic stored in process.env.DISPENSER_MNEMONIC @see {getAccount}
80
+ *
81
+ * @param algod An algod client
82
+ * @param kmd A KMD client, if not specified then a default KMD client will be loaded from environment variables @see {getAlgoKmdClient}
83
+ */
84
+ export declare function getDispenserAccount(algod: Algodv2, kmd?: Kmd): Promise<algosdk.Account | SigningAccount>;
85
+ //# 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,148 @@
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.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
+ /**
55
+ * Returns an Algorand account with private key loaded by convention based on the given name identifier.
56
+ *
57
+ * Note: This function expects to run in a Node.js environment.
58
+ *
59
+ * ## Convention:
60
+ * * **Non-LocalNet:** will load process.env['\{NAME\}_MNEMONIC'] as a mnemonic secret; **Note: Be careful how the mnemonic is handled**,
61
+ * never commit it into source control and ideally load it via a secret storage service rather than the file system.
62
+ * If process.env['\{NAME\}_SENDER'] is defined then it will use that for the sender address (i.e. to support rekeyed accounts)
63
+ * * **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
64
+ *
65
+ * 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).
66
+ *
67
+ * @example Default
68
+ *
69
+ * 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:
70
+ * ```typescript
71
+ * const account = await getAccount('ACCOUNT', algod)
72
+ * ```
73
+ *
74
+ * 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.
75
+ *
76
+ * @param account The details of the account to get, wither the name identifier (string) or an object with:
77
+ * * `name`: The name identifier of the account
78
+ * * `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}
79
+ * @param algod An algod client
80
+ * @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}
81
+ * @returns The requested account with private key loaded from the environment variables or when targeting LocalNet from KMD (idempotently creating and funding the account)
82
+ */
83
+ async function getAccount(account, algod, kmdClient) {
84
+ let name;
85
+ let fundWith = undefined;
86
+ if (typeof account === 'string') {
87
+ name = account;
88
+ }
89
+ else {
90
+ name = account.name;
91
+ fundWith = account.fundWith;
92
+ }
93
+ if (!process || !process.env) {
94
+ throw new Error('Attempt to get account with private key from a non Node.js context; not supported!');
95
+ }
96
+ const envKey = `${name.toUpperCase()}_MNEMONIC`;
97
+ if (process.env[envKey]) {
98
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
99
+ const signer = mnemonicAccount(process.env[envKey]);
100
+ const senderKey = `${name.toUpperCase()}_SENDER`;
101
+ if (process.env[senderKey]) {
102
+ _1.Config.logger.debug(`Using rekeyed account ${signer.addr} for sender ${process.env[senderKey]} for ${name} account`);
103
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
104
+ return new account_1.SigningAccount(signer, process.env[senderKey]);
105
+ }
106
+ else {
107
+ return signer;
108
+ }
109
+ }
110
+ if (await (0, network_client_1.isLocalNet)(algod)) {
111
+ const account = await (0, localnet_1.getOrCreateKmdWalletAccount)({ name, fundWith }, algod, kmdClient);
112
+ process.env[envKey] = algosdk_1.default.secretKeyToMnemonic(account.sk);
113
+ return account;
114
+ }
115
+ throw `Missing environment variable ${envKey} when looking for account ${name}`;
116
+ }
117
+ exports.getAccount = getAccount;
118
+ /** Returns an account's address as a byte array
119
+ *
120
+ * @param account Either an account (with private key loaded) or the string address of an account
121
+ */
122
+ function getAccountAddressAsUint8Array(account) {
123
+ return algosdk_1.default.decodeAddress(typeof account === 'string' ? account : account.addr).publicKey;
124
+ }
125
+ exports.getAccountAddressAsUint8Array = getAccountAddressAsUint8Array;
126
+ /** Returns the string address of an Algorand account from a base64 encoded version of the underlying byte array of the address public key
127
+ *
128
+ * @param addressEncodedInB64 The base64 encoded version of the underlying byte array of the address public key
129
+ */
130
+ function getAccountAddressAsString(addressEncodedInB64) {
131
+ return algosdk_1.default.encodeAddress(Buffer.from(addressEncodedInB64, 'base64'));
132
+ }
133
+ exports.getAccountAddressAsString = getAccountAddressAsString;
134
+ /** Returns an account (with private key loaded) that can act as a dispenser
135
+ *
136
+ * If running on Sandbox then it will return the default dispenser account automatically,
137
+ * otherwise it will load the account mnemonic stored in process.env.DISPENSER_MNEMONIC @see {getAccount}
138
+ *
139
+ * @param algod An algod client
140
+ * @param kmd A KMD client, if not specified then a default KMD client will be loaded from environment variables @see {getAlgoKmdClient}
141
+ */
142
+ async function getDispenserAccount(algod, kmd) {
143
+ // 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
144
+ const canFundFromDefaultAccount = await (0, network_client_1.isLocalNet)(algod);
145
+ return canFundFromDefaultAccount ? await (0, localnet_1.getLocalNetDispenserAccount)(algod, kmd) : await getAccount(account_1.DISPENSER_ACCOUNT, algod);
146
+ }
147
+ exports.getDispenserAccount = getDispenserAccount;
148
+ //# 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,MA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AAC,CAAC,MAAM,UAAU,CAAC,2BAAiB,EAAE,KAAK,CAAC,CAAA;AAC/H,CAAC;AAJD,kDAIC"}
package/amount.d.ts ADDED
@@ -0,0 +1,6 @@
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
+ //# sourceMappingURL=amount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"amount.d.ts","sourceRoot":"","sources":["../src/amount.ts"],"names":[],"mappings":"AAAA,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"}
package/amount.js ADDED
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.microAlgos = exports.algos = void 0;
4
+ const amount_1 = require("./types/amount");
5
+ /** Returns an amount of Algos using @see AlgoAmount */
6
+ const algos = (algos) => {
7
+ return amount_1.AlgoAmount.Algos(algos);
8
+ };
9
+ exports.algos = algos;
10
+ /** Returns an amount of µAlgos using @see AlgoAmount */
11
+ const microAlgos = (microAlgos) => {
12
+ return amount_1.AlgoAmount.MicroAlgos(microAlgos);
13
+ };
14
+ exports.microAlgos = microAlgos;
15
+ //# 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,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"}
package/app.d.ts ADDED
@@ -0,0 +1,51 @@
1
+ import algosdk, { Algodv2 } from 'algosdk';
2
+ import { ApplicationResponse, PendingTransactionResponse } from './types/algod';
3
+ import { ABIReturn, AppCallArgs, AppCallParams, AppCallTransactionResult, AppReference, CompiledTeal, CreateAppParams, UpdateAppParams } from './types/app';
4
+ /**
5
+ * Creates a smart contract app, returns the details of the created app.
6
+ * @param create The parameters to create the app with
7
+ * @param algod An algod client
8
+ * @returns The details of the created app, or the transaction to create it if `skipSending`
9
+ */
10
+ export declare function createApp(create: CreateAppParams, algod: Algodv2): Promise<AppCallTransactionResult & AppReference>;
11
+ /**
12
+ * Updates a smart contract app.
13
+ * @param update The parameters to update the app with
14
+ * @param algod An algod client
15
+ * @returns The transaction
16
+ */
17
+ export declare function updateApp(update: UpdateAppParams, algod: Algodv2): Promise<AppCallTransactionResult>;
18
+ /**
19
+ * Issues a call to a given app.
20
+ * @param call The call details.
21
+ * @param algod An algod client
22
+ * @returns The result of the call
23
+ */
24
+ export declare function callApp(call: AppCallParams, algod: Algodv2): Promise<AppCallTransactionResult>;
25
+ export declare function getABIReturn(args?: AppCallArgs, confirmation?: PendingTransactionResponse): ABIReturn | undefined;
26
+ /** Returns the app args ready to load onto an app @see {Transaction} object */
27
+ export declare function getAppArgsForTransaction(args?: AppCallArgs): {
28
+ accounts: string[] | undefined;
29
+ appArgs: Uint8Array[] | undefined;
30
+ boxes: algosdk.BoxReference[] | undefined;
31
+ foreignApps: number[] | undefined;
32
+ foreignAssets: number[] | undefined;
33
+ lease: Uint8Array | undefined;
34
+ } | undefined;
35
+ /**
36
+ * Gets the current data for the given app from algod.
37
+ *
38
+ * @param appId The id of the app
39
+ * @param algod An algod client
40
+ * @returns The data about the app
41
+ */
42
+ export declare function getAppByIndex(appId: number, algod: Algodv2): Promise<ApplicationResponse>;
43
+ /**
44
+ * Compiles the given TEAL using algod and returns the result.
45
+ *
46
+ * @param algod An algod client
47
+ * @param tealCode The TEAL code
48
+ * @returns The information about the compiled file
49
+ */
50
+ export declare function compileTeal(tealCode: string, algod: Algodv2): Promise<CompiledTeal>;
51
+ //# 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,OAAO,EAKR,MAAM,SAAS,CAAA;AAIhB,OAAO,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAA;AAC/E,OAAO,EACL,SAAS,EAET,WAAW,EACX,aAAa,EACb,wBAAwB,EACxB,YAAY,EAEZ,YAAY,EACZ,eAAe,EACf,eAAe,EAChB,MAAM,aAAa,CAAA;AAEpB;;;;;GAKG;AACH,wBAAsB,SAAS,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,wBAAwB,GAAG,YAAY,CAAC,CAuCzH;AAED;;;;;GAKG;AACH,wBAAsB,SAAS,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAyB1G;AAED;;;;;GAKG;AACH,wBAAsB,OAAO,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAqCpG;AAED,wBAAgB,YAAY,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,YAAY,CAAC,EAAE,0BAA0B,GAAG,SAAS,GAAG,SAAS,CA6BjH;AAED,+EAA+E;AAC/E,wBAAgB,wBAAwB,CAAC,IAAI,CAAC,EAAE,WAAW;;;;;;;cA6D1D;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,gCAEhE;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC,CAQzF"}
package/app.js ADDED
@@ -0,0 +1,265 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.compileTeal = exports.getAppByIndex = exports.getAppArgsForTransaction = exports.getABIReturn = exports.callApp = exports.updateApp = exports.createApp = void 0;
27
+ const algosdk_1 = __importStar(require("algosdk"));
28
+ const buffer_1 = require("buffer");
29
+ const _1 = require("./");
30
+ const transaction_1 = require("./transaction");
31
+ const app_1 = require("./types/app");
32
+ /**
33
+ * Creates a smart contract app, returns the details of the created app.
34
+ * @param create The parameters to create the app with
35
+ * @param algod An algod client
36
+ * @returns The details of the created app, or the transaction to create it if `skipSending`
37
+ */
38
+ async function createApp(create, algod) {
39
+ const { from, approvalProgram: approval, clearStateProgram: clear, schema, note, transactionParams, args, ...sendParams } = create;
40
+ const approvalProgram = typeof approval === 'string' ? (await compileTeal(approval, algod)).compiledBase64ToBytes : approval;
41
+ const clearProgram = typeof clear === 'string' ? (await compileTeal(clear, algod)).compiledBase64ToBytes : clear;
42
+ const transaction = algosdk_1.default.makeApplicationCreateTxnFromObject({
43
+ approvalProgram: approvalProgram,
44
+ clearProgram: clearProgram,
45
+ numLocalInts: schema.localInts,
46
+ numLocalByteSlices: schema.localByteSlices,
47
+ numGlobalInts: schema.globalInts,
48
+ numGlobalByteSlices: schema.globalByteSlices,
49
+ extraPages: schema.extraPages ?? Math.floor((approvalProgram.length + clearProgram.length) / app_1.APP_PAGE_MAX_SIZE),
50
+ onComplete: algosdk_1.default.OnApplicationComplete.NoOpOC,
51
+ suggestedParams: await (0, transaction_1.getTransactionParams)(transactionParams, algod),
52
+ from: (0, transaction_1.getSenderAddress)(from),
53
+ note: (0, transaction_1.encodeTransactionNote)(note),
54
+ ...getAppArgsForTransaction(args),
55
+ rekeyTo: undefined,
56
+ });
57
+ const { confirmation } = await (0, transaction_1.sendTransaction)({ transaction, from, sendParams }, algod);
58
+ if (confirmation) {
59
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
60
+ const appId = confirmation['application-index'];
61
+ _1.Config.getLogger(sendParams.suppressLog).debug(`Created app ${appId} from creator ${(0, transaction_1.getSenderAddress)(from)}`);
62
+ return {
63
+ transaction,
64
+ confirmation,
65
+ appId,
66
+ appAddress: algosdk_1.default.getApplicationAddress(appId),
67
+ return: getABIReturn(args, confirmation),
68
+ };
69
+ }
70
+ else {
71
+ return { transaction, appId: 0, appAddress: '' };
72
+ }
73
+ }
74
+ exports.createApp = createApp;
75
+ /**
76
+ * Updates a smart contract app.
77
+ * @param update The parameters to update the app with
78
+ * @param algod An algod client
79
+ * @returns The transaction
80
+ */
81
+ async function updateApp(update, algod) {
82
+ const { appId, from, approvalProgram: approval, clearStateProgram: clear, note, transactionParams, args, ...sendParams } = update;
83
+ const approvalProgram = typeof approval === 'string' ? (await compileTeal(approval, algod)).compiledBase64ToBytes : approval;
84
+ const clearProgram = typeof clear === 'string' ? (await compileTeal(clear, algod)).compiledBase64ToBytes : clear;
85
+ const transaction = algosdk_1.default.makeApplicationUpdateTxnFromObject({
86
+ appIndex: appId,
87
+ approvalProgram: approvalProgram,
88
+ clearProgram: clearProgram,
89
+ suggestedParams: await (0, transaction_1.getTransactionParams)(transactionParams, algod),
90
+ from: (0, transaction_1.getSenderAddress)(from),
91
+ note: (0, transaction_1.encodeTransactionNote)(note),
92
+ ...getAppArgsForTransaction(args),
93
+ rekeyTo: undefined,
94
+ });
95
+ _1.Config.getLogger(sendParams.suppressLog).debug(`Updating app ${appId}`);
96
+ const result = await (0, transaction_1.sendTransaction)({ transaction, from, sendParams }, algod);
97
+ return {
98
+ ...result,
99
+ return: getABIReturn(args, result.confirmation),
100
+ };
101
+ }
102
+ exports.updateApp = updateApp;
103
+ /**
104
+ * Issues a call to a given app.
105
+ * @param call The call details.
106
+ * @param algod An algod client
107
+ * @returns The result of the call
108
+ */
109
+ async function callApp(call, algod) {
110
+ const { appId, callType, from, args, note, transactionParams, ...sendParams } = call;
111
+ const appCallParameters = {
112
+ appIndex: appId,
113
+ from: (0, transaction_1.getSenderAddress)(from),
114
+ suggestedParams: await (0, transaction_1.getTransactionParams)(transactionParams, algod),
115
+ ...getAppArgsForTransaction(args),
116
+ note: (0, transaction_1.encodeTransactionNote)(note),
117
+ rekeyTo: undefined,
118
+ };
119
+ let transaction;
120
+ switch (callType) {
121
+ case 'optin':
122
+ transaction = algosdk_1.default.makeApplicationOptInTxnFromObject(appCallParameters);
123
+ break;
124
+ case 'clearstate':
125
+ transaction = algosdk_1.default.makeApplicationClearStateTxnFromObject(appCallParameters);
126
+ break;
127
+ case 'closeout':
128
+ transaction = algosdk_1.default.makeApplicationCloseOutTxnFromObject(appCallParameters);
129
+ break;
130
+ case 'delete':
131
+ transaction = algosdk_1.default.makeApplicationDeleteTxnFromObject(appCallParameters);
132
+ break;
133
+ case 'normal':
134
+ transaction = algosdk_1.default.makeApplicationNoOpTxnFromObject(appCallParameters);
135
+ break;
136
+ }
137
+ const result = await (0, transaction_1.sendTransaction)({ transaction, from, sendParams }, algod);
138
+ return {
139
+ ...result,
140
+ return: getABIReturn(args, result.confirmation),
141
+ };
142
+ }
143
+ exports.callApp = callApp;
144
+ function getABIReturn(args, confirmation) {
145
+ try {
146
+ if (!args || !('method' in args)) {
147
+ return undefined;
148
+ }
149
+ const method = 'txnCount' in args.method ? args.method : new algosdk_1.ABIMethod(args.method);
150
+ if (method.returns.type !== 'void' && confirmation) {
151
+ const logs = confirmation.logs || [];
152
+ if (logs.length === 0) {
153
+ throw new Error('App call transaction did not log a return value');
154
+ }
155
+ const lastLog = logs[logs.length - 1];
156
+ if (lastLog.byteLength < 4 || lastLog.slice(0, 4).toString() !== app_1.ABI_RETURN_PREFIX.toString()) {
157
+ throw new Error('App call transaction did not log a return value (ABI_RETURN_PREFIX not found)');
158
+ }
159
+ return {
160
+ rawReturnValue: new Uint8Array(lastLog.slice(4)),
161
+ returnValue: method.returns.type.decode(new Uint8Array(lastLog.slice(4))),
162
+ decodeError: undefined,
163
+ };
164
+ }
165
+ }
166
+ catch (e) {
167
+ return {
168
+ rawReturnValue: undefined,
169
+ returnValue: undefined,
170
+ decodeError: e,
171
+ };
172
+ }
173
+ return undefined;
174
+ }
175
+ exports.getABIReturn = getABIReturn;
176
+ /** Returns the app args ready to load onto an app @see {Transaction} object */
177
+ function getAppArgsForTransaction(args) {
178
+ if (!args)
179
+ return undefined;
180
+ let actualArgs;
181
+ if ('method' in args) {
182
+ // todo: Land a change to algosdk that extract the logic from ATC, because (fair warning) this is a HACK
183
+ // I don't want to have to rewrite all of the ABI resolution logic so using an ATC temporarily here
184
+ // and passing stuff in to keep it happy like a randomly generated account :O
185
+ // Most of these values aren't being used since the transaction is discarded
186
+ const dummyAtc = new algosdk_1.AtomicTransactionComposer();
187
+ const dummyAccount = algosdk_1.default.generateAccount();
188
+ const dummyAppId = 1;
189
+ const dummyParams = {
190
+ fee: 1,
191
+ firstRound: 1,
192
+ genesisHash: buffer_1.Buffer.from('abcd', 'utf-8').toString('base64'),
193
+ genesisID: 'a',
194
+ lastRound: 1,
195
+ };
196
+ const dummyOnComplete = algosdk_1.OnApplicationComplete.NoOpOC;
197
+ dummyAtc.addMethodCall({
198
+ method: 'txnCount' in args.method ? args.method : new algosdk_1.ABIMethod(args.method),
199
+ methodArgs: args.args,
200
+ // Rest are dummy values
201
+ appID: dummyAppId,
202
+ sender: dummyAccount.addr,
203
+ signer: (0, algosdk_1.makeBasicAccountTransactionSigner)(dummyAccount),
204
+ suggestedParams: dummyParams,
205
+ onComplete: dummyOnComplete,
206
+ });
207
+ const txn = dummyAtc.buildGroup()[0];
208
+ actualArgs = {
209
+ accounts: txn.txn.appAccounts,
210
+ appArgs: txn.txn.appArgs,
211
+ apps: txn.txn.appForeignApps,
212
+ assets: txn.txn.appForeignAssets,
213
+ boxes: txn.txn.boxes?.map((b) => ({
214
+ appId: b.appIndex,
215
+ name: b.name,
216
+ })),
217
+ lease: args.lease,
218
+ };
219
+ }
220
+ else {
221
+ actualArgs = args;
222
+ }
223
+ const encoder = new TextEncoder();
224
+ return {
225
+ accounts: actualArgs?.accounts?.map((a) => (typeof a === 'string' ? a : algosdk_1.default.encodeAddress(a.publicKey))),
226
+ appArgs: actualArgs?.appArgs?.map((a) => (typeof a === 'string' ? encoder.encode(a) : a)),
227
+ boxes: actualArgs?.boxes?.map((ref) => ({
228
+ appIndex: ref.appId,
229
+ name: typeof ref.name === 'string' ? encoder.encode(ref.name) : ref.name,
230
+ })),
231
+ foreignApps: actualArgs?.apps,
232
+ foreignAssets: actualArgs?.assets,
233
+ lease: typeof actualArgs?.lease === 'string' ? encoder.encode(actualArgs?.lease) : actualArgs?.lease,
234
+ };
235
+ }
236
+ exports.getAppArgsForTransaction = getAppArgsForTransaction;
237
+ /**
238
+ * Gets the current data for the given app from algod.
239
+ *
240
+ * @param appId The id of the app
241
+ * @param algod An algod client
242
+ * @returns The data about the app
243
+ */
244
+ async function getAppByIndex(appId, algod) {
245
+ return (await algod.getApplicationByID(appId).do());
246
+ }
247
+ exports.getAppByIndex = getAppByIndex;
248
+ /**
249
+ * Compiles the given TEAL using algod and returns the result.
250
+ *
251
+ * @param algod An algod client
252
+ * @param tealCode The TEAL code
253
+ * @returns The information about the compiled file
254
+ */
255
+ async function compileTeal(tealCode, algod) {
256
+ const compiled = await algod.compile(tealCode).do();
257
+ return {
258
+ teal: tealCode,
259
+ compiled: compiled.result,
260
+ compiledHash: compiled.hash,
261
+ compiledBase64ToBytes: new Uint8Array(buffer_1.Buffer.from(compiled.result, 'base64')),
262
+ };
263
+ }
264
+ exports.compileTeal = compileTeal;
265
+ //# sourceMappingURL=app.js.map
package/app.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAOgB;AAChB,mCAA+B;AAC/B,yBAA2B;AAC3B,+CAA8G;AAE9G,qCAWoB;AAEpB;;;;;GAKG;AACI,KAAK,UAAU,SAAS,CAAC,MAAuB,EAAE,KAAc;IACrE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,QAAQ,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,GAAG,UAAU,EAAE,GAAG,MAAM,CAAA;IAElI,MAAM,eAAe,GAAG,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,WAAW,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,QAAQ,CAAA;IAC5H,MAAM,YAAY,GAAG,OAAO,KA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,CAAA;AACH,CAAC;AARD,kCAQC"}
@@ -0,0 +1,11 @@
1
+ import { Algodv2, Indexer } from 'algosdk';
2
+ import { ApplicationClient, AppSpecAppDetails } from './types/application-client';
3
+ /**
4
+ * Create a new ApplicationClient instance
5
+ * @param appDetails The details of the app
6
+ * @param algod An algod instance
7
+ * @param indexer An indexer instance
8
+ * @returns The application client
9
+ */
10
+ export declare function getApplicationClient(appDetails: AppSpecAppDetails, algod: Algodv2, indexer: Indexer): ApplicationClient;
11
+ //# sourceMappingURL=application-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"application-client.d.ts","sourceRoot":"","sources":["../src/application-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAEjF;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,iBAAiB,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,qBAEnG"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getApplicationClient = void 0;
4
+ const application_client_1 = require("./types/application-client");
5
+ /**
6
+ * Create a new ApplicationClient instance
7
+ * @param appDetails The details of the app
8
+ * @param algod An algod instance
9
+ * @param indexer An indexer instance
10
+ * @returns The application client
11
+ */
12
+ function getApplicationClient(appDetails, algod, indexer) {
13
+ return new application_client_1.ApplicationClient(appDetails, algod, indexer);
14
+ }
15
+ exports.getApplicationClient = getApplicationClient;
16
+ //# sourceMappingURL=application-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"application-client.js","sourceRoot":"","sources":["../src/application-client.ts"],"names":[],"mappings":";;;AACA,mEAAiF;AAEjF;;;;;;GAMG;AACH,SAAgB,oBAAoB,CAAC,UAA6B,EAAE,KAAc,EAAE,OAAgB;IAClG,OAAO,IAAI,sCAAiB,CAAC,UAAU,EAAE,KAAK,EAAE,OAAO,CAAC,CAAA;AAC1D,CAAC;AAFD,oDAEC"}