@depay/web3-wallets-evm 15.15.4 → 15.16.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.
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
  }
@@ -42192,7 +42192,10 @@ class Transaction {
42192
42192
 
42193
42193
  getContractArguments() {
42194
42194
  let fragment = this.getContract().interface.fragments.find((fragment) => {
42195
- return fragment.name == this.method
42195
+ return(
42196
+ fragment.name == this.method &&
42197
+ fragment.inputs.length == this.params.length
42198
+ )
42196
42199
  });
42197
42200
 
42198
42201
  if(this.params instanceof Array) {
@@ -43563,11 +43566,25 @@ class WindowEthereum {
43563
43566
  }
43564
43567
 
43565
43568
  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
43569
+ if(typeof message === 'object') {
43570
+ let provider = this.getProvider();
43571
+ let account = await this.account();
43572
+ if((await this.connectedTo(Blockchains.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.providers.Web3Provider(this.getProvider(), 'any');
43584
+ let signer = provider.getSigner(0);
43585
+ let signature = await signer.signMessage(message);
43586
+ return signature
43587
+ }
43571
43588
  }
43572
43589
  } WindowEthereum.__initStatic(); WindowEthereum.__initStatic2();
43573
43590
 
@@ -44381,13 +44398,26 @@ class WalletConnectV1 {
44381
44398
  }
44382
44399
 
44383
44400
  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
44401
+ if(typeof message === 'object') {
44402
+ let account = await this.account();
44403
+ if((await this.connectedTo(Blockchains.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.utils.toUtf8Bytes(message), address];
44418
+ let signature = await this.connector.signPersonalMessage(params);
44419
+ return signature
44420
+ }
44391
44421
  }
44392
44422
  } WalletConnectV1.__initStatic(); WalletConnectV1.__initStatic2();
44393
44423
 
@@ -44559,6 +44589,7 @@ const getWalletConnectV2Config = ()=>{
44559
44589
  const methods = [
44560
44590
  "eth_sendTransaction",
44561
44591
  "personal_sign",
44592
+ "eth_signTypedData_v4",
44562
44593
  "eth_chainId",
44563
44594
  "eth_accounts",
44564
44595
  "wallet_switchEthereumChain",
@@ -44782,22 +44813,39 @@ class WalletConnectV2 {
44782
44813
  }
44783
44814
 
44784
44815
  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
44816
+ if(typeof message === 'object') {
44817
+ let account = await this.account();
44818
+ const blockchain = Blockchains.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.utils.hexlify(ethers.utils.toUtf8Bytes(message)), address];
44834
+ const connectedChainId = await getConnectedChainId(this.signClient, this.session);
44835
+ const blockchain = Blockchains.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.utils.hexlify(signature);
44795
44846
  }
44796
- });
44797
- if(typeof signature == 'object') {
44798
- signature = ethers.utils.hexlify(signature);
44847
+ return signature
44799
44848
  }
44800
- return signature
44801
44849
  }
44802
44850
  } WalletConnectV2.__initStatic(); WalletConnectV2.__initStatic2();
44803
44851
 
@@ -45015,11 +45063,25 @@ class WalletLink {
45015
45063
  }
45016
45064
 
45017
45065
  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
45066
+ if(typeof message === 'object') {
45067
+ let provider = this.connector;
45068
+ let account = await this.account();
45069
+ if((await this.connectedTo(Blockchains.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.providers.Web3Provider(this.connector, 'any');
45081
+ let signer = provider.getSigner(0);
45082
+ let signature = await signer.signMessage(message);
45083
+ return signature
45084
+ }
45023
45085
  }
45024
45086
  } WalletLink.__initStatic(); WalletLink.__initStatic2();
45025
45087
 
package/dist/esm/index.js CHANGED
@@ -63,7 +63,10 @@ class Transaction {
63
63
 
64
64
  getContractArguments() {
65
65
  let fragment = this.getContract().interface.fragments.find((fragment) => {
66
- return fragment.name == this.method
66
+ return(
67
+ fragment.name == this.method &&
68
+ fragment.inputs.length == this.params.length
69
+ )
67
70
  });
68
71
 
69
72
  if(this.params instanceof Array) {
@@ -598,11 +601,25 @@ class WindowEthereum {
598
601
  }
599
602
 
600
603
  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
604
+ if(typeof message === 'object') {
605
+ let provider = this.getProvider();
606
+ let account = await this.account();
607
+ if((await this.connectedTo(Blockchains.findByNetworkId(message.domain.chainId).name)) === false) {
608
+ throw({ code: 'WRONG_NETWORK' })
609
+ }
610
+ let signature = await provider.request({
611
+ method: 'eth_signTypedData_v4',
612
+ params: [account, message],
613
+ from: account,
614
+ });
615
+ return signature
616
+ } else if (typeof message === 'string') {
617
+ await this.account();
618
+ let provider = new ethers.providers.Web3Provider(this.getProvider(), 'any');
619
+ let signer = provider.getSigner(0);
620
+ let signature = await signer.signMessage(message);
621
+ return signature
622
+ }
606
623
  }
607
624
  } WindowEthereum.__initStatic(); WindowEthereum.__initStatic2();
608
625
 
@@ -1418,13 +1435,26 @@ class WalletConnectV1 {
1418
1435
  }
1419
1436
 
1420
1437
  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
1438
+ if(typeof message === 'object') {
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 this.connector.sendCustomRequest({
1444
+ jsonrpc: '2.0',
1445
+ method: 'eth_signTypedData_v4',
1446
+ params: [account, JSON.stringify(message)],
1447
+ });
1448
+ return signature
1449
+ } else if (typeof message === 'string') {
1450
+ let blockchain = await this.connectedTo();
1451
+ let address = await this.account();
1452
+ const smartContractWallet = await getSmartContractWallet(blockchain, address);
1453
+ if(smartContractWallet){ throw({ message: 'Smart contract wallets are not supported for signing!', code: "SMART_CONTRACT_WALLET_NOT_SUPPORTED" }) }
1454
+ var params = [ethers.utils.toUtf8Bytes(message), address];
1455
+ let signature = await this.connector.signPersonalMessage(params);
1456
+ return signature
1457
+ }
1428
1458
  }
1429
1459
  } WalletConnectV1.__initStatic(); WalletConnectV1.__initStatic2();
1430
1460
 
@@ -1596,6 +1626,7 @@ const getWalletConnectV2Config = ()=>{
1596
1626
  const methods = [
1597
1627
  "eth_sendTransaction",
1598
1628
  "personal_sign",
1629
+ "eth_signTypedData_v4",
1599
1630
  "eth_chainId",
1600
1631
  "eth_accounts",
1601
1632
  "wallet_switchEthereumChain",
@@ -1819,22 +1850,39 @@ class WalletConnectV2 {
1819
1850
  }
1820
1851
 
1821
1852
  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
1853
+ if(typeof message === 'object') {
1854
+ let account = await this.account();
1855
+ const blockchain = Blockchains.findByNetworkId(message.domain.chainId);
1856
+ if((await this.connectedTo(blockchain.name)) === false) {
1857
+ throw({ code: 'WRONG_NETWORK' })
1832
1858
  }
1833
- });
1834
- if(typeof signature == 'object') {
1835
- signature = ethers.utils.hexlify(signature);
1859
+ let signature = await this.signClient.request({
1860
+ topic: this.session.topic,
1861
+ chainId: `${blockchain.namespace}:${blockchain.networkId}`,
1862
+ request:{
1863
+ method: 'eth_signTypedData_v4',
1864
+ params: [account, JSON.stringify(message)],
1865
+ }
1866
+ });
1867
+ return signature
1868
+ } else if (typeof message === 'string') {
1869
+ const address = await this.account();
1870
+ const params = [ethers.utils.hexlify(ethers.utils.toUtf8Bytes(message)), address];
1871
+ const connectedChainId = await getConnectedChainId(this.signClient, this.session);
1872
+ const blockchain = Blockchains.findById(connectedChainId);
1873
+ let signature = await this.signClient.request({
1874
+ topic: this.session.topic,
1875
+ chainId: `${blockchain.namespace}:${blockchain.networkId}`,
1876
+ request:{
1877
+ method: 'personal_sign',
1878
+ params
1879
+ }
1880
+ });
1881
+ if(typeof signature == 'object') {
1882
+ signature = ethers.utils.hexlify(signature);
1883
+ }
1884
+ return signature
1836
1885
  }
1837
- return signature
1838
1886
  }
1839
1887
  } WalletConnectV2.__initStatic(); WalletConnectV2.__initStatic2();
