gun-eth 1.4.27 → 1.4.28

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,8 +1,17 @@
1
1
  {
2
2
  "name": "gun-eth",
3
- "version": "1.4.27",
3
+ "version": "1.4.28",
4
4
  "description": "A GunDB plugin for Ethereum, and Web3",
5
- "main": "dist/gun-eth.min.js",
5
+ "main": "dist/gun-eth.cjs.js",
6
+ "module": "dist/gun-eth.esm.js",
7
+ "browser": "dist/gun-eth.min.js",
8
+ "exports": {
9
+ ".": {
10
+ "require": "./dist/gun-eth.cjs.js",
11
+ "import": "./dist/gun-eth.esm.js",
12
+ "browser": "./dist/gun-eth.min.js"
13
+ }
14
+ },
6
15
  "type": "module",
7
16
  "scripts": {
8
17
  "test": "echo \"Error: no test specified\" && exit 1",
@@ -62,6 +71,7 @@
62
71
  "db"
63
72
  ],
64
73
  "files": [
65
- "dist"
74
+ "dist",
75
+ "src"
66
76
  ]
67
77
  }
@@ -0,0 +1,398 @@
1
+ import { LOCAL_CONFIG } from '../config/local.js';
2
+
3
+ // Indirizzi di produzione per diverse chain
4
+ export const CHAIN_CONFIG = {
5
+ optimismSepolia: {
6
+ STEALTH_ANNOUNCER_ADDRESS: "0xD0F2e9DA59d2DFECFdE67CcF17300BB6093A72f8",
7
+ PROOF_OF_INTEGRITY_ADDRESS: "0x...",
8
+ RPC_URL: "https://sepolia.optimism.io",
9
+ CHAIN_ID: 11155420
10
+ },
11
+ arbitrumSepolia: {
12
+ STEALTH_ANNOUNCER_ADDRESS: "0x...",
13
+ PROOF_OF_INTEGRITY_ADDRESS: "0x...",
14
+ RPC_URL: "https://sepolia-rollup.arbitrum.io/rpc",
15
+ CHAIN_ID: 421614
16
+ },
17
+ localhost: {
18
+ RPC_URL: "http://127.0.0.1:8545",
19
+ CHAIN_ID: 1337
20
+ }
21
+ };
22
+
23
+ // Esporta gli indirizzi di default (Optimism Sepolia)
24
+ export const STEALTH_ANNOUNCER_ADDRESS = CHAIN_CONFIG.optimismSepolia.STEALTH_ANNOUNCER_ADDRESS;
25
+ export const PROOF_OF_INTEGRITY_ADDRESS = CHAIN_CONFIG.optimismSepolia.PROOF_OF_INTEGRITY_ADDRESS;
26
+
27
+ // Funzione per ottenere gli indirizzi corretti
28
+ export function getAddressesForChain(chainName) {
29
+ let config;
30
+
31
+ // Se è localhost, prova a caricare gli indirizzi locali
32
+ if (chainName === 'localhost') {
33
+ try {
34
+ // Carica gli indirizzi dal file generato dal deploy locale
35
+ const localAddresses = require('../config/contract-address.json');
36
+ config = {
37
+ ...CHAIN_CONFIG.localhost,
38
+ ...localAddresses
39
+ };
40
+ console.log("Using local addresses:", config);
41
+ return config;
42
+ } catch (err) {
43
+ console.warn('No local addresses found');
44
+ throw new Error('No local addresses found. Did you run local deployment?');
45
+ }
46
+ }
47
+
48
+ // Altrimenti usa gli indirizzi di produzione
49
+ config = CHAIN_CONFIG[chainName];
50
+ if (!config) {
51
+ throw new Error(`Chain ${chainName} not supported. Supported chains: ${Object.keys(CHAIN_CONFIG).join(', ')}`);
52
+ }
53
+
54
+ return config;
55
+ }
56
+
57
+ // Funzione helper per verificare se siamo in ambiente locale
58
+ export function isLocalEnvironment() {
59
+ return process.env.NODE_ENV === 'development' &&
60
+ typeof window !== 'undefined' &&
61
+ window.location.hostname === 'localhost';
62
+ }
63
+
64
+ export const STEALTH_ANNOUNCER_ABI = [
65
+ {
66
+ "inputs": [
67
+ {
68
+ "internalType": "address",
69
+ "name": "_devAddress",
70
+ "type": "address"
71
+ }
72
+ ],
73
+ "stateMutability": "nonpayable",
74
+ "type": "constructor"
75
+ },
76
+ {
77
+ "anonymous": false,
78
+ "inputs": [
79
+ {
80
+ "internalType": "string",
81
+ "name": "senderPublicKey",
82
+ "type": "string"
83
+ },
84
+ {
85
+ "internalType": "string",
86
+ "name": "spendingPublicKey",
87
+ "type": "string"
88
+ },
89
+ {
90
+ "internalType": "address",
91
+ "name": "stealthAddress",
92
+ "type": "address"
93
+ },
94
+ {
95
+ "internalType": "uint256",
96
+ "name": "timestamp",
97
+ "type": "uint256"
98
+ }
99
+ ],
100
+ "name": "StealthPaymentAnnounced",
101
+ "type": "event"
102
+ },
103
+ {
104
+ "anonymous": false,
105
+ "inputs": [
106
+ {
107
+ "internalType": "address",
108
+ "name": "newAddress",
109
+ "type": "address"
110
+ }
111
+ ],
112
+ "name": "DevAddressUpdated",
113
+ "type": "event"
114
+ },
115
+ {
116
+ "anonymous": false,
117
+ "inputs": [
118
+ {
119
+ "internalType": "uint256",
120
+ "name": "newFee",
121
+ "type": "uint256"
122
+ }
123
+ ],
124
+ "name": "DevFeeUpdated",
125
+ "type": "event"
126
+ },
127
+ {
128
+ "inputs": [
129
+ {
130
+ "internalType": "string",
131
+ "name": "senderPublicKey",
132
+ "type": "string"
133
+ },
134
+ {
135
+ "internalType": "string",
136
+ "name": "spendingPublicKey",
137
+ "type": "string"
138
+ },
139
+ {
140
+ "internalType": "address",
141
+ "name": "stealthAddress",
142
+ "type": "address"
143
+ }
144
+ ],
145
+ "name": "announcePayment",
146
+ "outputs": [],
147
+ "stateMutability": "payable",
148
+ "type": "function"
149
+ },
150
+ {
151
+ "inputs": [],
152
+ "name": "devAddress",
153
+ "outputs": [
154
+ {
155
+ "internalType": "address",
156
+ "name": "",
157
+ "type": "address"
158
+ }
159
+ ],
160
+ "stateMutability": "view",
161
+ "type": "function"
162
+ },
163
+ {
164
+ "inputs": [],
165
+ "name": "devFee",
166
+ "outputs": [
167
+ {
168
+ "internalType": "uint256",
169
+ "name": "",
170
+ "type": "uint256"
171
+ }
172
+ ],
173
+ "stateMutability": "view",
174
+ "type": "function"
175
+ },
176
+ {
177
+ "inputs": [],
178
+ "name": "getAnnouncementsCount",
179
+ "outputs": [
180
+ {
181
+ "internalType": "uint256",
182
+ "name": "",
183
+ "type": "uint256"
184
+ }
185
+ ],
186
+ "stateMutability": "view",
187
+ "type": "function"
188
+ },
189
+ {
190
+ "inputs": [
191
+ {
192
+ "internalType": "uint256",
193
+ "name": "fromIndex",
194
+ "type": "uint256"
195
+ },
196
+ {
197
+ "internalType": "uint256",
198
+ "name": "toIndex",
199
+ "type": "uint256"
200
+ }
201
+ ],
202
+ "name": "getAnnouncementsInRange",
203
+ "outputs": [
204
+ {
205
+ "components": [
206
+ {
207
+ "internalType": "string",
208
+ "name": "senderPublicKey",
209
+ "type": "string"
210
+ },
211
+ {
212
+ "internalType": "string",
213
+ "name": "spendingPublicKey",
214
+ "type": "string"
215
+ },
216
+ {
217
+ "internalType": "address",
218
+ "name": "stealthAddress",
219
+ "type": "address"
220
+ },
221
+ {
222
+ "internalType": "uint256",
223
+ "name": "timestamp",
224
+ "type": "uint256"
225
+ }
226
+ ],
227
+ "internalType": "struct StealthAnnouncer.StealthAnnouncement[]",
228
+ "name": "",
229
+ "type": "tuple[]"
230
+ }
231
+ ],
232
+ "stateMutability": "view",
233
+ "type": "function"
234
+ },
235
+ {
236
+ "inputs": [
237
+ {
238
+ "internalType": "uint256",
239
+ "name": "_newFee",
240
+ "type": "uint256"
241
+ }
242
+ ],
243
+ "name": "updateDevFee",
244
+ "outputs": [],
245
+ "stateMutability": "nonpayable",
246
+ "type": "function"
247
+ },
248
+ {
249
+ "inputs": [
250
+ {
251
+ "internalType": "address",
252
+ "name": "_newAddress",
253
+ "type": "address"
254
+ }
255
+ ],
256
+ "name": "updateDevAddress",
257
+ "outputs": [],
258
+ "stateMutability": "nonpayable",
259
+ "type": "function"
260
+ },
261
+ {
262
+ "inputs": [],
263
+ "name": "withdrawStuckETH",
264
+ "outputs": [],
265
+ "stateMutability": "nonpayable",
266
+ "type": "function"
267
+ }
268
+ ];
269
+
270
+ export const PROOF_OF_INTEGRITY_ABI = [
271
+ {
272
+ "inputs": [
273
+ {
274
+ "internalType": "bytes[]",
275
+ "name": "nodeIds",
276
+ "type": "bytes[]"
277
+ },
278
+ {
279
+ "internalType": "bytes32[]",
280
+ "name": "contentHashes",
281
+ "type": "bytes32[]"
282
+ }
283
+ ],
284
+ "name": "batchUpdateData",
285
+ "outputs": [],
286
+ "stateMutability": "nonpayable",
287
+ "type": "function"
288
+ },
289
+ {
290
+ "anonymous": false,
291
+ "inputs": [
292
+ {
293
+ "indexed": true,
294
+ "internalType": "bytes",
295
+ "name": "nodeId",
296
+ "type": "bytes"
297
+ },
298
+ {
299
+ "indexed": false,
300
+ "internalType": "bytes32",
301
+ "name": "contentHash",
302
+ "type": "bytes32"
303
+ },
304
+ {
305
+ "indexed": false,
306
+ "internalType": "address",
307
+ "name": "updater",
308
+ "type": "address"
309
+ }
310
+ ],
311
+ "name": "DataUpdated",
312
+ "type": "event"
313
+ },
314
+ {
315
+ "inputs": [
316
+ {
317
+ "internalType": "bytes",
318
+ "name": "nodeId",
319
+ "type": "bytes"
320
+ }
321
+ ],
322
+ "name": "getLatestRecord",
323
+ "outputs": [
324
+ {
325
+ "internalType": "bytes32",
326
+ "name": "",
327
+ "type": "bytes32"
328
+ },
329
+ {
330
+ "internalType": "uint256",
331
+ "name": "",
332
+ "type": "uint256"
333
+ },
334
+ {
335
+ "internalType": "address",
336
+ "name": "",
337
+ "type": "address"
338
+ }
339
+ ],
340
+ "stateMutability": "view",
341
+ "type": "function"
342
+ },
343
+ {
344
+ "inputs": [
345
+ {
346
+ "internalType": "bytes",
347
+ "name": "nodeId",
348
+ "type": "bytes"
349
+ },
350
+ {
351
+ "internalType": "bytes32",
352
+ "name": "contentHash",
353
+ "type": "bytes32"
354
+ }
355
+ ],
356
+ "name": "updateData",
357
+ "outputs": [],
358
+ "stateMutability": "nonpayable",
359
+ "type": "function"
360
+ },
361
+ {
362
+ "inputs": [
363
+ {
364
+ "internalType": "bytes",
365
+ "name": "nodeId",
366
+ "type": "bytes"
367
+ },
368
+ {
369
+ "internalType": "bytes32",
370
+ "name": "contentHash",
371
+ "type": "bytes32"
372
+ }
373
+ ],
374
+ "name": "verifyData",
375
+ "outputs": [
376
+ {
377
+ "internalType": "bool",
378
+ "name": "",
379
+ "type": "bool"
380
+ },
381
+ {
382
+ "internalType": "uint256",
383
+ "name": "",
384
+ "type": "uint256"
385
+ },
386
+ {
387
+ "internalType": "address",
388
+ "name": "",
389
+ "type": "address"
390
+ }
391
+ ],
392
+ "stateMutability": "view",
393
+ "type": "function"
394
+ }
395
+ ];
396
+
397
+
398
+ export const SHINE_OPTIMISM_SEPOLIA = "0x43D838b683F772F08f321E5FA265ad3e333BE9C2";
@@ -0,0 +1,4 @@
1
+ {
2
+ "STEALTH_ANNOUNCER_ADDRESS": "",
3
+ "PROOF_OF_INTEGRITY_ADDRESS": ""
4
+ }
@@ -0,0 +1,29 @@
1
+ let contractAddresses = {
2
+ PROOF_OF_INTEGRITY_ADDRESS: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
3
+ STEALTH_ANNOUNCER_ADDRESS: "0x5FbDB2315678afecb367f032d93F642f64180aa3"
4
+ };
5
+
6
+ if (typeof window === 'undefined') {
7
+ const { fileURLToPath } = require('url');
8
+ const { dirname } = require('path');
9
+ const { readFileSync } = require('fs');
10
+ const { join } = require('path');
11
+
12
+ try {
13
+ const __filename = fileURLToPath(import.meta.url);
14
+ const __dirname = dirname(__filename);
15
+ const rawdata = readFileSync(join(__dirname, 'contract-address.json'), 'utf8');
16
+ contractAddresses = JSON.parse(rawdata);
17
+ console.log("Loaded contract addresses:", contractAddresses);
18
+ } catch (error) {
19
+ console.warn("Warning: contract-address.json not found or invalid");
20
+ }
21
+ }
22
+
23
+ export const LOCAL_CONFIG = {
24
+ CHAIN_ID: 1337,
25
+ PROOF_OF_INTEGRITY_ADDRESS: contractAddresses.PROOF_OF_INTEGRITY_ADDRESS,
26
+ STEALTH_ANNOUNCER_ADDRESS: contractAddresses.STEALTH_ANNOUNCER_ADDRESS,
27
+ RPC_URL: "http://127.0.0.1:8545",
28
+ GUN_PEER: "http://localhost:8765/gun"
29
+ };