-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:aura-nw/horoscope-v2 into feat/api-…
…health-check
- Loading branch information
Showing
26 changed files
with
6,187 additions
and
52 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Knex } from 'knex'; | ||
|
||
export async function up(knex: Knex): Promise<void> { | ||
await knex.schema.createTable('ibc_message', (table) => { | ||
table.increments(); | ||
table.integer('transaction_message_id').index(); | ||
table.string('src_channel_id').notNullable().index(); | ||
table.string('src_port_id').notNullable().index(); | ||
table.string('dst_channel_id').notNullable().index(); | ||
table.string('dst_port_id').notNullable().index(); | ||
table.string('type').notNullable().index(); | ||
table.integer('sequence').notNullable().index(); | ||
table.string('sequence_key').notNullable().index(); | ||
table.jsonb('data'); | ||
table | ||
.foreign('transaction_message_id') | ||
.references('transaction_message.id'); | ||
}); | ||
} | ||
|
||
export async function down(knex: Knex): Promise<void> { | ||
await knex.schema.dropTableIfExists('ibc_message'); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* eslint-disable import/no-cycle */ | ||
import { Model } from 'objection'; | ||
import BaseModel from './base'; | ||
import { IbcChannel } from './ibc_channel'; | ||
import { TransactionMessage } from './transaction_message'; | ||
|
||
export class IbcMessage extends BaseModel { | ||
id!: number; | ||
|
||
transaction_message_id!: number; | ||
|
||
src_channel_id!: string; | ||
|
||
src_port_id!: string; | ||
|
||
dst_channel_id!: string; | ||
|
||
dst_port_id!: string; | ||
|
||
type!: string; | ||
|
||
sequence!: number; | ||
|
||
sequence_key!: string; | ||
|
||
data!: any; | ||
|
||
static get tableName() { | ||
return 'ibc_message'; | ||
} | ||
|
||
static get jsonSchema() { | ||
return { | ||
type: 'object', | ||
required: [ | ||
'transaction_message_id', | ||
'src_channel_id', | ||
'src_port_id', | ||
'dst_channel_id', | ||
'dst_port_id', | ||
'type', | ||
'sequence', | ||
'sequence_key', | ||
], | ||
properties: { | ||
transaction_message_id: { type: 'number' }, | ||
src_channel_id: { type: 'string' }, | ||
src_port_id: { type: 'string' }, | ||
dst_channel_id: { type: 'string' }, | ||
dst_port_id: { type: 'string' }, | ||
type: { type: 'string' }, | ||
sequence: { type: 'number' }, | ||
sequence_key: { type: 'string' }, | ||
}, | ||
}; | ||
} | ||
|
||
static get relationMappings() { | ||
return { | ||
message: { | ||
relation: Model.BelongsToOneRelation, | ||
modelClass: TransactionMessage, | ||
join: { | ||
from: 'ibc_message.transaction_message_id', | ||
to: 'transaction_message.id', | ||
}, | ||
}, | ||
src_channel: { | ||
relation: Model.BelongsToOneRelation, | ||
modelClass: IbcChannel, | ||
join: { | ||
from: 'ibc_message.src_channel_id', | ||
to: 'ibc_channel.id', | ||
}, | ||
}, | ||
dst_channel: { | ||
relation: Model.BelongsToOneRelation, | ||
modelClass: IbcChannel, | ||
join: { | ||
from: 'ibc_message.dst_channel_id', | ||
to: 'ibc_channel.id', | ||
}, | ||
}, | ||
}; | ||
} | ||
|
||
static EVENT_TYPE = { | ||
SEND_PACKET: 'send_packet', | ||
RECV_PACKET: 'recv_packet', | ||
ACKNOWLEDGE_PACKET: 'acknowledge_packet', | ||
TIMEOUT_PACKET: 'timeout_packet', | ||
}; | ||
} |
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
Oops, something went wrong.