-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add moonChainFee and separate MrlChainRoute from ChainRoute
- Loading branch information
Showing
15 changed files
with
167 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
import type { ChainRoutes } from '../types/ChainRoutes'; | ||
import type { MrlChainRoutes } from '../types/MrlChainRoutes'; | ||
import { fantomTestnetRoutes } from './fantomTestnet'; | ||
import { moonbaseAlphaRoutes } from './moonbaseAlpha'; | ||
import { moonbaseBetaRoutes } from './moonbaseBeta'; | ||
import { peaqAlphanetRoutes } from './peaqAlphanet'; | ||
import { peaqEvmAlphanetRoutes } from './peaqEvmAlphanet'; | ||
|
||
export const mrlRoutesList: ChainRoutes[] = [ | ||
export const mrlRoutesList: MrlChainRoutes[] = [ | ||
fantomTestnetRoutes, | ||
moonbaseAlphaRoutes, | ||
moonbaseBetaRoutes, | ||
peaqAlphanetRoutes, | ||
peaqEvmAlphanetRoutes, | ||
]; | ||
|
||
export const mrlRoutesMap = new Map<string, ChainRoutes>( | ||
export const mrlRoutesMap = new Map<string, MrlChainRoutes>( | ||
mrlRoutesList.map((config) => [config.chain.key, config]), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import type { BalanceConfigBuilder } from '@moonbeam-network/xcm-builder'; | ||
import type { Asset } from '@moonbeam-network/xcm-types'; | ||
import { | ||
AssetRoute, | ||
type AssetRouteConstructorParams, | ||
type SourceConfig, | ||
} from './AssetRoute'; | ||
|
||
export interface MrlAssetRouteConstructorParams | ||
extends AssetRouteConstructorParams { | ||
source: MrlSourceConfig; | ||
} | ||
|
||
export interface MrlSourceConfig extends SourceConfig { | ||
moonChainFee?: { | ||
asset: Asset; | ||
balance: BalanceConfigBuilder; | ||
}; | ||
} | ||
|
||
export class MrlAssetRoute extends AssetRoute { | ||
readonly source: MrlSourceConfig; | ||
|
||
constructor({ | ||
source, | ||
destination, | ||
contract, | ||
extrinsic, | ||
mrl, | ||
}: MrlAssetRouteConstructorParams & { source: MrlSourceConfig }) { | ||
super({ source, destination, contract, extrinsic, mrl }); | ||
this.source = source; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { ChainRoutes, type ChainRoutesConstructorParams } from './ChainRoutes'; | ||
import { | ||
MrlAssetRoute, | ||
type MrlAssetRouteConstructorParams, | ||
type MrlSourceConfig, | ||
} from './MrlAssetRoute'; | ||
|
||
export interface MrlChainRoutesConstructorParams | ||
extends ChainRoutesConstructorParams { | ||
routes: MrlRoutesParam[]; | ||
} | ||
|
||
interface MrlRoutesParam | ||
extends Omit<MrlAssetRouteConstructorParams, 'source'> { | ||
source: Omit<MrlSourceConfig, 'chain'>; | ||
} | ||
|
||
export class MrlChainRoutes extends ChainRoutes { | ||
readonly #routes: Map<string, MrlAssetRoute>; | ||
|
||
constructor({ chain, routes }: MrlChainRoutesConstructorParams) { | ||
super({ chain, routes }); | ||
this.#routes = new Map( | ||
routes.map(({ source, destination, contract, extrinsic, mrl }) => [ | ||
`${source.asset.key}-${destination.chain.key}`, | ||
new MrlAssetRoute({ | ||
source: { ...source, chain }, | ||
destination, | ||
contract, | ||
extrinsic, | ||
mrl, | ||
}), | ||
]), | ||
); | ||
} | ||
|
||
getRoutes(): MrlAssetRoute[] { | ||
return Array.from(this.#routes.values()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters