├── packages ├── vue │ ├── README.md │ ├── tsup.config.ts │ ├── src │ │ ├── composables │ │ │ ├── chain.ts │ │ │ ├── address.ts │ │ │ ├── connectors.ts │ │ │ ├── error.ts │ │ │ ├── provider.ts │ │ │ └── status.ts │ │ └── index.ts │ ├── package.json │ └── tsconfig.json ├── react │ ├── README.md │ ├── src │ │ ├── constants │ │ │ └── index.ts │ │ ├── hooks │ │ │ ├── getW3Error.tsx │ │ │ ├── getW3Chain.tsx │ │ │ ├── getW3Address.tsx │ │ │ ├── getW3Provider.tsx │ │ │ └── useConnect.tsx │ │ ├── index.ts │ │ └── W3.tsx │ ├── tsup.config.ts │ ├── package.json │ └── tsconfig.json ├── solid │ ├── README.md │ ├── src │ │ ├── signals │ │ │ ├── error.ts │ │ │ ├── status.ts │ │ │ ├── chain.ts │ │ │ ├── address.ts │ │ │ ├── connectors.ts │ │ │ └── provider.ts │ │ └── index.ts │ ├── tsup.config.ts │ ├── package.json │ └── tsconfig.json ├── svelte │ ├── README.md │ ├── .npmrc │ ├── vite.config.ts │ ├── .gitignore │ ├── tsconfig.json │ ├── svelte.config.js │ ├── src │ │ └── lib │ │ │ └── index.svelte.ts │ └── package.json ├── connectors │ ├── metamask │ │ ├── .gitignore │ │ ├── src │ │ │ ├── index.ts │ │ │ └── connector │ │ │ │ └── index.ts │ │ ├── tsup.config.ts │ │ ├── tsconfig.json │ │ └── package.json │ ├── walletconnect │ │ ├── .gitignore │ │ ├── src │ │ │ ├── index.ts │ │ │ ├── store │ │ │ │ └── index.ts │ │ │ └── connector │ │ │ │ └── index.ts │ │ ├── tsup.config.ts │ │ ├── tsconfig.json │ │ └── package.json │ └── coinbase │ │ ├── src │ │ ├── index.ts │ │ └── connector │ │ │ └── index.ts │ │ ├── tsup.config.ts │ │ ├── tsconfig.json │ │ └── package.json └── core │ ├── src │ ├── constants │ │ └── index.ts │ ├── utils │ │ ├── index.ts │ │ ├── error.ts │ │ └── clear.ts │ ├── connectors │ │ ├── index.ts │ │ ├── EIP6963.ts │ │ └── injected.ts │ ├── functions │ │ ├── index.ts │ │ ├── connection.ts │ │ ├── switchChain.ts │ │ └── init.ts │ ├── index.ts │ ├── store │ │ └── w3store.ts │ └── types.ts │ ├── tsup.config.ts │ ├── tsconfig.json │ └── package.json ├── examples ├── svelte │ ├── .npmrc │ ├── src │ │ ├── lib │ │ │ └── index.ts │ │ ├── routes │ │ │ └── +page.svelte │ │ ├── app.d.ts │ │ └── app.html │ ├── static │ │ └── favicon.png │ ├── vite.config.ts │ ├── .gitignore │ ├── tsconfig.json │ ├── svelte.config.js │ ├── package.json │ └── README.md ├── html │ ├── src │ │ ├── vite-env.d.ts │ │ └── main.ts │ ├── index.html │ ├── package.json │ ├── tsconfig.json │ └── public │ │ └── vite.svg ├── vue │ ├── src │ │ ├── vite-env.d.ts │ │ ├── assets │ │ │ └── vue.svg │ │ ├── main.ts │ │ ├── App.vue │ │ └── style.css │ ├── .vscode │ │ └── extensions.json │ ├── vite.config.ts │ ├── tsconfig.node.json │ ├── .gitignore │ ├── index.html │ ├── package.json │ ├── tsconfig.json │ ├── public │ │ └── vite.svg │ └── README.md ├── solid │ ├── src │ │ ├── vite-env.d.ts │ │ ├── index.tsx │ │ ├── App.css │ │ ├── App.tsx │ │ ├── index.css │ │ └── assets │ │ │ └── solid.svg │ ├── vite.config.ts │ ├── tsconfig.node.json │ ├── .gitignore │ ├── index.html │ ├── package.json │ ├── tsconfig.json │ ├── README.md │ └── public │ │ └── vite.svg └── react │ ├── .env.local.example │ ├── .eslintrc.json │ ├── public │ ├── favicon.ico │ ├── wallet.png │ ├── walletconnect.svg │ ├── coinbase.svg │ └── metamask.svg │ ├── next.config.js │ ├── src │ ├── chains │ │ ├── index.ts │ │ ├── bsc.ts │ │ ├── polygon.ts │ │ ├── arbitrum.ts │ │ └── mainnet.ts │ ├── styles │ │ ├── globals.css │ │ └── Home.module.css │ └── pages │ │ ├── _document.tsx │ │ ├── _app.tsx │ │ └── index.tsx │ ├── tsconfig.json │ ├── package.json │ └── README.md ├── docs ├── pages │ ├── core │ │ ├── _meta.json │ │ └── index.mdx │ ├── web3modal │ │ ├── _meta.json │ │ └── index.mdx │ ├── _meta.json │ ├── react │ │ ├── _meta.json │ │ ├── hydration.mdx │ │ ├── hooks.mdx │ │ ├── initialize.mdx │ │ └── index.mdx │ └── index.mdx ├── next.config.js ├── next-env.d.ts ├── theme.config.jsx ├── package.json └── tsconfig.json ├── pnpm-workspace.yaml ├── biome.json ├── turbo.json ├── .gitignore ├── .size-limit.json ├── .github └── workflows │ └── size-limit.yml ├── package.json ├── LICENSE └── README.md /packages/vue/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/react/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/solid/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/svelte/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/svelte/.npmrc: -------------------------------------------------------------------------------- 1 | engine-strict=true 2 | -------------------------------------------------------------------------------- /packages/svelte/.npmrc: -------------------------------------------------------------------------------- 1 | engine-strict=true 2 | -------------------------------------------------------------------------------- /docs/pages/core/_meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "index": "Overview" 3 | } -------------------------------------------------------------------------------- /docs/pages/web3modal/_meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "index": "Overview" 3 | } -------------------------------------------------------------------------------- /examples/html/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /examples/vue/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /packages/connectors/metamask/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | .env -------------------------------------------------------------------------------- /examples/solid/src/vite-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /packages/connectors/walletconnect/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | .env -------------------------------------------------------------------------------- /examples/react/.env.local.example: -------------------------------------------------------------------------------- 1 | NEXT_PUBLIC_PROJECT_ID=WalletConnect_PROJECT_ID -------------------------------------------------------------------------------- /examples/react/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "next/core-web-vitals" 3 | } 4 | -------------------------------------------------------------------------------- /packages/connectors/coinbase/src/index.ts: -------------------------------------------------------------------------------- 1 | export { Coinbase } from './connector' 2 | -------------------------------------------------------------------------------- /packages/connectors/metamask/src/index.ts: -------------------------------------------------------------------------------- 1 | export { MetaMask } from './connector' 2 | -------------------------------------------------------------------------------- /packages/core/src/constants/index.ts: -------------------------------------------------------------------------------- 1 | export const KEY_WALLET = 'w3:connected_wallet' 2 | -------------------------------------------------------------------------------- /packages/react/src/constants/index.ts: -------------------------------------------------------------------------------- 1 | export const KEY_WALLET = 'w3:connected_wallet' 2 | -------------------------------------------------------------------------------- /pnpm-workspace.yaml: -------------------------------------------------------------------------------- 1 | packages: 2 | - packages/** 3 | - examples/** 4 | - docs 5 | - "!**/.next/**" -------------------------------------------------------------------------------- /examples/svelte/src/lib/index.ts: -------------------------------------------------------------------------------- 1 | // place files you want to import through the `$lib` alias in this folder. 2 | -------------------------------------------------------------------------------- /packages/core/src/utils/index.ts: -------------------------------------------------------------------------------- 1 | export { catchError } from './error' 2 | export { clearW3 } from './clear' 3 | -------------------------------------------------------------------------------- /examples/react/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/glitch-txs/w3vm/HEAD/examples/react/public/favicon.ico -------------------------------------------------------------------------------- /examples/react/public/wallet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/glitch-txs/w3vm/HEAD/examples/react/public/wallet.png -------------------------------------------------------------------------------- /examples/svelte/static/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/glitch-txs/w3vm/HEAD/examples/svelte/static/favicon.png -------------------------------------------------------------------------------- /examples/vue/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"] 3 | } 4 | -------------------------------------------------------------------------------- /packages/core/src/connectors/index.ts: -------------------------------------------------------------------------------- 1 | export { EIP6963Connector } from './EIP6963' 2 | export { Injected } from './injected' 3 | -------------------------------------------------------------------------------- /docs/pages/_meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "index": "Overview", 3 | "react": "React", 4 | "core": "Core", 5 | "web3modal": "Web3Modal Adapter" 6 | } -------------------------------------------------------------------------------- /docs/pages/react/_meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "index": "Overview", 3 | "initialize": "Initialize W3", 4 | "hooks": "Hooks & Function", 5 | "hydration": "SSR and Hydration" 6 | } -------------------------------------------------------------------------------- /examples/react/next.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('next').NextConfig} */ 2 | const nextConfig = { 3 | reactStrictMode: true, 4 | } 5 | 6 | module.exports = nextConfig 7 | -------------------------------------------------------------------------------- /packages/connectors/walletconnect/src/index.ts: -------------------------------------------------------------------------------- 1 | export { WalletConnect } from './connector' 2 | 3 | export { 4 | setWC, 5 | subWC, 6 | getWC, 7 | } from './store' 8 | -------------------------------------------------------------------------------- /docs/next.config.js: -------------------------------------------------------------------------------- 1 | const withNextra = require('nextra')({ 2 | theme: 'nextra-theme-docs', 3 | themeConfig: './theme.config.jsx' 4 | }) 5 | 6 | module.exports = withNextra() -------------------------------------------------------------------------------- /examples/svelte/src/routes/+page.svelte: -------------------------------------------------------------------------------- 1 |

