@leather.io/stacks 1.15.0 → 1.16.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/dist/index.d.ts +38 -11
- package/dist/index.js +91 -12
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as _stacks_common from '@stacks/common';
|
|
2
2
|
import { PrivateKey } from '@stacks/common';
|
|
3
3
|
import * as _stacks_transactions from '@stacks/transactions';
|
|
4
|
-
import { ClarityValue, StacksTransactionWire, AssetString, ContractIdString, UnsignedContractCallOptions, UnsignedContractDeployOptions, UnsignedTokenTransferOptions, PostConditionWire, PostCondition,
|
|
4
|
+
import { ClarityValue, StacksTransactionWire, AssetString, ContractIdString, UnsignedContractCallOptions, UnsignedContractDeployOptions, UnsignedTokenTransferOptions, TxBroadcastResultRejected, PostConditionWire, PostCondition, ClarityAbi } from '@stacks/transactions';
|
|
5
5
|
import { Signer } from '@leather.io/crypto';
|
|
6
|
-
import { NetworkModes,
|
|
6
|
+
import { NetworkModes, Money, ReplaceTypes, ChainId as ChainId$1, TransactionErrorKey } from '@leather.io/models';
|
|
7
7
|
import { HDKey } from '@scure/bip32';
|
|
8
8
|
import * as _stacks_network from '@stacks/network';
|
|
9
9
|
import { ChainId } from '@stacks/network';
|
|
@@ -118,6 +118,17 @@ declare function getStacksAssetStringParts(identifier: string): {
|
|
|
118
118
|
contractName: string;
|
|
119
119
|
};
|
|
120
120
|
|
|
121
|
+
interface CreateTransferSip10TxHex {
|
|
122
|
+
signer: StacksSigner;
|
|
123
|
+
assetId: string;
|
|
124
|
+
recipient: string;
|
|
125
|
+
amount: number;
|
|
126
|
+
nonce: number;
|
|
127
|
+
fee: Money;
|
|
128
|
+
memo?: string;
|
|
129
|
+
}
|
|
130
|
+
declare function createTransferSip10TxHex({ signer, assetId, recipient, amount, nonce, fee, memo, }: CreateTransferSip10TxHex): Promise<string>;
|
|
131
|
+
|
|
121
132
|
declare enum TransactionTypes {
|
|
122
133
|
ContractCall = "contract_call",
|
|
123
134
|
ContractDeploy = "smart_contract",
|
|
@@ -195,8 +206,9 @@ interface GetSip10FnArgs {
|
|
|
195
206
|
amount: number;
|
|
196
207
|
senderStacksAddress: string;
|
|
197
208
|
recipientStacksAddress: string;
|
|
209
|
+
memo?: string;
|
|
198
210
|
}
|
|
199
|
-
declare function createSip10FnArgs({ amount, senderStacksAddress, recipientStacksAddress, }: GetSip10FnArgs): ClarityValue[];
|
|
211
|
+
declare function createSip10FnArgs({ amount, senderStacksAddress, recipientStacksAddress, memo, }: GetSip10FnArgs): ClarityValue[];
|
|
200
212
|
interface GetSip9FnArgs {
|
|
201
213
|
assetId: string;
|
|
202
214
|
senderStacksAddress: string;
|
|
@@ -204,18 +216,27 @@ interface GetSip9FnArgs {
|
|
|
204
216
|
}
|
|
205
217
|
declare function createSip9FnArgs({ assetId, senderStacksAddress, recipientStacksAddress, }: GetSip9FnArgs): ClarityValue[];
|
|
206
218
|
|
|
219
|
+
declare function getErrorMessage(reason: TxBroadcastResultRejected['reason'] | 'BadTransactionVersion' | 'ConflictingNonceInMempool' | 'EstimatorError' | 'TransferAmountMustBePositive' | 'TransferRecipientCannotEqualSender'): "Incorrect address" | "Incorrect function argument" | "Incorrect nonce" | "Incorrect transaction" | "Nonce conflict" | "Contract already exists" | "Deserialization failure" | "Estimator error" | "Fee too low" | "No coinbase via mempool" | "Contract does not exist" | "Function does not exist" | "Not enough funds" | "Microblock conflict" | "No anchor block with public key hash" | "Invalid microblock" | "Serialization failure" | "Database error" | "No such chain tip" | "Server failure" | "Failed to validate signature" | "Transfer amount must be positive" | "Cannot transfer STX to yourself" | "Something went wrong";
|
|
220
|
+
|
|
207
221
|
declare function getPostConditionFromString(postCondition: string): PostConditionWire;
|
|
208
222
|
declare function ensurePostConditionWireFormat(postCondition: string | PostCondition | PostConditionWire): PostConditionWire;
|
|
209
223
|
declare function getPostCondition(postCondition: string | PostCondition | PostConditionWire): PostConditionWire;
|
|
210
224
|
declare function getPostConditions(postConditions?: (string | PostCondition | PostConditionWire)[]): PostConditionWire[] | undefined;
|
|
211
225
|
|
|
212
|
-
declare function
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
226
|
+
declare function isSip10Transfer({ functionName, contractInterfaceData, }: {
|
|
227
|
+
functionName: string;
|
|
228
|
+
contractInterfaceData: ClarityAbi;
|
|
229
|
+
}): boolean;
|
|
230
|
+
declare function getSip10TransferAmount({ functionName, functionArgs, contractInterfaceData, }: {
|
|
231
|
+
functionName: string;
|
|
232
|
+
functionArgs: ClarityValue[];
|
|
233
|
+
contractInterfaceData: ClarityAbi;
|
|
234
|
+
}): number | null;
|
|
235
|
+
declare function getSip10TransferRecipient({ functionName, functionArgs, contractInterfaceData, }: {
|
|
236
|
+
functionName: string;
|
|
237
|
+
functionArgs: ClarityValue[];
|
|
238
|
+
contractInterfaceData: ClarityAbi;
|
|
239
|
+
}): string | null;
|
|
219
240
|
|
|
220
241
|
declare function isValidStacksAddress(address: string): boolean;
|
|
221
242
|
declare function isValidAddressChain(address: string, chainId: ChainId$1): boolean;
|
|
@@ -226,6 +247,12 @@ declare const principalSchema: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
|
|
|
226
247
|
|
|
227
248
|
declare function isValidStacksMemo(memo: string): boolean;
|
|
228
249
|
|
|
250
|
+
type StacksErrorKey = TransactionErrorKey | 'InvalidSameAddress' | 'UnknownBalance' | 'UnknownFee' | 'UnknownAmount';
|
|
251
|
+
declare class StacksError extends Error {
|
|
252
|
+
message: StacksErrorKey;
|
|
253
|
+
constructor(message: StacksErrorKey);
|
|
254
|
+
}
|
|
255
|
+
|
|
229
256
|
interface StacksTransaction {
|
|
230
257
|
amount: Money;
|
|
231
258
|
payer: string;
|
|
@@ -236,4 +263,4 @@ interface StacksTransaction {
|
|
|
236
263
|
}
|
|
237
264
|
declare function isValidStacksTransaction({ amount, availableBalance, fee, payer, recipient, chainId, }: StacksTransaction): boolean;
|
|
238
265
|
|
|
239
|
-
export { type SignatureData, StacksError, type StacksErrorKey, type StacksSignMessageFn, type StacksSignStructuredMessageFn, type StacksSigner, type StacksSignerFn, type StacksUnsignedContractCallOptions, type StacksUnsignedContractDeployOptions, type StacksUnsignedTokenTransferOptions, type StacksUnsignedTransactionOptions, TEST_ACCOUNT_1_STX_ADDRESS, TEST_ACCOUNT_1_STX_ADDRESS_SM, TEST_ACCOUNT_2_STX_ADDRESS, TEST_TESTNET_ACCOUNT_2_STX_ADDRESS, TEST_TESTNET_ACCOUNT_2_STX_ADDRESS_SN, TransactionTypes, cleanHex, contractPrincipalSchema, createSignFnFromMnemonic, createSignMessageFnFromMnemonic, createSignStructuredDataMessageFnFromMnemonic, createSip10FnArgs, createSip9FnArgs, deriveStxPrivateKey, deriveStxPublicKey, ensurePostConditionWireFormat, extractStacksDerivationPathAccountIndex, formatAssetString, formatContractId, formatContractIdString, generateStacksUnsignedTransaction, getErrorMessage, getPostCondition, getPostConditionFromString, getPostConditions, getPrincipalFromAssetString, getStacksAssetStringParts, getStacksBurnAddress, getStacksContractAssetName, getStacksContractName, getUnsignedContractCallParsedOptions, getUnsignedContractDeployParsedOptions, getUnsignedStxTokenTransferParsedOptions, initNonce, initalizeStacksSigner, isTransactionTypeSupported, isValidAddressChain, isValidStacksAddress, isValidStacksMemo, isValidStacksTransaction, makeAccountIndexDerivationPathFactory, makeStxDerivationPath, principalSchema, signMessage, signStacksTransaction, signStructuredDataMessage, stacksChainIdToCoreNetworkMode, stacksRootKeychainToAccountDescriptor, standardPrincipalSchema, stxDerivationWithAccount, validatePayerNotRecipient, whenStacksChainId };
|
|
266
|
+
export { type SignatureData, StacksError, type StacksErrorKey, type StacksSignMessageFn, type StacksSignStructuredMessageFn, type StacksSigner, type StacksSignerFn, type StacksUnsignedContractCallOptions, type StacksUnsignedContractDeployOptions, type StacksUnsignedTokenTransferOptions, type StacksUnsignedTransactionOptions, TEST_ACCOUNT_1_STX_ADDRESS, TEST_ACCOUNT_1_STX_ADDRESS_SM, TEST_ACCOUNT_2_STX_ADDRESS, TEST_TESTNET_ACCOUNT_2_STX_ADDRESS, TEST_TESTNET_ACCOUNT_2_STX_ADDRESS_SN, TransactionTypes, cleanHex, contractPrincipalSchema, createSignFnFromMnemonic, createSignMessageFnFromMnemonic, createSignStructuredDataMessageFnFromMnemonic, createSip10FnArgs, createSip9FnArgs, createTransferSip10TxHex, deriveStxPrivateKey, deriveStxPublicKey, ensurePostConditionWireFormat, extractStacksDerivationPathAccountIndex, formatAssetString, formatContractId, formatContractIdString, generateStacksUnsignedTransaction, getErrorMessage, getPostCondition, getPostConditionFromString, getPostConditions, getPrincipalFromAssetString, getSip10TransferAmount, getSip10TransferRecipient, getStacksAssetStringParts, getStacksBurnAddress, getStacksContractAssetName, getStacksContractName, getUnsignedContractCallParsedOptions, getUnsignedContractDeployParsedOptions, getUnsignedStxTokenTransferParsedOptions, initNonce, initalizeStacksSigner, isSip10Transfer, isTransactionTypeSupported, isValidAddressChain, isValidStacksAddress, isValidStacksMemo, isValidStacksTransaction, makeAccountIndexDerivationPathFactory, makeStxDerivationPath, principalSchema, signMessage, signStacksTransaction, signStructuredDataMessage, stacksChainIdToCoreNetworkMode, stacksRootKeychainToAccountDescriptor, standardPrincipalSchema, stxDerivationWithAccount, validatePayerNotRecipient, whenStacksChainId };
|
package/dist/index.js
CHANGED
|
@@ -207,6 +207,10 @@ function initalizeStacksSigner(args) {
|
|
|
207
207
|
};
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
+
// src/transactions/create-tx-hex.ts
|
|
211
|
+
import { bytesToHex as bytesToHex2 } from "@stacks/common";
|
|
212
|
+
import { Pc, serializeCV } from "@stacks/transactions";
|
|
213
|
+
|
|
210
214
|
// src/transactions/generate-unsigned-transaction.ts
|
|
211
215
|
import { hexToBytes as hexToBytes2 } from "@noble/hashes/utils";
|
|
212
216
|
import {
|
|
@@ -306,23 +310,25 @@ function generateStacksUnsignedTransaction(options) {
|
|
|
306
310
|
|
|
307
311
|
// src/transactions/get-contract-fn-args.ts
|
|
308
312
|
import {
|
|
313
|
+
bufferCVFromString,
|
|
309
314
|
createAddress,
|
|
310
315
|
deserializeCV as deserializeCV2,
|
|
311
316
|
noneCV,
|
|
317
|
+
someCV,
|
|
312
318
|
standardPrincipalCVFromAddress,
|
|
313
319
|
uintCV
|
|
314
320
|
} from "@stacks/transactions";
|
|
315
321
|
function createSip10FnArgs({
|
|
316
322
|
amount,
|
|
317
323
|
senderStacksAddress,
|
|
318
|
-
recipientStacksAddress
|
|
324
|
+
recipientStacksAddress,
|
|
325
|
+
memo
|
|
319
326
|
}) {
|
|
320
327
|
const fnArgs = [
|
|
321
328
|
uintCV(amount),
|
|
322
329
|
standardPrincipalCVFromAddress(createAddress(senderStacksAddress)),
|
|
323
330
|
standardPrincipalCVFromAddress(createAddress(recipientStacksAddress)),
|
|
324
|
-
noneCV()
|
|
325
|
-
// Add memo to SIP-30?
|
|
331
|
+
memo && memo !== "" ? someCV(bufferCVFromString(memo)) : noneCV()
|
|
326
332
|
];
|
|
327
333
|
return fnArgs;
|
|
328
334
|
}
|
|
@@ -339,6 +345,41 @@ function createSip9FnArgs({
|
|
|
339
345
|
return fnArgs;
|
|
340
346
|
}
|
|
341
347
|
|
|
348
|
+
// src/transactions/create-tx-hex.ts
|
|
349
|
+
async function createTransferSip10TxHex({
|
|
350
|
+
signer,
|
|
351
|
+
assetId,
|
|
352
|
+
recipient,
|
|
353
|
+
amount,
|
|
354
|
+
nonce,
|
|
355
|
+
fee,
|
|
356
|
+
memo
|
|
357
|
+
}) {
|
|
358
|
+
const { contractAddress, contractAssetName, contractName } = getStacksAssetStringParts(assetId);
|
|
359
|
+
const currentStacksAddress = signer.address;
|
|
360
|
+
const fnArgs = createSip10FnArgs({
|
|
361
|
+
amount,
|
|
362
|
+
senderStacksAddress: currentStacksAddress,
|
|
363
|
+
recipientStacksAddress: recipient,
|
|
364
|
+
memo
|
|
365
|
+
});
|
|
366
|
+
const tx = await generateStacksUnsignedTransaction({
|
|
367
|
+
txType: "contract_call" /* ContractCall */,
|
|
368
|
+
publicKey: bytesToHex2(signer.publicKey),
|
|
369
|
+
contractAddress,
|
|
370
|
+
contractName,
|
|
371
|
+
functionArgs: fnArgs.map((arg) => serializeCV(arg)),
|
|
372
|
+
functionName: "transfer",
|
|
373
|
+
nonce,
|
|
374
|
+
fee,
|
|
375
|
+
postConditions: [
|
|
376
|
+
Pc.principal(currentStacksAddress).willSendEq(amount).ft(formatContractIdString({ contractAddress, contractName }), contractAssetName)
|
|
377
|
+
]
|
|
378
|
+
});
|
|
379
|
+
const txHex = tx.serialize();
|
|
380
|
+
return txHex;
|
|
381
|
+
}
|
|
382
|
+
|
|
342
383
|
// src/transactions/get-error-message.ts
|
|
343
384
|
function getErrorMessage(reason) {
|
|
344
385
|
switch (reason) {
|
|
@@ -393,16 +434,39 @@ function getErrorMessage(reason) {
|
|
|
393
434
|
}
|
|
394
435
|
}
|
|
395
436
|
|
|
396
|
-
// src/
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
437
|
+
// src/transactions/sip-10-contract-call.utils.ts
|
|
438
|
+
import { ClarityType } from "@stacks/transactions";
|
|
439
|
+
function isSip10Transfer({
|
|
440
|
+
functionName,
|
|
441
|
+
contractInterfaceData
|
|
442
|
+
}) {
|
|
443
|
+
if (functionName !== "transfer") return false;
|
|
444
|
+
const functionInterface = contractInterfaceData?.functions.find((f) => f.name === functionName);
|
|
445
|
+
if (functionInterface?.args[0]?.name === "amount" && functionInterface?.args[1]?.name === "sender" && functionInterface?.args[2]?.name === "recipient" && functionInterface?.args[3]?.name === "memo") {
|
|
446
|
+
return true;
|
|
404
447
|
}
|
|
405
|
-
|
|
448
|
+
return false;
|
|
449
|
+
}
|
|
450
|
+
function getSip10TransferAmount({
|
|
451
|
+
functionName,
|
|
452
|
+
functionArgs,
|
|
453
|
+
contractInterfaceData
|
|
454
|
+
}) {
|
|
455
|
+
if (isSip10Transfer({ functionName, contractInterfaceData }) && functionArgs[0]?.type === ClarityType.UInt) {
|
|
456
|
+
return Number(functionArgs[0].value);
|
|
457
|
+
}
|
|
458
|
+
return null;
|
|
459
|
+
}
|
|
460
|
+
function getSip10TransferRecipient({
|
|
461
|
+
functionName,
|
|
462
|
+
functionArgs,
|
|
463
|
+
contractInterfaceData
|
|
464
|
+
}) {
|
|
465
|
+
if (isSip10Transfer({ functionName, contractInterfaceData }) && functionArgs[2]?.type === ClarityType.PrincipalStandard) {
|
|
466
|
+
return functionArgs[2].value;
|
|
467
|
+
}
|
|
468
|
+
return null;
|
|
469
|
+
}
|
|
406
470
|
|
|
407
471
|
// src/validation/address-validation.ts
|
|
408
472
|
import { c32addressDecode } from "c32check";
|
|
@@ -471,6 +535,17 @@ function isValidStacksMemo(memo) {
|
|
|
471
535
|
return !exceedsMaxLengthBytes(memo, MEMO_MAX_LENGTH_BYTES);
|
|
472
536
|
}
|
|
473
537
|
|
|
538
|
+
// src/validation/stacks-error.ts
|
|
539
|
+
var StacksError = class extends Error {
|
|
540
|
+
message;
|
|
541
|
+
constructor(message) {
|
|
542
|
+
super(message);
|
|
543
|
+
this.name = "StacksError";
|
|
544
|
+
this.message = message;
|
|
545
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
|
|
474
549
|
// src/validation/amount-validation.ts
|
|
475
550
|
import BigNumber2 from "bignumber.js";
|
|
476
551
|
import { isDefined, stxToMicroStx } from "@leather.io/utils";
|
|
@@ -548,6 +623,7 @@ export {
|
|
|
548
623
|
createSignStructuredDataMessageFnFromMnemonic,
|
|
549
624
|
createSip10FnArgs,
|
|
550
625
|
createSip9FnArgs,
|
|
626
|
+
createTransferSip10TxHex,
|
|
551
627
|
deriveStxPrivateKey,
|
|
552
628
|
deriveStxPublicKey,
|
|
553
629
|
ensurePostConditionWireFormat,
|
|
@@ -561,6 +637,8 @@ export {
|
|
|
561
637
|
getPostConditionFromString,
|
|
562
638
|
getPostConditions,
|
|
563
639
|
getPrincipalFromAssetString,
|
|
640
|
+
getSip10TransferAmount,
|
|
641
|
+
getSip10TransferRecipient,
|
|
564
642
|
getStacksAssetStringParts,
|
|
565
643
|
getStacksBurnAddress,
|
|
566
644
|
getStacksContractAssetName,
|
|
@@ -570,6 +648,7 @@ export {
|
|
|
570
648
|
getUnsignedStxTokenTransferParsedOptions,
|
|
571
649
|
initNonce,
|
|
572
650
|
initalizeStacksSigner,
|
|
651
|
+
isSip10Transfer,
|
|
573
652
|
isTransactionTypeSupported,
|
|
574
653
|
isValidAddressChain,
|
|
575
654
|
isValidStacksAddress,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/message-signing.ts","../src/mocks/mocks.ts","../src/signer/signer.ts","../src/stacks.utils.ts","../src/transactions/generate-unsigned-transaction.ts","../src/transactions/post-condition.utils.ts","../src/transactions/transaction.types.ts","../src/transactions/get-contract-fn-args.ts","../src/transactions/get-error-message.ts","../src/validation/stacks-error.ts","../src/validation/address-validation.ts","../src/validation/memo-validation.ts","../src/validation/amount-validation.ts","../src/validation/transaction-validation.ts"],"sourcesContent":["import { bytesToHex } from '@noble/hashes/utils';\nimport { PrivateKey } from '@stacks/common';\nimport { hashMessage } from '@stacks/encryption';\nimport {\n ClarityValue,\n privateKeyToPublic,\n signMessageHashRsv,\n signStructuredData,\n} from '@stacks/transactions';\n\nexport interface SignatureData {\n signature: string;\n publicKey: string;\n}\nexport function signMessage(message: string, privateKey: PrivateKey): SignatureData {\n const hash = hashMessage(message);\n return {\n signature: signMessageHashRsv({ privateKey, messageHash: bytesToHex(hash) }),\n publicKey: privateKeyToPublic(privateKey) as string,\n };\n}\n\nexport function signStructuredDataMessage(\n message: ClarityValue,\n domain: ClarityValue,\n privateKey: PrivateKey\n): SignatureData {\n const signature = signStructuredData({\n message,\n domain,\n privateKey,\n });\n\n return {\n signature,\n publicKey: privateKeyToPublic(privateKey) as string,\n };\n}\n","// Stacks test addresses\nexport const TEST_ACCOUNT_1_STX_ADDRESS = 'SPS8CKF63P16J28AYF7PXW9E5AACH0NZNTEFWSFE';\nexport const TEST_ACCOUNT_2_STX_ADDRESS = 'SPXH3HNBPM5YP15VH16ZXZ9AX6CK289K3MCXRKCB';\nexport const TEST_TESTNET_ACCOUNT_2_STX_ADDRESS = 'STXH3HNBPM5YP15VH16ZXZ9AX6CK289K3NVR9T1P';\n// TODO ask about these prefixs\n// TEST_ACCOUNT_.. from extension mocks with prefix changed to SM / SN\nexport const TEST_ACCOUNT_1_STX_ADDRESS_SM = 'SM3FBR6RDNZYC5K4TZWV9VZJ6NGA4VX3YBQ8X2PQ';\nexport const TEST_TESTNET_ACCOUNT_2_STX_ADDRESS_SN = 'SNXH3HNBPM5YP15VH16ZXZ9AX6CK289K3NVR9T1P';\n","import {\n ClarityValue,\n StacksTransactionWire,\n TransactionSigner,\n createStacksPublicKey,\n publicKeyToAddressSingleSig,\n} from '@stacks/transactions';\n\nimport {\n Signer,\n decomposeDescriptor,\n deriveRootKeychainFromMnemonic,\n extractKeyFromDescriptor,\n} from '@leather.io/crypto';\nimport { NetworkModes } from '@leather.io/models';\n\nimport { SignatureData, signMessage, signStructuredDataMessage } from '../message-signing';\nimport { deriveStxPrivateKey, extractStacksDerivationPathAccountIndex } from '../stacks.utils';\n\n// Warning: mutative. Ideally there would be a tx.clone() method\nexport function signStacksTransaction(tx: StacksTransactionWire, privateKey: string) {\n const signer = new TransactionSigner(tx);\n signer.signOrigin(privateKey);\n return tx;\n}\n\nexport type StacksSignerFn = (tx: StacksTransactionWire) => Promise<StacksTransactionWire>;\nexport type StacksSignMessageFn = (message: string) => Promise<SignatureData>;\nexport type StacksSignStructuredMessageFn = (\n message: ClarityValue,\n domain: ClarityValue\n) => Promise<SignatureData>;\n\nexport interface StacksSigner extends Signer {\n descriptor: string;\n keyOrigin: string;\n address: string;\n accountIndex: number;\n network: NetworkModes;\n sign: StacksSignerFn;\n signMessage: StacksSignMessageFn;\n signStructuredMessage: StacksSignStructuredMessageFn;\n}\n\nasync function getPrivateKey(\n keyOrigin: string,\n getMnemonicFn: () => Promise<{ mnemonic: string; passphrase?: string }>\n) {\n const { mnemonic, passphrase } = await getMnemonicFn();\n const keychain = await deriveRootKeychainFromMnemonic(mnemonic, passphrase);\n return deriveStxPrivateKey({\n keychain,\n index: extractStacksDerivationPathAccountIndex(keyOrigin),\n });\n}\n\nexport function createSignFnFromMnemonic(\n keyOrigin: string,\n getMnemonicFn: () => Promise<{ mnemonic: string; passphrase?: string }>\n) {\n return async (tx: StacksTransactionWire) => {\n const privateKey = await getPrivateKey(keyOrigin, getMnemonicFn);\n return signStacksTransaction(tx, privateKey);\n };\n}\n\nexport function createSignMessageFnFromMnemonic(\n keyOrigin: string,\n getMnemonicFn: () => Promise<{ mnemonic: string; passphrase?: string }>\n) {\n return async (message: string) => {\n const privateKey = await getPrivateKey(keyOrigin, getMnemonicFn);\n return signMessage(message, privateKey);\n };\n}\nexport function createSignStructuredDataMessageFnFromMnemonic(\n keyOrigin: string,\n getMnemonicFn: () => Promise<{ mnemonic: string; passphrase?: string }>\n) {\n return async (message: ClarityValue, domain: ClarityValue) => {\n const privateKey = await getPrivateKey(keyOrigin, getMnemonicFn);\n return signStructuredDataMessage(message, domain, privateKey);\n };\n}\n\ninterface InitalizeStacksSignerArgs {\n descriptor: string;\n network: NetworkModes;\n signFn: StacksSignerFn;\n signMessageFn: StacksSignMessageFn;\n signStructuredMessageFn: StacksSignStructuredMessageFn;\n}\nexport function initalizeStacksSigner(args: InitalizeStacksSignerArgs): StacksSigner {\n const { descriptor, network, signFn, signMessageFn, signStructuredMessageFn } = args;\n\n const publicKey = createStacksPublicKey(extractKeyFromDescriptor(descriptor)).data;\n\n return {\n ...decomposeDescriptor(descriptor),\n // here we overwrite the accountIndex with the derivation path account index for stx\n accountIndex: extractStacksDerivationPathAccountIndex(descriptor),\n publicKey: publicKey,\n network,\n address: publicKeyToAddressSingleSig(publicKey, network),\n sign: signFn,\n signMessage: signMessageFn,\n signStructuredMessage: signStructuredMessageFn,\n };\n}\n","import { HDKey } from '@scure/bip32';\nimport { ChainId } from '@stacks/network';\nimport {\n AssetString,\n ContractIdString,\n compressPrivateKey,\n privateKeyToPublic,\n} from '@stacks/transactions';\n\nimport {\n DerivationPathDepth,\n createDescriptor,\n createKeyOriginPath,\n extractAddressIndexFromPath,\n} from '@leather.io/crypto';\nimport type { NetworkModes } from '@leather.io/models';\nimport { assertIsTruthy, isString, toHexString } from '@leather.io/utils';\n\nexport const stxDerivationWithAccount = `m/44'/5757'/0'/0/{account}`;\n\nexport function makeAccountIndexDerivationPathFactory(derivationPath: string) {\n return (account: number) => derivationPath.replace('{account}', account.toString());\n}\n\nexport function extractStacksDerivationPathAccountIndex(path: string) {\n if (!path.includes('5757')) throw new Error('Not a valid Stacks derivation path: ' + path);\n return extractAddressIndexFromPath(path);\n}\n\n/**\n * Stacks accounts always use the same derivation path, regardless of network\n */\nexport const makeStxDerivationPath =\n makeAccountIndexDerivationPathFactory(stxDerivationWithAccount);\n\nexport function stacksChainIdToCoreNetworkMode(chainId: ChainId): NetworkModes {\n return whenStacksChainId(chainId)({\n [ChainId.Mainnet]: 'mainnet',\n [ChainId.Testnet]: 'testnet',\n });\n}\n\ninterface WhenStacksChainIdMap<T> {\n [ChainId.Mainnet]: T;\n [ChainId.Testnet]: T;\n}\nexport function whenStacksChainId(chainId: ChainId) {\n return <T>(chainIdMap: WhenStacksChainIdMap<T>): T => chainIdMap[chainId];\n}\n\n// From `@stacks/wallet-sdk` package we are trying not to use\nexport function deriveStxPrivateKey({ keychain, index }: { keychain: HDKey; index: number }) {\n if (keychain.depth !== DerivationPathDepth.Root) throw new Error('Root keychain must be depth 0');\n const accountKeychain = keychain.derive(makeStxDerivationPath(index));\n assertIsTruthy(accountKeychain.privateKey);\n return compressPrivateKey(accountKeychain.privateKey);\n}\n\nexport function deriveStxPublicKey({\n keychain,\n index,\n}: {\n keychain: HDKey;\n index: number;\n}): string {\n return privateKeyToPublic(deriveStxPrivateKey({ keychain, index })) as string;\n}\n\nexport function stacksRootKeychainToAccountDescriptor(keychain: HDKey, accountIndex: number) {\n const fingerprint = toHexString(keychain.fingerprint);\n const publicKey = deriveStxPublicKey({ keychain, index: accountIndex });\n return createDescriptor(\n createKeyOriginPath(fingerprint, makeStxDerivationPath(accountIndex)),\n publicKey\n );\n}\n\nexport function getStacksBurnAddress(chainIdChainId: ChainId): string {\n switch (chainIdChainId) {\n case ChainId.Mainnet:\n return 'SP00000000000003SCNSJTCSE62ZF4MSE';\n case ChainId.Testnet:\n default:\n return 'ST000000000000000000002AMW42H';\n }\n}\n\nexport function cleanHex(hexWithMaybePrefix: string): string {\n if (!isString(hexWithMaybePrefix)) return hexWithMaybePrefix;\n return hexWithMaybePrefix.startsWith('0x')\n ? hexWithMaybePrefix.replace('0x', '')\n : hexWithMaybePrefix;\n}\n\nexport function getPrincipalFromAssetString(assetString: string) {\n return assetString.split('::')[0];\n}\n\nexport function formatContractId(address: string, name: string) {\n return `${address}.${name}`;\n}\n\ninterface FormatAssetStringArgs {\n contractAddress: string;\n contractName: string;\n assetName: string;\n}\nexport function formatAssetString({\n contractAddress,\n contractName,\n assetName,\n}: FormatAssetStringArgs): AssetString {\n return `${contractAddress}.${contractName}::${assetName}`;\n}\n\ninterface FormatContractIdStringArgs {\n contractAddress: string;\n contractName: string;\n}\nexport function formatContractIdString({\n contractAddress,\n contractName,\n}: FormatContractIdStringArgs): ContractIdString {\n return `${contractAddress}.${contractName}`;\n}\n\n/**\n * Gets the contract name.\n *\n * @param identifier - [principal].[contract-name] or [principal].[contract-name]::[asset-name]\n */\nexport function getStacksContractName(identifier: string): string {\n if (identifier.includes('.')) {\n const parts = identifier?.split('.');\n if (identifier.includes('::')) {\n return parts[1].split('::')[0];\n }\n return parts[1];\n }\n return identifier;\n}\n\n/**\n * Gets the asset name.\n *\n * @param identifier - [principal].[contract-name]::[asset-name]\n */\nexport function getStacksContractAssetName(identifier: string): string {\n if (!identifier.includes('::')) return identifier;\n return identifier.split('::')[1];\n}\n\n/**\n * Gets the parts that make up a fully qualified name of an asset.\n *\n * @param identifier - [principal].[contract-name]::[asset-name]\n */\nexport function getStacksAssetStringParts(identifier: string): {\n contractAddress: string;\n contractAssetName: string;\n contractName: string;\n} {\n if (!identifier.includes('.') && !identifier.includes('::')) {\n return {\n contractAddress: identifier,\n contractAssetName: identifier,\n contractName: identifier,\n };\n }\n\n const contractAddress = identifier.split('.')[0];\n const contractAssetName = getStacksContractAssetName(identifier);\n const contractName = getStacksContractName(identifier);\n\n return {\n contractAddress,\n contractAssetName,\n contractName,\n };\n}\n","import { hexToBytes } from '@noble/hashes/utils';\nimport {\n deserializeCV,\n makeUnsignedContractCall,\n makeUnsignedContractDeploy,\n makeUnsignedSTXTokenTransfer,\n} from '@stacks/transactions';\nimport BigNumber from 'bignumber.js';\n\nimport { assertUnreachable } from '@leather.io/utils';\n\nimport { cleanHex } from '../stacks.utils';\nimport { ensurePostConditionWireFormat, getPostConditions } from './post-condition.utils';\nimport {\n StacksUnsignedContractCallOptions,\n StacksUnsignedContractDeployOptions,\n StacksUnsignedTokenTransferOptions,\n StacksUnsignedTransactionOptions,\n TransactionTypes,\n isTransactionTypeSupported,\n} from './transaction.types';\n\nexport function initNonce(nonce: number | string) {\n return new BigNumber(nonce, 10);\n}\n\nexport function getUnsignedContractCallParsedOptions(options: StacksUnsignedContractCallOptions) {\n return {\n ...options,\n fee: options.fee.amount.toString(),\n functionArgs: options.functionArgs.map(arg => deserializeCV(hexToBytes(cleanHex(arg)))),\n nonce: initNonce(options.nonce).toString(),\n postConditions: options.postConditions,\n };\n}\n\nexport function getUnsignedContractDeployParsedOptions(\n options: StacksUnsignedContractDeployOptions\n) {\n return {\n ...options,\n fee: options.fee.amount.toString(),\n nonce: initNonce(options.nonce).toString(),\n postConditions: getPostConditions(\n options.postConditions?.map(pc => ensurePostConditionWireFormat(pc))\n ),\n };\n}\n\nexport function getUnsignedStxTokenTransferParsedOptions(\n options: StacksUnsignedTokenTransferOptions\n) {\n return {\n ...options,\n amount: options.amount.amount.toString(),\n fee: options.fee.amount.toString(),\n nonce: initNonce(options.nonce).toString(),\n };\n}\n\nexport function generateStacksUnsignedTransaction(options: StacksUnsignedTransactionOptions) {\n const { txType } = options;\n\n const isValid = isTransactionTypeSupported(txType);\n\n if (!isValid) throw new Error(`Invalid Transaction Type: ${txType}`);\n\n switch (txType) {\n case TransactionTypes.StxTokenTransfer:\n return makeUnsignedSTXTokenTransfer(getUnsignedStxTokenTransferParsedOptions(options));\n case TransactionTypes.ContractCall:\n return makeUnsignedContractCall(getUnsignedContractCallParsedOptions(options));\n case TransactionTypes.ContractDeploy:\n return makeUnsignedContractDeploy(getUnsignedContractDeployParsedOptions(options));\n default:\n assertUnreachable(txType);\n }\n}\n","import { hexToBytes } from '@noble/hashes/utils';\nimport {\n BytesReader,\n PostCondition,\n PostConditionWire,\n deserializePostConditionWire,\n postConditionToWire,\n} from '@stacks/transactions';\n\nimport { isString } from '@leather.io/utils';\n\nexport function getPostConditionFromString(postCondition: string): PostConditionWire {\n try {\n const reader = new BytesReader(hexToBytes(postCondition));\n return deserializePostConditionWire(reader);\n } catch {\n throw new Error('Not a serialized post condition');\n }\n}\n\nexport function ensurePostConditionWireFormat(\n postCondition: string | PostCondition | PostConditionWire\n) {\n if (isString(postCondition)) return getPostConditionFromString(postCondition);\n if ('conditionType' in postCondition) return postCondition;\n return postConditionToWire(postCondition);\n}\n\nexport function getPostCondition(\n postCondition: string | PostCondition | PostConditionWire\n): PostConditionWire {\n return isString(postCondition)\n ? getPostConditionFromString(postCondition)\n : ensurePostConditionWireFormat(postCondition);\n}\n\nexport function getPostConditions(\n postConditions?: (string | PostCondition | PostConditionWire)[]\n): PostConditionWire[] | undefined {\n return postConditions?.map(getPostCondition);\n}\n","import {\n UnsignedContractCallOptions,\n UnsignedContractDeployOptions,\n UnsignedTokenTransferOptions,\n} from '@stacks/transactions';\n\nimport { Money, ReplaceTypes } from '@leather.io/models';\n\nexport enum TransactionTypes {\n ContractCall = 'contract_call',\n ContractDeploy = 'smart_contract',\n StxTokenTransfer = 'token_transfer',\n}\n\nexport function isTransactionTypeSupported(txType: TransactionTypes) {\n return (\n txType === TransactionTypes.ContractCall ||\n txType === TransactionTypes.ContractDeploy ||\n txType === TransactionTypes.StxTokenTransfer\n );\n}\n\nexport type StacksUnsignedContractCallOptions = ReplaceTypes<\n UnsignedContractCallOptions,\n {\n fee: Money;\n functionArgs: string[];\n nonce: number | string;\n }\n> & { txType: TransactionTypes.ContractCall };\n\nexport type StacksUnsignedContractDeployOptions = ReplaceTypes<\n UnsignedContractDeployOptions,\n {\n fee: Money;\n nonce: number | string;\n }\n> & { txType: TransactionTypes.ContractDeploy };\n\nexport type StacksUnsignedTokenTransferOptions = ReplaceTypes<\n UnsignedTokenTransferOptions,\n {\n amount: Money;\n fee: Money;\n nonce: number | string;\n }\n> & { txType: TransactionTypes.StxTokenTransfer };\n\nexport type StacksUnsignedTransactionOptions =\n | StacksUnsignedContractCallOptions\n | StacksUnsignedContractDeployOptions\n | StacksUnsignedTokenTransferOptions;\n","import {\n ClarityValue,\n createAddress,\n deserializeCV,\n noneCV,\n standardPrincipalCVFromAddress,\n uintCV,\n} from '@stacks/transactions';\n\ninterface GetSip10FnArgs {\n amount: number;\n senderStacksAddress: string;\n recipientStacksAddress: string;\n}\n\nexport function createSip10FnArgs({\n amount,\n senderStacksAddress,\n recipientStacksAddress,\n}: GetSip10FnArgs) {\n const fnArgs: ClarityValue[] = [\n uintCV(amount),\n standardPrincipalCVFromAddress(createAddress(senderStacksAddress)),\n standardPrincipalCVFromAddress(createAddress(recipientStacksAddress)),\n noneCV(), // Add memo to SIP-30?\n ];\n return fnArgs;\n}\n\ninterface GetSip9FnArgs {\n assetId: string;\n senderStacksAddress: string;\n recipientStacksAddress: string;\n}\nexport function createSip9FnArgs({\n assetId,\n senderStacksAddress,\n recipientStacksAddress,\n}: GetSip9FnArgs) {\n const fnArgs: ClarityValue[] = [\n deserializeCV(assetId),\n standardPrincipalCVFromAddress(createAddress(senderStacksAddress)),\n standardPrincipalCVFromAddress(createAddress(recipientStacksAddress)),\n ];\n return fnArgs;\n}\n","import { TxBroadcastResultRejected } from '@stacks/transactions';\n\nexport function getErrorMessage(\n reason:\n | TxBroadcastResultRejected['reason']\n | 'BadTransactionVersion'\n | 'ConflictingNonceInMempool'\n | 'EstimatorError'\n | 'TransferAmountMustBePositive'\n | 'TransferRecipientCannotEqualSender'\n) {\n switch (reason) {\n case 'BadAddressVersionByte':\n return 'Incorrect address';\n case 'BadFunctionArgument':\n return 'Incorrect function argument';\n case 'BadNonce':\n return 'Incorrect nonce';\n case 'BadTransactionVersion':\n return 'Incorrect transaction';\n case 'ConflictingNonceInMempool':\n return 'Nonce conflict';\n case 'ContractAlreadyExists':\n return 'Contract already exists';\n case 'Deserialization':\n return 'Deserialization failure';\n case 'EstimatorError':\n return 'Estimator error';\n case 'FeeTooLow':\n return 'Fee too low';\n case 'NoCoinbaseViaMempool':\n return 'No coinbase via mempool';\n case 'NoSuchContract':\n return 'Contract does not exist';\n case 'NoSuchPublicFunction':\n return 'Function does not exist';\n case 'NotEnoughFunds':\n return 'Not enough funds';\n case 'PoisonMicroblocksDoNotConflict':\n return 'Microblock conflict';\n case 'PoisonMicroblockHasUnknownPubKeyHash':\n return 'No anchor block with public key hash';\n case 'PoisonMicroblockIsInvalid':\n return 'Invalid microblock';\n case 'Serialization':\n return 'Serialization failure';\n case 'ServerFailureDatabase':\n return 'Database error';\n case 'ServerFailureNoSuchChainTip':\n return 'No such chain tip';\n case 'ServerFailureOther':\n return 'Server failure';\n case 'SignatureValidation':\n return 'Failed to validate signature';\n case 'TransferAmountMustBePositive':\n return 'Transfer amount must be positive';\n case 'TransferRecipientCannotEqualSender':\n return 'Cannot transfer STX to yourself';\n default:\n return 'Something went wrong';\n }\n}\n","import { TransactionErrorKey } from '@leather.io/models';\n\nexport type StacksErrorKey =\n | TransactionErrorKey\n | 'InvalidSameAddress'\n | 'UnknownBalance'\n | 'UnknownFee'\n | 'UnknownAmount';\n\nexport class StacksError extends Error {\n public message: StacksErrorKey;\n constructor(message: StacksErrorKey) {\n super(message);\n this.name = 'StacksError';\n this.message = message;\n\n // Fix the prototype chain\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","import { c32addressDecode } from 'c32check';\nimport { z } from 'zod';\n\nimport { ChainId } from '@leather.io/models';\nimport { isEmptyString, isString, isUndefined } from '@leather.io/utils';\n\n// taken from stacks-utils.ts\nexport function isValidStacksAddress(address: string) {\n if (isUndefined(address) || isEmptyString(address)) {\n return false;\n }\n try {\n c32addressDecode(address);\n return true;\n } catch {\n return false;\n }\n}\n\nexport function isValidAddressChain(address: string, chainId: ChainId) {\n if (!address) {\n return false;\n }\n\n const prefix = address.slice(0, 2);\n switch (chainId) {\n case ChainId.Mainnet:\n return prefix === 'SM' || prefix === 'SP';\n case ChainId.Testnet:\n return prefix === 'SN' || prefix === 'ST';\n default:\n return false;\n }\n}\n\nexport function validatePayerNotRecipient(senderAddress: string, recipientAddress: string) {\n if (!senderAddress || !recipientAddress) {\n return false;\n }\n\n return senderAddress !== recipientAddress;\n}\n\nexport const standardPrincipalSchema = z.string().refine(\n (address: unknown) => {\n if (!isString(address)) return false;\n if (!isValidStacksAddress(address)) return false;\n return !address.includes('.');\n },\n { message: 'Invalid standard Stacks principal address' }\n);\n\nexport const contractPrincipalSchema = z.string().refine(\n (principal: unknown) => {\n if (!isString(principal)) return false;\n\n const parts = principal.split('.');\n if (parts.length !== 2) return false;\n\n const [address, contractName] = parts;\n\n if (!isValidStacksAddress(address)) return false;\n\n const contractNameRegex = /^[a-zA-Z0-9_-]{1,128}$/;\n return contractNameRegex.test(contractName);\n },\n { message: 'Invalid contract principal (must be address.contract-name format)' }\n);\n\nexport const principalSchema = z.union([standardPrincipalSchema, contractPrincipalSchema]);\n","import { MEMO_MAX_LENGTH_BYTES } from '@stacks/transactions';\n\nfunction exceedsMaxLengthBytes(value: string, maxLengthBytes: number): boolean {\n return value ? Buffer.from(value).length > maxLengthBytes : false;\n}\n\nexport function isValidStacksMemo(memo: string) {\n return !exceedsMaxLengthBytes(memo, MEMO_MAX_LENGTH_BYTES);\n}\n","import BigNumber from 'bignumber.js';\n\nimport { Money } from '@leather.io/models';\nimport { isDefined, stxToMicroStx } from '@leather.io/utils';\n\nimport { StacksError } from './stacks-error';\n\nfunction isMoneyAmountValid(amount: Money) {\n return amount && isDefined(amount.amount) && amount.amount;\n}\n\ninterface IsStxAmountValidArgs {\n availableBalance: Money;\n amount: Money;\n fee: Money;\n}\n\nexport function isStxAmountValid({ availableBalance, amount, fee }: IsStxAmountValidArgs) {\n if (!isMoneyAmountValid(amount)) {\n throw new StacksError('InvalidAmount');\n }\n if (!isMoneyAmountValid(availableBalance)) {\n throw new StacksError('UnknownBalance');\n }\n if (!isMoneyAmountValid(fee)) {\n throw new StacksError('UnknownFee');\n }\n return true;\n}\n\nexport function isStxBalanceSufficient({\n availableBalance: { amount: availableBalanceAmount },\n amount: { amount: desiredSpend },\n fee: { amount: feeAmount },\n}: IsStxAmountValidArgs) {\n const fee = new BigNumber(stxToMicroStx(feeAmount));\n\n if (!availableBalanceAmount) {\n throw new StacksError('UnknownBalance');\n }\n if (!fee.isFinite()) {\n throw new StacksError('UnknownFee');\n }\n\n const availableBalance = new BigNumber(stxToMicroStx(availableBalanceAmount));\n const spendableAmount = availableBalance.minus(fee);\n const amount = new BigNumber(stxToMicroStx(desiredSpend));\n return spendableAmount.isGreaterThanOrEqualTo(amount);\n}\n","import { ChainId, Money } from '@leather.io/models';\n\nimport {\n isValidAddressChain,\n isValidStacksAddress,\n validatePayerNotRecipient,\n} from './address-validation';\nimport { isStxAmountValid, isStxBalanceSufficient } from './amount-validation';\nimport { StacksError } from './stacks-error';\n\ninterface StacksTransaction {\n amount: Money;\n payer: string;\n recipient: string;\n chainId: ChainId;\n availableBalance: Money;\n fee: Money;\n}\n\nexport function isValidStacksTransaction({\n amount,\n availableBalance,\n fee,\n payer,\n recipient,\n chainId,\n}: StacksTransaction) {\n if (!isValidStacksAddress(payer) || !isValidStacksAddress(recipient)) {\n throw new StacksError('InvalidAddress');\n }\n if (!isValidAddressChain(payer, chainId) || !isValidAddressChain(recipient, chainId)) {\n throw new StacksError('InvalidNetworkAddress');\n }\n if (!validatePayerNotRecipient(payer, recipient)) {\n throw new StacksError('InvalidSameAddress');\n }\n\n if (!isStxAmountValid({ availableBalance, amount, fee })) {\n throw new StacksError('InvalidAmount');\n }\n if (!isStxBalanceSufficient({ availableBalance, amount, fee })) {\n throw new StacksError('InsufficientFunds');\n }\n return true;\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;AAE3B,SAAS,mBAAmB;AAC5B;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAMA,SAAS,YAAY,SAAiB,YAAuC;AAClF,QAAM,OAAO,YAAY,OAAO;AAChC,SAAO;AAAA,IACL,WAAW,mBAAmB,EAAE,YAAY,aAAa,WAAW,IAAI,EAAE,CAAC;AAAA,IAC3E,WAAW,mBAAmB,UAAU;AAAA,EAC1C;AACF;AAEO,SAAS,0BACd,SACA,QACA,YACe;AACf,QAAM,YAAY,mBAAmB;AAAA,IACnC;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,SAAO;AAAA,IACL;AAAA,IACA,WAAW,mBAAmB,UAAU;AAAA,EAC1C;AACF;;;ACpCO,IAAM,6BAA6B;AACnC,IAAM,6BAA6B;AACnC,IAAM,qCAAqC;AAG3C,IAAM,gCAAgC;AACtC,IAAM,wCAAwC;;;ACPrD;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACZP,SAAS,eAAe;AACxB;AAAA,EAGE;AA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AAIA,WAAU,cAAc,YAAY,CAAC;AACxD,SAAO,gBAAgB,uBAAuB,MAAM;AACtD;;;AC7BO,SAAS,yBAAyB;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAsB;AACpB,MAAI,CAAC,qBAAqB,KAAK,KAAK,CAAC,qBAAqB,SAAS,GAAG;AACpE,UAAM,IAAI,YAAY,gBAAgB;AAAA,EACxC;AACA,MAAI,CAAC,oBAAoB,OAAO,OAAO,KAAK,CAAC,oBAAoB,WAAW,OAAO,GAAG;AACpF,UAAM,IAAI,YAAY,uBAAuB;AAAA,EAC/C;AACA,MAAI,CAAC,0BAA0B,OAAO,SAAS,GAAG;AAChD,UAAM,IAAI,YAAY,oBAAoB;AAAA,EAC5C;AAEA,MAAI,CAAC,iBAAiB,EAAE,kBAAkB,QAAQ,IAAI,CAAC,GAAG;AACxD,UAAM,IAAI,YAAY,eAAe;AAAA,EACvC;AACA,MAAI,CAAC,uBAAuB,EAAE,kBAAkB,QAAQ,IAAI,CAAC,GAAG;AAC9D,UAAM,IAAI,YAAY,mBAAmB;AAAA,EAC3C;AACA,SAAO;AACT;","names":["privateKeyToPublic","hexToBytes","isString","TransactionTypes","hexToBytes","deserializeCV","ChainId","isString","BigNumber","BigNumber"]}
|
|
1
|
+
{"version":3,"sources":["../src/message-signing.ts","../src/mocks/mocks.ts","../src/signer/signer.ts","../src/stacks.utils.ts","../src/transactions/create-tx-hex.ts","../src/transactions/generate-unsigned-transaction.ts","../src/transactions/post-condition.utils.ts","../src/transactions/transaction.types.ts","../src/transactions/get-contract-fn-args.ts","../src/transactions/get-error-message.ts","../src/transactions/sip-10-contract-call.utils.ts","../src/validation/address-validation.ts","../src/validation/memo-validation.ts","../src/validation/stacks-error.ts","../src/validation/amount-validation.ts","../src/validation/transaction-validation.ts"],"sourcesContent":["import { bytesToHex } from '@noble/hashes/utils';\nimport { PrivateKey } from '@stacks/common';\nimport { hashMessage } from '@stacks/encryption';\nimport {\n ClarityValue,\n privateKeyToPublic,\n signMessageHashRsv,\n signStructuredData,\n} from '@stacks/transactions';\n\nexport interface SignatureData {\n signature: string;\n publicKey: string;\n}\nexport function signMessage(message: string, privateKey: PrivateKey): SignatureData {\n const hash = hashMessage(message);\n return {\n signature: signMessageHashRsv({ privateKey, messageHash: bytesToHex(hash) }),\n publicKey: privateKeyToPublic(privateKey) as string,\n };\n}\n\nexport function signStructuredDataMessage(\n message: ClarityValue,\n domain: ClarityValue,\n privateKey: PrivateKey\n): SignatureData {\n const signature = signStructuredData({\n message,\n domain,\n privateKey,\n });\n\n return {\n signature,\n publicKey: privateKeyToPublic(privateKey) as string,\n };\n}\n","// Stacks test addresses\nexport const TEST_ACCOUNT_1_STX_ADDRESS = 'SPS8CKF63P16J28AYF7PXW9E5AACH0NZNTEFWSFE';\nexport const TEST_ACCOUNT_2_STX_ADDRESS = 'SPXH3HNBPM5YP15VH16ZXZ9AX6CK289K3MCXRKCB';\nexport const TEST_TESTNET_ACCOUNT_2_STX_ADDRESS = 'STXH3HNBPM5YP15VH16ZXZ9AX6CK289K3NVR9T1P';\n// TODO ask about these prefixs\n// TEST_ACCOUNT_.. from extension mocks with prefix changed to SM / SN\nexport const TEST_ACCOUNT_1_STX_ADDRESS_SM = 'SM3FBR6RDNZYC5K4TZWV9VZJ6NGA4VX3YBQ8X2PQ';\nexport const TEST_TESTNET_ACCOUNT_2_STX_ADDRESS_SN = 'SNXH3HNBPM5YP15VH16ZXZ9AX6CK289K3NVR9T1P';\n","import {\n ClarityValue,\n StacksTransactionWire,\n TransactionSigner,\n createStacksPublicKey,\n publicKeyToAddressSingleSig,\n} from '@stacks/transactions';\n\nimport {\n Signer,\n decomposeDescriptor,\n deriveRootKeychainFromMnemonic,\n extractKeyFromDescriptor,\n} from '@leather.io/crypto';\nimport { NetworkModes } from '@leather.io/models';\n\nimport { SignatureData, signMessage, signStructuredDataMessage } from '../message-signing';\nimport { deriveStxPrivateKey, extractStacksDerivationPathAccountIndex } from '../stacks.utils';\n\n// Warning: mutative. Ideally there would be a tx.clone() method\nexport function signStacksTransaction(tx: StacksTransactionWire, privateKey: string) {\n const signer = new TransactionSigner(tx);\n signer.signOrigin(privateKey);\n return tx;\n}\n\nexport type StacksSignerFn = (tx: StacksTransactionWire) => Promise<StacksTransactionWire>;\nexport type StacksSignMessageFn = (message: string) => Promise<SignatureData>;\nexport type StacksSignStructuredMessageFn = (\n message: ClarityValue,\n domain: ClarityValue\n) => Promise<SignatureData>;\n\nexport interface StacksSigner extends Signer {\n descriptor: string;\n keyOrigin: string;\n address: string;\n accountIndex: number;\n network: NetworkModes;\n sign: StacksSignerFn;\n signMessage: StacksSignMessageFn;\n signStructuredMessage: StacksSignStructuredMessageFn;\n}\n\nasync function getPrivateKey(\n keyOrigin: string,\n getMnemonicFn: () => Promise<{ mnemonic: string; passphrase?: string }>\n) {\n const { mnemonic, passphrase } = await getMnemonicFn();\n const keychain = await deriveRootKeychainFromMnemonic(mnemonic, passphrase);\n return deriveStxPrivateKey({\n keychain,\n index: extractStacksDerivationPathAccountIndex(keyOrigin),\n });\n}\n\nexport function createSignFnFromMnemonic(\n keyOrigin: string,\n getMnemonicFn: () => Promise<{ mnemonic: string; passphrase?: string }>\n) {\n return async (tx: StacksTransactionWire) => {\n const privateKey = await getPrivateKey(keyOrigin, getMnemonicFn);\n return signStacksTransaction(tx, privateKey);\n };\n}\n\nexport function createSignMessageFnFromMnemonic(\n keyOrigin: string,\n getMnemonicFn: () => Promise<{ mnemonic: string; passphrase?: string }>\n) {\n return async (message: string) => {\n const privateKey = await getPrivateKey(keyOrigin, getMnemonicFn);\n return signMessage(message, privateKey);\n };\n}\nexport function createSignStructuredDataMessageFnFromMnemonic(\n keyOrigin: string,\n getMnemonicFn: () => Promise<{ mnemonic: string; passphrase?: string }>\n) {\n return async (message: ClarityValue, domain: ClarityValue) => {\n const privateKey = await getPrivateKey(keyOrigin, getMnemonicFn);\n return signStructuredDataMessage(message, domain, privateKey);\n };\n}\n\ninterface InitalizeStacksSignerArgs {\n descriptor: string;\n network: NetworkModes;\n signFn: StacksSignerFn;\n signMessageFn: StacksSignMessageFn;\n signStructuredMessageFn: StacksSignStructuredMessageFn;\n}\nexport function initalizeStacksSigner(args: InitalizeStacksSignerArgs): StacksSigner {\n const { descriptor, network, signFn, signMessageFn, signStructuredMessageFn } = args;\n\n const publicKey = createStacksPublicKey(extractKeyFromDescriptor(descriptor)).data;\n\n return {\n ...decomposeDescriptor(descriptor),\n // here we overwrite the accountIndex with the derivation path account index for stx\n accountIndex: extractStacksDerivationPathAccountIndex(descriptor),\n publicKey: publicKey,\n network,\n address: publicKeyToAddressSingleSig(publicKey, network),\n sign: signFn,\n signMessage: signMessageFn,\n signStructuredMessage: signStructuredMessageFn,\n };\n}\n","import { HDKey } from '@scure/bip32';\nimport { ChainId } from '@stacks/network';\nimport {\n AssetString,\n ContractIdString,\n compressPrivateKey,\n privateKeyToPublic,\n} from '@stacks/transactions';\n\nimport {\n DerivationPathDepth,\n createDescriptor,\n createKeyOriginPath,\n extractAddressIndexFromPath,\n} from '@leather.io/crypto';\nimport type { NetworkModes } from '@leather.io/models';\nimport { assertIsTruthy, isString, toHexString } from '@leather.io/utils';\n\nexport const stxDerivationWithAccount = `m/44'/5757'/0'/0/{account}`;\n\nexport function makeAccountIndexDerivationPathFactory(derivationPath: string) {\n return (account: number) => derivationPath.replace('{account}', account.toString());\n}\n\nexport function extractStacksDerivationPathAccountIndex(path: string) {\n if (!path.includes('5757')) throw new Error('Not a valid Stacks derivation path: ' + path);\n return extractAddressIndexFromPath(path);\n}\n\n/**\n * Stacks accounts always use the same derivation path, regardless of network\n */\nexport const makeStxDerivationPath =\n makeAccountIndexDerivationPathFactory(stxDerivationWithAccount);\n\nexport function stacksChainIdToCoreNetworkMode(chainId: ChainId): NetworkModes {\n return whenStacksChainId(chainId)({\n [ChainId.Mainnet]: 'mainnet',\n [ChainId.Testnet]: 'testnet',\n });\n}\n\ninterface WhenStacksChainIdMap<T> {\n [ChainId.Mainnet]: T;\n [ChainId.Testnet]: T;\n}\nexport function whenStacksChainId(chainId: ChainId) {\n return <T>(chainIdMap: WhenStacksChainIdMap<T>): T => chainIdMap[chainId];\n}\n\n// From `@stacks/wallet-sdk` package we are trying not to use\nexport function deriveStxPrivateKey({ keychain, index }: { keychain: HDKey; index: number }) {\n if (keychain.depth !== DerivationPathDepth.Root) throw new Error('Root keychain must be depth 0');\n const accountKeychain = keychain.derive(makeStxDerivationPath(index));\n assertIsTruthy(accountKeychain.privateKey);\n return compressPrivateKey(accountKeychain.privateKey);\n}\n\nexport function deriveStxPublicKey({\n keychain,\n index,\n}: {\n keychain: HDKey;\n index: number;\n}): string {\n return privateKeyToPublic(deriveStxPrivateKey({ keychain, index })) as string;\n}\n\nexport function stacksRootKeychainToAccountDescriptor(keychain: HDKey, accountIndex: number) {\n const fingerprint = toHexString(keychain.fingerprint);\n const publicKey = deriveStxPublicKey({ keychain, index: accountIndex });\n return createDescriptor(\n createKeyOriginPath(fingerprint, makeStxDerivationPath(accountIndex)),\n publicKey\n );\n}\n\nexport function getStacksBurnAddress(chainIdChainId: ChainId): string {\n switch (chainIdChainId) {\n case ChainId.Mainnet:\n return 'SP00000000000003SCNSJTCSE62ZF4MSE';\n case ChainId.Testnet:\n default:\n return 'ST000000000000000000002AMW42H';\n }\n}\n\nexport function cleanHex(hexWithMaybePrefix: string): string {\n if (!isString(hexWithMaybePrefix)) return hexWithMaybePrefix;\n return hexWithMaybePrefix.startsWith('0x')\n ? hexWithMaybePrefix.replace('0x', '')\n : hexWithMaybePrefix;\n}\n\nexport function getPrincipalFromAssetString(assetString: string) {\n return assetString.split('::')[0];\n}\n\nexport function formatContractId(address: string, name: string) {\n return `${address}.${name}`;\n}\n\ninterface FormatAssetStringArgs {\n contractAddress: string;\n contractName: string;\n assetName: string;\n}\nexport function formatAssetString({\n contractAddress,\n contractName,\n assetName,\n}: FormatAssetStringArgs): AssetString {\n return `${contractAddress}.${contractName}::${assetName}`;\n}\n\ninterface FormatContractIdStringArgs {\n contractAddress: string;\n contractName: string;\n}\nexport function formatContractIdString({\n contractAddress,\n contractName,\n}: FormatContractIdStringArgs): ContractIdString {\n return `${contractAddress}.${contractName}`;\n}\n\n/**\n * Gets the contract name.\n *\n * @param identifier - [principal].[contract-name] or [principal].[contract-name]::[asset-name]\n */\nexport function getStacksContractName(identifier: string): string {\n if (identifier.includes('.')) {\n const parts = identifier?.split('.');\n if (identifier.includes('::')) {\n return parts[1].split('::')[0];\n }\n return parts[1];\n }\n return identifier;\n}\n\n/**\n * Gets the asset name.\n *\n * @param identifier - [principal].[contract-name]::[asset-name]\n */\nexport function getStacksContractAssetName(identifier: string): string {\n if (!identifier.includes('::')) return identifier;\n return identifier.split('::')[1];\n}\n\n/**\n * Gets the parts that make up a fully qualified name of an asset.\n *\n * @param identifier - [principal].[contract-name]::[asset-name]\n */\nexport function getStacksAssetStringParts(identifier: string): {\n contractAddress: string;\n contractAssetName: string;\n contractName: string;\n} {\n if (!identifier.includes('.') && !identifier.includes('::')) {\n return {\n contractAddress: identifier,\n contractAssetName: identifier,\n contractName: identifier,\n };\n }\n\n const contractAddress = identifier.split('.')[0];\n const contractAssetName = getStacksContractAssetName(identifier);\n const contractName = getStacksContractName(identifier);\n\n return {\n contractAddress,\n contractAssetName,\n contractName,\n };\n}\n","import { bytesToHex } from '@stacks/common';\nimport { Pc, serializeCV } from '@stacks/transactions';\n\nimport { Money } from '@leather.io/models';\n\nimport { StacksSigner } from '../signer/signer';\nimport { formatContractIdString, getStacksAssetStringParts } from '../stacks.utils';\nimport { generateStacksUnsignedTransaction } from './generate-unsigned-transaction';\nimport { createSip10FnArgs } from './get-contract-fn-args';\nimport { TransactionTypes } from './transaction.types';\n\ninterface CreateTransferSip10TxHex {\n signer: StacksSigner;\n assetId: string;\n recipient: string;\n amount: number;\n nonce: number;\n fee: Money;\n memo?: string;\n}\n\nexport async function createTransferSip10TxHex({\n signer,\n assetId,\n recipient,\n amount,\n nonce,\n fee,\n memo,\n}: CreateTransferSip10TxHex) {\n const { contractAddress, contractAssetName, contractName } = getStacksAssetStringParts(assetId);\n\n const currentStacksAddress = signer.address;\n\n const fnArgs = createSip10FnArgs({\n amount: amount,\n senderStacksAddress: currentStacksAddress,\n recipientStacksAddress: recipient,\n memo,\n });\n\n const tx = await generateStacksUnsignedTransaction({\n txType: TransactionTypes.ContractCall,\n publicKey: bytesToHex(signer.publicKey),\n contractAddress,\n contractName,\n functionArgs: fnArgs.map(arg => serializeCV(arg)),\n functionName: 'transfer',\n nonce,\n fee,\n postConditions: [\n Pc.principal(currentStacksAddress)\n .willSendEq(amount)\n .ft(formatContractIdString({ contractAddress, contractName }), contractAssetName),\n ],\n });\n\n const txHex = tx.serialize();\n return txHex;\n}\n","import { hexToBytes } from '@noble/hashes/utils';\nimport {\n deserializeCV,\n makeUnsignedContractCall,\n makeUnsignedContractDeploy,\n makeUnsignedSTXTokenTransfer,\n} from '@stacks/transactions';\nimport BigNumber from 'bignumber.js';\n\nimport { assertUnreachable } from '@leather.io/utils';\n\nimport { cleanHex } from '../stacks.utils';\nimport { ensurePostConditionWireFormat, getPostConditions } from './post-condition.utils';\nimport {\n StacksUnsignedContractCallOptions,\n StacksUnsignedContractDeployOptions,\n StacksUnsignedTokenTransferOptions,\n StacksUnsignedTransactionOptions,\n TransactionTypes,\n isTransactionTypeSupported,\n} from './transaction.types';\n\nexport function initNonce(nonce: number | string) {\n return new BigNumber(nonce, 10);\n}\n\nexport function getUnsignedContractCallParsedOptions(options: StacksUnsignedContractCallOptions) {\n return {\n ...options,\n fee: options.fee.amount.toString(),\n functionArgs: options.functionArgs.map(arg => deserializeCV(hexToBytes(cleanHex(arg)))),\n nonce: initNonce(options.nonce).toString(),\n postConditions: options.postConditions,\n };\n}\n\nexport function getUnsignedContractDeployParsedOptions(\n options: StacksUnsignedContractDeployOptions\n) {\n return {\n ...options,\n fee: options.fee.amount.toString(),\n nonce: initNonce(options.nonce).toString(),\n postConditions: getPostConditions(\n options.postConditions?.map(pc => ensurePostConditionWireFormat(pc))\n ),\n };\n}\n\nexport function getUnsignedStxTokenTransferParsedOptions(\n options: StacksUnsignedTokenTransferOptions\n) {\n return {\n ...options,\n amount: options.amount.amount.toString(),\n fee: options.fee.amount.toString(),\n nonce: initNonce(options.nonce).toString(),\n };\n}\n\nexport function generateStacksUnsignedTransaction(options: StacksUnsignedTransactionOptions) {\n const { txType } = options;\n\n const isValid = isTransactionTypeSupported(txType);\n\n if (!isValid) throw new Error(`Invalid Transaction Type: ${txType}`);\n\n switch (txType) {\n case TransactionTypes.StxTokenTransfer:\n return makeUnsignedSTXTokenTransfer(getUnsignedStxTokenTransferParsedOptions(options));\n case TransactionTypes.ContractCall:\n return makeUnsignedContractCall(getUnsignedContractCallParsedOptions(options));\n case TransactionTypes.ContractDeploy:\n return makeUnsignedContractDeploy(getUnsignedContractDeployParsedOptions(options));\n default:\n assertUnreachable(txType);\n }\n}\n","import { hexToBytes } from '@noble/hashes/utils';\nimport {\n BytesReader,\n PostCondition,\n PostConditionWire,\n deserializePostConditionWire,\n postConditionToWire,\n} from '@stacks/transactions';\n\nimport { isString } from '@leather.io/utils';\n\nexport function getPostConditionFromString(postCondition: string): PostConditionWire {\n try {\n const reader = new BytesReader(hexToBytes(postCondition));\n return deserializePostConditionWire(reader);\n } catch {\n throw new Error('Not a serialized post condition');\n }\n}\n\nexport function ensurePostConditionWireFormat(\n postCondition: string | PostCondition | PostConditionWire\n) {\n if (isString(postCondition)) return getPostConditionFromString(postCondition);\n if ('conditionType' in postCondition) return postCondition;\n return postConditionToWire(postCondition);\n}\n\nexport function getPostCondition(\n postCondition: string | PostCondition | PostConditionWire\n): PostConditionWire {\n return isString(postCondition)\n ? getPostConditionFromString(postCondition)\n : ensurePostConditionWireFormat(postCondition);\n}\n\nexport function getPostConditions(\n postConditions?: (string | PostCondition | PostConditionWire)[]\n): PostConditionWire[] | undefined {\n return postConditions?.map(getPostCondition);\n}\n","import {\n UnsignedContractCallOptions,\n UnsignedContractDeployOptions,\n UnsignedTokenTransferOptions,\n} from '@stacks/transactions';\n\nimport { Money, ReplaceTypes } from '@leather.io/models';\n\nexport enum TransactionTypes {\n ContractCall = 'contract_call',\n ContractDeploy = 'smart_contract',\n StxTokenTransfer = 'token_transfer',\n}\n\nexport function isTransactionTypeSupported(txType: TransactionTypes) {\n return (\n txType === TransactionTypes.ContractCall ||\n txType === TransactionTypes.ContractDeploy ||\n txType === TransactionTypes.StxTokenTransfer\n );\n}\n\nexport type StacksUnsignedContractCallOptions = ReplaceTypes<\n UnsignedContractCallOptions,\n {\n fee: Money;\n functionArgs: string[];\n nonce: number | string;\n }\n> & { txType: TransactionTypes.ContractCall };\n\nexport type StacksUnsignedContractDeployOptions = ReplaceTypes<\n UnsignedContractDeployOptions,\n {\n fee: Money;\n nonce: number | string;\n }\n> & { txType: TransactionTypes.ContractDeploy };\n\nexport type StacksUnsignedTokenTransferOptions = ReplaceTypes<\n UnsignedTokenTransferOptions,\n {\n amount: Money;\n fee: Money;\n nonce: number | string;\n }\n> & { txType: TransactionTypes.StxTokenTransfer };\n\nexport type StacksUnsignedTransactionOptions =\n | StacksUnsignedContractCallOptions\n | StacksUnsignedContractDeployOptions\n | StacksUnsignedTokenTransferOptions;\n","import {\n ClarityValue,\n bufferCVFromString,\n createAddress,\n deserializeCV,\n noneCV,\n someCV,\n standardPrincipalCVFromAddress,\n uintCV,\n} from '@stacks/transactions';\n\ninterface GetSip10FnArgs {\n amount: number;\n senderStacksAddress: string;\n recipientStacksAddress: string;\n memo?: string;\n}\n\nexport function createSip10FnArgs({\n amount,\n senderStacksAddress,\n recipientStacksAddress,\n memo,\n}: GetSip10FnArgs) {\n const fnArgs: ClarityValue[] = [\n uintCV(amount),\n standardPrincipalCVFromAddress(createAddress(senderStacksAddress)),\n standardPrincipalCVFromAddress(createAddress(recipientStacksAddress)),\n memo && memo !== '' ? someCV(bufferCVFromString(memo)) : noneCV(),\n ];\n return fnArgs;\n}\n\ninterface GetSip9FnArgs {\n assetId: string;\n senderStacksAddress: string;\n recipientStacksAddress: string;\n}\nexport function createSip9FnArgs({\n assetId,\n senderStacksAddress,\n recipientStacksAddress,\n}: GetSip9FnArgs) {\n const fnArgs: ClarityValue[] = [\n deserializeCV(assetId),\n standardPrincipalCVFromAddress(createAddress(senderStacksAddress)),\n standardPrincipalCVFromAddress(createAddress(recipientStacksAddress)),\n ];\n return fnArgs;\n}\n","import { TxBroadcastResultRejected } from '@stacks/transactions';\n\nexport function getErrorMessage(\n reason:\n | TxBroadcastResultRejected['reason']\n | 'BadTransactionVersion'\n | 'ConflictingNonceInMempool'\n | 'EstimatorError'\n | 'TransferAmountMustBePositive'\n | 'TransferRecipientCannotEqualSender'\n) {\n switch (reason) {\n case 'BadAddressVersionByte':\n return 'Incorrect address';\n case 'BadFunctionArgument':\n return 'Incorrect function argument';\n case 'BadNonce':\n return 'Incorrect nonce';\n case 'BadTransactionVersion':\n return 'Incorrect transaction';\n case 'ConflictingNonceInMempool':\n return 'Nonce conflict';\n case 'ContractAlreadyExists':\n return 'Contract already exists';\n case 'Deserialization':\n return 'Deserialization failure';\n case 'EstimatorError':\n return 'Estimator error';\n case 'FeeTooLow':\n return 'Fee too low';\n case 'NoCoinbaseViaMempool':\n return 'No coinbase via mempool';\n case 'NoSuchContract':\n return 'Contract does not exist';\n case 'NoSuchPublicFunction':\n return 'Function does not exist';\n case 'NotEnoughFunds':\n return 'Not enough funds';\n case 'PoisonMicroblocksDoNotConflict':\n return 'Microblock conflict';\n case 'PoisonMicroblockHasUnknownPubKeyHash':\n return 'No anchor block with public key hash';\n case 'PoisonMicroblockIsInvalid':\n return 'Invalid microblock';\n case 'Serialization':\n return 'Serialization failure';\n case 'ServerFailureDatabase':\n return 'Database error';\n case 'ServerFailureNoSuchChainTip':\n return 'No such chain tip';\n case 'ServerFailureOther':\n return 'Server failure';\n case 'SignatureValidation':\n return 'Failed to validate signature';\n case 'TransferAmountMustBePositive':\n return 'Transfer amount must be positive';\n case 'TransferRecipientCannotEqualSender':\n return 'Cannot transfer STX to yourself';\n default:\n return 'Something went wrong';\n }\n}\n","import { ClarityAbi, ClarityType, ClarityValue } from '@stacks/transactions';\n\nexport function isSip10Transfer({\n functionName,\n contractInterfaceData,\n}: {\n functionName: string;\n contractInterfaceData: ClarityAbi;\n}) {\n if (functionName !== 'transfer') return false;\n const functionInterface = contractInterfaceData?.functions.find(f => f.name === functionName);\n if (\n functionInterface?.args[0]?.name === 'amount' &&\n functionInterface?.args[1]?.name === 'sender' &&\n functionInterface?.args[2]?.name === 'recipient' &&\n functionInterface?.args[3]?.name === 'memo'\n ) {\n return true;\n }\n return false;\n}\n\nexport function getSip10TransferAmount({\n functionName,\n functionArgs,\n contractInterfaceData,\n}: {\n functionName: string;\n functionArgs: ClarityValue[];\n contractInterfaceData: ClarityAbi;\n}) {\n if (\n isSip10Transfer({ functionName, contractInterfaceData }) &&\n functionArgs[0]?.type === ClarityType.UInt\n ) {\n return Number(functionArgs[0].value);\n }\n return null;\n}\n\nexport function getSip10TransferRecipient({\n functionName,\n functionArgs,\n contractInterfaceData,\n}: {\n functionName: string;\n functionArgs: ClarityValue[];\n contractInterfaceData: ClarityAbi;\n}) {\n if (\n isSip10Transfer({ functionName, contractInterfaceData }) &&\n functionArgs[2]?.type === ClarityType.PrincipalStandard\n ) {\n return functionArgs[2].value;\n }\n return null;\n}\n","import { c32addressDecode } from 'c32check';\nimport { z } from 'zod';\n\nimport { ChainId } from '@leather.io/models';\nimport { isEmptyString, isString, isUndefined } from '@leather.io/utils';\n\n// taken from stacks-utils.ts\nexport function isValidStacksAddress(address: string) {\n if (isUndefined(address) || isEmptyString(address)) {\n return false;\n }\n try {\n c32addressDecode(address);\n return true;\n } catch {\n return false;\n }\n}\n\nexport function isValidAddressChain(address: string, chainId: ChainId) {\n if (!address) {\n return false;\n }\n\n const prefix = address.slice(0, 2);\n switch (chainId) {\n case ChainId.Mainnet:\n return prefix === 'SM' || prefix === 'SP';\n case ChainId.Testnet:\n return prefix === 'SN' || prefix === 'ST';\n default:\n return false;\n }\n}\n\nexport function validatePayerNotRecipient(senderAddress: string, recipientAddress: string) {\n if (!senderAddress || !recipientAddress) {\n return false;\n }\n\n return senderAddress !== recipientAddress;\n}\n\nexport const standardPrincipalSchema = z.string().refine(\n (address: unknown) => {\n if (!isString(address)) return false;\n if (!isValidStacksAddress(address)) return false;\n return !address.includes('.');\n },\n { message: 'Invalid standard Stacks principal address' }\n);\n\nexport const contractPrincipalSchema = z.string().refine(\n (principal: unknown) => {\n if (!isString(principal)) return false;\n\n const parts = principal.split('.');\n if (parts.length !== 2) return false;\n\n const [address, contractName] = parts;\n\n if (!isValidStacksAddress(address)) return false;\n\n const contractNameRegex = /^[a-zA-Z0-9_-]{1,128}$/;\n return contractNameRegex.test(contractName);\n },\n { message: 'Invalid contract principal (must be address.contract-name format)' }\n);\n\nexport const principalSchema = z.union([standardPrincipalSchema, contractPrincipalSchema]);\n","import { MEMO_MAX_LENGTH_BYTES } from '@stacks/transactions';\n\nfunction exceedsMaxLengthBytes(value: string, maxLengthBytes: number): boolean {\n return value ? Buffer.from(value).length > maxLengthBytes : false;\n}\n\nexport function isValidStacksMemo(memo: string) {\n return !exceedsMaxLengthBytes(memo, MEMO_MAX_LENGTH_BYTES);\n}\n","import { TransactionErrorKey } from '@leather.io/models';\n\nexport type StacksErrorKey =\n | TransactionErrorKey\n | 'InvalidSameAddress'\n | 'UnknownBalance'\n | 'UnknownFee'\n | 'UnknownAmount';\n\nexport class StacksError extends Error {\n public message: StacksErrorKey;\n constructor(message: StacksErrorKey) {\n super(message);\n this.name = 'StacksError';\n this.message = message;\n\n // Fix the prototype chain\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n","import BigNumber from 'bignumber.js';\n\nimport { Money } from '@leather.io/models';\nimport { isDefined, stxToMicroStx } from '@leather.io/utils';\n\nimport { StacksError } from './stacks-error';\n\nfunction isMoneyAmountValid(amount: Money) {\n return amount && isDefined(amount.amount) && amount.amount;\n}\n\ninterface IsStxAmountValidArgs {\n availableBalance: Money;\n amount: Money;\n fee: Money;\n}\n\nexport function isStxAmountValid({ availableBalance, amount, fee }: IsStxAmountValidArgs) {\n if (!isMoneyAmountValid(amount)) {\n throw new StacksError('InvalidAmount');\n }\n if (!isMoneyAmountValid(availableBalance)) {\n throw new StacksError('UnknownBalance');\n }\n if (!isMoneyAmountValid(fee)) {\n throw new StacksError('UnknownFee');\n }\n return true;\n}\n\nexport function isStxBalanceSufficient({\n availableBalance: { amount: availableBalanceAmount },\n amount: { amount: desiredSpend },\n fee: { amount: feeAmount },\n}: IsStxAmountValidArgs) {\n const fee = new BigNumber(stxToMicroStx(feeAmount));\n\n if (!availableBalanceAmount) {\n throw new StacksError('UnknownBalance');\n }\n if (!fee.isFinite()) {\n throw new StacksError('UnknownFee');\n }\n\n const availableBalance = new BigNumber(stxToMicroStx(availableBalanceAmount));\n const spendableAmount = availableBalance.minus(fee);\n const amount = new BigNumber(stxToMicroStx(desiredSpend));\n return spendableAmount.isGreaterThanOrEqualTo(amount);\n}\n","import { ChainId, Money } from '@leather.io/models';\n\nimport {\n isValidAddressChain,\n isValidStacksAddress,\n validatePayerNotRecipient,\n} from './address-validation';\nimport { isStxAmountValid, isStxBalanceSufficient } from './amount-validation';\nimport { StacksError } from './stacks-error';\n\ninterface StacksTransaction {\n amount: Money;\n payer: string;\n recipient: string;\n chainId: ChainId;\n availableBalance: Money;\n fee: Money;\n}\n\nexport function isValidStacksTransaction({\n amount,\n availableBalance,\n fee,\n payer,\n recipient,\n chainId,\n}: StacksTransaction) {\n if (!isValidStacksAddress(payer) || !isValidStacksAddress(recipient)) {\n throw new StacksError('InvalidAddress');\n }\n if (!isValidAddressChain(payer, chainId) || !isValidAddressChain(recipient, chainId)) {\n throw new StacksError('InvalidNetworkAddress');\n }\n if (!validatePayerNotRecipient(payer, recipient)) {\n throw new StacksError('InvalidSameAddress');\n }\n\n if (!isStxAmountValid({ availableBalance, amount, fee })) {\n throw new StacksError('InvalidAmount');\n }\n if (!isStxBalanceSufficient({ availableBalance, amount, fee })) {\n throw new StacksError('InsufficientFunds');\n }\n return true;\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;AAE3B,SAAS,mBAAmB;AAC5B;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAMA,SAAS,YAAY,SAAiB,YAAuC;AAClF,QAAM,OAAO,YAAY,OAAO;AAChC,SAAO;AAAA,IACL,WAAW,mBAAmB,EAAE,YAAY,aAAa,WAAW,IAAI,EAAE,CAAC;AAAA,IAC3E,WAAW,mBAAmB,UAAU;AAAA,EAC1C;AACF;AAEO,SAAS,0BACd,SACA,QACA,YACe;AACf,QAAM,YAAY,mBAAmB;AAAA,IACnC;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,SAAO;AAAA,IACL;AAAA,IACA,WAAW,mBAAmB,UAAU;AAAA,EAC1C;AACF;;;ACpCO,IAAM,6BAA6B;AACnC,IAAM,6BAA6B;AACnC,IAAM,qCAAqC;AAG3C,IAAM,gCAAgC;AACtC,IAAM,wCAAwC;;;ACPrD;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACZP,SAAS,eAAe;AACxB;AAAA,EAGE;AAAA,EACA,sBAAAA;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,gBAAgB,UAAU,mBAAmB;AAE/C,IAAM,2BAA2B;AAEjC,SAAS,sCAAsC,gBAAwB;AAC5E,SAAO,CAAC,YAAoB,eAAe,QAAQ,aAAa,QAAQ,SAAS,CAAC;AACpF;AAEO,SAAS,wCAAwC,MAAc;AACpE,MAAI,CAAC,KAAK,SAAS,MAAM,EAAG,OAAM,IAAI,MAAM,yCAAyC,IAAI;AACzF,SAAO,4BAA4B,IAAI;AACzC;AAKO,IAAM,wBACX,sCAAsC,wBAAwB;A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;AAClD,QAAM,SAAS,IAAIA,WAAU,cAAc,YAAY,CAAC;AACxD,SAAO,gBAAgB,uBAAuB,MAAM;AACtD;;;AC7BO,SAAS,yBAAyB;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAsB;AACpB,MAAI,CAAC,qBAAqB,KAAK,KAAK,CAAC,qBAAqB,SAAS,GAAG;AACpE,UAAM,IAAI,YAAY,gBAAgB;AAAA,EACxC;AACA,MAAI,CAAC,oBAAoB,OAAO,OAAO,KAAK,CAAC,oBAAoB,WAAW,OAAO,GAAG;AACpF,UAAM,IAAI,YAAY,uBAAuB;AAAA,EAC/C;AACA,MAAI,CAAC,0BAA0B,OAAO,SAAS,GAAG;AAChD,UAAM,IAAI,YAAY,oBAAoB;AAAA,EAC5C;AAEA,MAAI,CAAC,iBAAiB,EAAE,kBAAkB,QAAQ,IAAI,CAAC,GAAG;AACxD,UAAM,IAAI,YAAY,eAAe;AAAA,EACvC;AACA,MAAI,CAAC,uBAAuB,EAAE,kBAAkB,QAAQ,IAAI,CAAC,GAAG;AAC9D,UAAM,IAAI,YAAY,mBAAmB;AAAA,EAC3C;AACA,SAAO;AACT;","names":["privateKeyToPublic","bytesToHex","hexToBytes","isString","TransactionTypes","hexToBytes","deserializeCV","bytesToHex","ChainId","isString","BigNumber","BigNumber"]}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@leather.io/stacks",
|
|
3
3
|
"author": "leather.io",
|
|
4
4
|
"description": "Stacks package for Leather",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.16.0",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"exports": {
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
"@stacks/transactions": "7.0.5",
|
|
19
19
|
"bignumber.js": "9.1.2",
|
|
20
20
|
"c32check": "2.0.0",
|
|
21
|
-
"zod": "4.0.
|
|
22
|
-
"@leather.io/
|
|
23
|
-
"@leather.io/
|
|
24
|
-
"@leather.io/
|
|
25
|
-
"@leather.io/
|
|
21
|
+
"zod": "4.0.17",
|
|
22
|
+
"@leather.io/models": "0.39.1",
|
|
23
|
+
"@leather.io/utils": "0.42.4",
|
|
24
|
+
"@leather.io/constants": "0.25.1",
|
|
25
|
+
"@leather.io/crypto": "1.11.6"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"tsup": "8.4.0",
|