From a9330df67afad5662d4561d0b59f7c2008ec8a88 Mon Sep 17 00:00:00 2001 From: Meet Mangukiya Date: Thu, 16 May 2024 16:47:33 +0530 Subject: [PATCH] ethers -> ethers_v6, some fixes --- package.json | 2 +- ts/index.ts | 22 +++++++++++----------- ts/testUtil.ts | 2 +- yarn.lock | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 2560b47..c47d20c 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "build": "tsc" }, "dependencies": { - "ethers": "^6.12.1", + "ethers_v6": "npm:ethers@^6.12.1", "typescript": "^5.4.5" }, "devDependencies": { diff --git a/ts/index.ts b/ts/index.ts index 187d8b8..fa593a8 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -5,21 +5,17 @@ import { solidityPackedKeccak256, TypedDataDomain, TypedDataEncoder, -} from 'ethers'; +} from 'ethers_v6'; import { FACTORY_ABI, PROXY_CREATION_CODE, SHED_ABI } from './constants'; -export const computeProxyAddress = (user: string) => { - getCreate2Address; -}; - -interface ISdkOptions { +export interface ISdkOptions { factoryAddress: string; proxyCreationCode?: string; implementationAddress: string; chainId: number; } -interface ICall { +export interface ICall { target: string; value: bigint; callData: string; @@ -27,7 +23,7 @@ interface ICall { isDelegateCall: boolean; } -interface IExecuteHooks { +export interface IExecuteHooks { calls: ICall[]; nonce: string; deadline: bigint; @@ -35,13 +31,16 @@ interface IExecuteHooks { const ABI_CODER = new ethers.AbiCoder(); -const COW_SHED_712_TYPES = { +const DOMAIN_TYPE = { EIP712Domain: [ { type: 'string', name: 'name' }, { type: 'string', name: 'version' }, { type: 'uint256', name: 'chainId' }, { type: 'address', name: 'verifyingContract' }, ], +}; + +const COW_SHED_712_TYPES = { ExecuteHooks: [ { type: 'Call[]', name: 'calls' }, { type: 'bytes32', name: 'nonce' }, @@ -79,8 +78,9 @@ export class CowShedSdk { } computeDomainSeparator(proxy: string) { - return TYPED_DATA_ENCODER.hashStruct( + return TypedDataEncoder.hashStruct( 'EIP712Domain', + DOMAIN_TYPE, this._getDomain(proxy) ); } @@ -139,7 +139,7 @@ export class CowShedSdk { } static encodeEOASignature(r: bigint, s: bigint, v: number) { - return solidityPacked(['bytes32', 'bytes32', 'uint8'], [r, s, v]); + return solidityPacked(['uint', 'uint', 'uint8'], [r, s, v]); } private _hashToSign( diff --git a/ts/testUtil.ts b/ts/testUtil.ts index 9922429..e07779b 100644 --- a/ts/testUtil.ts +++ b/ts/testUtil.ts @@ -1,4 +1,4 @@ -import { TypedDataEncoder, ZeroAddress } from 'ethers'; +import { TypedDataEncoder, ZeroAddress } from 'ethers_v6'; interface ICall { target: string; diff --git a/yarn.lock b/yarn.lock index 42a47b3..c68b450 100644 --- a/yarn.lock +++ b/yarn.lock @@ -99,7 +99,7 @@ diff@^4.0.1: resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== -ethers@^6.12.1: +"ethers_v6@npm:ethers@^6.12.1": version "6.12.1" resolved "https://registry.yarnpkg.com/ethers/-/ethers-6.12.1.tgz#517ff6d66d4fd5433e38e903051da3e57c87ff37" integrity sha512-j6wcVoZf06nqEcBbDWkKg8Fp895SS96dSnTCjiXT+8vt2o02raTn4Lo9ERUuIVU5bAjoPYeA+7ytQFexFmLuVw==