@rango-dev/provider-walletconnect-2 0.8.1-next.2 → 0.8.1-next.4
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/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/signer.d.ts +2 -2
- package/dist/signer.d.ts.map +1 -1
- package/dist/signers/evm.d.ts +4 -4
- package/dist/signers/evm.d.ts.map +1 -1
- package/dist/signers/helper.d.ts +1 -1
- package/dist/signers/helper.d.ts.map +1 -1
- package/dist/signers/mock.d.ts +1 -1
- package/dist/signers/mock.d.ts.map +1 -1
- package/dist/signers/solana.d.ts +2 -2
- package/dist/signers/solana.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/index.ts +1 -1
- package/src/signer.ts +5 -7
- package/src/signers/evm.ts +45 -31
- package/src/signers/helper.ts +6 -2
- package/src/signers/mock.ts +1 -1
- package/src/signers/solana.ts +19 -14
package/dist/signer.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { WCInstance } from './types';
|
|
2
|
+
import type { SignerFactory } from 'rango-types';
|
|
3
3
|
export default function getSigners(instance: WCInstance): SignerFactory;
|
|
4
4
|
//# sourceMappingURL=signer.d.ts.map
|
package/dist/signer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAQjD,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,QAAQ,EAAE,UAAU,GAAG,aAAa,CAoBtE"}
|
package/dist/signers/evm.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { SignClient } from '@walletconnect/sign-client/dist/types/client';
|
|
2
|
-
import { SessionTypes } from '@walletconnect/types';
|
|
3
|
-
import type {
|
|
4
|
-
import {
|
|
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;
|
|
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/dist/signers/helper.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { BlockchainMeta } from 'rango-types';
|
|
1
|
+
import type { BlockchainMeta } from 'rango-types';
|
|
2
2
|
export declare function sendTx(chainId: string, tx: unknown, mode: 'async' | 'sync' | 'block', supportedChains: BlockchainMeta[]): Promise<Uint8Array>;
|
|
3
3
|
//# sourceMappingURL=helper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../src/signers/helper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../src/signers/helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAMlD,wBAAsB,MAAM,CAC1B,OAAO,EAAE,MAAM,EACf,EAAE,EAAE,OAAO,EACX,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,EAChC,eAAe,EAAE,cAAc,EAAE,GAChC,OAAO,CAAC,UAAU,CAAC,CAiErB"}
|
package/dist/signers/mock.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../src/signers/mock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../src/signers/mock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,eAAO,MAAM,eAAe,EAAE,cAAc,EAwlH3C,CAAC"}
|
package/dist/signers/solana.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SignClient } from '@walletconnect/sign-client/dist/types/client';
|
|
2
|
-
import { SessionTypes } from '@walletconnect/types';
|
|
1
|
+
import type { SignClient } from '@walletconnect/sign-client/dist/types/client';
|
|
2
|
+
import type { SessionTypes } from '@walletconnect/types';
|
|
3
3
|
import type { GenericSigner, SolanaTransaction } from 'rango-types';
|
|
4
4
|
declare class SOLANASigner implements GenericSigner<SolanaTransaction> {
|
|
5
5
|
private client;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"solana.d.ts","sourceRoot":"","sources":["../../src/signers/solana.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"solana.d.ts","sourceRoot":"","sources":["../../src/signers/solana.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8CAA8C,CAAC;AAC/E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAWpE,cAAM,YAAa,YAAW,aAAa,CAAC,iBAAiB,CAAC;IAC5D,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;IAkCZ,aAAa,CACjB,EAAE,EAAE,iBAAiB,EACrB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GAAG,IAAI,GACrB,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAgC5B,OAAO,CAAC,iCAAiC;CA2D1C;AAED,eAAe,YAAY,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.
|
|
3
|
+
"version": "0.8.1-next.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
"@cosmjs/launchpad": "^0.27.1",
|
|
24
24
|
"@keplr-wallet/cosmos": "^0.9.12",
|
|
25
25
|
"@keplr-wallet/simple-fetch": "^0.12.14",
|
|
26
|
-
"@rango-dev/signer-cosmos": "^0.15.0",
|
|
27
|
-
"@rango-dev/signer-evm": "^0.15.
|
|
28
|
-
"@rango-dev/signer-solana": "^0.15.0",
|
|
29
|
-
"@rango-dev/wallets-shared": "^0.15.1-next.
|
|
26
|
+
"@rango-dev/signer-cosmos": "^0.15.1-next.0",
|
|
27
|
+
"@rango-dev/signer-evm": "^0.15.1-next.1",
|
|
28
|
+
"@rango-dev/signer-solana": "^0.15.1-next.0",
|
|
29
|
+
"@rango-dev/wallets-shared": "^0.15.1-next.2",
|
|
30
30
|
"@solana/web3.js": "^1.67.2",
|
|
31
31
|
"@walletconnect/encoding": "^1.0.2",
|
|
32
32
|
"@walletconnect/modal": "^2.6.1",
|
package/src/index.ts
CHANGED
|
@@ -187,7 +187,7 @@ export const getWalletInfo: (allBlockChains: BlockchainMeta[]) => WalletInfo = (
|
|
|
187
187
|
const evms = evmBlockchains(allBlockChains);
|
|
188
188
|
return {
|
|
189
189
|
name: 'WalletConnect',
|
|
190
|
-
img: 'https://raw.githubusercontent.com/rango-exchange/
|
|
190
|
+
img: 'https://raw.githubusercontent.com/rango-exchange/assets/main/wallets/walletconnect/icon.svg',
|
|
191
191
|
installLink: '',
|
|
192
192
|
color: '#b2dbff',
|
|
193
193
|
supportedChains: evms,
|
package/src/signer.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from 'rango-types';
|
|
1
|
+
import type { WCInstance } from './types';
|
|
2
|
+
import type { SignerFactory } from 'rango-types';
|
|
3
|
+
|
|
4
|
+
import { DefaultSignerFactory, TransactionType as TxType } from 'rango-types';
|
|
6
5
|
|
|
7
|
-
import { WCInstance } from './types';
|
|
8
|
-
import EVMSigner from './signers/evm';
|
|
9
6
|
import COSMOSSigner from './signers/cosmos';
|
|
7
|
+
import EVMSigner from './signers/evm';
|
|
10
8
|
import SOLANASigner from './signers/solana';
|
|
11
9
|
|
|
12
10
|
export default function getSigners(instance: WCInstance): SignerFactory {
|
package/src/signers/evm.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { SignClient } from '@walletconnect/sign-client/dist/types/client';
|
|
2
|
-
import { SessionTypes } from '@walletconnect/types';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import {
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
49
|
-
|
|
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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
-
|
|
92
|
-
|
|
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;
|
package/src/signers/helper.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import type { BlockchainMeta } from 'rango-types';
|
|
2
|
+
|
|
1
3
|
import { TendermintTxTracer } from '@keplr-wallet/cosmos';
|
|
2
4
|
import { simpleFetch } from '@keplr-wallet/simple-fetch';
|
|
3
|
-
import {
|
|
5
|
+
import { cosmosBlockchains } from 'rango-types';
|
|
6
|
+
|
|
4
7
|
export async function sendTx(
|
|
5
8
|
chainId: string,
|
|
6
9
|
tx: unknown,
|
|
@@ -16,7 +19,7 @@ export async function sendTx(
|
|
|
16
19
|
console.log({ chainInfo, isProtoTx });
|
|
17
20
|
|
|
18
21
|
if (!chainInfo) {
|
|
19
|
-
throw 'Chain info is undefined from server';
|
|
22
|
+
throw new Error('Chain info is undefined from server');
|
|
20
23
|
}
|
|
21
24
|
const params = isProtoTx
|
|
22
25
|
? {
|
|
@@ -61,6 +64,7 @@ export async function sendTx(
|
|
|
61
64
|
const txHash = Buffer.from(txResponse.txhash, 'hex');
|
|
62
65
|
|
|
63
66
|
const txTracer = new TendermintTxTracer(chainInfo.rpc, '/websocket');
|
|
67
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
64
68
|
txTracer.traceTx(txHash).then(() => {
|
|
65
69
|
txTracer.close();
|
|
66
70
|
});
|
package/src/signers/mock.ts
CHANGED
package/src/signers/solana.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { SolanaWeb3Signer } from '@rango-dev/signer-solana';
|
|
2
|
+
import type { Transaction, VersionedTransaction } from '@solana/web3.js';
|
|
3
|
+
import type { SignClient } from '@walletconnect/sign-client/dist/types/client';
|
|
4
|
+
import type { SessionTypes } from '@walletconnect/types';
|
|
4
5
|
import type { GenericSigner, SolanaTransaction } from 'rango-types';
|
|
6
|
+
|
|
7
|
+
import { generalSolanaTransactionExecutor } from '@rango-dev/signer-solana';
|
|
8
|
+
import { PublicKey } from '@solana/web3.js';
|
|
9
|
+
import base58 from 'bs58';
|
|
10
|
+
import { AccountId, ChainId } from 'caip';
|
|
5
11
|
import { SignerError, SignerErrorCode } from 'rango-types';
|
|
12
|
+
|
|
6
13
|
import { NAMESPACES, SolanaRPCMethods } from '../constants';
|
|
7
|
-
import {
|
|
8
|
-
SolanaWeb3Signer,
|
|
9
|
-
generalSolanaTransactionExecutor,
|
|
10
|
-
} from '@rango-dev/signer-solana';
|
|
11
|
-
import { PublicKey, Transaction, VersionedTransaction } from '@solana/web3.js';
|
|
12
|
-
import base58 from 'bs58';
|
|
13
14
|
|
|
14
15
|
const NAMESPACE_NAME = NAMESPACES.SOLANA;
|
|
15
16
|
class SOLANASigner implements GenericSigner<SolanaTransaction> {
|
|
@@ -101,15 +102,19 @@ class SOLANASigner implements GenericSigner<SolanaTransaction> {
|
|
|
101
102
|
}) {
|
|
102
103
|
const { address, chainId } = requestedFor;
|
|
103
104
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
/*
|
|
106
|
+
* TODO: solana chain id in supported blockchains("mainnet-beta") is different from solana chain id is here ("5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp")
|
|
107
|
+
* # Solana Mainnet
|
|
108
|
+
* solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvd
|
|
109
|
+
* refrence: https://github.com/ChainAgnostic/namespaces/blob/main/solana/caip2.md
|
|
110
|
+
*/
|
|
108
111
|
|
|
109
112
|
let solana_chain_id = chainId;
|
|
110
113
|
this.session.namespaces[NAMESPACE_NAME]?.accounts.map((account) => {
|
|
111
114
|
const sol_account = account.split(':');
|
|
112
|
-
if (sol_account[2] === address)
|
|
115
|
+
if (sol_account[2] === address) {
|
|
116
|
+
solana_chain_id = sol_account[1];
|
|
117
|
+
}
|
|
113
118
|
});
|
|
114
119
|
|
|
115
120
|
if (!solana_chain_id) {
|