@algorandfoundation/algokit-utils 10.0.0-alpha.31 → 10.0.0-alpha.32
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-manager.d.ts +448 -0
- package/account-manager.js +623 -0
- package/account-manager.js.map +1 -0
- package/account-manager.mjs +620 -0
- package/account-manager.mjs.map +1 -0
- package/account.d.ts +156 -0
- package/account.js +10 -0
- package/account.js.map +1 -0
- package/account.mjs +9 -0
- package/account.mjs.map +1 -0
- package/algorand-client-transaction-creator.d.ts +1103 -0
- package/algorand-client-transaction-creator.js +735 -0
- package/algorand-client-transaction-creator.js.map +1 -0
- package/algorand-client-transaction-creator.mjs +734 -0
- package/algorand-client-transaction-creator.mjs.map +1 -0
- package/algorand-client-transaction-sender.d.ts +1317 -0
- package/algorand-client-transaction-sender.js +933 -0
- package/algorand-client-transaction-sender.js.map +1 -0
- package/algorand-client-transaction-sender.mjs +932 -0
- package/algorand-client-transaction-sender.mjs.map +1 -0
- package/algorand-client.d.ts +246 -0
- package/algorand-client.js +325 -0
- package/algorand-client.js.map +1 -0
- package/algorand-client.mjs +325 -0
- package/algorand-client.mjs.map +1 -0
- package/amount.d.ts +46 -3
- package/amount.js +92 -13
- package/amount.js.map +1 -1
- package/amount.mjs +80 -3
- package/amount.mjs.map +1 -1
- package/app-client.d.ts +2130 -0
- package/app-client.js +909 -0
- package/app-client.js.map +1 -0
- package/app-client.mjs +908 -0
- package/app-client.mjs.map +1 -0
- package/app-deployer.d.ts +166 -0
- package/app-deployer.js +353 -0
- package/app-deployer.js.map +1 -0
- package/app-deployer.mjs +353 -0
- package/app-deployer.mjs.map +1 -0
- package/app-factory.d.ts +965 -0
- package/app-factory.js +448 -0
- package/app-factory.js.map +1 -0
- package/app-factory.mjs +448 -0
- package/app-factory.mjs.map +1 -0
- package/app-manager.d.ts +323 -0
- package/app-manager.js +468 -0
- package/app-manager.js.map +1 -0
- package/app-manager.mjs +468 -0
- package/app-manager.mjs.map +1 -0
- package/app-spec.d.ts +203 -0
- package/app-spec.js +137 -0
- package/app-spec.js.map +1 -0
- package/app-spec.mjs +137 -0
- package/app-spec.mjs.map +1 -0
- package/app.d.ts +257 -0
- package/app.js +49 -0
- package/app.js.map +1 -0
- package/app.mjs +42 -0
- package/app.mjs.map +1 -0
- package/asset-manager.d.ts +212 -0
- package/asset-manager.js +166 -0
- package/asset-manager.js.map +1 -0
- package/asset-manager.mjs +166 -0
- package/asset-manager.mjs.map +1 -0
- package/async-event-emitter.d.ts +16 -0
- package/async-event-emitter.js +38 -0
- package/async-event-emitter.js.map +1 -0
- package/async-event-emitter.mjs +37 -0
- package/async-event-emitter.mjs.map +1 -0
- package/client-manager.d.ts +475 -0
- package/client-manager.js +616 -0
- package/client-manager.js.map +1 -0
- package/client-manager.mjs +616 -0
- package/client-manager.mjs.map +1 -0
- package/composer.d.ts +947 -0
- package/composer.js +1584 -0
- package/composer.js.map +1 -0
- package/composer.mjs +1583 -0
- package/composer.mjs.map +1 -0
- package/config.d.ts +1 -1
- package/config.js +2 -2
- package/config.js.map +1 -1
- package/config.mjs +1 -1
- package/config.mjs.map +1 -1
- package/debugging.d.ts +47 -0
- package/debugging.js +20 -0
- package/debugging.js.map +1 -0
- package/debugging.mjs +15 -0
- package/debugging.mjs.map +1 -0
- package/dispenser-client.d.ts +90 -0
- package/dispenser-client.js +127 -0
- package/dispenser-client.js.map +1 -0
- package/dispenser-client.mjs +127 -0
- package/dispenser-client.mjs.map +1 -0
- package/expand.d.ts +2 -0
- package/expand.js +0 -0
- package/expand.mjs +0 -0
- package/index.d.ts +6 -5
- package/index.js +4 -3
- package/index.mjs +5 -5
- package/indexer-client/indexer-lookup.d.ts +1 -1
- package/indexer-client/indexer-lookup.js.map +1 -1
- package/indexer-client/indexer-lookup.mjs.map +1 -1
- package/indexer.d.ts +40 -0
- package/indexer.js +38 -0
- package/indexer.js.map +1 -0
- package/indexer.mjs +35 -0
- package/indexer.mjs.map +1 -0
- package/instance-of.d.ts +8 -0
- package/kmd-account-manager.d.ts +74 -0
- package/kmd-account-manager.js +167 -0
- package/kmd-account-manager.js.map +1 -0
- package/kmd-account-manager.mjs +165 -0
- package/kmd-account-manager.mjs.map +1 -0
- package/lifecycle-events.d.ts +14 -0
- package/lifecycle-events.js +11 -0
- package/lifecycle-events.js.map +1 -0
- package/lifecycle-events.mjs +10 -0
- package/lifecycle-events.mjs.map +1 -0
- package/logging.d.ts +13 -0
- package/logging.js +47 -0
- package/logging.js.map +1 -0
- package/logging.mjs +42 -0
- package/logging.mjs.map +1 -0
- package/logic-error.d.ts +39 -0
- package/logic-error.js +54 -0
- package/logic-error.js.map +1 -0
- package/logic-error.mjs +53 -0
- package/logic-error.mjs.map +1 -0
- package/network-client.d.ts +43 -0
- package/network-client.js +14 -0
- package/network-client.js.map +1 -0
- package/network-client.mjs +13 -0
- package/network-client.mjs.map +1 -0
- package/package.json +11 -1
- package/testing/account.d.ts +2 -2
- package/testing/account.js +1 -1
- package/testing/account.js.map +1 -1
- package/testing/account.mjs +1 -1
- package/testing/account.mjs.map +1 -1
- package/testing/fixtures/algokit-log-capture-fixture.d.ts +1 -1
- package/testing/fixtures/algokit-log-capture-fixture.js.map +1 -1
- package/testing/fixtures/algokit-log-capture-fixture.mjs.map +1 -1
- package/testing/fixtures/algorand-fixture.d.ts +2 -2
- package/testing/fixtures/algorand-fixture.js +2 -2
- package/testing/fixtures/algorand-fixture.js.map +1 -1
- package/testing/fixtures/algorand-fixture.mjs +2 -2
- package/testing/fixtures/algorand-fixture.mjs.map +1 -1
- package/testing/index.d.ts +2 -1
- package/testing/test-logger.d.ts +1 -1
- package/testing/test-logger.js.map +1 -1
- package/testing/test-logger.mjs.map +1 -1
- package/testing/types.d.ts +156 -0
- package/transaction/index.d.ts +4 -0
- package/transaction/index.js +9 -0
- package/transaction/index.mjs +4 -0
- package/transaction/perform-transaction-composer-simulate.d.ts +1 -1
- package/transaction/perform-transaction-composer-simulate.js.map +1 -1
- package/transaction/perform-transaction-composer-simulate.mjs.map +1 -1
- package/transaction/transaction.d.ts +2 -2
- package/transaction/transaction.js.map +1 -1
- package/transaction/transaction.mjs.map +1 -1
- package/transaction/types.d.ts +133 -0
- package/transactions/app-call.d.ts +1 -1
- package/transactions/app-call.js +1 -1
- package/transactions/app-call.js.map +1 -1
- package/transactions/app-call.mjs +1 -1
- package/transactions/app-call.mjs.map +1 -1
- package/transactions/common.d.ts +1 -1
- package/transactions/common.js.map +1 -1
- package/transactions/common.mjs.map +1 -1
- package/transactions/method-call.d.ts +1 -1
- package/transactions/method-call.js +1 -1
- package/transactions/method-call.js.map +1 -1
- package/transactions/method-call.mjs +1 -1
- package/transactions/method-call.mjs.map +1 -1
- package/transactions/payment.d.ts +1 -1
- package/transactions/payment.js.map +1 -1
- package/transactions/payment.mjs.map +1 -1
- package/types/account-manager.d.ts +11 -442
- package/types/account-manager.js +5 -616
- package/types/account-manager.js.map +1 -1
- package/types/account-manager.mjs +5 -614
- package/types/account-manager.mjs.map +1 -1
- package/types/account.d.ts +8 -150
- package/types/account.js +3 -4
- package/types/account.js.map +1 -1
- package/types/account.mjs +4 -4
- package/types/account.mjs.map +1 -1
- package/types/algorand-client-transaction-creator.d.ts +5 -1098
- package/types/algorand-client-transaction-creator.js +3 -729
- package/types/algorand-client-transaction-creator.js.map +1 -1
- package/types/algorand-client-transaction-creator.mjs +4 -729
- package/types/algorand-client-transaction-creator.mjs.map +1 -1
- package/types/algorand-client-transaction-sender.d.ts +5 -1312
- package/types/algorand-client-transaction-sender.js +3 -927
- package/types/algorand-client-transaction-sender.js.map +1 -1
- package/types/algorand-client-transaction-sender.mjs +3 -926
- package/types/algorand-client-transaction-sender.mjs.map +1 -1
- package/types/algorand-client.d.ts +5 -241
- package/types/algorand-client.js +3 -319
- package/types/algorand-client.js.map +1 -1
- package/types/algorand-client.mjs +3 -319
- package/types/algorand-client.mjs.map +1 -1
- package/types/amount.d.ts +6 -45
- package/types/amount.js +3 -79
- package/types/amount.js.map +1 -1
- package/types/amount.mjs +4 -79
- package/types/amount.mjs.map +1 -1
- package/types/app-client.d.ts +75 -2125
- package/types/app-client.js +3 -903
- package/types/app-client.js.map +1 -1
- package/types/app-client.mjs +3 -902
- package/types/app-client.mjs.map +1 -1
- package/types/app-deployer.d.ts +21 -161
- package/types/app-deployer.js +3 -347
- package/types/app-deployer.js.map +1 -1
- package/types/app-deployer.mjs +3 -347
- package/types/app-deployer.mjs.map +1 -1
- package/types/app-factory.d.ts +21 -960
- package/types/app-factory.js +3 -442
- package/types/app-factory.js.map +1 -1
- package/types/app-factory.mjs +3 -442
- package/types/app-factory.mjs.map +1 -1
- package/types/app-manager.d.ts +15 -318
- package/types/app-manager.js +3 -462
- package/types/app-manager.js.map +1 -1
- package/types/app-manager.mjs +3 -462
- package/types/app-manager.mjs.map +1 -1
- package/types/app-spec.d.ts +39 -198
- package/types/app-spec.js +3 -131
- package/types/app-spec.js.map +1 -1
- package/types/app-spec.mjs +3 -131
- package/types/app-spec.mjs.map +1 -1
- package/types/app.d.ts +62 -247
- package/types/app.js +15 -37
- package/types/app.js.map +1 -1
- package/types/app.mjs +16 -37
- package/types/app.mjs.map +1 -1
- package/types/asset-manager.d.ts +9 -207
- package/types/asset-manager.js +3 -160
- package/types/asset-manager.js.map +1 -1
- package/types/asset-manager.mjs +3 -160
- package/types/asset-manager.mjs.map +1 -1
- package/types/async-event-emitter.d.ts +7 -11
- package/types/async-event-emitter.js +3 -32
- package/types/async-event-emitter.js.map +1 -1
- package/types/async-event-emitter.mjs +4 -32
- package/types/async-event-emitter.mjs.map +1 -1
- package/types/client-manager.d.ts +27 -470
- package/types/client-manager.js +3 -610
- package/types/client-manager.js.map +1 -1
- package/types/client-manager.mjs +3 -610
- package/types/client-manager.mjs.map +1 -1
- package/types/composer.d.ts +79 -943
- package/types/composer.js +3 -1578
- package/types/composer.js.map +1 -1
- package/types/composer.mjs +3 -1577
- package/types/composer.mjs.map +1 -1
- package/types/config.d.ts +7 -52
- package/types/config.js +3 -74
- package/types/config.js.map +1 -1
- package/types/config.mjs +3 -74
- package/types/config.mjs.map +1 -1
- package/types/debugging.d.ts +12 -37
- package/types/debugging.js +11 -10
- package/types/debugging.js.map +1 -1
- package/types/debugging.mjs +12 -10
- package/types/debugging.mjs.map +1 -1
- package/types/dispenser-client.d.ts +11 -85
- package/types/dispenser-client.js +3 -121
- package/types/dispenser-client.js.map +1 -1
- package/types/dispenser-client.mjs +3 -121
- package/types/dispenser-client.mjs.map +1 -1
- package/types/expand.d.ts +8 -2
- package/types/indexer.d.ts +16 -36
- package/types/indexer.js +7 -30
- package/types/indexer.js.map +1 -1
- package/types/indexer.mjs +8 -30
- package/types/indexer.mjs.map +1 -1
- package/types/instance-of.d.ts +4 -4
- package/types/kmd-account-manager.d.ts +5 -69
- package/types/kmd-account-manager.js +3 -161
- package/types/kmd-account-manager.js.map +1 -1
- package/types/kmd-account-manager.mjs +3 -159
- package/types/kmd-account-manager.mjs.map +1 -1
- package/types/lifecycle-events.d.ts +7 -9
- package/types/lifecycle-events.js +3 -5
- package/types/lifecycle-events.js.map +1 -1
- package/types/lifecycle-events.mjs +4 -5
- package/types/lifecycle-events.mjs.map +1 -1
- package/types/logging.d.ts +14 -9
- package/types/logging.js +11 -37
- package/types/logging.js.map +1 -1
- package/types/logging.mjs +12 -37
- package/types/logging.mjs.map +1 -1
- package/types/logic-error.d.ts +8 -35
- package/types/logic-error.js +3 -48
- package/types/logic-error.js.map +1 -1
- package/types/logic-error.mjs +4 -48
- package/types/logic-error.mjs.map +1 -1
- package/types/network-client.d.ts +10 -39
- package/types/network-client.js +3 -8
- package/types/network-client.js.map +1 -1
- package/types/network-client.mjs +4 -8
- package/types/network-client.mjs.map +1 -1
- package/types/testing.d.ts +13 -151
- package/types/transaction.d.ts +33 -128
- package/updatable-config.d.ts +57 -0
- package/updatable-config.js +80 -0
- package/updatable-config.js.map +1 -0
- package/updatable-config.mjs +80 -0
- package/updatable-config.mjs.map +1 -0
- package/util.js +1 -1
- package/util.js.map +1 -1
- package/util.mjs +1 -1
- package/util.mjs.map +1 -1
|
@@ -1,324 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { TransactionComposer } from "./composer.mjs";
|
|
3
|
-
import { ClientManager } from "./client-manager.mjs";
|
|
4
|
-
import { AccountManager } from "./account-manager.mjs";
|
|
5
|
-
import { AlgorandClientTransactionCreator } from "./algorand-client-transaction-creator.mjs";
|
|
6
|
-
import { AlgorandClientTransactionSender } from "./algorand-client-transaction-sender.mjs";
|
|
7
|
-
import { AppDeployer } from "./app-deployer.mjs";
|
|
8
|
-
import { AssetManager } from "./asset-manager.mjs";
|
|
1
|
+
import { AlgorandClient as AlgorandClient$1 } from "../algorand-client.mjs";
|
|
9
2
|
|
|
10
3
|
//#region src/types/algorand-client.ts
|
|
11
|
-
/**
|
|
12
|
-
|
|
13
|
-
*/
|
|
14
|
-
var AlgorandClient = class AlgorandClient {
|
|
15
|
-
_clientManager;
|
|
16
|
-
_accountManager;
|
|
17
|
-
_appManager;
|
|
18
|
-
_appDeployer;
|
|
19
|
-
_assetManager;
|
|
20
|
-
_transactionSender;
|
|
21
|
-
_transactionCreator;
|
|
22
|
-
_cachedSuggestedParams;
|
|
23
|
-
_cachedSuggestedParamsExpiry;
|
|
24
|
-
_cachedSuggestedParamsTimeout = 3e3;
|
|
25
|
-
_defaultValidityWindow = void 0;
|
|
26
|
-
/**
|
|
27
|
-
* A set of error transformers to use when an error is caught in simulate or execute
|
|
28
|
-
* `registerErrorTransformer` and `unregisterErrorTransformer` can be used to add and remove
|
|
29
|
-
* error transformers from the set.
|
|
30
|
-
*/
|
|
31
|
-
_errorTransformers = /* @__PURE__ */ new Set();
|
|
32
|
-
constructor(config) {
|
|
33
|
-
this._clientManager = new ClientManager(config, this);
|
|
34
|
-
this._accountManager = new AccountManager(this._clientManager);
|
|
35
|
-
this._appManager = new AppManager(this._clientManager.algod);
|
|
36
|
-
this._assetManager = new AssetManager(this._clientManager.algod, (config$1) => this.newGroup(config$1));
|
|
37
|
-
this._transactionSender = new AlgorandClientTransactionSender((config$1) => this.newGroup(config$1), this._assetManager, this._appManager);
|
|
38
|
-
this._transactionCreator = new AlgorandClientTransactionCreator((config$1) => this.newGroup(config$1));
|
|
39
|
-
this._appDeployer = new AppDeployer(this._appManager, this._transactionSender, this._clientManager.indexerIfPresent);
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Sets the default validity window for transactions.
|
|
43
|
-
* @param validityWindow The number of rounds between the first and last valid rounds
|
|
44
|
-
* @returns The `AlgorandClient` so method calls can be chained
|
|
45
|
-
* @example
|
|
46
|
-
* ```typescript
|
|
47
|
-
* const algorand = AlgorandClient.mainNet().setDefaultValidityWindow(1000);
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
setDefaultValidityWindow(validityWindow) {
|
|
51
|
-
this._defaultValidityWindow = BigInt(validityWindow);
|
|
52
|
-
return this;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Sets the default signer to use if no other signer is specified.
|
|
56
|
-
* @param signer The signer to use, either a `TransactionSigner` or a `AddressWithSigner`
|
|
57
|
-
* @returns The `AlgorandClient` so method calls can be chained
|
|
58
|
-
* @example
|
|
59
|
-
* ```typescript
|
|
60
|
-
* const signer = new SigningAccount(account, account.addr)
|
|
61
|
-
* const algorand = AlgorandClient.mainNet().setDefaultSigner(signer)
|
|
62
|
-
* ```
|
|
63
|
-
*/
|
|
64
|
-
setDefaultSigner(signer) {
|
|
65
|
-
this._accountManager.setDefaultSigner(signer);
|
|
66
|
-
return this;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Tracks the given account (object that encapsulates an address and a signer) for later signing.
|
|
70
|
-
* @param account The account to register, which can be a `AddressWithSigner` or
|
|
71
|
-
* a `algosdk.Account`, `algosdk.LogicSigAccount`, `SigningAccount` or `MultisigAccount`
|
|
72
|
-
* @example
|
|
73
|
-
* ```typescript
|
|
74
|
-
* const accountManager = AlgorandClient.mainNet()
|
|
75
|
-
* .setSignerFromAccount(algosdk.generateAccount())
|
|
76
|
-
* .setSignerFromAccount(new algosdk.LogicSigAccount(program, args))
|
|
77
|
-
* .setSignerFromAccount(new SigningAccount(account, sender))
|
|
78
|
-
* .setSignerFromAccount(new MultisigAccount({version: 1, threshold: 1, addrs: ["ADDRESS1...", "ADDRESS2..."]}, [account1, account2]))
|
|
79
|
-
* .setSignerFromAccount({addr: "SENDERADDRESS", signer: transactionSigner})
|
|
80
|
-
* ```
|
|
81
|
-
* @returns The `AlgorandClient` so method calls can be chained
|
|
82
|
-
*/
|
|
83
|
-
setSignerFromAccount(account) {
|
|
84
|
-
this._accountManager.setSignerFromAccount(account);
|
|
85
|
-
return this;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Tracks the given signer against the given sender for later signing.
|
|
89
|
-
* @param sender The sender address to use this signer for
|
|
90
|
-
* @param signer The signer to sign transactions with for the given sender
|
|
91
|
-
* @returns The `AlgorandClient` so method calls can be chained
|
|
92
|
-
* @example
|
|
93
|
-
* ```typescript
|
|
94
|
-
* const signer = new SigningAccount(account, account.addr)
|
|
95
|
-
* const algorand = AlgorandClient.mainNet().setSigner(signer.addr, signer.signer)
|
|
96
|
-
* ```
|
|
97
|
-
*/
|
|
98
|
-
setSigner(sender, signer) {
|
|
99
|
-
this._accountManager.setSigner(sender, signer);
|
|
100
|
-
return this;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Sets a cache value to use for suggested transaction params.
|
|
104
|
-
* @param suggestedParams The suggested params to use
|
|
105
|
-
* @param until A date until which to cache, or if not specified then the timeout is used
|
|
106
|
-
* @returns The `AlgorandClient` so method calls can be chained
|
|
107
|
-
* @example
|
|
108
|
-
* ```typescript
|
|
109
|
-
* const algorand = AlgorandClient.mainNet().setSuggestedParamsCache(suggestedParams, new Date(+new Date() + 3_600_000))
|
|
110
|
-
* ```
|
|
111
|
-
*/
|
|
112
|
-
setSuggestedParamsCache(suggestedParams, until) {
|
|
113
|
-
this._cachedSuggestedParams = suggestedParams;
|
|
114
|
-
this._cachedSuggestedParamsExpiry = until ?? new Date(+/* @__PURE__ */ new Date() + this._cachedSuggestedParamsTimeout);
|
|
115
|
-
return this;
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Sets the timeout for caching suggested params.
|
|
119
|
-
* @param timeout The timeout in milliseconds
|
|
120
|
-
* @returns The `AlgorandClient` so method calls can be chained
|
|
121
|
-
* @example
|
|
122
|
-
* ```typescript
|
|
123
|
-
* const algorand = AlgorandClient.mainNet().setSuggestedParamsCacheTimeout(10_000)
|
|
124
|
-
* ```
|
|
125
|
-
*/
|
|
126
|
-
setSuggestedParamsCacheTimeout(timeout) {
|
|
127
|
-
this._cachedSuggestedParamsTimeout = timeout;
|
|
128
|
-
return this;
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Get suggested params for a transaction (either cached or from algod if the cache is stale or empty)
|
|
132
|
-
* @returns The suggested transaction parameters.
|
|
133
|
-
* @example
|
|
134
|
-
* const params = await AlgorandClient.mainNet().getSuggestedParams();
|
|
135
|
-
*/
|
|
136
|
-
async getSuggestedParams() {
|
|
137
|
-
if (this._cachedSuggestedParams && (!this._cachedSuggestedParamsExpiry || this._cachedSuggestedParamsExpiry > /* @__PURE__ */ new Date())) return { ...this._cachedSuggestedParams };
|
|
138
|
-
this._cachedSuggestedParams = await this._clientManager.algod.suggestedParams();
|
|
139
|
-
this._cachedSuggestedParamsExpiry = new Date((/* @__PURE__ */ new Date()).getTime() + this._cachedSuggestedParamsTimeout);
|
|
140
|
-
return { ...this._cachedSuggestedParams };
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Get clients, including algosdk clients and app clients.
|
|
144
|
-
* @returns The `ClientManager` instance.
|
|
145
|
-
* @example
|
|
146
|
-
* const clientManager = AlgorandClient.mainNet().client;
|
|
147
|
-
*/
|
|
148
|
-
get client() {
|
|
149
|
-
return this._clientManager;
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Get or create accounts that can sign transactions.
|
|
153
|
-
* @returns The `AccountManager` instance.
|
|
154
|
-
* @example
|
|
155
|
-
* const accountManager = AlgorandClient.mainNet().account;
|
|
156
|
-
*/
|
|
157
|
-
get account() {
|
|
158
|
-
return this._accountManager;
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Methods for interacting with assets.
|
|
162
|
-
* @returns The `AssetManager` instance.
|
|
163
|
-
* @example
|
|
164
|
-
* const assetManager = AlgorandClient.mainNet().asset;
|
|
165
|
-
*/
|
|
166
|
-
get asset() {
|
|
167
|
-
return this._assetManager;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Methods for interacting with apps.
|
|
171
|
-
* @returns The `AppManager` instance.
|
|
172
|
-
* @example
|
|
173
|
-
* const appManager = AlgorandClient.mainNet().app;
|
|
174
|
-
*/
|
|
175
|
-
get app() {
|
|
176
|
-
return this._appManager;
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Methods for deploying apps and managing app deployment metadata.
|
|
180
|
-
* @returns The `AppDeployer` instance.
|
|
181
|
-
* @example
|
|
182
|
-
* const deployer = AlgorandClient.mainNet().appDeployer;
|
|
183
|
-
*/
|
|
184
|
-
get appDeployer() {
|
|
185
|
-
return this._appDeployer;
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Register a function that will be used to transform an error caught when simulating or executing
|
|
189
|
-
* composed transaction groups made from `newGroup`
|
|
190
|
-
*/
|
|
191
|
-
registerErrorTransformer(transformer) {
|
|
192
|
-
this._errorTransformers.add(transformer);
|
|
193
|
-
}
|
|
194
|
-
unregisterErrorTransformer(transformer) {
|
|
195
|
-
this._errorTransformers.delete(transformer);
|
|
196
|
-
}
|
|
197
|
-
/** Start a new `TransactionComposer` transaction group
|
|
198
|
-
* @returns A new instance of `TransactionComposer`.
|
|
199
|
-
* @example
|
|
200
|
-
* const composer = AlgorandClient.mainNet().newGroup();
|
|
201
|
-
* const result = await composer.addTransaction(payment).send()
|
|
202
|
-
*/
|
|
203
|
-
newGroup(composerConfig) {
|
|
204
|
-
return new TransactionComposer({
|
|
205
|
-
algod: this.client.algod,
|
|
206
|
-
getSigner: (addr) => this.account.getSigner(addr),
|
|
207
|
-
getSuggestedParams: () => this.getSuggestedParams(),
|
|
208
|
-
defaultValidityWindow: this._defaultValidityWindow,
|
|
209
|
-
appManager: this._appManager,
|
|
210
|
-
errorTransformers: [...this._errorTransformers],
|
|
211
|
-
composerConfig
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Methods for sending a transaction.
|
|
216
|
-
* @returns The `AlgorandClientTransactionSender` instance.
|
|
217
|
-
* @example
|
|
218
|
-
* const result = await AlgorandClient.mainNet().send.payment({
|
|
219
|
-
* sender: "SENDERADDRESS",
|
|
220
|
-
* receiver: "RECEIVERADDRESS",
|
|
221
|
-
* amount: algo(1)
|
|
222
|
-
* })
|
|
223
|
-
*/
|
|
224
|
-
get send() {
|
|
225
|
-
return this._transactionSender;
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Methods for creating a transaction.
|
|
229
|
-
* @returns The `AlgorandClientTransactionCreator` instance.
|
|
230
|
-
* @example
|
|
231
|
-
* const payment = await AlgorandClient.mainNet().createTransaction.payment({
|
|
232
|
-
* sender: "SENDERADDRESS",
|
|
233
|
-
* receiver: "RECEIVERADDRESS",
|
|
234
|
-
* amount: algo(1)
|
|
235
|
-
* })
|
|
236
|
-
*/
|
|
237
|
-
get createTransaction() {
|
|
238
|
-
return this._transactionCreator;
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Creates an `AlgorandClient` pointing at default LocalNet ports and API token.
|
|
242
|
-
* @returns An instance of the `AlgorandClient`.
|
|
243
|
-
* @example
|
|
244
|
-
* const algorand = AlgorandClient.defaultLocalNet();
|
|
245
|
-
*/
|
|
246
|
-
static defaultLocalNet() {
|
|
247
|
-
return new AlgorandClient({
|
|
248
|
-
algodConfig: ClientManager.getDefaultLocalNetConfig("algod"),
|
|
249
|
-
indexerConfig: ClientManager.getDefaultLocalNetConfig("indexer"),
|
|
250
|
-
kmdConfig: ClientManager.getDefaultLocalNetConfig("kmd")
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* Creates an `AlgorandClient` pointing at TestNet using AlgoNode.
|
|
255
|
-
* @returns An instance of the `AlgorandClient`.
|
|
256
|
-
* @example
|
|
257
|
-
* const algorand = AlgorandClient.testNet();
|
|
258
|
-
*/
|
|
259
|
-
static testNet() {
|
|
260
|
-
return new AlgorandClient({
|
|
261
|
-
algodConfig: ClientManager.getAlgoNodeConfig("testnet", "algod"),
|
|
262
|
-
indexerConfig: ClientManager.getAlgoNodeConfig("testnet", "indexer"),
|
|
263
|
-
kmdConfig: void 0
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* Creates an `AlgorandClient` pointing at MainNet using AlgoNode.
|
|
268
|
-
* @returns An instance of the `AlgorandClient`.
|
|
269
|
-
* @example
|
|
270
|
-
* const algorand = AlgorandClient.mainNet();
|
|
271
|
-
*/
|
|
272
|
-
static mainNet() {
|
|
273
|
-
return new AlgorandClient({
|
|
274
|
-
algodConfig: ClientManager.getAlgoNodeConfig("mainnet", "algod"),
|
|
275
|
-
indexerConfig: ClientManager.getAlgoNodeConfig("mainnet", "indexer"),
|
|
276
|
-
kmdConfig: void 0
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
/**
|
|
280
|
-
* Creates an `AlgorandClient` pointing to the given client(s).
|
|
281
|
-
* @param clients The clients to use.
|
|
282
|
-
* @returns An instance of the `AlgorandClient`.
|
|
283
|
-
* @example
|
|
284
|
-
* const algorand = AlgorandClient.fromClients({ algod, indexer, kmd });
|
|
285
|
-
*/
|
|
286
|
-
static fromClients(clients) {
|
|
287
|
-
return new AlgorandClient(clients);
|
|
288
|
-
}
|
|
289
|
-
/**
|
|
290
|
-
* Creates an `AlgorandClient` loading the configuration from environment variables.
|
|
291
|
-
*
|
|
292
|
-
* Retrieve configurations from environment variables when defined or get default LocalNet configuration if they aren't defined.
|
|
293
|
-
*
|
|
294
|
-
* Expects to be called from a Node.js environment.
|
|
295
|
-
*
|
|
296
|
-
* If `process.env.ALGOD_SERVER` is defined it will use that along with optional `process.env.ALGOD_PORT` and `process.env.ALGOD_TOKEN`.
|
|
297
|
-
*
|
|
298
|
-
* If `process.env.INDEXER_SERVER` is defined it will use that along with optional `process.env.INDEXER_PORT` and `process.env.INDEXER_TOKEN`.
|
|
299
|
-
*
|
|
300
|
-
* If either aren't defined it will use the default LocalNet config.
|
|
301
|
-
*
|
|
302
|
-
* It will return a KMD configuration that uses `process.env.KMD_PORT` (or port 4002) if `process.env.ALGOD_SERVER` is defined,
|
|
303
|
-
* otherwise it will use the default LocalNet config unless it detects testnet or mainnet.
|
|
304
|
-
* @returns An instance of the `AlgorandClient`.
|
|
305
|
-
* @example
|
|
306
|
-
* const client = AlgorandClient.fromEnvironment();
|
|
307
|
-
*/
|
|
308
|
-
static fromEnvironment() {
|
|
309
|
-
return new AlgorandClient(ClientManager.getConfigFromEnvironmentOrLocalNet());
|
|
310
|
-
}
|
|
311
|
-
/**
|
|
312
|
-
* Creates an `AlgorandClient` from the given config.
|
|
313
|
-
* @param config The config to use.
|
|
314
|
-
* @returns An instance of the `AlgorandClient`.
|
|
315
|
-
* @example
|
|
316
|
-
* const client = AlgorandClient.fromConfig({ algodConfig, indexerConfig, kmdConfig });
|
|
317
|
-
*/
|
|
318
|
-
static fromConfig(config) {
|
|
319
|
-
return new AlgorandClient(config);
|
|
320
|
-
}
|
|
321
|
-
};
|
|
4
|
+
/** @deprecated Import from `@algorandfoundation/algokit-utils/algorand-client` instead */
|
|
5
|
+
const AlgorandClient = AlgorandClient$1;
|
|
322
6
|
|
|
323
7
|
//#endregion
|
|
324
8
|
export { AlgorandClient };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"algorand-client.mjs","names":["config"],"sources":["../../src/types/algorand-client.ts"],"sourcesContent":["import { SuggestedParams } from '@algorandfoundation/algokit-algod-client'\nimport { Address, ReadableAddress } from '@algorandfoundation/algokit-common'\nimport { AddressWithTransactionSigner, LogicSigAccount, TransactionSigner, MultisigAccount } from '@algorandfoundation/algokit-transact'\nimport { AccountManager } from './account-manager'\nimport { AlgorandClientTransactionCreator } from './algorand-client-transaction-creator'\nimport { AlgorandClientTransactionSender } from './algorand-client-transaction-sender'\nimport { AppDeployer } from './app-deployer'\nimport { AppManager } from './app-manager'\nimport { AssetManager } from './asset-manager'\nimport { AlgoSdkClients, ClientManager } from './client-manager'\nimport { ErrorTransformer, TransactionComposer, TransactionComposerConfig } from './composer'\nimport { AlgoConfig } from './network-client'\n\n/**\n * A client that brokers easy access to Algorand functionality.\n */\nexport class AlgorandClient {\n private _clientManager: ClientManager\n private _accountManager: AccountManager\n private _appManager: AppManager\n private _appDeployer: AppDeployer\n private _assetManager: AssetManager\n private _transactionSender: AlgorandClientTransactionSender\n private _transactionCreator: AlgorandClientTransactionCreator\n\n private _cachedSuggestedParams?: SuggestedParams\n private _cachedSuggestedParamsExpiry?: Date\n private _cachedSuggestedParamsTimeout: number = 3_000 // three seconds\n\n private _defaultValidityWindow: bigint | undefined = undefined\n\n /**\n * A set of error transformers to use when an error is caught in simulate or execute\n * `registerErrorTransformer` and `unregisterErrorTransformer` can be used to add and remove\n * error transformers from the set.\n */\n private _errorTransformers: Set<ErrorTransformer> = new Set()\n\n private constructor(config: AlgoConfig | AlgoSdkClients) {\n this._clientManager = new ClientManager(config, this)\n this._accountManager = new AccountManager(this._clientManager)\n this._appManager = new AppManager(this._clientManager.algod)\n this._assetManager = new AssetManager(this._clientManager.algod, (config) => this.newGroup(config))\n this._transactionSender = new AlgorandClientTransactionSender((config) => this.newGroup(config), this._assetManager, this._appManager)\n this._transactionCreator = new AlgorandClientTransactionCreator((config) => this.newGroup(config))\n this._appDeployer = new AppDeployer(this._appManager, this._transactionSender, this._clientManager.indexerIfPresent)\n }\n\n /**\n * Sets the default validity window for transactions.\n * @param validityWindow The number of rounds between the first and last valid rounds\n * @returns The `AlgorandClient` so method calls can be chained\n * @example\n * ```typescript\n * const algorand = AlgorandClient.mainNet().setDefaultValidityWindow(1000);\n * ```\n */\n public setDefaultValidityWindow(validityWindow: number | bigint) {\n this._defaultValidityWindow = BigInt(validityWindow)\n return this\n }\n\n /**\n * Sets the default signer to use if no other signer is specified.\n * @param signer The signer to use, either a `TransactionSigner` or a `AddressWithSigner`\n * @returns The `AlgorandClient` so method calls can be chained\n * @example\n * ```typescript\n * const signer = new SigningAccount(account, account.addr)\n * const algorand = AlgorandClient.mainNet().setDefaultSigner(signer)\n * ```\n */\n public setDefaultSigner(signer: TransactionSigner | AddressWithTransactionSigner): AlgorandClient {\n this._accountManager.setDefaultSigner(signer)\n return this\n }\n\n /**\n * Tracks the given account (object that encapsulates an address and a signer) for later signing.\n * @param account The account to register, which can be a `AddressWithSigner` or\n * a `algosdk.Account`, `algosdk.LogicSigAccount`, `SigningAccount` or `MultisigAccount`\n * @example\n * ```typescript\n * const accountManager = AlgorandClient.mainNet()\n * .setSignerFromAccount(algosdk.generateAccount())\n * .setSignerFromAccount(new algosdk.LogicSigAccount(program, args))\n * .setSignerFromAccount(new SigningAccount(account, sender))\n * .setSignerFromAccount(new MultisigAccount({version: 1, threshold: 1, addrs: [\"ADDRESS1...\", \"ADDRESS2...\"]}, [account1, account2]))\n * .setSignerFromAccount({addr: \"SENDERADDRESS\", signer: transactionSigner})\n * ```\n * @returns The `AlgorandClient` so method calls can be chained\n */\n public setSignerFromAccount(account: AddressWithTransactionSigner | LogicSigAccount | MultisigAccount) {\n this._accountManager.setSignerFromAccount(account)\n return this\n }\n\n /**\n * Tracks the given signer against the given sender for later signing.\n * @param sender The sender address to use this signer for\n * @param signer The signer to sign transactions with for the given sender\n * @returns The `AlgorandClient` so method calls can be chained\n * @example\n * ```typescript\n * const signer = new SigningAccount(account, account.addr)\n * const algorand = AlgorandClient.mainNet().setSigner(signer.addr, signer.signer)\n * ```\n */\n public setSigner(sender: string | Address, signer: TransactionSigner) {\n this._accountManager.setSigner(sender, signer)\n return this\n }\n\n /**\n * Sets a cache value to use for suggested transaction params.\n * @param suggestedParams The suggested params to use\n * @param until A date until which to cache, or if not specified then the timeout is used\n * @returns The `AlgorandClient` so method calls can be chained\n * @example\n * ```typescript\n * const algorand = AlgorandClient.mainNet().setSuggestedParamsCache(suggestedParams, new Date(+new Date() + 3_600_000))\n * ```\n */\n public setSuggestedParamsCache(suggestedParams: SuggestedParams, until?: Date) {\n this._cachedSuggestedParams = suggestedParams\n this._cachedSuggestedParamsExpiry = until ?? new Date(+new Date() + this._cachedSuggestedParamsTimeout)\n return this\n }\n\n /**\n * Sets the timeout for caching suggested params.\n * @param timeout The timeout in milliseconds\n * @returns The `AlgorandClient` so method calls can be chained\n * @example\n * ```typescript\n * const algorand = AlgorandClient.mainNet().setSuggestedParamsCacheTimeout(10_000)\n * ```\n */\n public setSuggestedParamsCacheTimeout(timeout: number) {\n this._cachedSuggestedParamsTimeout = timeout\n return this\n }\n\n /**\n * Get suggested params for a transaction (either cached or from algod if the cache is stale or empty)\n * @returns The suggested transaction parameters.\n * @example\n * const params = await AlgorandClient.mainNet().getSuggestedParams();\n */\n public async getSuggestedParams(): Promise<SuggestedParams> {\n if (this._cachedSuggestedParams && (!this._cachedSuggestedParamsExpiry || this._cachedSuggestedParamsExpiry > new Date())) {\n return {\n ...this._cachedSuggestedParams,\n }\n }\n\n this._cachedSuggestedParams = await this._clientManager.algod.suggestedParams()\n this._cachedSuggestedParamsExpiry = new Date(new Date().getTime() + this._cachedSuggestedParamsTimeout)\n\n return {\n ...this._cachedSuggestedParams,\n }\n }\n\n /**\n * Get clients, including algosdk clients and app clients.\n * @returns The `ClientManager` instance.\n * @example\n * const clientManager = AlgorandClient.mainNet().client;\n */\n public get client() {\n return this._clientManager\n }\n\n /**\n * Get or create accounts that can sign transactions.\n * @returns The `AccountManager` instance.\n * @example\n * const accountManager = AlgorandClient.mainNet().account;\n */\n public get account() {\n return this._accountManager\n }\n\n /**\n * Methods for interacting with assets.\n * @returns The `AssetManager` instance.\n * @example\n * const assetManager = AlgorandClient.mainNet().asset;\n */\n public get asset() {\n return this._assetManager\n }\n\n /**\n * Methods for interacting with apps.\n * @returns The `AppManager` instance.\n * @example\n * const appManager = AlgorandClient.mainNet().app;\n */\n public get app() {\n return this._appManager\n }\n\n /**\n * Methods for deploying apps and managing app deployment metadata.\n * @returns The `AppDeployer` instance.\n * @example\n * const deployer = AlgorandClient.mainNet().appDeployer;\n */\n public get appDeployer() {\n return this._appDeployer\n }\n\n /**\n * Register a function that will be used to transform an error caught when simulating or executing\n * composed transaction groups made from `newGroup`\n */\n public registerErrorTransformer(transformer: ErrorTransformer) {\n this._errorTransformers.add(transformer)\n }\n\n public unregisterErrorTransformer(transformer: ErrorTransformer) {\n this._errorTransformers.delete(transformer)\n }\n\n /** Start a new `TransactionComposer` transaction group\n * @returns A new instance of `TransactionComposer`.\n * @example\n * const composer = AlgorandClient.mainNet().newGroup();\n * const result = await composer.addTransaction(payment).send()\n */\n public newGroup(composerConfig?: TransactionComposerConfig) {\n return new TransactionComposer({\n algod: this.client.algod,\n getSigner: (addr: ReadableAddress) => this.account.getSigner(addr),\n getSuggestedParams: () => this.getSuggestedParams(),\n defaultValidityWindow: this._defaultValidityWindow,\n appManager: this._appManager,\n errorTransformers: [...this._errorTransformers],\n composerConfig: composerConfig,\n })\n }\n\n /**\n * Methods for sending a transaction.\n * @returns The `AlgorandClientTransactionSender` instance.\n * @example\n * const result = await AlgorandClient.mainNet().send.payment({\n * sender: \"SENDERADDRESS\",\n * receiver: \"RECEIVERADDRESS\",\n * amount: algo(1)\n * })\n */\n public get send() {\n return this._transactionSender\n }\n\n /**\n * Methods for creating a transaction.\n * @returns The `AlgorandClientTransactionCreator` instance.\n * @example\n * const payment = await AlgorandClient.mainNet().createTransaction.payment({\n * sender: \"SENDERADDRESS\",\n * receiver: \"RECEIVERADDRESS\",\n * amount: algo(1)\n * })\n */\n public get createTransaction() {\n return this._transactionCreator\n }\n\n // Static methods to create an `AlgorandClient`\n\n /**\n * Creates an `AlgorandClient` pointing at default LocalNet ports and API token.\n * @returns An instance of the `AlgorandClient`.\n * @example\n * const algorand = AlgorandClient.defaultLocalNet();\n */\n public static defaultLocalNet() {\n return new AlgorandClient({\n algodConfig: ClientManager.getDefaultLocalNetConfig('algod'),\n indexerConfig: ClientManager.getDefaultLocalNetConfig('indexer'),\n kmdConfig: ClientManager.getDefaultLocalNetConfig('kmd'),\n })\n }\n\n /**\n * Creates an `AlgorandClient` pointing at TestNet using AlgoNode.\n * @returns An instance of the `AlgorandClient`.\n * @example\n * const algorand = AlgorandClient.testNet();\n */\n public static testNet() {\n return new AlgorandClient({\n algodConfig: ClientManager.getAlgoNodeConfig('testnet', 'algod'),\n indexerConfig: ClientManager.getAlgoNodeConfig('testnet', 'indexer'),\n kmdConfig: undefined,\n })\n }\n\n /**\n * Creates an `AlgorandClient` pointing at MainNet using AlgoNode.\n * @returns An instance of the `AlgorandClient`.\n * @example\n * const algorand = AlgorandClient.mainNet();\n */\n public static mainNet() {\n return new AlgorandClient({\n algodConfig: ClientManager.getAlgoNodeConfig('mainnet', 'algod'),\n indexerConfig: ClientManager.getAlgoNodeConfig('mainnet', 'indexer'),\n kmdConfig: undefined,\n })\n }\n\n /**\n * Creates an `AlgorandClient` pointing to the given client(s).\n * @param clients The clients to use.\n * @returns An instance of the `AlgorandClient`.\n * @example\n * const algorand = AlgorandClient.fromClients({ algod, indexer, kmd });\n */\n public static fromClients(clients: AlgoSdkClients) {\n return new AlgorandClient(clients)\n }\n\n /**\n * Creates an `AlgorandClient` loading the configuration from environment variables.\n *\n * Retrieve configurations from environment variables when defined or get default LocalNet configuration if they aren't defined.\n *\n * Expects to be called from a Node.js environment.\n *\n * If `process.env.ALGOD_SERVER` is defined it will use that along with optional `process.env.ALGOD_PORT` and `process.env.ALGOD_TOKEN`.\n *\n * If `process.env.INDEXER_SERVER` is defined it will use that along with optional `process.env.INDEXER_PORT` and `process.env.INDEXER_TOKEN`.\n *\n * If either aren't defined it will use the default LocalNet config.\n *\n * It will return a KMD configuration that uses `process.env.KMD_PORT` (or port 4002) if `process.env.ALGOD_SERVER` is defined,\n * otherwise it will use the default LocalNet config unless it detects testnet or mainnet.\n * @returns An instance of the `AlgorandClient`.\n * @example\n * const client = AlgorandClient.fromEnvironment();\n */\n public static fromEnvironment() {\n return new AlgorandClient(ClientManager.getConfigFromEnvironmentOrLocalNet())\n }\n\n /**\n * Creates an `AlgorandClient` from the given config.\n * @param config The config to use.\n * @returns An instance of the `AlgorandClient`.\n * @example\n * const client = AlgorandClient.fromConfig({ algodConfig, indexerConfig, kmdConfig });\n */\n public static fromConfig(config: AlgoConfig) {\n return new AlgorandClient(config)\n }\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"algorand-client.mjs","names":["_AlgorandClient"],"sources":["../../src/types/algorand-client.ts"],"sourcesContent":["// Re-exports with deprecation notices for backwards compatibility\n// New imports should use '@algorandfoundation/algokit-utils/algorand-client'\n\nimport { AlgorandClient as _AlgorandClient } from '../algorand-client'\n\n/** @deprecated Import from `@algorandfoundation/algokit-utils/algorand-client` instead */\nexport const AlgorandClient = _AlgorandClient\n/** @deprecated Import from `@algorandfoundation/algokit-utils/algorand-client` instead */\nexport type AlgorandClient = _AlgorandClient\n"],"mappings":";;;;AAMA,MAAa,iBAAiBA"}
|
package/types/amount.d.ts
CHANGED
|
@@ -1,49 +1,10 @@
|
|
|
1
|
+
import { AlgoAmount as AlgoAmount$1 } from "../amount.js";
|
|
2
|
+
|
|
1
3
|
//#region src/types/amount.d.ts
|
|
2
|
-
/**
|
|
3
|
-
declare
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
get microAlgos(): bigint;
|
|
7
|
-
/** Return the amount as a number in µAlgo */
|
|
8
|
-
get microAlgo(): bigint;
|
|
9
|
-
/** Return the amount as a number in Algo */
|
|
10
|
-
get algos(): number;
|
|
11
|
-
/** Return the amount as a number in Algo */
|
|
12
|
-
get algo(): number;
|
|
13
|
-
/**
|
|
14
|
-
* Create a new `AlgoAmount` instance.
|
|
15
|
-
*
|
|
16
|
-
* @param amount - An object specifying the amount in Algo or µALGO. Use the key 'algo' for Algo amounts and 'microAlgo' for µALGO.
|
|
17
|
-
* @returns A new instance of `AlgoAmount` representing the specified amount.
|
|
18
|
-
* @example
|
|
19
|
-
* ```typescript
|
|
20
|
-
* const amount = new AlgoAmount({ algo: 5 });
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
constructor(amount: {
|
|
24
|
-
algos: number | bigint;
|
|
25
|
-
} | {
|
|
26
|
-
algo: number | bigint;
|
|
27
|
-
} | {
|
|
28
|
-
microAlgos: number | bigint;
|
|
29
|
-
} | {
|
|
30
|
-
microAlgo: number | bigint;
|
|
31
|
-
});
|
|
32
|
-
toString(): string;
|
|
33
|
-
/** valueOf allows you to use `AlgoAmount` in comparison operations such as `<` and `>=` etc.,
|
|
34
|
-
* but it's not recommended to use this to convert to a number, it's much safer to explicitly call
|
|
35
|
-
* the algos or microAlgos properties
|
|
36
|
-
*/
|
|
37
|
-
valueOf(): number;
|
|
38
|
-
/** Create a `AlgoAmount` object representing the given number of Algo */
|
|
39
|
-
static Algos(amount: number | bigint): AlgoAmount;
|
|
40
|
-
/** Create a `AlgoAmount` object representing the given number of Algo */
|
|
41
|
-
static Algo(amount: number | bigint): AlgoAmount;
|
|
42
|
-
/** Create a `AlgoAmount` object representing the given number of µAlgo */
|
|
43
|
-
static MicroAlgos(amount: number | bigint): AlgoAmount;
|
|
44
|
-
/** Create a `AlgoAmount` object representing the given number of µAlgo */
|
|
45
|
-
static MicroAlgo(amount: number | bigint): AlgoAmount;
|
|
46
|
-
}
|
|
4
|
+
/** @deprecated Import from `@algorandfoundation/algokit-utils/amount` instead */
|
|
5
|
+
declare const AlgoAmount: typeof AlgoAmount$1;
|
|
6
|
+
/** @deprecated Import from `@algorandfoundation/algokit-utils/amount` instead */
|
|
7
|
+
type AlgoAmount = AlgoAmount$1;
|
|
47
8
|
//#endregion
|
|
48
9
|
export { AlgoAmount };
|
|
49
10
|
//# sourceMappingURL=amount.d.ts.map
|
package/types/amount.js
CHANGED
|
@@ -1,84 +1,8 @@
|
|
|
1
|
+
const require_amount = require('../amount.js');
|
|
1
2
|
|
|
2
3
|
//#region src/types/amount.ts
|
|
3
|
-
/**
|
|
4
|
-
|
|
5
|
-
amountInMicroAlgo;
|
|
6
|
-
/** Return the amount as a number in µAlgo */
|
|
7
|
-
get microAlgos() {
|
|
8
|
-
return this.amountInMicroAlgo;
|
|
9
|
-
}
|
|
10
|
-
/** Return the amount as a number in µAlgo */
|
|
11
|
-
get microAlgo() {
|
|
12
|
-
return this.amountInMicroAlgo;
|
|
13
|
-
}
|
|
14
|
-
/** Return the amount as a number in Algo */
|
|
15
|
-
get algos() {
|
|
16
|
-
return microalgosToAlgos(Number(this.amountInMicroAlgo));
|
|
17
|
-
}
|
|
18
|
-
/** Return the amount as a number in Algo */
|
|
19
|
-
get algo() {
|
|
20
|
-
return microalgosToAlgos(Number(this.amountInMicroAlgo));
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Create a new `AlgoAmount` instance.
|
|
24
|
-
*
|
|
25
|
-
* @param amount - An object specifying the amount in Algo or µALGO. Use the key 'algo' for Algo amounts and 'microAlgo' for µALGO.
|
|
26
|
-
* @returns A new instance of `AlgoAmount` representing the specified amount.
|
|
27
|
-
* @example
|
|
28
|
-
* ```typescript
|
|
29
|
-
* const amount = new AlgoAmount({ algo: 5 });
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
constructor(amount) {
|
|
33
|
-
this.amountInMicroAlgo = "microAlgos" in amount ? BigInt(amount.microAlgos) : "microAlgo" in amount ? BigInt(amount.microAlgo) : "algos" in amount ? BigInt(algosToMicroalgos(Number(amount.algos))) : BigInt(algosToMicroalgos(Number(amount.algo)));
|
|
34
|
-
}
|
|
35
|
-
toString() {
|
|
36
|
-
return `${this.microAlgo.toLocaleString("en-US")} µALGO`;
|
|
37
|
-
}
|
|
38
|
-
/** valueOf allows you to use `AlgoAmount` in comparison operations such as `<` and `>=` etc.,
|
|
39
|
-
* but it's not recommended to use this to convert to a number, it's much safer to explicitly call
|
|
40
|
-
* the algos or microAlgos properties
|
|
41
|
-
*/
|
|
42
|
-
valueOf() {
|
|
43
|
-
return Number(this.microAlgo);
|
|
44
|
-
}
|
|
45
|
-
/** Create a `AlgoAmount` object representing the given number of Algo */
|
|
46
|
-
static Algos(amount) {
|
|
47
|
-
return new AlgoAmount({ algos: amount });
|
|
48
|
-
}
|
|
49
|
-
/** Create a `AlgoAmount` object representing the given number of Algo */
|
|
50
|
-
static Algo(amount) {
|
|
51
|
-
return new AlgoAmount({ algos: amount });
|
|
52
|
-
}
|
|
53
|
-
/** Create a `AlgoAmount` object representing the given number of µAlgo */
|
|
54
|
-
static MicroAlgos(amount) {
|
|
55
|
-
return new AlgoAmount({ microAlgos: amount });
|
|
56
|
-
}
|
|
57
|
-
/** Create a `AlgoAmount` object representing the given number of µAlgo */
|
|
58
|
-
static MicroAlgo(amount) {
|
|
59
|
-
return new AlgoAmount({ microAlgos: amount });
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
const MICROALGOS_TO_ALGOS_RATIO = 1e6;
|
|
63
|
-
const INVALID_MICROALGOS_ERROR_MSG = "Microalgos should be positive and less than 2^53 - 1.";
|
|
64
|
-
/**
|
|
65
|
-
* microalgosToAlgos converts microalgos to algos
|
|
66
|
-
* @param microalgos - number
|
|
67
|
-
* @returns number
|
|
68
|
-
*/
|
|
69
|
-
function microalgosToAlgos(microalgos) {
|
|
70
|
-
if (microalgos < 0 || !Number.isSafeInteger(microalgos)) throw new Error(INVALID_MICROALGOS_ERROR_MSG);
|
|
71
|
-
return microalgos / MICROALGOS_TO_ALGOS_RATIO;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* algosToMicroalgos converts algos to microalgos
|
|
75
|
-
* @param algos - number
|
|
76
|
-
* @returns number
|
|
77
|
-
*/
|
|
78
|
-
function algosToMicroalgos(algos) {
|
|
79
|
-
const microalgos = algos * MICROALGOS_TO_ALGOS_RATIO;
|
|
80
|
-
return Math.round(microalgos);
|
|
81
|
-
}
|
|
4
|
+
/** @deprecated Import from `@algorandfoundation/algokit-utils/amount` instead */
|
|
5
|
+
const AlgoAmount = require_amount.AlgoAmount;
|
|
82
6
|
|
|
83
7
|
//#endregion
|
|
84
8
|
exports.AlgoAmount = AlgoAmount;
|
package/types/amount.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amount.js","names":[],"sources":["../../src/types/amount.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"amount.js","names":["_AlgoAmount"],"sources":["../../src/types/amount.ts"],"sourcesContent":["// Re-exports with deprecation notices for backwards compatibility\n// New imports should use '@algorandfoundation/algokit-utils/amount'\n\nimport { AlgoAmount as _AlgoAmount } from '../amount'\n\n/** @deprecated Import from `@algorandfoundation/algokit-utils/amount` instead */\nexport const AlgoAmount = _AlgoAmount\n/** @deprecated Import from `@algorandfoundation/algokit-utils/amount` instead */\nexport type AlgoAmount = _AlgoAmount\n"],"mappings":";;;;AAMA,MAAa,aAAaA"}
|
package/types/amount.mjs
CHANGED
|
@@ -1,83 +1,8 @@
|
|
|
1
|
+
import { AlgoAmount as AlgoAmount$1 } from "../amount.mjs";
|
|
2
|
+
|
|
1
3
|
//#region src/types/amount.ts
|
|
2
|
-
/**
|
|
3
|
-
|
|
4
|
-
amountInMicroAlgo;
|
|
5
|
-
/** Return the amount as a number in µAlgo */
|
|
6
|
-
get microAlgos() {
|
|
7
|
-
return this.amountInMicroAlgo;
|
|
8
|
-
}
|
|
9
|
-
/** Return the amount as a number in µAlgo */
|
|
10
|
-
get microAlgo() {
|
|
11
|
-
return this.amountInMicroAlgo;
|
|
12
|
-
}
|
|
13
|
-
/** Return the amount as a number in Algo */
|
|
14
|
-
get algos() {
|
|
15
|
-
return microalgosToAlgos(Number(this.amountInMicroAlgo));
|
|
16
|
-
}
|
|
17
|
-
/** Return the amount as a number in Algo */
|
|
18
|
-
get algo() {
|
|
19
|
-
return microalgosToAlgos(Number(this.amountInMicroAlgo));
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Create a new `AlgoAmount` instance.
|
|
23
|
-
*
|
|
24
|
-
* @param amount - An object specifying the amount in Algo or µALGO. Use the key 'algo' for Algo amounts and 'microAlgo' for µALGO.
|
|
25
|
-
* @returns A new instance of `AlgoAmount` representing the specified amount.
|
|
26
|
-
* @example
|
|
27
|
-
* ```typescript
|
|
28
|
-
* const amount = new AlgoAmount({ algo: 5 });
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
constructor(amount) {
|
|
32
|
-
this.amountInMicroAlgo = "microAlgos" in amount ? BigInt(amount.microAlgos) : "microAlgo" in amount ? BigInt(amount.microAlgo) : "algos" in amount ? BigInt(algosToMicroalgos(Number(amount.algos))) : BigInt(algosToMicroalgos(Number(amount.algo)));
|
|
33
|
-
}
|
|
34
|
-
toString() {
|
|
35
|
-
return `${this.microAlgo.toLocaleString("en-US")} µALGO`;
|
|
36
|
-
}
|
|
37
|
-
/** valueOf allows you to use `AlgoAmount` in comparison operations such as `<` and `>=` etc.,
|
|
38
|
-
* but it's not recommended to use this to convert to a number, it's much safer to explicitly call
|
|
39
|
-
* the algos or microAlgos properties
|
|
40
|
-
*/
|
|
41
|
-
valueOf() {
|
|
42
|
-
return Number(this.microAlgo);
|
|
43
|
-
}
|
|
44
|
-
/** Create a `AlgoAmount` object representing the given number of Algo */
|
|
45
|
-
static Algos(amount) {
|
|
46
|
-
return new AlgoAmount({ algos: amount });
|
|
47
|
-
}
|
|
48
|
-
/** Create a `AlgoAmount` object representing the given number of Algo */
|
|
49
|
-
static Algo(amount) {
|
|
50
|
-
return new AlgoAmount({ algos: amount });
|
|
51
|
-
}
|
|
52
|
-
/** Create a `AlgoAmount` object representing the given number of µAlgo */
|
|
53
|
-
static MicroAlgos(amount) {
|
|
54
|
-
return new AlgoAmount({ microAlgos: amount });
|
|
55
|
-
}
|
|
56
|
-
/** Create a `AlgoAmount` object representing the given number of µAlgo */
|
|
57
|
-
static MicroAlgo(amount) {
|
|
58
|
-
return new AlgoAmount({ microAlgos: amount });
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
const MICROALGOS_TO_ALGOS_RATIO = 1e6;
|
|
62
|
-
const INVALID_MICROALGOS_ERROR_MSG = "Microalgos should be positive and less than 2^53 - 1.";
|
|
63
|
-
/**
|
|
64
|
-
* microalgosToAlgos converts microalgos to algos
|
|
65
|
-
* @param microalgos - number
|
|
66
|
-
* @returns number
|
|
67
|
-
*/
|
|
68
|
-
function microalgosToAlgos(microalgos) {
|
|
69
|
-
if (microalgos < 0 || !Number.isSafeInteger(microalgos)) throw new Error(INVALID_MICROALGOS_ERROR_MSG);
|
|
70
|
-
return microalgos / MICROALGOS_TO_ALGOS_RATIO;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* algosToMicroalgos converts algos to microalgos
|
|
74
|
-
* @param algos - number
|
|
75
|
-
* @returns number
|
|
76
|
-
*/
|
|
77
|
-
function algosToMicroalgos(algos) {
|
|
78
|
-
const microalgos = algos * MICROALGOS_TO_ALGOS_RATIO;
|
|
79
|
-
return Math.round(microalgos);
|
|
80
|
-
}
|
|
4
|
+
/** @deprecated Import from `@algorandfoundation/algokit-utils/amount` instead */
|
|
5
|
+
const AlgoAmount = AlgoAmount$1;
|
|
81
6
|
|
|
82
7
|
//#endregion
|
|
83
8
|
export { AlgoAmount };
|
package/types/amount.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amount.mjs","names":[],"sources":["../../src/types/amount.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"amount.mjs","names":["_AlgoAmount"],"sources":["../../src/types/amount.ts"],"sourcesContent":["// Re-exports with deprecation notices for backwards compatibility\n// New imports should use '@algorandfoundation/algokit-utils/amount'\n\nimport { AlgoAmount as _AlgoAmount } from '../amount'\n\n/** @deprecated Import from `@algorandfoundation/algokit-utils/amount` instead */\nexport const AlgoAmount = _AlgoAmount\n/** @deprecated Import from `@algorandfoundation/algokit-utils/amount` instead */\nexport type AlgoAmount = _AlgoAmount\n"],"mappings":";;;;AAMA,MAAa,aAAaA"}
|