Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
abb601a17b | ||
|
|
2a4a478e32 |
No files matched your search
+1
-1
@@ -3,7 +3,7 @@ REACT_APP_WALLET_CONNECT_PROJECT_ID=
|
||||
REACT_APP_DEFAULT_GAS_PRICE=0.025
|
||||
# Reference: https://github.com/cosmos/cosmos-sdk/issues/16020
|
||||
REACT_APP_GAS_ADJUSTMENT=2
|
||||
REACT_APP_LACONICD_RPC_URL=https://laconicd-sapo.laconic.com
|
||||
REACT_APP_LACONICD_RPC_URL=https://laconicd-mainnet-1.laconic.com
|
||||
|
||||
# Example: https://example-url-1.com,https://example-url-2.com
|
||||
REACT_APP_ALLOWED_URLS=
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "web-wallet",
|
||||
"version": "0.1.7",
|
||||
"version": "0.1.8",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@cerc-io/registry-sdk": "^0.2.5",
|
||||
|
||||
+14
-2
@@ -43,10 +43,11 @@ import useAccountsData from "./hooks/useAccountsData";
|
||||
import { useWebViewHandler } from "./hooks/useWebViewHandler";
|
||||
import SignRequestEmbed from "./screens/SignRequestEmbed";
|
||||
import useAddAccountEmbed from "./hooks/useAddAccountEmbed";
|
||||
import useExportPKEmbed from "./hooks/useExportPrivateKeyEmbed";
|
||||
import { SignTxEmbed } from "./screens/SignTxEmbed";
|
||||
import useCreateNetwork from "./hooks/useCreateNetwork";
|
||||
|
||||
const REACT_APP_ALLOWED_URLS = import.meta.env.REACT_APP_ALLOWED_URLS;
|
||||
|
||||
const Stack = createStackNavigator<StackParamsList>();
|
||||
|
||||
const App = (): React.JSX.Element => {
|
||||
@@ -235,6 +236,18 @@ const App = (): React.JSX.Element => {
|
||||
const handleCheckBalance = async (event: MessageEvent) => {
|
||||
if (event.data.type !== CHECK_BALANCE) return;
|
||||
|
||||
if (!REACT_APP_ALLOWED_URLS) {
|
||||
console.log('Allowed URLs are not set');
|
||||
return;
|
||||
}
|
||||
|
||||
const allowedUrls = REACT_APP_ALLOWED_URLS.split(',').map((url: string) => url.trim());
|
||||
|
||||
if (!allowedUrls.includes(event.origin)) {
|
||||
console.log('Unauthorized app.');
|
||||
return;
|
||||
}
|
||||
|
||||
const { chainId, amount } = event.data;
|
||||
const network = networksData.find(net => net.chainId === chainId);
|
||||
|
||||
@@ -287,7 +300,6 @@ const App = (): React.JSX.Element => {
|
||||
|
||||
useWebViewHandler();
|
||||
useAddAccountEmbed();
|
||||
useExportPKEmbed();
|
||||
useCreateNetwork();
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
import { useEffect } from 'react';
|
||||
|
||||
import { useAccounts } from '../context/AccountsContext';
|
||||
import { getPathKey, sendMessage } from '../utils/misc';
|
||||
import { ACCOUNT_PK_RESPONSE, REQUEST_ACCOUNT_PK } from '../utils/constants';
|
||||
|
||||
const useExportPKEmbed = () => {
|
||||
const { accounts } = useAccounts();
|
||||
|
||||
useEffect(() => {
|
||||
const handleMessage = async (event: MessageEvent) => {
|
||||
const { type, chainId, address } = event.data;
|
||||
|
||||
if (type !== REQUEST_ACCOUNT_PK) return;
|
||||
|
||||
try {
|
||||
const selectedAccount = accounts.find(account => account.address === address);
|
||||
if (!selectedAccount) {
|
||||
throw new Error("Account not found")
|
||||
}
|
||||
|
||||
const pathKey = await getPathKey(chainId, selectedAccount.index);
|
||||
const privateKey = pathKey.privKey;
|
||||
|
||||
sendMessage(
|
||||
event.source as Window,
|
||||
ACCOUNT_PK_RESPONSE,
|
||||
{ privateKey },
|
||||
event.origin,
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('Error fetching private key:', error);
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener('message', handleMessage);
|
||||
return () => {
|
||||
window.removeEventListener('message', handleMessage);
|
||||
};
|
||||
}, [accounts]);
|
||||
};
|
||||
|
||||
export default useExportPKEmbed;
|
||||
@@ -28,6 +28,8 @@ import useGetOrCreateAccounts from '../hooks/useGetOrCreateAccounts';
|
||||
import useAccountsData from '../hooks/useAccountsData';
|
||||
import { REQUEST_TX, REQUEST_WALLET_ACCOUNTS, TRANSACTION_RESPONSE, WALLET_ACCOUNTS_DATA } from '../utils/constants';
|
||||
|
||||
const REACT_APP_ALLOWED_URLS = import.meta.env.REACT_APP_ALLOWED_URLS;
|
||||
|
||||
type TransactionDetails = {
|
||||
chainId: string;
|
||||
fromAddress: string;
|
||||
@@ -54,6 +56,18 @@ export const WalletEmbed = () => {
|
||||
const handleGetAccounts = async (event: MessageEvent) => {
|
||||
if (event.data.type !== REQUEST_WALLET_ACCOUNTS) return;
|
||||
|
||||
if (!REACT_APP_ALLOWED_URLS) {
|
||||
console.log('Allowed URLs are not set');
|
||||
return;
|
||||
}
|
||||
|
||||
const allowedUrls = REACT_APP_ALLOWED_URLS.split(',').map((url: string) => url.trim());
|
||||
|
||||
if (!allowedUrls.includes(event.origin)) {
|
||||
console.log('Unauthorized app.');
|
||||
return;
|
||||
}
|
||||
|
||||
const accountsData = await getAccountsData(event.data.chainId);
|
||||
|
||||
if (accountsData.length === 0) {
|
||||
@@ -84,6 +98,18 @@ export const WalletEmbed = () => {
|
||||
try {
|
||||
if (event.data.type !== REQUEST_TX) return;
|
||||
|
||||
if (!REACT_APP_ALLOWED_URLS) {
|
||||
console.log('Allowed URLs are not set');
|
||||
return;
|
||||
}
|
||||
|
||||
const allowedUrls = REACT_APP_ALLOWED_URLS.split(',').map((url: string) => url.trim());
|
||||
|
||||
if (!allowedUrls.includes(event.origin)) {
|
||||
console.log('Unauthorized app.');
|
||||
return;
|
||||
}
|
||||
|
||||
txEventRef.current = event;
|
||||
|
||||
const { chainId, fromAddress, toAddress, amount } = event.data;
|
||||
|
||||
+13
-15
@@ -6,28 +6,28 @@ export const EIP155 = 'eip155';
|
||||
export const COSMOS = 'cosmos';
|
||||
|
||||
export const DEFAULT_NETWORKS: NetworksFormData[] = [
|
||||
{
|
||||
chainId: 'laconic-mainnet',
|
||||
networkName: 'laconicd mainnet',
|
||||
namespace: COSMOS,
|
||||
rpcUrl: import.meta.env.REACT_APP_LACONICD_RPC_URL,
|
||||
blockExplorerUrl: 'https://explorer.laconic.com/laconic-mainnet',
|
||||
nativeDenom: 'alnt',
|
||||
addressPrefix: 'laconic',
|
||||
coinType: '118',
|
||||
gasPrice: '0.001',
|
||||
isDefault: false,
|
||||
},
|
||||
{
|
||||
chainId: 'laconic-testnet-2',
|
||||
networkName: 'laconicd testnet-2',
|
||||
namespace: COSMOS,
|
||||
rpcUrl: import.meta.env.REACT_APP_LACONICD_RPC_URL!,
|
||||
rpcUrl: 'https://laconicd-sapo.laconic.com',
|
||||
blockExplorerUrl: '',
|
||||
nativeDenom: 'alnt',
|
||||
addressPrefix: 'laconic',
|
||||
coinType: '118',
|
||||
gasPrice: '0.001',
|
||||
isDefault: true,
|
||||
},
|
||||
{
|
||||
chainId: 'laconic_9000-1',
|
||||
networkName: 'laconicd',
|
||||
namespace: COSMOS,
|
||||
rpcUrl: "https://laconicd.laconic.com",
|
||||
blockExplorerUrl: '',
|
||||
nativeDenom: 'alnt',
|
||||
addressPrefix: 'laconic',
|
||||
coinType: '118',
|
||||
gasPrice: '1',
|
||||
isDefault: false,
|
||||
},
|
||||
{
|
||||
@@ -70,7 +70,6 @@ export const REQUEST_SIGN_MESSAGE = 'REQUEST_SIGN_MESSAGE';
|
||||
export const REQUEST_WALLET_ACCOUNTS = 'REQUEST_WALLET_ACCOUNTS';
|
||||
export const REQUEST_CREATE_OR_GET_ACCOUNTS = 'REQUEST_CREATE_OR_GET_ACCOUNTS';
|
||||
export const REQUEST_TX = 'REQUEST_TX';
|
||||
export const REQUEST_ACCOUNT_PK = 'REQUEST_ACCOUNT_PK';
|
||||
export const REQUEST_ADD_ACCOUNT = 'REQUEST_ADD_ACCOUNT';
|
||||
export const AUTO_SIGN_IN = 'AUTO_SIGN_IN';
|
||||
export const CHECK_BALANCE = 'CHECK_BALANCE';
|
||||
@@ -82,7 +81,6 @@ export const SIGN_TX_RESPONSE = 'SIGN_TX_RESPONSE';
|
||||
export const SIGN_MESSAGE_RESPONSE = 'SIGN_MESSAGE_RESPONSE';
|
||||
export const TRANSACTION_RESPONSE = 'TRANSACTION_RESPONSE';
|
||||
export const SIGN_IN_RESPONSE = 'SIGN_IN_RESPONSE';
|
||||
export const ACCOUNT_PK_RESPONSE = 'ACCOUNT_PK_RESPONSE';
|
||||
export const ADD_ACCOUNT_RESPONSE = 'ADD_ACCOUNT_RESPONSE';
|
||||
export const WALLET_ACCOUNTS_DATA = 'WALLET_ACCOUNTS_DATA';
|
||||
export const IS_SUFFICIENT = 'IS_SUFFICIENT';
|
||||
|
||||
@@ -10,7 +10,6 @@ services:
|
||||
CERC_DEFAULT_GAS_PRICE: ${CERC_DEFAULT_GAS_PRICE:-0.025}
|
||||
CERC_GAS_ADJUSTMENT: ${CERC_GAS_ADJUSTMENT:-2}
|
||||
CERC_LACONICD_RPC_URL: ${CERC_LACONICD_RPC_URL:-https://laconicd.laconic.com}
|
||||
CERC_ZENITHD_RPC_URL: ${CERC_ZENITHD_RPC_URL}
|
||||
CERC_ALLOWED_URLS: ${CERC_ALLOWED_URLS}
|
||||
command: ["bash", "/scripts/run.sh"]
|
||||
volumes:
|
||||
|
||||
@@ -65,10 +65,7 @@ Instructions for running the `laconic-wallet-web` using [laconic-so](https://git
|
||||
CERC_GAS_ADJUSTMENT=
|
||||
|
||||
# RPC endpoint of laconicd node (default: https://laconicd.laconic.com)
|
||||
CERC_LACONICD_RPC_URL=
|
||||
|
||||
# Zenith RPC endpoint
|
||||
CERC_ZENITHD_RPC_URL=
|
||||
CERC_LACONICD_RPC_URL=https://laconicd-mainnet-1.laconic.com
|
||||
```
|
||||
|
||||
## Start the deployment
|
||||
|
||||
Reference in new issue
Block a user