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

fix: store oracle transactions properly #173

Merged
merged 15 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/mappings/handlers/oracleHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import { OracleTransactionData, OracleTransactionService } from '../services/ora
export const handleOracleFed = errorHandler(_handleOracleFed)
async function _handleOracleFed(event: SubstrateEvent<OracleFedEvent>) {
const [feeder, key, value] = event.event.data
logger.info(`Oracle feed: ${feeder.toString()} key: ${key.toString()} value: ${value.toString()}`)
logger.info(`Oracle feed: ${feeder.toString()} key: ${key.isin.toString()} value: ${value.toString()}`)

const oracleTxData: OracleTransactionData = {
hash: event.extrinsic.extrinsic.hash.toString(),
timestamp: event.block.timestamp,
key: key.toString(),
key: key.isin.toString(),
value: value.toBigInt(),
}

OracleTransactionService.init(oracleTxData)
const oracleTx = OracleTransactionService.init(oracleTxData)
await oracleTx.save()
}
7 changes: 1 addition & 6 deletions src/mappings/services/oracleTransactionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ export interface OracleTransactionData {

export class OracleTransactionService extends OracleTransaction {
static init = (data: OracleTransactionData) => {
const tx = new this(
`${data.hash}-${data.timestamp.toString()}-${data.key.toString()}`,
data.timestamp,
data.key.toString(),
data.value
)
const tx = new this(`${data.hash}-${data.key.toString()}`, data.timestamp, data.key.toString(), data.value)

tx.timestamp = data.timestamp ?? null
tx.key = data.key ?? null
Expand Down
Loading