Merge pull request #332 from CosmWasm/test-examples
Test CLI example scripts
This commit is contained in:
commit
4802af044a
@ -139,6 +139,18 @@ jobs:
|
||||
environment:
|
||||
SKIP_BUILD: 1
|
||||
command: yarn selftest
|
||||
- run:
|
||||
name: Run CLI examples
|
||||
working_directory: packages/cli
|
||||
environment:
|
||||
SKIP_BUILD: 1
|
||||
command: |
|
||||
./bin/cosmwasm-cli --init examples/delegate.ts --code "process.exit(0)"
|
||||
./bin/cosmwasm-cli --init examples/faucet_addresses.ts --code "process.exit(0)"
|
||||
./bin/cosmwasm-cli --init examples/generate_address.ts --code "process.exit(0)"
|
||||
./bin/cosmwasm-cli --init examples/helpers.ts --code "process.exit(0)"
|
||||
./bin/cosmwasm-cli --init examples/local_faucet.ts --code "process.exit(0)"
|
||||
./bin/cosmwasm-cli --init examples/mask.ts --code "process.exit(0)"
|
||||
- run:
|
||||
command: ./scripts/wasmd/stop.sh
|
||||
- run:
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
|
||||
## HEAD
|
||||
|
||||
- @cosmjs/cli: Now supports HTTPs URLs for `--init` code sources.
|
||||
- @cosmjs/cli: Now supports adding code directly via `--code`.
|
||||
- @cosmjs/cosmwasm: Rename `CosmWasmClient.getNonce` method to `.getSequence`.
|
||||
- @cosmjs/cosmwasm: Remove `RestClient` class in favour of new modular
|
||||
`LcdClient` class from @cosmjs/sdk38.
|
||||
|
||||
@ -5,5 +5,5 @@ for (let i of [0, 1, 2, 3, 4]) {
|
||||
const wallet = await Secp256k1Wallet.fromMnemonic(mnemonic, makeCosmoshubPath(i), "cosmos");
|
||||
const [{ address, pubkey }] = await wallet.getAccounts();
|
||||
console.info(`Address ${i}: ${address}`);
|
||||
console.info(`Pubkey ${i}: ${pubkey}`);
|
||||
console.info(`Pubkey ${i}: ${toBase64(pubkey)}`);
|
||||
}
|
||||
|
||||
@ -3,5 +3,5 @@ const wallet = await Secp256k1Wallet.fromMnemonic(mnemonic);
|
||||
const [{ address, pubkey }] = await wallet.getAccounts();
|
||||
|
||||
console.info("mnemonic:", mnemonic);
|
||||
console.info("pubkey:", pubkey);
|
||||
console.info("pubkey:", encodeSecp256k1Pubkey(pubkey));
|
||||
console.info("address:", address);
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import axios from "axios";
|
||||
import * as fs from "fs";
|
||||
import { join } from "path";
|
||||
import yargs from "yargs";
|
||||
@ -6,12 +7,18 @@ import { TsRepl } from "./tsrepl";
|
||||
|
||||
import colors = require("colors/safe");
|
||||
|
||||
export function main(originalArgs: readonly string[]): void {
|
||||
export async function main(originalArgs: readonly string[]): Promise<void> {
|
||||
const args = yargs
|
||||
.options({
|
||||
// User options (we get --help and --version for free)
|
||||
init: {
|
||||
describe: "Read initial TypeScript code from files",
|
||||
describe:
|
||||
"Read initial TypeScript code from the given sources. This can be URLs (supported schemes: https) or local file paths.",
|
||||
type: "array",
|
||||
},
|
||||
code: {
|
||||
describe:
|
||||
"Add initial TypeScript code from the argument. All code arguments are processed after all init arguments.",
|
||||
type: "array",
|
||||
},
|
||||
// Maintainer options
|
||||
@ -24,7 +31,7 @@ export function main(originalArgs: readonly string[]): void {
|
||||
type: "boolean",
|
||||
},
|
||||
})
|
||||
.group(["init", "help", "version"], "User options")
|
||||
.group(["init", "code", "help", "version"], "User options")
|
||||
.group(["debug", "selftest"], "Maintainer options")
|
||||
.parse(originalArgs);
|
||||
|
||||
@ -155,9 +162,21 @@ export function main(originalArgs: readonly string[]): void {
|
||||
}
|
||||
|
||||
if (args.init) {
|
||||
for (const path of args.init.map((arg) => arg.toString())) {
|
||||
if (args.debug) console.info(`Adding file: '${path}' ...`);
|
||||
init += fs.readFileSync(path, "utf8") + "\n";
|
||||
for (const source of args.init.map((arg) => arg.toString())) {
|
||||
if (args.debug) console.info(`Adding code from: '${source}' ...`);
|
||||
if (source.startsWith("https://")) {
|
||||
const response = await axios.get(source);
|
||||
init += response.data + "\n";
|
||||
} else {
|
||||
init += fs.readFileSync(source, "utf8") + "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (args.code) {
|
||||
for (const code of args.code.map((arg) => arg.toString())) {
|
||||
if (args.debug) console.info(`Adding code: '${code}' ...`);
|
||||
init += `${code}\n`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user