Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Commit

Permalink
resolve issue #21
Browse files Browse the repository at this point in the history
  • Loading branch information
jawndiego committed Jul 31, 2023
1 parent 0c2cd64 commit 7b6aa69
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
6 changes: 5 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@
OWNER=''
# address for fetching txn hash + contract creation block number
CONTRACT_ADDRESS=''
ETHERSCAN_API_KEY='';
ETHERSCAN_API_KEY=''
API_URL=''
ALCHEMY_KEY=''
BUNDLR_FUNDING_CHAIN=''
SEPOLIA_ALCHEMY_KEY=''
3 changes: 2 additions & 1 deletion bundlr/bundlrInit.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import Bundlr from '@bundlr-network/client';
import env from '../services/env';

// initialize bundlr
export const bundlr = new Bundlr(
'http://devnet.bundlr.network',
'ethereum',
process.env.PRIVATE_KEY,
{
providerUrl: `https://eth-sepolia.g.alchemy.com/v2/${process.env.SEPOLIA_RPC_URL}`,
providerUrl: `${env.BUNDLR_FUNDING_CHAIN}/v2/${env.SEPOLIA_ALCHEMY_KEY}`,
}
);
2 changes: 1 addition & 1 deletion fetch/utils/getLastBlockNum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import env from '../../services/env';

export async function getLastBlockNum() {
const { data } = await apolloClient.query({ query: LAST_EVENT_QUERY, variables: { owner: env.OWNER } });
const apiUrl = `https://api-goerli-optimistic.etherscan.io/api?module=contract&action=getcontractcreation&contractaddresses=${env.CONTRACT_ADDRESS}&apikey=${env.OPTIMISM_GOERLI_API_KEY}`;
const apiUrl = `${env.API_URL}/api?module=contract&action=getcontractcreation&contractaddresses=${env.CONTRACT_ADDRESS}&apikey=${env.OPTIMISM_GOERLI_API_KEY}`;

if (!data.transactions.edges.length) {
const txn = await getContractCreationTxn(apiUrl);
Expand Down
6 changes: 6 additions & 0 deletions services/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ interface Env {
ETHERSCAN_API_KEY: string;
ALCHEMY_KEY: string;
OPTIMISM_GOERLI_API_KEY: string;
API_URL: string;
BUNDLR_FUNDING_CHAIN: string;
SEPOLIA_ALCHEMY_KEY: string;
}

const env: Env = {
Expand All @@ -17,6 +20,9 @@ const env: Env = {
ETHERSCAN_API_KEY: process.env.ETHERSCAN_API_KEY as string,
ALCHEMY_KEY: process.env.ALCHEMY_KEY as string,
OPTIMISM_GOERLI_API_KEY: process.env.OPTIMISM_GOERLI_API_KEY as string,
API_URL: process.env.API_URL as string,
BUNDLR_FUNDING_CHAIN: process.env.BUNDLR_FUNDING_CHAIN as string,
SEPOLIA_ALCHEMY_KEY: process.env.SEPOLIA_ALCHEMY_KEY as string,
};

objectKeys(env).forEach((key) => {
Expand Down
5 changes: 2 additions & 3 deletions viem/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import { createPublicClient, http } from 'viem';
import { sepolia } from 'viem/chains';
import env from '../services/env';

const transport = http(
`https://opt-goerli.g.alchemy.com/v2/${env.ALCHEMY_KEY}`
);

const transport = http(`${env.API_URL}v2/${env.ALCHEMY_KEY}`);

export const viemClient = createPublicClient({
chain: sepolia,
Expand Down

0 comments on commit 7b6aa69

Please sign in to comment.