Comparing version 1.6.0-1 to 1.6.0-2
@@ -17,2 +17,3 @@ const SuiCommonMethods = require('./SuiCommonMethods.js'); | ||
const { Transaction, Commands } = require('@mysten/sui/transactions'); | ||
const { decodeSuiPrivateKey } = require('@mysten/sui/cryptography'); | ||
@@ -40,2 +41,13 @@ | ||
this._keypair = params.keypair; | ||
} else if (params.privateKey) { | ||
const parsed = decodeSuiPrivateKey(params.privateKey); | ||
if (parsed && parsed.schema) { | ||
if (parsed.schema === 'ED25519') { | ||
this._keypair = Ed25519Keypair.fromSecretKey(parsed.secretKey); | ||
} else if (parsed.schema == 'Secp256k1') { | ||
this._keypair = Secp256k1Keypair.fromSecretKey(parsed.secretKey); | ||
} else if (parsed.schema == 'Secp256r1') { | ||
this._keypair = Secp256r1Keypair.fromSecretKey(parsed.secretKey); | ||
} | ||
} | ||
} else if (params.phrase) { | ||
@@ -42,0 +54,0 @@ if (params.keypairAlgo && (''+params.keypairAlgo).toLowerCase() == 'secp256r1') { |
{ | ||
"name": "suidouble", | ||
"version": "1.6.0-1", | ||
"version": "1.6.0-2", | ||
"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", | ||
@@ -36,4 +36,3 @@ "main": "index.js", | ||
}, | ||
"tap": { | ||
} | ||
"tap": {} | ||
} |
@@ -49,3 +49,3 @@ # suidouble | ||
You can initialize it directly, if you have keypair, secret phrase and can use it in code (so on node.js side - server side or CLI apps): | ||
You can initialize it directly, if you have keypair, secret phrase, or privateKey and can use it in code (so on node.js side - server side or CLI apps): | ||
```javascript | ||
@@ -59,2 +59,7 @@ const suiMaster = new SuiMaster({ | ||
debug: false, | ||
privateKey: 'suiprivkey1qpwly9xrfsv50mqug706s40l58klez5q6mpchq4f5ldzktjyr4x7yhj9lf2', | ||
client: 'dev', | ||
}); | ||
const suiMaster = new SuiMaster({ | ||
debug: false, | ||
phrase: 'thrive mean two thrive mean two thrive mean two thrive mean two', // secret phrase to generate keypair | ||
@@ -61,0 +66,0 @@ client: 'dev', |
@@ -42,2 +42,11 @@ 'use strict' | ||
test('keypair generation with privateKey works ok', async t => { | ||
const privateKey = 'suiprivkey1qpwly9xrfsv50mqug706s40l58klez5q6mpchq4f5ldzktjyr4x7yhj9lf2'; | ||
const suiMaster = new SuiMaster({client: 'test', privateKey: privateKey}); | ||
await suiMaster.initialize(); | ||
t.equal(`${suiMaster.address}`, `0x4d07e4a382dcb69288a8a4589e8fc0534378dad76b75565fda0c1e9ada45b7d1`, 'by privateKey generated ok'); | ||
}); | ||
test('keypair generation with seed phrase works ok', async t => { | ||
@@ -44,0 +53,0 @@ // Ed25519 |
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
241106
3907
489