@depay/web3-wallets-evm 15.15.4 → 15.16.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/README.md CHANGED
@@ -104,7 +104,7 @@ Pass a `drip` callback to `getWallets` to receive available wallet as soon as th
104
104
 
105
105
  getWallets({
106
106
  drip: (wallet)=>{
107
- setAvaialbleWallets(
107
+ setAvailableWallets(
108
108
  availableWallets.concat([wallet])
109
109
  )
110
110
  }
@@ -43563,11 +43563,25 @@ class WindowEthereum {
43563
43563
  }
43564
43564
 
43565
43565
  async sign(message) {
43566
- await this.account();
43567
- let provider = new ethers.providers.Web3Provider(this.getProvider(), 'any');
43568
- let signer = provider.getSigner(0);
43569
- let signature = await signer.signMessage(message);
43570
- return signature
43566
+ if(typeof message === 'object') {
43567
+ let provider = this.getProvider();
43568
+ let account = await this.account();
43569
+ if((await this.connectedTo(Blockchains.findByNetworkId(message.domain.chainId).name)) === false) {
43570
+ throw({ code: 'WRONG_NETWORK' })
43571
+ }
43572
+ let signature = await provider.request({
43573
+ method: 'eth_signTypedData_v4',
43574
+ params: [account, message],
43575
+ from: account,
43576
+ });
43577
+ return signature
43578
+ } else if (typeof message === 'string') {
43579
+ await this.account();
43580
+ let provider = new ethers.providers.Web3Provider(this.getProvider(), 'any');
43581
+ let signer = provider.getSigner(0);
43582
+ let signature = await signer.signMessage(message);
43583
+ return signature
43584
+ }
43571
43585
  }
43572
43586
  } WindowEthereum.__initStatic(); WindowEthereum.__initStatic2();
43573
43587
 
@@ -44381,13 +44395,26 @@ class WalletConnectV1 {
44381
44395
  }
44382
44396
 
44383
44397
  async sign(message) {
44384
- let blockchain = await this.connectedTo();
44385
- let address = await this.account();
44386
- const smartContractWallet = await getSmartContractWallet(blockchain, address);
44387
- if(smartContractWallet){ throw({ message: 'Smart contract wallets are not supported for signing!', code: "SMART_CONTRACT_WALLET_NOT_SUPPORTED" }) }
44388
- var params = [ethers.utils.toUtf8Bytes(message), address];
44389
- let signature = await this.connector.signPersonalMessage(params);
44390
- return signature
44398
+ if(typeof message === 'object') {
44399
+ let account = await this.account();
44400
+ if((await this.connectedTo(Blockchains.findByNetworkId(message.domain.chainId).name)) === false) {
44401
+ throw({ code: 'WRONG_NETWORK' })
44402
+ }
44403
+ let signature = await this.connector.sendCustomRequest({
44404
+ jsonrpc: '2.0',
44405
+ method: 'eth_signTypedData_v4',
44406
+ params: [account, JSON.stringify(message)],
44407
+ });
44408
+ return signature
44409
+ } else if (typeof message === 'string') {
44410
+ let blockchain = await this.connectedTo();
44411
+ let address = await this.account();
44412
+ const smartContractWallet = await getSmartContractWallet(blockchain, address);
44413
+ if(smartContractWallet){ throw({ message: 'Smart contract wallets are not supported for signing!', code: "SMART_CONTRACT_WALLET_NOT_SUPPORTED" }) }
44414
+ var params = [ethers.utils.toUtf8Bytes(message), address];
44415
+ let signature = await this.connector.signPersonalMessage(params);
44416
+ return signature
44417
+ }
44391
44418
  }
44392
44419
  } WalletConnectV1.__initStatic(); WalletConnectV1.__initStatic2();
44393
44420
 
@@ -44559,6 +44586,7 @@ const getWalletConnectV2Config = ()=>{
44559
44586
  const methods = [
44560
44587
  "eth_sendTransaction",
44561
44588
  "personal_sign",
44589
+ "eth_signTypedData_v4",
44562
44590
  "eth_chainId",
44563
44591
  "eth_accounts",
44564
44592
  "wallet_switchEthereumChain",
@@ -44782,22 +44810,39 @@ class WalletConnectV2 {
44782
44810
  }
44783
44811
 
44784
44812
  async sign(message) {
44785
- const address = await this.account();
44786
- const params = [ethers.utils.hexlify(ethers.utils.toUtf8Bytes(message)), address];
44787
- const connectedChainId = await getConnectedChainId(this.signClient, this.session);
44788
- const blockchain = Blockchains.findById(connectedChainId);
44789
- let signature = await this.signClient.request({
44790
- topic: this.session.topic,
44791
- chainId: `${blockchain.namespace}:${blockchain.networkId}`,
44792
- request:{
44793
- method: 'personal_sign',
44794
- params
44813
+ if(typeof message === 'object') {
44814
+ let account = await this.account();
44815
+ const blockchain = Blockchains.findByNetworkId(message.domain.chainId);
44816
+ if((await this.connectedTo(blockchain.name)) === false) {
44817
+ throw({ code: 'WRONG_NETWORK' })
44818
+ }
44819
+ let signature = await this.signClient.request({
44820
+ topic: this.session.topic,
44821
+ chainId: `${blockchain.namespace}:${blockchain.networkId}`,
44822
+ request:{
44823
+ method: 'eth_signTypedData_v4',
44824
+ params: [account, JSON.stringify(message)],
44825
+ }
44826
+ });
44827
+ return signature
44828
+ } else if (typeof message === 'string') {
44829
+ const address = await this.account();
44830
+ const params = [ethers.utils.hexlify(ethers.utils.toUtf8Bytes(message)), address];
44831
+ const connectedChainId = await getConnectedChainId(this.signClient, this.session);
44832
+ const blockchain = Blockchains.findById(connectedChainId);
44833
+ let signature = await this.signClient.request({
44834
+ topic: this.session.topic,
44835
+ chainId: `${blockchain.namespace}:${blockchain.networkId}`,
44836
+ request:{
44837
+ method: 'personal_sign',
44838
+ params
44839
+ }
44840
+ });
44841
+ if(typeof signature == 'object') {
44842
+ signature = ethers.utils.hexlify(signature);
44795
44843
  }
44796
- });
44797
- if(typeof signature == 'object') {
44798
- signature = ethers.utils.hexlify(signature);
44844
+ return signature
44799
44845
  }
44800
- return signature
44801
44846
  }
44802
44847
  } WalletConnectV2.__initStatic(); WalletConnectV2.__initStatic2();
44803
44848
 
@@ -45015,11 +45060,25 @@ class WalletLink {
45015
45060
  }
45016
45061
 
45017
45062
  async sign(message) {
45018
- await this.account();
45019
- let provider = new ethers.providers.Web3Provider(this.connector, 'any');
45020
- let signer = provider.getSigner(0);
45021
- let signature = await signer.signMessage(message);
45022
- return signature
45063
+ if(typeof message === 'object') {
45064
+ let provider = this.connector;
45065
+ let account = await this.account();
45066
+ if((await this.connectedTo(Blockchains.findByNetworkId(message.domain.chainId).name)) === false) {
45067
+ throw({ code: 'WRONG_NETWORK' })
45068
+ }
45069
+ let signature = await provider.request({
45070
+ method: 'eth_signTypedData_v4',
45071
+ params: [account, message],
45072
+ from: account,
45073
+ });
45074
+ return signature
45075
+ } else if (typeof message === 'string') {
45076
+ await this.account();
45077
+ let provider = new ethers.providers.Web3Provider(this.connector, 'any');
45078
+ let signer = provider.getSigner(0);
45079
+ let signature = await signer.signMessage(message);
45080
+ return signature
45081
+ }
45023
45082
  }
45024
45083
  } WalletLink.__initStatic(); WalletLink.__initStatic2();
45025
45084
 
package/dist/esm/index.js CHANGED
@@ -598,11 +598,25 @@ class WindowEthereum {
598
598
  }
599
599
 
600
600
  async sign(message) {
601
- await this.account();
602
- let provider = new ethers.providers.Web3Provider(this.getProvider(), 'any');
603
- let signer = provider.getSigner(0);
604
- let signature = await signer.signMessage(message);
605
- return signature
601
+ if(typeof message === 'object') {
602
+ let provider = this.getProvider();
603
+ let account = await this.account();
604
+ if((await this.connectedTo(Blockchains.findByNetworkId(message.domain.chainId).name)) === false) {
605
+ throw({ code: 'WRONG_NETWORK' })
606
+ }
607
+ let signature = await provider.request({
608
+ method: 'eth_signTypedData_v4',
609
+ params: [account, message],
610
+ from: account,
611
+ });
612
+ return signature
613
+ } else if (typeof message === 'string') {
614
+ await this.account();
615
+ let provider = new ethers.providers.Web3Provider(this.getProvider(), 'any');
616
+ let signer = provider.getSigner(0);
617
+ let signature = await signer.signMessage(message);
618
+ return signature
619
+ }
606
620
  }
607
621
  } WindowEthereum.__initStatic(); WindowEthereum.__initStatic2();
608
622
 
@@ -1418,13 +1432,26 @@ class WalletConnectV1 {
1418
1432
  }
1419
1433
 
1420
1434
  async sign(message) {
1421
- let blockchain = await this.connectedTo();
1422
- let address = await this.account();
1423
- const smartContractWallet = await getSmartContractWallet(blockchain, address);
1424
- if(smartContractWallet){ throw({ message: 'Smart contract wallets are not supported for signing!', code: "SMART_CONTRACT_WALLET_NOT_SUPPORTED" }) }
1425
- var params = [ethers.utils.toUtf8Bytes(message), address];
1426
- let signature = await this.connector.signPersonalMessage(params);
1427
- return signature
1435
+ if(typeof message === 'object') {
1436
+ let account = await this.account();
1437
+ if((await this.connectedTo(Blockchains.findByNetworkId(message.domain.chainId).name)) === false) {
1438
+ throw({ code: 'WRONG_NETWORK' })
1439
+ }
1440
+ let signature = await this.connector.sendCustomRequest({
1441
+ jsonrpc: '2.0',
1442
+ method: 'eth_signTypedData_v4',
1443
+ params: [account, JSON.stringify(message)],
1444
+ });
1445
+ return signature
1446
+ } else if (typeof message === 'string') {
1447
+ let blockchain = await this.connectedTo();
1448
+ let address = await this.account();
1449
+ const smartContractWallet = await getSmartContractWallet(blockchain, address);
1450
+ if(smartContractWallet){ throw({ message: 'Smart contract wallets are not supported for signing!', code: "SMART_CONTRACT_WALLET_NOT_SUPPORTED" }) }
1451
+ var params = [ethers.utils.toUtf8Bytes(message), address];
1452
+ let signature = await this.connector.signPersonalMessage(params);
1453
+ return signature
1454
+ }
1428
1455
  }
1429
1456
  } WalletConnectV1.__initStatic(); WalletConnectV1.__initStatic2();
1430
1457
 
@@ -1596,6 +1623,7 @@ const getWalletConnectV2Config = ()=>{
1596
1623
  const methods = [
1597
1624
  "eth_sendTransaction",
1598
1625
  "personal_sign",
1626
+ "eth_signTypedData_v4",
1599
1627
  "eth_chainId",
1600
1628
  "eth_accounts",
1601
1629
  "wallet_switchEthereumChain",
@@ -1819,22 +1847,39 @@ class WalletConnectV2 {
1819
1847
  }
1820
1848
 
1821
1849
  async sign(message) {
1822
- const address = await this.account();
1823
- const params = [ethers.utils.hexlify(ethers.utils.toUtf8Bytes(message)), address];
1824
- const connectedChainId = await getConnectedChainId(this.signClient, this.session);
1825
- const blockchain = Blockchains.findById(connectedChainId);
1826
- let signature = await this.signClient.request({
1827
- topic: this.session.topic,
1828
- chainId: `${blockchain.namespace}:${blockchain.networkId}`,
1829
- request:{
1830
- method: 'personal_sign',
1831
- params
1850
+ if(typeof message === 'object') {
1851
+ let account = await this.account();
1852
+ const blockchain = Blockchains.findByNetworkId(message.domain.chainId);
1853
+ if((await this.connectedTo(blockchain.name)) === false) {
1854
+ throw({ code: 'WRONG_NETWORK' })
1832
1855
  }
1833
- });
1834
- if(typeof signature == 'object') {
1835
- signature = ethers.utils.hexlify(signature);
1856
+ let signature = await this.signClient.request({
1857
+ topic: this.session.topic,
1858
+ chainId: `${blockchain.namespace}:${blockchain.networkId}`,
1859
+ request:{
1860
+ method: 'eth_signTypedData_v4',
1861
+ params: [account, JSON.stringify(message)],
1862
+ }
1863
+ });
1864
+ return signature
1865
+ } else if (typeof message === 'string') {
1866
+ const address = await this.account();
1867
+ const params = [ethers.utils.hexlify(ethers.utils.toUtf8Bytes(message)), address];
1868
+ const connectedChainId = await getConnectedChainId(this.signClient, this.session);
1869
+ const blockchain = Blockchains.findById(connectedChainId);
1870
+ let signature = await this.signClient.request({
1871
+ topic: this.session.topic,
1872
+ chainId: `${blockchain.namespace}:${blockchain.networkId}`,
1873
+ request:{
1874
+ method: 'personal_sign',
1875
+ params
1876
+ }
1877
+ });
1878
+ if(typeof signature == 'object') {
1879
+ signature = ethers.utils.hexlify(signature);
1880
+ }
1881
+ return signature
1836
1882
  }
1837
- return signature
1838
1883
  }
1839
1884
  } WalletConnectV2.__initStatic(); WalletConnectV2.__initStatic2();
1840
1885
 
@@ -2052,11 +2097,25 @@ class WalletLink {
2052
2097
  }
2053
2098
 
2054
2099
  async sign(message) {
2055
- await this.account();
2056
- let provider = new ethers.providers.Web3Provider(this.connector, 'any');
2057
- let signer = provider.getSigner(0);
2058
- let signature = await signer.signMessage(message);
2059
- return signature
2100
+ if(typeof message === 'object') {
2101
+ let provider = this.connector;
2102
+ let account = await this.account();
2103
+ if((await this.connectedTo(Blockchains.findByNetworkId(message.domain.chainId).name)) === false) {
2104
+ throw({ code: 'WRONG_NETWORK' })
2105
+ }
2106
+ let signature = await provider.request({
2107
+ method: 'eth_signTypedData_v4',
2108
+ params: [account, message],
2109
+ from: account,
2110
+ });
2111
+ return signature
2112
+ } else if (typeof message === 'string') {
2113
+ await this.account();
2114
+ let provider = new ethers.providers.Web3Provider(this.connector, 'any');
2115
+ let signer = provider.getSigner(0);
2116
+ let signature = await signer.signMessage(message);
2117
+ return signature
2118
+ }
2060
2119
  }
2061
2120
  } WalletLink.__initStatic(); WalletLink.__initStatic2();
2062
2121
 
@@ -1434,11 +1434,25 @@ class WindowEthereum {
1434
1434
  }
1435
1435
 
1436
1436
  async sign(message) {
1437
- await this.account();
1438
- let provider = new ethers.providers.Web3Provider(this.getProvider(), 'any');
1439
- let signer = provider.getSigner(0);
1440
- let signature = await signer.signMessage(message);
1441
- return signature
1437
+ if(typeof message === 'object') {
1438
+ let provider = this.getProvider();
1439
+ let account = await this.account();
1440
+ if((await this.connectedTo(Blockchains.findByNetworkId(message.domain.chainId).name)) === false) {
1441
+ throw({ code: 'WRONG_NETWORK' })
1442
+ }
1443
+ let signature = await provider.request({
1444
+ method: 'eth_signTypedData_v4',
1445
+ params: [account, message],
1446
+ from: account,
1447
+ });
1448
+ return signature
1449
+ } else if (typeof message === 'string') {
1450
+ await this.account();
1451
+ let provider = new ethers.providers.Web3Provider(this.getProvider(), 'any');
1452
+ let signer = provider.getSigner(0);
1453
+ let signature = await signer.signMessage(message);
1454
+ return signature
1455
+ }
1442
1456
  }
1443
1457
  } WindowEthereum.__initStatic(); WindowEthereum.__initStatic2();
1444
1458
 
@@ -2254,13 +2268,26 @@ class WalletConnectV1 {
2254
2268
  }
2255
2269
 
2256
2270
  async sign(message) {
2257
- let blockchain = await this.connectedTo();
2258
- let address = await this.account();
2259
- const smartContractWallet = await getSmartContractWallet(blockchain, address);
2260
- if(smartContractWallet){ throw({ message: 'Smart contract wallets are not supported for signing!', code: "SMART_CONTRACT_WALLET_NOT_SUPPORTED" }) }
2261
- var params = [ethers.utils.toUtf8Bytes(message), address];
2262
- let signature = await this.connector.signPersonalMessage(params);
2263
- return signature
2271
+ if(typeof message === 'object') {
2272
+ let account = await this.account();
2273
+ if((await this.connectedTo(Blockchains.findByNetworkId(message.domain.chainId).name)) === false) {
2274
+ throw({ code: 'WRONG_NETWORK' })
2275
+ }
2276
+ let signature = await this.connector.sendCustomRequest({
2277
+ jsonrpc: '2.0',
2278
+ method: 'eth_signTypedData_v4',
2279
+ params: [account, JSON.stringify(message)],
2280
+ });
2281
+ return signature
2282
+ } else if (typeof message === 'string') {
2283
+ let blockchain = await this.connectedTo();
2284
+ let address = await this.account();
2285
+ const smartContractWallet = await getSmartContractWallet(blockchain, address);
2286
+ if(smartContractWallet){ throw({ message: 'Smart contract wallets are not supported for signing!', code: "SMART_CONTRACT_WALLET_NOT_SUPPORTED" }) }
2287
+ var params = [ethers.utils.toUtf8Bytes(message), address];
2288
+ let signature = await this.connector.signPersonalMessage(params);
2289
+ return signature
2290
+ }
2264
2291
  }
2265
2292
  } WalletConnectV1.__initStatic(); WalletConnectV1.__initStatic2();
2266
2293
 
@@ -2432,6 +2459,7 @@ const getWalletConnectV2Config = ()=>{
2432
2459
  const methods = [
2433
2460
  "eth_sendTransaction",
2434
2461
  "personal_sign",
2462
+ "eth_signTypedData_v4",
2435
2463
  "eth_chainId",
2436
2464
  "eth_accounts",
2437
2465
  "wallet_switchEthereumChain",
@@ -2655,22 +2683,39 @@ class WalletConnectV2 {
2655
2683
  }
2656
2684
 
2657
2685
  async sign(message) {
2658
- const address = await this.account();
2659
- const params = [ethers.utils.hexlify(ethers.utils.toUtf8Bytes(message)), address];
2660
- const connectedChainId = await getConnectedChainId(this.signClient, this.session);
2661
- const blockchain = Blockchains.findById(connectedChainId);
2662
- let signature = await this.signClient.request({
2663
- topic: this.session.topic,
2664
- chainId: `${blockchain.namespace}:${blockchain.networkId}`,
2665
- request:{
2666
- method: 'personal_sign',
2667
- params
2686
+ if(typeof message === 'object') {
2687
+ let account = await this.account();
2688
+ const blockchain = Blockchains.findByNetworkId(message.domain.chainId);
2689
+ if((await this.connectedTo(blockchain.name)) === false) {
2690
+ throw({ code: 'WRONG_NETWORK' })
2668
2691
  }
2669
- });
2670
- if(typeof signature == 'object') {
2671
- signature = ethers.utils.hexlify(signature);
2692
+ let signature = await this.signClient.request({
2693
+ topic: this.session.topic,
2694
+ chainId: `${blockchain.namespace}:${blockchain.networkId}`,
2695
+ request:{
2696
+ method: 'eth_signTypedData_v4',
2697
+ params: [account, JSON.stringify(message)],
2698
+ }
2699
+ });
2700
+ return signature
2701
+ } else if (typeof message === 'string') {
2702
+ const address = await this.account();
2703
+ const params = [ethers.utils.hexlify(ethers.utils.toUtf8Bytes(message)), address];
2704
+ const connectedChainId = await getConnectedChainId(this.signClient, this.session);
2705
+ const blockchain = Blockchains.findById(connectedChainId);
2706
+ let signature = await this.signClient.request({
2707
+ topic: this.session.topic,
2708
+ chainId: `${blockchain.namespace}:${blockchain.networkId}`,
2709
+ request:{
2710
+ method: 'personal_sign',
2711
+ params
2712
+ }
2713
+ });
2714
+ if(typeof signature == 'object') {
2715
+ signature = ethers.utils.hexlify(signature);
2716
+ }
2717
+ return signature
2672
2718
  }
2673
- return signature
2674
2719
  }
2675
2720
  } WalletConnectV2.__initStatic(); WalletConnectV2.__initStatic2();
2676
2721
 
@@ -2888,11 +2933,25 @@ class WalletLink {
2888
2933
  }
2889
2934
 
2890
2935
  async sign(message) {
2891
- await this.account();
2892
- let provider = new ethers.providers.Web3Provider(this.connector, 'any');
2893
- let signer = provider.getSigner(0);
2894
- let signature = await signer.signMessage(message);
2895
- return signature
2936
+ if(typeof message === 'object') {
2937
+ let provider = this.connector;
2938
+ let account = await this.account();
2939
+ if((await this.connectedTo(Blockchains.findByNetworkId(message.domain.chainId).name)) === false) {
2940
+ throw({ code: 'WRONG_NETWORK' })
2941
+ }
2942
+ let signature = await provider.request({
2943
+ method: 'eth_signTypedData_v4',
2944
+ params: [account, message],
2945
+ from: account,
2946
+ });
2947
+ return signature
2948
+ } else if (typeof message === 'string') {
2949
+ await this.account();
2950
+ let provider = new ethers.providers.Web3Provider(this.connector, 'any');
2951
+ let signer = provider.getSigner(0);
2952
+ let signature = await signer.signMessage(message);
2953
+ return signature
2954
+ }
2896
2955
  }
2897
2956
  } WalletLink.__initStatic(); WalletLink.__initStatic2();
2898
2957
 
@@ -43566,11 +43566,25 @@
43566
43566
  }
43567
43567
 
43568
43568
  async sign(message) {
43569
- await this.account();
43570
- let provider = new ethers.ethers.providers.Web3Provider(this.getProvider(), 'any');
43571
- let signer = provider.getSigner(0);
43572
- let signature = await signer.signMessage(message);
43573
- return signature
43569
+ if(typeof message === 'object') {
43570
+ let provider = this.getProvider();
43571
+ let account = await this.account();
43572
+ if((await this.connectedTo(Blockchains__default['default'].findByNetworkId(message.domain.chainId).name)) === false) {
43573
+ throw({ code: 'WRONG_NETWORK' })
43574
+ }
43575
+ let signature = await provider.request({
43576
+ method: 'eth_signTypedData_v4',
43577
+ params: [account, message],
43578
+ from: account,
43579
+ });
43580
+ return signature
43581
+ } else if (typeof message === 'string') {
43582
+ await this.account();
43583
+ let provider = new ethers.ethers.providers.Web3Provider(this.getProvider(), 'any');
43584
+ let signer = provider.getSigner(0);
43585
+ let signature = await signer.signMessage(message);
43586
+ return signature
43587
+ }
43574
43588
  }
43575
43589
  } WindowEthereum.__initStatic(); WindowEthereum.__initStatic2();
43576
43590
 
@@ -44384,13 +44398,26 @@
44384
44398
  }
