Skip to content

Commit

Permalink
Merge pull request #15 from celo-org/chore/upgrade-web3
Browse files Browse the repository at this point in the history
chore: update web3 to 4.14.0
  • Loading branch information
nicolasbrugneaux authored Oct 22, 2024
2 parents 11fdffd + 5e1e9ef commit 8ce83b1
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 25 deletions.
5 changes: 5 additions & 0 deletions .changeset/silly-jobs-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@celo/web3-plugin-transaction-types": patch
---

Change the web3 peerDependency to a stable version
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: foundry-rs/foundry-toolchain@v1
with:
version: "nightly-f625d0fa7c51e65b4bf1e8f7931cd1c6e2e285e9"
- uses: oven-sh/setup-bun@v2
- run: bun install
- run: rm -rf node_modules/@celo/dev-utils/node_modules
Expand Down
Binary file modified bun.lockb
Binary file not shown.
11 changes: 3 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
".": "./lib/index.js"
},
"peerDependencies": {
"web3": ">= 4.13.1 < 5"
"web3": ">= 4.14.0 < 5"
},
"devDependencies": {
"@celo/dev-utils": "^0.0.5",
Expand All @@ -37,16 +37,11 @@
"eslint-plugin-jest": "^28.6.0",
"typescript": "^5.5.4",
"typescript-eslint": "^7.17.0",
"web3": "4.13.1-dev.cc99825.0"
"web3": "^4.14.0"
},
"dependencies": {
"@celo/abis": "^11.0.0",
"@celo/abis-l2": "npm:@celo/abis@12.0.0-canary.23",
"web3-eth-accounts": "4.2.2-dev.cc99825.0",
"web3-utils": "4.3.2-dev.cc99825.0"
},
"resolutions": {
"web3-eth": "4.9.1-dev.cc99825.0"
"@celo/abis-l2": "npm:@celo/abis@12.0.0-canary.23"
},
"patchedDependencies": {
"@celo/dev-utils@0.0.5": "patches/@celo%2Fdev-utils@0.0.5.patch"
Expand Down
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ class CeloTxMiddleware implements TransactionMiddleware {
// NOTE: small hack:
// `transactionBuilder` calls this.ctx.transactionBuilder if defined
this.ctx.transactionBuilder = undefined;
// @ts-expect-error
const tx: CeloTransaction = await transactionBuilder({
...options,
transaction: transaction,
Expand Down
1 change: 1 addition & 0 deletions src/tests/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ CeloTransactionTypesPlugin {
"useSubscriptionWhenCheckingBlockTimeout": false,
},
"handleRevert": false,
"ignoreGasPricing": false,
"maxListenersWarningThreshold": 100,
"transactionBlockTimeout": 50,
"transactionBuilder": [Function: AsyncFunction],
Expand Down
24 changes: 8 additions & 16 deletions src/tests/e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { CeloContract, CeloTransactionTypesPlugin } from "..";
import Web3, { Address } from "web3";
import { stableTokenEurABI } from "@celo/abis";
import { CeloChains, isWhitelisted } from "../utils";
import { sleep } from "bun";

let stable: CeloContract<typeof stableTokenEurABI>;
let stableAddress: Address;
Expand Down Expand Up @@ -49,6 +50,8 @@ test(
feeCurrency: stableAddress,
});

await sleep(5_000);

const balanceSenderAfter = BigInt(
await stable.methods.balanceOf(account.address).call()
);
Expand All @@ -62,7 +65,7 @@ test(
);
expect(balanceReceiverAfter).toEqual(balanceReceiverBefore + amount);
},
{ timeout: 10_000 }
{ timeout: 15_000 }
);

test(
Expand All @@ -83,6 +86,9 @@ test(
};
await web3.celo.populateTransaction(txData);
const tx = await web3.eth.sendTransaction(txData);

await sleep(5_000);

const stableBalanceSenderAfter = BigInt(
await stable.methods.balanceOf(account.address).call()
);
Expand All @@ -94,19 +100,5 @@ test(
expect(stableBalanceSenderAfter).toBeLessThan(stableBalanceSenderBefore);
expect(nativeBalanceBefore).toEqual(nativeBalanceAfter + amount);
},
{ timeout: 10_000 }
{ timeout: 15_000 }
);

describe("dango", () => {
const _web3 = new Web3("https://forno.dango.celo-testnet.org");
_web3.registerPlugin(new CeloTransactionTypesPlugin());

test("isWhitelisted", () => {
expect(_web3.celo.isValidFeeCurrency("0x123")).resolves.toBe(false);
expect(
_web3.celo.isValidFeeCurrency(
"0x4822e58de6f5e485eF90df51C41CE01721331dC0"
)
).resolves.toBe(true);
});
});

0 comments on commit 8ce83b1

Please sign in to comment.