Open harrysolovay opened 3 months ago
Interesting suggestion. I mean, you do have the option of not using the public key in testAccounts
, and converting it wherever you use them.
but many APIs, like Mina.transaction()
only take a PublicKey
and not a PrivateKey
, for the reason that you usually don't have the private key when you want to use them in a production environment.
So it's convenient to have the public key at hand
Good point. Thoughts on adding a TestAccount
type, which would extend PrivateKey
and initialize the publicKey
member? Any other test-account-specific operations could go in that subclass.
How expensive is it to create a
PublicKey
from aPrivateKey
? If it is cheap, might it be worthwhile to initialize a memberpublicKey: PublicKey
whenever aPrivateKey
is constructed (and to deprecatetoPublicKey
)?I believe this would simplify usage in a number of ways.
Accessing test accounts
Fewer naming decisions
This change would encourage access via the
publicKey
prop instead of via a separate variable (deployerPublicKey
/senderPublicKey
), thereby sparing the developer of choosing a name for thePublicKey
s. Without the need to distinguish between public and private keys in the given scope, the developer can name thePrivateKey
without a postfixdeployerPrivateKey
->deployer
senderPrivateKey
->sender
Additionally, this allows the developer to forgo extra work to share references to initialized
PublicKey
s.Meanwhile,
sign
calls become more minimal.