Skip to content
This repository has been archived by the owner on Nov 5, 2023. It is now read-only.

Commit

Permalink
Merge pull request #367 from web3well/contract-updates
Browse files Browse the repository at this point in the history
Contract Updates & Client Integration
  • Loading branch information
jacque006 authored Nov 15, 2022
2 parents 771de1f + 57e7ec3 commit ccc8a59
Show file tree
Hide file tree
Showing 44 changed files with 4,860 additions and 4,079 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/aggregator-proxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ on:
paths:
- 'aggregator-proxy/**'
pull_request:
branches:
- 'main'
paths:
- 'aggregator-proxy/**'

Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/aggregator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@ on:
- 'main'
paths:
- 'aggregator/**'
# Check for breaking changes from contracts
- 'contracts/**'
- '.github/workflows/aggregator.yml'
pull_request:
branches:
- 'main'
paths:
- 'aggregator/**'
# Check for breaking changes from contracts
- 'contracts/**'
- '.github/workflows/aggregator.yml'
branches-ignore:
# Changes targeting this branch should be tested+fixed when being merged
# into main
- contract-updates

defaults:
run:
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/clients.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ on:
paths:
- 'contracts/clients/**'
pull_request:
branches:
- 'main'
paths:
- 'contracts/clients/**'

Expand All @@ -17,6 +15,14 @@ defaults:
working-directory: ./contracts/clients

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup-contracts-clients
- run: yarn build

test:
runs-on: ubuntu-latest

Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ on:
- 'contracts/**'
- '!contracts/clients/**'
pull_request:
branches:
- 'main'
paths:
- 'contracts/**'
- '!contracts/clients/**'
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ on:
paths:
- 'extension/**'
pull_request:
branches:
- 'main'
paths:
- 'extension/**'

Expand Down
2 changes: 1 addition & 1 deletion aggregator-proxy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@types/koa__cors": "^3.3.0",
"@types/koa__router": "^8.0.11",
"@types/node-fetch": "^2.6.1",
"bls-wallet-clients": "^0.7.3",
"bls-wallet-clients": "0.8.0-940dd11",
"fp-ts": "^2.12.1",
"io-ts": "^2.2.16",
"io-ts-reporters": "^2.0.1",
Expand Down
8 changes: 4 additions & 4 deletions aggregator-proxy/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -885,10 +885,10 @@ bech32@1.1.4:
resolved "https://registry.yarnpkg.com/bech32/-/bech32-1.1.4.tgz#e38c9f37bf179b8eb16ae3a772b40c356d4832e9"
integrity sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ==

bls-wallet-clients@^0.7.3:
version "0.7.3"
resolved "https://registry.yarnpkg.com/bls-wallet-clients/-/bls-wallet-clients-0.7.3.tgz#22fae2434c67b642d172023f259131233e396eb7"
integrity sha512-u2mwyf5+1KHYCyeutfl4jhEDCmsW/C+S54QKbicUkU26MvAGJ76/TxSOOIBiWTjzVDdDUBdJ/zQRoRd35GSGcQ==
bls-wallet-clients@0.8.0-940dd11:
version "0.8.0-940dd11"
resolved "https://registry.yarnpkg.com/bls-wallet-clients/-/bls-wallet-clients-0.8.0-940dd11.tgz#6488e58b1fad12e577ec06d10a3c4f9763c1e395"
integrity sha512-f5zqGf5dAq7IPXbrsNLdvEX0lJx2/7DBOqbkvHABGEWEKnHd32tMKDZxUeGt/cPV+2W0nKmQk3uYPNGCEuC6EA==
dependencies:
"@thehubbleproject/bls" "^0.5.1"
ethers "5.5.4"
Expand Down
6 changes: 3 additions & 3 deletions aggregator/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export type {
PublicKey,
Signature,
VerificationGateway,
} from "https://esm.sh/bls-wallet-clients@0.7.3";
} from "https://esm.sh/bls-wallet-clients@0.8.0-940dd11";

export {
Aggregator as AggregatorClient,
Expand All @@ -59,10 +59,10 @@ export {
getConfig,
MockERC20__factory,
VerificationGateway__factory,
} from "https://esm.sh/bls-wallet-clients@0.7.3";
} from "https://esm.sh/bls-wallet-clients@0.8.0-940dd11";

