@algorandfoundation/algokit-utils 1.0.0-beta.7 → 1.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/{dist/index.js → index.js} +1 -0
- package/package.json +3 -94
- package/LICENSE +0 -21
- package/README.md +0 -31
- package/dist/account.d.ts +0 -87
- package/dist/account.d.ts.map +0 -1
- package/dist/account.js +0 -144
- package/dist/account.js.map +0 -1
- package/dist/algo-amount.d.ts +0 -18
- package/dist/algo-amount.d.ts.map +0 -1
- package/dist/algo-amount.js +0 -31
- package/dist/algo-amount.js.map +0 -1
- package/dist/algo-http-client-with-retry.d.ts +0 -14
- package/dist/algo-http-client-with-retry.d.ts.map +0 -1
- package/dist/algo-http-client-with-retry.js +0 -62
- package/dist/algo-http-client-with-retry.js.map +0 -1
- package/dist/app.d.ts +0 -189
- package/dist/app.d.ts.map +0 -1
- package/dist/app.js +0 -265
- package/dist/app.js.map +0 -1
- package/dist/application-client.d.ts +0 -108
- package/dist/application-client.d.ts.map +0 -1
- package/dist/application-client.js +0 -254
- package/dist/application-client.js.map +0 -1
- package/dist/config.d.ts +0 -27
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -46
- package/dist/config.js.map +0 -1
- package/dist/deploy-app.d.ts +0 -159
- package/dist/deploy-app.d.ts.map +0 -1
- package/dist/deploy-app.js +0 -416
- package/dist/deploy-app.js.map +0 -1
- package/dist/index.d.ts +0 -11
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/indexer-lookup.d.ts +0 -31
- package/dist/indexer-lookup.d.ts.map +0 -1
- package/dist/indexer-lookup.js +0 -96
- package/dist/indexer-lookup.js.map +0 -1
- package/dist/localnet.d.ts +0 -54
- package/dist/localnet.d.ts.map +0 -1
- package/dist/localnet.js +0 -121
- package/dist/localnet.js.map +0 -1
- package/dist/network-client.d.ts +0 -102
- package/dist/network-client.d.ts.map +0 -1
- package/dist/network-client.js +0 -182
- package/dist/network-client.js.map +0 -1
- package/dist/package.json +0 -20
- package/dist/transaction.d.ts +0 -157
- package/dist/transaction.d.ts.map +0 -1
- package/dist/transaction.js +0 -306
- package/dist/transaction.js.map +0 -1
- package/dist/transfer.d.ts +0 -24
- package/dist/transfer.d.ts.map +0 -1
- package/dist/transfer.js +0 -33
- package/dist/transfer.js.map +0 -1
- package/dist/types/algod.d.ts +0 -124
- package/dist/types/algod.d.ts.map +0 -1
- package/dist/types/algod.js +0 -3
- package/dist/types/algod.js.map +0 -1
- package/dist/types/appspec.d.ts +0 -79
- package/dist/types/appspec.d.ts.map +0 -1
- package/dist/types/appspec.js +0 -15
- package/dist/types/appspec.js.map +0 -1
- package/dist/types/indexer.d.ts +0 -314
- package/dist/types/indexer.d.ts.map +0 -1
- package/dist/types/indexer.js +0 -25
- package/dist/types/indexer.js.map +0 -1
- package/dist/urlTokenBaseHTTPClient.d.ts +0 -41
- package/dist/urlTokenBaseHTTPClient.d.ts.map +0 -1
- package/dist/urlTokenBaseHTTPClient.js +0 -151
- package/dist/urlTokenBaseHTTPClient.js.map +0 -1
package/dist/app.d.ts
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import algosdk, { ABIArgument, ABIMethod, ABIMethodParams, ABIValue, Address, Algodv2, SuggestedParams } from 'algosdk';
|
|
2
|
-
import { SendTransactionFrom, SendTransactionParams, SendTransactionResult, TransactionNote } from './transaction';
|
|
3
|
-
import { ApplicationResponse, PendingTransactionResponse } from './types/algod';
|
|
4
|
-
/** The maximum number of bytes in an app code page */
|
|
5
|
-
export declare const APP_PAGE_MAX_SIZE = 2048;
|
|
6
|
-
/** First 4 bytes of SHA-512/256 hash of "return" */
|
|
7
|
-
export declare const ABI_RETURN_PREFIX: Uint8Array;
|
|
8
|
-
/** Information about an Algorand app */
|
|
9
|
-
export interface AppReference {
|
|
10
|
-
/** The index of the app */
|
|
11
|
-
appIndex: number;
|
|
12
|
-
/** The Algorand address of the account associated with the app */
|
|
13
|
-
appAddress: string;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* A grouping of the app ID and name of the box in an Uint8Array
|
|
17
|
-
*/
|
|
18
|
-
export interface BoxReference {
|
|
19
|
-
/**
|
|
20
|
-
* A unique application index
|
|
21
|
-
*/
|
|
22
|
-
appIndex: number;
|
|
23
|
-
/**
|
|
24
|
-
* Name of box to reference
|
|
25
|
-
*/
|
|
26
|
-
name: Uint8Array | string;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* App call args with raw values (minus some processing like encoding strings as binary)
|
|
30
|
-
*/
|
|
31
|
-
export interface RawAppCallArgs {
|
|
32
|
-
/** The address of any accounts to load in */
|
|
33
|
-
accounts?: (string | Address)[];
|
|
34
|
-
/** Any application arguments to pass through */
|
|
35
|
-
appArgs?: (Uint8Array | string)[];
|
|
36
|
-
/** Any box references to load */
|
|
37
|
-
boxes?: BoxReference[];
|
|
38
|
-
/** IDs of any apps to load into the foreignApps array */
|
|
39
|
-
apps?: number[];
|
|
40
|
-
/** IDs of any assets to load into the foreignAssets array */
|
|
41
|
-
assets?: number[];
|
|
42
|
-
/** The optional lease for the transaction */
|
|
43
|
-
lease?: string | Uint8Array;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* App call args for an ABI call
|
|
47
|
-
*/
|
|
48
|
-
export interface ABIAppCallArgs {
|
|
49
|
-
/** The ABI method to call, either:
|
|
50
|
-
* * {method_name e.g. `hello`}; or
|
|
51
|
-
* * {method_signature e.g. `hello(string)string`} */
|
|
52
|
-
method: ABIMethodParams | ABIMethod;
|
|
53
|
-
/** The ABI args to pass in */
|
|
54
|
-
args: ABIArgument[];
|
|
55
|
-
/** The optional lease for the transaction */
|
|
56
|
-
lease?: string | Uint8Array;
|
|
57
|
-
}
|
|
58
|
-
/** Arguments to pass to an app call either:
|
|
59
|
-
* * The raw app call values to pass through into the transaction (after processing); or
|
|
60
|
-
* * An ABI method definition (method and args)
|
|
61
|
-
**/
|
|
62
|
-
export type AppCallArgs = RawAppCallArgs | ABIAppCallArgs;
|
|
63
|
-
/** Base interface for common data passed to an app create or update. */
|
|
64
|
-
interface CreateOrUpdateAppParams extends SendTransactionParams {
|
|
65
|
-
/** The account (with private key loaded) that will send the µALGOs */
|
|
66
|
-
from: SendTransactionFrom;
|
|
67
|
-
/** The approval program as raw teal (string) or compiled teal, base 64 encoded as a byte array (Uint8Array) */
|
|
68
|
-
approvalProgram: Uint8Array | string;
|
|
69
|
-
/** The clear state program as raw teal (string) or compiled teal, base 64 encoded as a byte array (Uint8Array) */
|
|
70
|
-
clearStateProgram: Uint8Array | string;
|
|
71
|
-
/** Optional transaction parameters */
|
|
72
|
-
transactionParams?: SuggestedParams;
|
|
73
|
-
/** The (optional) transaction note */
|
|
74
|
-
note?: TransactionNote;
|
|
75
|
-
/** The arguments passed in to the app call */
|
|
76
|
-
args?: AppCallArgs;
|
|
77
|
-
}
|
|
78
|
-
/** Parameters that are passed in when creating an app. */
|
|
79
|
-
export interface CreateAppParams extends CreateOrUpdateAppParams {
|
|
80
|
-
/** The storage schema to request for the created app */
|
|
81
|
-
schema: AppStorageSchema;
|
|
82
|
-
}
|
|
83
|
-
/** Parameters that are passed in when updating an app. */
|
|
84
|
-
export interface UpdateAppParams extends CreateOrUpdateAppParams {
|
|
85
|
-
/** The index of the app to update */
|
|
86
|
-
appIndex: number;
|
|
87
|
-
}
|
|
88
|
-
export interface AppCallParams extends SendTransactionParams {
|
|
89
|
-
/** The index of the app to call */
|
|
90
|
-
appIndex: number;
|
|
91
|
-
/** The type of call, everything except create (@see {createApp} ) and update (@see {updateApp} ) */
|
|
92
|
-
callType: 'optin' | 'closeout' | 'clearstate' | 'delete' | 'normal';
|
|
93
|
-
/** The account to make the call from */
|
|
94
|
-
from: SendTransactionFrom;
|
|
95
|
-
/** Optional transaction parameters */
|
|
96
|
-
transactionParams?: SuggestedParams;
|
|
97
|
-
/** The (optional) transaction note */
|
|
98
|
-
note?: TransactionNote;
|
|
99
|
-
/** The arguments passed in to the app call */
|
|
100
|
-
args?: AppCallArgs;
|
|
101
|
-
}
|
|
102
|
-
/** Parameters representing the storage schema of an app. */
|
|
103
|
-
export interface AppStorageSchema {
|
|
104
|
-
/** Restricts number of ints in per-user local state */
|
|
105
|
-
localInts: number;
|
|
106
|
-
/** Restricts number of byte slices in per-user local state */
|
|
107
|
-
localByteSlices: number;
|
|
108
|
-
/** Restricts number of ints in global state */
|
|
109
|
-
globalInts: number;
|
|
110
|
-
/** Restricts number of byte slices in global state */
|
|
111
|
-
globalByteSlices: number;
|
|
112
|
-
/** 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 */
|
|
113
|
-
extraPages?: number;
|
|
114
|
-
}
|
|
115
|
-
/** Information about a compiled teal program */
|
|
116
|
-
export interface CompiledTeal {
|
|
117
|
-
/** Original TEAL code */
|
|
118
|
-
teal: string;
|
|
119
|
-
/** The compiled code */
|
|
120
|
-
compiled: string;
|
|
121
|
-
/** The has returned by the compiler */
|
|
122
|
-
compiledHash: string;
|
|
123
|
-
/** The base64 encoded code as a byte array */
|
|
124
|
-
compiledBase64ToBytes: Uint8Array;
|
|
125
|
-
}
|
|
126
|
-
/** Result from calling an app */
|
|
127
|
-
export interface AppCallTransactionResult extends SendTransactionResult {
|
|
128
|
-
/** If an ABI method was called the processed return value */
|
|
129
|
-
return?: ABIReturn;
|
|
130
|
-
}
|
|
131
|
-
/** The return value of an ABI method call */
|
|
132
|
-
export type ABIReturn = {
|
|
133
|
-
rawReturnValue: Uint8Array;
|
|
134
|
-
returnValue: ABIValue;
|
|
135
|
-
decodeError: undefined;
|
|
136
|
-
} | {
|
|
137
|
-
rawReturnValue: undefined;
|
|
138
|
-
returnValue: undefined;
|
|
139
|
-
decodeError: Error;
|
|
140
|
-
};
|
|
141
|
-
/**
|
|
142
|
-
* Creates a smart contract app, returns the details of the created app.
|
|
143
|
-
* @param create The parameters to create the app with
|
|
144
|
-
* @param algod An algod client
|
|
145
|
-
* @returns The details of the created app, or the transaction to create it if `skipSending`
|
|
146
|
-
*/
|
|
147
|
-
export declare function createApp(create: CreateAppParams, algod: Algodv2): Promise<AppCallTransactionResult & AppReference>;
|
|
148
|
-
/**
|
|
149
|
-
* Updates a smart contract app.
|
|
150
|
-
* @param update The parameters to update the app with
|
|
151
|
-
* @param algod An algod client
|
|
152
|
-
* @returns The transaction
|
|
153
|
-
*/
|
|
154
|
-
export declare function updateApp(update: UpdateAppParams, algod: Algodv2): Promise<AppCallTransactionResult>;
|
|
155
|
-
/**
|
|
156
|
-
* Issues a call to a given app.
|
|
157
|
-
* @param call The call details.
|
|
158
|
-
* @param algod An algod client
|
|
159
|
-
* @returns The result of the call
|
|
160
|
-
*/
|
|
161
|
-
export declare function callApp(call: AppCallParams, algod: Algodv2): Promise<AppCallTransactionResult>;
|
|
162
|
-
export declare function getABIReturn(args?: AppCallArgs, confirmation?: PendingTransactionResponse): ABIReturn | undefined;
|
|
163
|
-
/** Returns the app args ready to load onto an app @see {Transaction} object */
|
|
164
|
-
export declare function getAppArgsForTransaction(args?: AppCallArgs): {
|
|
165
|
-
accounts: string[] | undefined;
|
|
166
|
-
appArgs: Uint8Array[] | undefined;
|
|
167
|
-
boxes: algosdk.BoxReference[] | undefined;
|
|
168
|
-
foreignApps: number[] | undefined;
|
|
169
|
-
foreignAssets: number[] | undefined;
|
|
170
|
-
lease: Uint8Array | undefined;
|
|
171
|
-
} | undefined;
|
|
172
|
-
/**
|
|
173
|
-
* Gets the current data for the given app from algod.
|
|
174
|
-
*
|
|
175
|
-
* @param appIndex The index of the app
|
|
176
|
-
* @param algod An algod client
|
|
177
|
-
* @returns The data about the app
|
|
178
|
-
*/
|
|
179
|
-
export declare function getAppByIndex(appIndex: number, algod: Algodv2): Promise<ApplicationResponse>;
|
|
180
|
-
/**
|
|
181
|
-
* Compiles the given TEAL using algod and returns the result.
|
|
182
|
-
*
|
|
183
|
-
* @param algod An algod client
|
|
184
|
-
* @param tealCode The TEAL code
|
|
185
|
-
* @returns The information about the compiled file
|
|
186
|
-
*/
|
|
187
|
-
export declare function compileTeal(tealCode: string, algod: Algodv2): Promise<CompiledTeal>;
|
|
188
|
-
export {};
|
|
189
|
-
//# sourceMappingURL=app.d.ts.map
|
package/dist/app.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EACd,WAAW,EACX,SAAS,EACT,eAAe,EACf,QAAQ,EACR,OAAO,EACP,OAAO,EAIP,eAAe,EAEhB,MAAM,SAAS,CAAA;AAGhB,OAAO,EAKL,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EAChB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAA;AAE/E,sDAAsD;AACtD,eAAO,MAAM,iBAAiB,OAAO,CAAA;AACrC,oDAAoD;AACpD,eAAO,MAAM,iBAAiB,YAAqC,CAAA;AAEnE,wCAAwC;AACxC,MAAM,WAAW,YAAY;IAC3B,2BAA2B;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,kEAAkE;IAClE,UAAU,EAAE,MAAM,CAAA;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,IAAI,EAAE,UAAU,GAAG,MAAM,CAAA;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,CAAC,MAAM,GAAG,OAAO,CAAC,EAAE,CAAA;IAC/B,gDAAgD;IAChD,OAAO,CAAC,EAAE,CAAC,UAAU,GAAG,MAAM,CAAC,EAAE,CAAA;IACjC,iCAAiC;IACjC,KAAK,CAAC,EAAE,YAAY,EAAE,CAAA;IACtB,yDAAyD;IACzD,IAAI,CAAC,EAAE,MAAM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AM,EAAE,eAAe,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAyB1G;AAED;;;;;GAKG;AACH,wBAAsB,OAAO,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAqCpG;AAED,wBAAgB,YAAY,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,YAAY,CAAC,EAAE,0BAA0B,GAAG,SAAS,GAAG,SAAS,CA6BjH;AAED,+EAA+E;AAC/E,wBAAgB,wBAAwB,CAAC,IAAI,CAAC,EAAE,WAAW;;;;;;;cA0D1D;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,gCAEnE;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC,CAQzF"}
|
package/dist/app.js
DELETED
|
@@ -1,265 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.compileTeal = exports.getAppByIndex = exports.getAppArgsForTransaction = exports.getABIReturn = exports.callApp = exports.updateApp = exports.createApp = exports.ABI_RETURN_PREFIX = exports.APP_PAGE_MAX_SIZE = void 0;
|
|
27
|
-
const algosdk_1 = __importStar(require("algosdk"));
|
|
28
|
-
const buffer_1 = require("buffer");
|
|
29
|
-
const config_1 = require("./config");
|
|
30
|
-
const transaction_1 = require("./transaction");
|
|
31
|
-
/** The maximum number of bytes in an app code page */
|
|
32
|
-
exports.APP_PAGE_MAX_SIZE = 2048;
|
|
33
|
-
/** First 4 bytes of SHA-512/256 hash of "return" */
|
|
34
|
-
exports.ABI_RETURN_PREFIX = new Uint8Array([21, 31, 124, 117]);
|
|
35
|
-
/**
|
|
36
|
-
* Creates a smart contract app, returns the details of the created app.
|
|
37
|
-
* @param create The parameters to create the app with
|
|
38
|
-
* @param algod An algod client
|
|
39
|
-
* @returns The details of the created app, or the transaction to create it if `skipSending`
|
|
40
|
-
*/
|
|
41
|
-
async function createApp(create, algod) {
|
|
42
|
-
const { from, approvalProgram: approval, clearStateProgram: clear, schema, note, transactionParams, args, ...sendParams } = create;
|
|
43
|
-
const approvalProgram = typeof approval === 'string' ? (await compileTeal(approval, algod)).compiledBase64ToBytes : approval;
|
|
44
|
-
const clearProgram = typeof clear === 'string' ? (await compileTeal(clear, algod)).compiledBase64ToBytes : clear;
|
|
45
|
-
const transaction = algosdk_1.default.makeApplicationCreateTxnFromObject({
|
|
46
|
-
approvalProgram: approvalProgram,
|
|
47
|
-
clearProgram: clearProgram,
|
|
48
|
-
numLocalInts: schema.localInts,
|
|
49
|
-
numLocalByteSlices: schema.localByteSlices,
|
|
50
|
-
numGlobalInts: schema.globalInts,
|
|
51
|
-
numGlobalByteSlices: schema.globalByteSlices,
|
|
52
|
-
extraPages: schema.extraPages ?? Math.floor((approvalProgram.length + clearProgram.length) / exports.APP_PAGE_MAX_SIZE),
|
|
53
|
-
onComplete: algosdk_1.default.OnApplicationComplete.NoOpOC,
|
|
54
|
-
suggestedParams: await (0, transaction_1.getTransactionParams)(transactionParams, algod),
|
|
55
|
-
from: (0, transaction_1.getSenderAddress)(from),
|
|
56
|
-
note: (0, transaction_1.encodeTransactionNote)(note),
|
|
57
|
-
...getAppArgsForTransaction(args),
|
|
58
|
-
rekeyTo: undefined,
|
|
59
|
-
});
|
|
60
|
-
const { confirmation } = await (0, transaction_1.sendTransaction)({ transaction, from, sendParams }, algod);
|
|
61
|
-
if (confirmation) {
|
|
62
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
63
|
-
const appIndex = confirmation['application-index'];
|
|
64
|
-
config_1.AlgoKitConfig.getLogger(sendParams.suppressLog).debug(`Created app ${appIndex} from creator ${(0, transaction_1.getSenderAddress)(from)}`);
|
|
65
|
-
return {
|
|
66
|
-
transaction,
|
|
67
|
-
confirmation,
|
|
68
|
-
appIndex,
|
|
69
|
-
appAddress: algosdk_1.default.getApplicationAddress(appIndex),
|
|
70
|
-
return: getABIReturn(args, confirmation),
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
return { transaction, appIndex: 0, appAddress: '' };
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
exports.createApp = createApp;
|
|
78
|
-
/**
|
|
79
|
-
* Updates a smart contract app.
|
|
80
|
-
* @param update The parameters to update the app with
|
|
81
|
-
* @param algod An algod client
|
|
82
|
-
* @returns The transaction
|
|
83
|
-
*/
|
|
84
|
-
async function updateApp(update, algod) {
|
|
85
|
-
const { appIndex, from, approvalProgram: approval, clearStateProgram: clear, note, transactionParams, args, ...sendParams } = update;
|
|
86
|
-
const approvalProgram = typeof approval === 'string' ? (await compileTeal(approval, algod)).compiledBase64ToBytes : approval;
|
|
87
|
-
const clearProgram = typeof clear === 'string' ? (await compileTeal(clear, algod)).compiledBase64ToBytes : clear;
|
|
88
|
-
const transaction = algosdk_1.default.makeApplicationUpdateTxnFromObject({
|
|
89
|
-
appIndex,
|
|
90
|
-
approvalProgram: approvalProgram,
|
|
91
|
-
clearProgram: clearProgram,
|
|
92
|
-
suggestedParams: await (0, transaction_1.getTransactionParams)(transactionParams, algod),
|
|
93
|
-
from: (0, transaction_1.getSenderAddress)(from),
|
|
94
|
-
note: (0, transaction_1.encodeTransactionNote)(note),
|
|
95
|
-
...getAppArgsForTransaction(args),
|
|
96
|
-
rekeyTo: undefined,
|
|
97
|
-
});
|
|
98
|
-
config_1.AlgoKitConfig.getLogger(sendParams.suppressLog).debug(`Updating app ${appIndex}`);
|
|
99
|
-
const result = await (0, transaction_1.sendTransaction)({ transaction, from, sendParams }, algod);
|
|
100
|
-
return {
|
|
101
|
-
...result,
|
|
102
|
-
return: getABIReturn(args, result.confirmation),
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
exports.updateApp = updateApp;
|
|
106
|
-
/**
|
|
107
|
-
* Issues a call to a given app.
|
|
108
|
-
* @param call The call details.
|
|
109
|
-
* @param algod An algod client
|
|
110
|
-
* @returns The result of the call
|
|
111
|
-
*/
|
|
112
|
-
async function callApp(call, algod) {
|
|
113
|
-
const { appIndex, callType, from, args, note, transactionParams, ...sendParams } = call;
|
|
114
|
-
const appCallParameters = {
|
|
115
|
-
appIndex: appIndex,
|
|
116
|
-
from: (0, transaction_1.getSenderAddress)(from),
|
|
117
|
-
suggestedParams: await (0, transaction_1.getTransactionParams)(transactionParams, algod),
|
|
118
|
-
...getAppArgsForTransaction(args),
|
|
119
|
-
note: (0, transaction_1.encodeTransactionNote)(note),
|
|
120
|
-
rekeyTo: undefined,
|
|
121
|
-
};
|
|
122
|
-
let transaction;
|
|
123
|
-
switch (callType) {
|
|
124
|
-
case 'optin':
|
|
125
|
-
transaction = algosdk_1.default.makeApplicationOptInTxnFromObject(appCallParameters);
|
|
126
|
-
break;
|
|
127
|
-
case 'clearstate':
|
|
128
|
-
transaction = algosdk_1.default.makeApplicationClearStateTxnFromObject(appCallParameters);
|
|
129
|
-
break;
|
|
130
|
-
case 'closeout':
|
|
131
|
-
transaction = algosdk_1.default.makeApplicationCloseOutTxnFromObject(appCallParameters);
|
|
132
|
-
break;
|
|
133
|
-
case 'delete':
|
|
134
|
-
transaction = algosdk_1.default.makeApplicationDeleteTxnFromObject(appCallParameters);
|
|
135
|
-
break;
|
|
136
|
-
case 'normal':
|
|
137
|
-
transaction = algosdk_1.default.makeApplicationNoOpTxnFromObject(appCallParameters);
|
|
138
|
-
break;
|
|
139
|
-
}
|
|
140
|
-
const result = await (0, transaction_1.sendTransaction)({ transaction, from, sendParams }, algod);
|
|
141
|
-
return {
|
|
142
|
-
...result,
|
|
143
|
-
return: getABIReturn(args, result.confirmation),
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
exports.callApp = callApp;
|
|
147
|
-
function getABIReturn(args, confirmation) {
|
|
148
|
-
try {
|
|
149
|
-
if (!args || !('method' in args)) {
|
|
150
|
-
return undefined;
|
|
151
|
-
}
|
|
152
|
-
const method = 'txnCount' in args.method ? args.method : new algosdk_1.ABIMethod(args.method);
|
|
153
|
-
if (method.returns.type !== 'void' && confirmation) {
|
|
154
|
-
const logs = confirmation.logs || [];
|
|
155
|
-
if (logs.length === 0) {
|
|
156
|
-
throw new Error('App call transaction did not log a return value');
|
|
157
|
-
}
|
|
158
|
-
const lastLog = logs[logs.length - 1];
|
|
159
|
-
if (lastLog.byteLength < 4 || lastLog.slice(0, 4).toString() !== exports.ABI_RETURN_PREFIX.toString()) {
|
|
160
|
-
throw new Error('App call transaction did not log a return value (ABI_RETURN_PREFIX not found)');
|
|
161
|
-
}
|
|
162
|
-
return {
|
|
163
|
-
rawReturnValue: new Uint8Array(lastLog.slice(4)),
|
|
164
|
-
returnValue: method.returns.type.decode(new Uint8Array(lastLog.slice(4))),
|
|
165
|
-
decodeError: undefined,
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
catch (e) {
|
|
170
|
-
return {
|
|
171
|
-
rawReturnValue: undefined,
|
|
172
|
-
returnValue: undefined,
|
|
173
|
-
decodeError: e,
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
return undefined;
|
|
177
|
-
}
|
|
178
|
-
exports.getABIReturn = getABIReturn;
|
|
179
|
-
/** Returns the app args ready to load onto an app @see {Transaction} object */
|
|
180
|
-
function getAppArgsForTransaction(args) {
|
|
181
|
-
if (!args)
|
|
182
|
-
return undefined;
|
|
183
|
-
let actualArgs;
|
|
184
|
-
if ('method' in args) {
|
|
185
|
-
// todo: Land a change to algosdk that extract the logic from ATC, because (fair warning) this is a HACK
|
|
186
|
-
// I don't want to have to rewrite all of the ABI resolution logic so using an ATC temporarily here
|
|
187
|
-
// and passing stuff in to keep it happy like a randomly generated account :O
|
|
188
|
-
// Most of these values aren't being used since the transaction is discarded
|
|
189
|
-
const dummyAtc = new algosdk_1.AtomicTransactionComposer();
|
|
190
|
-
const dummyAccount = algosdk_1.default.generateAccount();
|
|
191
|
-
const dummyAppId = 1;
|
|
192
|
-
const dummyParams = {
|
|
193
|
-
fee: 1,
|
|
194
|
-
firstRound: 1,
|
|
195
|
-
genesisHash: buffer_1.Buffer.from('abcd', 'utf-8').toString('base64'),
|
|
196
|
-
genesisID: 'a',
|
|
197
|
-
lastRound: 1,
|
|
198
|
-
};
|
|
199
|
-
const dummyOnComplete = algosdk_1.OnApplicationComplete.NoOpOC;
|
|
200
|
-
dummyAtc.addMethodCall({
|
|
201
|
-
method: 'txnCount' in args.method ? args.method : new algosdk_1.ABIMethod(args.method),
|
|
202
|
-
methodArgs: args.args,
|
|
203
|
-
// Rest are dummy values
|
|
204
|
-
appID: dummyAppId,
|
|
205
|
-
sender: dummyAccount.addr,
|
|
206
|
-
signer: (0, algosdk_1.makeBasicAccountTransactionSigner)(dummyAccount),
|
|
207
|
-
suggestedParams: dummyParams,
|
|
208
|
-
onComplete: dummyOnComplete,
|
|
209
|
-
});
|
|
210
|
-
const txn = dummyAtc.buildGroup()[0];
|
|
211
|
-
actualArgs = {
|
|
212
|
-
accounts: txn.txn.appAccounts,
|
|
213
|
-
appArgs: txn.txn.appArgs,
|
|
214
|
-
apps: txn.txn.appForeignApps,
|
|
215
|
-
assets: txn.txn.appForeignAssets,
|
|
216
|
-
boxes: txn.txn.boxes,
|
|
217
|
-
lease: args.lease,
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
else {
|
|
221
|
-
actualArgs = args;
|
|
222
|
-
}
|
|
223
|
-
const encoder = new TextEncoder();
|
|
224
|
-
return {
|
|
225
|
-
accounts: actualArgs?.accounts?.map((a) => (typeof a === 'string' ? a : algosdk_1.default.encodeAddress(a.publicKey))),
|
|
226
|
-
appArgs: actualArgs?.appArgs?.map((a) => (typeof a === 'string' ? encoder.encode(a) : a)),
|
|
227
|
-
boxes: actualArgs?.boxes?.map((ref) => ({
|
|
228
|
-
appIndex: ref.appIndex,
|
|
229
|
-
name: typeof ref.name === 'string' ? encoder.encode(ref.name) : ref.name,
|
|
230
|
-
})),
|
|
231
|
-
foreignApps: actualArgs?.apps,
|
|
232
|
-
foreignAssets: actualArgs?.assets,
|
|
233
|
-
lease: typeof actualArgs?.lease === 'string' ? encoder.encode(actualArgs?.lease) : actualArgs?.lease,
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
exports.getAppArgsForTransaction = getAppArgsForTransaction;
|
|
237
|
-
/**
|
|
238
|
-
* Gets the current data for the given app from algod.
|
|
239
|
-
*
|
|
240
|
-
* @param appIndex The index of the app
|
|
241
|
-
* @param algod An algod client
|
|
242
|
-
* @returns The data about the app
|
|
243
|
-
*/
|
|
244
|
-
async function getAppByIndex(appIndex, algod) {
|
|
245
|
-
return (await algod.getApplicationByID(appIndex).do());
|
|
246
|
-
}
|
|
247
|
-
exports.getAppByIndex = getAppByIndex;
|
|
248
|
-
/**
|
|
249
|
-
* Compiles the given TEAL using algod and returns the result.
|
|
250
|
-
*
|
|
251
|
-
* @param algod An algod client
|
|
252
|
-
* @param tealCode The TEAL code
|
|
253
|
-
* @returns The information about the compiled file
|
|
254
|
-
*/
|
|
255
|
-
async function compileTeal(tealCode, algod) {
|
|
256
|
-
const compiled = await algod.compile(tealCode).do();
|
|
257
|
-
return {
|
|
258
|
-
teal: tealCode,
|
|
259
|
-
compiled: compiled.result,
|
|
260
|
-
compiledHash: compiled.hash,
|
|
261
|
-
compiledBase64ToBytes: new Uint8Array(buffer_1.Buffer.from(compiled.result, 'base64')),
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
exports.compileTeal = compileTeal;
|
|
265
|
-
//# sourceMappingURL=app.js.map
|
package/dist/app.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAYgB;AAChB,mCAA+B;AAC/B,qCAAwC;AACxC,+CASsB;AAGtB,sDAAsD;AACzC,QAAA,iBAAiB,GAAG,IAAI,CAAA;AACrC,oDAAoD;AACvC,QAAA,iBAAiB,GAAG,IAAI,UAAU,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAA;AAkJnE;;;;;GAKG;AACI,KAAK,UAAU,SAAS,CAAC,MAAuB,EAAE,KAAc;IACrE,MAAM,EAAE,IAAI,EAAE,eAAe,EAAE,QAAQ,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,GAAG,UAAU,EAAE,GAAG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,eAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;KAC9E,CAAA;AACH,CAAC;AARD,kCAQC"}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import algosdk, { ABIArgument, Algodv2, Indexer, SuggestedParams } from 'algosdk';
|
|
2
|
-
import { AppCallArgs, AppReference, RawAppCallArgs } from './app';
|
|
3
|
-
import { AppLookup, AppMetadata, OnSchemaBreak, OnUpdate, TealTemplateParameters } from './deploy-app';
|
|
4
|
-
import { SendTransactionFrom, SendTransactionParams, TransactionNote } from './transaction';
|
|
5
|
-
import { AppSpec } from './types/appspec';
|
|
6
|
-
export declare class ApplicationClient {
|
|
7
|
-
private algod;
|
|
8
|
-
private indexer;
|
|
9
|
-
private appSpec;
|
|
10
|
-
private sender;
|
|
11
|
-
private params;
|
|
12
|
-
private existingDeployments;
|
|
13
|
-
private _appIndex;
|
|
14
|
-
private _appAddress;
|
|
15
|
-
private _creator;
|
|
16
|
-
constructor(appDetails: {
|
|
17
|
-
/** The ARC-0032 application spec as either:
|
|
18
|
-
* * Parsed JSON @see {AppSpec}
|
|
19
|
-
* * Raw JSON string
|
|
20
|
-
*/
|
|
21
|
-
app: AppSpec | string;
|
|
22
|
-
/** Default sender to use for transactions issued by this application client */
|
|
23
|
-
sender?: SendTransactionFrom;
|
|
24
|
-
/** Default suggested params object to use */
|
|
25
|
-
params?: SuggestedParams;
|
|
26
|
-
} & ({
|
|
27
|
-
/** The index of an existing app to call using this client */
|
|
28
|
-
index: number;
|
|
29
|
-
} | {
|
|
30
|
-
/** The address of the app creator account */
|
|
31
|
-
creatorAddress: string;
|
|
32
|
-
/** Optional cached value of the existing apps for the given creator */
|
|
33
|
-
existingDeployments?: AppLookup;
|
|
34
|
-
}), algod: Algodv2, indexer: Indexer);
|
|
35
|
-
/**
|
|
36
|
-
* Idempotently deploy (create, update/delete if changed) an app against the given name via the given creator account, including deploy-time template placeholder substitutions.
|
|
37
|
-
*
|
|
38
|
-
* 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
|
|
39
|
-
*
|
|
40
|
-
* **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.
|
|
41
|
-
*
|
|
42
|
-
* **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.
|
|
43
|
-
* @param deploy Deployment details
|
|
44
|
-
* @returns The metadata and transaction result(s) of the deployment, or just the metadata if it didn't need to issue transactions
|
|
45
|
-
*/
|
|
46
|
-
deploy(deploy: {
|
|
47
|
-
/** The version of the contract, e.g. "1.0" */
|
|
48
|
-
version: string;
|
|
49
|
-
/** The optional sender to send the transaction from, will use the application client's default sender by default if specified */
|
|
50
|
-
sender?: SendTransactionFrom;
|
|
51
|
-
/** Whether or not to allow updates in the contract using the deploy-time updatability control if present in your contract.
|
|
52
|
-
* If this is not specified then it will automatically be determined based on the AppSpec definition
|
|
53
|
-
**/
|
|
54
|
-
allowUpdate?: boolean;
|
|
55
|
-
/** Whether or not to allow deletes in the contract using the deploy-time deletability control if present in your contract.
|
|
56
|
-
* If this is not specified then it will automatically be determined based on the AppSpec definition
|
|
57
|
-
**/
|
|
58
|
-
allowDelete?: boolean;
|
|
59
|
-
/** Parameters to control transaction sending */
|
|
60
|
-
sendParams?: Omit<SendTransactionParams, 'args' | 'skipSending' | 'skipWaiting'>;
|
|
61
|
-
/** Any deploy-time parameters to replace in the TEAL code */
|
|
62
|
-
deployTimeParameters?: TealTemplateParameters;
|
|
63
|
-
/** What action to perform if a schema break is detected */
|
|
64
|
-
onSchemaBreak?: 'replace' | 'fail' | OnSchemaBreak;
|
|
65
|
-
/** What action to perform if a TEAL update is detected */
|
|
66
|
-
onUpdate?: 'update' | 'replace' | 'fail' | OnUpdate;
|
|
67
|
-
/** Any args to pass to any create transaction that is issued as part of deployment */
|
|
68
|
-
createArgs?: AppCallArgs;
|
|
69
|
-
/** Any args to pass to any update transaction that is issued as part of deployment */
|
|
70
|
-
updateArgs?: AppCallArgs;
|
|
71
|
-
/** Any args to pass to any delete transaction that is issued as part of deployment */
|
|
72
|
-
deleteArgs?: AppCallArgs;
|
|
73
|
-
}): Promise<import("./transaction").SendTransactionResult & AppMetadata & {
|
|
74
|
-
deleteResult?: import("./transaction").SendTransactionResult | undefined;
|
|
75
|
-
}>;
|
|
76
|
-
create(create?: {
|
|
77
|
-
sender?: SendTransactionFrom;
|
|
78
|
-
args?: AppCallArgs;
|
|
79
|
-
note?: TransactionNote;
|
|
80
|
-
sendParams?: SendTransactionParams;
|
|
81
|
-
deployTimeParameters?: TealTemplateParameters;
|
|
82
|
-
}): Promise<import("./app").AppCallTransactionResult & AppReference>;
|
|
83
|
-
update(update?: {
|
|
84
|
-
sender?: SendTransactionFrom;
|
|
85
|
-
args?: AppCallArgs;
|
|
86
|
-
note?: TransactionNote;
|
|
87
|
-
sendParams?: SendTransactionParams;
|
|
88
|
-
deployTimeParameters?: TealTemplateParameters;
|
|
89
|
-
}): Promise<import("./app").AppCallTransactionResult>;
|
|
90
|
-
call(call: {
|
|
91
|
-
callType: 'optin' | 'closeout' | 'clearstate' | 'delete' | 'normal';
|
|
92
|
-
sender?: SendTransactionFrom;
|
|
93
|
-
note?: TransactionNote;
|
|
94
|
-
sendParams?: SendTransactionParams;
|
|
95
|
-
} & ({
|
|
96
|
-
/** If calling an ABI method then either the name of the method, or the ABI signature, if undefined then a bare call will be made */
|
|
97
|
-
method: string;
|
|
98
|
-
/** The ABI args to pass in */
|
|
99
|
-
methodArgs: ABIArgument[];
|
|
100
|
-
/** The optional lease for the transaction */
|
|
101
|
-
lease?: string | Uint8Array;
|
|
102
|
-
} | {
|
|
103
|
-
args: RawAppCallArgs;
|
|
104
|
-
})): Promise<import("./app").AppCallTransactionResult>;
|
|
105
|
-
getABIMethod(method: string): algosdk.ABIMethod | undefined;
|
|
106
|
-
private loadAppReference;
|
|
107
|
-
}
|
|
108
|
-
//# sourceMappingURL=application-client.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"application-client.d.ts","sourceRoot":"","sources":["../src/application-client.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAE,WAAW,EAAE,OAAO,EAAyB,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAExG,OAAO,EAAE,WAAW,EAAE,YAAY,EAAsB,cAAc,EAAa,MAAM,OAAO,CAAA;AAChG,OAAO,EACL,SAAS,EACT,WAAW,EAGX,aAAa,EACb,QAAQ,EAER,sBAAsB,EACvB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAoB,mBAAmB,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC7G,OAAO,EAAE,OAAO,EAAmB,MAAM,iBAAiB,CAAA;AAE1D,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAiC;IAC/C,OAAO,CAAC,MAAM,CAA6B;IAC3C,OAAO,CAAC,mBAAmB,CAAuB;IAElD,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,WAAW,CAAQ;IAC3B,OAAO,CAAC,QAAQ,CAAoB;gBAGlC,UAAU,EAAE;QACV;;;WAGG;QACH,GAAG,EAAE,OAAO,GAAG,MAAM,CAAA;QACrB,+EAA+E;QAC/E,MAAM,CAAC,EAAE,mBAAmB,CAAA;QAC5B,6CAA6C;QAC7C,MAAM,CAAC,EAAE,eAAe,CAAA;KACzB,GAAG,CACA;QACE,6DAA6D;QAC7D,KAAK,EAAE,MAAM,CAAA;KACd,GACD;QACE,6CAA6C;QAC7C,cAAc,EAAE,MAAM,CAAA;QACtB,uEAAuE;QACvE,mBAAmB,CAAC,EAAE,SAAS,CAAA;KAChC,C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