Skip to content

Commit

Permalink
feat: Added addressSending property to swap and float details
Browse files Browse the repository at this point in the history
  • Loading branch information
sbp-rib committed Mar 29, 2021
1 parent ccb5a0d commit 98cfc88
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/modules/common-params/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export type SkybridgeParams<
hash: string;
/** Address where the user will receive their funds after the swap. */
addressReceiving: string;
/** Address where the user sends funds from to start a swap. */
addressSending: string | null;
/** Address that users have to send funds to to initiate a swap. */
addressDeposit: string;
/** Amount that users type in the UI. */
Expand Down
2 changes: 2 additions & 0 deletions src/modules/generic-details/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type ReturnType<R extends SkybridgeResource, M extends SkybridgeMode> = Pick<
| 'timestamp'
| 'feeTotal'
| 'feeCurrency'
| 'addressSending'
> & {
txDepositId: SkybridgeParams<R, M>['txDepositId'] | null;
txReceivingId: SkybridgeParams<R, M>['txReceivingId'] | null;
Expand Down Expand Up @@ -109,6 +110,7 @@ export const getDetails = async <R extends SkybridgeResource, M extends Skybridg
return ({
addressReceiving: result.data.addressOut,
addressDeposit: result.data.addressDeposit,
addressSending: result.data.addressIn || null,
amountDeposit: result.data.amountIn,
amountReceiving: result.data.amountOut || null,
// Temporarily fixes API bug where it retuns `BTCE` instead of `WBTC`
Expand Down
17 changes: 10 additions & 7 deletions src/modules/withdrawal/getMinimumWithdrawal/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,28 @@ it.each<
Pick<SkybridgeParams<'withdrawal', 'test'>, 'amountDesired' | 'currencyReceiving'> & {
bridge: SkybridgeBridge;
},
{ minimumWithdrawal: string; minimumWithdrawalCurrency: SkybridgeCoin },
{ minimumWithdrawalCurrency: SkybridgeCoin },
]
>([
[
{ bridge: 'btc_erc', amountDesired: '0', currencyReceiving: 'BTC' },
{ minimumWithdrawal: '0.0003006', minimumWithdrawalCurrency: 'BTC' },
{ minimumWithdrawalCurrency: 'BTC' },
],
[
{ bridge: 'btc_erc', amountDesired: '0', currencyReceiving: 'WBTC' },
{ minimumWithdrawal: '0.0001503', minimumWithdrawalCurrency: 'WBTC' },
{ minimumWithdrawalCurrency: 'WBTC' },
],
[
{ bridge: 'btc_erc', amountDesired: '200', currencyReceiving: 'WBTC' },
{ minimumWithdrawal: '0.0001503', minimumWithdrawalCurrency: 'WBTC' },
{ minimumWithdrawalCurrency: 'WBTC' },
],
[
{ bridge: 'btc_bep20', amountDesired: '200', currencyReceiving: 'BTCB.BEP20' },
{ minimumWithdrawal: '0.00001503', minimumWithdrawalCurrency: 'BTCB.BEP20' },
{ minimumWithdrawalCurrency: 'BTCB.BEP20' },
],
[
{ bridge: 'btc_bep20', amountDesired: '200', currencyReceiving: 'BTC' },
{ minimumWithdrawal: '0.0002004', minimumWithdrawalCurrency: 'BTC' },
{ minimumWithdrawalCurrency: 'BTC' },
],
])(
'gets minimum withdrawal for %O',
Expand All @@ -48,6 +48,9 @@ it.each<
currencyReceiving,
});

return expect(result).toMatchObject(expected);
return expect(result).toMatchObject({
...expected,
minimumWithdrawal: expect.stringMatching(/\d+(\.\d+)?/),
});
},
);

0 comments on commit 98cfc88

Please sign in to comment.