1840
1888
 
@@ -2052,11 +2100,25 @@ class WalletLink {
2052
2100
  }
2053
2101
 
2054
2102
  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
2103
+ if(typeof message === 'object') {
2104
+ let provider = this.connector;
2105
+ let account = await this.account();
2106
+ if((await this.connectedTo(Blockchains.findByNetworkId(message.domain.chainId).name)) === false) {
2107
+ throw({ code: 'WRONG_NETWORK' })
2108
+ }
2109
+ let signature = await provider.request({
2110
+ method: 'eth_signTypedData_v4',
2111
+ params: [account, message],
2112
+ from: account,
2113
+ });
2114
+ return signature
2115
+ } else if (typeof message === 'string') {
2116
+ await this.account();
2117
+ let provider = new ethers.providers.Web3Provider(this.connector, 'any');
2118
+ let signer = provider.getSigner(0);
2119
+ let signature = await signer.signMessage(message);
2120
+ return signature
2121
+ }
2060
2122
  }
2061
2123
  } WalletLink.__initStatic(); WalletLink.__initStatic2();
2062
2124
 
@@ -63,7 +63,10 @@ class Transaction {
63
63
 
64
64
  getContractArguments() {
65
65
  let fragment = this.getContract().interface.fragments.find((fragment) => {
66
- return fragment.name == this.method
66
+ return(
67
+ fragment.name == this.method &&
68
+ fragment.inputs.length == this.params.length
69
+ )
67
70
  });
68
71
 
69
72
  if(this.params instanceof Array) {
@@ -1434,11 +1437,25 @@ class WindowEthereum {
1434
1437
  }
1435
1438
 
1436
1439
  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
1440
+ if(typeof message === 'object') {
1441
+ let provider = this.getProvider();
1442
+ let account = await this.account();
1443
+ if((await this.connectedTo(Blockchains.findByNetworkId(message.domain.chainId).name)) === false) {
1444
+ throw({ code: 'WRONG_NETWORK' })
1445
+ }
1446
+ let signature = await provider.request({
1447
+ method: 'eth_signTypedData_v4',
1448
+ params: [account, message],
1449
+ from: account,
1450
+ });
1451
+ return signature
1452
+ } else if (typeof message === 'string') {
1453
+ await this.account();
1454
+ let provider = new ethers.providers.Web3Provider(this.getProvider(), 'any');
1455
+ let signer = provider.getSigner(0);
1456
+ let signature = await signer.signMessage(message);
1457
+ return signature
1458
+ }
1442
1459
  }
1443
1460
  } WindowEthereum.__initStatic(); WindowEthereum.__initStatic2();
1444
1461
 
@@ -2254,13 +2271,26 @@ class WalletConnectV1 {
2254
2271
  }
2255
2272
 
2256
2273
  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
2274
+ if(typeof message === 'object') {
2275
+ let account = await this.account();
2276
+ if((await this.connectedTo(Blockchains.findByNetworkId(message.domain.chainId).name)) === false) {
2277
+ throw({ code: 'WRONG_NETWORK' })
2278
+ }
2279
+ let signature = await this.connector.sendCustomRequest({
2280
+ jsonrpc: '2.0',
2281
+ method: 'eth_signTypedData_v4',
2282
+ params: [account, JSON.stringify(message)],
2283
+ });
2284
+ return signature
2285
+ } else if (typeof message === 'string') {
2286
+ let blockchain = await this.connectedTo();
2287
+ let address = await this.account();
2288
+ const smartContractWallet = await getSmartContractWallet(blockchain, address);
2289
+ if(smartContractWallet){ throw({ message: 'Smart contract wallets are not supported for signing!', code: "SMART_CONTRACT_WALLET_NOT_SUPPORTED" }) }
2290
+ var params = [ethers.utils.toUtf8Bytes(message), address];
2291
+ let signature = await this.connector.signPersonalMessage(params);
2292
+ return signature
2293
+ }
2264
2294
  }
