Skip to content

Commit

Permalink
feat: use process.env var for RPC
Browse files Browse the repository at this point in the history
  • Loading branch information
LayneHaber committed Jul 4, 2024
1 parent b90975a commit 313ab05
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 10 deletions.
3 changes: 2 additions & 1 deletion adapters/connext/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"dependencies": {
"@connext/nxtp-utils": "2.4.1",
"fast-csv": "5.0.1",
"csv-parser": "^3.0.0",
"csv-parser": "3.0.0",
"dotenv": "16.4.5",
"viem": "2.8.16"
},
"devDependencies": {
Expand Down
8 changes: 4 additions & 4 deletions adapters/connext/src/utils/assets.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { createPublicClient, http, parseUnits } from "viem";
import { linea } from "viem/chains";
import { parseUnits } from "viem";
import { getPoolInformationFromLpToken, poolInfo } from "./cartographer";
import { LINEA_CHAIN_ID, CONNEXT_LINEA_ADDRESS } from "./subgraph";
import { LpAccountBalanceHourly, RouterEventResponse } from "./types";
import { LpAccountBalanceHourly } from "./types";
import { getClient } from "./rpc";

type CompositeBalanceHourly = LpAccountBalanceHourly & {
underlyingTokens: string[];
Expand Down Expand Up @@ -43,7 +43,7 @@ export const getCompositeBalances = async (amms: LpAccountBalanceHourly[]): Prom
}

// get contract interface
const client = createPublicClient({ chain: linea, transport: http() });
const client = getClient();

// get composite balances for amms (underlying tokens and balances)
const balances = await Promise.all(amms.map(async ({ token, amount, block }) => {
Expand Down
2 changes: 2 additions & 0 deletions adapters/connext/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export * from "./cartographer";
export * from "./csv";
export * from "./getUserTvlByBlock";
export * from "./rpc";
export * from "./subgraph";
export * from "./types";
8 changes: 8 additions & 0 deletions adapters/connext/src/utils/rpc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { createPublicClient, http } from "viem";
import { linea } from "viem/chains";
import { config } from "dotenv";

export const getClient = () => {
config();
return createPublicClient({ chain: linea, transport: http(process.env.CONNEXT_LINEA_RPC) });
}
5 changes: 2 additions & 3 deletions adapters/connext/src/utils/subgraph.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { getClient } from "./rpc";
import { LpAccountBalanceHourly, SubgraphResult } from "./types";
import { linea } from "viem/chains";
import { createPublicClient, http } from "viem";

export const CONNEXT_SUBGRAPH_QUERY_URL = "https://api.goldsky.com/api/public/project_clssc64y57n5r010yeoly05up/subgraphs/connext/stableswap-analytics-linea-0.0.1/gn";
export const LINEA_CHAIN_ID = 59144;
Expand Down Expand Up @@ -146,7 +145,7 @@ const appendSubgraphData = (data: LpAccountBalanceHourly[], existing: Map<string
}

export const getBlock = async (blockNumber: number) => {
const client = createPublicClient({ chain: linea, transport: http() });
const client = getClient();
const block = await client.getBlock({ blockNumber: BigInt(blockNumber) });
return block;
}
9 changes: 7 additions & 2 deletions adapters/connext/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1177,9 +1177,9 @@ crypto-js@^3.1.9-1:
resolved "https://registry.npmjs.org/crypto-js/-/crypto-js-3.3.0.tgz"
integrity sha512-DIT51nX0dCfKltpRiXV+/TVZq+Qq2NgF4644+K7Ttnla7zEzqc+kjJyiB96BHNyUTBxyjzRcZYpUdZa+QAqi6Q==

csv-parser@^3.0.0:
[email protected]:
version "3.0.0"
resolved "https://registry.npmjs.org/csv-parser/-/csv-parser-3.0.0.tgz"
resolved "https://registry.yarnpkg.com/csv-parser/-/csv-parser-3.0.0.tgz#b88a6256d79e090a97a1b56451f9327b01d710e7"
integrity sha512-s6OYSXAK3IdKqYO33y09jhypG/bSDHPuyCme/IdEHfWpLf/jKcpitVFyOC6UemgGk8v7Q5u2XE0vvwmanxhGlQ==
dependencies:
minimist "^1.2.0"
Expand Down Expand Up @@ -1279,6 +1279,11 @@ dom-walk@^0.1.0:
resolved "https://registry.npmjs.org/dom-walk/-/dom-walk-0.1.2.tgz"
integrity sha512-6QvTW9mrGeIegrFXdtQi9pk7O/nSK6lSdXW2eqUspN5LWD7UTji2Fqw5V2YLjBpHEoU9Xl/eUWNpDeZvoyOv2w==

[email protected]:
version "16.4.5"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.4.5.tgz#cdd3b3b604cb327e286b4762e13502f717cb099f"
integrity sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==

ecc-jsbn@~0.1.1:
version "0.1.2"
resolved "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz"
Expand Down

0 comments on commit 313ab05

Please sign in to comment.