@secondlayer/stacks 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/shared/{stacks-shh3gp0x.js → stacks-43cxvnr7.js} +4 -3
- package/dist/shared/{stacks-shh3gp0x.js.map → stacks-43cxvnr7.js.map} +3 -3
- package/dist/shared/{stacks-9a0xebgq.cjs → stacks-vk8fwz0t.cjs} +4 -2
- package/dist/shared/{stacks-9a0xebgq.cjs.map → stacks-vk8fwz0t.cjs.map} +3 -3
- package/dist/src/bns/index.js +1 -1
- package/dist/src/clarity/index.d.cts +6 -2
- package/dist/src/clarity/index.d.ts +6 -2
- package/dist/src/clarity/index.js +4 -2
- package/dist/src/clarity/index.js.map +1 -1
- package/dist/src/index.cjs.map +4 -4
- package/dist/src/index.d.cts +4 -4
- package/dist/src/index.d.ts +4 -4
- package/dist/src/index.js.map +4 -4
- package/dist/src/tools/index.cjs +1 -1
- package/dist/src/tools/index.cjs.map +3 -3
- package/dist/src/tools/index.js +1 -1
- package/dist/src/tools/index.js.map +3 -3
- package/package.json +1 -1
|
@@ -291,6 +291,7 @@ function validateArgsArray(func, args) {
|
|
|
291
291
|
});
|
|
292
292
|
}
|
|
293
293
|
// src/clarity/abi/classify.ts
|
|
294
|
+
var TRAIT_STANDARDS = ["sip-009", "sip-010", "sip-013"];
|
|
294
295
|
var STANDARDS = [
|
|
295
296
|
{ id: "sip-010", abi: SIP010_ABI, optional: new Set(["get-token-uri"]) },
|
|
296
297
|
{ id: "sip-009", abi: SIP009_ABI, optional: new Set(["get-token-uri"]) },
|
|
@@ -347,7 +348,7 @@ function parseDeclaredStandards(claritySource) {
|
|
|
347
348
|
}
|
|
348
349
|
return [...out];
|
|
349
350
|
}
|
|
350
|
-
export { prettyPrint, cvToJSON, cvToValue, ClarityConversionError, jsToClarity, prepareArgs, validateArgs, validateArgsArray, classifyContract, parseDeclaredStandards };
|
|
351
|
+
export { prettyPrint, cvToJSON, cvToValue, ClarityConversionError, jsToClarity, prepareArgs, validateArgs, validateArgsArray, TRAIT_STANDARDS, classifyContract, parseDeclaredStandards };
|
|
351
352
|
|
|
352
|
-
//# debugId=
|
|
353
|
-
//# sourceMappingURL=stacks-
|
|
353
|
+
//# debugId=68302998D73CE86F64756E2164756E21
|
|
354
|
+
//# sourceMappingURL=stacks-43cxvnr7.js.map
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import {\n\tasciiToBytes,\n\tbytesToAscii,\n\thexToBytes,\n\tutf8ToBytes,\n} from \"../utils/encoding.ts\";\nimport type { ClarityValue } from \"./types.ts\";\n\nexport function prettyPrint(\n\tval: ClarityValue,\n\tencoding: \"tryAscii\" | \"hex\" = \"hex\",\n): string | undefined {\n\tswitch (val.type) {\n\t\tcase \"true\":\n\t\t\treturn \"true\";\n\t\tcase \"false\":\n\t\t\treturn \"false\";\n\t\tcase \"int\":\n\t\t\treturn val.value.toString();\n\t\tcase \"uint\":\n\t\t\treturn `u${val.value.toString()}`;\n\t\tcase \"buffer\":\n\t\t\tif (encoding === \"tryAscii\") {\n\t\t\t\tconst str = bytesToAscii(hexToBytes(val.value));\n\t\t\t\tif (/^[ -~]*$/.test(str)) return JSON.stringify(str);\n\t\t\t}\n\t\t\treturn `0x${val.value}`;\n\t\tcase \"none\":\n\t\t\treturn \"none\";\n\t\tcase \"some\":\n\t\t\treturn `(some ${prettyPrint(val.value, encoding)})`;\n\t\tcase \"ok\":\n\t\t\treturn `(ok ${prettyPrint(val.value, encoding)})`;\n\t\tcase \"err\":\n\t\t\treturn `(err ${prettyPrint(val.value, encoding)})`;\n\t\tcase \"address\":\n\t\tcase \"contract\":\n\t\t\treturn val.value;\n\t\tcase \"list\":\n\t\t\treturn `(list ${val.value.map((v) => prettyPrint(v, encoding)).join(\" \")})`;\n\t\tcase \"tuple\":\n\t\t\treturn `(tuple ${Object.keys(val.value)\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\t\t\t.map((key) => `(${key} ${prettyPrint(val.value[key]!, encoding)})`)\n\t\t\t\t.join(\" \")})`;\n\t\tcase \"ascii\":\n\t\t\treturn `\"${val.value}\"`;\n\t\tcase \"utf8\":\n\t\t\treturn `u\"${val.value}\"`;\n\t}\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\nexport function cvToJSON(val: ClarityValue): any {\n\tswitch (val.type) {\n\t\tcase \"true\":\n\t\t\treturn { type: \"bool\", value: true };\n\t\tcase \"false\":\n\t\t\treturn { type: \"bool\", value: false };\n\t\tcase \"int\":\n\t\t\treturn { type: \"int\", value: val.value.toString() };\n\t\tcase \"uint\":\n\t\t\treturn { type: \"uint\", value: val.value.toString() };\n\t\tcase \"buffer\":\n\t\t\treturn {\n\t\t\t\ttype: `(buff ${Math.ceil(val.value.length / 2)})`,\n\t\t\t\tvalue: `0x${val.value}`,\n\t\t\t};\n\t\tcase \"none\":\n\t\t\treturn { type: \"(optional none)\", value: null };\n\t\tcase \"some\":\n\t\t\treturn { type: \"(optional)\", value: cvToJSON(val.value) };\n\t\tcase \"ok\":\n\t\t\treturn { type: \"(response)\", value: cvToJSON(val.value), success: true };\n\t\tcase \"err\":\n\t\t\treturn { type: \"(response)\", value: cvToJSON(val.value), success: false };\n\t\tcase \"address\":\n\t\tcase \"contract\":\n\t\t\treturn { type: \"principal\", value: val.value };\n\t\tcase \"list\":\n\t\t\treturn { type: \"(list)\", value: val.value.map(cvToJSON) };\n\t\tcase \"tuple\": {\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\t\tconst result: Record<string, any> = {};\n\t\t\tfor (const key of Object.keys(val.value)) {\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\t\t\tresult[key] = cvToJSON(val.value[key]!);\n\t\t\t}\n\t\t\treturn { type: \"(tuple)\", value: result };\n\t\t}\n\t\tcase \"ascii\":\n\t\t\treturn {\n\t\t\t\ttype: `(string-ascii ${asciiToBytes(val.value).length})`,\n\t\t\t\tvalue: val.value,\n\t\t\t};\n\t\tcase \"utf8\":\n\t\t\treturn {\n\t\t\t\ttype: `(string-utf8 ${utf8ToBytes(val.value).length})`,\n\t\t\t\tvalue: val.value,\n\t\t\t};\n\t}\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\nexport function cvToValue(val: ClarityValue): any {\n\tswitch (val.type) {\n\t\tcase \"true\":\n\t\t\treturn true;\n\t\tcase \"false\":\n\t\t\treturn false;\n\t\tcase \"int\":\n\t\tcase \"uint\":\n\t\t\treturn val.value;\n\t\tcase \"buffer\":\n\t\t\treturn `0x${val.value}`;\n\t\tcase \"none\":\n\t\t\treturn null;\n\t\tcase \"some\":\n\t\t\treturn cvToValue(val.value);\n\t\tcase \"ok\":\n\t\tcase \"err\":\n\t\t\treturn cvToValue(val.value);\n\t\tcase \"address\":\n\t\tcase \"contract\":\n\t\t\treturn val.value;\n\t\tcase \"list\":\n\t\t\treturn val.value.map(cvToValue);\n\t\tcase \"tuple\": {\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\t\tconst result: Record<string, any> = {};\n\t\t\tfor (const key of Object.keys(val.value)) {\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\t\t\tresult[key] = cvToValue(val.value[key]!);\n\t\t\t}\n\t\t\treturn result;\n\t\t}\n\t\tcase \"ascii\":\n\t\tcase \"utf8\":\n\t\t\treturn val.value;\n\t}\n}\n",
|
|
6
6
|
"import type { AbiFunction } from \"./contract.ts\";\nimport {\n\tisAbiBuffer,\n\tisAbiList,\n\tisAbiOptional,\n\tisAbiResponse,\n\tisAbiStringAscii,\n\tisAbiStringUtf8,\n\tisAbiTuple,\n\tisBool,\n\tisInt128,\n\tisPrincipal,\n\tisString,\n\tisUint8Array,\n\tisUint128,\n} from \"./guards.ts\";\nimport type { AbiType } from \"./types.ts\";\nimport { toCamelCase } from \"./utils.ts\";\n\nexport class ClarityConversionError extends Error {\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic readonly type: AbiType,\n\t\tpublic readonly value: unknown,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"ClarityConversionError\";\n\t}\n}\n\nexport function jsToClarity(type: AbiType, value: unknown): unknown {\n\tif (type === \"none\") return null;\n\n\tif (type === \"uint128\") {\n\t\tif (!isUint128(value))\n\t\t\tthrow new ClarityConversionError(\"Invalid uint128 value\", type, value);\n\t\treturn value;\n\t}\n\n\tif (type === \"int128\") {\n\t\tif (!isInt128(value))\n\t\t\tthrow new ClarityConversionError(\"Invalid int128 value\", type, value);\n\t\treturn value;\n\t}\n\n\tif (type === \"bool\") {\n\t\tif (!isBool(value))\n\t\t\tthrow new ClarityConversionError(\"Invalid bool value\", type, value);\n\t\treturn value;\n\t}\n\n\tif (type === \"principal\") {\n\t\tif (!isPrincipal(value))\n\t\t\tthrow new ClarityConversionError(\"Invalid principal value\", type, value);\n\t\treturn value;\n\t}\n\n\tif (type === \"trait_reference\") {\n\t\tif (!isPrincipal(value))\n\t\t\tthrow new ClarityConversionError(\n\t\t\t\t\"Invalid trait_reference value\",\n\t\t\t\ttype,\n\t\t\t\tvalue,\n\t\t\t);\n\t\treturn value;\n\t}\n\n\tif (isAbiStringAscii(type)) {\n\t\tif (!isString(value))\n\t\t\tthrow new ClarityConversionError(\n\t\t\t\t\"Invalid string-ascii value\",\n\t\t\t\ttype,\n\t\t\t\tvalue,\n\t\t\t);\n\t\tconst str = value as string;\n\t\tfor (let i = 0; i < str.length; i++) {\n\t\t\tif (str.charCodeAt(i) > 127) {\n\t\t\t\tthrow new ClarityConversionError(\n\t\t\t\t\t`Non-ASCII character at position ${i}: '${str[i]}' (code ${str.charCodeAt(i)})`,\n\t\t\t\t\ttype,\n\t\t\t\t\tvalue,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tif (str.length > type[\"string-ascii\"].length) {\n\t\t\tthrow new ClarityConversionError(\n\t\t\t\t`String length ${str.length} exceeds max ${type[\"string-ascii\"].length}`,\n\t\t\t\ttype,\n\t\t\t\tvalue,\n\t\t\t);\n\t\t}\n\t\treturn value;\n\t}\n\n\tif (isAbiStringUtf8(type)) {\n\t\tif (!isString(value))\n\t\t\tthrow new ClarityConversionError(\n\t\t\t\t\"Invalid string-utf8 value\",\n\t\t\t\ttype,\n\t\t\t\tvalue,\n\t\t\t);\n\t\tconst str = value as string;\n\t\tconst byteLength = new TextEncoder().encode(str).length;\n\t\tif (byteLength > type[\"string-utf8\"].length) {\n\t\t\tthrow new ClarityConversionError(\n\t\t\t\t`String byte length ${byteLength} exceeds max ${type[\"string-utf8\"].length}`,\n\t\t\t\ttype,\n\t\t\t\tvalue,\n\t\t\t);\n\t\t}\n\t\treturn value;\n\t}\n\n\tif (isAbiBuffer(type)) {\n\t\tif (!isUint8Array(value))\n\t\t\tthrow new ClarityConversionError(\"Invalid buffer value\", type, value);\n\t\tconst buff = value as Uint8Array;\n\t\tif (buff.length > type.buff.length) {\n\t\t\tthrow new ClarityConversionError(\n\t\t\t\t`Buffer length ${buff.length} exceeds max ${type.buff.length}`,\n\t\t\t\ttype,\n\t\t\t\tvalue,\n\t\t\t);\n\t\t}\n\t\treturn value;\n\t}\n\n\tif (isAbiList(type)) {\n\t\tif (!Array.isArray(value))\n\t\t\tthrow new ClarityConversionError(\n\t\t\t\t\"Expected array for list type\",\n\t\t\t\ttype,\n\t\t\t\tvalue,\n\t\t\t);\n\t\tif (value.length > type.list.length) {\n\t\t\tthrow new ClarityConversionError(\n\t\t\t\t`List length ${value.length} exceeds max ${type.list.length}`,\n\t\t\t\ttype,\n\t\t\t\tvalue,\n\t\t\t);\n\t\t}\n\t\treturn value.map((item) => jsToClarity(type.list.type, item));\n\t}\n\n\tif (isAbiTuple(type)) {\n\t\tif (typeof value !== \"object\" || value === null)\n\t\t\tthrow new ClarityConversionError(\n\t\t\t\t\"Expected object for tuple type\",\n\t\t\t\ttype,\n\t\t\t\tvalue,\n\t\t\t);\n\t\tconst result: Record<string, unknown> = {};\n\t\tfor (const field of type.tuple) {\n\t\t\tconst camelKey = toCamelCase(field.name);\n\t\t\tconst hasOriginal = field.name in (value as object);\n\t\t\tconst hasCamel = camelKey in (value as object);\n\t\t\tif (!hasOriginal && !hasCamel) {\n\t\t\t\tthrow new ClarityConversionError(\n\t\t\t\t\t`Missing tuple field: ${field.name}`,\n\t\t\t\t\ttype,\n\t\t\t\t\tvalue,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst fieldValue = hasOriginal\n\t\t\t\t? (value as Record<string, unknown>)[field.name]\n\t\t\t\t: (value as Record<string, unknown>)[camelKey];\n\t\t\tresult[field.name] = jsToClarity(field.type, fieldValue);\n\t\t}\n\t\treturn result;\n\t}\n\n\tif (isAbiOptional(type)) {\n\t\tif (value === null || value === undefined) return null;\n\t\treturn jsToClarity(type.optional, value);\n\t}\n\n\tif (isAbiResponse(type)) {\n\t\tif (typeof value !== \"object\" || value === null)\n\t\t\tthrow new ClarityConversionError(\n\t\t\t\t\"Expected object for response type\",\n\t\t\t\ttype,\n\t\t\t\tvalue,\n\t\t\t);\n\t\tconst hasOk = \"ok\" in value;\n\t\tconst hasErr = \"err\" in value;\n\t\tif (hasOk && !hasErr) {\n\t\t\treturn {\n\t\t\t\tok: jsToClarity(type.response.ok, (value as { ok: unknown }).ok),\n\t\t\t};\n\t\t}\n\t\tif (hasErr && !hasOk) {\n\t\t\treturn {\n\t\t\t\terr: jsToClarity(type.response.error, (value as { err: unknown }).err),\n\t\t\t};\n\t\t}\n\t\tthrow new ClarityConversionError(\n\t\t\t\"Response must have exactly 'ok' or 'err' property\",\n\t\t\ttype,\n\t\t\tvalue,\n\t\t);\n\t}\n\n\tthrow new ClarityConversionError(\"Unknown Clarity type\", type, value);\n}\n\nexport function prepareArgs<F extends AbiFunction>(\n\tfunc: F,\n\targs: Record<string, unknown>,\n): unknown[] {\n\treturn func.args.map((arg) => {\n\t\tif (!(arg.name in args)) {\n\t\t\tthrow new ClarityConversionError(\n\t\t\t\t`Missing argument: ${arg.name}`,\n\t\t\t\targ.type,\n\t\t\t\tundefined,\n\t\t\t);\n\t\t}\n\t\treturn jsToClarity(arg.type, args[arg.name]);\n\t});\n}\n\nexport function validateArgs<F extends AbiFunction>(\n\tfunc: F,\n\targs: Record<string, unknown>,\n): void {\n\tfor (const arg of func.args) {\n\t\tif (!(arg.name in args)) {\n\t\t\tthrow new ClarityConversionError(\n\t\t\t\t`Missing argument: ${arg.name}`,\n\t\t\t\targ.type,\n\t\t\t\tundefined,\n\t\t\t);\n\t\t}\n\t\tjsToClarity(arg.type, args[arg.name]);\n\t}\n}\n\nexport function validateArgsArray<F extends AbiFunction>(\n\tfunc: F,\n\targs: unknown[],\n): void {\n\tif (args.length !== func.args.length) {\n\t\tthrow new ClarityConversionError(\n\t\t\t`Expected ${func.args.length} arguments, got ${args.length}`,\n\t\t\tfunc.args[0]?.type ?? \"bool\",\n\t\t\targs,\n\t\t);\n\t}\n\tfunc.args.forEach((arg, i) => {\n\t\tjsToClarity(arg.type, args[i]);\n\t});\n}\n",
|
|
7
|
-
"import type { AbiContract, AbiFunction } from \"./contract.ts\";\nimport { SIP009_ABI, SIP010_ABI, SIP013_ABI } from \"./standards.ts\";\n\n/**\n * Static conformance classification — \"does this contract's ABI look like a\n * SIP-009/010/013 token?\". Powers trait-based discovery for the (many) contracts\n * that conform to a standard without declaring its trait. Lean match: every\n * REQUIRED standard function must be present with the same access + arg arity\n * (optional functions like get-token-uri are ignored). Loose on exact arg/return\n * types to catch real-world variants; consumers wanting certainty use the\n * `declared` traits parsed from source instead.\n */\n\
|
|
7
|
+
"import type { AbiContract, AbiFunction } from \"./contract.ts\";\nimport { SIP009_ABI, SIP010_ABI, SIP013_ABI } from \"./standards.ts\";\n\n/**\n * Static conformance classification — \"does this contract's ABI look like a\n * SIP-009/010/013 token?\". Powers trait-based discovery for the (many) contracts\n * that conform to a standard without declaring its trait. Lean match: every\n * REQUIRED standard function must be present with the same access + arg arity\n * (optional functions like get-token-uri are ignored). Loose on exact arg/return\n * types to catch real-world variants; consumers wanting certainty use the\n * `declared` traits parsed from source instead.\n */\n\n/** The canonical SIP trait standards this package can classify/scaffold against.\n * Single source of truth — the `SipStandard` type, CLI `--trait` validation, and\n * the MCP traits resource all derive from this so the vocabulary can't drift. */\nexport const TRAIT_STANDARDS = [\"sip-009\", \"sip-010\", \"sip-013\"] as const;\n\nexport type SipStandard = (typeof TRAIT_STANDARDS)[number];\n\ninterface StandardSpec {\n\tid: SipStandard;\n\tabi: AbiContract;\n\t/** Functions in the reference ABI that real tokens may omit. */\n\toptional: ReadonlySet<string>;\n}\n\nconst STANDARDS: ReadonlyArray<StandardSpec> = [\n\t{ id: \"sip-010\", abi: SIP010_ABI, optional: new Set([\"get-token-uri\"]) },\n\t{ id: \"sip-009\", abi: SIP009_ABI, optional: new Set([\"get-token-uri\"]) },\n\t{\n\t\tid: \"sip-013\",\n\t\tabi: SIP013_ABI,\n\t\toptional: new Set([\n\t\t\t\"transfer-memo\",\n\t\t\t\"transfer-many\",\n\t\t\t\"transfer-many-memo\",\n\t\t\t\"get-token-uri\",\n\t\t\t\"get-overall-balance\",\n\t\t\t\"get-overall-supply\",\n\t\t]),\n\t},\n];\n\nfunction indexByName(abi: AbiContract): Map<string, AbiFunction> {\n\tconst m = new Map<string, AbiFunction>();\n\tfor (const f of abi.functions) m.set(f.name, f);\n\treturn m;\n}\n\nfunction conformsTo(candidate: AbiContract, spec: StandardSpec): boolean {\n\tconst fns = indexByName(candidate);\n\tfor (const required of spec.abi.functions) {\n\t\tif (spec.optional.has(required.name)) continue;\n\t\tconst got = fns.get(required.name);\n\t\tif (!got) return false;\n\t\tif (got.access !== required.access) return false;\n\t\tif (got.args.length !== required.args.length) return false;\n\t}\n\treturn true;\n}\n\n/** Return the SIP standards a contract's ABI statically conforms to. */\nexport function classifyContract(abi: AbiContract): SipStandard[] {\n\tif (!abi || !Array.isArray(abi.functions)) return [];\n\treturn STANDARDS.filter((s) => conformsTo(abi, s)).map((s) => s.id);\n}\n\n/**\n * Parse the standards a contract *declares* via `(impl-trait …)` in its Clarity\n * source. Matched heuristically on the trait-reference name (robust across\n * mainnet/testnet principals + community variants) rather than an exact principal\n * allowlist. The ABI/RPC doesn't carry trait info, so source is the only declared\n * signal. `declared` is the high-confidence signal; `classifyContract` is the\n * catch-all for conforming-but-undeclared contracts.\n */\nexport function parseDeclaredStandards(claritySource: string): SipStandard[] {\n\tconst out = new Set<SipStandard>();\n\tconst matches = claritySource.matchAll(/\\(impl-trait\\s+[^)]+\\)/gi);\n\tfor (const m of matches) {\n\t\tconst ref = m[0].toLowerCase();\n\t\tif (ref.includes(\"sip-010\") || ref.includes(\".ft-trait\"))\n\t\t\tout.add(\"sip-010\");\n\t\tif (ref.includes(\"sip-009\") || ref.includes(\"nft-trait\"))\n\t\t\tout.add(\"sip-009\");\n\t\tif (ref.includes(\"sip-013\") || ref.includes(\"semi-fungible\"))\n\t\t\tout.add(\"sip-013\");\n\t}\n\treturn [...out];\n}\n"
|
|
8
8
|
],
|
|
9
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQO,SAAS,WAAW,CAC1B,KACA,WAA+B,OACV;AAAA,EACrB,QAAQ,IAAI;AAAA,SACN;AAAA,MACJ,OAAO;AAAA,SACH;AAAA,MACJ,OAAO;AAAA,SACH;AAAA,MACJ,OAAO,IAAI,MAAM,SAAS;AAAA,SACtB;AAAA,MACJ,OAAO,IAAI,IAAI,MAAM,SAAS;AAAA,SAC1B;AAAA,MACJ,IAAI,aAAa,YAAY;AAAA,QAC5B,MAAM,MAAM,aAAa,WAAW,IAAI,KAAK,CAAC;AAAA,QAC9C,IAAI,WAAW,KAAK,GAAG;AAAA,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 @@ __export(exports_clarity, {
|
|
|
59
59
|
clarityTypeFromByte: () => clarityTypeFromByte,
|
|
60
60
|
bufferCV: () => bufferCV,
|
|
61
61
|
boolCV: () => boolCV,
|
|
62
|
+
TRAIT_STANDARDS: () => TRAIT_STANDARDS,
|
|
62
63
|
SIP013_ABI: () => SIP013_ABI,
|
|
63
64
|
SIP010_ABI: () => SIP010_ABI,
|
|
64
65
|
SIP009_ABI: () => SIP009_ABI,
|
|
@@ -335,6 +336,7 @@ function validateArgsArray(func, args) {
|
|
|
335
336
|
});
|
|
336
337
|
}
|
|
337
338
|
// src/clarity/abi/classify.ts
|
|
339
|
+
var TRAIT_STANDARDS = ["sip-009", "sip-010", "sip-013"];
|
|
338
340
|
var STANDARDS = [
|
|
339
341
|
{ id: "sip-010", abi: SIP010_ABI, optional: new Set(["get-token-uri"]) },
|
|
340
342
|
{ id: "sip-009", abi: SIP009_ABI, optional: new Set(["get-token-uri"]) },
|
|
@@ -392,5 +394,5 @@ function parseDeclaredStandards(claritySource) {
|
|
|
392
394
|
return [...out];
|
|
393
395
|
}
|
|
394
396
|
|
|
395
|
-
//# debugId=
|
|
396
|
-
//# sourceMappingURL=stacks-
|
|
397
|
+
//# debugId=D03CED766895F1B064756E2164756E21
|
|
398
|
+
//# sourceMappingURL=stacks-vk8fwz0t.cjs.map
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import {\n\tasciiToBytes,\n\tbytesToAscii,\n\thexToBytes,\n\tutf8ToBytes,\n} from \"../utils/encoding.ts\";\nimport type { ClarityValue } from \"./types.ts\";\n\nexport function prettyPrint(\n\tval: ClarityValue,\n\tencoding: \"tryAscii\" | \"hex\" = \"hex\",\n): string | undefined {\n\tswitch (val.type) {\n\t\tcase \"true\":\n\t\t\treturn \"true\";\n\t\tcase \"false\":\n\t\t\treturn \"false\";\n\t\tcase \"int\":\n\t\t\treturn val.value.toString();\n\t\tcase \"uint\":\n\t\t\treturn `u${val.value.toString()}`;\n\t\tcase \"buffer\":\n\t\t\tif (encoding === \"tryAscii\") {\n\t\t\t\tconst str = bytesToAscii(hexToBytes(val.value));\n\t\t\t\tif (/^[ -~]*$/.test(str)) return JSON.stringify(str);\n\t\t\t}\n\t\t\treturn `0x${val.value}`;\n\t\tcase \"none\":\n\t\t\treturn \"none\";\n\t\tcase \"some\":\n\t\t\treturn `(some ${prettyPrint(val.value, encoding)})`;\n\t\tcase \"ok\":\n\t\t\treturn `(ok ${prettyPrint(val.value, encoding)})`;\n\t\tcase \"err\":\n\t\t\treturn `(err ${prettyPrint(val.value, encoding)})`;\n\t\tcase \"address\":\n\t\tcase \"contract\":\n\t\t\treturn val.value;\n\t\tcase \"list\":\n\t\t\treturn `(list ${val.value.map((v) => prettyPrint(v, encoding)).join(\" \")})`;\n\t\tcase \"tuple\":\n\t\t\treturn `(tuple ${Object.keys(val.value)\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\t\t\t.map((key) => `(${key} ${prettyPrint(val.value[key]!, encoding)})`)\n\t\t\t\t.join(\" \")})`;\n\t\tcase \"ascii\":\n\t\t\treturn `\"${val.value}\"`;\n\t\tcase \"utf8\":\n\t\t\treturn `u\"${val.value}\"`;\n\t}\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\nexport function cvToJSON(val: ClarityValue): any {\n\tswitch (val.type) {\n\t\tcase \"true\":\n\t\t\treturn { type: \"bool\", value: true };\n\t\tcase \"false\":\n\t\t\treturn { type: \"bool\", value: false };\n\t\tcase \"int\":\n\t\t\treturn { type: \"int\", value: val.value.toString() };\n\t\tcase \"uint\":\n\t\t\treturn { type: \"uint\", value: val.value.toString() };\n\t\tcase \"buffer\":\n\t\t\treturn {\n\t\t\t\ttype: `(buff ${Math.ceil(val.value.length / 2)})`,\n\t\t\t\tvalue: `0x${val.value}`,\n\t\t\t};\n\t\tcase \"none\":\n\t\t\treturn { type: \"(optional none)\", value: null };\n\t\tcase \"some\":\n\t\t\treturn { type: \"(optional)\", value: cvToJSON(val.value) };\n\t\tcase \"ok\":\n\t\t\treturn { type: \"(response)\", value: cvToJSON(val.value), success: true };\n\t\tcase \"err\":\n\t\t\treturn { type: \"(response)\", value: cvToJSON(val.value), success: false };\n\t\tcase \"address\":\n\t\tcase \"contract\":\n\t\t\treturn { type: \"principal\", value: val.value };\n\t\tcase \"list\":\n\t\t\treturn { type: \"(list)\", value: val.value.map(cvToJSON) };\n\t\tcase \"tuple\": {\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\t\tconst result: Record<string, any> = {};\n\t\t\tfor (const key of Object.keys(val.value)) {\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\t\t\tresult[key] = cvToJSON(val.value[key]!);\n\t\t\t}\n\t\t\treturn { type: \"(tuple)\", value: result };\n\t\t}\n\t\tcase \"ascii\":\n\t\t\treturn {\n\t\t\t\ttype: `(string-ascii ${asciiToBytes(val.value).length})`,\n\t\t\t\tvalue: val.value,\n\t\t\t};\n\t\tcase \"utf8\":\n\t\t\treturn {\n\t\t\t\ttype: `(string-utf8 ${utf8ToBytes(val.value).length})`,\n\t\t\t\tvalue: val.value,\n\t\t\t};\n\t}\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\nexport function cvToValue(val: ClarityValue): any {\n\tswitch (val.type) {\n\t\tcase \"true\":\n\t\t\treturn true;\n\t\tcase \"false\":\n\t\t\treturn false;\n\t\tcase \"int\":\n\t\tcase \"uint\":\n\t\t\treturn val.value;\n\t\tcase \"buffer\":\n\t\t\treturn `0x${val.value}`;\n\t\tcase \"none\":\n\t\t\treturn null;\n\t\tcase \"some\":\n\t\t\treturn cvToValue(val.value);\n\t\tcase \"ok\":\n\t\tcase \"err\":\n\t\t\treturn cvToValue(val.value);\n\t\tcase \"address\":\n\t\tcase \"contract\":\n\t\t\treturn val.value;\n\t\tcase \"list\":\n\t\t\treturn val.value.map(cvToValue);\n\t\tcase \"tuple\": {\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\t\tconst result: Record<string, any> = {};\n\t\t\tfor (const key of Object.keys(val.value)) {\n\t\t\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\t\t\tresult[key] = cvToValue(val.value[key]!);\n\t\t\t}\n\t\t\treturn result;\n\t\t}\n\t\tcase \"ascii\":\n\t\tcase \"utf8\":\n\t\t\treturn val.value;\n\t}\n}\n",
|
|
6
6
|
"import type { AbiFunction } from \"./contract.ts\";\nimport {\n\tisAbiBuffer,\n\tisAbiList,\n\tisAbiOptional,\n\tisAbiResponse,\n\tisAbiStringAscii,\n\tisAbiStringUtf8,\n\tisAbiTuple,\n\tisBool,\n\tisInt128,\n\tisPrincipal,\n\tisString,\n\tisUint8Array,\n\tisUint128,\n} from \"./guards.ts\";\nimport type { AbiType } from \"./types.ts\";\nimport { toCamelCase } from \"./utils.ts\";\n\nexport class ClarityConversionError extends Error {\n\tconstructor(\n\t\tmessage: string,\n\t\tpublic readonly type: AbiType,\n\t\tpublic readonly value: unknown,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = \"ClarityConversionError\";\n\t}\n}\n\nexport function jsToClarity(type: AbiType, value: unknown): unknown {\n\tif (type === \"none\") return null;\n\n\tif (type === \"uint128\") {\n\t\tif (!isUint128(value))\n\t\t\tthrow new ClarityConversionError(\"Invalid uint128 value\", type, value);\n\t\treturn value;\n\t}\n\n\tif (type === \"int128\") {\n\t\tif (!isInt128(value))\n\t\t\tthrow new ClarityConversionError(\"Invalid int128 value\", type, value);\n\t\treturn value;\n\t}\n\n\tif (type === \"bool\") {\n\t\tif (!isBool(value))\n\t\t\tthrow new ClarityConversionError(\"Invalid bool value\", type, value);\n\t\treturn value;\n\t}\n\n\tif (type === \"principal\") {\n\t\tif (!isPrincipal(value))\n\t\t\tthrow new ClarityConversionError(\"Invalid principal value\", type, value);\n\t\treturn value;\n\t}\n\n\tif (type === \"trait_reference\") {\n\t\tif (!isPrincipal(value))\n\t\t\tthrow new ClarityConversionError(\n\t\t\t\t\"Invalid trait_reference value\",\n\t\t\t\ttype,\n\t\t\t\tvalue,\n\t\t\t);\n\t\treturn value;\n\t}\n\n\tif (isAbiStringAscii(type)) {\n\t\tif (!isString(value))\n\t\t\tthrow new ClarityConversionError(\n\t\t\t\t\"Invalid string-ascii value\",\n\t\t\t\ttype,\n\t\t\t\tvalue,\n\t\t\t);\n\t\tconst str = value as string;\n\t\tfor (let i = 0; i < str.length; i++) {\n\t\t\tif (str.charCodeAt(i) > 127) {\n\t\t\t\tthrow new ClarityConversionError(\n\t\t\t\t\t`Non-ASCII character at position ${i}: '${str[i]}' (code ${str.charCodeAt(i)})`,\n\t\t\t\t\ttype,\n\t\t\t\t\tvalue,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tif (str.length > type[\"string-ascii\"].length) {\n\t\t\tthrow new ClarityConversionError(\n\t\t\t\t`String length ${str.length} exceeds max ${type[\"string-ascii\"].length}`,\n\t\t\t\ttype,\n\t\t\t\tvalue,\n\t\t\t);\n\t\t}\n\t\treturn value;\n\t}\n\n\tif (isAbiStringUtf8(type)) {\n\t\tif (!isString(value))\n\t\t\tthrow new ClarityConversionError(\n\t\t\t\t\"Invalid string-utf8 value\",\n\t\t\t\ttype,\n\t\t\t\tvalue,\n\t\t\t);\n\t\tconst str = value as string;\n\t\tconst byteLength = new TextEncoder().encode(str).length;\n\t\tif (byteLength > type[\"string-utf8\"].length) {\n\t\t\tthrow new ClarityConversionError(\n\t\t\t\t`String byte length ${byteLength} exceeds max ${type[\"string-utf8\"].length}`,\n\t\t\t\ttype,\n\t\t\t\tvalue,\n\t\t\t);\n\t\t}\n\t\treturn value;\n\t}\n\n\tif (isAbiBuffer(type)) {\n\t\tif (!isUint8Array(value))\n\t\t\tthrow new ClarityConversionError(\"Invalid buffer value\", type, value);\n\t\tconst buff = value as Uint8Array;\n\t\tif (buff.length > type.buff.length) {\n\t\t\tthrow new ClarityConversionError(\n\t\t\t\t`Buffer length ${buff.length} exceeds max ${type.buff.length}`,\n\t\t\t\ttype,\n\t\t\t\tvalue,\n\t\t\t);\n\t\t}\n\t\treturn value;\n\t}\n\n\tif (isAbiList(type)) {\n\t\tif (!Array.isArray(value))\n\t\t\tthrow new ClarityConversionError(\n\t\t\t\t\"Expected array for list type\",\n\t\t\t\ttype,\n\t\t\t\tvalue,\n\t\t\t);\n\t\tif (value.length > type.list.length) {\n\t\t\tthrow new ClarityConversionError(\n\t\t\t\t`List length ${value.length} exceeds max ${type.list.length}`,\n\t\t\t\ttype,\n\t\t\t\tvalue,\n\t\t\t);\n\t\t}\n\t\treturn value.map((item) => jsToClarity(type.list.type, item));\n\t}\n\n\tif (isAbiTuple(type)) {\n\t\tif (typeof value !== \"object\" || value === null)\n\t\t\tthrow new ClarityConversionError(\n\t\t\t\t\"Expected object for tuple type\",\n\t\t\t\ttype,\n\t\t\t\tvalue,\n\t\t\t);\n\t\tconst result: Record<string, unknown> = {};\n\t\tfor (const field of type.tuple) {\n\t\t\tconst camelKey = toCamelCase(field.name);\n\t\t\tconst hasOriginal = field.name in (value as object);\n\t\t\tconst hasCamel = camelKey in (value as object);\n\t\t\tif (!hasOriginal && !hasCamel) {\n\t\t\t\tthrow new ClarityConversionError(\n\t\t\t\t\t`Missing tuple field: ${field.name}`,\n\t\t\t\t\ttype,\n\t\t\t\t\tvalue,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst fieldValue = hasOriginal\n\t\t\t\t? (value as Record<string, unknown>)[field.name]\n\t\t\t\t: (value as Record<string, unknown>)[camelKey];\n\t\t\tresult[field.name] = jsToClarity(field.type, fieldValue);\n\t\t}\n\t\treturn result;\n\t}\n\n\tif (isAbiOptional(type)) {\n\t\tif (value === null || value === undefined) return null;\n\t\treturn jsToClarity(type.optional, value);\n\t}\n\n\tif (isAbiResponse(type)) {\n\t\tif (typeof value !== \"object\" || value === null)\n\t\t\tthrow new ClarityConversionError(\n\t\t\t\t\"Expected object for response type\",\n\t\t\t\ttype,\n\t\t\t\tvalue,\n\t\t\t);\n\t\tconst hasOk = \"ok\" in value;\n\t\tconst hasErr = \"err\" in value;\n\t\tif (hasOk && !hasErr) {\n\t\t\treturn {\n\t\t\t\tok: jsToClarity(type.response.ok, (value as { ok: unknown }).ok),\n\t\t\t};\n\t\t}\n\t\tif (hasErr && !hasOk) {\n\t\t\treturn {\n\t\t\t\terr: jsToClarity(type.response.error, (value as { err: unknown }).err),\n\t\t\t};\n\t\t}\n\t\tthrow new ClarityConversionError(\n\t\t\t\"Response must have exactly 'ok' or 'err' property\",\n\t\t\ttype,\n\t\t\tvalue,\n\t\t);\n\t}\n\n\tthrow new ClarityConversionError(\"Unknown Clarity type\", type, value);\n}\n\nexport function prepareArgs<F extends AbiFunction>(\n\tfunc: F,\n\targs: Record<string, unknown>,\n): unknown[] {\n\treturn func.args.map((arg) => {\n\t\tif (!(arg.name in args)) {\n\t\t\tthrow new ClarityConversionError(\n\t\t\t\t`Missing argument: ${arg.name}`,\n\t\t\t\targ.type,\n\t\t\t\tundefined,\n\t\t\t);\n\t\t}\n\t\treturn jsToClarity(arg.type, args[arg.name]);\n\t});\n}\n\nexport function validateArgs<F extends AbiFunction>(\n\tfunc: F,\n\targs: Record<string, unknown>,\n): void {\n\tfor (const arg of func.args) {\n\t\tif (!(arg.name in args)) {\n\t\t\tthrow new ClarityConversionError(\n\t\t\t\t`Missing argument: ${arg.name}`,\n\t\t\t\targ.type,\n\t\t\t\tundefined,\n\t\t\t);\n\t\t}\n\t\tjsToClarity(arg.type, args[arg.name]);\n\t}\n}\n\nexport function validateArgsArray<F extends AbiFunction>(\n\tfunc: F,\n\targs: unknown[],\n): void {\n\tif (args.length !== func.args.length) {\n\t\tthrow new ClarityConversionError(\n\t\t\t`Expected ${func.args.length} arguments, got ${args.length}`,\n\t\t\tfunc.args[0]?.type ?? \"bool\",\n\t\t\targs,\n\t\t);\n\t}\n\tfunc.args.forEach((arg, i) => {\n\t\tjsToClarity(arg.type, args[i]);\n\t});\n}\n",
|
|
7
|
-
"import type { AbiContract, AbiFunction } from \"./contract.ts\";\nimport { SIP009_ABI, SIP010_ABI, SIP013_ABI } from \"./standards.ts\";\n\n/**\n * Static conformance classification — \"does this contract's ABI look like a\n * SIP-009/010/013 token?\". Powers trait-based discovery for the (many) contracts\n * that conform to a standard without declaring its trait. Lean match: every\n * REQUIRED standard function must be present with the same access + arg arity\n * (optional functions like get-token-uri are ignored). Loose on exact arg/return\n * types to catch real-world variants; consumers wanting certainty use the\n * `declared` traits parsed from source instead.\n */\n\
|
|
7
|
+
"import type { AbiContract, AbiFunction } from \"./contract.ts\";\nimport { SIP009_ABI, SIP010_ABI, SIP013_ABI } from \"./standards.ts\";\n\n/**\n * Static conformance classification — \"does this contract's ABI look like a\n * SIP-009/010/013 token?\". Powers trait-based discovery for the (many) contracts\n * that conform to a standard without declaring its trait. Lean match: every\n * REQUIRED standard function must be present with the same access + arg arity\n * (optional functions like get-token-uri are ignored). Loose on exact arg/return\n * types to catch real-world variants; consumers wanting certainty use the\n * `declared` traits parsed from source instead.\n */\n\n/** The canonical SIP trait standards this package can classify/scaffold against.\n * Single source of truth — the `SipStandard` type, CLI `--trait` validation, and\n * the MCP traits resource all derive from this so the vocabulary can't drift. */\nexport const TRAIT_STANDARDS = [\"sip-009\", \"sip-010\", \"sip-013\"] as const;\n\nexport type SipStandard = (typeof TRAIT_STANDARDS)[number];\n\ninterface StandardSpec {\n\tid: SipStandard;\n\tabi: AbiContract;\n\t/** Functions in the reference ABI that real tokens may omit. */\n\toptional: ReadonlySet<string>;\n}\n\nconst STANDARDS: ReadonlyArray<StandardSpec> = [\n\t{ id: \"sip-010\", abi: SIP010_ABI, optional: new Set([\"get-token-uri\"]) },\n\t{ id: \"sip-009\", abi: SIP009_ABI, optional: new Set([\"get-token-uri\"]) },\n\t{\n\t\tid: \"sip-013\",\n\t\tabi: SIP013_ABI,\n\t\toptional: new Set([\n\t\t\t\"transfer-memo\",\n\t\t\t\"transfer-many\",\n\t\t\t\"transfer-many-memo\",\n\t\t\t\"get-token-uri\",\n\t\t\t\"get-overall-balance\",\n\t\t\t\"get-overall-supply\",\n\t\t]),\n\t},\n];\n\nfunction indexByName(abi: AbiContract): Map<string, AbiFunction> {\n\tconst m = new Map<string, AbiFunction>();\n\tfor (const f of abi.functions) m.set(f.name, f);\n\treturn m;\n}\n\nfunction conformsTo(candidate: AbiContract, spec: StandardSpec): boolean {\n\tconst fns = indexByName(candidate);\n\tfor (const required of spec.abi.functions) {\n\t\tif (spec.optional.has(required.name)) continue;\n\t\tconst got = fns.get(required.name);\n\t\tif (!got) return false;\n\t\tif (got.access !== required.access) return false;\n\t\tif (got.args.length !== required.args.length) return false;\n\t}\n\treturn true;\n}\n\n/** Return the SIP standards a contract's ABI statically conforms to. */\nexport function classifyContract(abi: AbiContract): SipStandard[] {\n\tif (!abi || !Array.isArray(abi.functions)) return [];\n\treturn STANDARDS.filter((s) => conformsTo(abi, s)).map((s) => s.id);\n}\n\n/**\n * Parse the standards a contract *declares* via `(impl-trait …)` in its Clarity\n * source. Matched heuristically on the trait-reference name (robust across\n * mainnet/testnet principals + community variants) rather than an exact principal\n * allowlist. The ABI/RPC doesn't carry trait info, so source is the only declared\n * signal. `declared` is the high-confidence signal; `classifyContract` is the\n * catch-all for conforming-but-undeclared contracts.\n */\nexport function parseDeclaredStandards(claritySource: string): SipStandard[] {\n\tconst out = new Set<SipStandard>();\n\tconst matches = claritySource.matchAll(/\\(impl-trait\\s+[^)]+\\)/gi);\n\tfor (const m of matches) {\n\t\tconst ref = m[0].toLowerCase();\n\t\tif (ref.includes(\"sip-010\") || ref.includes(\".ft-trait\"))\n\t\t\tout.add(\"sip-010\");\n\t\tif (ref.includes(\"sip-009\") || ref.includes(\"nft-trait\"))\n\t\t\tout.add(\"sip-009\");\n\t\tif (ref.includes(\"sip-013\") || ref.includes(\"semi-fungible\"))\n\t\t\tout.add(\"sip-013\");\n\t}\n\treturn [...out];\n}\n"
|
|
8
8
|
],
|
|
9
|
-
"mappings": "
|
|
10
|
-
"debugId": "
|
|
9
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQO,SAAS,WAAW,CAC1B,KACA,WAA+B,OACV;AAAA,EACrB,QAAQ,IAAI;AAAA,SACN;AAAA,MACJ,OAAO;AAAA,SACH;AAAA,MACJ,OAAO;AAAA,SACH;AAAA,MACJ,OAAO,IAAI,MAAM,SAAS;AAAA,SACtB;AAAA,MACJ,OAAO,IAAI,IAAI,MAAM,SAAS;AAAA,SAC1B;AAAA,MACJ,IAAI,aAAa,YAAY;AAAA,QAC5B,MAAM,MAAM,aAAa,WAAW,IAAI,KAAK,CAAC;AAAA,QAC9C,IAAI,WAAW,KAAK,GAAG;AAAA,UAAG,OAAO,KAAK,UAAU,GAAG;AAAA,MACpD;AAAA,MACA,OAAO,KAAK,IAAI;AAAA,SACZ;AAAA,MACJ,OAAO;AAAA,SACH;AAAA,MACJ,OAAO,SAAS,YAAY,IAAI,OAAO,QAAQ;AAAA,SAC3C;AAAA,MACJ,OAAO,OAAO,YAAY,IAAI,OAAO,QAAQ;AAAA,SACzC;AAAA,MACJ,OAAO,QAAQ,YAAY,IAAI,OAAO,QAAQ;AAAA,SAC1C;AAAA,SACA;AAAA,MACJ,OAAO,IAAI;AAAA,SACP;AAAA,MACJ,OAAO,SAAS,IAAI,MAAM,IAAI,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAC,EAAE,KAAK,GAAG;AAAA,SACnE;AAAA,MACJ,OAAO,UAAU,OAAO,KAAK,IAAI,KAAK,EAEpC,IAAI,CAAC,QAAQ,IAAI,OAAO,YAAY,IAAI,MA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AAA,EACA,OAAO,CAAC,GAAG,GAAG;AAAA;",
|
|
10
|
+
"debugId": "D03CED766895F1B064756E2164756E21",
|
|
11
11
|
"names": []
|
|
12
12
|
}
|
package/dist/src/bns/index.js
CHANGED
|
@@ -838,7 +838,11 @@ declare const sip013Abi: AbiContract;
|
|
|
838
838
|
* types to catch real-world variants; consumers wanting certainty use the
|
|
839
839
|
* `declared` traits parsed from source instead.
|
|
840
840
|
*/
|
|
841
|
-
|
|
841
|
+
/** The canonical SIP trait standards this package can classify/scaffold against.
|
|
842
|
+
* Single source of truth — the `SipStandard` type, CLI `--trait` validation, and
|
|
843
|
+
* the MCP traits resource all derive from this so the vocabulary can't drift. */
|
|
844
|
+
declare const TRAIT_STANDARDS: readonly ["sip-009", "sip-010", "sip-013"];
|
|
845
|
+
type SipStandard = (typeof TRAIT_STANDARDS)[number];
|
|
842
846
|
/** Return the SIP standards a contract's ABI statically conforms to. */
|
|
843
847
|
declare function classifyContract(abi: AbiContract): SipStandard[];
|
|
844
848
|
/**
|
|
@@ -858,4 +862,4 @@ declare function jsToClarityValue(abiType: AbiType, value: unknown): ClarityValu
|
|
|
858
862
|
* Convert a ClarityValue back to a typed JS value using ABI type information.
|
|
859
863
|
*/
|
|
860
864
|
declare function clarityValueToJS<T extends AbiType>(abiType: T, cv: ClarityValue): AbiToTS<T>;
|
|
861
|
-
export { validateArgsArray, validateArgs, uintCV, tupleCV, trueCV, toCamelCase, stringUtf8CV, stringAsciiCV, standardPrincipalCV, someCV, sip013Abi, sip010Abi, sip009Abi, serializeCVBytes, serializeCV, responseOkCV, responseErrorCV, prettyPrint, prepareArgs, parseDeclaredStandards, noneCV, listCV, jsToClarityValue, jsToClarity, isUint8Array, isUint128, isTraitReference, isString, isStandardPrincipal, isResponse, isPrincipal, isOptional, isOkResponse, isInt128, isErrResponse, isContractPrincipal, isBool, isArray, isAbiTuple, isAbiTraitReference, isAbiStringUtf8, isAbiStringAscii, isAbiResponse, isAbiOptional, isAbiList, isAbiBuffer, intCV, falseCV, deserializeCVBytes, deserializeCV, cvToValue, cvToJSON, contractPrincipalCV, classifyContract, clarityValueToJS, clarityTypeFromByte, bufferCV, boolCV, VariableAccess, UIntCV, TupleData, TupleCV, TrueCV, TraitFunctionAccess, ToCamelCase, StringUtf8CV, StringAsciiCV, StandardPrincipalCV, SomeCV, SipStandard, SIP013_ABI, SIP010_ABI, SIP009_ABI, ResponseOkCV, ResponseOk, ResponseErrorCV, ResponseErr, ResponseCV, Response, PrincipalCV, OptionalCV, NoneCV, ListCV, IntCV, FunctionArg, FunctionAccess, FalseCV, ExtractVariableType, ExtractVariableNames, ExtractVariable, ExtractReadOnlyFunctions, ExtractPublicFunctions, ExtractPrivateFunctions, ExtractNonFungibleTokenNames, ExtractNFTAssetType, ExtractMapValue, ExtractMapNames, ExtractMapKey, ExtractMap, ExtractImplementedTraits, ExtractFungibleTokenNames, ExtractFunctionOutput, ExtractFunctionNames, ExtractFunctionArgs, ExtractFunction, ExtractDefinedTraitNames, ExtractDataVars, ExtractConstants, ContractPrincipalCV, ClarityWireType, ClarityValue, ClarityType, ClarityConversionError, Cl, CONTRACT_NAME_REGEX, BufferCV, BooleanCV, AbiVariable, AbiUInt128, AbiType, AbiTupleType, AbiTuple, AbiTraitReference, AbiTraitFunction, AbiTraitDefinition, AbiToTS, AbiStringUtf8, AbiStringAscii, AbiResponseType, AbiResponse, AbiPrincipal, AbiPrimitiveType, AbiOptionalType, AbiOptional, AbiNone, AbiNonFungibleToken, AbiMap, AbiListType, AbiList, AbiInt128, AbiFungibleToken, AbiFunction, AbiContract, AbiBuffer, AbiBool };
|
|
865
|
+
export { validateArgsArray, validateArgs, uintCV, tupleCV, trueCV, toCamelCase, stringUtf8CV, stringAsciiCV, standardPrincipalCV, someCV, sip013Abi, sip010Abi, sip009Abi, serializeCVBytes, serializeCV, responseOkCV, responseErrorCV, prettyPrint, prepareArgs, parseDeclaredStandards, noneCV, listCV, jsToClarityValue, jsToClarity, isUint8Array, isUint128, isTraitReference, isString, isStandardPrincipal, isResponse, isPrincipal, isOptional, isOkResponse, isInt128, isErrResponse, isContractPrincipal, isBool, isArray, isAbiTuple, isAbiTraitReference, isAbiStringUtf8, isAbiStringAscii, isAbiResponse, isAbiOptional, isAbiList, isAbiBuffer, intCV, falseCV, deserializeCVBytes, deserializeCV, cvToValue, cvToJSON, contractPrincipalCV, classifyContract, clarityValueToJS, clarityTypeFromByte, bufferCV, boolCV, VariableAccess, UIntCV, TupleData, TupleCV, TrueCV, TraitFunctionAccess, ToCamelCase, TRAIT_STANDARDS, StringUtf8CV, StringAsciiCV, StandardPrincipalCV, SomeCV, SipStandard, SIP013_ABI, SIP010_ABI, SIP009_ABI, ResponseOkCV, ResponseOk, ResponseErrorCV, ResponseErr, ResponseCV, Response, PrincipalCV, OptionalCV, NoneCV, ListCV, IntCV, FunctionArg, FunctionAccess, FalseCV, ExtractVariableType, ExtractVariableNames, ExtractVariable, ExtractReadOnlyFunctions, ExtractPublicFunctions, ExtractPrivateFunctions, ExtractNonFungibleTokenNames, ExtractNFTAssetType, ExtractMapValue, ExtractMapNames, ExtractMapKey, ExtractMap, ExtractImplementedTraits, ExtractFungibleTokenNames, ExtractFunctionOutput, ExtractFunctionNames, ExtractFunctionArgs, ExtractFunction, ExtractDefinedTraitNames, ExtractDataVars, ExtractConstants, ContractPrincipalCV, ClarityWireType, ClarityValue, ClarityType, ClarityConversionError, Cl, CONTRACT_NAME_REGEX, BufferCV, BooleanCV, AbiVariable, AbiUInt128, AbiType, AbiTupleType, AbiTuple, AbiTraitReference, AbiTraitFunction, AbiTraitDefinition, AbiToTS, AbiStringUtf8, AbiStringAscii, AbiResponseType, AbiResponse, AbiPrincipal, AbiPrimitiveType, AbiOptionalType, AbiOptional, AbiNone, AbiNonFungibleToken, AbiMap, AbiListType, AbiList, AbiInt128, AbiFungibleToken, AbiFunction, AbiContract, AbiBuffer, AbiBool };
|
|
@@ -838,7 +838,11 @@ declare const sip013Abi: AbiContract;
|
|
|
838
838
|
* types to catch real-world variants; consumers wanting certainty use the
|
|
839
839
|
* `declared` traits parsed from source instead.
|
|
840
840
|
*/
|
|
841
|
-
|
|
841
|
+
/** The canonical SIP trait standards this package can classify/scaffold against.
|
|
842
|
+
* Single source of truth — the `SipStandard` type, CLI `--trait` validation, and
|
|
843
|
+
* the MCP traits resource all derive from this so the vocabulary can't drift. */
|
|
844
|
+
declare const TRAIT_STANDARDS: readonly ["sip-009", "sip-010", "sip-013"];
|
|
845
|
+
type SipStandard = (typeof TRAIT_STANDARDS)[number];
|
|
842
846
|
/** Return the SIP standards a contract's ABI statically conforms to. */
|
|
843
847
|
declare function classifyContract(abi: AbiContract): SipStandard[];
|
|
844
848
|
/**
|
|
@@ -858,4 +862,4 @@ declare function jsToClarityValue(abiType: AbiType, value: unknown): ClarityValu
|
|
|
858
862
|
* Convert a ClarityValue back to a typed JS value using ABI type information.
|
|
859
863
|
*/
|
|
860
864
|
declare function clarityValueToJS<T extends AbiType>(abiType: T, cv: ClarityValue): AbiToTS<T>;
|
|
861
|
-
export { validateArgsArray, validateArgs, uintCV, tupleCV, trueCV, toCamelCase, stringUtf8CV, stringAsciiCV, standardPrincipalCV, someCV, sip013Abi, sip010Abi, sip009Abi, serializeCVBytes, serializeCV, responseOkCV, responseErrorCV, prettyPrint, prepareArgs, parseDeclaredStandards, noneCV, listCV, jsToClarityValue, jsToClarity, isUint8Array, isUint128, isTraitReference, isString, isStandardPrincipal, isResponse, isPrincipal, isOptional, isOkResponse, isInt128, isErrResponse, isContractPrincipal, isBool, isArray, isAbiTuple, isAbiTraitReference, isAbiStringUtf8, isAbiStringAscii, isAbiResponse, isAbiOptional, isAbiList, isAbiBuffer, intCV, falseCV, deserializeCVBytes, deserializeCV, cvToValue, cvToJSON, contractPrincipalCV, classifyContract, clarityValueToJS, clarityTypeFromByte, bufferCV, boolCV, VariableAccess, UIntCV, TupleData, TupleCV, TrueCV, TraitFunctionAccess, ToCamelCase, StringUtf8CV, StringAsciiCV, StandardPrincipalCV, SomeCV, SipStandard, SIP013_ABI, SIP010_ABI, SIP009_ABI, ResponseOkCV, ResponseOk, ResponseErrorCV, ResponseErr, ResponseCV, Response, PrincipalCV, OptionalCV, NoneCV, ListCV, IntCV, FunctionArg, FunctionAccess, FalseCV, ExtractVariableType, ExtractVariableNames, ExtractVariable, ExtractReadOnlyFunctions, ExtractPublicFunctions, ExtractPrivateFunctions, ExtractNonFungibleTokenNames, ExtractNFTAssetType, ExtractMapValue, ExtractMapNames, ExtractMapKey, ExtractMap, ExtractImplementedTraits, ExtractFungibleTokenNames, ExtractFunctionOutput, ExtractFunctionNames, ExtractFunctionArgs, ExtractFunction, ExtractDefinedTraitNames, ExtractDataVars, ExtractConstants, ContractPrincipalCV, ClarityWireType, ClarityValue, ClarityType, ClarityConversionError, Cl, CONTRACT_NAME_REGEX, BufferCV, BooleanCV, AbiVariable, AbiUInt128, AbiType, AbiTupleType, AbiTuple, AbiTraitReference, AbiTraitFunction, AbiTraitDefinition, AbiToTS, AbiStringUtf8, AbiStringAscii, AbiResponseType, AbiResponse, AbiPrincipal, AbiPrimitiveType, AbiOptionalType, AbiOptional, AbiNone, AbiNonFungibleToken, AbiMap, AbiListType, AbiList, AbiInt128, AbiFungibleToken, AbiFunction, AbiContract, AbiBuffer, AbiBool };
|
|
865
|
+
export { validateArgsArray, validateArgs, uintCV, tupleCV, trueCV, toCamelCase, stringUtf8CV, stringAsciiCV, standardPrincipalCV, someCV, sip013Abi, sip010Abi, sip009Abi, serializeCVBytes, serializeCV, responseOkCV, responseErrorCV, prettyPrint, prepareArgs, parseDeclaredStandards, noneCV, listCV, jsToClarityValue, jsToClarity, isUint8Array, isUint128, isTraitReference, isString, isStandardPrincipal, isResponse, isPrincipal, isOptional, isOkResponse, isInt128, isErrResponse, isContractPrincipal, isBool, isArray, isAbiTuple, isAbiTraitReference, isAbiStringUtf8, isAbiStringAscii, isAbiResponse, isAbiOptional, isAbiList, isAbiBuffer, intCV, falseCV, deserializeCVBytes, deserializeCV, cvToValue, cvToJSON, contractPrincipalCV, classifyContract, clarityValueToJS, clarityTypeFromByte, bufferCV, boolCV, VariableAccess, UIntCV, TupleData, TupleCV, TrueCV, TraitFunctionAccess, ToCamelCase, TRAIT_STANDARDS, StringUtf8CV, StringAsciiCV, StandardPrincipalCV, SomeCV, SipStandard, SIP013_ABI, SIP010_ABI, SIP009_ABI, ResponseOkCV, ResponseOk, ResponseErrorCV, ResponseErr, ResponseCV, Response, PrincipalCV, OptionalCV, NoneCV, ListCV, IntCV, FunctionArg, FunctionAccess, FalseCV, ExtractVariableType, ExtractVariableNames, ExtractVariable, ExtractReadOnlyFunctions, ExtractPublicFunctions, ExtractPrivateFunctions, ExtractNonFungibleTokenNames, ExtractNFTAssetType, ExtractMapValue, ExtractMapNames, ExtractMapKey, ExtractMap, ExtractImplementedTraits, ExtractFungibleTokenNames, ExtractFunctionOutput, ExtractFunctionNames, ExtractFunctionArgs, ExtractFunction, ExtractDefinedTraitNames, ExtractDataVars, ExtractConstants, ContractPrincipalCV, ClarityWireType, ClarityValue, ClarityType, ClarityConversionError, Cl, CONTRACT_NAME_REGEX, BufferCV, BooleanCV, AbiVariable, AbiUInt128, AbiType, AbiTupleType, AbiTuple, AbiTraitReference, AbiTraitFunction, AbiTraitDefinition, AbiToTS, AbiStringUtf8, AbiStringAscii, AbiResponseType, AbiResponse, AbiPrincipal, AbiPrimitiveType, AbiOptionalType, AbiOptional, AbiNone, AbiNonFungibleToken, AbiMap, AbiListType, AbiList, AbiInt128, AbiFungibleToken, AbiFunction, AbiContract, AbiBuffer, AbiBool };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ClarityConversionError,
|
|
3
|
+
TRAIT_STANDARDS,
|
|
3
4
|
classifyContract,
|
|
4
5
|
cvToJSON,
|
|
5
6
|
cvToValue,
|
|
@@ -9,7 +10,7 @@ import {
|
|
|
9
10
|
prettyPrint,
|
|
10
11
|
validateArgs,
|
|
11
12
|
validateArgsArray
|
|
12
|
-
} from "../../shared/stacks-
|
|
13
|
+
} from "../../shared/stacks-43cxvnr7.js";
|
|
13
14
|
import {
|
|
14
15
|
SIP009_ABI,
|
|
15
16
|
SIP010_ABI,
|
|
@@ -134,6 +135,7 @@ export {
|
|
|
134
135
|
clarityTypeFromByte,
|
|
135
136
|
bufferCV,
|
|
136
137
|
boolCV,
|
|
138
|
+
TRAIT_STANDARDS,
|
|
137
139
|
SIP013_ABI,
|
|
138
140
|
SIP010_ABI,
|
|
139
141
|
SIP009_ABI,
|
|
@@ -143,5 +145,5 @@ export {
|
|
|
143
145
|
CONTRACT_NAME_REGEX
|
|
144
146
|
};
|
|
145
147
|
|
|
146
|
-
//# debugId=
|
|
148
|
+
//# debugId=54EA4D1AFF16FB1B64756E2164756E21
|
|
147
149
|
//# sourceMappingURL=index.js.map
|
package/dist/src/index.cjs.map
CHANGED
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"import { createTransport } from \"./createTransport.ts\";\nimport type { RequestFn, TransportFactory } from \"./types.ts\";\n\n/** Create a transport backed by a user-provided request function. */\nexport function custom(params: { request: RequestFn }): TransportFactory {\n\treturn () => createTransport(\"custom\", { request: params.request });\n}\n",
|
|
15
15
|
"import { createTransport } from \"./createTransport.ts\";\nimport type { TransportFactory } from \"./types.ts\";\n\n/** Create a transport that tries each transport in order until one succeeds. */\nexport function fallback(transports: TransportFactory[]): TransportFactory {\n\treturn (params) => {\n\t\tconst resolved = transports.map((t) => t(params));\n\n\t\treturn createTransport(\"fallback\", {\n\t\t\trequest: async (path, options) => {\n\t\t\t\tlet lastError: Error | undefined;\n\t\t\t\tfor (const transport of resolved) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\treturn await transport.request(path, options);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tlastError =\n\t\t\t\t\t\t\terror instanceof Error ? error : new Error(String(error));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthrow lastError ?? new Error(\"All transports failed\");\n\t\t\t},\n\t\t});\n\t};\n}\n",
|
|
16
16
|
"import { WebSocketError } from \"../errors/websocket.ts\";\nimport type {\n\tSubscription,\n\tWsSubscribeParams,\n} from \"../subscriptions/types.ts\";\nimport { buildRequestFn } from \"./createTransport.ts\";\nimport type { Transport, TransportConfig, TransportFactory } from \"./types.ts\";\n\n/** Configuration for the WebSocket transport, extending base {@link TransportConfig}. */\nexport type WebSocketTransportConfig = TransportConfig & {\n\t/** WebSocket URL (resolved from chain if omitted) */\n\turl?: string;\n\t/** Enable auto-reconnect (default: true) */\n\treconnect?: boolean;\n\t/** Max reconnect attempts (default: 10) */\n\treconnectMaxAttempts?: number;\n\t/** Base delay in ms for exponential backoff (default: 1000) */\n\treconnectBaseDelay?: number;\n};\n\n/** Transport with WebSocket subscription capabilities and auto-reconnect. */\nexport type WebSocketTransport = Transport & {\n\ttype: \"webSocket\";\n\tsubscribe: (\n\t\tparams: WsSubscribeParams,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tcallback: (data: any) => void,\n\t) => Promise<Subscription>;\n\tdestroy: () => void;\n};\n\ntype JsonRpcRequest = {\n\tjsonrpc: \"2.0\";\n\tid: number;\n\tmethod: string;\n\tparams: Record<string, unknown>;\n};\n\ntype JsonRpcResponse = {\n\tjsonrpc: \"2.0\";\n\tid: number;\n\tresult?: unknown;\n\terror?: { code: number; message: string };\n};\n\ntype JsonRpcNotification = {\n\tjsonrpc: \"2.0\";\n\tmethod: string;\n\tparams: unknown;\n};\n\ntype SubEntry = {\n\tparams: WsSubscribeParams;\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\tcallbacks: Set<(data: any) => void>;\n};\n\nfunction subKey(params: WsSubscribeParams): string {\n\tconst parts: string[] = [params.event];\n\tif (params.tx_id) parts.push(`tx_id:${params.tx_id}`);\n\tif (params.address) parts.push(`address:${params.address}`);\n\tif (params.asset_identifier) parts.push(`asset:${params.asset_identifier}`);\n\tif (params.value) parts.push(`value:${params.value}`);\n\treturn parts.join(\"|\");\n}\n\nexport class WebSocketChannel {\n\tprivate ws: WebSocket | null = null;\n\tprivate url: string;\n\tprivate nextId = 1;\n\tprivate pending = new Map<\n\t\tnumber,\n\t\t{ resolve: (v: unknown) => void; reject: (e: Error) => void }\n\t>();\n\tprivate subs = new Map<string, SubEntry>();\n\tprivate destroyed = false;\n\tprivate reconnecting = false;\n\tprivate reconnectAttempt = 0;\n\tprivate reconnectTimer: ReturnType<typeof setTimeout> | null = null;\n\n\tprivate reconnect: boolean;\n\tprivate reconnectMaxAttempts: number;\n\tprivate reconnectBaseDelay: number;\n\n\tconstructor(url: string, config?: WebSocketTransportConfig) {\n\t\tthis.url = url;\n\t\tthis.reconnect = config?.reconnect ?? true;\n\t\tthis.reconnectMaxAttempts = config?.reconnectMaxAttempts ?? 10;\n\t\tthis.reconnectBaseDelay = config?.reconnectBaseDelay ?? 1000;\n\t}\n\n\tprivate connect(): Promise<void> {\n\t\tif (this.ws?.readyState === WebSocket.OPEN) return Promise.resolve();\n\t\tif (this.ws?.readyState === WebSocket.CONNECTING) {\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tconst onOpen = () => {\n\t\t\t\t\tthis.ws?.removeEventListener(\"error\", onError);\n\t\t\t\t\tresolve();\n\t\t\t\t};\n\t\t\t\tconst onError = (e: Event) => {\n\t\t\t\t\tthis.ws?.removeEventListener(\"open\", onOpen);\n\t\t\t\t\treject(\n\t\t\t\t\t\tnew WebSocketError(\"WebSocket connection failed\", {\n\t\t\t\t\t\t\tdetails: String(e),\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t\tthis.ws?.addEventListener(\"open\", onOpen, { once: true });\n\t\t\t\tthis.ws?.addEventListener(\"error\", onError, { once: true });\n\t\t\t});\n\t\t}\n\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tthis.ws = new WebSocket(this.url);\n\n\t\t\tthis.ws.addEventListener(\n\t\t\t\t\"open\",\n\t\t\t\t() => {\n\t\t\t\t\tthis.reconnectAttempt = 0;\n\t\t\t\t\tthis.reconnecting = false;\n\t\t\t\t\tresolve();\n\t\t\t\t},\n\t\t\t\t{ once: true },\n\t\t\t);\n\n\t\t\tthis.ws.addEventListener(\n\t\t\t\t\"error\",\n\t\t\t\t(e) => {\n\t\t\t\t\treject(\n\t\t\t\t\t\tnew WebSocketError(\"WebSocket connection failed\", {\n\t\t\t\t\t\t\tdetails: String(e),\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\t{ once: true },\n\t\t\t);\n\n\t\t\tthis.ws.addEventListener(\"message\", (event) => {\n\t\t\t\tthis.handleMessage(event.data);\n\t\t\t});\n\n\t\t\tthis.ws.addEventListener(\"close\", () => {\n\t\t\t\tif (!this.destroyed) this.handleDisconnect();\n\t\t\t});\n\t\t});\n\t}\n\n\tprivate handleMessage(raw: string | ArrayBuffer | Blob) {\n\t\tconst data =\n\t\t\ttypeof raw === \"string\"\n\t\t\t\t? raw\n\t\t\t\t: new TextDecoder().decode(raw as ArrayBuffer);\n\n\t\tlet msg: JsonRpcResponse | JsonRpcNotification;\n\t\ttry {\n\t\t\tmsg = JSON.parse(data);\n\t\t} catch {\n\t\t\treturn;\n\t\t}\n\n\t\t// RPC response\n\t\tif (\"id\" in msg && msg.id != null) {\n\t\t\tconst rpc = msg as JsonRpcResponse;\n\t\t\tconst p = this.pending.get(rpc.id);\n\t\t\tif (!p) return;\n\t\t\tthis.pending.delete(rpc.id);\n\t\t\tif (rpc.error) {\n\t\t\t\tp.reject(\n\t\t\t\t\tnew WebSocketError(rpc.error.message, {\n\t\t\t\t\t\tdetails: `JSON-RPC error ${rpc.error.code}`,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tp.resolve(rpc.result);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// Notification\n\t\tconst notif = msg as JsonRpcNotification;\n\t\tif (!notif.method) return;\n\n\t\tfor (const [, entry] of this.subs) {\n\t\t\tif (entry.params.event === notif.method) {\n\t\t\t\tfor (const cb of entry.callbacks) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tcb(notif.params);\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// subscriber error — don't crash channel\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate handleDisconnect() {\n\t\tthis.ws = null;\n\n\t\t// reject pending RPCs\n\t\tfor (const [, p] of this.pending) {\n\t\t\tp.reject(new WebSocketError(\"WebSocket disconnected\"));\n\t\t}\n\t\tthis.pending.clear();\n\n\t\tif (\n\t\t\tthis.reconnect &&\n\t\t\tthis.subs.size > 0 &&\n\t\t\tthis.reconnectAttempt < this.reconnectMaxAttempts\n\t\t) {\n\t\t\tthis.scheduleReconnect();\n\t\t}\n\t}\n\n\tprivate scheduleReconnect() {\n\t\tif (this.destroyed || this.reconnecting) return;\n\t\tthis.reconnecting = true;\n\t\tconst delay = this.reconnectBaseDelay * 2 ** this.reconnectAttempt;\n\t\tthis.reconnectAttempt++;\n\n\t\tthis.reconnectTimer = setTimeout(async () => {\n\t\t\tthis.reconnecting = false;\n\t\t\ttry {\n\t\t\t\tawait this.connect();\n\t\t\t\tawait this.resubscribeAll();\n\t\t\t} catch {\n\t\t\t\tif (!this.destroyed && this.subs.size > 0) {\n\t\t\t\t\tthis.handleDisconnect();\n\t\t\t\t}\n\t\t\t}\n\t\t}, delay);\n\t}\n\n\tprivate async resubscribeAll() {\n\t\tfor (const [, entry] of this.subs) {\n\t\t\tawait this.sendRpc(\"subscribe\", entry.params);\n\t\t}\n\t}\n\n\tprivate sendRpc(\n\t\tmethod: string,\n\t\tparams: Record<string, unknown>,\n\t): Promise<unknown> {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tif (!this.ws || this.ws.readyState !== WebSocket.OPEN) {\n\t\t\t\treturn reject(new WebSocketError(\"WebSocket not connected\"));\n\t\t\t}\n\n\t\t\tconst id = this.nextId++;\n\t\t\tconst msg: JsonRpcRequest = {\n\t\t\t\tjsonrpc: \"2.0\",\n\t\t\t\tid,\n\t\t\t\tmethod,\n\t\t\t\tparams,\n\t\t\t};\n\n\t\t\tthis.pending.set(id, { resolve, reject });\n\t\t\tthis.ws.send(JSON.stringify(msg));\n\t\t});\n\t}\n\n\tasync subscribe(\n\t\tparams: WsSubscribeParams,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tcallback: (data: any) => void,\n\t): Promise<Subscription> {\n\t\tif (this.destroyed) {\n\t\t\tthrow new WebSocketError(\"WebSocket channel has been destroyed\");\n\t\t}\n\n\t\tawait this.connect();\n\n\t\tconst key = subKey(params);\n\t\tlet entry = this.subs.get(key);\n\n\t\tif (entry) {\n\t\t\t// Dedup: reuse existing WS subscription\n\t\t\tentry.callbacks.add(callback);\n\t\t} else {\n\t\t\t// New WS subscription\n\t\t\tentry = { params, callbacks: new Set([callback]) };\n\t\t\tthis.subs.set(key, entry);\n\t\t\tawait this.sendRpc(\"subscribe\", params);\n\t\t}\n\n\t\treturn {\n\t\t\tunsubscribe: () => {\n\t\t\t\tconst e = this.subs.get(key);\n\t\t\t\tif (!e) return;\n\t\t\t\te.callbacks.delete(callback);\n\t\t\t\tif (e.callbacks.size === 0) {\n\t\t\t\t\tthis.subs.delete(key);\n\t\t\t\t\t// Best-effort unsubscribe RPC\n\t\t\t\t\tif (this.ws?.readyState === WebSocket.OPEN) {\n\t\t\t\t\t\tthis.sendRpc(\"unsubscribe\", params).catch(() => {});\n\t\t\t\t\t}\n\t\t\t\t\t// Auto-close when no subscribers remain\n\t\t\t\t\tif (this.subs.size === 0) this.closeQuietly();\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate closeQuietly() {\n\t\tif (this.ws) {\n\t\t\tthis.ws.close();\n\t\t\tthis.ws = null;\n\t\t}\n\t}\n\n\tdestroy(): void {\n\t\tthis.destroyed = true;\n\t\tif (this.reconnectTimer) clearTimeout(this.reconnectTimer);\n\n\t\tfor (const [, p] of this.pending) {\n\t\t\tp.reject(new WebSocketError(\"WebSocket channel destroyed\"));\n\t\t}\n\t\tthis.pending.clear();\n\t\tthis.subs.clear();\n\n\t\tif (this.ws) {\n\t\t\tthis.ws.close();\n\t\t\tthis.ws = null;\n\t\t}\n\t}\n}\n\nfunction deriveWsUrl(httpUrl: string): string {\n\treturn `${httpUrl.replace(/^http/, \"ws\").replace(/\\/$/, \"\")}/extended/v1/ws`;\n}\n\n/**\n * Create a WebSocket transport for real-time Stacks event subscriptions.\n * HTTP requests use the resolved RPC URL; subscriptions use the WS endpoint.\n */\nexport function webSocket(\n\turl?: string,\n\tconfig?: WebSocketTransportConfig,\n): TransportFactory {\n\treturn (params) => {\n\t\tconst httpUrl =\n\t\t\tconfig?.url ??\n\t\t\tparams?.chain?.rpcUrls.default.http[0] ??\n\t\t\t\"http://localhost:3999\";\n\n\t\tconst wsUrl =\n\t\t\turl ?? params?.chain?.rpcUrls.default.ws?.[0] ?? deriveWsUrl(httpUrl);\n\n\t\tconst resolvedHttpConfig: TransportConfig = {\n\t\t\t...config,\n\t\t\turl: httpUrl,\n\t\t};\n\n\t\tconst channel = new WebSocketChannel(wsUrl, config);\n\n\t\tconst transport: WebSocketTransport = {\n\t\t\ttype: \"webSocket\",\n\t\t\trequest: buildRequestFn(httpUrl, resolvedHttpConfig),\n\t\t\tconfig: resolvedHttpConfig,\n\t\t\tsubscribe: (subParams, callback) =>\n\t\t\t\tchannel.subscribe(subParams, callback),\n\t\t\tdestroy: () => channel.destroy(),\n\t\t};\n\n\t\treturn transport;\n\t};\n}\n",
|
|
17
|
-
"/**\n * Filter specs for `@secondlayer/sdk` subscriptions.\n *\n * Each `on.*` factory in this directory binds typed filter clauses to a\n * known table shape and returns a `SubscriptionFilterSpec`. Spread it into\n * a full subscription input alongside `name`, `url`, `format`, etc:\n *\n * const spec = on.transferTo(\n * { subgraph: \"my-watcher\", table: \"transfers\" },\n * \"SP1ABC...\",\n * );\n * await sdk.subscriptions.create({\n * ...spec,\n * name: \"watch-incoming\",\n * url: \"https://my-app.com/webhook\",\n * });\n *\n * The user supplies which subgraph + table to bind against — these factories\n * don't assume Foundation Datasets are subscribable. To watch FT transfers\n * to an address, build a subgraph with a `transfers` table (see\n * `sl subgraphs
|
|
18
|
-
"import {\n\ttype FactoryTarget,\n\ttype SubscriptionFilterSpec,\n\tmakeSpec,\n} from \"./spec.ts\";\n\nexport type BnsAction =\n\t| \"new-name\"\n\t| \"transfer-name\"\n\t| \"renew-name\"\n\t| \"burn-name\"\n\t| \"new-airdrop\";\n\n/**\n * Match BNS-V2 name lifecycle events.\n *\n * Bind against a subgraph table that mirrors the `bns_name_events` shape\n * (topic, namespace, name, owner, ...). Easiest path: scaffold via\n * `sl subgraphs
|
|
19
|
-
"import {\n\ttype FactoryTarget,\n\ttype SubscriptionFilterSpec,\n\tmakeSpec,\n} from \"./spec.ts\";\n\nexport type PoxFunction =\n\t| \"stack-stx\"\n\t| \"stack-extend\"\n\t| \"stack-increase\"\n\t| \"delegate-stx\"\n\t| \"revoke-delegate-stx\"\n\t| \"delegate-stack-stx\"\n\t| \"delegate-stack-extend\"\n\t| \"delegate-stack-increase\"\n\t| \"stack-aggregation-commit\"\n\t| \"stack-aggregation-commit-indexed\"\n\t| \"stack-aggregation-increase\"\n\t| \"set-signer-key-authorization\";\n\n/**\n * Match PoX-4 stacking calls. Bind against a subgraph table mirroring\n * `pox4_calls` (function_name, stacker, caller, ...). Scaffold via\n * `sl subgraphs
|
|
20
|
-
"import {\n\ttype FactoryTarget,\n\ttype SubscriptionFilterSpec,\n\tmakeSpec,\n} from \"./spec.ts\";\n\n/**\n * Match sBTC deposit completion events. Bind against a subgraph table\n * mirroring `sbtc_events` (topic, amount, sender, bitcoin_txid, ...).\n * Scaffold via `sl subgraphs
|
|
17
|
+
"/**\n * Filter specs for `@secondlayer/sdk` subscriptions.\n *\n * Each `on.*` factory in this directory binds typed filter clauses to a\n * known table shape and returns a `SubscriptionFilterSpec`. Spread it into\n * a full subscription input alongside `name`, `url`, `format`, etc:\n *\n * const spec = on.transferTo(\n * { subgraph: \"my-watcher\", table: \"transfers\" },\n * \"SP1ABC...\",\n * );\n * await sdk.subscriptions.create({\n * ...spec,\n * name: \"watch-incoming\",\n * url: \"https://my-app.com/webhook\",\n * });\n *\n * The user supplies which subgraph + table to bind against — these factories\n * don't assume Foundation Datasets are subscribable. To watch FT transfers\n * to an address, build a subgraph with a `transfers` table (see\n * `sl subgraphs create --template sip-010-balances`) and bind here.\n */\n\n/**\n * What every factory takes as its first arg: which user-owned subgraph table\n * to filter against.\n */\nexport type FactoryTarget = {\n\tsubgraph: string;\n\ttable: string;\n};\n\n/**\n * A primitive value that can appear in a filter clause.\n * Mirrors `SubscriptionFilterPrimitive` in\n * `@secondlayer/shared/schemas/subscriptions` — duplicated here to keep\n * `@secondlayer/stacks` from importing the api/server schema package.\n */\nexport type FilterPrimitive = string | number | boolean;\n\n/** Operator forms a filter clause can take. */\nexport type FilterOperator =\n\t| { eq: FilterPrimitive }\n\t| { neq: FilterPrimitive }\n\t| { gt: string | number }\n\t| { gte: string | number }\n\t| { lt: string | number }\n\t| { lte: string | number }\n\t| { in: FilterPrimitive[] };\n\n/** A single column's filter: bare value (eq) or operator object. */\nexport type FilterClause = FilterPrimitive | FilterOperator;\n\n/** Map of column → filter clause. Empty `{}` matches every row. */\nexport type Filter = Record<string, FilterClause>;\n\n/**\n * Output of every `on.*` factory. Use directly as a partial input to\n * `sdk.subscriptions.create` — the SDK's existing `CreateSubscriptionRequest`\n * already accepts these three fields.\n */\nexport type SubscriptionFilterSpec = {\n\tsubgraphName: string;\n\ttableName: string;\n\tfilter: Filter;\n};\n\n/** Thin helper to build a spec without restating the field-name mapping. */\nexport function makeSpec(\n\ttarget: FactoryTarget,\n\tfilter: Filter,\n): SubscriptionFilterSpec {\n\treturn {\n\t\tsubgraphName: target.subgraph,\n\t\ttableName: target.table,\n\t\tfilter,\n\t};\n}\n",
|
|
18
|
+
"import {\n\ttype FactoryTarget,\n\ttype SubscriptionFilterSpec,\n\tmakeSpec,\n} from \"./spec.ts\";\n\nexport type BnsAction =\n\t| \"new-name\"\n\t| \"transfer-name\"\n\t| \"renew-name\"\n\t| \"burn-name\"\n\t| \"new-airdrop\";\n\n/**\n * Match BNS-V2 name lifecycle events.\n *\n * Bind against a subgraph table that mirrors the `bns_name_events` shape\n * (topic, namespace, name, owner, ...). Easiest path: scaffold via\n * `sl subgraphs create --template bns-names`.\n *\n * @param action restrict to one topic; omit to fire on every name event\n */\nexport function bnsName(\n\ttarget: FactoryTarget,\n\taction?: BnsAction,\n\topts?: { namespace?: string; owner?: string },\n): SubscriptionFilterSpec {\n\treturn makeSpec(target, {\n\t\t...(action && { topic: action }),\n\t\t...(opts?.namespace && { namespace: opts.namespace }),\n\t\t...(opts?.owner && { owner: opts.owner }),\n\t});\n}\n",
|
|
19
|
+
"import {\n\ttype FactoryTarget,\n\ttype SubscriptionFilterSpec,\n\tmakeSpec,\n} from \"./spec.ts\";\n\nexport type PoxFunction =\n\t| \"stack-stx\"\n\t| \"stack-extend\"\n\t| \"stack-increase\"\n\t| \"delegate-stx\"\n\t| \"revoke-delegate-stx\"\n\t| \"delegate-stack-stx\"\n\t| \"delegate-stack-extend\"\n\t| \"delegate-stack-increase\"\n\t| \"stack-aggregation-commit\"\n\t| \"stack-aggregation-commit-indexed\"\n\t| \"stack-aggregation-increase\"\n\t| \"set-signer-key-authorization\";\n\n/**\n * Match PoX-4 stacking calls. Bind against a subgraph table mirroring\n * `pox4_calls` (function_name, stacker, caller, ...). Scaffold via\n * `sl subgraphs create --template pox-stacking`.\n *\n * @param fn restrict to one PoX-4 function; omit to fire on every call\n */\nexport function poxStack(\n\ttarget: FactoryTarget,\n\tfn?: PoxFunction,\n\topts?: { stacker?: string; signerKey?: string },\n): SubscriptionFilterSpec {\n\treturn makeSpec(target, {\n\t\t...(fn && { function_name: fn }),\n\t\t...(opts?.stacker && { stacker: opts.stacker }),\n\t\t...(opts?.signerKey && { signer_key: opts.signerKey }),\n\t});\n}\n",
|
|
20
|
+
"import {\n\ttype FactoryTarget,\n\ttype SubscriptionFilterSpec,\n\tmakeSpec,\n} from \"./spec.ts\";\n\n/**\n * Match sBTC deposit completion events. Bind against a subgraph table\n * mirroring `sbtc_events` (topic, amount, sender, bitcoin_txid, ...).\n * Scaffold via `sl subgraphs create --template sbtc-flows`.\n */\nexport function sbtcDeposit(\n\ttarget: FactoryTarget,\n\topts?: { sender?: string; bitcoinTxid?: string },\n): SubscriptionFilterSpec {\n\treturn makeSpec(target, {\n\t\ttopic: \"completed-deposit\",\n\t\t...(opts?.sender && { sender: opts.sender }),\n\t\t...(opts?.bitcoinTxid && { bitcoin_txid: opts.bitcoinTxid }),\n\t});\n}\n\n/**\n * Match sBTC withdrawal lifecycle events. Phase defaults to all three\n * (`create` / `accept` / `reject`); pass an explicit `phase` to narrow.\n */\nexport function sbtcWithdrawal(\n\ttarget: FactoryTarget,\n\topts?: {\n\t\tphase?: \"create\" | \"accept\" | \"reject\";\n\t\tsender?: string;\n\t\trequestId?: number;\n\t},\n): SubscriptionFilterSpec {\n\treturn makeSpec(target, {\n\t\ttopic: opts?.phase\n\t\t\t? { eq: `withdrawal-${opts.phase}` }\n\t\t\t: { in: [\"withdrawal-create\", \"withdrawal-accept\", \"withdrawal-reject\"] },\n\t\t...(opts?.sender && { sender: opts.sender }),\n\t\t...(opts?.requestId !== undefined && { request_id: opts.requestId }),\n\t});\n}\n",
|
|
21
21
|
"import {\n\ttype FactoryTarget,\n\ttype SubscriptionFilterSpec,\n\tmakeSpec,\n} from \"./spec.ts\";\n\n/**\n * Match transfer events into a recipient address.\n *\n * Works against any subgraph table that has a `recipient` column (and\n * optionally `asset_identifier`). Templates that scaffold this shape:\n * `sip-010-balances`, `sbtc-flows`.\n *\n * @param target the user's subgraph + table to bind against\n * @param recipient stx principal that should receive the transfer\n * @param opts.asset optional asset identifier (e.g. `\"SP1...usdc::usdc-token\"`)\n * to filter to a specific FT/NFT contract\n */\nexport function transferTo(\n\ttarget: FactoryTarget,\n\trecipient: string,\n\topts?: { asset?: string },\n): SubscriptionFilterSpec {\n\treturn makeSpec(target, {\n\t\trecipient,\n\t\t...(opts?.asset && { asset_identifier: opts.asset }),\n\t});\n}\n\n/**\n * SIP-010 (fungible token) transfer sugar — alias for `transferTo` that\n * makes the asset filter intent explicit at the call site. Same backing\n * filter; the `asset` param is optional (omit to match every SIP-010\n * transfer in the bound table).\n */\nexport function sip010Transfer(\n\ttarget: FactoryTarget,\n\tasset?: string,\n\topts?: { recipient?: string },\n): SubscriptionFilterSpec {\n\treturn makeSpec(target, {\n\t\t...(asset && { asset_identifier: asset }),\n\t\t...(opts?.recipient && { recipient: opts.recipient }),\n\t});\n}\n\n/**\n * SIP-009 (non-fungible token) transfer sugar — same pattern as\n * `sip010Transfer`. Bind against an NFT-shaped table (see template\n * `nft-transfers` if/when published).\n */\nexport function sip009Transfer(\n\ttarget: FactoryTarget,\n\tasset?: string,\n\topts?: { recipient?: string; tokenId?: string | number },\n): SubscriptionFilterSpec {\n\treturn makeSpec(target, {\n\t\t...(asset && { asset_identifier: asset }),\n\t\t...(opts?.recipient && { recipient: opts.recipient }),\n\t\t...(opts?.tokenId !== undefined && { token_id: String(opts.tokenId) }),\n\t});\n}\n",
|
|
22
22
|
"import { BaseError } from \"./base.ts\";\n\nexport class ContractCallError extends BaseError {\n\toverride name = \"ContractCallError\";\n}\n\nexport class ReadOnlyCallError extends BaseError {\n\toverride name = \"ReadOnlyCallError\";\n}\n"
|
|
23
23
|
],
|
package/dist/src/index.d.cts
CHANGED
|
@@ -867,7 +867,7 @@ declare namespace exports_on {
|
|
|
867
867
|
* The user supplies which subgraph + table to bind against — these factories
|
|
868
868
|
* don't assume Foundation Datasets are subscribable. To watch FT transfers
|
|
869
869
|
* to an address, build a subgraph with a `transfers` table (see
|
|
870
|
-
* `sl subgraphs
|
|
870
|
+
* `sl subgraphs create --template sip-010-balances`) and bind here.
|
|
871
871
|
*/
|
|
872
872
|
/**
|
|
873
873
|
* What every factory takes as its first arg: which user-owned subgraph table
|
|
@@ -922,7 +922,7 @@ type BnsAction = "new-name" | "transfer-name" | "renew-name" | "burn-name" | "ne
|
|
|
922
922
|
*
|
|
923
923
|
* Bind against a subgraph table that mirrors the `bns_name_events` shape
|
|
924
924
|
* (topic, namespace, name, owner, ...). Easiest path: scaffold via
|
|
925
|
-
* `sl subgraphs
|
|
925
|
+
* `sl subgraphs create --template bns-names`.
|
|
926
926
|
*
|
|
927
927
|
* @param action restrict to one topic; omit to fire on every name event
|
|
928
928
|
*/
|
|
@@ -934,7 +934,7 @@ type PoxFunction = "stack-stx" | "stack-extend" | "stack-increase" | "delegate-s
|
|
|
934
934
|
/**
|
|
935
935
|
* Match PoX-4 stacking calls. Bind against a subgraph table mirroring
|
|
936
936
|
* `pox4_calls` (function_name, stacker, caller, ...). Scaffold via
|
|
937
|
-
* `sl subgraphs
|
|
937
|
+
* `sl subgraphs create --template pox-stacking`.
|
|
938
938
|
*
|
|
939
939
|
* @param fn restrict to one PoX-4 function; omit to fire on every call
|
|
940
940
|
*/
|
|
@@ -945,7 +945,7 @@ declare function poxStack(target: FactoryTarget, fn?: PoxFunction, opts?: {
|
|
|
945
945
|
/**
|
|
946
946
|
* Match sBTC deposit completion events. Bind against a subgraph table
|
|
947
947
|
* mirroring `sbtc_events` (topic, amount, sender, bitcoin_txid, ...).
|
|
948
|
-
* Scaffold via `sl subgraphs
|
|
948
|
+
* Scaffold via `sl subgraphs create --template sbtc-flows`.
|
|
949
949
|
*/
|
|
950
950
|
declare function sbtcDeposit(target: FactoryTarget, opts?: {
|
|
951
951
|
sender?: string
|
package/dist/src/index.d.ts
CHANGED
|
@@ -867,7 +867,7 @@ declare namespace exports_on {
|
|
|
867
867
|
* The user supplies which subgraph + table to bind against — these factories
|
|
868
868
|
* don't assume Foundation Datasets are subscribable. To watch FT transfers
|
|
869
869
|
* to an address, build a subgraph with a `transfers` table (see
|
|
870
|
-
* `sl subgraphs
|
|
870
|
+
* `sl subgraphs create --template sip-010-balances`) and bind here.
|
|
871
871
|
*/
|
|
872
872
|
/**
|
|
873
873
|
* What every factory takes as its first arg: which user-owned subgraph table
|
|
@@ -922,7 +922,7 @@ type BnsAction = "new-name" | "transfer-name" | "renew-name" | "burn-name" | "ne
|
|
|
922
922
|
*
|
|
923
923
|
* Bind against a subgraph table that mirrors the `bns_name_events` shape
|
|
924
924
|
* (topic, namespace, name, owner, ...). Easiest path: scaffold via
|
|
925
|
-
* `sl subgraphs
|
|
925
|
+
* `sl subgraphs create --template bns-names`.
|
|
926
926
|
*
|
|
927
927
|
* @param action restrict to one topic; omit to fire on every name event
|
|
928
928
|
*/
|
|
@@ -934,7 +934,7 @@ type PoxFunction = "stack-stx" | "stack-extend" | "stack-increase" | "delegate-s
|
|
|
934
934
|
/**
|
|
935
935
|
* Match PoX-4 stacking calls. Bind against a subgraph table mirroring
|
|
936
936
|
* `pox4_calls` (function_name, stacker, caller, ...). Scaffold via
|
|
937
|
-
* `sl subgraphs
|
|
937
|
+
* `sl subgraphs create --template pox-stacking`.
|
|
938
938
|
*
|
|
939
939
|
* @param fn restrict to one PoX-4 function; omit to fire on every call
|
|
940
940
|
*/
|
|
@@ -945,7 +945,7 @@ declare function poxStack(target: FactoryTarget, fn?: PoxFunction, opts?: {
|
|
|
945
945
|
/**
|
|
946
946
|
* Match sBTC deposit completion events. Bind against a subgraph table
|
|
947
947
|
* mirroring `sbtc_events` (topic, amount, sender, bitcoin_txid, ...).
|
|
948
|
-
* Scaffold via `sl subgraphs
|
|
948
|
+
* Scaffold via `sl subgraphs create --template sbtc-flows`.
|
|
949
949
|
*/
|
|
950
950
|
declare function sbtcDeposit(target: FactoryTarget, opts?: {
|
|
951
951
|
sender?: string
|
package/dist/src/index.js.map
CHANGED
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"import { createTransport } from \"./createTransport.ts\";\nimport type { RequestFn, TransportFactory } from \"./types.ts\";\n\n/** Create a transport backed by a user-provided request function. */\nexport function custom(params: { request: RequestFn }): TransportFactory {\n\treturn () => createTransport(\"custom\", { request: params.request });\n}\n",
|
|
15
15
|
"import { createTransport } from \"./createTransport.ts\";\nimport type { TransportFactory } from \"./types.ts\";\n\n/** Create a transport that tries each transport in order until one succeeds. */\nexport function fallback(transports: TransportFactory[]): TransportFactory {\n\treturn (params) => {\n\t\tconst resolved = transports.map((t) => t(params));\n\n\t\treturn createTransport(\"fallback\", {\n\t\t\trequest: async (path, options) => {\n\t\t\t\tlet lastError: Error | undefined;\n\t\t\t\tfor (const transport of resolved) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\treturn await transport.request(path, options);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tlastError =\n\t\t\t\t\t\t\terror instanceof Error ? error : new Error(String(error));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthrow lastError ?? new Error(\"All transports failed\");\n\t\t\t},\n\t\t});\n\t};\n}\n",
|
|
16
16
|
"import { WebSocketError } from \"../errors/websocket.ts\";\nimport type {\n\tSubscription,\n\tWsSubscribeParams,\n} from \"../subscriptions/types.ts\";\nimport { buildRequestFn } from \"./createTransport.ts\";\nimport type { Transport, TransportConfig, TransportFactory } from \"./types.ts\";\n\n/** Configuration for the WebSocket transport, extending base {@link TransportConfig}. */\nexport type WebSocketTransportConfig = TransportConfig & {\n\t/** WebSocket URL (resolved from chain if omitted) */\n\turl?: string;\n\t/** Enable auto-reconnect (default: true) */\n\treconnect?: boolean;\n\t/** Max reconnect attempts (default: 10) */\n\treconnectMaxAttempts?: number;\n\t/** Base delay in ms for exponential backoff (default: 1000) */\n\treconnectBaseDelay?: number;\n};\n\n/** Transport with WebSocket subscription capabilities and auto-reconnect. */\nexport type WebSocketTransport = Transport & {\n\ttype: \"webSocket\";\n\tsubscribe: (\n\t\tparams: WsSubscribeParams,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tcallback: (data: any) => void,\n\t) => Promise<Subscription>;\n\tdestroy: () => void;\n};\n\ntype JsonRpcRequest = {\n\tjsonrpc: \"2.0\";\n\tid: number;\n\tmethod: string;\n\tparams: Record<string, unknown>;\n};\n\ntype JsonRpcResponse = {\n\tjsonrpc: \"2.0\";\n\tid: number;\n\tresult?: unknown;\n\terror?: { code: number; message: string };\n};\n\ntype JsonRpcNotification = {\n\tjsonrpc: \"2.0\";\n\tmethod: string;\n\tparams: unknown;\n};\n\ntype SubEntry = {\n\tparams: WsSubscribeParams;\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\tcallbacks: Set<(data: any) => void>;\n};\n\nfunction subKey(params: WsSubscribeParams): string {\n\tconst parts: string[] = [params.event];\n\tif (params.tx_id) parts.push(`tx_id:${params.tx_id}`);\n\tif (params.address) parts.push(`address:${params.address}`);\n\tif (params.asset_identifier) parts.push(`asset:${params.asset_identifier}`);\n\tif (params.value) parts.push(`value:${params.value}`);\n\treturn parts.join(\"|\");\n}\n\nexport class WebSocketChannel {\n\tprivate ws: WebSocket | null = null;\n\tprivate url: string;\n\tprivate nextId = 1;\n\tprivate pending = new Map<\n\t\tnumber,\n\t\t{ resolve: (v: unknown) => void; reject: (e: Error) => void }\n\t>();\n\tprivate subs = new Map<string, SubEntry>();\n\tprivate destroyed = false;\n\tprivate reconnecting = false;\n\tprivate reconnectAttempt = 0;\n\tprivate reconnectTimer: ReturnType<typeof setTimeout> | null = null;\n\n\tprivate reconnect: boolean;\n\tprivate reconnectMaxAttempts: number;\n\tprivate reconnectBaseDelay: number;\n\n\tconstructor(url: string, config?: WebSocketTransportConfig) {\n\t\tthis.url = url;\n\t\tthis.reconnect = config?.reconnect ?? true;\n\t\tthis.reconnectMaxAttempts = config?.reconnectMaxAttempts ?? 10;\n\t\tthis.reconnectBaseDelay = config?.reconnectBaseDelay ?? 1000;\n\t}\n\n\tprivate connect(): Promise<void> {\n\t\tif (this.ws?.readyState === WebSocket.OPEN) return Promise.resolve();\n\t\tif (this.ws?.readyState === WebSocket.CONNECTING) {\n\t\t\treturn new Promise((resolve, reject) => {\n\t\t\t\tconst onOpen = () => {\n\t\t\t\t\tthis.ws?.removeEventListener(\"error\", onError);\n\t\t\t\t\tresolve();\n\t\t\t\t};\n\t\t\t\tconst onError = (e: Event) => {\n\t\t\t\t\tthis.ws?.removeEventListener(\"open\", onOpen);\n\t\t\t\t\treject(\n\t\t\t\t\t\tnew WebSocketError(\"WebSocket connection failed\", {\n\t\t\t\t\t\t\tdetails: String(e),\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t\tthis.ws?.addEventListener(\"open\", onOpen, { once: true });\n\t\t\t\tthis.ws?.addEventListener(\"error\", onError, { once: true });\n\t\t\t});\n\t\t}\n\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tthis.ws = new WebSocket(this.url);\n\n\t\t\tthis.ws.addEventListener(\n\t\t\t\t\"open\",\n\t\t\t\t() => {\n\t\t\t\t\tthis.reconnectAttempt = 0;\n\t\t\t\t\tthis.reconnecting = false;\n\t\t\t\t\tresolve();\n\t\t\t\t},\n\t\t\t\t{ once: true },\n\t\t\t);\n\n\t\t\tthis.ws.addEventListener(\n\t\t\t\t\"error\",\n\t\t\t\t(e) => {\n\t\t\t\t\treject(\n\t\t\t\t\t\tnew WebSocketError(\"WebSocket connection failed\", {\n\t\t\t\t\t\t\tdetails: String(e),\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\t{ once: true },\n\t\t\t);\n\n\t\t\tthis.ws.addEventListener(\"message\", (event) => {\n\t\t\t\tthis.handleMessage(event.data);\n\t\t\t});\n\n\t\t\tthis.ws.addEventListener(\"close\", () => {\n\t\t\t\tif (!this.destroyed) this.handleDisconnect();\n\t\t\t});\n\t\t});\n\t}\n\n\tprivate handleMessage(raw: string | ArrayBuffer | Blob) {\n\t\tconst data =\n\t\t\ttypeof raw === \"string\"\n\t\t\t\t? raw\n\t\t\t\t: new TextDecoder().decode(raw as ArrayBuffer);\n\n\t\tlet msg: JsonRpcResponse | JsonRpcNotification;\n\t\ttry {\n\t\t\tmsg = JSON.parse(data);\n\t\t} catch {\n\t\t\treturn;\n\t\t}\n\n\t\t// RPC response\n\t\tif (\"id\" in msg && msg.id != null) {\n\t\t\tconst rpc = msg as JsonRpcResponse;\n\t\t\tconst p = this.pending.get(rpc.id);\n\t\t\tif (!p) return;\n\t\t\tthis.pending.delete(rpc.id);\n\t\t\tif (rpc.error) {\n\t\t\t\tp.reject(\n\t\t\t\t\tnew WebSocketError(rpc.error.message, {\n\t\t\t\t\t\tdetails: `JSON-RPC error ${rpc.error.code}`,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tp.resolve(rpc.result);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// Notification\n\t\tconst notif = msg as JsonRpcNotification;\n\t\tif (!notif.method) return;\n\n\t\tfor (const [, entry] of this.subs) {\n\t\t\tif (entry.params.event === notif.method) {\n\t\t\t\tfor (const cb of entry.callbacks) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tcb(notif.params);\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// subscriber error — don't crash channel\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate handleDisconnect() {\n\t\tthis.ws = null;\n\n\t\t// reject pending RPCs\n\t\tfor (const [, p] of this.pending) {\n\t\t\tp.reject(new WebSocketError(\"WebSocket disconnected\"));\n\t\t}\n\t\tthis.pending.clear();\n\n\t\tif (\n\t\t\tthis.reconnect &&\n\t\t\tthis.subs.size > 0 &&\n\t\t\tthis.reconnectAttempt < this.reconnectMaxAttempts\n\t\t) {\n\t\t\tthis.scheduleReconnect();\n\t\t}\n\t}\n\n\tprivate scheduleReconnect() {\n\t\tif (this.destroyed || this.reconnecting) return;\n\t\tthis.reconnecting = true;\n\t\tconst delay = this.reconnectBaseDelay * 2 ** this.reconnectAttempt;\n\t\tthis.reconnectAttempt++;\n\n\t\tthis.reconnectTimer = setTimeout(async () => {\n\t\t\tthis.reconnecting = false;\n\t\t\ttry {\n\t\t\t\tawait this.connect();\n\t\t\t\tawait this.resubscribeAll();\n\t\t\t} catch {\n\t\t\t\tif (!this.destroyed && this.subs.size > 0) {\n\t\t\t\t\tthis.handleDisconnect();\n\t\t\t\t}\n\t\t\t}\n\t\t}, delay);\n\t}\n\n\tprivate async resubscribeAll() {\n\t\tfor (const [, entry] of this.subs) {\n\t\t\tawait this.sendRpc(\"subscribe\", entry.params);\n\t\t}\n\t}\n\n\tprivate sendRpc(\n\t\tmethod: string,\n\t\tparams: Record<string, unknown>,\n\t): Promise<unknown> {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tif (!this.ws || this.ws.readyState !== WebSocket.OPEN) {\n\t\t\t\treturn reject(new WebSocketError(\"WebSocket not connected\"));\n\t\t\t}\n\n\t\t\tconst id = this.nextId++;\n\t\t\tconst msg: JsonRpcRequest = {\n\t\t\t\tjsonrpc: \"2.0\",\n\t\t\t\tid,\n\t\t\t\tmethod,\n\t\t\t\tparams,\n\t\t\t};\n\n\t\t\tthis.pending.set(id, { resolve, reject });\n\t\t\tthis.ws.send(JSON.stringify(msg));\n\t\t});\n\t}\n\n\tasync subscribe(\n\t\tparams: WsSubscribeParams,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tcallback: (data: any) => void,\n\t): Promise<Subscription> {\n\t\tif (this.destroyed) {\n\t\t\tthrow new WebSocketError(\"WebSocket channel has been destroyed\");\n\t\t}\n\n\t\tawait this.connect();\n\n\t\tconst key = subKey(params);\n\t\tlet entry = this.subs.get(key);\n\n\t\tif (entry) {\n\t\t\t// Dedup: reuse existing WS subscription\n\t\t\tentry.callbacks.add(callback);\n\t\t} else {\n\t\t\t// New WS subscription\n\t\t\tentry = { params, callbacks: new Set([callback]) };\n\t\t\tthis.subs.set(key, entry);\n\t\t\tawait this.sendRpc(\"subscribe\", params);\n\t\t}\n\n\t\treturn {\n\t\t\tunsubscribe: () => {\n\t\t\t\tconst e = this.subs.get(key);\n\t\t\t\tif (!e) return;\n\t\t\t\te.callbacks.delete(callback);\n\t\t\t\tif (e.callbacks.size === 0) {\n\t\t\t\t\tthis.subs.delete(key);\n\t\t\t\t\t// Best-effort unsubscribe RPC\n\t\t\t\t\tif (this.ws?.readyState === WebSocket.OPEN) {\n\t\t\t\t\t\tthis.sendRpc(\"unsubscribe\", params).catch(() => {});\n\t\t\t\t\t}\n\t\t\t\t\t// Auto-close when no subscribers remain\n\t\t\t\t\tif (this.subs.size === 0) this.closeQuietly();\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate closeQuietly() {\n\t\tif (this.ws) {\n\t\t\tthis.ws.close();\n\t\t\tthis.ws = null;\n\t\t}\n\t}\n\n\tdestroy(): void {\n\t\tthis.destroyed = true;\n\t\tif (this.reconnectTimer) clearTimeout(this.reconnectTimer);\n\n\t\tfor (const [, p] of this.pending) {\n\t\t\tp.reject(new WebSocketError(\"WebSocket channel destroyed\"));\n\t\t}\n\t\tthis.pending.clear();\n\t\tthis.subs.clear();\n\n\t\tif (this.ws) {\n\t\t\tthis.ws.close();\n\t\t\tthis.ws = null;\n\t\t}\n\t}\n}\n\nfunction deriveWsUrl(httpUrl: string): string {\n\treturn `${httpUrl.replace(/^http/, \"ws\").replace(/\\/$/, \"\")}/extended/v1/ws`;\n}\n\n/**\n * Create a WebSocket transport for real-time Stacks event subscriptions.\n * HTTP requests use the resolved RPC URL; subscriptions use the WS endpoint.\n */\nexport function webSocket(\n\turl?: string,\n\tconfig?: WebSocketTransportConfig,\n): TransportFactory {\n\treturn (params) => {\n\t\tconst httpUrl =\n\t\t\tconfig?.url ??\n\t\t\tparams?.chain?.rpcUrls.default.http[0] ??\n\t\t\t\"http://localhost:3999\";\n\n\t\tconst wsUrl =\n\t\t\turl ?? params?.chain?.rpcUrls.default.ws?.[0] ?? deriveWsUrl(httpUrl);\n\n\t\tconst resolvedHttpConfig: TransportConfig = {\n\t\t\t...config,\n\t\t\turl: httpUrl,\n\t\t};\n\n\t\tconst channel = new WebSocketChannel(wsUrl, config);\n\n\t\tconst transport: WebSocketTransport = {\n\t\t\ttype: \"webSocket\",\n\t\t\trequest: buildRequestFn(httpUrl, resolvedHttpConfig),\n\t\t\tconfig: resolvedHttpConfig,\n\t\t\tsubscribe: (subParams, callback) =>\n\t\t\t\tchannel.subscribe(subParams, callback),\n\t\t\tdestroy: () => channel.destroy(),\n\t\t};\n\n\t\treturn transport;\n\t};\n}\n",
|
|
17
|
-
"/**\n * Filter specs for `@secondlayer/sdk` subscriptions.\n *\n * Each `on.*` factory in this directory binds typed filter clauses to a\n * known table shape and returns a `SubscriptionFilterSpec`. Spread it into\n * a full subscription input alongside `name`, `url`, `format`, etc:\n *\n * const spec = on.transferTo(\n * { subgraph: \"my-watcher\", table: \"transfers\" },\n * \"SP1ABC...\",\n * );\n * await sdk.subscriptions.create({\n * ...spec,\n * name: \"watch-incoming\",\n * url: \"https://my-app.com/webhook\",\n * });\n *\n * The user supplies which subgraph + table to bind against — these factories\n * don't assume Foundation Datasets are subscribable. To watch FT transfers\n * to an address, build a subgraph with a `transfers` table (see\n * `sl subgraphs
|
|
18
|
-
"import {\n\ttype FactoryTarget,\n\ttype SubscriptionFilterSpec,\n\tmakeSpec,\n} from \"./spec.ts\";\n\nexport type BnsAction =\n\t| \"new-name\"\n\t| \"transfer-name\"\n\t| \"renew-name\"\n\t| \"burn-name\"\n\t| \"new-airdrop\";\n\n/**\n * Match BNS-V2 name lifecycle events.\n *\n * Bind against a subgraph table that mirrors the `bns_name_events` shape\n * (topic, namespace, name, owner, ...). Easiest path: scaffold via\n * `sl subgraphs
|
|
19
|
-
"import {\n\ttype FactoryTarget,\n\ttype SubscriptionFilterSpec,\n\tmakeSpec,\n} from \"./spec.ts\";\n\nexport type PoxFunction =\n\t| \"stack-stx\"\n\t| \"stack-extend\"\n\t| \"stack-increase\"\n\t| \"delegate-stx\"\n\t| \"revoke-delegate-stx\"\n\t| \"delegate-stack-stx\"\n\t| \"delegate-stack-extend\"\n\t| \"delegate-stack-increase\"\n\t| \"stack-aggregation-commit\"\n\t| \"stack-aggregation-commit-indexed\"\n\t| \"stack-aggregation-increase\"\n\t| \"set-signer-key-authorization\";\n\n/**\n * Match PoX-4 stacking calls. Bind against a subgraph table mirroring\n * `pox4_calls` (function_name, stacker, caller, ...). Scaffold via\n * `sl subgraphs
|
|
20
|
-
"import {\n\ttype FactoryTarget,\n\ttype SubscriptionFilterSpec,\n\tmakeSpec,\n} from \"./spec.ts\";\n\n/**\n * Match sBTC deposit completion events. Bind against a subgraph table\n * mirroring `sbtc_events` (topic, amount, sender, bitcoin_txid, ...).\n * Scaffold via `sl subgraphs
|
|
17
|
+
"/**\n * Filter specs for `@secondlayer/sdk` subscriptions.\n *\n * Each `on.*` factory in this directory binds typed filter clauses to a\n * known table shape and returns a `SubscriptionFilterSpec`. Spread it into\n * a full subscription input alongside `name`, `url`, `format`, etc:\n *\n * const spec = on.transferTo(\n * { subgraph: \"my-watcher\", table: \"transfers\" },\n * \"SP1ABC...\",\n * );\n * await sdk.subscriptions.create({\n * ...spec,\n * name: \"watch-incoming\",\n * url: \"https://my-app.com/webhook\",\n * });\n *\n * The user supplies which subgraph + table to bind against — these factories\n * don't assume Foundation Datasets are subscribable. To watch FT transfers\n * to an address, build a subgraph with a `transfers` table (see\n * `sl subgraphs create --template sip-010-balances`) and bind here.\n */\n\n/**\n * What every factory takes as its first arg: which user-owned subgraph table\n * to filter against.\n */\nexport type FactoryTarget = {\n\tsubgraph: string;\n\ttable: string;\n};\n\n/**\n * A primitive value that can appear in a filter clause.\n * Mirrors `SubscriptionFilterPrimitive` in\n * `@secondlayer/shared/schemas/subscriptions` — duplicated here to keep\n * `@secondlayer/stacks` from importing the api/server schema package.\n */\nexport type FilterPrimitive = string | number | boolean;\n\n/** Operator forms a filter clause can take. */\nexport type FilterOperator =\n\t| { eq: FilterPrimitive }\n\t| { neq: FilterPrimitive }\n\t| { gt: string | number }\n\t| { gte: string | number }\n\t| { lt: string | number }\n\t| { lte: string | number }\n\t| { in: FilterPrimitive[] };\n\n/** A single column's filter: bare value (eq) or operator object. */\nexport type FilterClause = FilterPrimitive | FilterOperator;\n\n/** Map of column → filter clause. Empty `{}` matches every row. */\nexport type Filter = Record<string, FilterClause>;\n\n/**\n * Output of every `on.*` factory. Use directly as a partial input to\n * `sdk.subscriptions.create` — the SDK's existing `CreateSubscriptionRequest`\n * already accepts these three fields.\n */\nexport type SubscriptionFilterSpec = {\n\tsubgraphName: string;\n\ttableName: string;\n\tfilter: Filter;\n};\n\n/** Thin helper to build a spec without restating the field-name mapping. */\nexport function makeSpec(\n\ttarget: FactoryTarget,\n\tfilter: Filter,\n): SubscriptionFilterSpec {\n\treturn {\n\t\tsubgraphName: target.subgraph,\n\t\ttableName: target.table,\n\t\tfilter,\n\t};\n}\n",
|
|
18
|
+
"import {\n\ttype FactoryTarget,\n\ttype SubscriptionFilterSpec,\n\tmakeSpec,\n} from \"./spec.ts\";\n\nexport type BnsAction =\n\t| \"new-name\"\n\t| \"transfer-name\"\n\t| \"renew-name\"\n\t| \"burn-name\"\n\t| \"new-airdrop\";\n\n/**\n * Match BNS-V2 name lifecycle events.\n *\n * Bind against a subgraph table that mirrors the `bns_name_events` shape\n * (topic, namespace, name, owner, ...). Easiest path: scaffold via\n * `sl subgraphs create --template bns-names`.\n *\n * @param action restrict to one topic; omit to fire on every name event\n */\nexport function bnsName(\n\ttarget: FactoryTarget,\n\taction?: BnsAction,\n\topts?: { namespace?: string; owner?: string },\n): SubscriptionFilterSpec {\n\treturn makeSpec(target, {\n\t\t...(action && { topic: action }),\n\t\t...(opts?.namespace && { namespace: opts.namespace }),\n\t\t...(opts?.owner && { owner: opts.owner }),\n\t});\n}\n",
|
|
19
|
+
"import {\n\ttype FactoryTarget,\n\ttype SubscriptionFilterSpec,\n\tmakeSpec,\n} from \"./spec.ts\";\n\nexport type PoxFunction =\n\t| \"stack-stx\"\n\t| \"stack-extend\"\n\t| \"stack-increase\"\n\t| \"delegate-stx\"\n\t| \"revoke-delegate-stx\"\n\t| \"delegate-stack-stx\"\n\t| \"delegate-stack-extend\"\n\t| \"delegate-stack-increase\"\n\t| \"stack-aggregation-commit\"\n\t| \"stack-aggregation-commit-indexed\"\n\t| \"stack-aggregation-increase\"\n\t| \"set-signer-key-authorization\";\n\n/**\n * Match PoX-4 stacking calls. Bind against a subgraph table mirroring\n * `pox4_calls` (function_name, stacker, caller, ...). Scaffold via\n * `sl subgraphs create --template pox-stacking`.\n *\n * @param fn restrict to one PoX-4 function; omit to fire on every call\n */\nexport function poxStack(\n\ttarget: FactoryTarget,\n\tfn?: PoxFunction,\n\topts?: { stacker?: string; signerKey?: string },\n): SubscriptionFilterSpec {\n\treturn makeSpec(target, {\n\t\t...(fn && { function_name: fn }),\n\t\t...(opts?.stacker && { stacker: opts.stacker }),\n\t\t...(opts?.signerKey && { signer_key: opts.signerKey }),\n\t});\n}\n",
|
|
20
|
+
"import {\n\ttype FactoryTarget,\n\ttype SubscriptionFilterSpec,\n\tmakeSpec,\n} from \"./spec.ts\";\n\n/**\n * Match sBTC deposit completion events. Bind against a subgraph table\n * mirroring `sbtc_events` (topic, amount, sender, bitcoin_txid, ...).\n * Scaffold via `sl subgraphs create --template sbtc-flows`.\n */\nexport function sbtcDeposit(\n\ttarget: FactoryTarget,\n\topts?: { sender?: string; bitcoinTxid?: string },\n): SubscriptionFilterSpec {\n\treturn makeSpec(target, {\n\t\ttopic: \"completed-deposit\",\n\t\t...(opts?.sender && { sender: opts.sender }),\n\t\t...(opts?.bitcoinTxid && { bitcoin_txid: opts.bitcoinTxid }),\n\t});\n}\n\n/**\n * Match sBTC withdrawal lifecycle events. Phase defaults to all three\n * (`create` / `accept` / `reject`); pass an explicit `phase` to narrow.\n */\nexport function sbtcWithdrawal(\n\ttarget: FactoryTarget,\n\topts?: {\n\t\tphase?: \"create\" | \"accept\" | \"reject\";\n\t\tsender?: string;\n\t\trequestId?: number;\n\t},\n): SubscriptionFilterSpec {\n\treturn makeSpec(target, {\n\t\ttopic: opts?.phase\n\t\t\t? { eq: `withdrawal-${opts.phase}` }\n\t\t\t: { in: [\"withdrawal-create\", \"withdrawal-accept\", \"withdrawal-reject\"] },\n\t\t...(opts?.sender && { sender: opts.sender }),\n\t\t...(opts?.requestId !== undefined && { request_id: opts.requestId }),\n\t});\n}\n",
|
|
21
21
|
"import {\n\ttype FactoryTarget,\n\ttype SubscriptionFilterSpec,\n\tmakeSpec,\n} from \"./spec.ts\";\n\n/**\n * Match transfer events into a recipient address.\n *\n * Works against any subgraph table that has a `recipient` column (and\n * optionally `asset_identifier`). Templates that scaffold this shape:\n * `sip-010-balances`, `sbtc-flows`.\n *\n * @param target the user's subgraph + table to bind against\n * @param recipient stx principal that should receive the transfer\n * @param opts.asset optional asset identifier (e.g. `\"SP1...usdc::usdc-token\"`)\n * to filter to a specific FT/NFT contract\n */\nexport function transferTo(\n\ttarget: FactoryTarget,\n\trecipient: string,\n\topts?: { asset?: string },\n): SubscriptionFilterSpec {\n\treturn makeSpec(target, {\n\t\trecipient,\n\t\t...(opts?.asset && { asset_identifier: opts.asset }),\n\t});\n}\n\n/**\n * SIP-010 (fungible token) transfer sugar — alias for `transferTo` that\n * makes the asset filter intent explicit at the call site. Same backing\n * filter; the `asset` param is optional (omit to match every SIP-010\n * transfer in the bound table).\n */\nexport function sip010Transfer(\n\ttarget: FactoryTarget,\n\tasset?: string,\n\topts?: { recipient?: string },\n): SubscriptionFilterSpec {\n\treturn makeSpec(target, {\n\t\t...(asset && { asset_identifier: asset }),\n\t\t...(opts?.recipient && { recipient: opts.recipient }),\n\t});\n}\n\n/**\n * SIP-009 (non-fungible token) transfer sugar — same pattern as\n * `sip010Transfer`. Bind against an NFT-shaped table (see template\n * `nft-transfers` if/when published).\n */\nexport function sip009Transfer(\n\ttarget: FactoryTarget,\n\tasset?: string,\n\topts?: { recipient?: string; tokenId?: string | number },\n): SubscriptionFilterSpec {\n\treturn makeSpec(target, {\n\t\t...(asset && { asset_identifier: asset }),\n\t\t...(opts?.recipient && { recipient: opts.recipient }),\n\t\t...(opts?.tokenId !== undefined && { token_id: String(opts.tokenId) }),\n\t});\n}\n",
|
|
22
22
|
"import { BaseError } from \"./base.ts\";\n\nexport class ContractCallError extends BaseError {\n\toverride name = \"ContractCallError\";\n}\n\nexport class ReadOnlyCallError extends BaseError {\n\toverride name = \"ReadOnlyCallError\";\n}\n"
|
|
23
23
|
],
|
package/dist/src/tools/index.cjs
CHANGED
|
@@ -2710,5 +2710,5 @@ var getNftHoldings = import_ai.tool({
|
|
|
2710
2710
|
execute: ({ principal, limit }) => nftHoldings(getDefaultPublicClient(), principal, limit)
|
|
2711
2711
|
});
|
|
2712
2712
|
|
|
2713
|
-
//# debugId=
|
|
2713
|
+
//# debugId=2C93FD5D1703F35064756E2164756E21
|
|
2714
2714
|
//# sourceMappingURL=index.cjs.map
|