Skip to content

Commit

Permalink
bugfixes and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sbauch committed Jul 27, 2023
1 parent 2f3d2a6 commit 02635cc
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 1 deletion.
22 changes: 22 additions & 0 deletions packages/ownership-oracle/__tests__/DelegationTree.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,28 @@ describe('DelegationTree', () => {
expect(authorized).toBe(false);
});

it('returns false when signer is not owner and no authorizer', async () => {
getAllDelegationsMock.mockReturnValueOnce([
{
vault: owner.address,
tokenId,
contract_: nftContract,
delegate: signer.address,
type_: 1,
},
]);

const tree = new DelegationTree(
provider,
nftContract,
tokenId,
signer.address,
);

const authorized = await tree.hasDelegatedOwnership('');
expect(authorized).toBe(false);
});

it('returns false when authorizer is not owner', async () => {
getAllDelegationsMock.mockReturnValueOnce([
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ describe('OwnershipService', () => {
return owner.address;
});
});

it('should throw an error when not authorized', async () => {
hasDelegatedOwnershipMock.mockResolvedValue(false);

Expand Down
1 change: 1 addition & 0 deletions packages/ownership-oracle/__tests__/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ describe('durin_call endpoint', () => {
expect(response.status).toBe(200);
expect(response.body).toHaveProperty('result', 'gud proof');
});

it('returns an error if signer is neither owner nor authorized', async () => {
processCallMock.mockRejectedValue(new Error('bad proof'));

Expand Down
2 changes: 2 additions & 0 deletions packages/ownership-oracle/src/NetworkProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const PROVIDERS = {
7700: 'https://canto.slingshot.finance/',
740: 'https://eth.plexnode.wtf/',
42170: 'https://nova.arbitrum.io/rpc',
7777777: 'https://rpc.zora.energy/',
};

class NetworkProvider {
Expand All @@ -22,6 +23,7 @@ class NetworkProvider {
case 7700:
case 740:
case 42170:
case 7777777:
provider = new providers.JsonRpcProvider(PROVIDERS[chainId], chainId);
break;
default:
Expand Down
2 changes: 1 addition & 1 deletion packages/ownership-oracle/src/OwnershipService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class OwnershipService {
from,
);

const authorized = await delegationTree.hasDelegatedOwnership(authorizer);
const authorized = await delegationTree.hasDelegatedOwnership(owner);

if (authorized) {
console.warn('AUTHORIZED RECURSIVELY');
Expand Down

0 comments on commit 02635cc

Please sign in to comment.