Skip to content

Commit

Permalink
Fixes after removing rpc from the contract (#69)
Browse files Browse the repository at this point in the history
* Fixes after removing rpc from the contract

* fix docker

* it all works
  • Loading branch information
Szegoo authored Sep 7, 2023
1 parent 243ab8b commit 001eee3
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 260 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ WORKDIR /dotflow-ui
COPY . .

# Set the necessary environment variables
ENV CONTRACT_IDENTITY="Yib3XD3rkKWstaCB6P3FYCuWu2gZ4nwLoi6x9w8e9UoLNjh"
ENV CONTRACT_IDENTITY="5E1rtM1uNKNttdYYEXdVnfCdVrg9DGgJG1ERiytAqPNjjGRf"
ENV CONTRACT_ADDRESS_BOOK="5ChUFfCSppd3rXqpYVJs5KAKgi9dz1zyEvWwpFvXLEvYFuVq"
ENV RELAY_CHAIN="kusama"

RUN apk add --no-cache libc6-compat

Expand Down
14 changes: 10 additions & 4 deletions src/components/Modals/AddAddress/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import {
FormControl,
FormHelperText,
FormLabel,
ListItem,
ListItemIcon,
ListItemText,
MenuItem,
TextField,
} from '@mui/material';
Expand Down Expand Up @@ -126,10 +128,14 @@ export const AddAddressModal = ({ open, onClose }: AddAddressModalProps) => {
>
{Object.entries(chains).map(([id, chain], index) => (
<MenuItem value={id} key={index}>
<ListItemIcon>
<Image src={chain.logo} alt='logo' width={32} height={32} />
</ListItemIcon>
{chain.name}
<ListItem>
<ListItemIcon sx={{ mr: '8px' }}>
<Image src={chain.logo} alt='logo' width={32} height={32} />
</ListItemIcon>
<ListItemText>
{chain.name}
</ListItemText>
</ListItem>
</MenuItem>
))}
</TextField>
Expand Down
6 changes: 3 additions & 3 deletions src/contracts/addressbook/metadata.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"source": {
"hash": "0x4b89e660114f8ff737a566aceadf6e154e8eaa63fed72acf47bd2dafa4739605",
"language": "ink! 4.2.0",
"hash": "0xad61ee4dec538e61854c87b9f4372413d50bbdf7bd4061e2425010aae6ec2f32",
"language": "ink! 4.3.0",
"compiler": "rustc 1.68.0-nightly",
"build_info": {
"build_mode": "Debug",
"cargo_contract_version": "2.0.0-rc.1",
"cargo_contract_version": "3.2.0",
"rust_toolchain": "nightly-aarch64-apple-darwin",
"wasm_opt_settings": {
"keep_debug_symbols": false,
Expand Down
22 changes: 8 additions & 14 deletions src/contracts/identity/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,7 @@ const IdentityContractProvider = ({ children }: Props) => {
return;
}

const getChainInfo = async (
rpcUrls: string[],
chainId: number
): Promise<ChainConsts | null> => {
const count = rpcUrls.length;
const rpcIndex = Math.min(Math.floor(Math.random() * count), count - 1);
const rpc = rpcUrls[rpcIndex];

const getChainInfo = async (chainId: number): Promise<ChainConsts | null> => {
const chaindata = new Chaindata();

try {
Expand All @@ -119,17 +112,19 @@ const IdentityContractProvider = ({ children }: Props) => {

const rpcCount = chain.rpcs.length;
const rpcIndex = Math.min(Math.floor(Math.random() * rpcCount), rpcCount - 1);
const rpc = chain.rpcs[rpcIndex].url;

const ss58Prefix = ss58Result ? ss58Result : await fetchSs58Prefix(chain.rpcs[rpcIndex].url);
const ss58Prefix = ss58Result ? ss58Result : await fetchSs58Prefix(rpc);

return {
name: chain.name,
ss58Prefix: ss58Prefix,
paraId: chainId,
logo: chain.logo
logo: chain.logo,
rpc
};
} catch (e) {
toastError && toastError(`Failed to get chain info for ${rpc}`);
toastError && toastError(`Failed to get chain info.`);
return null;
}
};
Expand Down Expand Up @@ -168,11 +163,10 @@ const IdentityContractProvider = ({ children }: Props) => {

for await (const item of output) {
const chainId = parseInt(item[0].replace(/,/g, ''));
const { accountType, rpcUrls } = item[1];
const info = await getChainInfo(rpcUrls, chainId);
const { accountType } = item[1];
const info = await getChainInfo(chainId);
if (info)
_chains[chainId] = {
rpcUrls,
accountType,
...info,
};
Expand Down
Loading

0 comments on commit 001eee3

Please sign in to comment.