From bd4c2baf6f97c23337639d401f078d131d289ace Mon Sep 17 00:00:00 2001 From: Keyan Zhang Date: Wed, 24 May 2023 17:59:28 -0700 Subject: [PATCH] Run tests using JsonRpcProvider --- examples/with-ethers/src/index.ts | 5 ++++- packages/ethers/src/__tests__/index-test.ts | 12 ++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/examples/with-ethers/src/index.ts b/examples/with-ethers/src/index.ts index a73a4aaec..17f095ba2 100644 --- a/examples/with-ethers/src/index.ts +++ b/examples/with-ethers/src/index.ts @@ -29,7 +29,10 @@ async function main() { // Bring your own provider (such as Alchemy or Infura: https://docs.ethers.org/v5/api/providers/) const network = "goerli"; - const provider = new ethers.providers.InfuraProvider(network); + const provider = new ethers.providers.JsonRpcProvider( + "https://goerli.infura.io/v3/84842078b09946638c03157f83405213", // using the default community project + network + ); const connectedSigner = turnkeySigner.connect(provider); const chainId = await connectedSigner.getChainId(); diff --git a/packages/ethers/src/__tests__/index-test.ts b/packages/ethers/src/__tests__/index-test.ts index 5962d24d5..2f2ecd2ea 100644 --- a/packages/ethers/src/__tests__/index-test.ts +++ b/packages/ethers/src/__tests__/index-test.ts @@ -1,5 +1,4 @@ import { Eip1193Bridge } from "@ethersproject/experimental"; -import { setBalance } from "@nomicfoundation/hardhat-network-helpers"; import { ethers } from "ethers"; import hre from "hardhat"; import { test, expect, beforeEach, describe } from "@jest/globals"; @@ -60,8 +59,10 @@ describe("TurnkeySigner", () => { `process.env.BANNED_TO_ADDRESS` ); - // @ts-ignore - const provider = hre.ethers.provider; + const provider = new ethers.providers.JsonRpcProvider( + hre.config.networks.localhost.url, + hre.config.networks.localhost.chainId + ); connectedSigner = new TurnkeySigner({ apiPublicKey, @@ -75,7 +76,10 @@ describe("TurnkeySigner", () => { eip1193 = new Eip1193Bridge(connectedSigner, provider); - setBalance(expectedEthAddress, ethers.utils.parseEther("999999")); + await provider.send("hardhat_setBalance", [ + expectedEthAddress, + "0xffffffffffffffffffffffff", + ]); }); testCase("basics", async () => {