Skip to content

Commit

Permalink
Accept keys with or without hex prefix (#75)
Browse files Browse the repository at this point in the history
Part of [laconicd testnet validator enrollment](https://www.notion.so/laconicd-testnet-validator-enrollment-6fc1d3cafcc64fef8c5ed3affa27c675)

Reviewed-on: https://git.vdb.to/cerc-io/laconic-registry-cli/pulls/75
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
  • Loading branch information
prathamesh0 authored and nabarun committed Aug 14, 2024
1 parent 30654bb commit acd4791
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,15 @@ Registering records in registry requires an account. To get account private key
laconicd keys export alice --keyring-backend test --unarmored-hex --unsafe
```

In `config.yml` file assign the account private key to `userKey`.
In `config.yml` file assign the account private key to `userKey`:

```yml
services:
registry:
..
userKey: "<user-key>"
..
```

## Gas and Fees

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cerc-io/laconic-registry-cli",
"version": "0.2.3",
"version": "0.2.4",
"main": "index.js",
"repository": "git@github.com:cerc-io/laconic-registry-cli.git",
"author": "",
Expand Down
7 changes: 6 additions & 1 deletion src/util/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ export const getConnectionInfo = (argv: Arguments, config: any) => {

const result = {
...config,
userKey: stripHexPrefix(config.userKey),
...clean({ server, userKey, bondId, txKey, chainId }),
privateKey: txKey || userKey || config.userKey,
privateKey: stripHexPrefix(txKey || userKey || config.userKey),
gas: String(gas || config.gas),
fees: String(fees || config.fees)
};

return result;
};

function stripHexPrefix (hex: string): string {
return hex && hex.startsWith('0x') ? hex.slice(2) : hex;
}

0 comments on commit acd4791

Please sign in to comment.