@algorandfoundation/algokit-utils 1.0.0-beta.3 → 1.0.0-beta.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/{dist/account.d.ts → account.d.ts} +36 -32
- package/account.d.ts.map +1 -0
- package/{dist/account.js → account.js} +55 -41
- package/account.js.map +1 -0
- package/amount.d.ts +8 -0
- package/amount.d.ts.map +1 -0
- package/amount.js +24 -0
- package/amount.js.map +1 -0
- package/app.d.ts +118 -0
- package/app.d.ts.map +1 -0
- package/app.js +541 -0
- package/app.js.map +1 -0
- package/application-client.d.ts +10 -0
- package/application-client.d.ts.map +1 -0
- package/application-client.js +15 -0
- package/application-client.js.map +1 -0
- package/deploy-app.d.ts +96 -0
- package/deploy-app.d.ts.map +1 -0
- package/{dist/deploy-app.js → deploy-app.js} +139 -114
- package/deploy-app.js.map +1 -0
- package/index.d.ts +14 -0
- package/index.d.ts.map +1 -0
- package/{dist/index.js → index.js} +6 -2
- package/index.js.map +1 -0
- package/{dist/localnet.d.ts → localnet.d.ts} +6 -6
- package/localnet.d.ts.map +1 -0
- package/{dist/localnet.js → localnet.js} +12 -12
- package/localnet.js.map +1 -0
- package/{dist/network-client.d.ts → network-client.d.ts} +15 -24
- package/network-client.d.ts.map +1 -0
- package/{dist/network-client.js → network-client.js} +16 -16
- package/{dist/network-client.js.map → network-client.js.map} +1 -1
- package/package.json +5 -93
- package/testing/account.d.ts +14 -0
- package/testing/account.d.ts.map +1 -0
- package/testing/account.js +31 -0
- package/testing/account.js.map +1 -0
- package/testing/fixtures/algokit-log-capture-fixture.d.ts +19 -0
- package/testing/fixtures/algokit-log-capture-fixture.d.ts.map +1 -0
- package/testing/fixtures/algokit-log-capture-fixture.js +43 -0
- package/testing/fixtures/algokit-log-capture-fixture.js.map +1 -0
- package/testing/fixtures/algorand-fixture.d.ts +20 -0
- package/testing/fixtures/algorand-fixture.d.ts.map +1 -0
- package/testing/fixtures/algorand-fixture.js +49 -0
- package/testing/fixtures/algorand-fixture.js.map +1 -0
- package/testing/fixtures/index.d.ts +3 -0
- package/testing/fixtures/index.d.ts.map +1 -0
- package/testing/fixtures/index.js +19 -0
- package/testing/fixtures/index.js.map +1 -0
- package/testing/index.d.ts +6 -0
- package/testing/index.d.ts.map +1 -0
- package/testing/index.js +22 -0
- package/testing/index.js.map +1 -0
- package/testing/indexer.d.ts +12 -0
- package/testing/indexer.d.ts.map +1 -0
- package/testing/indexer.js +39 -0
- package/testing/indexer.js.map +1 -0
- package/testing/test-logger.d.ts +39 -0
- package/testing/test-logger.d.ts.map +1 -0
- package/testing/test-logger.js +69 -0
- package/testing/test-logger.js.map +1 -0
- package/testing/transaction-logger.d.ts +29 -0
- package/testing/transaction-logger.d.ts.map +1 -0
- package/testing/transaction-logger.js +71 -0
- package/testing/transaction-logger.js.map +1 -0
- package/transaction.d.ts +120 -0
- package/transaction.d.ts.map +1 -0
- package/transaction.js +316 -0
- package/transaction.js.map +1 -0
- package/transfer.d.ts +21 -0
- package/transfer.d.ts.map +1 -0
- package/transfer.js +65 -0
- package/transfer.js.map +1 -0
- package/types/account.d.ts +55 -0
- package/types/account.d.ts.map +1 -0
- package/types/account.js +91 -0
- package/types/account.js.map +1 -0
- package/types/algo-http-client-with-retry.d.ts.map +1 -0
- package/{dist → types}/algo-http-client-with-retry.js +2 -2
- package/types/algo-http-client-with-retry.js.map +1 -0
- package/{dist/types → types}/algod.d.ts +22 -9
- package/types/algod.d.ts.map +1 -0
- package/{dist/algo-amount.d.ts → types/amount.d.ts} +3 -1
- package/types/amount.d.ts.map +1 -0
- package/{dist/algo-amount.js → types/amount.js} +7 -1
- package/types/amount.js.map +1 -0
- package/types/app.d.ts +286 -0
- package/types/app.d.ts.map +1 -0
- package/types/app.js +32 -0
- package/types/app.js.map +1 -0
- package/types/application-client.d.ts +232 -0
- package/types/application-client.d.ts.map +1 -0
- package/types/application-client.js +470 -0
- package/types/application-client.js.map +1 -0
- package/types/appspec.d.ts +77 -0
- package/types/appspec.d.ts.map +1 -0
- package/types/appspec.js +15 -0
- package/types/appspec.js.map +1 -0
- package/types/config.d.ts +15 -0
- package/types/config.d.ts.map +1 -0
- package/types/config.js +27 -0
- package/types/config.js.map +1 -0
- package/{dist/types → types}/indexer.d.ts +8 -9
- package/{dist/types → types}/indexer.d.ts.map +1 -1
- package/{dist/config.d.ts → types/logging.d.ts} +2 -16
- package/types/logging.d.ts.map +1 -0
- package/{dist/config.js → types/logging.js} +5 -24
- package/types/logging.js.map +1 -0
- package/types/logic-error.d.ts +33 -0
- package/types/logic-error.d.ts.map +1 -0
- package/types/logic-error.js +46 -0
- package/types/logic-error.js.map +1 -0
- package/types/network-client.d.ts +11 -0
- package/types/network-client.d.ts.map +1 -0
- package/types/network-client.js +3 -0
- package/types/network-client.js.map +1 -0
- package/types/testing.d.ts +89 -0
- package/types/testing.d.ts.map +1 -0
- package/types/testing.js +3 -0
- package/types/testing.js.map +1 -0
- package/types/transaction.d.ts +85 -0
- package/types/transaction.d.ts.map +1 -0
- package/types/transaction.js +3 -0
- package/types/transaction.js.map +1 -0
- package/types/transfer.d.ts +32 -0
- package/types/transfer.d.ts.map +1 -0
- package/types/transfer.js +3 -0
- package/types/transfer.js.map +1 -0
- package/types/urlTokenBaseHTTPClient.d.ts.map +1 -0
- package/types/urlTokenBaseHTTPClient.js.map +1 -0
- package/LICENSE +0 -21
- package/dist/account.d.ts.map +0 -1
- package/dist/account.js.map +0 -1
- package/dist/algo-amount.d.ts.map +0 -1
- package/dist/algo-amount.js.map +0 -1
- package/dist/algo-http-client-with-retry.d.ts.map +0 -1
- package/dist/algo-http-client-with-retry.js.map +0 -1
- package/dist/app.d.ts +0 -150
- package/dist/app.d.ts.map +0 -1
- package/dist/app.js +0 -156
- package/dist/app.js.map +0 -1
- package/dist/application-client.d.ts +0 -1
- package/dist/application-client.d.ts.map +0 -1
- package/dist/application-client.js +0 -69
- package/dist/application-client.js.map +0 -1
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js.map +0 -1
- package/dist/deploy-app.d.ts +0 -149
- package/dist/deploy-app.d.ts.map +0 -1
- package/dist/deploy-app.js.map +0 -1
- package/dist/index.d.ts +0 -11
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/localnet.d.ts.map +0 -1
- package/dist/localnet.js.map +0 -1
- package/dist/network-client.d.ts.map +0 -1
- package/dist/package.json +0 -20
- package/dist/transaction.d.ts +0 -152
- package/dist/transaction.d.ts.map +0 -1
- package/dist/transaction.js +0 -268
- package/dist/transaction.js.map +0 -1
- package/dist/transfer.d.ts +0 -24
- package/dist/transfer.d.ts.map +0 -1
- package/dist/transfer.js +0 -33
- package/dist/transfer.js.map +0 -1
- package/dist/types/algod.d.ts.map +0 -1
- package/dist/urlTokenBaseHTTPClient.d.ts.map +0 -1
- package/dist/urlTokenBaseHTTPClient.js.map +0 -1
- /package/{dist/indexer-lookup.d.ts → indexer-lookup.d.ts} +0 -0
- /package/{dist/indexer-lookup.d.ts.map → indexer-lookup.d.ts.map} +0 -0
- /package/{dist/indexer-lookup.js → indexer-lookup.js} +0 -0
- /package/{dist/indexer-lookup.js.map → indexer-lookup.js.map} +0 -0
- /package/{dist → types}/algo-http-client-with-retry.d.ts +0 -0
- /package/{dist/types → types}/algod.js +0 -0
- /package/{dist/types → types}/algod.js.map +0 -0
- /package/{dist/types → types}/indexer.js +0 -0
- /package/{dist/types → types}/indexer.js.map +0 -0
- /package/{dist → types}/urlTokenBaseHTTPClient.d.ts +0 -0
- /package/{dist → types}/urlTokenBaseHTTPClient.js +0 -0
|
@@ -14,14 +14,18 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.Config = void 0;
|
|
18
|
+
const config_1 = require("./types/config");
|
|
17
19
|
__exportStar(require("./account"), exports);
|
|
18
|
-
__exportStar(require("./
|
|
20
|
+
__exportStar(require("./amount"), exports);
|
|
19
21
|
__exportStar(require("./app"), exports);
|
|
20
|
-
__exportStar(require("./
|
|
22
|
+
__exportStar(require("./application-client"), exports);
|
|
21
23
|
__exportStar(require("./deploy-app"), exports);
|
|
22
24
|
__exportStar(require("./indexer-lookup"), exports);
|
|
23
25
|
__exportStar(require("./localnet"), exports);
|
|
24
26
|
__exportStar(require("./network-client"), exports);
|
|
25
27
|
__exportStar(require("./transaction"), exports);
|
|
26
28
|
__exportStar(require("./transfer"), exports);
|
|
29
|
+
/** The AlgoKit config. To update it use the configure method. */
|
|
30
|
+
exports.Config = new config_1.UpdatableConfig();
|
|
27
31
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2CAAgD;AAEhD,4CAAyB;AACzB,2CAAwB;AACxB,wCAAqB;AACrB,uDAAoC;AACpC,+CAA4B;AAC5B,mDAAgC;AAChC,6CAA0B;AAC1B,mDAAgC;AAChC,gDAA6B;AAC7B,6CAA0B;AAE1B,iEAAiE;AACpD,QAAA,MAAM,GAAG,IAAI,wBAAe,EAAE,CAAA"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Account, Algodv2, Kmd } from 'algosdk';
|
|
2
|
-
import { AlgoAmount } from './
|
|
2
|
+
import { AlgoAmount } from './types/amount';
|
|
3
3
|
/** Returns true if the algod client is pointing to a LocalNet Algorand network */
|
|
4
4
|
export declare function isLocalNet(algod: Algodv2): Promise<boolean>;
|
|
5
5
|
/**
|
|
6
6
|
* Gets an account with private key loaded from a KMD wallet of the given name, or alternatively creates one with funds in it via a KMD wallet of the given name.
|
|
7
7
|
*
|
|
8
|
-
* This is useful to get idempotent accounts from
|
|
8
|
+
* This is useful to get idempotent accounts from LocalNet without having to specify the private key (which will change when resetting the LocalNet).
|
|
9
9
|
*
|
|
10
|
-
* This significantly speeds up local dev time and improves experience since you can write code that *just works* first go without manual config in a fresh
|
|
10
|
+
* This significantly speeds up local dev time and improves experience since you can write code that *just works* first go without manual config in a fresh LocalNet.
|
|
11
11
|
*
|
|
12
12
|
* If this is used via @see {getAccount}, then you can even use the same code that runs on production without changes for local development!
|
|
13
13
|
*
|
|
@@ -33,7 +33,7 @@ export declare function getOrCreateKmdWalletAccount(walletAccount: {
|
|
|
33
33
|
* @param kmdClient A KMD client, if not specified then a default KMD client will be loaded from environment variables @see {getAlgoKmdClient}
|
|
34
34
|
* @example Get default funded account in a LocalNet
|
|
35
35
|
*
|
|
36
|
-
* ```
|
|
36
|
+
* ```typescript
|
|
37
37
|
* const defaultDispenserAccount = await getKmdWalletAccount(algod,
|
|
38
38
|
* 'unencrypted-default-wallet',
|
|
39
39
|
* a => a.status !== 'Offline' && a.amount > 1_000_000_000
|
|
@@ -48,7 +48,7 @@ export declare function getKmdWalletAccount(walletAccount: {
|
|
|
48
48
|
* Returns an Algorand account with private key loaded for the default LocalNet dispenser account (that can be used to fund other accounts)
|
|
49
49
|
*
|
|
50
50
|
* @param algod An algod client
|
|
51
|
-
* @param
|
|
51
|
+
* @param kmd A KMD client, if not specified then a default KMD client will be loaded from environment variables @see {getAlgoKmdClient}
|
|
52
52
|
*/
|
|
53
|
-
export declare function getLocalNetDispenserAccount(algod: Algodv2,
|
|
53
|
+
export declare function getLocalNetDispenserAccount(algod: Algodv2, kmd?: Kmd): Promise<Account>;
|
|
54
54
|
//# sourceMappingURL=localnet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localnet.d.ts","sourceRoot":"","sources":["../src/localnet.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AAKxD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE3C,kFAAkF;AAClF,wBAAsB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAIjE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,2BAA2B,CAC/C,aAAa,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,UAAU,CAAA;CAAE,EACtD,KAAK,EAAE,OAAO,EACd,SAAS,CAAC,EAAE,GAAG,GACd,OAAO,CAAC,OAAO,CAAC,CAmClB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,mBAAmB,CACvC,aAAa,EAAE;IACb,IAAI,EAAE,MAAM,CAAA;IAEZ,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,OAAO,CAAA;CACtD,EACD,KAAK,EAAE,OAAO,EACd,SAAS,CAAC,EAAE,GAAG,GACd,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAmC9B;AAED;;;;;GAKG;AACH,wBAAsB,2BAA2B,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,CAW7F"}
|
|
@@ -5,11 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getLocalNetDispenserAccount = exports.getKmdWalletAccount = exports.getOrCreateKmdWalletAccount = exports.isLocalNet = void 0;
|
|
7
7
|
const algosdk_1 = __importDefault(require("algosdk"));
|
|
8
|
+
const _1 = require("./");
|
|
8
9
|
const account_1 = require("./account");
|
|
9
|
-
const algo_amount_1 = require("./algo-amount");
|
|
10
|
-
const config_1 = require("./config");
|
|
11
10
|
const network_client_1 = require("./network-client");
|
|
12
11
|
const transfer_1 = require("./transfer");
|
|
12
|
+
const amount_1 = require("./types/amount");
|
|
13
13
|
/** Returns true if the algod client is pointing to a LocalNet Algorand network */
|
|
14
14
|
async function isLocalNet(algod) {
|
|
15
15
|
const params = await algod.getTransactionParams().do();
|
|
@@ -19,9 +19,9 @@ exports.isLocalNet = isLocalNet;
|
|
|
19
19
|
/**
|
|
20
20
|
* Gets an account with private key loaded from a KMD wallet of the given name, or alternatively creates one with funds in it via a KMD wallet of the given name.
|
|
21
21
|
*
|
|
22
|
-
* This is useful to get idempotent accounts from
|
|
22
|
+
* This is useful to get idempotent accounts from LocalNet without having to specify the private key (which will change when resetting the LocalNet).
|
|
23
23
|
*
|
|
24
|
-
* This significantly speeds up local dev time and improves experience since you can write code that *just works* first go without manual config in a fresh
|
|
24
|
+
* This significantly speeds up local dev time and improves experience since you can write code that *just works* first go without manual config in a fresh LocalNet.
|
|
25
25
|
*
|
|
26
26
|
* If this is used via @see {getAccount}, then you can even use the same code that runs on production without changes for local development!
|
|
27
27
|
*
|
|
@@ -47,11 +47,11 @@ async function getOrCreateKmdWalletAccount(walletAccount, algod, kmdClient) {
|
|
|
47
47
|
// Get the account from the new KMD wallet
|
|
48
48
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
49
49
|
const account = (await getKmdWalletAccount(walletAccount, algod, kmd));
|
|
50
|
-
|
|
50
|
+
_1.Config.logger.info(`LocalNet account '${walletAccount.name}' doesn't yet exist; created account ${account.addr} with keys stored in KMD and funding with ${walletAccount.fundWith?.algos ?? 1000} ALGOs`);
|
|
51
51
|
// Fund the account from the dispenser
|
|
52
52
|
await (0, transfer_1.transferAlgos)({
|
|
53
|
-
amount: walletAccount.fundWith ??
|
|
54
|
-
from: await (0, account_1.getDispenserAccount)(algod),
|
|
53
|
+
amount: walletAccount.fundWith ?? amount_1.AlgoAmount.Algos(1000),
|
|
54
|
+
from: await (0, account_1.getDispenserAccount)(algod, kmd),
|
|
55
55
|
to: account.addr,
|
|
56
56
|
}, algod);
|
|
57
57
|
return account;
|
|
@@ -67,7 +67,7 @@ exports.getOrCreateKmdWalletAccount = getOrCreateKmdWalletAccount;
|
|
|
67
67
|
* @param kmdClient A KMD client, if not specified then a default KMD client will be loaded from environment variables @see {getAlgoKmdClient}
|
|
68
68
|
* @example Get default funded account in a LocalNet
|
|
69
69
|
*
|
|
70
|
-
* ```
|
|
70
|
+
* ```typescript
|
|
71
71
|
* const defaultDispenserAccount = await getKmdWalletAccount(algod,
|
|
72
72
|
* 'unencrypted-default-wallet',
|
|
73
73
|
* a => a.status !== 'Offline' && a.amount > 1_000_000_000
|
|
@@ -101,21 +101,21 @@ async function getKmdWalletAccount(walletAccount, algod, kmdClient) {
|
|
|
101
101
|
}
|
|
102
102
|
const accountKey = (await kmd.exportKey(walletHandle, '', keyIds[i])).private_key;
|
|
103
103
|
const accountMnemonic = algosdk_1.default.secretKeyToMnemonic(accountKey);
|
|
104
|
-
return (0, account_1.
|
|
104
|
+
return (0, account_1.mnemonicAccount)(accountMnemonic);
|
|
105
105
|
}
|
|
106
106
|
exports.getKmdWalletAccount = getKmdWalletAccount;
|
|
107
107
|
/**
|
|
108
108
|
* Returns an Algorand account with private key loaded for the default LocalNet dispenser account (that can be used to fund other accounts)
|
|
109
109
|
*
|
|
110
110
|
* @param algod An algod client
|
|
111
|
-
* @param
|
|
111
|
+
* @param kmd A KMD client, if not specified then a default KMD client will be loaded from environment variables @see {getAlgoKmdClient}
|
|
112
112
|
*/
|
|
113
|
-
async function getLocalNetDispenserAccount(algod,
|
|
113
|
+
async function getLocalNetDispenserAccount(algod, kmd) {
|
|
114
114
|
if (!(await isLocalNet(algod))) {
|
|
115
115
|
throw "Can't get default account from non LocalNet network";
|
|
116
116
|
}
|
|
117
117
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
118
|
-
return (await getKmdWalletAccount({ name: 'unencrypted-default-wallet', predicate: (a) => a.status !== 'Offline' && a.amount > 1000000000 }, algod,
|
|
118
|
+
return (await getKmdWalletAccount({ name: 'unencrypted-default-wallet', predicate: (a) => a.status !== 'Offline' && a.amount > 1000000000 }, algod, kmd));
|
|
119
119
|
}
|
|
120
120
|
exports.getLocalNetDispenserAccount = getLocalNetDispenserAccount;
|
|
121
121
|
//# sourceMappingURL=localnet.js.map
|
package/localnet.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localnet.js","sourceRoot":"","sources":["../src/localnet.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAwD;AACxD,yBAA2B;AAC3B,uCAAgE;AAChE,qDAAmD;AACnD,yCAA0C;AAC1C,2CAA2C;AAE3C,kFAAkF;AAC3E,KAAK,UAAU,UAAU,CAAC,KAAc;IAC7C,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,oBAAoB,EAAE,CAAC,EAAE,EAAE,CAAA;IAEtD,OAAO,MAAM,CAAC,SAAS,KAAK,WAAW,IAAI,MAAM,CAAC,SAAS,KAAK,YAAY,CAAA;AAC9E,CAAC;AAJD,gCAIC;AAED;;;;;;;;;;;;;;;;GAgBG;AACI,KAAK,UAAU,2BAA2B,CAC/C,aAAsD,EACtD,KAAc,EACd,SAAe;IAEf,MAAM,GAAG,GAAG,SAAS,IAAI,IAAA,iCAAgB,GAAE,CAAA;IAE3C,8CAA8C;IAC9C,MAAM,QAAQ,GAAG,MAAM,mBAAmB,CAAC,aAAa,EAAE,KAAK,EAAE,GAAG,CAAC,CAAA;IACrE,IAAI,QAAQ,EAAE;QACZ,OAAO,QAAQ,CAAA;KAChB;IAED,8CAA8C;IAC9C,MAAM,QAAQ,GAAG,CAAC,MAAM,GAAG,CAAC,YAAY,CAAC,aAAa,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAA;IAC3E,MAAM,YAAY,GAAG,CAAC,MAAM,GAAG,CAAC,gBAAgB,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,mBAAmB,CAAA;IACnF,MAAM,GAAG,CAAC,WAAW,CAAC,YAAY,CAAC,CAAA;IAEnC,0CAA0C;IA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G,KAAK,EACL,GAAG,CACJ,CAAE,CAAA;AACL,CAAC;AAXD,kEAWC"}
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import { Algodv2, Indexer, Kmd } from 'algosdk';
|
|
2
|
-
import {
|
|
3
|
-
/** Config for an Algorand SDK client */
|
|
4
|
-
export interface AlgoClientConfig {
|
|
5
|
-
/** Base URL of the server e.g. http://localhost, https://testnet-api.algonode.cloud/, etc. */
|
|
6
|
-
server: string;
|
|
7
|
-
/** The port to use e.g. 4001, 443, etc. */
|
|
8
|
-
port?: string | number;
|
|
9
|
-
/** The token to use for API authentication (or undefined if none needed) - can be a string, or an object with the header key => value */
|
|
10
|
-
token?: string | TokenHeader;
|
|
11
|
-
}
|
|
2
|
+
import { AlgoClientConfig } from './types/network-client';
|
|
12
3
|
/** Retrieve the algod configuration from environment variables (expects to be called from a Node.js environment not algod-side) */
|
|
13
4
|
export declare function getAlgodConfigFromEnvironment(): AlgoClientConfig;
|
|
14
5
|
/** Retrieve the indexer configuration from environment variables (expects to be called from a Node.js environment not algod-side) */
|
|
@@ -29,24 +20,24 @@ export declare function getDefaultLocalNetConfig(configOrPort: 'algod' | 'indexe
|
|
|
29
20
|
* @param config The config if you want to override the default (getting config from process.env)
|
|
30
21
|
* @example Default (load from environment variables)
|
|
31
22
|
*
|
|
32
|
-
* ```
|
|
23
|
+
* ```typescript
|
|
33
24
|
* // Uses process.env.ALGOD_SERVER, process.env.ALGOD_PORT and process.env.ALGOD_TOKEN
|
|
34
25
|
* // Automatically detects if you are using PureStake to switch in the right header name for ALGOD_TOKEN
|
|
35
26
|
* const algod = getAlgoClient()
|
|
36
27
|
* await algod.healthCheck().do()
|
|
37
28
|
* ```
|
|
38
29
|
* @example AlgoNode (testnet)
|
|
39
|
-
* ```
|
|
30
|
+
* ```typescript
|
|
40
31
|
* const algod = getAlgoClient(getAlgoNodeConfig('testnet', 'algod'))
|
|
41
32
|
* await algod.healthCheck().do()
|
|
42
33
|
* ```
|
|
43
34
|
* @example AlgoNode (mainnet)
|
|
44
|
-
* ```
|
|
35
|
+
* ```typescript
|
|
45
36
|
* const algod = getAlgoClient(getAlgoNodeConfig('mainnet', 'algod'))
|
|
46
37
|
* await algod.healthCheck().do()
|
|
47
38
|
* ```
|
|
48
|
-
* @example Custom (e.g. default
|
|
49
|
-
* ```
|
|
39
|
+
* @example Custom (e.g. default LocalNet, although we recommend loading this into a .env and using the Default option instead)
|
|
40
|
+
* ```typescript
|
|
50
41
|
* const algod = getAlgoClient({server: 'http://localhost', port: '4001', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'})
|
|
51
42
|
* await algod.healthCheck().do()
|
|
52
43
|
* ```
|
|
@@ -57,24 +48,24 @@ export declare function getAlgoClient(config?: AlgoClientConfig): Algodv2;
|
|
|
57
48
|
* @param config The config if you want to override the default (getting config from process.env)
|
|
58
49
|
* @example Default (load from environment variables)
|
|
59
50
|
*
|
|
60
|
-
* ```
|
|
51
|
+
* ```typescript
|
|
61
52
|
* // Uses process.env.INDEXER_SERVER, process.env.INDEXER_PORT and process.env.INDEXER_TOKEN
|
|
62
53
|
* // Automatically detects if you are using PureStake to switch in the right header name for INDEXER_TOKEN
|
|
63
54
|
* const indexer = getAlgoIndexerClient()
|
|
64
55
|
* await indexer.makeHealthCheck().do()
|
|
65
56
|
* ```
|
|
66
57
|
* @example AlgoNode (testnet)
|
|
67
|
-
* ```
|
|
58
|
+
* ```typescript
|
|
68
59
|
* const indexer = getAlgoIndexerClient(getAlgoNodeConfig('testnet', 'indexer'))
|
|
69
60
|
* await indexer.makeHealthCheck().do()
|
|
70
61
|
* ```
|
|
71
62
|
* @example AlgoNode (mainnet)
|
|
72
|
-
* ```
|
|
63
|
+
* ```typescript
|
|
73
64
|
* const indexer = getAlgoIndexerClient(getAlgoNodeConfig('mainnet', 'indexer'))
|
|
74
65
|
* await indexer.makeHealthCheck().do()
|
|
75
66
|
* ```
|
|
76
|
-
* @example Custom (e.g. default
|
|
77
|
-
* ```
|
|
67
|
+
* @example Custom (e.g. default LocalNet, although we recommend loading this into a .env and using the Default option instead)
|
|
68
|
+
* ```typescript
|
|
78
69
|
* const indexer = getAlgoIndexerClient({server: 'http://localhost', port: '8980', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'})
|
|
79
70
|
* await indexer.makeHealthCheck().do()
|
|
80
71
|
* ```
|
|
@@ -83,17 +74,17 @@ export declare function getAlgoIndexerClient(config?: AlgoClientConfig): Indexer
|
|
|
83
74
|
/**
|
|
84
75
|
* Returns a KMD SDK client that automatically retries on idempotent calls
|
|
85
76
|
*
|
|
86
|
-
* KMD client allows you to export private keys, which is useful to get the default account in a
|
|
77
|
+
* KMD client allows you to export private keys, which is useful to get the default account in a LocalNet network.
|
|
87
78
|
*
|
|
88
79
|
* @param config The config if you want to override the default (getting config from process.env)
|
|
89
80
|
* @example Default (load from environment variables)
|
|
90
81
|
*
|
|
91
|
-
* ```
|
|
82
|
+
* ```typescript
|
|
92
83
|
* // Uses process.env.ALGOD_SERVER, process.env.KMD_PORT (or if not specified: port 4002) and process.env.ALGOD_TOKEN
|
|
93
84
|
* const kmd = getAlgoKmdClient()
|
|
94
85
|
* ```
|
|
95
|
-
* @example Custom (e.g. default
|
|
96
|
-
* ```
|
|
86
|
+
* @example Custom (e.g. default LocalNet, although we recommend loading this into a .env and using the Default option instead)
|
|
87
|
+
* ```typescript
|
|
97
88
|
* const kmd = getAlgoKmdClient({server: 'http://localhost', port: '4002', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'})
|
|
98
89
|
* ```
|
|
99
90
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network-client.d.ts","sourceRoot":"","sources":["../src/network-client.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AAGxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAEzD,mIAAmI;AACnI,wBAAgB,6BAA6B,IAAI,gBAAgB,CAchE;AAED,qIAAqI;AACrI,wBAAgB,+BAA+B,IAAI,gBAAgB,CAclE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,SAAS,GAAG,SAAS,EAAE,MAAM,EAAE,OAAO,GAAG,SAAS,GAAG,gBAAgB,CAK/G;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,YAAY,EAAE,OAAO,GAAG,SAAS,GAAG,KAAK,GAAG,MAAM,GAAG,gBAAgB,CAM7G;AAUD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,aAAa,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAIhE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAIvE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,GAAG,CAK/D;AAED,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.isLocalNet = exports.getAlgoKmdClient = exports.getAlgoIndexerClient = exports.getAlgoClient = exports.getDefaultLocalNetConfig = exports.getAlgoNodeConfig = exports.getIndexerConfigFromEnvironment = exports.getAlgodConfigFromEnvironment = void 0;
|
|
27
27
|
const algosdk_1 = __importStar(require("algosdk"));
|
|
28
|
-
const algo_http_client_with_retry_1 = require("./algo-http-client-with-retry");
|
|
28
|
+
const algo_http_client_with_retry_1 = require("./types/algo-http-client-with-retry");
|
|
29
29
|
/** Retrieve the algod configuration from environment variables (expects to be called from a Node.js environment not algod-side) */
|
|
30
30
|
function getAlgodConfigFromEnvironment() {
|
|
31
31
|
if (!process || !process.env) {
|
|
@@ -92,24 +92,24 @@ function getAlgoTokenHeader(server, token, defaultHeader) {
|
|
|
92
92
|
* @param config The config if you want to override the default (getting config from process.env)
|
|
93
93
|
* @example Default (load from environment variables)
|
|
94
94
|
*
|
|
95
|
-
* ```
|
|
95
|
+
* ```typescript
|
|
96
96
|
* // Uses process.env.ALGOD_SERVER, process.env.ALGOD_PORT and process.env.ALGOD_TOKEN
|
|
97
97
|
* // Automatically detects if you are using PureStake to switch in the right header name for ALGOD_TOKEN
|
|
98
98
|
* const algod = getAlgoClient()
|
|
99
99
|
* await algod.healthCheck().do()
|
|
100
100
|
* ```
|
|
101
101
|
* @example AlgoNode (testnet)
|
|
102
|
-
* ```
|
|
102
|
+
* ```typescript
|
|
103
103
|
* const algod = getAlgoClient(getAlgoNodeConfig('testnet', 'algod'))
|
|
104
104
|
* await algod.healthCheck().do()
|
|
105
105
|
* ```
|
|
106
106
|
* @example AlgoNode (mainnet)
|
|
107
|
-
* ```
|
|
107
|
+
* ```typescript
|
|
108
108
|
* const algod = getAlgoClient(getAlgoNodeConfig('mainnet', 'algod'))
|
|
109
109
|
* await algod.healthCheck().do()
|
|
110
110
|
* ```
|
|
111
|
-
* @example Custom (e.g. default
|
|
112
|
-
* ```
|
|
111
|
+
* @example Custom (e.g. default LocalNet, although we recommend loading this into a .env and using the Default option instead)
|
|
112
|
+
* ```typescript
|
|
113
113
|
* const algod = getAlgoClient({server: 'http://localhost', port: '4001', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'})
|
|
114
114
|
* await algod.healthCheck().do()
|
|
115
115
|
* ```
|
|
@@ -125,24 +125,24 @@ exports.getAlgoClient = getAlgoClient;
|
|
|
125
125
|
* @param config The config if you want to override the default (getting config from process.env)
|
|
126
126
|
* @example Default (load from environment variables)
|
|
127
127
|
*
|
|
128
|
-
* ```
|
|
128
|
+
* ```typescript
|
|
129
129
|
* // Uses process.env.INDEXER_SERVER, process.env.INDEXER_PORT and process.env.INDEXER_TOKEN
|
|
130
130
|
* // Automatically detects if you are using PureStake to switch in the right header name for INDEXER_TOKEN
|
|
131
131
|
* const indexer = getAlgoIndexerClient()
|
|
132
132
|
* await indexer.makeHealthCheck().do()
|
|
133
133
|
* ```
|
|
134
134
|
* @example AlgoNode (testnet)
|
|
135
|
-
* ```
|
|
135
|
+
* ```typescript
|
|
136
136
|
* const indexer = getAlgoIndexerClient(getAlgoNodeConfig('testnet', 'indexer'))
|
|
137
137
|
* await indexer.makeHealthCheck().do()
|
|
138
138
|
* ```
|
|
139
139
|
* @example AlgoNode (mainnet)
|
|
140
|
-
* ```
|
|
140
|
+
* ```typescript
|
|
141
141
|
* const indexer = getAlgoIndexerClient(getAlgoNodeConfig('mainnet', 'indexer'))
|
|
142
142
|
* await indexer.makeHealthCheck().do()
|
|
143
143
|
* ```
|
|
144
|
-
* @example Custom (e.g. default
|
|
145
|
-
* ```
|
|
144
|
+
* @example Custom (e.g. default LocalNet, although we recommend loading this into a .env and using the Default option instead)
|
|
145
|
+
* ```typescript
|
|
146
146
|
* const indexer = getAlgoIndexerClient({server: 'http://localhost', port: '8980', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'})
|
|
147
147
|
* await indexer.makeHealthCheck().do()
|
|
148
148
|
* ```
|
|
@@ -156,23 +156,23 @@ exports.getAlgoIndexerClient = getAlgoIndexerClient;
|
|
|
156
156
|
/**
|
|
157
157
|
* Returns a KMD SDK client that automatically retries on idempotent calls
|
|
158
158
|
*
|
|
159
|
-
* KMD client allows you to export private keys, which is useful to get the default account in a
|
|
159
|
+
* KMD client allows you to export private keys, which is useful to get the default account in a LocalNet network.
|
|
160
160
|
*
|
|
161
161
|
* @param config The config if you want to override the default (getting config from process.env)
|
|
162
162
|
* @example Default (load from environment variables)
|
|
163
163
|
*
|
|
164
|
-
* ```
|
|
164
|
+
* ```typescript
|
|
165
165
|
* // Uses process.env.ALGOD_SERVER, process.env.KMD_PORT (or if not specified: port 4002) and process.env.ALGOD_TOKEN
|
|
166
166
|
* const kmd = getAlgoKmdClient()
|
|
167
167
|
* ```
|
|
168
|
-
* @example Custom (e.g. default
|
|
169
|
-
* ```
|
|
168
|
+
* @example Custom (e.g. default LocalNet, although we recommend loading this into a .env and using the Default option instead)
|
|
169
|
+
* ```typescript
|
|
170
170
|
* const kmd = getAlgoKmdClient({server: 'http://localhost', port: '4002', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'})
|
|
171
171
|
* ```
|
|
172
172
|
*/
|
|
173
173
|
function getAlgoKmdClient(config) {
|
|
174
174
|
const { token, server } = config ?? getAlgodConfigFromEnvironment();
|
|
175
|
-
// We can only use Kmd on the
|
|
175
|
+
// We can only use Kmd on the LocalNet otherwise it's not exposed so this makes some assumptions
|
|
176
176
|
// (e.g. same token and server as algod and port 4002 by default)
|
|
177
177
|
return new algosdk_1.Kmd(token, server, process?.env?.KMD_PORT ?? '4002');
|
|
178
178
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network-client.js","sourceRoot":"","sources":["../src/network-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAwD;AAExD
|
|
1
|
+
{"version":3,"file":"network-client.js","sourceRoot":"","sources":["../src/network-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAwD;AAExD,qFAA6E;AAG7E,mIAAmI;AACnI,SAAgB,6BAA6B;IAC3C,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE;QAC5B,MAAM,IAAI,KAAK,CA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A;IAC/H,OAAO,IAAI,iBAAO,CAAC,mBAAmB,CAAC,CAAA;AACzC,CAAC;AAJD,oDAIC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,gBAAgB,CAAC,MAAyB;IACxD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,6BAA6B,EAAE,CAAA;IACnE,gGAAgG;IAChG,iEAAiE;IACjE,OAAO,IAAI,aAAG,CAAC,KAAe,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,IAAI,MAAM,CAAC,CAAA;AAC3E,CAAC;AALD,4CAKC;AAED,uCAAuC;AAA9B,sGAAA,UAAU,OAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
+
"main": "index.js",
|
|
3
|
+
"types": "index.d.ts",
|
|
2
4
|
"name": "@algorandfoundation/algokit-utils",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
5
|
+
"version": "1.0.0-beta.31",
|
|
4
6
|
"private": false,
|
|
5
7
|
"description": "A set of core Algorand utilities written in TypeScript and released via npm that make it easier to build solutions on Algorand.",
|
|
6
8
|
"author": "Algorand Foundation",
|
|
@@ -8,101 +10,11 @@
|
|
|
8
10
|
"engines": {
|
|
9
11
|
"node": ">=16.0"
|
|
10
12
|
},
|
|
11
|
-
"main": "./dist/index.js",
|
|
12
13
|
"files": [
|
|
13
|
-
"
|
|
14
|
+
"**/*"
|
|
14
15
|
],
|
|
15
|
-
"scripts": {
|
|
16
|
-
"build": "run-s build:*",
|
|
17
|
-
"build:0-clean": "rimraf dist coverage",
|
|
18
|
-
"build:1-compile": "tsc -p tsconfig.build.json",
|
|
19
|
-
"build:2-copy-pkg-json": "npx --yes @makerx/ts-toolkit@latest copy-package-json",
|
|
20
|
-
"test": "jest --coverage --passWithNoTests",
|
|
21
|
-
"lint": "eslint ./src/ --ext .ts",
|
|
22
|
-
"lint:fix": "eslint ./src/ --ext .ts --fix",
|
|
23
|
-
"check-types": "tsc --noEmit",
|
|
24
|
-
"audit": "npm audit",
|
|
25
|
-
"format": "prettier --write .",
|
|
26
|
-
"commit-lint": "commitlint --edit -o",
|
|
27
|
-
"semantic-release": "semantic-release"
|
|
28
|
-
},
|
|
29
16
|
"dependencies": {
|
|
30
|
-
"algosdk": "^2.
|
|
17
|
+
"algosdk": "^2.2.0",
|
|
31
18
|
"buffer": "^6.0.3"
|
|
32
|
-
},
|
|
33
|
-
"devDependencies": {
|
|
34
|
-
"@commitlint/cli": "^17.4.3",
|
|
35
|
-
"@commitlint/config-conventional": "^17.4.3",
|
|
36
|
-
"@makerx/eslint-config": "3.0.0",
|
|
37
|
-
"@makerx/prettier-config": "2.0.0",
|
|
38
|
-
"@makerx/ts-config": "1.0.1",
|
|
39
|
-
"@tsconfig/node16": "^1.0.3",
|
|
40
|
-
"@types/jest": "^29.2.3",
|
|
41
|
-
"@types/uuid": "^9.0.1",
|
|
42
|
-
"conventional-changelog-conventionalcommits": "^5.0.0",
|
|
43
|
-
"eslint": "8.36.0",
|
|
44
|
-
"npm-run-all": "^4.1.5",
|
|
45
|
-
"prettier": "2.8.4",
|
|
46
|
-
"rimraf": "^4.4.0",
|
|
47
|
-
"semantic-release": "^20.1.0",
|
|
48
|
-
"tiny-invariant": "^1.3.1",
|
|
49
|
-
"ts-jest": "^29.0.3",
|
|
50
|
-
"ts-node": "^10.9.1",
|
|
51
|
-
"typescript": "^4.9.3",
|
|
52
|
-
"uuid": "^9.0.0"
|
|
53
|
-
},
|
|
54
|
-
"release": {
|
|
55
|
-
"branches": [
|
|
56
|
-
{
|
|
57
|
-
"name": "main",
|
|
58
|
-
"prerelease": "beta"
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
"name": "release"
|
|
62
|
-
}
|
|
63
|
-
],
|
|
64
|
-
"plugins": [
|
|
65
|
-
[
|
|
66
|
-
"@semantic-release/commit-analyzer",
|
|
67
|
-
{
|
|
68
|
-
"preset": "conventionalcommits",
|
|
69
|
-
"releaseRules": [
|
|
70
|
-
{
|
|
71
|
-
"type": "build",
|
|
72
|
-
"release": "patch"
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
"type": "chore",
|
|
76
|
-
"release": "patch"
|
|
77
|
-
}
|
|
78
|
-
]
|
|
79
|
-
}
|
|
80
|
-
],
|
|
81
|
-
[
|
|
82
|
-
"@semantic-release/release-notes-generator",
|
|
83
|
-
{
|
|
84
|
-
"preset": "conventionalcommits",
|
|
85
|
-
"presetConfig": {
|
|
86
|
-
"types": [
|
|
87
|
-
{
|
|
88
|
-
"type": "feat",
|
|
89
|
-
"section": "Features"
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
"type": "fix",
|
|
93
|
-
"section": "Bug Fixes"
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
"type": "build",
|
|
97
|
-
"section": "Dependencies and Other Build Updates",
|
|
98
|
-
"hidden": false
|
|
99
|
-
}
|
|
100
|
-
]
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
],
|
|
104
|
-
"@semantic-release/npm",
|
|
105
|
-
"@semantic-release/github"
|
|
106
|
-
]
|
|
107
19
|
}
|
|
108
20
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Account, Algodv2, Kmd } from 'algosdk';
|
|
2
|
+
import { GetTestAccountParams } from '../types/testing';
|
|
3
|
+
/**
|
|
4
|
+
* Creates an ephemeral Algorand account for the purposes of testing.
|
|
5
|
+
* Returns a newly created random test account that is funded from the dispenser @see {getDispenserAccount}
|
|
6
|
+
* DO NOT USE THIS TO CREATE A MAINNET ACCOUNT!
|
|
7
|
+
* Note: By default this will log the mnemonic of the account.
|
|
8
|
+
* @param param0 The config for the test account to generate
|
|
9
|
+
* @param algod An algod client
|
|
10
|
+
* @param kmd A KMD client, if not specified then a default KMD client will be loaded from environment variables @see {getAlgoKmdClient}
|
|
11
|
+
* @returns The account, with private key loaded
|
|
12
|
+
*/
|
|
13
|
+
export declare function getTestAccount({ suppressLog, initialFunds }: GetTestAccountParams, algod: Algodv2, kmd?: Kmd): Promise<Account>;
|
|
14
|
+
//# sourceMappingURL=account.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../src/testing/account.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AAIxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAEvD;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CAAC,EAAE,WAAW,EAAE,YAAY,EAAE,EAAE,oBAAoB,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,CAgBrI"}
|
|
@@ -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.getTestAccount = void 0;
|
|
7
|
+
const algosdk_1 = __importDefault(require("algosdk"));
|
|
8
|
+
const __1 = require("../");
|
|
9
|
+
const account_1 = require("../account");
|
|
10
|
+
const transfer_1 = require("../transfer");
|
|
11
|
+
/**
|
|
12
|
+
* Creates an ephemeral Algorand account for the purposes of testing.
|
|
13
|
+
* Returns a newly created random test account that is funded from the dispenser @see {getDispenserAccount}
|
|
14
|
+
* DO NOT USE THIS TO CREATE A MAINNET ACCOUNT!
|
|
15
|
+
* Note: By default this will log the mnemonic of the account.
|
|
16
|
+
* @param param0 The config for the test account to generate
|
|
17
|
+
* @param algod An algod client
|
|
18
|
+
* @param kmd A KMD client, if not specified then a default KMD client will be loaded from environment variables @see {getAlgoKmdClient}
|
|
19
|
+
* @returns The account, with private key loaded
|
|
20
|
+
*/
|
|
21
|
+
async function getTestAccount({ suppressLog, initialFunds }, algod, kmd) {
|
|
22
|
+
const account = algosdk_1.default.generateAccount();
|
|
23
|
+
__1.Config.getLogger(suppressLog).info(`New test account created with address '${account.addr}' and mnemonic '${algosdk_1.default.secretKeyToMnemonic(account.sk)}'.`);
|
|
24
|
+
const dispenser = await (0, account_1.getDispenserAccount)(algod, kmd);
|
|
25
|
+
await (0, transfer_1.transferAlgos)({ from: dispenser, to: account.addr, amount: initialFunds, note: 'Funding test account', suppressLog }, algod);
|
|
26
|
+
const accountInfo = await algod.accountInformation(account.addr).do();
|
|
27
|
+
__1.Config.getLogger(suppressLog).info('Test account funded; account balance: %d µAlgos', accountInfo.amount);
|
|
28
|
+
return account;
|
|
29
|
+
}
|
|
30
|
+
exports.getTestAccount = getTestAccount;
|
|
31
|
+
//# sourceMappingURL=account.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/testing/account.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAwD;AACxD,2BAA4B;AAC5B,wCAAgD;AAChD,0CAA2C;AAG3C;;;;;;;;;GASG;AACI,KAAK,UAAU,cAAc,CAAC,EAAE,WAAW,EAAE,YAAY,EAAwB,EAAE,KAAc,EAAE,GAAS;IACjH,MAAM,OAAO,GAAG,iBAAO,CAAC,eAAe,EAAE,CAAA;IAEzC,UAAM,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,IAAI,CAChC,0CAA0C,OAAO,CAAC,IAAI,mBAAmB,iBAAO,CAAC,mBAAmB,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CACrH,CAAA;IAED,MAAM,SAAS,GAAG,MAAM,IAAA,6BAAmB,EAAC,KAAK,EAAE,GAAG,CAAC,CAAA;IAEvD,MAAM,IAAA,wBAAa,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,sBAAsB,EAAE,WAAW,EAAE,EAAE,KAAK,CAAC,CAAA;IAElI,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,kBAAkB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,CAAA;IAErE,UAAM,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,iDAAiD,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;IAEzG,OAAO,OAAO,CAAA;AAChB,CAAC;AAhBD,wCAgBC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AlgoKitLogCaptureFixture } from '../../types/testing';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a test fixture for capturing AlgoKit logs.
|
|
4
|
+
*
|
|
5
|
+
* @example ```typescript
|
|
6
|
+
* const logs = algoKitLogCaptureFixture()
|
|
7
|
+
*
|
|
8
|
+
* beforeEach(logs.beforeEach)
|
|
9
|
+
* afterEach(logs.afterEach)
|
|
10
|
+
*
|
|
11
|
+
* test('My test', () => {
|
|
12
|
+
* const capturedLogs = logs.testLogger.capturedLogs
|
|
13
|
+
* })
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @returns The fixture
|
|
17
|
+
*/
|
|
18
|
+
export declare const algoKitLogCaptureFixture: () => AlgoKitLogCaptureFixture;
|
|
19
|
+
//# sourceMappingURL=algokit-log-capture-fixture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"algokit-log-capture-fixture.d.ts","sourceRoot":"","sources":["../../../src/testing/fixtures/algokit-log-capture-fixture.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAG9D;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,wBAAwB,EAAE,MAAM,wBAqB5C,CAAA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.algoKitLogCaptureFixture = void 0;
|
|
4
|
+
const __1 = require("../../");
|
|
5
|
+
const test_logger_1 = require("../test-logger");
|
|
6
|
+
/**
|
|
7
|
+
* Creates a test fixture for capturing AlgoKit logs.
|
|
8
|
+
*
|
|
9
|
+
* @example ```typescript
|
|
10
|
+
* const logs = algoKitLogCaptureFixture()
|
|
11
|
+
*
|
|
12
|
+
* beforeEach(logs.beforeEach)
|
|
13
|
+
* afterEach(logs.afterEach)
|
|
14
|
+
*
|
|
15
|
+
* test('My test', () => {
|
|
16
|
+
* const capturedLogs = logs.testLogger.capturedLogs
|
|
17
|
+
* })
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @returns The fixture
|
|
21
|
+
*/
|
|
22
|
+
const algoKitLogCaptureFixture = () => {
|
|
23
|
+
const originalLogger = __1.Config.logger;
|
|
24
|
+
let hybridLogger;
|
|
25
|
+
return {
|
|
26
|
+
get testLogger() {
|
|
27
|
+
return hybridLogger;
|
|
28
|
+
},
|
|
29
|
+
beforeEach: () => {
|
|
30
|
+
hybridLogger = new test_logger_1.TestLogger(originalLogger);
|
|
31
|
+
__1.Config.configure({
|
|
32
|
+
logger: hybridLogger,
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
afterEach: () => {
|
|
36
|
+
__1.Config.configure({
|
|
37
|
+
logger: originalLogger,
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
exports.algoKitLogCaptureFixture = algoKitLogCaptureFixture;
|
|
43
|
+
//# sourceMappingURL=algokit-log-capture-fixture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"algokit-log-capture-fixture.js","sourceRoot":"","sources":["../../../src/testing/fixtures/algokit-log-capture-fixture.ts"],"names":[],"mappings":";;;AAAA,8BAA+B;AAE/B,gDAA2C;AAE3C;;;;;;;;;;;;;;;GAeG;AACI,MAAM,wBAAwB,GAAmC,GAAG,EAAE;IAC3E,MAAM,cAAc,GAAG,UAAM,CAAC,MAAM,CAAA;IAEpC,IAAI,YAAwB,CAAA;IAE5B,OAAO;QACL,IAAI,UAAU;YACZ,OAAO,YAAY,CAAA;QACrB,CAAC;QACD,UAAU,EAAE,GAAG,EAAE;YACf,YAAY,GAAG,IAAI,wBAAU,CAAC,cAAc,CAAC,CAAA;YAC7C,UAAM,CAAC,SAAS,CAAC;gBACf,MAAM,EAAE,YAAY;aACrB,CAAC,CAAA;QACJ,CAAC;QACD,SAAS,EAAE,GAAG,EAAE;YACd,UAAM,CAAC,SAAS,CAAC;gBACf,MAAM,EAAE,cAAc;aACvB,CAAC,CAAA;QACJ,CAAC;KACF,CAAA;AACH,CAAC,CAAA;AArBY,QAAA,wBAAwB,4BAqBpC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AlgorandFixture, AlgorandFixtureConfig } from '../../types/testing';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a test fixture for automated testing against Algorand.
|
|
4
|
+
* By default it tests against a default LocalNet instance, but you can pass in an algod and indexer if you want to test against, say, TestNet.
|
|
5
|
+
*
|
|
6
|
+
* @example ```typescript
|
|
7
|
+
* const algorand = algorandFixture()
|
|
8
|
+
*
|
|
9
|
+
* beforeEach(algorand.beforeEach, 10_000)
|
|
10
|
+
*
|
|
11
|
+
* test('My test', () => {
|
|
12
|
+
* const {algod, indexer, testAccount, ...} = algorand.context
|
|
13
|
+
* })
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @param fixtureConfig The fixture configuration
|
|
17
|
+
* @returns The fixture
|
|
18
|
+
*/
|
|
19
|
+
export declare const algorandFixture: (fixtureConfig?: AlgorandFixtureConfig) => AlgorandFixture;
|
|
20
|
+
//# sourceMappingURL=algorand-fixture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"algorand-fixture.d.ts","sourceRoot":"","sources":["../../../src/testing/fixtures/algorand-fixture.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAuD,MAAM,qBAAqB,CAAA;AAEjI;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,eAAe,mBAAoB,qBAAqB,KAAG,eA0BvE,CAAA"}
|