Skip to content

Commit

Permalink
feat(connect): allow custom optionalChains for WCConnector (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
minhtranlc authored Nov 21, 2024
1 parent aa2cfc2 commit 9a6d8f4
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/connect/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sky-mavis/tanto-connect",
"version": "0.0.10",
"version": "0.0.11",
"description": "Tanto Connect",
"main": "dist/cjs/index.js",
"module": "dist/mjs/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/connect/src/common/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ export const WC_SUPPORTED_METHODS = [
];
export const WC_SUPPORTED_OPTIONAL_METHODS = ['eth_accounts', 'eth_requestAccounts'];

declare type ArrayOneOrMore<T> = {
export declare type ArrayOneOrMore<T> = {
0: T;
} & Array<T>;
4 changes: 2 additions & 2 deletions packages/connect/src/connectors/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ConnectorType, RONIN_WALLET_CONNECT_PROJECT_ID } from '../common/connectors';
import { DEFAULT_DELAY_TIME, RONIN_WALLET_RDNS, WC_SUPPORTED_CHAIN_IDS } from '../common/constant';
import { ArrayOneOrMore, DEFAULT_DELAY_TIME, RONIN_WALLET_RDNS, WC_SUPPORTED_CHAIN_IDS } from '../common/constant';
import {
IWaypointProviderConfigs,
requestProviders,
Expand Down Expand Up @@ -46,7 +46,7 @@ export const requestRoninWalletConnectConnector = async (configs?: IRoninWalletC
const provider = await requestRoninWalletConnectProvider({
projectId: configs?.projectId ?? RONIN_WALLET_CONNECT_PROJECT_ID,
metadata: configs?.metadata,
optionalChains: WC_SUPPORTED_CHAIN_IDS,
optionalChains: [...WC_SUPPORTED_CHAIN_IDS, ...(configs?.optionalChains ?? [])] as ArrayOneOrMore<number>,
showQrModal: false,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import EthereumProvider from '@walletconnect/ethereum-provider/dist/types/Ethere
import { SignClientTypes } from '@walletconnect/types';

import { DEFAULT_CONNECTORS_CONFIG, RONIN_WALLET_CONNECT_PROJECT_ID } from '../../common/connectors';
import { WC_SUPPORTED_CHAIN_IDS } from '../../common/constant';
import { ArrayOneOrMore, WC_SUPPORTED_CHAIN_IDS } from '../../common/constant';
import { ReconnectStorage } from '../../common/storage';
import { requestRoninWalletConnectProvider } from '../../providers';
import { IConnectorConfigs } from '../../types/connector';
Expand All @@ -14,6 +14,7 @@ import { BaseConnector } from '../base/BaseConnector';
export interface IRoninWalletConnectConnectorConfigs extends Partial<IConnectorConfigs> {
projectId?: string;
metadata?: SignClientTypes.Metadata;
optionalChains?: ArrayOneOrMore<number>;
}

export class RoninWalletConnectConnector extends BaseConnector<EthereumProvider> {
Expand Down
15 changes: 15 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3509,6 +3509,21 @@
dependencies:
"@sinonjs/commons" "^3.0.0"

"@sky-mavis/[email protected]":
version "0.0.9"
resolved "https://registry.yarnpkg.com/@sky-mavis/tanto-connect/-/tanto-connect-0.0.9.tgz#3c917fc0272d7139ef59fe6f5c720ca22035cd26"
integrity sha512-MVyVC2Jmi2o+8jq/E+XOnKcJ9QAADjdI/Wq2Kr3qVPUGjUD66oCxvbiBRzJFCefItGZ5fEt32Fs1uobMWFwPZg==
dependencies:
"@safe-global/safe-apps-provider" "0.18.3"
"@safe-global/safe-apps-sdk" "9.1.0"
"@sky-mavis/waypoint" "2.0.2"
"@walletconnect/ethereum-provider" "2.10.5"

"@sky-mavis/[email protected]":
version "2.0.2"
resolved "https://registry.yarnpkg.com/@sky-mavis/waypoint/-/waypoint-2.0.2.tgz#dae199212ed5158032cf3069c4f1117a460863a3"
integrity sha512-+4NZtj1QFpR99PGlxukvRt8c5dZGzwuJwhBgqCS+RVpsSIpByBaBEbTH1fzWFDr+ZRuacUpTUN8P9nkPhPp8RQ==

"@sky-mavis/[email protected]":
version "3.1.1"
resolved "https://registry.yarnpkg.com/@sky-mavis/waypoint/-/waypoint-3.1.1.tgz#c903ee77094b4001871269a2f13c46c52ef53a70"
Expand Down

0 comments on commit 9a6d8f4

Please sign in to comment.