@secondlayer/stacks 2.5.2 → 2.7.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/README.md +65 -0
- package/dist/shared/{stacks-jevhg39n.cjs → stacks-7nf5h3qe.cjs} +16 -12
- package/dist/shared/{stacks-jevhg39n.cjs.map → stacks-7nf5h3qe.cjs.map} +4 -4
- package/dist/shared/{stacks-5th5dffx.js → stacks-a48qj7ss.js} +20 -16
- package/dist/shared/{stacks-5th5dffx.js.map → stacks-a48qj7ss.js.map} +4 -4
- package/dist/shared/{stacks-7wfdkhj6.cjs → stacks-e7pmsrbs.cjs} +9 -7
- package/dist/shared/{stacks-7wfdkhj6.cjs.map → stacks-e7pmsrbs.cjs.map} +3 -3
- package/dist/shared/{stacks-7wqprfrm.cjs → stacks-hxm7r5ay.cjs} +3 -3
- package/dist/shared/{stacks-7wqprfrm.cjs.map → stacks-hxm7r5ay.cjs.map} +3 -3
- package/dist/shared/{stacks-hyz7zgdk.js → stacks-k96f5g1a.js} +2 -2
- package/dist/shared/stacks-r3mqgw2d.js +204 -0
- package/dist/shared/stacks-r3mqgw2d.js.map +15 -0
- package/dist/shared/{stacks-4z1jhw6y.js → stacks-s6v8k4j5.js} +6 -6
- package/dist/shared/{stacks-4z1jhw6y.js.map → stacks-s6v8k4j5.js.map} +3 -3
- package/dist/shared/{stacks-yq5a5cda.js → stacks-txh6dadn.js} +12 -10
- package/dist/shared/{stacks-yq5a5cda.js.map → stacks-txh6dadn.js.map} +3 -3
- package/dist/shared/stacks-wb06pevp.cjs +190 -0
- package/dist/shared/stacks-wb06pevp.cjs.map +15 -0
- package/dist/src/actions/index.d.cts +138 -120
- package/dist/src/actions/index.d.ts +138 -120
- package/dist/src/actions/index.js +5 -5
- package/dist/src/bns/index.d.cts +18 -0
- package/dist/src/bns/index.d.ts +18 -0
- package/dist/src/bns/index.js +3 -3
- package/dist/src/index.cjs +180 -5
- package/dist/src/index.cjs.map +7 -5
- package/dist/src/index.d.cts +377 -101
- package/dist/src/index.d.ts +377 -101
- package/dist/src/index.js +193 -10
- package/dist/src/index.js.map +7 -5
- package/dist/src/pox/index.d.cts +18 -0
- package/dist/src/pox/index.d.ts +18 -0
- package/dist/src/pox/index.js +3 -3
- package/dist/src/sbtc/index.d.cts +18 -0
- package/dist/src/sbtc/index.d.ts +18 -0
- package/dist/src/sbtc/index.js +3 -3
- package/dist/src/stackingdao/index.d.cts +18 -0
- package/dist/src/stackingdao/index.d.ts +18 -0
- package/dist/src/stackingdao/index.js +3 -3
- package/dist/src/subscriptions/index.d.cts +18 -0
- package/dist/src/subscriptions/index.d.ts +18 -0
- package/dist/src/tools/index.cjs +44 -14
- package/dist/src/tools/index.cjs.map +7 -6
- package/dist/src/tools/index.d.cts +18 -0
- package/dist/src/tools/index.d.ts +18 -0
- package/dist/src/tools/index.js +44 -14
- package/dist/src/tools/index.js.map +7 -6
- package/dist/src/x402/index.d.cts +18 -0
- package/dist/src/x402/index.d.ts +18 -0
- package/dist/src/x402/index.js +2 -2
- package/package.json +1 -1
- package/dist/shared/stacks-qk8pdyjy.cjs +0 -76
- package/dist/shared/stacks-qk8pdyjy.cjs.map +0 -14
- package/dist/shared/stacks-y8e3gx6w.js +0 -90
- package/dist/shared/stacks-y8e3gx6w.js.map +0 -14
- /package/dist/shared/{stacks-hyz7zgdk.js.map → stacks-k96f5g1a.js.map} +0 -0
|
@@ -362,6 +362,22 @@ type ProviderAccount = {
|
|
|
362
362
|
publicKey: string
|
|
363
363
|
provider: StacksProvider
|
|
364
364
|
};
|
|
365
|
+
/** Allocates mempool-safe sequential nonces across rapid broadcasts from one account. */
|
|
366
|
+
type NonceManager = {
|
|
367
|
+
consume(params: {
|
|
368
|
+
client: Client
|
|
369
|
+
address: string
|
|
370
|
+
}): Promise<bigint>
|
|
371
|
+
reset(params: {
|
|
372
|
+
client: Client
|
|
373
|
+
address: string
|
|
374
|
+
}): void | Promise<void>
|
|
375
|
+
/** Next nonce that {@link NonceManager.consume} would return without consuming it, or `undefined` if untracked. */
|
|
376
|
+
peek(params: {
|
|
377
|
+
client: Client
|
|
378
|
+
address: string
|
|
379
|
+
}): Promise<bigint | undefined>
|
|
380
|
+
};
|
|
365
381
|
/** Function that sends an HTTP request to a Stacks node API path. */
|
|
366
382
|
type RequestFn = (path: string, options?: RequestOptions) => Promise<any>;
|
|
367
383
|
/** Options for a transport-level HTTP request. */
|
|
@@ -397,6 +413,8 @@ type Client<TExtended extends Record<string, unknown> = Record<string, unknown>>
|
|
|
397
413
|
account?: Account
|
|
398
414
|
transport: Transport
|
|
399
415
|
request: RequestFn
|
|
416
|
+
/** Optional nonce manager for mempool-safe sequential nonces across rapid broadcasts. */
|
|
417
|
+
nonceManager?: NonceManager
|
|
400
418
|
extend: <const TNew extends Record<string, unknown>>(fn: (client: Client<TExtended>) => TNew) => Client<TExtended & TNew> & TNew
|
|
401
419
|
} & TExtended;
|
|
402
420
|
type SponsorAndBroadcastOptions = {
|
package/dist/src/x402/index.d.ts
CHANGED
|
@@ -362,6 +362,22 @@ type ProviderAccount = {
|
|
|
362
362
|
publicKey: string
|
|
363
363
|
provider: StacksProvider
|
|
364
364
|
};
|
|
365
|
+
/** Allocates mempool-safe sequential nonces across rapid broadcasts from one account. */
|
|
366
|
+
type NonceManager = {
|
|
367
|
+
consume(params: {
|
|
368
|
+
client: Client
|
|
369
|
+
address: string
|
|
370
|
+
}): Promise<bigint>
|
|
371
|
+
reset(params: {
|
|
372
|
+
client: Client
|
|
373
|
+
address: string
|
|
374
|
+
}): void | Promise<void>
|
|
375
|
+
/** Next nonce that {@link NonceManager.consume} would return without consuming it, or `undefined` if untracked. */
|
|
376
|
+
peek(params: {
|
|
377
|
+
client: Client
|
|
378
|
+
address: string
|
|
379
|
+
}): Promise<bigint | undefined>
|
|
380
|
+
};
|
|
365
381
|
/** Function that sends an HTTP request to a Stacks node API path. */
|
|
366
382
|
type RequestFn = (path: string, options?: RequestOptions) => Promise<any>;
|
|
367
383
|
/** Options for a transport-level HTTP request. */
|
|
@@ -397,6 +413,8 @@ type Client<TExtended extends Record<string, unknown> = Record<string, unknown>>
|
|
|
397
413
|
account?: Account
|
|
398
414
|
transport: Transport
|
|
399
415
|
request: RequestFn
|
|
416
|
+
/** Optional nonce manager for mempool-safe sequential nonces across rapid broadcasts. */
|
|
417
|
+
nonceManager?: NonceManager
|
|
400
418
|
extend: <const TNew extends Record<string, unknown>>(fn: (client: Client<TExtended>) => TNew) => Client<TExtended & TNew> & TNew
|
|
401
419
|
} & TExtended;
|
|
402
420
|
type SponsorAndBroadcastOptions = {
|
package/dist/src/x402/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
sponsorTransaction
|
|
3
|
-
} from "../../shared/stacks-
|
|
3
|
+
} from "../../shared/stacks-s6v8k4j5.js";
|
|
4
4
|
import {
|
|
5
5
|
sendTransaction
|
|
6
|
-
} from "../../shared/stacks-
|
|
6
|
+
} from "../../shared/stacks-r3mqgw2d.js";
|
|
7
7
|
import"../../shared/stacks-709tra19.js";
|
|
8
8
|
import {
|
|
9
9
|
Pc
|
package/package.json
CHANGED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
// src/actions/public/estimateFee.ts
|
|
2
|
-
async function estimateFee(client, params) {
|
|
3
|
-
const payloadHex = bytesToHex(serializePayload(params.transaction.payload));
|
|
4
|
-
const txHex = bytesToHex(serializeTransaction(params.transaction));
|
|
5
|
-
const data = await client.request("/v2/fees/transaction", {
|
|
6
|
-
method: "POST",
|
|
7
|
-
body: {
|
|
8
|
-
estimated_len: Math.ceil(txHex.length / 2),
|
|
9
|
-
transaction_payload: `0x${payloadHex}`
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
return (data.estimations ?? []).map((e) => ({
|
|
13
|
-
feeRate: e.fee_rate,
|
|
14
|
-
fee: e.fee
|
|
15
|
-
}));
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// src/actions/public/getNonce.ts
|
|
19
|
-
async function getNonce(client, params) {
|
|
20
|
-
const data = await client.request(`/v2/accounts/${params.address}`, {
|
|
21
|
-
method: "GET"
|
|
22
|
-
});
|
|
23
|
-
return BigInt(data.nonce);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// src/errors/transaction.ts
|
|
27
|
-
class TransactionError extends BaseError {
|
|
28
|
-
name = "TransactionError";
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
class BroadcastError extends BaseError {
|
|
32
|
-
name = "BroadcastError";
|
|
33
|
-
txid;
|
|
34
|
-
reason;
|
|
35
|
-
constructor(message, options) {
|
|
36
|
-
super(message, options);
|
|
37
|
-
this.txid = options?.txid;
|
|
38
|
-
this.reason = options?.reason;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
class SerializationError extends BaseError {
|
|
43
|
-
name = "SerializationError";
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
class SigningError extends BaseError {
|
|
47
|
-
name = "SigningError";
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// src/actions/wallet/sendTransaction.ts
|
|
51
|
-
async function sendTransaction(client, params) {
|
|
52
|
-
const hex = bytesToHex(serializeTransaction(params.transaction));
|
|
53
|
-
const body = { tx: hex };
|
|
54
|
-
if (params.attachment) {
|
|
55
|
-
body.attachment = typeof params.attachment === "string" ? params.attachment : bytesToHex(params.attachment);
|
|
56
|
-
}
|
|
57
|
-
const data = await client.request("/v2/transactions", {
|
|
58
|
-
method: "POST",
|
|
59
|
-
body
|
|
60
|
-
});
|
|
61
|
-
if (data.error) {
|
|
62
|
-
throw new BroadcastError(data.reason ?? data.error, {
|
|
63
|
-
reason: data.reason
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
const txid = typeof data === "string" ? data.replace(/"/g, "") : data.txid ?? getTransactionId(params.transaction);
|
|
67
|
-
return { txid };
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// src/actions/wallet/utils.ts
|
|
71
|
-
function isProviderAccount(account) {
|
|
72
|
-
return account.type === "provider";
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
//# debugId=133EC4FD25ABDD7664756E2164756E21
|
|
76
|
-
//# sourceMappingURL=stacks-qk8pdyjy.cjs.map
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/actions/public/estimateFee.ts", "../src/actions/public/getNonce.ts", "../src/errors/transaction.ts", "../src/actions/wallet/sendTransaction.ts", "../src/actions/wallet/utils.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"import type { Client } from \"../../clients/types.ts\";\nimport type { StacksTransaction } from \"../../transactions/types.ts\";\nimport {\n\tserializePayload,\n\tserializeTransaction,\n} from \"../../transactions/wire/serialize.ts\";\nimport { bytesToHex } from \"../../utils/encoding.ts\";\n\nexport type EstimateFeeParams = {\n\ttransaction: StacksTransaction;\n};\n\nexport type FeeEstimation = {\n\tfeeRate: number;\n\tfee: number;\n};\n\nexport async function estimateFee(\n\tclient: Client,\n\tparams: EstimateFeeParams,\n): Promise<FeeEstimation[]> {\n\tconst payloadHex = bytesToHex(serializePayload(params.transaction.payload));\n\tconst txHex = bytesToHex(serializeTransaction(params.transaction));\n\n\tconst data = await client.request(\"/v2/fees/transaction\", {\n\t\tmethod: \"POST\",\n\t\tbody: {\n\t\t\testimated_len: Math.ceil(txHex.length / 2),\n\t\t\ttransaction_payload: `0x${payloadHex}`,\n\t\t},\n\t});\n\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\treturn (data.estimations ?? []).map((e: any) => ({\n\t\tfeeRate: e.fee_rate,\n\t\tfee: e.fee,\n\t}));\n}\n",
|
|
6
|
-
"import type { Client } from \"../../clients/types.ts\";\n\nexport type GetNonceParams = {\n\taddress: string;\n};\n\nexport type GetNonceResult = {\n\tnonce: bigint;\n\tpossibleNextNonce: bigint;\n};\n\nexport async function getNonce(\n\tclient: Client,\n\tparams: GetNonceParams,\n): Promise<bigint> {\n\tconst data = await client.request(`/v2/accounts/${params.address}`, {\n\t\tmethod: \"GET\",\n\t});\n\treturn BigInt(data.nonce);\n}\n",
|
|
7
|
-
"import { BaseError } from \"./base.ts\";\n\nexport class TransactionError extends BaseError {\n\toverride name = \"TransactionError\";\n}\n\nexport class BroadcastError extends BaseError {\n\toverride name = \"BroadcastError\";\n\ttxid?: string;\n\treason?: string;\n\n\tconstructor(\n\t\tmessage: string,\n\t\toptions?: { cause?: Error; txid?: string; reason?: string },\n\t) {\n\t\tsuper(message, options);\n\t\tthis.txid = options?.txid;\n\t\tthis.reason = options?.reason;\n\t}\n}\n\nexport class SerializationError extends BaseError {\n\toverride name = \"SerializationError\";\n}\n\nexport class SigningError extends BaseError {\n\toverride name = \"SigningError\";\n}\n",
|
|
8
|
-
"import type { Client } from \"../../clients/types.ts\";\nimport { BroadcastError } from \"../../errors/transaction.ts\";\nimport { getTransactionId } from \"../../transactions/signer.ts\";\nimport type { StacksTransaction } from \"../../transactions/types.ts\";\nimport { serializeTransaction } from \"../../transactions/wire/serialize.ts\";\nimport { bytesToHex } from \"../../utils/encoding.ts\";\n\nexport type SendTransactionParams = {\n\ttransaction: StacksTransaction;\n\tattachment?: Uint8Array | string;\n};\n\nexport type SendTransactionResult = {\n\ttxid: string;\n};\n\n/** Broadcast a signed transaction to the network */\nexport async function sendTransaction(\n\tclient: Client,\n\tparams: SendTransactionParams,\n): Promise<SendTransactionResult> {\n\tconst hex = bytesToHex(serializeTransaction(params.transaction));\n\n\tconst body: Record<string, string> = { tx: hex };\n\tif (params.attachment) {\n\t\tbody.attachment =\n\t\t\ttypeof params.attachment === \"string\"\n\t\t\t\t? params.attachment\n\t\t\t\t: bytesToHex(params.attachment);\n\t}\n\n\tconst data = await client.request(\"/v2/transactions\", {\n\t\tmethod: \"POST\",\n\t\tbody,\n\t});\n\n\tif (data.error) {\n\t\tthrow new BroadcastError(data.reason ?? data.error, {\n\t\t\treason: data.reason,\n\t\t});\n\t}\n\n\tconst txid =\n\t\ttypeof data === \"string\"\n\t\t\t? data.replace(/\"/g, \"\")\n\t\t\t: (data.txid ?? getTransactionId(params.transaction));\n\n\treturn { txid };\n}\n",
|
|
9
|
-
"import type { ProviderAccount } from \"../../accounts/types.ts\";\nimport type { Account } from \"../../clients/types.ts\";\n\nexport function isProviderAccount(\n\taccount: Account,\n): account is ProviderAccount {\n\treturn account.type === \"provider\";\n}\n"
|
|
10
|
-
],
|
|
11
|
-
"mappings": ";AAiBA,eAAsB,WAAW,CAChC,QACA,QAC2B;AAAA,EAC3B,MAAM,aAAa,WAAW,iBAAiB,OAAO,YAAY,OAAO,CAAC;AAAA,EAC1E,MAAM,QAAQ,WAAW,qBAAqB,OAAO,WAAW,CAAC;AAAA,EAEjE,MAAM,OAAO,MAAM,OAAO,QAAQ,wBAAwB;AAAA,IACzD,QAAQ;AAAA,IACR,MAAM;AAAA,MACL,eAAe,KAAK,KAAK,MAAM,SAAS,CAAC;AAAA,MACzC,qBAAqB,KAAK;AAAA,IAC3B;AAAA,EACD,CAAC;AAAA,EAGD,QAAQ,KAAK,eAAe,CAAC,GAAG,IAAI,CAAC,OAAY;AAAA,IAChD,SAAS,EAAE;AAAA,IACX,KAAK,EAAE;AAAA,EACR,EAAE;AAAA;;;ACzBH,eAAsB,QAAQ,CAC7B,QACA,QACkB;AAAA,EAClB,MAAM,OAAO,MAAM,OAAO,QAAQ,gBAAgB,OAAO,WAAW;AAAA,IACnE,QAAQ;AAAA,EACT,CAAC;AAAA,EACD,OAAO,OAAO,KAAK,KAAK;AAAA;;;AChBlB,MAAM,yBAAyB,UAAU;AAAA,EACtC,OAAO;AACjB;AAAA;AAEO,MAAM,uBAAuB,UAAU;AAAA,EACpC,OAAO;AAAA,EAChB;AAAA,EACA;AAAA,EAEA,WAAW,CACV,SACA,SACC;AAAA,IACD,MAAM,SAAS,OAAO;AAAA,IACtB,KAAK,OAAO,SAAS;AAAA,IACrB,KAAK,SAAS,SAAS;AAAA;AAEzB;AAAA;AAEO,MAAM,2BAA2B,UAAU;AAAA,EACxC,OAAO;AACjB;AAAA;AAEO,MAAM,qBAAqB,UAAU;AAAA,EAClC,OAAO;AACjB;;;ACVA,eAAsB,eAAe,CACpC,QACA,QACiC;AAAA,EACjC,MAAM,MAAM,WAAW,qBAAqB,OAAO,WAAW,CAAC;AAAA,EAE/D,MAAM,OAA+B,EAAE,IAAI,IAAI;AAAA,EAC/C,IAAI,OAAO,YAAY;AAAA,IACtB,KAAK,aACJ,OAAO,OAAO,eAAe,WAC1B,OAAO,aACP,WAAW,OAAO,UAAU;AAAA,EACjC;AAAA,EAEA,MAAM,OAAO,MAAM,OAAO,QAAQ,oBAAoB;AAAA,IACrD,QAAQ;AAAA,IACR;AAAA,EACD,CAAC;AAAA,EAED,IAAI,KAAK,OAAO;AAAA,IACf,MAAM,IAAI,eAAe,KAAK,UAAU,KAAK,OAAO;AAAA,MACnD,QAAQ,KAAK;AAAA,IACd,CAAC;AAAA,EACF;AAAA,EAEA,MAAM,OACL,OAAO,SAAS,WACb,KAAK,QAAQ,MAAM,EAAE,IACpB,KAAK,QAAQ,iBAAiB,OAAO,WAAW;AAAA,EAErD,OAAO,EAAE,KAAK;AAAA;;;AC5CR,SAAS,iBAAiB,CAChC,SAC6B;AAAA,EAC7B,OAAO,QAAQ,SAAS;AAAA;",
|
|
12
|
-
"debugId": "133EC4FD25ABDD7664756E2164756E21",
|
|
13
|
-
"names": []
|
|
14
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BaseError
|
|
3
|
-
} from "./stacks-709tra19.js";
|
|
4
|
-
import {
|
|
5
|
-
getTransactionId,
|
|
6
|
-
serializePayload,
|
|
7
|
-
serializeTransaction
|
|
8
|
-
} from "./stacks-4trgpb5a.js";
|
|
9
|
-
import {
|
|
10
|
-
bytesToHex
|
|
11
|
-
} from "./stacks-2h8d2y27.js";
|
|
12
|
-
|
|
13
|
-
// src/actions/public/estimateFee.ts
|
|
14
|
-
async function estimateFee(client, params) {
|
|
15
|
-
const payloadHex = bytesToHex(serializePayload(params.transaction.payload));
|
|
16
|
-
const txHex = bytesToHex(serializeTransaction(params.transaction));
|
|
17
|
-
const data = await client.request("/v2/fees/transaction", {
|
|
18
|
-
method: "POST",
|
|
19
|
-
body: {
|
|
20
|
-
estimated_len: Math.ceil(txHex.length / 2),
|
|
21
|
-
transaction_payload: `0x${payloadHex}`
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
return (data.estimations ?? []).map((e) => ({
|
|
25
|
-
feeRate: e.fee_rate,
|
|
26
|
-
fee: e.fee
|
|
27
|
-
}));
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// src/actions/public/getNonce.ts
|
|
31
|
-
async function getNonce(client, params) {
|
|
32
|
-
const data = await client.request(`/v2/accounts/${params.address}`, {
|
|
33
|
-
method: "GET"
|
|
34
|
-
});
|
|
35
|
-
return BigInt(data.nonce);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// src/errors/transaction.ts
|
|
39
|
-
class TransactionError extends BaseError {
|
|
40
|
-
name = "TransactionError";
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
class BroadcastError extends BaseError {
|
|
44
|
-
name = "BroadcastError";
|
|
45
|
-
txid;
|
|
46
|
-
reason;
|
|
47
|
-
constructor(message, options) {
|
|
48
|
-
super(message, options);
|
|
49
|
-
this.txid = options?.txid;
|
|
50
|
-
this.reason = options?.reason;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
class SerializationError extends BaseError {
|
|
55
|
-
name = "SerializationError";
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
class SigningError extends BaseError {
|
|
59
|
-
name = "SigningError";
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// src/actions/wallet/sendTransaction.ts
|
|
63
|
-
async function sendTransaction(client, params) {
|
|
64
|
-
const hex = bytesToHex(serializeTransaction(params.transaction));
|
|
65
|
-
const body = { tx: hex };
|
|
66
|
-
if (params.attachment) {
|
|
67
|
-
body.attachment = typeof params.attachment === "string" ? params.attachment : bytesToHex(params.attachment);
|
|
68
|
-
}
|
|
69
|
-
const data = await client.request("/v2/transactions", {
|
|
70
|
-
method: "POST",
|
|
71
|
-
body
|
|
72
|
-
});
|
|
73
|
-
if (data.error) {
|
|
74
|
-
throw new BroadcastError(data.reason ?? data.error, {
|
|
75
|
-
reason: data.reason
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
const txid = typeof data === "string" ? data.replace(/"/g, "") : data.txid ?? getTransactionId(params.transaction);
|
|
79
|
-
return { txid };
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// src/actions/wallet/utils.ts
|
|
83
|
-
function isProviderAccount(account) {
|
|
84
|
-
return account.type === "provider";
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export { estimateFee, getNonce, TransactionError, BroadcastError, SerializationError, SigningError, sendTransaction, isProviderAccount };
|
|
88
|
-
|
|
89
|
-
//# debugId=1B6D519ABD27C60964756E2164756E21
|
|
90
|
-
//# sourceMappingURL=stacks-y8e3gx6w.js.map
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/actions/public/estimateFee.ts", "../src/actions/public/getNonce.ts", "../src/errors/transaction.ts", "../src/actions/wallet/sendTransaction.ts", "../src/actions/wallet/utils.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"import type { Client } from \"../../clients/types.ts\";\nimport type { StacksTransaction } from \"../../transactions/types.ts\";\nimport {\n\tserializePayload,\n\tserializeTransaction,\n} from \"../../transactions/wire/serialize.ts\";\nimport { bytesToHex } from \"../../utils/encoding.ts\";\n\nexport type EstimateFeeParams = {\n\ttransaction: StacksTransaction;\n};\n\nexport type FeeEstimation = {\n\tfeeRate: number;\n\tfee: number;\n};\n\nexport async function estimateFee(\n\tclient: Client,\n\tparams: EstimateFeeParams,\n): Promise<FeeEstimation[]> {\n\tconst payloadHex = bytesToHex(serializePayload(params.transaction.payload));\n\tconst txHex = bytesToHex(serializeTransaction(params.transaction));\n\n\tconst data = await client.request(\"/v2/fees/transaction\", {\n\t\tmethod: \"POST\",\n\t\tbody: {\n\t\t\testimated_len: Math.ceil(txHex.length / 2),\n\t\t\ttransaction_payload: `0x${payloadHex}`,\n\t\t},\n\t});\n\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\treturn (data.estimations ?? []).map((e: any) => ({\n\t\tfeeRate: e.fee_rate,\n\t\tfee: e.fee,\n\t}));\n}\n",
|
|
6
|
-
"import type { Client } from \"../../clients/types.ts\";\n\nexport type GetNonceParams = {\n\taddress: string;\n};\n\nexport type GetNonceResult = {\n\tnonce: bigint;\n\tpossibleNextNonce: bigint;\n};\n\nexport async function getNonce(\n\tclient: Client,\n\tparams: GetNonceParams,\n): Promise<bigint> {\n\tconst data = await client.request(`/v2/accounts/${params.address}`, {\n\t\tmethod: \"GET\",\n\t});\n\treturn BigInt(data.nonce);\n}\n",
|
|
7
|
-
"import { BaseError } from \"./base.ts\";\n\nexport class TransactionError extends BaseError {\n\toverride name = \"TransactionError\";\n}\n\nexport class BroadcastError extends BaseError {\n\toverride name = \"BroadcastError\";\n\ttxid?: string;\n\treason?: string;\n\n\tconstructor(\n\t\tmessage: string,\n\t\toptions?: { cause?: Error; txid?: string; reason?: string },\n\t) {\n\t\tsuper(message, options);\n\t\tthis.txid = options?.txid;\n\t\tthis.reason = options?.reason;\n\t}\n}\n\nexport class SerializationError extends BaseError {\n\toverride name = \"SerializationError\";\n}\n\nexport class SigningError extends BaseError {\n\toverride name = \"SigningError\";\n}\n",
|
|
8
|
-
"import type { Client } from \"../../clients/types.ts\";\nimport { BroadcastError } from \"../../errors/transaction.ts\";\nimport { getTransactionId } from \"../../transactions/signer.ts\";\nimport type { StacksTransaction } from \"../../transactions/types.ts\";\nimport { serializeTransaction } from \"../../transactions/wire/serialize.ts\";\nimport { bytesToHex } from \"../../utils/encoding.ts\";\n\nexport type SendTransactionParams = {\n\ttransaction: StacksTransaction;\n\tattachment?: Uint8Array | string;\n};\n\nexport type SendTransactionResult = {\n\ttxid: string;\n};\n\n/** Broadcast a signed transaction to the network */\nexport async function sendTransaction(\n\tclient: Client,\n\tparams: SendTransactionParams,\n): Promise<SendTransactionResult> {\n\tconst hex = bytesToHex(serializeTransaction(params.transaction));\n\n\tconst body: Record<string, string> = { tx: hex };\n\tif (params.attachment) {\n\t\tbody.attachment =\n\t\t\ttypeof params.attachment === \"string\"\n\t\t\t\t? params.attachment\n\t\t\t\t: bytesToHex(params.attachment);\n\t}\n\n\tconst data = await client.request(\"/v2/transactions\", {\n\t\tmethod: \"POST\",\n\t\tbody,\n\t});\n\n\tif (data.error) {\n\t\tthrow new BroadcastError(data.reason ?? data.error, {\n\t\t\treason: data.reason,\n\t\t});\n\t}\n\n\tconst txid =\n\t\ttypeof data === \"string\"\n\t\t\t? data.replace(/\"/g, \"\")\n\t\t\t: (data.txid ?? getTransactionId(params.transaction));\n\n\treturn { txid };\n}\n",
|
|
9
|
-
"import type { ProviderAccount } from \"../../accounts/types.ts\";\nimport type { Account } from \"../../clients/types.ts\";\n\nexport function isProviderAccount(\n\taccount: Account,\n): account is ProviderAccount {\n\treturn account.type === \"provider\";\n}\n"
|
|
10
|
-
],
|
|
11
|
-
"mappings": ";;;;;;;;;;;;;AAiBA,eAAsB,WAAW,CAChC,QACA,QAC2B;AAAA,EAC3B,MAAM,aAAa,WAAW,iBAAiB,OAAO,YAAY,OAAO,CAAC;AAAA,EAC1E,MAAM,QAAQ,WAAW,qBAAqB,OAAO,WAAW,CAAC;AAAA,EAEjE,MAAM,OAAO,MAAM,OAAO,QAAQ,wBAAwB;AAAA,IACzD,QAAQ;AAAA,IACR,MAAM;AAAA,MACL,eAAe,KAAK,KAAK,MAAM,SAAS,CAAC;AAAA,MACzC,qBAAqB,KAAK;AAAA,IAC3B;AAAA,EACD,CAAC;AAAA,EAGD,QAAQ,KAAK,eAAe,CAAC,GAAG,IAAI,CAAC,OAAY;AAAA,IAChD,SAAS,EAAE;AAAA,IACX,KAAK,EAAE;AAAA,EACR,EAAE;AAAA;;;ACzBH,eAAsB,QAAQ,CAC7B,QACA,QACkB;AAAA,EAClB,MAAM,OAAO,MAAM,OAAO,QAAQ,gBAAgB,OAAO,WAAW;AAAA,IACnE,QAAQ;AAAA,EACT,CAAC;AAAA,EACD,OAAO,OAAO,KAAK,KAAK;AAAA;;;AChBlB,MAAM,yBAAyB,UAAU;AAAA,EACtC,OAAO;AACjB;AAAA;AAEO,MAAM,uBAAuB,UAAU;AAAA,EACpC,OAAO;AAAA,EAChB;AAAA,EACA;AAAA,EAEA,WAAW,CACV,SACA,SACC;AAAA,IACD,MAAM,SAAS,OAAO;AAAA,IACtB,KAAK,OAAO,SAAS;AAAA,IACrB,KAAK,SAAS,SAAS;AAAA;AAEzB;AAAA;AAEO,MAAM,2BAA2B,UAAU;AAAA,EACxC,OAAO;AACjB;AAAA;AAEO,MAAM,qBAAqB,UAAU;AAAA,EAClC,OAAO;AACjB;;;ACVA,eAAsB,eAAe,CACpC,QACA,QACiC;AAAA,EACjC,MAAM,MAAM,WAAW,qBAAqB,OAAO,WAAW,CAAC;AAAA,EAE/D,MAAM,OAA+B,EAAE,IAAI,IAAI;AAAA,EAC/C,IAAI,OAAO,YAAY;AAAA,IACtB,KAAK,aACJ,OAAO,OAAO,eAAe,WAC1B,OAAO,aACP,WAAW,OAAO,UAAU;AAAA,EACjC;AAAA,EAEA,MAAM,OAAO,MAAM,OAAO,QAAQ,oBAAoB;AAAA,IACrD,QAAQ;AAAA,IACR;AAAA,EACD,CAAC;AAAA,EAED,IAAI,KAAK,OAAO;AAAA,IACf,MAAM,IAAI,eAAe,KAAK,UAAU,KAAK,OAAO;AAAA,MACnD,QAAQ,KAAK;AAAA,IACd,CAAC;AAAA,EACF;AAAA,EAEA,MAAM,OACL,OAAO,SAAS,WACb,KAAK,QAAQ,MAAM,EAAE,IACpB,KAAK,QAAQ,iBAAiB,OAAO,WAAW;AAAA,EAErD,OAAO,EAAE,KAAK;AAAA;;;AC5CR,SAAS,iBAAiB,CAChC,SAC6B;AAAA,EAC7B,OAAO,QAAQ,SAAS;AAAA;",
|
|
12
|
-
"debugId": "1B6D519ABD27C60964756E2164756E21",
|
|
13
|
-
"names": []
|
|
14
|
-
}
|
|
File without changes
|