Skip to content

Commit 900b226

Browse files
committed
UintN -> Uint
1 parent 7c775fd commit 900b226

File tree

1 file changed

+32
-36
lines changed

1 file changed

+32
-36
lines changed

docs/tealscript-migration.md

Lines changed: 32 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@ This document is up-to-date as of TEALScript v0.107.0 and Algorand TypeScript v1
44

55
## Migration Table
66

7-
| TEALScript | Algorand TypeScript | Notes |
8-
| --- | --- | --- |
9-
| JS Object | JS Object | Algorand TypeScript does not yet support nested dynamic types in JavaScript objects. TEALScript allows one level of nesting. For nested dynamic types, see [Objects](#objects) |
10-
| JS Array | JS Array | Algorand TypeScript does not yet support nested dynamic types in JavaScript arrays. TEALScript allows one level ofnesting. For nested dynamic types, see [Arrays](#arrays) |
11-
| `EventLogger` | [`emit`](https://dev.algorand.co/reference/algorand-typescript/api-reference/index/functions/emit) ||
12-
| `BoxKey` | [`Box`](TOOD: link to box docs) | The crate method has new parameters as shown [here](TODO: link to box section) |
13-
| `Txn` | `Transaction` ||
14-
| `PayTxn` | `PaymentTxn` ||
15-
| `AppCallTxn` | `ApplicationCallTxn` ||
16-
| `KeyRegTxn` | `KeyRegistrationTxn` ||
17-
| `OnCompletion` | `OnCompleteAction` ||
18-
| Eliptic curve opcodes (i.e `ecAdd`) | Now under [`ElipticCurve`](TODO: link to EC docs) (i.e. `ElipticCurve.add`) ||
19-
| `GlobalStateKey` | `GlobalState` ||
20-
| `LocalStateKey` | `LocalState` ||
21-
| `GlobalStateMap` | Not yet supported ||
22-
| `LocalStateMap` | Not yet supported ||
23-
| `isOptedInToApp` and `isOptedInToAsset` | [`isOptedIn`](TODO: link to isOptedInDocs) ||
24-
| `this.txn` | [`Txn`](TOOD: link to Txn docs) ||
25-
| `verify...Txn` | `assertMatch` | `assertMatch` can be used on any txn type or any object |
26-
| `globals` | [`Global`](TODO: link to Global docs) ||
27-
| `StaticArray` | `FixedArray` | May not cover all cases. See the array section for more details |
7+
| TEALScript | Algorand TypeScript | Notes |
8+
| --------------------------------------- | -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
9+
| JS Object | JS Object | Algorand TypeScript does not yet support nested dynamic types in JavaScript objects. TEALScript allows one level of nesting. For nested dynamic types, see [Objects](#objects) |
10+
| JS Array | JS Array | Algorand TypeScript does not yet support nested dynamic types in JavaScript arrays. TEALScript allows one level ofnesting. For nested dynamic types, see [Arrays](#arrays) |
11+
| `EventLogger` | [`emit`](https://dev.algorand.co/reference/algorand-typescript/api-reference/index/functions/emit) | |
12+
| `BoxKey` | \[`Box`\](TOOD: link to box docs) | The crate method has new parameters as shown \[here\](TODO: link to box section) |
13+
| `Txn` | `Transaction` | |
14+
| `PayTxn` | `PaymentTxn` | |
15+
| `AppCallTxn` | `ApplicationCallTxn` | |
16+
| `KeyRegTxn` | `KeyRegistrationTxn` | |
17+
| `OnCompletion` | `OnCompleteAction` | |
18+
| Eliptic curve opcodes (i.e `ecAdd`) | Now under \[`ElipticCurve`\](TODO: link to EC docs) (i.e. `ElipticCurve.add`) | |
19+
| `GlobalStateKey` | `GlobalState` | |
20+
| `LocalStateKey` | `LocalState` | |
21+
| `GlobalStateMap` | Not yet supported | |
22+
| `LocalStateMap` | Not yet supported | |
23+
| `isOptedInToApp` and `isOptedInToAsset` | \[`isOptedIn`\](TODO: link to isOptedInDocs) | |
24+
| `this.txn` | \[`Txn`\](TOOD: link to Txn docs) | |
25+
| `verify...Txn` | `assertMatch` | `assertMatch` can be used on any txn type or any object |
26+
| `globals` | \[`Global`\](TODO: link to Global docs) | |
27+
| `StaticArray` | `FixedArray` | May not cover all cases. See the array section for more details |
2828

2929
## Migrations
3030

@@ -236,10 +236,6 @@ const result = compiled.call.greet({
236236
assert(result === 'hello world')
237237
```
238238

239-
### Reference Types
240-
241-
TODO: For 1.0 we will probably have similar types to TEALScript (i.e. `AppID` that is an ABI `uint64`) but exact API is TBD
242-
243239
### Compiled Contract Information
244240

245241
TEALScript contracts have static methods for getting the contract programs and schema. In Algorand TypeScript, you must first explicitly
@@ -383,10 +379,10 @@ add(a: uint64, b: uint64): uint64 {
383379
}
384380
```
385381

386-
#### UintN types
382+
#### Uint types
387383

388384
TEALScript supports typed numeric literals for most common uint types, such as `uint8`, `uint16`, `uint256`, etc. In Algorand TypeScript,
389-
the UintN constructors must be used.
385+
the Uint constructors must be used.
390386

391387
##### TEALScript
392388

@@ -401,19 +397,19 @@ addOne(n: uint256): uint256 {
401397
##### Algorand TypeScript
402398

403399
```ts
404-
addOne(n: UintN256): UintN256 {
405-
// Need to explicitly use UintN256 constructor to get uint256 and use bigint to perform arithmetic
400+
addOne(n: Uint256): Uint256 {
401+
// Need to explicitly use Uint256 constructor to get uint256 and use bigint to perform arithmetic
406402
const one = 1n;
407-
const sum = new UintN256(n.native + one + one);
403+
const sum = new Uint256(n.native + one + one);
408404
return sum;
409405
}
410406
```
411407

412408
#### Math and Overflows
413409

414410
In TEALScript, overflow checks do not occur until the value is encoded (returned, logged, put into an array/object). In Algorand TypeScript,
415-
overflow checking occurs whenever the `UintN` constructor is used. Since overflow checking is fairly expensive, it is recommended to not use
416-
the `UintN` type until it needs to be encoded.
411+
overflow checking occurs whenever the `Uint` constructor is used. Since overflow checking is fairly expensive, it is recommended to not use
412+
the `Uint` type until it needs to be encoded.
417413

418414
##### TEALScript
419415

@@ -431,12 +427,12 @@ addToNumber(n: uint8) {
431427
##### Algorand TypeScript
432428

433429
```ts
434-
addToNumber(n: UintN8) {
430+
addToNumber(n: Uint8) {
435431
// Use biguint for intermediate values which can go up to u512
436432
const x: biguint = 255
437433
const sum: biguint = BigUint(n.bytes) + x
438434

439-
return new UintN8(sum - x)
435+
return new Uint8(sum - x)
440436
}
441437
```
442438

@@ -456,8 +452,8 @@ convertNumber(n: uint64): uint8 {
456452
##### Algorand TypeScript
457453

458454
```ts
459-
convertNumber(n: uint64): UintN8 {
460-
return new UintN8(n)
455+
convertNumber(n: uint64): Uint8 {
456+
return new Uint8(n)
461457
}
462458
```
463459

0 commit comments

Comments
 (0)