From 947ed4618bf8a481f44dfa58f3bbf1acf7988d66 Mon Sep 17 00:00:00 2001 From: Vignesh Hirudayakanth Date: Thu, 12 Oct 2023 02:44:25 -0700 Subject: [PATCH] fix fee --- packages/sdk-viem/src/utils/helpers.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/sdk-viem/src/utils/helpers.ts b/packages/sdk-viem/src/utils/helpers.ts index 240b2492..30c855cb 100644 --- a/packages/sdk-viem/src/utils/helpers.ts +++ b/packages/sdk-viem/src/utils/helpers.ts @@ -1,8 +1,9 @@ -import keccak256 from 'keccak256' import { isHex, type Hex } from 'viem' +import { InvalidHexError } from '../errors' +import keccak256 from 'keccak256' -export function isHexList(list: string[]): list is Hex[] { - return list.every((value) => isHex(value)) +export function assertIsHex(value: string): asserts value is Hex { + if (!isHex(value, { strict: false })) throw new InvalidHexError({ value }) } export function getSaltAsBytes32(salt: string | number) { @@ -67,6 +68,16 @@ export async function retry( return fn() } +export function isHexList(list: string[]): list is Hex[] { + return list.every((value) => isHex(value, { strict: false })) +} + +export function assertIsHexList(list: string[]): asserts list is Hex[] { + for (const value of list) { + assertIsHex(value) + } +} + type NonEmptyArray = [T, ...T[]] export function BigIntMin(...[firstValue, ...values]: NonEmptyArray): bigint {