Skip to content

Commit

Permalink
Merge pull request #68 from reservoirprotocol/ted/grwth-4324-add-usee…
Browse files Browse the repository at this point in the history
…xactinput-parameter-to-bridge-action

Sync api types + add useExactInput parameter to demo
  • Loading branch information
ted-palmer authored Apr 18, 2024
2 parents ba44daf + 0dbeb4a commit 3b11d4f
Show file tree
Hide file tree
Showing 5 changed files with 366 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/moody-frogs-exist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@reservoir0x/relay-sdk': patch
---

Sync api types + add useExactInput parameter to demo
15 changes: 14 additions & 1 deletion demo/pages/sdk/actions/bridge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const BridgeActionPage: NextPage = () => {
const [currency, setCurrency] =useState<BridgeActionParameters['currency']>('eth')
const [usePermit, setUsePermit] = useState(false)
const [canonical, setCanonical] = useState(false)
const [useExactInput, setUseExactInput] = useState(false)
const [toChainId, setToChainId] = useState<number>(zora.id)
const [fromChainId, setFromChainId] = useState<number>(base.id)
const [depositGasLimit, setDepositGasLimit] = useState("")
Expand Down Expand Up @@ -91,6 +92,17 @@ const BridgeActionPage: NextPage = () => {
/>
</div>

<div>
<label>Use Exact Input: </label>
<input
type="checkbox"
checked={useExactInput}
onChange={(e) => {
setUseExactInput(e.target.checked)
}}
/>
</div>

<div>
<label>Recipient: </label>
<input placeholder='Who is the receiver?' value={recipient} onChange={(e) => setRecipient(e.target.value)} />
Expand Down Expand Up @@ -132,7 +144,8 @@ const BridgeActionPage: NextPage = () => {
depositGasLimit,
options: {
usePermit: usePermit,
useExternalLiquidity: canonical
useExternalLiquidity: canonical,
useExactInput: useExactInput
},
onProgress: (steps, fees, currentStep, currentStepItem, txHashes) => {
console.log(steps, fees, currentStep, currentStepItem, txHashes)
Expand Down
16 changes: 16 additions & 0 deletions demo/pages/sdk/methods/getBridgeQuote.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const GetBridgeQuotePage: NextPage = () => {
const [currency, setCurrency] =useState<BridgeActionParameters['currency']>('eth')
const [toChainId, setToChainId] = useState<number>(zora.id)
const [fromChainId, setFromChainId] = useState<number>(base.id)
const [useExactInput, setUseExactInput] = useState(false)
const { data: wallet } = useWalletClient()
const [response, setResponse] = useState<Execute |null>(null)

Expand Down Expand Up @@ -68,6 +69,18 @@ const GetBridgeQuotePage: NextPage = () => {
<label>To: </label>
<input placeholder='Who is the receiver?' value={recipient} onChange={(e) => setRecipient(e.target.value)} />
</div>

<div>
<label>Use Exact Input: </label>
<input
type="checkbox"
checked={useExactInput}
onChange={(e) => {
setUseExactInput(e.target.checked)
}}
/>
</div>

<button
style={{
marginTop: 50,
Expand Down Expand Up @@ -95,6 +108,9 @@ const GetBridgeQuotePage: NextPage = () => {
amount,
currency,
recipient: recipient ? recipient as Address : undefined,
options:{
useExactInput: useExactInput
}
})
setResponse(quote as Execute)
}}>
Expand Down
1 change: 1 addition & 0 deletions packages/sdk/src/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ export const routes = [
"/transactions/index",
"/transactions/status",
"/users/balance",
"/conduit/install",
"/prices/rates"
];
Loading

0 comments on commit 3b11d4f

Please sign in to comment.