suidouble 0.0.36 → 0.0.37
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/SuiMaster.js +1 -0
- package/lib/SuiMemoryObjectStorage.js +63 -0
- package/lib/SuiPackageModule.js +1 -60
- package/package.json +1 -1
package/lib/SuiMaster.js
CHANGED
|
@@ -97,6 +97,7 @@ class SuiMaster extends SuiCommonMethods {
|
|
|
97
97
|
// we are differient single instances of object storage by provider name (so we can separate like devnet-testnet entities if needed)
|
|
98
98
|
this._objectStorage = SuiMemoryObjectStorage.instanceOf(this._providerName, {
|
|
99
99
|
debug: this._debug,
|
|
100
|
+
suiMaster: this,
|
|
100
101
|
});
|
|
101
102
|
|
|
102
103
|
this._initialized = false;
|
|
@@ -4,6 +4,7 @@ class SuiMemoryObjectStorage extends SuiCommonMethods {
|
|
|
4
4
|
constructor(params = {}) {
|
|
5
5
|
super(params);
|
|
6
6
|
|
|
7
|
+
this._suiMaster = params.suiMaster;
|
|
7
8
|
this._objects = {};
|
|
8
9
|
}
|
|
9
10
|
|
|
@@ -60,6 +61,68 @@ class SuiMemoryObjectStorage extends SuiCommonMethods {
|
|
|
60
61
|
return null;
|
|
61
62
|
}
|
|
62
63
|
|
|
64
|
+
async fetchObjects() {
|
|
65
|
+
const objectsToFetch = this.asArray(); //Object.values(this._objects);
|
|
66
|
+
|
|
67
|
+
const objectIds = [];
|
|
68
|
+
for (const object of objectsToFetch) {
|
|
69
|
+
if (!object.isDeleted && objectIds.indexOf(object.address) === -1) {
|
|
70
|
+
objectIds.push(object.address);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
this.log('querying details about', objectIds.length, 'objects');
|
|
75
|
+
this.log(objectIds);
|
|
76
|
+
|
|
77
|
+
let results = [];
|
|
78
|
+
const maxCountToFetch = 50;
|
|
79
|
+
for (let i = 0; i < objectIds.length; i += maxCountToFetch) {
|
|
80
|
+
const objectIdsSlice = objectIds.slice(i, i + maxCountToFetch);
|
|
81
|
+
|
|
82
|
+
let resultsSlice = [];
|
|
83
|
+
let consoleWarnMessage = null;
|
|
84
|
+
try {
|
|
85
|
+
const originalConsoleWarn = console.warn;
|
|
86
|
+
console.warn = (e)=>{
|
|
87
|
+
consoleWarnMessage = e;
|
|
88
|
+
};
|
|
89
|
+
resultsSlice = await this._suiMaster._provider.multiGetObjects({
|
|
90
|
+
ids: objectIdsSlice,
|
|
91
|
+
options: { showType: true, showContent: true, showOwner: true, showDisplay: true, },
|
|
92
|
+
});
|
|
93
|
+
console.warn = originalConsoleWarn;
|
|
94
|
+
} catch(e) {
|
|
95
|
+
console.error(e);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (consoleWarnMessage) {
|
|
99
|
+
this.log('got', resultsSlice.length, 'objects but with warning (ok, but probably it is different client vs rpc versions)');
|
|
100
|
+
} else {
|
|
101
|
+
this.log('got', resultsSlice.length, 'objects');
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (resultsSlice && resultsSlice.length) {
|
|
105
|
+
results = results.concat(resultsSlice);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
for (const object of objectsToFetch) {
|
|
110
|
+
const foundInResults = results.find(element => object.idEquals(element?.data?.objectId));
|
|
111
|
+
if (foundInResults) {
|
|
112
|
+
object.tryToFillDataFromObjectChange(foundInResults);
|
|
113
|
+
// this.log('got updates for object', object.address, object.fields);
|
|
114
|
+
} else {
|
|
115
|
+
// object is removed?
|
|
116
|
+
const foundInRemoved = results.find(element => (element?.error?.code == 'deleted' && object.idEquals(element?.error?.object_id)));
|
|
117
|
+
if (foundInRemoved) {
|
|
118
|
+
object.markAsDeleted();
|
|
119
|
+
} else {
|
|
120
|
+
this.log('not found in results', object);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
63
126
|
static _instances = {};
|
|
64
127
|
|
|
65
128
|
static instanceOf(validatorId, params = {}) {
|
package/lib/SuiPackageModule.js
CHANGED
|
@@ -246,66 +246,7 @@ class SuiPackageModule extends SuiCommonMethods {
|
|
|
246
246
|
}
|
|
247
247
|
|
|
248
248
|
async fetchObjects() {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
const objectIds = [];
|
|
252
|
-
for (const object of objectsToFetch) {
|
|
253
|
-
if (!object.isDeleted && objectIds.indexOf(object.address) === -1) {
|
|
254
|
-
objectIds.push(object.address);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
this.log('querying details about', objectIds.length, 'objects');
|
|
259
|
-
this.log(objectIds);
|
|
260
|
-
|
|
261
|
-
let results = [];
|
|
262
|
-
const maxCountToFetch = 50;
|
|
263
|
-
for (let i = 0; i < objectIds.length; i += maxCountToFetch) {
|
|
264
|
-
const objectIdsSlice = objectIds.slice(i, i + maxCountToFetch);
|
|
265
|
-
|
|
266
|
-
let resultsSlice = [];
|
|
267
|
-
let consoleWarnMessage = null;
|
|
268
|
-
try {
|
|
269
|
-
const originalConsoleWarn = console.warn;
|
|
270
|
-
console.warn = (e)=>{
|
|
271
|
-
consoleWarnMessage = e;
|
|
272
|
-
};
|
|
273
|
-
resultsSlice = await this._suiMaster._provider.multiGetObjects({
|
|
274
|
-
ids: objectIdsSlice,
|
|
275
|
-
// only fetch the object type
|
|
276
|
-
options: { showType: true, showContent: true, showOwner: true, showDisplay: true, },
|
|
277
|
-
});
|
|
278
|
-
console.warn = originalConsoleWarn;
|
|
279
|
-
} catch(e) {
|
|
280
|
-
console.error(e);
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
if (consoleWarnMessage) {
|
|
284
|
-
this.log('got', resultsSlice.length, 'objects but with warning (ok, but probably it is different client vs rpc versions)');
|
|
285
|
-
} else {
|
|
286
|
-
this.log('got', resultsSlice.length, 'objects');
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
if (resultsSlice && resultsSlice.length) {
|
|
290
|
-
results = results.concat(resultsSlice);
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
for (const object of objectsToFetch) {
|
|
295
|
-
const foundInResults = results.find(element => object.idEquals(element?.data?.objectId));
|
|
296
|
-
if (foundInResults) {
|
|
297
|
-
object.tryToFillDataFromObjectChange(foundInResults);
|
|
298
|
-
// this.log('got updates for object', object.address, object.fields);
|
|
299
|
-
} else {
|
|
300
|
-
// object is removed?
|
|
301
|
-
const foundInRemoved = results.find(element => (element?.error?.code == 'deleted' && object.idEquals(element?.error?.object_id)));
|
|
302
|
-
if (foundInRemoved) {
|
|
303
|
-
object.markAsDeleted();
|
|
304
|
-
} else {
|
|
305
|
-
this.log('not found in results', object);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
}
|
|
249
|
+
return await this.objectStorage.fetchObjects();
|
|
309
250
|
}
|
|
310
251
|
|
|
311
252
|
async getNormalizedPackageAddress() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "suidouble",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.37",
|
|
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": {
|