@depay/web3-wallets-evm 15.6.0 → 15.8.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 +22 -2
- package/dist/esm/index.evm.js +130 -32
- package/dist/esm/index.js +13 -4
- package/dist/esm/index.solana.js +128 -30
- package/dist/umd/index.evm.js +130 -32
- package/dist/umd/index.js +13 -4
- package/dist/umd/index.solana.js +128 -30
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -14,6 +14,9 @@ npm install --save @depay/web3-wallets
|
|
|
14
14
|
import { getWallets } from '@depay/web3-wallets'
|
|
15
15
|
|
|
16
16
|
let wallets = await getWallets()
|
|
17
|
+
|
|
18
|
+
// display wallets, have user pick one:
|
|
19
|
+
|
|
17
20
|
let wallet = wallets[0]
|
|
18
21
|
|
|
19
22
|
wallet.name // MetaMask
|
|
@@ -78,7 +81,8 @@ import { getWallets } from '@depay/web3-wallets-solana'
|
|
|
78
81
|
|
|
79
82
|
### getWallets
|
|
80
83
|
|
|
81
|
-
`getWallets`: Returns an array of available/connectable wallets.
|
|
84
|
+
`getWallets`: Returns an array of available/connectable wallets. Can wait up to 5 seconds because of checking existing WalletConnect connections.
|
|
85
|
+
Use `drip` to receive available wallets faster.
|
|
82
86
|
|
|
83
87
|
```javascript
|
|
84
88
|
let availableWallets = await getWallets();
|
|
@@ -87,7 +91,7 @@ let availableWallets = await getWallets();
|
|
|
87
91
|
|
|
88
92
|
```javascript
|
|
89
93
|
let availableWallets = await getWallets();
|
|
90
|
-
// [] no wallets detected. (you can still try WalletConnect or WalletLink)
|
|
94
|
+
// [] no wallets detected. (you can still try have user connec via WalletConnect or WalletLink)
|
|
91
95
|
```
|
|
92
96
|
|
|
93
97
|
```javascript
|
|
@@ -108,6 +112,22 @@ if(availableWallets.length == 1) {
|
|
|
108
112
|
}
|
|
109
113
|
```
|
|
110
114
|
|
|
115
|
+
#### drip
|
|
116
|
+
|
|
117
|
+
Pass a `drip` callback to `getWallets` to receive available wallet as soon as they are found, without waiting for all wallets to be checked:
|
|
118
|
+
|
|
119
|
+
```javascript
|
|
120
|
+
|
|
121
|
+
getWallets({
|
|
122
|
+
drip: (wallet)=>{
|
|
123
|
+
setAvaialbleWallets(
|
|
124
|
+
availableWallets.concat([wallet])
|
|
125
|
+
)
|
|
126
|
+
}
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
|
|
111
131
|
### Name
|
|
112
132
|
|
|
113
133
|
`name:string`: Returns the name of the wallet.
|
package/dist/esm/index.evm.js
CHANGED
|
@@ -22639,7 +22639,7 @@ SystemProgram.programId = new PublicKey('11111111111111111111111111111111'); //
|
|
|
22639
22639
|
// TODO: replace 300 with a proper constant for the size of the other
|
|
22640
22640
|
// Transaction fields
|
|
22641
22641
|
|
|
22642
|
-
var CHUNK_SIZE$
|
|
22642
|
+
var CHUNK_SIZE$2 = PACKET_DATA_SIZE - 300;
|
|
22643
22643
|
/**
|
|
22644
22644
|
* Program loader interface
|
|
22645
22645
|
*/
|
|
@@ -22868,7 +22868,7 @@ var Loader = /*#__PURE__*/function () {
|
|
|
22868
22868
|
return Loader;
|
|
22869
22869
|
}();
|
|
22870
22870
|
|
|
22871
|
-
Loader.chunkSize = CHUNK_SIZE$
|
|
22871
|
+
Loader.chunkSize = CHUNK_SIZE$2;
|
|
22872
22872
|
var BPF_LOADER_PROGRAM_ID = new PublicKey('BPFLoader2111111111111111111111111111111111');
|
|
22873
22873
|
/**
|
|
22874
22874
|
* Factory class for transactions to interact with a program loader
|
|
@@ -40700,8 +40700,27 @@ lib.u8;
|
|
|
40700
40700
|
lib.vec;
|
|
40701
40701
|
lib.vecU8;
|
|
40702
40702
|
|
|
40703
|
-
|
|
40704
|
-
|
|
40703
|
+
let _window;
|
|
40704
|
+
|
|
40705
|
+
let getWindow = () => {
|
|
40706
|
+
if(_window) { return _window }
|
|
40707
|
+
if (typeof global == 'object') {
|
|
40708
|
+
_window = global;
|
|
40709
|
+
} else {
|
|
40710
|
+
_window = window;
|
|
40711
|
+
}
|
|
40712
|
+
return _window
|
|
40713
|
+
};
|
|
40714
|
+
|
|
40715
|
+
const getConfiguration = () =>{
|
|
40716
|
+
if(getWindow()._Web3ClientConfiguration === undefined) {
|
|
40717
|
+
getWindow()._Web3ClientConfiguration = {};
|
|
40718
|
+
}
|
|
40719
|
+
return getWindow()._Web3ClientConfiguration
|
|
40720
|
+
};
|
|
40721
|
+
|
|
40722
|
+
const BATCH_INTERVAL$1 = 10;
|
|
40723
|
+
const CHUNK_SIZE$1 = 99;
|
|
40705
40724
|
|
|
40706
40725
|
class StaticJsonRpcBatchProvider extends ethers.providers.JsonRpcProvider {
|
|
40707
40726
|
|
|
@@ -40711,6 +40730,7 @@ class StaticJsonRpcBatchProvider extends ethers.providers.JsonRpcProvider {
|
|
|
40711
40730
|
this._endpoint = url;
|
|
40712
40731
|
this._endpoints = endpoints;
|
|
40713
40732
|
this._failover = failover;
|
|
40733
|
+
this._pendingBatch = [];
|
|
40714
40734
|
}
|
|
40715
40735
|
|
|
40716
40736
|
detectNetwork() {
|
|
@@ -40779,19 +40799,19 @@ class StaticJsonRpcBatchProvider extends ethers.providers.JsonRpcProvider {
|
|
|
40779
40799
|
// Get the current batch and clear it, so new requests
|
|
40780
40800
|
// go into the next batch
|
|
40781
40801
|
const batch = this._pendingBatch;
|
|
40782
|
-
this._pendingBatch =
|
|
40802
|
+
this._pendingBatch = [];
|
|
40783
40803
|
this._pendingBatchAggregator = null;
|
|
40784
40804
|
// Prepare Chunks of CHUNK_SIZE
|
|
40785
40805
|
const chunks = [];
|
|
40786
|
-
for (let i = 0; i < Math.ceil(batch.length / CHUNK_SIZE); i++) {
|
|
40787
|
-
chunks[i] = batch.slice(i*CHUNK_SIZE, (i+1)*CHUNK_SIZE);
|
|
40806
|
+
for (let i = 0; i < Math.ceil(batch.length / CHUNK_SIZE$1); i++) {
|
|
40807
|
+
chunks[i] = batch.slice(i*CHUNK_SIZE$1, (i+1)*CHUNK_SIZE$1);
|
|
40788
40808
|
}
|
|
40789
40809
|
chunks.forEach((chunk)=>{
|
|
40790
40810
|
// Get the request as an array of requests
|
|
40791
40811
|
chunk.map((inflight) => inflight.request);
|
|
40792
40812
|
return this.requestChunk(chunk, this._endpoint)
|
|
40793
40813
|
});
|
|
40794
|
-
}, BATCH_INTERVAL);
|
|
40814
|
+
}, getConfiguration().batchInterval || BATCH_INTERVAL$1);
|
|
40795
40815
|
}
|
|
40796
40816
|
|
|
40797
40817
|
return promise
|
|
@@ -40799,18 +40819,6 @@ class StaticJsonRpcBatchProvider extends ethers.providers.JsonRpcProvider {
|
|
|
40799
40819
|
|
|
40800
40820
|
}
|
|
40801
40821
|
|
|
40802
|
-
let _window;
|
|
40803
|
-
|
|
40804
|
-
let getWindow = () => {
|
|
40805
|
-
if(_window) { return _window }
|
|
40806
|
-
if (typeof global == 'object') {
|
|
40807
|
-
_window = global;
|
|
40808
|
-
} else {
|
|
40809
|
-
_window = window;
|
|
40810
|
-
}
|
|
40811
|
-
return _window
|
|
40812
|
-
};
|
|
40813
|
-
|
|
40814
40822
|
const getAllProviders$1 = ()=> {
|
|
40815
40823
|
if(getWindow()._Web3ClientProviders == undefined) {
|
|
40816
40824
|
getWindow()._Web3ClientProviders = {};
|
|
@@ -40919,14 +40927,96 @@ var EVM = {
|
|
|
40919
40927
|
setProvider: setProvider$2,
|
|
40920
40928
|
};
|
|
40921
40929
|
|
|
40930
|
+
const BATCH_INTERVAL = 10;
|
|
40931
|
+
const CHUNK_SIZE = 99;
|
|
40932
|
+
|
|
40922
40933
|
class StaticJsonRpcSequentialProvider extends Connection {
|
|
40923
40934
|
|
|
40924
40935
|
constructor(url, network, endpoints, failover) {
|
|
40925
40936
|
super(url);
|
|
40937
|
+
this._provider = new Connection(url);
|
|
40926
40938
|
this._network = network;
|
|
40927
40939
|
this._endpoint = url;
|
|
40928
40940
|
this._endpoints = endpoints;
|
|
40929
40941
|
this._failover = failover;
|
|
40942
|
+
this._pendingBatch = [];
|
|
40943
|
+
this._rpcRequest = this._rpcRequestReplacement.bind(this);
|
|
40944
|
+
}
|
|
40945
|
+
|
|
40946
|
+
requestChunk(chunk) {
|
|
40947
|
+
|
|
40948
|
+
const batch = chunk.map((inflight) => inflight.request);
|
|
40949
|
+
|
|
40950
|
+
return this._provider._rpcBatchRequest(batch)
|
|
40951
|
+
.then((result) => {
|
|
40952
|
+
// For each result, feed it to the correct Promise, depending
|
|
40953
|
+
// on whether it was a success or error
|
|
40954
|
+
chunk.forEach((inflightRequest, index) => {
|
|
40955
|
+
const payload = result[index];
|
|
40956
|
+
if (payload.error) {
|
|
40957
|
+
const error = new Error(payload.error.message);
|
|
40958
|
+
error.code = payload.error.code;
|
|
40959
|
+
error.data = payload.error.data;
|
|
40960
|
+
inflightRequest.reject(error);
|
|
40961
|
+
} else {
|
|
40962
|
+
inflightRequest.resolve(payload);
|
|
40963
|
+
}
|
|
40964
|
+
});
|
|
40965
|
+
}).catch((error) => {
|
|
40966
|
+
if(error && [
|
|
40967
|
+
'Failed to fetch', '504', '503', '502', '500', '429', '426', '422', '413', '409', '408', '406', '405', '404', '403', '402', '401', '400'
|
|
40968
|
+
].some((errorType)=>error.toString().match(errorType))) {
|
|
40969
|
+
const index = this._endpoints.indexOf(this._endpoint)+1;
|
|
40970
|
+
this._endpoint = index >= this._endpoints.length ? this._endpoints[0] : this._endpoints[index];
|
|
40971
|
+
this._provider = new Connection(this._endpoint);
|
|
40972
|
+
this.requestChunk(chunk);
|
|
40973
|
+
} else {
|
|
40974
|
+
chunk.forEach((inflightRequest) => {
|
|
40975
|
+
inflightRequest.reject(error);
|
|
40976
|
+
});
|
|
40977
|
+
}
|
|
40978
|
+
})
|
|
40979
|
+
}
|
|
40980
|
+
|
|
40981
|
+
_rpcRequestReplacement(methodName, args) {
|
|
40982
|
+
|
|
40983
|
+
const request = { methodName, args };
|
|
40984
|
+
|
|
40985
|
+
if (this._pendingBatch == null) {
|
|
40986
|
+
this._pendingBatch = [];
|
|
40987
|
+
}
|
|
40988
|
+
|
|
40989
|
+
const inflightRequest = { request, resolve: null, reject: null };
|
|
40990
|
+
|
|
40991
|
+
const promise = new Promise((resolve, reject) => {
|
|
40992
|
+
inflightRequest.resolve = resolve;
|
|
40993
|
+
inflightRequest.reject = reject;
|
|
40994
|
+
});
|
|
40995
|
+
|
|
40996
|
+
this._pendingBatch.push(inflightRequest);
|
|
40997
|
+
|
|
40998
|
+
if (!this._pendingBatchAggregator) {
|
|
40999
|
+
// Schedule batch for next event loop + short duration
|
|
41000
|
+
this._pendingBatchAggregator = setTimeout(() => {
|
|
41001
|
+
// Get the current batch and clear it, so new requests
|
|
41002
|
+
// go into the next batch
|
|
41003
|
+
const batch = this._pendingBatch;
|
|
41004
|
+
this._pendingBatch = [];
|
|
41005
|
+
this._pendingBatchAggregator = null;
|
|
41006
|
+
// Prepare Chunks of CHUNK_SIZE
|
|
41007
|
+
const chunks = [];
|
|
41008
|
+
for (let i = 0; i < Math.ceil(batch.length / CHUNK_SIZE); i++) {
|
|
41009
|
+
chunks[i] = batch.slice(i*CHUNK_SIZE, (i+1)*CHUNK_SIZE);
|
|
41010
|
+
}
|
|
41011
|
+
chunks.forEach((chunk)=>{
|
|
41012
|
+
// Get the request as an array of requests
|
|
41013
|
+
chunk.map((inflight) => inflight.request);
|
|
41014
|
+
return this.requestChunk(chunk)
|
|
41015
|
+
});
|
|
41016
|
+
}, getConfiguration().batchInterval || BATCH_INTERVAL);
|
|
41017
|
+
}
|
|
41018
|
+
|
|
41019
|
+
return promise
|
|
40930
41020
|
}
|
|
40931
41021
|
}
|
|
40932
41022
|
|
|
@@ -40949,7 +41039,13 @@ const setProvider$1 = (blockchain, provider)=> {
|
|
|
40949
41039
|
const setProviderEndpoints$1 = async (blockchain, endpoints, detectFastest = true)=> {
|
|
40950
41040
|
|
|
40951
41041
|
getAllProviders()[blockchain] = endpoints.map((endpoint, index)=>
|
|
40952
|
-
new StaticJsonRpcSequentialProvider(endpoint, blockchain, endpoints)
|
|
41042
|
+
new StaticJsonRpcSequentialProvider(endpoint, blockchain, endpoints, ()=>{
|
|
41043
|
+
if(getAllProviders()[blockchain].length === 1) {
|
|
41044
|
+
setProviderEndpoints$1(blockchain, endpoints, detectFastest);
|
|
41045
|
+
} else {
|
|
41046
|
+
getAllProviders()[blockchain].splice(index, 1);
|
|
41047
|
+
}
|
|
41048
|
+
})
|
|
40953
41049
|
);
|
|
40954
41050
|
|
|
40955
41051
|
let provider;
|
|
@@ -41134,13 +41230,6 @@ let cache = function ({ call, key, expires = 0 }) {
|
|
|
41134
41230
|
})
|
|
41135
41231
|
};
|
|
41136
41232
|
|
|
41137
|
-
const getConfiguration = () =>{
|
|
41138
|
-
if(getWindow()._Web3ClientConfiguration === undefined) {
|
|
41139
|
-
getWindow()._Web3ClientConfiguration = {};
|
|
41140
|
-
}
|
|
41141
|
-
return getWindow()._Web3ClientConfiguration
|
|
41142
|
-
};
|
|
41143
|
-
|
|
41144
41233
|
let paramsToContractArgs = ({ contract, method, params }) => {
|
|
41145
41234
|
let fragment = contract.interface.fragments.find((fragment) => {
|
|
41146
41235
|
return fragment.name == method
|
|
@@ -42182,7 +42271,10 @@ const getPlainInstance = ()=>{
|
|
|
42182
42271
|
const isConnected = ()=>{
|
|
42183
42272
|
return new Promise(async(resolve, reject)=>{
|
|
42184
42273
|
|
|
42185
|
-
setTimeout(()=>{
|
|
42274
|
+
setTimeout(()=>{
|
|
42275
|
+
delete localStorage['walletconnect'];
|
|
42276
|
+
resolve(false);
|
|
42277
|
+
}, 5000);
|
|
42186
42278
|
|
|
42187
42279
|
if(!localStorage['walletconnect'] || JSON.parse(localStorage['walletconnect']).handshakeTopic.length == 0) {
|
|
42188
42280
|
delete localStorage['walletconnect'];
|
|
@@ -42668,10 +42760,14 @@ var wallets = {
|
|
|
42668
42760
|
WalletLink
|
|
42669
42761
|
};
|
|
42670
42762
|
|
|
42671
|
-
const getWallets = async()=>{
|
|
42763
|
+
const getWallets = async(args)=>{
|
|
42764
|
+
|
|
42765
|
+
let drip = (args && typeof args.drip === 'function') ? args.drip : undefined;
|
|
42672
42766
|
|
|
42673
42767
|
let availableWallets = await Promise.all(
|
|
42768
|
+
|
|
42674
42769
|
Object.keys(wallets).map(
|
|
42770
|
+
|
|
42675
42771
|
async(key)=>{
|
|
42676
42772
|
|
|
42677
42773
|
let wallet = wallets[key];
|
|
@@ -42681,16 +42777,18 @@ const getWallets = async()=>{
|
|
|
42681
42777
|
|
|
42682
42778
|
if(wallet.getConnectedInstance) {
|
|
42683
42779
|
instance = await wallet.getConnectedInstance();
|
|
42780
|
+
if(drip) { drip(instance); }
|
|
42684
42781
|
return instance
|
|
42685
42782
|
} else {
|
|
42783
|
+
if(drip) { drip(wallet); }
|
|
42686
42784
|
return new wallet
|
|
42687
|
-
}
|
|
42785
|
+
}
|
|
42688
42786
|
}
|
|
42689
42787
|
}
|
|
42690
42788
|
)
|
|
42691
42789
|
);
|
|
42692
42790
|
|
|
42693
|
-
return availableWallets.filter(
|
|
42791
|
+
return availableWallets.filter(Boolean)
|
|
42694
42792
|
};
|
|
42695
42793
|
|
|
42696
42794
|
const supported = [
|
package/dist/esm/index.js
CHANGED
|
@@ -839,7 +839,10 @@ const getPlainInstance = ()=>{
|
|
|
839
839
|
const isConnected = ()=>{
|
|
840
840
|
return new Promise(async(resolve, reject)=>{
|
|
841
841
|
|
|
842
|
-
setTimeout(()=>{
|
|
842
|
+
setTimeout(()=>{
|
|
843
|
+
delete localStorage['walletconnect'];
|
|
844
|
+
resolve(false);
|
|
845
|
+
}, 5000);
|
|
843
846
|
|
|
844
847
|
if(!localStorage['walletconnect'] || JSON.parse(localStorage['walletconnect']).handshakeTopic.length == 0) {
|
|
845
848
|
delete localStorage['walletconnect'];
|
|
@@ -1325,10 +1328,14 @@ var wallets = {
|
|
|
1325
1328
|
WalletLink
|
|
1326
1329
|
};
|
|
1327
1330
|
|
|
1328
|
-
const getWallets = async()=>{
|
|
1331
|
+
const getWallets = async(args)=>{
|
|
1332
|
+
|
|
1333
|
+
let drip = (args && typeof args.drip === 'function') ? args.drip : undefined;
|
|
1329
1334
|
|
|
1330
1335
|
let availableWallets = await Promise.all(
|
|
1336
|
+
|
|
1331
1337
|
Object.keys(wallets).map(
|
|
1338
|
+
|
|
1332
1339
|
async(key)=>{
|
|
1333
1340
|
|
|
1334
1341
|
let wallet = wallets[key];
|
|
@@ -1338,16 +1345,18 @@ const getWallets = async()=>{
|
|
|
1338
1345
|
|
|
1339
1346
|
if(wallet.getConnectedInstance) {
|
|
1340
1347
|
instance = await wallet.getConnectedInstance();
|
|
1348
|
+
if(drip) { drip(instance); }
|
|
1341
1349
|
return instance
|
|
1342
1350
|
} else {
|
|
1351
|
+
if(drip) { drip(wallet); }
|
|
1343
1352
|
return new wallet
|
|
1344
|
-
}
|
|
1353
|
+
}
|
|
1345
1354
|
}
|
|
1346
1355
|
}
|
|
1347
1356
|
)
|
|
1348
1357
|
);
|
|
1349
1358
|
|
|
1350
|
-
return availableWallets.filter(
|
|
1359
|
+
return availableWallets.filter(Boolean)
|
|
1351
1360
|
};
|
|
1352
1361
|
|
|
1353
1362
|
const supported = [
|
package/dist/esm/index.solana.js
CHANGED
|
@@ -9,8 +9,27 @@ let supported$2 = ['solana'];
|
|
|
9
9
|
supported$2.evm = [];
|
|
10
10
|
supported$2.solana = ['solana'];
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
let _window;
|
|
13
|
+
|
|
14
|
+
let getWindow = () => {
|
|
15
|
+
if(_window) { return _window }
|
|
16
|
+
if (typeof global == 'object') {
|
|
17
|
+
_window = global;
|
|
18
|
+
} else {
|
|
19
|
+
_window = window;
|
|
20
|
+
}
|
|
21
|
+
return _window
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const getConfiguration = () =>{
|
|
25
|
+
if(getWindow()._Web3ClientConfiguration === undefined) {
|
|
26
|
+
getWindow()._Web3ClientConfiguration = {};
|
|
27
|
+
}
|
|
28
|
+
return getWindow()._Web3ClientConfiguration
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const BATCH_INTERVAL$1 = 10;
|
|
32
|
+
const CHUNK_SIZE$1 = 99;
|
|
14
33
|
|
|
15
34
|
class StaticJsonRpcBatchProvider extends ethers.providers.JsonRpcProvider {
|
|
16
35
|
|
|
@@ -20,6 +39,7 @@ class StaticJsonRpcBatchProvider extends ethers.providers.JsonRpcProvider {
|
|
|
20
39
|
this._endpoint = url;
|
|
21
40
|
this._endpoints = endpoints;
|
|
22
41
|
this._failover = failover;
|
|
42
|
+
this._pendingBatch = [];
|
|
23
43
|
}
|
|
24
44
|
|
|
25
45
|
detectNetwork() {
|
|
@@ -88,19 +108,19 @@ class StaticJsonRpcBatchProvider extends ethers.providers.JsonRpcProvider {
|
|
|
88
108
|
// Get the current batch and clear it, so new requests
|
|
89
109
|
// go into the next batch
|
|
90
110
|
const batch = this._pendingBatch;
|
|
91
|
-
this._pendingBatch =
|
|
111
|
+
this._pendingBatch = [];
|
|
92
112
|
this._pendingBatchAggregator = null;
|
|
93
113
|
// Prepare Chunks of CHUNK_SIZE
|
|
94
114
|
const chunks = [];
|
|
95
|
-
for (let i = 0; i < Math.ceil(batch.length / CHUNK_SIZE); i++) {
|
|
96
|
-
chunks[i] = batch.slice(i*CHUNK_SIZE, (i+1)*CHUNK_SIZE);
|
|
115
|
+
for (let i = 0; i < Math.ceil(batch.length / CHUNK_SIZE$1); i++) {
|
|
116
|
+
chunks[i] = batch.slice(i*CHUNK_SIZE$1, (i+1)*CHUNK_SIZE$1);
|
|
97
117
|
}
|
|
98
118
|
chunks.forEach((chunk)=>{
|
|
99
119
|
// Get the request as an array of requests
|
|
100
120
|
chunk.map((inflight) => inflight.request);
|
|
101
121
|
return this.requestChunk(chunk, this._endpoint)
|
|
102
122
|
});
|
|
103
|
-
}, BATCH_INTERVAL);
|
|
123
|
+
}, getConfiguration().batchInterval || BATCH_INTERVAL$1);
|
|
104
124
|
}
|
|
105
125
|
|
|
106
126
|
return promise
|
|
@@ -108,18 +128,6 @@ class StaticJsonRpcBatchProvider extends ethers.providers.JsonRpcProvider {
|
|
|
108
128
|
|
|
109
129
|
}
|
|
110
130
|
|
|
111
|
-
let _window;
|
|
112
|
-
|
|
113
|
-
let getWindow = () => {
|
|
114
|
-
if(_window) { return _window }
|
|
115
|
-
if (typeof global == 'object') {
|
|
116
|
-
_window = global;
|
|
117
|
-
} else {
|
|
118
|
-
_window = window;
|
|
119
|
-
}
|
|
120
|
-
return _window
|
|
121
|
-
};
|
|
122
|
-
|
|
123
131
|
const getAllProviders$1 = ()=> {
|
|
124
132
|
if(getWindow()._Web3ClientProviders == undefined) {
|
|
125
133
|
getWindow()._Web3ClientProviders = {};
|
|
@@ -228,14 +236,96 @@ var EVM = {
|
|
|
228
236
|
setProvider: setProvider$2,
|
|
229
237
|
};
|
|
230
238
|
|
|
239
|
+
const BATCH_INTERVAL = 10;
|
|
240
|
+
const CHUNK_SIZE = 99;
|
|
241
|
+
|
|
231
242
|
class StaticJsonRpcSequentialProvider extends Connection {
|
|
232
243
|
|
|
233
244
|
constructor(url, network, endpoints, failover) {
|
|
234
245
|
super(url);
|
|
246
|
+
this._provider = new Connection(url);
|
|
235
247
|
this._network = network;
|
|
236
248
|
this._endpoint = url;
|
|
237
249
|
this._endpoints = endpoints;
|
|
238
250
|
this._failover = failover;
|
|
251
|
+
this._pendingBatch = [];
|
|
252
|
+
this._rpcRequest = this._rpcRequestReplacement.bind(this);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
requestChunk(chunk) {
|
|
256
|
+
|
|
257
|
+
const batch = chunk.map((inflight) => inflight.request);
|
|
258
|
+
|
|
259
|
+
return this._provider._rpcBatchRequest(batch)
|
|
260
|
+
.then((result) => {
|
|
261
|
+
// For each result, feed it to the correct Promise, depending
|
|
262
|
+
// on whether it was a success or error
|
|
263
|
+
chunk.forEach((inflightRequest, index) => {
|
|
264
|
+
const payload = result[index];
|
|
265
|
+
if (payload.error) {
|
|
266
|
+
const error = new Error(payload.error.message);
|
|
267
|
+
error.code = payload.error.code;
|
|
268
|
+
error.data = payload.error.data;
|
|
269
|
+
inflightRequest.reject(error);
|
|
270
|
+
} else {
|
|
271
|
+
inflightRequest.resolve(payload);
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
}).catch((error) => {
|
|
275
|
+
if(error && [
|
|
276
|
+
'Failed to fetch', '504', '503', '502', '500', '429', '426', '422', '413', '409', '408', '406', '405', '404', '403', '402', '401', '400'
|
|
277
|
+
].some((errorType)=>error.toString().match(errorType))) {
|
|
278
|
+
const index = this._endpoints.indexOf(this._endpoint)+1;
|
|
279
|
+
this._endpoint = index >= this._endpoints.length ? this._endpoints[0] : this._endpoints[index];
|
|
280
|
+
this._provider = new Connection(this._endpoint);
|
|
281
|
+
this.requestChunk(chunk);
|
|
282
|
+
} else {
|
|
283
|
+
chunk.forEach((inflightRequest) => {
|
|
284
|
+
inflightRequest.reject(error);
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
})
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
_rpcRequestReplacement(methodName, args) {
|
|
291
|
+
|
|
292
|
+
const request = { methodName, args };
|
|
293
|
+
|
|
294
|
+
if (this._pendingBatch == null) {
|
|
295
|
+
this._pendingBatch = [];
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
const inflightRequest = { request, resolve: null, reject: null };
|
|
299
|
+
|
|
300
|
+
const promise = new Promise((resolve, reject) => {
|
|
301
|
+
inflightRequest.resolve = resolve;
|
|
302
|
+
inflightRequest.reject = reject;
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
this._pendingBatch.push(inflightRequest);
|
|
306
|
+
|
|
307
|
+
if (!this._pendingBatchAggregator) {
|
|
308
|
+
// Schedule batch for next event loop + short duration
|
|
309
|
+
this._pendingBatchAggregator = setTimeout(() => {
|
|
310
|
+
// Get the current batch and clear it, so new requests
|
|
311
|
+
// go into the next batch
|
|
312
|
+
const batch = this._pendingBatch;
|
|
313
|
+
this._pendingBatch = [];
|
|
314
|
+
this._pendingBatchAggregator = null;
|
|
315
|
+
// Prepare Chunks of CHUNK_SIZE
|
|
316
|
+
const chunks = [];
|
|
317
|
+
for (let i = 0; i < Math.ceil(batch.length / CHUNK_SIZE); i++) {
|
|
318
|
+
chunks[i] = batch.slice(i*CHUNK_SIZE, (i+1)*CHUNK_SIZE);
|
|
319
|
+
}
|
|
320
|
+
chunks.forEach((chunk)=>{
|
|
321
|
+
// Get the request as an array of requests
|
|
322
|
+
chunk.map((inflight) => inflight.request);
|
|
323
|
+
return this.requestChunk(chunk)
|
|
324
|
+
});
|
|
325
|
+
}, getConfiguration().batchInterval || BATCH_INTERVAL);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
return promise
|
|
239
329
|
}
|
|
240
330
|
}
|
|
241
331
|
|
|
@@ -258,7 +348,13 @@ const setProvider$1 = (blockchain, provider)=> {
|
|
|
258
348
|
const setProviderEndpoints$1 = async (blockchain, endpoints, detectFastest = true)=> {
|
|
259
349
|
|
|
260
350
|
getAllProviders()[blockchain] = endpoints.map((endpoint, index)=>
|
|
261
|
-
new StaticJsonRpcSequentialProvider(endpoint, blockchain, endpoints)
|
|
351
|
+
new StaticJsonRpcSequentialProvider(endpoint, blockchain, endpoints, ()=>{
|
|
352
|
+
if(getAllProviders()[blockchain].length === 1) {
|
|
353
|
+
setProviderEndpoints$1(blockchain, endpoints, detectFastest);
|
|
354
|
+
} else {
|
|
355
|
+
getAllProviders()[blockchain].splice(index, 1);
|
|
356
|
+
}
|
|
357
|
+
})
|
|
262
358
|
);
|
|
263
359
|
|
|
264
360
|
let provider;
|
|
@@ -443,13 +539,6 @@ let cache = function ({ call, key, expires = 0 }) {
|
|
|
443
539
|
})
|
|
444
540
|
};
|
|
445
541
|
|
|
446
|
-
const getConfiguration = () =>{
|
|
447
|
-
if(getWindow()._Web3ClientConfiguration === undefined) {
|
|
448
|
-
getWindow()._Web3ClientConfiguration = {};
|
|
449
|
-
}
|
|
450
|
-
return getWindow()._Web3ClientConfiguration
|
|
451
|
-
};
|
|
452
|
-
|
|
453
542
|
let paramsToContractArgs = ({ contract, method, params }) => {
|
|
454
543
|
let fragment = contract.interface.fragments.find((fragment) => {
|
|
455
544
|
return fragment.name == method
|
|
@@ -1491,7 +1580,10 @@ const getPlainInstance = ()=>{
|
|
|
1491
1580
|
const isConnected = ()=>{
|
|
1492
1581
|
return new Promise(async(resolve, reject)=>{
|
|
1493
1582
|
|
|
1494
|
-
setTimeout(()=>{
|
|
1583
|
+
setTimeout(()=>{
|
|
1584
|
+
delete localStorage['walletconnect'];
|
|
1585
|
+
resolve(false);
|
|
1586
|
+
}, 5000);
|
|
1495
1587
|
|
|
1496
1588
|
if(!localStorage['walletconnect'] || JSON.parse(localStorage['walletconnect']).handshakeTopic.length == 0) {
|
|
1497
1589
|
delete localStorage['walletconnect'];
|
|
@@ -1977,10 +2069,14 @@ var wallets = {
|
|
|
1977
2069
|
WalletLink
|
|
1978
2070
|
};
|
|
1979
2071
|
|
|
1980
|
-
const getWallets = async()=>{
|
|
2072
|
+
const getWallets = async(args)=>{
|
|
2073
|
+
|
|
2074
|
+
let drip = (args && typeof args.drip === 'function') ? args.drip : undefined;
|
|
1981
2075
|
|
|
1982
2076
|
let availableWallets = await Promise.all(
|
|
2077
|
+
|
|
1983
2078
|
Object.keys(wallets).map(
|
|
2079
|
+
|
|
1984
2080
|
async(key)=>{
|
|
1985
2081
|
|
|
1986
2082
|
let wallet = wallets[key];
|
|
@@ -1990,16 +2086,18 @@ const getWallets = async()=>{
|
|
|
1990
2086
|
|
|
1991
2087
|
if(wallet.getConnectedInstance) {
|
|
1992
2088
|
instance = await wallet.getConnectedInstance();
|
|
2089
|
+
if(drip) { drip(instance); }
|
|
1993
2090
|
return instance
|
|
1994
2091
|
} else {
|
|
2092
|
+
if(drip) { drip(wallet); }
|
|
1995
2093
|
return new wallet
|
|
1996
|
-
}
|
|
2094
|
+
}
|
|
1997
2095
|
}
|
|
1998
2096
|
}
|
|
1999
2097
|
)
|
|
2000
2098
|
);
|
|
2001
2099
|
|
|
2002
|
-
return availableWallets.filter(
|
|
2100
|
+
return availableWallets.filter(Boolean)
|
|
2003
2101
|
};
|
|
2004
2102
|
|
|
2005
2103
|
const supported = [
|
package/dist/umd/index.evm.js
CHANGED
|
@@ -22643,7 +22643,7 @@
|
|
|
22643
22643
|
// TODO: replace 300 with a proper constant for the size of the other
|
|
22644
22644
|
// Transaction fields
|
|
22645
22645
|
|
|
22646
|
-
var CHUNK_SIZE$
|
|
22646
|
+
var CHUNK_SIZE$2 = PACKET_DATA_SIZE - 300;
|
|
22647
22647
|
/**
|
|
22648
22648
|
* Program loader interface
|
|
22649
22649
|
*/
|
|
@@ -22872,7 +22872,7 @@
|
|
|
22872
22872
|
return Loader;
|
|
22873
22873
|
}();
|
|
22874
22874
|
|
|
22875
|
-
Loader.chunkSize = CHUNK_SIZE$
|
|
22875
|
+
Loader.chunkSize = CHUNK_SIZE$2;
|
|
22876
22876
|
var BPF_LOADER_PROGRAM_ID = new PublicKey('BPFLoader2111111111111111111111111111111111');
|
|
22877
22877
|
/**
|
|
22878
22878
|
* Factory class for transactions to interact with a program loader
|
|
@@ -40704,8 +40704,27 @@
|
|
|
40704
40704
|
lib.vec;
|
|
40705
40705
|
lib.vecU8;
|
|
40706
40706
|
|
|
40707
|
-
|
|
40708
|
-
|
|
40707
|
+
let _window;
|
|
40708
|
+
|
|
40709
|
+
let getWindow = () => {
|
|
40710
|
+
if(_window) { return _window }
|
|
40711
|
+
if (typeof global == 'object') {
|
|
40712
|
+
_window = global;
|
|
40713
|
+
} else {
|
|
40714
|
+
_window = window;
|
|
40715
|
+
}
|
|
40716
|
+
return _window
|
|
40717
|
+
};
|
|
40718
|
+
|
|
40719
|
+
const getConfiguration = () =>{
|
|
40720
|
+
if(getWindow()._Web3ClientConfiguration === undefined) {
|
|
40721
|
+
getWindow()._Web3ClientConfiguration = {};
|
|
40722
|
+
}
|
|
40723
|
+
return getWindow()._Web3ClientConfiguration
|
|
40724
|
+
};
|
|
40725
|
+
|
|
40726
|
+
const BATCH_INTERVAL$1 = 10;
|
|
40727
|
+
const CHUNK_SIZE$1 = 99;
|
|
40709
40728
|
|
|
40710
40729
|
class StaticJsonRpcBatchProvider extends ethers.ethers.providers.JsonRpcProvider {
|
|
40711
40730
|
|
|
@@ -40715,6 +40734,7 @@
|
|
|
40715
40734
|
this._endpoint = url;
|
|
40716
40735
|
this._endpoints = endpoints;
|
|
40717
40736
|
this._failover = failover;
|
|
40737
|
+
this._pendingBatch = [];
|
|
40718
40738
|
}
|
|
40719
40739
|
|
|
40720
40740
|
detectNetwork() {
|
|
@@ -40783,19 +40803,19 @@
|
|
|
40783
40803
|
// Get the current batch and clear it, so new requests
|
|
40784
40804
|
// go into the next batch
|
|
40785
40805
|
const batch = this._pendingBatch;
|
|
40786
|
-
this._pendingBatch =
|
|
40806
|
+
this._pendingBatch = [];
|
|
40787
40807
|
this._pendingBatchAggregator = null;
|
|
40788
40808
|
// Prepare Chunks of CHUNK_SIZE
|
|
40789
40809
|
const chunks = [];
|
|
40790
|
-
for (let i = 0; i < Math.ceil(batch.length / CHUNK_SIZE); i++) {
|
|
40791
|
-
chunks[i] = batch.slice(i*CHUNK_SIZE, (i+1)*CHUNK_SIZE);
|
|
40810
|
+
for (let i = 0; i < Math.ceil(batch.length / CHUNK_SIZE$1); i++) {
|
|
40811
|
+
chunks[i] = batch.slice(i*CHUNK_SIZE$1, (i+1)*CHUNK_SIZE$1);
|
|
40792
40812
|
}
|
|
40793
40813
|
chunks.forEach((chunk)=>{
|
|
40794
40814
|
// Get the request as an array of requests
|
|
40795
40815
|
chunk.map((inflight) => inflight.request);
|
|
40796
40816
|
return this.requestChunk(chunk, this._endpoint)
|
|
40797
40817
|
});
|
|
40798
|
-
}, BATCH_INTERVAL);
|
|
40818
|
+
}, getConfiguration().batchInterval || BATCH_INTERVAL$1);
|
|
40799
40819
|
}
|
|
40800
40820
|
|
|
40801
40821
|
return promise
|
|
@@ -40803,18 +40823,6 @@
|
|
|
40803
40823
|
|
|
40804
40824
|
}
|
|
40805
40825
|
|
|
40806
|
-
let _window;
|
|
40807
|
-
|
|
40808
|
-
let getWindow = () => {
|
|
40809
|
-
if(_window) { return _window }
|
|
40810
|
-
if (typeof global == 'object') {
|
|
40811
|
-
_window = global;
|
|
40812
|
-
} else {
|
|
40813
|
-
_window = window;
|
|
40814
|
-
}
|
|
40815
|
-
return _window
|
|
40816
|
-
};
|
|
40817
|
-
|
|
40818
40826
|
const getAllProviders$1 = ()=> {
|
|
40819
40827
|
if(getWindow()._Web3ClientProviders == undefined) {
|
|
40820
40828
|
getWindow()._Web3ClientProviders = {};
|
|
@@ -40923,14 +40931,96 @@
|
|
|
40923
40931
|
setProvider: setProvider$2,
|
|
40924
40932
|
};
|
|
40925
40933
|
|
|
40934
|
+
const BATCH_INTERVAL = 10;
|
|
40935
|
+
const CHUNK_SIZE = 99;
|
|
40936
|
+
|
|
40926
40937
|
class StaticJsonRpcSequentialProvider extends Connection {
|
|
40927
40938
|
|
|
40928
40939
|
constructor(url, network, endpoints, failover) {
|
|
40929
40940
|
super(url);
|
|
40941
|
+
this._provider = new Connection(url);
|
|
40930
40942
|
this._network = network;
|
|
40931
40943
|
this._endpoint = url;
|
|
40932
40944
|
this._endpoints = endpoints;
|
|
40933
40945
|
this._failover = failover;
|
|
40946
|
+
this._pendingBatch = [];
|
|
40947
|
+
this._rpcRequest = this._rpcRequestReplacement.bind(this);
|
|
40948
|
+
}
|
|
40949
|
+
|
|
40950
|
+
requestChunk(chunk) {
|
|
40951
|
+
|
|
40952
|
+
const batch = chunk.map((inflight) => inflight.request);
|
|
40953
|
+
|
|
40954
|
+
return this._provider._rpcBatchRequest(batch)
|
|
40955
|
+
.then((result) => {
|
|
40956
|
+
// For each result, feed it to the correct Promise, depending
|
|
40957
|
+
// on whether it was a success or error
|
|
40958
|
+
chunk.forEach((inflightRequest, index) => {
|
|
40959
|
+
const payload = result[index];
|
|
40960
|
+
if (payload.error) {
|
|
40961
|
+
const error = new Error(payload.error.message);
|
|
40962
|
+
error.code = payload.error.code;
|
|
40963
|
+
error.data = payload.error.data;
|
|
40964
|
+
inflightRequest.reject(error);
|
|
40965
|
+
} else {
|
|
40966
|
+
inflightRequest.resolve(payload);
|
|
40967
|
+
}
|
|
40968
|
+
});
|
|
40969
|
+
}).catch((error) => {
|
|
40970
|
+
if(error && [
|
|
40971
|
+
'Failed to fetch', '504', '503', '502', '500', '429', '426', '422', '413', '409', '408', '406', '405', '404', '403', '402', '401', '400'
|
|
40972
|
+
].some((errorType)=>error.toString().match(errorType))) {
|
|
40973
|
+
const index = this._endpoints.indexOf(this._endpoint)+1;
|
|
40974
|
+
this._endpoint = index >= this._endpoints.length ? this._endpoints[0] : this._endpoints[index];
|
|
40975
|
+
this._provider = new Connection(this._endpoint);
|
|
40976
|
+
this.requestChunk(chunk);
|
|
40977
|
+
} else {
|
|
40978
|
+
chunk.forEach((inflightRequest) => {
|
|
40979
|
+
inflightRequest.reject(error);
|
|
40980
|
+
});
|
|
40981
|
+
}
|
|
40982
|
+
})
|
|
40983
|
+
}
|
|
40984
|
+
|
|
40985
|
+
_rpcRequestReplacement(methodName, args) {
|
|
40986
|
+
|
|
40987
|
+
const request = { methodName, args };
|
|
40988
|
+
|
|
40989
|
+
if (this._pendingBatch == null) {
|
|
40990
|
+
this._pendingBatch = [];
|
|
40991
|
+
}
|
|
40992
|
+
|
|
40993
|
+
const inflightRequest = { request, resolve: null, reject: null };
|
|
40994
|
+
|
|
40995
|
+
const promise = new Promise((resolve, reject) => {
|
|
40996
|
+
inflightRequest.resolve = resolve;
|
|
40997
|
+
inflightRequest.reject = reject;
|
|
40998
|
+
});
|
|
40999
|
+
|
|
41000
|
+
this._pendingBatch.push(inflightRequest);
|
|
41001
|
+
|
|
41002
|
+
if (!this._pendingBatchAggregator) {
|
|
41003
|
+
// Schedule batch for next event loop + short duration
|
|
41004
|
+
this._pendingBatchAggregator = setTimeout(() => {
|
|
41005
|
+
// Get the current batch and clear it, so new requests
|
|
41006
|
+
// go into the next batch
|
|
41007
|
+
const batch = this._pendingBatch;
|
|
41008
|
+
this._pendingBatch = [];
|
|
41009
|
+
this._pendingBatchAggregator = null;
|
|
41010
|
+
// Prepare Chunks of CHUNK_SIZE
|
|
41011
|
+
const chunks = [];
|
|
41012
|
+
for (let i = 0; i < Math.ceil(batch.length / CHUNK_SIZE); i++) {
|
|
41013
|
+
chunks[i] = batch.slice(i*CHUNK_SIZE, (i+1)*CHUNK_SIZE);
|
|
41014
|
+
}
|
|
41015
|
+
chunks.forEach((chunk)=>{
|
|
41016
|
+
// Get the request as an array of requests
|
|
41017
|
+
chunk.map((inflight) => inflight.request);
|
|
41018
|
+
return this.requestChunk(chunk)
|
|
41019
|
+
});
|
|
41020
|
+
}, getConfiguration().batchInterval || BATCH_INTERVAL);
|
|
41021
|
+
}
|
|
41022
|
+
|
|
41023
|
+
return promise
|
|
40934
41024
|
}
|
|
40935
41025
|
}
|
|
40936
41026
|
|
|
@@ -40953,7 +41043,13 @@
|
|
|
40953
41043
|
const setProviderEndpoints$1 = async (blockchain, endpoints, detectFastest = true)=> {
|
|
40954
41044
|
|
|
40955
41045
|
getAllProviders()[blockchain] = endpoints.map((endpoint, index)=>
|
|
40956
|
-
new StaticJsonRpcSequentialProvider(endpoint, blockchain, endpoints)
|
|
41046
|
+
new StaticJsonRpcSequentialProvider(endpoint, blockchain, endpoints, ()=>{
|
|
41047
|
+
if(getAllProviders()[blockchain].length === 1) {
|
|
41048
|
+
setProviderEndpoints$1(blockchain, endpoints, detectFastest);
|
|
41049
|
+
} else {
|
|
41050
|
+
getAllProviders()[blockchain].splice(index, 1);
|
|
41051
|
+
}
|
|
41052
|
+
})
|
|
40957
41053
|
);
|
|
40958
41054
|
|
|
40959
41055
|
let provider;
|
|
@@ -41138,13 +41234,6 @@
|
|
|
41138
41234
|
})
|
|
41139
41235
|
};
|
|
41140
41236
|
|
|
41141
|
-
const getConfiguration = () =>{
|
|
41142
|
-
if(getWindow()._Web3ClientConfiguration === undefined) {
|
|
41143
|
-
getWindow()._Web3ClientConfiguration = {};
|
|
41144
|
-
}
|
|
41145
|
-
return getWindow()._Web3ClientConfiguration
|
|
41146
|
-
};
|
|
41147
|
-
|
|
41148
41237
|
let paramsToContractArgs = ({ contract, method, params }) => {
|
|
41149
41238
|
let fragment = contract.interface.fragments.find((fragment) => {
|
|
41150
41239
|
return fragment.name == method
|
|
@@ -42186,7 +42275,10 @@
|
|
|
42186
42275
|
const isConnected = ()=>{
|
|
42187
42276
|
return new Promise(async(resolve, reject)=>{
|
|
42188
42277
|
|
|
42189
|
-
setTimeout(()=>{
|
|
42278
|
+
setTimeout(()=>{
|
|
42279
|
+
delete localStorage['walletconnect'];
|
|
42280
|
+
resolve(false);
|
|
42281
|
+
}, 5000);
|
|
42190
42282
|
|
|
42191
42283
|
if(!localStorage['walletconnect'] || JSON.parse(localStorage['walletconnect']).handshakeTopic.length == 0) {
|
|
42192
42284
|
delete localStorage['walletconnect'];
|
|
@@ -42672,10 +42764,14 @@
|
|
|
42672
42764
|
WalletLink
|
|
42673
42765
|
};
|
|
42674
42766
|
|
|
42675
|
-
const getWallets = async()=>{
|
|
42767
|
+
const getWallets = async(args)=>{
|
|
42768
|
+
|
|
42769
|
+
let drip = (args && typeof args.drip === 'function') ? args.drip : undefined;
|
|
42676
42770
|
|
|
42677
42771
|
let availableWallets = await Promise.all(
|
|
42772
|
+
|
|
42678
42773
|
Object.keys(wallets).map(
|
|
42774
|
+
|
|
42679
42775
|
async(key)=>{
|
|
42680
42776
|
|
|
42681
42777
|
let wallet = wallets[key];
|
|
@@ -42685,16 +42781,18 @@
|
|
|
42685
42781
|
|
|
42686
42782
|
if(wallet.getConnectedInstance) {
|
|
42687
42783
|
instance = await wallet.getConnectedInstance();
|
|
42784
|
+
if(drip) { drip(instance); }
|
|
42688
42785
|
return instance
|
|
42689
42786
|
} else {
|
|
42787
|
+
if(drip) { drip(wallet); }
|
|
42690
42788
|
return new wallet
|
|
42691
|
-
}
|
|
42789
|
+
}
|
|
42692
42790
|
}
|
|
42693
42791
|
}
|
|
42694
42792
|
)
|
|
42695
42793
|
);
|
|
42696
42794
|
|
|
42697
|
-
return availableWallets.filter(
|
|
42795
|
+
return availableWallets.filter(Boolean)
|
|
42698
42796
|
};
|
|
42699
42797
|
|
|
42700
42798
|
const supported = [
|
package/dist/umd/index.js
CHANGED
|
@@ -842,7 +842,10 @@
|
|
|
842
842
|
const isConnected = ()=>{
|
|
843
843
|
return new Promise(async(resolve, reject)=>{
|
|
844
844
|
|
|
845
|
-
setTimeout(()=>{
|
|
845
|
+
setTimeout(()=>{
|
|
846
|
+
delete localStorage['walletconnect'];
|
|
847
|
+
resolve(false);
|
|
848
|
+
}, 5000);
|
|
846
849
|
|
|
847
850
|
if(!localStorage['walletconnect'] || JSON.parse(localStorage['walletconnect']).handshakeTopic.length == 0) {
|
|
848
851
|
delete localStorage['walletconnect'];
|
|
@@ -1328,10 +1331,14 @@
|
|
|
1328
1331
|
WalletLink
|
|
1329
1332
|
};
|
|
1330
1333
|
|
|
1331
|
-
const getWallets = async()=>{
|
|
1334
|
+
const getWallets = async(args)=>{
|
|
1335
|
+
|
|
1336
|
+
let drip = (args && typeof args.drip === 'function') ? args.drip : undefined;
|
|
1332
1337
|
|
|
1333
1338
|
let availableWallets = await Promise.all(
|
|
1339
|
+
|
|
1334
1340
|
Object.keys(wallets).map(
|
|
1341
|
+
|
|
1335
1342
|
async(key)=>{
|
|
1336
1343
|
|
|
1337
1344
|
let wallet = wallets[key];
|
|
@@ -1341,16 +1348,18 @@
|
|
|
1341
1348
|
|
|
1342
1349
|
if(wallet.getConnectedInstance) {
|
|
1343
1350
|
instance = await wallet.getConnectedInstance();
|
|
1351
|
+
if(drip) { drip(instance); }
|
|
1344
1352
|
return instance
|
|
1345
1353
|
} else {
|
|
1354
|
+
if(drip) { drip(wallet); }
|
|
1346
1355
|
return new wallet
|
|
1347
|
-
}
|
|
1356
|
+
}
|
|
1348
1357
|
}
|
|
1349
1358
|
}
|
|
1350
1359
|
)
|
|
1351
1360
|
);
|
|
1352
1361
|
|
|
1353
|
-
return availableWallets.filter(
|
|
1362
|
+
return availableWallets.filter(Boolean)
|
|
1354
1363
|
};
|
|
1355
1364
|
|
|
1356
1365
|
const supported = [
|
package/dist/umd/index.solana.js
CHANGED
|
@@ -12,8 +12,27 @@
|
|
|
12
12
|
supported$2.evm = [];
|
|
13
13
|
supported$2.solana = ['solana'];
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
let _window;
|
|
16
|
+
|
|
17
|
+
let getWindow = () => {
|
|
18
|
+
if(_window) { return _window }
|
|
19
|
+
if (typeof global == 'object') {
|
|
20
|
+
_window = global;
|
|
21
|
+
} else {
|
|
22
|
+
_window = window;
|
|
23
|
+
}
|
|
24
|
+
return _window
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const getConfiguration = () =>{
|
|
28
|
+
if(getWindow()._Web3ClientConfiguration === undefined) {
|
|
29
|
+
getWindow()._Web3ClientConfiguration = {};
|
|
30
|
+
}
|
|
31
|
+
return getWindow()._Web3ClientConfiguration
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const BATCH_INTERVAL$1 = 10;
|
|
35
|
+
const CHUNK_SIZE$1 = 99;
|
|
17
36
|
|
|
18
37
|
class StaticJsonRpcBatchProvider extends ethers.ethers.providers.JsonRpcProvider {
|
|
19
38
|
|
|
@@ -23,6 +42,7 @@
|
|
|
23
42
|
this._endpoint = url;
|
|
24
43
|
this._endpoints = endpoints;
|
|
25
44
|
this._failover = failover;
|
|
45
|
+
this._pendingBatch = [];
|
|
26
46
|
}
|
|
27
47
|
|
|
28
48
|
detectNetwork() {
|
|
@@ -91,19 +111,19 @@
|
|
|
91
111
|
// Get the current batch and clear it, so new requests
|
|
92
112
|
// go into the next batch
|
|
93
113
|
const batch = this._pendingBatch;
|
|
94
|
-
this._pendingBatch =
|
|
114
|
+
this._pendingBatch = [];
|
|
95
115
|
this._pendingBatchAggregator = null;
|
|
96
116
|
// Prepare Chunks of CHUNK_SIZE
|
|
97
117
|
const chunks = [];
|
|
98
|
-
for (let i = 0; i < Math.ceil(batch.length / CHUNK_SIZE); i++) {
|
|
99
|
-
chunks[i] = batch.slice(i*CHUNK_SIZE, (i+1)*CHUNK_SIZE);
|
|
118
|
+
for (let i = 0; i < Math.ceil(batch.length / CHUNK_SIZE$1); i++) {
|
|
119
|
+
chunks[i] = batch.slice(i*CHUNK_SIZE$1, (i+1)*CHUNK_SIZE$1);
|
|
100
120
|
}
|
|
101
121
|
chunks.forEach((chunk)=>{
|
|
102
122
|
// Get the request as an array of requests
|
|
103
123
|
chunk.map((inflight) => inflight.request);
|
|
104
124
|
return this.requestChunk(chunk, this._endpoint)
|
|
105
125
|
});
|
|
106
|
-
}, BATCH_INTERVAL);
|
|
126
|
+
}, getConfiguration().batchInterval || BATCH_INTERVAL$1);
|
|
107
127
|
}
|
|
108
128
|
|
|
109
129
|
return promise
|
|
@@ -111,18 +131,6 @@
|
|
|
111
131
|
|
|
112
132
|
}
|
|
113
133
|
|
|
114
|
-
let _window;
|
|
115
|
-
|
|
116
|
-
let getWindow = () => {
|
|
117
|
-
if(_window) { return _window }
|
|
118
|
-
if (typeof global == 'object') {
|
|
119
|
-
_window = global;
|
|
120
|
-
} else {
|
|
121
|
-
_window = window;
|
|
122
|
-
}
|
|
123
|
-
return _window
|
|
124
|
-
};
|
|
125
|
-
|
|
126
134
|
const getAllProviders$1 = ()=> {
|
|
127
135
|
if(getWindow()._Web3ClientProviders == undefined) {
|
|
128
136
|
getWindow()._Web3ClientProviders = {};
|
|
@@ -231,14 +239,96 @@
|
|
|
231
239
|
setProvider: setProvider$2,
|
|
232
240
|
};
|
|
233
241
|
|
|
242
|
+
const BATCH_INTERVAL = 10;
|
|
243
|
+
const CHUNK_SIZE = 99;
|
|
244
|
+
|
|
234
245
|
class StaticJsonRpcSequentialProvider extends solanaWeb3_js.Connection {
|
|
235
246
|
|
|
236
247
|
constructor(url, network, endpoints, failover) {
|
|
237
248
|
super(url);
|
|
249
|
+
this._provider = new solanaWeb3_js.Connection(url);
|
|
238
250
|
this._network = network;
|
|
239
251
|
this._endpoint = url;
|
|
240
252
|
this._endpoints = endpoints;
|
|
241
253
|
this._failover = failover;
|
|
254
|
+
this._pendingBatch = [];
|
|
255
|
+
this._rpcRequest = this._rpcRequestReplacement.bind(this);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
requestChunk(chunk) {
|
|
259
|
+
|
|
260
|
+
const batch = chunk.map((inflight) => inflight.request);
|
|
261
|
+
|
|
262
|
+
return this._provider._rpcBatchRequest(batch)
|
|
263
|
+
.then((result) => {
|
|
264
|
+
// For each result, feed it to the correct Promise, depending
|
|
265
|
+
// on whether it was a success or error
|
|
266
|
+
chunk.forEach((inflightRequest, index) => {
|
|
267
|
+
const payload = result[index];
|
|
268
|
+
if (payload.error) {
|
|
269
|
+
const error = new Error(payload.error.message);
|
|
270
|
+
error.code = payload.error.code;
|
|
271
|
+
error.data = payload.error.data;
|
|
272
|
+
inflightRequest.reject(error);
|
|
273
|
+
} else {
|
|
274
|
+
inflightRequest.resolve(payload);
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
}).catch((error) => {
|
|
278
|
+
if(error && [
|
|
279
|
+
'Failed to fetch', '504', '503', '502', '500', '429', '426', '422', '413', '409', '408', '406', '405', '404', '403', '402', '401', '400'
|
|
280
|
+
].some((errorType)=>error.toString().match(errorType))) {
|
|
281
|
+
const index = this._endpoints.indexOf(this._endpoint)+1;
|
|
282
|
+
this._endpoint = index >= this._endpoints.length ? this._endpoints[0] : this._endpoints[index];
|
|
283
|
+
this._provider = new solanaWeb3_js.Connection(this._endpoint);
|
|
284
|
+
this.requestChunk(chunk);
|
|
285
|
+
} else {
|
|
286
|
+
chunk.forEach((inflightRequest) => {
|
|
287
|
+
inflightRequest.reject(error);
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
})
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
_rpcRequestReplacement(methodName, args) {
|
|
294
|
+
|
|
295
|
+
const request = { methodName, args };
|
|
296
|
+
|
|
297
|
+
if (this._pendingBatch == null) {
|
|
298
|
+
this._pendingBatch = [];
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
const inflightRequest = { request, resolve: null, reject: null };
|
|
302
|
+
|
|
303
|
+
const promise = new Promise((resolve, reject) => {
|
|
304
|
+
inflightRequest.resolve = resolve;
|
|
305
|
+
inflightRequest.reject = reject;
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
this._pendingBatch.push(inflightRequest);
|
|
309
|
+
|
|
310
|
+
if (!this._pendingBatchAggregator) {
|
|
311
|
+
// Schedule batch for next event loop + short duration
|
|
312
|
+
this._pendingBatchAggregator = setTimeout(() => {
|
|
313
|
+
// Get the current batch and clear it, so new requests
|
|
314
|
+
// go into the next batch
|
|
315
|
+
const batch = this._pendingBatch;
|
|
316
|
+
this._pendingBatch = [];
|
|
317
|
+
this._pendingBatchAggregator = null;
|
|
318
|
+
// Prepare Chunks of CHUNK_SIZE
|
|
319
|
+
const chunks = [];
|
|
320
|
+
for (let i = 0; i < Math.ceil(batch.length / CHUNK_SIZE); i++) {
|
|
321
|
+
chunks[i] = batch.slice(i*CHUNK_SIZE, (i+1)*CHUNK_SIZE);
|
|
322
|
+
}
|
|
323
|
+
chunks.forEach((chunk)=>{
|
|
324
|
+
// Get the request as an array of requests
|
|
325
|
+
chunk.map((inflight) => inflight.request);
|
|
326
|
+
return this.requestChunk(chunk)
|
|
327
|
+
});
|
|
328
|
+
}, getConfiguration().batchInterval || BATCH_INTERVAL);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
return promise
|
|
242
332
|
}
|
|
243
333
|
}
|
|
244
334
|
|
|
@@ -261,7 +351,13 @@
|
|
|
261
351
|
const setProviderEndpoints$1 = async (blockchain, endpoints, detectFastest = true)=> {
|
|
262
352
|
|
|
263
353
|
getAllProviders()[blockchain] = endpoints.map((endpoint, index)=>
|
|
264
|
-
new StaticJsonRpcSequentialProvider(endpoint, blockchain, endpoints)
|
|
354
|
+
new StaticJsonRpcSequentialProvider(endpoint, blockchain, endpoints, ()=>{
|
|
355
|
+
if(getAllProviders()[blockchain].length === 1) {
|
|
356
|
+
setProviderEndpoints$1(blockchain, endpoints, detectFastest);
|
|
357
|
+
} else {
|
|
358
|
+
getAllProviders()[blockchain].splice(index, 1);
|
|
359
|
+
}
|
|
360
|
+
})
|
|
265
361
|
);
|
|
266
362
|
|
|
267
363
|
let provider;
|
|
@@ -446,13 +542,6 @@
|
|
|
446
542
|
})
|
|
447
543
|
};
|
|
448
544
|
|
|
449
|
-
const getConfiguration = () =>{
|
|
450
|
-
if(getWindow()._Web3ClientConfiguration === undefined) {
|
|
451
|
-
getWindow()._Web3ClientConfiguration = {};
|
|
452
|
-
}
|
|
453
|
-
return getWindow()._Web3ClientConfiguration
|
|
454
|
-
};
|
|
455
|
-
|
|
456
545
|
let paramsToContractArgs = ({ contract, method, params }) => {
|
|
457
546
|
let fragment = contract.interface.fragments.find((fragment) => {
|
|
458
547
|
return fragment.name == method
|
|
@@ -1494,7 +1583,10 @@
|
|
|
1494
1583
|
const isConnected = ()=>{
|
|
1495
1584
|
return new Promise(async(resolve, reject)=>{
|
|
1496
1585
|
|
|
1497
|
-
setTimeout(()=>{
|
|
1586
|
+
setTimeout(()=>{
|
|
1587
|
+
delete localStorage['walletconnect'];
|
|
1588
|
+
resolve(false);
|
|
1589
|
+
}, 5000);
|
|
1498
1590
|
|
|
1499
1591
|
if(!localStorage['walletconnect'] || JSON.parse(localStorage['walletconnect']).handshakeTopic.length == 0) {
|
|
1500
1592
|
delete localStorage['walletconnect'];
|
|
@@ -1980,10 +2072,14 @@
|
|
|
1980
2072
|
WalletLink
|
|
1981
2073
|
};
|
|
1982
2074
|
|
|
1983
|
-
const getWallets = async()=>{
|
|
2075
|
+
const getWallets = async(args)=>{
|
|
2076
|
+
|
|
2077
|
+
let drip = (args && typeof args.drip === 'function') ? args.drip : undefined;
|
|
1984
2078
|
|
|
1985
2079
|
let availableWallets = await Promise.all(
|
|
2080
|
+
|
|
1986
2081
|
Object.keys(wallets).map(
|
|
2082
|
+
|
|
1987
2083
|
async(key)=>{
|
|
1988
2084
|
|
|
1989
2085
|
let wallet = wallets[key];
|
|
@@ -1993,16 +2089,18 @@
|
|
|
1993
2089
|
|
|
1994
2090
|
if(wallet.getConnectedInstance) {
|
|
1995
2091
|
instance = await wallet.getConnectedInstance();
|
|
2092
|
+
if(drip) { drip(instance); }
|
|
1996
2093
|
return instance
|
|
1997
2094
|
} else {
|
|
2095
|
+
if(drip) { drip(wallet); }
|
|
1998
2096
|
return new wallet
|
|
1999
|
-
}
|
|
2097
|
+
}
|
|
2000
2098
|
}
|
|
2001
2099
|
}
|
|
2002
2100
|
)
|
|
2003
2101
|
);
|
|
2004
2102
|
|
|
2005
|
-
return availableWallets.filter(
|
|
2103
|
+
return availableWallets.filter(Boolean)
|
|
2006
2104
|
};
|
|
2007
2105
|
|
|
2008
2106
|
const supported = [
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@depay/web3-wallets-evm",
|
|
3
3
|
"moduleName": "Web3Wallets",
|
|
4
|
-
"version": "15.
|
|
4
|
+
"version": "15.8.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",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@depay/walletconnect-v1": "^1.8.0",
|
|
29
29
|
"@depay/walletconnect-v2": "^2.4.2",
|
|
30
30
|
"@depay/web3-blockchains": "^8.0.1",
|
|
31
|
-
"@depay/web3-client-evm": "^10.
|
|
31
|
+
"@depay/web3-client-evm": "^10.12.0",
|
|
32
32
|
"ethers": "^5.7.1"
|
|
33
33
|
},
|
|
34
34
|
"engines": {
|