@secondlayer/stacks 3.3.1 → 4.1.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 +4 -0
- package/dist/shared/stacks-1arrcd11.js +48 -0
- package/dist/shared/stacks-1arrcd11.js.map +10 -0
- package/dist/shared/{stacks-6bgh2c9h.js → stacks-27fmgajb.js} +11 -3
- package/dist/shared/{stacks-b221qkst.cjs.map → stacks-27fmgajb.js.map} +4 -3
- package/dist/shared/{stacks-jknrzd6v.js → stacks-2evvn48s.js} +2 -2
- package/dist/shared/stacks-9mqveyjv.cjs.map +2 -2
- package/dist/shared/{stacks-8e5atbps.cjs → stacks-9qcr921s.cjs} +49 -5
- package/dist/shared/stacks-9qcr921s.cjs.map +10 -0
- package/dist/shared/{stacks-r1m1r72q.js → stacks-bw8qvqd1.js} +49 -23
- package/dist/shared/stacks-bw8qvqd1.js.map +27 -0
- package/dist/shared/stacks-enpj9krt.cjs +38 -0
- package/dist/shared/stacks-enpj9krt.cjs.map +10 -0
- package/dist/shared/{stacks-s361pmzs.cjs → stacks-fb75yew8.js} +86 -2
- package/dist/shared/{stacks-9d2d0qjc.js.map → stacks-fb75yew8.js.map} +6 -4
- package/dist/shared/{stacks-rw2xbtdv.js → stacks-gxq2pbky.js} +2 -2
- package/dist/shared/{stacks-rw2xbtdv.js.map → stacks-gxq2pbky.js.map} +1 -1
- package/dist/shared/{stacks-jx146qf1.js → stacks-hnqt5rz4.js} +27 -377
- package/dist/shared/stacks-hnqt5rz4.js.map +13 -0
- package/dist/shared/{stacks-v1hzk599.js → stacks-jpt52csy.js} +8 -10
- package/dist/shared/stacks-jpt52csy.js.map +10 -0
- package/dist/shared/{stacks-b221qkst.cjs → stacks-nyaw1z2a.cjs} +7 -2
- package/dist/shared/{stacks-6bgh2c9h.js.map → stacks-nyaw1z2a.cjs.map} +4 -3
- package/dist/shared/{stacks-bm49tsh0.js → stacks-rpqtgpyj.js} +42 -9
- package/dist/shared/stacks-rpqtgpyj.js.map +10 -0
- package/dist/shared/{stacks-g2qnr5qn.cjs → stacks-rryme9bv.cjs} +11 -364
- package/dist/shared/stacks-rryme9bv.cjs.map +13 -0
- package/dist/shared/{stacks-byyex2zk.cjs → stacks-ta1gar0b.cjs} +7 -2
- package/dist/shared/{stacks-byyex2zk.cjs.map → stacks-ta1gar0b.cjs.map} +2 -2
- package/dist/shared/{stacks-9d2d0qjc.js → stacks-tdsp5gsb.cjs} +54 -23
- package/dist/shared/{stacks-s361pmzs.cjs.map → stacks-tdsp5gsb.cjs.map} +6 -4
- package/dist/shared/stacks-vea7nde7.cjs +731 -0
- package/dist/shared/stacks-vea7nde7.cjs.map +13 -0
- package/dist/shared/stacks-w23294am.js +760 -0
- package/dist/shared/stacks-w23294am.js.map +13 -0
- package/dist/shared/{stacks-fvnxj77s.cjs → stacks-y4f7fm03.cjs} +33 -13
- package/dist/shared/{stacks-fvnxj77s.cjs.map → stacks-y4f7fm03.cjs.map} +7 -6
- package/dist/src/accounts/index.d.cts +1 -1
- package/dist/src/accounts/index.d.ts +1 -1
- package/dist/src/actions/index.d.cts +15 -11
- package/dist/src/actions/index.d.ts +15 -11
- package/dist/src/actions/index.js +21 -25
- package/dist/src/actions/index.js.map +1 -1
- package/dist/src/bitcoin/index.d.cts +29 -29
- package/dist/src/bitcoin/index.d.ts +29 -29
- package/dist/src/bitcoin/index.js +5 -6
- package/dist/src/bitcoin/index.js.map +2 -2
- package/dist/src/bns/index.d.cts +1 -1
- package/dist/src/bns/index.d.ts +1 -1
- package/dist/src/bns/index.js +9 -10
- package/dist/src/bns/index.js.map +2 -2
- package/dist/src/clarity/index.d.cts +37 -1
- package/dist/src/clarity/index.d.ts +37 -1
- package/dist/src/clarity/index.js +14 -2
- package/dist/src/clarity/index.js.map +1 -1
- package/dist/src/index.cjs.map +2 -2
- package/dist/src/index.d.cts +18 -14
- package/dist/src/index.d.ts +18 -14
- package/dist/src/index.js +22 -27
- package/dist/src/index.js.map +3 -3
- package/dist/src/postconditions/index.d.cts +66 -3
- package/dist/src/postconditions/index.d.ts +66 -3
- package/dist/src/postconditions/index.js +13 -3
- package/dist/src/postconditions/index.js.map +1 -1
- package/dist/src/pox/index.d.cts +1 -1
- package/dist/src/pox/index.d.ts +1 -1
- package/dist/src/pox/index.js +7 -9
- package/dist/src/pox/index.js.map +2 -2
- package/dist/src/pox5/index.cjs +213 -14
- package/dist/src/pox5/index.cjs.map +8 -7
- package/dist/src/pox5/index.d.cts +88 -5
- package/dist/src/pox5/index.d.ts +88 -5
- package/dist/src/pox5/index.js +222 -21
- package/dist/src/pox5/index.js.map +8 -7
- package/dist/src/sbtc/index.d.cts +1 -1
- package/dist/src/sbtc/index.d.ts +1 -1
- package/dist/src/sbtc/index.js +6 -7
- package/dist/src/sbtc/index.js.map +2 -2
- package/dist/src/stackingdao/index.d.cts +1 -1
- package/dist/src/stackingdao/index.d.ts +1 -1
- package/dist/src/stackingdao/index.js +7 -9
- package/dist/src/stackingdao/index.js.map +2 -2
- package/dist/src/subscriptions/index.d.cts +1 -1
- package/dist/src/subscriptions/index.d.ts +1 -1
- package/dist/src/tools/index.cjs +494 -367
- package/dist/src/tools/index.cjs.map +11 -9
- package/dist/src/tools/index.d.cts +1 -1
- package/dist/src/tools/index.d.ts +1 -1
- package/dist/src/tools/index.js +494 -367
- package/dist/src/tools/index.js.map +11 -9
- package/dist/src/transactions/index.cjs +3 -1
- package/dist/src/transactions/index.cjs.map +1 -1
- package/dist/src/transactions/index.d.cts +16 -9
- package/dist/src/transactions/index.d.ts +16 -9
- package/dist/src/transactions/index.js +31 -27
- package/dist/src/transactions/index.js.map +1 -1
- package/package.json +2 -7
- package/dist/shared/stacks-1mpmzzyp.js +0 -85
- package/dist/shared/stacks-1mpmzzyp.js.map +0 -11
- package/dist/shared/stacks-44y18a8e.cjs +0 -28
- package/dist/shared/stacks-44y18a8e.cjs.map +0 -10
- package/dist/shared/stacks-8e5atbps.cjs.map +0 -10
- package/dist/shared/stacks-8khy9v27.cjs +0 -7
- package/dist/shared/stacks-8khy9v27.cjs.map +0 -10
- package/dist/shared/stacks-bm49tsh0.js.map +0 -10
- package/dist/shared/stacks-d6pgp4qk.cjs +0 -9
- package/dist/shared/stacks-d6pgp4qk.cjs.map +0 -9
- package/dist/shared/stacks-fh48neva.js +0 -13
- package/dist/shared/stacks-fh48neva.js.map +0 -10
- package/dist/shared/stacks-fjrpnkt3.cjs +0 -55
- package/dist/shared/stacks-fjrpnkt3.cjs.map +0 -11
- package/dist/shared/stacks-g2qnr5qn.cjs.map +0 -15
- package/dist/shared/stacks-gkf9tsws.js +0 -285
- package/dist/shared/stacks-gkf9tsws.js.map +0 -10
- package/dist/shared/stacks-jx146qf1.js.map +0 -15
- package/dist/shared/stacks-qjgh6pqr.cjs +0 -258
- package/dist/shared/stacks-qjgh6pqr.cjs.map +0 -10
- package/dist/shared/stacks-r1m1r72q.js.map +0 -26
- package/dist/shared/stacks-v1hzk599.js.map +0 -10
- package/dist/shared/stacks-w8tt1fmt.js +0 -44
- package/dist/shared/stacks-w8tt1fmt.js.map +0 -10
- package/dist/shared/stacks-z53fwfcm.js +0 -3
- package/dist/shared/stacks-z53fwfcm.js.map +0 -9
- package/dist/src/x402/index.cjs +0 -65
- package/dist/src/x402/index.cjs.map +0 -11
- package/dist/src/x402/index.d.cts +0 -501
- package/dist/src/x402/index.d.ts +0 -501
- package/dist/src/x402/index.js +0 -90
- package/dist/src/x402/index.js.map +0 -11
- /package/dist/shared/{stacks-jknrzd6v.js.map → stacks-2evvn48s.js.map} +0 -0
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
// src/errors/response.ts
|
|
2
|
+
class MalformedResponseError extends BaseError {
|
|
3
|
+
name = "MalformedResponseError";
|
|
4
|
+
}
|
|
5
|
+
|
|
1
6
|
// src/actions/public/readContract.ts
|
|
2
7
|
async function readContract(client, params) {
|
|
3
8
|
const [address, name] = parseContractId(params.contract);
|
|
@@ -17,5 +22,5 @@ async function readContract(client, params) {
|
|
|
17
22
|
throw new Error(data.cause ?? "Read-only call failed");
|
|
18
23
|
}
|
|
19
24
|
|
|
20
|
-
//# debugId=
|
|
21
|
-
//# sourceMappingURL=stacks-
|
|
25
|
+
//# debugId=E26625FCD8E1B4DA64756E2164756E21
|
|
26
|
+
//# sourceMappingURL=stacks-nyaw1z2a.cjs.map
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/actions/public/readContract.ts"],
|
|
3
|
+
"sources": ["../src/errors/response.ts", "../src/actions/public/readContract.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
+
"import { BaseError } from \"./base.ts\";\n\n/** Thrown when a node/API response is missing an expected field. */\nexport class MalformedResponseError extends BaseError {\n\toverride name = \"MalformedResponseError\";\n}\n",
|
|
5
6
|
"import { deserializeCVBytes } from \"../../clarity/deserialize.ts\";\nimport { serializeCVBytes } from \"../../clarity/serialize.ts\";\nimport type { ClarityValue } from \"../../clarity/types.ts\";\nimport type { Client } from \"../../clients/types.ts\";\nimport { parseContractId } from \"../../utils/address.ts\";\nimport { bytesToHex, with0x } from \"../../utils/encoding.ts\";\n\nexport type ReadContractParams = {\n\tcontract: string; // \"address.name\"\n\tfunctionName: string;\n\targs?: ClarityValue[];\n\tsender?: string;\n\t/**\n\t * Nakamoto StacksBlockId to evaluate against. Without it the node answers\n\t * at its own moving tip, which makes a read non-deterministic — the same\n\t * reindex of the same block can return a different value.\n\t */\n\ttip?: string;\n};\n\nexport async function readContract<T extends ClarityValue = ClarityValue>(\n\tclient: Client,\n\tparams: ReadContractParams,\n): Promise<T> {\n\tconst [address, name] = parseContractId(params.contract);\n\tconst sender = params.sender ?? address;\n\n\tconst serializedArgs = (params.args ?? []).map((arg) =>\n\t\twith0x(bytesToHex(serializeCVBytes(arg))),\n\t);\n\n\tconst path = `/v2/contracts/call-read/${address}/${name}/${params.functionName}`;\n\tconst data = await client.request(\n\t\tparams.tip ? `${path}?tip=${params.tip}` : path,\n\t\t{\n\t\t\tmethod: \"POST\",\n\t\t\tbody: {\n\t\t\t\tsender,\n\t\t\t\targuments: serializedArgs,\n\t\t\t},\n\t\t},\n\t);\n\n\tif (data.okay) {\n\t\treturn deserializeCVBytes<T>(data.result);\n\t}\n\tthrow new Error(data.cause ?? \"Read-only call failed\");\n}\n"
|
|
6
7
|
],
|
|
7
|
-
"mappings": "
|
|
8
|
-
"debugId": "
|
|
8
|
+
"mappings": ";AAGO,MAAM,+BAA+B,UAAU;AAAA,EAC5C,OAAO;AACjB;;;ACeA,eAAsB,YAAmD,CACxE,QACA,QACa;AAAA,EACb,OAAO,SAAS,QAAQ,gBAAgB,OAAO,QAAQ;AAAA,EACvD,MAAM,SAAS,OAAO,UAAU;AAAA,EAEhC,MAAM,kBAAkB,OAAO,QAAQ,CAAC,GAAG,IAAI,CAAC,QAC/C,OAAO,WAAW,iBAAiB,GAAG,CAAC,CAAC,CACzC;AAAA,EAEA,MAAM,OAAO,2BAA2B,WAAW,QAAQ,OAAO;AAAA,EAClE,MAAM,OAAO,MAAM,OAAO,QACzB,OAAO,MAAM,GAAG,YAAY,OAAO,QAAQ,MAC3C;AAAA,IACC,QAAQ;AAAA,IACR,MAAM;AAAA,MACL;AAAA,MACA,WAAW;AAAA,IACZ;AAAA,EACD,CACD;AAAA,EAEA,IAAI,KAAK,MAAM;AAAA,IACd,OAAO,mBAAsB,KAAK,MAAM;AAAA,EACzC;AAAA,EACA,MAAM,IAAI,MAAM,KAAK,SAAS,uBAAuB;AAAA;",
|
|
9
|
+
"debugId": "E26625FCD8E1B4DA64756E2164756E21",
|
|
9
10
|
"names": []
|
|
10
11
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
fromHex,
|
|
3
|
+
parsePostConditionAmount
|
|
4
|
+
} from "./stacks-w23294am.js";
|
|
1
5
|
import {
|
|
2
6
|
parseContractId,
|
|
3
7
|
validateStacksAddress
|
|
4
8
|
} from "./stacks-bfan7ex7.js";
|
|
5
|
-
import {
|
|
6
|
-
intToBigInt
|
|
7
|
-
} from "./stacks-qs5fzts5.js";
|
|
8
9
|
|
|
9
10
|
// src/postconditions/builder.ts
|
|
10
11
|
class PartialPcWithPrincipal {
|
|
@@ -33,6 +34,30 @@ class PartialPcWithPrincipal {
|
|
|
33
34
|
willNotSendAsset() {
|
|
34
35
|
return new PartialPcNftWithCode(this.address, "not-sent");
|
|
35
36
|
}
|
|
37
|
+
willMaybeSendAsset() {
|
|
38
|
+
return new PartialPcNftWithCode(this.address, "maybe-sent");
|
|
39
|
+
}
|
|
40
|
+
willPerformPox() {
|
|
41
|
+
return {
|
|
42
|
+
type: "pox-postcondition",
|
|
43
|
+
address: this.address,
|
|
44
|
+
condition: "will-perform"
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
willNotPerformPox() {
|
|
48
|
+
return {
|
|
49
|
+
type: "pox-postcondition",
|
|
50
|
+
address: this.address,
|
|
51
|
+
condition: "will-not-perform"
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
mayPerformPox() {
|
|
55
|
+
return {
|
|
56
|
+
type: "pox-postcondition",
|
|
57
|
+
address: this.address,
|
|
58
|
+
condition: "may-perform"
|
|
59
|
+
};
|
|
60
|
+
}
|
|
36
61
|
}
|
|
37
62
|
|
|
38
63
|
class PartialPcFtWithCode {
|
|
@@ -49,7 +74,15 @@ class PartialPcFtWithCode {
|
|
|
49
74
|
type: "stx-postcondition",
|
|
50
75
|
address: this.address,
|
|
51
76
|
condition: this.code,
|
|
52
|
-
amount:
|
|
77
|
+
amount: parsePostConditionAmount(this.amount).toString()
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
ustxToLock() {
|
|
81
|
+
return {
|
|
82
|
+
type: "staking-postcondition",
|
|
83
|
+
address: this.address,
|
|
84
|
+
condition: this.code,
|
|
85
|
+
amount: parsePostConditionAmount(this.amount).toString()
|
|
53
86
|
};
|
|
54
87
|
}
|
|
55
88
|
ft(contractId, tokenName) {
|
|
@@ -61,7 +94,7 @@ class PartialPcFtWithCode {
|
|
|
61
94
|
type: "ft-postcondition",
|
|
62
95
|
address: this.address,
|
|
63
96
|
condition: this.code,
|
|
64
|
-
amount:
|
|
97
|
+
amount: parsePostConditionAmount(this.amount).toString(),
|
|
65
98
|
asset: `${contractId}::${tokenName}`
|
|
66
99
|
};
|
|
67
100
|
}
|
|
@@ -113,10 +146,10 @@ var Pc = {
|
|
|
113
146
|
},
|
|
114
147
|
origin() {
|
|
115
148
|
return new PartialPcWithPrincipal("origin");
|
|
116
|
-
}
|
|
149
|
+
},
|
|
150
|
+
fromHex
|
|
117
151
|
};
|
|
118
|
-
|
|
119
152
|
export { Pc };
|
|
120
153
|
|
|
121
|
-
//# debugId=
|
|
122
|
-
//# sourceMappingURL=stacks-
|
|
154
|
+
//# debugId=9A7CDC14F24F831364756E2164756E21
|
|
155
|
+
//# sourceMappingURL=stacks-rpqtgpyj.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/postconditions/builder.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import type { ClarityValue } from \"../clarity/types.ts\";\nimport { parseContractId, validateStacksAddress } from \"../utils/address.ts\";\nimport type { IntegerType } from \"../utils/encoding.ts\";\nimport { fromHex, parsePostConditionAmount } from \"./convert.ts\";\nimport type {\n\tFtPostCondition,\n\tFungibleComparator,\n\tNftPostCondition,\n\tNonFungibleComparator,\n\tPoxPostCondition,\n\tStakingPostCondition,\n\tStxPostCondition,\n} from \"./types.ts\";\n\nclass PartialPcWithPrincipal {\n\tconstructor(private address: string) {}\n\n\twillSendEq(amount: IntegerType) {\n\t\treturn new PartialPcFtWithCode(this.address, amount, \"eq\");\n\t}\n\twillSendGte(amount: IntegerType) {\n\t\treturn new PartialPcFtWithCode(this.address, amount, \"gte\");\n\t}\n\twillSendGt(amount: IntegerType) {\n\t\treturn new PartialPcFtWithCode(this.address, amount, \"gt\");\n\t}\n\twillSendLte(amount: IntegerType) {\n\t\treturn new PartialPcFtWithCode(this.address, amount, \"lte\");\n\t}\n\twillSendLt(amount: IntegerType) {\n\t\treturn new PartialPcFtWithCode(this.address, amount, \"lt\");\n\t}\n\twillSendAsset() {\n\t\treturn new PartialPcNftWithCode(this.address, \"sent\");\n\t}\n\twillNotSendAsset() {\n\t\treturn new PartialPcNftWithCode(this.address, \"not-sent\");\n\t}\n\twillMaybeSendAsset() {\n\t\treturn new PartialPcNftWithCode(this.address, \"maybe-sent\");\n\t}\n\twillPerformPox(): PoxPostCondition {\n\t\treturn {\n\t\t\ttype: \"pox-postcondition\",\n\t\t\taddress: this.address,\n\t\t\tcondition: \"will-perform\",\n\t\t};\n\t}\n\twillNotPerformPox(): PoxPostCondition {\n\t\treturn {\n\t\t\ttype: \"pox-postcondition\",\n\t\t\taddress: this.address,\n\t\t\tcondition: \"will-not-perform\",\n\t\t};\n\t}\n\tmayPerformPox(): PoxPostCondition {\n\t\treturn {\n\t\t\ttype: \"pox-postcondition\",\n\t\t\taddress: this.address,\n\t\t\tcondition: \"may-perform\",\n\t\t};\n\t}\n}\n\nclass PartialPcFtWithCode {\n\tconstructor(\n\t\tprivate address: string,\n\t\tprivate amount: IntegerType,\n\t\tprivate code: FungibleComparator,\n\t) {}\n\n\tustx(): StxPostCondition {\n\t\treturn {\n\t\t\ttype: \"stx-postcondition\",\n\t\t\taddress: this.address,\n\t\t\tcondition: this.code,\n\t\t\tamount: parsePostConditionAmount(this.amount).toString(),\n\t\t};\n\t}\n\n\tustxToLock(): StakingPostCondition {\n\t\treturn {\n\t\t\ttype: \"staking-postcondition\",\n\t\t\taddress: this.address,\n\t\t\tcondition: this.code,\n\t\t\tamount: parsePostConditionAmount(this.amount).toString(),\n\t\t};\n\t}\n\n\tft(contractId: string, tokenName: string): FtPostCondition {\n\t\tconst [address, name] = contractId.split(\".\");\n\t\tif (!address || !validateStacksAddress(address) || !name) {\n\t\t\tthrow new Error(`Invalid contract id: ${contractId}`);\n\t\t}\n\t\treturn {\n\t\t\ttype: \"ft-postcondition\",\n\t\t\taddress: this.address,\n\t\t\tcondition: this.code,\n\t\t\tamount: parsePostConditionAmount(this.amount).toString(),\n\t\t\tasset: `${contractId}::${tokenName}`,\n\t\t};\n\t}\n}\n\nclass PartialPcNftWithCode {\n\tconstructor(\n\t\tprivate address: string,\n\t\tprivate code: NonFungibleComparator,\n\t) {}\n\n\tnft(\n\t\tassetOrContractId: string,\n\t\ttokenNameOrAssetId: string | ClarityValue,\n\t\tassetId?: ClarityValue,\n\t): NftPostCondition {\n\t\tlet contractAddress: string;\n\t\tlet contractName: string;\n\t\tlet tokenName: string;\n\t\tlet id: ClarityValue;\n\n\t\tif (assetId !== undefined) {\n\t\t\t// 3 args: contractId, tokenName, assetId\n\t\t\t[contractAddress, contractName] = parseContractId(assetOrContractId);\n\t\t\ttokenName = tokenNameOrAssetId as string;\n\t\t\tid = assetId;\n\t\t} else {\n\t\t\t// 2 args: assetString (addr.contract::token), assetId\n\t\t\tconst [principal, tName] = assetOrContractId.split(\"::\");\n\t\t\tif (!principal || !tName)\n\t\t\t\tthrow new Error(`Invalid asset name: ${assetOrContractId}`);\n\t\t\t[contractAddress, contractName] = parseContractId(principal);\n\t\t\ttokenName = tName;\n\t\t\tid = tokenNameOrAssetId as ClarityValue;\n\t\t}\n\n\t\tif (!validateStacksAddress(contractAddress)) {\n\t\t\tthrow new Error(`Invalid contract address: ${contractAddress}`);\n\t\t}\n\n\t\treturn {\n\t\t\ttype: \"nft-postcondition\",\n\t\t\taddress: this.address,\n\t\t\tcondition: this.code,\n\t\t\tasset: `${contractAddress}.${contractName}::${tokenName}`,\n\t\t\tassetId: id,\n\t\t};\n\t}\n}\n\nexport const Pc = {\n\tprincipal(address: string) {\n\t\tconst [addr, name] = address.split(\".\");\n\t\tif (\n\t\t\t!addr ||\n\t\t\t!validateStacksAddress(addr) ||\n\t\t\t(typeof name === \"string\" && !name)\n\t\t) {\n\t\t\tthrow new Error(`Invalid principal: ${address}`);\n\t\t}\n\t\treturn new PartialPcWithPrincipal(address);\n\t},\n\torigin() {\n\t\treturn new PartialPcWithPrincipal(\"origin\");\n\t},\n\tfromHex,\n};\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": "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",
|
|
8
|
+
"debugId": "9A7CDC14F24F831364756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -1,293 +1,3 @@
|
|
|
1
|
-
// src/transactions/types.ts
|
|
2
|
-
var AuthType = {
|
|
3
|
-
Standard: 4,
|
|
4
|
-
Sponsored: 5
|
|
5
|
-
};
|
|
6
|
-
var PayloadType = {
|
|
7
|
-
TokenTransfer: 0,
|
|
8
|
-
SmartContract: 1,
|
|
9
|
-
ContractCall: 2,
|
|
10
|
-
PoisonMicroblock: 3,
|
|
11
|
-
Coinbase: 4,
|
|
12
|
-
CoinbaseToAltRecipient: 5,
|
|
13
|
-
VersionedSmartContract: 6,
|
|
14
|
-
TenureChange: 7,
|
|
15
|
-
NakamotoCoinbase: 8
|
|
16
|
-
};
|
|
17
|
-
var ClarityVersion = {
|
|
18
|
-
Clarity1: 1,
|
|
19
|
-
Clarity2: 2,
|
|
20
|
-
Clarity3: 3,
|
|
21
|
-
Clarity4: 4,
|
|
22
|
-
Clarity5: 5,
|
|
23
|
-
Clarity6: 6
|
|
24
|
-
};
|
|
25
|
-
var AnchorMode = {
|
|
26
|
-
OnChainOnly: 1,
|
|
27
|
-
OffChainOnly: 2,
|
|
28
|
-
Any: 3
|
|
29
|
-
};
|
|
30
|
-
var PostConditionModeWire = {
|
|
31
|
-
Allow: 1,
|
|
32
|
-
Deny: 2
|
|
33
|
-
};
|
|
34
|
-
var AddressHashMode = {
|
|
35
|
-
P2PKH: 0,
|
|
36
|
-
P2SH: 1,
|
|
37
|
-
P2WPKH: 2,
|
|
38
|
-
P2WSH: 3,
|
|
39
|
-
P2SH_NonSequential: 5,
|
|
40
|
-
P2WSH_P2SH_NonSequential: 7
|
|
41
|
-
};
|
|
42
|
-
var PubKeyEncoding = {
|
|
43
|
-
Compressed: 0,
|
|
44
|
-
Uncompressed: 1
|
|
45
|
-
};
|
|
46
|
-
var FungibleConditionCode = {
|
|
47
|
-
Equal: 1,
|
|
48
|
-
Greater: 2,
|
|
49
|
-
GreaterEqual: 3,
|
|
50
|
-
Less: 4,
|
|
51
|
-
LessEqual: 5
|
|
52
|
-
};
|
|
53
|
-
var NonFungibleConditionCode = {
|
|
54
|
-
Sends: 16,
|
|
55
|
-
DoesNotSend: 17
|
|
56
|
-
};
|
|
57
|
-
var PoxConditionCode = {
|
|
58
|
-
WillNotPerform: 48,
|
|
59
|
-
MayPerform: 49,
|
|
60
|
-
WillPerform: 50
|
|
61
|
-
};
|
|
62
|
-
var PostConditionPrincipalId = {
|
|
63
|
-
Origin: 1,
|
|
64
|
-
Standard: 2,
|
|
65
|
-
Contract: 3
|
|
66
|
-
};
|
|
67
|
-
var AssetType = {
|
|
68
|
-
STX: 0,
|
|
69
|
-
Fungible: 1,
|
|
70
|
-
NonFungible: 2,
|
|
71
|
-
Staking: 3,
|
|
72
|
-
Pox: 4
|
|
73
|
-
};
|
|
74
|
-
var AuthFieldType = {
|
|
75
|
-
PublicKeyCompressed: 0,
|
|
76
|
-
PublicKeyUncompressed: 1,
|
|
77
|
-
SignatureCompressed: 2,
|
|
78
|
-
SignatureUncompressed: 3
|
|
79
|
-
};
|
|
80
|
-
var RECOVERABLE_ECDSA_SIG_LENGTH_BYTES = 65;
|
|
81
|
-
var MEMO_MAX_LENGTH_BYTES = 34;
|
|
82
|
-
var MAX_STRING_LENGTH_BYTES = 128;
|
|
83
|
-
var COINBASE_BYTES_LENGTH = 32;
|
|
84
|
-
var VRF_PROOF_BYTES_LENGTH = 80;
|
|
85
|
-
var MICROBLOCK_HEADER_BYTES_LENGTH = 132;
|
|
86
|
-
var TenureChangeCause = {
|
|
87
|
-
BlockFound: 0,
|
|
88
|
-
Extended: 1,
|
|
89
|
-
ExtendedRuntime: 2,
|
|
90
|
-
ExtendedReadCount: 3,
|
|
91
|
-
ExtendedReadLength: 4,
|
|
92
|
-
ExtendedWriteCount: 5,
|
|
93
|
-
ExtendedWriteLength: 6
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
// src/transactions/wire/serialize.ts
|
|
97
|
-
function serializeAddress(c32Address) {
|
|
98
|
-
const [version, hash1602] = c32addressDecode(c32Address);
|
|
99
|
-
return concatBytes(new Uint8Array([version]), hexToBytes(hash1602));
|
|
100
|
-
}
|
|
101
|
-
function serializeLPString(str, prefixBytes = 1) {
|
|
102
|
-
const content = utf8ToBytes(str);
|
|
103
|
-
const prefix = hexToBytes(intToHex(content.byteLength, prefixBytes));
|
|
104
|
-
return concatBytes(prefix, content);
|
|
105
|
-
}
|
|
106
|
-
function serializeLPStringLong(str) {
|
|
107
|
-
return serializeLPString(str, 4);
|
|
108
|
-
}
|
|
109
|
-
function serializeMemo(memo) {
|
|
110
|
-
const content = asciiToBytes(memo);
|
|
111
|
-
const padded = new Uint8Array(MEMO_MAX_LENGTH_BYTES);
|
|
112
|
-
padded.set(content.slice(0, MEMO_MAX_LENGTH_BYTES));
|
|
113
|
-
return padded;
|
|
114
|
-
}
|
|
115
|
-
function serializeSpendingCondition(condition) {
|
|
116
|
-
const parts = [
|
|
117
|
-
writeUInt8(condition.hashMode),
|
|
118
|
-
hexToBytes(condition.signer),
|
|
119
|
-
intToBytes(condition.nonce, 8),
|
|
120
|
-
intToBytes(condition.fee, 8)
|
|
121
|
-
];
|
|
122
|
-
if ("signature" in condition) {
|
|
123
|
-
const sc = condition;
|
|
124
|
-
parts.push(writeUInt8(sc.keyEncoding));
|
|
125
|
-
parts.push(hexToBytes(sc.signature));
|
|
126
|
-
} else {
|
|
127
|
-
const mc = condition;
|
|
128
|
-
parts.push(writeUInt32BE(mc.fields.length));
|
|
129
|
-
for (const field of mc.fields) {
|
|
130
|
-
parts.push(serializeAuthField(field));
|
|
131
|
-
}
|
|
132
|
-
parts.push(writeUInt16BE(mc.signaturesRequired));
|
|
133
|
-
}
|
|
134
|
-
return concatBytes(...parts);
|
|
135
|
-
}
|
|
136
|
-
function serializeAuthField(field) {
|
|
137
|
-
if (field.type === "publicKey") {
|
|
138
|
-
const typeId2 = field.pubKeyEncoding === 0 ? 0 : 1;
|
|
139
|
-
return concatBytes(writeUInt8(typeId2), hexToBytes(field.data));
|
|
140
|
-
}
|
|
141
|
-
const typeId = field.pubKeyEncoding === 0 ? 2 : 3;
|
|
142
|
-
return concatBytes(writeUInt8(typeId), hexToBytes(field.data));
|
|
143
|
-
}
|
|
144
|
-
function serializeAuthorization(auth) {
|
|
145
|
-
const parts = [writeUInt8(auth.authType)];
|
|
146
|
-
parts.push(serializeSpendingCondition(auth.spendingCondition));
|
|
147
|
-
if (auth.authType === AuthType.Sponsored) {
|
|
148
|
-
parts.push(serializeSpendingCondition(auth.sponsorSpendingCondition));
|
|
149
|
-
}
|
|
150
|
-
return concatBytes(...parts);
|
|
151
|
-
}
|
|
152
|
-
function serializePrincipal(principal) {
|
|
153
|
-
switch (principal.type) {
|
|
154
|
-
case "origin":
|
|
155
|
-
return writeUInt8(PostConditionPrincipalId.Origin);
|
|
156
|
-
case "standard":
|
|
157
|
-
return concatBytes(writeUInt8(PostConditionPrincipalId.Standard), serializeAddress(principal.address));
|
|
158
|
-
case "contract":
|
|
159
|
-
return concatBytes(writeUInt8(PostConditionPrincipalId.Contract), serializeAddress(principal.address), serializeLPString(principal.contractName));
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
function serializeAssetInfo(asset) {
|
|
163
|
-
return concatBytes(serializeAddress(asset.address), serializeLPString(asset.contractName), serializeLPString(asset.assetName));
|
|
164
|
-
}
|
|
165
|
-
function serializePostCondition(pc) {
|
|
166
|
-
const parts = [];
|
|
167
|
-
switch (pc.type) {
|
|
168
|
-
case "stx":
|
|
169
|
-
parts.push(writeUInt8(AssetType.STX));
|
|
170
|
-
parts.push(serializePrincipal(pc.principal));
|
|
171
|
-
parts.push(writeUInt8(pc.conditionCode));
|
|
172
|
-
parts.push(intToBytes(pc.amount, 8));
|
|
173
|
-
break;
|
|
174
|
-
case "ft":
|
|
175
|
-
parts.push(writeUInt8(AssetType.Fungible));
|
|
176
|
-
parts.push(serializePrincipal(pc.principal));
|
|
177
|
-
parts.push(serializeAssetInfo(pc.asset));
|
|
178
|
-
parts.push(writeUInt8(pc.conditionCode));
|
|
179
|
-
parts.push(intToBytes(pc.amount, 8));
|
|
180
|
-
break;
|
|
181
|
-
case "nft":
|
|
182
|
-
parts.push(writeUInt8(AssetType.NonFungible));
|
|
183
|
-
parts.push(serializePrincipal(pc.principal));
|
|
184
|
-
parts.push(serializeAssetInfo(pc.asset));
|
|
185
|
-
parts.push(serializeCVBytes(pc.assetId));
|
|
186
|
-
parts.push(writeUInt8(pc.conditionCode));
|
|
187
|
-
break;
|
|
188
|
-
case "staking":
|
|
189
|
-
parts.push(writeUInt8(AssetType.Staking));
|
|
190
|
-
parts.push(serializePrincipal(pc.principal));
|
|
191
|
-
parts.push(writeUInt8(pc.conditionCode));
|
|
192
|
-
parts.push(intToBytes(pc.amount, 8));
|
|
193
|
-
break;
|
|
194
|
-
case "pox":
|
|
195
|
-
parts.push(writeUInt8(AssetType.Pox));
|
|
196
|
-
parts.push(serializePrincipal(pc.principal));
|
|
197
|
-
parts.push(writeUInt8(pc.conditionCode));
|
|
198
|
-
break;
|
|
199
|
-
}
|
|
200
|
-
return concatBytes(...parts);
|
|
201
|
-
}
|
|
202
|
-
function serializePostConditions(pcs) {
|
|
203
|
-
const parts = [writeUInt32BE(pcs.length)];
|
|
204
|
-
for (const pc of pcs) {
|
|
205
|
-
parts.push(serializePostCondition(pc));
|
|
206
|
-
}
|
|
207
|
-
return concatBytes(...parts);
|
|
208
|
-
}
|
|
209
|
-
function serializePayload(payload) {
|
|
210
|
-
const parts = [writeUInt8(payload.payloadType)];
|
|
211
|
-
switch (payload.payloadType) {
|
|
212
|
-
case PayloadType.TokenTransfer:
|
|
213
|
-
parts.push(serializeCVBytes(payload.recipient));
|
|
214
|
-
parts.push(intToBytes(payload.amount, 8));
|
|
215
|
-
parts.push(serializeMemo(payload.memo));
|
|
216
|
-
break;
|
|
217
|
-
case PayloadType.ContractCall:
|
|
218
|
-
parts.push(serializeAddress(payload.contractAddress));
|
|
219
|
-
parts.push(serializeLPString(payload.contractName));
|
|
220
|
-
parts.push(serializeLPString(payload.functionName));
|
|
221
|
-
parts.push(writeUInt32BE(payload.functionArgs.length));
|
|
222
|
-
for (const arg of payload.functionArgs) {
|
|
223
|
-
parts.push(serializeCVBytes(arg));
|
|
224
|
-
}
|
|
225
|
-
break;
|
|
226
|
-
case PayloadType.SmartContract:
|
|
227
|
-
parts.push(serializeLPString(payload.contractName));
|
|
228
|
-
parts.push(serializeLPStringLong(payload.codeBody));
|
|
229
|
-
break;
|
|
230
|
-
case PayloadType.VersionedSmartContract:
|
|
231
|
-
parts.push(writeUInt8(payload.clarityVersion ?? 2));
|
|
232
|
-
parts.push(serializeLPString(payload.contractName));
|
|
233
|
-
parts.push(serializeLPStringLong(payload.codeBody));
|
|
234
|
-
break;
|
|
235
|
-
case PayloadType.Coinbase:
|
|
236
|
-
parts.push(hexToBytes(payload.coinbaseBuffer));
|
|
237
|
-
break;
|
|
238
|
-
case PayloadType.CoinbaseToAltRecipient: {
|
|
239
|
-
const cbAlt = payload;
|
|
240
|
-
parts.push(hexToBytes(cbAlt.coinbaseBuffer));
|
|
241
|
-
parts.push(serializeCVBytes(cbAlt.recipient));
|
|
242
|
-
break;
|
|
243
|
-
}
|
|
244
|
-
case PayloadType.PoisonMicroblock: {
|
|
245
|
-
const pm = payload;
|
|
246
|
-
parts.push(hexToBytes(pm.header1));
|
|
247
|
-
parts.push(hexToBytes(pm.header2));
|
|
248
|
-
break;
|
|
249
|
-
}
|
|
250
|
-
case PayloadType.TenureChange: {
|
|
251
|
-
const tc = payload;
|
|
252
|
-
parts.push(hexToBytes(tc.tenureConsensusHash));
|
|
253
|
-
parts.push(hexToBytes(tc.prevTenureConsensusHash));
|
|
254
|
-
parts.push(hexToBytes(tc.burnViewConsensusHash));
|
|
255
|
-
parts.push(hexToBytes(tc.previousTenureEnd));
|
|
256
|
-
parts.push(writeUInt32BE(tc.previousTenureBlocks));
|
|
257
|
-
parts.push(writeUInt8(tc.cause));
|
|
258
|
-
parts.push(hexToBytes(tc.pubkeyHash));
|
|
259
|
-
break;
|
|
260
|
-
}
|
|
261
|
-
case PayloadType.NakamotoCoinbase: {
|
|
262
|
-
const nc = payload;
|
|
263
|
-
parts.push(hexToBytes(nc.coinbaseBuffer));
|
|
264
|
-
if (nc.recipient) {
|
|
265
|
-
parts.push(serializeCVBytes({ type: "some", value: nc.recipient }));
|
|
266
|
-
} else {
|
|
267
|
-
parts.push(serializeCVBytes({ type: "none" }));
|
|
268
|
-
}
|
|
269
|
-
parts.push(hexToBytes(nc.vrfProof));
|
|
270
|
-
break;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
return concatBytes(...parts);
|
|
274
|
-
}
|
|
275
|
-
var _txCache = new WeakMap;
|
|
276
|
-
function clearTxCache(tx) {
|
|
277
|
-
_txCache.delete(tx);
|
|
278
|
-
}
|
|
279
|
-
function serializeTransaction(tx) {
|
|
280
|
-
const cached = _txCache.get(tx);
|
|
281
|
-
if (cached)
|
|
282
|
-
return cached;
|
|
283
|
-
const bytes = concatBytes(writeUInt8(tx.version), writeUInt32BE(tx.chainId), serializeAuthorization(tx.auth), writeUInt8(tx.anchorMode), writeUInt8(tx.postConditionMode), serializePostConditions(tx.postConditions), serializePayload(tx.payload));
|
|
284
|
-
_txCache.set(tx, bytes);
|
|
285
|
-
return bytes;
|
|
286
|
-
}
|
|
287
|
-
function serializeTransactionHex(tx) {
|
|
288
|
-
return bytesToHex(serializeTransaction(tx));
|
|
289
|
-
}
|
|
290
|
-
|
|
291
1
|
// src/transactions/authorization.ts
|
|
292
2
|
var import_hmac = require("@noble/hashes/hmac.js");
|
|
293
3
|
var import_sha2 = require("@noble/hashes/sha2.js");
|
|
@@ -657,80 +367,17 @@ function combineMultiSigSignatures(baseTx, signedTxs) {
|
|
|
657
367
|
|
|
658
368
|
// src/transactions/build.ts
|
|
659
369
|
function resolvePcMode(mode) {
|
|
660
|
-
|
|
370
|
+
if (mode === "allow")
|
|
371
|
+
return PostConditionModeWire.Allow;
|
|
372
|
+
if (mode === "originator")
|
|
373
|
+
return PostConditionModeWire.Originator;
|
|
374
|
+
return PostConditionModeWire.Deny;
|
|
661
375
|
}
|
|
662
376
|
function convertPostConditions(pcs) {
|
|
663
377
|
if (!pcs || pcs.length === 0)
|
|
664
378
|
return [];
|
|
665
|
-
return pcs.map(convertPostCondition);
|
|
666
|
-
}
|
|
667
|
-
function resolvePrincipal(address) {
|
|
668
|
-
if (address === "origin")
|
|
669
|
-
return { type: "origin" };
|
|
670
|
-
const [addr, name] = address.split(".");
|
|
671
|
-
if (name) {
|
|
672
|
-
return { type: "contract", address: addr, contractName: name };
|
|
673
|
-
}
|
|
674
|
-
return { type: "standard", address: addr };
|
|
675
|
-
}
|
|
676
|
-
var FUNGIBLE_CODE_MAP = {
|
|
677
|
-
eq: FungibleConditionCode.Equal,
|
|
678
|
-
gt: FungibleConditionCode.Greater,
|
|
679
|
-
gte: FungibleConditionCode.GreaterEqual,
|
|
680
|
-
lt: FungibleConditionCode.Less,
|
|
681
|
-
lte: FungibleConditionCode.LessEqual
|
|
682
|
-
};
|
|
683
|
-
function convertPostCondition(pc) {
|
|
684
|
-
switch (pc.type) {
|
|
685
|
-
case "stx-postcondition":
|
|
686
|
-
return {
|
|
687
|
-
type: "stx",
|
|
688
|
-
principal: resolvePrincipal(pc.address),
|
|
689
|
-
conditionCode: FUNGIBLE_CODE_MAP[pc.condition],
|
|
690
|
-
amount: intToBigInt(pc.amount)
|
|
691
|
-
};
|
|
692
|
-
case "ft-postcondition": {
|
|
693
|
-
const [contractId, tokenName] = pc.asset.split("::");
|
|
694
|
-
const [addr, name] = parseContractId(contractId);
|
|
695
|
-
return {
|
|
696
|
-
type: "ft",
|
|
697
|
-
principal: resolvePrincipal(pc.address),
|
|
698
|
-
asset: { address: addr, contractName: name, assetName: tokenName },
|
|
699
|
-
conditionCode: FUNGIBLE_CODE_MAP[pc.condition],
|
|
700
|
-
amount: intToBigInt(pc.amount)
|
|
701
|
-
};
|
|
702
|
-
}
|
|
703
|
-
case "nft-postcondition": {
|
|
704
|
-
const [contractId, tokenName] = pc.asset.split("::");
|
|
705
|
-
const [addr, name] = parseContractId(contractId);
|
|
706
|
-
return {
|
|
707
|
-
type: "nft",
|
|
708
|
-
principal: resolvePrincipal(pc.address),
|
|
709
|
-
asset: { address: addr, contractName: name, assetName: tokenName },
|
|
710
|
-
conditionCode: pc.condition === "sent" ? NonFungibleConditionCode.Sends : NonFungibleConditionCode.DoesNotSend,
|
|
711
|
-
assetId: pc.assetId
|
|
712
|
-
};
|
|
713
|
-
}
|
|
714
|
-
case "staking-postcondition":
|
|
715
|
-
return {
|
|
716
|
-
type: "staking",
|
|
717
|
-
principal: resolvePrincipal(pc.address),
|
|
718
|
-
conditionCode: FUNGIBLE_CODE_MAP[pc.condition],
|
|
719
|
-
amount: intToBigInt(pc.amount)
|
|
720
|
-
};
|
|
721
|
-
case "pox-postcondition":
|
|
722
|
-
return {
|
|
723
|
-
type: "pox",
|
|
724
|
-
principal: resolvePrincipal(pc.address),
|
|
725
|
-
conditionCode: POX_CODE_MAP[pc.condition]
|
|
726
|
-
};
|
|
727
|
-
}
|
|
379
|
+
return pcs.map((pc) => convertPostCondition(typeof pc === "string" ? fromHex(pc) : pc));
|
|
728
380
|
}
|
|
729
|
-
var POX_CODE_MAP = {
|
|
730
|
-
"will-not-perform": PoxConditionCode.WillNotPerform,
|
|
731
|
-
"may-perform": PoxConditionCode.MayPerform,
|
|
732
|
-
"will-perform": PoxConditionCode.WillPerform
|
|
733
|
-
};
|
|
734
381
|
function resolveSpendingCondition(opts, nonce, fee) {
|
|
735
382
|
if (opts.publicKeys) {
|
|
736
383
|
return createMultiSigSpendingCondition(opts.publicKeys, opts.signaturesRequired, nonce, fee, opts.hashMode);
|
|
@@ -800,7 +447,7 @@ function buildContractDeploy(options) {
|
|
|
800
447
|
const fee = intToBigInt(options.fee);
|
|
801
448
|
const nonce = intToBigInt(options.nonce);
|
|
802
449
|
const spendingCondition = resolveSpendingCondition(options, nonce, fee);
|
|
803
|
-
const
|
|
450
|
+
const clarityVersion = options.clarityVersion ?? ClarityVersion.Clarity4;
|
|
804
451
|
const tx = {
|
|
805
452
|
version,
|
|
806
453
|
chainId,
|
|
@@ -809,8 +456,8 @@ function buildContractDeploy(options) {
|
|
|
809
456
|
postConditionMode: resolvePcMode(options.postConditionMode),
|
|
810
457
|
postConditions: convertPostConditions(options.postConditions),
|
|
811
458
|
payload: {
|
|
812
|
-
payloadType:
|
|
813
|
-
clarityVersion
|
|
459
|
+
payloadType: PayloadType.VersionedSmartContract,
|
|
460
|
+
clarityVersion,
|
|
814
461
|
contractName: options.contractName,
|
|
815
462
|
codeBody: options.codeBody
|
|
816
463
|
}
|
|
@@ -918,5 +565,5 @@ async function signSponsorWithAccount(tx, account) {
|
|
|
918
565
|
};
|
|
919
566
|
}
|
|
920
567
|
|
|
921
|
-
//# debugId=
|
|
922
|
-
//# sourceMappingURL=stacks-
|
|
568
|
+
//# debugId=4803818E842AF84364756E2164756E21
|
|
569
|
+
//# sourceMappingURL=stacks-rryme9bv.cjs.map
|