@stableflow/pay-widgets 0.0.1-beta-82ede460a5-20260923
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/dist/token-select/index.d.ts +165 -0
- package/dist/token-select/index.js +1467 -0
- package/dist/token-select/index.js.map +1 -0
- package/package.json +40 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
type ChainKind = "evm" | "near" | "solana" | "tron" | "zec";
|
|
5
|
+
type PayChain = {
|
|
6
|
+
blockchain: string;
|
|
7
|
+
chainName: string;
|
|
8
|
+
chainKind: ChainKind;
|
|
9
|
+
chainId?: string;
|
|
10
|
+
logo: string;
|
|
11
|
+
explorer: string;
|
|
12
|
+
};
|
|
13
|
+
type PayToken = {
|
|
14
|
+
assetId: string;
|
|
15
|
+
symbol: string;
|
|
16
|
+
providerSymbol: string;
|
|
17
|
+
blockchain: string;
|
|
18
|
+
decimals: number;
|
|
19
|
+
contractAddress: string | null;
|
|
20
|
+
price: number;
|
|
21
|
+
logo: string;
|
|
22
|
+
supportPayment: boolean;
|
|
23
|
+
supportReceive: boolean;
|
|
24
|
+
chain: PayChain;
|
|
25
|
+
};
|
|
26
|
+
/** API-shaped payload. Callers can pass this into their own chain registry. */
|
|
27
|
+
type PayConfigSource = {
|
|
28
|
+
chains: PayConfigSourceChain[];
|
|
29
|
+
tokens: PayConfigSourceToken[];
|
|
30
|
+
};
|
|
31
|
+
type PayConfigSourceChain = {
|
|
32
|
+
network: string;
|
|
33
|
+
chainId: string;
|
|
34
|
+
chainName: string;
|
|
35
|
+
logo: string;
|
|
36
|
+
explorer: string;
|
|
37
|
+
};
|
|
38
|
+
type PayConfigSourceToken = {
|
|
39
|
+
symbol: string;
|
|
40
|
+
network: string;
|
|
41
|
+
decimals: number;
|
|
42
|
+
contractAddress: string;
|
|
43
|
+
price: string;
|
|
44
|
+
supportPayment: boolean;
|
|
45
|
+
supportReceive: boolean;
|
|
46
|
+
};
|
|
47
|
+
type PopularTokenRef = {
|
|
48
|
+
blockchain: string;
|
|
49
|
+
symbol: string;
|
|
50
|
+
};
|
|
51
|
+
type WalletAccountInput = {
|
|
52
|
+
address?: string | null;
|
|
53
|
+
icon?: string | null;
|
|
54
|
+
connecting?: boolean;
|
|
55
|
+
/** False inside a Safe App, where the host owns the connection. */
|
|
56
|
+
canDisconnect?: boolean;
|
|
57
|
+
};
|
|
58
|
+
type PayWallet = {
|
|
59
|
+
accounts: Partial<Record<ChainKind, WalletAccountInput>>;
|
|
60
|
+
connect: (kind: ChainKind) => void | Promise<void>;
|
|
61
|
+
disconnect: (kind: ChainKind) => void | Promise<void>;
|
|
62
|
+
};
|
|
63
|
+
type BalanceReadSuccess = {
|
|
64
|
+
assetId: string;
|
|
65
|
+
formatted: string;
|
|
66
|
+
/** Integer token units, as a decimal string. */
|
|
67
|
+
raw?: string;
|
|
68
|
+
};
|
|
69
|
+
type BalanceReadFailure = {
|
|
70
|
+
assetId: string;
|
|
71
|
+
error: string;
|
|
72
|
+
};
|
|
73
|
+
type BalanceReadResult = BalanceReadSuccess | BalanceReadFailure;
|
|
74
|
+
type ReadBalances = (batch: {
|
|
75
|
+
owner: string;
|
|
76
|
+
chainKind: ChainKind;
|
|
77
|
+
blockchain: string;
|
|
78
|
+
tokens: PayToken[];
|
|
79
|
+
}) => Promise<BalanceReadResult[]>;
|
|
80
|
+
type TokenSelectRole = "payer" | "receiver";
|
|
81
|
+
type ChainOwners = Partial<Record<ChainKind, string>>;
|
|
82
|
+
type TokenBalanceStatus = "idle" | "loading" | "success" | "error";
|
|
83
|
+
|
|
84
|
+
type PayWidgetsProviderProps = {
|
|
85
|
+
apiHost?: string;
|
|
86
|
+
popularTokens?: PopularTokenRef[];
|
|
87
|
+
wallet: PayWallet;
|
|
88
|
+
readBalances: ReadBalances;
|
|
89
|
+
onConfig?: (config: PayConfigSource) => void;
|
|
90
|
+
onCopyAddress?: (address: string) => void;
|
|
91
|
+
chainKinds?: Partial<Record<string, ChainKind>>;
|
|
92
|
+
children: ReactNode;
|
|
93
|
+
};
|
|
94
|
+
declare function PayWidgetsProvider(props: PayWidgetsProviderProps): react.JSX.Element;
|
|
95
|
+
|
|
96
|
+
type TokenSelectSelection = {
|
|
97
|
+
token: PayToken;
|
|
98
|
+
};
|
|
99
|
+
type TokenSelectDialogProps = {
|
|
100
|
+
open: boolean;
|
|
101
|
+
onClose: () => void;
|
|
102
|
+
onSelect: (selection: TokenSelectSelection) => void;
|
|
103
|
+
role?: TokenSelectRole;
|
|
104
|
+
title?: string;
|
|
105
|
+
selectedAssetId?: string | null;
|
|
106
|
+
balanceOwners?: ChainOwners;
|
|
107
|
+
allowedBlockchains?: string[] | null;
|
|
108
|
+
lockChainKind?: ChainKind | null;
|
|
109
|
+
excludeNative?: boolean;
|
|
110
|
+
disabledBlockchains?: string[] | null;
|
|
111
|
+
disabledReason?: string;
|
|
112
|
+
className?: string;
|
|
113
|
+
titleClassName?: string;
|
|
114
|
+
closeClassName?: string;
|
|
115
|
+
contentClassName?: string;
|
|
116
|
+
searchClassName?: string;
|
|
117
|
+
railClassName?: string;
|
|
118
|
+
rowClassName?: string;
|
|
119
|
+
};
|
|
120
|
+
declare function TokenSelectDialog(props: TokenSelectDialogProps): react.JSX.Element;
|
|
121
|
+
|
|
122
|
+
type PayConfigStatus = "idle" | "loading" | "success" | "error";
|
|
123
|
+
type PayConfigSnapshot = {
|
|
124
|
+
apiHost: string;
|
|
125
|
+
chains: PayChain[];
|
|
126
|
+
tokens: PayToken[];
|
|
127
|
+
source: PayConfigSource | null;
|
|
128
|
+
status: PayConfigStatus;
|
|
129
|
+
error: string | null;
|
|
130
|
+
fetchedAt: number | null;
|
|
131
|
+
};
|
|
132
|
+
type ChainKindMap = Partial<Record<string, ChainKind>>;
|
|
133
|
+
declare function mapPayConfigSource(raw: unknown): PayConfigSource;
|
|
134
|
+
declare function normalizePayConfig(source: PayConfigSource, overrides?: ChainKindMap): {
|
|
135
|
+
chains: PayChain[];
|
|
136
|
+
tokens: PayToken[];
|
|
137
|
+
};
|
|
138
|
+
declare function usePayConfigSnapshot(): PayConfigSnapshot;
|
|
139
|
+
declare function usePayConfig(options?: {
|
|
140
|
+
apiHost?: string;
|
|
141
|
+
}): {
|
|
142
|
+
chains: PayChain[];
|
|
143
|
+
tokens: PayToken[];
|
|
144
|
+
source: PayConfigSource | null;
|
|
145
|
+
status: PayConfigStatus;
|
|
146
|
+
error: string | null;
|
|
147
|
+
refetch: () => void;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
type TokenBalance = {
|
|
151
|
+
raw: string | null;
|
|
152
|
+
formatted: string | null;
|
|
153
|
+
status: TokenBalanceStatus;
|
|
154
|
+
error: string | null;
|
|
155
|
+
updatedAt: number | null;
|
|
156
|
+
};
|
|
157
|
+
declare function clearPayTokenBalances(): void;
|
|
158
|
+
declare function usePayTokenBalance(owner: string | null | undefined, assetId: string | null | undefined): TokenBalance | undefined;
|
|
159
|
+
declare function refreshPayTokenBalance(owner: string, token: PayToken): Promise<TokenBalance | null>;
|
|
160
|
+
|
|
161
|
+
declare function parsePopularTokens(raw: string | null | undefined): PopularTokenRef[];
|
|
162
|
+
|
|
163
|
+
declare const DEFAULT_API_HOST = "https://api.stableflow.ai";
|
|
164
|
+
|
|
165
|
+
export { type BalanceReadResult, type ChainKind, type ChainOwners, DEFAULT_API_HOST, type PayChain, type PayConfigSnapshot, type PayConfigSource, type PayConfigStatus, type PayToken, type PayWallet, PayWidgetsProvider, type PayWidgetsProviderProps, type PopularTokenRef, type ReadBalances, type TokenBalance, TokenSelectDialog, type TokenSelectDialogProps, type TokenSelectRole, type TokenSelectSelection, clearPayTokenBalances, mapPayConfigSource, normalizePayConfig, parsePopularTokens, refreshPayTokenBalance, usePayConfig, usePayConfigSnapshot, usePayTokenBalance };
|