// Workaround for esbuild's export-star bug
import blsWalletClients from "https://esm.sh/bls-wallet-clients@0.7.3";
import blsWalletClients from "https://esm.sh/bls-wallet-clients@0.8.0-940dd11";
const {
bundleFromDto,
bundleToDto,
Expand Down
18 changes: 13 additions & 5 deletions aggregator/src/app/BundleService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
BigNumber,
BlsWalletSigner,
BlsWalletWrapper,
Bundle,
delay,
ethers,
Expand Down Expand Up @@ -151,15 +152,22 @@ export default class BundleService {
};
}

const signedCorrectly = this.blsWalletSigner.verify(bundle);
const walletAddresses = await Promise.all(bundle.senderPublicKeys.map(
(pubKey) => BlsWalletWrapper.AddressFromPublicKey(
pubKey, this.ethereumService.verificationGateway
)
));

const failures: TransactionFailure[] = [];

if (signedCorrectly === false) {
failures.push({
for (const walletAddr of walletAddresses) {
const signedCorrectly = this.blsWalletSigner.verify(bundle, walletAddr);
if (!signedCorrectly) {
failures.push({
type: "invalid-signature",
description: "invalid signature",
});
description: `invalid signature for wallet address ${walletAddr}`,
});
}
}

failures.push(...await this.ethereumService.checkNonces(bundle));
Expand Down
2 changes: 1 addition & 1 deletion aggregator/test/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function assertEquals<L, R extends L>(left: L, right: R) {

export function assertBundleSucceeds(res: AddBundleResponse) {
if ("failures" in res) {
throw new AssertionError("expected bundle to succeed");
throw new AssertionError(`expected bundle to succeed. failures: ${JSON.stringify(res.failures)}`);
}
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
node_modules
coverage
coverage.json
/typechain
/typechain-types
networks/local.json

#Hardhat files
Expand Down
2 changes: 1 addition & 1 deletion contracts/clients/.npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
*
!/dist/src/**/*
!/dist/typechain/**/*
!/dist/typechain-types/**/*
!/src/**/*
!/package.json
!/README.md
18 changes: 18 additions & 0 deletions contracts/clients/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,24 @@ const verificationGateway = VerificationGateway__factory.connect(
await verificationGateway.processBundle(bundle);
```

You can get the results of the operations in a bundle using `getOperationResults`.

```ts
import { getOperationResults } from 'bls-wallet-clients';

...

const txn = await verificationGateway.processBundle(bundle);
const txnReceipt = txn.wait();
const opResults = getOperationResults(txnReceipt);

// Includes data from WalletOperationProcessed event,
// as well as parsed errors with action index
const { error } = opResults[0];
console.log(error?.actionIndex); // ex. 0 (as BigNumber)
console.log(error?.message); // ex. "some require failure message"
```

## Signer

Utilities for signing, aggregating and verifying transaction bundles using the
Expand Down
10 changes: 5 additions & 5 deletions contracts/clients/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bls-wallet-clients",
"version": "0.7.3",
"version": "0.8.0",
"description": "Client libraries for interacting with BLS Wallet components",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
Expand All @@ -13,7 +13,7 @@
"yarn": ">=1.0.0"
},
"scripts": {
"build": "rm -rf dist && mkdir dist && cp -rH typechain dist/typechain && find ./dist/typechain -type f \\! -name '*.d.ts' -name '*.ts' -delete && tsc",
"build": "rm -rf dist && mkdir dist && cp -rH typechain-types dist/typechain-types && find ./dist/typechain-types -type f \\! -name '*.d.ts' -name '*.ts' -delete && tsc",
"watch": "tsc -w",
"test": "mocha --require ts-node/register --require source-map-support/register --require ./test/init.ts **/*.test.ts",
"premerge": "yarn test",
Expand All @@ -27,12 +27,12 @@
"devDependencies": {
"@types/chai": "^4.3.3",
"@types/chai-as-promised": "^7.1.5",
"@types/mocha": "^9.1.1",
"@types/mocha": "^10.0.0",
"chai": "^4.3.6",
"chai-as-promised": "^7.1.1",
"mocha": "^10.0.0",
"mocha": "^10.1.0",
"source-map-support": "^0.5.21",
"ts-node": "^10.9.1",
"typescript": "^4.8.2"
"typescript": "^4.8.4"
}
}
Loading

0 comments on commit ccc8a59

Please sign in to comment.