@trustwallet/connect-walletconnect 0.0.0

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.
Files changed (94) hide show
  1. package/LICENSE.md +76 -0
  2. package/dist/constants.d.ts +30 -0
  3. package/dist/constants.d.ts.map +1 -0
  4. package/dist/constants.js +30 -0
  5. package/dist/constants.js.map +1 -0
  6. package/dist/errors/index.d.ts +34 -0
  7. package/dist/errors/index.d.ts.map +1 -0
  8. package/dist/errors/index.js +55 -0
  9. package/dist/errors/index.js.map +1 -0
  10. package/dist/explorer-api/index.d.ts +83 -0
  11. package/dist/explorer-api/index.d.ts.map +1 -0
  12. package/dist/explorer-api/index.js +118 -0
  13. package/dist/explorer-api/index.js.map +1 -0
  14. package/dist/index.d.ts +7 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +7 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/react/hooks/index.d.ts +3 -0
  19. package/dist/react/hooks/index.d.ts.map +1 -0
  20. package/dist/react/hooks/index.js +3 -0
  21. package/dist/react/hooks/index.js.map +1 -0
  22. package/dist/react/hooks/useWalletConnect.d.ts +16 -0
  23. package/dist/react/hooks/useWalletConnect.d.ts.map +1 -0
  24. package/dist/react/hooks/useWalletConnect.js +51 -0
  25. package/dist/react/hooks/useWalletConnect.js.map +1 -0
  26. package/dist/react/hooks/useWalletConnectExplorer.d.ts +18 -0
  27. package/dist/react/hooks/useWalletConnectExplorer.d.ts.map +1 -0
  28. package/dist/react/hooks/useWalletConnectExplorer.js +82 -0
  29. package/dist/react/hooks/useWalletConnectExplorer.js.map +1 -0
  30. package/dist/react/hooks/useWalletConnectService.d.ts +7 -0
  31. package/dist/react/hooks/useWalletConnectService.d.ts.map +1 -0
  32. package/dist/react/hooks/useWalletConnectService.js +15 -0
  33. package/dist/react/hooks/useWalletConnectService.js.map +1 -0
  34. package/dist/react/index.d.ts +3 -0
  35. package/dist/react/index.d.ts.map +1 -0
  36. package/dist/react/index.js +2 -0
  37. package/dist/react/index.js.map +1 -0
  38. package/dist/rpc-interceptors/bip122/index.d.ts +25 -0
  39. package/dist/rpc-interceptors/bip122/index.d.ts.map +1 -0
  40. package/dist/rpc-interceptors/bip122/index.js +124 -0
  41. package/dist/rpc-interceptors/bip122/index.js.map +1 -0
  42. package/dist/rpc-interceptors/eip155/index.d.ts +27 -0
  43. package/dist/rpc-interceptors/eip155/index.d.ts.map +1 -0
  44. package/dist/rpc-interceptors/eip155/index.js +55 -0
  45. package/dist/rpc-interceptors/eip155/index.js.map +1 -0
  46. package/dist/rpc-interceptors/solana/index.d.ts +29 -0
  47. package/dist/rpc-interceptors/solana/index.d.ts.map +1 -0
  48. package/dist/rpc-interceptors/solana/index.js +112 -0
  49. package/dist/rpc-interceptors/solana/index.js.map +1 -0
  50. package/dist/rpc-types/bip122.d.ts +54 -0
  51. package/dist/rpc-types/bip122.d.ts.map +1 -0
  52. package/dist/rpc-types/bip122.js +2 -0
  53. package/dist/rpc-types/bip122.js.map +1 -0
  54. package/dist/rpc-types/eip155.d.ts +64 -0
  55. package/dist/rpc-types/eip155.d.ts.map +1 -0
  56. package/dist/rpc-types/eip155.js +6 -0
  57. package/dist/rpc-types/eip155.js.map +1 -0
  58. package/dist/rpc-types/index.d.ts +4 -0
  59. package/dist/rpc-types/index.d.ts.map +1 -0
  60. package/dist/rpc-types/index.js +4 -0
  61. package/dist/rpc-types/index.js.map +1 -0
  62. package/dist/rpc-types/solana.d.ts +72 -0
  63. package/dist/rpc-types/solana.d.ts.map +1 -0
  64. package/dist/rpc-types/solana.js +6 -0
  65. package/dist/rpc-types/solana.js.map +1 -0
  66. package/dist/scope-interceptor/index.d.ts +3 -0
  67. package/dist/scope-interceptor/index.d.ts.map +1 -0
  68. package/dist/scope-interceptor/index.js +29 -0
  69. package/dist/scope-interceptor/index.js.map +1 -0
  70. package/dist/service/index.d.ts +14 -0
  71. package/dist/service/index.d.ts.map +1 -0
  72. package/dist/service/index.js +40 -0
  73. package/dist/service/index.js.map +1 -0
  74. package/dist/service/service.d.ts +34 -0
  75. package/dist/service/service.d.ts.map +1 -0
  76. package/dist/service/service.js +63 -0
  77. package/dist/service/service.js.map +1 -0
  78. package/dist/types.d.ts +18 -0
  79. package/dist/types.d.ts.map +1 -0
  80. package/dist/types.js +2 -0
  81. package/dist/types.js.map +1 -0
  82. package/dist/wallet/index.d.ts +49 -0
  83. package/dist/wallet/index.d.ts.map +1 -0
  84. package/dist/wallet/index.js +361 -0
  85. package/dist/wallet/index.js.map +1 -0
  86. package/dist/wallet/namespace-config.d.ts +31 -0
  87. package/dist/wallet/namespace-config.d.ts.map +1 -0
  88. package/dist/wallet/namespace-config.js +92 -0
  89. package/dist/wallet/namespace-config.js.map +1 -0
  90. package/dist/wallet/types.d.ts +22 -0
  91. package/dist/wallet/types.d.ts.map +1 -0
  92. package/dist/wallet/types.js +2 -0
  93. package/dist/wallet/types.js.map +1 -0
  94. package/package.json +58 -0
