@algorandfoundation/algorand-typescript 1.0.0 → 1.0.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/arc-28.d.ts +3 -3
- package/arc4/c2c.d.ts +19 -16
- package/arc4/encoded-types.d.ts +99 -57
- package/arc4/index.d.ts +83 -10
- package/arc4/index.mjs +2 -2
- package/arrays.d.ts +75 -0
- package/base-contract.d.ts +2 -2
- package/box.d.ts +25 -89
- package/compiled.d.ts +15 -15
- package/errors-Bg4n2Chz.js +29 -0
- package/errors-Bg4n2Chz.js.map +1 -0
- package/gtxn.d.ts +617 -611
- package/{index-rjo2X8sp.js → index-C_DRi4sH.js} +96 -88
- package/index-C_DRi4sH.js.map +1 -0
- package/index.d.ts +8 -6
- package/index.mjs +363 -43
- package/index.mjs.map +1 -1
- package/internal/errors.d.ts +1 -0
- package/itxn-compose.d.ts +48 -0
- package/itxn.d.ts +1101 -1088
- package/logic-sig.d.ts +2 -2
- package/{op-BgdftarW.js → op-BUFe04-Y.js} +76 -34
- package/op-BUFe04-Y.js.map +1 -0
- package/op.d.ts +115 -85
- package/op.mjs +2 -2
- package/package.json +1 -11
- package/primitives.d.ts +129 -16
- package/{mutable-array.d.ts → reference-array.d.ts} +22 -6
- package/reference.d.ts +6 -3
- package/util.d.ts +33 -4
- package/errors-D124-zqo.js +0 -12
- package/errors-D124-zqo.js.map +0 -1
- package/gtxn-CXBH4yay.js +0 -71
- package/gtxn-CXBH4yay.js.map +0 -1
- package/gtxn.mjs +0 -3
- package/gtxn.mjs.map +0 -1
- package/index-rjo2X8sp.js.map +0 -1
- package/itxn-CPeSA_Q_.js +0 -202
- package/itxn-CPeSA_Q_.js.map +0 -1
- package/itxn.mjs +0 -3
- package/itxn.mjs.map +0 -1
- package/op-BgdftarW.js.map +0 -1
package/arc-28.d.ts
CHANGED
|
@@ -7,8 +7,8 @@ import { DeliberateAny } from './internal/typescript-helpers';
|
|
|
7
7
|
* @param event An ARC4Struct instance, or a plain object with a named type
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
|
-
* class Demo extends Struct<{ a:
|
|
11
|
-
* emit(new Demo({ a: new
|
|
10
|
+
* class Demo extends Struct<{ a: Uint64 }> {}
|
|
11
|
+
* emit(new Demo({ a: new Uint64(123) }))
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
14
|
* type Demo = { a: uint64 }
|
|
@@ -25,7 +25,7 @@ export declare function emit<TEvent extends Record<string, DeliberateAny>>(event
|
|
|
25
25
|
* @param eventProps A set of event properties (order is significant)
|
|
26
26
|
*
|
|
27
27
|
* @example
|
|
28
|
-
* emit("Demo", new
|
|
28
|
+
* emit("Demo", new Uint64(123))
|
|
29
29
|
*
|
|
30
30
|
* @example
|
|
31
31
|
* const a: uint64 = 123
|
package/arc4/c2c.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { CompileContractOptions, CompiledContract } from '../compiled';
|
|
2
|
-
import
|
|
3
|
-
import { AnyFunction, ConstructorFor,
|
|
4
|
-
import
|
|
5
|
-
import { ApplicationCallFields, ApplicationCallInnerTxn } from '../itxn';
|
|
2
|
+
import { gtxn } from '../gtxn';
|
|
3
|
+
import { AnyFunction, ConstructorFor, InstanceMethod } from '../internal/typescript-helpers';
|
|
4
|
+
import { itxn } from '../itxn';
|
|
6
5
|
import { Contract } from './index';
|
|
7
6
|
/**
|
|
8
7
|
* Defines txn fields that are available for a bare create application call.
|
|
@@ -11,7 +10,7 @@ import { Contract } from './index';
|
|
|
11
10
|
* - appId: because the appId is not known when creating an application
|
|
12
11
|
* - appArgs: because a bare call cannot have arguments
|
|
13
12
|
*/
|
|
14
|
-
export type BareCreateApplicationCallFields = Omit<ApplicationCallFields, 'appId' | 'appArgs'>;
|
|
13
|
+
export type BareCreateApplicationCallFields = Omit<itxn.ApplicationCallFields, 'appId' | 'appArgs'>;
|
|
15
14
|
/**
|
|
16
15
|
* Conditional type which given a group transaction type, returns the equivalent inner transaction
|
|
17
16
|
* params type.
|
|
@@ -27,24 +26,24 @@ export type TypedApplicationArg<TArg> = TArg extends gtxn.Transaction ? GtxnToIt
|
|
|
27
26
|
/**
|
|
28
27
|
* Conditional type which maps a tuple of application arguments to a tuple of input types for specifying those arguments.
|
|
29
28
|
*/
|
|
30
|
-
export type TypedApplicationArgs<TArgs> = TArgs extends [] ? [] : TArgs extends [infer TArg, ...infer TRest] ? [TypedApplicationArg<TArg>, ...TypedApplicationArgs<TRest>] : never;
|
|
29
|
+
export type TypedApplicationArgs<TArgs> = TArgs extends never ? unknown[] : TArgs extends [] ? [] : TArgs extends [infer TArg, ...infer TRest] ? readonly [TypedApplicationArg<TArg>, ...TypedApplicationArgs<TRest>] : never;
|
|
31
30
|
/**
|
|
32
31
|
* Application call fields with `appArgs` replaced with an `args` property that is strongly typed to the actual arguments for the
|
|
33
32
|
* given application call.
|
|
34
33
|
*/
|
|
35
|
-
export type TypedApplicationCallFields<TArgs> = Omit<ApplicationCallFields, 'appArgs'> & (TArgs extends [] ? {
|
|
36
|
-
args?: TypedApplicationArgs<TArgs>;
|
|
34
|
+
export type TypedApplicationCallFields<TArgs> = Omit<itxn.ApplicationCallFields, 'appArgs'> & (TArgs extends [] ? {
|
|
35
|
+
readonly args?: TypedApplicationArgs<TArgs>;
|
|
37
36
|
} : {
|
|
38
|
-
args: TypedApplicationArgs<TArgs>;
|
|
37
|
+
readonly args: TypedApplicationArgs<TArgs>;
|
|
39
38
|
});
|
|
40
39
|
/**
|
|
41
40
|
* The response type of a typed application call. Includes the raw itxn result object and the parsed ABI return value if applicable.
|
|
42
41
|
*/
|
|
43
42
|
export type TypedApplicationCallResponse<TReturn> = TReturn extends void ? {
|
|
44
|
-
itxn: ApplicationCallInnerTxn;
|
|
43
|
+
readonly itxn: itxn.ApplicationCallInnerTxn;
|
|
45
44
|
} : {
|
|
46
|
-
itxn: ApplicationCallInnerTxn;
|
|
47
|
-
returnValue: TReturn;
|
|
45
|
+
readonly itxn: itxn.ApplicationCallInnerTxn;
|
|
46
|
+
readonly returnValue: TReturn;
|
|
48
47
|
};
|
|
49
48
|
/**
|
|
50
49
|
* Conditional type which maps an ABI method to a factory method for constructing an application call transaction to call that method.
|
|
@@ -65,7 +64,7 @@ export type ContractProxy<TContract extends Contract> = CompiledContract & {
|
|
|
65
64
|
* Create a bare application call itxn to create the contract.
|
|
66
65
|
* @param fields Specify values for transaction fields which should override the default values.
|
|
67
66
|
*/
|
|
68
|
-
bareCreate(fields?: BareCreateApplicationCallFields): ApplicationCallInnerTxn;
|
|
67
|
+
bareCreate(fields?: BareCreateApplicationCallFields): itxn.ApplicationCallInnerTxn;
|
|
69
68
|
};
|
|
70
69
|
/**
|
|
71
70
|
* Pre compile the target ARC4 contract and return a proxy object for constructing inner transactions to call an instance of that contract.
|
|
@@ -73,9 +72,13 @@ export type ContractProxy<TContract extends Contract> = CompiledContract & {
|
|
|
73
72
|
* @param options Compile contract arguments
|
|
74
73
|
*/
|
|
75
74
|
export declare function compileArc4<TContract extends Contract>(contract: ConstructorFor<TContract>, options?: CompileContractOptions): ContractProxy<TContract>;
|
|
75
|
+
export interface AbiCallOptions<TMethod> extends Omit<itxn.ApplicationCallFields, 'appArgs'> {
|
|
76
|
+
readonly method?: TMethod;
|
|
77
|
+
readonly args?: TMethod extends InstanceMethod<Contract, infer TParams> ? TypedApplicationArgs<TParams> : unknown[];
|
|
78
|
+
}
|
|
79
|
+
export type AbiCallResponse<TMethod> = TMethod extends InstanceMethod<Contract, infer TParams, infer TResult> ? TypedApplicationCallResponse<TResult> : TypedApplicationCallResponse<unknown>;
|
|
76
80
|
/**
|
|
77
81
|
* Invokes the target ABI method using a strongly typed fields object.
|
|
78
|
-
* @param
|
|
79
|
-
* @param fields Specify values for transaction fields.
|
|
82
|
+
* @param options Specify options for the abi call.
|
|
80
83
|
*/
|
|
81
|
-
export declare function abiCall<
|
|
84
|
+
export declare function abiCall<TMethod>(options: AbiCallOptions<TMethod>): AbiCallResponse<TMethod>;
|
package/arc4/encoded-types.d.ts
CHANGED
|
@@ -9,13 +9,9 @@ type UintBitSize = 8 | 16 | 24 | 32 | 40 | 48 | 56 | 64;
|
|
|
9
9
|
*/
|
|
10
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
11
|
/**
|
|
12
|
-
* Defines supported bit sizes for the UintN and
|
|
12
|
+
* Defines supported bit sizes for the UintN and UFixed types
|
|
13
13
|
*/
|
|
14
14
|
export type BitSize = UintBitSize | BigUintBitSize;
|
|
15
|
-
/**
|
|
16
|
-
* Conditional type which returns the native equivalent type for a given UintN bit size
|
|
17
|
-
*/
|
|
18
|
-
type NativeForArc4Int<N extends BitSize> = N extends UintBitSize ? uint64 : biguint;
|
|
19
15
|
/**
|
|
20
16
|
* Conditional type which returns the compat type relevant to a given UintN bit size
|
|
21
17
|
*/
|
|
@@ -28,7 +24,15 @@ declare const TypeProperty: unique symbol;
|
|
|
28
24
|
* A base type for ARC4 encoded values
|
|
29
25
|
*/
|
|
30
26
|
export declare abstract class ARC4Encoded implements BytesBacked {
|
|
31
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* @hidden
|
|
29
|
+
*
|
|
30
|
+
* Since TypeScript is structurally typed, different ARC4Encodeds with compatible
|
|
31
|
+
* structures will often be assignable to one and another and this is generally
|
|
32
|
+
* not desirable. The TypeProperty property should be used to declare a literal value
|
|
33
|
+
* (usually the class name) on each distinct ARC4Encoded class to ensure they are
|
|
34
|
+
* structurally different.
|
|
35
|
+
*/
|
|
32
36
|
abstract [TypeProperty]?: string;
|
|
33
37
|
/**
|
|
34
38
|
* Retrieve the encoded bytes for this type
|
|
@@ -54,76 +58,76 @@ export declare class Str extends ARC4Encoded {
|
|
|
54
58
|
/**
|
|
55
59
|
* A fixed bit size unsigned int
|
|
56
60
|
*/
|
|
57
|
-
export declare class
|
|
61
|
+
export declare class Uint<N extends BitSize> extends ARC4Encoded {
|
|
58
62
|
/** @hidden */
|
|
59
|
-
[TypeProperty]?: `arc4.
|
|
63
|
+
[TypeProperty]?: `arc4.Uint<${N}>`;
|
|
60
64
|
/**
|
|
61
65
|
* Create a new UintN instance
|
|
62
66
|
* @param v The native uint64 or biguint value to initialize this UintN from
|
|
63
67
|
*/
|
|
64
68
|
constructor(v?: CompatForArc4Int<N>);
|
|
65
69
|
/**
|
|
66
|
-
* Retrieve the decoded native uint64
|
|
70
|
+
* Retrieve the decoded native uint64
|
|
67
71
|
*/
|
|
68
|
-
|
|
72
|
+
asUint64(): uint64;
|
|
73
|
+
/**
|
|
74
|
+
* Retrieve the decoded native biguint
|
|
75
|
+
*/
|
|
76
|
+
asBigUint(): biguint;
|
|
69
77
|
}
|
|
70
78
|
/**
|
|
71
|
-
* An alias for
|
|
79
|
+
* An alias for Uint<8>
|
|
72
80
|
*/
|
|
73
|
-
export declare class Byte extends
|
|
81
|
+
export declare class Byte extends Uint<8> {
|
|
74
82
|
}
|
|
75
83
|
/**
|
|
76
|
-
* An alias for
|
|
84
|
+
* An alias for Uint<8>
|
|
77
85
|
*/
|
|
78
|
-
export declare class
|
|
86
|
+
export declare class Uint8 extends Uint<8> {
|
|
79
87
|
}
|
|
80
88
|
/**
|
|
81
|
-
* An alias for
|
|
89
|
+
* An alias for Uint<16>
|
|
82
90
|
*/
|
|
83
|
-
export declare class
|
|
91
|
+
export declare class Uint16 extends Uint<16> {
|
|
84
92
|
}
|
|
85
93
|
/**
|
|
86
|
-
* An alias for
|
|
94
|
+
* An alias for Uint<32>
|
|
87
95
|
*/
|
|
88
|
-
export declare class
|
|
96
|
+
export declare class Uint32 extends Uint<32> {
|
|
89
97
|
}
|
|
90
98
|
/**
|
|
91
|
-
* An alias for
|
|
99
|
+
* An alias for Uint<64>
|
|
92
100
|
*/
|
|
93
|
-
export declare class
|
|
101
|
+
export declare class Uint64 extends Uint<64> {
|
|
94
102
|
}
|
|
95
103
|
/**
|
|
96
|
-
* An alias for
|
|
104
|
+
* An alias for Uint<128>
|
|
97
105
|
*/
|
|
98
|
-
export declare class
|
|
106
|
+
export declare class Uint128 extends Uint<128> {
|
|
99
107
|
}
|
|
100
108
|
/**
|
|
101
|
-
* An alias for
|
|
109
|
+
* An alias for Uint<256>
|
|
102
110
|
*/
|
|
103
|
-
export declare class
|
|
111
|
+
export declare class Uint256 extends Uint<256> {
|
|
104
112
|
}
|
|
105
113
|
/**
|
|
106
114
|
* A fixed bit size, fixed decimal unsigned value
|
|
107
115
|
*/
|
|
108
|
-
export declare class
|
|
116
|
+
export declare class UFixed<N extends BitSize, M extends number> extends ARC4Encoded {
|
|
109
117
|
/** @hidden */
|
|
110
|
-
[TypeProperty]?: `arc4.
|
|
118
|
+
[TypeProperty]?: `arc4.UFixed<${N}x${M}>`;
|
|
111
119
|
/**
|
|
112
|
-
* Create a new
|
|
120
|
+
* Create a new UFixed value
|
|
113
121
|
* @param v A string representing the integer and fractional portion of the number
|
|
114
122
|
*/
|
|
115
|
-
constructor(v
|
|
116
|
-
/**
|
|
117
|
-
* Retrieve the decoded native uint64 or biguint where the returned integer represents the fixed decimal value * (10 ^ M)
|
|
118
|
-
*/
|
|
119
|
-
get native(): NativeForArc4Int<N>;
|
|
123
|
+
constructor(v?: `${number}.${number}`);
|
|
120
124
|
}
|
|
121
125
|
/**
|
|
122
126
|
* A boolean value
|
|
123
127
|
*/
|
|
124
128
|
export declare class Bool extends ARC4Encoded {
|
|
125
129
|
/** @hidden */
|
|
126
|
-
[TypeProperty]?:
|
|
130
|
+
[TypeProperty]?: 'arc4.Bool';
|
|
127
131
|
/**
|
|
128
132
|
* Create a new Bool value
|
|
129
133
|
* @param v The native boolean to initialize this value from
|
|
@@ -137,7 +141,7 @@ export declare class Bool extends ARC4Encoded {
|
|
|
137
141
|
/**
|
|
138
142
|
* A base type for arc4 array types
|
|
139
143
|
*/
|
|
140
|
-
declare abstract class Arc4ArrayBase<TItem extends ARC4Encoded> extends ARC4Encoded {
|
|
144
|
+
declare abstract class Arc4ArrayBase<TItem extends ARC4Encoded> extends ARC4Encoded implements ConcatArray<TItem> {
|
|
141
145
|
protected constructor();
|
|
142
146
|
/**
|
|
143
147
|
* Returns the current length of this array
|
|
@@ -149,6 +153,30 @@ declare abstract class Arc4ArrayBase<TItem extends ARC4Encoded> extends ARC4Enco
|
|
|
149
153
|
* @param index The index of the item to retrieve
|
|
150
154
|
*/
|
|
151
155
|
at(index: Uint64Compat): TItem;
|
|
156
|
+
/** @deprecated Array slicing is not yet supported in Algorand TypeScript
|
|
157
|
+
* Create a new Dynamic array with all items from this array
|
|
158
|
+
*/
|
|
159
|
+
slice(): Array<TItem>;
|
|
160
|
+
/** @deprecated Array slicing is not yet supported in Algorand TypeScript
|
|
161
|
+
* Create a new DynamicArray with all items up till `end`.
|
|
162
|
+
* Negative indexes are taken from the end.
|
|
163
|
+
* @param end An index in which to stop copying items.
|
|
164
|
+
*/
|
|
165
|
+
slice(end: Uint64Compat): Array<TItem>;
|
|
166
|
+
/** @deprecated Array slicing is not yet supported in Algorand TypeScript
|
|
167
|
+
* Create a new DynamicArray with items from `start`, up until `end`
|
|
168
|
+
* Negative indexes are taken from the end.
|
|
169
|
+
* @param start An index in which to start copying items.
|
|
170
|
+
* @param end An index in which to stop copying items
|
|
171
|
+
*/
|
|
172
|
+
slice(start: Uint64Compat, end: Uint64Compat): Array<TItem>;
|
|
173
|
+
/**
|
|
174
|
+
* Creates a string by concatenating all the items in the array delimited by the
|
|
175
|
+
* specified separator (or ',' by default)
|
|
176
|
+
* @param separator
|
|
177
|
+
* @deprecated Join is not supported in Algorand TypeScript
|
|
178
|
+
*/
|
|
179
|
+
join(separator?: string): string;
|
|
152
180
|
/**
|
|
153
181
|
* Returns an iterator for the items in this array
|
|
154
182
|
*/
|
|
@@ -186,15 +214,15 @@ export declare class StaticArray<TItem extends ARC4Encoded, TLength extends numb
|
|
|
186
214
|
constructor(...items: TItem[] & {
|
|
187
215
|
length: TLength;
|
|
188
216
|
});
|
|
189
|
-
/**
|
|
190
|
-
* Returns a copy of this array
|
|
191
|
-
*/
|
|
192
|
-
copy(): StaticArray<TItem, TLength>;
|
|
193
217
|
/**
|
|
194
218
|
* Returns a new array containing all items from _this_ array, and _other_ array
|
|
195
219
|
* @param other Another array to concat with this one
|
|
196
220
|
*/
|
|
197
221
|
concat(other: Arc4ArrayBase<TItem>): DynamicArray<TItem>;
|
|
222
|
+
/**
|
|
223
|
+
* Returns the statically declared length of this array
|
|
224
|
+
*/
|
|
225
|
+
get length(): uint64;
|
|
198
226
|
}
|
|
199
227
|
/**
|
|
200
228
|
* A dynamic sized array of arc4 items
|
|
@@ -217,10 +245,6 @@ export declare class DynamicArray<TItem extends ARC4Encoded> extends Arc4ArrayBa
|
|
|
217
245
|
* Pop a single item from this array
|
|
218
246
|
*/
|
|
219
247
|
pop(): TItem;
|
|
220
|
-
/**
|
|
221
|
-
* Returns a copy of this array
|
|
222
|
-
*/
|
|
223
|
-
copy(): DynamicArray<TItem>;
|
|
224
248
|
/**
|
|
225
249
|
* Returns a new array containing all items from _this_ array, and _other_ array
|
|
226
250
|
* @param other Another array to concat with this one
|
|
@@ -230,14 +254,18 @@ export declare class DynamicArray<TItem extends ARC4Encoded> extends Arc4ArrayBa
|
|
|
230
254
|
/**
|
|
231
255
|
* @hidden
|
|
232
256
|
*/
|
|
233
|
-
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>}` : '';
|
|
257
|
+
type ExpandTupleType<T extends readonly ARC4Encoded[]> = T extends [infer T1 extends ARC4Encoded, ...infer TRest extends ARC4Encoded[]] ? TRest extends [] ? `${T1[typeof TypeProperty]}` : `${T1[typeof TypeProperty]},${ExpandTupleType<TRest>}` : '';
|
|
234
258
|
/**
|
|
235
259
|
* An arc4 encoded tuple of values
|
|
236
260
|
* @typeParam TTuple A type representing the native tuple of item types
|
|
237
261
|
*/
|
|
238
|
-
export declare class Tuple<TTuple extends [ARC4Encoded, ...ARC4Encoded[]]> extends ARC4Encoded {
|
|
262
|
+
export declare class Tuple<const TTuple extends readonly [ARC4Encoded, ...ARC4Encoded[]]> extends ARC4Encoded {
|
|
239
263
|
/** @hidden */
|
|
240
264
|
[TypeProperty]?: `arc4.Tuple<${ExpandTupleType<TTuple>}>`;
|
|
265
|
+
/**
|
|
266
|
+
* Create a new Tuple with the default zero values for items
|
|
267
|
+
*/
|
|
268
|
+
constructor();
|
|
241
269
|
/**
|
|
242
270
|
* Create a new Tuple with the specified items
|
|
243
271
|
* @param items The tuple items
|
|
@@ -262,7 +290,7 @@ export declare class Tuple<TTuple extends [ARC4Encoded, ...ARC4Encoded[]]> exten
|
|
|
262
290
|
*/
|
|
263
291
|
export declare class Address extends Arc4ArrayBase<Byte> {
|
|
264
292
|
/** @hidden */
|
|
265
|
-
[TypeProperty]?:
|
|
293
|
+
[TypeProperty]?: 'arc4.Address';
|
|
266
294
|
/**
|
|
267
295
|
* Create a new Address instance
|
|
268
296
|
* @param value An Account, base 32 address string, or the address bytes
|
|
@@ -278,12 +306,8 @@ export declare class Address extends Arc4ArrayBase<Byte> {
|
|
|
278
306
|
*/
|
|
279
307
|
declare class StructBase<T> extends ARC4Encoded {
|
|
280
308
|
/** @hidden */
|
|
281
|
-
[TypeProperty]
|
|
309
|
+
[TypeProperty]?: 'arc4.Struct';
|
|
282
310
|
get native(): T;
|
|
283
|
-
/**
|
|
284
|
-
* Returns a deep copy of this struct
|
|
285
|
-
*/
|
|
286
|
-
copy(): this;
|
|
287
311
|
}
|
|
288
312
|
/**
|
|
289
313
|
* Type alias for the Struct constructor function
|
|
@@ -297,7 +321,7 @@ type StructConstructor = {
|
|
|
297
321
|
*
|
|
298
322
|
* Usage:
|
|
299
323
|
* ```
|
|
300
|
-
* class MyStruct extends Struct<{ x:
|
|
324
|
+
* class MyStruct extends Struct<{ x: Uint8, y: Str, z: DynamicBytes }> { }
|
|
301
325
|
* ```
|
|
302
326
|
*/
|
|
303
327
|
export declare const Struct: StructConstructor;
|
|
@@ -306,7 +330,7 @@ export declare const Struct: StructConstructor;
|
|
|
306
330
|
*/
|
|
307
331
|
export declare class DynamicBytes extends Arc4ArrayBase<Byte> {
|
|
308
332
|
/** @hidden */
|
|
309
|
-
[TypeProperty]?:
|
|
333
|
+
[TypeProperty]?: 'arc4.DynamicBytes';
|
|
310
334
|
/**
|
|
311
335
|
* Create a new DynamicBytes instance
|
|
312
336
|
* @param value The bytes or utf8 interpreted string to initialize this type
|
|
@@ -325,22 +349,40 @@ export declare class DynamicBytes extends Arc4ArrayBase<Byte> {
|
|
|
325
349
|
/**
|
|
326
350
|
* A fixed length sequence of bytes
|
|
327
351
|
*/
|
|
328
|
-
export declare class StaticBytes<TLength extends
|
|
352
|
+
export declare class StaticBytes<TLength extends uint64 = 0> extends Arc4ArrayBase<Byte> {
|
|
329
353
|
/** @hidden */
|
|
330
354
|
[TypeProperty]?: `arc4.StaticBytes<${TLength}>`;
|
|
331
355
|
/**
|
|
332
|
-
* Create a new StaticBytes instance
|
|
333
|
-
* @param value
|
|
356
|
+
* Create a new StaticBytes instance from native fixed sized bytes
|
|
357
|
+
* @param value The bytes
|
|
334
358
|
*/
|
|
335
|
-
constructor(value
|
|
359
|
+
constructor(value: bytes<TLength>);
|
|
360
|
+
/**
|
|
361
|
+
* Create a new StaticBytes instance from native bytes
|
|
362
|
+
* @param value The bytes
|
|
363
|
+
*/
|
|
364
|
+
constructor(value: bytes);
|
|
365
|
+
/**
|
|
366
|
+
* Create a new StaticBytes instance from a utf8 string
|
|
367
|
+
* @param value A string
|
|
368
|
+
*/
|
|
369
|
+
constructor(value: string);
|
|
370
|
+
/**
|
|
371
|
+
* Create a new StaticBytes instance of length 0
|
|
372
|
+
*/
|
|
373
|
+
constructor();
|
|
336
374
|
/**
|
|
337
375
|
* Get the native bytes value
|
|
338
376
|
*/
|
|
339
|
-
get native(): bytes
|
|
377
|
+
get native(): bytes<TLength>;
|
|
340
378
|
/**
|
|
341
379
|
* Returns a dynamic bytes object containing all bytes from _this_ and _other_
|
|
342
380
|
* @param other Another array of bytes to concat with this one
|
|
343
381
|
*/
|
|
344
382
|
concat(other: Arc4ArrayBase<Byte>): DynamicBytes;
|
|
383
|
+
/**
|
|
384
|
+
* Returns the statically declared length of this byte array
|
|
385
|
+
*/
|
|
386
|
+
get length(): uint64;
|
|
345
387
|
}
|
|
346
388
|
export {};
|
package/arc4/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { BaseContract } from '../base-contract';
|
|
2
|
-
import { DeliberateAny, InstanceMethod } from '../internal/typescript-helpers';
|
|
2
|
+
import { AnyFunction, DeliberateAny, InstanceMethod } from '../internal/typescript-helpers';
|
|
3
3
|
import { OnCompleteActionStr } from '../on-complete-action';
|
|
4
4
|
import { bytes, BytesCompat, uint64 } from '../primitives';
|
|
5
5
|
import { ARC4Encoded } from './encoded-types';
|
|
6
|
-
export * from './encoded-types';
|
|
7
6
|
export * from './c2c';
|
|
7
|
+
export * from './encoded-types';
|
|
8
8
|
/**
|
|
9
9
|
* The base type for all ARC4 contracts in Algorand TypeScript
|
|
10
10
|
*/
|
|
@@ -15,6 +15,35 @@ export declare class Contract extends BaseContract {
|
|
|
15
15
|
*/
|
|
16
16
|
approvalProgram(): boolean;
|
|
17
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;
|
|
46
|
+
}
|
|
18
47
|
/**
|
|
19
48
|
* The possible options for a method being available on application create
|
|
20
49
|
*
|
|
@@ -23,6 +52,19 @@ export declare class Contract extends BaseContract {
|
|
|
23
52
|
* require: This method CAN ONLY be called when the application is being created
|
|
24
53
|
*/
|
|
25
54
|
export type CreateOptions = 'allow' | 'disallow' | 'require';
|
|
55
|
+
/**
|
|
56
|
+
* The possible options for the resource encoding to use for the method
|
|
57
|
+
*
|
|
58
|
+
* index: Application, Asset, and Account arguments are included in the transaction's relevant array. The argument value is the uint8 index of the resource in the that array.
|
|
59
|
+
* value: Application, Asset and Account arguments are passed by their uint64 id (Application and Asset) or bytes[32] address (Account).
|
|
60
|
+
*/
|
|
61
|
+
export type ResourceEncodingOptions = 'index' | 'value';
|
|
62
|
+
/**
|
|
63
|
+
* The possible options for validation behaviour for this method
|
|
64
|
+
* args: ABI arguments are validated automatically to ensure they are encoded correctly.
|
|
65
|
+
* unsafe-disabled: No automatic validation occurs. Arguments can instead be validated manually.
|
|
66
|
+
*/
|
|
67
|
+
export type ValidateEncodingOptions = 'unsafe-disabled' | 'args';
|
|
26
68
|
/**
|
|
27
69
|
* Type alias for a default argument schema
|
|
28
70
|
* @typeParam TContract The type of the contract containing the method this default argument is for
|
|
@@ -66,6 +108,23 @@ export type AbiMethodConfig<TContract extends Contract> = {
|
|
|
66
108
|
* Override the name used to generate the abi method selector
|
|
67
109
|
*/
|
|
68
110
|
name?: string;
|
|
111
|
+
/**
|
|
112
|
+
* The resource encoding to use for this method. The default is 'value'
|
|
113
|
+
*
|
|
114
|
+
* index: Application, Asset, and Account arguments are included in the transaction's relevant array. The argument value is the uint8 index of the resource in the that array.
|
|
115
|
+
* value: Application, Asset and Account arguments are passed by their uint64 id (Application and Asset) or bytes[32] address (Account).
|
|
116
|
+
*
|
|
117
|
+
* The resource must still be 'available' to this transaction but can take advantage of resource sharing within the transaction group.
|
|
118
|
+
*/
|
|
119
|
+
resourceEncoding?: ResourceEncodingOptions;
|
|
120
|
+
/**
|
|
121
|
+
* Controls validation behaviour for this method.
|
|
122
|
+
*
|
|
123
|
+
* If "args", then ABI arguments are validated automatically to ensure they are encoded correctly.
|
|
124
|
+
* If "unsafe-disabled", then no automatic validation occurs. Arguments can instead be validated using the validateEncoding(...) function.
|
|
125
|
+
* The default behaviour of this option can be controlled with the --validate-abi-args CLI flag.
|
|
126
|
+
*/
|
|
127
|
+
validateEncoding?: ValidateEncodingOptions;
|
|
69
128
|
/**
|
|
70
129
|
* Specify default arguments that can be populated by clients calling this method.
|
|
71
130
|
*
|
|
@@ -79,6 +138,13 @@ export type AbiMethodConfig<TContract extends Contract> = {
|
|
|
79
138
|
* @typeParam TContract the type of the contract this method is a part of
|
|
80
139
|
*/
|
|
81
140
|
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;
|
|
141
|
+
/**
|
|
142
|
+
* Declares this abi method does not mutate chain state and can be called using a simulate call to the same effect.
|
|
143
|
+
*
|
|
144
|
+
* Shorthand for `@abimethod({readonly: true})`
|
|
145
|
+
* @typeParam TContract the type of the contract this method is a part of
|
|
146
|
+
*/
|
|
147
|
+
export declare function readonly<TContract extends Contract, TArgs extends DeliberateAny[], TReturn>(target: (this: TContract, ...args: TArgs) => TReturn, ctx: ClassMethodDecoratorContext<TContract>): (this: TContract, ...args: TArgs) => TReturn;
|
|
82
148
|
/**
|
|
83
149
|
* Configuration options for a bare method
|
|
84
150
|
*/
|
|
@@ -106,20 +172,27 @@ export declare function baremethod<TContract extends Contract>(config?: BareMeth
|
|
|
106
172
|
* @param methodSignature An ARC4 contract method reference. (Eg. `MyContract.prototype.myMethod`)
|
|
107
173
|
* @returns The ARC4 method selector. Eg. `02BECE11`
|
|
108
174
|
*/
|
|
109
|
-
export declare function methodSelector(methodSignature: InstanceMethod<Contract>): bytes
|
|
175
|
+
export declare function methodSelector(methodSignature: InstanceMethod<Contract>): bytes<4>;
|
|
110
176
|
/**
|
|
111
177
|
* Returns the ARC4 method selector for a given ARC4 method signature. The method selector is the first
|
|
112
178
|
* 4 bytes of the SHA512/256 hash of the method signature.
|
|
113
179
|
* @param methodSignature An ARC4 method signature string (Eg. `hello(string)string`. Must be a compile time constant)
|
|
114
180
|
* @returns The ARC4 method selector. Eg. `02BECE11`
|
|
115
181
|
*/
|
|
116
|
-
export declare function methodSelector(methodSignature: string): bytes
|
|
182
|
+
export declare function methodSelector(methodSignature: string): bytes<4>;
|
|
117
183
|
/**
|
|
118
|
-
* Interpret the provided bytes as an ARC4 encoded type
|
|
184
|
+
* Interpret the provided bytes as an ARC4 encoded type
|
|
119
185
|
* @param bytes An arc4 encoded bytes value
|
|
120
|
-
* @param
|
|
186
|
+
* @param options Options for how the bytes should be converted
|
|
187
|
+
* @param options.prefix The prefix (if any), present in the bytes value. This prefix will be validated and removed
|
|
188
|
+
* @param options.strategy The strategy used for converting bytes.
|
|
189
|
+
* `unsafe-cast`: Reinterpret the value as an ARC4 encoded type without validation
|
|
190
|
+
* `validate`: Asserts the encoding of the raw bytes matches the expected type
|
|
121
191
|
*/
|
|
122
|
-
export declare function
|
|
192
|
+
export declare function convertBytes<T extends ARC4Encoded>(bytes: BytesCompat, options: {
|
|
193
|
+
prefix?: 'none' | 'log';
|
|
194
|
+
strategy: 'unsafe-cast' | 'validate';
|
|
195
|
+
}): T;
|
|
123
196
|
/**
|
|
124
197
|
* Decode the provided bytes to a native Algorand TypeScript value
|
|
125
198
|
* @param bytes An arc4 encoded bytes value
|
|
@@ -130,11 +203,11 @@ export declare function decodeArc4<T>(bytes: BytesCompat, prefix?: 'none' | 'log
|
|
|
130
203
|
* Encode the provided Algorand TypeScript value as ARC4 bytes
|
|
131
204
|
* @param value Any native Algorand TypeScript value with a supported ARC4 encoding
|
|
132
205
|
*/
|
|
133
|
-
export declare function encodeArc4<T>(value: T): bytes;
|
|
206
|
+
export declare function encodeArc4<const T>(value: T): bytes;
|
|
134
207
|
/**
|
|
135
|
-
* Return the total number of bytes required to store T as
|
|
208
|
+
* Return the total number of bytes required to store T as bytes.
|
|
136
209
|
*
|
|
137
210
|
* T must represent a type with a fixed length encoding scheme.
|
|
138
211
|
* @typeParam T Any native or arc4 type with a fixed encoding size.
|
|
139
212
|
*/
|
|
140
|
-
export declare function
|
|
213
|
+
export declare function sizeOf<T>(): uint64;
|
package/arc4/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { A as ARC4Encoded,
|
|
2
|
-
import '../errors-
|
|
1
|
+
export { A as ARC4Encoded, w as Address, u as Bool, j as Byte, C as Contract, D as DynamicArray, y as DynamicBytes, v as StaticArray, z as StaticBytes, S as Str, x as Struct, T as Tuple, t as UFixed, U as Uint, p as Uint128, l as Uint16, q as Uint256, n as Uint32, o as Uint64, k as Uint8, h as abiCall, a as abimethod, b as baremethod, g as compileArc4, d as convertBytes, e as decodeArc4, f as encodeArc4, m as methodSelector, r as readonly, s as sizeOf } from '../index-C_DRi4sH.js';
|
|
2
|
+
import '../errors-Bg4n2Chz.js';
|
|
3
3
|
//# sourceMappingURL=index.mjs.map
|
package/arrays.d.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { uint64, Uint64Compat } from './primitives';
|
|
2
|
+
/**
|
|
3
|
+
* A fixed sized array
|
|
4
|
+
* @typeParam TItem The type of a single item in the array
|
|
5
|
+
* @typeParam TLength The fixed length of the array
|
|
6
|
+
*/
|
|
7
|
+
export declare class FixedArray<TItem, TLength extends number> implements ConcatArray<TItem> {
|
|
8
|
+
/**
|
|
9
|
+
* Create a new FixedArray instance
|
|
10
|
+
*/
|
|
11
|
+
constructor();
|
|
12
|
+
/**
|
|
13
|
+
* Create a new FixedArray instance with the specified items
|
|
14
|
+
* @param items The initial items for the array
|
|
15
|
+
*/
|
|
16
|
+
constructor(...items: TItem[] & {
|
|
17
|
+
length: TLength;
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* Returns a new array containing all items from _this_ array, and _other_ array
|
|
21
|
+
* @param items Another array to concat with this one
|
|
22
|
+
*/
|
|
23
|
+
concat(...items: (TItem | ConcatArray<TItem>)[]): TItem[];
|
|
24
|
+
/**
|
|
25
|
+
* Returns the statically declared length of this array
|
|
26
|
+
*/
|
|
27
|
+
get length(): uint64;
|
|
28
|
+
/**
|
|
29
|
+
* Returns the item at the given index.
|
|
30
|
+
* Negative indexes are taken from the end.
|
|
31
|
+
* @param index The index of the item to retrieve
|
|
32
|
+
*/
|
|
33
|
+
at(index: Uint64Compat): TItem;
|
|
34
|
+
/** @deprecated Array slicing is not yet supported in Algorand TypeScript
|
|
35
|
+
* Create a new Dynamic array with all items from this array
|
|
36
|
+
*/
|
|
37
|
+
slice(): Array<TItem>;
|
|
38
|
+
/** @deprecated Array slicing is not yet supported in Algorand TypeScript
|
|
39
|
+
* Create a new DynamicArray with all items up till `end`.
|
|
40
|
+
* Negative indexes are taken from the end.
|
|
41
|
+
* @param end An index in which to stop copying items.
|
|
42
|
+
*/
|
|
43
|
+
slice(end: Uint64Compat): Array<TItem>;
|
|
44
|
+
/** @deprecated Array slicing is not yet supported in Algorand TypeScript
|
|
45
|
+
* Create a new DynamicArray with items from `start`, up until `end`
|
|
46
|
+
* Negative indexes are taken from the end.
|
|
47
|
+
* @param start An index in which to start copying items.
|
|
48
|
+
* @param end An index in which to stop copying items
|
|
49
|
+
*/
|
|
50
|
+
slice(start: Uint64Compat, end: Uint64Compat): Array<TItem>;
|
|
51
|
+
/**
|
|
52
|
+
* Returns an iterator for the items in this array
|
|
53
|
+
*/
|
|
54
|
+
[Symbol.iterator](): IterableIterator<TItem>;
|
|
55
|
+
/**
|
|
56
|
+
* Returns an iterator for a tuple of the indexes and items in this array
|
|
57
|
+
*/
|
|
58
|
+
entries(): ArrayIterator<readonly [uint64, TItem]>;
|
|
59
|
+
/**
|
|
60
|
+
* Returns an iterator for the indexes in this array
|
|
61
|
+
*/
|
|
62
|
+
keys(): IterableIterator<uint64>;
|
|
63
|
+
/**
|
|
64
|
+
* Get or set the item at the specified index.
|
|
65
|
+
* Negative indexes are not supported
|
|
66
|
+
*/
|
|
67
|
+
[index: uint64]: TItem;
|
|
68
|
+
/**
|
|
69
|
+
* Creates a string by concatenating all the items in the array delimited by the
|
|
70
|
+
* specified separator (or ',' by default)
|
|
71
|
+
* @param separator
|
|
72
|
+
* @deprecated Join is not supported in Algorand TypeScript
|
|
73
|
+
*/
|
|
74
|
+
join(separator?: string): string;
|
|
75
|
+
}
|
package/base-contract.d.ts
CHANGED
|
@@ -34,9 +34,9 @@ export type StateTotals = {
|
|
|
34
34
|
export type ContractOptions = {
|
|
35
35
|
/**
|
|
36
36
|
* Determines which AVM version to use, this affects what operations are supported.
|
|
37
|
-
* Defaults to value provided
|
|
37
|
+
* Defaults to value provided on command line (which defaults to current mainnet version)
|
|
38
38
|
*/
|
|
39
|
-
avmVersion?: 10 | 11;
|
|
39
|
+
avmVersion?: 10 | 11 | 12 | 13;
|
|
40
40
|
/**
|
|
41
41
|
* Override the name of the logic signature when generating build artifacts.
|
|
42
42
|
* Defaults to the class name
|