MCPcopy Create free account
hub / github.com/circlefin/arc-node / toBytes32

Function toBytes32

scripts/genesis/types.ts:118–130  ·  view source on GitHub ↗
(value: boolean | number | bigint)

Source from the content-addressed store, hash-verified

116 * @returns The bytes32 value.
117 */
118export 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
132export const slotIndex = (slotIndex: bigint): Bytes32 => toBytes32(slotIndex)
133

Callers 10

buildGenesisFunction · 0.90
verifyBatchEventsFunction · 0.90
verifySuccessFunction · 0.90
slotIndexFunction · 0.85

Calls

no outgoing calls

Tested by 2

verifyBatchEventsFunction · 0.72
verifySuccessFunction · 0.72