44385
44399
 
44386
44400
  async sign(message) {
44387
- let blockchain = await this.connectedTo();
44388
- let address = await this.account();
44389
- const smartContractWallet = await getSmartContractWallet(blockchain, address);
44390
- if(smartContractWallet){ throw({ message: 'Smart contract wallets are not supported for signing!', code: "SMART_CONTRACT_WALLET_NOT_SUPPORTED" }) }
44391
- var params = [ethers.ethers.utils.toUtf8Bytes(message), address];
44392
- let signature = await this.connector.signPersonalMessage(params);
44393
- return signature
44401
+ if(typeof message === 'object') {
44402
+ let account = await this.account();
44403
+ if((await this.connectedTo(Blockchains__default['default'].findByNetworkId(message.domain.chainId).name)) === false) {
44404
+ throw({ code: 'WRONG_NETWORK' })
44405
+ }
44406
+ let signature = await this.connector.sendCustomRequest({
44407
+ jsonrpc: '2.0',
44408
+ method: 'eth_signTypedData_v4',
44409
+ params: [account, JSON.stringify(message)],
44410
+ });
44411
+ return signature
44412
+ } else if (typeof message === 'string') {
44413
+ let blockchain = await this.connectedTo();
44414
+ let address = await this.account();
44415
+ const smartContractWallet = await getSmartContractWallet(blockchain, address);
44416
+ if(smartContractWallet){ throw({ message: 'Smart contract wallets are not supported for signing!', code: "SMART_CONTRACT_WALLET_NOT_SUPPORTED" }) }
44417
+ var params = [ethers.ethers.utils.toUtf8Bytes(message), address];
44418
+ let signature = await this.connector.signPersonalMessage(params);
44419
+ return signature
44420
+ }
44394
44421
  }
