-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use step functions for order status (#362)
* use step functions for limit orders * step function retry * cleanup * fix tests * fix tests * code review changes
- Loading branch information
1 parent
d68a235
commit 8d83309
Showing
10 changed files
with
131 additions
and
76 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
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
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
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,32 @@ | ||
import { SFNClient, StartExecutionCommand } from '@aws-sdk/client-sfn' | ||
import { OrderType } from '@uniswap/uniswapx-sdk' | ||
import { ORDER_STATUS } from '../../entities' | ||
import { log } from '../../Logging' | ||
import { checkDefined } from '../../preconditions/preconditions' | ||
|
||
export type OrderTrackingSfnInput = { | ||
orderHash: string | ||
chainId: number | ||
orderStatus: ORDER_STATUS | ||
quoteId: string | ||
orderType: OrderType | ||
stateMachineArn: string | ||
} | ||
|
||
//TODO: remove random for sfn name | ||
//this is to stop collisions in the running step function name | ||
const BIG_NUMBER = 1000000000000000000000 | ||
|
||
export async function kickoffOrderTrackingSfn(sfnInput: OrderTrackingSfnInput, stateMachineArn: string) { | ||
log.info('starting state machine') | ||
const region = checkDefined(process.env['REGION']) | ||
const sfnClient = new SFNClient({ region: region }) | ||
const rand = Math.floor(Math.random() * BIG_NUMBER) | ||
const startExecutionCommand = new StartExecutionCommand({ | ||
stateMachineArn: stateMachineArn, | ||
input: JSON.stringify(sfnInput), | ||
name: sfnInput.orderHash + '_' + rand, | ||
}) | ||
log.info('Starting state machine execution', { startExecutionCommand }) | ||
await sfnClient.send(startExecutionCommand) | ||
} |
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
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