suidouble 0.0.22 → 0.0.24
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 +5 -0
- package/lib/SuiObject.js +81 -0
- package/lib/SuiPackageModule.js +6 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -124,6 +124,11 @@ suiObject.fields; // {}, object. Fields stored on blockchain
|
|
|
124
124
|
suiObject.display; // display object stored on blockchain
|
|
125
125
|
suiObject.localProperties; // {} object. Any local properties you want to attach to object. No interaction with blockchain. May be helpful to store some temp data
|
|
126
126
|
suiObject.isOwnedBy('0x10cded4f9df05e37b44e3be2ffa9004dec77786950719fad6083694fdca45bf2'); // is object owned by somebody or some object
|
|
127
|
+
/// past versions:
|
|
128
|
+
await suiObject.getPastObject(version); // get instance of object from the past
|
|
129
|
+
await suiObject.getPastObject(); // try to get previous
|
|
130
|
+
/// object-related transactions:
|
|
131
|
+
await suiObject.queryTransactionBlocks(); // returns instance of SuiPaginatedResponse
|
|
127
132
|
```
|
|
128
133
|
|
|
129
134
|
@todo: better SuiObject documentation
|
package/lib/SuiObject.js
CHANGED
|
@@ -120,6 +120,87 @@ class SuiObject extends SuiCommonMethods {
|
|
|
120
120
|
return this._localProperties;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
get version() {
|
|
124
|
+
return this._version;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Try to get past version of an object from blockchain.
|
|
129
|
+
* Non-cacheable
|
|
130
|
+
* Note from SUI docs, there's no garantee past version is available on nodes, so may return null even if you expect v to be there
|
|
131
|
+
* @param {Number} v
|
|
132
|
+
* @returns SuiObject
|
|
133
|
+
*/
|
|
134
|
+
async getPastObject(v = null) {
|
|
135
|
+
if (!v) {
|
|
136
|
+
v = this._version - BigInt(1);
|
|
137
|
+
}
|
|
138
|
+
v = Number(v);
|
|
139
|
+
|
|
140
|
+
const result = await this._suiMaster._provider.tryGetPastObject({
|
|
141
|
+
version: (v),
|
|
142
|
+
id: this.address,
|
|
143
|
+
options: {
|
|
144
|
+
showType: true,
|
|
145
|
+
showContent: true,
|
|
146
|
+
showOwner: true,
|
|
147
|
+
showDisplay: true,
|
|
148
|
+
"showPreviousTransaction": true,
|
|
149
|
+
"showBcs": false,
|
|
150
|
+
"showStorageRebate": true
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
if (result && result.details && result.details.objectId) {
|
|
155
|
+
const pastObject = new SuiObject({
|
|
156
|
+
suiMaster: this._suiMaster,
|
|
157
|
+
debug: this._debug,
|
|
158
|
+
objectChange: result.details,
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
return pastObject;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
async queryTransactionBlocks(params = {}) {
|
|
168
|
+
// @todo: InputObject / ChangedObject ? make separate function or a param here?
|
|
169
|
+
const queryParams = {
|
|
170
|
+
filter: {
|
|
171
|
+
InputObject: this.address,
|
|
172
|
+
},
|
|
173
|
+
limit: params.limit || 10,
|
|
174
|
+
options: {
|
|
175
|
+
/* Whether to show transaction input data. Default to be false. */
|
|
176
|
+
showInput: true,
|
|
177
|
+
/* Whether to show transaction effects. Default to be false. */
|
|
178
|
+
showEffects: true,
|
|
179
|
+
/* Whether to show transaction events. Default to be false. */
|
|
180
|
+
showEvents: true,
|
|
181
|
+
/* Whether to show object changes. Default to be false. */
|
|
182
|
+
showObjectChanges: true,
|
|
183
|
+
/* Whether to show coin balance changes. Default to be false. */
|
|
184
|
+
showBalanceChanges: true,
|
|
185
|
+
showContent: true,
|
|
186
|
+
showOwner: true,
|
|
187
|
+
showDisplay: true,
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
const paginatedResponse = new SuiPaginatedResponse({
|
|
192
|
+
debug: this._debug,
|
|
193
|
+
suiMaster: this._suiMaster,
|
|
194
|
+
params: queryParams,
|
|
195
|
+
method: 'queryTransactionBlocks',
|
|
196
|
+
order: params.order,
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
await paginatedResponse.fetch();
|
|
200
|
+
|
|
201
|
+
return paginatedResponse;
|
|
202
|
+
}
|
|
203
|
+
|
|
123
204
|
async getDynamicFields(params = {}) {
|
|
124
205
|
const queryParams = {
|
|
125
206
|
parentId: this.address,
|
package/lib/SuiPackageModule.js
CHANGED
|
@@ -151,6 +151,11 @@ class SuiPackageModule extends SuiCommonMethods {
|
|
|
151
151
|
},
|
|
152
152
|
});
|
|
153
153
|
|
|
154
|
+
let status = null;
|
|
155
|
+
if (result && result.effects && result.effects.status && result.effects.status.status) {
|
|
156
|
+
status = result.effects.status.status;
|
|
157
|
+
}
|
|
158
|
+
|
|
154
159
|
const listCreated = [];
|
|
155
160
|
const listMutated = [];
|
|
156
161
|
const listDeleted = [];
|
|
@@ -242,6 +247,7 @@ class SuiPackageModule extends SuiCommonMethods {
|
|
|
242
247
|
created: listCreated,
|
|
243
248
|
mutated: listMutated,
|
|
244
249
|
deleted: listDeleted,
|
|
250
|
+
status: status,
|
|
245
251
|
};
|
|
246
252
|
}
|
|
247
253
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "suidouble",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.24",
|
|
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": {
|