Skip to content

Commit

Permalink
feat: getFloatDetails() returns fee too
Browse files Browse the repository at this point in the history
  • Loading branch information
sbp-rib committed Mar 12, 2021
1 parent 3cb1561 commit a151e19
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/modules/generic-details/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ type ReturnType<R extends SkybridgeResource, M extends SkybridgeMode> = Pick<
| 'hash'
| 'status'
| 'timestamp'
| 'feeTotal'
| 'feeCurrency'
> & {
txDepositId: SkybridgeParams<R, M>['txDepositId'] | null;
txReceivingId: SkybridgeParams<R, M>['txReceivingId'] | null;
} & (R extends 'pool' ? {} : Pick<SkybridgeParams<R, M>, 'feeTotal' | 'feeCurrency'>);
};

const bridgeCache = new Map<string, SkybridgeBridge>();

Expand Down Expand Up @@ -104,17 +106,7 @@ export const getDetails = async <R extends SkybridgeResource, M extends Skybridg
throw new Error(`"${hash}" is not a withdrawal, it is a swap.`);
}

const fees =
resource === 'pool'
? {}
: {
feeCurrency:
((result.feeCurrency as any) === 'BTCE' ? 'WBTC' : result.feeCurrency) || null,
feeTotal: result.fee,
};

return ({
...fees,
addressReceiving: result.addressOut,
addressDeposit: result.addressDeposit,
amountDeposit: result.amountIn,
Expand All @@ -127,5 +119,7 @@ export const getDetails = async <R extends SkybridgeResource, M extends Skybridg
txDepositId: result.txIdIn || null,
txReceivingId: result.txIdOut || null,
timestamp: new Date(result.timestamp * 1000),
feeCurrency: ((result.feeCurrency as any) === 'BTCE' ? 'WBTC' : result.feeCurrency) || null,
feeTotal: result.fee,
} as unknown) as ReturnType<R, M>;
};

0 comments on commit a151e19

Please sign in to comment.