Repository navigation
feat(sdk): add limit order actions and run quote/v3 style steps - #1184
pedromcunha-uneven wants to merge 4 commits into
Conversation
Add createOrder, getOrders, signOrder, cancelOrder and executeOrder for the Orders API, with Order types. executeSteps now also accepts flat steps that carry status, data and check on the step, alongside legacy items steps, and order steps run through it. Amp-Thread-ID: https://ampcode.com/threads/T-01a1cbc7-42ee-7072-956d-ef88023ffd1d
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Claude finished @pedromcunha-uneven's task in 50s —— View job Code Review: 2 issues found, both minor
Other things I checked that look correct:
|
|
Claude finished @pedromcunha-uneven's task in 30s —— View job 📝 Docs Drift Check — Confidence: LOW (below configured floor: medium) What changed: The SDK adds five limit-order actions on Why I didn't draft: The docs have no public page for the Orders API: no endpoint reference, no feature guide, and no mention of limit orders. SDK action pages would be the first public description of the feature. Whether it has launched, and how it should be introduced (feature guide, then API reference, then SDK), can't be decided from this diff alone. Pages likely affected:
Suggested next step: Open an issue or PR in |
[High impact] The changes since the previous review appear safe to merge.
|
|
Claude finished @pedromcunha-uneven's task in 25s —— View job Code Review: No issues found. I reviewed 10 files (+687/−3) for correctness, security, error handling and the repo guidelines. Since the last review:
Also checked, and these look correct:
|
|
Claude finished @pedromcunha-uneven's task in 19s —— View job 📝 Docs Drift Check — Confidence: LOW (below configured floor: medium) What changed: The SDK adds five limit-order actions on Why I didn't draft: The docs say nothing about limit orders or the Orders API yet: no endpoint reference, no feature guide and no mention of the feature. These SDK action pages would be its first public description, and this diff can't tell me whether it has launched or how it should be introduced. Pages likely affected:
Suggested next step: once the Orders API is public, open an issue or PR in |
| @@ -0,0 +1,185 @@ | |||
| import type { AxiosRequestConfig } from 'axios' | |||
There was a problem hiding this comment.
Can we break this file into separate files for each action which is the preexisting pattern here. We can put them into a folder called "orders" to organize them better.
There was a problem hiding this comment.
Done in 11da509. Each action now has its own file under packages/sdk/src/actions/orders/: createOrder.ts, getOrders.ts, signOrder.ts, cancelOrder.ts and executeOrder.ts, plus an index.ts that re-exports them. The shared request helper lives in requestOrders.ts and is not exported. The public exports are unchanged, and the tests moved to orders/orders.test.ts.
…rders-sdk-actions-create-get-cancel
Summary
Adds SDK actions for the Orders API (limit orders) and lets
executeStepsrun quote/v3-style flat steps, which is the step format the Orders API returns. Order steps run through the same execution path as quote steps.Changes and decisions to review
packages/sdk/src/actions/orders.ts, also available onclient.actions:createOrder(POST /orders, optionalidempotencyKeysent asIdempotency-Key),getOrders(GET /orders),signOrder(POST /orders/:orderId/signature),cancelOrder(POST /orders/:orderId/cancel) andexecuteOrder.wallet,createOrderandcancelOrderrun the order's steps and report progress throughonProgress. Without one, they return the order so its steps can run later withexecuteOrder, for example to resume apendingorder read withgetOrders.executeOrderhands the order's steps toexecuteSteps. It clones them first, asexecute()does, so the caller'sOrderis not mutated (executeStepswritesreferrerinto post bodies). It then reads the order back withGET /orders?orderId=, becauseexecuteStepsdoes not surface the signature post's response.signOrdersends the signature as thesignaturequery param, the same wayexecuteStepsposts signature steps, with a JSON{}body.cancelOrderis a soft cancel unlessonchain: trueis passed; withonchainand a wallet, it sends the returnedcanceltransaction.getOrderstakesstatusas an array and sends it comma-separated.executeStepsaccepts flat steps (status,dataandcheckon the step) as well as legacyitemssteps. Flat steps are converted to theitemsshape internally, soonProgressand the returned steps keep today's shape. A flat step without arequestIdtakes the response's top-levelrequestId, a new optional field onExecute.Execute's step id union is unchanged. Only the newFlatExecuteStepinput type includes the order step ids (cancel,withdraw). WideningExecutebreaks assigning it to quote response types, as the UI does inisGasSponsored.types/Order.ts, because the Orders endpoints are not in the generated API types yet.executeSteps.Testing
packages/sdk:vitest run, 110 passed. Neworders.test.tscovers create with approval and signature, create without a wallet, list params, soft cancel and onchain cancel. A newexecuteStepstest runs flat steps. Each new test fails when the behavior it covers is reverted.tsc --noEmitpasses forpackages/sdkandpackages/ui.APIError.rawError.errorCode; onchain cancel; resume withexecuteOrder; andsignOrderdirectly.