diff --git a/packages/connect/package.json b/packages/connect/package.json index e9d8c00..dfb7114 100644 --- a/packages/connect/package.json +++ b/packages/connect/package.json @@ -1,6 +1,6 @@ { "name": "@sky-mavis/tanto-connect", - "version": "0.0.2", + "version": "0.0.3", "description": "Tanto Connect", "main": "dist/cjs/index.js", "module": "dist/mjs/index.js", diff --git a/packages/connect/src/connectors/waypoint/WaypointConnector.ts b/packages/connect/src/connectors/waypoint/WaypointConnector.ts index ce21599..6d86680 100644 --- a/packages/connect/src/connectors/waypoint/WaypointConnector.ts +++ b/packages/connect/src/connectors/waypoint/WaypointConnector.ts @@ -2,8 +2,7 @@ import { WaypointProvider } from '@sky-mavis/waypoint'; import { DEFAULT_CONNECTORS_CONFIG } from '../../common/connectors'; import { LocalStorage, ReconnectStorage, WAYPOINT_ACCESS_TOKEN_STORAGE_KEY } from '../../common/storage'; -import { requestWaypointProvider } from '../../providers'; -import { IWaypointProviderConfigs } from '../../providers/waypoint-provider'; +import { IWaypointProviderConfigs, requestWaypointProvider } from '../../providers'; import { IConnectorConfigs, IConnectResult } from '../../types/connector'; import { ConnectorError, ConnectorErrorType } from '../../types/connector-error'; import { EIP1193Event } from '../../types/eip1193'; @@ -46,16 +45,19 @@ export class WaypointConnector extends BaseConnector { }); } - async connect() { + async connect(chainId?: number) { const provider = await this.getProvider(); - const chainId = await this.getChainId(); const accounts = await this.getAccounts(); + const currentChainId = await this.getChainId(); + if (currentChainId !== chainId) { + this.provider = await this.requestProvider({ chainId }); + } const account = accounts[0]; const connectResult: IConnectResult = { accessToken: LocalStorage.get(WAYPOINT_ACCESS_TOKEN_STORAGE_KEY), provider, - chainId, + chainId: chainId || currentChainId, account, }; diff --git a/packages/wagmi/package.json b/packages/wagmi/package.json index 950e990..d4495f3 100644 --- a/packages/wagmi/package.json +++ b/packages/wagmi/package.json @@ -49,7 +49,7 @@ }, "homepage": "https://github.com/skymavis/tanto-kit", "dependencies": { - "@sky-mavis/tanto-connect": "0.0.2", + "@sky-mavis/tanto-connect": "0.0.3", "@wagmi/core": "2.13.6", "eslint": "8.30.0", "jest": "29.7.0",