UNPKG

cip-23

Version:

Tiny library with utility functions that can help with signing and verifying CIP-23 based messages

23 lines (21 loc) 1.28 kB
import { encode } from './abi'; describe('encode', () => { it('encodes types and values to ABI', () => { expect(encode(['uint256', 'uint256'], [12345, 56789]).toString('hex')).toBe( '0000000000000000000000000000000000000000000000000000000000003039000000000000000000000000000000000000000000000000000000000000ddd5' ); expect(encode(['bytes32', 'string'], ['0x123456789', 'foo bar']).toString('hex')).toBe( '123456780000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000007666f6f2062617200000000000000000000000000000000000000000000000000' ); expect( encode(['bytes32', 'address'], ['0x123456789', 'cfx:aak2rra2njvd77ezwjvx04kkds9fzagfe6ku8scz91']).toString('hex') ).toBe( '12345678000000000000000000000000000000000000000000000000000000000000000000000000000000001386b4185a223ef49592233b69291bbe5a80c527' ); expect( encode(['bytes32', 'address'], ['0x123456789', '0x1386b4185a223ef49592233b69291bbe5a80c527']).toString('hex') ).toBe( '12345678000000000000000000000000000000000000000000000000000000000000000000000000000000001386b4185a223ef49592233b69291bbe5a80c527' ); }); });