Skip to content

feat(multisig): allow to import existing multisig by address#1397

Draft
n0izn0iz wants to merge 1 commit intomainfrom
import-multisig
Draft

feat(multisig): allow to import existing multisig by address#1397
n0izn0iz wants to merge 1 commit intomainfrom
import-multisig

Conversation

@n0izn0iz
Copy link
Collaborator

@n0izn0iz n0izn0iz commented Nov 18, 2024

Add a field to enter the address of a multisig that already exists on-chain. It will auto-fill the other fields and populate the public keys.

Some of our users have lost one of the member of their multisig.
This member never made a tx on-chain so we can't recover the public key with the usual getAccount on the member's address.

We can however import the public keys from the chain because the multisig "public key" embeds the members public keys.
For example on CLI:

❯ teritorid query account tori1cdk3ezewp88m69zcdlaxanuzkscysm2qgj238p --node https://rpc.mainnet.teritori.com:443 --output json | jq
{
  "@type": "/cosmos.auth.v1beta1.BaseAccount",
  "address": "tori1cdk3ezewp88m69zcdlaxanuzkscysm2qgj238p",
  "pub_key": {
    "@type": "/cosmos.crypto.multisig.LegacyAminoPubKey",
    "threshold": 2,
    "public_keys": [
      {
        "@type": "/cosmos.crypto.secp256k1.PubKey",
        "key": "AyOLVICt52x+KsiWar9VT1cDagPG9hNhQEO42dsrASBI"
      },
      {
        "@type": "/cosmos.crypto.secp256k1.PubKey",
        "key": "AokZeCsN+nLgdfeVPWlTD8VuVaDwCVPs7exse3II4Xs9"
      }
    ]
  },
  "account_number": "187027",
  "sequence": "1"
}

This is how it looks like:

Screenshot 2024-11-19 at 00 34 40

Signed-off-by: Norman Meier <norman@samourai.coop>
@n0izn0iz n0izn0iz self-assigned this Nov 18, 2024
@netlify
Copy link

netlify bot commented Nov 18, 2024

Deploy Preview for testitori ready!

Name Link
🔨 Latest commit 4695ff1
🔍 Latest deploy log https://app.netlify.com/sites/testitori/deploys/673b9d68b76fc3000835666b
😎 Deploy Preview https://deploy-preview-1397--testitori.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify
Copy link

netlify bot commented Nov 18, 2024

Deploy Preview for teritori-dapp ready!

Name Link
🔨 Latest commit 4695ff1
🔍 Latest deploy log https://app.netlify.com/sites/teritori-dapp/deploys/673b9d6841d2880008e8196a
😎 Deploy Preview https://deploy-preview-1397--teritori-dapp.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

label="Optional existing multisig address"
onChangeText={async (addr) => {
try {
console.log("addr", addr);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove console.log usages

variant="labelOutside"
noBrokenCorners
label="Optional existing multisig address"
onChangeText={async (addr) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's more lisible to use a function and remove the logic from the JSX imo

try {
console.log("addr", addr);
if (selectedNetwork?.kind !== NetworkKind.Cosmos) {
console.error("not a cosmos netwokr");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.error("not a cosmos netwokr");
console.error("not a cosmos network");

return;
}
const client = await getNonSigningStargateClient(networkId);
const account = await client.getAccount(addr);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should validateAddress before using the addr to getAccount to avoid unnecessary queries.
Wdyt?

@n0izn0iz n0izn0iz marked this pull request as draft November 21, 2024 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants