@coinbase/cdp-react 0.0.38 → 0.0.39
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 +2 -1
- package/dist/assets/SendEvmTransactionButton.css +1 -0
- package/dist/assets/SendSolanaTransactionButton.css +1 -0
- package/dist/components/Fund/FundProvider.js +78 -74
- package/dist/components/Fund/hooks/useBuyUrl.d.ts +1 -2
- package/dist/components/Fund/hooks/useBuyUrl.js +23 -23
- package/dist/components/Fund/types.d.ts +2 -1
- package/dist/components/{SendTransactionButton → SendEvmTransactionButton}/index.d.ts +2 -2
- package/dist/components/SendEvmTransactionButton/index.js +67 -0
- package/dist/components/SendSolanaTransactionButton/index.d.ts +13 -0
- package/dist/components/SendSolanaTransactionButton/index.js +67 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +87 -85
- package/package.json +5 -5
- package/dist/assets/SendTransactionButton.css +0 -1
- package/dist/components/SendTransactionButton/index.js +0 -67
package/README.md
CHANGED
|
@@ -7,7 +7,8 @@ the CDP frontend SDK.
|
|
|
7
7
|
- {@link SignIn | `SignIn`} - the forms for the sign in flow, a logo, heading, and description text
|
|
8
8
|
- {@link SignOutButton | `SignOutButton`} - a sign out button
|
|
9
9
|
- {@link AuthButton | `AuthButton`} - the `SignOutButton` when logged in, and the `SignInModal` when logged out
|
|
10
|
-
- {@link
|
|
10
|
+
- {@link SendEvmTransactionButton | `SendEvmTransactionButton`} - a button that signs and sends an EVM transaction
|
|
11
|
+
- {@link SendSolanaTransactionButton | `SendSolanaTransactionButton`} - a button that signs and sends a Solana transaction
|
|
11
12
|
- {@link Fund | `Fund`} - the fund flow
|
|
12
13
|
- {@link FundModal | `FundModal`} - a button that triggers a modal with the fund flow
|
|
13
14
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.SendEvmTransactionButton-module__send-evm-transaction-button___74m57{padding-left:2em;padding-right:2em}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.SendSolanaTransactionButton-module__send-solana-transaction-button___OxwvB{padding-left:2em;padding-right:2em}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
const x = {
|
|
1
|
+
import { jsx as A } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as E, useContext as R, useEffect as f, useMemo as b } from "react";
|
|
3
|
+
import { useBuyUrl as M } from "./hooks/useBuyUrl.js";
|
|
4
|
+
import { useEmitLifecycleStatus as g } from "./hooks/useEmitLifecycleStatus.js";
|
|
5
|
+
import { useExchangeRate as k } from "./hooks/useExchangeRate.js";
|
|
6
|
+
import { usePaymentMethods as H } from "./hooks/usePaymentMethods.js";
|
|
7
|
+
import { useFundReducer as N } from "./useFundReducer.js";
|
|
8
|
+
const h = {
|
|
10
9
|
country: "US",
|
|
11
10
|
cryptoCurrency: "ETH",
|
|
12
11
|
cryptoDecimalPlaces: 8,
|
|
@@ -18,113 +17,118 @@ const x = {
|
|
|
18
17
|
transactionStatus: {
|
|
19
18
|
statusName: "init",
|
|
20
19
|
statusData: null
|
|
21
|
-
}
|
|
22
|
-
|
|
20
|
+
},
|
|
21
|
+
destinationAddress: ""
|
|
22
|
+
}, S = E(void 0), q = ({
|
|
23
23
|
children: c,
|
|
24
|
-
fetchBuyOptions:
|
|
25
|
-
fetchBuyQuote:
|
|
26
|
-
inputType:
|
|
24
|
+
fetchBuyOptions: v,
|
|
25
|
+
fetchBuyQuote: y,
|
|
26
|
+
inputType: D,
|
|
27
27
|
onError: u,
|
|
28
|
-
onStatus:
|
|
29
|
-
onSuccess:
|
|
30
|
-
...
|
|
28
|
+
onStatus: F,
|
|
29
|
+
onSuccess: I,
|
|
30
|
+
...w
|
|
31
31
|
}) => {
|
|
32
32
|
const {
|
|
33
33
|
country: t,
|
|
34
34
|
cryptoCurrency: e,
|
|
35
|
-
cryptoDecimalPlaces:
|
|
35
|
+
cryptoDecimalPlaces: i,
|
|
36
36
|
fiatCurrency: s,
|
|
37
|
-
fiatDecimalPlaces:
|
|
38
|
-
locale:
|
|
39
|
-
network:
|
|
40
|
-
presetAmountInputs:
|
|
41
|
-
redirectUrl:
|
|
42
|
-
subdivision:
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
fiatDecimalPlaces: d,
|
|
38
|
+
locale: m,
|
|
39
|
+
network: n,
|
|
40
|
+
presetAmountInputs: p,
|
|
41
|
+
redirectUrl: T,
|
|
42
|
+
subdivision: o,
|
|
43
|
+
destinationAddress: a
|
|
44
|
+
} = w, [l, r] = N({
|
|
45
|
+
...h,
|
|
45
46
|
country: t,
|
|
46
47
|
cryptoCurrency: e,
|
|
47
|
-
cryptoDecimalPlaces:
|
|
48
|
+
cryptoDecimalPlaces: i,
|
|
48
49
|
fiatCurrency: s,
|
|
49
|
-
fiatDecimalPlaces:
|
|
50
|
-
locale:
|
|
51
|
-
network:
|
|
52
|
-
presetAmountInputs:
|
|
53
|
-
subdivision:
|
|
54
|
-
|
|
50
|
+
fiatDecimalPlaces: d,
|
|
51
|
+
locale: m,
|
|
52
|
+
network: n,
|
|
53
|
+
presetAmountInputs: p,
|
|
54
|
+
subdivision: o,
|
|
55
|
+
destinationAddress: a,
|
|
56
|
+
selectedInputType: D || h.selectedInputType
|
|
55
57
|
});
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
f(() => {
|
|
59
|
+
r({
|
|
58
60
|
type: "SYNC_WITH_PROPS",
|
|
59
61
|
payload: {
|
|
60
62
|
country: t,
|
|
61
63
|
cryptoCurrency: e,
|
|
62
|
-
cryptoDecimalPlaces:
|
|
64
|
+
cryptoDecimalPlaces: i,
|
|
63
65
|
fiatCurrency: s,
|
|
64
|
-
fiatDecimalPlaces:
|
|
65
|
-
locale:
|
|
66
|
-
network:
|
|
67
|
-
presetAmountInputs:
|
|
68
|
-
subdivision:
|
|
66
|
+
fiatDecimalPlaces: d,
|
|
67
|
+
locale: m,
|
|
68
|
+
network: n,
|
|
69
|
+
presetAmountInputs: p,
|
|
70
|
+
subdivision: o,
|
|
71
|
+
destinationAddress: a
|
|
69
72
|
}
|
|
70
73
|
});
|
|
71
74
|
}, [
|
|
72
75
|
t,
|
|
73
76
|
e,
|
|
74
|
-
a,
|
|
75
|
-
s,
|
|
76
77
|
i,
|
|
78
|
+
s,
|
|
77
79
|
d,
|
|
78
|
-
o,
|
|
79
80
|
m,
|
|
81
|
+
n,
|
|
82
|
+
p,
|
|
83
|
+
o,
|
|
80
84
|
r,
|
|
81
|
-
|
|
82
|
-
]),
|
|
83
|
-
lifecycleStatus:
|
|
85
|
+
a
|
|
86
|
+
]), g({
|
|
87
|
+
lifecycleStatus: l.transactionStatus,
|
|
84
88
|
onError: u,
|
|
85
|
-
onStatus:
|
|
86
|
-
onSuccess:
|
|
89
|
+
onStatus: F,
|
|
90
|
+
onSuccess: I
|
|
87
91
|
});
|
|
88
|
-
const { fetchExchangeRate:
|
|
92
|
+
const { fetchExchangeRate: P } = k({
|
|
89
93
|
cryptoCurrency: e,
|
|
90
94
|
country: t,
|
|
91
|
-
dispatch:
|
|
92
|
-
fetchBuyQuote:
|
|
95
|
+
dispatch: r,
|
|
96
|
+
fetchBuyQuote: y,
|
|
93
97
|
fiatCurrency: s,
|
|
94
|
-
network:
|
|
98
|
+
network: n,
|
|
95
99
|
onError: u,
|
|
96
|
-
subdivision:
|
|
97
|
-
}), { fetchPaymentMethods:
|
|
100
|
+
subdivision: o
|
|
101
|
+
}), { fetchPaymentMethods: x } = H({
|
|
98
102
|
country: t,
|
|
99
103
|
cryptoCurrency: e,
|
|
100
|
-
dispatch:
|
|
101
|
-
fetchBuyOptions:
|
|
104
|
+
dispatch: r,
|
|
105
|
+
fetchBuyOptions: v,
|
|
102
106
|
fiatCurrency: s,
|
|
103
|
-
network:
|
|
107
|
+
network: n,
|
|
104
108
|
onError: u,
|
|
105
|
-
subdivision:
|
|
106
|
-
}), { fetchBuyUrl:
|
|
109
|
+
subdivision: o
|
|
110
|
+
}), { fetchBuyUrl: C } = M({
|
|
107
111
|
cryptoCurrency: e,
|
|
108
|
-
destinationAddress: A || void 0,
|
|
109
112
|
fiatCurrency: s,
|
|
110
|
-
fetchBuyQuote:
|
|
113
|
+
fetchBuyQuote: y,
|
|
111
114
|
country: t,
|
|
112
|
-
network:
|
|
113
|
-
redirectUrl:
|
|
114
|
-
subdivision:
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}, [y]), l(() => {
|
|
115
|
+
network: n,
|
|
116
|
+
redirectUrl: T,
|
|
117
|
+
subdivision: o,
|
|
118
|
+
destinationAddress: a
|
|
119
|
+
}), U = b(() => ({ state: l, dispatch: r, fetchBuyUrl: C }), [l, r, C]);
|
|
120
|
+
return f(() => {
|
|
119
121
|
P();
|
|
120
|
-
}, [P]),
|
|
121
|
-
|
|
122
|
-
|
|
122
|
+
}, [P]), f(() => {
|
|
123
|
+
x();
|
|
124
|
+
}, [x]), /* @__PURE__ */ A(S.Provider, { value: U, children: c });
|
|
125
|
+
}, z = () => {
|
|
126
|
+
const c = R(S);
|
|
123
127
|
if (!c)
|
|
124
128
|
throw new Error("useFundContext must be used within a FundProvider");
|
|
125
129
|
return c;
|
|
126
130
|
};
|
|
127
131
|
export {
|
|
128
|
-
|
|
129
|
-
|
|
132
|
+
q as FundProvider,
|
|
133
|
+
z as useFundContext
|
|
130
134
|
};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { OnrampError, FundProps, FundState } from '../types';
|
|
2
|
-
export type UseBuyUrlParams = Pick<FundState, "country" | "cryptoCurrency" | "fiatCurrency" | "network" | "subdivision"> & {
|
|
2
|
+
export type UseBuyUrlParams = Pick<FundState, "country" | "cryptoCurrency" | "fiatCurrency" | "network" | "subdivision" | "destinationAddress"> & {
|
|
3
3
|
fetchBuyQuote: FundProps["fetchBuyQuote"];
|
|
4
4
|
onError?: (e: OnrampError | undefined) => void;
|
|
5
|
-
destinationAddress?: string;
|
|
6
5
|
redirectUrl?: string;
|
|
7
6
|
};
|
|
8
7
|
export interface FetchBuyUrlParams {
|
|
@@ -8,29 +8,29 @@ const _ = (o) => {
|
|
|
8
8
|
}, h = ({
|
|
9
9
|
country: o,
|
|
10
10
|
cryptoCurrency: a,
|
|
11
|
-
destinationAddress:
|
|
11
|
+
destinationAddress: c,
|
|
12
12
|
fetchBuyQuote: u,
|
|
13
13
|
fiatCurrency: p,
|
|
14
|
-
network:
|
|
15
|
-
onError:
|
|
16
|
-
redirectUrl:
|
|
14
|
+
network: d,
|
|
15
|
+
onError: n,
|
|
16
|
+
redirectUrl: s,
|
|
17
17
|
subdivision: i
|
|
18
18
|
}) => {
|
|
19
|
-
const
|
|
20
|
-
async ({ paymentMethod:
|
|
21
|
-
if (isNaN(m) || !
|
|
19
|
+
const U = y(
|
|
20
|
+
async ({ paymentMethod: l, paymentAmount: m }, f) => {
|
|
21
|
+
if (isNaN(m) || !l)
|
|
22
22
|
return "";
|
|
23
23
|
try {
|
|
24
24
|
const e = (await u({
|
|
25
25
|
purchaseCurrency: a.toUpperCase(),
|
|
26
|
-
purchaseNetwork:
|
|
26
|
+
purchaseNetwork: d.toLowerCase(),
|
|
27
27
|
paymentCurrency: p.toUpperCase(),
|
|
28
28
|
paymentAmount: m.toFixed(),
|
|
29
|
-
paymentMethod:
|
|
29
|
+
paymentMethod: l.replace("_GUEST", ""),
|
|
30
30
|
// remove "_GUEST" from the payment method since it is not valid in the Buy Quote API
|
|
31
31
|
country: o.toUpperCase(),
|
|
32
32
|
subdivision: i?.toUpperCase(),
|
|
33
|
-
destinationAddress:
|
|
33
|
+
destinationAddress: c
|
|
34
34
|
})).onrampUrl;
|
|
35
35
|
if (!e) {
|
|
36
36
|
const r = {
|
|
@@ -38,39 +38,39 @@ const _ = (o) => {
|
|
|
38
38
|
code: "NO_ONRAMP_URL",
|
|
39
39
|
debugMessage: "No payment methods found for the selected country and currency. See docs for more information: https://docs.cdp.coinbase.com/onramp/docs/api-configurations"
|
|
40
40
|
};
|
|
41
|
-
return f?.(r),
|
|
41
|
+
return f?.(r), n?.(r), "";
|
|
42
42
|
}
|
|
43
|
-
if (
|
|
43
|
+
if (s && _(s)) {
|
|
44
44
|
const r = new URL(e);
|
|
45
|
-
return r.searchParams.set("redirectUrl",
|
|
45
|
+
return r.searchParams.set("redirectUrl", s), r.toString();
|
|
46
46
|
}
|
|
47
47
|
return e;
|
|
48
|
-
} catch (
|
|
48
|
+
} catch (t) {
|
|
49
49
|
let e;
|
|
50
|
-
return
|
|
50
|
+
return t instanceof Error ? e = {
|
|
51
51
|
errorType: "handled_error",
|
|
52
52
|
code: "BUY_URL_ERROR",
|
|
53
|
-
debugMessage:
|
|
53
|
+
debugMessage: t.message
|
|
54
54
|
} : e = {
|
|
55
55
|
errorType: "unknown_error",
|
|
56
56
|
code: "UNKNOWN_BUY_URL_ERROR",
|
|
57
|
-
debugMessage: JSON.stringify(
|
|
58
|
-
}, f?.(e),
|
|
57
|
+
debugMessage: JSON.stringify(t)
|
|
58
|
+
}, f?.(e), n?.(e), "";
|
|
59
59
|
}
|
|
60
60
|
},
|
|
61
61
|
[
|
|
62
62
|
o,
|
|
63
63
|
a,
|
|
64
|
-
|
|
64
|
+
c,
|
|
65
65
|
u,
|
|
66
66
|
p,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
d,
|
|
68
|
+
n,
|
|
69
|
+
s,
|
|
70
70
|
i
|
|
71
71
|
]
|
|
72
72
|
);
|
|
73
|
-
return R(() => ({ fetchBuyUrl:
|
|
73
|
+
return R(() => ({ fetchBuyUrl: U }), [U]);
|
|
74
74
|
};
|
|
75
75
|
export {
|
|
76
76
|
h as useBuyUrl
|
|
@@ -100,8 +100,9 @@ export interface FundState {
|
|
|
100
100
|
selectedPaymentMethod?: FundPaymentMethod;
|
|
101
101
|
subdivision?: string;
|
|
102
102
|
transactionStatus: FundLifecycleStatus;
|
|
103
|
+
destinationAddress: string;
|
|
103
104
|
}
|
|
104
|
-
export type FundStateProps = Pick<FundState, "country" | "cryptoCurrency" | "cryptoDecimalPlaces" | "fiatCurrency" | "fiatDecimalPlaces" | "locale" | "network" | "presetAmountInputs" | "subdivision">;
|
|
105
|
+
export type FundStateProps = Pick<FundState, "country" | "cryptoCurrency" | "cryptoDecimalPlaces" | "fiatCurrency" | "fiatDecimalPlaces" | "locale" | "network" | "presetAmountInputs" | "subdivision" | "destinationAddress">;
|
|
105
106
|
export interface FundProps extends FundStateProps, FundLifecycleEvents {
|
|
106
107
|
children?: ReactNode | ((state: FundState) => ReactNode);
|
|
107
108
|
className?: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { APIError, SendEvmTransactionOptions } from '@coinbase/cdp-hooks';
|
|
2
2
|
import { ButtonHTMLAttributes, ReactNode } from 'react';
|
|
3
3
|
import { ButtonVariant } from '../../theme/theme';
|
|
4
|
-
export interface
|
|
4
|
+
export interface SendEvmTransactionButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "onError"> {
|
|
5
5
|
account: SendEvmTransactionOptions["evmAccount"];
|
|
6
6
|
network: SendEvmTransactionOptions["network"];
|
|
7
7
|
onError?: (error: APIError | Error) => void;
|
|
@@ -10,4 +10,4 @@ export interface SendTransactionButtonProps extends Omit<ButtonHTMLAttributes<HT
|
|
|
10
10
|
transaction: SendEvmTransactionOptions["transaction"];
|
|
11
11
|
variant?: ButtonVariant;
|
|
12
12
|
}
|
|
13
|
-
export declare const
|
|
13
|
+
export declare const SendEvmTransactionButton: ({ account, children, className, network, onClick, onError, onSuccess, pendingLabel, transaction, variant, ...props }: SendEvmTransactionButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { jsx as S } from "react/jsx-runtime";
|
|
2
|
+
import { useSendEvmTransaction as b, APIError as y } from "@coinbase/cdp-hooks";
|
|
3
|
+
import { useState as T, useCallback as _ } from "react";
|
|
4
|
+
import { Button as w } from "../ui/Button/index.js";
|
|
5
|
+
import "../../theme/theme.js";
|
|
6
|
+
import { getMessageFromUnknownError as B } from "../../utils/getMessageFromUnknownError.js";
|
|
7
|
+
import '../../assets/SendEvmTransactionButton.css';const P = {
|
|
8
|
+
"send-evm-transaction-button": "SendEvmTransactionButton-module__send-evm-transaction-button___74m57"
|
|
9
|
+
}, q = ({
|
|
10
|
+
account: e,
|
|
11
|
+
children: f,
|
|
12
|
+
className: l = "",
|
|
13
|
+
network: s,
|
|
14
|
+
onClick: o,
|
|
15
|
+
onError: a,
|
|
16
|
+
onSuccess: i,
|
|
17
|
+
pendingLabel: u,
|
|
18
|
+
transaction: r,
|
|
19
|
+
variant: p = "primary",
|
|
20
|
+
...g
|
|
21
|
+
}) => {
|
|
22
|
+
const [v, m] = T(!1), { sendEvmTransaction: c } = b(), h = _(
|
|
23
|
+
async (d) => {
|
|
24
|
+
d.preventDefault(), o?.(d);
|
|
25
|
+
try {
|
|
26
|
+
if (!e || !s || !r) {
|
|
27
|
+
const n = [];
|
|
28
|
+
throw e || n.push("account"), s || n.push("network"), r || n.push("transaction"), new Error(`Missing required parameters: ${n.join(", ")}`);
|
|
29
|
+
}
|
|
30
|
+
m(!0);
|
|
31
|
+
const { transactionHash: t } = await c({
|
|
32
|
+
transaction: r,
|
|
33
|
+
evmAccount: e,
|
|
34
|
+
network: s
|
|
35
|
+
});
|
|
36
|
+
i?.(t);
|
|
37
|
+
} catch (t) {
|
|
38
|
+
let n;
|
|
39
|
+
if (t instanceof y || t instanceof Error)
|
|
40
|
+
n = t;
|
|
41
|
+
else {
|
|
42
|
+
const E = B(t);
|
|
43
|
+
n = new Error(E);
|
|
44
|
+
}
|
|
45
|
+
a?.(n);
|
|
46
|
+
} finally {
|
|
47
|
+
m(!1);
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
[e, s, o, a, i, c, r]
|
|
51
|
+
);
|
|
52
|
+
return /* @__PURE__ */ S(
|
|
53
|
+
w,
|
|
54
|
+
{
|
|
55
|
+
className: `${P["send-evm-transaction-button"]} ${l}`,
|
|
56
|
+
isPending: v,
|
|
57
|
+
pendingLabel: u || "Sending transaction...",
|
|
58
|
+
onClick: h,
|
|
59
|
+
variant: p,
|
|
60
|
+
...g,
|
|
61
|
+
children: f || "Send transaction"
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
export {
|
|
66
|
+
q as SendEvmTransactionButton
|
|
67
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { APIError, SendSolanaTransactionOptions } from '@coinbase/cdp-hooks';
|
|
2
|
+
import { ButtonHTMLAttributes, ReactNode } from 'react';
|
|
3
|
+
import { ButtonVariant } from '../../theme/theme';
|
|
4
|
+
export interface SendSolanaTransactionButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "onError"> {
|
|
5
|
+
account: SendSolanaTransactionOptions["solanaAccount"];
|
|
6
|
+
network: SendSolanaTransactionOptions["network"];
|
|
7
|
+
onError?: (error: APIError | Error) => void;
|
|
8
|
+
onSuccess?: (signature: string) => void;
|
|
9
|
+
pendingLabel?: ReactNode;
|
|
10
|
+
transaction: SendSolanaTransactionOptions["transaction"];
|
|
11
|
+
variant?: ButtonVariant;
|
|
12
|
+
}
|
|
13
|
+
export declare const SendSolanaTransactionButton: ({ account, children, className, network, onClick, onError, onSuccess, pendingLabel, transaction, variant, ...props }: SendSolanaTransactionButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { jsx as y } from "react/jsx-runtime";
|
|
2
|
+
import { useSendSolanaTransaction as T, APIError as _ } from "@coinbase/cdp-hooks";
|
|
3
|
+
import { useState as w, useCallback as B } from "react";
|
|
4
|
+
import { Button as E } from "../ui/Button/index.js";
|
|
5
|
+
import "../../theme/theme.js";
|
|
6
|
+
import { getMessageFromUnknownError as x } from "../../utils/getMessageFromUnknownError.js";
|
|
7
|
+
import '../../assets/SendSolanaTransactionButton.css';const P = {
|
|
8
|
+
"send-solana-transaction-button": "SendSolanaTransactionButton-module__send-solana-transaction-button___OxwvB"
|
|
9
|
+
}, q = ({
|
|
10
|
+
account: t,
|
|
11
|
+
children: d,
|
|
12
|
+
className: f = "",
|
|
13
|
+
network: s,
|
|
14
|
+
onClick: r,
|
|
15
|
+
onError: e,
|
|
16
|
+
onSuccess: i,
|
|
17
|
+
pendingLabel: u,
|
|
18
|
+
transaction: o,
|
|
19
|
+
variant: p = "primary",
|
|
20
|
+
...S
|
|
21
|
+
}) => {
|
|
22
|
+
const [g, l] = w(!1), { sendSolanaTransaction: c } = T(), h = B(
|
|
23
|
+
async (m) => {
|
|
24
|
+
m.preventDefault(), r?.(m);
|
|
25
|
+
try {
|
|
26
|
+
if (!t || !s || !o) {
|
|
27
|
+
const n = [];
|
|
28
|
+
throw t || n.push("account"), s || n.push("network"), o || n.push("transaction"), new Error(`Missing required parameters: ${n.join(", ")}`);
|
|
29
|
+
}
|
|
30
|
+
l(!0);
|
|
31
|
+
const { transactionSignature: a } = await c({
|
|
32
|
+
transaction: o,
|
|
33
|
+
solanaAccount: t,
|
|
34
|
+
network: s
|
|
35
|
+
});
|
|
36
|
+
i?.(a);
|
|
37
|
+
} catch (a) {
|
|
38
|
+
let n;
|
|
39
|
+
if (a instanceof _ || a instanceof Error)
|
|
40
|
+
n = a;
|
|
41
|
+
else {
|
|
42
|
+
const b = x(a);
|
|
43
|
+
n = new Error(b);
|
|
44
|
+
}
|
|
45
|
+
e?.(n);
|
|
46
|
+
} finally {
|
|
47
|
+
l(!1);
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
[t, s, r, e, i, c, o]
|
|
51
|
+
);
|
|
52
|
+
return /* @__PURE__ */ y(
|
|
53
|
+
E,
|
|
54
|
+
{
|
|
55
|
+
className: `${P["send-solana-transaction-button"]} ${f}`,
|
|
56
|
+
isPending: g,
|
|
57
|
+
pendingLabel: u || "Sending transaction...",
|
|
58
|
+
onClick: h,
|
|
59
|
+
variant: p,
|
|
60
|
+
...S,
|
|
61
|
+
children: d || "Send transaction"
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
export {
|
|
66
|
+
q as SendSolanaTransactionButton
|
|
67
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ export * from './components/CDPReactProvider';
|
|
|
2
2
|
export * from './components/AuthButton';
|
|
3
3
|
export * from './components/Fund';
|
|
4
4
|
export * from './components/FundModal';
|
|
5
|
-
export * from './components/
|
|
5
|
+
export * from './components/SendEvmTransactionButton';
|
|
6
|
+
export * from './components/SendSolanaTransactionButton';
|
|
6
7
|
export * from './components/SignIn';
|
|
7
8
|
export * from './components/SignOutButton';
|
|
8
9
|
export * from './components/SignInModal';
|
package/dist/index.js
CHANGED
|
@@ -1,44 +1,45 @@
|
|
|
1
1
|
import { AUTH_METHODS as e, CDPReactProvider as t, useAppConfig as n } from "./components/CDPReactProvider/index.js";
|
|
2
2
|
import { AuthButton as p } from "./components/AuthButton/index.js";
|
|
3
3
|
import { Fund as x, FundFooter as i } from "./components/Fund/index.js";
|
|
4
|
-
import { FundModal as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
4
|
+
import { FundModal as s } from "./components/FundModal/index.js";
|
|
5
|
+
import { SendEvmTransactionButton as u } from "./components/SendEvmTransactionButton/index.js";
|
|
6
|
+
import { SendSolanaTransactionButton as l } from "./components/SendSolanaTransactionButton/index.js";
|
|
7
|
+
import { SignIn as S } from "./components/SignIn/index.js";
|
|
8
|
+
import { useSignInReducer as C } from "./components/SignIn/useSignInReducer.js";
|
|
9
|
+
import { SignOutButton as F } from "./components/SignOutButton/index.js";
|
|
10
|
+
import { SignInModal as k } from "./components/SignInModal/index.js";
|
|
11
|
+
import { ThemeProvider as E, useTheme as b } from "./components/ThemeProvider/index.js";
|
|
12
|
+
import { cssVariables as v } from "./theme/cssVariables.js";
|
|
13
|
+
import { theme as w } from "./theme/theme.js";
|
|
14
|
+
import { borderRadius as P, borderRadiusComponents as R, borderRadiusSemantic as O, colors as U, colorsBase as V, colorsComponents as H, colorsSemantic as L, font as j, fontComponents as N, fontSemantic as X, tokens as _ } from "./theme/tokens.js";
|
|
15
|
+
import { flattenTokensObject as y, themeToCssVariables as z } from "./theme/utils.js";
|
|
16
|
+
import { IconArrowLeft as J } from "./icons/IconArrowLeft.js";
|
|
17
|
+
import { IconArrowsUpDown as Q } from "./icons/IconArrowsUpDown.js";
|
|
18
|
+
import { IconCheck as Y } from "./icons/IconCheck.js";
|
|
19
|
+
import { IconCheckCircle as $ } from "./icons/IconCheckCircle.js";
|
|
20
|
+
import { IconChevronDown as ro } from "./icons/IconChevronDown.js";
|
|
21
|
+
import { IconEnvelope as to } from "./icons/IconEnvelope.js";
|
|
22
|
+
import { IconExclamationCircle as mo } from "./icons/IconExclamationCircle.js";
|
|
23
|
+
import { IconExclamationTriangle as fo } from "./icons/IconExclamationTriangle.js";
|
|
24
|
+
import { IconLock as io } from "./icons/IconLock.js";
|
|
25
|
+
import { IconPhone as so } from "./icons/IconPhone.js";
|
|
26
|
+
import { IconXMark as uo } from "./icons/IconXMark.js";
|
|
27
|
+
import { clamp as lo } from "./utils/clamp.js";
|
|
28
|
+
import { getMessageFromUnknownError as go } from "./utils/getMessageFromUnknownError.js";
|
|
29
|
+
import { isApiError as ho } from "./utils/isApiError.js";
|
|
30
|
+
import { isEmailInvalid as To } from "./utils/isEmailInvalid.js";
|
|
31
|
+
import { parseValuesFromPhoneNumber as Bo } from "./utils/parseValuesFromPhoneNumber.js";
|
|
31
32
|
import { FundForm as bo } from "./components/Fund/FundForm.js";
|
|
32
|
-
import { FundTitle as
|
|
33
|
-
import { useFundContext as
|
|
34
|
-
import { SignInAuthMethodButtons as
|
|
35
|
-
import { SignInBackButton as
|
|
36
|
-
import { SignInDescription as
|
|
37
|
-
import { SignInFooter as
|
|
38
|
-
import { SignInForm as
|
|
39
|
-
import { SignInImage as
|
|
40
|
-
import { SignInTitle as
|
|
41
|
-
import { useSignInContext as
|
|
33
|
+
import { FundTitle as vo } from "./components/Fund/FundTitle.js";
|
|
34
|
+
import { useFundContext as wo } from "./components/Fund/FundProvider.js";
|
|
35
|
+
import { SignInAuthMethodButtons as Po } from "./components/SignIn/SignInAuthMethodButtons.js";
|
|
36
|
+
import { SignInBackButton as Oo } from "./components/SignIn/SignInBackButton.js";
|
|
37
|
+
import { SignInDescription as Vo } from "./components/SignIn/SignInDescription.js";
|
|
38
|
+
import { SignInFooter as Lo } from "./components/SignIn/SignInFooter.js";
|
|
39
|
+
import { SignInForm as No } from "./components/SignIn/SignInForm.js";
|
|
40
|
+
import { SignInImage as _o } from "./components/SignIn/SignInImage.js";
|
|
41
|
+
import { SignInTitle as yo } from "./components/SignIn/SignInTitle.js";
|
|
42
|
+
import { useSignInContext as Go } from "./components/SignIn/SignInProvider.js";
|
|
42
43
|
export {
|
|
43
44
|
e as AUTH_METHODS,
|
|
44
45
|
p as AuthButton,
|
|
@@ -46,54 +47,55 @@ export {
|
|
|
46
47
|
x as Fund,
|
|
47
48
|
i as FundFooter,
|
|
48
49
|
bo as FundForm,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
u as
|
|
63
|
-
l as
|
|
64
|
-
|
|
65
|
-
Po as
|
|
66
|
-
Oo as
|
|
67
|
-
Vo as
|
|
68
|
-
Lo as
|
|
69
|
-
No as
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
ho as
|
|
90
|
-
To as
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
50
|
+
s as FundModal,
|
|
51
|
+
vo as FundTitle,
|
|
52
|
+
J as IconArrowLeft,
|
|
53
|
+
Q as IconArrowsUpDown,
|
|
54
|
+
Y as IconCheck,
|
|
55
|
+
$ as IconCheckCircle,
|
|
56
|
+
ro as IconChevronDown,
|
|
57
|
+
to as IconEnvelope,
|
|
58
|
+
mo as IconExclamationCircle,
|
|
59
|
+
fo as IconExclamationTriangle,
|
|
60
|
+
io as IconLock,
|
|
61
|
+
so as IconPhone,
|
|
62
|
+
uo as IconXMark,
|
|
63
|
+
u as SendEvmTransactionButton,
|
|
64
|
+
l as SendSolanaTransactionButton,
|
|
65
|
+
S as SignIn,
|
|
66
|
+
Po as SignInAuthMethodButtons,
|
|
67
|
+
Oo as SignInBackButton,
|
|
68
|
+
Vo as SignInDescription,
|
|
69
|
+
Lo as SignInFooter,
|
|
70
|
+
No as SignInForm,
|
|
71
|
+
_o as SignInImage,
|
|
72
|
+
k as SignInModal,
|
|
73
|
+
yo as SignInTitle,
|
|
74
|
+
F as SignOutButton,
|
|
75
|
+
E as ThemeProvider,
|
|
76
|
+
P as borderRadius,
|
|
77
|
+
R as borderRadiusComponents,
|
|
78
|
+
O as borderRadiusSemantic,
|
|
79
|
+
lo as clamp,
|
|
80
|
+
U as colors,
|
|
81
|
+
V as colorsBase,
|
|
82
|
+
H as colorsComponents,
|
|
83
|
+
L as colorsSemantic,
|
|
84
|
+
v as cssVariables,
|
|
85
|
+
y as flattenTokensObject,
|
|
86
|
+
j as font,
|
|
87
|
+
N as fontComponents,
|
|
88
|
+
X as fontSemantic,
|
|
89
|
+
go as getMessageFromUnknownError,
|
|
90
|
+
ho as isApiError,
|
|
91
|
+
To as isEmailInvalid,
|
|
92
|
+
Bo as parseValuesFromPhoneNumber,
|
|
93
|
+
w as theme,
|
|
94
|
+
z as themeToCssVariables,
|
|
95
|
+
_ as tokens,
|
|
94
96
|
n as useAppConfig,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
97
|
+
wo as useFundContext,
|
|
98
|
+
Go as useSignInContext,
|
|
99
|
+
C as useSignInReducer,
|
|
98
100
|
b as useTheme
|
|
99
101
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coinbase/cdp-react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.39",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@internationalized/number": "3.6.4",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
16
|
"react": ">=18.2.0",
|
|
17
|
-
"@coinbase/cdp-core": "^0.0.
|
|
18
|
-
"@coinbase/cdp-hooks": "^0.0.
|
|
17
|
+
"@coinbase/cdp-core": "^0.0.39",
|
|
18
|
+
"@coinbase/cdp-hooks": "^0.0.39"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@size-limit/preset-big-lib": "^11.2.0",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"vite": "^7.0.4",
|
|
46
46
|
"vite-plugin-dts": "^4.5.4",
|
|
47
47
|
"vite-plugin-lib-inject-css": "^2.2.2",
|
|
48
|
-
"@coinbase/cdp-core": "^0.0.
|
|
49
|
-
"@coinbase/cdp-hooks": "^0.0.
|
|
48
|
+
"@coinbase/cdp-core": "^0.0.39",
|
|
49
|
+
"@coinbase/cdp-hooks": "^0.0.39"
|
|
50
50
|
},
|
|
51
51
|
"size-limit": [
|
|
52
52
|
{
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.SendTransactionButton-module__send-transaction-button___-6UsN{padding-left:2em;padding-right:2em}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { jsx as b } from "react/jsx-runtime";
|
|
2
|
-
import { useSendEvmTransaction as y, APIError as T } from "@coinbase/cdp-hooks";
|
|
3
|
-
import { useState as _, useCallback as v } from "react";
|
|
4
|
-
import { Button as w } from "../ui/Button/index.js";
|
|
5
|
-
import "../../theme/theme.js";
|
|
6
|
-
import { getMessageFromUnknownError as B } from "../../utils/getMessageFromUnknownError.js";
|
|
7
|
-
import '../../assets/SendTransactionButton.css';const P = {
|
|
8
|
-
"send-transaction-button": "SendTransactionButton-module__send-transaction-button___-6UsN"
|
|
9
|
-
}, N = ({
|
|
10
|
-
account: s,
|
|
11
|
-
children: f,
|
|
12
|
-
className: l = "",
|
|
13
|
-
network: r,
|
|
14
|
-
onClick: o,
|
|
15
|
-
onError: a,
|
|
16
|
-
onSuccess: i,
|
|
17
|
-
pendingLabel: u,
|
|
18
|
-
transaction: e,
|
|
19
|
-
variant: p = "primary",
|
|
20
|
-
...g
|
|
21
|
-
}) => {
|
|
22
|
-
const [h, c] = _(!1), { sendEvmTransaction: m } = y(), E = v(
|
|
23
|
-
async (d) => {
|
|
24
|
-
d.preventDefault(), o?.(d);
|
|
25
|
-
try {
|
|
26
|
-
if (!s || !r || !e) {
|
|
27
|
-
const n = [];
|
|
28
|
-
throw s || n.push("account"), r || n.push("network"), e || n.push("transaction"), new Error(`Missing required parameters: ${n.join(", ")}`);
|
|
29
|
-
}
|
|
30
|
-
c(!0);
|
|
31
|
-
const { transactionHash: t } = await m({
|
|
32
|
-
transaction: e,
|
|
33
|
-
evmAccount: s,
|
|
34
|
-
network: r
|
|
35
|
-
});
|
|
36
|
-
i?.(t);
|
|
37
|
-
} catch (t) {
|
|
38
|
-
let n;
|
|
39
|
-
if (t instanceof T || t instanceof Error)
|
|
40
|
-
n = t;
|
|
41
|
-
else {
|
|
42
|
-
const S = B(t);
|
|
43
|
-
n = new Error(S);
|
|
44
|
-
}
|
|
45
|
-
a?.(n);
|
|
46
|
-
} finally {
|
|
47
|
-
c(!1);
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
[s, r, o, a, i, m, e]
|
|
51
|
-
);
|
|
52
|
-
return /* @__PURE__ */ b(
|
|
53
|
-
w,
|
|
54
|
-
{
|
|
55
|
-
className: `${P["send-transaction-button"]} ${l}`,
|
|
56
|
-
isPending: h,
|
|
57
|
-
pendingLabel: u || "Sending transaction...",
|
|
58
|
-
onClick: E,
|
|
59
|
-
variant: p,
|
|
60
|
-
...g,
|
|
61
|
-
children: f || "Send transaction"
|
|
62
|
-
}
|
|
63
|
-
);
|
|
64
|
-
};
|
|
65
|
-
export {
|
|
66
|
-
N as SendTransactionButton
|
|
67
|
-
};
|