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 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
- try {
93
- // try sui-test-validator
94
- const params = [];
95
- if (this._epochDuration) {
96
- params.push('--epoch-duration-ms');
97
- params.push(this._epochDuration);
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}`;
@@ -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
- const normalizedPackageAddress = await this.getNormalizedPackageAddress();
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.21.0",
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/sui": "^1.21.0",
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('suidouble_chat');
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('suidouble_chat');
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)=>{ //
@@ -21,6 +21,6 @@ dependencies = [
21
21
  ]
22
22
 
23
23
  [move.toolchain-version]
24
- compiler-version = "1.40.3"
24
+ compiler-version = "1.44.2"
25
25
  edition = "2024.beta"
26
26
  flavor = "sui"
@@ -22,6 +22,6 @@ dependencies = [
22
22
  ]
23
23
 
24
24
  [move.toolchain-version]
25
- compiler-version = "1.40.3"
25
+ compiler-version = "1.44.2"
26
26
  edition = "2024"
27
27
  flavor = "sui"