@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
package/README.md
CHANGED
|
@@ -16,6 +16,14 @@ This library can be installed from NPM using your favourite npm client, e.g.:
|
|
|
16
16
|
npm install @algorandfoundation/algokit-utils
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
+
Then to import it:
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { AlgorandClient, Config } from '@algorandfoundation/algokit-utils'
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
See [usage](./docs/README.md#usage) for more.
|
|
26
|
+
|
|
19
27
|
## Guiding principles
|
|
20
28
|
|
|
21
29
|
This library follows the [Guiding Principles of AlgoKit](https://github.com/algorandfoundation/algokit-cli/blob/main/docs/algokit.md#guiding-principles).
|
package/account/account.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ import Kmd = algosdk.Kmd;
|
|
|
8
8
|
import MultisigMetadata = algosdk.MultisigMetadata;
|
|
9
9
|
import TransactionSigner = algosdk.TransactionSigner;
|
|
10
10
|
/**
|
|
11
|
+
* @deprecated Use `algorandClient.account.multisig(multisigParams, signingAccounts)` or `new MultisigAccount(multisigParams, signingAccounts)` instead.
|
|
12
|
+
*
|
|
11
13
|
* Returns an account wrapper that supports partial or full multisig signing.
|
|
12
14
|
* @param multisigParams The parameters that define the multisig account
|
|
13
15
|
* @param signingAccounts The signers that are currently present
|
|
@@ -15,6 +17,8 @@ import TransactionSigner = algosdk.TransactionSigner;
|
|
|
15
17
|
*/
|
|
16
18
|
export declare function multisigAccount(multisigParams: MultisigMetadata, signingAccounts: (Account | SigningAccount)[]): MultisigAccount;
|
|
17
19
|
/**
|
|
20
|
+
* @deprecated Use `algorandClient.account.rekeyed(account, sender)` or `new SigningAccount(account, sender)` instead.
|
|
21
|
+
*
|
|
18
22
|
* Returns an account wrapper that supports a rekeyed account.
|
|
19
23
|
* @param signer The account, with private key loaded, that is signing
|
|
20
24
|
* @param sender The address of the rekeyed account that will act as a sender
|
|
@@ -22,19 +26,26 @@ export declare function multisigAccount(multisigParams: MultisigMetadata, signin
|
|
|
22
26
|
*/
|
|
23
27
|
export declare function rekeyedAccount(signer: Account, sender: string): SigningAccount;
|
|
24
28
|
/**
|
|
29
|
+
* @deprecated Use `algorandClient.account.getSigner(sender)` (after previously registering the signer with `setSigner`) or `{ addr: sender, signer }` instead.
|
|
30
|
+
*
|
|
25
31
|
* Returns an account wrapper that supports a transaction signer with associated sender address.
|
|
26
32
|
* @param signer The transaction signer
|
|
27
33
|
* @param sender The address of sender account
|
|
28
34
|
* @returns The SigningAccount wrapper
|
|
29
35
|
*/
|
|
30
36
|
export declare function transactionSignerAccount(signer: TransactionSigner, sender: string): TransactionSignerAccount;
|
|
31
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* @deprecated Use `algorandClient.account.random()` or `algosdk.generateAccount()` instead.
|
|
39
|
+
*
|
|
40
|
+
* Returns a new, random Algorand account with secret key loaded.
|
|
32
41
|
*
|
|
33
42
|
* This is a wrapper around algosdk.generateAccount to provide a more friendly/obvious name.
|
|
34
43
|
*
|
|
35
44
|
*/
|
|
36
45
|
export declare function randomAccount(): Account;
|
|
37
46
|
/**
|
|
47
|
+
* @deprecated Use `algorandClient.account.fromEnvironment(name, fundWith)` or `new AccountManager(clientManager).fromEnvironment()` instead.
|
|
48
|
+
*
|
|
38
49
|
* Returns an Algorand account with private key loaded by convention from environment variables based on the given name identifier.
|
|
39
50
|
*
|
|
40
51
|
* Note: This function expects to run in a Node.js environment.
|
|
@@ -68,17 +79,25 @@ export declare function mnemonicAccountFromEnvironment(account: string | {
|
|
|
68
79
|
name: string;
|
|
69
80
|
fundWith?: AlgoAmount;
|
|
70
81
|
}, algod: Algodv2, kmdClient?: Kmd): Promise<Account | SigningAccount>;
|
|
71
|
-
/**
|
|
82
|
+
/**
|
|
83
|
+
* @deprecated Use `algosdk.decodeAddress` instead.
|
|
84
|
+
*
|
|
85
|
+
* Returns an account's address as a byte array
|
|
72
86
|
*
|
|
73
87
|
* @param account Either an account (with private key loaded) or the string address of an account
|
|
74
88
|
*/
|
|
75
89
|
export declare function getAccountAddressAsUint8Array(account: SendTransactionFrom | string): Uint8Array;
|
|
76
|
-
/**
|
|
90
|
+
/**
|
|
91
|
+
* @deprecated Use `algosdk.encodeAddress` instead.
|
|
92
|
+
*
|
|
93
|
+
* Returns the string address of an Algorand account from a base64 encoded version of the underlying byte array of the address public key
|
|
77
94
|
*
|
|
78
95
|
* @param addressEncodedInB64 The base64 encoded version of the underlying byte array of the address public key
|
|
79
96
|
*/
|
|
80
97
|
export declare function getAccountAddressAsString(addressEncodedInB64: string): string;
|
|
81
98
|
/**
|
|
99
|
+
* @deprecated Use `algorandClient.account.getInformation(sender)` or `new AccountManager(clientManager).getInformation(sender)` instead.
|
|
100
|
+
*
|
|
82
101
|
* Returns the given sender account's current status, balance and spendable amounts.
|
|
83
102
|
*
|
|
84
103
|
* @example
|
|
@@ -94,6 +113,8 @@ export declare function getAccountAddressAsString(addressEncodedInB64: string):
|
|
|
94
113
|
*/
|
|
95
114
|
export declare function getAccountInformation(sender: string | SendTransactionFrom, algod: Algodv2): Promise<AccountInformation>;
|
|
96
115
|
/**
|
|
116
|
+
* @deprecated Use `algorandClient.account.getAssetInformation(sender, assetId)` or `new AccountManager(clientManager).getAssetInformation(sender, assetId)` instead.
|
|
117
|
+
*
|
|
97
118
|
* Returns the given sender account's asset holding for a given asset.
|
|
98
119
|
*
|
|
99
120
|
* @example
|
package/account/account.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../src/account/account.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../src/account/account.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAA;AAE7B,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,eAAe,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAA;AAEzI,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAC1D,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,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAA;AAClD,OAAO,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAA;AAEpD;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,cAAc,EAAE,gBAAgB,EAAE,eAAe,EAAE,CAAC,OAAO,GAAG,cAAc,CAAC,EAAE,mBAE9G;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAE7D;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,GAAG,wBAAwB,CAE5G;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAGvC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAsB,8BAA8B,CAClD,OAAO,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,UAAU,CAAA;CAAE,EACzD,KAAK,EAAE,OAAO,EACd,SAAS,CAAC,EAAE,GAAG,GACd,OAAO,CAAC,OAAO,GAAG,cAAc,CAAC,CAOnC;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,cAElF;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,mBAAmB,EAAE,MAAM,GAAG,MAAM,CAE7E;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,mBAAmB,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAE7H;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,MAAM,GAAG,mBAAmB,EACpC,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,uBAAuB,CAAC,CAElC"}
|
package/account/account.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var algosdk = require('algosdk');
|
|
4
|
-
var config = require('../config.js');
|
|
5
|
-
var getOrCreateKmdWalletAccount = require('../localnet/get-or-create-kmd-wallet-account.js');
|
|
6
|
-
var isLocalnet = require('../localnet/is-localnet.js');
|
|
7
4
|
var transaction = require('../transaction/transaction.js');
|
|
8
5
|
var types_account = require('../types/account.js');
|
|
9
|
-
var
|
|
10
|
-
var
|
|
6
|
+
var types_accountManager = require('../types/account-manager.js');
|
|
7
|
+
var types_clientManager = require('../types/client-manager.js');
|
|
11
8
|
|
|
12
|
-
var AccountInformationModel = algosdk.modelsv2.Account;
|
|
13
9
|
/**
|
|
10
|
+
* @deprecated Use `algorandClient.account.multisig(multisigParams, signingAccounts)` or `new MultisigAccount(multisigParams, signingAccounts)` instead.
|
|
11
|
+
*
|
|
14
12
|
* Returns an account wrapper that supports partial or full multisig signing.
|
|
15
13
|
* @param multisigParams The parameters that define the multisig account
|
|
16
14
|
* @param signingAccounts The signers that are currently present
|
|
@@ -20,6 +18,8 @@ function multisigAccount(multisigParams, signingAccounts) {
|
|
|
20
18
|
return new types_account.MultisigAccount(multisigParams, signingAccounts);
|
|
21
19
|
}
|
|
22
20
|
/**
|
|
21
|
+
* @deprecated Use `algorandClient.account.rekeyed(account, sender)` or `new SigningAccount(account, sender)` instead.
|
|
22
|
+
*
|
|
23
23
|
* Returns an account wrapper that supports a rekeyed account.
|
|
24
24
|
* @param signer The account, with private key loaded, that is signing
|
|
25
25
|
* @param sender The address of the rekeyed account that will act as a sender
|
|
@@ -29,6 +29,8 @@ function rekeyedAccount(signer, sender) {
|
|
|
29
29
|
return new types_account.SigningAccount(signer, sender);
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
|
+
* @deprecated Use `algorandClient.account.getSigner(sender)` (after previously registering the signer with `setSigner`) or `{ addr: sender, signer }` instead.
|
|
33
|
+
*
|
|
32
34
|
* Returns an account wrapper that supports a transaction signer with associated sender address.
|
|
33
35
|
* @param signer The transaction signer
|
|
34
36
|
* @param sender The address of sender account
|
|
@@ -37,7 +39,10 @@ function rekeyedAccount(signer, sender) {
|
|
|
37
39
|
function transactionSignerAccount(signer, sender) {
|
|
38
40
|
return { addr: sender, signer };
|
|
39
41
|
}
|
|
40
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* @deprecated Use `algorandClient.account.random()` or `algosdk.generateAccount()` instead.
|
|
44
|
+
*
|
|
45
|
+
* Returns a new, random Algorand account with secret key loaded.
|
|
41
46
|
*
|
|
42
47
|
* This is a wrapper around algosdk.generateAccount to provide a more friendly/obvious name.
|
|
43
48
|
*
|
|
@@ -47,6 +52,8 @@ function randomAccount() {
|
|
|
47
52
|
return algosdk.generateAccount();
|
|
48
53
|
}
|
|
49
54
|
/**
|
|
55
|
+
* @deprecated Use `algorandClient.account.fromEnvironment(name, fundWith)` or `new AccountManager(clientManager).fromEnvironment()` instead.
|
|
56
|
+
*
|
|
50
57
|
* Returns an Algorand account with private key loaded by convention from environment variables based on the given name identifier.
|
|
51
58
|
*
|
|
52
59
|
* Note: This function expects to run in a Node.js environment.
|
|
@@ -77,33 +84,22 @@ function randomAccount() {
|
|
|
77
84
|
* @returns The requested account with private key loaded from the environment variables or when targeting LocalNet from KMD (idempotently creating and funding the account)
|
|
78
85
|
*/
|
|
79
86
|
async function mnemonicAccountFromEnvironment(account, algod, kmdClient) {
|
|
80
|
-
|
|
81
|
-
// todo: When eventually removing this method, inline it here
|
|
82
|
-
const config$1 = getAccountConfigFromEnvironment.getAccountConfigFromEnvironment(name);
|
|
83
|
-
if (config$1.accountMnemonic) {
|
|
84
|
-
const signer = mnemonicAccount.mnemonicAccount(config$1.accountMnemonic);
|
|
85
|
-
const sender = config$1.senderAddress;
|
|
86
|
-
if (sender) {
|
|
87
|
-
config.Config.logger.debug(`Using rekeyed account ${signer.addr} for sender ${sender} for ${name} account`);
|
|
88
|
-
return new types_account.SigningAccount(signer, sender);
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
return signer;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
if (await isLocalnet.isLocalNet(algod)) {
|
|
95
|
-
return await getOrCreateKmdWalletAccount.getOrCreateKmdWalletAccount({ name, fundWith }, algod, kmdClient);
|
|
96
|
-
}
|
|
97
|
-
throw new Error(`Missing environment variable ${name.toUpperCase()}_MNEMONIC when looking for account ${name}`);
|
|
87
|
+
return (await new types_accountManager.AccountManager(new types_clientManager.ClientManager({ algod, kmd: kmdClient })).fromEnvironment(typeof account === 'string' ? account : account.name, typeof account === 'string' ? undefined : account.fundWith)).account;
|
|
98
88
|
}
|
|
99
|
-
/**
|
|
89
|
+
/**
|
|
90
|
+
* @deprecated Use `algosdk.decodeAddress` instead.
|
|
91
|
+
*
|
|
92
|
+
* Returns an account's address as a byte array
|
|
100
93
|
*
|
|
101
94
|
* @param account Either an account (with private key loaded) or the string address of an account
|
|
102
95
|
*/
|
|
103
96
|
function getAccountAddressAsUint8Array(account) {
|
|
104
97
|
return algosdk.decodeAddress(typeof account === 'string' ? account : transaction.getSenderAddress(account)).publicKey;
|
|
105
98
|
}
|
|
106
|
-
/**
|
|
99
|
+
/**
|
|
100
|
+
* @deprecated Use `algosdk.encodeAddress` instead.
|
|
101
|
+
*
|
|
102
|
+
* Returns the string address of an Algorand account from a base64 encoded version of the underlying byte array of the address public key
|
|
107
103
|
*
|
|
108
104
|
* @param addressEncodedInB64 The base64 encoded version of the underlying byte array of the address public key
|
|
109
105
|
*/
|
|
@@ -111,6 +107,8 @@ function getAccountAddressAsString(addressEncodedInB64) {
|
|
|
111
107
|
return algosdk.encodeAddress(Buffer.from(addressEncodedInB64, 'base64'));
|
|
112
108
|
}
|
|
113
109
|
/**
|
|
110
|
+
* @deprecated Use `algorandClient.account.getInformation(sender)` or `new AccountManager(clientManager).getInformation(sender)` instead.
|
|
111
|
+
*
|
|
114
112
|
* Returns the given sender account's current status, balance and spendable amounts.
|
|
115
113
|
*
|
|
116
114
|
* @example
|
|
@@ -125,27 +123,11 @@ function getAccountAddressAsString(addressEncodedInB64) {
|
|
|
125
123
|
* @returns The account information
|
|
126
124
|
*/
|
|
127
125
|
async function getAccountInformation(sender, algod) {
|
|
128
|
-
|
|
129
|
-
return {
|
|
130
|
-
...account,
|
|
131
|
-
// None of these can practically overflow 2^53
|
|
132
|
-
amount: Number(account.amount),
|
|
133
|
-
amountWithoutPendingRewards: Number(account.amountWithoutPendingRewards),
|
|
134
|
-
minBalance: Number(account.minBalance),
|
|
135
|
-
pendingRewards: Number(account.pendingRewards),
|
|
136
|
-
rewards: Number(account.rewards),
|
|
137
|
-
round: Number(account.round),
|
|
138
|
-
totalAppsOptedIn: Number(account.totalAppsOptedIn),
|
|
139
|
-
totalAssetsOptedIn: Number(account.totalAssetsOptedIn),
|
|
140
|
-
totalCreatedApps: Number(account.totalCreatedApps),
|
|
141
|
-
totalCreatedAssets: Number(account.totalCreatedAssets),
|
|
142
|
-
appsTotalExtraPages: account.appsTotalExtraPages ? Number(account.appsTotalExtraPages) : undefined,
|
|
143
|
-
rewardBase: account.rewardBase ? Number(account.rewardBase) : undefined,
|
|
144
|
-
totalBoxBytes: account.totalBoxBytes ? Number(account.totalBoxBytes) : undefined,
|
|
145
|
-
totalBoxes: account.totalBoxes ? Number(account.totalBoxes) : undefined,
|
|
146
|
-
};
|
|
126
|
+
return new types_accountManager.AccountManager(new types_clientManager.ClientManager({ algod })).getInformation(transaction.getSenderAddress(sender));
|
|
147
127
|
}
|
|
148
128
|
/**
|
|
129
|
+
* @deprecated Use `algorandClient.account.getAssetInformation(sender, assetId)` or `new AccountManager(clientManager).getAssetInformation(sender, assetId)` instead.
|
|
130
|
+
*
|
|
149
131
|
* Returns the given sender account's asset holding for a given asset.
|
|
150
132
|
*
|
|
151
133
|
* @example
|
|
@@ -162,13 +144,7 @@ async function getAccountInformation(sender, algod) {
|
|
|
162
144
|
* @returns The account asset holding information
|
|
163
145
|
*/
|
|
164
146
|
async function getAccountAssetInformation(sender, assetId, algod) {
|
|
165
|
-
|
|
166
|
-
return {
|
|
167
|
-
assetId: BigInt(assetId),
|
|
168
|
-
balance: BigInt(info['asset-holding']['amount']),
|
|
169
|
-
frozen: info['asset-holding']['is-frozen'] === 'true',
|
|
170
|
-
round: BigInt(info['round']),
|
|
171
|
-
};
|
|
147
|
+
return new types_accountManager.AccountManager(new types_clientManager.ClientManager({ algod })).getAssetInformation(transaction.getSenderAddress(sender), assetId);
|
|
172
148
|
}
|
|
173
149
|
|
|
174
150
|
exports.getAccountAddressAsString = getAccountAddressAsString;
|
package/account/account.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.js","sources":["../../src/account/account.ts"],"sourcesContent":[null],"names":["MultisigAccount","SigningAccount","
|
|
1
|
+
{"version":3,"file":"account.js","sources":["../../src/account/account.ts"],"sourcesContent":[null],"names":["MultisigAccount","SigningAccount","AccountManager","ClientManager","getSenderAddress"],"mappings":";;;;;;;;AAaA;;;;;;;AAOG;AACa,SAAA,eAAe,CAAC,cAAgC,EAAE,eAA6C,EAAA;AAC7G,IAAA,OAAO,IAAIA,6BAAe,CAAC,cAAc,EAAE,eAAe,CAAC,CAAA;AAC7D,CAAC;AAED;;;;;;;AAOG;AACa,SAAA,cAAc,CAAC,MAAe,EAAE,MAAc,EAAA;AAC5D,IAAA,OAAO,IAAIC,4BAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAC3C,CAAC;AAED;;;;;;;AAOG;AACa,SAAA,wBAAwB,CAAC,MAAyB,EAAE,MAAc,EAAA;AAChF,IAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAA;AACjC,CAAC;AAED;;;;;;;AAOG;SACa,aAAa,GAAA;;AAE3B,IAAA,OAAO,OAAO,CAAC,eAAe,EAAE,CAAA;AAClC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BG;AACI,eAAe,8BAA8B,CAClD,OAAyD,EACzD,KAAc,EACd,SAAe,EAAA;IAEf,OAAO,CACL,MAAM,IAAIC,mCAAc,CAAC,IAAIC,iCAAa,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,eAAe,CACpF,OAAO,OAAO,KAAK,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC,IAAI,EACpD,OAAO,OAAO,KAAK,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAC,QAAQ,CAC3D,EACD,OAAO,CAAA;AACX,CAAC;AAED;;;;;;AAMG;AACG,SAAU,6BAA6B,CAAC,OAAqC,EAAA;IACjF,OAAO,OAAO,CAAC,aAAa,CAAC,OAAO,OAAO,KAAK,QAAQ,GAAG,OAAO,GAAGC,4BAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAA;AAC3G,CAAC;AAED;;;;;;AAMG;AACG,SAAU,yBAAyB,CAAC,mBAA2B,EAAA;AACnE,IAAA,OAAO,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,mBAAmB,EAAE,QAAQ,CAAC,CAAC,CAAA;AAC1E,CAAC;AAED;;;;;;;;;;;;;;;AAeG;AACI,eAAe,qBAAqB,CAAC,MAAoC,EAAE,KAAc,EAAA;AAC9F,IAAA,OAAO,IAAIF,mCAAc,CAAC,IAAIC,iCAAa,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,cAAc,CAACC,4BAAgB,CAAC,MAAM,CAAC,CAAC,CAAA;AAClG,CAAC;AAED;;;;;;;;;;;;;;;;;AAiBG;AACI,eAAe,0BAA0B,CAC9C,MAAoC,EACpC,OAAwB,EACxB,KAAc,EAAA;IAEd,OAAO,IAAIF,mCAAc,CAAC,IAAIC,iCAAa,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,mBAAmB,CAACC,4BAAgB,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAA;AAChH;;;;;;;;;;;;"}
|
package/account/account.mjs
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import algosdk from 'algosdk';
|
|
2
|
-
import { Config } from '../config.mjs';
|
|
3
|
-
import { getOrCreateKmdWalletAccount } from '../localnet/get-or-create-kmd-wallet-account.mjs';
|
|
4
|
-
import { isLocalNet } from '../localnet/is-localnet.mjs';
|
|
5
2
|
import { getSenderAddress } from '../transaction/transaction.mjs';
|
|
6
3
|
import { MultisigAccount, SigningAccount } from '../types/account.mjs';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
4
|
+
import { AccountManager } from '../types/account-manager.mjs';
|
|
5
|
+
import { ClientManager } from '../types/client-manager.mjs';
|
|
9
6
|
|
|
10
|
-
var AccountInformationModel = algosdk.modelsv2.Account;
|
|
11
7
|
/**
|
|
8
|
+
* @deprecated Use `algorandClient.account.multisig(multisigParams, signingAccounts)` or `new MultisigAccount(multisigParams, signingAccounts)` instead.
|
|
9
|
+
*
|
|
12
10
|
* Returns an account wrapper that supports partial or full multisig signing.
|
|
13
11
|
* @param multisigParams The parameters that define the multisig account
|
|
14
12
|
* @param signingAccounts The signers that are currently present
|
|
@@ -18,6 +16,8 @@ function multisigAccount(multisigParams, signingAccounts) {
|
|
|
18
16
|
return new MultisigAccount(multisigParams, signingAccounts);
|
|
19
17
|
}
|
|
20
18
|
/**
|
|
19
|
+
* @deprecated Use `algorandClient.account.rekeyed(account, sender)` or `new SigningAccount(account, sender)` instead.
|
|
20
|
+
*
|
|
21
21
|
* Returns an account wrapper that supports a rekeyed account.
|
|
22
22
|
* @param signer The account, with private key loaded, that is signing
|
|
23
23
|
* @param sender The address of the rekeyed account that will act as a sender
|
|
@@ -27,6 +27,8 @@ function rekeyedAccount(signer, sender) {
|
|
|
27
27
|
return new SigningAccount(signer, sender);
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
|
+
* @deprecated Use `algorandClient.account.getSigner(sender)` (after previously registering the signer with `setSigner`) or `{ addr: sender, signer }` instead.
|
|
31
|
+
*
|
|
30
32
|
* Returns an account wrapper that supports a transaction signer with associated sender address.
|
|
31
33
|
* @param signer The transaction signer
|
|
32
34
|
* @param sender The address of sender account
|
|
@@ -35,7 +37,10 @@ function rekeyedAccount(signer, sender) {
|
|
|
35
37
|
function transactionSignerAccount(signer, sender) {
|
|
36
38
|
return { addr: sender, signer };
|
|
37
39
|
}
|
|
38
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* @deprecated Use `algorandClient.account.random()` or `algosdk.generateAccount()` instead.
|
|
42
|
+
*
|
|
43
|
+
* Returns a new, random Algorand account with secret key loaded.
|
|
39
44
|
*
|
|
40
45
|
* This is a wrapper around algosdk.generateAccount to provide a more friendly/obvious name.
|
|
41
46
|
*
|
|
@@ -45,6 +50,8 @@ function randomAccount() {
|
|
|
45
50
|
return algosdk.generateAccount();
|
|
46
51
|
}
|
|
47
52
|
/**
|
|
53
|
+
* @deprecated Use `algorandClient.account.fromEnvironment(name, fundWith)` or `new AccountManager(clientManager).fromEnvironment()` instead.
|
|
54
|
+
*
|
|
48
55
|
* Returns an Algorand account with private key loaded by convention from environment variables based on the given name identifier.
|
|
49
56
|
*
|
|
50
57
|
* Note: This function expects to run in a Node.js environment.
|
|
@@ -75,33 +82,22 @@ function randomAccount() {
|
|
|
75
82
|
* @returns The requested account with private key loaded from the environment variables or when targeting LocalNet from KMD (idempotently creating and funding the account)
|
|
76
83
|
*/
|
|
77
84
|
async function mnemonicAccountFromEnvironment(account, algod, kmdClient) {
|
|
78
|
-
|
|
79
|
-
// todo: When eventually removing this method, inline it here
|
|
80
|
-
const config = getAccountConfigFromEnvironment(name);
|
|
81
|
-
if (config.accountMnemonic) {
|
|
82
|
-
const signer = mnemonicAccount(config.accountMnemonic);
|
|
83
|
-
const sender = config.senderAddress;
|
|
84
|
-
if (sender) {
|
|
85
|
-
Config.logger.debug(`Using rekeyed account ${signer.addr} for sender ${sender} for ${name} account`);
|
|
86
|
-
return new SigningAccount(signer, sender);
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
return signer;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
if (await isLocalNet(algod)) {
|
|
93
|
-
return await getOrCreateKmdWalletAccount({ name, fundWith }, algod, kmdClient);
|
|
94
|
-
}
|
|
95
|
-
throw new Error(`Missing environment variable ${name.toUpperCase()}_MNEMONIC when looking for account ${name}`);
|
|
85
|
+
return (await new AccountManager(new ClientManager({ algod, kmd: kmdClient })).fromEnvironment(typeof account === 'string' ? account : account.name, typeof account === 'string' ? undefined : account.fundWith)).account;
|
|
96
86
|
}
|
|
97
|
-
/**
|
|
87
|
+
/**
|
|
88
|
+
* @deprecated Use `algosdk.decodeAddress` instead.
|
|
89
|
+
*
|
|
90
|
+
* Returns an account's address as a byte array
|
|
98
91
|
*
|
|
99
92
|
* @param account Either an account (with private key loaded) or the string address of an account
|
|
100
93
|
*/
|
|
101
94
|
function getAccountAddressAsUint8Array(account) {
|
|
102
95
|
return algosdk.decodeAddress(typeof account === 'string' ? account : getSenderAddress(account)).publicKey;
|
|
103
96
|
}
|
|
104
|
-
/**
|
|
97
|
+
/**
|
|
98
|
+
* @deprecated Use `algosdk.encodeAddress` instead.
|
|
99
|
+
*
|
|
100
|
+
* Returns the string address of an Algorand account from a base64 encoded version of the underlying byte array of the address public key
|
|
105
101
|
*
|
|
106
102
|
* @param addressEncodedInB64 The base64 encoded version of the underlying byte array of the address public key
|
|
107
103
|
*/
|
|
@@ -109,6 +105,8 @@ function getAccountAddressAsString(addressEncodedInB64) {
|
|
|
109
105
|
return algosdk.encodeAddress(Buffer.from(addressEncodedInB64, 'base64'));
|
|
110
106
|
}
|
|
111
107
|
/**
|
|
108
|
+
* @deprecated Use `algorandClient.account.getInformation(sender)` or `new AccountManager(clientManager).getInformation(sender)` instead.
|
|
109
|
+
*
|
|
112
110
|
* Returns the given sender account's current status, balance and spendable amounts.
|
|
113
111
|
*
|
|
114
112
|
* @example
|
|
@@ -123,27 +121,11 @@ function getAccountAddressAsString(addressEncodedInB64) {
|
|
|
123
121
|
* @returns The account information
|
|
124
122
|
*/
|
|
125
123
|
async function getAccountInformation(sender, algod) {
|
|
126
|
-
|
|
127
|
-
return {
|
|
128
|
-
...account,
|
|
129
|
-
// None of these can practically overflow 2^53
|
|
130
|
-
amount: Number(account.amount),
|
|
131
|
-
amountWithoutPendingRewards: Number(account.amountWithoutPendingRewards),
|
|
132
|
-
minBalance: Number(account.minBalance),
|
|
133
|
-
pendingRewards: Number(account.pendingRewards),
|
|
134
|
-
rewards: Number(account.rewards),
|
|
135
|
-
round: Number(account.round),
|
|
136
|
-
totalAppsOptedIn: Number(account.totalAppsOptedIn),
|
|
137
|
-
totalAssetsOptedIn: Number(account.totalAssetsOptedIn),
|
|
138
|
-
totalCreatedApps: Number(account.totalCreatedApps),
|
|
139
|
-
totalCreatedAssets: Number(account.totalCreatedAssets),
|
|
140
|
-
appsTotalExtraPages: account.appsTotalExtraPages ? Number(account.appsTotalExtraPages) : undefined,
|
|
141
|
-
rewardBase: account.rewardBase ? Number(account.rewardBase) : undefined,
|
|
142
|
-
totalBoxBytes: account.totalBoxBytes ? Number(account.totalBoxBytes) : undefined,
|
|
143
|
-
totalBoxes: account.totalBoxes ? Number(account.totalBoxes) : undefined,
|
|
144
|
-
};
|
|
124
|
+
return new AccountManager(new ClientManager({ algod })).getInformation(getSenderAddress(sender));
|
|
145
125
|
}
|
|
146
126
|
/**
|
|
127
|
+
* @deprecated Use `algorandClient.account.getAssetInformation(sender, assetId)` or `new AccountManager(clientManager).getAssetInformation(sender, assetId)` instead.
|
|
128
|
+
*
|
|
147
129
|
* Returns the given sender account's asset holding for a given asset.
|
|
148
130
|
*
|
|
149
131
|
* @example
|
|
@@ -160,13 +142,7 @@ async function getAccountInformation(sender, algod) {
|
|
|
160
142
|
* @returns The account asset holding information
|
|
161
143
|
*/
|
|
162
144
|
async function getAccountAssetInformation(sender, assetId, algod) {
|
|
163
|
-
|
|
164
|
-
return {
|
|
165
|
-
assetId: BigInt(assetId),
|
|
166
|
-
balance: BigInt(info['asset-holding']['amount']),
|
|
167
|
-
frozen: info['asset-holding']['is-frozen'] === 'true',
|
|
168
|
-
round: BigInt(info['round']),
|
|
169
|
-
};
|
|
145
|
+
return new AccountManager(new ClientManager({ algod })).getAssetInformation(getSenderAddress(sender), assetId);
|
|
170
146
|
}
|
|
171
147
|
|
|
172
148
|
export { getAccountAddressAsString, getAccountAddressAsUint8Array, getAccountAssetInformation, getAccountInformation, mnemonicAccountFromEnvironment, multisigAccount, randomAccount, rekeyedAccount, transactionSignerAccount };
|
package/account/account.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.mjs","sources":["../../src/account/account.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"account.mjs","sources":["../../src/account/account.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;AAaA;;;;;;;AAOG;AACa,SAAA,eAAe,CAAC,cAAgC,EAAE,eAA6C,EAAA;AAC7G,IAAA,OAAO,IAAI,eAAe,CAAC,cAAc,EAAE,eAAe,CAAC,CAAA;AAC7D,CAAC;AAED;;;;;;;AAOG;AACa,SAAA,cAAc,CAAC,MAAe,EAAE,MAAc,EAAA;AAC5D,IAAA,OAAO,IAAI,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAC3C,CAAC;AAED;;;;;;;AAOG;AACa,SAAA,wBAAwB,CAAC,MAAyB,EAAE,MAAc,EAAA;AAChF,IAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAA;AACjC,CAAC;AAED;;;;;;;AAOG;SACa,aAAa,GAAA;;AAE3B,IAAA,OAAO,OAAO,CAAC,eAAe,EAAE,CAAA;AAClC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BG;AACI,eAAe,8BAA8B,CAClD,OAAyD,EACzD,KAAc,EACd,SAAe,EAAA;IAEf,OAAO,CACL,MAAM,IAAI,cAAc,CAAC,IAAI,aAAa,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,eAAe,CACpF,OAAO,OAAO,KAAK,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAC,IAAI,EACpD,OAAO,OAAO,KAAK,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAC,QAAQ,CAC3D,EACD,OAAO,CAAA;AACX,CAAC;AAED;;;;;;AAMG;AACG,SAAU,6BAA6B,CAAC,OAAqC,EAAA;IACjF,OAAO,OAAO,CAAC,aAAa,CAAC,OAAO,OAAO,KAAK,QAAQ,GAAG,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAA;AAC3G,CAAC;AAED;;;;;;AAMG;AACG,SAAU,yBAAyB,CAAC,mBAA2B,EAAA;AACnE,IAAA,OAAO,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,mBAAmB,EAAE,QAAQ,CAAC,CAAC,CAAA;AAC1E,CAAC;AAED;;;;;;;;;;;;;;;AAeG;AACI,eAAe,qBAAqB,CAAC,MAAoC,EAAE,KAAc,EAAA;AAC9F,IAAA,OAAO,IAAI,cAAc,CAAC,IAAI,aAAa,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAA;AAClG,CAAC;AAED;;;;;;;;;;;;;;;;;AAiBG;AACI,eAAe,0BAA0B,CAC9C,MAAoC,EACpC,OAAwB,EACxB,KAAc,EAAA;IAEd,OAAO,IAAI,cAAc,CAAC,IAAI,aAAa,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAA;AAChH;;;;"}
|
package/account/get-account.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { AlgoAmount } from '../types/amount';
|
|
|
4
4
|
import Account = algosdk.Account;
|
|
5
5
|
import Algodv2 = algosdk.Algodv2;
|
|
6
6
|
import Kmd = algosdk.Kmd;
|
|
7
|
-
/** @deprecated use
|
|
7
|
+
/** @deprecated use `algorandClient.account.fromEnvironment()` instead
|
|
8
8
|
*
|
|
9
9
|
* Returns an Algorand account with private key loaded by convention based on the given name identifier.
|
|
10
10
|
*
|
|
@@ -38,7 +38,7 @@ export declare function getAccount(account: {
|
|
|
38
38
|
name: string;
|
|
39
39
|
fundWith?: AlgoAmount;
|
|
40
40
|
} | string, algod: Algodv2, kmdClient?: Kmd): Promise<Account | SigningAccount>;
|
|
41
|
-
/** @deprecated use
|
|
41
|
+
/** @deprecated use `algorandClient.account.fromEnvironment()` instead
|
|
42
42
|
* Returns an Algorand account with private key loaded by convention based on the given name identifier.
|
|
43
43
|
*
|
|
44
44
|
* Note: This function expects to run in a Node.js environment.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-account.d.ts","sourceRoot":"","sources":["../../src/account/get-account.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"get-account.d.ts","sourceRoot":"","sources":["../../src/account/get-account.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAA;AAC7B,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEhE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAG5C,OAAO,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;AAChC,OAAO,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;AAChC,OAAO,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;AAExB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;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,CAAA;AAEpC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,UAAU,CAC9B,OAAO,EAAE;IAAE,MAAM,EAAE,aAAa,CAAC;IAAC,QAAQ,CAAC,EAAE,UAAU,CAAA;CAAE,EACzD,KAAK,EAAE,OAAO,EACd,SAAS,CAAC,EAAE,GAAG,GACd,OAAO,CAAC,OAAO,GAAG,cAAc,CAAC,CAAA"}
|
package/account/get-account.js
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var getOrCreateKmdWalletAccount = require('../localnet/get-or-create-kmd-wallet-account.js');
|
|
6
|
-
var isLocalnet = require('../localnet/is-localnet.js');
|
|
7
|
-
var types_account = require('../types/account.js');
|
|
3
|
+
var types_accountManager = require('../types/account-manager.js');
|
|
4
|
+
var types_clientManager = require('../types/client-manager.js');
|
|
8
5
|
var getAccountConfigFromEnvironment = require('./get-account-config-from-environment.js');
|
|
9
|
-
var mnemonicAccount = require('./mnemonic-account.js');
|
|
10
6
|
|
|
11
|
-
/** @deprecated use
|
|
7
|
+
/** @deprecated use `algorandClient.account.fromEnvironment()` instead
|
|
12
8
|
* Returns an Algorand account with private key loaded by convention based on the given name identifier.
|
|
13
9
|
*
|
|
14
10
|
* Note: This function expects to run in a Node.js environment.
|
|
@@ -42,41 +38,25 @@ var mnemonicAccount = require('./mnemonic-account.js');
|
|
|
42
38
|
async function getAccount(account, algod, kmdClient) {
|
|
43
39
|
let name;
|
|
44
40
|
let fundWith = undefined;
|
|
45
|
-
let config
|
|
41
|
+
let config;
|
|
46
42
|
if (typeof account === 'string') {
|
|
47
43
|
name = account;
|
|
48
|
-
config
|
|
44
|
+
config = getAccountConfigFromEnvironment.getAccountConfigFromEnvironment(name);
|
|
49
45
|
}
|
|
50
46
|
else if ('name' in account) {
|
|
51
47
|
name = account.name;
|
|
52
|
-
config
|
|
48
|
+
config = getAccountConfigFromEnvironment.getAccountConfigFromEnvironment(name);
|
|
53
49
|
fundWith = account.fundWith;
|
|
54
50
|
}
|
|
55
51
|
else if ('config' in account) {
|
|
56
|
-
config
|
|
57
|
-
name = config
|
|
52
|
+
config = account.config;
|
|
53
|
+
name = config.accountName;
|
|
58
54
|
fundWith = account.fundWith;
|
|
59
55
|
}
|
|
60
56
|
else {
|
|
61
57
|
throw new Error('Missing name or account config');
|
|
62
58
|
}
|
|
63
|
-
|
|
64
|
-
const signer = mnemonicAccount.mnemonicAccount(config$1.accountMnemonic);
|
|
65
|
-
const sender = config$1.senderAddress || config$1.senderMnemonic;
|
|
66
|
-
if (sender) {
|
|
67
|
-
config.Config.logger.debug(`Using rekeyed account ${signer.addr} for sender ${sender} for ${name} account`);
|
|
68
|
-
return new types_account.SigningAccount(signer, sender);
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
return signer;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
if (await isLocalnet.isLocalNet(algod)) {
|
|
75
|
-
const account = await getOrCreateKmdWalletAccount.getOrCreateKmdWalletAccount({ name, fundWith }, algod, kmdClient);
|
|
76
|
-
config$1.accountMnemonic = algosdk.secretKeyToMnemonic(account.sk);
|
|
77
|
-
return account;
|
|
78
|
-
}
|
|
79
|
-
throw new Error(`Missing environment variable ${name.toUpperCase()}_MNEMONIC when looking for account ${name}`);
|
|
59
|
+
return (await new types_accountManager.AccountManager(new types_clientManager.ClientManager({ algod, kmd: kmdClient })).fromEnvironment(name, fundWith)).account;
|
|
80
60
|
}
|
|
81
61
|
|
|
82
62
|
exports.getAccount = getAccount;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-account.js","sources":["../../src/account/get-account.ts"],"sourcesContent":[null],"names":["
|
|
1
|
+
{"version":3,"file":"get-account.js","sources":["../../src/account/get-account.ts"],"sourcesContent":[null],"names":["getAccountConfigFromEnvironment","AccountManager","ClientManager"],"mappings":";;;;;;AAyEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BG;AACI,eAAe,UAAU,CAC9B,OAA4G,EAC5G,KAAc,EACd,SAAe,EAAA;AAEf,IAAA,IAAI,IAAY,CAAA;IAChB,IAAI,QAAQ,GAA2B,SAAS,CAAA;AAChD,IAAA,IAAI,MAAqB,CAAA;AAEzB,IAAA,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;QAC/B,IAAI,GAAG,OAAO,CAAA;AACd,QAAA,MAAM,GAAGA,+DAA+B,CAAC,IAAI,CAAC,CAAA;KAC/C;AAAM,SAAA,IAAI,MAAM,IAAI,OAAO,EAAE;AAC5B,QAAA,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;AACnB,QAAA,MAAM,GAAGA,+DAA+B,CAAC,IAAI,CAAC,CAAA;AAC9C,QAAA,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAA;KAC5B;AAAM,SAAA,IAAI,QAAQ,IAAI,OAAO,EAAE;AAC9B,QAAA,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;AACvB,QAAA,IAAI,GAAG,MAAM,CAAC,WAAW,CAAA;AACzB,QAAA,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAA;KAC5B;SAAM;AACL,QAAA,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;KAClD;IAED,OAAO,CAAC,MAAM,IAAIC,mCAAc,CAAC,IAAIC,iCAAa,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;AACzH;;;;"}
|
package/account/get-account.mjs
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { getOrCreateKmdWalletAccount } from '../localnet/get-or-create-kmd-wallet-account.mjs';
|
|
4
|
-
import { isLocalNet } from '../localnet/is-localnet.mjs';
|
|
5
|
-
import { SigningAccount } from '../types/account.mjs';
|
|
1
|
+
import { AccountManager } from '../types/account-manager.mjs';
|
|
2
|
+
import { ClientManager } from '../types/client-manager.mjs';
|
|
6
3
|
import { getAccountConfigFromEnvironment } from './get-account-config-from-environment.mjs';
|
|
7
|
-
import { mnemonicAccount } from './mnemonic-account.mjs';
|
|
8
4
|
|
|
9
|
-
/** @deprecated use
|
|
5
|
+
/** @deprecated use `algorandClient.account.fromEnvironment()` instead
|
|
10
6
|
* Returns an Algorand account with private key loaded by convention based on the given name identifier.
|
|
11
7
|
*
|
|
12
8
|
* Note: This function expects to run in a Node.js environment.
|
|
@@ -58,23 +54,7 @@ async function getAccount(account, algod, kmdClient) {
|
|
|
58
54
|
else {
|
|
59
55
|
throw new Error('Missing name or account config');
|
|
60
56
|
}
|
|
61
|
-
|
|
62
|
-
const signer = mnemonicAccount(config.accountMnemonic);
|
|
63
|
-
const sender = config.senderAddress || config.senderMnemonic;
|
|
64
|
-
if (sender) {
|
|
65
|
-
Config.logger.debug(`Using rekeyed account ${signer.addr} for sender ${sender} for ${name} account`);
|
|
66
|
-
return new SigningAccount(signer, sender);
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
return signer;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
if (await isLocalNet(algod)) {
|
|
73
|
-
const account = await getOrCreateKmdWalletAccount({ name, fundWith }, algod, kmdClient);
|
|
74
|
-
config.accountMnemonic = algosdk.secretKeyToMnemonic(account.sk);
|
|
75
|
-
return account;
|
|
76
|
-
}
|
|
77
|
-
throw new Error(`Missing environment variable ${name.toUpperCase()}_MNEMONIC when looking for account ${name}`);
|
|
57
|
+
return (await new AccountManager(new ClientManager({ algod, kmd: kmdClient })).fromEnvironment(name, fundWith)).account;
|
|
78
58
|
}
|
|
79
59
|
|
|
80
60
|
export { getAccount };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-account.mjs","sources":["../../src/account/get-account.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-account.mjs","sources":["../../src/account/get-account.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAyEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BG;AACI,eAAe,UAAU,CAC9B,OAA4G,EAC5G,KAAc,EACd,SAAe,EAAA;AAEf,IAAA,IAAI,IAAY,CAAA;IAChB,IAAI,QAAQ,GAA2B,SAAS,CAAA;AAChD,IAAA,IAAI,MAAqB,CAAA;AAEzB,IAAA,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;QAC/B,IAAI,GAAG,OAAO,CAAA;AACd,QAAA,MAAM,GAAG,+BAA+B,CAAC,IAAI,CAAC,CAAA;KAC/C;AAAM,SAAA,IAAI,MAAM,IAAI,OAAO,EAAE;AAC5B,QAAA,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;AACnB,QAAA,MAAM,GAAG,+BAA+B,CAAC,IAAI,CAAC,CAAA;AAC9C,QAAA,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAA;KAC5B;AAAM,SAAA,IAAI,QAAQ,IAAI,OAAO,EAAE;AAC9B,QAAA,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;AACvB,QAAA,IAAI,GAAG,MAAM,CAAC,WAAW,CAAA;AACzB,QAAA,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAA;KAC5B;SAAM;AACL,QAAA,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;KAClD;IAED,OAAO,CAAC,MAAM,IAAI,cAAc,CAAC,IAAI,aAAa,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;AACzH;;;;"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import algosdk from 'algosdk';
|
|
2
2
|
import Algodv2 = algosdk.Algodv2;
|
|
3
3
|
import Kmd = algosdk.Kmd;
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated Use `algorandClient.account.dispenserFromEnvironment()` or `new AccountManager(clientManager).dispenserFromEnvironment()` instead
|
|
6
|
+
*
|
|
7
|
+
* Returns an account (with private key loaded) that can act as a dispenser
|
|
5
8
|
*
|
|
6
9
|
* If running on LocalNet then it will return the default dispenser account automatically,
|
|
7
10
|
* otherwise it will load the account mnemonic stored in process.env.DISPENSER_MNEMONIC
|
|
@@ -9,5 +12,7 @@ import Kmd = algosdk.Kmd;
|
|
|
9
12
|
* @param algod An algod client
|
|
10
13
|
* @param kmd A KMD client, if not specified then a default KMD client will be loaded from environment variables
|
|
11
14
|
*/
|
|
12
|
-
export declare function getDispenserAccount(algod: Algodv2, kmd?: Kmd): Promise<
|
|
15
|
+
export declare function getDispenserAccount(algod: Algodv2, kmd?: Kmd): Promise<import("../types/account").TransactionSignerAccount & {
|
|
16
|
+
account: import("../types/account").SigningAccount;
|
|
17
|
+
}>;
|
|
13
18
|
//# sourceMappingURL=get-dispenser-account.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-dispenser-account.d.ts","sourceRoot":"","sources":["../../src/account/get-dispenser-account.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"get-dispenser-account.d.ts","sourceRoot":"","sources":["../../src/account/get-dispenser-account.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAA;AAI7B,OAAO,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;AAChC,OAAO,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;AAExB;;;;;;;;;;GAUG;AACH,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,GAAG;;GAElE"}
|