diff --git a/demo/pages/sdk/actions/bridge.tsx b/demo/pages/sdk/actions/bridge.tsx index 048dc330..7031db83 100644 --- a/demo/pages/sdk/actions/bridge.tsx +++ b/demo/pages/sdk/actions/bridge.tsx @@ -11,6 +11,7 @@ const BridgeActionPage: NextPage = () => { const [amount, setAmount] = useState("") const [currency, setCurrency] =useState('eth') const [usePermit, setUsePermit] = useState(false) + const [canonical, setCanonical] = useState(false) const [toChainId, setToChainId] = useState(zora.id) const [fromChainId, setFromChainId] = useState(base.id) const [depositGasLimit, setDepositGasLimit] = useState("") @@ -70,26 +71,24 @@ const BridgeActionPage: NextPage = () => {
-
- setUsePermit(true)} - /> - -
-
- setUsePermit(false)} - /> - -
+ { + setUsePermit(e.target.checked) + }} + /> +
+ +
+ + { + setCanonical(e.target.checked) + }} + />
@@ -132,7 +131,8 @@ const BridgeActionPage: NextPage = () => { recipient: recipient ? recipient as Address : undefined, depositGasLimit, options: { - usePermit: usePermit + usePermit: usePermit, + useExternalLiquidity: canonical }, onProgress: (steps, fees, currentStep, currentStepItem, txHashes) => { console.log(steps, fees, currentStep, currentStepItem, txHashes) diff --git a/packages/sdk/src/utils/executeSteps.ts b/packages/sdk/src/utils/executeSteps.ts index a93bfc49..2fbec86d 100644 --- a/packages/sdk/src/utils/executeSteps.ts +++ b/packages/sdk/src/utils/executeSteps.ts @@ -35,14 +35,14 @@ export async function executeSteps( setState: ( steps: Execute['steps'], fees?: Execute['fees'], - breakdown?: Execute['breakdown'] + breakdown?: Execute['breakdown'], ) => any, newJson?: Execute, stepOptions?: { [stepId: string]: { gasLimit?: string } - } + }, ) { const client = getClient() @@ -94,7 +94,7 @@ export async function executeSteps( } incompleteStepItemIndex = step.items.findIndex( - (item) => item.status == 'incomplete' + (item) => item.status == 'incomplete', ) if (incompleteStepItemIndex !== -1) { incompleteStepIndex = i @@ -124,7 +124,7 @@ export async function executeSteps( if (!stepItems) { client.log( ['Execute Steps: skipping step, no items in step'], - LogLevel.Verbose + LogLevel.Verbose, ) return } @@ -135,12 +135,12 @@ export async function executeSteps( if (!stepItem.data) { client.log( ['Execute Steps: step item data is missing, begin polling'], - LogLevel.Verbose + LogLevel.Verbose, ) json = (await pollUntilHasData(request, (json) => { client.log( ['Execute Steps: step item data is missing, polling', json], - LogLevel.Verbose + LogLevel.Verbose, ) const data = json as Execute // An item is ready if: @@ -169,7 +169,7 @@ export async function executeSteps( } client.log( [`Execute Steps: Begin processing step items for: ${step.action}`], - LogLevel.Verbose + LogLevel.Verbose, ) const promises = stepItems @@ -191,7 +191,7 @@ export async function executeSteps( [ 'Execute Steps: Begin transaction step for, sending transaction', ], - LogLevel.Verbose + LogLevel.Verbose, ) // if chainId is present in the tx data field then you should relay the tx on that chain @@ -212,14 +212,14 @@ export async function executeSteps( 'Execute Steps: Transaction step, got transactions', txHashes, ], - LogLevel.Verbose + LogLevel.Verbose, ) stepItem.txHashes = txHashes if (json) { setState( [...json.steps], { ...json?.fees }, - json?.breakdown + json?.breakdown, ) } }, @@ -229,13 +229,13 @@ export async function executeSteps( setState( [...json.steps], { ...json?.fees }, - json?.breakdown + json?.breakdown, ) } }, request, undefined, - crossChainIntentChainId + crossChainIntentChainId, ) } catch (e) { throw e @@ -250,12 +250,12 @@ export async function executeSteps( const postData = stepData['post'] client.log( ['Execute Steps: Begin signature step'], - LogLevel.Verbose + LogLevel.Verbose, ) if (signData) { signature = await wallet.handleSignMessageStep( stepItem as SignatureStepItem, - step + step, ) if (signature) { @@ -269,7 +269,7 @@ export async function executeSteps( if (postData) { client.log(['Execute Steps: Posting order'], LogLevel.Verbose) const postOrderUrl = new URL( - `${request.baseURL}${postData.endpoint}` + `${request.baseURL}${postData.endpoint}`, ) const headers = { 'Content-Type': 'application/json', @@ -298,7 +298,7 @@ export async function executeSteps( setState( [...json?.steps], { ...json?.fees }, - json?.breakdown + json?.breakdown, ) await pollUntilOk( @@ -313,7 +313,7 @@ export async function executeSteps( `Execute Steps: Polling execute status to check if indexed`, res, ], - LogLevel.Verbose + LogLevel.Verbose, ) if ( res?.data?.status === 'success' && @@ -328,7 +328,7 @@ export async function executeSteps( chainId: res.data.destinationChainId ?? chain?.id, } - } + }, ) if (res?.data?.inTxHashes) { @@ -341,7 +341,7 @@ export async function executeSteps( chainId: res.data.destinationChainId ?? chain?.id, } - } + }, ) stepItem.internalTxHashes = chainInTxHashes } @@ -350,14 +350,14 @@ export async function executeSteps( return true } else if (res?.data?.status === 'failure') { throw Error( - res?.data?.details || 'Transaction failed' + res?.data?.details || 'Transaction failed', ) } return false }, maximumAttempts, 0, - pollingInterval + pollingInterval, ) } @@ -377,7 +377,7 @@ export async function executeSteps( setState( [...json?.steps], { ...json?.fees }, - json?.breakdown + json?.breakdown, ) } catch (err) { throw err @@ -424,12 +424,12 @@ export async function executeSteps( } catch (blockError) { client.log( ['Execute Steps: Failed to get block number', blockError], - LogLevel.Error + LogLevel.Error, ) } client.log( ['Execute Steps: An error occurred', err, 'Block Number:', blockNumber], - LogLevel.Error + LogLevel.Error, ) if (json) { diff --git a/packages/sdk/src/utils/transaction.ts b/packages/sdk/src/utils/transaction.ts index 69848f16..790f365c 100644 --- a/packages/sdk/src/utils/transaction.ts +++ b/packages/sdk/src/utils/transaction.ts @@ -115,8 +115,7 @@ export async function sendTransactionSafely( !transactionCancelled ) { let res - - if (item?.check?.endpoint) { + if (item?.check?.endpoint && !request.data.useExternalLiquidity) { res = await axios.request({ url: `${request.baseURL}${item?.check?.endpoint}`, method: item?.check?.method,