-
Notifications
You must be signed in to change notification settings - Fork 7
[explorer/rest] feat: Added account endpoint #1907
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
Open
AnthonyLaw
wants to merge
5
commits into
explorer/puller-process-accounts
Choose a base branch
from
explorer/rest-account
base: explorer/puller-process-accounts
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ec9d232
[explorer/rest] feat: added Account model
AnthonyLaw b251db1
[explorer/rest] feat: Added account endpoint, and unit test
AnthonyLaw 47b39fa
[explorer/rest] feat: Added get account query in database
AnthonyLaw 7b14041
[explorer/rest] feat: Added get account logic in facade
AnthonyLaw 30dafc0
[explorer/rest] fix: improvement
AnthonyLaw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| class AccountView: # pylint: disable=too-many-locals,too-many-instance-attributes | ||
| def __init__( | ||
| self, | ||
| address, | ||
| public_key, | ||
| remote_address, | ||
| importance, | ||
| balance, | ||
| vested_balance, | ||
| mosaics, | ||
| harvested_fees, | ||
| harvested_blocks, | ||
| status, | ||
| remote_status, | ||
| last_harvested_height, | ||
| min_cosignatories, | ||
| cosignatory_of, | ||
| cosignatories | ||
| ): | ||
| """Create account view.""" | ||
|
|
||
| # pylint: disable=too-many-arguments,too-many-positional-arguments | ||
|
|
||
| self.address = address | ||
| self.public_key = public_key | ||
| self.remote_address = remote_address | ||
| self.importance = importance | ||
| self.balance = balance | ||
| self.vested_balance = vested_balance | ||
| self.mosaics = mosaics | ||
| self.harvested_fees = harvested_fees | ||
| self.harvested_blocks = harvested_blocks | ||
| self.status = status | ||
| self.remote_status = remote_status | ||
| self.last_harvested_height = last_harvested_height | ||
| self.min_cosignatories = min_cosignatories | ||
| self.cosignatory_of = cosignatory_of | ||
| self.cosignatories = cosignatories | ||
|
|
||
| def __eq__(self, other): | ||
| return isinstance(other, AccountView) and all([ | ||
| self.address == other.address, | ||
| self.public_key == other.public_key, | ||
| self.remote_address == other.remote_address, | ||
| self.importance == other.importance, | ||
| self.balance == other.balance, | ||
| self.vested_balance == other.vested_balance, | ||
| self.mosaics == other.mosaics, | ||
| self.harvested_fees == other.harvested_fees, | ||
| self.harvested_blocks == other.harvested_blocks, | ||
| self.status == other.status, | ||
| self.remote_status == other.remote_status, | ||
| self.last_harvested_height == other.last_harvested_height, | ||
| self.min_cosignatories == other.min_cosignatories, | ||
| self.cosignatory_of == other.cosignatory_of, | ||
| self.cosignatories == other.cosignatories | ||
| ]) | ||
|
|
||
| def to_dict(self): | ||
| """Formats the account info as a dictionary.""" | ||
|
|
||
| return { | ||
| 'address': self.address, | ||
| 'publicKey': self.public_key, | ||
| 'remoteAddress': self.remote_address, | ||
| 'importance': self.importance, | ||
| 'balance': self.balance, | ||
| 'vestedBalance': self.vested_balance, | ||
| 'mosaics': self.mosaics, | ||
| 'harvestedFees': self.harvested_fees, | ||
| 'harvestedBlocks': self.harvested_blocks, | ||
| 'status': self.status, | ||
| 'remoteStatus': self.remote_status, | ||
| 'lastHarvestedHeight': self.last_harvested_height, | ||
| 'minCosignatories': self.min_cosignatories, | ||
| 'cosignatoryOf': self.cosignatory_of, | ||
| 'cosignatories': self.cosignatories | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
What format is the incoming address? I guess maybe bytes from the database?
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, bytes from DB.
Or do you think the formatting better happen under AccoutView's to_dict method?
AccountView(Address(address))
to_dict -> str(self.address )
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.
No, here is fine.
At first look I thought this
str(Address(address))was converting str_address -> Address->back to string but then I notice its coming from the DB😅