Skip to content

Commit

Permalink
handle unbonded nominator
Browse files Browse the repository at this point in the history
  • Loading branch information
will pankiewicz authored and will pankiewicz committed Feb 14, 2024
1 parent c5e2aeb commit 11ff0f6
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 19 deletions.
2 changes: 1 addition & 1 deletion apps/1kv-backend-staging/templates/kusama-otv-backend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
source:
repoURL: https://w3f.github.io/helm-charts/
chart: otv-backend
targetRevision: v3.0.14
targetRevision: v3.0.15
plugin:
env:
- name: HELM_VALUES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
source:
repoURL: https://w3f.github.io/helm-charts/
chart: otv-backend
targetRevision: v3.0.14
targetRevision: v3.0.15
plugin:
env:
- name: HELM_VALUES
Expand Down
2 changes: 1 addition & 1 deletion apps/1kv-backend/templates/kusama-otv-backend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
source:
repoURL: https://w3f.github.io/helm-charts/
chart: otv-backend
targetRevision: v3.0.14
targetRevision: v3.0.15
plugin:
env:
- name: HELM_VALUES
Expand Down
2 changes: 1 addition & 1 deletion apps/1kv-backend/templates/polkadot-otv-backend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
source:
repoURL: https://w3f.github.io/helm-charts/
chart: otv-backend
targetRevision: v3.0.14
targetRevision: v3.0.15
plugin:
env:
- name: HELM_VALUES
Expand Down
4 changes: 2 additions & 2 deletions charts/otv-backend/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
description: 1K Validators Backend
name: otv-backend
version: v3.0.14
appVersion: v3.0.14
version: v3.0.15
appVersion: v3.0.15
apiVersion: v2
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@1kv/common",
"version": "3.0.14",
"version": "3.0.15",
"description": "Services for running the Thousand Validator Program.",
"main": "build/index.js",
"types": "build/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@1kv/core",
"version": "3.0.14",
"version": "3.0.15",
"description": "Services for running the Thousand Validator Program.",
"main": "index.js",
"scripts": {
Expand Down
33 changes: 25 additions & 8 deletions packages/core/src/nominator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,21 @@ export default class Nominator {
}

public async stash(): Promise<any> {
const api = this.handler.getApi();
const ledger = await api.query.staking.ledger(this.controller);
if (!ledger.isSome) {
logger.warn(`Account ${this.controller} is not a controller account!`);
return "0x";
}
const { stash } = ledger.unwrap();
try {
const api = this.handler.getApi();
const ledger = await api.query.staking.ledger(this.controller);
if (!ledger.isSome) {
logger.warn(`Account ${this.controller} is not bonded!`);
return "0x";
}
const { stash } = ledger.unwrap();

return stash;
return stash;
} catch (e) {
logger.error(`Error getting stash for ${this.controller}: ${e}`, label);
logger.error(e, label);
return this.controller;
}
}

public async payee(): Promise<any> {
Expand Down Expand Up @@ -156,6 +162,17 @@ export default class Nominator {
} else {
const api = this.handler.getApi();

try {
const controller = await api.query.staking.bonded(this.controller);
if (controller.isNone) {
logger.warn(`Account ${this.controller} is not bonded!`);
return false;
}
} catch (e) {
logger.error(`Error checking if ${this.controller} is bonded: ${e}`);
return false;
}

let tx: SubmittableExtrinsic<"promise">;

// Start an announcement for a delayed proxy tx
Expand Down
2 changes: 1 addition & 1 deletion packages/gateway/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@1kv/gateway",
"version": "3.0.14",
"version": "3.0.15",
"description": "Services for running the Thousand Validator Program.",
"main": "build/index.js",
"types": "build/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/telemetry/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@1kv/telemetry",
"version": "3.0.14",
"version": "3.0.15",
"description": "Services for running the Thousand Validator Program.",
"main": "build/index.js",
"types": "build/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/worker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@1kv/worker",
"version": "3.0.14",
"version": "3.0.15",
"description": "Services for running the Thousand Validator Program.",
"main": "build/index.js",
"types": "build/index.d.ts",
Expand Down

0 comments on commit 11ff0f6

Please sign in to comment.