@izi-noir/sdk 0.1.6 → 0.1.8
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/dist/index.cjs +74 -8
- package/dist/index.js +74 -8
- package/dist/providers/arkworks.cjs +79 -8
- package/dist/providers/arkworks.js +79 -8
- package/dist/providers/barretenberg.cjs +79 -8
- package/dist/providers/barretenberg.js +79 -8
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -191,8 +191,15 @@ async function initWasm() {
|
|
|
191
191
|
} else {
|
|
192
192
|
const moduleUrl = new URL(import_meta.url);
|
|
193
193
|
const isSourceFile = moduleUrl.pathname.includes("/src/");
|
|
194
|
-
const
|
|
195
|
-
|
|
194
|
+
const isViteProduction = moduleUrl.pathname.includes("/assets/");
|
|
195
|
+
let wasmJsUrl;
|
|
196
|
+
if (isSourceFile) {
|
|
197
|
+
wasmJsUrl = new URL("../../wasm/web/arkworks_groth16_wasm.js", moduleUrl);
|
|
198
|
+
} else if (isViteProduction) {
|
|
199
|
+
wasmJsUrl = new URL("/wasm/web/arkworks_groth16_wasm.js", moduleUrl.origin);
|
|
200
|
+
} else {
|
|
201
|
+
wasmJsUrl = new URL("./wasm/web/arkworks_groth16_wasm.js", moduleUrl);
|
|
202
|
+
}
|
|
196
203
|
const module2 = await import(
|
|
197
204
|
/* @vite-ignore */
|
|
198
205
|
wasmJsUrl.href
|
|
@@ -1479,6 +1486,18 @@ var IziNoir = class _IziNoir {
|
|
|
1479
1486
|
const networkConfig = NETWORK_CONFIG[this._network];
|
|
1480
1487
|
const { Connection, Transaction, PublicKey } = await import("@solana/web3.js");
|
|
1481
1488
|
const connection = new Connection(networkConfig.rpcUrl, "confirmed");
|
|
1489
|
+
const vkPubkey = new PublicKey(vk);
|
|
1490
|
+
const accountInfo = await connection.getAccountInfo(vkPubkey);
|
|
1491
|
+
if (!accountInfo) {
|
|
1492
|
+
throw new Error(
|
|
1493
|
+
`VK account ${vk} does not exist on ${this._network}. Did deploy() succeed? Check the account on explorer: ${getExplorerAccountUrl(this._network, vk)}`
|
|
1494
|
+
);
|
|
1495
|
+
}
|
|
1496
|
+
if (accountInfo.data.length < 8) {
|
|
1497
|
+
throw new Error(
|
|
1498
|
+
`VK account ${vk} has invalid data (${accountInfo.data.length} bytes). Expected at least 8 bytes for a valid account.`
|
|
1499
|
+
);
|
|
1500
|
+
}
|
|
1482
1501
|
const builder = new SolanaTransactionBuilder({
|
|
1483
1502
|
programId: networkConfig.programId,
|
|
1484
1503
|
computeUnits: 4e5
|
|
@@ -1506,12 +1525,59 @@ var IziNoir = class _IziNoir {
|
|
|
1506
1525
|
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");
|
|
1507
1526
|
tx.recentBlockhash = blockhash;
|
|
1508
1527
|
tx.feePayer = new PublicKey(wallet.publicKey.toBase58());
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1528
|
+
try {
|
|
1529
|
+
const simulation = await connection.simulateTransaction(tx);
|
|
1530
|
+
if (simulation.value.err) {
|
|
1531
|
+
const logs = simulation.value.logs?.join("\n") || "No logs available";
|
|
1532
|
+
throw new Error(
|
|
1533
|
+
`Transaction simulation failed:
|
|
1534
|
+
Error: ${JSON.stringify(simulation.value.err)}
|
|
1535
|
+
Logs:
|
|
1536
|
+
${logs}`
|
|
1537
|
+
);
|
|
1538
|
+
}
|
|
1539
|
+
} catch (simError) {
|
|
1540
|
+
if (simError instanceof Error && simError.message.includes("Transaction simulation failed")) {
|
|
1541
|
+
throw simError;
|
|
1542
|
+
}
|
|
1543
|
+
const err = simError;
|
|
1544
|
+
throw new Error(
|
|
1545
|
+
`Failed to simulate transaction: ${err.message}
|
|
1546
|
+
VK Account: ${vk}
|
|
1547
|
+
Network: ${this._network}
|
|
1548
|
+
Proof size: ${proofData.proof.bytes.length} bytes
|
|
1549
|
+
Public inputs: ${proofData.publicInputs.hex.length} items`
|
|
1550
|
+
);
|
|
1551
|
+
}
|
|
1552
|
+
let signature;
|
|
1553
|
+
try {
|
|
1554
|
+
signature = await wallet.sendTransaction(tx, connection);
|
|
1555
|
+
} catch (sendError) {
|
|
1556
|
+
const originalError = sendError;
|
|
1557
|
+
const enhancedError = new Error(
|
|
1558
|
+
`Failed to send verify transaction: ${originalError.message}
|
|
1559
|
+
VK Account: ${vk}
|
|
1560
|
+
Network: ${this._network}
|
|
1561
|
+
Proof size: ${proofData.proof.bytes.length} bytes
|
|
1562
|
+
Public inputs: ${proofData.publicInputs.hex.length} items`
|
|
1563
|
+
);
|
|
1564
|
+
enhancedError.cause = originalError;
|
|
1565
|
+
throw enhancedError;
|
|
1566
|
+
}
|
|
1567
|
+
try {
|
|
1568
|
+
await connection.confirmTransaction({
|
|
1569
|
+
signature,
|
|
1570
|
+
blockhash,
|
|
1571
|
+
lastValidBlockHeight
|
|
1572
|
+
});
|
|
1573
|
+
} catch (confirmError) {
|
|
1574
|
+
const err = confirmError;
|
|
1575
|
+
throw new Error(
|
|
1576
|
+
`Transaction sent but confirmation failed: ${err.message}
|
|
1577
|
+
Signature: ${signature}
|
|
1578
|
+
Check on explorer: ${getExplorerTxUrl(this._network, signature)}`
|
|
1579
|
+
);
|
|
1580
|
+
}
|
|
1515
1581
|
return {
|
|
1516
1582
|
verified: true,
|
|
1517
1583
|
signature,
|
package/dist/index.js
CHANGED
|
@@ -172,8 +172,15 @@ async function initWasm() {
|
|
|
172
172
|
} else {
|
|
173
173
|
const moduleUrl = new URL(import.meta.url);
|
|
174
174
|
const isSourceFile = moduleUrl.pathname.includes("/src/");
|
|
175
|
-
const
|
|
176
|
-
|
|
175
|
+
const isViteProduction = moduleUrl.pathname.includes("/assets/");
|
|
176
|
+
let wasmJsUrl;
|
|
177
|
+
if (isSourceFile) {
|
|
178
|
+
wasmJsUrl = new URL("../../wasm/web/arkworks_groth16_wasm.js", moduleUrl);
|
|
179
|
+
} else if (isViteProduction) {
|
|
180
|
+
wasmJsUrl = new URL("/wasm/web/arkworks_groth16_wasm.js", moduleUrl.origin);
|
|
181
|
+
} else {
|
|
182
|
+
wasmJsUrl = new URL("./wasm/web/arkworks_groth16_wasm.js", moduleUrl);
|
|
183
|
+
}
|
|
177
184
|
const module = await import(
|
|
178
185
|
/* @vite-ignore */
|
|
179
186
|
wasmJsUrl.href
|
|
@@ -1411,6 +1418,18 @@ var IziNoir = class _IziNoir {
|
|
|
1411
1418
|
const networkConfig = NETWORK_CONFIG[this._network];
|
|
1412
1419
|
const { Connection, Transaction, PublicKey } = await import("@solana/web3.js");
|
|
1413
1420
|
const connection = new Connection(networkConfig.rpcUrl, "confirmed");
|
|
1421
|
+
const vkPubkey = new PublicKey(vk);
|
|
1422
|
+
const accountInfo = await connection.getAccountInfo(vkPubkey);
|
|
1423
|
+
if (!accountInfo) {
|
|
1424
|
+
throw new Error(
|
|
1425
|
+
`VK account ${vk} does not exist on ${this._network}. Did deploy() succeed? Check the account on explorer: ${getExplorerAccountUrl(this._network, vk)}`
|
|
1426
|
+
);
|
|
1427
|
+
}
|
|
1428
|
+
if (accountInfo.data.length < 8) {
|
|
1429
|
+
throw new Error(
|
|
1430
|
+
`VK account ${vk} has invalid data (${accountInfo.data.length} bytes). Expected at least 8 bytes for a valid account.`
|
|
1431
|
+
);
|
|
1432
|
+
}
|
|
1414
1433
|
const builder = new SolanaTransactionBuilder({
|
|
1415
1434
|
programId: networkConfig.programId,
|
|
1416
1435
|
computeUnits: 4e5
|
|
@@ -1438,12 +1457,59 @@ var IziNoir = class _IziNoir {
|
|
|
1438
1457
|
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");
|
|
1439
1458
|
tx.recentBlockhash = blockhash;
|
|
1440
1459
|
tx.feePayer = new PublicKey(wallet.publicKey.toBase58());
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1460
|
+
try {
|
|
1461
|
+
const simulation = await connection.simulateTransaction(tx);
|
|
1462
|
+
if (simulation.value.err) {
|
|
1463
|
+
const logs = simulation.value.logs?.join("\n") || "No logs available";
|
|
1464
|
+
throw new Error(
|
|
1465
|
+
`Transaction simulation failed:
|
|
1466
|
+
Error: ${JSON.stringify(simulation.value.err)}
|
|
1467
|
+
Logs:
|
|
1468
|
+
${logs}`
|
|
1469
|
+
);
|
|
1470
|
+
}
|
|
1471
|
+
} catch (simError) {
|
|
1472
|
+
if (simError instanceof Error && simError.message.includes("Transaction simulation failed")) {
|
|
1473
|
+
throw simError;
|
|
1474
|
+
}
|
|
1475
|
+
const err = simError;
|
|
1476
|
+
throw new Error(
|
|
1477
|
+
`Failed to simulate transaction: ${err.message}
|
|
1478
|
+
VK Account: ${vk}
|
|
1479
|
+
Network: ${this._network}
|
|
1480
|
+
Proof size: ${proofData.proof.bytes.length} bytes
|
|
1481
|
+
Public inputs: ${proofData.publicInputs.hex.length} items`
|
|
1482
|
+
);
|
|
1483
|
+
}
|
|
1484
|
+
let signature;
|
|
1485
|
+
try {
|
|
1486
|
+
signature = await wallet.sendTransaction(tx, connection);
|
|
1487
|
+
} catch (sendError) {
|
|
1488
|
+
const originalError = sendError;
|
|
1489
|
+
const enhancedError = new Error(
|
|
1490
|
+
`Failed to send verify transaction: ${originalError.message}
|
|
1491
|
+
VK Account: ${vk}
|
|
1492
|
+
Network: ${this._network}
|
|
1493
|
+
Proof size: ${proofData.proof.bytes.length} bytes
|
|
1494
|
+
Public inputs: ${proofData.publicInputs.hex.length} items`
|
|
1495
|
+
);
|
|
1496
|
+
enhancedError.cause = originalError;
|
|
1497
|
+
throw enhancedError;
|
|
1498
|
+
}
|
|
1499
|
+
try {
|
|
1500
|
+
await connection.confirmTransaction({
|
|
1501
|
+
signature,
|
|
1502
|
+
blockhash,
|
|
1503
|
+
lastValidBlockHeight
|
|
1504
|
+
});
|
|
1505
|
+
} catch (confirmError) {
|
|
1506
|
+
const err = confirmError;
|
|
1507
|
+
throw new Error(
|
|
1508
|
+
`Transaction sent but confirmation failed: ${err.message}
|
|
1509
|
+
Signature: ${signature}
|
|
1510
|
+
Check on explorer: ${getExplorerTxUrl(this._network, signature)}`
|
|
1511
|
+
);
|
|
1512
|
+
}
|
|
1447
1513
|
return {
|
|
1448
1514
|
verified: true,
|
|
1449
1515
|
signature,
|
|
@@ -96,8 +96,15 @@ async function initWasm() {
|
|
|
96
96
|
} else {
|
|
97
97
|
const moduleUrl = new URL(import_meta.url);
|
|
98
98
|
const isSourceFile = moduleUrl.pathname.includes("/src/");
|
|
99
|
-
const
|
|
100
|
-
|
|
99
|
+
const isViteProduction = moduleUrl.pathname.includes("/assets/");
|
|
100
|
+
let wasmJsUrl;
|
|
101
|
+
if (isSourceFile) {
|
|
102
|
+
wasmJsUrl = new URL("../../wasm/web/arkworks_groth16_wasm.js", moduleUrl);
|
|
103
|
+
} else if (isViteProduction) {
|
|
104
|
+
wasmJsUrl = new URL("/wasm/web/arkworks_groth16_wasm.js", moduleUrl.origin);
|
|
105
|
+
} else {
|
|
106
|
+
wasmJsUrl = new URL("./wasm/web/arkworks_groth16_wasm.js", moduleUrl);
|
|
107
|
+
}
|
|
101
108
|
const module2 = await import(
|
|
102
109
|
/* @vite-ignore */
|
|
103
110
|
wasmJsUrl.href
|
|
@@ -593,6 +600,11 @@ function getExplorerTxUrl(network, signature) {
|
|
|
593
600
|
const clusterParam = network === "mainnet-beta" /* Mainnet */ ? "" : `?cluster=${network}`;
|
|
594
601
|
return `${config.explorerUrl.replace(/\?.*$/, "")}/tx/${signature}${clusterParam}`;
|
|
595
602
|
}
|
|
603
|
+
function getExplorerAccountUrl(network, address) {
|
|
604
|
+
const config = NETWORK_CONFIG[network];
|
|
605
|
+
const clusterParam = network === "mainnet-beta" /* Mainnet */ ? "" : `?cluster=${network}`;
|
|
606
|
+
return `${config.explorerUrl.replace(/\?.*$/, "")}/address/${address}${clusterParam}`;
|
|
607
|
+
}
|
|
596
608
|
|
|
597
609
|
// src/domain/types/provider.ts
|
|
598
610
|
var Provider = /* @__PURE__ */ ((Provider2) => {
|
|
@@ -1352,6 +1364,18 @@ var IziNoir = class _IziNoir {
|
|
|
1352
1364
|
const networkConfig = NETWORK_CONFIG[this._network];
|
|
1353
1365
|
const { Connection, Transaction, PublicKey } = await import("@solana/web3.js");
|
|
1354
1366
|
const connection = new Connection(networkConfig.rpcUrl, "confirmed");
|
|
1367
|
+
const vkPubkey = new PublicKey(vk);
|
|
1368
|
+
const accountInfo = await connection.getAccountInfo(vkPubkey);
|
|
1369
|
+
if (!accountInfo) {
|
|
1370
|
+
throw new Error(
|
|
1371
|
+
`VK account ${vk} does not exist on ${this._network}. Did deploy() succeed? Check the account on explorer: ${getExplorerAccountUrl(this._network, vk)}`
|
|
1372
|
+
);
|
|
1373
|
+
}
|
|
1374
|
+
if (accountInfo.data.length < 8) {
|
|
1375
|
+
throw new Error(
|
|
1376
|
+
`VK account ${vk} has invalid data (${accountInfo.data.length} bytes). Expected at least 8 bytes for a valid account.`
|
|
1377
|
+
);
|
|
1378
|
+
}
|
|
1355
1379
|
const builder = new SolanaTransactionBuilder({
|
|
1356
1380
|
programId: networkConfig.programId,
|
|
1357
1381
|
computeUnits: 4e5
|
|
@@ -1379,12 +1403,59 @@ var IziNoir = class _IziNoir {
|
|
|
1379
1403
|
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");
|
|
1380
1404
|
tx.recentBlockhash = blockhash;
|
|
1381
1405
|
tx.feePayer = new PublicKey(wallet.publicKey.toBase58());
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1406
|
+
try {
|
|
1407
|
+
const simulation = await connection.simulateTransaction(tx);
|
|
1408
|
+
if (simulation.value.err) {
|
|
1409
|
+
const logs = simulation.value.logs?.join("\n") || "No logs available";
|
|
1410
|
+
throw new Error(
|
|
1411
|
+
`Transaction simulation failed:
|
|
1412
|
+
Error: ${JSON.stringify(simulation.value.err)}
|
|
1413
|
+
Logs:
|
|
1414
|
+
${logs}`
|
|
1415
|
+
);
|
|
1416
|
+
}
|
|
1417
|
+
} catch (simError) {
|
|
1418
|
+
if (simError instanceof Error && simError.message.includes("Transaction simulation failed")) {
|
|
1419
|
+
throw simError;
|
|
1420
|
+
}
|
|
1421
|
+
const err = simError;
|
|
1422
|
+
throw new Error(
|
|
1423
|
+
`Failed to simulate transaction: ${err.message}
|
|
1424
|
+
VK Account: ${vk}
|
|
1425
|
+
Network: ${this._network}
|
|
1426
|
+
Proof size: ${proofData.proof.bytes.length} bytes
|
|
1427
|
+
Public inputs: ${proofData.publicInputs.hex.length} items`
|
|
1428
|
+
);
|
|
1429
|
+
}
|
|
1430
|
+
let signature;
|
|
1431
|
+
try {
|
|
1432
|
+
signature = await wallet.sendTransaction(tx, connection);
|
|
1433
|
+
} catch (sendError) {
|
|
1434
|
+
const originalError = sendError;
|
|
1435
|
+
const enhancedError = new Error(
|
|
1436
|
+
`Failed to send verify transaction: ${originalError.message}
|
|
1437
|
+
VK Account: ${vk}
|
|
1438
|
+
Network: ${this._network}
|
|
1439
|
+
Proof size: ${proofData.proof.bytes.length} bytes
|
|
1440
|
+
Public inputs: ${proofData.publicInputs.hex.length} items`
|
|
1441
|
+
);
|
|
1442
|
+
enhancedError.cause = originalError;
|
|
1443
|
+
throw enhancedError;
|
|
1444
|
+
}
|
|
1445
|
+
try {
|
|
1446
|
+
await connection.confirmTransaction({
|
|
1447
|
+
signature,
|
|
1448
|
+
blockhash,
|
|
1449
|
+
lastValidBlockHeight
|
|
1450
|
+
});
|
|
1451
|
+
} catch (confirmError) {
|
|
1452
|
+
const err = confirmError;
|
|
1453
|
+
throw new Error(
|
|
1454
|
+
`Transaction sent but confirmation failed: ${err.message}
|
|
1455
|
+
Signature: ${signature}
|
|
1456
|
+
Check on explorer: ${getExplorerTxUrl(this._network, signature)}`
|
|
1457
|
+
);
|
|
1458
|
+
}
|
|
1388
1459
|
return {
|
|
1389
1460
|
verified: true,
|
|
1390
1461
|
signature,
|
|
@@ -77,8 +77,15 @@ async function initWasm() {
|
|
|
77
77
|
} else {
|
|
78
78
|
const moduleUrl = new URL(import.meta.url);
|
|
79
79
|
const isSourceFile = moduleUrl.pathname.includes("/src/");
|
|
80
|
-
const
|
|
81
|
-
|
|
80
|
+
const isViteProduction = moduleUrl.pathname.includes("/assets/");
|
|
81
|
+
let wasmJsUrl;
|
|
82
|
+
if (isSourceFile) {
|
|
83
|
+
wasmJsUrl = new URL("../../wasm/web/arkworks_groth16_wasm.js", moduleUrl);
|
|
84
|
+
} else if (isViteProduction) {
|
|
85
|
+
wasmJsUrl = new URL("/wasm/web/arkworks_groth16_wasm.js", moduleUrl.origin);
|
|
86
|
+
} else {
|
|
87
|
+
wasmJsUrl = new URL("./wasm/web/arkworks_groth16_wasm.js", moduleUrl);
|
|
88
|
+
}
|
|
82
89
|
const module = await import(
|
|
83
90
|
/* @vite-ignore */
|
|
84
91
|
wasmJsUrl.href
|
|
@@ -560,6 +567,11 @@ function getExplorerTxUrl(network, signature) {
|
|
|
560
567
|
const clusterParam = network === "mainnet-beta" /* Mainnet */ ? "" : `?cluster=${network}`;
|
|
561
568
|
return `${config.explorerUrl.replace(/\?.*$/, "")}/tx/${signature}${clusterParam}`;
|
|
562
569
|
}
|
|
570
|
+
function getExplorerAccountUrl(network, address) {
|
|
571
|
+
const config = NETWORK_CONFIG[network];
|
|
572
|
+
const clusterParam = network === "mainnet-beta" /* Mainnet */ ? "" : `?cluster=${network}`;
|
|
573
|
+
return `${config.explorerUrl.replace(/\?.*$/, "")}/address/${address}${clusterParam}`;
|
|
574
|
+
}
|
|
563
575
|
|
|
564
576
|
// src/domain/types/provider.ts
|
|
565
577
|
var Provider = /* @__PURE__ */ ((Provider2) => {
|
|
@@ -1319,6 +1331,18 @@ var IziNoir = class _IziNoir {
|
|
|
1319
1331
|
const networkConfig = NETWORK_CONFIG[this._network];
|
|
1320
1332
|
const { Connection, Transaction, PublicKey } = await import("@solana/web3.js");
|
|
1321
1333
|
const connection = new Connection(networkConfig.rpcUrl, "confirmed");
|
|
1334
|
+
const vkPubkey = new PublicKey(vk);
|
|
1335
|
+
const accountInfo = await connection.getAccountInfo(vkPubkey);
|
|
1336
|
+
if (!accountInfo) {
|
|
1337
|
+
throw new Error(
|
|
1338
|
+
`VK account ${vk} does not exist on ${this._network}. Did deploy() succeed? Check the account on explorer: ${getExplorerAccountUrl(this._network, vk)}`
|
|
1339
|
+
);
|
|
1340
|
+
}
|
|
1341
|
+
if (accountInfo.data.length < 8) {
|
|
1342
|
+
throw new Error(
|
|
1343
|
+
`VK account ${vk} has invalid data (${accountInfo.data.length} bytes). Expected at least 8 bytes for a valid account.`
|
|
1344
|
+
);
|
|
1345
|
+
}
|
|
1322
1346
|
const builder = new SolanaTransactionBuilder({
|
|
1323
1347
|
programId: networkConfig.programId,
|
|
1324
1348
|
computeUnits: 4e5
|
|
@@ -1346,12 +1370,59 @@ var IziNoir = class _IziNoir {
|
|
|
1346
1370
|
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");
|
|
1347
1371
|
tx.recentBlockhash = blockhash;
|
|
1348
1372
|
tx.feePayer = new PublicKey(wallet.publicKey.toBase58());
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1373
|
+
try {
|
|
1374
|
+
const simulation = await connection.simulateTransaction(tx);
|
|
1375
|
+
if (simulation.value.err) {
|
|
1376
|
+
const logs = simulation.value.logs?.join("\n") || "No logs available";
|
|
1377
|
+
throw new Error(
|
|
1378
|
+
`Transaction simulation failed:
|
|
1379
|
+
Error: ${JSON.stringify(simulation.value.err)}
|
|
1380
|
+
Logs:
|
|
1381
|
+
${logs}`
|
|
1382
|
+
);
|
|
1383
|
+
}
|
|
1384
|
+
} catch (simError) {
|
|
1385
|
+
if (simError instanceof Error && simError.message.includes("Transaction simulation failed")) {
|
|
1386
|
+
throw simError;
|
|
1387
|
+
}
|
|
1388
|
+
const err = simError;
|
|
1389
|
+
throw new Error(
|
|
1390
|
+
`Failed to simulate transaction: ${err.message}
|
|
1391
|
+
VK Account: ${vk}
|
|
1392
|
+
Network: ${this._network}
|
|
1393
|
+
Proof size: ${proofData.proof.bytes.length} bytes
|
|
1394
|
+
Public inputs: ${proofData.publicInputs.hex.length} items`
|
|
1395
|
+
);
|
|
1396
|
+
}
|
|
1397
|
+
let signature;
|
|
1398
|
+
try {
|
|
1399
|
+
signature = await wallet.sendTransaction(tx, connection);
|
|
1400
|
+
} catch (sendError) {
|
|
1401
|
+
const originalError = sendError;
|
|
1402
|
+
const enhancedError = new Error(
|
|
1403
|
+
`Failed to send verify transaction: ${originalError.message}
|
|
1404
|
+
VK Account: ${vk}
|
|
1405
|
+
Network: ${this._network}
|
|
1406
|
+
Proof size: ${proofData.proof.bytes.length} bytes
|
|
1407
|
+
Public inputs: ${proofData.publicInputs.hex.length} items`
|
|
1408
|
+
);
|
|
1409
|
+
enhancedError.cause = originalError;
|
|
1410
|
+
throw enhancedError;
|
|
1411
|
+
}
|
|
1412
|
+
try {
|
|
1413
|
+
await connection.confirmTransaction({
|
|
1414
|
+
signature,
|
|
1415
|
+
blockhash,
|
|
1416
|
+
lastValidBlockHeight
|
|
1417
|
+
});
|
|
1418
|
+
} catch (confirmError) {
|
|
1419
|
+
const err = confirmError;
|
|
1420
|
+
throw new Error(
|
|
1421
|
+
`Transaction sent but confirmation failed: ${err.message}
|
|
1422
|
+
Signature: ${signature}
|
|
1423
|
+
Check on explorer: ${getExplorerTxUrl(this._network, signature)}`
|
|
1424
|
+
);
|
|
1425
|
+
}
|
|
1355
1426
|
return {
|
|
1356
1427
|
verified: true,
|
|
1357
1428
|
signature,
|
|
@@ -191,8 +191,15 @@ async function initWasm() {
|
|
|
191
191
|
} else {
|
|
192
192
|
const moduleUrl = new URL(import_meta.url);
|
|
193
193
|
const isSourceFile = moduleUrl.pathname.includes("/src/");
|
|
194
|
-
const
|
|
195
|
-
|
|
194
|
+
const isViteProduction = moduleUrl.pathname.includes("/assets/");
|
|
195
|
+
let wasmJsUrl;
|
|
196
|
+
if (isSourceFile) {
|
|
197
|
+
wasmJsUrl = new URL("../../wasm/web/arkworks_groth16_wasm.js", moduleUrl);
|
|
198
|
+
} else if (isViteProduction) {
|
|
199
|
+
wasmJsUrl = new URL("/wasm/web/arkworks_groth16_wasm.js", moduleUrl.origin);
|
|
200
|
+
} else {
|
|
201
|
+
wasmJsUrl = new URL("./wasm/web/arkworks_groth16_wasm.js", moduleUrl);
|
|
202
|
+
}
|
|
196
203
|
const module2 = await import(
|
|
197
204
|
/* @vite-ignore */
|
|
198
205
|
wasmJsUrl.href
|
|
@@ -592,6 +599,11 @@ function getExplorerTxUrl(network, signature) {
|
|
|
592
599
|
const clusterParam = network === "mainnet-beta" /* Mainnet */ ? "" : `?cluster=${network}`;
|
|
593
600
|
return `${config.explorerUrl.replace(/\?.*$/, "")}/tx/${signature}${clusterParam}`;
|
|
594
601
|
}
|
|
602
|
+
function getExplorerAccountUrl(network, address) {
|
|
603
|
+
const config = NETWORK_CONFIG[network];
|
|
604
|
+
const clusterParam = network === "mainnet-beta" /* Mainnet */ ? "" : `?cluster=${network}`;
|
|
605
|
+
return `${config.explorerUrl.replace(/\?.*$/, "")}/address/${address}${clusterParam}`;
|
|
606
|
+
}
|
|
595
607
|
|
|
596
608
|
// src/domain/types/provider.ts
|
|
597
609
|
var Provider = /* @__PURE__ */ ((Provider2) => {
|
|
@@ -1351,6 +1363,18 @@ var IziNoir = class _IziNoir {
|
|
|
1351
1363
|
const networkConfig = NETWORK_CONFIG[this._network];
|
|
1352
1364
|
const { Connection, Transaction, PublicKey } = await import("@solana/web3.js");
|
|
1353
1365
|
const connection = new Connection(networkConfig.rpcUrl, "confirmed");
|
|
1366
|
+
const vkPubkey = new PublicKey(vk);
|
|
1367
|
+
const accountInfo = await connection.getAccountInfo(vkPubkey);
|
|
1368
|
+
if (!accountInfo) {
|
|
1369
|
+
throw new Error(
|
|
1370
|
+
`VK account ${vk} does not exist on ${this._network}. Did deploy() succeed? Check the account on explorer: ${getExplorerAccountUrl(this._network, vk)}`
|
|
1371
|
+
);
|
|
1372
|
+
}
|
|
1373
|
+
if (accountInfo.data.length < 8) {
|
|
1374
|
+
throw new Error(
|
|
1375
|
+
`VK account ${vk} has invalid data (${accountInfo.data.length} bytes). Expected at least 8 bytes for a valid account.`
|
|
1376
|
+
);
|
|
1377
|
+
}
|
|
1354
1378
|
const builder = new SolanaTransactionBuilder({
|
|
1355
1379
|
programId: networkConfig.programId,
|
|
1356
1380
|
computeUnits: 4e5
|
|
@@ -1378,12 +1402,59 @@ var IziNoir = class _IziNoir {
|
|
|
1378
1402
|
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");
|
|
1379
1403
|
tx.recentBlockhash = blockhash;
|
|
1380
1404
|
tx.feePayer = new PublicKey(wallet.publicKey.toBase58());
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1405
|
+
try {
|
|
1406
|
+
const simulation = await connection.simulateTransaction(tx);
|
|
1407
|
+
if (simulation.value.err) {
|
|
1408
|
+
const logs = simulation.value.logs?.join("\n") || "No logs available";
|
|
1409
|
+
throw new Error(
|
|
1410
|
+
`Transaction simulation failed:
|
|
1411
|
+
Error: ${JSON.stringify(simulation.value.err)}
|
|
1412
|
+
Logs:
|
|
1413
|
+
${logs}`
|
|
1414
|
+
);
|
|
1415
|
+
}
|
|
1416
|
+
} catch (simError) {
|
|
1417
|
+
if (simError instanceof Error && simError.message.includes("Transaction simulation failed")) {
|
|
1418
|
+
throw simError;
|
|
1419
|
+
}
|
|
1420
|
+
const err = simError;
|
|
1421
|
+
throw new Error(
|
|
1422
|
+
`Failed to simulate transaction: ${err.message}
|
|
1423
|
+
VK Account: ${vk}
|
|
1424
|
+
Network: ${this._network}
|
|
1425
|
+
Proof size: ${proofData.proof.bytes.length} bytes
|
|
1426
|
+
Public inputs: ${proofData.publicInputs.hex.length} items`
|
|
1427
|
+
);
|
|
1428
|
+
}
|
|
1429
|
+
let signature;
|
|
1430
|
+
try {
|
|
1431
|
+
signature = await wallet.sendTransaction(tx, connection);
|
|
1432
|
+
} catch (sendError) {
|
|
1433
|
+
const originalError = sendError;
|
|
1434
|
+
const enhancedError = new Error(
|
|
1435
|
+
`Failed to send verify transaction: ${originalError.message}
|
|
1436
|
+
VK Account: ${vk}
|
|
1437
|
+
Network: ${this._network}
|
|
1438
|
+
Proof size: ${proofData.proof.bytes.length} bytes
|
|
1439
|
+
Public inputs: ${proofData.publicInputs.hex.length} items`
|
|
1440
|
+
);
|
|
1441
|
+
enhancedError.cause = originalError;
|
|
1442
|
+
throw enhancedError;
|
|
1443
|
+
}
|
|
1444
|
+
try {
|
|
1445
|
+
await connection.confirmTransaction({
|
|
1446
|
+
signature,
|
|
1447
|
+
blockhash,
|
|
1448
|
+
lastValidBlockHeight
|
|
1449
|
+
});
|
|
1450
|
+
} catch (confirmError) {
|
|
1451
|
+
const err = confirmError;
|
|
1452
|
+
throw new Error(
|
|
1453
|
+
`Transaction sent but confirmation failed: ${err.message}
|
|
1454
|
+
Signature: ${signature}
|
|
1455
|
+
Check on explorer: ${getExplorerTxUrl(this._network, signature)}`
|
|
1456
|
+
);
|
|
1457
|
+
}
|
|
1387
1458
|
return {
|
|
1388
1459
|
verified: true,
|
|
1389
1460
|
signature,
|
|
@@ -172,8 +172,15 @@ async function initWasm() {
|
|
|
172
172
|
} else {
|
|
173
173
|
const moduleUrl = new URL(import.meta.url);
|
|
174
174
|
const isSourceFile = moduleUrl.pathname.includes("/src/");
|
|
175
|
-
const
|
|
176
|
-
|
|
175
|
+
const isViteProduction = moduleUrl.pathname.includes("/assets/");
|
|
176
|
+
let wasmJsUrl;
|
|
177
|
+
if (isSourceFile) {
|
|
178
|
+
wasmJsUrl = new URL("../../wasm/web/arkworks_groth16_wasm.js", moduleUrl);
|
|
179
|
+
} else if (isViteProduction) {
|
|
180
|
+
wasmJsUrl = new URL("/wasm/web/arkworks_groth16_wasm.js", moduleUrl.origin);
|
|
181
|
+
} else {
|
|
182
|
+
wasmJsUrl = new URL("./wasm/web/arkworks_groth16_wasm.js", moduleUrl);
|
|
183
|
+
}
|
|
177
184
|
const module = await import(
|
|
178
185
|
/* @vite-ignore */
|
|
179
186
|
wasmJsUrl.href
|
|
@@ -560,6 +567,11 @@ function getExplorerTxUrl(network, signature) {
|
|
|
560
567
|
const clusterParam = network === "mainnet-beta" /* Mainnet */ ? "" : `?cluster=${network}`;
|
|
561
568
|
return `${config.explorerUrl.replace(/\?.*$/, "")}/tx/${signature}${clusterParam}`;
|
|
562
569
|
}
|
|
570
|
+
function getExplorerAccountUrl(network, address) {
|
|
571
|
+
const config = NETWORK_CONFIG[network];
|
|
572
|
+
const clusterParam = network === "mainnet-beta" /* Mainnet */ ? "" : `?cluster=${network}`;
|
|
573
|
+
return `${config.explorerUrl.replace(/\?.*$/, "")}/address/${address}${clusterParam}`;
|
|
574
|
+
}
|
|
563
575
|
|
|
564
576
|
// src/domain/types/provider.ts
|
|
565
577
|
var Provider = /* @__PURE__ */ ((Provider2) => {
|
|
@@ -1319,6 +1331,18 @@ var IziNoir = class _IziNoir {
|
|
|
1319
1331
|
const networkConfig = NETWORK_CONFIG[this._network];
|
|
1320
1332
|
const { Connection, Transaction, PublicKey } = await import("@solana/web3.js");
|
|
1321
1333
|
const connection = new Connection(networkConfig.rpcUrl, "confirmed");
|
|
1334
|
+
const vkPubkey = new PublicKey(vk);
|
|
1335
|
+
const accountInfo = await connection.getAccountInfo(vkPubkey);
|
|
1336
|
+
if (!accountInfo) {
|
|
1337
|
+
throw new Error(
|
|
1338
|
+
`VK account ${vk} does not exist on ${this._network}. Did deploy() succeed? Check the account on explorer: ${getExplorerAccountUrl(this._network, vk)}`
|
|
1339
|
+
);
|
|
1340
|
+
}
|
|
1341
|
+
if (accountInfo.data.length < 8) {
|
|
1342
|
+
throw new Error(
|
|
1343
|
+
`VK account ${vk} has invalid data (${accountInfo.data.length} bytes). Expected at least 8 bytes for a valid account.`
|
|
1344
|
+
);
|
|
1345
|
+
}
|
|
1322
1346
|
const builder = new SolanaTransactionBuilder({
|
|
1323
1347
|
programId: networkConfig.programId,
|
|
1324
1348
|
computeUnits: 4e5
|
|
@@ -1346,12 +1370,59 @@ var IziNoir = class _IziNoir {
|
|
|
1346
1370
|
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");
|
|
1347
1371
|
tx.recentBlockhash = blockhash;
|
|
1348
1372
|
tx.feePayer = new PublicKey(wallet.publicKey.toBase58());
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1373
|
+
try {
|
|
1374
|
+
const simulation = await connection.simulateTransaction(tx);
|
|
1375
|
+
if (simulation.value.err) {
|
|
1376
|
+
const logs = simulation.value.logs?.join("\n") || "No logs available";
|
|
1377
|
+
throw new Error(
|
|
1378
|
+
`Transaction simulation failed:
|
|
1379
|
+
Error: ${JSON.stringify(simulation.value.err)}
|
|
1380
|
+
Logs:
|
|
1381
|
+
${logs}`
|
|
1382
|
+
);
|
|
1383
|
+
}
|
|
1384
|
+
} catch (simError) {
|
|
1385
|
+
if (simError instanceof Error && simError.message.includes("Transaction simulation failed")) {
|
|
1386
|
+
throw simError;
|
|
1387
|
+
}
|
|
1388
|
+
const err = simError;
|
|
1389
|
+
throw new Error(
|
|
1390
|
+
`Failed to simulate transaction: ${err.message}
|
|
1391
|
+
VK Account: ${vk}
|
|
1392
|
+
Network: ${this._network}
|
|
1393
|
+
Proof size: ${proofData.proof.bytes.length} bytes
|
|
1394
|
+
Public inputs: ${proofData.publicInputs.hex.length} items`
|
|
1395
|
+
);
|
|
1396
|
+
}
|
|
1397
|
+
let signature;
|
|
1398
|
+
try {
|
|
1399
|
+
signature = await wallet.sendTransaction(tx, connection);
|
|
1400
|
+
} catch (sendError) {
|
|
1401
|
+
const originalError = sendError;
|
|
1402
|
+
const enhancedError = new Error(
|
|
1403
|
+
`Failed to send verify transaction: ${originalError.message}
|
|
1404
|
+
VK Account: ${vk}
|
|
1405
|
+
Network: ${this._network}
|
|
1406
|
+
Proof size: ${proofData.proof.bytes.length} bytes
|
|
1407
|
+
Public inputs: ${proofData.publicInputs.hex.length} items`
|
|
1408
|
+
);
|
|
1409
|
+
enhancedError.cause = originalError;
|
|
1410
|
+
throw enhancedError;
|
|
1411
|
+
}
|
|
1412
|
+
try {
|
|
1413
|
+
await connection.confirmTransaction({
|
|
1414
|
+
signature,
|
|
1415
|
+
blockhash,
|
|
1416
|
+
lastValidBlockHeight
|
|
1417
|
+
});
|
|
1418
|
+
} catch (confirmError) {
|
|
1419
|
+
const err = confirmError;
|
|
1420
|
+
throw new Error(
|
|
1421
|
+
`Transaction sent but confirmation failed: ${err.message}
|
|
1422
|
+
Signature: ${signature}
|
|
1423
|
+
Check on explorer: ${getExplorerTxUrl(this._network, signature)}`
|
|
1424
|
+
);
|
|
1425
|
+
}
|
|
1355
1426
|
return {
|
|
1356
1427
|
verified: true,
|
|
1357
1428
|
signature,
|