@secondlayer/stacks 6.1.0 → 6.1.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.
- package/dist/shared/stacks-esm-0pc6tmf0.js +50 -0
- package/dist/shared/{stacks-esm-743jfh10.js.map → stacks-esm-0pc6tmf0.js.map} +2 -2
- package/dist/shared/{stacks-esm-0rdxcta7.js → stacks-esm-16d82wyc.js} +10 -10
- package/dist/shared/{stacks-esm-0rdxcta7.js.map → stacks-esm-16d82wyc.js.map} +2 -2
- package/dist/shared/{stacks-esm-cvhazvhd.js → stacks-esm-7a0ehykf.js} +43 -43
- package/dist/shared/{stacks-esm-cvhazvhd.js.map → stacks-esm-7a0ehykf.js.map} +2 -2
- package/dist/shared/{stacks-esm-1jae0a3r.js → stacks-esm-7v18h5dk.js} +4 -4
- package/dist/shared/{stacks-esm-1jae0a3r.js.map → stacks-esm-7v18h5dk.js.map} +2 -2
- package/dist/shared/{stacks-esm-9rnx0zxr.js → stacks-esm-8f5catbf.js} +126 -126
- package/dist/shared/{stacks-esm-9rnx0zxr.js.map → stacks-esm-8f5catbf.js.map} +2 -2
- package/dist/shared/{stacks-esm-7fpqgtyx.js → stacks-esm-8jt6k8p3.js} +13 -13
- package/dist/shared/{stacks-esm-7fpqgtyx.js.map → stacks-esm-8jt6k8p3.js.map} +2 -2
- package/dist/shared/{stacks-esm-hr7fpxtj.js → stacks-esm-a20wyky3.js} +92 -92
- package/dist/shared/{stacks-esm-hr7fpxtj.js.map → stacks-esm-a20wyky3.js.map} +2 -2
- package/dist/shared/{stacks-esm-3pv5avgr.js → stacks-esm-b54n1jdx.js} +54 -54
- package/dist/shared/{stacks-esm-3pv5avgr.js.map → stacks-esm-b54n1jdx.js.map} +2 -2
- package/dist/shared/{stacks-esm-r9q4wnyw.js → stacks-esm-cmtj5vky.js} +162 -162
- package/dist/shared/{stacks-esm-r9q4wnyw.js.map → stacks-esm-cmtj5vky.js.map} +2 -2
- package/dist/shared/{stacks-esm-wv67m4g6.js → stacks-esm-e2qhfgke.js} +36 -36
- package/dist/shared/{stacks-esm-wv67m4g6.js.map → stacks-esm-e2qhfgke.js.map} +2 -2
- package/dist/shared/{stacks-esm-qk0p9fr6.js → stacks-esm-ea4m4bk7.js} +117 -117
- package/dist/shared/{stacks-esm-qk0p9fr6.js.map → stacks-esm-ea4m4bk7.js.map} +2 -2
- package/dist/shared/{stacks-esm-fcfdn2zx.js → stacks-esm-hkw1kvd4.js} +140 -140
- package/dist/shared/{stacks-esm-fcfdn2zx.js.map → stacks-esm-hkw1kvd4.js.map} +2 -2
- package/dist/shared/{stacks-esm-qkj67g80.js → stacks-esm-k108pemv.js} +4 -4
- package/dist/shared/{stacks-esm-qkj67g80.js.map → stacks-esm-k108pemv.js.map} +2 -2
- package/dist/shared/stacks-esm-kbz5s6v8.js +84 -0
- package/dist/shared/{stacks-esm-2mc7ebrm.js.map → stacks-esm-kbz5s6v8.js.map} +2 -2
- package/dist/shared/{stacks-esm-n53kvwmt.js → stacks-esm-mt1thm7k.js} +9 -9
- package/dist/shared/{stacks-esm-n53kvwmt.js.map → stacks-esm-mt1thm7k.js.map} +2 -2
- package/dist/shared/{stacks-esm-v45990hx.js → stacks-esm-n1mekwnb.js} +9 -9
- package/dist/shared/{stacks-esm-v45990hx.js.map → stacks-esm-n1mekwnb.js.map} +2 -2
- package/dist/shared/{stacks-esm-r6dejrgr.js → stacks-esm-nt5hf8ht.js} +34 -34
- package/dist/shared/{stacks-esm-r6dejrgr.js.map → stacks-esm-nt5hf8ht.js.map} +2 -2
- package/dist/shared/{stacks-esm-skmcf5n2.js → stacks-esm-phgy8yqf.js} +210 -210
- package/dist/shared/{stacks-esm-skmcf5n2.js.map → stacks-esm-phgy8yqf.js.map} +2 -2
- package/dist/shared/{stacks-esm-kds4n82p.js → stacks-esm-pxv6ny92.js} +116 -116
- package/dist/shared/{stacks-esm-kds4n82p.js.map → stacks-esm-pxv6ny92.js.map} +2 -2
- package/dist/shared/{stacks-esm-3g33bqsm.js → stacks-esm-qfzxhdqz.js} +19 -19
- package/dist/shared/{stacks-esm-3g33bqsm.js.map → stacks-esm-qfzxhdqz.js.map} +2 -2
- package/dist/shared/{stacks-esm-aw2mj3sj.js → stacks-esm-snj9s2q8.js} +43 -43
- package/dist/shared/{stacks-esm-aw2mj3sj.js.map → stacks-esm-snj9s2q8.js.map} +2 -2
- package/dist/shared/{stacks-esm-q19a17fd.js → stacks-esm-ss9ap75h.js} +28 -28
- package/dist/shared/{stacks-esm-q19a17fd.js.map → stacks-esm-ss9ap75h.js.map} +2 -2
- package/dist/shared/{stacks-esm-x1r01353.js → stacks-esm-t88hc019.js} +18 -18
- package/dist/shared/{stacks-esm-x1r01353.js.map → stacks-esm-t88hc019.js.map} +2 -2
- package/dist/shared/stacks-esm-tdrdye4y.js +48 -0
- package/dist/shared/{stacks-esm-pxhfqfff.js.map → stacks-esm-tdrdye4y.js.map} +2 -2
- package/dist/src/accounts/index.cjs +15 -13
- package/dist/src/accounts/index.cjs.map +2 -2
- package/dist/src/accounts/index.d.cts +1 -1
- package/dist/src/accounts/index.d.ts +1 -1
- package/dist/src/accounts/index.js +26 -26
- package/dist/src/accounts/index.js.map +2 -2
- package/dist/src/actions/index.cjs +83 -81
- package/dist/src/actions/index.cjs.map +2 -2
- package/dist/src/actions/index.d.cts +1 -1
- package/dist/src/actions/index.d.ts +1 -1
- package/dist/src/actions/index.js +102 -103
- package/dist/src/actions/index.js.map +1 -1
- package/dist/src/bitcoin/index.cjs +2035 -2036
- package/dist/src/bitcoin/index.cjs.map +8 -8
- package/dist/src/bitcoin/index.d.cts +92 -92
- package/dist/src/bitcoin/index.d.ts +92 -92
- package/dist/src/bitcoin/index.js +88 -90
- package/dist/src/bitcoin/index.js.map +2 -2
- package/dist/src/bns/index.cjs +3313 -3310
- package/dist/src/bns/index.cjs.map +13 -13
- package/dist/src/bns/index.d.cts +1 -1
- package/dist/src/bns/index.d.ts +1 -1
- package/dist/src/bns/index.js +39 -41
- package/dist/src/bns/index.js.map +2 -2
- package/dist/src/chains/index.cjs +14 -12
- package/dist/src/chains/index.cjs.map +2 -2
- package/dist/src/chains/index.d.cts +1 -1
- package/dist/src/chains/index.d.ts +1 -1
- package/dist/src/chains/index.js +12 -12
- package/dist/src/chains/index.js.map +1 -1
- package/dist/src/clarity/index.cjs +98 -96
- package/dist/src/clarity/index.cjs.map +2 -2
- package/dist/src/clarity/index.d.cts +1 -1
- package/dist/src/clarity/index.d.ts +1 -1
- package/dist/src/clarity/index.js +170 -171
- package/dist/src/clarity/index.js.map +1 -1
- package/dist/src/connect/index.cjs +19 -19
- package/dist/src/connect/index.cjs.map +2 -2
- package/dist/src/connect/index.d.cts +1 -1
- package/dist/src/connect/index.d.ts +1 -1
- package/dist/src/connect/index.js +19 -19
- package/dist/src/connect/index.js.map +2 -2
- package/dist/src/connect/walletconnect/index.cjs +6 -46
- package/dist/src/connect/walletconnect/index.cjs.map +3 -4
- package/dist/src/connect/walletconnect/index.d.cts +1 -1
- package/dist/src/connect/walletconnect/index.d.ts +1 -1
- package/dist/src/connect/walletconnect/index.js +6 -46
- package/dist/src/connect/walletconnect/index.js.map +3 -4
- package/dist/src/filters/index.cjs +22 -20
- package/dist/src/filters/index.cjs.map +2 -2
- package/dist/src/filters/index.d.cts +1 -1
- package/dist/src/filters/index.d.ts +1 -1
- package/dist/src/filters/index.js +30 -30
- package/dist/src/filters/index.js.map +1 -1
- package/dist/src/index.cjs +1411 -1410
- package/dist/src/index.cjs.map +11 -11
- package/dist/src/index.d.cts +724 -724
- package/dist/src/index.d.ts +724 -724
- package/dist/src/index.js +219 -219
- package/dist/src/index.js.map +2 -2
- package/dist/src/postconditions/index.cjs +26 -24
- package/dist/src/postconditions/index.cjs.map +2 -2
- package/dist/src/postconditions/index.d.cts +1 -1
- package/dist/src/postconditions/index.d.ts +1 -1
- package/dist/src/postconditions/index.js +16 -17
- package/dist/src/postconditions/index.js.map +1 -1
- package/dist/src/pox/index.cjs +722 -721
- package/dist/src/pox/index.cjs.map +9 -9
- package/dist/src/pox/index.d.cts +1 -1
- package/dist/src/pox/index.d.ts +1 -1
- package/dist/src/pox/index.js +40 -41
- package/dist/src/pox/index.js.map +2 -2
- package/dist/src/pox5/index.cjs +141 -137
- package/dist/src/pox5/index.cjs.map +3 -3
- package/dist/src/pox5/index.d.cts +9 -1
- package/dist/src/pox5/index.d.ts +9 -1
- package/dist/src/pox5/index.js +210 -209
- package/dist/src/pox5/index.js.map +3 -3
- package/dist/src/sbtc/index.cjs +71 -69
- package/dist/src/sbtc/index.cjs.map +2 -2
- package/dist/src/sbtc/index.d.cts +1 -1
- package/dist/src/sbtc/index.d.ts +1 -1
- package/dist/src/sbtc/index.js +39 -40
- package/dist/src/sbtc/index.js.map +2 -2
- package/dist/src/simnet/index.cjs +16 -16
- package/dist/src/simnet/index.cjs.map +2 -2
- package/dist/src/simnet/index.d.cts +1 -1
- package/dist/src/simnet/index.d.ts +1 -1
- package/dist/src/simnet/index.js +16 -16
- package/dist/src/simnet/index.js.map +2 -2
- package/dist/src/stackingdao/index.cjs +716 -715
- package/dist/src/stackingdao/index.cjs.map +9 -9
- package/dist/src/stackingdao/index.d.cts +1 -1
- package/dist/src/stackingdao/index.d.ts +1 -1
- package/dist/src/stackingdao/index.js +26 -27
- package/dist/src/stackingdao/index.js.map +2 -2
- package/dist/src/subscriptions/index.cjs +15 -13
- package/dist/src/subscriptions/index.cjs.map +2 -2
- package/dist/src/subscriptions/index.d.cts +1 -1
- package/dist/src/subscriptions/index.d.ts +1 -1
- package/dist/src/subscriptions/index.js +14 -15
- package/dist/src/subscriptions/index.js.map +1 -1
- package/dist/src/transactions/index.cjs +79 -77
- package/dist/src/transactions/index.cjs.map +2 -2
- package/dist/src/transactions/index.d.cts +1 -1
- package/dist/src/transactions/index.d.ts +1 -1
- package/dist/src/transactions/index.js +104 -105
- package/dist/src/transactions/index.js.map +1 -1
- package/dist/src/utils/index.cjs +76 -74
- package/dist/src/utils/index.cjs.map +2 -2
- package/dist/src/utils/index.d.cts +1 -1
- package/dist/src/utils/index.d.ts +1 -1
- package/dist/src/utils/index.js +131 -131
- package/dist/src/utils/index.js.map +2 -2
- package/package.json +1 -1
- package/dist/shared/stacks-esm-2mc7ebrm.js +0 -84
- package/dist/shared/stacks-esm-743jfh10.js +0 -50
- package/dist/shared/stacks-esm-pxhfqfff.js +0 -48
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./stacks-esm-
|
|
2
|
+
BaseError2
|
|
3
|
+
} from "./stacks-esm-7v18h5dk.js";
|
|
4
4
|
|
|
5
5
|
// src/errors/websocket.ts
|
|
6
|
-
class
|
|
6
|
+
class WebSocketError2 extends BaseError2 {
|
|
7
7
|
name = "WebSocketError";
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
// src/subscriptions/actions.ts
|
|
11
11
|
function getWsTransport(client) {
|
|
12
12
|
if (client.transport.type !== "webSocket") {
|
|
13
|
-
throw new
|
|
13
|
+
throw new WebSocketError2("Watch actions require a webSocket transport. Use `webSocket()` when creating your client.");
|
|
14
14
|
}
|
|
15
15
|
return client.transport;
|
|
16
16
|
}
|
|
17
|
-
async function
|
|
17
|
+
async function watchBlocks2(client, params) {
|
|
18
18
|
const transport = getWsTransport(client);
|
|
19
19
|
return transport.subscribe({ event: "block" }, params.onBlock);
|
|
20
20
|
}
|
|
21
|
-
async function
|
|
21
|
+
async function watchMempool2(client, params) {
|
|
22
22
|
const transport = getWsTransport(client);
|
|
23
23
|
return transport.subscribe({ event: "mempool" }, params.onTransaction);
|
|
24
24
|
}
|
|
25
|
-
async function
|
|
25
|
+
async function watchTransaction2(client, params) {
|
|
26
26
|
const transport = getWsTransport(client);
|
|
27
27
|
return transport.subscribe({ event: "tx_update", tx_id: params.txId }, params.onUpdate);
|
|
28
28
|
}
|
|
29
|
-
async function
|
|
29
|
+
async function watchAddress2(client, params) {
|
|
30
30
|
const transport = getWsTransport(client);
|
|
31
31
|
return transport.subscribe({ event: "address_tx_update", address: params.address }, params.onTransaction);
|
|
32
32
|
}
|
|
33
|
-
async function
|
|
33
|
+
async function watchAddressBalance2(client, params) {
|
|
34
34
|
const transport = getWsTransport(client);
|
|
35
35
|
return transport.subscribe({ event: "address_balance_update", address: params.address }, params.onBalance);
|
|
36
36
|
}
|
|
37
|
-
async function
|
|
37
|
+
async function watchNftEvent2(client, params) {
|
|
38
38
|
const transport = getWsTransport(client);
|
|
39
39
|
let event;
|
|
40
40
|
if (params.assetIdentifier && params.value) {
|
|
@@ -51,7 +51,7 @@ async function watchNftEvent(client, params) {
|
|
|
51
51
|
}, params.onEvent);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
export {
|
|
54
|
+
export { WebSocketError2, watchBlocks2, watchMempool2, watchTransaction2, watchAddress2, watchAddressBalance2, watchNftEvent2 };
|
|
55
55
|
|
|
56
|
-
//# debugId=
|
|
57
|
-
//# sourceMappingURL=stacks-esm-
|
|
56
|
+
//# debugId=2A76287E31CCA3FA64756E2164756E21
|
|
57
|
+
//# sourceMappingURL=stacks-esm-8jt6k8p3.js.map
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"import { BaseError } from \"./base.ts\";\n\nexport class WebSocketError extends BaseError {\n\toverride name = \"WebSocketError\";\n}\n",
|
|
6
6
|
"import type { Client } from \"../clients/types.ts\";\nimport { WebSocketError } from \"../errors/websocket.ts\";\nimport type { WebSocketTransport } from \"../transports/webSocket.ts\";\nimport type {\n\tAddressBalanceNotification,\n\tAddressTxNotification,\n\tBlockNotification,\n\tMempoolNotification,\n\tNftEventNotification,\n\tSubscription,\n\tTxUpdateNotification,\n} from \"./types.ts\";\n\nfunction getWsTransport(client: Client): WebSocketTransport {\n\tif (client.transport.type !== \"webSocket\") {\n\t\tthrow new WebSocketError(\n\t\t\t\"Watch actions require a webSocket transport. Use `webSocket()` when creating your client.\",\n\t\t);\n\t}\n\treturn client.transport as WebSocketTransport;\n}\n\nexport type WatchBlocksParams = {\n\tonBlock: (block: BlockNotification) => void;\n};\n\nexport async function watchBlocks(\n\tclient: Client,\n\tparams: WatchBlocksParams,\n): Promise<Subscription> {\n\tconst transport = getWsTransport(client);\n\treturn transport.subscribe({ event: \"block\" }, params.onBlock);\n}\n\nexport type WatchMempoolParams = {\n\tonTransaction: (tx: MempoolNotification) => void;\n};\n\nexport async function watchMempool(\n\tclient: Client,\n\tparams: WatchMempoolParams,\n): Promise<Subscription> {\n\tconst transport = getWsTransport(client);\n\treturn transport.subscribe({ event: \"mempool\" }, params.onTransaction);\n}\n\nexport type WatchTransactionParams = {\n\ttxId: string;\n\tonUpdate: (update: TxUpdateNotification) => void;\n};\n\nexport async function watchTransaction(\n\tclient: Client,\n\tparams: WatchTransactionParams,\n): Promise<Subscription> {\n\tconst transport = getWsTransport(client);\n\treturn transport.subscribe(\n\t\t{ event: \"tx_update\", tx_id: params.txId },\n\t\tparams.onUpdate,\n\t);\n}\n\nexport type WatchAddressParams = {\n\taddress: string;\n\tonTransaction: (tx: AddressTxNotification) => void;\n};\n\nexport async function watchAddress(\n\tclient: Client,\n\tparams: WatchAddressParams,\n): Promise<Subscription> {\n\tconst transport = getWsTransport(client);\n\treturn transport.subscribe(\n\t\t{ event: \"address_tx_update\", address: params.address },\n\t\tparams.onTransaction,\n\t);\n}\n\nexport type WatchAddressBalanceParams = {\n\taddress: string;\n\tonBalance: (balance: AddressBalanceNotification) => void;\n};\n\nexport async function watchAddressBalance(\n\tclient: Client,\n\tparams: WatchAddressBalanceParams,\n): Promise<Subscription> {\n\tconst transport = getWsTransport(client);\n\treturn transport.subscribe(\n\t\t{ event: \"address_balance_update\", address: params.address },\n\t\tparams.onBalance,\n\t);\n}\n\nexport type WatchNftEventParams = {\n\tonEvent: (event: NftEventNotification) => void;\n\tassetIdentifier?: string;\n\tvalue?: string;\n};\n\nexport async function watchNftEvent(\n\tclient: Client,\n\tparams: WatchNftEventParams,\n): Promise<Subscription> {\n\tconst transport = getWsTransport(client);\n\n\tlet event: \"nft_event\" | \"nft_asset_event\" | \"nft_collection_event\";\n\tif (params.assetIdentifier && params.value) {\n\t\tevent = \"nft_event\";\n\t} else if (params.assetIdentifier) {\n\t\tevent = \"nft_collection_event\";\n\t} else {\n\t\tevent = \"nft_event\";\n\t}\n\n\treturn transport.subscribe(\n\t\t{\n\t\t\tevent,\n\t\t\tasset_identifier: params.assetIdentifier,\n\t\t\tvalue: params.value,\n\t\t},\n\t\tparams.onEvent,\n\t);\n}\n"
|
|
7
7
|
],
|
|
8
|
-
"mappings": ";;;;;AAEO,MAAM,
|
|
9
|
-
"debugId": "
|
|
8
|
+
"mappings": ";;;;;AAEO,MAAM,wBAAuB,WAAU;AAAA,EACpC,OAAO;AACjB;;;ACSA,SAAS,cAAc,CAAC,QAAoC;AAAA,EAC3D,IAAI,OAAO,UAAU,SAAS,aAAa;AAAA,IAC1C,MAAM,IAAI,gBACT,2FACD;AAAA,EACD;AAAA,EACA,OAAO,OAAO;AAAA;AAOf,eAAsB,YAAW,CAChC,QACA,QACwB;AAAA,EACxB,MAAM,YAAY,eAAe,MAAM;AAAA,EACvC,OAAO,UAAU,UAAU,EAAE,OAAO,QAAQ,GAAG,OAAO,OAAO;AAAA;AAO9D,eAAsB,aAAY,CACjC,QACA,QACwB;AAAA,EACxB,MAAM,YAAY,eAAe,MAAM;AAAA,EACvC,OAAO,UAAU,UAAU,EAAE,OAAO,UAAU,GAAG,OAAO,aAAa;AAAA;AAQtE,eAAsB,iBAAgB,CACrC,QACA,QACwB;AAAA,EACxB,MAAM,YAAY,eAAe,MAAM;AAAA,EACvC,OAAO,UAAU,UAChB,EAAE,OAAO,aAAa,OAAO,OAAO,KAAK,GACzC,OAAO,QACR;AAAA;AAQD,eAAsB,aAAY,CACjC,QACA,QACwB;AAAA,EACxB,MAAM,YAAY,eAAe,MAAM;AAAA,EACvC,OAAO,UAAU,UAChB,EAAE,OAAO,qBAAqB,SAAS,OAAO,QAAQ,GACtD,OAAO,aACR;AAAA;AAQD,eAAsB,oBAAmB,CACxC,QACA,QACwB;AAAA,EACxB,MAAM,YAAY,eAAe,MAAM;AAAA,EACvC,OAAO,UAAU,UAChB,EAAE,OAAO,0BAA0B,SAAS,OAAO,QAAQ,GAC3D,OAAO,SACR;AAAA;AASD,eAAsB,cAAa,CAClC,QACA,QACwB;AAAA,EACxB,MAAM,YAAY,eAAe,MAAM;AAAA,EAEvC,IAAI;AAAA,EACJ,IAAI,OAAO,mBAAmB,OAAO,OAAO;AAAA,IAC3C,QAAQ;AAAA,EACT,EAAO,SAAI,OAAO,iBAAiB;AAAA,IAClC,QAAQ;AAAA,EACT,EAAO;AAAA,IACN,QAAQ;AAAA;AAAA,EAGT,OAAO,UAAU,UAChB;AAAA,IACC;AAAA,IACA,kBAAkB,OAAO;AAAA,IACzB,OAAO,OAAO;AAAA,EACf,GACA,OAAO,OACR;AAAA;",
|
|
9
|
+
"debugId": "2A76287E31CCA3FA64756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
|
@@ -1,71 +1,71 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
noneCV,
|
|
8
|
-
responseErrorCV,
|
|
9
|
-
responseOkCV,
|
|
10
|
-
someCV,
|
|
11
|
-
stringAsciiCV,
|
|
12
|
-
stringUtf8CV,
|
|
13
|
-
tupleCV,
|
|
14
|
-
uintCV
|
|
15
|
-
} from "./stacks-esm-fcfdn2zx.js";
|
|
2
|
+
MAX_U1282,
|
|
3
|
+
MAX_I1282,
|
|
4
|
+
MIN_I1282,
|
|
5
|
+
parsePrincipal2
|
|
6
|
+
} from "./stacks-esm-kbz5s6v8.js";
|
|
16
7
|
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
8
|
+
intCV2,
|
|
9
|
+
uintCV2,
|
|
10
|
+
boolCV2,
|
|
11
|
+
bufferCV2,
|
|
12
|
+
noneCV2,
|
|
13
|
+
someCV2,
|
|
14
|
+
responseOkCV2,
|
|
15
|
+
responseErrorCV2,
|
|
16
|
+
listCV2,
|
|
17
|
+
tupleCV2,
|
|
18
|
+
stringAsciiCV2,
|
|
19
|
+
stringUtf8CV2,
|
|
20
|
+
Cl2
|
|
21
|
+
} from "./stacks-esm-hkw1kvd4.js";
|
|
22
22
|
// src/clarity/abi/guards.ts
|
|
23
|
-
function
|
|
24
|
-
return typeof value === "bigint" && value >= 0n && value <=
|
|
23
|
+
function isUint1282(value) {
|
|
24
|
+
return typeof value === "bigint" && value >= 0n && value <= MAX_U1282;
|
|
25
25
|
}
|
|
26
|
-
function
|
|
27
|
-
return typeof value === "bigint" && value >=
|
|
26
|
+
function isInt1282(value) {
|
|
27
|
+
return typeof value === "bigint" && value >= MIN_I1282 && value <= MAX_I1282;
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function isBool2(value) {
|
|
30
30
|
return typeof value === "boolean";
|
|
31
31
|
}
|
|
32
|
-
function
|
|
33
|
-
return typeof value === "string" &&
|
|
32
|
+
function isPrincipal3(value) {
|
|
33
|
+
return typeof value === "string" && parsePrincipal2(value) !== null;
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function isStandardPrincipal2(value) {
|
|
36
36
|
if (typeof value !== "string")
|
|
37
37
|
return false;
|
|
38
|
-
const parsed =
|
|
38
|
+
const parsed = parsePrincipal2(value);
|
|
39
39
|
return parsed !== null && parsed.contractName === undefined;
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function isContractPrincipal2(value) {
|
|
42
42
|
if (typeof value !== "string")
|
|
43
43
|
return false;
|
|
44
|
-
const parsed =
|
|
44
|
+
const parsed = parsePrincipal2(value);
|
|
45
45
|
return parsed !== null && parsed.contractName !== undefined;
|
|
46
46
|
}
|
|
47
|
-
function
|
|
48
|
-
return
|
|
47
|
+
function isTraitReference2(value) {
|
|
48
|
+
return isContractPrincipal2(value);
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function isString2(value) {
|
|
51
51
|
return typeof value === "string";
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function isUint8Array2(value) {
|
|
54
54
|
return value instanceof Uint8Array;
|
|
55
55
|
}
|
|
56
|
-
function
|
|
56
|
+
function isArray2(value, itemGuard) {
|
|
57
57
|
return Array.isArray(value) && value.every(itemGuard);
|
|
58
58
|
}
|
|
59
|
-
function
|
|
59
|
+
function isOptional2(value, guard) {
|
|
60
60
|
return value === null || guard(value);
|
|
61
61
|
}
|
|
62
|
-
function
|
|
62
|
+
function isOkResponse2(response) {
|
|
63
63
|
return "ok" in response && !("err" in response);
|
|
64
64
|
}
|
|
65
|
-
function
|
|
65
|
+
function isErrResponse2(response) {
|
|
66
66
|
return "err" in response && !("ok" in response);
|
|
67
67
|
}
|
|
68
|
-
function
|
|
68
|
+
function isResponse2(value, okGuard, errGuard) {
|
|
69
69
|
if (typeof value !== "object" || value === null)
|
|
70
70
|
return false;
|
|
71
71
|
const obj = value;
|
|
@@ -75,33 +75,33 @@ function isResponse(value, okGuard, errGuard) {
|
|
|
75
75
|
return errGuard(obj.err);
|
|
76
76
|
return false;
|
|
77
77
|
}
|
|
78
|
-
function
|
|
78
|
+
function isAbiList2(type) {
|
|
79
79
|
return typeof type === "object" && type !== null && "list" in type;
|
|
80
80
|
}
|
|
81
|
-
function
|
|
81
|
+
function isAbiTuple2(type) {
|
|
82
82
|
return typeof type === "object" && type !== null && "tuple" in type;
|
|
83
83
|
}
|
|
84
|
-
function
|
|
84
|
+
function isAbiOptional2(type) {
|
|
85
85
|
return typeof type === "object" && type !== null && "optional" in type;
|
|
86
86
|
}
|
|
87
|
-
function
|
|
87
|
+
function isAbiResponse2(type) {
|
|
88
88
|
return typeof type === "object" && type !== null && "response" in type;
|
|
89
89
|
}
|
|
90
|
-
function
|
|
90
|
+
function isAbiBuffer2(type) {
|
|
91
91
|
return typeof type === "object" && type !== null && "buff" in type;
|
|
92
92
|
}
|
|
93
|
-
function
|
|
93
|
+
function isAbiStringAscii2(type) {
|
|
94
94
|
return typeof type === "object" && type !== null && "string-ascii" in type;
|
|
95
95
|
}
|
|
96
|
-
function
|
|
96
|
+
function isAbiStringUtf82(type) {
|
|
97
97
|
return typeof type === "object" && type !== null && "string-utf8" in type;
|
|
98
98
|
}
|
|
99
|
-
function
|
|
99
|
+
function isAbiTraitReference2(type) {
|
|
100
100
|
return type === "trait_reference";
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
// src/clarity/abi/utils.ts
|
|
104
|
-
function
|
|
104
|
+
function toCamelCase2(str) {
|
|
105
105
|
return str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase()).replace(/-([A-Z])/g, (_, letter) => letter).replace(/-(\d)/g, (_, digit) => digit).replace(/-/g, "").replace(/^\d/, "_$&");
|
|
106
106
|
}
|
|
107
107
|
|
|
@@ -123,7 +123,7 @@ var CV_TYPE_TAGS = new Set([
|
|
|
123
123
|
"ok",
|
|
124
124
|
"err"
|
|
125
125
|
]);
|
|
126
|
-
function
|
|
126
|
+
function isClarityValue2(value) {
|
|
127
127
|
if (typeof value !== "object" || value === null)
|
|
128
128
|
return false;
|
|
129
129
|
const type = value.type;
|
|
@@ -136,84 +136,84 @@ function isClarityValue(value) {
|
|
|
136
136
|
var HEX_PAIRS_REGEX = /^(?:[0-9a-fA-F]{2})+$/;
|
|
137
137
|
function coerceBuffer(value) {
|
|
138
138
|
if (value instanceof Uint8Array)
|
|
139
|
-
return
|
|
139
|
+
return bufferCV2(value);
|
|
140
140
|
if (typeof value === "object" && value !== null && "type" in value) {
|
|
141
141
|
const tagged = value;
|
|
142
|
-
if (tagged.type === "buffer" &&
|
|
142
|
+
if (tagged.type === "buffer" && isClarityValue2(value))
|
|
143
143
|
return value;
|
|
144
144
|
if (typeof tagged.value === "string") {
|
|
145
145
|
if (tagged.type === "ascii")
|
|
146
|
-
return
|
|
146
|
+
return Cl2.bufferFromAscii(tagged.value);
|
|
147
147
|
if (tagged.type === "utf8")
|
|
148
|
-
return
|
|
148
|
+
return Cl2.bufferFromUtf8(tagged.value);
|
|
149
149
|
if (tagged.type === "hex")
|
|
150
|
-
return
|
|
150
|
+
return Cl2.bufferFromHex(tagged.value);
|
|
151
151
|
}
|
|
152
152
|
throw new Error(`Unsupported buffer input: ${JSON.stringify(value)}`);
|
|
153
153
|
}
|
|
154
154
|
if (typeof value === "string") {
|
|
155
155
|
const hex = value.startsWith("0x") ? value.slice(2) : value;
|
|
156
156
|
if (HEX_PAIRS_REGEX.test(hex))
|
|
157
|
-
return
|
|
158
|
-
return
|
|
157
|
+
return Cl2.bufferFromHex(hex);
|
|
158
|
+
return Cl2.bufferFromUtf8(value);
|
|
159
159
|
}
|
|
160
160
|
throw new Error("buffer arg expects Uint8Array, hex string, { type, value }, or BufferCV");
|
|
161
161
|
}
|
|
162
|
-
function
|
|
163
|
-
if (
|
|
162
|
+
function jsToClarityValue2(abiType, value) {
|
|
163
|
+
if (isAbiBuffer2(abiType))
|
|
164
164
|
return coerceBuffer(value);
|
|
165
|
-
if (
|
|
165
|
+
if (isClarityValue2(value))
|
|
166
166
|
return value;
|
|
167
167
|
if (abiType === "uint128")
|
|
168
|
-
return
|
|
168
|
+
return uintCV2(value);
|
|
169
169
|
if (abiType === "int128")
|
|
170
|
-
return
|
|
170
|
+
return intCV2(value);
|
|
171
171
|
if (abiType === "bool")
|
|
172
|
-
return
|
|
172
|
+
return boolCV2(value);
|
|
173
173
|
if (abiType === "principal" || abiType === "trait_reference")
|
|
174
|
-
return
|
|
175
|
-
if (
|
|
176
|
-
return
|
|
177
|
-
if (
|
|
178
|
-
return
|
|
179
|
-
if (
|
|
174
|
+
return Cl2.principal(value);
|
|
175
|
+
if (isAbiStringAscii2(abiType))
|
|
176
|
+
return stringAsciiCV2(value);
|
|
177
|
+
if (isAbiStringUtf82(abiType))
|
|
178
|
+
return stringUtf8CV2(value);
|
|
179
|
+
if (isAbiList2(abiType)) {
|
|
180
180
|
const arr = value;
|
|
181
|
-
return
|
|
181
|
+
return listCV2(arr.map((item) => jsToClarityValue2(abiType.list.type, item)));
|
|
182
182
|
}
|
|
183
|
-
if (
|
|
183
|
+
if (isAbiTuple2(abiType)) {
|
|
184
184
|
const obj = value;
|
|
185
185
|
const data = {};
|
|
186
186
|
for (const field of abiType.tuple) {
|
|
187
|
-
const camelKey =
|
|
187
|
+
const camelKey = toCamelCase2(field.name);
|
|
188
188
|
const hasOriginal = field.name in obj;
|
|
189
189
|
const hasCamel = camelKey in obj;
|
|
190
190
|
const fieldValue = hasOriginal ? obj[field.name] : hasCamel ? obj[camelKey] : undefined;
|
|
191
|
-
if (fieldValue === undefined && !
|
|
191
|
+
if (fieldValue === undefined && !isAbiOptional2(field.type)) {
|
|
192
192
|
throw new Error(`Missing tuple field: ${field.name}`);
|
|
193
193
|
}
|
|
194
|
-
data[field.name] =
|
|
194
|
+
data[field.name] = jsToClarityValue2(field.type, fieldValue);
|
|
195
195
|
}
|
|
196
|
-
return
|
|
196
|
+
return tupleCV2(data);
|
|
197
197
|
}
|
|
198
|
-
if (
|
|
198
|
+
if (isAbiOptional2(abiType)) {
|
|
199
199
|
if (value === null || value === undefined)
|
|
200
|
-
return
|
|
201
|
-
return
|
|
200
|
+
return noneCV2();
|
|
201
|
+
return someCV2(jsToClarityValue2(abiType.optional, value));
|
|
202
202
|
}
|
|
203
|
-
if (
|
|
203
|
+
if (isAbiResponse2(abiType)) {
|
|
204
204
|
const obj = value;
|
|
205
205
|
if ("ok" in obj && !("err" in obj))
|
|
206
|
-
return
|
|
206
|
+
return responseOkCV2(jsToClarityValue2(abiType.response.ok, obj.ok));
|
|
207
207
|
if ("err" in obj && !("ok" in obj))
|
|
208
|
-
return
|
|
208
|
+
return responseErrorCV2(jsToClarityValue2(abiType.response.error, obj.err));
|
|
209
209
|
throw new Error("Response must have exactly 'ok' or 'err' property");
|
|
210
210
|
}
|
|
211
211
|
throw new Error(`Unknown ABI type: ${JSON.stringify(abiType)}`);
|
|
212
212
|
}
|
|
213
|
-
function
|
|
213
|
+
function clarityValueToJS2(abiType, cv) {
|
|
214
214
|
return clarityValueToJSInner(abiType, cv);
|
|
215
215
|
}
|
|
216
|
-
function
|
|
216
|
+
function clarityValueToJSUntyped2(abiType, cv) {
|
|
217
217
|
return clarityValueToJSInner(abiType, cv);
|
|
218
218
|
}
|
|
219
219
|
function clarityValueToJSInner(abiType, cv) {
|
|
@@ -234,12 +234,12 @@ function clarityValueToJSInner(abiType, cv) {
|
|
|
234
234
|
throw new Error(`Expected principal CV, got ${cv.type}`);
|
|
235
235
|
return cv.value;
|
|
236
236
|
}
|
|
237
|
-
if (
|
|
237
|
+
if (isAbiStringAscii2(abiType) || isAbiStringUtf82(abiType)) {
|
|
238
238
|
if (cv.type !== "ascii" && cv.type !== "utf8")
|
|
239
239
|
throw new Error(`Expected string CV, got ${cv.type}`);
|
|
240
240
|
return cv.value;
|
|
241
241
|
}
|
|
242
|
-
if (
|
|
242
|
+
if (isAbiBuffer2(abiType)) {
|
|
243
243
|
if (cv.type !== "buffer")
|
|
244
244
|
throw new Error(`Expected buffer CV, got ${cv.type}`);
|
|
245
245
|
const hex = cv.value;
|
|
@@ -249,12 +249,12 @@ function clarityValueToJSInner(abiType, cv) {
|
|
|
249
249
|
}
|
|
250
250
|
return bytes;
|
|
251
251
|
}
|
|
252
|
-
if (
|
|
252
|
+
if (isAbiList2(abiType)) {
|
|
253
253
|
if (cv.type !== "list")
|
|
254
254
|
throw new Error(`Expected list CV, got ${cv.type}`);
|
|
255
255
|
return cv.value.map((item) => clarityValueToJSInner(abiType.list.type, item));
|
|
256
256
|
}
|
|
257
|
-
if (
|
|
257
|
+
if (isAbiTuple2(abiType)) {
|
|
258
258
|
if (cv.type !== "tuple")
|
|
259
259
|
throw new Error(`Expected tuple CV, got ${cv.type}`);
|
|
260
260
|
const result = {};
|
|
@@ -262,19 +262,19 @@ function clarityValueToJSInner(abiType, cv) {
|
|
|
262
262
|
const fieldCV = cv.value[field.name];
|
|
263
263
|
if (!fieldCV)
|
|
264
264
|
throw new Error(`Missing tuple field in CV: ${field.name}`);
|
|
265
|
-
const camelKey =
|
|
265
|
+
const camelKey = toCamelCase2(field.name);
|
|
266
266
|
result[camelKey] = clarityValueToJSInner(field.type, fieldCV);
|
|
267
267
|
}
|
|
268
268
|
return result;
|
|
269
269
|
}
|
|
270
|
-
if (
|
|
270
|
+
if (isAbiOptional2(abiType)) {
|
|
271
271
|
if (cv.type === "none")
|
|
272
272
|
return null;
|
|
273
273
|
if (cv.type === "some")
|
|
274
274
|
return clarityValueToJSInner(abiType.optional, cv.value);
|
|
275
275
|
throw new Error(`Expected optional CV, got ${cv.type}`);
|
|
276
276
|
}
|
|
277
|
-
if (
|
|
277
|
+
if (isAbiResponse2(abiType)) {
|
|
278
278
|
if (cv.type === "ok")
|
|
279
279
|
return { ok: clarityValueToJSInner(abiType.response.ok, cv.value) };
|
|
280
280
|
if (cv.type === "err")
|
|
@@ -284,7 +284,7 @@ function clarityValueToJSInner(abiType, cv) {
|
|
|
284
284
|
throw new Error(`Unknown ABI type: ${JSON.stringify(abiType)}`);
|
|
285
285
|
}
|
|
286
286
|
|
|
287
|
-
export {
|
|
287
|
+
export { isUint1282, isInt1282, isBool2, isPrincipal3, isStandardPrincipal2, isContractPrincipal2, isTraitReference2, isString2, isUint8Array2, isArray2, isOptional2, isOkResponse2, isErrResponse2, isResponse2, isAbiList2, isAbiTuple2, isAbiOptional2, isAbiResponse2, isAbiBuffer2, isAbiStringAscii2, isAbiStringUtf82, isAbiTraitReference2, toCamelCase2, isClarityValue2, jsToClarityValue2, clarityValueToJS2, clarityValueToJSUntyped2 };
|
|
288
288
|
|
|
289
|
-
//# debugId=
|
|
290
|
-
//# sourceMappingURL=stacks-esm-
|
|
289
|
+
//# debugId=24A34C3ABD1FC51B64756E2164756E21
|
|
290
|
+
//# sourceMappingURL=stacks-esm-a20wyky3.js.map
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"type CamelCaseInner<S extends string> =\n\tS extends `${infer P1}-${infer P2}${infer P3}`\n\t\t? `${P1}${Capitalize<CamelCaseInner<`${P2}${P3}`>>}`\n\t\t: S;\n\nexport type ToCamelCase<S extends string> =\n\tCamelCaseInner<S> extends `${number}${string}`\n\t\t? `_${CamelCaseInner<S>}`\n\t\t: CamelCaseInner<S>;\n\nexport function toCamelCase(str: string): string {\n\treturn str\n\t\t.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase())\n\t\t.replace(/-([A-Z])/g, (_, letter) => letter)\n\t\t.replace(/-(\\d)/g, (_, digit) => digit)\n\t\t.replace(/-/g, \"\")\n\t\t.replace(/^\\d/, \"_$&\");\n}\n",
|
|
7
7
|
"import {\n\tisAbiBuffer,\n\tisAbiList,\n\tisAbiOptional,\n\tisAbiResponse,\n\tisAbiStringAscii,\n\tisAbiStringUtf8,\n\tisAbiTuple,\n} from \"./abi/guards.ts\";\nimport type { AbiToTS } from \"./abi/mappings.ts\";\nimport type { AbiType } from \"./abi/types.ts\";\nimport { toCamelCase } from \"./abi/utils.ts\";\nimport type { ClarityValue } from \"./types.ts\";\nimport {\n\tboolCV,\n\tbufferCV,\n\tintCV,\n\tlistCV,\n\tnoneCV,\n\tresponseErrorCV,\n\tresponseOkCV,\n\tsomeCV,\n\tstringAsciiCV,\n\tstringUtf8CV,\n\ttupleCV,\n\tuintCV,\n} from \"./values.ts\";\nimport { Cl } from \"./values.ts\";\n\n/** CV type tags — mirrors the discriminants of `ClarityValue`. */\nconst CV_TYPE_TAGS = new Set([\n\t\"int\",\n\t\"uint\",\n\t\"true\",\n\t\"false\",\n\t\"address\",\n\t\"contract\",\n\t\"ascii\",\n\t\"utf8\",\n\t\"buffer\",\n\t\"list\",\n\t\"tuple\",\n\t\"none\",\n\t\"some\",\n\t\"ok\",\n\t\"err\",\n]);\n\n/**\n * Duck-type check: is `value` already a built ClarityValue? Tag-only CVs\n * (`true`/`false`/`none`) have no payload; every other tag carries `value`.\n */\nexport function isClarityValue(value: unknown): value is ClarityValue {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tconst type = (value as { type?: unknown }).type;\n\tif (typeof type !== \"string\" || !CV_TYPE_TAGS.has(type)) return false;\n\tif (type === \"true\" || type === \"false\" || type === \"none\") return true;\n\treturn \"value\" in value;\n}\n\nconst HEX_PAIRS_REGEX = /^(?:[0-9a-fA-F]{2})+$/;\n\n/**\n * Coerce a flexible buffer input to a BufferCV. Accepts `Uint8Array`, a\n * pre-built `BufferCV`, a tagged `{ type: 'ascii' | 'utf8' | 'hex', value }`\n * object, or a bare string (even-length hex — optionally 0x-prefixed — is\n * decoded as hex; anything else is UTF-8 encoded).\n */\nfunction coerceBuffer(value: unknown): ClarityValue {\n\tif (value instanceof Uint8Array) return bufferCV(value);\n\tif (typeof value === \"object\" && value !== null && \"type\" in value) {\n\t\tconst tagged = value as { type: string; value?: unknown };\n\t\tif (tagged.type === \"buffer\" && isClarityValue(value)) return value;\n\t\tif (typeof tagged.value === \"string\") {\n\t\t\tif (tagged.type === \"ascii\") return Cl.bufferFromAscii(tagged.value);\n\t\t\tif (tagged.type === \"utf8\") return Cl.bufferFromUtf8(tagged.value);\n\t\t\tif (tagged.type === \"hex\") return Cl.bufferFromHex(tagged.value);\n\t\t}\n\t\tthrow new Error(`Unsupported buffer input: ${JSON.stringify(value)}`);\n\t}\n\tif (typeof value === \"string\") {\n\t\tconst hex = value.startsWith(\"0x\") ? value.slice(2) : value;\n\t\tif (HEX_PAIRS_REGEX.test(hex)) return Cl.bufferFromHex(hex);\n\t\treturn Cl.bufferFromUtf8(value);\n\t}\n\tthrow new Error(\n\t\t\"buffer arg expects Uint8Array, hex string, { type, value }, or BufferCV\",\n\t);\n}\n\n/**\n * Convert a JS value to a ClarityValue using ABI type information.\n *\n * Pre-built ClarityValues pass through unchanged (escape hatch for callers\n * that already hold a CV). Buffer args additionally accept hex strings and\n * tagged `{ type, value }` objects — matching the generated-client input\n * contract.\n */\nexport function jsToClarityValue(\n\tabiType: AbiType,\n\tvalue: unknown,\n): ClarityValue {\n\t// Buffers first: the tagged `{ type: 'ascii', value }` input form is\n\t// shape-identical to StringAsciiCV, so buffer coercion wins for buff args.\n\tif (isAbiBuffer(abiType)) return coerceBuffer(value);\n\n\tif (isClarityValue(value)) return value;\n\n\tif (abiType === \"uint128\") return uintCV(value as bigint | number);\n\tif (abiType === \"int128\") return intCV(value as bigint | number);\n\tif (abiType === \"bool\") return boolCV(value as boolean);\n\tif (abiType === \"principal\" || abiType === \"trait_reference\")\n\t\treturn Cl.principal(value as string);\n\n\tif (isAbiStringAscii(abiType)) return stringAsciiCV(value as string);\n\tif (isAbiStringUtf8(abiType)) return stringUtf8CV(value as string);\n\n\tif (isAbiList(abiType)) {\n\t\tconst arr = value as unknown[];\n\t\treturn listCV(arr.map((item) => jsToClarityValue(abiType.list.type, item)));\n\t}\n\n\tif (isAbiTuple(abiType)) {\n\t\tconst obj = value as Record<string, unknown>;\n\t\tconst data: Record<string, ClarityValue> = {};\n\t\tfor (const field of abiType.tuple) {\n\t\t\tconst camelKey = toCamelCase(field.name);\n\t\t\tconst hasOriginal = field.name in obj;\n\t\t\tconst hasCamel = camelKey in obj;\n\t\t\tconst fieldValue = hasOriginal\n\t\t\t\t? obj[field.name]\n\t\t\t\t: hasCamel\n\t\t\t\t\t? obj[camelKey]\n\t\t\t\t\t: undefined;\n\t\t\tif (fieldValue === undefined && !isAbiOptional(field.type)) {\n\t\t\t\tthrow new Error(`Missing tuple field: ${field.name}`);\n\t\t\t}\n\t\t\tdata[field.name] = jsToClarityValue(field.type, fieldValue);\n\t\t}\n\t\treturn tupleCV(data);\n\t}\n\n\tif (isAbiOptional(abiType)) {\n\t\tif (value === null || value === undefined) return noneCV();\n\t\treturn someCV(jsToClarityValue(abiType.optional, value));\n\t}\n\n\tif (isAbiResponse(abiType)) {\n\t\tconst obj = value as Record<string, unknown>;\n\t\tif (\"ok\" in obj && !(\"err\" in obj))\n\t\t\treturn responseOkCV(jsToClarityValue(abiType.response.ok, obj.ok));\n\t\tif (\"err\" in obj && !(\"ok\" in obj))\n\t\t\treturn responseErrorCV(jsToClarityValue(abiType.response.error, obj.err));\n\t\tthrow new Error(\"Response must have exactly 'ok' or 'err' property\");\n\t}\n\n\tthrow new Error(`Unknown ABI type: ${JSON.stringify(abiType)}`);\n}\n\n/**\n * Convert a ClarityValue back to a typed JS value using ABI type information.\n */\nexport function clarityValueToJS<T extends AbiType>(\n\tabiType: T,\n\tcv: ClarityValue,\n): AbiToTS<T> {\n\treturn clarityValueToJSInner(abiType, cv) as AbiToTS<T>;\n}\n\n/** Non-generic version for internal use — avoids deep type instantiation. */\nexport function clarityValueToJSUntyped(\n\tabiType: AbiType,\n\tcv: ClarityValue,\n): unknown {\n\treturn clarityValueToJSInner(abiType, cv);\n}\n\nfunction clarityValueToJSInner(abiType: AbiType, cv: ClarityValue): unknown {\n\tif (abiType === \"uint128\" || abiType === \"int128\") {\n\t\tif (cv.type !== \"int\" && cv.type !== \"uint\")\n\t\t\tthrow new Error(`Expected int/uint CV, got ${cv.type}`);\n\t\treturn cv.value;\n\t}\n\n\tif (abiType === \"bool\") {\n\t\tif (cv.type === \"true\") return true;\n\t\tif (cv.type === \"false\") return false;\n\t\tthrow new Error(`Expected bool CV, got ${cv.type}`);\n\t}\n\n\tif (abiType === \"principal\" || abiType === \"trait_reference\") {\n\t\tif (cv.type !== \"address\" && cv.type !== \"contract\")\n\t\t\tthrow new Error(`Expected principal CV, got ${cv.type}`);\n\t\treturn cv.value;\n\t}\n\n\tif (isAbiStringAscii(abiType) || isAbiStringUtf8(abiType)) {\n\t\tif (cv.type !== \"ascii\" && cv.type !== \"utf8\")\n\t\t\tthrow new Error(`Expected string CV, got ${cv.type}`);\n\t\treturn cv.value;\n\t}\n\n\tif (isAbiBuffer(abiType)) {\n\t\tif (cv.type !== \"buffer\")\n\t\t\tthrow new Error(`Expected buffer CV, got ${cv.type}`);\n\t\t// BufferCV stores hex string; convert back to Uint8Array\n\t\tconst hex = cv.value;\n\t\tconst bytes = new Uint8Array(hex.length / 2);\n\t\tfor (let i = 0; i < bytes.length; i++) {\n\t\t\tbytes[i] = Number.parseInt(hex.substring(i * 2, i * 2 + 2), 16);\n\t\t}\n\t\treturn bytes;\n\t}\n\n\tif (isAbiList(abiType)) {\n\t\tif (cv.type !== \"list\") throw new Error(`Expected list CV, got ${cv.type}`);\n\t\treturn cv.value.map((item) =>\n\t\t\tclarityValueToJSInner(abiType.list.type, item),\n\t\t);\n\t}\n\n\tif (isAbiTuple(abiType)) {\n\t\tif (cv.type !== \"tuple\")\n\t\t\tthrow new Error(`Expected tuple CV, got ${cv.type}`);\n\t\tconst result: Record<string, unknown> = {};\n\t\tfor (const field of abiType.tuple) {\n\t\t\tconst fieldCV = cv.value[field.name];\n\t\t\tif (!fieldCV) throw new Error(`Missing tuple field in CV: ${field.name}`);\n\t\t\tconst camelKey = toCamelCase(field.name);\n\t\t\tresult[camelKey] = clarityValueToJSInner(field.type, fieldCV);\n\t\t}\n\t\treturn result;\n\t}\n\n\tif (isAbiOptional(abiType)) {\n\t\tif (cv.type === \"none\") return null;\n\t\tif (cv.type === \"some\")\n\t\t\treturn clarityValueToJSInner(abiType.optional, cv.value);\n\t\tthrow new Error(`Expected optional CV, got ${cv.type}`);\n\t}\n\n\tif (isAbiResponse(abiType)) {\n\t\tif (cv.type === \"ok\")\n\t\t\treturn { ok: clarityValueToJSInner(abiType.response.ok, cv.value) };\n\t\tif (cv.type === \"err\")\n\t\t\treturn { err: clarityValueToJSInner(abiType.response.error, cv.value) };\n\t\tthrow new Error(`Expected response CV, got ${cv.type}`);\n\t}\n\n\tthrow new Error(`Unknown ABI type: ${JSON.stringify(abiType)}`);\n}\n"
|
|
8
8
|
],
|
|
9
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAiBO,SAAS,
|
|
10
|
-
"debugId": "
|
|
9
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAiBO,SAAS,UAAS,CAAC,OAAiC;AAAA,EAC1D,OAAO,OAAO,U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