1- import { StacksNetwork } from "@stacks/network" ;
21import {
32 AnchorMode ,
43 PostConditionMode ,
@@ -16,19 +15,22 @@ import { Contracts } from "../constants";
1615
1716import { toBytes } from "@stacks/common" ;
1817import { decodeBtcAddress } from "@stacks/stacking" ;
19- import { Account } from "./helpers" ;
18+ import { Account , BroadcastOptions , BroadcastOptionsPox2 } from "./helpers" ;
2019const fetch = require ( "node-fetch" ) ;
2120
2221export const broadcastDelegateSTX = async (
23- poxVersion : number ,
24- network : StacksNetwork ,
25- account : Account ,
26- fee : number ,
27- nonce : number ,
28- amount : number ,
29- poolAddress : Account ,
30- poolRewardAccount ?: Account ,
31- untilBurnHeight ?: number
22+ { poxVersion, network, account, fee, nonce } : BroadcastOptions ,
23+ {
24+ amount,
25+ poolAddress,
26+ poolRewardAccount,
27+ untilBurnHeight,
28+ } : {
29+ amount : number ;
30+ poolAddress : Account ;
31+ poolRewardAccount ?: Account ;
32+ untilBurnHeight ?: number ;
33+ }
3234) : Promise < TxBroadcastResult > => {
3335 let poxAddressCV ;
3436 if ( poolRewardAccount ) {
@@ -69,13 +71,13 @@ export const broadcastDelegateSTX = async (
6971 return result ;
7072} ;
7173
72- export const broadcastRevokeDelegateStx = async (
73- poxVersion : number ,
74- network : StacksNetwork ,
75- account : Account ,
76- fee : number ,
77- nonce : number
78- ) : Promise < TxBroadcastResult > => {
74+ export const broadcastRevokeDelegateStx = async ( {
75+ poxVersion,
76+ network,
77+ account,
78+ fee,
79+ nonce,
80+ } : BroadcastOptions ) : Promise < TxBroadcastResult > => {
7981 const txOptions = {
8082 contractAddress : Contracts . POX_1 . address ,
8183 contractName : poxVersion == 1 ? Contracts . POX_1 . name : Contracts . POX_2 . name ,
@@ -95,16 +97,20 @@ export const broadcastRevokeDelegateStx = async (
9597} ;
9698
9799export const broadcastDelegateStackSTX = async (
98- poxVersion : number ,
99- network : StacksNetwork ,
100- account : Account ,
101- fee : number ,
102- nonce : number ,
103- stacker : Account ,
104- amount : number ,
105- poolRewardAccount : Account ,
106- startBurnHeight : number ,
107- lockPeriodCycles : number
100+ { poxVersion, network, account, fee, nonce } : BroadcastOptions ,
101+ {
102+ stacker,
103+ amount,
104+ poolRewardAccount,
105+ startBurnHeight,
106+ lockPeriodCycles,
107+ } : {
108+ stacker : Account ;
109+ amount : number ;
110+ poolRewardAccount : Account ;
111+ startBurnHeight : number ;
112+ lockPeriodCycles : number ;
113+ }
108114) : Promise < TxBroadcastResult > => {
109115 const { version, data } = decodeBtcAddress ( poolRewardAccount . btcAddress ) ;
110116 const poxAddress = {
@@ -137,14 +143,12 @@ export const broadcastDelegateStackSTX = async (
137143} ;
138144
139145export const broadcastDelegateStackExtend = async (
140- poxVersion : number ,
141- network : StacksNetwork ,
142- account : Account ,
143- fee : number ,
144- nonce : number ,
145- stacker : Account ,
146- poolRewardAccount : Account ,
147- extendByCount : number
146+ { poxVersion, network, account, fee, nonce } : BroadcastOptions ,
147+ {
148+ stacker,
149+ poolRewardAccount,
150+ extendByCount,
151+ } : { stacker : Account ; poolRewardAccount : Account ; extendByCount : number }
148152) : Promise < TxBroadcastResult > => {
149153 const { version, data } = decodeBtcAddress ( poolRewardAccount . btcAddress ) ;
150154 const poxAddress = {
@@ -175,14 +179,16 @@ export const broadcastDelegateStackExtend = async (
175179} ;
176180
177181export const broadcastDelegateStackIncrease = async (
178- poxVersion : number ,
179- network : StacksNetwork ,
180- account : Account ,
181- fee : number ,
182- nonce : number ,
183- stacker : Account ,
184- poolRewardAccount : Account ,
185- increaseByAmountUstx : number
182+ { poxVersion, network, account, fee, nonce } : BroadcastOptions ,
183+ {
184+ stacker,
185+ poolRewardAccount,
186+ increaseByAmountUstx,
187+ } : {
188+ stacker : Account ;
189+ poolRewardAccount : Account ;
190+ increaseByAmountUstx : number ;
191+ }
186192) : Promise < TxBroadcastResult > => {
187193 const { version, data } = decodeBtcAddress ( poolRewardAccount . btcAddress ) ;
188194 const poxAddress = {
@@ -225,13 +231,11 @@ export const broadcastDelegateStackIncrease = async (
225231 * @returns
226232 */
227233export const broadcastStackAggregationCommitIndexed = async (
228- poxVersion : number ,
229- network : StacksNetwork ,
230- account : Account ,
231- fee : number ,
232- nonce : number ,
233- poolRewardAccount : Account ,
234- cycleId : number
234+ { poxVersion, network, account, fee, nonce } : BroadcastOptions ,
235+ {
236+ poolRewardAccount,
237+ cycleId,
238+ } : { poolRewardAccount : Account ; cycleId : number }
235239) : Promise < TxBroadcastResult > => {
236240 const { version, data } = decodeBtcAddress ( poolRewardAccount . btcAddress ) ;
237241 const poxAddress = {
@@ -261,13 +265,12 @@ export const broadcastStackAggregationCommitIndexed = async (
261265} ;
262266
263267export const broadcastStackAggregationIncrease = async (
264- network : StacksNetwork ,
265- account : Account ,
266- fee : number ,
267- nonce : number ,
268- poolRewardAccount : Account ,
269- cycleId : number ,
270- rewardIndex : number
268+ { network, account, fee, nonce } : BroadcastOptionsPox2 ,
269+ {
270+ poolRewardAccount,
271+ cycleId,
272+ rewardIndex,
273+ } : { poolRewardAccount : Account ; cycleId : number ; rewardIndex : number }
271274) : Promise < TxBroadcastResult > => {
272275 const { version, data } = decodeBtcAddress ( poolRewardAccount . btcAddress ) ;
273276 const poxAddress = {
0 commit comments