Skip to content

Commit 7d17dff

Browse files
mtyszczakvogel76
authored andcommitted
Add hpToVests method to TS interface
1 parent 3d8a519 commit 7d17dff

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

ts/wasm/lib/detailed/base_api.ts

+8
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,14 @@ export class WaxBaseApi implements IWaxBaseInterface {
252252
return safeWasmCall(() => this.proto.cpp_vests_to_hp(vestsAsset, totalVestingFundHiveAsset, totalVestingSharesAsset) as NaiAsset);
253253
}
254254

255+
public hpToVests(hive: TNaiAssetSource, totalVestingFundHive: TNaiAssetSource, totalVestingShares: TNaiAssetSource): NaiAsset {
256+
const hiveAsset = this.createAssetWithRequiredSymbol(EAssetName.HIVE, hive);
257+
const totalVestingFundHiveAsset = this.createAssetWithRequiredSymbol(EAssetName.HIVE, totalVestingFundHive);
258+
const totalVestingSharesAsset = this.createAssetWithRequiredSymbol(EAssetName.VESTS, totalVestingShares);
259+
260+
return safeWasmCall(() => this.proto.cpp_hp_to_vests(hiveAsset, totalVestingFundHiveAsset, totalVestingSharesAsset) as NaiAsset);
261+
}
262+
255263
public hbdToHive(hbd: TNaiAssetSource, base: TNaiAssetSource, quote: TNaiAssetSource): NaiAsset {
256264
const hbdAsset = this.createAssetWithRequiredSymbol(EAssetName.HBD, hbd as NaiAsset);
257265
const baseAsset = this.createAssetWithRequiredSymbol(EAssetName.HBD, base as NaiAsset);

ts/wasm/lib/detailed/interfaces.ts

+8
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,14 @@ export interface IWaxBaseInterface {
770770
*/
771771
vestsToHp(vests: TNaiAssetSource, totalVestingFundHive: TNaiAssetSource, totalVestingShares: TNaiAssetSource): NaiAsset
772772

773+
/**
774+
* Converts HP to VESTS in nai form
775+
* @param {NaiAsset} hive HIVE asset
776+
* @param {NaiAsset} totalVestingFundHive HIVE assest total vesting fund
777+
* @param {NaiAsset} totalVestingShares VESTS asset total shares
778+
*/
779+
hpToVests(hive: TNaiAssetSource, totalVestingFundHive: TNaiAssetSource, totalVestingShares: TNaiAssetSource): NaiAsset;
780+
773781
/**
774782
* Converts HBD to HIVE in nai form
775783
* @param {NaiAsset} hbd HBD asset

ts/wasm/src/wasm_interface.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ json_asset cpp_vests_to_hp(const json_asset& vests, const json_asset& total_vest
145145
return foundation::cpp_vests_to_hp(vests, total_vesting_fund_hive, total_vesting_shares);
146146
}
147147

148+
json_asset cpp_hp_to_vests(const json_asset& vests, const json_asset& total_vesting_fund_hive, const json_asset& total_vesting_shares) const
149+
{
150+
return foundation::cpp_hp_to_vests(vests, total_vesting_fund_hive, total_vesting_shares);
151+
}
152+
148153
result cpp_calculate_inflation_rate_for_block(const uint32_t block_num) const
149154
{
150155
return foundation::cpp_calculate_inflation_rate_for_block( block_num );
@@ -347,6 +352,7 @@ EMSCRIPTEN_BINDINGS(wax_api_instance) {
347352
.function("cpp_calculate_hp_apr", &foundation_wasm::cpp_calculate_hp_apr)
348353
.function("cpp_calculate_inflation_rate_for_block", &foundation_wasm::cpp_calculate_inflation_rate_for_block)
349354
.function("cpp_vests_to_hp", &foundation_wasm::cpp_vests_to_hp)
355+
.function("cpp_hp_to_vests", &foundation_wasm::cpp_hp_to_vests)
350356
.function("cpp_hbd_to_hive", &foundation_wasm::cpp_hbd_to_hive)
351357
.function("cpp_hive_to_hbd", &foundation_wasm::cpp_hive_to_hbd)
352358
.function("cpp_estimate_hive_collateral", &foundation_wasm::cpp_estimate_hive_collateral)

0 commit comments

Comments
 (0)