Skip to content

Commit

Permalink
Merge pull request #7 from agoltzman/main
Browse files Browse the repository at this point in the history
fix: removed controller references
  • Loading branch information
SlavaSereb authored Aug 6, 2023
2 parents 2aa7724 + 42f8231 commit 3b73b81
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

This script allows to stake DOT via the Fireblocks system using the RAW signing API feature.

## :warning: Breaking Change in 2.0.0 :warning:
Version 2.0.0 introduces a breaking change; as per [this forum post](https://forum.polkadot.network/t/staking-controller-deprecation-plan-staking-ui-leads-comms/2748) on Polkadot - the controller is being deprecated.<br>
As a result the following breaking changes were introduced:
* The function `setController` will no longer work and will results in an error
* The function `bond` no longer accepts 4 arguments, instead only 3 arguments - `vaultAccountId: string, amount?: number, rewardDestination?: string` (the `controller` argument was removed)

## Getting started

1. Clone this repo locally
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{
"name": "dot_staking",
"version": "1.0.0",
"version": "2.0.0",
"description": "FB DOT Staking",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"postinstall": "echo \"!!!Breaking Change Introduced!!!\nPlease see README.md\""
},
"author": "",
"license": "ISC",
"dependencies": {
"@polkadot/api": "^10.2.1",
"@polkadot/api": "^10.9.1",
"fireblocks-sdk": ">=1.7.1",
"fs": "0.0.1-security",
"path": "^0.12.7",
Expand Down
9 changes: 4 additions & 5 deletions src/dot-staker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,9 @@ export class DOTStaker {
* Bond an amount of DOT from the stash to the controller
* @param vaultAccountId - Stash vault account ID
* @param amount - the amount to bond (Default is the entire available balance)
* @param controllerAddress - the controller's address
* @param rewardDestination - rewards destination (Stash, Staked or Controller)
*/
public async bond(vaultAccountId: string, amount?: number, controllerAddress?: string, rewardDestination?: string) {
public async bond(vaultAccountId: string, amount?: number, rewardDestination?: string) {

if(!amount) {
await this.refreshBalance(vaultAccountId)
Expand All @@ -77,12 +76,12 @@ export class DOTStaker {

const amountToBond = amount ? amount : this.availableBalance;

const txNote = controllerAddress ? `Bond ${amountToBond} DOT to ${controllerAddress}` : `Bond ${amountToBond} DOT`;
const txNote = `Bond ${amountToBond} DOT`;

await this.sendTransaction({
vaultAccountId,
params: [
'staking.bond', controllerAddress || await this.getPermanentAddress(vaultAccountId),
'staking.bond',
(this.testnet? amountToBond * 1000000000000 : amountToBond * 10000000000).toString(),
rewardDestination? rewardDestination: 'Stash'
],
Expand Down Expand Up @@ -196,7 +195,7 @@ export class DOTStaker {
* @param controllerAddress - new controller address
*/
public async setController(vaultAccountId: string, controllerAddress: string){
await this.sendTransaction({params: ['staking.setController', controllerAddress], vaultAccountId, txNote: `Setting ${controllerAddress} as contoller`})
throw new Error("setController is no longer supported in DOT / KSM / WND, for more information see README.md")
}


Expand Down

0 comments on commit 3b73b81

Please sign in to comment.