@algorandfoundation/algokit-utils 7.0.0-beta.1 → 7.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/account/account.d.ts +7 -7
- package/account/account.js +7 -7
- package/account/account.mjs +7 -7
- package/account/get-account.d.ts +2 -2
- package/account/get-account.js +1 -1
- package/account/get-account.mjs +1 -1
- package/account/get-dispenser-account.d.ts +1 -1
- package/account/get-dispenser-account.js +1 -1
- package/account/get-dispenser-account.mjs +1 -1
- package/account/mnemonic-account.d.ts +1 -1
- package/account/mnemonic-account.js +1 -1
- package/account/mnemonic-account.mjs +1 -1
- package/app-deploy.d.ts +18 -1
- package/app-deploy.d.ts.map +1 -1
- package/app-deploy.js +142 -333
- package/app-deploy.js.map +1 -1
- package/app-deploy.mjs +145 -336
- package/app-deploy.mjs.map +1 -1
- package/app.d.ts +38 -1
- package/app.d.ts.map +1 -1
- package/app.js +113 -370
- package/app.js.map +1 -1
- package/app.mjs +114 -371
- package/app.mjs.map +1 -1
- package/asset.d.ts +5 -5
- package/asset.js +5 -5
- package/asset.mjs +5 -5
- package/debugging/debugging.js +2 -2
- package/debugging/debugging.js.map +1 -1
- package/debugging/debugging.mjs +2 -2
- package/debugging/debugging.mjs.map +1 -1
- package/index.d.ts +1 -1
- package/index.d.ts.map +1 -1
- package/index.js +12 -12
- package/index.mjs +1 -1
- package/localnet/get-kmd-wallet-account.d.ts +1 -1
- package/localnet/get-kmd-wallet-account.js +1 -1
- package/localnet/get-kmd-wallet-account.mjs +1 -1
- package/localnet/get-localnet-dispenser-account.d.ts +1 -1
- package/localnet/get-localnet-dispenser-account.js +1 -1
- package/localnet/get-localnet-dispenser-account.mjs +1 -1
- package/localnet/get-or-create-kmd-wallet-account.d.ts +1 -1
- package/localnet/get-or-create-kmd-wallet-account.js +1 -1
- package/localnet/get-or-create-kmd-wallet-account.mjs +1 -1
- package/localnet/is-localnet.d.ts +1 -1
- package/localnet/is-localnet.js +1 -1
- package/localnet/is-localnet.mjs +1 -1
- package/network-client.d.ts +2 -2
- package/network-client.d.ts.map +1 -1
- package/network-client.js +2 -2
- package/network-client.mjs +2 -2
- package/package.json +1 -1
- package/testing/fixtures/algorand-fixture.js +12 -12
- package/testing/fixtures/algorand-fixture.js.map +1 -1
- package/testing/fixtures/algorand-fixture.mjs +12 -12
- package/testing/fixtures/algorand-fixture.mjs.map +1 -1
- package/transaction/legacy-bridge.d.ts +31 -5
- package/transaction/legacy-bridge.d.ts.map +1 -1
- package/transaction/legacy-bridge.js +99 -5
- package/transaction/legacy-bridge.js.map +1 -1
- package/transaction/legacy-bridge.mjs +98 -7
- package/transaction/legacy-bridge.mjs.map +1 -1
- package/transfer/transfer-algos.d.ts +1 -1
- package/transfer/transfer-algos.js +1 -1
- package/transfer/transfer-algos.mjs +1 -1
- package/transfer/transfer.d.ts +1 -1
- package/transfer/transfer.js +1 -1
- package/transfer/transfer.mjs +1 -1
- package/types/account-manager.d.ts +1 -1
- package/types/account-manager.d.ts.map +1 -1
- package/types/algorand-client-transaction-creator.d.ts +450 -20
- package/types/algorand-client-transaction-creator.d.ts.map +1 -1
- package/types/algorand-client-transaction-creator.js +406 -22
- package/types/algorand-client-transaction-creator.js.map +1 -1
- package/types/algorand-client-transaction-creator.mjs +406 -22
- package/types/algorand-client-transaction-creator.mjs.map +1 -1
- package/types/algorand-client-transaction-sender.d.ts +750 -24
- package/types/algorand-client-transaction-sender.d.ts.map +1 -1
- package/types/algorand-client-transaction-sender.js +426 -12
- package/types/algorand-client-transaction-sender.js.map +1 -1
- package/types/algorand-client-transaction-sender.mjs +426 -12
- package/types/algorand-client-transaction-sender.mjs.map +1 -1
- package/types/algorand-client.d.ts +8 -0
- package/types/algorand-client.d.ts.map +1 -1
- package/types/algorand-client.js +14 -1
- package/types/algorand-client.js.map +1 -1
- package/types/algorand-client.mjs +14 -1
- package/types/algorand-client.mjs.map +1 -1
- package/types/app-client.d.ts +13 -1
- package/types/app-client.d.ts.map +1 -1
- package/types/app-client.js +8 -5
- package/types/app-client.js.map +1 -1
- package/types/app-client.mjs +9 -6
- package/types/app-client.mjs.map +1 -1
- package/types/app-deployer.d.ts +121 -0
- package/types/app-deployer.d.ts.map +1 -0
- package/types/app-deployer.js +354 -0
- package/types/app-deployer.js.map +1 -0
- package/types/app-deployer.mjs +352 -0
- package/types/app-deployer.mjs.map +1 -0
- package/types/app-manager.d.ts +235 -0
- package/types/app-manager.d.ts.map +1 -0
- package/types/app-manager.js +336 -0
- package/types/app-manager.js.map +1 -0
- package/types/app-manager.mjs +334 -0
- package/types/app-manager.mjs.map +1 -0
- package/types/app.d.ts +42 -7
- package/types/app.d.ts.map +1 -1
- package/types/app.js +1 -1
- package/types/app.js.map +1 -1
- package/types/app.mjs +1 -1
- package/types/app.mjs.map +1 -1
- package/types/client-manager.d.ts +2 -0
- package/types/client-manager.d.ts.map +1 -1
- package/types/client-manager.js +4 -0
- package/types/client-manager.js.map +1 -1
- package/types/client-manager.mjs +4 -0
- package/types/client-manager.mjs.map +1 -1
- package/types/composer.d.ts +150 -39
- package/types/composer.d.ts.map +1 -1
- package/types/composer.js +218 -62
- package/types/composer.js.map +1 -1
- package/types/composer.mjs +218 -62
- package/types/composer.mjs.map +1 -1
- package/types/expand.d.ts +8 -0
- package/types/expand.d.ts.map +1 -0
- package/types/expand.js +3 -0
- package/types/expand.js.map +1 -0
- package/types/expand.mjs +2 -0
- package/types/expand.mjs.map +1 -0
- package/types/transaction.d.ts +3 -0
- package/types/transaction.d.ts.map +1 -1
package/app.js
CHANGED
|
@@ -1,199 +1,79 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var algosdk = require('algosdk');
|
|
4
|
-
var
|
|
5
|
-
var config = require('./config.js');
|
|
4
|
+
var legacyBridge = require('./transaction/legacy-bridge.js');
|
|
6
5
|
var transaction = require('./transaction/transaction.js');
|
|
7
|
-
var
|
|
6
|
+
var types_appManager = require('./types/app-manager.js');
|
|
8
7
|
var util = require('./util.js');
|
|
9
8
|
|
|
10
9
|
var ABIMethod = algosdk.ABIMethod;
|
|
11
|
-
var AtomicTransactionComposer = algosdk.AtomicTransactionComposer;
|
|
12
10
|
var modelsv2 = algosdk.modelsv2;
|
|
13
11
|
var OnApplicationComplete = algosdk.OnApplicationComplete;
|
|
14
|
-
var SourceMap = algosdk.SourceMap;
|
|
15
12
|
/**
|
|
13
|
+
* @deprecated Use `algorand.send.appCreate()` / `algorand.transactions.appCreate()` / `algorand.send.appCreateMethodCall()`
|
|
14
|
+
* / `algorand.transactions.appCreateMethodCall()` instead
|
|
15
|
+
*
|
|
16
16
|
* Creates a smart contract app, returns the details of the created app.
|
|
17
17
|
* @param create The parameters to create the app with
|
|
18
18
|
* @param algod An algod client
|
|
19
19
|
* @returns The details of the created app, or the transaction to create it if `skipSending` and the compilation result
|
|
20
20
|
*/
|
|
21
21
|
async function createApp(create, algod) {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const compiledClear = typeof clear === 'string' ? await compileTeal(clear, algod) : undefined;
|
|
26
|
-
const clearProgram = compiledClear ? compiledClear.compiledBase64ToBytes : clear;
|
|
27
|
-
if (args && args.method) {
|
|
28
|
-
const atc = attachATC(sendParams);
|
|
29
|
-
const before = transaction.getAtomicTransactionComposerTransactions(atc);
|
|
30
|
-
atc.addMethodCall({
|
|
31
|
-
appID: 0,
|
|
32
|
-
approvalProgram: approvalProgram,
|
|
33
|
-
clearProgram: clearProgram,
|
|
34
|
-
numLocalInts: schema.localInts,
|
|
35
|
-
numLocalByteSlices: schema.localByteSlices,
|
|
36
|
-
numGlobalInts: schema.globalInts,
|
|
37
|
-
numGlobalByteSlices: schema.globalByteSlices,
|
|
38
|
-
extraPages: schema.extraPages ?? Math.floor((approvalProgram.length + clearProgram.length) / types_app.APP_PAGE_MAX_SIZE),
|
|
39
|
-
onComplete: getAppOnCompleteAction(onCompleteAction),
|
|
40
|
-
suggestedParams: transaction.controlFees(await transaction.getTransactionParams(transactionParams, algod), sendParams),
|
|
41
|
-
note: transaction.encodeTransactionNote(note),
|
|
42
|
-
...(await getAppArgsForABICall(args, from)),
|
|
43
|
-
});
|
|
44
|
-
if (sendParams.skipSending) {
|
|
45
|
-
const after = atc.clone().buildGroup();
|
|
46
|
-
return {
|
|
47
|
-
transaction: after[after.length - 1].txn,
|
|
48
|
-
transactions: after.slice(before.length).map((t) => t.txn),
|
|
49
|
-
appId: 0,
|
|
50
|
-
appAddress: '',
|
|
51
|
-
compiledApproval,
|
|
52
|
-
compiledClear,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
const result = await transaction.sendAtomicTransactionComposer({ atc, sendParams }, algod);
|
|
56
|
-
const confirmation = result.confirmations ? result.confirmations[result.confirmations?.length - 1] : undefined;
|
|
57
|
-
if (confirmation) {
|
|
58
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
59
|
-
const appId = confirmation.applicationIndex;
|
|
60
|
-
config.Config.getLogger(sendParams.suppressLog).debug(`Created app ${appId} from creator ${transaction.getSenderAddress(from)}`);
|
|
61
|
-
return {
|
|
62
|
-
transactions: result.transactions,
|
|
63
|
-
confirmations: result.confirmations,
|
|
64
|
-
return: confirmation ? getABIReturn(args, confirmation) : undefined,
|
|
65
|
-
transaction: result.transactions[result.transactions.length - 1],
|
|
66
|
-
confirmation: confirmation,
|
|
67
|
-
appId,
|
|
68
|
-
appAddress: algosdk.getApplicationAddress(appId),
|
|
69
|
-
compiledApproval,
|
|
70
|
-
compiledClear,
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
return {
|
|
75
|
-
transactions: result.transactions,
|
|
76
|
-
confirmations: result.confirmations,
|
|
77
|
-
return: confirmation ? getABIReturn(args, confirmation) : undefined,
|
|
78
|
-
transaction: result.transactions[result.transactions.length - 1],
|
|
79
|
-
confirmation: confirmation,
|
|
80
|
-
appId: 0,
|
|
81
|
-
appAddress: '',
|
|
82
|
-
compiledApproval,
|
|
83
|
-
compiledClear,
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
const transaction$1 = algosdk.makeApplicationCreateTxnFromObject({
|
|
89
|
-
approvalProgram: approvalProgram,
|
|
90
|
-
clearProgram: clearProgram,
|
|
91
|
-
numLocalInts: schema.localInts,
|
|
92
|
-
numLocalByteSlices: schema.localByteSlices,
|
|
93
|
-
numGlobalInts: schema.globalInts,
|
|
94
|
-
numGlobalByteSlices: schema.globalByteSlices,
|
|
95
|
-
extraPages: schema.extraPages ?? Math.floor((approvalProgram.length + clearProgram.length) / types_app.APP_PAGE_MAX_SIZE),
|
|
96
|
-
onComplete: getAppOnCompleteAction(onCompleteAction),
|
|
97
|
-
suggestedParams: await transaction.getTransactionParams(transactionParams, algod),
|
|
98
|
-
from: transaction.getSenderAddress(from),
|
|
99
|
-
note: transaction.encodeTransactionNote(note),
|
|
100
|
-
...getAppArgsForTransaction(args),
|
|
101
|
-
rekeyTo: args?.rekeyTo ? (typeof args.rekeyTo === 'string' ? args.rekeyTo : transaction.getSenderAddress(args.rekeyTo)) : undefined,
|
|
102
|
-
});
|
|
103
|
-
const { confirmation } = await transaction.sendTransaction({ transaction: transaction$1, from, sendParams }, algod);
|
|
104
|
-
if (confirmation) {
|
|
105
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
106
|
-
const appId = confirmation.applicationIndex;
|
|
107
|
-
config.Config.getLogger(sendParams.suppressLog).debug(`Created app ${appId} from creator ${transaction.getSenderAddress(from)}`);
|
|
108
|
-
return {
|
|
109
|
-
transaction: transaction$1,
|
|
110
|
-
transactions: [transaction$1],
|
|
111
|
-
confirmation,
|
|
112
|
-
confirmations: confirmation ? [confirmation] : undefined,
|
|
113
|
-
appId,
|
|
114
|
-
appAddress: algosdk.getApplicationAddress(appId),
|
|
115
|
-
return: getABIReturn(args, confirmation),
|
|
116
|
-
compiledApproval,
|
|
117
|
-
compiledClear,
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
return { transaction: transaction$1, transactions: [transaction$1], appId: 0, appAddress: '', compiledApproval, compiledClear };
|
|
122
|
-
}
|
|
22
|
+
const onComplete = getAppOnCompleteAction(create.onCompleteAction);
|
|
23
|
+
if (onComplete === algosdk.OnApplicationComplete.ClearStateOC) {
|
|
24
|
+
throw new Error('Cannot create an app with on-complete action of ClearState');
|
|
123
25
|
}
|
|
26
|
+
const result = create.args?.method
|
|
27
|
+
? await legacyBridge.legacySendAppTransactionBridge(algod, create.from, create.args, create, {
|
|
28
|
+
sender: transaction.getSenderAddress(create.from),
|
|
29
|
+
onComplete,
|
|
30
|
+
approvalProgram: create.approvalProgram,
|
|
31
|
+
clearStateProgram: create.clearStateProgram,
|
|
32
|
+
method: create.args.method instanceof ABIMethod ? create.args.method : new ABIMethod(create.args.method),
|
|
33
|
+
extraProgramPages: create.schema.extraPages,
|
|
34
|
+
schema: create.schema,
|
|
35
|
+
}, (c) => c.appCreateMethodCall, (c) => c.appCreateMethodCall)
|
|
36
|
+
: await legacyBridge.legacySendAppTransactionBridge(algod, create.from, create.args, create, {
|
|
37
|
+
sender: transaction.getSenderAddress(create.from),
|
|
38
|
+
onComplete,
|
|
39
|
+
approvalProgram: create.approvalProgram,
|
|
40
|
+
clearStateProgram: create.clearStateProgram,
|
|
41
|
+
extraProgramPages: create.schema.extraPages,
|
|
42
|
+
schema: create.schema,
|
|
43
|
+
}, (c) => c.appCreate, (c) => c.appCreate);
|
|
44
|
+
return { ...result, appId: 'appId' in result ? Number(result.appId) : 0, appAddress: 'appAddress' in result ? result.appAddress : '' };
|
|
124
45
|
}
|
|
125
46
|
/**
|
|
47
|
+
* @deprecated Use `algorand.send.appUpdate()` / `algorand.transactions.appUpdate()` / `algorand.send.appUpdateMethodCall()`
|
|
48
|
+
* / `algorand.transactions.appUpdateMethodCall()` instead
|
|
49
|
+
*
|
|
126
50
|
* Updates a smart contract app.
|
|
127
51
|
* @param update The parameters to update the app with
|
|
128
52
|
* @param algod An algod client
|
|
129
53
|
* @returns The transaction send result and the compilation result
|
|
130
54
|
*/
|
|
131
55
|
async function updateApp(update, algod) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
...(await getAppArgsForABICall(args, from)),
|
|
149
|
-
});
|
|
150
|
-
if (sendParams.skipSending) {
|
|
151
|
-
const after = atc.clone().buildGroup();
|
|
152
|
-
return {
|
|
153
|
-
transaction: after[after.length - 1].txn,
|
|
154
|
-
transactions: after.slice(before.length).map((t) => t.txn),
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
const result = await transaction.sendAtomicTransactionComposer({ atc, sendParams }, algod);
|
|
158
|
-
const confirmation = result.confirmations ? result.confirmations[result.confirmations?.length - 1] : undefined;
|
|
159
|
-
return {
|
|
160
|
-
transactions: result.transactions,
|
|
161
|
-
confirmations: result.confirmations,
|
|
162
|
-
return: confirmation ? getABIReturn(args, confirmation) : undefined,
|
|
163
|
-
transaction: result.transactions[result.transactions.length - 1],
|
|
164
|
-
confirmation: confirmation,
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
const transaction$1 = algosdk.makeApplicationUpdateTxnFromObject({
|
|
169
|
-
appIndex: util.toNumber(appId),
|
|
170
|
-
approvalProgram: approvalProgram,
|
|
171
|
-
clearProgram: clearProgram,
|
|
172
|
-
suggestedParams: await transaction.getTransactionParams(transactionParams, algod),
|
|
173
|
-
from: transaction.getSenderAddress(from),
|
|
174
|
-
note: transaction.encodeTransactionNote(note),
|
|
175
|
-
...getAppArgsForTransaction(args),
|
|
176
|
-
rekeyTo: args?.rekeyTo ? (typeof args.rekeyTo === 'string' ? args.rekeyTo : transaction.getSenderAddress(args.rekeyTo)) : undefined,
|
|
177
|
-
});
|
|
178
|
-
const result = await transaction.sendTransaction({ transaction: transaction$1, from, sendParams }, algod);
|
|
179
|
-
return {
|
|
180
|
-
...result,
|
|
181
|
-
transactions: [result.transaction],
|
|
182
|
-
confirmations: result.confirmation ? [result.confirmation] : undefined,
|
|
183
|
-
return: getABIReturn(args, result.confirmation),
|
|
184
|
-
compiledApproval,
|
|
185
|
-
compiledClear,
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
function attachATC(sendParams) {
|
|
190
|
-
if (sendParams.atc) {
|
|
191
|
-
sendParams.skipSending = true;
|
|
192
|
-
}
|
|
193
|
-
sendParams.atc = sendParams.atc ?? new AtomicTransactionComposer();
|
|
194
|
-
return sendParams.atc;
|
|
56
|
+
return update.args?.method
|
|
57
|
+
? await legacyBridge.legacySendAppTransactionBridge(algod, update.from, update.args, update, {
|
|
58
|
+
appId: BigInt(update.appId),
|
|
59
|
+
sender: transaction.getSenderAddress(update.from),
|
|
60
|
+
onComplete: algosdk.OnApplicationComplete.UpdateApplicationOC,
|
|
61
|
+
approvalProgram: update.approvalProgram,
|
|
62
|
+
clearStateProgram: update.clearStateProgram,
|
|
63
|
+
method: update.args.method instanceof ABIMethod ? update.args.method : new ABIMethod(update.args.method),
|
|
64
|
+
}, (c) => c.appUpdateMethodCall, (c) => c.appUpdateMethodCall)
|
|
65
|
+
: await legacyBridge.legacySendAppTransactionBridge(algod, update.from, update.args, update, {
|
|
66
|
+
appId: BigInt(update.appId),
|
|
67
|
+
sender: transaction.getSenderAddress(update.from),
|
|
68
|
+
onComplete: algosdk.OnApplicationComplete.UpdateApplicationOC,
|
|
69
|
+
approvalProgram: update.approvalProgram,
|
|
70
|
+
clearStateProgram: update.clearStateProgram,
|
|
71
|
+
}, (c) => c.appUpdate, (c) => c.appUpdate);
|
|
195
72
|
}
|
|
196
|
-
/**
|
|
73
|
+
/**
|
|
74
|
+
* @deprecated Use `algosdk.OnApplicationComplete` directly instead.
|
|
75
|
+
*
|
|
76
|
+
* Returns a `algosdk.OnApplicationComplete` for the given onCompleteAction.
|
|
197
77
|
*
|
|
198
78
|
* If given `undefined` will return `OnApplicationComplete.NoOpOC`.
|
|
199
79
|
*
|
|
@@ -226,77 +106,35 @@ function getAppOnCompleteAction(onCompletionAction) {
|
|
|
226
106
|
}
|
|
227
107
|
}
|
|
228
108
|
/**
|
|
109
|
+
* @deprecated Use `algorand.send.appUpdate()` / `algorand.transactions.appUpdate()` / `algorand.send.appUpdateMethodCall()`
|
|
110
|
+
* / `algorand.transactions.appUpdateMethodCall()` instead
|
|
111
|
+
*
|
|
229
112
|
* Issues a call to a given app.
|
|
230
113
|
* @param call The call details.
|
|
231
114
|
* @param algod An algod client
|
|
232
115
|
* @returns The result of the call
|
|
233
116
|
*/
|
|
234
117
|
async function callApp(call, algod) {
|
|
235
|
-
const
|
|
236
|
-
if (
|
|
237
|
-
|
|
238
|
-
const before = transaction.getAtomicTransactionComposerTransactions(atc);
|
|
239
|
-
atc.addMethodCall({
|
|
240
|
-
appID: util.toNumber(appId),
|
|
241
|
-
suggestedParams: transaction.controlFees(await transaction.getTransactionParams(transactionParams, algod), sendParams),
|
|
242
|
-
note: transaction.encodeTransactionNote(note),
|
|
243
|
-
onComplete: getAppOnCompleteAction(callType),
|
|
244
|
-
...(await getAppArgsForABICall(args, from)),
|
|
245
|
-
});
|
|
246
|
-
if (sendParams.skipSending) {
|
|
247
|
-
const after = atc.clone().buildGroup();
|
|
248
|
-
return {
|
|
249
|
-
transaction: after[after.length - 1].txn,
|
|
250
|
-
transactions: after.slice(before.length).map((t) => t.txn),
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
const result = await transaction.sendAtomicTransactionComposer({ atc, sendParams }, algod);
|
|
254
|
-
const confirmation = result.confirmations ? result.confirmations[result.confirmations?.length - 1] : undefined;
|
|
255
|
-
return {
|
|
256
|
-
transactions: result.transactions,
|
|
257
|
-
confirmations: result.confirmations,
|
|
258
|
-
return: confirmation ? getABIReturn(args, confirmation) : undefined,
|
|
259
|
-
transaction: result.transactions[result.transactions.length - 1],
|
|
260
|
-
confirmation: confirmation,
|
|
261
|
-
};
|
|
118
|
+
const onComplete = getAppOnCompleteAction(call.callType);
|
|
119
|
+
if (onComplete === algosdk.OnApplicationComplete.UpdateApplicationOC) {
|
|
120
|
+
throw new Error('Cannot execute an app call with on-complete action of Update');
|
|
262
121
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
break;
|
|
276
|
-
case OnApplicationComplete.ClearStateOC:
|
|
277
|
-
transaction$1 = algosdk.makeApplicationClearStateTxnFromObject(appCallParams);
|
|
278
|
-
break;
|
|
279
|
-
case OnApplicationComplete.CloseOutOC:
|
|
280
|
-
transaction$1 = algosdk.makeApplicationCloseOutTxnFromObject(appCallParams);
|
|
281
|
-
break;
|
|
282
|
-
case OnApplicationComplete.DeleteApplicationOC:
|
|
283
|
-
transaction$1 = algosdk.makeApplicationDeleteTxnFromObject(appCallParams);
|
|
284
|
-
break;
|
|
285
|
-
case OnApplicationComplete.NoOpOC:
|
|
286
|
-
transaction$1 = algosdk.makeApplicationNoOpTxnFromObject(appCallParams);
|
|
287
|
-
break;
|
|
288
|
-
default:
|
|
289
|
-
throw new Error(`Received unexpected call type ${callType}`);
|
|
290
|
-
}
|
|
291
|
-
const result = await transaction.sendTransaction({ transaction: transaction$1, from, sendParams }, algod);
|
|
292
|
-
return {
|
|
293
|
-
...result,
|
|
294
|
-
transactions: [result.transaction],
|
|
295
|
-
confirmations: result.confirmation ? [result.confirmation] : undefined,
|
|
296
|
-
return: getABIReturn(args, result.confirmation),
|
|
297
|
-
};
|
|
122
|
+
return call.args?.method
|
|
123
|
+
? await legacyBridge.legacySendAppTransactionBridge(algod, call.from, call.args, call, {
|
|
124
|
+
appId: BigInt(call.appId),
|
|
125
|
+
sender: transaction.getSenderAddress(call.from),
|
|
126
|
+
onComplete,
|
|
127
|
+
method: call.args.method instanceof ABIMethod ? call.args.method : new ABIMethod(call.args.method),
|
|
128
|
+
}, (c) => c.appCallMethodCall, (c) => c.appCallMethodCall)
|
|
129
|
+
: await legacyBridge.legacySendAppTransactionBridge(algod, call.from, call.args, call, {
|
|
130
|
+
appId: BigInt(call.appId),
|
|
131
|
+
sender: transaction.getSenderAddress(call.from),
|
|
132
|
+
onComplete,
|
|
133
|
+
}, (c) => c.appCall, (c) => c.appCall);
|
|
298
134
|
}
|
|
299
135
|
/**
|
|
136
|
+
* @deprecated Use `AppManager.getABIReturn` instead.
|
|
137
|
+
*
|
|
300
138
|
* Returns any ABI return values for the given app call arguments and transaction confirmation.
|
|
301
139
|
* @param args The arguments that were used for the call
|
|
302
140
|
* @param confirmation The transaction confirmation from algod
|
|
@@ -307,43 +145,22 @@ function getABIReturn(args, confirmation) {
|
|
|
307
145
|
return undefined;
|
|
308
146
|
}
|
|
309
147
|
const method = 'txnCount' in args.method ? args.method : new ABIMethod(args.method);
|
|
310
|
-
|
|
311
|
-
// The parseMethodResponse method mutates the second parameter :(
|
|
312
|
-
const resultDummy = {
|
|
313
|
-
txID: '',
|
|
314
|
-
method,
|
|
315
|
-
rawReturnValue: new Uint8Array(),
|
|
316
|
-
};
|
|
317
|
-
const response = AtomicTransactionComposer.parseMethodResponse(method, resultDummy, confirmation);
|
|
318
|
-
return !response.decodeError
|
|
319
|
-
? {
|
|
320
|
-
rawReturnValue: response.rawReturnValue,
|
|
321
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
322
|
-
returnValue: response.returnValue,
|
|
323
|
-
decodeError: undefined,
|
|
324
|
-
}
|
|
325
|
-
: {
|
|
326
|
-
rawReturnValue: undefined,
|
|
327
|
-
returnValue: undefined,
|
|
328
|
-
decodeError: response.decodeError,
|
|
329
|
-
};
|
|
330
|
-
}
|
|
331
|
-
return undefined;
|
|
148
|
+
return types_appManager.AppManager.getABIReturn(confirmation, method);
|
|
332
149
|
}
|
|
333
150
|
/**
|
|
151
|
+
* @deprecated Use `(await appManager.getById(appId)).globalState` instead.
|
|
152
|
+
*
|
|
334
153
|
* Returns the current global state values for the given app ID
|
|
335
154
|
* @param appId The ID of the app return global state for
|
|
336
155
|
* @param algod An algod client instance
|
|
337
156
|
* @returns The current global state
|
|
338
157
|
*/
|
|
339
158
|
async function getAppGlobalState(appId, algod) {
|
|
340
|
-
|
|
341
|
-
if (!appInfo.params || !appInfo.params.globalState) {
|
|
342
|
-
throw new Error("Couldn't find global state");
|
|
343
|
-
}
|
|
344
|
-
return decodeAppState(appInfo.params.globalState);
|
|
159
|
+
return (await new types_appManager.AppManager(algod).getById(BigInt(appId))).globalState;
|
|
345
160
|
}
|
|
346
161
|
/**
|
|
162
|
+
* @deprecated Use `algorand.app.getLocalState` instead.
|
|
163
|
+
*
|
|
347
164
|
* Returns the current global state values for the given app ID and account
|
|
348
165
|
* @param appId The ID of the app return global state for
|
|
349
166
|
* @param account Either the string address of an account or an account object for the account to get local state for the given app
|
|
@@ -351,30 +168,20 @@ async function getAppGlobalState(appId, algod) {
|
|
|
351
168
|
* @returns The current local state for the given (app, account) combination
|
|
352
169
|
*/
|
|
353
170
|
async function getAppLocalState(appId, account, algod) {
|
|
354
|
-
|
|
355
|
-
const appInfo = modelsv2.AccountApplicationResponse.from_obj_for_encoding(await algod.accountApplicationInformation(accountAddress, util.toNumber(appId)).do());
|
|
356
|
-
if (!appInfo.appLocalState?.keyValue) {
|
|
357
|
-
throw new Error("Couldn't find local state");
|
|
358
|
-
}
|
|
359
|
-
return decodeAppState(appInfo.appLocalState.keyValue);
|
|
171
|
+
return new types_appManager.AppManager(algod).getLocalState(BigInt(appId), transaction.getSenderAddress(account));
|
|
360
172
|
}
|
|
361
173
|
/**
|
|
174
|
+
* @deprecated Use `algorand.app.getBoxNames` instead.
|
|
362
175
|
* Returns the names of the boxes for the given app.
|
|
363
176
|
* @param appId The ID of the app return box names for
|
|
364
177
|
* @param algod An algod client instance
|
|
365
178
|
* @returns The current box names
|
|
366
179
|
*/
|
|
367
180
|
async function getAppBoxNames(appId, algod) {
|
|
368
|
-
|
|
369
|
-
return boxResult.boxes.map((b) => {
|
|
370
|
-
return {
|
|
371
|
-
nameRaw: b.name,
|
|
372
|
-
nameBase64: buffer.Buffer.from(b.name).toString('base64'),
|
|
373
|
-
name: buffer.Buffer.from(b.name).toString('utf-8'),
|
|
374
|
-
};
|
|
375
|
-
});
|
|
181
|
+
return new types_appManager.AppManager(algod).getBoxNames(BigInt(appId));
|
|
376
182
|
}
|
|
377
183
|
/**
|
|
184
|
+
* @deprecated Use `algorand.app.getBoxValue` instead.
|
|
378
185
|
* Returns the value of the given box name for the given app.
|
|
379
186
|
* @param appId The ID of the app return box names for
|
|
380
187
|
* @param boxName The name of the box to return either as a string, binary array or `BoxName`
|
|
@@ -382,11 +189,10 @@ async function getAppBoxNames(appId, algod) {
|
|
|
382
189
|
* @returns The current box value as a byte array
|
|
383
190
|
*/
|
|
384
191
|
async function getAppBoxValue(appId, boxName, algod) {
|
|
385
|
-
|
|
386
|
-
const boxResult = await algod.getApplicationBoxByName(util.toNumber(appId), name).do();
|
|
387
|
-
return boxResult.value;
|
|
192
|
+
return new types_appManager.AppManager(algod).getBoxValue(BigInt(appId), typeof boxName !== 'string' && 'name' in boxName ? boxName.nameRaw : boxName);
|
|
388
193
|
}
|
|
389
194
|
/**
|
|
195
|
+
* @deprecated Use `algorand.app.getBoxValues` instead.
|
|
390
196
|
* Returns the value of the given box names for the given app.
|
|
391
197
|
* @param appId The ID of the app return box names for
|
|
392
198
|
* @param boxNames The names of the boxes to return either as a string, binary array or `BoxName`
|
|
@@ -394,74 +200,50 @@ async function getAppBoxValue(appId, boxName, algod) {
|
|
|
394
200
|
* @returns The current box values as a byte array in the same order as the passed in box names
|
|
395
201
|
*/
|
|
396
202
|
async function getAppBoxValues(appId, boxNames, algod) {
|
|
397
|
-
return
|
|
203
|
+
return new types_appManager.AppManager(algod).getBoxValues(BigInt(appId), boxNames.map((b) => (typeof b !== 'string' && 'name' in b ? b.nameRaw : b)));
|
|
398
204
|
}
|
|
399
205
|
/**
|
|
206
|
+
* @deprecated Use `algorand.app.getBoxValueFromABIType` instead.
|
|
400
207
|
* Returns the value of the given box name for the given app decoded based on the given ABI type.
|
|
401
208
|
* @param request The parameters for the box value request
|
|
402
209
|
* @param algod An algod client instance
|
|
403
210
|
* @returns The current box value as an ABI value
|
|
404
211
|
*/
|
|
405
212
|
async function getAppBoxValueFromABIType(request, algod) {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
213
|
+
return new types_appManager.AppManager(algod).getBoxValueFromABIType({
|
|
214
|
+
appId: BigInt(request.appId),
|
|
215
|
+
boxName: typeof request.boxName !== 'string' && 'name' in request.boxName ? request.boxName.nameRaw : request.boxName,
|
|
216
|
+
type: request.type,
|
|
217
|
+
});
|
|
409
218
|
}
|
|
410
219
|
/**
|
|
220
|
+
* @deprecated Use `algorand.app.getBoxValuesFromABIType` instead.
|
|
411
221
|
* Returns the value of the given box names for the given app decoded based on the given ABI type.
|
|
412
222
|
* @param request The parameters for the box value request
|
|
413
223
|
* @param algod An algod client instance
|
|
414
224
|
* @returns The current box values as an ABI value in the same order as the passed in box names
|
|
415
225
|
*/
|
|
416
226
|
async function getAppBoxValuesFromABIType(request, algod) {
|
|
417
|
-
|
|
418
|
-
|
|
227
|
+
return new types_appManager.AppManager(algod).getBoxValuesFromABIType({
|
|
228
|
+
appId: BigInt(request.appId),
|
|
229
|
+
boxNames: request.boxNames.map((b) => (typeof b !== 'string' && 'name' in b ? b.nameRaw : b)),
|
|
230
|
+
type: request.type,
|
|
231
|
+
});
|
|
419
232
|
}
|
|
420
233
|
/**
|
|
234
|
+
* @deprecated Use `AppManager.decodeAppState` instead.
|
|
235
|
+
*
|
|
421
236
|
* Converts an array of global/local state values from the algod api to a more friendly
|
|
422
237
|
* generic object keyed by the UTF-8 value of the key.
|
|
423
238
|
* @param state A `global-state`, `local-state`, `global-state-deltas` or `local-state-deltas`
|
|
424
239
|
* @returns An object keyeed by the UTF-8 representation of the key with various parsings of the values
|
|
425
240
|
*/
|
|
426
241
|
function decodeAppState(state) {
|
|
427
|
-
|
|
428
|
-
// Start with empty set
|
|
429
|
-
for (const stateVal of state) {
|
|
430
|
-
const keyBase64 = stateVal.key;
|
|
431
|
-
const keyRaw = buffer.Buffer.from(keyBase64, 'base64');
|
|
432
|
-
const key = keyRaw.toString('utf-8');
|
|
433
|
-
const tealValue = stateVal.value;
|
|
434
|
-
const dataTypeFlag = 'action' in tealValue ? tealValue.action : tealValue.type;
|
|
435
|
-
let valueBase64;
|
|
436
|
-
let valueRaw;
|
|
437
|
-
switch (dataTypeFlag) {
|
|
438
|
-
case 1:
|
|
439
|
-
valueBase64 = tealValue.bytes ?? '';
|
|
440
|
-
valueRaw = buffer.Buffer.from(valueBase64, 'base64');
|
|
441
|
-
stateValues[key] = {
|
|
442
|
-
keyRaw,
|
|
443
|
-
keyBase64,
|
|
444
|
-
valueRaw: new Uint8Array(valueRaw),
|
|
445
|
-
valueBase64: valueBase64,
|
|
446
|
-
value: valueRaw.toString('utf-8'),
|
|
447
|
-
};
|
|
448
|
-
break;
|
|
449
|
-
case 2: {
|
|
450
|
-
const value = tealValue.uint ?? 0;
|
|
451
|
-
stateValues[key] = {
|
|
452
|
-
keyRaw,
|
|
453
|
-
keyBase64,
|
|
454
|
-
value,
|
|
455
|
-
};
|
|
456
|
-
break;
|
|
457
|
-
}
|
|
458
|
-
default:
|
|
459
|
-
throw new Error(`Received unknown state data type of ${dataTypeFlag}`);
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
return stateValues;
|
|
242
|
+
return types_appManager.AppManager.decodeAppState(state);
|
|
463
243
|
}
|
|
464
244
|
/**
|
|
245
|
+
* @deprecated Use `AlgoKitComposer` methods to construct transactions instead.
|
|
246
|
+
*
|
|
465
247
|
* Returns the app args ready to load onto an app `Transaction` object
|
|
466
248
|
* @param args The app call args
|
|
467
249
|
* @returns The args ready to load into a `Transaction`
|
|
@@ -480,68 +262,32 @@ function getAppArgsForTransaction(args) {
|
|
|
480
262
|
};
|
|
481
263
|
}
|
|
482
264
|
/**
|
|
265
|
+
* @deprecated Use `AlgoKitComposer` methods to construct transactions instead.
|
|
266
|
+
*
|
|
483
267
|
* Returns the app args ready to load onto an ABI method call in `AtomicTransactionComposer`
|
|
484
268
|
* @param args The ABI app call args
|
|
485
269
|
* @param from The transaction signer
|
|
486
270
|
* @returns The parameters ready to pass into `addMethodCall` within AtomicTransactionComposer
|
|
487
271
|
*/
|
|
488
272
|
async function getAppArgsForABICall(args, from) {
|
|
489
|
-
|
|
490
|
-
const methodArgs = await Promise.all(('methodArgs' in args ? args.methodArgs : args)?.map(async (a, index) => {
|
|
491
|
-
if (a === undefined) {
|
|
492
|
-
throw new Error(`Argument at position ${index} does not have a value`);
|
|
493
|
-
}
|
|
494
|
-
if (typeof a !== 'object') {
|
|
495
|
-
return a;
|
|
496
|
-
}
|
|
497
|
-
// Handle the various forms of transactions to wrangle them for ATC
|
|
498
|
-
return 'txn' in a
|
|
499
|
-
? a
|
|
500
|
-
: a instanceof Promise
|
|
501
|
-
? { txn: (await a).transaction, signer }
|
|
502
|
-
: 'transaction' in a
|
|
503
|
-
? { txn: a.transaction, signer: 'signer' in a ? transaction.getSenderTransactionSigner(a.signer) : signer }
|
|
504
|
-
: 'txID' in a
|
|
505
|
-
? { txn: a, signer }
|
|
506
|
-
: a;
|
|
507
|
-
}));
|
|
508
|
-
return {
|
|
509
|
-
method: 'txnCount' in args.method ? args.method : new ABIMethod(args.method),
|
|
510
|
-
sender: transaction.getSenderAddress(from),
|
|
511
|
-
signer: signer,
|
|
512
|
-
boxes: args.boxes?.map(getBoxReference),
|
|
513
|
-
lease: transaction.encodeLease(args.lease),
|
|
514
|
-
appForeignApps: args.apps,
|
|
515
|
-
appForeignAssets: args.assets,
|
|
516
|
-
appAccounts: args.accounts?.map(_getAccountAddress),
|
|
517
|
-
methodArgs: methodArgs,
|
|
518
|
-
rekeyTo: args?.rekeyTo ? (typeof args.rekeyTo === 'string' ? args.rekeyTo : transaction.getSenderAddress(args.rekeyTo)) : undefined,
|
|
519
|
-
};
|
|
273
|
+
return legacyBridge._getAppArgsForABICall(args, from);
|
|
520
274
|
}
|
|
521
275
|
/**
|
|
276
|
+
* @deprecated Use `AppManager.getBoxReference()` instead.
|
|
277
|
+
*
|
|
522
278
|
* Returns a `algosdk.BoxReference` given a `BoxIdentifier` or `BoxReference`.
|
|
523
279
|
* @param box The box to return a reference for
|
|
524
280
|
* @returns The box reference ready to pass into a `Transaction`
|
|
525
281
|
*/
|
|
526
282
|
function getBoxReference(box) {
|
|
527
|
-
|
|
528
|
-
if (typeof box === 'object' && 'appIndex' in box) {
|
|
529
|
-
return box;
|
|
530
|
-
}
|
|
531
|
-
const ref = typeof box === 'object' && 'appId' in box ? box : { appId: 0, name: box };
|
|
532
|
-
return {
|
|
533
|
-
appIndex: ref.appId,
|
|
534
|
-
name: typeof ref.name === 'string'
|
|
535
|
-
? encoder.encode(ref.name)
|
|
536
|
-
: 'length' in ref.name
|
|
537
|
-
? ref.name
|
|
538
|
-
: algosdk.decodeAddress(transaction.getSenderAddress(ref.name)).publicKey,
|
|
539
|
-
};
|
|
283
|
+
return legacyBridge._getBoxReference(box);
|
|
540
284
|
}
|
|
541
285
|
function _getAccountAddress(account) {
|
|
542
286
|
return typeof account === 'string' ? account : algosdk.encodeAddress(account.publicKey);
|
|
543
287
|
}
|
|
544
288
|
/**
|
|
289
|
+
* @deprecated Use `algorand.app.getById` instead.
|
|
290
|
+
*
|
|
545
291
|
* Gets the current data for the given app from algod.
|
|
546
292
|
*
|
|
547
293
|
* @param appId The id of the app
|
|
@@ -552,6 +298,8 @@ async function getAppById(appId, algod) {
|
|
|
552
298
|
return modelsv2.Application.from_obj_for_encoding(await algod.getApplicationByID(util.toNumber(appId)).do());
|
|
553
299
|
}
|
|
554
300
|
/**
|
|
301
|
+
* @deprecated Use `algorand.app.compileTeal` instead.
|
|
302
|
+
*
|
|
555
303
|
* Compiles the given TEAL using algod and returns the result, including source map.
|
|
556
304
|
*
|
|
557
305
|
* @param algod An algod client
|
|
@@ -559,16 +307,11 @@ async function getAppById(appId, algod) {
|
|
|
559
307
|
* @returns The information about the compiled file
|
|
560
308
|
*/
|
|
561
309
|
async function compileTeal(tealCode, algod) {
|
|
562
|
-
|
|
563
|
-
return {
|
|
564
|
-
teal: tealCode,
|
|
565
|
-
compiled: compiled.result,
|
|
566
|
-
compiledHash: compiled.hash,
|
|
567
|
-
compiledBase64ToBytes: new Uint8Array(buffer.Buffer.from(compiled.result, 'base64')),
|
|
568
|
-
sourceMap: new SourceMap(compiled['sourcemap']),
|
|
569
|
-
};
|
|
310
|
+
return await new types_appManager.AppManager(algod).compileTeal(tealCode);
|
|
570
311
|
}
|
|
571
312
|
/**
|
|
313
|
+
* @deprecated Use `abiMethod.getSignature()` or `new ABIMethod(abiMethodParams).getSignature()` instead.
|
|
314
|
+
*
|
|
572
315
|
* Returns the encoded ABI spec for a given ABI Method
|
|
573
316
|
* @param method The method to return a signature for
|
|
574
317
|
* @returns The encoded ABI method spec e.g. `method_name(uint64,string)string`
|