Skip to content

Duplicated address access list references #1008

@neilcampbell

Description

@neilcampbell

Duplicate address access list references

When creating a transaction with the access field specified which uses addresses across the various resource types can result in duplicate address resource references.

This appears to be an object equality issue when comparing an address from a HoldingReference or LocalsReference to determine if it should be added as an additional address reference.

Your environment

  • Software version: 4.5.1 (latest)

Steps to reproduce

const tx = algosdk.makeApplicationCallTxnFromObject({
  sender: 'L3P7WB2YUUV7DX5BRFYHIC4TTY7VRQKT4AIKDINKVWEWC2BCRFG2FS3OVY',
  appIndex: 1234n,
  onComplete: algosdk.OnApplicationComplete.NoOpOC,
  suggestedParams: {
    fee: 0,
    flatFee: true,
    firstValid: 1000,
    lastValid: 2000,
    minFee: 1000,
  },
  access: [
    { address: algosdk.Address.fromString('FDMKB5D72THLYSJEBHBDHUE7XFRDOM5IHO44SOJ7AWPD6EZMWOQ2WKN7HQ') },
    { assetIndex: 54n },
    {
      holding: {
        assetIndex: 54n,
        address: algosdk.Address.fromString('FDMKB5D72THLYSJEBHBDHUE7XFRDOM5IHO44SOJ7AWPD6EZMWOQ2WKN7HQ'),
      },
    },
    { appIndex: 432n },
    {
      locals: {
        appIndex: 432n,
        address: algosdk.Address.fromString('FDMKB5D72THLYSJEBHBDHUE7XFRDOM5IHO44SOJ7AWPD6EZMWOQ2WKN7HQ'),
      },
    },
  ],
})
const accessList = tx.toEncodingData().get('al') as algosdk.ResourceReference[]
expect(accessList.length).toBe(tx.applicationCall!.access.length) // Length is 7 when it should be 5 because 2 additional address references have been added in.

In the above example, if I create the address once and use between the resources we get the correct length of 5.

Expected behaviour

The above test passes

Actual behaviour

The above test does not pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    new-bugBug report that needs triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions