suidouble 2.16.0 → 2.17.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 +18 -1
- package/lib/SuiInBrowserAdapter.js +30 -5
- package/package.json +2 -2
- package/test/test_move_contracts/different_types/Move.lock +18 -0
- package/test/test_move_contracts/suidouble_chat/Move.lock +18 -0
- package/types/lib/SuiInBrowser.d.ts +6 -0
- package/types/lib/SuiInBrowserAdapter.d.ts +8 -2
package/lib/SuiInBrowser.js
CHANGED
|
@@ -94,7 +94,8 @@ export default class SuiInBrowser extends SuiCommonMethods {
|
|
|
94
94
|
* @returns {Promise<*>}
|
|
95
95
|
*/
|
|
96
96
|
async signAndExecuteTransactionBlock(params) {
|
|
97
|
-
|
|
97
|
+
const enriched = { account: { address: this._connectedAddress }, chain: this._connectedChain, ...params };
|
|
98
|
+
return await this._activeAdapter.signAndExecuteTransactionBlock(enriched);
|
|
98
99
|
}
|
|
99
100
|
|
|
100
101
|
/**
|
|
@@ -107,6 +108,16 @@ export default class SuiInBrowser extends SuiCommonMethods {
|
|
|
107
108
|
return await this._activeAdapter.signAndExecuteTransaction(enriched);
|
|
108
109
|
}
|
|
109
110
|
|
|
111
|
+
/**
|
|
112
|
+
* Sign a personal/arbitrary message via the active adapter.
|
|
113
|
+
* @param {Object} params
|
|
114
|
+
* @returns {Promise<*>}
|
|
115
|
+
*/
|
|
116
|
+
async signPersonalMessage(params) {
|
|
117
|
+
const enriched = { account: { address: this._connectedAddress }, chain: this._connectedChain, ...params };
|
|
118
|
+
return await this._activeAdapter.signPersonalMessage(enriched);
|
|
119
|
+
}
|
|
120
|
+
|
|
110
121
|
/** @returns {*} The gRPC client instance, or null if not yet initialised. */
|
|
111
122
|
get client() {
|
|
112
123
|
return this._client;
|
|
@@ -200,6 +211,10 @@ export default class SuiInBrowser extends SuiCommonMethods {
|
|
|
200
211
|
this.log('error', e);
|
|
201
212
|
}
|
|
202
213
|
this._isConnecting = false;
|
|
214
|
+
|
|
215
|
+
if (this._activeAdapter.isConnected && this._connectedAddress !== this._activeAdapter.connectedAddress) {
|
|
216
|
+
this.adapterConnected(this._activeAdapter);
|
|
217
|
+
}
|
|
203
218
|
}
|
|
204
219
|
|
|
205
220
|
/**
|
|
@@ -279,8 +294,10 @@ export default class SuiInBrowser extends SuiCommonMethods {
|
|
|
279
294
|
...adapterParams,
|
|
280
295
|
debug: this._debug,
|
|
281
296
|
});
|
|
297
|
+
adapter._preferredChain = this._defaultChain;
|
|
282
298
|
if (this._adapters[adapterName]) {
|
|
283
299
|
// already attached
|
|
300
|
+
this._adapters[adapterName]._preferredChain = this._defaultChain;
|
|
284
301
|
if (adapterParams.standartAdapter) {
|
|
285
302
|
this._adapters[adapterName].setStandartAdapter(adapterParams.standartAdapter);
|
|
286
303
|
}
|
|
@@ -59,6 +59,10 @@ export default class SuiInBrowserAdapter extends SuiCommonMethods {
|
|
|
59
59
|
this._connectedChain = null;
|
|
60
60
|
/** @type {boolean} */
|
|
61
61
|
this._isConnected = false;
|
|
62
|
+
/** @type {boolean} */
|
|
63
|
+
this._userDisconnected = false;
|
|
64
|
+
/** @type {?string} */
|
|
65
|
+
this._preferredChain = null;
|
|
62
66
|
}
|
|
63
67
|
|
|
64
68
|
/**
|
|
@@ -138,13 +142,26 @@ export default class SuiInBrowserAdapter extends SuiCommonMethods {
|
|
|
138
142
|
|
|
139
143
|
/**
|
|
140
144
|
* Disconnect from the wallet and refresh connection state.
|
|
145
|
+
* Force-clears local connection state even if the wallet doesn't support
|
|
146
|
+
* standard:disconnect or doesn't revoke site authorization (e.g. Phantom).
|
|
141
147
|
* @param {Object} [params]
|
|
142
|
-
* @returns {Promise
|
|
148
|
+
* @returns {Promise<void>}
|
|
143
149
|
*/
|
|
144
150
|
async disconnect(params) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
151
|
+
try {
|
|
152
|
+
const feature = this.getFeature(Feature.DISCONNECT);
|
|
153
|
+
if (feature) {
|
|
154
|
+
await feature.disconnect(params);
|
|
155
|
+
}
|
|
156
|
+
} catch (e) {
|
|
157
|
+
console.warn('[SuiInBrowserAdapter] standard:disconnect failed:', e);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
this._connectedAddress = null;
|
|
161
|
+
this._connectedChain = null;
|
|
162
|
+
this._isConnected = false;
|
|
163
|
+
this._userDisconnected = true;
|
|
164
|
+
this.emit('disconnected', this);
|
|
148
165
|
}
|
|
149
166
|
|
|
150
167
|
/**
|
|
@@ -187,6 +204,7 @@ export default class SuiInBrowserAdapter extends SuiCommonMethods {
|
|
|
187
204
|
* @returns {Promise<void>}
|
|
188
205
|
*/
|
|
189
206
|
async connect() {
|
|
207
|
+
this._userDisconnected = false;
|
|
190
208
|
try {
|
|
191
209
|
await this.getFeature(Feature.CONNECT).connect();
|
|
192
210
|
} catch (e) {
|
|
@@ -202,13 +220,20 @@ export default class SuiInBrowserAdapter extends SuiCommonMethods {
|
|
|
202
220
|
* `'disconnected'` if the state changed.
|
|
203
221
|
*/
|
|
204
222
|
connectionUpdated() {
|
|
223
|
+
if (this._userDisconnected) return;
|
|
224
|
+
|
|
205
225
|
const wasConnectedAddress = ''+this._connectedAddress;
|
|
206
226
|
const wasConnectedChain = ''+this._connectedChain;
|
|
207
227
|
|
|
208
228
|
try {
|
|
209
229
|
if (this._standardAdapter && this._standardAdapter.accounts && this._standardAdapter.accounts.length) {
|
|
210
230
|
this._connectedAddress = this._standardAdapter.accounts[0].address;
|
|
211
|
-
|
|
231
|
+
const accountChains = this._standardAdapter.accounts[0].chains;
|
|
232
|
+
if (this._preferredChain && accountChains.includes(this._preferredChain)) {
|
|
233
|
+
this._connectedChain = this._preferredChain;
|
|
234
|
+
} else {
|
|
235
|
+
this._connectedChain = accountChains[0];
|
|
236
|
+
}
|
|
212
237
|
} else {
|
|
213
238
|
this._connectedAddress = null;
|
|
214
239
|
this._connectedChain = null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "suidouble",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.17.0-1",
|
|
4
4
|
"description": "JavaScript library for Sui Move smart contracts. Publish, upgrade, and test packages; call contract methods; query objects and events — same code works on Node.js and in the browser.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"license": "Apache-2.0",
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@mysten/bcs": "^2.0.3",
|
|
40
|
-
"@mysten/sui": "^2.
|
|
40
|
+
"@mysten/sui": "^2.17.0",
|
|
41
41
|
"@polymedia/coinmeta": "^0.0.24",
|
|
42
42
|
"@scure/bip39": "^1.6.0",
|
|
43
43
|
"@wallet-standard/core": "^1.1.1"
|
|
@@ -21,3 +21,21 @@ source = { root = true }
|
|
|
21
21
|
use_environment = "mainnet"
|
|
22
22
|
manifest_digest = "EC6E90369603CE16A65E2F7B784DCFCA80948E3C176AD82DC6EB101BAA942A89"
|
|
23
23
|
deps = { Sui = "Sui" }
|
|
24
|
+
|
|
25
|
+
[pinned.testnet.MoveStdlib]
|
|
26
|
+
source = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/move-stdlib", rev = "14bf3e318215db21415c7c0ab0c01cf8d7ef594a" }
|
|
27
|
+
use_environment = "testnet"
|
|
28
|
+
manifest_digest = "C4FE4C91DE74CBF223B2E380AE40F592177D21870DC2D7EB6227D2D694E05363"
|
|
29
|
+
deps = {}
|
|
30
|
+
|
|
31
|
+
[pinned.testnet.Sui]
|
|
32
|
+
source = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "14bf3e318215db21415c7c0ab0c01cf8d7ef594a" }
|
|
33
|
+
use_environment = "testnet"
|
|
34
|
+
manifest_digest = "7AFB66695545775FBFBB2D3078ADFD084244D5002392E837FDE21D9EA1C6D01C"
|
|
35
|
+
deps = { MoveStdlib = "MoveStdlib" }
|
|
36
|
+
|
|
37
|
+
[pinned.testnet.different_types]
|
|
38
|
+
source = { root = true }
|
|
39
|
+
use_environment = "testnet"
|
|
40
|
+
manifest_digest = "CC15E09306E902854F6BDD9B90D21287DB7EC557173965E5355493A2783E25B3"
|
|
41
|
+
deps = { Sui = "Sui" }
|
|
@@ -21,3 +21,21 @@ source = { root = true }
|
|
|
21
21
|
use_environment = "mainnet"
|
|
22
22
|
manifest_digest = "EC6E90369603CE16A65E2F7B784DCFCA80948E3C176AD82DC6EB101BAA942A89"
|
|
23
23
|
deps = { Sui = "Sui" }
|
|
24
|
+
|
|
25
|
+
[pinned.testnet.MoveStdlib]
|
|
26
|
+
source = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/move-stdlib", rev = "14bf3e318215db21415c7c0ab0c01cf8d7ef594a" }
|
|
27
|
+
use_environment = "testnet"
|
|
28
|
+
manifest_digest = "C4FE4C91DE74CBF223B2E380AE40F592177D21870DC2D7EB6227D2D694E05363"
|
|
29
|
+
deps = {}
|
|
30
|
+
|
|
31
|
+
[pinned.testnet.Sui]
|
|
32
|
+
source = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "14bf3e318215db21415c7c0ab0c01cf8d7ef594a" }
|
|
33
|
+
use_environment = "testnet"
|
|
34
|
+
manifest_digest = "7AFB66695545775FBFBB2D3078ADFD084244D5002392E837FDE21D9EA1C6D01C"
|
|
35
|
+
deps = { MoveStdlib = "MoveStdlib" }
|
|
36
|
+
|
|
37
|
+
[pinned.testnet.suidouble_chat]
|
|
38
|
+
source = { root = true }
|
|
39
|
+
use_environment = "testnet"
|
|
40
|
+
manifest_digest = "CC15E09306E902854F6BDD9B90D21287DB7EC557173965E5355493A2783E25B3"
|
|
41
|
+
deps = { Sui = "Sui" }
|
|
@@ -88,6 +88,12 @@ export default class SuiInBrowser extends SuiCommonMethods {
|
|
|
88
88
|
* @returns {Promise<*>}
|
|
89
89
|
*/
|
|
90
90
|
signAndExecuteTransaction(params: any): Promise<any>;
|
|
91
|
+
/**
|
|
92
|
+
* Sign a personal/arbitrary message via the active adapter.
|
|
93
|
+
* @param {Object} params
|
|
94
|
+
* @returns {Promise<*>}
|
|
95
|
+
*/
|
|
96
|
+
signPersonalMessage(params: any): Promise<any>;
|
|
91
97
|
/** @returns {*} The gRPC client instance, or null if not yet initialised. */
|
|
92
98
|
get client(): any;
|
|
93
99
|
toSuiAddress(): string;
|
|
@@ -36,6 +36,10 @@ export default class SuiInBrowserAdapter extends SuiCommonMethods {
|
|
|
36
36
|
_connectedChain: string | null;
|
|
37
37
|
/** @type {boolean} */
|
|
38
38
|
_isConnected: boolean;
|
|
39
|
+
/** @type {boolean} */
|
|
40
|
+
_userDisconnected: boolean;
|
|
41
|
+
/** @type {?string} */
|
|
42
|
+
_preferredChain: string | null;
|
|
39
43
|
/**
|
|
40
44
|
* Sign and execute a transaction. Prefers the current `sui:signAndExecuteTransaction`
|
|
41
45
|
* feature; falls back to the legacy `sui:signAndExecuteTransactionBlock` for older wallets.
|
|
@@ -77,10 +81,12 @@ export default class SuiInBrowserAdapter extends SuiCommonMethods {
|
|
|
77
81
|
signMessage(params: any): Promise<any>;
|
|
78
82
|
/**
|
|
79
83
|
* Disconnect from the wallet and refresh connection state.
|
|
84
|
+
* Force-clears local connection state even if the wallet doesn't support
|
|
85
|
+
* standard:disconnect or doesn't revoke site authorization (e.g. Phantom).
|
|
80
86
|
* @param {Object} [params]
|
|
81
|
-
* @returns {Promise
|
|
87
|
+
* @returns {Promise<void>}
|
|
82
88
|
*/
|
|
83
|
-
disconnect(params?: any): Promise<
|
|
89
|
+
disconnect(params?: any): Promise<void>;
|
|
84
90
|
/**
|
|
85
91
|
* Return the Chrome Web Store download URL, or null if not configured.
|
|
86
92
|
* @returns {?string}
|