gun-eth 1.4.30 → 1.4.31
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/gun-eth.cjs.js +22 -12632
- package/dist/gun-eth.cjs.js.map +1 -1
- package/dist/gun-eth.esm.js +1368 -9
- package/dist/gun-eth.esm.js.map +1 -1
- package/dist/gun-eth.min.js +1 -9
- package/dist/gun-eth.min.js.map +1 -1
- package/dist/gun-eth.mjs +13 -12623
- package/dist/gun-eth.mjs.map +1 -1
- package/package.json +2 -2
- package/src/index.js +18 -8
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "gun-eth",
|
3
|
-
"version": "1.4.
|
3
|
+
"version": "1.4.31",
|
4
4
|
"description": "A GunDB plugin for Ethereum, and Web3",
|
5
5
|
"main": "dist/gun-eth.cjs.js",
|
6
6
|
"module": "dist/gun-eth.mjs",
|
@@ -58,7 +58,7 @@
|
|
58
58
|
"@types/mocha": "^10.0.1",
|
59
59
|
"chai": "^4.2.0",
|
60
60
|
"cross-env": "^7.0.3",
|
61
|
-
"ethers": "^6.
|
61
|
+
"ethers": "^6.13.4",
|
62
62
|
"gun": "^0.2020.1239",
|
63
63
|
"hardhat": "^2.17.0",
|
64
64
|
"hardhat-gas-reporter": "^1.0.8",
|
package/src/index.js
CHANGED
@@ -15,6 +15,16 @@ import { LOCAL_CONFIG } from "./config/local.js";
|
|
15
15
|
import { fileURLToPath } from 'url';
|
16
16
|
import { dirname } from 'path';
|
17
17
|
import { readFileSync } from 'fs';
|
18
|
+
import {
|
19
|
+
JsonRpcProvider,
|
20
|
+
BrowserProvider,
|
21
|
+
Wallet,
|
22
|
+
Contract,
|
23
|
+
concat,
|
24
|
+
keccak256,
|
25
|
+
verifyMessage,
|
26
|
+
getBytes
|
27
|
+
} from 'ethers';
|
18
28
|
|
19
29
|
let PROOF_CONTRACT_ADDRESS;
|
20
30
|
let rpcUrl = "";
|
@@ -117,13 +127,13 @@ export const getSigner = async () => {
|
|
117
127
|
chainId: LOCAL_CONFIG.CHAIN_ID,
|
118
128
|
name: "localhost"
|
119
129
|
});
|
120
|
-
return new
|
130
|
+
return new Wallet(privateKey, provider);
|
121
131
|
} else if (
|
122
132
|
typeof window !== "undefined" &&
|
123
133
|
typeof window.ethereum !== "undefined"
|
124
134
|
) {
|
125
135
|
await window.ethereum.request({ method: "eth_requestAccounts" });
|
126
|
-
const provider = new
|
136
|
+
const provider = new BrowserProvider(window.ethereum);
|
127
137
|
return provider.getSigner();
|
128
138
|
} else {
|
129
139
|
throw new Error("No valid Ethereum provider found");
|
@@ -138,17 +148,17 @@ export const getSigner = async () => {
|
|
138
148
|
*/
|
139
149
|
export function deriveStealthAddress(sharedSecret, spendingPublicKey) {
|
140
150
|
try {
|
141
|
-
const sharedSecretBytes =
|
142
|
-
const spendingPublicKeyBytes =
|
151
|
+
const sharedSecretBytes = getBytes(sharedSecret);
|
152
|
+
const spendingPublicKeyBytes = getBytes(spendingPublicKey);
|
143
153
|
|
144
|
-
const stealthPrivateKey =
|
145
|
-
|
154
|
+
const stealthPrivateKey = keccak256(
|
155
|
+
concat([
|
146
156
|
sharedSecretBytes,
|
147
157
|
spendingPublicKeyBytes
|
148
158
|
])
|
149
159
|
);
|
150
160
|
|
151
|
-
const stealthWallet = new
|
161
|
+
const stealthWallet = new Wallet(stealthPrivateKey);
|
152
162
|
|
153
163
|
console.log("Debug deriveStealthAddress:", {
|
154
164
|
sharedSecretHex: stealthPrivateKey,
|
@@ -198,7 +208,7 @@ Gun.chain.getSigner = getSigner();
|
|
198
208
|
*/
|
199
209
|
Gun.chain.verifySignature = async function (message, signature) {
|
200
210
|
try {
|
201
|
-
const recoveredAddress =
|
211
|
+
const recoveredAddress = verifyMessage(message, signature);
|
202
212
|
return recoveredAddress;
|
203
213
|
} catch (error) {
|
204
214
|
console.error("Error verifying signature:", error);
|