2265
2295
  } WalletConnectV1.__initStatic(); WalletConnectV1.__initStatic2();
2266
2296
 
@@ -2432,6 +2462,7 @@ const getWalletConnectV2Config = ()=>{
2432
2462
  const methods = [
2433
2463
  "eth_sendTransaction",
2434
2464
  "personal_sign",
2465
+ "eth_signTypedData_v4",
2435
2466
  "eth_chainId",
2436
2467
  "eth_accounts",
2437
2468
  "wallet_switchEthereumChain",
@@ -2655,22 +2686,39 @@ class WalletConnectV2 {
2655
2686
  }
2656
2687
 
2657
2688
  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
2689
+ if(typeof message === 'object') {
2690
+ let account = await this.account();
2691
+ const blockchain = Blockchains.findByNetworkId(message.domain.chainId);
2692
+ if((await this.connectedTo(blockchain.name)) === false) {
2693
+ throw({ code: 'WRONG_NETWORK' })
2668
2694
  }
2669
- });
2670
- if(typeof signature == 'object') {
2671
- signature = ethers.utils.hexlify(signature);
2695
+ let signature = await this.signClient.request({
2696
+ topic: this.session.topic,
2697
+ chainId: `${blockchain.namespace}:${blockchain.networkId}`,
2698
+ request:{
2699
+ method: 'eth_signTypedData_v4',
2700
+ params: [account, JSON.stringify(message)],
2701
+ }
2702
+ });
2703
+ return signature
2704
+ } else if (typeof message === 'string') {
2705
+ const address = await this.account();
2706
+ const params = [ethers.utils.hexlify(ethers.utils.toUtf8Bytes(message)), address];
2707
+ const connectedChainId = await getConnectedChainId(this.signClient, this.session);
2708
+ const blockchain = Blockchains.findById(connectedChainId);
2709
+ let signature = await this.signClient.request({
2710
+ topic: this.session.topic,
2711
+ chainId: `${blockchain.namespace}:${blockchain.networkId}`,
2712
+ request:{
2713
+ method: 'personal_sign',
2714
+ params
2715
+ }
2716
+ });
2717
+ if(typeof signature == 'object') {
2718
+ signature = ethers.utils.hexlify(signature);
2719
+ }
2720
+ return signature
2672
2721
  }
2673
- return signature
2674
2722
  }
