Remove TransactionConfig (#465)

pull/482/head
Nam Chu Hoai 3 years ago committed by GitHub
parent ba29b50a8f
commit b8388f859d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      typescript/deploy/src/config.ts
  2. 6
      typescript/deploy/src/index.ts
  3. 44
      typescript/infra/config/networks/mainnets.ts
  4. 5
      typescript/infra/scripts/utils.ts
  5. 33
      typescript/sdk/src/chains.ts
  6. 26
      typescript/sdk/src/provider.ts

@ -1,6 +1,4 @@
import { ethers } from 'ethers'; import { ChainMap, ChainName, IChainConnection } from '@abacus-network/sdk';
import { ChainMap, ChainName } from '@abacus-network/sdk';
export interface CheckerViolation { export interface CheckerViolation {
chain: ChainName; chain: ChainName;
@ -10,15 +8,7 @@ export interface CheckerViolation {
data?: any; data?: any;
} }
export type TransactionConfig = {
overrides?: ethers.Overrides;
// The number of confirmations considered reorg safe
confirmations?: number;
signer?: ethers.Signer;
provider?: ethers.providers.Provider;
};
export type EnvironmentConfig<Chain extends ChainName> = ChainMap< export type EnvironmentConfig<Chain extends ChainName> = ChainMap<
Chain, Chain,
TransactionConfig IChainConnection
>; >;

@ -1,9 +1,5 @@
export { AbacusAppChecker, Ownable } from './check'; export { AbacusAppChecker, Ownable } from './check';
export { export { CheckerViolation, EnvironmentConfig } from './config';
CheckerViolation,
EnvironmentConfig,
TransactionConfig,
} from './config';
export { export {
AbacusCoreDeployer, AbacusCoreDeployer,
CoreConfig, CoreConfig,

@ -1,44 +0,0 @@
import { BigNumber } from 'ethers';
import { TransactionConfig } from '@abacus-network/deploy';
import { ChainMap } from '@abacus-network/sdk';
export const celo: TransactionConfig = {
overrides: {},
};
export const ethereum: TransactionConfig = {
overrides: {
// This isn't actually used because Ethereum supports EIP 1559 - but just in case
gasPrice: '400000000000', // 400 gwei
// EIP 1559 params
maxFeePerGas: '300000000000', // 300 gwei
maxPriorityFeePerGas: '4000000000', // 4 gwei
},
};
export const avalanche: TransactionConfig = {
overrides: {
// This isn't actually used because Avalanche supports EIP 1559 - but just in case
gasPrice: BigNumber.from(50_000_000_000), // 50 nAVAX (50 gwei)
// EIP 1559 params
maxFeePerGas: '50000000000', // 50 nAVAX (50 gwei)
maxPriorityFeePerGas: '10000000000', // 10 nAVAX (10 gwei)
},
};
export const polygon: TransactionConfig = {
overrides: {
gasPrice: '5000000000', // 50 gwei
},
};
const _configs = {
celo,
ethereum,
avalanche,
polygon,
};
export const configs: ChainMap<keyof typeof _configs, TransactionConfig> =
_configs;

@ -1,10 +1,11 @@
import path from 'path'; import path from 'path';
import { TransactionConfig, utils } from '@abacus-network/deploy'; import { utils } from '@abacus-network/deploy';
import { import {
AllChains, AllChains,
ChainMap, ChainMap,
ChainName, ChainName,
IChainConnection,
MultiProvider, MultiProvider,
} from '@abacus-network/sdk'; } from '@abacus-network/sdk';
import { objMap, promiseObjAll } from '@abacus-network/sdk/dist/utils'; import { objMap, promiseObjAll } from '@abacus-network/sdk/dist/utils';
@ -39,7 +40,7 @@ export async function getEnvironmentConfig() {
} }
export async function getMultiProviderFromGCP<Chain extends ChainName>( export async function getMultiProviderFromGCP<Chain extends ChainName>(
txConfigs: ChainMap<Chain, TransactionConfig>, txConfigs: ChainMap<Chain, IChainConnection>,
environment: DeployEnvironment, environment: DeployEnvironment,
) { ) {
const connections = await promiseObjAll( const connections = await promiseObjAll(

@ -4,6 +4,35 @@ import { ethers } from 'ethers';
import { IChainConnection } from './provider'; import { IChainConnection } from './provider';
import { ChainMap, ChainName } from './types'; import { ChainMap, ChainName } from './types';
export const ethereum: IChainConnection = {
provider: new ethers.providers.JsonRpcProvider(
'https://mainnet-nethermind.blockscout.com',
1,
),
confirmations: 7,
};
export const celo: IChainConnection = {
provider: new StaticCeloJsonRpcProvider('https://forno.celo.org', 42220),
confirmations: 1,
};
export const polygon: IChainConnection = {
provider: new ethers.providers.JsonRpcProvider(
'https://rpc-mainnet.matic.quiknode.pro',
137,
),
confirmations: 200,
};
export const avalanche: IChainConnection = {
provider: new ethers.providers.JsonRpcProvider(
'https://api.avax.network/ext/bc/C/rpc',
43114,
),
confirmations: 1,
};
export const alfajores: IChainConnection = { export const alfajores: IChainConnection = {
provider: new StaticCeloJsonRpcProvider( provider: new StaticCeloJsonRpcProvider(
'https://alfajores-forno.celo.org', 'https://alfajores-forno.celo.org',
@ -85,6 +114,10 @@ export const test3: IChainConnection = {
}; };
const _configs = { const _configs = {
ethereum,
celo,
polygon,
avalanche,
alfajores, alfajores,
fuji, fuji,
kovan, kovan,

@ -1,22 +1,22 @@
import { ethers } from 'ethers'; import { ethers } from 'ethers';
import { ChainMap, ChainName } from './types'; import { ChainMap, ChainName } from './types';
import { MultiGeneric } from './utils'; import { MultiGeneric, objMap } from './utils';
export interface IChainConnection { export interface IChainConnection {
provider?: ethers.providers.Provider; provider: ethers.providers.Provider;
signer?: ethers.Signer; signer?: ethers.Signer;
overrides?: ethers.Overrides; overrides?: ethers.Overrides;
confirmations?: number; confirmations?: number;
} }
export class ChainConnection { export class ChainConnection {
provider?: ethers.providers.Provider; provider: ethers.providers.Provider;
signer?: ethers.Signer; signer?: ethers.Signer;
overrides: ethers.Overrides; overrides: ethers.Overrides;
confirmations: number; confirmations: number;
constructor(dc: IChainConnection = {}) { constructor(dc: IChainConnection) {
this.provider = dc.provider; this.provider = dc.provider;
this.signer = dc.signer; this.signer = dc.signer;
this.overrides = dc.overrides ?? {}; this.overrides = dc.overrides ?? {};
@ -31,17 +31,13 @@ export class ChainConnection {
export class MultiProvider< export class MultiProvider<
Chain extends ChainName = ChainName, Chain extends ChainName = ChainName,
> extends MultiGeneric<Chain, ChainConnection> { > extends MultiGeneric<Chain, ChainConnection> {
constructor( constructor(chainConnectionConfigs: ChainMap<Chain, IChainConnection>) {
chainConnectionConfigs: ChainMap<Chain, IChainConnection> | Chain[], super(
) { objMap(
const params = Array.isArray(chainConnectionConfigs) chainConnectionConfigs,
? chainConnectionConfigs.map((v) => [v, {}]) (_, connection) => new ChainConnection(connection),
: (Object.entries(chainConnectionConfigs) as [Chain, IChainConnection][]); ),
const providerEntries = params.map(([chain, v]) => [ );
chain,
new ChainConnection(v),
]);
super(Object.fromEntries(providerEntries));
} }
getChainConnection(chain: Chain) { getChainConnection(chain: Chain) {
return this.get(chain); return this.get(chain);

Loading…
Cancel
Save