Skip to content

Conversation

@leonardocustodio
Copy link

@leonardocustodio leonardocustodio commented Mar 9, 2025

PR Type

  • Bug fix

Description

  • Replace immortal era with computed mortal era.

  • Retrieve current block number and corresponding block hash.

  • Update transaction payload to include dynamic era data.


Changes walkthrough 📝

Relevant files
Bug fix
transaction.ts
Implement mortal era computation for transactions.             

resources/js/store/transaction.ts

  • Added import for GenericExtrinsicEra.
  • Removed static immortal era extraction.
  • Fetched current block number and block hash.
  • Replaced payload era with computed mortalEra.
  • +8/-5     

    Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • @github-actions
    Copy link

    github-actions bot commented Mar 9, 2025

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Hard-coded Period

    The period value "64" used in the instantiation of GenericExtrinsicEra is hard-coded. Confirm that this constant is valid under all intended network conditions.

    const mortalEra = new GenericExtrinsicEra(api.registry, { current: blockNumber.toNumber(), period: 64 });
    Block Data Conversion

    Verify that converting the block number to a hexadecimal string using toHex() aligns correctly with the transaction payload format and network requirements.

    const blockNumber = currentBlock.block.header.number;
    const blockHash = await api.rpc.chain.getBlockHash(blockNumber.toNumber());
    
    // This is the call that comes from the platform transactions 'encodedCall'
    const call = transaction.encodedData;
    const genesis = genesisHash.toHex(); // The genesis block
    const mortalEra = new GenericExtrinsicEra(api.registry, { current: blockNumber.toNumber(), period: 64 });
    
    const payloadToSign: SignerPayloadJSON = {
        specVersion: runtime.specVersion.toHex(),
        transactionVersion: runtime.transactionVersion.toHex(),
        address: address,
        blockHash: blockHash.toHex(),
        blockNumber: blockNumber.toHex(),
        era: mortalEra.toHex(),

    @github-actions
    Copy link

    github-actions bot commented Mar 9, 2025

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Ensure blockNumber type consistency

    Confirm that blockNumber is of a type that provides a toHex() method; if not,
    convert or instantiate it using the registry methods to ensure consistent
    hexadecimal conversion.

    resources/js/store/transaction.ts [41]

    -const blockNumber = currentBlock.block.header.number;
    +const blockNumber = api.registry.createType('BlockNumber', currentBlock.block.header.number);
    Suggestion importance[1-10]: 7

    __

    Why: The suggestion addresses a potential issue with blockNumber not having a toHex() method by converting it using the registry, which could prevent runtime errors. While it adds type safety, it is an enhancement rather than a critical fix.

    Medium

    @leonardocustodio leonardocustodio merged commit 57f02fc into master Mar 10, 2025
    4 checks passed
    @leonardocustodio leonardocustodio deleted the hotfix/PLA-2209/fix-wc branch March 10, 2025 09:07
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Development

    Successfully merging this pull request may close these issues.

    2 participants