@algorandfoundation/algokit-utils 7.0.0-beta.7 → 7.0.0-beta.8
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/package.json +1 -1
- package/types/app-client.d.ts +41 -73
- package/types/app-client.js +27 -17
- package/types/app-client.js.map +1 -1
- package/types/app-client.mjs +27 -17
- package/types/app-client.mjs.map +1 -1
- package/types/app-factory.d.ts +17 -202
- package/types/app-factory.js +16 -7
- package/types/app-factory.js.map +1 -1
- package/types/app-factory.mjs +16 -7
- package/types/app-factory.mjs.map +1 -1
- package/types/app.d.ts +1 -1
- package/types/app.js.map +1 -1
- package/types/app.mjs.map +1 -1
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"**"
|
|
7
7
|
],
|
|
8
8
|
"name": "@algorandfoundation/algokit-utils",
|
|
9
|
-
"version": "7.0.0-beta.
|
|
9
|
+
"version": "7.0.0-beta.8",
|
|
10
10
|
"private": false,
|
|
11
11
|
"description": "A set of core Algorand utilities written in TypeScript and released via npm that make it easier to build solutions on Algorand.",
|
|
12
12
|
"author": "Algorand Foundation",
|
package/types/app-client.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import algosdk from 'algosdk';
|
|
2
2
|
import { AlgorandClientInterface } from './algorand-client-interface';
|
|
3
3
|
import { AlgoAmount } from './amount';
|
|
4
|
-
import { ABIAppCallArgs, ABIReturn, AppCallArgs, AppCallTransactionResult, AppCallType, AppCompilationResult, AppMetadata, AppReference, AppReturn, AppState, AppStorageSchema, BoxName, AppLookup as LegacyAppLookup, OnSchemaBreak, OnUpdate, RawAppCallArgs, SendAppTransactionResult, TealTemplateParams } from './app';
|
|
4
|
+
import { ABIAppCallArgs, ABIReturn, AppCallArgs, AppCallTransactionResult, AppCallType, AppCompilationResult, AppMetadata, AppReference, AppReturn, AppState, AppStorageSchema, BoxName, CompiledTeal, AppLookup as LegacyAppLookup, OnSchemaBreak, OnUpdate, RawAppCallArgs, SendAppTransactionResult, TealTemplateParams } from './app';
|
|
5
5
|
import { ABIStruct, Arc56Contract, Arc56Method } from './app-arc56';
|
|
6
6
|
import { AppLookup } from './app-deployer';
|
|
7
7
|
import { AppManager, BoxIdentifier } from './app-manager';
|
|
@@ -176,6 +176,19 @@ export interface SourceMapExport {
|
|
|
176
176
|
names: string[];
|
|
177
177
|
mappings: string;
|
|
178
178
|
}
|
|
179
|
+
/**
|
|
180
|
+
* The result of asking an `AppClient` to compile a program.
|
|
181
|
+
*/
|
|
182
|
+
export interface AppClientCompilationResult {
|
|
183
|
+
/** The compiled bytecode of the approval program, ready to deploy to algod */
|
|
184
|
+
approvalProgram: Uint8Array;
|
|
185
|
+
/** The compiled bytecode of the clear state program, ready to deploy to algod */
|
|
186
|
+
clearStateProgram: Uint8Array;
|
|
187
|
+
/** The result of compilation of the approval program, including source map, if TEAL code was compiled */
|
|
188
|
+
approvalProgramCompilationResult?: CompiledTeal;
|
|
189
|
+
/** The result of compilation of the clear state program, including source map, if TEAL code was compiled */
|
|
190
|
+
clearStateProgramCompilationResult?: CompiledTeal;
|
|
191
|
+
}
|
|
179
192
|
/** Parameters to create an app client */
|
|
180
193
|
export interface AppClientParams {
|
|
181
194
|
/** The ID of the app instance this client should make calls against. */
|
|
@@ -371,40 +384,15 @@ export declare class AppClient {
|
|
|
371
384
|
sender?: string | undefined;
|
|
372
385
|
method: string;
|
|
373
386
|
args?: (algosdk.ABIValue | AppMethodCallTransactionArgument | ABIStruct | undefined)[] | undefined;
|
|
374
|
-
} & AppClientCompilationParams) => Promise<
|
|
375
|
-
|
|
376
|
-
compiledApproval: undefined;
|
|
377
|
-
clearStateProgram: Uint8Array;
|
|
378
|
-
compiledClear: undefined;
|
|
379
|
-
lease?: string | Uint8Array | undefined;
|
|
380
|
-
note?: string | Uint8Array | undefined;
|
|
381
|
-
maxFee?: AlgoAmount | undefined;
|
|
382
|
-
signer?: algosdk.TransactionSigner | import("./account").TransactionSignerAccount | undefined;
|
|
383
|
-
rekeyTo?: string | undefined;
|
|
384
|
-
staticFee?: AlgoAmount | undefined;
|
|
385
|
-
extraFee?: AlgoAmount | undefined;
|
|
386
|
-
validityWindow?: number | undefined;
|
|
387
|
-
firstValidRound?: bigint | undefined;
|
|
388
|
-
lastValidRound?: bigint | undefined;
|
|
389
|
-
onComplete?: algosdk.OnApplicationComplete | undefined;
|
|
390
|
-
accountReferences?: string[] | undefined;
|
|
391
|
-
appReferences?: bigint[] | undefined;
|
|
392
|
-
assetReferences?: bigint[] | undefined;
|
|
393
|
-
boxReferences?: (BoxIdentifier | import("./app-manager").BoxReference)[] | undefined;
|
|
394
|
-
sender?: string | undefined;
|
|
395
|
-
method: string;
|
|
396
|
-
args?: (algosdk.ABIValue | AppMethodCallTransactionArgument | ABIStruct | undefined)[] | undefined;
|
|
397
|
-
/** Any deploy-time parameters to replace in the TEAL code */
|
|
398
|
-
deployTimeParams?: TealTemplateParams | undefined;
|
|
399
|
-
/** Whether or not the contract should have deploy-time immutability control set, undefined = ignore */
|
|
400
|
-
updatable?: boolean | undefined;
|
|
401
|
-
/** Whether or not the contract should have deploy-time permanence control set, undefined = ignore */
|
|
402
|
-
deletable?: boolean | undefined;
|
|
403
|
-
} | {
|
|
387
|
+
} & AppClientCompilationParams) => Promise<{
|
|
388
|
+
/** The compiled bytecode of the approval program, ready to deploy to algod */
|
|
404
389
|
approvalProgram: Uint8Array;
|
|
405
|
-
|
|
390
|
+
/** The compiled bytecode of the clear state program, ready to deploy to algod */
|
|
406
391
|
clearStateProgram: Uint8Array;
|
|
407
|
-
|
|
392
|
+
/** The result of compilation of the approval program, including source map, if TEAL code was compiled */
|
|
393
|
+
approvalProgramCompilationResult?: CompiledTeal | undefined;
|
|
394
|
+
/** The result of compilation of the clear state program, including source map, if TEAL code was compiled */
|
|
395
|
+
clearStateProgramCompilationResult?: CompiledTeal | undefined;
|
|
408
396
|
lease?: string | Uint8Array | undefined;
|
|
409
397
|
note?: string | Uint8Array | undefined;
|
|
410
398
|
maxFee?: AlgoAmount | undefined;
|
|
@@ -429,7 +417,7 @@ export declare class AppClient {
|
|
|
429
417
|
updatable?: boolean | undefined;
|
|
430
418
|
/** Whether or not the contract should have deploy-time permanence control set, undefined = ignore */
|
|
431
419
|
deletable?: boolean | undefined;
|
|
432
|
-
}
|
|
420
|
+
} & {
|
|
433
421
|
appId: bigint;
|
|
434
422
|
sender: string;
|
|
435
423
|
method: Arc56Method;
|
|
@@ -1033,8 +1021,8 @@ export declare class AppClient {
|
|
|
1033
1021
|
method: string;
|
|
1034
1022
|
args?: (algosdk.ABIValue | AppMethodCallTransactionArgument | ABIStruct | undefined)[] | undefined;
|
|
1035
1023
|
} & AppClientCompilationParams & SendParams) => Promise<{
|
|
1036
|
-
compiledApproval?:
|
|
1037
|
-
compiledClear?:
|
|
1024
|
+
compiledApproval?: CompiledTeal | undefined;
|
|
1025
|
+
compiledClear?: CompiledTeal | undefined;
|
|
1038
1026
|
groupId: string;
|
|
1039
1027
|
txIds: string[];
|
|
1040
1028
|
returns?: ABIReturn[] | undefined;
|
|
@@ -1193,6 +1181,8 @@ export declare class AppClient {
|
|
|
1193
1181
|
boxReferences?: (BoxIdentifier | import("./app-manager").BoxReference)[] | undefined;
|
|
1194
1182
|
sender?: string | undefined;
|
|
1195
1183
|
} & AppClientCompilationParams & SendParams) | undefined) => Promise<{
|
|
1184
|
+
compiledApproval?: CompiledTeal | undefined;
|
|
1185
|
+
compiledClear?: CompiledTeal | undefined;
|
|
1196
1186
|
groupId: string;
|
|
1197
1187
|
txIds: string[];
|
|
1198
1188
|
returns?: ABIReturn[] | undefined;
|
|
@@ -1201,8 +1191,6 @@ export declare class AppClient {
|
|
|
1201
1191
|
confirmation: algosdk.modelsv2.PendingTransactionResponse;
|
|
1202
1192
|
transaction: algosdk.Transaction;
|
|
1203
1193
|
return?: ABIReturn | undefined;
|
|
1204
|
-
compiledApproval?: import("./app").CompiledTeal | undefined;
|
|
1205
|
-
compiledClear?: import("./app").CompiledTeal | undefined;
|
|
1206
1194
|
}>;
|
|
1207
1195
|
/** Signs and sends an opt-in call */
|
|
1208
1196
|
optIn: (params?: ({
|
|
@@ -1557,17 +1545,7 @@ export declare class AppClient {
|
|
|
1557
1545
|
*
|
|
1558
1546
|
* Will store any generated source maps for later use in debugging.
|
|
1559
1547
|
*/
|
|
1560
|
-
compile(compilation?: AppClientCompilationParams): Promise<
|
|
1561
|
-
approvalProgram: Uint8Array;
|
|
1562
|
-
compiledApproval: undefined;
|
|
1563
|
-
clearStateProgram: Uint8Array;
|
|
1564
|
-
compiledClear: undefined;
|
|
1565
|
-
} | {
|
|
1566
|
-
approvalProgram: Uint8Array;
|
|
1567
|
-
compiledApproval: import("./app").CompiledTeal;
|
|
1568
|
-
clearStateProgram: Uint8Array;
|
|
1569
|
-
compiledClear: import("./app").CompiledTeal;
|
|
1570
|
-
}>;
|
|
1548
|
+
compile(compilation?: AppClientCompilationParams): Promise<AppClientCompilationResult>;
|
|
1571
1549
|
/**
|
|
1572
1550
|
* Takes an error that may include a logic error from a call to the current app and re-exposes the
|
|
1573
1551
|
* error to include source code information via the source map and ARC-56 spec.
|
|
@@ -1592,17 +1570,7 @@ export declare class AppClient {
|
|
|
1592
1570
|
* @param appSpec The app spec for the app
|
|
1593
1571
|
* @param compilation Any compilation parameters to use
|
|
1594
1572
|
*/
|
|
1595
|
-
static compile(appSpec: Arc56Contract, appManager: AppManager, compilation?: AppClientCompilationParams): Promise<
|
|
1596
|
-
approvalProgram: Uint8Array;
|
|
1597
|
-
compiledApproval: undefined;
|
|
1598
|
-
clearStateProgram: Uint8Array;
|
|
1599
|
-
compiledClear: undefined;
|
|
1600
|
-
} | {
|
|
1601
|
-
approvalProgram: Uint8Array;
|
|
1602
|
-
compiledApproval: import("./app").CompiledTeal;
|
|
1603
|
-
clearStateProgram: Uint8Array;
|
|
1604
|
-
compiledClear: import("./app").CompiledTeal;
|
|
1605
|
-
}>;
|
|
1573
|
+
static compile(appSpec: Arc56Contract, appManager: AppManager, compilation?: AppClientCompilationParams): Promise<AppClientCompilationResult>;
|
|
1606
1574
|
/**
|
|
1607
1575
|
* Returns ABI method arguments ready for a method call params object with default values populated
|
|
1608
1576
|
* and structs replaced with tuples.
|
|
@@ -1669,8 +1637,8 @@ export declare class ApplicationClient {
|
|
|
1669
1637
|
* @returns The compiled approval and clear state programs
|
|
1670
1638
|
*/
|
|
1671
1639
|
compile(compilation?: AppClientCompilationParams): Promise<{
|
|
1672
|
-
approvalCompiled:
|
|
1673
|
-
clearCompiled:
|
|
1640
|
+
approvalCompiled: CompiledTeal;
|
|
1641
|
+
clearCompiled: CompiledTeal;
|
|
1674
1642
|
}>;
|
|
1675
1643
|
/**
|
|
1676
1644
|
* Export the current source maps for the app.
|
|
@@ -1698,8 +1666,8 @@ export declare class ApplicationClient {
|
|
|
1698
1666
|
deploy(deploy?: AppClientDeployParams): Promise<(Partial<AppCompilationResult> & AppMetadata & {
|
|
1699
1667
|
operationPerformed: "nothing";
|
|
1700
1668
|
}) | {
|
|
1701
|
-
compiledApproval:
|
|
1702
|
-
compiledClear:
|
|
1669
|
+
compiledApproval: CompiledTeal;
|
|
1670
|
+
compiledClear: CompiledTeal;
|
|
1703
1671
|
confirmation: algosdk.modelsv2.PendingTransactionResponse;
|
|
1704
1672
|
confirmations: algosdk.modelsv2.PendingTransactionResponse[];
|
|
1705
1673
|
transaction: algosdk.Transaction;
|
|
@@ -1707,7 +1675,7 @@ export declare class ApplicationClient {
|
|
|
1707
1675
|
createdRound: number;
|
|
1708
1676
|
updatedRound: number;
|
|
1709
1677
|
createdMetadata: import("./app").AppDeployMetadata;
|
|
1710
|
-
deleted: boolean;
|
|
1678
|
+
deleted: boolean; /** Any overrides for the storage schema to request for the created app; by default the schema indicated by the app spec is used. */
|
|
1711
1679
|
appId: number | bigint;
|
|
1712
1680
|
appAddress: string;
|
|
1713
1681
|
name: string;
|
|
@@ -1717,8 +1685,8 @@ export declare class ApplicationClient {
|
|
|
1717
1685
|
return?: ABIReturn | undefined;
|
|
1718
1686
|
operationPerformed: "update" | "create";
|
|
1719
1687
|
} | {
|
|
1720
|
-
compiledApproval:
|
|
1721
|
-
compiledClear:
|
|
1688
|
+
compiledApproval: CompiledTeal;
|
|
1689
|
+
compiledClear: CompiledTeal;
|
|
1722
1690
|
confirmation: algosdk.modelsv2.PendingTransactionResponse;
|
|
1723
1691
|
confirmations: algosdk.modelsv2.PendingTransactionResponse[];
|
|
1724
1692
|
transaction: algosdk.Transaction;
|
|
@@ -1726,14 +1694,14 @@ export declare class ApplicationClient {
|
|
|
1726
1694
|
createdRound: number;
|
|
1727
1695
|
updatedRound: number;
|
|
1728
1696
|
createdMetadata: import("./app").AppDeployMetadata;
|
|
1729
|
-
deleted: boolean;
|
|
1697
|
+
deleted: boolean; /** Any overrides for the storage schema to request for the created app; by default the schema indicated by the app spec is used. */
|
|
1730
1698
|
appId: number | bigint;
|
|
1731
1699
|
appAddress: string;
|
|
1732
1700
|
name: string;
|
|
1733
1701
|
version: string;
|
|
1734
1702
|
deletable?: boolean | undefined;
|
|
1735
1703
|
updatable?: boolean | undefined;
|
|
1736
|
-
return?: ABIReturn | undefined;
|
|
1704
|
+
return?: ABIReturn | undefined; /** The optional name override to resolve the app by within the creator account (default: uses the name in the ABI contract) */
|
|
1737
1705
|
deleteReturn?: ABIReturn | undefined;
|
|
1738
1706
|
deleteResult: import("./transaction").ConfirmedTransactionResult;
|
|
1739
1707
|
operationPerformed: "replace";
|
|
@@ -1746,8 +1714,8 @@ export declare class ApplicationClient {
|
|
|
1746
1714
|
* @returns The details of the created app, or the transaction to create it if `skipSending` and the compilation result
|
|
1747
1715
|
*/
|
|
1748
1716
|
create(create?: AppClientCreateParams): Promise<{
|
|
1749
|
-
compiledApproval:
|
|
1750
|
-
compiledClear:
|
|
1717
|
+
compiledApproval: CompiledTeal;
|
|
1718
|
+
compiledClear: CompiledTeal;
|
|
1751
1719
|
return?: ABIReturn | undefined;
|
|
1752
1720
|
transactions: algosdk.Transaction[];
|
|
1753
1721
|
confirmations?: algosdk.modelsv2.PendingTransactionResponse[] | undefined;
|
|
@@ -1764,8 +1732,8 @@ export declare class ApplicationClient {
|
|
|
1764
1732
|
* @returns The transaction send result and the compilation result
|
|
1765
1733
|
*/
|
|
1766
1734
|
update(update?: AppClientUpdateParams): Promise<{
|
|
1767
|
-
compiledApproval:
|
|
1768
|
-
compiledClear:
|
|
1735
|
+
compiledApproval: CompiledTeal;
|
|
1736
|
+
compiledClear: CompiledTeal;
|
|
1769
1737
|
return?: ABIReturn | undefined;
|
|
1770
1738
|
transactions: algosdk.Transaction[];
|
|
1771
1739
|
confirmations?: algosdk.modelsv2.PendingTransactionResponse[] | undefined;
|
package/types/app-client.js
CHANGED
|
@@ -340,11 +340,11 @@ class AppClient {
|
|
|
340
340
|
*/
|
|
341
341
|
async compile(compilation) {
|
|
342
342
|
const result = await AppClient.compile(this._appSpec, this._algorand.app, compilation);
|
|
343
|
-
if (result.
|
|
344
|
-
this._approvalSourceMap = result.
|
|
343
|
+
if (result.approvalProgramCompilationResult) {
|
|
344
|
+
this._approvalSourceMap = result.approvalProgramCompilationResult.sourceMap;
|
|
345
345
|
}
|
|
346
|
-
if (result.
|
|
347
|
-
this._clearSourceMap = result.
|
|
346
|
+
if (result.clearStateProgramCompilationResult) {
|
|
347
|
+
this._clearSourceMap = result.clearStateProgramCompilationResult.sourceMap;
|
|
348
348
|
}
|
|
349
349
|
return result;
|
|
350
350
|
}
|
|
@@ -396,31 +396,29 @@ class AppClient {
|
|
|
396
396
|
}
|
|
397
397
|
return {
|
|
398
398
|
approvalProgram: buffer.Buffer.from(appSpec.byteCode.approval, 'base64'),
|
|
399
|
-
compiledApproval: undefined,
|
|
400
399
|
clearStateProgram: buffer.Buffer.from(appSpec.byteCode.clear, 'base64'),
|
|
401
|
-
compiledClear: undefined,
|
|
402
400
|
};
|
|
403
401
|
}
|
|
404
402
|
const approvalTemplate = buffer.Buffer.from(appSpec.source.approval, 'base64').toString('utf-8');
|
|
405
|
-
const
|
|
403
|
+
const approvalProgramCompilationResult = await appManager.compileTealTemplate(approvalTemplate, deployTimeParams, {
|
|
406
404
|
updatable,
|
|
407
405
|
deletable,
|
|
408
406
|
});
|
|
409
407
|
const clearTemplate = buffer.Buffer.from(appSpec.source.clear, 'base64').toString('utf-8');
|
|
410
|
-
const
|
|
408
|
+
const clearStateProgramCompilationResult = await appManager.compileTealTemplate(clearTemplate, deployTimeParams);
|
|
411
409
|
if (config.Config.debug) {
|
|
412
410
|
await config.Config.events.emitAsync(types_asyncEventEmitter.EventType.AppCompiled, {
|
|
413
411
|
sources: [
|
|
414
|
-
{ compiledTeal:
|
|
415
|
-
{ compiledTeal:
|
|
412
|
+
{ compiledTeal: approvalProgramCompilationResult, appName: appSpec.name, fileName: 'approval' },
|
|
413
|
+
{ compiledTeal: clearStateProgramCompilationResult, appName: appSpec.name, fileName: 'clear' },
|
|
416
414
|
],
|
|
417
415
|
});
|
|
418
416
|
}
|
|
419
417
|
return {
|
|
420
|
-
approvalProgram:
|
|
421
|
-
|
|
422
|
-
clearStateProgram:
|
|
423
|
-
|
|
418
|
+
approvalProgram: approvalProgramCompilationResult.compiledBase64ToBytes,
|
|
419
|
+
approvalProgramCompilationResult,
|
|
420
|
+
clearStateProgram: clearStateProgramCompilationResult.compiledBase64ToBytes,
|
|
421
|
+
clearStateProgramCompilationResult,
|
|
424
422
|
};
|
|
425
423
|
}
|
|
426
424
|
/**
|
|
@@ -542,7 +540,14 @@ class AppClient {
|
|
|
542
540
|
return {
|
|
543
541
|
/** Signs and sends an update call, including deploy-time TEAL template replacements and compilation if provided */
|
|
544
542
|
update: async (params) => {
|
|
545
|
-
|
|
543
|
+
const compiled = await this.compile(params);
|
|
544
|
+
return {
|
|
545
|
+
...(await this.handleCallErrors(async () => this._algorand.send.appUpdate(await this.params.bare.update(params)))),
|
|
546
|
+
...{
|
|
547
|
+
compiledApproval: compiled.approvalProgramCompilationResult,
|
|
548
|
+
compiledClear: compiled.clearStateProgramCompilationResult,
|
|
549
|
+
},
|
|
550
|
+
};
|
|
546
551
|
},
|
|
547
552
|
/** Signs and sends an opt-in call */
|
|
548
553
|
optIn: (params) => {
|
|
@@ -614,7 +619,10 @@ class AppClient {
|
|
|
614
619
|
const compiled = await this.compile(params);
|
|
615
620
|
return {
|
|
616
621
|
...(await this.handleCallErrors(async () => this.processMethodCallReturn(this._algorand.send.appUpdateMethodCall(await this.params.update({ ...params })), types_appArc56.getArc56Method(params.method, this._appSpec)))),
|
|
617
|
-
...
|
|
622
|
+
...{
|
|
623
|
+
compiledApproval: compiled.approvalProgramCompilationResult,
|
|
624
|
+
compiledClear: compiled.clearStateProgramCompilationResult,
|
|
625
|
+
},
|
|
618
626
|
};
|
|
619
627
|
},
|
|
620
628
|
/**
|
|
@@ -645,7 +653,9 @@ class AppClient {
|
|
|
645
653
|
const result = await this._algorand
|
|
646
654
|
.newGroup()
|
|
647
655
|
.addAppCallMethodCall(await this.params.call(params))
|
|
648
|
-
.simulate(
|
|
656
|
+
.simulate({
|
|
657
|
+
allowUnnamedResources: params.populateAppCallResources,
|
|
658
|
+
});
|
|
649
659
|
return this.processMethodCallReturn({
|
|
650
660
|
...result,
|
|
651
661
|
transaction: result.transactions.at(-1),
|