Add support for ERC20 in faucet
This commit is contained in:
parent
b7ca6da1bf
commit
f38e07632a
@ -38,17 +38,17 @@ const defaultConfig: TokenConfiguration = {
|
||||
// ticker: "ASH",
|
||||
// name: "Ash Token",
|
||||
// },
|
||||
// {
|
||||
// contractAddress: "cosmos1hqrdl6wstt8qzshwc6mrumpjk9338k0lr4dqxd",
|
||||
// fractionalDigits: 0,
|
||||
// ticker: "BASH",
|
||||
// name: "Bash Token",
|
||||
// },
|
||||
{
|
||||
contractAddress: "cosmos1hqrdl6wstt8qzshwc6mrumpjk9338k0lr4dqxd",
|
||||
fractionalDigits: 0,
|
||||
ticker: "BASH",
|
||||
name: "Bash Token",
|
||||
},
|
||||
],
|
||||
};
|
||||
const defaultPrefix = "cosmos" as CosmosAddressBech32Prefix;
|
||||
const defaultChainId = "cosmos:testing" as ChainId;
|
||||
const codec = new CosmWasmCodec(defaultPrefix, defaultConfig.bankTokens);
|
||||
const codec = new CosmWasmCodec(defaultPrefix, defaultConfig.bankTokens, defaultConfig.erc20Tokens);
|
||||
|
||||
function makeRandomAddress(): Address {
|
||||
return Bech32.encode(defaultPrefix, Random.getBytes(20)) as Address;
|
||||
@ -81,7 +81,34 @@ describe("Faucet", () => {
|
||||
});
|
||||
|
||||
describe("send", () => {
|
||||
it("can send", async () => {
|
||||
it("can send bank token", async () => {
|
||||
pendingWithoutCosmos();
|
||||
const connection = await CosmWasmConnection.establish(httpUrl, defaultPrefix, defaultConfig);
|
||||
const { profile, holder } = await makeProfile();
|
||||
const faucet = new Faucet(defaultConfig, connection, codec, profile);
|
||||
const recipient = makeRandomAddress();
|
||||
await faucet.send({
|
||||
amount: {
|
||||
quantity: "7",
|
||||
fractionalDigits: 0,
|
||||
tokenTicker: "BASH" as TokenTicker,
|
||||
},
|
||||
sender: holder,
|
||||
recipient: recipient,
|
||||
});
|
||||
const account = await connection.getAccount({ address: recipient });
|
||||
assert(account);
|
||||
expect(account.balance).toEqual([
|
||||
{
|
||||
quantity: "7",
|
||||
fractionalDigits: 0,
|
||||
tokenTicker: "BASH" as TokenTicker,
|
||||
},
|
||||
]);
|
||||
connection.disconnect();
|
||||
});
|
||||
|
||||
it("can send ERC20 token", async () => {
|
||||
pendingWithoutCosmos();
|
||||
const connection = await CosmWasmConnection.establish(httpUrl, defaultPrefix, defaultConfig);
|
||||
const { profile, holder } = await makeProfile();
|
||||
@ -119,6 +146,10 @@ describe("Faucet", () => {
|
||||
const distributorBalance = (await connection.getAccount({ pubkey: distributors[0].pubkey }))?.balance;
|
||||
assert(distributorBalance);
|
||||
expect(distributorBalance).toEqual([
|
||||
jasmine.objectContaining({
|
||||
tokenTicker: "BASH",
|
||||
fractionalDigits: 0,
|
||||
}),
|
||||
jasmine.objectContaining({
|
||||
tokenTicker: "COSM",
|
||||
fractionalDigits: 6,
|
||||
@ -128,8 +159,9 @@ describe("Faucet", () => {
|
||||
fractionalDigits: 6,
|
||||
}),
|
||||
]);
|
||||
expect(Number.parseInt(distributorBalance[0].quantity, 10)).toBeGreaterThanOrEqual(80_000000);
|
||||
expect(Number.parseInt(distributorBalance[0].quantity, 10)).toBeGreaterThanOrEqual(80);
|
||||
expect(Number.parseInt(distributorBalance[1].quantity, 10)).toBeGreaterThanOrEqual(80_000000);
|
||||
expect(Number.parseInt(distributorBalance[2].quantity, 10)).toBeGreaterThanOrEqual(80_000000);
|
||||
connection.disconnect();
|
||||
});
|
||||
});
|
||||
@ -181,7 +213,7 @@ describe("Faucet", () => {
|
||||
const { profile } = await makeProfile();
|
||||
const faucet = new Faucet(defaultConfig, connection, codec, profile);
|
||||
const tickers = await faucet.loadTokenTickers();
|
||||
expect(tickers).toEqual(["COSM", "STAKE"]);
|
||||
expect(tickers).toEqual(["BASH", "COSM", "STAKE"]);
|
||||
connection.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user