From 092615f58a19994b6ba01dfb30b9ba0f6ad2902b Mon Sep 17 00:00:00 2001 From: jxom <7336481+jxom@users.noreply.github.com> Date: Thu, 5 Dec 2024 06:39:53 +0100 Subject: [PATCH] feat: sync 7739 (#3096) feat: up 7739 --- .changeset/ten-rockets-repeat.md | 5 +++++ contracts/lib/solady | 2 +- .../implementations/toSoladySmartAccount.ts | 8 -------- .../erc7739/actions/signTypedData.test.ts | 4 ---- .../erc7739/actions/signTypedData.ts | 18 ++---------------- .../erc7739/utils/hashTypedData.test.ts | 8 +------- .../erc7739/utils/hashTypedData.ts | 16 +--------------- 7 files changed, 10 insertions(+), 51 deletions(-) create mode 100644 .changeset/ten-rockets-repeat.md diff --git a/.changeset/ten-rockets-repeat.md b/.changeset/ten-rockets-repeat.md new file mode 100644 index 0000000000..46df295640 --- /dev/null +++ b/.changeset/ten-rockets-repeat.md @@ -0,0 +1,5 @@ +--- +"viem": patch +--- + +**Experimental:** Synced ERC-7739 extension to latest spec. diff --git a/contracts/lib/solady b/contracts/lib/solady index 8200a70e8d..86b922d52c 160000 --- a/contracts/lib/solady +++ b/contracts/lib/solady @@ -1 +1 @@ -Subproject commit 8200a70e8dc2a77ecb074fc2e99a2a0d36547522 +Subproject commit 86b922d52cb3e90d8e40c5c16540d7f452456743 diff --git a/src/account-abstraction/accounts/implementations/toSoladySmartAccount.ts b/src/account-abstraction/accounts/implementations/toSoladySmartAccount.ts index 22dbfc9ec6..8a54851789 100644 --- a/src/account-abstraction/accounts/implementations/toSoladySmartAccount.ts +++ b/src/account-abstraction/accounts/implementations/toSoladySmartAccount.ts @@ -298,10 +298,6 @@ const abi = [ name: 'eip712Domain', inputs: [], outputs: [ - { - name: 'fields', - type: 'bytes1', - }, { name: 'name', type: 'string', @@ -322,10 +318,6 @@ const abi = [ name: 'salt', type: 'bytes32', }, - { - name: 'extensions', - type: 'uint256[]', - }, ], stateMutability: 'view', }, diff --git a/src/experimental/erc7739/actions/signTypedData.test.ts b/src/experimental/erc7739/actions/signTypedData.test.ts index 5ba1c758a5..7009c87ad1 100644 --- a/src/experimental/erc7739/actions/signTypedData.test.ts +++ b/src/experimental/erc7739/actions/signTypedData.test.ts @@ -99,8 +99,6 @@ describe('args: verifierDomain', () => { salt: '0x0000000000000000000000000000000000000000000000000000000000000000', verifyingContract: verifier, }, - fields: '0x0f', - extensions: [], primaryType: 'Mail', }) @@ -124,8 +122,6 @@ describe('args: verifierDomain', () => { salt: '0x0000000000000000000000000000000000000000000000000000000000000000', verifyingContract: verifier, }, - fields: '0x0f', - extensions: [], primaryType: 'Mail', }) diff --git a/src/experimental/erc7739/actions/signTypedData.ts b/src/experimental/erc7739/actions/signTypedData.ts index ca1a30cafd..de1f2b8500 100644 --- a/src/experimental/erc7739/actions/signTypedData.ts +++ b/src/experimental/erc7739/actions/signTypedData.ts @@ -37,8 +37,6 @@ export type SignTypedDataParameters< TypedDataDomain, 'chainId' | 'name' | 'verifyingContract' | 'salt' | 'version' > - fields: Hex - extensions: readonly bigint[] verifier?: undefined } | (GetVerifierParameter & { @@ -48,8 +46,6 @@ export type SignTypedDataParameters< 'chainId' | 'name' | 'verifyingContract' | 'salt' | 'version' > | undefined - fields?: Hex | undefined - extensions?: readonly bigint[] | undefined }) > @@ -189,16 +185,10 @@ export async function signTypedData< const account = parseAccount(account_!) // Retrieve account EIP712 domain. - const { - domain: verifierDomain, - fields, - extensions, - } = await (async () => { - if (parameters.verifierDomain && parameters.fields && parameters.extensions) + const { domain: verifierDomain } = await (async () => { + if (parameters.verifierDomain) return { domain: parameters.verifierDomain, - fields: parameters.fields, - extensions: parameters.extensions, } return getAction( client, @@ -223,20 +213,16 @@ export async function signTypedData< ...types, TypedDataSign: [ { name: 'contents', type: primaryType }, - { name: 'fields', type: 'bytes1' }, { name: 'name', type: 'string' }, { name: 'version', type: 'string' }, { name: 'chainId', type: 'uint256' }, { name: 'verifyingContract', type: 'address' }, { name: 'salt', type: 'bytes32' }, - { name: 'extensions', type: 'uint256[]' }, ], }, primaryType: 'TypedDataSign', message: { contents: message as any, - fields, - extensions, ...(verifierDomain as any), }, }) diff --git a/src/experimental/erc7739/utils/hashTypedData.test.ts b/src/experimental/erc7739/utils/hashTypedData.test.ts index 88c6beec72..3189917277 100644 --- a/src/experimental/erc7739/utils/hashTypedData.test.ts +++ b/src/experimental/erc7739/utils/hashTypedData.test.ts @@ -35,18 +35,12 @@ beforeAll(async () => { }) test('default', async () => { - const { - domain: verifierDomain, - extensions, - fields, - } = await getEip712Domain(client, { + const { domain: verifierDomain } = await getEip712Domain(client, { address: verifier, }) const hash = hashTypedData({ ...typedData.complex, - extensions, - fields, verifierDomain, primaryType: 'Mail', }) diff --git a/src/experimental/erc7739/utils/hashTypedData.ts b/src/experimental/erc7739/utils/hashTypedData.ts index d4180cfebd..2363add59d 100644 --- a/src/experimental/erc7739/utils/hashTypedData.ts +++ b/src/experimental/erc7739/utils/hashTypedData.ts @@ -14,8 +14,6 @@ export type HashTypedDataParameters< /// primaryTypes = typedData extends TypedData ? keyof typedData : string, > = TypedDataDefinition & { - fields: Hex - extensions: readonly bigint[] verifierDomain: RequiredBy< TypedDataDomain, 'chainId' | 'name' | 'verifyingContract' | 'version' @@ -76,15 +74,7 @@ export function hashTypedData< >( parameters: HashTypedDataParameters, ): HashTypedDataReturnType { - const { - domain, - extensions, - fields, - message, - primaryType, - types, - verifierDomain, - } = parameters + const { domain, message, primaryType, types, verifierDomain } = parameters return hashTypedData_({ domain: domain as any, @@ -92,20 +82,16 @@ export function hashTypedData< ...types, TypedDataSign: [ { name: 'contents', type: primaryType }, - { name: 'fields', type: 'bytes1' }, { name: 'name', type: 'string' }, { name: 'version', type: 'string' }, { name: 'chainId', type: 'uint256' }, { name: 'verifyingContract', type: 'address' }, { name: 'salt', type: 'bytes32' }, - { name: 'extensions', type: 'uint256[]' }, ], }, primaryType: 'TypedDataSign', message: { contents: message as any, - fields, - extensions, ...(verifierDomain as any), }, })