Add multisig address derivation example
This commit is contained in:
parent
18fcd841a4
commit
cb37451f8f
31
packages/cli/examples/multisig_address.ts
Normal file
31
packages/cli/examples/multisig_address.ts
Normal 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);
|
||||
@ -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",
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user