Skip to content

Commit

Permalink
Enable cross-chain authorizers
Browse files Browse the repository at this point in the history
  • Loading branch information
dcroote committed Oct 4, 2022
1 parent 5d1022a commit aa4c3dc
Show file tree
Hide file tree
Showing 41 changed files with 236 additions and 33 deletions.
9 changes: 9 additions & 0 deletions .changeset/wild-walls-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@api3/airnode-deployer': minor
'@api3/airnode-examples': minor
'@api3/airnode-node': minor
'@api3/airnode-operation': minor
'@api3/airnode-validator': minor
---

Enable cross-chain authorizers
3 changes: 2 additions & 1 deletion packages/airnode-deployer/config/config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
{
"maxConcurrency": 100,
"authorizers": {
"requesterEndpointAuthorizers": []
"requesterEndpointAuthorizers": [],
"crossChainRequesterAuthorizers": []
},
"authorizations": {
"requesterEndpointAuthorizations": {}
Expand Down
3 changes: 2 additions & 1 deletion packages/airnode-deployer/test/fixtures/config.valid.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
{
"maxConcurrency": 100,
"authorizers": {
"requesterEndpointAuthorizers": []
"requesterEndpointAuthorizers": [],
"crossChainRequesterAuthorizers": []
},
"authorizations": {
"requesterEndpointAuthorizations": {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
{
"maxConcurrency": 100,
"authorizers": {
"requesterEndpointAuthorizers": []
"requesterEndpointAuthorizers": [],
"crossChainRequesterAuthorizers": []
},
"authorizations": {
"requesterEndpointAuthorizations": {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const createConfig = async (generateExampleFile: boolean): Promise<Config> => ({
maxConcurrency: 100,
authorizers: {
requesterEndpointAuthorizers: [],
crossChainRequesterAuthorizers: [],
},
authorizations: {
requesterEndpointAuthorizations: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
{
"maxConcurrency": 100,
"authorizers": {
"requesterEndpointAuthorizers": []
"requesterEndpointAuthorizers": [],
"crossChainRequesterAuthorizers": []
},
"authorizations": {
"requesterEndpointAuthorizations": {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const createConfig = async (generateExampleFile: boolean): Promise<Config> => ({
maxConcurrency: 100,
authorizers: {
requesterEndpointAuthorizers: [],
crossChainRequesterAuthorizers: [],
},
authorizations: {
requesterEndpointAuthorizations: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
{
"maxConcurrency": 100,
"authorizers": {
"requesterEndpointAuthorizers": []
"requesterEndpointAuthorizers": [],
"crossChainRequesterAuthorizers": []
},
"authorizations": {
"requesterEndpointAuthorizations": {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const createConfig = async (generateExampleFile: boolean): Promise<Config> => ({
maxConcurrency: 100,
authorizers: {
requesterEndpointAuthorizers: [],
crossChainRequesterAuthorizers: [],
},
authorizations: {
requesterEndpointAuthorizations: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
{
"maxConcurrency": 100,
"authorizers": {
"requesterEndpointAuthorizers": []
"requesterEndpointAuthorizers": [],
"crossChainRequesterAuthorizers": []
},
"authorizations": {
"requesterEndpointAuthorizations": {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const createConfig = async (generateExampleFile: boolean): Promise<Config> => ({
maxConcurrency: 100,
authorizers: {
requesterEndpointAuthorizers: [],
crossChainRequesterAuthorizers: [],
},
authorizations: {
requesterEndpointAuthorizations: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
{
"maxConcurrency": 100,
"authorizers": {
"requesterEndpointAuthorizers": []
"requesterEndpointAuthorizers": [],
"crossChainRequesterAuthorizers": []
},
"authorizations": {
"requesterEndpointAuthorizations": {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const createConfig = async (generateExampleFile: boolean): Promise<Config> => ({
maxConcurrency: 100,
authorizers: {
requesterEndpointAuthorizers: [],
crossChainRequesterAuthorizers: [],
},
authorizations: {
requesterEndpointAuthorizations: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
{
"maxConcurrency": 100,
"authorizers": {
"requesterEndpointAuthorizers": []
"requesterEndpointAuthorizers": [],
"crossChainRequesterAuthorizers": []
},
"authorizations": {
"requesterEndpointAuthorizations": {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const createConfig = async (generateExampleFile: boolean): Promise<Config> => ({
maxConcurrency: 100,
authorizers: {
requesterEndpointAuthorizers: [],
crossChainRequesterAuthorizers: [],
},
authorizations: {
requesterEndpointAuthorizations: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
{
"maxConcurrency": 100,
"authorizers": {
"requesterEndpointAuthorizers": []
"requesterEndpointAuthorizers": [],
"crossChainRequesterAuthorizers": []
},
"authorizations": {
"requesterEndpointAuthorizations": {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const createConfig = async (generateExampleFile: boolean): Promise<Config> => ({
maxConcurrency: 100,
authorizers: {
requesterEndpointAuthorizers: [],
crossChainRequesterAuthorizers: [],
},
authorizations: {
requesterEndpointAuthorizations: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
{
"maxConcurrency": 100,
"authorizers": {
"requesterEndpointAuthorizers": []
"requesterEndpointAuthorizers": [],
"crossChainRequesterAuthorizers": []
},
"authorizations": {
"requesterEndpointAuthorizations": {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const createConfig = async (generateExampleFile: boolean): Promise<Config> => ({
maxConcurrency: 100,
authorizers: {
requesterEndpointAuthorizers: [],
crossChainRequesterAuthorizers: [],
},
authorizations: {
requesterEndpointAuthorizations: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
{
"maxConcurrency": 100,
"authorizers": {
"requesterEndpointAuthorizers": []
"requesterEndpointAuthorizers": [],
"crossChainRequesterAuthorizers": []
},
"authorizations": {
"requesterEndpointAuthorizations": {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const createConfig = async (generateExampleFile: boolean): Promise<Config> => ({
maxConcurrency: 100,
authorizers: {
requesterEndpointAuthorizers: [],
crossChainRequesterAuthorizers: [],
},
authorizations: {
requesterEndpointAuthorizations: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
{
"maxConcurrency": 100,
"authorizers": {
"requesterEndpointAuthorizers": []
"requesterEndpointAuthorizers": [],
"crossChainRequesterAuthorizers": []
},
"authorizations": {
"requesterEndpointAuthorizations": {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const createConfig = async (generateExampleFile: boolean): Promise<Config> => ({
maxConcurrency: 100,
authorizers: {
requesterEndpointAuthorizers: [],
crossChainRequesterAuthorizers: [],
},
authorizations: {
requesterEndpointAuthorizations: {},
Expand Down
3 changes: 2 additions & 1 deletion packages/airnode-node/config/config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
{
"maxConcurrency": 100,
"authorizers": {
"requesterEndpointAuthorizers": []
"requesterEndpointAuthorizers": [],
"crossChainRequesterAuthorizers": []
},
"authorizations": {
"requesterEndpointAuthorizations": {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const createChainConfig = (overrides: Partial<ChainConfig>): ChainConfig => {
maxConcurrency: 100,
authorizers: {
requesterEndpointAuthorizers: [],
crossChainRequesterAuthorizers: [],
},
authorizations: {
requesterEndpointAuthorizations: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ describe('fetch (authorizations)', () => {
'0x711c93B32c0D28a5d18feD87434cce11C3e5699B',
'0x9E0e23766b0ed0C492804872c5164E9187fB56f5',
],
crossChainRequesterAuthorizers: [],
},
authorizations: {
requesterEndpointAuthorizations: {},
Expand All @@ -41,7 +42,7 @@ describe('fetch (authorizations)', () => {
expect(res).toEqual({});
});

it('returns true for all pending requests if authorizers array is empty', async () => {
it('returns true for all pending requests if authorizers arrays are empty', async () => {
const apiCalls = Array.from(Array(19).keys()).map((n) => {
return fixtures.requests.buildApiCall({
id: `${n}`,
Expand All @@ -52,7 +53,10 @@ describe('fetch (authorizations)', () => {
});
const [logs, res] = await authorization.fetch(apiCalls, {
...mutableFetchOptions,
authorizers: { requesterEndpointAuthorizers: [] },
authorizers: {
requesterEndpointAuthorizers: [],
crossChainRequesterAuthorizers: [],
},
});

expect(logs).toEqual([]);
Expand Down Expand Up @@ -318,7 +322,10 @@ describe('fetch (authorizations)', () => {
});

describe('fetchAuthorizationStatus', () => {
const authorizers = { requesterEndpointAuthorizers: ['0x0000000000000000000000000000000000000000'] };
const authorizers = {
requesterEndpointAuthorizers: ['0x0000000000000000000000000000000000000000'],
crossChainRequesterAuthorizers: [],
};
const airnodeAddress = '0xairnodeAddress';
let mutableAirnodeRrp: AirnodeRrpV0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ mockEthers({

import { ethers } from 'ethers';
import * as adapter from '@api3/airnode-adapter';
import { initializeProvider } from './initialize-provider';
import { initializeProvider, mergeAuthorizationsByRequestId } from './initialize-provider';
import * as fixtures from '../../../test/fixtures';
import { AuthorizationByRequestId } from '../../types';

describe('initializeProvider', () => {
jest.setTimeout(30_000);
Expand Down Expand Up @@ -228,4 +229,31 @@ describe('initializeProvider', () => {
expect(res).toEqual(null);
expect(getLogsSpy).toHaveBeenCalledTimes(1);
});

it('merges authorizations and cross-chain authorizations', () => {
const authorizations: AuthorizationByRequestId = {
'0x1': false,
'0x2': true,
'0x3': true,
'0x4': false,
'0x5': false,
'0x6': true,
};
const crossChainAuthorizations: AuthorizationByRequestId = {
'0x1': true,
'0x2': true,
'0x3': true,
'0x4': false,
};

const merged = mergeAuthorizationsByRequestId([authorizations, crossChainAuthorizations]);
expect(merged).toEqual({
'0x1': true,
'0x2': true,
'0x3': true,
'0x4': false,
'0x5': false,
'0x6': true,
} as AuthorizationByRequestId);
});
});
Loading

0 comments on commit aa4c3dc

Please sign in to comment.