Skip to content

Commit

Permalink
feat: abstract testnet 712 domain (#2709)
Browse files Browse the repository at this point in the history
* Use custom EIP712 domain for Abstract

* Fix custom data

* chore: refactor

* chore: reverT

---------

Co-authored-by: cygaar <[email protected]>
  • Loading branch information
jxom and cygaar authored Sep 9, 2024
1 parent 7bdb6f9 commit 1f5ec79
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
34 changes: 34 additions & 0 deletions src/chains/definitions/abstractTestnet.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { defineChain } from '../../utils/chain/defineChain.js'
import { chainConfig } from '../../zksync/chainConfig.js'
import type { ZksyncTransactionSerializableEIP712 } from '../../zksync/types/transaction.js'
import { transactionToMessage } from '../../zksync/utils/getEip712Domain.js'

export const abstractTestnet = /*#__PURE__*/ defineChain({
...chainConfig,
Expand All @@ -20,4 +22,36 @@ export const abstractTestnet = /*#__PURE__*/ defineChain({
},
},
testnet: true,
custom: {
getEip712Domain(transaction: ZksyncTransactionSerializableEIP712) {
const message = transactionToMessage(transaction)

return {
domain: {
name: 'Abstract', // Use 'Abstract' rather than 'zkSync'
version: '2',
chainId: transaction.chainId,
},
types: {
Transaction: [
{ name: 'txType', type: 'uint256' },
{ name: 'from', type: 'uint256' },
{ name: 'to', type: 'uint256' },
{ name: 'gasLimit', type: 'uint256' },
{ name: 'gasPerPubdataByteLimit', type: 'uint256' },
{ name: 'maxFeePerGas', type: 'uint256' },
{ name: 'maxPriorityFeePerGas', type: 'uint256' },
{ name: 'paymaster', type: 'uint256' },
{ name: 'nonce', type: 'uint256' },
{ name: 'value', type: 'uint256' },
{ name: 'data', type: 'bytes' },
{ name: 'factoryDeps', type: 'bytes32[]' },
{ name: 'paymasterInput', type: 'bytes' },
],
},
primaryType: 'Transaction',
message: message,
}
},
},
})
2 changes: 1 addition & 1 deletion src/zksync/utils/getEip712Domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const getEip712Domain: EIP712DomainFn<
//////////////////////////////////////////////////////////////////////////////
// Utilities

function transactionToMessage(
export function transactionToMessage(
transaction: ZksyncTransactionSerializableEIP712,
): ZksyncEIP712TransactionSignable {
const {
Expand Down

0 comments on commit 1f5ec79

Please sign in to comment.