@coinlist-co/react 0.10.1 → 0.11.1-rc.10770e8
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 +32 -0
- package/dist/chunk-7CTH4KPU.js +2399 -0
- package/dist/chunk-7CTH4KPU.js.map +1 -0
- package/dist/{chunk-AQVCOWOV.js → chunk-LSPZETDH.js} +249 -317
- package/dist/chunk-LSPZETDH.js.map +1 -0
- package/dist/chunk-UZUQALFY.js +279 -0
- package/dist/chunk-UZUQALFY.js.map +1 -0
- package/dist/client/index.cjs +13430 -3308
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +5486 -899
- package/dist/client/index.d.ts +5486 -899
- package/dist/client/index.js +11025 -2388
- package/dist/client/index.js.map +1 -1
- package/dist/collections-BBI_XydI.d.cts +116 -0
- package/dist/collections-BrX9rRWc.d.ts +116 -0
- package/dist/config-CMl1bR3F.d.cts +2959 -0
- package/dist/config-CMl1bR3F.d.ts +2959 -0
- package/dist/server/index.cjs +1768 -511
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +266 -162
- package/dist/server/index.d.ts +266 -162
- package/dist/server/index.js +235 -169
- package/dist/server/index.js.map +1 -1
- package/dist/shared/index.cjs +2423 -926
- package/dist/shared/index.cjs.map +1 -1
- package/dist/shared/index.d.cts +325 -132
- package/dist/shared/index.d.ts +325 -132
- package/dist/shared/index.js +112 -28
- package/package.json +12 -8
- package/dist/chunk-AQVCOWOV.js.map +0 -1
- package/dist/chunk-TBU3EBNM.js +0 -442
- package/dist/chunk-TBU3EBNM.js.map +0 -1
- package/dist/chunk-UOHD7US2.js +0 -855
- package/dist/chunk-UOHD7US2.js.map +0 -1
- package/dist/collections-Bv1Oxzu_.d.ts +0 -28
- package/dist/collections-DDyxbOPZ.d.cts +0 -28
- package/dist/requirement-oVZA1INj.d.cts +0 -1040
- package/dist/requirement-oVZA1INj.d.ts +0 -1040
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { aC as ClientId, bj as RedirectUri, aD as CodeChallenge, b8 as PKCEState, C as CodeVerifier, q as EvmWalletAddress, a as EthereumChain, bC as Tx, B as BlockchainAmount, bs as SwapPreview, X as AssetDecimals, au as Newtype } from './config-CMl1bR3F.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 { aC as ClientId, bj as RedirectUri, aD as CodeChallenge, b8 as PKCEState, C as CodeVerifier, q as EvmWalletAddress, a as EthereumChain, bC as Tx, B as BlockchainAmount, bs as SwapPreview, X as AssetDecimals, au as Newtype } from './config-CMl1bR3F.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 };
|