Skip to content

Commit

Permalink
Merge pull request #95 from reservoirprotocol/ted/upgrade-solver-capa…
Browse files Browse the repository at this point in the history
…city-to-v2

Upgrade getSolverCapacity method to use config/v2 api
  • Loading branch information
pedromcunha authored May 23, 2024
2 parents 1a3730e + 309af6e commit 275e690
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/plenty-doors-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@reservoir0x/relay-sdk': minor
---

Upgrade getSolverCapacity method to use config v2 api
6 changes: 3 additions & 3 deletions demo/pages/sdk/actions/getSolverCapacity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const GetSolverCapcityPage: NextPage = () => {
zora.id.toString()
)
const [originChainId, setOriginChainId] = useState<string>(base.id.toString())
const [currency, setCurrency] = useState<string>(zeroAddress)
const [currency, setCurrency] = useState<string>('eth')
const [user, setUser] = useState<string>(zeroAddress)
const { data: wallet } = useWalletClient()
const [response, setResponse] = useState<GetConfigResponse | null>(null)
Expand Down Expand Up @@ -82,8 +82,8 @@ const GetSolverCapcityPage: NextPage = () => {
const solverCapacity = await getClient()?.actions.getSolverCapacity({
destinationChainId,
originChainId,
user: zeroAddress,
currency: zeroAddress
user: user,
currency: currency as any
})
setResponse(solverCapacity)
}}
Expand Down
10 changes: 5 additions & 5 deletions packages/sdk/src/actions/getSolverCapacity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ export type GetConfigQueryParams = Required<
>
> &
Omit<
NonNullable<paths['/config']['get']['parameters']['query']>,
NonNullable<paths['/config/v2']['get']['parameters']['query']>,
'originChainId' | 'destinationChainId'
>

export type GetConfigResponse =
paths['/config']['get']['responses']['200']['content']['application/json']
paths['/config/v2']['get']['responses']['200']['content']['application/json']

export async function getSolverCapacity(
data: GetConfigQueryParams,
Expand All @@ -28,12 +28,12 @@ export async function getSolverCapacity(
throw new Error('Client not initialized')
}

// Fallback to zero address if user or currency are not provided
// Fallback to zero address if user is not provided
data.user = data.user || zeroAddress
data.currency = data.currency || zeroAddress
data.currency = data.currency

const response = await axiosInstance.get<GetConfigResponse>(
`${client.baseApiUrl}/config`,
`${client.baseApiUrl}/config/v2`,
{ params: data }
)

Expand Down

0 comments on commit 275e690

Please sign in to comment.