44395
44422
  } WalletConnectV1.__initStatic(); WalletConnectV1.__initStatic2();
44396
44423
 
@@ -44562,6 +44589,7 @@
44562
44589
  const methods = [
44563
44590
  "eth_sendTransaction",
44564
44591
  "personal_sign",
44592
+ "eth_signTypedData_v4",
44565
44593
  "eth_chainId",
44566
44594
  "eth_accounts",
44567
44595
  "wallet_switchEthereumChain",
@@ -44785,22 +44813,39 @@
44785
44813
  }
44786
44814
 
44787
44815
  async sign(message) {
44788
- const address = await this.account();
44789
- const params = [ethers.ethers.utils.hexlify(ethers.ethers.utils.toUtf8Bytes(message)), address];
44790
- const connectedChainId = await getConnectedChainId(this.signClient, this.session);
44791
- const blockchain = Blockchains__default['default'].findById(connectedChainId);
44792
- let signature = await this.signClient.request({
44793
- topic: this.session.topic,
44794
- chainId: `${blockchain.namespace}:${blockchain.networkId}`,
44795
- request:{
44796
- method: 'personal_sign',
44797
- params
44816
+ if(typeof message === 'object') {
44817
+ let account = await this.account();
44818
+ const blockchain = Blockchains__default['default'].findByNetworkId(message.domain.chainId);
44819
+ if((await this.connectedTo(blockchain.name)) === false) {
44820
+ throw({ code: 'WRONG_NETWORK' })
44821
+ }
44822
+ let signature = await this.signClient.request({
44823
+ topic: this.session.topic,
44824
+ chainId: `${blockchain.namespace}:${blockchain.networkId}`,
44825
+ request:{
44826
+ method: 'eth_signTypedData_v4',
44827
+ params: [account, JSON.stringify(message)],
44828
+ }
44829
+ });
44830
+ return signature
44831
+ } else if (typeof message === 'string') {
44832
+ const address = await this.account();
44833
+ const params = [ethers.ethers.utils.hexlify(ethers.ethers.utils.toUtf8Bytes(message)), address];
44834
+ const connectedChainId = await getConnectedChainId(this.signClient, this.session);
44835
+ const blockchain = Blockchains__default['default'].findById(connectedChainId);
44836
+ let signature = await this.signClient.request({
44837
+ topic: this.session.topic,
44838
+ chainId: `${blockchain.namespace}:${blockchain.networkId}`,
44839
+ request:{
44840
+ method: 'personal_sign',
44841
+ params
44842
+ }
44843
+ });
44844
+ if(typeof signature == 'object') {
44845
+ signature = ethers.ethers.utils.hexlify(signature);
44798
44846
  }
44799
- });
44800
- if(typeof signature == 'object') {
44801
- signature = ethers.ethers.utils.hexlify(signature);
44847
+ return signature
44802
44848
  }
44803
- return signature
44804
44849
  }
44805
44850
  } WalletConnectV2.__initStatic(); WalletConnectV2.__initStatic2();
44806
44851
 
@@ -45018,11 +45063,25 @@
45018
45063
  }
