@kimafinance/kima-transaction-widget 1.5.0 → 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 +7613 -5812
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +77 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +235 -91
- package/dist/index.d.ts +235 -91
- package/dist/index.js +7480 -5701
- 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,10 +1,49 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { LogLevelDesc } from 'loglevel';
|
|
3
4
|
import { Connection, Transaction, VersionedTransaction, PublicKey } from '@solana/web3.js';
|
|
4
5
|
import { TronWeb } from 'tronweb';
|
|
5
6
|
import { SignedTransaction } from '@tronweb3/tronwallet-abstract-adapter';
|
|
6
7
|
import { BrowserProvider, JsonRpcSigner } from 'ethers';
|
|
7
|
-
import {
|
|
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
|
+
}
|
|
8
47
|
|
|
9
48
|
declare enum ChainName {
|
|
10
49
|
ETHEREUM = "ETH",
|
|
@@ -28,6 +67,26 @@ declare const CHAIN_NAMES_TO_STRING: {
|
|
|
28
67
|
declare const CHAIN_STRING_TO_NAME: {
|
|
29
68
|
[chainName: string]: ChainName;
|
|
30
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
|
+
|
|
31
90
|
declare enum TransactionStatus {
|
|
32
91
|
AVAILABLE = "Available",
|
|
33
92
|
CONFIRMED = "Pull_Confirmed",
|
|
@@ -42,62 +101,6 @@ declare enum TransactionStatus {
|
|
|
42
101
|
REFUNDCOMPLETED = "RefundCompleted",
|
|
43
102
|
DECLINEDINVALID = "DeclinedInvalid"
|
|
44
103
|
}
|
|
45
|
-
|
|
46
|
-
declare enum NetworkOptions {
|
|
47
|
-
testnet = "testnet",
|
|
48
|
-
mainnet = "mainnet"
|
|
49
|
-
}
|
|
50
|
-
declare enum ModeOptions {
|
|
51
|
-
payment = "payment",
|
|
52
|
-
bridge = "bridge",
|
|
53
|
-
status = "status",
|
|
54
|
-
light = "light"
|
|
55
|
-
}
|
|
56
|
-
declare enum CurrencyOptions {
|
|
57
|
-
USDK = "USDK",
|
|
58
|
-
USDC = "USDC",
|
|
59
|
-
USDT = "USDT",
|
|
60
|
-
WBTC = "WBTC",
|
|
61
|
-
G$ = "GDOLLAR"
|
|
62
|
-
}
|
|
63
|
-
declare enum ColorModeOptions {
|
|
64
|
-
light = "light",
|
|
65
|
-
dark = "dark"
|
|
66
|
-
}
|
|
67
|
-
declare enum DAppOptions {
|
|
68
|
-
None = "none",
|
|
69
|
-
LPAdd = "LPAdd",
|
|
70
|
-
LPDrain = "LPDrain"
|
|
71
|
-
}
|
|
72
|
-
interface Option {
|
|
73
|
-
id: ChainName | string;
|
|
74
|
-
label: string;
|
|
75
|
-
}
|
|
76
|
-
interface TransactionOption {
|
|
77
|
-
sourceChain?: ChainName;
|
|
78
|
-
targetChain: ChainName;
|
|
79
|
-
targetAddress: string;
|
|
80
|
-
amount: number;
|
|
81
|
-
currency: string;
|
|
82
|
-
}
|
|
83
|
-
interface TitleOption {
|
|
84
|
-
initialTitle?: string;
|
|
85
|
-
confirmTitle?: string;
|
|
86
|
-
}
|
|
87
|
-
interface PaymentTitleOption {
|
|
88
|
-
title?: string;
|
|
89
|
-
style?: object;
|
|
90
|
-
}
|
|
91
|
-
interface CompliantOption {
|
|
92
|
-
checkCompliant: boolean;
|
|
93
|
-
xploriskBaseUrl?: string;
|
|
94
|
-
xploriskApiKey?: string;
|
|
95
|
-
}
|
|
96
|
-
interface ThemeOptions {
|
|
97
|
-
colorMode?: ColorModeOptions;
|
|
98
|
-
backgroundColorLight?: string;
|
|
99
|
-
backgroundColorDark?: string;
|
|
100
|
-
}
|
|
101
104
|
interface TransactionData {
|
|
102
105
|
status: TransactionStatus;
|
|
103
106
|
sourceChain: string;
|
|
@@ -111,40 +114,55 @@ interface TransactionData {
|
|
|
111
114
|
kimaTxHash: string;
|
|
112
115
|
failReason: string;
|
|
113
116
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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;
|
|
121
126
|
decimals: number;
|
|
122
127
|
}
|
|
123
|
-
interface
|
|
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>> {
|
|
124
148
|
feeId: string;
|
|
125
149
|
feeOriginGasFiat: string;
|
|
126
|
-
feeOriginGasBigInt:
|
|
150
|
+
feeOriginGasBigInt: T;
|
|
127
151
|
feeKimaProcessingFiat: string;
|
|
128
|
-
feeKimaProcessingBigInt:
|
|
152
|
+
feeKimaProcessingBigInt: T;
|
|
129
153
|
feeTargetGasFiat: string;
|
|
130
|
-
feeTargetGasBigInt:
|
|
154
|
+
feeTargetGasBigInt: T;
|
|
155
|
+
feeSwapFiat?: string;
|
|
156
|
+
feeSwapBigInt?: T;
|
|
131
157
|
feeTotalFiat: string;
|
|
132
|
-
feeTotalBigInt:
|
|
158
|
+
feeTotalBigInt: T;
|
|
133
159
|
peggedTo: string;
|
|
134
160
|
expiration: string;
|
|
135
|
-
transactionValues: FeeTransactionValues<
|
|
161
|
+
transactionValues: FeeTransactionValues<T>;
|
|
136
162
|
options?: {
|
|
137
163
|
payment_method: '' | 'sepa_eur' | 'credit_card' | 'swift_usd';
|
|
138
164
|
};
|
|
139
|
-
|
|
140
|
-
interface FeeTransactionValues<TBigInt = BigintAmount<bigint | string>> {
|
|
141
|
-
feeFromOrigin: TransactionValues<TBigInt>;
|
|
142
|
-
feeFromTarget: TransactionValues<TBigInt>;
|
|
143
|
-
}
|
|
144
|
-
interface TransactionValues<TBigInt = BigintAmount<bigint | string>> {
|
|
145
|
-
allowanceAmount: TBigInt;
|
|
146
|
-
submitAmount: TBigInt;
|
|
147
|
-
message: string;
|
|
165
|
+
swapInfo?: SwapInfo<T>;
|
|
148
166
|
}
|
|
149
167
|
type FeeResponse = FeeResult<BigintAmount<string>>;
|
|
150
168
|
interface ServiceFee {
|
|
@@ -163,28 +181,154 @@ interface ServiceFee {
|
|
|
163
181
|
targetFee: BigintAmount<bigint>;
|
|
164
182
|
kimaFee: BigintAmount<bigint>;
|
|
165
183
|
totalFee: BigintAmount<bigint>;
|
|
184
|
+
swapFee?: BigintAmount<bigint>;
|
|
185
|
+
swapInfo?: SwapInfo<BigintAmount<bigint>>;
|
|
166
186
|
options?: {
|
|
167
187
|
payment_method: '' | 'sepa_eur' | 'credit_card' | 'swift_usd';
|
|
168
188
|
};
|
|
169
189
|
}
|
|
190
|
+
|
|
170
191
|
interface TronProvider {
|
|
171
192
|
tronWeb: TronWeb;
|
|
172
193
|
signTransaction: (transaction: Transaction, privateKey?: string) => Promise<SignedTransaction>;
|
|
173
|
-
signMessage(message: string, privateKey?: string)
|
|
194
|
+
signMessage: (message: string, privateKey?: string) => Promise<string>;
|
|
174
195
|
}
|
|
175
196
|
interface SolProvider {
|
|
176
197
|
connection: Connection;
|
|
177
|
-
signTransaction
|
|
198
|
+
signTransaction<T extends Transaction | VersionedTransaction>(tx: T): Promise<T>;
|
|
178
199
|
signMessage(message: Uint8Array): Promise<Uint8Array>;
|
|
179
200
|
}
|
|
180
|
-
|
|
181
|
-
type: 'evm'
|
|
182
|
-
provider: BrowserProvider
|
|
183
|
-
signer: JsonRpcSigner
|
|
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"
|
|
184
328
|
}
|
|
185
329
|
|
|
186
330
|
interface KimaProviderProps {
|
|
187
|
-
|
|
331
|
+
projectId: string;
|
|
188
332
|
externalProvider?: ExternalProvider;
|
|
189
333
|
kimaBackendUrl: string;
|
|
190
334
|
children: ReactNode;
|
|
@@ -195,7 +339,7 @@ interface KimaProviderProps {
|
|
|
195
339
|
keplrHandler?: (e: any) => void;
|
|
196
340
|
switchChainHandler?: (e: any) => void;
|
|
197
341
|
}
|
|
198
|
-
declare const KimaProvider: ({
|
|
342
|
+
declare const KimaProvider: ({ projectId, children, externalProvider, kimaBackendUrl, logLevel, keplrHandler, successHandler, closeHandler, errorHandler, switchChainHandler }: KimaProviderProps) => react_jsx_runtime.JSX.Element;
|
|
199
343
|
|
|
200
344
|
interface Props {
|
|
201
345
|
theme: ThemeOptions;
|
|
@@ -208,6 +352,6 @@ interface Props {
|
|
|
208
352
|
transactionOption?: TransactionOption;
|
|
209
353
|
paymentTitleOption?: PaymentTitleOption;
|
|
210
354
|
}
|
|
211
|
-
declare const KimaTransactionWidget: ({ mode, txId, dAppOption, theme, titleOption, paymentTitleOption, helpURL, compliantOption, transactionOption }: Props) =>
|
|
355
|
+
declare const KimaTransactionWidget: ({ mode, txId, dAppOption, theme, titleOption, paymentTitleOption, helpURL, compliantOption, transactionOption }: Props) => react_jsx_runtime.JSX.Element;
|
|
212
356
|
|
|
213
|
-
export { type BigintAmount, CHAIN_NAMES_TO_STRING, CHAIN_STRING_TO_NAME, ColorModeOptions, type CompliantOption,
|
|
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 };
|