Remove unmaintained coralnet.ts and helpers.ts
This commit is contained in:
parent
23c3706ff0
commit
36c5cc3615
@ -160,11 +160,9 @@ jobs:
|
||||
SKIP_BUILD: 1
|
||||
command: |
|
||||
yarn node ./bin/cosmwasm-cli --init examples/cosmwasm.ts --code "process.exit(0)"
|
||||
yarn node ./bin/cosmwasm-cli --init examples/coralnet.ts --code "process.exit(0)"
|
||||
yarn node ./bin/cosmwasm-cli --init examples/delegate.ts --code "process.exit(0)"
|
||||
yarn node ./bin/cosmwasm-cli --init examples/faucet_addresses.ts --code "process.exit(0)"
|
||||
yarn node ./bin/cosmwasm-cli --init examples/generate_address.ts --code "process.exit(0)"
|
||||
yarn node ./bin/cosmwasm-cli --init examples/helpers.ts --code "process.exit(0)"
|
||||
yarn node ./bin/cosmwasm-cli --init examples/local_faucet.ts --code "process.exit(0)"
|
||||
yarn node ./bin/cosmwasm-cli --init examples/mask.ts --code "process.exit(0)"
|
||||
- run:
|
||||
|
||||
@ -1,32 +0,0 @@
|
||||
import { HdPath } from "@cosmjs/crypto";
|
||||
import { CosmWasmFeeTable, SigningCosmWasmClient } from "@cosmjs/cosmwasm-launchpad";
|
||||
import { GasPrice, GasLimits, makeCosmoshubPath, Secp256k1HdWallet } from "@cosmjs/launchpad";
|
||||
|
||||
interface Options {
|
||||
readonly httpUrl: string;
|
||||
readonly bech32prefix: string;
|
||||
readonly hdPaths: readonly HdPath[];
|
||||
readonly gasPrice: GasPrice;
|
||||
readonly gasLimits: Partial<GasLimits<CosmWasmFeeTable>>; // only set the ones you want to override
|
||||
}
|
||||
|
||||
const coralnetOptions: Options = {
|
||||
httpUrl: "https://lcd.coralnet.cosmwasm.com",
|
||||
gasPrice: GasPrice.fromString("0.025ushell"),
|
||||
bech32prefix: "coral",
|
||||
hdPaths: [makeCosmoshubPath(0)],
|
||||
gasLimits: {
|
||||
upload: 1500000,
|
||||
},
|
||||
};
|
||||
|
||||
const wallet = await Secp256k1HdWallet.generate(12, coralnetOptions);
|
||||
const [{ address }] = await wallet.getAccounts();
|
||||
|
||||
const client = new SigningCosmWasmClient(
|
||||
coralnetOptions.httpUrl,
|
||||
address,
|
||||
wallet,
|
||||
coralnetOptions.gasPrice,
|
||||
coralnetOptions.gasLimits,
|
||||
);
|
||||
@ -1,84 +0,0 @@
|
||||
import axios from "axios";
|
||||
import * as fs from "fs";
|
||||
|
||||
import { Bip39, Random } from "@cosmjs/crypto";
|
||||
import { SigningCosmWasmClient } from "@cosmjs/cosmwasm-launchpad";
|
||||
import { logs, GasPrice, Secp256k1HdWallet } from "@cosmjs/launchpad";
|
||||
|
||||
interface Options {
|
||||
httpUrl: string;
|
||||
networkId: string;
|
||||
feeToken: string;
|
||||
gasPrice: number;
|
||||
bech32prefix: string;
|
||||
}
|
||||
|
||||
const defaultOptions: Options = {
|
||||
httpUrl: "https://lcd.demo-10.cosmwasm.com",
|
||||
networkId: "testing",
|
||||
feeToken: "ucosm",
|
||||
gasPrice: 0.025,
|
||||
bech32prefix: "cosmos",
|
||||
};
|
||||
|
||||
const defaultFaucetUrl = "https://faucet.demo-10.cosmwasm.com/credit";
|
||||
|
||||
const connect = async (
|
||||
mnemonic: string,
|
||||
opts: Partial<Options>,
|
||||
): Promise<{
|
||||
client: SigningCosmWasmClient;
|
||||
address: string;
|
||||
}> => {
|
||||
const options: Options = {
|
||||
bech32prefix: opts.bech32prefix ?? defaultOptions.bech32prefix,
|
||||
feeToken: opts.feeToken ?? defaultOptions.feeToken,
|
||||
gasPrice: opts.gasPrice ?? defaultOptions.gasPrice,
|
||||
httpUrl: opts.httpUrl ?? defaultOptions.httpUrl,
|
||||
networkId: opts.networkId ?? defaultOptions.networkId,
|
||||
};
|
||||
const gasPrice = GasPrice.fromString(`${options.gasPrice}${options.feeToken}`);
|
||||
const wallet = await Secp256k1HdWallet.fromMnemonic(mnemonic);
|
||||
const [{ address }] = await wallet.getAccounts();
|
||||
|
||||
const client = new SigningCosmWasmClient(options.httpUrl, address, wallet, gasPrice);
|
||||
return { client, address };
|
||||
};
|
||||
|
||||
// loadOrCreateMnemonic will try to load a mnemonic from the file.
|
||||
// If missing, it will generate a random one and save to the file.
|
||||
//
|
||||
// This is not secure, but does allow simple developer access to persist a
|
||||
// mnemonic between sessions
|
||||
const loadOrCreateMnemonic = (filename: string): string => {
|
||||
try {
|
||||
const mnemonic = fs.readFileSync(filename, "utf8");
|
||||
return mnemonic.trim();
|
||||
} catch (err) {
|
||||
const mnemonic = Bip39.encode(Random.getBytes(16)).toString();
|
||||
fs.writeFileSync(filename, mnemonic, "utf8");
|
||||
return mnemonic;
|
||||
}
|
||||
};
|
||||
|
||||
const randomAddress = async (prefix: string): Promise<string> => {
|
||||
const mnemonic = Bip39.encode(Random.getBytes(16)).toString();
|
||||
return mnemonicToAddress(prefix, mnemonic);
|
||||
};
|
||||
|
||||
const mnemonicToAddress = async (prefix: string, mnemonic: string): Promise<string> => {
|
||||
const wallet = await Secp256k1HdWallet.fromMnemonic(mnemonic);
|
||||
const [{ address }] = await wallet.getAccounts();
|
||||
return address;
|
||||
};
|
||||
|
||||
const downloadWasm = async (url: string): Promise<Uint8Array> => {
|
||||
const r = await axios.get(url, { responseType: "arraybuffer" });
|
||||
if (r.status !== 200) {
|
||||
throw new Error(`Download error: ${r.status}`);
|
||||
}
|
||||
return r.data;
|
||||
};
|
||||
|
||||
const getAttibute = (logs: readonly logs.Log[], key: string): string | undefined =>
|
||||
logs[0].events[0].attributes.find((x) => x.key == key)?.value;
|
||||
@ -5,13 +5,11 @@ command -v shellcheck >/dev/null && shellcheck "$0"
|
||||
if [ -n "${SIMAPP_ENABLED:-}" ]; then
|
||||
yarn node ./bin/cosmwasm-cli --init examples/cosmwasm.ts --code "process.exit(0)"
|
||||
fi
|
||||
yarn node ./bin/cosmwasm-cli --init examples/coralnet.ts --code "process.exit(0)"
|
||||
if [ -n "${LAUNCHPAD_ENABLED:-}" ]; then
|
||||
yarn node ./bin/cosmwasm-cli --init examples/delegate.ts --code "process.exit(0)"
|
||||
fi
|
||||
yarn node ./bin/cosmwasm-cli --init examples/faucet_addresses.ts --code "process.exit(0)"
|
||||
yarn node ./bin/cosmwasm-cli --init examples/generate_address.ts --code "process.exit(0)"
|
||||
yarn node ./bin/cosmwasm-cli --init examples/helpers.ts --code "process.exit(0)"
|
||||
yarn node ./bin/cosmwasm-cli --init examples/local_faucet.ts --code "process.exit(0)"
|
||||
yarn node ./bin/cosmwasm-cli --init examples/mask.ts --code "process.exit(0)"
|
||||
yarn node ./bin/cosmwasm-cli --init examples/multisig_address.ts --code "process.exit(0)"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user