@oasisprotocol/privana-sdk 0.5.3 → 0.5.5
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/README.md +29 -57
- package/dist/{chunk-7KEQHWZB.cjs → chunk-7VNAGKRC.cjs} +917 -365
- package/dist/chunk-7VNAGKRC.cjs.map +1 -0
- package/dist/{chunk-DZURIIRE.js → chunk-PMBU2F2R.js} +918 -366
- package/dist/chunk-PMBU2F2R.js.map +1 -0
- package/dist/index.cjs +1495 -2600
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +17 -46
- package/dist/index.d.ts +17 -46
- package/dist/index.js +1359 -2461
- package/dist/index.js.map +1 -1
- package/dist/on-ramp.cjs +3 -3
- package/dist/on-ramp.d.cts +81 -52
- package/dist/on-ramp.d.ts +81 -52
- package/dist/on-ramp.js +1 -1
- package/dist/{pending-lock-f4bWWTyN.d.cts → pending-lock-IgzZyg9C.d.cts} +23 -19
- package/dist/{pending-lock-f4bWWTyN.d.ts → pending-lock-IgzZyg9C.d.ts} +23 -19
- package/package.json +1 -1
- package/dist/chunk-7KEQHWZB.cjs.map +0 -1
- package/dist/chunk-DZURIIRE.js.map +0 -1
package/dist/on-ramp.cjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var chunk7VNAGKRC_cjs = require('./chunk-7VNAGKRC.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, "FiatOnRampForm", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunk7VNAGKRC_cjs.FiatOnRampForm; }
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "useFiatOnRamp", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunk7VNAGKRC_cjs.useFiatOnRamp; }
|
|
15
15
|
});
|
|
16
16
|
//# sourceMappingURL=on-ramp.cjs.map
|
|
17
17
|
//# sourceMappingURL=on-ramp.cjs.map
|
package/dist/on-ramp.d.cts
CHANGED
|
@@ -1,28 +1,59 @@
|
|
|
1
1
|
import { MoonPayBuyWidget } from '@moonpay/moonpay-react';
|
|
2
|
-
import { B as Bytes32, Z as OnRampPostDepositLockConfig, e as TransactionSubmissionResponse, f as PostDepositLockError,
|
|
3
|
-
export {
|
|
2
|
+
import { _ as OnRampProvider, A as Address, B as Bytes32, C as CreateOnRampIntentRequest, P as PrivanaClient, $ as OnRampRecord, Z as OnRampPostDepositLockConfig, e as TransactionSubmissionResponse, f as PostDepositLockError, T as TokenConfig } from './pending-lock-IgzZyg9C.cjs';
|
|
3
|
+
export { n as CreateOnRampIntentResponse, a0 as OnRampStatus, a3 as PendingOnRampsResponse, a7 as SignOnRampUrlRequest, a8 as SignOnRampUrlResponse, am as UpdateOnRampRequest, an as UpdateOnRampResponse } from './pending-lock-IgzZyg9C.cjs';
|
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
5
|
import 'viem';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
interface OnRampProviderIntentInput {
|
|
8
|
+
walletAddress: Address;
|
|
9
|
+
tokenId: Bytes32;
|
|
10
|
+
chainId: number;
|
|
11
|
+
providerAssetCode: string;
|
|
12
|
+
}
|
|
13
|
+
interface OnRampProviderTransactionContext {
|
|
14
|
+
client: PrivanaClient;
|
|
15
|
+
intentId: string;
|
|
16
|
+
providerTransactionId: string;
|
|
17
|
+
tokenId: Bytes32;
|
|
18
|
+
chainId: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The deliberately small backend-facing provider seam. Provider launch UI
|
|
22
|
+
* normalizes its callbacks into `OnRampProviderEvent`; the shared hook owns
|
|
23
|
+
* recovery, receipt verification, credit, and lock settlement.
|
|
24
|
+
*/
|
|
25
|
+
interface OnRampProviderAdapter {
|
|
26
|
+
provider: OnRampProvider;
|
|
27
|
+
pollPendingWhileOpen: boolean;
|
|
28
|
+
buildIntentRequest(input: OnRampProviderIntentInput): CreateOnRampIntentRequest;
|
|
29
|
+
registerTransaction?(context: OnRampProviderTransactionContext): Promise<OnRampRecord | undefined>;
|
|
30
|
+
}
|
|
31
|
+
type OnRampProviderEventKind = 'transaction-created' | 'transaction-completed';
|
|
32
|
+
interface OnRampProviderEvent {
|
|
33
|
+
provider: OnRampProvider;
|
|
34
|
+
kind: OnRampProviderEventKind;
|
|
35
|
+
providerTransactionId: string;
|
|
36
|
+
/** Signed Privana intent echoed by the provider, when present. */
|
|
37
|
+
intentId?: string;
|
|
38
|
+
}
|
|
10
39
|
|
|
11
|
-
type
|
|
12
|
-
/**
|
|
40
|
+
type OnRampFlowStatus = 'idle'
|
|
41
|
+
/** Provider launch succeeded; the user is completing the purchase. */
|
|
13
42
|
| 'awaiting-purchase'
|
|
14
|
-
/**
|
|
43
|
+
/** Provider reported completion; polling recovery until the on-chain transfer appears. */
|
|
15
44
|
| 'awaiting-delivery'
|
|
16
45
|
/** checkDeposit fired; polling getDepositStatus until credited. */
|
|
17
46
|
| 'verifying' | 'credited' | 'failed';
|
|
18
|
-
interface
|
|
47
|
+
interface OnRampDebugEvent {
|
|
19
48
|
at: string;
|
|
20
49
|
event: string;
|
|
21
|
-
status:
|
|
50
|
+
status: OnRampFlowStatus;
|
|
22
51
|
tokenId: Bytes32;
|
|
23
52
|
payload?: Record<string, unknown>;
|
|
24
53
|
}
|
|
25
|
-
interface
|
|
54
|
+
interface UseOnRampOptions {
|
|
55
|
+
/** Deployment-selected provider behavior. */
|
|
56
|
+
adapter: OnRampProviderAdapter;
|
|
26
57
|
/** Privana token the on-ramp will deposit into. */
|
|
27
58
|
tokenId: Bytes32;
|
|
28
59
|
/**
|
|
@@ -44,15 +75,18 @@ interface UseFiatOnRampOptions {
|
|
|
44
75
|
onLockFailed?: (error: PostDepositLockError) => void;
|
|
45
76
|
onError?: (error: Error) => void;
|
|
46
77
|
/** Optional diagnostic event stream for previews/tests. No auth tokens or signatures are emitted. */
|
|
47
|
-
onDebugEvent?: (event:
|
|
78
|
+
onDebugEvent?: (event: OnRampDebugEvent) => void;
|
|
48
79
|
/**
|
|
49
80
|
* Max time in ms to wait for the backend to surface the on-chain tx hash
|
|
50
|
-
* after
|
|
81
|
+
* after the provider reports completion or its widget closes
|
|
51
82
|
* (default: 120000 = 2 minutes).
|
|
52
83
|
* If exceeded, the row stays in `pending` for the user to finish later.
|
|
53
84
|
*/
|
|
54
85
|
deliveryTimeout?: number;
|
|
55
|
-
/**
|
|
86
|
+
/**
|
|
87
|
+
* Polling interval in ms while waiting for the on-chain tx hash. Values below
|
|
88
|
+
* the rate-safe 10000 ms minimum are clamped.
|
|
89
|
+
*/
|
|
56
90
|
deliveryPollInterval?: number;
|
|
57
91
|
/** Max time in ms for Privana deposit verification after the on-chain tx hash appears. */
|
|
58
92
|
verificationTimeout?: number;
|
|
@@ -61,9 +95,9 @@ interface UseFiatOnRampOptions {
|
|
|
61
95
|
/** Polling interval in ms while waiting for Privana deposit credit. */
|
|
62
96
|
verificationPollInterval?: number;
|
|
63
97
|
}
|
|
64
|
-
interface
|
|
65
|
-
status:
|
|
66
|
-
/** Privana intent id passed to
|
|
98
|
+
interface UseOnRampResult {
|
|
99
|
+
status: OnRampFlowStatus;
|
|
100
|
+
/** Active signed Privana intent id passed to the configured provider. */
|
|
67
101
|
activeIntentId: string | null;
|
|
68
102
|
/** Completed on-ramps that still need Privana verification. */
|
|
69
103
|
pending: OnRampRecord[];
|
|
@@ -95,9 +129,9 @@ interface UseFiatOnRampResult {
|
|
|
95
129
|
* token (e.g., still loading or misconfigured).
|
|
96
130
|
*/
|
|
97
131
|
selectedToken: TokenConfig | undefined;
|
|
98
|
-
/** Create the backend intent that
|
|
132
|
+
/** Create the backend intent that the configured provider will echo. */
|
|
99
133
|
prepareOnRampIntent: (request: {
|
|
100
|
-
|
|
134
|
+
providerAssetCode: string;
|
|
101
135
|
baseCurrencyCode?: string;
|
|
102
136
|
baseCurrencyAmount?: string;
|
|
103
137
|
/**
|
|
@@ -107,43 +141,38 @@ interface UseFiatOnRampResult {
|
|
|
107
141
|
*/
|
|
108
142
|
quoteCurrencyAmount?: string;
|
|
109
143
|
}) => Promise<OnRampRecord>;
|
|
110
|
-
/**
|
|
144
|
+
/** Mark a provider launch as ready for user interaction. */
|
|
145
|
+
handleProviderLaunchReady: () => void;
|
|
146
|
+
/** Surface a provider-specific launch failure through the shared flow. */
|
|
147
|
+
handleProviderLaunchFailed: (error: Error) => void;
|
|
148
|
+
/** Handle a normalized provider transaction event. */
|
|
149
|
+
handleProviderEvent: (event: OnRampProviderEvent) => Promise<void>;
|
|
150
|
+
/** Trigger Privana verification for a row returned by `pending`. */
|
|
151
|
+
finishPendingVerification: (record: OnRampRecord) => Promise<void>;
|
|
152
|
+
/** Reconcile local state after the provider UI closes. */
|
|
153
|
+
handleProviderClosed: () => Promise<void>;
|
|
154
|
+
refreshPending: () => Promise<void>;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
type MoonPayBuyProps = Parameters<typeof MoonPayBuyWidget>[0];
|
|
158
|
+
type OnTransactionCompletedProps = Parameters<NonNullable<MoonPayBuyProps['onTransactionCompleted']>>[0];
|
|
159
|
+
type OnTransactionCreatedProps = Parameters<NonNullable<MoonPayBuyProps['onTransactionCreated']>>[0];
|
|
160
|
+
type FiatOnRampStatus = OnRampFlowStatus;
|
|
161
|
+
type FiatOnRampDebugEvent = OnRampDebugEvent;
|
|
162
|
+
type UseFiatOnRampOptions = Omit<UseOnRampOptions, 'adapter'>;
|
|
163
|
+
interface UseFiatOnRampResult extends Omit<UseOnRampResult, 'prepareOnRampIntent' | 'handleProviderLaunchReady' | 'handleProviderLaunchFailed' | 'handleProviderEvent' | 'handleProviderClosed'> {
|
|
164
|
+
prepareOnRampIntent: (request: {
|
|
165
|
+
currencyCode: string;
|
|
166
|
+
baseCurrencyCode?: string;
|
|
167
|
+
baseCurrencyAmount?: string;
|
|
168
|
+
quoteCurrencyAmount?: string;
|
|
169
|
+
}) => Promise<OnRampRecord>;
|
|
111
170
|
signUrl: (url: string) => Promise<string>;
|
|
112
|
-
/**
|
|
113
|
-
* Wire to `<MoonPayBuyWidget onTransactionCreated>`. Fire-and-forget - records the Privana
|
|
114
|
-
* `token_id` + `chain_id` against the MoonPay transaction so the backend can credit the
|
|
115
|
-
* right balance when the delivery webhook arrives.
|
|
116
|
-
*/
|
|
117
171
|
handleTransactionCreated: (props: OnTransactionCreatedProps) => Promise<void>;
|
|
118
|
-
/** Wire to `<MoonPayBuyWidget onTransactionCompleted>`. */
|
|
119
172
|
handleTransactionCompleted: (props: OnTransactionCompletedProps) => Promise<void>;
|
|
120
|
-
/** Trigger Privana verification for a row returned by `pending`. */
|
|
121
|
-
finishPendingVerification: (record: OnRampRecord) => Promise<void>;
|
|
122
|
-
/** Reconcile local state after the MoonPay widget closes. */
|
|
123
173
|
handleWidgetClosed: () => Promise<void>;
|
|
124
|
-
refreshPending: () => Promise<void>;
|
|
125
174
|
}
|
|
126
|
-
/**
|
|
127
|
-
* Buy crypto via MoonPay and credit it to a Privana balance in one flow.
|
|
128
|
-
*
|
|
129
|
-
* Architecture: MoonPay delivers USDC directly to the user's Privana deposit
|
|
130
|
-
* address (NOT the connected wallet) — the wallet is only used for SIWE auth
|
|
131
|
-
* and signs no on-chain transfer. After MoonPay reports the purchase complete,
|
|
132
|
-
* the on-chain tx hash arrives via the MoonPay→backend webhook (not the widget
|
|
133
|
-
* event), so this hook polls `/onramp/pending` until the row's
|
|
134
|
-
* `on_chain_tx_hash` is populated and then triggers Privana verification
|
|
135
|
-
* (`checkDeposit` + `getDepositStatus` poll, delegated to
|
|
136
|
-
* `useDepositVerification`).
|
|
137
|
-
*
|
|
138
|
-
* Wire the returned callbacks to `<MoonPayBuyWidget>`:
|
|
139
|
-
*
|
|
140
|
-
* onUrlSignatureRequested = signUrl
|
|
141
|
-
* onTransactionCreated = handleTransactionCreated
|
|
142
|
-
* onTransactionCompleted = handleTransactionCompleted
|
|
143
|
-
* onClose / onCloseOverlay = handleWidgetClosed
|
|
144
|
-
*
|
|
145
|
-
* Use `<FiatOnRampForm>` if you don't need custom UI around the widget.
|
|
146
|
-
*/
|
|
175
|
+
/** Thin MoonPay compatibility adapter over the shared on-ramp state machine. */
|
|
147
176
|
declare function useFiatOnRamp(options: UseFiatOnRampOptions): UseFiatOnRampResult;
|
|
148
177
|
|
|
149
178
|
interface FiatOnRampFormProps {
|
|
@@ -208,4 +237,4 @@ interface FiatOnRampFormProps {
|
|
|
208
237
|
}
|
|
209
238
|
declare function FiatOnRampForm({ tokenId, currencyCode, baseCurrencyCode, defaultBaseCurrencyAmount, quoteCurrencyAmount, tokenSymbol, theme, themeId, colorCode, variant, autoStart, lockAmount, paymentMethod, postDepositLock, onCredited, onLockSubmitted, onLockFailed, onError, onDebugEvent, }: FiatOnRampFormProps): react_jsx_runtime.JSX.Element;
|
|
210
239
|
|
|
211
|
-
export { type FiatOnRampDebugEvent, FiatOnRampForm, type FiatOnRampFormProps, type FiatOnRampStatus, OnRampPostDepositLockConfig, OnRampRecord, type UseFiatOnRampOptions, type UseFiatOnRampResult, useFiatOnRamp };
|
|
240
|
+
export { CreateOnRampIntentRequest, type FiatOnRampDebugEvent, FiatOnRampForm, type FiatOnRampFormProps, type FiatOnRampStatus, OnRampPostDepositLockConfig, OnRampProvider, OnRampRecord, type UseFiatOnRampOptions, type UseFiatOnRampResult, useFiatOnRamp };
|
package/dist/on-ramp.d.ts
CHANGED
|
@@ -1,28 +1,59 @@
|
|
|
1
1
|
import { MoonPayBuyWidget } from '@moonpay/moonpay-react';
|
|
2
|
-
import { B as Bytes32, Z as OnRampPostDepositLockConfig, e as TransactionSubmissionResponse, f as PostDepositLockError,
|
|
3
|
-
export {
|
|
2
|
+
import { _ as OnRampProvider, A as Address, B as Bytes32, C as CreateOnRampIntentRequest, P as PrivanaClient, $ as OnRampRecord, Z as OnRampPostDepositLockConfig, e as TransactionSubmissionResponse, f as PostDepositLockError, T as TokenConfig } from './pending-lock-IgzZyg9C.js';
|
|
3
|
+
export { n as CreateOnRampIntentResponse, a0 as OnRampStatus, a3 as PendingOnRampsResponse, a7 as SignOnRampUrlRequest, a8 as SignOnRampUrlResponse, am as UpdateOnRampRequest, an as UpdateOnRampResponse } from './pending-lock-IgzZyg9C.js';
|
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
5
|
import 'viem';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
interface OnRampProviderIntentInput {
|
|
8
|
+
walletAddress: Address;
|
|
9
|
+
tokenId: Bytes32;
|
|
10
|
+
chainId: number;
|
|
11
|
+
providerAssetCode: string;
|
|
12
|
+
}
|
|
13
|
+
interface OnRampProviderTransactionContext {
|
|
14
|
+
client: PrivanaClient;
|
|
15
|
+
intentId: string;
|
|
16
|
+
providerTransactionId: string;
|
|
17
|
+
tokenId: Bytes32;
|
|
18
|
+
chainId: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The deliberately small backend-facing provider seam. Provider launch UI
|
|
22
|
+
* normalizes its callbacks into `OnRampProviderEvent`; the shared hook owns
|
|
23
|
+
* recovery, receipt verification, credit, and lock settlement.
|
|
24
|
+
*/
|
|
25
|
+
interface OnRampProviderAdapter {
|
|
26
|
+
provider: OnRampProvider;
|
|
27
|
+
pollPendingWhileOpen: boolean;
|
|
28
|
+
buildIntentRequest(input: OnRampProviderIntentInput): CreateOnRampIntentRequest;
|
|
29
|
+
registerTransaction?(context: OnRampProviderTransactionContext): Promise<OnRampRecord | undefined>;
|
|
30
|
+
}
|
|
31
|
+
type OnRampProviderEventKind = 'transaction-created' | 'transaction-completed';
|
|
32
|
+
interface OnRampProviderEvent {
|
|
33
|
+
provider: OnRampProvider;
|
|
34
|
+
kind: OnRampProviderEventKind;
|
|
35
|
+
providerTransactionId: string;
|
|
36
|
+
/** Signed Privana intent echoed by the provider, when present. */
|
|
37
|
+
intentId?: string;
|
|
38
|
+
}
|
|
10
39
|
|
|
11
|
-
type
|
|
12
|
-
/**
|
|
40
|
+
type OnRampFlowStatus = 'idle'
|
|
41
|
+
/** Provider launch succeeded; the user is completing the purchase. */
|
|
13
42
|
| 'awaiting-purchase'
|
|
14
|
-
/**
|
|
43
|
+
/** Provider reported completion; polling recovery until the on-chain transfer appears. */
|
|
15
44
|
| 'awaiting-delivery'
|
|
16
45
|
/** checkDeposit fired; polling getDepositStatus until credited. */
|
|
17
46
|
| 'verifying' | 'credited' | 'failed';
|
|
18
|
-
interface
|
|
47
|
+
interface OnRampDebugEvent {
|
|
19
48
|
at: string;
|
|
20
49
|
event: string;
|
|
21
|
-
status:
|
|
50
|
+
status: OnRampFlowStatus;
|
|
22
51
|
tokenId: Bytes32;
|
|
23
52
|
payload?: Record<string, unknown>;
|
|
24
53
|
}
|
|
25
|
-
interface
|
|
54
|
+
interface UseOnRampOptions {
|
|
55
|
+
/** Deployment-selected provider behavior. */
|
|
56
|
+
adapter: OnRampProviderAdapter;
|
|
26
57
|
/** Privana token the on-ramp will deposit into. */
|
|
27
58
|
tokenId: Bytes32;
|
|
28
59
|
/**
|
|
@@ -44,15 +75,18 @@ interface UseFiatOnRampOptions {
|
|
|
44
75
|
onLockFailed?: (error: PostDepositLockError) => void;
|
|
45
76
|
onError?: (error: Error) => void;
|
|
46
77
|
/** Optional diagnostic event stream for previews/tests. No auth tokens or signatures are emitted. */
|
|
47
|
-
onDebugEvent?: (event:
|
|
78
|
+
onDebugEvent?: (event: OnRampDebugEvent) => void;
|
|
48
79
|
/**
|
|
49
80
|
* Max time in ms to wait for the backend to surface the on-chain tx hash
|
|
50
|
-
* after
|
|
81
|
+
* after the provider reports completion or its widget closes
|
|
51
82
|
* (default: 120000 = 2 minutes).
|
|
52
83
|
* If exceeded, the row stays in `pending` for the user to finish later.
|
|
53
84
|
*/
|
|
54
85
|
deliveryTimeout?: number;
|
|
55
|
-
/**
|
|
86
|
+
/**
|
|
87
|
+
* Polling interval in ms while waiting for the on-chain tx hash. Values below
|
|
88
|
+
* the rate-safe 10000 ms minimum are clamped.
|
|
89
|
+
*/
|
|
56
90
|
deliveryPollInterval?: number;
|
|
57
91
|
/** Max time in ms for Privana deposit verification after the on-chain tx hash appears. */
|
|
58
92
|
verificationTimeout?: number;
|
|
@@ -61,9 +95,9 @@ interface UseFiatOnRampOptions {
|
|
|
61
95
|
/** Polling interval in ms while waiting for Privana deposit credit. */
|
|
62
96
|
verificationPollInterval?: number;
|
|
63
97
|
}
|
|
64
|
-
interface
|
|
65
|
-
status:
|
|
66
|
-
/** Privana intent id passed to
|
|
98
|
+
interface UseOnRampResult {
|
|
99
|
+
status: OnRampFlowStatus;
|
|
100
|
+
/** Active signed Privana intent id passed to the configured provider. */
|
|
67
101
|
activeIntentId: string | null;
|
|
68
102
|
/** Completed on-ramps that still need Privana verification. */
|
|
69
103
|
pending: OnRampRecord[];
|
|
@@ -95,9 +129,9 @@ interface UseFiatOnRampResult {
|
|
|
95
129
|
* token (e.g., still loading or misconfigured).
|
|
96
130
|
*/
|
|
97
131
|
selectedToken: TokenConfig | undefined;
|
|
98
|
-
/** Create the backend intent that
|
|
132
|
+
/** Create the backend intent that the configured provider will echo. */
|
|
99
133
|
prepareOnRampIntent: (request: {
|
|
100
|
-
|
|
134
|
+
providerAssetCode: string;
|
|
101
135
|
baseCurrencyCode?: string;
|
|
102
136
|
baseCurrencyAmount?: string;
|
|
103
137
|
/**
|
|
@@ -107,43 +141,38 @@ interface UseFiatOnRampResult {
|
|
|
107
141
|
*/
|
|
108
142
|
quoteCurrencyAmount?: string;
|
|
109
143
|
}) => Promise<OnRampRecord>;
|
|
110
|
-
/**
|
|
144
|
+
/** Mark a provider launch as ready for user interaction. */
|
|
145
|
+
handleProviderLaunchReady: () => void;
|
|
146
|
+
/** Surface a provider-specific launch failure through the shared flow. */
|
|
147
|
+
handleProviderLaunchFailed: (error: Error) => void;
|
|
148
|
+
/** Handle a normalized provider transaction event. */
|
|
149
|
+
handleProviderEvent: (event: OnRampProviderEvent) => Promise<void>;
|
|
150
|
+
/** Trigger Privana verification for a row returned by `pending`. */
|
|
151
|
+
finishPendingVerification: (record: OnRampRecord) => Promise<void>;
|
|
152
|
+
/** Reconcile local state after the provider UI closes. */
|
|
153
|
+
handleProviderClosed: () => Promise<void>;
|
|
154
|
+
refreshPending: () => Promise<void>;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
type MoonPayBuyProps = Parameters<typeof MoonPayBuyWidget>[0];
|
|
158
|
+
type OnTransactionCompletedProps = Parameters<NonNullable<MoonPayBuyProps['onTransactionCompleted']>>[0];
|
|
159
|
+
type OnTransactionCreatedProps = Parameters<NonNullable<MoonPayBuyProps['onTransactionCreated']>>[0];
|
|
160
|
+
type FiatOnRampStatus = OnRampFlowStatus;
|
|
161
|
+
type FiatOnRampDebugEvent = OnRampDebugEvent;
|
|
162
|
+
type UseFiatOnRampOptions = Omit<UseOnRampOptions, 'adapter'>;
|
|
163
|
+
interface UseFiatOnRampResult extends Omit<UseOnRampResult, 'prepareOnRampIntent' | 'handleProviderLaunchReady' | 'handleProviderLaunchFailed' | 'handleProviderEvent' | 'handleProviderClosed'> {
|
|
164
|
+
prepareOnRampIntent: (request: {
|
|
165
|
+
currencyCode: string;
|
|
166
|
+
baseCurrencyCode?: string;
|
|
167
|
+
baseCurrencyAmount?: string;
|
|
168
|
+
quoteCurrencyAmount?: string;
|
|
169
|
+
}) => Promise<OnRampRecord>;
|
|
111
170
|
signUrl: (url: string) => Promise<string>;
|
|
112
|
-
/**
|
|
113
|
-
* Wire to `<MoonPayBuyWidget onTransactionCreated>`. Fire-and-forget - records the Privana
|
|
114
|
-
* `token_id` + `chain_id` against the MoonPay transaction so the backend can credit the
|
|
115
|
-
* right balance when the delivery webhook arrives.
|
|
116
|
-
*/
|
|
117
171
|
handleTransactionCreated: (props: OnTransactionCreatedProps) => Promise<void>;
|
|
118
|
-
/** Wire to `<MoonPayBuyWidget onTransactionCompleted>`. */
|
|
119
172
|
handleTransactionCompleted: (props: OnTransactionCompletedProps) => Promise<void>;
|
|
120
|
-
/** Trigger Privana verification for a row returned by `pending`. */
|
|
121
|
-
finishPendingVerification: (record: OnRampRecord) => Promise<void>;
|
|
122
|
-
/** Reconcile local state after the MoonPay widget closes. */
|
|
123
173
|
handleWidgetClosed: () => Promise<void>;
|
|
124
|
-
refreshPending: () => Promise<void>;
|
|
125
174
|
}
|
|
126
|
-
/**
|
|
127
|
-
* Buy crypto via MoonPay and credit it to a Privana balance in one flow.
|
|
128
|
-
*
|
|
129
|
-
* Architecture: MoonPay delivers USDC directly to the user's Privana deposit
|
|
130
|
-
* address (NOT the connected wallet) — the wallet is only used for SIWE auth
|
|
131
|
-
* and signs no on-chain transfer. After MoonPay reports the purchase complete,
|
|
132
|
-
* the on-chain tx hash arrives via the MoonPay→backend webhook (not the widget
|
|
133
|
-
* event), so this hook polls `/onramp/pending` until the row's
|
|
134
|
-
* `on_chain_tx_hash` is populated and then triggers Privana verification
|
|
135
|
-
* (`checkDeposit` + `getDepositStatus` poll, delegated to
|
|
136
|
-
* `useDepositVerification`).
|
|
137
|
-
*
|
|
138
|
-
* Wire the returned callbacks to `<MoonPayBuyWidget>`:
|
|
139
|
-
*
|
|
140
|
-
* onUrlSignatureRequested = signUrl
|
|
141
|
-
* onTransactionCreated = handleTransactionCreated
|
|
142
|
-
* onTransactionCompleted = handleTransactionCompleted
|
|
143
|
-
* onClose / onCloseOverlay = handleWidgetClosed
|
|
144
|
-
*
|
|
145
|
-
* Use `<FiatOnRampForm>` if you don't need custom UI around the widget.
|
|
146
|
-
*/
|
|
175
|
+
/** Thin MoonPay compatibility adapter over the shared on-ramp state machine. */
|
|
147
176
|
declare function useFiatOnRamp(options: UseFiatOnRampOptions): UseFiatOnRampResult;
|
|
148
177
|
|
|
149
178
|
interface FiatOnRampFormProps {
|
|
@@ -208,4 +237,4 @@ interface FiatOnRampFormProps {
|
|
|
208
237
|
}
|
|
209
238
|
declare function FiatOnRampForm({ tokenId, currencyCode, baseCurrencyCode, defaultBaseCurrencyAmount, quoteCurrencyAmount, tokenSymbol, theme, themeId, colorCode, variant, autoStart, lockAmount, paymentMethod, postDepositLock, onCredited, onLockSubmitted, onLockFailed, onError, onDebugEvent, }: FiatOnRampFormProps): react_jsx_runtime.JSX.Element;
|
|
210
239
|
|
|
211
|
-
export { type FiatOnRampDebugEvent, FiatOnRampForm, type FiatOnRampFormProps, type FiatOnRampStatus, OnRampPostDepositLockConfig, OnRampRecord, type UseFiatOnRampOptions, type UseFiatOnRampResult, useFiatOnRamp };
|
|
240
|
+
export { CreateOnRampIntentRequest, type FiatOnRampDebugEvent, FiatOnRampForm, type FiatOnRampFormProps, type FiatOnRampStatus, OnRampPostDepositLockConfig, OnRampProvider, OnRampRecord, type UseFiatOnRampOptions, type UseFiatOnRampResult, useFiatOnRamp };
|
package/dist/on-ramp.js
CHANGED
|
@@ -4,7 +4,7 @@ var networks = {
|
|
|
4
4
|
testnet: {
|
|
5
5
|
chainId: 23295,
|
|
6
6
|
name: "Sapphire Testnet",
|
|
7
|
-
accountingContract: "
|
|
7
|
+
accountingContract: "0x910CFfe4e8B27bc367F6E34D6D8e3C31DED68B6f",
|
|
8
8
|
apiUrl: "https://api.testnet.privana.finance"
|
|
9
9
|
},
|
|
10
10
|
mainnet: {
|
|
@@ -361,6 +361,7 @@ interface JwtLogoutResponse {
|
|
|
361
361
|
revoked_tokens: number;
|
|
362
362
|
}
|
|
363
363
|
|
|
364
|
+
type OnRampProvider = 'moonpay' | 'transak';
|
|
364
365
|
type OnRampStatus = 'pending' | 'completed' | 'failed' | 'cancelled';
|
|
365
366
|
/** Request body / response of POST /api/onramp/sign-url */
|
|
366
367
|
interface SignOnRampUrlRequest {
|
|
@@ -374,9 +375,8 @@ interface CreateOnRampIntentRequest {
|
|
|
374
375
|
wallet_address?: Address;
|
|
375
376
|
token_id: Bytes32;
|
|
376
377
|
chain_id: number;
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
base_currency_amount?: string;
|
|
378
|
+
/** MoonPay compatibility field retained while its SDK adapter is active. */
|
|
379
|
+
moonpay_currency_code?: string;
|
|
380
380
|
}
|
|
381
381
|
type CreateOnRampIntentResponse = OnRampRecord;
|
|
382
382
|
/** Request body / response of POST /api/onramp/{id}. */
|
|
@@ -394,20 +394,24 @@ interface UpdateOnRampRequest {
|
|
|
394
394
|
type UpdateOnRampResponse = OnRampRecord;
|
|
395
395
|
interface OnRampRecord {
|
|
396
396
|
transaction_id: string;
|
|
397
|
-
external_transaction_id?: string;
|
|
398
|
-
|
|
397
|
+
external_transaction_id?: string | null;
|
|
398
|
+
provider: OnRampProvider;
|
|
399
|
+
provider_transaction_id?: string | null;
|
|
400
|
+
provider_asset_code: string;
|
|
401
|
+
moonpay_transaction_id?: string | null;
|
|
399
402
|
status: OnRampStatus;
|
|
400
|
-
wallet_address?: Address;
|
|
401
|
-
token_id?: Bytes32;
|
|
402
|
-
chain_id?: number;
|
|
403
|
-
moonpay_currency_code?: string;
|
|
404
|
-
base_currency_code?: string;
|
|
405
|
-
base_currency_amount?: string;
|
|
406
|
-
quote_currency_amount?: string;
|
|
407
|
-
on_chain_tx_hash?: HexString;
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
403
|
+
wallet_address?: Address | null;
|
|
404
|
+
token_id?: Bytes32 | null;
|
|
405
|
+
chain_id?: number | null;
|
|
406
|
+
moonpay_currency_code?: string | null;
|
|
407
|
+
base_currency_code?: string | null;
|
|
408
|
+
base_currency_amount?: string | null;
|
|
409
|
+
quote_currency_amount?: string | null;
|
|
410
|
+
on_chain_tx_hash?: HexString | null;
|
|
411
|
+
deposit_id?: string | null;
|
|
412
|
+
deposit_tx_hash?: HexString | null;
|
|
413
|
+
deposit_triggered_at?: number | null;
|
|
414
|
+
credited_at?: number | null;
|
|
411
415
|
created_at: number;
|
|
412
416
|
updated_at: number;
|
|
413
417
|
}
|
|
@@ -478,7 +482,7 @@ declare class PrivanaClient {
|
|
|
478
482
|
signOnRampUrl(request: SignOnRampUrlRequest): Promise<SignOnRampUrlResponse>;
|
|
479
483
|
createOnRampIntent(request: CreateOnRampIntentRequest): Promise<CreateOnRampIntentResponse>;
|
|
480
484
|
updateOnRamp(transactionId: string, request: UpdateOnRampRequest): Promise<UpdateOnRampResponse>;
|
|
481
|
-
getPendingOnRamps(): Promise<PendingOnRampsResponse>;
|
|
485
|
+
getPendingOnRamps(externalTransactionIds?: readonly string[]): Promise<PendingOnRampsResponse>;
|
|
482
486
|
/**
|
|
483
487
|
* @deprecated This mutates the shared client's headers and displaces its Authorization
|
|
484
488
|
* (JWT bearer) header, which breaks concurrent JWT-authenticated requests. Use
|
|
@@ -631,4 +635,4 @@ declare function savePendingLock(userAddress: string, correlationId: string, pay
|
|
|
631
635
|
declare function loadPendingLock(userAddress: string, correlationId: string): LockFundsRequest | undefined;
|
|
632
636
|
declare function clearPendingLock(userAddress: string, correlationId: string): void;
|
|
633
637
|
|
|
634
|
-
export { type
|
|
638
|
+
export { type OnRampRecord as $, type Address as A, type Bytes32 as B, type CreateOnRampIntentRequest as C, type DepositAddressResponse as D, type ExpiredLocksResponse as E, type HttpClientConfig as F, type JwtLogoutRequest as G, type HostedAuthTokenExchangeResponse as H, type IntegerLike as I, type JwtRefreshResponse as J, type JwtLogoutResponse as K, type LockInfo as L, type JwtRefreshRequest as M, type NetworkConfig as N, type LockFundsRequest as O, PrivanaClient as P, type LockNonceResponse as Q, type LockedFundsResponse as R, type MinDepositAmounts as S, type TokenConfig as T, type ModifyLockNonceResponse as U, type ModifyLockRequest as V, type WithdrawalInfo as W, NETWORK_CONFIG as X, type Network as Y, type OnRampPostDepositLockConfig as Z, type OnRampProvider as _, type HexString as a, type OnRampStatus as a0, type PendingDepositStatus as a1, type PendingDepositsRequest as a2, type PendingOnRampsResponse as a3, type PendingWithdrawalsResponse as a4, type PostDepositLockFailureReason as a5, type PrivanaClientConfig as a6, type SignOnRampUrlRequest as a7, type SignOnRampUrlResponse as a8, type SiweDomainResponse as a9, loadPendingLock as aA, normalizeAddress as aB, normalizeHex as aC, requireDepositLockOwner as aD, requireServiceAddress as aE, savePendingLock as aF, submitPendingLock as aG, type SiweLoginRequest as aa, type SiweLoginResponse as ab, type SiweNonceResponse as ac, type SubmitPendingLockParams as ad, type TokenListResponse as ae, type TotalLockedBalanceResponse as af, type TransferFundsRequest as ag, type TransferLockedFundsRequest as ah, type TransferLockedNonceResponse as ai, type TransferNonceResponse as aj, type UnlockAllExpiredRequest as ak, type UnlockFundsRequest as al, type UpdateOnRampRequest as am, type UpdateOnRampResponse as an, type WithdrawFromLockRequest as ao, type WithdrawalInfoResponse as ap, type WithdrawalNonceResponse as aq, type WithdrawalRequest as ar, applyLockBuffer as as, clampLockAmount as at, clearPendingLock as au, createSignedLockRequest as av, getAccountingContract as aw, getApiUrl as ax, getChainId as ay, isSignedLockUsable as az, type TokenBalance as b, type PostDepositLockConfig as c, type DepositCheckResponse as d, type TransactionSubmissionResponse as e, PostDepositLockError as f, type PendingDeposit as g, type PendingDepositsResponse as h, type HistoryEntry as i, type TokenInfoResponse as j, type BalanceResponse as k, type BatchBalancesRequest as l, type BatchBalancesResponse as m, type CreateOnRampIntentResponse as n, type CreateSignedLockRequestParams as o, DEFAULT_LOCK_DURATION_SECONDS as p, DEFAULT_ONRAMP_LOCK_BUFFER as q, type DepositAddressRequest as r, type DepositCheckRequest as s, type HistoryKind as t, type HistoryRequest as u, type HistoryResponse as v, type HostedAuthAuthorizeUrlRequest as w, type HostedAuthResponseMode as x, type HostedAuthTokenExchangeRequest as y, HttpClient as z };
|
|
@@ -4,7 +4,7 @@ var networks = {
|
|
|
4
4
|
testnet: {
|
|
5
5
|
chainId: 23295,
|
|
6
6
|
name: "Sapphire Testnet",
|
|
7
|
-
accountingContract: "
|
|
7
|
+
accountingContract: "0x910CFfe4e8B27bc367F6E34D6D8e3C31DED68B6f",
|
|
8
8
|
apiUrl: "https://api.testnet.privana.finance"
|
|
9
9
|
},
|
|
10
10
|
mainnet: {
|
|
@@ -361,6 +361,7 @@ interface JwtLogoutResponse {
|
|
|
361
361
|
revoked_tokens: number;
|
|
362
362
|
}
|
|
363
363
|
|
|
364
|
+
type OnRampProvider = 'moonpay' | 'transak';
|
|
364
365
|
type OnRampStatus = 'pending' | 'completed' | 'failed' | 'cancelled';
|
|
365
366
|
/** Request body / response of POST /api/onramp/sign-url */
|
|
366
367
|
interface SignOnRampUrlRequest {
|
|
@@ -374,9 +375,8 @@ interface CreateOnRampIntentRequest {
|
|
|
374
375
|
wallet_address?: Address;
|
|
375
376
|
token_id: Bytes32;
|
|
376
377
|
chain_id: number;
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
base_currency_amount?: string;
|
|
378
|
+
/** MoonPay compatibility field retained while its SDK adapter is active. */
|
|
379
|
+
moonpay_currency_code?: string;
|
|
380
380
|
}
|
|
381
381
|
type CreateOnRampIntentResponse = OnRampRecord;
|
|
382
382
|
/** Request body / response of POST /api/onramp/{id}. */
|
|
@@ -394,20 +394,24 @@ interface UpdateOnRampRequest {
|
|
|
394
394
|
type UpdateOnRampResponse = OnRampRecord;
|
|
395
395
|
interface OnRampRecord {
|
|
396
396
|
transaction_id: string;
|
|
397
|
-
external_transaction_id?: string;
|
|
398
|
-
|
|
397
|
+
external_transaction_id?: string | null;
|
|
398
|
+
provider: OnRampProvider;
|
|
399
|
+
provider_transaction_id?: string | null;
|
|
400
|
+
provider_asset_code: string;
|
|
401
|
+
moonpay_transaction_id?: string | null;
|
|
399
402
|
status: OnRampStatus;
|
|
400
|
-
wallet_address?: Address;
|
|
401
|
-
token_id?: Bytes32;
|
|
402
|
-
chain_id?: number;
|
|
403
|
-
moonpay_currency_code?: string;
|
|
404
|
-
base_currency_code?: string;
|
|
405
|
-
base_currency_amount?: string;
|
|
406
|
-
quote_currency_amount?: string;
|
|
407
|
-
on_chain_tx_hash?: HexString;
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
403
|
+
wallet_address?: Address | null;
|
|
404
|
+
token_id?: Bytes32 | null;
|
|
405
|
+
chain_id?: number | null;
|
|
406
|
+
moonpay_currency_code?: string | null;
|
|
407
|
+
base_currency_code?: string | null;
|
|
408
|
+
base_currency_amount?: string | null;
|
|
409
|
+
quote_currency_amount?: string | null;
|
|
410
|
+
on_chain_tx_hash?: HexString | null;
|
|
411
|
+
deposit_id?: string | null;
|
|
412
|
+
deposit_tx_hash?: HexString | null;
|
|
413
|
+
deposit_triggered_at?: number | null;
|
|
414
|
+
credited_at?: number | null;
|
|
411
415
|
created_at: number;
|
|
412
416
|
updated_at: number;
|
|
413
417
|
}
|
|
@@ -478,7 +482,7 @@ declare class PrivanaClient {
|
|
|
478
482
|
signOnRampUrl(request: SignOnRampUrlRequest): Promise<SignOnRampUrlResponse>;
|
|
479
483
|
createOnRampIntent(request: CreateOnRampIntentRequest): Promise<CreateOnRampIntentResponse>;
|
|
480
484
|
updateOnRamp(transactionId: string, request: UpdateOnRampRequest): Promise<UpdateOnRampResponse>;
|
|
481
|
-
getPendingOnRamps(): Promise<PendingOnRampsResponse>;
|
|
485
|
+
getPendingOnRamps(externalTransactionIds?: readonly string[]): Promise<PendingOnRampsResponse>;
|
|
482
486
|
/**
|
|
483
487
|
* @deprecated This mutates the shared client's headers and displaces its Authorization
|
|
484
488
|
* (JWT bearer) header, which breaks concurrent JWT-authenticated requests. Use
|
|
@@ -631,4 +635,4 @@ declare function savePendingLock(userAddress: string, correlationId: string, pay
|
|
|
631
635
|
declare function loadPendingLock(userAddress: string, correlationId: string): LockFundsRequest | undefined;
|
|
632
636
|
declare function clearPendingLock(userAddress: string, correlationId: string): void;
|
|
633
637
|
|
|
634
|
-
export { type
|
|
638
|
+
export { type OnRampRecord as $, type Address as A, type Bytes32 as B, type CreateOnRampIntentRequest as C, type DepositAddressResponse as D, type ExpiredLocksResponse as E, type HttpClientConfig as F, type JwtLogoutRequest as G, type HostedAuthTokenExchangeResponse as H, type IntegerLike as I, type JwtRefreshResponse as J, type JwtLogoutResponse as K, type LockInfo as L, type JwtRefreshRequest as M, type NetworkConfig as N, type LockFundsRequest as O, PrivanaClient as P, type LockNonceResponse as Q, type LockedFundsResponse as R, type MinDepositAmounts as S, type TokenConfig as T, type ModifyLockNonceResponse as U, type ModifyLockRequest as V, type WithdrawalInfo as W, NETWORK_CONFIG as X, type Network as Y, type OnRampPostDepositLockConfig as Z, type OnRampProvider as _, type HexString as a, type OnRampStatus as a0, type PendingDepositStatus as a1, type PendingDepositsRequest as a2, type PendingOnRampsResponse as a3, type PendingWithdrawalsResponse as a4, type PostDepositLockFailureReason as a5, type PrivanaClientConfig as a6, type SignOnRampUrlRequest as a7, type SignOnRampUrlResponse as a8, type SiweDomainResponse as a9, loadPendingLock as aA, normalizeAddress as aB, normalizeHex as aC, requireDepositLockOwner as aD, requireServiceAddress as aE, savePendingLock as aF, submitPendingLock as aG, type SiweLoginRequest as aa, type SiweLoginResponse as ab, type SiweNonceResponse as ac, type SubmitPendingLockParams as ad, type TokenListResponse as ae, type TotalLockedBalanceResponse as af, type TransferFundsRequest as ag, type TransferLockedFundsRequest as ah, type TransferLockedNonceResponse as ai, type TransferNonceResponse as aj, type UnlockAllExpiredRequest as ak, type UnlockFundsRequest as al, type UpdateOnRampRequest as am, type UpdateOnRampResponse as an, type WithdrawFromLockRequest as ao, type WithdrawalInfoResponse as ap, type WithdrawalNonceResponse as aq, type WithdrawalRequest as ar, applyLockBuffer as as, clampLockAmount as at, clearPendingLock as au, createSignedLockRequest as av, getAccountingContract as aw, getApiUrl as ax, getChainId as ay, isSignedLockUsable as az, type TokenBalance as b, type PostDepositLockConfig as c, type DepositCheckResponse as d, type TransactionSubmissionResponse as e, PostDepositLockError as f, type PendingDeposit as g, type PendingDepositsResponse as h, type HistoryEntry as i, type TokenInfoResponse as j, type BalanceResponse as k, type BatchBalancesRequest as l, type BatchBalancesResponse as m, type CreateOnRampIntentResponse as n, type CreateSignedLockRequestParams as o, DEFAULT_LOCK_DURATION_SECONDS as p, DEFAULT_ONRAMP_LOCK_BUFFER as q, type DepositAddressRequest as r, type DepositCheckRequest as s, type HistoryKind as t, type HistoryRequest as u, type HistoryResponse as v, type HostedAuthAuthorizeUrlRequest as w, type HostedAuthResponseMode as x, type HostedAuthTokenExchangeRequest as y, HttpClient as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oasisprotocol/privana-sdk",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.5",
|
|
4
4
|
"description": "React SDK for Privana - manage deposits, withdrawals, locks, and transfers",
|
|
5
5
|
"author": "Oasis Protocol Foundation <security@oasisprotocol.org>",
|
|
6
6
|
"license": "Apache-2.0",
|