Convert CLI examples to pen

This commit is contained in:
Simon Warta 2020-02-07 09:35:24 +01:00
parent d46b59db4f
commit 11d369b4a1
4 changed files with 3 additions and 49 deletions

View File

@ -64,9 +64,8 @@ const sendTokensMsg: types.MsgSend = {
},
};
const signBytes = makeSignBytes([sendTokensMsg], defaultFee, defaultNetworkId, memo, account) as SignableBytes;
const rawSignature = await wallet.createTransactionSignature(signer, signBytes, PrehashType.Sha256);
const signature = encodeSecp256k1Signature(signer.pubkey.data, rawSignature);
const signBytes = makeSignBytes([sendTokensMsg], defaultFee, defaultNetworkId, memo, account);
const signature = encodeSecp256k1Signature(pen.pubkey, await pen.createSignature(signBytes));
const signedTx: types.StdTx = {
msg: [sendTokensMsg],
fee: defaultFee,

View File

@ -12,10 +12,7 @@ const defaultFee: types.StdFee = {
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 faucetPath = HdPaths.cosmos(0);
const faucetAddress = "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6";
const wallet = Secp256k1HdWallet.fromMnemonic(faucetMnemonic);
const signer = await wallet.createIdentity("unused_value" as ChainId, faucetPath);
const pen = await Secp256k1Pen.fromMnemonic(faucetMnemonic);
const client = new RestClient(defaultHttpUrl);

View File

@ -34,10 +34,8 @@
],
"dependencies": {
"@cosmwasm/sdk": "^0.0.3",
"@iov/bcp": "^2.0.0-alpha.7",
"@iov/crypto": "^2.0.0-alpha.7",
"@iov/encoding": "^2.0.0-alpha.7",
"@iov/keycontrol": "^2.0.0-alpha.7",
"@iov/utils": "^2.0.0-alpha.7",
"argparse": "^1.0.10",
"babylon": "^6.18.0",

View File

@ -50,29 +50,6 @@ export function main(originalArgs: readonly string[]): void {
"types",
],
],
[
"@iov/bcp",
[
"Address",
"Algorithm",
"ChainId",
"Nonce",
"PrehashType",
"PubkeyBytes",
"SendTransaction",
"SignableBytes",
"TokenTicker",
"TransactionId",
// block info
"BlockInfoPending",
"BlockInfoSucceeded",
"BlockInfoFailed",
"BlockInfo",
"isBlockInfoPending",
"isBlockInfoSucceeded",
"isBlockInfoFailed",
],
],
[
"@iov/crypto",
[
@ -101,20 +78,6 @@ export function main(originalArgs: readonly string[]): void {
"Uint64",
],
],
[
"@iov/keycontrol",
[
"Ed25519HdWallet",
"HdPaths",
"Keyring",
"Secp256k1HdWallet",
"UserProfile",
"Wallet",
"WalletId",
"WalletImplementationIdString",
"WalletSerializationString",
],
],
["@iov/utils", ["sleep"]],
]);
@ -164,9 +127,6 @@ export function main(originalArgs: readonly string[]): void {
const data = Encoding.toAscii("foo bar");
const signature = await pen.createSignature(data);
const profile = new UserProfile();
const wallet = profile.addWallet(Ed25519HdWallet.fromMnemonic("degree tackle suggest window test behind mesh extra cover prepare oak script"));
console.info("Done testing, will exit now.");
process.exit(0);
`;