Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fund button - setupOnrampEventListeners util for setting up onSuccess, onEvent and onExit callbacks #1626

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

rustam-cb
Copy link

What changed? Why?
Added util function setupEventSubscriptions that is used to specify onEvent, onExit and onSuccess callbacks

Notes to reviewers
Example of usage of setupOnrampEventListeners

import { setupOnrampEventListeners } from '@onchainkit/utils';

setupOnrampEventListeners({
  onEvent: (event: EventMetadata) => {
    console.log('Event received', event.eventName);
  },
  onExit: () => {
    console.log('Exit event received');
  },
  onSuccess: () => {
    console.log('Success event received');
  } ,
  host: 'https://somthing.coinbase.com', // Optional: The host of the Coinbase Onramp widget. Defaults to https://pay.coinbase.com.
});

How has it been tested?
Unit tests added

export type PublicErrorEvent = {
eventName: 'error';
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
error: any;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these errors aren't type constrained at all?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed this. Added a type

export type PostMessageData = {
eventName: MessageCode;
data?: MessageData;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do these types need to be exported? didn't see them used anywhere else

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed to be exported. Removed export

Copy link

vercel bot commented Nov 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
onchainkit-coverage ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 15, 2024 9:09pm
onchainkit-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 15, 2024 9:09pm
onchainkit-routes ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 15, 2024 9:09pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants