@rango-dev/provider-walletconnect-2 0.26.2 → 0.26.3-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.
@@ -0,0 +1 @@
1
+ {"inputs":{"src/constants.ts":{"bytes":2718,"imports":[{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true}],"format":"esm"},"src/session.ts":{"bytes":10497,"imports":[{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"@walletconnect/utils","kind":"import-statement","external":true},{"path":"caip","kind":"import-statement","external":true},{"path":"src/constants.ts","kind":"import-statement","original":"./constants"},{"path":"src/helpers.ts","kind":"import-statement","original":"./helpers"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/helpers.ts":{"bytes":6372,"imports":[{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"@walletconnect/modal","kind":"import-statement","external":true},{"path":"caip","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"src/constants.ts","kind":"import-statement","original":"./constants"},{"path":"src/session.ts","kind":"import-statement","original":"./session"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/signers/helper.ts":{"bytes":2088,"imports":[{"path":"@keplr-wallet/cosmos","kind":"import-statement","external":true},{"path":"@keplr-wallet/simple-fetch","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/signers/mock.ts":{"bytes":102937,"imports":[],"format":"esm"},"src/signers/cosmos.ts":{"bytes":7359,"imports":[{"path":"@cosmjs/launchpad","kind":"import-statement","external":true},{"path":"@keplr-wallet/cosmos","kind":"import-statement","external":true},{"path":"@rango-dev/signer-cosmos","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"caip","kind":"import-statement","external":true},{"path":"cosmos-wallet","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"src/constants.ts","kind":"import-statement","original":"../constants"},{"path":"src/signers/helper.ts","kind":"import-statement","original":"./helper"},{"path":"src/signers/mock.ts","kind":"import-statement","original":"./mock"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/signers/evm.ts":{"bytes":5135,"imports":[{"path":"@rango-dev/signer-evm","kind":"import-statement","external":true},{"path":"@walletconnect/encoding","kind":"import-statement","external":true},{"path":"caip","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"src/constants.ts","kind":"import-statement","original":"../constants"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/signers/solana.ts":{"bytes":4693,"imports":[{"path":"@rango-dev/signer-solana","kind":"import-statement","external":true},{"path":"@solana/web3.js","kind":"import-statement","external":true},{"path":"bs58","kind":"import-statement","external":true},{"path":"caip","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"src/constants.ts","kind":"import-statement","original":"../constants"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/signer.ts":{"bytes":861,"imports":[{"path":"rango-types","kind":"import-statement","external":true},{"path":"src/signers/cosmos.ts","kind":"import-statement","original":"./signers/cosmos"},{"path":"src/signers/evm.ts","kind":"import-statement","original":"./signers/evm"},{"path":"src/signers/solana.ts","kind":"import-statement","original":"./signers/solana"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":6645,"imports":[{"path":"@rango-dev/logging-core","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"@walletconnect/sign-client","kind":"import-statement","external":true},{"path":"caip","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"src/constants.ts","kind":"import-statement","original":"./constants"},{"path":"src/helpers.ts","kind":"import-statement","original":"./helpers"},{"path":"src/session.ts","kind":"import-statement","original":"./session"},{"path":"src/signer.ts","kind":"import-statement","original":"./signer"},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"dist/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":215687},"dist/index.js":{"imports":[{"path":"@rango-dev/logging-core","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"@walletconnect/sign-client","kind":"import-statement","external":true},{"path":"caip","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"@walletconnect/modal","kind":"import-statement","external":true},{"path":"caip","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"@walletconnect/utils","kind":"import-statement","external":true},{"path":"caip","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"@cosmjs/launchpad","kind":"import-statement","external":true},{"path":"@keplr-wallet/cosmos","kind":"import-statement","external":true},{"path":"@rango-dev/signer-cosmos","kind":"import-statement","external":true},{"path":"@rango-dev/wallets-shared","kind":"import-statement","external":true},{"path":"caip","kind":"import-statement","external":true},{"path":"cosmos-wallet","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"@keplr-wallet/cosmos","kind":"import-statement","external":true},{"path":"@keplr-wallet/simple-fetch","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true},{"path":"@rango-dev/signer-evm","kind":"import-statement","external":true},{"path":"@walletconnect/encoding","kind":"import-statement","external":true},{"path":"caip","kind":"import-statement","external":true},{"path":"@rango-dev/signer-solana","kind":"import-statement","external":true},{"path":"@solana/web3.js","kind":"import-statement","external":true},{"path":"bs58","kind":"import-statement","external":true},{"path":"caip","kind":"import-statement","external":true},{"path":"rango-types","kind":"import-statement","external":true}],"exports":["canSwitchNetworkTo","config","connect","disconnect","getInstance","getSigners","getWalletInfo","init","subscribe","switchNetwork"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":2485},"src/constants.ts":{"bytesInOutput":521},"src/helpers.ts":{"bytesInOutput":2191},"src/session.ts":{"bytesInOutput":3084},"src/signer.ts":{"bytesInOutput":367},"src/signers/cosmos.ts":{"bytesInOutput":3227},"src/signers/helper.ts":{"bytesInOutput":1056},"src/signers/mock.ts":{"bytesInOutput":68018},"src/signers/evm.ts":{"bytesInOutput":2114},"src/signers/solana.ts":{"bytesInOutput":1839}},"bytes":85197}}}
package/dist/session.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ConnectParams, CreateSessionParams } from './types';
1
+ import type { ConnectParams, CreateSessionParams, Environments } from './types';
2
2
  import type { SignClient } from '@walletconnect/sign-client/dist/types/client';
3
3
  import type { PairingTypes, SessionTypes, SignClientTypes } from '@walletconnect/types';
4
4
  import type { BlockchainMeta } from 'rango-types';
@@ -18,7 +18,9 @@ export declare function restoreSession(client: SignClient, pairingTopic: Pairing
18
18
  * @param options
19
19
  * @returns
20
20
  */
21
- export declare function createSession(client: SignClient, options: CreateSessionParams): Promise<SessionTypes.Struct>;
21
+ export declare function createSession(client: SignClient, options: CreateSessionParams, configs: {
22
+ envs: Environments;
23
+ }): Promise<SessionTypes.Struct>;
22
24
  /**
23
25
  *
24
26
  * A user (client) can have multiple pairings (to different wallets), we are assuming
@@ -1 +1 @@
1
- {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8CAA8C,CAAC;AAC/E,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,eAAe,EAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAelD,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,uBAEhD;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,C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AAoB,CAClC,KAAK,EAAE,eAAe,CAAC,aAAa,CAAC;IACnC,UAAU,EAAE,YAAY,CAAC,UAAU,CAAC;CACrC,CAAC;;;IAeH;AAMD,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,GAAG,EACb,gBAAgB,EAAE,MAAM,EACxB,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,cAAc,EAAE,iBA8CvB;AASD,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,GAAG,GAAG,OAAO,CAM7D;AAED,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,UAAU,EAClB,OAAO,CAAC,EAAE,MAAM,iBAKjB;AAMD,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,UAAU,+BAQ3D"}
package/dist/types.d.ts CHANGED
@@ -1,6 +1,10 @@
1
1
  import type { SignClient } from '@walletconnect/sign-client/dist/types/client';
2
2
  import type { ProposalTypes, SessionTypes } from '@walletconnect/types';
3
3
  import type { BlockchainMeta, CosmosBlockchainMeta } from 'rango-types/lib';
4
+ export interface Environments extends Record<string, string | undefined> {
5
+ WC_PROJECT_ID: string;
6
+ DISABLE_MODAL_AND_OPEN_LINK?: string;
7
+ }
4
8
  export interface WCInstance {
5
9
  client: SignClient;
6
10
  session: SessionTypes.Struct | null;
@@ -13,6 +17,7 @@ export interface CreateSessionParams {
13
17
  }
14
18
  export interface ConnectParams {
15
19
  meta: BlockchainMeta[];
20
+ envs: Environments;
16
21
  }
17
22
  export interface CosmosMeta extends CosmosBlockchainMeta {
18
23
  chainId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8CAA8C,CAAC;AAC/E,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAE5E,M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C;IACtD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,cAAc,EAAE,CAAC;IACvB,IAAI,EAAE,YAAY,CAAC;CACpB;AAED,MAAM,WAAW,UAAW,SAAQ,oBAAoB;IAEtD,OAAO,EAAE,MAAM,CAAC;CACjB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/provider-walletconnect-2",
3
- "version": "0.26.2",
3
+ "version": "0.26.3-next.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
@@ -24,11 +24,11 @@
24
24
  "@cosmjs/launchpad": "^0.27.1",
25
25
  "@keplr-wallet/cosmos": "^0.9.12",
26
26
  "@keplr-wallet/simple-fetch": "^0.12.14",
27
- "@rango-dev/logging-core": "^0.3.0",
27
+ "@rango-dev/logging-core": "^0.3.1-next.1",
28
28
  "@rango-dev/signer-cosmos": "^0.26.0",
29
29
  "@rango-dev/signer-evm": "^0.27.1",
30
- "@rango-dev/signer-solana": "^0.28.0",
31
- "@rango-dev/wallets-shared": "^0.33.0",
30
+ "@rango-dev/signer-solana": "^0.28.1-next.2",
31
+ "@rango-dev/wallets-shared": "^0.33.1-next.1",
32
32
  "@solana/web3.js": "^1.91.4",
33
33
  "@walletconnect/encoding": "^1.0.2",
34
34
  "@walletconnect/modal": "^2.6.2",
@@ -45,4 +45,4 @@
45
45
  "publishConfig": {
46
46
  "access": "public"
47
47
  }
48
- }
48
+ }
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { WCInstance } from './types';
1
+ import type { Environments, WCInstance } from './types';
2
2
  import type {
3
3
  CanSwitchNetwork,
4
4
  Connect,
@@ -47,13 +47,13 @@ import signer from './signer';
47
47
 
48
48
  const WALLET = WalletTypes.WALLET_CONNECT_2;
49
49
 
50
- export interface Environments extends Record<string, string> {
51
- WC_PROJECT_ID: string;
52
- }
53
-
54
50
  let envs: Environments = {
55
51
  WC_PROJECT_ID: '',
52
+ DISABLE_MODAL_AND_OPEN_LINK: undefined,
56
53
  };
54
+
55
+ export type { Environments };
56
+
57
57
  export const init = (environments: Environments) => {
58
58
  envs = environments;
59
59
 
@@ -102,7 +102,7 @@ export const getInstance: GetInstance = async (options) => {
102
102
  export const connect: Connect = async ({ instance, meta }) => {
103
103
  const { client } = instance as WCInstance;
104
104
  // Try to restore the session first, if couldn't, create a new session by showing a modal.
105
- const session = await tryConnect(client, { meta });
105
+ const session = await tryConnect(client, { meta, envs });
106
106
  // Override the value (session).
107
107
  instance.session = session;
108
108
  const currentChainId = await getPersistedChainId(client);
package/src/session.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ConnectParams, CreateSessionParams } from './types';
1
+ import type { ConnectParams, CreateSessionParams, Environments } from './types';
2
2
  import type { SignClient } from '@walletconnect/sign-client/dist/types/client';
3
3
  import type {
4
4
  PairingTypes,
@@ -56,7 +56,10 @@ export async function restoreSession(
56
56
  */
57
57
  export async function createSession(
58
58
  client: SignClient,
59
- options: CreateSessionParams
59
+ options: CreateSessionParams,
60
+ configs: {
61
+ envs: Environments;
62
+ }
60
63
  ): Promise<SessionTypes.Struct> {
61
64
  const { requiredNamespaces, optionalNamespaces, pairingTopic } = options;
62
65
 
@@ -70,27 +73,37 @@ export async function createSession(
70
73
  // Open QRCode modal if a URI was returned (i.e. we're not connecting an existing pairing).
71
74
  let onCloseModal;
72
75
  if (uri) {
73
- // Create a flat array of all requested chains across namespaces.
74
- const allNamespaces = {
75
- ...(requiredNamespaces || {}),
76
- ...(optionalNamespaces || {}),
77
- };
78
-
79
- const standaloneChains = Object.values(allNamespaces)
80
- .map((namespace) => namespace.chains)
81
- .flat() as string[];
82
-
83
- const modal = getModal();
84
- void modal.openModal({ uri, standaloneChains });
85
-
86
- onCloseModal = new Promise((_, reject) => {
87
- modal.subscribeModal((state) => {
88
- // the modal was closed so reject the promise
89
- if (!state.open) {
90
- reject(new Error('Modal has been closed.'));
91
- }
76
+ /*
77
+ * There are some wallets have been listed in WC itself (https://docs.walletconnect.com/cloud/explorer-submission),
78
+ * Using `DISABLE_MODAL_AND_OPEN_LINK` option, we can directly open a specific desktop wallet.
79
+ */
80
+ const redirectLink = configs.envs.DISABLE_MODAL_AND_OPEN_LINK;
81
+ if (redirectLink) {
82
+ const url = `${redirectLink}/wc?uri=${encodeURIComponent(uri)}`;
83
+ window.open(url, '_blank', 'noreferrer noopener');
84
+ } else {
85
+ // Create a flat array of all requested chains across namespaces.
86
+ const allNamespaces = {
87
+ ...(requiredNamespaces || {}),
88
+ ...(optionalNamespaces || {}),
89
+ };
90
+
91
+ const standaloneChains = Object.values(allNamespaces)
92
+ .map((namespace) => namespace.chains)
93
+ .flat() as string[];
94
+
95
+ const modal = getModal();
96
+ void modal.openModal({ uri, standaloneChains });
97
+
98
+ onCloseModal = new Promise((_, reject) => {
99
+ modal.subscribeModal((state) => {
100
+ // the modal was closed so reject the promise
101
+ if (!state.open) {
102
+ reject(new Error('Modal has been closed.'));
103
+ }
104
+ });
92
105
  });
93
- });
106
+ }
94
107
  }
95
108
 
96
109
  const session = approval();
@@ -150,10 +163,16 @@ export async function tryConnect(
150
163
 
151
164
  // In case of connecting for the first time or session couldn't be restored, we will create a new session.
152
165
  if (!session) {
153
- session = await createSession(client, {
154
- requiredNamespaces: {},
155
- optionalNamespaces,
156
- });
166
+ session = await createSession(
167
+ client,
168
+ {
169
+ requiredNamespaces: {},
170
+ optionalNamespaces,
171
+ },
172
+ {
173
+ envs: params.envs,
174
+ }
175
+ );
157
176
  }
158
177
 
159
178
  return session;
package/src/types.ts CHANGED
@@ -2,6 +2,11 @@ import type { SignClient } from '@walletconnect/sign-client/dist/types/client';
2
2
  import type { ProposalTypes, SessionTypes } from '@walletconnect/types';
3
3
  import type { BlockchainMeta, CosmosBlockchainMeta } from 'rango-types/lib';
4
4
 
5
+ export interface Environments extends Record<string, string | undefined> {
6
+ WC_PROJECT_ID: string;
7
+ // This is useful for directly opening a listed WC wallet. you will need to pass a url.
8
+ DISABLE_MODAL_AND_OPEN_LINK?: string;
9
+ }
5
10
  export interface WCInstance {
6
11
  client: SignClient;
7
12
  session: SessionTypes.Struct | null;
@@ -16,6 +21,7 @@ export interface CreateSessionParams {
16
21
 
17
22
  export interface ConnectParams {
18
23
  meta: BlockchainMeta[];
24
+ envs: Environments;
19
25
  }
20
26
 
21
27
  export interface CosmosMeta extends CosmosBlockchainMeta {