@algorandfoundation/algokit-utils 1.0.0-beta.9 → 1.0.0
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.d.ts +35 -31
- package/account.d.ts.map +1 -1
- package/account.js +53 -39
- package/account.js.map +1 -1
- package/amount.d.ts +8 -0
- package/amount.d.ts.map +1 -0
- package/amount.js +24 -0
- package/amount.js.map +1 -0
- package/app.d.ts +64 -145
- package/app.d.ts.map +1 -1
- package/app.js +197 -39
- package/app.js.map +1 -1
- package/application-client.d.ts +9 -112
- package/application-client.d.ts.map +1 -1
- package/application-client.js +11 -254
- package/application-client.js.map +1 -1
- package/deploy-app.d.ts +20 -91
- package/deploy-app.d.ts.map +1 -1
- package/deploy-app.js +84 -93
- package/deploy-app.js.map +1 -1
- package/index.d.ts +4 -2
- package/index.d.ts.map +1 -1
- package/index.js +5 -2
- package/index.js.map +1 -1
- package/localnet.d.ts +4 -4
- package/localnet.d.ts.map +1 -1
- package/localnet.js +10 -10
- package/localnet.js.map +1 -1
- package/network-client.d.ts +11 -20
- package/network-client.d.ts.map +1 -1
- package/network-client.js +11 -11
- package/network-client.js.map +1 -1
- package/package.json +2 -2
- package/testing/account.d.ts +14 -0
- package/testing/account.d.ts.map +1 -0
- package/testing/account.js +31 -0
- package/testing/account.js.map +1 -0
- package/testing/fixtures/algokit-log-capture-fixture.d.ts +19 -0
- package/testing/fixtures/algokit-log-capture-fixture.d.ts.map +1 -0
- package/testing/fixtures/algokit-log-capture-fixture.js +43 -0
- package/testing/fixtures/algokit-log-capture-fixture.js.map +1 -0
- package/testing/fixtures/algorand-fixture.d.ts +20 -0
- package/testing/fixtures/algorand-fixture.d.ts.map +1 -0
- package/testing/fixtures/algorand-fixture.js +49 -0
- package/testing/fixtures/algorand-fixture.js.map +1 -0
- package/testing/fixtures/index.d.ts +3 -0
- package/testing/fixtures/index.d.ts.map +1 -0
- package/testing/fixtures/index.js +19 -0
- package/testing/fixtures/index.js.map +1 -0
- package/testing/index.d.ts +6 -0
- package/testing/index.d.ts.map +1 -0
- package/testing/index.js +22 -0
- package/testing/index.js.map +1 -0
- package/testing/indexer.d.ts +12 -0
- package/testing/indexer.d.ts.map +1 -0
- package/testing/indexer.js +39 -0
- package/testing/indexer.js.map +1 -0
- package/testing/test-logger.d.ts +39 -0
- package/testing/test-logger.d.ts.map +1 -0
- package/testing/test-logger.js +69 -0
- package/testing/test-logger.js.map +1 -0
- package/testing/transaction-logger.d.ts +29 -0
- package/testing/transaction-logger.d.ts.map +1 -0
- package/testing/transaction-logger.js +71 -0
- package/testing/transaction-logger.js.map +1 -0
- package/transaction.d.ts +4 -81
- package/transaction.d.ts.map +1 -1
- package/transaction.js +39 -89
- package/transaction.js.map +1 -1
- package/transfer.d.ts +13 -16
- package/transfer.d.ts.map +1 -1
- package/transfer.js +35 -3
- package/transfer.js.map +1 -1
- package/types/account.d.ts +52 -0
- package/types/account.d.ts.map +1 -0
- package/types/account.js +86 -0
- package/types/account.js.map +1 -0
- package/types/algo-http-client-with-retry.d.ts.map +1 -0
- package/{algo-http-client-with-retry.js → types/algo-http-client-with-retry.js} +2 -2
- package/types/algo-http-client-with-retry.js.map +1 -0
- package/types/algod.d.ts +22 -9
- package/types/algod.d.ts.map +1 -1
- package/{algo-amount.d.ts → types/amount.d.ts} +3 -1
- package/types/amount.d.ts.map +1 -0
- package/{algo-amount.js → types/amount.js} +7 -1
- package/types/amount.js.map +1 -0
- package/types/app.d.ts +279 -0
- package/types/app.d.ts.map +1 -0
- package/types/app.js +32 -0
- package/types/app.js.map +1 -0
- package/types/application-client.d.ts +229 -0
- package/types/application-client.d.ts.map +1 -0
- package/types/application-client.js +470 -0
- package/types/application-client.js.map +1 -0
- package/types/appspec.d.ts +1 -2
- package/types/appspec.d.ts.map +1 -1
- package/types/appspec.js.map +1 -1
- package/types/config.d.ts +15 -0
- package/types/config.d.ts.map +1 -0
- package/types/config.js +27 -0
- package/types/config.js.map +1 -0
- package/types/indexer.d.ts +8 -9
- package/types/indexer.d.ts.map +1 -1
- package/{config.d.ts → types/logging.d.ts} +2 -16
- package/types/logging.d.ts.map +1 -0
- package/{config.js → types/logging.js} +5 -24
- package/types/logging.js.map +1 -0
- package/types/logic-error.d.ts +33 -0
- package/types/logic-error.d.ts.map +1 -0
- package/types/logic-error.js +46 -0
- package/types/logic-error.js.map +1 -0
- package/types/network-client.d.ts +11 -0
- package/types/network-client.d.ts.map +1 -0
- package/types/network-client.js +3 -0
- package/types/network-client.js.map +1 -0
- package/types/testing.d.ts +89 -0
- package/types/testing.d.ts.map +1 -0
- package/types/testing.js +3 -0
- package/types/testing.js.map +1 -0
- package/types/transaction.d.ts +67 -0
- package/types/transaction.d.ts.map +1 -0
- package/types/transaction.js +3 -0
- package/types/transaction.js.map +1 -0
- package/types/transfer.d.ts +32 -0
- package/types/transfer.d.ts.map +1 -0
- package/types/transfer.js +3 -0
- package/types/transfer.js.map +1 -0
- package/types/urlTokenBaseHTTPClient.d.ts.map +1 -0
- package/types/urlTokenBaseHTTPClient.js.map +1 -0
- package/algo-amount.d.ts.map +0 -1
- package/algo-amount.js.map +0 -1
- package/algo-http-client-with-retry.d.ts.map +0 -1
- package/algo-http-client-with-retry.js.map +0 -1
- package/config.d.ts.map +0 -1
- package/config.js.map +0 -1
- package/urlTokenBaseHTTPClient.d.ts.map +0 -1
- package/urlTokenBaseHTTPClient.js.map +0 -1
- /package/{algo-http-client-with-retry.d.ts → types/algo-http-client-with-retry.d.ts} +0 -0
- /package/{urlTokenBaseHTTPClient.d.ts → types/urlTokenBaseHTTPClient.d.ts} +0 -0
- /package/{urlTokenBaseHTTPClient.js → types/urlTokenBaseHTTPClient.js} +0 -0
package/transfer.js
CHANGED
|
@@ -3,9 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.transferAlgos = void 0;
|
|
6
|
+
exports.ensureFunded = exports.transferAlgos = void 0;
|
|
7
7
|
const algosdk_1 = __importDefault(require("algosdk"));
|
|
8
|
-
const
|
|
8
|
+
const _1 = require("./");
|
|
9
9
|
const transaction_1 = require("./transaction");
|
|
10
10
|
/**
|
|
11
11
|
* Transfer ALGOs between two accounts.
|
|
@@ -25,9 +25,41 @@ async function transferAlgos(transfer, algod) {
|
|
|
25
25
|
rekeyTo: undefined,
|
|
26
26
|
});
|
|
27
27
|
if (!sendParams.skipSending) {
|
|
28
|
-
|
|
28
|
+
_1.Config.getLogger(sendParams.suppressLog).debug(`Transferring ${amount.microAlgos}µALGOs from ${(0, transaction_1.getSenderAddress)(from)} to ${to}`);
|
|
29
29
|
}
|
|
30
30
|
return (0, transaction_1.sendTransaction)({ transaction, from, sendParams }, algod);
|
|
31
31
|
}
|
|
32
32
|
exports.transferAlgos = transferAlgos;
|
|
33
|
+
/**
|
|
34
|
+
* Funds a given account using a funding source such that it has a certain amount of algos free to spend (accounting for ALGOs locked in minimum balance requirement).
|
|
35
|
+
*
|
|
36
|
+
* @see https://developer.algorand.org/docs/get-details/accounts/#minimum-balance
|
|
37
|
+
*
|
|
38
|
+
* @param funding The funding configuration
|
|
39
|
+
* @param algod An algod client
|
|
40
|
+
* @returns undefined if nothing was needed or the transaction send result
|
|
41
|
+
*/
|
|
42
|
+
async function ensureFunded(funding, algod) {
|
|
43
|
+
const { accountToFund, fundingSource, minSpendingBalance, minFundingIncrement, transactionParams, note, ...sendParams } = funding;
|
|
44
|
+
const addressToFund = typeof accountToFund === 'string' ? accountToFund : (0, transaction_1.getSenderAddress)(accountToFund);
|
|
45
|
+
const accountInfo = await algod.accountInformation(addressToFund).do();
|
|
46
|
+
const balance = Number(accountInfo.amount);
|
|
47
|
+
const minimumBalanceRequirement = (0, _1.microAlgos)(Number(accountInfo['min-balance']));
|
|
48
|
+
const currentSpendingBalance = (0, _1.microAlgos)(balance - +minimumBalanceRequirement);
|
|
49
|
+
if (minSpendingBalance > currentSpendingBalance) {
|
|
50
|
+
const minFundAmount = (0, _1.microAlgos)(+minSpendingBalance - +currentSpendingBalance);
|
|
51
|
+
const fundAmount = (0, _1.microAlgos)(Math.max(+minFundAmount, minFundingIncrement?.microAlgos ?? 0));
|
|
52
|
+
_1.Config.getLogger(sendParams.suppressLog).info(`Funding ${addressToFund} ${fundAmount} from ${(0, transaction_1.getSenderAddress)(fundingSource)} to reach minimum spend amount of ${minSpendingBalance} (balance = ${balance}, min_balance_req = ${minimumBalanceRequirement})`);
|
|
53
|
+
return await transferAlgos({
|
|
54
|
+
from: fundingSource,
|
|
55
|
+
to: addressToFund,
|
|
56
|
+
note: note ?? 'Funding account to meet minimum requirement',
|
|
57
|
+
amount: fundAmount,
|
|
58
|
+
transactionParams,
|
|
59
|
+
...sendParams,
|
|
60
|
+
}, algod);
|
|
61
|
+
}
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
exports.ensureFunded = ensureFunded;
|
|
33
65
|
//# sourceMappingURL=transfer.js.map
|
package/transfer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transfer.js","sourceRoot":"","sources":["../src/transfer.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"transfer.js","sourceRoot":"","sources":["../src/transfer.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA0C;AAC1C,yBAAuC;AACvC,+CAA8G;AAI9G;;;;;GAKG;AACI,KAAK,UAAU,aAAa,CAAC,QAA4B,EAAE,KAAc;IAC9E,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE,GAAG,UAAU,EAAE,GAAG,QAAQ,CAAA;IAE7E,MAAM,WAAW,GAAG,iBAAO,CAAC,2CAA2C,CAAC;QACtE,IAAI,EAAE,IAAA,8BAAgB,EAAC,IAAI,CAAC;QAC5B,EAAE,EAAE,EAAE;QACN,MAAM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;IAE/E,IAAI,kBAAkB,GAAG,sBAAsB,EAAE;QAC/C,MAAM,aAAa,GAAG,IAAA,aAAU,EAAC,CAAC,kBAAkB,GAAG,CAAC,sBAAsB,CAAC,CAAA;QAC/E,MAAM,UAAU,GAAG,IAAA,aAAU,EAAC,IAAI,CAAC,GAAG,CAAC,CAAC,aAAa,EAAE,mBAAmB,EAAE,UAAU,IAAI,CAAC,CAAC,CAAC,CAAA;QAC7F,SAAM,CAAC,SAAS,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,IAAI,CAC3C,WAAW,aAAa,IAAI,UAAU,SAAS,IAAA,8BAAgB,EAC7D,aAAa,CACd,qCAAqC,kBAAkB,eAAe,OAAO,uBAAuB,yBAAyB,GAAG,CAClI,CAAA;QACD,OAAO,MAAM,aAAa,CACxB;YACE,IAAI,EAAE,aAAa;YACnB,EAAE,EAAE,aAAa;YACjB,IAAI,EAAE,IAAI,IAAI,6CAA6C;YAC3D,MAAM,EAAE,UAAU;YAClB,iBAAiB;YACjB,GAAG,UAAU;SACd,EACD,KAAK,CACN,CAAA;KACF;IAED,OAAO,SAAS,CAAA;AAClB,CAAC;AAhCD,oCAgCC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import algosdk, { Account, MultisigMetadata, Transaction, TransactionSigner } from 'algosdk';
|
|
2
|
+
/**
|
|
3
|
+
* The account name identifier used for fund dispensing in test environments
|
|
4
|
+
*/
|
|
5
|
+
export declare const DISPENSER_ACCOUNT = "DISPENSER";
|
|
6
|
+
/** Account wrapper that supports partial or full multisig signing. */
|
|
7
|
+
export declare class MultisigAccount {
|
|
8
|
+
_params: algosdk.MultisigMetadata;
|
|
9
|
+
_signingAccounts: (algosdk.Account | SigningAccount)[];
|
|
10
|
+
_addr: string;
|
|
11
|
+
/** The parameters for the multisig account */
|
|
12
|
+
get params(): Readonly<algosdk.MultisigMetadata>;
|
|
13
|
+
/** The list of accounts that are present to sign */
|
|
14
|
+
get signingAccounts(): Readonly<(algosdk.Account | SigningAccount)[]>;
|
|
15
|
+
/** The address of the multisig account */
|
|
16
|
+
get addr(): Readonly<string>;
|
|
17
|
+
constructor(multisigParams: MultisigMetadata, signingAccounts: (Account | SigningAccount)[]);
|
|
18
|
+
/**
|
|
19
|
+
* Sign the given transaction
|
|
20
|
+
* @param transaction Either a transaction object or a raw, partially signed transaction
|
|
21
|
+
* @returns The transaction signed by the present signers
|
|
22
|
+
*/
|
|
23
|
+
sign(transaction: Transaction | Uint8Array): Uint8Array;
|
|
24
|
+
}
|
|
25
|
+
/** Account wrapper that supports a rekeyed account */
|
|
26
|
+
export declare class SigningAccount implements Account {
|
|
27
|
+
private _account;
|
|
28
|
+
private _sender;
|
|
29
|
+
/**
|
|
30
|
+
* Algorand address of the sender
|
|
31
|
+
*/
|
|
32
|
+
get addr(): Readonly<string>;
|
|
33
|
+
/**
|
|
34
|
+
* Secret key belonging to the signer
|
|
35
|
+
*/
|
|
36
|
+
get sk(): Readonly<Uint8Array>;
|
|
37
|
+
/**
|
|
38
|
+
* Algorand account of the underlying signing account
|
|
39
|
+
*/
|
|
40
|
+
get signer(): Account;
|
|
41
|
+
/**
|
|
42
|
+
* Algorand account of the sender address and signer private key
|
|
43
|
+
*/
|
|
44
|
+
get sender(): Account;
|
|
45
|
+
constructor(account: Account, sender: string | undefined);
|
|
46
|
+
}
|
|
47
|
+
/** A wrapper around @see {TransactionSigner} that also has the sender address. */
|
|
48
|
+
export interface TransactionSignerAccount {
|
|
49
|
+
addr: Readonly<string>;
|
|
50
|
+
signer: TransactionSigner;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=account.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../src/types/account.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAE5F;;GAEG;AACH,eAA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|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SigningAccount = exports.MultisigAccount = exports.DISPENSER_ACCOUNT = void 0;
|
|
7
|
+
const algosdk_1 = __importDefault(require("algosdk"));
|
|
8
|
+
/**
|
|
9
|
+
* The account name identifier used for fund dispensing in test environments
|
|
10
|
+
*/
|
|
11
|
+
exports.DISPENSER_ACCOUNT = 'DISPENSER';
|
|
12
|
+
/** Account wrapper that supports partial or full multisig signing. */
|
|
13
|
+
class MultisigAccount {
|
|
14
|
+
/** The parameters for the multisig account */
|
|
15
|
+
get params() {
|
|
16
|
+
return this._params;
|
|
17
|
+
}
|
|
18
|
+
/** The list of accounts that are present to sign */
|
|
19
|
+
get signingAccounts() {
|
|
20
|
+
return this._signingAccounts;
|
|
21
|
+
}
|
|
22
|
+
/** The address of the multisig account */
|
|
23
|
+
get addr() {
|
|
24
|
+
return this._addr;
|
|
25
|
+
}
|
|
26
|
+
constructor(multisigParams, signingAccounts) {
|
|
27
|
+
this._params = multisigParams;
|
|
28
|
+
this._signingAccounts = signingAccounts;
|
|
29
|
+
this._addr = algosdk_1.default.multisigAddress(multisigParams);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Sign the given transaction
|
|
33
|
+
* @param transaction Either a transaction object or a raw, partially signed transaction
|
|
34
|
+
* @returns The transaction signed by the present signers
|
|
35
|
+
*/
|
|
36
|
+
sign(transaction) {
|
|
37
|
+
let signedTxn = 'from' in transaction ? undefined : transaction;
|
|
38
|
+
for (const signer of this._signingAccounts) {
|
|
39
|
+
if (signedTxn) {
|
|
40
|
+
signedTxn = algosdk_1.default.appendSignMultisigTransaction(signedTxn, this._params, signer.sk).blob;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
signedTxn = algosdk_1.default.signMultisigTransaction(transaction, this._params, signer.sk).blob;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
47
|
+
return signedTxn;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.MultisigAccount = MultisigAccount;
|
|
51
|
+
/** Account wrapper that supports a rekeyed account */
|
|
52
|
+
class SigningAccount {
|
|
53
|
+
/**
|
|
54
|
+
* Algorand address of the sender
|
|
55
|
+
*/
|
|
56
|
+
get addr() {
|
|
57
|
+
return this._sender;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Secret key belonging to the signer
|
|
61
|
+
*/
|
|
62
|
+
get sk() {
|
|
63
|
+
return this._account.sk;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Algorand account of the underlying signing account
|
|
67
|
+
*/
|
|
68
|
+
get signer() {
|
|
69
|
+
return this._account;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Algorand account of the sender address and signer private key
|
|
73
|
+
*/
|
|
74
|
+
get sender() {
|
|
75
|
+
return {
|
|
76
|
+
addr: this._sender,
|
|
77
|
+
sk: this._account.sk,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
constructor(account, sender) {
|
|
81
|
+
this._account = account;
|
|
82
|
+
this._sender = sender ?? account.addr;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.SigningAccount = SigningAccount;
|
|
86
|
+
//# sourceMappingURL=account.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/types/account.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA4F;AAE5F;;GAEG;AACU,QAAA,iBAAiB,GAAG,WAAW,CAAA;AAE5C,sEAAsE;AACtE,MAAa,eAAe;IAK1B,8CAA8C;IAC9C,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;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E,MAAM,EACpB,IAAI,EAAE,UAAU,EAChB,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,EACrB,cAAc,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GAC1C,OAAO,CAAC,sBAAsB,CAAC;CAGnC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AlgoHttpClientWithRetry = void 0;
|
|
4
|
-
const
|
|
4
|
+
const __1 = require("../");
|
|
5
5
|
const urlTokenBaseHTTPClient_1 = require("./urlTokenBaseHTTPClient");
|
|
6
6
|
/** A HTTP Client that wraps the Algorand SDK HTTP Client with retries */
|
|
7
7
|
class AlgoHttpClientWithRetry extends urlTokenBaseHTTPClient_1.URLTokenBaseHTTPClient {
|
|
@@ -26,7 +26,7 @@ class AlgoHttpClientWithRetry extends urlTokenBaseHTTPClient_1.URLTokenBaseHTTPC
|
|
|
26
26
|
if (delayTimeMs > 0) {
|
|
27
27
|
await new Promise((r) => setTimeout(r, delayTimeMs));
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
__1.Config.logger.warn(`algosdk request failed ${numTries} times. Retrying in ${delayTimeMs}ms: ${err}`);
|
|
30
30
|
}
|
|
31
31
|
} while (!response && ++numTries <= AlgoHttpClientWithRetry.MAX_TRIES);
|
|
32
32
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -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,2BAA4B;AAC5B,qEAAiE;AAEjE,yEAAyE;AACzE,MAAa,uBAAwB,SAAQ,+CAAsB;IAmBzD,KAAK,CAAC,aAAa,CAAC,IAA2C;QACrE,IAAI,QAA4C,CAAA;QAChD,IAAI,QAAQ,GAAG,CAAC,CAAA;QAChB,GAAG;YACD,IAAI;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AAC;IAED,KAAK,CAAC,IAAI,CACR,YAAoB,EACpB,IAAgB,EAChB,KAAqB,EACrB,iBAAyC,EAAE;QAE3C,OAAO,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,CAAA;IAC9F,CAAC;IAED,KAAK,CAAC,MAAM,CACV,YAAoB,EACpB,IAAgB,EAChB,KAAqB,EACrB,iBAAyC,EAAE;QAE3C,OAAO,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,YAAY,EAAE,IAAI,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,CAAA;IAChG,CAAC;;AApEH,0DAqEC;AApEyB,iCAAS,GAAG,CAAC,CAAA;AACb,sCAAc,GAAG,KAAK,CAAA;AAE9C,oFAAoF;AACpF,mHAAmH;AAC3F,0CAAkB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;AACxD,yCAAiB,GAAG;IAC1C,WAAW;IACX,YAAY;IACZ,YAAY;IACZ,cAAc;IACd,OAAO;IACP,WAAW;IACX,aAAa;IACb,WAAW;IACX,QAAQ,EAAE,+CAA+C;CAC1D,CAAA"}
|
package/types/algod.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { EncodedSignedTransaction } from 'algosdk';
|
|
|
2
2
|
/** The response from the pending transaction API @see https://developer.algorand.org/docs/rest-apis/algod/v2/#get-v2transactionspendingtxid */
|
|
3
3
|
export interface PendingTransactionResponse {
|
|
4
4
|
/**
|
|
5
|
-
* The application
|
|
5
|
+
* The application id if the transaction was found and it created an
|
|
6
6
|
* application.
|
|
7
7
|
*/
|
|
8
8
|
'application-index'?: number;
|
|
@@ -11,7 +11,7 @@ export interface PendingTransactionResponse {
|
|
|
11
11
|
*/
|
|
12
12
|
'asset-closing-amount'?: number;
|
|
13
13
|
/**
|
|
14
|
-
* The asset
|
|
14
|
+
* The asset id if the transaction was found and it created an asset.
|
|
15
15
|
*/
|
|
16
16
|
'asset-index'?: number;
|
|
17
17
|
/**
|
|
@@ -61,18 +61,32 @@ export interface PendingTransactionResponse {
|
|
|
61
61
|
txn: EncodedSignedTransaction;
|
|
62
62
|
}
|
|
63
63
|
/** Represents a TEAL value delta @see https://developer.algorand.org/docs/rest-apis/algod/v2/#evaldelta */
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
export type EvalDelta = {
|
|
65
|
+
/**
|
|
66
|
+
* Value `1` refers to **bytes**, value `2` refers to **uint**
|
|
67
|
+
*/
|
|
68
|
+
action: 1;
|
|
69
|
+
/**
|
|
70
|
+
* Bytes value.
|
|
71
|
+
*/
|
|
66
72
|
bytes: string;
|
|
67
|
-
|
|
68
|
-
|
|
73
|
+
} | {
|
|
74
|
+
/**
|
|
75
|
+
* Value `1` refers to **bytes**, value `2` refers to **uint**
|
|
76
|
+
*/
|
|
77
|
+
action: 2;
|
|
78
|
+
/**
|
|
79
|
+
* Uint value.
|
|
80
|
+
*/
|
|
81
|
+
uint: number | bigint;
|
|
82
|
+
};
|
|
69
83
|
/** The response from the application API @see https://developer.algorand.org/docs/rest-apis/algod/v2/#get-v2applicationsapplication-id */
|
|
70
84
|
export interface ApplicationResponse {
|
|
71
85
|
id: number;
|
|
72
86
|
params: ApplicationParams;
|
|
73
87
|
}
|
|
74
88
|
/** Stores the global information associated with an application @see https://developer.algorand.org/docs/rest-apis/algod/v2/#applicationparams */
|
|
75
|
-
interface ApplicationParams {
|
|
89
|
+
export interface ApplicationParams {
|
|
76
90
|
/** Address of the account that created the app */
|
|
77
91
|
creator: string;
|
|
78
92
|
/** Base64 encoded TEAL approval program */
|
|
@@ -94,7 +108,7 @@ interface ApplicationParams {
|
|
|
94
108
|
/**
|
|
95
109
|
* Represents a TEAL value @see https://developer.algorand.org/docs/rest-apis/algod/v2/#tealvalue
|
|
96
110
|
*/
|
|
97
|
-
type TealValue = {
|
|
111
|
+
export type TealValue = {
|
|
98
112
|
/**
|
|
99
113
|
* (tt) value type. Value `1` refers to **bytes**, value `2` refers to **uint**
|
|
100
114
|
*/
|
|
@@ -120,5 +134,4 @@ export interface ApplicationStateSchema {
|
|
|
120
134
|
/** [nui] num of uints */
|
|
121
135
|
'num-uint': number;
|
|
122
136
|
}
|
|
123
|
-
export {};
|
|
124
137
|
//# sourceMappingURL=algod.d.ts.map
|
package/types/algod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"algod.d.ts","sourceRoot":"","sources":["../../src/types/algod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAElD,+IAA+I;AAC/I,MAAM,WAAW,0BAA0B;IACzC;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B;;OAEG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAA;IAC/B;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B;;;OAGG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,CAAA;IAClD;;OAEG;IACH,YAAY,CAAC,EAAE,0BAA0B,EAAE,CAAA;IAC3C;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,CAAA;IACjD;;OAEG;IACH,IAAI,CAAC,EAAE,UAAU,EAAE,CAAA;IACnB;4GACwG;IACxG,YAAY,EAAE,MAAM,CAAA;IACpB;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B;;OA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EAAE,CAAC,CAAA;IAET;;OAEG;IACH,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;CACtB,CAAA;AAEL,0IAA0I;AAC1I,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,iBAAiB,CAAA;CAC1B;AAED,kJAAkJ;AAClJ,MAAM,WAAW,iBAAiB;IAChC,kDAAkD;IAClD,OAAO,EAAE,MAAM,CAAA;IACf,2CAA2C;IAC3C,kBAAkB,EAAE,MAAM,CAAA;IAC1B,8CAA8C;IAC9C,qBAAqB,EAAE,MAAM,CAAA;IAC7B,+DAA+D;IAC/D,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,kCAAkC;IAClC,cAAc,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,SAAS,CAAA;KAAE,EAAE,CAAA;IACpD,0BAA0B;IAC1B,qBAAqB,CAAC,EAAE,sBAAsB,CAAA;IAC9C,yBAAyB;IACzB,oBAAoB,CAAC,EAAE,sBAAsB,CAAA;CAC9C;AAED;;GAEG;AACH,MAAM,MAAM,SAAS,GACjB;IACE;;OAEG;IACH,IAAI,EAAE,CAAC,CAAA;IACP;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;CACd,GACD;IACE;;OAEG;IACH,IAAI,EAAE,CAAC,CAAA;IAEP;;OAEG;IACH,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;CACtB,CAAA;AAEL,2JAA2J;AAC3J,MAAM,WAAW,sBAAsB;IACrC,+BAA+B;IAC/B,gBAAgB,EAAE,MAAM,CAAA;IACxB,yBAAyB;IACzB,UAAU,EAAE,MAAM,CAAA;CACnB"}
|
|
@@ -10,9 +10,11 @@ export declare class AlgoAmount {
|
|
|
10
10
|
} | {
|
|
11
11
|
microAlgos: number;
|
|
12
12
|
});
|
|
13
|
+
toString(): string;
|
|
14
|
+
valueOf(): number;
|
|
13
15
|
/** Create a @see {AlgoAmount} object representing the given number of Algos */
|
|
14
16
|
static Algos(amount: number): AlgoAmount;
|
|
15
17
|
/** Create a @see {AlgoAmount} object representing the given number of µAlgos */
|
|
16
18
|
static MicroAlgos(amount: number): AlgoAmount;
|
|
17
19
|
}
|
|
18
|
-
//# sourceMappingURL=
|
|
20
|
+
//# sourceMappingURL=amount.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amount.d.ts","sourceRoot":"","sources":["../../src/types/amount.ts"],"names":[],"mappings":"AAEA,0FAA0F;AAC1F,qBAAa,UAAU;IACrB,OAAO,CAAC,kBAAkB,CAAA;IAE1B,8CAA8C;IAC9C,IAAI,UAAU,WAEb;IAED,6CAA6C;IAC7C,IAAI,KAAK,WAER;gBAEW,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE;IAI9D,QAAQ,IAAI,MAAM;IAIlB,OAAO,IAAI,MAAM;IAIjB,+EAA+E;IAC/E,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM;IAI3B,gFAAgF;IAChF,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM;CAGjC"}
|
|
@@ -18,6 +18,12 @@ class AlgoAmount {
|
|
|
18
18
|
constructor(amount) {
|
|
19
19
|
this.amountInMicroAlgos = 'microAlgos' in amount ? amount.microAlgos : algosdk_1.default.algosToMicroalgos(amount.algos);
|
|
20
20
|
}
|
|
21
|
+
toString() {
|
|
22
|
+
return `${this.microAlgos.toLocaleString('en-US')} µALGO${this.microAlgos === 1 ? '' : 's'}`;
|
|
23
|
+
}
|
|
24
|
+
valueOf() {
|
|
25
|
+
return this.microAlgos;
|
|
26
|
+
}
|
|
21
27
|
/** Create a @see {AlgoAmount} object representing the given number of Algos */
|
|
22
28
|
static Algos(amount) {
|
|
23
29
|
return new AlgoAmount({ algos: amount });
|
|
@@ -28,4 +34,4 @@ class AlgoAmount {
|
|
|
28
34
|
}
|
|
29
35
|
}
|
|
30
36
|
exports.AlgoAmount = AlgoAmount;
|
|
31
|
-
//# sourceMappingURL=
|
|
37
|
+
//# sourceMappingURL=amount.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amount.js","sourceRoot":"","sources":["../../src/types/amount.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA6B;AAE7B,0FAA0F;AAC1F,MAAa,UAAU;IAGrB,8CAA8C;IAC9C,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,kBAAkB,CAAA;IAChC,CAAC;IAED,6CAA6C;IAC7C,IAAI,KAAK;QACP,OAAO,iBAAO,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,iBAAO,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,OAAO;QACL,OAAO,IAAI,CAAC,UAAU,CAAA;IACxB,CAAC;IAED,+EAA+E;IAC/E,MAAM,CAAC,KAAK,CAAC,MAAc;QACzB,OAAO,IAAI,UAAU,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAA;IAC1C,CAAC;IAED,gFAAgF;IAChF,MAAM,CAAC,UAAU,CAAC,MAAc;QAC9B,OAAO,IAAI,UAAU,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAA;IAC/C,CAAC;CACF;AAlCD,gCAkCC"}
|
package/types/app.d.ts
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { ABIArgument, ABIMethod, ABIMethodParams, ABIType, ABIValue, Address, SourceMap, SuggestedParams, Transaction } from 'algosdk';
|
|
2
|
+
import { SendTransactionFrom, SendTransactionParams, SendTransactionResult, TransactionNote, TransactionToSign } from './transaction';
|
|
3
|
+
/** The name of the TEAL template variable for deploy-time immutability control */
|
|
4
|
+
export declare const UPDATABLE_TEMPLATE_NAME = "TMPL_UPDATABLE";
|
|
5
|
+
/** The name of the TEAL template variable for deploy-time permanence control */
|
|
6
|
+
export declare const DELETABLE_TEMPLATE_NAME = "TMPL_DELETABLE";
|
|
7
|
+
/** The app create/update ARC-2 transaction note prefix */
|
|
8
|
+
export declare const APP_DEPLOY_NOTE_DAPP = "ALGOKIT_DEPLOYER";
|
|
9
|
+
/** The maximum number of bytes in a single app code page */
|
|
10
|
+
export declare const APP_PAGE_MAX_SIZE = 2048;
|
|
11
|
+
/** First 4 bytes of SHA-512/256 hash of "return" for retrieving ABI return values */
|
|
12
|
+
export declare const ABI_RETURN_PREFIX: Uint8Array;
|
|
13
|
+
/** Information about an Algorand app */
|
|
14
|
+
export interface AppReference {
|
|
15
|
+
/** The id of the app */
|
|
16
|
+
appId: number;
|
|
17
|
+
/** The Algorand address of the account associated with the app */
|
|
18
|
+
appAddress: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A grouping of the app ID and name of the box in an Uint8Array
|
|
22
|
+
*/
|
|
23
|
+
export interface BoxReference {
|
|
24
|
+
/**
|
|
25
|
+
* A unique application id
|
|
26
|
+
*/
|
|
27
|
+
appId: number;
|
|
28
|
+
/**
|
|
29
|
+
* Name of box to reference
|
|
30
|
+
*/
|
|
31
|
+
name: Uint8Array | string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* App call args with raw values (minus some processing like encoding strings as binary)
|
|
35
|
+
*/
|
|
36
|
+
export interface RawAppCallArgs {
|
|
37
|
+
/** The address of any accounts to load in */
|
|
38
|
+
accounts?: (string | Address)[];
|
|
39
|
+
/** Any application arguments to pass through */
|
|
40
|
+
appArgs?: (Uint8Array | string)[];
|
|
41
|
+
/** Any box references to load */
|
|
42
|
+
boxes?: BoxReference[];
|
|
43
|
+
/** IDs of any apps to load into the foreignApps array */
|
|
44
|
+
apps?: number[];
|
|
45
|
+
/** IDs of any assets to load into the foreignAssets array */
|
|
46
|
+
assets?: number[];
|
|
47
|
+
/** The optional lease for the transaction */
|
|
48
|
+
lease?: string | Uint8Array;
|
|
49
|
+
}
|
|
50
|
+
export type ABIAppCallArg = ABIArgument | TransactionToSign | Transaction;
|
|
51
|
+
/**
|
|
52
|
+
* App call args for an ABI call
|
|
53
|
+
*/
|
|
54
|
+
export interface ABIAppCallArgs {
|
|
55
|
+
/** The ABI method to call, either:
|
|
56
|
+
* * `method_name` e.g. `hello`; or
|
|
57
|
+
* * `method_signature` e.g. `hello(string)string`
|
|
58
|
+
**/
|
|
59
|
+
method: ABIMethodParams | ABIMethod;
|
|
60
|
+
/** The ABI args to pass in */
|
|
61
|
+
args: ABIAppCallArg[];
|
|
62
|
+
/** The optional lease for the transaction */
|
|
63
|
+
lease?: string | Uint8Array;
|
|
64
|
+
/** Any box references to load either as the box name (if for the current app) or the reference with app id */
|
|
65
|
+
boxes?: (BoxReference | Uint8Array | string)[];
|
|
66
|
+
}
|
|
67
|
+
/** Arguments to pass to an app call either:
|
|
68
|
+
* * The raw app call values to pass through into the transaction (after processing); or
|
|
69
|
+
* * An ABI method definition (method and args)
|
|
70
|
+
**/
|
|
71
|
+
export type AppCallArgs = RawAppCallArgs | ABIAppCallArgs;
|
|
72
|
+
/** Base interface for common data passed to an app create or update. */
|
|
73
|
+
interface CreateOrUpdateAppParams extends SendTransactionParams {
|
|
74
|
+
/** The account (with private key loaded) that will send the µALGOs */
|
|
75
|
+
from: SendTransactionFrom;
|
|
76
|
+
/** The approval program as raw teal (string) or compiled teal, base 64 encoded as a byte array (Uint8Array) */
|
|
77
|
+
approvalProgram: Uint8Array | string;
|
|
78
|
+
/** The clear state program as raw teal (string) or compiled teal, base 64 encoded as a byte array (Uint8Array) */
|
|
79
|
+
clearStateProgram: Uint8Array | string;
|
|
80
|
+
/** Optional transaction parameters */
|
|
81
|
+
transactionParams?: SuggestedParams;
|
|
82
|
+
/** The (optional) transaction note */
|
|
83
|
+
note?: TransactionNote;
|
|
84
|
+
/** The arguments passed in to the app call */
|
|
85
|
+
args?: AppCallArgs;
|
|
86
|
+
}
|
|
87
|
+
/** Parameters that are passed in when creating an app. */
|
|
88
|
+
export interface CreateAppParams extends CreateOrUpdateAppParams {
|
|
89
|
+
/** The storage schema to request for the created app */
|
|
90
|
+
schema: AppStorageSchema;
|
|
91
|
+
}
|
|
92
|
+
/** Parameters that are passed in when updating an app. */
|
|
93
|
+
export interface UpdateAppParams extends CreateOrUpdateAppParams {
|
|
94
|
+
/** The id of the app to update */
|
|
95
|
+
appId: number;
|
|
96
|
+
}
|
|
97
|
+
export interface AppCallParams extends SendTransactionParams {
|
|
98
|
+
/** The id of the app to call */
|
|
99
|
+
appId: number;
|
|
100
|
+
/** The type of call, everything except create (@see createApp ) and update (@see updateApp ) */
|
|
101
|
+
callType: 'optin' | 'closeout' | 'clearstate' | 'delete' | 'normal';
|
|
102
|
+
/** The account to make the call from */
|
|
103
|
+
from: SendTransactionFrom;
|
|
104
|
+
/** Optional transaction parameters */
|
|
105
|
+
transactionParams?: SuggestedParams;
|
|
106
|
+
/** The (optional) transaction note */
|
|
107
|
+
note?: TransactionNote;
|
|
108
|
+
/** The arguments passed in to the app call */
|
|
109
|
+
args?: AppCallArgs;
|
|
110
|
+
}
|
|
111
|
+
/** Parameters representing the storage schema of an app. */
|
|
112
|
+
export interface AppStorageSchema {
|
|
113
|
+
/** Restricts number of ints in per-user local state */
|
|
114
|
+
localInts: number;
|
|
115
|
+
/** Restricts number of byte slices in per-user local state */
|
|
116
|
+
localByteSlices: number;
|
|
117
|
+
/** Restricts number of ints in global state */
|
|
118
|
+
globalInts: number;
|
|
119
|
+
/** Restricts number of byte slices in global state */
|
|
120
|
+
globalByteSlices: number;
|
|
121
|
+
/** Any extra pages that are needed for the smart contract; if left blank then the right number of pages will be calculated based on the teal code size */
|
|
122
|
+
extraPages?: number;
|
|
123
|
+
}
|
|
124
|
+
/** Information about a compiled teal program */
|
|
125
|
+
export interface CompiledTeal {
|
|
126
|
+
/** Original TEAL code */
|
|
127
|
+
teal: string;
|
|
128
|
+
/** The compiled code */
|
|
129
|
+
compiled: string;
|
|
130
|
+
/** The has returned by the compiler */
|
|
131
|
+
compiledHash: string;
|
|
132
|
+
/** The base64 encoded code as a byte array */
|
|
133
|
+
compiledBase64ToBytes: Uint8Array;
|
|
134
|
+
/** Source map from the compilation */
|
|
135
|
+
sourceMap: SourceMap;
|
|
136
|
+
}
|
|
137
|
+
/** Result from calling an app */
|
|
138
|
+
export interface AppCallTransactionResult extends SendTransactionResult {
|
|
139
|
+
/** If an ABI method was called the processed return value */
|
|
140
|
+
return?: ABIReturn;
|
|
141
|
+
}
|
|
142
|
+
/** The return value of an ABI method call */
|
|
143
|
+
export type ABIReturn = {
|
|
144
|
+
rawReturnValue: Uint8Array;
|
|
145
|
+
returnValue: ABIValue;
|
|
146
|
+
decodeError: undefined;
|
|
147
|
+
} | {
|
|
148
|
+
rawReturnValue: undefined;
|
|
149
|
+
returnValue: undefined;
|
|
150
|
+
decodeError: Error;
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* The payload of the metadata to add to the transaction note when deploying an app, noting it will be prefixed with @see {APP_DEPLOY_NOTE_PREFIX}.
|
|
154
|
+
*/
|
|
155
|
+
export interface AppDeployMetadata {
|
|
156
|
+
/** The unique name identifier of the app within the creator account */
|
|
157
|
+
name: string;
|
|
158
|
+
/** The version of app that is / will be deployed */
|
|
159
|
+
version: string;
|
|
160
|
+
/** Whether or not the app is deletable / permanent / unspecified */
|
|
161
|
+
deletable?: boolean;
|
|
162
|
+
/** Whether or not the app is updatable / immutable / unspecified */
|
|
163
|
+
updatable?: boolean;
|
|
164
|
+
}
|
|
165
|
+
/** The metadata that can be collected about a deployed app */
|
|
166
|
+
export interface AppMetadata extends AppReference, AppDeployMetadata {
|
|
167
|
+
/** The round the app was created */
|
|
168
|
+
createdRound: number;
|
|
169
|
+
/** The last round that the app was updated */
|
|
170
|
+
updatedRound: number;
|
|
171
|
+
/** The metadata when the app was created */
|
|
172
|
+
createdMetadata: AppDeployMetadata;
|
|
173
|
+
/** Whether or not the app is deleted */
|
|
174
|
+
deleted: boolean;
|
|
175
|
+
}
|
|
176
|
+
/** A lookup of name -> Algorand app for a creator */
|
|
177
|
+
export interface AppLookup {
|
|
178
|
+
creator: Readonly<string>;
|
|
179
|
+
apps: Readonly<{
|
|
180
|
+
[name: string]: AppMetadata;
|
|
181
|
+
}>;
|
|
182
|
+
}
|
|
183
|
+
/** Dictionary of deploy-time parameters to replace in a teal template.
|
|
184
|
+
*
|
|
185
|
+
* Note: Looks for `TMPL_{parameter}` for template replacements i.e. you can leave out the `TMPL_`.
|
|
186
|
+
*
|
|
187
|
+
*/
|
|
188
|
+
export interface TealTemplateParams {
|
|
189
|
+
[key: string]: string | bigint | number | Uint8Array;
|
|
190
|
+
}
|
|
191
|
+
/** What action to perform when deploying an app and an update is detected in the TEAL code */
|
|
192
|
+
export declare enum OnUpdate {
|
|
193
|
+
/** Fail the deployment */
|
|
194
|
+
Fail = 0,
|
|
195
|
+
/** Update the app */
|
|
196
|
+
UpdateApp = 1,
|
|
197
|
+
/** Delete the app and create a new one in its place */
|
|
198
|
+
ReplaceApp = 2
|
|
199
|
+
}
|
|
200
|
+
/** What action to perform when deploying an app and a breaking schema change is detected */
|
|
201
|
+
export declare enum OnSchemaBreak {
|
|
202
|
+
/** Fail the deployment */
|
|
203
|
+
Fail = 0,
|
|
204
|
+
/** Delete the app and create a new one in its place */
|
|
205
|
+
ReplaceApp = 1
|
|
206
|
+
}
|
|
207
|
+
/** The parameters to deploy an app */
|
|
208
|
+
export interface AppDeploymentParams extends Omit<CreateAppParams, 'args' | 'note' | 'skipSending' | 'skipWaiting'> {
|
|
209
|
+
/** The deployment metadata */
|
|
210
|
+
metadata: AppDeployMetadata;
|
|
211
|
+
/** Any deploy-time parameters to replace in the TEAL code */
|
|
212
|
+
deployTimeParams?: TealTemplateParams;
|
|
213
|
+
/** What action to perform if a schema break is detected */
|
|
214
|
+
onSchemaBreak?: 'replace' | 'fail' | OnSchemaBreak;
|
|
215
|
+
/** What action to perform if a TEAL update is detected */
|
|
216
|
+
onUpdate?: 'update' | 'replace' | 'fail' | OnUpdate;
|
|
217
|
+
/** Optional cached value of the existing apps for the given creator */
|
|
218
|
+
existingDeployments?: AppLookup;
|
|
219
|
+
/** Any args to pass to any create transaction that is issued as part of deployment */
|
|
220
|
+
createArgs?: AppCallArgs;
|
|
221
|
+
/** Any args to pass to any update transaction that is issued as part of deployment */
|
|
222
|
+
updateArgs?: AppCallArgs;
|
|
223
|
+
/** Any args to pass to any delete transaction that is issued as part of deployment */
|
|
224
|
+
deleteArgs?: AppCallArgs;
|
|
225
|
+
}
|
|
226
|
+
/** The result of compiling the approval and clear TEAL for an app */
|
|
227
|
+
export interface AppCompilationResult {
|
|
228
|
+
/** The compilation result of approval */
|
|
229
|
+
compiledApproval: CompiledTeal;
|
|
230
|
+
/** The compilation result of clear */
|
|
231
|
+
compiledClear: CompiledTeal;
|
|
232
|
+
}
|
|
233
|
+
/** Object holding app state values */
|
|
234
|
+
export interface AppState {
|
|
235
|
+
[key: string]: {
|
|
236
|
+
value: number | bigint;
|
|
237
|
+
keyRaw: Uint8Array;
|
|
238
|
+
keyBase64: string;
|
|
239
|
+
} | {
|
|
240
|
+
value: string;
|
|
241
|
+
valueRaw: Uint8Array;
|
|
242
|
+
valueBase64: string;
|
|
243
|
+
keyRaw: Uint8Array;
|
|
244
|
+
keyBase64: string;
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
/** The name of a box storage box */
|
|
248
|
+
export interface BoxName {
|
|
249
|
+
/** Name in UTF-8 */
|
|
250
|
+
name: string;
|
|
251
|
+
/** Name in binary bytes */
|
|
252
|
+
nameRaw: Uint8Array;
|
|
253
|
+
/** Name in Base64 */
|
|
254
|
+
nameBase64: string;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Parameters to get and decode a box value as an ABI type.
|
|
258
|
+
*/
|
|
259
|
+
export interface BoxValueRequestParams {
|
|
260
|
+
/** The ID of the app return box names for */
|
|
261
|
+
appId: number;
|
|
262
|
+
/** The name of the box to return either as a string, binary array or @see BoxName */
|
|
263
|
+
boxName: string | Uint8Array | BoxName;
|
|
264
|
+
/** The ABI type to decode the value using */
|
|
265
|
+
type: ABIType;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Parameters to get and decode a box value as an ABI type.
|
|
269
|
+
*/
|
|
270
|
+
export interface BoxValuesRequestParams {
|
|
271
|
+
/** The ID of the app return box names for */
|
|
272
|
+
appId: number;
|
|
273
|
+
/** The names of the boxes to return either as a string, binary array or @see BoxName */
|
|
274
|
+
boxNames: (string | Uint8Array | BoxName)[];
|
|
275
|
+
/** The ABI type to decode the value using */
|
|
276
|
+
type: ABIType;
|
|
277
|
+
}
|
|
278
|
+
export {};
|
|
279
|
+
//# sourceMappingURL=app.d.ts.map
|