Use new token names HASH/ISA/JADE
those don't conflict with other BCP demo tokens
This commit is contained in:
@@ -22,17 +22,17 @@ const defaultErc20Tokens: readonly Erc20Token[] = [
|
||||
{
|
||||
contractAddress: "cosmos18vd8fpwxzck93qlwghaj6arh4p7c5n89uzcee5",
|
||||
fractionalDigits: 5,
|
||||
ticker: "ASH",
|
||||
ticker: "HASH",
|
||||
},
|
||||
{
|
||||
contractAddress: "cosmos1hqrdl6wstt8qzshwc6mrumpjk9338k0lr4dqxd",
|
||||
fractionalDigits: 0,
|
||||
ticker: "BASH",
|
||||
ticker: "ISA",
|
||||
},
|
||||
{
|
||||
contractAddress: "cosmos18r5szma8hm93pvx6lwpjwyxruw27e0k5uw835c",
|
||||
fractionalDigits: 18,
|
||||
ticker: "CASH",
|
||||
ticker: "JADE",
|
||||
},
|
||||
];
|
||||
|
||||
@@ -73,11 +73,11 @@ describe("CosmWasmCodec", () => {
|
||||
chainId: chainId,
|
||||
sender: "cosmos1txqfn5jmcts0x0q7krdxj8tgf98tj0965vqlmq" as Address,
|
||||
recipient: "cosmos1dddd" as Address,
|
||||
memo: "My first BASH payment",
|
||||
memo: "My first ISA payment",
|
||||
amount: {
|
||||
fractionalDigits: 0,
|
||||
quantity: "345",
|
||||
tokenTicker: "BASH" as TokenTicker,
|
||||
tokenTicker: "ISA" as TokenTicker,
|
||||
},
|
||||
fee: {
|
||||
tokens: {
|
||||
@@ -91,7 +91,7 @@ describe("CosmWasmCodec", () => {
|
||||
|
||||
const expected = {
|
||||
bytes: toUtf8(
|
||||
'{"account_number":"0","chain_id":"cosmoshub-3","fee":{"amount":[{"amount":"2500","denom":"uatom"}],"gas":"100000"},"memo":"My first BASH payment","msgs":[{"type":"wasm/execute","value":{"contract":"cosmos1hqrdl6wstt8qzshwc6mrumpjk9338k0lr4dqxd","msg":{"transfer":{"amount":"345","recipient":"cosmos1dddd"}},"sender":"cosmos1txqfn5jmcts0x0q7krdxj8tgf98tj0965vqlmq","sent_funds":[]}}],"sequence":"99"}',
|
||||
'{"account_number":"0","chain_id":"cosmoshub-3","fee":{"amount":[{"amount":"2500","denom":"uatom"}],"gas":"100000"},"memo":"My first ISA payment","msgs":[{"type":"wasm/execute","value":{"contract":"cosmos1hqrdl6wstt8qzshwc6mrumpjk9338k0lr4dqxd","msg":{"transfer":{"amount":"345","recipient":"cosmos1dddd"}},"sender":"cosmos1txqfn5jmcts0x0q7krdxj8tgf98tj0965vqlmq","sent_funds":[]}}],"sequence":"99"}',
|
||||
),
|
||||
prehashType: PrehashType.Sha256,
|
||||
};
|
||||
|
||||
@@ -54,7 +54,7 @@ const faucet = {
|
||||
|
||||
describe("CosmWasmConnection", () => {
|
||||
const cosm = "COSM" as TokenTicker;
|
||||
const bash = "BASH" as TokenTicker;
|
||||
const isa = "ISA" as TokenTicker;
|
||||
const httpUrl = "http://localhost:1317";
|
||||
const defaultChainId = "cosmos:testing" as ChainId;
|
||||
const defaultEmptyAddress = "cosmos1h806c7khnvmjlywdrkdgk2vrayy2mmvf9rxk2r" as Address;
|
||||
@@ -93,20 +93,20 @@ describe("CosmWasmConnection", () => {
|
||||
{
|
||||
contractAddress: "cosmos18vd8fpwxzck93qlwghaj6arh4p7c5n89uzcee5",
|
||||
fractionalDigits: 5,
|
||||
ticker: "ASH",
|
||||
name: "Ash Token",
|
||||
ticker: "HASH",
|
||||
name: "Hash Token",
|
||||
},
|
||||
{
|
||||
contractAddress: "cosmos1hqrdl6wstt8qzshwc6mrumpjk9338k0lr4dqxd",
|
||||
fractionalDigits: 0,
|
||||
ticker: "BASH",
|
||||
name: "Bash Token",
|
||||
ticker: "ISA",
|
||||
name: "Isa Token",
|
||||
},
|
||||
{
|
||||
contractAddress: "cosmos18r5szma8hm93pvx6lwpjwyxruw27e0k5uw835c",
|
||||
fractionalDigits: 18,
|
||||
ticker: "CASH",
|
||||
name: "Cash Token",
|
||||
ticker: "JADE",
|
||||
name: "Jade Token",
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -178,26 +178,26 @@ describe("CosmWasmConnection", () => {
|
||||
const connection = await CosmWasmConnection.establish(httpUrl, defaultPrefix, defaultConfig);
|
||||
const tokens = await connection.getAllTokens();
|
||||
expect(tokens).toEqual([
|
||||
{
|
||||
fractionalDigits: 5,
|
||||
tokenName: "Ash Token",
|
||||
tokenTicker: "ASH" as TokenTicker,
|
||||
},
|
||||
{
|
||||
fractionalDigits: 0,
|
||||
tokenName: "Bash Token",
|
||||
tokenTicker: "BASH" as TokenTicker,
|
||||
},
|
||||
{
|
||||
fractionalDigits: 18,
|
||||
tokenName: "Cash Token",
|
||||
tokenTicker: "CASH" as TokenTicker,
|
||||
},
|
||||
{
|
||||
fractionalDigits: 6,
|
||||
tokenName: "Fee Token",
|
||||
tokenTicker: "COSM" as TokenTicker,
|
||||
},
|
||||
{
|
||||
fractionalDigits: 5,
|
||||
tokenName: "Hash Token",
|
||||
tokenTicker: "HASH" as TokenTicker,
|
||||
},
|
||||
{
|
||||
fractionalDigits: 0,
|
||||
tokenName: "Isa Token",
|
||||
tokenTicker: "ISA" as TokenTicker,
|
||||
},
|
||||
{
|
||||
fractionalDigits: 18,
|
||||
tokenName: "Jade Token",
|
||||
tokenTicker: "JADE" as TokenTicker,
|
||||
},
|
||||
{
|
||||
fractionalDigits: 6,
|
||||
tokenName: "Staking Token",
|
||||
@@ -236,20 +236,20 @@ describe("CosmWasmConnection", () => {
|
||||
expect(account.pubkey).toBeUndefined();
|
||||
expect(account.balance).toEqual([
|
||||
{
|
||||
tokenTicker: "ASH" as TokenTicker,
|
||||
tokenTicker: "COSM" as TokenTicker,
|
||||
quantity: "1000000000",
|
||||
fractionalDigits: 6,
|
||||
},
|
||||
{
|
||||
tokenTicker: "HASH" as TokenTicker,
|
||||
quantity: "12812345",
|
||||
fractionalDigits: 5,
|
||||
},
|
||||
{
|
||||
tokenTicker: "BASH" as TokenTicker,
|
||||
tokenTicker: "ISA" as TokenTicker,
|
||||
quantity: "42",
|
||||
fractionalDigits: 0,
|
||||
},
|
||||
{
|
||||
tokenTicker: "COSM" as TokenTicker,
|
||||
quantity: "1000000000",
|
||||
fractionalDigits: 6,
|
||||
},
|
||||
{
|
||||
tokenTicker: "STAKE" as TokenTicker,
|
||||
quantity: "1000000000",
|
||||
@@ -410,7 +410,7 @@ describe("CosmWasmConnection", () => {
|
||||
amount: {
|
||||
quantity: "345",
|
||||
fractionalDigits: 0,
|
||||
tokenTicker: bash,
|
||||
tokenTicker: isa,
|
||||
},
|
||||
});
|
||||
const nonce = await connection.getNonce({ address: senderAddress });
|
||||
@@ -1000,7 +1000,7 @@ describe("CosmWasmConnection", () => {
|
||||
amount: {
|
||||
quantity: "75",
|
||||
fractionalDigits: 0,
|
||||
tokenTicker: "BASH" as TokenTicker,
|
||||
tokenTicker: "ISA" as TokenTicker,
|
||||
},
|
||||
});
|
||||
const nonce = await connection.getNonce({ address: senderAddress });
|
||||
@@ -1011,10 +1011,10 @@ describe("CosmWasmConnection", () => {
|
||||
expect(blockInfo.state).toEqual(TransactionState.Succeeded);
|
||||
|
||||
const recipientAccount = await connection.getAccount({ address: recipient });
|
||||
assert(recipientAccount, "Recipient account must have BASH tokens");
|
||||
assert(recipientAccount, "Recipient account must have ISA tokens");
|
||||
expect(recipientAccount.balance).toEqual([
|
||||
{
|
||||
tokenTicker: "BASH" as TokenTicker,
|
||||
tokenTicker: "ISA" as TokenTicker,
|
||||
quantity: "75",
|
||||
fractionalDigits: 0,
|
||||
},
|
||||
|
||||
@@ -68,17 +68,17 @@ describe("decode", () => {
|
||||
{
|
||||
contractAddress: "cosmos18vd8fpwxzck93qlwghaj6arh4p7c5n89uzcee5",
|
||||
fractionalDigits: 5,
|
||||
ticker: "ASH",
|
||||
ticker: "HASH",
|
||||
},
|
||||
{
|
||||
contractAddress: "cosmos1hqrdl6wstt8qzshwc6mrumpjk9338k0lr4dqxd",
|
||||
fractionalDigits: 0,
|
||||
ticker: "BASH",
|
||||
ticker: "ISA",
|
||||
},
|
||||
{
|
||||
contractAddress: "cosmos18r5szma8hm93pvx6lwpjwyxruw27e0k5uw835c",
|
||||
fractionalDigits: 18,
|
||||
ticker: "CASH",
|
||||
ticker: "JADE",
|
||||
},
|
||||
];
|
||||
|
||||
@@ -187,7 +187,7 @@ describe("decode", () => {
|
||||
recipient: "cosmos1z7g5w84ynmjyg0kqpahdjqpj7yq34v3suckp0e" as Address,
|
||||
amount: {
|
||||
quantity: "887878484",
|
||||
tokenTicker: "ASH" as TokenTicker,
|
||||
tokenTicker: "HASH" as TokenTicker,
|
||||
fractionalDigits: 5,
|
||||
},
|
||||
memo: defaultMemo,
|
||||
@@ -255,7 +255,7 @@ describe("decode", () => {
|
||||
recipient: "cosmos1z7g5w84ynmjyg0kqpahdjqpj7yq34v3suckp0e" as Address,
|
||||
amount: {
|
||||
quantity: "887878484",
|
||||
tokenTicker: "ASH" as TokenTicker,
|
||||
tokenTicker: "HASH" as TokenTicker,
|
||||
fractionalDigits: 5,
|
||||
},
|
||||
memo: defaultMemo,
|
||||
|
||||
@@ -53,17 +53,17 @@ describe("encode", () => {
|
||||
{
|
||||
contractAddress: "cosmos18vd8fpwxzck93qlwghaj6arh4p7c5n89uzcee5",
|
||||
fractionalDigits: 5,
|
||||
ticker: "ASH",
|
||||
ticker: "HASH",
|
||||
},
|
||||
{
|
||||
contractAddress: "cosmos1hqrdl6wstt8qzshwc6mrumpjk9338k0lr4dqxd",
|
||||
fractionalDigits: 0,
|
||||
ticker: "BASH",
|
||||
ticker: "ISA",
|
||||
},
|
||||
{
|
||||
contractAddress: "cosmos18r5szma8hm93pvx6lwpjwyxruw27e0k5uw835c",
|
||||
fractionalDigits: 18,
|
||||
ticker: "CASH",
|
||||
ticker: "JADE",
|
||||
},
|
||||
];
|
||||
|
||||
@@ -83,7 +83,7 @@ describe("encode", () => {
|
||||
const amount: Amount = {
|
||||
quantity: "789",
|
||||
fractionalDigits: 0,
|
||||
tokenTicker: "BASH" as TokenTicker,
|
||||
tokenTicker: "ISA" as TokenTicker,
|
||||
};
|
||||
expect(toErc20Amount(amount, bash)).toEqual("789");
|
||||
});
|
||||
@@ -92,7 +92,7 @@ describe("encode", () => {
|
||||
const amount: Amount = {
|
||||
quantity: "789",
|
||||
fractionalDigits: 0,
|
||||
tokenTicker: "BASH" as TokenTicker,
|
||||
tokenTicker: "ISA" as TokenTicker,
|
||||
};
|
||||
expect(() => toErc20Amount(amount, ash)).toThrowError(/ticker mismatch/i);
|
||||
});
|
||||
@@ -101,7 +101,7 @@ describe("encode", () => {
|
||||
const amount: Amount = {
|
||||
quantity: "789",
|
||||
fractionalDigits: 2,
|
||||
tokenTicker: "BASH" as TokenTicker,
|
||||
tokenTicker: "ISA" as TokenTicker,
|
||||
};
|
||||
expect(() => toErc20Amount(amount, bash)).toThrowError(/fractional digits mismatch/i);
|
||||
});
|
||||
@@ -298,7 +298,7 @@ describe("encode", () => {
|
||||
amount: {
|
||||
fractionalDigits: 0,
|
||||
quantity: "345",
|
||||
tokenTicker: "BASH" as TokenTicker,
|
||||
tokenTicker: "ISA" as TokenTicker,
|
||||
},
|
||||
fee: {
|
||||
tokens: {
|
||||
|
||||
@@ -116,7 +116,7 @@ situation is different.
|
||||
```
|
||||
curl --header "Content-Type: application/json" \
|
||||
--request POST \
|
||||
--data '{"ticker":"BASH","address":"cosmos1yre6ac7qfgyfgvh58ph0rgw627rhw766y430qq"}' \
|
||||
--data '{"ticker":"ISA","address":"cosmos1yre6ac7qfgyfgvh58ph0rgw627rhw766y430qq"}' \
|
||||
http://localhost:8000/credit
|
||||
```
|
||||
|
||||
|
||||
@@ -2,26 +2,26 @@ import { RequestParser } from "./requestparser";
|
||||
|
||||
describe("RequestParser", () => {
|
||||
it("can process valid credit request", () => {
|
||||
const body = { address: "abc", ticker: "CASH" };
|
||||
expect(RequestParser.parseCreditBody(body)).toEqual({ address: "abc", ticker: "CASH" });
|
||||
const body = { address: "abc", ticker: "TKN" };
|
||||
expect(RequestParser.parseCreditBody(body)).toEqual({ address: "abc", ticker: "TKN" });
|
||||
});
|
||||
|
||||
it("throws for invalid credit requests", () => {
|
||||
// address unset
|
||||
{
|
||||
const body = { ticker: "CASH" };
|
||||
const body = { ticker: "TKN" };
|
||||
expect(() => RequestParser.parseCreditBody(body)).toThrowError(/Property 'address' must be a string/i);
|
||||
}
|
||||
|
||||
// address wrong type
|
||||
{
|
||||
const body = { address: true, ticker: "CASH" };
|
||||
const body = { address: true, ticker: "TKN" };
|
||||
expect(() => RequestParser.parseCreditBody(body)).toThrowError(/Property 'address' must be a string/i);
|
||||
}
|
||||
|
||||
// address empty
|
||||
{
|
||||
const body = { address: "", ticker: "CASH" };
|
||||
const body = { address: "", ticker: "TKN" };
|
||||
expect(() => RequestParser.parseCreditBody(body)).toThrowError(/Property 'address' must not be empty/i);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,8 +27,8 @@ export const developmentTokenConfig: TokenConfiguration = {
|
||||
{
|
||||
contractAddress: "cosmos1hqrdl6wstt8qzshwc6mrumpjk9338k0lr4dqxd",
|
||||
fractionalDigits: 0,
|
||||
ticker: "BASH",
|
||||
name: "Bash Token",
|
||||
ticker: "ISA",
|
||||
name: "Isa Token",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
@@ -35,8 +35,8 @@ const defaultConfig: TokenConfiguration = {
|
||||
{
|
||||
contractAddress: "cosmos1hqrdl6wstt8qzshwc6mrumpjk9338k0lr4dqxd",
|
||||
fractionalDigits: 0,
|
||||
ticker: "BASH",
|
||||
name: "Bash Token",
|
||||
ticker: "ISA",
|
||||
name: "Isa Token",
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -112,7 +112,7 @@ describe("Faucet", () => {
|
||||
amount: {
|
||||
quantity: "7",
|
||||
fractionalDigits: 0,
|
||||
tokenTicker: "BASH" as TokenTicker,
|
||||
tokenTicker: "ISA" as TokenTicker,
|
||||
},
|
||||
sender: holder,
|
||||
recipient: recipient,
|
||||
@@ -123,7 +123,7 @@ describe("Faucet", () => {
|
||||
{
|
||||
quantity: "7",
|
||||
fractionalDigits: 0,
|
||||
tokenTicker: "BASH" as TokenTicker,
|
||||
tokenTicker: "ISA" as TokenTicker,
|
||||
},
|
||||
]);
|
||||
connection.disconnect();
|
||||
@@ -140,21 +140,21 @@ 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,
|
||||
}),
|
||||
jasmine.objectContaining({
|
||||
tokenTicker: "ISA",
|
||||
fractionalDigits: 0,
|
||||
}),
|
||||
jasmine.objectContaining({
|
||||
tokenTicker: "STAKE",
|
||||
fractionalDigits: 6,
|
||||
}),
|
||||
]);
|
||||
expect(Number.parseInt(distributorBalance[0].quantity, 10)).toBeGreaterThanOrEqual(80);
|
||||
expect(Number.parseInt(distributorBalance[1].quantity, 10)).toBeGreaterThanOrEqual(80_000000);
|
||||
expect(Number.parseInt(distributorBalance[0].quantity, 10)).toBeGreaterThanOrEqual(80_000000);
|
||||
expect(Number.parseInt(distributorBalance[1].quantity, 10)).toBeGreaterThanOrEqual(80);
|
||||
expect(Number.parseInt(distributorBalance[2].quantity, 10)).toBeGreaterThanOrEqual(80_000000);
|
||||
connection.disconnect();
|
||||
});
|
||||
@@ -207,7 +207,7 @@ describe("Faucet", () => {
|
||||
const { profile } = await makeProfile();
|
||||
const faucet = new Faucet(defaultConfig, connection, codec, profile);
|
||||
const tickers = await faucet.loadTokenTickers();
|
||||
expect(tickers).toEqual(["BASH", "COSM", "STAKE"]);
|
||||
expect(tickers).toEqual(["COSM", "ISA", "STAKE"]);
|
||||
connection.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -26,11 +26,11 @@ describe("multichainhelpers", () => {
|
||||
{
|
||||
quantity: "1",
|
||||
fractionalDigits: 9,
|
||||
tokenTicker: "CASH" as TokenTicker,
|
||||
tokenTicker: "JADE" as TokenTicker,
|
||||
},
|
||||
],
|
||||
});
|
||||
expect(tickers).toEqual(["CASH"]);
|
||||
expect(tickers).toEqual(["JADE"]);
|
||||
});
|
||||
|
||||
it("works for two tokens", () => {
|
||||
@@ -41,7 +41,7 @@ describe("multichainhelpers", () => {
|
||||
{
|
||||
quantity: "1",
|
||||
fractionalDigits: 9,
|
||||
tokenTicker: "CASH" as TokenTicker,
|
||||
tokenTicker: "JADE" as TokenTicker,
|
||||
},
|
||||
{
|
||||
quantity: "1",
|
||||
@@ -50,7 +50,7 @@ describe("multichainhelpers", () => {
|
||||
},
|
||||
],
|
||||
});
|
||||
expect(tickers).toEqual(["CASH", "TRASH"]);
|
||||
expect(tickers).toEqual(["JADE", "TRASH"]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user