Skip to content

Commit 884894e

Browse files
committed
Allow set version for EIP721 domain separator
1 parent 75013f0 commit 884894e

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

packages/common-ts/src/attestations/attestations.test.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ describe('Attestations', () => {
2727
1,
2828
'0x0000000000000000000000000000000000000000',
2929
receipt,
30+
'0',
3031
)
3132

3233
expect(attestation).toStrictEqual({
@@ -78,8 +79,14 @@ describe('Attestations', () => {
7879
chainID,
7980
contractAddress,
8081
receipt,
82+
'1.0.0',
83+
)
84+
const recoveredAddress = recoverAttestation(
85+
chainID,
86+
contractAddress,
87+
attestation,
88+
'1.0.0',
8189
)
82-
const recoveredAddress = recoverAttestation(chainID, contractAddress, attestation)
8390
expect(recoveredAddress).toStrictEqual(await signer.getAddress())
8491
})
8592
})

packages/common-ts/src/attestations/attestations.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,11 @@ export interface Attestation {
4343
export const getDomainSeparator = (
4444
chainId: number,
4545
disputeManagerAddress: string,
46+
version: string,
4647
): string => {
4748
const domainSeparator = eip712.domainSeparator({
4849
name: 'Graph Protocol',
49-
version: '0',
50+
version,
5051
chainId,
5152
verifyingContract: disputeManagerAddress,
5253
salt: SALT,
@@ -59,8 +60,9 @@ export const createAttestation = async (
5960
chainId: number,
6061
disputeManagerAddress: string,
6162
receipt: Receipt,
63+
version: string,
6264
): Promise<Attestation> => {
63-
const domainSeparator = getDomainSeparator(chainId, disputeManagerAddress)
65+
const domainSeparator = getDomainSeparator(chainId, disputeManagerAddress, version)
6466
const encodedReceipt = encodeReceipt(receipt)
6567
const message = eip712.encode(domainSeparator, encodedReceipt)
6668
const messageHash = utils.keccak256(message)
@@ -116,8 +118,9 @@ export const recoverAttestation = (
116118
chainId: number,
117119
disputeManagerAddress: string,
118120
attestation: Attestation,
121+
version: string,
119122
): string => {
120-
const domainSeparator = getDomainSeparator(chainId, disputeManagerAddress)
123+
const domainSeparator = getDomainSeparator(chainId, disputeManagerAddress, version)
121124
const receipt = {
122125
requestCID: attestation.requestCID,
123126
responseCID: attestation.responseCID,

0 commit comments

Comments
 (0)