|
1 | 1 | import { bytes, internal, uint64 } from '@algorandfoundation/algorand-typescript' |
2 | 2 | import { lazyContext } from '../context-helpers/internal-context' |
3 | 3 |
|
| 4 | +export const gloadUint64: internal.opTypes.GloadUint64Type = ( |
| 5 | + a: internal.primitives.StubUint64Compat, |
| 6 | + b: internal.primitives.StubUint64Compat, |
| 7 | +): uint64 => { |
| 8 | + const txn = lazyContext.activeGroup.getTransaction(a) |
| 9 | + const result = txn.getScratchSlot(b) |
| 10 | + if (result instanceof internal.primitives.Uint64Cls) { |
| 11 | + return result.asAlgoTs() |
| 12 | + } |
| 13 | + throw new internal.errors.InternalError('invalid scratch slot type') |
| 14 | +} |
| 15 | + |
| 16 | +export const gloadBytes: internal.opTypes.GloadBytesType = ( |
| 17 | + a: internal.primitives.StubUint64Compat, |
| 18 | + b: internal.primitives.StubUint64Compat, |
| 19 | +): bytes => { |
| 20 | + const txn = lazyContext.activeGroup.getTransaction(a) |
| 21 | + const result = txn.getScratchSlot(b) |
| 22 | + if (result instanceof internal.primitives.BytesCls) { |
| 23 | + return result.asAlgoTs() |
| 24 | + } |
| 25 | + throw new internal.errors.InternalError('invalid scratch slot type') |
| 26 | +} |
| 27 | + |
4 | 28 | export const Scratch: internal.opTypes.ScratchType = { |
5 | 29 | loadBytes: function (a: internal.primitives.StubUint64Compat): bytes { |
6 | 30 | const result = lazyContext.activeGroup.activeTransaction.getScratchSlot(a) |
7 | 31 | if (result instanceof internal.primitives.BytesCls) { |
8 | 32 | return result as bytes |
9 | 33 | } |
10 | | - throw new internal.errors.InternalError('Invalid scratch slot type') |
| 34 | + throw new internal.errors.InternalError('invalid scratch slot type') |
11 | 35 | }, |
12 | 36 | loadUint64: function (a: internal.primitives.StubUint64Compat): uint64 { |
13 | 37 | const result = lazyContext.activeGroup.activeTransaction.getScratchSlot(a) |
14 | 38 | if (result instanceof internal.primitives.Uint64Cls) { |
15 | 39 | return result as uint64 |
16 | 40 | } |
17 | | - throw new internal.errors.InternalError('Invalid scratch slot type') |
| 41 | + throw new internal.errors.InternalError('invalid scratch slot type') |
18 | 42 | }, |
19 | 43 | store: function ( |
20 | 44 | a: internal.primitives.StubUint64Compat, |
|
0 commit comments