This repository has been archived by the owner on Oct 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
299 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const qs = require('querystring'); | ||
const { utils } = require('near-api-js'); | ||
|
||
const connect = require('../../utils/connect'); | ||
const inspectResponse = require('../../utils/inspect-response'); | ||
const { assertCredentials } = require('../../utils/credentials'); | ||
const { DEFAULT_NETWORK } = require('../../config'); | ||
|
||
module.exports = { | ||
command: 'validator-stake accountId stakingKey amount', | ||
aliases: ['stake'], | ||
desc: 'Create a staking transaction (for **validators** only)', | ||
builder: (yargs) => yargs | ||
.option('accountId', { | ||
desc: 'Account that wants to become a network validator', | ||
type: 'string', | ||
required: true, | ||
}) | ||
.option('stakingKey', { | ||
desc: 'Public key to stake with (base58 encoded)', | ||
type: 'string', | ||
required: true, | ||
}) | ||
.option('amount', { | ||
desc: 'Amount to stake', | ||
type: 'string', | ||
required: true, | ||
}) | ||
.option('networkId', { | ||
desc: 'Which network to use. Supports: mainnet, testnet, custom', | ||
type: 'string', | ||
default: DEFAULT_NETWORK | ||
}), | ||
handler: stake | ||
}; | ||
|
||
|
||
async function stake(options) { | ||
await assertCredentials(options.accountId, options.networkId, options.keyStore); | ||
console.log(`Staking ${options.amount} (${utils.format.parseNearAmount(options.amount)}N) on ${options.accountId} with public key = ${qs.unescape(options.stakingKey)}.`); | ||
const near = await connect(options); | ||
const account = await near.account(options.accountId); | ||
const result = await account.stake(qs.unescape(options.stakingKey), utils.format.parseNearAmount(options.amount)); | ||
inspectResponse.prettyPrintResponse(result, options); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const { DEFAULT_NETWORK } = require('../../config'); | ||
const connect = require('../../utils/connect'); | ||
const validatorsInfo = require('../../utils/validators-info'); | ||
|
||
module.exports = { | ||
command: 'validators <query>', | ||
desc: 'Info on validators', | ||
handler: validators, | ||
builder: (yargs) => yargs | ||
.option('query', | ||
{ | ||
desc: 'current | next | <block number> | <block hash> to lookup validators at a specific epoch, or "proposals" to see the current proposals', | ||
type: 'string', | ||
default: 'current' | ||
} | ||
) | ||
.option('networkId', { | ||
desc: 'Which network to use. Supports: mainnet, testnet, custom', | ||
type: 'string', | ||
default: DEFAULT_NETWORK | ||
}), | ||
}; | ||
|
||
async function validators(options) { | ||
const near = await connect(options); | ||
|
||
switch (options.query) { | ||
case 'proposals': | ||
await validatorsInfo.showProposalsTable(near); | ||
break; | ||
case 'current': | ||
await validatorsInfo.showValidatorsTable(near, null); | ||
break; | ||
case 'next': | ||
await validatorsInfo.showNextValidatorsTable(near); | ||
break; | ||
default: | ||
await validatorsInfo.showValidatorsTable(near, options.query); | ||
break; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.