45019
45064
 
45020
45065
  async sign(message) {
45021
- await this.account();
45022
- let provider = new ethers.ethers.providers.Web3Provider(this.connector, 'any');
45023
- let signer = provider.getSigner(0);
45024
- let signature = await signer.signMessage(message);
45025
- return signature
45066
+ if(typeof message === 'object') {
45067
+ let provider = this.connector;
45068
+ let account = await this.account();
45069
+ if((await this.connectedTo(Blockchains__default['default'].findByNetworkId(message.domain.chainId).name)) === false) {
45070
+ throw({ code: 'WRONG_NETWORK' })
45071
+ }
45072
+ let signature = await provider.request({
45073
+ method: 'eth_signTypedData_v4',
45074
+ params: [account, message],
45075
+ from: account,
45076
+ });
45077
+ return signature
45078
+ } else if (typeof message === 'string') {
45079
+ await this.account();
45080
+ let provider = new ethers.ethers.providers.Web3Provider(this.connector, 'any');
45081
+ let signer = provider.getSigner(0);
45082
+ let signature = await signer.signMessage(message);
45083
+ return signature
45084
+ }
45026
45085
  }
45027
45086
  } WalletLink.__initStatic(); WalletLink.__initStatic2();
45028
45087
 
package/dist/umd/index.js CHANGED
@@ -600,11 +600,25 @@
600
600
  }
