@rango-dev/provider-walletconnect-2 0.8.1-next.2 → 0.8.1-next.3

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,7 +1,7 @@
1
- import { SignClient } from '@walletconnect/sign-client/dist/types/client';
2
- import { SessionTypes } from '@walletconnect/types';
3
- import type { GenericSigner } from 'rango-types';
4
- import { EvmTransaction } from 'rango-types/lib/api/main';
1
+ import type { SignClient } from '@walletconnect/sign-client/dist/types/client';
2
+ import type { SessionTypes } from '@walletconnect/types';
3
+ import type { EvmTransaction } from 'rango-types/lib/api/main';
4
+ import { type GenericSigner } from 'rango-types';
5
5
  declare class EVMSigner implements GenericSigner<EvmTransaction> {
6
6
  private client;
7
7
  private session;
@@ -1 +1 @@
1
- {"version":3,"file":"evm.d.ts","sourceRoot":"","sources":["../../src/signers/evm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,8CAA8C,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAM1D,cAAM,SAAU,YAAW,aAAa,CAAC,cAAc,CAAC;IACtD,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,OAAO,CAAsB;gBAEzB,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,CAAC,MAAM;IAK/C,WAAW,CACtB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GAAG,IAAI,GACrB,OAAO,CAAC,MAAM,CAAC;IA8BZ,aAAa,CACjB,EAAE,EAAE,cAAc,EAClB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GAAG,IAAI,GACrB,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAoB5B,OAAO,CAAC,iCAAiC;CAsD1C;AAED,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"evm.d.ts","sourceRoot":"","sources":["../../src/signers/evm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8CAA8C,CAAC;AAC/E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAK/D,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAMjD,cAAM,SAAU,YAAW,aAAa,CAAC,cAAc,CAAC;IACtD,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,OAAO,CAAsB;gBAEzB,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,CAAC,MAAM;IAK/C,WAAW,CACtB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GAAG,IAAI,GACrB,OAAO,CAAC,MAAM,CAAC;IAqCZ,aAAa,CACjB,EAAE,EAAE,cAAc,EAClB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GAAG,IAAI,GACrB,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAsB5B,OAAO,CAAC,iCAAiC;CAwD1C;AAED,eAAe,SAAS,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/provider-walletconnect-2",
3
- "version": "0.8.1-next.2",
3
+ "version": "0.8.1-next.3",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",
@@ -24,7 +24,7 @@
24
24
  "@keplr-wallet/cosmos": "^0.9.12",
25
25
  "@keplr-wallet/simple-fetch": "^0.12.14",
26
26
  "@rango-dev/signer-cosmos": "^0.15.0",
27
- "@rango-dev/signer-evm": "^0.15.0",
27
+ "@rango-dev/signer-evm": "^0.15.1-next.0",
28
28
  "@rango-dev/signer-solana": "^0.15.0",
29
29
  "@rango-dev/wallets-shared": "^0.15.1-next.1",
30
30
  "@solana/web3.js": "^1.67.2",
@@ -1,9 +1,12 @@
1
- import { SignClient } from '@walletconnect/sign-client/dist/types/client';
2
- import { SessionTypes } from '@walletconnect/types';
3
- import { AccountId, ChainId } from 'caip';
4
- import type { GenericSigner } from 'rango-types';
5
- import { EvmTransaction } from 'rango-types/lib/api/main';
1
+ import type { SignClient } from '@walletconnect/sign-client/dist/types/client';
2
+ import type { SessionTypes } from '@walletconnect/types';
3
+ import type { EvmTransaction } from 'rango-types/lib/api/main';
4
+
5
+ import { cleanEvmError } from '@rango-dev/signer-evm';
6
6
  import * as encoding from '@walletconnect/encoding';
7
+ import { AccountId, ChainId } from 'caip';
8
+ import { type GenericSigner } from 'rango-types';
9
+
7
10
  import { EthereumRPCMethods, NAMESPACES } from '../constants';
8
11
 
9
12
  const NAMESPACE_NAME = NAMESPACES.ETHEREUM;
@@ -35,18 +38,25 @@ class EVMSigner implements GenericSigner<EvmTransaction> {
35
38
 
36
39
  const params = [hexMsg, address];
37
40
 
38
- // Send message to wallet (using relayer)
39
- const signature: string = await this.client.request({
40
- topic: this.session.topic,
41
- chainId: caipChainId.toString(),
42
- request: {
43
- method: EthereumRPCMethods.PERSONAL_SIGN,
44
- params,
45
- },
46
- });
41
+ let signature: string;
42
+ try {
43
+ // Send message to wallet (using relayer)
44
+ signature = await this.client.request({
45
+ topic: this.session.topic,
46
+ chainId: caipChainId.toString(),
47
+ request: {
48
+ method: EthereumRPCMethods.PERSONAL_SIGN,
49
+ params,
50
+ },
51
+ });
52
+ } catch (error) {
53
+ throw cleanEvmError(error);
54
+ }
47
55
 
48
- // TODO: We can also verify the signature here
49
- // Check web-examples: dapps/react-dapp-v2/src/contexts/JsonRpcContext.tsx
56
+ /*
57
+ * TODO: We can also verify the signature here
58
+ * Check web-examples: dapps/react-dapp-v2/src/contexts/JsonRpcContext.tsx
59
+ */
50
60
 
51
61
  return signature;
52
62
  }
@@ -60,19 +70,21 @@ class EVMSigner implements GenericSigner<EvmTransaction> {
60
70
  address,
61
71
  chainId,
62
72
  });
63
-
64
- const signedTx: string = await this.client.request({
65
- topic: this.session.topic,
66
- chainId: requestedFor.caipChainId,
67
- request: {
68
- method: EthereumRPCMethods.SEND_TRANSACTION,
69
- params: [tx],
70
- },
71
- });
72
-
73
- return {
74
- hash: signedTx,
75
- };
73
+ try {
74
+ const hash: string = await this.client.request({
75
+ topic: this.session.topic,
76
+ chainId: requestedFor.caipChainId,
77
+ request: {
78
+ method: EthereumRPCMethods.SEND_TRANSACTION,
79
+ params: [tx],
80
+ },
81
+ });
82
+ return {
83
+ hash,
84
+ };
85
+ } catch (error) {
86
+ throw cleanEvmError(error);
87
+ }
76
88
  }
77
89
 
78
90
  private isNetworkAndAccountExistInSession(requestedFor: {
@@ -88,8 +100,10 @@ class EVMSigner implements GenericSigner<EvmTransaction> {
88
100
  );
89
101
  }
90
102
 
91
- // TODO: We need to make sure we are using a single format for chain ids, it should be hex or number.
92
- // This is a quick fix for evm.
103
+ /*
104
+ * TODO: We need to make sure we are using a single format for chain ids, it should be hex or number.
105
+ * This is a quick fix for evm.
106
+ */
93
107
  const chainIdNumber = chainId.startsWith('0x')
94
108
  ? String(parseInt(chainId))
95
109
  : chainId;