Remove supports1559 (#460)

* Remove supports1550

* Lint

* Readd chains
pull/465/head
Nam Chu Hoai 3 years ago committed by GitHub
parent 5ab8e221db
commit 0fd42b63a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      typescript/deploy/src/config.ts
  2. 56
      typescript/deploy/src/utils.ts
  3. 6
      typescript/infra/config/environments/dev/chains.ts
  4. 8
      typescript/infra/config/environments/test/chains.ts
  5. 16
      typescript/infra/config/environments/testnet/chains.ts
  6. 23
      typescript/infra/config/networks/testnets.ts
  7. 27
      typescript/sdk/src/provider.ts

@ -12,7 +12,6 @@ export interface CheckerViolation {
export type TransactionConfig = {
overrides?: ethers.Overrides;
supports1559?: boolean;
// The number of confirmations considered reorg safe
confirmations?: number;
signer?: ethers.Signer;

@ -9,7 +9,7 @@ import {
objMap,
} from '@abacus-network/sdk';
import { EnvironmentConfig, TransactionConfig } from './config';
import { EnvironmentConfig } from './config';
import { RouterConfig } from './router';
export function getArgs() {
@ -33,61 +33,15 @@ export function getRouterConfig<N extends ChainName>(
}));
}
// this is currently a kludge to account for ethers issues
function fixOverrides(config: TransactionConfig): ethers.Overrides {
if (config.supports1559) {
return {
maxFeePerGas: config.overrides?.maxFeePerGas,
maxPriorityFeePerGas: config.overrides?.maxPriorityFeePerGas,
gasLimit: config.overrides?.gasLimit,
};
} else {
return {
type: 0,
gasPrice: config.overrides?.gasPrice,
gasLimit: config.overrides?.gasLimit,
};
}
}
export const registerEnvironment = <Chain extends ChainName>(
multiProvider: MultiProvider<Chain>,
environmentConfig: EnvironmentConfig<Chain>,
) => {
multiProvider.apply((chain, dc) => {
const txConfig = environmentConfig[chain];
dc.registerOverrides(fixOverrides(txConfig));
if (txConfig.confirmations) {
dc.registerConfirmations(txConfig.confirmations);
}
if (txConfig.signer) {
dc.registerSigner(txConfig.signer);
}
});
};
export const registerSigners = <Chain extends ChainName>(
multiProvider: MultiProvider,
signers: ChainMap<Chain, ethers.Signer>,
) =>
objMap(signers, (chain, signer) =>
multiProvider.getChainConnection(chain).registerSigner(signer),
);
export const registerSigner = <Chain extends ChainName>(
multiProvider: MultiProvider<Chain>,
signer: ethers.Signer,
) => multiProvider.apply((_, dc) => dc.registerSigner(signer));
export const getMultiProviderFromConfigAndSigner = <Chain extends ChainName>(
environmentConfig: EnvironmentConfig<Chain>,
signer: ethers.Signer,
): MultiProvider<Chain> => {
const chainProviders = objMap(environmentConfig, () => ({
const chainProviders = objMap(environmentConfig, (_, config) => ({
provider: signer.provider!,
signer,
confirmations: config.confirmations,
overrides: config.overrides,
}));
const multiProvider = new MultiProvider(chainProviders);
registerEnvironment(multiProvider, environmentConfig);
return multiProvider;
return new MultiProvider(chainProviders);
};

@ -1,8 +1,8 @@
import { configs } from '../../networks/testnets';
import { chainConnectionConfigs } from '@abacus-network/sdk';
export const devConfigs = {
alfajores: configs.alfajores,
kovan: configs.kovan,
alfajores: chainConnectionConfigs.alfajores,
kovan: chainConnectionConfigs.kovan,
};
export type DevChains = keyof typeof devConfigs;

@ -1,9 +1,9 @@
import { configs } from '../../networks/testnets';
import { chainConnectionConfigs } from '@abacus-network/sdk';
export const testConfigs = {
test1: configs.test1,
test2: configs.test2,
test3: configs.test3,
test1: chainConnectionConfigs.test1,
test2: chainConnectionConfigs.test2,
test3: chainConnectionConfigs.test3,
};
export type TestChains = keyof typeof testConfigs;

@ -1,13 +1,13 @@
import { configs } from '../../networks/testnets';
import { chainConnectionConfigs } from '@abacus-network/sdk';
export const testnetConfigs = {
alfajores: configs.alfajores,
kovan: configs.kovan,
fuji: configs.fuji,
mumbai: configs.mumbai,
bsctestnet: configs.bsctestnet,
arbitrumrinkeby: configs.arbitrumrinkeby,
optimismkovan: configs.optimismkovan,
alfajores: chainConnectionConfigs.alfajores,
kovan: chainConnectionConfigs.kovan,
fuji: chainConnectionConfigs.fuji,
mumbai: chainConnectionConfigs.mumbai,
bsctestnet: chainConnectionConfigs.bsctestnet,
arbitrumrinkeby: chainConnectionConfigs.arbitrumrinkeby,
optimismkovan: chainConnectionConfigs.optimismkovan,
};
export type TestnetChains = keyof typeof testnetConfigs;

@ -1,23 +0,0 @@
import { BigNumber } from 'ethers';
import { TransactionConfig } from '@abacus-network/deploy';
import { chainConnectionConfigs } from '@abacus-network/sdk';
import { ChainMap } from '@abacus-network/sdk';
const { kovan } = chainConnectionConfigs;
export const overriddenKovan: TransactionConfig = {
...kovan,
overrides: {
gasPrice: BigNumber.from(10_000_000_000),
gasLimit: 15_000_000,
},
};
const _configs = {
...chainConnectionConfigs,
kovan: overriddenKovan,
};
export const configs: ChainMap<keyof typeof _configs, TransactionConfig> =
_configs;

@ -23,33 +23,6 @@ export class ChainConnection {
this.confirmations = dc.confirmations ?? 0;
}
registerOverrides = (overrides: ethers.Overrides) =>
(this.overrides = overrides);
registerConfirmations = (confirmations: number) =>
(this.confirmations = confirmations);
registerProvider(provider: ethers.providers.Provider) {
if (this.signer) {
this.signer.connect(provider);
}
this.provider = provider;
}
registerRpcURL(url: string) {
this.registerProvider(new ethers.providers.JsonRpcProvider(url));
}
registerSigner(signer: ethers.Signer) {
if (this.provider) {
signer.connect(this.provider);
}
this.signer = signer;
}
registerWalletSigner = (privatekey: string) =>
this.registerSigner(new ethers.Wallet(privatekey));
getConnection = () => this.signer ?? this.provider;
getAddress = () => this.signer?.getAddress();

Loading…
Cancel
Save