Skip to content

Commit

Permalink
Merge branch 'ethereum-attestation-service:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
nodoubtz authored Jun 19, 2024
2 parents c6a0f0d + 683bd9c commit 6939944
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 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
Expand Down
2 changes: 2 additions & 0 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
1 change: 1 addition & 0 deletions dist/transaction.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface TransactionSigner {
}
export declare class Transaction<T> {
readonly data: ContractTransaction;
receipt?: TransactionReceipt;
private readonly signer;
private readonly waitCallback;
constructor(data: ContractTransaction, signer: TransactionSigner, waitCallback: (receipt: TransactionReceipt) => Promise<T>);
Expand Down
10 changes: 7 additions & 3 deletions dist/transaction.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/transaction.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": "2.1.4",
"version": "2.2.0",
"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
11 changes: 8 additions & 3 deletions src/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface TransactionSigner {

export class Transaction<T> {
public readonly data: ContractTransaction;
public receipt?: TransactionReceipt;
private readonly signer: TransactionSigner;
private readonly waitCallback: (receipt: TransactionReceipt) => Promise<T>;

Expand All @@ -31,13 +32,17 @@ export class Transaction<T> {
}

public async wait(confirmations?: number): Promise<T> {
if (this.receipt) {
throw new Error(`Transaction already broadcast: ${this.receipt}`);
}

const tx = await this.signer.sendTransaction(this.data);
const receipt = await tx.wait(confirmations);
if (!receipt) {
this.receipt = await tx.wait(confirmations);
if (!this.receipt) {
throw new Error(`Unable to confirm: ${tx}`);
}

return this.waitCallback(receipt);
return this.waitCallback(this.receipt);
}
}

Expand Down

0 comments on commit 6939944

Please # to comment.