Skip to content

Commit

Permalink
add promise api compatibility for getPolkadotXcmDeliveryFee (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
RomeroYang authored Feb 7, 2024
1 parent fb70e1c commit e65fe18
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@
"jest": "^28.1.1",
"typescript": "^4.7.4"
},
"stableVersion": "0.1.5-30"
"stableVersion": "0.1.5-31"
}
10 changes: 7 additions & 3 deletions src/utils/get-xcm-delivery-fee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,13 @@ export async function getPolkadotXcmDeliveryFee(
) as any;
const xcmBytes = exampleXcm.toU8a();

const deliveryFeeFactor: Codec = await firstValueFrom(
fromApi?.query.dmp.deliveryFeeFactor(BigInt(paraID)) as Observable<Codec>
);
const deliveryFeeFactor: Codec = await (fromApi?.type === "rxjs"
? firstValueFrom(
fromApi?.query.dmp.deliveryFeeFactor(
BigInt(paraID)
) as Observable<Codec>
)
: (fromApi?.query.dmp.deliveryFeeFactor(BigInt(paraID)) as Promise<Codec>));

const convDeliveryFeeFactor =
BigInt(deliveryFeeFactor.toString()) / BigInt(10 ** 18);
Expand Down

0 comments on commit e65fe18

Please sign in to comment.