@stacks/stacking
Advanced tools
Comparing version 6.17.0 to 7.0.0-next.70
@@ -1,5 +0,6 @@ | ||
import { IntegerType } from '@stacks/common'; | ||
import { StacksNetwork } from '@stacks/network'; | ||
import { ClientOpts, IntegerType, PrivateKey } from '@stacks/common'; | ||
import { StacksNetwork, StacksNetworkName } from '@stacks/network'; | ||
import { BurnchainRewardListResponse, BurnchainRewardSlotHolderListResponse, BurnchainRewardsTotal } from '@stacks/stacks-blockchain-api-types'; | ||
import { ContractCallOptions, StacksPrivateKey, StacksTransaction, TxBroadcastResult } from '@stacks/transactions'; | ||
import type { ContractIdString } from '@stacks/transactions'; | ||
import { ContractCallOptions, StacksTransaction, TxBroadcastResult } from '@stacks/transactions'; | ||
import { PoxOperationPeriod } from './constants'; | ||
@@ -52,16 +53,2 @@ import { Pox4SignatureTopic } from './utils'; | ||
}; | ||
export interface AccountExtendedBalances { | ||
stx: { | ||
balance: IntegerType; | ||
total_sent: IntegerType; | ||
total_received: IntegerType; | ||
locked: IntegerType; | ||
lock_tx_id: string; | ||
lock_height: number; | ||
burnchain_lock_height: number; | ||
burnchain_unlock_height: number; | ||
}; | ||
fungible_tokens: any; | ||
non_fungible_tokens: any; | ||
} | ||
export type StackerInfo = { | ||
@@ -88,32 +75,9 @@ stacked: false; | ||
delegated_to: string; | ||
pox_address: { | ||
version: Uint8Array; | ||
pox_address?: { | ||
version: number; | ||
hashbytes: Uint8Array; | ||
} | undefined; | ||
until_burn_ht: number | undefined; | ||
}; | ||
until_burn_ht?: number; | ||
}; | ||
}; | ||
export interface BlockTimeInfo { | ||
mainnet: { | ||
target_block_time: number; | ||
}; | ||
testnet: { | ||
target_block_time: number; | ||
}; | ||
} | ||
export interface CoreInfo { | ||
burn_block_height: number; | ||
stable_pox_consensus: string; | ||
} | ||
export interface BalanceInfo { | ||
balance: string; | ||
nonce: number; | ||
} | ||
export interface PaginationOptions { | ||
limit: number; | ||
offset: number; | ||
} | ||
export interface RewardsError { | ||
error: string; | ||
} | ||
export interface RewardSetOptions { | ||
@@ -217,18 +181,25 @@ contractId: string; | ||
network: StacksNetwork; | ||
constructor(address: string, network: StacksNetwork); | ||
getCoreInfo(): Promise<CoreInfo>; | ||
getPoxInfo(): Promise<PoxInfo>; | ||
client: Required<ClientOpts>; | ||
constructor(opts: { | ||
address: string; | ||
network: StacksNetworkName | StacksNetwork; | ||
client?: ClientOpts; | ||
}); | ||
get baseUrl(): string; | ||
get fetch(): import("@stacks/common").FetchFn; | ||
getCoreInfo(): Promise<V2CoreInfoResponse>; | ||
getPoxInfo(): Promise<V2PoxInfoResponse>; | ||
getTargetBlockTime(): Promise<number>; | ||
getAccountStatus(): Promise<any>; | ||
getAccountBalance(): Promise<bigint>; | ||
getAccountExtendedBalances(): Promise<AccountExtendedBalances>; | ||
getAccountExtendedBalances(): Promise<ExtendedAccountBalances>; | ||
getAccountBalanceLocked(): Promise<bigint>; | ||
getCycleDuration(): Promise<number>; | ||
getRewardsTotalForBtcAddress(): Promise<BurnchainRewardsTotal | RewardsError>; | ||
getRewardsForBtcAddress(options?: PaginationOptions): Promise<BurnchainRewardListResponse | RewardsError>; | ||
getRewardHoldersForBtcAddress(options?: PaginationOptions): Promise<BurnchainRewardSlotHolderListResponse | RewardsError>; | ||
getRewardsTotalForBtcAddress(): Promise<BurnchainRewardsTotal | BaseErrorResponse>; | ||
getRewardsForBtcAddress(options?: PaginationOptions): Promise<BurnchainRewardListResponse | BaseErrorResponse>; | ||
getRewardHoldersForBtcAddress(options?: PaginationOptions): Promise<BurnchainRewardSlotHolderListResponse | BaseErrorResponse>; | ||
getRewardSet(options: RewardSetOptions): Promise<RewardSetInfo | undefined>; | ||
getSecondsUntilNextCycle(): Promise<number>; | ||
getSecondsUntilStackingDeadline(): Promise<number>; | ||
getPoxOperationInfo(poxInfo?: PoxInfo): Promise<PoxOperationInfo>; | ||
getPoxOperationInfo(poxInfo?: V2PoxInfoResponse): Promise<PoxOperationInfo>; | ||
hasMinimumStx(): Promise<boolean>; | ||
@@ -356,3 +327,3 @@ canStack({ poxAddress, cycles }: CanLockStxOptions): Promise<StackingEligibility>; | ||
period: number; | ||
signerPrivateKey: StacksPrivateKey; | ||
signerPrivateKey: PrivateKey; | ||
maxAmount: IntegerType; | ||
@@ -362,1 +333,84 @@ authId: IntegerType; | ||
} | ||
export interface V2CoreInfoResponse { | ||
burn_block_height: number; | ||
stable_pox_consensus: string; | ||
} | ||
export interface CycleInfoResponse { | ||
id: number; | ||
min_threshold_ustx: number; | ||
stacked_ustx: number; | ||
is_pox_active: boolean; | ||
} | ||
export interface ContractVersionResponse { | ||
contract_id: ContractIdString; | ||
activation_burnchain_block_height: number; | ||
first_reward_cycle_id: number; | ||
} | ||
export interface V2PoxInfoResponse { | ||
contract_id: string; | ||
contract_versions: ContractVersionResponse[]; | ||
current_burnchain_block_height?: number; | ||
first_burnchain_block_height: number; | ||
min_amount_ustx: string; | ||
next_reward_cycle_in: number; | ||
prepare_cycle_length: number; | ||
prepare_phase_block_length: number; | ||
rejection_fraction: number; | ||
rejection_votes_left_required: number; | ||
reward_cycle_id: number; | ||
reward_cycle_length: number; | ||
reward_phase_block_length: number; | ||
reward_slots: number; | ||
current_cycle: CycleInfoResponse; | ||
next_cycle: CycleInfoResponse & { | ||
min_increment_ustx: number; | ||
prepare_phase_start_block_height: number; | ||
blocks_until_prepare_phase: number; | ||
reward_phase_start_block_height: number; | ||
blocks_until_reward_phase: number; | ||
ustx_until_pox_rejection: number; | ||
}; | ||
} | ||
export interface V1InfoBlockTimesResponse { | ||
mainnet: { | ||
target_block_time: number; | ||
}; | ||
testnet: { | ||
target_block_time: number; | ||
}; | ||
} | ||
export interface ExtendedAccountBalancesResponse { | ||
stx: { | ||
balance: string; | ||
total_sent: string; | ||
total_received: string; | ||
locked: string; | ||
lock_tx_id: string; | ||
lock_height: number; | ||
burnchain_lock_height: number; | ||
burnchain_unlock_height: number; | ||
}; | ||
fungible_tokens: any; | ||
non_fungible_tokens: any; | ||
} | ||
export interface ExtendedAccountBalances { | ||
stx: { | ||
balance: bigint; | ||
total_sent: bigint; | ||
total_received: bigint; | ||
locked: bigint; | ||
lock_tx_id: string; | ||
lock_height: number; | ||
burnchain_lock_height: number; | ||
burnchain_unlock_height: number; | ||
}; | ||
fungible_tokens: any; | ||
non_fungible_tokens: any; | ||
} | ||
export interface PaginationOptions { | ||
limit: number; | ||
offset: number; | ||
} | ||
export interface BaseErrorResponse { | ||
error: string; | ||
} |
import { hexToBytes, intToBigInt } from '@stacks/common'; | ||
import { AnchorMode, ClarityType, broadcastTransaction, bufferCV, callReadOnlyFunction, cvToString, getFee, makeContractCall, noneCV, principalCV, principalToString, someCV, stringAsciiCV, uintCV, validateStacksAddress, } from '@stacks/transactions'; | ||
import { ChainId, defaultClientOptsFromNetwork, networkFrom, } from '@stacks/network'; | ||
import { ClarityType, broadcastTransaction, bufferCV, cvToString, fetchCallReadOnlyFunction, getFee, makeContractCall, noneCV, principalCV, someCV, stringAsciiCV, uintCV, validateStacksAddress, } from '@stacks/transactions'; | ||
import { PoxOperationPeriod, StackingErrors } from './constants'; | ||
@@ -7,39 +8,54 @@ import { ensureLegacyBtcAddressForPox1, ensurePox2Activated, ensureSignerArgsReadiness, poxAddressToTuple, signPox4SignatureHash, unwrap, unwrapMap, } from './utils'; | ||
export class StackingClient { | ||
constructor(address, network) { | ||
this.address = address; | ||
this.network = network; | ||
constructor(opts) { | ||
this.address = opts.address; | ||
this.network = networkFrom(opts.network); | ||
this.client = defaultClientOptsFromNetwork(this.network, opts.client); | ||
} | ||
async getCoreInfo() { | ||
const url = this.network.getInfoUrl(); | ||
return this.network.fetchFn(url).then(res => res.json()); | ||
get baseUrl() { | ||
return this.client.baseUrl; | ||
} | ||
async getPoxInfo() { | ||
const url = this.network.getPoxInfoUrl(); | ||
return this.network.fetchFn(url).then(res => res.json()); | ||
get fetch() { | ||
return this.client.fetch; | ||
} | ||
getCoreInfo() { | ||
return this.client.fetch(`${this.client.baseUrl}/v2/info`).then(res => res.json()); | ||
} | ||
getPoxInfo() { | ||
return this.client.fetch(`${this.client.baseUrl}/v2/pox`).then(res => res.json()); | ||
} | ||
async getTargetBlockTime() { | ||
const url = this.network.getBlockTimeInfoUrl(); | ||
const res = await this.network.fetchFn(url).then(res => res.json()); | ||
if (this.network.isMainnet()) { | ||
const res = await this.client | ||
.fetch(`${this.client.baseUrl}/extended/v1/info/network_block_times`) | ||
.then((res) => res.json()); | ||
if (this.network.chainId === ChainId.Mainnet) | ||
return res.mainnet.target_block_time; | ||
} | ||
else { | ||
return res.testnet.target_block_time; | ||
} | ||
return res.testnet.target_block_time; | ||
} | ||
async getAccountStatus() { | ||
const url = this.network.getAccountApiUrl(this.address); | ||
return this.network.fetchFn(url).then(res => res.json()); | ||
return this.client | ||
.fetch(`${this.client.baseUrl}/v2/accounts/${this.address}?proof=0`) | ||
.then(res => res.json()) | ||
.then(json => { | ||
json.balance = BigInt(json.balance); | ||
json.locked = BigInt(json.locked); | ||
return json; | ||
}); | ||
} | ||
async getAccountBalance() { | ||
return this.getAccountStatus().then(res => { | ||
return BigInt(res.balance); | ||
}); | ||
return this.getAccountStatus().then(a => a.balance); | ||
} | ||
async getAccountExtendedBalances() { | ||
const url = this.network.getAccountExtendedBalancesApiUrl(this.address); | ||
return this.network.fetchFn(url).then(res => res.json()); | ||
return this.client | ||
.fetch(`${this.client.baseUrl}/extended/v1/address/${this.address}/balances`) | ||
.then(res => res.json()) | ||
.then(json => { | ||
json.stx.balance = BigInt(json.stx.balance); | ||
json.stx.total_sent = BigInt(json.stx.total_sent); | ||
json.stx.total_received = BigInt(json.stx.total_received); | ||
json.stx.locked = BigInt(json.stx.locked); | ||
return json; | ||
}); | ||
} | ||
async getAccountBalanceLocked() { | ||
return this.getAccountStatus().then(res => BigInt(res.locked)); | ||
return this.getAccountStatus().then(a => a.locked); | ||
} | ||
@@ -54,17 +70,26 @@ async getCycleDuration() { | ||
async getRewardsTotalForBtcAddress() { | ||
const url = this.network.getRewardsTotalUrl(this.address); | ||
return this.network.fetchFn(url).then(res => res.json()); | ||
return this.client | ||
.fetch(`${this.client.baseUrl}/extended/v1/burnchain/rewards/${this.address}/total`) | ||
.then(res => res.json()) | ||
.then(json => { | ||
json.reward_amount = BigInt(json.reward_amount); | ||
return json; | ||
}); | ||
} | ||
async getRewardsForBtcAddress(options) { | ||
const url = `${this.network.getRewardsUrl(this.address, options)}`; | ||
return this.network.fetchFn(url).then(res => res.json()); | ||
let url = `${this.client.baseUrl}/extended/v1/burnchain/rewards/${this.address}`; | ||
if (options) | ||
url += `?limit=${options.limit}&offset=${options.offset}`; | ||
return this.client.fetch(url).then(res => res.json()); | ||
} | ||
async getRewardHoldersForBtcAddress(options) { | ||
const url = `${this.network.getRewardHoldersUrl(this.address, options)}`; | ||
return this.network.fetchFn(url).then(res => res.json()); | ||
let url = `${this.client.baseUrl}/extended/v1/burnchain/reward_slot_holders/${this.address}`; | ||
if (options) | ||
url += `?limit=${options.limit}&offset=${options.offset}`; | ||
return this.client.fetch(url).then(res => res.json()); | ||
} | ||
async getRewardSet(options) { | ||
const [contractAddress, contractName] = this.parseContractId(options?.contractId); | ||
const result = await callReadOnlyFunction({ | ||
network: this.network, | ||
const result = await fetchCallReadOnlyFunction({ | ||
client: this.client, | ||
senderAddress: this.address, | ||
@@ -78,6 +103,6 @@ contractAddress, | ||
pox_address: { | ||
version: tuple.data['pox-addr'].data['version'].buffer, | ||
hashbytes: tuple.data['pox-addr'].data['hashbytes'].buffer, | ||
version: hexToBytes(tuple.value['pox-addr'].value['version'].value), | ||
hashbytes: hexToBytes(tuple.value['pox-addr'].value['hashbytes'].value), | ||
}, | ||
total_ustx: tuple.data['total-ustx'].value, | ||
total_ustx: BigInt(tuple.value['total-ustx'].value), | ||
})); | ||
@@ -121,4 +146,4 @@ } | ||
const [contractAddress, contractName] = this.parseContractId(poxInfo.contract_id); | ||
return callReadOnlyFunction({ | ||
network: this.network, | ||
return fetchCallReadOnlyFunction({ | ||
client: this.client, | ||
contractName, | ||
@@ -172,3 +197,3 @@ contractAddress, | ||
}); | ||
return broadcastTransaction(tx, callOptions.network); | ||
return broadcastTransaction({ transaction: tx, client: this.client }); | ||
} | ||
@@ -199,3 +224,3 @@ async stackExtend({ extendCycles, poxAddress, signerKey, signerSignature, maxAmount, authId, ...txOptions }) { | ||
}); | ||
return broadcastTransaction(tx, callOptions.network); | ||
return broadcastTransaction({ transaction: tx, client: this.client }); | ||
} | ||
@@ -225,3 +250,3 @@ async stackIncrease({ increaseBy, signerKey, signerSignature, maxAmount, authId, ...txOptions }) { | ||
}); | ||
return broadcastTransaction(tx, callOptions.network); | ||
return broadcastTransaction({ transaction: tx, client: this.client }); | ||
} | ||
@@ -244,3 +269,3 @@ async delegateStx({ amountMicroStx, delegateTo, untilBurnBlockHeight, poxAddress, ...txOptions }) { | ||
}); | ||
return broadcastTransaction(tx, callOptions.network); | ||
return broadcastTransaction({ transaction: tx, client: this.client }); | ||
} | ||
@@ -264,3 +289,3 @@ async delegateStackStx({ stacker, amountMicroStx, poxAddress, burnBlockHeight, cycles, ...txOptions }) { | ||
}); | ||
return broadcastTransaction(tx, callOptions.network); | ||
return broadcastTransaction({ transaction: tx, client: this.client }); | ||
} | ||
@@ -280,3 +305,3 @@ async delegateStackExtend({ stacker, poxAddress, extendCount, ...txOptions }) { | ||
}); | ||
return broadcastTransaction(tx, callOptions.network); | ||
return broadcastTransaction({ transaction: tx, client: this.client }); | ||
} | ||
@@ -297,3 +322,3 @@ async delegateStackIncrease({ stacker, poxAddress, increaseBy, ...txOptions }) { | ||
}); | ||
return broadcastTransaction(tx, callOptions.network); | ||
return broadcastTransaction({ transaction: tx, client: this.client }); | ||
} | ||
@@ -317,3 +342,3 @@ async stackAggregationCommit({ poxAddress, rewardCycle, signerKey, signerSignature, maxAmount, authId, ...txOptions }) { | ||
}); | ||
return broadcastTransaction(tx, callOptions.network); | ||
return broadcastTransaction({ transaction: tx, client: this.client }); | ||
} | ||
@@ -337,3 +362,3 @@ async stackAggregationCommitIndexed({ poxAddress, rewardCycle, signerKey, signerSignature, maxAmount, authId, ...txOptions }) { | ||
}); | ||
return broadcastTransaction(tx, callOptions.network); | ||
return broadcastTransaction({ transaction: tx, client: this.client }); | ||
} | ||
@@ -358,3 +383,3 @@ async stackAggregationIncrease({ poxAddress, rewardCycle, rewardIndex, signerKey, signerSignature, maxAmount, authId, ...txOptions }) { | ||
}); | ||
return broadcastTransaction(tx, callOptions.network); | ||
return broadcastTransaction({ transaction: tx, client: this.client }); | ||
} | ||
@@ -371,3 +396,3 @@ async revokeDelegateStx(arg) { | ||
}); | ||
return broadcastTransaction(tx, callOptions.network); | ||
return broadcastTransaction({ transaction: tx, client: this.client }); | ||
} | ||
@@ -390,2 +415,3 @@ getStackOptions({ amountMicroStx, poxAddress, cycles, contract, burnBlockHeight, signerKey, signerSignature, maxAmount, authId, }) { | ||
const callOptions = { | ||
client: this.client, | ||
contractAddress, | ||
@@ -397,3 +423,2 @@ contractName, | ||
network: this.network, | ||
anchorMode: AnchorMode.Any, | ||
}; | ||
@@ -413,2 +438,3 @@ return callOptions; | ||
const callOptions = { | ||
client: this.client, | ||
contractAddress, | ||
@@ -420,3 +446,2 @@ contractName, | ||
network: this.network, | ||
anchorMode: AnchorMode.Any, | ||
}; | ||
@@ -435,2 +460,3 @@ return callOptions; | ||
const callOptions = { | ||
client: this.client, | ||
contractAddress, | ||
@@ -442,3 +468,2 @@ contractName, | ||
network: this.network, | ||
anchorMode: AnchorMode.Any, | ||
}; | ||
@@ -451,2 +476,3 @@ return callOptions; | ||
const callOptions = { | ||
client: this.client, | ||
contractAddress, | ||
@@ -463,3 +489,2 @@ contractName, | ||
network: this.network, | ||
anchorMode: AnchorMode.Any, | ||
}; | ||
@@ -472,2 +497,3 @@ return callOptions; | ||
const callOptions = { | ||
client: this.client, | ||
contractAddress, | ||
@@ -485,3 +511,2 @@ contractName, | ||
network: this.network, | ||
anchorMode: AnchorMode.Any, | ||
}; | ||
@@ -494,2 +519,3 @@ return callOptions; | ||
const callOptions = { | ||
client: this.client, | ||
contractAddress, | ||
@@ -501,3 +527,2 @@ contractName, | ||
network: this.network, | ||
anchorMode: AnchorMode.Any, | ||
}; | ||
@@ -510,2 +535,3 @@ return callOptions; | ||
const callOptions = { | ||
client: this.client, | ||
contractAddress, | ||
@@ -517,3 +543,2 @@ contractName, | ||
network: this.network, | ||
anchorMode: AnchorMode.Any, | ||
}; | ||
@@ -533,2 +558,3 @@ return callOptions; | ||
const callOptions = { | ||
client: this.client, | ||
contractAddress, | ||
@@ -540,3 +566,2 @@ contractName, | ||
network: this.network, | ||
anchorMode: AnchorMode.Any, | ||
}; | ||
@@ -556,2 +581,3 @@ return callOptions; | ||
const callOptions = { | ||
client: this.client, | ||
contractAddress, | ||
@@ -563,3 +589,2 @@ contractName, | ||
network: this.network, | ||
anchorMode: AnchorMode.Any, | ||
}; | ||
@@ -579,2 +604,3 @@ return callOptions; | ||
const callOptions = { | ||
client: this.client, | ||
contractAddress, | ||
@@ -586,3 +612,2 @@ contractName, | ||
network: this.network, | ||
anchorMode: AnchorMode.Any, | ||
}; | ||
@@ -594,2 +619,3 @@ return callOptions; | ||
const callOptions = { | ||
client: this.client, | ||
contractAddress, | ||
@@ -601,3 +627,2 @@ contractName, | ||
network: this.network, | ||
anchorMode: AnchorMode.Any, | ||
}; | ||
@@ -611,3 +636,3 @@ return callOptions; | ||
const functionName = 'get-stacker-info'; | ||
return callReadOnlyFunction({ | ||
return fetchCallReadOnlyFunction({ | ||
contractAddress, | ||
@@ -618,3 +643,3 @@ contractName, | ||
functionArgs: [principalCV(this.address)], | ||
network: this.network, | ||
client: this.client, | ||
}).then((responseCV) => { | ||
@@ -624,7 +649,7 @@ if (responseCV.type === ClarityType.OptionalSome) { | ||
const tupleCV = someCV.value; | ||
const poxAddress = tupleCV.data['pox-addr']; | ||
const firstRewardCycle = tupleCV.data['first-reward-cycle']; | ||
const lockPeriod = tupleCV.data['lock-period']; | ||
const version = poxAddress.data['version']; | ||
const hashbytes = poxAddress.data['hashbytes']; | ||
const poxAddress = tupleCV.value['pox-addr']; | ||
const firstRewardCycle = tupleCV.value['first-reward-cycle']; | ||
const lockPeriod = tupleCV.value['lock-period']; | ||
const version = poxAddress.value['version']; | ||
const hashbytes = poxAddress.value['hashbytes']; | ||
return { | ||
@@ -637,4 +662,4 @@ stacked: true, | ||
pox_address: { | ||
version: version.buffer, | ||
hashbytes: hashbytes.buffer, | ||
version: hexToBytes(version.value), | ||
hashbytes: hexToBytes(hashbytes.value), | ||
}, | ||
@@ -658,19 +683,19 @@ }, | ||
const functionName = 'get-delegation-info'; | ||
return callReadOnlyFunction({ | ||
return fetchCallReadOnlyFunction({ | ||
contractAddress, | ||
contractName, | ||
functionName, | ||
functionArgs: [principalCV(this.address)], | ||
senderAddress: this.address, | ||
functionArgs: [principalCV(this.address)], | ||
network: this.network, | ||
client: this.client, | ||
}).then((responseCV) => { | ||
if (responseCV.type === ClarityType.OptionalSome) { | ||
const tupleCV = responseCV.value; | ||
const amountMicroStx = tupleCV.data['amount-ustx']; | ||
const delegatedTo = tupleCV.data['delegated-to']; | ||
const poxAddress = unwrapMap(tupleCV.data['pox-addr'], tuple => ({ | ||
version: tuple.data['version'].buffer, | ||
hashbytes: tuple.data['hashbytes'].buffer, | ||
const amountMicroStx = tupleCV.value['amount-ustx']; | ||
const delegatedTo = tupleCV.value['delegated-to']; | ||
const poxAddress = unwrapMap(tupleCV.value['pox-addr'], tuple => ({ | ||
version: hexToBytes(tuple.value['version'].value)[0], | ||
hashbytes: hexToBytes(tuple.value['hashbytes'].value), | ||
})); | ||
const untilBurnBlockHeight = unwrap(tupleCV.data['until-burn-ht']); | ||
const untilBurnBlockHeight = unwrap(tupleCV.value['until-burn-ht']); | ||
return { | ||
@@ -680,3 +705,3 @@ delegated: true, | ||
amount_micro_stx: BigInt(amountMicroStx.value), | ||
delegated_to: principalToString(delegatedTo), | ||
delegated_to: delegatedTo.value, | ||
pox_address: poxAddress, | ||
@@ -712,3 +737,3 @@ until_burn_ht: untilBurnBlockHeight ? Number(untilBurnBlockHeight.value) : undefined, | ||
]; | ||
return callReadOnlyFunction({ | ||
return fetchCallReadOnlyFunction({ | ||
contractAddress, | ||
@@ -718,4 +743,4 @@ contractName, | ||
functionArgs, | ||
network: this.network, | ||
senderAddress: this.address, | ||
client: this.client, | ||
}).then(responseCV => responseCV.type === ClarityType.ResponseOk); | ||
@@ -738,3 +763,3 @@ } | ||
const fee = getFee(tx.auth); | ||
tx.payload.functionArgs[0] = uintCV(intToBigInt(amountMicroStx, false) - fee); | ||
tx.payload.functionArgs[0] = uintCV(intToBigInt(amountMicroStx) - fee); | ||
return tx; | ||
@@ -741,0 +766,0 @@ } |
@@ -1,4 +0,4 @@ | ||
import { IntegerType } from '@stacks/common'; | ||
import { IntegerType, PrivateKey } from '@stacks/common'; | ||
import { StacksNetwork, StacksNetworkName } from '@stacks/network'; | ||
import { BufferCV, ClarityValue, OptionalCV, StacksPrivateKey, TupleCV } from '@stacks/transactions'; | ||
import { BufferCV, ClarityValue, OptionalCV, TupleCV } from '@stacks/transactions'; | ||
import { PoXAddressVersion, StackingErrors } from './constants'; | ||
@@ -19,5 +19,3 @@ export declare class InvalidAddressError extends Error { | ||
export declare function getErrorString(error: StackingErrors): string; | ||
export declare function poxAddressToTuple(poxAddress: string): TupleCV<{ | ||
[key: string]: BufferCV; | ||
}>; | ||
export declare function poxAddressToTuple(poxAddress: string): TupleCV<import("@stacks/transactions").TupleData<BufferCV>>; | ||
export declare function poxAddressToBtcAddress(version: number, hashBytes: Uint8Array, network: StacksNetworkName): string; | ||
@@ -39,3 +37,3 @@ export declare function poxAddressToBtcAddress(poxAddrClarityValue: ClarityValue, network: StacksNetworkName): string; | ||
period: number; | ||
network: StacksNetwork; | ||
network: StacksNetworkName | StacksNetwork; | ||
maxAmount: IntegerType; | ||
@@ -45,3 +43,3 @@ authId: IntegerType; | ||
export declare function signPox4SignatureHash({ topic, poxAddress, rewardCycle, period, network, privateKey, maxAmount, authId, }: Pox4SignatureOptions & { | ||
privateKey: StacksPrivateKey; | ||
privateKey: PrivateKey; | ||
}): string; | ||
@@ -52,11 +50,5 @@ export declare function verifyPox4SignatureHash({ topic, poxAddress, rewardCycle, period, network, publicKey, signature, maxAmount, authId, }: Pox4SignatureOptions & { | ||
}): boolean; | ||
export declare function pox4SignatureMessage({ topic, poxAddress, rewardCycle, period: lockPeriod, network, maxAmount, authId, }: Pox4SignatureOptions): { | ||
message: TupleCV<{ | ||
[key: string]: import("@stacks/transactions/dist/clarity/types/intCV").UIntCV | import("@stacks/transactions/dist/clarity/types/stringCV").StringAsciiCV | TupleCV<{ | ||
[key: string]: BufferCV; | ||
}>; | ||
}>; | ||
domain: TupleCV<{ | ||
[key: string]: import("@stacks/transactions/dist/clarity/types/intCV").UIntCV | import("@stacks/transactions/dist/clarity/types/stringCV").StringAsciiCV; | ||
}>; | ||
export declare function pox4SignatureMessage({ topic, poxAddress, rewardCycle, period: lockPeriod, network: networkOrName, maxAmount, authId, }: Pox4SignatureOptions): { | ||
message: TupleCV<import("@stacks/transactions").TupleData<import("@stacks/transactions").UIntCV | import("@stacks/transactions").StringAsciiCV | TupleCV<import("@stacks/transactions").TupleData<BufferCV>>>>; | ||
domain: TupleCV<import("@stacks/transactions").TupleData<import("@stacks/transactions").UIntCV | import("@stacks/transactions").StringAsciiCV>>; | ||
}; |
import { sha256 } from '@noble/hashes/sha256'; | ||
import { bech32, bech32m } from '@scure/base'; | ||
import { bigIntToBytes } from '@stacks/common'; | ||
import { bigIntToBytes, hexToBytes } from '@stacks/common'; | ||
import { base58CheckDecode, base58CheckEncode, verifyMessageSignatureRsv, } from '@stacks/encryption'; | ||
import { StacksNetworks } from '@stacks/network'; | ||
import { StacksNetworks, networkFrom } from '@stacks/network'; | ||
import { ClarityType, bufferCV, encodeStructuredData, signStructuredData, stringAsciiCV, tupleCV, uintCV, } from '@stacks/transactions'; | ||
@@ -96,10 +96,10 @@ import { B58_ADDR_PREFIXES, BitcoinNetworkVersion, PoXAddressVersion, PoxOperationPeriod, SEGWIT_ADDR_PREFIXES, SEGWIT_V0, SEGWIT_V0_ADDR_PREFIX, SEGWIT_V1, SEGWIT_V1_ADDR_PREFIX, SegwitPrefix, StackingErrors, } from './constants'; | ||
const clarityValue = poxAddrClarityValue; | ||
if (clarityValue.type !== ClarityType.Tuple || !clarityValue.data) { | ||
if (clarityValue.type !== ClarityType.Tuple || !clarityValue.value) { | ||
throw new Error('Invalid argument, expected ClarityValue to be a TupleCV'); | ||
} | ||
if (!('version' in clarityValue.data) || !('hashbytes' in clarityValue.data)) { | ||
if (!('version' in clarityValue.value) || !('hashbytes' in clarityValue.value)) { | ||
throw new Error('Invalid argument, expected Clarity tuple value to contain `version` and `hashbytes` keys'); | ||
} | ||
const versionCV = clarityValue.data['version']; | ||
const hashBytesCV = clarityValue.data['hashbytes']; | ||
const versionCV = clarityValue.value['version']; | ||
const hashBytesCV = clarityValue.value['hashbytes']; | ||
if (versionCV.type !== ClarityType.Buffer || hashBytesCV.type !== ClarityType.Buffer) { | ||
@@ -109,4 +109,4 @@ throw new Error('Invalid argument, expected Clarity tuple value to contain `version` and `hashbytes` buffers'); | ||
return { | ||
version: versionCV.buffer[0], | ||
hashBytes: hashBytesCV.buffer, | ||
version: hexToBytes(versionCV.value)[0], | ||
hashBytes: hexToBytes(hashBytesCV.value), | ||
}; | ||
@@ -276,3 +276,3 @@ } | ||
privateKey, | ||
}).data; | ||
}); | ||
} | ||
@@ -286,3 +286,4 @@ export function verifyPox4SignatureHash({ topic, poxAddress, rewardCycle, period, network, publicKey, signature, maxAmount, authId, }) { | ||
} | ||
export function pox4SignatureMessage({ topic, poxAddress, rewardCycle, period: lockPeriod, network, maxAmount, authId, }) { | ||
export function pox4SignatureMessage({ topic, poxAddress, rewardCycle, period: lockPeriod, network: networkOrName, maxAmount, authId, }) { | ||
const network = networkFrom(networkOrName); | ||
const message = tupleCV({ | ||
@@ -289,0 +290,0 @@ 'pox-addr': poxAddressToTuple(poxAddress), |
@@ -1,5 +0,6 @@ | ||
import { IntegerType } from '@stacks/common'; | ||
import { StacksNetwork } from '@stacks/network'; | ||
import { ClientOpts, IntegerType, PrivateKey } from '@stacks/common'; | ||
import { StacksNetwork, StacksNetworkName } from '@stacks/network'; | ||
import { BurnchainRewardListResponse, BurnchainRewardSlotHolderListResponse, BurnchainRewardsTotal } from '@stacks/stacks-blockchain-api-types'; | ||
import { ContractCallOptions, StacksPrivateKey, StacksTransaction, TxBroadcastResult } from '@stacks/transactions'; | ||
import type { ContractIdString } from '@stacks/transactions'; | ||
import { ContractCallOptions, StacksTransaction, TxBroadcastResult } from '@stacks/transactions'; | ||
import { PoxOperationPeriod } from './constants'; | ||
@@ -52,16 +53,2 @@ import { Pox4SignatureTopic } from './utils'; | ||
}; | ||
export interface AccountExtendedBalances { | ||
stx: { | ||
balance: IntegerType; | ||
total_sent: IntegerType; | ||
total_received: IntegerType; | ||
locked: IntegerType; | ||
lock_tx_id: string; | ||
lock_height: number; | ||
burnchain_lock_height: number; | ||
burnchain_unlock_height: number; | ||
}; | ||
fungible_tokens: any; | ||
non_fungible_tokens: any; | ||
} | ||
export type StackerInfo = { | ||
@@ -88,32 +75,9 @@ stacked: false; | ||
delegated_to: string; | ||
pox_address: { | ||
version: Uint8Array; | ||
pox_address?: { | ||
version: number; | ||
hashbytes: Uint8Array; | ||
} | undefined; | ||
until_burn_ht: number | undefined; | ||
}; | ||
until_burn_ht?: number; | ||
}; | ||
}; | ||
export interface BlockTimeInfo { | ||
mainnet: { | ||
target_block_time: number; | ||
}; | ||
testnet: { | ||
target_block_time: number; | ||
}; | ||
} | ||
export interface CoreInfo { | ||
burn_block_height: number; | ||
stable_pox_consensus: string; | ||
} | ||
export interface BalanceInfo { | ||
balance: string; | ||
nonce: number; | ||
} | ||
export interface PaginationOptions { | ||
limit: number; | ||
offset: number; | ||
} | ||
export interface RewardsError { | ||
error: string; | ||
} | ||
export interface RewardSetOptions { | ||
@@ -217,18 +181,25 @@ contractId: string; | ||
network: StacksNetwork; | ||
constructor(address: string, network: StacksNetwork); | ||
getCoreInfo(): Promise<CoreInfo>; | ||
getPoxInfo(): Promise<PoxInfo>; | ||
client: Required<ClientOpts>; | ||
constructor(opts: { | ||
address: string; | ||
network: StacksNetworkName | StacksNetwork; | ||
client?: ClientOpts; | ||
}); | ||
get baseUrl(): string; | ||
get fetch(): import("@stacks/common").FetchFn; | ||
getCoreInfo(): Promise<V2CoreInfoResponse>; | ||
getPoxInfo(): Promise<V2PoxInfoResponse>; | ||
getTargetBlockTime(): Promise<number>; | ||
getAccountStatus(): Promise<any>; | ||
getAccountBalance(): Promise<bigint>; | ||
getAccountExtendedBalances(): Promise<AccountExtendedBalances>; | ||
getAccountExtendedBalances(): Promise<ExtendedAccountBalances>; | ||
getAccountBalanceLocked(): Promise<bigint>; | ||
getCycleDuration(): Promise<number>; | ||
getRewardsTotalForBtcAddress(): Promise<BurnchainRewardsTotal | RewardsError>; | ||
getRewardsForBtcAddress(options?: PaginationOptions): Promise<BurnchainRewardListResponse | RewardsError>; | ||
getRewardHoldersForBtcAddress(options?: PaginationOptions): Promise<BurnchainRewardSlotHolderListResponse | RewardsError>; | ||
getRewardsTotalForBtcAddress(): Promise<BurnchainRewardsTotal | BaseErrorResponse>; | ||
getRewardsForBtcAddress(options?: PaginationOptions): Promise<BurnchainRewardListResponse | BaseErrorResponse>; | ||
getRewardHoldersForBtcAddress(options?: PaginationOptions): Promise<BurnchainRewardSlotHolderListResponse | BaseErrorResponse>; | ||
getRewardSet(options: RewardSetOptions): Promise<RewardSetInfo | undefined>; | ||
getSecondsUntilNextCycle(): Promise<number>; | ||
getSecondsUntilStackingDeadline(): Promise<number>; | ||
getPoxOperationInfo(poxInfo?: PoxInfo): Promise<PoxOperationInfo>; | ||
getPoxOperationInfo(poxInfo?: V2PoxInfoResponse): Promise<PoxOperationInfo>; | ||
hasMinimumStx(): Promise<boolean>; | ||
@@ -356,3 +327,3 @@ canStack({ poxAddress, cycles }: CanLockStxOptions): Promise<StackingEligibility>; | ||
period: number; | ||
signerPrivateKey: StacksPrivateKey; | ||
signerPrivateKey: PrivateKey; | ||
maxAmount: IntegerType; | ||
@@ -362,1 +333,84 @@ authId: IntegerType; | ||
} | ||
export interface V2CoreInfoResponse { | ||
burn_block_height: number; | ||
stable_pox_consensus: string; | ||
} | ||
export interface CycleInfoResponse { | ||
id: number; | ||
min_threshold_ustx: number; | ||
stacked_ustx: number; | ||
is_pox_active: boolean; | ||
} | ||
export interface ContractVersionResponse { | ||
contract_id: ContractIdString; | ||
activation_burnchain_block_height: number; | ||
first_reward_cycle_id: number; | ||
} | ||
export interface V2PoxInfoResponse { | ||
contract_id: string; | ||
contract_versions: ContractVersionResponse[]; | ||
current_burnchain_block_height?: number; | ||
first_burnchain_block_height: number; | ||
min_amount_ustx: string; | ||
next_reward_cycle_in: number; | ||
prepare_cycle_length: number; | ||
prepare_phase_block_length: number; | ||
rejection_fraction: number; | ||
rejection_votes_left_required: number; | ||
reward_cycle_id: number; | ||
reward_cycle_length: number; | ||
reward_phase_block_length: number; | ||
reward_slots: number; | ||
current_cycle: CycleInfoResponse; | ||
next_cycle: CycleInfoResponse & { | ||
min_increment_ustx: number; | ||
prepare_phase_start_block_height: number; | ||
blocks_until_prepare_phase: number; | ||
reward_phase_start_block_height: number; | ||
blocks_until_reward_phase: number; | ||
ustx_until_pox_rejection: number; | ||
}; | ||
} | ||
export interface V1InfoBlockTimesResponse { | ||
mainnet: { | ||
target_block_time: number; | ||
}; | ||
testnet: { | ||
target_block_time: number; | ||
}; | ||
} | ||
export interface ExtendedAccountBalancesResponse { | ||
stx: { | ||
balance: string; | ||
total_sent: string; | ||
total_received: string; | ||
locked: string; | ||
lock_tx_id: string; | ||
lock_height: number; | ||
burnchain_lock_height: number; | ||
burnchain_unlock_height: number; | ||
}; | ||
fungible_tokens: any; | ||
non_fungible_tokens: any; | ||
} | ||
export interface ExtendedAccountBalances { | ||
stx: { | ||
balance: bigint; | ||
total_sent: bigint; | ||
total_received: bigint; | ||
locked: bigint; | ||
lock_tx_id: string; | ||
lock_height: number; | ||
burnchain_lock_height: number; | ||
burnchain_unlock_height: number; | ||
}; | ||
fungible_tokens: any; | ||
non_fungible_tokens: any; | ||
} | ||
export interface PaginationOptions { | ||
limit: number; | ||
offset: number; | ||
} | ||
export interface BaseErrorResponse { | ||
error: string; | ||
} |
@@ -19,2 +19,3 @@ "use strict"; | ||
const common_1 = require("@stacks/common"); | ||
const network_1 = require("@stacks/network"); | ||
const transactions_1 = require("@stacks/transactions"); | ||
@@ -25,39 +26,54 @@ const constants_1 = require("./constants"); | ||
class StackingClient { | ||
constructor(address, network) { | ||
this.address = address; | ||
this.network = network; | ||
constructor(opts) { | ||
this.address = opts.address; | ||
this.network = (0, network_1.networkFrom)(opts.network); | ||
this.client = (0, network_1.defaultClientOptsFromNetwork)(this.network, opts.client); | ||
} | ||
async getCoreInfo() { | ||
const url = this.network.getInfoUrl(); | ||
return this.network.fetchFn(url).then(res => res.json()); | ||
get baseUrl() { | ||
return this.client.baseUrl; | ||
} | ||
async getPoxInfo() { | ||
const url = this.network.getPoxInfoUrl(); | ||
return this.network.fetchFn(url).then(res => res.json()); | ||
get fetch() { | ||
return this.client.fetch; | ||
} | ||
getCoreInfo() { | ||
return this.client.fetch(`${this.client.baseUrl}/v2/info`).then(res => res.json()); | ||
} | ||
getPoxInfo() { | ||
return this.client.fetch(`${this.client.baseUrl}/v2/pox`).then(res => res.json()); | ||
} | ||
async getTargetBlockTime() { | ||
const url = this.network.getBlockTimeInfoUrl(); | ||
const res = await this.network.fetchFn(url).then(res => res.json()); | ||
if (this.network.isMainnet()) { | ||
const res = await this.client | ||
.fetch(`${this.client.baseUrl}/extended/v1/info/network_block_times`) | ||
.then((res) => res.json()); | ||
if (this.network.chainId === network_1.ChainId.Mainnet) | ||
return res.mainnet.target_block_time; | ||
} | ||
else { | ||
return res.testnet.target_block_time; | ||
} | ||
return res.testnet.target_block_time; | ||
} | ||
async getAccountStatus() { | ||
const url = this.network.getAccountApiUrl(this.address); | ||
return this.network.fetchFn(url).then(res => res.json()); | ||
return this.client | ||
.fetch(`${this.client.baseUrl}/v2/accounts/${this.address}?proof=0`) | ||
.then(res => res.json()) | ||
.then(json => { | ||
json.balance = BigInt(json.balance); | ||
json.locked = BigInt(json.locked); | ||
return json; | ||
}); | ||
} | ||
async getAccountBalance() { | ||
return this.getAccountStatus().then(res => { | ||
return BigInt(res.balance); | ||
}); | ||
return this.getAccountStatus().then(a => a.balance); | ||
} | ||
async getAccountExtendedBalances() { | ||
const url = this.network.getAccountExtendedBalancesApiUrl(this.address); | ||
return this.network.fetchFn(url).then(res => res.json()); | ||
return this.client | ||
.fetch(`${this.client.baseUrl}/extended/v1/address/${this.address}/balances`) | ||
.then(res => res.json()) | ||
.then(json => { | ||
json.stx.balance = BigInt(json.stx.balance); | ||
json.stx.total_sent = BigInt(json.stx.total_sent); | ||
json.stx.total_received = BigInt(json.stx.total_received); | ||
json.stx.locked = BigInt(json.stx.locked); | ||
return json; | ||
}); | ||
} | ||
async getAccountBalanceLocked() { | ||
return this.getAccountStatus().then(res => BigInt(res.locked)); | ||
return this.getAccountStatus().then(a => a.locked); | ||
} | ||
@@ -72,17 +88,26 @@ async getCycleDuration() { | ||
async getRewardsTotalForBtcAddress() { | ||
const url = this.network.getRewardsTotalUrl(this.address); | ||
return this.network.fetchFn(url).then(res => res.json()); | ||
return this.client | ||
.fetch(`${this.client.baseUrl}/extended/v1/burnchain/rewards/${this.address}/total`) | ||
.then(res => res.json()) | ||
.then(json => { | ||
json.reward_amount = BigInt(json.reward_amount); | ||
return json; | ||
}); | ||
} | ||
async getRewardsForBtcAddress(options) { | ||
const url = `${this.network.getRewardsUrl(this.address, options)}`; | ||
return this.network.fetchFn(url).then(res => res.json()); | ||
let url = `${this.client.baseUrl}/extended/v1/burnchain/rewards/${this.address}`; | ||
if (options) | ||
url += `?limit=${options.limit}&offset=${options.offset}`; | ||
return this.client.fetch(url).then(res => res.json()); | ||
} | ||
async getRewardHoldersForBtcAddress(options) { | ||
const url = `${this.network.getRewardHoldersUrl(this.address, options)}`; | ||
return this.network.fetchFn(url).then(res => res.json()); | ||
let url = `${this.client.baseUrl}/extended/v1/burnchain/reward_slot_holders/${this.address}`; | ||
if (options) | ||
url += `?limit=${options.limit}&offset=${options.offset}`; | ||
return this.client.fetch(url).then(res => res.json()); | ||
} | ||
async getRewardSet(options) { | ||
const [contractAddress, contractName] = this.parseContractId(options?.contractId); | ||
const result = await (0, transactions_1.callReadOnlyFunction)({ | ||
network: this.network, | ||
const result = await (0, transactions_1.fetchCallReadOnlyFunction)({ | ||
client: this.client, | ||
senderAddress: this.address, | ||
@@ -96,6 +121,6 @@ contractAddress, | ||
pox_address: { | ||
version: tuple.data['pox-addr'].data['version'].buffer, | ||
hashbytes: tuple.data['pox-addr'].data['hashbytes'].buffer, | ||
version: (0, common_1.hexToBytes)(tuple.value['pox-addr'].value['version'].value), | ||
hashbytes: (0, common_1.hexToBytes)(tuple.value['pox-addr'].value['hashbytes'].value), | ||
}, | ||
total_ustx: tuple.data['total-ustx'].value, | ||
total_ustx: BigInt(tuple.value['total-ustx'].value), | ||
})); | ||
@@ -139,4 +164,4 @@ } | ||
const [contractAddress, contractName] = this.parseContractId(poxInfo.contract_id); | ||
return (0, transactions_1.callReadOnlyFunction)({ | ||
network: this.network, | ||
return (0, transactions_1.fetchCallReadOnlyFunction)({ | ||
client: this.client, | ||
contractName, | ||
@@ -190,3 +215,3 @@ contractAddress, | ||
}); | ||
return (0, transactions_1.broadcastTransaction)(tx, callOptions.network); | ||
return (0, transactions_1.broadcastTransaction)({ transaction: tx, client: this.client }); | ||
} | ||
@@ -217,3 +242,3 @@ async stackExtend({ extendCycles, poxAddress, signerKey, signerSignature, maxAmount, authId, ...txOptions }) { | ||
}); | ||
return (0, transactions_1.broadcastTransaction)(tx, callOptions.network); | ||
return (0, transactions_1.broadcastTransaction)({ transaction: tx, client: this.client }); | ||
} | ||
@@ -243,3 +268,3 @@ async stackIncrease({ increaseBy, signerKey, signerSignature, maxAmount, authId, ...txOptions }) { | ||
}); | ||
return (0, transactions_1.broadcastTransaction)(tx, callOptions.network); | ||
return (0, transactions_1.broadcastTransaction)({ transaction: tx, client: this.client }); | ||
} | ||
@@ -262,3 +287,3 @@ async delegateStx({ amountMicroStx, delegateTo, untilBurnBlockHeight, poxAddress, ...txOptions }) { | ||
}); | ||
return (0, transactions_1.broadcastTransaction)(tx, callOptions.network); | ||
return (0, transactions_1.broadcastTransaction)({ transaction: tx, client: this.client }); | ||
} | ||
@@ -282,3 +307,3 @@ async delegateStackStx({ stacker, amountMicroStx, poxAddress, burnBlockHeight, cycles, ...txOptions }) { | ||
}); | ||
return (0, transactions_1.broadcastTransaction)(tx, callOptions.network); | ||
return (0, transactions_1.broadcastTransaction)({ transaction: tx, client: this.client }); | ||
} | ||
@@ -298,3 +323,3 @@ async delegateStackExtend({ stacker, poxAddress, extendCount, ...txOptions }) { | ||
}); | ||
return (0, transactions_1.broadcastTransaction)(tx, callOptions.network); | ||
return (0, transactions_1.broadcastTransaction)({ transaction: tx, client: this.client }); | ||
} | ||
@@ -315,3 +340,3 @@ async delegateStackIncrease({ stacker, poxAddress, increaseBy, ...txOptions }) { | ||
}); | ||
return (0, transactions_1.broadcastTransaction)(tx, callOptions.network); | ||
return (0, transactions_1.broadcastTransaction)({ transaction: tx, client: this.client }); | ||
} | ||
@@ -335,3 +360,3 @@ async stackAggregationCommit({ poxAddress, rewardCycle, signerKey, signerSignature, maxAmount, authId, ...txOptions }) { | ||
}); | ||
return (0, transactions_1.broadcastTransaction)(tx, callOptions.network); | ||
return (0, transactions_1.broadcastTransaction)({ transaction: tx, client: this.client }); | ||
} | ||
@@ -355,3 +380,3 @@ async stackAggregationCommitIndexed({ poxAddress, rewardCycle, signerKey, signerSignature, maxAmount, authId, ...txOptions }) { | ||
}); | ||
return (0, transactions_1.broadcastTransaction)(tx, callOptions.network); | ||
return (0, transactions_1.broadcastTransaction)({ transaction: tx, client: this.client }); | ||
} | ||
@@ -376,3 +401,3 @@ async stackAggregationIncrease({ poxAddress, rewardCycle, rewardIndex, signerKey, signerSignature, maxAmount, authId, ...txOptions }) { | ||
}); | ||
return (0, transactions_1.broadcastTransaction)(tx, callOptions.network); | ||
return (0, transactions_1.broadcastTransaction)({ transaction: tx, client: this.client }); | ||
} | ||
@@ -389,3 +414,3 @@ async revokeDelegateStx(arg) { | ||
}); | ||
return (0, transactions_1.broadcastTransaction)(tx, callOptions.network); | ||
return (0, transactions_1.broadcastTransaction)({ transaction: tx, client: this.client }); | ||
} | ||
@@ -408,2 +433,3 @@ getStackOptions({ amountMicroStx, poxAddress, cycles, contract, burnBlockHeight, signerKey, signerSignature, maxAmount, authId, }) { | ||
const callOptions = { | ||
client: this.client, | ||
contractAddress, | ||
@@ -415,3 +441,2 @@ contractName, | ||
network: this.network, | ||
anchorMode: transactions_1.AnchorMode.Any, | ||
}; | ||
@@ -431,2 +456,3 @@ return callOptions; | ||
const callOptions = { | ||
client: this.client, | ||
contractAddress, | ||
@@ -438,3 +464,2 @@ contractName, | ||
network: this.network, | ||
anchorMode: transactions_1.AnchorMode.Any, | ||
}; | ||
@@ -453,2 +478,3 @@ return callOptions; | ||
const callOptions = { | ||
client: this.client, | ||
contractAddress, | ||
@@ -460,3 +486,2 @@ contractName, | ||
network: this.network, | ||
anchorMode: transactions_1.AnchorMode.Any, | ||
}; | ||
@@ -469,2 +494,3 @@ return callOptions; | ||
const callOptions = { | ||
client: this.client, | ||
contractAddress, | ||
@@ -481,3 +507,2 @@ contractName, | ||
network: this.network, | ||
anchorMode: transactions_1.AnchorMode.Any, | ||
}; | ||
@@ -490,2 +515,3 @@ return callOptions; | ||
const callOptions = { | ||
client: this.client, | ||
contractAddress, | ||
@@ -503,3 +529,2 @@ contractName, | ||
network: this.network, | ||
anchorMode: transactions_1.AnchorMode.Any, | ||
}; | ||
@@ -512,2 +537,3 @@ return callOptions; | ||
const callOptions = { | ||
client: this.client, | ||
contractAddress, | ||
@@ -519,3 +545,2 @@ contractName, | ||
network: this.network, | ||
anchorMode: transactions_1.AnchorMode.Any, | ||
}; | ||
@@ -528,2 +553,3 @@ return callOptions; | ||
const callOptions = { | ||
client: this.client, | ||
contractAddress, | ||
@@ -535,3 +561,2 @@ contractName, | ||
network: this.network, | ||
anchorMode: transactions_1.AnchorMode.Any, | ||
}; | ||
@@ -551,2 +576,3 @@ return callOptions; | ||
const callOptions = { | ||
client: this.client, | ||
contractAddress, | ||
@@ -558,3 +584,2 @@ contractName, | ||
network: this.network, | ||
anchorMode: transactions_1.AnchorMode.Any, | ||
}; | ||
@@ -574,2 +599,3 @@ return callOptions; | ||
const callOptions = { | ||
client: this.client, | ||
contractAddress, | ||
@@ -581,3 +607,2 @@ contractName, | ||
network: this.network, | ||
anchorMode: transactions_1.AnchorMode.Any, | ||
}; | ||
@@ -597,2 +622,3 @@ return callOptions; | ||
const callOptions = { | ||
client: this.client, | ||
contractAddress, | ||
@@ -604,3 +630,2 @@ contractName, | ||
network: this.network, | ||
anchorMode: transactions_1.AnchorMode.Any, | ||
}; | ||
@@ -612,2 +637,3 @@ return callOptions; | ||
const callOptions = { | ||
client: this.client, | ||
contractAddress, | ||
@@ -619,3 +645,2 @@ contractName, | ||
network: this.network, | ||
anchorMode: transactions_1.AnchorMode.Any, | ||
}; | ||
@@ -629,3 +654,3 @@ return callOptions; | ||
const functionName = 'get-stacker-info'; | ||
return (0, transactions_1.callReadOnlyFunction)({ | ||
return (0, transactions_1.fetchCallReadOnlyFunction)({ | ||
contractAddress, | ||
@@ -636,3 +661,3 @@ contractName, | ||
functionArgs: [(0, transactions_1.principalCV)(this.address)], | ||
network: this.network, | ||
client: this.client, | ||
}).then((responseCV) => { | ||
@@ -642,7 +667,7 @@ if (responseCV.type === transactions_1.ClarityType.OptionalSome) { | ||
const tupleCV = someCV.value; | ||
const poxAddress = tupleCV.data['pox-addr']; | ||
const firstRewardCycle = tupleCV.data['first-reward-cycle']; | ||
const lockPeriod = tupleCV.data['lock-period']; | ||
const version = poxAddress.data['version']; | ||
const hashbytes = poxAddress.data['hashbytes']; | ||
const poxAddress = tupleCV.value['pox-addr']; | ||
const firstRewardCycle = tupleCV.value['first-reward-cycle']; | ||
const lockPeriod = tupleCV.value['lock-period']; | ||
const version = poxAddress.value['version']; | ||
const hashbytes = poxAddress.value['hashbytes']; | ||
return { | ||
@@ -655,4 +680,4 @@ stacked: true, | ||
pox_address: { | ||
version: version.buffer, | ||
hashbytes: hashbytes.buffer, | ||
version: (0, common_1.hexToBytes)(version.value), | ||
hashbytes: (0, common_1.hexToBytes)(hashbytes.value), | ||
}, | ||
@@ -676,19 +701,19 @@ }, | ||
const functionName = 'get-delegation-info'; | ||
return (0, transactions_1.callReadOnlyFunction)({ | ||
return (0, transactions_1.fetchCallReadOnlyFunction)({ | ||
contractAddress, | ||
contractName, | ||
functionName, | ||
functionArgs: [(0, transactions_1.principalCV)(this.address)], | ||
senderAddress: this.address, | ||
functionArgs: [(0, transactions_1.principalCV)(this.address)], | ||
network: this.network, | ||
client: this.client, | ||
}).then((responseCV) => { | ||
if (responseCV.type === transactions_1.ClarityType.OptionalSome) { | ||
const tupleCV = responseCV.value; | ||
const amountMicroStx = tupleCV.data['amount-ustx']; | ||
const delegatedTo = tupleCV.data['delegated-to']; | ||
const poxAddress = (0, utils_1.unwrapMap)(tupleCV.data['pox-addr'], tuple => ({ | ||
version: tuple.data['version'].buffer, | ||
hashbytes: tuple.data['hashbytes'].buffer, | ||
const amountMicroStx = tupleCV.value['amount-ustx']; | ||
const delegatedTo = tupleCV.value['delegated-to']; | ||
const poxAddress = (0, utils_1.unwrapMap)(tupleCV.value['pox-addr'], tuple => ({ | ||
version: (0, common_1.hexToBytes)(tuple.value['version'].value)[0], | ||
hashbytes: (0, common_1.hexToBytes)(tuple.value['hashbytes'].value), | ||
})); | ||
const untilBurnBlockHeight = (0, utils_1.unwrap)(tupleCV.data['until-burn-ht']); | ||
const untilBurnBlockHeight = (0, utils_1.unwrap)(tupleCV.value['until-burn-ht']); | ||
return { | ||
@@ -698,3 +723,3 @@ delegated: true, | ||
amount_micro_stx: BigInt(amountMicroStx.value), | ||
delegated_to: (0, transactions_1.principalToString)(delegatedTo), | ||
delegated_to: delegatedTo.value, | ||
pox_address: poxAddress, | ||
@@ -730,3 +755,3 @@ until_burn_ht: untilBurnBlockHeight ? Number(untilBurnBlockHeight.value) : undefined, | ||
]; | ||
return (0, transactions_1.callReadOnlyFunction)({ | ||
return (0, transactions_1.fetchCallReadOnlyFunction)({ | ||
contractAddress, | ||
@@ -736,4 +761,4 @@ contractName, | ||
functionArgs, | ||
network: this.network, | ||
senderAddress: this.address, | ||
client: this.client, | ||
}).then(responseCV => responseCV.type === transactions_1.ClarityType.ResponseOk); | ||
@@ -756,3 +781,3 @@ } | ||
const fee = (0, transactions_1.getFee)(tx.auth); | ||
tx.payload.functionArgs[0] = (0, transactions_1.uintCV)((0, common_1.intToBigInt)(amountMicroStx, false) - fee); | ||
tx.payload.functionArgs[0] = (0, transactions_1.uintCV)((0, common_1.intToBigInt)(amountMicroStx) - fee); | ||
return tx; | ||
@@ -759,0 +784,0 @@ } |
@@ -1,4 +0,4 @@ | ||
import { IntegerType } from '@stacks/common'; | ||
import { IntegerType, PrivateKey } from '@stacks/common'; | ||
import { StacksNetwork, StacksNetworkName } from '@stacks/network'; | ||
import { BufferCV, ClarityValue, OptionalCV, StacksPrivateKey, TupleCV } from '@stacks/transactions'; | ||
import { BufferCV, ClarityValue, OptionalCV, TupleCV } from '@stacks/transactions'; | ||
import { PoXAddressVersion, StackingErrors } from './constants'; | ||
@@ -19,5 +19,3 @@ export declare class InvalidAddressError extends Error { | ||
export declare function getErrorString(error: StackingErrors): string; | ||
export declare function poxAddressToTuple(poxAddress: string): TupleCV<{ | ||
[key: string]: BufferCV; | ||
}>; | ||
export declare function poxAddressToTuple(poxAddress: string): TupleCV<import("@stacks/transactions").TupleData<BufferCV>>; | ||
export declare function poxAddressToBtcAddress(version: number, hashBytes: Uint8Array, network: StacksNetworkName): string; | ||
@@ -39,3 +37,3 @@ export declare function poxAddressToBtcAddress(poxAddrClarityValue: ClarityValue, network: StacksNetworkName): string; | ||
period: number; | ||
network: StacksNetwork; | ||
network: StacksNetworkName | StacksNetwork; | ||
maxAmount: IntegerType; | ||
@@ -45,3 +43,3 @@ authId: IntegerType; | ||
export declare function signPox4SignatureHash({ topic, poxAddress, rewardCycle, period, network, privateKey, maxAmount, authId, }: Pox4SignatureOptions & { | ||
privateKey: StacksPrivateKey; | ||
privateKey: PrivateKey; | ||
}): string; | ||
@@ -52,11 +50,5 @@ export declare function verifyPox4SignatureHash({ topic, poxAddress, rewardCycle, period, network, publicKey, signature, maxAmount, authId, }: Pox4SignatureOptions & { | ||
}): boolean; | ||
export declare function pox4SignatureMessage({ topic, poxAddress, rewardCycle, period: lockPeriod, network, maxAmount, authId, }: Pox4SignatureOptions): { | ||
message: TupleCV<{ | ||
[key: string]: import("@stacks/transactions/dist/clarity/types/intCV").UIntCV | import("@stacks/transactions/dist/clarity/types/stringCV").StringAsciiCV | TupleCV<{ | ||
[key: string]: BufferCV; | ||
}>; | ||
}>; | ||
domain: TupleCV<{ | ||
[key: string]: import("@stacks/transactions/dist/clarity/types/intCV").UIntCV | import("@stacks/transactions/dist/clarity/types/stringCV").StringAsciiCV; | ||
}>; | ||
export declare function pox4SignatureMessage({ topic, poxAddress, rewardCycle, period: lockPeriod, network: networkOrName, maxAmount, authId, }: Pox4SignatureOptions): { | ||
message: TupleCV<import("@stacks/transactions").TupleData<import("@stacks/transactions").UIntCV | import("@stacks/transactions").StringAsciiCV | TupleCV<import("@stacks/transactions").TupleData<BufferCV>>>>; | ||
domain: TupleCV<import("@stacks/transactions").TupleData<import("@stacks/transactions").UIntCV | import("@stacks/transactions").StringAsciiCV>>; | ||
}; |
@@ -102,10 +102,10 @@ "use strict"; | ||
const clarityValue = poxAddrClarityValue; | ||
if (clarityValue.type !== transactions_1.ClarityType.Tuple || !clarityValue.data) { | ||
if (clarityValue.type !== transactions_1.ClarityType.Tuple || !clarityValue.value) { | ||
throw new Error('Invalid argument, expected ClarityValue to be a TupleCV'); | ||
} | ||
if (!('version' in clarityValue.data) || !('hashbytes' in clarityValue.data)) { | ||
if (!('version' in clarityValue.value) || !('hashbytes' in clarityValue.value)) { | ||
throw new Error('Invalid argument, expected Clarity tuple value to contain `version` and `hashbytes` keys'); | ||
} | ||
const versionCV = clarityValue.data['version']; | ||
const hashBytesCV = clarityValue.data['hashbytes']; | ||
const versionCV = clarityValue.value['version']; | ||
const hashBytesCV = clarityValue.value['hashbytes']; | ||
if (versionCV.type !== transactions_1.ClarityType.Buffer || hashBytesCV.type !== transactions_1.ClarityType.Buffer) { | ||
@@ -115,4 +115,4 @@ throw new Error('Invalid argument, expected Clarity tuple value to contain `version` and `hashbytes` buffers'); | ||
return { | ||
version: versionCV.buffer[0], | ||
hashBytes: hashBytesCV.buffer, | ||
version: (0, common_1.hexToBytes)(versionCV.value)[0], | ||
hashBytes: (0, common_1.hexToBytes)(hashBytesCV.value), | ||
}; | ||
@@ -291,3 +291,3 @@ } | ||
privateKey, | ||
}).data; | ||
}); | ||
} | ||
@@ -303,3 +303,4 @@ exports.signPox4SignatureHash = signPox4SignatureHash; | ||
exports.verifyPox4SignatureHash = verifyPox4SignatureHash; | ||
function pox4SignatureMessage({ topic, poxAddress, rewardCycle, period: lockPeriod, network, maxAmount, authId, }) { | ||
function pox4SignatureMessage({ topic, poxAddress, rewardCycle, period: lockPeriod, network: networkOrName, maxAmount, authId, }) { | ||
const network = (0, network_1.networkFrom)(networkOrName); | ||
const message = (0, transactions_1.tupleCV)({ | ||
@@ -306,0 +307,0 @@ 'pox-addr': poxAddressToTuple(poxAddress), |
{ | ||
"name": "@stacks/stacking", | ||
"version": "6.17.0", | ||
"version": "7.0.0-next.70+0adf46c4", | ||
"description": "Library for Stacking.", | ||
@@ -25,7 +25,7 @@ "license": "MIT", | ||
"@scure/base": "1.1.1", | ||
"@stacks/common": "^6.16.0", | ||
"@stacks/encryption": "^6.17.0", | ||
"@stacks/network": "^6.17.0", | ||
"@stacks/common": "^7.0.0-next.70+0adf46c4", | ||
"@stacks/encryption": "^7.0.0-next.70+0adf46c4", | ||
"@stacks/network": "^7.0.0-next.70+0adf46c4", | ||
"@stacks/stacks-blockchain-api-types": "^0.61.0", | ||
"@stacks/transactions": "^6.17.0", | ||
"@stacks/transactions": "^7.0.0-next.70+0adf46c4", | ||
"bs58": "^5.0.0" | ||
@@ -35,2 +35,3 @@ }, | ||
"@stacks/blockchain-api-client": "^7.3.0", | ||
"@stacks/internal": "^undefined", | ||
"jest-fetch-mock": "^3.0.3", | ||
@@ -62,3 +63,3 @@ "process": "^0.11.10", | ||
}, | ||
"gitHead": "626e1ca12e300838504dc35b32bfae7a0ebfe109" | ||
"gitHead": "0adf46c4eadac85f234140dc2df0e5d06b0ca775" | ||
} |
467
src/index.ts
@@ -1,4 +0,10 @@ | ||
import { IntegerType, hexToBytes, intToBigInt } from '@stacks/common'; | ||
import { StacksNetwork } from '@stacks/network'; | ||
import { ClientOpts, IntegerType, PrivateKey, hexToBytes, intToBigInt } from '@stacks/common'; | ||
import { | ||
ChainId, | ||
StacksNetwork, | ||
StacksNetworkName, | ||
defaultClientOptsFromNetwork, | ||
networkFrom, | ||
} from '@stacks/network'; | ||
import { | ||
BurnchainRewardListResponse, | ||
@@ -8,4 +14,4 @@ BurnchainRewardSlotHolderListResponse, | ||
} from '@stacks/stacks-blockchain-api-types'; | ||
import type { ContractIdString } from '@stacks/transactions'; | ||
import { | ||
AnchorMode, | ||
BufferCV, | ||
@@ -19,3 +25,2 @@ ClarityType, | ||
ResponseErrorCV, | ||
StacksPrivateKey, | ||
StacksTransaction, | ||
@@ -27,4 +32,4 @@ TupleCV, | ||
bufferCV, | ||
callReadOnlyFunction, | ||
cvToString, | ||
fetchCallReadOnlyFunction, | ||
getFee, | ||
@@ -34,3 +39,2 @@ makeContractCall, | ||
principalCV, | ||
principalToString, | ||
someCV, | ||
@@ -112,17 +116,2 @@ stringAsciiCV, | ||
export interface AccountExtendedBalances { | ||
stx: { | ||
balance: IntegerType; | ||
total_sent: IntegerType; | ||
total_received: IntegerType; | ||
locked: IntegerType; | ||
lock_tx_id: string; | ||
lock_height: number; | ||
burnchain_lock_height: number; | ||
burnchain_unlock_height: number; | ||
}; | ||
fungible_tokens: any; | ||
non_fungible_tokens: any; | ||
} | ||
export type StackerInfo = | ||
@@ -154,40 +143,10 @@ | { | ||
delegated_to: string; | ||
pox_address: | ||
| { | ||
version: Uint8Array; | ||
hashbytes: Uint8Array; | ||
} | ||
| undefined; | ||
until_burn_ht: number | undefined; | ||
pox_address?: { | ||
version: number; | ||
hashbytes: Uint8Array; | ||
}; | ||
until_burn_ht?: number; | ||
}; | ||
}; | ||
export interface BlockTimeInfo { | ||
mainnet: { | ||
target_block_time: number; | ||
}; | ||
testnet: { | ||
target_block_time: number; | ||
}; | ||
} | ||
export interface CoreInfo { | ||
burn_block_height: number; | ||
stable_pox_consensus: string; | ||
} | ||
export interface BalanceInfo { | ||
balance: string; | ||
nonce: number; | ||
} | ||
export interface PaginationOptions { | ||
limit: number; | ||
offset: number; | ||
} | ||
export interface RewardsError { | ||
error: string; | ||
} | ||
export interface RewardSetOptions { | ||
@@ -378,79 +337,84 @@ contractId: string; | ||
export class StackingClient { | ||
constructor( | ||
public address: string, | ||
public network: StacksNetwork | ||
) {} | ||
public address: string; | ||
public network: StacksNetwork; | ||
/** | ||
* Get stacks node info | ||
* | ||
* @returns {Promise<CoreInfo>} that resolves to a CoreInfo response if the operation succeeds | ||
*/ | ||
async getCoreInfo(): Promise<CoreInfo> { | ||
const url = this.network.getInfoUrl(); | ||
return this.network.fetchFn(url).then(res => res.json()); | ||
public client: Required<ClientOpts>; | ||
// todo: make more constructor opts optional | ||
constructor(opts: { | ||
address: string; | ||
network: StacksNetworkName | StacksNetwork; | ||
client?: ClientOpts; | ||
}) { | ||
this.address = opts.address; | ||
this.network = networkFrom(opts.network); | ||
this.client = defaultClientOptsFromNetwork(this.network, opts.client); | ||
} | ||
/** | ||
* Get stacks node pox info | ||
* | ||
* @returns {Promise<PoxInfo>} that resolves to a PoxInfo response if the operation succeeds | ||
*/ | ||
async getPoxInfo(): Promise<PoxInfo> { | ||
const url = this.network.getPoxInfoUrl(); | ||
return this.network.fetchFn(url).then(res => res.json()); | ||
get baseUrl() { | ||
return this.client.baseUrl; | ||
} | ||
/** | ||
* Get stacks node target block time | ||
* | ||
* @returns {Promise<number>} resolves to a number if the operation succeeds | ||
*/ | ||
get fetch() { | ||
return this.client.fetch; | ||
} | ||
/** @deprecated Kept for backwards compatibility, may be removed in the future */ | ||
getCoreInfo(): Promise<V2CoreInfoResponse> { | ||
return this.client.fetch(`${this.client.baseUrl}/v2/info`).then(res => res.json()); | ||
} | ||
/** @deprecated Kept for backwards compatibility, may be removed in the future */ | ||
getPoxInfo(): Promise<V2PoxInfoResponse> { | ||
return this.client.fetch(`${this.client.baseUrl}/v2/pox`).then(res => res.json()); | ||
} | ||
/** @deprecated Kept for backwards compatibility, may be removed in the future */ | ||
async getTargetBlockTime(): Promise<number> { | ||
const url = this.network.getBlockTimeInfoUrl(); | ||
const res = await this.network.fetchFn(url).then(res => res.json()); | ||
const res = await this.client | ||
.fetch(`${this.client.baseUrl}/extended/v1/info/network_block_times`) | ||
.then((res: any): V1InfoBlockTimesResponse => res.json()); | ||
if (this.network.isMainnet()) { | ||
return res.mainnet.target_block_time; | ||
} else { | ||
return res.testnet.target_block_time; | ||
} | ||
if (this.network.chainId === ChainId.Mainnet) return res.mainnet.target_block_time; | ||
return res.testnet.target_block_time; | ||
} | ||
/** Get account status */ | ||
async getAccountStatus(): Promise<any> { | ||
const url = this.network.getAccountApiUrl(this.address); | ||
return this.network.fetchFn(url).then(res => res.json()); | ||
// todo: add types for response | ||
return this.client | ||
.fetch(`${this.client.baseUrl}/v2/accounts/${this.address}?proof=0`) | ||
.then(res => res.json()) | ||
.then(json => { | ||
json.balance = BigInt(json.balance); | ||
json.locked = BigInt(json.locked); | ||
return json; | ||
}); | ||
} | ||
/** | ||
* Get account balance | ||
* @returns {Promise<bigint>} resolves to a bigint if the operation succeeds | ||
*/ | ||
/** Get account balance */ | ||
async getAccountBalance(): Promise<bigint> { | ||
return this.getAccountStatus().then(res => { | ||
return BigInt(res.balance); | ||
}); | ||
return this.getAccountStatus().then(a => a.balance); | ||
} | ||
/** | ||
* Get extended account balances | ||
* @returns {Promise<AccountExtendedBalances>} resolves to an AccountExtendedBalances response if the operation succeeds | ||
*/ | ||
async getAccountExtendedBalances(): Promise<AccountExtendedBalances> { | ||
const url = this.network.getAccountExtendedBalancesApiUrl(this.address); | ||
return this.network.fetchFn(url).then(res => res.json()); | ||
/** Get extended account balances */ | ||
async getAccountExtendedBalances(): Promise<ExtendedAccountBalances> { | ||
return this.client | ||
.fetch(`${this.client.baseUrl}/extended/v1/address/${this.address}/balances`) | ||
.then(res => res.json()) | ||
.then(json => { | ||
json.stx.balance = BigInt(json.stx.balance); | ||
json.stx.total_sent = BigInt(json.stx.total_sent); | ||
json.stx.total_received = BigInt(json.stx.total_received); | ||
json.stx.locked = BigInt(json.stx.locked); | ||
return json; | ||
}); | ||
} | ||
/** | ||
* Get account balance of locked tokens | ||
* @returns {Promise<bigint>} resolves to a bigint if the operation succeeds | ||
*/ | ||
/** Get account balance of locked tokens */ | ||
async getAccountBalanceLocked(): Promise<bigint> { | ||
return this.getAccountStatus().then(res => BigInt(res.locked)); | ||
return this.getAccountStatus().then(a => a.locked); | ||
} | ||
/** | ||
* Get reward cycle duration in seconds | ||
* @returns {Promise<number>} resolves to a number if the operation succeeds | ||
*/ | ||
/** Get reward cycle duration in seconds */ | ||
async getCycleDuration(): Promise<number> { | ||
@@ -467,41 +431,38 @@ const poxInfoPromise = this.getPoxInfo(); | ||
/** | ||
* Get the total burnchain rewards total for the set address | ||
* @returns {Promise<TotalRewardsResponse | RewardsError>} that resolves to TotalRewardsResponse or RewardsError | ||
*/ | ||
async getRewardsTotalForBtcAddress(): Promise<BurnchainRewardsTotal | RewardsError> { | ||
const url = this.network.getRewardsTotalUrl(this.address); | ||
return this.network.fetchFn(url).then(res => res.json()); | ||
/** Get the total burnchain rewards total for the set address */ | ||
async getRewardsTotalForBtcAddress(): Promise<BurnchainRewardsTotal | BaseErrorResponse> { | ||
return this.client | ||
.fetch(`${this.client.baseUrl}/extended/v1/burnchain/rewards/${this.address}/total`) | ||
.then(res => res.json()) | ||
.then(json => { | ||
json.reward_amount = BigInt(json.reward_amount); | ||
return json; | ||
}); | ||
} | ||
/** | ||
* Get burnchain rewards for the set address | ||
* @returns {Promise<RewardsResponse | RewardsError>} that resolves to RewardsResponse or RewardsError | ||
*/ | ||
/** Get burnchain rewards for the set address */ | ||
async getRewardsForBtcAddress( | ||
options?: PaginationOptions | ||
): Promise<BurnchainRewardListResponse | RewardsError> { | ||
const url = `${this.network.getRewardsUrl(this.address, options)}`; | ||
return this.network.fetchFn(url).then(res => res.json()); | ||
): Promise<BurnchainRewardListResponse | BaseErrorResponse> { | ||
let url = `${this.client.baseUrl}/extended/v1/burnchain/rewards/${this.address}`; | ||
if (options) url += `?limit=${options.limit}&offset=${options.offset}`; | ||
return this.client.fetch(url).then(res => res.json()); | ||
} | ||
/** | ||
* Get burnchain rewards holders for the set address | ||
* @returns {Promise<RewardHoldersResponse | RewardsError>} that resolves to RewardHoldersResponse or RewardsError | ||
*/ | ||
/** Get burnchain rewards holders for the set address */ | ||
async getRewardHoldersForBtcAddress( | ||
options?: PaginationOptions | ||
): Promise<BurnchainRewardSlotHolderListResponse | RewardsError> { | ||
const url = `${this.network.getRewardHoldersUrl(this.address, options)}`; | ||
return this.network.fetchFn(url).then(res => res.json()); | ||
): Promise<BurnchainRewardSlotHolderListResponse | BaseErrorResponse> { | ||
let url = `${this.client.baseUrl}/extended/v1/burnchain/reward_slot_holders/${this.address}`; | ||
if (options) url += `?limit=${options.limit}&offset=${options.offset}`; | ||
return this.client.fetch(url).then(res => res.json()); | ||
} | ||
/** | ||
* Get PoX address from reward set by index | ||
* @returns {Promise<RewardSetInfo | undefined>} that resolves to RewardSetInfo if the entry exists | ||
*/ | ||
/** Get PoX address from reward set by index (if it exists) */ | ||
async getRewardSet(options: RewardSetOptions): Promise<RewardSetInfo | undefined> { | ||
const [contractAddress, contractName] = this.parseContractId(options?.contractId); | ||
const result = await callReadOnlyFunction({ | ||
network: this.network, | ||
const result = await fetchCallReadOnlyFunction({ | ||
client: this.client, | ||
senderAddress: this.address, | ||
@@ -516,6 +477,10 @@ contractAddress, | ||
pox_address: { | ||
version: ((tuple.data['pox-addr'] as TupleCV).data['version'] as BufferCV).buffer, | ||
hashbytes: ((tuple.data['pox-addr'] as TupleCV).data['hashbytes'] as BufferCV).buffer, | ||
version: hexToBytes( | ||
((tuple.value['pox-addr'] as TupleCV).value['version'] as BufferCV).value | ||
), | ||
hashbytes: hexToBytes( | ||
((tuple.value['pox-addr'] as TupleCV).value['hashbytes'] as BufferCV).value | ||
), | ||
}, | ||
total_ustx: (tuple.data['total-ustx'] as UIntCV).value, | ||
total_ustx: BigInt((tuple.value['total-ustx'] as UIntCV).value), | ||
})); | ||
@@ -526,6 +491,3 @@ } | ||
* Get number of seconds until next reward cycle | ||
* @returns {Promise<number>} resolves to a number if the operation succeeds | ||
* | ||
* See also: | ||
* - {@link getSecondsUntilStackingDeadline} | ||
* @see {@link getSecondsUntilStackingDeadline} | ||
*/ | ||
@@ -552,7 +514,5 @@ async getSecondsUntilNextCycle(): Promise<number> { | ||
* transactions to be included in the upcoming reward cycle. | ||
* @returns {Promise<number>} resolves to a number of seconds if the operation succeeds. | ||
* @returns number of seconds | ||
* **⚠️ Attention**: The returned number of seconds can be negative if the deadline has passed and the prepare phase has started. | ||
* | ||
* See also: | ||
* - {@link getSecondsUntilNextCycle} | ||
* @see {@link getSecondsUntilNextCycle} | ||
*/ | ||
@@ -576,6 +536,4 @@ async getSecondsUntilStackingDeadline(): Promise<number> { | ||
* - Period 3: This is after cycle (N+1) has begun. Original PoX contract state will no longer have any impact on reward sets, account lock status, etc. | ||
* | ||
* @returns {Promise<PoxOperationInfo>} that resolves to PoX operation info | ||
*/ | ||
async getPoxOperationInfo(poxInfo?: PoxInfo): Promise<PoxOperationInfo> { | ||
async getPoxOperationInfo(poxInfo?: V2PoxInfoResponse): Promise<PoxOperationInfo> { | ||
poxInfo = poxInfo ?? (await this.getPoxInfo()); | ||
@@ -585,7 +543,7 @@ | ||
(a, b) => a.activation_burnchain_block_height - b.activation_burnchain_block_height | ||
); // by activation height ASC (earliest first) | ||
); // by activation height ASC (earliest first) | ||
const [pox1, pox2, pox3, pox4] = poxContractVersions; | ||
const activatedPoxs = poxContractVersions.filter( | ||
(c: ContractVersion) => | ||
(c: ContractVersionResponse) => | ||
(poxInfo?.current_burnchain_block_height as number) >= c.activation_burnchain_block_height | ||
@@ -624,4 +582,4 @@ ); | ||
return callReadOnlyFunction({ | ||
network: this.network, | ||
return fetchCallReadOnlyFunction({ | ||
client: this.client, | ||
contractName, | ||
@@ -696,3 +654,3 @@ contractAddress, | ||
return broadcastTransaction(tx, callOptions.network as StacksNetwork); | ||
return broadcastTransaction({ transaction: tx, client: this.client }); | ||
} | ||
@@ -743,3 +701,3 @@ | ||
return broadcastTransaction(tx, callOptions.network as StacksNetwork); | ||
return broadcastTransaction({ transaction: tx, client: this.client }); | ||
} | ||
@@ -785,3 +743,3 @@ | ||
return broadcastTransaction(tx, callOptions.network as StacksNetwork); | ||
return broadcastTransaction({ transaction: tx, client: this.client }); | ||
} | ||
@@ -823,3 +781,3 @@ | ||
return broadcastTransaction(tx, callOptions.network as StacksNetwork); | ||
return broadcastTransaction({ transaction: tx, client: this.client }); | ||
} | ||
@@ -861,3 +819,3 @@ | ||
return broadcastTransaction(tx, callOptions.network as StacksNetwork); | ||
return broadcastTransaction({ transaction: tx, client: this.client }); | ||
} | ||
@@ -893,3 +851,3 @@ | ||
return broadcastTransaction(tx, callOptions.network as StacksNetwork); | ||
return broadcastTransaction({ transaction: tx, client: this.client }); | ||
} | ||
@@ -924,3 +882,3 @@ | ||
return broadcastTransaction(tx, callOptions.network as StacksNetwork); | ||
return broadcastTransaction({ transaction: tx, client: this.client }); | ||
} | ||
@@ -960,3 +918,3 @@ | ||
return broadcastTransaction(tx, callOptions.network as StacksNetwork); | ||
return broadcastTransaction({ transaction: tx, client: this.client }); | ||
} | ||
@@ -1009,3 +967,3 @@ | ||
return broadcastTransaction(tx, callOptions.network as StacksNetwork); | ||
return broadcastTransaction({ transaction: tx, client: this.client }); | ||
} | ||
@@ -1049,3 +1007,3 @@ | ||
return broadcastTransaction(tx, callOptions.network as StacksNetwork); | ||
return broadcastTransaction({ transaction: tx, client: this.client }); | ||
} | ||
@@ -1078,3 +1036,3 @@ | ||
return broadcastTransaction(tx, callOptions.network as StacksNetwork); | ||
return broadcastTransaction({ transaction: tx, client: this.client }); | ||
} | ||
@@ -1121,2 +1079,3 @@ | ||
const callOptions: ContractCallOptions = { | ||
client: this.client, | ||
contractAddress, | ||
@@ -1128,3 +1087,2 @@ contractName, | ||
network: this.network, | ||
anchorMode: AnchorMode.Any, | ||
}; | ||
@@ -1164,2 +1122,3 @@ return callOptions; | ||
const callOptions: ContractCallOptions = { | ||
client: this.client, | ||
contractAddress, | ||
@@ -1171,3 +1130,2 @@ contractName, | ||
network: this.network, | ||
anchorMode: AnchorMode.Any, | ||
}; | ||
@@ -1204,2 +1162,3 @@ return callOptions; | ||
const callOptions: ContractCallOptions = { | ||
client: this.client, | ||
contractAddress, | ||
@@ -1211,3 +1170,2 @@ contractName, | ||
network: this.network, | ||
anchorMode: AnchorMode.Any, | ||
}; | ||
@@ -1233,2 +1191,3 @@ return callOptions; | ||
const callOptions: ContractCallOptions = { | ||
client: this.client, | ||
contractAddress, | ||
@@ -1245,3 +1204,2 @@ contractName, | ||
network: this.network, | ||
anchorMode: AnchorMode.Any, | ||
}; | ||
@@ -1270,2 +1228,3 @@ return callOptions; | ||
const callOptions: ContractCallOptions = { | ||
client: this.client, | ||
contractAddress, | ||
@@ -1283,3 +1242,2 @@ contractName, | ||
network: this.network, | ||
anchorMode: AnchorMode.Any, | ||
}; | ||
@@ -1305,2 +1263,3 @@ | ||
const callOptions: ContractCallOptions = { | ||
client: this.client, | ||
contractAddress, | ||
@@ -1312,3 +1271,2 @@ contractName, | ||
network: this.network, | ||
anchorMode: AnchorMode.Any, | ||
}; | ||
@@ -1333,2 +1291,3 @@ | ||
const callOptions: ContractCallOptions = { | ||
client: this.client, | ||
contractAddress, | ||
@@ -1340,3 +1299,2 @@ contractName, | ||
network: this.network, | ||
anchorMode: AnchorMode.Any, | ||
}; | ||
@@ -1377,2 +1335,3 @@ | ||
const callOptions: ContractCallOptions = { | ||
client: this.client, | ||
contractAddress, | ||
@@ -1384,3 +1343,2 @@ contractName, | ||
network: this.network, | ||
anchorMode: AnchorMode.Any, | ||
}; | ||
@@ -1422,2 +1380,3 @@ return callOptions; | ||
const callOptions: ContractCallOptions = { | ||
client: this.client, | ||
contractAddress, | ||
@@ -1429,3 +1388,2 @@ contractName, | ||
network: this.network, | ||
anchorMode: AnchorMode.Any, | ||
}; | ||
@@ -1465,2 +1423,3 @@ return callOptions; | ||
const callOptions: ContractCallOptions = { | ||
client: this.client, | ||
contractAddress, | ||
@@ -1472,3 +1431,2 @@ contractName, | ||
network: this.network, | ||
anchorMode: AnchorMode.Any, | ||
}; | ||
@@ -1481,2 +1439,3 @@ return callOptions; | ||
const callOptions: ContractCallOptions = { | ||
client: this.client, | ||
contractAddress, | ||
@@ -1488,3 +1447,2 @@ contractName, | ||
network: this.network, | ||
anchorMode: AnchorMode.Any, | ||
}; | ||
@@ -1505,3 +1463,3 @@ return callOptions; | ||
return callReadOnlyFunction({ | ||
return fetchCallReadOnlyFunction({ | ||
contractAddress, | ||
@@ -1512,3 +1470,3 @@ contractName, | ||
functionArgs: [principalCV(this.address)], | ||
network: this.network, | ||
client: this.client, | ||
}).then((responseCV: ClarityValue) => { | ||
@@ -1518,7 +1476,7 @@ if (responseCV.type === ClarityType.OptionalSome) { | ||
const tupleCV: TupleCV = someCV.value as TupleCV; | ||
const poxAddress: TupleCV = tupleCV.data['pox-addr'] as TupleCV; | ||
const firstRewardCycle: UIntCV = tupleCV.data['first-reward-cycle'] as UIntCV; | ||
const lockPeriod: UIntCV = tupleCV.data['lock-period'] as UIntCV; | ||
const version: BufferCV = poxAddress.data['version'] as BufferCV; | ||
const hashbytes: BufferCV = poxAddress.data['hashbytes'] as BufferCV; | ||
const poxAddress: TupleCV = tupleCV.value['pox-addr'] as TupleCV; | ||
const firstRewardCycle: UIntCV = tupleCV.value['first-reward-cycle'] as UIntCV; | ||
const lockPeriod: UIntCV = tupleCV.value['lock-period'] as UIntCV; | ||
const version: BufferCV = poxAddress.value['version'] as BufferCV; | ||
const hashbytes: BufferCV = poxAddress.value['hashbytes'] as BufferCV; | ||
@@ -1532,4 +1490,4 @@ return { | ||
pox_address: { | ||
version: version.buffer, | ||
hashbytes: hashbytes.buffer, | ||
version: hexToBytes(version.value), | ||
hashbytes: hexToBytes(hashbytes.value), | ||
}, | ||
@@ -1558,20 +1516,20 @@ }, | ||
return callReadOnlyFunction({ | ||
return fetchCallReadOnlyFunction({ | ||
contractAddress, | ||
contractName, | ||
functionName, | ||
functionArgs: [principalCV(this.address)], | ||
senderAddress: this.address, | ||
functionArgs: [principalCV(this.address)], | ||
network: this.network, | ||
client: this.client, | ||
}).then((responseCV: ClarityValue) => { | ||
if (responseCV.type === ClarityType.OptionalSome) { | ||
const tupleCV = responseCV.value as TupleCV; | ||
const amountMicroStx = tupleCV.data['amount-ustx'] as UIntCV; | ||
const delegatedTo = tupleCV.data['delegated-to'] as PrincipalCV; | ||
const amountMicroStx = tupleCV.value['amount-ustx'] as UIntCV; | ||
const delegatedTo = tupleCV.value['delegated-to'] as PrincipalCV; | ||
const poxAddress = unwrapMap(tupleCV.data['pox-addr'] as OptionalCV<TupleCV>, tuple => ({ | ||
version: (tuple.data['version'] as BufferCV).buffer, | ||
hashbytes: (tuple.data['hashbytes'] as BufferCV).buffer, | ||
const poxAddress = unwrapMap(tupleCV.value['pox-addr'] as OptionalCV<TupleCV>, tuple => ({ | ||
version: hexToBytes((tuple.value['version'] as BufferCV).value)[0], | ||
hashbytes: hexToBytes((tuple.value['hashbytes'] as BufferCV).value), | ||
})); | ||
const untilBurnBlockHeight = unwrap(tupleCV.data['until-burn-ht'] as OptionalCV<UIntCV>); | ||
const untilBurnBlockHeight = unwrap(tupleCV.value['until-burn-ht'] as OptionalCV<UIntCV>); | ||
@@ -1582,3 +1540,3 @@ return { | ||
amount_micro_stx: BigInt(amountMicroStx.value), | ||
delegated_to: principalToString(delegatedTo), | ||
delegated_to: delegatedTo.value, | ||
pox_address: poxAddress, | ||
@@ -1640,3 +1598,3 @@ until_burn_ht: untilBurnBlockHeight ? Number(untilBurnBlockHeight.value) : undefined, | ||
return callReadOnlyFunction({ | ||
return fetchCallReadOnlyFunction({ | ||
contractAddress, | ||
@@ -1646,4 +1604,4 @@ contractName, | ||
functionArgs, | ||
network: this.network, | ||
senderAddress: this.address, | ||
client: this.client, | ||
}).then(responseCV => responseCV.type === ClarityType.ResponseOk); | ||
@@ -1677,5 +1635,3 @@ } | ||
const fee = getFee(tx.auth); | ||
(tx.payload as ContractCallPayload).functionArgs[0] = uintCV( | ||
intToBigInt(amountMicroStx, false) - fee | ||
); | ||
(tx.payload as ContractCallPayload).functionArgs[0] = uintCV(intToBigInt(amountMicroStx) - fee); | ||
return tx; | ||
@@ -1716,3 +1672,3 @@ } | ||
period: number; | ||
signerPrivateKey: StacksPrivateKey; | ||
signerPrivateKey: PrivateKey; | ||
maxAmount: IntegerType; | ||
@@ -1748,1 +1704,102 @@ authId: IntegerType; | ||
} | ||
/** @beta @ignore Type export subject to change*/ | ||
export interface V2CoreInfoResponse { | ||
burn_block_height: number; | ||
stable_pox_consensus: string; | ||
} | ||
/** @beta @ignore Type export subject to change*/ | ||
export interface CycleInfoResponse { | ||
id: number; | ||
min_threshold_ustx: number; | ||
stacked_ustx: number; | ||
is_pox_active: boolean; | ||
} | ||
/** @beta @ignore Type export subject to change*/ | ||
export interface ContractVersionResponse { | ||
contract_id: ContractIdString; | ||
activation_burnchain_block_height: number; | ||
first_reward_cycle_id: number; | ||
} | ||
/** @beta @ignore Type export subject to change*/ | ||
export interface V2PoxInfoResponse { | ||
contract_id: string; | ||
contract_versions: ContractVersionResponse[]; | ||
current_burnchain_block_height?: number; | ||
first_burnchain_block_height: number; | ||
min_amount_ustx: string; | ||
next_reward_cycle_in: number; | ||
prepare_cycle_length: number; | ||
prepare_phase_block_length: number; | ||
rejection_fraction: number; | ||
rejection_votes_left_required: number; | ||
reward_cycle_id: number; | ||
reward_cycle_length: number; | ||
reward_phase_block_length: number; | ||
reward_slots: number; | ||
current_cycle: CycleInfoResponse; | ||
next_cycle: CycleInfoResponse & { | ||
min_increment_ustx: number; | ||
prepare_phase_start_block_height: number; | ||
blocks_until_prepare_phase: number; | ||
reward_phase_start_block_height: number; | ||
blocks_until_reward_phase: number; | ||
ustx_until_pox_rejection: number; | ||
}; | ||
} | ||
/** @beta @ignore Type export subject to change*/ | ||
export interface V1InfoBlockTimesResponse { | ||
mainnet: { | ||
target_block_time: number; | ||
}; | ||
testnet: { | ||
target_block_time: number; | ||
}; | ||
} | ||
/** @beta @ignore Type export subject to change*/ | ||
export interface ExtendedAccountBalancesResponse { | ||
stx: { | ||
balance: string; | ||
total_sent: string; | ||
total_received: string; | ||
locked: string; | ||
lock_tx_id: string; | ||
lock_height: number; | ||
burnchain_lock_height: number; | ||
burnchain_unlock_height: number; | ||
}; | ||
fungible_tokens: any; | ||
non_fungible_tokens: any; | ||
} | ||
/** @beta @ignore Type export subject to change*/ | ||
export interface ExtendedAccountBalances { | ||
stx: { | ||
balance: bigint; | ||
total_sent: bigint; | ||
total_received: bigint; | ||
locked: bigint; | ||
lock_tx_id: string; | ||
lock_height: number; | ||
burnchain_lock_height: number; | ||
burnchain_unlock_height: number; | ||
}; | ||
fungible_tokens: any; | ||
non_fungible_tokens: any; | ||
} | ||
/** @beta @ignore Type export subject to change*/ | ||
export interface PaginationOptions { | ||
limit: number; | ||
offset: number; | ||
} | ||
/** @beta @ignore Type export subject to change*/ | ||
export interface BaseErrorResponse { | ||
error: string; | ||
} |
import { sha256 } from '@noble/hashes/sha256'; | ||
import { bech32, bech32m } from '@scure/base'; | ||
import { IntegerType, bigIntToBytes } from '@stacks/common'; | ||
import { IntegerType, PrivateKey, bigIntToBytes, hexToBytes } from '@stacks/common'; | ||
import { | ||
@@ -9,3 +9,3 @@ base58CheckDecode, | ||
} from '@stacks/encryption'; | ||
import { StacksNetwork, StacksNetworkName, StacksNetworks } from '@stacks/network'; | ||
import { StacksNetwork, StacksNetworkName, StacksNetworks, networkFrom } from '@stacks/network'; | ||
import { | ||
@@ -16,3 +16,2 @@ BufferCV, | ||
OptionalCV, | ||
StacksPrivateKey, | ||
TupleCV, | ||
@@ -148,8 +147,11 @@ bufferCV, | ||
export function extractPoxAddressFromClarityValue(poxAddrClarityValue: ClarityValue) { | ||
export function extractPoxAddressFromClarityValue(poxAddrClarityValue: ClarityValue): { | ||
version: number; | ||
hashBytes: Uint8Array; | ||
} { | ||
const clarityValue = poxAddrClarityValue as TupleCV; | ||
if (clarityValue.type !== ClarityType.Tuple || !clarityValue.data) { | ||
if (clarityValue.type !== ClarityType.Tuple || !clarityValue.value) { | ||
throw new Error('Invalid argument, expected ClarityValue to be a TupleCV'); | ||
} | ||
if (!('version' in clarityValue.data) || !('hashbytes' in clarityValue.data)) { | ||
if (!('version' in clarityValue.value) || !('hashbytes' in clarityValue.value)) { | ||
throw new Error( | ||
@@ -159,4 +161,4 @@ 'Invalid argument, expected Clarity tuple value to contain `version` and `hashbytes` keys' | ||
} | ||
const versionCV = clarityValue.data['version'] as BufferCV; | ||
const hashBytesCV = clarityValue.data['hashbytes'] as BufferCV; | ||
const versionCV = clarityValue.value['version'] as BufferCV; | ||
const hashBytesCV = clarityValue.value['hashbytes'] as BufferCV; | ||
if (versionCV.type !== ClarityType.Buffer || hashBytesCV.type !== ClarityType.Buffer) { | ||
@@ -168,4 +170,4 @@ throw new Error( | ||
return { | ||
version: versionCV.buffer[0], | ||
hashBytes: hashBytesCV.buffer, | ||
version: hexToBytes(versionCV.value)[0], | ||
hashBytes: hexToBytes(hashBytesCV.value), | ||
}; | ||
@@ -326,2 +328,3 @@ } | ||
export function poxAddressToBtcAddress(...args: any[]): string { | ||
// todo: allow these helpers to take a bitcoin network instead of a stacks network, once we have a concept of bitcoin networks in the codebase | ||
if (typeof args[0] === 'number') return _poxAddressToBtcAddress_Values(args[0], args[1], args[2]); | ||
@@ -421,3 +424,3 @@ return _poxAddressToBtcAddress_ClarityValue(args[0], args[1]); | ||
period: number; | ||
network: StacksNetwork; | ||
network: StacksNetworkName | StacksNetwork; | ||
/** Maximum amount of uSTX that can be locked during this function call */ | ||
@@ -441,7 +444,7 @@ maxAmount: IntegerType; | ||
authId, | ||
}: Pox4SignatureOptions & { privateKey: StacksPrivateKey }) { | ||
}: Pox4SignatureOptions & { privateKey: PrivateKey }) { | ||
return signStructuredData({ | ||
...pox4SignatureMessage({ topic, poxAddress, rewardCycle, period, network, maxAmount, authId }), | ||
privateKey, | ||
}).data; | ||
}); | ||
} | ||
@@ -484,6 +487,7 @@ | ||
period: lockPeriod, | ||
network, | ||
network: networkOrName, | ||
maxAmount, | ||
authId, | ||
}: Pox4SignatureOptions) { | ||
const network = networkFrom(networkOrName); | ||
const message = tupleCV({ | ||
@@ -490,0 +494,0 @@ 'pox-addr': poxAddressToTuple(poxAddress), |
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
Sorry, the diff of this file is not supported yet
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
6057
1115932
6
1
2
+ Added@stacks/common@7.0.2(transitive)
+ Added@stacks/encryption@7.0.2(transitive)
+ Added@stacks/network@7.0.2(transitive)
+ Added@stacks/transactions@7.0.2(transitive)
- Removed@stacks/common@6.16.0(transitive)
- Removed@stacks/encryption@6.17.0(transitive)
- Removed@stacks/network@6.17.0(transitive)
- Removed@stacks/transactions@6.17.0(transitive)
- Removed@types/bn.js@5.1.6(transitive)
- Removed@types/node@18.19.73(transitive)
- Removedundici-types@5.26.5(transitive)