Welcome to SvelteKit

2 |

Visit svelte.dev/docs/kit to read the documentation

3 | -------------------------------------------------------------------------------- /examples/react/src/chains/index.ts: -------------------------------------------------------------------------------- 1 | export { mainnet } from './mainnet' 2 | export { polygon } from './polygon' 3 | export { bsc } from './bsc' 4 | export { arbitrum } from './arbitrum' -------------------------------------------------------------------------------- /examples/solid/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite' 2 | import solid from 'vite-plugin-solid' 3 | 4 | export default defineConfig({ 5 | plugins: [solid()], 6 | }) 7 | -------------------------------------------------------------------------------- /examples/svelte/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { sveltekit } from '@sveltejs/kit/vite'; 2 | import { defineConfig } from 'vite'; 3 | 4 | export default defineConfig({ 5 | plugins: [sveltekit()] 6 | }); 7 | -------------------------------------------------------------------------------- /packages/svelte/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { sveltekit } from '@sveltejs/kit/vite'; 2 | import { defineConfig } from 'vite'; 3 | 4 | export default defineConfig({ 5 | plugins: [sveltekit()] 6 | }); 7 | -------------------------------------------------------------------------------- /examples/vue/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite' 2 | import vue from '@vitejs/plugin-vue' 3 | 4 | // https://vitejs.dev/config/ 5 | export default defineConfig({ 6 | plugins: [vue()], 7 | }) 8 | -------------------------------------------------------------------------------- /packages/solid/src/signals/error.ts: -------------------------------------------------------------------------------- 1 | import { createSignal } from 'solid-js' 2 | import { subW3, getW3 } from '@w3vm/core' 3 | 4 | const [error, setError] = createSignal(getW3.error()) 5 | subW3.error(setError) 6 | 7 | export { error } -------------------------------------------------------------------------------- /docs/next-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | 4 | // NOTE: This file should not be edited 5 | // see https://nextjs.org/docs/basic-features/typescript for more information. 6 | -------------------------------------------------------------------------------- /packages/solid/src/signals/status.ts: -------------------------------------------------------------------------------- 1 | import { createSignal } from 'solid-js' 2 | import { subW3, getW3 } from '@w3vm/core' 3 | 4 | const [status, setStatus] = createSignal(getW3.status()) 5 | subW3.status(setStatus) 6 | 7 | export { status } 8 | -------------------------------------------------------------------------------- /packages/react/src/hooks/getW3Error.tsx: -------------------------------------------------------------------------------- 1 | import { useSyncExternalStore } from 'react' 2 | import { subW3, getW3 } from '@w3vm/core' 3 | 4 | export function getW3Error() { 5 | return useSyncExternalStore(subW3.error, getW3.error, getW3.error) 6 | } 7 | -------------------------------------------------------------------------------- /packages/solid/src/signals/chain.ts: -------------------------------------------------------------------------------- 1 | import { createSignal } from 'solid-js' 2 | import { subW3, getW3 } from '@w3vm/core' 3 | 4 | const [chainId, setChainId] = createSignal(getW3.chainId()) 5 | subW3.chainId(setChainId) 6 | 7 | export { chainId } 8 | -------------------------------------------------------------------------------- /examples/solid/src/index.tsx: -------------------------------------------------------------------------------- 1 | /* @refresh reload */ 2 | import { render } from 'solid-js/web' 3 | 4 | import './index.css' 5 | import App from './App' 6 | 7 | const root = document.getElementById('root') 8 | 9 | render(() => , root!) 10 | -------------------------------------------------------------------------------- /packages/react/src/hooks/getW3Chain.tsx: -------------------------------------------------------------------------------- 1 | import { useSyncExternalStore } from 'react' 2 | import { subW3, getW3 } from '@w3vm/core' 3 | 4 | export function getW3Chain() { 5 | return useSyncExternalStore(subW3.chainId, getW3.chainId, getW3.chainId) 6 | } 7 | -------------------------------------------------------------------------------- /packages/solid/src/signals/address.ts: -------------------------------------------------------------------------------- 1 | import { createSignal } from 'solid-js' 2 | import { subW3, getW3 } from '@w3vm/core' 3 | 4 | const [address, setAddress] = createSignal(getW3.address()) 5 | subW3.address(setAddress) 6 | 7 | export { address } 8 | -------------------------------------------------------------------------------- /packages/core/src/utils/error.ts: -------------------------------------------------------------------------------- 1 | import { setW3 } from '../store/w3store' 2 | import { ProviderRpcError } from '../types' 3 | 4 | export function catchError(e: Error | ProviderRpcError) { 5 | setW3.error(e) 6 | setW3.status(undefined) 7 | throw e 8 | } 9 | -------------------------------------------------------------------------------- /packages/react/src/hooks/getW3Address.tsx: -------------------------------------------------------------------------------- 1 | import { useSyncExternalStore } from 'react' 2 | import { subW3, getW3 } from '@w3vm/core' 3 | 4 | export function getW3Address() { 5 | return useSyncExternalStore(subW3.address, getW3.address, getW3.address) 6 | } 7 | -------------------------------------------------------------------------------- /packages/core/src/functions/index.ts: -------------------------------------------------------------------------------- 1 | export { 2 | connectW3, 3 | disconnectW3, 4 | } from './connection' 5 | 6 | export { 7 | initEIP6963, 8 | initW3, 9 | _storedWalletExists, 10 | } from './init' 11 | 12 | export { switchChain } from './switchChain' 13 | -------------------------------------------------------------------------------- /packages/solid/src/signals/connectors.ts: -------------------------------------------------------------------------------- 1 | import { createSignal } from 'solid-js' 2 | import { subW3, getW3 } from '@w3vm/core' 3 | 4 | const [connectors, setConnectors] = createSignal(getW3.connectors()) 5 | subW3.connectors(setConnectors) 6 | 7 | export { connectors } -------------------------------------------------------------------------------- /packages/core/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'tsup' 2 | 3 | export default defineConfig({ 4 | entry: ['src/index.ts'], 5 | splitting: true, 6 | format: ['cjs', 'esm'], 7 | target: 'es2021', 8 | clean: true, 9 | bundle: true, 10 | dts: true, 11 | }) 12 | -------------------------------------------------------------------------------- /packages/vue/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'tsup' 2 | 3 | export default defineConfig({ 4 | entry: ['src/index.ts'], 5 | format: ['cjs', 'esm'], 6 | target: 'es2021', 7 | splitting: true, 8 | clean: true, 9 | bundle: true, 10 | dts: true, 11 | }) 12 | -------------------------------------------------------------------------------- /packages/react/src/hooks/getW3Provider.tsx: -------------------------------------------------------------------------------- 1 | import { useSyncExternalStore } from 'react' 2 | import { subW3, getW3 } from '@w3vm/core' 3 | 4 | export function getW3Provider() { 5 | return useSyncExternalStore(subW3.walletProvider, getW3.walletProvider, getW3.walletProvider) 6 | } 7 | -------------------------------------------------------------------------------- /packages/react/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'tsup' 2 | 3 | export default defineConfig({ 4 | entry: ['src/index.ts'], 5 | format: ['cjs', 'esm'], 6 | target: 'es2021', 7 | splitting: true, 8 | clean: true, 9 | bundle: true, 10 | dts: true, 11 | }) 12 | -------------------------------------------------------------------------------- /packages/solid/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'tsup' 2 | 3 | export default defineConfig({ 4 | entry: ['src/index.ts'], 5 | format: ['cjs', 'esm'], 6 | target: 'es2021', 7 | splitting: true, 8 | clean: true, 9 | bundle: true, 10 | dts: true, 11 | }) 12 | -------------------------------------------------------------------------------- /examples/solid/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "skipLibCheck": true, 5 | "module": "ESNext", 6 | "moduleResolution": "bundler", 7 | "allowSyntheticDefaultImports": true 8 | }, 9 | "include": ["vite.config.ts"] 10 | } 11 | -------------------------------------------------------------------------------- /examples/vue/tsconfig.node.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "composite": true, 4 | "skipLibCheck": true, 5 | "module": "ESNext", 6 | "moduleResolution": "bundler", 7 | "allowSyntheticDefaultImports": true 8 | }, 9 | "include": ["vite.config.ts"] 10 | } 11 | -------------------------------------------------------------------------------- /packages/connectors/coinbase/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'tsup' 2 | 3 | export default defineConfig({ 4 | entry: ['src/index.ts'], 5 | splitting: true, 6 | format: ['cjs', 'esm'], 7 | target: 'es2021', 8 | clean: true, 9 | bundle: true, 10 | dts: true, 11 | }) 12 | -------------------------------------------------------------------------------- /packages/connectors/metamask/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'tsup' 2 | 3 | export default defineConfig({ 4 | entry: ['src/index.ts'], 5 | splitting: true, 6 | format: ['cjs', 'esm'], 7 | target: 'es2021', 8 | clean: true, 9 | bundle: true, 10 | dts: true, 11 | }) 12 | -------------------------------------------------------------------------------- /packages/solid/src/signals/provider.ts: -------------------------------------------------------------------------------- 1 | import { createSignal } from 'solid-js' 2 | import { subW3, getW3 } from '@w3vm/core' 3 | 4 | const [walletProvider, setWalletProvider] = createSignal(getW3.walletProvider()) 5 | subW3.walletProvider(setWalletProvider) 6 | 7 | export { walletProvider } 8 | -------------------------------------------------------------------------------- /packages/connectors/walletconnect/tsup.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'tsup' 2 | 3 | export default defineConfig({ 4 | entry: ['src/index.ts'], 5 | splitting: true, 6 | format: ['cjs', 'esm'], 7 | target: 'es2021', 8 | clean: true, 9 | bundle: true, 10 | dts: true, 11 | }) 12 | -------------------------------------------------------------------------------- /examples/react/src/styles/globals.css: -------------------------------------------------------------------------------- 1 | * { 2 | box-sizing: border-box; 3 | padding: 0; 4 | margin: 0; 5 | } 6 | 7 | body { 8 | color: #fff; 9 | background: #131313; 10 | min-height: 100vh; 11 | width: 100%; 12 | } 13 | 14 | a { 15 | color: inherit; 16 | text-decoration: none; 17 | } -------------------------------------------------------------------------------- /packages/vue/src/composables/chain.ts: -------------------------------------------------------------------------------- 1 | import { ref } from 'vue' 2 | import { subW3, getW3 } from '@w3vm/core' 3 | 4 | export const chainId = ref(getW3.chainId()) 5 | 6 | function onChainId(_chainId: number | undefined) { 7 | chainId.value = _chainId 8 | } 9 | 10 | subW3.chainId(onChainId) 11 | -------------------------------------------------------------------------------- /packages/vue/src/composables/address.ts: -------------------------------------------------------------------------------- 1 | import { ref } from 'vue' 2 | import { subW3, getW3 } from '@w3vm/core' 3 | 4 | export const address = ref(getW3.address()) 5 | 6 | function onAddress(_address: string | undefined) { 7 | address.value = _address 8 | } 9 | 10 | subW3.address(onAddress) 11 | -------------------------------------------------------------------------------- /examples/react/src/pages/_document.tsx: -------------------------------------------------------------------------------- 1 | import { Html, Head, Main, NextScript } from 'next/document' 2 | 3 | export default function Document() { 4 | return ( 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | ) 13 | } 14 | -------------------------------------------------------------------------------- /examples/svelte/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | 3 | # Output 4 | .output 5 | .vercel 6 | .netlify 7 | .wrangler 8 | /.svelte-kit 9 | /build 10 | 11 | # OS 12 | .DS_Store 13 | Thumbs.db 14 | 15 | # Env 16 | .env 17 | .env.* 18 | !.env.example 19 | !.env.test 20 | 21 | # Vite 22 | vite.config.js.timestamp-* 23 | vite.config.ts.timestamp-* 24 | -------------------------------------------------------------------------------- /packages/vue/src/composables/connectors.ts: -------------------------------------------------------------------------------- 1 | import { ref } from 'vue' 2 | import { subW3, getW3, type Injected } from '@w3vm/core' 3 | 4 | export const connectors = ref(getW3.connectors()) 5 | 6 | function onConnectors(_connectors: Injected[]) { 7 | connectors.value = _connectors 8 | } 9 | 10 | subW3.connectors(onConnectors) 11 | -------------------------------------------------------------------------------- /packages/svelte/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | 3 | # Output 4 | .output 5 | .vercel 6 | .netlify 7 | .wrangler 8 | /.svelte-kit 9 | /build 10 | /dist 11 | 12 | # OS 13 | .DS_Store 14 | Thumbs.db 15 | 16 | # Env 17 | .env 18 | .env.* 19 | !.env.example 20 | !.env.test 21 | 22 | # Vite 23 | vite.config.js.timestamp-* 24 | vite.config.ts.timestamp-* 25 | -------------------------------------------------------------------------------- /examples/svelte/src/app.d.ts: -------------------------------------------------------------------------------- 1 | // See https://svelte.dev/docs/kit/types#app.d.ts 2 | // for information about these interfaces 3 | declare global { 4 | namespace App { 5 | // interface Error {} 6 | // interface Locals {} 7 | // interface PageData {} 8 | // interface PageState {} 9 | // interface Platform {} 10 | } 11 | } 12 | 13 | export {}; 14 | -------------------------------------------------------------------------------- /packages/vue/src/composables/error.ts: -------------------------------------------------------------------------------- 1 | import { ref } from 'vue' 2 | import { subW3, getW3, type ProviderRpcError } from '@w3vm/core' 3 | 4 | export const error = ref(getW3.error()) 5 | 6 | function onError(_error: Error | ProviderRpcError | undefined) { 7 | error.value = _error 8 | } 9 | 10 | subW3.error(onError) 11 | -------------------------------------------------------------------------------- /packages/vue/src/composables/provider.ts: -------------------------------------------------------------------------------- 1 | import { ref } from 'vue' 2 | import { subW3, getW3, type Provider } from '@w3vm/core' 3 | 4 | export const walletProvider = ref(getW3.walletProvider()) 5 | 6 | function onWalletProvider(_provider: Provider | undefined) { 7 | walletProvider.value = _provider 8 | } 9 | 10 | subW3.walletProvider(onWalletProvider) 11 | -------------------------------------------------------------------------------- /examples/vue/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /examples/react/src/chains/bsc.ts: -------------------------------------------------------------------------------- 1 | import { Chain } from "@w3vm/react"; 2 | 3 | export const bsc: Chain = { 4 | chainId:'0x38', 5 | chainName: 'Smart Chain', 6 | nativeCurrency:{ 7 | name: 'BNB', 8 | symbol: 'BNB', 9 | decimals: 18, 10 | }, 11 | rpcUrls:['https://bsc-dataseed1.binance.org/'], 12 | blockExplorerUrls: ['https://bscscan.com'], 13 | iconUrls: [''] 14 | } -------------------------------------------------------------------------------- /examples/react/src/chains/polygon.ts: -------------------------------------------------------------------------------- 1 | import { Chain } from "@w3vm/react"; 2 | 3 | export const polygon: Chain = { 4 | chainName: 'Polygon', 5 | chainId:'0x89', 6 | nativeCurrency:{ 7 | name: 'MATIC', 8 | symbol: 'MATIC', 9 | decimals: 18, 10 | }, 11 | rpcUrls:['https://polygon-rpc.com/'], 12 | blockExplorerUrls:['https://polygonscan.com/'], 13 | iconUrls:[''] 14 | } -------------------------------------------------------------------------------- /examples/solid/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /examples/react/src/chains/arbitrum.ts: -------------------------------------------------------------------------------- 1 | import { Chain } from "@w3vm/react"; 2 | 3 | export const arbitrum: Chain = { 4 | chainName: 'Arbitrum One', 5 | chainId:'0xA4B1', 6 | nativeCurrency:{ 7 | name: 'ETH', 8 | symbol: 'ETH', 9 | decimals: 18, 10 | }, 11 | rpcUrls:['https://arb1.arbitrum.io/rpc'], 12 | blockExplorerUrls:['https://arbiscan.io'], 13 | iconUrls:[''] 14 | } -------------------------------------------------------------------------------- /examples/react/src/chains/mainnet.ts: -------------------------------------------------------------------------------- 1 | import { Chain } from "@w3vm/react"; 2 | 3 | export const mainnet: Chain = { 4 | chainName: 'Ethereum Mainnet', 5 | chainId: '0x1', 6 | nativeCurrency:{ 7 | name: 'ETH', 8 | symbol: 'ETH', 9 | decimals: 18, 10 | }, 11 | rpcUrls:['https://eth.llamarpc.com'], 12 | blockExplorerUrls:['https://etherscan.io/'], 13 | iconUrls:[''] 14 | } -------------------------------------------------------------------------------- /biome.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://biomejs.dev/schemas/1.4.1/schema.json", 3 | "organizeImports": { 4 | "enabled": false 5 | }, 6 | "linter": { 7 | "enabled": true, 8 | "rules": { 9 | "recommended": true 10 | } 11 | }, 12 | "javascript": { 13 | "formatter": { 14 | "semicolons": "asNeeded", 15 | "quoteStyle":"single", 16 | "lineWidth": 120 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/vue/src/composables/status.ts: -------------------------------------------------------------------------------- 1 | import { ref } from 'vue' 2 | import { subW3, getW3 } from '@w3vm/core' 3 | 4 | type Status = 'Initializing' | 'Connecting' | 'Disconnecting' | 'Loading' | 'GeneratingURI' | undefined 5 | 6 | export const status = ref(getW3.status()) 7 | 8 | function onStatus(_provider: Status) { 9 | status.value = _provider 10 | } 11 | 12 | subW3.status(onStatus) 13 | -------------------------------------------------------------------------------- /examples/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Vite + TS 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /examples/html/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "html", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "tsc && vite build", 9 | "preview": "vite preview" 10 | }, 11 | "devDependencies": { 12 | "typescript": "^5.0.2", 13 | "vite": "^4.4.5" 14 | }, 15 | "dependencies": { 16 | "@w3vm/core": "workspace:*" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /examples/svelte/src/app.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | %sveltekit.head% 8 | 9 | 10 |
%sveltekit.body%
11 | 12 | 13 | -------------------------------------------------------------------------------- /packages/core/src/utils/clear.ts: -------------------------------------------------------------------------------- 1 | import { KEY_WALLET } from '../constants' 2 | import { setW3 } from '../store/w3store' 3 | 4 | export function clearW3(id?: string) { 5 | if (typeof id === 'undefined' || localStorage.getItem(KEY_WALLET) === id) { 6 | localStorage.removeItem(KEY_WALLET) 7 | setW3.address(undefined), setW3.chainId(undefined) 8 | setW3.walletProvider(undefined), setW3.status(undefined) 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/svelte/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./.svelte-kit/tsconfig.json", 3 | "compilerOptions": { 4 | "allowJs": true, 5 | "checkJs": true, 6 | "esModuleInterop": true, 7 | "forceConsistentCasingInFileNames": true, 8 | "resolveJsonModule": true, 9 | "skipLibCheck": true, 10 | "sourceMap": true, 11 | "strict": true, 12 | "module": "NodeNext", 13 | "moduleResolution": "NodeNext" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /packages/react/src/hooks/useConnect.tsx: -------------------------------------------------------------------------------- 1 | import { useSyncExternalStore } from 'react' 2 | import { subW3, getW3, connectW3, disconnectW3 } from '@w3vm/core' 3 | 4 | export function useConnect() { 5 | const connectors = useSyncExternalStore(subW3.connectors, getW3.connectors, getW3.connectors) 6 | const status = useSyncExternalStore(subW3.status, getW3.status, getW3.status) 7 | return { connectors, connectW3, disconnectW3, status } 8 | } 9 | -------------------------------------------------------------------------------- /examples/vue/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Vite + Vue + TS 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /turbo.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://turborepo.org/schema.json", 3 | "pipeline": { 4 | "build": { 5 | "dependsOn": ["^build"], 6 | "outputs": [".next/**", "!.next/cache/**", "dist/**"] 7 | }, 8 | "start": { 9 | "dependsOn": ["^build"], 10 | "cache": false 11 | }, 12 | "dev": { 13 | "cache": false 14 | }, 15 | "clean": { 16 | "cache": false 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /examples/solid/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Vite + Solid + TS 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /docs/theme.config.jsx: -------------------------------------------------------------------------------- 1 | export default { 2 | logo: W3Vm, 3 | project: { 4 | link: 'https://github.com/ronin-builders/w3vm' 5 | }, 6 | head: ( 7 | <> 8 | W3Vm 9 | 10 | 11 | 12 | 13 | ) 14 | } -------------------------------------------------------------------------------- /packages/connectors/walletconnect/src/store/index.ts: -------------------------------------------------------------------------------- 1 | import { createStore } from 'vanilla-cafe' 2 | 3 | interface WalletConnectStore { 4 | /** 5 | * WalletConnect URI 6 | */ 7 | uri: string 8 | /** 9 | * Last session update state 10 | */ 11 | sessionEvent: unknown 12 | } 13 | 14 | export const { 15 | set: setWC, 16 | sub: subWC, 17 | get: getWC, 18 | } = createStore({ 19 | uri: '', 20 | sessionEvent: undefined, 21 | }) 22 | -------------------------------------------------------------------------------- /docs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "docs", 3 | "scripts": { 4 | "dev": "next dev", 5 | "build": "next build", 6 | "start": "next start", 7 | "clean": "rm -rf .next && rm -rf .turbo" 8 | }, 9 | "dependencies": { 10 | "next": "^13.5.2", 11 | "nextra": "^2.12.3", 12 | "nextra-theme-docs": "^2.12.3", 13 | "react": "^18.2.0", 14 | "react-dom": "^18.2.0" 15 | }, 16 | "devDependencies": { 17 | "@types/node": "20.8.3", 18 | "typescript": "5.2.2" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /examples/vue/src/assets/vue.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/solid/src/App.css: -------------------------------------------------------------------------------- 1 | #root { 2 | max-width: 1280px; 3 | margin: 0 auto; 4 | padding: 2rem; 5 | text-align: center; 6 | } 7 | 8 | .logo { 9 | height: 6em; 10 | padding: 1.5em; 11 | will-change: filter; 12 | transition: filter 300ms; 13 | } 14 | .logo:hover { 15 | filter: drop-shadow(0 0 2em #646cffaa); 16 | } 17 | .logo.solid:hover { 18 | filter: drop-shadow(0 0 2em #61dafbaa); 19 | } 20 | 21 | .card { 22 | padding: 2em; 23 | } 24 | 25 | .read-the-docs { 26 | color: #888; 27 | } 28 | -------------------------------------------------------------------------------- /examples/vue/src/main.ts: -------------------------------------------------------------------------------- 1 | import { createApp } from 'vue' 2 | import './style.css' 3 | import App from './App.vue' 4 | 5 | import { initW3, Injected } from '@w3vm/vue' 6 | import { WalletConnect } from '@w3vm/walletconnect' 7 | 8 | const projectId = 'cdbd18f9f96172be74c3e351ce99b908' 9 | 10 | initW3({ 11 | connectors: [ 12 | new Injected(), 13 | new WalletConnect({ 14 | projectId, 15 | showQrModal: true, 16 | chains:[1] 17 | }) 18 | ] 19 | }) 20 | 21 | createApp(App).mount('#app') 22 | -------------------------------------------------------------------------------- /packages/react/src/index.ts: -------------------------------------------------------------------------------- 1 | export { getW3Address } from './hooks/getW3Address' 2 | export { getW3Chain } from './hooks/getW3Chain' 3 | export { getW3Provider } from './hooks/getW3Provider' 4 | export { useConnect } from './hooks/useConnect' 5 | export { getW3Error } from './hooks/getW3Error' 6 | export { W3 } from './W3' 7 | 8 | export { 9 | getW3, 10 | setW3, 11 | subW3, 12 | Injected, 13 | initEIP6963, 14 | initW3, 15 | } from '@w3vm/core' 16 | 17 | export type { 18 | Chain, 19 | Provider, 20 | EIP1193Provider, 21 | ProviderRpcError, 22 | } from '@w3vm/core' 23 | -------------------------------------------------------------------------------- /examples/solid/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "w3vm-solid", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "tsc && vite build", 9 | "preview": "vite preview" 10 | }, 11 | "dependencies": { 12 | "@w3vm/core": "workspace:*", 13 | "@w3vm/solid": "workspace:*", 14 | "@w3vm/walletconnect": "workspace:*", 15 | "solid-js": "^1.8.7" 16 | }, 17 | "devDependencies": { 18 | "typescript": "^5.2.2", 19 | "vite": "^5.0.8", 20 | "vite-plugin-solid": "^2.8.0" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /examples/vue/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "vue-tsc && vite build", 9 | "preview": "vite preview" 10 | }, 11 | "dependencies": { 12 | "vue": "^3.3.11", 13 | "@w3vm/core": "workspace:*", 14 | "@w3vm/vue": "workspace:*", 15 | "@w3vm/walletconnect": "workspace:*" 16 | }, 17 | "devDependencies": { 18 | "@vitejs/plugin-vue": "^4.5.2", 19 | "typescript": "^5.2.2", 20 | "vite": "^5.0.8", 21 | "vue-tsc": "^1.8.25" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /packages/solid/src/index.ts: -------------------------------------------------------------------------------- 1 | export { error } from './signals/error' 2 | export { address } from './signals/address' 3 | export { chainId } from './signals/chain' 4 | export { walletProvider } from './signals/provider' 5 | export { status } from './signals/status' 6 | export { connectors } from './signals/connectors' 7 | 8 | export { 9 | getW3, 10 | setW3, 11 | subW3, 12 | Injected, 13 | initEIP6963, 14 | initW3, 15 | connectW3, 16 | disconnectW3, 17 | } from '@w3vm/core' 18 | 19 | export type { 20 | Chain, 21 | Provider, 22 | EIP1193Provider, 23 | ProviderRpcError, 24 | } from '@w3vm/core' 25 | -------------------------------------------------------------------------------- /packages/vue/src/index.ts: -------------------------------------------------------------------------------- 1 | export { error } from './composables/error' 2 | export { address } from './composables/address' 3 | export { chainId } from './composables/chain' 4 | export { walletProvider } from './composables/provider' 5 | export { status } from './composables/status' 6 | export { connectors } from './composables/connectors' 7 | 8 | export { 9 | getW3, 10 | setW3, 11 | subW3, 12 | Injected, 13 | initEIP6963, 14 | initW3, 15 | connectW3, 16 | disconnectW3, 17 | } from '@w3vm/core' 18 | 19 | export type { 20 | Chain, 21 | Provider, 22 | EIP1193Provider, 23 | ProviderRpcError, 24 | } from '@w3vm/core' 25 | -------------------------------------------------------------------------------- /docs/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "lib": [ 4 | "dom", 5 | "dom.iterable", 6 | "esnext" 7 | ], 8 | "allowJs": true, 9 | "skipLibCheck": true, 10 | "strict": false, 11 | "noEmit": true, 12 | "incremental": true, 13 | "esModuleInterop": true, 14 | "module": "esnext", 15 | "moduleResolution": "node", 16 | "resolveJsonModule": true, 17 | "isolatedModules": true, 18 | "jsx": "preserve" 19 | }, 20 | "include": [ 21 | "next-env.d.ts", 22 | "**/*.ts", 23 | "**/*.tsx" 24 | ], 25 | "exclude": [ 26 | "node_modules" 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /packages/core/src/index.ts: -------------------------------------------------------------------------------- 1 | export { getW3, setW3, subW3 } from './store/w3store' 2 | 3 | export { 4 | Injected, 5 | EIP6963Connector, 6 | } from './connectors' 7 | 8 | export { 9 | connectW3, 10 | disconnectW3, 11 | initEIP6963, 12 | initW3, 13 | switchChain, 14 | _storedWalletExists, 15 | } from './functions' 16 | 17 | export type { 18 | Chain, 19 | Provider, 20 | EIP1193Provider, 21 | ProviderRpcError, 22 | Connector, 23 | RequestArguments, 24 | } from './types' 25 | 26 | export { 27 | catchError as _catchError, 28 | clearW3 as _clearW3, 29 | } from './utils' 30 | 31 | export { KEY_WALLET as _KEY_WALLET } from './constants' 32 | -------------------------------------------------------------------------------- /examples/html/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "useDefineForClassFields": true, 5 | "module": "ESNext", 6 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 7 | "skipLibCheck": true, 8 | 9 | /* Bundler mode */ 10 | "moduleResolution": "bundler", 11 | "allowImportingTsExtensions": true, 12 | "resolveJsonModule": true, 13 | "isolatedModules": true, 14 | "noEmit": true, 15 | 16 | /* Linting */ 17 | "strict": true, 18 | "noUnusedLocals": true, 19 | "noUnusedParameters": true, 20 | "noFallthroughCasesInSwitch": true 21 | }, 22 | "include": ["src"] 23 | } 24 | -------------------------------------------------------------------------------- /examples/vue/src/App.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 26 | -------------------------------------------------------------------------------- /examples/react/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": ["dom", "dom.iterable", "esnext"], 5 | "allowJs": true, 6 | "skipLibCheck": true, 7 | "strict": true, 8 | "forceConsistentCasingInFileNames": true, 9 | "noEmit": true, 10 | "esModuleInterop": true, 11 | "module": "esnext", 12 | "moduleResolution": "node", 13 | "resolveJsonModule": true, 14 | "isolatedModules": true, 15 | "jsx": "preserve", 16 | "incremental": true, 17 | "paths": { 18 | "@/*": ["./src/*"] 19 | } 20 | }, 21 | "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], 22 | "exclude": ["node_modules"] 23 | } 24 | -------------------------------------------------------------------------------- /packages/core/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2016", 4 | /* Modules */ 5 | "module": "esnext", 6 | "moduleResolution": "node", 7 | 8 | /* Emit */ 9 | "declaration": true, 10 | "noEmit": true, 11 | "esModuleInterop": true, 12 | "forceConsistentCasingInFileNames": true, 13 | "lib": ["es2019", "es2017", "dom"], 14 | "noImplicitAny": true, 15 | "noUnusedLocals": true, 16 | // "noUnusedParameters": true, 17 | "strictNullChecks": true, 18 | 19 | /* Type Checking */ 20 | "strict": true, 21 | "noUncheckedIndexedAccess": true, 22 | 23 | /* Completeness */ 24 | "skipLibCheck": true 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | 3 | # next.js 4 | **/.next/ 5 | **/out/ 6 | 7 | # testing 8 | **/coverage 9 | 10 | # production 11 | **/build 12 | .turbo 13 | 14 | # misc 15 | .DS_Store 16 | *.pem 17 | 18 | # Logs 19 | logs 20 | *.log 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | pnpm-debug.log* 25 | lerna-debug.log* 26 | 27 | **/dist 28 | **/dist-ssr 29 | *.local 30 | 31 | # Editor directories and files 32 | .vscode/* 33 | !.vscode/extensions.json 34 | .idea 35 | .DS_Store 36 | *.suo 37 | *.ntvs* 38 | *.njsproj 39 | *.sln 40 | *.sw? 41 | 42 | # local env files 43 | .env*.local 44 | .env 45 | 46 | # vercel 47 | .vercel 48 | 49 | # typescript 50 | *.tsbuildinfo 51 | next-env.d.ts 52 | -------------------------------------------------------------------------------- /packages/connectors/coinbase/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2016", 4 | /* Modules */ 5 | "module": "esnext", 6 | "moduleResolution": "node", 7 | 8 | /* Emit */ 9 | "declaration": true, 10 | "noEmit": true, 11 | "esModuleInterop": true, 12 | "forceConsistentCasingInFileNames": true, 13 | "lib": ["es2019", "es2017", "dom"], 14 | "noImplicitAny": true, 15 | "noUnusedLocals": true, 16 | // "noUnusedParameters": true, 17 | "strictNullChecks": true, 18 | 19 | /* Type Checking */ 20 | "strict": true, 21 | "noUncheckedIndexedAccess": true, 22 | 23 | /* Completeness */ 24 | "skipLibCheck": true 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /packages/connectors/metamask/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2016", 4 | /* Modules */ 5 | "module": "esnext", 6 | "moduleResolution": "node", 7 | 8 | /* Emit */ 9 | "declaration": true, 10 | "noEmit": true, 11 | "esModuleInterop": true, 12 | "forceConsistentCasingInFileNames": true, 13 | "lib": ["es2019", "es2017", "dom"], 14 | "noImplicitAny": true, 15 | "noUnusedLocals": true, 16 | // "noUnusedParameters": true, 17 | "strictNullChecks": true, 18 | 19 | /* Type Checking */ 20 | "strict": true, 21 | "noUncheckedIndexedAccess": true, 22 | 23 | /* Completeness */ 24 | "skipLibCheck": true 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /packages/connectors/walletconnect/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2016", 4 | /* Modules */ 5 | "module": "esnext", 6 | "moduleResolution": "node", 7 | 8 | /* Emit */ 9 | "declaration": true, 10 | "noEmit": true, 11 | "esModuleInterop": true, 12 | "forceConsistentCasingInFileNames": true, 13 | "lib": ["es2019", "es2017", "dom"], 14 | "noImplicitAny": true, 15 | "noUnusedLocals": true, 16 | // "noUnusedParameters": true, 17 | "strictNullChecks": true, 18 | 19 | /* Type Checking */ 20 | "strict": true, 21 | "noUncheckedIndexedAccess": true, 22 | 23 | /* Completeness */ 24 | "skipLibCheck": true 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /.size-limit.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "Core", 4 | "path": "packages/core/dist/index.js", 5 | "import" : "*" 6 | }, 7 | { 8 | "name": "WalletConnect", 9 | "path": "packages/connectors/walletconnect/dist/index.js", 10 | "import" : "*" 11 | }, 12 | { 13 | "name": "Solid", 14 | "path": "packages/solid/dist/index.js", 15 | "import" : "*" 16 | }, 17 | { 18 | "name": "Svelte", 19 | "path": "packages/svelte/dist/index.js", 20 | "import" : "*" 21 | }, 22 | { 23 | "name": "React", 24 | "path": "packages/react/dist/index.js", 25 | "import" : "*" 26 | }, 27 | { 28 | "name": "Vue", 29 | "path": "packages/vue/dist/index.js", 30 | "import" : "*" 31 | } 32 | ] -------------------------------------------------------------------------------- /.github/workflows/size-limit.yml: -------------------------------------------------------------------------------- 1 | name: "Measuring Bundle Size" 2 | on: 3 | pull_request: 4 | branches: 5 | - main 6 | permissions: 7 | pull-requests: write 8 | jobs: 9 | size: 10 | runs-on: ubuntu-latest 11 | env: 12 | CI_JOB_NUMBER: 1 13 | steps: 14 | - uses: actions/checkout@v4 15 | - uses: pnpm/action-setup@v3 16 | with: 17 | version: 8 18 | - uses: actions/setup-node@v4 19 | with: 20 | node-version: '20' 21 | cache: 'pnpm' 22 | - run: pnpm install 23 | - uses: actions/checkout@v1 24 | - uses: andresz1/size-limit-action@v1 25 | with: 26 | github_token: ${{ secrets.GITHUB_TOKEN }} 27 | build_script: size -------------------------------------------------------------------------------- /examples/svelte/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./.svelte-kit/tsconfig.json", 3 | "compilerOptions": { 4 | "allowJs": true, 5 | "checkJs": true, 6 | "esModuleInterop": true, 7 | "forceConsistentCasingInFileNames": true, 8 | "resolveJsonModule": true, 9 | "skipLibCheck": true, 10 | "sourceMap": true, 11 | "strict": true, 12 | "moduleResolution": "bundler" 13 | } 14 | // Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias 15 | // except $lib which is handled by https://svelte.dev/docs/kit/configuration#files 16 | // 17 | // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes 18 | // from the referenced tsconfig.json - TypeScript does not merge them in 19 | } 20 | -------------------------------------------------------------------------------- /examples/svelte/svelte.config.js: -------------------------------------------------------------------------------- 1 | import adapter from '@sveltejs/adapter-auto'; 2 | import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'; 3 | 4 | /** @type {import('@sveltejs/kit').Config} */ 5 | const config = { 6 | // Consult https://svelte.dev/docs/kit/integrations 7 | // for more information about preprocessors 8 | preprocess: vitePreprocess(), 9 | 10 | kit: { 11 | // adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list. 12 | // If your environment is not supported, or you settled on a specific environment, switch out the adapter. 13 | // See https://svelte.dev/docs/kit/adapters for more information about adapters. 14 | adapter: adapter() 15 | } 16 | }; 17 | 18 | export default config; 19 | -------------------------------------------------------------------------------- /packages/svelte/svelte.config.js: -------------------------------------------------------------------------------- 1 | import adapter from '@sveltejs/adapter-auto'; 2 | import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'; 3 | 4 | /** @type {import('@sveltejs/kit').Config} */ 5 | const config = { 6 | // Consult https://svelte.dev/docs/kit/integrations 7 | // for more information about preprocessors 8 | preprocess: vitePreprocess(), 9 | 10 | kit: { 11 | // adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list. 12 | // If your environment is not supported, or you settled on a specific environment, switch out the adapter. 13 | // See https://svelte.dev/docs/kit/adapters for more information about adapters. 14 | adapter: adapter() 15 | } 16 | }; 17 | 18 | export default config; 19 | -------------------------------------------------------------------------------- /packages/react/src/W3.tsx: -------------------------------------------------------------------------------- 1 | import { useEffect } from 'react' 2 | import { Connector, initEIP6963, setW3, _storedWalletExists } from '@w3vm/core' 3 | import { KEY_WALLET } from './constants' 4 | 5 | let init = 0 6 | 7 | export function W3({ connectors }: { connectors?: Connector[] }): null { 8 | useEffect(() => { 9 | if (init === 0 && connectors) { 10 | initEIP6963() 11 | for (let w of connectors) w.init() 12 | 13 | if (!localStorage.getItem(KEY_WALLET)) { 14 | setW3.status(undefined) 15 | } else { 16 | setTimeout(_storedWalletExists, 1000) 17 | } 18 | } 19 | 20 | // This component must be mounted only once in the whole application's lifecycle 21 | return () => { 22 | init = 1 23 | } 24 | }, []) 25 | 26 | return null 27 | } 28 | -------------------------------------------------------------------------------- /examples/solid/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "useDefineForClassFields": true, 5 | "module": "ESNext", 6 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 7 | "skipLibCheck": true, 8 | 9 | /* Bundler mode */ 10 | "moduleResolution": "bundler", 11 | "allowImportingTsExtensions": true, 12 | "resolveJsonModule": true, 13 | "isolatedModules": true, 14 | "noEmit": true, 15 | "jsx": "preserve", 16 | "jsxImportSource": "solid-js", 17 | 18 | /* Linting */ 19 | "strict": true, 20 | "noUnusedLocals": true, 21 | "noUnusedParameters": true, 22 | "noFallthroughCasesInSwitch": true 23 | }, 24 | "include": ["src"], 25 | "references": [{ "path": "./tsconfig.node.json" }] 26 | } 27 | -------------------------------------------------------------------------------- /examples/vue/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2020", 4 | "useDefineForClassFields": true, 5 | "module": "ESNext", 6 | "lib": ["ES2020", "DOM", "DOM.Iterable"], 7 | "skipLibCheck": true, 8 | 9 | /* Bundler mode */ 10 | "moduleResolution": "bundler", 11 | "allowImportingTsExtensions": true, 12 | "resolveJsonModule": true, 13 | "isolatedModules": true, 14 | "noEmit": true, 15 | "jsx": "preserve", 16 | 17 | /* Linting */ 18 | "strict": true, 19 | "noUnusedLocals": true, 20 | "noUnusedParameters": true, 21 | "noFallthroughCasesInSwitch": true 22 | }, 23 | "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"], 24 | "references": [{ "path": "./tsconfig.node.json" }] 25 | } 26 | -------------------------------------------------------------------------------- /packages/core/src/functions/connection.ts: -------------------------------------------------------------------------------- 1 | import { KEY_WALLET } from '../constants' 2 | import { getW3, setW3 } from '../store/w3store' 3 | import { Chain, Connector } from '../types' 4 | 5 | /* Connect & Disconnect Functions */ 6 | export async function connectW3({ connector, chain }: { connector: Connector; chain?: Chain | number }): Promise { 7 | if (connector.id === 'walletConnect') setW3.status('GeneratingURI') 8 | await connector.connect({ chain }) 9 | } 10 | 11 | export async function disconnectW3() { 12 | const connectors = getW3.connectors() 13 | const [connector] = connectors.filter((c) => c.id === window?.localStorage.getItem(KEY_WALLET)) 14 | 15 | if (connector) await connector.disconnect() 16 | else for (let c of connectors) c.disconnect() 17 | } 18 | -------------------------------------------------------------------------------- /examples/react/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "next dev", 7 | "build": "next build", 8 | "start": "next start", 9 | "lint": "next lint" 10 | }, 11 | "dependencies": { 12 | "@types/node": "20.2.5", 13 | "@types/react": "18.2.8", 14 | "@types/react-dom": "18.2.4", 15 | "@w3vm/core": "workspace:*", 16 | "@w3vm/coinbase": "workspace:*", 17 | "@w3vm/metamask": "workspace:*", 18 | "@w3vm/react": "workspace:*", 19 | "@w3vm/walletconnect": "workspace:*", 20 | "eslint": "8.41.0", 21 | "eslint-config-next": "13.4.4", 22 | "next": "13.4.4", 23 | "react": "18.2.0", 24 | "react-dom": "18.2.0", 25 | "typescript": "5.1.3" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /examples/svelte/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "svelte", 3 | "private": true, 4 | "version": "0.0.1", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite dev", 8 | "build": "vite build", 9 | "preview": "vite preview", 10 | "prepare": "svelte-kit sync || echo ''", 11 | "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", 12 | "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch" 13 | }, 14 | "dependencies": { 15 | "@w3vm/svelte": "workspace: *" 16 | }, 17 | "devDependencies": { 18 | "@sveltejs/adapter-auto": "^6.0.0", 19 | "@sveltejs/kit": "^2.16.0", 20 | "@sveltejs/vite-plugin-svelte": "^5.0.0", 21 | "svelte": "^5.0.0", 22 | "svelte-check": "^4.0.0", 23 | "typescript": "^5.0.0", 24 | "vite": "^6.2.6" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /examples/html/src/main.ts: -------------------------------------------------------------------------------- 1 | import { initW3, Injected, connectW3, getW3, subW3, disconnectW3 } from '@w3vm/core' 2 | 3 | initW3({ 4 | connectors: [ 5 | new Injected(), 6 | ] 7 | }) 8 | 9 | const btnEl = document.getElementById("connect") 10 | const userEl = document.getElementById("user") 11 | 12 | subW3.address( address => { 13 | if(!btnEl || !userEl) return 14 | if(address){ 15 | btnEl.innerText = "Disconnect" 16 | userEl.innerText = `Address: ${address}` 17 | }else{ 18 | btnEl.innerText = "Connect" 19 | userEl.innerText = "" 20 | } 21 | }) 22 | 23 | btnEl?.addEventListener('click',()=>{ 24 | const address = getW3.address() 25 | if(address){ 26 | disconnectW3() 27 | }else{ 28 | const connectors = getW3.connectors() 29 | connectW3({ connector: connectors[0] }) 30 | } 31 | }) -------------------------------------------------------------------------------- /docs/pages/react/hydration.mdx: -------------------------------------------------------------------------------- 1 | # SSR and Hydration 2 | 3 | If you are **not** using SSR or want to deal with hydration mismatch errors to get a faster first load of W3, you can ignore the SSR flag and remove the W3 component. 4 | 5 | ```tsx 6 | import { initW3, Injected, WalletConnect } from '@w3vm/react' 7 | 8 | /* Icons */ 9 | import walletconnect from 'public/walletconnect.svg' 10 | import wallet from 'public/extension-wallet.png' 11 | 12 | /* WalletConnect Project Id */ 13 | const projectId = 'YOUR_PROJECT_ID' 14 | 15 | initW3({ 16 | connectors: [ 17 | new Injected({ icon: wallet }), 18 | new WalletConnect({ projectId, icon: walletconnect, showQrModal: true }) 19 | ], 20 | chains:[1, 137], 21 | }) 22 | 23 | export default function App({ Component, pageProps }: AppProps) { 24 | return 25 | } 26 | ``` -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "engines": { 4 | "pnpm": ">=8.6.5" 5 | }, 6 | "scripts": { 7 | "preinstall": "npx only-allow pnpm", 8 | "format": "pnpm dlx @biomejs/biome format packages --write", 9 | "build": "turbo run build", 10 | "build:packages": "turbo run build --filter=./packages/**", 11 | "build:web3modal": "turbo run build --filter=next...", 12 | "start:web3modal": "turbo run start --filter=next", 13 | "dev": "turbo run dev --filter=next...", 14 | "build:docs": "turbo run build --filter=docs", 15 | "start:docs": "turbo run start --filter=docs", 16 | "size": "pnpm run build && size-limit --json", 17 | "clean": "turbo run clean --filter=./packages/**" 18 | }, 19 | "devDependencies": { 20 | "@biomejs/biome": "1.4.1", 21 | "@size-limit/preset-big-lib": "11.0.2", 22 | "size-limit": "11.0.2", 23 | "turbo": "^1.10.15" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /examples/react/public/walletconnect.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/pages/index.mdx: -------------------------------------------------------------------------------- 1 | import { Cards, Card } from 'nextra/components' 2 | import { Callout } from 'nextra/components' 3 | 4 | # W3Vm 5 | 6 | W3Vm is an evm **wallet** connectors library for decentralized applications. 7 | It sets up for you a wallet connection infrastructure with a built-in store and React hooks to handle the wallet state and user's sessions. 8 | 9 | 10 | **Compatible with ethers.js, viem and Web3.js** 11 | 12 | 13 | W3Vm consists of 14 | - A Core library that can be used in vanilla JavaScript or any framework 15 | - High level libraries for React or Web3Modal v3. 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /examples/solid/README.md: -------------------------------------------------------------------------------- 1 | ## Usage 2 | 3 | ```bash 4 | $ npm install # or pnpm install or yarn install 5 | ``` 6 | 7 | ### Learn more on the [Solid Website](https://solidjs.com) and come chat with us on our [Discord](https://discord.com/invite/solidjs) 8 | 9 | ## Available Scripts 10 | 11 | In the project directory, you can run: 12 | 13 | ### `npm run dev` 14 | 15 | Runs the app in the development mode.
16 | Open [http://localhost:5173](http://localhost:5173) to view it in the browser. 17 | 18 | ### `npm run build` 19 | 20 | Builds the app for production to the `dist` folder.
21 | It correctly bundles Solid in production mode and optimizes the build for the best performance. 22 | 23 | The build is minified and the filenames include the hashes.
24 | Your app is ready to be deployed! 25 | 26 | ## Deployment 27 | 28 | Learn more about deploying your application with the [documentations](https://vitejs.dev/guide/static-deploy.html) 29 | -------------------------------------------------------------------------------- /examples/solid/src/App.tsx: -------------------------------------------------------------------------------- 1 | import { For } from 'solid-js' 2 | import './App.css' 3 | 4 | import { address, connectors, connectW3, initW3, status } from '@w3vm/solid' 5 | import { WalletConnect } from '@w3vm/walletconnect' 6 | import { effect } from 'solid-js/web' 7 | 8 | function App() { 9 | const projectId = 'YOUR_PROJECT_ID' 10 | 11 | initW3({ 12 | connectors: [ 13 | new WalletConnect({ 14 | projectId, 15 | chains: [1, 137], 16 | showQrModal: true 17 | }) 18 | ] 19 | }) 20 | 21 | effect(()=>{ 22 | console.log(status(), address()) 23 | }) 24 | 25 | return ( 26 | 27 | {connector =>( 28 | 32 | )} 33 | 34 | ) 35 | } 36 | 37 | export default App 38 | -------------------------------------------------------------------------------- /packages/core/src/functions/switchChain.ts: -------------------------------------------------------------------------------- 1 | import { getW3 } from '../store/w3store' 2 | import { Chain } from '../types' 3 | import { catchError } from '../utils' 4 | 5 | export async function switchChain({ chain }: { chain: number | Chain }) { 6 | const provider = getW3.walletProvider() 7 | if (!provider) { 8 | catchError(new Error('While calling switchChain Provider was undefined')) 9 | return 10 | } 11 | const chainId = typeof chain === 'number' ? chain : (chain as Chain)?.chainId 12 | await provider 13 | .request({ 14 | method: 'wallet_switchEthereumChain', 15 | params: [{ chainId: '0x' + chainId.toString(16) }], 16 | }) 17 | .catch(async (er: any) => { 18 | if (typeof chain !== 'number' && (er.code === 4902 || er?.data?.originalError?.code == 4902)) { 19 | await provider 20 | .request({ 21 | method: 'wallet_addEthereumChain', 22 | params: [chain], 23 | }) 24 | .catch(catchError) 25 | } 26 | }) 27 | } 28 | -------------------------------------------------------------------------------- /examples/svelte/README.md: -------------------------------------------------------------------------------- 1 | # sv 2 | 3 | Everything you need to build a Svelte project, powered by [`sv`](https://github.com/sveltejs/cli). 4 | 5 | ## Creating a project 6 | 7 | If you're seeing this, you've probably already done this step. Congrats! 8 | 9 | ```bash 10 | # create a new project in the current directory 11 | npx sv create 12 | 13 | # create a new project in my-app 14 | npx sv create my-app 15 | ``` 16 | 17 | ## Developing 18 | 19 | Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server: 20 | 21 | ```bash 22 | npm run dev 23 | 24 | # or start the server and open the app in a new browser tab 25 | npm run dev -- --open 26 | ``` 27 | 28 | ## Building 29 | 30 | To create a production version of your app: 31 | 32 | ```bash 33 | npm run build 34 | ``` 35 | 36 | You can preview the production build with `npm run preview`. 37 | 38 | > To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment. 39 | -------------------------------------------------------------------------------- /packages/core/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@w3vm/core", 3 | "version": "0.0.4", 4 | "description": "EVM Wallets Library For Decentralized Applications", 5 | "main": "dist/index.js", 6 | "types": "dist/index.d.ts", 7 | "files": [ 8 | "dist" 9 | ], 10 | "scripts": { 11 | "watch": "tsc -w", 12 | "build": "tsup", 13 | "upload": "pnpm run build && pnpm publish", 14 | "clean": "rm -rf .turbo && rm -rf dist" 15 | }, 16 | "type": "module", 17 | "author": "Glitch-txs", 18 | "license": "MIT", 19 | "dependencies": { 20 | "vanilla-cafe": "^0.1.5" 21 | }, 22 | "peerDependencies": { 23 | "typescript": ">=5" 24 | }, 25 | "peerDependenciesMeta": { 26 | "typescript": { 27 | "optional": true 28 | } 29 | }, 30 | "keywords": [ 31 | "wallet", 32 | "eth", 33 | "ethereum", 34 | "wallets", 35 | "web3" 36 | ], 37 | "repository": { 38 | "type": "git", 39 | "url": "https://github.com/w3vm" 40 | }, 41 | "publishConfig": { 42 | "access": "public" 43 | }, 44 | "devDependencies": { 45 | "tsup": "^6.7.0" 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 weth, LLC 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/core/src/connectors/EIP6963.ts: -------------------------------------------------------------------------------- 1 | import { setW3 } from '../store/w3store' 2 | import { EIP6963ProviderDetail } from '../types' 3 | import { KEY_WALLET } from '../constants' 4 | import { Injected } from './injected' 5 | 6 | export class EIP6963Connector extends Injected { 7 | readonly uuid: string 8 | readonly id: string 9 | readonly name: string 10 | icon: any 11 | 12 | constructor({ info, provider }: EIP6963ProviderDetail) { 13 | super() 14 | this.uuid = info.uuid 15 | this.id = info.rdns 16 | this.name = info.name 17 | this.icon = info.icon 18 | this.getProvider = () => provider 19 | this.init() 20 | } 21 | 22 | async init() { 23 | if (window.localStorage.getItem(KEY_WALLET) === this.id) { 24 | const provider = await this.getProvider() 25 | if (!provider) throw new Error('EIP-6963 Provider is undefined') 26 | 27 | const connected = await this.setAccountAndChainId(provider) 28 | if (connected) { 29 | this.addEvents(provider) 30 | setW3.walletProvider(provider) 31 | } else { 32 | window?.localStorage.removeItem(KEY_WALLET) 33 | } 34 | setW3.status(undefined) 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /packages/vue/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@w3vm/vue", 3 | "version": "0.0.0", 4 | "description": "Vue composables for W3Vm", 5 | "main": "dist/index.js", 6 | "types": "dist/index.d.ts", 7 | "files": [ 8 | "dist" 9 | ], 10 | "scripts": { 11 | "build": "tsup", 12 | "up": "pnpm add @w3vm/core@latest", 13 | "upload": "pnpm run build && npm publish --public", 14 | "clean": "rm -rf .turbo && rm -rf dist" 15 | }, 16 | "type": "module", 17 | "author": "glitch-txs", 18 | "license": "MIT", 19 | "peerDependencies": { 20 | "vue": ">=3", 21 | "typescript": ">=5", 22 | "@w3vm/core": "workspace:*" 23 | }, 24 | "peerDependenciesMeta": { 25 | "typescript": { 26 | "optional": true 27 | } 28 | }, 29 | "keywords": [ 30 | "wallet", 31 | "vue", 32 | "sveltekit", 33 | "ethereum", 34 | "wallets", 35 | "web3" 36 | ], 37 | "repository": { 38 | "type": "git", 39 | "url": "https://github.com/w3vm" 40 | }, 41 | "publishConfig": { 42 | "access": "public" 43 | }, 44 | "devDependencies": { 45 | "tsup": "^6.7.0", 46 | "@w3vm/core": "workspace:*" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /packages/solid/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@w3vm/solid", 3 | "version": "0.0.0", 4 | "description": "Solid signals for W3Vm", 5 | "main": "dist/index.js", 6 | "types": "dist/index.d.ts", 7 | "files": [ 8 | "dist" 9 | ], 10 | "scripts": { 11 | "build": "tsup", 12 | "up": "pnpm add @w3vm/core@latest", 13 | "upload": "pnpm run build && npm publish --public", 14 | "clean": "rm -rf .turbo && rm -rf dist" 15 | }, 16 | "type": "module", 17 | "author": "glitch-txs", 18 | "license": "MIT", 19 | "peerDependencies": { 20 | "solid-js": ">=1", 21 | "typescript": ">=5", 22 | "@w3vm/core": "workspace:*" 23 | }, 24 | "peerDependenciesMeta": { 25 | "typescript": { 26 | "optional": true 27 | } 28 | }, 29 | "keywords": [ 30 | "wallet", 31 | "solid", 32 | "signals", 33 | "ethereum", 34 | "wallets", 35 | "web3" 36 | ], 37 | "repository": { 38 | "type": "git", 39 | "url": "https://github.com/w3vm" 40 | }, 41 | "publishConfig": { 42 | "access": "public" 43 | }, 44 | "devDependencies": { 45 | "tsup": "^6.7.0", 46 | "@w3vm/core": "workspace:*" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /packages/connectors/coinbase/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@w3vm/coinbase", 3 | "version": "0.0.4", 4 | "description": "Coinbase connector for W3Vm library", 5 | "author": "Glitch-txs", 6 | "license": "MIT", 7 | "type": "module", 8 | "main": "dist/index.js", 9 | "types": "dist/index.d.ts", 10 | "files": [ 11 | "dist" 12 | ], 13 | "scripts": { 14 | "watch": "tsc -w", 15 | "build": "tsup", 16 | "upload": "npm run build && npm publish --public", 17 | "clean": "rm -rf .turbo && rm -rf dist" 18 | }, 19 | "peerDependencies": { 20 | "@w3vm/core": ">=0", 21 | "typescript": ">=5" 22 | }, 23 | "peerDependenciesMeta": { 24 | "typescript": { 25 | "optional": true 26 | } 27 | }, 28 | "keywords": [ 29 | "wallet", 30 | "eth", 31 | "ethereum", 32 | "coinbase", 33 | "web3" 34 | ], 35 | "repository": { 36 | "type": "git", 37 | "url": "https://github.com/w3vm" 38 | }, 39 | "publishConfig": { 40 | "access": "public" 41 | }, 42 | "devDependencies": { 43 | "tsup": "^6.7.0", 44 | "@w3vm/core": "workspace:*" 45 | }, 46 | "dependencies": { 47 | "@coinbase/wallet-sdk": "3.7.2" 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /examples/react/public/coinbase.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /packages/connectors/metamask/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@w3vm/metamask", 3 | "version": "0.0.5", 4 | "description": "MetaMask SDK connector for W3 EVM library", 5 | "author": "Glitch-txs", 6 | "license": "MIT", 7 | "type": "module", 8 | "main": "dist/index.js", 9 | "types": "dist/index.d.ts", 10 | "files": [ 11 | "dist" 12 | ], 13 | "scripts": { 14 | "watch": "tsc -w", 15 | "build": "tsup", 16 | "upload": "pnpm run build && pnpm publish --public", 17 | "clean": "rm -rf .turbo && rm -rf dist" 18 | }, 19 | "dependencies": { 20 | "@metamask/sdk": "^0.14.1" 21 | }, 22 | "peerDependencies": { 23 | "@w3vm/core": ">=0", 24 | "typescript": ">=5" 25 | }, 26 | "peerDependenciesMeta": { 27 | "typescript": { 28 | "optional": true 29 | } 30 | }, 31 | "keywords": [ 32 | "wallet", 33 | "eth", 34 | "ethereum", 35 | "walletconnect", 36 | "web3" 37 | ], 38 | "repository": { 39 | "type": "git", 40 | "url": "https://github.com/w3vm" 41 | }, 42 | "publishConfig": { 43 | "access": "public" 44 | }, 45 | "devDependencies": { 46 | "tsup": "^6.7.0", 47 | "@w3vm/core": "workspace:*" 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /examples/react/src/pages/_app.tsx: -------------------------------------------------------------------------------- 1 | import '@/styles/globals.css' 2 | import type { AppProps } from 'next/app' 3 | 4 | import { W3, initW3, Injected } from '@w3vm/react' 5 | import { WalletConnect } from '@w3vm/walletconnect' 6 | import { Coinbase } from '@w3vm/coinbase' 7 | import { MetaMask } from '@w3vm/metamask' 8 | 9 | import walletconnect from 'public/walletconnect.svg' 10 | import coinbase from 'public/coinbase.svg' 11 | import metamask from 'public/metamask.svg' 12 | import wallet from 'public/wallet.png' 13 | 14 | const projectId = process.env.NEXT_PUBLIC_PROJECT_ID as string 15 | 16 | const w3props = initW3({ 17 | connectors: [ 18 | new Injected({ icon: wallet }), 19 | new WalletConnect({ 20 | projectId, 21 | icon: walletconnect, 22 | showQrModal: true, 23 | chains:[1] 24 | }), 25 | new Coinbase({ 26 | appName:'Test', 27 | icon: coinbase, 28 | defaultChainId: 1, 29 | defaultJsonRpcUrl:'https://mainnet.infura.io/v3/' 30 | }) 31 | ], 32 | SSR: true, 33 | }) 34 | 35 | export default function App({ Component, pageProps }: AppProps) { 36 | return <> 37 | 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /packages/react/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@w3vm/react", 3 | "version": "0.0.7", 4 | "description": "React Hooks for W3Vm", 5 | "main": "dist/index.js", 6 | "types": "dist/index.d.ts", 7 | "files": [ 8 | "dist" 9 | ], 10 | "scripts": { 11 | "build": "tsup", 12 | "up": "pnpm add @w3vm/core@latest", 13 | "upload": "pnpm run build && npm publish --public", 14 | "clean": "rm -rf .turbo && rm -rf dist" 15 | }, 16 | "type": "module", 17 | "author": "glitch-txs", 18 | "license": "MIT", 19 | "peerDependencies": { 20 | "@types/react": ">=18.2.8", 21 | "react": ">=18.2.0", 22 | "typescript": ">=5", 23 | "@w3vm/core": "workspace:*" 24 | }, 25 | "peerDependenciesMeta": { 26 | "@types/react": { 27 | "optional": true 28 | }, 29 | "typescript": { 30 | "optional": true 31 | } 32 | }, 33 | "keywords": [ 34 | "wallet", 35 | "react", 36 | "next", 37 | "ethereum", 38 | "wallets", 39 | "web3" 40 | ], 41 | "repository": { 42 | "type": "git", 43 | "url": "https://github.com/w3vm" 44 | }, 45 | "publishConfig": { 46 | "access": "public" 47 | }, 48 | "devDependencies": { 49 | "tsup": "^6.7.0", 50 | "@w3vm/core": "workspace:*" 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /packages/core/src/store/w3store.ts: -------------------------------------------------------------------------------- 1 | import { createStore } from 'vanilla-cafe' 2 | import { Chain, Connector, Provider, ProviderRpcError } from '../types' 3 | 4 | interface W3Store { 5 | /** 6 | * Current connection state. Shows if there's an ongoing process. 7 | */ 8 | status?: 'Initializing' | 'Connecting' | 'Disconnecting' | 'Loading' | 'GeneratingURI' 9 | /** 10 | * Connected wallet address, undefined if disconnected. 11 | */ 12 | address?: string 13 | /** 14 | * Connected chain id. 15 | */ 16 | chainId?: number 17 | /** 18 | * Default chain to switch to when connecting. 19 | */ 20 | defaultChain?: Chain | number 21 | /** 22 | * ProviderRpcError: object with an error message and its code. 23 | */ 24 | error?: ProviderRpcError | Error 25 | /** 26 | * Array of connectors instances. 27 | */ 28 | connectors: Connector[] 29 | /** 30 | * extended EIP-1193 provider of the connected wallet. 31 | */ 32 | walletProvider?: Provider 33 | } 34 | 35 | export const { 36 | set: setW3, 37 | sub: subW3, 38 | get: getW3, 39 | } = createStore({ 40 | status: 'Initializing', 41 | address: undefined, 42 | chainId: undefined, 43 | defaultChain: undefined, 44 | error: undefined, 45 | connectors: [], 46 | walletProvider: undefined, 47 | }) 48 | -------------------------------------------------------------------------------- /packages/connectors/walletconnect/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@w3vm/walletconnect", 3 | "version": "0.0.9", 4 | "description": "WalletConnect connector for W3 EVM library", 5 | "author": "Glitch-txs", 6 | "license": "MIT", 7 | "type": "module", 8 | "main": "dist/index.js", 9 | "types": "dist/index.d.ts", 10 | "files": [ 11 | "dist" 12 | ], 13 | "scripts": { 14 | "watch": "tsc -w", 15 | "build": "tsup", 16 | "up": "pnpm add @walletconnect/ethereum-provider@latest @walletconnect/modal@latest", 17 | "upload": "pnpm run build && pnpm publish", 18 | "clean": "rm -rf .turbo && rm -rf dist" 19 | }, 20 | "dependencies": { 21 | "@walletconnect/ethereum-provider": "2.18.0", 22 | "@walletconnect/modal": "2.7.0" 23 | }, 24 | "peerDependencies": { 25 | "@w3vm/core": ">=0", 26 | "typescript": ">=5", 27 | "vanilla-cafe": ">=0" 28 | }, 29 | "peerDependenciesMeta": { 30 | "typescript": { 31 | "optional": true 32 | } 33 | }, 34 | "keywords": [ 35 | "wallet", 36 | "eth", 37 | "ethereum", 38 | "walletconnect", 39 | "web3" 40 | ], 41 | "repository": { 42 | "type": "git", 43 | "url": "https://github.com/w3vm" 44 | }, 45 | "publishConfig": { 46 | "access": "public" 47 | }, 48 | "devDependencies": { 49 | "@w3vm/core": "workspace:*", 50 | "tsup": "^6.7.0" 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /packages/svelte/src/lib/index.svelte.ts: -------------------------------------------------------------------------------- 1 | import { subW3, getW3, type ProviderRpcError, type Provider, Injected } from '@w3vm/core'; 2 | 3 | type Status = 'Initializing' | 'Connecting' | 'Disconnecting' | 'Loading' | 'GeneratingURI' | undefined; 4 | 5 | type W3vm = { 6 | connectors: Injected[] 7 | } 8 | 9 | type Wallet = { 10 | address: string | undefined 11 | provider: Provider | undefined 12 | error: Error | ProviderRpcError | undefined 13 | chainId: number | undefined 14 | status: Status 15 | } 16 | 17 | export const w3vm = $state({ 18 | connectors: getW3.connectors() 19 | }); 20 | 21 | export const wallet = $state({ 22 | address: getW3.address(), 23 | provider: getW3.walletProvider(), 24 | error: getW3.error(), 25 | chainId: getW3.chainId(), 26 | status: getW3.status(), 27 | }); 28 | 29 | subW3.address((newAddress: string | undefined) => { 30 | wallet.address = newAddress; 31 | }); 32 | 33 | subW3.chainId((newChainId: number | undefined) => { 34 | wallet.chainId = newChainId; 35 | }); 36 | 37 | subW3.error((newError: Error | ProviderRpcError | undefined) => { 38 | wallet.error = newError; 39 | }); 40 | 41 | subW3.walletProvider((newProvider: Provider | undefined) => { 42 | wallet.provider = newProvider; 43 | }); 44 | 45 | subW3.status((newStatus: Status) => { 46 | wallet.status = newStatus; 47 | }); 48 | 49 | subW3.connectors((newConnectors: Injected[]) => { 50 | w3vm.connectors = newConnectors; 51 | }); -------------------------------------------------------------------------------- /examples/html/public/vite.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/solid/public/vite.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/vue/public/vite.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/solid/src/index.css: -------------------------------------------------------------------------------- 1 | :root { 2 | font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; 3 | line-height: 1.5; 4 | font-weight: 400; 5 | 6 | color-scheme: light dark; 7 | color: rgba(255, 255, 255, 0.87); 8 | background-color: #242424; 9 | 10 | font-synthesis: none; 11 | text-rendering: optimizeLegibility; 12 | -webkit-font-smoothing: antialiased; 13 | -moz-osx-font-smoothing: grayscale; 14 | } 15 | 16 | a { 17 | font-weight: 500; 18 | color: #646cff; 19 | text-decoration: inherit; 20 | } 21 | a:hover { 22 | color: #535bf2; 23 | } 24 | 25 | body { 26 | margin: 0; 27 | display: flex; 28 | place-items: center; 29 | min-width: 320px; 30 | min-height: 100vh; 31 | } 32 | 33 | h1 { 34 | font-size: 3.2em; 35 | line-height: 1.1; 36 | } 37 | 38 | button { 39 | border-radius: 8px; 40 | border: 1px solid transparent; 41 | padding: 0.6em 1.2em; 42 | font-size: 1em; 43 | font-weight: 500; 44 | font-family: inherit; 45 | background-color: #1a1a1a; 46 | cursor: pointer; 47 | transition: border-color 0.25s; 48 | } 49 | button:hover { 50 | border-color: #646cff; 51 | } 52 | button:focus, 53 | button:focus-visible { 54 | outline: 4px auto -webkit-focus-ring-color; 55 | } 56 | 57 | @media (prefers-color-scheme: light) { 58 | :root { 59 | color: #213547; 60 | background-color: #ffffff; 61 | } 62 | a:hover { 63 | color: #747bff; 64 | } 65 | button { 66 | background-color: #f9f9f9; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /examples/solid/src/assets/solid.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /examples/vue/README.md: -------------------------------------------------------------------------------- 1 | # Vue 3 + TypeScript + Vite 2 | 3 | This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `