algosdk 3.4.0 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/browser/algosdk.min.js +1 -1
- package/dist/browser/algosdk.min.js.map +1 -1
- package/dist/cjs/appAccess.js +261 -0
- package/dist/cjs/appAccess.js.map +1 -0
- package/dist/cjs/client/v2/indexer/models/types.js +266 -8
- package/dist/cjs/client/v2/indexer/models/types.js.map +1 -1
- package/dist/cjs/logicsig.js +54 -17
- package/dist/cjs/logicsig.js.map +1 -1
- package/dist/cjs/makeTxn.js +66 -12
- package/dist/cjs/makeTxn.js.map +1 -1
- package/dist/cjs/signing.js +4 -4
- package/dist/cjs/signing.js.map +1 -1
- package/dist/cjs/transaction.js +107 -0
- package/dist/cjs/transaction.js.map +1 -1
- package/dist/esm/appAccess.js +255 -0
- package/dist/esm/appAccess.js.map +1 -0
- package/dist/esm/client/v2/indexer/models/types.js +261 -6
- package/dist/esm/client/v2/indexer/models/types.js.map +1 -1
- package/dist/esm/logicsig.js +54 -17
- package/dist/esm/logicsig.js.map +1 -1
- package/dist/esm/makeTxn.js +66 -12
- package/dist/esm/makeTxn.js.map +1 -1
- package/dist/esm/signing.js +4 -4
- package/dist/esm/signing.js.map +1 -1
- package/dist/esm/transaction.js +107 -0
- package/dist/esm/transaction.js.map +1 -1
- package/dist/types/appAccess.d.ts +28 -0
- package/dist/types/client/v2/indexer/models/types.d.ts +157 -8
- package/dist/types/logicsig.d.ts +2 -0
- package/dist/types/makeTxn.d.ts +9 -9
- package/dist/types/transaction.d.ts +17 -0
- package/dist/types/types/transactions/base.d.ts +71 -0
- package/package.json +1 -1
- package/src/appAccess.ts +298 -0
- package/src/client/v2/indexer/models/types.ts +423 -5
- package/src/logicsig.ts +68 -17
- package/src/makeTxn.ts +110 -12
- package/src/signing.ts +4 -4
- package/src/transaction.ts +162 -0
- package/src/types/transactions/base.ts +85 -0
package/src/transaction.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import base32 from 'hi-base32';
|
|
2
2
|
import { boxReferencesToEncodingData } from './boxStorage.js';
|
|
3
|
+
import {
|
|
4
|
+
resourceReferencesToEncodingData,
|
|
5
|
+
convertIndicesToResourceReferences,
|
|
6
|
+
} from './appAccess.js';
|
|
3
7
|
import { Address } from './encoding/address.js';
|
|
4
8
|
import * as encoding from './encoding/encoding.js';
|
|
5
9
|
import {
|
|
@@ -180,6 +184,73 @@ function ensureBoxReference(input: unknown): TransactionBoxReference {
|
|
|
180
184
|
throw new Error(`Not a box reference: ${input}`);
|
|
181
185
|
}
|
|
182
186
|
|
|
187
|
+
export interface TransactionHoldingReference {
|
|
188
|
+
readonly assetIndex: bigint;
|
|
189
|
+
readonly address: Address;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function ensureHoldingReference(input: unknown): TransactionHoldingReference {
|
|
193
|
+
if (input != null && typeof input === 'object') {
|
|
194
|
+
const { assetIndex, address } = input as TransactionHoldingReference;
|
|
195
|
+
return {
|
|
196
|
+
assetIndex: utils.ensureUint64(assetIndex),
|
|
197
|
+
address: ensureAddress(address),
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
throw new Error(`Not a holding reference: ${input}`);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export interface TransactionLocalsReference {
|
|
204
|
+
readonly appIndex: bigint;
|
|
205
|
+
readonly address: Address;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function ensureLocalsReference(input: unknown): TransactionLocalsReference {
|
|
209
|
+
if (input != null && typeof input === 'object') {
|
|
210
|
+
const { appIndex, address } = input as TransactionLocalsReference;
|
|
211
|
+
return {
|
|
212
|
+
appIndex: utils.ensureUint64(appIndex),
|
|
213
|
+
address: ensureAddress(address),
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
throw new Error(`Not a locals reference: ${input}`);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export interface TransactionResourceReference {
|
|
220
|
+
readonly address?: Readonly<Address>;
|
|
221
|
+
readonly appIndex?: Readonly<bigint>;
|
|
222
|
+
readonly assetIndex?: Readonly<bigint>;
|
|
223
|
+
readonly holding?: Readonly<TransactionHoldingReference>;
|
|
224
|
+
readonly locals?: Readonly<TransactionLocalsReference>;
|
|
225
|
+
readonly box?: Readonly<TransactionBoxReference>;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function ensureResourceReference(input: unknown): TransactionResourceReference {
|
|
229
|
+
if (input != null && typeof input === 'object') {
|
|
230
|
+
const { address, appIndex, assetIndex, holding, locals, box } =
|
|
231
|
+
input as TransactionResourceReference;
|
|
232
|
+
if (address !== undefined) {
|
|
233
|
+
return { address: ensureAddress(address) };
|
|
234
|
+
}
|
|
235
|
+
if (appIndex !== undefined) {
|
|
236
|
+
return { appIndex: utils.ensureUint64(appIndex) };
|
|
237
|
+
}
|
|
238
|
+
if (assetIndex !== undefined) {
|
|
239
|
+
return { assetIndex: utils.ensureUint64(assetIndex) };
|
|
240
|
+
}
|
|
241
|
+
if (holding !== undefined) {
|
|
242
|
+
return { holding: ensureHoldingReference(holding) };
|
|
243
|
+
}
|
|
244
|
+
if (locals !== undefined) {
|
|
245
|
+
return { locals: ensureLocalsReference(locals) };
|
|
246
|
+
}
|
|
247
|
+
if (box !== undefined) {
|
|
248
|
+
return { box: ensureBoxReference(box) };
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
throw new Error(`Not a resource reference: ${input}`);
|
|
252
|
+
}
|
|
253
|
+
|
|
183
254
|
const TX_TAG = new TextEncoder().encode('TX');
|
|
184
255
|
|
|
185
256
|
export interface PaymentTransactionFields {
|
|
@@ -242,6 +313,7 @@ export interface ApplicationTransactionFields {
|
|
|
242
313
|
readonly foreignApps: ReadonlyArray<bigint>;
|
|
243
314
|
readonly foreignAssets: ReadonlyArray<bigint>;
|
|
244
315
|
readonly boxes: ReadonlyArray<TransactionBoxReference>;
|
|
316
|
+
readonly access: ReadonlyArray<TransactionResourceReference>;
|
|
245
317
|
}
|
|
246
318
|
|
|
247
319
|
export interface StateProofTransactionFields {
|
|
@@ -404,6 +476,80 @@ export class Transaction implements encoding.Encodable {
|
|
|
404
476
|
)
|
|
405
477
|
),
|
|
406
478
|
},
|
|
479
|
+
{
|
|
480
|
+
key: 'al',
|
|
481
|
+
valueSchema: new OptionalSchema(
|
|
482
|
+
new ArraySchema(
|
|
483
|
+
new NamedMapSchema(
|
|
484
|
+
allOmitEmpty([
|
|
485
|
+
{
|
|
486
|
+
key: 'd',
|
|
487
|
+
valueSchema: new OptionalSchema(new AddressSchema()),
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
key: 's',
|
|
491
|
+
valueSchema: new OptionalSchema(new Uint64Schema()),
|
|
492
|
+
},
|
|
493
|
+
{
|
|
494
|
+
key: 'p',
|
|
495
|
+
valueSchema: new OptionalSchema(new Uint64Schema()),
|
|
496
|
+
},
|
|
497
|
+
{
|
|
498
|
+
key: 'h',
|
|
499
|
+
valueSchema: new OptionalSchema(
|
|
500
|
+
new NamedMapSchema(
|
|
501
|
+
allOmitEmpty([
|
|
502
|
+
{
|
|
503
|
+
key: 'd',
|
|
504
|
+
valueSchema: new Uint64Schema(),
|
|
505
|
+
},
|
|
506
|
+
{
|
|
507
|
+
key: 's',
|
|
508
|
+
valueSchema: new Uint64Schema(),
|
|
509
|
+
},
|
|
510
|
+
])
|
|
511
|
+
)
|
|
512
|
+
),
|
|
513
|
+
},
|
|
514
|
+
{
|
|
515
|
+
key: 'l',
|
|
516
|
+
valueSchema: new OptionalSchema(
|
|
517
|
+
new NamedMapSchema(
|
|
518
|
+
allOmitEmpty([
|
|
519
|
+
{
|
|
520
|
+
key: 'd',
|
|
521
|
+
valueSchema: new Uint64Schema(),
|
|
522
|
+
},
|
|
523
|
+
{
|
|
524
|
+
key: 'p',
|
|
525
|
+
valueSchema: new Uint64Schema(),
|
|
526
|
+
},
|
|
527
|
+
])
|
|
528
|
+
)
|
|
529
|
+
),
|
|
530
|
+
},
|
|
531
|
+
{
|
|
532
|
+
key: 'b',
|
|
533
|
+
valueSchema: new OptionalSchema(
|
|
534
|
+
new NamedMapSchema(
|
|
535
|
+
allOmitEmpty([
|
|
536
|
+
{
|
|
537
|
+
key: 'i',
|
|
538
|
+
valueSchema: new Uint64Schema(),
|
|
539
|
+
},
|
|
540
|
+
{
|
|
541
|
+
key: 'n',
|
|
542
|
+
valueSchema: new ByteArraySchema(),
|
|
543
|
+
},
|
|
544
|
+
])
|
|
545
|
+
)
|
|
546
|
+
),
|
|
547
|
+
},
|
|
548
|
+
])
|
|
549
|
+
)
|
|
550
|
+
)
|
|
551
|
+
),
|
|
552
|
+
},
|
|
407
553
|
{ key: 'apap', valueSchema: new OptionalSchema(new ByteArraySchema()) },
|
|
408
554
|
{ key: 'apsu', valueSchema: new OptionalSchema(new ByteArraySchema()) },
|
|
409
555
|
{
|
|
@@ -702,6 +848,9 @@ export class Transaction implements encoding.Encodable {
|
|
|
702
848
|
boxes: ensureArray(params.appCallParams.boxes ?? []).map(
|
|
703
849
|
ensureBoxReference
|
|
704
850
|
),
|
|
851
|
+
access: ensureArray(params.appCallParams.access ?? []).map(
|
|
852
|
+
ensureResourceReference
|
|
853
|
+
),
|
|
705
854
|
};
|
|
706
855
|
}
|
|
707
856
|
|
|
@@ -829,6 +978,13 @@ export class Transaction implements encoding.Encodable {
|
|
|
829
978
|
this.applicationCall.appIndex
|
|
830
979
|
)
|
|
831
980
|
);
|
|
981
|
+
data.set(
|
|
982
|
+
'al',
|
|
983
|
+
resourceReferencesToEncodingData(
|
|
984
|
+
this.applicationCall.appIndex,
|
|
985
|
+
this.applicationCall.access
|
|
986
|
+
)
|
|
987
|
+
);
|
|
832
988
|
data.set('apap', this.applicationCall.approvalProgram);
|
|
833
989
|
data.set('apsu', this.applicationCall.clearProgram);
|
|
834
990
|
data.set(
|
|
@@ -1030,6 +1186,12 @@ export class Transaction implements encoding.Encodable {
|
|
|
1030
1186
|
};
|
|
1031
1187
|
});
|
|
1032
1188
|
}
|
|
1189
|
+
const references = data.get('al') as
|
|
1190
|
+
| Array<Map<string, unknown>>
|
|
1191
|
+
| undefined;
|
|
1192
|
+
if (references) {
|
|
1193
|
+
appCallParams.access = convertIndicesToResourceReferences(references);
|
|
1194
|
+
}
|
|
1033
1195
|
params.appCallParams = appCallParams;
|
|
1034
1196
|
} else if (params.type === TransactionType.stpf) {
|
|
1035
1197
|
const stateProofParams: StateProofTransactionParams = {
|
|
@@ -181,6 +181,86 @@ export interface BoxReference {
|
|
|
181
181
|
name: Uint8Array;
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
+
/**
|
|
185
|
+
* A grouping of the asset index and address of the account
|
|
186
|
+
*/
|
|
187
|
+
export interface HoldingReference {
|
|
188
|
+
/**
|
|
189
|
+
* The asset index of the holding
|
|
190
|
+
*/
|
|
191
|
+
assetIndex: number | bigint;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* The address of the account holding the asset
|
|
195
|
+
*/
|
|
196
|
+
address: string | Address;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** A grouping of the application index and address of the account
|
|
200
|
+
*/
|
|
201
|
+
export interface LocalsReference {
|
|
202
|
+
/**
|
|
203
|
+
* The application index of the local state
|
|
204
|
+
*/
|
|
205
|
+
appIndex: number | bigint;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* The address of the account holding the local state
|
|
209
|
+
*/
|
|
210
|
+
address: string | Address;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Parameters for resource references in application transactions
|
|
215
|
+
*/
|
|
216
|
+
export interface ApplicationCallReferenceParams {
|
|
217
|
+
/**
|
|
218
|
+
* A grouping of the asset index and address of the account
|
|
219
|
+
*/
|
|
220
|
+
holdings?: HoldingReference[];
|
|
221
|
+
|
|
222
|
+
/** A grouping of the application index and address of the account
|
|
223
|
+
*/
|
|
224
|
+
locals?: LocalsReference[];
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* If true, use the foreign accounts, apps, assets, boxes, holdings, and locals fields to construct the access list
|
|
228
|
+
*/
|
|
229
|
+
convertToAccess?: boolean;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export interface ResourceReference {
|
|
233
|
+
/**
|
|
234
|
+
* Address string, any additional accounts to supply to the application
|
|
235
|
+
*/
|
|
236
|
+
address?: string | Address;
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Asset index uniquely specifying the asset
|
|
240
|
+
*/
|
|
241
|
+
assetIndex?: number | bigint;
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* A unique application ID
|
|
245
|
+
*/
|
|
246
|
+
appIndex?: number | bigint;
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Holding definition: asset ID and account address
|
|
250
|
+
*/
|
|
251
|
+
holding?: HoldingReference;
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Local state definition: application ID and account address
|
|
255
|
+
*/
|
|
256
|
+
locals?: LocalsReference;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Box definition: application ID and a name of the box
|
|
260
|
+
*/
|
|
261
|
+
box?: BoxReference;
|
|
262
|
+
}
|
|
263
|
+
|
|
184
264
|
/**
|
|
185
265
|
* Contains payment transaction parameters.
|
|
186
266
|
*
|
|
@@ -451,6 +531,11 @@ export interface ApplicationCallTransactionParams {
|
|
|
451
531
|
* A grouping of the app ID and name of the box in an Uint8Array
|
|
452
532
|
*/
|
|
453
533
|
boxes?: BoxReference[];
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* Resources accessed by the application
|
|
537
|
+
*/
|
|
538
|
+
access?: ResourceReference[];
|
|
454
539
|
}
|
|
455
540
|
|
|
456
541
|
/**
|