suidouble 0.0.23 → 0.0.25
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/SuiInBrowser.js +4 -0
- package/lib/SuiInBrowserAdapter.js +18 -5
- package/lib/SuiObject.js +81 -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/SuiInBrowser.js
CHANGED
|
@@ -30,6 +30,24 @@ class SuiInBrowserAdapter extends SuiCommonMethods {
|
|
|
30
30
|
this._isConnected = false;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
async signAndExecuteTransactionBlock(params) {
|
|
34
|
+
return await this.getFeature(Feature.SUI_SIGN_AND_EXECUTE_TX_BLOCK).signAndExecuteTransactionBlock(params);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async signTransactionBlock(params) {
|
|
38
|
+
return await this.getFeature(Feature.SUI_SIGN_TX_BLOCK).signTransactionBlock(params);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async signMessage(params) {
|
|
42
|
+
return await this.getFeature(Feature.SUI_SIGN_MESSAGE).signMessage(params);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async disconnect(params) {
|
|
46
|
+
const res = await this.getFeature(Feature.DISCONNECT).disconnect(params);
|
|
47
|
+
this.connectionUpdated();
|
|
48
|
+
return res;
|
|
49
|
+
}
|
|
50
|
+
|
|
33
51
|
getDownloadURL() {
|
|
34
52
|
if (this._downloadUrls && this._downloadUrls.chrome) {
|
|
35
53
|
return this._downloadUrls.chrome;
|
|
@@ -112,11 +130,6 @@ class SuiInBrowserAdapter extends SuiCommonMethods {
|
|
|
112
130
|
this.connectionUpdated();
|
|
113
131
|
}
|
|
114
132
|
|
|
115
|
-
async signAndExecuteTransactionBlock(params) {
|
|
116
|
-
return await this.getFeature(Feature.SUI_SIGN_AND_EXECUTE_TX_BLOCK).signAndExecuteTransactionBlock(params);
|
|
117
|
-
// console.log(this.getFeature(Feature.SUI_SIGN_AND_EXECUTE_TX_BLOCK));
|
|
118
|
-
}
|
|
119
|
-
|
|
120
133
|
get okForSui() {
|
|
121
134
|
if (!this.isInstalled) {
|
|
122
135
|
return false;
|
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "suidouble",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.25",
|
|
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": {
|