@funkit/connect 12.15.3 → 12.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/dist/clients/axiom.d.ts +11 -3
- package/dist/clients/axiom.js +3 -1
- package/dist/domains/convert/balances.d.ts +38 -0
- package/dist/domains/convert/recipient.d.ts +21 -0
- package/dist/domains/convert/sourceWallet.d.ts +29 -0
- package/dist/domains/convert/types.d.ts +149 -0
- package/dist/hooks/statsig/index.d.ts +1 -1
- package/dist/hooks/track/analytics/mappers.d.ts +0 -6
- package/dist/hooks/useSwappedBuyingCrypto.d.ts +13 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +900 -926
- package/dist/providers/FunkitCheckoutContext/types.d.ts +7 -0
- package/dist/providers/FunkitStatsigWhnProvider.d.ts +0 -11
- package/dist/providers/SwappedProvider.d.ts +4 -2
- package/dist/wallets/walletConnectors/index.js +38 -38
- package/package.json +4 -4
- package/dist/hooks/statsig/useExperimentV2.d.ts +0 -8
- package/dist/utils/statsig/client.d.ts +0 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @funkit/connect
|
|
2
2
|
|
|
3
|
+
## 12.16.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 943ea85: Adds experimental contract types for the upcoming Convert flow
|
|
8
|
+
- 7bef744: The fiat on-ramp shows the checkout's destination token under the amount; opt out per checkout with `showFiatDestinationToken: false`
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- ca6f477: Use the shared chain address-family mapping from `@funkit/connect-core`; no behaviour change.
|
|
13
|
+
- 7ac5b52: Support consistent Statsig event metadata across Connect SDKs.
|
|
14
|
+
- 7b33236: Keep secondary Fun WHN Statsig experiments consistent across Connect SDKs.
|
|
15
|
+
- Updated dependencies [cf8a8e3]
|
|
16
|
+
- Updated dependencies [665b790]
|
|
17
|
+
- Updated dependencies [943ea85]
|
|
18
|
+
- Updated dependencies [ca6f477]
|
|
19
|
+
- Updated dependencies [57bc44c]
|
|
20
|
+
- Updated dependencies [7ac5b52]
|
|
21
|
+
- Updated dependencies [7b33236]
|
|
22
|
+
- Updated dependencies [8892863]
|
|
23
|
+
- Updated dependencies [7c1c826]
|
|
24
|
+
- @funkit/connect-core@9.4.0
|
|
25
|
+
|
|
3
26
|
## 12.15.3
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
package/dist/clients/axiom.d.ts
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
|
+
import type { ConvertConfig } from '../domains/convert/types';
|
|
1
2
|
import type { FunkitCheckoutConfig } from '../providers/FunkitCheckoutContext/types';
|
|
3
|
+
export type { ConvertAsset, ConvertConfig, ConvertErrorResult, ConvertErrorStage, ConvertRecipientAddresses, ConvertResolvedAsset, ConvertSourceBalances, ConvertSourceWallet, ConvertSuccessResult, ConvertTransaction, ConvertVm, GetConvertSourceBalances, GetConvertSourceWallet, } from '../domains/convert/types';
|
|
2
4
|
export interface CreateAxiomDepositConfigParams {
|
|
3
5
|
/** The checkout config the Deposit tab runs. */
|
|
4
6
|
checkoutConfig: FunkitCheckoutConfig;
|
|
7
|
+
/**
|
|
8
|
+
* Source wallets, balances, recipients and callbacks for the Convert tab.
|
|
9
|
+
* The screen doesn't read them yet, so passing them changes nothing today.
|
|
10
|
+
* @experimental
|
|
11
|
+
*/
|
|
12
|
+
convert?: ConvertConfig;
|
|
5
13
|
}
|
|
6
14
|
/**
|
|
7
15
|
* Adds Axiom's Deposit | Convert header tabs to a checkout config.
|
|
8
16
|
*
|
|
9
|
-
* Convert is in development: it shows an empty swap screen
|
|
10
|
-
*
|
|
17
|
+
* Convert is in development: it shows an empty swap screen until the
|
|
18
|
+
* contracts in `convert` are wired to it.
|
|
11
19
|
*/
|
|
12
|
-
export declare function createAxiomDepositConfig({ checkoutConfig, }: CreateAxiomDepositConfigParams): FunkitCheckoutConfig;
|
|
20
|
+
export declare function createAxiomDepositConfig({ checkoutConfig, convert, }: CreateAxiomDepositConfigParams): FunkitCheckoutConfig;
|
package/dist/clients/axiom.js
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ConvertResolvedAsset, ConvertSourceBalances, GetConvertSourceBalances } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* One key per token for every lookup (supported-assets, host balances).
|
|
4
|
+
* - EVM: checksummed; the asset list is checksummed and hosts send lowercase.
|
|
5
|
+
* - Solana: as-is; base58 is case-sensitive.
|
|
6
|
+
* - Anything else (Hypercore's `0x` + 32-zero placeholder): lowercase.
|
|
7
|
+
*/
|
|
8
|
+
export declare function normalizeConvertAssetKey(chainId: string, tokenAddress: string): string;
|
|
9
|
+
export type ConvertAssetBalance = {
|
|
10
|
+
status: 'available';
|
|
11
|
+
baseUnits: string;
|
|
12
|
+
} | {
|
|
13
|
+
status: 'unavailable';
|
|
14
|
+
};
|
|
15
|
+
export type ConvertBalancesResult = {
|
|
16
|
+
status: 'success';
|
|
17
|
+
walletAddress: string;
|
|
18
|
+
balances: Record<string, ConvertAssetBalance>;
|
|
19
|
+
} | {
|
|
20
|
+
status: 'error';
|
|
21
|
+
reason: 'invalidWalletAddress' | 'fetchFailed';
|
|
22
|
+
error?: unknown;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Turns a host balance result into one entry per requested asset. An asset the
|
|
26
|
+
* host left out, or returned malformed, is unavailable; it never becomes 0.
|
|
27
|
+
*/
|
|
28
|
+
export declare function parseConvertSourceBalances({ chainId, assets, result, }: {
|
|
29
|
+
chainId: string;
|
|
30
|
+
assets: ConvertResolvedAsset[];
|
|
31
|
+
result: ConvertSourceBalances;
|
|
32
|
+
}): ConvertBalancesResult;
|
|
33
|
+
/** Calls the host getter and parses its result; a throw is an error state. */
|
|
34
|
+
export declare function fetchConvertSourceBalances({ chainId, assets, getSourceBalances, }: {
|
|
35
|
+
chainId: string;
|
|
36
|
+
assets: ConvertResolvedAsset[];
|
|
37
|
+
getSourceBalances: GetConvertSourceBalances;
|
|
38
|
+
}): Promise<ConvertBalancesResult>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ConvertRecipientAddresses, ConvertResolvedAsset, ConvertVm } from './types';
|
|
2
|
+
export type ConvertRecipientUnavailableReason = 'unsupportedChain' | 'missingAddress' | 'invalidAddress' | 'resolverFailed';
|
|
3
|
+
export type ConvertRecipientSelection = {
|
|
4
|
+
status: 'available';
|
|
5
|
+
/** Checksummed for EVM and Hypercore, validated base58 for Solana. */
|
|
6
|
+
address: string;
|
|
7
|
+
} | {
|
|
8
|
+
status: 'unavailable';
|
|
9
|
+
reason: ConvertRecipientUnavailableReason;
|
|
10
|
+
};
|
|
11
|
+
/** The host's default recipient for a VM, before any per-asset override. */
|
|
12
|
+
export declare function getDefaultConvertRecipient(vm: ConvertVm, recipientAddresses: ConvertRecipientAddresses): string | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Resolves and validates where a destination asset's funds land: the host's
|
|
15
|
+
* custom recipient if it returns one, else the VM default. The custom resolver
|
|
16
|
+
* is not called for a chain Convert can't execute on.
|
|
17
|
+
*/
|
|
18
|
+
export declare function selectConvertRecipient({ asset, recipientAddresses, }: {
|
|
19
|
+
asset: ConvertResolvedAsset;
|
|
20
|
+
recipientAddresses: ConvertRecipientAddresses;
|
|
21
|
+
}): Promise<ConvertRecipientSelection>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ConvertSourceWallet, ConvertVm, GetConvertSourceWallet } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Which wallet kind a source chain needs, or `undefined` when Convert can't
|
|
4
|
+
* execute there. EVM needs the chain registered in `@funkit/chains` (wagmi
|
|
5
|
+
* chain list, icons, explorers), which is what keeps Arc out for now.
|
|
6
|
+
*/
|
|
7
|
+
export declare function resolveConvertVm(chainId: string): ConvertVm | undefined;
|
|
8
|
+
export type ConvertSourceUnavailableReason = 'unsupportedChain' | 'vmMismatch' | 'invalidWalletAddress' | 'resolverFailed';
|
|
9
|
+
export type ConvertSourceWalletSelection = {
|
|
10
|
+
status: 'available';
|
|
11
|
+
vm: ConvertVm;
|
|
12
|
+
wallet: ConvertSourceWallet;
|
|
13
|
+
/** Checksummed for EVM and Hypercore, validated base58 for Solana. */
|
|
14
|
+
address: string;
|
|
15
|
+
} | {
|
|
16
|
+
status: 'unavailable';
|
|
17
|
+
reason: ConvertSourceUnavailableReason;
|
|
18
|
+
};
|
|
19
|
+
/** Accepts a resolved wallet only if it is the kind the source chain needs. */
|
|
20
|
+
export declare function checkConvertSourceWallet(chainId: string, wallet: ConvertSourceWallet): ConvertSourceWalletSelection;
|
|
21
|
+
/**
|
|
22
|
+
* Resolves and validates the wallet for a source chain. The resolver is not
|
|
23
|
+
* called for a chain Convert can't execute on, since a host resolver may do
|
|
24
|
+
* real work (Polygon confirms the Polymarket proxy with their relayer).
|
|
25
|
+
*/
|
|
26
|
+
export declare function selectConvertSourceWallet({ chainId, getSourceWallet, }: {
|
|
27
|
+
chainId: string;
|
|
28
|
+
getSourceWallet: GetConvertSourceWallet;
|
|
29
|
+
}): Promise<ConvertSourceWalletSelection>;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import type { HypercoreSigner } from '@funkit/connect-core/clients/hypercore';
|
|
2
|
+
import type { SolanaWalletSigner } from '../../interfaces/solanaWallet';
|
|
3
|
+
import type { WithdrawalClient } from '../../wallets/Wallet';
|
|
4
|
+
/** Relay's names for the VMs a Convert source or destination can live on. */
|
|
5
|
+
export type ConvertVm = 'evm' | 'svm' | 'hypevm';
|
|
6
|
+
/**
|
|
7
|
+
* A token the host lists for Convert, by Fun chain id and token address.
|
|
8
|
+
* Every chain's native asset (ETH, BNB, SOL, Hypercore perps USDC) uses the
|
|
9
|
+
* `NATIVE_TOKEN` placeholder, the same as deposit configs; the SDK resolves
|
|
10
|
+
* chain-specific ids from it. Balance results are keyed by these same
|
|
11
|
+
* addresses. Decimals and icon are resolved from Fun's asset list, not
|
|
12
|
+
* supplied here.
|
|
13
|
+
* @experimental
|
|
14
|
+
*/
|
|
15
|
+
export interface ConvertAsset {
|
|
16
|
+
chainId: string;
|
|
17
|
+
address: string;
|
|
18
|
+
symbol: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A listed asset with the decimals the SDK resolved from Fun's asset list, so
|
|
22
|
+
* the host never has to. What {@link GetConvertSourceBalances} receives.
|
|
23
|
+
* @experimental
|
|
24
|
+
*/
|
|
25
|
+
export interface ConvertResolvedAsset extends ConvertAsset {
|
|
26
|
+
decimals: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The wallet that signs on one source chain, in the shape the SDK already
|
|
30
|
+
* executes with:
|
|
31
|
+
* - `evm`: a {@link WithdrawalClient}. `sendTransaction` must return a real
|
|
32
|
+
* on-chain hash; `sendTransactions` is opt-in and must also return a tx hash,
|
|
33
|
+
* never a wallet calls id.
|
|
34
|
+
* - `svm`: a {@link SolanaWalletSigner}. `signAndSendTransaction` resolves the
|
|
35
|
+
* 64-byte signature; when both signing methods are supplied the SDK uses
|
|
36
|
+
* `signTransaction` and submits itself.
|
|
37
|
+
* - `hypevm`: a {@link HypercoreSigner}; the SDK builds the Relay action wallet
|
|
38
|
+
* from it.
|
|
39
|
+
* @experimental
|
|
40
|
+
*/
|
|
41
|
+
export type ConvertSourceWallet = {
|
|
42
|
+
vm: 'evm';
|
|
43
|
+
wallet: WithdrawalClient;
|
|
44
|
+
} | {
|
|
45
|
+
vm: 'svm';
|
|
46
|
+
signer: SolanaWalletSigner;
|
|
47
|
+
} | {
|
|
48
|
+
vm: 'hypevm';
|
|
49
|
+
signer: HypercoreSigner;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Resolves the signing wallet for a source chain. Called when the user picks a
|
|
53
|
+
* source or flips direction, never for chains they haven't chosen. Polygon
|
|
54
|
+
* resolves to the Polymarket proxy client, other EVM chains to the EOA.
|
|
55
|
+
* @experimental
|
|
56
|
+
*/
|
|
57
|
+
export type GetConvertSourceWallet = (params: {
|
|
58
|
+
chainId: string;
|
|
59
|
+
}) => Promise<ConvertSourceWallet>;
|
|
60
|
+
/**
|
|
61
|
+
* Balances for one chain.
|
|
62
|
+
* - `walletAddress`: the wallet the balances were read for. Returned, not
|
|
63
|
+
* passed in, so the host never has to resolve a wallet just to echo it back.
|
|
64
|
+
* - `balances`: base-unit integer strings keyed by token address, in the
|
|
65
|
+
* decimals the SDK passed. Leave a token out when it couldn't be read; the
|
|
66
|
+
* SDK shows it as unavailable, never as 0. `"0"` means a real zero.
|
|
67
|
+
* @experimental
|
|
68
|
+
*/
|
|
69
|
+
export interface ConvertSourceBalances {
|
|
70
|
+
walletAddress: string;
|
|
71
|
+
balances: Record<string, string>;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Fetches live balances for every listed asset on one chain.
|
|
75
|
+
* - Read fresh from the host's balance source, not from page state.
|
|
76
|
+
* - Exclude anything the user can't move (Hypercore locked collateral, margin).
|
|
77
|
+
* - Throw on failure; the SDK shows an error state rather than a zero.
|
|
78
|
+
* @experimental
|
|
79
|
+
*/
|
|
80
|
+
export type GetConvertSourceBalances = (params: {
|
|
81
|
+
chainId: string;
|
|
82
|
+
assets: ConvertResolvedAsset[];
|
|
83
|
+
}) => Promise<ConvertSourceBalances>;
|
|
84
|
+
/** A chain-native transaction id: an EVM hash or a base58 Solana signature. */
|
|
85
|
+
export interface ConvertTransaction {
|
|
86
|
+
chainId: string;
|
|
87
|
+
txId: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Fired once, after Relay reports destination settlement. A source receipt
|
|
91
|
+
* alone never fires it.
|
|
92
|
+
* @experimental
|
|
93
|
+
*/
|
|
94
|
+
export interface ConvertSuccessResult {
|
|
95
|
+
requestId: string;
|
|
96
|
+
source: ConvertResolvedAsset & {
|
|
97
|
+
walletAddress: string;
|
|
98
|
+
};
|
|
99
|
+
destination: ConvertResolvedAsset & {
|
|
100
|
+
walletAddress: string;
|
|
101
|
+
};
|
|
102
|
+
amountInBaseUnits: string;
|
|
103
|
+
quotedAmountOutBaseUnits: string;
|
|
104
|
+
/** Only when the provider reports a measured amount; never the quote. */
|
|
105
|
+
settledAmountOutBaseUnits?: string;
|
|
106
|
+
/** May be empty for a leg with no reported on-chain transaction. */
|
|
107
|
+
sourceTransactions: ConvertTransaction[];
|
|
108
|
+
destinationTransactions: ConvertTransaction[];
|
|
109
|
+
}
|
|
110
|
+
/** @experimental */
|
|
111
|
+
export type ConvertErrorStage = 'quote' | 'source' | 'settlement';
|
|
112
|
+
/** @experimental */
|
|
113
|
+
export interface ConvertErrorResult {
|
|
114
|
+
stage: ConvertErrorStage;
|
|
115
|
+
/** The user declined a signature; not worth alerting on. */
|
|
116
|
+
userRejected: boolean;
|
|
117
|
+
message: string;
|
|
118
|
+
/** Whatever was thrown, untouched: a viem, Relay or host wallet error. */
|
|
119
|
+
error: unknown;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Where converted funds land, by destination VM. No signing happens on the
|
|
123
|
+
* destination side. A destination with no resolvable recipient is shown as
|
|
124
|
+
* unavailable.
|
|
125
|
+
* @experimental
|
|
126
|
+
*/
|
|
127
|
+
export interface ConvertRecipientAddresses {
|
|
128
|
+
evm?: string;
|
|
129
|
+
svm?: string;
|
|
130
|
+
/** Falls back to `evm`; Hyperliquid accounts share the EVM address. */
|
|
131
|
+
hypevm?: string;
|
|
132
|
+
/**
|
|
133
|
+
* Recipient for one destination asset when it differs from the VM default,
|
|
134
|
+
* e.g. a Polymarket proxy for pUSD. Return undefined to use the default.
|
|
135
|
+
*/
|
|
136
|
+
getCustomRecipient?: (asset: ConvertResolvedAsset) => Promise<string | undefined>;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Everything the Convert screen needs from the host, in one place.
|
|
140
|
+
* @experimental
|
|
141
|
+
*/
|
|
142
|
+
export interface ConvertConfig {
|
|
143
|
+
assets: ConvertAsset[];
|
|
144
|
+
recipientAddresses: ConvertRecipientAddresses;
|
|
145
|
+
getSourceWallet: GetConvertSourceWallet;
|
|
146
|
+
getSourceBalances: GetConvertSourceBalances;
|
|
147
|
+
onSuccess?: (result: ConvertSuccessResult) => void;
|
|
148
|
+
onError?: (error: ConvertErrorResult) => void;
|
|
149
|
+
}
|
|
@@ -20,9 +20,3 @@ export declare function resolvePaymentMethodProperties(args: {
|
|
|
20
20
|
serviceProvider?: MeldServiceProvider;
|
|
21
21
|
}, connectorId: string | undefined): PaymentMethodProperties;
|
|
22
22
|
export declare function mapSwappedFopTypeToPaymentMethod(fopType: FormOfPaymentType): PaymentMethod | null;
|
|
23
|
-
/**
|
|
24
|
-
* Explicit, non-recursive stringify for a flat analytics payload. Statsig
|
|
25
|
-
* event metadata must be Record<string, string>; values are stringified and
|
|
26
|
-
* null/undefined values (e.g. a not-applicable provider) are omitted.
|
|
27
|
-
*/
|
|
28
|
-
export declare function toStatsigMetadata(payload: Record<string, string | number | boolean | null | undefined>): Record<string, string>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type SwappedBuyingCrypto } from '@funkit/connect-core';
|
|
2
|
+
import type { FunkitCheckoutConfig } from '../providers/FunkitCheckoutContext/types';
|
|
3
|
+
/**
|
|
4
|
+
* Destination token for the Swapped on-ramp's "of <token>" row, from the
|
|
5
|
+
* checkout config. The config's `targetAssetTicker` / `iconSrc` already hold
|
|
6
|
+
* the selected dynamic candidate, so no candidate lookup is needed here.
|
|
7
|
+
*
|
|
8
|
+
* Rollout is gated: `enable-swapped-destination-token` is off until Swapped's
|
|
9
|
+
* widget change is live, so the embed's own deploy can't flip the row on for
|
|
10
|
+
* every customer. Integrators opt out per checkout with
|
|
11
|
+
* `showFiatDestinationToken: false`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function useSwappedBuyingCrypto(config: Pick<FunkitCheckoutConfig, 'targetAssetTicker' | 'iconSrc' | 'showFiatDestinationToken'>): SwappedBuyingCrypto | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -49,5 +49,6 @@ export type { FunkitConnectWalletConnectParameters, Wallet, WalletDetailsParams,
|
|
|
49
49
|
export { createConnectedWithdrawalClient } from './wallets/createConnectedWithdrawalClient';
|
|
50
50
|
export { useSolanaWithdrawalConfig, type SolanaWithdrawalConfig, } from './wallets/solanaWithdrawal';
|
|
51
51
|
export { useHypercoreWithdrawalConfig, type HypercoreSigner, type HypercoreWithdrawalOptions, } from './wallets/hypercoreWithdrawal';
|
|
52
|
+
export type { ConvertAsset, ConvertConfig, ConvertErrorResult, ConvertErrorStage, ConvertRecipientAddresses, ConvertResolvedAsset, ConvertSourceBalances, ConvertSourceWallet, ConvertSuccessResult, ConvertTransaction, ConvertVm, GetConvertSourceBalances, GetConvertSourceWallet, } from './domains/convert/types';
|
|
52
53
|
export { useFunkitAccount, useFunkitDisconnect, useFunkitReconnect, useFunkitSwitchChains, } from './providers/GeneralWalletProvider';
|
|
53
54
|
export { SelectedHomeTab } from './modals/ProfileDetails/FunProfileViews/Home';
|