Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ethereum-attestation-service/eas-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
slavik0329 committed Jun 21, 2024
2 parents a1ccc06 + f35195a commit ee2f8b7
Show file tree
Hide file tree
Showing 98 changed files with 9,376 additions and 3,378 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
cache: 'pnpm'

- name: Install SDK dependencies
Expand Down
11 changes: 6 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
# Dependencies.
# Dependencies
/node_modules
/.pnp
.pnp.js

# Testing.
# Testing
/coverage
.hardhat-dependency-compiler

# Production.
# Production
/build

# Ignore all .env files.
# Ignore all .env files
.env*
!.env
!.env.template

# Misc.
# Misc
.DS_Store
.vscode/
41 changes: 40 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,45 @@
# Changelog

## 1.4.0 (2023-12-08)
## 2.2.0

- Add a method to receive the tx receipt to the Transaction object

## 2.1.4

- Support legacy versions by coercing them to full semver

## 2.1.2

- Avoid using @ethereum-attestation-service/eas-contracts-legacy in production
- Automatically derive the EIP712 version via the domain separator
- Improve delegated attestation backward compatibility
- Don't require the signer/provider to have the `getAddress` method
- Allow offchain verification with refUID
- Don't automatically broadcast transactions. In order to broadcast transactions, it's now always necessary to call the `wait()` function.

## 1.6.1

- Avoid using @ethereum-attestation-service/eas-contracts-legacy in production

## 1.6.0

- Automatically derive the EIP712 version via the domain separator
- Improve delegated attestation backward compatibility

## 1.5.0

- Introduce framework-agnostic `TransactionSigner` and `TypeDataSigner` interfaces which replace the previous usage of the signer/provider
- Fix recipient being mandatory in `attest()` calls

## 1.4.2

- Remove nonce from serialization/deserialization of offchain attestations

## 1.4.1

- Check for ethers v6 compatibility

## 1.4.0

- Add customizable salt to offchain attestations to reduce the chance of predictable UIDs (which may be abused in some very specific use-cases)
- Remove unnecessary offchain attestation version input from the `signOffchainAttestation` API
31 changes: 23 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ const tx = await eas.attest({
const newAttestationUID = await tx.wait();

console.log("New attestation UID:", newAttestationUID);

console.log("Transaction receipt:", tx.receipt);
```

### Creating Offchain Attestations
Expand Down Expand Up @@ -172,12 +174,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 Expand Up @@ -206,7 +205,23 @@ await transaction.wait();

### Creating Timestamps

To create a timestamp for a single piece of data, you can use the `timestamp` function provided by the EAS SDK. Here's an example:
To timestamp an off-chain attestation UID on-chain, you can use the timestamp function provided by the EAS SDK. Here's an example:

```javascript
import { EAS } from "@ethereum-attestation-service/eas-sdk";

const eas = new EAS(EASContractAddress);
eas.connect(provider);

const uid = "0x6776de8122c352b4d671003e58ca112aedb99f34c629a1d1fe3b332504e2943a";

const transaction = await eas.timestamp(uid);

// Optional: Wait for the transaction to be validated
await transaction.wait();
```

To create a timestamp for a any piece of data, you can use the `timestamp` function provided by the EAS SDK. Here's an example:

```javascript
import { EAS } from "@ethereum-attestation-service/eas-sdk";
Expand Down Expand Up @@ -279,7 +294,7 @@ await transaction.wait();
To verify an offchain attestation, you can use the `verifyOffchainAttestationSignature` function provided by the EAS SDK. Here's an example:

```javascript
import { OffchainAttestationVersion, Offchain, PartialTypedDataConfig } from "@ethereum-attestation-service/eas-sdk";
import { OffchainAttestationVersion, Offchain, OffchainConfig } from "@ethereum-attestation-service/eas-sdk";

const attestation = {
// your offchain attestation
Expand Down Expand Up @@ -315,7 +330,7 @@ const attestation = {
signer: "0x1e3de6aE412cA218FD2ae3379750388D414532dc",
};

const EAS_CONFIG: PartialTypedDataConfig = {
const EAS_CONFIG: OffchainConfig = {
address: attestation.sig.domain.verifyingContract,
version: attestation.sig.domain.version,
chainId: attestation.sig.domain.chainId,
Expand Down
9 changes: 6 additions & 3 deletions dist/eas.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Overrides } from 'ethers';
import { EIP712Proxy } from './eip712-proxy';
import { Delegated, Offchain } from './offchain';
import { AttestationRequest, DelegatedAttestationRequest, DelegatedProxyAttestationRequest, DelegatedProxyRevocationRequest, DelegatedRevocationRequest, MultiAttestationRequest, MultiDelegatedAttestationRequest, MultiDelegatedProxyAttestationRequest, MultiDelegatedProxyRevocationRequest, MultiDelegatedRevocationRequest, MultiRevocationRequest, RevocationRequest } from './request';
import { Base, SignerOrProvider, Transaction } from './transaction';
import { Base, Transaction, TransactionSigner } from './transaction';
export { Overrides } from 'ethers';
export * from './request';
export interface Attestation {
Expand All @@ -19,15 +19,17 @@ export interface Attestation {
data: string;
}
export interface EASOptions {
signerOrProvider?: SignerOrProvider;
signer?: TransactionSigner;
proxy?: EIP712Proxy;
}
export declare class EAS extends Base<EASContract> {
private proxy?;
private delegated?;
private offchain?;
private version?;
private legacyEAS;
constructor(address: string, options?: EASOptions);
connect(signerOrProvider: SignerOrProvider): this;
connect(signer: TransactionSigner): this;
getVersion(): Promise<string>;
getAttestation(uid: string): Promise<Attestation>;
isAttestationValid(uid: string): Promise<boolean>;
Expand Down Expand Up @@ -59,4 +61,5 @@ export declare class EAS extends Base<EASContract> {
getRevokeTypeHash(): Promise<string>;
private setDelegated;
private setOffchain;
private isLegacyContract;
}
Loading

0 comments on commit ee2f8b7

Please sign in to comment.