@algorandfoundation/algorand-typescript 0.0.1-alpha.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.
@@ -0,0 +1,342 @@
1
+ import { OnCompleteActionStr } from './arc4';
2
+ import { bytes, uint64 } from './primitives';
3
+ import { Account, Application, Asset } from './reference';
4
+ /**
5
+ * The different transaction types available in a transaction
6
+ */
7
+ export declare enum TransactionType {
8
+ /**
9
+ * A Payment transaction
10
+ */
11
+ Payment = 1,
12
+ /**
13
+ * A Key Registration transaction
14
+ */
15
+ KeyRegistration = 2,
16
+ /**
17
+ * An Asset Config transaction
18
+ */
19
+ AssetConfig = 3,
20
+ /**
21
+ * An Asset Transfer transaction
22
+ */
23
+ AssetTransfer = 4,
24
+ /**
25
+ * An Asset Freeze transaction
26
+ */
27
+ AssetFreeze = 5,
28
+ /**
29
+ * An Application Call transaction
30
+ */
31
+ ApplicationCall = 6
32
+ }
33
+ interface TransactionBase {
34
+ /**
35
+ * 32 byte address
36
+ */
37
+ readonly sender: Account;
38
+ /**
39
+ * microalgos
40
+ */
41
+ readonly fee: uint64;
42
+ /**
43
+ * round number
44
+ */
45
+ readonly firstValid: uint64;
46
+ /**
47
+ * UNIX timestamp of block before txn.FirstValid. Fails if negative
48
+ */
49
+ readonly firstValidTime: uint64;
50
+ /**
51
+ * round number
52
+ */
53
+ readonly lastValid: uint64;
54
+ /**
55
+ * Any data up to 1024 bytes
56
+ */
57
+ readonly note: bytes;
58
+ /**
59
+ * 32 byte lease value
60
+ */
61
+ readonly lease: bytes;
62
+ /**
63
+ * Transaction type as bytes
64
+ */
65
+ readonly typeBytes: bytes;
66
+ /**
67
+ * Position of this transaction within an atomic group
68
+ * A stand-alone transaction is implicitly element 0 in a group of 1
69
+ */
70
+ readonly groupIndex: uint64;
71
+ /**
72
+ * The computed ID for this transaction. 32 bytes.
73
+ */
74
+ readonly txnId: bytes;
75
+ /**
76
+ * 32 byte Sender's new AuthAddr
77
+ */
78
+ readonly rekeyTo: Account;
79
+ }
80
+ export interface PaymentTxn extends TransactionBase {
81
+ /**
82
+ * 32 byte address
83
+ */
84
+ readonly receiver: Account;
85
+ /**
86
+ * microalgos
87
+ */
88
+ readonly amount: uint64;
89
+ /**
90
+ * 32 byte address
91
+ */
92
+ readonly closeRemainderTo: Account;
93
+ /**
94
+ * Transaction type as integer
95
+ */
96
+ readonly type: TransactionType.Payment;
97
+ }
98
+ export interface KeyRegistrationTxn extends TransactionBase {
99
+ /**
100
+ * 32 byte address
101
+ */
102
+ readonly voteKey: bytes;
103
+ /**
104
+ * 32 byte address
105
+ */
106
+ readonly selectionKey: bytes;
107
+ /**
108
+ * The first round that the participation key is valid.
109
+ */
110
+ readonly voteFirst: uint64;
111
+ /**
112
+ * The last round that the participation key is valid.
113
+ */
114
+ readonly voteLast: uint64;
115
+ /**
116
+ * Dilution for the 2-level participation key
117
+ */
118
+ readonly voteKeyDilution: uint64;
119
+ /**
120
+ * Marks an account nonparticipating for rewards
121
+ */
122
+ readonly nonparticipation: boolean;
123
+ /**
124
+ * 64 byte state proof public key
125
+ */
126
+ readonly stateProofKey: bytes;
127
+ /**
128
+ * Transaction type as integer
129
+ */
130
+ readonly type: TransactionType.KeyRegistration;
131
+ }
132
+ export interface AssetConfigTxn extends TransactionBase {
133
+ /**
134
+ * Asset ID in asset config transaction
135
+ */
136
+ readonly configAsset: Asset;
137
+ /**
138
+ * Total number of units of this asset created
139
+ */
140
+ readonly total: uint64;
141
+ /**
142
+ * Number of digits to display after the decimal place when displaying the asset
143
+ */
144
+ readonly decimals: uint64;
145
+ /**
146
+ * Whether the asset's slots are frozen by default or not, 0 or 1
147
+ */
148
+ readonly defaultFrozen: boolean;
149
+ /**
150
+ * Unit name of the asset
151
+ */
152
+ readonly unitName: bytes;
153
+ /**
154
+ * The asset name
155
+ */
156
+ readonly assetName: bytes;
157
+ /**
158
+ * URL
159
+ */
160
+ readonly url: bytes;
161
+ /**
162
+ * 32 byte commitment to unspecified asset metadata
163
+ */
164
+ readonly metadataHash: bytes;
165
+ /**
166
+ * 32 byte address
167
+ */
168
+ readonly manager: Account;
169
+ /**
170
+ * 32 byte address
171
+ */
172
+ readonly reserve: Account;
173
+ /**
174
+ * 32 byte address
175
+ */
176
+ readonly freeze: Account;
177
+ /**
178
+ * 32 byte address
179
+ */
180
+ readonly clawback: Account;
181
+ /**
182
+ * Asset ID allocated by the creation of an ASA
183
+ */
184
+ createdAsset: Asset;
185
+ /**
186
+ * Transaction type as integer
187
+ */
188
+ readonly type: TransactionType.AssetConfig;
189
+ }
190
+ export interface AssetTransferTxn extends TransactionBase {
191
+ /**
192
+ * Asset ID
193
+ */
194
+ readonly xferAsset: Asset;
195
+ /**
196
+ * value in Asset's units
197
+ */
198
+ readonly assetAmount: uint64;
199
+ /**
200
+ * 32 byte address. Source of assets if Sender is the Asset's Clawback address.
201
+ */
202
+ readonly assetSender: Account;
203
+ /**
204
+ * 32 byte address
205
+ */
206
+ readonly assetReceiver: Account;
207
+ /**
208
+ * 32 byte address
209
+ */
210
+ readonly assetCloseTo: Account;
211
+ /**
212
+ * Transaction type as integer
213
+ */
214
+ readonly type: TransactionType.AssetTransfer;
215
+ }
216
+ export interface AssetFreezeTxn extends TransactionBase {
217
+ /**
218
+ * Asset ID being frozen or un-frozen
219
+ */
220
+ readonly freezeAsset: Asset;
221
+ /**
222
+ * 32 byte address of the account whose asset slot is being frozen or un-frozen
223
+ */
224
+ readonly freezeAccount: Account;
225
+ /**
226
+ * The new frozen value
227
+ */
228
+ readonly frozen: boolean;
229
+ /**
230
+ * Transaction type as integer
231
+ */
232
+ readonly type: TransactionType.AssetFreeze;
233
+ }
234
+ export interface ApplicationTxn extends TransactionBase {
235
+ /**
236
+ * ApplicationID from ApplicationCall transaction
237
+ */
238
+ readonly appId: Application;
239
+ /**
240
+ * ApplicationCall transaction on completion action
241
+ */
242
+ readonly onCompletion: OnCompleteActionStr;
243
+ /**
244
+ * Number of ApplicationArgs
245
+ */
246
+ readonly numAppArgs: uint64;
247
+ /**
248
+ * Number of ApplicationArgs
249
+ */
250
+ readonly numAccounts: uint64;
251
+ /**
252
+ * Approval program
253
+ */
254
+ readonly approvalProgram: bytes;
255
+ /**
256
+ * Clear State program
257
+ */
258
+ readonly clearStateProgram: bytes;
259
+ /**
260
+ * Number of Assets
261
+ */
262
+ readonly numAssets: uint64;
263
+ /**
264
+ * Number of Applications
265
+ */
266
+ readonly numApps: uint64;
267
+ /**
268
+ * Number of global state integers in ApplicationCall
269
+ */
270
+ readonly globalNumUint: uint64;
271
+ /**
272
+ * Number of global state byteslices in ApplicationCall
273
+ */
274
+ readonly globalNumBytes: uint64;
275
+ /**
276
+ * Number of local state integers in ApplicationCall
277
+ */
278
+ readonly localNumUint: uint64;
279
+ /**
280
+ * Number of local state byteslices in ApplicationCall
281
+ */
282
+ readonly localNumBytes: uint64;
283
+ /**
284
+ * Number of additional pages for each of the application's approval and clear state programs. An ExtraProgramPages of 1 means 2048 more total bytes, or 1024 for each program.
285
+ */
286
+ readonly extraProgramPages: uint64;
287
+ /**
288
+ * The last message emitted. Empty bytes if none were emitted. Application mode only
289
+ */
290
+ readonly lastLog: bytes;
291
+ /**
292
+ * Log messages emitted by an application call
293
+ */
294
+ logs(index: uint64): bytes;
295
+ /**
296
+ * Number of logs
297
+ */
298
+ readonly numLogs: uint64;
299
+ /**
300
+ * ApplicationID allocated by the creation of an application
301
+ */
302
+ readonly createdApp: Application;
303
+ /**
304
+ * Number of Approval Program pages
305
+ */
306
+ readonly numApprovalProgramPages: uint64;
307
+ /**
308
+ * Number of Clear State Program pages
309
+ */
310
+ readonly numClearStateProgramPages: uint64;
311
+ /**
312
+ * Arguments passed to the application in the ApplicationCall transaction
313
+ * @param index
314
+ */
315
+ appArgs(index: uint64): bytes;
316
+ /**
317
+ * Accounts listed in the ApplicationCall transaction
318
+ */
319
+ accounts(index: uint64): Account;
320
+ /**
321
+ * Foreign Assets listed in the ApplicationCall transaction
322
+ */
323
+ assets(index: uint64): Asset;
324
+ /**
325
+ * Foreign Apps listed in the ApplicationCall transaction
326
+ */
327
+ apps(index: uint64): Application;
328
+ /**
329
+ * Approval Program as an array of pages
330
+ */
331
+ approvalProgramPages(index: uint64): bytes;
332
+ /**
333
+ * Clear State Program as an array of pages
334
+ */
335
+ clearStateProgramPages(index: uint64): bytes;
336
+ /**
337
+ * Transaction type as integer
338
+ */
339
+ readonly type: TransactionType.ApplicationCall;
340
+ }
341
+ export type Transaction = PaymentTxn | KeyRegistrationTxn | AssetConfigTxn | AssetTransferTxn | AssetFreezeTxn | ApplicationTxn;
342
+ export {};
@@ -0,0 +1,2 @@
1
+ export type DeliberateAny = any;
2
+ export type AnyFunction = (...args: DeliberateAny[]) => DeliberateAny;
package/util.d.ts ADDED
@@ -0,0 +1,31 @@
1
+ import { biguint, BigUintCompat, BytesCompat, StringCompat, uint64, Uint64Compat } from './primitives';
2
+ export declare function log(...args: Array<Uint64Compat | BytesCompat | BigUintCompat | StringCompat>): void;
3
+ export declare function assert(condition: unknown, message?: string): asserts condition;
4
+ export declare function err(message?: string): never;
5
+ type NumericComparison<T> = T | {
6
+ lessThan: T;
7
+ } | {
8
+ greaterThan: T;
9
+ } | {
10
+ greaterThanEq: T;
11
+ } | {
12
+ lessThanEq: T;
13
+ } | {
14
+ between: [T, T];
15
+ };
16
+ type ComparisonFor<T> = T extends uint64 | biguint ? NumericComparison<T> : T;
17
+ type MatchTest<T> = {
18
+ [key in keyof T]?: ComparisonFor<T[key]>;
19
+ };
20
+ export declare function match<T>(subject: T, test: MatchTest<T>): boolean;
21
+ export declare function assertMatch<T>(subject: T, test: MatchTest<T>, message?: string): boolean;
22
+ export declare enum OpUpFeeSource {
23
+ GroupCredit = 0,
24
+ AppAccount = 1,
25
+ Any = 2
26
+ }
27
+ export declare function ensureBudget(budget: uint64, feeSource?: OpUpFeeSource): void;
28
+ export declare function urange(stop: Uint64Compat): IterableIterator<uint64>;
29
+ export declare function urange(start: Uint64Compat, stop: Uint64Compat): IterableIterator<uint64>;
30
+ export declare function urange(start: Uint64Compat, stop: Uint64Compat, step: Uint64Compat): IterableIterator<uint64>;
31
+ export {};