Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
feat: add filecoin to CLI, Filecoin.ChainNotify method, and Filecoi…
Browse files Browse the repository at this point in the history
…n support for websockets/subscriptions (#768)

Co-authored-by: David Murdoch <[email protected]>
  • Loading branch information
mikeseese and davidmurdoch committed Mar 30, 2021
1 parent 5f2e0bf commit 384bfa4
Show file tree
Hide file tree
Showing 147 changed files with 6,122 additions and 1,629 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ jobs:
if: startsWith(matrix.os, 'windows-')
run: npm config set msvs_version 2015
- run: npm ci
- run: npm run tsc
- run: npm test
env:
FORCE_COLOR: 1
2 changes: 2 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
with:
node-version: ${{ matrix.node }}
- run: npm ci
- run: npm run tsc
- run: npm test
env:
FORCE_COLOR: 1
Expand Down Expand Up @@ -66,6 +67,7 @@ jobs:
if: startsWith(matrix.os, 'windows-')
run: npm config set msvs_version 2015
- run: npm ci
- run: npm run tsc
- run: npm test
env:
FORCE_COLOR: 1
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"start": "lerna exec --loglevel=silent --scope ganache -- npm run start --silent -- ",
"test": "lerna exec -- npm run test",
"tsc": "ttsc --build src",
"tsc.clean": "npx lerna exec -- npx shx rm -rf lib dist"
"tsc.clean": "npx lerna exec -- npx shx rm -rf lib dist",
"tsc.filecoin.declarations": "lerna run tsc.declarations --scope @ganache/filecoin && pretty-quick src/chains/filecoin/types"
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "1.0.1",
Expand Down
3 changes: 1 addition & 2 deletions src/chains/ethereum/ethereum/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
hashPersonalMessage
} from "ethereumjs-util";
import { TypedData as NotTypedData, signTypedData_v4 } from "eth-sig-util";
import { EthereumInternalOptions } from "@ganache/ethereum-options";
import { EthereumInternalOptions, Hardfork } from "@ganache/ethereum-options";
import { types, Data, Quantity, PromiEvent, utils } from "@ganache/utils";
import Blockchain, { TransactionTraceOptions } from "./blockchain";
import Wallet from "./wallet";
Expand All @@ -44,7 +44,6 @@ import {
parseFilterDetails,
parseFilterRange
} from "./helpers/filter-parsing";
import { Hardfork } from "@ganache/ethereum-options";

// Read in the current ganache version from core's package.json
const { version } = $INLINE_JSON("../../../../packages/ganache/package.json");
Expand Down
4 changes: 2 additions & 2 deletions src/chains/ethereum/ethereum/src/connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { RecognizedString, WebSocket, HttpRequest } from "uWebSockets.js";
import { CodedError, ErrorCodes } from "@ganache/ethereum-utils";
import {
EthereumProviderOptions,
EthereumLegacyOptions
EthereumLegacyProviderOptions
} from "@ganache/ethereum-options";

export type ProviderOptions = EthereumProviderOptions | EthereumLegacyOptions;
type ProviderOptions = EthereumProviderOptions | EthereumLegacyProviderOptions;
export type Provider = EthereumProvider;
export const Provider = EthereumProvider;

Expand Down
4 changes: 2 additions & 2 deletions src/chains/ethereum/ethereum/src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
EthereumProviderOptions,
EthereumInternalOptions,
EthereumOptionsConfig,
EthereumLegacyOptions
EthereumLegacyProviderOptions
} from "@ganache/ethereum-options";
import cloneDeep from "lodash.clonedeep";
import { PromiEvent, types, utils } from "@ganache/utils";
Expand Down Expand Up @@ -43,7 +43,7 @@ export default class EthereumProvider
#wallet: Wallet;

constructor(
options: EthereumProviderOptions | EthereumLegacyOptions = {},
options: EthereumProviderOptions | EthereumLegacyProviderOptions = {},
executor: utils.Executor
) {
super();
Expand Down
2 changes: 1 addition & 1 deletion src/chains/ethereum/ethereum/tests/api/debug/debug.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,6 @@ describe("api", () => {
}

assert.strictEqual(countMap.size, expectedObjectsInFinalTrace);
});
}).timeout(5000);
});
});
31 changes: 13 additions & 18 deletions src/chains/ethereum/options/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { WalletConfig, WalletOptions } from "./wallet-options";
import {
Base,
Defaults,
Definitions,
ExternalConfig,
InternalConfig,
Legacy,
Expand All @@ -18,14 +17,22 @@ import {
} from "@ganache/options";
import { UnionToIntersection } from "./helper-types";

export type EthereumOptions = {
type EthereumConfig = {
chain: ChainConfig;
database: DatabaseConfig;
logging: LoggingConfig;
miner: MinerConfig;
wallet: WalletConfig;
};

export const EthereumDefaults: Defaults<EthereumConfig> = {
chain: ChainOptions,
database: DatabaseOptions,
logging: LoggingOptions,
miner: MinerOptions,
wallet: WalletOptions
};

type MakeLegacyOptions<C extends Base.Config> = UnionToIntersection<
{
[K in OptionName<C>]: K extends LegacyOptions<C>
Expand All @@ -34,7 +41,7 @@ type MakeLegacyOptions<C extends Base.Config> = UnionToIntersection<
}[keyof Options<C>]
>;

export type EthereumLegacyOptions = Partial<
export type EthereumLegacyProviderOptions = Partial<
MakeLegacyOptions<ChainConfig> &
MakeLegacyOptions<DatabaseConfig> &
MakeLegacyOptions<LoggingConfig> &
Expand All @@ -44,27 +51,15 @@ export type EthereumLegacyOptions = Partial<

export type EthereumProviderOptions = Partial<
{
[K in keyof EthereumOptions]: ExternalConfig<EthereumOptions[K]>;
[K in keyof EthereumConfig]: ExternalConfig<EthereumConfig[K]>;
}
>;

export type EthereumInternalOptions = {
[K in keyof EthereumOptions]: InternalConfig<EthereumOptions[K]>;
};

export type EthereumDefaults = {
[K in keyof EthereumOptions]: Definitions<EthereumOptions[K]>;
};

export const ethereumDefaults: Defaults<EthereumOptions> = {
chain: ChainOptions,
database: DatabaseOptions,
logging: LoggingOptions,
miner: MinerOptions,
wallet: WalletOptions
[K in keyof EthereumConfig]: InternalConfig<EthereumConfig[K]>;
};

export const EthereumOptionsConfig = new OptionsConfig(ethereumDefaults);
export const EthereumOptionsConfig = new OptionsConfig(EthereumDefaults);

export * from "./chain-options";
export * from "./database-options";
Expand Down
8 changes: 7 additions & 1 deletion src/chains/ethereum/options/src/miner-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,13 @@ export type MinerConfig = {

export const MinerOptions: Definitions<MinerConfig> = {
blockTime: {
normalize,
normalize: rawInput => {
if (rawInput < 0) {
throw new Error("miner.blockTime must be 0 or a positive number.");
}

return rawInput;
},
cliDescription:
'Sets the `blockTime` in seconds for automatic mining. A blockTime of `0` enables "instamine mode", where new executable transactions will be mined instantly.',
default: () => 0,
Expand Down
Loading

0 comments on commit 384bfa4

Please sign in to comment.