loomchain icon indicating copy to clipboard operation
loomchain copied to clipboard

Reformat dpos3 commands

Open atchapcyp opened this issue 5 years ago • 5 comments

This PR's goal is to make JSON response from dpos3 command more readable. for example :

  • change Address field from base64 to hex
  • change fields that have value as Unix time to ISO date time
  • change LockTimeTier field (TIER_ZERO=2 weeks, TIER_ONE=3 months,TIER_TWO= 6 months, TIER_THREE=1 year)
  • change amount and value field to base 10 number with 18 decimals

Will change more you can request.

ref: https://github.com/loomnetwork/loomchain/issues/1287

  • [ ] I added unit tests for any code that added
  • [ ] I updated the CHANGELOG.md
  • [ ] All IP is original and not copied from another source
  • [ ] I assign all copyright to Loom Network for the code in the pull request

atchapcyp avatar Aug 09 '19 06:08 atchapcyp

dpos3 list-validators command Change from :

{
  "statistics": [
    {
      "address": {
        "chainId": "default",
        "local": "kRrDNPcBTwY1uVpKIiW0XFKSxsY="
      },
      "whitelistAmount": {
        "Value": 1250000000000000000000000
      },
      "locktimeTier": "TIER_THREE",
      "delegationTotal": {
        "Value": 12927004943367014391760122
      },
      "slashPercentage": {
        "Value": 0
      },
      "recentlyMissedBlocks": "306811710398922970",
      "updateWhitelistAmount": null,
      "updateLocktimeTier": "TIER_THREE",
      "jailed": false
    },
]
}

To :

{
  "Statistics": [
    {
      "Address": "0x911aC334f7014f0635b95a4A2225b45C5292C6c6",
      "WhitelistAmount": "1250000.000000000000000000",
      "LocktimeTier": "1 year",
      "DelegationTotal": "12927041.835581495966656070",
      "SlashPercentage": "0",
      "RecentlyMissedBlocks": {
        "Period_1": 356,
        "Period_2": 834,
        "Period_3": 928,
        "Period_4": 1090
      },
      "UpdateWhitelistAmount": "nil",
      "UpdateLocktimeTier": "1 year",
      "Jailed": false
    }, 
  ]
}

atchapcyp avatar Aug 09 '19 07:08 atchapcyp

dpos3 list-candidates Command Changed from

{
  "candidates": [
    {
      "statistic": {
        "address": {
          "chainId": "default",
          "local": "N3ku4rYiaJWcC1T6PVs0Ga/5ddc="
        },
        "whitelistAmount": {
          "Value": 1300000000000000000000000
        },
        "locktimeTier": "TIER_ZERO",
        "delegationTotal": {
          "Value": 1300021123656797570383411
        },
        "slashPercentage": {
          "Value": 0
        },
        "recentlyMissedBlocks": "0",
        "updateWhitelistAmount": null,
        "updateLocktimeTier": "TIER_ZERO",
        "jailed": false
      },
      "candidate": {
        "address": {
          "chainId": "default",
          "local": "N3ku4rYiaJWcC1T6PVs0Ga/5ddc="
        },
        "pubKey": "29oi+cDBL73d7J11Pxg0DnSfZoXOOZhnB2pxfyAKSUA=",
        "fee": "2598",
        "newFee": "2598",
        "state": "REGISTERED",
        "name": "",
        "description": "",
        "website": "",
        "maxReferralPercentage": "0"
      }
    },
  ]
}

To ..

{
  "Statistics": [
    {
      "ValidatorAddress": "0x37792EE2b62268959C0B54fA3d5b3419AfF975d7",
      "WhitelistAmount": "1300000.000000000000000000",
      "LockTimeTier": "2 weeks",
      "DelegationTotal": "1300021.123656797570383411",
      "SlashPercentage": "0",
      "RecentlyMissedBlock": {
        "Period_1": 0,
        "Period_2": 0,
        "Period_3": 0,
        "Period_4": 0
      },
      "UpdateWhitelistAmount": "nil",
      "UpdateLocktimeTier": "",
      "Jailed": false,
      "CandidateAddress": "0x37792EE2b62268959C0B54fA3d5b3419AfF975d7",
      "PubKey": "29oi+cDBL73d7J11Pxg0DnSfZoXOOZhnB2pxfyAKSUA=",
      "Fee": "25.98%",
      "NewFee": "25.98%",
      "State": "REGISTERED",
      "Name": "",
      "Description": "",
      "Website": "",
      "MaxReferralPercentage": 0
    },
  ]
}

atchapcyp avatar Aug 09 '19 17:08 atchapcyp

Fee, NewFee and MaxReferralPercentage are percentage. You can change it from 2598 to 25.98%.

pathornteng avatar Aug 14 '19 07:08 pathornteng

dpos3 check-all-delegations command Change from

