-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'refs/heads/feat/argent-one-button-connector' into feat/…
…argent-one-button-connector-ui
- Loading branch information
Showing
27 changed files
with
303 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import type { StarknetWindowObject } from "@starknet-io/types-js" | ||
|
||
export function getInjectedArgentX() { | ||
return window?.starknet_argentX as | ||
| (StarknetWindowObject & { | ||
isInAppBrowser: boolean | ||
}) | ||
| undefined | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { getInjectedArgentX } from "./getInjectedArgentX" | ||
|
||
export const isInArgentMobileAppBrowser = (): boolean => { | ||
if (typeof window === "undefined") { | ||
return false | ||
} | ||
|
||
const argentX = getInjectedArgentX() | ||
|
||
if (!argentX) { | ||
return false | ||
} | ||
|
||
return argentX.isInAppBrowser | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { ArgentX } from "../injected/argentX" | ||
import { | ||
ArgentMobileBaseConnector, | ||
ArgentMobileConnectorOptions, | ||
isInArgentMobileAppBrowser, | ||
} from "./argentMobile" | ||
|
||
import { getInjectedArgentX } from "./helpers/getInjectedArgentX" | ||
import { DEFAULT_ARGENT_MOBILE_ICON } from "./argentMobile/constants" | ||
import { StarknetkitCompoundConnector } from "../connector" | ||
|
||
/** | ||
* Checks if window object has injected ArgentX | ||
*/ | ||
function hasInjectedArgentX(): boolean { | ||
return Boolean(getInjectedArgentX()) | ||
} | ||
|
||
type ArgentCompoundSettings = ArgentMobileConnectorOptions | ||
|
||
// TODO think about naming | ||
// - ArgentUnified | ||
// - ArgentOneButton | ||
// - ArgentCompound | ||
// - Argent | ||
|
||
// TODO | ||
// - get qr code | ||
// - get full modal for both ux flows? | ||
|
||
export class ArgentCompound | ||
extends StarknetkitCompoundConnector | ||
implements StarknetkitCompoundConnector | ||
{ | ||
readonly argentX?: ArgentX | ||
readonly argentMobile?: ArgentMobileBaseConnector | ||
|
||
readonly connector: ArgentX | ArgentMobileBaseConnector | ||
readonly fallbackConnector: ArgentX | ArgentMobileBaseConnector | ||
|
||
constructor(settings: ArgentCompoundSettings) { | ||
super() | ||
|
||
this.argentX = new ArgentX({ | ||
name: "Argent", | ||
icon: DEFAULT_ARGENT_MOBILE_ICON, | ||
isCompoundConnector: true, | ||
}) | ||
this.argentMobile = new ArgentMobileBaseConnector({ | ||
isCompoundConnector: true, | ||
...settings, | ||
}) | ||
|
||
if (hasInjectedArgentX() || isInArgentMobileAppBrowser()) { | ||
this.connector = this.argentX | ||
this.fallbackConnector = this.argentMobile | ||
} else { | ||
this.connector = this.argentMobile | ||
this.fallbackConnector = this.argentX | ||
} | ||
} | ||
|
||
getArgentXConnector() { | ||
return this.argentX | ||
} | ||
|
||
getArgentMobileConnector() { | ||
return this.argentMobile | ||
} | ||
} | ||
|
||
// | ||
// // Second way | ||
// const compoundConnector = new ArgentCompound({ | ||
// url: typeof window !== "undefined" ? window.location.href : "", | ||
// dappName: "Example dapp", | ||
// }) | ||
// | ||
// compoundConnector.getConector() | ||
// | ||
// compoundConnector.getArgentX() | ||
// compoundConnector.getArgentMobile() | ||
// compoundConnector.getFallback() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
export * from "./connector" | ||
export * from "./injected" | ||
export * from "./webwallet" | ||
export * from "./argentMobile" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { InjectedConnector, InjectedConnectorOptions } from "./index" | ||
|
||
export class ArgentX extends InjectedConnector { | ||
constructor(options?: Omit<InjectedConnectorOptions, "id">) { | ||
super({ options: { id: "argentX", ...options } }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { InjectedConnector, InjectedConnectorOptions } from "./index" | ||
|
||
export class Braavos extends InjectedConnector { | ||
constructor(options?: Omit<InjectedConnectorOptions, "id">) { | ||
super({ options: { id: "braavos", ...options } }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.