Skip to content

Commit

Permalink
fix linter issues from sovereign account balance checking implementat…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
mmaurello committed Oct 16, 2024
1 parent f6238f4 commit af79815
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 25 deletions.
37 changes: 18 additions & 19 deletions packages/sdk/src/getTransferData/getDestinationData.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import type { AssetRoute, DestinationConfig, SourceConfig } from '@moonbeam-network/xcm-config';
import type {
AssetRoute,
DestinationConfig,
SourceConfig,
} from '@moonbeam-network/xcm-config';
import { Parachain } from '@moonbeam-network/xcm-types';
import { getSovereignAccountAddresses } from '@moonbeam-network/xcm-utils';
import type { DestinationChainTransferData } from '../sdk.interfaces';
import {
getAssetMin,
getBalance,
getDestinationFee,
getExistentialDeposit,
} from './getTransferData.utils';
import {
getSovereignAccountAddresses,
} from '@moonbeam-network/xcm-utils';
import { Parachain } from '@moonbeam-network/xcm-types';

export interface GetDestinationDataParams {
route: AssetRoute;
Expand Down Expand Up @@ -48,34 +50,31 @@ export async function getDestinationData({
existentialDeposit,
fee,
min,
sovereignAccountBalances: await getSovereignAccountBalances({
source: route.source,
destination: route.destination,
}),
sovereignAccountBalances: await getSovereignAccountBalances({
source: route.source,
destination: route.destination,
}),
};

}

interface GetSovereignAccountBalancesProps {
source: SourceConfig;
destination: DestinationConfig;
source: SourceConfig;
destination: DestinationConfig;
}

async function getSovereignAccountBalances( {
async function getSovereignAccountBalances({
destination,
source,
}: GetSovereignAccountBalancesProps) {

if(!Parachain.is(source.chain) || !Parachain.is(destination.chain)) {
return undefined
if (!Parachain.is(source.chain) || !Parachain.is(destination.chain)) {
return undefined;
}

const sovereignAccountAddresses = getSovereignAccountAddresses(
source.chain.parachainId,
);

const destinationFeeAssetBalance =
destination.fee.balance;
const destinationFeeAssetBalance = destination.fee.balance;

const sovereignAccountAddress = destination.chain.isRelay
? sovereignAccountAddresses.relay
Expand All @@ -93,7 +92,7 @@ async function getSovereignAccountBalances( {
address: sovereignAccountAddress,
asset: destination.chain.getChainAsset(destination.fee.asset),
builder: destinationFeeAssetBalance,
chain: destination.chain,
chain: destination.chain,
})
: undefined;
return {
Expand Down
9 changes: 4 additions & 5 deletions packages/sdk/src/getTransferData/getTransferData.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ import {
} from '@moonbeam-network/xcm-types';
import { convertDecimals, toBigInt } from '@moonbeam-network/xcm-utils';
import Big from 'big.js';
import { EvmService } from '../services/evm/EvmService';
import { PolkadotService } from '../services/polkadot';
import {
import type {
DestinationChainTransferData,
SourceChainTransferData,
} from '../sdk.interfaces';

import { EvmService } from '../services/evm/EvmService';
import { PolkadotService } from '../services/polkadot';

export interface GetBalancesParams {
address: string;
Expand Down Expand Up @@ -355,7 +354,7 @@ export function validateSovereignAccountBalances({
destination,
}: ValidateSovereignAccountBalancesProps): void {
if (
!Parachain.is(destination.chain) ||
!Parachain.is(destination.chain) ||
!destination.chain.checkSovereignAccountBalances ||
!destination.sovereignAccountBalances
) {
Expand Down
1 change: 0 additions & 1 deletion packages/types/src/chain/parachain/Parachain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export interface ParachainConstructorParams extends ChainConstructorParams {
}

export class Parachain extends Chain {

readonly checkSovereignAccountBalances: boolean;

readonly genesisHash: string;
Expand Down

0 comments on commit af79815

Please sign in to comment.