@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/application-client.js
CHANGED
|
@@ -1,258 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
this.algod = algod;
|
|
37
|
-
this.indexer = indexer;
|
|
38
|
-
this.appSpec = typeof app == 'string' ? JSON.parse(app) : app;
|
|
39
|
-
if ('creatorAddress' in appIdentifier) {
|
|
40
|
-
this._creator = appIdentifier.creatorAddress;
|
|
41
|
-
if (appIdentifier.existingDeployments && appIdentifier.existingDeployments.creator !== this._creator) {
|
|
42
|
-
throw new Error(`Attempt to create application client with invalid existingDeployments against a different creator (${appIdentifier.existingDeployments.creator}) instead of expected creator ${this._creator}`);
|
|
43
|
-
}
|
|
44
|
-
this.existingDeployments = appIdentifier.existingDeployments;
|
|
45
|
-
this._appIndex = 0;
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
if (appIdentifier.index < 0) {
|
|
49
|
-
throw new Error(`Attempt to create application client with invalid app index of ${appIdentifier.index}`);
|
|
50
|
-
}
|
|
51
|
-
this._appIndex = appIdentifier.index;
|
|
52
|
-
}
|
|
53
|
-
this._appAddress = algosdk_1.default.getApplicationAddress(this._appIndex);
|
|
54
|
-
this.sender = sender;
|
|
55
|
-
this.params = params;
|
|
56
|
-
// todo: find create, update, delete, etc. methods from app spec
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Idempotently deploy (create, update/delete if changed) an app against the given name via the given creator account, including deploy-time template placeholder substitutions.
|
|
60
|
-
*
|
|
61
|
-
* To understand the architecture decisions behind this functionality please @see https://github.com/algorandfoundation/algokit-cli/blob/main/docs/architecture-decisions/2023-01-12_smart-contract-deployment.md
|
|
62
|
-
*
|
|
63
|
-
* **Note:** if there is a breaking state schema change to an existing app (and `onSchemaBreak` is set to `'replace'`) the existing app will be deleted and re-created.
|
|
64
|
-
*
|
|
65
|
-
* **Note:** if there is an update (different TEAL code) to an existing app (and `onUpdate` is set to `'replace'`) the existing app will be deleted and re-created.
|
|
66
|
-
* @param deploy Deployment details
|
|
67
|
-
* @returns The metadata and transaction result(s) of the deployment, or just the metadata if it didn't need to issue transactions
|
|
68
|
-
*/
|
|
69
|
-
async deploy(deploy) {
|
|
70
|
-
const { sender, version, allowUpdate, allowDelete, sendParams, ...deployArgs } = deploy;
|
|
71
|
-
if (this._appIndex !== 0) {
|
|
72
|
-
throw new Error(`Attempt to deploy app which already has an app index of ${this._appIndex}`);
|
|
73
|
-
}
|
|
74
|
-
if (!sender && !this.sender) {
|
|
75
|
-
throw new Error('No sender provided, unable to deploy app');
|
|
76
|
-
}
|
|
77
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
78
|
-
const from = sender ?? this.sender;
|
|
79
|
-
if (!this._creator) {
|
|
80
|
-
throw new Error('Attempt to deploy a contract without having specified a creator');
|
|
81
|
-
}
|
|
82
|
-
if (this._creator !== (0, transaction_1.getSenderAddress)(from)) {
|
|
83
|
-
throw new Error(`Attempt to deploy contract with a sender address (${(0, transaction_1.getSenderAddress)(from)}) that differs from the given creator address for this application client: ${this._creator}`);
|
|
84
|
-
}
|
|
85
|
-
const approval = buffer_1.Buffer.from(this.appSpec.source.approval, 'base64').toString('utf-8');
|
|
86
|
-
const clear = buffer_1.Buffer.from(this.appSpec.source.clear, 'base64').toString('utf-8');
|
|
87
|
-
await this.loadAppReference();
|
|
88
|
-
const result = await (0, deploy_app_1.deployApp)({
|
|
89
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
90
|
-
from,
|
|
91
|
-
approvalProgram: approval,
|
|
92
|
-
clearStateProgram: clear,
|
|
93
|
-
metadata: {
|
|
94
|
-
name: this.appSpec.contract.name,
|
|
95
|
-
version: version,
|
|
96
|
-
updatable: allowUpdate ??
|
|
97
|
-
((!this.appSpec.bare_call_config.update_application && this.appSpec.bare_call_config.update_application !== 'NEVER') ||
|
|
98
|
-
!!Object.keys(this.appSpec.hints).filter((h) => !this.appSpec.hints[h].call_config.update_application && this.appSpec.hints[h].call_config.update_application !== 'NEVER')[0]),
|
|
99
|
-
deletable: allowDelete ??
|
|
100
|
-
((!this.appSpec.bare_call_config.delete_application && this.appSpec.bare_call_config.delete_application !== 'NEVER') ||
|
|
101
|
-
!!Object.keys(this.appSpec.hints).filter((h) => !this.appSpec.hints[h].call_config.delete_application && this.appSpec.hints[h].call_config.delete_application !== 'NEVER')[0]),
|
|
102
|
-
},
|
|
103
|
-
schema: {
|
|
104
|
-
globalByteSlices: this.appSpec.state.global.num_byte_slices,
|
|
105
|
-
globalInts: this.appSpec.state.global.num_uints,
|
|
106
|
-
localByteSlices: this.appSpec.state.local.num_byte_slices,
|
|
107
|
-
localInts: this.appSpec.state.local.num_uints,
|
|
108
|
-
},
|
|
109
|
-
transactionParams: this.params,
|
|
110
|
-
...(sendParams ?? {}),
|
|
111
|
-
...deployArgs,
|
|
112
|
-
existingDeployments: this.existingDeployments,
|
|
113
|
-
}, this.algod, this.indexer);
|
|
114
|
-
// Nothing needed to happen
|
|
115
|
-
if (!('transaction' in result)) {
|
|
116
|
-
return result;
|
|
117
|
-
}
|
|
118
|
-
if (!this.existingDeployments) {
|
|
119
|
-
throw new Error('Expected existingDeployments to be present');
|
|
120
|
-
}
|
|
121
|
-
const { transaction, confirmation, operationPerformed, ...appMetadata } = result;
|
|
122
|
-
if ('deleteResult' in appMetadata) {
|
|
123
|
-
delete appMetadata.deleteResult;
|
|
124
|
-
}
|
|
125
|
-
this.existingDeployments = {
|
|
126
|
-
creator: this.existingDeployments.creator,
|
|
127
|
-
apps: { ...this.existingDeployments.apps, [this.appSpec.contract.name]: appMetadata },
|
|
128
|
-
};
|
|
129
|
-
return result;
|
|
130
|
-
}
|
|
131
|
-
async create(create) {
|
|
132
|
-
const { sender, args, note, sendParams, deployTimeParameters } = create ?? {};
|
|
133
|
-
// todo: Add deploy-time updatable/etc.
|
|
134
|
-
if (this._appIndex !== 0) {
|
|
135
|
-
throw new Error(`Attempt to create app which already has an app index of ${this._appIndex}`);
|
|
136
|
-
}
|
|
137
|
-
if (!sender && !this.sender) {
|
|
138
|
-
throw new Error('No sender provided, unable to create app');
|
|
139
|
-
}
|
|
140
|
-
const approval = buffer_1.Buffer.from(this.appSpec.source.approval, 'base64').toString('utf-8');
|
|
141
|
-
const clear = buffer_1.Buffer.from(this.appSpec.source.clear, 'base64').toString('utf-8');
|
|
142
|
-
const result = await (0, app_1.createApp)({
|
|
143
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
144
|
-
from: sender ?? this.sender,
|
|
145
|
-
approvalProgram: (0, deploy_app_1.performTemplateSubstitution)(approval, deployTimeParameters),
|
|
146
|
-
clearStateProgram: (0, deploy_app_1.performTemplateSubstitution)(clear, deployTimeParameters),
|
|
147
|
-
schema: {
|
|
148
|
-
globalByteSlices: this.appSpec.state.global.num_byte_slices,
|
|
149
|
-
globalInts: this.appSpec.state.global.num_uints,
|
|
150
|
-
localByteSlices: this.appSpec.state.local.num_byte_slices,
|
|
151
|
-
localInts: this.appSpec.state.local.num_uints,
|
|
152
|
-
},
|
|
153
|
-
args: args,
|
|
154
|
-
note: note,
|
|
155
|
-
transactionParams: this.params,
|
|
156
|
-
...(sendParams ?? {}),
|
|
157
|
-
}, this.algod);
|
|
158
|
-
if (result.confirmation) {
|
|
159
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
160
|
-
this._appIndex = result.confirmation['application-index'];
|
|
161
|
-
this._appAddress = (0, algosdk_1.getApplicationAddress)(this._appIndex);
|
|
162
|
-
}
|
|
163
|
-
return result;
|
|
164
|
-
}
|
|
165
|
-
async update(update) {
|
|
166
|
-
const { sender, args, note, sendParams, deployTimeParameters } = update ?? {};
|
|
167
|
-
if (this._appIndex === 0) {
|
|
168
|
-
throw new Error(`Attempt to update app which doesn't have an app index defined`);
|
|
169
|
-
}
|
|
170
|
-
if (!sender && !this.sender) {
|
|
171
|
-
throw new Error('No sender provided, unable to create app');
|
|
172
|
-
}
|
|
173
|
-
const approval = buffer_1.Buffer.from(this.appSpec.source.approval, 'base64').toString('utf-8');
|
|
174
|
-
const clear = buffer_1.Buffer.from(this.appSpec.source.clear, 'base64').toString('utf-8');
|
|
175
|
-
const result = await (0, app_1.updateApp)({
|
|
176
|
-
appIndex: this._appIndex,
|
|
177
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
178
|
-
from: sender ?? this.sender,
|
|
179
|
-
approvalProgram: (0, deploy_app_1.performTemplateSubstitution)(approval, deployTimeParameters),
|
|
180
|
-
clearStateProgram: (0, deploy_app_1.performTemplateSubstitution)(clear, deployTimeParameters),
|
|
181
|
-
args: args,
|
|
182
|
-
note: note,
|
|
183
|
-
transactionParams: this.params,
|
|
184
|
-
...(sendParams ?? {}),
|
|
185
|
-
}, this.algod);
|
|
186
|
-
return result;
|
|
187
|
-
}
|
|
188
|
-
async call(call) {
|
|
189
|
-
const { sender, callType, note, sendParams, ...args } = call;
|
|
190
|
-
if (!sender && !this.sender) {
|
|
191
|
-
throw new Error('No sender provided, unable to call app');
|
|
192
|
-
}
|
|
193
|
-
const appMetadata = await this.loadAppReference();
|
|
194
|
-
if (appMetadata.appIndex === 0) {
|
|
195
|
-
throw new Error(`Attempt to call an app that can't be found '${this.appSpec.contract.name}' for creator '${this._creator}'.`);
|
|
196
|
-
}
|
|
197
|
-
// todo: use this in create et. al. as well
|
|
198
|
-
let callArgs;
|
|
199
|
-
// ABI call
|
|
200
|
-
if ('method' in args) {
|
|
201
|
-
const abiMethod = this.getABIMethod(args.method);
|
|
202
|
-
if (!abiMethod) {
|
|
203
|
-
throw new Error(`Attempt to call ABI method ${args.method}, but it wasn't found`);
|
|
204
|
-
}
|
|
205
|
-
callArgs = {
|
|
206
|
-
method: abiMethod,
|
|
207
|
-
args: args.methodArgs,
|
|
208
|
-
lease: args.lease,
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
callArgs = args.args;
|
|
213
|
-
}
|
|
214
|
-
// todo: process ABI args as needed to make them nicer to deal with like beaker-ts???
|
|
215
|
-
// todo: support unwrapping a logic error?
|
|
216
|
-
return (0, app_1.callApp)({
|
|
217
|
-
appIndex: appMetadata.appIndex,
|
|
218
|
-
callType: callType,
|
|
219
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
220
|
-
from: sender ?? this.sender,
|
|
221
|
-
args: callArgs,
|
|
222
|
-
note: note,
|
|
223
|
-
transactionParams: this.params,
|
|
224
|
-
...(sendParams ?? {}),
|
|
225
|
-
}, this.algod);
|
|
226
|
-
}
|
|
227
|
-
getABIMethod(method) {
|
|
228
|
-
if (!method.includes('(')) {
|
|
229
|
-
const methods = this.appSpec.contract.methods.filter((m) => m.name === method);
|
|
230
|
-
if (methods.length > 1) {
|
|
231
|
-
throw new Error(`Received a call to method ${method} in contract ${this.appSpec.contract.name}, but this resolved to multiple methods; please pass in an ABI signature instead: ${methods.map(appspec_1.getABISignature).join(', ')}`);
|
|
232
|
-
}
|
|
233
|
-
return methods[0];
|
|
234
|
-
}
|
|
235
|
-
return this.appSpec.contract.methods.find((m) => (0, appspec_1.getABISignature)(m) === method);
|
|
236
|
-
}
|
|
237
|
-
async loadAppReference() {
|
|
238
|
-
if (!this.existingDeployments && this._creator) {
|
|
239
|
-
this.existingDeployments = await (0, deploy_app_1.getCreatorAppsByName)(this._creator, this.indexer);
|
|
240
|
-
}
|
|
241
|
-
if (this.existingDeployments && this._appIndex === 0) {
|
|
242
|
-
const app = this.existingDeployments.apps[this.appSpec.contract.name];
|
|
243
|
-
if (!app) {
|
|
244
|
-
return {
|
|
245
|
-
appIndex: 0,
|
|
246
|
-
appAddress: (0, algosdk_1.getApplicationAddress)(0),
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
return app;
|
|
250
|
-
}
|
|
251
|
-
return {
|
|
252
|
-
appIndex: this._appIndex,
|
|
253
|
-
appAddress: this._appAddress,
|
|
254
|
-
};
|
|
255
|
-
}
|
|
3
|
+
exports.getApplicationClient = void 0;
|
|
4
|
+
const application_client_1 = require("./types/application-client");
|
|
5
|
+
/**
|
|
6
|
+
* Create a new ApplicationClient instance
|
|
7
|
+
* @param appDetails The details of the app
|
|
8
|
+
* @param algod An algod instance
|
|
9
|
+
* @returns The application client
|
|
10
|
+
*/
|
|
11
|
+
function getApplicationClient(appDetails, algod) {
|
|
12
|
+
return new application_client_1.ApplicationClient(appDetails, algod);
|
|
256
13
|
}
|
|
257
|
-
exports.
|
|
14
|
+
exports.getApplicationClient = getApplicationClient;
|
|
258
15
|
//# sourceMappingURL=application-client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application-client.js","sourceRoot":"","sources":["../src/application-client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"application-client.js","sourceRoot":"","sources":["../src/application-client.ts"],"names":[],"mappings":";;;AACA,mEAAiF;AAEjF;;;;;GAKG;AACH,SAAgB,oBAAoB,CAAC,UAA6B,EAAE,KAAc;IAChF,OAAO,IAAI,sCAAiB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAA;AACjD,CAAC;AAFD,oDAEC"}
|
package/deploy-app.d.ts
CHANGED
|
@@ -1,105 +1,30 @@
|
|
|
1
1
|
import { Algodv2, Indexer } from 'algosdk';
|
|
2
|
-
import { AppCallArgs, AppReference, CompiledTeal, CreateAppParams } from './app';
|
|
3
|
-
import { SendTransactionFrom, SendTransactionResult } from './transaction';
|
|
4
2
|
import { ApplicationStateSchema } from './types/algod';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export declare const APP_DEPLOY_NOTE_PREFIX = "APP_DEPLOY::";
|
|
8
|
-
/**
|
|
9
|
-
* 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}.
|
|
10
|
-
*/
|
|
11
|
-
export interface AppDeployMetadata {
|
|
12
|
-
/** The unique name identifier of the app within the creator account */
|
|
13
|
-
name: string;
|
|
14
|
-
/** The version of app that is / will be deployed */
|
|
15
|
-
version: string;
|
|
16
|
-
/** Whether or not the app is deletable / permanent / unspecified */
|
|
17
|
-
deletable?: boolean;
|
|
18
|
-
/** Whether or not the app is updatable / immutable / unspecified */
|
|
19
|
-
updatable?: boolean;
|
|
20
|
-
}
|
|
21
|
-
/** The metadata that can be collected about a deployed app */
|
|
22
|
-
export interface AppMetadata extends AppReference, AppDeployMetadata {
|
|
23
|
-
/** The round the app was created */
|
|
24
|
-
createdRound: number;
|
|
25
|
-
/** The last round that the app was updated */
|
|
26
|
-
updatedRound: number;
|
|
27
|
-
/** The metadata when the app was created */
|
|
28
|
-
createdMetadata: AppDeployMetadata;
|
|
29
|
-
/** Whether or not the app is deleted */
|
|
30
|
-
deleted: boolean;
|
|
31
|
-
}
|
|
32
|
-
/** A lookup of name -> Algorand app for a creator */
|
|
33
|
-
export interface AppLookup {
|
|
34
|
-
creator: Readonly<string>;
|
|
35
|
-
apps: Readonly<{
|
|
36
|
-
[name: string]: AppMetadata;
|
|
37
|
-
}>;
|
|
38
|
-
}
|
|
39
|
-
/** Dictionary of deploy-time parameters to replace in a teal template.
|
|
40
|
-
*
|
|
41
|
-
* Note: Looks for `TMPL_{parameter}` for template replacements i.e. you can leave out the `TMPL_`.
|
|
42
|
-
*
|
|
43
|
-
*/
|
|
44
|
-
export interface TealTemplateParameters {
|
|
45
|
-
[key: string]: string | bigint | number | Uint8Array;
|
|
46
|
-
}
|
|
47
|
-
/** What action to perform when deploying an app and an update is detected in the TEAL code */
|
|
48
|
-
export declare enum OnUpdate {
|
|
49
|
-
/** Fail the deployment */
|
|
50
|
-
Fail = 0,
|
|
51
|
-
/** Update the app */
|
|
52
|
-
UpdateApp = 1,
|
|
53
|
-
/** Delete the app and create a new one in its place */
|
|
54
|
-
ReplaceApp = 2
|
|
55
|
-
}
|
|
56
|
-
/** What action to perform when deploying an app and a breaking schema change is detected */
|
|
57
|
-
export declare enum OnSchemaBreak {
|
|
58
|
-
/** Fail the deployment */
|
|
59
|
-
Fail = 0,
|
|
60
|
-
/** Delete the app and create a new one in its place */
|
|
61
|
-
ReplaceApp = 1
|
|
62
|
-
}
|
|
63
|
-
/** The parameters to deploy an app */
|
|
64
|
-
export interface AppDeploymentParams extends Omit<CreateAppParams, 'args' | 'note' | 'skipSending' | 'skipWaiting'> {
|
|
65
|
-
/** The deployment metadata */
|
|
66
|
-
metadata: AppDeployMetadata;
|
|
67
|
-
/** Any deploy-time parameters to replace in the TEAL code */
|
|
68
|
-
deployTimeParameters?: TealTemplateParameters;
|
|
69
|
-
/** What action to perform if a schema break is detected */
|
|
70
|
-
onSchemaBreak?: 'replace' | 'fail' | OnSchemaBreak;
|
|
71
|
-
/** What action to perform if a TEAL update is detected */
|
|
72
|
-
onUpdate?: 'update' | 'replace' | 'fail' | OnUpdate;
|
|
73
|
-
/** Optional cached value of the existing apps for the given creator */
|
|
74
|
-
existingDeployments?: AppLookup;
|
|
75
|
-
/** Any args to pass to any create transaction that is issued as part of deployment */
|
|
76
|
-
createArgs?: AppCallArgs;
|
|
77
|
-
/** Any args to pass to any update transaction that is issued as part of deployment */
|
|
78
|
-
updateArgs?: AppCallArgs;
|
|
79
|
-
/** Any args to pass to any delete transaction that is issued as part of deployment */
|
|
80
|
-
deleteArgs?: AppCallArgs;
|
|
81
|
-
}
|
|
3
|
+
import { AppCompilationResult, AppDeploymentParams, AppDeployMetadata, AppLookup, AppMetadata, CompiledTeal, TealTemplateParams } from './types/app';
|
|
4
|
+
import { ConfirmedTransactionResult, SendTransactionFrom } from './types/transaction';
|
|
82
5
|
/**
|
|
83
6
|
* Idempotently deploy (create, update/delete if changed) an app against the given name via the given creator account, including deploy-time template placeholder substitutions.
|
|
84
7
|
*
|
|
85
8
|
* To understand the architecture decisions behind this functionality please @see https://github.com/algorandfoundation/algokit-cli/blob/main/docs/architecture-decisions/2023-01-12_smart-contract-deployment.md
|
|
86
9
|
*
|
|
10
|
+
* **Note:** When using the return from this function be sure to check `operationPerformed` to get access to various return properties like `transaction`, `confirmation` and `deleteResult`.
|
|
11
|
+
*
|
|
87
12
|
* **Note:** if there is a breaking state schema change to an existing app (and `onSchemaBreak` is set to `'replace'`) the existing app will be deleted and re-created.
|
|
88
13
|
*
|
|
89
14
|
* **Note:** if there is an update (different TEAL code) to an existing app (and `onUpdate` is set to `'replace'`) the existing app will be deleted and re-created.
|
|
90
15
|
* @param deployment The arguments to control the app deployment
|
|
91
16
|
* @param algod An algod client
|
|
92
|
-
* @param indexer An indexer client
|
|
17
|
+
* @param indexer An indexer client, needed if `existingDeployments` not passed in
|
|
93
18
|
* @returns The app reference of the new/existing app
|
|
94
19
|
*/
|
|
95
|
-
export declare function deployApp(deployment: AppDeploymentParams, algod: Algodv2, indexer
|
|
20
|
+
export declare function deployApp(deployment: AppDeploymentParams, algod: Algodv2, indexer?: Indexer): Promise<Partial<AppCompilationResult> & ((ConfirmedTransactionResult & AppMetadata & {
|
|
96
21
|
operationPerformed: 'create' | 'update';
|
|
97
|
-
}) | (
|
|
98
|
-
deleteResult
|
|
22
|
+
}) | (ConfirmedTransactionResult & AppMetadata & {
|
|
23
|
+
deleteResult: ConfirmedTransactionResult;
|
|
99
24
|
operationPerformed: 'replace';
|
|
100
25
|
}) | (AppMetadata & {
|
|
101
|
-
operationPerformed: '
|
|
102
|
-
})>;
|
|
26
|
+
operationPerformed: 'nothing';
|
|
27
|
+
}))>;
|
|
103
28
|
/** Returns true is there is a breaking change in the application state schema from before to after.
|
|
104
29
|
* i.e. if the schema becomes larger, since applications can't ask for more schema after creation.
|
|
105
30
|
* Otherwise, there is no error, the app just doesn't store data in the extra schema :(
|
|
@@ -108,7 +33,7 @@ export declare function deployApp(deployment: AppDeploymentParams, algod: Algodv
|
|
|
108
33
|
* @param after The new schema
|
|
109
34
|
* @returns Whether or not there is a breaking change
|
|
110
35
|
*/
|
|
111
|
-
export declare function
|
|
36
|
+
export declare function isSchemaIsBroken(before: ApplicationStateSchema, after: ApplicationStateSchema): boolean;
|
|
112
37
|
/**
|
|
113
38
|
* Returns a lookup of name => app metadata (id, address, ...metadata) for all apps created by the given account that have an @see {AppDeployNote} in the transaction note of the creation transaction.
|
|
114
39
|
*
|
|
@@ -124,7 +49,11 @@ export declare function getCreatorAppsByName(creatorAccount: SendTransactionFrom
|
|
|
124
49
|
* @param metadata The metadata of the deployment
|
|
125
50
|
* @returns The transaction note as a utf-8 string
|
|
126
51
|
*/
|
|
127
|
-
export declare function getAppDeploymentTransactionNote(metadata: AppDeployMetadata):
|
|
52
|
+
export declare function getAppDeploymentTransactionNote(metadata: AppDeployMetadata): {
|
|
53
|
+
dAppName: string;
|
|
54
|
+
data: AppDeployMetadata;
|
|
55
|
+
format: string;
|
|
56
|
+
};
|
|
128
57
|
/**
|
|
129
58
|
* Replaces deploy-time deployment control parameters within the given teal code.
|
|
130
59
|
*
|
|
@@ -145,10 +74,10 @@ export declare function replaceDeployTimeControlParams(tealCode: string, params:
|
|
|
145
74
|
* Looks for `TMPL_{parameter}` for template replacements.
|
|
146
75
|
*
|
|
147
76
|
* @param tealCode The TEAL logic to compile
|
|
148
|
-
* @param
|
|
77
|
+
* @param templateParams Any parameters to replace in the .teal file before compiling
|
|
149
78
|
* @returns The TEAL code with replacements
|
|
150
79
|
*/
|
|
151
|
-
export declare function performTemplateSubstitution(tealCode: string,
|
|
80
|
+
export declare function performTemplateSubstitution(tealCode: string, templateParams?: TealTemplateParams): string;
|
|
152
81
|
/**
|
|
153
82
|
* Performs template substitution of a teal file and compiles it, returning the compiled result.
|
|
154
83
|
*
|
|
@@ -156,9 +85,9 @@ export declare function performTemplateSubstitution(tealCode: string, templatePa
|
|
|
156
85
|
*
|
|
157
86
|
* @param tealCode The TEAL logic to compile
|
|
158
87
|
* @param algod An algod client
|
|
159
|
-
* @param
|
|
88
|
+
* @param templateParams Any parameters to replace in the .teal file before compiling
|
|
160
89
|
* @param deploymentMetadata The deployment metadata the app will be deployed with
|
|
161
90
|
* @returns The information about the compiled code
|
|
162
91
|
*/
|
|
163
|
-
export declare function performTemplateSubstitutionAndCompile(tealCode: string, algod: Algodv2,
|
|
92
|
+
export declare function performTemplateSubstitutionAndCompile(tealCode: string, algod: Algodv2, templateParams?: TealTemplateParams, deploymentMetadata?: AppDeployMetadata): Promise<CompiledTeal>;
|
|
164
93
|
//# sourceMappingURL=deploy-app.d.ts.map
|
package/deploy-app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy-app.d.ts","sourceRoot":"","sources":["../src/deploy-app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAyB,OAAO,EAAmB,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"deploy-app.d.ts","sourceRoot":"","sources":["../src/deploy-app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAyB,OAAO,EAAmB,MAAM,SAAS,CAAA;AAKlF,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,SAAS,EACT,WAAW,EAEX,YAAY,EAIZ,kBAAkB,EAEnB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAErF;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,SAAS,CAC7B,UAAU,EAAE,mBAAmB,EAC/B,KAAK,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,OAAO,GAChB,OAAO,CACR,OAAO,CAAC,oBAAoB,CAAC,GAC3B,CACI,CAAC,0BAA0B,GAAG,WAAW,GAAG;IAAE,kBAAkB,EAAE,QAAQ,GAAG,QAAQ,CAAA;CAAE,CAAC,GACxF,CAAC,0BAA0B,GAAG,WAAW,GAAG;IAAE,YAAY,EAAE,0BAA0B,CAAC;IAAC,kBAAkB,EAAE,SAAS,CAAA;CAAE,CAAC,GACxH,CAAC,WAAW,GAAG;IAAE,kBAAkB,EAAE,SAAS,CAAA;CAAE,CAAC,CACpD,CACJ,CA4TA;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,sBAAsB,EAAE,KAAK,EAAE,sBAAsB,WAE7F;AAED;;;;;;;;GAQG;AACH,wBAAsB,oBAAoB,CAAC,cAAc,EAAE,mBAAmB,GAAG,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAyF7H;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAAC,QAAQ,EAAE,iBAAiB;;;;EAM1E;AAED;;;;;;;;;GASG;AACH,wBAAgB,8BAA8B,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE;IAAE,SAAS,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,UAoBpH;AAED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,kBAAkB,UAiBhG;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,qCAAqC,CACzD,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,OAAO,EACd,cAAc,CAAC,EAAE,kBAAkB,EACnC,kBAAkB,CAAC,EAAE,iBAAiB,GACrC,OAAO,CAAC,YAAY,CAAC,CAQvB"}
|