@rango-dev/provider-walletconnect-2 0.54.0 → 0.54.1-next.1

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.
@@ -1,2 +1,2 @@
1
- import"./chunk-RPL2NMJC.js";import{a as l}from"./chunk-DXVBX5XQ.js";import{generalSolanaTransactionExecutor as h}from"@rango-dev/signer-solana";import{PublicKey as u}from"@solana/web3.js";import g from"bs58";import{AccountId as f,ChainId as S}from"caip";import{SignerError as w,SignerErrorCode as y}from"rango-types";var c="solana",p=class{static{l(this,"SOLANASigner")}client;session;constructor(s,e){this.client=s,this.session=e}async signMessage(s,e,o){let n=this.isNetworkAndAccountExistInSession({address:e,chainId:o}),a=new S({namespace:c,reference:n.chainId});try{let t=g.encode(new TextEncoder().encode(s)),i=new u(e),{signature:r}=await this.client.request({topic:this.session.topic,chainId:a.toString(),request:{method:"solana_signMessage",params:{message:t,pubkey:i}}});return r}catch(t){throw new w(y.SIGN_TX_ERROR,void 0,t)}}async signAndSendTx(s,e,o){let n=this.isNetworkAndAccountExistInSession({address:e,chainId:o});return{hash:await h(s,l(async i=>{let r=await this.client.request({topic:this.session.topic,chainId:n.caipChainId,request:{method:"solana_signTransaction",params:i}}),d=new u(s.from),m=g.decode(r.signature);return i.addSignature(d,Buffer.from(m)),i.serialize()},"DefaultSolanaSigner"))}}isNetworkAndAccountExistInSession(s){let{address:e,chainId:o}=s,n=o;if(this.session.namespaces[c]?.accounts.map(r=>{let d=r.split(":");d[2]===e&&(n=d[1])}),!n)throw new Error("You need to set your chain for signing message/transaction.");let a=new f({chainId:{namespace:c,reference:n},address:e}),t=this.session.namespaces[c]?.accounts.map(r=>r);if(!t||!t.includes(a.toString()))throw console.warn("Available adresses and requested address:",t,a.toString()),new Error("Your requested address doesn't exist on your wallect connect session. Please reconnect your wallet.");let i=new S({namespace:c,reference:n});return{chainId:n,address:e,caipChainId:i.toString()}}},P=p;export{P as default};
2
- //# sourceMappingURL=solana-35I33VLX.js.map
1
+ import"./chunk-6V3WUFOU.js";import{a as l}from"./chunk-DXVBX5XQ.js";import{generalSolanaTransactionExecutor as h}from"@rango-dev/signer-solana";import{PublicKey as u}from"@solana/web3.js";import g from"bs58";import{AccountId as f,ChainId as S}from"caip";import{SignerError as w,SignerErrorCode as y}from"rango-types";var c="solana",p=class{static{l(this,"SOLANASigner")}client;session;constructor(s,e){this.client=s,this.session=e}async signMessage(s,e,o){let n=this.isNetworkAndAccountExistInSession({address:e,chainId:o}),a=new S({namespace:c,reference:n.chainId});try{let t=g.encode(new TextEncoder().encode(s)),i=new u(e),{signature:r}=await this.client.request({topic:this.session.topic,chainId:a.toString(),request:{method:"solana_signMessage",params:{message:t,pubkey:i}}});return r}catch(t){throw new w(y.SIGN_TX_ERROR,void 0,t)}}async signAndSendTx(s,e,o){let n=this.isNetworkAndAccountExistInSession({address:e,chainId:o});return{hash:await h(s,l(async i=>{let r=await this.client.request({topic:this.session.topic,chainId:n.caipChainId,request:{method:"solana_signTransaction",params:i}}),d=new u(s.from),m=g.decode(r.signature);return i.addSignature(d,Buffer.from(m)),i.serialize()},"DefaultSolanaSigner"))}}isNetworkAndAccountExistInSession(s){let{address:e,chainId:o}=s,n=o;if(this.session.namespaces[c]?.accounts.map(r=>{let d=r.split(":");d[2]===e&&(n=d[1])}),!n)throw new Error("You need to set your chain for signing message/transaction.");let a=new f({chainId:{namespace:c,reference:n},address:e}),t=this.session.namespaces[c]?.accounts.map(r=>r);if(!t||!t.includes(a.toString()))throw console.warn("Available adresses and requested address:",t,a.toString()),new Error("Your requested address doesn't exist on your wallect connect session. Please reconnect your wallet.");let i=new S({namespace:c,reference:n});return{chainId:n,address:e,caipChainId:i.toString()}}},P=p;export{P as default};
2
+ //# sourceMappingURL=solana-MFA7C5XI.js.map
package/dist/types.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { SignClient } from '@walletconnect/sign-client/dist/types/client';
2
2
  import type { ProposalTypes, SessionTypes } from '@walletconnect/types';
