Skip to content

Commit

Permalink
Merge branch 'v2/dev' into pavania1/authz-illustrations
Browse files Browse the repository at this point in the history
  • Loading branch information
charymalloju authored Sep 13, 2024
2 parents 3749862 + aa4d389 commit 93f4351
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 41 deletions.
34 changes: 24 additions & 10 deletions frontend/src/components/main-layout/ConnectWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,37 @@ const ConnectWallet = () => {

const tryConnectWallet = async (walletName: string) => {
if (walletName === 'metamask') {
const notSupoortedMetamaskChainIds = ['agoric-3', 'evmos_9001-2', 'desmos-mainnet']
dispatch(setIsLoading());

try {
const snapInstalled = await getSnap();
if (!snapInstalled) {
await connectSnap(); // Initiates installation if not already present
}
} catch (error) {
console.log('Unable to install snap', error)
}

try {
for (let i = 0; i < networks.length; i++) {
console.time("Function execution time");

const chainId: string = networks[i].config.chainId;
const snapInstalled = await getSnap();
if (!snapInstalled) {
await connectSnap(); // Initiates installation if not already present
if (notSupoortedMetamaskChainIds.indexOf(chainId) <= -1) {
try {
await experimentalSuggestChain(networks[i].config, {
force: false,
});
} catch (error) {
console.log('Error while connecting ', chainId);
}
}

try {
await experimentalSuggestChain(networks[i].config, {
force: false,
});
} catch (error) {
console.log('Error while connecting ', chainId);
}
console.timeEnd("Function execution time");
}


} catch (error) {
console.log('trying to connect wallet ', error);
}
Expand Down
25 changes: 15 additions & 10 deletions frontend/src/components/main-layout/FixedLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,30 @@ const FixedLayout = ({ children }: { children: React.ReactNode }) => {
const isLoading = useAppSelector((state) => state.wallet.isLoading);

const walletState = useAppSelector((state) => state.wallet.status);
const notSupoortedMetamaskChainIds = ['agoric-3', 'evmos_9001-2', 'desmos-mainnet']

const tryConnectWallet = async (walletName: string) => {
if (walletName === 'metamask') {
dispatch(setIsLoading());
try {
const snapInstalled = await getSnap();
if (!snapInstalled) {
await connectSnap(); // Initiates installation if not already present
}

for (let i = 0; i < networks.length; i++) {
const chainId: string = networks[i].config.chainId;
const snapInstalled = await getSnap();
if (!snapInstalled) {
await connectSnap(); // Initiates installation if not already present
}
if (notSupoortedMetamaskChainIds.indexOf(chainId) <= -1) {

try {
await experimentalSuggestChain(networks[i].config, {
force: false,
});
} catch (error) {
console.log('Error while connecting ', chainId);
try {
await experimentalSuggestChain(networks[i].config, {
force: false,
});
} catch (error) {
console.log('Error while connecting ', chainId);
}
}

}
} catch (error) {
console.log('trying to connect wallet ', error);
Expand Down
43 changes: 24 additions & 19 deletions frontend/src/store/features/wallet/walletSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,31 +87,36 @@ export const establishWalletConnection = createAsyncThunk(
const chainInfos: Record<string, ChainInfo> = {};
const nameToChainIDs: Record<string, string> = {};
let anyNetworkAddress = '';
const notSupoortedMetamaskChainIds = ['agoric-3', 'evmos_9001-2', 'desmos-mainnet']
for (let i = 0; i < networks.length; i++) {
if (data.walletName === 'metamask') {

try {
const chainId: string = networks[i].config.chainId;
const chainName: string = networks[i].config.chainName;
const walletInfo = await getKey(chainId);
if (walletInfo?.address.includes('cosmos')) {
walletName = walletInfo?.address;
}
isNanoLedger = false;
if (notSupoortedMetamaskChainIds.indexOf(chainId) <= -1) {
const chainName: string = networks[i].config.chainName;
const walletInfo = await getKey(chainId);
if (walletInfo?.address.includes('cosmos')) {
walletName = walletInfo?.address;
}
isNanoLedger = false;

chainInfos[chainId] = {
walletInfo: {
algo: walletInfo?.algo,
bech32Address: walletInfo?.address,
pubKey: Buffer.from(walletInfo?.pubkey).toString('base64'),
isKeystone: '',
isNanoLedger: isNanoLedger,
name: walletName,
},
network: networks[i],
};
chainInfos[chainId] = {
walletInfo: {
algo: walletInfo?.algo,
bech32Address: walletInfo?.address,
pubKey: Buffer.from(walletInfo?.pubkey).toString('base64'),
isKeystone: '',
isNanoLedger: isNanoLedger,
name: walletName,
},
network: networks[i],
};

nameToChainIDs[chainName?.toLowerCase().split(' ').join('')] =
chainId;
}

nameToChainIDs[chainName?.toLowerCase().split(' ').join('')] =
chainId;
} catch (error) {
console.log(
`unable to connect to network ${networks[i].config.chainName}: `,
Expand Down
4 changes: 2 additions & 2 deletions server/cron/cron.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ func (c *Cron) Start() error {

// Every 15 minute
cron.AddFunc("0 */15 * * * *", func() {
c.CoinsPriceInfoList()
go c.CoinsPriceInfoList()
log.Println("successfully saved price information list")
})

// Every 15 minute
cron.AddFunc("0 */15 * * * *", func() {
c.StartCheckUris()
go c.StartCheckUris()
log.Println("successfully saved chain information list")
})

Expand Down

0 comments on commit 93f4351

Please sign in to comment.