Request only for personal sign method (#1)
* Remove send eth send transaction method * Use Urbit logo instead of walletConnect logo * Only display ethereum chains * Remove optional namespaces * Undo changes made to react dapp with web3 repo
This commit is contained in:
parent
34bb1727d9
commit
79cad33e0a
@ -10,9 +10,10 @@ const SBannerWrapper = styled.div`
|
|||||||
const SBanner = styled.div`
|
const SBanner = styled.div`
|
||||||
width: 275px;
|
width: 275px;
|
||||||
height: 45px;
|
height: 45px;
|
||||||
background: url(/assets/walletconnect.png) no-repeat;
|
background: url(https://avatars.githubusercontent.com/u/5237680) no-repeat;
|
||||||
background-size: cover;
|
background-size: 50% auto;
|
||||||
background-position: center;
|
background-position: center;
|
||||||
|
margin-top: 2rem;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Banner = () => (
|
const Banner = () => (
|
||||||
|
@ -6,37 +6,12 @@ if (!process.env.NEXT_PUBLIC_PROJECT_ID)
|
|||||||
export const DEFAULT_MAIN_CHAINS = [
|
export const DEFAULT_MAIN_CHAINS = [
|
||||||
// mainnets
|
// mainnets
|
||||||
"eip155:1",
|
"eip155:1",
|
||||||
"eip155:10",
|
|
||||||
"eip155:100",
|
|
||||||
"eip155:137",
|
|
||||||
"eip155:324",
|
|
||||||
"eip155:42161",
|
|
||||||
"eip155:42220",
|
|
||||||
"cosmos:cosmoshub-4",
|
|
||||||
"solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ",
|
|
||||||
"polkadot:91b171bb158e2d3848fa23a9f1c25182",
|
|
||||||
"mvx:1",
|
|
||||||
"tron:0x2b6653dc",
|
|
||||||
"tezos:mainnet",
|
|
||||||
"kadena:mainnet01",
|
|
||||||
];
|
];
|
||||||
|
|
||||||
export const DEFAULT_TEST_CHAINS = [
|
export const DEFAULT_TEST_CHAINS = [
|
||||||
// testnets
|
// testnets
|
||||||
"eip155:5",
|
"eip155:5",
|
||||||
"eip155:11155111",
|
"eip155:11155111",
|
||||||
"eip155:280",
|
|
||||||
"eip155:420",
|
|
||||||
"eip155:80001",
|
|
||||||
"eip155:421611",
|
|
||||||
"eip155:44787",
|
|
||||||
"solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K",
|
|
||||||
"polkadot:e143f23803ac50e8f6f8e62695d1ce9e",
|
|
||||||
"near:testnet",
|
|
||||||
"mvx:D",
|
|
||||||
"tron:0xcd8690dc",
|
|
||||||
"tezos:testnet",
|
|
||||||
"kadena:testnet04",
|
|
||||||
];
|
];
|
||||||
|
|
||||||
export const DEFAULT_CHAINS = [...DEFAULT_MAIN_CHAINS, ...DEFAULT_TEST_CHAINS];
|
export const DEFAULT_CHAINS = [...DEFAULT_MAIN_CHAINS, ...DEFAULT_TEST_CHAINS];
|
||||||
@ -50,7 +25,7 @@ export const DEFAULT_APP_METADATA = {
|
|||||||
name: "React App",
|
name: "React App",
|
||||||
description: "React App for WalletConnect",
|
description: "React App for WalletConnect",
|
||||||
url: "https://walletconnect.com/",
|
url: "https://walletconnect.com/",
|
||||||
icons: ["https://avatars.githubusercontent.com/u/37784886"],
|
icons: ["https://avatars.githubusercontent.com/u/5237680"],
|
||||||
verifyUrl: "https://verify.walletconnect.com",
|
verifyUrl: "https://verify.walletconnect.com",
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -58,7 +33,6 @@ export const DEFAULT_APP_METADATA = {
|
|||||||
* EIP155
|
* EIP155
|
||||||
*/
|
*/
|
||||||
export enum DEFAULT_EIP155_METHODS {
|
export enum DEFAULT_EIP155_METHODS {
|
||||||
ETH_SEND_TRANSACTION = "eth_sendTransaction",
|
|
||||||
PERSONAL_SIGN = "personal_sign",
|
PERSONAL_SIGN = "personal_sign",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,6 @@ type TRpcRequestCallback = (
|
|||||||
interface IContext {
|
interface IContext {
|
||||||
ping: () => Promise<void>;
|
ping: () => Promise<void>;
|
||||||
ethereumRpc: {
|
ethereumRpc: {
|
||||||
testSendTransaction: TRpcRequestCallback;
|
|
||||||
testSignTransaction: TRpcRequestCallback;
|
testSignTransaction: TRpcRequestCallback;
|
||||||
testEthSign: TRpcRequestCallback;
|
testEthSign: TRpcRequestCallback;
|
||||||
testSignPersonalMessage: TRpcRequestCallback;
|
testSignPersonalMessage: TRpcRequestCallback;
|
||||||
@ -232,45 +231,6 @@ export function JsonRpcContextProvider({
|
|||||||
// -------- ETHEREUM/EIP155 RPC METHODS --------
|
// -------- ETHEREUM/EIP155 RPC METHODS --------
|
||||||
|
|
||||||
const ethereumRpc = {
|
const ethereumRpc = {
|
||||||
testSendTransaction: _createJsonRpcRequestHandler(
|
|
||||||
async (chainId: string, address: string) => {
|
|
||||||
const caipAccountAddress = `${chainId}:${address}`;
|
|
||||||
const account = accounts.find(
|
|
||||||
(account) => account === caipAccountAddress
|
|
||||||
);
|
|
||||||
if (account === undefined)
|
|
||||||
throw new Error(`Account for ${caipAccountAddress} not found`);
|
|
||||||
|
|
||||||
const tx = await formatTestTransaction(account);
|
|
||||||
|
|
||||||
const balance = BigNumber.from(balances[account][0].balance || "0");
|
|
||||||
if (balance.lt(BigNumber.from(tx.gasPrice).mul(tx.gasLimit))) {
|
|
||||||
return {
|
|
||||||
method: DEFAULT_EIP155_METHODS.ETH_SEND_TRANSACTION,
|
|
||||||
address,
|
|
||||||
valid: false,
|
|
||||||
result: "Insufficient funds for intrinsic transaction cost",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const result = await client!.request<string>({
|
|
||||||
topic: session!.topic,
|
|
||||||
chainId,
|
|
||||||
request: {
|
|
||||||
method: DEFAULT_EIP155_METHODS.ETH_SEND_TRANSACTION,
|
|
||||||
params: [tx],
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// format displayed result
|
|
||||||
return {
|
|
||||||
method: DEFAULT_EIP155_METHODS.ETH_SEND_TRANSACTION,
|
|
||||||
address,
|
|
||||||
valid: true,
|
|
||||||
result,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
),
|
|
||||||
testSignTransaction: _createJsonRpcRequestHandler(
|
testSignTransaction: _createJsonRpcRequestHandler(
|
||||||
async (chainId: string, address: string) => {
|
async (chainId: string, address: string) => {
|
||||||
const caipAccountAddress = `${chainId}:${address}`;
|
const caipAccountAddress = `${chainId}:${address}`;
|
||||||
|
@ -63,7 +63,6 @@ export const getSupportedRequiredMethodsByNamespace = (namespace: string) => {
|
|||||||
export const getSupportedOptionalMethodsByNamespace = (namespace: string) => {
|
export const getSupportedOptionalMethodsByNamespace = (namespace: string) => {
|
||||||
switch (namespace) {
|
switch (namespace) {
|
||||||
case "eip155":
|
case "eip155":
|
||||||
return Object.values(DEFAULT_EIP155_OPTIONAL_METHODS);
|
|
||||||
case "cosmos":
|
case "cosmos":
|
||||||
case "solana":
|
case "solana":
|
||||||
case "polkadot":
|
case "polkadot":
|
||||||
|
@ -146,13 +146,6 @@ const Home: NextPage = () => {
|
|||||||
|
|
||||||
const getEthereumActions = (): AccountAction[] => {
|
const getEthereumActions = (): AccountAction[] => {
|
||||||
const actions = {
|
const actions = {
|
||||||
[DEFAULT_EIP155_METHODS.ETH_SEND_TRANSACTION]: {
|
|
||||||
method: DEFAULT_EIP155_METHODS.ETH_SEND_TRANSACTION,
|
|
||||||
callback: async (chainId: string, address: string) => {
|
|
||||||
openRequestModal();
|
|
||||||
await ethereumRpc.testSendTransaction(chainId, address);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
[DEFAULT_EIP155_METHODS.PERSONAL_SIGN]: {
|
[DEFAULT_EIP155_METHODS.PERSONAL_SIGN]: {
|
||||||
method: DEFAULT_EIP155_METHODS.PERSONAL_SIGN,
|
method: DEFAULT_EIP155_METHODS.PERSONAL_SIGN,
|
||||||
callback: async (chainId: string, address: string) => {
|
callback: async (chainId: string, address: string) => {
|
||||||
|
@ -10,7 +10,7 @@ const projectId = import.meta.env.VITE_PROJECT_ID as string;
|
|||||||
const provider = await EthereumProvider.init({
|
const provider = await EthereumProvider.init({
|
||||||
projectId,
|
projectId,
|
||||||
chains: [1],
|
chains: [1],
|
||||||
methods: ["personal_sign", "eth_sendTransaction"],
|
methods: ["personal_sign"],
|
||||||
showQrModal: true,
|
showQrModal: true,
|
||||||
qrModalOptions: {
|
qrModalOptions: {
|
||||||
themeMode: "light",
|
themeMode: "light",
|
||||||
|
Loading…
Reference in New Issue
Block a user