Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: multichain indexer ( part 1 ) #293

Merged
merged 12 commits into from
Aug 4, 2024
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { EVMContractData } from "../types";
import { sepolia } from "viem/chains";
import { EVMContractData } from "../../types";

export const TestnetAllowList: EVMContractData = {
address: "0x3D18904711fe451356eBA461B7747EA3Abff6c93",
indexFromBlock: 12241046,
chainId: 15557,
chainType: "evm",
chainName: "Sepolia",
chain: sepolia,
abi: [
{
inputs: [],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { EVMContractData } from "../types";
import { sepolia } from "viem/chains";
import { EVMContractData } from "../../types";

export const TestnetDepositOrder: EVMContractData = {
address: "0x4faA684A1E0Cdd7cb271b5424a12A2D039624D78",
indexFromBlock: 12240840,
chainId: 15557,
chainType: "evm",
chainName: "EOS EVM Tesnet",
chain: sepolia,
abi: [
{
inputs: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { EVMContractData } from "../types";
import { sepolia } from "viem/chains";
import { EVMContractData } from "../../types";

export const TestnetEasyAuction: EVMContractData = {
address: "0x8d37219725eB0088360f744A5d894035D0f88F82",
indexFromBlock: 12239067,
chainId: 15557,
chainType: "evm",
chainName: "EOS EVM Tesnet",
chain: sepolia,
abi: [
{
inputs: [],
Expand Down
51 changes: 43 additions & 8 deletions packages/app-contracts/src/dev/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,43 @@
export * from "./testnet-easy-auction";
export * from "./testnet-deposit-order";
export * from "./testnet-usd-cred";
export * from "./testnet-mbots-prelaunch";
export * from "./sepolia-usdt";
export * from "./testnet-usdt";
export * from "./eos-fake-bitusd";
export * from "./eos-fake-usdt";
export * from "./auction/testnet-easy-auction";
export * from "./auction/testnet-deposit-order";
export * from "./tokens/testnet-usd-cred";
export * from "./tokens/testnet-mbots-prelaunch";
export * from "./tokens/sepolia-usdt";
export * from "./tokens/testnet-usdt";
export * from "./tokens/eos-fake-bitusd";
export * from "./tokens/eos-fake-usdt";

import { TestnetEasyAuction } from "./auction/testnet-easy-auction";
import { TestnetDepositOrder } from "./auction/testnet-deposit-order";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (complexity): Consider using dynamic imports and a single source of truth for all modules to simplify the code.

The new code introduces increased complexity due to the number of explicit imports and manual list management. This makes the file harder to maintain and scale. Consider using dynamic imports and a single source of truth for all modules to simplify the code. Here's a suggested refactor:

// Re-export all modules from their respective directories
export * from "./auction/testnet-easy-auction";
export * from "./auction/testnet-deposit-order";
export * from "./tokens/testnet-usd-cred";
export * from "./tokens/testnet-mbots-prelaunch";
export * from "./tokens/sepolia-usdt";
export * from "./tokens/testnet-usdt";
export * from "./tokens/eos-fake-bitusd";
export * from "./tokens/eos-fake-usdt";

// Import all modules dynamically
const modules = {
  auction: {
    TestnetEasyAuction: require("./auction/testnet-easy-auction").TestnetEasyAuction,
    TestnetDepositOrder: require("./auction/testnet-deposit-order").TestnetDepositOrder,
  },
  tokens: {
    TestnetUSDCred: require("./tokens/testnet-usd-cred").TestnetUSDCred,
    TestnetMBOTSPL: require("./tokens/testnet-mbots-prelaunch").TestnetMBOTSPL,
    SepoliaUSDT: require("./tokens/sepolia-usdt").SepoliaUSDT,
    TestnetUSDT: require("./tokens/testnet-usdt").TestnetUSDT,
    EOSFakeBITUSD: require("./tokens/eos-fake-bitusd").EOSFakeBITUSD,
    EOSFakeUSDT: require("./tokens/eos-fake-usdt").EOSFakeUSDT,
  }
};

// Categorize contracts
const evmTokens = [
  modules.tokens.TestnetUSDCred,
  modules.tokens.TestnetMBOTSPL,
  modules.tokens.SepoliaUSDT,
  modules.tokens.TestnetUSDT,
];

const eosTokens = [
  modules.tokens.EOSFakeBITUSD,
  modules.tokens.EOSFakeUSDT,
];

const auctions = [
  modules.auction.TestnetEasyAuction,
  modules.auction.TestnetDepositOrder,
];

export const devContracts = {
  tokens: {
    evm: evmTokens,
    eos: eosTokens,
  },
  auctions,
};

This approach reduces redundancy, makes the code easier to read, and simplifies the process of adding new contracts.

import { TestnetUSDCred } from "./tokens/testnet-usd-cred";
import { TestnetMBOTSPL } from "./tokens/testnet-mbots-prelaunch";
import { SepoliaUSDT } from "./tokens/sepolia-usdt";
import { TestnetUSDT } from "./tokens/testnet-usdt";
import { EOSFakeBITUSD } from "./tokens/eos-fake-bitusd";
import { EOSFakeUSDT } from "./tokens/eos-fake-usdt";
import {ContractData, EOSTokenContractData, EVMTokenContractData} from '../types';

const evmTokens: EVMTokenContractData[] = [
TestnetUSDCred,
TestnetMBOTSPL,
SepoliaUSDT,
TestnetUSDT,
]

const eosTokens: EOSTokenContractData[] = [
EOSFakeBITUSD,
EOSFakeUSDT,
]

const auctions: ContractData[] = [
TestnetEasyAuction,
TestnetDepositOrder,
]

export const devContracts = {
tokens: {
evm: evmTokens,
eos: eosTokens
},
auctions
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TokenContractData } from "../types";
import { EOSTokenContractData} from '../../types';

export const EOSFakeBITUSD: TokenContractData = {
export const EOSFakeBITUSD: EOSTokenContractData = {
address: "bkbtokentest",
name: "BITUSD",
symbol: "BITUSD",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TokenContractData } from "../types";
import { EOSTokenContractData} from '../../types';

export const EOSFakeUSDT: TokenContractData = {
export const EOSFakeUSDT: EOSTokenContractData = {
address: "bkbmocktoken",
name: "Fake EOS USDT",
symbol: "USDT",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { EVMTokenContractData } from "../types";
import { sepolia } from "viem/chains";
import { EVMTokenContractData } from "../../types";

export const SepoliaUSDT: EVMTokenContractData = {
address: "0x5b148580635e8b67184bcb496741e423f2c326bf",
Expand All @@ -9,6 +10,7 @@ export const SepoliaUSDT: EVMTokenContractData = {
chainId: 11155111, // sepolia
chainType: "evm",
chainName: "Sepolia",
chain: sepolia,
abi: [
{
inputs: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { EVMTokenContractData } from "../types";
import { EVMTokenContractData } from "../../types";
import {eosEvmTestnet} from '../../../../app-env/src/chains';

export const TestnetMBOTSPL: EVMTokenContractData = {
address: "0x357752b66961021524b44523cD90a8B3861803E5",
Expand All @@ -9,6 +10,7 @@ export const TestnetMBOTSPL: EVMTokenContractData = {
chainId: 15557,
chainType: "evm",
chainName: "EOS EVM Tesnet",
chain: eosEvmTestnet,
abi: [
{
inputs: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { EVMTokenContractData } from "../types";
import { EVMTokenContractData } from "../../types";
import {eosEvmTestnet} from '../../../../app-env/src/chains';

export const TestnetUSDCred: EVMTokenContractData = {
address: "0x1d5A4C37e60cAd0C72c057E3c191352429cDB38e",
Expand All @@ -9,6 +10,7 @@ export const TestnetUSDCred: EVMTokenContractData = {
chainId: 15557,
chainType: "evm",
chainName: "EOS EVM Tesnet",
chain: eosEvmTestnet,
abi: [
{
inputs: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { EVMTokenContractData } from "../types";
import { EVMTokenContractData } from "../../types";
import {eosEvmTestnet} from '../../../../app-env/src/chains';

export const TestnetUSDT: EVMTokenContractData = {
address: "0xE561021FCB5FFB86b439ae9e6AeCE0370e2394eC",
Expand All @@ -9,6 +10,7 @@ export const TestnetUSDT: EVMTokenContractData = {
chainId: 15557, // eos_evm
chainType: "evm",
chainName: "EOS EVM Tesnet",
chain: eosEvmTestnet,
abi: [
{
inputs: [
Expand Down
181 changes: 0 additions & 181 deletions packages/app-contracts/src/dev/usdc.ts

This file was deleted.

Loading
Loading