@flapsdk/vault-runtime 0.1.23 → 0.1.25
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 +64 -11
- package/sdk.js +103 -509
- 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-XMLOEthr.d.mts → txError-BEercCCG.d.mts} +1 -1
- package/{types-BO7AzXbw.d.mts → types-RxLUOC02.d.mts} +29 -1
- package/ui.d.mts +13 -2
- package/ui.js +3 -522
- package/ui.js.map +1 -1
- package/hostRuntimeConfig-B9Od3Mc7.d.mts +0 -14
package/sdk.js
CHANGED
|
@@ -1,443 +1,53 @@
|
|
|
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
|
+
import { formatUnits } from 'viem';
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
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);
|
|
16
|
+
// src/sdk/three.ts
|
|
17
|
+
function assertArtifactAssetUrl(assetUrl, moduleUrl) {
|
|
18
|
+
const moduleLocation = new URL(moduleUrl);
|
|
19
|
+
const asset = new URL(assetUrl, moduleLocation);
|
|
20
|
+
const moduleDirectory = moduleLocation.pathname.slice(0, moduleLocation.pathname.lastIndexOf("/") + 1);
|
|
21
|
+
if (asset.origin !== moduleLocation.origin || !asset.pathname.startsWith(`${moduleDirectory}assets/`)) {
|
|
22
|
+
throw new Error("Mini App 3D assets must resolve from the current artifact assets/ manifest.");
|
|
123
23
|
}
|
|
24
|
+
return asset.href;
|
|
124
25
|
}
|
|
125
|
-
function
|
|
126
|
-
return
|
|
26
|
+
function resolveMiniApp3DAssetUrl(assetUrl, moduleUrl) {
|
|
27
|
+
return assertArtifactAssetUrl(assetUrl, moduleUrl);
|
|
127
28
|
}
|
|
128
|
-
function
|
|
129
|
-
const filteredParams = provision.allowedParams && provision.allowedParams.length ? Object.fromEntries(Object.entries(params ?? {}).filter(([key]) => provision.allowedParams?.includes(key))) : params;
|
|
29
|
+
function resolveMiniApp3DDecoderUrls(urls, moduleUrl) {
|
|
130
30
|
return {
|
|
131
|
-
...
|
|
132
|
-
...
|
|
31
|
+
...urls.draco ? { draco: assertArtifactAssetUrl(urls.draco, moduleUrl) } : {},
|
|
32
|
+
...urls.ktx2 ? { ktx2: assertArtifactAssetUrl(urls.ktx2, moduleUrl) } : {}
|
|
133
33
|
};
|
|
134
34
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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);
|
|
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));
|
|
155
42
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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
|
-
}
|
|
184
|
-
function cn(...inputs) {
|
|
185
|
-
return twMerge(clsx(inputs));
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// src/ui/Alert.tsx
|
|
189
|
-
var toneClass = {
|
|
190
|
-
info: "border-[#303236] bg-black text-[#D4D4D4]",
|
|
191
|
-
success: "border-[#D0FF00]/45 bg-[#101400] text-[#D0FF00]",
|
|
192
|
-
warning: "border-[#FFD166]/45 bg-[#1A1305] text-[#FFD166]",
|
|
193
|
-
danger: "border-[#FF4A55]/55 bg-[#1D0709] text-[#FF8A91]"
|
|
194
|
-
};
|
|
195
|
-
var iconMap = {
|
|
196
|
-
info: Info,
|
|
197
|
-
success: CheckCircle2,
|
|
198
|
-
warning: AlertTriangle,
|
|
199
|
-
danger: AlertTriangle
|
|
200
|
-
};
|
|
201
|
-
function Alert({ children, tone = "info", className }) {
|
|
202
|
-
const Icon = iconMap[tone];
|
|
203
|
-
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));
|
|
204
|
-
}
|
|
205
|
-
var buttonVariants = cva(
|
|
206
|
-
"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",
|
|
207
|
-
{
|
|
208
|
-
variants: {
|
|
209
|
-
variant: {
|
|
210
|
-
default: "ui20-connect-chamfer text-[#070808] [--ui20-chamfer-bg:#D0FF00] [--ui20-chamfer-border:#D0FF00] hover:[--ui20-chamfer-bg:#BDE800] hover:[--ui20-chamfer-border:#BDE800]",
|
|
211
|
-
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]",
|
|
212
|
-
outline: "ui20-connect-chamfer text-[#D4D4D4] [--ui20-chamfer-bg:#000000] [--ui20-chamfer-border:#303236] hover:text-[#D0FF00] hover:[--ui20-chamfer-border:#D0FF00]",
|
|
213
|
-
ghost: "rounded-[6px] text-[#D4D4D4] hover:bg-[#131516] hover:text-[#D0FF00]",
|
|
214
|
-
destructive: "ui20-connect-chamfer text-[#FF4A55] [--ui20-chamfer-bg:#000000] [--ui20-chamfer-border:#FF4A55] hover:text-black hover:[--ui20-chamfer-bg:#FF4A55]"
|
|
215
|
-
},
|
|
216
|
-
size: {
|
|
217
|
-
default: "h-10 px-4",
|
|
218
|
-
sm: "h-8 px-3 text-xs",
|
|
219
|
-
lg: "h-12 px-5",
|
|
220
|
-
icon: "h-10 w-10 px-0"
|
|
221
|
-
}
|
|
222
|
-
},
|
|
223
|
-
defaultVariants: {
|
|
224
|
-
variant: "default",
|
|
225
|
-
size: "default"
|
|
226
|
-
}
|
|
43
|
+
activeNftMetadataReads += 1;
|
|
44
|
+
try {
|
|
45
|
+
return await task();
|
|
46
|
+
} finally {
|
|
47
|
+
activeNftMetadataReads -= 1;
|
|
48
|
+
pendingNftMetadataReads.shift()?.();
|
|
227
49
|
}
|
|
228
|
-
);
|
|
229
|
-
var Button = React3.forwardRef(
|
|
230
|
-
({ className, variant, size, asChild = false, loading = false, disabled, children, ...props }, ref) => {
|
|
231
|
-
const Comp = asChild ? Slot : "button";
|
|
232
|
-
if (asChild) {
|
|
233
|
-
return /* @__PURE__ */ React3.createElement(Comp, { "data-flap-ui": "button", className: cn(buttonVariants({ variant, size, className })), ref, ...props }, children);
|
|
234
|
-
}
|
|
235
|
-
return /* @__PURE__ */ React3.createElement(
|
|
236
|
-
Comp,
|
|
237
|
-
{
|
|
238
|
-
"data-flap-ui": "button",
|
|
239
|
-
className: cn(buttonVariants({ variant, size, className })),
|
|
240
|
-
ref,
|
|
241
|
-
disabled: disabled || loading,
|
|
242
|
-
...props
|
|
243
|
-
},
|
|
244
|
-
loading ? /* @__PURE__ */ React3.createElement(Loader2, { className: "relative z-10 h-4 w-4 animate-spin" }) : null,
|
|
245
|
-
/* @__PURE__ */ React3.createElement("span", { className: "relative z-10 inline-flex min-w-0 items-center justify-center gap-2" }, children)
|
|
246
|
-
);
|
|
247
|
-
}
|
|
248
|
-
);
|
|
249
|
-
Button.displayName = "Button";
|
|
250
|
-
var Card = React3.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React3.createElement(
|
|
251
|
-
"div",
|
|
252
|
-
{
|
|
253
|
-
"data-flap-ui": "card",
|
|
254
|
-
ref,
|
|
255
|
-
className: cn(
|
|
256
|
-
"rounded-[8px] border border-[#303236] bg-[#070808] text-white shadow-[0_18px_60px_-42px_rgba(208,255,0,0.45)]",
|
|
257
|
-
className
|
|
258
|
-
),
|
|
259
|
-
...props
|
|
260
|
-
}
|
|
261
|
-
));
|
|
262
|
-
Card.displayName = "Card";
|
|
263
|
-
var CardHeader = React3.forwardRef(
|
|
264
|
-
({ 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 })
|
|
265
|
-
);
|
|
266
|
-
CardHeader.displayName = "CardHeader";
|
|
267
|
-
var CardTitle = React3.forwardRef(
|
|
268
|
-
({ 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 })
|
|
269
|
-
);
|
|
270
|
-
CardTitle.displayName = "CardTitle";
|
|
271
|
-
var CardDescription = React3.forwardRef(
|
|
272
|
-
({ className, ...props }, ref) => /* @__PURE__ */ React3.createElement("p", { "data-flap-ui": "card-description", ref, className: cn("text-sm leading-6 text-[#84888C]", className), ...props })
|
|
273
|
-
);
|
|
274
|
-
CardDescription.displayName = "CardDescription";
|
|
275
|
-
var CardContent = React3.forwardRef(
|
|
276
|
-
({ 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 })
|
|
277
|
-
);
|
|
278
|
-
CardContent.displayName = "CardContent";
|
|
279
|
-
var Input = React3.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React3.createElement(
|
|
280
|
-
"input",
|
|
281
|
-
{
|
|
282
|
-
"data-flap-ui": "input",
|
|
283
|
-
ref,
|
|
284
|
-
className: cn(
|
|
285
|
-
"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",
|
|
286
|
-
className
|
|
287
|
-
),
|
|
288
|
-
...props
|
|
289
|
-
}
|
|
290
|
-
));
|
|
291
|
-
Input.displayName = "Input";
|
|
292
|
-
|
|
293
|
-
// src/sdk/taxInfo.ts
|
|
294
|
-
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
295
|
-
function isValidAddress(value) {
|
|
296
|
-
return Boolean(value && /^0x[a-fA-F0-9]{40}$/.test(value));
|
|
297
|
-
}
|
|
298
|
-
function isSameAddress(a, b) {
|
|
299
|
-
return Boolean(a && b && a.toLowerCase() === b.toLowerCase());
|
|
300
|
-
}
|
|
301
|
-
function resolveManifestBinding(manifest, input) {
|
|
302
|
-
const bindings = manifest.match.bindings;
|
|
303
|
-
if (!bindings.length) return null;
|
|
304
|
-
const resolveUnique = (candidates) => {
|
|
305
|
-
if (candidates.length === 1) return candidates[0];
|
|
306
|
-
return null;
|
|
307
|
-
};
|
|
308
|
-
const matchesChain = (binding) => !input.chainId || binding.chainId === input.chainId;
|
|
309
|
-
const matchesToken = (binding) => !input.tokenAddress || !binding.tokenAddresses?.length || binding.tokenAddresses.some((address) => isSameAddress(address, input.tokenAddress));
|
|
310
|
-
const isVaultScopedBinding = (binding) => !binding.factoryAddress && Boolean(binding.vaultAddresses?.length);
|
|
311
|
-
const isTokenScopedBinding = (binding) => !binding.factoryAddress && !binding.vaultAddresses?.length && Boolean(binding.tokenAddresses?.length);
|
|
312
|
-
if (input.factoryAddress) {
|
|
313
|
-
const factoryMatch = resolveUnique(
|
|
314
|
-
bindings.filter((binding) => matchesChain(binding) && Boolean(binding.factoryAddress) && isSameAddress(binding.factoryAddress, input.factoryAddress) && matchesToken(binding))
|
|
315
|
-
);
|
|
316
|
-
if (factoryMatch) return factoryMatch;
|
|
317
|
-
if (!input.vaultAddress && !input.tokenAddress) return null;
|
|
318
|
-
}
|
|
319
|
-
if (input.vaultAddress) {
|
|
320
|
-
const vaultMatch = resolveUnique(
|
|
321
|
-
bindings.filter(
|
|
322
|
-
(binding) => matchesChain(binding) && isVaultScopedBinding(binding) && Boolean(binding.vaultAddresses?.some((address) => isSameAddress(address, input.vaultAddress))) && matchesToken(binding)
|
|
323
|
-
)
|
|
324
|
-
);
|
|
325
|
-
if (vaultMatch) return vaultMatch;
|
|
326
|
-
}
|
|
327
|
-
if (input.tokenAddress) {
|
|
328
|
-
const tokenMatch = resolveUnique(
|
|
329
|
-
bindings.filter(
|
|
330
|
-
(binding) => matchesChain(binding) && isTokenScopedBinding(binding) && Boolean(binding.tokenAddresses?.some((address) => isSameAddress(address, input.tokenAddress)))
|
|
331
|
-
)
|
|
332
|
-
);
|
|
333
|
-
if (tokenMatch) return tokenMatch;
|
|
334
|
-
}
|
|
335
|
-
if (input.factoryAddress || input.vaultAddress) {
|
|
336
|
-
return null;
|
|
337
|
-
}
|
|
338
|
-
if (input.chainId && input.tokenAddress) {
|
|
339
|
-
const tokenScopedMatch = resolveUnique(bindings.filter((binding) => binding.chainId === input.chainId && binding.tokenAddresses?.some((address) => isSameAddress(address, input.tokenAddress))));
|
|
340
|
-
if (tokenScopedMatch) return tokenScopedMatch;
|
|
341
|
-
}
|
|
342
|
-
if (input.tokenAddress) {
|
|
343
|
-
return resolveUnique(bindings.filter((binding) => binding.tokenAddresses?.some((address) => isSameAddress(address, input.tokenAddress))));
|
|
344
|
-
}
|
|
345
|
-
if (input.chainId) {
|
|
346
|
-
return resolveUnique(bindings.filter((binding) => binding.chainId === input.chainId && matchesToken(binding)));
|
|
347
|
-
}
|
|
348
|
-
return null;
|
|
349
|
-
}
|
|
350
|
-
function resolveTokenMarketPhase(tokenInfo) {
|
|
351
|
-
if (!tokenInfo?.exists) return "unknown";
|
|
352
|
-
return tokenInfo.status >= 2 ? "dex-listed" : "internal-market";
|
|
353
50
|
}
|
|
354
|
-
function isCustomVaultTaxToken(tokenInfo) {
|
|
355
|
-
return Boolean(tokenInfo?.exists && tokenInfo.isTaxToken);
|
|
356
|
-
}
|
|
357
|
-
function isActionAvailableForPhase(stage, marketPhase = "unknown") {
|
|
358
|
-
if (stage === "read-only") return false;
|
|
359
|
-
if (stage === "both") return true;
|
|
360
|
-
if (marketPhase === "unknown") return false;
|
|
361
|
-
return stage === marketPhase;
|
|
362
|
-
}
|
|
363
|
-
function readTaxVaultHostContext(host) {
|
|
364
|
-
const tokenInfo = host?.tokenInfo;
|
|
365
|
-
const marketPhase = host?.marketPhase ?? resolveTokenMarketPhase(tokenInfo);
|
|
366
|
-
const isListed = host?.isListed ?? Boolean(tokenInfo && tokenInfo.status >= 2);
|
|
367
|
-
const isTaxToken = tokenInfo?.isTaxToken === true;
|
|
368
|
-
return {
|
|
369
|
-
tokenInfo,
|
|
370
|
-
taxInfo: host?.taxInfo ?? null,
|
|
371
|
-
vaultInfo: host?.vaultInfo ?? null,
|
|
372
|
-
feeMode: host?.feeMode ?? "unknown",
|
|
373
|
-
renderSurface: host?.renderSurface ?? "unavailable",
|
|
374
|
-
vaultType: host?.vaultType,
|
|
375
|
-
copyScope: host?.copyScope ?? "tax",
|
|
376
|
-
marketPhase,
|
|
377
|
-
isListed,
|
|
378
|
-
isTaxToken,
|
|
379
|
-
isSupportedCustomVaultToken: isCustomVaultTaxToken(tokenInfo)
|
|
380
|
-
};
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
// src/sdk/runtimeContext.ts
|
|
384
|
-
var zeroAddress = "0x0000000000000000000000000000000000000000";
|
|
385
|
-
function explorerForChain(chainId) {
|
|
386
|
-
if (chainId === 56) return "https://bscscan.com";
|
|
387
|
-
if (chainId === 97) return "https://testnet.bscscan.com";
|
|
388
|
-
if (chainId === 4663) return "https://robinhoodchain.blockscout.com";
|
|
389
|
-
if (chainId === 46630) return "https://explorer.testnet.chain.robinhood.com";
|
|
390
|
-
return void 0;
|
|
391
|
-
}
|
|
392
|
-
function chainLabelForChain(chainId) {
|
|
393
|
-
if (chainId === 56) return "BNB Chain";
|
|
394
|
-
if (chainId === 97) return "BNB Testnet";
|
|
395
|
-
if (chainId === 4663) return "Robinhood Chain";
|
|
396
|
-
if (chainId === 46630) return "Robinhood Chain Testnet";
|
|
397
|
-
return `Chain ${chainId}`;
|
|
398
|
-
}
|
|
399
|
-
function buildRuntimeExtraConfig(input) {
|
|
400
|
-
const hostRuntimeResult = input.hostRuntimeResult;
|
|
401
|
-
const runtimeOverrides = input.runtimeOverrides;
|
|
402
|
-
return {
|
|
403
|
-
...hostRuntimeResult ? {
|
|
404
|
-
hostRuntimeStatus: hostRuntimeResult.status,
|
|
405
|
-
hostRuntimePolicy: hostRuntimeResult.policy,
|
|
406
|
-
hostRuntimeDegradeReason: hostRuntimeResult.degradeReason,
|
|
407
|
-
hostRuntimeWarnings: hostRuntimeResult.warnings
|
|
408
|
-
} : {},
|
|
409
|
-
...hostRuntimeResult?.presentation?.extraConfig ?? {},
|
|
410
|
-
...runtimeOverrides?.extraConfig ?? {}
|
|
411
|
-
};
|
|
412
|
-
}
|
|
413
|
-
function createVaultRuntimeContext(input) {
|
|
414
|
-
const runtimeOverrides = input.runtimeOverrides;
|
|
415
|
-
const resolvedBinding = resolveManifestBinding(input.manifest, {
|
|
416
|
-
chainId: runtimeOverrides?.chainId ?? input.connectedChainId ?? input.hostRuntimeResult?.addresses.chainId,
|
|
417
|
-
factoryAddress: runtimeOverrides?.factoryAddress ?? input.hostRuntimeResult?.addresses.factoryAddress,
|
|
418
|
-
vaultAddress: runtimeOverrides?.vaultAddress ?? input.hostRuntimeResult?.addresses.vaultAddress,
|
|
419
|
-
tokenAddress: runtimeOverrides?.tokenAddress ?? input.hostRuntimeResult?.addresses.tokenAddress
|
|
420
|
-
});
|
|
421
|
-
const effectiveChainId = runtimeOverrides?.chainId ?? input.hostRuntimeResult?.addresses.chainId ?? input.connectedChainId ?? resolvedBinding?.chainId ?? input.manifest.match.bindings[0]?.chainId ?? 56;
|
|
422
|
-
return {
|
|
423
|
-
chainId: effectiveChainId,
|
|
424
|
-
factoryAddress: runtimeOverrides?.factoryAddress ?? input.hostRuntimeResult?.addresses.factoryAddress ?? resolvedBinding?.factoryAddress ?? zeroAddress,
|
|
425
|
-
tokenAddress: runtimeOverrides?.tokenAddress ?? input.hostRuntimeResult?.addresses.tokenAddress ?? zeroAddress,
|
|
426
|
-
vaultAddress: runtimeOverrides?.vaultAddress ?? input.hostRuntimeResult?.addresses.vaultAddress ?? zeroAddress,
|
|
427
|
-
userAddress: runtimeOverrides?.userAddress,
|
|
428
|
-
tokenSymbol: runtimeOverrides?.tokenSymbol ?? input.hostRuntimeResult?.tokenSymbol,
|
|
429
|
-
tokenName: runtimeOverrides?.tokenName ?? input.hostRuntimeResult?.tokenName,
|
|
430
|
-
tokenImageUrl: runtimeOverrides?.tokenImageUrl ?? input.hostRuntimeResult?.tokenImageUrl,
|
|
431
|
-
explorerBaseUrl: runtimeOverrides?.explorerBaseUrl ?? explorerForChain(effectiveChainId),
|
|
432
|
-
paymentToken: runtimeOverrides?.paymentToken ?? input.hostRuntimeResult?.paymentToken,
|
|
433
|
-
host: runtimeOverrides?.host ?? input.hostRuntimeResult?.host,
|
|
434
|
-
extraConfig: buildRuntimeExtraConfig(input),
|
|
435
|
-
manifest: input.manifest
|
|
436
|
-
};
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
// src/sdk/runtime.tsx
|
|
440
|
-
var RuntimeContext = createContext(null);
|
|
441
51
|
function applyParams(value, params) {
|
|
442
52
|
if (!params) return value;
|
|
443
53
|
return Object.entries(params).reduce((acc, [key, item]) => acc.replaceAll(`{${key}}`, String(item)), value);
|
|
@@ -448,10 +58,12 @@ function getPreviewOracleEndpoint(extraConfig, oracleId) {
|
|
|
448
58
|
const endpoint = oracleEndpoints[oracleId];
|
|
449
59
|
return typeof endpoint === "string" ? endpoint : void 0;
|
|
450
60
|
}
|
|
451
|
-
function VaultRuntimeProvider({ children, manifest, i18n, runtimeContext: runtimeOverrides, hostRuntimeResult, locale = "en", oracleReader }) {
|
|
61
|
+
function VaultRuntimeProvider({ children, manifest, i18n, runtimeContext: runtimeOverrides, hostRuntimeResult, locale = "en", oracleReader, nftMetadataReader }) {
|
|
452
62
|
const [version, setVersion] = useState(0);
|
|
453
63
|
const [messages, setMessages] = useState([]);
|
|
454
64
|
const toastTimersRef = useRef(/* @__PURE__ */ new Map());
|
|
65
|
+
const nftMetadataCacheRef = useRef(/* @__PURE__ */ new Map());
|
|
66
|
+
const vaultNftAddressCacheRef = useRef(/* @__PURE__ */ new Map());
|
|
455
67
|
const { address: accountAddress, isConnected } = useAccount();
|
|
456
68
|
const connectedChainId = useChainId();
|
|
457
69
|
const { connect, connectors } = useConnect();
|
|
@@ -643,6 +255,65 @@ function VaultRuntimeProvider({ children, manifest, i18n, runtimeContext: runtim
|
|
|
643
255
|
},
|
|
644
256
|
[oracleReader, runtimeContext]
|
|
645
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
|
+
);
|
|
646
317
|
const refetch = useCallback(async () => {
|
|
647
318
|
setVersion((item) => item + 1);
|
|
648
319
|
}, []);
|
|
@@ -664,11 +335,12 @@ function VaultRuntimeProvider({ children, manifest, i18n, runtimeContext: runtim
|
|
|
664
335
|
writeContract,
|
|
665
336
|
waitForTx,
|
|
666
337
|
readOracle,
|
|
338
|
+
readNftMetadata,
|
|
667
339
|
refetch,
|
|
668
340
|
refetchNonce: version,
|
|
669
341
|
openExplorerTx
|
|
670
342
|
}),
|
|
671
|
-
[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]
|
|
672
344
|
);
|
|
673
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(
|
|
674
346
|
Alert,
|
|
@@ -679,90 +351,12 @@ function VaultRuntimeProvider({ children, manifest, i18n, runtimeContext: runtim
|
|
|
679
351
|
/* @__PURE__ */ React.createElement("button", { type: "button", className: "w-full text-left", onClick: () => dismissMessage(message.id) }, message.message)
|
|
680
352
|
)))));
|
|
681
353
|
}
|
|
682
|
-
function useFlapSdk() {
|
|
683
|
-
const sdk = useContext(RuntimeContext);
|
|
684
|
-
if (!sdk) throw new Error("useFlapSdk must be used within VaultRuntimeProvider.");
|
|
685
|
-
return sdk;
|
|
686
|
-
}
|
|
687
|
-
function useVaultContext() {
|
|
688
|
-
return useFlapSdk().context;
|
|
689
|
-
}
|
|
690
|
-
function useFlapI18n() {
|
|
691
|
-
return useFlapSdk().i18n;
|
|
692
|
-
}
|
|
693
|
-
function useFlapNotify() {
|
|
694
|
-
return useFlapSdk().notify;
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
// src/sdk/txError.ts
|
|
698
|
-
var defaultMessages = {
|
|
699
|
-
userRejected: "You rejected the wallet request.",
|
|
700
|
-
walletDisconnected: "Connect a wallet before sending this transaction.",
|
|
701
|
-
wrongNetwork: "Switch the wallet to the required chain before sending this transaction.",
|
|
702
|
-
insufficientFunds: "Insufficient wallet balance to complete this transaction.",
|
|
703
|
-
simulationFailed: "The transaction could not pass simulation.",
|
|
704
|
-
reverted: "The contract rejected this transaction.",
|
|
705
|
-
unknown: "Transaction failed. Please check your wallet and try again."
|
|
706
|
-
};
|
|
707
|
-
function isObject(value) {
|
|
708
|
-
return Boolean(value) && typeof value === "object";
|
|
709
|
-
}
|
|
710
|
-
function readString(value) {
|
|
711
|
-
return typeof value === "string" ? value : "";
|
|
712
|
-
}
|
|
713
|
-
function collectMessages(error, depth = 0, seen = /* @__PURE__ */ new Set()) {
|
|
714
|
-
if (depth > 4 || error == null || seen.has(error)) return [];
|
|
715
|
-
seen.add(error);
|
|
716
|
-
if (typeof error === "string") return [error];
|
|
717
|
-
if (!isObject(error)) return [];
|
|
718
|
-
const messages = [
|
|
719
|
-
readString(error.shortMessage),
|
|
720
|
-
readString(error.message),
|
|
721
|
-
readString(error.details),
|
|
722
|
-
readString(error.reason)
|
|
723
|
-
].filter(Boolean);
|
|
724
|
-
return [...messages, ...collectMessages(error.cause, depth + 1, seen)];
|
|
725
|
-
}
|
|
726
|
-
function collectCodes(error, depth = 0, seen = /* @__PURE__ */ new Set()) {
|
|
727
|
-
if (depth > 4 || error == null || seen.has(error)) return [];
|
|
728
|
-
seen.add(error);
|
|
729
|
-
if (!isObject(error)) return [];
|
|
730
|
-
const codes = [error.code, error.name].filter((value) => typeof value === "string" || typeof value === "number");
|
|
731
|
-
return [...codes, ...collectCodes(error.cause, depth + 1, seen)];
|
|
732
|
-
}
|
|
733
|
-
function getTxErrorKind(error) {
|
|
734
|
-
const message = collectMessages(error).join(" ").toLowerCase();
|
|
735
|
-
const codes = collectCodes(error).map((value) => String(value).toLowerCase()).join(" ");
|
|
736
|
-
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)) {
|
|
737
|
-
return "userRejected";
|
|
738
|
-
}
|
|
739
|
-
if (/wallet is not connected|connector not connected|account not found|no wallet client/i.test(message)) {
|
|
740
|
-
return "walletDisconnected";
|
|
741
|
-
}
|
|
742
|
-
if (/wrong network|switch wallet to|switch network to|required chain/i.test(message)) {
|
|
743
|
-
return "wrongNetwork";
|
|
744
|
-
}
|
|
745
|
-
if (/insufficient funds|exceeds the balance|gas \* price \+ value/i.test(message)) {
|
|
746
|
-
return "insufficientFunds";
|
|
747
|
-
}
|
|
748
|
-
if (/simulation failed|simulatecontract|execution reverted during simulation/i.test(message)) {
|
|
749
|
-
return "simulationFailed";
|
|
750
|
-
}
|
|
751
|
-
if (/execution reverted|reverted with the following reason|contract function .* reverted|call exception/i.test(message)) {
|
|
752
|
-
return "reverted";
|
|
753
|
-
}
|
|
754
|
-
return "unknown";
|
|
755
|
-
}
|
|
756
|
-
function handleTxError(error, messages) {
|
|
757
|
-
const kind = getTxErrorKind(error);
|
|
758
|
-
return messages?.[kind] ?? defaultMessages[kind];
|
|
759
|
-
}
|
|
760
354
|
|
|
761
355
|
// src/sdk/useFlapWallet.ts
|
|
762
356
|
function useFlapWallet() {
|
|
763
357
|
return useFlapSdk().wallet;
|
|
764
358
|
}
|
|
765
359
|
|
|
766
|
-
export {
|
|
360
|
+
export { VaultRuntimeProvider, resolveMiniApp3DAssetUrl, resolveMiniApp3DDecoderUrls, useFlapWallet };
|
|
767
361
|
//# sourceMappingURL=sdk.js.map
|
|
768
362
|
//# sourceMappingURL=sdk.js.map
|