Skip to content
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

Feat/update owner for each cw721 activity ( develop ) #351

Closed
wants to merge 47 commits into from

Conversation

phamphong9981
Copy link
Collaborator

@phamphong9981 phamphong9981 commented Sep 5, 2023

ref #349

phamphong9981 and others added 30 commits July 5, 2023 14:55
feat: add migration to add index time to block, tx
fix: update validator as UNRECOGNIZED when not found onchain
* feat: reindex cw20 service

* test: test cw20 reindexing

* fix: idiot

* refactor: code

* feat: api admin
* refactor: cw20 index and add relation

* refactor: code
* feat: move statistic feature from v1 to v2 (not tested yet)

* feat: change job params so it can aggregate data at a specific date

* fix: query fields from exact table

* fix: query exact fields

* feat: add logger when done

* feat: finish statistic jobs (not tested)

* feat: create a separate interval job that gets the current date and create statistics jobs with date

* feat: update logic using dayjs and lodash lib

* feat: update cron jobs logic, move api actions to its service folder

* fix: query event from db and group it based on event_id and tx_id

* fix: just use a single job to query all daily data

* fix: move all queries in daily_stats job into a single Promise all

* fix: move dayjs.extend to after import statements

* fix: remove _start

* fix: only count native token in account_stats job

* feat: add api to sync stats from prev dates

* fix: support case when user just pass startDate to api

* fix: fix whitelist graphql

* fix: update column in account_statistic table, update bignum top_tx_sent

* fix: remove drop index in modify account statistic table

---------

Co-authored-by: AnDQK <doquockhanhan@gmail.com>
Co-authored-by: Phan Anh Tuan <fibonacci998@gmail.com>
#322)

* refactor: migrate cw721 activity missing smart contract event

* feat: api

* test: test params

* test: test params

* test: test params

* test: test params

* test: test params

* test: test params

* refactor: code

* refactor: code

* refactor: code

* refactor: code

* refactor: code

* fix: ci
* fix: get use_feegrant_grantee if has, other get tx_fee_payer

* fix: remove code not used
* fix: cw721 activity missing from/to

* fix: fill from/to cw721 activity

* fix: fill from/to cw721 activity

* fix: fill from/to cw721 activity

* fix: fill from/to cw721 activity

* refactor: code

* fix: code

* refactor: code

---------

Co-authored-by: Vu Ngoc Quang <quang.vn@outlook.com>
* feat: crawl ibc tao

* feat: crawl genesis ibc tao

* fix: code

* fix: code
* fix: cw721 activity missing from/to

* fix: fill from/to cw721 activity

* fix: fill from/to cw721 activity

* fix: fill from/to cw721 activity

* fix: fill from/to cw721 activity

* refactor: code

* fix: code

* refactor: code

---------

Co-authored-by: Vu Ngoc Quang <quang.vn@outlook.com>
* feat: crawl ibc tao

* feat: crawl genesis ibc tao

* fix: code

* fix: code
@phamphong9981 phamphong9981 changed the title Fix/approve cw721 activity dev Feat/update owner for each cw721 activity ( develop ) Sep 6, 2023
await knex.transaction(async (trx) => {
const activities = await CW721Activity.query()
.joinRelated('event')
.orderBy('event.block_height', 'asc')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

order theo event id vì 1 block có nhiều event

.transacting(trx);
const done: CW721Activity[] = [];
activities.forEach((activity) => {
const latestActivity = _.findLast(done, function (e) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lưu 1 object latest theo contract_id vào token_id, khi for qua từng event thì update vào bảng đó, lúc cần lấy ra là được

async getLatestOwnerForToken(
cw721ContractId: number,
cw721TokenId: number | null,
others: CW721Activity[]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sao lại tên là others?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

làm như bên migration

.merge()
.transacting(trx)
// eslint-disable-next-line no-await-in-loop
const from = await this.getLatestOwnerForToken(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

có cái foundToken ngay trên mà nhỉ?

if (cw721Activities.length > 0) {
await CW721Activity.query()
.insert(cw721Activities)
.onConflict(['smart_contract_event_id'])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cái này mới tinh mà, làm gì có conflict

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants