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
+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();