@ututrust/utu-metamask-snap 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +85 -2
- package/package.json +1 -1
- package/snap.manifest.json +2 -2
package/README.md
CHANGED
|
@@ -1,4 +1,87 @@
|
|
|
1
|
-
|
|
1
|
+
# UTU Trust Metamask Snap
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
UTU has built a Snap (basically a MetaMask plugin) to let you get UTU signal inside your MetaMask Wallet right at the moment when you're about to confirm a transaction.
|
|
4
|
+
|
|
5
|
+
At the moment the UTU Snap is only available in MetaMask Flask (an experimental version of MetaMask) that you can think of like a training ground for the big stage.
|
|
6
|
+
|
|
7
|
+
[More information about UTU](https://app.utu.io)
|
|
8
|
+
|
|
9
|
+
UTU Trust SDK provides web-components that access UTU’s Trust API and allows you simple integration with its services.
|
|
10
|
+
|
|
11
|
+
Find the [repository here](https://gitlab.com/ututrust/utu-metamask-snap.git)
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
$ npm i @ututrust/utu-metamask-snap
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Example
|
|
20
|
+
|
|
21
|
+
### Quickstart React
|
|
22
|
+
|
|
23
|
+
```jsx
|
|
24
|
+
import React from 'react';
|
|
25
|
+
|
|
26
|
+
const Snap = () => {
|
|
27
|
+
const getEnv = () => {
|
|
28
|
+
let env = 'staging';
|
|
29
|
+
if (window.location.href.includes('3000')) {
|
|
30
|
+
env = 'local';
|
|
31
|
+
} else if (process.env.REACT_APP_API_URL?.includes("<place-your-production-api-url>")) {
|
|
32
|
+
env = 'production';
|
|
33
|
+
}
|
|
34
|
+
return env;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const installMetaMaskFlask = () => {
|
|
38
|
+
const win = window.open('https://metamask.io/flask/', '_blank');
|
|
39
|
+
win.focus();
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const installSnap = async () => {
|
|
43
|
+
try {
|
|
44
|
+
const accessToken = await getUTUApiAccessToken(); // Replace with your logic for fetching the token
|
|
45
|
+
|
|
46
|
+
// Request to add the UTU Snap
|
|
47
|
+
await window.ethereum.request({
|
|
48
|
+
method: 'wallet_requestSnaps',
|
|
49
|
+
params: {
|
|
50
|
+
'npm:@ututrust/utu-metamask-snap': {},
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const env = getEnv();
|
|
55
|
+
|
|
56
|
+
// Authorize the UTU Snap
|
|
57
|
+
await window.ethereum.request({
|
|
58
|
+
method: 'wallet_invokeSnap',
|
|
59
|
+
params: {
|
|
60
|
+
snapId: 'npm:@ututrust/utu-metamask-snap',
|
|
61
|
+
request: {
|
|
62
|
+
method: 'authorizeUTUSnap',
|
|
63
|
+
params: { token: accessToken, env },
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
console.log("UTU Snap installed and authorized!");
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.error("Error installing or authorizing the UTU Snap:", error);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<div>
|
|
75
|
+
<button onClick={installMetaMaskFlask}>
|
|
76
|
+
Install MetaMask Flask
|
|
77
|
+
</button>
|
|
78
|
+
<button onClick={installSnap}>
|
|
79
|
+
Install UTU Snap into MetaMask Flask
|
|
80
|
+
</button>
|
|
81
|
+
</div>
|
|
82
|
+
);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export default Snap;
|
|
86
|
+
```
|
|
4
87
|
|
package/package.json
CHANGED
package/snap.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.
|
|
2
|
+
"version": "1.0.2",
|
|
3
3
|
"description": "Snap giving UTU Signal!",
|
|
4
4
|
"proposedName": "UTU Trust Signal",
|
|
5
5
|
"repository": {
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"url": "https://gitlab.com/ututrust/utu-metamask-snap.git"
|
|
8
8
|
},
|
|
9
9
|
"source": {
|
|
10
|
-
"shasum": "
|
|
10
|
+
"shasum": "uMAZ0Ky81C+9NU7uCPq/WcLDRHYLFNz46OQlJE39eRo=",
|
|
11
11
|
"location": {
|
|
12
12
|
"npm": {
|
|
13
13
|
"filePath": "dist/bundle.js",
|