601
601
 
602
602
  async sign(message) {
603
- await this.account();
604
- let provider = new ethers.ethers.providers.Web3Provider(this.getProvider(), 'any');
605
- let signer = provider.getSigner(0);
606
- let signature = await signer.signMessage(message);
607
- return signature
603
+ if(typeof message === 'object') {
604
+ let provider = this.getProvider();
605
+ let account = await this.account();
606
+ if((await this.connectedTo(Blockchains__default['default'].findByNetworkId(message.domain.chainId).name)) === false) {
607
+ throw({ code: 'WRONG_NETWORK' })
608
+ }
609
+ let signature = await provider.request({
610
+ method: 'eth_signTypedData_v4',
611
+ params: [account, message],
612
+ from: account,
613
+ });
614
+ return signature
615
+ } else if (typeof message === 'string') {
616
+ await this.account();
617
+ let provider = new ethers.ethers.providers.Web3Provider(this.getProvider(), 'any');
618
+ let signer = provider.getSigner(0);
619
+ let signature = await signer.signMessage(message);
620
+ return signature
621
+ }
608
622
  }
609
623
  } WindowEthereum.__initStatic(); WindowEthereum.__initStatic2();
610
624
 
@@ -1420,13 +1434,26 @@
1420
1434
  }
1421
1435
 
