Skip to content

Commit

Permalink
Multiple proofs (#50)
Browse files Browse the repository at this point in the history
* add support for multiple proofs

* release 0.2.4

* remove console.log

* yarn lint

* add missing type definition

* lint
  • Loading branch information
AlexNi245 authored Sep 7, 2023
1 parent 864cc8e commit 51468eb
Showing 1 changed file with 26 additions and 14 deletions.
40 changes: 26 additions & 14 deletions gateway/handler/optimism-bedrock/optimismBedrockHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ethers } from 'ethers';

import { OptimismBedrockConfigEntry } from '../../config/Config';
import { getProofParamType } from '../../service/encoding/proof/getProofParamType';
import { ProofService } from '../../service/proof/ProofService';
import { ProofService, StorageLayout } from '../../service/proof/ProofService';

export async function optimismBedrockHandler(
calldata: string,
Expand All @@ -28,22 +28,34 @@ export async function optimismBedrockHandler(

// for each proof request, create a proof
const proofs = await Promise.all(
proofRequests.map(async ({ target, slot, layout, result }) => {
if (!target || !slot || layout === undefined) {
throw new Error('optimismBedrockHandler : Invalid data source response');
}

const { proof, result: proofResult } = await new ProofService(l1Provider, l2Provider).createProof(
proofRequests.map(
async ({
target,
slot,
layout,
);

console.log('Proof result: ', proofResult);

const proofParamType = await getProofParamType();
return ethers.utils.defaultAbiCoder.encode(['bytes', proofParamType], [result, proof]);
}),
result,
}: {
target: string;
slot: string;
layout: StorageLayout;
result: string;
}) => {
if (!target || !slot || layout === undefined) {
throw new Error('optimismBedrockHandler : Invalid data source response');
}

const { proof, result: proofResult } = await new ProofService(l1Provider, l2Provider).createProof(
target,
slot,
layout,
);

console.log('Proof result: ', proofResult);

const proofParamType = await getProofParamType();
return ethers.utils.defaultAbiCoder.encode(['bytes', proofParamType], [result, proof]);
},
),
);
// return the proofs as bytes array
return ethers.utils.defaultAbiCoder.encode(['bytes[]'], [proofs]);
Expand Down

0 comments on commit 51468eb

Please sign in to comment.