Skip to content

Commit 9aaf150

Browse files
committed
Adds vue solana composables
1 parent 8266918 commit 9aaf150

29 files changed

+4200
-1032
lines changed

demo/vue-app-new/package-lock.json

Lines changed: 3500 additions & 1020 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/vue-app-new/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"@toruslabs/tweetnacl-js": "^1.0.4",
1919
"@toruslabs/vue-components": "^8.0.6",
2020
"@toruslabs/vue-icons": "^8.0.2",
21+
"@wagmi/vue": "^0.1.15",
2122
"@web3auth/auth": "^10.4.0",
2223
"@web3auth/modal": "file:../../packages/modal",
2324
"@web3auth/no-modal": "file:../../packages/no-modal",

demo/vue-app-new/src/components/AppDashboard.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { useCheckout, useEnableMFA, useIdentityToken, useManageMFA, useSwitchCha
55
import { CustomChainConfig, type NFTCheckoutPluginType, type WalletServicesPluginType } from "@web3auth/no-modal";
66
import { useI18n } from "petite-vue-i18n";
77
8+
import { useAccount } from "@wagmi/vue";
9+
810
import { Connection } from "@solana/web3.js";
911
import { ProviderConfig } from "@toruslabs/base-controllers";
1012
import { SUPPORTED_NETWORKS } from "@toruslabs/ethereum-controllers";
@@ -58,6 +60,7 @@ const { showWalletUI, loading: showWalletUILoading } = useWalletUI();
5860
const { showWalletConnectScanner, loading: showWalletConnectScannerLoading } = useWalletConnectScanner();
5961
const { showCheckout, loading: showCheckoutLoading } = useCheckout();
6062
const { authenticateUser, loading: authenticateUserLoading } = useIdentityToken();
63+
const { status } = useAccount();
6164
6265
const currentChainId = ref<string | undefined>(web3Auth.value?.currentChain?.chainId);
6366
const currentChainConfig = computed(() => supportedNetworks[currentChainId.value as keyof typeof supportedNetworks]);
@@ -142,6 +145,10 @@ const printToConsole = (...args: unknown[]) => {
142145
}
143146
};
144147
148+
watch(status, (newStatus) => {
149+
console.log("status", newStatus);
150+
}, { immediate: true });
151+
145152
// const onWalletSignPersonalMessage = async () => {
146153
// const walletPlugin = web3Auth.value?.getPlugin(WALLET_PLUGINS.WALLET_SERVICES) as WalletServicesPluginType;
147154
// await walletSignPersonalMessage(walletPlugin.wsEmbedInstance.provider, printToConsole);

package-lock.json

Lines changed: 122 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/modal/eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import toruslabsReact from "@toruslabs/eslint-config-react";
33
export default [
44
...toruslabsReact,
55
{
6-
ignores: ["./src/vue"],
6+
ignores: ["src/vue/WalletServicesInnerProvider.vue"],
77
},
88
];

packages/modal/package.json

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,20 @@
4646
},
4747
"wagmi": {
4848
"optional": true
49+
},
50+
"@wagmi/core": {
51+
"optional": true
52+
},
53+
"@wagmi/vue": {
54+
"optional": true
4955
}
5056
},
5157
"peerDependencies": {
5258
"@babel/runtime": "^7.x",
5359
"@coinbase/wallet-sdk": "^4.3.x",
5460
"@solana/web3.js": ">=1.98",
55-
"@tanstack/react-query": "^5.72.x",
61+
"@wagmi/core": ">=2.16",
62+
"@wagmi/vue": ">=0.1.x",
5663
"react": ">=18",
5764
"react-dom": ">=18",
5865
"viem": "^2.23.x",
@@ -76,6 +83,8 @@
7683
"@toruslabs/vue-components": "^8.0.6",
7784
"@types/react": "^19.1.2",
7885
"@types/react-dom": "^19.1.2",
86+
"@wagmi/core": "^2.16.1",
87+
"@wagmi/vue": "^0.1.15",
7988
"autoprefixer": "^10.4.21",
8089
"css-loader": "^7.1.2",
8190
"live-server": "^1.2.2",
@@ -133,6 +142,16 @@
133142
"import": "./dist/lib.esm/packages/modal/src/vue/index.js",
134143
"require": "./dist/lib.cjs/packages/modal/src/vue/index.js",
135144
"types": "./dist/lib.cjs/types/vue/index.d.ts"
145+
},
146+
"./vue/solana": {
147+
"import": "./dist/lib.esm/packages/modal/src/vue/solana/index.js",
148+
"require": "./dist/lib.cjs/packages/modal/src/vue/solana/index.js",
149+
"types": "./dist/lib.cjs/types/vue/solana/index.d.ts"
150+
},
151+
"./vue/wagmi": {
152+
"import": "./dist/lib.esm/packages/modal/src/vue/wagmi/index.js",
153+
"require": "./dist/lib.cjs/packages/modal/src/vue/wagmi/index.js",
154+
"types": "./dist/lib.cjs/types/vue/wagmi/index.d.ts"
136155
}
137156
},
138157
"typesVersions": {
@@ -148,6 +167,12 @@
148167
],
149168
"vue": [
150169
"./dist/lib.cjs/types/vue/index.d.ts"
170+
],
171+
"vue/solana": [
172+
"./dist/lib.cjs/types/vue/solana/index.d.ts"
173+
],
174+
"vue/wagmi": [
175+
"./dist/lib.cjs/types/vue/wagmi/index.d.ts"
151176
]
152177
}
153178
},

