algosdk 3.6.0 → 3.7.0-beta.1
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/browser/algosdk.min.js +1 -1
- package/dist/browser/algosdk.min.js.map +1 -1
- package/dist/cjs/client/v2/algod/algod.js +0 -18
- package/dist/cjs/client/v2/algod/algod.js.map +1 -1
- package/dist/cjs/client/v2/algod/models/types.js +2 -434
- package/dist/cjs/client/v2/algod/models/types.js.map +1 -1
- package/dist/cjs/ed25519-signer.js +76 -0
- package/dist/cjs/ed25519-signer.js.map +1 -0
- package/dist/cjs/encoding/address.js +61 -1
- package/dist/cjs/encoding/address.js.map +1 -1
- package/dist/cjs/falcon-signer.js +17 -0
- package/dist/cjs/falcon-signer.js.map +1 -0
- package/dist/cjs/logicsig.js +201 -16
- package/dist/cjs/logicsig.js.map +1 -1
- package/dist/cjs/main.js +32 -63
- package/dist/cjs/main.js.map +1 -1
- package/dist/cjs/mnemonic/mnemonic.js +26 -1
- package/dist/cjs/mnemonic/mnemonic.js.map +1 -1
- package/dist/cjs/multisigSigning.js +78 -1
- package/dist/cjs/multisigSigning.js.map +1 -1
- package/dist/cjs/pq-signer.js +54 -0
- package/dist/cjs/pq-signer.js.map +1 -0
- package/dist/cjs/signedTransaction.js +15 -1
- package/dist/cjs/signedTransaction.js.map +1 -1
- package/dist/cjs/signer.js.map +1 -1
- package/dist/cjs/signing.js +94 -7
- package/dist/cjs/signing.js.map +1 -1
- package/dist/cjs/transaction.js +9 -1
- package/dist/cjs/transaction.js.map +1 -1
- package/dist/cjs/types/transactions/encoded.js +51 -1
- package/dist/cjs/types/transactions/encoded.js.map +1 -1
- package/dist/cjs/utils/ed25519-check.js +69 -0
- package/dist/cjs/utils/ed25519-check.js.map +1 -0
- package/dist/esm/client/v2/algod/algod.js +0 -18
- package/dist/esm/client/v2/algod/algod.js.map +1 -1
- package/dist/esm/client/v2/algod/models/types.js +0 -427
- package/dist/esm/client/v2/algod/models/types.js.map +1 -1
- package/dist/esm/ed25519-signer.js +72 -0
- package/dist/esm/ed25519-signer.js.map +1 -0
- package/dist/esm/encoding/address.js +58 -0
- package/dist/esm/encoding/address.js.map +1 -1
- package/dist/esm/falcon-signer.js +13 -0
- package/dist/esm/falcon-signer.js.map +1 -0
- package/dist/esm/logicsig.js +200 -15
- package/dist/esm/logicsig.js.map +1 -1
- package/dist/esm/main.js +8 -56
- package/dist/esm/main.js.map +1 -1
- package/dist/esm/mnemonic/mnemonic.js +25 -1
- package/dist/esm/mnemonic/mnemonic.js.map +1 -1
- package/dist/esm/multisigSigning.js +75 -0
- package/dist/esm/multisigSigning.js.map +1 -1
- package/dist/esm/pq-signer.js +50 -0
- package/dist/esm/pq-signer.js.map +1 -0
- package/dist/esm/signedTransaction.js +16 -2
- package/dist/esm/signedTransaction.js.map +1 -1
- package/dist/esm/signer.js.map +1 -1
- package/dist/esm/signing.js +91 -8
- package/dist/esm/signing.js.map +1 -1
- package/dist/esm/transaction.js +9 -1
- package/dist/esm/transaction.js.map +1 -1
- package/dist/esm/types/transactions/encoded.js +49 -1
- package/dist/esm/types/transactions/encoded.js.map +1 -1
- package/dist/esm/utils/ed25519-check.js +65 -0
- package/dist/esm/utils/ed25519-check.js.map +1 -0
- package/dist/types/client/v2/algod/algod.d.ts +0 -16
- package/dist/types/client/v2/algod/models/types.d.ts +0 -217
- package/dist/types/ed25519-signer.d.ts +7 -0
- package/dist/types/encoding/address.d.ts +37 -0
- package/dist/types/falcon-signer.d.ts +11 -0
- package/dist/types/logicsig.d.ts +72 -1
- package/dist/types/main.d.ts +8 -44
- package/dist/types/mnemonic/mnemonic.d.ts +13 -0
- package/dist/types/multisigSigning.d.ts +49 -0
- package/dist/types/pq-signer.d.ts +8 -0
- package/dist/types/signedTransaction.d.ts +7 -2
- package/dist/types/signer.d.ts +38 -0
- package/dist/types/signing.d.ts +45 -0
- package/dist/types/transaction.d.ts +9 -0
- package/dist/types/types/transactions/encoded.d.ts +27 -0
- package/dist/types/utils/ed25519-check.d.ts +10 -0
- package/package.json +2 -1
- package/src/client/v2/algod/algod.ts +0 -19
- package/src/client/v2/algod/models/types.ts +0 -700
- package/src/ed25519-signer.ts +125 -0
- package/src/encoding/address.ts +80 -0
- package/src/falcon-signer.ts +30 -0
- package/src/logicsig.ts +258 -16
- package/src/main.ts +30 -60
- package/src/mnemonic/mnemonic.ts +34 -1
- package/src/multisigSigning.ts +111 -0
- package/src/pq-signer.ts +90 -0
- package/src/signedTransaction.ts +24 -0
- package/src/signer.ts +53 -0
- package/src/signing.ts +109 -8
- package/src/transaction.ts +9 -1
- package/src/types/transactions/encoded.ts +88 -0
- package/src/utils/ed25519-check.ts +67 -0
- package/dist/cjs/client/v2/algod/dryrun.js +0 -34
- package/dist/cjs/client/v2/algod/dryrun.js.map +0 -1
- package/dist/cjs/dryrun.js +0 -214
- package/dist/cjs/dryrun.js.map +0 -1
- package/dist/esm/client/v2/algod/dryrun.js +0 -28
- package/dist/esm/client/v2/algod/dryrun.js.map +0 -1
- package/dist/esm/dryrun.js +0 -208
- package/dist/esm/dryrun.js.map +0 -1
- package/dist/types/client/v2/algod/dryrun.d.ts +0 -11
- package/dist/types/dryrun.d.ts +0 -28
- package/src/client/v2/algod/dryrun.ts +0 -38
- package/src/dryrun.ts +0 -292
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { HTTPClient, HTTPClientResponse } from '../../client.js';
|
|
2
|
-
import { decodeJSON, encodeMsgpack } from '../../../encoding/encoding.js';
|
|
3
|
-
import JSONRequest from '../jsonrequest.js';
|
|
4
|
-
import { setHeaders } from './compile.js';
|
|
5
|
-
import { DryrunResponse } from './models/types.js';
|
|
6
|
-
import * as modelsv2 from './models/types.js';
|
|
7
|
-
|
|
8
|
-
export default class Dryrun extends JSONRequest<DryrunResponse> {
|
|
9
|
-
private blob: Uint8Array;
|
|
10
|
-
|
|
11
|
-
constructor(c: HTTPClient, dr: modelsv2.DryrunRequest) {
|
|
12
|
-
super(c);
|
|
13
|
-
this.blob = encodeMsgpack(dr);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// eslint-disable-next-line class-methods-use-this
|
|
17
|
-
path() {
|
|
18
|
-
return '/v2/teal/dryrun';
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
protected executeRequest(
|
|
22
|
-
headers?: Record<string, string>,
|
|
23
|
-
customOptions?: Record<string, unknown>
|
|
24
|
-
): Promise<HTTPClientResponse> {
|
|
25
|
-
const txHeaders = setHeaders(headers);
|
|
26
|
-
return this.c.post({
|
|
27
|
-
relativePath: this.path(),
|
|
28
|
-
data: this.blob,
|
|
29
|
-
requestHeaders: txHeaders,
|
|
30
|
-
customOptions,
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// eslint-disable-next-line class-methods-use-this
|
|
35
|
-
prepare(response: HTTPClientResponse): DryrunResponse {
|
|
36
|
-
return decodeJSON(response.getJSONText(), DryrunResponse);
|
|
37
|
-
}
|
|
38
|
-
}
|
package/src/dryrun.ts
DELETED
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
import { AlgodClient } from './client/v2/algod/algod.js';
|
|
2
|
-
import {
|
|
3
|
-
Account,
|
|
4
|
-
Application,
|
|
5
|
-
ApplicationParams,
|
|
6
|
-
ApplicationStateSchema,
|
|
7
|
-
DryrunRequest,
|
|
8
|
-
DryrunSource,
|
|
9
|
-
DryrunTxnResult,
|
|
10
|
-
DryrunState,
|
|
11
|
-
TealValue,
|
|
12
|
-
} from './client/v2/algod/models/types.js';
|
|
13
|
-
import { getApplicationAddress } from './encoding/address.js';
|
|
14
|
-
import { bytesToHex } from './encoding/binarydata.js';
|
|
15
|
-
import { SignedTransaction } from './signedTransaction.js';
|
|
16
|
-
import { TransactionType } from './types/transactions/index.js';
|
|
17
|
-
import { stringifyJSON } from './utils/utils.js';
|
|
18
|
-
|
|
19
|
-
const defaultAppId = 1380011588;
|
|
20
|
-
const defaultMaxWidth = 30;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* createDryrun takes an Algod Client (from algod.AlgodV2Client) and an array of Signed Transactions
|
|
24
|
-
* from (transaction.SignedTransaction) and creates a DryrunRequest object with relevant balances
|
|
25
|
-
* @param client - the AlgodClient to make requests against
|
|
26
|
-
* @param txns - the array of SignedTransaction to use for generating the DryrunRequest object
|
|
27
|
-
* @param protocolVersion - the string representing the protocol version to use
|
|
28
|
-
* @param latestTimestamp - the timestamp
|
|
29
|
-
* @param round - the round available to some TEAL scripts. Defaults to the current round on the network.
|
|
30
|
-
* @param sources - TEAL source text that gets uploaded, compiled, and inserted into transactions or application state.
|
|
31
|
-
* @returns the DryrunRequest object constructed from the SignedTransactions passed
|
|
32
|
-
*/
|
|
33
|
-
export async function createDryrun({
|
|
34
|
-
client,
|
|
35
|
-
txns,
|
|
36
|
-
protocolVersion,
|
|
37
|
-
latestTimestamp,
|
|
38
|
-
round,
|
|
39
|
-
sources,
|
|
40
|
-
}: {
|
|
41
|
-
client: AlgodClient;
|
|
42
|
-
txns: SignedTransaction[];
|
|
43
|
-
protocolVersion?: string;
|
|
44
|
-
latestTimestamp?: number | bigint;
|
|
45
|
-
round?: number | bigint;
|
|
46
|
-
sources?: DryrunSource[];
|
|
47
|
-
}): Promise<DryrunRequest> {
|
|
48
|
-
const appInfos: Application[] = [];
|
|
49
|
-
const acctInfos: Account[] = [];
|
|
50
|
-
|
|
51
|
-
const apps: bigint[] = [];
|
|
52
|
-
const assets: bigint[] = [];
|
|
53
|
-
const accts: string[] = [];
|
|
54
|
-
|
|
55
|
-
for (const t of txns) {
|
|
56
|
-
if (t.txn.type === TransactionType.appl) {
|
|
57
|
-
accts.push(t.txn.sender.toString());
|
|
58
|
-
|
|
59
|
-
accts.push(...t.txn.applicationCall!.accounts.map((a) => a.toString()));
|
|
60
|
-
|
|
61
|
-
apps.push(...t.txn.applicationCall!.foreignApps);
|
|
62
|
-
accts.push(
|
|
63
|
-
...t.txn
|
|
64
|
-
.applicationCall!.foreignApps.map(getApplicationAddress)
|
|
65
|
-
.map((a) => a.toString())
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
assets.push(...t.txn.applicationCall!.foreignAssets);
|
|
69
|
-
|
|
70
|
-
// Create application,
|
|
71
|
-
if (t.txn.applicationCall!.appIndex === BigInt(0)) {
|
|
72
|
-
appInfos.push(
|
|
73
|
-
new Application({
|
|
74
|
-
id: defaultAppId,
|
|
75
|
-
params: new ApplicationParams({
|
|
76
|
-
creator: t.txn.sender.toString(),
|
|
77
|
-
approvalProgram: t.txn.applicationCall!.approvalProgram,
|
|
78
|
-
clearStateProgram: t.txn.applicationCall!.clearProgram,
|
|
79
|
-
localStateSchema: new ApplicationStateSchema({
|
|
80
|
-
numUint: t.txn.applicationCall!.numLocalInts,
|
|
81
|
-
numByteSlice: t.txn.applicationCall!.numLocalByteSlices,
|
|
82
|
-
}),
|
|
83
|
-
globalStateSchema: new ApplicationStateSchema({
|
|
84
|
-
numUint: t.txn.applicationCall!.numGlobalInts,
|
|
85
|
-
numByteSlice: t.txn.applicationCall!.numGlobalByteSlices,
|
|
86
|
-
}),
|
|
87
|
-
}),
|
|
88
|
-
})
|
|
89
|
-
);
|
|
90
|
-
} else {
|
|
91
|
-
const { appIndex } = t.txn.applicationCall!;
|
|
92
|
-
apps.push(appIndex);
|
|
93
|
-
accts.push(getApplicationAddress(appIndex).toString());
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// Dedupe and add creator to accts array
|
|
99
|
-
const assetPromises = [];
|
|
100
|
-
for (const assetId of new Set(assets)) {
|
|
101
|
-
assetPromises.push(
|
|
102
|
-
client
|
|
103
|
-
.getAssetByID(assetId)
|
|
104
|
-
.do()
|
|
105
|
-
.then((assetInfo) => {
|
|
106
|
-
accts.push(assetInfo.params!.creator);
|
|
107
|
-
})
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
// Wait for assets to finish since we append to accts array
|
|
111
|
-
await Promise.all(assetPromises);
|
|
112
|
-
|
|
113
|
-
// Dedupe and get app info for all apps
|
|
114
|
-
const appPromises = [];
|
|
115
|
-
for (const appId of new Set(apps)) {
|
|
116
|
-
appPromises.push(
|
|
117
|
-
client
|
|
118
|
-
.getApplicationByID(appId)
|
|
119
|
-
.do()
|
|
120
|
-
.then((appInfo) => {
|
|
121
|
-
appInfos.push(appInfo);
|
|
122
|
-
accts.push(appInfo.params!.creator.toString());
|
|
123
|
-
})
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
await Promise.all(appPromises);
|
|
127
|
-
|
|
128
|
-
const acctPromises = [];
|
|
129
|
-
for (const acct of new Set(accts)) {
|
|
130
|
-
acctPromises.push(
|
|
131
|
-
client
|
|
132
|
-
.accountInformation(acct)
|
|
133
|
-
.do()
|
|
134
|
-
.then((acctInfo) => {
|
|
135
|
-
acctInfos.push(acctInfo);
|
|
136
|
-
})
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
await Promise.all(acctPromises);
|
|
140
|
-
|
|
141
|
-
return new DryrunRequest({
|
|
142
|
-
txns: txns.slice(),
|
|
143
|
-
accounts: acctInfos,
|
|
144
|
-
apps: appInfos,
|
|
145
|
-
latestTimestamp: latestTimestamp ?? 0,
|
|
146
|
-
round: round ?? 0,
|
|
147
|
-
protocolVersion: protocolVersion ?? '',
|
|
148
|
-
sources: sources ?? [],
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export interface StackPrinterConfig {
|
|
153
|
-
maxValueWidth: number | undefined;
|
|
154
|
-
topOfStackFirst: boolean | undefined;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
function truncate(str: string, maxValueWidth: number): string {
|
|
158
|
-
if (str.length > maxValueWidth && maxValueWidth > 0) {
|
|
159
|
-
return `${str.slice(0, maxValueWidth)}...`;
|
|
160
|
-
}
|
|
161
|
-
return str;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
function scratchToString(
|
|
165
|
-
prevScratch: TealValue[],
|
|
166
|
-
currScratch: TealValue[]
|
|
167
|
-
): string {
|
|
168
|
-
if (currScratch.length === 0) return '';
|
|
169
|
-
|
|
170
|
-
let newScratchIdx = null;
|
|
171
|
-
for (let idx = 0; idx < currScratch.length; idx++) {
|
|
172
|
-
if (idx > prevScratch.length) {
|
|
173
|
-
newScratchIdx = idx;
|
|
174
|
-
continue;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
if (stringifyJSON(prevScratch[idx]) !== stringifyJSON(currScratch[idx])) {
|
|
178
|
-
newScratchIdx = idx;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
if (newScratchIdx == null) return '';
|
|
183
|
-
|
|
184
|
-
const newScratch = currScratch[newScratchIdx];
|
|
185
|
-
if (newScratch.bytes.length > 0) {
|
|
186
|
-
return `${newScratchIdx} = 0x${bytesToHex(newScratch.bytes)}`;
|
|
187
|
-
}
|
|
188
|
-
return `${newScratchIdx} = ${newScratch.uint.toString()}`;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
function stackToString(
|
|
192
|
-
stack: TealValue[],
|
|
193
|
-
reverse: boolean | undefined
|
|
194
|
-
): string {
|
|
195
|
-
const svs = reverse ? stack.reverse() : stack;
|
|
196
|
-
return `[${svs
|
|
197
|
-
.map((sv) => {
|
|
198
|
-
switch (sv.type) {
|
|
199
|
-
case 1:
|
|
200
|
-
return `0x${bytesToHex(sv.bytes)}`;
|
|
201
|
-
case 2:
|
|
202
|
-
return sv.uint.toString();
|
|
203
|
-
default:
|
|
204
|
-
return '';
|
|
205
|
-
}
|
|
206
|
-
})
|
|
207
|
-
.join(', ')}]`;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
function dryrunTrace(
|
|
211
|
-
trace: DryrunState[],
|
|
212
|
-
disassembly: string[],
|
|
213
|
-
spc: StackPrinterConfig
|
|
214
|
-
): string {
|
|
215
|
-
const maxWidth = spc.maxValueWidth || defaultMaxWidth;
|
|
216
|
-
|
|
217
|
-
// Create the array of arrays, each sub array contains N columns
|
|
218
|
-
const lines = [['pc#', 'ln#', 'source', 'scratch', 'stack']];
|
|
219
|
-
for (let idx = 0; idx < trace.length; idx++) {
|
|
220
|
-
const { line, error, pc, scratch, stack } = trace[idx];
|
|
221
|
-
|
|
222
|
-
const currScratch = scratch !== undefined ? scratch : [];
|
|
223
|
-
const prevScratch =
|
|
224
|
-
idx > 0 && trace[idx - 1].scratch !== undefined
|
|
225
|
-
? trace[idx - 1].scratch!
|
|
226
|
-
: [];
|
|
227
|
-
|
|
228
|
-
const src = !error ? disassembly[line] : `!! ${error} !!`;
|
|
229
|
-
|
|
230
|
-
lines.push([
|
|
231
|
-
pc.toString().padEnd(3, ' '),
|
|
232
|
-
line.toString().padEnd(3, ' '),
|
|
233
|
-
truncate(src, maxWidth),
|
|
234
|
-
truncate(scratchToString(prevScratch, currScratch), maxWidth),
|
|
235
|
-
truncate(stackToString(stack, spc.topOfStackFirst), maxWidth),
|
|
236
|
-
]);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
// Get the max length for each column
|
|
240
|
-
const maxLengths = lines.reduce((prev, curr) => {
|
|
241
|
-
const newVal = new Array(lines[0].length).fill(0);
|
|
242
|
-
for (let idx = 0; idx < prev.length; idx++) {
|
|
243
|
-
newVal[idx] = curr[idx].length > prev[idx] ? curr[idx].length : prev[idx];
|
|
244
|
-
}
|
|
245
|
-
return newVal;
|
|
246
|
-
}, new Array(lines[0].length).fill(0));
|
|
247
|
-
|
|
248
|
-
return `${lines
|
|
249
|
-
.map((line) =>
|
|
250
|
-
line
|
|
251
|
-
.map((v, idx) => v.padEnd(maxLengths[idx] + 1, ' '))
|
|
252
|
-
.join('|')
|
|
253
|
-
.trim()
|
|
254
|
-
)
|
|
255
|
-
.join('\n')}\n`;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
export function dryrunTxnResultAppTrace(
|
|
259
|
-
result: DryrunTxnResult,
|
|
260
|
-
spc?: StackPrinterConfig
|
|
261
|
-
): string {
|
|
262
|
-
if (!result.appCallTrace || !result.disassembly) return '';
|
|
263
|
-
|
|
264
|
-
let conf = spc;
|
|
265
|
-
if (spc !== undefined) conf = spc;
|
|
266
|
-
else {
|
|
267
|
-
conf = {
|
|
268
|
-
maxValueWidth: defaultMaxWidth,
|
|
269
|
-
topOfStackFirst: false,
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
return dryrunTrace(result.appCallTrace, result.disassembly, conf);
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
export function dryrunTxnResultLogicSigTrace(
|
|
277
|
-
result: DryrunTxnResult,
|
|
278
|
-
spc?: StackPrinterConfig
|
|
279
|
-
): string {
|
|
280
|
-
if (!result.logicSigTrace || !result.logicSigDisassembly) return '';
|
|
281
|
-
|
|
282
|
-
let conf: StackPrinterConfig;
|
|
283
|
-
if (spc !== undefined) conf = spc;
|
|
284
|
-
else {
|
|
285
|
-
conf = {
|
|
286
|
-
maxValueWidth: defaultMaxWidth,
|
|
287
|
-
topOfStackFirst: true,
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
return dryrunTrace(result.logicSigTrace, result.logicSigDisassembly, conf);
|
|
292
|
-
}
|