|
1 | 1 | import type { biguint, BigUintCompat, bytes, BytesCompat, uint64, Uint64Compat } from '@algorandfoundation/algorand-typescript' |
2 | 2 | import { encodingUtil } from '@algorandfoundation/puya-ts' |
3 | 3 | import { avmError, AvmError, avmInvariant, CodeError, InternalError } from '../errors' |
4 | | -import type { DeliberateAny } from '../typescript-helpers' |
5 | 4 | import { nameOfType } from '../typescript-helpers' |
6 | 5 | import { base32ToUint8Array } from './base-32' |
7 | 6 |
|
@@ -88,97 +87,6 @@ export function BigUint(v?: BigUintCompat | string): biguint { |
88 | 87 | return BigUintCls.fromCompat(v).asAlgoTs() |
89 | 88 | } |
90 | 89 |
|
91 | | -/** |
92 | | - * @internal |
93 | | - * Create a byte array from a string interpolation template and compatible replacements |
94 | | - * @param value * |
95 | | - * @param replacements * |
96 | | - */ |
97 | | -export function FixedBytes<TLength extends uint64 = uint64>( |
98 | | - length: TLength, |
99 | | - value: TemplateStringsArray, |
100 | | - ...replacements: BytesCompat[] |
101 | | -): bytes<TLength> |
102 | | -/** |
103 | | - * @internal |
104 | | - * Create a byte array from a utf8 string |
105 | | - */ |
106 | | -export function FixedBytes<TLength extends uint64 = uint64>(length: TLength, value: string): bytes<TLength> |
107 | | -/** |
108 | | - * @internal |
109 | | - * No op, returns the provided byte array. |
110 | | - */ |
111 | | -export function FixedBytes<TLength extends uint64 = uint64>(length: TLength, value: bytes): bytes<TLength> |
112 | | -/** |
113 | | - * @internal |
114 | | - * Create a byte array from a biguint value encoded as a variable length big-endian number * |
115 | | - */ |
116 | | -export function FixedBytes<TLength extends uint64 = uint64>(length: TLength, value: biguint): bytes<TLength> |
117 | | -/** |
118 | | - * @internal |
119 | | - * Create a byte array from a uint64 value encoded as a fixed length 64-bit number |
120 | | - */ |
121 | | -export function FixedBytes<TLength extends uint64 = uint64>(length: TLength, value: uint64): bytes<TLength> |
122 | | -/** |
123 | | - * @internal |
124 | | - * Create a byte array from an Iterable<uint64> where each item is interpreted as a single byte and must be between 0 and 255 inclusively |
125 | | - */ |
126 | | -export function FixedBytes<TLength extends uint64 = uint64>(length: TLength, value: Iterable<uint64>): bytes<TLength> |
127 | | -/** |
128 | | - * @internal |
129 | | - * Create an empty byte array |
130 | | - */ |
131 | | -export function FixedBytes<TLength extends uint64 = uint64>(length: TLength): bytes<TLength> |
132 | | -export function FixedBytes<TLength extends uint64 = uint64>( |
133 | | - length: TLength, |
134 | | - value?: BytesCompat | TemplateStringsArray | biguint | uint64 | Iterable<number>, |
135 | | - ...replacements: BytesCompat[] |
136 | | -): bytes<TLength> { |
137 | | - const result = Bytes((value ?? new Uint8Array(length)) as DeliberateAny, ...replacements) |
138 | | - if (length && length !== getNumber(result.length)) { |
139 | | - throw new CodeError(`Invalid bytes constant length of ${result.length}, expected ${length}`) |
140 | | - } |
141 | | - return result.toFixed({ length }) |
142 | | -} |
143 | | - |
144 | | -/** |
145 | | - * @internal |
146 | | - * Create a new bytes value from a hexadecimal encoded string |
147 | | - * @param hex |
148 | | - */ |
149 | | -FixedBytes.fromHex = <TLength extends uint64 = uint64>(length: TLength, hex: string): bytes<TLength> => { |
150 | | - const result = BytesCls.fromHex(hex).asAlgoTs() |
151 | | - if (length && length !== getNumber(result.length)) { |
152 | | - throw new CodeError(`Expected decoded bytes value of length ${length}, received ${result.length}`) |
153 | | - } |
154 | | - return result.toFixed({ length }) |
155 | | -} |
156 | | -/** |
157 | | - * @internal |
158 | | - * Create a new bytes value from a base 64 encoded string |
159 | | - * @param b64 |
160 | | - */ |
161 | | -FixedBytes.fromBase64 = <TLength extends uint64 = uint64>(length: TLength, b64: string): bytes<TLength> => { |
162 | | - const result = BytesCls.fromBase64(b64).asAlgoTs() |
163 | | - if (length && length !== getNumber(result.length)) { |
164 | | - throw new CodeError(`Expected decoded bytes value of length ${length}, received ${result.length}`) |
165 | | - } |
166 | | - return result.toFixed({ length }) |
167 | | -} |
168 | | - |
169 | | -/** |
170 | | - * @internal |
171 | | - * Create a new bytes value from a base 32 encoded string |
172 | | - * @param b32 |
173 | | - */ |
174 | | -FixedBytes.fromBase32 = <TLength extends uint64 = uint64>(length: TLength, b32: string): bytes<TLength> => { |
175 | | - const result = BytesCls.fromBase32(b32).asAlgoTs() |
176 | | - if (length && length !== getNumber(result.length)) { |
177 | | - throw new CodeError(`Expected decoded bytes value of length ${length}, received ${result.length}`) |
178 | | - } |
179 | | - return result.toFixed({ length }) |
180 | | -} |
181 | | - |
182 | 90 | /** |
183 | 91 | * @internal |
184 | 92 | * Create a byte array from a string interpolation template and compatible replacements |
|
0 commit comments