Remove laucnhpad

Applies diff from https://github.com/cosmos/cosmjs/pull/1015
This commit is contained in:
Simon Warta
2022-02-08 13:56:18 +01:00
parent 1cfda9dccf
commit 9970f77f18
105 changed files with 110 additions and 9216 deletions
+15 -23
View File
@@ -45,37 +45,29 @@ $ cosmwasm-cli
```ts
// Get account information
const { account_number, sequence } = (await client.authAccounts(faucetAddress))
.result.value;
const account = await client.getAccount(faucetAddress);
// Craft a send transaction
const emptyAddress = Bech32.encode("cosmos", Random.getBytes(20));
const memo = "My first contract on chain";
const sendTokensMsg: MsgSend = {
type: "cosmos-sdk/MsgSend",
value: {
from_address: faucetAddress,
to_address: emptyAddress,
amount: [
{
denom: "ucosm",
amount: "1234567",
},
],
},
const memo = "My very first tx!";
const msgSend = {
fromAddress: faucetAddress,
toAddress: emptyAddress,
amount: coins(1234, "ucosm"),
};
const signDoc = makeSignDoc(
[sendTokensMsg],
const msgAny = {
typeUrl: "/cosmos.bank.v1beta1.MsgSend",
value: msgSend,
};
// Broadcast and sign the transaction
const broadcastResult = await client.signAndBroadcast(
faucetAddress,
[msgAny],
defaultFee,
defaultNetworkId,
memo,
account_number,
sequence,
);
const { signed, signature } = await wallet.signAmino(faucetAddress, signDoc);
const signedTx = makeStdTx(signed, signature);
const broadcastResult = await client.broadcastTx(signedTx);
```
## Extended helpers
+31 -28
View File
@@ -1,45 +1,48 @@
import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
import {
coin,
coins,
makeSignDoc,
makeStdTx,
CosmosClient,
MsgDelegate,
Secp256k1HdWallet,
} from "@cosmjs/launchpad";
MsgDelegateEncodeObject,
SigningStargateClient,
calculateFee,
assertIsDeliverTxSuccess,
GasPrice,
} from "@cosmjs/stargate";
const wallet = await Secp256k1HdWallet.fromMnemonic(
// Wallet
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(
"enlist hip relief stomach skate base shallow young switch frequent cry park",
);
const [{ address: senderAddress }] = await wallet.getAccounts();
const [{ address: signerAddress }] = await wallet.getAccounts();
console.log("Signer address:", signerAddress);
const client = new CosmosClient("http://localhost:1317");
// Network config
const rpcEndpoint = "ws://localhost:26658";
const gasPrice = GasPrice.fromString("0.025ucosm");
const msg: MsgDelegate = {
type: "cosmos-sdk/MsgDelegate",
// Setup client
const client = await SigningStargateClient.connectWithSigner(rpcEndpoint, wallet);
// Send delegate transaction
const msg: MsgDelegateEncodeObject = {
typeUrl: "/cosmos.staking.v1beta1.MsgDelegate",
value: {
delegator_address: senderAddress,
// To get the proper validator address, start the demo chain (./scripts/launchpad/start.sh), then run:
// curl http://localhost:1317/staking/validators | jq '.result[0].operator_address'
validator_address: "cosmosvaloper1yfkkk04ve8a0sugj4fe6q6zxuvmvza8r3arurr",
delegatorAddress: signerAddress,
// To get the proper validator address, start the demo chain (./scripts/simapp42/start.sh), then run:
// curl http://localhost:1318/staking/validators | jq '.result[0].operator_address'
validatorAddress: "cosmosvaloper1urk9gy7cfws0ak9x5nu7lx4un9n6gqkrp230jk",
amount: coin(300000, "ustake"),
},
};
const fee = {
amount: coins(2000, "ucosm"),
gas: "180000", // 180k
};
const fee = calculateFee(180_000, gasPrice);
const memo = "Use your power wisely";
const chainId = await client.getChainId();
console.log("Connected to chain:", chainId);
const { accountNumber, sequence } = await client.getSequence(senderAddress);
console.log("Account/sequence:", accountNumber, sequence);
const signDoc = makeSignDoc([msg], fee, chainId, memo, accountNumber, sequence);
const { signed, signature } = await wallet.signAmino(senderAddress, signDoc);
const signedTx = makeStdTx(signed, signature);
const result = await client.broadcastTx(signedTx);
const result = await client.signAndBroadcast(signerAddress, [msg], fee, memo);
console.log("Broadcast result:", result);
assertIsDeliverTxSuccess(result);
console.log("Successfully broadcasted:", result);
client.disconnect();
+9 -5
View File
@@ -1,7 +1,11 @@
import { LcdClient, Secp256k1HdWallet, StdFee } from "@cosmjs/launchpad";
import { StdFee, SigningStargateClient } from "@cosmjs/stargate";
import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
import { MsgSend } from "cosmjs-types/cosmos/bank/v1beta1/tx";
import { coins } from "@cosmjs/amino";
import { Bech32 } from "@cosmjs/encoding";
import { Random } from "@cosmjs/crypto";
const defaultHttpUrl = "http://localhost:1317";
const defaultNetworkId = "testing";
const defaultHttpUrl = "http://localhost:26658";
const defaultFee: StdFee = {
amount: [
{
@@ -16,5 +20,5 @@ const faucetMnemonic =
"economy stock theory fatal elder harbor betray wasp final emotion task crumble siren bottom lizard educate guess current outdoor pair theory focus wife stone";
const faucetAddress = "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6";
const wallet = await Secp256k1HdWallet.fromMnemonic(faucetMnemonic);
const client = new LcdClient(defaultHttpUrl);
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(faucetMnemonic);
const client = await SigningStargateClient.connectWithSigner(defaultHttpUrl, wallet);
-1
View File
@@ -45,7 +45,6 @@
"@cosmjs/crypto": "workspace:packages/crypto",
"@cosmjs/encoding": "workspace:packages/encoding",
"@cosmjs/faucet-client": "workspace:packages/faucet-client",
"@cosmjs/launchpad": "workspace:packages/launchpad",
"@cosmjs/math": "workspace:packages/math",
"@cosmjs/proto-signing": "workspace:packages/proto-signing",
"@cosmjs/stargate": "workspace:packages/stargate",
+1 -1
View File
@@ -5,7 +5,7 @@ command -v shellcheck >/dev/null && shellcheck "$0"
if [ -n "${WASMD_ENABLED:-}" ]; then
yarn node ./bin/cosmwasm-cli --init examples/cosmwasm.ts --code "process.exit(0)"
fi
if [ -n "${LAUNCHPAD_ENABLED:-}" ]; then
if [ -n "${SIMAPP42_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)"