Skip to content

Commit

Permalink
rename properties
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaurello committed Oct 2, 2024
1 parent f04a877 commit 3d61e89
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions packages/builder/src/fee/FeeBuilder.interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export interface FeeConfigBuilderPrams {
address: string;
api: ApiPromise;
asset: ChainAsset;
chain: AnyParachain;
transferAsset: ChainAsset;
destination: AnyParachain;
feeAsset: ChainAsset;
}

export interface XcmPaymentFeeProps {
Expand Down
24 changes: 12 additions & 12 deletions packages/builder/src/fee/FeeBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,43 +34,43 @@ function xcmPaymentApi() {
address,
api,
asset,
chain,
transferAsset,
destination,
feeAsset,
}: FeeConfigBuilderPrams) =>
new SubstrateCallConfig({
api,
call: async (): Promise<bigint> => {
const versionedAssetId = await getVersionedAssetId(
const versionedFeeAssetId = await getVersionedAssetId(
api,
asset,
chain,
feeAsset,
destination,
);
const versionedTransferAssetId = await getVersionedAssetId(
api,
transferAsset,
chain,
asset,
destination,
);
const versionedAssets = shouldTransferAssetPrecedeFeeAsset
? [versionedTransferAssetId, versionedAssetId]
: [versionedAssetId, versionedTransferAssetId];
? [versionedTransferAssetId, versionedFeeAssetId]
: [versionedFeeAssetId, versionedTransferAssetId];

const assets =
asset === transferAsset ? [versionedAssetId] : versionedAssets;
feeAsset === asset ? [versionedFeeAssetId] : versionedAssets;

const instructions = [
isAssetReserveChain
? getWithdrawAssetInstruction(assets)
: getReserveAssetDepositedInstruction(assets),
getClearOriginInstruction(),
getBuyExecutionInstruction(versionedAssetId),
getBuyExecutionInstruction(versionedFeeAssetId),
getDepositAssetInstruction(address, assets),
getSetTopicInstruction(),
];

return getFeeForXcmInstructionsAndAsset(
api,
instructions,
versionedAssetId,
versionedFeeAssetId,
);
},
}),
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/getTransferData/getDestinationData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export async function getDestinationData({
const fee = await getDestinationFee({
address: destinationAddress,
asset: route.destination.fee.asset,
chain: destination,
destination,
fee: route.destination.fee.amount,
transferAsset: route.source.asset,
});
Expand Down
16 changes: 8 additions & 8 deletions packages/sdk/src/getTransferData/getTransferData.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,19 +157,19 @@ export function getMax({
export interface GetDestinationFeeParams {
address: string;
asset: Asset;
chain: AnyChain;
destination: AnyChain;
fee: number | FeeConfigBuilder;
transferAsset: Asset;
}

export async function getDestinationFee({
address,
asset,
chain,
destination,
fee,
transferAsset,
}: GetDestinationFeeParams): Promise<AssetAmount> {
const zero = AssetAmount.fromChainAsset(chain.getChainAsset(asset), {
const zero = AssetAmount.fromChainAsset(destination.getChainAsset(asset), {
amount: 0n,
});

Expand All @@ -179,14 +179,14 @@ export async function getDestinationFee({
});
}

if (EvmParachain.isAnyParachain(chain)) {
const polkadot = await PolkadotService.create(chain);
if (EvmParachain.isAnyParachain(destination)) {
const polkadot = await PolkadotService.create(destination);
const cfg = (fee as FeeConfigBuilder).build({
address,
api: polkadot.api,
asset: chain.getChainAsset(asset),
chain,
transferAsset: chain.getChainAsset(transferAsset),
asset: destination.getChainAsset(transferAsset),
feeAsset: destination.getChainAsset(asset),
destination,
});

return zero.copyWith({
Expand Down

0 comments on commit 3d61e89

Please sign in to comment.