@flapsdk/vault-runtime 0.1.24 → 0.1.26
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/README.md +2 -2
- package/chunk-CPAMDXX7.js +45 -0
- package/chunk-CPAMDXX7.js.map +1 -0
- package/chunk-GA5VEHC2.js +40 -0
- package/chunk-GA5VEHC2.js.map +1 -0
- package/chunk-JLI25XFB.js +78 -0
- package/chunk-JLI25XFB.js.map +1 -0
- package/chunk-SYEMIHOY.js +408 -0
- package/chunk-SYEMIHOY.js.map +1 -0
- package/chunk-WX6B7JWO.js +183 -0
- package/chunk-WX6B7JWO.js.map +1 -0
- package/chunk-XGUVYKIJ.js +185 -0
- package/chunk-XGUVYKIJ.js.map +1 -0
- package/chunk-ZK3O6QPF.js +544 -0
- package/chunk-ZK3O6QPF.js.map +1 -0
- package/host.d.mts +4 -4
- package/host.js +8 -555
- package/host.js.map +1 -1
- package/hostRuntimeConfig-C_JJVgY0.d.mts +34 -0
- package/package.json +2 -2
- package/runtime-contract.json +1 -1
- package/sdk.d.mts +55 -11
- package/sdk.js +90 -516
- package/sdk.js.map +1 -1
- package/server.d.mts +12 -24
- package/server.js +197 -277
- package/server.js.map +1 -1
- package/{txError-BQUh3OY8.d.mts → txError-BEercCCG.d.mts} +1 -1
- package/{types-CUhkhTgO.d.mts → types-RxLUOC02.d.mts} +27 -1
- package/ui.d.mts +13 -2
- package/ui.js +3 -522
- package/ui.js.map +1 -1
- package/hostRuntimeConfig-oF7rDRpq.d.mts +0 -14
package/sdk.js
CHANGED
|
@@ -1,186 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
export { erc20Abi } from '
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
import {
|
|
2
|
+
import { createVaultRuntimeContext, chainLabelForChain, isValidAddress, ZERO_ADDRESS } from './chunk-SYEMIHOY.js';
|
|
3
|
+
export { ZERO_ADDRESS, erc20Abi, getTxErrorKind, handleTxError, isActionAvailableForPhase, isCustomVaultTaxToken, isValidAddress, readTaxVaultHostContext, resolveTokenMarketPhase, standardErc20Abi } from './chunk-SYEMIHOY.js';
|
|
4
|
+
import { createLocalNftMetadataReader, vaultV2NftAbi, nftTokenUriAbi } from './chunk-XGUVYKIJ.js';
|
|
5
|
+
export { createLocalNftMetadataReader, nftTokenUriAbi, normalizeInlineNftImage, parseInlineNftMetadata, sanitizeNftMetadataRecord, vaultV2NftAbi } from './chunk-XGUVYKIJ.js';
|
|
6
|
+
import { fetchOracleJson } from './chunk-JLI25XFB.js';
|
|
7
|
+
export { OracleReadError, buildLocalOracleUrl, createLocalOracleReader, fetchOracleJson, fetchProvisionedOracle } from './chunk-JLI25XFB.js';
|
|
8
|
+
import { RuntimeContext, Alert, useFlapSdk } from './chunk-ZK3O6QPF.js';
|
|
9
|
+
export { isIpfsImageCid, normalizeIpfsImagePath, resolveIpfsImageUrl, resolveIpfsImageUrls, useVaultContext as useFlapChain, useFlapI18n, useFlapNotify, useFlapSdk, useVaultContext } from './chunk-ZK3O6QPF.js';
|
|
10
|
+
export { formatCountdown, formatPercentBps, formatTokenAmount, parseTokenAmount, shortenAddress } from './chunk-GA5VEHC2.js';
|
|
11
|
+
import './chunk-CPAMDXX7.js';
|
|
12
|
+
import { useState, useRef, useCallback, useEffect, useMemo } from 'react';
|
|
7
13
|
import { useAccount, useChainId, useConnect, useDisconnect, useSwitchChain, usePublicClient, useWalletClient, useBalance } from 'wagmi';
|
|
8
|
-
import {
|
|
9
|
-
import { clsx } from 'clsx';
|
|
10
|
-
import { twMerge } from 'tailwind-merge';
|
|
11
|
-
import { Slot } from '@radix-ui/react-slot';
|
|
12
|
-
import { cva } from 'class-variance-authority';
|
|
13
|
-
import 'react-dom';
|
|
14
|
-
|
|
15
|
-
var standardErc20Abi = erc20Abi;
|
|
16
|
-
function shortenAddress(raw, start = 6, end = 4) {
|
|
17
|
-
if (!raw) return "";
|
|
18
|
-
if (raw.length <= start + end) return raw;
|
|
19
|
-
return `${raw.slice(0, start)}...${raw.slice(-end)}`;
|
|
20
|
-
}
|
|
21
|
-
function formatTokenAmount(value, decimals = 18, precision = 4) {
|
|
22
|
-
if (value === void 0 || value === null) return "-";
|
|
23
|
-
const raw = typeof value === "bigint" ? formatUnits(value, decimals) : String(value);
|
|
24
|
-
return new Decimal(raw).toDecimalPlaces(precision, Decimal.ROUND_DOWN).toString();
|
|
25
|
-
}
|
|
26
|
-
function parseTokenAmount(value, decimals = 18) {
|
|
27
|
-
if (!/^\d*(\.\d*)?$/.test(value.trim())) {
|
|
28
|
-
throw new Error("Invalid decimal amount.");
|
|
29
|
-
}
|
|
30
|
-
return parseUnits(value || "0", decimals);
|
|
31
|
-
}
|
|
32
|
-
function formatPercentBps(value, precision = 2) {
|
|
33
|
-
if (value === void 0 || value === null) return "-";
|
|
34
|
-
return `${new Decimal(String(value)).div(100).toDecimalPlaces(precision).toString()}%`;
|
|
35
|
-
}
|
|
36
|
-
function formatCountdown(targetTimeMs) {
|
|
37
|
-
if (!targetTimeMs) return "-";
|
|
38
|
-
const diff = Math.max(0, targetTimeMs - Date.now());
|
|
39
|
-
const totalSeconds = Math.floor(diff / 1e3);
|
|
40
|
-
const days = Math.floor(totalSeconds / 86400);
|
|
41
|
-
const hours = Math.floor(totalSeconds % 86400 / 3600);
|
|
42
|
-
const minutes = Math.floor(totalSeconds % 3600 / 60);
|
|
43
|
-
const seconds = totalSeconds % 60;
|
|
44
|
-
if (days > 0) return `${days}d ${hours}h ${minutes}m`;
|
|
45
|
-
if (hours > 0) return `${hours}h ${minutes}m ${seconds}s`;
|
|
46
|
-
return `${minutes}m ${seconds}s`;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// src/sdk/hostRuntimeConfig.ts
|
|
50
|
-
var taxVaultHostChains = {
|
|
51
|
-
56: {
|
|
52
|
-
portal: "0xe2ce6ab80874fa9fa2aae65d277dd6b8e65c9de0",
|
|
53
|
-
taxTokenHelperAddress: "0x53841c73217735F37BC1775538b03b23feFD8346",
|
|
54
|
-
vaultPortal: "0x90497450f2a706f1951b5bdda52B4E5d16f34C06",
|
|
55
|
-
wrappedNativeTokenAddress: "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
|
|
56
|
-
giftVaultFactory: "0x025549F52B03cF36f9e1a337c02d3AA7Af66ab32",
|
|
57
|
-
hostChainSlug: "bnb",
|
|
58
|
-
ipfsGateway: "https://flap.mypinata.cloud"
|
|
59
|
-
},
|
|
60
|
-
97: {
|
|
61
|
-
portal: "0x5bEacaF7ABCbB3aB280e80D007FD31fcE26510e9",
|
|
62
|
-
taxTokenHelperAddress: "0xD64441e5FcD02D342B8cf6eBA10Ef6E40d0dA90f",
|
|
63
|
-
vaultPortal: "0x027e3704fC5C16522e9393d04C60A3ac5c0d775f",
|
|
64
|
-
wrappedNativeTokenAddress: "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd",
|
|
65
|
-
giftVaultFactory: "0xa02DA44D67DB6D692efa7f751b5952bd670d5326",
|
|
66
|
-
hostChainSlug: "bnb-testnet",
|
|
67
|
-
ipfsGateway: "https://magenta-naval-penguin-822.mypinata.cloud"
|
|
68
|
-
},
|
|
69
|
-
4663: {
|
|
70
|
-
portal: "0x26605f322f7fF986f381bB9A6e3f5DAb0bEaEb09",
|
|
71
|
-
taxTokenHelperAddress: "0xb10bD2672aE63735d677164A54B573a016f0203C",
|
|
72
|
-
vaultPortal: "0xe9F7AB7DE8FB8756acbB6a1cd13316a43308197B",
|
|
73
|
-
wrappedNativeTokenAddress: "0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73",
|
|
74
|
-
giftVaultFactory: "0xe6ca297D1d963b6F00d5b216986123CAeB883AF6",
|
|
75
|
-
hostChainSlug: "robinhood",
|
|
76
|
-
ipfsGateway: "https://flap.mypinata.cloud"
|
|
77
|
-
},
|
|
78
|
-
46630: {
|
|
79
|
-
portal: "0x26605f322f7fF986f381bB9A6e3f5DAb0bEaEb09",
|
|
80
|
-
taxTokenHelperAddress: "0xb10bD2672aE63735d677164A54B573a016f0203C",
|
|
81
|
-
vaultPortal: "0xe9F7AB7DE8FB8756acbB6a1cd13316a43308197B",
|
|
82
|
-
wrappedNativeTokenAddress: "0x7943e237c7F95DA44E0301572D358911207852Fa",
|
|
83
|
-
hostChainSlug: "robinhood-testnet",
|
|
84
|
-
ipfsGateway: "https://flap.mypinata.cloud"
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
function getTaxVaultHostChainConfig(chainId) {
|
|
88
|
-
return taxVaultHostChains[chainId];
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// src/sdk/ipfsImage.ts
|
|
92
|
-
var DEFAULT_IPFS_IMAGE_GATEWAY = "https://flap.mypinata.cloud";
|
|
93
|
-
var IPFS_IMAGE_GATEWAYS = ["https://flap.mypinata.cloud", "https://magenta-naval-penguin-822.mypinata.cloud"];
|
|
94
|
-
var CID_RE = /^(?:Qm[1-9A-HJ-NP-Za-km-z]{44}|b[a-z2-7]{20,})$/;
|
|
95
|
-
function isIpfsImageCid(value) {
|
|
96
|
-
return CID_RE.test(value.trim());
|
|
97
|
-
}
|
|
98
|
-
function resolveIpfsImageUrl(cid, chainId = 56) {
|
|
99
|
-
if (!isIpfsImageCid(cid)) return void 0;
|
|
100
|
-
const gateway = (getTaxVaultHostChainConfig(chainId)?.ipfsGateway ?? DEFAULT_IPFS_IMAGE_GATEWAY).replace(/\/+$/, "");
|
|
101
|
-
return `${gateway}/ipfs/${cid.trim()}`;
|
|
102
|
-
}
|
|
103
|
-
function resolveIpfsImageUrls(cid, chainId = 56) {
|
|
104
|
-
if (!isIpfsImageCid(cid)) return [];
|
|
105
|
-
const preferred = (getTaxVaultHostChainConfig(chainId)?.ipfsGateway ?? DEFAULT_IPFS_IMAGE_GATEWAY).replace(/\/+$/, "");
|
|
106
|
-
const gateways = [preferred, ...IPFS_IMAGE_GATEWAYS.map((gateway) => gateway.replace(/\/+$/, ""))];
|
|
107
|
-
return [...new Set(gateways)].map((gateway) => `${gateway}/ipfs/${cid.trim()}`);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// src/sdk/oracle.ts
|
|
111
|
-
var DEFAULT_LOCAL_ORACLE_ENDPOINT_BASE = "/api/runtime/oracle";
|
|
112
|
-
var CONTEXT_CHAIN_ORACLE_IDS = /* @__PURE__ */ new Set(["v2-pool-reserves"]);
|
|
113
|
-
var OracleReadError = class extends Error {
|
|
114
|
-
constructor(message, status) {
|
|
115
|
-
super(message);
|
|
116
|
-
this.name = "OracleReadError";
|
|
117
|
-
this.status = status;
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
function appendSearchParams(url, params) {
|
|
121
|
-
for (const [key, value] of Object.entries(params ?? {})) {
|
|
122
|
-
url.searchParams.set(key, value);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
function toOracleProvision(provision) {
|
|
126
|
-
return typeof provision === "string" ? { endpoint: provision } : provision;
|
|
127
|
-
}
|
|
128
|
-
function buildProvisionedParams(provision, params) {
|
|
129
|
-
const filteredParams = provision.allowedParams && provision.allowedParams.length ? Object.fromEntries(Object.entries(params ?? {}).filter(([key]) => provision.allowedParams?.includes(key))) : params;
|
|
130
|
-
return {
|
|
131
|
-
...filteredParams ?? {},
|
|
132
|
-
...provision.fixedParams ?? {}
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
function buildLocalOracleUrl(oracleId, params, endpointBase = DEFAULT_LOCAL_ORACLE_ENDPOINT_BASE) {
|
|
136
|
-
const normalizedBase = endpointBase.replace(/\/+$/, "");
|
|
137
|
-
const url = new URL(`${normalizedBase}/${encodeURIComponent(oracleId)}`, "http://localhost");
|
|
138
|
-
appendSearchParams(url, params);
|
|
139
|
-
return `${url.pathname}${url.search}`;
|
|
140
|
-
}
|
|
141
|
-
async function fetchOracleJson({
|
|
142
|
-
endpoint,
|
|
143
|
-
params,
|
|
144
|
-
fetchImpl
|
|
145
|
-
}) {
|
|
146
|
-
const fallbackOrigin = typeof window !== "undefined" ? window.location.origin : "http://localhost";
|
|
147
|
-
const url = new URL(endpoint, fallbackOrigin);
|
|
148
|
-
appendSearchParams(url, params);
|
|
149
|
-
const response = await (fetchImpl ?? fetch)(url.toString(), {
|
|
150
|
-
cache: "no-store",
|
|
151
|
-
method: "GET"
|
|
152
|
-
});
|
|
153
|
-
if (!response.ok) {
|
|
154
|
-
throw new OracleReadError(`Oracle request returned ${response.status}.`, response.status);
|
|
155
|
-
}
|
|
156
|
-
return await response.json();
|
|
157
|
-
}
|
|
158
|
-
async function fetchProvisionedOracle({
|
|
159
|
-
provision,
|
|
160
|
-
params,
|
|
161
|
-
fetchImpl
|
|
162
|
-
}) {
|
|
163
|
-
const normalizedProvision = toOracleProvision(provision);
|
|
164
|
-
return fetchOracleJson({
|
|
165
|
-
endpoint: normalizedProvision.endpoint,
|
|
166
|
-
params: buildProvisionedParams(normalizedProvision, params),
|
|
167
|
-
fetchImpl
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
function createLocalOracleReader(options = {}) {
|
|
171
|
-
const endpointBase = options.endpointBase ?? DEFAULT_LOCAL_ORACLE_ENDPOINT_BASE;
|
|
172
|
-
const fetchImpl = options.fetchImpl;
|
|
173
|
-
return async function readLocalOracle({ oracleId, params, context }) {
|
|
174
|
-
const oracleParams = CONTEXT_CHAIN_ORACLE_IDS.has(oracleId) && !params?.chainId ? {
|
|
175
|
-
...params ?? {},
|
|
176
|
-
chainId: String(context.chainId)
|
|
177
|
-
} : params;
|
|
178
|
-
return fetchOracleJson({
|
|
179
|
-
endpoint: buildLocalOracleUrl(oracleId, oracleParams, endpointBase),
|
|
180
|
-
fetchImpl
|
|
181
|
-
});
|
|
182
|
-
};
|
|
183
|
-
}
|
|
14
|
+
import { formatUnits } from 'viem';
|
|
184
15
|
|
|
185
16
|
// src/sdk/three.ts
|
|
186
17
|
function assertArtifactAssetUrl(assetUrl, moduleUrl) {
|
|
@@ -201,263 +32,22 @@ function resolveMiniApp3DDecoderUrls(urls, moduleUrl) {
|
|
|
201
32
|
...urls.ktx2 ? { ktx2: assertArtifactAssetUrl(urls.ktx2, moduleUrl) } : {}
|
|
202
33
|
};
|
|
203
34
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
success: "border-[#D0FF00]/45 bg-[#101400] text-[#D0FF00]",
|
|
212
|
-
warning: "border-[#FFD166]/45 bg-[#1A1305] text-[#FFD166]",
|
|
213
|
-
danger: "border-[#FF4A55]/55 bg-[#1D0709] text-[#FF8A91]"
|
|
214
|
-
};
|
|
215
|
-
var iconMap = {
|
|
216
|
-
info: Info,
|
|
217
|
-
success: CheckCircle2,
|
|
218
|
-
warning: AlertTriangle,
|
|
219
|
-
danger: AlertTriangle
|
|
220
|
-
};
|
|
221
|
-
function Alert({ children, tone = "info", className }) {
|
|
222
|
-
const Icon = iconMap[tone];
|
|
223
|
-
return /* @__PURE__ */ React.createElement("div", { "data-flap-ui": "alert", className: cn("flex gap-3 rounded-[6px] border p-3 text-sm font-medium leading-6", toneClass[tone], className) }, /* @__PURE__ */ React.createElement(Icon, { className: "mt-0.5 h-4 w-4 shrink-0 opacity-90" }), /* @__PURE__ */ React.createElement("div", { className: "min-w-0 break-words" }, children));
|
|
224
|
-
}
|
|
225
|
-
var buttonVariants = cva(
|
|
226
|
-
"inline-flex items-center justify-center gap-2 whitespace-nowrap text-sm font-semibold uppercase leading-[1.4] tracking-normal duration-0 hover:transition-colors hover:duration-150 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#D0FF00]/45 disabled:pointer-events-none disabled:opacity-50",
|
|
227
|
-
{
|
|
228
|
-
variants: {
|
|
229
|
-
variant: {
|
|
230
|
-
default: "ui20-connect-chamfer text-[#070808] [--ui20-chamfer-bg:#D0FF00] [--ui20-chamfer-border:#D0FF00] hover:[--ui20-chamfer-bg:#BDE800] hover:[--ui20-chamfer-border:#BDE800]",
|
|
231
|
-
secondary: "ui20-connect-chamfer text-white [--ui20-chamfer-bg:#262626] [--ui20-chamfer-border:#262626] hover:text-[#D0FF00] hover:[--ui20-chamfer-bg:#303030] hover:[--ui20-chamfer-border:#303030]",
|
|
232
|
-
outline: "ui20-connect-chamfer text-[#D4D4D4] [--ui20-chamfer-bg:#000000] [--ui20-chamfer-border:#303236] hover:text-[#D0FF00] hover:[--ui20-chamfer-border:#D0FF00]",
|
|
233
|
-
ghost: "rounded-[6px] text-[#D4D4D4] hover:bg-[#131516] hover:text-[#D0FF00]",
|
|
234
|
-
destructive: "ui20-connect-chamfer text-[#FF4A55] [--ui20-chamfer-bg:#000000] [--ui20-chamfer-border:#FF4A55] hover:text-black hover:[--ui20-chamfer-bg:#FF4A55]"
|
|
235
|
-
},
|
|
236
|
-
size: {
|
|
237
|
-
default: "h-10 px-4",
|
|
238
|
-
sm: "h-8 px-3 text-xs",
|
|
239
|
-
lg: "h-12 px-5",
|
|
240
|
-
icon: "h-10 w-10 px-0"
|
|
241
|
-
}
|
|
242
|
-
},
|
|
243
|
-
defaultVariants: {
|
|
244
|
-
variant: "default",
|
|
245
|
-
size: "default"
|
|
246
|
-
}
|
|
35
|
+
var defaultNftMetadataReader = createLocalNftMetadataReader();
|
|
36
|
+
var NFT_METADATA_MAX_CONCURRENCY = 6;
|
|
37
|
+
var activeNftMetadataReads = 0;
|
|
38
|
+
var pendingNftMetadataReads = [];
|
|
39
|
+
async function limitNftMetadataRead(task) {
|
|
40
|
+
if (activeNftMetadataReads >= NFT_METADATA_MAX_CONCURRENCY) {
|
|
41
|
+
await new Promise((resolve) => pendingNftMetadataReads.push(resolve));
|
|
247
42
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
}
|
|
255
|
-
return /* @__PURE__ */ React3.createElement(
|
|
256
|
-
Comp,
|
|
257
|
-
{
|
|
258
|
-
"data-flap-ui": "button",
|
|
259
|
-
className: cn(buttonVariants({ variant, size, className })),
|
|
260
|
-
ref,
|
|
261
|
-
disabled: disabled || loading,
|
|
262
|
-
...props
|
|
263
|
-
},
|
|
264
|
-
loading ? /* @__PURE__ */ React3.createElement(Loader2, { className: "relative z-10 h-4 w-4 animate-spin" }) : null,
|
|
265
|
-
/* @__PURE__ */ React3.createElement("span", { className: "relative z-10 inline-flex min-w-0 items-center justify-center gap-2" }, children)
|
|
266
|
-
);
|
|
43
|
+
activeNftMetadataReads += 1;
|
|
44
|
+
try {
|
|
45
|
+
return await task();
|
|
46
|
+
} finally {
|
|
47
|
+
activeNftMetadataReads -= 1;
|
|
48
|
+
pendingNftMetadataReads.shift()?.();
|
|
267
49
|
}
|
|
268
|
-
);
|
|
269
|
-
Button.displayName = "Button";
|
|
270
|
-
var Card = React3.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React3.createElement(
|
|
271
|
-
"div",
|
|
272
|
-
{
|
|
273
|
-
"data-flap-ui": "card",
|
|
274
|
-
ref,
|
|
275
|
-
className: cn(
|
|
276
|
-
"rounded-[8px] border border-[#303236] bg-[#070808] text-white shadow-[0_18px_60px_-42px_rgba(208,255,0,0.45)]",
|
|
277
|
-
className
|
|
278
|
-
),
|
|
279
|
-
...props
|
|
280
|
-
}
|
|
281
|
-
));
|
|
282
|
-
Card.displayName = "Card";
|
|
283
|
-
var CardHeader = React3.forwardRef(
|
|
284
|
-
({ className, ...props }, ref) => /* @__PURE__ */ React3.createElement("div", { "data-flap-ui": "card-header", ref, className: cn("flex flex-col gap-1.5 p-4 sm:p-5", className), ...props })
|
|
285
|
-
);
|
|
286
|
-
CardHeader.displayName = "CardHeader";
|
|
287
|
-
var CardTitle = React3.forwardRef(
|
|
288
|
-
({ className, ...props }, ref) => /* @__PURE__ */ React3.createElement("h3", { "data-flap-ui": "card-title", ref, className: cn("text-base font-semibold uppercase leading-tight tracking-normal text-white sm:text-lg", className), ...props })
|
|
289
|
-
);
|
|
290
|
-
CardTitle.displayName = "CardTitle";
|
|
291
|
-
var CardDescription = React3.forwardRef(
|
|
292
|
-
({ className, ...props }, ref) => /* @__PURE__ */ React3.createElement("p", { "data-flap-ui": "card-description", ref, className: cn("text-sm leading-6 text-[#84888C]", className), ...props })
|
|
293
|
-
);
|
|
294
|
-
CardDescription.displayName = "CardDescription";
|
|
295
|
-
var CardContent = React3.forwardRef(
|
|
296
|
-
({ className, ...props }, ref) => /* @__PURE__ */ React3.createElement("div", { "data-flap-ui": "card-content", ref, className: cn("p-4 pt-0 sm:p-5 sm:pt-0", className), ...props })
|
|
297
|
-
);
|
|
298
|
-
CardContent.displayName = "CardContent";
|
|
299
|
-
var Input = React3.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React3.createElement(
|
|
300
|
-
"input",
|
|
301
|
-
{
|
|
302
|
-
"data-flap-ui": "input",
|
|
303
|
-
ref,
|
|
304
|
-
className: cn(
|
|
305
|
-
"flex h-11 w-full rounded-[6px] border border-[#303236] bg-black px-3 py-2 text-sm font-semibold text-white caret-[#D0FF00] shadow-[inset_0_1px_0_rgba(255,255,255,0.04)] outline-none duration-0 selection:bg-[#D0FF00]/35 selection:text-white placeholder:text-[#84888C] focus:border-[#D0FF00] focus:ring-2 focus:ring-[#D0FF00]/25 disabled:cursor-not-allowed disabled:bg-[#131516] disabled:text-[#84888C] disabled:opacity-80",
|
|
306
|
-
className
|
|
307
|
-
),
|
|
308
|
-
...props
|
|
309
|
-
}
|
|
310
|
-
));
|
|
311
|
-
Input.displayName = "Input";
|
|
312
|
-
|
|
313
|
-
// src/sdk/taxInfo.ts
|
|
314
|
-
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
315
|
-
function isValidAddress(value) {
|
|
316
|
-
return Boolean(value && /^0x[a-fA-F0-9]{40}$/.test(value));
|
|
317
50
|
}
|
|
318
|
-
function isSameAddress(a, b) {
|
|
319
|
-
return Boolean(a && b && a.toLowerCase() === b.toLowerCase());
|
|
320
|
-
}
|
|
321
|
-
function resolveManifestBinding(manifest, input) {
|
|
322
|
-
const bindings = manifest.match.bindings;
|
|
323
|
-
if (!bindings.length) return null;
|
|
324
|
-
const resolveUnique = (candidates) => {
|
|
325
|
-
if (candidates.length === 1) return candidates[0];
|
|
326
|
-
return null;
|
|
327
|
-
};
|
|
328
|
-
const matchesChain = (binding) => !input.chainId || binding.chainId === input.chainId;
|
|
329
|
-
const matchesToken = (binding) => !input.tokenAddress || !binding.tokenAddresses?.length || binding.tokenAddresses.some((address) => isSameAddress(address, input.tokenAddress));
|
|
330
|
-
const isVaultScopedBinding = (binding) => !binding.factoryAddress && Boolean(binding.vaultAddresses?.length);
|
|
331
|
-
const isTokenScopedBinding = (binding) => !binding.factoryAddress && !binding.vaultAddresses?.length && Boolean(binding.tokenAddresses?.length);
|
|
332
|
-
if (input.factoryAddress) {
|
|
333
|
-
const factoryMatch = resolveUnique(
|
|
334
|
-
bindings.filter((binding) => matchesChain(binding) && Boolean(binding.factoryAddress) && isSameAddress(binding.factoryAddress, input.factoryAddress) && matchesToken(binding))
|
|
335
|
-
);
|
|
336
|
-
if (factoryMatch) return factoryMatch;
|
|
337
|
-
if (!input.vaultAddress && !input.tokenAddress) return null;
|
|
338
|
-
}
|
|
339
|
-
if (input.vaultAddress) {
|
|
340
|
-
const vaultMatch = resolveUnique(
|
|
341
|
-
bindings.filter(
|
|
342
|
-
(binding) => matchesChain(binding) && isVaultScopedBinding(binding) && Boolean(binding.vaultAddresses?.some((address) => isSameAddress(address, input.vaultAddress))) && matchesToken(binding)
|
|
343
|
-
)
|
|
344
|
-
);
|
|
345
|
-
if (vaultMatch) return vaultMatch;
|
|
346
|
-
}
|
|
347
|
-
if (input.tokenAddress) {
|
|
348
|
-
const tokenMatch = resolveUnique(
|
|
349
|
-
bindings.filter(
|
|
350
|
-
(binding) => matchesChain(binding) && isTokenScopedBinding(binding) && Boolean(binding.tokenAddresses?.some((address) => isSameAddress(address, input.tokenAddress)))
|
|
351
|
-
)
|
|
352
|
-
);
|
|
353
|
-
if (tokenMatch) return tokenMatch;
|
|
354
|
-
}
|
|
355
|
-
if (input.factoryAddress || input.vaultAddress) {
|
|
356
|
-
return null;
|
|
357
|
-
}
|
|
358
|
-
if (input.chainId && input.tokenAddress) {
|
|
359
|
-
const tokenScopedMatch = resolveUnique(bindings.filter((binding) => binding.chainId === input.chainId && binding.tokenAddresses?.some((address) => isSameAddress(address, input.tokenAddress))));
|
|
360
|
-
if (tokenScopedMatch) return tokenScopedMatch;
|
|
361
|
-
}
|
|
362
|
-
if (input.tokenAddress) {
|
|
363
|
-
return resolveUnique(bindings.filter((binding) => binding.tokenAddresses?.some((address) => isSameAddress(address, input.tokenAddress))));
|
|
364
|
-
}
|
|
365
|
-
if (input.chainId) {
|
|
366
|
-
return resolveUnique(bindings.filter((binding) => binding.chainId === input.chainId && matchesToken(binding)));
|
|
367
|
-
}
|
|
368
|
-
return null;
|
|
369
|
-
}
|
|
370
|
-
function resolveTokenMarketPhase(tokenInfo) {
|
|
371
|
-
if (!tokenInfo?.exists) return "unknown";
|
|
372
|
-
return tokenInfo.status >= 2 ? "dex-listed" : "internal-market";
|
|
373
|
-
}
|
|
374
|
-
function isCustomVaultTaxToken(tokenInfo) {
|
|
375
|
-
return Boolean(tokenInfo?.exists && tokenInfo.isTaxToken);
|
|
376
|
-
}
|
|
377
|
-
function isActionAvailableForPhase(stage, marketPhase = "unknown") {
|
|
378
|
-
if (stage === "read-only") return false;
|
|
379
|
-
if (stage === "both") return true;
|
|
380
|
-
if (marketPhase === "unknown") return false;
|
|
381
|
-
return stage === marketPhase;
|
|
382
|
-
}
|
|
383
|
-
function readTaxVaultHostContext(host) {
|
|
384
|
-
const tokenInfo = host?.tokenInfo;
|
|
385
|
-
const marketPhase = host?.marketPhase ?? resolveTokenMarketPhase(tokenInfo);
|
|
386
|
-
const isListed = host?.isListed ?? Boolean(tokenInfo && tokenInfo.status >= 2);
|
|
387
|
-
const isTaxToken = tokenInfo?.isTaxToken === true;
|
|
388
|
-
return {
|
|
389
|
-
tokenInfo,
|
|
390
|
-
taxInfo: host?.taxInfo ?? null,
|
|
391
|
-
vaultInfo: host?.vaultInfo ?? null,
|
|
392
|
-
feeMode: host?.feeMode ?? "unknown",
|
|
393
|
-
renderSurface: host?.renderSurface ?? "unavailable",
|
|
394
|
-
vaultType: host?.vaultType,
|
|
395
|
-
copyScope: host?.copyScope ?? "tax",
|
|
396
|
-
marketPhase,
|
|
397
|
-
isListed,
|
|
398
|
-
isTaxToken,
|
|
399
|
-
isSupportedCustomVaultToken: isCustomVaultTaxToken(tokenInfo)
|
|
400
|
-
};
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
// src/sdk/runtimeContext.ts
|
|
404
|
-
var zeroAddress = "0x0000000000000000000000000000000000000000";
|
|
405
|
-
function explorerForChain(chainId) {
|
|
406
|
-
if (chainId === 56) return "https://bscscan.com";
|
|
407
|
-
if (chainId === 97) return "https://testnet.bscscan.com";
|
|
408
|
-
if (chainId === 4663) return "https://robinhoodchain.blockscout.com";
|
|
409
|
-
if (chainId === 46630) return "https://explorer.testnet.chain.robinhood.com";
|
|
410
|
-
return void 0;
|
|
411
|
-
}
|
|
412
|
-
function chainLabelForChain(chainId) {
|
|
413
|
-
if (chainId === 56) return "BNB Chain";
|
|
414
|
-
if (chainId === 97) return "BNB Testnet";
|
|
415
|
-
if (chainId === 4663) return "Robinhood Chain";
|
|
416
|
-
if (chainId === 46630) return "Robinhood Chain Testnet";
|
|
417
|
-
return `Chain ${chainId}`;
|
|
418
|
-
}
|
|
419
|
-
function buildRuntimeExtraConfig(input) {
|
|
420
|
-
const hostRuntimeResult = input.hostRuntimeResult;
|
|
421
|
-
const runtimeOverrides = input.runtimeOverrides;
|
|
422
|
-
return {
|
|
423
|
-
...hostRuntimeResult ? {
|
|
424
|
-
hostRuntimeStatus: hostRuntimeResult.status,
|
|
425
|
-
hostRuntimePolicy: hostRuntimeResult.policy,
|
|
426
|
-
hostRuntimeDegradeReason: hostRuntimeResult.degradeReason,
|
|
427
|
-
hostRuntimeWarnings: hostRuntimeResult.warnings
|
|
428
|
-
} : {},
|
|
429
|
-
...hostRuntimeResult?.presentation?.extraConfig ?? {},
|
|
430
|
-
...runtimeOverrides?.extraConfig ?? {}
|
|
431
|
-
};
|
|
432
|
-
}
|
|
433
|
-
function createVaultRuntimeContext(input) {
|
|
434
|
-
const runtimeOverrides = input.runtimeOverrides;
|
|
435
|
-
const resolvedBinding = resolveManifestBinding(input.manifest, {
|
|
436
|
-
chainId: runtimeOverrides?.chainId ?? input.connectedChainId ?? input.hostRuntimeResult?.addresses.chainId,
|
|
437
|
-
factoryAddress: runtimeOverrides?.factoryAddress ?? input.hostRuntimeResult?.addresses.factoryAddress,
|
|
438
|
-
vaultAddress: runtimeOverrides?.vaultAddress ?? input.hostRuntimeResult?.addresses.vaultAddress,
|
|
439
|
-
tokenAddress: runtimeOverrides?.tokenAddress ?? input.hostRuntimeResult?.addresses.tokenAddress
|
|
440
|
-
});
|
|
441
|
-
const effectiveChainId = runtimeOverrides?.chainId ?? input.hostRuntimeResult?.addresses.chainId ?? input.connectedChainId ?? resolvedBinding?.chainId ?? input.manifest.match.bindings[0]?.chainId ?? 56;
|
|
442
|
-
return {
|
|
443
|
-
chainId: effectiveChainId,
|
|
444
|
-
factoryAddress: runtimeOverrides?.factoryAddress ?? input.hostRuntimeResult?.addresses.factoryAddress ?? resolvedBinding?.factoryAddress ?? zeroAddress,
|
|
445
|
-
tokenAddress: runtimeOverrides?.tokenAddress ?? input.hostRuntimeResult?.addresses.tokenAddress ?? zeroAddress,
|
|
446
|
-
vaultAddress: runtimeOverrides?.vaultAddress ?? input.hostRuntimeResult?.addresses.vaultAddress ?? zeroAddress,
|
|
447
|
-
userAddress: runtimeOverrides?.userAddress,
|
|
448
|
-
tokenSymbol: runtimeOverrides?.tokenSymbol ?? input.hostRuntimeResult?.tokenSymbol,
|
|
449
|
-
tokenName: runtimeOverrides?.tokenName ?? input.hostRuntimeResult?.tokenName,
|
|
450
|
-
tokenImageUrl: runtimeOverrides?.tokenImageUrl ?? input.hostRuntimeResult?.tokenImageUrl,
|
|
451
|
-
explorerBaseUrl: runtimeOverrides?.explorerBaseUrl ?? explorerForChain(effectiveChainId),
|
|
452
|
-
paymentToken: runtimeOverrides?.paymentToken ?? input.hostRuntimeResult?.paymentToken,
|
|
453
|
-
host: runtimeOverrides?.host ?? input.hostRuntimeResult?.host,
|
|
454
|
-
extraConfig: buildRuntimeExtraConfig(input),
|
|
455
|
-
manifest: input.manifest
|
|
456
|
-
};
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
// src/sdk/runtime.tsx
|
|
460
|
-
var RuntimeContext = createContext(null);
|
|
461
51
|
function applyParams(value, params) {
|
|
462
52
|
if (!params) return value;
|
|
463
53
|
return Object.entries(params).reduce((acc, [key, item]) => acc.replaceAll(`{${key}}`, String(item)), value);
|
|
@@ -468,10 +58,12 @@ function getPreviewOracleEndpoint(extraConfig, oracleId) {
|
|
|
468
58
|
const endpoint = oracleEndpoints[oracleId];
|
|
469
59
|
return typeof endpoint === "string" ? endpoint : void 0;
|
|
470
60
|
}
|
|
471
|
-
function VaultRuntimeProvider({ children, manifest, i18n, runtimeContext: runtimeOverrides, hostRuntimeResult, locale = "en", oracleReader }) {
|
|
61
|
+
function VaultRuntimeProvider({ children, manifest, i18n, runtimeContext: runtimeOverrides, hostRuntimeResult, locale = "en", oracleReader, nftMetadataReader }) {
|
|
472
62
|
const [version, setVersion] = useState(0);
|
|
473
63
|
const [messages, setMessages] = useState([]);
|
|
474
64
|
const toastTimersRef = useRef(/* @__PURE__ */ new Map());
|
|
65
|
+
const nftMetadataCacheRef = useRef(/* @__PURE__ */ new Map());
|
|
66
|
+
const vaultNftAddressCacheRef = useRef(/* @__PURE__ */ new Map());
|
|
475
67
|
const { address: accountAddress, isConnected } = useAccount();
|
|
476
68
|
const connectedChainId = useChainId();
|
|
477
69
|
const { connect, connectors } = useConnect();
|
|
@@ -663,6 +255,65 @@ function VaultRuntimeProvider({ children, manifest, i18n, runtimeContext: runtim
|
|
|
663
255
|
},
|
|
664
256
|
[oracleReader, runtimeContext]
|
|
665
257
|
);
|
|
258
|
+
const readNftMetadata = useCallback(
|
|
259
|
+
async (request) => {
|
|
260
|
+
if (request.tokenId < 0n) throw new Error("NFT tokenId must not be negative.");
|
|
261
|
+
const vaultAddress = runtimeContext.vaultAddress;
|
|
262
|
+
if (!isValidAddress(vaultAddress) || vaultAddress.toLowerCase() === ZERO_ADDRESS) {
|
|
263
|
+
throw new Error("Vault V2 NFT metadata requires a valid runtime Vault address.");
|
|
264
|
+
}
|
|
265
|
+
const cacheKey = `${runtimeContext.chainId}:${vaultAddress.toLowerCase()}:${request.tokenId.toString()}:${version}`;
|
|
266
|
+
const cached = nftMetadataCacheRef.current.get(cacheKey);
|
|
267
|
+
if (cached) return cached;
|
|
268
|
+
const pending = limitNftMetadataRead(async () => {
|
|
269
|
+
const nftAddressCacheKey = `${runtimeContext.chainId}:${vaultAddress.toLowerCase()}:${version}`;
|
|
270
|
+
let nftAddressPending = vaultNftAddressCacheRef.current.get(nftAddressCacheKey);
|
|
271
|
+
if (!nftAddressPending) {
|
|
272
|
+
nftAddressPending = readContract({
|
|
273
|
+
contract: "vault",
|
|
274
|
+
address: vaultAddress,
|
|
275
|
+
abi: vaultV2NftAbi,
|
|
276
|
+
functionName: "nft"
|
|
277
|
+
}).then((nftAddress2) => {
|
|
278
|
+
if (!isValidAddress(nftAddress2) || nftAddress2.toLowerCase() === ZERO_ADDRESS) {
|
|
279
|
+
throw new Error("Vault V2 nft() returned an invalid NFT address.");
|
|
280
|
+
}
|
|
281
|
+
return nftAddress2;
|
|
282
|
+
});
|
|
283
|
+
vaultNftAddressCacheRef.current.set(nftAddressCacheKey, nftAddressPending);
|
|
284
|
+
if (vaultNftAddressCacheRef.current.size > 32) {
|
|
285
|
+
const oldestNftAddressKey = vaultNftAddressCacheRef.current.keys().next().value;
|
|
286
|
+
if (oldestNftAddressKey) vaultNftAddressCacheRef.current.delete(oldestNftAddressKey);
|
|
287
|
+
}
|
|
288
|
+
nftAddressPending.catch(() => vaultNftAddressCacheRef.current.delete(nftAddressCacheKey));
|
|
289
|
+
}
|
|
290
|
+
const nftAddress = await nftAddressPending;
|
|
291
|
+
const tokenUri = await readContract({
|
|
292
|
+
contract: "nft",
|
|
293
|
+
address: nftAddress,
|
|
294
|
+
abi: nftTokenUriAbi,
|
|
295
|
+
functionName: "tokenURI",
|
|
296
|
+
args: [request.tokenId]
|
|
297
|
+
});
|
|
298
|
+
if (typeof tokenUri !== "string" || !tokenUri.trim()) throw new Error("NFT tokenURI returned an empty value.");
|
|
299
|
+
return (nftMetadataReader ?? defaultNftMetadataReader)({
|
|
300
|
+
...request,
|
|
301
|
+
chainId: runtimeContext.chainId,
|
|
302
|
+
nftAddress,
|
|
303
|
+
tokenUri: tokenUri.trim(),
|
|
304
|
+
context: runtimeContext
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
nftMetadataCacheRef.current.set(cacheKey, pending);
|
|
308
|
+
if (nftMetadataCacheRef.current.size > 128) {
|
|
309
|
+
const oldestKey = nftMetadataCacheRef.current.keys().next().value;
|
|
310
|
+
if (oldestKey) nftMetadataCacheRef.current.delete(oldestKey);
|
|
311
|
+
}
|
|
312
|
+
pending.catch(() => nftMetadataCacheRef.current.delete(cacheKey));
|
|
313
|
+
return pending;
|
|
314
|
+
},
|
|
315
|
+
[nftMetadataReader, readContract, runtimeContext, version]
|
|
316
|
+
);
|
|
666
317
|
const refetch = useCallback(async () => {
|
|
667
318
|
setVersion((item) => item + 1);
|
|
668
319
|
}, []);
|
|
@@ -684,11 +335,12 @@ function VaultRuntimeProvider({ children, manifest, i18n, runtimeContext: runtim
|
|
|
684
335
|
writeContract,
|
|
685
336
|
waitForTx,
|
|
686
337
|
readOracle,
|
|
338
|
+
readNftMetadata,
|
|
687
339
|
refetch,
|
|
688
340
|
refetchNonce: version,
|
|
689
341
|
openExplorerTx
|
|
690
342
|
}),
|
|
691
|
-
[i18nApi, notify, openExplorerTx, readContract, readOracle, refetch, runtimeContext, simulateContract, version, waitForTx, wallet, writeContract]
|
|
343
|
+
[i18nApi, notify, openExplorerTx, readContract, readNftMetadata, readOracle, refetch, runtimeContext, simulateContract, version, waitForTx, wallet, writeContract]
|
|
692
344
|
);
|
|
693
345
|
return /* @__PURE__ */ React.createElement(RuntimeContext.Provider, { value: sdk }, children, /* @__PURE__ */ React.createElement("div", { className: "pointer-events-none fixed bottom-4 right-4 z-50 flex w-[min(360px,calc(100vw-2rem))] flex-col gap-2" }, messages.map((message) => /* @__PURE__ */ React.createElement("div", { key: message.id, className: "pointer-events-auto" }, /* @__PURE__ */ React.createElement(
|
|
694
346
|
Alert,
|
|
@@ -699,90 +351,12 @@ function VaultRuntimeProvider({ children, manifest, i18n, runtimeContext: runtim
|
|
|
699
351
|
/* @__PURE__ */ React.createElement("button", { type: "button", className: "w-full text-left", onClick: () => dismissMessage(message.id) }, message.message)
|
|
700
352
|
)))));
|
|
701
353
|
}
|
|
702
|
-
function useFlapSdk() {
|
|
703
|
-
const sdk = useContext(RuntimeContext);
|
|
704
|
-
if (!sdk) throw new Error("useFlapSdk must be used within VaultRuntimeProvider.");
|
|
705
|
-
return sdk;
|
|
706
|
-
}
|
|
707
|
-
function useVaultContext() {
|
|
708
|
-
return useFlapSdk().context;
|
|
709
|
-
}
|
|
710
|
-
function useFlapI18n() {
|
|
711
|
-
return useFlapSdk().i18n;
|
|
712
|
-
}
|
|
713
|
-
function useFlapNotify() {
|
|
714
|
-
return useFlapSdk().notify;
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
// src/sdk/txError.ts
|
|
718
|
-
var defaultMessages = {
|
|
719
|
-
userRejected: "You rejected the wallet request.",
|
|
720
|
-
walletDisconnected: "Connect a wallet before sending this transaction.",
|
|
721
|
-
wrongNetwork: "Switch the wallet to the required chain before sending this transaction.",
|
|
722
|
-
insufficientFunds: "Insufficient wallet balance to complete this transaction.",
|
|
723
|
-
simulationFailed: "The transaction could not pass simulation.",
|
|
724
|
-
reverted: "The contract rejected this transaction.",
|
|
725
|
-
unknown: "Transaction failed. Please check your wallet and try again."
|
|
726
|
-
};
|
|
727
|
-
function isObject(value) {
|
|
728
|
-
return Boolean(value) && typeof value === "object";
|
|
729
|
-
}
|
|
730
|
-
function readString(value) {
|
|
731
|
-
return typeof value === "string" ? value : "";
|
|
732
|
-
}
|
|
733
|
-
function collectMessages(error, depth = 0, seen = /* @__PURE__ */ new Set()) {
|
|
734
|
-
if (depth > 4 || error == null || seen.has(error)) return [];
|
|
735
|
-
seen.add(error);
|
|
736
|
-
if (typeof error === "string") return [error];
|
|
737
|
-
if (!isObject(error)) return [];
|
|
738
|
-
const messages = [
|
|
739
|
-
readString(error.shortMessage),
|
|
740
|
-
readString(error.message),
|
|
741
|
-
readString(error.details),
|
|
742
|
-
readString(error.reason)
|
|
743
|
-
].filter(Boolean);
|
|
744
|
-
return [...messages, ...collectMessages(error.cause, depth + 1, seen)];
|
|
745
|
-
}
|
|
746
|
-
function collectCodes(error, depth = 0, seen = /* @__PURE__ */ new Set()) {
|
|
747
|
-
if (depth > 4 || error == null || seen.has(error)) return [];
|
|
748
|
-
seen.add(error);
|
|
749
|
-
if (!isObject(error)) return [];
|
|
750
|
-
const codes = [error.code, error.name].filter((value) => typeof value === "string" || typeof value === "number");
|
|
751
|
-
return [...codes, ...collectCodes(error.cause, depth + 1, seen)];
|
|
752
|
-
}
|
|
753
|
-
function getTxErrorKind(error) {
|
|
754
|
-
const message = collectMessages(error).join(" ").toLowerCase();
|
|
755
|
-
const codes = collectCodes(error).map((value) => String(value).toLowerCase()).join(" ");
|
|
756
|
-
if (codes.includes("4001") || codes.includes("action_rejected") || codes.includes("userrejectedrequesterror") || /user rejected|user denied|rejected the request|denied transaction|request rejected|cancelled/i.test(message)) {
|
|
757
|
-
return "userRejected";
|
|
758
|
-
}
|
|
759
|
-
if (/wallet is not connected|connector not connected|account not found|no wallet client/i.test(message)) {
|
|
760
|
-
return "walletDisconnected";
|
|
761
|
-
}
|
|
762
|
-
if (/wrong network|switch wallet to|switch network to|required chain/i.test(message)) {
|
|
763
|
-
return "wrongNetwork";
|
|
764
|
-
}
|
|
765
|
-
if (/insufficient funds|exceeds the balance|gas \* price \+ value/i.test(message)) {
|
|
766
|
-
return "insufficientFunds";
|
|
767
|
-
}
|
|
768
|
-
if (/simulation failed|simulatecontract|execution reverted during simulation/i.test(message)) {
|
|
769
|
-
return "simulationFailed";
|
|
770
|
-
}
|
|
771
|
-
if (/execution reverted|reverted with the following reason|contract function .* reverted|call exception/i.test(message)) {
|
|
772
|
-
return "reverted";
|
|
773
|
-
}
|
|
774
|
-
return "unknown";
|
|
775
|
-
}
|
|
776
|
-
function handleTxError(error, messages) {
|
|
777
|
-
const kind = getTxErrorKind(error);
|
|
778
|
-
return messages?.[kind] ?? defaultMessages[kind];
|
|
779
|
-
}
|
|
780
354
|
|
|
781
355
|
// src/sdk/useFlapWallet.ts
|
|
782
356
|
function useFlapWallet() {
|
|
783
357
|
return useFlapSdk().wallet;
|
|
784
358
|
}
|
|
785
359
|
|
|
786
|
-
export {
|
|
360
|
+
export { VaultRuntimeProvider, resolveMiniApp3DAssetUrl, resolveMiniApp3DDecoderUrls, useFlapWallet };
|
|
787
361
|
//# sourceMappingURL=sdk.js.map
|
|
788
362
|
//# sourceMappingURL=sdk.js.map
|