Compare commits
No commits in common. "main" and "main" have entirely different histories.
@ -3,20 +3,17 @@ name: Lint and Build
|
|||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ main ]
|
branches: [ main ]
|
||||||
push:
|
|
||||||
branches: [ main ]
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lint-and-build:
|
lint-and-build:
|
||||||
name: Run lint and build checks
|
name: Run lint and build checks
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: '22'
|
node-version: '22'
|
||||||
|
|
||||||
@ -25,9 +22,9 @@ jobs:
|
|||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: yarn install --frozen-lockfile
|
run: yarn install --frozen-lockfile
|
||||||
|
|
||||||
- name: Run ESLint
|
- name: Run ESLint
|
||||||
run: yarn lint
|
run: yarn lint
|
||||||
|
|
||||||
- name: Run build
|
- name: Run build
|
||||||
run: yarn build
|
run: yarn build
|
||||||
|
|||||||
@ -54,20 +54,5 @@ module.exports = function override(config, env) {
|
|||||||
|
|
||||||
config.resolve.alias['react-native$'] = require.resolve('react-native-web');
|
config.resolve.alias['react-native$'] = require.resolve('react-native-web');
|
||||||
|
|
||||||
// Ignore source map warnings from third-party packages. Ref: https://github.com/facebook/create-react-app/discussions/11767#discussioncomment-3416044
|
|
||||||
const ignoreSourceMapPackages = [
|
|
||||||
'@cosmjs',
|
|
||||||
'@confio/ics23',
|
|
||||||
'@json-rpc-tools',
|
|
||||||
'@pedrouid/environment',
|
|
||||||
'@walletconnect',
|
|
||||||
'cosmjs-types',
|
|
||||||
];
|
|
||||||
|
|
||||||
config.ignoreWarnings = ignoreSourceMapPackages.map(pkg => ({
|
|
||||||
module: new RegExp(`node_modules/${pkg.replace('/', '\\/')}`),
|
|
||||||
message: /Failed to parse source map/,
|
|
||||||
}));
|
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "web-wallet",
|
"name": "web-wallet",
|
||||||
"version": "0.1.7-zenith-0.2.5",
|
"version": "0.1.7-zenith-0.2.2",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@laconic-network/cosmjs-util": "^0.1.0",
|
"@laconic-network/cosmjs-util": "^0.1.0",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { useEffect, useCallback } from "react";
|
import { useEffect, useCallback } from "react";
|
||||||
|
|
||||||
import { addNewNetwork, createWallet, checkNetworkForChainID, isWalletCreated, updateNetworkRpcUrl } from "../utils/accounts";
|
import { addNewNetwork, createWallet, checkNetworkForChainID, isWalletCreated } from "../utils/accounts";
|
||||||
import { useNetworks } from "../context/NetworksContext";
|
import { useNetworks } from "../context/NetworksContext";
|
||||||
import { NETWORK_ADDED_RESPONSE, NETWORK_ADD_FAILED_RESPONSE, NETWORK_ALREADY_EXISTS_RESPONSE, REQUEST_ADD_NETWORK } from "../utils/constants";
|
import { NETWORK_ADDED_RESPONSE, NETWORK_ADD_FAILED_RESPONSE, NETWORK_ALREADY_EXISTS_RESPONSE, REQUEST_ADD_NETWORK } from "../utils/constants";
|
||||||
import { NetworksFormData } from "../types";
|
import { NetworksFormData } from "../types";
|
||||||
@ -52,11 +52,6 @@ const useCreateNetwork = () => {
|
|||||||
chainId
|
chainId
|
||||||
}, sourceOrigin);
|
}, sourceOrigin);
|
||||||
} else {
|
} else {
|
||||||
console.log("Network already exists. Updating RPC URL");
|
|
||||||
|
|
||||||
const retrievedNetworksData = await updateNetworkRpcUrl(chainId, networkData.rpcUrl);
|
|
||||||
setNetworksData(retrievedNetworksData);
|
|
||||||
|
|
||||||
sendMessage(window.parent, NETWORK_ALREADY_EXISTS_RESPONSE, {
|
sendMessage(window.parent, NETWORK_ALREADY_EXISTS_RESPONSE, {
|
||||||
type: NETWORK_ALREADY_EXISTS_RESPONSE,
|
type: NETWORK_ALREADY_EXISTS_RESPONSE,
|
||||||
chainId
|
chainId
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
|
|
||||||
import { retrieveNetworksData, retrieveAccounts } from '../utils/accounts';
|
import { useAccounts } from '../context/AccountsContext';
|
||||||
import { getPathKey, sendMessage } from '../utils/misc';
|
import { getPathKey, sendMessage } from '../utils/misc';
|
||||||
import { ACCOUNT_PK_RESPONSE, REQUEST_ACCOUNT_PK } from '../utils/constants';
|
import { ACCOUNT_PK_RESPONSE, REQUEST_ACCOUNT_PK } from '../utils/constants';
|
||||||
|
|
||||||
const useExportPKEmbed = () => {
|
const useExportPKEmbed = () => {
|
||||||
|
const { accounts } = useAccounts();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleMessage = async (event: MessageEvent) => {
|
const handleMessage = async (event: MessageEvent) => {
|
||||||
const { type, chainId, address } = event.data;
|
const { type, chainId, address } = event.data;
|
||||||
@ -12,23 +14,9 @@ const useExportPKEmbed = () => {
|
|||||||
if (type !== REQUEST_ACCOUNT_PK) return;
|
if (type !== REQUEST_ACCOUNT_PK) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Look up the network and accounts directly from storage
|
const selectedAccount = accounts.find(account => account.address === address);
|
||||||
// rather than relying on the accounts context, which can be
|
|
||||||
// overwritten by HomeScreen's fetchAccounts for a different network.
|
|
||||||
const networksData = await retrieveNetworksData();
|
|
||||||
const targetNetwork = networksData.find(
|
|
||||||
net => `${net.namespace}:${net.chainId}` === chainId,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!targetNetwork) {
|
|
||||||
throw new Error("Network not found");
|
|
||||||
}
|
|
||||||
|
|
||||||
const networkAccounts = await retrieveAccounts(targetNetwork);
|
|
||||||
const selectedAccount = networkAccounts?.find(account => account.address === address);
|
|
||||||
|
|
||||||
if (!selectedAccount) {
|
if (!selectedAccount) {
|
||||||
throw new Error("Account not found");
|
throw new Error("Account not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
const pathKey = await getPathKey(chainId, selectedAccount.index);
|
const pathKey = await getPathKey(chainId, selectedAccount.index);
|
||||||
@ -49,7 +37,7 @@ const useExportPKEmbed = () => {
|
|||||||
return () => {
|
return () => {
|
||||||
window.removeEventListener('message', handleMessage);
|
window.removeEventListener('message', handleMessage);
|
||||||
};
|
};
|
||||||
}, []);
|
}, [accounts]);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default useExportPKEmbed;
|
export default useExportPKEmbed;
|
||||||
|
|||||||
@ -459,35 +459,6 @@ const checkNetworkForChainID = async (
|
|||||||
return networksData.some((network) => network.chainId === chainId);
|
return networksData.some((network) => network.chainId === chainId);
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateNetworkRpcUrl = async (
|
|
||||||
chainId: string,
|
|
||||||
rpcUrl: string,
|
|
||||||
): Promise<NetworksDataState[]> => {
|
|
||||||
const networks = await getInternetCredentials('networks');
|
|
||||||
|
|
||||||
if (!networks) {
|
|
||||||
throw new Error('Networks not found');
|
|
||||||
}
|
|
||||||
|
|
||||||
const networksData: NetworksDataState[] = JSON.parse(networks);
|
|
||||||
|
|
||||||
const networkIndex = networksData.findIndex((network) => network.chainId === chainId);
|
|
||||||
|
|
||||||
if (networkIndex === -1) {
|
|
||||||
throw new Error('Network not found');
|
|
||||||
}
|
|
||||||
|
|
||||||
networksData[networkIndex].rpcUrl = rpcUrl;
|
|
||||||
|
|
||||||
await setInternetCredentials(
|
|
||||||
'networks',
|
|
||||||
'_',
|
|
||||||
JSON.stringify(networksData),
|
|
||||||
);
|
|
||||||
|
|
||||||
return networksData;
|
|
||||||
}
|
|
||||||
|
|
||||||
const isWalletCreated = async (
|
const isWalletCreated = async (
|
||||||
): Promise<boolean> => {
|
): Promise<boolean> => {
|
||||||
const mnemonicServer = await getInternetCredentials("mnemonicServer");
|
const mnemonicServer = await getInternetCredentials("mnemonicServer");
|
||||||
@ -512,6 +483,5 @@ export {
|
|||||||
getCosmosAccountByHDPath,
|
getCosmosAccountByHDPath,
|
||||||
addNewNetwork,
|
addNewNetwork,
|
||||||
checkNetworkForChainID,
|
checkNetworkForChainID,
|
||||||
isWalletCreated,
|
isWalletCreated
|
||||||
updateNetworkRpcUrl
|
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user