@trustware/sdk-staging 1.0.16-staging.13 → 1.0.17-staging.14
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/constants.cjs +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/index.cjs +2035 -270
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +193 -31
- package/dist/index.d.ts +193 -31
- package/dist/index.mjs +2017 -263
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/index.d.cts
CHANGED
|
@@ -54,8 +54,11 @@ type BuildRouteBody = {
|
|
|
54
54
|
fromAddress: string;
|
|
55
55
|
toAddress: string;
|
|
56
56
|
fromAmountUsd?: string;
|
|
57
|
+
fromAmountUSD?: string;
|
|
57
58
|
refundAddress?: string;
|
|
59
|
+
direction?: string;
|
|
58
60
|
slippage?: number;
|
|
61
|
+
slippageBps?: number;
|
|
59
62
|
linkId?: string;
|
|
60
63
|
memo?: string;
|
|
61
64
|
};
|
|
@@ -80,6 +83,16 @@ declare function buildRoute(body: BuildRouteBody, signal?: AbortSignal): Promise
|
|
|
80
83
|
};
|
|
81
84
|
route: RoutePlan | undefined;
|
|
82
85
|
}>;
|
|
86
|
+
declare function buildDepositAddress(body: BuildRouteBody, signal?: AbortSignal): Promise<{
|
|
87
|
+
intentId: string;
|
|
88
|
+
depositAddress: string;
|
|
89
|
+
actions: unknown[];
|
|
90
|
+
finalExchangeRate: {
|
|
91
|
+
fromAmountUSD?: string;
|
|
92
|
+
toAmountMinUSD?: string;
|
|
93
|
+
};
|
|
94
|
+
route: RoutePlan | undefined;
|
|
95
|
+
}>;
|
|
83
96
|
declare function submitReceipt(intentId: string, txHash: string): Promise<any>;
|
|
84
97
|
declare function getStatus(intentId: string): Promise<Transaction>;
|
|
85
98
|
declare function pollStatus(intentId: string, { intervalMs, timeoutMs }?: {
|
|
@@ -316,12 +329,14 @@ type ResolvedRetryConfig = {
|
|
|
316
329
|
};
|
|
317
330
|
declare const DEFAULT_RETRY_CONFIG: ResolvedRetryConfig;
|
|
318
331
|
|
|
319
|
-
type WalletId = "metamask" | "coinbase" | "walletconnect" | "rainbow" | "phantom-evm" | "rabby" | "brave" | "okx" | "zerion" | "taho" | "safe" | "imtoken" | "trust" | "bitget" | "kucoin";
|
|
332
|
+
type WalletId = "metamask" | "coinbase" | "walletconnect" | "rainbow" | "phantom-evm" | "phantom-solana" | "solflare" | "backpack" | "rabby" | "brave" | "okx" | "zerion" | "taho" | "safe" | "imtoken" | "trust" | "bitget" | "kucoin";
|
|
320
333
|
type WalletCategory = "injected" | "walletconnect" | "app";
|
|
334
|
+
type WalletEcosystem = "evm" | "solana" | "multi";
|
|
321
335
|
type WalletMeta = {
|
|
322
336
|
id: WalletId;
|
|
323
337
|
name: string;
|
|
324
338
|
category: WalletCategory;
|
|
339
|
+
ecosystem: WalletEcosystem;
|
|
325
340
|
logo: string;
|
|
326
341
|
emoji?: string;
|
|
327
342
|
homepage?: string;
|
|
@@ -356,12 +371,37 @@ type EIP6963ProviderDetail = {
|
|
|
356
371
|
};
|
|
357
372
|
type DetectedWallet = {
|
|
358
373
|
meta: WalletMeta;
|
|
359
|
-
via: "eip6963" | "injected-flag" | "walletconnect";
|
|
374
|
+
via: "eip6963" | "injected-flag" | "walletconnect" | "solana-window";
|
|
360
375
|
detail?: EIP6963ProviderDetail;
|
|
361
376
|
provider?: any;
|
|
362
377
|
};
|
|
363
|
-
type
|
|
378
|
+
type SolanaProviderLike = {
|
|
379
|
+
isPhantom?: boolean;
|
|
380
|
+
isSolflare?: boolean;
|
|
381
|
+
isBackpack?: boolean;
|
|
382
|
+
isConnected?: boolean;
|
|
383
|
+
publicKey?: {
|
|
384
|
+
toString(): string;
|
|
385
|
+
};
|
|
386
|
+
connect?: (options?: Record<string, unknown>) => Promise<unknown>;
|
|
387
|
+
disconnect?: () => Promise<void>;
|
|
388
|
+
signAndSendTransaction?: (transaction: unknown, options?: Record<string, unknown>) => Promise<{
|
|
389
|
+
signature?: string;
|
|
390
|
+
} | string>;
|
|
391
|
+
signTransaction?: (transaction: unknown) => Promise<{
|
|
392
|
+
serialize: () => Uint8Array;
|
|
393
|
+
}>;
|
|
394
|
+
on?: (event: string, listener: (...args: unknown[]) => void) => void;
|
|
395
|
+
off?: (event: string, listener: (...args: unknown[]) => void) => void;
|
|
396
|
+
removeListener?: (event: string, listener: (...args: unknown[]) => void) => void;
|
|
397
|
+
};
|
|
398
|
+
type BaseWalletInterface = {
|
|
399
|
+
ecosystem: "evm" | "solana";
|
|
364
400
|
getAddress(): Promise<string>;
|
|
401
|
+
disconnect?(): Promise<void>;
|
|
402
|
+
};
|
|
403
|
+
type EvmWalletInterface = BaseWalletInterface & {
|
|
404
|
+
ecosystem: "evm";
|
|
365
405
|
getChainId(): Promise<number>;
|
|
366
406
|
switchChain(chainId: number): Promise<void>;
|
|
367
407
|
} & ({
|
|
@@ -381,10 +421,16 @@ type WalletInterFaceAPI = {
|
|
|
381
421
|
hash: `0x${string}`;
|
|
382
422
|
}>;
|
|
383
423
|
});
|
|
424
|
+
type SolanaWalletInterface = BaseWalletInterface & {
|
|
425
|
+
ecosystem: "solana";
|
|
426
|
+
type: "solana";
|
|
427
|
+
getChainKey(): Promise<string>;
|
|
428
|
+
sendSerializedTransaction(serializedTransactionBase64: string, rpcUrl?: string): Promise<string>;
|
|
429
|
+
};
|
|
430
|
+
type WalletInterFaceAPI = EvmWalletInterface | SolanaWalletInterface;
|
|
384
431
|
type SimpleWalletInterface = {
|
|
385
432
|
getAddress(): Promise<string>;
|
|
386
|
-
|
|
387
|
-
switchChain(chainId: number): Promise<void>;
|
|
433
|
+
disconnect?(): Promise<void>;
|
|
388
434
|
};
|
|
389
435
|
|
|
390
436
|
type ChainMeta = {
|
|
@@ -407,11 +453,14 @@ type TokenMeta = {
|
|
|
407
453
|
type BalanceRow = {
|
|
408
454
|
chain_key: string;
|
|
409
455
|
category: "native" | "erc20" | "spl" | "btc";
|
|
410
|
-
contract?:
|
|
456
|
+
contract?: string;
|
|
457
|
+
address?: string;
|
|
411
458
|
symbol?: string;
|
|
412
459
|
decimals: number;
|
|
413
460
|
balance: string;
|
|
414
461
|
name?: string;
|
|
462
|
+
logoURI?: string;
|
|
463
|
+
usdPrice?: number;
|
|
415
464
|
};
|
|
416
465
|
type WalletAddressBalanceWrapper = {
|
|
417
466
|
chain_id: string;
|
|
@@ -475,12 +524,121 @@ type TokenWithBalance = TokenDef & {
|
|
|
475
524
|
balance?: bigint;
|
|
476
525
|
};
|
|
477
526
|
|
|
478
|
-
|
|
479
|
-
|
|
527
|
+
type WalletAddressSource = "provider" | "manual" | "imported";
|
|
528
|
+
type WalletIdentityAddress = {
|
|
529
|
+
address: string;
|
|
530
|
+
chainType: ChainType;
|
|
531
|
+
chainKey?: string;
|
|
532
|
+
chainId?: string;
|
|
533
|
+
providerId?: string;
|
|
534
|
+
source: WalletAddressSource;
|
|
535
|
+
};
|
|
536
|
+
type WalletIdentity = {
|
|
537
|
+
addresses: WalletIdentityAddress[];
|
|
538
|
+
};
|
|
539
|
+
type WalletAddressResolution = {
|
|
540
|
+
status: "resolved";
|
|
541
|
+
address: string;
|
|
542
|
+
source: WalletAddressSource;
|
|
543
|
+
chainType: ChainType;
|
|
544
|
+
chainKey?: string;
|
|
545
|
+
chainId?: string;
|
|
546
|
+
} | {
|
|
547
|
+
status: "missing" | "invalid";
|
|
548
|
+
reason: string;
|
|
549
|
+
address?: string;
|
|
550
|
+
source?: WalletAddressSource;
|
|
551
|
+
chainType?: ChainType;
|
|
552
|
+
chainKey?: string;
|
|
553
|
+
chainId?: string;
|
|
554
|
+
};
|
|
555
|
+
type WalletIdentityChainLike = ChainDef | ChainType | string | null;
|
|
556
|
+
|
|
557
|
+
type WagmiConnector = {
|
|
558
|
+
/** Human label like "MetaMask", "WalletConnect" */
|
|
559
|
+
name: string;
|
|
560
|
+
/** Free-form type hint: "injected" | "walletConnect" | ... */
|
|
561
|
+
type?: string;
|
|
562
|
+
};
|
|
563
|
+
type WagmiBridge = {
|
|
564
|
+
/** Host app believes it’s connected (Wagmi state) */
|
|
565
|
+
isConnected(): boolean;
|
|
566
|
+
/** List of available connectors */
|
|
567
|
+
connectors(): WagmiConnector[];
|
|
568
|
+
/** Try connecting via a specific connector */
|
|
569
|
+
connect(connector: WagmiConnector): Promise<void>;
|
|
570
|
+
/** Disconnect current session */
|
|
571
|
+
disconnect(): Promise<void>;
|
|
572
|
+
};
|
|
573
|
+
|
|
574
|
+
declare function createWalletIdentity(addresses?: WalletIdentityAddress[]): WalletIdentity;
|
|
575
|
+
declare function upsertWalletIdentityAddress(identity: WalletIdentity, next: WalletIdentityAddress): WalletIdentity;
|
|
576
|
+
declare function resolveWalletAddressForChain(identity: WalletIdentity, chain?: WalletIdentityChainLike): WalletAddressResolution;
|
|
577
|
+
declare function buildWalletIdentityAddress(params: {
|
|
578
|
+
address: string;
|
|
579
|
+
chain: WalletIdentityChainLike;
|
|
580
|
+
source: WalletAddressSource;
|
|
581
|
+
providerId?: string;
|
|
582
|
+
}): WalletIdentityAddress | null;
|
|
583
|
+
declare class IdentityStore {
|
|
584
|
+
private _identity;
|
|
585
|
+
get snapshot(): WalletIdentity;
|
|
586
|
+
reset(): void;
|
|
587
|
+
upsert(next: WalletIdentityAddress): WalletIdentity;
|
|
588
|
+
resolve(chain?: WalletIdentityChainLike): WalletAddressResolution;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
type Status$1 = "idle" | "detecting" | "connecting" | "connected" | "error";
|
|
592
|
+
type Listener = (s: Status$1) => void;
|
|
593
|
+
declare class WalletManager {
|
|
594
|
+
private _status;
|
|
595
|
+
private _wallet;
|
|
596
|
+
private _detected;
|
|
597
|
+
private _listeners;
|
|
598
|
+
private _error;
|
|
599
|
+
private _identity;
|
|
600
|
+
private _providerCleanup;
|
|
601
|
+
private _connectedWalletId;
|
|
602
|
+
get status(): Status$1;
|
|
603
|
+
get error(): unknown;
|
|
604
|
+
get detected(): DetectedWallet[];
|
|
605
|
+
get wallet(): WalletInterFaceAPI | null;
|
|
606
|
+
get simple(): SimpleWalletInterface | null;
|
|
607
|
+
get identity(): WalletIdentity;
|
|
608
|
+
get connectedWalletId(): string | null;
|
|
609
|
+
onChange(fn: Listener): () => boolean;
|
|
610
|
+
private emit;
|
|
611
|
+
/** Provide detection results (from your hook or custom function). */
|
|
612
|
+
setDetected(list: DetectedWallet[]): void;
|
|
613
|
+
/** Optional: auto attach to the first/best detected wallet. */
|
|
614
|
+
autoAttach(opts?: {
|
|
615
|
+
wagmi?: WagmiBridge;
|
|
616
|
+
pick?: (list: DetectedWallet[]) => DetectedWallet | undefined;
|
|
617
|
+
}): Promise<void>;
|
|
618
|
+
connectDetected(target: DetectedWallet, opts?: {
|
|
619
|
+
wagmi?: WagmiBridge;
|
|
620
|
+
}): Promise<void>;
|
|
621
|
+
disconnect(wagmi?: WagmiBridge): Promise<void>;
|
|
622
|
+
/** Directly attach a pre-provided wallet interface (from old provider prop). */
|
|
623
|
+
attachWallet(api: WalletInterFaceAPI): void;
|
|
624
|
+
/** Optional helper to set explicit status (e.g., "initializing" UX). */
|
|
625
|
+
setStatus(s: Status$1): void;
|
|
626
|
+
addIdentityAddress(address: WalletIdentityAddress): void;
|
|
627
|
+
resolveAddressForChain(chain: Parameters<IdentityStore["resolve"]>[0]): WalletAddressResolution;
|
|
628
|
+
private clearProviderCleanup;
|
|
629
|
+
private clearConnectedWalletState;
|
|
630
|
+
private bindProviderEvents;
|
|
631
|
+
private syncIdentityFromWallet;
|
|
632
|
+
}
|
|
633
|
+
declare const walletManager: WalletManager;
|
|
634
|
+
/** If you’re in React, call this once near your widget to push detection results into the manager. */
|
|
635
|
+
declare function useWireDetectionIntoManager(): void;
|
|
636
|
+
|
|
637
|
+
/** Map chain reference -> backend chain_key and return enriched balances */
|
|
638
|
+
declare function getBalances(chainRef: string | number, address: string): Promise<BalanceRow[]>;
|
|
480
639
|
declare function getBalancesByAddress(address: string): Promise<WalletAddressBalanceWrapper[]>;
|
|
481
640
|
|
|
482
|
-
declare function sendRouteTransaction(b: BuildRouteResult, fallbackChainId?: number): Promise
|
|
483
|
-
/** One-shot flow that mirrors your old runTopUp */
|
|
641
|
+
declare function sendRouteTransaction(b: BuildRouteResult, fallbackChainId?: number | string): Promise<string>;
|
|
484
642
|
declare function runTopUp(params: {
|
|
485
643
|
fromChain?: string;
|
|
486
644
|
toChain?: string;
|
|
@@ -554,6 +712,24 @@ interface UseTokensResult {
|
|
|
554
712
|
*/
|
|
555
713
|
declare function useTokens(chainId: number | null | undefined): UseTokensResult;
|
|
556
714
|
|
|
715
|
+
type AddressValidationResult = {
|
|
716
|
+
isValid: boolean;
|
|
717
|
+
error?: string;
|
|
718
|
+
};
|
|
719
|
+
declare function validateEvmAddress(address: string): AddressValidationResult;
|
|
720
|
+
declare function validateSeiAddress(address: string): AddressValidationResult;
|
|
721
|
+
declare function validateSolanaAddress(address: string): AddressValidationResult;
|
|
722
|
+
declare function validateBtcAddress(address: string): AddressValidationResult;
|
|
723
|
+
declare function validateAddressForChain(address: string, chain?: ChainDef | ChainType | string | null): AddressValidationResult;
|
|
724
|
+
declare function validateRouteAddresses(params: {
|
|
725
|
+
fromChain?: ChainDef | ChainType | string | null;
|
|
726
|
+
toChain?: ChainDef | ChainType | string | null;
|
|
727
|
+
fromAddress: string;
|
|
728
|
+
toAddress: string;
|
|
729
|
+
refundAddress?: string;
|
|
730
|
+
direction?: string;
|
|
731
|
+
}): AddressValidationResult;
|
|
732
|
+
|
|
557
733
|
declare const Trustware: {
|
|
558
734
|
/** Initialize config */
|
|
559
735
|
init(cfg: TrustwareConfigOptions): Promise</*elided*/ any>;
|
|
@@ -566,9 +742,13 @@ declare const Trustware: {
|
|
|
566
742
|
setDestinationAddress(address?: string | null): /*elided*/ any;
|
|
567
743
|
/** Read active wallet */
|
|
568
744
|
getWallet(): WalletInterFaceAPI | null;
|
|
745
|
+
getIdentity(): WalletIdentity;
|
|
746
|
+
resolveAddressForChain(chain: Parameters<typeof walletManager.resolveAddressForChain>[0]): WalletAddressResolution;
|
|
747
|
+
addIdentityAddress(address: Parameters<typeof walletManager.addIdentityAddress>[0]): /*elided*/ any;
|
|
569
748
|
/** Simple helpers */
|
|
570
749
|
getAddress(): Promise<string>;
|
|
571
750
|
buildRoute: typeof buildRoute;
|
|
751
|
+
buildDepositAddress: typeof buildDepositAddress;
|
|
572
752
|
submitReceipt: typeof submitReceipt;
|
|
573
753
|
getStatus: typeof getStatus;
|
|
574
754
|
pollStatus: typeof pollStatus;
|
|
@@ -576,6 +756,8 @@ declare const Trustware: {
|
|
|
576
756
|
getBalancesByAddress: typeof getBalancesByAddress;
|
|
577
757
|
useChains: typeof useChains;
|
|
578
758
|
useTokens: typeof useTokens;
|
|
759
|
+
validateAddressForChain: typeof validateAddressForChain;
|
|
760
|
+
validateRouteAddresses: typeof validateRouteAddresses;
|
|
579
761
|
sendRouteTransaction: typeof sendRouteTransaction;
|
|
580
762
|
runTopUp: typeof runTopUp;
|
|
581
763
|
};
|
|
@@ -587,23 +769,6 @@ declare class RateLimitError extends Error {
|
|
|
587
769
|
constructor(info: RateLimitInfo, retriesExhausted: boolean);
|
|
588
770
|
}
|
|
589
771
|
|
|
590
|
-
type WagmiConnector = {
|
|
591
|
-
/** Human label like "MetaMask", "WalletConnect" */
|
|
592
|
-
name: string;
|
|
593
|
-
/** Free-form type hint: "injected" | "walletConnect" | ... */
|
|
594
|
-
type?: string;
|
|
595
|
-
};
|
|
596
|
-
type WagmiBridge = {
|
|
597
|
-
/** Host app believes it’s connected (Wagmi state) */
|
|
598
|
-
isConnected(): boolean;
|
|
599
|
-
/** List of available connectors */
|
|
600
|
-
connectors(): WagmiConnector[];
|
|
601
|
-
/** Try connecting via a specific connector */
|
|
602
|
-
connect(connector: WagmiConnector): Promise<void>;
|
|
603
|
-
/** Disconnect current session */
|
|
604
|
-
disconnect(): Promise<void>;
|
|
605
|
-
};
|
|
606
|
-
|
|
607
772
|
/** Try wagmi bridge first (if provided), otherwise return EIP-1193 adapter. */
|
|
608
773
|
declare function connectDetectedWallet(dw: DetectedWallet, opts?: {
|
|
609
774
|
wagmi?: WagmiBridge;
|
|
@@ -613,9 +778,6 @@ declare function connectDetectedWallet(dw: DetectedWallet, opts?: {
|
|
|
613
778
|
api: WalletInterFaceAPI | null;
|
|
614
779
|
}>;
|
|
615
780
|
|
|
616
|
-
/** If you’re in React, call this once near your widget to push detection results into the manager. */
|
|
617
|
-
declare function useWireDetectionIntoManager(): void;
|
|
618
|
-
|
|
619
781
|
declare function useEIP1193(eth: EIP1193): WalletInterFaceAPI;
|
|
620
782
|
declare function useWagmi(client: any): WalletInterFaceAPI;
|
|
621
783
|
|
|
@@ -707,4 +869,4 @@ declare function TrustwareProvider({ config, wallet, autoDetect, children, }: {
|
|
|
707
869
|
}): react_jsx_runtime.JSX.Element;
|
|
708
870
|
declare function useTrustware(): Ctx;
|
|
709
871
|
|
|
710
|
-
export { type BalanceRow, type BuildRouteResult, type ChainDef, type ChainMeta, type ChainType, DEFAULT_AUTO_DETECT_PROVIDER, DEFAULT_MESSAGES, DEFAULT_RETRY_CONFIG, DEFAULT_SLIPPAGE, DEFAULT_THEME, type DetectedWallet, type EIP1193, type EIP6963ProviderDetail, type NativeCurrency, RateLimitError, type RateLimitInfo, type ResolvedRetryConfig, type ResolvedTrustwareConfig, type ResolvedWalletConnectConfig, type RetryConfig, type RouteEstimate, type RouteIntent, type RouteParams, type RoutePlan, type SimpleWalletInterface, type TokenDef, type TokenMeta, type TokenType, type TokenWithBalance, type Transaction, Trustware, type TrustwareConfigOptions, type TrustwareCore, TrustwareError, TrustwareProvider, TrustwareWidgetV2 as TrustwareWidget, type TrustwareWidgetMessages, type TrustwareWidgetTheme, type WagmiBridge, type WagmiConnector, type WalletAddressBalanceWrapper, type WalletCategory, type WalletConnectConfig, type WalletId, type WalletInterFaceAPI, type WalletMeta, connectDetectedWallet, toWalletInterfaceFromDetected, useEIP1193, useTrustware, useWagmi, useWalletDetection, useWireDetectionIntoManager };
|
|
872
|
+
export { type BalanceRow, type BuildRouteResult, type ChainDef, type ChainMeta, type ChainType, DEFAULT_AUTO_DETECT_PROVIDER, DEFAULT_MESSAGES, DEFAULT_RETRY_CONFIG, DEFAULT_SLIPPAGE, DEFAULT_THEME, type DetectedWallet, type EIP1193, type EIP6963ProviderDetail, type EvmWalletInterface, IdentityStore, type NativeCurrency, RateLimitError, type RateLimitInfo, type ResolvedRetryConfig, type ResolvedTrustwareConfig, type ResolvedWalletConnectConfig, type RetryConfig, type RouteEstimate, type RouteIntent, type RouteParams, type RoutePlan, type SimpleWalletInterface, type SolanaProviderLike, type SolanaWalletInterface, type TokenDef, type TokenMeta, type TokenType, type TokenWithBalance, type Transaction, Trustware, type TrustwareConfigOptions, type TrustwareCore, TrustwareError, TrustwareProvider, TrustwareWidgetV2 as TrustwareWidget, type TrustwareWidgetMessages, type TrustwareWidgetTheme, type WagmiBridge, type WagmiConnector, type WalletAddressBalanceWrapper, type WalletAddressResolution, type WalletAddressSource, type WalletCategory, type WalletConnectConfig, type WalletEcosystem, type WalletId, type WalletIdentity, type WalletIdentityAddress, type WalletIdentityChainLike, type WalletInterFaceAPI, type WalletMeta, buildWalletIdentityAddress, connectDetectedWallet, createWalletIdentity, resolveWalletAddressForChain, toWalletInterfaceFromDetected, upsertWalletIdentityAddress, useEIP1193, useTrustware, useWagmi, useWalletDetection, useWireDetectionIntoManager, validateAddressForChain, validateBtcAddress, validateEvmAddress, validateRouteAddresses, validateSeiAddress, validateSolanaAddress };
|
package/dist/index.d.ts
CHANGED
|
@@ -54,8 +54,11 @@ type BuildRouteBody = {
|
|
|
54
54
|
fromAddress: string;
|
|
55
55
|
toAddress: string;
|
|
56
56
|
fromAmountUsd?: string;
|
|
57
|
+
fromAmountUSD?: string;
|
|
57
58
|
refundAddress?: string;
|
|
59
|
+
direction?: string;
|
|
58
60
|
slippage?: number;
|
|
61
|
+
slippageBps?: number;
|
|
59
62
|
linkId?: string;
|
|
60
63
|
memo?: string;
|
|
61
64
|
};
|
|
@@ -80,6 +83,16 @@ declare function buildRoute(body: BuildRouteBody, signal?: AbortSignal): Promise
|
|
|
80
83
|
};
|
|
81
84
|
route: RoutePlan | undefined;
|
|
82
85
|
}>;
|
|
86
|
+
declare function buildDepositAddress(body: BuildRouteBody, signal?: AbortSignal): Promise<{
|
|
87
|
+
intentId: string;
|
|
88
|
+
depositAddress: string;
|
|
89
|
+
actions: unknown[];
|
|
90
|
+
finalExchangeRate: {
|
|
91
|
+
fromAmountUSD?: string;
|
|
92
|
+
toAmountMinUSD?: string;
|
|
93
|
+
};
|
|
94
|
+
route: RoutePlan | undefined;
|
|
95
|
+
}>;
|
|
83
96
|
declare function submitReceipt(intentId: string, txHash: string): Promise<any>;
|
|
84
97
|
declare function getStatus(intentId: string): Promise<Transaction>;
|
|
85
98
|
declare function pollStatus(intentId: string, { intervalMs, timeoutMs }?: {
|
|
@@ -316,12 +329,14 @@ type ResolvedRetryConfig = {
|
|
|
316
329
|
};
|
|
317
330
|
declare const DEFAULT_RETRY_CONFIG: ResolvedRetryConfig;
|
|
318
331
|
|
|
319
|
-
type WalletId = "metamask" | "coinbase" | "walletconnect" | "rainbow" | "phantom-evm" | "rabby" | "brave" | "okx" | "zerion" | "taho" | "safe" | "imtoken" | "trust" | "bitget" | "kucoin";
|
|
332
|
+
type WalletId = "metamask" | "coinbase" | "walletconnect" | "rainbow" | "phantom-evm" | "phantom-solana" | "solflare" | "backpack" | "rabby" | "brave" | "okx" | "zerion" | "taho" | "safe" | "imtoken" | "trust" | "bitget" | "kucoin";
|
|
320
333
|
type WalletCategory = "injected" | "walletconnect" | "app";
|
|
334
|
+
type WalletEcosystem = "evm" | "solana" | "multi";
|
|
321
335
|
type WalletMeta = {
|
|
322
336
|
id: WalletId;
|
|
323
337
|
name: string;
|
|
324
338
|
category: WalletCategory;
|
|
339
|
+
ecosystem: WalletEcosystem;
|
|
325
340
|
logo: string;
|
|
326
341
|
emoji?: string;
|
|
327
342
|
homepage?: string;
|
|
@@ -356,12 +371,37 @@ type EIP6963ProviderDetail = {
|
|
|
356
371
|
};
|
|
357
372
|
type DetectedWallet = {
|
|
358
373
|
meta: WalletMeta;
|
|
359
|
-
via: "eip6963" | "injected-flag" | "walletconnect";
|
|
374
|
+
via: "eip6963" | "injected-flag" | "walletconnect" | "solana-window";
|
|
360
375
|
detail?: EIP6963ProviderDetail;
|
|
361
376
|
provider?: any;
|
|
362
377
|
};
|
|
363
|
-
type
|
|
378
|
+
type SolanaProviderLike = {
|
|
379
|
+
isPhantom?: boolean;
|
|
380
|
+
isSolflare?: boolean;
|
|
381
|
+
isBackpack?: boolean;
|
|
382
|
+
isConnected?: boolean;
|
|
383
|
+
publicKey?: {
|
|
384
|
+
toString(): string;
|
|
385
|
+
};
|
|
386
|
+
connect?: (options?: Record<string, unknown>) => Promise<unknown>;
|
|
387
|
+
disconnect?: () => Promise<void>;
|
|
388
|
+
signAndSendTransaction?: (transaction: unknown, options?: Record<string, unknown>) => Promise<{
|
|
389
|
+
signature?: string;
|
|
390
|
+
} | string>;
|
|
391
|
+
signTransaction?: (transaction: unknown) => Promise<{
|
|
392
|
+
serialize: () => Uint8Array;
|
|
393
|
+
}>;
|
|
394
|
+
on?: (event: string, listener: (...args: unknown[]) => void) => void;
|
|
395
|
+
off?: (event: string, listener: (...args: unknown[]) => void) => void;
|
|
396
|
+
removeListener?: (event: string, listener: (...args: unknown[]) => void) => void;
|
|
397
|
+
};
|
|
398
|
+
type BaseWalletInterface = {
|
|
399
|
+
ecosystem: "evm" | "solana";
|
|
364
400
|
getAddress(): Promise<string>;
|
|
401
|
+
disconnect?(): Promise<void>;
|
|
402
|
+
};
|
|
403
|
+
type EvmWalletInterface = BaseWalletInterface & {
|
|
404
|
+
ecosystem: "evm";
|
|
365
405
|
getChainId(): Promise<number>;
|
|
366
406
|
switchChain(chainId: number): Promise<void>;
|
|
367
407
|
} & ({
|
|
@@ -381,10 +421,16 @@ type WalletInterFaceAPI = {
|
|
|
381
421
|
hash: `0x${string}`;
|
|
382
422
|
}>;
|
|
383
423
|
});
|
|
424
|
+
type SolanaWalletInterface = BaseWalletInterface & {
|
|
425
|
+
ecosystem: "solana";
|
|
426
|
+
type: "solana";
|
|
427
|
+
getChainKey(): Promise<string>;
|
|
428
|
+
sendSerializedTransaction(serializedTransactionBase64: string, rpcUrl?: string): Promise<string>;
|
|
429
|
+
};
|
|
430
|
+
type WalletInterFaceAPI = EvmWalletInterface | SolanaWalletInterface;
|
|
384
431
|
type SimpleWalletInterface = {
|
|
385
432
|
getAddress(): Promise<string>;
|
|
386
|
-
|
|
387
|
-
switchChain(chainId: number): Promise<void>;
|
|
433
|
+
disconnect?(): Promise<void>;
|
|
388
434
|
};
|
|
389
435
|
|
|
390
436
|
type ChainMeta = {
|
|
@@ -407,11 +453,14 @@ type TokenMeta = {
|
|
|
407
453
|
type BalanceRow = {
|
|
408
454
|
chain_key: string;
|
|
409
455
|
category: "native" | "erc20" | "spl" | "btc";
|
|
410
|
-
contract?:
|
|
456
|
+
contract?: string;
|
|
457
|
+
address?: string;
|
|
411
458
|
symbol?: string;
|
|
412
459
|
decimals: number;
|
|
413
460
|
balance: string;
|
|
414
461
|
name?: string;
|
|
462
|
+
logoURI?: string;
|
|
463
|
+
usdPrice?: number;
|
|
415
464
|
};
|
|
416
465
|
type WalletAddressBalanceWrapper = {
|
|
417
466
|
chain_id: string;
|
|
@@ -475,12 +524,121 @@ type TokenWithBalance = TokenDef & {
|
|
|
475
524
|
balance?: bigint;
|
|
476
525
|
};
|
|
477
526
|
|
|
478
|
-
|
|
479
|
-
|
|
527
|
+
type WalletAddressSource = "provider" | "manual" | "imported";
|
|
528
|
+
type WalletIdentityAddress = {
|
|
529
|
+
address: string;
|
|
530
|
+
chainType: ChainType;
|
|
531
|
+
chainKey?: string;
|
|
532
|
+
chainId?: string;
|
|
533
|
+
providerId?: string;
|
|
534
|
+
source: WalletAddressSource;
|
|
535
|
+
};
|
|
536
|
+
type WalletIdentity = {
|
|
537
|
+
addresses: WalletIdentityAddress[];
|
|
538
|
+
};
|
|
539
|
+
type WalletAddressResolution = {
|
|
540
|
+
status: "resolved";
|
|
541
|
+
address: string;
|
|
542
|
+
source: WalletAddressSource;
|
|
543
|
+
chainType: ChainType;
|
|
544
|
+
chainKey?: string;
|
|
545
|
+
chainId?: string;
|
|
546
|
+
} | {
|
|
547
|
+
status: "missing" | "invalid";
|
|
548
|
+
reason: string;
|
|
549
|
+
address?: string;
|
|
550
|
+
source?: WalletAddressSource;
|
|
551
|
+
chainType?: ChainType;
|
|
552
|
+
chainKey?: string;
|
|
553
|
+
chainId?: string;
|
|
554
|
+
};
|
|
555
|
+
type WalletIdentityChainLike = ChainDef | ChainType | string | null;
|
|
556
|
+
|
|
557
|
+
type WagmiConnector = {
|
|
558
|
+
/** Human label like "MetaMask", "WalletConnect" */
|
|
559
|
+
name: string;
|
|
560
|
+
/** Free-form type hint: "injected" | "walletConnect" | ... */
|
|
561
|
+
type?: string;
|
|
562
|
+
};
|
|
563
|
+
type WagmiBridge = {
|
|
564
|
+
/** Host app believes it’s connected (Wagmi state) */
|
|
565
|
+
isConnected(): boolean;
|
|
566
|
+
/** List of available connectors */
|
|
567
|
+
connectors(): WagmiConnector[];
|
|
568
|
+
/** Try connecting via a specific connector */
|
|
569
|
+
connect(connector: WagmiConnector): Promise<void>;
|
|
570
|
+
/** Disconnect current session */
|
|
571
|
+
disconnect(): Promise<void>;
|
|
572
|
+
};
|
|
573
|
+
|
|
574
|
+
declare function createWalletIdentity(addresses?: WalletIdentityAddress[]): WalletIdentity;
|
|
575
|
+
declare function upsertWalletIdentityAddress(identity: WalletIdentity, next: WalletIdentityAddress): WalletIdentity;
|
|
576
|
+
declare function resolveWalletAddressForChain(identity: WalletIdentity, chain?: WalletIdentityChainLike): WalletAddressResolution;
|
|
577
|
+
declare function buildWalletIdentityAddress(params: {
|
|
578
|
+
address: string;
|
|
579
|
+
chain: WalletIdentityChainLike;
|
|
580
|
+
source: WalletAddressSource;
|
|
581
|
+
providerId?: string;
|
|
582
|
+
}): WalletIdentityAddress | null;
|
|
583
|
+
declare class IdentityStore {
|
|
584
|
+
private _identity;
|
|
585
|
+
get snapshot(): WalletIdentity;
|
|
586
|
+
reset(): void;
|
|
587
|
+
upsert(next: WalletIdentityAddress): WalletIdentity;
|
|
588
|
+
resolve(chain?: WalletIdentityChainLike): WalletAddressResolution;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
type Status$1 = "idle" | "detecting" | "connecting" | "connected" | "error";
|
|
592
|
+
type Listener = (s: Status$1) => void;
|
|
593
|
+
declare class WalletManager {
|
|
594
|
+
private _status;
|
|
595
|
+
private _wallet;
|
|
596
|
+
private _detected;
|
|
597
|
+
private _listeners;
|
|
598
|
+
private _error;
|
|
599
|
+
private _identity;
|
|
600
|
+
private _providerCleanup;
|
|
601
|
+
private _connectedWalletId;
|
|
602
|
+
get status(): Status$1;
|
|
603
|
+
get error(): unknown;
|
|
604
|
+
get detected(): DetectedWallet[];
|
|
605
|
+
get wallet(): WalletInterFaceAPI | null;
|
|
606
|
+
get simple(): SimpleWalletInterface | null;
|
|
607
|
+
get identity(): WalletIdentity;
|
|
608
|
+
get connectedWalletId(): string | null;
|
|
609
|
+
onChange(fn: Listener): () => boolean;
|
|
610
|
+
private emit;
|
|
611
|
+
/** Provide detection results (from your hook or custom function). */
|
|
612
|
+
setDetected(list: DetectedWallet[]): void;
|
|
613
|
+
/** Optional: auto attach to the first/best detected wallet. */
|
|
614
|
+
autoAttach(opts?: {
|
|
615
|
+
wagmi?: WagmiBridge;
|
|
616
|
+
pick?: (list: DetectedWallet[]) => DetectedWallet | undefined;
|
|
617
|
+
}): Promise<void>;
|
|
618
|
+
connectDetected(target: DetectedWallet, opts?: {
|
|
619
|
+
wagmi?: WagmiBridge;
|
|
620
|
+
}): Promise<void>;
|
|
621
|
+
disconnect(wagmi?: WagmiBridge): Promise<void>;
|
|
622
|
+
/** Directly attach a pre-provided wallet interface (from old provider prop). */
|
|
623
|
+
attachWallet(api: WalletInterFaceAPI): void;
|
|
624
|
+
/** Optional helper to set explicit status (e.g., "initializing" UX). */
|
|
625
|
+
setStatus(s: Status$1): void;
|
|
626
|
+
addIdentityAddress(address: WalletIdentityAddress): void;
|
|
627
|
+
resolveAddressForChain(chain: Parameters<IdentityStore["resolve"]>[0]): WalletAddressResolution;
|
|
628
|
+
private clearProviderCleanup;
|
|
629
|
+
private clearConnectedWalletState;
|
|
630
|
+
private bindProviderEvents;
|
|
631
|
+
private syncIdentityFromWallet;
|
|
632
|
+
}
|
|
633
|
+
declare const walletManager: WalletManager;
|
|
634
|
+
/** If you’re in React, call this once near your widget to push detection results into the manager. */
|
|
635
|
+
declare function useWireDetectionIntoManager(): void;
|
|
636
|
+
|
|
637
|
+
/** Map chain reference -> backend chain_key and return enriched balances */
|
|
638
|
+
declare function getBalances(chainRef: string | number, address: string): Promise<BalanceRow[]>;
|
|
480
639
|
declare function getBalancesByAddress(address: string): Promise<WalletAddressBalanceWrapper[]>;
|
|
481
640
|
|
|
482
|
-
declare function sendRouteTransaction(b: BuildRouteResult, fallbackChainId?: number): Promise
|
|
483
|
-
/** One-shot flow that mirrors your old runTopUp */
|
|
641
|
+
declare function sendRouteTransaction(b: BuildRouteResult, fallbackChainId?: number | string): Promise<string>;
|
|
484
642
|
declare function runTopUp(params: {
|
|
485
643
|
fromChain?: string;
|
|
486
644
|
toChain?: string;
|
|
@@ -554,6 +712,24 @@ interface UseTokensResult {
|
|
|
554
712
|
*/
|
|
555
713
|
declare function useTokens(chainId: number | null | undefined): UseTokensResult;
|
|
556
714
|
|
|
715
|
+
type AddressValidationResult = {
|
|
716
|
+
isValid: boolean;
|
|
717
|
+
error?: string;
|
|
718
|
+
};
|
|
719
|
+
declare function validateEvmAddress(address: string): AddressValidationResult;
|
|
720
|
+
declare function validateSeiAddress(address: string): AddressValidationResult;
|
|
721
|
+
declare function validateSolanaAddress(address: string): AddressValidationResult;
|
|
722
|
+
declare function validateBtcAddress(address: string): AddressValidationResult;
|
|
723
|
+
declare function validateAddressForChain(address: string, chain?: ChainDef | ChainType | string | null): AddressValidationResult;
|
|
724
|
+
declare function validateRouteAddresses(params: {
|
|
725
|
+
fromChain?: ChainDef | ChainType | string | null;
|
|
726
|
+
toChain?: ChainDef | ChainType | string | null;
|
|
727
|
+
fromAddress: string;
|
|
728
|
+
toAddress: string;
|
|
729
|
+
refundAddress?: string;
|
|
730
|
+
direction?: string;
|
|
731
|
+
}): AddressValidationResult;
|
|
732
|
+
|
|
557
733
|
declare const Trustware: {
|
|
558
734
|
/** Initialize config */
|
|
559
735
|
init(cfg: TrustwareConfigOptions): Promise</*elided*/ any>;
|
|
@@ -566,9 +742,13 @@ declare const Trustware: {
|
|
|
566
742
|
setDestinationAddress(address?: string | null): /*elided*/ any;
|
|
567
743
|
/** Read active wallet */
|
|
568
744
|
getWallet(): WalletInterFaceAPI | null;
|
|
745
|
+
getIdentity(): WalletIdentity;
|
|
746
|
+
resolveAddressForChain(chain: Parameters<typeof walletManager.resolveAddressForChain>[0]): WalletAddressResolution;
|
|
747
|
+
addIdentityAddress(address: Parameters<typeof walletManager.addIdentityAddress>[0]): /*elided*/ any;
|
|
569
748
|
/** Simple helpers */
|
|
570
749
|
getAddress(): Promise<string>;
|
|
571
750
|
buildRoute: typeof buildRoute;
|
|
751
|
+
buildDepositAddress: typeof buildDepositAddress;
|
|
572
752
|
submitReceipt: typeof submitReceipt;
|
|
573
753
|
getStatus: typeof getStatus;
|
|
574
754
|
pollStatus: typeof pollStatus;
|
|
@@ -576,6 +756,8 @@ declare const Trustware: {
|
|
|
576
756
|
getBalancesByAddress: typeof getBalancesByAddress;
|
|
577
757
|
useChains: typeof useChains;
|
|
578
758
|
useTokens: typeof useTokens;
|
|
759
|
+
validateAddressForChain: typeof validateAddressForChain;
|
|
760
|
+
validateRouteAddresses: typeof validateRouteAddresses;
|
|
579
761
|
sendRouteTransaction: typeof sendRouteTransaction;
|
|
580
762
|
runTopUp: typeof runTopUp;
|
|
581
763
|
};
|
|
@@ -587,23 +769,6 @@ declare class RateLimitError extends Error {
|
|
|
587
769
|
constructor(info: RateLimitInfo, retriesExhausted: boolean);
|
|
588
770
|
}
|
|
589
771
|
|
|
590
|
-
type WagmiConnector = {
|
|
591
|
-
/** Human label like "MetaMask", "WalletConnect" */
|
|
592
|
-
name: string;
|
|
593
|
-
/** Free-form type hint: "injected" | "walletConnect" | ... */
|
|
594
|
-
type?: string;
|
|
595
|
-
};
|
|
596
|
-
type WagmiBridge = {
|
|
597
|
-
/** Host app believes it’s connected (Wagmi state) */
|
|
598
|
-
isConnected(): boolean;
|
|
599
|
-
/** List of available connectors */
|
|
600
|
-
connectors(): WagmiConnector[];
|
|
601
|
-
/** Try connecting via a specific connector */
|
|
602
|
-
connect(connector: WagmiConnector): Promise<void>;
|
|
603
|
-
/** Disconnect current session */
|
|
604
|
-
disconnect(): Promise<void>;
|
|
605
|
-
};
|
|
606
|
-
|
|
607
772
|
/** Try wagmi bridge first (if provided), otherwise return EIP-1193 adapter. */
|
|
608
773
|
declare function connectDetectedWallet(dw: DetectedWallet, opts?: {
|
|
609
774
|
wagmi?: WagmiBridge;
|
|
@@ -613,9 +778,6 @@ declare function connectDetectedWallet(dw: DetectedWallet, opts?: {
|
|
|
613
778
|
api: WalletInterFaceAPI | null;
|
|
614
779
|
}>;
|
|
615
780
|
|
|
616
|
-
/** If you’re in React, call this once near your widget to push detection results into the manager. */
|
|
617
|
-
declare function useWireDetectionIntoManager(): void;
|
|
618
|
-
|
|
619
781
|
declare function useEIP1193(eth: EIP1193): WalletInterFaceAPI;
|
|
620
782
|
declare function useWagmi(client: any): WalletInterFaceAPI;
|
|
621
783
|
|
|
@@ -707,4 +869,4 @@ declare function TrustwareProvider({ config, wallet, autoDetect, children, }: {
|
|
|
707
869
|
}): react_jsx_runtime.JSX.Element;
|
|
708
870
|
declare function useTrustware(): Ctx;
|
|
709
871
|
|
|
710
|
-
export { type BalanceRow, type BuildRouteResult, type ChainDef, type ChainMeta, type ChainType, DEFAULT_AUTO_DETECT_PROVIDER, DEFAULT_MESSAGES, DEFAULT_RETRY_CONFIG, DEFAULT_SLIPPAGE, DEFAULT_THEME, type DetectedWallet, type EIP1193, type EIP6963ProviderDetail, type NativeCurrency, RateLimitError, type RateLimitInfo, type ResolvedRetryConfig, type ResolvedTrustwareConfig, type ResolvedWalletConnectConfig, type RetryConfig, type RouteEstimate, type RouteIntent, type RouteParams, type RoutePlan, type SimpleWalletInterface, type TokenDef, type TokenMeta, type TokenType, type TokenWithBalance, type Transaction, Trustware, type TrustwareConfigOptions, type TrustwareCore, TrustwareError, TrustwareProvider, TrustwareWidgetV2 as TrustwareWidget, type TrustwareWidgetMessages, type TrustwareWidgetTheme, type WagmiBridge, type WagmiConnector, type WalletAddressBalanceWrapper, type WalletCategory, type WalletConnectConfig, type WalletId, type WalletInterFaceAPI, type WalletMeta, connectDetectedWallet, toWalletInterfaceFromDetected, useEIP1193, useTrustware, useWagmi, useWalletDetection, useWireDetectionIntoManager };
|
|
872
|
+
export { type BalanceRow, type BuildRouteResult, type ChainDef, type ChainMeta, type ChainType, DEFAULT_AUTO_DETECT_PROVIDER, DEFAULT_MESSAGES, DEFAULT_RETRY_CONFIG, DEFAULT_SLIPPAGE, DEFAULT_THEME, type DetectedWallet, type EIP1193, type EIP6963ProviderDetail, type EvmWalletInterface, IdentityStore, type NativeCurrency, RateLimitError, type RateLimitInfo, type ResolvedRetryConfig, type ResolvedTrustwareConfig, type ResolvedWalletConnectConfig, type RetryConfig, type RouteEstimate, type RouteIntent, type RouteParams, type RoutePlan, type SimpleWalletInterface, type SolanaProviderLike, type SolanaWalletInterface, type TokenDef, type TokenMeta, type TokenType, type TokenWithBalance, type Transaction, Trustware, type TrustwareConfigOptions, type TrustwareCore, TrustwareError, TrustwareProvider, TrustwareWidgetV2 as TrustwareWidget, type TrustwareWidgetMessages, type TrustwareWidgetTheme, type WagmiBridge, type WagmiConnector, type WalletAddressBalanceWrapper, type WalletAddressResolution, type WalletAddressSource, type WalletCategory, type WalletConnectConfig, type WalletEcosystem, type WalletId, type WalletIdentity, type WalletIdentityAddress, type WalletIdentityChainLike, type WalletInterFaceAPI, type WalletMeta, buildWalletIdentityAddress, connectDetectedWallet, createWalletIdentity, resolveWalletAddressForChain, toWalletInterfaceFromDetected, upsertWalletIdentityAddress, useEIP1193, useTrustware, useWagmi, useWalletDetection, useWireDetectionIntoManager, validateAddressForChain, validateBtcAddress, validateEvmAddress, validateRouteAddresses, validateSeiAddress, validateSolanaAddress };
|