zano_web3 3.6.0 → 3.9.0
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/index.ts +2 -2
- package/package.json +2 -1
- package/src/server.ts +89 -89
- package/src/zanoWallet.ts +4 -0
package/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ import zanoWallet from "./src/zanoWallet";
|
|
|
3
3
|
import {useZanoWallet} from "./src/hooks";
|
|
4
4
|
export {useZanoWallet};
|
|
5
5
|
|
|
6
|
-
import validateWallet from "./src/server";
|
|
7
|
-
export {validateWallet};
|
|
6
|
+
// import validateWallet from "./src/server";
|
|
7
|
+
// export {validateWallet};
|
|
8
8
|
|
|
9
9
|
export default zanoWallet;
|
package/package.json
CHANGED
package/src/server.ts
CHANGED
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
|
-
|
|
3
|
-
interface BaseAuthData {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
interface AliasAuth extends BaseAuthData {
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface PkeyAuth extends BaseAuthData {
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
type AuthData = AliasAuth | PkeyAuth;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
interface ValidationParams {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
async function validateWallet(rpcUrl: string, authData: AuthData) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
1
|
+
// import axios from 'axios';
|
|
2
|
+
|
|
3
|
+
// interface BaseAuthData {
|
|
4
|
+
// address: string;
|
|
5
|
+
// signature: string;
|
|
6
|
+
// message: string;
|
|
7
|
+
// }
|
|
8
|
+
|
|
9
|
+
// interface AliasAuth extends BaseAuthData {
|
|
10
|
+
// alias: string;
|
|
11
|
+
// }
|
|
12
|
+
|
|
13
|
+
// interface PkeyAuth extends BaseAuthData {
|
|
14
|
+
// pkey: string;
|
|
15
|
+
// }
|
|
16
|
+
|
|
17
|
+
// type AuthData = AliasAuth | PkeyAuth;
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
// interface ValidationParams {
|
|
21
|
+
// buff: string;
|
|
22
|
+
// sig: string;
|
|
23
|
+
// alias?: string;
|
|
24
|
+
// pkey?: string;
|
|
25
|
+
// }
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
// async function validateWallet(rpcUrl: string, authData: AuthData) {
|
|
29
|
+
|
|
30
|
+
// async function fetchZanoApi(method: string, params: any) {
|
|
31
|
+
// return await axios.post(
|
|
32
|
+
// rpcUrl,
|
|
33
|
+
// {
|
|
34
|
+
// "id": 0,
|
|
35
|
+
// "jsonrpc": "2.0",
|
|
36
|
+
// "method": method,
|
|
37
|
+
// "params": params,
|
|
38
|
+
// }
|
|
39
|
+
// ).then(res => res.data);
|
|
40
|
+
// }
|
|
41
|
+
|
|
42
|
+
// const { message, address, signature } = authData;
|
|
43
|
+
|
|
44
|
+
// const alias = (authData as AliasAuth).alias || undefined;
|
|
45
|
+
// const pkey = (authData as PkeyAuth).pkey || undefined;
|
|
46
|
+
|
|
47
|
+
// if (!message || (!alias && !pkey) || !signature) {
|
|
48
|
+
// return false;
|
|
49
|
+
// }
|
|
50
|
+
|
|
51
|
+
// const validationParams: ValidationParams = {
|
|
52
|
+
// "buff": Buffer.from(message).toString("base64"),
|
|
53
|
+
// "sig": signature
|
|
54
|
+
// };
|
|
55
|
+
|
|
56
|
+
// if (alias) {
|
|
57
|
+
// validationParams['alias'] = alias;
|
|
58
|
+
// } else {
|
|
59
|
+
// validationParams['pkey'] = pkey;
|
|
60
|
+
// }
|
|
61
|
+
|
|
62
|
+
// const response = await fetchZanoApi(
|
|
63
|
+
// 'validate_signature',
|
|
64
|
+
// validationParams
|
|
65
|
+
// );
|
|
66
|
+
|
|
67
|
+
// const valid = response?.result?.status === 'OK';
|
|
68
|
+
|
|
69
|
+
// if (!valid) {
|
|
70
|
+
// return false;
|
|
71
|
+
// }
|
|
72
|
+
|
|
73
|
+
// if (alias) {
|
|
74
|
+
// const aliasDetailsResponse = await fetchZanoApi(
|
|
75
|
+
// 'get_alias_details',
|
|
76
|
+
// {
|
|
77
|
+
// "alias": alias,
|
|
78
|
+
// }
|
|
79
|
+
// );
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
// const aliasDetails = aliasDetailsResponse?.result?.alias_details;
|
|
82
|
+
// const aliasAddress = aliasDetails?.address;
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
// const addressValid = !!aliasAddress && aliasAddress === address;
|
|
85
85
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
// if (!addressValid) {
|
|
87
|
+
// return false;
|
|
88
|
+
// }
|
|
89
|
+
// }
|
|
90
90
|
|
|
91
|
-
|
|
92
|
-
}
|
|
91
|
+
// return valid;
|
|
92
|
+
// }
|
|
93
93
|
|
|
94
|
-
export default validateWallet;
|
|
94
|
+
// export default validateWallet;
|
package/src/zanoWallet.ts
CHANGED
|
@@ -117,6 +117,10 @@ class ZanoWallet {
|
|
|
117
117
|
const existingWallet = this.params.useLocalStorage ? this.getSavedWalletCredentials() : undefined;
|
|
118
118
|
|
|
119
119
|
const existingWalletValid = existingWallet && existingWallet.address === walletData.address;
|
|
120
|
+
|
|
121
|
+
console.log('existingWalletValid', existingWalletValid);
|
|
122
|
+
console.log('existingWallet', existingWallet);
|
|
123
|
+
console.log('walletData', walletData);
|
|
120
124
|
|
|
121
125
|
if (existingWalletValid) {
|
|
122
126
|
nonce = existingWallet.nonce;
|