-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ab04325
commit d4e4bfa
Showing
32 changed files
with
448 additions
and
142 deletions.
There are no files selected for viewing
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
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
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,18 @@ | ||
import { MetaMaskInpageProvider } from '@metamask/providers'; | ||
|
||
export type EthereumProvider = MetaMaskInpageProvider & { | ||
providers: MetaMaskInpageProvider[]; | ||
detected: MetaMaskInpageProvider[]; | ||
setProvider: (provider: MetaMaskInpageProvider) => void; | ||
}; | ||
|
||
declare global { | ||
interface Window { | ||
ethereum: EthereumProvider; | ||
} | ||
} | ||
|
||
export type SignAminoOptions = { | ||
isADR36?: boolean; | ||
enableExtraEntropy?: boolean; | ||
}; |
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,66 @@ | ||
import { EthereumProvider } from './types'; | ||
import { MM_SNAP_ORIGIN } from './config'; | ||
|
||
/** | ||
* The fool proof version of getting the ethereum provider suggested by | ||
* https://github.com/Montoya/snap-connect-test/blob/0dad2dd53ab2ecbf4b4369230d3aaaeca08c6dae/index.html#L41 | ||
* | ||
* @returns the ethereum provider which supports snaps | ||
*/ | ||
export const getSnapEthereumProvider = async (): Promise<EthereumProvider> => { | ||
let mmFound = false; | ||
if ('detected' in window.ethereum) { | ||
for (const provider of window.ethereum.detected) { | ||
try { | ||
// Detect snaps support | ||
await provider.request({ | ||
method: 'wallet_getSnaps' | ||
}); | ||
// enforces MetaMask as provider | ||
window.ethereum.setProvider(provider); | ||
|
||
mmFound = true; | ||
// @ts-ignore | ||
return provider; | ||
} catch { | ||
// no-op | ||
} | ||
} | ||
} | ||
|
||
if (!mmFound && 'providers' in window.ethereum) { | ||
for (const provider of window.ethereum.providers) { | ||
try { | ||
// Detect snaps support | ||
await provider.request({ | ||
method: 'wallet_getSnaps' | ||
}); | ||
|
||
// @ts-ignore | ||
window.ethereum = provider; | ||
|
||
mmFound = true; | ||
// @ts-ignore | ||
return provider; | ||
} catch { | ||
// no-op | ||
} | ||
} | ||
} | ||
|
||
return window.ethereum; | ||
}; | ||
|
||
export const sendReqToSnap = async (method: string, params: any): Promise<any> => { | ||
const provider = await getSnapEthereumProvider(); | ||
return provider.request({ | ||
method: 'wallet_invokeSnap', | ||
params: { | ||
snapId: MM_SNAP_ORIGIN, | ||
request: { | ||
method, | ||
params | ||
} | ||
} | ||
}); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# @sei-js/metamask-snap | ||
|
||
## 0.0.0-internal-20231226184402 | ||
|
||
### Minor Changes | ||
|
||
- Simplified exports | ||
|
||
### Patch Changes | ||
|
||
- Updated dependencies | ||
- @sei-js/core@0.0.0-internal-20231226184402 | ||
|
||
## 0.0.0-internal-20231226181823 | ||
|
||
### Patch Changes | ||
|
||
- Updated @noble versions | ||
- Updated dependencies | ||
- @sei-js/core@0.0.0-internal-20231226181823 | ||
|
||
## 0.0.0-internal-20231226173424 | ||
|
||
### Patch Changes | ||
|
||
- Moved helper libraries to /core | ||
- Updated dependencies | ||
- @sei-js/core@0.0.0-internal-20231226173424 | ||
|
||
## 0.0.0-internal-20231226165919 | ||
|
||
### Patch Changes | ||
|
||
- Include files in export | ||
- Updated dependencies | ||
- @sei-js/core@0.0.0-internal-20231226165919 | ||
|
||
## 0.0.0-internal-20231226154916 | ||
|
||
### Patch Changes | ||
|
||
- Testing splitting out functions | ||
- Updated dependencies | ||
- @sei-js/core@0.0.0-internal-20231226154916 | ||
|
||
## 0.0.0-internal-20231218170904 | ||
|
||
### Patch Changes | ||
|
||
- Use safe provider throughout | ||
|
||
## 0.0.0-internal-20231218165750 | ||
|
||
### Patch Changes | ||
|
||
- Use safe provider function to get ethereum provider that supports snaps | ||
|
||
## 0.0.0-internal-20231218151625 | ||
|
||
### Patch Changes | ||
|
||
- Adjusted library entry path | ||
|
||
## 0.0.0-internal-20231218151104 | ||
|
||
### Patch Changes | ||
|
||
- Changed package entry file | ||
|
||
## 0.0.0-internal-20231213101440 | ||
|
||
### Patch Changes | ||
|
||
- Release for testing | ||
- ab04325: Initial pre-release of MM snap |
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
Oops, something went wrong.