Minor updates #1
36
dist/index.js
vendored
36
dist/index.js
vendored
@ -31,6 +31,26 @@ function _interopNamespaceDefault(e) {
|
||||
|
||||
var websnarkUtils__namespace = /*#__PURE__*/_interopNamespaceDefault(websnarkUtils);
|
||||
|
||||
var __async$d = (__this, __arguments, generator) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
var fulfilled = (value) => {
|
||||
try {
|
||||
step(generator.next(value));
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
};
|
||||
var rejected = (value) => {
|
||||
try {
|
||||
step(generator.throw(value));
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
};
|
||||
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
||||
step((generator = generator.apply(__this, __arguments)).next());
|
||||
});
|
||||
};
|
||||
BigInt.prototype.toJSON = function() {
|
||||
return this.toString();
|
||||
};
|
||||
@ -64,7 +84,7 @@ function bufferToBytes(b) {
|
||||
return new Uint8Array(b.buffer);
|
||||
}
|
||||
function bytesToBase64(bytes) {
|
||||
return btoa(String.fromCharCode.apply(null, Array.from(bytes)));
|
||||
return btoa(bytes.reduce((data, byte) => data + String.fromCharCode(byte), ""));
|
||||
}
|
||||
function base64ToBytes(base64) {
|
||||
return Uint8Array.from(atob(base64), (c) => c.charCodeAt(0));
|
||||
@ -119,6 +139,11 @@ function substring(str, length = 10) {
|
||||
}
|
||||
return `${str.substring(0, length)}...${str.substring(str.length - length)}`;
|
||||
}
|
||||
function digest(bytes, algo = "SHA-384") {
|
||||
return __async$d(this, null, function* () {
|
||||
return new Uint8Array(yield crypto.subtle.digest(algo, bytes));
|
||||
});
|
||||
}
|
||||
|
||||
var __defProp$4 = Object.defineProperty;
|
||||
var __defProps$3 = Object.defineProperties;
|
||||
@ -318,11 +343,15 @@ function getProvider(rpcUrl, fetchOptions) {
|
||||
const fetchReq = new ethers.FetchRequest(rpcUrl);
|
||||
fetchReq.getUrlFunc = fetchGetUrlFunc(fetchOptions);
|
||||
const staticNetwork = yield new ethers.JsonRpcProvider(fetchReq).getNetwork();
|
||||
const provider = new ethers.JsonRpcProvider(fetchReq, staticNetwork, {
|
||||
const chainId = Number(staticNetwork.chainId);
|
||||
if ((fetchOptions == null ? void 0 : fetchOptions.netId) && fetchOptions.netId !== chainId) {
|
||||
const errMsg = `Wrong network for ${rpcUrl}, wants ${fetchOptions.netId} got ${chainId}`;
|
||||
throw new Error(errMsg);
|
||||
}
|
||||
return new ethers.JsonRpcProvider(fetchReq, staticNetwork, {
|
||||
staticNetwork,
|
||||
pollingInterval: (fetchOptions == null ? void 0 : fetchOptions.pollingInterval) || 1e3
|
||||
});
|
||||
return provider;
|
||||
});
|
||||
}
|
||||
function getProviderWithNetId(netId, rpcUrl, config, fetchOptions) {
|
||||
@ -6686,6 +6715,7 @@ exports.createDeposit = createDeposit;
|
||||
exports.crypto = crypto;
|
||||
exports.defaultConfig = defaultConfig;
|
||||
exports.defaultUserAgent = defaultUserAgent;
|
||||
exports.digest = digest;
|
||||
exports.enabledChains = enabledChains;
|
||||
exports.factories = index;
|
||||
exports.fetch = fetch;
|
||||
|
37
dist/index.mjs
vendored
37
dist/index.mjs
vendored
@ -10,6 +10,26 @@ import { MerkleTree, PartialMerkleTree } from '@tornado/fixed-merkle-tree';
|
||||
import * as websnarkUtils from '@tornado/websnark/src/utils';
|
||||
import websnarkGroth from '@tornado/websnark/src/groth16';
|
||||
|
||||
var __async$d = (__this, __arguments, generator) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
var fulfilled = (value) => {
|
||||
try {
|
||||
step(generator.next(value));
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
};
|
||||
var rejected = (value) => {
|
||||
try {
|
||||
step(generator.throw(value));
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
};
|
||||
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
||||
step((generator = generator.apply(__this, __arguments)).next());
|
||||
});
|
||||
};
|
||||
BigInt.prototype.toJSON = function() {
|
||||
return this.toString();
|
||||
};
|
||||
@ -43,7 +63,7 @@ function bufferToBytes(b) {
|
||||
return new Uint8Array(b.buffer);
|
||||
}
|
||||
function bytesToBase64(bytes) {
|
||||
return btoa(String.fromCharCode.apply(null, Array.from(bytes)));
|
||||
return btoa(bytes.reduce((data, byte) => data + String.fromCharCode(byte), ""));
|
||||
}
|
||||
function base64ToBytes(base64) {
|
||||
return Uint8Array.from(atob(base64), (c) => c.charCodeAt(0));
|
||||
@ -98,6 +118,11 @@ function substring(str, length = 10) {
|
||||
}
|
||||
return `${str.substring(0, length)}...${str.substring(str.length - length)}`;
|
||||
}
|
||||
function digest(bytes, algo = "SHA-384") {
|
||||
return __async$d(this, null, function* () {
|
||||
return new Uint8Array(yield crypto.subtle.digest(algo, bytes));
|
||||
});
|
||||
}
|
||||
|
||||
var __defProp$4 = Object.defineProperty;
|
||||
var __defProps$3 = Object.defineProperties;
|
||||
@ -297,11 +322,15 @@ function getProvider(rpcUrl, fetchOptions) {
|
||||
const fetchReq = new FetchRequest(rpcUrl);
|
||||
fetchReq.getUrlFunc = fetchGetUrlFunc(fetchOptions);
|
||||
const staticNetwork = yield new JsonRpcProvider(fetchReq).getNetwork();
|
||||
const provider = new JsonRpcProvider(fetchReq, staticNetwork, {
|
||||
const chainId = Number(staticNetwork.chainId);
|
||||
if ((fetchOptions == null ? void 0 : fetchOptions.netId) && fetchOptions.netId !== chainId) {
|
||||
const errMsg = `Wrong network for ${rpcUrl}, wants ${fetchOptions.netId} got ${chainId}`;
|
||||
throw new Error(errMsg);
|
||||
}
|
||||
return new JsonRpcProvider(fetchReq, staticNetwork, {
|
||||
staticNetwork,
|
||||
pollingInterval: (fetchOptions == null ? void 0 : fetchOptions.pollingInterval) || 1e3
|
||||
});
|
||||
return provider;
|
||||
});
|
||||
}
|
||||
function getProviderWithNetId(netId, rpcUrl, config, fetchOptions) {
|
||||
@ -6602,4 +6631,4 @@ function calculateSnarkProof(input, circuit, provingKey) {
|
||||
});
|
||||
}
|
||||
|
||||
export { BaseEchoService, BaseEncryptedNotesService, BaseEventsService, BaseGovernanceService, BaseRegistryService, BaseTornadoService, BatchBlockService, BatchEventsService, BatchTransactionService, DEPOSIT, Deposit, ENS__factory, ERC20__factory, GET_DEPOSITS, GET_ECHO_EVENTS, GET_ENCRYPTED_NOTES, GET_GOVERNANCE_APY, GET_GOVERNANCE_EVENTS, GET_NOTE_ACCOUNTS, GET_REGISTERED, GET_STATISTIC, GET_WITHDRAWALS, Invoice, MAX_FEE, MIN_FEE, MIN_STAKE_BALANCE, MerkleTreeService, Mimc, Multicall__factory, NetId, NoteAccount, OffchainOracle__factory, OvmGasPriceOracle__factory, Pedersen, RelayerClient, ReverseRecords__factory, TokenPriceOracle, TornadoBrowserProvider, TornadoFeeOracle, TornadoRpcSigner, TornadoVoidSigner, TornadoWallet, WITHDRAWAL, _META, addNetwork, ajv, base64ToBytes, bigIntReplacer, bnToBytes, buffPedersenHash, bufferToBytes, bytesToBN, bytesToBase64, bytesToHex, calculateScore, calculateSnarkProof, chunk, concatBytes, convertETHToTokenAmount, createDeposit, crypto, customConfig, defaultConfig, defaultUserAgent, enabledChains, index as factories, fetch, fetchData, fetchGetUrlFunc, getAllDeposits, getAllEncryptedNotes, getAllGovernanceEvents, getAllGraphEchoEvents, getAllRegisters, getAllWithdrawals, getConfig, getDeposits, getEncryptedNotes, getGovernanceEvents, getGraphEchoEvents, getHttpAgent, getInstanceByAddress, getMeta, getNetworkConfig, getNoteAccounts, getProvider, getProviderWithNetId, getRegisters, getRelayerEnsSubdomains, getStatistic, getStatusSchema, getSubdomains, getSupportedInstances, getTokenBalances, getWeightRandom, getWithdrawals, hexToBytes, initGroth16, isNode, isRelayerUpdated, jobsSchema, leBuff2Int, leInt2Buff, mimc, multicall, packEncryptedMessage, parseSemanticVersion, pedersen, pickWeightedRandomRelayer, populateTransaction, queryGraph, rBigInt, sleep, substring, toFixedHex, toFixedLength, unpackEncryptedMessage, validateUrl };
|
||||
export { BaseEchoService, BaseEncryptedNotesService, BaseEventsService, BaseGovernanceService, BaseRegistryService, BaseTornadoService, BatchBlockService, BatchEventsService, BatchTransactionService, DEPOSIT, Deposit, ENS__factory, ERC20__factory, GET_DEPOSITS, GET_ECHO_EVENTS, GET_ENCRYPTED_NOTES, GET_GOVERNANCE_APY, GET_GOVERNANCE_EVENTS, GET_NOTE_ACCOUNTS, GET_REGISTERED, GET_STATISTIC, GET_WITHDRAWALS, Invoice, MAX_FEE, MIN_FEE, MIN_STAKE_BALANCE, MerkleTreeService, Mimc, Multicall__factory, NetId, NoteAccount, OffchainOracle__factory, OvmGasPriceOracle__factory, Pedersen, RelayerClient, ReverseRecords__factory, TokenPriceOracle, TornadoBrowserProvider, TornadoFeeOracle, TornadoRpcSigner, TornadoVoidSigner, TornadoWallet, WITHDRAWAL, _META, addNetwork, ajv, base64ToBytes, bigIntReplacer, bnToBytes, buffPedersenHash, bufferToBytes, bytesToBN, bytesToBase64, bytesToHex, calculateScore, calculateSnarkProof, chunk, concatBytes, convertETHToTokenAmount, createDeposit, crypto, customConfig, defaultConfig, defaultUserAgent, digest, enabledChains, index as factories, fetch, fetchData, fetchGetUrlFunc, getAllDeposits, getAllEncryptedNotes, getAllGovernanceEvents, getAllGraphEchoEvents, getAllRegisters, getAllWithdrawals, getConfig, getDeposits, getEncryptedNotes, getGovernanceEvents, getGraphEchoEvents, getHttpAgent, getInstanceByAddress, getMeta, getNetworkConfig, getNoteAccounts, getProvider, getProviderWithNetId, getRegisters, getRelayerEnsSubdomains, getStatistic, getStatusSchema, getSubdomains, getSupportedInstances, getTokenBalances, getWeightRandom, getWithdrawals, hexToBytes, initGroth16, isNode, isRelayerUpdated, jobsSchema, leBuff2Int, leInt2Buff, mimc, multicall, packEncryptedMessage, parseSemanticVersion, pedersen, pickWeightedRandomRelayer, populateTransaction, queryGraph, rBigInt, sleep, substring, toFixedHex, toFixedLength, unpackEncryptedMessage, validateUrl };
|
||||
|
27
dist/merkleTreeWorker.umd.js
vendored
27
dist/merkleTreeWorker.umd.js
vendored
@ -102026,6 +102026,26 @@ var crypto_browserify = __webpack_require__(1565);
|
||||
var bn = __webpack_require__(9404);
|
||||
;// CONCATENATED MODULE: ./src/utils.ts
|
||||
|
||||
var utils_async = (__this, __arguments, generator) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
var fulfilled = (value) => {
|
||||
try {
|
||||
step(generator.next(value));
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
};
|
||||
var rejected = (value) => {
|
||||
try {
|
||||
step(generator.throw(value));
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
};
|
||||
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
||||
step((generator = generator.apply(__this, __arguments)).next());
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
BigInt.prototype.toJSON = function() {
|
||||
@ -102061,7 +102081,7 @@ function bufferToBytes(b) {
|
||||
return new Uint8Array(b.buffer);
|
||||
}
|
||||
function bytesToBase64(bytes) {
|
||||
return btoa(String.fromCharCode.apply(null, Array.from(bytes)));
|
||||
return btoa(bytes.reduce((data, byte) => data + String.fromCharCode(byte), ""));
|
||||
}
|
||||
function base64ToBytes(base64) {
|
||||
return Uint8Array.from(atob(base64), (c) => c.charCodeAt(0));
|
||||
@ -102116,6 +102136,11 @@ function substring(str, length = 10) {
|
||||
}
|
||||
return `${str.substring(0, length)}...${str.substring(str.length - length)}`;
|
||||
}
|
||||
function digest(bytes, algo = "SHA-384") {
|
||||
return utils_async(this, null, function* () {
|
||||
return new Uint8Array(yield utils_crypto.subtle.digest(algo, bytes));
|
||||
});
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./src/merkleTreeWorker.ts
|
||||
|
||||
|
1
dist/providers.d.ts
vendored
1
dist/providers.d.ts
vendored
@ -32,6 +32,7 @@ export declare function getHttpAgent({ fetchUrl, proxyUrl, torPort, retry, }: {
|
||||
export declare function fetchData(url: string, options?: fetchDataOptions): Promise<any>;
|
||||
export declare const fetchGetUrlFunc: (options?: fetchDataOptions) => FetchGetUrlFunc;
|
||||
export type getProviderOptions = fetchDataOptions & {
|
||||
netId?: NetIdType;
|
||||
pollingInterval?: number;
|
||||
};
|
||||
export declare function getProvider(rpcUrl: string, fetchOptions?: getProviderOptions): Promise<JsonRpcProvider>;
|
||||
|
37
dist/tornado.umd.js
vendored
37
dist/tornado.umd.js
vendored
@ -71226,11 +71226,15 @@ function getProvider(rpcUrl, fetchOptions) {
|
||||
const fetchReq = new FetchRequest(rpcUrl);
|
||||
fetchReq.getUrlFunc = fetchGetUrlFunc(fetchOptions);
|
||||
const staticNetwork = yield new JsonRpcProvider(fetchReq).getNetwork();
|
||||
const provider = new JsonRpcProvider(fetchReq, staticNetwork, {
|
||||
const chainId = Number(staticNetwork.chainId);
|
||||
if ((fetchOptions == null ? void 0 : fetchOptions.netId) && fetchOptions.netId !== chainId) {
|
||||
const errMsg = `Wrong network for ${rpcUrl}, wants ${fetchOptions.netId} got ${chainId}`;
|
||||
throw new Error(errMsg);
|
||||
}
|
||||
return new JsonRpcProvider(fetchReq, staticNetwork, {
|
||||
staticNetwork,
|
||||
pollingInterval: (fetchOptions == null ? void 0 : fetchOptions.pollingInterval) || 1e3
|
||||
});
|
||||
return provider;
|
||||
});
|
||||
}
|
||||
function getProviderWithNetId(netId, rpcUrl, config, fetchOptions) {
|
||||
@ -74357,6 +74361,7 @@ ReverseRecords__factory.abi = ReverseRecords_factory_abi;
|
||||
/* harmony export */ My: () => (/* binding */ bytesToHex),
|
||||
/* harmony export */ aT: () => (/* binding */ hexToBytes),
|
||||
/* harmony export */ ae: () => (/* binding */ leBuff2Int),
|
||||
/* harmony export */ br: () => (/* binding */ digest),
|
||||
/* harmony export */ gn: () => (/* binding */ bigIntReplacer),
|
||||
/* harmony export */ ib: () => (/* binding */ rBigInt),
|
||||
/* harmony export */ "if": () => (/* binding */ bytesToBase64),
|
||||
@ -74372,6 +74377,26 @@ ReverseRecords__factory.abi = ReverseRecords_factory_abi;
|
||||
/* harmony import */ var bn_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(39404);
|
||||
/* harmony import */ var bn_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(bn_js__WEBPACK_IMPORTED_MODULE_1__);
|
||||
|
||||
var __async = (__this, __arguments, generator) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
var fulfilled = (value) => {
|
||||
try {
|
||||
step(generator.next(value));
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
};
|
||||
var rejected = (value) => {
|
||||
try {
|
||||
step(generator.throw(value));
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
};
|
||||
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
||||
step((generator = generator.apply(__this, __arguments)).next());
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
BigInt.prototype.toJSON = function() {
|
||||
@ -74407,7 +74432,7 @@ function bufferToBytes(b) {
|
||||
return new Uint8Array(b.buffer);
|
||||
}
|
||||
function bytesToBase64(bytes) {
|
||||
return btoa(String.fromCharCode.apply(null, Array.from(bytes)));
|
||||
return btoa(bytes.reduce((data, byte) => data + String.fromCharCode(byte), ""));
|
||||
}
|
||||
function base64ToBytes(base64) {
|
||||
return Uint8Array.from(atob(base64), (c) => c.charCodeAt(0));
|
||||
@ -74462,6 +74487,11 @@ function substring(str, length = 10) {
|
||||
}
|
||||
return `${str.substring(0, length)}...${str.substring(str.length - length)}`;
|
||||
}
|
||||
function digest(bytes, algo = "SHA-384") {
|
||||
return __async(this, null, function* () {
|
||||
return new Uint8Array(yield crypto.subtle.digest(algo, bytes));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/***/ }),
|
||||
@ -173004,6 +173034,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ customConfig: () => (/* reexport safe */ _networkConfig__WEBPACK_IMPORTED_MODULE_11__.cX),
|
||||
/* harmony export */ defaultConfig: () => (/* reexport safe */ _networkConfig__WEBPACK_IMPORTED_MODULE_11__.sb),
|
||||
/* harmony export */ defaultUserAgent: () => (/* reexport safe */ _providers__WEBPACK_IMPORTED_MODULE_14__.mJ),
|
||||
/* harmony export */ digest: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_17__.br),
|
||||
/* harmony export */ enabledChains: () => (/* reexport safe */ _networkConfig__WEBPACK_IMPORTED_MODULE_11__.Af),
|
||||
/* harmony export */ factories: () => (/* reexport safe */ _typechain__WEBPACK_IMPORTED_MODULE_3__.XB),
|
||||
/* harmony export */ fetch: () => (/* reexport safe */ _providers__WEBPACK_IMPORTED_MODULE_14__.hd),
|
||||
|
2
dist/tornado.umd.min.js
vendored
2
dist/tornado.umd.min.js
vendored
File diff suppressed because one or more lines are too long
1
dist/utils.d.ts
vendored
1
dist/utils.d.ts
vendored
@ -22,4 +22,5 @@ export declare function toFixedLength(string: string, length?: number): string;
|
||||
export declare function rBigInt(nbytes?: number): bigint;
|
||||
export declare function bigIntReplacer(key: any, value: any): any;
|
||||
export declare function substring(str: string, length?: number): string;
|
||||
export declare function digest(bytes: Uint8Array, algo?: string): Promise<Uint8Array>;
|
||||
export {};
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@tornado/core",
|
||||
"version": "1.0.12",
|
||||
"version": "1.0.13",
|
||||
"description": "An SDK for building applications on top of Privacy Pools",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.mjs",
|
||||
|
@ -258,18 +258,29 @@ export const fetchGetUrlFunc =
|
||||
/* eslint-enable @typescript-eslint/no-explicit-any */
|
||||
|
||||
export type getProviderOptions = fetchDataOptions & {
|
||||
// NetId to check against rpc
|
||||
netId?: NetIdType;
|
||||
pollingInterval?: number;
|
||||
};
|
||||
|
||||
export async function getProvider(rpcUrl: string, fetchOptions?: getProviderOptions): Promise<JsonRpcProvider> {
|
||||
const fetchReq = new FetchRequest(rpcUrl);
|
||||
|
||||
fetchReq.getUrlFunc = fetchGetUrlFunc(fetchOptions);
|
||||
|
||||
const staticNetwork = await new JsonRpcProvider(fetchReq).getNetwork();
|
||||
const provider = new JsonRpcProvider(fetchReq, staticNetwork, {
|
||||
|
||||
const chainId = Number(staticNetwork.chainId);
|
||||
|
||||
if (fetchOptions?.netId && fetchOptions.netId !== chainId) {
|
||||
const errMsg = `Wrong network for ${rpcUrl}, wants ${fetchOptions.netId} got ${chainId}`;
|
||||
throw new Error(errMsg);
|
||||
}
|
||||
|
||||
return new JsonRpcProvider(fetchReq, staticNetwork, {
|
||||
staticNetwork,
|
||||
pollingInterval: fetchOptions?.pollingInterval || 1000,
|
||||
});
|
||||
return provider;
|
||||
}
|
||||
|
||||
export function getProviderWithNetId(
|
||||
|
@ -54,7 +54,7 @@ export function bufferToBytes(b: Buffer) {
|
||||
}
|
||||
|
||||
export function bytesToBase64(bytes: Uint8Array) {
|
||||
return btoa(String.fromCharCode.apply(null, Array.from(bytes)));
|
||||
return btoa(bytes.reduce((data, byte) => data + String.fromCharCode(byte), ''));
|
||||
}
|
||||
|
||||
export function base64ToBytes(base64: string) {
|
||||
@ -143,3 +143,7 @@ export function substring(str: string, length: number = 10) {
|
||||
|
||||
return `${str.substring(0, length)}...${str.substring(str.length - length)}`;
|
||||
}
|
||||
|
||||
export async function digest(bytes: Uint8Array, algo: string = 'SHA-384') {
|
||||
return new Uint8Array(await crypto.subtle.digest(algo, bytes));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user