Skip to content

Commit ee2cb00

Browse files
committed
Add mapping after creating key
1 parent ffbea4e commit ee2cb00

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { CCKey } from "codechain-keystore";
88
import { CLIError, CLIErrorType } from "./error";
99
import { getAddressFromPublic, findPublicKey, getOpt } from "./util";
1010
import { Option, AccountType, actions } from "./types";
11+
import { getAccountIdFromPublic, blake256 } from "codechain-sdk/lib/utils";
12+
import { H256 } from "codechain-sdk/lib/core/classes";
1113

1214
commander
1315
.version("0.1.0-alpha.1")
@@ -70,6 +72,14 @@ async function main(action: string, option: Option) {
7072
const publicKey = await cckey[accountType].createKey({
7173
passphrase
7274
});
75+
if (accountType === "platform") {
76+
const accountId = getAccountIdFromPublic(publicKey);
77+
cckey.mapping.add({ key: accountId, value: publicKey });
78+
} if (accountType === "asset") {
79+
const hash = H256.ensure(blake256(publicKey)).value;
80+
cckey.mapping.add({ key: hash, value: publicKey });
81+
}
82+
7383
console.log(
7484
getAddressFromPublic(
7585
accountType,

0 commit comments

Comments
 (0)