@algorandfoundation/algorand-typescript 1.0.0-beta.7 → 1.0.0-beta.71
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/arc-28.d.ts +1 -1
- package/arc4/c2c.d.ts +81 -0
- package/arc4/encoded-types.d.ts +241 -30
- package/arc4/index.d.ts +116 -13
- package/arc4/index.mjs +2 -4
- package/arc4/index.mjs.map +1 -1
- package/base-contract.d.ts +17 -12
- package/box.d.ts +184 -15
- package/compiled.d.ts +1 -1
- package/errors-D124-zqo.js +12 -0
- package/errors-D124-zqo.js.map +1 -0
- package/gtxn-CXBH4yay.js +71 -0
- package/gtxn-CXBH4yay.js.map +1 -0
- package/gtxn.d.ts +604 -16
- package/gtxn.mjs +3 -0
- package/gtxn.mjs.map +1 -0
- package/index-dzo0agbK.js +524 -0
- package/index-dzo0agbK.js.map +1 -0
- package/index.d.ts +3 -3
- package/index.mjs +180 -150
- package/index.mjs.map +1 -1
- package/internal/errors.d.ts +7 -0
- package/{typescript-helpers.d.ts → internal/typescript-helpers.d.ts} +1 -0
- package/itxn-CPeSA_Q_.js +202 -0
- package/itxn-CPeSA_Q_.js.map +1 -0
- package/itxn.d.ts +1006 -72
- package/itxn.mjs +3 -0
- package/itxn.mjs.map +1 -0
- package/logic-sig.d.ts +28 -1
- package/mutable-array.d.ts +10 -17
- package/on-complete-action.d.ts +33 -0
- package/{op-types.d.ts → op-BgdftarW.js} +1706 -691
- package/op-BgdftarW.js.map +1 -0
- package/op.d.ts +2621 -67
- package/op.mjs +2 -1
- package/op.mjs.map +1 -1
- package/package.json +13 -2
- package/primitives.d.ts +97 -0
- package/reference.d.ts +34 -1
- package/state.d.ts +67 -10
- package/template-var.d.ts +7 -0
- package/transactions.d.ts +0 -313
- package/util.d.ts +100 -3
- package/execution-context.d.ts +0 -47
- package/impl/base-32.d.ts +0 -2
- package/impl/encoding-util.d.ts +0 -10
- package/impl/errors.d.ts +0 -36
- package/impl/name-of-type.d.ts +0 -1
- package/impl/primitives.d.ts +0 -81
- package/index-CLBMQ4-B.js +0 -926
- package/index-CLBMQ4-B.js.map +0 -1
- package/internal.d.ts +0 -6
- package/op-Mj11EGRt.js +0 -170
- package/op-Mj11EGRt.js.map +0 -1
package/arc-28.d.ts
CHANGED
package/arc4/c2c.d.ts
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
import { CompileContractOptions, CompiledContract } from '../compiled';
|
2
|
+
import * as gtxn from '../gtxn';
|
3
|
+
import { AnyFunction, ConstructorFor, DeliberateAny, InstanceMethod } from '../internal/typescript-helpers';
|
4
|
+
import * as itxn from '../itxn';
|
5
|
+
import { ApplicationCallFields, ApplicationCallInnerTxn } from '../itxn';
|
6
|
+
import { Contract } from './index';
|
7
|
+
/**
|
8
|
+
* Defines txn fields that are available for a bare create application call.
|
9
|
+
*
|
10
|
+
* This is the regular application call fields minus:
|
11
|
+
* - appId: because the appId is not known when creating an application
|
12
|
+
* - appArgs: because a bare call cannot have arguments
|
13
|
+
*/
|
14
|
+
export type BareCreateApplicationCallFields = Omit<ApplicationCallFields, 'appId' | 'appArgs'>;
|
15
|
+
/**
|
16
|
+
* Conditional type which given a group transaction type, returns the equivalent inner transaction
|
17
|
+
* params type.
|
18
|
+
*/
|
19
|
+
export type GtxnToItxnFields<T extends gtxn.Transaction> = T extends gtxn.PaymentTxn ? itxn.PaymentItxnParams : T extends gtxn.KeyRegistrationTxn ? itxn.KeyRegistrationItxnParams : T extends gtxn.AssetConfigTxn ? itxn.AssetConfigItxnParams : T extends gtxn.AssetTransferTxn ? itxn.AssetTransferItxnParams : T extends gtxn.AssetFreezeTxn ? itxn.AssetFreezeItxnParams : T extends gtxn.ApplicationCallTxn ? itxn.ApplicationCallItxnParams : itxn.ItxnParams;
|
20
|
+
/**
|
21
|
+
* Conditional type which given an application argument, returns the input type for that argument.
|
22
|
+
*
|
23
|
+
* The input type will usually be the original type apart from group transactions which will be substituted
|
24
|
+
* with their equivalent inner transaction type.
|
25
|
+
*/
|
26
|
+
export type TypedApplicationArg<TArg> = TArg extends gtxn.Transaction ? GtxnToItxnFields<TArg> : TArg;
|
27
|
+
/**
|
28
|
+
* Conditional type which maps a tuple of application arguments to a tuple of input types for specifying those arguments.
|
29
|
+
*/
|
30
|
+
export type TypedApplicationArgs<TArgs> = TArgs extends [] ? [] : TArgs extends [infer TArg, ...infer TRest] ? [TypedApplicationArg<TArg>, ...TypedApplicationArgs<TRest>] : never;
|
31
|
+
/**
|
32
|
+
* Application call fields with `appArgs` replaced with an `args` property that is strongly typed to the actual arguments for the
|
33
|
+
* given application call.
|
34
|
+
*/
|
35
|
+
export type TypedApplicationCallFields<TArgs> = Omit<ApplicationCallFields, 'appArgs'> & (TArgs extends [] ? {
|
36
|
+
args?: TypedApplicationArgs<TArgs>;
|
37
|
+
} : {
|
38
|
+
args: TypedApplicationArgs<TArgs>;
|
39
|
+
});
|
40
|
+
/**
|
41
|
+
* The response type of a typed application call. Includes the raw itxn result object and the parsed ABI return value if applicable.
|
42
|
+
*/
|
43
|
+
export type TypedApplicationCallResponse<TReturn> = TReturn extends void ? {
|
44
|
+
itxn: ApplicationCallInnerTxn;
|
45
|
+
} : {
|
46
|
+
itxn: ApplicationCallInnerTxn;
|
47
|
+
returnValue: TReturn;
|
48
|
+
};
|
49
|
+
/**
|
50
|
+
* Conditional type which maps an ABI method to a factory method for constructing an application call transaction to call that method.
|
51
|
+
*/
|
52
|
+
export type ContractProxyMethod<TMethod> = TMethod extends (...args: infer TArgs) => infer TReturn ? (fields?: TypedApplicationCallFields<TArgs>) => TypedApplicationCallResponse<TReturn> : never;
|
53
|
+
/**
|
54
|
+
* Conditional type which maps an ARC4 compatible contract to a proxy object which allows for constructing application call transactions for
|
55
|
+
* all available ABI and bare methods. Also includes the compiled contract result data.
|
56
|
+
*/
|
57
|
+
export type ContractProxy<TContract extends Contract> = CompiledContract & {
|
58
|
+
/**
|
59
|
+
* Get methods for calling ABI and bare methods on the target contract
|
60
|
+
*/
|
61
|
+
call: {
|
62
|
+
[key in keyof TContract as key extends 'approvalProgram' | 'clearStateProgram' ? never : TContract[key] extends AnyFunction ? key : never]: ContractProxyMethod<TContract[key]>;
|
63
|
+
};
|
64
|
+
/**
|
65
|
+
* Create a bare application call itxn to create the contract.
|
66
|
+
* @param fields Specify values for transaction fields which should override the default values.
|
67
|
+
*/
|
68
|
+
bareCreate(fields?: BareCreateApplicationCallFields): ApplicationCallInnerTxn;
|
69
|
+
};
|
70
|
+
/**
|
71
|
+
* Pre compile the target ARC4 contract and return a proxy object for constructing inner transactions to call an instance of that contract.
|
72
|
+
* @param contract An ARC4 contract class
|
73
|
+
* @param options Compile contract arguments
|
74
|
+
*/
|
75
|
+
export declare function compileArc4<TContract extends Contract>(contract: ConstructorFor<TContract>, options?: CompileContractOptions): ContractProxy<TContract>;
|
76
|
+
/**
|
77
|
+
* Invokes the target ABI method using a strongly typed fields object.
|
78
|
+
* @param method An ABI method function reference.
|
79
|
+
* @param fields Specify values for transaction fields.
|
80
|
+
*/
|
81
|
+
export declare function abiCall<TArgs extends DeliberateAny[], TReturn>(method: InstanceMethod<Contract, TArgs, TReturn>, fields: TypedApplicationCallFields<TArgs>): TypedApplicationCallResponse<TReturn>;
|
package/arc4/encoded-types.d.ts
CHANGED
@@ -1,51 +1,143 @@
|
|
1
|
-
import { biguint, BigUintCompat, bytes, BytesBacked,
|
1
|
+
import { biguint, BigUintCompat, bytes, BytesBacked, NTuple, StringCompat, uint64, Uint64Compat } from '../primitives';
|
2
2
|
import { Account } from '../reference';
|
3
|
+
/**
|
4
|
+
* Defines UintN bit sizes which are compatible with the uint64 type
|
5
|
+
*/
|
3
6
|
type UintBitSize = 8 | 16 | 24 | 32 | 40 | 48 | 56 | 64;
|
7
|
+
/**
|
8
|
+
* Defines UintN bit sizes which are only compatible with the biguint type
|
9
|
+
*/
|
4
10
|
type BigUintBitSize = 72 | 80 | 88 | 96 | 104 | 112 | 120 | 128 | 136 | 144 | 152 | 160 | 168 | 176 | 184 | 192 | 200 | 208 | 216 | 224 | 232 | 240 | 248 | 256 | 264 | 272 | 280 | 288 | 296 | 304 | 312 | 320 | 328 | 336 | 344 | 352 | 360 | 368 | 376 | 384 | 392 | 400 | 408 | 416 | 424 | 432 | 440 | 448 | 456 | 464 | 472 | 480 | 488 | 496 | 504 | 512;
|
11
|
+
/**
|
12
|
+
* Defines supported bit sizes for the UintN and UFixedNxM types
|
13
|
+
*/
|
5
14
|
export type BitSize = UintBitSize | BigUintBitSize;
|
15
|
+
/**
|
16
|
+
* Conditional type which returns the native equivalent type for a given UintN bit size
|
17
|
+
*/
|
6
18
|
type NativeForArc4Int<N extends BitSize> = N extends UintBitSize ? uint64 : biguint;
|
19
|
+
/**
|
20
|
+
* Conditional type which returns the compat type relevant to a given UintN bit size
|
21
|
+
*/
|
7
22
|
type CompatForArc4Int<N extends BitSize> = N extends UintBitSize ? Uint64Compat : BigUintCompat;
|
23
|
+
/**
|
24
|
+
* @hidden
|
25
|
+
*/
|
8
26
|
declare const TypeProperty: unique symbol;
|
27
|
+
/**
|
28
|
+
* A base type for ARC4 encoded values
|
29
|
+
*/
|
9
30
|
export declare abstract class ARC4Encoded implements BytesBacked {
|
31
|
+
/** @hidden */
|
10
32
|
abstract [TypeProperty]?: string;
|
33
|
+
/**
|
34
|
+
* Retrieve the encoded bytes for this type
|
35
|
+
*/
|
11
36
|
get bytes(): bytes;
|
12
37
|
}
|
38
|
+
/**
|
39
|
+
* A utf8 encoded string prefixed with its length expressed as a 2 byte uint
|
40
|
+
*/
|
13
41
|
export declare class Str extends ARC4Encoded {
|
14
|
-
|
42
|
+
/** @hidden */
|
15
43
|
[TypeProperty]?: 'arc4.Str';
|
44
|
+
/**
|
45
|
+
* Create a new Str instance
|
46
|
+
* @param s The native string to initialize this Str from
|
47
|
+
*/
|
16
48
|
constructor(s?: StringCompat);
|
49
|
+
/**
|
50
|
+
* Retrieve the decoded native string
|
51
|
+
*/
|
17
52
|
get native(): string;
|
18
53
|
}
|
54
|
+
/**
|
55
|
+
* A fixed bit size unsigned int
|
56
|
+
*/
|
19
57
|
export declare class UintN<N extends BitSize> extends ARC4Encoded {
|
58
|
+
/** @hidden */
|
20
59
|
[TypeProperty]?: `arc4.UintN<${N}>`;
|
60
|
+
/**
|
61
|
+
* Create a new UintN instance
|
62
|
+
* @param v The native uint64 or biguint value to initialize this UintN from
|
63
|
+
*/
|
21
64
|
constructor(v?: CompatForArc4Int<N>);
|
65
|
+
/**
|
66
|
+
* Retrieve the decoded native uint64 or biguint
|
67
|
+
*/
|
22
68
|
get native(): NativeForArc4Int<N>;
|
23
69
|
}
|
70
|
+
/**
|
71
|
+
* An alias for UintN<8>
|
72
|
+
*/
|
24
73
|
export declare class Byte extends UintN<8> {
|
25
74
|
}
|
75
|
+
/**
|
76
|
+
* An alias for UintN<8>
|
77
|
+
*/
|
26
78
|
export declare class UintN8 extends UintN<8> {
|
27
79
|
}
|
80
|
+
/**
|
81
|
+
* An alias for UintN<16>
|
82
|
+
*/
|
28
83
|
export declare class UintN16 extends UintN<16> {
|
29
84
|
}
|
85
|
+
/**
|
86
|
+
* An alias for UintN<32>
|
87
|
+
*/
|
30
88
|
export declare class UintN32 extends UintN<32> {
|
31
89
|
}
|
90
|
+
/**
|
91
|
+
* An alias for UintN<64>
|
92
|
+
*/
|
32
93
|
export declare class UintN64 extends UintN<64> {
|
33
94
|
}
|
95
|
+
/**
|
96
|
+
* An alias for UintN<128>
|
97
|
+
*/
|
34
98
|
export declare class UintN128 extends UintN<128> {
|
35
99
|
}
|
100
|
+
/**
|
101
|
+
* An alias for UintN<256>
|
102
|
+
*/
|
36
103
|
export declare class UintN256 extends UintN<256> {
|
37
104
|
}
|
105
|
+
/**
|
106
|
+
* A fixed bit size, fixed decimal unsigned value
|
107
|
+
*/
|
38
108
|
export declare class UFixedNxM<N extends BitSize, M extends number> extends ARC4Encoded {
|
109
|
+
/** @hidden */
|
39
110
|
[TypeProperty]?: `arc4.UFixedNxM<${N}x${M}>`;
|
40
|
-
|
111
|
+
/**
|
112
|
+
* Create a new UFixedNxM value
|
113
|
+
* @param v A string representing the integer and fractional portion of the number
|
114
|
+
*/
|
115
|
+
constructor(v?: `${number}.${number}`);
|
116
|
+
/**
|
117
|
+
* Retrieve the decoded native uint64 or biguint where the returned integer represents the fixed decimal value * (10 ^ M)
|
118
|
+
*/
|
41
119
|
get native(): NativeForArc4Int<N>;
|
42
120
|
}
|
121
|
+
/**
|
122
|
+
* A boolean value
|
123
|
+
*/
|
43
124
|
export declare class Bool extends ARC4Encoded {
|
125
|
+
/** @hidden */
|
44
126
|
[TypeProperty]?: `arc4.Bool`;
|
127
|
+
/**
|
128
|
+
* Create a new Bool value
|
129
|
+
* @param v The native boolean to initialize this value from
|
130
|
+
*/
|
45
131
|
constructor(v?: boolean);
|
132
|
+
/**
|
133
|
+
* Get the decoded native boolean for this value
|
134
|
+
*/
|
46
135
|
get native(): boolean;
|
47
136
|
}
|
48
|
-
|
137
|
+
/**
|
138
|
+
* A base type for arc4 array types
|
139
|
+
*/
|
140
|
+
declare abstract class Arc4ArrayBase<TItem extends ARC4Encoded> extends ARC4Encoded {
|
49
141
|
protected constructor();
|
50
142
|
/**
|
51
143
|
* Returns the current length of this array
|
@@ -75,17 +167,50 @@ declare abstract class Arc4ReadonlyArray<TItem extends ARC4Encoded> extends ARC4
|
|
75
167
|
*/
|
76
168
|
[index: uint64]: TItem;
|
77
169
|
}
|
78
|
-
|
170
|
+
/**
|
171
|
+
* A fixed sized array of arc4 items
|
172
|
+
* @typeParam TItem The type of a single item in the array
|
173
|
+
* @typeParam TLength The fixed length of the array
|
174
|
+
*/
|
175
|
+
export declare class StaticArray<TItem extends ARC4Encoded, TLength extends number> extends Arc4ArrayBase<TItem> {
|
176
|
+
/** @hidden */
|
79
177
|
[TypeProperty]?: `arc4.StaticArray<${TItem[typeof TypeProperty]}, ${TLength}>`;
|
178
|
+
/**
|
179
|
+
* Create a new StaticArray instance
|
180
|
+
*/
|
80
181
|
constructor();
|
182
|
+
/**
|
183
|
+
* Create a new StaticArray instance with the specified items
|
184
|
+
* @param items The initial items for the array
|
185
|
+
*/
|
81
186
|
constructor(...items: TItem[] & {
|
82
187
|
length: TLength;
|
83
188
|
});
|
84
|
-
|
189
|
+
/**
|
190
|
+
* Returns a copy of this array
|
191
|
+
*/
|
85
192
|
copy(): StaticArray<TItem, TLength>;
|
193
|
+
/**
|
194
|
+
* Returns a new array containing all items from _this_ array, and _other_ array
|
195
|
+
* @param other Another array to concat with this one
|
196
|
+
*/
|
197
|
+
concat(other: Arc4ArrayBase<TItem>): DynamicArray<TItem>;
|
198
|
+
/**
|
199
|
+
* Return the array items as a native tuple
|
200
|
+
*/
|
201
|
+
get native(): NTuple<TItem, TLength>;
|
86
202
|
}
|
87
|
-
|
203
|
+
/**
|
204
|
+
* A dynamic sized array of arc4 items
|
205
|
+
* @typeParam TItem The type of a single item in the array
|
206
|
+
*/
|
207
|
+
export declare class DynamicArray<TItem extends ARC4Encoded> extends Arc4ArrayBase<TItem> {
|
208
|
+
/** @hidden */
|
88
209
|
[TypeProperty]?: `arc4.DynamicArray<${TItem[typeof TypeProperty]}>`;
|
210
|
+
/**
|
211
|
+
* Create a new DynamicArray with the specified items
|
212
|
+
* @param items The initial items for the array
|
213
|
+
*/
|
89
214
|
constructor(...items: TItem[]);
|
90
215
|
/**
|
91
216
|
* Push a number of items into this array
|
@@ -96,52 +221,138 @@ export declare class DynamicArray<TItem extends ARC4Encoded> extends Arc4Readonl
|
|
96
221
|
* Pop a single item from this array
|
97
222
|
*/
|
98
223
|
pop(): TItem;
|
224
|
+
/**
|
225
|
+
* Returns a copy of this array
|
226
|
+
*/
|
99
227
|
copy(): DynamicArray<TItem>;
|
228
|
+
/**
|
229
|
+
* Returns a new array containing all items from _this_ array, and _other_ array
|
230
|
+
* @param other Another array to concat with this one
|
231
|
+
*/
|
232
|
+
concat(other: Arc4ArrayBase<TItem>): DynamicArray<TItem>;
|
233
|
+
/**
|
234
|
+
* Return the array items as a native immutable array
|
235
|
+
*/
|
236
|
+
get native(): TItem[];
|
100
237
|
}
|
238
|
+
/**
|
239
|
+
* @hidden
|
240
|
+
*/
|
101
241
|
type ExpandTupleType<T extends ARC4Encoded[]> = T extends [infer T1 extends ARC4Encoded, ...infer TRest extends ARC4Encoded[]] ? TRest extends [] ? `${T1[typeof TypeProperty]}` : `${T1[typeof TypeProperty]},${ExpandTupleType<TRest>}` : '';
|
242
|
+
/**
|
243
|
+
* An arc4 encoded tuple of values
|
244
|
+
* @typeParam TTuple A type representing the native tuple of item types
|
245
|
+
*/
|
102
246
|
export declare class Tuple<TTuple extends [ARC4Encoded, ...ARC4Encoded[]]> extends ARC4Encoded {
|
247
|
+
/** @hidden */
|
103
248
|
[TypeProperty]?: `arc4.Tuple<${ExpandTupleType<TTuple>}>`;
|
249
|
+
/**
|
250
|
+
* Create a new Tuple with the default zero values for items
|
251
|
+
*/
|
252
|
+
constructor();
|
253
|
+
/**
|
254
|
+
* Create a new Tuple with the specified items
|
255
|
+
* @param items The tuple items
|
256
|
+
*/
|
104
257
|
constructor(...items: TTuple);
|
258
|
+
/**
|
259
|
+
* Returns the item at the specified index
|
260
|
+
* @param index The index of the item to get. Must be a positive literal representing a tuple index
|
261
|
+
*/
|
105
262
|
at<TIndex extends keyof TTuple>(index: TIndex): TTuple[TIndex];
|
263
|
+
/**
|
264
|
+
* Returns the length of this tuple
|
265
|
+
*/
|
106
266
|
get length(): TTuple['length'] & uint64;
|
267
|
+
/**
|
268
|
+
* Returns the decoded native tuple (with arc4 encoded items)
|
269
|
+
*/
|
107
270
|
get native(): TTuple;
|
108
271
|
}
|
109
|
-
|
272
|
+
/**
|
273
|
+
* A 32 byte Algorand Address
|
274
|
+
*/
|
275
|
+
export declare class Address extends Arc4ArrayBase<Byte> {
|
276
|
+
/** @hidden */
|
110
277
|
[TypeProperty]?: `arc4.Address`;
|
278
|
+
/**
|
279
|
+
* Create a new Address instance
|
280
|
+
* @param value An Account, base 32 address string, or the address bytes
|
281
|
+
*/
|
111
282
|
constructor(value?: Account | string | bytes);
|
283
|
+
/**
|
284
|
+
* Returns an Account instance for this Address
|
285
|
+
*/
|
112
286
|
get native(): Account;
|
113
287
|
}
|
114
|
-
|
115
|
-
|
288
|
+
/**
|
289
|
+
* The base type for arc4 structs
|
290
|
+
*/
|
291
|
+
declare class StructBase<T> extends ARC4Encoded {
|
292
|
+
/** @hidden */
|
116
293
|
[TypeProperty]: string;
|
294
|
+
get native(): T;
|
295
|
+
/**
|
296
|
+
* Returns a deep copy of this struct
|
297
|
+
*/
|
298
|
+
copy(): this;
|
117
299
|
}
|
118
|
-
|
300
|
+
/**
|
301
|
+
* Type alias for the Struct constructor function
|
302
|
+
* @typeParam T The shape of the arc4 struct
|
303
|
+
*/
|
304
|
+
type StructConstructor = {
|
305
|
+
new <T extends Record<string, ARC4Encoded>>(initial: T): StructBase<T> & T;
|
306
|
+
};
|
307
|
+
/**
|
308
|
+
* The base type of arc4 structs
|
309
|
+
*
|
310
|
+
* Usage:
|
311
|
+
* ```
|
312
|
+
* class MyStruct extends Struct<{ x: UintN8, y: Str, z: DynamicBytes }> {}
|
313
|
+
* ```
|
314
|
+
*/
|
119
315
|
export declare const Struct: StructConstructor;
|
120
|
-
|
316
|
+
/**
|
317
|
+
* A variable length sequence of bytes prefixed with its length expressed as a 2 byte uint
|
318
|
+
*/
|
319
|
+
export declare class DynamicBytes extends Arc4ArrayBase<Byte> {
|
320
|
+
/** @hidden */
|
121
321
|
[TypeProperty]?: `arc4.DynamicBytes`;
|
322
|
+
/**
|
323
|
+
* Create a new DynamicBytes instance
|
324
|
+
* @param value The bytes or utf8 interpreted string to initialize this type
|
325
|
+
*/
|
122
326
|
constructor(value?: bytes | string);
|
327
|
+
/**
|
328
|
+
* Get the native bytes value (excludes the length prefix)
|
329
|
+
*/
|
123
330
|
get native(): bytes;
|
331
|
+
/**
|
332
|
+
* Returns a dynamic bytes object containing all bytes from _this_ and _other_
|
333
|
+
* @param other Another array of bytes to concat with this one
|
334
|
+
*/
|
335
|
+
concat(other: Arc4ArrayBase<Byte>): DynamicBytes;
|
124
336
|
}
|
125
|
-
|
337
|
+
/**
|
338
|
+
* A fixed length sequence of bytes
|
339
|
+
*/
|
340
|
+
export declare class StaticBytes<TLength extends number = 0> extends Arc4ArrayBase<Byte> {
|
341
|
+
/** @hidden */
|
126
342
|
[TypeProperty]?: `arc4.StaticBytes<${TLength}>`;
|
343
|
+
/**
|
344
|
+
* Create a new StaticBytes instance
|
345
|
+
* @param value THe bytes or utf8 interpreted string to initialize this type
|
346
|
+
*/
|
127
347
|
constructor(value?: bytes | string);
|
348
|
+
/**
|
349
|
+
* Get the native bytes value
|
350
|
+
*/
|
128
351
|
get native(): bytes;
|
352
|
+
/**
|
353
|
+
* Returns a dynamic bytes object containing all bytes from _this_ and _other_
|
354
|
+
* @param other Another array of bytes to concat with this one
|
355
|
+
*/
|
356
|
+
concat(other: Arc4ArrayBase<Byte>): DynamicBytes;
|
129
357
|
}
|
130
|
-
/**
|
131
|
-
* Interpret the provided bytes as an ARC4 encoded type with no validation
|
132
|
-
* @param bytes An arc4 encoded bytes value
|
133
|
-
* @param prefix The prefix (if any), present in the bytes value. This prefix will be validated and removed
|
134
|
-
*/
|
135
|
-
export declare function interpretAsArc4<T extends ARC4Encoded>(bytes: BytesCompat, prefix?: 'none' | 'log'): T;
|
136
|
-
/**
|
137
|
-
* Decode the provided bytes to a native Algorand TypeScript value
|
138
|
-
* @param bytes An arc4 encoded bytes value
|
139
|
-
* @param prefix The prefix (if any), present in the bytes value. This prefix will be validated and removed
|
140
|
-
*/
|
141
|
-
export declare function decodeArc4<T>(bytes: BytesCompat, prefix?: 'none' | 'log'): T;
|
142
|
-
/**
|
143
|
-
* Encode the provided Algorand TypeScript value as ARC4 bytes
|
144
|
-
* @param value Any native Algorand TypeScript value with a supported ARC4 encoding
|
145
|
-
*/
|
146
|
-
export declare function encodeArc4<T>(value: T): bytes;
|
147
358
|
export {};
|
package/arc4/index.d.ts
CHANGED
@@ -1,26 +1,80 @@
|
|
1
1
|
import { BaseContract } from '../base-contract';
|
2
|
-
import {
|
3
|
-
import {
|
2
|
+
import { AnyFunction, DeliberateAny, InstanceMethod } from '../internal/typescript-helpers';
|
3
|
+
import { OnCompleteActionStr } from '../on-complete-action';
|
4
|
+
import { bytes, BytesCompat, uint64 } from '../primitives';
|
5
|
+
import { ARC4Encoded } from './encoded-types';
|
4
6
|
export * from './encoded-types';
|
7
|
+
export * from './c2c';
|
8
|
+
/**
|
9
|
+
* The base type for all ARC4 contracts in Algorand TypeScript
|
10
|
+
*/
|
5
11
|
export declare class Contract extends BaseContract {
|
6
|
-
|
12
|
+
/**
|
13
|
+
* Default implementation of an ARC4 approval program, routes transactions to ABI or bare methods based on application
|
14
|
+
* args and on completion actions
|
15
|
+
*/
|
7
16
|
approvalProgram(): boolean;
|
8
17
|
}
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
+
/**
|
19
|
+
* Defines conventional routing method names. When used, methods with these names will be implicitly routed to the corresponding
|
20
|
+
* application lifecycle event.
|
21
|
+
*
|
22
|
+
* @remarks This behaviour is independent of a contract explicitly implementing this interface. The interface is provided simply to improve
|
23
|
+
* the developer experience of using this feature.
|
24
|
+
*/
|
25
|
+
export interface ConventionalRouting {
|
26
|
+
/**
|
27
|
+
* The function to invoke when closing out of this application
|
28
|
+
*/
|
29
|
+
closeOutOfApplication?: AnyFunction;
|
30
|
+
/**
|
31
|
+
* The function to invoke when creating this application
|
32
|
+
*/
|
33
|
+
createApplication?: AnyFunction;
|
34
|
+
/**
|
35
|
+
* The function to invoke when deleting this application
|
36
|
+
*/
|
37
|
+
deleteApplication?: AnyFunction;
|
38
|
+
/**
|
39
|
+
* The function to invoke when opting in to this application
|
40
|
+
*/
|
41
|
+
optInToApplication?: AnyFunction;
|
42
|
+
/**
|
43
|
+
* The function to invoke when updating this application
|
44
|
+
*/
|
45
|
+
updateApplication?: AnyFunction;
|
18
46
|
}
|
47
|
+
/**
|
48
|
+
* The possible options for a method being available on application create
|
49
|
+
*
|
50
|
+
* allow: This method CAN be called when the application is being created, but it is not required
|
51
|
+
* disallow: This method CANNOT be called when the application is being created
|
52
|
+
* require: This method CAN ONLY be called when the application is being created
|
53
|
+
*/
|
54
|
+
export type CreateOptions = 'allow' | 'disallow' | 'require';
|
55
|
+
/**
|
56
|
+
* Type alias for a default argument schema
|
57
|
+
* @typeParam TContract The type of the contract containing the method this default argument is for
|
58
|
+
*/
|
19
59
|
export type DefaultArgument<TContract extends Contract> = {
|
60
|
+
/**
|
61
|
+
* A compile time constant value to be used as a default
|
62
|
+
*/
|
20
63
|
constant: string | boolean | number | bigint;
|
21
64
|
} | {
|
65
|
+
/**
|
66
|
+
* Retrieve the default value from a member of this contract. The member can be
|
67
|
+
*
|
68
|
+
* LocalState: The value is retrieved from the calling user's local state before invoking this method
|
69
|
+
* GlobalState: The value is retrieved from the specified global state key before invoking this method
|
70
|
+
* Method: Any readonly abimethod with no arguments can be used as a source
|
71
|
+
*/
|
22
72
|
from: keyof TContract;
|
23
73
|
};
|
74
|
+
/**
|
75
|
+
* Configuration options for an abi method
|
76
|
+
* @typeParam TContract the type of the contract this method is a part of
|
77
|
+
*/
|
24
78
|
export type AbiMethodConfig<TContract extends Contract> = {
|
25
79
|
/**
|
26
80
|
* Which on complete action(s) are allowed when invoking this method.
|
@@ -41,9 +95,22 @@ export type AbiMethodConfig<TContract extends Contract> = {
|
|
41
95
|
* Override the name used to generate the abi method selector
|
42
96
|
*/
|
43
97
|
name?: string;
|
98
|
+
/**
|
99
|
+
* Specify default arguments that can be populated by clients calling this method.
|
100
|
+
*
|
101
|
+
* A map of parameter names to the default argument source
|
102
|
+
*/
|
44
103
|
defaultArguments?: Record<string, DefaultArgument<TContract>>;
|
45
104
|
};
|
105
|
+
/**
|
106
|
+
* Declares the decorated method as an abimethod that is called when the first transaction arg matches the method selector
|
107
|
+
* @param config The config for this abi method
|
108
|
+
* @typeParam TContract the type of the contract this method is a part of
|
109
|
+
*/
|
46
110
|
export declare function abimethod<TContract extends Contract>(config?: AbiMethodConfig<TContract>): <TArgs extends DeliberateAny[], TReturn>(target: (this: TContract, ...args: TArgs) => TReturn, ctx: ClassMethodDecoratorContext<TContract>) => (this: TContract, ...args: TArgs) => TReturn;
|
111
|
+
/**
|
112
|
+
* Configuration options for a bare method
|
113
|
+
*/
|
47
114
|
export type BareMethodConfig = {
|
48
115
|
/**
|
49
116
|
* Which on complete action(s) are allowed when invoking this method.
|
@@ -56,11 +123,47 @@ export type BareMethodConfig = {
|
|
56
123
|
*/
|
57
124
|
onCreate?: CreateOptions;
|
58
125
|
};
|
126
|
+
/**
|
127
|
+
* Declares the decorated method as a baremethod that can only be called with no transaction args
|
128
|
+
* @param config The config for this bare method
|
129
|
+
* @typeParam TContract the type of the contract this method is a part of
|
130
|
+
*/
|
59
131
|
export declare function baremethod<TContract extends Contract>(config?: BareMethodConfig): <TArgs extends DeliberateAny[], TReturn>(target: (this: TContract, ...args: TArgs) => TReturn, ctx: ClassMethodDecoratorContext<TContract>) => (this: TContract, ...args: TArgs) => TReturn;
|
60
132
|
/**
|
61
133
|
* Returns the ARC4 method selector for a given ARC4 method signature. The method selector is the first
|
62
134
|
* 4 bytes of the SHA512/256 hash of the method signature.
|
63
|
-
* @param methodSignature An ARC4 method
|
135
|
+
* @param methodSignature An ARC4 contract method reference. (Eg. `MyContract.prototype.myMethod`)
|
136
|
+
* @returns The ARC4 method selector. Eg. `02BECE11`
|
137
|
+
*/
|
138
|
+
export declare function methodSelector(methodSignature: InstanceMethod<Contract>): bytes;
|
139
|
+
/**
|
140
|
+
* Returns the ARC4 method selector for a given ARC4 method signature. The method selector is the first
|
141
|
+
* 4 bytes of the SHA512/256 hash of the method signature.
|
142
|
+
* @param methodSignature An ARC4 method signature string (Eg. `hello(string)string`. Must be a compile time constant)
|
64
143
|
* @returns The ARC4 method selector. Eg. `02BECE11`
|
65
144
|
*/
|
66
145
|
export declare function methodSelector(methodSignature: string): bytes;
|
146
|
+
/**
|
147
|
+
* Interpret the provided bytes as an ARC4 encoded type with no validation
|
148
|
+
* @param bytes An arc4 encoded bytes value
|
149
|
+
* @param prefix The prefix (if any), present in the bytes value. This prefix will be validated and removed
|
150
|
+
*/
|
151
|
+
export declare function interpretAsArc4<T extends ARC4Encoded>(bytes: BytesCompat, prefix?: 'none' | 'log'): T;
|
152
|
+
/**
|
153
|
+
* Decode the provided bytes to a native Algorand TypeScript value
|
154
|
+
* @param bytes An arc4 encoded bytes value
|
155
|
+
* @param prefix The prefix (if any), present in the bytes value. This prefix will be validated and removed
|
156
|
+
*/
|
157
|
+
export declare function decodeArc4<T>(bytes: BytesCompat, prefix?: 'none' | 'log'): T;
|
158
|
+
/**
|
159
|
+
* Encode the provided Algorand TypeScript value as ARC4 bytes
|
160
|
+
* @param value Any native Algorand TypeScript value with a supported ARC4 encoding
|
161
|
+
*/
|
162
|
+
export declare function encodeArc4<const T>(value: T): bytes;
|
163
|
+
/**
|
164
|
+
* Return the total number of bytes required to store T as ARC4 bytes.
|
165
|
+
*
|
166
|
+
* T must represent a type with a fixed length encoding scheme.
|
167
|
+
* @typeParam T Any native or arc4 type with a fixed encoding size.
|
168
|
+
*/
|
169
|
+
export declare function arc4EncodedLength<T>(): uint64;
|
package/arc4/index.mjs
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
export {
|
2
|
-
import '../
|
3
|
-
import 'node:buffer';
|
4
|
-
import 'node:util';
|
1
|
+
export { A as ARC4Encoded, t as Address, r as Bool, h as Byte, C as Contract, D as DynamicArray, v as DynamicBytes, s as StaticArray, w as StaticBytes, S as Str, u as Struct, T as Tuple, q as UFixedNxM, U as UintN, o as UintN128, k as UintN16, p as UintN256, l as UintN32, n as UintN64, j as UintN8, y as abiCall, a as abimethod, g as arc4EncodedLength, b as baremethod, x as compileArc4, e as decodeArc4, f as encodeArc4, d as interpretAsArc4, m as methodSelector } from '../index-dzo0agbK.js';
|
2
|
+
import '../errors-D124-zqo.js';
|
5
3
|
//# sourceMappingURL=index.mjs.map
|
package/arc4/index.mjs.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|