Skip to content

Commit

Permalink
chore: add provider getter
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-schultz committed Nov 10, 2023
1 parent 794988b commit 8820cb7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
9 changes: 8 additions & 1 deletion contracts/GitcoinPassportDecoder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,19 @@ contract GitcoinPassportDecoder is
function _authorizeUpgrade(address) internal override onlyOwner {}

/**
1 * @dev Gets the EAS contract.
* @dev Gets the EAS contract.
*/
function getEASAddress() public view returns (IEAS) {
return eas;
}

/**
* @dev Gets providers by version.
*/
function getProviders(uint32 version) public view returns (string[] memory) {
return providerVersions[version];
}

/**
* @dev Sets the address of the EAS contract.
* @param _easContractAddress The address of the EAS contract.
Expand Down
16 changes: 16 additions & 0 deletions test/GitcoinPassportDecoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,22 @@ describe("GitcoinPassportDecoder", function () {
expect(lastProvider === "NewStamp3");
});

it("should return provider given a version", async function () {
const providers = ["NewStamp1", "NewStamp2"];
await this.gitcoinPassportDecoder
.connect(this.owner)
.addProviders(providers);

const currentVersion = await this.gitcoinPassportDecoder.currentVersion();

const savedProviders = await this.gitcoinPassportDecoder.getProviders(
currentVersion
);

expect(savedProviders.length === providers.length);
expect(savedProviders).to.eql(providers);
});

it("should not allow anyone other than owner to append new providers array in the provider mapping", async function () {
await expect(
this.gitcoinPassportDecoder
Expand Down

0 comments on commit 8820cb7

Please sign in to comment.