2675
2723
  } WalletConnectV2.__initStatic(); WalletConnectV2.__initStatic2();
2676
2724
 
@@ -2888,11 +2936,25 @@ class WalletLink {
2888
2936
  }
2889
2937
 
2890
2938
  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
2939
+ if(typeof message === 'object') {
2940
+ let provider = this.connector;
2941
+ let account = await this.account();
2942
+ if((await this.connectedTo(Blockchains.findByNetworkId(message.domain.chainId).name)) === false) {
2943
+ throw({ code: 'WRONG_NETWORK' })
2944
+ }
2945
+ let signature = await provider.request({
2946
+ method: 'eth_signTypedData_v4',
2947
+ params: [account, message],
2948
+ from: account,
2949
+ });
2950
+ return signature
2951
+ } else if (typeof message === 'string') {
2952
+ await this.account();
2953
+ let provider = new ethers.providers.Web3Provider(this.connector, 'any');
2954
+ let signer = provider.getSigner(0);
2955
+ let signature = await signer.signMessage(message);
2956
+ return signature
2957
+ }
2896
2958
  }
2897
2959
  } WalletLink.__initStatic(); WalletLink.__initStatic2();
2898
2960
 
@@ -42195,7 +42195,10 @@
42195
42195
 
42196
42196
  getContractArguments() {
42197
42197
  let fragment = this.getContract().interface.fragments.find((fragment) => {
42198
- return fragment.name == this.method
42198
+ return(
42199
+ fragment.name == this.method &&
42200
+ fragment.inputs.length == this.params.length
42201
+ )
42199
42202
  });
42200
42203
 
42201
42204
  if(this.params instanceof Array) {
@@ -43566,11 +43569,25 @@
43566
43569
  }
43567
43570
 
43568
43571
  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
43572
+ if(typeof message === 'object') {
43573
+ let provider = this.getProvider();
43574
+ let account = await this.account();
43575
+ if((await this.connectedTo(Blockchains__default['default'].findByNetworkId(message.domain.chainId).name)) === false) {
43576
+ throw({ code: 'WRONG_NETWORK' })
43577
+ }
43578
+ let signature = await provider.request({
43579
+ method: 'eth_signTypedData_v4',
43580
+ params: [account, message],
43581
+ from: account,
43582
+ });
43583
+ return signature
43584
+ } else if (typeof message === 'string') {
43585
+ await this.account();
43586
+ let provider = new ethers.ethers.providers.Web3Provider(this.getProvider(), 'any');
43587
+ let signer = provider.getSigner(0);
43588
+ let signature = await signer.signMessage(message);
43589
+ return signature
43590
+ }
43574
43591
  }
