Skip to content

Commit

Permalink
Fix coldstake component
Browse files Browse the repository at this point in the history
  • Loading branch information
thecrypt0hunter committed Feb 24, 2020
1 parent 9874aaa commit 8f580e3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,70 +127,12 @@ export class ColdStakingCreateComponent implements OnInit, OnDestroy {
}
);
};

public getMaxBalance() {

private startSubscriptions() {
this.getWalletBalance();
}

private cancelSubscriptions() {
if (this.walletBalanceSubscription) {
this.walletBalanceSubscription.unsubscribe();
}
};

public send() {
this.isSending = true;
this.buildTransaction();
};

public ngOnDestroy() {
this.cancelSubscriptions();
};

public buildTransaction(): void {
const walletName = this.globalService.getWalletName();
const walletPassword = this.sendForm.get("password").value;
const amount = this.sendForm.get("amount").value;
const hotWalletAddress = this.sendForm.get("hotWalletAddress").value.trim();
const accountName = "account 0";

this.stakingService.createColdStakingAccount(walletName, walletPassword, true)
.subscribe(
createColdStakingAccountResponse => {
this.stakingService.getAddress(walletName, true).subscribe(getAddressResponse => {
this.stakingService.createColdstaking(new ColdStakingSetup(
hotWalletAddress,
getAddressResponse.address,
amount,
walletName,
walletPassword,
accountName,
this.selectedFeeType.value
))
.subscribe(
createColdstakingResponse => {
const transaction = new TransactionSending(createColdstakingResponse.transactionHex);
this.apiService
.sendTransaction(transaction)
.subscribe(
sendTransactionResponse => {
this.modalService.open(ColdStakingCreateSuccessComponent, { backdrop: 'static' }).result
.then(_ => this.activeModal.close());
},
error => {
this.isSending = false;
this.apiError = error.error.errors[0].message;
}
);
},
error => {
this.isSending = false;
this.apiError = error.error.errors[0].message;
}
}
}
);
};
let maxAmount = this.spendableBalance - (this.selectedFeeType.value * 100000000);
this.sendForm.patchValue({ amount: maxAmount / 100000000 });
};

private startSubscriptions() {
this.getWalletBalance();
Expand Down
1 change: 1 addition & 0 deletions xds
Submodule xds added at c38b85

0 comments on commit 8f580e3

Please sign in to comment.