@0xbow/privacy-pools-core-sdk 0.1.13 → 0.1.14
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/esm/{fetchArtifacts.esm-BYX0rUCf.js → fetchArtifacts.esm-CN7uN1ly.js} +2 -2
- package/dist/esm/{fetchArtifacts.esm-BYX0rUCf.js.map → fetchArtifacts.esm-CN7uN1ly.js.map} +1 -1
- package/dist/esm/{fetchArtifacts.node-Cbihl9b_.js → fetchArtifacts.node-B93BS926.js} +2 -2
- package/dist/esm/{fetchArtifacts.node-Cbihl9b_.js.map → fetchArtifacts.node-B93BS926.js.map} +1 -1
- package/dist/esm/{index-DEloI2DV.js → index-B2wT3cOz.js} +21 -42
- package/dist/esm/{index-DEloI2DV.js.map → index-B2wT3cOz.js.map} +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/index.d.mts +5 -10
- package/dist/node/{fetchArtifacts.esm-BsIxGCYt.js → fetchArtifacts.esm-BE3E5wR9.js} +2 -2
- package/dist/node/{fetchArtifacts.esm-BsIxGCYt.js.map → fetchArtifacts.esm-BE3E5wR9.js.map} +1 -1
- package/dist/node/{fetchArtifacts.node-DTgZZT0w.js → fetchArtifacts.node-BoI4I9Vy.js} +2 -2
- package/dist/node/{fetchArtifacts.node-DTgZZT0w.js.map → fetchArtifacts.node-BoI4I9Vy.js.map} +1 -1
- package/dist/node/{index-RJ4j0bvk.js → index-BX96yzW6.js} +21 -42
- package/dist/node/{index-RJ4j0bvk.js.map → index-BX96yzW6.js.map} +1 -1
- package/dist/node/index.mjs +1 -1
- package/dist/types/core/account.service.d.ts +2 -4
- package/dist/types/{fetchArtifacts.esm-BqoMt1AU.js → fetchArtifacts.esm-XXmZbdtj.js} +1 -1
- package/dist/types/{fetchArtifacts.node-DjoY_2xb.js → fetchArtifacts.node-CO7FJNaO.js} +1 -1
- package/dist/types/{index-CRv-bhjr.js → index-Dp0aOfF2.js} +20 -41
- package/dist/types/index.js +1 -1
- package/dist/types/types/account.d.ts +3 -3
- package/dist/types/types/events.d.ts +0 -3
- package/package.json +1 -1
- package/src/core/account.service.ts +6 -27
- package/src/core/data.service.ts +6 -16
- package/src/crypto.ts +4 -4
- package/src/keys.ts +7 -7
- package/src/types/account.ts +4 -4
- package/src/types/events.ts +0 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as FetchArtifact } from './index-
|
|
1
|
+
import { F as FetchArtifact } from './index-B2wT3cOz.js';
|
|
2
2
|
import 'viem/accounts';
|
|
3
3
|
import 'buffer';
|
|
4
4
|
import 'assert';
|
|
@@ -15,4 +15,4 @@ async function fetchVersionedArtifact(artifactUrl) {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export { fetchVersionedArtifact };
|
|
18
|
-
//# sourceMappingURL=fetchArtifacts.esm-
|
|
18
|
+
//# sourceMappingURL=fetchArtifacts.esm-CN7uN1ly.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchArtifacts.esm-
|
|
1
|
+
{"version":3,"file":"fetchArtifacts.esm-CN7uN1ly.js","sources":["../../src/circuits/fetchArtifacts.esm.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AAEO,eAAe,sBAAsB,CAC1C,WAAgB,EAAA;AAEhB,IAAA,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,WAAW,CAAC;AACpC,IAAA,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE;AACtB,QAAA,MAAM,IAAI,aAAa,CAAC,WAAW,CAAC;;AAEtC,IAAA,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,WAAW,EAAE;AACpC,IAAA,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC;AAC7B;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as FetchArtifact } from './index-
|
|
1
|
+
import { F as FetchArtifact } from './index-B2wT3cOz.js';
|
|
2
2
|
import 'viem/accounts';
|
|
3
3
|
import 'buffer';
|
|
4
4
|
import 'assert';
|
|
@@ -28,4 +28,4 @@ async function fetchVersionedArtifact(artifactUrl) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
export { fetchVersionedArtifact };
|
|
31
|
-
//# sourceMappingURL=fetchArtifacts.node-
|
|
31
|
+
//# sourceMappingURL=fetchArtifacts.node-B93BS926.js.map
|
package/dist/esm/{fetchArtifacts.node-Cbihl9b_.js.map → fetchArtifacts.node-B93BS926.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchArtifacts.node-
|
|
1
|
+
{"version":3,"file":"fetchArtifacts.node-B93BS926.js","sources":["../../src/circuits/fetchArtifacts.node.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AAEO,eAAe,sBAAsB,CAC1C,WAAgB,EAAA;AAEhB,IAAA,IAAI;QACF,MAAM,EAAE,GAAG,CAAC,MAAM,OAAO,IAAI,CAAC,EAAE,OAAO;QACvC,MAAM,WAAW,GAAoB,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAI;AACnE,YAAA,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,IAAI,KAAI;gBAC9C,IAAI,GAAG,EAAE;oBACP,MAAM,CAAC,GAAG,CAAC;;qBACN;oBACL,OAAO,CAAC,IAAI,CAAC;;AAEjB,aAAC,CAAC;AACJ,SAAC,CAAC;AACF,QAAA,MAAM,GAAG,GAAG,MAAM,WAAW;AAC7B,QAAA,OAAO,IAAI,UAAU,CAAC,GAAG,CAAC;;IAC1B,OAAO,KAAK,EAAE;AACd,QAAA,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;AACpB,QAAA,MAAM,IAAI,aAAa,CAAC,WAAW,CAAC;;AAExC;;;;"}
|
|
@@ -45602,10 +45602,10 @@ function generateMasterKeys(mnemonic) {
|
|
|
45602
45602
|
if (!mnemonic) {
|
|
45603
45603
|
throw new PrivacyPoolError(ErrorCode$1.INVALID_VALUE, "Invalid input: mnemonic phrase is required.");
|
|
45604
45604
|
}
|
|
45605
|
-
|
|
45606
|
-
|
|
45607
|
-
|
|
45608
|
-
|
|
45605
|
+
const key1 = bytesToNumber(mnemonicToAccount(mnemonic, { accountIndex: 0 }).getHdKey().privateKey);
|
|
45606
|
+
const key2 = bytesToNumber(mnemonicToAccount(mnemonic, { accountIndex: 1 }).getHdKey().privateKey);
|
|
45607
|
+
const masterNullifier = hashingExports.poseidon([BigInt(key1)]);
|
|
45608
|
+
const masterSecret = hashingExports.poseidon([BigInt(key2)]);
|
|
45609
45609
|
return { masterNullifier, masterSecret };
|
|
45610
45610
|
}
|
|
45611
45611
|
/**
|
|
@@ -45815,10 +45815,10 @@ const circuitToAsset = {
|
|
|
45815
45815
|
|
|
45816
45816
|
async function importFetchVersionedArtifact(isBrowser) {
|
|
45817
45817
|
if (isBrowser) {
|
|
45818
|
-
return import('./fetchArtifacts.esm-
|
|
45818
|
+
return import('./fetchArtifacts.esm-CN7uN1ly.js');
|
|
45819
45819
|
}
|
|
45820
45820
|
else {
|
|
45821
|
-
return import('./fetchArtifacts.node-
|
|
45821
|
+
return import('./fetchArtifacts.node-B93BS926.js');
|
|
45822
45822
|
}
|
|
45823
45823
|
}
|
|
45824
45824
|
|
|
@@ -68687,10 +68687,10 @@ class AccountService {
|
|
|
68687
68687
|
_initializeAccount(mnemonic) {
|
|
68688
68688
|
try {
|
|
68689
68689
|
this.logger.debug("Initializing account with mnemonic");
|
|
68690
|
-
|
|
68691
|
-
|
|
68692
|
-
|
|
68693
|
-
|
|
68690
|
+
const masterNullifierSeed = bytesToNumber$1(mnemonicToAccount(mnemonic, { accountIndex: 0 }).getHdKey().privateKey);
|
|
68691
|
+
const masterSecretSeed = bytesToNumber$1(mnemonicToAccount(mnemonic, { accountIndex: 1 }).getHdKey().privateKey);
|
|
68692
|
+
const masterNullifier = hashingExports.poseidon([BigInt(masterNullifierSeed)]);
|
|
68693
|
+
const masterSecret = hashingExports.poseidon([BigInt(masterSecretSeed)]);
|
|
68694
68694
|
return {
|
|
68695
68695
|
masterKeys: [masterNullifier, masterSecret],
|
|
68696
68696
|
poolAccounts: new Map(),
|
|
@@ -68794,20 +68794,12 @@ class AccountService {
|
|
|
68794
68794
|
* @param secret - The secret used for the deposit
|
|
68795
68795
|
* @param label - The label for the commitment
|
|
68796
68796
|
* @param blockNumber - The block number of the deposit
|
|
68797
|
-
* @param timestamp - The timestamp of the deposit
|
|
68798
68797
|
* @param txHash - The transaction hash of the deposit
|
|
68799
68798
|
* @returns The new pool account
|
|
68800
68799
|
*/
|
|
68801
|
-
addPoolAccount(scope, value, nullifier, secret, label, blockNumber,
|
|
68800
|
+
addPoolAccount(scope, value, nullifier, secret, label, blockNumber, txHash) {
|
|
68802
68801
|
const precommitment = this._hashPrecommitment(nullifier, secret);
|
|
68803
68802
|
const commitment = this._hashCommitment(value, label, precommitment);
|
|
68804
|
-
// Update account timestamps
|
|
68805
|
-
if (this.account.creationTimestamp === 0n || timestamp < this.account.creationTimestamp) {
|
|
68806
|
-
this.account.creationTimestamp = timestamp;
|
|
68807
|
-
}
|
|
68808
|
-
if (timestamp > this.account.lastUpdateTimestamp) {
|
|
68809
|
-
this.account.lastUpdateTimestamp = timestamp;
|
|
68810
|
-
}
|
|
68811
68803
|
const newAccount = {
|
|
68812
68804
|
label,
|
|
68813
68805
|
deposit: {
|
|
@@ -68817,7 +68809,6 @@ class AccountService {
|
|
|
68817
68809
|
nullifier,
|
|
68818
68810
|
secret,
|
|
68819
68811
|
blockNumber,
|
|
68820
|
-
timestamp,
|
|
68821
68812
|
txHash,
|
|
68822
68813
|
},
|
|
68823
68814
|
children: [],
|
|
@@ -68837,16 +68828,11 @@ class AccountService {
|
|
|
68837
68828
|
* @param nullifier - The nullifier used for spending
|
|
68838
68829
|
* @param secret - The secret used for spending
|
|
68839
68830
|
* @param blockNumber - The block number of the withdrawal
|
|
68840
|
-
* @param timestamp - The timestamp of the withdrawal
|
|
68841
68831
|
* @param txHash - The transaction hash of the withdrawal
|
|
68842
68832
|
* @returns The new commitment
|
|
68843
68833
|
* @throws {AccountError} If no account is found for the commitment
|
|
68844
68834
|
*/
|
|
68845
|
-
addWithdrawalCommitment(parentCommitment, value, nullifier, secret, blockNumber,
|
|
68846
|
-
// Update last update timestamp
|
|
68847
|
-
if (timestamp > this.account.lastUpdateTimestamp) {
|
|
68848
|
-
this.account.lastUpdateTimestamp = timestamp;
|
|
68849
|
-
}
|
|
68835
|
+
addWithdrawalCommitment(parentCommitment, value, nullifier, secret, blockNumber, txHash) {
|
|
68850
68836
|
let foundAccount;
|
|
68851
68837
|
let foundScope;
|
|
68852
68838
|
for (const [scope, accounts] of this.account.poolAccounts.entries()) {
|
|
@@ -68871,7 +68857,6 @@ class AccountService {
|
|
|
68871
68857
|
nullifier,
|
|
68872
68858
|
secret,
|
|
68873
68859
|
blockNumber,
|
|
68874
|
-
timestamp,
|
|
68875
68860
|
txHash,
|
|
68876
68861
|
};
|
|
68877
68862
|
foundAccount.children.push(newCommitment);
|
|
@@ -68932,7 +68917,7 @@ class AccountService {
|
|
|
68932
68917
|
this.logger.info(`Found ${foundDeposits.length} deposits for pool ${pool.address}`);
|
|
68933
68918
|
// Process deposits first
|
|
68934
68919
|
const accounts = foundDeposits.map(({ nullifier, secret, deposit }) => {
|
|
68935
|
-
return this.addPoolAccount(pool.scope, deposit.value, nullifier, secret, deposit.label, deposit.blockNumber, deposit.
|
|
68920
|
+
return this.addPoolAccount(pool.scope, deposit.value, nullifier, secret, deposit.label, deposit.blockNumber, deposit.transactionHash);
|
|
68936
68921
|
});
|
|
68937
68922
|
// Create a map for faster account lookups
|
|
68938
68923
|
const accountMap = new Map();
|
|
@@ -68959,7 +68944,7 @@ class AccountService {
|
|
|
68959
68944
|
this.logger.warn(`No parent commitment found for withdrawal ${withdrawal.spentNullifier.toString()}`);
|
|
68960
68945
|
continue;
|
|
68961
68946
|
}
|
|
68962
|
-
this.addWithdrawalCommitment(parentCommitment, withdrawal.withdrawn, withdrawal.spentNullifier, parentCommitment.secret, withdrawal.blockNumber, withdrawal.
|
|
68947
|
+
this.addWithdrawalCommitment(parentCommitment, withdrawal.withdrawn, withdrawal.spentNullifier, parentCommitment.secret, withdrawal.blockNumber, withdrawal.transactionHash);
|
|
68963
68948
|
break;
|
|
68964
68949
|
}
|
|
68965
68950
|
}
|
|
@@ -69045,9 +69030,8 @@ class DataService {
|
|
|
69045
69030
|
}).catch(error => {
|
|
69046
69031
|
throw new DataError("Failed to fetch deposit logs", ErrorCode.NETWORK_ERROR, { error: error instanceof Error ? error.message : "Unknown error" });
|
|
69047
69032
|
});
|
|
69048
|
-
return
|
|
69033
|
+
return logs.map((log) => {
|
|
69049
69034
|
try {
|
|
69050
|
-
const block = await client.getBlock({ blockNumber: log.blockNumber });
|
|
69051
69035
|
if (!log.args) {
|
|
69052
69036
|
throw DataError.invalidLog("deposit", "missing args");
|
|
69053
69037
|
}
|
|
@@ -69062,7 +69046,6 @@ class DataService {
|
|
|
69062
69046
|
value,
|
|
69063
69047
|
precommitment: precommitment,
|
|
69064
69048
|
blockNumber: BigInt(log.blockNumber),
|
|
69065
|
-
timestamp: BigInt(block.timestamp),
|
|
69066
69049
|
transactionHash: log.transactionHash,
|
|
69067
69050
|
};
|
|
69068
69051
|
}
|
|
@@ -69071,7 +69054,7 @@ class DataService {
|
|
|
69071
69054
|
throw error;
|
|
69072
69055
|
throw DataError.invalidLog("deposit", error instanceof Error ? error.message : "Unknown error");
|
|
69073
69056
|
}
|
|
69074
|
-
})
|
|
69057
|
+
});
|
|
69075
69058
|
}
|
|
69076
69059
|
catch (error) {
|
|
69077
69060
|
if (error instanceof DataError)
|
|
@@ -69099,9 +69082,8 @@ class DataService {
|
|
|
69099
69082
|
}).catch(error => {
|
|
69100
69083
|
throw new DataError("Failed to fetch withdrawal logs", ErrorCode.NETWORK_ERROR, { error: error instanceof Error ? error.message : "Unknown error" });
|
|
69101
69084
|
});
|
|
69102
|
-
return
|
|
69085
|
+
return logs.map((log) => {
|
|
69103
69086
|
try {
|
|
69104
|
-
const block = await client.getBlock({ blockNumber: log.blockNumber });
|
|
69105
69087
|
if (!log.args) {
|
|
69106
69088
|
throw DataError.invalidLog("withdrawal", "missing args");
|
|
69107
69089
|
}
|
|
@@ -69114,7 +69096,6 @@ class DataService {
|
|
|
69114
69096
|
spentNullifier: spentNullifier,
|
|
69115
69097
|
newCommitment: newCommitment,
|
|
69116
69098
|
blockNumber: BigInt(log.blockNumber),
|
|
69117
|
-
timestamp: BigInt(block.timestamp),
|
|
69118
69099
|
transactionHash: log.transactionHash,
|
|
69119
69100
|
};
|
|
69120
69101
|
}
|
|
@@ -69123,7 +69104,7 @@ class DataService {
|
|
|
69123
69104
|
throw error;
|
|
69124
69105
|
throw DataError.invalidLog("withdrawal", error instanceof Error ? error.message : "Unknown error");
|
|
69125
69106
|
}
|
|
69126
|
-
})
|
|
69107
|
+
});
|
|
69127
69108
|
}
|
|
69128
69109
|
catch (error) {
|
|
69129
69110
|
if (error instanceof DataError)
|
|
@@ -69151,9 +69132,8 @@ class DataService {
|
|
|
69151
69132
|
}).catch(error => {
|
|
69152
69133
|
throw new DataError("Failed to fetch ragequit logs", ErrorCode.NETWORK_ERROR, { error: error instanceof Error ? error.message : "Unknown error" });
|
|
69153
69134
|
});
|
|
69154
|
-
return
|
|
69135
|
+
return logs.map((log) => {
|
|
69155
69136
|
try {
|
|
69156
|
-
const block = await client.getBlock({ blockNumber: log.blockNumber });
|
|
69157
69137
|
if (!log.args) {
|
|
69158
69138
|
throw DataError.invalidLog("ragequit", "missing args");
|
|
69159
69139
|
}
|
|
@@ -69167,7 +69147,6 @@ class DataService {
|
|
|
69167
69147
|
label: label,
|
|
69168
69148
|
value,
|
|
69169
69149
|
blockNumber: BigInt(log.blockNumber),
|
|
69170
|
-
timestamp: BigInt(block.timestamp),
|
|
69171
69150
|
transactionHash: log.transactionHash,
|
|
69172
69151
|
};
|
|
69173
69152
|
}
|
|
@@ -69176,7 +69155,7 @@ class DataService {
|
|
|
69176
69155
|
throw error;
|
|
69177
69156
|
throw DataError.invalidLog("ragequit", error instanceof Error ? error.message : "Unknown error");
|
|
69178
69157
|
}
|
|
69179
|
-
})
|
|
69158
|
+
});
|
|
69180
69159
|
}
|
|
69181
69160
|
catch (error) {
|
|
69182
69161
|
if (error instanceof DataError)
|
|
@@ -69201,4 +69180,4 @@ class DataService {
|
|
|
69201
69180
|
}
|
|
69202
69181
|
|
|
69203
69182
|
export { AccountService as A, BlockchainProvider as B, CommitmentService as C, DataService as D, ErrorCode as E, FetchArtifact as F, InvalidRpcUrl as I, PrivacyPoolSDK as P, SDKError as S, WithdrawalService as W, generateDepositSecrets as a, generateWithdrawalSecrets as b, getCommitment as c, generateMerkleProof as d, bigintToHash as e, bigintToHex as f, generateMasterKeys as g, hashPrecommitment as h, calculateContext as i, Circuits as j, ContractInteractionsService as k, ProofError as l, ContractError as m, AccountError as n, CircuitName as o };
|
|
69204
|
-
//# sourceMappingURL=index-
|
|
69183
|
+
//# sourceMappingURL=index-B2wT3cOz.js.map
|