Skip to content

Commit

Permalink
Merge pull request #83 from ethereum-attestation-service/remove-nonce
Browse files Browse the repository at this point in the history
Remove nonce from serialization/deserialization of offchain attestations
  • Loading branch information
lbeder authored Feb 5, 2024
2 parents 1f3aa86 + d189392 commit 395d6d9
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 17 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@
## 1.4.1 (2024-02-02)

- Check for ethers v6 compatibility

## 1.4.2 (2024-02-03)

- Remove nonce from serialization/deserialization of offchain attestations
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,9 @@ const signer = new ethers.Wallet(privateKey, provider);

const offchainAttestation = await offchain.signOffchainAttestation({
recipient: '0xFD50b031E778fAb33DfD2Fc3Ca66a1EeF0652165',
// Unix timestamp of when attestation expires. (0 for no expiration)
expirationTime: 0n,
// Unix timestamp of current time
time: BigInt(Math.floor(Date.now() / 1000)),
expirationTime: 0n, // Unix timestamp of when attestation expires. (0 for no expiration)
time: BigInt(Math.floor(Date.now() / 1000)), // Unix timestamp of current time
revocable: true, // Be aware that if your schema is not revocable, this MUST be false
nonce: 0n, // This variable is optional
schema: "0xb16fa048b0d597f5a821747eba64efa4762ee5143e9a80600d0005386edfc995",
refUID: '0x0000000000000000000000000000000000000000000000000000000000000000',
data: encodedData,
Expand Down
2 changes: 1 addition & 1 deletion dist/offchain/offchain-utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export type CompactAttestationShareablePackageObject = [
refUID: string,
revocable: boolean,
data: string,
nonce: number,
reserved: number,
offchainVersion?: number,
salt?: string
];
Expand Down
3 changes: 1 addition & 2 deletions dist/offchain/offchain-utils.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/offchain/offchain-utils.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ethereum-attestation-service/eas-sdk",
"version": "1.4.1",
"version": "1.4.2",
"description": "Ethereum Attestation Service - TypeScript/JavaScript SDK",
"repository": "git@github.com:ethereum-attestation-service/eas-sdk.git",
"author": "Leonid Beder <leonid@lbeder.com>",
Expand Down
5 changes: 2 additions & 3 deletions src/offchain/offchain-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export type CompactAttestationShareablePackageObject = [
refUID: string,
revocable: boolean,
data: string,
nonce: number,
reserved: number, // This field is currently unused and will serialized as 0
offchainVersion?: number,
salt?: string
];
Expand Down Expand Up @@ -88,7 +88,7 @@ export const compactOffchainAttestationPackage = (
sig.message.refUID === ZeroHash ? '0' : sig.message.refUID,
sig.message.revocable,
sig.message.data,
Number(sig.message.nonce),
0,
sig.message.version,
sig.message.salt
];
Expand Down Expand Up @@ -192,7 +192,6 @@ export const uncompactOffchainAttestationPackage = (
refUID: compacted[12] === '0' ? ZeroHash : compacted[12],
revocable: compacted[13],
data: compacted[14],
nonce: BigInt(compacted[15]),
salt: compacted[17]
}
},
Expand Down
6 changes: 2 additions & 4 deletions test/test/offchain-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ const TEST_ATTESTATIONS: Spec[] = [
revocable: true,
refUID: '0x0000000000000000000000000000000000000000000000000000000000000000',
data: '0x',
salt: '0x0000000000000000000000000000000000000000000000000000000000000123',
nonce: 0n
salt: '0x0000000000000000000000000000000000000000000000000000000000000123'
}
},
signer: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'
Expand Down Expand Up @@ -126,8 +125,7 @@ const TEST_ATTESTATIONS: Spec[] = [
expirationTime: 1692891810n,
revocable: true,
refUID: '0x0000000000000000000000000000000000000000000000000000000000000000',
data: '0x',
nonce: 0n
data: '0x'
}
} as unknown as SignedOffchainAttestation,
signer: '0x8f80b8f45cA0F036da46fFA4D9e5e42D086fB302'
Expand Down

0 comments on commit 395d6d9

Please sign in to comment.