@algorandfoundation/algokit-utils 6.0.0-beta.3 → 6.0.0-beta.4
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/account/account.d.ts +33 -1
- package/account/account.d.ts.map +1 -1
- package/account/account.js +63 -0
- package/account/account.js.map +1 -1
- package/account/account.mjs +62 -1
- package/account/account.mjs.map +1 -1
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +4 -0
- package/index.js.map +1 -1
- package/index.mjs +2 -1
- package/index.mjs.map +1 -1
- package/package.json +1 -1
- package/testing/fixtures/algorand-fixture.d.ts.map +1 -1
- package/testing/fixtures/algorand-fixture.js +15 -2
- package/testing/fixtures/algorand-fixture.js.map +1 -1
- package/testing/fixtures/algorand-fixture.mjs +15 -2
- package/testing/fixtures/algorand-fixture.mjs.map +1 -1
- package/types/account-manager.d.ts +211 -0
- package/types/account-manager.d.ts.map +1 -0
- package/types/account-manager.js +265 -0
- package/types/account-manager.js.map +1 -0
- package/types/account-manager.mjs +263 -0
- package/types/account-manager.mjs.map +1 -0
- package/types/account.d.ts +19 -0
- package/types/account.d.ts.map +1 -1
- package/types/account.js.map +1 -1
- package/types/account.mjs.map +1 -1
- package/types/algorand-client.d.ts +183 -0
- package/types/algorand-client.d.ts.map +1 -0
- package/types/algorand-client.js +296 -0
- package/types/algorand-client.js.map +1 -0
- package/types/algorand-client.mjs +291 -0
- package/types/algorand-client.mjs.map +1 -0
- package/types/client-manager.d.ts +99 -0
- package/types/client-manager.d.ts.map +1 -0
- package/types/client-manager.js +99 -0
- package/types/client-manager.js.map +1 -0
- package/types/client-manager.mjs +97 -0
- package/types/client-manager.mjs.map +1 -0
- package/types/composer.d.ts +331 -0
- package/types/composer.d.ts.map +1 -0
- package/types/composer.js +446 -0
- package/types/composer.js.map +1 -0
- package/types/composer.mjs +444 -0
- package/types/composer.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 +8 -2
- package/types/testing.d.ts.map +1 -1
- package/types/transaction.d.ts +4 -0
- package/types/transaction.d.ts.map +1 -1
package/account/account.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import algosdk from 'algosdk';
|
|
2
|
-
import { MultisigAccount, SigningAccount, TransactionSignerAccount } from '../types/account';
|
|
2
|
+
import { AccountAssetInformation, AccountInformation, MultisigAccount, SigningAccount, TransactionSignerAccount } from '../types/account';
|
|
3
3
|
import { AlgoAmount } from '../types/amount';
|
|
4
4
|
import { SendTransactionFrom } from '../types/transaction';
|
|
5
5
|
import Account = algosdk.Account;
|
|
@@ -78,4 +78,36 @@ export declare function getAccountAddressAsUint8Array(account: SendTransactionFr
|
|
|
78
78
|
* @param addressEncodedInB64 The base64 encoded version of the underlying byte array of the address public key
|
|
79
79
|
*/
|
|
80
80
|
export declare function getAccountAddressAsString(addressEncodedInB64: string): string;
|
|
81
|
+
/**
|
|
82
|
+
* Returns the given sender account's current status, balance and spendable amounts.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA";
|
|
87
|
+
* const accountInfo = await account.getInformation(address, algod);
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2accountsaddress)
|
|
91
|
+
* @param sender The address of the sender/account to look up
|
|
92
|
+
* @param algod The algod instance
|
|
93
|
+
* @returns The account information
|
|
94
|
+
*/
|
|
95
|
+
export declare function getAccountInformation(sender: string | SendTransactionFrom, algod: Algodv2): Promise<AccountInformation>;
|
|
96
|
+
/**
|
|
97
|
+
* Returns the given sender account's asset holding for a given asset.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA";
|
|
102
|
+
* const assetId = 123345;
|
|
103
|
+
* const accountInfo = await account.getAccountAssetInformation(address, assetId, algod);
|
|
104
|
+
* ```
|
|
105
|
+
*
|
|
106
|
+
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2accountsaddressassetsasset-id)
|
|
107
|
+
* @param sender The address of the sender/account to look up
|
|
108
|
+
* @param assetId The ID of the asset to return a holding for
|
|
109
|
+
* @param algod The algod instance
|
|
110
|
+
* @returns The account asset holding information
|
|
111
|
+
*/
|
|
112
|
+
export declare function getAccountAssetInformation(sender: string | SendTransactionFrom, assetId: number | bigint, algod: Algodv2): Promise<AccountAssetInformation>;
|
|
81
113
|
//# sourceMappingURL=account.d.ts.map
|
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;AAK7B,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../src/account/account.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAA;AAK7B,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,eAAe,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAA;AACzI,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAI1D,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,CA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.js
CHANGED
|
@@ -9,6 +9,7 @@ var types_account = require('../types/account.js');
|
|
|
9
9
|
var getAccountConfigFromEnvironment = require('./get-account-config-from-environment.js');
|
|
10
10
|
var mnemonicAccount = require('./mnemonic-account.js');
|
|
11
11
|
|
|
12
|
+
var AccountInformationModel = algosdk.modelsv2.Account;
|
|
12
13
|
/**
|
|
13
14
|
* Returns an account wrapper that supports partial or full multisig signing.
|
|
14
15
|
* @param multisigParams The parameters that define the multisig account
|
|
@@ -109,9 +110,71 @@ function getAccountAddressAsUint8Array(account) {
|
|
|
109
110
|
function getAccountAddressAsString(addressEncodedInB64) {
|
|
110
111
|
return algosdk.encodeAddress(Buffer.from(addressEncodedInB64, 'base64'));
|
|
111
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Returns the given sender account's current status, balance and spendable amounts.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```typescript
|
|
118
|
+
* const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA";
|
|
119
|
+
* const accountInfo = await account.getInformation(address, algod);
|
|
120
|
+
* ```
|
|
121
|
+
*
|
|
122
|
+
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2accountsaddress)
|
|
123
|
+
* @param sender The address of the sender/account to look up
|
|
124
|
+
* @param algod The algod instance
|
|
125
|
+
* @returns The account information
|
|
126
|
+
*/
|
|
127
|
+
async function getAccountInformation(sender, algod) {
|
|
128
|
+
const account = AccountInformationModel.from_obj_for_encoding(await algod.accountInformation(typeof sender === 'string' ? sender : transaction.getSenderAddress(sender)).do());
|
|
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
|
+
};
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Returns the given sender account's asset holding for a given asset.
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```typescript
|
|
153
|
+
* const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA";
|
|
154
|
+
* const assetId = 123345;
|
|
155
|
+
* const accountInfo = await account.getAccountAssetInformation(address, assetId, algod);
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
158
|
+
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2accountsaddressassetsasset-id)
|
|
159
|
+
* @param sender The address of the sender/account to look up
|
|
160
|
+
* @param assetId The ID of the asset to return a holding for
|
|
161
|
+
* @param algod The algod instance
|
|
162
|
+
* @returns The account asset holding information
|
|
163
|
+
*/
|
|
164
|
+
async function getAccountAssetInformation(sender, assetId, algod) {
|
|
165
|
+
const info = await algod.accountAssetInformation(typeof sender === 'string' ? sender : transaction.getSenderAddress(sender), Number(assetId)).do();
|
|
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
|
+
};
|
|
172
|
+
}
|
|
112
173
|
|
|
113
174
|
exports.getAccountAddressAsString = getAccountAddressAsString;
|
|
114
175
|
exports.getAccountAddressAsUint8Array = getAccountAddressAsUint8Array;
|
|
176
|
+
exports.getAccountAssetInformation = getAccountAssetInformation;
|
|
177
|
+
exports.getAccountInformation = getAccountInformation;
|
|
115
178
|
exports.mnemonicAccountFromEnvironment = mnemonicAccountFromEnvironment;
|
|
116
179
|
exports.multisigAccount = multisigAccount;
|
|
117
180
|
exports.randomAccount = randomAccount;
|
package/account/account.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.js","sources":["../../src/account/account.ts"],"sourcesContent":[null],"names":["MultisigAccount","SigningAccount","config","getAccountConfigFromEnvironment","mnemonicAccount","Config","isLocalNet","getOrCreateKmdWalletAccount","getSenderAddress"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"account.js","sources":["../../src/account/account.ts"],"sourcesContent":[null],"names":["MultisigAccount","SigningAccount","config","getAccountConfigFromEnvironment","mnemonicAccount","Config","isLocalNet","getOrCreateKmdWalletAccount","getSenderAddress"],"mappings":";;;;;;;;;;;AAUA,IAAO,uBAAuB,GAAG,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAA;AAOzD;;;;;AAKG;AACa,SAAA,eAAe,CAAC,cAAgC,EAAE,eAA6C,EAAA;AAC7G,IAAA,OAAO,IAAIA,6BAAe,CAAC,cAAc,EAAE,eAAe,CAAC,CAAA;AAC7D,CAAC;AAED;;;;;AAKG;AACa,SAAA,cAAc,CAAC,MAAe,EAAE,MAAc,EAAA;AAC5D,IAAA,OAAO,IAAIC,4BAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAC3C,CAAC;AAED;;;;;AAKG;AACa,SAAA,wBAAwB,CAAC,MAAyB,EAAE,MAAc,EAAA;AAChF,IAAA,OAAO,EAAE,IAAI,EAAE,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AAO,CAAC,gBAAgB,CAAC;AAClD,QAAA,kBAAkB,EAAE,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC;AACtD,QAAA,mBAAmB,EAAE,OAAO,CAAC,mBAAmB,GAAG,MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC,GAAG,SAAS;AAClG,QAAA,UAAU,EAAE,OAAO,CAAC,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,SAAS;AACvE,QAAA,aAAa,EAAE,OAAO,CAAC,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG,SAAS;AAChF,QAAA,UAAU,EAAE,OAAO,CAAC,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,SAAS;KACxE,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;;;AAeG;AACI,eAAe,0BAA0B,CAC9C,MAAoC,EACpC,OAAwB,EACxB,KAAc,EAAA;AAEd,IAAA,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,uBAAuB,CAAC,OAAO,MAAM,KAAK,QAAQ,GAAG,MAAM,GAAGA,4BAAgB,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAA;IAEtI,OAAO;AACL,QAAA,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC;QACxB,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,QAAQ,CAAC,CAAC;QAChD,MAAM,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC,WAAW,CAAC,KAAK,MAAM;AACrD,QAAA,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;KAC7B,CAAA;AACH;;;;;;;;;;;;"}
|
package/account/account.mjs
CHANGED
|
@@ -7,6 +7,7 @@ import { MultisigAccount, SigningAccount } from '../types/account.mjs';
|
|
|
7
7
|
import { getAccountConfigFromEnvironment } from './get-account-config-from-environment.mjs';
|
|
8
8
|
import { mnemonicAccount } from './mnemonic-account.mjs';
|
|
9
9
|
|
|
10
|
+
var AccountInformationModel = algosdk.modelsv2.Account;
|
|
10
11
|
/**
|
|
11
12
|
* Returns an account wrapper that supports partial or full multisig signing.
|
|
12
13
|
* @param multisigParams The parameters that define the multisig account
|
|
@@ -107,6 +108,66 @@ function getAccountAddressAsUint8Array(account) {
|
|
|
107
108
|
function getAccountAddressAsString(addressEncodedInB64) {
|
|
108
109
|
return algosdk.encodeAddress(Buffer.from(addressEncodedInB64, 'base64'));
|
|
109
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Returns the given sender account's current status, balance and spendable amounts.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA";
|
|
117
|
+
* const accountInfo = await account.getInformation(address, algod);
|
|
118
|
+
* ```
|
|
119
|
+
*
|
|
120
|
+
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2accountsaddress)
|
|
121
|
+
* @param sender The address of the sender/account to look up
|
|
122
|
+
* @param algod The algod instance
|
|
123
|
+
* @returns The account information
|
|
124
|
+
*/
|
|
125
|
+
async function getAccountInformation(sender, algod) {
|
|
126
|
+
const account = AccountInformationModel.from_obj_for_encoding(await algod.accountInformation(typeof sender === 'string' ? sender : getSenderAddress(sender)).do());
|
|
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
|
+
};
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Returns the given sender account's asset holding for a given asset.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```typescript
|
|
151
|
+
* const address = "XBYLS2E6YI6XXL5BWCAMOA4GTWHXWENZMX5UHXMRNWWUQ7BXCY5WC5TEPA";
|
|
152
|
+
* const assetId = 123345;
|
|
153
|
+
* const accountInfo = await account.getAccountAssetInformation(address, assetId, algod);
|
|
154
|
+
* ```
|
|
155
|
+
*
|
|
156
|
+
* [Response data schema details](https://developer.algorand.org/docs/rest-apis/algod/#get-v2accountsaddressassetsasset-id)
|
|
157
|
+
* @param sender The address of the sender/account to look up
|
|
158
|
+
* @param assetId The ID of the asset to return a holding for
|
|
159
|
+
* @param algod The algod instance
|
|
160
|
+
* @returns The account asset holding information
|
|
161
|
+
*/
|
|
162
|
+
async function getAccountAssetInformation(sender, assetId, algod) {
|
|
163
|
+
const info = await algod.accountAssetInformation(typeof sender === 'string' ? sender : getSenderAddress(sender), Number(assetId)).do();
|
|
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
|
+
};
|
|
170
|
+
}
|
|
110
171
|
|
|
111
|
-
export { getAccountAddressAsString, getAccountAddressAsUint8Array, mnemonicAccountFromEnvironment, multisigAccount, randomAccount, rekeyedAccount, transactionSignerAccount };
|
|
172
|
+
export { getAccountAddressAsString, getAccountAddressAsUint8Array, getAccountAssetInformation, getAccountInformation, mnemonicAccountFromEnvironment, multisigAccount, randomAccount, rekeyedAccount, transactionSignerAccount };
|
|
112
173
|
//# sourceMappingURL=account.mjs.map
|
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":";;;;;;;;;AAUA,IAAO,uBAAuB,GAAG,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAA;AAOzD;;;;;AAKG;AACa,SAAA,eAAe,CAAC,cAAgC,EAAE,eAA6C,EAAA;AAC7G,IAAA,OAAO,IAAI,eAAe,CAAC,cAAc,EAAE,eAAe,CAAC,CAAA;AAC7D,CAAC;AAED;;;;;AAKG;AACa,SAAA,cAAc,CAAC,MAAe,EAAE,MAAc,EAAA;AAC5D,IAAA,OAAO,IAAI,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAC3C,CAAC;AAED;;;;;AAKG;AACa,SAAA,wBAAwB,CAAC,MAAyB,EAAE,MAAc,EAAA;AAChF,IAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAA;AACjC,CAAC;AAED;;;;AAIG;SACa,aAAa,GAAA;;AAE3B,IAAA,OAAO,OAAO,CAAC,eAAe,EAAE,CAAA;AAClC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BG;AACI,eAAe,8BAA8B,CAClD,OAAyD,EACzD,KAAc,EACd,SAAe,EAAA;IAEf,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,OAAO,OAAO,KAAK,QAAQ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AAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,cAAc,OAAO,CAAA;AACrB,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,yBAAyB,CAAA"}
|
package/index.js
CHANGED
|
@@ -9,6 +9,7 @@ var config = require('./config.js');
|
|
|
9
9
|
var dispenserClient = require('./dispenser-client.js');
|
|
10
10
|
var indexerLookup = require('./indexer-lookup.js');
|
|
11
11
|
var networkClient = require('./network-client.js');
|
|
12
|
+
var types_algorandClient = require('./types/algorand-client.js');
|
|
12
13
|
var account = require('./account/account.js');
|
|
13
14
|
var getAccount = require('./account/get-account.js');
|
|
14
15
|
var getAccountConfigFromEnvironment = require('./account/get-account-config-from-environment.js');
|
|
@@ -82,8 +83,11 @@ exports.getDefaultLocalNetConfig = networkClient.getDefaultLocalNetConfig;
|
|
|
82
83
|
exports.getIndexerConfigFromEnvironment = networkClient.getIndexerConfigFromEnvironment;
|
|
83
84
|
exports.isMainNet = networkClient.isMainNet;
|
|
84
85
|
exports.isTestNet = networkClient.isTestNet;
|
|
86
|
+
exports.AlgorandClient = types_algorandClient.AlgorandClient;
|
|
85
87
|
exports.getAccountAddressAsString = account.getAccountAddressAsString;
|
|
86
88
|
exports.getAccountAddressAsUint8Array = account.getAccountAddressAsUint8Array;
|
|
89
|
+
exports.getAccountAssetInformation = account.getAccountAssetInformation;
|
|
90
|
+
exports.getAccountInformation = account.getAccountInformation;
|
|
87
91
|
exports.mnemonicAccountFromEnvironment = account.mnemonicAccountFromEnvironment;
|
|
88
92
|
exports.multisigAccount = account.multisigAccount;
|
|
89
93
|
exports.randomAccount = account.randomAccount;
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/index.mjs
CHANGED
|
@@ -7,7 +7,8 @@ export { Config } from './config.mjs';
|
|
|
7
7
|
export { getTestNetDispenserApiClient } from './dispenser-client.mjs';
|
|
8
8
|
export { executePaginatedRequest, lookupAccountByAddress, lookupAccountCreatedApplicationByAddress, lookupTransactionById, searchTransactions } from './indexer-lookup.mjs';
|
|
9
9
|
export { getAlgoClient, getAlgoIndexerClient, getAlgoKmdClient, getAlgoNodeConfig, getAlgodConfigFromEnvironment, getConfigFromEnvOrDefaults, getDefaultLocalNetConfig, getIndexerConfigFromEnvironment, isMainNet, isTestNet } from './network-client.mjs';
|
|
10
|
-
export {
|
|
10
|
+
export { AlgorandClient } from './types/algorand-client.mjs';
|
|
11
|
+
export { getAccountAddressAsString, getAccountAddressAsUint8Array, getAccountAssetInformation, getAccountInformation, mnemonicAccountFromEnvironment, multisigAccount, randomAccount, rekeyedAccount, transactionSignerAccount } from './account/account.mjs';
|
|
11
12
|
export { getAccount } from './account/get-account.mjs';
|
|
12
13
|
export { getAccountConfigFromEnvironment } from './account/get-account-config-from-environment.mjs';
|
|
13
14
|
export { getDispenserAccount } from './account/get-dispenser-account.mjs';
|
package/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"**"
|
|
7
7
|
],
|
|
8
8
|
"name": "@algorandfoundation/algokit-utils",
|
|
9
|
-
"version": "6.0.0-beta.
|
|
9
|
+
"version": "6.0.0-beta.4",
|
|
10
10
|
"private": false,
|
|
11
11
|
"description": "A set of core Algorand utilities written in TypeScript and released via npm that make it easier to build solutions on Algorand.",
|
|
12
12
|
"author": "Algorand Foundation",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"algorand-fixture.d.ts","sourceRoot":"","sources":["../../../src/testing/fixtures/algorand-fixture.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"algorand-fixture.d.ts","sourceRoot":"","sources":["../../../src/testing/fixtures/algorand-fixture.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAuD,MAAM,qBAAqB,CAAA;AAKjI;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,eAAe,CAAC,aAAa,CAAC,EAAE,qBAAqB,GAAG,eAAe,CAAA;AAEvF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,eAAe,CAAC,aAAa,EAAE,qBAAqB,GAAG,SAAS,EAAE,MAAM,EAAE,UAAU,GAAG,eAAe,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var types_algorandClient = require('../../types/algorand-client.js');
|
|
3
4
|
var account = require('../account.js');
|
|
4
5
|
var indexer = require('../indexer.js');
|
|
5
6
|
var transactionLogger = require('../transaction-logger.js');
|
|
@@ -37,16 +38,25 @@ function algorandFixture(fixtureConfig, config$1) {
|
|
|
37
38
|
const indexer$1 = fixtureConfig?.indexer ?? networkClient.getAlgoIndexerClient(config$1.indexerConfig);
|
|
38
39
|
const kmd = fixtureConfig?.kmd ?? networkClient.getAlgoKmdClient(config$1.kmdConfig);
|
|
39
40
|
let context;
|
|
41
|
+
let algorandClient;
|
|
40
42
|
const beforeEach = async () => {
|
|
41
43
|
config.Config.configure({ debug: true });
|
|
42
44
|
const transactionLogger$1 = new transactionLogger.TransactionLogger();
|
|
43
45
|
const transactionLoggerAlgod = transactionLogger$1.capture(algod);
|
|
46
|
+
const acc = await account.getTestAccount({ initialFunds: fixtureConfig?.testAccountFunding ?? amount.algos(10), suppressLog: true }, transactionLoggerAlgod, kmd);
|
|
47
|
+
algorandClient = algorandClient ?? types_algorandClient.AlgorandClient.fromClients({ algod: transactionLoggerAlgod, indexer: indexer$1, kmd });
|
|
48
|
+
algorandClient.setSignerFromAccount(acc).setDefaultValidityWindow(1000).setSuggestedParamsTimeout(0);
|
|
49
|
+
const testAccount = { ...acc, signer: algorandClient.account.getSigner(acc.addr) };
|
|
44
50
|
context = {
|
|
45
51
|
algod: transactionLoggerAlgod,
|
|
46
52
|
indexer: indexer$1,
|
|
47
53
|
kmd: kmd,
|
|
48
|
-
testAccount
|
|
49
|
-
generateAccount: (params) =>
|
|
54
|
+
testAccount,
|
|
55
|
+
generateAccount: async (params) => {
|
|
56
|
+
const account$1 = await account.getTestAccount(params, transactionLoggerAlgod, kmd);
|
|
57
|
+
algorandClient.setSignerFromAccount(account$1);
|
|
58
|
+
return { ...account$1, signer: algorandClient.account.getSigner(account$1.addr) };
|
|
59
|
+
},
|
|
50
60
|
transactionLogger: transactionLogger$1,
|
|
51
61
|
waitForIndexer: () => transactionLogger$1.waitForIndexer(indexer$1),
|
|
52
62
|
waitForIndexerTransaction: (transactionId) => indexer.runWhenIndexerCaughtUp(() => indexerLookup.lookupTransactionById(transactionId, indexer$1)),
|
|
@@ -56,6 +66,9 @@ function algorandFixture(fixtureConfig, config$1) {
|
|
|
56
66
|
get context() {
|
|
57
67
|
return context;
|
|
58
68
|
},
|
|
69
|
+
get algorand() {
|
|
70
|
+
return algorandClient;
|
|
71
|
+
},
|
|
59
72
|
beforeEach,
|
|
60
73
|
};
|
|
61
74
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"algorand-fixture.js","sources":["../../../src/testing/fixtures/algorand-fixture.ts"],"sourcesContent":[null],"names":["config","getConfigFromEnvOrDefaults","getAlgoClient","indexer","getAlgoIndexerClient","getAlgoKmdClient","Config","transactionLogger","TransactionLogger","getTestAccount","algos","runWhenIndexerCaughtUp","lookupTransactionById"],"mappings":"
|
|
1
|
+
{"version":3,"file":"algorand-fixture.js","sources":["../../../src/testing/fixtures/algorand-fixture.ts"],"sourcesContent":[null],"names":["config","getConfigFromEnvOrDefaults","getAlgoClient","indexer","getAlgoIndexerClient","getAlgoKmdClient","Config","transactionLogger","TransactionLogger","getTestAccount","algos","AlgorandClient","account","runWhenIndexerCaughtUp","lookupTransactionById"],"mappings":";;;;;;;;;;;AAiEA;;;;;;;;;;;;;;;;;;;;;;AAsBG;AACa,SAAA,eAAe,CAAC,aAAqC,EAAEA,QAAmB,EAAA;AACxF,IAAAA,QAAM,GAAGA,QAAM,IAAIC,wCAA0B,EAAE,CAAA;AAE/C,IAAA,MAAM,KAAK,GAAG,aAAa,EAAE,KAAK,IAAIC,2BAAa,CAACF,QAAM,CAAC,WAAW,CAAC,CAAA;AACvE,IAAA,MAAMG,SAAO,GAAG,aAAa,EAAE,OAAO,IAAIC,kCAAoB,CAACJ,QAAM,CAAC,aAAa,CAAC,CAAA;AACpF,IAAA,MAAM,GAAG,GAAG,aAAa,EAAE,GAAG,IAAIK,8BAAgB,CAACL,QAAM,CAAC,SAAS,CAAC,CAAA;AACpE,IAAA,IAAI,OAAsC,CAAA;AAC1C,IAAA,IAAI,cAA8B,CAAA;AAElC,IAAA,MAAM,UAAU,GAAG,YAAW;QAC5BM,aAAM,CAAC,SAAS,CAAC,EA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mBAAiB;YACpC,cAAc,EAAE,MAAMA,mBAAiB,CAAC,cAAc,CAACJ,SAAO,CAAC;AAC/D,YAAA,yBAAyB,EAAE,CAAC,aAAqB,KAAKU,8BAAsB,CAAC,MAAMC,mCAAqB,CAAC,aAAa,EAAEX,SAAO,CAAC,CAAC;SAClI,CAAA;AACH,KAAC,CAAA;IAED,OAAO;AACL,QAAA,IAAI,OAAO,GAAA;AACT,YAAA,OAAO,OAAO,CAAA;SACf;AACD,QAAA,IAAI,QAAQ,GAAA;AACV,YAAA,OAAO,cAAc,CAAA;SACtB;QACD,UAAU;KACX,CAAA;AACH;;;;"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AlgorandClient } from '../../types/algorand-client.mjs';
|
|
1
2
|
import { getTestAccount } from '../account.mjs';
|
|
2
3
|
import { runWhenIndexerCaughtUp } from '../indexer.mjs';
|
|
3
4
|
import { TransactionLogger } from '../transaction-logger.mjs';
|
|
@@ -35,16 +36,25 @@ function algorandFixture(fixtureConfig, config) {
|
|
|
35
36
|
const indexer = fixtureConfig?.indexer ?? getAlgoIndexerClient(config.indexerConfig);
|
|
36
37
|
const kmd = fixtureConfig?.kmd ?? getAlgoKmdClient(config.kmdConfig);
|
|
37
38
|
let context;
|
|
39
|
+
let algorandClient;
|
|
38
40
|
const beforeEach = async () => {
|
|
39
41
|
Config.configure({ debug: true });
|
|
40
42
|
const transactionLogger = new TransactionLogger();
|
|
41
43
|
const transactionLoggerAlgod = transactionLogger.capture(algod);
|
|
44
|
+
const acc = await getTestAccount({ initialFunds: fixtureConfig?.testAccountFunding ?? algos(10), suppressLog: true }, transactionLoggerAlgod, kmd);
|
|
45
|
+
algorandClient = algorandClient ?? AlgorandClient.fromClients({ algod: transactionLoggerAlgod, indexer, kmd });
|
|
46
|
+
algorandClient.setSignerFromAccount(acc).setDefaultValidityWindow(1000).setSuggestedParamsTimeout(0);
|
|
47
|
+
const testAccount = { ...acc, signer: algorandClient.account.getSigner(acc.addr) };
|
|
42
48
|
context = {
|
|
43
49
|
algod: transactionLoggerAlgod,
|
|
44
50
|
indexer: indexer,
|
|
45
51
|
kmd: kmd,
|
|
46
|
-
testAccount
|
|
47
|
-
generateAccount: (params) =>
|
|
52
|
+
testAccount,
|
|
53
|
+
generateAccount: async (params) => {
|
|
54
|
+
const account = await getTestAccount(params, transactionLoggerAlgod, kmd);
|
|
55
|
+
algorandClient.setSignerFromAccount(account);
|
|
56
|
+
return { ...account, signer: algorandClient.account.getSigner(account.addr) };
|
|
57
|
+
},
|
|
48
58
|
transactionLogger: transactionLogger,
|
|
49
59
|
waitForIndexer: () => transactionLogger.waitForIndexer(indexer),
|
|
50
60
|
waitForIndexerTransaction: (transactionId) => runWhenIndexerCaughtUp(() => lookupTransactionById(transactionId, indexer)),
|
|
@@ -54,6 +64,9 @@ function algorandFixture(fixtureConfig, config) {
|
|
|
54
64
|
get context() {
|
|
55
65
|
return context;
|
|
56
66
|
},
|
|
67
|
+
get algorand() {
|
|
68
|
+
return algorandClient;
|
|
69
|
+
},
|
|
57
70
|
beforeEach,
|
|
58
71
|
};
|
|
59
72
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"algorand-fixture.mjs","sources":["../../../src/testing/fixtures/algorand-fixture.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"algorand-fixture.mjs","sources":["../../../src/testing/fixtures/algorand-fixture.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;AAiEA;;;;;;;;;;;;;;;;;;;;;;AAsBG;AACa,SAAA,eAAe,CAAC,aAAqC,EAAE,MAAmB,EAAA;AACxF,IAAA,MAAM,GAAG,MAAM,IAAI,0BAA0B,EAAE,CAAA;AAE/C,IAAA,MAAM,KAAK,GAAG,aAAa,EAAE,KAAK,IAAI,aAAa,CAAC,MAAM,CAAC,WAAW,CAAC,CAAA;AACvE,IAAA,MAAM,OAAO,GAAG,aAAa,EAAE,OAAO,IAAI,oBAAoB,CAAC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