-
Notifications
You must be signed in to change notification settings - Fork 66
feat(gateway): list orders's output tokens #711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,6 @@ | ||||||||||||||||||||||||||||||||||
| import type { EsploraClient } from '../esplora'; | ||||||||||||||||||||||||||||||||||
| import { Address, Hex } from 'viem'; | ||||||||||||||||||||||||||||||||||
| import { offrampCaller, strategyCaller } from './abi'; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| type ChainSlug = string | number; | ||||||||||||||||||||||||||||||||||
| type TokenSymbol = string; | ||||||||||||||||||||||||||||||||||
|
|
@@ -310,6 +310,10 @@ | |||||||||||||||||||||||||||||||||
| /** @description The output amount (from strategies) */ | ||||||||||||||||||||||||||||||||||
| outputTokenAmount?: string; | ||||||||||||||||||||||||||||||||||
| /** @description The tx hash on the EVM chain */ | ||||||||||||||||||||||||||||||||||
| outputTokenAddresses?: EvmAddress[]; | ||||||||||||||||||||||||||||||||||
| /** @description The output amount (from strategies) */ | ||||||||||||||||||||||||||||||||||
| outputTokenAmounts?: string[]; | ||||||||||||||||||||||||||||||||||
| /** @description The tx hash on the EVM chain */ | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+313
to
+316
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainFix type reference and incorrect JSDoc for multi-output fields
Apply this diff: - /** @description The tx hash on the EVM chain */
- outputTokenAddresses?: EvmAddress[];
+ /** @description Output token contract addresses (from strategies). Matches outputTokenAmounts by index. */
+ outputTokenAddresses?: Address[];
/** @description The output amount (from strategies) */
outputTokenAmounts?: string[];Run to confirm EvmAddress isn’t defined anywhere: 🏁 Script executed: #!/bin/bash
rg -n -C2 '\bEvmAddress\b'Length of output: 394 🏁 Script executed: #!/bin/bash
rg -n "import.*\bAddress\b" -C2 sdk/src/gateway/types.tsLength of output: 208 Fix undefined EvmAddress and correct JSDoc for outputTokenAddresses
--- a/sdk/src/gateway/types.ts
+++ b/sdk/src/gateway/types.ts
@@ lines 311-316
- /** @description The tx hash on the EVM chain */
- outputTokenAddresses?: EvmAddress[];
+ /** @description Output token contract addresses (from strategies). Matches outputTokenAmounts by index. */
+ outputTokenAddresses?: Address[];
/** @description The output amount (from strategies) */
outputTokenAmounts?: string[];📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||
| txHash?: string; | ||||||||||||||||||||||||||||||||||
| /** @description V4 order details */ | ||||||||||||||||||||||||||||||||||
| orderDetails?: OrderDetails; | ||||||||||||||||||||||||||||||||||
|
|
@@ -348,11 +352,16 @@ | |||||||||||||||||||||||||||||||||
| 'satsToConvertToEth' | ||||||||||||||||||||||||||||||||||
| > & { | ||||||||||||||||||||||||||||||||||
| /** @description Get the actual token address received */ | ||||||||||||||||||||||||||||||||||
| /** @deprecated use getOutputTokenAmounts instead */ | ||||||||||||||||||||||||||||||||||
| getTokenAddress(): string | undefined; | ||||||||||||||||||||||||||||||||||
| /** @description Get the actual token received */ | ||||||||||||||||||||||||||||||||||
| /** @deprecated use getOutputTokenAmounts instead */ | ||||||||||||||||||||||||||||||||||
| getToken(): Token | undefined; | ||||||||||||||||||||||||||||||||||
| /** @description Get the actual amount received of the token */ | ||||||||||||||||||||||||||||||||||
| /** @deprecated use getOutputTokenAmounts instead */ | ||||||||||||||||||||||||||||||||||
| getTokenAmount(): string | number | undefined; | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
| /** @deprecated use getOutputTokenAmounts instead */ | |
| getTokenAddress(): string | undefined; | |
| /** @description Get the actual token received */ | |
| /** @deprecated use getOutputTokenAmounts instead */ | |
| getToken(): Token | undefined; | |
| /** @description Get the actual amount received of the token */ | |
| /** @deprecated use getOutputTokenAmounts instead */ | |
| getTokenAmount(): string | number | undefined; | |
| /** @deprecated use getOutputs() instead */ | |
| getTokenAddress(): string | undefined; | |
| /** @description Get the actual token received */ | |
| /** @deprecated use getOutputs() instead */ | |
| getToken(): Token | undefined; | |
| /** @description Get the actual amount received of the token */ | |
| /** @deprecated use getOutputs() instead */ | |
| getTokenAmount(): string | number | undefined; |
🤖 Prompt for AI Agents
In sdk/src/gateway/types.ts around lines 355 to 362, the deprecation JSDoc
refers to a non-existent getOutputTokenAmounts API; update the deprecation notes
to point to the correct replacement getOutputs(). Edit the three deprecated
method comments (getTokenAddress, getToken, getTokenAmount) so their
"@deprecated" lines say "use getOutputs() instead" and optionally update any
accompanying "@description" text to match the new API naming.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Fix getOutputs: wrong this context, return type mismatch, and undefined return
Issues:
Apply this diff to make getOutputs robust and type-safe:
outputToken: ADDRESS_LOOKUP[chainId][order.outputTokenAddress!],
If the guarantee doesn’t hold, update it to:
outputToken: order.outputTokenAddress ? ADDRESS_LOOKUP[chainId][order.outputTokenAddress] : undefined,
🏁 Script executed:
Length of output: 4735
🏁 Script executed:
Length of output: 6794
🏁 Script executed:
Length of output: 422
🏁 Script executed:
Length of output: 2063
Fix getOutputs and singular outputToken lookup
The current implementation uses
this.chainId, doesn’t guard optional arrays, and can returnundefinedor mismatched tuples, whileorder.outputTokenAddressis optional but asserted non-null.Attention needed in
sdk/src/gateway/client.ts:order.outputTokenAddressbefore lookupchainId, default to empty arrays, filter out invalid entries, and cast to[Token, string]Apply this diff:
These changes ensure the correct
chainIdis used, optional data is handled safely, and the return type matches[Token, string][].📝 Committable suggestion
🤖 Prompt for AI Agents