Skip to content

Commit 5575c62

Browse files
committed
fix: only connect provider to aws signer
1 parent b015756 commit 5575c62

File tree

3 files changed

+33
-24
lines changed

3 files changed

+33
-24
lines changed

src/utils/account.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { getSmartWallet } from "../server/utils/wallets/getSmartWallet";
1313
import { getChain } from "./chain";
1414

1515
export const _accountsCache = new Map<string, Account>();
16-
export const _providerCache = new Map<number, providers.JsonRpcProvider>();
1716

1817
export const getAccount = async (args: {
1918
chainId: number;
@@ -56,17 +55,9 @@ export const getAccount = async (args: {
5655
throw new Error(`Wallet type not supported: ${walletDetails.type}`);
5756
}
5857

59-
// Get chain rpc provider.
60-
let provider = _providerCache.get(chainId);
61-
if (!provider) {
62-
const chain = await getChain(chainId);
63-
64-
provider = new providers.JsonRpcProvider(chain.rpc);
65-
_providerCache.set(chainId, provider);
66-
}
67-
6858
// Get smart wallet if `accountAddress` is provided.
6959
let signer: Signer;
60+
7061
if (accountAddress) {
7162
const smartWallet = await getSmartWallet({
7263
chainId,
@@ -78,9 +69,18 @@ export const getAccount = async (args: {
7869
signer = await wallet.getSigner();
7970
}
8071

81-
const connectedSigner = signer.connect(provider);
72+
if (walletDetails.type === WalletType.awsKms) {
73+
// Get chain rpc provider.
74+
const chain = await getChain(chainId);
75+
console.log("received chain in to account", chain);
76+
const provider = new providers.JsonRpcProvider(chain.rpc);
77+
console.log("provider in to account", provider);
78+
79+
signer = signer.connect(provider);
80+
}
81+
8282
const account = await ethers5Adapter.signer.fromEthers({
83-
signer: connectedSigner,
83+
signer,
8484
});
8585

8686
// Set cache.

test/e2e/config.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import assert from "assert";
2-
import type { Chain } from "viem";
3-
import { anvil } from "viem/chains";
2+
import { defineChain, type Chain } from "viem";
43

54
assert(process.env.ENGINE_URL, "ENGINE_URL is required");
65
assert(process.env.ENGINE_ACCESS_TOKEN, "ENGINE_ACCESS_TOKEN is required");
@@ -16,8 +15,23 @@ export const CONFIG: Config = {
1615
// USE_LOCAL_CHAIN: true,
1716
// CHAIN: arbitrumSepolia,
1817

19-
USE_LOCAL_CHAIN: true,
20-
CHAIN: anvil,
18+
USE_LOCAL_CHAIN: false,
19+
CHAIN: defineChain({
20+
id: 1993,
21+
name: "B3 Sepolia Testnet",
22+
testnet: true,
23+
rpcUrls: {
24+
default: {
25+
http: ["https://sepolia.b3.fun/http"],
26+
webSocket: ["wss://sepolia.b3.fun/ws"],
27+
},
28+
},
29+
nativeCurrency: {
30+
name: "Ether",
31+
symbol: "ETH",
32+
decimals: 18,
33+
},
34+
}),
2135

2236
TRANSACTION_COUNT: 500,
2337
TRANSACTIONS_PER_BATCH: 100,

test/e2e/tests/setup.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
import { sleep } from "bun";
22
import { beforeAll } from "bun:test";
3-
import {
4-
createChain,
5-
getEngineBackendWallet,
6-
setWalletBalance,
7-
setupEngine,
8-
} from "../utils/engine";
3+
import { createChain, setWalletBalance, setupEngine } from "../utils/engine";
94

105
import type { Address } from "viem";
116
import { CONFIG } from "../config";
@@ -28,11 +23,11 @@ export const setup = async (): Promise<SetupResult> => {
2823

2924
const publicClient = setupPublicClient();
3025
const engine = setupEngine();
31-
const backendWallet = await getEngineBackendWallet(engine);
26+
// const backendWallet = await getEngineBackendWallet(engine);
3227
let testClient;
3328

3429
// temporarily set to aws wallet
35-
// const backendWallet = "0x7C243d1475DA6fe0eeB8d1C4Ee4510aF35cf7CD5";
30+
const backendWallet = "0x7C243d1475DA6fe0eeB8d1C4Ee4510aF35cf7CD5";
3631

3732
if (CONFIG.USE_LOCAL_CHAIN) {
3833
setupAnvil();

0 commit comments

Comments
 (0)