-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: smart contract missing label ( develop ) (#367)
* fix: cw721 activity missing from/to ( main ) (#294) * 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 ( main ) (#278) * feat: crawl ibc tao * feat: crawl genesis ibc tao * fix: code * fix: code * fix: smart contract missing label * fix: test * fix: test * fix: test * fix: test --------- Co-authored-by: Vu Ngoc Quang <quang.vn@outlook.com>
- Loading branch information
1 parent
58ffa5f
commit 94f3e24
Showing
5 changed files
with
40 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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,32 @@ | ||
import { Knex } from 'knex'; | ||
import { getHttpBatchClient } from '../src/common'; | ||
import { SmartContract } from '../src/models'; | ||
|
||
export async function up(knex: Knex): Promise<void> { | ||
await knex.schema.alterTable('smart_contract', (table) => { | ||
table.string('label').defaultTo(''); | ||
}); | ||
await knex.transaction(async (trx) => { | ||
const smartContracts = await SmartContract.query().transacting(trx); | ||
if (smartContracts.length > 0) { | ||
const contractsInfo = await SmartContract.getContractInfos( | ||
smartContracts.map((smartContract) => smartContract.address), | ||
getHttpBatchClient() | ||
); | ||
smartContracts.forEach((smartContract, index) => { | ||
smartContract.label = contractsInfo[index]?.contractInfo?.label; | ||
}); | ||
await SmartContract.query() | ||
.transacting(trx) | ||
.insert(smartContracts) | ||
.onConflict('id') | ||
.merge(); | ||
} | ||
}); | ||
} | ||
|
||
export async function down(knex: Knex): Promise<void> { | ||
await knex.schema.alterTable('smart_contract', (table) => { | ||
table.dropColumn('label'); | ||
}); | ||
} |
This file contains 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 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 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 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