Add multisig address derivation example

This commit is contained in:
Simon Warta 2021-03-22 16:46:10 +01:00
parent 18fcd841a4
commit cb37451f8f
3 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,31 @@
import { MultisigThresholdPubkey, pubkeyToRawAddress } from "@cosmjs/amino";
import { Bech32 } from "@cosmjs/encoding";
// https://github.com/cosmos/cosmjs/issues/673#issuecomment-779847238
const multisigPubkey: MultisigThresholdPubkey = {
"type": "tendermint/PubKeyMultisigThreshold",
"value": {
"threshold": "3",
"pubkeys": [
{
"type": "tendermint/PubKeySecp256k1",
"value": "A4KZH7VSRwW/6RTExROivRYKsQP63LnGcBlXFo+eKGpQ"
},
{
"type": "tendermint/PubKeySecp256k1",
"value": "A8/Cq4VigOnDgl6RSdcx97fjrdCo/qwAX6C34n7ZDZLs"
},
{
"type": "tendermint/PubKeySecp256k1",
"value": "ApKgZuwy03xgdRnXqG6yEHATomsWDOPacy7nbpsuUCSS"
},
{
"type": "tendermint/PubKeySecp256k1",
"value": "Aptm8E3WSSFS0RTAIUW+bLi/slYnTEE+h4qPTG28CHfq"
}
]
}
};
const address = Bech32.encode("cosmos", pubkeyToRawAddress(multisigPubkey));
console.log(address);

View File

@ -39,6 +39,7 @@
"!**/testdata/"
],
"dependencies": {
"@cosmjs/amino": "^0.25.0-alpha.0",
"@cosmjs/cosmwasm-launchpad": "^0.25.0-alpha.0",
"@cosmjs/cosmwasm-stargate": "^0.25.0-alpha.0",
"@cosmjs/crypto": "^0.25.0-alpha.0",

View File

@ -13,6 +13,7 @@ cosmwasm-cli --init examples/generate_address.ts --code "process.exit(0)"
cosmwasm-cli --init examples/helpers.ts --code "process.exit(0)"
cosmwasm-cli --init examples/local_faucet.ts --code "process.exit(0)"
cosmwasm-cli --init examples/mask.ts --code "process.exit(0)"
cosmwasm-cli --init examples/multisig_address.ts --code "process.exit(0)"
if [ -n "${SIMAPP_ENABLED:-}" ]; then
cosmwasm-cli --init examples/stargate.ts --code "process.exit(0)"
fi