@recoilpay/intent-react 0.2.0 → 0.4.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/README.md +11 -1
- package/dist/index.cjs +439 -99
- package/dist/index.d.cts +38 -3
- package/dist/index.d.ts +38 -3
- package/dist/index.js +433 -94
- package/dist/styles.css +94 -0
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { IntentSession, IntentWallet, IntentState } from '@recoilpay/intent-core';
|
|
3
|
-
export { IntentPhase, IntentPreview, IntentSession, IntentState, IntentWallet, createIntentSession, viemWallet } from '@recoilpay/intent-core';
|
|
2
|
+
import { IntentSession, IntentWallet, IntentState, OfframpSession, FiatTrade, OfframpState } from '@recoilpay/intent-core';
|
|
3
|
+
export { IntentPhase, IntentPreview, IntentSession, IntentState, IntentWallet, OfframpPhase, OfframpSession, OfframpState, createIntentSession, createOfframpSession, viemWallet } from '@recoilpay/intent-core';
|
|
4
4
|
|
|
5
5
|
interface RecoilTheme {
|
|
6
6
|
/** Default `dark`. */
|
|
@@ -40,6 +40,17 @@ interface RecoilIntentProps {
|
|
|
40
40
|
/** Every intent in the sentence reached a final status. */
|
|
41
41
|
onComplete?: (state: IntentState) => void;
|
|
42
42
|
onError?: (message: string) => void;
|
|
43
|
+
/** Share or inject the cash-out session (tests, or your own cash-out UI). */
|
|
44
|
+
offrampSession?: OfframpSession;
|
|
45
|
+
/**
|
|
46
|
+
* A cash-out opened. Store the id if you want to bring the user back to it
|
|
47
|
+
* later (`resumeCashOut`): they must confirm or dispute once paid.
|
|
48
|
+
*/
|
|
49
|
+
onCashOutStarted?: (tradeId: string) => void;
|
|
50
|
+
/** A cash-out reached its end: settled, refunded or failed. */
|
|
51
|
+
onCashOutEnded?: (trade: FiatTrade) => void;
|
|
52
|
+
/** Show this cash-out trade on mount, e.g. one saved from `onCashOutStarted`. */
|
|
53
|
+
resumeCashOut?: string | null;
|
|
43
54
|
}
|
|
44
55
|
/**
|
|
45
56
|
* RecoilPay intents in one component: the user types what they want, sees
|
|
@@ -74,4 +85,28 @@ interface UseRecoilIntent extends IntentState {
|
|
|
74
85
|
*/
|
|
75
86
|
declare function useRecoilIntent(options?: UseRecoilIntentOptions): UseRecoilIntent;
|
|
76
87
|
|
|
77
|
-
|
|
88
|
+
interface UseOfframpOptions {
|
|
89
|
+
/** Aggregator base URL. Defaults to production. Read once, on first render. */
|
|
90
|
+
apiUrl?: string;
|
|
91
|
+
/** Bring your own session (shared, or for tests). */
|
|
92
|
+
session?: OfframpSession;
|
|
93
|
+
/** The connected wallet, or null. */
|
|
94
|
+
wallet?: IntentWallet | null;
|
|
95
|
+
}
|
|
96
|
+
interface UseOfframp extends OfframpState {
|
|
97
|
+
/** The session's `quote()`; renamed because `quote` is the chosen offer. */
|
|
98
|
+
requestQuote: OfframpSession['quote'];
|
|
99
|
+
confirm: OfframpSession['confirm'];
|
|
100
|
+
confirmReceived: OfframpSession['confirmReceived'];
|
|
101
|
+
dispute: OfframpSession['dispute'];
|
|
102
|
+
resume: OfframpSession['resume'];
|
|
103
|
+
reset: OfframpSession['reset'];
|
|
104
|
+
session: OfframpSession;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* A cash-out to a bank account as React state. Renders nothing; the
|
|
108
|
+
* `<RecoilIntent />` component uses it when a sentence asks to cash out.
|
|
109
|
+
*/
|
|
110
|
+
declare function useOfframp(options?: UseOfframpOptions): UseOfframp;
|
|
111
|
+
|
|
112
|
+
export { type IntentExample, RecoilIntent, type RecoilIntentProps, type RecoilTheme, type UseOfframp, type UseOfframpOptions, type UseRecoilIntent, type UseRecoilIntentOptions, useOfframp, useRecoilIntent };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { IntentSession, IntentWallet, IntentState } from '@recoilpay/intent-core';
|
|
3
|
-
export { IntentPhase, IntentPreview, IntentSession, IntentState, IntentWallet, createIntentSession, viemWallet } from '@recoilpay/intent-core';
|
|
2
|
+
import { IntentSession, IntentWallet, IntentState, OfframpSession, FiatTrade, OfframpState } from '@recoilpay/intent-core';
|
|
3
|
+
export { IntentPhase, IntentPreview, IntentSession, IntentState, IntentWallet, OfframpPhase, OfframpSession, OfframpState, createIntentSession, createOfframpSession, viemWallet } from '@recoilpay/intent-core';
|
|
4
4
|
|
|
5
5
|
interface RecoilTheme {
|
|
6
6
|
/** Default `dark`. */
|
|
@@ -40,6 +40,17 @@ interface RecoilIntentProps {
|
|
|
40
40
|
/** Every intent in the sentence reached a final status. */
|
|
41
41
|
onComplete?: (state: IntentState) => void;
|
|
42
42
|
onError?: (message: string) => void;
|
|
43
|
+
/** Share or inject the cash-out session (tests, or your own cash-out UI). */
|
|
44
|
+
offrampSession?: OfframpSession;
|
|
45
|
+
/**
|
|
46
|
+
* A cash-out opened. Store the id if you want to bring the user back to it
|
|
47
|
+
* later (`resumeCashOut`): they must confirm or dispute once paid.
|
|
48
|
+
*/
|
|
49
|
+
onCashOutStarted?: (tradeId: string) => void;
|
|
50
|
+
/** A cash-out reached its end: settled, refunded or failed. */
|
|
51
|
+
onCashOutEnded?: (trade: FiatTrade) => void;
|
|
52
|
+
/** Show this cash-out trade on mount, e.g. one saved from `onCashOutStarted`. */
|
|
53
|
+
resumeCashOut?: string | null;
|
|
43
54
|
}
|
|
44
55
|
/**
|
|
45
56
|
* RecoilPay intents in one component: the user types what they want, sees
|
|
@@ -74,4 +85,28 @@ interface UseRecoilIntent extends IntentState {
|
|
|
74
85
|
*/
|
|
75
86
|
declare function useRecoilIntent(options?: UseRecoilIntentOptions): UseRecoilIntent;
|
|
76
87
|
|
|
77
|
-
|
|
88
|
+
interface UseOfframpOptions {
|
|
89
|
+
/** Aggregator base URL. Defaults to production. Read once, on first render. */
|
|
90
|
+
apiUrl?: string;
|
|
91
|
+
/** Bring your own session (shared, or for tests). */
|
|
92
|
+
session?: OfframpSession;
|
|
93
|
+
/** The connected wallet, or null. */
|
|
94
|
+
wallet?: IntentWallet | null;
|
|
95
|
+
}
|
|
96
|
+
interface UseOfframp extends OfframpState {
|
|
97
|
+
/** The session's `quote()`; renamed because `quote` is the chosen offer. */
|
|
98
|
+
requestQuote: OfframpSession['quote'];
|
|
99
|
+
confirm: OfframpSession['confirm'];
|
|
100
|
+
confirmReceived: OfframpSession['confirmReceived'];
|
|
101
|
+
dispute: OfframpSession['dispute'];
|
|
102
|
+
resume: OfframpSession['resume'];
|
|
103
|
+
reset: OfframpSession['reset'];
|
|
104
|
+
session: OfframpSession;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* A cash-out to a bank account as React state. Renders nothing; the
|
|
108
|
+
* `<RecoilIntent />` component uses it when a sentence asks to cash out.
|
|
109
|
+
*/
|
|
110
|
+
declare function useOfframp(options?: UseOfframpOptions): UseOfframp;
|
|
111
|
+
|
|
112
|
+
export { type IntentExample, RecoilIntent, type RecoilIntentProps, type RecoilTheme, type UseOfframp, type UseOfframpOptions, type UseRecoilIntent, type UseRecoilIntentOptions, useOfframp, useRecoilIntent };
|