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

Support Mantle Testnet #512

Merged
merged 3 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/apps/__tests__/bridge.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const mapToTestChain: { [key: string]: string } = {
arbitrum: 'arbitrum-goerli',
zksync: 'zksync-goerli',
linea: 'linea-goerli',
mantle: 'mantle-goerli',
};

describe('bridge utils', () => {
Expand All @@ -49,12 +50,12 @@ describe('bridge utils', () => {
console.log('🌉 All cross-chain directions to be tested', allDirections);

it('should support bridge count: ', () => {
expect(testBridges).toHaveLength(6);
expect(testBridges).toHaveLength(9);
expect(formalBridges).toHaveLength(47);
});

it('should support transfer count: ', () => {
expect(allDirections).toHaveLength(132);
expect(allDirections).toHaveLength(144);
});

it('Should correct bridge category name', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/apps/__tests__/network.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('network utils', () => {
.find((item) => item.partner.name === arrival);

it('should contains chains count: ', () => {
expect(chainConfigs).toHaveLength(19);
expect(chainConfigs).toHaveLength(20);
});

it('crab-dvm contains 5 leafs and substrate-substrateDVM deprecated', () => {
Expand Down Expand Up @@ -183,7 +183,7 @@ describe('network utils', () => {
const group = data.find((item) => item[0] === 'goerli');

expect(group).not.toEqual(undefined);
expect(uniq(sort(group![1]))).toEqual(sort(['linea-goerli', 'arbitrum-goerli', 'zksync-goerli']));
expect(uniq(sort(group![1]))).toEqual(sort(['linea-goerli', 'arbitrum-goerli', 'zksync-goerli', 'mantle-goerli']));
});

it('pangoro-dvm contains 0 leafs', () => {
Expand Down
12 changes: 12 additions & 0 deletions packages/apps/bridges/bridges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ import { ArbitrumZksyncBridge as ArbitrumZksyncBridgeLnBridge } from './lnbridge
import { ZksyncArbitrumBridge as ZksyncArbitrumBridgeLnBridge } from './lnbridge/zksync-arbitrum/utils';
import { LineaZksyncBridge as LineaZksyncBridgeLnBridge } from './lnbridge/linea-zksync/utils';
import { ZksyncLineaBridge as ZksyncLineaBridgeLnBridge } from './lnbridge/zksync-linea/utils';
import { MantleArbitrumBridge as MantleArbitrumBridgeLnBridge } from './lnbridge/mantle-arbitrum/utils';
import { ArbitrumMantleBridge as ArbitrumMantleBridgeLnBridge } from './lnbridge/arbitrum-mantle/utils';
import { MantleEthereumBridge as MantleEthereumBridgeLnBridge } from './lnbridge/mantle-ethereum/utils';
import { EthereumMantleBridge as EthereumMantleBridgeLnBridge } from './lnbridge/ethereum-mantle/utils';
import { MantleLineaBridge as MantleLineaBridgeLnBridge } from './lnbridge/mantle-linea/utils';
import { LineaMantleBridge as LineaMantleBridgeLnBridge } from './lnbridge/linea-mantle/utils';

export const bridgeConstructors = [
CBridgeBridge,
Expand Down Expand Up @@ -75,6 +81,12 @@ export const bridgeConstructors = [
ZksyncArbitrumBridgeLnBridge,
LineaZksyncBridgeLnBridge,
ZksyncLineaBridgeLnBridge,
MantleArbitrumBridgeLnBridge,
ArbitrumMantleBridgeLnBridge,
MantleEthereumBridgeLnBridge,
EthereumMantleBridgeLnBridge,
MantleLineaBridgeLnBridge,
LineaMantleBridgeLnBridge,
];

export function bridgeFactory<C extends BridgeConfig, O extends ChainConfig, T extends ChainConfig>(
Expand Down
7 changes: 7 additions & 0 deletions packages/apps/bridges/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,10 @@ export { Zksync2ArbitrumLnBridge } from './lnbridge/zksync-arbitrum';

export { Linea2ZksyncLnBridge } from './lnbridge/linea-zksync';
export { Zksync2LineaLnBridge } from './lnbridge/zksync-linea';

export { Mantle2ArbitrumLnBridge } from './lnbridge/mantle-arbitrum';
export { Arbitrum2MantleLnBridge } from './lnbridge/arbitrum-mantle';
export { Mantle2EthereumLnBridge } from './lnbridge/mantle-ethereum';
export { Ethereum2MantleLnBridge } from './lnbridge/ethereum-mantle';
export { Mantle2LineaLnBridge } from './lnbridge/mantle-linea';
export { Linea2MantleLnBridge } from './lnbridge/linea-mantle';
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { CrossToken, DVMChainConfig } from 'shared/model';
import { Bridge } from '../../../components/bridge/Bridge';
import { CrossChainComponentProps } from '../../../model/component';
import { ArbitrumMantleBridge } from './utils/bridge';

export function Arbitrum2MantleLnBridge(
props: CrossChainComponentProps<ArbitrumMantleBridge, CrossToken<DVMChainConfig>, CrossToken<DVMChainConfig>>
) {
return <Bridge {...props} hideRecipient />;
}
33 changes: 33 additions & 0 deletions packages/apps/bridges/lnbridge/arbitrum-mantle/config/bridge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { arbitrumConfig, mantleConfig } from 'shared/config/network';
import { arbitrumGoerliConfig, mantleGoerliConfig } from 'shared/config/network';
import { BridgeBase } from 'shared/core/bridge';
import { ArbitrumMantleBridgeConfig } from '../model';

const arbitrumMantleConfig: ArbitrumMantleBridgeConfig = {
contracts: {
backing: '',
issuing: '',
},
};

const arbitrumGoerliMantleGoerliConfig: ArbitrumMantleBridgeConfig = {
contracts: {
backing: '0x54cc9716905ba8ebdD01E6364125cA338Cd0054E',
issuing: '',
},
};

export const arbitrumMantleLnBridge = new BridgeBase(arbitrumConfig, mantleConfig, arbitrumMantleConfig, {
name: 'arbitrum-mantle',
category: 'lnbridgev20-default',
});

export const arbitrumGoerliMantleGoerliLnBridge = new BridgeBase(
arbitrumGoerliConfig,
mantleGoerliConfig,
arbitrumGoerliMantleGoerliConfig,
{
name: 'arbitrum-mantle',
category: 'lnbridgev20-default',
}
);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './bridge';
1 change: 1 addition & 0 deletions packages/apps/bridges/lnbridge/arbitrum-mantle/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './Arbitrum2MantleLnBridge';
21 changes: 21 additions & 0 deletions packages/apps/bridges/lnbridge/arbitrum-mantle/model/bridge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { BridgeConfig } from 'shared/model';
import { ContractConfig } from 'shared/model';
import { CrossToken, DVMChainConfig } from 'shared/model';
import { Bridge } from '../../../../core/bridge';
import { CrossChainPayload } from '../../../../model/tx';

type ArbitrumMantleContractConfig = ContractConfig;

export type ArbitrumMantleBridgeConfig = Required<BridgeConfig<ArbitrumMantleContractConfig>>;

export type IssuingPayload = CrossChainPayload<
Bridge<ArbitrumMantleBridgeConfig, DVMChainConfig, DVMChainConfig>,
CrossToken<DVMChainConfig>,
CrossToken<DVMChainConfig>
>;

export type RedeemPayload = CrossChainPayload<
Bridge<ArbitrumMantleBridgeConfig, DVMChainConfig, DVMChainConfig>,
CrossToken<DVMChainConfig>,
CrossToken<DVMChainConfig>
>;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './bridge';
17 changes: 17 additions & 0 deletions packages/apps/bridges/lnbridge/arbitrum-mantle/utils/bridge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { BN } from '@polkadot/util';
import { DVMChainConfig, Tx } from 'shared/model';
import { Observable } from 'rxjs';
import { IssuingPayload, RedeemPayload, ArbitrumMantleBridgeConfig } from '../model';
import { LnBridgeBridge } from '../../lnbridge/utils/bridge';

export class ArbitrumMantleBridge extends LnBridgeBridge<ArbitrumMantleBridgeConfig, DVMChainConfig, DVMChainConfig> {
static readonly alias: string = 'ArbitrumMantleLnBridge';

back(payload: IssuingPayload, fee: BN): Observable<Tx> {
return this.send(payload, fee);
}

burn(payload: RedeemPayload, fee: BN): Observable<Tx> {
return this.send(payload, fee);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './bridge';
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const ethereumLineaConfig: EthereumLineaBridgeConfig = {

const goerliLineaGoerliConfig: EthereumLineaBridgeConfig = {
contracts: {
backing: '0x5A351EA4F4128F58EA13DDa52E3d1842c0b3B690',
issuing: '0xeA5f0a09A8723444965FDd6f76523C338faB00f7',
backing: '0x54cc9716905ba8ebdD01E6364125cA338Cd0054E',
issuing: '',
},
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { CrossToken, DVMChainConfig } from 'shared/model';
import { Bridge } from '../../../components/bridge/Bridge';
import { CrossChainComponentProps } from '../../../model/component';
import { EthereumMantleBridge } from './utils/bridge';

export function Ethereum2MantleLnBridge(
props: CrossChainComponentProps<EthereumMantleBridge, CrossToken<DVMChainConfig>, CrossToken<DVMChainConfig>>
) {
return <Bridge {...props} hideRecipient />;
}
27 changes: 27 additions & 0 deletions packages/apps/bridges/lnbridge/ethereum-mantle/config/bridge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { mantleConfig, ethereumConfig, mantleGoerliConfig, goerliConfig } from 'shared/config/network';
import { BridgeBase } from 'shared/core/bridge';
import { EthereumMantleBridgeConfig } from '../model';

const ethereumMantleConfig: EthereumMantleBridgeConfig = {
contracts: {
backing: '',
issuing: '',
},
};

const goerliMantleGoerliConfig: EthereumMantleBridgeConfig = {
contracts: {
backing: '0x54cc9716905ba8ebdD01E6364125cA338Cd0054E',
issuing: '',
},
};

export const ethereumMantleLnBridge = new BridgeBase(ethereumConfig, mantleConfig, ethereumMantleConfig, {
name: 'ethereum-mantle',
category: 'lnbridgev20-default',
});

export const goerliMantleGoerliLnBridge = new BridgeBase(goerliConfig, mantleGoerliConfig, goerliMantleGoerliConfig, {
name: 'ethereum-mantle',
category: 'lnbridgev20-default',
});
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './bridge';
1 change: 1 addition & 0 deletions packages/apps/bridges/lnbridge/ethereum-mantle/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './Ethereum2MantleLnBridge';
21 changes: 21 additions & 0 deletions packages/apps/bridges/lnbridge/ethereum-mantle/model/bridge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { BridgeConfig } from 'shared/model';
import { ContractConfig } from 'shared/model';
import { CrossToken, DVMChainConfig } from 'shared/model';
import { Bridge } from '../../../../core/bridge';
import { CrossChainPayload } from '../../../../model/tx';

type EthereumMantleContractConfig = ContractConfig;

export type EthereumMantleBridgeConfig = Required<BridgeConfig<EthereumMantleContractConfig>>;

export type IssuingPayload = CrossChainPayload<
Bridge<EthereumMantleBridgeConfig, DVMChainConfig, DVMChainConfig>,
CrossToken<DVMChainConfig>,
CrossToken<DVMChainConfig>
>;

export type RedeemPayload = CrossChainPayload<
Bridge<EthereumMantleBridgeConfig, DVMChainConfig, DVMChainConfig>,
CrossToken<DVMChainConfig>,
CrossToken<DVMChainConfig>
>;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './bridge';
17 changes: 17 additions & 0 deletions packages/apps/bridges/lnbridge/ethereum-mantle/utils/bridge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { BN } from '@polkadot/util';
import { DVMChainConfig, Tx } from 'shared/model';
import { Observable } from 'rxjs';
import { IssuingPayload, RedeemPayload, EthereumMantleBridgeConfig } from '../model';
import { LnBridgeBridge } from '../../lnbridge/utils/bridge';

export class EthereumMantleBridge extends LnBridgeBridge<EthereumMantleBridgeConfig, DVMChainConfig, DVMChainConfig> {
static readonly alias: string = 'EthereumMantleLnBridge';

back(payload: IssuingPayload, fee: BN): Observable<Tx> {
return this.send(payload, fee);
}

burn(payload: RedeemPayload, fee: BN): Observable<Tx> {
return this.send(payload, fee);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './bridge';
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const lineaEthereumConfig: LineaEthereumBridgeConfig = {

const lineaGoerliGoerliConfig: LineaEthereumBridgeConfig = {
contracts: {
backing: '0x9C80EdD342b5D179c3a87946fC1F0963BfcaAa09',
issuing: '0x91bdd735Dc214876605C18A57C7841CFF7eE959a',
backing: '0x79e6f452f1e491a7aF0382FA0a6EF9368691960D',
issuing: '',
},
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { CrossToken, DVMChainConfig } from 'shared/model';
import { Bridge } from '../../../components/bridge/Bridge';
import { CrossChainComponentProps } from '../../../model/component';
import { LineaMantleBridge } from './utils/bridge';

export function Linea2MantleLnBridge(
props: CrossChainComponentProps<LineaMantleBridge, CrossToken<DVMChainConfig>, CrossToken<DVMChainConfig>>
) {
return <Bridge {...props} hideRecipient />;
}
32 changes: 32 additions & 0 deletions packages/apps/bridges/lnbridge/linea-mantle/config/bridge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { lineaConfig, mantleConfig, lineaGoerliConfig, mantleGoerliConfig } from 'shared/config/network';
import { BridgeBase } from 'shared/core/bridge';
import { LineaMantleBridgeConfig } from '../model';

const lineaMantleConfig: LineaMantleBridgeConfig = {
contracts: {
backing: '',
issuing: '',
},
};

const lineaGoerliMantleGoerliConfig: LineaMantleBridgeConfig = {
contracts: {
backing: '0x54cc9716905ba8ebdD01E6364125cA338Cd0054E',
issuing: '',
},
};

export const lineaMantleLnBridge = new BridgeBase(lineaConfig, mantleConfig, lineaMantleConfig, {
name: 'linea-mantle',
category: 'lnbridgev20-default',
});

export const lineaGoerliMantleGoerliLnBridge = new BridgeBase(
lineaGoerliConfig,
mantleGoerliConfig,
lineaGoerliMantleGoerliConfig,
{
name: 'linea-mantle',
category: 'lnbridgev20-default',
}
);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './bridge';
1 change: 1 addition & 0 deletions packages/apps/bridges/lnbridge/linea-mantle/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './Linea2MantleLnBridge';
21 changes: 21 additions & 0 deletions packages/apps/bridges/lnbridge/linea-mantle/model/bridge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { BridgeConfig } from 'shared/model';
import { ContractConfig } from 'shared/model';
import { CrossToken, DVMChainConfig } from 'shared/model';
import { Bridge } from '../../../../core/bridge';
import { CrossChainPayload } from '../../../../model/tx';

type LineaMantleContractConfig = ContractConfig;

export type LineaMantleBridgeConfig = Required<BridgeConfig<LineaMantleContractConfig>>;

export type IssuingPayload = CrossChainPayload<
Bridge<LineaMantleBridgeConfig, DVMChainConfig, DVMChainConfig>,
CrossToken<DVMChainConfig>,
CrossToken<DVMChainConfig>
>;

export type RedeemPayload = CrossChainPayload<
Bridge<LineaMantleBridgeConfig, DVMChainConfig, DVMChainConfig>,
CrossToken<DVMChainConfig>,
CrossToken<DVMChainConfig>
>;
1 change: 1 addition & 0 deletions packages/apps/bridges/lnbridge/linea-mantle/model/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './bridge';
17 changes: 17 additions & 0 deletions packages/apps/bridges/lnbridge/linea-mantle/utils/bridge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { BN } from '@polkadot/util';
import { DVMChainConfig, Tx } from 'shared/model';
import { Observable } from 'rxjs';
import { IssuingPayload, RedeemPayload, LineaMantleBridgeConfig } from '../model';
import { LnBridgeBridge } from '../../lnbridge/utils/bridge';

export class LineaMantleBridge extends LnBridgeBridge<LineaMantleBridgeConfig, DVMChainConfig, DVMChainConfig> {
static readonly alias: string = 'LineaMantleLnBridge';

back(payload: IssuingPayload, fee: BN): Observable<Tx> {
return this.send(payload, fee);
}

burn(payload: RedeemPayload, fee: BN): Observable<Tx> {
return this.send(payload, fee);
}
}
1 change: 1 addition & 0 deletions packages/apps/bridges/lnbridge/linea-mantle/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './bridge';
Loading
Loading