From 3ee82016cc9a408654bab6f78ec7bd9b101adbc4 Mon Sep 17 00:00:00 2001 From: Johnson Chen Date: Thu, 23 May 2024 15:54:33 +0800 Subject: [PATCH] feat(app): donate with message --- app/app.vue | 2 +- app/components.d.ts | 3 + app/core/sidebar.ts | 11 ++ app/pages/app/donate-with-message.vue | 197 +++++++++++++++++++++++++ app/stores/{useEthers.ts => ethers.ts} | 11 +- app/utils/chains.ts | 57 +++++++ 6 files changed, 279 insertions(+), 2 deletions(-) create mode 100644 app/pages/app/donate-with-message.vue rename app/stores/{useEthers.ts => ethers.ts} (73%) create mode 100644 app/utils/chains.ts diff --git a/app/app.vue b/app/app.vue index 42ffdca..5fdac0f 100644 --- a/app/app.vue +++ b/app/app.vue @@ -72,7 +72,7 @@ const { darkMode } = storeToRefs(useAppStore()) - + h(NuxtLink, { to: 'app/donate-with-message' }, { default: () => 'Donate with Message' }), + key: 'app/donate-with-message', + }, + ], + }, + { label: () => h( diff --git a/app/pages/app/donate-with-message.vue b/app/pages/app/donate-with-message.vue new file mode 100644 index 0000000..bf7de55 --- /dev/null +++ b/app/pages/app/donate-with-message.vue @@ -0,0 +1,197 @@ + + + + + diff --git a/app/stores/useEthers.ts b/app/stores/ethers.ts similarity index 73% rename from app/stores/useEthers.ts rename to app/stores/ethers.ts index b41ebf5..281d8ac 100644 --- a/app/stores/useEthers.ts +++ b/app/stores/ethers.ts @@ -2,7 +2,7 @@ import type { EIP1193Provider } from '@vue-dapp/core' import { ethers } from 'ethers' import { defineStore } from 'pinia' -export const useEthers = defineStore('useEthers', () => { +export const useEthersStore = defineStore('ethers', () => { const provider = ref(null) const signer = ref(null) @@ -24,3 +24,12 @@ export const useEthers = defineStore('useEthers', () => { resetWallet, } }) + +export function useEthers() { + const ethersStore = useEthersStore() + + return { + ...useEthersStore(), + ...storeToRefs(ethersStore), + } +} diff --git a/app/utils/chains.ts b/app/utils/chains.ts new file mode 100644 index 0000000..cf93620 --- /dev/null +++ b/app/utils/chains.ts @@ -0,0 +1,57 @@ +export type Chain = { + chainId: number + chainName: string + nativeCurrency: { + symbol: string + decimals: number + } + rpcUrls: string[] + blockExplorerUrls: string[] +} +export const chains: { + [key: number]: Chain +} = { + 1: { + chainId: 1, + chainName: 'Ethereum', + nativeCurrency: { + symbol: 'ETH', + decimals: 18, + }, + rpcUrls: ['https://ethereum-rpc.publicnode.com/'], + blockExplorerUrls: ['https://etherscan.io/'], + }, + + 11155111: { + chainId: 11155111, + chainName: 'Sepolia', + nativeCurrency: { + symbol: 'ETH', + decimals: 18, + }, + rpcUrls: ['https://ethereum-sepolia-rpc.publicnode.com/'], + blockExplorerUrls: ['https://sepolia.etherscan.io/'], + }, + + 42161: { + chainId: 42161, + chainName: 'Arbitrum', + nativeCurrency: { + symbol: 'ETH', + decimals: 18, + }, + rpcUrls: ['https://arbitrum-one-rpc.publicnode.com/'], + blockExplorerUrls: ['https://arbiscan.io/'], + }, + + 421614: { + chainId: 421614, + chainName: 'Arbitrum Sepolia', + nativeCurrency: { + symbol: 'ETH', + decimals: 18, + }, + rpcUrls: ['https://arbitrum-sepolia-rpc.publicnode.com/'], + blockExplorerUrls: ['https://sepolia.arbiscan.io/'], + }, +}