33import { local , staging } from '@aave/env' ;
44import type { AnyVariables } from '@aave/graphql' ;
55import { schema } from '@aave/graphql/test-utils' ;
6- import { chainId } from '@aave/types' ;
6+ import {
7+ type BigDecimal ,
8+ bigDecimal ,
9+ chainId ,
10+ type EvmAddress ,
11+ } from '@aave/types' ;
712import type { TypedDocumentNode } from '@urql/core' ;
813import { validate } from 'graphql' ;
914import type { ValidationRule } from 'graphql/validation/ValidationContext' ;
10- import { createWalletClient , http , type WalletClient } from 'viem' ;
15+ import {
16+ createPublicClient ,
17+ createWalletClient ,
18+ http ,
19+ parseEther ,
20+ type WalletClient ,
21+ } from 'viem' ;
1122import { privateKeyToAccount } from 'viem/accounts' ;
1223import { sepolia } from 'viem/chains' ;
1324import { expect } from 'vitest' ;
@@ -18,7 +29,13 @@ export const signer = privateKeyToAccount(import.meta.env.PRIVATE_KEY);
1829export const environment =
1930 import . meta. env . ENVIRONMENT === 'local' ? local : staging ;
2031
21- export const tenderlyFork = chainId ( 99999999 ) ;
32+ export const ETHEREUM_FORK_ID = chainId ( 99999999 ) ;
33+
34+ export const ETHEREUM_FORK_RPC_URL =
35+ 'https://virtual.mainnet.rpc.tenderly.co/27ff3c60-0e2c-4d46-8190-f5170dc7da8c' ;
36+
37+ // Re-export for convenience
38+ export { bigDecimal } from '@aave/types' ;
2239
2340export const client = AaveClient . create ( {
2441 environment,
@@ -30,6 +47,48 @@ export const wallet: WalletClient = createWalletClient({
3047 transport : http ( ) ,
3148} ) ;
3249
50+ // Tenderly RPC type for setBalance
51+ type TSetBalanceRpc = {
52+ Method : 'tenderly_setBalance' ;
53+ Parameters : [ addresses : string [ ] , amount : string ] ;
54+ ReturnType : string ;
55+ } ;
56+
57+ /**
58+ * Fund an address on Tenderly fork with specified ETH amount
59+ * @param address - Address to fund
60+ * @param amount - Amount in ETH (BigDecimal string, e.g., "1.5" for 1.5 ETH)
61+ * @returns Transaction hash
62+ */
63+ export async function fundAddress (
64+ address : EvmAddress ,
65+ amount : BigDecimal = bigDecimal ( '1.0' ) , // 1 ETH
66+ ) : Promise < string > {
67+ // Create client with fork chain - you'll need to replace this with your actual fork chain config
68+ const publicClient = createPublicClient ( {
69+ chain : {
70+ id : ETHEREUM_FORK_ID ,
71+ name : 'Tenderly Fork' ,
72+ network : 'tenderly-fork' ,
73+ nativeCurrency : { name : 'Ether' , symbol : 'ETH' , decimals : 18 } ,
74+ rpcUrls : {
75+ default : { http : [ ETHEREUM_FORK_RPC_URL ] } ,
76+ } ,
77+ } ,
78+ transport : http ( ETHEREUM_FORK_RPC_URL ) ,
79+ } ) ;
80+
81+ const amountInWei = parseEther ( amount ) ;
82+ const amountHex = `0x${ amountInWei . toString ( 16 ) } ` ;
83+
84+ const txHash = await publicClient . request < TSetBalanceRpc > ( {
85+ method : 'tenderly_setBalance' ,
86+ params : [ [ address ] , amountHex ] ,
87+ } ) ;
88+
89+ return txHash ;
90+ }
91+
3392const messages : Record < GraphQLErrorCode , string > = {
3493 [ GraphQLErrorCode . UNAUTHENTICATED ] :
3594 "Unauthenticated - Authentication is required to access '<operation>'" ,
0 commit comments