Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] update: Abstract testnet EIP712 domain #2687

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions src/chains/definitions/abstractTestnet.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,51 @@
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,
}
}

export const abstractTestnet = /*#__PURE__*/ defineChain({
...chainConfig,
Expand All @@ -20,4 +66,7 @@ export const abstractTestnet = /*#__PURE__*/ defineChain({
},
},
testnet: true,
custom: {
getEip712Domain: getAbstractEip712Domain, // Use Abstract's specific EIP712 domain
},
})
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
Loading