Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update contract #79

Merged
merged 12 commits into from
Feb 13, 2022
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ In addition, you'll create a one-time account internally during the game, which

You need Rust and Yarn.

### Setup

```
yarn install
cp common/js/src/envs/local.example.json common/js/src/envs/local.json
```

### Start chain

```
Expand All @@ -59,7 +66,6 @@ make dev

```
cd chain/scripts
yarn install
yarn seed-data:dev
```

Expand All @@ -69,6 +75,5 @@ yarn seed-data:dev

```
cd front
yarn install
yarn dev
```
2 changes: 1 addition & 1 deletion chain/pallets/game/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ pub mod pallet {
ensure_root(origin)?;

let bases = check_and_build_emo_bases(
<EmoBases<T>>::get().unwrap_or_else(emo::Bases::new),
<EmoBases<T>>::get(),
new_bases,
&fixed_base_ids,
&built_base_ids,
Expand Down
1 change: 1 addition & 0 deletions common/js/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/src/envs/local.json
23 changes: 23 additions & 0 deletions common/js/src/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import localEnv from "./envs/local.json"
import stagingEnv from "./envs/staging.json"
import productionEnv from "./envs/production.json"

type Env = typeof productionEnv
export type EnvContract = Env["contract"]

export const getEnv = (envName: any): Env => {
if (!envName) {
throw new Error(`no envName: ${envName}`)
}

switch (envName) {
case "local":
return localEnv
case "staging":
return stagingEnv
case "production":
return productionEnv
default:
throw new Error(`undefined env: ${envName}`)
}
}
26 changes: 0 additions & 26 deletions common/js/src/envs.json

This file was deleted.

8 changes: 8 additions & 0 deletions common/js/src/envs/local.example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"chainEndpoint": "ws://127.0.0.1:9944",
"contract": {
"endpoint": "ws://127.0.0.1:9988",
"storageAddress": "",
"forwarderAddress": ""
}
}
8 changes: 8 additions & 0 deletions common/js/src/envs/production.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"chainEndpoint": "wss://proto0.open-emoji-battler.community/",
"contract": {
"endpoint": "",
"storageAddress": "",
"forwarderAddress": ""
}
}
8 changes: 8 additions & 0 deletions common/js/src/envs/staging.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"chainEndpoint": "",
"contract": {
"endpoint": "",
"storageAddress": "",
"forwarderAddress": ""
}
}
1 change: 1 addition & 0 deletions common/js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export * from "./pow"
export * from "./utils"
export * from "./interfaces"
export * from "./contract"
export * from "./env"
2 changes: 1 addition & 1 deletion common/js/src/scriptUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Keyring } from "@polkadot/keyring"
import { cryptoWaitReady } from "@polkadot/util-crypto"

import { createType } from "./api"
import { getEnv } from "./utils"
import { getEnv } from "./env"

export const getChainEndpointAndKeyringPair = async (envName: string, mnemonic: string) => {
const endpoint = getEnv(envName).chainEndpoint
Expand Down
14 changes: 0 additions & 14 deletions common/js/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,6 @@ import { base64 } from "./pow/optimized.wrap"
import { getWasmSolver } from "./pow/wasm"
import * as definitions from "./interfaces/definitions"

import envs from "./envs.json"
type EnvNames = keyof typeof envs
export type EnvContract = (typeof envs)[EnvNames]["contract"]
export const getEnv = (envName: any) => {
if (!envName) {
throw new Error(`no envName: ${envName}`)
}
const env = envs[envName as EnvNames]
if (!env) {
throw new Error(`undefined env: ${envName}`)
}
return env
}

export const buildTypes = () => {
let types: RegistryTypes = {
AccountInfo: "AccountInfoWithDualRefCount",
Expand Down
1 change: 1 addition & 0 deletions common/rs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/Cargo.lock
Loading