-
-
Notifications
You must be signed in to change notification settings - Fork 775
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
Add management command to track Kudos purchases #4198
Add management command to track Kudos purchases #4198
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4198 +/- ##
======================================
Coverage 30.3% 30.3%
======================================
Files 249 249
Lines 21470 21470
Branches 3115 3115
======================================
Hits 6506 6506
Misses 14677 14677
Partials 287 287 Continue to review full report at Codecov.
|
scripts/crontab
Outdated
@@ -19,6 +19,7 @@ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/us | |||
## KUDOS | |||
*/15 3,10,17 * * * cd gitcoin/coin; bash scripts/run_management_command_if_not_already_running.bash sync_kudos mainnet opensea --catchup >> /var/log/gitcoin/sync_kudos_catchup.log 2>&1 | |||
*/10 4,11,18 * * * cd gitcoin/coin; bash scripts/run_management_command_if_not_already_running.bash sync_kudos mainnet opensea --start 1 >> /var/log/gitcoin/sync_kudos_all.log 2>&1 | |||
0 */1 * * * cd gitcoin/coin; bash scripts/run_management_command_if_not_already_running.bash kudos_revenue mainnet --account-address 0xdb282cee382244e05dd226c8809d2405b76fbdc9 |
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.
*1 == * right?
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.
logger.info(f"ETH Tx Records were found. Continuing from block {params['startblock']}") | ||
|
||
params['action'] = 'txlist' | ||
call_etherscan_api(network, params) |
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 do we need to call call_etherscan_api()
twice? why not just once
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.
Etherscan API uses two separate methods to retrieve ETH transactions (txlist) and ERC-20 token transactions (tokentx)
9608d37
to
3ecfb9c
Compare
this LGTM. @danlipert look ok to you? |
bumping this @danlipert ^^ |
@santteegt Can you add some tests for this? Thanks! |
3ecfb9c
to
c06be7d
Compare
Hi @danlipert, I've just updated my PR to consider your review comments |
ETHERSCAN_API_KEY = env('ETHERSCAN_API_KEY', default='') | ||
|
||
# Kudos revenue account | ||
KUDOS_REVENUE_ACCOUNT_ADDRESS = env('KUDOS_REVENUE_ACCOUNT_ADDRESS', default='0xdb282cee382244e05dd226c8809d2405b76fbdc9') |
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.
@owocki is this the correct address (and is it the same on rinkeby, or is there even a rinkeby equivalent?)
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 rinkeby equiv; this is the right addr yes
@santteegt looking great - I'm wondering if you can test the management command directly and actually inspect the resulting DGP objects that are created after running to ensure they match whats on the blockchain. Also, how are the tests returning data properly even though no API key is set? 🤔 |
c06be7d
to
3f08221
Compare
Hi @danlipert, I've finally added a test case that directly performs a call to the management command. Regarding the empty API key during tests, Etherscan has a limited quota to call their API for free without an API_KEY |
@owocki how is this looking to you? |
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.
@danlipert LGTM; well have to get an etherscan api key b4 deploy tho!
ETHERSCAN_API_KEY = env('ETHERSCAN_API_KEY', default='') | ||
|
||
# Kudos revenue account | ||
KUDOS_REVENUE_ACCOUNT_ADDRESS = env('KUDOS_REVENUE_ACCOUNT_ADDRESS', default='0xdb282cee382244e05dd226c8809d2405b76fbdc9') |
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 rinkeby equiv; this is the right addr yes
API Key is in place for when this gets merged 👍 |
@santteegt we are almost able to get this in, but the automated tests are failing because of the reliance on Etherscan. Can you mock those out so that our automated tests don't depend on Etherscan's availability or whether they block the free requests in the future? Thanks! |
@danlipert sure! I'll try to get this done ASAP |
@santteegt any update on this . ? |
Add management command to track Kudos purchases
2c4cb73
to
c2558f7
Compare
Hi @thelostone-mc, Sorry for the late PR submission. I just updated it for you to review |
Description
Gitcoin team members want to track kudos purchases by recording revenue in the database. So, a management command to track Kudos purchases is implemented to track ETH and token transaction from a specified account address, while a cron job is setup to run the command once an hour.
Checklist
Affected core subsystem(s)
Refers/Fixes
Refs: #4122
Testing and Sign-off
Before testing new features please create an Etherscan API Key on https://etherscan.io/apis and set its value on
ETHERSCAN_API_KEY
env variable.Contributor
make test
and everything passed!Reviewer
Funder