@secondlayer/stacks 0.1.0 → 0.2.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-2ar4prfz.cjs +328 -0
- package/dist/shared/stacks-2ar4prfz.cjs.map +11 -0
- package/dist/shared/stacks-61rvzkz1.cjs.map +1 -1
- package/dist/shared/{stacks-d1fmkv3p.js → stacks-9avax1yf.js} +2 -2
- package/dist/shared/{stacks-ph4a6322.js → stacks-9mdk86wp.js} +16 -18
- package/dist/shared/{stacks-ph4a6322.js.map → stacks-9mdk86wp.js.map} +2 -2
- package/dist/shared/stacks-an5k8n4t.cjs.map +2 -2
- package/dist/shared/stacks-dr5en54r.cjs +119 -0
- package/dist/shared/stacks-dr5en54r.cjs.map +10 -0
- package/dist/shared/{stacks-b008c3w8.cjs → stacks-fedzr2ka.js} +134 -2
- package/dist/shared/stacks-fedzr2ka.js.map +13 -0
- package/dist/shared/{stacks-j2cy7qtt.js → stacks-ky14tdf6.cjs} +109 -24
- package/dist/shared/stacks-ky14tdf6.cjs.map +13 -0
- package/dist/shared/stacks-mrk6tkkh.cjs +41 -0
- package/dist/shared/{stacks-2gdt3aqj.cjs.map → stacks-mrk6tkkh.cjs.map} +1 -1
- package/dist/shared/{stacks-1ddg6mbv.js → stacks-qcx67vqa.js} +3 -3
- package/dist/shared/stacks-qcx67vqa.js.map +10 -0
- package/dist/shared/stacks-qyt8m5v0.js +282 -0
- package/dist/shared/stacks-qyt8m5v0.js.map +11 -0
- package/dist/shared/{stacks-hfem9dck.cjs → stacks-vbke9mqw.cjs} +328 -87
- package/dist/shared/stacks-vbke9mqw.cjs.map +15 -0
- package/dist/shared/{stacks-md6e5ta0.js → stacks-vd9jcp0b.js} +13 -17
- package/dist/shared/{stacks-md6e5ta0.js.map → stacks-vd9jcp0b.js.map} +3 -3
- package/dist/shared/stacks-vdfag81a.cjs.map +2 -2
- package/dist/shared/{stacks-xtz0n62y.js → stacks-vyb9rx8q.js} +341 -106
- package/dist/shared/stacks-vyb9rx8q.js.map +15 -0
- package/dist/shared/{stacks-m2dc5xwg.js → stacks-wrb1es85.js} +7 -11
- package/dist/shared/{stacks-m2dc5xwg.js.map → stacks-wrb1es85.js.map} +3 -3
- package/dist/shared/stacks-yfveb68e.js +121 -0
- package/dist/shared/stacks-yfveb68e.js.map +10 -0
- package/dist/src/accounts/index.js +1 -2
- package/dist/src/accounts/index.js.map +2 -2
- package/dist/src/actions/index.d.cts +3 -5
- package/dist/src/actions/index.d.ts +3 -5
- package/dist/src/actions/index.js +8 -11
- package/dist/src/actions/index.js.map +1 -1
- package/dist/src/bns/index.cjs +13 -13
- package/dist/src/bns/index.cjs.map +3 -3
- package/dist/src/bns/index.js +22 -25
- package/dist/src/bns/index.js.map +3 -3
- package/dist/src/chains/index.js +1 -2
- package/dist/src/chains/index.js.map +1 -1
- package/dist/src/clarity/index.cjs +1 -326
- package/dist/src/clarity/index.cjs.map +3 -5
- package/dist/src/clarity/index.js +18 -272
- package/dist/src/clarity/index.js.map +3 -5
- package/dist/src/connect/index.cjs +19 -9
- package/dist/src/connect/index.cjs.map +2 -2
- package/dist/src/connect/walletconnect/index.cjs +19 -9
- package/dist/src/connect/walletconnect/index.cjs.map +4 -4
- package/dist/src/connect/walletconnect/index.js +1 -1
- package/dist/src/connect/walletconnect/index.js.map +4 -4
- package/dist/src/index.cjs +1 -2
- package/dist/src/index.cjs.map +5 -5
- package/dist/src/index.js +9 -16
- package/dist/src/index.js.map +5 -5
- package/dist/src/postconditions/index.cjs +1 -117
- package/dist/src/postconditions/index.cjs.map +3 -4
- package/dist/src/postconditions/index.js +5 -119
- package/dist/src/postconditions/index.js.map +3 -4
- package/dist/src/pox/index.cjs +9 -9
- package/dist/src/pox/index.cjs.map +4 -4
- package/dist/src/pox/index.js +17 -20
- package/dist/src/pox/index.js.map +4 -4
- package/dist/src/stackingdao/index.cjs +13 -13
- package/dist/src/stackingdao/index.cjs.map +3 -3
- package/dist/src/stackingdao/index.js +21 -24
- package/dist/src/stackingdao/index.js.map +3 -3
- package/dist/src/subscriptions/index.js +1 -2
- package/dist/src/subscriptions/index.js.map +1 -1
- package/dist/src/transactions/index.js +18 -22
- package/dist/src/transactions/index.js.map +1 -1
- package/dist/src/utils/index.cjs.map +2 -2
- package/dist/src/utils/index.js +4 -5
- package/dist/src/utils/index.js.map +3 -3
- package/package.json +1 -1
- package/dist/shared/stacks-1aqm7c2h.cjs +0 -110
- package/dist/shared/stacks-1aqm7c2h.cjs.map +0 -11
- package/dist/shared/stacks-1ddg6mbv.js.map +0 -10
- package/dist/shared/stacks-2gdt3aqj.cjs +0 -44
- package/dist/shared/stacks-8yykgdww.js +0 -125
- package/dist/shared/stacks-8yykgdww.js.map +0 -11
- package/dist/shared/stacks-b008c3w8.cjs.map +0 -11
- package/dist/shared/stacks-hfem9dck.cjs.map +0 -13
- package/dist/shared/stacks-j2cy7qtt.js.map +0 -11
- package/dist/shared/stacks-njvyj3ab.js +0 -23
- package/dist/shared/stacks-njvyj3ab.js.map +0 -9
- package/dist/shared/stacks-pz73cn97.js +0 -285
- package/dist/shared/stacks-pz73cn97.js.map +0 -11
- package/dist/shared/stacks-xtz0n62y.js.map +0 -13
- package/dist/shared/stacks-zyv9qqme.cjs +0 -249
- package/dist/shared/stacks-zyv9qqme.cjs.map +0 -11
- /package/dist/shared/{stacks-d1fmkv3p.js.map → stacks-9avax1yf.js.map} +0 -0
|
@@ -4,14 +4,14 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
buildContractCall,
|
|
6
6
|
getTransactionId,
|
|
7
|
+
serializePayload,
|
|
8
|
+
serializeTransaction,
|
|
7
9
|
signTransactionWithAccount
|
|
8
|
-
} from "./stacks-
|
|
9
|
-
import {
|
|
10
|
-
deserializeCVBytes
|
|
11
|
-
} from "./stacks-j2cy7qtt.js";
|
|
10
|
+
} from "./stacks-vyb9rx8q.js";
|
|
12
11
|
import {
|
|
12
|
+
deserializeCVBytes,
|
|
13
13
|
serializeCVBytes
|
|
14
|
-
} from "./stacks-
|
|
14
|
+
} from "./stacks-fedzr2ka.js";
|
|
15
15
|
import {
|
|
16
16
|
parseContractId
|
|
17
17
|
} from "./stacks-gjvbq6w7.js";
|
|
@@ -19,10 +19,6 @@ import {
|
|
|
19
19
|
bytesToHex,
|
|
20
20
|
with0x
|
|
21
21
|
} from "./stacks-nqytwfcc.js";
|
|
22
|
-
import {
|
|
23
|
-
serializePayload,
|
|
24
|
-
serializeTransaction
|
|
25
|
-
} from "./stacks-xtz0n62y.js";
|
|
26
22
|
|
|
27
23
|
// src/actions/public/getNonce.ts
|
|
28
24
|
async function getNonce(client, params) {
|
|
@@ -156,5 +152,5 @@ async function callContract(client, params) {
|
|
|
156
152
|
|
|
157
153
|
export { getNonce, readContract, getMapEntry, estimateFee, sendTransaction, isProviderAccount, callContract };
|
|
158
154
|
|
|
159
|
-
//# debugId=
|
|
160
|
-
//# sourceMappingURL=stacks-
|
|
155
|
+
//# debugId=8DDF03B060055A5664756E2164756E21
|
|
156
|
+
//# sourceMappingURL=stacks-wrb1es85.js.map
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
"import type { Client } from \"../../clients/types.ts\";\nimport type { ClarityValue } from \"../../clarity/types.ts\";\nimport { serializeCVBytes } from \"../../clarity/serialize.ts\";\nimport { deserializeCVBytes } from \"../../clarity/deserialize.ts\";\nimport { bytesToHex, with0x } from \"../../utils/encoding.ts\";\nimport { parseContractId } from \"../../utils/address.ts\";\n\nexport type GetMapEntryParams = {\n contract: string; // \"address.name\"\n mapName: string;\n key: ClarityValue;\n};\n\nexport async function getMapEntry<T extends ClarityValue = ClarityValue>(\n client: Client,\n params: GetMapEntryParams\n): Promise<T> {\n const [address, name] = parseContractId(params.contract);\n const serializedKey = with0x(bytesToHex(serializeCVBytes(params.key)));\n\n const data = await client.request(\n `/v2/map_entry/${address}/${name}/${params.mapName}`,\n {\n method: \"POST\",\n body: serializedKey,\n }\n );\n\n return deserializeCVBytes<T>(data.data);\n}\n",
|
|
8
8
|
"import type { Client } from \"../../clients/types.ts\";\nimport { bytesToHex } from \"../../utils/encoding.ts\";\nimport { serializePayload, serializeTransaction } from \"../../transactions/wire/serialize.ts\";\nimport type { StacksTransaction } from \"../../transactions/types.ts\";\n\nexport type EstimateFeeParams = {\n transaction: StacksTransaction;\n};\n\nexport type FeeEstimation = {\n feeRate: number;\n fee: number;\n};\n\nexport async function estimateFee(\n client: Client,\n params: EstimateFeeParams\n): Promise<FeeEstimation[]> {\n const payloadHex = bytesToHex(serializePayload(params.transaction.payload));\n const txHex = bytesToHex(serializeTransaction(params.transaction));\n\n const data = await client.request(\"/v2/fees/transaction\", {\n method: \"POST\",\n body: {\n estimated_len: Math.ceil(txHex.length / 2),\n transaction_payload: \"0x\" + payloadHex,\n },\n });\n\n return (data.estimations ?? []).map((e: any) => ({\n feeRate: e.fee_rate,\n fee: e.fee,\n }));\n}\n",
|
|
9
9
|
"import { BaseError } from \"./base.ts\";\n\nexport class TransactionError extends BaseError {\n override name = \"TransactionError\";\n}\n\nexport class BroadcastError extends BaseError {\n override name = \"BroadcastError\";\n txid?: string;\n reason?: string;\n\n constructor(\n message: string,\n options?: { cause?: Error; txid?: string; reason?: string }\n ) {\n super(message, options);\n this.txid = options?.txid;\n this.reason = options?.reason;\n }\n}\n\nexport class SerializationError extends BaseError {\n override name = \"SerializationError\";\n}\n\nexport class SigningError extends BaseError {\n override name = \"SigningError\";\n}\n",
|
|
10
|
-
"import type { Client
|
|
10
|
+
"import type { Client } from \"../../clients/types.ts\";\nimport { bytesToHex } from \"../../utils/encoding.ts\";\nimport { serializeTransaction } from \"../../transactions/wire/serialize.ts\";\nimport { getTransactionId } from \"../../transactions/signer.ts\";\nimport type { StacksTransaction } from \"../../transactions/types.ts\";\nimport { BroadcastError } from \"../../errors/transaction.ts\";\n\nexport type SendTransactionParams = {\n transaction: StacksTransaction;\n attachment?: Uint8Array | string;\n};\n\nexport type SendTransactionResult = {\n txid: string;\n};\n\n/** Broadcast a signed transaction to the network */\nexport async function sendTransaction(\n client: Client,\n params: SendTransactionParams\n): Promise<SendTransactionResult> {\n const hex = bytesToHex(serializeTransaction(params.transaction));\n\n const body: Record<string, string> = { tx: hex };\n if (params.attachment) {\n body.attachment =\n typeof params.attachment === \"string\"\n ? params.attachment\n : bytesToHex(params.attachment);\n }\n\n const data = await client.request(\"/v2/transactions\", {\n method: \"POST\",\n body,\n });\n\n if (data.error) {\n throw new BroadcastError(data.reason ?? data.error, {\n reason: data.reason,\n });\n }\n\n const txid =\n typeof data === \"string\"\n ? data.replace(/\"/g, \"\")\n : data.txid ?? getTransactionId(params.transaction);\n\n return { txid };\n}\n",
|
|
11
11
|
"import type { Account } from \"../../clients/types.ts\";\nimport type { ProviderAccount } from \"../../accounts/types.ts\";\n\nexport function isProviderAccount(account: Account): account is ProviderAccount {\n return account.type === \"provider\";\n}\n",
|
|
12
12
|
"import type { Client } from \"../../clients/types.ts\";\nimport type { ClarityValue } from \"../../clarity/types.ts\";\nimport type { PostCondition } from \"../../postconditions/types.ts\";\nimport type { IntegerType } from \"../../utils/encoding.ts\";\nimport { parseContractId } from \"../../utils/address.ts\";\nimport { buildContractCall } from \"../../transactions/build.ts\";\nimport { signTransactionWithAccount } from \"../../transactions/signer.ts\";\nimport { sendTransaction } from \"./sendTransaction.ts\";\nimport { getNonce } from \"../public/getNonce.ts\";\nimport { estimateFee } from \"../public/estimateFee.ts\";\nimport { isProviderAccount } from \"./utils.ts\";\n\nexport type CallContractParams = {\n contract: string; // \"address.name\"\n functionName: string;\n functionArgs?: ClarityValue[];\n fee?: IntegerType;\n nonce?: IntegerType;\n postConditionMode?: \"allow\" | \"deny\";\n postConditions?: PostCondition[];\n};\n\n/** Build, sign, and broadcast a contract call */\nexport async function callContract(\n client: Client,\n params: CallContractParams\n): Promise<string> {\n const account = client.account;\n if (!account) throw new Error(\"Account required\");\n\n // Provider: delegate to wallet\n if (isProviderAccount(account)) {\n const result = await account.provider.request(\"stx_callContract\", {\n contract: params.contract,\n functionName: params.functionName,\n functionArgs: params.functionArgs ?? [],\n });\n return result.txid;\n }\n\n // Local/Custom: build → sign → broadcast\n const [contractAddress, contractName] = parseContractId(params.contract);\n\n const nonce =\n params.nonce ?? await getNonce(client, { address: account.address });\n\n const unsigned = buildContractCall({\n contractAddress,\n contractName,\n functionName: params.functionName,\n functionArgs: params.functionArgs ?? [],\n fee: params.fee ?? 0n,\n nonce,\n publicKey: account.publicKey,\n chain: client.chain,\n postConditionMode: params.postConditionMode,\n postConditions: params.postConditions,\n });\n\n if (params.fee === undefined) {\n const estimates = await estimateFee(client, { transaction: unsigned });\n const mid = estimates[1] ?? estimates[0];\n if (mid) {\n (unsigned.auth.spendingCondition as any).fee = BigInt(mid.fee);\n }\n }\n\n const signed = await signTransactionWithAccount(unsigned, account);\n const result = await sendTransaction(client, { transaction: signed });\n return result.txid;\n}\n"
|
|
13
13
|
],
|
|
14
|
-
"mappings": "
|
|
15
|
-
"debugId": "
|
|
14
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAWA,eAAsB,QAAQ,CAC5B,QACA,QACiB;AAAA,EACjB,MAAM,OAAO,MAAM,OAAO,QAAQ,gBAAgB,OAAO,WAAW;AAAA,IAClE,QAAQ;AAAA,EACV,CAAC;AAAA,EACD,OAAO,OAAO,KAAK,KAAK;AAAA;;;ACJ1B,eAAsB,YAAmD,CACvE,QACA,QACY;AAAA,EACZ,OAAO,SAAS,QAAQ,gBAAgB,OAAO,QAAQ;AAAA,EACvD,MAAM,SAAS,OAAO,UAAU;AAAA,EAEhC,MAAM,kBAAkB,OAAO,QAAQ,CAAC,GAAG,IAAI,CAAC,QAC9C,OAAO,WAAW,iBAAiB,GAAG,CAAC,CAAC,CAC1C;AAAA,EAEA,MAAM,OAAO,MAAM,OAAO,QACxB,2BAA2B,WAAW,QAAQ,OAAO,gBACrD;AAAA,IACE,QAAQ;AAAA,IACR,MAAM;AAAA,MACJ;AAAA,MACA,WAAW;AAAA,IACb;AAA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A;AAAA,IACA,cAAc,OAAO;AAAA,IACrB,cAAc,OAAO,gBAAgB,CAAC;AAAA,IACtC,KAAK,OAAO,OAAO;AAAA,IACnB;AAAA,IACA,WAAW,QAAQ;AAAA,IACnB,OAAO,OAAO;AAAA,IACd,mBAAmB,OAAO;AAAA,IAC1B,gBAAgB,OAAO;AAAA,EACzB,CAAC;AAAA,EAED,IAAI,OAAO,QAAQ,WAAW;AAAA,IAC5B,MAAM,YAAY,MAAM,YAAY,QAAQ,EAAE,aAAa,SAAS,CAAC;AAAA,IACrE,MAAM,MAAM,UAAU,MAAM,UAAU;AAAA,IACtC,IAAI,KAAK;AAAA,MACN,SAAS,KAAK,kBAA0B,MAAM,OAAO,IAAI,GAAG;AAAA,IAC/D;AAAA,EACF;AAAA,EAEA,MAAM,SAAS,MAAM,2BAA2B,UAAU,OAAO;AAAA,EACjE,MAAM,SAAS,MAAM,gBAAgB,QAAQ,EAAE,aAAa,OAAO,CAAC;AAAA,EACpE,OAAO,OAAO;AAAA;",
|
|
15
|
+
"debugId": "8DDF03B060055A5664756E2164756E21",
|
|
16
16
|
"names": []
|
|
17
17
|
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import {
|
|
2
|
+
parseContractId,
|
|
3
|
+
validateStacksAddress
|
|
4
|
+
} from "./stacks-gjvbq6w7.js";
|
|
5
|
+
import {
|
|
6
|
+
intToBigInt
|
|
7
|
+
} from "./stacks-nqytwfcc.js";
|
|
8
|
+
|
|
9
|
+
// src/postconditions/builder.ts
|
|
10
|
+
class PartialPcWithPrincipal {
|
|
11
|
+
address;
|
|
12
|
+
constructor(address) {
|
|
13
|
+
this.address = address;
|
|
14
|
+
}
|
|
15
|
+
willSendEq(amount) {
|
|
16
|
+
return new PartialPcFtWithCode(this.address, amount, "eq");
|
|
17
|
+
}
|
|
18
|
+
willSendGte(amount) {
|
|
19
|
+
return new PartialPcFtWithCode(this.address, amount, "gte");
|
|
20
|
+
}
|
|
21
|
+
willSendGt(amount) {
|
|
22
|
+
return new PartialPcFtWithCode(this.address, amount, "gt");
|
|
23
|
+
}
|
|
24
|
+
willSendLte(amount) {
|
|
25
|
+
return new PartialPcFtWithCode(this.address, amount, "lte");
|
|
26
|
+
}
|
|
27
|
+
willSendLt(amount) {
|
|
28
|
+
return new PartialPcFtWithCode(this.address, amount, "lt");
|
|
29
|
+
}
|
|
30
|
+
willSendAsset() {
|
|
31
|
+
return new PartialPcNftWithCode(this.address, "sent");
|
|
32
|
+
}
|
|
33
|
+
willNotSendAsset() {
|
|
34
|
+
return new PartialPcNftWithCode(this.address, "not-sent");
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
class PartialPcFtWithCode {
|
|
39
|
+
address;
|
|
40
|
+
amount;
|
|
41
|
+
code;
|
|
42
|
+
constructor(address, amount, code) {
|
|
43
|
+
this.address = address;
|
|
44
|
+
this.amount = amount;
|
|
45
|
+
this.code = code;
|
|
46
|
+
}
|
|
47
|
+
ustx() {
|
|
48
|
+
return {
|
|
49
|
+
type: "stx-postcondition",
|
|
50
|
+
address: this.address,
|
|
51
|
+
condition: this.code,
|
|
52
|
+
amount: intToBigInt(this.amount).toString()
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
ft(contractId, tokenName) {
|
|
56
|
+
const [address, name] = contractId.split(".");
|
|
57
|
+
if (!address || !validateStacksAddress(address) || !name) {
|
|
58
|
+
throw new Error(`Invalid contract id: ${contractId}`);
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
type: "ft-postcondition",
|
|
62
|
+
address: this.address,
|
|
63
|
+
condition: this.code,
|
|
64
|
+
amount: intToBigInt(this.amount).toString(),
|
|
65
|
+
asset: `${contractId}::${tokenName}`
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
class PartialPcNftWithCode {
|
|
71
|
+
address;
|
|
72
|
+
code;
|
|
73
|
+
constructor(address, code) {
|
|
74
|
+
this.address = address;
|
|
75
|
+
this.code = code;
|
|
76
|
+
}
|
|
77
|
+
nft(assetOrContractId, tokenNameOrAssetId, assetId) {
|
|
78
|
+
let contractAddress;
|
|
79
|
+
let contractName;
|
|
80
|
+
let tokenName;
|
|
81
|
+
let id;
|
|
82
|
+
if (assetId !== undefined) {
|
|
83
|
+
[contractAddress, contractName] = parseContractId(assetOrContractId);
|
|
84
|
+
tokenName = tokenNameOrAssetId;
|
|
85
|
+
id = assetId;
|
|
86
|
+
} else {
|
|
87
|
+
const [principal, tName] = assetOrContractId.split("::");
|
|
88
|
+
if (!principal || !tName)
|
|
89
|
+
throw new Error(`Invalid asset name: ${assetOrContractId}`);
|
|
90
|
+
[contractAddress, contractName] = parseContractId(principal);
|
|
91
|
+
tokenName = tName;
|
|
92
|
+
id = tokenNameOrAssetId;
|
|
93
|
+
}
|
|
94
|
+
if (!validateStacksAddress(contractAddress)) {
|
|
95
|
+
throw new Error(`Invalid contract address: ${contractAddress}`);
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
type: "nft-postcondition",
|
|
99
|
+
address: this.address,
|
|
100
|
+
condition: this.code,
|
|
101
|
+
asset: `${contractAddress}.${contractName}::${tokenName}`,
|
|
102
|
+
assetId: id
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
var Pc = {
|
|
107
|
+
principal(address) {
|
|
108
|
+
const [addr, name] = address.split(".");
|
|
109
|
+
if (!addr || !validateStacksAddress(addr) || typeof name === "string" && !name) {
|
|
110
|
+
throw new Error(`Invalid principal: ${address}`);
|
|
111
|
+
}
|
|
112
|
+
return new PartialPcWithPrincipal(address);
|
|
113
|
+
},
|
|
114
|
+
origin() {
|
|
115
|
+
return new PartialPcWithPrincipal("origin");
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
export { Pc };
|
|
119
|
+
|
|
120
|
+
//# debugId=A955F701F76F44AE64756E2164756E21
|
|
121
|
+
//# sourceMappingURL=stacks-yfveb68e.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/postconditions/builder.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import { intToBigInt, type IntegerType } from \"../utils/encoding.ts\";\nimport { validateStacksAddress, parseContractId } from \"../utils/address.ts\";\nimport type { ClarityValue } from \"../clarity/types.ts\";\nimport type {\n StxPostCondition,\n FtPostCondition,\n NftPostCondition,\n FungibleComparator,\n NonFungibleComparator,\n} from \"./types.ts\";\n\nclass PartialPcWithPrincipal {\n constructor(private address: string) {}\n\n willSendEq(amount: IntegerType) {\n return new PartialPcFtWithCode(this.address, amount, \"eq\");\n }\n willSendGte(amount: IntegerType) {\n return new PartialPcFtWithCode(this.address, amount, \"gte\");\n }\n willSendGt(amount: IntegerType) {\n return new PartialPcFtWithCode(this.address, amount, \"gt\");\n }\n willSendLte(amount: IntegerType) {\n return new PartialPcFtWithCode(this.address, amount, \"lte\");\n }\n willSendLt(amount: IntegerType) {\n return new PartialPcFtWithCode(this.address, amount, \"lt\");\n }\n willSendAsset() {\n return new PartialPcNftWithCode(this.address, \"sent\");\n }\n willNotSendAsset() {\n return new PartialPcNftWithCode(this.address, \"not-sent\");\n }\n}\n\nclass PartialPcFtWithCode {\n constructor(\n private address: string,\n private amount: IntegerType,\n private code: FungibleComparator\n ) {}\n\n ustx(): StxPostCondition {\n return {\n type: \"stx-postcondition\",\n address: this.address,\n condition: this.code,\n amount: intToBigInt(this.amount).toString(),\n };\n }\n\n ft(contractId: string, tokenName: string): FtPostCondition {\n const [address, name] = contractId.split(\".\");\n if (!address || !validateStacksAddress(address) || !name) {\n throw new Error(`Invalid contract id: ${contractId}`);\n }\n return {\n type: \"ft-postcondition\",\n address: this.address,\n condition: this.code,\n amount: intToBigInt(this.amount).toString(),\n asset: `${contractId}::${tokenName}`,\n };\n }\n}\n\nclass PartialPcNftWithCode {\n constructor(\n private address: string,\n private code: NonFungibleComparator\n ) {}\n\n nft(assetOrContractId: string, tokenNameOrAssetId: string | ClarityValue, assetId?: ClarityValue): NftPostCondition {\n let contractAddress: string;\n let contractName: string;\n let tokenName: string;\n let id: ClarityValue;\n\n if (assetId !== undefined) {\n // 3 args: contractId, tokenName, assetId\n [contractAddress, contractName] = parseContractId(assetOrContractId);\n tokenName = tokenNameOrAssetId as string;\n id = assetId;\n } else {\n // 2 args: assetString (addr.contract::token), assetId\n const [principal, tName] = assetOrContractId.split(\"::\");\n if (!principal || !tName) throw new Error(`Invalid asset name: ${assetOrContractId}`);\n [contractAddress, contractName] = parseContractId(principal);\n tokenName = tName;\n id = tokenNameOrAssetId as ClarityValue;\n }\n\n if (!validateStacksAddress(contractAddress)) {\n throw new Error(`Invalid contract address: ${contractAddress}`);\n }\n\n return {\n type: \"nft-postcondition\",\n address: this.address,\n condition: this.code,\n asset: `${contractAddress}.${contractName}::${tokenName}`,\n assetId: id,\n };\n }\n}\n\nexport const Pc = {\n principal(address: string) {\n const [addr, name] = address.split(\".\");\n if (!addr || !validateStacksAddress(addr) || (typeof name === \"string\" && !name)) {\n throw new Error(`Invalid principal: ${address}`);\n }\n return new PartialPcWithPrincipal(address);\n },\n origin() {\n return new PartialPcWithPrincipal(\"origin\");\n },\n};\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";;;;;;;;;AAWA,MAAM,uBAAuB;AAAA,EACP;AAAA,EAApB,WAAW,CAAS,SAAiB;AAAA,IAAjB;AAAA;AAAA,EAEpB,UAAU,CAAC,QAAqB;AAAA,IAC9B,OAAO,IAAI,oBAAoB,KAAK,SAAS,QAAQ,IAAI;AAAA;AAAA,EAE3D,WAAW,CAAC,QAAqB;AAAA,IAC/B,OAAO,IAAI,oBAAoB,KAAK,SAAS,QAAQ,KAAK;AAAA;AAAA,EAE5D,UAAU,CAAC,QAAqB;AAAA,IAC9B,OAAO,IAAI,oBAAoB,KAAK,SAAS,QAAQ,IAAI;AAAA;AAAA,EAE3D,WAAW,CAAC,QAAqB;AAAA,IAC/B,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
|
-
import"../../shared/stacks-njvyj3ab.js";
|
|
14
13
|
|
|
15
14
|
// src/accounts/privateKeyToAccount.ts
|
|
16
15
|
import {
|
|
@@ -100,5 +99,5 @@ export {
|
|
|
100
99
|
compressPrivateKey
|
|
101
100
|
};
|
|
102
101
|
|
|
103
|
-
//# debugId=
|
|
102
|
+
//# debugId=7A617EF207440E2164756E2164756E21
|
|
104
103
|
//# sourceMappingURL=index.js.map
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"import { HDKey } from \"@scure/bip32\";\nimport { mnemonicToSeedSync } from \"@scure/bip39\";\nimport { bytesToHex } from \"../utils/encoding.ts\";\nimport { privateKeyToAccount, compressPrivateKey } from \"./privateKeyToAccount.ts\";\nimport type { LocalAccount } from \"./types.ts\";\n\nconst STX_DERIVATION_PATH = \"m/44'/5757'/0'/0\";\n\nexport function mnemonicToAccount(\n mnemonic: string,\n options?: {\n accountIndex?: number;\n addressVersion?: number;\n }\n): LocalAccount {\n const { accountIndex = 0, addressVersion } = options ?? {};\n\n const seed = mnemonicToSeedSync(mnemonic);\n const root = HDKey.fromMasterSeed(seed);\n const child = root.derive(`${STX_DERIVATION_PATH}/${accountIndex}`);\n\n if (!child.privateKey) throw new Error(\"Failed to derive private key\");\n\n const privateKeyHex = compressPrivateKey(bytesToHex(child.privateKey));\n return privateKeyToAccount(privateKeyHex, { addressVersion });\n}\n",
|
|
7
7
|
"import type { AccountSource, CustomAccount } from \"./types.ts\";\n\nexport function toAccount(source: AccountSource): CustomAccount {\n return {\n type: \"custom\",\n address: source.address,\n publicKey: source.publicKey,\n sign: source.sign,\n };\n}\n"
|
|
8
8
|
],
|
|
9
|
-
"mappings": "
|
|
10
|
-
"debugId": "
|
|
9
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA,kBACE;AAAA;AAAA;AAAA;AAIF;AACA;AAMA,SAAS,iBAAiB,GAAG;AAAA,EAC3B,IAAI,CAAC,IAAI,gBAAgB;AAAA,IACvB,IAAI,iBAA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ClC;AAAA,EACA,OAAO;AAAA;AAIF,SAAS,kBAAkB,CAAC,KAAkC;AAAA,EACnE,MAAM,MAAM,OAAO,QAAQ,WAAW,UAAU,GAAG,IAAI,WAAW,GAAG;AAAA,EACrE,IAAI,IAAI,WAAW,gCAAgC;AAAA,IAAG,OAAO;AAAA,EAC7D,OAAO,GAAG;AAAA;;AC5EZ;AACA;AAKA,IAAM,sBAAsB;AAErB,SAAS,iBAAiB,CAC/B,UACA,SAIc;AAAA,EACd,QAAQ,eAAe,GAAG,mBAAmB,WAAW,CAAC;AAAA,EAEzD,MAAM,OAAO,mBAAmB,QAAQ;AAAA,EACxC,MAAM,OAAO,MAAM,eAAe,IAAI;AAAA,EACtC,MAAM,QAAQ,KAAK,OAAO,GAAG,uBAAuB,cAAc;AAAA,EAElE,IAAI,CAAC,MAAM;AAAA,IAAY,MAAM,IAAI,MAAM,8BAA8B;AAAA,EAErE,MAAM,gBAAgB,mBAAmB,WAAW,MAAM,UAAU,CAAC;AAAA,EACrE,OAAO,oBAAoB,eAAe,EAAE,eAAe,CAAC;AAAA;;ACtBvD,SAAS,SAAS,CAAC,QAAsC;AAAA,EAC9D,OAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS,OAAO;AAAA,IAChB,WAAW,OAAO;AAAA,IAClB,MAAM,OAAO;AAAA,EACf;AAAA;",
|
|
10
|
+
"debugId": "7A617EF207440E2164756E2164756E21",
|
|
11
11
|
"names": []
|
|
12
12
|
}
|
|
@@ -750,7 +750,6 @@ interface AbiResponseType {
|
|
|
750
750
|
type AbiType = AbiPrimitiveType | AbiListType | AbiTupleType | AbiOptionalType | AbiResponseType;
|
|
751
751
|
type CamelCaseInner<S extends string> = S extends `${infer P1}-${infer P2}${infer P3}` ? `${P1}${Capitalize<CamelCaseInner<`${P2}${P3}`>>}` : S;
|
|
752
752
|
type ToCamelCase<S extends string> = CamelCaseInner<S> extends `${number}${string}` ? `_${CamelCaseInner<S>}` : CamelCaseInner<S>;
|
|
753
|
-
declare function toCamelCase(str: string): string;
|
|
754
753
|
type TupleToObject<T extends ReadonlyArray<{
|
|
755
754
|
name: string
|
|
756
755
|
type: AbiType
|
|
@@ -897,10 +896,9 @@ type ReadMethodReturn<
|
|
|
897
896
|
C extends AbiContract,
|
|
898
897
|
N extends ExtractReadOnlyFunctions<C>
|
|
899
898
|
> = UnwrapResponse<ExtractFunctionOutput<C, N>>;
|
|
900
|
-
type ReadMethods<C extends AbiContract> = { [N in ExtractReadOnlyFunctions<C> as
|
|
901
|
-
type CallMethods<C extends AbiContract> = { [N in ExtractPublicFunctions<C> as
|
|
902
|
-
type MapMethods<C extends AbiContract> = { [N in ExtractMapNames<C> as
|
|
903
|
-
type ToCamelCaseName<S extends string> = S extends string ? ReturnType<typeof toCamelCase> extends string ? S : S : S;
|
|
899
|
+
type ReadMethods<C extends AbiContract> = { [N in ExtractReadOnlyFunctions<C> as ToCamelCase<N>] : (args: ExtractFunctionArgs<C, N>) => Promise<ReadMethodReturn<C, N>> };
|
|
900
|
+
type CallMethods<C extends AbiContract> = { [N in ExtractPublicFunctions<C> as ToCamelCase<N>] : (args: ExtractFunctionArgs<C, N>, options?: ContractCallOptions) => Promise<string> };
|
|
901
|
+
type MapMethods<C extends AbiContract> = { [N in ExtractMapNames<C> as ToCamelCase<N>] : (key: ExtractMapKey<C, N>) => Promise<ExtractMapValue<C, N> | null> };
|
|
904
902
|
type ContractCallOptions = {
|
|
905
903
|
fee?: IntegerType
|
|
906
904
|
nonce?: IntegerType
|
|
@@ -750,7 +750,6 @@ interface AbiResponseType {
|
|
|
750
750
|
type AbiType = AbiPrimitiveType | AbiListType | AbiTupleType | AbiOptionalType | AbiResponseType;
|
|
751
751
|
type CamelCaseInner<S extends string> = S extends `${infer P1}-${infer P2}${infer P3}` ? `${P1}${Capitalize<CamelCaseInner<`${P2}${P3}`>>}` : S;
|
|
752
752
|
type ToCamelCase<S extends string> = CamelCaseInner<S> extends `${number}${string}` ? `_${CamelCaseInner<S>}` : CamelCaseInner<S>;
|
|
753
|
-
declare function toCamelCase(str: string): string;
|
|
754
753
|
type TupleToObject<T extends ReadonlyArray<{
|
|
755
754
|
name: string
|
|
756
755
|
type: AbiType
|
|
@@ -897,10 +896,9 @@ type ReadMethodReturn<
|
|
|
897
896
|
C extends AbiContract,
|
|
898
897
|
N extends ExtractReadOnlyFunctions<C>
|
|
899
898
|
> = UnwrapResponse<ExtractFunctionOutput<C, N>>;
|
|
900
|
-
type ReadMethods<C extends AbiContract> = { [N in ExtractReadOnlyFunctions<C> as
|
|
901
|
-
type CallMethods<C extends AbiContract> = { [N in ExtractPublicFunctions<C> as
|
|
902
|
-
type MapMethods<C extends AbiContract> = { [N in ExtractMapNames<C> as
|
|
903
|
-
type ToCamelCaseName<S extends string> = S extends string ? ReturnType<typeof toCamelCase> extends string ? S : S : S;
|
|
899
|
+
type ReadMethods<C extends AbiContract> = { [N in ExtractReadOnlyFunctions<C> as ToCamelCase<N>] : (args: ExtractFunctionArgs<C, N>) => Promise<ReadMethodReturn<C, N>> };
|
|
900
|
+
type CallMethods<C extends AbiContract> = { [N in ExtractPublicFunctions<C> as ToCamelCase<N>] : (args: ExtractFunctionArgs<C, N>, options?: ContractCallOptions) => Promise<string> };
|
|
901
|
+
type MapMethods<C extends AbiContract> = { [N in ExtractMapNames<C> as ToCamelCase<N>] : (key: ExtractMapKey<C, N>) => Promise<ExtractMapValue<C, N> | null> };
|
|
904
902
|
type ContractCallOptions = {
|
|
905
903
|
fee?: IntegerType
|
|
906
904
|
nonce?: IntegerType
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ContractResponseError,
|
|
3
3
|
getContract
|
|
4
|
-
} from "../../shared/stacks-
|
|
4
|
+
} from "../../shared/stacks-qcx67vqa.js";
|
|
5
5
|
import {
|
|
6
6
|
deployContract,
|
|
7
7
|
getAccountInfo,
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
simulateTransaction,
|
|
17
17
|
sponsorTransaction,
|
|
18
18
|
transferStx
|
|
19
|
-
} from "../../shared/stacks-
|
|
19
|
+
} from "../../shared/stacks-vd9jcp0b.js";
|
|
20
20
|
import {
|
|
21
21
|
callContract,
|
|
22
22
|
estimateFee,
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
isProviderAccount,
|
|
26
26
|
readContract,
|
|
27
27
|
sendTransaction
|
|
28
|
-
} from "../../shared/stacks-
|
|
28
|
+
} from "../../shared/stacks-wrb1es85.js";
|
|
29
29
|
import {
|
|
30
30
|
watchAddress,
|
|
31
31
|
watchAddressBalance,
|
|
@@ -35,17 +35,14 @@ import {
|
|
|
35
35
|
watchTransaction
|
|
36
36
|
} from "../../shared/stacks-y3dh7hv1.js";
|
|
37
37
|
import"../../shared/stacks-709tra19.js";
|
|
38
|
-
import"../../shared/stacks-
|
|
39
|
-
import"../../shared/stacks-
|
|
40
|
-
import"../../shared/stacks-
|
|
41
|
-
import"../../shared/stacks-
|
|
42
|
-
import"../../shared/stacks-8yykgdww.js";
|
|
38
|
+
import"../../shared/stacks-9avax1yf.js";
|
|
39
|
+
import"../../shared/stacks-9mdk86wp.js";
|
|
40
|
+
import"../../shared/stacks-vyb9rx8q.js";
|
|
41
|
+
import"../../shared/stacks-fedzr2ka.js";
|
|
43
42
|
import"../../shared/stacks-v9jqcpd4.js";
|
|
44
43
|
import"../../shared/stacks-bycy6t9k.js";
|
|
45
44
|
import"../../shared/stacks-gjvbq6w7.js";
|
|
46
45
|
import"../../shared/stacks-nqytwfcc.js";
|
|
47
|
-
import"../../shared/stacks-njvyj3ab.js";
|
|
48
|
-
import"../../shared/stacks-xtz0n62y.js";
|
|
49
46
|
export {
|
|
50
47
|
watchTransaction,
|
|
51
48
|
watchNftEvent,
|
|
@@ -77,5 +74,5 @@ export {
|
|
|
77
74
|
ContractResponseError
|
|
78
75
|
};
|
|
79
76
|
|
|
80
|
-
//# debugId=
|
|
77
|
+
//# debugId=1F3515003973BE3864756E2164756E21
|
|
81
78
|
//# sourceMappingURL=index.js.map
|
package/dist/src/bns/index.cjs
CHANGED
|
@@ -354,7 +354,7 @@ async function resolveName(client, nameOrFQN) {
|
|
|
354
354
|
const { name, namespace } = parseFQN(nameOrFQN);
|
|
355
355
|
const bns = getBnsContract(client);
|
|
356
356
|
try {
|
|
357
|
-
return await bns.read
|
|
357
|
+
return await bns.read.getOwnerName({
|
|
358
358
|
name: stringToBytes(name),
|
|
359
359
|
namespace: stringToBytes(namespace)
|
|
360
360
|
});
|
|
@@ -367,7 +367,7 @@ async function resolveName(client, nameOrFQN) {
|
|
|
367
367
|
async function getPrimaryName(client, address) {
|
|
368
368
|
const bns = getBnsContract(client);
|
|
369
369
|
try {
|
|
370
|
-
const result = await bns.read
|
|
370
|
+
const result = await bns.read.getPrimary({
|
|
371
371
|
owner: address
|
|
372
372
|
});
|
|
373
373
|
if (result === null)
|
|
@@ -388,7 +388,7 @@ async function canRegister(client, nameOrFQN) {
|
|
|
388
388
|
const { name, namespace } = parseFQN(nameOrFQN);
|
|
389
389
|
const bns = getBnsContract(client);
|
|
390
390
|
try {
|
|
391
|
-
await bns.read
|
|
391
|
+
await bns.read.canResolveName({
|
|
392
392
|
namespace: stringToBytes(namespace),
|
|
393
393
|
name: stringToBytes(name)
|
|
394
394
|
});
|
|
@@ -403,7 +403,7 @@ async function getNamePrice(client, nameOrFQN) {
|
|
|
403
403
|
}
|
|
404
404
|
const { name, namespace } = parseFQN(nameOrFQN);
|
|
405
405
|
const bns = getBnsContract(client);
|
|
406
|
-
const result = await bns.read
|
|
406
|
+
const result = await bns.read.getNamePrice({
|
|
407
407
|
namespace: stringToBytes(namespace),
|
|
408
408
|
name: stringToBytes(name)
|
|
409
409
|
});
|
|
@@ -418,7 +418,7 @@ async function getNameId(client, nameOrFQN) {
|
|
|
418
418
|
const { name, namespace } = parseFQN(nameOrFQN);
|
|
419
419
|
const bns = getBnsContract(client);
|
|
420
420
|
try {
|
|
421
|
-
return await bns.read
|
|
421
|
+
return await bns.read.getIdFromBns({
|
|
422
422
|
name: stringToBytes(name),
|
|
423
423
|
namespace: stringToBytes(namespace)
|
|
424
424
|
});
|
|
@@ -443,7 +443,7 @@ async function preorder(client, params) {
|
|
|
443
443
|
const salt = providedSalt ?? generateSalt();
|
|
444
444
|
const hashedSaltedFqn = hashPreorder(name, namespace, salt);
|
|
445
445
|
const bns = getBnsContract(client);
|
|
446
|
-
const txid = await bns.call
|
|
446
|
+
const txid = await bns.call.namePreorder({
|
|
447
447
|
hashedSaltedFqn,
|
|
448
448
|
stxToBurn: price
|
|
449
449
|
}, {
|
|
@@ -459,7 +459,7 @@ async function register(client, params) {
|
|
|
459
459
|
}
|
|
460
460
|
const { name, namespace } = parseFQN(fqn);
|
|
461
461
|
const bns = getBnsContract(client);
|
|
462
|
-
return bns.call
|
|
462
|
+
return bns.call.nameRegister({
|
|
463
463
|
name: stringToBytes(name),
|
|
464
464
|
namespace: stringToBytes(namespace),
|
|
465
465
|
salt
|
|
@@ -478,7 +478,7 @@ async function claimFast(client, params) {
|
|
|
478
478
|
}
|
|
479
479
|
const price = await getNamePrice(client, fqn);
|
|
480
480
|
const bns = getBnsContract(client);
|
|
481
|
-
return bns.call
|
|
481
|
+
return bns.call.nameClaimFast({
|
|
482
482
|
name: stringToBytes(name),
|
|
483
483
|
namespace: stringToBytes(namespace),
|
|
484
484
|
sendTo: recipient
|
|
@@ -527,7 +527,7 @@ async function setPrimary(client, params) {
|
|
|
527
527
|
throw new Error(`Name ${fqn} does not exist`);
|
|
528
528
|
}
|
|
529
529
|
const bns = getBnsContract(client);
|
|
530
|
-
return bns.call
|
|
530
|
+
return bns.call.setPrimaryName({ primaryNameId: id });
|
|
531
531
|
}
|
|
532
532
|
async function getZonefile(client, nameOrFQN) {
|
|
533
533
|
if (!validateFQN(nameOrFQN)) {
|
|
@@ -536,7 +536,7 @@ async function getZonefile(client, nameOrFQN) {
|
|
|
536
536
|
const { name, namespace } = parseFQN(nameOrFQN);
|
|
537
537
|
const zonefile = getZonefileContract(client);
|
|
538
538
|
try {
|
|
539
|
-
const result = await zonefile.read
|
|
539
|
+
const result = await zonefile.read.resolveName({
|
|
540
540
|
name: stringToBytes(name),
|
|
541
541
|
namespace: stringToBytes(namespace)
|
|
542
542
|
});
|
|
@@ -564,7 +564,7 @@ async function updateZonefile(client, params) {
|
|
|
564
564
|
throw new Error(`Zonefile too large: ${zonefileBytes.length} bytes (max 8192)`);
|
|
565
565
|
}
|
|
566
566
|
}
|
|
567
|
-
return zonefileContract.call
|
|
567
|
+
return zonefileContract.call.updateZonefile({
|
|
568
568
|
name: stringToBytes(name),
|
|
569
569
|
namespace: stringToBytes(namespace),
|
|
570
570
|
newZonefile: zonefileBytes
|
|
@@ -576,7 +576,7 @@ async function revokeZonefile(client, nameOrFQN) {
|
|
|
576
576
|
}
|
|
577
577
|
const { name, namespace } = parseFQN(nameOrFQN);
|
|
578
578
|
const zonefileContract = getZonefileContract(client);
|
|
579
|
-
return zonefileContract.call
|
|
579
|
+
return zonefileContract.call.revokeName({
|
|
580
580
|
name: stringToBytes(name),
|
|
581
581
|
namespace: stringToBytes(namespace)
|
|
582
582
|
});
|
|
@@ -603,5 +603,5 @@ function bns() {
|
|
|
603
603
|
});
|
|
604
604
|
}
|
|
605
605
|
|
|
606
|
-
//# debugId=
|
|
606
|
+
//# debugId=B3D7DDC7C337032364756E2164756E21
|
|
607
607
|
//# sourceMappingURL=index.cjs.map
|