@venlyfinance/react 0.1.0
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/AGENTS.md +23 -0
- package/CHANGELOG.md +12 -0
- package/LICENSE +20 -0
- package/README.md +129 -0
- package/dist/flows/four-eyes.d.ts +71 -0
- package/dist/flows/four-eyes.js +91 -0
- package/dist/flows/ramp-lifecycle.d.ts +96 -0
- package/dist/flows/ramp-lifecycle.js +148 -0
- package/dist/flows/staged-transfer.d.ts +114 -0
- package/dist/flows/staged-transfer.js +182 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +18 -0
- package/dist/keys.d.ts +20 -0
- package/dist/keys.js +20 -0
- package/dist/mutations.d.ts +123 -0
- package/dist/mutations.js +58 -0
- package/dist/provider.d.ts +66 -0
- package/dist/provider.js +98 -0
- package/dist/proxy.d.ts +39 -0
- package/dist/proxy.js +42 -0
- package/dist/queries.d.ts +200 -0
- package/dist/queries.js +91 -0
- package/dist/query-options.d.ts +244 -0
- package/dist/query-options.js +73 -0
- package/package.json +65 -0
package/dist/provider.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { createContext, createElement, useContext, useState, } from "react";
|
|
2
|
+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
3
|
+
import { FundflowClient, VenlyFinanceClient, } from "@venlyfinance/sdk";
|
|
4
|
+
import { VENLY_PROXY_SECRET_SENTINEL } from "./proxy.js";
|
|
5
|
+
const VenlyContext = createContext(null);
|
|
6
|
+
/**
|
|
7
|
+
* A secret is dangerous when it would actually be used: mock-mode options
|
|
8
|
+
* ignore credentials by construction, and the proxy sentinel is a
|
|
9
|
+
* placeholder the backend never honours. Everything else is a real secret.
|
|
10
|
+
*/
|
|
11
|
+
function armedSecret(options) {
|
|
12
|
+
if (!options || options.environment === "mock")
|
|
13
|
+
return undefined;
|
|
14
|
+
const secret = options.clientSecret;
|
|
15
|
+
return secret && secret !== VENLY_PROXY_SECRET_SENTINEL ? secret : undefined;
|
|
16
|
+
}
|
|
17
|
+
function buildClients(props) {
|
|
18
|
+
const environment = props.environment ?? "mock";
|
|
19
|
+
// Guard every path a secret can take into this component: the top-level
|
|
20
|
+
// prop AND the per-client options objects (the options path would
|
|
21
|
+
// otherwise short-circuit past a top-level-only check).
|
|
22
|
+
const secretInBrowser = typeof window !== "undefined" &&
|
|
23
|
+
Boolean((environment !== "mock" && props.clientSecret) ||
|
|
24
|
+
armedSecret(props.financeOptions) ||
|
|
25
|
+
armedSecret(props.fundflowOptions));
|
|
26
|
+
if (secretInBrowser) {
|
|
27
|
+
throw new Error("[@venlyfinance/react] Refusing to construct a credentialed client in the browser: " +
|
|
28
|
+
"a bundled clientSecret is full API access for anyone who opens devtools. " +
|
|
29
|
+
"Keep credentials behind your backend and pass proxyClientOptions(), " +
|
|
30
|
+
"or build the clients in server code and pass them via the `finance`/`fundflow` props.");
|
|
31
|
+
}
|
|
32
|
+
const finance = props.finance ??
|
|
33
|
+
new VenlyFinanceClient(props.financeOptions ??
|
|
34
|
+
(environment === "mock"
|
|
35
|
+
? { environment: "mock" }
|
|
36
|
+
: {
|
|
37
|
+
environment,
|
|
38
|
+
clientId: requireCredential(props.clientId, "clientId"),
|
|
39
|
+
clientSecret: requireCredential(props.clientSecret, "clientSecret"),
|
|
40
|
+
}));
|
|
41
|
+
const fundflow = props.fundflow ??
|
|
42
|
+
new FundflowClient(props.fundflowOptions ??
|
|
43
|
+
(environment === "mock"
|
|
44
|
+
? { environment: "mock" }
|
|
45
|
+
: {
|
|
46
|
+
environment,
|
|
47
|
+
clientId: requireCredential(props.clientId, "clientId"),
|
|
48
|
+
clientSecret: requireCredential(props.clientSecret, "clientSecret"),
|
|
49
|
+
}));
|
|
50
|
+
return { environment, finance, fundflow };
|
|
51
|
+
}
|
|
52
|
+
function requireCredential(value, name) {
|
|
53
|
+
if (!value) {
|
|
54
|
+
throw new Error(`[@venlyfinance/react] environment is not "mock" but no ${name} was provided. ` +
|
|
55
|
+
"Pass credentials (server-side only), proxyClientOptions(), or pre-built clients.");
|
|
56
|
+
}
|
|
57
|
+
return value;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Context provider for every hook in this package.
|
|
61
|
+
*
|
|
62
|
+
* ```tsx
|
|
63
|
+
* <VenlyProvider environment="mock">
|
|
64
|
+
* <App />
|
|
65
|
+
* </VenlyProvider>
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export function VenlyProvider(props) {
|
|
69
|
+
// Clients and the fallback QueryClient are constructed exactly once per
|
|
70
|
+
// provider instance; changing construction props requires a remount (key=).
|
|
71
|
+
const [clients] = useState(() => buildClients(props));
|
|
72
|
+
const [queryClient] = useState(() => props.queryClient ??
|
|
73
|
+
new QueryClient({
|
|
74
|
+
defaultOptions: {
|
|
75
|
+
queries: { retry: false, staleTime: 5_000, refetchOnWindowFocus: false },
|
|
76
|
+
mutations: { retry: false },
|
|
77
|
+
},
|
|
78
|
+
}));
|
|
79
|
+
return createElement(QueryClientProvider, { client: queryClient }, createElement(VenlyContext.Provider, { value: clients }, props.children));
|
|
80
|
+
}
|
|
81
|
+
/** The configured clients. Throws outside a `<VenlyProvider>`. */
|
|
82
|
+
export function useVenly() {
|
|
83
|
+
const clients = useContext(VenlyContext);
|
|
84
|
+
if (!clients) {
|
|
85
|
+
throw new Error("[@venlyfinance/react] useVenly() called outside <VenlyProvider>. " +
|
|
86
|
+
"Wrap your tree in <VenlyProvider environment=\"mock\"> to get started.");
|
|
87
|
+
}
|
|
88
|
+
return clients;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Mock controls (call log, failNext, lifecycle advancement). Defined only
|
|
92
|
+
* when the provider runs with environment "mock"; both fields are undefined
|
|
93
|
+
* otherwise, so demo/test affordances can never fire against live money.
|
|
94
|
+
*/
|
|
95
|
+
export function useVenlyMock() {
|
|
96
|
+
const { finance, fundflow } = useVenly();
|
|
97
|
+
return { finance: finance.mock, fundflow: fundflow.mock };
|
|
98
|
+
}
|
package/dist/proxy.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { FundflowClientOptions, VenlyFinanceClientOptions } from "@venlyfinance/sdk";
|
|
2
|
+
/**
|
|
3
|
+
* Client options for the browser-safe deployment shape: the browser talks to
|
|
4
|
+
* YOUR backend, and your backend holds the credentials and forwards to Venly
|
|
5
|
+
* with the real OAuth token. No secret ever enters the bundle.
|
|
6
|
+
*
|
|
7
|
+
* The SDK always runs an OAuth token flow before calling out, so this wraps
|
|
8
|
+
* `fetch` to answer the token request locally with a synthetic token (your
|
|
9
|
+
* proxy ignores the Authorization header and applies its own). Every API
|
|
10
|
+
* call then goes to `proxyBaseUrl` unchanged.
|
|
11
|
+
*
|
|
12
|
+
* ```tsx
|
|
13
|
+
* const proxy = proxyClientOptions("/api/venly");
|
|
14
|
+
* <VenlyProvider environment="production"
|
|
15
|
+
* financeOptions={proxy.finance} fundflowOptions={proxy.fundflow} />
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* Server side, the matching route handler uses the SDK with real credentials
|
|
19
|
+
* (see README "Going live" for a Next.js example) and MUST enforce its own
|
|
20
|
+
* authentication: the proxy inherits your app's session, not Venly's.
|
|
21
|
+
*/
|
|
22
|
+
export interface ProxyClientOptions {
|
|
23
|
+
finance: VenlyFinanceClientOptions;
|
|
24
|
+
fundflow: FundflowClientOptions;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The placeholder credential used by proxy options. It is not a secret –
|
|
28
|
+
* the proxy backend ignores the Authorization header entirely – and the
|
|
29
|
+
* provider's browser guard recognises it as safe. Never assign a real
|
|
30
|
+
* secret this value.
|
|
31
|
+
*/
|
|
32
|
+
export declare const VENLY_PROXY_SECRET_SENTINEL = "venly-proxy";
|
|
33
|
+
export declare function proxyClientOptions(proxyBaseUrl: string, options?: {
|
|
34
|
+
fetch?: typeof fetch;
|
|
35
|
+
/** Path under proxyBaseUrl that forwards to the Finance API. Default "/finance". */
|
|
36
|
+
financePath?: string;
|
|
37
|
+
/** Path under proxyBaseUrl that forwards to the Fundflow API. Default "/fundflow". */
|
|
38
|
+
fundflowPath?: string;
|
|
39
|
+
}): ProxyClientOptions;
|
package/dist/proxy.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The placeholder credential used by proxy options. It is not a secret –
|
|
3
|
+
* the proxy backend ignores the Authorization header entirely – and the
|
|
4
|
+
* provider's browser guard recognises it as safe. Never assign a real
|
|
5
|
+
* secret this value.
|
|
6
|
+
*/
|
|
7
|
+
export const VENLY_PROXY_SECRET_SENTINEL = "venly-proxy";
|
|
8
|
+
const SYNTHETIC_TOKEN_PATH = "/__venly-proxy-token";
|
|
9
|
+
export function proxyClientOptions(proxyBaseUrl, options) {
|
|
10
|
+
const base = proxyBaseUrl.replace(/\/$/, "");
|
|
11
|
+
const tokenUrl = `${base}${SYNTHETIC_TOKEN_PATH}`;
|
|
12
|
+
const realFetch = options?.fetch ?? fetch;
|
|
13
|
+
const proxyFetch = async (input, init) => {
|
|
14
|
+
const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
|
|
15
|
+
if (url === tokenUrl) {
|
|
16
|
+
return Response.json({
|
|
17
|
+
access_token: "venly-proxy",
|
|
18
|
+
token_type: "Bearer",
|
|
19
|
+
expires_in: 3600,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return realFetch(input, init);
|
|
23
|
+
};
|
|
24
|
+
return {
|
|
25
|
+
finance: {
|
|
26
|
+
environment: "production",
|
|
27
|
+
clientId: "venly-proxy",
|
|
28
|
+
clientSecret: VENLY_PROXY_SECRET_SENTINEL,
|
|
29
|
+
baseUrl: `${base}${options?.financePath ?? "/finance"}`,
|
|
30
|
+
tokenUrl,
|
|
31
|
+
fetch: proxyFetch,
|
|
32
|
+
},
|
|
33
|
+
fundflow: {
|
|
34
|
+
environment: "production",
|
|
35
|
+
clientId: "venly-proxy",
|
|
36
|
+
clientSecret: VENLY_PROXY_SECRET_SENTINEL,
|
|
37
|
+
baseUrl: `${base}${options?.fundflowPath ?? "/fundflow"}`,
|
|
38
|
+
tokenUrl,
|
|
39
|
+
fetch: proxyFetch,
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { type UseQueryOptions } from "@tanstack/react-query";
|
|
2
|
+
import { venlyQueries, type AccountsQuery, type FeeQuoteInput, type PartiesQuery, type RampRequestsQuery, type TransfersQuery, type VirtualBankAccountsQuery, type WalletsQuery } from "./query-options.js";
|
|
3
|
+
type Tune<T> = Omit<UseQueryOptions<T, Error>, "queryKey" | "queryFn">;
|
|
4
|
+
export declare function useParties(query?: PartiesQuery, options?: Tune<PartiesPage>): import("@tanstack/react-query").UseQueryResult<NoInfer<import("@venlyfinance/sdk").Page<{
|
|
5
|
+
id?: string;
|
|
6
|
+
externalId?: string;
|
|
7
|
+
partyType?: import("@venlyfinance/sdk").FinanceComponents["schemas"]["PartyType"];
|
|
8
|
+
status?: import("@venlyfinance/sdk").FinanceComponents["schemas"]["PartyStatus"];
|
|
9
|
+
firstName?: string;
|
|
10
|
+
lastName?: string;
|
|
11
|
+
kycStatus?: import("@venlyfinance/sdk").FinanceComponents["schemas"]["KycStatus"];
|
|
12
|
+
name?: string;
|
|
13
|
+
vatNumber?: string;
|
|
14
|
+
kybStatus?: import("@venlyfinance/sdk").FinanceComponents["schemas"]["KybStatus"];
|
|
15
|
+
address?: import("@venlyfinance/sdk").FinanceComponents["schemas"]["Address"];
|
|
16
|
+
createdAt?: string;
|
|
17
|
+
updatedAt?: string;
|
|
18
|
+
version?: number;
|
|
19
|
+
}>>, Error>;
|
|
20
|
+
type PartiesPage = Awaited<ReturnType<ReturnType<typeof venlyQueries.parties>["queryFn"]>>;
|
|
21
|
+
export declare function useParty(partyId: string | undefined, options?: Tune<Party>): import("@tanstack/react-query").UseQueryResult<NoInfer<{
|
|
22
|
+
id?: string;
|
|
23
|
+
externalId?: string;
|
|
24
|
+
partyType?: import("@venlyfinance/sdk").FinanceComponents["schemas"]["PartyType"];
|
|
25
|
+
status?: import("@venlyfinance/sdk").FinanceComponents["schemas"]["PartyStatus"];
|
|
26
|
+
firstName?: string;
|
|
27
|
+
lastName?: string;
|
|
28
|
+
kycStatus?: import("@venlyfinance/sdk").FinanceComponents["schemas"]["KycStatus"];
|
|
29
|
+
name?: string;
|
|
30
|
+
vatNumber?: string;
|
|
31
|
+
kybStatus?: import("@venlyfinance/sdk").FinanceComponents["schemas"]["KybStatus"];
|
|
32
|
+
address?: import("@venlyfinance/sdk").FinanceComponents["schemas"]["Address"];
|
|
33
|
+
createdAt?: string;
|
|
34
|
+
updatedAt?: string;
|
|
35
|
+
version?: number;
|
|
36
|
+
}>, Error>;
|
|
37
|
+
type Party = Awaited<ReturnType<ReturnType<typeof venlyQueries.party>["queryFn"]>>;
|
|
38
|
+
export declare function useAccounts(query?: AccountsQuery, options?: Tune<AccountsPage>): import("@tanstack/react-query").UseQueryResult<NoInfer<import("@venlyfinance/sdk").Page<{
|
|
39
|
+
id?: string;
|
|
40
|
+
externalId?: string;
|
|
41
|
+
name?: string;
|
|
42
|
+
kycStatus?: import("@venlyfinance/sdk").FinanceComponents["schemas"]["KycStatus"];
|
|
43
|
+
status?: import("@venlyfinance/sdk").FinanceComponents["schemas"]["AccountStatus"];
|
|
44
|
+
createdAt?: string;
|
|
45
|
+
version?: number;
|
|
46
|
+
}>>, Error>;
|
|
47
|
+
type AccountsPage = Awaited<ReturnType<ReturnType<typeof venlyQueries.accounts>["queryFn"]>>;
|
|
48
|
+
export declare function useAccount(accountId: string | undefined, options?: Tune<Account>): import("@tanstack/react-query").UseQueryResult<NoInfer<{
|
|
49
|
+
id?: string;
|
|
50
|
+
externalId?: string;
|
|
51
|
+
name?: string;
|
|
52
|
+
kycStatus?: import("@venlyfinance/sdk").FinanceComponents["schemas"]["KycStatus"];
|
|
53
|
+
status?: import("@venlyfinance/sdk").FinanceComponents["schemas"]["AccountStatus"];
|
|
54
|
+
createdAt?: string;
|
|
55
|
+
version?: number;
|
|
56
|
+
}>, Error>;
|
|
57
|
+
type Account = Awaited<ReturnType<ReturnType<typeof venlyQueries.account>["queryFn"]>>;
|
|
58
|
+
export declare function useWallets(accountId: string | undefined, query?: WalletsQuery, options?: Tune<WalletsPage>): import("@tanstack/react-query").UseQueryResult<NoInfer<import("@venlyfinance/sdk").Page<{
|
|
59
|
+
id?: string;
|
|
60
|
+
chain?: import("@venlyfinance/sdk").FinanceComponents["schemas"]["BlockchainNetwork"];
|
|
61
|
+
type?: import("@venlyfinance/sdk").FinanceComponents["schemas"]["WalletType"];
|
|
62
|
+
address?: string;
|
|
63
|
+
balances?: import("@venlyfinance/sdk").FinanceComponents["schemas"]["TokenBalance"][];
|
|
64
|
+
amlStatus?: import("@venlyfinance/sdk").FinanceComponents["schemas"]["AmlStatus"];
|
|
65
|
+
}>>, Error>;
|
|
66
|
+
type WalletsPage = Awaited<ReturnType<ReturnType<typeof venlyQueries.wallets>["queryFn"]>>;
|
|
67
|
+
export declare function useVirtualBankAccounts(accountId: string | undefined, query?: VirtualBankAccountsQuery, options?: Tune<VibaPage>): import("@tanstack/react-query").UseQueryResult<NoInfer<import("@venlyfinance/sdk").Page<{
|
|
68
|
+
id?: string;
|
|
69
|
+
accountId?: string;
|
|
70
|
+
bankAccountType?: import("@venlyfinance/sdk").FinanceComponents["schemas"]["BankAccountType"];
|
|
71
|
+
name?: string;
|
|
72
|
+
status?: import("@venlyfinance/sdk").FinanceComponents["schemas"]["VirtualBankAccountStatus"];
|
|
73
|
+
currency?: import("@venlyfinance/sdk").FinanceComponents["schemas"]["FiatCurrency"];
|
|
74
|
+
targetCryptocurrency?: import("@venlyfinance/sdk").FinanceComponents["schemas"]["Cryptocurrency"];
|
|
75
|
+
iban?: string;
|
|
76
|
+
bic?: string;
|
|
77
|
+
bankName?: string;
|
|
78
|
+
beneficiaryName?: string;
|
|
79
|
+
referenceCode?: string;
|
|
80
|
+
createdAt?: string;
|
|
81
|
+
updatedAt?: string;
|
|
82
|
+
}>>, Error>;
|
|
83
|
+
type VibaPage = Awaited<ReturnType<ReturnType<typeof venlyQueries.virtualBankAccounts>["queryFn"]>>;
|
|
84
|
+
export declare function useTransfers(accountId: string | undefined, query?: TransfersQuery, options?: Tune<TransfersPage>): import("@tanstack/react-query").UseQueryResult<NoInfer<import("@venlyfinance/sdk").Page<{
|
|
85
|
+
id?: string;
|
|
86
|
+
senderAccountId?: string;
|
|
87
|
+
receiverAccountId?: string;
|
|
88
|
+
chain?: import("@venlyfinance/sdk").FinanceComponents["schemas"]["BlockchainNetwork"];
|
|
89
|
+
asset?: string;
|
|
90
|
+
amount?: number;
|
|
91
|
+
fiatOrigin?: import("@venlyfinance/sdk").FinanceComponents["schemas"]["FiatOrigin"];
|
|
92
|
+
description?: string;
|
|
93
|
+
merchantReference?: string;
|
|
94
|
+
idempotencyKey?: string;
|
|
95
|
+
status?: import("@venlyfinance/sdk").FinanceComponents["schemas"]["TransferStatus"];
|
|
96
|
+
transactionHash?: string;
|
|
97
|
+
errorMessage?: string;
|
|
98
|
+
createdAt?: string;
|
|
99
|
+
updatedAt?: string;
|
|
100
|
+
}>>, Error>;
|
|
101
|
+
type TransfersPage = Awaited<ReturnType<ReturnType<typeof venlyQueries.transfers>["queryFn"]>>;
|
|
102
|
+
export declare function useTransfer(accountId: string | undefined, transferId: string | undefined, options?: Tune<Transfer>): import("@tanstack/react-query").UseQueryResult<NoInfer<{
|
|
103
|
+
id?: string;
|
|
104
|
+
senderAccountId?: string;
|
|
105
|
+
receiverAccountId?: string;
|
|
106
|
+
chain?: import("@venlyfinance/sdk").FinanceComponents["schemas"]["BlockchainNetwork"];
|
|
107
|
+
asset?: string;
|
|
108
|
+
amount?: number;
|
|
109
|
+
fiatOrigin?: import("@venlyfinance/sdk").FinanceComponents["schemas"]["FiatOrigin"];
|
|
110
|
+
description?: string;
|
|
111
|
+
merchantReference?: string;
|
|
112
|
+
idempotencyKey?: string;
|
|
113
|
+
status?: import("@venlyfinance/sdk").FinanceComponents["schemas"]["TransferStatus"];
|
|
114
|
+
transactionHash?: string;
|
|
115
|
+
errorMessage?: string;
|
|
116
|
+
createdAt?: string;
|
|
117
|
+
updatedAt?: string;
|
|
118
|
+
}>, Error>;
|
|
119
|
+
type Transfer = Awaited<ReturnType<ReturnType<typeof venlyQueries.transfer>["queryFn"]>>;
|
|
120
|
+
export declare function useRampRequests(query?: RampRequestsQuery, options?: Tune<RampPage>): import("@tanstack/react-query").UseQueryResult<NoInfer<import("@venlyfinance/sdk").Page<{
|
|
121
|
+
id?: string;
|
|
122
|
+
paymentReference?: string;
|
|
123
|
+
rampType?: "ON_RAMP" | "OFF_RAMP";
|
|
124
|
+
status?: "AWAITING_APPROVAL" | "AWAITING_FUNDS" | "PROCESSING" | "SUCCEEDED" | "FAILED" | "BLOCKED" | "DENIED" | "REJECTED" | "CANCELLED";
|
|
125
|
+
fiatAmount?: number;
|
|
126
|
+
fiatCurrency?: string;
|
|
127
|
+
cryptoAmount?: number;
|
|
128
|
+
cryptoCurrency?: string;
|
|
129
|
+
createdAt?: string;
|
|
130
|
+
createdBy?: string;
|
|
131
|
+
}>>, Error>;
|
|
132
|
+
type RampPage = Awaited<ReturnType<ReturnType<typeof venlyQueries.rampRequests>["queryFn"]>>;
|
|
133
|
+
export declare function useRampRequest(id: string | undefined, options?: Tune<Ramp>): import("@tanstack/react-query").UseQueryResult<NoInfer<{
|
|
134
|
+
id?: string;
|
|
135
|
+
companyId?: string;
|
|
136
|
+
companyName?: string;
|
|
137
|
+
rampType?: "ON_RAMP" | "OFF_RAMP";
|
|
138
|
+
status?: "AWAITING_APPROVAL" | "AWAITING_FUNDS" | "PROCESSING" | "SUCCEEDED" | "FAILED" | "BLOCKED" | "DENIED" | "REJECTED" | "CANCELLED";
|
|
139
|
+
amount?: number;
|
|
140
|
+
netAmount?: number;
|
|
141
|
+
fiatAmount?: number;
|
|
142
|
+
fiatNetAmount?: number;
|
|
143
|
+
cryptoAmount?: number;
|
|
144
|
+
fiatFeeAmount?: number;
|
|
145
|
+
exchangeRate?: number;
|
|
146
|
+
feePercentage?: number;
|
|
147
|
+
paymentReference?: string;
|
|
148
|
+
paymentReceived?: boolean;
|
|
149
|
+
blockchainTransactionHash?: string;
|
|
150
|
+
createdAt?: string;
|
|
151
|
+
companyBankAccount?: import("@venlyfinance/sdk").FundflowComponents["schemas"]["EurSepaCompanyBankAccountDto"] | import("@venlyfinance/sdk").FundflowComponents["schemas"]["GbpChapsCompanyBankAccountDto"] | import("@venlyfinance/sdk").FundflowComponents["schemas"]["GbpFpsCompanyBankAccountDto"] | import("@venlyfinance/sdk").FundflowComponents["schemas"]["OtherCurrencySwiftCompanyBankAccountDto"] | import("@venlyfinance/sdk").FundflowComponents["schemas"]["UsAchCompanyBankAccountDto"] | import("@venlyfinance/sdk").FundflowComponents["schemas"]["UsSwiftCompanyBankAccountDto"] | import("@venlyfinance/sdk").FundflowComponents["schemas"]["UsWireCompanyBankAccountDto"];
|
|
152
|
+
companyWallet?: import("@venlyfinance/sdk").FundflowComponents["schemas"]["CompanyWalletDto"];
|
|
153
|
+
depositBankAccount?: import("@venlyfinance/sdk").FundflowComponents["schemas"]["EurSepaDepositBankAccountDto"] | import("@venlyfinance/sdk").FundflowComponents["schemas"]["GbpChapsDepositBankAccountDto"] | import("@venlyfinance/sdk").FundflowComponents["schemas"]["GbpFpsDepositBankAccountDto"] | import("@venlyfinance/sdk").FundflowComponents["schemas"]["OtherCurrencySwiftDepositBankAccountDto"] | import("@venlyfinance/sdk").FundflowComponents["schemas"]["UsAchDepositBankAccountDto"] | import("@venlyfinance/sdk").FundflowComponents["schemas"]["UsSwiftDepositBankAccountDto"] | import("@venlyfinance/sdk").FundflowComponents["schemas"]["UsWireDepositBankAccountDto"];
|
|
154
|
+
depositWallet?: import("@venlyfinance/sdk").FundflowComponents["schemas"]["DepositWalletDto"];
|
|
155
|
+
fiatCurrency?: import("@venlyfinance/sdk").FundflowComponents["schemas"]["FiatCurrencyDto"];
|
|
156
|
+
cryptoCurrency?: import("@venlyfinance/sdk").FundflowComponents["schemas"]["CryptoCurrencyDto"];
|
|
157
|
+
events?: import("@venlyfinance/sdk").FundflowComponents["schemas"]["RampRequestEventDto"][];
|
|
158
|
+
version?: number;
|
|
159
|
+
amountReceived?: number;
|
|
160
|
+
}>, Error>;
|
|
161
|
+
type Ramp = Awaited<ReturnType<ReturnType<typeof venlyQueries.rampRequest>["queryFn"]>>;
|
|
162
|
+
export declare function useReferenceData(options?: Tune<ReferenceData>): import("@tanstack/react-query").UseQueryResult<NoInfer<{
|
|
163
|
+
fiatCurrencies: {
|
|
164
|
+
id?: string;
|
|
165
|
+
currency?: string;
|
|
166
|
+
label?: string;
|
|
167
|
+
enabled?: boolean;
|
|
168
|
+
version?: number;
|
|
169
|
+
}[];
|
|
170
|
+
cryptoCurrencies: {
|
|
171
|
+
id?: string;
|
|
172
|
+
currency?: string;
|
|
173
|
+
chain?: "ETHEREUM" | "POLYGON" | "BASE" | "ARBITRUM" | "SUI";
|
|
174
|
+
label?: string;
|
|
175
|
+
enabled?: boolean;
|
|
176
|
+
version?: number;
|
|
177
|
+
coingeckoId?: string;
|
|
178
|
+
}[];
|
|
179
|
+
chains: {
|
|
180
|
+
supportedChains?: ("ETHEREUM" | "POLYGON" | "BASE" | "ARBITRUM" | "SUI")[];
|
|
181
|
+
}[];
|
|
182
|
+
}>, Error>;
|
|
183
|
+
type ReferenceData = Awaited<ReturnType<ReturnType<typeof venlyQueries.referenceData>["queryFn"]>>;
|
|
184
|
+
export declare function useCompanyFees(options?: Tune<CompanyFees>): import("@tanstack/react-query").UseQueryResult<NoInfer<{
|
|
185
|
+
id?: string;
|
|
186
|
+
companyId?: string;
|
|
187
|
+
name?: string;
|
|
188
|
+
type?: "ON_RAMP" | "OFF_RAMP";
|
|
189
|
+
minVolume?: number;
|
|
190
|
+
maxVolume?: number;
|
|
191
|
+
percentage?: number;
|
|
192
|
+
version?: number;
|
|
193
|
+
}[]>, Error>;
|
|
194
|
+
type CompanyFees = Awaited<ReturnType<ReturnType<typeof venlyQueries.companyFees>["queryFn"]>>;
|
|
195
|
+
export declare function useFeeQuote(input: FeeQuoteInput | undefined, options?: Tune<FeeQuote>): import("@tanstack/react-query").UseQueryResult<NoInfer<{
|
|
196
|
+
amount?: number;
|
|
197
|
+
percentage?: number;
|
|
198
|
+
}>, Error>;
|
|
199
|
+
type FeeQuote = Awaited<ReturnType<ReturnType<typeof venlyQueries.feeQuote>["queryFn"]>>;
|
|
200
|
+
export {};
|
package/dist/queries.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { useQuery } from "@tanstack/react-query";
|
|
2
|
+
import { useVenly } from "./provider.js";
|
|
3
|
+
import { venlyQueries, } from "./query-options.js";
|
|
4
|
+
export function useParties(query, options) {
|
|
5
|
+
const clients = useVenly();
|
|
6
|
+
return useQuery({ ...venlyQueries.parties(clients, query), ...options });
|
|
7
|
+
}
|
|
8
|
+
export function useParty(partyId, options) {
|
|
9
|
+
const clients = useVenly();
|
|
10
|
+
return useQuery({
|
|
11
|
+
...venlyQueries.party(clients, partyId ?? ""),
|
|
12
|
+
enabled: Boolean(partyId) && (options?.enabled ?? true),
|
|
13
|
+
...options,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
export function useAccounts(query, options) {
|
|
17
|
+
const clients = useVenly();
|
|
18
|
+
return useQuery({ ...venlyQueries.accounts(clients, query), ...options });
|
|
19
|
+
}
|
|
20
|
+
export function useAccount(accountId, options) {
|
|
21
|
+
const clients = useVenly();
|
|
22
|
+
return useQuery({
|
|
23
|
+
...venlyQueries.account(clients, accountId ?? ""),
|
|
24
|
+
enabled: Boolean(accountId) && (options?.enabled ?? true),
|
|
25
|
+
...options,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
export function useWallets(accountId, query, options) {
|
|
29
|
+
const clients = useVenly();
|
|
30
|
+
return useQuery({
|
|
31
|
+
...venlyQueries.wallets(clients, accountId ?? "", query),
|
|
32
|
+
enabled: Boolean(accountId) && (options?.enabled ?? true),
|
|
33
|
+
...options,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
export function useVirtualBankAccounts(accountId, query, options) {
|
|
37
|
+
const clients = useVenly();
|
|
38
|
+
return useQuery({
|
|
39
|
+
...venlyQueries.virtualBankAccounts(clients, accountId ?? "", query),
|
|
40
|
+
enabled: Boolean(accountId) && (options?.enabled ?? true),
|
|
41
|
+
...options,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
export function useTransfers(accountId, query, options) {
|
|
45
|
+
const clients = useVenly();
|
|
46
|
+
return useQuery({
|
|
47
|
+
...venlyQueries.transfers(clients, accountId ?? "", query),
|
|
48
|
+
enabled: Boolean(accountId) && (options?.enabled ?? true),
|
|
49
|
+
...options,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
export function useTransfer(accountId, transferId, options) {
|
|
53
|
+
const clients = useVenly();
|
|
54
|
+
return useQuery({
|
|
55
|
+
...venlyQueries.transfer(clients, accountId ?? "", transferId ?? ""),
|
|
56
|
+
enabled: Boolean(accountId && transferId) && (options?.enabled ?? true),
|
|
57
|
+
...options,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
export function useRampRequests(query, options) {
|
|
61
|
+
const clients = useVenly();
|
|
62
|
+
return useQuery({ ...venlyQueries.rampRequests(clients, query), ...options });
|
|
63
|
+
}
|
|
64
|
+
export function useRampRequest(id, options) {
|
|
65
|
+
const clients = useVenly();
|
|
66
|
+
return useQuery({
|
|
67
|
+
...venlyQueries.rampRequest(clients, id ?? ""),
|
|
68
|
+
enabled: Boolean(id) && (options?.enabled ?? true),
|
|
69
|
+
...options,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
export function useReferenceData(options) {
|
|
73
|
+
const clients = useVenly();
|
|
74
|
+
return useQuery({
|
|
75
|
+
...venlyQueries.referenceData(clients),
|
|
76
|
+
staleTime: Infinity, // chains and currencies change on deploys, not minutes
|
|
77
|
+
...options,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
export function useCompanyFees(options) {
|
|
81
|
+
const clients = useVenly();
|
|
82
|
+
return useQuery({ ...venlyQueries.companyFees(clients), ...options });
|
|
83
|
+
}
|
|
84
|
+
export function useFeeQuote(input, options) {
|
|
85
|
+
const clients = useVenly();
|
|
86
|
+
return useQuery({
|
|
87
|
+
...venlyQueries.feeQuote(clients, input),
|
|
88
|
+
enabled: Boolean(input) && (options?.enabled ?? true),
|
|
89
|
+
...options,
|
|
90
|
+
});
|
|
91
|
+
}
|