@flapsdk/vault-runtime 0.1.36-next.0 → 0.1.36
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/{chunk-FWYBGHBX.js → chunk-22KTLOYH.js} +4 -17
- package/chunk-22KTLOYH.js.map +1 -0
- package/chunk-AGLB72HK.js +61 -0
- package/chunk-AGLB72HK.js.map +1 -0
- package/{chunk-MLAOJT5Q.js → chunk-IN34R3DY.js} +494 -361
- package/chunk-IN34R3DY.js.map +1 -0
- package/{chunk-V7U4QTMT.js → chunk-QLVWFL4T.js} +164 -106
- package/chunk-QLVWFL4T.js.map +1 -0
- package/host-client.d.mts +2 -9
- package/host-client.js +3 -3
- package/host.d.mts +5 -5
- package/host.js +4 -4
- package/{hostRuntimeConfig-DibvcxHE.d.mts → hostRuntimeConfig-DAz-f577.d.mts} +1 -1
- package/{mpegts-J2J6JTD7.js → mpegts-536UQHCG.js} +6 -6
- package/{mpegts-J2J6JTD7.js.map → mpegts-536UQHCG.js.map} +1 -1
- package/package.json +3 -4
- package/runtime-contract.json +1 -2
- package/sdk.d.mts +4 -40
- package/sdk.js +6 -37
- package/sdk.js.map +1 -1
- package/server.d.mts +3 -3
- package/{txError-OBuRV8xN.d.mts → txError-DmiNOh9R.d.mts} +2 -15
- package/{types-DUZWZ3mC.d.mts → types-BbjEsfiD.d.mts} +4 -98
- package/ui.d.mts +1 -1
- package/ui.js +1 -1
- package/chunk-A3ER7XYN.js +0 -408
- package/chunk-A3ER7XYN.js.map +0 -1
- package/chunk-FWYBGHBX.js.map +0 -1
- package/chunk-MLAOJT5Q.js.map +0 -1
- package/chunk-V7U4QTMT.js.map +0 -1
|
@@ -1,20 +1,7 @@
|
|
|
1
1
|
import { erc20Abi } from 'viem';
|
|
2
2
|
export { erc20Abi } from 'viem';
|
|
3
3
|
|
|
4
|
-
// src/sdk/
|
|
5
|
-
var MINI_APP_SLUG_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
6
|
-
var RESERVED_SLUGS = /* @__PURE__ */ new Set(["api", "apps", "admin", "www", "app", "launch", "preview", "login", "settings"]);
|
|
7
|
-
function isMiniAppSlug(value) {
|
|
8
|
-
return typeof value === "string" && value.length >= 3 && value.length <= 64 && MINI_APP_SLUG_PATTERN.test(value) && !RESERVED_SLUGS.has(value);
|
|
9
|
-
}
|
|
10
|
-
function isStandaloneMiniApp(manifest) {
|
|
11
|
-
if (!manifest || typeof manifest !== "object") return false;
|
|
12
|
-
const value = manifest;
|
|
13
|
-
const match = value.match;
|
|
14
|
-
const chains = value.walletChains;
|
|
15
|
-
if (chains !== void 0 && (!Array.isArray(chains) || !chains.length || chains.length > 8 || chains.some((id) => !Number.isSafeInteger(id) || id <= 0) || new Set(chains).size !== chains.length)) return false;
|
|
16
|
-
return value.schemaVersion === 2 && value.mode === "mini-app" && value.appModel === "standalone" && isMiniAppSlug(value.slug) && typeof value.artifactId === "string" && Array.isArray(match?.bindings) && match.bindings.length === 0;
|
|
17
|
-
}
|
|
4
|
+
// src/sdk/erc20.ts
|
|
18
5
|
var standardErc20Abi = erc20Abi;
|
|
19
6
|
|
|
20
7
|
// src/sdk/txError.ts
|
|
@@ -81,6 +68,6 @@ function handleTxError(error, messages) {
|
|
|
81
68
|
return messages?.[kind] ?? defaultMessages[kind];
|
|
82
69
|
}
|
|
83
70
|
|
|
84
|
-
export {
|
|
85
|
-
//# sourceMappingURL=chunk-
|
|
86
|
-
//# sourceMappingURL=chunk-
|
|
71
|
+
export { getTxErrorKind, handleTxError, standardErc20Abi };
|
|
72
|
+
//# sourceMappingURL=chunk-22KTLOYH.js.map
|
|
73
|
+
//# sourceMappingURL=chunk-22KTLOYH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/sdk/erc20.ts","../../src/sdk/txError.ts"],"names":[],"mappings":";;;;AAGO,IAAM,gBAAA,GAAmB;;;ACChC,IAAM,eAAA,GAA+C;AAAA,EACnD,YAAA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A,CAAgE,IAAA,CAAK,OAAO,CAAA,EAAG;AACjF,IAAA,OAAO,mBAAA;AAAA,EACT;AAEA,EAAA,IAAI,0EAAA,CAA2E,IAAA,CAAK,OAAO,CAAA,EAAG;AAC5F,IAAA,OAAO,kBAAA;AAAA,EACT;AAEA,EAAA,IAAI,qGAAA,CAAsG,IAAA,CAAK,OAAO,CAAA,EAAG;AACvH,IAAA,OAAO,UAAA;AAAA,EACT;AAEA,EAAA,OAAO,SAAA;AACT;AAEO,SAAS,aAAA,CAAc,OAAgB,QAAA,EAA8B;AAC1E,EAAA,MAAM,IAAA,GAAO,eAAe,KAAK,CAAA;AACjC,EAAA,OAAO,QAAA,GAAW,IAAI,CAAA,IAAK,eAAA,CAAgB,IAAI,CAAA;AACjD","file":"chunk-22KTLOYH.js","sourcesContent":["import { erc20Abi } from \"viem\";\n\nexport { erc20Abi };\nexport const standardErc20Abi = erc20Abi;\n","export type TxErrorKind = \"userRejected\" | \"walletDisconnected\" | \"wrongNetwork\" | \"insufficientFunds\" | \"simulationFailed\" | \"reverted\" | \"unknown\";\n\ntype TxErrorMessageMap = Partial<Record<TxErrorKind, string>>;\n\nconst defaultMessages: Record<TxErrorKind, string> = {\n userRejected: \"You rejected the wallet request.\",\n walletDisconnected: \"Connect a wallet before sending this transaction.\",\n wrongNetwork: \"Switch the wallet to the required chain before sending this transaction.\",\n insufficientFunds: \"Insufficient wallet balance to complete this transaction.\",\n simulationFailed: \"The transaction could not pass simulation.\",\n reverted: \"The contract rejected this transaction.\",\n unknown: \"Transaction failed. Please check your wallet and try again.\",\n};\n\nfunction isObject(value: unknown): value is Record<string, unknown> {\n return Boolean(value) && typeof value === \"object\";\n}\n\nfunction readString(value: unknown) {\n return typeof value === \"string\" ? value : \"\";\n}\n\nfunction collectMessages(error: unknown, depth = 0, seen = new Set<unknown>()): string[] {\n if (depth > 4 || error == null || seen.has(error)) return [];\n seen.add(error);\n\n if (typeof error === \"string\") return [error];\n if (!isObject(error)) return [];\n\n const messages = [\n readString(error.shortMessage),\n readString(error.message),\n readString(error.details),\n readString(error.reason),\n ].filter(Boolean);\n\n return [...messages, ...collectMessages(error.cause, depth + 1, seen)];\n}\n\nfunction collectCodes(error: unknown, depth = 0, seen = new Set<unknown>()): Array<string | number> {\n if (depth > 4 || error == null || seen.has(error)) return [];\n seen.add(error);\n if (!isObject(error)) return [];\n\n const codes = [error.code, error.name].filter((value) => typeof value === \"string\" || typeof value === \"number\");\n return [...codes, ...collectCodes(error.cause, depth + 1, seen)];\n}\n\nexport function getTxErrorKind(error: unknown): TxErrorKind {\n const message = collectMessages(error).join(\" \").toLowerCase();\n const codes = collectCodes(error)\n .map((value: string | number) => String(value).toLowerCase())\n .join(\" \");\n\n if (\n codes.includes(\"4001\") ||\n codes.includes(\"action_rejected\") ||\n codes.includes(\"userrejectedrequesterror\") ||\n /user rejected|user denied|rejected the request|denied transaction|request rejected|cancelled/i.test(message)\n ) {\n return \"userRejected\";\n }\n\n if (/wallet is not connected|connector not connected|account not found|no wallet client/i.test(message)) {\n return \"walletDisconnected\";\n }\n\n if (/wrong network|switch wallet to|switch network to|required chain/i.test(message)) {\n return \"wrongNetwork\";\n }\n\n if (/insufficient funds|exceeds the balance|gas \\* price \\+ value/i.test(message)) {\n return \"insufficientFunds\";\n }\n\n if (/simulation failed|simulatecontract|execution reverted during simulation/i.test(message)) {\n return \"simulationFailed\";\n }\n\n if (/execution reverted|reverted with the following reason|contract function .* reverted|call exception/i.test(message)) {\n return \"reverted\";\n }\n\n return \"unknown\";\n}\n\nexport function handleTxError(error: unknown, messages?: TxErrorMessageMap) {\n const kind = getTxErrorKind(error);\n return messages?.[kind] ?? defaultMessages[kind];\n}\n"]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { resolveManifestBinding } from './chunk-B4WKI3EW.js';
|
|
2
|
+
|
|
3
|
+
// src/sdk/runtimeContext.ts
|
|
4
|
+
var zeroAddress = "0x0000000000000000000000000000000000000000";
|
|
5
|
+
function explorerForChain(chainId) {
|
|
6
|
+
if (chainId === 56) return "https://bscscan.com";
|
|
7
|
+
if (chainId === 97) return "https://testnet.bscscan.com";
|
|
8
|
+
if (chainId === 4663) return "https://robinhoodchain.blockscout.com";
|
|
9
|
+
if (chainId === 46630) return "https://explorer.testnet.chain.robinhood.com";
|
|
10
|
+
return void 0;
|
|
11
|
+
}
|
|
12
|
+
function chainLabelForChain(chainId) {
|
|
13
|
+
if (chainId === 56) return "BNB Chain";
|
|
14
|
+
if (chainId === 97) return "BNB Testnet";
|
|
15
|
+
if (chainId === 4663) return "Robinhood Chain";
|
|
16
|
+
if (chainId === 46630) return "Robinhood Chain Testnet";
|
|
17
|
+
return `Chain ${chainId}`;
|
|
18
|
+
}
|
|
19
|
+
function buildRuntimeExtraConfig(input) {
|
|
20
|
+
const hostRuntimeResult = input.hostRuntimeResult;
|
|
21
|
+
const runtimeOverrides = input.runtimeOverrides;
|
|
22
|
+
return {
|
|
23
|
+
...hostRuntimeResult ? {
|
|
24
|
+
hostRuntimeStatus: hostRuntimeResult.status,
|
|
25
|
+
hostRuntimePolicy: hostRuntimeResult.policy,
|
|
26
|
+
hostRuntimeDegradeReason: hostRuntimeResult.degradeReason,
|
|
27
|
+
hostRuntimeWarnings: hostRuntimeResult.warnings
|
|
28
|
+
} : {},
|
|
29
|
+
...hostRuntimeResult?.presentation?.extraConfig ?? {},
|
|
30
|
+
...runtimeOverrides?.extraConfig ?? {}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function createVaultRuntimeContext(input) {
|
|
34
|
+
const runtimeOverrides = input.runtimeOverrides;
|
|
35
|
+
const resolvedBinding = resolveManifestBinding(input.manifest, {
|
|
36
|
+
chainId: runtimeOverrides?.chainId ?? input.connectedChainId ?? input.hostRuntimeResult?.addresses.chainId,
|
|
37
|
+
factoryAddress: runtimeOverrides?.factoryAddress ?? input.hostRuntimeResult?.addresses.factoryAddress,
|
|
38
|
+
vaultAddress: runtimeOverrides?.vaultAddress ?? input.hostRuntimeResult?.addresses.vaultAddress,
|
|
39
|
+
tokenAddress: runtimeOverrides?.tokenAddress ?? input.hostRuntimeResult?.addresses.tokenAddress
|
|
40
|
+
});
|
|
41
|
+
const effectiveChainId = runtimeOverrides?.chainId ?? input.hostRuntimeResult?.addresses.chainId ?? input.connectedChainId ?? resolvedBinding?.chainId ?? input.manifest.match.bindings[0]?.chainId ?? 56;
|
|
42
|
+
return {
|
|
43
|
+
chainId: effectiveChainId,
|
|
44
|
+
factoryAddress: runtimeOverrides?.factoryAddress ?? input.hostRuntimeResult?.addresses.factoryAddress ?? resolvedBinding?.factoryAddress ?? zeroAddress,
|
|
45
|
+
tokenAddress: runtimeOverrides?.tokenAddress ?? input.hostRuntimeResult?.addresses.tokenAddress ?? zeroAddress,
|
|
46
|
+
vaultAddress: runtimeOverrides?.vaultAddress ?? input.hostRuntimeResult?.addresses.vaultAddress ?? zeroAddress,
|
|
47
|
+
userAddress: runtimeOverrides?.userAddress,
|
|
48
|
+
tokenSymbol: runtimeOverrides?.tokenSymbol ?? input.hostRuntimeResult?.tokenSymbol,
|
|
49
|
+
tokenName: runtimeOverrides?.tokenName ?? input.hostRuntimeResult?.tokenName,
|
|
50
|
+
tokenImageUrl: runtimeOverrides?.tokenImageUrl ?? input.hostRuntimeResult?.tokenImageUrl,
|
|
51
|
+
explorerBaseUrl: runtimeOverrides?.explorerBaseUrl ?? explorerForChain(effectiveChainId),
|
|
52
|
+
paymentToken: runtimeOverrides?.paymentToken ?? input.hostRuntimeResult?.paymentToken,
|
|
53
|
+
host: runtimeOverrides?.host ?? input.hostRuntimeResult?.host,
|
|
54
|
+
extraConfig: buildRuntimeExtraConfig(input),
|
|
55
|
+
manifest: input.manifest
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { chainLabelForChain, createVaultRuntimeContext, explorerForChain };
|
|
60
|
+
//# sourceMappingURL=chunk-AGLB72HK.js.map
|
|
61
|
+
//# sourceMappingURL=chunk-AGLB72HK.js.map
|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A,IACnE,aAAA,EAAe,gBAAA,EAAkB,aAAA,IAAiB,KAAA,CAAM,iBAAA,EAAmB,aAAA;AAAA,IAC3E,eAAA,EAAiB,gBAAA,EAAkB,eAAA,IAAmB,gBAAA,CAAiB,gBAAgB,CAAA;AAAA,IACvF,YAAA,EAAc,gBAAA,EAAkB,YAAA,IAAgB,KAAA,CAAM,iBAAA,EAAmB,YAAA;AAAA,IACzE,IAAA,EAAM,gBAAA,EAAkB,IAAA,IAAQ,KAAA,CAAM,iBAAA,EAAmB,IAAA;AAAA,IACzD,WAAA,EAAa,wBAAwB,KAAK,CAAA;AAAA,IAC1C,UAAU,KAAA,CAAM;AAAA,GAClB;AACF","file":"chunk-AGLB72HK.js","sourcesContent":["import { resolveManifestBinding } from \"./taxInfo\";\nimport type { Address, CreateVaultRuntimeContextInput, VaultRuntimeContext, VaultRuntimeExtraConfig } from \"./types\";\n\nconst zeroAddress = \"0x0000000000000000000000000000000000000000\" as Address;\n\nexport function explorerForChain(chainId: number) {\n if (chainId === 56) return \"https://bscscan.com\";\n if (chainId === 97) return \"https://testnet.bscscan.com\";\n if (chainId === 4663) return \"https://robinhoodchain.blockscout.com\";\n if (chainId === 46630) return \"https://explorer.testnet.chain.robinhood.com\";\n return undefined;\n}\n\nexport function chainLabelForChain(chainId: number) {\n if (chainId === 56) return \"BNB Chain\";\n if (chainId === 97) return \"BNB Testnet\";\n if (chainId === 4663) return \"Robinhood Chain\";\n if (chainId === 46630) return \"Robinhood Chain Testnet\";\n return `Chain ${chainId}`;\n}\n\nfunction buildRuntimeExtraConfig(input: CreateVaultRuntimeContextInput): VaultRuntimeExtraConfig {\n const hostRuntimeResult = input.hostRuntimeResult;\n const runtimeOverrides = input.runtimeOverrides;\n\n return {\n ...(hostRuntimeResult\n ? {\n hostRuntimeStatus: hostRuntimeResult.status,\n hostRuntimePolicy: hostRuntimeResult.policy,\n hostRuntimeDegradeReason: hostRuntimeResult.degradeReason,\n hostRuntimeWarnings: hostRuntimeResult.warnings,\n }\n : {}),\n ...(hostRuntimeResult?.presentation?.extraConfig ?? {}),\n ...(runtimeOverrides?.extraConfig ?? {}),\n };\n}\n\nexport function createVaultRuntimeContext(input: CreateVaultRuntimeContextInput): VaultRuntimeContext {\n const runtimeOverrides = input.runtimeOverrides;\n const resolvedBinding = resolveManifestBinding(input.manifest, {\n chainId: runtimeOverrides?.chainId ?? input.connectedChainId ?? input.hostRuntimeResult?.addresses.chainId,\n factoryAddress: runtimeOverrides?.factoryAddress ?? input.hostRuntimeResult?.addresses.factoryAddress,\n vaultAddress: runtimeOverrides?.vaultAddress ?? input.hostRuntimeResult?.addresses.vaultAddress,\n tokenAddress: runtimeOverrides?.tokenAddress ?? input.hostRuntimeResult?.addresses.tokenAddress,\n });\n const effectiveChainId =\n runtimeOverrides?.chainId ?? input.hostRuntimeResult?.addresses.chainId ?? input.connectedChainId ?? resolvedBinding?.chainId ?? input.manifest.match.bindings[0]?.chainId ?? 56;\n\n return {\n chainId: effectiveChainId,\n factoryAddress: runtimeOverrides?.factoryAddress ?? input.hostRuntimeResult?.addresses.factoryAddress ?? resolvedBinding?.factoryAddress ?? zeroAddress,\n tokenAddress: runtimeOverrides?.tokenAddress ?? input.hostRuntimeResult?.addresses.tokenAddress ?? zeroAddress,\n vaultAddress: runtimeOverrides?.vaultAddress ?? input.hostRuntimeResult?.addresses.vaultAddress ?? zeroAddress,\n userAddress: runtimeOverrides?.userAddress,\n tokenSymbol: runtimeOverrides?.tokenSymbol ?? input.hostRuntimeResult?.tokenSymbol,\n tokenName: runtimeOverrides?.tokenName ?? input.hostRuntimeResult?.tokenName,\n tokenImageUrl: runtimeOverrides?.tokenImageUrl ?? input.hostRuntimeResult?.tokenImageUrl,\n explorerBaseUrl: runtimeOverrides?.explorerBaseUrl ?? explorerForChain(effectiveChainId),\n paymentToken: runtimeOverrides?.paymentToken ?? input.hostRuntimeResult?.paymentToken,\n host: runtimeOverrides?.host ?? input.hostRuntimeResult?.host,\n extraConfig: buildRuntimeExtraConfig(input),\n manifest: input.manifest,\n };\n}\n"]}
|