From 5ba20268dde00a5116239c521af0298a933a6408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Tue, 22 Jun 2021 17:15:20 +0100 Subject: [PATCH] Allow passing optional explicit bond value (#652) * Allows passing an optional argument to specify bond value * Fixed incorrect coin array usage * Using minimum gateway bond for gateway bonding * Bumped validator client version number * Made the explicit bond value required as an argument --- clients/validator/package.json | 2 +- clients/validator/src/index.ts | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/clients/validator/package.json b/clients/validator/package.json index acbcb713c5..630678b4d6 100644 --- a/clients/validator/package.json +++ b/clients/validator/package.json @@ -1,6 +1,6 @@ { "name": "@nymproject/nym-validator-client", - "version": "0.12.1", + "version": "0.13.0", "description": "A TypeScript client for interacting with smart contracts in Nym validators", "repository": "https://github.com/nymtech/nym", "main": "./dist/index.js", diff --git a/clients/validator/src/index.ts b/clients/validator/src/index.ts index 851bea5fd3..9c52fd3f38 100644 --- a/clients/validator/src/index.ts +++ b/clients/validator/src/index.ts @@ -254,10 +254,9 @@ export default class ValidatorClient { /** * Announce a mixnode, paying a fee. */ - async bondMixnode(mixNode: MixNode): Promise { + async bondMixnode(mixNode: MixNode, bond: Coin): Promise { if (this.client instanceof NetClient) { - const bond = [await this.minimumMixnodeBond()]; - const result = await this.client.executeContract(this.client.clientAddress, this.contractAddress, { bond_mixnode: { mix_node: mixNode } }, "adding mixnode", bond).catch((err) => this.handleRequestFailure(err)); + const result = await this.client.executeContract(this.client.clientAddress, this.contractAddress, { bond_mixnode: { mix_node: mixNode } }, "adding mixnode", [bond]).catch((err) => this.handleRequestFailure(err)); console.log(`account ${this.client.clientAddress} added mixnode with ${mixNode.host}`); return result; } else { @@ -401,9 +400,8 @@ export default class ValidatorClient { /** * Announce a gateway, paying a fee. */ - async bondGateway(gateway: Gateway): Promise { + async bondGateway(gateway: Gateway, bond: Coin): Promise { if (this.client instanceof NetClient) { - const bond = await this.minimumGatewayBond() const result = await this.client.executeContract(this.client.clientAddress, this.contractAddress, {bond_gateway: {gateway: gateway}}, "adding gateway", [bond]).catch((err) => this.handleRequestFailure(err)); console.log(`account ${this.client.clientAddress} added gateway with ${gateway.mix_host}`); return result;