diff --git a/package-lock.json b/package-lock.json index cb193ff6..5f8ecd11 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4506,28 +4506,6 @@ "@babel/runtime": "7.x" } }, - "node_modules/@tkey-mpc/common-types/node_modules/@toruslabs/http-helpers": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/@toruslabs/http-helpers/-/http-helpers-6.1.1.tgz", - "integrity": "sha512-bJYOaltRzklzObhRdutT1wau17vXyrCCBKJOeN46F1t99MUXi5udQNeErFOcr9qBsvrq2q67eVBkU5XOeBMX5A==", - "dependencies": { - "lodash.merge": "^4.6.2", - "loglevel": "^1.9.1" - }, - "engines": { - "node": ">=18.x", - "npm": ">=9.x" - }, - "peerDependencies": { - "@babel/runtime": "^7.x", - "@sentry/types": "^7.x" - }, - "peerDependenciesMeta": { - "@sentry/types": { - "optional": true - } - } - }, "node_modules/@tkey-mpc/common-types/node_modules/@toruslabs/torus.js": { "version": "11.0.6", "resolved": "https://registry.npmjs.org/@toruslabs/torus.js/-/torus.js-11.0.6.tgz", @@ -4550,6 +4528,28 @@ "@babel/runtime": "7.x" } }, + "node_modules/@tkey-mpc/common-types/node_modules/@toruslabs/torus.js/node_modules/@toruslabs/http-helpers": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@toruslabs/http-helpers/-/http-helpers-5.0.0.tgz", + "integrity": "sha512-GmezWz9JeF6YyhjLSm+9XDF4YaeICEckY0Jbo43i86SjhfJYgRWqEi63VSiNsaqc/z810Q0FQvEk1TnBRX2tgA==", + "dependencies": { + "lodash.merge": "^4.6.2", + "loglevel": "^1.8.1" + }, + "engines": { + "node": ">=18.x", + "npm": ">=9.x" + }, + "peerDependencies": { + "@babel/runtime": "^7.x", + "@sentry/types": "^7.x" + }, + "peerDependenciesMeta": { + "@sentry/types": { + "optional": true + } + } + }, "node_modules/@tkey-mpc/core": { "version": "9.1.1", "resolved": "https://registry.npmjs.org/@tkey-mpc/core/-/core-9.1.1.tgz", diff --git a/src/interfaces.ts b/src/interfaces.ts index 74c81816..33ad9a9b 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -9,7 +9,7 @@ import type { TorusVerifierResponse, UX_MODE_TYPE, } from "@toruslabs/customauth"; -import { CustomChainConfig, SafeEventEmitterProvider } from "@web3auth/base"; +import { CustomChainConfig } from "@web3auth/base"; import BN from "bn.js"; import { FactorKeyTypeShareDescription, TssShareType, USER_PATH, WEB3AUTH_NETWORK } from "./constants"; @@ -156,11 +156,6 @@ export interface ICoreKit { **/ tKey: ThresholdKey | null; - /** - * Provider for making the blockchain calls. - **/ - provider: SafeEventEmitterProvider | null; - /** * Signatures generated from the OAuth Login. **/ diff --git a/src/mpcCoreKit.ts b/src/mpcCoreKit.ts index aebfe995..b50d6c96 100644 --- a/src/mpcCoreKit.ts +++ b/src/mpcCoreKit.ts @@ -1,5 +1,4 @@ /* eslint-disable @typescript-eslint/member-ordering */ -import { createSwappableProxy, SwappableProxy } from "@metamask/swappable-obj-proxy"; import { BNString, encrypt, getPubKeyPoint, Point as TkeyPoint, SHARE_DELETED, ShareStore, StringifiedType } from "@tkey-mpc/common-types"; import ThresholdKey, { CoreError, lagrangeInterpolation } from "@tkey-mpc/core"; import { TorusServiceProvider } from "@tkey-mpc/service-provider-torus"; @@ -15,7 +14,7 @@ import { OpenloginSessionManager } from "@toruslabs/openlogin-session-manager"; import TorusUtils, { TorusKey } from "@toruslabs/torus.js"; import { Client, getDKLSCoeff, setupSockets } from "@toruslabs/tss-client"; import type * as TssLib from "@toruslabs/tss-lib"; -import { CHAIN_NAMESPACES, CustomChainConfig, log, SafeEventEmitterProvider } from "@web3auth/base"; +import { CHAIN_NAMESPACES, CustomChainConfig, log } from "@web3auth/base"; import { EthereumSigningProvider } from "@web3auth-mpc/ethereum-provider"; import BN from "bn.js"; import bowser from "bowser"; @@ -69,8 +68,6 @@ export class Web3AuthMPCCoreKit implements ICoreKit { private options: Web3AuthOptionsWithDefaults; - private providerProxy: SwappableProxy | null = null; - private torusSp: TorusServiceProvider | null = null; private storageLayer: TorusStorageLayer | null = null; @@ -152,14 +149,6 @@ export class Web3AuthMPCCoreKit implements ICoreKit { return this.tkey; } - get provider(): SafeEventEmitterProvider | null { - return this.providerProxy ? this.providerProxy : null; - } - - set provider(_: SafeEventEmitterProvider | null) { - throw new Error("Not implemented"); - } - get signatures(): string[] { return this.state?.signatures ? this.state.signatures : []; } @@ -1166,13 +1155,6 @@ export class Web3AuthMPCCoreKit implements ICoreKit { this.options.chainConfig = option.chainConfig; const signingProvider = new EthereumSigningProvider({ config: { chainConfig: this.options.chainConfig } }); await signingProvider.setupProvider({ sign: this.sign, getPublic: this.getPublic }); - - if (this.providerProxy === null) { - const provider = createSwappableProxy(signingProvider.provider); - this.providerProxy = provider; - } else { - this.providerProxy.setTarget(signingProvider.provider); - } } private updateState(newState: Partial): void { @@ -1184,7 +1166,6 @@ export class Web3AuthMPCCoreKit implements ICoreKit { this.tkey = null; this.torusSp = null; this.storageLayer = null; - this.providerProxy = null; } private _getOAuthKey(result: TorusKey): string { diff --git a/tests/login.spec.ts b/tests/login.spec.ts index b00f8047..e437a72c 100644 --- a/tests/login.spec.ts +++ b/tests/login.spec.ts @@ -9,7 +9,7 @@ import * as TssLib from "@toruslabs/tss-lib-node"; import BN from "bn.js"; import { ec as EC } from "elliptic"; -import { BrowserStorage, COREKIT_STATUS, DEFAULT_CHAIN_CONFIG, WEB3AUTH_NETWORK, WEB3AUTH_NETWORK_TYPE, Web3AuthMPCCoreKit } from "../src"; +import { BrowserStorage, COREKIT_STATUS, WEB3AUTH_NETWORK, WEB3AUTH_NETWORK_TYPE, Web3AuthMPCCoreKit } from "../src"; import { criticalResetAccount, mockLogin, stringGen } from "./setup"; type TestVariable = { @@ -107,8 +107,8 @@ variable.forEach((testVariable) => { // get key details await checkLogin(coreKitInstance); - const result = await coreKitInstance.provider.request({ method: "eth_chainId", params: [] }); - assert.strictEqual(result, DEFAULT_CHAIN_CONFIG.chainId); + // const result = await coreKitInstance.provider.request({ method: "eth_chainId", params: [] }); + // assert.strictEqual(result, DEFAULT_CHAIN_CONFIG.chainId); checkPubKey = coreKitInstance.getTssPublicKey(); const factorkey = coreKitInstance.getCurrentFactorKey(); @@ -137,16 +137,16 @@ variable.forEach((testVariable) => { // get key details await checkLogin(coreKitInstanceWithoutProvider); assert.strictEqual(coreKitInstanceWithoutProvider.status, COREKIT_STATUS.LOGGED_IN); - assert.strictEqual(coreKitInstanceWithoutProvider.provider, null); - try { - await coreKitInstanceWithoutProvider.provider.request({ method: "eth_chainId", params: [] }); - throw new Error("should not reach here"); - } catch (error) {} + // assert.strictEqual(coreKitInstanceWithoutProvider.provider, null); + // try { + // await coreKitInstanceWithoutProvider.provider.request({ method: "eth_chainId", params: [] }); + // throw new Error("should not reach here"); + // } catch (error) {} // setup provider - await coreKitInstanceWithoutProvider.setupProvider({ chainConfig: DEFAULT_CHAIN_CONFIG }); - const result = await coreKitInstanceWithoutProvider.provider.request({ method: "eth_chainId", params: [] }); - assert.strictEqual(result, DEFAULT_CHAIN_CONFIG.chainId); + // await coreKitInstanceWithoutProvider.setupProvider({ chainConfig: DEFAULT_CHAIN_CONFIG }); + // const result = await coreKitInstanceWithoutProvider.provider.request({ method: "eth_chainId", params: [] }); + // assert.strictEqual(result, DEFAULT_CHAIN_CONFIG.chainId); }); await t.test("#relogin ", async function () {