@secondlayer/stacks 0.3.0 → 1.0.0-beta.1

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.
@@ -1,65 +0,0 @@
1
- var import_node_module = require("node:module");
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- function __accessProp(key) {
7
- return this[key];
8
- }
9
- var __toCommonJS = (from) => {
10
- var entry = (__moduleCache ??= new WeakMap).get(from), desc;
11
- if (entry)
12
- return entry;
13
- entry = __defProp({}, "__esModule", { value: true });
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (var key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(entry, key))
17
- __defProp(entry, key, {
18
- get: __accessProp.bind(from, key),
19
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
20
- });
21
- }
22
- __moduleCache.set(from, entry);
23
- return entry;
24
- };
25
- var __moduleCache;
26
- var __returnValue = (v) => v;
27
- function __exportSetter(name, newValue) {
28
- this[name] = __returnValue.bind(null, newValue);
29
- }
30
- var __export = (target, all) => {
31
- for (var name in all)
32
- __defProp(target, name, {
33
- get: all[name],
34
- enumerable: true,
35
- configurable: true,
36
- set: __exportSetter.bind(all, name)
37
- });
38
- };
39
-
40
- // src/tx/index.ts
41
- var exports_tx = {};
42
- __export(exports_tx, {
43
- tx: () => tx
44
- });
45
- module.exports = __toCommonJS(exports_tx);
46
-
47
- // src/tx/builders.ts
48
- var tx = {
49
- transfer: (opts) => ({
50
- kind: "transfer",
51
- ...opts
52
- }),
53
- contractCall: (opts) => ({ kind: "contract-call", ...opts }),
54
- deploy: (opts) => ({
55
- kind: "deploy",
56
- ...opts
57
- }),
58
- multisend: (opts) => ({
59
- kind: "multisend",
60
- ...opts
61
- })
62
- };
63
-
64
- //# debugId=64DC96EB3711AFB064756E2164756E21
65
- //# sourceMappingURL=index.cjs.map
@@ -1,10 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/tx/builders.ts"],
4
- "sourcesContent": [
5
- "/**\n * Unsigned transaction intents for workflow use.\n *\n * import { tx } from \"@secondlayer/stacks/tx\"\n * await step.run(\"pay\", () => broadcast(\n * tx.transfer({ recipient: \"SP…\", amount: 1_000_000n, memo: \"DCA\" }),\n * { signer: \"treasury\" },\n * ))\n *\n * These helpers return plain \"intent\" objects — a description of *what*\n * should be broadcast, without fee, nonce, signer, or signature. The\n * `broadcast()` step (see Sprint 4) hydrates those at submit time using the\n * configured signer.\n *\n * Keeping intents separate from the existing `buildTokenTransfer` /\n * `buildContractCall` / `buildContractDeploy` in `@secondlayer/stacks/transactions`\n * means workflow authors don't have to manage fee/nonce and a single\n * `broadcast()` path can enforce budget caps + safety layers uniformly.\n */\n\nimport type { ClarityValue, PostCondition } from \"@stacks/transactions\";\n\nexport interface TransferIntent {\n\tkind: \"transfer\";\n\trecipient: string;\n\tamount: bigint;\n\tmemo?: string;\n\tpostConditions?: PostCondition[];\n}\n\nexport interface ContractCallIntent {\n\tkind: \"contract-call\";\n\t/** Fully-qualified contract id, e.g. `\"SP000000000000000000002Q6VF78.bns\"`. */\n\tcontract: string;\n\tfn: string;\n\targs: ClarityValue[];\n\tpostConditions?: PostCondition[];\n}\n\nexport interface DeployIntent {\n\tkind: \"deploy\";\n\tname: string;\n\tsource: string;\n\tclarityVersion?: 1 | 2 | 3;\n}\n\nexport interface MultiSendIntent {\n\tkind: \"multisend\";\n\tpayments: Array<{ recipient: string; amount: bigint; memo?: string }>;\n}\n\nexport type TxIntent =\n\t| TransferIntent\n\t| ContractCallIntent\n\t| DeployIntent\n\t| MultiSendIntent;\n\n/**\n * Lightweight factory functions for building tx intents. Identity-shaped\n * with a `kind` tag so the broadcast step can discriminate at runtime.\n */\nexport const tx = {\n\ttransfer: (opts: Omit<TransferIntent, \"kind\">): TransferIntent => ({\n\t\tkind: \"transfer\",\n\t\t...opts,\n\t}),\n\tcontractCall: (\n\t\topts: Omit<ContractCallIntent, \"kind\">,\n\t): ContractCallIntent => ({ kind: \"contract-call\", ...opts }),\n\tdeploy: (opts: Omit<DeployIntent, \"kind\">): DeployIntent => ({\n\t\tkind: \"deploy\",\n\t\t...opts,\n\t}),\n\tmultisend: (opts: Omit<MultiSendIntent, \"kind\">): MultiSendIntent => ({\n\t\tkind: \"multisend\",\n\t\t...opts,\n\t}),\n} as const;\n"
6
- ],
7
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DO,IAAM,KAAK;AAAA,EACjB,UAAU,CAAC,UAAwD;AAAA,IAClE,MAAM;AAAA,OACH;AAAA,EACJ;AAAA,EACA,cAAc,CACb,UACyB,EAAE,MAAM,oBAAoB,KAAK;AAAA,EAC3D,QAAQ,CAAC,UAAoD;AAAA,IAC5D,MAAM;AAAA,OACH;AAAA,EACJ;AAAA,EACA,WAAW,CAAC,UAA0D;AAAA,IACrE,MAAM;AAAA,OACH;AAAA,EACJ;AACD;",
8
- "debugId": "64DC96EB3711AFB064756E2164756E21",
9
- "names": []
10
- }
@@ -1,42 +0,0 @@
1
- import { ClarityValue, PostCondition } from "@stacks/transactions";
2
- interface TransferIntent {
3
- kind: "transfer";
4
- recipient: string;
5
- amount: bigint;
6
- memo?: string;
7
- postConditions?: PostCondition[];
8
- }
9
- interface ContractCallIntent {
10
- kind: "contract-call";
11
- /** Fully-qualified contract id, e.g. `"SP000000000000000000002Q6VF78.bns"`. */
12
- contract: string;
13
- fn: string;
14
- args: ClarityValue[];
15
- postConditions?: PostCondition[];
16
- }
17
- interface DeployIntent {
18
- kind: "deploy";
19
- name: string;
20
- source: string;
21
- clarityVersion?: 1 | 2 | 3;
22
- }
23
- interface MultiSendIntent {
24
- kind: "multisend";
25
- payments: Array<{
26
- recipient: string
27
- amount: bigint
28
- memo?: string
29
- }>;
30
- }
31
- type TxIntent = TransferIntent | ContractCallIntent | DeployIntent | MultiSendIntent;
32
- /**
33
- * Lightweight factory functions for building tx intents. Identity-shaped
34
- * with a `kind` tag so the broadcast step can discriminate at runtime.
35
- */
36
- declare const tx: {
37
- readonly transfer: (opts: Omit<TransferIntent, "kind">) => TransferIntent
38
- readonly contractCall: (opts: Omit<ContractCallIntent, "kind">) => ContractCallIntent
39
- readonly deploy: (opts: Omit<DeployIntent, "kind">) => DeployIntent
40
- readonly multisend: (opts: Omit<MultiSendIntent, "kind">) => MultiSendIntent
41
- };
42
- export { tx, TxIntent, TransferIntent, MultiSendIntent, DeployIntent, ContractCallIntent };
@@ -1,42 +0,0 @@
1
- import { ClarityValue, PostCondition } from "@stacks/transactions";
2
- interface TransferIntent {
3
- kind: "transfer";
4
- recipient: string;
5
- amount: bigint;
6
- memo?: string;
7
- postConditions?: PostCondition[];
8
- }
9
- interface ContractCallIntent {
10
- kind: "contract-call";
11
- /** Fully-qualified contract id, e.g. `"SP000000000000000000002Q6VF78.bns"`. */
12
- contract: string;
13
- fn: string;
14
- args: ClarityValue[];
15
- postConditions?: PostCondition[];
16
- }
17
- interface DeployIntent {
18
- kind: "deploy";
19
- name: string;
20
- source: string;
21
- clarityVersion?: 1 | 2 | 3;
22
- }
23
- interface MultiSendIntent {
24
- kind: "multisend";
25
- payments: Array<{
26
- recipient: string
27
- amount: bigint
28
- memo?: string
29
- }>;
30
- }
31
- type TxIntent = TransferIntent | ContractCallIntent | DeployIntent | MultiSendIntent;
32
- /**
33
- * Lightweight factory functions for building tx intents. Identity-shaped
34
- * with a `kind` tag so the broadcast step can discriminate at runtime.
35
- */
36
- declare const tx: {
37
- readonly transfer: (opts: Omit<TransferIntent, "kind">) => TransferIntent
38
- readonly contractCall: (opts: Omit<ContractCallIntent, "kind">) => ContractCallIntent
39
- readonly deploy: (opts: Omit<DeployIntent, "kind">) => DeployIntent
40
- readonly multisend: (opts: Omit<MultiSendIntent, "kind">) => MultiSendIntent
41
- };
42
- export { tx, TxIntent, TransferIntent, MultiSendIntent, DeployIntent, ContractCallIntent };
@@ -1,22 +0,0 @@
1
- // src/tx/builders.ts
2
- var tx = {
3
- transfer: (opts) => ({
4
- kind: "transfer",
5
- ...opts
6
- }),
7
- contractCall: (opts) => ({ kind: "contract-call", ...opts }),
8
- deploy: (opts) => ({
9
- kind: "deploy",
10
- ...opts
11
- }),
12
- multisend: (opts) => ({
13
- kind: "multisend",
14
- ...opts
15
- })
16
- };
17
- export {
18
- tx
19
- };
20
-
21
- //# debugId=EA2A810D5257349464756E2164756E21
22
- //# sourceMappingURL=index.js.map
@@ -1,10 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/tx/builders.ts"],
4
- "sourcesContent": [
5
- "/**\n * Unsigned transaction intents for workflow use.\n *\n * import { tx } from \"@secondlayer/stacks/tx\"\n * await step.run(\"pay\", () => broadcast(\n * tx.transfer({ recipient: \"SP…\", amount: 1_000_000n, memo: \"DCA\" }),\n * { signer: \"treasury\" },\n * ))\n *\n * These helpers return plain \"intent\" objects — a description of *what*\n * should be broadcast, without fee, nonce, signer, or signature. The\n * `broadcast()` step (see Sprint 4) hydrates those at submit time using the\n * configured signer.\n *\n * Keeping intents separate from the existing `buildTokenTransfer` /\n * `buildContractCall` / `buildContractDeploy` in `@secondlayer/stacks/transactions`\n * means workflow authors don't have to manage fee/nonce and a single\n * `broadcast()` path can enforce budget caps + safety layers uniformly.\n */\n\nimport type { ClarityValue, PostCondition } from \"@stacks/transactions\";\n\nexport interface TransferIntent {\n\tkind: \"transfer\";\n\trecipient: string;\n\tamount: bigint;\n\tmemo?: string;\n\tpostConditions?: PostCondition[];\n}\n\nexport interface ContractCallIntent {\n\tkind: \"contract-call\";\n\t/** Fully-qualified contract id, e.g. `\"SP000000000000000000002Q6VF78.bns\"`. */\n\tcontract: string;\n\tfn: string;\n\targs: ClarityValue[];\n\tpostConditions?: PostCondition[];\n}\n\nexport interface DeployIntent {\n\tkind: \"deploy\";\n\tname: string;\n\tsource: string;\n\tclarityVersion?: 1 | 2 | 3;\n}\n\nexport interface MultiSendIntent {\n\tkind: \"multisend\";\n\tpayments: Array<{ recipient: string; amount: bigint; memo?: string }>;\n}\n\nexport type TxIntent =\n\t| TransferIntent\n\t| ContractCallIntent\n\t| DeployIntent\n\t| MultiSendIntent;\n\n/**\n * Lightweight factory functions for building tx intents. Identity-shaped\n * with a `kind` tag so the broadcast step can discriminate at runtime.\n */\nexport const tx = {\n\ttransfer: (opts: Omit<TransferIntent, \"kind\">): TransferIntent => ({\n\t\tkind: \"transfer\",\n\t\t...opts,\n\t}),\n\tcontractCall: (\n\t\topts: Omit<ContractCallIntent, \"kind\">,\n\t): ContractCallIntent => ({ kind: \"contract-call\", ...opts }),\n\tdeploy: (opts: Omit<DeployIntent, \"kind\">): DeployIntent => ({\n\t\tkind: \"deploy\",\n\t\t...opts,\n\t}),\n\tmultisend: (opts: Omit<MultiSendIntent, \"kind\">): MultiSendIntent => ({\n\t\tkind: \"multisend\",\n\t\t...opts,\n\t}),\n} as const;\n"
6
- ],
7
- "mappings": ";AA6DO,IAAM,KAAK;AAAA,EACjB,UAAU,CAAC,UAAwD;AAAA,IAClE,MAAM;AAAA,OACH;AAAA,EACJ;AAAA,EACA,cAAc,CACb,UACyB,EAAE,MAAM,oBAAoB,KAAK;AAAA,EAC3D,QAAQ,CAAC,UAAoD;AAAA,IAC5D,MAAM;AAAA,OACH;AAAA,EACJ;AAAA,EACA,WAAW,CAAC,UAA0D;AAAA,IACrE,MAAM;AAAA,OACH;AAAA,EACJ;AACD;",
8
- "debugId": "EA2A810D5257349464756E2164756E21",
9
- "names": []
10
- }
@@ -1,431 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropNames = Object.getOwnPropertyNames;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- function __accessProp(key) {
6
- return this[key];
7
- }
8
- var __toCommonJS = (from) => {
9
- var entry = (__moduleCache ??= new WeakMap).get(from), desc;
10
- if (entry)
11
- return entry;
12
- entry = __defProp({}, "__esModule", { value: true });
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (var key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(entry, key))
16
- __defProp(entry, key, {
17
- get: __accessProp.bind(from, key),
18
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
- });
20
- }
21
- __moduleCache.set(from, entry);
22
- return entry;
23
- };
24
- var __moduleCache;
25
- var __returnValue = (v) => v;
26
- function __exportSetter(name, newValue) {
27
- this[name] = __returnValue.bind(null, newValue);
28
- }
29
- var __export = (target, all) => {
30
- for (var name in all)
31
- __defProp(target, name, {
32
- get: all[name],
33
- enumerable: true,
34
- configurable: true,
35
- set: __exportSetter.bind(all, name)
36
- });
37
- };
38
-
39
- // src/ui/index.ts
40
- var exports_ui = {};
41
- __export(exports_ui, {
42
- schema: () => import_react.schema,
43
- defineCatalog: () => import_core.defineCatalog,
44
- atoms: () => atoms,
45
- atomComponentMap: () => atomComponentMap,
46
- TxStatusProps: () => TxStatusProps,
47
- TxStatus: () => TxStatus,
48
- TokenProps: () => TokenProps,
49
- Token: () => Token,
50
- PrincipalProps: () => PrincipalProps,
51
- Principal: () => Principal,
52
- NftAssetProps: () => NftAssetProps,
53
- NftAsset: () => NftAsset,
54
- BnsNameProps: () => BnsNameProps,
55
- BnsName: () => BnsName,
56
- BlockHeightProps: () => BlockHeightProps,
57
- BlockHeight: () => BlockHeight,
58
- AmountProps: () => AmountProps,
59
- Amount: () => Amount,
60
- AddressProps: () => AddressProps,
61
- Address: () => Address
62
- });
63
- module.exports = __toCommonJS(exports_ui);
64
- var import_core = require("@json-render/core");
65
- var import_react = require("@json-render/react");
66
-
67
- // src/ui/atoms/address.schema.ts
68
- var import_zod = require("zod");
69
- var AddressProps = import_zod.z.object({
70
- value: import_zod.z.string().describe("Stacks principal (SP…/SM…/ST…)"),
71
- bns: import_zod.z.string().nullable().optional().describe("Optional BNS override"),
72
- truncate: import_zod.z.boolean().optional().default(true)
73
- });
74
-
75
- // src/ui/atoms/address.tsx
76
- var jsx_dev_runtime = require("react/jsx-dev-runtime");
77
- function truncatePrincipal(value) {
78
- if (value.length <= 14)
79
- return value;
80
- return `${value.slice(0, 6)}…${value.slice(-4)}`;
81
- }
82
- function Address(props) {
83
- const display = props.bns ?? (props.truncate ? truncatePrincipal(props.value) : props.value);
84
- return /* @__PURE__ */ jsx_dev_runtime.jsxDEV("span", {
85
- className: "font-mono text-sm",
86
- title: props.value,
87
- children: display
88
- }, undefined, false, undefined, this);
89
- }
90
- var AddressComponent = {
91
- props: AddressProps,
92
- render: Address
93
- };
94
-
95
- // src/ui/atoms/amount.schema.ts
96
- var import_zod2 = require("zod");
97
- var AmountProps = import_zod2.z.object({
98
- microUnits: import_zod2.z.string().describe("Amount in micro-units (as string to preserve bigint precision)"),
99
- decimals: import_zod2.z.number().int().min(0).max(18).default(6).describe("Decimal places (6 for STX, 8 for sBTC, varies for SIP-010 tokens)"),
100
- symbol: import_zod2.z.string().default("STX"),
101
- usdValue: import_zod2.z.number().nullable().optional()
102
- });
103
-
104
- // src/ui/atoms/amount.tsx
105
- var jsx_dev_runtime2 = require("react/jsx-dev-runtime");
106
- function formatAmount(microUnits, decimals) {
107
- try {
108
- const raw = BigInt(microUnits);
109
- const divisor = 10n ** BigInt(decimals);
110
- const whole = raw / divisor;
111
- const fraction = raw % divisor;
112
- if (fraction === 0n)
113
- return whole.toLocaleString();
114
- const fracStr = fraction.toString().padStart(decimals, "0").replace(/0+$/, "");
115
- return `${whole.toLocaleString()}.${fracStr}`;
116
- } catch {
117
- return microUnits;
118
- }
119
- }
120
- function Amount(props) {
121
- const decimals = props.decimals ?? 6;
122
- const symbol = props.symbol ?? "STX";
123
- const formatted = formatAmount(props.microUnits, decimals);
124
- return /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("span", {
125
- className: "font-mono tabular-nums",
126
- children: [
127
- /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("span", {
128
- className: "font-medium",
129
- children: formatted
130
- }, undefined, false, undefined, this),
131
- /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("span", {
132
- className: "ml-1 text-muted-foreground",
133
- children: symbol
134
- }, undefined, false, undefined, this),
135
- props.usdValue != null && /* @__PURE__ */ jsx_dev_runtime2.jsxDEV("span", {
136
- className: "ml-2 text-sm text-muted-foreground",
137
- children: [
138
- "($",
139
- props.usdValue.toLocaleString(undefined, {
140
- maximumFractionDigits: 2
141
- }),
142
- ")"
143
- ]
144
- }, undefined, true, undefined, this)
145
- ]
146
- }, undefined, true, undefined, this);
147
- }
148
- var AmountComponent = {
149
- props: AmountProps,
150
- render: Amount
151
- };
152
-
153
- // src/ui/atoms/blockHeight.schema.ts
154
- var import_zod3 = require("zod");
155
- var BlockHeightProps = import_zod3.z.object({
156
- height: import_zod3.z.number().int().nonnegative(),
157
- timestamp: import_zod3.z.string().nullable().optional().describe("ISO-8601 block timestamp")
158
- });
159
-
160
- // src/ui/atoms/blockHeight.tsx
161
- var jsx_dev_runtime3 = require("react/jsx-dev-runtime");
162
- function relative(timestamp) {
163
- if (!timestamp)
164
- return null;
165
- const then = new Date(timestamp).getTime();
166
- if (Number.isNaN(then))
167
- return null;
168
- const delta = Math.max(0, Date.now() - then);
169
- const s = Math.floor(delta / 1000);
170
- if (s < 60)
171
- return `${s}s ago`;
172
- const m = Math.floor(s / 60);
173
- if (m < 60)
174
- return `${m}m ago`;
175
- const h = Math.floor(m / 60);
176
- if (h < 24)
177
- return `${h}h ago`;
178
- return `${Math.floor(h / 24)}d ago`;
179
- }
180
- function BlockHeight(props) {
181
- const rel = relative(props.timestamp);
182
- return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("span", {
183
- className: "font-mono text-sm",
184
- children: [
185
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("span", {
186
- children: [
187
- "#",
188
- props.height.toLocaleString()
189
- ]
190
- }, undefined, true, undefined, this),
191
- rel && /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("span", {
192
- className: "ml-1 text-muted-foreground",
193
- children: [
194
- "· ",
195
- rel
196
- ]
197
- }, undefined, true, undefined, this)
198
- ]
199
- }, undefined, true, undefined, this);
200
- }
201
- var BlockHeightComponent = {
202
- props: BlockHeightProps,
203
- render: BlockHeight
204
- };
205
-
206
- // src/ui/atoms/bnsName.schema.ts
207
- var import_zod4 = require("zod");
208
- var BnsNameProps = import_zod4.z.object({
209
- name: import_zod4.z.string(),
210
- namespace: import_zod4.z.string(),
211
- expiresAt: import_zod4.z.string().nullable().optional().describe("ISO-8601 timestamp")
212
- });
213
-
214
- // src/ui/atoms/bnsName.tsx
215
- var jsx_dev_runtime4 = require("react/jsx-dev-runtime");
216
- function BnsName(props) {
217
- return /* @__PURE__ */ jsx_dev_runtime4.jsxDEV("span", {
218
- className: "font-mono text-sm",
219
- children: [
220
- /* @__PURE__ */ jsx_dev_runtime4.jsxDEV("span", {
221
- className: "font-medium",
222
- children: props.name
223
- }, undefined, false, undefined, this),
224
- /* @__PURE__ */ jsx_dev_runtime4.jsxDEV("span", {
225
- className: "text-muted-foreground",
226
- children: [
227
- ".",
228
- props.namespace
229
- ]
230
- }, undefined, true, undefined, this)
231
- ]
232
- }, undefined, true, undefined, this);
233
- }
234
- var BnsNameComponent = {
235
- props: BnsNameProps,
236
- render: BnsName
237
- };
238
-
239
- // src/ui/atoms/nftAsset.schema.ts
240
- var import_zod5 = require("zod");
241
- var NftAssetProps = import_zod5.z.object({
242
- assetIdentifier: import_zod5.z.string().describe("Full asset identifier (e.g. SP123.contract::asset-name)"),
243
- tokenId: import_zod5.z.string().describe("Token id (as string to preserve bigint precision)"),
244
- name: import_zod5.z.string().nullable().optional(),
245
- imageUrl: import_zod5.z.string().url().nullable().optional()
246
- });
247
-
248
- // src/ui/atoms/nftAsset.tsx
249
- var jsx_dev_runtime5 = require("react/jsx-dev-runtime");
250
- function NftAsset(props) {
251
- const [, assetName] = props.assetIdentifier.split("::", 2);
252
- const displayName = props.name ?? `${assetName ?? "NFT"} #${props.tokenId}`;
253
- return /* @__PURE__ */ jsx_dev_runtime5.jsxDEV("span", {
254
- className: "inline-flex items-center gap-2",
255
- children: [
256
- props.imageUrl && /* @__PURE__ */ jsx_dev_runtime5.jsxDEV("img", {
257
- src: props.imageUrl,
258
- alt: displayName,
259
- className: "h-5 w-5 rounded",
260
- loading: "lazy"
261
- }, undefined, false, undefined, this),
262
- /* @__PURE__ */ jsx_dev_runtime5.jsxDEV("span", {
263
- className: "font-mono text-sm",
264
- children: displayName
265
- }, undefined, false, undefined, this)
266
- ]
267
- }, undefined, true, undefined, this);
268
- }
269
- var NftAssetComponent = {
270
- props: NftAssetProps,
271
- render: NftAsset
272
- };
273
-
274
- // src/ui/atoms/principal.schema.ts
275
- var import_zod6 = require("zod");
276
- var PrincipalProps = import_zod6.z.object({
277
- value: import_zod6.z.string().describe("Standard or contract principal"),
278
- bns: import_zod6.z.string().nullable().optional(),
279
- kind: import_zod6.z.enum(["standard", "contract"]).optional()
280
- });
281
-
282
- // src/ui/atoms/principal.tsx
283
- var jsx_dev_runtime6 = require("react/jsx-dev-runtime");
284
- function inferKind(value) {
285
- return value.includes(".") ? "contract" : "standard";
286
- }
287
- function Principal(props) {
288
- const kind = props.kind ?? inferKind(props.value);
289
- if (kind === "contract") {
290
- const parts = props.value.split(".", 2);
291
- const addr = parts[0] ?? props.value;
292
- const name = parts[1] ?? "";
293
- return /* @__PURE__ */ jsx_dev_runtime6.jsxDEV("span", {
294
- className: "font-mono text-sm",
295
- title: props.value,
296
- children: [
297
- /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Address, {
298
- value: addr,
299
- bns: props.bns,
300
- truncate: true
301
- }, undefined, false, undefined, this),
302
- /* @__PURE__ */ jsx_dev_runtime6.jsxDEV("span", {
303
- className: "text-muted-foreground",
304
- children: "."
305
- }, undefined, false, undefined, this),
306
- /* @__PURE__ */ jsx_dev_runtime6.jsxDEV("span", {
307
- className: "text-foreground",
308
- children: name
309
- }, undefined, false, undefined, this)
310
- ]
311
- }, undefined, true, undefined, this);
312
- }
313
- return /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Address, {
314
- value: props.value,
315
- bns: props.bns,
316
- truncate: true
317
- }, undefined, false, undefined, this);
318
- }
319
- var PrincipalComponent = {
320
- props: PrincipalProps,
321
- render: Principal
322
- };
323
-
324
- // src/ui/atoms/token.schema.ts
325
- var import_zod7 = require("zod");
326
- var TokenProps = import_zod7.z.object({
327
- symbol: import_zod7.z.string(),
328
- contract: import_zod7.z.string().nullable().optional().describe("SIP-010 contract id (for non-STX tokens)"),
329
- decimals: import_zod7.z.number().int().min(0).max(18).default(6)
330
- });
331
-
332
- // src/ui/atoms/token.tsx
333
- var jsx_dev_runtime7 = require("react/jsx-dev-runtime");
334
- function Token(props) {
335
- return /* @__PURE__ */ jsx_dev_runtime7.jsxDEV("span", {
336
- className: "font-mono text-sm",
337
- title: props.contract ?? undefined,
338
- children: /* @__PURE__ */ jsx_dev_runtime7.jsxDEV("span", {
339
- className: "font-medium",
340
- children: props.symbol
341
- }, undefined, false, undefined, this)
342
- }, undefined, false, undefined, this);
343
- }
344
- var TokenComponent = {
345
- props: TokenProps,
346
- render: Token
347
- };
348
-
349
- // src/ui/atoms/txStatus.schema.ts
350
- var import_zod8 = require("zod");
351
- var TxStatusProps = import_zod8.z.object({
352
- status: import_zod8.z.enum([
353
- "pending",
354
- "success",
355
- "failed",
356
- "abort_by_post_condition",
357
- "abort_by_response"
358
- ]),
359
- txId: import_zod8.z.string().nullable().optional()
360
- });
361
-
362
- // src/ui/atoms/txStatus.tsx
363
- var jsx_dev_runtime8 = require("react/jsx-dev-runtime");
364
- var TONE = {
365
- pending: "bg-yellow-100 text-yellow-900 dark:bg-yellow-950 dark:text-yellow-200",
366
- success: "bg-green-100 text-green-900 dark:bg-green-950 dark:text-green-200",
367
- failed: "bg-red-100 text-red-900 dark:bg-red-950 dark:text-red-200",
368
- abort_by_post_condition: "bg-orange-100 text-orange-900 dark:bg-orange-950 dark:text-orange-200",
369
- abort_by_response: "bg-red-100 text-red-900 dark:bg-red-950 dark:text-red-200"
370
- };
371
- var LABEL = {
372
- pending: "pending",
373
- success: "confirmed",
374
- failed: "failed",
375
- abort_by_post_condition: "post-condition aborted",
376
- abort_by_response: "aborted"
377
- };
378
- function TxStatus(props) {
379
- return /* @__PURE__ */ jsx_dev_runtime8.jsxDEV("span", {
380
- className: `inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ${TONE[props.status]}`,
381
- title: props.txId ?? undefined,
382
- children: LABEL[props.status]
383
- }, undefined, false, undefined, this);
384
- }
385
- var TxStatusComponent = {
386
- props: TxStatusProps,
387
- render: TxStatus
388
- };
389
- // src/ui/componentMap.tsx
390
- var jsx_dev_runtime9 = require("react/jsx-dev-runtime");
391
- var atomComponentMap = {
392
- Address: ({ element }) => /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Address, {
393
- ...element.props
394
- }, undefined, false, undefined, this),
395
- Amount: ({ element }) => /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Amount, {
396
- ...element.props
397
- }, undefined, false, undefined, this),
398
- BlockHeight: ({ element }) => /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(BlockHeight, {
399
- ...element.props
400
- }, undefined, false, undefined, this),
401
- BnsName: ({ element }) => /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(BnsName, {
402
- ...element.props
403
- }, undefined, false, undefined, this),
404
- NftAsset: ({ element }) => /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(NftAsset, {
405
- ...element.props
406
- }, undefined, false, undefined, this),
407
- Principal: ({ element }) => /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Principal, {
408
- ...element.props
409
- }, undefined, false, undefined, this),
410
- Token: ({ element }) => /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(Token, {
411
- ...element.props
412
- }, undefined, false, undefined, this),
413
- TxStatus: ({ element }) => /* @__PURE__ */ jsx_dev_runtime9.jsxDEV(TxStatus, {
414
- ...element.props
415
- }, undefined, false, undefined, this)
416
- };
417
-
418
- // src/ui/index.ts
419
- var atoms = {
420
- Address: AddressComponent,
421
- Amount: AmountComponent,
422
- BlockHeight: BlockHeightComponent,
423
- BnsName: BnsNameComponent,
424
- NftAsset: NftAssetComponent,
425
- Principal: PrincipalComponent,
426
- Token: TokenComponent,
427
- TxStatus: TxStatusComponent
428
- };
429
-
430
- //# debugId=ED836273CB17B50E64756E2164756E21
431
- //# sourceMappingURL=index.cjs.map