Skip to content

Commit 2bd7343

Browse files
committed
feat: add escrow expired event
1 parent c853d19 commit 2bd7343

File tree

7 files changed

+101
-7
lines changed

7 files changed

+101
-7
lines changed

packages/fasset-indexer-core/chain/artifacts/ICoreVaultManager.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,25 @@
183183
"name": "EmergencyPauseSenderRemoved",
184184
"type": "event"
185185
},
186+
{
187+
"anonymous": false,
188+
"inputs": [
189+
{
190+
"indexed": true,
191+
"internalType": "bytes32",
192+
"name": "preimageHash",
193+
"type": "bytes32"
194+
},
195+
{
196+
"indexed": false,
197+
"internalType": "uint256",
198+
"name": "amount",
199+
"type": "uint256"
200+
}
201+
],
202+
"name": "EscrowExpired",
203+
"type": "event"
204+
},
186205
{
187206
"anonymous": false,
188207
"inputs": [

packages/fasset-indexer-core/chain/typechain/ICoreVaultManager.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ export interface ICoreVaultManagerInterface extends Interface {
194194
| "CustomInstructions"
195195
| "EmergencyPauseSenderAdded"
196196
| "EmergencyPauseSenderRemoved"
197+
| "EscrowExpired"
197198
| "EscrowFinished"
198199
| "EscrowInstructions"
199200
| "NotAllEscrowsProcessed"
@@ -523,6 +524,19 @@ export namespace EmergencyPauseSenderRemovedEvent {
523524
export type LogDescription = TypedLogDescription<Event>;
524525
}
525526

527+
export namespace EscrowExpiredEvent {
528+
export type InputTuple = [preimageHash: BytesLike, amount: BigNumberish];
529+
export type OutputTuple = [preimageHash: string, amount: bigint];
530+
export interface OutputObject {
531+
preimageHash: string;
532+
amount: bigint;
533+
}
534+
export type Event = TypedContractEvent<InputTuple, OutputTuple, OutputObject>;
535+
export type Filter = TypedDeferredTopicFilter<Event>;
536+
export type Log = TypedEventLog<Event>;
537+
export type LogDescription = TypedLogDescription<Event>;
538+
}
539+
526540
export namespace EscrowFinishedEvent {
527541
export type InputTuple = [preimageHash: BytesLike, amount: BigNumberish];
528542
export type OutputTuple = [preimageHash: string, amount: bigint];
@@ -1109,6 +1123,13 @@ export interface ICoreVaultManager extends BaseContract {
11091123
EmergencyPauseSenderRemovedEvent.OutputTuple,
11101124
EmergencyPauseSenderRemovedEvent.OutputObject
11111125
>;
1126+
getEvent(
1127+
key: "EscrowExpired"
1128+
): TypedContractEvent<
1129+
EscrowExpiredEvent.InputTuple,
1130+
EscrowExpiredEvent.OutputTuple,
1131+
EscrowExpiredEvent.OutputObject
1132+
>;
11121133
getEvent(
11131134
key: "EscrowFinished"
11141135
): TypedContractEvent<
@@ -1275,6 +1296,17 @@ export interface ICoreVaultManager extends BaseContract {
12751296
EmergencyPauseSenderRemovedEvent.OutputObject
12761297
>;
12771298

1299+
"EscrowExpired(bytes32,uint256)": TypedContractEvent<
1300+
EscrowExpiredEvent.InputTuple,
1301+
EscrowExpiredEvent.OutputTuple,
1302+
EscrowExpiredEvent.OutputObject
1303+
>;
1304+
EscrowExpired: TypedContractEvent<
1305+
EscrowExpiredEvent.InputTuple,
1306+
EscrowExpiredEvent.OutputTuple,
1307+
EscrowExpiredEvent.OutputObject
1308+
>;
1309+
12781310
"EscrowFinished(bytes32,uint256)": TypedContractEvent<
12791311
EscrowFinishedEvent.InputTuple,
12801312
EscrowFinishedEvent.OutputTuple,

packages/fasset-indexer-core/chain/typechain/factories/ICoreVaultManager__factory.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,25 @@ const _abi = [
189189
name: "EmergencyPauseSenderRemoved",
190190
type: "event",
191191
},
192+
{
193+
anonymous: false,
194+
inputs: [
195+
{
196+
indexed: true,
197+
internalType: "bytes32",
198+
name: "preimageHash",
199+
type: "bytes32",
200+
},
201+
{
202+
indexed: false,
203+
internalType: "uint256",
204+
name: "amount",
205+
type: "uint256",
206+
},
207+
],
208+
name: "EscrowExpired",
209+
type: "event",
210+
},
192211
{
193212
anonymous: false,
194213
inputs: [

packages/fasset-indexer-core/src/config/constants.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,10 @@ export const EVENTS = {
122122
ESCROW_INSTRUCTIONS: "EscrowInstructions",
123123
TRANSFER_REQUEST_CANCELED: "TransferRequestCanceled",
124124
NOT_ALL_ESCROWS_PROCESSED: "NotAllEscrowsProcessed",
125+
ESCROW_EXPIRED: "EscrowExpired",
125126
ESCROW_FINISHED: "EscrowFinished",
126-
CUSTODIAN_ADDRESS_UPDATED: "CustodianAddressUpdated",
127-
SETTINGS_UPDATED: "SettingsUpdated"
127+
SETTINGS_UPDATED: "SettingsUpdated",
128+
CUSTODIAN_ADDRESS_UPDATED: "CustodianAddressUpdated"
128129
}
129130
} as const
130131

packages/fasset-indexer-core/src/indexer/eventlib/event-storer.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,9 @@ export class EventStorer {
275275
} case EVENTS.CORE_VAULT_MANAGER.CUSTODIAN_ADDRESS_UPDATED: {
276276
await this.onCustodianAddressUpdated(em, evmLog, log.args)
277277
break
278+
} case EVENTS.CORE_VAULT_MANAGER.ESCROW_EXPIRED: {
279+
await this.onEscrowExpired(em, evmLog, log.args)
280+
break
278281
} case EVENTS.CORE_VAULT_MANAGER.ESCROW_FINISHED: {
279282
await this.onEscrowFinished(em, evmLog, log.args)
280283
break
@@ -1373,6 +1376,16 @@ export class EventStorer {
13731376
})
13741377
}
13751378

1379+
protected async onEscrowExpired(
1380+
em: EntityManager,
1381+
evmLog: Entities.EvmLog,
1382+
logArgs: CoreVaultManager.EscrowExpiredEvent.OutputTuple
1383+
): Promise<Entities.EscrowExpired> {
1384+
const fasset = this.lookup.coreVaultManagerToFAssetType(evmLog.address.hex)
1385+
const [ preimageHash, amount ] = logArgs
1386+
return em.create(Entities.EscrowExpired, { evmLog, fasset, preimageHash, amount })
1387+
}
1388+
13761389
protected async onEscrowFinished(
13771390
em: EntityManager,
13781391
evmLog: Entities.EvmLog,

packages/fasset-indexer-core/src/orm/entities/events/core-vault-manager.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ export class CoreVaultManagerSettingsUpdated extends FAssetEventBound {
2121
fee!: bigint
2222
}
2323

24+
@Entity()
25+
export class CoreVaultManagerCustodianAddressUpdated extends FAssetEventBound {
26+
27+
@ManyToOne({ entity: () => UnderlyingAddress })
28+
custodian!: UnderlyingAddress
29+
}
30+
2431
@Entity()
2532
@Unique({ properties: ['fasset', 'transactionId'] })
2633
export class CoreVaultManagerPaymentConfirmed extends FAssetEventBound {
@@ -115,7 +122,7 @@ export class CoreVaultManagerTransferRequestCanceled extends FAssetEventBound {
115122
export class CoreVaultManagerNotAllEscrowsProcessed extends FAssetEventBound {}
116123

117124
@Entity()
118-
export class EscrowFinished extends FAssetEventBound {
125+
export class EscrowExpired extends FAssetEventBound {
119126

120127
@Property({ type: 'text', length: BYTES32_LENGTH })
121128
preimageHash!: string
@@ -125,8 +132,11 @@ export class EscrowFinished extends FAssetEventBound {
125132
}
126133

127134
@Entity()
128-
export class CoreVaultManagerCustodianAddressUpdated extends FAssetEventBound {
135+
export class EscrowFinished extends FAssetEventBound {
129136

130-
@ManyToOne({ entity: () => UnderlyingAddress })
131-
custodian!: UnderlyingAddress
137+
@Property({ type: 'text', length: BYTES32_LENGTH })
138+
preimageHash!: string
139+
140+
@Property({ type: new uint256() })
141+
amount!: bigint
132142
}

packages/fasset-indexer-core/src/orm/entities/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export {
6363
CoreVaultManagerEscrowInstructions, CoreVaultManagerNotAllEscrowsProcessed,
6464
CoreVaultManagerPaymentConfirmed, CoreVaultManagerPaymentInstructions,
6565
CoreVaultManagerSettingsUpdated, CoreVaultManagerTransferRequestCanceled,
66-
EscrowFinished
66+
EscrowExpired, EscrowFinished
6767
} from './events/core-vault-manager'
6868
export { PricesPublished } from './events/price'
6969
// underlying data

0 commit comments

Comments
 (0)