1422
1436
  async sign(message) {
1423
- let blockchain = await this.connectedTo();
1424
- let address = await this.account();
1425
- const smartContractWallet = await getSmartContractWallet(blockchain, address);
1426
- if(smartContractWallet){ throw({ message: 'Smart contract wallets are not supported for signing!', code: "SMART_CONTRACT_WALLET_NOT_SUPPORTED" }) }
1427
- var params = [ethers.ethers.utils.toUtf8Bytes(message), address];
1428
- let signature = await this.connector.signPersonalMessage(params);
1429
- return signature
1437
+ if(typeof message === 'object') {
1438
+ let account = await this.account();
1439
+ if((await this.connectedTo(Blockchains__default['default'].findByNetworkId(message.domain.chainId).name)) === false) {
1440
+ throw({ code: 'WRONG_NETWORK' })
1441
+ }
1442
+ let signature = await this.connector.sendCustomRequest({
1443
+ jsonrpc: '2.0',
1444
+ method: 'eth_signTypedData_v4',
1445
+ params: [account, JSON.stringify(message)],
1446
+ });
1447
+ return signature
1448
+ } else if (typeof message === 'string') {
1449
+ let blockchain = await this.connectedTo();
1450
+ let address = await this.account();
1451
+ const smartContractWallet = await getSmartContractWallet(blockchain, address);
1452
+ if(smartContractWallet){ throw({ message: 'Smart contract wallets are not supported for signing!', code: "SMART_CONTRACT_WALLET_NOT_SUPPORTED" }) }
1453
+ var params = [ethers.ethers.utils.toUtf8Bytes(message), address];
1454
+ let signature = await this.connector.signPersonalMessage(params);
1455
+ return signature
1456
+ }
1430
1457
  }
1431
1458
  } WalletConnectV1.__initStatic(); WalletConnectV1.__initStatic2();
1432
1459
 
@@ -1598,6 +1625,7 @@
1598
1625
  const methods = [
1599
1626
  "eth_sendTransaction",
1600
1627
  "personal_sign",
1628
+ "eth_signTypedData_v4",
1601
1629
  "eth_chainId",
1602
1630
  "eth_accounts",
1603
1631
  "wallet_switchEthereumChain",
@@ -1821,22 +1849,39 @@
1821
1849
  }
1822
1850
 