43575
43592
  } WindowEthereum.__initStatic(); WindowEthereum.__initStatic2();
43576
43593
 
@@ -44384,13 +44401,26 @@
44384
44401
  }
44385
44402
 
44386
44403
  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
44404
+ if(typeof message === 'object') {
44405
+ let account = await this.account();
44406
+ if((await this.connectedTo(Blockchains__default['default'].findByNetworkId(message.domain.chainId).name)) === false) {
44407
+ throw({ code: 'WRONG_NETWORK' })
44408
+ }
44409
+ let signature = await this.connector.sendCustomRequest({
44410
+ jsonrpc: '2.0',
44411
+ method: 'eth_signTypedData_v4',
44412
+ params: [account, JSON.stringify(message)],
44413
+ });
44414
+ return signature
44415
+ } else if (typeof message === 'string') {
44416
+ let blockchain = await this.connectedTo();
44417
+ let address = await this.account();
44418
+ const smartContractWallet = await getSmartContractWallet(blockchain, address);
44419
+ if(smartContractWallet){ throw({ message: 'Smart contract wallets are not supported for signing!', code: "SMART_CONTRACT_WALLET_NOT_SUPPORTED" }) }
44420
+ var params = [ethers.ethers.utils.toUtf8Bytes(message), address];
44421
+ let signature = await this.connector.signPersonalMessage(params);
44422
+ return signature
44423
+ }
44394
44424
  }
44395
44425
  } WalletConnectV1.__initStatic(); WalletConnectV1.__initStatic2();
44396
44426
 
@@ -44562,6 +44592,7 @@
44562
44592
  const methods = [
44563
44593
  "eth_sendTransaction",
44564
44594
  "personal_sign",
44595
+ "eth_signTypedData_v4",
44565
44596
  "eth_chainId",
44566
44597
  "eth_accounts",
44567
44598
  "wallet_switchEthereumChain",
@@ -44785,22 +44816,39 @@
44785
44816
  }
44786
44817
 
44787
44818
  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
44819
+ if(typeof message === 'object') {
44820
+ let account = await this.account();
44821
+ const blockchain = Blockchains__default['default'].findByNetworkId(message.domain.chainId);
44822
+ if((await this.connectedTo(blockchain.name)) === false) {
44823
+ throw({ code: 'WRONG_NETWORK' })
44824
+ }
44825
+ let signature = await this.signClient.request({
44826
+ topic: this.session.topic,
44827
+ chainId: `${blockchain.namespace}:${blockchain.networkId}`,
44828
+ request:{
44829
+ method: 'eth_signTypedData_v4',
44830
+ params: [account, JSON.stringify(message)],
44831
+ }
44832
+ });
44833
+ return signature
44834
+ } else if (typeof message === 'string') {
44835
+ const address = await this.account();
44836
+ const params = [ethers.ethers.utils.hexlify(ethers.ethers.utils.toUtf8Bytes(message)), address];
44837
+ const connectedChainId = await getConnectedChainId(this.signClient, this.session);
44838
+ const blockchain = Blockchains__default['default'].findById(connectedChainId);
44839
+ let signature = await this.signClient.request({
44840
+ topic: this.session.topic,
44841
+ chainId: `${blockchain.namespace}:${blockchain.networkId}`,
44842
+ request:{
44843
+ method: 'personal_sign',
44844
+ params
44845
+ }
44846
+ });
44847
+ if(typeof signature == 'object') {
44848
+ signature = ethers.ethers.utils.hexlify(signature);
44798
44849
  }
44799
- });
44800
- if(typeof signature == 'object') {
44801
- signature = ethers.ethers.utils.hexlify(signature);
44850
+ return signature
44802
44851
  }
44803
- return signature
44804
44852
  }
44805
44853
  } WalletConnectV2.__initStatic(); WalletConnectV2.__initStatic2();
44806
44854
 
@@ -45018,11 +45066,25 @@
45018
45066
  }
45019
45067
 
45020
45068
  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
