Remove unused ethereum support from faucet

This commit is contained in:
Simon Warta
2020-01-30 07:36:44 +01:00
parent bf22ee313f
commit 3fbd1288fe
12 changed files with 9 additions and 146 deletions
-1
View File
@@ -63,7 +63,6 @@ The faucet uses standard HD paths for each blockchain, e.g.
```
IOV m/44'/234'/a'
Lisk m/44'/134'/a'
Ethereum m/44'/60'/0'/0/a
CosmWasm m/44'/118'/0'/0/a
```
-1
View File
@@ -37,7 +37,6 @@
"@iov/bns": "^2.0.0-alpha.7",
"@iov/crypto": "^2.0.0-alpha.7",
"@iov/encoding": "^2.0.0-alpha.7",
"@iov/ethereum": "^2.0.0-alpha.7",
"@iov/lisk": "^2.0.0-alpha.7",
"@iov/multichain": "^2.0.0-alpha.7",
"@koa/cors": "^3.0.0",
+3 -5
View File
@@ -5,7 +5,7 @@ import cors = require("@koa/cors");
import Koa from "koa";
import bodyParser from "koa-bodyparser";
import { creditAmount, gasLimit, gasPrice, setFractionalDigits } from "../../cashflow";
import { creditAmount, setFractionalDigits } from "../../cashflow";
import {
codecDefaultFractionalDigits,
codecFromString,
@@ -73,8 +73,8 @@ export async function start(args: ReadonlyArray<string>): Promise<void> {
const distibutorIdentities = identitiesOfFirstWallet(profile).slice(1);
await refillFirstChain(profile, signer, codec);
setInterval(async () => refillFirstChain(profile, signer, codec), 60_000); // ever 60 seconds
await refillFirstChain(profile, signer);
setInterval(async () => refillFirstChain(profile, signer), 60_000); // ever 60 seconds
console.info("Creating webserver ...");
const api = new Koa();
@@ -135,8 +135,6 @@ export async function start(args: ReadonlyArray<string>): Promise<void> {
recipient: address,
amount: creditAmount(ticker),
tokenTicker: ticker,
gasPrice: gasPrice(codec),
gasLimit: gasLimit(codec),
};
logSendJob(signer, job);
await sendOnFirstChain(profile, signer, job);
+1 -39
View File
@@ -1,15 +1,7 @@
// tslint:disable: no-object-mutation
import { TokenTicker } from "@iov/bcp";
import {
creditAmount,
gasLimit,
gasPrice,
refillAmount,
refillThreshold,
setFractionalDigits,
} from "./cashflow";
import { Codec } from "./codec";
import { creditAmount, refillAmount, refillThreshold, setFractionalDigits } from "./cashflow";
describe("Cashflow", () => {
beforeAll(() => {
@@ -130,34 +122,4 @@ describe("Cashflow", () => {
});
});
});
describe("gasPrice", () => {
it("returns undefined for non-Ethereum codecs", () => {
expect(gasPrice(Codec.Lisk)).toBeUndefined();
expect(gasPrice(Codec.Bns)).toBeUndefined();
});
it("returns amount for Ethereum codec", () => {
expect(gasPrice(Codec.Ethereum)).toEqual({
quantity: "20000000000",
fractionalDigits: 18,
tokenTicker: "ETH",
});
});
});
describe("gasLimit", () => {
it("returns undefined for non-Ethereum codecs", () => {
expect(gasLimit(Codec.Lisk)).toBeUndefined();
expect(gasLimit(Codec.Bns)).toBeUndefined();
});
it("returns amount for Ethereum codec", () => {
expect(gasLimit(Codec.Ethereum)).toEqual({
quantity: "2100000",
fractionalDigits: 18,
tokenTicker: "ETH",
});
});
});
});
-37
View File
@@ -3,9 +3,6 @@ import BN = require("bn.js");
import { Account, Amount, TokenTicker } from "@iov/bcp";
import { Int53 } from "@iov/encoding";
import { Codec } from "./codec";
import * as constants from "./constants";
/** Send `factor` times credit amount on refilling */
const defaultRefillFactor = 20;
@@ -61,37 +58,3 @@ export function needsRefill(account: Account, token: TokenTicker): boolean {
const refillQty = new BN(refillThreshold(token).quantity);
return new BN(tokenBalance).lt(refillQty);
}
export function gasPrice(codec: Codec): Amount | undefined {
switch (codec) {
case Codec.Bns:
case Codec.Lisk:
case Codec.CosmWasm:
return undefined;
case Codec.Ethereum:
return {
quantity: constants.ethereum.gasPrice,
fractionalDigits: 18,
tokenTicker: "ETH" as TokenTicker,
};
default:
throw new Error("No gasPrice imlementation found for this codec");
}
}
export function gasLimit(codec: Codec): Amount | undefined {
switch (codec) {
case Codec.Bns:
case Codec.Lisk:
case Codec.CosmWasm:
return undefined;
case Codec.Ethereum:
return {
quantity: constants.ethereum.gasLimit,
fractionalDigits: 18,
tokenTicker: "ETH" as TokenTicker,
};
default:
throw new Error("No gasLimit imlementation found for this codec");
}
}
+2 -2
View File
@@ -4,11 +4,11 @@ describe("Codec", () => {
it("can convert string to codec", () => {
expect(codecFromString("bns")).toEqual(Codec.Bns);
expect(codecFromString("lisk")).toEqual(Codec.Lisk);
expect(codecFromString("ethereum")).toEqual(Codec.Ethereum);
expect(codecFromString("cosmwasm")).toEqual(Codec.CosmWasm);
expect(() => codecFromString("")).toThrowError(/not supported/i);
expect(() => codecFromString("abc")).toThrowError(/not supported/i);
expect(() => codecFromString("LISK")).toThrowError(/not supported/i);
expect(() => codecFromString("ETHEREUM")).toThrowError(/not supported/i);
expect(() => codecFromString("CosmWasm")).toThrowError(/not supported/i);
});
});
-10
View File
@@ -2,14 +2,12 @@ import { createCosmWasmConnector, TokenInfo } from "@cosmwasm/bcp";
import { ChainConnector, TokenTicker, TxCodec } from "@iov/bcp";
import { createBnsConnector } from "@iov/bns";
import { Slip10RawIndex } from "@iov/crypto";
import { createEthereumConnector } from "@iov/ethereum";
import { HdPaths } from "@iov/keycontrol";
import { createLiskConnector } from "@iov/lisk";
export const enum Codec {
Bns,
Lisk,
Ethereum,
CosmWasm,
}
@@ -19,8 +17,6 @@ export function codecFromString(input: string): Codec {
return Codec.Bns;
case "lisk":
return Codec.Lisk;
case "ethereum":
return Codec.Ethereum;
case "cosmwasm":
return Codec.CosmWasm;
default:
@@ -35,8 +31,6 @@ export function createPathBuilderForCodec(codec: Codec): (derivation: number) =>
return HdPaths.iov(accountIndex);
case Codec.Lisk:
return HdPaths.bip44Like(134, accountIndex);
case Codec.Ethereum:
return HdPaths.ethereum(accountIndex);
case Codec.CosmWasm:
return HdPaths.cosmos(accountIndex);
default:
@@ -52,8 +46,6 @@ export function createChainConnector(codec: Codec, url: string): ChainConnector
return createBnsConnector(url);
case Codec.Lisk:
return createLiskConnector(url);
case Codec.Ethereum:
return createEthereumConnector(url, {});
case Codec.CosmWasm: {
const tokens: readonly TokenInfo[] = [
{
@@ -86,8 +78,6 @@ export function codecDefaultFractionalDigits(codec: Codec): number {
return 9; // fixed for all weave tokens
case Codec.Lisk:
return 8;
case Codec.Ethereum:
return 18;
case Codec.CosmWasm:
return 6;
default:
-4
View File
@@ -1,7 +1,3 @@
export const concurrency: number = Number.parseInt(process.env.FAUCET_CONCURRENCY || "", 10) || 5;
export const port: number = Number.parseInt(process.env.FAUCET_PORT || "", 10) || 8000;
export const mnemonic: string | undefined = process.env.FAUCET_MNEMONIC;
export const ethereum = {
gasPrice: "20000000000",
gasLimit: "2100000",
};
-1
View File
@@ -7,7 +7,6 @@ export function createWalletForCodec(input: Codec, mnemonic: string): Wallet {
case Codec.Bns:
case Codec.Lisk:
return Ed25519HdWallet.fromMnemonic(mnemonic);
case Codec.Ethereum:
case Codec.CosmWasm:
return Secp256k1HdWallet.fromMnemonic(mnemonic);
default:
+2 -9
View File
@@ -9,8 +9,7 @@ import {
import { UserProfile } from "@iov/keycontrol";
import { MultiChainSigner } from "@iov/multichain";
import { gasLimit, gasPrice, needsRefill, refillAmount } from "./cashflow";
import { Codec } from "./codec";
import { needsRefill, refillAmount } from "./cashflow";
import { debugAccount, logAccountsState, logSendJob } from "./debugging";
import { SendJob } from "./types";
@@ -89,11 +88,7 @@ export function availableTokensFromHolder(holderAccount: Account): ReadonlyArray
return holderAccount.balance.map(coin => coin.tokenTicker);
}
export async function refillFirstChain(
profile: UserProfile,
signer: MultiChainSigner,
codec: Codec,
): Promise<void> {
export async function refillFirstChain(profile: UserProfile, signer: MultiChainSigner): Promise<void> {
const chainId = signer.chainIds()[0];
console.info(`Connected to network: ${chainId}`);
@@ -124,8 +119,6 @@ export async function refillFirstChain(
recipient: refillDistibutor.address,
tokenTicker: token,
amount: refillAmount(token),
gasPrice: gasPrice(codec),
gasLimit: gasLimit(codec),
});
}
}
-2
View File
@@ -5,6 +5,4 @@ export interface SendJob {
readonly recipient: Address;
readonly tokenTicker: TokenTicker;
readonly amount: Amount;
readonly gasPrice?: Amount;
readonly gasLimit?: Amount;
}