@funkit/connect
Version:
Funkit Connect SDK elevates DeFi apps via web2 sign-ins and one-click checkouts.
37 lines (36 loc) • 2.11 kB
TypeScript
import type { DynamicRoutePath } from '@funkit/fun-relay';
import type { DynamicTargetAssetCandidate, FunkitCheckoutConfig } from '../providers/FunkitCheckoutContext';
/**
* The path shape accepted by {@link mergeDynamicRoutingIntoConfig} /
* `applyDynamicRouting`. It is a {@link DynamicRoutePath} with the
* already-bound callbacks (`customRecipient`, `generateActionsParams`) and
* optional routing context layered on top.
*/
export type ApplyDynamicRoutingPath = Omit<DynamicRoutePath, 'getCustomRecipient' | 'generateActionsParams'> & {
customRecipient?: FunkitCheckoutConfig['customRecipient'];
generateActionsParams?: FunkitCheckoutConfig['generateActionsParams'];
bridgeOverride?: FunkitCheckoutConfig['bridgeOverride'];
dynamicRoutingId?: FunkitCheckoutConfig['dynamicRoutingId'];
};
/**
* Merge a resolved dynamic-routing path into a checkout config.
*
* The `dynamicRoutingId` is kept in lockstep with the target it selects: when
* the path carries one it wins, otherwise the config's existing id is
* preserved. This is what guarantees that anything keyed off
* `dynamicRoutingId` (e.g. the modal title) can't drift away from the active
* route when the target asset/chain is rebound.
*/
export declare function mergeDynamicRoutingIntoConfig(config: FunkitCheckoutConfig, path: ApplyDynamicRoutingPath): FunkitCheckoutConfig;
/**
* Merge a selected {@link DynamicTargetAssetCandidate} into a checkout config —
* the pure core of `applyDynamicTargetAssetCandidate`. Rebinds the target token
* fields and, in lockstep, the `dynamicRoutingId`; when the candidate carries a
* `customRecipient` (account-style candidates such as Polymarket
* Predictions/Perps) it also repoints the recipient, otherwise the existing
* recipient and routing id are preserved.
*
* Shared by the SourceChange target-asset dropdown and customer account pickers
* so destination selection has a single, tested code path.
*/
export declare function mergeDynamicTargetAssetCandidateIntoConfig(config: FunkitCheckoutConfig, candidate: DynamicTargetAssetCandidate): FunkitCheckoutConfig;