Skip to content

Commit

Permalink
Fix linting error
Browse files Browse the repository at this point in the history
  • Loading branch information
makoto committed May 8, 2024
1 parent 1a62678 commit e1a3e64
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 44 deletions.
6 changes: 5 additions & 1 deletion evm-gateway/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
export { EVMGateway, StorageLayout } from './EVMGateway.js';
export { EVMProofHelper, type StateProof } from './EVMProofHelper.js';
export type { IProofService, ProvableBlock } from './IProofService.js';
export { propsDecoder, convertIntoMerkleTrieProof,type Router } from './utils.js';
export {
propsDecoder,
convertIntoMerkleTrieProof,
type Router,
} from './utils.js';
26 changes: 15 additions & 11 deletions evm-gateway/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,21 @@ export const propsDecoder: PropsDecoder<CFWRequest> = (
}
};

export const convertIntoMerkleTrieProof = (
proof: StateProof
) => {
const storageProofs:any = []
const stateTrieWitness = AbiCoder.defaultAbiCoder().encode(["bytes[]"], [proof.stateTrieWitness])
export const convertIntoMerkleTrieProof = (proof: StateProof) => {
const storageProofs: string[] = [];
const stateTrieWitness = AbiCoder.defaultAbiCoder().encode(
['bytes[]'],
[proof.stateTrieWitness]
);
for (let index = 0; index < proof.storageProofs.length; index++) {
const storageProof = AbiCoder.defaultAbiCoder().encode(["bytes[]"], [proof.storageProofs[index]])
storageProofs[index] = storageProof
const storageProof = AbiCoder.defaultAbiCoder().encode(
['bytes[]'],
[proof.storageProofs[index]]
);
storageProofs[index] = storageProof;
}
return({
return {
stateTrieWitness,
storageProofs
})
}
storageProofs,
};
};
6 changes: 5 additions & 1 deletion l1-gateway/src/L1ProofService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import {
type JsonRpcProvider,
} from 'ethers';

import { EVMProofHelper, convertIntoMerkleTrieProof, type IProofService } from '@ensdomains/evm-gateway';
import {
EVMProofHelper,
convertIntoMerkleTrieProof,
type IProofService,
} from '@ensdomains/evm-gateway';
import { Block, type JsonRpcBlock } from '@ethereumjs/block';

type RlpObject = Uint8Array | Array<RlpObject>;
Expand Down
6 changes: 5 additions & 1 deletion op-gateway/src/OPProofService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { EVMProofHelper, convertIntoMerkleTrieProof, type IProofService } from '@ensdomains/evm-gateway';
import {
EVMProofHelper,
convertIntoMerkleTrieProof,
type IProofService,
} from '@ensdomains/evm-gateway';
import { type JsonRpcBlock } from '@ethereumjs/block';
import { AbiCoder, Contract, JsonRpcProvider, type AddressLike } from 'ethers';

Expand Down
13 changes: 6 additions & 7 deletions scroll-gateway/src/ScrollProofService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ export class ScrollProofService implements IProofService<ScrollProvableBlock> {
slots: bigint[]
): Promise<string> {
const searchUrl = 'https://sepolia-api-re.scroll.io/api/search';
const resp:any = await fetch(`${searchUrl}?keyword=${Number(block.number)}`)
const obj:any = await resp.json()
const batchIndex = obj.batch_index
const proof = await this.helper.getProofs(Number(block.number), address, slots)
const compressedProofs:any = []
const { batch_index: batchIndex } = await (
await fetch(`${searchUrl}?keyword=${Number(block.number)}`)
).json();
const proof = await this.helper.getProofs(Number(block.number), address, slots);
const compressedProofs: string[] = [];
const accountProof: string = proof.stateTrieWitness;
for (let index = 0; index < proof.storageProofs.length; index++) {
const storageProof: string = proof.storageProofs[index];
Expand All @@ -56,7 +56,7 @@ export class ScrollProofService implements IProofService<ScrollProvableBlock> {
...storageProof,
]);
}
const res:any = AbiCoder.defaultAbiCoder().encode(
return AbiCoder.defaultAbiCoder().encode(
[
'tuple(uint256 batchIndex)',
'tuple(bytes[] storageProofs)',
Expand All @@ -70,7 +70,6 @@ export class ScrollProofService implements IProofService<ScrollProvableBlock> {
},
]
);
return res;
}
/**
* @dev Returns an object representing a block whose state can be proven on L1.
Expand Down
13 changes: 6 additions & 7 deletions scroll-gateway/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { EVMGateway } from '@ensdomains/evm-gateway';
import { JsonRpcProvider } from 'ethers';
import { ScrollProofService, type ScrollProvableBlock } from './ScrollProofService.js';
import {
ScrollProofService,
type ScrollProvableBlock,
} from './ScrollProofService.js';

export type ScrollGateway = EVMGateway<ScrollProvableBlock>;

export async function makeScrollGateway(
l2providerUrl: string,
l2providerUrl: string
): Promise<ScrollGateway> {
const l2Provider = new JsonRpcProvider(l2providerUrl);
return new EVMGateway(
new ScrollProofService(
l2Provider,
)
);
return new EVMGateway(new ScrollProofService(l2Provider));
}

export { ScrollProofService, type ScrollProvableBlock };
6 changes: 1 addition & 5 deletions scroll-gateway/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ program.parse();

const l2Provider = new JsonRpcProvider(options.l2ProviderUrl);

const gateway = new EVMGateway(
new ScrollProofService(
l2Provider
)
);
const gateway = new EVMGateway(new ScrollProofService(l2Provider));
const server = new Server();
gateway.add(server);
const app = server.makeApp('/');
Expand Down
13 changes: 2 additions & 11 deletions scroll-gateway/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ interface Env {
let app: Router;

async function fetch(request: CFWRequest, env: Env) {
const {
L2_PROVIDER_URL,
GATEWAY_DOMAIN,
ENDPOINT_URL,
} = env;
const { L2_PROVIDER_URL, GATEWAY_DOMAIN, ENDPOINT_URL } = env;

// Loading libraries dynamically as a temp work around.
// Otherwise, deployment thorws "Error: Script startup exceeded CPU time limit." error
Expand All @@ -35,11 +31,7 @@ async function fetch(request: CFWRequest, env: Env) {
.ScrollProofService;
const l2Provider = new ethers.JsonRpcProvider(L2_PROVIDER_URL);

const gateway = new EVMGateway(
new ScrollProofService(
l2Provider
)
);
const gateway = new EVMGateway(new ScrollProofService(l2Provider));

const server = new Server();
gateway.add(server);
Expand All @@ -50,7 +42,6 @@ async function fetch(request: CFWRequest, env: Env) {
return app
.handle(request)
.then(tracker.logResult.bind(tracker, propsDecoder, request));

}

export default {
Expand Down

0 comments on commit e1a3e64

Please sign in to comment.