openclaw-algorand-plugin 0.5.0
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/LICENSE +21 -0
- package/README.md +112 -0
- package/index.ts +361 -0
- package/lib/mcp-servers.ts +14 -0
- package/lib/x402-fetch.ts +213 -0
- package/memory/algorand-plugin.md +82 -0
- package/openclaw.plugin.json +30 -0
- package/package.json +38 -0
- package/setup.ts +80 -0
- package/skills/algorand-development/SKILL.md +90 -0
- package/skills/algorand-development/references/build-smart-contracts-reference.md +79 -0
- package/skills/algorand-development/references/build-smart-contracts.md +52 -0
- package/skills/algorand-development/references/create-project-reference.md +86 -0
- package/skills/algorand-development/references/create-project.md +89 -0
- package/skills/algorand-development/references/implement-arc-standards-arc32-arc56.md +396 -0
- package/skills/algorand-development/references/implement-arc-standards-arc4.md +265 -0
- package/skills/algorand-development/references/implement-arc-standards.md +92 -0
- package/skills/algorand-development/references/search-algorand-examples-reference.md +119 -0
- package/skills/algorand-development/references/search-algorand-examples.md +89 -0
- package/skills/algorand-development/references/troubleshoot-errors-contract.md +373 -0
- package/skills/algorand-development/references/troubleshoot-errors-transaction.md +599 -0
- package/skills/algorand-development/references/troubleshoot-errors.md +105 -0
- package/skills/algorand-development/references/use-algokit-cli-reference.md +228 -0
- package/skills/algorand-development/references/use-algokit-cli.md +64 -0
- package/skills/algorand-interaction/SKILL.md +223 -0
- package/skills/algorand-interaction/references/algorand-mcp.md +743 -0
- package/skills/algorand-interaction/references/examples-algorand-mcp.md +647 -0
- package/skills/algorand-python/SKILL.md +95 -0
- package/skills/algorand-python/references/build-smart-contracts-decorators.md +413 -0
- package/skills/algorand-python/references/build-smart-contracts-reference.md +55 -0
- package/skills/algorand-python/references/build-smart-contracts-storage.md +452 -0
- package/skills/algorand-python/references/build-smart-contracts-transactions.md +445 -0
- package/skills/algorand-python/references/build-smart-contracts-types.md +438 -0
- package/skills/algorand-python/references/build-smart-contracts.md +82 -0
- package/skills/algorand-python/references/create-project-reference.md +55 -0
- package/skills/algorand-python/references/create-project.md +75 -0
- package/skills/algorand-python/references/implement-arc-standards-arc32-arc56.md +101 -0
- package/skills/algorand-python/references/implement-arc-standards-arc4.md +154 -0
- package/skills/algorand-python/references/implement-arc-standards.md +39 -0
- package/skills/algorand-python/references/troubleshoot-errors-contract.md +355 -0
- package/skills/algorand-python/references/troubleshoot-errors-transaction.md +430 -0
- package/skills/algorand-python/references/troubleshoot-errors.md +46 -0
- package/skills/algorand-python/references/use-algokit-utils-reference.md +350 -0
- package/skills/algorand-python/references/use-algokit-utils.md +76 -0
- package/skills/algorand-typescript/SKILL.md +131 -0
- package/skills/algorand-typescript/references/algorand-ts-migration-from-beta.md +448 -0
- package/skills/algorand-typescript/references/algorand-ts-migration-from-tealscript.md +487 -0
- package/skills/algorand-typescript/references/algorand-ts-migration.md +102 -0
- package/skills/algorand-typescript/references/algorand-typescript-syntax-methods-and-abi.md +134 -0
- package/skills/algorand-typescript/references/algorand-typescript-syntax-reference.md +58 -0
- package/skills/algorand-typescript/references/algorand-typescript-syntax-storage.md +154 -0
- package/skills/algorand-typescript/references/algorand-typescript-syntax-transactions.md +187 -0
- package/skills/algorand-typescript/references/algorand-typescript-syntax-types-and-values.md +150 -0
- package/skills/algorand-typescript/references/algorand-typescript-syntax.md +84 -0
- package/skills/algorand-typescript/references/build-smart-contracts-reference.md +52 -0
- package/skills/algorand-typescript/references/build-smart-contracts.md +74 -0
- package/skills/algorand-typescript/references/call-smart-contracts-reference.md +237 -0
- package/skills/algorand-typescript/references/call-smart-contracts.md +183 -0
- package/skills/algorand-typescript/references/create-project-reference.md +53 -0
- package/skills/algorand-typescript/references/create-project.md +86 -0
- package/skills/algorand-typescript/references/deploy-react-frontend-examples.md +527 -0
- package/skills/algorand-typescript/references/deploy-react-frontend-reference.md +412 -0
- package/skills/algorand-typescript/references/deploy-react-frontend.md +239 -0
- package/skills/algorand-typescript/references/implement-arc-standards-arc32-arc56.md +73 -0
- package/skills/algorand-typescript/references/implement-arc-standards-arc4.md +126 -0
- package/skills/algorand-typescript/references/implement-arc-standards.md +44 -0
- package/skills/algorand-typescript/references/test-smart-contracts-examples.md +245 -0
- package/skills/algorand-typescript/references/test-smart-contracts-unit-tests.md +147 -0
- package/skills/algorand-typescript/references/test-smart-contracts.md +127 -0
- package/skills/algorand-typescript/references/troubleshoot-errors-contract.md +296 -0
- package/skills/algorand-typescript/references/troubleshoot-errors-transaction.md +438 -0
- package/skills/algorand-typescript/references/troubleshoot-errors.md +56 -0
- package/skills/algorand-typescript/references/use-algokit-utils-reference.md +342 -0
- package/skills/algorand-typescript/references/use-algokit-utils.md +74 -0
- package/skills/algorand-x402-python/SKILL.md +113 -0
- package/skills/algorand-x402-python/references/create-python-x402-client-examples.md +469 -0
- package/skills/algorand-x402-python/references/create-python-x402-client-reference.md +313 -0
- package/skills/algorand-x402-python/references/create-python-x402-client.md +207 -0
- package/skills/algorand-x402-python/references/create-python-x402-facilitator-examples.md +924 -0
- package/skills/algorand-x402-python/references/create-python-x402-facilitator-reference.md +629 -0
- package/skills/algorand-x402-python/references/create-python-x402-facilitator.md +408 -0
- package/skills/algorand-x402-python/references/create-python-x402-server-examples.md +703 -0
- package/skills/algorand-x402-python/references/create-python-x402-server-reference.md +303 -0
- package/skills/algorand-x402-python/references/create-python-x402-server.md +221 -0
- package/skills/algorand-x402-python/references/explain-algorand-x402-python-examples.md +605 -0
- package/skills/algorand-x402-python/references/explain-algorand-x402-python-reference.md +315 -0
- package/skills/algorand-x402-python/references/explain-algorand-x402-python.md +167 -0
- package/skills/algorand-x402-python/references/use-python-x402-core-avm-examples.md +554 -0
- package/skills/algorand-x402-python/references/use-python-x402-core-avm-reference.md +278 -0
- package/skills/algorand-x402-python/references/use-python-x402-core-avm.md +166 -0
- package/skills/algorand-x402-typescript/SKILL.md +129 -0
- package/skills/algorand-x402-typescript/references/create-typescript-x402-client-examples.md +879 -0
- package/skills/algorand-x402-typescript/references/create-typescript-x402-client-reference.md +371 -0
- package/skills/algorand-x402-typescript/references/create-typescript-x402-client.md +236 -0
- package/skills/algorand-x402-typescript/references/create-typescript-x402-facilitator-examples.md +875 -0
- package/skills/algorand-x402-typescript/references/create-typescript-x402-facilitator-reference.md +461 -0
- package/skills/algorand-x402-typescript/references/create-typescript-x402-facilitator.md +270 -0
- package/skills/algorand-x402-typescript/references/create-typescript-x402-nextjs-examples.md +1181 -0
- package/skills/algorand-x402-typescript/references/create-typescript-x402-nextjs-reference.md +360 -0
- package/skills/algorand-x402-typescript/references/create-typescript-x402-nextjs.md +251 -0
- package/skills/algorand-x402-typescript/references/create-typescript-x402-paywall-examples.md +870 -0
- package/skills/algorand-x402-typescript/references/create-typescript-x402-paywall-reference.md +323 -0
- package/skills/algorand-x402-typescript/references/create-typescript-x402-paywall.md +281 -0
- package/skills/algorand-x402-typescript/references/create-typescript-x402-server-examples.md +1135 -0
- package/skills/algorand-x402-typescript/references/create-typescript-x402-server-reference.md +382 -0
- package/skills/algorand-x402-typescript/references/create-typescript-x402-server.md +216 -0
- package/skills/algorand-x402-typescript/references/explain-algorand-x402-typescript-examples.md +616 -0
- package/skills/algorand-x402-typescript/references/explain-algorand-x402-typescript-reference.md +323 -0
- package/skills/algorand-x402-typescript/references/explain-algorand-x402-typescript.md +232 -0
- package/skills/algorand-x402-typescript/references/use-typescript-x402-core-avm-examples.md +1417 -0
- package/skills/algorand-x402-typescript/references/use-typescript-x402-core-avm-reference.md +504 -0
- package/skills/algorand-x402-typescript/references/use-typescript-x402-core-avm.md +158 -0
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
# Migrating Algorand TypeScript Beta to 1.0
|
|
2
|
+
|
|
3
|
+
## Table of Contents
|
|
4
|
+
|
|
5
|
+
- [Migration Checklist](#migration-checklist)
|
|
6
|
+
- [Breaking Changes](#breaking-changes)
|
|
7
|
+
- [Object literals - mutability](#object-literals---add-readonly-or-as-const-if-immutability-needed)
|
|
8
|
+
- [Native arrays - mutability](#native-arrays---add-readonly-or-as-const-if-immutability-needed)
|
|
9
|
+
- [MutableArray → ReferenceArray](#rename-mutablearray-to-referencearray)
|
|
10
|
+
- [copy() → clone()](#replace-xxxcopy-calls-with-clonexxx)
|
|
11
|
+
- [ARC4 numeric types](#remove-n-and-nxm-suffixes-from-arc4-numeric-types)
|
|
12
|
+
- [gtxn/itxn imports](#update-gtxn-and-itxn-imports)
|
|
13
|
+
- [Resource encoding](#update-resource-encoding)
|
|
14
|
+
- [Test file naming](#rename-test-files)
|
|
15
|
+
- [arc4EncodedLength → sizeOf](#rename-arc4encodedlength-to-sizeof)
|
|
16
|
+
- [abiCall signature](#update-abicall-syntax)
|
|
17
|
+
- [interpretAsArc4 → convertBytes](#rename-interpretasarc4-to-convertbytes)
|
|
18
|
+
- [BoxRef → Box\<bytes\>](#replace-boxref-with-boxbytes)
|
|
19
|
+
- [.native property](#replace-native-property)
|
|
20
|
+
- [New Features](#new-features)
|
|
21
|
+
|
|
22
|
+
## Migration Checklist
|
|
23
|
+
|
|
24
|
+
Work through these changes when migrating from beta to 1.0:
|
|
25
|
+
|
|
26
|
+
- [ ] **Object literals**: Add `readonly` or `as const` if immutability needed
|
|
27
|
+
- [ ] **Native arrays**: Add `readonly` or `as const` if immutability needed
|
|
28
|
+
- [ ] **MutableArray → ReferenceArray**: Replace all usages
|
|
29
|
+
- [ ] **Copy method**: Replace `.copy()` with `clone()`
|
|
30
|
+
- [ ] **ARC4 numeric types**: Remove 'N' and 'NxM' suffixes
|
|
31
|
+
- [ ] **gtxn/itxn imports**: Update to namespaced imports
|
|
32
|
+
- [ ] **Resource encoding**: Add `resourceEncoding: 'index'` or update implementation
|
|
33
|
+
- [ ] **Test files**: Rename from `.(spec|test).ts` to `.algo.(spec|test).ts`
|
|
34
|
+
- [ ] **arc4EncodedLength**: Replace with `sizeOf`
|
|
35
|
+
- [ ] **abiCall signature**: Update to object parameter syntax
|
|
36
|
+
- [ ] **interpretAsArc4**: Replace with `convertBytes`
|
|
37
|
+
- [ ] **BoxRef**: Replace with `Box<bytes>`
|
|
38
|
+
- [ ] **.native property**: Replace with `.asUint64()` or `.asBigUint()`
|
|
39
|
+
|
|
40
|
+
## Breaking Changes
|
|
41
|
+
|
|
42
|
+
### Object literals - add `readonly` or `as const` if immutability needed
|
|
43
|
+
|
|
44
|
+
Object literals are now mutable by default.
|
|
45
|
+
|
|
46
|
+
**BEFORE - Beta**
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import { uint64, Uint64 } from '@algorandfoundation/algorand-typescript';
|
|
50
|
+
|
|
51
|
+
// These are immutable
|
|
52
|
+
type Point = { y: uint64; x: uint64 };
|
|
53
|
+
const p1: Point = { x: 1, y: 2 };
|
|
54
|
+
const p2 = { x: Uint64(1), y: Uint64(2) };
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**AFTER - 1.0**
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import { uint64, Uint64 } from '@algorandfoundation/algorand-typescript';
|
|
61
|
+
|
|
62
|
+
// Mutable by default
|
|
63
|
+
type Point = { y: uint64; x: uint64 };
|
|
64
|
+
const p1: Point = { x: 1, y: 2 };
|
|
65
|
+
p1.x = 3; // Now allowed
|
|
66
|
+
|
|
67
|
+
// For immutability, use readonly or as const
|
|
68
|
+
type ImmutablePoint = Readonly<{ y: uint64; x: uint64 }>;
|
|
69
|
+
const p2 = { x: Uint64(1), y: Uint64(2) } as const;
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Native arrays - add `readonly` or `as const` if immutability needed
|
|
73
|
+
|
|
74
|
+
Native arrays are now mutable by default.
|
|
75
|
+
|
|
76
|
+
**BEFORE - Beta**
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
import { uint64, Uint64 } from '@algorandfoundation/algorand-typescript';
|
|
80
|
+
|
|
81
|
+
// Arrays are immutable
|
|
82
|
+
const t1: uint64[] = [1, 2, 3];
|
|
83
|
+
const t2 = [Uint64(1), Uint64(2), Uint64(3)];
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**AFTER - 1.0**
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
import { uint64, Uint64 } from '@algorandfoundation/algorand-typescript';
|
|
90
|
+
|
|
91
|
+
// Arrays are mutable
|
|
92
|
+
const t1: uint64[] = [1, 2, 3];
|
|
93
|
+
t1[0] = 3;
|
|
94
|
+
t1.push(4);
|
|
95
|
+
|
|
96
|
+
// For immutability
|
|
97
|
+
const t2: readonly uint64[] = [1, 2, 3];
|
|
98
|
+
const t3 = [Uint64(1), Uint64(2), Uint64(3)] as const;
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Rename `MutableArray` to `ReferenceArray`
|
|
102
|
+
|
|
103
|
+
**BEFORE - Beta**
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
import { uint64, MutableArray } from '@algorandfoundation/algorand-typescript';
|
|
107
|
+
|
|
108
|
+
const a = new MutableArray<uint64>();
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**AFTER - 1.0**
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
import { uint64, ReferenceArray } from '@algorandfoundation/algorand-typescript';
|
|
115
|
+
|
|
116
|
+
const a = new ReferenceArray<uint64>();
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Replace `xxx.copy()` calls with `clone(xxx)`
|
|
120
|
+
|
|
121
|
+
**BEFORE - Beta**
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
import { arc4 } from '@algorandfoundation/algorand-typescript';
|
|
125
|
+
|
|
126
|
+
const a = new arc4.StaticArray<arc4.UintN64, 3>(
|
|
127
|
+
new arc4.UintN64(1),
|
|
128
|
+
new arc4.UintN64(2),
|
|
129
|
+
new arc4.UintN64(3)
|
|
130
|
+
);
|
|
131
|
+
const b = a.copy();
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**AFTER - 1.0**
|
|
135
|
+
|
|
136
|
+
```ts
|
|
137
|
+
import { arc4, clone } from '@algorandfoundation/algorand-typescript';
|
|
138
|
+
|
|
139
|
+
const a = new arc4.StaticArray<arc4.Uint64, 3>(
|
|
140
|
+
new arc4.Uint64(1),
|
|
141
|
+
new arc4.Uint64(2),
|
|
142
|
+
new arc4.Uint64(3)
|
|
143
|
+
);
|
|
144
|
+
const b = clone(a);
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Remove 'N' and 'NxM' suffixes from ARC4 numeric types
|
|
148
|
+
|
|
149
|
+
**BEFORE - Beta**
|
|
150
|
+
|
|
151
|
+
```ts
|
|
152
|
+
import { arc4 } from '@algorandfoundation/algorand-typescript';
|
|
153
|
+
|
|
154
|
+
type User = {
|
|
155
|
+
id: arc4.UintN16;
|
|
156
|
+
score: arc4.UFixedNxM<32, 4>;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
const user = {
|
|
160
|
+
id: new arc4.UintN<16>(1234),
|
|
161
|
+
score: new arc4.UFixedNxM<32, 4>('1.234'),
|
|
162
|
+
};
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
**AFTER - 1.0**
|
|
166
|
+
|
|
167
|
+
```ts
|
|
168
|
+
import { arc4 } from '@algorandfoundation/algorand-typescript';
|
|
169
|
+
|
|
170
|
+
type User = {
|
|
171
|
+
id: arc4.Uint16;
|
|
172
|
+
score: arc4.UFixed<32, 4>;
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
const user = {
|
|
176
|
+
id: new arc4.Uint<16>(1234),
|
|
177
|
+
score: new arc4.UFixed<32, 4>('1.234'),
|
|
178
|
+
};
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Update `gtxn` and `itxn` imports
|
|
182
|
+
|
|
183
|
+
**BEFORE - Beta**
|
|
184
|
+
|
|
185
|
+
```ts
|
|
186
|
+
import type { PaymentTxn } from '@algorandfoundation/algorand-typescript/gtxn';
|
|
187
|
+
|
|
188
|
+
function makePayment(payment: PaymentTxn) {
|
|
189
|
+
// ...
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
**AFTER - 1.0**
|
|
194
|
+
|
|
195
|
+
```ts
|
|
196
|
+
import type { gtxn } from '@algorandfoundation/algorand-typescript';
|
|
197
|
+
|
|
198
|
+
function makePayment(payment: gtxn.PaymentTxn) {
|
|
199
|
+
// ...
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Update resource encoding
|
|
204
|
+
|
|
205
|
+
`resourceEncoding: 'index' | 'value'` option added to `@abimethod` with `value` as default.
|
|
206
|
+
|
|
207
|
+
**BEFORE - Beta**
|
|
208
|
+
|
|
209
|
+
```ts
|
|
210
|
+
test(asset: Asset, app: Application, acc: Account) {
|
|
211
|
+
const assetIdx = op.btoi(Txn.applicationArgs(1));
|
|
212
|
+
assert(asset === Txn.assets(assetIdx));
|
|
213
|
+
// ...
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
**AFTER - 1.0 (keeping index behavior)**
|
|
218
|
+
|
|
219
|
+
```ts
|
|
220
|
+
import { abimethod } from '@algorandfoundation/algorand-typescript';
|
|
221
|
+
|
|
222
|
+
@abimethod({ resourceEncoding: 'index' })
|
|
223
|
+
test(asset: Asset, app: Application, acc: Account) {
|
|
224
|
+
const assetIdx = op.btoi(Txn.applicationArgs(1));
|
|
225
|
+
assert(asset === Txn.assets(assetIdx));
|
|
226
|
+
// ...
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
**AFTER - 1.0 (using new value encoding)**
|
|
231
|
+
|
|
232
|
+
```ts
|
|
233
|
+
test(asset: Asset, app: Application, acc: Account) {
|
|
234
|
+
const assetId = op.btoi(Txn.applicationArgs(1));
|
|
235
|
+
assert(asset === Asset(assetId)); // Now passed by value
|
|
236
|
+
// ...
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### Rename test files
|
|
241
|
+
|
|
242
|
+
Rename test files from `.(spec|test).ts` to `.algo.(spec|test).ts` for files that:
|
|
243
|
+
- Run in simulated AVM environment
|
|
244
|
+
- Import from `algorand-typescript` or `algorand-typescript-testing`
|
|
245
|
+
|
|
246
|
+
### Rename `arc4EncodedLength` to `sizeOf`
|
|
247
|
+
|
|
248
|
+
**BEFORE - Beta**
|
|
249
|
+
|
|
250
|
+
```ts
|
|
251
|
+
import { arc4EncodedLength, assert } from '@algorandfoundation/algorand-typescript';
|
|
252
|
+
|
|
253
|
+
assert(arc4EncodedLength<uint64>() === 8);
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
**AFTER - 1.0**
|
|
257
|
+
|
|
258
|
+
```ts
|
|
259
|
+
import { sizeOf, assert } from '@algorandfoundation/algorand-typescript';
|
|
260
|
+
|
|
261
|
+
assert(sizeOf<uint64>() === 8);
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### Update `abiCall` syntax
|
|
265
|
+
|
|
266
|
+
**BEFORE - Beta**
|
|
267
|
+
|
|
268
|
+
```ts
|
|
269
|
+
arc4.abiCall(Hello.prototype.greet, {
|
|
270
|
+
appId: 1234,
|
|
271
|
+
args: ['abi'],
|
|
272
|
+
});
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
**AFTER - 1.0**
|
|
276
|
+
|
|
277
|
+
```ts
|
|
278
|
+
// Option 1: method property
|
|
279
|
+
arc4.abiCall({
|
|
280
|
+
method: Hello.prototype.greet,
|
|
281
|
+
appId: app,
|
|
282
|
+
args: ['abi'],
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
// Option 2: type argument (supports type-only imports)
|
|
286
|
+
arc4.abiCall<typeof HelloStubbed.prototype.greet>({
|
|
287
|
+
appId: app,
|
|
288
|
+
args: ['stubbed'],
|
|
289
|
+
});
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### Rename `interpretAsArc4` to `convertBytes`
|
|
293
|
+
|
|
294
|
+
**BEFORE - Beta**
|
|
295
|
+
|
|
296
|
+
```ts
|
|
297
|
+
const x = arc4.interpretAsArc4<arc4.UintN<32>>(someBytes);
|
|
298
|
+
const y = arc4.interpretAsArc4<arc4.Byte>(someBytes, 'log');
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
**AFTER - 1.0**
|
|
302
|
+
|
|
303
|
+
```ts
|
|
304
|
+
const x = arc4.convertBytes<arc4.Uint<32>>(someBytes, { strategy: 'validate' });
|
|
305
|
+
const y = arc4.convertBytes<arc4.Byte>(someBytes, {
|
|
306
|
+
prefix: 'log',
|
|
307
|
+
strategy: 'unsafe-cast',
|
|
308
|
+
});
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
### Replace `BoxRef` with `Box<bytes>`
|
|
312
|
+
|
|
313
|
+
**BEFORE - Beta**
|
|
314
|
+
|
|
315
|
+
```ts
|
|
316
|
+
import { BoxRef, Bytes } from '@algorandfoundation/algorand-typescript';
|
|
317
|
+
|
|
318
|
+
const box = BoxRef({ key: 'test_key' });
|
|
319
|
+
box.create({ size: 32768 });
|
|
320
|
+
box.put(Bytes('FOO'));
|
|
321
|
+
box.resize(Uint64(6));
|
|
322
|
+
const extracted = box.extract(0, 3);
|
|
323
|
+
box.resize(extracted.size);
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
**AFTER - 1.0**
|
|
327
|
+
|
|
328
|
+
```ts
|
|
329
|
+
import { Box, Bytes, bytes } from '@algorandfoundation/algorand-typescript';
|
|
330
|
+
|
|
331
|
+
const box = Box<bytes>({ key: 'test_key' });
|
|
332
|
+
box.create({ size: 32768 });
|
|
333
|
+
box.value = Bytes('FOO');
|
|
334
|
+
box.resize(Uint64(6));
|
|
335
|
+
const extracted = box.extract(Uint64(0), Uint64(3));
|
|
336
|
+
box.resize(extracted.length);
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
### Replace `.native` property
|
|
340
|
+
|
|
341
|
+
**BEFORE - Beta**
|
|
342
|
+
|
|
343
|
+
```ts
|
|
344
|
+
const z = new arc4.UintN8(n);
|
|
345
|
+
const z_native = z.native;
|
|
346
|
+
|
|
347
|
+
const a = new arc4.UintN128(b);
|
|
348
|
+
const a_native = a.native;
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
**AFTER - 1.0**
|
|
352
|
+
|
|
353
|
+
```ts
|
|
354
|
+
const z = new arc4.Uint<8>(n);
|
|
355
|
+
const z_native = z.asUint64(); // For types ≤64 bits
|
|
356
|
+
|
|
357
|
+
const a = new arc4.Uint<128>(b);
|
|
358
|
+
const a_native = a.asBigUint(); // For types >64 bits
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
## New Features
|
|
362
|
+
|
|
363
|
+
### Native mutable objects
|
|
364
|
+
|
|
365
|
+
```ts
|
|
366
|
+
type Point = { x: uint64; y: uint64 };
|
|
367
|
+
const p: Point = { x: 1, y: 2 };
|
|
368
|
+
p.x = 3;
|
|
369
|
+
p.y = 4;
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
### Native mutable arrays
|
|
373
|
+
|
|
374
|
+
```ts
|
|
375
|
+
const a: uint64[] = [1, 2, 3];
|
|
376
|
+
a[0] = 10;
|
|
377
|
+
a.push(4);
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
### FixedArray type
|
|
381
|
+
|
|
382
|
+
```ts
|
|
383
|
+
const x = new FixedArray<uint64, 4>(1, 2, 3, 4);
|
|
384
|
+
x[0] = 0;
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
### Fixed-size bytes
|
|
388
|
+
|
|
389
|
+
```ts
|
|
390
|
+
snapshotPublicKey = GlobalState<bytes<32>>();
|
|
391
|
+
const fromUtf8 = Bytes('abc', { length: 3 });
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
### Number and bigint const literals
|
|
395
|
+
|
|
396
|
+
```ts
|
|
397
|
+
const x = 123;
|
|
398
|
+
const y = x * 500;
|
|
399
|
+
const a = 2n ** 128n;
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
### Tuples in storage
|
|
403
|
+
|
|
404
|
+
```ts
|
|
405
|
+
boxA = Box<[string, bytes]>({ key: Bytes('A') });
|
|
406
|
+
boxA.value = ['Hello', Bytes('World')];
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
### Composite box map keys
|
|
410
|
+
|
|
411
|
+
```ts
|
|
412
|
+
boxMap = BoxMap<{ a: uint64; b: uint64 }, string>({ keyPrefix: '' });
|
|
413
|
+
boxMap({ a: 1, b: 2 }).value = 'test';
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
### Dynamic inner transaction composition
|
|
417
|
+
|
|
418
|
+
```ts
|
|
419
|
+
itxnCompose.begin(payFields);
|
|
420
|
+
for (const i of urange(1, addresses.length)) {
|
|
421
|
+
itxnCompose.next({ ...payFields, receiver: addresses[i].bytes });
|
|
422
|
+
}
|
|
423
|
+
itxnCompose.submit();
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
### `not` expressions in match
|
|
427
|
+
|
|
428
|
+
```ts
|
|
429
|
+
assertMatch(xObj, { x: { not: 3 } }, 'x should not be 3');
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
### `@readonly` decorator
|
|
433
|
+
|
|
434
|
+
```ts
|
|
435
|
+
@readonly
|
|
436
|
+
public getPreconditions(signature: bytes<64>): VotingPreconditions {
|
|
437
|
+
// ...
|
|
438
|
+
}
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
### `validateEncoding` option
|
|
442
|
+
|
|
443
|
+
```ts
|
|
444
|
+
@abimethod({ validateEncoding: 'args' })
|
|
445
|
+
withValidation(value: bytes<32>) {
|
|
446
|
+
return value.length;
|
|
447
|
+
}
|
|
448
|
+
```
|