@kimafinance/kima-transaction-widget 1.5.1 → 1.5.2
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/index.cjs +684 -692
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +357 -3
- package/dist/index.d.ts +357 -3
- package/dist/index.js +692 -700
- package/dist/index.js.map +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,357 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { LogLevelDesc } from 'loglevel';
|
|
4
|
+
import { Connection, Transaction, VersionedTransaction, PublicKey } from '@solana/web3.js';
|
|
5
|
+
import { TronWeb } from 'tronweb';
|
|
6
|
+
import { SignedTransaction } from '@tronweb3/tronwallet-abstract-adapter';
|
|
7
|
+
import { BrowserProvider, JsonRpcSigner } from 'ethers';
|
|
8
|
+
import { Chain } from 'viem';
|
|
9
|
+
|
|
10
|
+
declare enum NetworkOptions {
|
|
11
|
+
testnet = "testnet",
|
|
12
|
+
mainnet = "mainnet"
|
|
13
|
+
}
|
|
14
|
+
declare enum ModeOptions {
|
|
15
|
+
payment = "payment",
|
|
16
|
+
bridge = "bridge",
|
|
17
|
+
status = "status",
|
|
18
|
+
light = "light"
|
|
19
|
+
}
|
|
20
|
+
declare enum ColorModeOptions {
|
|
21
|
+
light = "light",
|
|
22
|
+
dark = "dark"
|
|
23
|
+
}
|
|
24
|
+
declare enum DAppOptions {
|
|
25
|
+
None = "none",
|
|
26
|
+
LPAdd = "LPAdd",
|
|
27
|
+
LPDrain = "LPDrain"
|
|
28
|
+
}
|
|
29
|
+
interface ThemeOptions {
|
|
30
|
+
colorMode?: ColorModeOptions;
|
|
31
|
+
backgroundColorLight?: string;
|
|
32
|
+
backgroundColorDark?: string;
|
|
33
|
+
}
|
|
34
|
+
interface Web3ModalAccountInfo {
|
|
35
|
+
address?: string;
|
|
36
|
+
isConnected?: boolean;
|
|
37
|
+
chainId?: number;
|
|
38
|
+
}
|
|
39
|
+
declare enum LoadingErrorTitle {
|
|
40
|
+
EnvLoadingError = "Fatal ENV Initialization Error",
|
|
41
|
+
ChainLoadingError = "Fatal Chains Initialization Error"
|
|
42
|
+
}
|
|
43
|
+
declare enum LoadingErrorMessage {
|
|
44
|
+
EnvLoadingError = "There was an error loading the required environment variables from the backend. Please check that the backend is running properly and the widget points to the corresponding url.",
|
|
45
|
+
ChainLoadingError = "There was an error loading the chain data from the backend. Please check that the backend is running properly and the widget points to the corresponding url."
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
declare enum ChainName {
|
|
49
|
+
ETHEREUM = "ETH",
|
|
50
|
+
POLYGON = "POL",
|
|
51
|
+
AVALANCHE = "AVX",
|
|
52
|
+
SOLANA = "SOL",
|
|
53
|
+
BASE = "BASE",
|
|
54
|
+
BSC = "BSC",
|
|
55
|
+
ARBITRUM = "ARB",
|
|
56
|
+
OPTIMISM = "OPT",
|
|
57
|
+
POLYGON_ZKEVM = "ZKE",
|
|
58
|
+
TRON = "TRX",
|
|
59
|
+
FIAT = "FIAT",
|
|
60
|
+
BTC = "BTC",
|
|
61
|
+
BERA = "BERA",
|
|
62
|
+
CFX = "CFX"
|
|
63
|
+
}
|
|
64
|
+
declare const CHAIN_NAMES_TO_STRING: {
|
|
65
|
+
[chainName: string]: string;
|
|
66
|
+
};
|
|
67
|
+
declare const CHAIN_STRING_TO_NAME: {
|
|
68
|
+
[chainName: string]: ChainName;
|
|
69
|
+
};
|
|
70
|
+
declare const CHAIN_NAMES_TO_EXPLORER_TESTNET: {
|
|
71
|
+
[chainName: string]: string;
|
|
72
|
+
};
|
|
73
|
+
declare const CHAIN_NAMES_TO_EXPLORER_MAINNET: {
|
|
74
|
+
[chainName: string]: string;
|
|
75
|
+
};
|
|
76
|
+
type Cluster = 'devnet' | 'testnet' | 'mainnet';
|
|
77
|
+
declare const CLUSTER: Cluster;
|
|
78
|
+
declare const SOLANA_HOST: string;
|
|
79
|
+
declare const lightDemoAccounts: {
|
|
80
|
+
EVM: string;
|
|
81
|
+
SOL: string;
|
|
82
|
+
TRX: string;
|
|
83
|
+
};
|
|
84
|
+
declare const lightDemoNetworks: string[];
|
|
85
|
+
type CoinOptions = {
|
|
86
|
+
[key: string]: any;
|
|
87
|
+
};
|
|
88
|
+
declare const COIN_LIST: CoinOptions;
|
|
89
|
+
|
|
90
|
+
declare enum TransactionStatus {
|
|
91
|
+
AVAILABLE = "Available",
|
|
92
|
+
CONFIRMED = "Pull_Confirmed",
|
|
93
|
+
PULLED = "Pulled",
|
|
94
|
+
PAID = "Paid",
|
|
95
|
+
COMPLETED = "Completed",
|
|
96
|
+
FAILEDTOPAY = "FailedToPay",
|
|
97
|
+
FAILEDTOPULL = "FailedToPull",
|
|
98
|
+
UNAVAILABLE = "UnAvailable",
|
|
99
|
+
REFUNDSTART = "RefundStart",
|
|
100
|
+
REFUNDFAILED = "RefundFailed",
|
|
101
|
+
REFUNDCOMPLETED = "RefundCompleted",
|
|
102
|
+
DECLINEDINVALID = "DeclinedInvalid"
|
|
103
|
+
}
|
|
104
|
+
interface TransactionData {
|
|
105
|
+
status: TransactionStatus;
|
|
106
|
+
sourceChain: string;
|
|
107
|
+
targetChain: string;
|
|
108
|
+
tssPullHash: string;
|
|
109
|
+
tssReleaseHash: string;
|
|
110
|
+
tssRefundHash: string;
|
|
111
|
+
sourceSymbol: string;
|
|
112
|
+
targetSymbol: string;
|
|
113
|
+
amount: number | string;
|
|
114
|
+
kimaTxHash: string;
|
|
115
|
+
failReason: string;
|
|
116
|
+
}
|
|
117
|
+
type PendingTxData = {
|
|
118
|
+
expireTime: string;
|
|
119
|
+
amount: string;
|
|
120
|
+
status: string;
|
|
121
|
+
hash: string;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
interface BigintAmount<T extends bigint | string> {
|
|
125
|
+
value: T;
|
|
126
|
+
decimals: number;
|
|
127
|
+
}
|
|
128
|
+
interface TransactionValues<T = BigintAmount<bigint | string>> {
|
|
129
|
+
allowanceAmount: T;
|
|
130
|
+
submitAmount: T;
|
|
131
|
+
message: string;
|
|
132
|
+
}
|
|
133
|
+
interface FeeTransactionValues<T = BigintAmount<bigint | string>> {
|
|
134
|
+
feeFromOrigin: TransactionValues<T>;
|
|
135
|
+
feeFromTarget: TransactionValues<T>;
|
|
136
|
+
}
|
|
137
|
+
interface SwapInfo<T = BigintAmount<bigint | string>> {
|
|
138
|
+
amountOutFiat: string;
|
|
139
|
+
amountOutBigInt: T;
|
|
140
|
+
dex: string;
|
|
141
|
+
slippage: {
|
|
142
|
+
percentage: number;
|
|
143
|
+
minAmountFiat: string;
|
|
144
|
+
maxAmountFiat: string;
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
interface FeeResult<T extends BigintAmount<bigint | string>> {
|
|
148
|
+
feeId: string;
|
|
149
|
+
feeOriginGasFiat: string;
|
|
150
|
+
feeOriginGasBigInt: T;
|
|
151
|
+
feeKimaProcessingFiat: string;
|
|
152
|
+
feeKimaProcessingBigInt: T;
|
|
153
|
+
feeTargetGasFiat: string;
|
|
154
|
+
feeTargetGasBigInt: T;
|
|
155
|
+
feeSwapFiat?: string;
|
|
156
|
+
feeSwapBigInt?: T;
|
|
157
|
+
feeTotalFiat: string;
|
|
158
|
+
feeTotalBigInt: T;
|
|
159
|
+
peggedTo: string;
|
|
160
|
+
expiration: string;
|
|
161
|
+
transactionValues: FeeTransactionValues<T>;
|
|
162
|
+
options?: {
|
|
163
|
+
payment_method: '' | 'sepa_eur' | 'credit_card' | 'swift_usd';
|
|
164
|
+
};
|
|
165
|
+
swapInfo?: SwapInfo<T>;
|
|
166
|
+
}
|
|
167
|
+
type FeeResponse = FeeResult<BigintAmount<string>>;
|
|
168
|
+
interface ServiceFee {
|
|
169
|
+
feeId: string;
|
|
170
|
+
peggedTo: string;
|
|
171
|
+
expiration: string;
|
|
172
|
+
transactionValues: FeeTransactionValues<BigintAmount<bigint>> & {
|
|
173
|
+
originChain: string;
|
|
174
|
+
originAddress: string;
|
|
175
|
+
originSymbol: string;
|
|
176
|
+
targetChain: string;
|
|
177
|
+
targetAddress: string;
|
|
178
|
+
targetSymbol: string;
|
|
179
|
+
};
|
|
180
|
+
sourceFee: BigintAmount<bigint>;
|
|
181
|
+
targetFee: BigintAmount<bigint>;
|
|
182
|
+
kimaFee: BigintAmount<bigint>;
|
|
183
|
+
totalFee: BigintAmount<bigint>;
|
|
184
|
+
swapFee?: BigintAmount<bigint>;
|
|
185
|
+
swapInfo?: SwapInfo<BigintAmount<bigint>>;
|
|
186
|
+
options?: {
|
|
187
|
+
payment_method: '' | 'sepa_eur' | 'credit_card' | 'swift_usd';
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
interface TronProvider {
|
|
192
|
+
tronWeb: TronWeb;
|
|
193
|
+
signTransaction: (transaction: Transaction, privateKey?: string) => Promise<SignedTransaction>;
|
|
194
|
+
signMessage: (message: string, privateKey?: string) => Promise<string>;
|
|
195
|
+
}
|
|
196
|
+
interface SolProvider {
|
|
197
|
+
connection: Connection;
|
|
198
|
+
signTransaction<T extends Transaction | VersionedTransaction>(tx: T): Promise<T>;
|
|
199
|
+
signMessage(message: Uint8Array): Promise<Uint8Array>;
|
|
200
|
+
}
|
|
201
|
+
type ExternalProvider = {
|
|
202
|
+
type: 'evm';
|
|
203
|
+
provider: BrowserProvider;
|
|
204
|
+
signer: JsonRpcSigner;
|
|
205
|
+
} | {
|
|
206
|
+
type: 'solana';
|
|
207
|
+
provider: SolProvider;
|
|
208
|
+
signer: PublicKey;
|
|
209
|
+
} | {
|
|
210
|
+
type: 'tron';
|
|
211
|
+
provider: TronProvider;
|
|
212
|
+
signer: string;
|
|
213
|
+
};
|
|
214
|
+
declare const isSolProvider: (provider: SolProvider) => boolean;
|
|
215
|
+
declare const isTronProvider: (provider: TronProvider) => boolean;
|
|
216
|
+
|
|
217
|
+
interface Option {
|
|
218
|
+
id: ChainName | string;
|
|
219
|
+
label: string;
|
|
220
|
+
}
|
|
221
|
+
interface TransactionOption {
|
|
222
|
+
sourceChain?: ChainName;
|
|
223
|
+
targetChain: ChainName;
|
|
224
|
+
targetAddress: string;
|
|
225
|
+
amount: number;
|
|
226
|
+
currency: string;
|
|
227
|
+
}
|
|
228
|
+
interface TitleOption {
|
|
229
|
+
initialTitle?: string;
|
|
230
|
+
confirmTitle?: string;
|
|
231
|
+
}
|
|
232
|
+
interface PaymentTitleOption {
|
|
233
|
+
title?: string;
|
|
234
|
+
style?: object;
|
|
235
|
+
}
|
|
236
|
+
interface CompliantOption {
|
|
237
|
+
checkCompliant: boolean;
|
|
238
|
+
xploriskBaseUrl?: string;
|
|
239
|
+
xploriskApiKey?: string;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
interface Plugin {
|
|
243
|
+
compatibility: ChainCompatibility;
|
|
244
|
+
data: PluginData;
|
|
245
|
+
id: string;
|
|
246
|
+
initialize: () => PluginInit;
|
|
247
|
+
isCompatible: (chain: ChainData) => boolean;
|
|
248
|
+
Provider: React.FC<PluginProviderProps>;
|
|
249
|
+
useAllowance?: (args?: any) => PluginUseAllowanceResult;
|
|
250
|
+
useNativeBalance?: () => PluginUseBalanceResult | undefined;
|
|
251
|
+
useTokenBalance?: () => PluginUseBalanceResult | undefined;
|
|
252
|
+
useIsWalletReady?: () => PluginUseIsWalletReadyResult;
|
|
253
|
+
useDisconnectWallet?: () => PluginUseDisconnectWalletResult;
|
|
254
|
+
getAllowance?(): Promise<GetTokenAllowanceResult & {
|
|
255
|
+
isApproved: boolean;
|
|
256
|
+
}>;
|
|
257
|
+
getNativeBalance?(): Promise<PluginUseBalanceResult>;
|
|
258
|
+
getTokenBalance?(): Promise<PluginUseBalanceResult>;
|
|
259
|
+
isWalletReady?(): Promise<PluginUseIsWalletReadyResult>;
|
|
260
|
+
disconnectWallet?(): Promise<void>;
|
|
261
|
+
}
|
|
262
|
+
interface SignDataType {
|
|
263
|
+
targetAddress: string;
|
|
264
|
+
targetChain: string;
|
|
265
|
+
originChain: string;
|
|
266
|
+
originSymbol: string;
|
|
267
|
+
}
|
|
268
|
+
interface GetTokenAllowanceResult {
|
|
269
|
+
allowance?: bigint | undefined;
|
|
270
|
+
decimals?: number | undefined;
|
|
271
|
+
}
|
|
272
|
+
interface PluginUseAllowanceResult extends GetTokenAllowanceResult {
|
|
273
|
+
isApproved: boolean;
|
|
274
|
+
approve: (isCancel?: boolean) => Promise<void>;
|
|
275
|
+
signMessage?: (data: SignDataType) => Promise<any>;
|
|
276
|
+
}
|
|
277
|
+
interface PluginUseBalanceResult {
|
|
278
|
+
balance?: bigint | undefined;
|
|
279
|
+
decimals?: number | undefined;
|
|
280
|
+
}
|
|
281
|
+
interface PluginUseIsWalletReadyResult {
|
|
282
|
+
isReady: boolean;
|
|
283
|
+
statusMessage: string;
|
|
284
|
+
connectedAddress?: string;
|
|
285
|
+
}
|
|
286
|
+
interface PluginUseDisconnectWalletResult {
|
|
287
|
+
disconnectWallet: () => Promise<void>;
|
|
288
|
+
}
|
|
289
|
+
interface PluginInit {
|
|
290
|
+
data: PluginData;
|
|
291
|
+
provider: React.FC<PluginProviderProps>;
|
|
292
|
+
}
|
|
293
|
+
interface PluginProviderProps {
|
|
294
|
+
children: React.ReactNode;
|
|
295
|
+
networkOption?: NetworkOptions;
|
|
296
|
+
projectId?: string;
|
|
297
|
+
isLoading?: boolean;
|
|
298
|
+
}
|
|
299
|
+
interface PluginData {
|
|
300
|
+
id: string;
|
|
301
|
+
pluginData: {
|
|
302
|
+
[key: string]: any;
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
type ChainLocation = 'origin' | 'target';
|
|
306
|
+
interface ChainData extends Chain {
|
|
307
|
+
compatibility: ChainCompatibility;
|
|
308
|
+
name: string;
|
|
309
|
+
shortName: string;
|
|
310
|
+
supportedTokens: ChainToken[];
|
|
311
|
+
supportedLocations: ChainLocation[];
|
|
312
|
+
disabled: boolean;
|
|
313
|
+
}
|
|
314
|
+
interface ChainToken {
|
|
315
|
+
address: string;
|
|
316
|
+
decimals: number;
|
|
317
|
+
symbol: string;
|
|
318
|
+
peggedTo: string;
|
|
319
|
+
}
|
|
320
|
+
declare enum ChainCompatibility {
|
|
321
|
+
BTC = "BTC",
|
|
322
|
+
EVM = "EVM",
|
|
323
|
+
FIAT = "FIAT",
|
|
324
|
+
COSMOS = "COSMOS",
|
|
325
|
+
SELF = "SELF",
|
|
326
|
+
CC = "CC",
|
|
327
|
+
BANK = "BANK"
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
interface KimaProviderProps {
|
|
331
|
+
projectId: string;
|
|
332
|
+
externalProvider?: ExternalProvider;
|
|
333
|
+
kimaBackendUrl: string;
|
|
334
|
+
children: ReactNode;
|
|
335
|
+
logLevel?: LogLevelDesc;
|
|
336
|
+
errorHandler?: (e: any) => void;
|
|
337
|
+
closeHandler?: (e: any) => void;
|
|
338
|
+
successHandler?: (e: any) => void;
|
|
339
|
+
keplrHandler?: (e: any) => void;
|
|
340
|
+
switchChainHandler?: (e: any) => void;
|
|
341
|
+
}
|
|
342
|
+
declare const KimaProvider: ({ projectId, children, externalProvider, kimaBackendUrl, logLevel, keplrHandler, successHandler, closeHandler, errorHandler, switchChainHandler }: KimaProviderProps) => react_jsx_runtime.JSX.Element;
|
|
343
|
+
|
|
344
|
+
interface Props {
|
|
345
|
+
theme: ThemeOptions;
|
|
346
|
+
mode: ModeOptions;
|
|
347
|
+
txId?: number | string;
|
|
348
|
+
dAppOption?: DAppOptions;
|
|
349
|
+
titleOption?: TitleOption;
|
|
350
|
+
compliantOption?: boolean;
|
|
351
|
+
helpURL?: string;
|
|
352
|
+
transactionOption?: TransactionOption;
|
|
353
|
+
paymentTitleOption?: PaymentTitleOption;
|
|
354
|
+
}
|
|
355
|
+
declare const KimaTransactionWidget: ({ mode, txId, dAppOption, theme, titleOption, paymentTitleOption, helpURL, compliantOption, transactionOption }: Props) => react_jsx_runtime.JSX.Element;
|
|
356
|
+
|
|
357
|
+
export { type BigintAmount, CHAIN_NAMES_TO_EXPLORER_MAINNET, CHAIN_NAMES_TO_EXPLORER_TESTNET, CHAIN_NAMES_TO_STRING, CHAIN_STRING_TO_NAME, CLUSTER, COIN_LIST, ChainCompatibility, type ChainData, type ChainLocation, ChainName, type ChainToken, type Cluster, ColorModeOptions, type CompliantOption, DAppOptions, type ExternalProvider, type FeeResponse, type FeeResult, type FeeTransactionValues, type GetTokenAllowanceResult, KimaProvider, KimaTransactionWidget, LoadingErrorMessage, LoadingErrorTitle, ModeOptions, NetworkOptions, type Option, type PaymentTitleOption, type PendingTxData, type Plugin, type PluginData, type PluginInit, type PluginProviderProps, type PluginUseAllowanceResult, type PluginUseBalanceResult, type PluginUseDisconnectWalletResult, type PluginUseIsWalletReadyResult, SOLANA_HOST, type ServiceFee, type SignDataType, type SolProvider, type SwapInfo, type ThemeOptions, type TitleOption, type TransactionData, type TransactionOption, TransactionStatus, type TransactionValues, type TronProvider, type Web3ModalAccountInfo, isSolProvider, isTronProvider, lightDemoAccounts, lightDemoNetworks };
|