Skip to content

Commit

Permalink
Merge pull request #5 from argentlabs/fix/argent-mobile-adapter
Browse files Browse the repository at this point in the history
fix: argent mobile login return ConnectedStarknetWindowObject
  • Loading branch information
bluecco authored Oct 6, 2023
2 parents a5e73a6 + 327d239 commit cdfbe65
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/connectors/argentMobile/modal/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import type { StarknetWindowObject } from "get-starknet-core"
import type {
StarknetWindowObject,
ConnectedStarknetWindowObject,
} from "get-starknet-core"

import { login } from "./login"
import type { IArgentLoginOptions } from "./login"
Expand All @@ -8,4 +11,4 @@ export type { StarknetWindowObject, IArgentLoginOptions }

export const getStarknetWindowObject = async (
options: IArgentLoginOptions,
): Promise<StarknetWindowObject> => login(options, StarknetAdapter)
): Promise<ConnectedStarknetWindowObject> => login(options, StarknetAdapter)
5 changes: 5 additions & 0 deletions src/connectors/argentMobile/modal/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const Network: typeof constants.NetworkName = constants.NetworkName

import type { NamespaceAdapter, NamespaceAdapterOptions } from "./adapter"
import { argentModal } from "./argentModal"
import { resetWalletConnect } from "../../../helpers/resetWalletConnect"

export interface IArgentLoginOptions {
projectId?: string
Expand Down Expand Up @@ -79,6 +80,10 @@ export const login = async <TAdapter extends NamespaceAdapter>(
}

const params = { requiredNamespaces: adapter.getRequiredNamespaces() }

resetWalletConnect()
// wait for cookies to be removed and reset the websocket for walletconnect
await new Promise((resolve) => setTimeout(resolve, 200))
const { uri, approval } = await client.connect(params)

// Open QRCode modal if a URI was returned (i.e. we're not connecting an existing pairing).
Expand Down
5 changes: 3 additions & 2 deletions src/connectors/argentMobile/modal/starknet/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,9 @@ export class StarknetAdapter

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
get isConnected(): boolean {
return this.signerConnection.connected
get isConnected(): true {
// needed to be implemented returning true since it's implementing ConnectedStarknetWindowObject
return true
}

async isPreauthorized(): Promise<boolean> {
Expand Down

0 comments on commit cdfbe65

Please sign in to comment.