Skip to content

Commit 2987f93

Browse files
committed
Merge pull-request #1081
2 parents b6192df + 27c5cbc commit 2987f93

File tree

7 files changed

+40
-16
lines changed

7 files changed

+40
-16
lines changed

examples/react-components/src/app/dashboard/OnRamp.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const OnRamp = ({ ethAddress }: OnRampProps) => {
4646
);
4747
}
4848
} catch (error) {
49-
console.error("Failed to init Coinbase on-ramp:", error);
49+
console.error("Failed to init Coinbase onramp:", error);
5050
}
5151
};
5252

@@ -74,7 +74,7 @@ export const OnRamp = ({ ethAddress }: OnRampProps) => {
7474
);
7575
}
7676
} catch (error) {
77-
console.error("Failed to init MoonPay on-ramp:", error);
77+
console.error("Failed to init MoonPay onramp:", error);
7878
}
7979
};
8080

examples/react-wallet-kit/src/components/demo/DemoPanel.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export default function DemoPanel() {
5353
handleImportWallet,
5454
handleConnectExternalWallet,
5555
fetchWalletProviders,
56+
handleOnRamp,
5657
} = useTurnkey();
5758

5859
const { pushPage } = useModal();
@@ -112,6 +113,18 @@ export default function DemoPanel() {
112113
}
113114
}, [wallets]);
114115

