@coinlist-co/react 0.11.0 → 0.11.1-rc.22d81d4

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.
Files changed (34) hide show
  1. package/dist/chunk-AQIHCFW4.js +279 -0
  2. package/dist/chunk-AQIHCFW4.js.map +1 -0
  3. package/dist/{chunk-B2HCVPCQ.js → chunk-PRG3EDQJ.js} +25 -10
  4. package/dist/chunk-PRG3EDQJ.js.map +1 -0
  5. package/dist/{chunk-UIIXXLA7.js → chunk-ZVB6KWZ2.js} +484 -141
  6. package/dist/chunk-ZVB6KWZ2.js.map +1 -0
  7. package/dist/client/index.cjs +1307 -461
  8. package/dist/client/index.cjs.map +1 -1
  9. package/dist/client/index.d.cts +216 -211
  10. package/dist/client/index.d.ts +216 -211
  11. package/dist/client/index.js +464 -108
  12. package/dist/client/index.js.map +1 -1
  13. package/dist/collections-DrJFEDHl.d.cts +116 -0
  14. package/dist/collections-pLtrj6fw.d.ts +116 -0
  15. package/dist/{config-B5mwS_2l.d.cts → config-C6vlghJY.d.cts} +713 -22
  16. package/dist/{config-B5mwS_2l.d.ts → config-C6vlghJY.d.ts} +713 -22
  17. package/dist/server/index.cjs +766 -209
  18. package/dist/server/index.cjs.map +1 -1
  19. package/dist/server/index.d.cts +80 -3
  20. package/dist/server/index.d.ts +80 -3
  21. package/dist/server/index.js +120 -51
  22. package/dist/server/index.js.map +1 -1
  23. package/dist/shared/index.cjs +486 -123
  24. package/dist/shared/index.cjs.map +1 -1
  25. package/dist/shared/index.d.cts +18 -5
  26. package/dist/shared/index.d.ts +18 -5
  27. package/dist/shared/index.js +8 -2
  28. package/package.json +3 -2
  29. package/dist/chunk-B2HCVPCQ.js.map +0 -1
  30. package/dist/chunk-KDGNDAHA.js +0 -146
  31. package/dist/chunk-KDGNDAHA.js.map +0 -1
  32. package/dist/chunk-UIIXXLA7.js.map +0 -1
  33. package/dist/collections-BhDkYmzV.d.cts +0 -65
  34. package/dist/collections-CZhHoQHr.d.ts +0 -65
