-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Generalise script for reading from production repo * Fix autogenerated code files with update script * Add auto-generated code from production repo * Add local dev coins from backend repo * Swap cosmos mock backend logic with cosmos core logic * Fix searching of state for tick pairs: frontend has no sorting context * Remove cosmos-mock generated (and semi-generated code) * Add sorted Tick arrays and keyed Ticks by ID structures both: - to handle different scenarios better: - Keyed Ticks by ID are better for isolated context updates better - Sorted arrays allow sorting only once when needed * Stop storing TickInfo indexes as they need to be updated on new info - when events come through with updates to certain ticks, indexes of all ticks will need to change * Optimise finding state pairs without knowing the sorting order * Subscribe to core backend NewDeposit and NewWithdraw shapes * Make event new totalShares calculation more understandable * Fix Query transformation of tick pools to be transformed independently * Ensure Msg requests in token are rounded to minimum denom integers * Add note about unhandled pool arrays * Handle sorting of new tick pools * Remove unused mock data of outdated format * Add JSDoc types to helper script Co-authored-by: Nick Z <nzoumis@outlook.com> * Add note about price type * Remove explicit \n chars from autogenerated code changes * Update generated code with new changes * Do not check for pool length in one direction: - pools may be empty in one direction if there is no liquidity of one of the tokens available * Fix tickState sorted pools shape on handling Events * Revert "Update generated code with new changes" This reverts commit cc08afe. * Abstract out combining old tick state new tick data * Abstract out combining old tick state new tick data, part 2: move * Rename message handler for dex module messages * Add update to tick state from NewSwap messages * Fix unsurfaced possible value is undefined error * Remove previous commit issue by replacing tick objects completely * Add PoolTicks type * Add note about possible future backend provision of totalShares * Add note about tick state optimization Co-authored-by: Nick Z <nzoumis@outlook.com>
- Loading branch information
Showing
45 changed files
with
9,320 additions
and
2,431 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import fs from 'fs'; | ||
|
||
/** | ||
* @param {string} directory | ||
* @param {{ recursive: boolean }} opts | ||
*/ | ||
function getDirFilenames(directory, opts = {}) { | ||
return fs | ||
.readdirSync(directory, { withFileTypes: true }) | ||
.reduce((result, file) => { | ||
const path = `${directory}/${file.name}`; | ||
if (opts.recursive && file.isDirectory()) { | ||
result.push(...getDirFilenames(path, opts)); | ||
} else { | ||
result.push(path); | ||
} | ||
return result; | ||
}, []); | ||
} | ||
|
||
const files = getDirFilenames('./src/lib/web3/generated', { recursive: true }); | ||
|
||
// fix ESLint and TypeScript warnings | ||
files | ||
.filter((file) => file.endsWith('/index.ts')) | ||
.forEach((file) => { | ||
const data = fs.readFileSync(file, { encoding: 'utf8' }); | ||
fs.writeFileSync( | ||
file, | ||
` | ||
/* eslint-disable */ | ||
/* tslint:disable */ | ||
${data}`.trimStart() | ||
); | ||
}); | ||
|
||
// fix TypeScript error | ||
files | ||
.filter((file) => file.endsWith('/index.ts')) | ||
.forEach((file) => { | ||
const data = fs.readFileSync(file, { encoding: 'utf8' }); | ||
const get = ` | ||
let client; | ||
if (addr) { | ||
client = await SigningStargateClient.connectWithSigner(addr, wallet, { registry }); | ||
}else{ | ||
client = await SigningStargateClient.offline( wallet, { registry }); | ||
} | ||
`; | ||
const set = ` | ||
const client = addr | ||
? await SigningStargateClient.connectWithSigner(addr, wallet, { registry }) | ||
: await SigningStargateClient.offline( wallet, { registry }); | ||
`; | ||
const replaced = data.replace(get, set); | ||
fs.writeFileSync(file, replaced); | ||
}); | ||
|
||
// fix hardcoded URLs | ||
files | ||
.filter((file) => file.endsWith('/index.ts')) | ||
.forEach((file) => { | ||
const replaced = fs | ||
.readFileSync(file, { encoding: 'utf8' }) | ||
.replace( | ||
'"http://localhost:26657"', | ||
'process.env.REACT_APP__RPC_API || ""' | ||
) | ||
.replace( | ||
'"http://localhost:1317"', | ||
'process.env.REACT_APP__REST_API || ""' | ||
); | ||
fs.writeFileSync(file, replaced); | ||
}); | ||
|
||
// remove non-module index files (eg. vuex index.ts files) | ||
files | ||
.filter( | ||
(file) => file.endsWith('/index.ts') && !file.endsWith('/module/index.ts') | ||
) | ||
.forEach((file) => { | ||
fs.rmSync(file); | ||
}); | ||
|
||
// remove vuex-root files | ||
files | ||
.filter((file) => file.endsWith('/vuex-root')) | ||
.forEach((file) => { | ||
fs.rmSync(file); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,19 @@ | ||
#!/bin/sh | ||
|
||
# use provided source path or a default | ||
DUALITY_CORE_DIRECTORY="${1:-"../duality"}" | ||
CHAIN_REPO="${1:-"duality"}" | ||
CHAIN_REPO_USER_NAME=$(echo $CHAIN_REPO | cut -d '/' -f 1) # get name part | ||
CHAIN_REPO_PROJECT_NAME=$(echo "$CHAIN_REPO" | cut -d '/' -f 2) # get name part | ||
CHAIN_REPO_PROJECT_NAME="${CHAIN_REPO_PROJECT_NAME:-$CHAIN_REPO_USER_NAME}" # default project name to copy of username if not specified | ||
CHAIN_REPO_MODULE_NAME=$(echo $CHAIN_REPO_USER_NAME | tr '[:upper:]' '[:lower:]') # get name part as lowercase of username | ||
DUALITY_CORE_DIRECTORY="${2:-"../duality"}" | ||
|
||
# copy type files | ||
cp -r "$DUALITY_CORE_DIRECTORY/vue/src/store/generated/duality/duality.duality/module/types" \ | ||
"src/lib/web3/generated/duality/duality.duality/module" | ||
|
||
# copy REST API file | ||
cp -r "$DUALITY_CORE_DIRECTORY/vue/src/store/generated/duality/duality.duality/module/rest.ts" \ | ||
"src/lib/web3/generated/duality/duality.duality/module/rest.ts" | ||
|
||
# copy version info | ||
cp -r "$DUALITY_CORE_DIRECTORY/vue/src/store/generated/duality/duality.duality/package.json" \ | ||
"src/lib/web3/generated/duality/duality.duality/package.json" | ||
# copy module files | ||
cp -r "$DUALITY_CORE_DIRECTORY/vue/src/store/generated/$CHAIN_REPO" \ | ||
"src/lib/web3/generated" | ||
|
||
# copy readme info | ||
cp -r "$DUALITY_CORE_DIRECTORY/vue/src/store/generated/readme.md" \ | ||
"src/lib/web3/generated/readme.md" | ||
|
||
node ./scripts/update-generated-files.mjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.