Skip to content

Commit

Permalink
chore: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
jxom committed Sep 9, 2024
1 parent 685b9c4 commit 8e750c4
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 50 deletions.
79 changes: 32 additions & 47 deletions src/chains/definitions/abstractTestnet.ts
Original file line number Diff line number Diff line change
@@ -1,51 +1,7 @@
import { transactionToMessage } from '../..//zksync/utils/getEip712Domain.js'
import { defineChain } from '../../utils/chain/defineChain.js'
import { chainConfig } from '../../zksync/chainConfig.js'
import type { EIP712DomainFn } from '../../zksync/types/eip712.js'
import type {
ZksyncEIP712TransactionSignable,
ZksyncTransactionSerializable,
ZksyncTransactionSerializableEIP712,
} from '../../zksync/types/transaction.js'
import { assertEip712Transaction } from '../../zksync/utils/assertEip712Transaction.js'

export const getAbstractEip712Domain: EIP712DomainFn<
ZksyncTransactionSerializable,
ZksyncEIP712TransactionSignable
> = (transaction) => {
assertEip712Transaction(transaction)

const message = transactionToMessage(
transaction as ZksyncTransactionSerializableEIP712,
)

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,
}
}
import type { ZksyncTransactionSerializableEIP712 } from '../../zksync/types/transaction.js'
import { transactionToMessage } from '../../zksync/utils/getEip712Domain.js'

export const abstractTestnet = /*#__PURE__*/ defineChain({
...chainConfig,
Expand All @@ -67,6 +23,35 @@ export const abstractTestnet = /*#__PURE__*/ defineChain({
},
testnet: true,
custom: {
getEip712Domain: getAbstractEip712Domain, // Use Abstract's specific EIP712 domain
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,
}
},
},
})
3 changes: 0 additions & 3 deletions src/zksync/utils/getEip712Domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@ import type {
ZksyncTransactionSerializable,
ZksyncTransactionSerializableEIP712,
} from '../types/transaction.js'
import { assertEip712Transaction } from './assertEip712Transaction.js'
import { hashBytecode } from './hashBytecode.js'

export const getEip712Domain: EIP712DomainFn<
ZksyncTransactionSerializable,
ZksyncEIP712TransactionSignable
> = (transaction) => {
assertEip712Transaction(transaction)

const message = transactionToMessage(
transaction as ZksyncTransactionSerializableEIP712,
)
Expand Down

0 comments on commit 8e750c4

Please sign in to comment.