({
+ method: chainNamespace === CHAIN_NAMESPACES.EIP155 ? "personal_sign" : "signMessage",
+ params: chainNamespace === CHAIN_NAMESPACES.EIP155 ? [challenge, accounts[0]] : { message: Buffer.from(challenge) },
});
+ if (chainNamespace === CHAIN_NAMESPACES.SOLANA) return base58.encode(signedMessage as Uint8Array);
+ return signedMessage as string;
}
}
diff --git a/packages/adapters/wallet-connect-v2-adapter/torus.config.js b/packages/adapters/wallet-connect-v2-adapter/torus.config.js
index 6df6a4932..927b75e03 100644
--- a/packages/adapters/wallet-connect-v2-adapter/torus.config.js
+++ b/packages/adapters/wallet-connect-v2-adapter/torus.config.js
@@ -1 +1 @@
-module.exports = require("../../../torus.config");
+module.exports = require('../../../torus.config.js');
diff --git a/packages/providers/solana-provider/src/index.ts b/packages/providers/solana-provider/src/index.ts
index eb3d71de4..d1e438257 100644
--- a/packages/providers/solana-provider/src/index.ts
+++ b/packages/providers/solana-provider/src/index.ts
@@ -1,3 +1,4 @@
export * from "./interface";
export * from "./providers";
+export * from "./rpc";
export * from "./solanaWallet";
diff --git a/packages/providers/solana-provider/src/providers/injectedProviders/base/baseInjectedProvider.ts b/packages/providers/solana-provider/src/providers/injectedProviders/base/baseInjectedProvider.ts
index 720ce94f1..0ab112f96 100644
--- a/packages/providers/solana-provider/src/providers/injectedProviders/base/baseInjectedProvider.ts
+++ b/packages/providers/solana-provider/src/providers/injectedProviders/base/baseInjectedProvider.ts
@@ -2,8 +2,9 @@ import { JRPCEngine, JRPCMiddleware, providerFromEngine } from "@web3auth/auth";
import { CustomChainConfig, WalletLoginError } from "@web3auth/base";
import { BaseProvider, BaseProviderConfig, BaseProviderState } from "@web3auth/base-provider";
+import { IProviderHandlers } from "../../../rpc";
import { createConfigMiddleware } from "../../../rpc/JrpcClient";
-import { createSolanaMiddleware, IProviderHandlers } from "../../../rpc/solanaRpcMiddlewares";
+import { createSolanaMiddleware } from "../../../rpc/solanaRpcMiddlewares";
export abstract class BaseInjectedProvider extends BaseProvider {
constructor({ config, state }: { config: BaseProviderConfig; state?: BaseProviderState }) {
diff --git a/packages/providers/solana-provider/src/providers/injectedProviders/base/providerHandlers.ts b/packages/providers/solana-provider/src/providers/injectedProviders/base/providerHandlers.ts
index 73b3ffc9e..e250a52fe 100644
--- a/packages/providers/solana-provider/src/providers/injectedProviders/base/providerHandlers.ts
+++ b/packages/providers/solana-provider/src/providers/injectedProviders/base/providerHandlers.ts
@@ -2,7 +2,7 @@ import { JRPCRequest, rpcErrors } from "@web3auth/auth";
import bs58 from "bs58";
import { IBaseWalletProvider, TransactionOrVersionedTransaction } from "../../../interface";
-import { IProviderHandlers } from "../../../rpc/solanaRpcMiddlewares";
+import { IProviderHandlers } from "../../../rpc";
export const getBaseProviderHandlers = (injectedProvider: IBaseWalletProvider): IProviderHandlers => {
const providerHandlers: IProviderHandlers = {
diff --git a/packages/providers/solana-provider/src/providers/injectedProviders/torus/providerHandlers.ts b/packages/providers/solana-provider/src/providers/injectedProviders/torus/providerHandlers.ts
index cd0edf24f..c9efa87da 100644
--- a/packages/providers/solana-provider/src/providers/injectedProviders/torus/providerHandlers.ts
+++ b/packages/providers/solana-provider/src/providers/injectedProviders/torus/providerHandlers.ts
@@ -1,7 +1,7 @@
import { JRPCRequest, rpcErrors } from "@web3auth/auth";
import { ITorusWalletProvider, TransactionOrVersionedTransaction } from "../../../interface";
-import { IProviderHandlers } from "../../../rpc/solanaRpcMiddlewares";
+import { IProviderHandlers } from "../../../rpc";
export const getTorusHandlers = (injectedProvider: ITorusWalletProvider): IProviderHandlers => {
const providerHandlers: IProviderHandlers = {
diff --git a/packages/providers/solana-provider/src/providers/injectedProviders/walletStandardProvider.ts b/packages/providers/solana-provider/src/providers/injectedProviders/walletStandardProvider.ts
index ba46fa454..c24870c64 100644
--- a/packages/providers/solana-provider/src/providers/injectedProviders/walletStandardProvider.ts
+++ b/packages/providers/solana-provider/src/providers/injectedProviders/walletStandardProvider.ts
@@ -1,5 +1,5 @@
import { IWalletStandardProviderHandler } from "../../interface";
-import { IProviderHandlers } from "../../rpc/solanaRpcMiddlewares";
+import { IProviderHandlers } from "../../rpc";
import { BaseInjectedProvider } from "./base/baseInjectedProvider";
import { getBaseProviderHandlers } from "./base/providerHandlers";
diff --git a/packages/providers/solana-provider/src/providers/privateKeyProvider/solanaPrivateKeyProvider.ts b/packages/providers/solana-provider/src/providers/privateKeyProvider/solanaPrivateKeyProvider.ts
index 773075fa0..09671649e 100644
--- a/packages/providers/solana-provider/src/providers/privateKeyProvider/solanaPrivateKeyProvider.ts
+++ b/packages/providers/solana-provider/src/providers/privateKeyProvider/solanaPrivateKeyProvider.ts
@@ -2,15 +2,9 @@ import { getED25519Key, JRPCEngine, JRPCMiddleware, JRPCRequest, providerErrors,
import { CHAIN_NAMESPACES, CustomChainConfig, WalletInitializationError } from "@web3auth/base";
import { BaseProvider, BaseProviderConfig, BaseProviderState } from "@web3auth/base-provider";
+import { AddSolanaChainParameter, IChainSwitchHandlers } from "../../rpc";
import { createJsonRpcClient } from "../../rpc/JrpcClient";
-import {
- AddSolanaChainParameter,
- createAccountMiddleware,
- createChainSwitchMiddleware,
- createSolanaMiddleware,
- IAccountHandlers,
- IChainSwitchHandlers,
-} from "../../rpc/solanaRpcMiddlewares";
+import { createAccountMiddleware, createChainSwitchMiddleware, createSolanaMiddleware, IAccountHandlers } from "../../rpc/solanaRpcMiddlewares";
import { getProviderHandlers } from "./solanaPrivateKeyUtils";
export interface SolanaPrivKeyProviderConfig extends BaseProviderConfig {
diff --git a/packages/providers/solana-provider/src/providers/privateKeyProvider/solanaPrivateKeyUtils.ts b/packages/providers/solana-provider/src/providers/privateKeyProvider/solanaPrivateKeyUtils.ts
index ae507854f..9cff0a049 100644
--- a/packages/providers/solana-provider/src/providers/privateKeyProvider/solanaPrivateKeyUtils.ts
+++ b/packages/providers/solana-provider/src/providers/privateKeyProvider/solanaPrivateKeyUtils.ts
@@ -5,7 +5,7 @@ import { SafeEventEmitterProvider, WalletInitializationError } from "@web3auth/b
import bs58 from "bs58";
import { TransactionOrVersionedTransaction } from "../../interface";
-import { IProviderHandlers } from "../../rpc/solanaRpcMiddlewares";
+import { IProviderHandlers } from "../../rpc";
export async function getProviderHandlers({
privKey,
diff --git a/packages/providers/solana-provider/src/rpc/index.ts b/packages/providers/solana-provider/src/rpc/index.ts
new file mode 100644
index 000000000..532554f34
--- /dev/null
+++ b/packages/providers/solana-provider/src/rpc/index.ts
@@ -0,0 +1,3 @@
+export * from "./interfaces";
+export * from "./JrpcClient";
+export * from "./solanaRpcMiddlewares";
diff --git a/packages/providers/solana-provider/src/rpc/interfaces.ts b/packages/providers/solana-provider/src/rpc/interfaces.ts
new file mode 100644
index 000000000..100af4806
--- /dev/null
+++ b/packages/providers/solana-provider/src/rpc/interfaces.ts
@@ -0,0 +1,33 @@
+import { JRPCRequest } from "@web3auth/auth";
+
+import { TransactionOrVersionedTransaction } from "../interface";
+
+export interface AddSolanaChainParameter {
+ chainId: string; // A 0x-prefixed hexadecimal string
+ chainName: string;
+ nativeCurrency: {
+ name: string;
+ symbol: string; // 2-6 characters long
+ decimals: 18;
+ };
+ rpcUrls: string[];
+ blockExplorerUrls?: string[];
+ iconUrls?: string[];
+}
+
+export interface IChainSwitchHandlers {
+ addNewChainConfig: (req: JRPCRequest) => Promise;
+ switchSolanaChain: (req: JRPCRequest<{ chainId: string }>) => Promise;
+}
+
+export interface IProviderHandlers {
+ requestAccounts: (req: JRPCRequest) => Promise;
+ getAccounts: (req: JRPCRequest) => Promise;
+ getPublicKey: (req: JRPCRequest) => Promise;
+ getPrivateKey: (req: JRPCRequest) => Promise;
+ signTransaction: (req: JRPCRequest<{ message: TransactionOrVersionedTransaction }>) => Promise;
+ signAllTransactions: (req: JRPCRequest<{ message: TransactionOrVersionedTransaction[] }>) => Promise;
+ signAndSendTransaction: (req: JRPCRequest<{ message: TransactionOrVersionedTransaction }>) => Promise<{ signature: string }>;
+ getSecretKey: (req: JRPCRequest) => Promise;
+ signMessage: (req: JRPCRequest<{ message: Uint8Array; display?: string }>) => Promise;
+}
diff --git a/packages/providers/solana-provider/src/rpc/solanaRpcMiddlewares.ts b/packages/providers/solana-provider/src/rpc/solanaRpcMiddlewares.ts
index b920667ad..2a8e9e0b5 100644
--- a/packages/providers/solana-provider/src/rpc/solanaRpcMiddlewares.ts
+++ b/packages/providers/solana-provider/src/rpc/solanaRpcMiddlewares.ts
@@ -1,18 +1,7 @@
import { createAsyncMiddleware, JRPCMiddleware, JRPCRequest, mergeMiddleware } from "@web3auth/auth";
import { TransactionOrVersionedTransaction } from "../interface";
-
-export interface IProviderHandlers {
- requestAccounts: (req: JRPCRequest) => Promise;
- getAccounts: (req: JRPCRequest) => Promise;
- getPublicKey: (req: JRPCRequest) => Promise;
- getPrivateKey: (req: JRPCRequest) => Promise;
- signTransaction: (req: JRPCRequest<{ message: TransactionOrVersionedTransaction }>) => Promise;
- signAllTransactions: (req: JRPCRequest<{ message: TransactionOrVersionedTransaction[] }>) => Promise;
- signAndSendTransaction: (req: JRPCRequest<{ message: TransactionOrVersionedTransaction }>) => Promise<{ signature: string }>;
- getSecretKey: (req: JRPCRequest) => Promise;
- signMessage: (req: JRPCRequest<{ message: Uint8Array; display?: string }>) => Promise;
-}
+import { AddSolanaChainParameter, IChainSwitchHandlers, IProviderHandlers } from "./interfaces";
export function createGetAccountsMiddleware({ getAccounts }: { getAccounts: IProviderHandlers["getAccounts"] }): JRPCMiddleware {
return createAsyncMiddleware(async (request, response, next) => {
@@ -110,23 +99,7 @@ export function createSolanaMiddleware(providerHandlers: IProviderHandlers): JRP
createGenericJRPCMiddleware("solanaSecretKey", getSecretKey) as JRPCMiddleware,
]);
}
-export interface AddSolanaChainParameter {
- chainId: string; // A 0x-prefixed hexadecimal string
- chainName: string;
- nativeCurrency: {
- name: string;
- symbol: string; // 2-6 characters long
- decimals: 18;
- };
- rpcUrls: string[];
- blockExplorerUrls?: string[];
- iconUrls?: string[];
-}
-export interface IChainSwitchHandlers {
- addNewChainConfig: (req: JRPCRequest) => Promise;
- switchSolanaChain: (req: JRPCRequest<{ chainId: string }>) => Promise;
-}
export function createChainSwitchMiddleware({ addNewChainConfig, switchSolanaChain }: IChainSwitchHandlers): JRPCMiddleware {
return mergeMiddleware([
createGenericJRPCMiddleware("addSolanaChain", addNewChainConfig) as JRPCMiddleware,