suidouble 1.32.0 → 1.44.0
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/SuiCoins.js +1 -0
- package/lib/SuiCommonMethods.js +1 -0
- package/lib/SuiInBrowser.js +1 -1
- package/lib/SuiLocalTestValidator.js +14 -0
- package/lib/SuiMaster.js +32 -1
- package/lib/SuiObject.js +16 -0
- package/lib/SuiPackage.js +19 -0
- package/lib/SuiPackageModule.js +0 -7
- package/lib/SuiPaginatedResponse.js +1 -1
- package/package.json +3 -3
package/lib/SuiCoins.js
CHANGED
|
@@ -3,6 +3,7 @@ import SuiCommonMethods from './SuiCommonMethods.js';
|
|
|
3
3
|
import { allCoinMetas } from '@polymedia/coinmeta';
|
|
4
4
|
import { normalizeStructTag } from "@mysten/sui/utils";
|
|
5
5
|
|
|
6
|
+
|
|
6
7
|
/**
|
|
7
8
|
* @typedef {import("./SuiCoin.js").CoinMeta} CoinMeta
|
|
8
9
|
* @typedef {import("./SuiCoin.js").SuidoubleCoinBalance} SuidoubleCoinBalance
|
package/lib/SuiCommonMethods.js
CHANGED
package/lib/SuiInBrowser.js
CHANGED
|
@@ -273,7 +273,7 @@ export default class SuiInBrowser extends SuiCommonMethods {
|
|
|
273
273
|
static getPossibleWallets() {
|
|
274
274
|
return [
|
|
275
275
|
{
|
|
276
|
-
name: 'Slush
|
|
276
|
+
name: 'Slush',
|
|
277
277
|
icon: icons['SLUSH'],
|
|
278
278
|
downloadUrls: {
|
|
279
279
|
chrome: 'https://chromewebstore.google.com/detail/slush-%E2%80%94-a-sui-wallet/opcgpfmipidbgpenhmajoajpbobppdil',
|
|
@@ -47,6 +47,12 @@ export default class SuiLocalTestValidator extends SuiCommonMethods {
|
|
|
47
47
|
return this._active;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Launch a localnet sui and wait for it to become available to accept transactions.
|
|
52
|
+
* Don't forget to .stop() it after usage.
|
|
53
|
+
*
|
|
54
|
+
* @returns {SuiLocalTestValidator}
|
|
55
|
+
*/
|
|
50
56
|
static async launch(params = {}) {
|
|
51
57
|
if (SuiLocalTestValidator.__instance) {
|
|
52
58
|
return await SuiLocalTestValidator.__instance.launch();
|
|
@@ -56,6 +62,9 @@ export default class SuiLocalTestValidator extends SuiCommonMethods {
|
|
|
56
62
|
return await SuiLocalTestValidator.__instance.launch();
|
|
57
63
|
}
|
|
58
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Stop the local sui node
|
|
67
|
+
*/
|
|
59
68
|
static async stop() {
|
|
60
69
|
if (SuiLocalTestValidator.__instance) {
|
|
61
70
|
return await SuiLocalTestValidator.__instance.stop();
|
|
@@ -81,6 +90,11 @@ export default class SuiLocalTestValidator extends SuiCommonMethods {
|
|
|
81
90
|
return portIsThere;
|
|
82
91
|
}
|
|
83
92
|
|
|
93
|
+
/**
|
|
94
|
+
* Launch a local sui node and wait for it to become available to accept transactions.
|
|
95
|
+
*
|
|
96
|
+
* @returns {SuiLocalTestValidator}
|
|
97
|
+
*/
|
|
84
98
|
async launch() {
|
|
85
99
|
if (this._active) {
|
|
86
100
|
return this;
|
package/lib/SuiMaster.js
CHANGED
|
@@ -21,6 +21,7 @@ import { decodeSuiPrivateKey } from '@mysten/sui/cryptography';
|
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* @typedef {import("@mysten/sui/client").SuiClient} SuiClient
|
|
24
|
+
* @typedef {import("@mysten/sui/client").SuiTransactionBlockResponse} SuiTransactionBlockResponse
|
|
24
25
|
*/
|
|
25
26
|
|
|
26
27
|
export default class SuiMaster extends SuiCommonMethods {
|
|
@@ -53,6 +54,14 @@ export default class SuiMaster extends SuiCommonMethods {
|
|
|
53
54
|
} else if (parsed.schema == 'Secp256r1') {
|
|
54
55
|
this._keypair = Secp256r1Keypair.fromSecretKey(parsed.secretKey);
|
|
55
56
|
}
|
|
57
|
+
} else if (parsed && parsed.scheme) {
|
|
58
|
+
if (parsed.scheme === 'ED25519') {
|
|
59
|
+
this._keypair = Ed25519Keypair.fromSecretKey(parsed.secretKey);
|
|
60
|
+
} else if (parsed.scheme == 'Secp256k1') {
|
|
61
|
+
this._keypair = Secp256k1Keypair.fromSecretKey(parsed.secretKey);
|
|
62
|
+
} else if (parsed.scheme == 'Secp256r1') {
|
|
63
|
+
this._keypair = Secp256r1Keypair.fromSecretKey(parsed.secretKey);
|
|
64
|
+
}
|
|
56
65
|
}
|
|
57
66
|
} else if (params.phrase) {
|
|
58
67
|
if (params.keypairAlgo && (''+params.keypairAlgo).toLowerCase() == 'secp256r1') {
|
|
@@ -110,6 +119,7 @@ export default class SuiMaster extends SuiCommonMethods {
|
|
|
110
119
|
|
|
111
120
|
this._initialized = false;
|
|
112
121
|
|
|
122
|
+
/** @type {Object.<string, SuiPackage>} */
|
|
113
123
|
this._packages = {};
|
|
114
124
|
|
|
115
125
|
/** @type {SuiCoins} */
|
|
@@ -214,11 +224,31 @@ export default class SuiMaster extends SuiCommonMethods {
|
|
|
214
224
|
return this._signer;
|
|
215
225
|
}
|
|
216
226
|
|
|
227
|
+
/**
|
|
228
|
+
* Attach a smart contract package to this SuiMaster instance.
|
|
229
|
+
*
|
|
230
|
+
* @param {Object} params - Configuration parameters
|
|
231
|
+
* @param {?string} [params.path] - Local filesystem path to the Move package source code
|
|
232
|
+
* @param {?string} [params.id] - ID or address of the Move package on the Sui blockchain
|
|
233
|
+
* @param {?Array.<string>|string} [params.modules] - List of modules in the package to look on chain in the UpgradeCap owned by current address
|
|
234
|
+
*
|
|
235
|
+
* @returns {SuiPackage}
|
|
236
|
+
*/
|
|
217
237
|
package(params = {}) {
|
|
218
238
|
return this.addPackage(params);
|
|
219
239
|
}
|
|
220
240
|
|
|
221
|
-
|
|
241
|
+
/**
|
|
242
|
+
* Attach a smart contract package to this SuiMaster instance.
|
|
243
|
+
*
|
|
244
|
+
* @param {Object} params - Configuration parameters
|
|
245
|
+
* @param {?string} [params.path] - Local filesystem path to the Move package source code
|
|
246
|
+
* @param {?string} [params.id] - ID or address of the Move package on the Sui blockchain
|
|
247
|
+
* @param {?Array.<string>|string} [params.modules] - List of modules in the package to look on chain in the UpgradeCap owned by current address
|
|
248
|
+
*
|
|
249
|
+
* @returns {SuiPackage}
|
|
250
|
+
*/
|
|
251
|
+
addPackage(params) {
|
|
222
252
|
if (params.id && this._packages[params.id]) {
|
|
223
253
|
return this._packages[params.id];
|
|
224
254
|
}
|
|
@@ -325,6 +355,7 @@ export default class SuiMaster extends SuiCommonMethods {
|
|
|
325
355
|
params.account = { address: this._address };
|
|
326
356
|
}
|
|
327
357
|
|
|
358
|
+
/** @type {SuiTransactionBlockResponse} */
|
|
328
359
|
let txResults = null;
|
|
329
360
|
if (this._keypair) {
|
|
330
361
|
params.signer = this._keypair;
|
package/lib/SuiObject.js
CHANGED
|
@@ -2,17 +2,33 @@ import SuiCommonMethods from './SuiCommonMethods.js';
|
|
|
2
2
|
import SuiPaginatedResponse from './SuiPaginatedResponse.js';
|
|
3
3
|
import { normalizeSuiAddress } from './SuiUtils.js';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {import("./SuiMaster.js").default} SuiMaster
|
|
7
|
+
*/
|
|
8
|
+
|
|
5
9
|
export default class SuiObject extends SuiCommonMethods {
|
|
10
|
+
/**
|
|
11
|
+
* Sui Object representation
|
|
12
|
+
*
|
|
13
|
+
* @param {Object} params - parameters
|
|
14
|
+
* @param {SuiMaster} params.suiMaster - instance of SuiMaster
|
|
15
|
+
* @param {?string} [params.id] - ID or address on the sui blockchain
|
|
16
|
+
*/
|
|
6
17
|
constructor(params = {}) {
|
|
7
18
|
super(params);
|
|
8
19
|
|
|
20
|
+
/** @type {SuiMaster} */
|
|
9
21
|
this._suiMaster = params.suiMaster;
|
|
10
22
|
if (!this._suiMaster) {
|
|
11
23
|
throw new Error('suiMaster is requried for suiPackage');
|
|
12
24
|
}
|
|
13
25
|
|
|
26
|
+
/** @type {string} */
|
|
14
27
|
this._id = params.id || null;
|
|
15
28
|
this._version = params.version || null;
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
/** @type {string} */
|
|
16
32
|
this._type = params.type || null;
|
|
17
33
|
|
|
18
34
|
this._fields = {}; // on-chain fields on the object
|
package/lib/SuiPackage.js
CHANGED
|
@@ -5,7 +5,21 @@ import SuiPaginatedResponse from './SuiPaginatedResponse.js';
|
|
|
5
5
|
import { Transaction } from '@mysten/sui/transactions';
|
|
6
6
|
import { normalizeSuiAddress } from './SuiUtils.js';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {import("./SuiMaster.js").default} SuiMaster
|
|
10
|
+
*/
|
|
11
|
+
|
|
8
12
|
export default class SuiPackage extends SuiObject {
|
|
13
|
+
/**
|
|
14
|
+
* Smart Contract Package on Sui blockchain
|
|
15
|
+
*
|
|
16
|
+
* @param {Object} params - Configuration parameters
|
|
17
|
+
* @param {SuiMaster} params.suiMaster - instance of SuiMaster
|
|
18
|
+
* @param {?string} [params.path] - Local filesystem path to the Move package source code
|
|
19
|
+
* @param {?string} [params.id] - ID or address of the Move package on the Sui blockchain
|
|
20
|
+
* @param {?Array.<string>|string} [params.modules] - List of modules in the package to look on chain in the UpgradeCap owned by current address
|
|
21
|
+
* @param {boolean} [params.debug] - Enable debug mode
|
|
22
|
+
*/
|
|
9
23
|
constructor(params = {}) {
|
|
10
24
|
super(params);
|
|
11
25
|
|
|
@@ -13,8 +27,12 @@ export default class SuiPackage extends SuiObject {
|
|
|
13
27
|
// this._id
|
|
14
28
|
// this._suiMaster
|
|
15
29
|
|
|
30
|
+
|
|
31
|
+
/** @type {?string} */
|
|
16
32
|
this._path = params.path;
|
|
33
|
+
/** @type {?string} */
|
|
17
34
|
this._id = params.id || null;
|
|
35
|
+
/** @type {?Array.<string>|string} */
|
|
18
36
|
this._expectedModules = params.modules || null;
|
|
19
37
|
|
|
20
38
|
this._isPublished = false;
|
|
@@ -28,6 +46,7 @@ export default class SuiPackage extends SuiObject {
|
|
|
28
46
|
this._builtDependencies = null;
|
|
29
47
|
this._builtDigest = null;
|
|
30
48
|
|
|
49
|
+
/** @type {Object.<string, SuiPackageModule>} */
|
|
31
50
|
this._modules = {
|
|
32
51
|
|
|
33
52
|
};
|
package/lib/SuiPackageModule.js
CHANGED
|
@@ -246,13 +246,6 @@ export default class SuiPackageModule extends SuiCommonMethods {
|
|
|
246
246
|
}
|
|
247
247
|
|
|
248
248
|
return suiTransaction;
|
|
249
|
-
|
|
250
|
-
// return {
|
|
251
|
-
// created: listCreated,
|
|
252
|
-
// mutated: listMutated,
|
|
253
|
-
// deleted: listDeleted,
|
|
254
|
-
// status: status,
|
|
255
|
-
// };
|
|
256
249
|
}
|
|
257
250
|
|
|
258
251
|
async getOwnedObjects(params = {}) {
|
|
@@ -24,7 +24,7 @@ export default class SuiPaginatedResponse extends SuiCommonMethods {
|
|
|
24
24
|
/**
|
|
25
25
|
* Simple itterator to go over all list of items, not caring about pagination/cursors etc. It fetches next page when needed
|
|
26
26
|
* Optional maxLimit second parameter to stop when reached count
|
|
27
|
-
* @param {
|
|
27
|
+
* @param {function} callbackFunc
|
|
28
28
|
* @param {Number} maxLimit
|
|
29
29
|
*/
|
|
30
30
|
async forEach(callbackFunc, maxLimit = null) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "suidouble",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.44.0",
|
|
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,8 @@
|
|
|
22
22
|
"author": "suidouble (https://github.com/suidouble)",
|
|
23
23
|
"license": "Apache-2.0",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@mysten/bcs": "^1.
|
|
26
|
-
"@mysten/sui": "^1.
|
|
25
|
+
"@mysten/bcs": "^1.9.2",
|
|
26
|
+
"@mysten/sui": "^1.44.0",
|
|
27
27
|
"@polymedia/coinmeta": "^0.0.17",
|
|
28
28
|
"@scure/bip39": "^1.6.0",
|
|
29
29
|
"@wallet-standard/core": "^1.1.1",
|