@stacks/stacking
Advanced tools
Comparing version 6.14.1-pr.f066584c.0 to 6.14.1-pr.fa0674c3.23
@@ -1,5 +0,6 @@ | ||
import { IntegerType } from '@stacks/common'; | ||
import { BaseErrorResponse, PaginationOptions, StacksNodeApi, V2PoxInfoResponse } from '@stacks/api'; | ||
import { ApiOpts, IntegerType, PrivateKey } from '@stacks/common'; | ||
import { StacksNetwork } from '@stacks/network'; | ||
import { BurnchainRewardListResponse, BurnchainRewardSlotHolderListResponse, BurnchainRewardsTotal } from '@stacks/stacks-blockchain-api-types'; | ||
import { ContractCallOptions, StacksPrivateKey, StacksTransaction, TxBroadcastResult } 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,23 @@ contractId: string; | ||
network: StacksNetwork; | ||
constructor(address: string, network: StacksNetwork); | ||
getCoreInfo(): Promise<CoreInfo>; | ||
getPoxInfo(): Promise<PoxInfo>; | ||
api: StacksNodeApi; | ||
constructor(opts: { | ||
address: string; | ||
network: StacksNetwork; | ||
api?: StacksNodeApi | ApiOpts; | ||
}); | ||
getCoreInfo(): Promise<import("@stacks/api").V2CoreInfoResponse>; | ||
getPoxInfo(): Promise<V2PoxInfoResponse>; | ||
getTargetBlockTime(): Promise<number>; | ||
getAccountStatus(): Promise<any>; | ||
getAccountBalance(): Promise<bigint>; | ||
getAccountExtendedBalances(): Promise<AccountExtendedBalances>; | ||
getAccountExtendedBalances(): Promise<import("@stacks/api").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 +325,3 @@ canStack({ poxAddress, cycles }: CanLockStxOptions): Promise<StackingEligibility>; | ||
period: number; | ||
signerPrivateKey: StacksPrivateKey; | ||
signerPrivateKey: PrivateKey; | ||
maxAmount: IntegerType; | ||
@@ -359,0 +328,0 @@ authId: IntegerType; |
@@ -1,2 +0,3 @@ | ||
import { hexToBytes, intToBigInt } from '@stacks/common'; | ||
import { StacksNodeApi, } from '@stacks/api'; | ||
import { hexToBytes, intToBigInt, isInstance, } from '@stacks/common'; | ||
import { AnchorMode, ClarityType, broadcastTransaction, bufferCV, callReadOnlyFunction, cvToString, getFee, makeContractCall, noneCV, principalCV, principalToString, someCV, stringAsciiCV, uintCV, validateStacksAddress, } from '@stacks/transactions'; | ||
@@ -7,39 +8,29 @@ import { PoxOperationPeriod, StackingErrors } from './constants'; | ||
export class StackingClient { | ||
constructor(address, network) { | ||
this.address = address; | ||
this.network = network; | ||
constructor(opts) { | ||
this.address = opts.address; | ||
this.network = opts.network; | ||
this.api = isInstance(opts.api, StacksNodeApi) | ||
? opts.api | ||
: new StacksNodeApi({ url: opts.api?.url, fetch: opts.api?.fetch, network: opts.network }); | ||
} | ||
async getCoreInfo() { | ||
const url = this.network.getInfoUrl(); | ||
return this.network.fetchFn(url).then(res => res.json()); | ||
getCoreInfo() { | ||
return this.api.getInfo(); | ||
} | ||
async getPoxInfo() { | ||
const url = this.network.getPoxInfoUrl(); | ||
return this.network.fetchFn(url).then(res => res.json()); | ||
getPoxInfo() { | ||
return this.api.getPoxInfo(); | ||
} | ||
async getTargetBlockTime() { | ||
const url = this.network.getBlockTimeInfoUrl(); | ||
const res = await this.network.fetchFn(url).then(res => res.json()); | ||
if (this.network.isMainnet()) { | ||
return res.mainnet.target_block_time; | ||
} | ||
else { | ||
return res.testnet.target_block_time; | ||
} | ||
getTargetBlockTime() { | ||
return this.api.getTargetBlockTime(); | ||
} | ||
async getAccountStatus() { | ||
const url = this.network.getAccountApiUrl(this.address); | ||
return this.network.fetchFn(url).then(res => res.json()); | ||
return this.api.getAccountInfo(this.address); | ||
} | ||
async getAccountBalance() { | ||
return this.getAccountStatus().then(res => { | ||
return BigInt(res.balance); | ||
}); | ||
return this.api.getAccountInfo(this.address).then(a => a.balance); | ||
} | ||
async getAccountExtendedBalances() { | ||
const url = this.network.getAccountExtendedBalancesApiUrl(this.address); | ||
return this.network.fetchFn(url).then(res => res.json()); | ||
return this.api.getExtendedAccountBalances(this.address); | ||
} | ||
async getAccountBalanceLocked() { | ||
return this.getAccountStatus().then(res => BigInt(res.locked)); | ||
return this.api.getAccountInfo(this.address).then(a => a.locked); | ||
} | ||
@@ -54,12 +45,9 @@ async getCycleDuration() { | ||
async getRewardsTotalForBtcAddress() { | ||
const url = this.network.getRewardsTotalUrl(this.address); | ||
return this.network.fetchFn(url).then(res => res.json()); | ||
return this.api.getExtendedBtcRewardsTotal(this.address); | ||
} | ||
async getRewardsForBtcAddress(options) { | ||
const url = `${this.network.getRewardsUrl(this.address, options)}`; | ||
return this.network.fetchFn(url).then(res => res.json()); | ||
return this.api.getExtendedBtcRewards(this.address, options); | ||
} | ||
async getRewardHoldersForBtcAddress(options) { | ||
const url = `${this.network.getRewardHoldersUrl(this.address, options)}`; | ||
return this.network.fetchFn(url).then(res => res.json()); | ||
return this.api.getExtendedBtcRewardHolders(this.address, options); | ||
} | ||
@@ -69,3 +57,3 @@ async getRewardSet(options) { | ||
const result = await callReadOnlyFunction({ | ||
network: this.network, | ||
api: this.api, | ||
senderAddress: this.address, | ||
@@ -122,3 +110,3 @@ contractAddress, | ||
return callReadOnlyFunction({ | ||
network: this.network, | ||
api: this.api, | ||
contractName, | ||
@@ -172,3 +160,3 @@ contractAddress, | ||
}); | ||
return broadcastTransaction(tx, callOptions.network); | ||
return broadcastTransaction({ transaction: tx, api: this.api }); | ||
} | ||
@@ -199,3 +187,3 @@ async stackExtend({ extendCycles, poxAddress, signerKey, signerSignature, maxAmount, authId, ...txOptions }) { | ||
}); | ||
return broadcastTransaction(tx, callOptions.network); | ||
return broadcastTransaction({ transaction: tx, api: this.api }); | ||
} | ||
@@ -225,3 +213,3 @@ async stackIncrease({ increaseBy, signerKey, signerSignature, maxAmount, authId, ...txOptions }) { | ||
}); | ||
return broadcastTransaction(tx, callOptions.network); | ||
return broadcastTransaction({ transaction: tx, api: this.api }); | ||
} | ||
@@ -244,3 +232,3 @@ async delegateStx({ amountMicroStx, delegateTo, untilBurnBlockHeight, poxAddress, ...txOptions }) { | ||
}); | ||
return broadcastTransaction(tx, callOptions.network); | ||
return broadcastTransaction({ transaction: tx, api: this.api }); | ||
} | ||
@@ -264,3 +252,3 @@ async delegateStackStx({ stacker, amountMicroStx, poxAddress, burnBlockHeight, cycles, ...txOptions }) { | ||
}); | ||
return broadcastTransaction(tx, callOptions.network); | ||
return broadcastTransaction({ transaction: tx, api: this.api }); | ||
} | ||
@@ -280,3 +268,3 @@ async delegateStackExtend({ stacker, poxAddress, extendCount, ...txOptions }) { | ||
}); | ||
return broadcastTransaction(tx, callOptions.network); | ||
return broadcastTransaction({ transaction: tx, api: this.api }); | ||
} | ||
@@ -297,3 +285,3 @@ async delegateStackIncrease({ stacker, poxAddress, increaseBy, ...txOptions }) { | ||
}); | ||
return broadcastTransaction(tx, callOptions.network); | ||
return broadcastTransaction({ transaction: tx, api: this.api }); | ||
} | ||
@@ -317,3 +305,3 @@ async stackAggregationCommit({ poxAddress, rewardCycle, signerKey, signerSignature, maxAmount, authId, ...txOptions }) { | ||
}); | ||
return broadcastTransaction(tx, callOptions.network); | ||
return broadcastTransaction({ transaction: tx, api: this.api }); | ||
} | ||
@@ -337,3 +325,3 @@ async stackAggregationCommitIndexed({ poxAddress, rewardCycle, signerKey, signerSignature, maxAmount, authId, ...txOptions }) { | ||
}); | ||
return broadcastTransaction(tx, callOptions.network); | ||
return broadcastTransaction({ transaction: tx, api: this.api }); | ||
} | ||
@@ -358,3 +346,3 @@ async stackAggregationIncrease({ poxAddress, rewardCycle, rewardIndex, signerKey, signerSignature, maxAmount, authId, ...txOptions }) { | ||
}); | ||
return broadcastTransaction(tx, callOptions.network); | ||
return broadcastTransaction({ transaction: tx, api: this.api }); | ||
} | ||
@@ -371,3 +359,3 @@ async revokeDelegateStx(arg) { | ||
}); | ||
return broadcastTransaction(tx, callOptions.network); | ||
return broadcastTransaction({ transaction: tx, api: this.api }); | ||
} | ||
@@ -390,2 +378,3 @@ getStackOptions({ amountMicroStx, poxAddress, cycles, contract, burnBlockHeight, signerKey, signerSignature, maxAmount, authId, }) { | ||
const callOptions = { | ||
api: this.api, | ||
contractAddress, | ||
@@ -412,2 +401,3 @@ contractName, | ||
const callOptions = { | ||
api: this.api, | ||
contractAddress, | ||
@@ -433,2 +423,3 @@ contractName, | ||
const callOptions = { | ||
api: this.api, | ||
contractAddress, | ||
@@ -448,2 +439,3 @@ contractName, | ||
const callOptions = { | ||
api: this.api, | ||
contractAddress, | ||
@@ -468,2 +460,3 @@ contractName, | ||
const callOptions = { | ||
api: this.api, | ||
contractAddress, | ||
@@ -489,2 +482,3 @@ contractName, | ||
const callOptions = { | ||
api: this.api, | ||
contractAddress, | ||
@@ -504,2 +498,3 @@ contractName, | ||
const callOptions = { | ||
api: this.api, | ||
contractAddress, | ||
@@ -526,2 +521,3 @@ contractName, | ||
const callOptions = { | ||
api: this.api, | ||
contractAddress, | ||
@@ -548,2 +544,3 @@ contractName, | ||
const callOptions = { | ||
api: this.api, | ||
contractAddress, | ||
@@ -570,2 +567,3 @@ contractName, | ||
const callOptions = { | ||
api: this.api, | ||
contractAddress, | ||
@@ -584,2 +582,3 @@ contractName, | ||
const callOptions = { | ||
api: this.api, | ||
contractAddress, | ||
@@ -606,3 +605,3 @@ contractName, | ||
functionArgs: [principalCV(this.address)], | ||
network: this.network, | ||
api: this.api, | ||
}).then((responseCV) => { | ||
@@ -648,5 +647,5 @@ if (responseCV.type === ClarityType.OptionalSome) { | ||
functionName, | ||
functionArgs: [principalCV(this.address)], | ||
senderAddress: this.address, | ||
functionArgs: [principalCV(this.address)], | ||
network: this.network, | ||
api: this.api, | ||
}).then((responseCV) => { | ||
@@ -658,3 +657,3 @@ if (responseCV.type === ClarityType.OptionalSome) { | ||
const poxAddress = unwrapMap(tupleCV.data['pox-addr'], tuple => ({ | ||
version: tuple.data['version'].buffer, | ||
version: tuple.data['version'].buffer[0], | ||
hashbytes: tuple.data['hashbytes'].buffer, | ||
@@ -703,4 +702,4 @@ })); | ||
functionArgs, | ||
network: this.network, | ||
senderAddress: this.address, | ||
api: this.api, | ||
}).then(responseCV => responseCV.type === ClarityType.ResponseOk); | ||
@@ -707,0 +706,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; | ||
@@ -44,3 +42,3 @@ export declare function poxAddressToBtcAddress(poxAddrClarityValue: ClarityValue, network: StacksNetworkName): string; | ||
export declare function signPox4SignatureHash({ topic, poxAddress, rewardCycle, period, network, privateKey, maxAmount, authId, }: Pox4SignatureOptions & { | ||
privateKey: StacksPrivateKey; | ||
privateKey: PrivateKey; | ||
}): string; | ||
@@ -52,10 +50,4 @@ export declare function verifyPox4SignatureHash({ topic, poxAddress, rewardCycle, period, network, publicKey, signature, maxAmount, authId, }: Pox4SignatureOptions & { | ||
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; | ||
}>; | ||
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>>; | ||
}; |
@@ -1,5 +0,6 @@ | ||
import { IntegerType } from '@stacks/common'; | ||
import { BaseErrorResponse, PaginationOptions, StacksNodeApi, V2PoxInfoResponse } from '@stacks/api'; | ||
import { ApiOpts, IntegerType, PrivateKey } from '@stacks/common'; | ||
import { StacksNetwork } from '@stacks/network'; | ||
import { BurnchainRewardListResponse, BurnchainRewardSlotHolderListResponse, BurnchainRewardsTotal } from '@stacks/stacks-blockchain-api-types'; | ||
import { ContractCallOptions, StacksPrivateKey, StacksTransaction, TxBroadcastResult } 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,23 @@ contractId: string; | ||
network: StacksNetwork; | ||
constructor(address: string, network: StacksNetwork); | ||
getCoreInfo(): Promise<CoreInfo>; | ||
getPoxInfo(): Promise<PoxInfo>; | ||
api: StacksNodeApi; | ||
constructor(opts: { | ||
address: string; | ||
network: StacksNetwork; | ||
api?: StacksNodeApi | ApiOpts; | ||
}); | ||
getCoreInfo(): Promise<import("@stacks/api").V2CoreInfoResponse>; | ||
getPoxInfo(): Promise<V2PoxInfoResponse>; | ||
getTargetBlockTime(): Promise<number>; | ||
getAccountStatus(): Promise<any>; | ||
getAccountBalance(): Promise<bigint>; | ||
getAccountExtendedBalances(): Promise<AccountExtendedBalances>; | ||
getAccountExtendedBalances(): Promise<import("@stacks/api").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 +325,3 @@ canStack({ poxAddress, cycles }: CanLockStxOptions): Promise<StackingEligibility>; | ||
period: number; | ||
signerPrivateKey: StacksPrivateKey; | ||
signerPrivateKey: PrivateKey; | ||
maxAmount: IntegerType; | ||
@@ -359,0 +328,0 @@ authId: IntegerType; |
@@ -18,2 +18,3 @@ "use strict"; | ||
exports.StackingClient = void 0; | ||
const api_1 = require("@stacks/api"); | ||
const common_1 = require("@stacks/common"); | ||
@@ -25,39 +26,29 @@ const transactions_1 = require("@stacks/transactions"); | ||
class StackingClient { | ||
constructor(address, network) { | ||
this.address = address; | ||
this.network = network; | ||
constructor(opts) { | ||
this.address = opts.address; | ||
this.network = opts.network; | ||
this.api = (0, common_1.isInstance)(opts.api, api_1.StacksNodeApi) | ||
? opts.api | ||
: new api_1.StacksNodeApi({ url: opts.api?.url, fetch: opts.api?.fetch, network: opts.network }); | ||
} | ||
async getCoreInfo() { | ||
const url = this.network.getInfoUrl(); | ||
return this.network.fetchFn(url).then(res => res.json()); | ||
getCoreInfo() { | ||
return this.api.getInfo(); | ||
} | ||
async getPoxInfo() { | ||
const url = this.network.getPoxInfoUrl(); | ||
return this.network.fetchFn(url).then(res => res.json()); | ||
getPoxInfo() { | ||
return this.api.getPoxInfo(); | ||
} | ||
async getTargetBlockTime() { | ||
const url = this.network.getBlockTimeInfoUrl(); | ||
const res = await this.network.fetchFn(url).then(res => res.json()); | ||
if (this.network.isMainnet()) { | ||
return res.mainnet.target_block_time; | ||
} | ||
else { | ||
return res.testnet.target_block_time; | ||
} | ||
getTargetBlockTime() { | ||
return this.api.getTargetBlockTime(); | ||
} | ||
async getAccountStatus() { | ||
const url = this.network.getAccountApiUrl(this.address); | ||
return this.network.fetchFn(url).then(res => res.json()); | ||
return this.api.getAccountInfo(this.address); | ||
} | ||
async getAccountBalance() { | ||
return this.getAccountStatus().then(res => { | ||
return BigInt(res.balance); | ||
}); | ||
return this.api.getAccountInfo(this.address).then(a => a.balance); | ||
} | ||
async getAccountExtendedBalances() { | ||
const url = this.network.getAccountExtendedBalancesApiUrl(this.address); | ||
return this.network.fetchFn(url).then(res => res.json()); | ||
return this.api.getExtendedAccountBalances(this.address); | ||
} | ||
async getAccountBalanceLocked() { | ||
return this.getAccountStatus().then(res => BigInt(res.locked)); | ||
return this.api.getAccountInfo(this.address).then(a => a.locked); | ||
} | ||
@@ -72,12 +63,9 @@ async getCycleDuration() { | ||
async getRewardsTotalForBtcAddress() { | ||
const url = this.network.getRewardsTotalUrl(this.address); | ||
return this.network.fetchFn(url).then(res => res.json()); | ||
return this.api.getExtendedBtcRewardsTotal(this.address); | ||
} | ||
async getRewardsForBtcAddress(options) { | ||
const url = `${this.network.getRewardsUrl(this.address, options)}`; | ||
return this.network.fetchFn(url).then(res => res.json()); | ||
return this.api.getExtendedBtcRewards(this.address, options); | ||
} | ||
async getRewardHoldersForBtcAddress(options) { | ||
const url = `${this.network.getRewardHoldersUrl(this.address, options)}`; | ||
return this.network.fetchFn(url).then(res => res.json()); | ||
return this.api.getExtendedBtcRewardHolders(this.address, options); | ||
} | ||
@@ -87,3 +75,3 @@ async getRewardSet(options) { | ||
const result = await (0, transactions_1.callReadOnlyFunction)({ | ||
network: this.network, | ||
api: this.api, | ||
senderAddress: this.address, | ||
@@ -140,3 +128,3 @@ contractAddress, | ||
return (0, transactions_1.callReadOnlyFunction)({ | ||
network: this.network, | ||
api: this.api, | ||
contractName, | ||
@@ -190,3 +178,3 @@ contractAddress, | ||
}); | ||
return (0, transactions_1.broadcastTransaction)(tx, callOptions.network); | ||
return (0, transactions_1.broadcastTransaction)({ transaction: tx, api: this.api }); | ||
} | ||
@@ -217,3 +205,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, api: this.api }); | ||
} | ||
@@ -243,3 +231,3 @@ async stackIncrease({ increaseBy, signerKey, signerSignature, maxAmount, authId, ...txOptions }) { | ||
}); | ||
return (0, transactions_1.broadcastTransaction)(tx, callOptions.network); | ||
return (0, transactions_1.broadcastTransaction)({ transaction: tx, api: this.api }); | ||
} | ||
@@ -262,3 +250,3 @@ async delegateStx({ amountMicroStx, delegateTo, untilBurnBlockHeight, poxAddress, ...txOptions }) { | ||
}); | ||
return (0, transactions_1.broadcastTransaction)(tx, callOptions.network); | ||
return (0, transactions_1.broadcastTransaction)({ transaction: tx, api: this.api }); | ||
} | ||
@@ -282,3 +270,3 @@ async delegateStackStx({ stacker, amountMicroStx, poxAddress, burnBlockHeight, cycles, ...txOptions }) { | ||
}); | ||
return (0, transactions_1.broadcastTransaction)(tx, callOptions.network); | ||
return (0, transactions_1.broadcastTransaction)({ transaction: tx, api: this.api }); | ||
} | ||
@@ -298,3 +286,3 @@ async delegateStackExtend({ stacker, poxAddress, extendCount, ...txOptions }) { | ||
}); | ||
return (0, transactions_1.broadcastTransaction)(tx, callOptions.network); | ||
return (0, transactions_1.broadcastTransaction)({ transaction: tx, api: this.api }); | ||
} | ||
@@ -315,3 +303,3 @@ async delegateStackIncrease({ stacker, poxAddress, increaseBy, ...txOptions }) { | ||
}); | ||
return (0, transactions_1.broadcastTransaction)(tx, callOptions.network); | ||
return (0, transactions_1.broadcastTransaction)({ transaction: tx, api: this.api }); | ||
} | ||
@@ -335,3 +323,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, api: this.api }); | ||
} | ||
@@ -355,3 +343,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, api: this.api }); | ||
} | ||
@@ -376,3 +364,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, api: this.api }); | ||
} | ||
@@ -389,3 +377,3 @@ async revokeDelegateStx(arg) { | ||
}); | ||
return (0, transactions_1.broadcastTransaction)(tx, callOptions.network); | ||
return (0, transactions_1.broadcastTransaction)({ transaction: tx, api: this.api }); | ||
} | ||
@@ -408,2 +396,3 @@ getStackOptions({ amountMicroStx, poxAddress, cycles, contract, burnBlockHeight, signerKey, signerSignature, maxAmount, authId, }) { | ||
const callOptions = { | ||
api: this.api, | ||
contractAddress, | ||
@@ -430,2 +419,3 @@ contractName, | ||
const callOptions = { | ||
api: this.api, | ||
contractAddress, | ||
@@ -451,2 +441,3 @@ contractName, | ||
const callOptions = { | ||
api: this.api, | ||
contractAddress, | ||
@@ -466,2 +457,3 @@ contractName, | ||
const callOptions = { | ||
api: this.api, | ||
contractAddress, | ||
@@ -486,2 +478,3 @@ contractName, | ||
const callOptions = { | ||
api: this.api, | ||
contractAddress, | ||
@@ -507,2 +500,3 @@ contractName, | ||
const callOptions = { | ||
api: this.api, | ||
contractAddress, | ||
@@ -522,2 +516,3 @@ contractName, | ||
const callOptions = { | ||
api: this.api, | ||
contractAddress, | ||
@@ -544,2 +539,3 @@ contractName, | ||
const callOptions = { | ||
api: this.api, | ||
contractAddress, | ||
@@ -566,2 +562,3 @@ contractName, | ||
const callOptions = { | ||
api: this.api, | ||
contractAddress, | ||
@@ -588,2 +585,3 @@ contractName, | ||
const callOptions = { | ||
api: this.api, | ||
contractAddress, | ||
@@ -602,2 +600,3 @@ contractName, | ||
const callOptions = { | ||
api: this.api, | ||
contractAddress, | ||
@@ -624,3 +623,3 @@ contractName, | ||
functionArgs: [(0, transactions_1.principalCV)(this.address)], | ||
network: this.network, | ||
api: this.api, | ||
}).then((responseCV) => { | ||
@@ -666,5 +665,5 @@ if (responseCV.type === transactions_1.ClarityType.OptionalSome) { | ||
functionName, | ||
functionArgs: [(0, transactions_1.principalCV)(this.address)], | ||
senderAddress: this.address, | ||
functionArgs: [(0, transactions_1.principalCV)(this.address)], | ||
network: this.network, | ||
api: this.api, | ||
}).then((responseCV) => { | ||
@@ -676,3 +675,3 @@ if (responseCV.type === transactions_1.ClarityType.OptionalSome) { | ||
const poxAddress = (0, utils_1.unwrapMap)(tupleCV.data['pox-addr'], tuple => ({ | ||
version: tuple.data['version'].buffer, | ||
version: tuple.data['version'].buffer[0], | ||
hashbytes: tuple.data['hashbytes'].buffer, | ||
@@ -721,4 +720,4 @@ })); | ||
functionArgs, | ||
network: this.network, | ||
senderAddress: this.address, | ||
api: this.api, | ||
}).then(responseCV => responseCV.type === transactions_1.ClarityType.ResponseOk); | ||
@@ -725,0 +724,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; | ||
@@ -44,3 +42,3 @@ export declare function poxAddressToBtcAddress(poxAddrClarityValue: ClarityValue, network: StacksNetworkName): string; | ||
export declare function signPox4SignatureHash({ topic, poxAddress, rewardCycle, period, network, privateKey, maxAmount, authId, }: Pox4SignatureOptions & { | ||
privateKey: StacksPrivateKey; | ||
privateKey: PrivateKey; | ||
}): string; | ||
@@ -52,10 +50,4 @@ export declare function verifyPox4SignatureHash({ topic, poxAddress, rewardCycle, period, network, publicKey, signature, maxAmount, authId, }: Pox4SignatureOptions & { | ||
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; | ||
}>; | ||
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>>; | ||
}; |
{ | ||
"name": "@stacks/stacking", | ||
"version": "6.14.1-pr.f066584c.0+f066584c", | ||
"version": "6.14.1-pr.fa0674c3.23+fa0674c3", | ||
"description": "Library for Stacking.", | ||
@@ -25,7 +25,8 @@ "license": "MIT", | ||
"@scure/base": "1.1.1", | ||
"@stacks/common": "^6.14.1-pr.f066584c.0+f066584c", | ||
"@stacks/encryption": "^6.14.1-pr.f066584c.0+f066584c", | ||
"@stacks/network": "^6.14.1-pr.f066584c.0+f066584c", | ||
"@stacks/api": "^6.14.1-pr.fa0674c3.23+fa0674c3", | ||
"@stacks/common": "^6.14.1-pr.fa0674c3.23+fa0674c3", | ||
"@stacks/encryption": "^6.14.1-pr.fa0674c3.23+fa0674c3", | ||
"@stacks/network": "^6.14.1-pr.fa0674c3.23+fa0674c3", | ||
"@stacks/stacks-blockchain-api-types": "^0.61.0", | ||
"@stacks/transactions": "^6.14.1-pr.f066584c.0+f066584c", | ||
"@stacks/transactions": "^6.14.1-pr.fa0674c3.23+fa0674c3", | ||
"bs58": "^5.0.0" | ||
@@ -61,3 +62,3 @@ }, | ||
}, | ||
"gitHead": "f066584c39c28ab7a824af17c701500947ebe90d" | ||
"gitHead": "fa0674c3396ed7f1acba049bad1aaec70c20859a" | ||
} |
263
src/index.ts
@@ -1,2 +0,16 @@ | ||
import { IntegerType, hexToBytes, intToBigInt } from '@stacks/common'; | ||
import { | ||
BaseErrorResponse, | ||
ContractVersionResponse, | ||
PaginationOptions, | ||
StacksNodeApi, | ||
V2PoxInfoResponse, | ||
} from '@stacks/api'; | ||
import { | ||
ApiOpts, | ||
IntegerType, | ||
PrivateKey, | ||
hexToBytes, | ||
intToBigInt, | ||
isInstance, | ||
} from '@stacks/common'; | ||
import { StacksNetwork } from '@stacks/network'; | ||
@@ -18,3 +32,2 @@ import { | ||
ResponseErrorCV, | ||
StacksPrivateKey, | ||
StacksTransaction, | ||
@@ -109,17 +122,2 @@ TupleCV, | ||
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 = | ||
@@ -151,40 +149,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 { | ||
@@ -375,79 +343,51 @@ 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 api: StacksNodeApi; | ||
constructor(opts: { address: string; network: StacksNetwork; api?: StacksNodeApi | ApiOpts }) { | ||
this.address = opts.address; | ||
this.network = opts.network; | ||
this.api = isInstance(opts.api, StacksNodeApi) | ||
? opts.api | ||
: new StacksNodeApi({ url: opts.api?.url, fetch: opts.api?.fetch, network: opts.network }); | ||
} | ||
/** | ||
* 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()); | ||
/** @deprecated alias of StacksNodeApi.getCoreInfo, kept for backwards compatibility */ | ||
getCoreInfo() { | ||
return this.api.getInfo(); | ||
} | ||
/** | ||
* Get stacks node target block time | ||
* | ||
* @returns {Promise<number>} resolves to a number if the operation succeeds | ||
*/ | ||
async getTargetBlockTime(): Promise<number> { | ||
const url = this.network.getBlockTimeInfoUrl(); | ||
const res = await this.network.fetchFn(url).then(res => res.json()); | ||
/** @deprecated alias of StacksNodeApi.getPoxInfo, kept for backwards compatibility */ | ||
getPoxInfo() { | ||
return this.api.getPoxInfo(); | ||
} | ||
if (this.network.isMainnet()) { | ||
return res.mainnet.target_block_time; | ||
} else { | ||
return res.testnet.target_block_time; | ||
} | ||
/** @deprecated alias of StacksNodeApi.getTargetBlockTime, kept for backwards compatibility */ | ||
getTargetBlockTime() { | ||
return this.api.getTargetBlockTime(); | ||
} | ||
/** Get account status */ | ||
async getAccountStatus(): Promise<any> { | ||
const url = this.network.getAccountApiUrl(this.address); | ||
return this.network.fetchFn(url).then(res => res.json()); | ||
return this.api.getAccountInfo(this.address); | ||
} | ||
/** | ||
* 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.api.getAccountInfo(this.address).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() { | ||
return this.api.getExtendedAccountBalances(this.address); | ||
} | ||
/** | ||
* 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.api.getAccountInfo(this.address).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> { | ||
@@ -464,41 +404,26 @@ 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.api.getExtendedBtcRewardsTotal(this.address); | ||
} | ||
/** | ||
* 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> { | ||
return this.api.getExtendedBtcRewards(this.address, options); | ||
} | ||
/** | ||
* 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> { | ||
return this.api.getExtendedBtcRewardHolders(this.address, options); | ||
} | ||
/** | ||
* 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, | ||
api: this.api, | ||
senderAddress: this.address, | ||
@@ -522,6 +447,3 @@ contractAddress, | ||
* 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} | ||
*/ | ||
@@ -548,7 +470,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} | ||
*/ | ||
@@ -572,6 +492,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()); | ||
@@ -581,7 +499,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 | ||
@@ -621,3 +539,3 @@ ); | ||
return callReadOnlyFunction({ | ||
network: this.network, | ||
api: this.api, | ||
contractName, | ||
@@ -692,3 +610,3 @@ contractAddress, | ||
return broadcastTransaction(tx, callOptions.network as StacksNetwork); | ||
return broadcastTransaction({ transaction: tx, api: this.api }); | ||
} | ||
@@ -739,3 +657,3 @@ | ||
return broadcastTransaction(tx, callOptions.network as StacksNetwork); | ||
return broadcastTransaction({ transaction: tx, api: this.api }); | ||
} | ||
@@ -781,3 +699,3 @@ | ||
return broadcastTransaction(tx, callOptions.network as StacksNetwork); | ||
return broadcastTransaction({ transaction: tx, api: this.api }); | ||
} | ||
@@ -819,3 +737,3 @@ | ||
return broadcastTransaction(tx, callOptions.network as StacksNetwork); | ||
return broadcastTransaction({ transaction: tx, api: this.api }); | ||
} | ||
@@ -857,3 +775,3 @@ | ||
return broadcastTransaction(tx, callOptions.network as StacksNetwork); | ||
return broadcastTransaction({ transaction: tx, api: this.api }); | ||
} | ||
@@ -889,3 +807,3 @@ | ||
return broadcastTransaction(tx, callOptions.network as StacksNetwork); | ||
return broadcastTransaction({ transaction: tx, api: this.api }); | ||
} | ||
@@ -920,3 +838,3 @@ | ||
return broadcastTransaction(tx, callOptions.network as StacksNetwork); | ||
return broadcastTransaction({ transaction: tx, api: this.api }); | ||
} | ||
@@ -956,3 +874,3 @@ | ||
return broadcastTransaction(tx, callOptions.network as StacksNetwork); | ||
return broadcastTransaction({ transaction: tx, api: this.api }); | ||
} | ||
@@ -1005,3 +923,3 @@ | ||
return broadcastTransaction(tx, callOptions.network as StacksNetwork); | ||
return broadcastTransaction({ transaction: tx, api: this.api }); | ||
} | ||
@@ -1045,3 +963,3 @@ | ||
return broadcastTransaction(tx, callOptions.network as StacksNetwork); | ||
return broadcastTransaction({ transaction: tx, api: this.api }); | ||
} | ||
@@ -1074,3 +992,3 @@ | ||
return broadcastTransaction(tx, callOptions.network as StacksNetwork); | ||
return broadcastTransaction({ transaction: tx, api: this.api }); | ||
} | ||
@@ -1117,2 +1035,3 @@ | ||
const callOptions: ContractCallOptions = { | ||
api: this.api, | ||
contractAddress, | ||
@@ -1159,2 +1078,3 @@ contractName, | ||
const callOptions: ContractCallOptions = { | ||
api: this.api, | ||
contractAddress, | ||
@@ -1198,2 +1118,3 @@ contractName, | ||
const callOptions: ContractCallOptions = { | ||
api: this.api, | ||
contractAddress, | ||
@@ -1226,2 +1147,3 @@ contractName, | ||
const callOptions: ContractCallOptions = { | ||
api: this.api, | ||
contractAddress, | ||
@@ -1262,2 +1184,3 @@ contractName, | ||
const callOptions: ContractCallOptions = { | ||
api: this.api, | ||
contractAddress, | ||
@@ -1296,2 +1219,3 @@ contractName, | ||
const callOptions: ContractCallOptions = { | ||
api: this.api, | ||
contractAddress, | ||
@@ -1323,2 +1247,3 @@ contractName, | ||
const callOptions: ContractCallOptions = { | ||
api: this.api, | ||
contractAddress, | ||
@@ -1366,2 +1291,3 @@ contractName, | ||
const callOptions: ContractCallOptions = { | ||
api: this.api, | ||
contractAddress, | ||
@@ -1410,2 +1336,3 @@ contractName, | ||
const callOptions: ContractCallOptions = { | ||
api: this.api, | ||
contractAddress, | ||
@@ -1452,2 +1379,3 @@ contractName, | ||
const callOptions: ContractCallOptions = { | ||
api: this.api, | ||
contractAddress, | ||
@@ -1467,2 +1395,3 @@ contractName, | ||
const callOptions: ContractCallOptions = { | ||
api: this.api, | ||
contractAddress, | ||
@@ -1496,3 +1425,3 @@ contractName, | ||
functionArgs: [principalCV(this.address)], | ||
network: this.network, | ||
api: this.api, | ||
}).then((responseCV: ClarityValue) => { | ||
@@ -1544,5 +1473,5 @@ if (responseCV.type === ClarityType.OptionalSome) { | ||
functionName, | ||
functionArgs: [principalCV(this.address)], | ||
senderAddress: this.address, | ||
functionArgs: [principalCV(this.address)], | ||
network: this.network, | ||
api: this.api, | ||
}).then((responseCV: ClarityValue) => { | ||
@@ -1555,3 +1484,3 @@ if (responseCV.type === ClarityType.OptionalSome) { | ||
const poxAddress = unwrapMap(tupleCV.data['pox-addr'] as OptionalCV<TupleCV>, tuple => ({ | ||
version: (tuple.data['version'] as BufferCV).buffer, | ||
version: (tuple.data['version'] as BufferCV).buffer[0], | ||
hashbytes: (tuple.data['hashbytes'] as BufferCV).buffer, | ||
@@ -1627,4 +1556,4 @@ })); | ||
functionArgs, | ||
network: this.network, | ||
senderAddress: this.address, | ||
api: this.api, | ||
}).then(responseCV => responseCV.type === ClarityType.ResponseOk); | ||
@@ -1696,3 +1625,3 @@ } | ||
period: number; | ||
signerPrivateKey: StacksPrivateKey; | ||
signerPrivateKey: PrivateKey; | ||
maxAmount: IntegerType; | ||
@@ -1699,0 +1628,0 @@ authId: IntegerType; |
import { sha256 } from '@noble/hashes/sha256'; | ||
import { bech32, bech32m } from '@scure/base'; | ||
import { IntegerType, bigIntToBytes } from '@stacks/common'; | ||
import { IntegerType, PrivateKey, bigIntToBytes } from '@stacks/common'; | ||
import { | ||
@@ -15,3 +15,2 @@ base58CheckDecode, | ||
OptionalCV, | ||
StacksPrivateKey, | ||
TupleCV, | ||
@@ -435,3 +434,3 @@ bufferCV, | ||
authId, | ||
}: Pox4SignatureOptions & { privateKey: StacksPrivateKey }) { | ||
}: Pox4SignatureOptions & { privateKey: PrivateKey }) { | ||
return signStructuredData({ | ||
@@ -438,0 +437,0 @@ ...pox4SignatureMessage({ topic, poxAddress, rewardCycle, period, network, maxAmount, authId }), |
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
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
1095826
9
5710
+ Added@stacks/api@6.14.1-pr.fa0674c3.23(transitive)