Skip to content

Fallback Provider sorts priorities in descending order (ascending expected) #4150

Closed
@therealjmj

Description

Ethers Version

6.6.0

Search Terms

No response

Describe the Problem

Priorites are sorted in descending order currently.

Lower numbers represent higher priority, so fallback provider priorities are expected to sort ascending, ie 1, 2, 3 - where priority 1 precedes 2 and 3.

Code Snippet

From fallback-provider.ts:

allConfigs.sort((a, b) => (b.priority - a.priority));

Passing test code to demonstrate the proper effect: 

  it('Should sort ascending and descending', () => {
    const allConfigs = [
      {
        priority: 3,
      },
      {
        priority: 1,
      },
      {
        priority: 2,
      },
    ];

    // Ascending
    allConfigs.sort((a, b) => a.priority - b.priority);
    expect(allConfigs.map(c => c.priority)).to.deep.equal([1, 2, 3]);

    // Descending
    allConfigs.sort((a, b) => b.priority - a.priority);
    expect(allConfigs.map(c => c.priority)).to.deep.equal([3, 2, 1]);
  });

Contract ABI

No response

Errors

No response

Environment

No response

Environment (Other)

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

bugVerified to be an issue.minor-bumpPlanned for the next minor version bump.v6Issues regarding v6

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions