Press n or j to go to the next uncovered block, b, p or k for the previous block.
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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 24073x 24073x 24073x 3676x 1744x 24073x 1716x 24073x 1696x 24073x 3646x 3646x 1704x 24073x 13339x 13339x 24073x 3869x 3869x 3869x 3869x 3869x 3869x 3868x 3869x 3868x 3868x 3868x 9470x 9470x 24073x 3517x 3517x 3517x 3517x 3517x 3517x 1754x 1754x 5953x 5953x 24073x 5952x 5952x 5952x 5952x 5952x 5952x 11972x 5952x 5952x 5952x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 4035x 4035x 4035x 4035x 12101x 4035x 4035x 4035x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2016x 2016x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2016x 2016x | import { getAddress } from "../address/index.js"; import { keccak256 as _keccak256, sha256 as _sha256 } from "../crypto/index.js"; import { concat, dataLength, getBytes, hexlify, toBeArray, toTwos, toUtf8Bytes, zeroPadBytes, zeroPadValue, assertArgument } from "../utils/index.js"; const regexBytes = new RegExp("^bytes([0-9]+)$"); const regexNumber = new RegExp("^(u?int)([0-9]*)$"); const regexArray = new RegExp("^(.*)\\[([0-9]*)\\]$"); function _pack(type: string, value: any, isArray?: boolean): Uint8Array { switch(type) { case "address": if (isArray) { return getBytes(zeroPadValue(value, 32)); } return getBytes(getAddress(value)); case "string": return toUtf8Bytes(value); case "bytes": return getBytes(value); case "bool": value = (!!value ? "0x01": "0x00"); if (isArray) { return getBytes(zeroPadValue(value, 32)); } return getBytes(value); } let match = type.match(regexNumber); if (match) { let signed = (match[1] === "int"); let size = parseInt(match[2] || "256") assertArgument((!match[2] || match[2] === String(size)) && (size % 8 === 0) && size !== 0 && size <= 256, "invalid number type", "type", type); if (isArray) { size = 256; } if (signed) { value = toTwos(value, size); } return getBytes(zeroPadValue(toBeArray(value), size / 8)); } match = type.match(regexBytes); if (match) { const size = parseInt(match[1]); assertArgument(String(size) === match[1] && size !== 0 && size <= 32, "invalid bytes type", "type", type); assertArgument(dataLength(value) === size, `invalid value for ${ type }`, "value", value); if (isArray) { return getBytes(zeroPadBytes(value, 32)); } return value; } match = type.match(regexArray); if (match && Array.isArray(value)) { const baseType = match[1]; const count = parseInt(match[2] || String(value.length)); assertArgument(count === value.length, `invalid array length for ${ type }`, "value", value); const result: Array<Uint8Array> = []; value.forEach(function(value) { result.push(_pack(baseType, value, true)); }); return getBytes(concat(result)); } assertArgument(false, "invalid type", "type", type) } // @TODO: Array Enum /** * Computes the [[link-solc-packed]] representation of %%values%% * respectively to their %%types%%. * * @example: * addr = "0x8ba1f109551bd432803012645ac136ddd64dba72" * solidityPacked([ "address", "uint" ], [ addr, 45 ]); * //_result: */ export function solidityPacked(types: ReadonlyArray<string>, values: ReadonlyArray<any>): string { assertArgument(types.length === values.length, "wrong number of values; expected ${ types.length }", "values", values); const tight: Array<Uint8Array> = []; types.forEach(function(type, index) { tight.push(_pack(type, values[index])); }); return hexlify(concat(tight)); } /** * Computes the [[link-solc-packed]] [[keccak256]] hash of %%values%% * respectively to their %%types%%. * * @example: * addr = "0x8ba1f109551bd432803012645ac136ddd64dba72" * solidityPackedKeccak256([ "address", "uint" ], [ addr, 45 ]); * //_result: */ export function solidityPackedKeccak256(types: ReadonlyArray<string>, values: ReadonlyArray<any>): string { return _keccak256(solidityPacked(types, values)); } /** * Computes the [[link-solc-packed]] [[sha256]] hash of %%values%% * respectively to their %%types%%. * * @example: * addr = "0x8ba1f109551bd432803012645ac136ddd64dba72" * solidityPackedSha256([ "address", "uint" ], [ addr, 45 ]); * //_result: */ export function solidityPackedSha256(types: ReadonlyArray<string>, values: ReadonlyArray<any>): string { return _sha256(solidityPacked(types, values)); } |