forked from tornado-packages/tornado-core
Added ERC20Tornado instances on BSC
This commit is contained in:
parent
68fcf07c2a
commit
2337892195
47
dist/events/db.d.ts
vendored
47
dist/events/db.d.ts
vendored
@ -1,10 +1,10 @@
|
||||
import { IndexedDB } from '../idb';
|
||||
import { BaseTornadoService, BaseTornadoServiceConstructor, BaseEchoService, BaseEchoServiceConstructor, BaseEncryptedNotesService, BaseEncryptedNotesServiceConstructor, BaseGovernanceService, BaseGovernanceServiceConstructor, BaseRegistryService, BaseRegistryServiceConstructor, BaseRevenueService, BaseRevenueServiceConstructor, CachedRelayers } from './base';
|
||||
import { BaseEvents, MinimalEvents, DepositsEvents, WithdrawalsEvents, CachedEvents, EchoEvents, EncryptedNotesEvents, AllGovernanceEvents, AllRelayerRegistryEvents, StakeBurnedEvents } from './types';
|
||||
export declare function saveDBEvents<T extends MinimalEvents>({ idb, instanceName, events, lastBlock, }: {
|
||||
import { BaseTornadoService, BaseTornadoServiceConstructor, BaseEchoService, BaseEchoServiceConstructor, BaseEncryptedNotesService, BaseEncryptedNotesServiceConstructor, BaseGovernanceService, BaseGovernanceServiceConstructor, BaseRegistryService, BaseRegistryServiceConstructor, BaseRevenueService, BaseRevenueServiceConstructor, CachedRelayers, BaseMultiTornadoService, BaseMultiTornadoServiceConstructor } from './base';
|
||||
import { BaseEvents, MinimalEvents, DepositsEvents, WithdrawalsEvents, CachedEvents, EchoEvents, EncryptedNotesEvents, AllGovernanceEvents, AllRelayerRegistryEvents, StakeBurnedEvents, MultiDepositsEvents, MultiWithdrawalsEvents } from './types';
|
||||
export declare function saveDBEvents<T extends MinimalEvents>({ idb, instanceName, newEvents, lastBlock, }: {
|
||||
idb: IndexedDB;
|
||||
instanceName: string;
|
||||
events: T[];
|
||||
newEvents: T[];
|
||||
lastBlock: number;
|
||||
}): Promise<void>;
|
||||
export declare function loadDBEvents<T extends MinimalEvents>({ idb, instanceName, }: {
|
||||
@ -28,7 +28,24 @@ export declare class DBTornadoService extends BaseTornadoService {
|
||||
constructor(params: DBTornadoServiceConstructor);
|
||||
getEventsFromDB(): Promise<BaseEvents<DepositsEvents | WithdrawalsEvents>>;
|
||||
getEventsFromCache(): Promise<CachedEvents<DepositsEvents | WithdrawalsEvents>>;
|
||||
saveEvents({ events, lastBlock }: BaseEvents<DepositsEvents | WithdrawalsEvents>): Promise<void>;
|
||||
saveEvents({ newEvents, lastBlock, }: BaseEvents<DepositsEvents | WithdrawalsEvents> & {
|
||||
newEvents: (DepositsEvents | WithdrawalsEvents)[];
|
||||
}): Promise<void>;
|
||||
}
|
||||
export interface DBMultiTornadoServiceConstructor extends BaseMultiTornadoServiceConstructor {
|
||||
staticUrl: string;
|
||||
idb: IndexedDB;
|
||||
}
|
||||
export declare class DBMultiTornadoService extends BaseMultiTornadoService {
|
||||
staticUrl: string;
|
||||
idb: IndexedDB;
|
||||
zipDigest?: string;
|
||||
constructor(params: DBMultiTornadoServiceConstructor);
|
||||
getEventsFromDB(): Promise<BaseEvents<MultiDepositsEvents | MultiWithdrawalsEvents>>;
|
||||
getEventsFromCache(): Promise<CachedEvents<MultiDepositsEvents | MultiWithdrawalsEvents>>;
|
||||
saveEvents({ newEvents, lastBlock, }: BaseEvents<MultiDepositsEvents | MultiWithdrawalsEvents> & {
|
||||
newEvents: (MultiDepositsEvents | MultiWithdrawalsEvents)[];
|
||||
}): Promise<void>;
|
||||
}
|
||||
export interface DBEchoServiceConstructor extends BaseEchoServiceConstructor {
|
||||
staticUrl: string;
|
||||
@ -41,7 +58,9 @@ export declare class DBEchoService extends BaseEchoService {
|
||||
constructor(params: DBEchoServiceConstructor);
|
||||
getEventsFromDB(): Promise<BaseEvents<EchoEvents>>;
|
||||
getEventsFromCache(): Promise<CachedEvents<EchoEvents>>;
|
||||
saveEvents({ events, lastBlock }: BaseEvents<EchoEvents>): Promise<void>;
|
||||
saveEvents({ newEvents, lastBlock }: BaseEvents<EchoEvents> & {
|
||||
newEvents: EchoEvents[];
|
||||
}): Promise<void>;
|
||||
}
|
||||
export interface DBEncryptedNotesServiceConstructor extends BaseEncryptedNotesServiceConstructor {
|
||||
staticUrl: string;
|
||||
@ -54,7 +73,9 @@ export declare class DBEncryptedNotesService extends BaseEncryptedNotesService {
|
||||
constructor(params: DBEncryptedNotesServiceConstructor);
|
||||
getEventsFromDB(): Promise<BaseEvents<EncryptedNotesEvents>>;
|
||||
getEventsFromCache(): Promise<CachedEvents<EncryptedNotesEvents>>;
|
||||
saveEvents({ events, lastBlock }: BaseEvents<EncryptedNotesEvents>): Promise<void>;
|
||||
saveEvents({ newEvents, lastBlock, }: BaseEvents<EncryptedNotesEvents> & {
|
||||
newEvents: EncryptedNotesEvents[];
|
||||
}): Promise<void>;
|
||||
}
|
||||
export interface DBGovernanceServiceConstructor extends BaseGovernanceServiceConstructor {
|
||||
staticUrl: string;
|
||||
@ -67,7 +88,9 @@ export declare class DBGovernanceService extends BaseGovernanceService {
|
||||
constructor(params: DBGovernanceServiceConstructor);
|
||||
getEventsFromDB(): Promise<BaseEvents<AllGovernanceEvents>>;
|
||||
getEventsFromCache(): Promise<CachedEvents<AllGovernanceEvents>>;
|
||||
saveEvents({ events, lastBlock }: BaseEvents<AllGovernanceEvents>): Promise<void>;
|
||||
saveEvents({ newEvents, lastBlock }: BaseEvents<AllGovernanceEvents> & {
|
||||
newEvents: AllGovernanceEvents[];
|
||||
}): Promise<void>;
|
||||
}
|
||||
export interface DBRegistryServiceConstructor extends BaseRegistryServiceConstructor {
|
||||
staticUrl: string;
|
||||
@ -81,7 +104,9 @@ export declare class DBRegistryService extends BaseRegistryService {
|
||||
constructor(params: DBRegistryServiceConstructor);
|
||||
getEventsFromDB(): Promise<BaseEvents<AllRelayerRegistryEvents>>;
|
||||
getEventsFromCache(): Promise<CachedEvents<AllRelayerRegistryEvents>>;
|
||||
saveEvents({ events, lastBlock }: BaseEvents<AllRelayerRegistryEvents>): Promise<void>;
|
||||
saveEvents({ newEvents, lastBlock, }: BaseEvents<AllRelayerRegistryEvents> & {
|
||||
newEvents: AllRelayerRegistryEvents[];
|
||||
}): Promise<void>;
|
||||
getRelayersFromDB(): Promise<CachedRelayers>;
|
||||
getRelayersFromCache(): Promise<CachedRelayers>;
|
||||
saveRelayers(cachedRelayers: CachedRelayers): Promise<void>;
|
||||
@ -98,5 +123,7 @@ export declare class DBRevenueService extends BaseRevenueService {
|
||||
constructor(params: DBRevenueServiceConstructor);
|
||||
getEventsFromDB(): Promise<BaseEvents<StakeBurnedEvents>>;
|
||||
getEventsFromCache(): Promise<CachedEvents<StakeBurnedEvents>>;
|
||||
saveEvents({ events, lastBlock }: BaseEvents<StakeBurnedEvents>): Promise<void>;
|
||||
saveEvents({ newEvents, lastBlock }: BaseEvents<StakeBurnedEvents> & {
|
||||
newEvents: StakeBurnedEvents[];
|
||||
}): Promise<void>;
|
||||
}
|
||||
|
2
dist/fees.d.ts
vendored
2
dist/fees.d.ts
vendored
@ -29,7 +29,7 @@ export declare class TornadoFeeOracle {
|
||||
* (A single block can bump 12.5% of fees, see the methodology https://hackmd.io/@tvanepps/1559-wallets)
|
||||
* (Still it is recommended to use 100% premium for sending transactions to prevent stucking it)
|
||||
*/
|
||||
gasPrice(): Promise<bigint>;
|
||||
gasPrice(premium?: number): Promise<bigint>;
|
||||
/**
|
||||
* Calculate L1 fee for op-stack chains
|
||||
*
|
||||
|
128
dist/index.js
vendored
128
dist/index.js
vendored
@ -1031,6 +1031,34 @@ const defaultConfig = {
|
||||
},
|
||||
symbol: "BNB",
|
||||
decimals: 18
|
||||
},
|
||||
usdt: {
|
||||
instanceAddress: {
|
||||
"10": "0x261fB4f84bb0BdEe7E035B6a8a08e5c35AdacdDD",
|
||||
"100": "0x3957861d4897d883C9b944C0b4E22bBd0DDE6e21",
|
||||
"1000": "0x6D180403AdFb39F70983eB51A033C5e52eb9BB69",
|
||||
"10000": "0x3722662D8AaB07B216B14C02eF0ee940d14A4200"
|
||||
},
|
||||
instanceApproval: true,
|
||||
tokenAddress: "0x55d398326f99059fF775485246999027B3197955",
|
||||
tokenGasLimit: 7e4,
|
||||
symbol: "USDT",
|
||||
decimals: 18,
|
||||
gasLimit: 7e5
|
||||
},
|
||||
btcb: {
|
||||
instanceAddress: {
|
||||
"0.0001": "0x736dABbFc8101Ae75287104eCcf67e45D7369Ae1",
|
||||
"0.001": "0x82c7Ce6f1F158cEC5536d591a2BC19864b3CA823",
|
||||
"0.01": "0x8284c96679037d8081E498d8F767cA5a140BFAAf",
|
||||
"0.1": "0x2bcD128Ce23ee30Ee945E613ff129c4DE1102C79"
|
||||
},
|
||||
instanceApproval: true,
|
||||
tokenAddress: "0x7130d2A12B9BCbFAe4f2634d864A1Ee1Ce3Ead9c",
|
||||
tokenGasLimit: 7e4,
|
||||
symbol: "BTCB",
|
||||
decimals: 18,
|
||||
gasLimit: 7e5
|
||||
}
|
||||
},
|
||||
relayerEnsSubdomain: "bsc-tornado",
|
||||
@ -2578,7 +2606,10 @@ class BaseMultiTornadoService extends BaseEventsService {
|
||||
}
|
||||
return acc;
|
||||
},
|
||||
{}
|
||||
{
|
||||
depositEvents: [],
|
||||
withdrawalEvents: []
|
||||
}
|
||||
);
|
||||
return {
|
||||
depositEvents,
|
||||
@ -3257,11 +3288,11 @@ async function downloadZip({
|
||||
async function saveDBEvents({
|
||||
idb,
|
||||
instanceName,
|
||||
events,
|
||||
newEvents,
|
||||
lastBlock
|
||||
}) {
|
||||
try {
|
||||
const formattedEvents = events.map((e) => {
|
||||
const formattedEvents = newEvents.map((e) => {
|
||||
return {
|
||||
eid: `${e.transactionHash}_${e.logIndex}`,
|
||||
...e
|
||||
@ -3372,11 +3403,49 @@ class DBTornadoService extends BaseTornadoService {
|
||||
zipDigest: this.zipDigest
|
||||
});
|
||||
}
|
||||
async saveEvents({ events, lastBlock }) {
|
||||
async saveEvents({
|
||||
newEvents,
|
||||
lastBlock
|
||||
}) {
|
||||
await saveDBEvents({
|
||||
idb: this.idb,
|
||||
instanceName: this.getInstanceName(),
|
||||
events,
|
||||
newEvents,
|
||||
lastBlock
|
||||
});
|
||||
}
|
||||
}
|
||||
class DBMultiTornadoService extends BaseMultiTornadoService {
|
||||
staticUrl;
|
||||
idb;
|
||||
zipDigest;
|
||||
constructor(params) {
|
||||
super(params);
|
||||
this.staticUrl = params.staticUrl;
|
||||
this.idb = params.idb;
|
||||
}
|
||||
async getEventsFromDB() {
|
||||
return await loadDBEvents({
|
||||
idb: this.idb,
|
||||
instanceName: this.getInstanceName()
|
||||
});
|
||||
}
|
||||
async getEventsFromCache() {
|
||||
return await loadRemoteEvents({
|
||||
staticUrl: this.staticUrl,
|
||||
instanceName: this.getInstanceName(),
|
||||
deployedBlock: this.deployedBlock,
|
||||
zipDigest: this.zipDigest
|
||||
});
|
||||
}
|
||||
async saveEvents({
|
||||
newEvents,
|
||||
lastBlock
|
||||
}) {
|
||||
await saveDBEvents({
|
||||
idb: this.idb,
|
||||
instanceName: this.getInstanceName(),
|
||||
newEvents,
|
||||
lastBlock
|
||||
});
|
||||
}
|
||||
@ -3404,11 +3473,11 @@ class DBEchoService extends BaseEchoService {
|
||||
zipDigest: this.zipDigest
|
||||
});
|
||||
}
|
||||
async saveEvents({ events, lastBlock }) {
|
||||
async saveEvents({ newEvents, lastBlock }) {
|
||||
await saveDBEvents({
|
||||
idb: this.idb,
|
||||
instanceName: this.getInstanceName(),
|
||||
events,
|
||||
newEvents,
|
||||
lastBlock
|
||||
});
|
||||
}
|
||||
@ -3436,11 +3505,14 @@ class DBEncryptedNotesService extends BaseEncryptedNotesService {
|
||||
zipDigest: this.zipDigest
|
||||
});
|
||||
}
|
||||
async saveEvents({ events, lastBlock }) {
|
||||
async saveEvents({
|
||||
newEvents,
|
||||
lastBlock
|
||||
}) {
|
||||
await saveDBEvents({
|
||||
idb: this.idb,
|
||||
instanceName: this.getInstanceName(),
|
||||
events,
|
||||
newEvents,
|
||||
lastBlock
|
||||
});
|
||||
}
|
||||
@ -3468,11 +3540,11 @@ class DBGovernanceService extends BaseGovernanceService {
|
||||
zipDigest: this.zipDigest
|
||||
});
|
||||
}
|
||||
async saveEvents({ events, lastBlock }) {
|
||||
async saveEvents({ newEvents, lastBlock }) {
|
||||
await saveDBEvents({
|
||||
idb: this.idb,
|
||||
instanceName: this.getInstanceName(),
|
||||
events,
|
||||
newEvents,
|
||||
lastBlock
|
||||
});
|
||||
}
|
||||
@ -3501,11 +3573,14 @@ class DBRegistryService extends BaseRegistryService {
|
||||
zipDigest: this.zipDigest
|
||||
});
|
||||
}
|
||||
async saveEvents({ events, lastBlock }) {
|
||||
async saveEvents({
|
||||
newEvents,
|
||||
lastBlock
|
||||
}) {
|
||||
await saveDBEvents({
|
||||
idb: this.idb,
|
||||
instanceName: this.getInstanceName(),
|
||||
events,
|
||||
newEvents,
|
||||
lastBlock
|
||||
});
|
||||
}
|
||||
@ -3594,11 +3669,11 @@ class DBRevenueService extends BaseRevenueService {
|
||||
zipDigest: this.zipDigest
|
||||
});
|
||||
}
|
||||
async saveEvents({ events, lastBlock }) {
|
||||
async saveEvents({ newEvents, lastBlock }) {
|
||||
await saveDBEvents({
|
||||
idb: this.idb,
|
||||
instanceName: this.getInstanceName(),
|
||||
events,
|
||||
newEvents,
|
||||
lastBlock
|
||||
});
|
||||
}
|
||||
@ -9341,7 +9416,7 @@ class TornadoFeeOracle {
|
||||
* (A single block can bump 12.5% of fees, see the methodology https://hackmd.io/@tvanepps/1559-wallets)
|
||||
* (Still it is recommended to use 100% premium for sending transactions to prevent stucking it)
|
||||
*/
|
||||
async gasPrice() {
|
||||
async gasPrice(premium) {
|
||||
const [block, getGasPrice, getPriorityFee] = await Promise.all([
|
||||
this.provider.getBlock("latest"),
|
||||
(async () => {
|
||||
@ -9359,7 +9434,7 @@ class TornadoFeeOracle {
|
||||
}
|
||||
})()
|
||||
]);
|
||||
return block?.baseFeePerGas ? block.baseFeePerGas * BigInt(15) / BigInt(10) + getPriorityFee : getGasPrice;
|
||||
return block?.baseFeePerGas ? block.baseFeePerGas * BigInt(1e4 * (100 + (premium || 50))) / BigInt(1e4 * 100) + getPriorityFee : getGasPrice;
|
||||
}
|
||||
/**
|
||||
* Calculate L1 fee for op-stack chains
|
||||
@ -9502,7 +9577,7 @@ class IndexedDB {
|
||||
}
|
||||
};
|
||||
this.dbName = dbName;
|
||||
this.dbVersion = 35;
|
||||
this.dbVersion = 36;
|
||||
}
|
||||
async initDB() {
|
||||
try {
|
||||
@ -9698,15 +9773,16 @@ async function getIndexedDB(netId) {
|
||||
}
|
||||
const minimalIndexes = [
|
||||
{
|
||||
name: "blockNumber",
|
||||
unique: false
|
||||
},
|
||||
{
|
||||
name: "transactionHash",
|
||||
unique: false
|
||||
name: "eid",
|
||||
unique: true
|
||||
}
|
||||
];
|
||||
const defaultState = [
|
||||
{
|
||||
name: `tornado_${netId}`,
|
||||
keyPath: "eid",
|
||||
indexes: [...minimalIndexes]
|
||||
},
|
||||
{
|
||||
name: `echo_${netId}`,
|
||||
keyPath: "eid",
|
||||
@ -9734,8 +9810,7 @@ async function getIndexedDB(netId) {
|
||||
]
|
||||
}
|
||||
];
|
||||
const config = getConfig(netId);
|
||||
const { tokens, nativeCurrency, registryContract, governanceContract } = config;
|
||||
const { tokens, nativeCurrency, registryContract, governanceContract } = getConfig(netId);
|
||||
const stores = [...defaultState];
|
||||
if (registryContract) {
|
||||
stores.push({
|
||||
@ -10641,6 +10716,7 @@ exports.BatchTransactionService = BatchTransactionService;
|
||||
exports.DBEchoService = DBEchoService;
|
||||
exports.DBEncryptedNotesService = DBEncryptedNotesService;
|
||||
exports.DBGovernanceService = DBGovernanceService;
|
||||
exports.DBMultiTornadoService = DBMultiTornadoService;
|
||||
exports.DBRegistryService = DBRegistryService;
|
||||
exports.DBRevenueService = DBRevenueService;
|
||||
exports.DBTornadoService = DBTornadoService;
|
||||
|
129
dist/index.mjs
vendored
129
dist/index.mjs
vendored
@ -1009,6 +1009,34 @@ const defaultConfig = {
|
||||
},
|
||||
symbol: "BNB",
|
||||
decimals: 18
|
||||
},
|
||||
usdt: {
|
||||
instanceAddress: {
|
||||
"10": "0x261fB4f84bb0BdEe7E035B6a8a08e5c35AdacdDD",
|
||||
"100": "0x3957861d4897d883C9b944C0b4E22bBd0DDE6e21",
|
||||
"1000": "0x6D180403AdFb39F70983eB51A033C5e52eb9BB69",
|
||||
"10000": "0x3722662D8AaB07B216B14C02eF0ee940d14A4200"
|
||||
},
|
||||
instanceApproval: true,
|
||||
tokenAddress: "0x55d398326f99059fF775485246999027B3197955",
|
||||
tokenGasLimit: 7e4,
|
||||
symbol: "USDT",
|
||||
decimals: 18,
|
||||
gasLimit: 7e5
|
||||
},
|
||||
btcb: {
|
||||
instanceAddress: {
|
||||
"0.0001": "0x736dABbFc8101Ae75287104eCcf67e45D7369Ae1",
|
||||
"0.001": "0x82c7Ce6f1F158cEC5536d591a2BC19864b3CA823",
|
||||
"0.01": "0x8284c96679037d8081E498d8F767cA5a140BFAAf",
|
||||
"0.1": "0x2bcD128Ce23ee30Ee945E613ff129c4DE1102C79"
|
||||
},
|
||||
instanceApproval: true,
|
||||
tokenAddress: "0x7130d2A12B9BCbFAe4f2634d864A1Ee1Ce3Ead9c",
|
||||
tokenGasLimit: 7e4,
|
||||
symbol: "BTCB",
|
||||
decimals: 18,
|
||||
gasLimit: 7e5
|
||||
}
|
||||
},
|
||||
relayerEnsSubdomain: "bsc-tornado",
|
||||
@ -2556,7 +2584,10 @@ class BaseMultiTornadoService extends BaseEventsService {
|
||||
}
|
||||
return acc;
|
||||
},
|
||||
{}
|
||||
{
|
||||
depositEvents: [],
|
||||
withdrawalEvents: []
|
||||
}
|
||||
);
|
||||
return {
|
||||
depositEvents,
|
||||
@ -3235,11 +3266,11 @@ async function downloadZip({
|
||||
async function saveDBEvents({
|
||||
idb,
|
||||
instanceName,
|
||||
events,
|
||||
newEvents,
|
||||
lastBlock
|
||||
}) {
|
||||
try {
|
||||
const formattedEvents = events.map((e) => {
|
||||
const formattedEvents = newEvents.map((e) => {
|
||||
return {
|
||||
eid: `${e.transactionHash}_${e.logIndex}`,
|
||||
...e
|
||||
@ -3350,11 +3381,49 @@ class DBTornadoService extends BaseTornadoService {
|
||||
zipDigest: this.zipDigest
|
||||
});
|
||||
}
|
||||
async saveEvents({ events, lastBlock }) {
|
||||
async saveEvents({
|
||||
newEvents,
|
||||
lastBlock
|
||||
}) {
|
||||
await saveDBEvents({
|
||||
idb: this.idb,
|
||||
instanceName: this.getInstanceName(),
|
||||
events,
|
||||
newEvents,
|
||||
lastBlock
|
||||
});
|
||||
}
|
||||
}
|
||||
class DBMultiTornadoService extends BaseMultiTornadoService {
|
||||
staticUrl;
|
||||
idb;
|
||||
zipDigest;
|
||||
constructor(params) {
|
||||
super(params);
|
||||
this.staticUrl = params.staticUrl;
|
||||
this.idb = params.idb;
|
||||
}
|
||||
async getEventsFromDB() {
|
||||
return await loadDBEvents({
|
||||
idb: this.idb,
|
||||
instanceName: this.getInstanceName()
|
||||
});
|
||||
}
|
||||
async getEventsFromCache() {
|
||||
return await loadRemoteEvents({
|
||||
staticUrl: this.staticUrl,
|
||||
instanceName: this.getInstanceName(),
|
||||
deployedBlock: this.deployedBlock,
|
||||
zipDigest: this.zipDigest
|
||||
});
|
||||
}
|
||||
async saveEvents({
|
||||
newEvents,
|
||||
lastBlock
|
||||
}) {
|
||||
await saveDBEvents({
|
||||
idb: this.idb,
|
||||
instanceName: this.getInstanceName(),
|
||||
newEvents,
|
||||
lastBlock
|
||||
});
|
||||
}
|
||||
@ -3382,11 +3451,11 @@ class DBEchoService extends BaseEchoService {
|
||||
zipDigest: this.zipDigest
|
||||
});
|
||||
}
|
||||
async saveEvents({ events, lastBlock }) {
|
||||
async saveEvents({ newEvents, lastBlock }) {
|
||||
await saveDBEvents({
|
||||
idb: this.idb,
|
||||
instanceName: this.getInstanceName(),
|
||||
events,
|
||||
newEvents,
|
||||
lastBlock
|
||||
});
|
||||
}
|
||||
@ -3414,11 +3483,14 @@ class DBEncryptedNotesService extends BaseEncryptedNotesService {
|
||||
zipDigest: this.zipDigest
|
||||
});
|
||||
}
|
||||
async saveEvents({ events, lastBlock }) {
|
||||
async saveEvents({
|
||||
newEvents,
|
||||
lastBlock
|
||||
}) {
|
||||
await saveDBEvents({
|
||||
idb: this.idb,
|
||||
instanceName: this.getInstanceName(),
|
||||
events,
|
||||
newEvents,
|
||||
lastBlock
|
||||
});
|
||||
}
|
||||
@ -3446,11 +3518,11 @@ class DBGovernanceService extends BaseGovernanceService {
|
||||
zipDigest: this.zipDigest
|
||||
});
|
||||
}
|
||||
async saveEvents({ events, lastBlock }) {
|
||||
async saveEvents({ newEvents, lastBlock }) {
|
||||
await saveDBEvents({
|
||||
idb: this.idb,
|
||||
instanceName: this.getInstanceName(),
|
||||
events,
|
||||
newEvents,
|
||||
lastBlock
|
||||
});
|
||||
}
|
||||
@ -3479,11 +3551,14 @@ class DBRegistryService extends BaseRegistryService {
|
||||
zipDigest: this.zipDigest
|
||||
});
|
||||
}
|
||||
async saveEvents({ events, lastBlock }) {
|
||||
async saveEvents({
|
||||
newEvents,
|
||||
lastBlock
|
||||
}) {
|
||||
await saveDBEvents({
|
||||
idb: this.idb,
|
||||
instanceName: this.getInstanceName(),
|
||||
events,
|
||||
newEvents,
|
||||
lastBlock
|
||||
});
|
||||
}
|
||||
@ -3572,11 +3647,11 @@ class DBRevenueService extends BaseRevenueService {
|
||||
zipDigest: this.zipDigest
|
||||
});
|
||||
}
|
||||
async saveEvents({ events, lastBlock }) {
|
||||
async saveEvents({ newEvents, lastBlock }) {
|
||||
await saveDBEvents({
|
||||
idb: this.idb,
|
||||
instanceName: this.getInstanceName(),
|
||||
events,
|
||||
newEvents,
|
||||
lastBlock
|
||||
});
|
||||
}
|
||||
@ -9319,7 +9394,7 @@ class TornadoFeeOracle {
|
||||
* (A single block can bump 12.5% of fees, see the methodology https://hackmd.io/@tvanepps/1559-wallets)
|
||||
* (Still it is recommended to use 100% premium for sending transactions to prevent stucking it)
|
||||
*/
|
||||
async gasPrice() {
|
||||
async gasPrice(premium) {
|
||||
const [block, getGasPrice, getPriorityFee] = await Promise.all([
|
||||
this.provider.getBlock("latest"),
|
||||
(async () => {
|
||||
@ -9337,7 +9412,7 @@ class TornadoFeeOracle {
|
||||
}
|
||||
})()
|
||||
]);
|
||||
return block?.baseFeePerGas ? block.baseFeePerGas * BigInt(15) / BigInt(10) + getPriorityFee : getGasPrice;
|
||||
return block?.baseFeePerGas ? block.baseFeePerGas * BigInt(1e4 * (100 + (premium || 50))) / BigInt(1e4 * 100) + getPriorityFee : getGasPrice;
|
||||
}
|
||||
/**
|
||||
* Calculate L1 fee for op-stack chains
|
||||
@ -9480,7 +9555,7 @@ class IndexedDB {
|
||||
}
|
||||
};
|
||||
this.dbName = dbName;
|
||||
this.dbVersion = 35;
|
||||
this.dbVersion = 36;
|
||||
}
|
||||
async initDB() {
|
||||
try {
|
||||
@ -9676,15 +9751,16 @@ async function getIndexedDB(netId) {
|
||||
}
|
||||
const minimalIndexes = [
|
||||
{
|
||||
name: "blockNumber",
|
||||
unique: false
|
||||
},
|
||||
{
|
||||
name: "transactionHash",
|
||||
unique: false
|
||||
name: "eid",
|
||||
unique: true
|
||||
}
|
||||
];
|
||||
const defaultState = [
|
||||
{
|
||||
name: `tornado_${netId}`,
|
||||
keyPath: "eid",
|
||||
indexes: [...minimalIndexes]
|
||||
},
|
||||
{
|
||||
name: `echo_${netId}`,
|
||||
keyPath: "eid",
|
||||
@ -9712,8 +9788,7 @@ async function getIndexedDB(netId) {
|
||||
]
|
||||
}
|
||||
];
|
||||
const config = getConfig(netId);
|
||||
const { tokens, nativeCurrency, registryContract, governanceContract } = config;
|
||||
const { tokens, nativeCurrency, registryContract, governanceContract } = getConfig(netId);
|
||||
const stores = [...defaultState];
|
||||
if (registryContract) {
|
||||
stores.push({
|
||||
@ -10605,4 +10680,4 @@ async function calculateSnarkProof(input, circuit, provingKey) {
|
||||
return { proof, args };
|
||||
}
|
||||
|
||||
export { BaseEchoService, BaseEncryptedNotesService, BaseEventsService, BaseGovernanceService, BaseMultiTornadoService, BaseRegistryService, BaseRevenueService, BaseTornadoService, BatchBlockService, BatchEventsService, BatchTransactionService, DBEchoService, DBEncryptedNotesService, DBGovernanceService, DBRegistryService, DBRevenueService, DBTornadoService, Deposit, ENSNameWrapper__factory, ENSRegistry__factory, ENSResolver__factory, ENSUtils, ENS__factory, ERC20__factory, EnsContracts, INDEX_DB_ERROR, IndexedDB, Invoice, MAX_FEE, MAX_TOVARISH_EVENTS, 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, TovarishClient, addNetwork, addressSchemaType, ajv, base64ToBytes, bigIntReplacer, bnSchemaType, bnToBytes, buffPedersenHash, bufferToBytes, bytes32BNSchemaType, bytes32SchemaType, bytesToBN, bytesToBase64, bytesToHex, calculateScore, calculateSnarkProof, chunk, concatBytes, convertETHToTokenAmount, createDeposit, crypto, customConfig, defaultConfig, defaultUserAgent, deployHasher, depositsEventsSchema, digest, downloadZip, echoEventsSchema, enabledChains, encodedLabelToLabelhash, encryptedNotesSchema, index as factories, fetchData, fetchGetUrlFunc, fetchIp, fromContentHash, gasZipID, gasZipInbounds, gasZipInput, gasZipMinMax, getActiveTokenInstances, getActiveTokens, getConfig, getEventsSchemaValidator, getHttpAgent, getIndexedDB, getInstanceByAddress, getMultiInstances, getNetworkConfig, getPermit2CommitmentsSignature, getPermit2Signature, getPermitCommitmentsSignature, getPermitSignature, getProvider, getProviderWithNetId, getRelayerEnsSubdomains, getStatusSchema, getSubInfo, getSupportedInstances, getTokenBalances, getTovarishNetworks, getWeightRandom, governanceEventsSchema, hasherBytecode, hexToBytes, initGroth16, isHex, isNode, jobRequestSchema, jobsSchema, labelhash, leBuff2Int, leInt2Buff, loadDBEvents, loadRemoteEvents, makeLabelNodeAndParent, mimc, multiQueryFilter, multicall, numberFormatter, packEncryptedMessage, parseInvoice, parseNote, pedersen, permit2Address, pickWeightedRandomRelayer, populateTransaction, proofSchemaType, proposalState, rBigInt, rHex, relayerRegistryEventsSchema, saveDBEvents, sleep, stakeBurnedEventsSchema, substring, toContentHash, toFixedHex, toFixedLength, tornadoEventsSchema, unpackEncryptedMessage, unzipAsync, validateUrl, withdrawalsEventsSchema, zipAsync };
|
||||
export { BaseEchoService, BaseEncryptedNotesService, BaseEventsService, BaseGovernanceService, BaseMultiTornadoService, BaseRegistryService, BaseRevenueService, BaseTornadoService, BatchBlockService, BatchEventsService, BatchTransactionService, DBEchoService, DBEncryptedNotesService, DBGovernanceService, DBMultiTornadoService, DBRegistryService, DBRevenueService, DBTornadoService, Deposit, ENSNameWrapper__factory, ENSRegistry__factory, ENSResolver__factory, ENSUtils, ENS__factory, ERC20__factory, EnsContracts, INDEX_DB_ERROR, IndexedDB, Invoice, MAX_FEE, MAX_TOVARISH_EVENTS, 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, TovarishClient, addNetwork, addressSchemaType, ajv, base64ToBytes, bigIntReplacer, bnSchemaType, bnToBytes, buffPedersenHash, bufferToBytes, bytes32BNSchemaType, bytes32SchemaType, bytesToBN, bytesToBase64, bytesToHex, calculateScore, calculateSnarkProof, chunk, concatBytes, convertETHToTokenAmount, createDeposit, crypto, customConfig, defaultConfig, defaultUserAgent, deployHasher, depositsEventsSchema, digest, downloadZip, echoEventsSchema, enabledChains, encodedLabelToLabelhash, encryptedNotesSchema, index as factories, fetchData, fetchGetUrlFunc, fetchIp, fromContentHash, gasZipID, gasZipInbounds, gasZipInput, gasZipMinMax, getActiveTokenInstances, getActiveTokens, getConfig, getEventsSchemaValidator, getHttpAgent, getIndexedDB, getInstanceByAddress, getMultiInstances, getNetworkConfig, getPermit2CommitmentsSignature, getPermit2Signature, getPermitCommitmentsSignature, getPermitSignature, getProvider, getProviderWithNetId, getRelayerEnsSubdomains, getStatusSchema, getSubInfo, getSupportedInstances, getTokenBalances, getTovarishNetworks, getWeightRandom, governanceEventsSchema, hasherBytecode, hexToBytes, initGroth16, isHex, isNode, jobRequestSchema, jobsSchema, labelhash, leBuff2Int, leInt2Buff, loadDBEvents, loadRemoteEvents, makeLabelNodeAndParent, mimc, multiQueryFilter, multicall, numberFormatter, packEncryptedMessage, parseInvoice, parseNote, pedersen, permit2Address, pickWeightedRandomRelayer, populateTransaction, proofSchemaType, proposalState, rBigInt, rHex, relayerRegistryEventsSchema, saveDBEvents, sleep, stakeBurnedEventsSchema, substring, toContentHash, toFixedHex, toFixedLength, tornadoEventsSchema, unpackEncryptedMessage, unzipAsync, validateUrl, withdrawalsEventsSchema, zipAsync };
|
||||
|
1
dist/networkConfig.d.ts
vendored
1
dist/networkConfig.d.ts
vendored
@ -31,6 +31,7 @@ export interface TornadoInstance {
|
||||
instanceAddress: {
|
||||
[key: string]: string;
|
||||
};
|
||||
instanceApproval?: boolean;
|
||||
optionalInstances?: string[];
|
||||
tokenAddress?: string;
|
||||
tokenGasLimit?: number;
|
||||
|
129
dist/tornado.umd.js
vendored
129
dist/tornado.umd.js
vendored
@ -92585,7 +92585,10 @@ class BaseMultiTornadoService extends BaseEventsService {
|
||||
}
|
||||
return acc;
|
||||
},
|
||||
{}
|
||||
{
|
||||
depositEvents: [],
|
||||
withdrawalEvents: []
|
||||
}
|
||||
);
|
||||
return {
|
||||
depositEvents,
|
||||
@ -93222,6 +93225,7 @@ RevenueService: Mismatch on withdrawal logs (${withdrawalLogs.length} ) and even
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ $B: () => (/* binding */ DBEncryptedNotesService),
|
||||
/* harmony export */ Aq: () => (/* binding */ DBGovernanceService),
|
||||
/* harmony export */ C_: () => (/* binding */ DBMultiTornadoService),
|
||||
/* harmony export */ Fb: () => (/* binding */ saveDBEvents),
|
||||
/* harmony export */ Oz: () => (/* binding */ loadRemoteEvents),
|
||||
/* harmony export */ f8: () => (/* binding */ DBTornadoService),
|
||||
@ -93242,11 +93246,11 @@ RevenueService: Mismatch on withdrawal logs (${withdrawalLogs.length} ) and even
|
||||
async function saveDBEvents({
|
||||
idb,
|
||||
instanceName,
|
||||
events,
|
||||
newEvents,
|
||||
lastBlock
|
||||
}) {
|
||||
try {
|
||||
const formattedEvents = events.map((e) => {
|
||||
const formattedEvents = newEvents.map((e) => {
|
||||
return {
|
||||
eid: `${e.transactionHash}_${e.logIndex}`,
|
||||
...e
|
||||
@ -93357,11 +93361,49 @@ class DBTornadoService extends _base__WEBPACK_IMPORTED_MODULE_3__/* .BaseTornado
|
||||
zipDigest: this.zipDigest
|
||||
});
|
||||
}
|
||||
async saveEvents({ events, lastBlock }) {
|
||||
async saveEvents({
|
||||
newEvents,
|
||||
lastBlock
|
||||
}) {
|
||||
await saveDBEvents({
|
||||
idb: this.idb,
|
||||
instanceName: this.getInstanceName(),
|
||||
events,
|
||||
newEvents,
|
||||
lastBlock
|
||||
});
|
||||
}
|
||||
}
|
||||
class DBMultiTornadoService extends _base__WEBPACK_IMPORTED_MODULE_3__/* .BaseMultiTornadoService */ .lG {
|
||||
staticUrl;
|
||||
idb;
|
||||
zipDigest;
|
||||
constructor(params) {
|
||||
super(params);
|
||||
this.staticUrl = params.staticUrl;
|
||||
this.idb = params.idb;
|
||||
}
|
||||
async getEventsFromDB() {
|
||||
return await loadDBEvents({
|
||||
idb: this.idb,
|
||||
instanceName: this.getInstanceName()
|
||||
});
|
||||
}
|
||||
async getEventsFromCache() {
|
||||
return await loadRemoteEvents({
|
||||
staticUrl: this.staticUrl,
|
||||
instanceName: this.getInstanceName(),
|
||||
deployedBlock: this.deployedBlock,
|
||||
zipDigest: this.zipDigest
|
||||
});
|
||||
}
|
||||
async saveEvents({
|
||||
newEvents,
|
||||
lastBlock
|
||||
}) {
|
||||
await saveDBEvents({
|
||||
idb: this.idb,
|
||||
instanceName: this.getInstanceName(),
|
||||
newEvents,
|
||||
lastBlock
|
||||
});
|
||||
}
|
||||
@ -93389,11 +93431,11 @@ class DBEchoService extends _base__WEBPACK_IMPORTED_MODULE_3__/* .BaseEchoServic
|
||||
zipDigest: this.zipDigest
|
||||
});
|
||||
}
|
||||
async saveEvents({ events, lastBlock }) {
|
||||
async saveEvents({ newEvents, lastBlock }) {
|
||||
await saveDBEvents({
|
||||
idb: this.idb,
|
||||
instanceName: this.getInstanceName(),
|
||||
events,
|
||||
newEvents,
|
||||
lastBlock
|
||||
});
|
||||
}
|
||||
@ -93421,11 +93463,14 @@ class DBEncryptedNotesService extends _base__WEBPACK_IMPORTED_MODULE_3__/* .Base
|
||||
zipDigest: this.zipDigest
|
||||
});
|
||||
}
|
||||
async saveEvents({ events, lastBlock }) {
|
||||
async saveEvents({
|
||||
newEvents,
|
||||
lastBlock
|
||||
}) {
|
||||
await saveDBEvents({
|
||||
idb: this.idb,
|
||||
instanceName: this.getInstanceName(),
|
||||
events,
|
||||
newEvents,
|
||||
lastBlock
|
||||
});
|
||||
}
|
||||
@ -93453,11 +93498,11 @@ class DBGovernanceService extends _base__WEBPACK_IMPORTED_MODULE_3__/* .BaseGove
|
||||
zipDigest: this.zipDigest
|
||||
});
|
||||
}
|
||||
async saveEvents({ events, lastBlock }) {
|
||||
async saveEvents({ newEvents, lastBlock }) {
|
||||
await saveDBEvents({
|
||||
idb: this.idb,
|
||||
instanceName: this.getInstanceName(),
|
||||
events,
|
||||
newEvents,
|
||||
lastBlock
|
||||
});
|
||||
}
|
||||
@ -93486,11 +93531,14 @@ class DBRegistryService extends _base__WEBPACK_IMPORTED_MODULE_3__/* .BaseRegist
|
||||
zipDigest: this.zipDigest
|
||||
});
|
||||
}
|
||||
async saveEvents({ events, lastBlock }) {
|
||||
async saveEvents({
|
||||
newEvents,
|
||||
lastBlock
|
||||
}) {
|
||||
await saveDBEvents({
|
||||
idb: this.idb,
|
||||
instanceName: this.getInstanceName(),
|
||||
events,
|
||||
newEvents,
|
||||
lastBlock
|
||||
});
|
||||
}
|
||||
@ -93579,11 +93627,11 @@ class DBRevenueService extends _base__WEBPACK_IMPORTED_MODULE_3__/* .BaseRevenue
|
||||
zipDigest: this.zipDigest
|
||||
});
|
||||
}
|
||||
async saveEvents({ events, lastBlock }) {
|
||||
async saveEvents({ newEvents, lastBlock }) {
|
||||
await saveDBEvents({
|
||||
idb: this.idb,
|
||||
instanceName: this.getInstanceName(),
|
||||
events,
|
||||
newEvents,
|
||||
lastBlock
|
||||
});
|
||||
}
|
||||
@ -93609,6 +93657,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ DBEchoService: () => (/* reexport safe */ _db__WEBPACK_IMPORTED_MODULE_2__.xc),
|
||||
/* harmony export */ DBEncryptedNotesService: () => (/* reexport safe */ _db__WEBPACK_IMPORTED_MODULE_2__.$B),
|
||||
/* harmony export */ DBGovernanceService: () => (/* reexport safe */ _db__WEBPACK_IMPORTED_MODULE_2__.Aq),
|
||||
/* harmony export */ DBMultiTornadoService: () => (/* reexport safe */ _db__WEBPACK_IMPORTED_MODULE_2__.C_),
|
||||
/* harmony export */ DBRegistryService: () => (/* reexport safe */ _db__WEBPACK_IMPORTED_MODULE_2__.hD),
|
||||
/* harmony export */ DBRevenueService: () => (/* reexport safe */ _db__WEBPACK_IMPORTED_MODULE_2__.wV),
|
||||
/* harmony export */ DBTornadoService: () => (/* reexport safe */ _db__WEBPACK_IMPORTED_MODULE_2__.f8),
|
||||
@ -93677,7 +93726,7 @@ class TornadoFeeOracle {
|
||||
* (A single block can bump 12.5% of fees, see the methodology https://hackmd.io/@tvanepps/1559-wallets)
|
||||
* (Still it is recommended to use 100% premium for sending transactions to prevent stucking it)
|
||||
*/
|
||||
async gasPrice() {
|
||||
async gasPrice(premium) {
|
||||
const [block, getGasPrice, getPriorityFee] = await Promise.all([
|
||||
this.provider.getBlock("latest"),
|
||||
(async () => {
|
||||
@ -93695,7 +93744,7 @@ class TornadoFeeOracle {
|
||||
}
|
||||
})()
|
||||
]);
|
||||
return block?.baseFeePerGas ? block.baseFeePerGas * BigInt(15) / BigInt(10) + getPriorityFee : getGasPrice;
|
||||
return block?.baseFeePerGas ? block.baseFeePerGas * BigInt(1e4 * (100 + (premium || 50))) / BigInt(1e4 * 100) + getPriorityFee : getGasPrice;
|
||||
}
|
||||
/**
|
||||
* Calculate L1 fee for op-stack chains
|
||||
@ -94196,7 +94245,7 @@ class IndexedDB {
|
||||
}
|
||||
};
|
||||
this.dbName = dbName;
|
||||
this.dbVersion = 35;
|
||||
this.dbVersion = 36;
|
||||
}
|
||||
async initDB() {
|
||||
try {
|
||||
@ -94392,15 +94441,16 @@ async function getIndexedDB(netId) {
|
||||
}
|
||||
const minimalIndexes = [
|
||||
{
|
||||
name: "blockNumber",
|
||||
unique: false
|
||||
},
|
||||
{
|
||||
name: "transactionHash",
|
||||
unique: false
|
||||
name: "eid",
|
||||
unique: true
|
||||
}
|
||||
];
|
||||
const defaultState = [
|
||||
{
|
||||
name: `tornado_${netId}`,
|
||||
keyPath: "eid",
|
||||
indexes: [...minimalIndexes]
|
||||
},
|
||||
{
|
||||
name: `echo_${netId}`,
|
||||
keyPath: "eid",
|
||||
@ -94428,8 +94478,7 @@ async function getIndexedDB(netId) {
|
||||
]
|
||||
}
|
||||
];
|
||||
const config = (0,networkConfig/* getConfig */.zj)(netId);
|
||||
const { tokens, nativeCurrency, registryContract, governanceContract } = config;
|
||||
const { tokens, nativeCurrency, registryContract, governanceContract } = (0,networkConfig/* getConfig */.zj)(netId);
|
||||
const stores = [...defaultState];
|
||||
if (registryContract) {
|
||||
stores.push({
|
||||
@ -95015,6 +95064,34 @@ const defaultConfig = {
|
||||
},
|
||||
symbol: "BNB",
|
||||
decimals: 18
|
||||
},
|
||||
usdt: {
|
||||
instanceAddress: {
|
||||
"10": "0x261fB4f84bb0BdEe7E035B6a8a08e5c35AdacdDD",
|
||||
"100": "0x3957861d4897d883C9b944C0b4E22bBd0DDE6e21",
|
||||
"1000": "0x6D180403AdFb39F70983eB51A033C5e52eb9BB69",
|
||||
"10000": "0x3722662D8AaB07B216B14C02eF0ee940d14A4200"
|
||||
},
|
||||
instanceApproval: true,
|
||||
tokenAddress: "0x55d398326f99059fF775485246999027B3197955",
|
||||
tokenGasLimit: 7e4,
|
||||
symbol: "USDT",
|
||||
decimals: 18,
|
||||
gasLimit: 7e5
|
||||
},
|
||||
btcb: {
|
||||
instanceAddress: {
|
||||
"0.0001": "0x736dABbFc8101Ae75287104eCcf67e45D7369Ae1",
|
||||
"0.001": "0x82c7Ce6f1F158cEC5536d591a2BC19864b3CA823",
|
||||
"0.01": "0x8284c96679037d8081E498d8F767cA5a140BFAAf",
|
||||
"0.1": "0x2bcD128Ce23ee30Ee945E613ff129c4DE1102C79"
|
||||
},
|
||||
instanceApproval: true,
|
||||
tokenAddress: "0x7130d2A12B9BCbFAe4f2634d864A1Ee1Ce3Ead9c",
|
||||
tokenGasLimit: 7e4,
|
||||
symbol: "BTCB",
|
||||
decimals: 18,
|
||||
gasLimit: 7e5
|
||||
}
|
||||
},
|
||||
relayerEnsSubdomain: "bsc-tornado",
|
||||
|
6
dist/tornado.umd.min.js
vendored
6
dist/tornado.umd.min.js
vendored
File diff suppressed because one or more lines are too long
@ -613,9 +613,9 @@ export class BaseMultiTornadoService extends BaseEventsService<MultiDepositsEven
|
||||
}
|
||||
return acc;
|
||||
},
|
||||
{} as {
|
||||
depositEvents: MultiDepositsEvents[];
|
||||
withdrawalEvents: MultiWithdrawalsEvents[];
|
||||
{
|
||||
depositEvents: [] as MultiDepositsEvents[],
|
||||
withdrawalEvents: [] as MultiWithdrawalsEvents[],
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -17,6 +17,8 @@ import {
|
||||
BaseRevenueService,
|
||||
BaseRevenueServiceConstructor,
|
||||
CachedRelayers,
|
||||
BaseMultiTornadoService,
|
||||
BaseMultiTornadoServiceConstructor,
|
||||
} from './base';
|
||||
|
||||
import {
|
||||
@ -30,21 +32,23 @@ import {
|
||||
AllGovernanceEvents,
|
||||
AllRelayerRegistryEvents,
|
||||
StakeBurnedEvents,
|
||||
MultiDepositsEvents,
|
||||
MultiWithdrawalsEvents,
|
||||
} from './types';
|
||||
|
||||
export async function saveDBEvents<T extends MinimalEvents>({
|
||||
idb,
|
||||
instanceName,
|
||||
events,
|
||||
newEvents,
|
||||
lastBlock,
|
||||
}: {
|
||||
idb: IndexedDB;
|
||||
instanceName: string;
|
||||
events: T[];
|
||||
newEvents: T[];
|
||||
lastBlock: number;
|
||||
}) {
|
||||
try {
|
||||
const formattedEvents = events.map((e) => {
|
||||
const formattedEvents = newEvents.map((e) => {
|
||||
return {
|
||||
eid: `${e.transactionHash}_${e.logIndex}`,
|
||||
...e,
|
||||
@ -192,11 +196,63 @@ export class DBTornadoService extends BaseTornadoService {
|
||||
});
|
||||
}
|
||||
|
||||
async saveEvents({ events, lastBlock }: BaseEvents<DepositsEvents | WithdrawalsEvents>) {
|
||||
async saveEvents({
|
||||
newEvents,
|
||||
lastBlock,
|
||||
}: BaseEvents<DepositsEvents | WithdrawalsEvents> & { newEvents: (DepositsEvents | WithdrawalsEvents)[] }) {
|
||||
await saveDBEvents<DepositsEvents | WithdrawalsEvents>({
|
||||
idb: this.idb,
|
||||
instanceName: this.getInstanceName(),
|
||||
events,
|
||||
newEvents,
|
||||
lastBlock,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export interface DBMultiTornadoServiceConstructor extends BaseMultiTornadoServiceConstructor {
|
||||
staticUrl: string;
|
||||
idb: IndexedDB;
|
||||
}
|
||||
|
||||
export class DBMultiTornadoService extends BaseMultiTornadoService {
|
||||
staticUrl: string;
|
||||
idb: IndexedDB;
|
||||
|
||||
zipDigest?: string;
|
||||
|
||||
constructor(params: DBMultiTornadoServiceConstructor) {
|
||||
super(params);
|
||||
|
||||
this.staticUrl = params.staticUrl;
|
||||
this.idb = params.idb;
|
||||
}
|
||||
|
||||
async getEventsFromDB() {
|
||||
return await loadDBEvents<MultiDepositsEvents | MultiWithdrawalsEvents>({
|
||||
idb: this.idb,
|
||||
instanceName: this.getInstanceName(),
|
||||
});
|
||||
}
|
||||
|
||||
async getEventsFromCache() {
|
||||
return await loadRemoteEvents<MultiDepositsEvents | MultiWithdrawalsEvents>({
|
||||
staticUrl: this.staticUrl,
|
||||
instanceName: this.getInstanceName(),
|
||||
deployedBlock: this.deployedBlock,
|
||||
zipDigest: this.zipDigest,
|
||||
});
|
||||
}
|
||||
|
||||
async saveEvents({
|
||||
newEvents,
|
||||
lastBlock,
|
||||
}: BaseEvents<MultiDepositsEvents | MultiWithdrawalsEvents> & {
|
||||
newEvents: (MultiDepositsEvents | MultiWithdrawalsEvents)[];
|
||||
}) {
|
||||
await saveDBEvents<MultiDepositsEvents | MultiWithdrawalsEvents>({
|
||||
idb: this.idb,
|
||||
instanceName: this.getInstanceName(),
|
||||
newEvents,
|
||||
lastBlock,
|
||||
});
|
||||
}
|
||||
@ -236,11 +292,11 @@ export class DBEchoService extends BaseEchoService {
|
||||
});
|
||||
}
|
||||
|
||||
async saveEvents({ events, lastBlock }: BaseEvents<EchoEvents>) {
|
||||
async saveEvents({ newEvents, lastBlock }: BaseEvents<EchoEvents> & { newEvents: EchoEvents[] }) {
|
||||
await saveDBEvents<EchoEvents>({
|
||||
idb: this.idb,
|
||||
instanceName: this.getInstanceName(),
|
||||
events,
|
||||
newEvents,
|
||||
lastBlock,
|
||||
});
|
||||
}
|
||||
@ -280,11 +336,14 @@ export class DBEncryptedNotesService extends BaseEncryptedNotesService {
|
||||
});
|
||||
}
|
||||
|
||||
async saveEvents({ events, lastBlock }: BaseEvents<EncryptedNotesEvents>) {
|
||||
async saveEvents({
|
||||
newEvents,
|
||||
lastBlock,
|
||||
}: BaseEvents<EncryptedNotesEvents> & { newEvents: EncryptedNotesEvents[] }) {
|
||||
await saveDBEvents<EncryptedNotesEvents>({
|
||||
idb: this.idb,
|
||||
instanceName: this.getInstanceName(),
|
||||
events,
|
||||
newEvents,
|
||||
lastBlock,
|
||||
});
|
||||
}
|
||||
@ -324,11 +383,11 @@ export class DBGovernanceService extends BaseGovernanceService {
|
||||
});
|
||||
}
|
||||
|
||||
async saveEvents({ events, lastBlock }: BaseEvents<AllGovernanceEvents>) {
|
||||
async saveEvents({ newEvents, lastBlock }: BaseEvents<AllGovernanceEvents> & { newEvents: AllGovernanceEvents[] }) {
|
||||
await saveDBEvents<AllGovernanceEvents>({
|
||||
idb: this.idb,
|
||||
instanceName: this.getInstanceName(),
|
||||
events,
|
||||
newEvents,
|
||||
lastBlock,
|
||||
});
|
||||
}
|
||||
@ -369,11 +428,14 @@ export class DBRegistryService extends BaseRegistryService {
|
||||
});
|
||||
}
|
||||
|
||||
async saveEvents({ events, lastBlock }: BaseEvents<AllRelayerRegistryEvents>) {
|
||||
async saveEvents({
|
||||
newEvents,
|
||||
lastBlock,
|
||||
}: BaseEvents<AllRelayerRegistryEvents> & { newEvents: AllRelayerRegistryEvents[] }) {
|
||||
await saveDBEvents<AllRelayerRegistryEvents>({
|
||||
idb: this.idb,
|
||||
instanceName: this.getInstanceName(),
|
||||
events,
|
||||
newEvents,
|
||||
lastBlock,
|
||||
});
|
||||
}
|
||||
@ -486,11 +548,11 @@ export class DBRevenueService extends BaseRevenueService {
|
||||
});
|
||||
}
|
||||
|
||||
async saveEvents({ events, lastBlock }: BaseEvents<StakeBurnedEvents>) {
|
||||
async saveEvents({ newEvents, lastBlock }: BaseEvents<StakeBurnedEvents> & { newEvents: StakeBurnedEvents[] }) {
|
||||
await saveDBEvents<StakeBurnedEvents>({
|
||||
idb: this.idb,
|
||||
instanceName: this.getInstanceName(),
|
||||
events,
|
||||
newEvents,
|
||||
lastBlock,
|
||||
});
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ export class TornadoFeeOracle {
|
||||
* (A single block can bump 12.5% of fees, see the methodology https://hackmd.io/@tvanepps/1559-wallets)
|
||||
* (Still it is recommended to use 100% premium for sending transactions to prevent stucking it)
|
||||
*/
|
||||
async gasPrice() {
|
||||
async gasPrice(premium?: number) {
|
||||
const [block, getGasPrice, getPriorityFee] = await Promise.all([
|
||||
this.provider.getBlock('latest'),
|
||||
(async () => {
|
||||
@ -74,7 +74,9 @@ export class TornadoFeeOracle {
|
||||
})(),
|
||||
]);
|
||||
|
||||
return block?.baseFeePerGas ? (block.baseFeePerGas * BigInt(15)) / BigInt(10) + getPriorityFee : getGasPrice;
|
||||
return block?.baseFeePerGas
|
||||
? (block.baseFeePerGas * BigInt(10000 * (100 + (premium || 50)))) / BigInt(10000 * 100) + getPriorityFee
|
||||
: getGasPrice;
|
||||
}
|
||||
|
||||
/**
|
||||
|
19
src/idb.ts
19
src/idb.ts
@ -55,7 +55,7 @@ export class IndexedDB {
|
||||
};
|
||||
|
||||
this.dbName = dbName;
|
||||
this.dbVersion = 35;
|
||||
this.dbVersion = 36;
|
||||
}
|
||||
|
||||
async initDB() {
|
||||
@ -324,16 +324,17 @@ export async function getIndexedDB(netId?: NetIdType) {
|
||||
|
||||
const minimalIndexes = [
|
||||
{
|
||||
name: 'blockNumber',
|
||||
unique: false,
|
||||
},
|
||||
{
|
||||
name: 'transactionHash',
|
||||
unique: false,
|
||||
name: 'eid',
|
||||
unique: true,
|
||||
},
|
||||
];
|
||||
|
||||
const defaultState = [
|
||||
{
|
||||
name: `tornado_${netId}`,
|
||||
keyPath: 'eid',
|
||||
indexes: [...minimalIndexes],
|
||||
},
|
||||
{
|
||||
name: `echo_${netId}`,
|
||||
keyPath: 'eid',
|
||||
@ -362,9 +363,7 @@ export async function getIndexedDB(netId?: NetIdType) {
|
||||
},
|
||||
];
|
||||
|
||||
const config = getConfig(netId);
|
||||
|
||||
const { tokens, nativeCurrency, registryContract, governanceContract } = config;
|
||||
const { tokens, nativeCurrency, registryContract, governanceContract } = getConfig(netId);
|
||||
|
||||
const stores = [...defaultState];
|
||||
|
||||
|
@ -38,6 +38,7 @@ export interface TornadoInstance {
|
||||
instanceAddress: {
|
||||
[key: string]: string;
|
||||
};
|
||||
instanceApproval?: boolean;
|
||||
optionalInstances?: string[];
|
||||
tokenAddress?: string;
|
||||
tokenGasLimit?: number;
|
||||
@ -303,6 +304,34 @@ export const defaultConfig: networkConfig = {
|
||||
symbol: 'BNB',
|
||||
decimals: 18,
|
||||
},
|
||||
usdt: {
|
||||
instanceAddress: {
|
||||
'10': '0x261fB4f84bb0BdEe7E035B6a8a08e5c35AdacdDD',
|
||||
'100': '0x3957861d4897d883C9b944C0b4E22bBd0DDE6e21',
|
||||
'1000': '0x6D180403AdFb39F70983eB51A033C5e52eb9BB69',
|
||||
'10000': '0x3722662D8AaB07B216B14C02eF0ee940d14A4200',
|
||||
},
|
||||
instanceApproval: true,
|
||||
tokenAddress: '0x55d398326f99059fF775485246999027B3197955',
|
||||
tokenGasLimit: 70_000,
|
||||
symbol: 'USDT',
|
||||
decimals: 18,
|
||||
gasLimit: 700_000,
|
||||
},
|
||||
btcb: {
|
||||
instanceAddress: {
|
||||
'0.0001': '0x736dABbFc8101Ae75287104eCcf67e45D7369Ae1',
|
||||
'0.001': '0x82c7Ce6f1F158cEC5536d591a2BC19864b3CA823',
|
||||
'0.01': '0x8284c96679037d8081E498d8F767cA5a140BFAAf',
|
||||
'0.1': '0x2bcD128Ce23ee30Ee945E613ff129c4DE1102C79',
|
||||
},
|
||||
instanceApproval: true,
|
||||
tokenAddress: '0x7130d2A12B9BCbFAe4f2634d864A1Ee1Ce3Ead9c',
|
||||
tokenGasLimit: 70_000,
|
||||
symbol: 'BTCB',
|
||||
decimals: 18,
|
||||
gasLimit: 700_000,
|
||||
},
|
||||
},
|
||||
relayerEnsSubdomain: 'bsc-tornado',
|
||||
pollInterval: 10,
|
||||
|
Loading…
Reference in New Issue
Block a user