Skip to content

Commit 44ad3f1

Browse files
committed
fix: use a publicClient instead of exporting devnet
1 parent 4a95adc commit 44ad3f1

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

packages/client/src/testing.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,21 @@ export const client = AaveClient.create({
118118
environment,
119119
});
120120

121-
export const devnetChain = await chain(client, { chainId: ETHEREUM_FORK_ID })
121+
const devnetChain = await chain(client, { chainId: ETHEREUM_FORK_ID })
122122
.map(nonNullable)
123123
.map(toViemChain)
124124
.match(
125125
(c) => c,
126126
() => never('No devnet chain found'),
127127
);
128128

129+
export async function createForkPublicClient() {
130+
return createPublicClient({
131+
chain: devnetChain,
132+
transport: http(ETHEREUM_FORK_RPC_URL),
133+
});
134+
}
135+
129136
export async function createNewWallet(
130137
privateKey?: `0x${string}`,
131138
): Promise<WalletClient<Transport, Chain, Account>> {

packages/spec/positions/math/helper.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { type BigDecimal, bigDecimal } from '@aave/client';
2-
import { devnetChain, ETHEREUM_FORK_RPC_URL } from '@aave/client/testing';
3-
import { type Address, createPublicClient, http } from 'viem';
2+
import { createForkPublicClient } from '@aave/client/testing';
3+
import type { Address } from 'viem';
44

55
// Constants
66
const WAD = 10n ** 18n; // 1e18 = 1.0 in WAD format
@@ -60,12 +60,8 @@ export async function getAccountData(
6060
address: Address,
6161
spoke: Address,
6262
): Promise<UserAccountData> {
63-
const publicClient = createPublicClient({
64-
chain: devnetChain,
65-
transport: http(ETHEREUM_FORK_RPC_URL),
66-
});
67-
68-
const result = await publicClient.readContract({
63+
const forkPublicClient = await createForkPublicClient();
64+
const result = await forkPublicClient.readContract({
6965
address: spoke,
7066
abi: userAccountDataABI,
7167
functionName: 'getUserAccountData',

packages/spec/positions/math/userPositions.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ describe('Given a user with a User Position on a Spoke', () => {
152152
);
153153
expect(totalSupplied).toBeBigDecimalCloseTo(
154154
position.totalSupplied.current.value,
155-
1,
155+
2,
156156
);
157157
});
158158

0 commit comments

Comments
 (0)