@mijoco/stx_helpers
Advanced tools
Comparing version 0.4.4 to 0.4.5
@@ -18,3 +18,2 @@ export type DashboardInfoI = { | ||
rewardSetSize: number; | ||
numRewardSetPoxAddresses: number; | ||
numbEntriesRewardCyclePoxList: number; | ||
@@ -21,0 +20,0 @@ totalPoxRejection: number; |
import { Delegation, PoxCycleInfo, Stacker, StackerInfo } from '../pox_types'; | ||
import { VerifySignerKey } from '../signer'; | ||
export declare function getPoxContractFromCycle(cycle: number): Promise<"pox" | "pox-2" | "pox-3" | "pox-4">; | ||
export declare function getPoxContractFromHeight(height: number): Promise<"pox" | "pox-2" | "pox-3" | "pox-4">; | ||
export declare function getPoxContractFromCycle(cycle: number): "pox" | "pox-2" | "pox-3" | "pox-4"; | ||
export declare function getPoxContractFromHeight(height: number): "pox" | "pox-2" | "pox-3" | "pox-4"; | ||
export declare function getBurnHeightToRewardCycle(stacksApi: string, poxContractId: string, height: number): Promise<any>; | ||
@@ -12,5 +12,4 @@ export declare function getRewardCycleToBurnHeight(stacksApi: string, poxContractId: string, cycle: number): Promise<any>; | ||
export declare function getNumbEntriesRewardCyclePoxList(stacksApi: string, poxContractId: string, cycle: number): Promise<any>; | ||
export declare function getRewardSetSize(stacksApi: string, poxContractId: string, cycle: number): Promise<any>; | ||
export declare function getTotalPoxRejection(stacksApi: string, poxContractId: string, cycle: number): Promise<any>; | ||
export declare function getRewardSetSize(stacksApi: string, poxContractId: string, cycle: number): Promise<any>; | ||
export declare function getNumRewardSetPoxAddresses(stacksApi: string, poxContractId: string, cycle: number): Promise<any>; | ||
export declare function getAllowanceContractCallers(stacksApi: string, poxContractId: string, address: string, contract: string, tip?: number | undefined): Promise<any>; | ||
@@ -17,0 +16,0 @@ export declare function getPartialStackedByCycle(stacksApi: string, network: string, poxContractId: string, address: string, cycle: number, sender: string): Promise<any>; |
@@ -21,5 +21,4 @@ "use strict"; | ||
exports.getNumbEntriesRewardCyclePoxList = getNumbEntriesRewardCyclePoxList; | ||
exports.getRewardSetSize = getRewardSetSize; | ||
exports.getTotalPoxRejection = getTotalPoxRejection; | ||
exports.getRewardSetSize = getRewardSetSize; | ||
exports.getNumRewardSetPoxAddresses = getNumRewardSetPoxAddresses; | ||
exports.getAllowanceContractCallers = getAllowanceContractCallers; | ||
@@ -40,32 +39,28 @@ exports.getPartialStackedByCycle = getPartialStackedByCycle; | ||
function getPoxContractFromCycle(cycle) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (cycle < 56) { | ||
return 'pox'; | ||
} | ||
else if (cycle < 60) { | ||
return 'pox-2'; | ||
} | ||
else if (cycle < 84) { | ||
return 'pox-3'; | ||
} | ||
else { | ||
return 'pox-4'; | ||
} | ||
}); | ||
if (cycle < 56) { | ||
return 'pox'; | ||
} | ||
else if (cycle < 60) { | ||
return 'pox-2'; | ||
} | ||
else if (cycle < 84) { | ||
return 'pox-3'; | ||
} | ||
else { | ||
return 'pox-4'; | ||
} | ||
} | ||
function getPoxContractFromHeight(height) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (height < 783650) { | ||
return 'pox'; | ||
} | ||
else if (height < 792050) { | ||
return 'pox-2'; | ||
} | ||
else if (height < 842450) { | ||
return 'pox-3'; | ||
} | ||
else { | ||
return 'pox-4'; | ||
} | ||
}); | ||
if (height < 783650) { | ||
return 'pox'; | ||
} | ||
else if (height < 792050) { | ||
return 'pox-2'; | ||
} | ||
else if (height < 842450) { | ||
return 'pox-3'; | ||
} | ||
else { | ||
return 'pox-4'; | ||
} | ||
} | ||
@@ -114,3 +109,2 @@ function getBurnHeightToRewardCycle(stacksApi, poxContractId, height) { | ||
const totalStacked = yield getTotalUstxStacked(stacksApi, poxContractId, cycle); | ||
const numRewardSetPoxAddresses = yield getNumRewardSetPoxAddresses(stacksApi, poxContractId, cycle); | ||
const numbEntriesRewardCyclePoxList = yield getNumbEntriesRewardCyclePoxList(stacksApi, poxContractId, cycle); | ||
@@ -125,3 +119,2 @@ const totalPoxRejection = yield getTotalPoxRejection(stacksApi, poxContractId, cycle); | ||
rewardSetSize: (cycle > 0 && rewardSetSize) ? Number(rewardSetSize) : 0, | ||
numRewardSetPoxAddresses: (numRewardSetPoxAddresses) ? Number(numRewardSetPoxAddresses) : 0, | ||
numbEntriesRewardCyclePoxList: (numbEntriesRewardCyclePoxList) ? Number(numbEntriesRewardCyclePoxList) : 0, | ||
@@ -137,3 +130,2 @@ totalPoxRejection: (totalPoxRejection) ? Number(totalPoxRejection) : 0, | ||
const totalStacked = yield getTotalUstxStacked(stacksApi, poxContractId, cycle); | ||
const numRewardSetPoxAddresses = yield getNumRewardSetPoxAddresses(stacksApi, poxContractId, cycle); | ||
const numbEntriesRewardCyclePoxList = yield getNumbEntriesRewardCyclePoxList(stacksApi, poxContractId, cycle); | ||
@@ -174,3 +166,2 @@ //const totalPoxRejection = await getTotalPoxRejection(stacksApi, poxContractId, cycle) | ||
rewardSetSize: (cycle > 0 && rewardSetSize) ? Number(rewardSetSize) : 0, | ||
numRewardSetPoxAddresses: (numRewardSetPoxAddresses) ? Number(numRewardSetPoxAddresses) : 0, | ||
numbEntriesRewardCyclePoxList: (numbEntriesRewardCyclePoxList) ? Number(numbEntriesRewardCyclePoxList) : 0, | ||
@@ -221,15 +212,3 @@ totalPoxRejection: -1, | ||
} | ||
function getTotalPoxRejection(stacksApi, poxContractId, cycle) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const functionArgs = [`0x${base_1.hex.encode((0, transactions_1.serializeCV)((0, transactions_1.uintCV)(cycle)))}`]; | ||
const data = { | ||
contractAddress: poxContractId.split('.')[0], | ||
contractName: getPoxContractFromCycle(cycle), | ||
functionName: 'get-total-pox-rejection', | ||
functionArgs, | ||
}; | ||
const val = (yield (0, stacks_node_1.callContractReadOnly)(stacksApi, data)); | ||
return (val.value) ? Number(val.value) : 0; | ||
}); | ||
} | ||
// includes reward slots currently under stacking limit. | ||
function getRewardSetSize(stacksApi, poxContractId, cycle) { | ||
@@ -248,3 +227,3 @@ return __awaiter(this, void 0, void 0, function* () { | ||
} | ||
function getNumRewardSetPoxAddresses(stacksApi, poxContractId, cycle) { | ||
function getTotalPoxRejection(stacksApi, poxContractId, cycle) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -255,12 +234,7 @@ const functionArgs = [`0x${base_1.hex.encode((0, transactions_1.serializeCV)((0, transactions_1.uintCV)(cycle)))}`]; | ||
contractName: getPoxContractFromCycle(cycle), | ||
functionName: 'get-num-reward-set-pox-addresses', | ||
functionName: 'get-total-pox-rejection', | ||
functionArgs, | ||
}; | ||
try { | ||
const result = yield (0, stacks_node_1.callContractReadOnly)(stacksApi, data); | ||
return result.value; | ||
} | ||
catch (e) { | ||
return { stacked: 0 }; | ||
} | ||
const val = (yield (0, stacks_node_1.callContractReadOnly)(stacksApi, data)); | ||
return (val.value) ? Number(val.value) : 0; | ||
}); | ||
@@ -267,0 +241,0 @@ } |
{ | ||
"name": "@mijoco/stx_helpers", | ||
"version": "0.4.4", | ||
"version": "0.4.5", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
144201
3941