Skip to content

Commit

Permalink
Merge pull request #913 from oraichain/feat/fix-load-position
Browse files Browse the repository at this point in the history
Feat/fix load position
  • Loading branch information
haunv3 authored Aug 10, 2024
2 parents bcb3f61 + 4b39857 commit 8f66cdf
Show file tree
Hide file tree
Showing 59 changed files with 3,747 additions and 4,548 deletions.
2 changes: 1 addition & 1 deletion codegen.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CodegenConfig } from '@graphql-codegen/cli';

// https://subql-staging.orai.io/
export const endpoint_gql = `http://10.10.20.72:3000/`;
export const endpoint_gql = `https//staging-ammv3-indexer.oraidex.io/`;
const config: CodegenConfig = {
schema: endpoint_gql,
documents: ['src/**/*.tsx'],
Expand Down
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@
"@cosmjs/stargate": "^0.31.0",
"@cosmjs/tendermint-rpc": "^0.31.0",
"@duckdb/duckdb-wasm": "1.28.0",
"@emotion/react": "^11.13.0",
"@emotion/styled": "^11.13.0",
"@injectivelabs/sdk-ts": "1.12.1",
"@leapwallet/cosmos-snap-provider": "0.1.25",
"@lucky-canvas/react": "^0.1.13",
"@mui/icons-material": "^5.16.6",
"@mui/material": "^5.16.6",
"@nivo/bar": "^0.87.0",
"@nivo/line": "^0.86.0",
"@oraichain/common-contracts-sdk": "^1.0.31",
Expand Down Expand Up @@ -58,6 +62,7 @@
"redux-persist": "^6.0.0",
"serialize-error": "8.0.0",
"tronweb": "^5.1.0",
"tss-react": "^4.9.12",
"urql": "^4.1.0"
},
"devDependencies": {
Expand Down Expand Up @@ -95,7 +100,8 @@
"stream-http": "^3.2.0",
"ts-jest": "^29.1.1",
"typed-scss-modules": "^7.1.4",
"typescript": "^5.1.6"
"typescript": "^5.1.6",
"@oraichain/oraiswap-v3": "0.1.5"
},
"scripts": {
"analyze": "source-map-explorer 'build/static/js/*.js'",
Expand Down
5 changes: 3 additions & 2 deletions src/config/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
AMM_V3_CONTRACT
} from '@oraichain/oraidex-common';

export const network: CustomChainInfo & NetworkConfig & { pool_v3: string } = {
export const network: CustomChainInfo & NetworkConfig & { pool_v3: string; indexer_v3: string } = {
...oraichainNetwork,
prefix: oraichainNetwork.bech32Config.bech32PrefixAccAddr,
denom: 'orai',
Expand All @@ -34,5 +34,6 @@ export const network: CustomChainInfo & NetworkConfig & { pool_v3: string } = {
staking_oraix: CW20_STAKING_CONTRACT,
multicall: MULTICALL_CONTRACT,
explorer: 'https://scan.orai.io',
pool_v3: AMM_V3_CONTRACT
pool_v3: AMM_V3_CONTRACT,
indexer_v3: 'https://staging-ammv3-indexer.oraidex.io/'
};
1 change: 1 addition & 0 deletions src/helper/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ export const AMOUNT_BALANCE_ENTRIES_UNIVERSAL_SWAP: [number, string, string][] =

export const DEFAULT_RELAYER_FEE = '1000000';
export const RELAYER_DECIMAL = 6;
export const DAY_IN_MILIS = 86400000;
41 changes: 1 addition & 40 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import { persistor, store } from 'store/configure';
import './index.scss';
import App from './layouts/App';
import ScrollToTop from './layouts/ScrollToTop';
import loadWasm from 'pages/Pool-V3/packages/wasm/oraiswap_v3_wasm';
import { Client, cacheExchange, fetchExchange, Provider as UrqlProvider } from 'urql';

// const client = new Client({
// url: 'http://10.10.20.72:3000/',
Expand Down Expand Up @@ -96,41 +94,4 @@ const initApp = async () => {
}
};

export interface WasmInfo {
imports: {
from: string;
names: string[];
}[];
exports: string[];
}

export async function parseWasm(wasmFilePath: string): Promise<WasmInfo> {
try {
const wasmBinary = await fetch(wasmFilePath)
.then((res) => res.arrayBuffer())
.then((buf) => buf);

console.log('wasmBinary', wasmBinary);
// const wasmBinary = await fs.promises.readFile(wasmFilePath);
const wasmModule = await WebAssembly.compile(wasmBinary);
const imports = Object.entries(
WebAssembly.Module.imports(wasmModule).reduce(
(result, item) => ({
...result,
[item.module]: [...(result[item.module] || []), item.name]
}),
{} as Record<string, string[]>
)
).map(([from, names]) => ({ from, names }));

const exports = WebAssembly.Module.exports(wasmModule).map((item) => item.name);

return { imports, exports };
} catch (e) {
throw new Error(`Failed to parse WASM file: ${e.message}`);
}
}

loadWasm().then(() => {
initApp();
});
initApp();
17 changes: 17 additions & 0 deletions src/layouts/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import './index.scss';
import Menu from './Menu';
import { NoticeBanner } from './NoticeBanner';
import Sidebar from './Sidebar';
import SingletonOraiswapV3 from 'libs/contractSingleton';
import { getCosmWasmClient } from 'libs/cosmjs';

const App = () => {
const [address, setOraiAddress] = useConfigReducer('address');
Expand Down Expand Up @@ -58,6 +60,21 @@ const App = () => {
}
}, [walletByNetworks, window.tronWeb, window.tronLink, ethOwallet]);

useEffect(() => {
const loadSingleton = async () => {
if (address) {
try {
const { client } = await getCosmWasmClient({ chainId: network.chainId });
SingletonOraiswapV3.load(client, address);
} catch (error) {
console.error('Error loading OraiswapV3 singleton:', error);
}
}
};

loadSingleton();
}, [address]);

//Public API that will echo messages sent to it back to the client
const { sendJsonMessage, lastJsonMessage } = useWebSocket(
`wss://${new URL(network.rpc).host}/websocket`, // only get rpc.orai.io
Expand Down
Loading

0 comments on commit 8f66cdf

Please sign in to comment.