@algorandfoundation/algokit-utils 1.0.0-beta.8 → 1.0.0-beta.9
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 +87 -0
- package/account.d.ts.map +1 -0
- package/account.js +144 -0
- package/account.js.map +1 -0
- package/algo-amount.d.ts +18 -0
- package/algo-amount.d.ts.map +1 -0
- package/algo-amount.js +31 -0
- package/algo-amount.js.map +1 -0
- package/algo-http-client-with-retry.d.ts +14 -0
- package/algo-http-client-with-retry.d.ts.map +1 -0
- package/algo-http-client-with-retry.js +62 -0
- package/algo-http-client-with-retry.js.map +1 -0
- package/app.d.ts +189 -0
- package/app.d.ts.map +1 -0
- package/app.js +265 -0
- package/app.js.map +1 -0
- package/application-client.d.ts +113 -0
- package/application-client.d.ts.map +1 -0
- package/application-client.js +258 -0
- package/application-client.js.map +1 -0
- package/config.d.ts +27 -0
- package/config.d.ts.map +1 -0
- package/config.js +46 -0
- package/config.js.map +1 -0
- package/deploy-app.d.ts +164 -0
- package/deploy-app.d.ts.map +1 -0
- package/deploy-app.js +419 -0
- package/deploy-app.js.map +1 -0
- package/index.d.ts +12 -0
- package/index.d.ts.map +1 -0
- package/index.js.map +1 -0
- package/indexer-lookup.d.ts +31 -0
- package/indexer-lookup.d.ts.map +1 -0
- package/indexer-lookup.js +96 -0
- package/indexer-lookup.js.map +1 -0
- package/localnet.d.ts +54 -0
- package/localnet.d.ts.map +1 -0
- package/localnet.js +121 -0
- package/localnet.js.map +1 -0
- package/network-client.d.ts +102 -0
- package/network-client.d.ts.map +1 -0
- package/network-client.js +182 -0
- package/network-client.js.map +1 -0
- package/package.json +2 -2
- package/transaction.d.ts +157 -0
- package/transaction.d.ts.map +1 -0
- package/transaction.js +306 -0
- package/transaction.js.map +1 -0
- package/transfer.d.ts +24 -0
- package/transfer.d.ts.map +1 -0
- package/transfer.js +33 -0
- package/transfer.js.map +1 -0
- package/types/algod.d.ts +124 -0
- package/types/algod.d.ts.map +1 -0
- package/types/algod.js +3 -0
- package/types/algod.js.map +1 -0
- package/types/appspec.d.ts +78 -0
- package/types/appspec.d.ts.map +1 -0
- package/types/appspec.js +15 -0
- package/types/appspec.js.map +1 -0
- package/types/indexer.d.ts +314 -0
- package/types/indexer.d.ts.map +1 -0
- package/types/indexer.js +25 -0
- package/types/indexer.js.map +1 -0
- package/urlTokenBaseHTTPClient.d.ts +41 -0
- package/urlTokenBaseHTTPClient.d.ts.map +1 -0
- package/urlTokenBaseHTTPClient.js +151 -0
- package/urlTokenBaseHTTPClient.js.map +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../src/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEvI,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE1C,OAAO,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAA;AAE1D,qEAAqE;AACrE,qBAAa,eAAe;IAC1B,OAAO,EAAE,OAAO,CAAC,gBAAgB,CAAA;IACjC,gBAAgB,EAAE,CAAC,OAAO,CAAC,OAAO,GAAG,cAAc,CAAC,EAAE,CAAA;IACtD,KAAK,EAAE,MAAM,CAAA;IAEb,IAAI,MAAM,IAAI,QAAQ,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAE/C;IAED,IAAI,eAAe,IAAI,QAAQ,CAAC,CAAC,OAAO,CAAC,OAAO,GAAG,cAAc,CAAC,EAAE,CAAC,CAEpE;IAED,IAAI,IAAI,IAAI,QAAQ,CAAC,MAAM,CAAC,CAE3B;gBAEW,cAAc,EAAE,gBAAgB,EAAE,eAAe,EAAE,CAAC,OAAO,GAAG,cAAc,CAAC,EAAE;IAMpF,IAAI,CAAC,WAAW,EAAE,WAAW,GA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B/F;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS,EAAE,KAAK,EAAE,OAAO,oCAE7F"}
|
package/transaction.js
ADDED
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getTransactionParams = exports.capTransactionFee = exports.waitForConfirmation = exports.sendGroupOfTransactions = exports.sendTransaction = exports.getSenderAddress = exports.encodeTransactionNote = exports.SigningAccount = exports.MultisigAccount = void 0;
|
|
7
|
+
const algosdk_1 = __importDefault(require("algosdk"));
|
|
8
|
+
const buffer_1 = require("buffer");
|
|
9
|
+
const config_1 = require("./config");
|
|
10
|
+
/** Account wrapper that supports partial or full multisig signing */
|
|
11
|
+
class MultisigAccount {
|
|
12
|
+
get params() {
|
|
13
|
+
return this._params;
|
|
14
|
+
}
|
|
15
|
+
get signingAccounts() {
|
|
16
|
+
return this._signingAccounts;
|
|
17
|
+
}
|
|
18
|
+
get addr() {
|
|
19
|
+
return this._addr;
|
|
20
|
+
}
|
|
21
|
+
constructor(multisigParams, signingAccounts) {
|
|
22
|
+
this._params = multisigParams;
|
|
23
|
+
this._signingAccounts = signingAccounts;
|
|
24
|
+
this._addr = algosdk_1.default.multisigAddress(multisigParams);
|
|
25
|
+
}
|
|
26
|
+
sign(transaction) {
|
|
27
|
+
let signedTxn = 'from' in transaction ? undefined : transaction;
|
|
28
|
+
for (const signer of this._signingAccounts) {
|
|
29
|
+
if (signedTxn) {
|
|
30
|
+
signedTxn = algosdk_1.default.appendSignMultisigTransaction(signedTxn, this._params, signer.sk).blob;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
signedTxn = algosdk_1.default.signMultisigTransaction(transaction, this._params, signer.sk).blob;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
37
|
+
return signedTxn;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.MultisigAccount = MultisigAccount;
|
|
41
|
+
/** Account wrapper that supports a rekeyed account */
|
|
42
|
+
class SigningAccount {
|
|
43
|
+
/**
|
|
44
|
+
* Algorand address of the sender
|
|
45
|
+
*/
|
|
46
|
+
get addr() {
|
|
47
|
+
return this._sender;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Secret key belonging to the signer
|
|
51
|
+
*/
|
|
52
|
+
get sk() {
|
|
53
|
+
return this._account.sk;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Algorand account of the underlying signing account
|
|
57
|
+
*/
|
|
58
|
+
get signer() {
|
|
59
|
+
return this._account;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Algorand account of the sender address and signer private key
|
|
63
|
+
*/
|
|
64
|
+
get sender() {
|
|
65
|
+
return {
|
|
66
|
+
addr: this._sender,
|
|
67
|
+
sk: this._account.sk,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
constructor(account, sender) {
|
|
71
|
+
this._account = account;
|
|
72
|
+
this._sender = sender ?? account.addr;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.SigningAccount = SigningAccount;
|
|
76
|
+
/** Encodes a transaction note into a byte array ready to be included in an Algorand transaction.
|
|
77
|
+
*
|
|
78
|
+
* @param note The transaction note
|
|
79
|
+
* @returns the transaction note ready for inclusion in a transaction
|
|
80
|
+
*
|
|
81
|
+
* Case on the value of `data` this either either be:
|
|
82
|
+
* * `null` | `undefined`: `undefined`
|
|
83
|
+
* * `string`: The string value
|
|
84
|
+
* * Uint8Array: passthrough
|
|
85
|
+
* * Arc2TransactionNote object: ARC-0002 compatible transaction note
|
|
86
|
+
* * Else: The object/value converted into a JSON string representation
|
|
87
|
+
*/
|
|
88
|
+
function encodeTransactionNote(note) {
|
|
89
|
+
if (note == null || typeof note === 'undefined') {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
else if (typeof note === 'object' && note.constructor === Uint8Array) {
|
|
93
|
+
return note;
|
|
94
|
+
}
|
|
95
|
+
else if (typeof note === 'object' && 'dAppName' in note) {
|
|
96
|
+
const arc2Payload = `${note.dAppName}:${note.format}${note.data}`;
|
|
97
|
+
const encoder = new TextEncoder();
|
|
98
|
+
return encoder.encode(arc2Payload);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
const n = typeof note === 'string' ? note : JSON.stringify(note);
|
|
102
|
+
const encoder = new TextEncoder();
|
|
103
|
+
return encoder.encode(n);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
exports.encodeTransactionNote = encodeTransactionNote;
|
|
107
|
+
/**
|
|
108
|
+
* Returns the public address of the given transaction sender.
|
|
109
|
+
* @param sender A transaction sender
|
|
110
|
+
* @returns The public address
|
|
111
|
+
*/
|
|
112
|
+
const getSenderAddress = function (sender) {
|
|
113
|
+
return 'addr' in sender ? sender.addr : sender.address();
|
|
114
|
+
};
|
|
115
|
+
exports.getSenderAddress = getSenderAddress;
|
|
116
|
+
/** Signs and sends the given transaction to the chain
|
|
117
|
+
*
|
|
118
|
+
* @param send The details for the transaction to send, including:
|
|
119
|
+
* * `transaction`: The unsigned transaction
|
|
120
|
+
* * `from`: The account to sign the transaction with: either an account with private key loaded or a logic signature account
|
|
121
|
+
* * `config`: The sending configuration for this transaction
|
|
122
|
+
* @param algod An algod client
|
|
123
|
+
*
|
|
124
|
+
* @returns An object with transaction (`transaction`) and (if `skipWaiting` is `false` or unset) confirmation (`confirmation`)
|
|
125
|
+
*/
|
|
126
|
+
const sendTransaction = async function (send, algod) {
|
|
127
|
+
const { transaction, from, sendParams } = send;
|
|
128
|
+
const { skipSending, skipWaiting, maxFee, suppressLog, maxRoundsToWaitForConfirmation } = sendParams ?? {};
|
|
129
|
+
if (maxFee !== undefined) {
|
|
130
|
+
capTransactionFee(transaction, maxFee);
|
|
131
|
+
}
|
|
132
|
+
if (skipSending) {
|
|
133
|
+
return { transaction };
|
|
134
|
+
}
|
|
135
|
+
const signedTransaction = 'sk' in from
|
|
136
|
+
? transaction.signTxn(from.sk)
|
|
137
|
+
: 'lsig' in from
|
|
138
|
+
? algosdk_1.default.signLogicSigTransactionObject(transaction, from).blob
|
|
139
|
+
: 'signer' in from
|
|
140
|
+
? (await from.signer([transaction], [0]))[0]
|
|
141
|
+
: from.sign(transaction);
|
|
142
|
+
await algod.sendRawTransaction(signedTransaction).do();
|
|
143
|
+
config_1.AlgoKitConfig.getLogger(suppressLog).info(`Sent transaction ID ${transaction.txID()} ${transaction.type} from ${(0, exports.getSenderAddress)(from)}`);
|
|
144
|
+
let confirmation = undefined;
|
|
145
|
+
if (!skipWaiting) {
|
|
146
|
+
confirmation = await (0, exports.waitForConfirmation)(transaction.txID(), maxRoundsToWaitForConfirmation ?? 5, algod);
|
|
147
|
+
}
|
|
148
|
+
return { transaction, confirmation };
|
|
149
|
+
};
|
|
150
|
+
exports.sendTransaction = sendTransaction;
|
|
151
|
+
const groupBy = (array, predicate) => array.reduce((acc, value, index, array) => {
|
|
152
|
+
var _a;
|
|
153
|
+
;
|
|
154
|
+
(acc[_a = predicate(value, index, array)] || (acc[_a] = [])).push(value);
|
|
155
|
+
return acc;
|
|
156
|
+
}, {});
|
|
157
|
+
/**
|
|
158
|
+
* Signs and sends a group of [up to 16](https://developer.algorand.org/docs/get-details/atomic_transfers/#create-transactions) transactions to the chain
|
|
159
|
+
*
|
|
160
|
+
* @param groupSend The group details to send, with:
|
|
161
|
+
* * `transactions`: The array of transactions to send along with their signing account
|
|
162
|
+
* * `sendParams`: The parameters to dictate how the group is sent
|
|
163
|
+
* @param algod An algod client
|
|
164
|
+
* @returns An object with group transaction ID (`groupTransactionId`) and (if `skipWaiting` is `false` or unset) confirmation (`confirmation`)
|
|
165
|
+
*/
|
|
166
|
+
const sendGroupOfTransactions = async function (groupSend, algod) {
|
|
167
|
+
const { transactions, sendParams } = groupSend;
|
|
168
|
+
const transactionsToSend = transactions.map((t) => {
|
|
169
|
+
return t.transaction;
|
|
170
|
+
});
|
|
171
|
+
const group = algosdk_1.default.assignGroupID(transactionsToSend);
|
|
172
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
173
|
+
const groupId = buffer_1.Buffer.from(group[0].group).toString('base64');
|
|
174
|
+
config_1.AlgoKitConfig.getLogger(sendParams?.suppressLog).info(`Sending group of transactions (${groupId})`, { transactionsToSend });
|
|
175
|
+
// Sign transactions either using TransactionSigners, or not
|
|
176
|
+
let signedTransactions;
|
|
177
|
+
if (transactions.find((t) => 'signer' in t.signer)) {
|
|
178
|
+
// Validate all or nothing for transaction signers
|
|
179
|
+
if (transactions.find((t) => !('signer' in t.signer))) {
|
|
180
|
+
throw new Error("When issuing a group transaction the signers should either all be TransactionSignerAccount's or all not. " +
|
|
181
|
+
'Received at least one TransactionSignerAccount, but not all of them so failing the send.');
|
|
182
|
+
}
|
|
183
|
+
// Group transaction signers by signer
|
|
184
|
+
const groupedBySigner = groupBy(transactions.map((t, i) => ({
|
|
185
|
+
signer: t.signer,
|
|
186
|
+
index: i,
|
|
187
|
+
})), (t) => t.signer.addr);
|
|
188
|
+
// Perform the signature, grouped by signer
|
|
189
|
+
const signed = (await Promise.all(Object.values(groupedBySigner).map(async (signature) => {
|
|
190
|
+
const indexes = signature.map((s) => s.index);
|
|
191
|
+
const signed = await signature[0].signer.signer(group, indexes);
|
|
192
|
+
return signed.map((txn, i) => ({
|
|
193
|
+
txn,
|
|
194
|
+
index: indexes[i],
|
|
195
|
+
}));
|
|
196
|
+
}))).flatMap((a) => a);
|
|
197
|
+
// Extract the signed transactions in order
|
|
198
|
+
signedTransactions = signed.sort((s1, s2) => s1.index - s2.index).map((s) => s.txn);
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
signedTransactions = group.map((groupedTransaction, index) => {
|
|
202
|
+
const signer = transactions[index].signer;
|
|
203
|
+
return 'sk' in signer
|
|
204
|
+
? groupedTransaction.signTxn(signer.sk)
|
|
205
|
+
: 'lsig' in signer
|
|
206
|
+
? algosdk_1.default.signLogicSigTransactionObject(groupedTransaction, signer).blob
|
|
207
|
+
: 'sign' in signer
|
|
208
|
+
? signer.sign(groupedTransaction)
|
|
209
|
+
: // This bit will never happen because above if statement
|
|
210
|
+
new Uint8Array();
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
config_1.AlgoKitConfig.getLogger(sendParams?.suppressLog).debug(`Signer IDs (${groupId})`, transactions.map((t) => (0, exports.getSenderAddress)(t.signer)));
|
|
214
|
+
config_1.AlgoKitConfig.getLogger(sendParams?.suppressLog).debug(`Transaction IDs (${groupId})`, transactionsToSend.map((t) => t.txID()));
|
|
215
|
+
// https://developer.algorand.org/docs/rest-apis/algod/v2/#post-v2transactions
|
|
216
|
+
await algod.sendRawTransaction(signedTransactions).do();
|
|
217
|
+
config_1.AlgoKitConfig.getLogger(sendParams?.suppressLog).info(`Group transaction (${groupId}) sent with ${transactionsToSend.length} transactions`);
|
|
218
|
+
let confirmations = undefined;
|
|
219
|
+
if (!sendParams?.skipWaiting) {
|
|
220
|
+
confirmations = await Promise.all(transactionsToSend.map(async (t) => await (0, exports.waitForConfirmation)(t.txID(), sendParams?.maxRoundsToWaitForConfirmation ?? 5, algod)));
|
|
221
|
+
}
|
|
222
|
+
return {
|
|
223
|
+
groupId,
|
|
224
|
+
confirmations,
|
|
225
|
+
txIds: transactionsToSend.map((t) => t.txID()),
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
exports.sendGroupOfTransactions = sendGroupOfTransactions;
|
|
229
|
+
/**
|
|
230
|
+
* Wait until the transaction is confirmed or rejected, or until `timeout`
|
|
231
|
+
* number of rounds have passed.
|
|
232
|
+
*
|
|
233
|
+
* @param algod An algod client
|
|
234
|
+
* @param transactionId The transaction ID to wait for
|
|
235
|
+
* @param maxRoundsToWait Maximum number of rounds to wait
|
|
236
|
+
*
|
|
237
|
+
* @return Pending transaction information
|
|
238
|
+
* @throws Throws an error if the transaction is not confirmed or rejected in the next `timeout` rounds
|
|
239
|
+
*/
|
|
240
|
+
const waitForConfirmation = async function (transactionId, maxRoundsToWait, algod) {
|
|
241
|
+
if (maxRoundsToWait < 0) {
|
|
242
|
+
throw new Error(`Invalid timeout, received ${maxRoundsToWait}, expected > 0`);
|
|
243
|
+
}
|
|
244
|
+
// Get current round
|
|
245
|
+
const status = await algod.status().do();
|
|
246
|
+
if (status === undefined) {
|
|
247
|
+
throw new Error('Unable to get node status');
|
|
248
|
+
}
|
|
249
|
+
// Loop for up to `timeout` rounds looking for a confirmed transaction
|
|
250
|
+
const startRound = status['last-round'] + 1;
|
|
251
|
+
let currentRound = startRound;
|
|
252
|
+
while (currentRound < startRound + maxRoundsToWait) {
|
|
253
|
+
const pendingInfo = (await algod.pendingTransactionInformation(transactionId).do());
|
|
254
|
+
if (pendingInfo !== undefined) {
|
|
255
|
+
const confirmedRound = pendingInfo['confirmed-round'];
|
|
256
|
+
if (confirmedRound && confirmedRound > 0) {
|
|
257
|
+
return pendingInfo;
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
const poolError = pendingInfo['pool-error'];
|
|
261
|
+
if (poolError != null && poolError.length > 0) {
|
|
262
|
+
// If there was a pool error, then the transaction has been rejected!
|
|
263
|
+
throw new Error(`Transaction ${transactionId} was rejected; pool error: ${poolError}`);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
await algod.statusAfterBlock(currentRound).do();
|
|
268
|
+
currentRound++;
|
|
269
|
+
}
|
|
270
|
+
throw new Error(`Transaction ${transactionId} not confirmed after ${maxRoundsToWait} rounds`);
|
|
271
|
+
};
|
|
272
|
+
exports.waitForConfirmation = waitForConfirmation;
|
|
273
|
+
/**
|
|
274
|
+
* Limit the acceptable fee to a defined amount of µALGOs.
|
|
275
|
+
* This also sets the transaction to be flatFee to ensure the transaction only succeeds at
|
|
276
|
+
* the estimated rate.
|
|
277
|
+
* @param transaction The transaction to cap
|
|
278
|
+
* @param maxAcceptableFee The maximum acceptable fee to pay
|
|
279
|
+
*/
|
|
280
|
+
function capTransactionFee(transaction, maxAcceptableFee) {
|
|
281
|
+
// If a flat fee hasn't already been defined
|
|
282
|
+
if (!transaction.flatFee) {
|
|
283
|
+
// Once a transaction has been constructed by algosdk, transaction.fee indicates what the total transaction fee
|
|
284
|
+
// Will be based on the current suggested fee-per-byte value.
|
|
285
|
+
if (transaction.fee > maxAcceptableFee.microAlgos) {
|
|
286
|
+
throw new Error(`Cancelled transaction due to high network congestion fees. Algorand suggested fees would cause this transaction to cost ${transaction.fee} µALGOs. Cap for this transaction is ${maxAcceptableFee.microAlgos} µALGOs.`);
|
|
287
|
+
}
|
|
288
|
+
else if (transaction.fee > algosdk_1.default.ALGORAND_MIN_TX_FEE) {
|
|
289
|
+
config_1.AlgoKitConfig.logger.warn(`Algorand network congestion fees are in effect. This transaction will incur a fee of ${transaction.fee} µALGOs.`);
|
|
290
|
+
}
|
|
291
|
+
// Now set the flat on the transaction. Otherwise the network may increase the fee above our cap and perform the transaction.
|
|
292
|
+
transaction.flatFee = true;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
exports.capTransactionFee = capTransactionFee;
|
|
296
|
+
/**
|
|
297
|
+
* Returns suggested transaction parameters from algod unless some are already provided.
|
|
298
|
+
* @param params Optionally provide parameters to use
|
|
299
|
+
* @param algod Algod algod
|
|
300
|
+
* @returns The suggested transaction parameters
|
|
301
|
+
*/
|
|
302
|
+
async function getTransactionParams(params, algod) {
|
|
303
|
+
return params ?? (await algod.getTransactionParams().do());
|
|
304
|
+
}
|
|
305
|
+
exports.getTransactionParams = getTransactionParams;
|
|
306
|
+
//# sourceMappingURL=transaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction.js","sourceRoot":"","sources":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;YACjD,MAAM,IAAI,KAAK,CACb,2HAA2H,WAAW,CAAC,GAAG,wCAAwC,gBAAgB,CAAC,UAAU,UAAU,CACxN,CAAA;SACF;aAAM,IAAI,WAAW,CAAC,GAAG,GAAG,iBAAO,CAAC,mBAAmB,EAAE;YACxD,sBAAa,CAAC,MAAM,CAAC,IAAI,CACvB,wFAAwF,WAAW,CAAC,GAAG,UAAU,CAClH,CAAA;SACF;QAED,6HAA6H;QAC7H,WAAW,CAAC,OAAO,GAAG,IAAI,CAAA;KAC3B;AACH,CAAC;AAlBD,8CAkBC;AAED;;;;;GAKG;AACI,KAAK,UAAU,oBAAoB,CAAC,MAAmC,EAAE,KAAc;IAC5F,OAAO,MAAM,IAAI,CAAC,MAAM,KAAK,CAAC,oBAAoB,EAAE,CAAC,EAAE,EAAE,CAAC,CAAA;AAC5D,CAAC;AAFD,oDAEC"}
|
package/transfer.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Algodv2, SuggestedParams } from 'algosdk';
|
|
2
|
+
import { AlgoAmount } from './algo-amount';
|
|
3
|
+
import { SendTransactionFrom, SendTransactionParams, SendTransactionResult, TransactionNote } from './transaction';
|
|
4
|
+
interface AlgoTransferParams extends SendTransactionParams {
|
|
5
|
+
/** The account (with private key loaded) that will send the µALGOs */
|
|
6
|
+
from: SendTransactionFrom;
|
|
7
|
+
/** The account address that will receive the ALGOs */
|
|
8
|
+
to: string;
|
|
9
|
+
/** The amount to send */
|
|
10
|
+
amount: AlgoAmount;
|
|
11
|
+
/** Optional transaction parameters */
|
|
12
|
+
transactionParams?: SuggestedParams;
|
|
13
|
+
/** The (optional) transaction note */
|
|
14
|
+
note?: TransactionNote;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Transfer ALGOs between two accounts.
|
|
18
|
+
* @param transfer The transfer definition
|
|
19
|
+
* @param algod An algod client
|
|
20
|
+
* @returns The transaction object and optionally the confirmation if it was sent to the chain (`skipSending` is `false` or unset)
|
|
21
|
+
*/
|
|
22
|
+
export declare function transferAlgos(transfer: AlgoTransferParams, algod: Algodv2): Promise<SendTransactionResult>;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=transfer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transfer.d.ts","sourceRoot":"","sources":["../src/transfer.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE1C,OAAO,EAKL,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EAChB,MAAM,eAAe,CAAA;AAEtB,UAAU,kBAAmB,SAAQ,qBAAqB;IACxD,sEAAsE;IACtE,IAAI,EAAE,mBAAmB,CAAA;IACzB,sDAAsD;IACtD,EAAE,EAAE,MAAM,CAAA;IACV,yBAAyB;IACzB,MAAM,EAAE,UAAU,CAAA;IAClB,sCAAsC;IACtC,iBAAiB,CAAC,EAAE,eAAe,CAAA;IACnC,sCAAsC;IACtC,IAAI,CAAC,EAAE,eAAe,CAAA;CACvB;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CAAC,QAAQ,EAAE,kBAAkB,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAkBhH"}
|
package/transfer.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.transferAlgos = void 0;
|
|
7
|
+
const algosdk_1 = __importDefault(require("algosdk"));
|
|
8
|
+
const config_1 = require("./config");
|
|
9
|
+
const transaction_1 = require("./transaction");
|
|
10
|
+
/**
|
|
11
|
+
* Transfer ALGOs between two accounts.
|
|
12
|
+
* @param transfer The transfer definition
|
|
13
|
+
* @param algod An algod client
|
|
14
|
+
* @returns The transaction object and optionally the confirmation if it was sent to the chain (`skipSending` is `false` or unset)
|
|
15
|
+
*/
|
|
16
|
+
async function transferAlgos(transfer, algod) {
|
|
17
|
+
const { from, to, amount, note, transactionParams, ...sendParams } = transfer;
|
|
18
|
+
const transaction = algosdk_1.default.makePaymentTxnWithSuggestedParamsFromObject({
|
|
19
|
+
from: (0, transaction_1.getSenderAddress)(from),
|
|
20
|
+
to: to,
|
|
21
|
+
amount: amount.microAlgos,
|
|
22
|
+
note: (0, transaction_1.encodeTransactionNote)(note),
|
|
23
|
+
suggestedParams: await (0, transaction_1.getTransactionParams)(transactionParams, algod),
|
|
24
|
+
closeRemainderTo: undefined,
|
|
25
|
+
rekeyTo: undefined,
|
|
26
|
+
});
|
|
27
|
+
if (!sendParams.skipSending) {
|
|
28
|
+
config_1.AlgoKitConfig.getLogger(sendParams.suppressLog).debug(`Transferring ${amount.microAlgos}µALGOs from ${(0, transaction_1.getSenderAddress)(from)} to ${to}`);
|
|
29
|
+
}
|
|
30
|
+
return (0, transaction_1.sendTransaction)({ transaction, from, sendParams }, algod);
|
|
31
|
+
}
|
|
32
|
+
exports.transferAlgos = transferAlgos;
|
|
33
|
+
//# sourceMappingURL=transfer.js.map
|
package/transfer.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transfer.js","sourceRoot":"","sources":["../src/transfer.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA2D;AAE3D,qCAAwC;AACxC,+CASsB;AAetB;;;;;GAKG;AACI,KAAK,UAAU,aAAa,CAAC,QAA4B,EAAE,KAAc;IAC9E,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE,GAAG,UAAU,EAAE,GAAG,QAAQ,CAAA;IAE7E,MAAM,WAAW,GAAG,iBAAO,CAAC,2CAA2C,CAAC;QACtE,IAAI,EAAE,IAAA,8BAAgB,EAAC,IAAI,CAAC;QAC5B,EAAE,EAAE,EAAE;QACN,MAAM,EAAE,MAAM,CAAC,UAAU;QACzB,IAAI,EAAE,IAAA,mCAAqB,EAAC,IAAI,CAAC;QACjC,eAAe,EAAE,MAAM,IAAA,kCAAoB,EAAC,iBAAiB,EAAE,KAAK,CAAC;QACrE,gBAAgB,EAAE,SAAS;QAC3B,OAAO,EAAE,SAAS;KACnB,CAAC,CAAA;IAEF,IAAI,CAAC,UAAU,CAAC,WAAW,EAAE;QAC3B,sBAAa,CAAC,SAAS,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,gBAAgB,MAAM,CAAC,UAAU,eAAe,IAAA,8BAAgB,EAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;KACzI;IAED,OAAO,IAAA,6BAAe,EAAC,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,KAAK,CAAC,CAAA;AAClE,CAAC;AAlBD,sCAkBC"}
|
package/types/algod.d.ts
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { EncodedSignedTransaction } from 'algosdk';
|
|
2
|
+
/** The response from the pending transaction API @see https://developer.algorand.org/docs/rest-apis/algod/v2/#get-v2transactionspendingtxid */
|
|
3
|
+
export interface PendingTransactionResponse {
|
|
4
|
+
/**
|
|
5
|
+
* The application index if the transaction was found and it created an
|
|
6
|
+
* application.
|
|
7
|
+
*/
|
|
8
|
+
'application-index'?: number;
|
|
9
|
+
/**
|
|
10
|
+
* The number of the asset's unit that were transferred to the close-to address.
|
|
11
|
+
*/
|
|
12
|
+
'asset-closing-amount'?: number;
|
|
13
|
+
/**
|
|
14
|
+
* The asset index if the transaction was found and it created an asset.
|
|
15
|
+
*/
|
|
16
|
+
'asset-index'?: number;
|
|
17
|
+
/**
|
|
18
|
+
* Rewards in microalgos applied to the close remainder to account.
|
|
19
|
+
*/
|
|
20
|
+
'close-rewards'?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Closing amount for the transaction.
|
|
23
|
+
*/
|
|
24
|
+
'closing-amount'?: number;
|
|
25
|
+
/**
|
|
26
|
+
* The round where this transaction was confirmed, if present.
|
|
27
|
+
*/
|
|
28
|
+
'confirmed-round'?: number;
|
|
29
|
+
/**
|
|
30
|
+
* (gd) Global state key/value changes for the application being executed by this
|
|
31
|
+
* transaction.
|
|
32
|
+
*/
|
|
33
|
+
'global-state-delta'?: Record<string, EvalDelta>[];
|
|
34
|
+
/**
|
|
35
|
+
* Inner transactions produced by application execution.
|
|
36
|
+
*/
|
|
37
|
+
'inner-txns'?: PendingTransactionResponse[];
|
|
38
|
+
/**
|
|
39
|
+
* (ld) Local state key/value changes for the application being executed by this
|
|
40
|
+
* transaction.
|
|
41
|
+
*/
|
|
42
|
+
'local-state-delta'?: Record<string, EvalDelta>[];
|
|
43
|
+
/**
|
|
44
|
+
* (lg) Logs for the application being executed by this transaction.
|
|
45
|
+
*/
|
|
46
|
+
logs?: Uint8Array[];
|
|
47
|
+
/** Indicates that the transaction was kicked out of this node's transaction pool (and specifies why that happened).
|
|
48
|
+
* An empty string indicates the transaction wasn't kicked out of this node's txpool due to an error. */
|
|
49
|
+
'pool-error': string;
|
|
50
|
+
/**
|
|
51
|
+
* Rewards in µALGOs applied to the receiver account.
|
|
52
|
+
*/
|
|
53
|
+
'receiver-rewards'?: number;
|
|
54
|
+
/**
|
|
55
|
+
* Rewards in µALGOs applied to the sender account.
|
|
56
|
+
*/
|
|
57
|
+
'sender-rewards'?: number;
|
|
58
|
+
/**
|
|
59
|
+
* The raw signed transaction.
|
|
60
|
+
*/
|
|
61
|
+
txn: EncodedSignedTransaction;
|
|
62
|
+
}
|
|
63
|
+
/** Represents a TEAL value delta @see https://developer.algorand.org/docs/rest-apis/algod/v2/#evaldelta */
|
|
64
|
+
interface EvalDelta {
|
|
65
|
+
action: number;
|
|
66
|
+
bytes: string;
|
|
67
|
+
uint: number;
|
|
68
|
+
}
|
|
69
|
+
/** The response from the application API @see https://developer.algorand.org/docs/rest-apis/algod/v2/#get-v2applicationsapplication-id */
|
|
70
|
+
export interface ApplicationResponse {
|
|
71
|
+
id: number;
|
|
72
|
+
params: ApplicationParams;
|
|
73
|
+
}
|
|
74
|
+
/** Stores the global information associated with an application @see https://developer.algorand.org/docs/rest-apis/algod/v2/#applicationparams */
|
|
75
|
+
interface ApplicationParams {
|
|
76
|
+
/** Address of the account that created the app */
|
|
77
|
+
creator: string;
|
|
78
|
+
/** Base64 encoded TEAL approval program */
|
|
79
|
+
'approval-program': string;
|
|
80
|
+
/** Base64 encoded TEAL clear state program */
|
|
81
|
+
'clear-state-program': string;
|
|
82
|
+
/** The amount of extra program pages available to this app. */
|
|
83
|
+
'extra-program-pages'?: number;
|
|
84
|
+
/** Current global state values */
|
|
85
|
+
'global-state'?: {
|
|
86
|
+
key: string;
|
|
87
|
+
value: TealValue;
|
|
88
|
+
}[];
|
|
89
|
+
/** Global state schema */
|
|
90
|
+
'global-state-schema'?: ApplicationStateSchema;
|
|
91
|
+
/** Local state schema */
|
|
92
|
+
'local-state-schema'?: ApplicationStateSchema;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Represents a TEAL value @see https://developer.algorand.org/docs/rest-apis/algod/v2/#tealvalue
|
|
96
|
+
*/
|
|
97
|
+
type TealValue = {
|
|
98
|
+
/**
|
|
99
|
+
* (tt) value type. Value `1` refers to **bytes**, value `2` refers to **uint**
|
|
100
|
+
*/
|
|
101
|
+
type: 1;
|
|
102
|
+
/**
|
|
103
|
+
* (tb) bytes value.
|
|
104
|
+
*/
|
|
105
|
+
bytes: string;
|
|
106
|
+
} | {
|
|
107
|
+
/**
|
|
108
|
+
* (tt) value type. Value `1` refers to **bytes**, value `2` refers to **uint**
|
|
109
|
+
*/
|
|
110
|
+
type: 2;
|
|
111
|
+
/**
|
|
112
|
+
* (ui) uint value.
|
|
113
|
+
*/
|
|
114
|
+
uint: number | bigint;
|
|
115
|
+
};
|
|
116
|
+
/** Specifies maximums on the number of each type that may be stored @see https://developer.algorand.org/docs/rest-apis/algod/v2/#applicationstateschema */
|
|
117
|
+
export interface ApplicationStateSchema {
|
|
118
|
+
/** [nbs] num of byte slices */
|
|
119
|
+
'num-byte-slice': number;
|
|
120
|
+
/** [nui] num of uints */
|
|
121
|
+
'num-uint': number;
|
|
122
|
+
}
|
|
123
|
+
export {};
|
|
124
|
+
//# sourceMappingURL=algod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"algod.d.ts","sourceRoot":"","sources":["../../src/types/algod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAElD,+IAA+I;AAC/I,MAAM,WAAW,0BAA0B;IACzC;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B;;OAEG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAA;IAC/B;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B;;;OAGG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,CAAA;IAClD;;OAEG;IACH,YAAY,CAAC,EAAE,0BAA0B,EAAE,CAAA;IAC3C;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,CAAA;IACjD;;OAEG;IACH,IAAI,CAAC,EAAE,UAAU,EAAE,CAAA;IACnB;4GACwG;IACxG,YAAY,EAAE,MAAM,CAAA;IACpB;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB;;OAEG;IACH,GAAG,EAAE,wBAAwB,CAAA;CAC9B;AAED,2GAA2G;AAC3G,UAAU,SAAS;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;CACb;AAED,0IAA0I;AAC1I,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,iBAAiB,CAAA;CAC1B;AAED,kJAAkJ;AAClJ,UAAU,iBAAiB;IACzB,kDAAkD;IAClD,OAAO,EAAE,MAAM,CAAA;IACf,2CAA2C;IAC3C,kBAAkB,EAAE,MAAM,CAAA;IAC1B,8CAA8C;IAC9C,qBAAqB,EAAE,MAAM,CAAA;IAC7B,+DAA+D;IAC/D,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,kCAAkC;IAClC,cAAc,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,SAAS,CAAA;KAAE,EAAE,CAAA;IACpD,0BAA0B;IAC1B,qBAAqB,CAAC,EAAE,sBAAsB,CAAA;IAC9C,yBAAyB;IACzB,oBAAoB,CAAC,EAAE,sBAAsB,CAAA;CAC9C;AAED;;GAEG;AACH,KAAK,SAAS,GACV;IACE;;OAEG;IACH,IAAI,EAAE,CAAC,CAAA;IACP;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;CACd,GACD;IACE;;OAEG;IACH,IAAI,EAAE,CAAC,CAAA;IAEP;;OAEG;IACH,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;CACtB,CAAA;AAEL,2JAA2J;AAC3J,MAAM,WAAW,sBAAsB;IACrC,+BAA+B;IAC/B,gBAAgB,EAAE,MAAM,CAAA;IACxB,yBAAyB;IACzB,UAAU,EAAE,MAAM,CAAA;CACnB"}
|
package/types/algod.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"algod.js","sourceRoot":"","sources":["../../src/types/algod.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { ABIContractParams, ABIMethod, ABIMethodParams } from 'algosdk';
|
|
2
|
+
export interface AppSpec {
|
|
3
|
+
hints: HintSpec;
|
|
4
|
+
schema: SchemaSpec;
|
|
5
|
+
source: AppSources;
|
|
6
|
+
contract: ABIContractParams;
|
|
7
|
+
state: StateSchemaSpec;
|
|
8
|
+
bare_call_config: {
|
|
9
|
+
no_op?: CallConfigValue;
|
|
10
|
+
opt_in?: CallConfigValue;
|
|
11
|
+
close_out?: CallConfigValue;
|
|
12
|
+
clear_state?: CallConfigValue;
|
|
13
|
+
update_application?: CallConfigValue;
|
|
14
|
+
delete_application?: CallConfigValue;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export type HintSpec = Record<string, Hint>;
|
|
18
|
+
export interface AppSources {
|
|
19
|
+
approval: string;
|
|
20
|
+
clear: string;
|
|
21
|
+
}
|
|
22
|
+
export type CallConfigValue = 'NEVER' | 'CALL' | 'CREATE' | 'ALL';
|
|
23
|
+
export interface Hint {
|
|
24
|
+
structs: Record<string, Struct>;
|
|
25
|
+
readonly: boolean;
|
|
26
|
+
default_arguments: Record<string, DefaultArgument>;
|
|
27
|
+
call_config: {
|
|
28
|
+
no_op?: CallConfigValue;
|
|
29
|
+
opt_in?: CallConfigValue;
|
|
30
|
+
close_out?: CallConfigValue;
|
|
31
|
+
clear_state?: CallConfigValue;
|
|
32
|
+
update_application?: CallConfigValue;
|
|
33
|
+
delete_application?: CallConfigValue;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
type StructElement = [string, string];
|
|
37
|
+
export interface Struct {
|
|
38
|
+
name: string;
|
|
39
|
+
elements: StructElement[];
|
|
40
|
+
}
|
|
41
|
+
export interface DefaultArgument {
|
|
42
|
+
source: string;
|
|
43
|
+
data: string | bigint | number;
|
|
44
|
+
}
|
|
45
|
+
export declare enum AVMType {
|
|
46
|
+
uint64 = 0,
|
|
47
|
+
bytes = 1
|
|
48
|
+
}
|
|
49
|
+
export interface DeclaredSchemaValueSpec {
|
|
50
|
+
type: AVMType;
|
|
51
|
+
key: string;
|
|
52
|
+
desc: string;
|
|
53
|
+
static: boolean;
|
|
54
|
+
}
|
|
55
|
+
export interface ReservedSchemaValueSpec {
|
|
56
|
+
type: AVMType;
|
|
57
|
+
desc: string;
|
|
58
|
+
max_keys: number;
|
|
59
|
+
}
|
|
60
|
+
export interface SchemaSpec {
|
|
61
|
+
local: Schema;
|
|
62
|
+
global: Schema;
|
|
63
|
+
}
|
|
64
|
+
export interface Schema {
|
|
65
|
+
declared: Record<string, DeclaredSchemaValueSpec>;
|
|
66
|
+
reserved: Record<string, ReservedSchemaValueSpec>;
|
|
67
|
+
}
|
|
68
|
+
export interface StateSchemaSpec {
|
|
69
|
+
global: StateSchema;
|
|
70
|
+
local: StateSchema;
|
|
71
|
+
}
|
|
72
|
+
export type StateSchema = {
|
|
73
|
+
num_uints: number;
|
|
74
|
+
num_byte_slices: number;
|
|
75
|
+
};
|
|
76
|
+
export declare const getABISignature: (method: ABIMethodParams | ABIMethod) => string;
|
|
77
|
+
export {};
|
|
78
|
+
//# sourceMappingURL=appspec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appspec.d.ts","sourceRoot":"","sources":["../../src/types/appspec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAEvE,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,QAAQ,CAAA;IACf,MAAM,EAAE,UAAU,CAAA;IAClB,MAAM,EAAE,UAAU,CAAA;IAClB,QAAQ,EAAE,iBAAiB,CAAA;IAC3B,KAAK,EAAE,eAAe,CAAA;IACtB,gBAAgB,EAAE;QAChB,KAAK,CAAC,EAAE,eAAe,CAAA;QACvB,MAAM,CAAC,EAAE,eAAe,CAAA;QACxB,SAAS,CAAC,EAAE,eAAe,CAAA;QAC3B,WAAW,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AM,CAAA;IACZ,MAAM,EAAE,OAAO,CAAA;CAChB;AAED,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,OAAO,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,MAAM;IACrB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAA;IACjD,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAA;CAClD;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,WAAW,CAAA;IACnB,KAAK,EAAE,WAAW,CAAA;CACnB;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,SAAS,EAAE,MAAM,CAAA;IACjB,eAAe,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,eAAO,MAAM,eAAe,WAAY,eAAe,GAAG,SAAS,WAIlE,CAAA"}
|
package/types/appspec.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getABISignature = exports.AVMType = void 0;
|
|
4
|
+
var AVMType;
|
|
5
|
+
(function (AVMType) {
|
|
6
|
+
AVMType[AVMType["uint64"] = 0] = "uint64";
|
|
7
|
+
AVMType[AVMType["bytes"] = 1] = "bytes";
|
|
8
|
+
})(AVMType = exports.AVMType || (exports.AVMType = {}));
|
|
9
|
+
const getABISignature = (method) => {
|
|
10
|
+
const argSignature = method.args.map((a) => a.type).join(',');
|
|
11
|
+
const returnSignature = method.returns.type;
|
|
12
|
+
return `{${method.name}}(${argSignature})${returnSignature}`;
|
|
13
|
+
};
|
|
14
|
+
exports.getABISignature = getABISignature;
|
|
15
|
+
//# sourceMappingURL=appspec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appspec.js","sourceRoot":"","sources":["../../src/types/appspec.ts"],"names":[],"mappings":";;;AAoDA,IAAY,OAGX;AAHD,WAAY,OAAO;IACjB,yCAAM,CAAA;IACN,uCAAK,CAAA;AACP,CAAC,EAHW,OAAO,GAAP,eAAO,KAAP,eAAO,QAGlB;AAkCM,MAAM,eAAe,GAAG,CAAC,MAAmC,EAAE,EAAE;IACrE,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAC7D,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAA;IAC3C,OAAO,IAAI,MAAM,CAAC,IAAI,KAAK,YAAY,IAAI,eAAe,EAAE,CAAA;AAC9D,CAAC,CAAA;AAJY,QAAA,eAAe,mBAI3B"}
|