Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use function InMemorySigner::from_file (field names mismatch) #7030

Closed
formiat opened this issue Jun 14, 2022 · 2 comments · Fixed by #7035
Closed

Unable to use function InMemorySigner::from_file (field names mismatch) #7030

formiat opened this issue Jun 14, 2022 · 2 comments · Fixed by #7035
Assignees

Comments

@formiat
Copy link

formiat commented Jun 14, 2022

Problem:
Unable to use function InMemorySigner::from_file, because field names are different in struct InMemorySigner and in credentials file.

In struct we got field secret_key, but in credentials file we got private_key. Function InMemorySigner::from_file uses serde's deserializer, so, when we try to deserialize struct InMemorySigner, serde's deserializer doesn't find a match for the field and deserialization fails.

Solution 1:
Rename struct InMemorySigner field secret_key to private_key.

Solution 2:
Rename credentials' field private_key to secret_key.

Problem crate: near-crypto
Problem file: src/signer.rs

Versions:

near-jsonrpc-client = "0.3.0"
near-jsonrpc-primitives = "0.12.0"
near-primitives = "0.12.0"
near-crypto = "0.12.0"
@mina86
Copy link
Contributor

mina86 commented Jun 14, 2022

It’s not clear to me what credential file you’re referring to. nearcore uses secret_key throughout the code.

@formiat
Copy link
Author

formiat commented Jun 14, 2022

@mina86 , I mean this file: /home/user/.near-credentials/testnet/<account>.testnet.json

@mina86 mina86 self-assigned this Jun 14, 2022
mina86 added a commit to mina86/nearcore that referenced this issue Jun 14, 2022
To make it easier to use credential files that near cli tool works
with, introduce ‘private_key’ alias for the ‘secret_key’ field in
KeyFile struct.  This way, the JSON file can have either of those
fields set and it’ll be read correctly.

Fixes: near#7030
mina86 added a commit to mina86/nearcore that referenced this issue Jun 14, 2022
To make it easier to use credential files that near cli tool works
with, introduce ‘private_key’ alias for the ‘secret_key’ field in
KeyFile struct.  This way, the JSON file can have either of those
fields set and it’ll be read correctly.

Fixes: near#7030
near-bulldozer bot pushed a commit that referenced this issue Jun 14, 2022
To make it easier to use credential files that near cli tool works
with, introduce ‘private_key’ alias for the ‘secret_key’ field in
KeyFile struct.  This way, the JSON file can have either of those
fields set and it’ll be read correctly.

Fixes: #7030
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants