-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* operator * set operator command * operator set * refactor: operator -> manager (#69) * rename owner to admin * rename to manager * revert: owner -> admin * fix: method names Co-authored-by: Linguists <95207870+linguists@users.noreply.github.com> * style: code format * refactor: manager commands Co-authored-by: Linguists <95207870+linguists@users.noreply.github.com>
- Loading branch information
Showing
12 changed files
with
635 additions
and
409 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const { init } = require("../near"); | ||
|
||
exports.command = 'add-manager <address>'; | ||
exports.desc = 'Add manager'; | ||
exports.builder = yargs => { | ||
yargs | ||
.positional('address', { | ||
describe: 'Contract address', | ||
type: 'string' | ||
}) | ||
.option('network', { | ||
describe: 'network ID', | ||
default: 'testnet', | ||
choices: ['testnet', 'mainnet'] | ||
}) | ||
.option('signer', { | ||
describe: 'signer account Id to call contract' | ||
}) | ||
.option('manager', { | ||
describe: 'new manager ID' | ||
}) | ||
.demandOption(['signer', 'manager']) | ||
} | ||
|
||
exports.handler = async function (argv) { | ||
const { address, manager } = argv; | ||
|
||
const near = await init(argv.network); | ||
const signer = await near.account(argv.signer); | ||
|
||
console.log(`Adding manager ${manager}`); | ||
|
||
await signer.functionCall({ | ||
contractId: address, | ||
methodName: 'add_manager', | ||
args: { | ||
new_manager_id: manager | ||
} | ||
}); | ||
|
||
console.log('done'); | ||
} |
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,42 @@ | ||
const { init } = require("../near"); | ||
|
||
exports.command = 'del-manager <address>'; | ||
exports.desc = 'Remove manager'; | ||
exports.builder = yargs => { | ||
yargs | ||
.positional('address', { | ||
describe: 'Contract address', | ||
type: 'string' | ||
}) | ||
.option('network', { | ||
describe: 'network ID', | ||
default: 'testnet', | ||
choices: ['testnet', 'mainnet'] | ||
}) | ||
.option('signer', { | ||
describe: 'signer account Id to call contract' | ||
}) | ||
.option('manager', { | ||
describe: 'manager ID to remove' | ||
}) | ||
.demandOption(['signer', 'manager']) | ||
} | ||
|
||
exports.handler = async function (argv) { | ||
const { address, manager } = argv; | ||
|
||
const near = await init(argv.network); | ||
const signer = await near.account(argv.signer); | ||
|
||
console.log(`Removing manager ${manager}`); | ||
|
||
await signer.functionCall({ | ||
contractId: address, | ||
methodName: 'remove_manager', | ||
args: { | ||
manager_id: manager | ||
} | ||
}); | ||
|
||
console.log('done'); | ||
} |
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,27 @@ | ||
const { init } = require("../near"); | ||
|
||
exports.command = 'list-managers <address>'; | ||
exports.desc = 'List manager'; | ||
exports.builder = yargs => { | ||
yargs | ||
.positional('address', { | ||
describe: 'Contract address', | ||
type: 'string' | ||
}) | ||
.option('network', { | ||
describe: 'network ID', | ||
default: 'testnet', | ||
choices: ['testnet', 'mainnet'] | ||
}) | ||
} | ||
|
||
exports.handler = async function (argv) { | ||
const { address } = argv; | ||
|
||
const near = await init(argv.network); | ||
const contract = await near.account(address); | ||
|
||
const managers = await contract.viewFunction(address, 'get_managers'); | ||
|
||
console.log(managers); | ||
} |
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
Oops, something went wrong.