Skip to content

Commit 28c82c0

Browse files
authored
Merge pull request #134 from argentlabs/fix/connect-injected-wallet
fix: add params to connect method and update starknetkit modal to use…
2 parents 6610a8b + d578c9a commit 28c82c0

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

src/connectors/connector.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ export interface ConnectorEvents {
2828
disconnect(): void
2929
}
3030

31+
export type ConnectOptions = {
32+
silent_mode: boolean
33+
}
34+
3135
export abstract class Connector extends EventEmitter<ConnectorEvents> {
3236
/** Unique connector id. */
3337
abstract get id(): string
@@ -41,7 +45,7 @@ export abstract class Connector extends EventEmitter<ConnectorEvents> {
4145
/** Whether connector is already authorized */
4246
abstract ready(): Promise<boolean>
4347
/** Connect wallet. */
44-
abstract connect(): Promise<ConnectorData>
48+
abstract connect(params?: ConnectOptions): Promise<ConnectorData>
4549
/** Disconnect wallet. */
4650
abstract disconnect(): Promise<void>
4751
/** Get current account silently. Return null if the account is not authorized */

src/connectors/injected/index.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
} from "../../errors"
1919
import { removeStarknetLastConnectedWallet } from "../../helpers/lastConnected"
2020
import {
21+
ConnectOptions,
2122
Connector,
2223
type ConnectorData,
2324
type ConnectorIcons,
@@ -138,7 +139,7 @@ export class InjectedConnector extends Connector {
138139
return new Account(provider, accounts[0], "")
139140
}
140141

141-
async connect(): Promise<ConnectorData> {
142+
async connect(params: ConnectOptions): Promise<ConnectorData> {
142143
this.ensureWallet()
143144

144145
if (!this._wallet) {
@@ -147,9 +148,16 @@ export class InjectedConnector extends Connector {
147148

148149
let accounts: string[]
149150
try {
150-
accounts = await this.request({
151-
type: "wallet_requestAccounts",
152-
})
151+
accounts = await this.request(
152+
params
153+
? {
154+
type: "wallet_requestAccounts",
155+
params,
156+
}
157+
: {
158+
type: "wallet_requestAccounts",
159+
},
160+
)
153161
} catch {
154162
throw new UserRejectedRequestError()
155163
}

src/main.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ export const connect = async ({
5252
let connectorData: ConnectorData | null = null
5353

5454
if (connector && resultType === "wallet") {
55-
connectorData = await connector.connect()
55+
connectorData = await connector.connect({
56+
silent_mode: true,
57+
})
5658
}
5759

5860
return {

0 commit comments

Comments
 (0)