3
- import type { BlockchainMeta, CosmosBlockchainMeta } from 'rango-types';
3
+ import type { BlockchainMeta } from 'rango-types';
4
4
  export interface Environments extends Record<string, string | undefined> {
5
5
  WC_PROJECT_ID: string;
6
6
  DISABLE_MODAL_AND_OPEN_LINK?: string;
@@ -19,6 +19,3 @@ export interface ConnectParams {
19
19
  meta: BlockchainMeta[];
20
20
  envs: Environments;
21
21
  }
22
- export interface CosmosMeta extends CosmosBlockchainMeta {
23
- chainId: string;
24
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/provider-walletconnect-2",
3
- "version": "0.54.0",
3
+ "version": "0.54.1-next.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
@@ -24,7 +24,7 @@
24
24
  "@rango-dev/logging-core": "^0.12.1",
25
25
  "@rango-dev/signer-evm": "^0.42.0",
26
26
  "@rango-dev/signer-solana": "^0.48.0",
27
- "@rango-dev/wallets-shared": "^0.60.0",
27
+ "@rango-dev/wallets-shared": "^0.60.1-next.1",
28
28
  "@solana/web3.js": "^1.91.4",
29
29
  "@walletconnect/encoding": "^1.0.2",
30
30
  "@walletconnect/sign-client": "^2.11.2",
package/src/constants.ts CHANGED
@@ -6,7 +6,6 @@ export const PING_TIMEOUT = 10_000;
6
6
  export enum NAMESPACES {
7
7
  ETHEREUM = 'eip155',
8
8
  SOLANA = 'solana',
9
- COSMOS = 'cosmos',
10
9
  POLKADOT = 'polkadot',
11
10
  CARDANO = 'cip34',
12
11
  ERLOND = 'elrond',
@@ -23,13 +22,6 @@ export enum SolanaRPCMethods {
23
22
  SIGN_MESSAGE = 'solana_signMessage',
24
23
  }
25
24
 
26
- // Refrence: https://docs.walletconnect.com/2.0/advanced/rpc-reference/cosmos-rpc
27
- export enum CosmosRPCMethods {
28
- GET_ACCOUNTS = 'cosmos_getAccounts',
29
- SIGN_DIRECT = 'cosmos_signDirect',
30
- SIGN_AMINO = 'cosmos_signAmino',
31
- }
32
-
33
25
  // Refrence: https://docs.walletconnect.com/2.0/advanced/rpc-reference/ethereum-rpc
34
26
  export enum EthereumRPCMethods {
35
27
  PERSONAL_SIGN = 'personal_sign',
@@ -72,12 +64,6 @@ export const DEFAULT_SOLANA_METHODS = [
72
64
  SolanaRPCMethods.SIGN_MESSAGE,
73
65
  ];
74
66
 
75
- export const DEFAULT_COSMOS_METHODS = [
76
- CosmosRPCMethods.GET_ACCOUNTS,
77
- CosmosRPCMethods.SIGN_AMINO,
78
- CosmosRPCMethods.SIGN_DIRECT,
79
- ];
80
-
81
67
  // refrence: https://github.com/ChainAgnostic/namespaces/blob/main/solana/caip2.md
82
68
  export const DEFAULT_SOLANA_CHAIN_ID = '4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ';
83
69
 
package/src/helpers.ts CHANGED
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
1
2
  import type { WalletConnectModal as WalletConnectModalType } from './wc-types.js';
2
3
  import type { WalletState } from '@rango-dev/wallets-shared';
3
4
  import type { ProposalTypes } from '@walletconnect/types';
@@ -42,11 +43,6 @@ type FinalNamespaces = {
42
43
  [key in NAMESPACES]?: ProposalTypes.BaseRequiredNamespace;
43
44
  };
44
45
 
45
- /*
46
- * Some wallets like 1inch (android) has problem when we pass cosmos chains in optional namespace
47
- * Also some wallets like keplr mobile doesn't work when we don't pass cosmos chains in required namespace
48
- * It seems to be a bug in their current implementation.
49
- */
50
46
  export function generateOptionalNamespace(
51
47
  meta: BlockchainMeta[]
52
48
  ): FinalNamespaces | undefined {
package/src/index.ts CHANGED
@@ -94,6 +94,7 @@ export const getInstance: GetInstance = async (options) => {
94
94
  return {
95
95
  client: provider,
96
96
  session: null,
97
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
97
98
  request: async (params: any) =>
98
99
  simulateRequest(params, provider, meta, getState),
99
100
  };
package/src/session.ts CHANGED
@@ -160,7 +160,7 @@ export async function tryConnect(
160
160
  if (pairing) {
161
161
  try {
162
162
  session = await restoreSession(client, pairing.topic);
163
- } catch (e) {
163
+ } catch {
164
164
  await disconnectSessions(client);
165
165
  }
166
166
  }
@@ -284,6 +284,7 @@ export function getAccountsFromEvent(
284
284
  * to contain both current chain and target chain accoutns.
285
285
  */
286
286
  export async function updateSessionAccounts(
287
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
287
288
  instance: any,
288
289
  requestedNetwork: string,
289
290
  currentNetwork: string,
@@ -342,6 +343,7 @@ export async function updateSessionAccounts(
342
343
  * For the time being, we should avoid their session namespace response.
343
344
  * see also: https://github.com/trustwallet/wallet-core/issues/3588
344
345
  */
346
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
345
347
  export function ignoreNamespaceMethods(instance: any): boolean {
346
348
  const WALLETS_WITH_WRONG_NAMESPACE_METHODS = ['trust', '1inch'];
347
349
  const peerName = instance?.session?.peer?.metadata?.name;
@@ -89,6 +89,7 @@ class EVMSigner implements GenericSigner<EvmTransaction> {
89
89
  return {
90
90
  hash,
91
91
  };
92
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
92
93
  } catch (error: any) {
93
94
  const modifiedError = cleanEvmError(error);
94
95
  const session = this.session;
package/src/types.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { SignClient } from '@walletconnect/sign-client/dist/types/client';
2
2
  import type { ProposalTypes, SessionTypes } from '@walletconnect/types';
3
- import type { BlockchainMeta, CosmosBlockchainMeta } from 'rango-types';
3
+ import type { BlockchainMeta } from 'rango-types';
4
4
 
5
5
  export interface Environments extends Record<string, string | undefined> {
6
6
  WC_PROJECT_ID: string;
@@ -10,6 +10,7 @@ export interface Environments extends Record<string, string | undefined> {
10
10
  export interface WCInstance {
11
11
  client: SignClient;
12
12
  session: SessionTypes.Struct | null;
13
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
14
  request: (params: any) => Promise<string>;
14
15
  }
15
16
 
@@ -23,8 +24,3 @@ export interface ConnectParams {
23
24
  meta: BlockchainMeta[];
24
25
  envs: Environments;
25
26
  }
26
-
27
- export interface CosmosMeta extends CosmosBlockchainMeta {
28
- // forcing the chainId to be `string` only.
29
- chainId: string;
30
- }
@@ -1,2 +0,0 @@
1
- import{Networks as _}from"@rango-dev/wallets-shared";var T=_.ETHEREUM,A=1e4;var N="wc@2:client//namespaces";var e=["chainChanged","accountsChanged"],o=["personal_sign","eth_sendTransaction","eth_signTransaction","wallet_switchEthereumChain","wallet_addEthereumChain","eth_chainId"];var t="4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ",s={name:"Rango Exchange",description:"The Ultimate Cross-Chain Solution",url:"https://app.rango.exchange/",icons:["https://app.rango.exchange/logo-rounded.png"]},a="wss://relay.walletconnect.com";export{T as a,A as b,N as c,e as d,o as e,t as f,s as g,a as h};
2
- //# sourceMappingURL=chunk-RPL2NMJC.js.map
@@ -1,2 +0,0 @@
1
- import type { BlockchainMeta } from 'rango-types';
2
- export declare const supportedChains: BlockchainMeta[];