amend code, as described on PR, trialled and testing on QA

This commit is contained in:
Tommy Verrall
2024-02-08 15:46:21 +00:00
parent fd68debf9d
commit 23ba8298be
5 changed files with 35 additions and 53 deletions
-1
View File
@@ -12,7 +12,6 @@ bip39 = { workspace = true }
bs58 = "0.4"
comfy-table = "6.0.0"
cfg-if = "1.0.0"
chrono = "0.4.31"
clap = { workspace = true, features = ["derive"] }
csv = "1.3.0"
cw-utils = { workspace = true }
@@ -1,4 +1,4 @@
n1q85lscptz860j3dx92f8phaeaw08j2l5dt7adq,50,nym
n136ckky0n39eskewg04xhvahq9yp9f7sgtnxytt,50,unym
n1xh7ru0zp67czxhvx0r5e8ur7rvg6n3ymmje0ju,50,nyx
n13mpm4aj03alffnvz2x9ynjy4u3cxemxn2xw34w,50,unyx
n1xh7ru0zp67czxhvx0r5e8ur7rvg6n3ymmje0ju,50,unyx
n13mpm4aj03alffnvz2x9ynjy4u3cxemxn2xw34w,5000,nyx
1 n1q85lscptz860j3dx92f8phaeaw08j2l5dt7adq 50 nym
2 n136ckky0n39eskewg04xhvahq9yp9f7sgtnxytt 50 unym
3 n1xh7ru0zp67czxhvx0r5e8ur7rvg6n3ymmje0ju 50 nyx unyx
4 n13mpm4aj03alffnvz2x9ynjy4u3cxemxn2xw34w 50 5000 unyx nyx
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
// Copyright 2023 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0
use clap::{Args, Subcommand};
@@ -1,22 +1,16 @@
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0
use chrono::{DateTime, Utc};
use clap::Parser;
use comfy_table::Table;
use cosmrs::rpc::endpoint::tx::Response;
use cosmwasm_std::{Coin as CosmWasmCoin, Uint128};
use log::{error, info, warn};
use serde_json::json;
use std::ops::MulAssign;
use std::str::FromStr;
use std::time::SystemTime;
use std::{fs, io::Write};
use log::{error, info};
use nym_validator_client::nyxd::{AccountId, Coin};
use serde_json::json;
use std::str::FromStr;
use std::{fs, io::Write};
use crate::context::SigningClient;
use crate::utils::pretty_cosmwasm_coin;
use crate::utils::pretty_coin;
#[derive(Debug, Parser)]
pub struct Args {
@@ -62,10 +56,7 @@ pub async fn send_multiple(args: Args, client: &SigningClient) {
table.set_header(vec!["Address", "Amount"]);
for row in rows.rows.iter() {
table.add_row(vec![
row.address.to_string(),
pretty_cosmwasm_coin(&row.amount),
]);
table.add_row(vec![row.address.to_string(), pretty_coin(&row.amount)]);
}
println!("{table}");
@@ -130,9 +121,8 @@ fn write_output_file(
.append(true)
.open(output_filename)?;
let now = SystemTime::now();
let now: DateTime<Utc> = now.into();
let now = now.to_rfc3339();
let now = time::OffsetDateTime::now_utc();
let now = now.format(&time::format_description::well_known::Rfc3339)?;
let data = rows
.rows
@@ -152,8 +142,9 @@ fn write_output_file(
#[derive(Debug)]
pub struct InputFileRow {
pub address: AccountId,
pub amount: CosmWasmCoin,
pub amount: Coin,
}
pub struct InputFileReader {
pub rows: Vec<InputFileRow>,
}
@@ -165,39 +156,31 @@ impl InputFileReader {
let lines: Vec<String> = file_contents.lines().map(String::from).collect();
for line in lines {
let tokens: Vec<_> = line.split(&[',']).filter(|k| !k.is_empty()).collect();
let tokens: Vec<_> = line.split(',').collect();
if tokens.len() < 3 {
warn!(
return Err(anyhow::anyhow!(
"'{}' does not have enough columns, expecting <address>,<amount>,<denom>",
line
);
continue;
));
}
// try parse amount to u128
let amount = Uint128::from_str(tokens[1]);
if amount.is_err() {
warn!("'{}' has an invalid amount", line);
continue;
}
let mut amount = amount.unwrap();
let mut denom: String = tokens[2].into();
let amount = u128::from_str(tokens[1])
.map_err(|_| anyhow::anyhow!("'{}' has an invalid amount", line))?;
let denom: String = tokens[2].into();
// multiply when a whole token amount, e.g. 50nym (50.123456nym is not allowed, that must be input as 50123456unym)
if !denom.starts_with('u') {
amount.mul_assign(Uint128::new(1_000_000u128));
denom = format!("u{}", denom);
}
let (amount, denom) = if !denom.starts_with('u') {
(amount * 1_000_000u128, format!("u{}", denom))
} else {
(amount, denom)
};
let amount = CosmWasmCoin::new(amount.into(), denom);
let address = AccountId::from_str(tokens[0])
.map_err(|e| anyhow::anyhow!("'{}' has an invalid address: {}", line, e))?;
// try parse address
let address = AccountId::from_str(tokens[0]);
if let Err(e) = address {
warn!("'{}' has an invalid address: {}", line, e);
continue;
}
let address = address.unwrap();
let amount = Coin { amount, denom };
rows.push(InputFileRow { address, amount })
}
+6 -6
View File
@@ -12,18 +12,18 @@ DENOMS_EXPONENT=6
MIXNET_CONTRACT_ADDRESS=n14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sjyvg3g
VESTING_CONTRACT_ADDRESS=n1nc5tatafv6eyq7llkr2gv50ff9e22mnf70qgjlv737ktmt4eswrq73f2nw
COCONUT_BANDWIDTH_CONTRACT_ADDRESS=n1w798gp0zqv3s9hjl3jlnwxtwhykga6rn93p46q2crsdqhaj3y4gs68f74j
GROUP_CONTRACT_ADDRESS=n1sthrn5ep8ls5vzz8f9gp89khhmedahhdqd244dh9uqzk3hx2pzrsvf7zgk
MULTISIG_CONTRACT_ADDRESS=n1sr06m8yqg0wzqqyqvzvp5t07dj4nevx9u8qc7j4qa72qu8e3ct8qledthy
COCONUT_DKG_CONTRACT_ADDRESS=n1udfs22xpxle475m2nz7u47jfa3vngncdegmczwwdx00cmetypa3s7uyuqn
EPHEMERA_CONTRACT_ADDRESS=n19lc9u84cz0yz3fww5283nucc9yvr8gsjmgeul0
COCONUT_BANDWIDTH_CONTRACT_ADDRESS=n1aht6sekk0302hh30eje9a4lq84juwehw2hxv65kjh863ptay0sxs84mhx8
GROUP_CONTRACT_ADDRESS=n17akgf5y2t775k27kulyw8durzsgfedym9wemg0qv3msc4ry0cg2senyl36
MULTISIG_CONTRACT_ADDRESS=n1075wwvq8ypag74tmzeu7a05mplwsa95g2p8wnxhhctv7hlp6y3wq9ttqcg
COCONUT_DKG_CONTRACT_ADDRESS=n1hk7jy0m6ec5gventvgsx8skrz8mrudhqhun0ufg5gaa3mrr83qyq45v2zk
REWARDING_VALIDATOR_ADDRESS=n1rfvpsynktze6wvn6ldskj8xgwfzzk5v6pnff39
NAME_SERVICE_CONTRACT_ADDRESS=n1qum2tr7hh4y7ruzew68c64myjec0dq2s2njf6waja5t0w879lutqadamme
SERVICE_PROVIDER_DIRECTORY_CONTRACT_ADDRESS=n13ehuhysn5mqjeaheeuew2gjs785f6k7jm8vfsqg3jhtpkwppcmzq6m2hmz
STATISTICS_SERVICE_DOMAIN_ADDRESS="https://mainnet-stats.nymte.ch:8090"
EXPLORER_API=https://qa-network-explorer.qa.nymte.ch/api
NYXD="https://qa-validator.qa.nymte.ch/"
NYXD="https://qa-validator.qa.nymte.ch"
NYM_API="https://qa-nym-api.qa.nymte.ch/api"
DKG_TIME_CONFIGURATION="600,300,300,60,60,1209600"
EXIT_POLICY="https://nymtech.net/.wellknown/network-requester/exit-policy.txt"