@masterpeach/launchpad-sdk 0.0.0-experimental-20260818121657
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 +262 -0
- package/README.zh-CN.md +242 -0
- package/dist/abi/index.cjs +2786 -0
- package/dist/abi/index.cjs.map +1 -0
- package/dist/abi/index.d.cts +2121 -0
- package/dist/abi/index.d.ts +2121 -0
- package/dist/abi/index.js +19 -0
- package/dist/abi/index.js.map +1 -0
- package/dist/chunk-PGZCTPUB.js +127 -0
- package/dist/chunk-PGZCTPUB.js.map +1 -0
- package/dist/chunk-SH2Y5F5L.js +2754 -0
- package/dist/chunk-SH2Y5F5L.js.map +1 -0
- package/dist/core.cjs +163 -0
- package/dist/core.cjs.map +1 -0
- package/dist/core.d.cts +48 -0
- package/dist/core.d.ts +48 -0
- package/dist/core.js +27 -0
- package/dist/core.js.map +1 -0
- package/dist/index.cjs +4420 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1273 -0
- package/dist/index.d.ts +1273 -0
- package/dist/index.js +1840 -0
- package/dist/index.js.map +1 -0
- package/dist/transaction-BiLcoXyx.d.cts +13 -0
- package/dist/transaction-BiLcoXyx.d.ts +13 -0
- package/package.json +81 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
constantProductCurveAbi,
|
|
3
|
+
launchTokenAbi,
|
|
4
|
+
launchpadAbiArtifactCommit,
|
|
5
|
+
liquidityLockerAbi,
|
|
6
|
+
portalAbi,
|
|
7
|
+
tokenFactoryAbi,
|
|
8
|
+
v3MigratorAbi
|
|
9
|
+
} from "../chunk-SH2Y5F5L.js";
|
|
10
|
+
export {
|
|
11
|
+
constantProductCurveAbi,
|
|
12
|
+
launchTokenAbi,
|
|
13
|
+
launchpadAbiArtifactCommit,
|
|
14
|
+
liquidityLockerAbi,
|
|
15
|
+
portalAbi,
|
|
16
|
+
tokenFactoryAbi,
|
|
17
|
+
v3MigratorAbi
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// ../core/src/amount.ts
|
|
2
|
+
import { formatUnits, parseUnits } from "viem";
|
|
3
|
+
|
|
4
|
+
// ../core/src/errors.ts
|
|
5
|
+
import { UserRejectedRequestError } from "viem";
|
|
6
|
+
var PEACH_SDK_ERROR_BRAND = /* @__PURE__ */ Symbol.for("masterpeach.sdk-core.PeachSdkError");
|
|
7
|
+
var PeachSdkError = class extends Error {
|
|
8
|
+
code;
|
|
9
|
+
metadata;
|
|
10
|
+
constructor(code, message, options = {}) {
|
|
11
|
+
super(message, { cause: options.cause });
|
|
12
|
+
this.name = "PeachSdkError";
|
|
13
|
+
this.code = code;
|
|
14
|
+
this.metadata = options.metadata ?? {};
|
|
15
|
+
Object.defineProperty(this, PEACH_SDK_ERROR_BRAND, { value: true });
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
var UnsupportedChainError = class extends PeachSdkError {
|
|
19
|
+
constructor(chainId) {
|
|
20
|
+
super("UNSUPPORTED_CHAIN", `Unsupported chain: ${chainId}`, {
|
|
21
|
+
metadata: { chainId }
|
|
22
|
+
});
|
|
23
|
+
this.name = "UnsupportedChainError";
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
var MissingChainError = class extends PeachSdkError {
|
|
27
|
+
constructor() {
|
|
28
|
+
super("MISSING_CHAIN", "A chain ID is required for this operation.");
|
|
29
|
+
this.name = "MissingChainError";
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
var MissingAccountError = class extends PeachSdkError {
|
|
33
|
+
constructor() {
|
|
34
|
+
super("MISSING_ACCOUNT", "A wallet account is required for this operation.");
|
|
35
|
+
this.name = "MissingAccountError";
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
function isPeachSdkError(value, code) {
|
|
39
|
+
if (typeof value !== "object" || value === null) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
if (value[PEACH_SDK_ERROR_BRAND] !== true) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
return code === void 0 || value.code === code;
|
|
46
|
+
}
|
|
47
|
+
function toPeachSdkError(error) {
|
|
48
|
+
if (isPeachSdkError(error)) {
|
|
49
|
+
return error;
|
|
50
|
+
}
|
|
51
|
+
if (error instanceof UserRejectedRequestError) {
|
|
52
|
+
return new PeachSdkError("USER_REJECTED", "The wallet request was rejected.", {
|
|
53
|
+
cause: error
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return new PeachSdkError("UNKNOWN_ERROR", "An unknown SDK error occurred.", {
|
|
57
|
+
cause: error
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// ../core/src/amount.ts
|
|
62
|
+
var DECIMAL_AMOUNT_PATTERN = /^(0|[1-9]\d*)(\.\d+)?$/;
|
|
63
|
+
function assertDecimals(decimals) {
|
|
64
|
+
if (!Number.isInteger(decimals) || decimals < 0 || decimals > 255) {
|
|
65
|
+
throw new PeachSdkError("INVALID_AMOUNT", `Invalid decimals: ${decimals}`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function parseAmount(value, decimals) {
|
|
69
|
+
assertDecimals(decimals);
|
|
70
|
+
if (!DECIMAL_AMOUNT_PATTERN.test(value)) {
|
|
71
|
+
throw new PeachSdkError("INVALID_AMOUNT", `Invalid decimal amount: ${value}`);
|
|
72
|
+
}
|
|
73
|
+
const fraction = value.split(".")[1] ?? "";
|
|
74
|
+
if (fraction.length > decimals) {
|
|
75
|
+
throw new PeachSdkError(
|
|
76
|
+
"INVALID_AMOUNT",
|
|
77
|
+
`Amount has ${fraction.length} decimal places but token supports ${decimals}.`
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
return parseUnits(value, decimals);
|
|
81
|
+
}
|
|
82
|
+
function formatAmount(value, decimals) {
|
|
83
|
+
assertDecimals(decimals);
|
|
84
|
+
if (value < 0n) {
|
|
85
|
+
throw new PeachSdkError("INVALID_AMOUNT", "Token amounts cannot be negative.");
|
|
86
|
+
}
|
|
87
|
+
return formatUnits(value, decimals);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// ../core/src/chain.ts
|
|
91
|
+
function resolveChainValue(registry, chainId) {
|
|
92
|
+
const value = registry[chainId];
|
|
93
|
+
if (value === void 0) {
|
|
94
|
+
throw new UnsupportedChainError(chainId);
|
|
95
|
+
}
|
|
96
|
+
return value;
|
|
97
|
+
}
|
|
98
|
+
function requireWalletClient(walletClient) {
|
|
99
|
+
if (!walletClient?.account) {
|
|
100
|
+
throw new MissingAccountError();
|
|
101
|
+
}
|
|
102
|
+
return walletClient;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// ../core/src/transaction.ts
|
|
106
|
+
function transactionResultFromReceipt(receipt) {
|
|
107
|
+
return {
|
|
108
|
+
hash: receipt.transactionHash,
|
|
109
|
+
status: receipt.status === "success" ? "confirmed" : "reverted",
|
|
110
|
+
receipt
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export {
|
|
115
|
+
PeachSdkError,
|
|
116
|
+
UnsupportedChainError,
|
|
117
|
+
MissingChainError,
|
|
118
|
+
MissingAccountError,
|
|
119
|
+
isPeachSdkError,
|
|
120
|
+
toPeachSdkError,
|
|
121
|
+
parseAmount,
|
|
122
|
+
formatAmount,
|
|
123
|
+
resolveChainValue,
|
|
124
|
+
requireWalletClient,
|
|
125
|
+
transactionResultFromReceipt
|
|
126
|
+
};
|
|
127
|
+
//# sourceMappingURL=chunk-PGZCTPUB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../core/src/amount.ts","../../core/src/errors.ts","../../core/src/chain.ts","../../core/src/transaction.ts"],"sourcesContent":["import { formatUnits, parseUnits } from \"viem\";\n\nimport { PeachSdkError } from \"./errors\";\n\nconst DECIMAL_AMOUNT_PATTERN = /^(0|[1-9]\\d*)(\\.\\d+)?$/;\n\nfunction assertDecimals(decimals: number): void {\n if (!Number.isInteger(decimals) || decimals < 0 || decimals > 255) {\n throw new PeachSdkError(\"INVALID_AMOUNT\", `Invalid decimals: ${decimals}`);\n }\n}\n\n/** Parses a canonical unsigned decimal token amount into integer base units. */\nexport function parseAmount(value: string, decimals: number): bigint {\n assertDecimals(decimals);\n\n if (!DECIMAL_AMOUNT_PATTERN.test(value)) {\n throw new PeachSdkError(\"INVALID_AMOUNT\", `Invalid decimal amount: ${value}`);\n }\n\n const fraction = value.split(\".\")[1] ?? \"\";\n if (fraction.length > decimals) {\n throw new PeachSdkError(\n \"INVALID_AMOUNT\",\n `Amount has ${fraction.length} decimal places but token supports ${decimals}.`,\n );\n }\n\n return parseUnits(value, decimals);\n}\n\n/** Formats an unsigned base-unit token amount without introducing floating-point rounding. */\nexport function formatAmount(value: bigint, decimals: number): string {\n assertDecimals(decimals);\n\n if (value < 0n) {\n throw new PeachSdkError(\"INVALID_AMOUNT\", \"Token amounts cannot be negative.\");\n }\n\n return formatUnits(value, decimals);\n}\n","import { UserRejectedRequestError } from \"viem\";\n\nexport type PeachSdkErrorCode =\n | \"INVALID_AMOUNT\"\n | \"MISSING_ACCOUNT\"\n | \"MISSING_CHAIN\"\n | \"UNSUPPORTED_CHAIN\"\n | \"USER_REJECTED\"\n | \"TRANSPORT_ERROR\"\n | \"CONTRACT_ERROR\"\n | \"UNKNOWN_ERROR\";\n\n/**\n * Cross-copy brand for shared SDK errors.\n *\n * Every product SDK bundles its own copy of these primitives, so an error thrown by\n * `@masterpeach/launchpad-sdk` is not an `instanceof` the class of the same name exported by\n * `@masterpeach/lending-sdk`. `Symbol.for` resolves through the runtime-wide symbol registry, so\n * each copy brands its errors with the identical key and can recognize the others'.\n */\nconst PEACH_SDK_ERROR_BRAND = Symbol.for(\"masterpeach.sdk-core.PeachSdkError\");\n\n/** Base error carrying a stable machine-readable code and structured diagnostic metadata. */\nexport class PeachSdkError extends Error {\n readonly code: PeachSdkErrorCode;\n readonly metadata: Readonly<Record<string, unknown>>;\n\n constructor(\n code: PeachSdkErrorCode,\n message: string,\n options: { cause?: unknown; metadata?: Readonly<Record<string, unknown>> } = {},\n ) {\n super(message, { cause: options.cause });\n this.name = \"PeachSdkError\";\n this.code = code;\n this.metadata = options.metadata ?? {};\n // Non-enumerable so the brand stays out of structured clones and JSON diagnostics.\n Object.defineProperty(this, PEACH_SDK_ERROR_BRAND, { value: true });\n }\n}\n\nexport class UnsupportedChainError extends PeachSdkError {\n constructor(chainId: number) {\n super(\"UNSUPPORTED_CHAIN\", `Unsupported chain: ${chainId}`, {\n metadata: { chainId },\n });\n this.name = \"UnsupportedChainError\";\n }\n}\n\nexport class MissingChainError extends PeachSdkError {\n constructor() {\n super(\"MISSING_CHAIN\", \"A chain ID is required for this operation.\");\n this.name = \"MissingChainError\";\n }\n}\n\nexport class MissingAccountError extends PeachSdkError {\n constructor() {\n super(\"MISSING_ACCOUNT\", \"A wallet account is required for this operation.\");\n this.name = \"MissingAccountError\";\n }\n}\n\n/**\n * Recognizes a shared SDK error regardless of which product SDK created it.\n *\n * Prefer this over `instanceof PeachSdkError` whenever an application depends on more than one\n * MasterPeach SDK: each package carries its own copy of the class, so `instanceof` only matches\n * errors that happened to originate from the same package. Pass a `code` to narrow in one step.\n */\nexport function isPeachSdkError(value: unknown): value is PeachSdkError;\nexport function isPeachSdkError<TCode extends PeachSdkErrorCode>(\n value: unknown,\n code: TCode,\n): value is PeachSdkError & { readonly code: TCode };\nexport function isPeachSdkError(value: unknown, code?: PeachSdkErrorCode): boolean {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n if ((value as Record<symbol, unknown>)[PEACH_SDK_ERROR_BRAND] !== true) {\n return false;\n }\n return code === undefined || (value as PeachSdkError).code === code;\n}\n\n/** Normalizes wallet rejection and unknown failures at a shared SDK boundary. */\nexport function toPeachSdkError(error: unknown): PeachSdkError {\n // Brand check rather than `instanceof`, so an error raised by a sibling SDK keeps its code\n // instead of being flattened into UNKNOWN_ERROR.\n if (isPeachSdkError(error)) {\n return error;\n }\n\n if (error instanceof UserRejectedRequestError) {\n return new PeachSdkError(\"USER_REJECTED\", \"The wallet request was rejected.\", {\n cause: error,\n });\n }\n\n return new PeachSdkError(\"UNKNOWN_ERROR\", \"An unknown SDK error occurred.\", {\n cause: error,\n });\n}\n","import type { WalletClient } from \"viem\";\n\nimport { MissingAccountError, UnsupportedChainError } from \"./errors\";\n\nexport type ChainRegistry<T> = Readonly<Record<number, T>>;\n\n/** Resolves a chain-scoped configuration value or throws a stable unsupported-chain error. */\nexport function resolveChainValue<T>(registry: ChainRegistry<T>, chainId: number): T {\n const value = registry[chainId];\n if (value === undefined) {\n throw new UnsupportedChainError(chainId);\n }\n return value;\n}\n\n/** Requires a Wallet Client with an attached account before a signing or write operation. */\nexport function requireWalletClient(walletClient: WalletClient | undefined): WalletClient {\n if (!walletClient?.account) {\n throw new MissingAccountError();\n }\n return walletClient;\n}\n","import type { Hash, TransactionReceipt } from \"viem\";\n\nexport type SdkTransactionStatus = \"pending\" | \"confirmed\" | \"reverted\";\n\n/** Framework-neutral transaction result shared by product SDK packages. */\nexport interface SdkTransactionResult {\n readonly hash: Hash;\n readonly status: SdkTransactionStatus;\n readonly receipt?: TransactionReceipt;\n}\n\n/** Converts a Viem receipt into the stable shared transaction result shape. */\nexport function transactionResultFromReceipt(receipt: TransactionReceipt): SdkTransactionResult {\n return {\n hash: receipt.transactionHash,\n status: receipt.status === \"success\" ? \"confirmed\" : \"reverted\",\n receipt,\n };\n}\n"],"mappings":";AAAA,SAAS,aAAa,kBAAkB;;;ACAxC,SAAS,gCAAgC;AAoBzC,IAAM,wBAAwB,uBAAO,IAAI,oCAAoC;AAGtE,IAAM,gBAAN,cAA4B,MAAM;AAAA,EAC9B;AAAA,EACA;AAAA,EAET,YACE,MACA,SACA,UAA6E,CAAC,GAC9E;AACA,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