Skip to content

Commit

Permalink
extend base #130
Browse files Browse the repository at this point in the history
  • Loading branch information
mfornos committed Dec 12, 2024
1 parent 848a13e commit 886f9d9
Showing 1 changed file with 36 additions and 50 deletions.
86 changes: 36 additions & 50 deletions packages/server/src/services/agents/xcm/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,36 +144,6 @@ export interface XcmRelayedWithContext extends XcmInboundWithContext {
origin: NetworkURN
}

export class GenericXcmRelayedWithContext implements XcmRelayedWithContext {
event: AnyJson
extrinsicPosition?: number
blockNumber: string | number
blockHash: HexString
timestamp?: number
messageHash: HexString
messageId?: HexString
recipient: NetworkURN
origin: NetworkURN
outcome: 'Success' | 'Fail'
error: AnyJson
extrinsicHash?: HexString

constructor(msg: XcmRelayedWithContext) {
this.event = msg.event
this.messageHash = msg.messageHash
this.messageId = msg.messageId ?? msg.messageHash
this.blockHash = msg.blockHash
this.blockNumber = msg.blockNumber.toString()
this.timestamp = msg.timestamp
this.extrinsicPosition = msg.extrinsicPosition
this.recipient = msg.recipient
this.origin = msg.origin
this.outcome = msg.outcome
this.error = msg.error
this.extrinsicHash = msg.extrinsicHash
}
}

export abstract class BaseGenericXcmWithContext implements XcmWithContext {
event: AnyJson
extrinsicPosition?: number
Expand All @@ -196,20 +166,6 @@ export abstract class BaseGenericXcmWithContext implements XcmWithContext {
}
}

export class GenericXcmInboundWithContext extends BaseGenericXcmWithContext implements XcmInboundWithContext {
outcome: 'Success' | 'Fail'
error?: AnyJson
assetsTrapped?: AssetsTrapped

constructor(msg: XcmInboundWithContext) {
super(msg)

this.outcome = msg.outcome
this.error = msg.error
this.assetsTrapped = msg.assetsTrapped
}
}

abstract class BaseXcmEvent {
event: AnyJson
messageHash: HexString
Expand All @@ -232,18 +188,30 @@ abstract class BaseXcmEvent {
}
}

export class XcmInbound extends BaseXcmEvent {
subscriptionId: string
chainId: NetworkURN
export class GenericXcmRelayedWithContext extends BaseGenericXcmWithContext implements XcmRelayedWithContext {
recipient: NetworkURN
origin: NetworkURN
outcome: 'Success' | 'Fail'
error: AnyJson

constructor(msg: XcmRelayedWithContext) {
super(msg)

this.recipient = msg.recipient
this.origin = msg.origin
this.outcome = msg.outcome
this.error = msg.error
}
}

export class GenericXcmInboundWithContext extends BaseGenericXcmWithContext implements XcmInboundWithContext {
outcome: 'Success' | 'Fail'
error?: AnyJson
assetsTrapped?: AssetsTrapped

constructor(subscriptionId: string, chainId: NetworkURN, msg: XcmInboundWithContext) {
constructor(msg: XcmInboundWithContext) {
super(msg)

this.subscriptionId = subscriptionId
this.chainId = chainId
this.outcome = msg.outcome
this.error = msg.error
this.assetsTrapped = msg.assetsTrapped
Expand Down Expand Up @@ -439,6 +407,24 @@ export type XcmTimeout = XcmJourney
*/
export type XcmRelayed = XcmJourney

export class XcmInbound extends BaseXcmEvent {
subscriptionId: string
chainId: NetworkURN
outcome: 'Success' | 'Fail'
error: AnyJson
assetsTrapped?: AssetsTrapped

constructor(subscriptionId: string, chainId: NetworkURN, msg: XcmInboundWithContext) {
super(msg)

this.subscriptionId = subscriptionId
this.chainId = chainId
this.outcome = msg.outcome
this.error = msg.error
this.assetsTrapped = msg.assetsTrapped
}
}

abstract class BaseXcmJourney {
subscriptionId: string
legs: Leg[]
Expand Down

0 comments on commit 886f9d9

Please sign in to comment.