UNPKG

@crtxio/abi

Version:

A tiny Solidity ABI encoder and decoder

31 lines (27 loc) 571 B
import { number } from './number'; export const getBooleanValue = value => { if (value === true || typeof value === 'string' && value === 'true' || value === 'yes') { return 1n; } return 0n; }; export const bool = { isDynamic: false, encode({ buffer, value }) { const booleanValue = getBooleanValue(value); return number.encode({ type: 'uint256', buffer, value: booleanValue }); }, decode(args) { return number.decode({ ...args, type: 'uint256' }) === 1n; } }; //# sourceMappingURL=bool.js.map