116+
const handleAddFunds = async () => {
117+
try {
118+
await handleOnRamp({
119+
onrampProvider: "FIAT_ON_RAMP_PROVIDER_MOONPAY",
120+
walletAccount: selectedWalletAccount!,
121+
sandboxMode: true,
122+
});
123+
} catch (error) {
124+
handleError(error);
125+
}
126+
};
127+
115128
function truncateAddress(address: string) {
116129
return `${address.slice(0, 4)}...${address.slice(-4)}`;
117130
}
@@ -385,6 +398,13 @@ export default function DemoPanel() {
385398
>
386399
Sign Message
387400
</Button>
401+
402+
<Button
403+
className="bg-primary-light dark:bg-primary-dark text-primary-text-light dark:text-primary-text-dark rounded-lg px-4 py-2 active:scale-95 transition-transform cursor-pointer"
404+
onClick={handleAddFunds}
405+
>
406+
Add Funds
407+
</Button>
388408
{selectedWallet?.source === WalletSource.Embedded && (
389409
<>
390410
<hr className="border-draggable-background-light dark:border-draggable-background-dark" />

examples/with-sdk-js/src/app/page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export default function AuthPage() {
163163
const handleOnRamp = async () => {
164164
try {
165165
if (!wallets.length || !wallets[0].accounts?.length) {
166-
console.error("No wallets available for on-ramp");
166+
console.error("No wallets available for onramp");
167167
return;
168168
}
169169

@@ -172,7 +172,7 @@ export default function AuthPage() {
172172
);
173173

174174
if (!evmAccount) {
175-
console.error("No EVM-compatible account found for on-ramp");
175+
console.error("No EVM-compatible account found for onramp");
176176
return;
177177
}
178178

@@ -183,7 +183,7 @@ export default function AuthPage() {
183183
sandboxMode: true,
184184
});
185185
} catch (err) {
186-
console.error("Fiat On-Ramp failed:", err);
186+
console.error("Fiat OnRamp failed:", err);
187187
}
188188
};
189189

packages/react-wallet-kit/src/components/onramp/OnRamp.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export function OnRampPage({
5454
)}
5555
>
5656
<ActionPage
57-
title="Initiating On-Ramp"
57+
title="Initiating OnRamp"
5858
icon={icon}
5959
action={async () => {
6060
try {
@@ -72,7 +72,7 @@ export function OnRampPage({
7272
: "Use the MoonPay popup to finish funding your account."}
7373
</div>
7474
{sandboxMode && (
75-
<div className="mt-2 text-xs text-blue-500 dark:text-blue-400">
75+
<div className="mt-2 text-xs text-primary-light dark:text-primary-dark">
7676
Sandbox mode — no real funds will be used.
7777
</div>
7878
)}

packages/react-wallet-kit/src/providers/client/Provider.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5331,7 +5331,11 @@ export const ClientProvider: React.FC<ClientProviderProps> = ({
53315331
pollingRef.current = null;
53325332
}
53335333
};
5334-
5334+
useEffect(() => {
5335+
return () => {
5336+
cleanup();
5337+
};
5338+
}, []);
53355339
const action = async () => {
53365340
try {
53375341
let onRampWindow: Window | null = null;
@@ -5460,14 +5464,14 @@ export const ClientProvider: React.FC<ClientProviderProps> = ({
54605464
};
54615465

54625466
pushPage({
5463-
key: "Fiat On-Ramp",
5467+
key: "Fiat OnRamp",
54645468
content: <OnRampContainer />,
54655469
showTitle: false,
54665470
preventBack: true,
54675471
onClose: () =>
54685472
reject(
54695473
new TurnkeyError(
5470-
"User canceled the on-ramp process.",
5474+
"User canceled the onramp process.",
54715475
TurnkeyErrorCodes.USER_CANCELED,
54725476
),
54735477
),

packages/react-wallet-kit/src/providers/client/Types.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -744,9 +744,9 @@ export type ClientContextType = Override<
744744
) => Promise<void>;
745745

746746
/**
747-
* Handles the fiat on-ramp process for converting fiat currency into crypto and funding a wallet.
747+
* Handles the fiat onramp process for converting fiat currency into crypto and funding a wallet.
748748
*
749-
* - Initializes a fiat on-ramp transaction with a specified provider (e.g., Coinbase or MoonPay).
749+
* - Initializes a fiat onramp transaction with a specified provider (e.g., Coinbase or MoonPay).
750750
* - Opens the provider flow in a new window and polls the transaction status until completion.
751751
* - Displays a modal to show progress and success state.
752752
* - Supports both sandbox and production modes.
@@ -756,7 +756,7 @@ export type ClientContextType = Override<
756756
* @param params.cryptoCurrencyCode - optional cryptocurrency to purchase, e.g., FIAT_ON_RAMP_CRYPTO_CURRENCY_BTC, defaults to the native currency associated with the network/wallet address passed in.
757757
* @param params.fiatCurrencyCode - optional fiat currency to use, e.g., FIAT_ON_RAMP_CURRENCY_ETH.
758758
* @param params.fiatCurrencyAmount - optional preset fiat amount, e.g., '100'.
759-
* @param params.onrampProvider - optional on-ramp provider, e.g., FIAT_ON_RAMP_PROVIDER_COINBASE or FIAT_ON_RAMP_PROVIDER_MOONPAY, defaults to FIAT_ON_RAMP_PROVIDER_MOONPAY.
759+
* @param params.onrampProvider - optional onramp provider, e.g., FIAT_ON_RAMP_PROVIDER_COINBASE or FIAT_ON_RAMP_PROVIDER_MOONPAY, defaults to FIAT_ON_RAMP_PROVIDER_MOONPAY.
760760
* @param params.paymentMethod - optional payment method, e.g., FIAT_ON_RAMP_PAYMENT_METHOD_CREDIT_DEBIT_CARD.
761761
* @param params.countryCode - optional ISO 3166-1 country code.
762762
* @param params.countrySubdivisionCode - optional ISO 3166-2 subdivision code, e.g., NY.
@@ -765,8 +765,8 @@ export type ClientContextType = Override<
765765
* @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
766766
* @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
767767
* @param params.successPageDuration - optional duration (in ms) for the success page after connecting (default: 2000ms).
768-
* @param params.openInNewTab: optional boolean on whether to open the on-ramp URL in a new browser tab or popup
769-
* @returns A promise that resolves when the on-ramp flow completes successfully.
768+
* @param params.openInNewTab: optional boolean on whether to open the onramp URL in a new browser tab or popup
769+
* @returns A promise that resolves when the onramp flow completes successfully.
770770
* @throws {TurnkeyError} If initialization fails, polling fails, or the user cancels the process.
771771
*/
772772
handleOnRamp: (params: HandleOnRampParams) => Promise<void>;

packages/react-wallet-kit/src/types/method-types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,5 +277,5 @@ export type HandleOnRampParams = {
277277
userId?: string; // Optional end user ID
278278
stampWith?: StamperType; // Stamper type (passkey, api key, wallet, etc.)
279279
successPageDuration?: number; // Duration for success page in ms (0 disables it)
280-
openInNewTab?: boolean; // Whether to open the on-ramp URL in a new browser tab or popup
280+
openInNewTab?: boolean; // Whether to open the onramp URL in a new browser tab or popup
281281
};

0 commit comments

Comments
 (0)