{
  "amount": {
    "Value": 1250222039637937547651989
  },
  "weightedAmount": {
    "Value": 1250222039637937547651989
  },
  "delegations": [
    {
      "delegator": {
        "chainId": "default",
        "local": "+05D4rU/lGQwh8CJo/iUhO4pUPE="
      },
      "validator": {
        "chainId": "default",
        "local": "hEUiwOB4zJ8RYIdgWiIK3tksku0="
      },
      "updateValidator": null,
      "index": "1",
      "amount": {
        "Value": 222000000000000000000
      },
      "updateAmount": {
        "Value": 0
      },
      "locktimeTier": "TIER_ZERO",
      "updateLocktimeTier": "TIER_ZERO",
      "lockTime": "1566984905",
      "state": "BONDED",
      "referrer": ""
    },
    {
      "delegator": {
        "chainId": "default",
        "local": "+05D4rU/lGQwh8CJo/iUhO4pUPE="
      },
      "validator": {
        "chainId": "default",
        "local": "hEUiwOB4zJ8RYIdgWiIK3tksku0="
      },
      "updateValidator": null,
      "index": "0",
      "amount": {
        "Value": 696916016467
      },
      "updateAmount": {
        "Value": 0
      },
      "locktimeTier": "TIER_ZERO",
      "updateLocktimeTier": "TIER_ZERO",
      "lockTime": "0",
      "state": "BONDED",
      "referrer": ""
    }
  ]
}

to

{
  "Amount": "1250222.039637937547651989",
  "WeightedAmount": "1250222.039637937547651989",
  "Delegations": [
    {
      "Delegator": "0xfb4E43E2b53f94643087c089A3f89484eE2950f1",
      "Validator": "0x844522c0e078cC9f116087605A220aDEd92c92ed",
      "UpdateValidator": "nil",
      "Index": "1",
      "Amount": "222.000000000000000000",
      "UpdateAmount": "0",
      "LockTimeTier": "2 weeks",
      "UpdateLockTimeTier": "2 weeks",
      "LockTime": "2019-08-28 16:35:05 +0700 +07",
      "State": "BONDED",
      "Referrer": ""
    },
    {
      "Delegator": "0xfb4E43E2b53f94643087c089A3f89484eE2950f1",
      "Validator": "0x844522c0e078cC9f116087605A220aDEd92c92ed",
      "UpdateValidator": "nil",
      "Index": "Rewards",
      "Amount": "696916016467",
      "UpdateAmount": "0",
      "LockTimeTier": "2 weeks",
      "UpdateLockTimeTier": "2 weeks",
      "LockTime": "0",
      "State": "BONDED",
      "Referrer": ""
    },
  ]
}

atchapcyp avatar Aug 14 '19 09:08 atchapcyp

Change dpos3 check-delegation response From

{
  "amount": {
    "Value": 200000013812785791176020
  },
  "weightedAmount": {
    "Value": 200000013812785791176020
  },
  "delegations": [
    {
      "delegator": {
        "chainId": "default",
        "local": "sknmTnnGaJWqm8Oi11c91aUXhpI="
      },
      "validator": {
        "chainId": "default",
        "local": "nKnHP2o+iPyd5zjijGdxmnp8Luc="
      },
      "updateValidator": null,
      "index": "1",
      "amount": {
        "Value": 200000000000000000000000
      },
      "updateAmount": {
        "Value": 0
      },
      "locktimeTier": "TIER_ZERO",
      "updateLocktimeTier": "TIER_ZERO",
      "lockTime": "1566993604",
      "state": "BONDED",
      "referrer": ""
    },
    {
      "delegator": {
        "chainId": "default",
        "local": "sknmTnnGaJWqm8Oi11c91aUXhpI="
      },
      "validator": {
        "chainId": "default",
        "local": "nKnHP2o+iPyd5zjijGdxmnp8Luc="
      },
      "updateValidator": null,
      "index": "0",
      "amount": {
        "Value": 13812785791176020
      },
      "updateAmount": {
        "Value": 0
      },
      "locktimeTier": "TIER_ZERO",
      "updateLocktimeTier": "TIER_ZERO",
      "lockTime": "0",
      "state": "BONDED",
      "referrer": ""
    }
  ]
}

To

{
  "Amount": "200000.013812785791176020",
  "WeightedAmount": "200000.013812785791176020",
  "Delegations": [
    {
      "Delegator": "0xB249e64E79C66895aa9bC3a2d7573Dd5A5178692",
      "Validator": "0x9cA9C73f6a3e88FC9dE738E28c67719a7A7c2eE7",
      "UpdateValidator": "nil",
      "Index": "1",
      "Amount": "200000.000000000000000000",
      "UpdateAmount": "0.000000000000000000",
      "LockTimeTier": "2 weeks",
      "UpdateLockTimeTier": "2 weeks",
      "LockTime": "2019-08-28 19:00:04 +0700 +07",
      "State": "BONDED",
      "Referrer": ""
    },
    {
      "Delegator": "0xB249e64E79C66895aa9bC3a2d7573Dd5A5178692",
      "Validator": "0x9cA9C73f6a3e88FC9dE738E28c67719a7A7c2eE7",
      "UpdateValidator": "nil",
      "Index": "Rewards",
      "Amount": "0.013812785791176020",
      "UpdateAmount": "0.000000000000000000",
      "LockTimeTier": "2 weeks",
      "UpdateLockTimeTier": "2 weeks",
      "LockTime": "0",
      "State": "BONDED",
      "Referrer": ""
    }
  ]
}

atchapcyp avatar Aug 14 '19 12:08 atchapcyp