@algorandfoundation/algokit-utils 2.3.3-beta.3 → 2.3.3-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/cjs/account.d.ts.map +1 -0
- package/cjs/account.js.map +1 -0
- package/cjs/amount.d.ts.map +1 -0
- package/cjs/amount.js.map +1 -0
- package/cjs/app-client.d.ts.map +1 -0
- package/cjs/app-client.js.map +1 -0
- package/cjs/app-deploy.d.ts.map +1 -0
- package/cjs/app-deploy.js.map +1 -0
- package/cjs/app.d.ts.map +1 -0
- package/cjs/app.js.map +1 -0
- package/cjs/index.d.ts.map +1 -0
- package/cjs/index.js.map +1 -0
- package/cjs/indexer-lookup.d.ts.map +1 -0
- package/cjs/indexer-lookup.js.map +1 -0
- package/cjs/localnet.d.ts.map +1 -0
- package/{localnet.js → cjs/localnet.js} +1 -1
- package/cjs/localnet.js.map +1 -0
- package/cjs/network-client.d.ts.map +1 -0
- package/cjs/network-client.js.map +1 -0
- package/cjs/testing/account.d.ts.map +1 -0
- package/cjs/testing/account.js.map +1 -0
- package/cjs/testing/fixtures/algokit-log-capture-fixture.d.ts.map +1 -0
- package/cjs/testing/fixtures/algokit-log-capture-fixture.js.map +1 -0
- package/cjs/testing/fixtures/algorand-fixture.d.ts.map +1 -0
- package/cjs/testing/fixtures/algorand-fixture.js.map +1 -0
- package/cjs/testing/fixtures/index.d.ts.map +1 -0
- package/cjs/testing/fixtures/index.js.map +1 -0
- package/cjs/testing/index.d.ts.map +1 -0
- package/cjs/testing/index.js.map +1 -0
- package/cjs/testing/indexer.d.ts.map +1 -0
- package/cjs/testing/indexer.js.map +1 -0
- package/cjs/testing/test-logger.d.ts.map +1 -0
- package/{testing → cjs/testing}/test-logger.js +2 -0
- package/cjs/testing/test-logger.js.map +1 -0
- package/cjs/testing/transaction-logger.d.ts.map +1 -0
- package/{testing → cjs/testing}/transaction-logger.js +2 -3
- package/cjs/testing/transaction-logger.js.map +1 -0
- package/cjs/transaction.d.ts.map +1 -0
- package/cjs/transaction.js.map +1 -0
- package/cjs/transfer.d.ts.map +1 -0
- package/cjs/transfer.js.map +1 -0
- package/cjs/types/account.d.ts +66 -0
- package/cjs/types/account.d.ts.map +1 -0
- package/{types → cjs/types}/account.js +7 -0
- package/cjs/types/account.js.map +1 -0
- package/cjs/types/algo-http-client-with-retry.d.ts.map +1 -0
- package/{types → cjs/types}/algo-http-client-with-retry.js +16 -16
- package/cjs/types/algo-http-client-with-retry.js.map +1 -0
- package/cjs/types/amount.d.ts +24 -0
- package/cjs/types/amount.d.ts.map +1 -0
- package/{types → cjs/types}/amount.js +1 -0
- package/cjs/types/amount.js.map +1 -0
- package/cjs/types/app-client.d.ts +408 -0
- package/cjs/types/app-client.d.ts.map +1 -0
- package/{types → cjs/types}/app-client.js +13 -0
- package/cjs/types/app-client.js.map +1 -0
- package/cjs/types/app-spec.d.ts.map +1 -0
- package/{types → cjs/types}/app-spec.js.map +1 -1
- package/cjs/types/app.d.ts +308 -0
- package/cjs/types/app.d.ts.map +1 -0
- package/cjs/types/app.js.map +1 -0
- package/cjs/types/config.d.ts.map +1 -0
- package/{types → cjs/types}/config.js +1 -0
- package/cjs/types/config.js.map +1 -0
- package/cjs/types/indexer.d.ts.map +1 -0
- package/cjs/types/indexer.js.map +1 -0
- package/cjs/types/logging.d.ts.map +1 -0
- package/cjs/types/logging.js.map +1 -0
- package/cjs/types/logic-error.d.ts.map +1 -0
- package/{types → cjs/types}/logic-error.js +5 -2
- package/cjs/types/logic-error.js.map +1 -0
- package/cjs/types/network-client.d.ts +20 -0
- package/cjs/types/network-client.d.ts.map +1 -0
- package/cjs/types/network-client.js.map +1 -0
- package/cjs/types/testing.d.ts.map +1 -0
- package/{types → cjs/types}/testing.js.map +1 -1
- package/cjs/types/transaction.d.ts +111 -0
- package/cjs/types/transaction.d.ts.map +1 -0
- package/{types → cjs/types}/transaction.js.map +1 -1
- package/cjs/types/transfer.d.ts +32 -0
- package/cjs/types/transfer.d.ts.map +1 -0
- package/{types → cjs/types}/transfer.js.map +1 -1
- package/cjs/types/urlTokenBaseHTTPClient.d.ts.map +1 -0
- package/{types → cjs/types}/urlTokenBaseHTTPClient.js +4 -0
- package/cjs/types/urlTokenBaseHTTPClient.js.map +1 -0
- package/cjs/util.d.ts.map +1 -0
- package/cjs/util.js.map +1 -0
- package/esm/account.js +170 -0
- package/esm/account.js.map +1 -0
- package/esm/amount.js +27 -0
- package/esm/amount.js.map +1 -0
- package/esm/app-client.js +76 -0
- package/esm/app-client.js.map +1 -0
- package/esm/app-deploy.js +446 -0
- package/esm/app-deploy.js.map +1 -0
- package/esm/app.js +572 -0
- package/esm/app.js.map +1 -0
- package/esm/index.js +14 -0
- package/esm/index.js.map +1 -0
- package/esm/indexer-lookup.js +98 -0
- package/esm/indexer-lookup.js.map +1 -0
- package/esm/localnet.js +111 -0
- package/esm/localnet.js.map +1 -0
- package/esm/network-client.js +179 -0
- package/esm/network-client.js.map +1 -0
- package/esm/testing/account.js +24 -0
- package/esm/testing/account.js.map +1 -0
- package/esm/testing/fixtures/algokit-log-capture-fixture.js +39 -0
- package/esm/testing/fixtures/algokit-log-capture-fixture.js.map +1 -0
- package/esm/testing/fixtures/algorand-fixture.js +53 -0
- package/esm/testing/fixtures/algorand-fixture.js.map +1 -0
- package/esm/testing/fixtures/index.js +3 -0
- package/esm/testing/fixtures/index.js.map +1 -0
- package/esm/testing/index.js +6 -0
- package/esm/testing/index.js.map +1 -0
- package/esm/testing/indexer.js +36 -0
- package/esm/testing/indexer.js.map +1 -0
- package/esm/testing/test-logger.js +69 -0
- package/esm/testing/test-logger.js.map +1 -0
- package/esm/testing/transaction-logger.js +66 -0
- package/esm/testing/transaction-logger.js.map +1 -0
- package/esm/transaction.js +365 -0
- package/esm/transaction.js.map +1 -0
- package/esm/transfer.js +59 -0
- package/esm/transfer.js.map +1 -0
- package/esm/types/account.js +90 -0
- package/esm/types/account.js.map +1 -0
- package/esm/types/algo-http-client-with-retry.js +58 -0
- package/esm/types/algo-http-client-with-retry.js.map +1 -0
- package/esm/types/amount.js +35 -0
- package/esm/types/amount.js.map +1 -0
- package/esm/types/app-client.js +624 -0
- package/esm/types/app-client.js.map +1 -0
- package/esm/types/app-spec.js +2 -0
- package/esm/types/app-spec.js.map +1 -0
- package/esm/types/app.js +33 -0
- package/esm/types/app.js.map +1 -0
- package/esm/types/config.js +50 -0
- package/esm/types/config.js.map +1 -0
- package/esm/types/indexer.js +31 -0
- package/esm/types/indexer.js.map +1 -0
- package/esm/types/logging.js +24 -0
- package/esm/types/logging.js.map +1 -0
- package/esm/types/logic-error.js +49 -0
- package/esm/types/logic-error.js.map +1 -0
- package/esm/types/network-client.js +2 -0
- package/esm/types/network-client.js.map +1 -0
- package/esm/types/testing.js +2 -0
- package/esm/types/testing.js.map +1 -0
- package/esm/types/transaction.js +2 -0
- package/esm/types/transaction.js.map +1 -0
- package/esm/types/transfer.js +2 -0
- package/esm/types/transfer.js.map +1 -0
- package/esm/types/urlTokenBaseHTTPClient.js +151 -0
- package/esm/types/urlTokenBaseHTTPClient.js.map +1 -0
- package/esm/util.js +20 -0
- package/esm/util.js.map +1 -0
- package/package.json +40 -6
- package/types/account.d.ts +125 -63
- package/types/account.d.ts.map +1 -1
- package/types/amount.d.ts +18 -22
- package/types/amount.d.ts.map +1 -1
- package/types/app-client.d.ts +70 -407
- package/types/app-client.d.ts.map +1 -1
- package/types/app-deploy.d.ts +101 -0
- package/types/app-deploy.d.ts.map +1 -0
- package/types/app.d.ts +145 -290
- package/types/app.d.ts.map +1 -1
- package/types/index.d.ts +14 -0
- package/types/index.d.ts.map +1 -0
- package/types/indexer-lookup.d.ts +38 -0
- package/types/indexer-lookup.d.ts.map +1 -0
- package/types/localnet.d.ts +54 -0
- package/types/localnet.d.ts.map +1 -0
- package/types/network-client.d.ts +96 -19
- package/types/network-client.d.ts.map +1 -1
- package/types/testing/account.d.ts +14 -0
- package/types/testing/account.d.ts.map +1 -0
- package/types/testing/fixtures/algokit-log-capture-fixture.d.ts +19 -0
- package/types/testing/fixtures/algokit-log-capture-fixture.d.ts.map +1 -0
- package/types/testing/fixtures/algorand-fixture.d.ts +48 -0
- package/types/testing/fixtures/algorand-fixture.d.ts.map +1 -0
- package/types/testing/fixtures/index.d.ts +3 -0
- package/types/testing/fixtures/index.d.ts.map +1 -0
- package/types/testing/index.d.ts +6 -0
- package/types/testing/index.d.ts.map +1 -0
- package/types/testing/indexer.d.ts +12 -0
- package/types/testing/indexer.d.ts.map +1 -0
- package/types/testing/test-logger.d.ts +41 -0
- package/types/testing/test-logger.d.ts.map +1 -0
- package/types/testing/transaction-logger.d.ts +29 -0
- package/types/testing/transaction-logger.d.ts.map +1 -0
- package/types/transaction.d.ts +133 -106
- package/types/transaction.d.ts.map +1 -1
- package/types/transfer.d.ts +21 -31
- package/types/transfer.d.ts.map +1 -1
- package/types/types/account.d.ts +66 -0
- package/types/types/account.d.ts.map +1 -0
- package/types/types/algo-http-client-with-retry.d.ts +14 -0
- package/types/types/algo-http-client-with-retry.d.ts.map +1 -0
- package/types/types/amount.d.ts +24 -0
- package/types/types/amount.d.ts.map +1 -0
- package/types/types/app-client.d.ts +408 -0
- package/types/types/app-client.d.ts.map +1 -0
- package/types/types/app-spec.d.ts +154 -0
- package/types/types/app-spec.d.ts.map +1 -0
- package/types/types/app.d.ts +308 -0
- package/types/types/app.d.ts.map +1 -0
- package/types/types/config.d.ts +32 -0
- package/types/types/config.d.ts.map +1 -0
- package/types/types/indexer.d.ts +623 -0
- package/types/types/indexer.d.ts.map +1 -0
- package/types/types/logging.d.ts +13 -0
- package/types/types/logging.d.ts.map +1 -0
- package/types/types/logic-error.d.ts +37 -0
- package/types/types/logic-error.d.ts.map +1 -0
- package/types/types/network-client.d.ts +20 -0
- package/types/types/network-client.d.ts.map +1 -0
- package/types/types/testing.d.ts +89 -0
- package/types/types/testing.d.ts.map +1 -0
- package/types/types/transaction.d.ts +111 -0
- package/types/types/transaction.d.ts.map +1 -0
- package/types/types/transfer.d.ts +32 -0
- package/types/types/transfer.d.ts.map +1 -0
- package/types/types/urlTokenBaseHTTPClient.d.ts +41 -0
- package/types/types/urlTokenBaseHTTPClient.d.ts.map +1 -0
- package/types/util.d.ts +10 -0
- package/types/util.d.ts.map +1 -0
- package/account.d.ts.map +0 -1
- package/account.js.map +0 -1
- package/amount.d.ts.map +0 -1
- package/amount.js.map +0 -1
- package/app-client.d.ts.map +0 -1
- package/app-client.js.map +0 -1
- package/app-deploy.d.ts.map +0 -1
- package/app-deploy.js.map +0 -1
- package/app.d.ts.map +0 -1
- package/app.js.map +0 -1
- package/index.d.ts.map +0 -1
- package/index.js.map +0 -1
- package/indexer-lookup.d.ts.map +0 -1
- package/indexer-lookup.js.map +0 -1
- package/localnet.d.ts.map +0 -1
- package/localnet.js.map +0 -1
- package/network-client.d.ts.map +0 -1
- package/network-client.js.map +0 -1
- package/testing/account.d.ts.map +0 -1
- package/testing/account.js.map +0 -1
- package/testing/fixtures/algokit-log-capture-fixture.d.ts.map +0 -1
- package/testing/fixtures/algokit-log-capture-fixture.js.map +0 -1
- package/testing/fixtures/algorand-fixture.d.ts.map +0 -1
- package/testing/fixtures/algorand-fixture.js.map +0 -1
- package/testing/fixtures/index.d.ts.map +0 -1
- package/testing/fixtures/index.js.map +0 -1
- package/testing/index.d.ts.map +0 -1
- package/testing/index.js.map +0 -1
- package/testing/indexer.d.ts.map +0 -1
- package/testing/indexer.js.map +0 -1
- package/testing/test-logger.d.ts.map +0 -1
- package/testing/test-logger.js.map +0 -1
- package/testing/transaction-logger.d.ts.map +0 -1
- package/testing/transaction-logger.js.map +0 -1
- package/transaction.d.ts.map +0 -1
- package/transaction.js.map +0 -1
- package/transfer.d.ts.map +0 -1
- package/transfer.js.map +0 -1
- package/types/account.js.map +0 -1
- package/types/algo-http-client-with-retry.d.ts.map +0 -1
- package/types/algo-http-client-with-retry.js.map +0 -1
- package/types/amount.js.map +0 -1
- package/types/app-client.js.map +0 -1
- package/types/app-spec.d.ts.map +0 -1
- package/types/app.js.map +0 -1
- package/types/config.d.ts.map +0 -1
- package/types/config.js.map +0 -1
- package/types/indexer.d.ts.map +0 -1
- package/types/indexer.js.map +0 -1
- package/types/logging.d.ts.map +0 -1
- package/types/logging.js.map +0 -1
- package/types/logic-error.d.ts.map +0 -1
- package/types/logic-error.js.map +0 -1
- package/types/network-client.js.map +0 -1
- package/types/testing.d.ts.map +0 -1
- package/types/urlTokenBaseHTTPClient.d.ts.map +0 -1
- package/types/urlTokenBaseHTTPClient.js.map +0 -1
- package/util.d.ts.map +0 -1
- package/util.js.map +0 -1
- /package/{account.d.ts → cjs/account.d.ts} +0 -0
- /package/{account.js → cjs/account.js} +0 -0
- /package/{amount.d.ts → cjs/amount.d.ts} +0 -0
- /package/{amount.js → cjs/amount.js} +0 -0
- /package/{app-client.d.ts → cjs/app-client.d.ts} +0 -0
- /package/{app-client.js → cjs/app-client.js} +0 -0
- /package/{app-deploy.d.ts → cjs/app-deploy.d.ts} +0 -0
- /package/{app-deploy.js → cjs/app-deploy.js} +0 -0
- /package/{app.d.ts → cjs/app.d.ts} +0 -0
- /package/{app.js → cjs/app.js} +0 -0
- /package/{index.d.ts → cjs/index.d.ts} +0 -0
- /package/{index.js → cjs/index.js} +0 -0
- /package/{indexer-lookup.d.ts → cjs/indexer-lookup.d.ts} +0 -0
- /package/{indexer-lookup.js → cjs/indexer-lookup.js} +0 -0
- /package/{localnet.d.ts → cjs/localnet.d.ts} +0 -0
- /package/{network-client.d.ts → cjs/network-client.d.ts} +0 -0
- /package/{network-client.js → cjs/network-client.js} +0 -0
- /package/{testing → cjs/testing}/account.d.ts +0 -0
- /package/{testing → cjs/testing}/account.js +0 -0
- /package/{testing → cjs/testing}/fixtures/algokit-log-capture-fixture.d.ts +0 -0
- /package/{testing → cjs/testing}/fixtures/algokit-log-capture-fixture.js +0 -0
- /package/{testing → cjs/testing}/fixtures/algorand-fixture.d.ts +0 -0
- /package/{testing → cjs/testing}/fixtures/algorand-fixture.js +0 -0
- /package/{testing → cjs/testing}/fixtures/index.d.ts +0 -0
- /package/{testing → cjs/testing}/fixtures/index.js +0 -0
- /package/{testing → cjs/testing}/index.d.ts +0 -0
- /package/{testing → cjs/testing}/index.js +0 -0
- /package/{testing → cjs/testing}/indexer.d.ts +0 -0
- /package/{testing → cjs/testing}/indexer.js +0 -0
- /package/{testing → cjs/testing}/test-logger.d.ts +0 -0
- /package/{testing → cjs/testing}/transaction-logger.d.ts +0 -0
- /package/{transaction.d.ts → cjs/transaction.d.ts} +0 -0
- /package/{transaction.js → cjs/transaction.js} +0 -0
- /package/{transfer.d.ts → cjs/transfer.d.ts} +0 -0
- /package/{transfer.js → cjs/transfer.js} +0 -0
- /package/{types → cjs/types}/algo-http-client-with-retry.d.ts +0 -0
- /package/{types → cjs/types}/app-spec.d.ts +0 -0
- /package/{types → cjs/types}/app-spec.js +0 -0
- /package/{types → cjs/types}/app.js +0 -0
- /package/{types → cjs/types}/config.d.ts +0 -0
- /package/{types → cjs/types}/indexer.d.ts +0 -0
- /package/{types → cjs/types}/indexer.js +0 -0
- /package/{types → cjs/types}/logging.d.ts +0 -0
- /package/{types → cjs/types}/logging.js +0 -0
- /package/{types → cjs/types}/logic-error.d.ts +0 -0
- /package/{types → cjs/types}/network-client.js +0 -0
- /package/{types → cjs/types}/testing.d.ts +0 -0
- /package/{types → cjs/types}/testing.js +0 -0
- /package/{types → cjs/types}/transaction.js +0 -0
- /package/{types → cjs/types}/transfer.js +0 -0
- /package/{types → cjs/types}/urlTokenBaseHTTPClient.d.ts +0 -0
- /package/{util.d.ts → cjs/util.d.ts} +0 -0
- /package/{util.js → cjs/util.js} +0 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import algosdk from 'algosdk';
|
|
2
|
+
/**
|
|
3
|
+
* The account name identifier used for fund dispensing in test environments
|
|
4
|
+
*/
|
|
5
|
+
export const DISPENSER_ACCOUNT = 'DISPENSER';
|
|
6
|
+
/** Account wrapper that supports partial or full multisig signing. */
|
|
7
|
+
export class MultisigAccount {
|
|
8
|
+
_params;
|
|
9
|
+
_signingAccounts;
|
|
10
|
+
_addr;
|
|
11
|
+
_signer;
|
|
12
|
+
/** The parameters for the multisig account */
|
|
13
|
+
get params() {
|
|
14
|
+
return this._params;
|
|
15
|
+
}
|
|
16
|
+
/** The list of accounts that are present to sign */
|
|
17
|
+
get signingAccounts() {
|
|
18
|
+
return this._signingAccounts;
|
|
19
|
+
}
|
|
20
|
+
/** The address of the multisig account */
|
|
21
|
+
get addr() {
|
|
22
|
+
return this._addr;
|
|
23
|
+
}
|
|
24
|
+
get signer() {
|
|
25
|
+
return this._signer;
|
|
26
|
+
}
|
|
27
|
+
constructor(multisigParams, signingAccounts) {
|
|
28
|
+
this._params = multisigParams;
|
|
29
|
+
this._signingAccounts = signingAccounts;
|
|
30
|
+
this._addr = algosdk.multisigAddress(multisigParams);
|
|
31
|
+
this._signer = algosdk.makeMultiSigAccountTransactionSigner(multisigParams, signingAccounts.map((a) => a.sk));
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Sign the given transaction
|
|
35
|
+
* @param transaction Either a transaction object or a raw, partially signed transaction
|
|
36
|
+
* @returns The transaction signed by the present signers
|
|
37
|
+
*/
|
|
38
|
+
sign(transaction) {
|
|
39
|
+
let signedTxn = 'from' in transaction ? undefined : transaction;
|
|
40
|
+
for (const signer of this._signingAccounts) {
|
|
41
|
+
if (signedTxn) {
|
|
42
|
+
signedTxn = algosdk.appendSignMultisigTransaction(signedTxn, this._params, signer.sk).blob;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
signedTxn = algosdk.signMultisigTransaction(transaction, this._params, signer.sk).blob;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
49
|
+
return signedTxn;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/** Account wrapper that supports a rekeyed account */
|
|
53
|
+
export class SigningAccount {
|
|
54
|
+
_account;
|
|
55
|
+
_signer;
|
|
56
|
+
_sender;
|
|
57
|
+
/**
|
|
58
|
+
* Algorand address of the sender
|
|
59
|
+
*/
|
|
60
|
+
get addr() {
|
|
61
|
+
return this._sender;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Secret key belonging to the signer
|
|
65
|
+
*/
|
|
66
|
+
get sk() {
|
|
67
|
+
return this._account.sk;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Transaction signer for the underlying signing account
|
|
71
|
+
*/
|
|
72
|
+
get signer() {
|
|
73
|
+
return this._signer;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Algorand account of the sender address and signer private key
|
|
77
|
+
*/
|
|
78
|
+
get sender() {
|
|
79
|
+
return {
|
|
80
|
+
addr: this._sender,
|
|
81
|
+
sk: this._account.sk,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
constructor(account, sender) {
|
|
85
|
+
this._account = account;
|
|
86
|
+
this._sender = sender ?? account.addr;
|
|
87
|
+
this._signer = algosdk.makeBasicAccountTransactionSigner(account);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=account.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../../src/types/account.ts"],"names":[],"mappings":"AAAA,OAAO,OAAsE,MAAM,SAAS,CAAA;AAE5F;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,WAAW,CAAA;AAE5C,sEAAsE;AACtE,MAAM,OAAO,eAAe;IAC1B,OAAO,CAA0B;IACjC,gBAAgB,CAAsC;IACtD,KAAK,CAAQ;IACb,OAAO,CAAmB;IAE1B,8CAA8C;IAC9C,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;IAED,oDAAoD;IACpD,IAAI,eAAe;QACjB,OAAO,IAAI,CAAC,gBAAgB,CAAA;IAC9B,CAAC;IAED,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H,IAAI,EAAE;QACJ,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAA;IACzB,CAAC;IAED;;OAEG;IACH,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;IAED;;OAEG;IACH,IAAI,MAAM;QACR,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,OAAO;YAClB,EAAE,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE;SACrB,CAAA;IACH,CAAC;IAED,YAAY,OAAgB,EAAE,MAA0B;QACtD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;QACvB,IAAI,CAAC,OAAO,GAAG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAA;QACrC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,iCAAiC,CAAC,OAAO,CAAC,CAAA;IACnE,CAAC;CACF"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Config } from '../';
|
|
2
|
+
import { URLTokenBaseHTTPClient } from './urlTokenBaseHTTPClient';
|
|
3
|
+
/** A HTTP Client that wraps the Algorand SDK HTTP Client with retries */
|
|
4
|
+
export class AlgoHttpClientWithRetry extends URLTokenBaseHTTPClient {
|
|
5
|
+
static MAX_TRIES = 5;
|
|
6
|
+
static MAX_BACKOFF_MS = 10000;
|
|
7
|
+
// These lists come from https://visionmedia.github.io/superagent/#retrying-requests
|
|
8
|
+
// which is the underlying library used by algosdk - but the CloudFlare specific 52X status codes have been removed
|
|
9
|
+
static RETRY_STATUS_CODES = [408, 413, 429, 500, 502, 503, 504];
|
|
10
|
+
static RETRY_ERROR_CODES = [
|
|
11
|
+
'ETIMEDOUT',
|
|
12
|
+
'ECONNRESET',
|
|
13
|
+
'EADDRINUSE',
|
|
14
|
+
'ECONNREFUSED',
|
|
15
|
+
'EPIPE',
|
|
16
|
+
'ENOTFOUND',
|
|
17
|
+
'ENETUNREACH',
|
|
18
|
+
'EAI_AGAIN',
|
|
19
|
+
'EPROTO', // We get this intermittently with AlgoNode API
|
|
20
|
+
];
|
|
21
|
+
async callWithRetry(func) {
|
|
22
|
+
let response;
|
|
23
|
+
let numTries = 1;
|
|
24
|
+
do {
|
|
25
|
+
try {
|
|
26
|
+
response = await func();
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
if (numTries >= AlgoHttpClientWithRetry.MAX_TRIES) {
|
|
31
|
+
throw err;
|
|
32
|
+
}
|
|
33
|
+
// Only retry for one of the hardcoded conditions
|
|
34
|
+
if (!(AlgoHttpClientWithRetry.RETRY_ERROR_CODES.includes(err.code) || AlgoHttpClientWithRetry.RETRY_STATUS_CODES.includes(err.status))) {
|
|
35
|
+
throw err;
|
|
36
|
+
}
|
|
37
|
+
// Retry immediately the first time, then exponentially backoff.
|
|
38
|
+
const delayTimeMs = numTries == 1 ? 0 : Math.min(1000 * Math.pow(2, numTries - 1), AlgoHttpClientWithRetry.MAX_BACKOFF_MS);
|
|
39
|
+
if (delayTimeMs > 0) {
|
|
40
|
+
await new Promise((r) => setTimeout(r, delayTimeMs));
|
|
41
|
+
}
|
|
42
|
+
Config.logger.warn(`algosdk request failed ${numTries} times. Retrying in ${delayTimeMs}ms: ${err}`);
|
|
43
|
+
}
|
|
44
|
+
} while (!response && ++numTries <= AlgoHttpClientWithRetry.MAX_TRIES);
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
46
|
+
return response;
|
|
47
|
+
}
|
|
48
|
+
async get(relativePath, query, requestHeaders = {}) {
|
|
49
|
+
return await this.callWithRetry(() => super.get(relativePath, query, requestHeaders));
|
|
50
|
+
}
|
|
51
|
+
async post(relativePath, data, query, requestHeaders = {}) {
|
|
52
|
+
return await this.callWithRetry(() => super.post(relativePath, data, query, requestHeaders));
|
|
53
|
+
}
|
|
54
|
+
async delete(relativePath, data, query, requestHeaders = {}) {
|
|
55
|
+
return await this.callWithRetry(() => super.delete(relativePath, data, query, requestHeaders));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=algo-http-client-with-retry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"algo-http-client-with-retry.js","sourceRoot":"","sources":["../../../src/types/algo-http-client-with-retry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,CAAA;AAC5B,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AAEjE,yEAAyE;AACzE,MAAM,OAAO,uBAAwB,SAAQ,sBAAsB;IACzD,MAAM,CAAU,SAAS,GAAG,CAAC,CAAA;IAC7B,MAAM,CAAU,cAAc,GAAG,KAAK,CAAA;IAE9C,oFAAoF;IACpF,mHAAmH;IAC3G,MAAM,CAAU,kBAAkB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;IACxE,MAAM,CAAU,iBAAiB,GAAG;QAC1C,WAAW;QACX,YAAY;QACZ,YAAY;QACZ,cAAc;QACd,OAAO;QACP,WAAW;QACX,aAAa;QACb,WAAW;QACX,QAAQ,EAAE,+CAA+C;KAC1D,CAAA;IAEO,KAAK,CAAC,aAAa,CAAC,IAA2C;QACrE,IAAI,QAA4C,CAAA;QAChD,IAAI,QAAQ,GAAG,CAAC,CAAA;QAChB,GAAG;YACD,IAAI;gBACF,QAAQ,GAAG,MAAM,IAAI,EAAE,CAAA;gBACvB,8DAA8D;aAC/D;YAAC,OAAO,GAAQ,EAAE;gBACjB,IAAI,QAAQ,IAAI,uBAAuB,CAAC,SAAS,EAAE;oBACjD,MAAM,GAAG,CAAA;iBACV;gBACD,iDAAiD;gBACjD,IACE,CAAC,CAAC,uBAAuB,CAAC,iBAAiB,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,uBAAuB,CAAC,kBAAkB,CAAC,QAAQ,CAAC,GAAG,CAAC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,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,YAAY,EAAE,IAAI,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,CAAA;IAChG,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import algosdk from 'algosdk';
|
|
2
|
+
/** Wrapper class to ensure safe, explicit conversion between µAlgos, Algos and numbers */
|
|
3
|
+
export class AlgoAmount {
|
|
4
|
+
amountInMicroAlgos;
|
|
5
|
+
/** Return the amount as a number in µAlgos */
|
|
6
|
+
get microAlgos() {
|
|
7
|
+
return this.amountInMicroAlgos;
|
|
8
|
+
}
|
|
9
|
+
/** Return the amount as a number in Algos */
|
|
10
|
+
get algos() {
|
|
11
|
+
return algosdk.microalgosToAlgos(this.amountInMicroAlgos);
|
|
12
|
+
}
|
|
13
|
+
constructor(amount) {
|
|
14
|
+
this.amountInMicroAlgos = 'microAlgos' in amount ? amount.microAlgos : algosdk.algosToMicroalgos(amount.algos);
|
|
15
|
+
}
|
|
16
|
+
toString() {
|
|
17
|
+
return `${this.microAlgos.toLocaleString('en-US')} µALGO${this.microAlgos === 1 ? '' : 's'}`;
|
|
18
|
+
}
|
|
19
|
+
/** valueOf allows you to use `AlgoAmount` in comparison operations such as `<` and `>=` etc.,
|
|
20
|
+
* but it's not recommended to use this to convert to a number, it's much safer to explicitly call
|
|
21
|
+
* the algos or microAlgos properties
|
|
22
|
+
*/
|
|
23
|
+
valueOf() {
|
|
24
|
+
return this.microAlgos;
|
|
25
|
+
}
|
|
26
|
+
/** Create a `AlgoAmount` object representing the given number of Algos */
|
|
27
|
+
static Algos(amount) {
|
|
28
|
+
return new AlgoAmount({ algos: amount });
|
|
29
|
+
}
|
|
30
|
+
/** Create a `AlgoAmount` object representing the given number of µAlgos */
|
|
31
|
+
static MicroAlgos(amount) {
|
|
32
|
+
return new AlgoAmount({ microAlgos: amount });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=amount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amount.js","sourceRoot":"","sources":["../../../src/types/amount.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAA;AAE7B,0FAA0F;AAC1F,MAAM,OAAO,UAAU;IACb,kBAAkB,CAAA;IAE1B,8CAA8C;IAC9C,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,kBAAkB,CAAA;IAChC,CAAC;IAED,6CAA6C;IAC7C,IAAI,KAAK;QACP,OAAO,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;IAC3D,CAAC;IAED,YAAY,MAAkD;QAC5D,IAAI,CAAC,kBAAkB,GAAG,YAAY,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IAChH,CAAC;IAED,QAAQ;QACN,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,OAAO,CAAC,SAAS,IAAI,CAAC,UAAU,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAA;IAC9F,CAAC;IAED;;;OAGG;IACH,OAAO;QACL,OAAO,IAAI,CAAC,UAAU,CAAA;IACxB,CAAC;IAED,0EAA0E;IAC1E,MAAM,CAAC,KAAK,CAAC,MAAc;QACzB,OAAO,IAAI,UAAU,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAA;IAC1C,CAAC;IAED,2EAA2E;IAC3E,MAAM,CAAC,UAAU,CAAC,MAAc;QAC9B,OAAO,IAAI,UAAU,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAA;IAC/C,CAAC;CACF"}
|