Skip to content

Commit

Permalink
support evm localnet
Browse files Browse the repository at this point in the history
  • Loading branch information
Revantark committed Jun 24, 2024
1 parent 6b99bd7 commit bd88d06
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/orderbook/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gardenfi/orderbook",
"version": "0.1.5",
"version": "0.1.6",
"type": "module",
"dependencies": {
"@catalogfi/utils": "^0.1.6",
Expand Down
48 changes: 47 additions & 1 deletion packages/orderbook/src/lib/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export const Chains = {
bitcoin_testnet: "bitcoin_testnet",
bitcoin_regtest: "bitcoin_regtest",
ethereum_arbitrum: "ethereum_arbitrum",
ethereum_arbitrumlocalnet: "ethereum_arbitrumlocalnet",
ethereum_localnet: "ethereum_localnet",
} as const;

export type Chain = keyof typeof Chains;
Expand Down Expand Up @@ -55,6 +57,28 @@ export const Assets = {
address: "0x3D1e56247033FE191DC789b5838E366dC04b1b73",
},
},
ethereum_arb_localnet: {
WBTC: {
name: "Wrapped Bitcoin",
symbol: "WBTC",
decimals: 8,
chain: Chains.ethereum_arbitrum,
isToken: true,
thumbnail: "https://cryptologos.cc/logos/wrapped-bitcoin-wbtc-logo.svg",
address: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
},
},
ethereum_localnet: {
WBTC: {
name: "Wrapped Bitcoin",
symbol: "WBTC",
decimals: 8,
chain: Chains.ethereum_localnet,
isToken: true,
thumbnail: "https://cryptologos.cc/logos/wrapped-bitcoin-wbtc-logo.svg",
address: "0x5FbDB2315678afecb367f032d93F642f64180aa3",
},
},
bitcoin: {
BTC: {
name: "Bitcoin",
Expand Down Expand Up @@ -149,12 +173,34 @@ export const ChainsData: Record<Chain, ChainData> = {
thumbnail: "https://cryptologos.cc/logos/arbitrum-arb-logo.svg",
},
},
ethereum_arbitrumlocalnet: {
nativeAsset: {
name: "Ethereum",
symbol: "ETH",
decimals: 18,
chain: Chains.ethereum_arbitrumlocalnet,
isToken: false,
thumbnail: "https://cryptologos.cc/logos/arbitrum-arb-logo.svg",
},
},
ethereum_localnet: {
nativeAsset: {
name: "Ethereum",
symbol: "ETH",
decimals: 18,
chain: Chains.ethereum_localnet,
isToken: false,
thumbnail: "https://cryptologos.cc/logos/ethereum-eth-logo.svg",
},
},
};

export const isMainnet = (chain: Chain) => {
return !(
chain === Chains.ethereum_sepolia ||
chain === Chains.bitcoin_testnet ||
chain === Chains.bitcoin_regtest
chain === Chains.bitcoin_regtest ||
chain === Chains.ethereum_arbitrumlocalnet ||
chain === Chains.ethereum_localnet
);
};
27 changes: 17 additions & 10 deletions packages/orderbook/src/lib/contractAddress.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
export type ContractAddress = {
AtomicSwap: string;
// TODO: Make this lowercase
AtomicSwap: string;
};

export const CONTRACT_ADDRESS: Record<number, ContractAddress> = {
1: {
AtomicSwap: "0xA5E38d098b54C00F10e32E51647086232a9A0afD",
},
11155111: {
AtomicSwap: "0x9ceD08aeE17Fbc333BB7741Ec5eB2907b0CA4241",
},
42161: {
AtomicSwap: "0x203DAC25763aE783Ad532A035FfF33d8df9437eE",
},
1: {
AtomicSwap: "0xA5E38d098b54C00F10e32E51647086232a9A0afD",
},
11155111: {
AtomicSwap: "0x9ceD08aeE17Fbc333BB7741Ec5eB2907b0CA4241",
},
42161: {
AtomicSwap: "0x203DAC25763aE783Ad532A035FfF33d8df9437eE",
},
31337: {
AtomicSwap: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
},
31338: {
AtomicSwap: "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9",
},
};
8 changes: 5 additions & 3 deletions packages/orderbook/src/lib/orderpair.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Asset, Chains, EvmChain } from './asset';
import { CONTRACT_ADDRESS } from './contractAddress';
import { OrderpairErrors } from './errors';
import { Asset, Chains, EvmChain } from "./asset";
import { CONTRACT_ADDRESS } from "./contractAddress";
import { OrderpairErrors } from "./errors";

export const orderPairGenerator = (from: Asset, to: Asset) => {
if (from.chain === to.chain) {
Expand Down Expand Up @@ -28,6 +28,8 @@ export const chainToId: Record<EvmChain, number> = {
ethereum: 1,
ethereum_sepolia: 11155111,
ethereum_arbitrum: 42161,
ethereum_arbitrumlocalnet: 31338,
ethereum_localnet: 31337,
};

export const idToChain: Record<number, EvmChain> = Object.entries(
Expand Down

0 comments on commit bd88d06

Please sign in to comment.