UNPKG

vasku

Version:

TVM-Solidity contract development framework

31 lines (24 loc) 639 B
import { B } from '../../../utils/suffixes' export type SendOptions = { to: string value: string } export function validate (options: SendOptions): { to: string value: bigint } { if (!isAddress(options.to)) throw new Error(`Invalid address: "${options.to}"`) if (!isFloat(options.value)) throw new Error(`Invalid value: "${options.value}"`) return { to: options.to, value: BigInt(parseFloat(options.value) * B) } } function isAddress (address: string): boolean { return /^\d:[0-9a-fA-F]{64}$/.test(address) } function isFloat (number: string): boolean { return !Number.isNaN(parseFloat(number)) }