diff --git a/main.ts b/main.ts index 76b3fcb..7b8d3c8 100644 --- a/main.ts +++ b/main.ts @@ -8,6 +8,7 @@ import { ChainId } from "@aave/contract-helpers"; import { createFork, forkIdToForkParams, + fundAccount, getForkParameters, } from "./src/tenderly"; import { @@ -47,6 +48,7 @@ type CommonOptions = { // pool?: string; aclManagerAddress?: string; + userAddress?: string; keepAlive?: boolean | string; }; @@ -221,6 +223,12 @@ const questions: { [key: string]: InquirerQuestion | YargsQuestion } = { Number(args.networkId) !== ChainId.mainnet ), }, + userAddress: { + message: + "Enter an address you want to fund with 1000 native currency on the fork?", + describe: "Address to fund with 1000 of native currency", + type: "string", + }, keepAlive: { message: "Should the fork be kept alive after terminal is closed?", describe: "Keep the fork alive after this session", @@ -385,6 +393,10 @@ function getName(options: Options) { argv = { ...argv, ...params }; } + if (argv.userAddress) { + await fundAccount(forkId, argv.userAddress); + } + console.log(`To use this fork on the aave interface you need to do the following things. 1. Open the browser console on app.aave.com (or a local instance) and enter diff --git a/package.json b/package.json index 1ce0a74..74f56e0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bgd-labs/aave-tenderly-cli", - "version": "0.0.6", + "version": "0.0.7", "description": "", "main": "main.ts", "private": false, @@ -10,7 +10,7 @@ "scripts": { "start": "npm run build && node dist/index.js", "build": "ncc build ./main.ts -o dist --minify", - "publish:local": "npm run build && npm pack && npm i -g bgd-labs-aave-tenderly-cli-0.0.6.tgz && rm bgd-labs-aave-tenderly-cli-0.0.6.tgz" + "publish:local": "npm run build && npm pack && npm i -g bgd-labs-aave-tenderly-cli-0.0.7.tgz && rm bgd-labs-aave-tenderly-cli-0.0.7.tgz" }, "repository": { "type": "git", diff --git a/src/tenderly.ts b/src/tenderly.ts index 2735763..96900a0 100644 --- a/src/tenderly.ts +++ b/src/tenderly.ts @@ -103,3 +103,12 @@ export async function deleteFork(forkId: string) { const { axiosOnTenderly, projectUrl } = getTenderlyClient(); await axiosOnTenderly.delete(`${projectUrl}/fork/${forkId}`); } + +export async function fundAccount(forkId: string, address: string) { + const { axiosOnTenderly, projectUrl } = getTenderlyClient(); + + await axiosOnTenderly.post(`${projectUrl}/fork/${forkId}/balance`, { + accounts: [address], + amount: 1000, + }); +}