1- import {
2- type Signature ,
3- encodeDeployData ,
4- encodeFunctionData ,
5- isErc6492Signature ,
6- serializeSignature ,
7- universalSignatureValidatorAbi ,
8- universalSignatureValidatorByteCode ,
9- } from "viem" ;
1+ import * as ox__Abi from "ox/Abi" ;
2+ import * as ox__AbiConstructor from "ox/AbiConstructor" ;
3+ import * as ox__AbiFunction from "ox/AbiFunction" ;
4+ import * as ox__Signature from "ox/Signature" ;
5+ import { WrappedSignature as ox__WrappedSignature } from "ox/erc6492" ;
106import type { Chain } from "../chains/types.js" ;
117import type { ThirdwebClient } from "../client/client.js" ;
128import { type ThirdwebContract , getContract } from "../contract/contract.js" ;
@@ -20,7 +16,7 @@ import { serializeErc6492Signature } from "./serialize-erc6492-signature.js";
2016
2117export type VerifyHashParams = {
2218 hash : Hex ;
23- signature : string | Uint8Array | Signature ;
19+ signature : string | Uint8Array | ox__Signature . Signature ;
2420 address : string ;
2521 client : ThirdwebClient ;
2622 chain : Chain ;
@@ -71,7 +67,7 @@ export async function verifyHash({
7167 const signatureHex = ( ( ) => {
7268 if ( isHex ( signature ) ) return signature ;
7369 if ( typeof signature === "object" && "r" in signature && "s" in signature )
74- return serializeSignature ( signature ) ;
70+ return ox__Signature . toHex ( signature ) ;
7571 if ( signature instanceof Uint8Array ) return fromBytes ( signature , "hex" ) ;
7672 // We should never hit this but TS doesn't know that
7773 throw new Error (
@@ -85,7 +81,7 @@ export async function verifyHash({
8581 if ( ! accountFactory ) return signatureHex ;
8682
8783 // If this sigature was already wrapped for ERC-6492, carry on
88- if ( isErc6492Signature ( signatureHex ) ) return signatureHex ;
84+ if ( ox__WrappedSignature . validate ( signatureHex ) ) return signatureHex ;
8985
9086 // Otherwise, serialize the signature for ERC-6492 validation
9187 return serializeErc6492Signature ( {
@@ -100,23 +96,23 @@ export async function verifyHash({
10096 data : Hex ;
10197 } ;
10298 const zkSyncChain = await isZkSyncChain ( chain ) ;
99+ const abi = ox__Abi . from ( ox__WrappedSignature . universalSignatureValidatorAbi ) ;
103100 if ( zkSyncChain ) {
104101 // zksync chains dont support deploying code with eth_call
105102 // need to call a deployed contract instead
106103 verificationData = {
107104 to : ZKSYNC_VALIDATOR_ADDRESS ,
108- data : encodeFunctionData ( {
109- abi : universalSignatureValidatorAbi ,
110- functionName : "isValidSig" ,
111- args : [ address , hash , wrappedSignature ] ,
112- } ) ,
105+ data : ox__AbiFunction . encodeData (
106+ ox__AbiFunction . fromAbi ( abi , "isValidSig" ) ,
107+ [ address , hash , wrappedSignature ] ,
108+ ) ,
113109 } ;
114110 } else {
111+ const validatorConstructor = ox__AbiConstructor . fromAbi ( abi ) ;
115112 verificationData = {
116- data : encodeDeployData ( {
117- abi : universalSignatureValidatorAbi ,
113+ data : ox__AbiConstructor . encode ( validatorConstructor , {
118114 args : [ address , hash , wrappedSignature ] ,
119- bytecode : universalSignatureValidatorByteCode ,
115+ bytecode : ox__WrappedSignature . universalSignatureValidatorBytecode ,
120116 } ) ,
121117 } ;
122118 }
0 commit comments