|
1 | | -const immutable = require('immutable') |
2 | | - |
3 | 1 | /** |
4 | 2 | * ethereum.Value -> AssemblyScript conversions |
5 | 3 | */ |
@@ -55,29 +53,56 @@ const ETHEREUM_VALUE_TO_ASSEMBLYSCRIPT = [ |
55 | 53 |
|
56 | 54 | // Multi dimensional arrays |
57 | 55 |
|
58 | | - [/^address\[([0-9]+)?\]\[([0-9]+)?\]$/, 'Array<Array<Address>>', code => `${code}.toAddressMatrix()`], |
59 | | - [/^bool\[([0-9]+)?\]\[([0-9]+)?\]$/, 'Array<Array<boolean>>', code => `${code}.toBooleanMatrix()`], |
60 | | - [/^byte\[([0-9]+)?\]\[([0-9]+)?\]$/, 'Array<Array<Bytes>>', code => `${code}.toBytesMatrix()`], |
| 56 | + [ |
| 57 | + /^address\[([0-9]+)?\]\[([0-9]+)?\]$/, |
| 58 | + 'Array<Array<Address>>', |
| 59 | + code => `${code}.toAddressMatrix()`, |
| 60 | + ], |
| 61 | + [ |
| 62 | + /^bool\[([0-9]+)?\]\[([0-9]+)?\]$/, |
| 63 | + 'Array<Array<boolean>>', |
| 64 | + code => `${code}.toBooleanMatrix()`, |
| 65 | + ], |
| 66 | + [ |
| 67 | + /^byte\[([0-9]+)?\]\[([0-9]+)?\]$/, |
| 68 | + 'Array<Array<Bytes>>', |
| 69 | + code => `${code}.toBytesMatrix()`, |
| 70 | + ], |
61 | 71 | [ |
62 | 72 | /^bytes(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32)?\[([0-9]+)?\]\[([0-9]+)?\]$/, |
63 | 73 | 'Array<Array<Bytes>>', |
64 | 74 | code => `${code}.toBytesMatrix()`, |
65 | 75 | ], |
66 | | - [/^int(8|16|24|32)\[([0-9]+)?\]\[([0-9]+)?\]$/, 'Array<Array<i32>>', code => `${code}.toI32Matrix()`], |
67 | | - [/^uint(8|16|24)\[([0-9]+)?\]\[([0-9]+)?\]$/, 'Array<Array<i32>>', code => `${code}.toI32Matrix()`], |
68 | | - [/^uint32\[([0-9]+)?\]\[([0-9]+)?\]$/, 'Array<Array<BigInt>>', code => `${code}.toBigIntMatrix()`], |
| 76 | + [ |
| 77 | + /^int(8|16|24|32)\[([0-9]+)?\]\[([0-9]+)?\]$/, |
| 78 | + 'Array<Array<i32>>', |
| 79 | + code => `${code}.toI32Matrix()`, |
| 80 | + ], |
| 81 | + [ |
| 82 | + /^uint(8|16|24)\[([0-9]+)?\]\[([0-9]+)?\]$/, |
| 83 | + 'Array<Array<i32>>', |
| 84 | + code => `${code}.toI32Matrix()`, |
| 85 | + ], |
| 86 | + [ |
| 87 | + /^uint32\[([0-9]+)?\]\[([0-9]+)?\]$/, |
| 88 | + 'Array<Array<BigInt>>', |
| 89 | + code => `${code}.toBigIntMatrix()`, |
| 90 | + ], |
69 | 91 | [ |
70 | 92 | /^u?int(40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)\[([0-9]+)?\]\[([0-9]+)?\]$/, |
71 | 93 | 'Array<Array<BigInt>>', |
72 | 94 | code => `${code}.toBigIntMatrix()`, |
73 | 95 | ], |
74 | | - [/^string\[([0-9]+)?\]\[([0-9]+)?\]$/, 'Array<Array<string>>', code => `${code}.toStringMatrix()`], |
| 96 | + [ |
| 97 | + /^string\[([0-9]+)?\]\[([0-9]+)?\]$/, |
| 98 | + 'Array<Array<string>>', |
| 99 | + code => `${code}.toStringMatrix()`, |
| 100 | + ], |
75 | 101 | [ |
76 | 102 | /^tuple\[([0-9]+)?\]\[([0-9]+)?\]$/, |
77 | 103 | 'Array<Array<ethereum.Tuple>>', |
78 | 104 | (code, type) => `${code}.toTupleMatrix<${type}>()`, |
79 | 105 | ], |
80 | | - |
81 | 106 | ] |
82 | 107 |
|
83 | 108 | /** |
@@ -178,7 +203,7 @@ const ASSEMBLYSCRIPT_TO_ETHEREUM_VALUE = [ |
178 | 203 | /^tuple\[([0-9]+)?\]$/, |
179 | 204 | code => `ethereum.Value.fromTupleArray(${code})`, |
180 | 205 | ], |
181 | | - |
| 206 | + |
182 | 207 | // Multi dimentional arrays |
183 | 208 |
|
184 | 209 | [ |
@@ -282,9 +307,13 @@ const ASSEMBLYSCRIPT_TO_VALUE = [ |
282 | 307 | ['Array<Array<BigInt>>', '[[BigInt]]', code => `Value.fromBigIntMatrix(${code})`], |
283 | 308 | ['Array<Array<string>>', '[[String]]', code => `Value.fromStringMatrix(${code})`], |
284 | 309 | ['Array<Array<string>>', '[[ID]]', code => `Value.fromStringMatrix(${code})`], |
285 | | - ['Array<Array<BigDecimal>>', '[[BigDecimal]]', code => `Value.fromBigDecimalMatrix(${code})`], |
| 310 | + [ |
| 311 | + 'Array<Array<BigDecimal>>', |
| 312 | + '[[BigDecimal]]', |
| 313 | + code => `Value.fromBigDecimalMatrix(${code})`, |
| 314 | + ], |
286 | 315 | ['Array<Array<string>>', /\[\[.*\]\]/, code => `Value.fromStringMatrix(${code})`], |
287 | | - ['Array<Array<string | null>>', null, code => `Value.fromStringMatrix(${code})`],// is this overwriting the Array null below? |
| 316 | + ['Array<Array<string | null>>', null, code => `Value.fromStringMatrix(${code})`], // is this overwriting the Array null below? |
288 | 317 |
|
289 | 318 | // Arrays |
290 | 319 |
|
@@ -315,7 +344,7 @@ const ASSEMBLYSCRIPT_TO_VALUE = [ |
315 | 344 | /** |
316 | 345 | * Type conversions |
317 | 346 | */ |
318 | | -module.exports = immutable.fromJS({ |
| 347 | +module.exports = Object.freeze({ |
319 | 348 | ethereum: { |
320 | 349 | AssemblyScript: ETHEREUM_VALUE_TO_ASSEMBLYSCRIPT, |
321 | 350 | }, |
|
0 commit comments