MinaFoundation / ecosystem-ideas

Get inspired to build on MinaProtocol.
MIT License
1 stars 0 forks source link

Account Update visualizer #14

Open hgedia opened 2 months ago

hgedia commented 2 months ago

Summary

Transactions can result in a series of account updates. Account updates can include token transfers, state updates, and changing delegation. These updates can be seen in the JSON file created by toPretty() function call on the transaction object.

Ex:

const txn = await Mina.transaction(senderAccount, async () => {
        await zkApp.verify(id, creditScore, signature);
      });
      await txn.prove();
      await txn.sign([senderKey]).send();
     console.log('txn', txn.toPretty());

Output:

    txn [
      {
        label: 'feePayer',
        publicKey: '..e1Co',
        fee: '0',
        nonce: '0',
        authorization: '..gUdq'
      },
      {
        label: 'OracleExample.verify()',
        publicKey: '..CVr7',
        events: '[["1"]]',
        preconditions: {
          account: '{"state":["5381126474252558361076605461681340039227154619768231462994659962968677770124","1",null,null,null,null,null,null]}'
        },
        mayUseToken: { parentsOwnToken: false, inheritFromParent: false },
        authorizationKind: {
          isSigned: false,
          isProved: true,
          verificationKeyHash: '3392518251768960475377392625298437850623664973002200885669375116181514017494'
        },
        authorization: { proof: '..KQ==' }
      }
    ]

This transacation has two account updates

The output of the tx, if it is accepted by the network, will be that an event with the value 1 is emitted by the contract.

These JSON documents are harder to read as the transactions get more complicated(see Other accounts raw.).

A tool could be built (as a start to locally) to generate the account update JSON and have these updates visualized and easy to navigate/understand. For developers it's more useful to visualize a transaction without having to send it. And this can be expanded to support wallets or block explorers.

Submitted by 45930

Resources

YashBit commented 2 months ago

@hgedia Please can you assign this to me.

YashBit commented 1 month ago

@hgedia Proposal submitted. Please can you put this issue under review or something similar?

hgedia commented 1 month ago

hey @YashBit - your current proposal is taking a different route - so will leave this open and in existing state.