@algorandfoundation/algorand-typescript 0.0.1-alpha.9 → 1.0.0-alpha.44

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.
Files changed (58) hide show
  1. package/arc-28.d.ts +34 -0
  2. package/arc4/c2c.d.ts +81 -0
  3. package/arc4/encoded-types.d.ts +323 -30
  4. package/arc4/index.d.ts +93 -10
  5. package/arc4/index.mjs +3 -0
  6. package/arc4/index.mjs.map +1 -0
  7. package/base-contract.d.ts +72 -0
  8. package/box.d.ts +186 -17
  9. package/compiled.d.ts +107 -0
  10. package/errors-D124-zqo.js +12 -0
  11. package/errors-D124-zqo.js.map +1 -0
  12. package/gtxn-CXBH4yay.js +71 -0
  13. package/gtxn-CXBH4yay.js.map +1 -0
  14. package/gtxn.d.ts +604 -16
  15. package/gtxn.mjs +3 -0
  16. package/gtxn.mjs.map +1 -0
  17. package/index-dzo0agbK.js +524 -0
  18. package/index-dzo0agbK.js.map +1 -0
  19. package/index.d.ts +9 -3
  20. package/index.mjs +271 -308
  21. package/index.mjs.map +1 -1
  22. package/internal/errors.d.ts +7 -0
  23. package/internal/typescript-helpers.d.ts +4 -0
  24. package/itxn-CPeSA_Q_.js +202 -0
  25. package/itxn-CPeSA_Q_.js.map +1 -0
  26. package/itxn.d.ts +1006 -72
  27. package/itxn.mjs +3 -0
  28. package/itxn.mjs.map +1 -0
  29. package/logic-sig.d.ts +53 -0
  30. package/mutable-array.d.ts +51 -0
  31. package/on-complete-action.d.ts +33 -0
  32. package/op-BgdftarW.js +3645 -0
  33. package/op-BgdftarW.js.map +1 -0
  34. package/op.d.ts +2621 -55
  35. package/op.mjs +3 -0
  36. package/op.mjs.map +1 -0
  37. package/package.json +19 -2
  38. package/primitives.d.ts +105 -0
  39. package/readme.md +3 -0
  40. package/reference.d.ts +35 -2
  41. package/state.d.ts +68 -12
  42. package/template-var.d.ts +8 -0
  43. package/transactions.d.ts +0 -313
  44. package/util.d.ts +101 -3
  45. package/execution-context.d.ts +0 -40
  46. package/impl/base-32.d.ts +0 -2
  47. package/impl/encoding-util.d.ts +0 -10
  48. package/impl/errors.d.ts +0 -29
  49. package/impl/name-of-type.d.ts +0 -1
  50. package/impl/primitives.d.ts +0 -82
  51. package/impl/state.d.ts +0 -24
  52. package/index-DLlAi-Hh.js +0 -831
  53. package/index-DLlAi-Hh.js.map +0 -1
  54. package/index2.mjs +0 -4
  55. package/index2.mjs.map +0 -1
  56. package/internal.d.ts +0 -6
  57. package/op-types.d.ts +0 -2102
  58. package/typescript-helpers.d.ts +0 -2
package/arc-28.d.ts ADDED
@@ -0,0 +1,34 @@
1
+ import { DeliberateAny } from './internal/typescript-helpers';
2
+ /**
3
+ * Emit an arc28 event log using either an ARC4Struct type or a named object type.
4
+ * Object types must have an ARC4 equivalent type.
5
+ *
6
+ * Anonymous types cannot be used as the type name is used to determine the event prefix
7
+ * @param event An ARC4Struct instance, or a plain object with a named type
8
+ *
9
+ * @example
10
+ * class Demo extends Struct<{ a: UintN64 }> {}
11
+ * emit(new Demo({ a: new UintN64(123) }))
12
+ *
13
+ * @example
14
+ * type Demo = { a: uint64 }
15
+ * emit<Demo>({a: 123})
16
+ * // or
17
+ * const d: Demo = { a: 123 }
18
+ * emit(d)
19
+ */
20
+ export declare function emit<TEvent extends Record<string, DeliberateAny>>(event: TEvent): void;
21
+ /**
22
+ * Emit an arc28 event log using an explicit name and inferred property/field types.
23
+ * Property types must be ARC4 or have an ARC4 equivalent type.
24
+ * @param eventName The name of the event (must be a compile time constant)
25
+ * @param eventProps A set of event properties (order is significant)
26
+ *
27
+ * @example
28
+ * emit("Demo", new UintN64(123))
29
+ *
30
+ * @example
31
+ * const a: uint64 = 123
32
+ * emit("Demo", a)
33
+ */
34
+ export declare function emit<TProps extends [...DeliberateAny[]]>(eventName: string, ...eventProps: TProps): void;
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>;
@@ -1,65 +1,358 @@
1
- import { biguint, BigUintCompat, bytes, BytesBacked, StringCompat, uint64, Uint64Compat } from '../primitives';
1
+ import { biguint, BigUintCompat, bytes, BytesBacked, NTuple, StringCompat, uint64, Uint64Compat } from '../primitives';
2
2
  import { Account } from '../reference';
