@algorandfoundation/algorand-typescript 0.0.1-alpha.9 → 1.0.0-beta.2
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 +34 -0
- package/arc4/encoded-types.d.ts +111 -29
- package/arc4/index.d.ts +8 -0
- package/arc4/index.mjs +5 -0
- package/arc4/index.mjs.map +1 -0
- package/base-contract.d.ts +66 -0
- package/box.d.ts +2 -2
- package/compiled.d.ts +108 -0
- package/execution-context.d.ts +8 -1
- package/impl/errors.d.ts +7 -0
- package/impl/primitives.d.ts +3 -3
- package/{index-DLlAi-Hh.js → index-BykxIQos.js} +206 -113
- package/index-BykxIQos.js.map +1 -0
- package/index.d.ts +7 -1
- package/index.mjs +143 -210
- package/index.mjs.map +1 -1
- package/internal.d.ts +1 -1
- package/logic-sig.d.ts +26 -0
- package/mutable-array.d.ts +58 -0
- package/op-Buke-Sl8.js +164 -0
- package/op-Buke-Sl8.js.map +1 -0
- package/op-types.d.ts +536 -2
- package/op.d.ts +11 -2
- package/op.mjs +2 -0
- package/op.mjs.map +1 -0
- package/package.json +8 -2
- package/primitives.d.ts +8 -0
- package/readme.md +3 -0
- package/reference.d.ts +1 -1
- package/state.d.ts +1 -2
- package/template-var.d.ts +1 -0
- package/typescript-helpers.d.ts +1 -0
- package/util.d.ts +3 -2
- package/impl/state.d.ts +0 -24
- package/index-DLlAi-Hh.js.map +0 -1
- package/index2.mjs +0 -4
- package/index2.mjs.map +0 -1
package/arc-28.d.ts
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
import { DeliberateAny } from './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/encoded-types.d.ts
CHANGED
@@ -1,43 +1,82 @@
|
|
1
|
-
import { biguint, BigUintCompat, bytes, BytesBacked, StringCompat, uint64, Uint64Compat } from '../primitives';
|
1
|
+
import { biguint, BigUintCompat, bytes, BytesBacked, BytesCompat, StringCompat, uint64, Uint64Compat } from '../primitives';
|
2
2
|
import { Account } from '../reference';
|
3
|
-
|
4
|
-
type
|
5
|
-
type
|
6
|
-
|
3
|
+
type UintBitSize = 8 | 16 | 24 | 32 | 40 | 48 | 56 | 64;
|
4
|
+
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;
|
5
|
+
export type BitSize = UintBitSize | BigUintBitSize;
|
6
|
+
type NativeForArc4Int<N extends BitSize> = N extends UintBitSize ? uint64 : biguint;
|
7
|
+
type CompatForArc4Int<N extends BitSize> = N extends UintBitSize ? Uint64Compat : BigUintCompat;
|
8
|
+
declare const TypeProperty: unique symbol;
|
9
|
+
export declare abstract class ARC4Encoded implements BytesBacked {
|
10
|
+
abstract [TypeProperty]?: string;
|
7
11
|
get bytes(): bytes;
|
8
12
|
}
|
9
|
-
export declare class Str extends
|
10
|
-
|
13
|
+
export declare class Str extends ARC4Encoded {
|
14
|
+
#private;
|
15
|
+
[TypeProperty]?: 'arc4.Str';
|
16
|
+
constructor(s?: StringCompat);
|
11
17
|
get native(): string;
|
12
18
|
}
|
13
|
-
export declare class UintN<N extends BitSize> extends
|
19
|
+
export declare class UintN<N extends BitSize> extends ARC4Encoded {
|
20
|
+
[TypeProperty]?: `arc4.UintN<${N}>`;
|
14
21
|
constructor(v?: CompatForArc4Int<N>);
|
15
22
|
get native(): NativeForArc4Int<N>;
|
16
23
|
}
|
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
|
-
}
|
21
24
|
export declare class Byte extends UintN<8> {
|
22
|
-
constructor(v: Uint64Compat);
|
23
|
-
get native(): uint64;
|
24
25
|
}
|
25
|
-
export declare class
|
26
|
-
|
27
|
-
|
26
|
+
export declare class UintN8 extends UintN<8> {
|
27
|
+
}
|
28
|
+
export declare class UintN16 extends UintN<16> {
|
29
|
+
}
|
30
|
+
export declare class UintN32 extends UintN<32> {
|
31
|
+
}
|
32
|
+
export declare class UintN64 extends UintN<64> {
|
33
|
+
}
|
34
|
+
export declare class UintN128 extends UintN<128> {
|
35
|
+
}
|
36
|
+
export declare class UintN256 extends UintN<256> {
|
37
|
+
}
|
38
|
+
export declare class UFixedNxM<N extends BitSize, M extends number> extends ARC4Encoded {
|
39
|
+
[TypeProperty]?: `arc4.UFixedNxM<${N}x${M}>`;
|
40
|
+
constructor(v: `${number}.${number}`);
|
41
|
+
get native(): NativeForArc4Int<N>;
|
42
|
+
}
|
43
|
+
export declare class Bool extends ARC4Encoded {
|
44
|
+
[TypeProperty]?: `arc4.Bool`;
|
45
|
+
constructor(v?: boolean);
|
28
46
|
get native(): boolean;
|
29
47
|
}
|
30
|
-
declare abstract class
|
31
|
-
protected
|
32
|
-
|
48
|
+
declare abstract class Arc4ReadonlyArray<TItem extends ARC4Encoded> extends ARC4Encoded {
|
49
|
+
protected constructor();
|
50
|
+
/**
|
51
|
+
* Returns the current length of this array
|
52
|
+
*/
|
33
53
|
get length(): uint64;
|
54
|
+
/**
|
55
|
+
* Returns the item at the given index.
|
56
|
+
* Negative indexes are taken from the end.
|
57
|
+
* @param index The index of the item to retrieve
|
58
|
+
*/
|
34
59
|
at(index: Uint64Compat): TItem;
|
35
|
-
|
60
|
+
/**
|
61
|
+
* Returns an iterator for the items in this array
|
62
|
+
*/
|
36
63
|
[Symbol.iterator](): IterableIterator<TItem>;
|
64
|
+
/**
|
65
|
+
* Returns an iterator for a tuple of the indexes and items in this array
|
66
|
+
*/
|
37
67
|
entries(): IterableIterator<readonly [uint64, TItem]>;
|
68
|
+
/**
|
69
|
+
* Returns an iterator for the indexes in this array
|
70
|
+
*/
|
38
71
|
keys(): IterableIterator<uint64>;
|
72
|
+
/**
|
73
|
+
* Get or set the item at the specified index.
|
74
|
+
* Negative indexes are not supported
|
75
|
+
*/
|
76
|
+
[index: uint64]: TItem;
|
39
77
|
}
|
40
|
-
export declare class StaticArray<TItem, TLength extends number> extends
|
78
|
+
export declare class StaticArray<TItem extends ARC4Encoded, TLength extends number> extends Arc4ReadonlyArray<TItem> {
|
79
|
+
[TypeProperty]?: `arc4.StaticArray<${TItem[typeof TypeProperty]}, ${TLength}>`;
|
41
80
|
constructor();
|
42
81
|
constructor(...items: TItem[] & {
|
43
82
|
length: TLength;
|
@@ -45,21 +84,64 @@ export declare class StaticArray<TItem, TLength extends number> extends Arc4Arra
|
|
45
84
|
constructor(...items: TItem[]);
|
46
85
|
copy(): StaticArray<TItem, TLength>;
|
47
86
|
}
|
48
|
-
export declare class DynamicArray<TItem> extends
|
87
|
+
export declare class DynamicArray<TItem extends ARC4Encoded> extends Arc4ReadonlyArray<TItem> {
|
88
|
+
[TypeProperty]?: `arc4.DynamicArray<${TItem[typeof TypeProperty]}>`;
|
49
89
|
constructor(...items: TItem[]);
|
90
|
+
/**
|
91
|
+
* Push a number of items into this array
|
92
|
+
* @param items The items to be added to this array
|
93
|
+
*/
|
50
94
|
push(...items: TItem[]): void;
|
95
|
+
/**
|
96
|
+
* Pop a single item from this array
|
97
|
+
*/
|
51
98
|
pop(): TItem;
|
52
99
|
copy(): DynamicArray<TItem>;
|
53
100
|
}
|
54
|
-
type
|
55
|
-
export declare class Tuple<TTuple extends
|
56
|
-
|
101
|
+
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>}` : '';
|
102
|
+
export declare class Tuple<TTuple extends [ARC4Encoded, ...ARC4Encoded[]]> extends ARC4Encoded {
|
103
|
+
[TypeProperty]?: `arc4.Tuple<${ExpandTupleType<TTuple>}>`;
|
57
104
|
constructor(...items: TTuple);
|
58
|
-
at<TIndex extends
|
105
|
+
at<TIndex extends keyof TTuple>(index: TIndex): TTuple[TIndex];
|
106
|
+
get length(): TTuple['length'] & uint64;
|
59
107
|
get native(): TTuple;
|
60
108
|
}
|
61
|
-
export declare class Address extends
|
62
|
-
|
109
|
+
export declare class Address extends Arc4ReadonlyArray<Byte> {
|
110
|
+
[TypeProperty]?: `arc4.Address`;
|
111
|
+
constructor(value?: Account | string | bytes);
|
63
112
|
get native(): Account;
|
64
113
|
}
|
114
|
+
type StructConstraint = Record<string, ARC4Encoded>;
|
115
|
+
declare class StructBase extends ARC4Encoded {
|
116
|
+
[TypeProperty]: string;
|
117
|
+
}
|
118
|
+
type StructConstructor = new <T extends StructConstraint>(initial: T) => StructBase & T;
|
119
|
+
export declare const Struct: StructConstructor;
|
120
|
+
export declare class DynamicBytes extends Arc4ReadonlyArray<Byte> {
|
121
|
+
[TypeProperty]?: `arc4.DynamicBytes`;
|
122
|
+
constructor(value?: bytes | string);
|
123
|
+
get native(): bytes;
|
124
|
+
}
|
125
|
+
export declare class StaticBytes<TLength extends number = 0> extends Arc4ReadonlyArray<Byte> {
|
126
|
+
[TypeProperty]?: `arc4.StaticBytes<${TLength}>`;
|
127
|
+
constructor(value?: bytes | string);
|
128
|
+
get native(): bytes;
|
129
|
+
}
|
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;
|
65
147
|
export {};
|
package/arc4/index.d.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import { BaseContract } from '../base-contract';
|
2
|
+
import { bytes } from '../primitives';
|
2
3
|
import { DeliberateAny } from '../typescript-helpers';
|
3
4
|
export * from './encoded-types';
|
4
5
|
export declare class Contract extends BaseContract {
|
@@ -55,3 +56,10 @@ export type BareMethodConfig = {
|
|
55
56
|
onCreate?: CreateOptions;
|
56
57
|
};
|
57
58
|
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;
|
59
|
+
/**
|
60
|
+
* Returns the ARC4 method selector for a given ARC4 method signature. The method selector is the first
|
61
|
+
* 4 bytes of the SHA512/256 hash of the method signature.
|
62
|
+
* @param methodSignature An ARC4 method signature. Eg. `hello(string)string`. Must be a compile time constant.
|
63
|
+
* @returns The ARC4 method selector. Eg. `02BECE11`
|
64
|
+
*/
|
65
|
+
export declare function methodSelector(methodSignature: string): bytes;
|
package/arc4/index.mjs
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
export { d as ARC4Encoded, I as Address, F as Bool, u as Byte, h as Contract, H as DynamicArray, K as DynamicBytes, O as OnCompleteAction, G as StaticArray, L as StaticBytes, S as Str, J as Struct, T as Tuple, E as UFixedNxM, t as UintN, z as UintN128, w as UintN16, D as UintN256, x as UintN32, y as UintN64, v as UintN8, j as abimethod, r as baremethod, P as decodeArc4, Q as encodeArc4, M as interpretAsArc4, s as methodSelector } from '../index-BykxIQos.js';
|
2
|
+
import '../op-Buke-Sl8.js';
|
3
|
+
import 'node:buffer';
|
4
|
+
import 'node:util';
|
5
|
+
//# sourceMappingURL=index.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
package/base-contract.d.ts
CHANGED
@@ -1,5 +1,71 @@
|
|
1
|
+
import { Contract } from './arc4';
|
1
2
|
import { uint64 } from './primitives';
|
3
|
+
import { ConstructorFor } from './typescript-helpers';
|
2
4
|
export declare abstract class BaseContract {
|
3
5
|
abstract approvalProgram(): boolean | uint64;
|
4
6
|
clearStateProgram(): boolean | uint64;
|
5
7
|
}
|
8
|
+
type NumberRange = {
|
9
|
+
from: number;
|
10
|
+
to: number;
|
11
|
+
};
|
12
|
+
/**
|
13
|
+
* Options class to manually define the total amount of global and local state contract will use.
|
14
|
+
*
|
15
|
+
* This is not required when all state is assigned to `this.`, but is required if a
|
16
|
+
* contract dynamically interacts with state via `AppGlobal.getBytes` etc, or if you want
|
17
|
+
* to reserve additional state storage for future contract updates, since the Algorand protocol
|
18
|
+
* doesn't allow increasing them after creation.
|
19
|
+
*/
|
20
|
+
type StateTotals = {
|
21
|
+
globalUints?: number;
|
22
|
+
globalBytes?: number;
|
23
|
+
localUints?: number;
|
24
|
+
localBytes?: number;
|
25
|
+
};
|
26
|
+
type ContractOptions = {
|
27
|
+
/**
|
28
|
+
* Determines which AVM version to use, this affects what operations are supported.
|
29
|
+
* Defaults to value provided supplied on command line (which defaults to current mainnet version)
|
30
|
+
*/
|
31
|
+
avmVersion?: 10 | 11;
|
32
|
+
/**
|
33
|
+
* Override the name of the logic signature when generating build artifacts.
|
34
|
+
* Defaults to the class name
|
35
|
+
*/
|
36
|
+
name?: string;
|
37
|
+
/**
|
38
|
+
* Allows you to mark a slot ID or range of slot IDs as "off limits" to Puya.
|
39
|
+
* These slot ID(s) will never be written to or otherwise manipulating by the compiler itself.
|
40
|
+
* This is particularly useful in combination with `op.gload_bytes` / `op.gload_uint64`
|
41
|
+
* which lets a contract in a group transaction read from the scratch slots of another contract
|
42
|
+
* that occurs earlier in the transaction group.
|
43
|
+
*
|
44
|
+
* In the case of inheritance, scratch slots reserved become cumulative. It is not an error
|
45
|
+
* to have overlapping ranges or values either, so if a base class contract reserves slots
|
46
|
+
* 0-5 inclusive and the derived contract reserves 5-10 inclusive, then within the derived
|
47
|
+
* contract all slots 0-10 will be marked as reserved.
|
48
|
+
*/
|
49
|
+
scratchSlots?: Array<number | NumberRange>;
|
50
|
+
/**
|
51
|
+
* Allows defining what values should be used for global and local uint and bytes storage
|
52
|
+
* values when creating a contract. Used when outputting ARC-32 application.json schemas.
|
53
|
+
*
|
54
|
+
* If left unspecified, the totals will be determined by the compiler based on state
|
55
|
+
* variables assigned to `this`.
|
56
|
+
*
|
57
|
+
* This setting is not inherited, and only applies to the exact `Contract` it is specified
|
58
|
+
* on. If a base class does specify this setting, and a derived class does not, a warning
|
59
|
+
* will be emitted for the derived class. To resolve this warning, `stateTotals` must be
|
60
|
+
* specified. An empty object may be provided in order to indicate that this contract should
|
61
|
+
* revert to the default behaviour
|
62
|
+
*/
|
63
|
+
stateTotals?: StateTotals;
|
64
|
+
};
|
65
|
+
/**
|
66
|
+
* The contract decorator can be used to specify additional configuration options for a smart contract
|
67
|
+
* @param options An object containing the configuration options
|
68
|
+
*/
|
69
|
+
export declare const ContractOptionsSymbol: unique symbol;
|
70
|
+
export declare function contract(options: ContractOptions): <T extends ConstructorFor<Contract>>(contract: T, ctx: ClassDecoratorContext) => T;
|
71
|
+
export {};
|
package/box.d.ts
CHANGED
@@ -29,8 +29,8 @@ export type BoxRef = {
|
|
29
29
|
get(options: {
|
30
30
|
default: bytes;
|
31
31
|
}): bytes;
|
32
|
-
put(value: bytes):
|
33
|
-
splice(start: uint64,
|
32
|
+
put(value: bytes): void;
|
33
|
+
splice(start: uint64, length: uint64, value: bytes): void;
|
34
34
|
replace(start: uint64, value: bytes): void;
|
35
35
|
extract(start: uint64, length: uint64): bytes;
|
36
36
|
delete(): boolean;
|
package/compiled.d.ts
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
import { BaseContract } from './base-contract';
|
2
|
+
import { LogicSig } from './logic-sig';
|
3
|
+
import { bytes, uint64 } from './primitives';
|
4
|
+
import { Account } from './reference';
|
5
|
+
import { ConstructorFor, DeliberateAny } from './typescript-helpers';
|
6
|
+
/**
|
7
|
+
* Provides compiled programs and state allocation values for a Contract. Created by calling `compile(ExampleContractType)`
|
8
|
+
*/
|
9
|
+
export type CompiledContract = {
|
10
|
+
/**
|
11
|
+
* Approval program pages for a contract, after template variables have been replaced and compiled to AVM bytecode
|
12
|
+
*/
|
13
|
+
approvalProgram: [bytes, bytes];
|
14
|
+
/**
|
15
|
+
* Clear state program pages for a contract, after template variables have been replaced and compiled to AVM bytecode
|
16
|
+
*/
|
17
|
+
clearStateProgram: [bytes, bytes];
|
18
|
+
/**
|
19
|
+
* By default, provides extra program pages required based on approval and clear state program size, can be overridden when calling `compile(ExampleContractType, { extraProgramPages: ... })`
|
20
|
+
*/
|
21
|
+
extraProgramPages: uint64;
|
22
|
+
/**
|
23
|
+
* By default, provides global num uints based on contract state totals, can be overridden when calling `compile(ExampleContractType, { globalUints: ... })`
|
24
|
+
*/
|
25
|
+
globalUints: uint64;
|
26
|
+
/**
|
27
|
+
* By default, provides global num bytes based on contract state totals, can be overridden when calling `compile(ExampleContractType, { globalBytes: ... })`
|
28
|
+
*/
|
29
|
+
globalBytes: uint64;
|
30
|
+
/**
|
31
|
+
* By default, provides local num uints based on contract state totals, can be overridden when calling `compile(ExampleContractType, { localUints: ... })`
|
32
|
+
*/
|
33
|
+
localUints: uint64;
|
34
|
+
/**
|
35
|
+
* By default, provides local num bytes based on contract state totals, can be overridden when calling `compile(ExampleContractType, { localBytes: ... })`
|
36
|
+
*/
|
37
|
+
localBytes: uint64;
|
38
|
+
};
|
39
|
+
/**
|
40
|
+
* Provides account for a Logic Signature. Created by calling `compile(LogicSigType)`
|
41
|
+
*/
|
42
|
+
export type CompiledLogicSig = {
|
43
|
+
/**
|
44
|
+
* Address of a logic sig program, after template variables have been replaced and compiled to AVM bytecode
|
45
|
+
*/
|
46
|
+
account: Account;
|
47
|
+
};
|
48
|
+
/**
|
49
|
+
* Options for compiling a contract
|
50
|
+
*/
|
51
|
+
type CompileContractOptions = {
|
52
|
+
/**
|
53
|
+
* Number of extra program pages, defaults to minimum required for contract
|
54
|
+
*/
|
55
|
+
extraProgramPages?: uint64;
|
56
|
+
/**
|
57
|
+
* Number of global uint64s, defaults to value defined for contract
|
58
|
+
*/
|
59
|
+
globalUints?: uint64;
|
60
|
+
/**
|
61
|
+
* Number of global bytes, defaults to value defined for contract
|
62
|
+
*/
|
63
|
+
globalBytes?: uint64;
|
64
|
+
/**
|
65
|
+
* Number of local uint64s, defaults to value defined for contract
|
66
|
+
*/
|
67
|
+
localUints?: uint64;
|
68
|
+
/**
|
69
|
+
* Number of local bytes, defaults to value defined for contract
|
70
|
+
*/
|
71
|
+
localBytes?: uint64;
|
72
|
+
/**
|
73
|
+
* Template variables to substitute into the contract, key should be without the prefix, must evaluate to a compile time constant
|
74
|
+
* and match the type of the template var declaration
|
75
|
+
*/
|
76
|
+
templateVars?: Record<string, DeliberateAny>;
|
77
|
+
/**
|
78
|
+
* Prefix to add to provided template vars, defaults to the prefix supplied on command line (which defaults to TMPL_)
|
79
|
+
*/
|
80
|
+
templateVarsPrefix?: string;
|
81
|
+
};
|
82
|
+
/**
|
83
|
+
* Options for compiling a logic signature
|
84
|
+
*/
|
85
|
+
type CompileLogicSigOptions = {
|
86
|
+
/**
|
87
|
+
* Template variables to substitute into the contract, key should be without the prefix, must evaluate to a compile time constant
|
88
|
+
* and match the type of the template var declaration
|
89
|
+
*/
|
90
|
+
templateVars?: Record<string, DeliberateAny>;
|
91
|
+
/**
|
92
|
+
* Prefix to add to provided template vars, defaults to the prefix supplied on command line (which defaults to TMPL_)
|
93
|
+
*/
|
94
|
+
templateVarsPrefix?: string;
|
95
|
+
};
|
96
|
+
/**
|
97
|
+
* Compile a contract and return the resulting byte code for approval and clear state programs.
|
98
|
+
* @param contract The contract class to compile
|
99
|
+
* @param options Options for compiling the contract
|
100
|
+
*/
|
101
|
+
export declare function compile(contract: ConstructorFor<BaseContract>, options?: CompileContractOptions): CompiledContract;
|
102
|
+
/**
|
103
|
+
* Compile a logic signature and return an account ready for signing transactions.
|
104
|
+
* @param logicSig The logic sig class to compile
|
105
|
+
* @param options Options for compiling the logic sig
|
106
|
+
*/
|
107
|
+
export declare function compile(logicSig: ConstructorFor<LogicSig>, options?: CompileLogicSigOptions): CompiledLogicSig;
|
108
|
+
export {};
|
package/execution-context.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Contract, gtxn, itxn } from '.';
|
1
|
+
import { Box, BoxMap, BoxRef, Contract, GlobalState, gtxn, itxn, LocalState } from '.';
|
2
2
|
import { AbiMethodConfig, BareMethodConfig } from './arc4';
|
3
3
|
import { OpsNamespace } from './op-types';
|
4
4
|
import { bytes, uint64 } from './primitives';
|
@@ -30,6 +30,13 @@ export type ExecutionContext = {
|
|
30
30
|
assetFreeze: typeof itxn.assetFreeze;
|
31
31
|
applicationCall: typeof itxn.applicationCall;
|
32
32
|
};
|
33
|
+
state: {
|
34
|
+
GlobalState: typeof GlobalState;
|
35
|
+
LocalState: typeof LocalState;
|
36
|
+
Box: typeof Box;
|
37
|
+
BoxMap: typeof BoxMap;
|
38
|
+
BoxRef: typeof BoxRef;
|
39
|
+
};
|
33
40
|
};
|
34
41
|
declare global {
|
35
42
|
var puyaTsExecutionContext: ExecutionContext | undefined;
|
package/impl/errors.d.ts
CHANGED
@@ -27,3 +27,10 @@ export declare class CodeError extends Error {
|
|
27
27
|
constructor(message: string, options?: ErrorOptions);
|
28
28
|
}
|
29
29
|
export declare function codeError(message: string): never;
|
30
|
+
/**
|
31
|
+
* This error can be used in stub implementations that are expected to be overridden
|
32
|
+
* by the testing framework
|
33
|
+
*/
|
34
|
+
export declare class NoImplementation extends Error {
|
35
|
+
constructor();
|
36
|
+
}
|
package/impl/primitives.d.ts
CHANGED
@@ -6,13 +6,13 @@ export declare function toExternalValue(val: uint64): bigint;
|
|
6
6
|
export declare function toExternalValue(val: biguint): bigint;
|
7
7
|
export declare function toExternalValue(val: bytes): Uint8Array;
|
8
8
|
export declare function toExternalValue(val: string): string;
|
9
|
-
export declare const toBytes: (val: unknown) => bytes;
|
10
9
|
/**
|
11
10
|
* Convert a StubUint64Compat value into a 'number' if possible.
|
12
11
|
* This value may be negative
|
13
12
|
* @param v
|
14
13
|
*/
|
15
14
|
export declare const getNumber: (v: StubUint64Compat) => number;
|
15
|
+
export declare const getUint8Array: (v: StubBytesCompat) => Uint8Array;
|
16
16
|
export declare const isBytes: (v: unknown) => v is StubBytesCompat;
|
17
17
|
export declare const isUint64: (v: unknown) => v is StubUint64Compat;
|
18
18
|
export declare const checkUint64: (v: bigint) => bigint;
|
@@ -51,7 +51,7 @@ export declare class BytesCls extends AlgoTsPrimitiveCls {
|
|
51
51
|
get length(): Uint64Cls;
|
52
52
|
toBytes(): BytesCls;
|
53
53
|
at(i: StubUint64Compat): BytesCls;
|
54
|
-
slice(start
|
54
|
+
slice(start?: StubUint64Compat, end?: StubUint64Compat): BytesCls;
|
55
55
|
concat(other: StubBytesCompat): BytesCls;
|
56
56
|
bitwiseAnd(other: StubBytesCompat): BytesCls;
|
57
57
|
bitwiseOr(other: StubBytesCompat): BytesCls;
|
@@ -78,5 +78,5 @@ export declare const arrayUtil: {
|
|
78
78
|
arrayAt<T>(arrayLike: T[] | Uint8Array, index: StubUint64Compat): T | Uint8Array;
|
79
79
|
arraySlice(arrayLike: Uint8Array, start: undefined | StubUint64Compat, end: undefined | StubUint64Compat): Uint8Array;
|
80
80
|
arraySlice<T>(arrayLike: T[], start: undefined | StubUint64Compat, end: undefined | StubUint64Compat): T[];
|
81
|
-
arraySlice<T>(arrayLike: Uint8Array | T[], start: undefined | StubUint64Compat, end: undefined | StubUint64Compat): Uint8Array | T[];
|
81
|
+
arraySlice<T>(arrayLike: Uint8Array<ArrayBufferLike> | T[], start: undefined | StubUint64Compat, end: undefined | StubUint64Compat): Uint8Array<ArrayBufferLike> | T[];
|
82
82
|
};
|