Skip to content

Commit

Permalink
Merge pull request #2 from ProofOfInnocence/migrate-to-sepolia
Browse files Browse the repository at this point in the history
Migrate to Sepolia
  • Loading branch information
ekrembal authored Mar 13, 2024
2 parents 3e98f80 + c3688e3 commit 14f94b4
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 27 deletions.
6 changes: 3 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ REDIS_URL=redis://redis/0
# for development
# REDIS_URL=redis://127.0.0.1:6379

CHAIN_ID=100
CHAIN_ID=11155111

RPC_URL=https://rpc.gnosischain.com
RPC_URL=https://ethereum-sepolia-rpc.publicnode.com
REWARD_ADDRESS=

PRIVATE_KEY=
Expand All @@ -22,7 +22,7 @@ MAX_GAS_PRICE=100
# commission for service
# transfer fee is a fixed value in ether, 0.01 means 0.01 ether
TRANSFER_SERVICE_FEE=0.00000001
WITHDRAWAL_SERVICE_FEE=0.05
WITHDRAWAL_SERVICE_FEE=0.005


# Pinata api key for uploading files to IPFS https://app.pinata.cloud/developers/api-keys
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
"@nestjs/microservices": "^9.0.0",
"@nestjs/platform-express": "^9.0.0",
"@pinata/sdk": "^2.1.0",
"@tornado/gas-price-oracle": "^0.5.3",
"@tornado/tx-manager": "^0.4.9",
"gas-price-oracle": "^0.5.2",
"tx-manager": "^0.4.9",
"ajv": "^8.6.1",
"bull": "^3.22.11",
"class-validator": "^0.13.1",
Expand Down
2 changes: 2 additions & 0 deletions src/constants/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ export const CONTRACT_NETWORKS: { [chainId in ChainId]: string } = {
// [ChainId.MAINNET]: '',
[ChainId.GOERLI]: '0x30221943644ffaa55f20e915a83352d0548585ca',
[ChainId.LOCALHOST]: '0xdc64a140aa3e981100a9beca4e685f962f0cf6c9',
[ChainId.SEPOLIA]: '0x8e3E4702B4ec7400ef15fba30B3e4bfdc72aBC3B',
};

export const RPC_LIST: { [chainId in ChainId]: string } = {
// [ChainId.MAINNET]: 'https://api.mycryptoapi.com/eth',
[ChainId.GOERLI]: 'https://ethereum-goerli.publicnode.com',
[ChainId.LOCALHOST]: 'http://127.0.0.1:8545/',
[ChainId.SEPOLIA]: 'https://ethereum-sepolia-rpc.publicnode.com',
};
6 changes: 6 additions & 0 deletions src/constants/variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ const NETWORKS_INFO: { [chainId in ChainId] } = {
gasLimit: BigNumber.from(2000000),
minimumBalance: '0.1',
},
[ChainId.SEPOLIA]: {
symbol: 'sepolia',
gasLimit: BigNumber.from(2000000),
minimumBalance: '0.1',
},
[ChainId.LOCALHOST]: {
symbol: 'localhost',
gasLimit: BigNumber.from(2000000),
Expand Down Expand Up @@ -58,4 +63,5 @@ export const SERVICE_ERRORS = {
TOKEN_RATES: 'Could not get token rates',
GAS_SPIKE: 'Provided fee is not enough. Probably it is a Gas Price spike, try to resubmit.',
IPFS_CID_FAIL: 'CIDs do not match',
INVALID_RELAYER_ADDRESS: 'Invalid relayer address',
};
8 changes: 7 additions & 1 deletion src/modules/queue/transaction.processor.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BigNumber } from 'ethers';
import { TxManager } from '@tornado/tx-manager';
import { TxManager } from 'tx-manager';
import { Job, Queue, DoneCallback } from 'bull';

