Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ekenigs committed Jul 4, 2024
1 parent a154391 commit 40ebf17
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions packages/sdk/src/getTransferData/getSourceData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ export async function getSourceData({
});

const fee = await getFee({
balance,
chain,
contractConfig: contract,
contract,
extrinsic,
feeBalance,
feeConfig: config.fee,
polkadot,
sourceAddress,
Expand All @@ -117,8 +117,8 @@ export async function getSourceData({
}

export interface GetFeeParams {
balance: AssetAmount;
contractConfig?: ContractConfig;
feeBalance: AssetAmount;
contract?: ContractConfig;
chain: AnyChain;
extrinsic?: ExtrinsicConfig;
feeConfig?: FeeAssetConfig;
Expand All @@ -127,9 +127,9 @@ export interface GetFeeParams {
}

export async function getFee({
balance,
feeBalance,
chain,
contractConfig,
contract: contractConfig,
extrinsic,
feeConfig,
polkadot,
Expand All @@ -144,28 +144,28 @@ export async function getFee({
chain,
contractConfig,
) as TransferContractInterface;
const fee = await contract.getFee(balance.amount, sourceAddress);
const fee = await contract.getFee(feeBalance.amount, sourceAddress);

return balance.copyWith({ amount: fee });
return feeBalance.copyWith({ amount: fee });
}

const fee = await getExtrinsicFee(
balance,
feeBalance,
extrinsic as ExtrinsicConfig,
polkadot,
sourceAddress,
);

const extra = feeConfig?.extra
? toBigInt(feeConfig.extra, balance.decimals)
? toBigInt(feeConfig.extra, feeBalance.decimals)
: 0n;
const totalFee = fee + extra;

const converted = chain.usesChainDecimals
? convertDecimals(totalFee, polkadot.decimals, balance.decimals)
? convertDecimals(totalFee, polkadot.decimals, feeBalance.decimals)
: totalFee;

return balance.copyWith({ amount: converted });
return feeBalance.copyWith({ amount: converted });
}

export async function getExtrinsicFee(
Expand Down

0 comments on commit 40ebf17

Please sign in to comment.