-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement ApeX StarkKey recovery (#415)
* implement apex starkkey recovery Co-authored-by: Piotr Szlachciak <[email protected]> * implement apex testnet starkkey recovery * pass isMainnet in context * change isMainnet flag to chainId * improve user experience regarding metamask * fix linter errors * fix failing test --------- Co-authored-by: Piotr Szlachciak <[email protected]>
- Loading branch information
1 parent
969e3f4
commit 3acd964
Showing
17 changed files
with
237 additions
and
84 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
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
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
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,25 @@ | ||
export class MetamaskClient { | ||
constructor( | ||
private readonly provider: Provider, | ||
private readonly instanceChainId: number | ||
) {} | ||
|
||
async getChainId(): Promise<string> { | ||
return (await this.provider.request({ method: 'eth_chainId' })) as string | ||
} | ||
|
||
async switchToInstanceNetwork() { | ||
return await this.switchToNetwork(`0x${this.instanceChainId.toString(16)}`) | ||
} | ||
|
||
async switchToNetwork(chainId: `0x${string}`) { | ||
return await this.provider.request({ | ||
method: 'wallet_switchEthereumChain', | ||
params: [{ chainId }], | ||
}) | ||
} | ||
|
||
async requestAccounts() { | ||
return await this.provider.request({ method: 'eth_requestAccounts' }) | ||
} | ||
} |
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
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
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.