rosetta-client icon indicating copy to clipboard operation
rosetta-client copied to clipboard

transfer_combine fails on staking operations

Open roman-kashitsyn opened this issue 3 years ago • 0 comments

transfer_combine call fails if the transaction contains staking operations. For example, when I try to execute the following transaction:

    const payloads = await session.payloads({
        network_identifier: net_id,
        operations: [
            {
                operation_identifier: { index: 0 },
                type: "TRANSACTION",
                account: account.account_identifier,
                amount: {
                    value: `${-stakeAmount}`,
                    currency: {symbol: "ICP", decimals: 8}
                }
            },
            {
                operation_identifier: { index: 1 },
                type: "TRANSACTION",
                account: neuronAccount.account_identifier,
                amount: {
                    value: `${stakeAmount}`,
                    currency: {symbol: "ICP", decimals: 8}
                }
            },
            {
                operation_identifier: { index: 2 },
                type: "FEE",
                account: account.account_identifier,
                amount: {
                    value: "-10000",
                    currency: {symbol: "ICP", decimals: 8}
                }
            },
            {
                operation_identifier: { index: 3 },
                type: "STAKE",
                account: account.account_identifier,
                metadata: { neuron_identifier: 1}
            },
            {
                operation_identifier: { index: 4 },
                type: "SET_DISSOLVE_TIMESTAMP",
                account: account.account_identifier,
                metadata: {
                    neuron_identifier: 1,
                    dissolve_time_utc_seconds: 1879939507
                }
            },
            {
                operation_identifier: { index: 5 },
                type: "START_DISSOLVE",
                account: account.account_identifier,
                metadata: { neuron_identifier: 1}
            }
        ],
        public_keys: [{hex_bytes: pub_key, curve_type: "edwards25519"}]
    });

    const combined = transfer_combine(private_key, payloads);

The client fails with the following assertion error:

AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:

  assert(
    req.signatures.length === unsigned_transaction.ingress_expiries.length * 2
  )

    at combine (/Users/lifted/Projects/rosetta-client/lib/construction_combine.js:52:3)
    at transfer_combine (/Users/lifted/Projects/rosetta-client/lib/construction_combine.js:15:10)

roman-kashitsyn avatar Dec 22 '21 13:12 roman-kashitsyn