Make BASH token usable in local faucet

This commit is contained in:
Simon Warta
2020-02-10 18:53:15 +01:00
parent 748900f22d
commit a83344be94
6 changed files with 18 additions and 14 deletions
+3 -3
View File
@@ -10,12 +10,12 @@ import { CosmWasmConnection, TokenConfiguration } from "./cosmwasmconnection";
export function createCosmWasmConnector(
url: string,
addressPrefix: CosmosAddressBech32Prefix,
tokens: TokenConfiguration,
tokenConfig: TokenConfiguration,
expectedChainId?: ChainId,
): ChainConnector<CosmWasmConnection> {
const codec = new CosmWasmCodec(addressPrefix, tokens.bankTokens);
const codec = new CosmWasmCodec(addressPrefix, tokenConfig.bankTokens, tokenConfig.erc20Tokens);
return {
establishConnection: async () => CosmWasmConnection.establish(url, addressPrefix, tokens),
establishConnection: async () => CosmWasmConnection.establish(url, addressPrefix, tokenConfig),
codec: codec,
expectedChainId: expectedChainId,
};
+1 -1
View File
@@ -7,6 +7,6 @@ import { CosmWasmConnection, TokenConfiguration } from "./cosmwasmconnection";
export declare function createCosmWasmConnector(
url: string,
addressPrefix: CosmosAddressBech32Prefix,
tokens: TokenConfiguration,
tokenConfig: TokenConfiguration,
expectedChainId?: ChainId,
): ChainConnector<CosmWasmConnection>;
+1 -1
View File
@@ -116,7 +116,7 @@ situation is different.
```
curl --header "Content-Type: application/json" \
--request POST \
--data '{"ticker":"CASH","address":"tiov1k898u78hgs36uqw68dg7va5nfkgstu5z0fhz3f"}' \
--data '{"ticker":"BASH","address":"cosmos1yre6ac7qfgyfgvh58ph0rgw627rhw766y430qq"}' \
http://localhost:8000/credit
```
+2 -2
View File
@@ -19,7 +19,7 @@ export async function start(args: ReadonlyArray<string>): Promise<void> {
const connector = createCosmWasmConnector(
blockchainBaseUrl,
constants.addressPrefix,
constants.tokenConfig,
constants.developmentTokenConfig,
);
console.info(`Connecting to blockchain ${blockchainBaseUrl} ...`);
const connection = await connector.establishConnection();
@@ -35,7 +35,7 @@ export async function start(args: ReadonlyArray<string>): Promise<void> {
);
// Faucet
const faucet = new Faucet(constants.tokenConfig, connection, connector.codec, profile, true);
const faucet = new Faucet(constants.developmentTokenConfig, connection, connector.codec, profile, true);
const chainTokens = await faucet.loadTokenTickers();
console.info("Chain tokens:", chainTokens);
const accounts = await faucet.loadAccounts();
+11 -1
View File
@@ -6,7 +6,9 @@ export const port: number = Number.parseInt(process.env.FAUCET_PORT || "", 10) |
export const mnemonic: string | undefined = process.env.FAUCET_MNEMONIC;
export const addressPrefix = "cosmos";
export const tokenConfig: TokenConfiguration = {
/** For the local development chain */
export const developmentTokenConfig: TokenConfiguration = {
bankTokens: [
{
fractionalDigits: 6,
@@ -21,4 +23,12 @@ export const tokenConfig: TokenConfiguration = {
denom: "ustake",
},
],
erc20Tokens: [
{
contractAddress: "cosmos1hqrdl6wstt8qzshwc6mrumpjk9338k0lr4dqxd",
fractionalDigits: 0,
ticker: "BASH",
name: "Bash Token",
},
],
};
-6
View File
@@ -32,12 +32,6 @@ const defaultConfig: TokenConfiguration = {
},
],
erc20Tokens: [
// {
// contractAddress: "cosmos18vd8fpwxzck93qlwghaj6arh4p7c5n89uzcee5",
// fractionalDigits: 5,
// ticker: "ASH",
// name: "Ash Token",
// },
{
contractAddress: "cosmos1hqrdl6wstt8qzshwc6mrumpjk9338k0lr4dqxd",
fractionalDigits: 0,