@@ -0,0 +1,116 @@
1
+ import { ay as ClientId, be as RedirectUri, az as CodeChallenge, b3 as PKCEState, C as CodeVerifier, n as EvmWalletAddress, a as EthereumChain, bx as Tx, B as BlockchainAmount, bn as SwapPreview, Q as AssetDecimals, ar as Newtype } from './config-C6vlghJY.cjs';
2
+ import { Hex, Abi, Hash, TransactionReceipt } from 'viem';
3
+
4
+ type PKCEParams = {
5
+ clientId: ClientId;
6
+ responseType: 'code';
7
+ redirectUri: RedirectUri;
8
+ codeChallenge: CodeChallenge;
9
+ codeChallengeMethod: 'S256';
10
+ state: PKCEState;
11
+ codeVerifier: CodeVerifier;
12
+ };
13
+ type PKCEConfig = {
14
+ clientId: ClientId;
15
+ redirectUri: RedirectUri;
16
+ };
17
+ /**
18
+ * Generates PKCE parameters for an OAuth2 authorization code flow.
19
+ * Pure crypto — no React, no DOM beyond Web Crypto API. Safe to use
20
+ * in server-side code and Next.js middleware.
21
+ */
22
+ declare function generatePKCEParams(config: PKCEConfig): Promise<PKCEParams>;
23
+
24
+ type WriteContractParams = {
25
+ abi: Abi;
26
+ address: `0x${string}`;
27
+ functionName: string;
28
+ args?: readonly unknown[];
29
+ value?: bigint;
30
+ chain: EthereumChain;
31
+ };
32
+ type BroadcastTxParams = Tx & {
33
+ chain: EthereumChain;
34
+ };
35
+ /**
36
+ * The signing-only wallet capability: address + `signMessage`. This is all the
37
+ * external-wallet ownership proof needs (see `useConnectWallet`), so hosts can
38
+ * satisfy that flow without implementing on-chain capabilities. The richer
39
+ * {@link EvmWallet} extends this for swap flows.
40
+ *
41
+ * SDK users implement this against their own wallet stack (e.g. viem, wagmi,
42
+ * Privy). `signMessage` throws on failure and the SDK classifies it.
43
+ */
44
+ interface EvmSigner {
45
+ readonly address: EvmWalletAddress;
46
+ signMessage(message: string): Promise<Hex>;
47
+ }
48
+ /**
49
+ * The full on-chain wallet the SDK needs to run the swap flows: an
50
+ * {@link EvmSigner} plus contract writes, raw-tx broadcast, and confirmation.
51
+ * SDK users implement this against their own wallet stack (e.g. viem, wagmi,
52
+ * Privy).
53
+ *
54
+ * Methods throw on failure. The SDK catches and classifies the thrown error
55
+ * (viem's `UserRejectedRequestError`, `InsufficientFundsError`, timeouts, …)
56
+ * into a typed {@link WalletError}, so implementers can simply let their wallet
57
+ * library's errors propagate.
58
+ */
59
+ interface EvmWallet extends EvmSigner {
60
+ writeContract(params: WriteContractParams): Promise<Hash>;
61
+ broadcastRawTx(params: BroadcastTxParams): Promise<Hash>;
62
+ awaitTx(hash: Hash, chain: EthereumChain): Promise<TransactionReceipt>;
63
+ }
64
+ /**
65
+ * The host-provided wallet the ownership flow signs with: the signing-only
66
+ * {@link EvmSigner} plus the {@link EthereumChain} the signature is proven on.
67
+ * `chain` rides on the wallet (not the offer) because the binding is
68
+ * chain-agnostic: it only records which EVM chain signed.
69
+ */
70
+ type ConnectWallet = EvmSigner & {
71
+ readonly chain: EthereumChain;
72
+ };
73
+
74
+ /**
75
+ * A read-only quote for a swap as domain amounts: how much goes in, the
76
+ * protocol fee, and how much would come out. Derived from the raw
77
+ * {@link SwapPreview} the swap contract returns.
78
+ */
79
+ type SwapQuote = {
80
+ inputTokenAmount: BlockchainAmount;
81
+ fee: BlockchainAmount;
82
+ outputTokenAmount: BlockchainAmount;
83
+ };
84
+ declare const SwapQuote: {
85
+ /**
86
+ * Assembles a {@link SwapQuote} from a raw contract {@link SwapPreview}. The
87
+ * input and fee are denominated in the input token; the output in the output
88
+ * token.
89
+ */
90
+ fromPreview: (preview: SwapPreview, inputDecimals: AssetDecimals, outputDecimals: AssetDecimals) => SwapQuote;
91
+ };
92
+
93
+ type FormattedAmountUi = Newtype<string, 'FormattedAmountUi'>;
94
+ declare const FormattedAmountUi: (value: string) => FormattedAmountUi;
95
+ type FormattedPercentUi = Newtype<string, 'FormattedPercentUi'>;
96
+ declare const FormattedPercentUi: (value: string) => FormattedPercentUi;
97
+ type TxExplorerUrl = Newtype<string, 'TxExplorerUrl'>;
98
+ declare const TxExplorerUrl: (value: string) => TxExplorerUrl;
99
+ /**
100
+ * A wallet address shortened for display (e.g. `0x1234…5678`). Keeps a
101
+ * `0x${string}` base but drops the runtime `0x` narrowing.
102
+ */
103
+ type ShortenedWalletAddress = Newtype<`0x${string}`, 'ShortenedWalletAddress'>;
104
+ declare const ShortenedWalletAddress: (value: string) => ShortenedWalletAddress;
105
+ type FormattedAmountAssetUi = Newtype<string, 'FormattedAmountAssetUi'>;
106
+ declare const FormattedAmountAssetUi: (value: string) => FormattedAmountAssetUi;
107
+ type AssetIconUrl = Newtype<string, 'AssetIconUrl'>;
108
+ declare const AssetIconUrl: (value: string) => AssetIconUrl;
109
+
110
+ /**
111
+ * An array guaranteed to hold at least one element. Use it where an empty list
112
+ * would be a bug (e.g. the set of assets a swap always offers).
113
+ */
114
+ type NonEmptyArray<T> = [T, ...T[]];
115
+
116
+ export { AssetIconUrl as A, type BroadcastTxParams as B, type ConnectWallet as C, type EvmWallet as E, FormattedAmountAssetUi as F, type NonEmptyArray as N, type PKCEConfig as P, SwapQuote as S, TxExplorerUrl as T, type WriteContractParams as W, ShortenedWalletAddress as a, FormattedPercentUi as b, type EvmSigner as c, FormattedAmountUi as d, type PKCEParams as e, generatePKCEParams as g };
@@ -0,0 +1,116 @@
1
+ import { ay as ClientId, be as RedirectUri, az as CodeChallenge, b3 as PKCEState, C as CodeVerifier, n as EvmWalletAddress, a as EthereumChain, bx as Tx, B as BlockchainAmount, bn as SwapPreview, Q as AssetDecimals, ar as Newtype } from './config-C6vlghJY.js';
2
+ import { Hex, Abi, Hash, TransactionReceipt } from 'viem';
3
+
4
+ type PKCEParams = {
5
+ clientId: ClientId;
6
+ responseType: 'code';
7
+ redirectUri: RedirectUri;
8
+ codeChallenge: CodeChallenge;
9
+ codeChallengeMethod: 'S256';
10
+ state: PKCEState;
11
+ codeVerifier: CodeVerifier;
12
+ };
13
+ type PKCEConfig = {
14
+ clientId: ClientId;
15
+ redirectUri: RedirectUri;
16
+ };
17
+ /**
18
+ * Generates PKCE parameters for an OAuth2 authorization code flow.
19
+ * Pure crypto — no React, no DOM beyond Web Crypto API. Safe to use
20
+ * in server-side code and Next.js middleware.
21
+ */
22
+ declare function generatePKCEParams(config: PKCEConfig): Promise<PKCEParams>;
23
+
24
+ type WriteContractParams = {
25
+ abi: Abi;
26
+ address: `0x${string}`;
27
+ functionName: string;
28
+ args?: readonly unknown[];
29
+ value?: bigint;
30
+ chain: EthereumChain;
31
+ };
32
+ type BroadcastTxParams = Tx & {
33
+ chain: EthereumChain;
34
+ };
35
+ /**
36
+ * The signing-only wallet capability: address + `signMessage`. This is all the
37
+ * external-wallet ownership proof needs (see `useConnectWallet`), so hosts can
38
+ * satisfy that flow without implementing on-chain capabilities. The richer
39
+ * {@link EvmWallet} extends this for swap flows.
40
+ *
41
+ * SDK users implement this against their own wallet stack (e.g. viem, wagmi,
42
+ * Privy). `signMessage` throws on failure and the SDK classifies it.
43
+ */
44
+ interface EvmSigner {
45
+ readonly address: EvmWalletAddress;
46
+ signMessage(message: string): Promise<Hex>;
47
+ }
48
+ /**
49
+ * The full on-chain wallet the SDK needs to run the swap flows: an
50
+ * {@link EvmSigner} plus contract writes, raw-tx broadcast, and confirmation.
51
+ * SDK users implement this against their own wallet stack (e.g. viem, wagmi,
52
+ * Privy).
53
+ *
54
+ * Methods throw on failure. The SDK catches and classifies the thrown error
55
+ * (viem's `UserRejectedRequestError`, `InsufficientFundsError`, timeouts, …)
56
+ * into a typed {@link WalletError}, so implementers can simply let their wallet
57
+ * library's errors propagate.
58
+ */
59
+ interface EvmWallet extends EvmSigner {
60
+ writeContract(params: WriteContractParams): Promise<Hash>;
61
+ broadcastRawTx(params: BroadcastTxParams): Promise<Hash>;
62
+ awaitTx(hash: Hash, chain: EthereumChain): Promise<TransactionReceipt>;
63
+ }
64
+ /**
65
+ * The host-provided wallet the ownership flow signs with: the signing-only
66
+ * {@link EvmSigner} plus the {@link EthereumChain} the signature is proven on.
67
+ * `chain` rides on the wallet (not the offer) because the binding is
68
+ * chain-agnostic: it only records which EVM chain signed.
69
+ */
70
+ type ConnectWallet = EvmSigner & {
71
+ readonly chain: EthereumChain;
72
+ };
73
+
74
+ /**
75
+ * A read-only quote for a swap as domain amounts: how much goes in, the
76
+ * protocol fee, and how much would come out. Derived from the raw
77
+ * {@link SwapPreview} the swap contract returns.
78
+ */
79
+ type SwapQuote = {
80
+ inputTokenAmount: BlockchainAmount;
81
+ fee: BlockchainAmount;
82
+ outputTokenAmount: BlockchainAmount;
83
+ };
84
+ declare const SwapQuote: {
85
+ /**
86
+ * Assembles a {@link SwapQuote} from a raw contract {@link SwapPreview}. The
87
+ * input and fee are denominated in the input token; the output in the output
88
+ * token.
89
+ */
90
+ fromPreview: (preview: SwapPreview, inputDecimals: AssetDecimals, outputDecimals: AssetDecimals) => SwapQuote;
91
+ };
92
+
93
+ type FormattedAmountUi = Newtype<string, 'FormattedAmountUi'>;
94
+ declare const FormattedAmountUi: (value: string) => FormattedAmountUi;
95
+ type FormattedPercentUi = Newtype<string, 'FormattedPercentUi'>;
96
+ declare const FormattedPercentUi: (value: string) => FormattedPercentUi;
97
+ type TxExplorerUrl = Newtype<string, 'TxExplorerUrl'>;
98
+ declare const TxExplorerUrl: (value: string) => TxExplorerUrl;
99
+ /**
100
+ * A wallet address shortened for display (e.g. `0x1234…5678`). Keeps a
101
+ * `0x${string}` base but drops the runtime `0x` narrowing.
102
+ */
103
+ type ShortenedWalletAddress = Newtype<`0x${string}`, 'ShortenedWalletAddress'>;
104
+ declare const ShortenedWalletAddress: (value: string) => ShortenedWalletAddress;
105
+ type FormattedAmountAssetUi = Newtype<string, 'FormattedAmountAssetUi'>;
106
+ declare const FormattedAmountAssetUi: (value: string) => FormattedAmountAssetUi;
107
+ type AssetIconUrl = Newtype<string, 'AssetIconUrl'>;
108
+ declare const AssetIconUrl: (value: string) => AssetIconUrl;
109
+
110
+ /**
111
+ * An array guaranteed to hold at least one element. Use it where an empty list
112
+ * would be a bug (e.g. the set of assets a swap always offers).
113
+ */
114
+ type NonEmptyArray<T> = [T, ...T[]];
115
+
116
+ export { AssetIconUrl as A, type BroadcastTxParams as B, type ConnectWallet as C, type EvmWallet as E, FormattedAmountAssetUi as F, type NonEmptyArray as N, type PKCEConfig as P, SwapQuote as S, TxExplorerUrl as T, type WriteContractParams as W, ShortenedWalletAddress as a, FormattedPercentUi as b, type EvmSigner as c, FormattedAmountUi as d, type PKCEParams as e, generatePKCEParams as g };