@secondlayer/stacks 5.1.0 → 5.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -2
- package/dist/shared/{stacks-6gavarmy.js → stacks-1m3m1agc.js} +2 -2
- package/dist/shared/{stacks-db3kwavg.cjs → stacks-37kz5t9f.cjs} +4 -6
- package/dist/shared/{stacks-db3kwavg.cjs.map → stacks-37kz5t9f.cjs.map} +3 -3
- package/dist/shared/{stacks-w9t61fra.cjs → stacks-f35mnrmg.cjs} +6 -6
- package/dist/shared/stacks-f35mnrmg.cjs.map +10 -0
- package/dist/shared/{stacks-e3nwm1dz.js → stacks-fd4rx56e.js} +8 -8
- package/dist/shared/stacks-fd4rx56e.js.map +10 -0
- package/dist/shared/{stacks-7bqkf3b0.js → stacks-mbt36bzt.js} +3 -3
- package/dist/shared/{stacks-ga026yxz.js → stacks-qex691bh.js} +11 -4
- package/dist/shared/stacks-qex691bh.js.map +11 -0
- package/dist/shared/{stacks-n4d8j8q3.js → stacks-v03zef3g.js} +5 -7
- package/dist/shared/{stacks-n4d8j8q3.js.map → stacks-v03zef3g.js.map} +3 -3
- package/dist/shared/{stacks-ggdz96r1.cjs → stacks-wk8yp13j.cjs} +10 -3
- package/dist/shared/stacks-wk8yp13j.cjs.map +11 -0
- package/dist/src/actions/index.d.cts +19 -7
- package/dist/src/actions/index.d.ts +19 -7
- package/dist/src/actions/index.js +5 -5
- package/dist/src/bitcoin/index.js +1 -1
- package/dist/src/bns/index.js +3 -3
- package/dist/src/index.cjs +2 -1
- package/dist/src/index.cjs.map +2 -2
- package/dist/src/index.d.cts +5 -1
- package/dist/src/index.d.ts +5 -1
- package/dist/src/index.js +7 -5
- package/dist/src/index.js.map +2 -2
- package/dist/src/pox/index.js +3 -3
- package/dist/src/pox5/index.js +4 -4
- package/dist/src/sbtc/index.js +3 -3
- package/dist/src/stackingdao/index.js +3 -3
- package/dist/src/tools/index.cjs +15 -10
- package/dist/src/tools/index.cjs.map +6 -6
- package/dist/src/tools/index.js +15 -10
- package/dist/src/tools/index.js.map +6 -6
- package/package.json +1 -1
- package/dist/shared/stacks-e3nwm1dz.js.map +0 -10
- package/dist/shared/stacks-ga026yxz.js.map +0 -11
- package/dist/shared/stacks-ggdz96r1.cjs.map +0 -11
- package/dist/shared/stacks-w9t61fra.cjs.map +0 -10
- /package/dist/shared/{stacks-6gavarmy.js.map → stacks-1m3m1agc.js.map} +0 -0
- /package/dist/shared/{stacks-7bqkf3b0.js.map → stacks-mbt36bzt.js.map} +0 -0
package/dist/src/tools/index.js
CHANGED
|
@@ -47,6 +47,10 @@ class MalformedResponseError extends BaseError {
|
|
|
47
47
|
name = "MalformedResponseError";
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
class ReadContractError extends BaseError {
|
|
51
|
+
name = "ReadContractError";
|
|
52
|
+
}
|
|
53
|
+
|
|
50
54
|
// src/utils/c32.ts
|
|
51
55
|
import { sha256 } from "@noble/hashes/sha2.js";
|
|
52
56
|
|
|
@@ -1390,9 +1394,12 @@ async function readContract(client, params) {
|
|
|
1390
1394
|
}
|
|
1391
1395
|
});
|
|
1392
1396
|
if (data.okay) {
|
|
1397
|
+
if (typeof data.result !== "string") {
|
|
1398
|
+
throw new MalformedResponseError(`readContract: /v2/contracts/call-read response is missing "result"`);
|
|
1399
|
+
}
|
|
1393
1400
|
return deserializeCVBytes(data.result);
|
|
1394
1401
|
}
|
|
1395
|
-
throw new
|
|
1402
|
+
throw new ReadContractError(data.cause ?? "Read-only call failed");
|
|
1396
1403
|
}
|
|
1397
1404
|
|
|
1398
1405
|
// src/actions/wallet/utils.ts
|
|
@@ -2248,12 +2255,10 @@ async function getMapEntry(client, params) {
|
|
|
2248
2255
|
|
|
2249
2256
|
// src/actions/public/getNonce.ts
|
|
2250
2257
|
async function getNonce(client, params) {
|
|
2251
|
-
const data = await client.request(`/v2/accounts/${params.address}`, {
|
|
2252
|
-
method: "GET"
|
|
2253
|
-
});
|
|
2258
|
+
const data = await client.request(`/v2/accounts/${encodeURIComponent(params.address)}`, { method: "GET" });
|
|
2254
2259
|
const nonce = data?.nonce;
|
|
2255
2260
|
if (typeof nonce !== "number" && typeof nonce !== "string") {
|
|
2256
|
-
throw new
|
|
2261
|
+
throw new MalformedResponseError(`getNonce: /v2/accounts/${params.address} response is missing "nonce"`);
|
|
2257
2262
|
}
|
|
2258
2263
|
return BigInt(nonce);
|
|
2259
2264
|
}
|
|
@@ -2505,7 +2510,7 @@ function getContract(params) {
|
|
|
2505
2510
|
const fn = fnByName.get(fnName);
|
|
2506
2511
|
if (!fn || fn.access !== "read-only")
|
|
2507
2512
|
return;
|
|
2508
|
-
return async (args) => {
|
|
2513
|
+
return async (args = {}) => {
|
|
2509
2514
|
const clarityArgs = buildFunctionArgs(fn, args);
|
|
2510
2515
|
const result = await readContract(client, {
|
|
2511
2516
|
contract: contractId,
|
|
@@ -2529,7 +2534,7 @@ function getContract(params) {
|
|
|
2529
2534
|
const fn = fnByName.get(fnName);
|
|
2530
2535
|
if (!fn || fn.access !== "public")
|
|
2531
2536
|
return;
|
|
2532
|
-
return async (args, options) => {
|
|
2537
|
+
return async (args = {}, options) => {
|
|
2533
2538
|
const clarityArgs = buildFunctionArgs(fn, args);
|
|
2534
2539
|
return callContract(client, {
|
|
2535
2540
|
contract: contractId,
|
|
@@ -2546,7 +2551,7 @@ function getContract(params) {
|
|
|
2546
2551
|
const fn = fnByName.get(fnName);
|
|
2547
2552
|
if (!fn || fn.access !== "public")
|
|
2548
2553
|
return;
|
|
2549
|
-
return async (args, options) => {
|
|
2554
|
+
return async (args = {}, options) => {
|
|
2550
2555
|
const publicKey = options?.publicKey ?? client.account?.publicKey;
|
|
2551
2556
|
if (!publicKey) {
|
|
2552
2557
|
throw new Error("buildCall requires a publicKey (pass options.publicKey or configure a client account)");
|
|
@@ -2607,7 +2612,7 @@ function resolveNetworkContract(client, contracts) {
|
|
|
2607
2612
|
}
|
|
2608
2613
|
return contracts[client.chain.network];
|
|
2609
2614
|
}
|
|
2610
|
-
function buildFunctionArgs(fn, args) {
|
|
2615
|
+
function buildFunctionArgs(fn, args = {}) {
|
|
2611
2616
|
return fn.args.map((arg) => {
|
|
2612
2617
|
const camelKey = toCamelCase(arg.name);
|
|
2613
2618
|
const hasOriginal = arg.name in args;
|
|
@@ -3818,5 +3823,5 @@ export {
|
|
|
3818
3823
|
bnsResolve
|
|
3819
3824
|
};
|
|
3820
3825
|
|
|
3821
|
-
//# debugId=
|
|
3826
|
+
//# debugId=BF92A0AEA897CFBD64756E2164756E21
|
|
3822
3827
|
//# sourceMappingURL=index.js.map
|