Skip to content

Commit 46d089c

Browse files
author
Booyoun-Kim
committed
Added checkSum parameter at getKeystationMainAddress()
1 parent 25f21ba commit 46d089c

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

www/js/bundle.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const cosmosjs = require("../src");
44

5-
getKeyStationMainAddress = function (mnemonic, hdPath, prefix) {
5+
getKeyStationMainAddress = function (mnemonic, hdPath, prefix, checkSum = true) {
66
var chainId2 = ""
77
switch (prefix) {
88
case "cosmos":
@@ -22,7 +22,7 @@
2222
const cosmos = cosmosjs.network(window.lcd, chainId2);
2323
cosmos.setBech32MainPrefix(prefix);
2424
cosmos.setPath(hdPath);
25-
const address = cosmos.getAddress(mnemonic);
25+
const address = cosmos.getAddress(mnemonic, checkSum);
2626

2727
return address;
2828
}
@@ -46,7 +46,7 @@
4646

4747
let signedTx = cosmos.sign(stdSignMsg, ecpairPriv);
4848

49-
// // IRIS exception handling about "irishub/stake/BeginRedelegate" type
49+
// * IRIS exception handling about "irishub/stake/BeginRedelegate" type
5050
// if (signedTx.tx.msg[0].type == "irishub/stake/BeginRedelegate") {
5151
// // The key of "shares" is using to sign for IRIS Redelegate.
5252
// // After signing, you have to replace the "shares" key name to "shares_amount".
@@ -56,7 +56,7 @@
5656
// signedTx = JSON.parse(txBodyStr);
5757
// }
5858

59-
// Debug
59+
// * Debug
6060
// if (stdSignMsg.json.msgs[0].value.from_address == "[KAVA_ADDRESS]") {
6161
// console.log("signedTx: ", JSON.stringify(signedTx));
6262
// return;
@@ -34423,12 +34423,12 @@ Cosmos.prototype.getAccounts = function(address) {
3442334423
.then(response => response.json())
3442434424
}
3442534425

34426-
Cosmos.prototype.getAddress = function(mnemonic) {
34426+
Cosmos.prototype.getAddress = function(mnemonic, checkSum = true) {
3442734427
if (typeof mnemonic !== "string") {
3442834428
throw new Error("mnemonic expects a string")
3442934429
}
34430-
if (!bip39.validateMnemonic(mnemonic)) {
34431-
throw new Error("mnemonic phrases have invalid checksums")
34430+
if (checkSum) {
34431+
if (!bip39.validateMnemonic(mnemonic)) throw new Error("mnemonic phrases have invalid checksums");
3443234432
}
3443334433
const seed = bip39.mnemonicToSeed(mnemonic);
3443434434
const node = bip32.fromSeed(seed);
@@ -34537,7 +34537,6 @@ Cosmos.prototype.sign = function(stdSignMsg, ecpairPriv, modeType = "sync") {
3453734537
} else {
3453834538
signMessage = stdSignMsg.json;
3453934539
}
34540-
3454134540
const hash = crypto.createHash('sha256').update(JSON.stringify(sortObject(signMessage))).digest('hex');
3454234541
const buf = Buffer.from(hash, 'hex');
3454334542
let signObj = secp256k1.sign(buf, ecpairPriv);

www/js/pin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@
150150
}
151151

152152
var prefix = getParameterByName('payload');
153-
var address = getKeyStationMainAddress(decryptedMnemonics, hdPathResult, prefix);
153+
var address = getKeyStationMainAddress(decryptedMnemonics, hdPathResult, prefix, false);
154154

155155
var msgObj = {
156156
"address": address,

0 commit comments

Comments
 (0)