UNPKG

eip-712

Version:

Tiny library with utility functions that can help with signing and verifying EIP-712 based messages

14 lines (12 loc) 749 B
import { bytesToHex } from '@noble/hashes/utils'; import { encode } from './abi'; describe('encode', () => { it('encodes types and values to ABI', () => { expect(bytesToHex(encode(['uint256', 'uint256'], [12345, 56789]))).toBe( '0000000000000000000000000000000000000000000000000000000000003039000000000000000000000000000000000000000000000000000000000000ddd5' ); expect(bytesToHex(encode(['bytes32', 'string'], ['0x123456789', 'foo bar']))).toBe( '123456780000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000007666f6f2062617200000000000000000000000000000000000000000000000000' ); }); });