Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make getOperations consider multiple Transfer Asset #1626

Closed
Torres-ssf opened this issue Jan 9, 2024 · 1 comment
Closed

Make getOperations consider multiple Transfer Asset #1626

Torres-ssf opened this issue Jan 9, 2024 · 1 comment
Assignees
Labels
bug Issue is a bug

Comments

@Torres-ssf
Copy link
Contributor

Torres-ssf commented Jan 9, 2024

We must consider multiple Transfer Asset operations in the same TX.

There is a bug in how the getOperations function is assembling Transfer Asset operations for processed TXs:

Consider the following Transaction that simply transfers coins from 2 assets to 2 different wallets:

    const asset1 = '0x0101010101010101010101010101010101010101010101010101010101010101';
    const asset2 = '0x0202020202020202020202020202020202020202020202020202020202020202';

    const request = new ScriptTransactionRequest({
      gasLimit: 10_000,
      gasPrice: 1,
    });

    request.addCoinOutput(receiver1.address, 100, asset1);
    request.addCoinOutput(receiver2.address, 100, asset1);
    request.addCoinOutput(receiver2.address, 100, asset2);

    const tx = await adminWallet.sendTransaction(request);

This transaction should generate 2 Transfer Asset operations, one for each receiver.

e.g.

[
  {
    name: 'Transfer asset',
    // TX sender
    from: {
      ...
    },
    // Receiver 1
    to: {
      ...
    },
    assetsSent: [
      {
        assetId: '0x0101010101010101010101010101010101010101010101010101010101010101',
        amount: BN(100)
      }
    ]
  },
  {
    name: 'Transfer asset',
    // TX sender
    from: {
      ...
    },
    // Receiver 2
    to: {
      ...
    },
    assetsSent: [
      {
        assetId: '0x0101010101010101010101010101010101010101010101010101010101010101',
        amount: BN(100)
      },
      {
        assetId: '0x0202020202020202020202020202020202020202020202020202020202020202',
        amount: BN(100)
      }
    ]
  }
]

However, getOperations returns the operations array containing only one Transfer Asset operation, usually the one that is processed last by the addOperations helper.

@Torres-ssf Torres-ssf added the bug Issue is a bug label Jan 9, 2024
@Torres-ssf Torres-ssf added this to the 1 - Salamander milestone Jan 9, 2024
@Torres-ssf Torres-ssf self-assigned this Jan 9, 2024
@arboleya arboleya changed the title Make getOperations consider multiple Transfer Asset operations in the same TX Make getOperations consider multiple Transfer Asset Jan 12, 2024
@Torres-ssf Torres-ssf mentioned this issue Jan 15, 2024
44 tasks
@arboleya
Copy link
Member

Completed via #1619.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is a bug
Projects
None yet
Development

No branches or pull requests

2 participants