Skip to content

Commit

Permalink
fix: allow custom provider for argent mobile connector
Browse files Browse the repository at this point in the history
  • Loading branch information
bluecco committed Dec 13, 2023
1 parent 83b6601 commit 8e99cbb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
15 changes: 14 additions & 1 deletion src/connectors/argentMobile/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type {
AccountChangeEventHandler,
StarknetWindowObject,
} from "get-starknet-core"
import type { AccountInterface } from "starknet"
import type { AccountInterface, ProviderInterface } from "starknet"
import { constants } from "starknet"
import { DEFAULT_ARGENT_MOBILE_ICON, DEFAULT_PROJECT_ID } from "./constants"
import {
Expand All @@ -26,6 +26,7 @@ export interface ArgentMobileConnectorOptions {
description?: string
url?: string
icons?: string[]
provider?: ProviderInterface
}

export class ArgentMobileConnector extends Connector {
Expand Down Expand Up @@ -153,6 +154,10 @@ export class ArgentMobileConnector extends Connector {
description,
url,
icons,
rpcUrl:
chainId === constants.NetworkName.SN_MAIN
? "https://cloud.argent-api.com/v1/starknet/goerli/rpc/v0.5"
: "https://api.hydrogen.argent47.net/v1/starknet/goerli/rpc/v0.5",
}

if (projectId === DEFAULT_PROJECT_ID) {
Expand All @@ -171,6 +176,14 @@ export class ArgentMobileConnector extends Connector {
}

const _wallet = await getStarknetWindowObject(options)

const { provider } = this._options
if (provider) {
Object.assign(_wallet, {
provider,
})
}
console.log(_wallet.provider)
this._wallet = _wallet

// wallet connect rpc enable
Expand Down
9 changes: 2 additions & 7 deletions src/connectors/argentMobile/modal/starknet/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type {
ProviderInterface,
SignerInterface,
} from "starknet"
import { Provider, constants } from "starknet"
import { RpcProvider, constants } from "starknet"

import type { NamespaceAdapterOptions } from "../adapter"
import { NamespaceAdapter } from "../adapter"
Expand Down Expand Up @@ -84,12 +84,7 @@ export class StarknetAdapter

this.remoteSigner = new StarknetRemoteSigner(this.walletRpc)

if (rpcUrl) {
this.provider = new Provider({ rpc: { nodeUrl: rpcUrl } })
} else {
const network = this.getNetworkName(this.chainId)
this.provider = new Provider({ sequencer: { network } })
}
this.provider = new RpcProvider({ nodeUrl: rpcUrl })
this.account = new StarknetRemoteAccount(
this.provider,
"",
Expand Down
8 changes: 6 additions & 2 deletions src/helpers/defaultConnectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ export const defaultConnectors = ({
)
}

defaultConnectors.push(new ArgentMobileConnector(argentMobileOptions))
defaultConnectors.push(new WebWalletConnector({ url: webWalletUrl }))
defaultConnectors.push(
new ArgentMobileConnector({ ...argentMobileOptions, provider }),
)
defaultConnectors.push(
new WebWalletConnector({ url: webWalletUrl, provider }),
)

return defaultConnectors
}

0 comments on commit 8e99cbb

Please sign in to comment.