Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/nextjs-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@headlessui/react": "^2.2.0",
"@rainbow-me/rainbowkit": "^2.2.8",
"@rozoai/intent-common": "0.1.7",
"@rozoai/intent-pay": "0.1.7",
"@rozoai/intent-pay": "0.1.9",
"@tanstack/react-query": "^5.51.11",
"@types/react-syntax-highlighter": "^15.5.13",
"@wagmi/core": "^2.22.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/connectkit/bundle-analysis.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/connectkit/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@rozoai/intent-pay",
"private": false,
"version": "0.1.7",
"version": "0.1.9",
"author": "RozoAI",
"homepage": "https://github.com/RozoAI/intent-pay",
"license": "BSD-2-Clause",
Expand Down
33 changes: 26 additions & 7 deletions packages/connectkit/src/payment/paymentEffects.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
ApiVersion,
assert,
baseEURC,
baseUSDC,
CreateNewPaymentParams,
createPayment,
Expand Down Expand Up @@ -390,8 +391,15 @@ async function runHydratePayParamsEffects(
? Number(toUnits)
: Number(toUnits) - Number(walletOption?.fees.usd ?? 0);

const toTokenAddress = order.destFinalCallTokenAmount.token.token;
const toChain = getOrderDestChainId(order);
const toToken = order.destFinalCallTokenAmount.token.token;
const toToken = getKnownToken(toChain, toTokenAddress);

if (!toToken) {
throw new Error(
`Token not found for chain ${toChain} and token ${toTokenAddress}`
);
}

/**
* ROZO API CALL
Expand All @@ -407,15 +415,26 @@ async function runHydratePayParamsEffects(
toAddress = payParams.toStellarAddress;
}

const preferredChain =
walletOption?.required.token.chainId ?? baseUSDC.chainId;
const preferredTokenAddress =
walletOption?.required.token.token ?? baseUSDC.token;
// TODO: If we want to add another currency OR EUR support for other chains

let preferredChain = 0;
let preferredTokenAddress = "";

if (walletOption) {
preferredChain = walletOption.required.token.chainId;
preferredTokenAddress = walletOption.required.token.token;
} else {
const isNonUSDToken = toToken.fiatISO !== "USD";

preferredChain = isNonUSDToken ? baseEURC.chainId : baseUSDC.chainId;
preferredTokenAddress = isNonUSDToken ? baseEURC.token : baseUSDC.token;
}

const title =
payParams?.metadata?.intent ??
generateIntentTitle({
toChainId: toChain,
toTokenAddress: toToken,
toTokenAddress: toTokenAddress,
preferredChainId: preferredChain,
preferredTokenAddress: preferredTokenAddress,
});
Expand All @@ -440,7 +459,7 @@ async function runHydratePayParamsEffects(
description: payParams?.metadata?.description ?? "",
feeType,
toChain,
toToken,
toToken: toTokenAddress,
toAddress,
toUnits: calculatedToUnits.toFixed(2),
preferredChain,
Expand Down
24 changes: 12 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.