suidouble 0.0.28 → 0.0.30

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 CHANGED
@@ -53,6 +53,12 @@ const suiMaster = new SuiMaster({
53
53
  phrase: 'thrive mean two thrive mean two thrive mean two thrive mean two', // secret phrase to generate keypair
54
54
  provider: 'dev',
55
55
  });
56
+ const suiMaster = new SuiMaster({
57
+ debug: false,
58
+ phrase: 'thrive mean two thrive mean two thrive mean two thrive mean two', // secret phrase to generate keypair
59
+ accountIndex: 1, // derive path index (you can generate few addresses with same seed phrase)
60
+ provider: 'dev',
61
+ });
56
62
  ```
57
63
 
58
64
  Also, there's option to generate pseudo-random phrases and wallets from strings, works like a charm for testing:
package/lib/SuiMaster.js CHANGED
@@ -25,7 +25,13 @@ class SuiMaster extends SuiCommonMethods {
25
25
  } else if (params.keypair) {
26
26
  this._keypair = params.keypair;
27
27
  } else if (params.phrase) {
28
- this._keypair = sui.Ed25519Keypair.deriveKeypair(params.phrase);
28
+ if (!params.accountIndex) {
29
+ this._keypair = sui.Ed25519Keypair.deriveKeypair(params.phrase);
30
+ } else {
31
+ // remember you can generate many addresses with same seed?
32
+ const derivePath = `m/44'/784'/${params.accountIndex}'/0'/0'`;
33
+ this._keypair = sui.Ed25519Keypair.deriveKeypair(params.phrase, derivePath);
34
+ }
29
35
 
30
36
  this.log('goint to use keypair of', this._keypair.getPublicKey().toSuiAddress());
31
37
  } else if (params.as) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "suidouble",
3
- "version": "0.0.28",
3
+ "version": "0.0.30",
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": {
@@ -21,7 +21,7 @@
21
21
  "author": "Jeka Kiselyov <jeka911@gmail.com> (https://github.com/jeka-kiselyov)",
22
22
  "license": "Apache-2.0",
23
23
  "dependencies": {
24
- "@mysten/sui.js": "^0.35.1",
24
+ "@mysten/sui.js": "^0.37.1",
25
25
  "@wallet-standard/core": "^1.0.3"
26
26
  },
27
27
  "devDependencies": {
@@ -39,6 +39,22 @@ test('pseudo-random keypairs generation works ok', async t => {
39
39
  t.equal(`${suiMasterAsAdminAnother.address}`, `${suiMasterAsAdmin.address}`, 'same string should generate same pseudo-random');
40
40
  });
41
41
 
42
+ test('keypair generation with seed phrase works ok', async t => {
43
+ // Ed25519
44
+ const phrase = 'seek weekend run rival noodle dog alone mosquito decide hover aerobic fiction'; // 0x2bfe9c35ca9400c42e24e4b424cbd2dfb51bcb7c2487e1b4694ff53d8ca00262
45
+ const suiMaster = new SuiMaster({provider: 'test', phrase: phrase});
46
+ await suiMaster.initialize();
47
+
48
+ t.equal(`${suiMaster.address}`, `0x2bfe9c35ca9400c42e24e4b424cbd2dfb51bcb7c2487e1b4694ff53d8ca00262`, 'Ed25519 generated ok');
49
+
50
+ const suiMasterNextAccount = new SuiMaster({provider: 'test', phrase: phrase, accountIndex: 1}); // default = 0
51
+ await suiMasterNextAccount.initialize();
52
+
53
+ t.notEqual(`${suiMaster.address}`, `${suiMasterNextAccount.address}`);
54
+
55
+ t.equal(`${suiMasterNextAccount.address}`, `0xa6fb5c51b751e07a3e3b3af1f40f3115004702aad5a96263ff0be9078195f43b`, 'Ed25519 next account generated ok');
56
+ });
57
+
42
58
  test('connecting to different chains', async t => {
43
59
  const suiMaster = new SuiMaster({provider: 'test', as: 'somebody'});
44
60
  await suiMaster.initialize();