suidouble 1.21.0 → 1.26.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 +11 -0
- package/lib/SuiEvent.js +4 -0
- package/lib/SuiLocalTestValidator.js +7 -17
- package/lib/SuiPackage.js +7 -0
- package/lib/SuiPackageModule.js +1 -2
- package/package.json +4 -2
- package/test/sui_master_onlocal.test.js +4 -2
- package/test/test_move_contracts/different_types/Move.lock +1 -1
- package/test/test_move_contracts/suidouble_chat/Move.lock +1 -1
package/README.md
CHANGED
|
@@ -339,6 +339,17 @@ await package.publish();
|
|
|
339
339
|
console.log('published as', package.address);
|
|
340
340
|
```
|
|
341
341
|
|
|
342
|
+
Optionally, you can switch sui's env of `sui client switch` for the build (useful for Automated Address Management of dependencies via their Move.lock)
|
|
343
|
+
|
|
344
|
+
```javascript
|
|
345
|
+
const package = suiMaster.addPackage({
|
|
346
|
+
path: '../path_to_move_project_root/',
|
|
347
|
+
});
|
|
348
|
+
await package.build({ env: 'testnet', });
|
|
349
|
+
await package.publish();
|
|
350
|
+
|
|
351
|
+
```
|
|
352
|
+
|
|
342
353
|
### upgrading the package
|
|
343
354
|
|
|
344
355
|
Same, it's for CLI as it re-builds the package.
|
package/lib/SuiEvent.js
CHANGED
|
@@ -40,6 +40,10 @@ export default class SuiEvent extends Event {
|
|
|
40
40
|
return this._data ? (''+this._data.type).split('<')[0].split('::').pop() : null;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
get type() {
|
|
44
|
+
return this._data ? (''+this._data.type) : null;
|
|
45
|
+
}
|
|
46
|
+
|
|
43
47
|
get data() {
|
|
44
48
|
return this._data;
|
|
45
49
|
}
|
|
@@ -86,25 +86,15 @@ export default class SuiLocalTestValidator extends SuiCommonMethods {
|
|
|
86
86
|
return this;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
this.log('launching sui-test-validator ...');
|
|
89
|
+
this.log('launching sui-test-validator (sui start)...');
|
|
90
90
|
|
|
91
91
|
try {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
this._child = await SuiCliCommands.spawn('sui-test-validator', params, { RUST_LOG: 'consensus=off' });
|
|
100
|
-
} catch (e) {
|
|
101
|
-
this.log('can not launch sui-test-validator. Trying to run "sui start"...');
|
|
102
|
-
const params = [];
|
|
103
|
-
params.push('start');
|
|
104
|
-
params.push('--with-faucet');
|
|
105
|
-
params.push('--force-regenesis');
|
|
106
|
-
this._child = await SuiCliCommands.spawn('sui', params, { RUST_LOG: 'off,sui_node=info' });
|
|
107
|
-
}
|
|
92
|
+
this.log('Trying to run "sui start"...');
|
|
93
|
+
const params = [];
|
|
94
|
+
params.push('start');
|
|
95
|
+
params.push('--with-faucet');
|
|
96
|
+
params.push('--force-regenesis');
|
|
97
|
+
this._child = await SuiCliCommands.spawn('sui', params, { RUST_LOG: 'off,sui_node=info' });
|
|
108
98
|
} catch (e) {
|
|
109
99
|
if (this._testFallbackEnabled) {
|
|
110
100
|
// can't start local node. Let's switch to sui:dev
|
package/lib/SuiPackage.js
CHANGED
|
@@ -509,6 +509,13 @@ export default class SuiPackage extends SuiObject {
|
|
|
509
509
|
throw new Error('Cant build a package with no path defined');
|
|
510
510
|
}
|
|
511
511
|
|
|
512
|
+
if (params.env) {
|
|
513
|
+
// switch to env
|
|
514
|
+
this.log('switching environment to', params.env);
|
|
515
|
+
const switchResult = await SuiCliCommands.exec(`sui client switch --env ${params.env}`);
|
|
516
|
+
this.log(switchResult);
|
|
517
|
+
}
|
|
518
|
+
|
|
512
519
|
let command = `sui move build --dump-bytecode-as-base64 --path ${path}`;
|
|
513
520
|
if (params.withUnpublishedDependencies) {
|
|
514
521
|
command = `sui move build --with-unpublished-dependencies --dump-bytecode-as-base64 --path ${path}`;
|
package/lib/SuiPackageModule.js
CHANGED
|
@@ -53,7 +53,6 @@ export default class SuiPackageModule extends SuiCommonMethods {
|
|
|
53
53
|
function: methodName,
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
-
// console.log(ret);
|
|
57
56
|
return ret;
|
|
58
57
|
}
|
|
59
58
|
|
|
@@ -295,7 +294,7 @@ export default class SuiPackageModule extends SuiCommonMethods {
|
|
|
295
294
|
const moduleFilter = {};
|
|
296
295
|
|
|
297
296
|
// we need very first package version's id here. So we are getting it from normalized data
|
|
298
|
-
|
|
297
|
+
let normalizedPackageAddress = await this.getNormalizedPackageAddress();
|
|
299
298
|
if (params.eventTypeName) {
|
|
300
299
|
moduleFilter.MoveEventType = `${normalizedPackageAddress}::${this._moduleName}::${params.eventTypeName}`;
|
|
301
300
|
this.log('queriying for events of type: ', moduleFilter.MoveEventType);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "suidouble",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.26.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
|
"type": "module",
|
|
@@ -22,8 +22,10 @@
|
|
|
22
22
|
"author": "suidouble (https://github.com/suidouble)",
|
|
23
23
|
"license": "Apache-2.0",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@mysten/
|
|
25
|
+
"@mysten/bcs": "^1.5.0",
|
|
26
|
+
"@mysten/sui": "^1.26.1",
|
|
26
27
|
"@polymedia/coinmeta": "^0.0.17",
|
|
28
|
+
"@scure/bip39": "^1.5.4",
|
|
27
29
|
"@wallet-standard/core": "^1.0.3",
|
|
28
30
|
"websocket": "^1.0.35"
|
|
29
31
|
},
|
|
@@ -86,6 +86,8 @@ test('attach a local package', async t => {
|
|
|
86
86
|
t.not(contract.address, contractAddressV1);
|
|
87
87
|
t.equal(contract.version, 2);
|
|
88
88
|
|
|
89
|
+
await new Promise((res)=>setTimeout(res, 1000)); // wait for upgrade in rpc
|
|
90
|
+
|
|
89
91
|
contractAddressV2 = contract.address;
|
|
90
92
|
|
|
91
93
|
// let's quickly check it worked, there should be event ChatShopCreated created and we can fetch it from contract's module
|
|
@@ -259,7 +261,7 @@ test('testing paginatedResponse', async t => {
|
|
|
259
261
|
const moveCallResult = await contract.moveCall('suidouble_chat', 'fill', [chatTopMessage.id, contract.arg('string', 'the message response'), contract.arg('string', 'metadata')]);
|
|
260
262
|
t.ok(moveCallResult.created.length >= 60); // it's 60 in move code, but let's keep chat flexible
|
|
261
263
|
|
|
262
|
-
const eventsResponse = await contract.fetchEvents('
|
|
264
|
+
const eventsResponse = await contract.modules.suidouble_chat.fetchEvents({eventTypeName: 'ChatResponseCreated'});
|
|
263
265
|
const idsInEventsDict = {};
|
|
264
266
|
let responsesInEventsCount = 0;
|
|
265
267
|
do {
|
|
@@ -274,7 +276,7 @@ test('testing paginatedResponse', async t => {
|
|
|
274
276
|
t.ok(responsesInEventsCount >= 60); // it's 60 in move code, but let's keep chat flexible
|
|
275
277
|
|
|
276
278
|
// or using SuiPaginatedResponse forEach itterator:
|
|
277
|
-
const anotherEventsResponse = await contract.fetchEvents('
|
|
279
|
+
const anotherEventsResponse = await contract.modules.suidouble_chat.fetchEvents({eventTypeName: 'ChatResponseCreated'});
|
|
278
280
|
let loopsInForEach = 0;
|
|
279
281
|
const idsInLoopDict = {};
|
|
280
282
|
await anotherEventsResponse.forEach(async (event)=>{ //
|