diff --git a/.changeset/great-kings-mix.md b/.changeset/great-kings-mix.md new file mode 100644 index 00000000..8b02b083 --- /dev/null +++ b/.changeset/great-kings-mix.md @@ -0,0 +1,6 @@ +--- +"@polkadex/thea": minor +"@polkadex/ux": minor +--- + +Added a new enum for ChainType and minor UI fix diff --git a/packages/thea/src/config/substrate/config/polkadex.ts b/packages/thea/src/config/substrate/config/polkadex.ts index 11141f82..ec272fe0 100644 --- a/packages/thea/src/config/substrate/config/polkadex.ts +++ b/packages/thea/src/config/substrate/config/polkadex.ts @@ -152,7 +152,7 @@ const toAstar: AssetConfig[] = [ balance: BalanceBuilder().substrate().assets().account(), destination: astar, destinationFee: { - amount: 0, // TODO: Change it later + amount: 0.05, asset: astr, balance: BalanceBuilder().substrate().system().account(), }, diff --git a/packages/thea/src/config/substrate/helpers.ts b/packages/thea/src/config/substrate/helpers.ts index 965d4b12..3234e0da 100644 --- a/packages/thea/src/config/substrate/helpers.ts +++ b/packages/thea/src/config/substrate/helpers.ts @@ -1,4 +1,8 @@ -import { AnyChain, ChainAssetsData } from "@moonbeam-network/xcm-types"; +import { + AnyChain, + ChainAssetsData, + ChainType as MoonbeamChainType, +} from "@moonbeam-network/xcm-types"; import { Asset, ChainType, Chain } from "../types"; @@ -8,7 +12,10 @@ export const changeSubstrateToBaseChain = (chain: AnyChain): Chain => ({ genesis: chain.genesisHash, logo: chain.name, name: chain.name, - type: ChainType.Substrate, + type: + chain.type === MoonbeamChainType.EvmParachain + ? ChainType.EvmSubstrate + : ChainType.Substrate, isTestnet: chain.isTestChain, }); diff --git a/packages/thea/src/config/types.ts b/packages/thea/src/config/types.ts index a8ea7d39..8fa77ba1 100644 --- a/packages/thea/src/config/types.ts +++ b/packages/thea/src/config/types.ts @@ -1,5 +1,6 @@ export enum ChainType { Substrate, + EvmSubstrate, Evm, } diff --git a/packages/thea/src/sdk/substrate/assetHub.ts b/packages/thea/src/sdk/substrate/assetHub.ts index 37c9c2d0..60015046 100644 --- a/packages/thea/src/sdk/substrate/assetHub.ts +++ b/packages/thea/src/sdk/substrate/assetHub.ts @@ -132,6 +132,14 @@ export class AssetHub implements BaseChainAdapter { ), }; + const sourceFeeExistential: AssetAmount = { + ticker: transferConfig.source.existentialDeposit.originSymbol, + amount: +Utils.formatUnits( + transferConfig.source.existentialDeposit.amount, + transferConfig.source.existentialDeposit.decimals + ), + }; + const destinationFee: AssetAmount = { ticker: transferConfig.destination.fee.originSymbol, amount: +Utils.formatUnits( @@ -157,6 +165,7 @@ export class AssetHub implements BaseChainAdapter { destinationFee, sourceFeeBalance, destinationFeeBalance, + sourceFeeExistential, transfer: async (amount: number): Promise => { const api = await getPolkadotApi(this.chain.ws); diff --git a/packages/thea/src/sdk/substrate/astar.ts b/packages/thea/src/sdk/substrate/astar.ts index a5317801..1e3de344 100644 --- a/packages/thea/src/sdk/substrate/astar.ts +++ b/packages/thea/src/sdk/substrate/astar.ts @@ -132,6 +132,14 @@ export class Astar implements BaseChainAdapter { ), }; + const sourceFeeExistential: AssetAmount = { + ticker: transferConfig.source.existentialDeposit.originSymbol, + amount: +Utils.formatUnits( + transferConfig.source.existentialDeposit.amount, + transferConfig.source.existentialDeposit.decimals + ), + }; + const destinationFee: AssetAmount = { ticker: transferConfig.destination.fee.originSymbol, amount: +Utils.formatUnits( @@ -157,6 +165,7 @@ export class Astar implements BaseChainAdapter { destinationFee, sourceFeeBalance, destinationFeeBalance, + sourceFeeExistential, transfer: async (amount: number): Promise => { const api = await getPolkadotApi(this.chain.ws); diff --git a/packages/thea/src/sdk/substrate/bifrost.ts b/packages/thea/src/sdk/substrate/bifrost.ts index b77519d5..4265cb0b 100644 --- a/packages/thea/src/sdk/substrate/bifrost.ts +++ b/packages/thea/src/sdk/substrate/bifrost.ts @@ -132,6 +132,14 @@ export class Bifrost implements BaseChainAdapter { ), }; + const sourceFeeExistential: AssetAmount = { + ticker: transferConfig.source.existentialDeposit.originSymbol, + amount: +Utils.formatUnits( + transferConfig.source.existentialDeposit.amount, + transferConfig.source.existentialDeposit.decimals + ), + }; + const destinationFee: AssetAmount = { ticker: transferConfig.destination.fee.originSymbol, amount: +Utils.formatUnits( @@ -157,6 +165,7 @@ export class Bifrost implements BaseChainAdapter { destinationFee, sourceFeeBalance, destinationFeeBalance, + sourceFeeExistential, transfer: async (amount: number): Promise => { const api = await getPolkadotApi(this.chain.ws); diff --git a/packages/thea/src/sdk/substrate/interlay.ts b/packages/thea/src/sdk/substrate/interlay.ts index f94f85d8..2b676a1b 100644 --- a/packages/thea/src/sdk/substrate/interlay.ts +++ b/packages/thea/src/sdk/substrate/interlay.ts @@ -132,6 +132,14 @@ export class Interlay implements BaseChainAdapter { ), }; + const sourceFeeExistential: AssetAmount = { + ticker: transferConfig.source.existentialDeposit.originSymbol, + amount: +Utils.formatUnits( + transferConfig.source.existentialDeposit.amount, + transferConfig.source.existentialDeposit.decimals + ), + }; + const destinationFee: AssetAmount = { ticker: transferConfig.destination.fee.originSymbol, amount: +Utils.formatUnits( @@ -157,6 +165,7 @@ export class Interlay implements BaseChainAdapter { destinationFee, sourceFeeBalance, destinationFeeBalance, + sourceFeeExistential, transfer: async (amount: number): Promise => { const api = await getPolkadotApi(this.chain.ws); diff --git a/packages/thea/src/sdk/substrate/moonbeam.ts b/packages/thea/src/sdk/substrate/moonbeam.ts index 77ad3299..9f7d32d1 100644 --- a/packages/thea/src/sdk/substrate/moonbeam.ts +++ b/packages/thea/src/sdk/substrate/moonbeam.ts @@ -132,6 +132,14 @@ export class Moonbeam implements BaseChainAdapter { ), }; + const sourceFeeExistential: AssetAmount = { + ticker: transferConfig.source.existentialDeposit.originSymbol, + amount: +Utils.formatUnits( + transferConfig.source.existentialDeposit.amount, + transferConfig.source.existentialDeposit.decimals + ), + }; + const destinationFee: AssetAmount = { ticker: transferConfig.destination.fee.originSymbol, amount: +Utils.formatUnits( @@ -157,6 +165,7 @@ export class Moonbeam implements BaseChainAdapter { destinationFee, sourceFeeBalance, destinationFeeBalance, + sourceFeeExistential, transfer: async (amount: number): Promise => { const api = await getPolkadotApi(this.chain.ws); diff --git a/packages/thea/src/sdk/substrate/phala.ts b/packages/thea/src/sdk/substrate/phala.ts index c8311186..fc8abc64 100644 --- a/packages/thea/src/sdk/substrate/phala.ts +++ b/packages/thea/src/sdk/substrate/phala.ts @@ -132,6 +132,14 @@ export class Phala implements BaseChainAdapter { ), }; + const sourceFeeExistential: AssetAmount = { + ticker: transferConfig.source.existentialDeposit.originSymbol, + amount: +Utils.formatUnits( + transferConfig.source.existentialDeposit.amount, + transferConfig.source.existentialDeposit.decimals + ), + }; + const destinationFee: AssetAmount = { ticker: transferConfig.destination.fee.originSymbol, amount: +Utils.formatUnits( @@ -157,6 +165,7 @@ export class Phala implements BaseChainAdapter { destinationFee, sourceFeeBalance, destinationFeeBalance, + sourceFeeExistential, transfer: async (amount: number): Promise => { const api = await getPolkadotApi(this.chain.ws); diff --git a/packages/thea/src/sdk/substrate/polkadex.ts b/packages/thea/src/sdk/substrate/polkadex.ts index 551aca1b..0ff581c8 100644 --- a/packages/thea/src/sdk/substrate/polkadex.ts +++ b/packages/thea/src/sdk/substrate/polkadex.ts @@ -132,6 +132,14 @@ export class Polkadex implements BaseChainAdapter { ), }; + const sourceFeeExistential: AssetAmount = { + ticker: transferConfig.source.existentialDeposit.originSymbol, + amount: +Utils.formatUnits( + transferConfig.source.existentialDeposit.amount, + transferConfig.source.existentialDeposit.decimals + ), + }; + const destinationFee: AssetAmount = { ticker: transferConfig.destination.fee.originSymbol, amount: +Utils.formatUnits( @@ -157,6 +165,7 @@ export class Polkadex implements BaseChainAdapter { destinationFee, sourceFeeBalance, destinationFeeBalance, + sourceFeeExistential, transfer: async (amount: number): Promise => { const api = await getPolkadotApi(this.chain.ws); diff --git a/packages/thea/src/sdk/substrate/polkadot.ts b/packages/thea/src/sdk/substrate/polkadot.ts index e982073d..9e4c156e 100644 --- a/packages/thea/src/sdk/substrate/polkadot.ts +++ b/packages/thea/src/sdk/substrate/polkadot.ts @@ -132,6 +132,14 @@ export class Polkadot implements BaseChainAdapter { ), }; + const sourceFeeExistential: AssetAmount = { + ticker: transferConfig.source.existentialDeposit.originSymbol, + amount: +Utils.formatUnits( + transferConfig.source.existentialDeposit.amount, + transferConfig.source.existentialDeposit.decimals + ), + }; + const destinationFee: AssetAmount = { ticker: transferConfig.destination.fee.originSymbol, amount: +Utils.formatUnits( @@ -157,6 +165,7 @@ export class Polkadot implements BaseChainAdapter { destinationFee, sourceFeeBalance, destinationFeeBalance, + sourceFeeExistential, transfer: async (amount: number): Promise => { const api = await getPolkadotApi(this.chain.ws); diff --git a/packages/thea/src/sdk/substrate/unique.ts b/packages/thea/src/sdk/substrate/unique.ts index f78f879f..501ee068 100644 --- a/packages/thea/src/sdk/substrate/unique.ts +++ b/packages/thea/src/sdk/substrate/unique.ts @@ -132,6 +132,14 @@ export class Unique implements BaseChainAdapter { ), }; + const sourceFeeExistential: AssetAmount = { + ticker: transferConfig.source.existentialDeposit.originSymbol, + amount: +Utils.formatUnits( + transferConfig.source.existentialDeposit.amount, + transferConfig.source.existentialDeposit.decimals + ), + }; + const destinationFee: AssetAmount = { ticker: transferConfig.destination.fee.originSymbol, amount: +Utils.formatUnits( @@ -157,6 +165,7 @@ export class Unique implements BaseChainAdapter { destinationFee, sourceFeeBalance, destinationFeeBalance, + sourceFeeExistential, transfer: async (amount: number): Promise => { const api = await getPolkadotApi(this.chain.ws); diff --git a/packages/thea/src/sdk/types.ts b/packages/thea/src/sdk/types.ts index 17894413..d6842322 100644 --- a/packages/thea/src/sdk/types.ts +++ b/packages/thea/src/sdk/types.ts @@ -11,8 +11,9 @@ export type TransferConfig = { min: AssetAmount; max: AssetAmount; sourceFee: AssetAmount; - destinationFee: AssetAmount; sourceFeeBalance: AssetAmount; + sourceFeeExistential: AssetAmount; + destinationFee: AssetAmount; destinationFeeBalance: AssetAmount; // Do the actual transfer diff --git a/packages/ui/src/components/input.tsx b/packages/ui/src/components/input.tsx index 1db8bbae..4916e331 100644 --- a/packages/ui/src/components/input.tsx +++ b/packages/ui/src/components/input.tsx @@ -87,7 +87,7 @@ const Primary = forwardRef, InputWithContainerProps>( {...containerProps} >
-
+
{LabelComponent}