Skip to content

Commit

Permalink
rename Gear.MessageEnqueued to Gear.MessageQueued (#215)
Browse files Browse the repository at this point in the history
  • Loading branch information
osipov-mit authored Nov 22, 2023
1 parent b1f5b1f commit 778580c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions substrate/substrate-data/src/extension/gear.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {Event} from '../interfaces/data'
import {assertEvent} from '../types/util'


const GearMessageEnqueued = struct({
const GearMessageQueued = struct({
destination: bytes()
})

Expand All @@ -18,8 +18,8 @@ const GearUserMessageSent = struct({

export function setGearProgramId(runtime: Runtime, event: Event): void {
switch(event.name) {
case 'Gear.MessageEnqueued':
assertEvent(runtime, GearMessageEnqueued, event)
case 'Gear.MessageQueued':
assertEvent(runtime, GearMessageQueued, event)
event._gearProgramId = event.args.destination
break
case 'Gear.UserMessageSent':
Expand Down
4 changes: 2 additions & 2 deletions substrate/substrate-processor/src/ds-rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ function toBaseDataRequest(req: DataRequest): base.DataRequest {
let events = !!req.events?.length
|| !!req.evmLogs?.length
|| !!req.contractsEvents?.length
|| !!req.gearMessagesEnqueued?.length
|| !!req.gearMessagesQueued?.length
|| !!req.gearUserMessagesSent?.length
|| req.calls?.some(c => c.events)
|| req.ethereumTransactions?.some(c => c.events)
Expand All @@ -203,7 +203,7 @@ function toBaseDataRequest(req: DataRequest): base.DataRequest {
|| req.events?.some(e => e.extrinsic || e.call || e.stack)
|| req.evmLogs?.some(e => e.extrinsic || e.call || e.stack)
|| req.contractsEvents?.some(e => e.extrinsic || e.call || e.stack)
|| req.gearMessagesEnqueued?.some(e => e.extrinsic || e.call || e.stack)
|| req.gearMessagesQueued?.some(e => e.extrinsic || e.call || e.stack)
|| req.gearUserMessagesSent?.some(e => e.extrinsic || e.call || e.stack)
|| false

Expand Down
4 changes: 2 additions & 2 deletions substrate/substrate-processor/src/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ function buildEventRequests(dataRequest: DataRequest): Requests<Event, EventRela
requests.add(filter, relations)
})

dataRequest.gearMessagesEnqueued?.forEach(req => {
dataRequest.gearMessagesQueued?.forEach(req => {
let {programId, ...relations} = req
let filter = new FilterBuilder<Event>()
filter.propIn('name', ['Gear.MessageEnqueued'])
filter.propIn('name', ['Gear.MessageQueued'])
filter.propIn('_gearProgramId', programId)
requests.add(filter, relations)
})
Expand Down
4 changes: 2 additions & 2 deletions substrate/substrate-processor/src/interfaces/data-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface DataRequest {
evmLogs?: EvmLogRequest[]
ethereumTransactions?: EthereumTransactRequest[]
contractsEvents?: ContractsContractEmittedRequest[]
gearMessagesEnqueued?: GearMessageEnqueuedRequest[]
gearMessagesQueued?: GearMessageQueuedRequest[]
gearUserMessagesSent?: GearUserMessageSentRequest[]
}

Expand Down Expand Up @@ -59,7 +59,7 @@ export interface ContractsContractEmittedRequest extends EventRelations {
}


export interface GearMessageEnqueuedRequest extends EventRelations {
export interface GearMessageQueuedRequest extends EventRelations {
programId?: Bytes[]
}

Expand Down
8 changes: 4 additions & 4 deletions substrate/substrate-processor/src/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
EthereumTransactRequest,
EventRequest,
EvmLogRequest,
GearMessageEnqueuedRequest,
GearMessageQueuedRequest,
GearUserMessageSentRequest
} from './interfaces/data-request'

Expand Down Expand Up @@ -153,9 +153,9 @@ export class SubstrateBatchProcessor<F extends FieldSelection = {}> {
return this
}

addGearMessageEnqueued(options: GearMessageEnqueuedRequest & BlockRange): this {
addGearMessageQueued(options: GearMessageQueuedRequest & BlockRange): this {
this.assertNotRunning()
this.add({gearMessagesEnqueued: [options]}, options.range)
this.add({gearMessagesQueued: [options]}, options.range)
return this
}

Expand Down Expand Up @@ -362,7 +362,7 @@ export class SubstrateBatchProcessor<F extends FieldSelection = {}> {
evmLogs: concat(a.evmLogs, b.evmLogs),
ethereumTransactions: concat(a.ethereumTransactions, b.ethereumTransactions),
contractsEvents: concat(a.contractsEvents, b.contractsEvents),
gearMessagesEnqueued: concat(a.gearMessagesEnqueued, b.gearMessagesEnqueued),
gearMessagesQueued: concat(a.gearMessagesQueued, b.gearMessagesQueued),
gearUserMessagesSent: concat(a.gearUserMessagesSent, b.gearUserMessagesSent)
}
})
Expand Down
4 changes: 2 additions & 2 deletions test/gear-nft/src/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const processor = new SubstrateBatchProcessor()
.setDataSource({
archive: 'https://gear-testnet.archive.subsquid.io/graphql'
})
.addGearMessageEnqueued(NFT_PROGRAM_ID, {
.addGearMessageQueued(NFT_PROGRAM_ID, {
data: {
event: {
args: true,
Expand Down Expand Up @@ -96,7 +96,7 @@ async function extractMintsAndReplies(ctx: Ctx): Promise<{records: MintRecord[],
for (let block of ctx.blocks) {
for (let item of block.items) {
if (item.kind != 'event') continue
if (item.event.name == 'Gear.MessageEnqueued') {
if (item.event.name == 'Gear.MessageQueued') {
if (item.event.call.name != 'Gear.send_message') continue
let input = await decodeNFTInput(item.event.call.args.payload)
if ('mint' in input) {
Expand Down

0 comments on commit 778580c

Please sign in to comment.