(value: boolean | number | bigint)
| 116 | * @returns The bytes32 value. |
| 117 | */ |
| 118 | export const toBytes32 = (value: boolean | number | bigint): Bytes32 => { |
| 119 | if (typeof value === 'boolean') { |
| 120 | return toHex(value ? 1n : 0n, { size: 32 }) |
| 121 | } |
| 122 | if (typeof value === 'number') { |
| 123 | return toHex(BigInt(value), { size: 32 }) |
| 124 | } |
| 125 | if (typeof value === 'bigint') { |
| 126 | return toHex(value, { size: 32 }) |
| 127 | } |
| 128 | // eslint-disable-next-line @typescript-eslint/restrict-template-expressions |
| 129 | throw new Error(`Invalid value: ${value}`) |
| 130 | } |
| 131 | |
| 132 | export const slotIndex = (slotIndex: bigint): Bytes32 => toBytes32(slotIndex) |
| 133 |
no outgoing calls