@swype-org/react-sdk 0.1.219 → 0.1.220
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +31 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +31 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -94,7 +94,7 @@ interface Amount {
|
|
|
94
94
|
/** Transfer destination in a response */
|
|
95
95
|
interface TransferDestination {
|
|
96
96
|
id: string;
|
|
97
|
-
chainId:
|
|
97
|
+
chainId: number;
|
|
98
98
|
address: string;
|
|
99
99
|
token: {
|
|
100
100
|
address: string;
|
|
@@ -167,7 +167,7 @@ interface SourceSelection {
|
|
|
167
167
|
}
|
|
168
168
|
/** Destination input provided by the host app */
|
|
169
169
|
interface Destination {
|
|
170
|
-
chainId:
|
|
170
|
+
chainId: number;
|
|
171
171
|
address: string;
|
|
172
172
|
token: {
|
|
173
173
|
address: string;
|
|
@@ -308,7 +308,7 @@ declare function useBlinkDepositAmount(): {
|
|
|
308
308
|
setAmount: (amount: number | null) => void;
|
|
309
309
|
};
|
|
310
310
|
|
|
311
|
-
declare function fetchProviders(apiBaseUrl: string, token
|
|
311
|
+
declare function fetchProviders(apiBaseUrl: string, token?: string | null): Promise<Provider[]>;
|
|
312
312
|
declare function fetchChains(apiBaseUrl: string, token: string): Promise<Chain[]>;
|
|
313
313
|
declare function fetchAccounts(apiBaseUrl: string, token: string, credentialId: string): Promise<Account[]>;
|
|
314
314
|
declare function fetchAccount(apiBaseUrl: string, token: string, accountId: string, credentialId: string): Promise<Account>;
|
|
@@ -389,7 +389,7 @@ interface CreateGuestTransferParams {
|
|
|
389
389
|
id?: string;
|
|
390
390
|
merchantAuthorization: MerchantAuthorization;
|
|
391
391
|
destinations: Array<{
|
|
392
|
-
chainId:
|
|
392
|
+
chainId: number;
|
|
393
393
|
token: {
|
|
394
394
|
address: string;
|
|
395
395
|
};
|
|
@@ -428,7 +428,7 @@ declare function getTransferByGuestToken(apiBaseUrl: string, guestToken: string)
|
|
|
428
428
|
* Set the sender's wallet address and selected source token on a guest transfer.
|
|
429
429
|
* PUT /v1/transfers/:id/sender
|
|
430
430
|
*/
|
|
431
|
-
declare function setTransferSender(apiBaseUrl: string, transferId: string, guestSessionToken: string, senderAddress: string, sourceChainId:
|
|
431
|
+
declare function setTransferSender(apiBaseUrl: string, transferId: string, guestSessionToken: string, senderAddress: string, sourceChainId: number, sourceToken: string): Promise<Transfer>;
|
|
432
432
|
/**
|
|
433
433
|
* Submit the origin chain tx hash for a guest transfer.
|
|
434
434
|
* PATCH /v1/transfers/:id with { originTxHash }
|
|
@@ -441,7 +441,7 @@ declare function signGuestTransfer(apiBaseUrl: string, transferId: string, guest
|
|
|
441
441
|
declare function getGuestTransfer(apiBaseUrl: string, transferId: string, guestSessionToken: string): Promise<Transfer>;
|
|
442
442
|
/** Balance option returned by the guest transfer balances endpoint. */
|
|
443
443
|
interface GuestBalanceOption extends SourceOption {
|
|
444
|
-
sourceChainId:
|
|
444
|
+
sourceChainId: number;
|
|
445
445
|
}
|
|
446
446
|
/**
|
|
447
447
|
* Fetch stablecoin balances for a wallet address, scoped to a guest transfer.
|
package/dist/index.d.ts
CHANGED
|
@@ -94,7 +94,7 @@ interface Amount {
|
|
|
94
94
|
/** Transfer destination in a response */
|
|
95
95
|
interface TransferDestination {
|
|
96
96
|
id: string;
|
|
97
|
-
chainId:
|
|
97
|
+
chainId: number;
|
|
98
98
|
address: string;
|
|
99
99
|
token: {
|
|
100
100
|
address: string;
|
|
@@ -167,7 +167,7 @@ interface SourceSelection {
|
|
|
167
167
|
}
|
|
168
168
|
/** Destination input provided by the host app */
|
|
169
169
|
interface Destination {
|
|
170
|
-
chainId:
|
|
170
|
+
chainId: number;
|
|
171
171
|
address: string;
|
|
172
172
|
token: {
|
|
173
173
|
address: string;
|
|
@@ -308,7 +308,7 @@ declare function useBlinkDepositAmount(): {
|
|
|
308
308
|
setAmount: (amount: number | null) => void;
|
|
309
309
|
};
|
|
310
310
|
|
|
311
|
-
declare function fetchProviders(apiBaseUrl: string, token
|
|
311
|
+
declare function fetchProviders(apiBaseUrl: string, token?: string | null): Promise<Provider[]>;
|
|
312
312
|
declare function fetchChains(apiBaseUrl: string, token: string): Promise<Chain[]>;
|
|
313
313
|
declare function fetchAccounts(apiBaseUrl: string, token: string, credentialId: string): Promise<Account[]>;
|
|
314
314
|
declare function fetchAccount(apiBaseUrl: string, token: string, accountId: string, credentialId: string): Promise<Account>;
|
|
@@ -389,7 +389,7 @@ interface CreateGuestTransferParams {
|
|
|
389
389
|
id?: string;
|
|
390
390
|
merchantAuthorization: MerchantAuthorization;
|
|
391
391
|
destinations: Array<{
|
|
392
|
-
chainId:
|
|
392
|
+
chainId: number;
|
|
393
393
|
token: {
|
|
394
394
|
address: string;
|
|
395
395
|
};
|
|
@@ -428,7 +428,7 @@ declare function getTransferByGuestToken(apiBaseUrl: string, guestToken: string)
|
|
|
428
428
|
* Set the sender's wallet address and selected source token on a guest transfer.
|
|
429
429
|
* PUT /v1/transfers/:id/sender
|
|
430
430
|
*/
|
|
431
|
-
declare function setTransferSender(apiBaseUrl: string, transferId: string, guestSessionToken: string, senderAddress: string, sourceChainId:
|
|
431
|
+
declare function setTransferSender(apiBaseUrl: string, transferId: string, guestSessionToken: string, senderAddress: string, sourceChainId: number, sourceToken: string): Promise<Transfer>;
|
|
432
432
|
/**
|
|
433
433
|
* Submit the origin chain tx hash for a guest transfer.
|
|
434
434
|
* PATCH /v1/transfers/:id with { originTxHash }
|
|
@@ -441,7 +441,7 @@ declare function signGuestTransfer(apiBaseUrl: string, transferId: string, guest
|
|
|
441
441
|
declare function getGuestTransfer(apiBaseUrl: string, transferId: string, guestSessionToken: string): Promise<Transfer>;
|
|
442
442
|
/** Balance option returned by the guest transfer balances endpoint. */
|
|
443
443
|
interface GuestBalanceOption extends SourceOption {
|
|
444
|
-
sourceChainId:
|
|
444
|
+
sourceChainId: number;
|
|
445
445
|
}
|
|
446
446
|
/**
|
|
447
447
|
* Fetch stablecoin balances for a wallet address, scoped to a guest transfer.
|
package/dist/index.js
CHANGED
|
@@ -488,9 +488,11 @@ async function throwApiError(res) {
|
|
|
488
488
|
throw new Error(`${res.status} \u2014 ${code}: ${msg}`);
|
|
489
489
|
}
|
|
490
490
|
async function fetchProviders(apiBaseUrl, token) {
|
|
491
|
-
const
|
|
492
|
-
|
|
493
|
-
|
|
491
|
+
const headers = {};
|
|
492
|
+
if (token) {
|
|
493
|
+
headers.Authorization = `Bearer ${token}`;
|
|
494
|
+
}
|
|
495
|
+
const res = await fetch(`${apiBaseUrl}/v1/providers`, { headers });
|
|
494
496
|
if (!res.ok) await throwApiError(res);
|
|
495
497
|
const data = await res.json();
|
|
496
498
|
return data.items;
|
|
@@ -7988,6 +7990,32 @@ function usePaymentEffects(deps) {
|
|
|
7988
7990
|
state.selectedAccountId,
|
|
7989
7991
|
depositAmount
|
|
7990
7992
|
]);
|
|
7993
|
+
useEffect(() => {
|
|
7994
|
+
if (authenticated || state.providers.length > 0) return;
|
|
7995
|
+
if (state.step !== "wallet-picker") return;
|
|
7996
|
+
let cancelled = false;
|
|
7997
|
+
const loadProviders = async () => {
|
|
7998
|
+
try {
|
|
7999
|
+
const providers = await fetchProviders(apiBaseUrl);
|
|
8000
|
+
if (cancelled) return;
|
|
8001
|
+
dispatch({
|
|
8002
|
+
type: "DATA_LOADED",
|
|
8003
|
+
providers,
|
|
8004
|
+
accounts: state.accounts,
|
|
8005
|
+
chains: state.chains,
|
|
8006
|
+
defaults: null
|
|
8007
|
+
});
|
|
8008
|
+
} catch (err) {
|
|
8009
|
+
if (!cancelled) {
|
|
8010
|
+
captureException(err);
|
|
8011
|
+
}
|
|
8012
|
+
}
|
|
8013
|
+
};
|
|
8014
|
+
loadProviders();
|
|
8015
|
+
return () => {
|
|
8016
|
+
cancelled = true;
|
|
8017
|
+
};
|
|
8018
|
+
}, [authenticated, state.step, state.providers.length, apiBaseUrl]);
|
|
7991
8019
|
useEffect(() => {
|
|
7992
8020
|
if (!polling.transfer) return;
|
|
7993
8021
|
if (polling.transfer.status === "COMPLETED") {
|