@rash2x/bridge-widget 0.6.62 → 0.6.63

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.d.ts CHANGED
@@ -6,6 +6,11 @@ import { TonClient } from '@ton/ton';
6
6
  import { TronWeb } from 'tronweb';
7
7
  import { UseBoundStore } from 'zustand';
8
8
 
9
+ /**
10
+ * Add network fees to quote from chain strategies
11
+ */
12
+ export declare function addNetworkFeesToQuote(quote: Quote | undefined, chainRegistry: ChainStrategyRegistry, chains: Chain[] | undefined): Promise<Quote | undefined>;
13
+
9
14
  export declare function addrForApi(chainKey: string, addr: string): string;
10
15
 
11
16
  export declare type AssetMatrix = Record<string, Record<string, Token>>;
@@ -99,6 +104,13 @@ declare interface ChainActions {
99
104
  swapChains: () => void;
100
105
  }
101
106
 
107
+ declare interface ChainConnectionState {
108
+ provider: string;
109
+ address: string | null;
110
+ connected: boolean;
111
+ isConnecting: boolean;
112
+ }
113
+
102
114
  export declare type ChainKey = "TON" | "EVM" | "TRON" | string;
103
115
 
104
116
  declare interface chainState {
@@ -112,6 +124,49 @@ declare interface chainState {
112
124
 
113
125
  declare type ChainStoreType = chainState & ChainActions;
114
126
 
127
+ declare interface ChainStrategy {
128
+ canHandle(chainKey: string): boolean;
129
+ getNetworkType(): NetworkType;
130
+ getName(): string;
131
+ connect(options?: ChainStrategyConnectOptions): Promise<void>;
132
+ disconnect(options?: ChainStrategyConnectOptions): Promise<void>;
133
+ isConnected(): boolean;
134
+ isConnecting(): boolean;
135
+ getAccount(): string | null;
136
+ getError(): string | null;
137
+ isInitialized(): boolean;
138
+ getConnectLabel(t: (key: string) => string): string;
139
+ getClient(): unknown;
140
+ getBalances(address: string, tokens: Token[]): Promise<WalletBalances>;
141
+ isAddressValid(address?: string): boolean;
142
+ getAvailableConnections(): ChainConnectionState[];
143
+ validateSteps(steps: TransactionStep[]): void;
144
+ executeSteps(steps: TransactionStep[], context: TransactionStrategyContext, onFirstHash?: (hash: string) => void): Promise<TransactionResult>;
145
+ getSourceCost?: (txHash: string) => Promise<SourceCost | null>;
146
+ estimateNetworkFee: (steps: TransactionStep[]) => Promise<number>;
147
+ convertMessageHashToTxHash?: (messageHash: string, timeoutMs?: number) => Promise<string | null>;
148
+ }
149
+
150
+ declare interface ChainStrategyConnectOptions {
151
+ provider?: string;
152
+ }
153
+
154
+ declare class ChainStrategyRegistry {
155
+ private strategies;
156
+ constructor(strategies: ChainStrategy[]);
157
+ getStrategy(chainKey: string): ChainStrategy | undefined;
158
+ getStrategyByType(type: NetworkType): ChainStrategy | undefined;
159
+ getAllStrategies(): ChainStrategy[];
160
+ isChainSupported(chainKey: string): boolean;
161
+ getAddressForChain(chainKey?: string): string | undefined;
162
+ isWalletConnected(chainKey?: string): boolean;
163
+ getBalances(chainKey: string, address: string, tokens: Token[]): Promise<WalletBalances>;
164
+ isAddressValid(chainKey: string, address?: string): boolean;
165
+ getConnectLabel(chainKey: string, t: (key: string) => string): string;
166
+ connectWallet(chainKey: string, options?: ChainStrategyConnectOptions): Promise<void>;
167
+ disconnectWallet(chainKey: string, options?: ChainStrategyConnectOptions): Promise<void>;
168
+ }
169
+
115
170
  export declare function computeFeesUsdFromArray(fees: Array<Fees_2> | undefined, tokens: Token[] | undefined, chains: Chain[] | undefined): FeeBreakdown;
116
171
 
117
172
  declare interface ConnectedWalletActions {
@@ -381,6 +436,8 @@ export declare interface MonitorResult {
381
436
  confirmations?: number;
382
437
  }
383
438
 
439
+ declare type NetworkType = "ton" | "evm" | "tron";
440
+
384
441
  /**
385
442
  * Нормализует строку символа токена
386
443
  * - USD₮ → USDT
@@ -485,6 +542,14 @@ declare interface SettingsState {
485
542
  getSlippageDecimal: () => number;
486
543
  }
487
544
 
545
+ declare interface SourceCost {
546
+ totalNative: number;
547
+ breakdown?: {
548
+ gasFee?: number;
549
+ layerZeroFee?: number;
550
+ };
551
+ }
552
+
488
553
  declare type Store = TransactionState & TransactionActions;
489
554
 
490
555
  export declare function sumFeeByTokenLD(fees: Array<{
@@ -613,6 +678,14 @@ declare interface TransactionMetadata {
613
678
  layerZeroTotalFeeUsd?: number;
614
679
  }
615
680
 
681
+ declare interface TransactionResult {
682
+ hash?: string;
683
+ error?: string;
684
+ chainKey?: string;
685
+ messageId?: string;
686
+ tonTransactionHash?: string;
687
+ }
688
+
616
689
  declare interface TransactionState {
617
690
  current?: CurrentTransaction;
618
691
  successModalOpen: boolean;
@@ -626,6 +699,13 @@ export declare interface TransactionStep {
626
699
  transaction: Transaction;
627
700
  }
628
701
 
702
+ declare interface TransactionStrategyContext {
703
+ srcAddress: string;
704
+ dstAddress: string;
705
+ srcChainKey: string;
706
+ dstChainKey: string;
707
+ }
708
+
629
709
  export declare interface TronLinkApi {
630
710
  ready?: boolean;
631
711
  tronWeb?: TronWeb;