3
- export type BitSize = 8 | 16 | 32 | 64 | 128 | 256 | 512;
4
- type NativeForArc4Int<N extends BitSize> = N extends 8 | 16 | 32 | 64 ? uint64 : biguint;
5
- type CompatForArc4Int<N extends BitSize> = N extends 8 | 16 | 32 | 64 ? Uint64Compat : BigUintCompat;
6
- declare abstract class AbiEncoded implements BytesBacked {
3
+ /**
4
+ * Defines UintN bit sizes which are compatible with the uint64 type
5
+ */
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
+ */
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
+ */
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
+ /**
20
+ * Conditional type which returns the compat type relevant to a given UintN bit size
21
+ */
22
+ type CompatForArc4Int<N extends BitSize> = N extends UintBitSize ? Uint64Compat : BigUintCompat;
23
+ /**
24
+ * @hidden
25
+ */
26
+ declare const TypeProperty: unique symbol;
27
+ /**
28
+ * A base type for ARC4 encoded values
29
+ */
30
+ export declare abstract class ARC4Encoded implements BytesBacked {
31
+ /** @hidden */
32
+ abstract [TypeProperty]?: string;
33
+ /**
34
+ * Retrieve the encoded bytes for this type
35
+ */
7
36
  get bytes(): bytes;
8
37
  }
9
- export declare class Str extends AbiEncoded {
10
- constructor(s: StringCompat);
38
+ /**
39
+ * A utf8 encoded string prefixed with its length expressed as a 2 byte uint
40
+ */
41
+ export declare class Str extends ARC4Encoded {
42
+ /** @hidden */
43
+ [TypeProperty]?: 'arc4.Str';
44
+ /**
45
+ * Create a new Str instance
46
+ * @param s The native string to initialize this Str from
47
+ */
48
+ constructor(s?: StringCompat);
49
+ /**
50
+ * Retrieve the decoded native string
51
+ */
11
52
  get native(): string;
12
53
  }
13
- export declare class UintN<N extends BitSize> extends AbiEncoded {
54
+ /**
55
+ * A fixed bit size unsigned int
56
+ */
57
+ export declare class UintN<N extends BitSize> extends ARC4Encoded {
58
+ /** @hidden */
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
+ */
14
64
  constructor(v?: CompatForArc4Int<N>);
65
+ /**
66
+ * Retrieve the decoded native uint64 or biguint
67
+ */
15
68
  get native(): NativeForArc4Int<N>;
16
69
  }
17
- export declare class UFixedNxM<N extends BitSize, M extends number> {
18
- constructor(v: `${number}:${number}`, n?: N, m?: M);
19
- get native(): NativeForArc4Int<N>;
20
- }
70
+ /**
71
+ * An alias for UintN<8>
72
+ */
21
73
  export declare class Byte extends UintN<8> {
22
- constructor(v: Uint64Compat);
23
- get native(): uint64;
24
74
  }
25
- export declare class Bool {
26
- #private;
27
- constructor(v: boolean);
75
+ /**
76
+ * An alias for UintN<8>
77
+ */
78
+ export declare class UintN8 extends UintN<8> {
79
+ }
80
+ /**
81
+ * An alias for UintN<16>
82
+ */
83
+ export declare class UintN16 extends UintN<16> {
84
+ }
85
+ /**
86
+ * An alias for UintN<32>
87
+ */
88
+ export declare class UintN32 extends UintN<32> {
89
+ }
90
+ /**
91
+ * An alias for UintN<64>
92
+ */
93
+ export declare class UintN64 extends UintN<64> {
94
+ }
95
+ /**
96
+ * An alias for UintN<128>
97
+ */
98
+ export declare class UintN128 extends UintN<128> {
99
+ }
100
+ /**
101
+ * An alias for UintN<256>
102
+ */
103
+ export declare class UintN256 extends UintN<256> {
104
+ }
105
+ /**
106
+ * A fixed bit size, fixed decimal unsigned value
107
+ */
108
+ export declare class UFixedNxM<N extends BitSize, M extends number> extends ARC4Encoded {
109
+ /** @hidden */
110
+ [TypeProperty]?: `arc4.UFixedNxM<${N}x${M}>`;
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
+ */
119
+ get native(): NativeForArc4Int<N>;
120
+ }
121
+ /**
122
+ * A boolean value
123
+ */
124
+ export declare class Bool extends ARC4Encoded {
125
+ /** @hidden */
126
+ [TypeProperty]?: `arc4.Bool`;
127
+ /**
128
+ * Create a new Bool value
129
+ * @param v The native boolean to initialize this value from
130
+ */
131
+ constructor(v?: boolean);
132
+ /**
133
+ * Get the decoded native boolean for this value
134
+ */
28
135
  get native(): boolean;
29
136
  }
30
- declare abstract class Arc4Array<TItem> extends AbiEncoded {
31
- protected items: TItem[];
32
- protected constructor(items: TItem[]);
137
+ /**
138
+ * A base type for arc4 array types
139
+ */
140
+ declare abstract class Arc4ArrayBase<TItem extends ARC4Encoded> extends ARC4Encoded {
141
+ protected constructor();
142
+ /**
143
+ * Returns the current length of this array
144
+ */
33
145
  get length(): uint64;
146
+ /**
147
+ * Returns the item at the given index.
148
+ * Negative indexes are taken from the end.
149
+ * @param index The index of the item to retrieve
150
+ */
34
151
  at(index: Uint64Compat): TItem;
35
- slice(start: Uint64Compat, end: Uint64Compat): DynamicArray<TItem>;
152
+ /**
153
+ * Returns an iterator for the items in this array
154
+ */
36
155
  [Symbol.iterator](): IterableIterator<TItem>;
156
+ /**
157
+ * Returns an iterator for a tuple of the indexes and items in this array
158
+ */
37
159
  entries(): IterableIterator<readonly [uint64, TItem]>;
160
+ /**
161
+ * Returns an iterator for the indexes in this array
162
+ */
38
163
  keys(): IterableIterator<uint64>;
164
+ /**
165
+ * Get or set the item at the specified index.
166
+ * Negative indexes are not supported
167
+ */
168
+ [index: uint64]: TItem;
39
169
  }
40
- export declare class StaticArray<TItem, TLength extends number> extends Arc4Array<TItem> {
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 */
177
+ [TypeProperty]?: `arc4.StaticArray<${TItem[typeof TypeProperty]}, ${TLength}>`;
178
+ /**
179
+ * Create a new StaticArray instance
180
+ */
41
181
  constructor();
182
+ /**
183
+ * Create a new StaticArray instance with the specified items
184
+ * @param items The initial items for the array
185
+ */
42
186
  constructor(...items: TItem[] & {
43
187
  length: TLength;
44
188
  });
45
- constructor(...items: TItem[]);
189
+ /**
190
+ * Returns a copy of this array
191
+ */
46
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>;
47
202
  }
48
- export declare class DynamicArray<TItem> extends Arc4Array<TItem> {
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 */
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
+ */
49
214
  constructor(...items: TItem[]);
215
+ /**
216
+ * Push a number of items into this array
217
+ * @param items The items to be added to this array
218
+ */
50
219
  push(...items: TItem[]): void;
220
+ /**
221
+ * Pop a single item from this array
222
+ */
51
223
  pop(): TItem;
224
+ /**
225
+ * Returns a copy of this array
226
+ */
52
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[];
53
237
  }
54
- type ItemAt<TTuple extends unknown[], TIndex extends number> = undefined extends TTuple[TIndex] ? never : TTuple[TIndex];
55
- export declare class Tuple<TTuple extends unknown[]> {
56
- #private;
238
+ /**
239
+ * @hidden
240
+ */
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
+ */
246
+ export declare class Tuple<TTuple extends [ARC4Encoded, ...ARC4Encoded[]]> extends ARC4Encoded {
247
+ /** @hidden */
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
+ */
57
257
  constructor(...items: TTuple);
58
- at<TIndex extends number>(index: TIndex): ItemAt<TTuple, TIndex>;
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
+ */
262
+ at<TIndex extends keyof TTuple>(index: TIndex): TTuple[TIndex];
263
+ /**
264
+ * Returns the length of this tuple
265
+ */
266
+ get length(): TTuple['length'] & uint64;
267
+ /**
268
+ * Returns the decoded native tuple (with arc4 encoded items)
269
+ */
59
270
  get native(): TTuple;
60
271
  }
61
- export declare class Address extends StaticArray<Byte, 32> {
62
- constructor(value: Account | string | bytes);
272
+ /**
273
+ * A 32 byte Algorand Address
274
+ */
275
+ export declare class Address extends Arc4ArrayBase<Byte> {
276
+ /** @hidden */
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
+ */
282
+ constructor(value?: Account | string | bytes);
283
+ /**
284
+ * Returns an Account instance for this Address
285
+ */
63
286
  get native(): Account;
64
287
  }
288
+ /**
289
+ * The base type for arc4 structs
290
+ */
291
+ declare class StructBase<T> extends ARC4Encoded {
292
+ /** @hidden */
293
+ [TypeProperty]: string;
294
+ get native(): T;
295
+ /**
296
+ * Returns a deep copy of this struct
297
+ */
298
+ copy(): this;
299
+ }
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
+ */
315
+ export declare const Struct: StructConstructor;
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 */
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
+ */
326
+ constructor(value?: bytes | string);
327
+ /**
328
+ * Get the native bytes value (excludes the length prefix)
329
+ */
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;
336
+ }
337
+ /**
338
+ * A fixed length sequence of bytes
339
+ */
340
+ export declare class StaticBytes<TLength extends number = 0> extends Arc4ArrayBase<Byte> {
341
+ /** @hidden */
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
+ */
347
+ constructor(value?: bytes | string);
348
+ /**
349
+ * Get the native bytes value
350
+ */
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;
357
+ }
65
358
  export {};
package/arc4/index.d.ts CHANGED
@@ -1,24 +1,51 @@
1
1
  import { BaseContract } from '../base-contract';
2
- import { DeliberateAny } from '../typescript-helpers';
2
+ import { 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';
3
6
  export * from './encoded-types';
7
+ export * from './c2c';
8
+ /**
9
+ * The base type for all ARC4 contracts in Algorand TypeScript
10
+ */
4
11
  export declare class Contract extends BaseContract {
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
+ */
5
16
  approvalProgram(): boolean;
6
17
  }
18
+ /**
19
+ * The possible options for a method being available on application create
20
+ *
21
+ * allow: This method CAN be called when the application is being created, but it is not required
22
+ * disallow: This method CANNOT be called when the application is being created
23
+ * require: This method CAN ONLY be called when the application is being created
24
+ */
7
25
  export type CreateOptions = 'allow' | 'disallow' | 'require';
8
- export type OnCompleteActionStr = 'NoOp' | 'OptIn' | 'ClearState' | 'CloseOut' | 'UpdateApplication' | 'DeleteApplication';
9
- export declare enum OnCompleteAction {
10
- NoOp,
11
- OptIn,
12
- CloseOut,
13
- ClearState,
14
- UpdateApplication,
15
- DeleteApplication
16
- }
26
+ /**
27
+ * Type alias for a default argument schema
28
+ * @typeParam TContract The type of the contract containing the method this default argument is for
29
+ */
17
30
  export type DefaultArgument<TContract extends Contract> = {
31
+ /**
32
+ * A compile time constant value to be used as a default
33
+ */
18
34
  constant: string | boolean | number | bigint;
19
35
  } | {
36
+ /**
37
+ * Retrieve the default value from a member of this contract. The member can be
38
+ *
39
+ * LocalState: The value is retrieved from the calling user's local state before invoking this method
40
+ * GlobalState: The value is retrieved from the specified global state key before invoking this method
41
+ * Method: Any readonly abimethod with no arguments can be used as a source
42
+ */
20
43
  from: keyof TContract;
21
44
  };
45
+ /**
46
+ * Configuration options for an abi method
47
+ * @typeParam TContract the type of the contract this method is a part of
48
+ */
22
49
  export type AbiMethodConfig<TContract extends Contract> = {
23
50
  /**
24
51
  * Which on complete action(s) are allowed when invoking this method.
@@ -39,9 +66,22 @@ export type AbiMethodConfig<TContract extends Contract> = {
39
66
  * Override the name used to generate the abi method selector
40
67
  */
41
68
  name?: string;
69
+ /**
70
+ * Specify default arguments that can be populated by clients calling this method.
71
+ *
72
+ * A map of parameter names to the default argument source
73
+ */
42
74
  defaultArguments?: Record<string, DefaultArgument<TContract>>;
43
75
  };
76
+ /**
77
+ * Declares the decorated method as an abimethod that is called when the first transaction arg matches the method selector
78
+ * @param config The config for this abi method
79
+ * @typeParam TContract the type of the contract this method is a part of
80
+ */
44
81
  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;
82
+ /**
83
+ * Configuration options for a bare method
84
+ */
45
85
  export type BareMethodConfig = {
46
86
  /**
47
87
  * Which on complete action(s) are allowed when invoking this method.
@@ -54,4 +94,47 @@ export type BareMethodConfig = {
54
94
  */
55
95
  onCreate?: CreateOptions;
56
96
  };
97
+ /**
98
+ * Declares the decorated method as a baremethod that can only be called with no transaction args
99
+ * @param config The config for this bare method
100
+ * @typeParam TContract the type of the contract this method is a part of
101
+ */
57
102
  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;
103
+ /**
104
+ * Returns the ARC4 method selector for a given ARC4 method signature. The method selector is the first
105
+ * 4 bytes of the SHA512/256 hash of the method signature.
106
+ * @param methodSignature An ARC4 contract method reference. (Eg. `MyContract.prototype.myMethod`)
107
+ * @returns The ARC4 method selector. Eg. `02BECE11`
108
+ */
109
+ export declare function methodSelector(methodSignature: InstanceMethod<Contract>): bytes;
110
+ /**
111
+ * Returns the ARC4 method selector for a given ARC4 method signature. The method selector is the first
112
+ * 4 bytes of the SHA512/256 hash of the method signature.
113
+ * @param methodSignature An ARC4 method signature string (Eg. `hello(string)string`. Must be a compile time constant)
114
+ * @returns The ARC4 method selector. Eg. `02BECE11`
115
+ */
116
+ export declare function methodSelector(methodSignature: string): bytes;
117
+ /**
118
+ * Interpret the provided bytes as an ARC4 encoded type with no validation
119
+ * @param bytes An arc4 encoded bytes value
120
+ * @param prefix The prefix (if any), present in the bytes value. This prefix will be validated and removed
121
+ */
122
+ export declare function interpretAsArc4<T extends ARC4Encoded>(bytes: BytesCompat, prefix?: 'none' | 'log'): T;
123
+ /**
124
+ * Decode the provided bytes to a native Algorand TypeScript value
125
+ * @param bytes An arc4 encoded bytes value
126
+ * @param prefix The prefix (if any), present in the bytes value. This prefix will be validated and removed
127
+ */
128
+ export declare function decodeArc4<T>(bytes: BytesCompat, prefix?: 'none' | 'log'): T;
129
+ /**
130
+ * Encode the provided Algorand TypeScript value as ARC4 bytes
131
+ * @param value Any native Algorand TypeScript value with a supported ARC4 encoding
132
+ */
133
+ export declare function encodeArc4<const T>(value: T): bytes;
134
+ /**
135
+ * Return the total number of bytes required to store T as ARC4 bytes.
136
+ *
137
+ * T must represent a type with a fixed length encoding scheme.
138
+ * @typeParam T Any native or arc4 type with a fixed encoding size.
139
+ */
140
+ export declare function arc4EncodedLength<T>(): uint64;
package/arc4/index.mjs ADDED
@@ -0,0 +1,3 @@
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';
3
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}