Skip to content

Commit

Permalink
Update docs (#1036)
Browse files Browse the repository at this point in the history
* Update docs

* Restore code removed

* Fix linter
  • Loading branch information
hippocampus-web3 authored Feb 12, 2024
1 parent e032702 commit 0e0c43a
Show file tree
Hide file tree
Showing 49 changed files with 2,074 additions and 1,322 deletions.
5 changes: 5 additions & 0 deletions packages/xchain-arbitrum/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
// Import the Client class from '@xchainjs/xchain-evm' module
import { Client as XchainEvmClient } from '@xchainjs/xchain-evm'

// Import defaultArbParams constant from './const' file
import { defaultArbParams } from './const'

// Create a class called Client that extends the XchainEvmClient class
export class Client extends XchainEvmClient {
// Constructor function that takes an optional config parameter, defaulting to defaultArbParams
constructor(config = defaultArbParams) {
// Call the constructor of the parent class (XchainEvmClient) with the provided config
super(config)
}
}
30 changes: 13 additions & 17 deletions packages/xchain-arbitrum/src/const.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,30 @@
// Import necessary modules and classes from external packages and files
import { ExplorerProvider, Network } from '@xchainjs/xchain-client'
import { EVMClientParams } from '@xchainjs/xchain-evm'
import { EtherscanProvider } from '@xchainjs/xchain-evm-providers'
import { Asset } from '@xchainjs/xchain-util'
import { BigNumber, ethers } from 'ethers'

// Define constants related to Arbitrum
export const ARB_DECIMAL = 18

export const LOWER_FEE_BOUND = 100_000_000
export const UPPER_FEE_BOUND = 1_000_000_000

export const ARB_GAS_ASSET_DECIMAL = 18

/**
* Chain identifier for ARB.
*
*/
export const ARBChain = 'ARB' as const

/**
* Base "chain" asset of Arbitrum chain.
*
*/
export const AssetARB: Asset = { chain: ARBChain, symbol: 'ARB', ticker: 'ETH', synth: false }

// =====Ethers providers=====
// Define JSON-RPC providers for mainnet and testnet
const ARBITRUM_MAINNET_ETHERS_PROVIDER = new ethers.providers.JsonRpcProvider('https://arb1.arbitrum.io/rpc')
const ARBITRUM_TESTNET_ETHERS_PROVIDER = new ethers.providers.JsonRpcProvider('https://goerli-rollup.arbitrum.io/rpc')

// Define ethers providers for different networks
const ethersJSProviders = {
[Network.Mainnet]: ARBITRUM_MAINNET_ETHERS_PROVIDER,
[Network.Testnet]: ARBITRUM_TESTNET_ETHERS_PROVIDER,
[Network.Stagenet]: ARBITRUM_MAINNET_ETHERS_PROVIDER,
}

// =====ONLINE providers=====

// Define online providers (Etherscan) for mainnet and testnet
const ARB_ONLINE_PROVIDER_MAINNET = new EtherscanProvider(
ARBITRUM_MAINNET_ETHERS_PROVIDER,
'https://api.arbiscan.io',
Expand All @@ -53,36 +43,41 @@ const ARB_ONLINE_PROVIDER_TESTNET = new EtherscanProvider(
18,
)

// Define providers for different networks
const arbProviders = {
[Network.Mainnet]: ARB_ONLINE_PROVIDER_MAINNET,
[Network.Testnet]: ARB_ONLINE_PROVIDER_TESTNET,
[Network.Stagenet]: ARB_ONLINE_PROVIDER_MAINNET,
}

// =====Explorers=====
// Define explorer providers for mainnet and testnet
const ARB_MAINNET_EXPLORER = new ExplorerProvider(
'https://arbiscan.io/',
'https://arbiscan.io/address/%%ADDRESS%%',
'https://arbiscan.io/tx/%%TX_ID%%',
)

const ARB_TESTNET_EXPLORER = new ExplorerProvider(
'https://goerli.arbiscan.io',
'https://goerli.arbiscan.io/address/%%ADDRESS%%',
'https://goerli.arbiscan.io/tx/%%TX_ID%%',
)

// Define explorer providers for different networks
const arbExplorerProviders = {
[Network.Mainnet]: ARB_MAINNET_EXPLORER,
[Network.Testnet]: ARB_TESTNET_EXPLORER,
[Network.Stagenet]: ARB_MAINNET_EXPLORER,
}
// =====Explorers=====

// Define root derivation paths for different networks
const ethRootDerivationPaths = {
[Network.Mainnet]: `m/44'/60'/0'/0/`,
[Network.Testnet]: `m/44'/60'/0'/0/`,
[Network.Stagenet]: `m/44'/60'/0'/0/`,
}

// Define default parameters for the Arbitrum client
const defaults = {
[Network.Mainnet]: {
approveGasLimit: BigNumber.from(200000),
Expand All @@ -104,6 +99,7 @@ const defaults = {
},
}

// Define the default parameters for the Arbitrum client
export const defaultArbParams: EVMClientParams = {
chain: ARBChain,
gasAsset: AssetARB,
Expand Down
3 changes: 3 additions & 0 deletions packages/xchain-arbitrum/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
// Export all elements from the 'client' module
export * from './client'

// Export all elements from the 'const' module
export * from './const'
7 changes: 7 additions & 0 deletions packages/xchain-avax/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
// Import the Client class from '@xchainjs/xchain-evm' module
import { Client as XchainEvmClient } from '@xchainjs/xchain-evm'

// Import defaultAvaxParams constant from './const' file
import { defaultAvaxParams } from './const'

// Define and export the Client class as the default export
export default class Client extends XchainEvmClient {
// Constructor function that takes an optional config parameter, defaulting to defaultAvaxParams
constructor(config = defaultAvaxParams) {
// Call the constructor of the parent class (XchainEvmClient) with the provided config
super(config)
}
}

// Export the Client class explicitly (not as a default export)
export { Client }
34 changes: 15 additions & 19 deletions packages/xchain-avax/src/const.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,30 @@
// Import necessary modules and classes from external packages and files
import { ExplorerProvider, Network } from '@xchainjs/xchain-client'
import { EVMClientParams } from '@xchainjs/xchain-evm'
import { EtherscanProvider, RoutescanProvider } from '@xchainjs/xchain-evm-providers'
import { Asset } from '@xchainjs/xchain-util'
import { BigNumber, ethers } from 'ethers'

// Define constants related to Avalanche
export const AVAX_DECIMAL = 18

export const LOWER_FEE_BOUND = 2_000_000_000
export const UPPER_FEE_BOUND = 1_000_000_000_000

export const AVAX_GAS_ASSET_DECIMAL = 18

/**
* Chain identifier for AVAX.
*
*/
export const AVAXChain = 'AVAX' as const

/**
* Base "chain" asset of Avalanche chain.
*
*/
export const AssetAVAX: Asset = { chain: AVAXChain, symbol: 'AVAX', ticker: 'AVAX', synth: false }

// =====Ethers providers=====
// Define JSON-RPC providers for mainnet and testnet
const AVALANCHE_MAINNET_ETHERS_PROVIDER = new ethers.providers.JsonRpcProvider('https://rpc.ankr.com/avalanche')
const AVALANCHE_TESTNET_ETHERS_PROVIDER = new ethers.providers.JsonRpcProvider('https://rpc.ankr.com/avalanche_fuji')

// Define ethers providers for different networks
const ethersJSProviders = {
[Network.Mainnet]: AVALANCHE_MAINNET_ETHERS_PROVIDER,
[Network.Testnet]: AVALANCHE_TESTNET_ETHERS_PROVIDER,
[Network.Stagenet]: AVALANCHE_MAINNET_ETHERS_PROVIDER,
}
// =====Ethers providers=====
// =====ONLINE providers=====

// Define online providers (Etherscan) for mainnet and testnet
const AVAX_ONLINE_PROVIDER_TESTNET = new EtherscanProvider(
AVALANCHE_TESTNET_ETHERS_PROVIDER,
'https://api-testnet.snowtrace.io',
Expand All @@ -52,12 +42,14 @@ const AVAX_ONLINE_PROVIDER_MAINNET = new EtherscanProvider(
18,
)

// Define providers for different networks
const avaxProviders = {
[Network.Mainnet]: AVAX_ONLINE_PROVIDER_MAINNET,
[Network.Testnet]: AVAX_ONLINE_PROVIDER_TESTNET,
[Network.Stagenet]: AVAX_ONLINE_PROVIDER_MAINNET,
}

// Define Routescan providers for mainnet and testnet
const ROUTESCAN_PROVIDER_MAINNET = new RoutescanProvider(
AVALANCHE_MAINNET_ETHERS_PROVIDER,
'https://api.routescan.io',
Expand All @@ -75,15 +67,14 @@ const ROUTESCAN_PROVIDER_TESTNET = new RoutescanProvider(
true,
)

// Define Routescan providers for different networks
const routescanProviders = {
[Network.Mainnet]: ROUTESCAN_PROVIDER_MAINNET,
[Network.Testnet]: ROUTESCAN_PROVIDER_TESTNET,
[Network.Stagenet]: ROUTESCAN_PROVIDER_MAINNET,
}

// =====ONLINE providers=====

// =====Explorers=====
// Define explorer providers for mainnet and testnet
const AVAX_MAINNET_EXPLORER = new ExplorerProvider(
'https://snowtrace.dev/',
'https://snowtrace.dev/address/%%ADDRESS%%',
Expand All @@ -94,19 +85,22 @@ const AVAX_TESTNET_EXPLORER = new ExplorerProvider(
'https://testnet.snowtrace.dev/address/%%ADDRESS%%',
'https://testnet.snowtrace.dev/tx/%%TX_ID%%',
)

// Define explorer providers for different networks
const avaxExplorerProviders = {
[Network.Mainnet]: AVAX_MAINNET_EXPLORER,
[Network.Testnet]: AVAX_TESTNET_EXPLORER,
[Network.Stagenet]: AVAX_MAINNET_EXPLORER,
}
// =====Explorers=====

// Define root derivation paths for different networks
const ethRootDerivationPaths = {
[Network.Mainnet]: `m/44'/60'/0'/0/`,
[Network.Testnet]: `m/44'/60'/0'/0/`,
[Network.Stagenet]: `m/44'/60'/0'/0/`,
}

// Define default parameters for the Avalanche client
const defaults = {
[Network.Mainnet]: {
approveGasLimit: BigNumber.from(200000),
Expand All @@ -127,6 +121,8 @@ const defaults = {
gasPrice: BigNumber.from(30 * 10 ** 9),
},
}

// Define the default parameters for the Avalanche client
export const defaultAvaxParams: EVMClientParams = {
chain: AVAXChain,
gasAsset: AssetAVAX,
Expand Down
3 changes: 3 additions & 0 deletions packages/xchain-avax/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
// Export all elements from the 'client' module
export * from './client'

// Export all elements from the 'const' module
export * from './const'
Loading

0 comments on commit 0e0c43a

Please sign in to comment.