45069
+ if(typeof message === 'object') {
45070
+ let provider = this.connector;
45071
+ let account = await this.account();
45072
+ if((await this.connectedTo(Blockchains__default['default'].findByNetworkId(message.domain.chainId).name)) === false) {
45073
+ throw({ code: 'WRONG_NETWORK' })
45074
+ }
45075
+ let signature = await provider.request({
45076
+ method: 'eth_signTypedData_v4',
45077
+ params: [account, message],
45078
+ from: account,
45079
+ });
45080
+ return signature
45081
+ } else if (typeof message === 'string') {
45082
+ await this.account();
45083
+ let provider = new ethers.ethers.providers.Web3Provider(this.connector, 'any');
45084
+ let signer = provider.getSigner(0);
45085
+ let signature = await signer.signMessage(message);
45086
+ return signature
45087
+ }
45026
45088
  }
45027
45089
  } WalletLink.__initStatic(); WalletLink.__initStatic2();
45028
45090
 
package/dist/umd/index.js CHANGED
@@ -65,7 +65,10 @@
65
65
 
66
66
  getContractArguments() {
67
67
  let fragment = this.getContract().interface.fragments.find((fragment) => {
68
- return fragment.name == this.method
68
+ return(
69
+ fragment.name == this.method &&
70
+ fragment.inputs.length == this.params.length
71
+ )
69
72
  });
70
73
 
71
74
  if(this.params instanceof Array) {
@@ -600,11 +603,25 @@
600
603
  }
601
604
 
602
605
  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
606
+ if(typeof message === 'object') {
607
+ let provider = this.getProvider();
608
+ let account = await this.account();
609
+ if((await this.connectedTo(Blockchains__default['default'].findByNetworkId(message.domain.chainId).name)) === false) {
610
+ throw({ code: 'WRONG_NETWORK' })
611
+ }
612
+ let signature = await provider.request({
613
+ method: 'eth_signTypedData_v4',
614
+ params: [account, message],
615
+ from: account,
616
+ });
617
+ return signature
618
+ } else if (typeof message === 'string') {
619
+ await this.account();
620
+ let provider = new ethers.ethers.providers.Web3Provider(this.getProvider(), 'any');
621
+ let signer = provider.getSigner(0);
622
+ let signature = await signer.signMessage(message);
623
+ return signature
624
+ }
608
625
  }
609
626
  } WindowEthereum.__initStatic(); WindowEthereum.__initStatic2();
610
627
 
@@ -1420,13 +1437,26 @@
1420
1437
  }
1421
1438
 
1422
1439
  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
1440
+ if(typeof message === 'object') {
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 this.connector.sendCustomRequest({
1446
+ jsonrpc: '2.0',
1447
+ method: 'eth_signTypedData_v4',
1448
+ params: [account, JSON.stringify(message)],
1449
+ });
1450
+ return signature
1451
+ } else if (typeof message === 'string') {
1452
+ let blockchain = await this.connectedTo();
1453
+ let address = await this.account();
1454
+ const smartContractWallet = await getSmartContractWallet(blockchain, address);
1455
+ if(smartContractWallet){ throw({ message: 'Smart contract wallets are not supported for signing!', code: "SMART_CONTRACT_WALLET_NOT_SUPPORTED" }) }
1456
+ var params = [ethers.ethers.utils.toUtf8Bytes(message), address];
1457
+ let signature = await this.connector.signPersonalMessage(params);
1458
+ return signature
1459
+ }
1430
1460
  }
1431
1461
  } WalletConnectV1.__initStatic(); WalletConnectV1.__initStatic2();
1432
1462
 
@@ -1598,6 +1628,7 @@
1598
1628
  const methods = [
1599
1629
  "eth_sendTransaction",
1600
1630
  "personal_sign",
1631
+ "eth_signTypedData_v4",
1601
1632
  "eth_chainId",
1602
1633
  "eth_accounts",
1603
1634
  "wallet_switchEthereumChain",
@@ -1821,22 +1852,39 @@
1821
1852
  }
1822
1853
 
1823
1854
  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
