1 | let patterns = Object.freeze({
|
2 | // starts with '0x'
|
3 | zeroX: /^0x/i,
|
4 | // starts with 0x or -0x
|
5 | // zeroXNegative: /^(-)?0x/i,
|
6 | zeroXNegative: /^-0x/i,
|
7 | // positive or negative hex with optional 0x
|
8 | hex: /^(-0x|0x)?[0-9a-f]{1,}$/i,
|
9 | // positive or negative hex with 0x
|
10 | hexStrict: /^(-)?0x[0-9a-f]{1,}$/i,
|
11 | // address begins with a0 (for special addresses that don't, use separate whitelist)
|
12 | address: /^(0x)?a0[0-9a-f]{62}$/i,
|
13 | hash: /^(0x)?[0-9a-f]{64}$/i,
|
14 | // starts with utf8 null characters
|
15 | utf8Null: /^(?:\u0000)*/, // eslint-disable-line no-control-regex
|
16 | // matches solidity array types int128[64] or uint128[32]
|
17 | // captures array length
|
18 | typeNArray: /^\D{3,}(?:\d{1,})?\[(\d+)\]$/,
|
19 | // match int128 or uint128
|
20 | // captures byte size
|
21 | typeN: /^\D+(\d+).*$/,
|
22 | // if you have `unit128` just get `uint`
|
23 | solidityTypeNoLength: /^([a-z]{3,})/,
|
24 | // get [8] or []
|
25 | solidityDimensions: /(\[(\d{1,})\]|\[\])/g,
|
26 | // get the 8 from [8]
|
27 | solidityDimensionDigit: /\d{1,}/,
|
28 | // matches left-padded hex strings like 0000000FF
|
29 | leadingHexZeroPadding: /^(?:00)*/,
|
30 | // similar to typeNArray but just captures array length
|
31 | arraySizeDigit: /(?:\[)(\d+)/,
|
32 | // used to check against IBAN addresses ../iban.js
|
33 | validIban: /^XE[0-9]{2}(AIO[0-9A-Z]{13}|[0-9A-Z]{30,31})$/
|
34 | })
|
35 |
|
36 | module.exports = patterns
|