-
Notifications
You must be signed in to change notification settings - Fork 359
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
Use Nile's Signer #283
Use Nile's Signer #283
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry that it took me so long to review this! I think we're on the right track, opened a few discussions.
tests/utils.py
Outdated
@@ -128,7 +125,7 @@ def cached_contract(state, definition, deployed): | |||
return contract | |||
|
|||
|
|||
class Signer(): | |||
class ActivatedSigner(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clear to me what the right name for this is. I was considering moving the transaction functionality upstream to Nile, but the reason we had this split in the first time is that Nile's should be generic enough while this is tied to StarkNet's testing framework -- which is not good to send transactions to public chains.
We could either abstract the provider (testing fw / starknet.py / public net?) on Nile's side and just provision the testing fw from each test and not have this intermediate abstraction, or maybe rename this one to TestSigner or something like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm yeah, I struggled a little bit with naming this (SignerWithAccount
, ExtendedSigner
, and this). I think renaming to TestSigner
is perfectly fine. We're just using it here to test the contracts anyway.
tox.ini
Outdated
@@ -16,6 +16,7 @@ passenv = | |||
PYTHONPATH | |||
deps = | |||
cairo-lang==0.8.1 | |||
cairo-nile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we fix versions in here to avoid breaking changes impacting this repo's development?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good idea
@@ -1,11 +1,12 @@ | |||
import pytest | |||
from starkware.starknet.testing.starknet import Starknet | |||
from utils import ( | |||
Signer, str_to_felt, TRUE, FALSE, get_contract_def, cached_contract, assert_revert, to_uint | |||
ActivatedSigner, str_to_felt, TRUE, FALSE, get_contract_def, cached_contract, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this PR is old, but would that TRUE
and FALSE
end up in main
if we merge this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would that TRUE
and FALSE
end up in main
as a duplicate you mean? If that's the question, I'll rebase first and make sure there are no duplicates
docs/Account.md
Outdated
|
||
To use Signer, pass a private key when instantiating the class: | ||
* reformats callarray |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should "callarray" be formatted somehow? has been defined before? reformat how?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good questions. It's really just converting callarray[0] to hex so "reformat" isn't correct. I'll better explain this and include where it's first defined as well.
docs/Account.md
Outdated
|
||
To use Signer, pass a private key when instantiating the class: | ||
* reformats callarray | ||
* a necessary process to convert the `to` contract address to hexadecimal format |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is it necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because Nile converts to
to base-16 which requires the to
address to be a string. Converting the address with str()
creates an integer that exceeds Cairo's FIELD_PRIME
...I'll add this to the docs :)
Co-authored-by: Martín Triay <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking very good now! Great work
This PR removes the local
Signer
in utils.py and instead imports/uses Nile'sSigner
class. This PR proposes to include theActivatedSigner
class.ActivatedSigner
performs the following:Signer
__execute__
with the tx signature returned from Nile's SignerFurther, this PR includes updated documentation regarding how
ActivatedSigner
works with Nile'sSigner
. This resolves #221.