@funkit/connect 12.0.0 → 12.1.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 +17 -0
- package/dist/clients/{chunk-3DHSLLCU.js → chunk-DNVDK7JQ.js} +18 -14
- package/dist/clients/fanatics.css +1 -1
- package/dist/clients/fanatics.js +1 -1
- package/dist/clients/internal/nado/withdrawalCallback.js +2 -2
- package/dist/clients/internal/nado/withdrawalForm.css +11 -14
- package/dist/clients/internal/nado/withdrawalForm.js +1 -0
- package/dist/clients/lighter.css +11 -14
- package/dist/clients/lighter.js +1 -1
- package/dist/clients/nado.js +2 -2
- package/dist/components/FunTransactionSummary/PaymentFeesSummary.d.ts +3 -2
- package/dist/components/FunTransactionSummary/PaymentFeesSummary.track.d.ts +4 -2
- package/dist/hooks/queries/useWithdrawalQuote.d.ts +7 -0
- package/dist/hooks/statsig/index.d.ts +1 -0
- package/dist/hooks/statsig/useExperimentV2.d.ts +8 -0
- package/dist/hooks/track/analytics/events.d.ts +51 -2
- package/dist/hooks/track/analytics/mappers.d.ts +4 -1
- package/dist/hooks/track/analytics/useWithdrawalAnalytics.d.ts +16 -3
- package/dist/hooks/track/useTrack.d.ts +1 -1
- package/dist/hooks/track/user.d.ts +8 -0
- package/dist/index.css +11 -14
- package/dist/index.js +3276 -2952
- package/dist/modals/CheckoutModal/InputAmount/InputAmount.d.ts +1 -1
- package/dist/modals/CheckoutModal/InputAmount/state.d.ts +10 -0
- package/dist/modals/WithdrawalModal/useTrackWithdrawalEvents.d.ts +8 -1
- package/dist/modals/WithdrawalModal/useTrackWithdrawalQuoteEvents.d.ts +16 -0
- package/dist/providers/FunkitConfigContext.d.ts +1 -1
- package/dist/providers/FunkitStatsigProvider.d.ts +2 -7
- package/dist/providers/FunkitStatsigWhnProvider.d.ts +17 -0
- package/dist/providers/GeneralWalletProvider.d.ts +1 -0
- package/dist/shadow-css.js +1 -1
- package/dist/utils/statsig/client.d.ts +4 -0
- package/dist/wallets/walletConnectors/bifrostWallet/bifrostWallet.js +2 -2
- package/dist/wallets/walletConnectors/bitgetWallet/bitgetWallet.js +2 -2
- package/dist/wallets/walletConnectors/bybitWallet/bybitWallet.js +2 -2
- package/dist/wallets/walletConnectors/clvWallet/clvWallet.js +2 -2
- package/dist/wallets/walletConnectors/coin98Wallet/coin98Wallet.js +2 -2
- package/dist/wallets/walletConnectors/coreWallet/coreWallet.js +2 -2
- package/dist/wallets/walletConnectors/foxWallet/foxWallet.js +2 -2
- package/dist/wallets/walletConnectors/frontierWallet/frontierWallet.js +2 -2
- package/dist/wallets/walletConnectors/gateWallet/gateWallet.js +2 -2
- package/dist/wallets/walletConnectors/index.js +59 -59
- package/dist/wallets/walletConnectors/metaMaskWallet/metaMaskWallet.js +2 -2
- package/dist/wallets/walletConnectors/okxWallet/okxWallet.js +2 -2
- package/dist/wallets/walletConnectors/rainbowWallet/rainbowWallet.js +2 -2
- package/dist/wallets/walletConnectors/roninWallet/roninWallet.js +2 -2
- package/dist/wallets/walletConnectors/safepalWallet/safepalWallet.js +2 -2
- package/dist/wallets/walletConnectors/subWallet/subWallet.js +2 -2
- package/dist/wallets/walletConnectors/tokenPocketWallet/tokenPocketWallet.js +2 -2
- package/dist/wallets/walletConnectors/trustWallet/trustWallet.js +2 -2
- package/dist/wallets/walletConnectors/zerionWallet/zerionWallet.js +2 -2
- package/package.json +4 -4
- package/dist/clients/chunk-37Q6DUR7.js +0 -296
- package/dist/clients/chunk-3J2GOB5X.js +0 -190
- package/dist/clients/chunk-BCNE3ZKM.js +0 -190
- package/dist/clients/chunk-BWJC2WD7.js +0 -4899
- package/dist/clients/chunk-EQA5U4V6.js +0 -98
- package/dist/clients/chunk-EYMFEWQL.js +0 -30
- package/dist/clients/chunk-FPOGADLJ.js +0 -4899
- package/dist/clients/chunk-HB7S3NDI.js +0 -15
- package/dist/clients/chunk-HDFCM5UL.js +0 -15
- package/dist/clients/chunk-NEKHTWTT.js +0 -331
- package/dist/clients/chunk-PA7WW6VC.js +0 -296
- package/dist/clients/chunk-SKDFSMAO.js +0 -30
- package/dist/clients/chunk-TI2NG2Z6.js +0 -30
- package/dist/clients/chunk-TZFXFVDW.js +0 -296
- package/dist/clients/chunk-VXX2XK5J.js +0 -190
- package/dist/clients/chunk-WXSFLUPZ.js +0 -4891
- package/dist/clients/chunk-XSRAZSYG.js +0 -15
- package/dist/wallets/walletConnectors/chunk-4NV5BYRP.js +0 -95
- package/dist/wallets/walletConnectors/chunk-AVDUNQUW.js +0 -96
- package/dist/wallets/walletConnectors/chunk-GUQM4QSL.js +0 -66
- package/dist/wallets/walletConnectors/chunk-IULPZP2Q.js +0 -69
- package/dist/wallets/walletConnectors/chunk-JPN6TWIT.js +0 -92
- package/dist/wallets/walletConnectors/chunk-KCRO2AGO.js +0 -106
- package/dist/wallets/walletConnectors/chunk-KI5Y2BBF.js +0 -94
- package/dist/wallets/walletConnectors/chunk-NR2OGDHQ.js +0 -103
- package/dist/wallets/walletConnectors/chunk-OEEGYENV.js +0 -87
- package/dist/wallets/walletConnectors/chunk-OX37G4YT.js +0 -98
- package/dist/wallets/walletConnectors/chunk-SWFF3TWJ.js +0 -100
- package/dist/wallets/walletConnectors/chunk-TKB2OY6G.js +0 -99
- package/dist/wallets/walletConnectors/chunk-W2LCLDPX.js +0 -70
- package/dist/wallets/walletConnectors/chunk-WAHGI5L7.js +0 -96
- package/dist/wallets/walletConnectors/chunk-WKNQMP4A.js +0 -93
- package/dist/wallets/walletConnectors/chunk-XCNHV3HS.js +0 -110
- package/dist/wallets/walletConnectors/chunk-YO2K4MBH.js +0 -218
- package/dist/wallets/walletConnectors/chunk-YQFGVZGR.js +0 -92
- package/dist/clients/{chunk-JVR4CX6N.js → chunk-ECGTOMZQ.js} +3 -3
- /package/dist/clients/{chunk-RHOSJED2.js → chunk-RQALGV5U.js} +0 -0
|
@@ -1,296 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
isExpectedNadoWithdrawalFailure,
|
|
4
|
-
toNadoWithdrawalErrorMessage
|
|
5
|
-
} from "./chunk-SKDFSMAO.js";
|
|
6
|
-
import {
|
|
7
|
-
toWithdrawalAmountBaseUnit
|
|
8
|
-
} from "./chunk-B7UU2ETA.js";
|
|
9
|
-
import {
|
|
10
|
-
getAccount,
|
|
11
|
-
signTypedData,
|
|
12
|
-
switchChain
|
|
13
|
-
} from "./chunk-OODIKHYE.js";
|
|
14
|
-
import {
|
|
15
|
-
i18n_default
|
|
16
|
-
} from "./chunk-BWJC2WD7.js";
|
|
17
|
-
import {
|
|
18
|
-
generateClientMetadataForTokenTransfer
|
|
19
|
-
} from "./chunk-PENJ5JGH.js";
|
|
20
|
-
import {
|
|
21
|
-
logger
|
|
22
|
-
} from "./chunk-AHYOV7AV.js";
|
|
23
|
-
|
|
24
|
-
// src/clients/internal/nado/withdrawalCallback.ts
|
|
25
|
-
import {
|
|
26
|
-
NADO_API_KEY,
|
|
27
|
-
initializeCheckoutTokenTransferAddress
|
|
28
|
-
} from "@funkit/api-base";
|
|
29
|
-
import {
|
|
30
|
-
deductFlatFee,
|
|
31
|
-
normalizeRecipientAddress,
|
|
32
|
-
safeBigInt
|
|
33
|
-
} from "@funkit/connect-core";
|
|
34
|
-
import {
|
|
35
|
-
INK_CHAIN_ID,
|
|
36
|
-
NADO_WITHDRAWAL_ACTION_TYPE,
|
|
37
|
-
NadoGatewayError,
|
|
38
|
-
NadoWithdrawalUnconfirmedError,
|
|
39
|
-
buildWithdrawCollateralV2TypedData,
|
|
40
|
-
executeNadoWithdrawCollateralV2,
|
|
41
|
-
getNadoMaxWithdrawable,
|
|
42
|
-
getNadoTxNonce,
|
|
43
|
-
x18ToRawBaseUnit
|
|
44
|
-
} from "@funkit/connect-core/clients/nado";
|
|
45
|
-
import { isEVMAddressEquivalent } from "@funkit/utils";
|
|
46
|
-
|
|
47
|
-
// src/utils/signature.ts
|
|
48
|
-
import { isSwitchChainError, isUserRejectedError } from "@funkit/connect-core";
|
|
49
|
-
|
|
50
|
-
// src/clients/internal/nado/withdrawalCallback.ts
|
|
51
|
-
var NadoWithdrawalInputError = class extends Error {
|
|
52
|
-
};
|
|
53
|
-
var NadoWithdrawalUserError = class extends Error {
|
|
54
|
-
};
|
|
55
|
-
function createNadoWithdrawalCallback({
|
|
56
|
-
walletAddress,
|
|
57
|
-
subaccount,
|
|
58
|
-
wagmiConfig
|
|
59
|
-
}) {
|
|
60
|
-
return async (param) => {
|
|
61
|
-
const {
|
|
62
|
-
customerData,
|
|
63
|
-
userInputAmount,
|
|
64
|
-
targetAssetAddress,
|
|
65
|
-
targetChainId,
|
|
66
|
-
destinationAddress
|
|
67
|
-
} = param;
|
|
68
|
-
const recipientAddr = normalizeRecipientAddress(destinationAddress);
|
|
69
|
-
let step = "validate";
|
|
70
|
-
try {
|
|
71
|
-
if (customerData?.customerName !== "nado" || !userInputAmount) {
|
|
72
|
-
throw new NadoWithdrawalInputError(
|
|
73
|
-
"Missing Nado customerData or userInputAmount"
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
const {
|
|
77
|
-
spotLeverage,
|
|
78
|
-
sequencerFeeTokenAmount,
|
|
79
|
-
selectedSourceToken: { productId, decimals }
|
|
80
|
-
} = customerData;
|
|
81
|
-
const netTokens = deductFlatFee(userInputAmount, sequencerFeeTokenAmount);
|
|
82
|
-
const netRawAmount = toWithdrawalAmountBaseUnit(netTokens, decimals);
|
|
83
|
-
if (netRawAmount <= 0n) {
|
|
84
|
-
logger.warn("nado:withdrawal:amountTooLow", {
|
|
85
|
-
productId,
|
|
86
|
-
userInputAmount,
|
|
87
|
-
sequencerFeeTokenAmount
|
|
88
|
-
});
|
|
89
|
-
throw new NadoWithdrawalUserError(
|
|
90
|
-
i18n_default.t("withdrawal.nado.errorAmountTooLow")
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
logger.info("nado:withdrawal:start", {
|
|
94
|
-
productId,
|
|
95
|
-
spotLeverage,
|
|
96
|
-
decimals,
|
|
97
|
-
userInputAmount,
|
|
98
|
-
netTokens,
|
|
99
|
-
sequencerFeeTokenAmount,
|
|
100
|
-
targetChainId,
|
|
101
|
-
targetAssetAddress,
|
|
102
|
-
destinationAddress: recipientAddr
|
|
103
|
-
});
|
|
104
|
-
await assertWithinMaxWithdrawable({
|
|
105
|
-
subaccount,
|
|
106
|
-
productId,
|
|
107
|
-
decimals,
|
|
108
|
-
spotLeverage,
|
|
109
|
-
netRawAmount
|
|
110
|
-
});
|
|
111
|
-
step = "switchChain";
|
|
112
|
-
await ensureWalletOnInk(wagmiConfig);
|
|
113
|
-
assertOwnerIsSigner({ walletAddress, wagmiConfig });
|
|
114
|
-
step = "uda";
|
|
115
|
-
const transferInit = await initializeCheckoutTokenTransferAddress({
|
|
116
|
-
apiKey: NADO_API_KEY,
|
|
117
|
-
// No Fun user context in a client bundle entry; the owner wallet is the
|
|
118
|
-
// stable per-user id and matches what sourceOfFund records.
|
|
119
|
-
userId: walletAddress,
|
|
120
|
-
recipientAddr,
|
|
121
|
-
toChainId: targetChainId.toString(),
|
|
122
|
-
toTokenAddress: targetAssetAddress,
|
|
123
|
-
sourceOfFund: `balance|nado|${walletAddress}`,
|
|
124
|
-
// Attribution only — forces a separate UDA from Nado deposits so the
|
|
125
|
-
// direct executions off it are tagged as withdrawals.
|
|
126
|
-
actionType: NADO_WITHDRAWAL_ACTION_TYPE,
|
|
127
|
-
logger,
|
|
128
|
-
clientMetadata: {
|
|
129
|
-
...generateClientMetadataForTokenTransfer(),
|
|
130
|
-
isWithdrawal: true
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
const depositAddr = transferInit.depositAddr;
|
|
134
|
-
logger.info("nado:withdrawal:udaGenerated", {
|
|
135
|
-
depositAddr,
|
|
136
|
-
productId,
|
|
137
|
-
destinationAddress: recipientAddr
|
|
138
|
-
});
|
|
139
|
-
step = "sign";
|
|
140
|
-
const nonce = await getNadoTxNonce(walletAddress, { logger });
|
|
141
|
-
const signature = await signTypedData(wagmiConfig, {
|
|
142
|
-
...buildWithdrawCollateralV2TypedData({
|
|
143
|
-
sender: subaccount,
|
|
144
|
-
productId,
|
|
145
|
-
amount: netRawAmount,
|
|
146
|
-
nonce,
|
|
147
|
-
sendTo: depositAddr
|
|
148
|
-
}),
|
|
149
|
-
account: walletAddress
|
|
150
|
-
});
|
|
151
|
-
logger.info("nado:withdrawal:signed", {
|
|
152
|
-
nonce: nonce.toString(),
|
|
153
|
-
depositAddr,
|
|
154
|
-
productId
|
|
155
|
-
});
|
|
156
|
-
step = "execute";
|
|
157
|
-
await executeNadoWithdrawCollateralV2(
|
|
158
|
-
{
|
|
159
|
-
sender: subaccount,
|
|
160
|
-
productId,
|
|
161
|
-
amount: netRawAmount,
|
|
162
|
-
nonce,
|
|
163
|
-
sendTo: depositAddr,
|
|
164
|
-
signature,
|
|
165
|
-
spotLeverage
|
|
166
|
-
},
|
|
167
|
-
{ logger }
|
|
168
|
-
);
|
|
169
|
-
logger.info("nado:withdrawal:executeSubmitted", {
|
|
170
|
-
nonce: nonce.toString(),
|
|
171
|
-
depositAddr,
|
|
172
|
-
productId,
|
|
173
|
-
netRawAmount: netRawAmount.toString()
|
|
174
|
-
});
|
|
175
|
-
return depositAddr;
|
|
176
|
-
} catch (error) {
|
|
177
|
-
throw toThrownWithdrawalError(error, {
|
|
178
|
-
step,
|
|
179
|
-
walletAddress,
|
|
180
|
-
subaccount,
|
|
181
|
-
destinationAddress: recipientAddr,
|
|
182
|
-
targetChainId
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
async function assertWithinMaxWithdrawable({
|
|
188
|
-
subaccount,
|
|
189
|
-
productId,
|
|
190
|
-
decimals,
|
|
191
|
-
spotLeverage,
|
|
192
|
-
netRawAmount
|
|
193
|
-
}) {
|
|
194
|
-
const maxWithdrawableX18 = await getNadoMaxWithdrawable(
|
|
195
|
-
{ productId, sender: subaccount, spotLeverage },
|
|
196
|
-
{ logger }
|
|
197
|
-
);
|
|
198
|
-
const maxRawAmount = x18ToRawBaseUnit(
|
|
199
|
-
safeBigInt(maxWithdrawableX18, 0n),
|
|
200
|
-
decimals
|
|
201
|
-
);
|
|
202
|
-
if (netRawAmount <= maxRawAmount) {
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
logger.warn("nado:withdrawal:exceedsMaxWithdrawable", {
|
|
206
|
-
productId,
|
|
207
|
-
spotLeverage,
|
|
208
|
-
netRawAmount: netRawAmount.toString(),
|
|
209
|
-
maxRawAmount: maxRawAmount.toString()
|
|
210
|
-
});
|
|
211
|
-
throw new NadoWithdrawalUserError(
|
|
212
|
-
i18n_default.t("withdrawal.nado.errorBalanceChanged")
|
|
213
|
-
);
|
|
214
|
-
}
|
|
215
|
-
async function ensureWalletOnInk(wagmiConfig) {
|
|
216
|
-
const connectedChainId = getAccount(wagmiConfig).chainId;
|
|
217
|
-
if (connectedChainId === INK_CHAIN_ID) {
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
logger.info("nado:withdrawal:switchingChain", {
|
|
221
|
-
fromChainId: connectedChainId ?? null
|
|
222
|
-
});
|
|
223
|
-
try {
|
|
224
|
-
await switchChain(wagmiConfig, { chainId: INK_CHAIN_ID });
|
|
225
|
-
} catch (error) {
|
|
226
|
-
if (isUserRejectedError(error)) {
|
|
227
|
-
throw error;
|
|
228
|
-
}
|
|
229
|
-
logger.warn("nado:withdrawal:switchChainFailed", {
|
|
230
|
-
fromChainId: connectedChainId ?? null,
|
|
231
|
-
errorMessage: error instanceof Error ? error.message : String(error)
|
|
232
|
-
});
|
|
233
|
-
throw new NadoWithdrawalUserError(
|
|
234
|
-
i18n_default.t("withdrawal.nado.errorSwitchChain")
|
|
235
|
-
);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
function assertOwnerIsSigner({
|
|
239
|
-
walletAddress,
|
|
240
|
-
wagmiConfig
|
|
241
|
-
}) {
|
|
242
|
-
const connectedAddress = getAccount(wagmiConfig).address;
|
|
243
|
-
if (connectedAddress && isEVMAddressEquivalent({
|
|
244
|
-
firstAddress: connectedAddress,
|
|
245
|
-
secondAddress: walletAddress
|
|
246
|
-
})) {
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
249
|
-
logger.warn("nado:withdrawal:signerMismatch", {
|
|
250
|
-
walletAddress,
|
|
251
|
-
connectedAddress: connectedAddress ?? null
|
|
252
|
-
});
|
|
253
|
-
throw new NadoWithdrawalUserError(
|
|
254
|
-
i18n_default.t("withdrawal.nado.errorSignerMismatch")
|
|
255
|
-
);
|
|
256
|
-
}
|
|
257
|
-
function toThrownWithdrawalError(error, context) {
|
|
258
|
-
const logContext = {
|
|
259
|
-
...context,
|
|
260
|
-
nadoErrorCode: error instanceof NadoGatewayError ? error.errorCode ?? null : null,
|
|
261
|
-
nadoErrorKind: error instanceof NadoGatewayError ? error.kind : null,
|
|
262
|
-
errorMessage: error instanceof Error ? error.message : String(error)
|
|
263
|
-
};
|
|
264
|
-
if (isUserRejectedError(error)) {
|
|
265
|
-
logger.warn("nado:withdrawal:rejected", logContext);
|
|
266
|
-
return error;
|
|
267
|
-
}
|
|
268
|
-
if (error instanceof NadoWithdrawalUserError) {
|
|
269
|
-
return error;
|
|
270
|
-
}
|
|
271
|
-
if (error instanceof NadoWithdrawalInputError) {
|
|
272
|
-
logger.error("nado:withdrawal:invalidInput", error, logContext);
|
|
273
|
-
return new Error(i18n_default.t("withdrawal.nado.errorGeneric"));
|
|
274
|
-
}
|
|
275
|
-
if (error instanceof NadoWithdrawalUnconfirmedError) {
|
|
276
|
-
return new Error(toNadoWithdrawalErrorMessage(error));
|
|
277
|
-
}
|
|
278
|
-
if (!(error instanceof NadoGatewayError)) {
|
|
279
|
-
logger.error(
|
|
280
|
-
"nado:withdrawal:failed",
|
|
281
|
-
error instanceof Error ? error : new Error(String(error)),
|
|
282
|
-
logContext
|
|
283
|
-
);
|
|
284
|
-
return error;
|
|
285
|
-
}
|
|
286
|
-
if (isExpectedNadoWithdrawalFailure(error)) {
|
|
287
|
-
logger.warn("nado:withdrawal:gatewayRejected", logContext);
|
|
288
|
-
} else {
|
|
289
|
-
logger.error("nado:withdrawal:gatewayFailed", error, logContext);
|
|
290
|
-
}
|
|
291
|
-
return new Error(toNadoWithdrawalErrorMessage(error));
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
export {
|
|
295
|
-
createNadoWithdrawalCallback
|
|
296
|
-
};
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
useFunkitTranslation
|
|
4
|
-
} from "./chunk-HDFCM5UL.js";
|
|
5
|
-
|
|
6
|
-
// src/providers/FunkitConfigContext.tsx
|
|
7
|
-
import {
|
|
8
|
-
createContext,
|
|
9
|
-
useContext,
|
|
10
|
-
useMemo
|
|
11
|
-
} from "react";
|
|
12
|
-
var DEFAULT_TEXT_CUSTOMIZATIONS = {
|
|
13
|
-
virtualFiat: "Deposit with SEPA",
|
|
14
|
-
brokerageOrExchange: "Connect Exchange",
|
|
15
|
-
debitOrCredit: "Deposit with Card",
|
|
16
|
-
accountBalance: "Wallet",
|
|
17
|
-
selectAccount: "Select an exchange",
|
|
18
|
-
perpsTransferTitle: "Transfer",
|
|
19
|
-
sourceMethodTitle: "Your source",
|
|
20
|
-
tokensListTitle: "Your tokens",
|
|
21
|
-
transferTokens: "Transfer Crypto",
|
|
22
|
-
bitcoinLightning: "Bitcoin Lightning",
|
|
23
|
-
cashAppLightning: "Cash App",
|
|
24
|
-
receiveDropdownTitle: "",
|
|
25
|
-
// Default to empty
|
|
26
|
-
receiveDropdownLabel: "Asset to Receive",
|
|
27
|
-
confirmationScreen: {
|
|
28
|
-
payAmountLabel: "You send",
|
|
29
|
-
receiveAmountLabel: "You receive"
|
|
30
|
-
},
|
|
31
|
-
paymentMethodSubtitles: {}
|
|
32
|
-
};
|
|
33
|
-
var DEFAULT_UI_CUSTOMIZATIONS = {
|
|
34
|
-
alignTitle: "center",
|
|
35
|
-
alwaysShowTopDivider: false,
|
|
36
|
-
showModalTitle: true,
|
|
37
|
-
callToActionsUppercase: false,
|
|
38
|
-
enableCompactList: false,
|
|
39
|
-
checkoutHistory: {
|
|
40
|
-
showGetHelpAsAlert: true,
|
|
41
|
-
simplifiedUi: false
|
|
42
|
-
},
|
|
43
|
-
confirmationScreen: {
|
|
44
|
-
autoExpandFeesSummary: false,
|
|
45
|
-
preferDestinationWhenSame: false,
|
|
46
|
-
showAmountSummaryAbovePaymentMethod: false,
|
|
47
|
-
showDisclaimerAsAlert: true,
|
|
48
|
-
showInstantTimeEstimate: false,
|
|
49
|
-
showLeftAlignedDollarValueWithLabel: false,
|
|
50
|
-
showPaymentAmountUsd: false,
|
|
51
|
-
showReceiveAmountUsd: false,
|
|
52
|
-
showSelectedRoute: false,
|
|
53
|
-
stepIndicatorType: "spinner",
|
|
54
|
-
showTransactionDigest: "none"
|
|
55
|
-
},
|
|
56
|
-
sourceChangeScreen: {
|
|
57
|
-
bottomBarCloseButton: {
|
|
58
|
-
enabled: false,
|
|
59
|
-
labelKey: "common.close"
|
|
60
|
-
},
|
|
61
|
-
showTargetAssetSelection: false,
|
|
62
|
-
showWalletOnInsufficientBalance: false,
|
|
63
|
-
showWalletConnect: true,
|
|
64
|
-
showCustomTopComponentDivider: false,
|
|
65
|
-
paymentMethodIcons: {}
|
|
66
|
-
},
|
|
67
|
-
inputAmountScreen: {
|
|
68
|
-
allowTokenAmountInput: true
|
|
69
|
-
},
|
|
70
|
-
selectAssetScreen: {
|
|
71
|
-
isSecondaryTokenSymbolVisible: true,
|
|
72
|
-
navigateOnAssetClick: false
|
|
73
|
-
},
|
|
74
|
-
transferCryptoScreen: {
|
|
75
|
-
showYouSendYouReceive: false
|
|
76
|
-
},
|
|
77
|
-
withdrawalScreen: {
|
|
78
|
-
autoExpandFeesSummary: false
|
|
79
|
-
},
|
|
80
|
-
selectBrokerageScreen: {},
|
|
81
|
-
connectExchangeScreen: {},
|
|
82
|
-
customIcons: {},
|
|
83
|
-
customFontFamily: {
|
|
84
|
-
primary: "",
|
|
85
|
-
secondary: "",
|
|
86
|
-
tertiary: ""
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
var DEFAULT_FUNKIT_CONFIG = {
|
|
90
|
-
apiKey: "",
|
|
91
|
-
appName: "",
|
|
92
|
-
textCustomizations: DEFAULT_TEXT_CUSTOMIZATIONS,
|
|
93
|
-
uiCustomizations: DEFAULT_UI_CUSTOMIZATIONS
|
|
94
|
-
};
|
|
95
|
-
var FunkitConfigContext = createContext(
|
|
96
|
-
DEFAULT_FUNKIT_CONFIG
|
|
97
|
-
);
|
|
98
|
-
function useFunkitConfig() {
|
|
99
|
-
const originalFunkitConfig = useContext(FunkitConfigContext);
|
|
100
|
-
const { t } = useFunkitTranslation();
|
|
101
|
-
const translatedDefaults = useMemo(() => {
|
|
102
|
-
return {
|
|
103
|
-
virtualFiat: t("textCustomizations.virtualFiat"),
|
|
104
|
-
brokerageOrExchange: t("textCustomizations.brokerageOrExchange"),
|
|
105
|
-
debitOrCredit: t("textCustomizations.debitOrCredit"),
|
|
106
|
-
accountBalance: t("textCustomizations.accountBalance"),
|
|
107
|
-
selectAccount: t("textCustomizations.selectAccount"),
|
|
108
|
-
perpsTransferTitle: t("perpsTransfer.title"),
|
|
109
|
-
sourceMethodTitle: t("textCustomizations.sourceMethodTitle"),
|
|
110
|
-
tokensListTitle: t("textCustomizations.tokensListTitle"),
|
|
111
|
-
transferTokens: t("textCustomizations.transferTokens"),
|
|
112
|
-
bitcoinLightning: t("textCustomizations.bitcoinLightning"),
|
|
113
|
-
cashAppLightning: t("textCustomizations.cashAppLightning"),
|
|
114
|
-
receiveDropdownTitle: t("textCustomizations.receiveDropdownTitle"),
|
|
115
|
-
receiveDropdownLabel: t("textCustomizations.receiveDropdownLabel"),
|
|
116
|
-
confirmationScreen: {
|
|
117
|
-
payAmountLabel: t("textCustomizations.payAmountLabel"),
|
|
118
|
-
receiveAmountLabel: t("textCustomizations.receiveAmountLabel")
|
|
119
|
-
},
|
|
120
|
-
paymentMethodSubtitles: {}
|
|
121
|
-
};
|
|
122
|
-
}, [t]);
|
|
123
|
-
const finalFunkitConfig = useMemo(() => {
|
|
124
|
-
return {
|
|
125
|
-
...DEFAULT_FUNKIT_CONFIG,
|
|
126
|
-
...originalFunkitConfig,
|
|
127
|
-
textCustomizations: {
|
|
128
|
-
...translatedDefaults,
|
|
129
|
-
...originalFunkitConfig.textCustomizations,
|
|
130
|
-
confirmationScreen: {
|
|
131
|
-
...translatedDefaults.confirmationScreen,
|
|
132
|
-
...originalFunkitConfig.textCustomizations?.confirmationScreen
|
|
133
|
-
},
|
|
134
|
-
paymentMethodSubtitles: {
|
|
135
|
-
...translatedDefaults.paymentMethodSubtitles,
|
|
136
|
-
...originalFunkitConfig.textCustomizations?.paymentMethodSubtitles
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
uiCustomizations: {
|
|
140
|
-
...DEFAULT_FUNKIT_CONFIG.uiCustomizations,
|
|
141
|
-
...originalFunkitConfig.uiCustomizations,
|
|
142
|
-
checkoutHistory: {
|
|
143
|
-
...DEFAULT_FUNKIT_CONFIG.uiCustomizations.checkoutHistory,
|
|
144
|
-
...originalFunkitConfig.uiCustomizations?.checkoutHistory
|
|
145
|
-
},
|
|
146
|
-
confirmationScreen: {
|
|
147
|
-
...DEFAULT_FUNKIT_CONFIG.uiCustomizations.confirmationScreen,
|
|
148
|
-
...originalFunkitConfig.uiCustomizations?.confirmationScreen
|
|
149
|
-
},
|
|
150
|
-
connectExchangeScreen: {
|
|
151
|
-
...DEFAULT_FUNKIT_CONFIG.uiCustomizations.connectExchangeScreen,
|
|
152
|
-
...originalFunkitConfig.uiCustomizations?.connectExchangeScreen
|
|
153
|
-
},
|
|
154
|
-
inputAmountScreen: {
|
|
155
|
-
...DEFAULT_FUNKIT_CONFIG.uiCustomizations.inputAmountScreen,
|
|
156
|
-
...originalFunkitConfig.uiCustomizations?.inputAmountScreen
|
|
157
|
-
},
|
|
158
|
-
selectAssetScreen: {
|
|
159
|
-
...DEFAULT_FUNKIT_CONFIG.uiCustomizations.selectAssetScreen,
|
|
160
|
-
...originalFunkitConfig.uiCustomizations?.selectAssetScreen
|
|
161
|
-
},
|
|
162
|
-
selectBrokerageScreen: {
|
|
163
|
-
...DEFAULT_FUNKIT_CONFIG.uiCustomizations.selectBrokerageScreen,
|
|
164
|
-
...originalFunkitConfig.uiCustomizations?.selectBrokerageScreen
|
|
165
|
-
},
|
|
166
|
-
sourceChangeScreen: {
|
|
167
|
-
...DEFAULT_FUNKIT_CONFIG.uiCustomizations.sourceChangeScreen,
|
|
168
|
-
...originalFunkitConfig.uiCustomizations?.sourceChangeScreen,
|
|
169
|
-
bottomBarCloseButton: {
|
|
170
|
-
...DEFAULT_FUNKIT_CONFIG.uiCustomizations.sourceChangeScreen.bottomBarCloseButton,
|
|
171
|
-
...originalFunkitConfig.uiCustomizations?.sourceChangeScreen?.bottomBarCloseButton
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
transferCryptoScreen: {
|
|
175
|
-
...DEFAULT_FUNKIT_CONFIG.uiCustomizations.transferCryptoScreen,
|
|
176
|
-
...originalFunkitConfig.uiCustomizations?.transferCryptoScreen
|
|
177
|
-
},
|
|
178
|
-
withdrawalScreen: {
|
|
179
|
-
...DEFAULT_FUNKIT_CONFIG.uiCustomizations.withdrawalScreen,
|
|
180
|
-
...originalFunkitConfig.uiCustomizations?.withdrawalScreen
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
}, [originalFunkitConfig, translatedDefaults]);
|
|
185
|
-
return finalFunkitConfig;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
export {
|
|
189
|
-
useFunkitConfig
|
|
190
|
-
};
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
useFunkitTranslation
|
|
4
|
-
} from "./chunk-XSRAZSYG.js";
|
|
5
|
-
|
|
6
|
-
// src/providers/FunkitConfigContext.tsx
|
|
7
|
-
import {
|
|
8
|
-
createContext,
|
|
9
|
-
useContext,
|
|
10
|
-
useMemo
|
|
11
|
-
} from "react";
|
|
12
|
-
var DEFAULT_TEXT_CUSTOMIZATIONS = {
|
|
13
|
-
virtualFiat: "Deposit with SEPA",
|
|
14
|
-
brokerageOrExchange: "Connect Exchange",
|
|
15
|
-
debitOrCredit: "Deposit with Card",
|
|
16
|
-
accountBalance: "Wallet",
|
|
17
|
-
selectAccount: "Select an exchange",
|
|
18
|
-
perpsTransferTitle: "Transfer",
|
|
19
|
-
sourceMethodTitle: "Your source",
|
|
20
|
-
tokensListTitle: "Your tokens",
|
|
21
|
-
transferTokens: "Transfer Crypto",
|
|
22
|
-
bitcoinLightning: "Bitcoin Lightning",
|
|
23
|
-
cashAppLightning: "Cash App",
|
|
24
|
-
receiveDropdownTitle: "",
|
|
25
|
-
// Default to empty
|
|
26
|
-
receiveDropdownLabel: "Asset to Receive",
|
|
27
|
-
confirmationScreen: {
|
|
28
|
-
payAmountLabel: "You send",
|
|
29
|
-
receiveAmountLabel: "You receive"
|
|
30
|
-
},
|
|
31
|
-
paymentMethodSubtitles: {}
|
|
32
|
-
};
|
|
33
|
-
var DEFAULT_UI_CUSTOMIZATIONS = {
|
|
34
|
-
alignTitle: "center",
|
|
35
|
-
alwaysShowTopDivider: false,
|
|
36
|
-
showModalTitle: true,
|
|
37
|
-
callToActionsUppercase: false,
|
|
38
|
-
enableCompactList: false,
|
|
39
|
-
checkoutHistory: {
|
|
40
|
-
showGetHelpAsAlert: true,
|
|
41
|
-
simplifiedUi: false
|
|
42
|
-
},
|
|
43
|
-
confirmationScreen: {
|
|
44
|
-
autoExpandFeesSummary: false,
|
|
45
|
-
preferDestinationWhenSame: false,
|
|
46
|
-
showAmountSummaryAbovePaymentMethod: false,
|
|
47
|
-
showDisclaimerAsAlert: true,
|
|
48
|
-
showInstantTimeEstimate: false,
|
|
49
|
-
showLeftAlignedDollarValueWithLabel: false,
|
|
50
|
-
showPaymentAmountUsd: false,
|
|
51
|
-
showReceiveAmountUsd: false,
|
|
52
|
-
showSelectedRoute: false,
|
|
53
|
-
stepIndicatorType: "spinner",
|
|
54
|
-
showTransactionDigest: "none"
|
|
55
|
-
},
|
|
56
|
-
sourceChangeScreen: {
|
|
57
|
-
bottomBarCloseButton: {
|
|
58
|
-
enabled: false,
|
|
59
|
-
labelKey: "common.close"
|
|
60
|
-
},
|
|
61
|
-
showTargetAssetSelection: false,
|
|
62
|
-
showWalletOnInsufficientBalance: false,
|
|
63
|
-
showWalletConnect: true,
|
|
64
|
-
showCustomTopComponentDivider: false,
|
|
65
|
-
paymentMethodIcons: {}
|
|
66
|
-
},
|
|
67
|
-
inputAmountScreen: {
|
|
68
|
-
allowTokenAmountInput: true
|
|
69
|
-
},
|
|
70
|
-
selectAssetScreen: {
|
|
71
|
-
isSecondaryTokenSymbolVisible: true,
|
|
72
|
-
navigateOnAssetClick: false
|
|
73
|
-
},
|
|
74
|
-
transferCryptoScreen: {
|
|
75
|
-
showYouSendYouReceive: false
|
|
76
|
-
},
|
|
77
|
-
withdrawalScreen: {
|
|
78
|
-
autoExpandFeesSummary: false
|
|
79
|
-
},
|
|
80
|
-
selectBrokerageScreen: {},
|
|
81
|
-
connectExchangeScreen: {},
|
|
82
|
-
customIcons: {},
|
|
83
|
-
customFontFamily: {
|
|
84
|
-
primary: "",
|
|
85
|
-
secondary: "",
|
|
86
|
-
tertiary: ""
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
var DEFAULT_FUNKIT_CONFIG = {
|
|
90
|
-
apiKey: "",
|
|
91
|
-
appName: "",
|
|
92
|
-
textCustomizations: DEFAULT_TEXT_CUSTOMIZATIONS,
|
|
93
|
-
uiCustomizations: DEFAULT_UI_CUSTOMIZATIONS
|
|
94
|
-
};
|
|
95
|
-
var FunkitConfigContext = createContext(
|
|
96
|
-
DEFAULT_FUNKIT_CONFIG
|
|
97
|
-
);
|
|
98
|
-
function useFunkitConfig() {
|
|
99
|
-
const originalFunkitConfig = useContext(FunkitConfigContext);
|
|
100
|
-
const { t } = useFunkitTranslation();
|
|
101
|
-
const translatedDefaults = useMemo(() => {
|
|
102
|
-
return {
|
|
103
|
-
virtualFiat: t("textCustomizations.virtualFiat"),
|
|
104
|
-
brokerageOrExchange: t("textCustomizations.brokerageOrExchange"),
|
|
105
|
-
debitOrCredit: t("textCustomizations.debitOrCredit"),
|
|
106
|
-
accountBalance: t("textCustomizations.accountBalance"),
|
|
107
|
-
selectAccount: t("textCustomizations.selectAccount"),
|
|
108
|
-
perpsTransferTitle: t("perpsTransfer.title"),
|
|
109
|
-
sourceMethodTitle: t("textCustomizations.sourceMethodTitle"),
|
|
110
|
-
tokensListTitle: t("textCustomizations.tokensListTitle"),
|
|
111
|
-
transferTokens: t("textCustomizations.transferTokens"),
|
|
112
|
-
bitcoinLightning: t("textCustomizations.bitcoinLightning"),
|
|
113
|
-
cashAppLightning: t("textCustomizations.cashAppLightning"),
|
|
114
|
-
receiveDropdownTitle: t("textCustomizations.receiveDropdownTitle"),
|
|
115
|
-
receiveDropdownLabel: t("textCustomizations.receiveDropdownLabel"),
|
|
116
|
-
confirmationScreen: {
|
|
117
|
-
payAmountLabel: t("textCustomizations.payAmountLabel"),
|
|
118
|
-
receiveAmountLabel: t("textCustomizations.receiveAmountLabel")
|
|
119
|
-
},
|
|
120
|
-
paymentMethodSubtitles: {}
|
|
121
|
-
};
|
|
122
|
-
}, [t]);
|
|
123
|
-
const finalFunkitConfig = useMemo(() => {
|
|
124
|
-
return {
|
|
125
|
-
...DEFAULT_FUNKIT_CONFIG,
|
|
126
|
-
...originalFunkitConfig,
|
|
127
|
-
textCustomizations: {
|
|
128
|
-
...translatedDefaults,
|
|
129
|
-
...originalFunkitConfig.textCustomizations,
|
|
130
|
-
confirmationScreen: {
|
|
131
|
-
...translatedDefaults.confirmationScreen,
|
|
132
|
-
...originalFunkitConfig.textCustomizations?.confirmationScreen
|
|
133
|
-
},
|
|
134
|
-
paymentMethodSubtitles: {
|
|
135
|
-
...translatedDefaults.paymentMethodSubtitles,
|
|
136
|
-
...originalFunkitConfig.textCustomizations?.paymentMethodSubtitles
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
uiCustomizations: {
|
|
140
|
-
...DEFAULT_FUNKIT_CONFIG.uiCustomizations,
|
|
141
|
-
...originalFunkitConfig.uiCustomizations,
|
|
142
|
-
checkoutHistory: {
|
|
143
|
-
...DEFAULT_FUNKIT_CONFIG.uiCustomizations.checkoutHistory,
|
|
144
|
-
...originalFunkitConfig.uiCustomizations?.checkoutHistory
|
|
145
|
-
},
|
|
146
|
-
confirmationScreen: {
|
|
147
|
-
...DEFAULT_FUNKIT_CONFIG.uiCustomizations.confirmationScreen,
|
|
148
|
-
...originalFunkitConfig.uiCustomizations?.confirmationScreen
|
|
149
|
-
},
|
|
150
|
-
connectExchangeScreen: {
|
|
151
|
-
...DEFAULT_FUNKIT_CONFIG.uiCustomizations.connectExchangeScreen,
|
|
152
|
-
...originalFunkitConfig.uiCustomizations?.connectExchangeScreen
|
|
153
|
-
},
|
|
154
|
-
inputAmountScreen: {
|
|
155
|
-
...DEFAULT_FUNKIT_CONFIG.uiCustomizations.inputAmountScreen,
|
|
156
|
-
...originalFunkitConfig.uiCustomizations?.inputAmountScreen
|
|
157
|
-
},
|
|
158
|
-
selectAssetScreen: {
|
|
159
|
-
...DEFAULT_FUNKIT_CONFIG.uiCustomizations.selectAssetScreen,
|
|
160
|
-
...originalFunkitConfig.uiCustomizations?.selectAssetScreen
|
|
161
|
-
},
|
|
162
|
-
selectBrokerageScreen: {
|
|
163
|
-
...DEFAULT_FUNKIT_CONFIG.uiCustomizations.selectBrokerageScreen,
|
|
164
|
-
...originalFunkitConfig.uiCustomizations?.selectBrokerageScreen
|
|
165
|
-
},
|
|
166
|
-
sourceChangeScreen: {
|
|
167
|
-
...DEFAULT_FUNKIT_CONFIG.uiCustomizations.sourceChangeScreen,
|
|
168
|
-
...originalFunkitConfig.uiCustomizations?.sourceChangeScreen,
|
|
169
|
-
bottomBarCloseButton: {
|
|
170
|
-
...DEFAULT_FUNKIT_CONFIG.uiCustomizations.sourceChangeScreen.bottomBarCloseButton,
|
|
171
|
-
...originalFunkitConfig.uiCustomizations?.sourceChangeScreen?.bottomBarCloseButton
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
transferCryptoScreen: {
|
|
175
|
-
...DEFAULT_FUNKIT_CONFIG.uiCustomizations.transferCryptoScreen,
|
|
176
|
-
...originalFunkitConfig.uiCustomizations?.transferCryptoScreen
|
|
177
|
-
},
|
|
178
|
-
withdrawalScreen: {
|
|
179
|
-
...DEFAULT_FUNKIT_CONFIG.uiCustomizations.withdrawalScreen,
|
|
180
|
-
...originalFunkitConfig.uiCustomizations?.withdrawalScreen
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
}, [originalFunkitConfig, translatedDefaults]);
|
|
185
|
-
return finalFunkitConfig;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
export {
|
|
189
|
-
useFunkitConfig
|
|
190
|
-
};
|