BCP: Rename CosmWasm* -> Cosmos*
This commit is contained in:
parent
0d41983927
commit
d357b67d81
@ -1,7 +1,7 @@
|
||||
import { PostableBytes, PrehashType } from "@iov/bcp";
|
||||
import { Encoding } from "@iov/encoding";
|
||||
|
||||
import { CosmWasmCodec } from "./cosmwasmcodec";
|
||||
import { CosmosCodec } from "./cosmwasmcodec";
|
||||
import { chainId, nonce, sendTxJson, signedTxBin, signedTxEncodedJson, signedTxJson } from "./testdata.spec";
|
||||
import { BankToken } from "./types";
|
||||
|
||||
@ -17,8 +17,8 @@ const defaultBankTokens: readonly BankToken[] = [
|
||||
},
|
||||
];
|
||||
|
||||
describe("CosmWasmCodec", () => {
|
||||
const codec = new CosmWasmCodec(defaultPrefix, defaultBankTokens);
|
||||
describe("CosmosCodec", () => {
|
||||
const codec = new CosmosCodec(defaultPrefix, defaultBankTokens);
|
||||
|
||||
describe("isValidAddress", () => {
|
||||
it("accepts valid addresses", () => {
|
||||
|
||||
@ -22,7 +22,7 @@ import { parseSignedTx } from "./decode";
|
||||
import { buildSignedTx, buildUnsignedTx } from "./encode";
|
||||
import { BankToken, nonceToAccountNumber, nonceToSequence } from "./types";
|
||||
|
||||
export class CosmWasmCodec implements TxCodec {
|
||||
export class CosmosCodec implements TxCodec {
|
||||
private readonly addressPrefix: string;
|
||||
private readonly bankTokens: readonly BankToken[];
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ import { HdPaths, Secp256k1HdWallet, UserProfile } from "@iov/keycontrol";
|
||||
import { assert } from "@iov/utils";
|
||||
import BN from "bn.js";
|
||||
|
||||
import { CosmWasmConnection, TokenConfiguration } from "./cosmwasmconnection";
|
||||
import { CosmosConnection, TokenConfiguration } from "./cosmwasmconnection";
|
||||
import { encodeFullSignature } from "./encode";
|
||||
import * as testdata from "./testdata.spec";
|
||||
|
||||
@ -67,7 +67,7 @@ const bob = {
|
||||
address: "cosmos1hsm76p4ahyhl5yh3ve9ur49r5kemhp2r0dcjvx" as Address,
|
||||
};
|
||||
|
||||
describe("CosmWasmConnection", () => {
|
||||
describe("CosmosConnection", () => {
|
||||
const cosm = "COSM" as TokenTicker;
|
||||
const httpUrl = "http://localhost:1317";
|
||||
const defaultChainId = "cosmos:testing" as ChainId;
|
||||
@ -119,7 +119,7 @@ describe("CosmWasmConnection", () => {
|
||||
describe("establish", () => {
|
||||
it("can connect to Cosmos via http", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const connection = await CosmWasmConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const connection = await CosmosConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
expect(connection).toBeTruthy();
|
||||
connection.disconnect();
|
||||
});
|
||||
@ -128,7 +128,7 @@ describe("CosmWasmConnection", () => {
|
||||
describe("chainId", () => {
|
||||
it("displays the chain ID", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const connection = await CosmWasmConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const connection = await CosmosConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
expect(connection.chainId).toEqual(defaultChainId);
|
||||
connection.disconnect();
|
||||
});
|
||||
@ -137,7 +137,7 @@ describe("CosmWasmConnection", () => {
|
||||
describe("height", () => {
|
||||
it("displays the current height", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const connection = await CosmWasmConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const connection = await CosmosConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const height = await connection.height();
|
||||
expect(height).toBeGreaterThan(0);
|
||||
connection.disconnect();
|
||||
@ -147,7 +147,7 @@ describe("CosmWasmConnection", () => {
|
||||
describe("getToken", () => {
|
||||
it("displays a given token", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const connection = await CosmWasmConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const connection = await CosmosConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const token = await connection.getToken("COSM" as TokenTicker);
|
||||
expect(token).toEqual({
|
||||
fractionalDigits: 6,
|
||||
@ -159,7 +159,7 @@ describe("CosmWasmConnection", () => {
|
||||
|
||||
it("resolves to undefined if the token is not supported", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const connection = await CosmWasmConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const connection = await CosmosConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const token = await connection.getToken("whatever" as TokenTicker);
|
||||
expect(token).toBeUndefined();
|
||||
connection.disconnect();
|
||||
@ -169,7 +169,7 @@ describe("CosmWasmConnection", () => {
|
||||
describe("getAllTokens", () => {
|
||||
it("resolves to a list of all supported tokens", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const connection = await CosmWasmConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const connection = await CosmosConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const tokens = await connection.getAllTokens();
|
||||
expect(tokens).toEqual([
|
||||
{
|
||||
@ -190,7 +190,7 @@ describe("CosmWasmConnection", () => {
|
||||
describe("identifier", () => {
|
||||
it("calculates tx hash from PostableBytes", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const connection = await CosmWasmConnection.establish(httpUrl, defaultAddressPrefix, atomConfig);
|
||||
const connection = await CosmosConnection.establish(httpUrl, defaultAddressPrefix, atomConfig);
|
||||
const id = await connection.identifier(testdata.signedTxJson);
|
||||
expect(id).toMatch(/^[0-9A-F]{64}$/);
|
||||
expect(id).toEqual(testdata.txId);
|
||||
@ -200,7 +200,7 @@ describe("CosmWasmConnection", () => {
|
||||
describe("getAccount", () => {
|
||||
it("gets an empty account by address", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const connection = await CosmWasmConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const connection = await CosmosConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const account = await connection.getAccount({ address: defaultEmptyAddress });
|
||||
expect(account).toBeUndefined();
|
||||
connection.disconnect();
|
||||
@ -208,7 +208,7 @@ describe("CosmWasmConnection", () => {
|
||||
|
||||
it("gets an account by address", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const connection = await CosmWasmConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const connection = await CosmosConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const account = await connection.getAccount({ address: unusedAccount.address });
|
||||
assert(account, "Account must be defined");
|
||||
expect(account.address).toEqual(unusedAccount.address);
|
||||
@ -230,7 +230,7 @@ describe("CosmWasmConnection", () => {
|
||||
|
||||
it("gets an account by pubkey", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const connection = await CosmWasmConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const connection = await CosmosConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const byAddress = await connection.getAccount({ address: unusedAccount.address });
|
||||
const byPubkey = await connection.getAccount({ pubkey: unusedAccount.pubkey });
|
||||
expect(byPubkey).toEqual(byAddress); // above we verified that by address works as expected
|
||||
@ -239,7 +239,7 @@ describe("CosmWasmConnection", () => {
|
||||
|
||||
it("has a pubkey when getting account with transactions", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const connection = await CosmWasmConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const connection = await CosmosConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const account = await connection.getAccount({ address: faucet.address });
|
||||
expect(account?.pubkey).toEqual(faucet.pubkey);
|
||||
connection.disconnect();
|
||||
@ -253,7 +253,7 @@ describe("CosmWasmConnection", () => {
|
||||
const events = new Array<Account | undefined>();
|
||||
|
||||
(async () => {
|
||||
const connection = await CosmWasmConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const connection = await CosmosConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const subscription = connection.watchAccount({ address: recipient }).subscribe({
|
||||
next: (event) => {
|
||||
events.push(event);
|
||||
@ -313,7 +313,7 @@ describe("CosmWasmConnection", () => {
|
||||
describe("getTx", () => {
|
||||
it("can get a recently posted bank send transaction", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const connection = await CosmWasmConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const connection = await CosmosConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const profile = new UserProfile();
|
||||
const wallet = profile.addWallet(Secp256k1HdWallet.fromMnemonic(bob.mnemonic));
|
||||
const senderIdentity = await profile.createIdentity(wallet.id, defaultChainId, bob.path);
|
||||
@ -364,7 +364,7 @@ describe("CosmWasmConnection", () => {
|
||||
|
||||
it("can get an old transaction", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const connection = await CosmWasmConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const connection = await CosmosConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
|
||||
const results = await connection.searchTx({ sentFromOrTo: bob.address });
|
||||
const firstSearchResult = results.find(() => true);
|
||||
@ -405,7 +405,7 @@ describe("CosmWasmConnection", () => {
|
||||
|
||||
it("throws for non-existent transaction", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const connection = await CosmWasmConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const connection = await CosmosConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
|
||||
const nonExistentId = "0000000000000000000000000000000000000000000000000000000000000000" as TransactionId;
|
||||
await connection.getTx(nonExistentId).then(
|
||||
@ -420,7 +420,7 @@ describe("CosmWasmConnection", () => {
|
||||
describe("searchTx", () => {
|
||||
it("can post and search for a transaction", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const connection = await CosmWasmConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const connection = await CosmosConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const profile = new UserProfile();
|
||||
const wallet = profile.addWallet(Secp256k1HdWallet.fromMnemonic(bob.mnemonic));
|
||||
const sender = await profile.createIdentity(wallet.id, defaultChainId, bob.path);
|
||||
@ -510,7 +510,7 @@ describe("CosmWasmConnection", () => {
|
||||
|
||||
it("can search by minHeight and maxHeight", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const connection = await CosmWasmConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const connection = await CosmosConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const profile = new UserProfile();
|
||||
const wallet = profile.addWallet(Secp256k1HdWallet.fromMnemonic(bob.mnemonic));
|
||||
const sender = await profile.createIdentity(wallet.id, defaultChainId, bob.path);
|
||||
@ -721,7 +721,7 @@ describe("CosmWasmConnection", () => {
|
||||
pendingWithoutWasmd();
|
||||
|
||||
(async () => {
|
||||
const connection = await CosmWasmConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const connection = await CosmosConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
|
||||
const profile = new UserProfile();
|
||||
const wallet = profile.addWallet(Secp256k1HdWallet.fromMnemonic(bob.mnemonic));
|
||||
@ -804,7 +804,7 @@ describe("CosmWasmConnection", () => {
|
||||
pendingWithoutWasmd();
|
||||
|
||||
(async () => {
|
||||
const connection = await CosmWasmConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const connection = await CosmosConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
|
||||
const profile = new UserProfile();
|
||||
const wallet = profile.addWallet(Secp256k1HdWallet.fromMnemonic(bob.mnemonic));
|
||||
@ -854,7 +854,7 @@ describe("CosmWasmConnection", () => {
|
||||
pendingWithoutWasmd();
|
||||
|
||||
(async () => {
|
||||
const connection = await CosmWasmConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const connection = await CosmosConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
|
||||
const profile = new UserProfile();
|
||||
const wallet = profile.addWallet(Secp256k1HdWallet.fromMnemonic(bob.mnemonic));
|
||||
|
||||
@ -43,7 +43,7 @@ import { Producer, Stream } from "xstream";
|
||||
|
||||
import { pubkeyToAddress } from "./address";
|
||||
import { Caip5 } from "./caip5";
|
||||
import { CosmWasmCodec } from "./cosmwasmcodec";
|
||||
import { CosmosCodec } from "./cosmwasmcodec";
|
||||
import { decodeAmount, decodePubkey, parseTxsResponseSigned, parseTxsResponseUnsigned } from "./decode";
|
||||
import { buildSignedTx } from "./encode";
|
||||
import { accountToNonce, BankToken } from "./types";
|
||||
@ -82,16 +82,16 @@ function compareByHeightAndHash(a: IndexedTx, b: IndexedTx): number {
|
||||
/** Account and undefined are valid events. The third option means no event fired yet */
|
||||
type LastWatchAccountEvent = Account | undefined | "no_event_fired_yet";
|
||||
|
||||
export class CosmWasmConnection implements BlockchainConnection {
|
||||
export class CosmosConnection implements BlockchainConnection {
|
||||
// we must know prefix and tokens a priori to understand the chain
|
||||
public static async establish(
|
||||
url: string,
|
||||
addressPrefix: string,
|
||||
tokens: TokenConfiguration,
|
||||
): Promise<CosmWasmConnection> {
|
||||
): Promise<CosmosConnection> {
|
||||
const cosmosClient = new CosmosClient(url);
|
||||
const chainData = await this.initialize(cosmosClient);
|
||||
return new CosmWasmConnection(cosmosClient, chainData, addressPrefix, tokens);
|
||||
return new CosmosConnection(cosmosClient, chainData, addressPrefix, tokens);
|
||||
}
|
||||
|
||||
private static async initialize(cosmosClient: CosmosClient): Promise<ChainId> {
|
||||
@ -118,7 +118,7 @@ export class CosmWasmConnection implements BlockchainConnection {
|
||||
) {
|
||||
this.cosmosClient = cosmosClient;
|
||||
this.chainId = chainId;
|
||||
this.codec = new CosmWasmCodec(addressPrefix, tokens.bankTokens);
|
||||
this.codec = new CosmosCodec(addressPrefix, tokens.bankTokens);
|
||||
this.addressPrefix = addressPrefix;
|
||||
this.bankTokens = tokens.bankTokens;
|
||||
this.feeToken = this.bankTokens.find(() => true);
|
||||
@ -148,7 +148,7 @@ export class CosmWasmConnection implements BlockchainConnection {
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a replacement for the unimplemented CosmWasmCodec.identifier. Here we have more
|
||||
* This is a replacement for the unimplemented CosmosCodec.identifier. Here we have more
|
||||
* context and network available, which we might use to implement the API in an async way.
|
||||
*/
|
||||
public async identifier(signed: SignedTransaction): Promise<TransactionId> {
|
||||
|
||||
@ -1,20 +1,20 @@
|
||||
import { ChainConnector, ChainId } from "@iov/bcp";
|
||||
|
||||
import { CosmWasmCodec } from "./cosmwasmcodec";
|
||||
import { CosmWasmConnection, TokenConfiguration } from "./cosmwasmconnection";
|
||||
import { CosmosCodec } from "./cosmwasmcodec";
|
||||
import { CosmosConnection, TokenConfiguration } from "./cosmwasmconnection";
|
||||
|
||||
/**
|
||||
* A helper to connect to a cosmos-based chain at a given url
|
||||
*/
|
||||
export function createCosmWasmConnector(
|
||||
export function createCosmosConnector(
|
||||
url: string,
|
||||
addressPrefix: string,
|
||||
tokenConfig: TokenConfiguration,
|
||||
expectedChainId?: ChainId,
|
||||
): ChainConnector<CosmWasmConnection> {
|
||||
const codec = new CosmWasmCodec(addressPrefix, tokenConfig.bankTokens);
|
||||
): ChainConnector<CosmosConnection> {
|
||||
const codec = new CosmosCodec(addressPrefix, tokenConfig.bankTokens);
|
||||
return {
|
||||
establishConnection: async () => CosmWasmConnection.establish(url, addressPrefix, tokenConfig),
|
||||
establishConnection: async () => CosmosConnection.establish(url, addressPrefix, tokenConfig),
|
||||
codec: codec,
|
||||
expectedChainId: expectedChainId,
|
||||
};
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
export { CosmWasmCodec } from "./cosmwasmcodec";
|
||||
export { CosmWasmConnection, TokenConfiguration } from "./cosmwasmconnection";
|
||||
export { createCosmWasmConnector } from "./cosmwasmconnector";
|
||||
export { CosmosCodec } from "./cosmwasmcodec";
|
||||
export { CosmosConnection, TokenConfiguration } from "./cosmwasmconnection";
|
||||
export { createCosmosConnector } from "./cosmwasmconnector";
|
||||
export { BankToken } from "./types";
|
||||
|
||||
2
packages/bcp/types/cosmwasmcodec.d.ts
vendored
2
packages/bcp/types/cosmwasmcodec.d.ts
vendored
@ -11,7 +11,7 @@ import {
|
||||
UnsignedTransaction,
|
||||
} from "@iov/bcp";
|
||||
import { BankToken } from "./types";
|
||||
export declare class CosmWasmCodec implements TxCodec {
|
||||
export declare class CosmosCodec implements TxCodec {
|
||||
private readonly addressPrefix;
|
||||
private readonly bankTokens;
|
||||
constructor(addressPrefix: string, bankTokens: readonly BankToken[]);
|
||||
|
||||
10
packages/bcp/types/cosmwasmconnection.d.ts
vendored
10
packages/bcp/types/cosmwasmconnection.d.ts
vendored
@ -31,12 +31,8 @@ export interface TokenConfiguration {
|
||||
}
|
||||
>;
|
||||
}
|
||||
export declare class CosmWasmConnection implements BlockchainConnection {
|
||||
static establish(
|
||||
url: string,
|
||||
addressPrefix: string,
|
||||
tokens: TokenConfiguration,
|
||||
): Promise<CosmWasmConnection>;
|
||||
export declare class CosmosConnection implements BlockchainConnection {
|
||||
static establish(url: string, addressPrefix: string, tokens: TokenConfiguration): Promise<CosmosConnection>;
|
||||
private static initialize;
|
||||
readonly chainId: ChainId;
|
||||
readonly codec: TxCodec;
|
||||
@ -51,7 +47,7 @@ export declare class CosmWasmConnection implements BlockchainConnection {
|
||||
getToken(searchTicker: TokenTicker): Promise<Token | undefined>;
|
||||
getAllTokens(): Promise<readonly Token[]>;
|
||||
/**
|
||||
* This is a replacement for the unimplemented CosmWasmCodec.identifier. Here we have more
|
||||
* This is a replacement for the unimplemented CosmosCodec.identifier. Here we have more
|
||||
* context and network available, which we might use to implement the API in an async way.
|
||||
*/
|
||||
identifier(signed: SignedTransaction): Promise<TransactionId>;
|
||||
|
||||
6
packages/bcp/types/cosmwasmconnector.d.ts
vendored
6
packages/bcp/types/cosmwasmconnector.d.ts
vendored
@ -1,11 +1,11 @@
|
||||
import { ChainConnector, ChainId } from "@iov/bcp";
|
||||
import { CosmWasmConnection, TokenConfiguration } from "./cosmwasmconnection";
|
||||
import { CosmosConnection, TokenConfiguration } from "./cosmwasmconnection";
|
||||
/**
|
||||
* A helper to connect to a cosmos-based chain at a given url
|
||||
*/
|
||||
export declare function createCosmWasmConnector(
|
||||
export declare function createCosmosConnector(
|
||||
url: string,
|
||||
addressPrefix: string,
|
||||
tokenConfig: TokenConfiguration,
|
||||
expectedChainId?: ChainId,
|
||||
): ChainConnector<CosmWasmConnection>;
|
||||
): ChainConnector<CosmosConnection>;
|
||||
|
||||
6
packages/bcp/types/index.d.ts
vendored
6
packages/bcp/types/index.d.ts
vendored
@ -1,4 +1,4 @@
|
||||
export { CosmWasmCodec } from "./cosmwasmcodec";
|
||||
export { CosmWasmConnection, TokenConfiguration } from "./cosmwasmconnection";
|
||||
export { createCosmWasmConnector } from "./cosmwasmconnector";
|
||||
export { CosmosCodec } from "./cosmwasmcodec";
|
||||
export { CosmosConnection, TokenConfiguration } from "./cosmwasmconnection";
|
||||
export { createCosmosConnector } from "./cosmwasmconnector";
|
||||
export { BankToken } from "./types";
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { createCosmWasmConnector } from "@cosmwasm/bcp";
|
||||
import { createCosmosConnector } from "@cosmwasm/bcp";
|
||||
|
||||
import { Webserver } from "../../api/webserver";
|
||||
import * as constants from "../../constants";
|
||||
@ -16,7 +16,7 @@ export async function start(args: ReadonlyArray<string>): Promise<void> {
|
||||
|
||||
// Connection
|
||||
const blockchainBaseUrl = args[0];
|
||||
const connector = createCosmWasmConnector(
|
||||
const connector = createCosmosConnector(
|
||||
blockchainBaseUrl,
|
||||
constants.addressPrefix,
|
||||
constants.developmentTokenConfig,
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import { CosmWasmCodec } from "@cosmwasm/bcp";
|
||||
import { CosmosCodec } from "@cosmwasm/bcp";
|
||||
import { Address, Identity, TxCodec } from "@iov/bcp";
|
||||
|
||||
import * as constants from "./constants";
|
||||
|
||||
const noTokensCodec: Pick<TxCodec, "identityToAddress" | "isValidAddress"> = new CosmWasmCodec(
|
||||
const noTokensCodec: Pick<TxCodec, "identityToAddress" | "isValidAddress"> = new CosmosCodec(
|
||||
constants.addressPrefix,
|
||||
[],
|
||||
);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { CosmWasmCodec, CosmWasmConnection, TokenConfiguration } from "@cosmwasm/bcp";
|
||||
import { CosmosCodec, CosmosConnection, TokenConfiguration } from "@cosmwasm/bcp";
|
||||
import { Address, ChainId, Identity, TokenTicker } from "@iov/bcp";
|
||||
import { Random } from "@iov/crypto";
|
||||
import { Bech32 } from "@iov/encoding";
|
||||
@ -33,7 +33,7 @@ const defaultConfig: TokenConfiguration = {
|
||||
};
|
||||
const defaultAddressPrefix = "cosmos";
|
||||
const defaultChainId = "cosmos:testing" as ChainId;
|
||||
const codec = new CosmWasmCodec(defaultAddressPrefix, defaultConfig.bankTokens);
|
||||
const codec = new CosmosCodec(defaultAddressPrefix, defaultConfig.bankTokens);
|
||||
|
||||
function makeRandomAddress(): Address {
|
||||
return Bech32.encode(defaultAddressPrefix, Random.getBytes(20)) as Address;
|
||||
@ -57,7 +57,7 @@ describe("Faucet", () => {
|
||||
describe("constructor", () => {
|
||||
it("can be constructed", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const connection = await CosmWasmConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const connection = await CosmosConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const { profile } = await makeProfile();
|
||||
const faucet = new Faucet(defaultConfig, connection, codec, profile);
|
||||
expect(faucet).toBeTruthy();
|
||||
@ -68,7 +68,7 @@ describe("Faucet", () => {
|
||||
describe("send", () => {
|
||||
it("can send bank token", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const connection = await CosmWasmConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const connection = await CosmosConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const { profile, holder } = await makeProfile();
|
||||
const faucet = new Faucet(defaultConfig, connection, codec, profile);
|
||||
const recipient = makeRandomAddress();
|
||||
@ -97,7 +97,7 @@ describe("Faucet", () => {
|
||||
describe("refill", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const connection = await CosmWasmConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const connection = await CosmosConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const { profile, distributors } = await makeProfile(1);
|
||||
const faucet = new Faucet(defaultConfig, connection, codec, profile);
|
||||
await faucet.refill();
|
||||
@ -122,7 +122,7 @@ describe("Faucet", () => {
|
||||
describe("credit", () => {
|
||||
it("works for fee token", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const connection = await CosmWasmConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const connection = await CosmosConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const { profile } = await makeProfile(1);
|
||||
const faucet = new Faucet(defaultConfig, connection, codec, profile);
|
||||
const recipient = makeRandomAddress();
|
||||
@ -141,7 +141,7 @@ describe("Faucet", () => {
|
||||
|
||||
it("works for stake token", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const connection = await CosmWasmConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const connection = await CosmosConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const { profile } = await makeProfile(1);
|
||||
const faucet = new Faucet(defaultConfig, connection, codec, profile);
|
||||
const recipient = makeRandomAddress();
|
||||
@ -162,7 +162,7 @@ describe("Faucet", () => {
|
||||
describe("loadTokenTickers", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const connection = await CosmWasmConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const connection = await CosmosConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const { profile } = await makeProfile();
|
||||
const faucet = new Faucet(defaultConfig, connection, codec, profile);
|
||||
const tickers = await faucet.loadTokenTickers();
|
||||
@ -174,7 +174,7 @@ describe("Faucet", () => {
|
||||
describe("loadAccounts", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const connection = await CosmWasmConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const connection = await CosmosConnection.establish(httpUrl, defaultAddressPrefix, defaultConfig);
|
||||
const { profile, holder } = await makeProfile();
|
||||
const faucet = new Faucet(defaultConfig, connection, codec, profile);
|
||||
const accounts = await faucet.loadAccounts();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user