1855
+ if(typeof message === 'object') {
1856
+ let account = await this.account();
1857
+ const blockchain = Blockchains__default['default'].findByNetworkId(message.domain.chainId);
1858
+ if((await this.connectedTo(blockchain.name)) === false) {
1859
+ throw({ code: 'WRONG_NETWORK' })
1834
1860
  }
1835
- });
1836
- if(typeof signature == 'object') {
1837
- signature = ethers.ethers.utils.hexlify(signature);
1861
+ let signature = await this.signClient.request({
1862
+ topic: this.session.topic,
1863
+ chainId: `${blockchain.namespace}:${blockchain.networkId}`,
1864
+ request:{
1865
+ method: 'eth_signTypedData_v4',
1866
+ params: [account, JSON.stringify(message)],
1867
+ }
1868
+ });
1869
+ return signature
1870
+ } else if (typeof message === 'string') {
1871
+ const address = await this.account();
1872
+ const params = [ethers.ethers.utils.hexlify(ethers.ethers.utils.toUtf8Bytes(message)), address];
1873
+ const connectedChainId = await getConnectedChainId(this.signClient, this.session);
1874
+ const blockchain = Blockchains__default['default'].findById(connectedChainId);
1875
+ let signature = await this.signClient.request({
1876
+ topic: this.session.topic,
1877
+ chainId: `${blockchain.namespace}:${blockchain.networkId}`,
1878
+ request:{
1879
+ method: 'personal_sign',
1880
+ params
1881
+ }
1882
+ });
1883
+ if(typeof signature == 'object') {
1884
+ signature = ethers.ethers.utils.hexlify(signature);
1885
+ }
1886
+ return signature
1838
1887
  }
1839
- return signature
1840
1888
  }
1841
1889
  } WalletConnectV2.__initStatic(); WalletConnectV2.__initStatic2();
1842
1890
 
@@ -2054,11 +2102,25 @@
2054
2102
  }
2055
2103
 
2056
2104
  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
2105
+ if(typeof message === 'object') {
2106
+ let provider = this.connector;
2107
+ let account = await this.account();
2108
+ if((await this.connectedTo(Blockchains__default['default'].findByNetworkId(message.domain.chainId).name)) === false) {
2109
+ throw({ code: 'WRONG_NETWORK' })
2110
+ }
2111
+ let signature = await provider.request({
2112
+ method: 'eth_signTypedData_v4',
2113
+ params: [account, message],
2114
+ from: account,
2115
+ });
2116
+ return signature
2117
+ } else if (typeof message === 'string') {
2118
+ await this.account();
2119
+ let provider = new ethers.ethers.providers.Web3Provider(this.connector, 'any');
2120
+ let signer = provider.getSigner(0);
2121
+ let signature = await signer.signMessage(message);
2122
+ return signature
2123
+ }
2062
2124
  }
2063
2125
  } WalletLink.__initStatic(); WalletLink.__initStatic2();
2064
2126
 
@@ -65,7 +65,10 @@
65
65
 
66
66
  getContractArguments() {
67
67
  let fragment = this.getContract().interface.fragments.find((fragment) => {
68
- return fragment.name == this.method
68
+ return(
69
+ fragment.name == this.method &&
70
+ fragment.inputs.length == this.params.length
71
+ )
69
72
  });
70
73
 
71
74
  if(this.params instanceof Array) {
@@ -1436,11 +1439,25 @@
1436
1439
  }
1437
1440
 
1438
1441
  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
1442
+ if(typeof message === 'object') {
1443
+ let provider = this.getProvider();
1444
+ let account = await this.account();
1445
+ if((await this.connectedTo(Blockchains__default['default'].findByNetworkId(message.domain.chainId).name)) === false) {
1446
+ throw({ code: 'WRONG_NETWORK' })
1447
+ }
1448
+ let signature = await provider.request({
1449
+ method: 'eth_signTypedData_v4',
1450
+ params: [account, message],
1451
+ from: account,
1452
+ });
1453
+ return signature
1454
+ } else if (typeof message === 'string') {
1455
+ await this.account();
1456
+ let provider = new ethers.ethers.providers.Web3Provider(this.getProvider(), 'any');
1457
+ let signer = provider.getSigner(0);
1458
+ let signature = await signer.signMessage(message);
1459
+ return signature
1460
+ }
1444
1461
  }
1445
1462
  } WindowEthereum.__initStatic(); WindowEthereum.__initStatic2();
1446
1463
 
@@ -2256,13 +2273,26 @@
2256
2273
  }
2257
2274
 
2258
2275
  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