1823
1851
  async sign(message) {
1824
- const address = await this.account();
1825
- const params = [ethers.ethers.utils.hexlify(ethers.ethers.utils.toUtf8Bytes(message)), address];
1826
- const connectedChainId = await getConnectedChainId(this.signClient, this.session);
1827
- const blockchain = Blockchains__default['default'].findById(connectedChainId);
1828
- let signature = await this.signClient.request({
1829
- topic: this.session.topic,
1830
- chainId: `${blockchain.namespace}:${blockchain.networkId}`,
1831
- request:{
1832
- method: 'personal_sign',
1833
- params
1852
+ if(typeof message === 'object') {
1853
+ let account = await this.account();
1854
+ const blockchain = Blockchains__default['default'].findByNetworkId(message.domain.chainId);
1855
+ if((await this.connectedTo(blockchain.name)) === false) {
1856
+ throw({ code: 'WRONG_NETWORK' })
1834
1857
  }
1835
- });
1836
- if(typeof signature == 'object') {
1837
- signature = ethers.ethers.utils.hexlify(signature);
1858
+ let signature = await this.signClient.request({
1859
+ topic: this.session.topic,
1860
+ chainId: `${blockchain.namespace}:${blockchain.networkId}`,
1861
+ request:{
1862
+ method: 'eth_signTypedData_v4',
1863
+ params: [account, JSON.stringify(message)],
1864
+ }
1865
+ });
1866
+ return signature
1867
+ } else if (typeof message === 'string') {
1868
+ const address = await this.account();
1869
+ const params = [ethers.ethers.utils.hexlify(ethers.ethers.utils.toUtf8Bytes(message)), address];
1870
+ const connectedChainId = await getConnectedChainId(this.signClient, this.session);
1871
+ const blockchain = Blockchains__default['default'].findById(connectedChainId);
1872
+ let signature = await this.signClient.request({
1873
+ topic: this.session.topic,
1874
+ chainId: `${blockchain.namespace}:${blockchain.networkId}`,
1875
+ request:{
1876
+ method: 'personal_sign',
1877
+ params
1878
+ }
1879
+ });
1880
+ if(typeof signature == 'object') {
1881
+ signature = ethers.ethers.utils.hexlify(signature);
1882
+ }
1883
+ return signature
1838
1884
  }
1839
- return signature
1840
1885
  }
1841
1886
  } WalletConnectV2.__initStatic(); WalletConnectV2.__initStatic2();
1842
1887
 
@@ -2054,11 +2099,25 @@
2054
2099
  }
2055
2100
 
2056
2101
  async sign(message) {
2057
- await this.account();
2058
- let provider = new ethers.ethers.providers.Web3Provider(this.connector, 'any');
2059
- let signer = provider.getSigner(0);
2060
- let signature = await signer.signMessage(message);
2061
- return signature
2102
+ if(typeof message === 'object') {
2103
+ let provider = this.connector;
2104
+ let account = await this.account();
2105
+ if((await this.connectedTo(Blockchains__default['default'].findByNetworkId(message.domain.chainId).name)) === false) {
2106
+ throw({ code: 'WRONG_NETWORK' })
2107
+ }
2108
+ let signature = await provider.request({
2109
+ method: 'eth_signTypedData_v4',
2110
+ params: [account, message],
2111
+ from: account,
2112
+ });
2113
+ return signature
2114
+ } else if (typeof message === 'string') {
2115
+ await this.account();
2116
+ let provider = new ethers.ethers.providers.Web3Provider(this.connector, 'any');
2117
+ let signer = provider.getSigner(0);
2118
+ let signature = await signer.signMessage(message);
2119
+ return signature
2120
+ }
2062
2121
  }
2063
2122
  } WalletLink.__initStatic(); WalletLink.__initStatic2();
2064
2123
 
@@ -1436,11 +1436,25 @@
1436
1436
  }
1437
1437
 
1438
1438
  async sign(message) {
1439
- await this.account();
1440
- let provider = new ethers.ethers.providers.Web3Provider(this.getProvider(), 'any');
1441
- let signer = provider.getSigner(0);
1442
- let signature = await signer.signMessage(message);
1443
- return signature
1439
+ if(typeof message === 'object') {
1440
+ let provider = this.getProvider();
1441
+ let account = await this.account();
1442
+ if((await this.connectedTo(Blockchains__default['default'].findByNetworkId(message.domain.chainId).name)) === false) {
1443
+ throw({ code: 'WRONG_NETWORK' })
1444
+ }
1445
+ let signature = await provider.request({
1446
+ method: 'eth_signTypedData_v4',
1447
+ params: [account, message],
1448
+ from: account,
1449
+ });
1450
+ return signature
1451
+ } else if (typeof message === 'string') {
1452
+ await this.account();
1453
+ let provider = new ethers.ethers.providers.Web3Provider(this.getProvider(), 'any');
1454
+ let signer = provider.getSigner(0);
1455
+ let signature = await signer.signMessage(message);
1456
+ return signature
1457
+ }
1444
1458
  }
1445
1459
  } WindowEthereum.__initStatic(); WindowEthereum.__initStatic2();
1446
1460
 
@@ -2256,13 +2270,26 @@
2256
2270
  }
2257
2271
 
