stackswap-front-api-test-02 1.2.6 → 1.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stackswap-front-api-test-02",
3
- "version": "1.2.6",
3
+ "version": "1.2.7",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "start": "tsc -b tsconfig.build.json --watch --verbose",
package/src/index.ts CHANGED
@@ -25,6 +25,7 @@ import {LBTCStakingManager} from "./stackswap/manager/lbtcstaking.manager";
25
25
  import {GroupFarmManager} from "./stackswap/manager/groupfarm.manager";
26
26
  import {BridgeManager} from "./stackswap/manager/bridge.manager";
27
27
  import {Farm3Manager} from "./stackswap/manager/farm3.manager";
28
+ import {hexToCV} from "@stacks/transactions";
28
29
 
29
30
  export interface StackswapAPI {
30
31
  config : StackswapConfig;
@@ -115,18 +116,28 @@ export class StackswapMainnetAPI implements StackswapAPI{
115
116
  getSenderAddress() : string {
116
117
  return this.fixedSenderAddress? this.fixedSenderAddress : this.senderAdderss;
117
118
  }
119
+ getTenureBlockHeight: ()=> Promise<any> = async () => {
120
+ const get_result = await axios.post(`${this.config.STACKS_API_URL()}/v2/contracts/call-read/SP3RF75T6HCZF0DG7ZATSHRBJ3Q17CBYMN1AEBR1Q/tenure-block/get-block-numbers`, {sender:"SP3RF75T6HCZF0DG7ZATSHRBJ3Q17CBYMN1AEBR1Q",arguments:[]}
121
+ );
122
+ return Number((hexToCV(get_result.data.result) as any).value);
123
+ }
118
124
 
125
+ getFastBlockHeight: ()=> Promise<any> = async () => {
126
+ const get_result = await axios.get(`${this.config.STACKS_API_URL()}/v2/info`);
127
+ //TODO should change
128
+ return get_result.data.stacks_tip_height;
129
+ }
119
130
 
120
131
  getCurrentBlock: () => Promise<any> = async () => {
121
132
  //https://stacks-node-api.mainnet.stacks.co/extended/v1/block?limit=0
122
- const get_result = await axios.get(this.config.STACKS_API_URL() + '/extended/v2/block?limit=1');
123
- return get_result.data.total;
133
+ const get_result = await axios.get(this.config.STACKS_API_URL() + '/v2/info');
134
+ return get_result.data.stacks_tip_height;
124
135
  };
125
136
 
126
137
  // @ts-ignore
127
138
  async getCurrentBlocks() {
128
- const get_result = await axios.get(this.config.STACKS_API_URL() + '/extended/v2/block?limit=1');
129
- return {block_height : get_result.data.results[0].height, burn_block_height : get_result.data.results[0].burn_block_height};
139
+ const get_result = await axios.get(this.config.STACKS_API_URL() + '/v2/info');
140
+ return {block_height : get_result.data.stacks_tip_height, burn_block_height : get_result.data.burn_block_height, tenure_block_height : await this.getTenureBlockHeight()};
130
141
  }
131
142
 
132
143
  getQualifiedAddress(address: string): string {