@@ -0,0 +1,82 @@
1
+ import { useState, useEffect, useCallback, useRef, useMemo } from 'react';
2
+ import { WalletConnectExplorer } from '../../explorer-api';
3
+ import { useWalletConnectService } from './useWalletConnectService';
4
+ import { getPlatform } from '@trustwallet/connect-utils';
5
+ import { WalletConnectServiceNotInitializedError } from '../../errors';
6
+ /**
7
+ * Hook to fetch and paginate WalletConnect explorer wallets
8
+ * @param query - Optional search query to filter wallets
9
+ * @returns Wallets data, loading states, and pagination controls
10
+ */
11
+ export function useWalletConnectExplorer({ query, entries } = { query: '', entries: 10 }) {
12
+ const service = useWalletConnectService();
13
+ if (!service)
14
+ throw new WalletConnectServiceNotInitializedError();
15
+ const explorer = useMemo(() => {
16
+ return new WalletConnectExplorer(service.projectId);
17
+ }, [service]);
18
+ const [wallets, setWallets] = useState([]);
19
+ const [isLoading, setIsLoading] = useState(false);
20
+ const [isLoadingMore, setIsLoadingMore] = useState(false);
21
+ const [error, setError] = useState(null);
22
+ const [hasMore, setHasMore] = useState(true);
23
+ const pageRef = useRef(1);
24
+ const platform = getPlatform();
25
+ const fetchWallets = useCallback(async (search, reset = false) => {
26
+ if (reset) {
27
+ pageRef.current = 1;
28
+ setWallets([]);
29
+ setHasMore(true);
30
+ }
31
+ if (reset) {
32
+ setIsLoading(true);
33
+ }
34
+ else {
35
+ setIsLoadingMore(true);
36
+ }
37
+ setError(null);
38
+ try {
39
+ const response = await explorer.fetchWallets({
40
+ page: pageRef.current,
41
+ entries: entries || 10,
42
+ search,
43
+ platforms: platform === 'desktop' ? undefined : [platform],
44
+ });
45
+ if (reset) {
46
+ setWallets(response.data);
47
+ }
48
+ else {
49
+ setWallets((prev) => [...prev, ...response.data]);
50
+ }
51
+ setHasMore(response.data.length === 10);
52
+ pageRef.current += 1;
53
+ }
54
+ catch (err) {
55
+ setError(err instanceof Error ? err : new Error('Failed to fetch wallets'));
56
+ }
57
+ finally {
58
+ setIsLoading(false);
59
+ setIsLoadingMore(false);
60
+ }
61
+ }, [explorer, platform]);
62
+ const loadMore = useCallback(() => {
63
+ if (!isLoadingMore && hasMore) {
64
+ fetchWallets(query, false);
65
+ }
66
+ }, [fetchWallets, query, isLoadingMore, hasMore]);
67
+ useEffect(() => {
68
+ const timer = setTimeout(() => {
69
+ fetchWallets(query, true);
70
+ }, 300);
71
+ return () => clearTimeout(timer);
72
+ }, [query, fetchWallets]);
73
+ return {
74
+ wallets,
75
+ isLoading,
76
+ isLoadingMore,
77
+ error,
78
+ hasMore,
79
+ loadMore,
80
+ };
81
+ }
82
+ //# sourceMappingURL=useWalletConnectExplorer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWalletConnectExplorer.js","sourceRoot":"","sources":["../../../src/react/hooks/useWalletConnectExplorer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AACzE,OAAO,EAAE,qBAAqB,EAAuB,MAAM,oBAAoB,CAAA;AAC/E,OAAO,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CAAC,GAAG,EAAE;QACjC,IAAI,CAAC,aAAa,IAAI,OAAO,EAAE,CAAC;YAC/B,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;QAC3B,CAAC;IACF,CAAC,EAAE,CAAC,YAAY,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC,CAAA;IAEjD,SAAS,CAAC,GAAG,EAAE;QACd,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YAC7B,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;QAC1B,CAAC,EAAE,GAAG,CAAC,CAAA;QAEP,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;IACjC,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC,CAAA;IAEzB,OAAO;QACN,OAAO;QACP,SAAS;QACT,aAAa;QACb,KAAK;QACL,OAAO;QACP,QAAQ;KACR,CAAA;AACF,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { WalletConnectService } from '../../service/service';
2
+ /**
3
+ * Internal hook to get the WalletConnect service instance
4
+ * @returns WalletConnectService instance or undefined if not configured
5
+ */
6
+ export declare function useWalletConnectService(): WalletConnectService | undefined;
7
+ //# sourceMappingURL=useWalletConnectService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWalletConnectService.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useWalletConnectService.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAGjE;;;GAGG;AACH,wBAAgB,uBAAuB,IAAI,oBAAoB,GAAG,SAAS,CAO1E"}
@@ -0,0 +1,15 @@
1
+ import { useMemo } from 'react';
2
+ import { useTrustConnectContext } from '@trustwallet/connect-headless';
3
+ import { WALLETCONNECT_WALLET } from '../../constants';
4
+ /**
5
+ * Internal hook to get the WalletConnect service instance
6
+ * @returns WalletConnectService instance or undefined if not configured
7
+ */
8
+ export function useWalletConnectService() {
9
+ const { client } = useTrustConnectContext();
10
+ return useMemo(() => {
11
+ const services = client.getServices();
12
+ return services.find((service) => service.id === WALLETCONNECT_WALLET.ID);
13
+ }, [client]);
14
+ }
15
+ //# sourceMappingURL=useWalletConnectService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWalletConnectService.js","sourceRoot":"","sources":["../../../src/react/hooks/useWalletConnectService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAA;AAEtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAEtD;;;GAGG;AACH,MAAM,UAAU,uBAAuB;IACtC,MAAM,EAAE,MAAM,EAAE,GAAG,sBAAsB,EAAE,CAAA;IAE3C,OAAO,OAAO,CAAC,GAAG,EAAE;QACnB,MAAM,QAAQ,GAAG,MAAM,CAAC,WAAW,EAAE,CAAA;QACrC,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,oBAAoB,CAAC,EAAE,CAAqC,CAAA;IAC9G,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAA;AACb,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { useWalletConnect, useWalletConnectExplorer, } from './hooks';
2
+ export type { ExplorerWallet } from '../explorer-api';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,gBAAgB,EAChB,wBAAwB,GACxB,MAAM,SAAS,CAAA;AAChB,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { useWalletConnect, useWalletConnectExplorer, } from './hooks';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,gBAAgB,EAChB,wBAAwB,GACxB,MAAM,SAAS,CAAA"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Bitcoin RPC Interceptor
3
+ * Converts Bitcoin namespace RPC calls to WalletConnect format
4
+ */
5
+ import type { SignClientInstance } from '../../types';
6
+ import type { SessionTypes } from '@walletconnect/types';
7
+ import type { Account } from '@trustwallet/connect-bip122-types';
8
+ export type BIP122InterceptorContext = {
9
+ client: SignClientInstance;
10
+ session: SessionTypes.Struct;
11
+ currentChainId: `bip122:${string}`;
12
+ currentAccount?: Account;
13
+ };
14
+ export type BIP122RequestArgs = {
15
+ request: {
16
+ method: string;
17
+ params?: unknown;
18
+ };
19
+ chainId: string;
20
+ };
21
+ /**
22
+ * Intercepts Bitcoin RPC requests and handles them locally or forwards to WalletConnect
23
+ */
24
+ export declare function interceptBIP122Requests<T = unknown>(context: BIP122InterceptorContext, args: BIP122RequestArgs): Promise<T>;
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/rpc-interceptors/bip122/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,KAAK,EACX,OAAO,EAOP,MAAM,mCAAmC,CAAA;AAK1C,MAAM,MAAM,wBAAwB,GAAG;IACtC,MAAM,EAAE,kBAAkB,CAAA;IAC1B,OAAO,EAAE,YAAY,CAAC,MAAM,CAAA;IAC5B,cAAc,EAAE,UAAU,MAAM,EAAE,CAAA;IAClC,cAAc,CAAC,EAAE,OAAO,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC/B,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,CAAA;IAC7C,OAAO,EAAE,MAAM,CAAA;CACf,CAAA;AAED;;GAEG;AACH,wBAAsB,uBAAuB,CAAC,CAAC,GAAG,OAAO,EACxD,OAAO,EAAE,wBAAwB,EACjC,IAAI,EAAE,iBAAiB,GACrB,OAAO,CAAC,CAAC,CAAC,CAsIZ"}
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Bitcoin RPC Interceptor
3
+ * Converts Bitcoin namespace RPC calls to WalletConnect format
4
+ */
5
+ import { bytesToBase64, base64ToBytes, bytesToHex, hexToBytes } from '@trustwallet/connect-utils/encoding';
6
+ import { AccountNotFoundError, UnsupportedMethodError } from '@trustwallet/connect-core';
7
+ /**
8
+ * Intercepts Bitcoin RPC requests and handles them locally or forwards to WalletConnect
9
+ */
10
+ export async function interceptBIP122Requests(context, args) {
11
+ const { client, session, currentChainId, currentAccount } = context;
12
+ const method = args.request.method;
13
+ const params = args.request.params;
14
+ switch (method) {
15
+ case 'getAccounts': {
16
+ if (!currentAccount) {
17
+ return [];
18
+ }
19
+ const result = [
20
+ {
21
+ address: currentAccount.address,
22
+ publicKey: currentAccount.publicKey,
23
+ addressType: currentAccount.addressType,
24
+ },
25
+ ];
26
+ return result;
27
+ }
28
+ case 'signMessage': {
29
+ if (!currentAccount) {
30
+ throw new AccountNotFoundError('', 'bip122');
31
+ }
32
+ const msgParams = params;
33
+ // Convert Uint8Array message to hex string for WalletConnect
34
+ const messageHex = bytesToHex(msgParams.message);
35
+ const wcRequest = {
36
+ method: 'signMessage',
37
+ params: {
38
+ address: msgParams.address,
39
+ message: messageHex,
40
+ protocol: msgParams.protocol,
41
+ },
42
+ };
43
+ const response = await client.request({
44
+ topic: session.topic,
45
+ chainId: currentChainId,
46
+ request: wcRequest,
47
+ });
48
+ // Convert hex signature and messageHash back to Uint8Array
49
+ const result = {
50
+ signature: hexToBytes(response.signature),
51
+ address: response.address,
52
+ messageHash: response.messageHash ? hexToBytes(response.messageHash) : undefined,
53
+ };
54
+ return result;
55
+ }
56
+ case 'signPsbt': {
57
+ if (!currentAccount) {
58
+ throw new AccountNotFoundError('', 'bip122');
59
+ }
60
+ const psbtParams = params;
61
+ // Convert Uint8Array PSBT to base64 for WalletConnect
62
+ const psbtBase64 = bytesToBase64(psbtParams.psbt);
63
+ // Convert Uint8Array publicKeys in signInputs to hex strings
64
+ const signInputs = psbtParams.signInputs?.map((input) => ({
65
+ index: input.index,
66
+ address: input.address,
67
+ publicKey: input.publicKey ? bytesToHex(input.publicKey) : undefined,
68
+ sighashType: input.sighashType,
69
+ }));
70
+ const wcRequest = {
71
+ method: 'signPsbt',
72
+ params: {
73
+ psbt: psbtBase64,
74
+ signInputs,
75
+ broadcast: psbtParams.finalize,
76
+ },
77
+ };
78
+ const response = await client.request({
79
+ topic: session.topic,
80
+ chainId: currentChainId,
81
+ request: wcRequest,
82
+ });
83
+ // Convert base64 PSBT back to Uint8Array
84
+ const psbtBytes = base64ToBytes(response.psbt);
85
+ let result;
86
+ if (psbtParams.finalize && response.txid) {
87
+ result = {
88
+ psbt: psbtBytes,
89
+ txid: response.txid,
90
+ finalized: true,
91
+ };
92
+ }
93
+ else {
94
+ result = {
95
+ psbt: psbtBytes,
96
+ finalized: false,
97
+ };
98
+ }
99
+ return result;
100
+ }
101
+ case 'sendTransfer': {
102
+ if (!currentAccount) {
103
+ throw new AccountNotFoundError('', 'bip122');
104
+ }
105
+ const transferParams = params;
106
+ const wcRequest = {
107
+ method: 'sendTransfer',
108
+ params: {
109
+ toAddress: transferParams.toAddress,
110
+ satoshis: transferParams.satoshis,
111
+ },
112
+ };
113
+ const response = await client.request({
114
+ topic: session.topic,
115
+ chainId: currentChainId,
116
+ request: wcRequest,
117
+ });
118
+ return response.txid;
119
+ }
120
+ default:
121
+ throw new UnsupportedMethodError(method, 'bip122');
122
+ }
123
+ }
124
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":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CAAA;YAEF,OAAO,QAAQ,CAAC,IAAS,CAAA;QAC1B,CAAC;QAED;YACC,MAAM,IAAI,sBAAsB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IACpD,CAAC;AACF,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * EIP155 RPC Interceptor
3
+ * Converts EIP155 namespace RPC calls to WalletConnect format
4
+ * Based on: https://docs.walletconnect.network/wallet-sdk/chain-support/evm
5
+ */
6
+ import type { SignClientInstance } from '../../types';
7
+ import type { SessionTypes } from '@walletconnect/types';
8
+ export type EIP155InterceptorContext = {
9
+ client: SignClientInstance;
10
+ session: SessionTypes.Struct;
11
+ currentChainId: `eip155:${number}`;
12
+ currentAddress?: `0x${string}`;
13
+ supportedChains: string[];
14
+ };
15
+ export type EIP155RequestArgs = {
16
+ request: {
17
+ method: string;
18
+ params?: unknown;
19
+ };
20
+ chainId: string;
21
+ };
22
+ /**
23
+ * Intercepts EIP155 RPC requests and handles them locally or forwards to WalletConnect
24
+ * This acts as an adapter between the namespace API and WalletConnect's RPC format
25
+ */
26
+ export declare function interceptEip155Requests<T = unknown>(context: EIP155InterceptorContext, args: EIP155RequestArgs): Promise<T>;
27
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/rpc-interceptors/eip155/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAIxD,MAAM,MAAM,wBAAwB,GAAG;IACtC,MAAM,EAAE,kBAAkB,CAAA;IAC1B,OAAO,EAAE,YAAY,CAAC,MAAM,CAAA;IAC5B,cAAc,EAAE,UAAU,MAAM,EAAE,CAAA;IAClC,cAAc,CAAC,EAAE,KAAK,MAAM,EAAE,CAAA;IAC9B,eAAe,EAAE,MAAM,EAAE,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC/B,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,CAAA;IAC7C,OAAO,EAAE,MAAM,CAAA;CACf,CAAA;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,CAAC,CAAC,GAAG,OAAO,EACxD,OAAO,EAAE,wBAAwB,EACjC,IAAI,EAAE,iBAAiB,GACrB,OAAO,CAAC,CAAC,CAAC,CAqDZ"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * EIP155 RPC Interceptor
3
+ * Converts EIP155 namespace RPC calls to WalletConnect format
4
+ * Based on: https://docs.walletconnect.network/wallet-sdk/chain-support/evm
5
+ */
6
+ import { InvalidChainRefError, AccountNotFoundError, ChainNotSupportedError } from '@trustwallet/connect-core';
7
+ /**
8
+ * Intercepts EIP155 RPC requests and handles them locally or forwards to WalletConnect
9
+ * This acts as an adapter between the namespace API and WalletConnect's RPC format
10
+ */
11
+ export async function interceptEip155Requests(context, args) {
12
+ const { client, session, currentChainId, currentAddress, supportedChains } = context;
13
+ const method = args.request.method;
14
+ const params = args.request.params;
15
+ switch (method) {
16
+ case 'wallet_switchEthereumChain': {
17
+ const chainIdParam = params[0].chainId;
18
+ const numRef = Number(chainIdParam);
19
+ if (!Number.isFinite(numRef)) {
20
+ throw new InvalidChainRefError(chainIdParam, 'eip155');
21
+ }
22
+ const targetChain = `eip155:${numRef}`;
23
+ if (!supportedChains.includes(targetChain)) {
24
+ throw new ChainNotSupportedError(chainIdParam, supportedChains);
25
+ }
26
+ return null;
27
+ }
28
+ case 'eth_accounts':
29
+ case 'eth_requestAccounts': {
30
+ const addresses = currentAddress ? [currentAddress] : [];
31
+ return addresses;
32
+ }
33
+ case 'eth_chainId': {
34
+ const chainReference = currentChainId.split(':')[1];
35
+ const chainIdHex = `0x${Number(chainReference).toString(16)}`;
36
+ return chainIdHex;
37
+ }
38
+ default: {
39
+ if (!currentAddress) {
40
+ throw new AccountNotFoundError('', 'eip155');
41
+ }
42
+ const wcRequest = {
43
+ method,
44
+ params,
45
+ };
46
+ const response = await client.request({
47
+ topic: session.topic,
48
+ chainId: currentChainId,
49
+ request: wcRequest,
50
+ });
51
+ return response;
52
+ }
53
+ }
54
+ }
55
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/rpc-interceptors/eip155/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;AAe9G;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC5C,OAAiC,EACjC,IAAuB;IAEvB,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,GAAG,OAAO,CAAA;IACpF,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAA;IAClC,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAA;IAElC,QAAQ,MAAM,EAAE,CAAC;QAChB,KAAK,4BAA4B,CAAC,CAAC,CAAC;YACnC,MAAM,YAAY,GAAI,MAAgC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAA;YACjE,MAAM,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC,CAAA;YAEnC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC9B,MAAM,IAAI,oBAAoB,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAA;YACvD,CAAC;YAED,MAAM,WAAW,GAAG,UAAU,MAAM,EAAE,CAAA;YACtC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;gBAC5C,MAAM,IAAI,sBAAsB,CAAC,YAAY,EAAE,eAAe,CAAC,CAAA;YAChE,CAAC;YAED,OAAO,IAAS,CAAA;QACjB,CAAC;QAED,KAAK,cAAc,CAAC;QACpB,KAAK,qBAAqB,CAAC,CAAC,CAAC;YAC5B,MAAM,SAAS,GAAgB,cAAc,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;YACrE,OAAO,SAAc,CAAA;QACtB,CAAC;QAED,KAAK,aAAa,CAAC,CAAC,CAAC;YACpB,MAAM,cAAc,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;YACnD,MAAM,UAAU,GAAG,KAAK,MAAM,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAe,CAAA;YAC1E,OAAO,UAAe,CAAA;QACvB,CAAC;QAED,OAAO,CAAC,CAAC,CAAC;YACT,IAAI,CAAC,cAAc,EAAE,CAAC;gBACrB,MAAM,IAAI,oBAAoB,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAA;YAC7C,CAAC;YAED,MAAM,SAAS,GAAG;gBACjB,MAAM;gBACN,MAAM;aACwB,CAAA;YAE/B,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAgD;gBACpF,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,OAAO,EAAE,cAAc;gBACvB,OAAO,EAAE,SAAS;aAClB,CAAC,CAAA;YAEF,OAAO,QAAa,CAAA;QACrB,CAAC;IACF,CAAC;AACF,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Solana RPC Interceptor
3
+ * Converts Solana namespace RPC calls to WalletConnect format
4
+ * Based on: https://docs.walletconnect.network/wallet-sdk/chain-support/solana
5
+ */
6
+ import type { SignClientInstance } from '../../types';
7
+ import type { SessionTypes } from '@walletconnect/types';
8
+ import type { Base58String } from '../../rpc-types';
9
+ export type SolanaInterceptorContext = {
10
+ client: SignClientInstance;
11
+ session: SessionTypes.Struct;
12
+ currentChainId: `solana:${string}`;
13
+ currentAccount?: {
14
+ pubkey: Base58String;
15
+ };
16
+ };
17
+ export type SolanaRequestArgs = {
18
+ request: {
19
+ method: string;
20
+ params?: unknown;
21
+ };
22
+ chainId: string;
23
+ };
24
+ /**
25
+ * Intercepts Solana RPC requests and handles them locally or forwards to WalletConnect
26
+ * This acts as an adapter between the namespace API (Wallet Standard format) and WalletConnect's RPC format
27
+ */
28
+ export declare function interceptSolanaRequests<T = unknown>(context: SolanaInterceptorContext, args: SolanaRequestArgs): Promise<T>;
29
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/rpc-interceptors/solana/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,KAAK,EAA2D,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAa5G,MAAM,MAAM,wBAAwB,GAAG;IACtC,MAAM,EAAE,kBAAkB,CAAA;IAC1B,OAAO,EAAE,YAAY,CAAC,MAAM,CAAA;IAC5B,cAAc,EAAE,UAAU,MAAM,EAAE,CAAA;IAClC,cAAc,CAAC,EAAE;QAChB,MAAM,EAAE,YAAY,CAAA;KACpB,CAAA;CACD,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC/B,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,CAAA;IAC7C,OAAO,EAAE,MAAM,CAAA;CACf,CAAA;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,CAAC,CAAC,GAAG,OAAO,EACxD,OAAO,EAAE,wBAAwB,EACjC,IAAI,EAAE,iBAAiB,GACrB,OAAO,CAAC,CAAC,CAAC,CAyHZ"}
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Solana RPC Interceptor
3
+ * Converts Solana namespace RPC calls to WalletConnect format
4
+ * Based on: https://docs.walletconnect.network/wallet-sdk/chain-support/solana
5
+ */
6
+ import { bytesToBase64, base64ToBytes, bytesToBase58, base58ToBytes } from '@trustwallet/connect-utils/encoding';
7
+ import { AccountNotFoundError, UnsupportedMethodError } from '@trustwallet/connect-core';
8
+ /**
9
+ * Intercepts Solana RPC requests and handles them locally or forwards to WalletConnect
10
+ * This acts as an adapter between the namespace API (Wallet Standard format) and WalletConnect's RPC format
11
+ */
12
+ export async function interceptSolanaRequests(context, args) {
13
+ const { client, session, currentChainId, currentAccount } = context;
14
+ const method = args.request.method;
15
+ const params = args.request.params;
16
+ if (!currentAccount) {
17
+ throw new AccountNotFoundError('', 'solana');
18
+ }
19
+ switch (method) {
20
+ case 'signMessage': {
21
+ const { message } = params;
22
+ const wcRequest = {
23
+ method: 'solana_signMessage',
24
+ params: {
25
+ message: bytesToBase58(message),
26
+ pubkey: currentAccount.pubkey,
27
+ },
28
+ };
29
+ const response = await client.request({
30
+ topic: session.topic,
31
+ chainId: currentChainId,
32
+ request: wcRequest,
33
+ });
34
+ return {
35
+ signature: base58ToBytes(response.signature),
36
+ signedMessage: message,
37
+ };
38
+ }
39
+ case 'signTransaction': {
40
+ const { transaction } = params;
41
+ const wcRequest = {
42
+ method: 'solana_signTransaction',
43
+ params: {
44
+ transaction: bytesToBase64(transaction),
45
+ },
46
+ };
47
+ const response = await client.request({
48
+ topic: session.topic,
49
+ chainId: currentChainId,
50
+ request: wcRequest,
51
+ });
52
+ const signedTransaction = response.transaction ? base64ToBytes(response.transaction) : transaction;
53
+ return {
54
+ signedTransaction,
55
+ };
56
+ }
57
+ case 'signAndSendTransaction': {
58
+ const { transaction, options } = params;
59
+ const wcRequest = {
60
+ method: 'solana_signAndSendTransaction',
61
+ params: {
62
+ transaction: bytesToBase64(transaction),
63
+ sendOptions: options
64
+ ? {
65
+ skipPreflight: options.skipPreflight,
66
+ preflightCommitment: options.preflightCommitment,
67
+ maxRetries: options.maxRetries,
68
+ }
69
+ : undefined,
70
+ },
71
+ };
72
+ const response = await client.request({
73
+ topic: session.topic,
74
+ chainId: currentChainId,
75
+ request: wcRequest,
76
+ });
77
+ return {
78
+ signature: base58ToBytes(response.signature),
79
+ };
80
+ }
81
+ case 'signAndSendAllTransactions': {
82
+ const { inputs } = params;
83
+ const results = await Promise.allSettled(inputs.map(async (input) => {
84
+ const wcRequest = {
85
+ method: 'solana_signAndSendTransaction',
86
+ params: {
87
+ transaction: bytesToBase64(input.transaction),
88
+ sendOptions: input.options
89
+ ? {
90
+ skipPreflight: input.options.skipPreflight,
91
+ preflightCommitment: input.options.preflightCommitment,
92
+ maxRetries: input.options.maxRetries,
93
+ }
94
+ : undefined,
95
+ },
96
+ };
97
+ const response = await client.request({
98
+ topic: session.topic,
99
+ chainId: currentChainId,
100
+ request: wcRequest,
101
+ });
102
+ return {
103
+ signature: base58ToBytes(response.signature),
104
+ };
105
+ }));
106
+ return results;
107
+ }
108
+ default:
109
+ throw new UnsupportedMethodError(method, 'solana');
110
+ }
111
+ }
112
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/rpc-interceptors/solana/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAcH,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAA;AAChH,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;AAgBxF;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC5C,OAAiC,EACjC,IAAuB;IAEvB,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,GAAG,OAAO,CAAA;IACnE,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAA;IAClC,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,M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C,UAAU;6BACpC;4BACF,CAAC,CAAC,SAAS;qBACZ;iBACD,CAAA;gBAED,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAgD;oBACpF,KAAK,EAAE,OAAO,CAAC,KAAK;oBACpB,OAAO,EAAE,cAAc;oBACvB,OAAO,EAAE,SAAS;iBAClB,CAAC,CAAA;gBAEF,OAAO;oBACN,SAAS,EAAE,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC;iBAC5C,CAAA;YACF,CAAC,CAAC,CACF,CAAA;YAED,OAAO,OAAY,CAAA;QACpB,CAAC;QAED;YACC,MAAM,IAAI,sBAAsB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IACpD,CAAC;AACF,CAAC"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * BIP122 RPC Types
3
+ */
4
+ export type WalletConnectBIP122Request = {
5
+ method: 'getAccounts';
6
+ } | {
7
+ method: 'signMessage';
8
+ params: {
9
+ address: string;
10
+ message: string;
11
+ protocol?: 'ecdsa' | 'bip322';
12
+ };
13
+ } | {
14
+ method: 'signPsbt';
15
+ params: {
16
+ psbt: string;
17
+ signInputs?: Array<{
18
+ index: number;
19
+ address?: string;
20
+ publicKey?: string;
21
+ sighashType?: number;
22
+ }>;
23
+ broadcast?: boolean;
24
+ };
25
+ } | {
26
+ method: 'sendTransfer';
27
+ params: {
28
+ toAddress: string;
29
+ satoshis: number;
30
+ };
31
+ };
32
+ export type WalletConnectBIP122Response<T extends WalletConnectBIP122Request = WalletConnectBIP122Request> = T extends {
33
+ method: 'getAccounts';
34
+ } ? Array<{
35
+ address: string;
36
+ publicKey?: string;
37
+ addressType?: string;
38
+ }> : T extends {
39
+ method: 'signMessage';
40
+ } ? {
41
+ signature: string;
42
+ messageHash?: string;
43
+ address: string;
44
+ } : T extends {
45
+ method: 'signPsbt';
46
+ } ? {
47
+ psbt: string;
48
+ txid?: string;
49
+ } : T extends {
50
+ method: 'sendTransfer';
51
+ } ? {
52
+ txid: string;
53
+ } : never;
54
+ //# sourceMappingURL=bip122.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bip122.d.ts","sourceRoot":"","sources":["../../src/rpc-types/bip122.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,0BAA0B,GACnC;IACA,MAAM,EAAE,aAAa,CAAA;CACpB,GACD;IACA,MAAM,EAAE,aAAa,CAAA;IACrB,MAAM,EAAE;QACP,OAAO,EAAE,MAAM,CAAA;QACf,OAAO,EAAE,MAAM,CAAA;QACf,QAAQ,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAA;KAC7B,CAAA;CACA,GACD;IACA,MAAM,EAAE,UAAU,CAAA;IAClB,MAAM,EAAE;QACP,IAAI,EAAE,MAAM,CAAA;QACZ,UAAU,CAAC,EAAE,KAAK,CAAC;YAClB,KAAK,EAAE,MAAM,CAAA;YACb,OAAO,CAAC,EAAE,MAAM,CAAA;YAChB,SAAS,CAAC,EAAE,MAAM,CAAA;YAClB,WAAW,CAAC,EAAE,MAAM,CAAA;SACpB,CAAC,CAAA;QACF,SAAS,CAAC,EAAE,OAAO,CAAA;KACnB,CAAA;CACA,GACD;IACA,MAAM,EAAE,cAAc,CAAA;IACtB,MAAM,EAAE;QACP,SAAS,EAAE,MAAM,CAAA;QACjB,QAAQ,EAAE,MAAM,CAAA;KAChB,CAAA;CACA,CAAA;AAEJ,MAAM,MAAM,2BAA2B,CAAC,CAAC,SAAS,0BAA0B,GAAG,0BAA0B,IAAI,CAAC,SAAS;IACtH,MAAM,EAAE,aAAa,CAAA;CACrB,GACE,KAAK,CAAC;IACN,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;CACpB,CAAC,GACD,CAAC,SAAS;IAAE,MAAM,EAAE,aAAa,CAAA;CAAE,GAClC;IACA,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,EAAE,MAAM,CAAA;CACf,GACA,CAAC,SAAS;IAAE,MAAM,EAAE,UAAU,CAAA;CAAE,GAC/B;IACA,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;CACb,GACA,CAAC,SAAS;IAAE,MAAM,EAAE,cAAc,CAAA;CAAE,GACnC;IACA,IAAI,EAAE,MAAM,CAAA;CACZ,GACA,KAAK,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=bip122.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bip122.js","sourceRoot":"","sources":["../../src/rpc-types/bip122.ts"],"names":[],"mappings":""}