2258
2272
  async sign(message) {
2259
- let blockchain = await this.connectedTo();
2260
- let address = await this.account();
2261
- const smartContractWallet = await getSmartContractWallet(blockchain, address);
2262
- if(smartContractWallet){ throw({ message: 'Smart contract wallets are not supported for signing!', code: "SMART_CONTRACT_WALLET_NOT_SUPPORTED" }) }
2263
- var params = [ethers.ethers.utils.toUtf8Bytes(message), address];
2264
- let signature = await this.connector.signPersonalMessage(params);
2265
- return signature
2273
+ if(typeof message === 'object') {
2274
+ let account = await this.account();
2275
+ if((await this.connectedTo(Blockchains__default['default'].findByNetworkId(message.domain.chainId).name)) === false) {
2276
+ throw({ code: 'WRONG_NETWORK' })
2277
+ }
2278
+ let signature = await this.connector.sendCustomRequest({
2279
+ jsonrpc: '2.0',
2280
+ method: 'eth_signTypedData_v4',
2281
+ params: [account, JSON.stringify(message)],
2282
+ });
2283
+ return signature
2284
+ } else if (typeof message === 'string') {
2285
+ let blockchain = await this.connectedTo();
2286
+ let address = await this.account();
2287
+ const smartContractWallet = await getSmartContractWallet(blockchain, address);
2288
+ if(smartContractWallet){ throw({ message: 'Smart contract wallets are not supported for signing!', code: "SMART_CONTRACT_WALLET_NOT_SUPPORTED" }) }
2289
+ var params = [ethers.ethers.utils.toUtf8Bytes(message), address];
2290
+ let signature = await this.connector.signPersonalMessage(params);
2291
+ return signature
2292
+ }
2266
2293
  }
2267
2294
  } WalletConnectV1.__initStatic(); WalletConnectV1.__initStatic2();
2268
2295
 
@@ -2434,6 +2461,7 @@
2434
2461
  const methods = [
2435
2462
  "eth_sendTransaction",
2436
2463
  "personal_sign",
2464
+ "eth_signTypedData_v4",
2437
2465
  "eth_chainId",
2438
2466
  "eth_accounts",
2439
2467
  "wallet_switchEthereumChain",
@@ -2657,22 +2685,39 @@
2657
2685
  }
2658
2686
 
2659
2687
  async sign(message) {
2660
- const address = await this.account();
2661
- const params = [ethers.ethers.utils.hexlify(ethers.ethers.utils.toUtf8Bytes(message)), address];
2662
- const connectedChainId = await getConnectedChainId(this.signClient, this.session);
2663
- const blockchain = Blockchains__default['default'].findById(connectedChainId);
2664
- let signature = await this.signClient.request({
2665
- topic: this.session.topic,
2666
- chainId: `${blockchain.namespace}:${blockchain.networkId}`,
2667
- request:{
2668
- method: 'personal_sign',
2669
- params
2688
+ if(typeof message === 'object') {
2689
+ let account = await this.account();
2690
+ const blockchain = Blockchains__default['default'].findByNetworkId(message.domain.chainId);
2691
+ if((await this.connectedTo(blockchain.name)) === false) {
2692
+ throw({ code: 'WRONG_NETWORK' })
2670
2693
  }
2671
- });
2672
- if(typeof signature == 'object') {
2673
- signature = ethers.ethers.utils.hexlify(signature);
2694
+ let signature = await this.signClient.request({
2695
+ topic: this.session.topic,
2696
+ chainId: `${blockchain.namespace}:${blockchain.networkId}`,
2697
+ request:{
2698
+ method: 'eth_signTypedData_v4',
2699
+ params: [account, JSON.stringify(message)],
2700
+ }
2701
+ });
2702
+ return signature
2703
+ } else if (typeof message === 'string') {
2704
+ const address = await this.account();
2705
+ const params = [ethers.ethers.utils.hexlify(ethers.ethers.utils.toUtf8Bytes(message)), address];
2706
+ const connectedChainId = await getConnectedChainId(this.signClient, this.session);
2707
+ const blockchain = Blockchains__default['default'].findById(connectedChainId);
2708
+ let signature = await this.signClient.request({
2709
+ topic: this.session.topic,
2710
+ chainId: `${blockchain.namespace}:${blockchain.networkId}`,
2711
+ request:{
2712
+ method: 'personal_sign',
2713
+ params
2714
+ }
2715
+ });
2716
+ if(typeof signature == 'object') {
2717
+ signature = ethers.ethers.utils.hexlify(signature);
2718
+ }
2719
+ return signature
2674
2720
  }
2675
- return signature
2676
2721
  }
2677
2722
  } WalletConnectV2.__initStatic(); WalletConnectV2.__initStatic2();
2678
2723
 
@@ -2890,11 +2935,25 @@
2890
2935
  }
2891
2936
 
2892
2937
  async sign(message) {
2893
- await this.account();
2894
- let provider = new ethers.ethers.providers.Web3Provider(this.connector, 'any');
2895
- let signer = provider.getSigner(0);
2896
- let signature = await signer.signMessage(message);
2897
- return signature
2938
+ if(typeof message === 'object') {
2939
+ let provider = this.connector;
2940
+ let account = await this.account();
2941
+ if((await this.connectedTo(Blockchains__default['default'].findByNetworkId(message.domain.chainId).name)) === false) {
2942
+ throw({ code: 'WRONG_NETWORK' })
2943
+ }
2944
+ let signature = await provider.request({
2945
+ method: 'eth_signTypedData_v4',
2946
+ params: [account, message],
2947
+ from: account,
2948
+ });
2949
+ return signature
2950
+ } else if (typeof message === 'string') {
2951
+ await this.account();
2952
+ let provider = new ethers.ethers.providers.Web3Provider(this.connector, 'any');
2953
+ let signer = provider.getSigner(0);
2954
+ let signature = await signer.signMessage(message);
2955
+ return signature
2956
+ }
2898
2957
  }
2899
2958
  } WalletLink.__initStatic(); WalletLink.__initStatic2();
2900
2959
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@depay/web3-wallets-evm",
3
3
  "moduleName": "Web3Wallets",
4
- "version": "15.15.4",
4
+ "version": "15.16.0",
5
5
  "description": "One-Stop-Shop JavaScript library to integrate various web3 crypto wallets and multiple blockchains at once with a single interface.",
6
6
  "main": "dist/umd/index.evm.js",
7
7
  "module": "dist/esm/index.evm.js",