Skip to content

Commit

Permalink
Deletin unused components of previous Pegout form
Browse files Browse the repository at this point in the history
  • Loading branch information
ronaldsg20 committed Oct 24, 2024
1 parent feb4d91 commit f083b3c
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 748 deletions.
51 changes: 0 additions & 51 deletions src/common/services/BridgeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@ import { bridge } from '@rsksmart/rsk-precompiled-abis';
import Web3 from 'web3';
import { Contract } from 'web3-eth-contract';
import { EnvironmentAccessorService } from '@/common/services/enviroment-accessor.service';
import * as constants from '@/common/store/constants';

export class BridgeService {
private bridgeContract: Contract;

private web3: Web3;

private totalRbtcStock = constants.TOTAL_RBTC_STOCK;

constructor() {
this.web3 = new Web3(EnvironmentAccessorService.getEnvironmentVariables().vueAppRskNodeHost);
this.bridgeContract = bridge.build(this.web3);
Expand All @@ -36,54 +33,6 @@ export class BridgeService {
});
}

public getLockingCapAmount(): Promise<number> {
return new Promise<number>((resolve, reject) => {
this.bridgeContract.methods
.getLockingCap()
.call()
.then((lockingCap: string) => resolve(Number(lockingCap)))
.catch(reject);
});
}

public getRbtcInCirculation(): Promise<number> {
return new Promise<number>((resolve, reject) => {
this.web3.eth
.getBalance(bridge.address)
.then((balance: bigint) => {
const amount = Number(
this.web3.utils.toWei(
this.web3.utils.toBigInt(this.totalRbtcStock),
'wei',
),
) - Number(balance);
resolve(amount);
})
.catch((reason) => {
reject(reason);
});
});
}

public getPeginAvailability(): Promise<number> {
return new Promise<number>((resolve, reject) => {
Promise.all([this.getLockingCapAmount(), this.getRbtcInCirculation()])
.then(([lockingCap, rbtcInCirculation]) => {
const rbtcInCirculationToSatoshis = Math.round(rbtcInCirculation / 1e10);
let availability = lockingCap - rbtcInCirculationToSatoshis;
availability = availability > 0 ? availability : 0;
const maxAllowed = EnvironmentAccessorService.getEnvironmentVariables()
.maxAmountAllowedInSatoshis ? Number(EnvironmentAccessorService
.getEnvironmentVariables().maxAmountAllowedInSatoshis)
: Infinity;
resolve(Math.min(availability, maxAllowed));
})
.catch((reason) => {
reject(reason);
});
});
}

public getEstimatedFeesForNextPegOutEvent(): Promise<bigint> {
return new Promise<bigint>((resolve, reject) => {
this.bridgeContract.methods
Expand Down
2 changes: 0 additions & 2 deletions src/common/store/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ export const OPERATION_AMOUNT = 'OPERATION_AMOUNT';
export const DERIVE_BTC_ADDRESS_DOCUMENTATION_URL = 'https://dev.rootstock.io/guides/two-way-peg-app/pegout/deriving-electrum/';
export const RLOGIN_METAMASK_WALLET = 'MetaMask';

export const TOTAL_RBTC_STOCK = 21000000;

// devices
export const IS_TREZOR_CONNECTED = 'IS_TREZOR_CONNECTED';

Expand Down
298 changes: 0 additions & 298 deletions src/pegout/components/PegOutForm.vue

This file was deleted.

Loading

0 comments on commit f083b3c

Please sign in to comment.