-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a81c4f5
commit 56797dd
Showing
6 changed files
with
112 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { Delegation } from 'universal-types'; | ||
import { getDelegationType } from './utils/get-delegation-type.js'; | ||
import { processLimitOrderDelegation } from './process-limit-order-delegation.js'; | ||
|
||
export async function processDelegation(delegation: Delegation) { | ||
const delegationType = getDelegationType(delegation); | ||
|
||
if (delegationType === 'LimitOrder') { | ||
return processLimitOrderDelegation(delegation); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
apps/api-delegations/src/processing/process-limit-order-delegation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type { Delegation } from 'universal-types'; | ||
|
||
export async function processLimitOrderDelegation(delegation: Delegation) { | ||
console.log('Processing Limit Order Delegation:', delegation); | ||
} |
21 changes: 21 additions & 0 deletions
21
apps/api-delegations/src/processing/utils/get-delegation-type.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type { Delegation } from 'universal-types'; | ||
import { universalDeployments } from 'universal-data'; | ||
|
||
// TODO: Extract type/function and make it globally available | ||
export type DelegationType = 'LimitOrder'; | ||
|
||
export function getDelegationType( | ||
delegation: Delegation, | ||
): DelegationType | null { | ||
// TODO: Add more robust logic to determine delegation type | ||
if ( | ||
delegation.caveats.some( | ||
({ enforcer }) => | ||
enforcer.toLowerCase() === | ||
universalDeployments.ExternalHookEnforcer.toLowerCase(), | ||
) | ||
) { | ||
return 'LimitOrder'; | ||
} | ||
return null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
export const caveatEnforcerAbi = [ | ||
{ | ||
type: 'function', | ||
name: 'afterAllHook', | ||
inputs: [ | ||
{ name: '', type: 'bytes', internalType: 'bytes' }, | ||
{ name: '', type: 'bytes', internalType: 'bytes' }, | ||
{ name: '', type: 'bytes32', internalType: 'ModeCode' }, | ||
{ name: '', type: 'bytes', internalType: 'bytes' }, | ||
{ name: '', type: 'bytes32', internalType: 'bytes32' }, | ||
{ name: '', type: 'address', internalType: 'address' }, | ||
{ name: '', type: 'address', internalType: 'address' }, | ||
], | ||
outputs: [], | ||
stateMutability: 'nonpayable', | ||
}, | ||
{ | ||
type: 'function', | ||
name: 'afterHook', | ||
inputs: [ | ||
{ name: '', type: 'bytes', internalType: 'bytes' }, | ||
{ name: '', type: 'bytes', internalType: 'bytes' }, | ||
{ name: '', type: 'bytes32', internalType: 'ModeCode' }, | ||
{ name: '', type: 'bytes', internalType: 'bytes' }, | ||
{ name: '', type: 'bytes32', internalType: 'bytes32' }, | ||
{ name: '', type: 'address', internalType: 'address' }, | ||
{ name: '', type: 'address', internalType: 'address' }, | ||
], | ||
outputs: [], | ||
stateMutability: 'nonpayable', | ||
}, | ||
{ | ||
type: 'function', | ||
name: 'beforeAllHook', | ||
inputs: [ | ||
{ name: '', type: 'bytes', internalType: 'bytes' }, | ||
{ name: '', type: 'bytes', internalType: 'bytes' }, | ||
{ name: '', type: 'bytes32', internalType: 'ModeCode' }, | ||
{ name: '', type: 'bytes', internalType: 'bytes' }, | ||
{ name: '', type: 'bytes32', internalType: 'bytes32' }, | ||
{ name: '', type: 'address', internalType: 'address' }, | ||
{ name: '', type: 'address', internalType: 'address' }, | ||
], | ||
outputs: [], | ||
stateMutability: 'nonpayable', | ||
}, | ||
{ | ||
type: 'function', | ||
name: 'beforeHook', | ||
inputs: [ | ||
{ name: '', type: 'bytes', internalType: 'bytes' }, | ||
{ name: '', type: 'bytes', internalType: 'bytes' }, | ||
{ name: '', type: 'bytes32', internalType: 'ModeCode' }, | ||
{ name: '', type: 'bytes', internalType: 'bytes' }, | ||
{ name: '', type: 'bytes32', internalType: 'bytes32' }, | ||
{ name: '', type: 'address', internalType: 'address' }, | ||
{ name: '', type: 'address', internalType: 'address' }, | ||
], | ||
outputs: [], | ||
stateMutability: 'nonpayable', | ||
}, | ||
] as const; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters