{"dist":{"shasum":"6083c7c58f336f819dd6c22c9f1ac093b86807d6","tarball":"https://registry.npmjs.org/@cosmjs/launchpad/-/launchpad-0.24.0-alpha.24.tgz","fileCount":96,"integrity":"sha512-dzwuZODL0OBqxl280sPUWXpVUeZXRerMYUYtVcM7upPODx111mIo/9G71U2QohrxVEj/8tUTOXmu4YhP1SU5gg==","signatures":[{"sig":"MEYCIQCFhQmzW8FUr5QXxtj2ffvyjmIpIca36cB0HVjA9CE3bAIhAK5tuzbIzMDaK6kNOeQ8E0QVidfudN/xXPyqAwYs1XJi","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":222039,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgJQVmCRA9TVsSAnZWagAAKpQP/0giP93iRzX/VbbwPTx3\nWJS4CxE0qdX/AThFbD4FzR6ki2j63biijzUg9aW+tzKm3diZi/jbdmvoqnSv\nY6koP1VFA6CBGC4AhXRz5t8X87XkvIDmVTsw+neinoI6DbtTvOArs/cqI1hg\nzGZi5ee+bPVGsV/vLphYpcsHemeHl9zJOf07NfEp85uMb3I7xWfK6cm2oGpu\nxiDjU1NOep/eGVS7T/zHVcKXCRYXeG1rCcdEee6w/qJs1ljkt1I0b6Iql8C8\n3Xn1Fv7Hd8aD1iJv0oIDqlAKwk4sUYdIJ5sAegXp6V0zmXPgB3czkYOI4aIc\np+n1X36/hBtqxl5fmLtb+ytpXupQIHRpad8BAob0rj25tjGiYEUMIy1QQ6UU\nJxksEjeLA+FwK2gM+AsP0b64R3XLufARlNsKpSe5VzAefkicdYZbYpEzM1ju\njcpfahq4iQitAYtqkPfo7PChB2FFFn5mVJztvUIZU7WOskZdqhipVYYYXohK\nIeRnSh/hmdzYlgt9LM1E6fLpHM/61eb/jTyeanBw0mt3v62aBmJVO1HOgF+t\nwdzwezBJu/eWEXsktEDcgy06JrvGsPYr+MAebwUJvbAR5W2mZL+ULg29F+Mc\nbt4iAhAOW42gdsrkKD3m05LSboxvpyOiEGd1+BviQmvcP63qe9hh6t5kl3Gz\nNn1B\r\n=xW5N\r\n-----END PGP SIGNATURE-----\r\n"},"main":"build/index.js","name":"@cosmjs/launchpad","types":"build/index.d.ts","readme":"# @cosmjs/launchpad\n\n[![npm version](https://img.shields.io/npm/v/@cosmjs/launchpad.svg)](https://www.npmjs.com/package/@cosmjs/launchpad)\n\nA client library for the Cosmos SDK 0.37 (cosmoshub-3), 0.38 and 0.39\n(Launchpad). See the article\n[Launchpad — A pre-stargate stable version of the Cosmos SDK](https://blog.cosmos.network/launchpad-a-pre-stargate-stable-version-of-the-cosmos-sdk-e0c58d8c4e24)\nto learn more about launchpad.\n\n## Basic usage\n\nThe basic usage of the package `@cosmjs/launchpad` contains the following:\n\n1. [Create a wallet](#create-a-wallet)\n2. [Sign and broadcast transactions](#sign-and-broadcast-transactions)\n\n### Create a wallet\n\nFor the sake of simplicity we use an in-memory wallet. This is not the safest\nway to store production keys. The following demo code is intended for developers\nusing testnet credentials only. Integrating it into end user facing products\nrequires serious security review.\n\nIf you do not yet have a mnemonic, generate a new wallet with a random mnemonic:\n\n```ts\nimport { Secp256k1HdWallet } from \"@cosmjs/launchpad\";\n\n// …\n\nconst wallet = await Secp256k1HdWallet.generate();\nconsole.log(\"Mnemonic:\", wallet.mnemonic);\n\nconst [{ address }] = await wallet.getAccounts();\nconsole.log(\"Address:\", address);\n```\n\nOr import an existing one:\n\n```ts\nimport { Secp256k1HdWallet } from \"@cosmjs/launchpad\";\n\n// …\n\nconst wallet = await Secp256k1HdWallet.fromMnemonic(\n  // your mnemonic here 👇\n  \"enlist hip relief stomach skate base shallow young switch frequent cry park\",\n);\n\nconst [{ address }] = await wallet.getAccounts();\nconsole.log(\"Address:\", address);\n```\n\n### Sign and broadcast transactions\n\nA wallet holds private keys and can use them for signing transactions. To do so\nwe stick the wallet into a client:\n\n```ts\nimport {\n  Secp256k1HdWallet,\n  SigningCosmosClient,\n  coins,\n} from \"@cosmjs/launchpad\";\n\n// …\n\nconst wallet = await Secp256k1HdWallet.generate();\nconst [{ address }] = await wallet.getAccounts();\nconsole.log(\"Address:\", address);\n\n// Ensure the address has some tokens to spend\n\nconst lcdApi = \"https://…\";\nconst client = new SigningCosmosClient(lcdApi, address, wallet);\n\n// check our balance\nconst account = await client.getAccount();\nconsole.log(\"Account:\", account);\n\n// Send tokens\nconst recipient = \"cosmos1b2340gb2…\";\nawait client.sendTokens(recipient, coins(123, \"uatom\"));\n```\n\nor use custom message types:\n\n```ts\nimport {\n  Secp256k1HdWallet,\n  SigningCosmosClient,\n  coins,\n  coin,\n  MsgDelegate,\n} from \"@cosmjs/launchpad\";\n\n// …\n\nconst wallet = await Secp256k1HdWallet.generate();\nconst [{ address }] = await wallet.getAccounts();\nconsole.log(\"Address:\", address);\n\n// Ensure the address has some tokens to spend\n\nconst lcdApi = \"https://…\";\nconst client = new SigningCosmosClient(lcdApi, address, wallet);\n\n// …\n\nconst msg: MsgDelegate = {\n  type: \"cosmos-sdk/MsgDelegate\",\n  value: {\n    delegator_address: address,\n    validator_address: \"cosmosvaloper1yfkkk04ve8a0sugj4fe6q6zxuvmvza8r3arurr\",\n    amount: coin(300000, \"ustake\"),\n  },\n};\nconst fee = {\n  amount: coins(2000, \"ucosm\"),\n  gas: \"180000\", // 180k\n};\nawait client.signAndBroadcast([msg], fee);\n```\n\n## Advanced usage\n\nHere you will learn a few things that are slightly more advanced:\n\n1. [Sign only](#sign-only)\n2. [Aggregate signatures](#aggregate-signatures) from multiple signers\n\n### Sign only\n\nYou can sign a transaction without broadcasting it:\n\n```ts\nimport {\n  Secp256k1HdWallet,\n  SigningCosmosClient,\n  coins,\n  coin,\n  MsgDelegate,\n} from \"@cosmjs/launchpad\";\n\n// …\n\nconst wallet = await Secp256k1HdWallet.generate();\nconst [{ address }] = await wallet.getAccounts();\nconsole.log(\"Address:\", address);\n\nconst lcdApi = \"https://…\"; // Signing is offline, but from this endpoint we get the account number and sequence\nconst client = new SigningCosmosClient(lcdApi, address, wallet);\n\n// …\n\nconst msg: MsgDelegate = {\n  type: \"cosmos-sdk/MsgDelegate\",\n  value: {\n    delegator_address: address,\n    validator_address: \"cosmosvaloper1yfkkk04ve8a0sugj4fe6q6zxuvmvza8r3arurr\",\n    amount: coin(300000, \"ustake\"),\n  },\n};\nconst fee = {\n  amount: coins(2000, \"ucosm\"),\n  gas: \"180000\", // 180k\n};\n\nlet signed = await client.sign([msg], fee);\nconsole.log(\"Signed transaction:\", signed);\n\n// We can broadcast it manually later on\nconst result = await client.broadcastTx(signed);\nconsole.log(\"Broadcasting result:\", result);\n```\n\n### Aggregate signatures\n\nIn this example we use `wallet0`/`client0` and `wallet1`/`client1` which can\nlive on separate systems:\n\n```ts\nimport {\n  Secp256k1HdWallet,\n  SigningCosmosClient,\n  coins,\n  coin,\n  MsgDelegate,\n} from \"@cosmjs/launchpad\";\n\nconst wallet0 = await Secp256k1HdWallet.fromMnemonic(mnemonic0);\nconst [{ address: address0 }] = await wallet.getAccounts();\nconst client0 = new SigningCosmosClient(\"https://…\", address0, wallet0);\n\nconst wallet1 = await Secp256k1HdWallet.fromMnemonic(mnemonic1);\nconst [{ address: address1 }] = await wallet.getAccounts();\nconst client1 = new SigningCosmosClient(\"https://…\", address1, wallet1);\n\nconst msg1: MsgSend = {\n  type: \"cosmos-sdk/MsgSend\",\n  value: {\n    from_address: address0,\n    to_address: \"cosmos1b2340gb2…\",\n    amount: coins(1234567, \"ucosm\"),\n  },\n};\nconst msg2: MsgSend = {\n  type: \"cosmos-sdk/MsgSend\",\n  value: {\n    from_address: address1,\n    to_address: \"cosmos1b2340gb2…\",\n    amount: coins(1234567, \"ucosm\"),\n  },\n};\nconst fee = {\n  amount: coins(2000, \"ucosm\"),\n  gas: \"160000\", // 2*80k\n};\nconst memo = \"This must be authorized by the two of us\";\n\nconst signed = await client0.sign([msg1, msg2], fee, memo);\n\nconst cosigned = await client1.appendSignature(signed);\n\nconst result = await client1.broadcastTx(cosigned);\nconsole.log(\"Broadcasting result:\", result);\n```\n\n## Cosmos SDK module support\n\nThis client library supports connecting to standard Cosmos SDK modules as well\nas custom modules. The modularity has two sides that are handled separately:\n\n- Queries are for reading data from the chain;\n- Messages are for writing data to chain as part of the transaction signing.\n\n### Query support\n\n@cosmjs/launchpad now has a flexible\n[LcdClient](https://cosmwasm.github.io/cosmjs/latest/launchpad/classes/lcdclient.html),\nwhich can be extended with all the standard Cosmos SDK modules in a type-safe\nway. With\n\n```ts\nimport { LcdClient } from \"@cosmjs/launchpad\";\n\nconst client = new LcdClient(apiUrl);\nconst response = await client.nodeInfo();\n```\n\nyou only get access to blocks, transaction lists and node info. In order to sign\ntransactions, you need to setup the auth extension with:\n\n```ts\nimport { LcdClient, setupAuthExtension } from \"@cosmjs/launchpad\";\n\nconst client = LcdClient.withExtensions({ apiUrl }, setupAuthExtension);\nconst { account_number, sequence } = (\n  await client.auth.account(myAddress)\n).result.value;\n```\n\nA full client can use all of the following extensions:\n\n```ts\nimport {\n  LcdClient,\n  setupAuthExtension,\n  setupBankExtension,\n  setupDistributionExtension,\n  setupGovExtension,\n  setupMintExtension,\n  setupSlashingExtension,\n  setupStakingExtension,\n  setupSupplyExtension,\n} from \"@cosmjs/launchpad\";\n\nconst client = LcdClient.withExtensions(\n  { apiUrl },\n  setupAuthExtension,\n  setupBankExtension,\n  setupDistributionExtension,\n  setupGovExtension,\n  setupMintExtension,\n  setupSlashingExtension,\n  setupStakingExtension,\n  setupSupplyExtension,\n);\n\n// Example queries\nconst balances = await client.bank.balances(myAddress);\nconst distParameters = await client.distribution.parameters();\nconst proposals = await client.gov.proposals();\nconst inflation = await client.mint.inflation();\nconst signingInfos = await client.slashing.signingInfos();\nconst redelegations = await client.staking.redelegations();\nconst supply = await client.supply.totalAll();\n```\n\n### Messages suppport\n\nEvery Amino-JSON compatible message can be used for the\n[Msg](https://cosmwasm.github.io/cosmjs/latest/launchpad/interfaces/msg.html)\ninterface like this:\n\n```ts\nconst voteMsg: Msg = {\n  type: \"cosmos-sdk/MsgVote\",\n  value: {\n    proposal_id: proposalId,\n    voter: faucet.address,\n    option: \"Yes\",\n  },\n};\n```\n\nThis is most flexible since you are not restricted to known messages, but gives\nyou very little type safety. For improved type safety, we added TypeScript\ndefinitions for all common Cosmos SDK messages:\n\n- MsgSend\n- MsgMultiSend\n- MsgVerifyInvariant\n- MsgSetWithdrawAddress\n- MsgWithdrawDelegatorReward\n- MsgWithdrawValidatorCommission\n- MsgFundCommunityPool\n- MsgSubmitEvidence\n- MsgSubmitProposal\n- MsgVote\n- MsgDeposit\n- MsgUnjail\n- MsgCreateValidator\n- MsgEditValidator\n- MsgDelegate\n- MsgBeginRedelegate\n- MsgUndelegate\n\nThose can be signed and broadcast the manual way or by using a higher level\n[SigningCosmosClient](https://cosmwasm.github.io/cosmjs/latest/launchpad/classes/signingcosmosclient.html):\n\n```ts\nimport {\n  coins,\n  BroadcastTxResult,\n  MsgSubmitProposal,\n  OfflineSigner,\n  SigningCosmosClient,\n  StdFee,\n} from \"@cosmjs/launchpad\";\n\nasync function publishProposal(\n  apiUrl: string,\n  signer: OfflineSigner,\n): Promise<BroadcastTxResult> {\n  const [{ address: authorAddress }] = await signer.getAccounts();\n\n  const memo = \"My first proposal on chain\";\n  const msg: MsgSubmitProposal = {\n    type: \"cosmos-sdk/MsgSubmitProposal\",\n    value: {\n      content: {\n        type: \"cosmos-sdk/TextProposal\",\n        value: {\n          description:\n            \"This proposal proposes to test whether this proposal passes\",\n          title: \"Test Proposal\",\n        },\n      },\n      proposer: authorAddress,\n      initial_deposit: coins(25000000, \"ustake\"),\n    },\n  };\n  const fee: StdFee = {\n    amount: coins(5000000, \"ucosm\"),\n    gas: \"89000000\",\n  };\n\n  const client = new SigningCosmosClient(apiUrl, authorAddress, signer);\n  return client.signAndBroadcast([msg], fee, memo);\n}\n```\n\n### Custom modules\n\nBoth query and message support is implemented in a decentralized fashion, which\nallows applications to add their extensions without changing CosmJS. As an\nexample we show how to build a client for a blockchain with a wasm module:\n\n```ts\nimport {\n  MsgExecuteContract,\n  setupWasmExtension,\n} from \"@cosmjs/cosmwasm-launchpad\";\nimport {\n  assertIsBroadcastTxResult,\n  LcdClient,\n  makeSignDoc,\n  setupAuthExtension,\n  StdFee,\n  StdTx,\n} from \"@cosmjs/launchpad\";\n\nconst client = LcdClient.withExtensions(\n  { apiUrl },\n  setupAuthExtension,\n  // 👇 this extension can come from a chain-specific package or the application itself\n  setupWasmExtension,\n);\n\n// 👇 this message type can come from a chain-specific package or the application itself\nconst msg: MsgExecuteContract = {\n  type: \"wasm/MsgExecuteContract\",\n  value: {\n    sender: myAddress,\n    contract: contractAddress,\n    msg: wasmMsg,\n    sent_funds: [],\n  },\n};\n\nconst fee: StdFee = {\n  amount: coins(5000000, \"ucosm\"),\n  gas: \"89000000\",\n};\nconst memo = \"Time for action\";\nconst { account_number, sequence } = (\n  await client.auth.account(myAddress)\n).result.value;\nconst signDoc = makeSignDoc([msg], fee, apiUrl, memo, account_number, sequence);\nconst { signed, signature } = await signer.sign(myAddress, signDoc);\nconst signedTx = makeStdTx(signed, signature);\nconst result = await client.broadcastTx(signedTx);\nassertIsBroadcastTxResult(result);\n```\n\n## Secure key storage\n\n[Secp256k1HdWallet](https://cosmwasm.github.io/cosmjs/latest/launchpad/classes/secp256k1hdwallet.html)\nsupports securely encrypted serialization/deserialization using Argon2 for key\nderivation and XChaCha20Poly1305 for authenticated encryption. It can be used as\neasily as:\n\n```ts\n// generate an 18 word mnemonic\nconst wallet = await Secp256k1HdWallet.generate(18);\nconst serialized = await original.serialize(\"my password\");\n\n// serialized is encrypted and can now be stored in an application-specific way\n\nconst restored = await Secp256k1HdWallet.deserialize(serialized, \"my password\");\n```\n\nIf you want to use really strong KDF parameters in a user interface, you should\noffload the KDF execution to a separate thread in order to avoid freezing the\nUI. This can be done in the advanced mode:\n\n**Session 1 (main thread)**\n\n```ts\nconst wallet = await Secp256k1HdWallet.generate(18);\n```\n\n**Session 1 (WebWorker)**\n\nThis operation can now run a couple of seconds without freezing the UI.\n\n```ts\nimport { executeKdf } from \"@cosmjs/launchpad\";\n\n// pass password to the worker\n\nconst strongKdfParams: KdfConfiguration = {\n  algorithm: \"argon2id\",\n  params: {\n    outputLength: 32,\n    opsLimit: 5000,\n    memLimitKib: 15 * 1024,\n  },\n};\nconst encryptionKey = await executeKdf(password, strongKdfParams);\n\n// pass encryptionKey to the main thread\n```\n\n**Session 1 (main thread)**\n\n```ts\nconst serialized = await wallet.serializeWithEncryptionKey(\n  encryptionKey,\n  anyKdfParams,\n);\n```\n\n**Session 2 (WebWorker)**\n\n```ts\nimport { executeKdf, extractKdfConfiguration } from \"@cosmjs/launchpad\";\n\n// pass serialized and password to the worker\n\nconst kdfConfiguration = extractKdfConfiguration(serialized);\nconst encryptionKey = await executeKdf(password, kdfConfiguration);\n\n// pass encryptionKey to the main thread\n```\n\n**Session 2 (main thead)**\n\n```ts\nconst restored = await Secp256k1HdWallet.deserializeWithEncryptionKey(\n  serialized,\n  encryptionKey,\n);\n\n// use restored for signing\n```\n\n## License\n\nThis package is part of the cosmjs repository, licensed under the Apache License\n2.0 (see [NOTICE](https://github.com/cosmos/cosmjs/blob/main/NOTICE) and\n[LICENSE](https://github.com/cosmos/cosmjs/blob/main/LICENSE)).\n","gitHead":"15a3a9b83a2cfe3deae389128ede5e58e3041569","license":"Apache-2.0","scripts":{"docs":"typedoc --options typedoc.js","lint":"eslint --max-warnings 0 \"**/*.{js,ts}\"","test":"yarn build-or-skip && yarn test-node","build":"tsc","format":"prettier --write --loglevel warn \"./src/**/*.ts\"","coverage":"nyc --reporter=text --reporter=lcov yarn test --quiet","lint-fix":"eslint --max-warnings 0 \"**/*.{js,ts}\" --fix","pack-web":"yarn build-or-skip && webpack --mode development --config webpack.web.config.js","prebuild":"shx rm -rf ./build","test-node":"node jasmine-testrunner.js","format-text":"prettier --write --prose-wrap always --print-width 80 \"./*.md\"","test-chrome":"yarn pack-web && karma start --single-run --browsers ChromeHeadless","test-firefox":"yarn pack-web && karma start --single-run --browsers Firefox","build-or-skip":"[ -n \"$SKIP_BUILD\" ] || yarn build"},"_npmUser":{"name":"willclarktech","email":"will@willclark.tech"},"repository":{"url":"https://github.com/cosmos/cosmjs/tree/main/packages/launchpad","type":"git"},"_npmVersion":"lerna/3.22.1/node@v12.20.1+x64 (darwin)","description":"A client library for the Cosmos SDK 0.37 (cosmoshub-3), 0.38 and 0.39 (Launchpad)","directories":{},"maintainers":[{"name":"webmaster128","email":"simon@warta.it"},{"name":"willclarktech","email":"will@willclark.tech"}],"_nodeVersion":"12.20.1","contributors":[{"name":"Ethan Frey","email":"ethanfrey@users.noreply.github.com"},{"name":"Simon Warta","email":"webmaster128@users.noreply.github.com"}],"dependencies":{"axios":"^0.21.1","@cosmjs/math":"^0.24.0-alpha.24","@cosmjs/utils":"^0.24.0-alpha.24","@cosmjs/crypto":"^0.24.0-alpha.24","fast-deep-equal":"^3.1.3","@cosmjs/encoding":"^0.24.0-alpha.24"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"readonly-date":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/launchpad_0.24.0-alpha.24_1613038949780_0.5736076197934135","host":"s3://npm-registry-packages"},"_id":"@cosmjs/launchpad@0.24.0-alpha.24","version":"0.24.0-alpha.24"}