suidouble 1.44.0 → 1.45.2
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 +21 -5
- package/package.json +2 -2
package/lib/SuiMaster.js
CHANGED
|
@@ -21,20 +21,38 @@ import { decodeSuiPrivateKey } from '@mysten/sui/cryptography';
|
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* @typedef {import("@mysten/sui/client").SuiClient} SuiClient
|
|
24
|
+
* @typedef {import("@mysten/sui/cryptography").Signer} SuiSigner
|
|
25
|
+
* @typedef {import("@mysten/sui/cryptography").Keypair} SuiKeypair
|
|
24
26
|
* @typedef {import("@mysten/sui/client").SuiTransactionBlockResponse} SuiTransactionBlockResponse
|
|
25
27
|
*/
|
|
26
28
|
|
|
27
29
|
export default class SuiMaster extends SuiCommonMethods {
|
|
28
|
-
|
|
30
|
+
/**
|
|
31
|
+
* SuiMaster constructor
|
|
32
|
+
* @param {Object} params - Initialization parameters
|
|
33
|
+
* @param {?SuiSigner} params.signer - instance of Sui SDK Signer (like Keypair)
|
|
34
|
+
* @param {?SuiKeypair} params.keypair - instance of Sui SDK Keypair
|
|
35
|
+
* @param {?string} param.privateKey - private key in Sui format, starting with "suiprivkey1"
|
|
36
|
+
* @param {?boolean} param.debug - enable debug mode
|
|
37
|
+
* @param {?string} param.phrase - mnemonic phrase to derive keypair from
|
|
38
|
+
* @param {?string} param.keypairAlgo - keypair algorithm to use with mnemonic phrase. One of 'ed25519' (default), 'secp256k1', 'secp256r1'
|
|
39
|
+
* @param {?number} param.accountIndex - index of account to derive from mnemonic phrase. Default is 0
|
|
40
|
+
* @param {?string} param.as - pseudo-random address generation seed string
|
|
41
|
+
* @param {?SuiClient|string} params.client - instance of SuiClient or chain name to make SuiClient connected to it (like 'local', 'devnet', 'testnet', 'mainnet')
|
|
42
|
+
*/
|
|
43
|
+
constructor(params) {
|
|
29
44
|
super(params);
|
|
30
45
|
|
|
31
46
|
// quick value to differenciate instances (if there're few) in logs
|
|
32
47
|
SuiMaster.instancesCount++;
|
|
33
48
|
this._instanceN = SuiMaster.instancesCount;
|
|
34
49
|
|
|
50
|
+
/** @type {SuiSigner} */
|
|
35
51
|
this._signer = null;
|
|
52
|
+
/** @type {SuiKeypair} */
|
|
36
53
|
this._keypair = null;
|
|
37
54
|
|
|
55
|
+
/** @type {string} */
|
|
38
56
|
this._address = null;
|
|
39
57
|
|
|
40
58
|
if (params.signer) {
|
|
@@ -81,7 +99,6 @@ export default class SuiMaster extends SuiCommonMethods {
|
|
|
81
99
|
this._keypair = Secp256k1Keypair.deriveKeypair(params.phrase, derivePath);
|
|
82
100
|
}
|
|
83
101
|
} else {
|
|
84
|
-
// default is Ed25519{
|
|
85
102
|
// default is Ed25519
|
|
86
103
|
|
|
87
104
|
if (!params.accountIndex) {
|
|
@@ -104,6 +121,7 @@ export default class SuiMaster extends SuiCommonMethods {
|
|
|
104
121
|
|
|
105
122
|
/** @type {SuiClient} */
|
|
106
123
|
this._client = SuiUtils.normalizeClient(params.client);
|
|
124
|
+
/** @type {string} */
|
|
107
125
|
this._providerName = this._client ? this._client.providerName : null;
|
|
108
126
|
|
|
109
127
|
if (!this._client) {
|
|
@@ -117,6 +135,7 @@ export default class SuiMaster extends SuiCommonMethods {
|
|
|
117
135
|
suiMaster: this,
|
|
118
136
|
});
|
|
119
137
|
|
|
138
|
+
/** @type {boolean} */
|
|
120
139
|
this._initialized = false;
|
|
121
140
|
|
|
122
141
|
/** @type {Object.<string, SuiPackage>} */
|
|
@@ -279,13 +298,10 @@ export default class SuiMaster extends SuiCommonMethods {
|
|
|
279
298
|
|
|
280
299
|
this._initialized = true;
|
|
281
300
|
|
|
282
|
-
// this._keypair = sui.Ed25519Keypair.deriveKeypair(this._phrase);
|
|
283
301
|
if (!this._signer && this._keypair) { // we may optionally go without signer, to work in read-only mode
|
|
284
302
|
this._signer = this._keypair;//
|
|
285
303
|
}
|
|
286
304
|
|
|
287
|
-
// const publicKey = this._keypair.getPublicKey();
|
|
288
|
-
// this._address = publicKey.toSuiAddress();
|
|
289
305
|
if (this._signer) {
|
|
290
306
|
if (this._signer.toSuiAddress) {
|
|
291
307
|
this._address = this._signer.toSuiAddress(); // after Sui's refactor Keypair's method
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "suidouble",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.45.2",
|
|
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",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"license": "Apache-2.0",
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@mysten/bcs": "^1.9.2",
|
|
26
|
-
"@mysten/sui": "^1.
|
|
26
|
+
"@mysten/sui": "^1.45.2",
|
|
27
27
|
"@polymedia/coinmeta": "^0.0.17",
|
|
28
28
|
"@scure/bip39": "^1.6.0",
|
|
29
29
|
"@wallet-standard/core": "^1.1.1",
|