@depay/web3-wallets-evm 14.2.0 → 14.3.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.
- package/dist/esm/index.evm.js +98 -44
- package/dist/esm/index.js +113 -59
- package/dist/umd/index.evm.js +97 -43
- package/dist/umd/index.js +112 -58
- package/package.json +1 -1
package/dist/esm/index.evm.js
CHANGED
|
@@ -2,11 +2,11 @@ import { Blockchain } from '@depay/web3-blockchains';
|
|
|
2
2
|
import { ethers } from 'ethers';
|
|
3
3
|
import { CONSTANTS } from '@depay/web3-constants';
|
|
4
4
|
import { request as request$3 } from '@depay/web3-client-evm';
|
|
5
|
-
import { WalletConnectClient
|
|
5
|
+
import { WalletConnectClient } from '@depay/walletconnect-v1';
|
|
6
6
|
import { Core, SignClient } from '@depay/walletconnect-v2';
|
|
7
7
|
import { CoinbaseWalletSDK } from '@depay/coinbase-wallet-sdk';
|
|
8
8
|
|
|
9
|
-
function _optionalChain$
|
|
9
|
+
function _optionalChain$d(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
10
10
|
class Transaction$1 {
|
|
11
11
|
|
|
12
12
|
constructor({ blockchain, from, to, value, api, method, params, instructions, sent, succeeded, failed }) {
|
|
@@ -17,7 +17,7 @@ class Transaction$1 {
|
|
|
17
17
|
this.to = (to && to.match('0x')) ? ethers.utils.getAddress(to) : to;
|
|
18
18
|
|
|
19
19
|
// optional
|
|
20
|
-
this.value = _optionalChain$
|
|
20
|
+
this.value = _optionalChain$d([Transaction$1, 'access', _ => _.bigNumberify, 'call', _2 => _2(value, blockchain), 'optionalAccess', _3 => _3.toString, 'call', _4 => _4()]);
|
|
21
21
|
this.api = api;
|
|
22
22
|
this.method = method;
|
|
23
23
|
this.params = params;
|
|
@@ -185,7 +185,7 @@ let supported$3 = ['ethereum', 'bsc', 'polygon', 'velas'];
|
|
|
185
185
|
supported$3.evm = ['ethereum', 'bsc', 'polygon', 'velas'];
|
|
186
186
|
supported$3.solana = [];
|
|
187
187
|
|
|
188
|
-
function _optionalChain$
|
|
188
|
+
function _optionalChain$c(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
189
189
|
class WindowEthereum {
|
|
190
190
|
|
|
191
191
|
static __initStatic() {this.info = {
|
|
@@ -196,12 +196,12 @@ class WindowEthereum {
|
|
|
196
196
|
|
|
197
197
|
static __initStatic2() {this.isAvailable = ()=>{
|
|
198
198
|
return (
|
|
199
|
-
_optionalChain$
|
|
199
|
+
_optionalChain$c([window, 'optionalAccess', _13 => _13.ethereum]) &&
|
|
200
200
|
Object.keys(window.ethereum).filter((key)=>key.match(/^is(?!Connected)/)).length != 1 && // MetaMask
|
|
201
|
-
!_optionalChain$
|
|
202
|
-
!(_optionalChain$
|
|
203
|
-
!_optionalChain$
|
|
204
|
-
!(_optionalChain$
|
|
201
|
+
!_optionalChain$c([window, 'optionalAccess', _14 => _14.coin98]) && // Coin98
|
|
202
|
+
!(_optionalChain$c([window, 'optionalAccess', _15 => _15.ethereum, 'optionalAccess', _16 => _16.isTrust]) || _optionalChain$c([window, 'optionalAccess', _17 => _17.ethereum, 'optionalAccess', _18 => _18.isTrustWallet])) && // Trust Wallet
|
|
203
|
+
!_optionalChain$c([window, 'optionalAccess', _19 => _19.ethereum, 'optionalAccess', _20 => _20.isDeficonnectProvider]) && // crypto.com
|
|
204
|
+
!(_optionalChain$c([window, 'optionalAccess', _21 => _21.ethereum, 'optionalAccess', _22 => _22.isCoinbaseWallet]) || _optionalChain$c([window, 'optionalAccess', _23 => _23.ethereum, 'optionalAccess', _24 => _24.isWalletLink]))
|
|
205
205
|
)
|
|
206
206
|
};}
|
|
207
207
|
|
|
@@ -308,7 +308,7 @@ class WindowEthereum {
|
|
|
308
308
|
}
|
|
309
309
|
} WindowEthereum.__initStatic(); WindowEthereum.__initStatic2();
|
|
310
310
|
|
|
311
|
-
function _optionalChain$
|
|
311
|
+
function _optionalChain$b(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
312
312
|
class Binance extends WindowEthereum {
|
|
313
313
|
|
|
314
314
|
static __initStatic() {this.info = {
|
|
@@ -318,7 +318,7 @@ class Binance extends WindowEthereum {
|
|
|
318
318
|
};}
|
|
319
319
|
|
|
320
320
|
static __initStatic2() {this.isAvailable = ()=>{
|
|
321
|
-
return _optionalChain$
|
|
321
|
+
return _optionalChain$b([window, 'optionalAccess', _2 => _2.BinanceChain]) &&
|
|
322
322
|
!window.coin98
|
|
323
323
|
};}
|
|
324
324
|
|
|
@@ -326,7 +326,7 @@ class Binance extends WindowEthereum {
|
|
|
326
326
|
|
|
327
327
|
} Binance.__initStatic(); Binance.__initStatic2();
|
|
328
328
|
|
|
329
|
-
function _optionalChain$
|
|
329
|
+
function _optionalChain$a(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
330
330
|
class Brave extends WindowEthereum {
|
|
331
331
|
|
|
332
332
|
static __initStatic() {this.info = {
|
|
@@ -335,10 +335,10 @@ class Brave extends WindowEthereum {
|
|
|
335
335
|
blockchains: ['ethereum', 'bsc', 'polygon', 'velas']
|
|
336
336
|
};}
|
|
337
337
|
|
|
338
|
-
static __initStatic2() {this.isAvailable = ()=>{ return _optionalChain$
|
|
338
|
+
static __initStatic2() {this.isAvailable = ()=>{ return _optionalChain$a([window, 'optionalAccess', _3 => _3.ethereum, 'optionalAccess', _4 => _4.isBraveWallet]) };}
|
|
339
339
|
} Brave.__initStatic(); Brave.__initStatic2();
|
|
340
340
|
|
|
341
|
-
function _optionalChain$
|
|
341
|
+
function _optionalChain$9(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
342
342
|
class Coin98 extends WindowEthereum {
|
|
343
343
|
|
|
344
344
|
static __initStatic() {this.info = {
|
|
@@ -347,10 +347,10 @@ class Coin98 extends WindowEthereum {
|
|
|
347
347
|
blockchains: ['ethereum', 'bsc', 'polygon', 'velas']
|
|
348
348
|
};}
|
|
349
349
|
|
|
350
|
-
static __initStatic2() {this.isAvailable = ()=>{ return _optionalChain$
|
|
350
|
+
static __initStatic2() {this.isAvailable = ()=>{ return _optionalChain$9([window, 'optionalAccess', _2 => _2.coin98]) };}
|
|
351
351
|
} Coin98.__initStatic(); Coin98.__initStatic2();
|
|
352
352
|
|
|
353
|
-
function _optionalChain$
|
|
353
|
+
function _optionalChain$8(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
354
354
|
class Coinbase extends WindowEthereum {
|
|
355
355
|
|
|
356
356
|
static __initStatic() {this.info = {
|
|
@@ -359,10 +359,10 @@ class Coinbase extends WindowEthereum {
|
|
|
359
359
|
blockchains: ['ethereum', 'bsc', 'polygon', 'velas']
|
|
360
360
|
};}
|
|
361
361
|
|
|
362
|
-
static __initStatic2() {this.isAvailable = ()=>{ return (_optionalChain$
|
|
362
|
+
static __initStatic2() {this.isAvailable = ()=>{ return (_optionalChain$8([window, 'optionalAccess', _5 => _5.ethereum, 'optionalAccess', _6 => _6.isCoinbaseWallet]) || _optionalChain$8([window, 'optionalAccess', _7 => _7.ethereum, 'optionalAccess', _8 => _8.isWalletLink])) };}
|
|
363
363
|
} Coinbase.__initStatic(); Coinbase.__initStatic2();
|
|
364
364
|
|
|
365
|
-
function _optionalChain$
|
|
365
|
+
function _optionalChain$7(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
366
366
|
class CryptoCom extends WindowEthereum {
|
|
367
367
|
|
|
368
368
|
static __initStatic() {this.info = {
|
|
@@ -371,10 +371,10 @@ class CryptoCom extends WindowEthereum {
|
|
|
371
371
|
blockchains: ['ethereum', 'bsc', 'polygon', 'velas']
|
|
372
372
|
};}
|
|
373
373
|
|
|
374
|
-
static __initStatic2() {this.isAvailable = ()=>{ return _optionalChain$
|
|
374
|
+
static __initStatic2() {this.isAvailable = ()=>{ return _optionalChain$7([window, 'optionalAccess', _3 => _3.ethereum, 'optionalAccess', _4 => _4.isDeficonnectProvider]) };}
|
|
375
375
|
} CryptoCom.__initStatic(); CryptoCom.__initStatic2();
|
|
376
376
|
|
|
377
|
-
function _optionalChain$
|
|
377
|
+
function _optionalChain$6(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
378
378
|
class MetaMask extends WindowEthereum {
|
|
379
379
|
|
|
380
380
|
static __initStatic() {this.info = {
|
|
@@ -384,11 +384,11 @@ class MetaMask extends WindowEthereum {
|
|
|
384
384
|
};}
|
|
385
385
|
|
|
386
386
|
static __initStatic2() {this.isAvailable = ()=>{
|
|
387
|
-
return _optionalChain$
|
|
387
|
+
return _optionalChain$6([window, 'optionalAccess', _3 => _3.ethereum, 'optionalAccess', _4 => _4.isMetaMask]) && Object.keys(window.ethereum).filter((key)=>key.match(/^is(?!Connected)/)).length == 1
|
|
388
388
|
};}
|
|
389
389
|
} MetaMask.__initStatic(); MetaMask.__initStatic2();
|
|
390
390
|
|
|
391
|
-
function _optionalChain$
|
|
391
|
+
function _optionalChain$5(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
392
392
|
class Opera extends WindowEthereum {
|
|
393
393
|
|
|
394
394
|
static __initStatic() {this.info = {
|
|
@@ -397,10 +397,10 @@ class Opera extends WindowEthereum {
|
|
|
397
397
|
blockchains: ['ethereum', 'bsc', 'polygon', 'velas']
|
|
398
398
|
};}
|
|
399
399
|
|
|
400
|
-
static __initStatic2() {this.isAvailable = ()=>{ return _optionalChain$
|
|
400
|
+
static __initStatic2() {this.isAvailable = ()=>{ return _optionalChain$5([window, 'optionalAccess', _3 => _3.ethereum, 'optionalAccess', _4 => _4.isOpera]) };}
|
|
401
401
|
} Opera.__initStatic(); Opera.__initStatic2();
|
|
402
402
|
|
|
403
|
-
function _optionalChain$
|
|
403
|
+
function _optionalChain$4(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
404
404
|
class Trust extends WindowEthereum {
|
|
405
405
|
|
|
406
406
|
static __initStatic() {this.info = {
|
|
@@ -409,7 +409,7 @@ class Trust extends WindowEthereum {
|
|
|
409
409
|
blockchains: ['ethereum', 'bsc', 'polygon', 'velas']
|
|
410
410
|
};}
|
|
411
411
|
|
|
412
|
-
static __initStatic2() {this.isAvailable = ()=>{ return (_optionalChain$
|
|
412
|
+
static __initStatic2() {this.isAvailable = ()=>{ return (_optionalChain$4([window, 'optionalAccess', _5 => _5.ethereum, 'optionalAccess', _6 => _6.isTrust]) || _optionalChain$4([window, 'optionalAccess', _7 => _7.ethereum, 'optionalAccess', _8 => _8.isTrustWallet])) };}
|
|
413
413
|
} Trust.__initStatic(); Trust.__initStatic2();
|
|
414
414
|
|
|
415
415
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
@@ -59891,7 +59891,6 @@ const getProvider = async (blockchain)=>{
|
|
|
59891
59891
|
}
|
|
59892
59892
|
};
|
|
59893
59893
|
|
|
59894
|
-
function _optionalChain$5(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
59895
59894
|
const sendTransaction$3 = async ({ transaction, wallet })=> {
|
|
59896
59895
|
transaction = new Transaction$1(transaction);
|
|
59897
59896
|
if((await wallet.connectedTo(transaction.blockchain)) == false) {
|
|
@@ -59967,30 +59966,57 @@ const submit$3 = ({ transaction, wallet }) => {
|
|
|
59967
59966
|
|
|
59968
59967
|
const submitContractInteraction$2 = async ({ transaction, wallet })=>{
|
|
59969
59968
|
const provider = await getProvider(transaction.blockchain);
|
|
59969
|
+
const gasPrice = await provider.getGasPrice();
|
|
59970
|
+
const gas = await estimate(transaction);
|
|
59971
|
+
const data = await transaction.getData();
|
|
59972
|
+
const value = transaction.value ? ethers.utils.hexlify(ethers.BigNumber.from(transaction.value)) : undefined;
|
|
59973
|
+
const nonce = ethers.utils.hexlify(transaction.nonce);
|
|
59974
|
+
console.log({
|
|
59975
|
+
from: transaction.from,
|
|
59976
|
+
to: transaction.to,
|
|
59977
|
+
value,
|
|
59978
|
+
data,
|
|
59979
|
+
gas: gas.toHexString(),
|
|
59980
|
+
gasPrice: gasPrice.toHexString(),
|
|
59981
|
+
nonce,
|
|
59982
|
+
});
|
|
59970
59983
|
return wallet.connector.sendTransaction({
|
|
59971
59984
|
from: transaction.from,
|
|
59972
59985
|
to: transaction.to,
|
|
59973
|
-
value
|
|
59974
|
-
data
|
|
59975
|
-
gas:
|
|
59976
|
-
gasPrice:
|
|
59977
|
-
nonce
|
|
59986
|
+
value,
|
|
59987
|
+
data,
|
|
59988
|
+
gas: gas.toHexString(),
|
|
59989
|
+
gasPrice: gasPrice.toHexString(),
|
|
59990
|
+
nonce,
|
|
59978
59991
|
})
|
|
59979
59992
|
};
|
|
59980
59993
|
|
|
59981
59994
|
const submitSimpleTransfer$3 = async ({ transaction, wallet })=>{
|
|
59982
59995
|
const provider = await getProvider(transaction.blockchain);
|
|
59996
|
+
const gasPrice = await provider.getGasPrice();
|
|
59997
|
+
const gas = await estimate(transaction);
|
|
59998
|
+
const value = ethers.utils.hexlify(ethers.BigNumber.from(transaction.value));
|
|
59999
|
+
const nonce = ethers.utils.hexlify(transaction.nonce);
|
|
60000
|
+
console.log({
|
|
60001
|
+
from: transaction.from,
|
|
60002
|
+
to: transaction.to,
|
|
60003
|
+
value,
|
|
60004
|
+
data: '0x',
|
|
60005
|
+
gas: gas.toHexString(),
|
|
60006
|
+
gasPrice: gasPrice.toHexString(),
|
|
60007
|
+
nonce,
|
|
60008
|
+
});
|
|
59983
60009
|
return wallet.connector.sendTransaction({
|
|
59984
60010
|
from: transaction.from,
|
|
59985
60011
|
to: transaction.to,
|
|
59986
|
-
value
|
|
59987
|
-
|
|
59988
|
-
|
|
59989
|
-
|
|
60012
|
+
value,
|
|
60013
|
+
data: '0x',
|
|
60014
|
+
gas: gas.toHexString(),
|
|
60015
|
+
gasPrice: gasPrice.toHexString(),
|
|
60016
|
+
nonce,
|
|
59990
60017
|
})
|
|
59991
60018
|
};
|
|
59992
60019
|
|
|
59993
|
-
function _optionalChain$4(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
59994
60020
|
const KEY$1 = '_DePayWeb3WalletsConnectedWalletConnectV1Instance';
|
|
59995
60021
|
|
|
59996
60022
|
const getConnectedInstance$2 = ()=>{
|
|
@@ -60017,7 +60043,6 @@ class WalletConnectV1 {
|
|
|
60017
60043
|
this.name = this.constructor.info.name;
|
|
60018
60044
|
this.logo = this.constructor.info.logo;
|
|
60019
60045
|
this.blockchains = this.constructor.info.blockchains;
|
|
60020
|
-
this.connector = WalletConnectV1.instance || this.newWalletConnectInstance();
|
|
60021
60046
|
this.sendTransaction = (transaction)=>{
|
|
60022
60047
|
return sendTransaction$3({
|
|
60023
60048
|
wallet: this,
|
|
@@ -60026,10 +60051,13 @@ class WalletConnectV1 {
|
|
|
60026
60051
|
};
|
|
60027
60052
|
}
|
|
60028
60053
|
|
|
60029
|
-
newWalletConnectInstance() {
|
|
60054
|
+
newWalletConnectInstance(connect) {
|
|
60030
60055
|
let instance = new WalletConnectClient({
|
|
60031
|
-
bridge: "https://
|
|
60032
|
-
qrcodeModal:
|
|
60056
|
+
bridge: "https://walletconnect.depay.com",
|
|
60057
|
+
qrcodeModal: {
|
|
60058
|
+
open: async(uri)=>connect({ uri }),
|
|
60059
|
+
close: ()=>{},
|
|
60060
|
+
}
|
|
60033
60061
|
});
|
|
60034
60062
|
|
|
60035
60063
|
instance.on("connect", (error, payload) => {
|
|
@@ -60065,20 +60093,23 @@ class WalletConnectV1 {
|
|
|
60065
60093
|
}
|
|
60066
60094
|
|
|
60067
60095
|
async connect(options) {
|
|
60096
|
+
let connect = (options && options.connect) ? options.connect : ({uri})=>{};
|
|
60068
60097
|
try {
|
|
60069
60098
|
window.localStorage.removeItem('walletconnect'); // https://github.com/WalletConnect/walletconnect-monorepo/issues/315
|
|
60070
60099
|
|
|
60100
|
+
this.connector = WalletConnectV1.instance;
|
|
60101
|
+
|
|
60071
60102
|
if(this.connector == undefined){
|
|
60072
|
-
this.connector = this.newWalletConnectInstance();
|
|
60103
|
+
this.connector = this.newWalletConnectInstance(connect);
|
|
60073
60104
|
}
|
|
60074
60105
|
|
|
60075
60106
|
if(this.connector.connected) {
|
|
60076
60107
|
await this.connector.killSession();
|
|
60077
60108
|
setConnectedInstance$2(undefined);
|
|
60078
|
-
this.connector = this.newWalletConnectInstance();
|
|
60109
|
+
this.connector = this.newWalletConnectInstance(connect);
|
|
60079
60110
|
}
|
|
60080
60111
|
|
|
60081
|
-
let { accounts, chainId } = await this.connector.connect(
|
|
60112
|
+
let { accounts, chainId } = await this.connector.connect();
|
|
60082
60113
|
|
|
60083
60114
|
if(accounts instanceof Array && accounts.length) {
|
|
60084
60115
|
setConnectedInstance$2(this);
|
|
@@ -60384,6 +60415,8 @@ class WalletConnectV2 {
|
|
|
60384
60415
|
methods: [
|
|
60385
60416
|
"eth_sendTransaction",
|
|
60386
60417
|
"personal_sign",
|
|
60418
|
+
"eth_chainId",
|
|
60419
|
+
"wallet_switchEthereumChain",
|
|
60387
60420
|
],
|
|
60388
60421
|
chains: [`${blockchain.namespace}:${blockchain.networkId}`],
|
|
60389
60422
|
events: [],
|
|
@@ -60423,7 +60456,28 @@ class WalletConnectV2 {
|
|
|
60423
60456
|
|
|
60424
60457
|
switchTo(blockchainName) {
|
|
60425
60458
|
return new Promise((resolve, reject)=>{
|
|
60426
|
-
|
|
60459
|
+
let resolved, rejected;
|
|
60460
|
+
const blockchain = Blockchain.findByName(blockchainName);
|
|
60461
|
+
setTimeout(async()=>{
|
|
60462
|
+
if(!(await this.connectedTo(blockchainName)) && !resolved && !rejected){
|
|
60463
|
+
reject({ code: 'NOT_SUPPORTED' });
|
|
60464
|
+
} else {
|
|
60465
|
+
resolve();
|
|
60466
|
+
}
|
|
60467
|
+
}, 4000);
|
|
60468
|
+
this.connectedBlockchain = blockchain.name;
|
|
60469
|
+
this.signClient.request({
|
|
60470
|
+
topic: this.session.topic,
|
|
60471
|
+
chainId: this.session.chainId,
|
|
60472
|
+
request:{
|
|
60473
|
+
method: 'wallet_switchEthereumChain',
|
|
60474
|
+
params: [{ chainId: blockchain.id }],
|
|
60475
|
+
}
|
|
60476
|
+
}).then((result)=>{
|
|
60477
|
+
console.log('RESULT ', result);
|
|
60478
|
+
resolved = true;
|
|
60479
|
+
resolve();
|
|
60480
|
+
});
|
|
60427
60481
|
})
|
|
60428
60482
|
}
|
|
60429
60483
|
|