Comparing version 0.0.48 to 0.0.49
@@ -13,2 +13,4 @@ const SuiCommonMethods = require('./SuiCommonMethods.js'); | ||
const { Ed25519Keypair } = require('@mysten/sui.js/keypairs/ed25519'); | ||
const { Secp256r1Keypair } = require('@mysten/sui.js/keypairs/secp256r1'); | ||
const { Secp256k1Keypair } = require('@mysten/sui.js/keypairs/secp256k1'); | ||
const { requestSuiFromFaucetV0, getFaucetHost } = require('@mysten/sui.js/faucet'); | ||
@@ -38,10 +40,32 @@ const { TransactionBlock,Transactions } = require('@mysten/sui.js/transactions'); | ||
} else if (params.phrase) { | ||
if (!params.accountIndex) { | ||
this._keypair = Ed25519Keypair.deriveKeypair(params.phrase); | ||
if (params.keypairAlgo && (''+params.keypairAlgo).toLowerCase() == 'secp256r1') { | ||
if (!params.accountIndex) { | ||
this._keypair = Secp256r1Keypair.deriveKeypair(params.phrase); | ||
} else { | ||
// remember you can generate many addresses with same seed? | ||
const derivePath = `m/74'/784'/${params.accountIndex}'/0/0`; | ||
this._keypair = Secp256r1Keypair.deriveKeypair(params.phrase, derivePath); | ||
} | ||
} else if (params.keypairAlgo && (''+params.keypairAlgo).toLowerCase() == 'secp256k1') { | ||
if (!params.accountIndex) { | ||
this._keypair = Secp256k1Keypair.deriveKeypair(params.phrase); | ||
} else { | ||
// remember you can generate many addresses with same seed? | ||
const derivePath = `m/54'/784'/${params.accountIndex}'/0/0`; | ||
this._keypair = Secp256k1Keypair.deriveKeypair(params.phrase, derivePath); | ||
} | ||
} else { | ||
// remember you can generate many addresses with same seed? | ||
const derivePath = `m/44'/784'/${params.accountIndex}'/0'/0'`; | ||
this._keypair = Ed25519Keypair.deriveKeypair(params.phrase, derivePath); | ||
// default is Ed25519{ | ||
// default is Ed25519 | ||
if (!params.accountIndex) { | ||
this._keypair = Ed25519Keypair.deriveKeypair(params.phrase); | ||
} else { | ||
// remember you can generate many addresses with same seed? | ||
const derivePath = `m/44'/784'/${params.accountIndex}'/0'/0'`; | ||
this._keypair = Ed25519Keypair.deriveKeypair(params.phrase, derivePath); | ||
} | ||
} | ||
this.log('goint to use keypair of', this._keypair.getPublicKey().toSuiAddress()); | ||
@@ -48,0 +72,0 @@ } else if (params.as) { |
{ | ||
"name": "suidouble", | ||
"version": "0.0.48", | ||
"version": "0.0.49", | ||
"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", | ||
@@ -24,3 +24,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"@mysten/sui.js": "^0.41.0", | ||
"@mysten/sui.js": "^0.42.0", | ||
"@wallet-standard/core": "^1.0.3" | ||
@@ -27,0 +27,0 @@ }, |
@@ -52,3 +52,3 @@ # suidouble | ||
const suiMaster = new SuiMaster({ | ||
keypair: Ed25519Keypair, | ||
keypair: Ed25519Keypair || Secp256r1Keypair || Secp256k1Keypair, | ||
debug: true, // echo testing messages to console | ||
@@ -68,2 +68,8 @@ provider: 'test', // 'test', 'dev', 'local', 'main' or instance of this lib's SuiLocalTestValidator, or instance of Sui's JsonRpcProvider | ||
}); | ||
const suiMaster = new SuiMaster({ | ||
debug: false, | ||
phrase: 'thrive mean two thrive mean two thrive mean two thrive mean two', // secret phrase to generate keypair | ||
keypairAlgo: 'secp256k1', // 'secp256r1' or 'secp256r1' or 'ed25519' default is ed25519 | ||
provider: 'dev', | ||
}); | ||
``` | ||
@@ -70,0 +76,0 @@ |
@@ -58,2 +58,35 @@ 'use strict' | ||
test('keypair generation with seed phrase works ok with secp256r1', async t => { | ||
// Ed25519 | ||
const phrase = 'seek weekend run rival noodle dog alone mosquito decide hover aerobic fiction'; // | ||
const suiMaster = new SuiMaster({provider: 'test', phrase: phrase, keypairAlgo: 'secp256r1'}); | ||
await suiMaster.initialize(); | ||
t.equal(`${suiMaster.address}`, `0x444f18d480b4d776d7679fae88ebb4f274941a81c3d98db430f7bd13f82e287d`, 'secp256r1 generated ok'); | ||
const suiMasterNextAccount = new SuiMaster({provider: 'test', phrase: phrase, accountIndex: 1, keypairAlgo: 'secp256r1'}); // default = 0 | ||
await suiMasterNextAccount.initialize(); | ||
t.notEqual(`${suiMaster.address}`, `${suiMasterNextAccount.address}`); | ||
t.equal(`${suiMasterNextAccount.address}`, `0xae496597c64aa6b1aaa03792c0ba0a725b1212adcb0df85d22c447cd57c21c95`, 'secp256r1 next account generated ok'); | ||
}); | ||
test('keypair generation with seed phrase works ok with secp256k1', async t => { | ||
// Ed25519 | ||
const phrase = 'seek weekend run rival noodle dog alone mosquito decide hover aerobic fiction'; // | ||
const suiMaster = new SuiMaster({provider: 'test', phrase: phrase, keypairAlgo: 'secp256k1'}); | ||
await suiMaster.initialize(); | ||
t.equal(`${suiMaster.address}`, `0x86a5dd3def25cab060af90f438842524894c7901839a954b2e9547ecc0f35ef8`, 'secp256k1 generated ok'); | ||
const suiMasterNextAccount = new SuiMaster({provider: 'test', phrase: phrase, accountIndex: 1, keypairAlgo: 'secp256k1'}); // default = 0 | ||
await suiMasterNextAccount.initialize(); | ||
t.notEqual(`${suiMaster.address}`, `${suiMasterNextAccount.address}`); | ||
t.equal(`${suiMasterNextAccount.address}`, `0xc5390344b0344a3e657176eaf72ca00ecf3ed4ec791640b6fc65a11cb680c53f`, 'secp256k1 next account generated ok'); | ||
}); | ||
test('SuiMaster has MIST_PER_SUI property available as BigInt', async t => { | ||
@@ -60,0 +93,0 @@ const suiMaster = new SuiMaster({provider: 'test', as: 'somebody'}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
224965
3518
445
+ Added@mysten/sui.js@0.42.0(transitive)
- Removed@mysten/sui.js@0.41.2(transitive)
Updated@mysten/sui.js@^0.42.0