Skip to content

Commit

Permalink
solana: add listeners
Browse files Browse the repository at this point in the history
  • Loading branch information
a5-pickle committed Apr 6, 2024
1 parent 405aba1 commit 6b52f55
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 0 deletions.
24 changes: 24 additions & 0 deletions solana/target/idl/matching_engine.json
Original file line number Diff line number Diff line change
Expand Up @@ -3125,6 +3125,18 @@
}
]
},
{
"name": "Enacted",
"fields": [
{
"name": "action",
"type": {
"defined": "ProposalAction"
},
"index": false
}
]
},
{
"name": "OrderExecuted",
"fields": [
Expand All @@ -3146,6 +3158,18 @@
"index": false
}
]
},
{
"name": "Proposed",
"fields": [
{
"name": "action",
"type": {
"defined": "ProposalAction"
},
"index": false
}
]
}
],
"errors": [
Expand Down
48 changes: 48 additions & 0 deletions solana/target/types/matching_engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3125,6 +3125,18 @@ export type MatchingEngine = {
}
]
},
{
"name": "Enacted",
"fields": [
{
"name": "action",
"type": {
"defined": "ProposalAction"
},
"index": false
}
]
},
{
"name": "OrderExecuted",
"fields": [
Expand All @@ -3146,6 +3158,18 @@ export type MatchingEngine = {
"index": false
}
]
},
{
"name": "Proposed",
"fields": [
{
"name": "action",
"type": {
"defined": "ProposalAction"
},
"index": false
}
]
}
],
"errors": [
Expand Down Expand Up @@ -6487,6 +6511,18 @@ export const IDL: MatchingEngine = {
}
]
},
{
"name": "Enacted",
"fields": [
{
"name": "action",
"type": {
"defined": "ProposalAction"
},
"index": false
}
]
},
{
"name": "OrderExecuted",
"fields": [
Expand All @@ -6508,6 +6544,18 @@ export const IDL: MatchingEngine = {
"index": false
}
]
},
{
"name": "Proposed",
"fields": [
{
"name": "action",
"type": {
"defined": "ProposalAction"
},
"index": false
}
]
}
],
"errors": [
Expand Down
17 changes: 17 additions & 0 deletions solana/ts/src/matchingEngine/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
MessageProtocol,
PreparedOrderResponse,
Proposal,
ProposalAction,
RedeemedFastFill,
RouterEndpoint,
} from "./state";
Expand Down Expand Up @@ -155,6 +156,14 @@ export type OrderExecuted = {
targetProtocol: MessageProtocol;
};

export type Proposed = {
action: ProposalAction;
};

export type Enacted = {
action: ProposalAction;
};

export class MatchingEngineProgram {
private _programId: ProgramId;
private _mint: PublicKey;
Expand Down Expand Up @@ -189,6 +198,14 @@ export class MatchingEngineProgram {
return this.program.addEventListener("OrderExecuted", callback);
}

onProposed(callback: (event: Proposed, slot: number, signature: string) => void) {
return this.program.addEventListener("Proposed", callback);
}

onEnacted(callback: (event: Enacted, slot: number, signature: string) => void) {
return this.program.addEventListener("Enacted", callback);
}

custodianAddress(): PublicKey {
return Custodian.address(this.ID);
}
Expand Down

0 comments on commit 6b52f55

Please sign in to comment.