@stacks/transactions
Advanced tools
Comparing version 6.14.1-next.32 to 6.14.1-next.36
@@ -52,5 +52,3 @@ "use strict"; | ||
if (txOptions.nonce == null) { | ||
const addressVersion = options.network.transactionVersion === network_1.TransactionVersion.Mainnet | ||
? constants_1.AddressVersion.MainnetSingleSig | ||
: constants_1.AddressVersion.TestnetSingleSig; | ||
const addressVersion = network.addressVersion.singleSig; | ||
const address = (0, c32check_1.c32address)(addressVersion, transaction.auth.spendingCondition.signer); | ||
@@ -141,5 +139,3 @@ const txNonce = await (0, fetch_1.getNonce)({ address, api: options.api }); | ||
if (txOptions.nonce === undefined || txOptions.nonce === null) { | ||
const addressVersion = options.network.transactionVersion === network_1.TransactionVersion.Mainnet | ||
? constants_1.AddressVersion.MainnetSingleSig | ||
: constants_1.AddressVersion.TestnetSingleSig; | ||
const addressVersion = network.addressVersion.singleSig; | ||
const address = (0, c32check_1.c32address)(addressVersion, transaction.auth.spendingCondition.signer); | ||
@@ -208,5 +204,3 @@ const txNonce = await (0, fetch_1.getNonce)({ address, api: options.api }); | ||
if (txOptions.nonce === undefined || txOptions.nonce === null) { | ||
const addressVersion = network.transactionVersion === network_1.TransactionVersion.Mainnet | ||
? constants_1.AddressVersion.MainnetSingleSig | ||
: constants_1.AddressVersion.TestnetSingleSig; | ||
const addressVersion = network.addressVersion.singleSig; | ||
const address = (0, c32check_1.c32address)(addressVersion, transaction.auth.spendingCondition.signer); | ||
@@ -274,2 +268,3 @@ const txNonce = await (0, fetch_1.getNonce)({ address, api: options.api }); | ||
options.api = (0, utils_1.defaultApiFromNetwork)(options.network, sponsorOptions.api); | ||
const network = (0, network_1.networkFrom)(options.network); | ||
const sponsorPubKey = (0, keys_1.privateKeyToPublic)(options.sponsorPrivateKey); | ||
@@ -292,6 +287,3 @@ if (sponsorOptions.fee == null) { | ||
if (sponsorOptions.sponsorNonce == null) { | ||
const addressVersion = (0, network_1.whenTransactionVersion)(options.transaction.version)({ | ||
[network_1.TransactionVersion.Mainnet]: constants_1.AddressVersion.MainnetSingleSig, | ||
[network_1.TransactionVersion.Testnet]: constants_1.AddressVersion.TestnetSingleSig, | ||
}); | ||
const addressVersion = network.addressVersion.singleSig; | ||
const address = (0, keys_1.publicKeyToAddress)(addressVersion, sponsorPubKey); | ||
@@ -298,0 +290,0 @@ const sponsorNonce = await (0, fetch_1.getNonce)({ address, api: options.api }); |
@@ -74,8 +74,3 @@ export declare const BLOCKSTACK_DEFAULT_GAIA_HUB_URL = "https://hub.blockstack.org"; | ||
export type MultiSigHashMode = AddressHashMode.SerializeP2SH | AddressHashMode.SerializeP2WSH | AddressHashMode.SerializeP2SHNonSequential | AddressHashMode.SerializeP2WSHNonSequential; | ||
export declare enum AddressVersion { | ||
MainnetSingleSig = 22, | ||
MainnetMultiSig = 20, | ||
TestnetSingleSig = 26, | ||
TestnetMultiSig = 21 | ||
} | ||
export { AddressVersion } from '@stacks/network'; | ||
export declare enum PubKeyEncoding { | ||
@@ -126,2 +121,1 @@ Compressed = 0, | ||
} | ||
export {}; |
@@ -97,9 +97,4 @@ "use strict"; | ||
})(AddressHashMode || (exports.AddressHashMode = AddressHashMode = {})); | ||
var AddressVersion; | ||
(function (AddressVersion) { | ||
AddressVersion[AddressVersion["MainnetSingleSig"] = 22] = "MainnetSingleSig"; | ||
AddressVersion[AddressVersion["MainnetMultiSig"] = 20] = "MainnetMultiSig"; | ||
AddressVersion[AddressVersion["TestnetSingleSig"] = 26] = "TestnetSingleSig"; | ||
AddressVersion[AddressVersion["TestnetMultiSig"] = 21] = "TestnetMultiSig"; | ||
})(AddressVersion || (exports.AddressVersion = AddressVersion = {})); | ||
var network_1 = require("@stacks/network"); | ||
Object.defineProperty(exports, "AddressVersion", { enumerable: true, get: function () { return network_1.AddressVersion; } }); | ||
var PubKeyEncoding; | ||
@@ -106,0 +101,0 @@ (function (PubKeyEncoding) { |
import { STACKS_MAINNET, STACKS_TESTNET, TransactionVersion, networkFrom, whenTransactionVersion, } from '@stacks/network'; | ||
import { c32address } from 'c32check'; | ||
import { createMultiSigSpendingCondition, createSingleSigSpendingCondition, createSponsoredAuth, createStandardAuth, isSingleSig, } from './authorization'; | ||
import { AddressHashMode, AddressVersion, AnchorMode, ClarityVersion, PayloadType, PostConditionMode, } from './constants'; | ||
import { AddressHashMode, AnchorMode, ClarityVersion, PayloadType, PostConditionMode, } from './constants'; | ||
import { validateContractCall } from './contract-abi'; | ||
@@ -49,5 +49,3 @@ import { estimateFee, getAbi, getNonce } from './fetch'; | ||
if (txOptions.nonce == null) { | ||
const addressVersion = options.network.transactionVersion === TransactionVersion.Mainnet | ||
? AddressVersion.MainnetSingleSig | ||
: AddressVersion.TestnetSingleSig; | ||
const addressVersion = network.addressVersion.singleSig; | ||
const address = c32address(addressVersion, transaction.auth.spendingCondition.signer); | ||
@@ -135,5 +133,3 @@ const txNonce = await getNonce({ address, api: options.api }); | ||
if (txOptions.nonce === undefined || txOptions.nonce === null) { | ||
const addressVersion = options.network.transactionVersion === TransactionVersion.Mainnet | ||
? AddressVersion.MainnetSingleSig | ||
: AddressVersion.TestnetSingleSig; | ||
const addressVersion = network.addressVersion.singleSig; | ||
const address = c32address(addressVersion, transaction.auth.spendingCondition.signer); | ||
@@ -201,5 +197,3 @@ const txNonce = await getNonce({ address, api: options.api }); | ||
if (txOptions.nonce === undefined || txOptions.nonce === null) { | ||
const addressVersion = network.transactionVersion === TransactionVersion.Mainnet | ||
? AddressVersion.MainnetSingleSig | ||
: AddressVersion.TestnetSingleSig; | ||
const addressVersion = network.addressVersion.singleSig; | ||
const address = c32address(addressVersion, transaction.auth.spendingCondition.signer); | ||
@@ -259,2 +253,3 @@ const txNonce = await getNonce({ address, api: options.api }); | ||
options.api = defaultApiFromNetwork(options.network, sponsorOptions.api); | ||
const network = networkFrom(options.network); | ||
const sponsorPubKey = privateKeyToPublic(options.sponsorPrivateKey); | ||
@@ -277,6 +272,3 @@ if (sponsorOptions.fee == null) { | ||
if (sponsorOptions.sponsorNonce == null) { | ||
const addressVersion = whenTransactionVersion(options.transaction.version)({ | ||
[TransactionVersion.Mainnet]: AddressVersion.MainnetSingleSig, | ||
[TransactionVersion.Testnet]: AddressVersion.TestnetSingleSig, | ||
}); | ||
const addressVersion = network.addressVersion.singleSig; | ||
const address = publicKeyToAddress(addressVersion, sponsorPubKey); | ||
@@ -283,0 +275,0 @@ const sponsorNonce = await getNonce({ address, api: options.api }); |
@@ -74,8 +74,3 @@ export declare const BLOCKSTACK_DEFAULT_GAIA_HUB_URL = "https://hub.blockstack.org"; | ||
export type MultiSigHashMode = AddressHashMode.SerializeP2SH | AddressHashMode.SerializeP2WSH | AddressHashMode.SerializeP2SHNonSequential | AddressHashMode.SerializeP2WSHNonSequential; | ||
export declare enum AddressVersion { | ||
MainnetSingleSig = 22, | ||
MainnetMultiSig = 20, | ||
TestnetSingleSig = 26, | ||
TestnetMultiSig = 21 | ||
} | ||
export { AddressVersion } from '@stacks/network'; | ||
export declare enum PubKeyEncoding { | ||
@@ -126,2 +121,1 @@ Compressed = 0, | ||
} | ||
export {}; |
@@ -92,9 +92,3 @@ export const BLOCKSTACK_DEFAULT_GAIA_HUB_URL = 'https://hub.blockstack.org'; | ||
})(AddressHashMode || (AddressHashMode = {})); | ||
export var AddressVersion; | ||
(function (AddressVersion) { | ||
AddressVersion[AddressVersion["MainnetSingleSig"] = 22] = "MainnetSingleSig"; | ||
AddressVersion[AddressVersion["MainnetMultiSig"] = 20] = "MainnetMultiSig"; | ||
AddressVersion[AddressVersion["TestnetSingleSig"] = 26] = "TestnetSingleSig"; | ||
AddressVersion[AddressVersion["TestnetMultiSig"] = 21] = "TestnetMultiSig"; | ||
})(AddressVersion || (AddressVersion = {})); | ||
export { AddressVersion } from '@stacks/network'; | ||
export var PubKeyEncoding; | ||
@@ -101,0 +95,0 @@ (function (PubKeyEncoding) { |
{ | ||
"name": "@stacks/transactions", | ||
"version": "6.14.1-next.32+ccfeedb9", | ||
"version": "6.14.1-next.36+95cd674f", | ||
"description": "Javascript library for constructing transactions on the Stacks blockchain.", | ||
@@ -30,4 +30,4 @@ "license": "MIT", | ||
"@noble/secp256k1": "1.7.1", | ||
"@stacks/common": "^6.14.1-next.32+ccfeedb9", | ||
"@stacks/network": "^6.14.1-next.32+ccfeedb9", | ||
"@stacks/common": "^6.14.1-next.36+95cd674f", | ||
"@stacks/network": "^6.14.1-next.36+95cd674f", | ||
"c32check": "^2.0.0", | ||
@@ -37,3 +37,3 @@ "lodash.clonedeep": "^4.5.0" | ||
"devDependencies": { | ||
"@stacks/encryption": "^6.14.1-next.32+ccfeedb9", | ||
"@stacks/encryption": "^6.14.1-next.36+95cd674f", | ||
"@types/common-tags": "^1.8.0", | ||
@@ -67,3 +67,3 @@ "@types/elliptic": "^6.4.12", | ||
}, | ||
"gitHead": "ccfeedb9e887d3160f4a9fab08f5766bf9b5d981" | ||
"gitHead": "95cd674ff54d3b2b18b3742813846622e4925742" | ||
} |
@@ -23,3 +23,2 @@ import { ApiOpts, ApiParam, IntegerType } from '@stacks/common'; | ||
AddressHashMode, | ||
AddressVersion, | ||
AnchorMode, | ||
@@ -205,6 +204,3 @@ ClarityVersion, | ||
if (txOptions.nonce == null) { | ||
const addressVersion = | ||
options.network.transactionVersion === TransactionVersion.Mainnet | ||
? AddressVersion.MainnetSingleSig | ||
: AddressVersion.TestnetSingleSig; | ||
const addressVersion = network.addressVersion.singleSig; | ||
const address = c32address(addressVersion, transaction.auth.spendingCondition!.signer); | ||
@@ -423,6 +419,3 @@ const txNonce = await getNonce({ address, api: options.api }); | ||
if (txOptions.nonce === undefined || txOptions.nonce === null) { | ||
const addressVersion = | ||
options.network.transactionVersion === TransactionVersion.Mainnet | ||
? AddressVersion.MainnetSingleSig | ||
: AddressVersion.TestnetSingleSig; | ||
const addressVersion = network.addressVersion.singleSig; | ||
const address = c32address(addressVersion, transaction.auth.spendingCondition!.signer); | ||
@@ -584,6 +577,3 @@ const txNonce = await getNonce({ address, api: options.api }); | ||
if (txOptions.nonce === undefined || txOptions.nonce === null) { | ||
const addressVersion = | ||
network.transactionVersion === TransactionVersion.Mainnet | ||
? AddressVersion.MainnetSingleSig | ||
: AddressVersion.TestnetSingleSig; | ||
const addressVersion = network.addressVersion.singleSig; | ||
const address = c32address(addressVersion, transaction.auth.spendingCondition!.signer); | ||
@@ -829,2 +819,3 @@ const txNonce = await getNonce({ address, api: options.api }); | ||
const network = networkFrom(options.network); | ||
const sponsorPubKey = privateKeyToPublic(options.sponsorPrivateKey); | ||
@@ -853,6 +844,3 @@ | ||
if (sponsorOptions.sponsorNonce == null) { | ||
const addressVersion = whenTransactionVersion(options.transaction.version)({ | ||
[TransactionVersion.Mainnet]: AddressVersion.MainnetSingleSig, | ||
[TransactionVersion.Testnet]: AddressVersion.TestnetSingleSig, | ||
}); // detect address version from transaction version | ||
const addressVersion = network.addressVersion.singleSig; | ||
const address = publicKeyToAddress(addressVersion, sponsorPubKey); | ||
@@ -859,0 +847,0 @@ const sponsorNonce = await getNonce({ address, api: options.api }); |
@@ -172,18 +172,4 @@ /** @ignore internal */ | ||
/** | ||
* Address versions for identifying address types in an encoded Stacks address. | ||
* The address version is a single byte, indicating the address type. | ||
* Every Stacks address starts with `S` followed by a single character indicating the address version. | ||
* The second character is the c32-encoded AddressVersion byte. | ||
*/ | ||
export enum AddressVersion { | ||
/** `P` — A single-sig address for mainnet (starting with `SP`) */ | ||
MainnetSingleSig = 22, | ||
/** `M` — A multi-sig address for mainnet (starting with `SM`) */ | ||
MainnetMultiSig = 20, | ||
/** `T` — A single-sig address for testnet (starting with `ST`) */ | ||
TestnetSingleSig = 26, | ||
/** `N` — A multi-sig address for testnet (starting with `SN`) */ | ||
TestnetMultiSig = 21, | ||
} | ||
// re-export for backwards compatibility | ||
export { AddressVersion } from '@stacks/network'; | ||
@@ -190,0 +176,0 @@ // todo: try to remove this |
@@ -66,2 +66,3 @@ import { | ||
// todo: next: change to opts object with `network` opt | ||
constructor( | ||
@@ -68,0 +69,0 @@ version: TransactionVersion, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
1857102
18733