brendanwenzel / perp_cli_curie

Built for Perpetual Protocol v2 Curie on Optimism chain. This CLI tool was built with Rust.
https://perp.com
14 stars 2 forks source link

[Feature] allow read only mode #1

Open SvenMeyer opened 1 year ago

SvenMeyer commented 1 year ago

(To start with), I would like to use the CLI in read-only mode to get a list of my open positions. However, changing the private key to a real one is needed to setup the config

$ perp position -t 0x3aFxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Creating New Config File
Would you like to change your RPC URL? (y/n)
y
Please provide an RPC URL:
https://endpoints.omniatech.io/v1/op/mainnet/d33exxxxxxxxxxxxxxxxxxxxxxx
New RPC URL has been validated and works. Saving to config file now...
Your Chain ID is set to: 10
Would you like to change your Chain ID? (y/n)
n
Would you like to change your key? (y/n)
n
Would you like to change your key? (y/n)
n
Error: Failed to parse private key: HexError(InvalidHexCharacter { c: 'N', index: 0 })

Location:
    src/utils.rs:49:22

$ perp position -t 0x3aFxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Would you like to change your key? (y/n)
n
Would you like to change your key? (y/n)
y
Please provide the 64-character private key: (Without the 0x prefix)
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
Key updated
Error: Failed to parse private key: EcdsaError(signature::Error { source: None })

Location:
    src/utils.rs:49:22
brendanwenzel commented 1 year ago

Yes, that's something that I was already thinking about. Will work on adding that over the weekend.

In the meantime, I've been using the 1 private key as a read-only key: 0000000000000000000000000000000000000000000000000000000000000001

brendanwenzel commented 1 year ago

@SvenMeyer Would an acceptable solution be to make a default private key if the user either chooses no to changing the key or if the key given has an error? That seems to be the easiest to implement.

lkblkb commented 1 year ago

@brendanwenzel works for me :grin:

brendanwenzel commented 1 year ago

@brendanwenzel works for me :grin:

Thank you @lkblkb for the feedback. Going to shoot to have this pushed by Tuesday.