2276
+ if(typeof message === 'object') {
2277
+ let account = await this.account();
2278
+ if((await this.connectedTo(Blockchains__default['default'].findByNetworkId(message.domain.chainId).name)) === false) {
2279
+ throw({ code: 'WRONG_NETWORK' })
2280
+ }
2281
+ let signature = await this.connector.sendCustomRequest({
2282
+ jsonrpc: '2.0',
2283
+ method: 'eth_signTypedData_v4',
2284
+ params: [account, JSON.stringify(message)],
2285
+ });
2286
+ return signature
2287
+ } else if (typeof message === 'string') {
2288
+ let blockchain = await this.connectedTo();
2289
+ let address = await this.account();
2290
+ const smartContractWallet = await getSmartContractWallet(blockchain, address);
2291
+ if(smartContractWallet){ throw({ message: 'Smart contract wallets are not supported for signing!', code: "SMART_CONTRACT_WALLET_NOT_SUPPORTED" }) }
2292
+ var params = [ethers.ethers.utils.toUtf8Bytes(message), address];
2293
+ let signature = await this.connector.signPersonalMessage(params);
2294
+ return signature
2295
+ }
2266
2296
  }
2267
2297
  } WalletConnectV1.__initStatic(); WalletConnectV1.__initStatic2();
2268
2298
 
@@ -2434,6 +2464,7 @@
2434
2464
  const methods = [
2435
2465
  "eth_sendTransaction",
2436
2466
  "personal_sign",
2467
+ "eth_signTypedData_v4",
2437
2468
  "eth_chainId",
2438
2469
  "eth_accounts",
2439
2470
  "wallet_switchEthereumChain",
@@ -2657,22 +2688,39 @@
2657
2688
  }
2658
2689
 
2659
2690
  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
2691
+ if(typeof message === 'object') {
2692
+ let account = await this.account();
2693
+ const blockchain = Blockchains__default['default'].findByNetworkId(message.domain.chainId);
2694
+ if((await this.connectedTo(blockchain.name)) === false) {
2695
+ throw({ code: 'WRONG_NETWORK' })
2670
2696
  }
2671
- });
2672
- if(typeof signature == 'object') {
2673
- signature = ethers.ethers.utils.hexlify(signature);
2697
+ let signature = await this.signClient.request({
2698
+ topic: this.session.topic,
2699
+ chainId: `${blockchain.namespace}:${blockchain.networkId}`,
2700
+ request:{
2701
+ method: 'eth_signTypedData_v4',
2702
+ params: [account, JSON.stringify(message)],
2703
+ }
2704
+ });
2705
+ return signature
2706
+ } else if (typeof message === 'string') {
2707
+ const address = await this.account();
2708
+ const params = [ethers.ethers.utils.hexlify(ethers.ethers.utils.toUtf8Bytes(message)), address];
2709
+ const connectedChainId = await getConnectedChainId(this.signClient, this.session);
2710
+ const blockchain = Blockchains__default['default'].findById(connectedChainId);
2711
+ let signature = await this.signClient.request({
2712
+ topic: this.session.topic,
2713
+ chainId: `${blockchain.namespace}:${blockchain.networkId}`,
2714
+ request:{
2715
+ method: 'personal_sign',
2716
+ params
2717
+ }
2718
+ });
2719
+ if(typeof signature == 'object') {
2720
+ signature = ethers.ethers.utils.hexlify(signature);
2721
+ }
2722
+ return signature
2674
2723
  }
2675
- return signature
2676
2724
  }
2677
2725
  } WalletConnectV2.__initStatic(); WalletConnectV2.__initStatic2();
2678
2726
 
@@ -2890,11 +2938,25 @@
2890
2938
  }
2891
2939
 
2892
2940
  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
2941
+ if(typeof message === 'object') {
2942
+ let provider = this.connector;
2943
+ let account = await this.account();
2944
+ if((await this.connectedTo(Blockchains__default['default'].findByNetworkId(message.domain.chainId).name)) === false) {
2945
+ throw({ code: 'WRONG_NETWORK' })
2946
+ }
2947
+ let signature = await provider.request({
2948
+ method: 'eth_signTypedData_v4',
2949
+ params: [account, message],
2950
+ from: account,
2951
+ });
2952
+ return signature
2953
+ } else if (typeof message === 'string') {
2954
+ await this.account();
2955
+ let provider = new ethers.ethers.providers.Web3Provider(this.connector, 'any');
2956
+ let signer = provider.getSigner(0);
2957
+ let signature = await signer.signMessage(message);
2958
+ return signature
2959
+ }
2898
2960
  }
2899
2961
  } WalletLink.__initStatic(); WalletLink.__initStatic2();
2900
2962
 
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.1",
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",