@daimo/pay
Version:
Seamless crypto payments. Onboard users from any chain, any coin into your app with one click.
109 lines (104 loc) • 3.66 kB
TypeScript
import { Address, Hex } from 'viem';
import { MiniKit } from '@worldcoin/minikit-js';
import { PaymentStartedEvent, PaymentCompletedEvent, PaymentBouncedEvent, DaimoPayUserMetadata } from '@daimo/pay-common';
import { ReactElement } from 'react';
import { M as Mode, T as Theme, C as CustomTheme } from './types-26343050.js';
declare function useWithdrawToWorld(): {
withdrawToWorld: ({ appId, toUnits, closeOnSuccess, resetOnSuccess, }: {
appId: string;
toUnits: string;
closeOnSuccess?: boolean;
resetOnSuccess?: boolean;
}) => Promise<Address | null>;
};
declare function useWorldSignIn(): {
signInWithWorld: () => Promise<typeof MiniKit.user | null>;
worldUser: typeof MiniKit.user | null;
isLoadingSignIn: boolean;
};
type WorldPayButtonPaymentProps = {
/**
* Your public app ID. Specify either (payId) or (appId + parameters).
*/
appId: string;
/**
* Destination chain ID.
*/
toChain: number;
/**
* The destination token to send, completing payment. Must be an ERC-20
* token or the zero address, indicating the native token / ETH.
*/
toToken: Address;
/**
* The amount of destination token to send (transfer or approve).
*/
toUnits: string;
/**
* The destination address to transfer to, or contract to call.
*/
toAddress: Address;
/**
* Optional calldata to call an arbitrary function on `toAddress`.
*/
toCallData?: Hex;
/**
* The intent verb, such as "Pay", "Deposit", or "Purchase".
*/
intent?: string;
/**
* External ID. E.g. a correlation ID.
*/
externalId?: string;
/**
* Developer metadata. E.g. correlation ID.
* */
metadata?: DaimoPayUserMetadata;
/**
* The address to refund to if the payment bounces.
*/
refundAddress?: Address;
} | {
/** The payment ID, generated via the Daimo Pay API. Replaces params above. */
payId: string;
};
type WorldPayButtonCommonProps = WorldPayButtonPaymentProps & {
/** Called when user sends payment and transaction is seen on chain */
onPaymentStarted?: (event: PaymentStartedEvent) => void;
/** Called when destination transfer or call completes successfully */
onPaymentCompleted?: (event: PaymentCompletedEvent) => void;
/** Called when destination call reverts and funds are refunded */
onPaymentBounced?: (event: PaymentBouncedEvent) => void;
/** Open the modal by default. */
defaultOpen?: boolean;
/** Automatically close the modal after a successful payment. */
closeOnSuccess?: boolean;
/** Reset the payment after a successful payment. */
resetOnSuccess?: boolean;
};
type WorldPayButtonProps = WorldPayButtonCommonProps & {
/** Light mode, dark mode, or auto. */
mode?: Mode;
/** Named theme. See docs for options. */
theme?: Theme;
/** Custom theme. See docs for options. */
customTheme?: CustomTheme;
/** Disable interaction. */
disabled?: boolean;
};
type WorldPayButtonCustomProps = WorldPayButtonCommonProps & {
children: (renderProps: {
show: () => void;
isMiniKitReady: boolean;
}) => ReactElement;
};
declare function WorldPayButton(props: WorldPayButtonProps): JSX.Element;
declare namespace WorldPayButton {
var Custom: typeof WorldPayButtonCustom;
}
declare function WorldPayButtonCustom(props: WorldPayButtonCustomProps): JSX.Element;
declare namespace WorldPayButtonCustom {
var displayName: string;
}
export { WorldPayButton, useWithdrawToWorld, useWorldSignIn };
export type { WorldPayButtonCustomProps, WorldPayButtonProps };