Skip to content

Commit

Permalink
Fix remove ethers
Browse files Browse the repository at this point in the history
  • Loading branch information
jiqiang90 committed Jul 3, 2024
1 parent 4f1922d commit 66d284f
Show file tree
Hide file tree
Showing 6 changed files with 252 additions and 50 deletions.
3 changes: 2 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@subql/common-algorand": "^4.0.0",
"@subql/common-concordium": "^4.0.1",
"@subql/common-cosmos": "^5.0.0",
"@subql/common-ethereum": "^4.0.0",
"@subql/common-ethereum": "^4.1.0",
"@subql/common-near": "^4.0.0",
"@subql/common-stellar": "^4.0.0",
"@subql/common-substrate": "workspace:*",
Expand All @@ -52,6 +52,7 @@
"eslint": "^8.8.0",
"eslint-config-oclif": "^4.0.0",
"eslint-config-oclif-typescript": "^1.0.2",
"ethers": "^5.7.0",
"oclif": "^3.15.0"
},
"engines": {
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/commands/codegen/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
generateHandlers,
generateManifestTs,
generateManifestYaml,
getAbiInterface,
getManifestData,
ManifestExtractor,
prepareAbiDirectory,
Expand Down Expand Up @@ -113,7 +112,7 @@ export default class Generate extends Command {
const abiFileName = path.basename(abiPath);

// fragments from abi
const abiInterface = getAbiInterface(root, abiFileName);
const abiInterface = ethModule.getAbiInterface(root, abiFileName);
const eventsFragments = abiInterface.events;
const functionFragments = filterObjectsByStateMutability(abiInterface.functions);

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/controller/generate-controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import os from 'os';
import path from 'path';
import {EventFragment, FunctionFragment} from '@ethersproject/abi/src.ts/fragments';
import {DEFAULT_TS_MANIFEST, NETWORK_FAMILY} from '@subql/common';
import {getAbiInterface} from '@subql/common-ethereum';
import {
SubqlRuntimeDatasource as EthereumDs,
EthereumLogFilter,
Expand All @@ -32,7 +33,6 @@ import {
filterExistingMethods,
filterObjectsByStateMutability,
generateHandlerName,
getAbiInterface,
prepareInputFragments,
removeKeyword,
tsExtractor,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/controller/generate-controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import path from 'path';
import {promisify} from 'util';
import {EventFragment, FunctionFragment} from '@ethersproject/abi';
import {DEFAULT_TS_MANIFEST, loadFromJsonOrYaml, NETWORK_FAMILY} from '@subql/common';
import {getAbiInterface} from '@subql/common-ethereum';
import {SubqlRuntimeDatasource as EthereumDs} from '@subql/types-ethereum';
import rimraf from 'rimraf';
import {Document, stringify} from 'yaml';
Expand All @@ -19,7 +20,6 @@ import {
generateHandlers,
generateManifestTs,
generateManifestYaml,
getAbiInterface,
getManifestData,
prepareAbiDirectory,
prepareInputFragments,
Expand Down
17 changes: 2 additions & 15 deletions packages/cli/src/controller/generate-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import fs from 'fs';
import path from 'path';
import {ConstructorFragment, EventFragment, Fragment, FunctionFragment} from '@ethersproject/abi/src.ts/fragments';
import {loadFromJsonOrYaml, NETWORK_FAMILY} from '@subql/common';
import type {ConstructorFragment, EventFragment, Fragment, FunctionFragment} from '@ethersproject/abi/src.ts/fragments';
import {NETWORK_FAMILY} from '@subql/common';
import type {
EthereumDatasourceKind,
EthereumHandlerKind,
Expand All @@ -14,7 +14,6 @@ import type {
SubqlRuntimeHandler,
} from '@subql/types-ethereum';
import chalk from 'chalk';
import {Interface} from 'ethers/lib/utils';
import * as inquirer from 'inquirer';
import {difference, pickBy, upperFirst} from 'lodash';
import {Document, parseDocument, YAMLSeq} from 'yaml';
Expand Down Expand Up @@ -103,18 +102,6 @@ export async function promptSelectables<T extends ConstructorFragment | Fragment
return selectedMethods;
}

export function getAbiInterface(projectPath: string, abiFileName: string): Interface {
const abi = loadFromJsonOrYaml(path.join(projectPath, DEFAULT_ABI_DIR, abiFileName)) as any;
if (!Array.isArray(abi)) {
if (!abi.abi) {
throw new Error(`Provided ABI is not a valid ABI or Artifact`);
}
return new Interface(abi.abi);
} else {
return new Interface(abi);
}
}

export function filterObjectsByStateMutability(
obj: Record<string, FunctionFragment>
): Record<string, FunctionFragment> {
Expand Down
Loading

0 comments on commit 66d284f

Please sign in to comment.