suidouble 1.12.0 → 1.13.0-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/lib/SuiInBrowser.js +30 -5
- package/package.json +2 -2
package/lib/SuiInBrowser.js
CHANGED
|
@@ -25,6 +25,8 @@ class SuiInBrowser extends SuiCommonMethods {
|
|
|
25
25
|
this._client = null;
|
|
26
26
|
this._suiMaster = null;
|
|
27
27
|
|
|
28
|
+
this._rpcSettings = null;
|
|
29
|
+
|
|
28
30
|
setTimeout(()=>{
|
|
29
31
|
this.initialize();
|
|
30
32
|
}, 50);
|
|
@@ -119,6 +121,10 @@ class SuiInBrowser extends SuiCommonMethods {
|
|
|
119
121
|
const wasConnectedToChain = this._connectedChain;
|
|
120
122
|
this._connectedChain = suiInBrowserAdapter.connectedChain;
|
|
121
123
|
|
|
124
|
+
if (this._connectedChain == 'sui:unknown') {
|
|
125
|
+
this._connectedChain = 'sui:mainnet'; // custom RPC in Sui Wallet
|
|
126
|
+
}
|
|
127
|
+
|
|
122
128
|
if (this._connectedChain != wasConnectedToChain) {
|
|
123
129
|
this.log('chain was switched');
|
|
124
130
|
this._client = null;
|
|
@@ -130,6 +136,23 @@ class SuiInBrowser extends SuiCommonMethods {
|
|
|
130
136
|
this.emit('connected');
|
|
131
137
|
}
|
|
132
138
|
|
|
139
|
+
/**
|
|
140
|
+
* Switch connection to use custom RPC endpoint
|
|
141
|
+
* @param {Object} params parameters
|
|
142
|
+
* @param {string} params.url rpc url
|
|
143
|
+
* @param {Object} params.rpc rpc settings
|
|
144
|
+
* @param {Object.<string, string>} params.rpc.headers rpc headers
|
|
145
|
+
*/
|
|
146
|
+
async setRPC(params = {}) {
|
|
147
|
+
this._rpcSettings = params;
|
|
148
|
+
this._client = null;
|
|
149
|
+
this._suiMaster = null;
|
|
150
|
+
|
|
151
|
+
await this.initClient();
|
|
152
|
+
|
|
153
|
+
this.emit('rpc');
|
|
154
|
+
}
|
|
155
|
+
|
|
133
156
|
adapterDisconnected(suiInBrowserAdapter) {
|
|
134
157
|
this._isConnected = false;
|
|
135
158
|
this._connectedAddress = null;
|
|
@@ -181,13 +204,17 @@ class SuiInBrowser extends SuiCommonMethods {
|
|
|
181
204
|
const chainSettings = SuiInBrowser.getChainsSettings();
|
|
182
205
|
// https://github.com/MystenLabs/sui/blob/827f1138a09190975172ec99389751ca95cce5df/sdk/typescript/src/rpc/connection.ts#L32
|
|
183
206
|
|
|
184
|
-
if (
|
|
207
|
+
if (this._rpcSettings) {
|
|
208
|
+
this._rpcSettings.providerName = chainName;
|
|
209
|
+
this._client = SuiMaster.SuiUtils.suiClientForRPC(this._rpcSettings);
|
|
210
|
+
} else if (!chainSettings[chainName]) {
|
|
185
211
|
this.log('error', 'invalid chain', chainName);
|
|
186
212
|
throw new Error('invalid chain: '+chainName);
|
|
213
|
+
} else {
|
|
214
|
+
this._client = new SuiClient({url: chainSettings[chainName].fullnode});
|
|
215
|
+
this._client.endpoint = chainSettings[chainName].fullnode;
|
|
187
216
|
}
|
|
188
217
|
|
|
189
|
-
this._client = new SuiClient({url: chainSettings[chainName].fullnode});
|
|
190
|
-
this._client.endpoint = chainSettings[chainName].fullnode;
|
|
191
218
|
this._suiMaster = new SuiMaster({
|
|
192
219
|
debug: this._debug,
|
|
193
220
|
signer: this,
|
|
@@ -218,8 +245,6 @@ class SuiInBrowser extends SuiCommonMethods {
|
|
|
218
245
|
});
|
|
219
246
|
}
|
|
220
247
|
});
|
|
221
|
-
|
|
222
|
-
|
|
223
248
|
}
|
|
224
249
|
|
|
225
250
|
static getChainsSettings() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "suidouble",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0-1",
|
|
4
4
|
"description": "Set of provider, package and object classes for javascript representation of Sui Move smart contracts. Use same code for publishing, upgrading, integration testing, interaction with smart contracts and integration in browser web3 dapps",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"author": "Jeka Kiselyov <jeka911@gmail.com> (https://github.com/jeka-kiselyov)",
|
|
22
22
|
"license": "Apache-2.0",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@mysten/sui": "^1.
|
|
24
|
+
"@mysten/sui": "^1.13.0",
|
|
25
25
|
"@wallet-standard/core": "^1.0.3",
|
|
26
26
|
"websocket": "^1.0.35"
|
|
27
27
|
},
|