Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-implement "Estimate gas for RRP fulfillments" #1817

Merged
merged 9 commits into from
Jul 10, 2023
6 changes: 6 additions & 0 deletions .changeset/rich-snails-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@api3/airnode-validator': minor
'@api3/airnode-node': minor
---

Estimate gas for RRP fulfillments
2 changes: 1 addition & 1 deletion packages/airnode-node/src/config/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('config validation', () => {
const exampleSecrets = dotenv.parse(readFileSync(join(__dirname, '../../config/secrets.example.env')));

it('loads the config and adds default contract addresses', () => {
const chainId = '4';
const chainId = '5';
const invalidConfig = JSON.parse(readFileSync(exampleConfigPath, 'utf-8'));
invalidConfig.chains[0].id = chainId; // Need to use an actual chain not hardhat
delete invalidConfig.chains[0].contracts;
Expand Down
2 changes: 1 addition & 1 deletion packages/airnode-node/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const readConfig = (configPath: string): unknown => {
export function addDefaultContractAddresses(config: configTypes.Config): configTypes.Config {
const ctx = { addIssue: () => {}, path: [] }; // Unused, but required by validator functions
const chains = config.chains.map((chain) => {
const contracts = configTypes.ensureValidAirnodeRrp(chain.contracts, chain.id, ctx);
const { contracts } = configTypes.ensureConfigValidAirnodeRrp(chain, ctx);

const crossChainRequesterAuthorizers = chain.authorizers.crossChainRequesterAuthorizers.map((craObj) => {
return configTypes.ensureCrossChainRequesterAuthorizerValidAirnodeRrp(craObj, ctx);
Expand Down
32 changes: 32 additions & 0 deletions packages/airnode-node/src/evm/contracts/airnodeRrpDryRun.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { AirnodeRrpV0DryRunFactory, airnodeRrpDryRunTopics } from './airnodeRrpDryRun';

describe('AirnodeRrpDryRun', () => {
it('exposes the contract ABI function', () => {
const functions = AirnodeRrpV0DryRunFactory.abi
.filter((fn: any) => fn.type === 'function')
.map((fn: any) => fn.name)
.sort();
bdrhn9 marked this conversation as resolved.
Show resolved Hide resolved

expect(functions).toEqual(['fulfill']);
});

it('exposes the contract ABI events', () => {
const events = AirnodeRrpV0DryRunFactory.abi
.filter((fn: any) => fn.type === 'event')
.map((fn: any) => fn.name)
.sort();
expect(events).toEqual(['FulfilledRequest']);
});

it('exposes the contract topics', () => {
// Make sure all topics are covered
expect.assertions(2);

expect(Object.keys(airnodeRrpDryRunTopics).sort()).toEqual(['FulfilledRequest']);

// API calls
expect(airnodeRrpDryRunTopics.FulfilledRequest).toEqual(
'0xc0977dab79883641ece94bb6a932ca83049f561ffff8d8daaeafdbc1acce9e0a'
);
});
});
11 changes: 11 additions & 0 deletions packages/airnode-node/src/evm/contracts/airnodeRrpDryRun.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { ethers } from 'ethers';
import { AirnodeRrpV0DryRun, AirnodeRrpV0DryRunFactory } from '@api3/airnode-protocol';

const FulfilledRequest = ethers.utils.id('FulfilledRequest(address,bytes32,bytes)');

const airnodeRrpDryRunTopics = {
// API calls
FulfilledRequest,
};

export { AirnodeRrpV0DryRunFactory, AirnodeRrpV0DryRun, airnodeRrpDryRunTopics };
1 change: 1 addition & 0 deletions packages/airnode-node/src/evm/contracts/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './airnodeRrp';
export * from './airnodeRrpDryRun';
Loading