Skip to content

Commit

Permalink
Add codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
josefleventon committed Feb 25, 2023
1 parent 37ded4a commit 8010672
Show file tree
Hide file tree
Showing 5 changed files with 3,866 additions and 0 deletions.
63 changes: 63 additions & 0 deletions ts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
build/

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test
.env.production

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
35 changes: 35 additions & 0 deletions ts/codegen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import codegen from '@cosmwasm/ts-codegen'

codegen({
contracts: [
{
name: 'Wager',
dir: '../schema',
},
],
outPath: './types/',

// options are completely optional ;)
options: {
bundle: {
enabled: false,
},
types: {
enabled: true,
},
client: {
enabled: true,
},
reactQuery: {
enabled: false,
},
recoil: {
enabled: false,
},
messageComposer: {
enabled: true,
},
},
}).then(() => {
console.log('✨ all done!')
})
24 changes: 24 additions & 0 deletions ts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "@pixelwizards/types",
"version": "2.0.0",
"description": "Pixel Wizards Wager CosmWasm Typescript Types",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"codegen": "ts-node codegen.ts"
},
"license": "Apache-2.0",
"dependencies": {
"@cosmjs/amino": "0.29.1",
"@cosmjs/cosmwasm-stargate": "^0.29.1",
"@cosmjs/encoding": "0.29.1",
"@cosmjs/proto-signing": "0.29.1",
"@cosmjs/stargate": "0.29.1",
"@cosmjs/tendermint-rpc": "^0.29.1",
"@cosmwasm/ts-codegen": "^0.19.0",
"cosmjs-types": "^0.5.1",
"cosmwasm": "1.1.1",
"ts-node": "^10.9.1",
"typescript": "^4.8.4"
}
}
114 changes: 114 additions & 0 deletions ts/types/Wager.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/**
* This file was automatically generated by @cosmwasm/ts-codegen@0.19.0.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/

export type Uint128 = string;
export interface InstantiateMsg {
amounts: Uint128[];
collection_address: string;
expiries: number[];
fairburn_bps: number;
fee_address: string;
fee_bps: number;
matchmaking_expiry: number;
max_currencies: number;
}
export type ExecuteMsg = {
update_config: {
params: ParamInfo;
};
} | {
set_winner: {
wager_key: [[Addr, number], [Addr, number]];
winner: [Addr, number];
};
} | {
wager: {
against_currencies: Currency[];
currency: Currency;
expiry: number;
token: [Addr, number];
};
} | {
cancel: {
token: [Addr, number];
};
};
export type Addr = string;
export type Currency = "d_o_t" | "a_v_a_x" | "u_n_i" | "a_t_o_m" | "l_i_n_k" | "n_e_a_r" | "i_c_p" | "s_a_n_d" | "b_t_c" | "e_t_h" | "b_n_b" | "x_r_p" | "a_d_a" | "d_o_g_e" | "s_o_l" | "m_a_n_a" | "c_a_k_e" | "a_r" | "o_s_m_o" | "r_u_n_e" | "l_u_n_a" | "u_s_t_c" | "s_t_a_r_s" | "m_i_r";
export interface ParamInfo {
amounts?: Uint128[] | null;
collection_address?: string | null;
expiries?: number[] | null;
fairburn_bps?: number | null;
fee_address?: string | null;
fee_bps?: number | null;
matchmaking_expiry?: number | null;
max_currencies?: number | null;
}
export type QueryMsg = {
wagers: {};
} | {
wager: {
token: [Addr, number];
};
} | {
token_status: {
token: [Addr, number];
};
} | {
config: {};
};
export type Decimal = string;
export interface ConfigResponse {
config: Config;
}
export interface Config {
amounts: Uint128[];
collection_address: Addr;
expiries: number[];
fairburn_percent: Decimal;
fee_address: Addr;
fee_percent: Decimal;
matchmaking_expiry: number;
max_currencies: number;
}
export type TokenStatus = "none" | {
matchmaking: MatchmakingItemExport;
} | {
wager: WagerExport;
};
export type Timestamp = Uint64;
export type Uint64 = string;
export interface TokenStatusResponse {
token_status: TokenStatus;
}
export interface MatchmakingItemExport {
against_currencies: Currency[];
amount: Uint128;
currency: Currency;
expires_at: Timestamp;
expiry: number;
token: NFT;
}
export interface NFT {
collection: Addr;
token_id: number;
}
export interface WagerExport {
amount: Uint128;
expires_at: Timestamp;
wagers: [WagerInfo, WagerInfo];
}
export interface WagerInfo {
currency: Currency;
token: NFT;
}
export interface WagerResponse {
wager: WagerExport;
}
export interface WagersResponse {
wagers: WagerExport[];
}
Loading

0 comments on commit 8010672

Please sign in to comment.