-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from subspace/34-create-a-cli-to-target-all-fu…
…nctionality Create a cli to target all functionality
- Loading branch information
Showing
15 changed files
with
148 additions
and
36 deletions.
There are no files selected for viewing
Binary file not shown.
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,110 @@ | ||
import { Command } from 'commander' | ||
|
||
const program = new Command() | ||
console.log( | ||
'\x1b[34m', | ||
` | ||
t) d) k) | ||
t)tTTT d) k) | ||
a)AAAA u) UU t) o)OOO s)SSSS d)DDDD k) KK | ||
a)AAA u) UU t) o) OO ####### s)SSSS d) DD k)KK | ||
a) A u) UU t) o) OO s) d) DD k) KK | ||
a)AAAA u)UUU t)T o)OOO s)SSSS d)DDDD k) KK | ||
`, | ||
'\x1b[33m', | ||
` | ||
l)L | ||
l) | ||
e)EEEEE x) XX a)AAAA m)MM MMM p)PPPP l) e)EEEEE | ||
e)EEEE x)X a)AAA m) MM MM p) PP l) e)EEEE | ||
e) x)X a) A m) MM MM p) PP l) e) | ||
e)EEEE x) XX a)AAAA m) MM p)PPPP l)LL e)EEEE | ||
p) | ||
p) | ||
`, | ||
'\x1b[0m', | ||
) | ||
|
||
program.name('auto-sdk-example-cli').description('CLI for Autonomys functions').version('0.1.0') | ||
|
||
program | ||
.command('address') | ||
.description('Run the address function') | ||
.action(async () => { | ||
const { addressFunction } = await import('./address') | ||
addressFunction() | ||
}) | ||
|
||
program | ||
.command('balance') | ||
.description('Run the balance function') | ||
.action(async () => { | ||
const { balanceFunction } = await import('./balance') | ||
balanceFunction() | ||
}) | ||
|
||
program | ||
.command('transfer') | ||
.description('Run the transfer function') | ||
.action(async () => { | ||
const { transferFunction } = await import('./transfer') | ||
transferFunction() | ||
}) | ||
|
||
program | ||
.command('operators') | ||
.description('Run the operators function') | ||
.action(async () => { | ||
const { operatorsFunction } = await import('./operators') | ||
operatorsFunction() | ||
}) | ||
|
||
program | ||
.command('register-operator') | ||
.description('Run the register operator function') | ||
.action(async () => { | ||
const { registerOperatorFunction } = await import('./register-operator') | ||
registerOperatorFunction() | ||
}) | ||
|
||
program | ||
.command('nominate-operator') | ||
.description('Run the nominate operator function') | ||
.action(async () => { | ||
const { nominateOperatorFunction } = await import('./nominate-operator') | ||
nominateOperatorFunction() | ||
}) | ||
|
||
program | ||
.command('withdraw-stake') | ||
.description('Run the withdraw stake function') | ||
.action(async () => { | ||
const { withdrawStakeFunction } = await import('./withdraw-stake') | ||
withdrawStakeFunction() | ||
}) | ||
|
||
program | ||
.command('deregister-operator') | ||
.description('Run the deregister operator function') | ||
.action(async () => { | ||
const { deregisterOperatorFunction } = await import('./deregister-operator') | ||
deregisterOperatorFunction() | ||
}) | ||
|
||
program | ||
.command('unlock-funds') | ||
.description('Run the unlock funds function') | ||
.action(async () => { | ||
const { unlockFundsFunction } = await import('./unlock-funds') | ||
unlockFundsFunction() | ||
}) | ||
|
||
program | ||
.command('unlock-nominator') | ||
.description('Run the unlock nominator function') | ||
.action(async () => { | ||
const { unlockNominatorFunction } = await import('./unlock-nominator') | ||
unlockNominatorFunction() | ||
}) | ||
|
||
program.parse(process.argv) |
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 |
---|---|---|
@@ -1,33 +1,22 @@ | ||
import { ActivateWalletInput, activateWallet, networks } from '@autonomys/auto-utils' | ||
import { ActivateWalletInput, activateWallet, mockWallets, networks } from '@autonomys/auto-utils' | ||
import { mnemonicGenerate } from '@polkadot/util-crypto' | ||
import 'dotenv/config' | ||
|
||
export const setup = async () => { | ||
if (!process.env.ALICE_SEED) throw new Error('Missing ALICE_SEED in .env') | ||
if (!process.env.BOB_SEED) throw new Error('Missing BOB_SEED in .env') | ||
|
||
const config = | ||
process.env.LOCALHOST !== 'true' | ||
? { networkId: networks[0].id } | ||
: { networkId: 'autonomys-localhost' } | ||
|
||
console.log('\x1b[32m%s\x1b[0m', 'Network:', config.networkId, '\n') | ||
|
||
const { api, accounts: alice } = await activateWallet({ | ||
...config, | ||
uri: process.env.ALICE_SEED, | ||
} as ActivateWalletInput) | ||
|
||
const { accounts: bob } = await activateWallet({ | ||
...config, | ||
uri: process.env.BOB_SEED, | ||
} as ActivateWalletInput) | ||
const wallets = await mockWallets(config) | ||
|
||
const randomMnemonic = mnemonicGenerate() | ||
const { accounts: randomUser } = await activateWallet({ | ||
const { api, accounts: randomUser } = await activateWallet({ | ||
...config, | ||
uri: randomMnemonic, | ||
} as ActivateWalletInput) | ||
|
||
return { api, alice, bob, randomUser } | ||
return { api, alice: wallets[0].accounts, bob: wallets[1].accounts, randomUser } | ||
} |
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