@algorandfoundation/algokit-utils 6.1.0-beta.1 → 6.1.0-beta.3
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 +8 -0
- package/account/account.d.ts +24 -3
- package/account/account.d.ts.map +1 -1
- package/account/account.js +29 -53
- package/account/account.js.map +1 -1
- package/account/account.mjs +29 -53
- package/account/account.mjs.map +1 -1
- package/account/get-account.d.ts +2 -2
- package/account/get-account.d.ts.map +1 -1
- package/account/get-account.js +9 -29
- package/account/get-account.js.map +1 -1
- package/account/get-account.mjs +4 -24
- package/account/get-account.mjs.map +1 -1
- package/account/get-dispenser-account.d.ts +7 -2
- package/account/get-dispenser-account.d.ts.map +1 -1
- package/account/get-dispenser-account.js +7 -8
- package/account/get-dispenser-account.js.map +1 -1
- package/account/get-dispenser-account.mjs +7 -8
- package/account/get-dispenser-account.mjs.map +1 -1
- package/account/mnemonic-account.d.ts +4 -1
- package/account/mnemonic-account.d.ts.map +1 -1
- package/account/mnemonic-account.js +4 -1
- package/account/mnemonic-account.js.map +1 -1
- package/account/mnemonic-account.mjs +4 -1
- package/account/mnemonic-account.mjs.map +1 -1
- package/dispenser-client.d.ts +2 -0
- package/dispenser-client.d.ts.map +1 -1
- package/dispenser-client.js +2 -0
- package/dispenser-client.js.map +1 -1
- package/dispenser-client.mjs +2 -0
- package/dispenser-client.mjs.map +1 -1
- package/index.d.ts +7 -7
- package/index.d.ts.map +1 -1
- package/index.js +31 -31
- package/index.mjs +9 -9
- package/localnet/get-kmd-wallet-account.d.ts +2 -0
- package/localnet/get-kmd-wallet-account.d.ts.map +1 -1
- package/localnet/get-kmd-wallet-account.js +5 -30
- package/localnet/get-kmd-wallet-account.js.map +1 -1
- package/localnet/get-kmd-wallet-account.mjs +5 -30
- package/localnet/get-kmd-wallet-account.mjs.map +1 -1
- package/localnet/get-localnet-dispenser-account.d.ts +2 -0
- package/localnet/get-localnet-dispenser-account.d.ts.map +1 -1
- package/localnet/get-localnet-dispenser-account.js +5 -7
- package/localnet/get-localnet-dispenser-account.js.map +1 -1
- package/localnet/get-localnet-dispenser-account.mjs +5 -7
- package/localnet/get-localnet-dispenser-account.mjs.map +1 -1
- package/localnet/get-or-create-kmd-wallet-account.d.ts +2 -0
- package/localnet/get-or-create-kmd-wallet-account.d.ts.map +1 -1
- package/localnet/get-or-create-kmd-wallet-account.js +5 -27
- package/localnet/get-or-create-kmd-wallet-account.js.map +1 -1
- package/localnet/get-or-create-kmd-wallet-account.mjs +5 -27
- package/localnet/get-or-create-kmd-wallet-account.mjs.map +1 -1
- package/localnet/is-localnet.d.ts +4 -1
- package/localnet/is-localnet.d.ts.map +1 -1
- package/localnet/is-localnet.js +7 -3
- package/localnet/is-localnet.js.map +1 -1
- package/localnet/is-localnet.mjs +7 -3
- package/localnet/is-localnet.mjs.map +1 -1
- package/network-client.d.ts +36 -8
- package/network-client.d.ts.map +1 -1
- package/network-client.js +49 -88
- package/network-client.js.map +1 -1
- package/network-client.mjs +49 -88
- package/network-client.mjs.map +1 -1
- package/package.json +3 -2
- package/testing/account.d.ts +3 -5
- package/testing/account.d.ts.map +1 -1
- package/testing/account.js +6 -9
- package/testing/account.js.map +1 -1
- package/testing/account.mjs +6 -9
- package/testing/account.mjs.map +1 -1
- package/testing/fixtures/algorand-fixture.d.ts +20 -2
- package/testing/fixtures/algorand-fixture.d.ts.map +1 -1
- package/testing/fixtures/algorand-fixture.js +11 -30
- package/testing/fixtures/algorand-fixture.js.map +1 -1
- package/testing/fixtures/algorand-fixture.mjs +11 -30
- package/testing/fixtures/algorand-fixture.mjs.map +1 -1
- package/transaction/transaction.d.ts.map +1 -1
- package/transaction/transaction.js +8 -8
- package/transaction/transaction.js.map +1 -1
- package/transaction/transaction.mjs +8 -8
- package/transaction/transaction.mjs.map +1 -1
- package/transfer/transfer.js +4 -4
- package/transfer/transfer.js.map +1 -1
- package/transfer/transfer.mjs +4 -4
- package/transfer/transfer.mjs.map +1 -1
- package/types/account-manager.d.ts +108 -24
- package/types/account-manager.d.ts.map +1 -1
- package/types/account-manager.js +167 -34
- package/types/account-manager.js.map +1 -1
- package/types/account-manager.mjs +166 -34
- package/types/account-manager.mjs.map +1 -1
- package/types/account.d.ts +13 -11
- package/types/account.d.ts.map +1 -1
- package/types/algorand-client.d.ts +12 -6
- package/types/algorand-client.d.ts.map +1 -1
- package/types/algorand-client.js +20 -15
- package/types/algorand-client.js.map +1 -1
- package/types/algorand-client.mjs +20 -15
- package/types/algorand-client.mjs.map +1 -1
- package/types/client-manager.d.ts +197 -4
- package/types/client-manager.d.ts.map +1 -1
- package/types/client-manager.js +284 -7
- package/types/client-manager.js.map +1 -1
- package/types/client-manager.mjs +284 -7
- package/types/client-manager.mjs.map +1 -1
- package/types/indexer.d.ts +11 -2
- package/types/indexer.d.ts.map +1 -1
- package/types/indexer.js.map +1 -1
- package/types/indexer.mjs.map +1 -1
- package/types/kmd-account-manager.d.ts +70 -0
- package/types/kmd-account-manager.d.ts.map +1 -0
- package/types/kmd-account-manager.js +144 -0
- package/types/kmd-account-manager.js.map +1 -0
- package/types/kmd-account-manager.mjs +142 -0
- package/types/kmd-account-manager.mjs.map +1 -0
- package/types/network-client.d.ts +2 -2
- package/types/network-client.d.ts.map +1 -1
- package/types/testing.d.ts +9 -6
- package/types/testing.d.ts.map +1 -1
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var transferAlgos = require('../transfer/transfer-algos.js');
|
|
6
|
-
var types_amount = require('../types/amount.js');
|
|
7
|
-
var getKmdWalletAccount = require('./get-kmd-wallet-account.js');
|
|
8
|
-
var getLocalnetDispenserAccount = require('./get-localnet-dispenser-account.js');
|
|
3
|
+
var types_clientManager = require('../types/client-manager.js');
|
|
4
|
+
var types_kmdAccountManager = require('../types/kmd-account-manager.js');
|
|
9
5
|
|
|
10
6
|
/**
|
|
7
|
+
* @deprecated use `algorandClient.account.kmd.getOrCreateWalletAccount(name, fundWith)` or `new KMDAccountManager(clientManager).getOrCreateWalletAccount(name, fundWith)` instead.
|
|
8
|
+
*
|
|
11
9
|
* 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.
|
|
12
10
|
*
|
|
13
11
|
* This is useful to get idempotent accounts from LocalNet without having to specify the private key (which will change when resetting the LocalNet).
|
|
@@ -25,27 +23,7 @@ var getLocalnetDispenserAccount = require('./get-localnet-dispenser-account.js')
|
|
|
25
23
|
* @returns An Algorand account with private key loaded - either one that already existed in the given KMD wallet, or a new one that is funded for you
|
|
26
24
|
*/
|
|
27
25
|
async function getOrCreateKmdWalletAccount(walletAccount, algod, kmdClient) {
|
|
28
|
-
|
|
29
|
-
// Get an existing account from the KMD wallet
|
|
30
|
-
const existing = await getKmdWalletAccount.getKmdWalletAccount(walletAccount, algod, kmd);
|
|
31
|
-
if (existing) {
|
|
32
|
-
return existing;
|
|
33
|
-
}
|
|
34
|
-
// None existed: create the KMD wallet instead
|
|
35
|
-
const walletId = (await kmd.createWallet(walletAccount.name, '')).wallet.id;
|
|
36
|
-
const walletHandle = (await kmd.initWalletHandle(walletId, '')).wallet_handle_token;
|
|
37
|
-
await kmd.generateKey(walletHandle);
|
|
38
|
-
// Get the account from the new KMD wallet
|
|
39
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
40
|
-
const account = (await getKmdWalletAccount.getKmdWalletAccount(walletAccount, algod, kmd));
|
|
41
|
-
config.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`);
|
|
42
|
-
// Fund the account from the dispenser
|
|
43
|
-
await transferAlgos.transferAlgos({
|
|
44
|
-
amount: walletAccount.fundWith ?? types_amount.AlgoAmount.Algos(1000),
|
|
45
|
-
from: await getLocalnetDispenserAccount.getLocalNetDispenserAccount(algod, kmd),
|
|
46
|
-
to: account.addr,
|
|
47
|
-
}, algod);
|
|
48
|
-
return account;
|
|
26
|
+
return (await new types_kmdAccountManager.KmdAccountManager(new types_clientManager.ClientManager({ algod, kmd: kmdClient })).getOrCreateWalletAccount(walletAccount.name, walletAccount.fundWith)).account;
|
|
49
27
|
}
|
|
50
28
|
|
|
51
29
|
exports.getOrCreateKmdWalletAccount = getOrCreateKmdWalletAccount;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-or-create-kmd-wallet-account.js","sources":["../../src/localnet/get-or-create-kmd-wallet-account.ts"],"sourcesContent":[null],"names":["
|
|
1
|
+
{"version":3,"file":"get-or-create-kmd-wallet-account.js","sources":["../../src/localnet/get-or-create-kmd-wallet-account.ts"],"sourcesContent":[null],"names":["KmdAccountManager","ClientManager"],"mappings":";;;;;AAQA;;;;;;;;;;;;;;;;;;AAkBG;AACI,eAAe,2BAA2B,CAC/C,aAAsD,EACtD,KAAc,EACd,SAAe,EAAA;AAEf,IAAA,OAAO,CACL,MAAM,IAAIA,yCAAiB,CAAC,IAAIC,iCAAa,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,wBAAwB,CAChG,aAAa,CAAC,IAAI,EAClB,aAAa,CAAC,QAAQ,CACvB,EACD,OAAO,CAAA;AACX;;;;"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { transferAlgos } from '../transfer/transfer-algos.mjs';
|
|
4
|
-
import { AlgoAmount } from '../types/amount.mjs';
|
|
5
|
-
import { getKmdWalletAccount } from './get-kmd-wallet-account.mjs';
|
|
6
|
-
import { getLocalNetDispenserAccount } from './get-localnet-dispenser-account.mjs';
|
|
1
|
+
import { ClientManager } from '../types/client-manager.mjs';
|
|
2
|
+
import { KmdAccountManager } from '../types/kmd-account-manager.mjs';
|
|
7
3
|
|
|
8
4
|
/**
|
|
5
|
+
* @deprecated use `algorandClient.account.kmd.getOrCreateWalletAccount(name, fundWith)` or `new KMDAccountManager(clientManager).getOrCreateWalletAccount(name, fundWith)` instead.
|
|
6
|
+
*
|
|
9
7
|
* 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.
|
|
10
8
|
*
|
|
11
9
|
* This is useful to get idempotent accounts from LocalNet without having to specify the private key (which will change when resetting the LocalNet).
|
|
@@ -23,27 +21,7 @@ import { getLocalNetDispenserAccount } from './get-localnet-dispenser-account.mj
|
|
|
23
21
|
* @returns An Algorand account with private key loaded - either one that already existed in the given KMD wallet, or a new one that is funded for you
|
|
24
22
|
*/
|
|
25
23
|
async function getOrCreateKmdWalletAccount(walletAccount, algod, kmdClient) {
|
|
26
|
-
|
|
27
|
-
// Get an existing account from the KMD wallet
|
|
28
|
-
const existing = await getKmdWalletAccount(walletAccount, algod, kmd);
|
|
29
|
-
if (existing) {
|
|
30
|
-
return existing;
|
|
31
|
-
}
|
|
32
|
-
// None existed: create the KMD wallet instead
|
|
33
|
-
const walletId = (await kmd.createWallet(walletAccount.name, '')).wallet.id;
|
|
34
|
-
const walletHandle = (await kmd.initWalletHandle(walletId, '')).wallet_handle_token;
|
|
35
|
-
await kmd.generateKey(walletHandle);
|
|
36
|
-
// Get the account from the new KMD wallet
|
|
37
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
38
|
-
const account = (await getKmdWalletAccount(walletAccount, algod, kmd));
|
|
39
|
-
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`);
|
|
40
|
-
// Fund the account from the dispenser
|
|
41
|
-
await transferAlgos({
|
|
42
|
-
amount: walletAccount.fundWith ?? AlgoAmount.Algos(1000),
|
|
43
|
-
from: await getLocalNetDispenserAccount(algod, kmd),
|
|
44
|
-
to: account.addr,
|
|
45
|
-
}, algod);
|
|
46
|
-
return account;
|
|
24
|
+
return (await new KmdAccountManager(new ClientManager({ algod, kmd: kmdClient })).getOrCreateWalletAccount(walletAccount.name, walletAccount.fundWith)).account;
|
|
47
25
|
}
|
|
48
26
|
|
|
49
27
|
export { getOrCreateKmdWalletAccount };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-or-create-kmd-wallet-account.mjs","sources":["../../src/localnet/get-or-create-kmd-wallet-account.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-or-create-kmd-wallet-account.mjs","sources":["../../src/localnet/get-or-create-kmd-wallet-account.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAQA;;;;;;;;;;;;;;;;;;AAkBG;AACI,eAAe,2BAA2B,CAC/C,aAAsD,EACtD,KAAc,EACd,SAAe,EAAA;AAEf,IAAA,OAAO,CACL,MAAM,IAAI,iBAAiB,CAAC,IAAI,aAAa,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,wBAAwB,CAChG,aAAa,CAAC,IAAI,EAClB,aAAa,CAAC,QAAQ,CACvB,EACD,OAAO,CAAA;AACX;;;;"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import algosdk from 'algosdk';
|
|
2
2
|
import Algodv2 = algosdk.Algodv2;
|
|
3
|
-
/**
|
|
3
|
+
/** @deprecated Use `await algorandClient.client.isLocalNet()` or `await new ClientManager({ algod }).isLocalNet()` instead.
|
|
4
|
+
*
|
|
5
|
+
* Returns true if the algod client is pointing to a LocalNet Algorand network
|
|
6
|
+
*/
|
|
4
7
|
export declare function isLocalNet(algod: Algodv2): Promise<boolean>;
|
|
5
8
|
//# sourceMappingURL=is-localnet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-localnet.d.ts","sourceRoot":"","sources":["../../src/localnet/is-localnet.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"is-localnet.d.ts","sourceRoot":"","sources":["../../src/localnet/is-localnet.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAA;AAE7B,OAAO,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;AAEhC;;;GAGG;AACH,wBAAsB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAEjE"}
|
package/localnet/is-localnet.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
var types_clientManager = require('../types/client-manager.js');
|
|
4
|
+
|
|
5
|
+
/** @deprecated Use `await algorandClient.client.isLocalNet()` or `await new ClientManager({ algod }).isLocalNet()` instead.
|
|
6
|
+
*
|
|
7
|
+
* Returns true if the algod client is pointing to a LocalNet Algorand network
|
|
8
|
+
*/
|
|
4
9
|
async function isLocalNet(algod) {
|
|
5
|
-
|
|
6
|
-
return params.genesisID === 'devnet-v1' || params.genesisID === 'sandnet-v1' || params.genesisID === 'dockernet-v1';
|
|
10
|
+
return await new types_clientManager.ClientManager({ algod }).isLocalNet();
|
|
7
11
|
}
|
|
8
12
|
|
|
9
13
|
exports.isLocalNet = isLocalNet;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-localnet.js","sources":["../../src/localnet/is-localnet.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"is-localnet.js","sources":["../../src/localnet/is-localnet.ts"],"sourcesContent":[null],"names":["ClientManager"],"mappings":";;;;AAIA;;;AAGG;AACI,eAAe,UAAU,CAAC,KAAc,EAAA;IAC7C,OAAO,MAAM,IAAIA,iCAAa,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,UAAU,EAAE,CAAA;AACxD;;;;"}
|
package/localnet/is-localnet.mjs
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { ClientManager } from '../types/client-manager.mjs';
|
|
2
|
+
|
|
3
|
+
/** @deprecated Use `await algorandClient.client.isLocalNet()` or `await new ClientManager({ algod }).isLocalNet()` instead.
|
|
4
|
+
*
|
|
5
|
+
* Returns true if the algod client is pointing to a LocalNet Algorand network
|
|
6
|
+
*/
|
|
2
7
|
async function isLocalNet(algod) {
|
|
3
|
-
|
|
4
|
-
return params.genesisID === 'devnet-v1' || params.genesisID === 'sandnet-v1' || params.genesisID === 'dockernet-v1';
|
|
8
|
+
return await new ClientManager({ algod }).isLocalNet();
|
|
5
9
|
}
|
|
6
10
|
|
|
7
11
|
export { isLocalNet };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-localnet.mjs","sources":["../../src/localnet/is-localnet.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"is-localnet.mjs","sources":["../../src/localnet/is-localnet.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAIA;;;AAGG;AACI,eAAe,UAAU,CAAC,KAAc,EAAA;IAC7C,OAAO,MAAM,IAAI,aAAa,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,UAAU,EAAE,CAAA;AACxD;;;;"}
|
package/network-client.d.ts
CHANGED
|
@@ -4,24 +4,45 @@ import Algodv2 = algosdk.Algodv2;
|
|
|
4
4
|
import Indexer = algosdk.Indexer;
|
|
5
5
|
import Kmd = algosdk.Kmd;
|
|
6
6
|
import IntDecoding = algosdk.IntDecoding;
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated Use `ClientManager.getConfigFromEnvironmentOrLocalNet()` instead.
|
|
9
|
+
*
|
|
10
|
+
* Retrieve configurations from environment variables when defined or get defaults (expects to be called from a Node.js environment not algod-side)
|
|
11
|
+
*/
|
|
8
12
|
export declare function getConfigFromEnvOrDefaults(): AlgoConfig;
|
|
9
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Use `ClientManager.getAlgodConfigFromEnvironment()` instead.
|
|
15
|
+
*
|
|
16
|
+
* Retrieve the algod configuration from environment variables (expects to be called from a Node.js environment not algod-side)
|
|
17
|
+
*/
|
|
10
18
|
export declare function getAlgodConfigFromEnvironment(): AlgoClientConfig;
|
|
11
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated Use `ClientManager.getIndexerConfigFromEnvironment()` instead.
|
|
21
|
+
*
|
|
22
|
+
* Retrieve the indexer configuration from environment variables (expects to be called from a Node.js environment not algod-side)
|
|
23
|
+
*/
|
|
12
24
|
export declare function getIndexerConfigFromEnvironment(): AlgoClientConfig;
|
|
13
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated Use `ClientManager.getAlgoNodeConfig(network, config)` instead.
|
|
27
|
+
*
|
|
28
|
+
* Returns the Algorand configuration to point to the AlgoNode service
|
|
14
29
|
*
|
|
15
30
|
* @param network Which network to connect to - TestNet or MainNet
|
|
16
31
|
* @param config Which algod config to return - Algod or Indexer
|
|
17
32
|
*/
|
|
18
33
|
export declare function getAlgoNodeConfig(network: 'testnet' | 'mainnet', config: 'algod' | 'indexer'): AlgoClientConfig;
|
|
19
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* @deprecated Use `ClientManager.getDefaultLocalNetConfig(configOrPort)` instead.
|
|
36
|
+
*
|
|
37
|
+
* Returns the Algorand configuration to point to the default LocalNet
|
|
20
38
|
*
|
|
21
39
|
* @param configOrPort Which algod config to return - algod, kmd, or indexer OR a port number
|
|
22
40
|
*/
|
|
23
41
|
export declare function getDefaultLocalNetConfig(configOrPort: 'algod' | 'indexer' | 'kmd' | number): AlgoClientConfig;
|
|
24
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* @deprecated Use `ClientManager.getAlgodClient(config)` or `ClientManager.getAlgodClientFromEnvironment()` instead.
|
|
44
|
+
*
|
|
45
|
+
* Returns an algod SDK client that automatically retries transient failures on idempotent calls
|
|
25
46
|
*
|
|
26
47
|
* @param config The config if you want to override the default (getting config from process.env)
|
|
27
48
|
* @example Default (load from environment variables)
|
|
@@ -49,7 +70,10 @@ export declare function getDefaultLocalNetConfig(configOrPort: 'algod' | 'indexe
|
|
|
49
70
|
* ```
|
|
50
71
|
*/
|
|
51
72
|
export declare function getAlgoClient(config?: AlgoClientConfig): Algodv2;
|
|
52
|
-
/**
|
|
73
|
+
/**
|
|
74
|
+
* @deprecated Use `ClientManager.getIndexerClient(config, overrideIntDecoding)` or `ClientManager.getIndexerClientFromEnvironment(overrideIntDecoding)` instead.
|
|
75
|
+
*
|
|
76
|
+
* Returns an indexer SDK client that automatically retries transient failures on idempotent calls
|
|
53
77
|
*
|
|
54
78
|
* @param config The config if you want to override the default (getting config from process.env)
|
|
55
79
|
* @param overrideIntDecoding Override the default int decoding for responses, uses MIXED by default to avoid lost precision for big integers
|
|
@@ -82,7 +106,9 @@ export declare function getAlgoClient(config?: AlgoClientConfig): Algodv2;
|
|
|
82
106
|
*/
|
|
83
107
|
export declare function getAlgoIndexerClient(config?: AlgoClientConfig, overrideIntDecoding?: IntDecoding): Indexer;
|
|
84
108
|
/**
|
|
85
|
-
*
|
|
109
|
+
* @deprecated Use `ClientManager.getKmdClient(config)` or `ClientManager.getKmdClientFromEnvironment()` instead.
|
|
110
|
+
*
|
|
111
|
+
* Returns a KMD SDK client that automatically retries transient failures on idempotent calls.
|
|
86
112
|
*
|
|
87
113
|
* KMD client allows you to export private keys, which is useful to get the default account in a LocalNet network.
|
|
88
114
|
*
|
|
@@ -99,6 +125,8 @@ export declare function getAlgoIndexerClient(config?: AlgoClientConfig, override
|
|
|
99
125
|
* ```
|
|
100
126
|
*/
|
|
101
127
|
export declare function getAlgoKmdClient(config?: AlgoClientConfig): Kmd;
|
|
128
|
+
/** @deprecated Use `await algorandClient.client.isTestNet()` or `await new ClientManager({ algod }).isTestNet()` instead. */
|
|
102
129
|
export declare function isTestNet(algod: Algodv2): Promise<boolean>;
|
|
130
|
+
/** @deprecated Use `await algorandClient.client.isMainNet()` or `await new ClientManager({ algod }).isMainNet()` instead. */
|
|
103
131
|
export declare function isMainNet(algod: Algodv2): Promise<boolean>;
|
|
104
132
|
//# sourceMappingURL=network-client.d.ts.map
|
package/network-client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network-client.d.ts","sourceRoot":"","sources":["../src/network-client.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"network-client.d.ts","sourceRoot":"","sources":["../src/network-client.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAA;AAE7B,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACrE,OAAO,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;AAChC,OAAO,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;AAChC,OAAO,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;AACxB,OAAO,WAAW,GAAG,OAAO,CAAC,WAAW,CAAA;AAExC;;;;GAIG;AACH,wBAAgB,0BAA0B,IAAI,UAAU,CAEvD;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,IAAI,gBAAgB,CAEhE;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,IAAI,gBAAgB,CAElE;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,SAAS,GAAG,SAAS,EAAE,MAAM,EAAE,OAAO,GAAG,SAAS,GAAG,gBAAgB,CAE/G;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,YAAY,EAAE,OAAO,GAAG,SAAS,GAAG,KAAK,GAAG,MAAM,GAAG,gBAAgB,CAE7G;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,aAAa,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAEhE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,CAAC,EAAE,gBAAgB,EAAE,mBAAmB,CAAC,EAAE,WAAW,GAAG,OAAO,CAI1G;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,GAAG,CAE/D;AAED,6HAA6H;AAC7H,wBAAsB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAEhE;AAED,6HAA6H;AAC7H,wBAAsB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAEhE"}
|
package/network-client.js
CHANGED
|
@@ -1,92 +1,56 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var types_algoHttpClientWithRetry = require('./types/algo-http-client-with-retry.js');
|
|
3
|
+
var types_clientManager = require('./types/client-manager.js');
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Use `ClientManager.getConfigFromEnvironmentOrLocalNet()` instead.
|
|
7
|
+
*
|
|
8
|
+
* Retrieve configurations from environment variables when defined or get defaults (expects to be called from a Node.js environment not algod-side)
|
|
9
|
+
*/
|
|
10
10
|
function getConfigFromEnvOrDefaults() {
|
|
11
|
-
|
|
12
|
-
throw new Error('Attempt to get default algod configuration from a non Node.js context; supply the config instead');
|
|
13
|
-
}
|
|
14
|
-
const algodConfig = !process.env.ALGOD_SERVER
|
|
15
|
-
? getDefaultLocalNetConfig('algod')
|
|
16
|
-
: { server: process.env.ALGOD_SERVER, port: process.env.ALGOD_PORT, token: process.env.ALGOD_TOKEN };
|
|
17
|
-
const indexerConfig = !process.env.INDEXER_SERVER
|
|
18
|
-
? getDefaultLocalNetConfig('indexer')
|
|
19
|
-
: {
|
|
20
|
-
server: process.env.INDEXER_SERVER,
|
|
21
|
-
port: process.env.INDEXER_PORT,
|
|
22
|
-
token: process.env.INDEXER_TOKEN,
|
|
23
|
-
};
|
|
24
|
-
return {
|
|
25
|
-
algodConfig,
|
|
26
|
-
indexerConfig,
|
|
27
|
-
kmdConfig: process && process.env && process.env.ALGOD_SERVER
|
|
28
|
-
? { ...algodConfig, port: process?.env?.KMD_PORT ?? '4002' }
|
|
29
|
-
: getDefaultLocalNetConfig('kmd'),
|
|
30
|
-
};
|
|
11
|
+
return types_clientManager.ClientManager.getConfigFromEnvironmentOrLocalNet();
|
|
31
12
|
}
|
|
32
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Use `ClientManager.getAlgodConfigFromEnvironment()` instead.
|
|
15
|
+
*
|
|
16
|
+
* Retrieve the algod configuration from environment variables (expects to be called from a Node.js environment not algod-side)
|
|
17
|
+
*/
|
|
33
18
|
function getAlgodConfigFromEnvironment() {
|
|
34
|
-
|
|
35
|
-
throw new Error('Attempt to get default algod configuration from a non Node.js context; supply the config instead');
|
|
36
|
-
}
|
|
37
|
-
if (!process.env.ALGOD_SERVER) {
|
|
38
|
-
throw new Error('Attempt to get default algod configuration without specifying ALGOD_SERVER in the environment variables');
|
|
39
|
-
}
|
|
40
|
-
return {
|
|
41
|
-
server: process.env.ALGOD_SERVER,
|
|
42
|
-
port: process.env.ALGOD_PORT,
|
|
43
|
-
token: process.env.ALGOD_TOKEN,
|
|
44
|
-
};
|
|
19
|
+
return types_clientManager.ClientManager.getAlgodConfigFromEnvironment();
|
|
45
20
|
}
|
|
46
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated Use `ClientManager.getIndexerConfigFromEnvironment()` instead.
|
|
23
|
+
*
|
|
24
|
+
* Retrieve the indexer configuration from environment variables (expects to be called from a Node.js environment not algod-side)
|
|
25
|
+
*/
|
|
47
26
|
function getIndexerConfigFromEnvironment() {
|
|
48
|
-
|
|
49
|
-
throw new Error('Attempt to get default indexer configuration from a non Node.js context; supply the config instead');
|
|
50
|
-
}
|
|
51
|
-
if (!process.env.INDEXER_SERVER) {
|
|
52
|
-
throw new Error('Attempt to get default indexer configuration without specifying INDEXER_SERVER in the environment variables');
|
|
53
|
-
}
|
|
54
|
-
return {
|
|
55
|
-
server: process.env.INDEXER_SERVER,
|
|
56
|
-
port: process.env.INDEXER_PORT,
|
|
57
|
-
token: process.env.INDEXER_TOKEN,
|
|
58
|
-
};
|
|
27
|
+
return types_clientManager.ClientManager.getIndexerConfigFromEnvironment();
|
|
59
28
|
}
|
|
60
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* @deprecated Use `ClientManager.getAlgoNodeConfig(network, config)` instead.
|
|
31
|
+
*
|
|
32
|
+
* Returns the Algorand configuration to point to the AlgoNode service
|
|
61
33
|
*
|
|
62
34
|
* @param network Which network to connect to - TestNet or MainNet
|
|
63
35
|
* @param config Which algod config to return - Algod or Indexer
|
|
64
36
|
*/
|
|
65
37
|
function getAlgoNodeConfig(network, config) {
|
|
66
|
-
return
|
|
67
|
-
server: `https://${network}-${config === 'algod' ? 'api' : 'idx'}.algonode.cloud/`,
|
|
68
|
-
port: 443,
|
|
69
|
-
};
|
|
38
|
+
return types_clientManager.ClientManager.getAlgoNodeConfig(network, config);
|
|
70
39
|
}
|
|
71
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* @deprecated Use `ClientManager.getDefaultLocalNetConfig(configOrPort)` instead.
|
|
42
|
+
*
|
|
43
|
+
* Returns the Algorand configuration to point to the default LocalNet
|
|
72
44
|
*
|
|
73
45
|
* @param configOrPort Which algod config to return - algod, kmd, or indexer OR a port number
|
|
74
46
|
*/
|
|
75
47
|
function getDefaultLocalNetConfig(configOrPort) {
|
|
76
|
-
return
|
|
77
|
-
server: `http://localhost`,
|
|
78
|
-
port: configOrPort === 'algod' ? 4001 : configOrPort === 'indexer' ? 8980 : configOrPort === 'kmd' ? 4002 : configOrPort,
|
|
79
|
-
token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
|
|
80
|
-
};
|
|
48
|
+
return types_clientManager.ClientManager.getDefaultLocalNetConfig(configOrPort);
|
|
81
49
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
// Because we override the default HTTP Client construction (to get retries) we need to put a string token into the standard header ourselves
|
|
87
|
-
return typeof token === 'string' ? { [defaultHeader ?? 'X-Algo-API-Token']: token } : token ?? {};
|
|
88
|
-
}
|
|
89
|
-
/** Returns an algod SDK client that automatically retries on idempotent calls
|
|
50
|
+
/**
|
|
51
|
+
* @deprecated Use `ClientManager.getAlgodClient(config)` or `ClientManager.getAlgodClientFromEnvironment()` instead.
|
|
52
|
+
*
|
|
53
|
+
* Returns an algod SDK client that automatically retries transient failures on idempotent calls
|
|
90
54
|
*
|
|
91
55
|
* @param config The config if you want to override the default (getting config from process.env)
|
|
92
56
|
* @example Default (load from environment variables)
|
|
@@ -114,11 +78,12 @@ function getAlgoTokenHeader(server, token, defaultHeader) {
|
|
|
114
78
|
* ```
|
|
115
79
|
*/
|
|
116
80
|
function getAlgoClient(config) {
|
|
117
|
-
|
|
118
|
-
const httpClientWithRetry = new types_algoHttpClientWithRetry.AlgoHttpClientWithRetry(getAlgoTokenHeader(server, token), server, port);
|
|
119
|
-
return new algosdk.Algodv2(httpClientWithRetry, server);
|
|
81
|
+
return config ? types_clientManager.ClientManager.getAlgodClient(config) : types_clientManager.ClientManager.getAlgodClientFromEnvironment();
|
|
120
82
|
}
|
|
121
|
-
/**
|
|
83
|
+
/**
|
|
84
|
+
* @deprecated Use `ClientManager.getIndexerClient(config, overrideIntDecoding)` or `ClientManager.getIndexerClientFromEnvironment(overrideIntDecoding)` instead.
|
|
85
|
+
*
|
|
86
|
+
* Returns an indexer SDK client that automatically retries transient failures on idempotent calls
|
|
122
87
|
*
|
|
123
88
|
* @param config The config if you want to override the default (getting config from process.env)
|
|
124
89
|
* @param overrideIntDecoding Override the default int decoding for responses, uses MIXED by default to avoid lost precision for big integers
|
|
@@ -150,15 +115,14 @@ function getAlgoClient(config) {
|
|
|
150
115
|
* ```
|
|
151
116
|
*/
|
|
152
117
|
function getAlgoIndexerClient(config, overrideIntDecoding) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
// Use mixed int decoding by default so bigints don't have lost precision
|
|
157
|
-
indexer.setIntEncoding(overrideIntDecoding ?? IntDecoding.MIXED);
|
|
158
|
-
return indexer;
|
|
118
|
+
return config
|
|
119
|
+
? types_clientManager.ClientManager.getIndexerClient(config, overrideIntDecoding)
|
|
120
|
+
: types_clientManager.ClientManager.getIndexerClientFromEnvironment(overrideIntDecoding);
|
|
159
121
|
}
|
|
160
122
|
/**
|
|
161
|
-
*
|
|
123
|
+
* @deprecated Use `ClientManager.getKmdClient(config)` or `ClientManager.getKmdClientFromEnvironment()` instead.
|
|
124
|
+
*
|
|
125
|
+
* Returns a KMD SDK client that automatically retries transient failures on idempotent calls.
|
|
162
126
|
*
|
|
163
127
|
* KMD client allows you to export private keys, which is useful to get the default account in a LocalNet network.
|
|
164
128
|
*
|
|
@@ -175,18 +139,15 @@ function getAlgoIndexerClient(config, overrideIntDecoding) {
|
|
|
175
139
|
* ```
|
|
176
140
|
*/
|
|
177
141
|
function getAlgoKmdClient(config) {
|
|
178
|
-
|
|
179
|
-
// We can only use Kmd on the LocalNet otherwise it's not exposed so this makes some assumptions
|
|
180
|
-
// (e.g. same token and server as algod and port 4002 by default)
|
|
181
|
-
return new Kmd(token, server, process?.env?.KMD_PORT ?? '4002');
|
|
142
|
+
return config ? types_clientManager.ClientManager.getKmdClient(config) : types_clientManager.ClientManager.getKmdClientFromEnvironment();
|
|
182
143
|
}
|
|
144
|
+
/** @deprecated Use `await algorandClient.client.isTestNet()` or `await new ClientManager({ algod }).isTestNet()` instead. */
|
|
183
145
|
async function isTestNet(algod) {
|
|
184
|
-
|
|
185
|
-
return ['testnet-v1.0', 'testnet-v1', 'testnet'].includes(params.genesisID);
|
|
146
|
+
return await new types_clientManager.ClientManager({ algod }).isTestNet();
|
|
186
147
|
}
|
|
148
|
+
/** @deprecated Use `await algorandClient.client.isMainNet()` or `await new ClientManager({ algod }).isMainNet()` instead. */
|
|
187
149
|
async function isMainNet(algod) {
|
|
188
|
-
|
|
189
|
-
return ['mainnet-v1.0', 'mainnet-v1', 'mainnet'].includes(params.genesisID);
|
|
150
|
+
return await new types_clientManager.ClientManager({ algod }).isMainNet();
|
|
190
151
|
}
|
|
191
152
|
|
|
192
153
|
exports.getAlgoClient = getAlgoClient;
|
package/network-client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network-client.js","sources":["../src/network-client.ts"],"sourcesContent":[null],"names":["
|
|
1
|
+
{"version":3,"file":"network-client.js","sources":["../src/network-client.ts"],"sourcesContent":[null],"names":["ClientManager"],"mappings":";;;;AAQA;;;;AAIG;SACa,0BAA0B,GAAA;AACxC,IAAA,OAAOA,iCAAa,CAAC,kCAAkC,EAAE,CAAA;AAC3D,CAAC;AAED;;;;AAIG;SACa,6BAA6B,GAAA;AAC3C,IAAA,OAAOA,iCAAa,CAAC,6BAA6B,EAAE,CAAA;AACtD,CAAC;AAED;;;;AAIG;SACa,+BAA+B,GAAA;AAC7C,IAAA,OAAOA,iCAAa,CAAC,+BAA+B,EAAE,CAAA;AACxD,CAAC;AAED;;;;;;;AAOG;AACa,SAAA,iBAAiB,CAAC,OAA8B,EAAE,MAA2B,EAAA;IAC3F,OAAOA,iCAAa,CAAC,iBAAiB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;AACzD,CAAC;AAED;;;;;;AAMG;AACG,SAAU,wBAAwB,CAAC,YAAkD,EAAA;AACzF,IAAA,OAAOA,iCAAa,CAAC,wBAAwB,CAAC,YAAY,CAAC,CAAA;AAC7D,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BG;AACG,SAAU,aAAa,CAAC,MAAyB,EAAA;AACrD,IAAA,OAAO,MAAM,GAAGA,iCAAa,CAAC,cAAc,CAAC,MAAM,CAAC,GAAGA,iCAAa,CAAC,6BAA6B,EAAE,CAAA;AACtG,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCG;AACa,SAAA,oBAAoB,CAAC,MAAyB,EAAE,mBAAiC,EAAA;AAC/F,IAAA,OAAO,MAAM;UACTA,iCAAa,CAAC,gBAAgB,CAAC,MAAM,EAAE,mBAAmB,CAAC;AAC7D,UAAEA,iCAAa,CAAC,+BAA+B,CAAC,mBAAmB,CAAC,CAAA;AACxE,CAAC;AAED;;;;;;;;;;;;;;;;;;AAkBG;AACG,SAAU,gBAAgB,CAAC,MAAyB,EAAA;AACxD,IAAA,OAAO,MAAM,GAAGA,iCAAa,CAAC,YAAY,CAAC,MAAM,CAAC,GAAGA,iCAAa,CAAC,2BAA2B,EAAE,CAAA;AAClG,CAAC;AAED;AACO,eAAe,SAAS,CAAC,KAAc,EAAA;IAC5C,OAAO,MAAM,IAAIA,iCAAa,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,SAAS,EAAE,CAAA;AACvD,CAAC;AAED;AACO,eAAe,SAAS,CAAC,KAAc,EAAA;IAC5C,OAAO,MAAM,IAAIA,iCAAa,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,SAAS,EAAE,CAAA;AACvD;;;;;;;;;;;;;"}
|