import { Injectable } from '@nestjs/common';
Expand Down Expand Up @@ -37,6 +37,12 @@ export class TransactionProcessor extends BaseProcessor<Transaction> {
async processTransactions(job: Job<Transaction>, cb: DoneCallback) {
try {
const { extData, membershipProof } = job.data;
console.log('extData relayer:', extData.relayer);
const {rewardAddress} = this.configService.get('base');

Check failure on line 41 in src/modules/queue/transaction.processor.ts

View workflow job for this annotation

GitHub Actions / build

Replace `rewardAddress` with `·rewardAddress·`

Check failure on line 41 in src/modules/queue/transaction.processor.ts

View workflow job for this annotation

GitHub Actions / build

Replace `rewardAddress` with `·rewardAddress·`

if(extData.relayer != rewardAddress) {

Check failure on line 43 in src/modules/queue/transaction.processor.ts

View workflow job for this annotation

GitHub Actions / build

Insert `·`

Check failure on line 43 in src/modules/queue/transaction.processor.ts

View workflow job for this annotation

GitHub Actions / build

Insert `·`
throw new Error(SERVICE_ERRORS.INVALID_RELAYER_ADDRESS);
}
console.log('extData:', extData);
console.log('membershipProof:', membershipProof);
await this.checkFee({ fee: extData.fee, externalAmount: extData.extAmount });
Expand Down
4 changes: 2 additions & 2 deletions src/services/gas-price.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { Injectable } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';

import { BigNumber } from 'ethers';
import { GasPriceOracle } from '@tornado/gas-price-oracle';
import type { GasPrice } from '@tornado/gas-price-oracle/lib/services';
import { GasPriceOracle } from 'gas-price-oracle';
import type { GasPrice } from 'gas-price-oracle/lib/services';

import { toWei } from '@/utilities';
import { SERVICE_ERRORS } from '@/constants';
Expand Down
2 changes: 2 additions & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import { BytesLike } from '@ethersproject/bytes';
// const MAINNET_CHAIN_ID = 1;
const GOERLI_CHAIN_ID = 5;
const LOCALHOST_CHAIN_ID = 31337;
const SEPOLIA_CHAIN_ID = 11155111;

export enum ChainId {
// MAINNET = MAINNET_CHAIN_ID,
GOERLI = GOERLI_CHAIN_ID,
LOCALHOST = LOCALHOST_CHAIN_ID,
SEPOLIA = SEPOLIA_CHAIN_ID,
}

export type ExtData = {
Expand Down
38 changes: 19 additions & 19 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1223,25 +1223,6 @@
resolved "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82"
integrity sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==

"@tornado/gas-price-oracle@^0.5.3":
version "0.5.3"
resolved "https://git.tornado.ws/api/packages/tornado-packages/npm/%40tornado%2Fgas-price-oracle/-/0.5.3/gas-price-oracle-0.5.3.tgz#fb5423dddee2f52edbc16174c5ddce90bea5413d"
integrity sha512-LpVfPiPIz3FOmJdiqJf/yoeO5n9/Pd5jgtdY+6hB9lNW0AiWhylhpScojICViS+3OL9QC8CoTlgr+kbfGeO9pQ==
dependencies:
axios "^0.21.2"
bignumber.js "^9.0.0"
node-cache "^5.1.2"

"@tornado/tx-manager@^0.4.9":
version "0.4.9"
resolved "https://git.tornado.ws/api/packages/tornado-packages/npm/%40tornado%2Ftx-manager/-/0.4.9/tx-manager-0.4.9.tgz#075add158e3c01da1b34bbcd68ba764491746ceb"
integrity sha512-0j6bquM/gB6JZvm2nv2y1Xo35IvsZcjQ0BMlvoH8OZYa1dzXQCiNBKSlNOIBOFMsOklUXHNE1JmQpko+rTgXOA==
dependencies:
"@tornado/gas-price-oracle" "^0.5.3"
async-mutex "^0.2.4"
ethers "^5.4.6"
web3-core-promievent "^1.3.0"

"@tsconfig/node10@^1.0.7":
version "1.0.8"
resolved "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.8.tgz#c1e4e80d6f964fbecb3359c43bd48b40f7cadad9"
Expand Down Expand Up @@ -3330,6 +3311,15 @@ functional-red-black-tree@^1.0.1:
resolved "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327"
integrity sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=

gas-price-oracle@^0.5.0, gas-price-oracle@^0.5.2:
version "0.5.2"
resolved "https://registry.yarnpkg.com/gas-price-oracle/-/gas-price-oracle-0.5.2.tgz#f0ecadd49f4f20cd0038ea8ce396c5ab39aa3480"
integrity sha512-sV9CgnUNA/upJM2p4ksFWOXxxceV+1UXgdSi3e2AWUBBjJ+jviKKxyyGlF+zNFaXa6Ux6RcIDR6Abt2HL+CPkQ==
dependencies:
axios "^0.21.2"
bignumber.js "^9.0.0"
node-cache "^5.1.2"

gensync@^1.0.0-beta.2:
version "1.0.0-beta.2"
resolved "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz#32a6ee76c3d7f52d46b2b1ae5d93fea8580a25e0"
Expand Down Expand Up @@ -6050,6 +6040,16 @@ tsutils@^3.21.0:
dependencies:
tslib "^1.8.1"

tx-manager@^0.4.9:
version "0.4.9"
resolved "https://registry.yarnpkg.com/tx-manager/-/tx-manager-0.4.9.tgz#234a672ae0c5efb00697444896fc5ada3c464462"
integrity sha512-sSnLHXD6M8pBi1wqaGRdyAd2ZRMAoB/L5kDXUghJb3WkWx+/T0mM5N4CJ0Uy3FxPG88A8CWnOoaEt0lr/WXkcg==
dependencies:
async-mutex "^0.2.4"
ethers "^5.4.6"
gas-price-oracle "^0.5.0"
web3-core-promievent "^1.3.0"

type-check@^0.4.0, type-check@~0.4.0:
version "0.4.0"
resolved "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz#07b8203bfa7056c0657050e3ccd2c37730bab8f1"
Expand Down

0 comments on commit 14f94b4

Please sign in to comment.