Skip to content

Commit

Permalink
fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
pyramation committed Apr 13, 2024
1 parent 7585a92 commit 74a6d3a
Show file tree
Hide file tree
Showing 5 changed files with 264 additions and 5 deletions.
90 changes: 90 additions & 0 deletions __fixtures__/output/assetlist.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
interface Asset {
deprecated?: boolean;
description?: string;
extended_description?: string;
denom_units: Denomunit[];
type_asset?: string;
address?: string;
base: string;
name: string;
display: string;
symbol: string;
traces?: any[];
ibc?: {
source_channel: string;
dst_channel: string;
source_denom: string;
};
logo_URIs?: {
png?: string;
svg?: string;
};
images?: {
image_sync?: Pointer;
png?: string;
svg?: string;
theme?: {
primary_color_hex?: string;
circle?: boolean;
dark_mode?: boolean;
};
}[];
coingecko_id?: string;
keywords?: string[];
socials?: {
website?: string;
twitter?: string;
};
}
interface Denomunit {
denom: string;
exponent: number;
aliases?: string[];
}
interface Pointer {
chain_name: string;
base_denom?: string;
}
interface Ibctransition {
type: string;
counterparty: {
chain_name: string;
base_denom: string;
channel_id: string;
};
chain: {
channel_id: string;
path: string;
};
}
interface Ibccw20transition {
type: string;
counterparty: {
chain_name: string;
base_denom: string;
port: string;
channel_id: string;
};
chain: {
port: string;
channel_id: string;
path: string;
};
}
interface Nonibctransition {
type: string;
counterparty: {
chain_name: string;
base_denom: string;
contract?: string;
};
chain?: {
contract: string;
};
provider: string;
}
interface Asset Lists {
$schema?: string;
chain_name: string;
assets: Asset[];
}
159 changes: 159 additions & 0 deletions __fixtures__/output/chain.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
interface Peer {
id: string;
address: string;
provider?: string;
}
interface Endpoint {
address: string;
provider?: string;
archive?: boolean;
}
interface Explorer {
kind?: string;
url?: string;
tx_page?: string;
account_page?: string;
}
interface Feetoken {
denom: string;
fixed_min_gas_price?: number;
low_gas_price?: number;
average_gas_price?: number;
high_gas_price?: number;
gas_costs?: {
cosmos_send?: number;
ibc_transfer?: number;
};
}
interface Stakingtoken {
denom: string;
}
interface Pointer {
chain_name: string;
base_denom?: string;
}
interface Cosmos Chain {
$schema?: string;
chain_name: string;
chain_id: string;
pre_fork_chain_name?: string;
pretty_name?: string;
website?: string;
update_link?: string;
status?: any;
network_type?: any;
bech32_prefix: string;
bech32_config?: {
bech32PrefixAccAddr?: string;
bech32PrefixAccPub?: string;
bech32PrefixValAddr?: string;
bech32PrefixValPub?: string;
bech32PrefixConsAddr?: string;
bech32PrefixConsPub?: string;
};
daemon_name?: string;
node_home?: string;
key_algos?: string[];
slip44?: number;
alternative_slip44s?: number[];
fees?: {
fee_tokens: Feetoken[];
};
staking?: {
staking_tokens: Stakingtoken[];
lock_duration?: {
blocks?: number;
time?: string;
};
};
codebase?: {
git_repo?: string;
recommended_version?: string;
go_version?: string;
compatible_versions?: string[];
binaries?: {
"'linux/amd64'"?: string;
"'linux/arm64'"?: string;
"'darwin/amd64'"?: string;
"'darwin/arm64'"?: string;
"'windows/amd64'"?: string;
"'windows/arm64'"?: string;
};
cosmos_sdk_version?: string;
consensus?: {
type: string;
version?: string;
};
cosmwasm_version?: string;
cosmwasm_enabled?: boolean;
cosmwasm_path?: string;
ibc_go_version?: string;
ics_enabled?: string[];
genesis?: {
name?: string;
genesis_url: string;
ics_ccv_url?: string;
};
versions?: {
name: string;
tag?: string;
height?: number;
proposal?: number;
previous_version_name?: string;
next_version_name?: string;
recommended_version?: string;
go_version?: string;
compatible_versions?: string[];
cosmos_sdk_version?: string;
consensus?: {
type: string;
version?: string;
};
cosmwasm_version?: string;
cosmwasm_enabled?: boolean;
cosmwasm_path?: string;
ibc_go_version?: string;
ics_enabled?: string[];
binaries?: {
"'linux/amd64'"?: string;
"'linux/arm64'"?: string;
"'darwin/amd64'"?: string;
"'darwin/arm64'"?: string;
"'windows/amd64'"?: string;
"'windows/arm64'"?: string;
};
}[];
};
images?: {
image_sync?: Pointer;
png?: string;
svg?: string;
theme?: {
primary_color_hex?: string;
circle?: boolean;
dark_mode?: boolean;
};
layout?: string;
text_position?: string;
}[];
logo_URIs?: {
png?: string;
svg?: string;
};
description?: string;
peers?: {
seeds?: Peer[];
persistent_peers?: Peer[];
};
apis?: {
rpc?: Endpoint[];
rest?: Endpoint[];
grpc?: Endpoint[];
wss?: Endpoint[];
"'grpc-web'"?: Endpoint[];
"'evm-http-jsonrpc'"?: Endpoint[];
};
explorers?: Explorer[];
keywords?: string[];
extra_codecs?: string[];
}
9 changes: 7 additions & 2 deletions __tests__/assetlist.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import assetlist from '../__fixtures__/schemas/assetlist.json';
import { writeFileSync } from 'fs';

import schema from '../__fixtures__/schemas/assetlist.json';
import { generateTypeScript } from '../src';

it('assetlist', () => {
expect(generateTypeScript(assetlist as any)).toMatchSnapshot();
const code = generateTypeScript(schema as any);
expect(code).toMatchSnapshot();
writeFileSync(__dirname + '/../__fixtures__/output/assetlist.ts', code);
});
9 changes: 7 additions & 2 deletions __tests__/chain.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import chain from '../__fixtures__/schemas/chain.json';
import { writeFileSync } from 'fs';

import schema from '../__fixtures__/schemas/chain.json';
import { generateTypeScript } from '../src';

it('chain', () => {
expect(generateTypeScript(chain as any)).toMatchSnapshot();
const code = generateTypeScript(schema as any);
expect(code).toMatchSnapshot();
writeFileSync(__dirname + '/../__fixtures__/output/chain.ts', code);
});
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ module.exports = {
transformIgnorePatterns: [`/node_modules/*`],
testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
modulePathIgnorePatterns: ["dist/*"]
modulePathIgnorePatterns: ["dist/*", "__fixtures__/*"]
};

0 comments on commit 74a6d3a

Please sign in to comment.