packages/modal/rollup.config.mjs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,15 @@ const pkg = await readJSONFile(path.resolve("./package.json"));
1111
// TODO: use ssr module for cjs build
1212

1313
export const baseConfig = {
14-
input: ["./src/index.ts", "./src/react/index.ts", "./src/vue/index.ts", "./src/react/wagmi/index.ts", "./src/react/solana/index.ts"],
14+
input: [
15+
"./src/index.ts",
16+
"./src/react/index.ts",
17+
"./src/vue/index.ts",
18+
"./src/react/wagmi/index.ts",
19+
"./src/react/solana/index.ts",
20+
"./src/vue/solana/index.ts",
21+
"./src/vue/wagmi/index.ts",
22+
],
1523
plugins: [
1624
replace({
1725
"process.env.WEB3AUTH_VERSION": `"${pkg.version}"`,

packages/modal/src/react/solana/hooks/useSignAndSendTransaction.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { TransactionOrVersionedTransaction, Web3AuthError } from "@web3auth/no-modal";
1+
import { TransactionOrVersionedTransaction, WalletInitializationError, Web3AuthError } from "@web3auth/no-modal";
22
import { useCallback, useState } from "react";
33

44
import { useSolanaWallet } from "./useSolanaWallet";
@@ -21,7 +21,7 @@ export const useSignAndSendTransaction = (): IUseSignAndSendTransaction => {
2121
setLoading(true);
2222
setError(null);
2323
try {
24-
if (!solanaWallet) throw new Error("Solana wallet not found");
24+
if (!solanaWallet) throw WalletInitializationError.notReady();
2525
const signature = await solanaWallet.signAndSendTransaction(transaction);
2626
setData(signature);
2727
return signature;

packages/modal/src/react/solana/hooks/useSignMessage.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Web3AuthError } from "@web3auth/no-modal";
1+
import { WalletInitializationError, Web3AuthError } from "@web3auth/no-modal";
22
import { useCallback, useState } from "react";
33

44
import { useSolanaWallet } from "./useSolanaWallet";
@@ -21,7 +21,7 @@ export const useSignMessage = (): IUseSignMessage => {
2121
setLoading(true);
2222
setError(null);
2323
try {
24-
if (!solanaWallet) throw new Error("Solana wallet not found");
24+
if (!solanaWallet) throw WalletInitializationError.notReady();
2525
const signature = await solanaWallet.signMessage(message, from ?? accounts?.[0]);
2626
setData(signature);
2727
return signature;

packages/modal/src/react/solana/hooks/useSignTransaction.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { TransactionOrVersionedTransaction, Web3AuthError } from "@web3auth/no-modal";
1+
import { type TransactionOrVersionedTransaction, WalletInitializationError, Web3AuthError } from "@web3auth/no-modal";
22
import { useCallback, useState } from "react";
33

44
import { useSolanaWallet } from "./useSolanaWallet";
@@ -21,6 +21,7 @@ export const useSignTransaction = () => {
2121
setLoading(true);
2222
setError(null);
2323
try {
24+
if (!solanaWallet) throw WalletInitializationError.notReady();
2425
const signedTransaction = await solanaWallet.signTransaction(transaction);
2526
setData(signedTransaction);
2627
return signedTransaction;

0 commit comments

Comments
 (0)