Skip to content

Commit

Permalink
Merging the develop branch into the main branch (v3.9.0)
Browse files Browse the repository at this point in the history
Address prefixes, tron mainnet
  • Loading branch information
EvgenKor authored Jan 10, 2024
2 parents 810f69d + 2c94a16 commit a1cc05a
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 46 deletions.
59 changes: 42 additions & 17 deletions client-config-full.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"defaultPool": "BOB2USDC-goerli",
"defaultPool": "USDT-tron",

"pools": {
"USDC-polygon": {
Expand Down Expand Up @@ -107,30 +107,49 @@
"minTxAmount": 50000,
"depositScheme": "approve"
},
"USDT-devnet": {
"chainId": 728126428,
"poolAddress": "TVtGa6o4KWYa6pfcd6A34xQte1FuDJPFah",
"tokenAddress": "TRdunaTZCKYM9xW3HGJjJLQYV6f89UHEkD",
"relayerUrls": ["https://tron-devnet-relayer.thgkjlr.website"],
"USDT-nile": {
"chainId": 3448148188,
"poolAddress": "TT8GgygLhEDh88kYwY8mYz38iEpJWw1YLG",
"tokenAddress": "TXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBf",
"relayerUrls": ["https://tron-nile-relayer.thgkjlr.website"],
"delegatedProverUrls": [],
"coldStorageConfigPath": "",
"feeDecimals": 2,
"minTxAmount": 50000,
"depositScheme": "approve"
},
"USDT-nile": {
"USDT-nile-guard": {
"chainId": 3448148188,
"poolAddress": "TT8GgygLhEDh88kYwY8mYz38iEpJWw1YLG",
"poolAddress": "TJp4J3M2rEZ5euswTpGzUaVVEJxkXX66mL",
"tokenAddress": "TXYZopYRdj2D9XRtbG411XZZ3kM5VkAeBf",
"relayerUrls": ["https://tron-nile-relayer.thgkjlr.website"],
"relayerUrls": ["https://tron-nile-mpc-relayer.thgkjlr.website"],
"delegatedProverUrls": [],
"coldStorageConfigPath": "",
"feeDecimals": 2,
"minTxAmount": 50000,
"depositScheme": "approve"
},
"USDT-tron": {
"chainId": 728126428,
"poolAddress": "TXViaNRhEugXpAZApviBqBnbTSKUgejnR9",
"tokenAddress": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
"relayerUrls": ["https://relayer-tron-mpc.zkbob.com/"],
"delegatedProverUrls": [],
"coldStorageConfigPath": "",
"minTxAmount": 50000,
"depositScheme": "approve",
"ddSubgraph": ""
}
},

"extraPrefixes": [
{
"poolId": 16776968,
"prefix": "zkbob_nile_g",
"name": "USDT on Nile testnet (MPC guard contracts)"
}
],

"chains": {
"137": {
"rpcUrls": ["https://polygon-rpc.com", "https://rpc.ankr.com/polygon"]
Expand All @@ -150,11 +169,11 @@
"2494104990": {
"rpcUrls": ["https://api.shasta.trongrid.io"]
},
"728126428": {
"rpcUrls": ["https://tron-devnet.zkbob.com"]
},
"3448148188": {
"rpcUrls": ["https://nile.trongrid.io"]
},
"728126428": {
"rpcUrls": ["https://api.trongrid.io"]
}
},

Expand Down Expand Up @@ -196,8 +215,8 @@
"address": "https://shasta.tronscan.org/#/address/{{addr}}"
},
"728126428": {
"tx": "{{hash}}",
"address": "{{addr}}"
"tx": "https://tronscan.org/#/transaction/{{hash}}",
"address": "https://tronscan.org/#/address/{{addr}}"
},
"3448148188": {
"tx": "https://nile.tronscan.org/#/transaction/{{hash}}",
Expand All @@ -216,7 +235,9 @@
"BOB-op-goerli": "0x357cA353dbCad28418d5F3110727B2af62803F20",
"USDT-shasta": "",
"USDT-devnet": "TRdunaTZCKYM9xW3HGJjJLQYV6f89UHEkD",
"USDT-nile": ""
"USDT-nile": "",
"USDT-nile-guard": "",
"USDT-tron": ""
},

"cloudApi": {
Expand All @@ -230,7 +251,9 @@
"BOB-op-goerli": "",
"USDT-shasta": "",
"USDT-devnet": "",
"USDT-nile": ""
"USDT-nile": "",
"USDT-nile-guard": "",
"USDT-tron": ""
},

"redemptionUrls": {
Expand All @@ -244,7 +267,9 @@
"BOB-op-goerli": "https://staging--zkbob.netlify.app",
"USDT-shasta": "https://staging--zkbob.netlify.app",
"USDT-devnet": "https://staging--zkbob.netlify.app",
"USDT-nile": "https://staging--zkbob.netlify.app"
"USDT-nile": "https://staging--zkbob.netlify.app",
"USDT-nile-guard": "https://staging--zkbob.netlify.app",
"USDT-tron": "https://tron.zkbob.com"
},

"migrations": {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zkbob-console",
"version": "3.8.0",
"version": "3.9.0",
"license": "MIT",
"author": "Dmitry Vdovin <[email protected]>",
"homepage": "https://github.com/zkBob/zkbob-console",
Expand Down Expand Up @@ -40,7 +40,7 @@
"tslib": "^2.3.1",
"uuid": "^9.0.0",
"web3": "^1.7.1",
"zkbob-client-js": "5.4.0",
"zkbob-client-js": "5.5.0",
"zkbob-support-js": "1.0.1"
},
"devDependencies": {
Expand Down
12 changes: 9 additions & 3 deletions src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export class Account {
this.config = {
pools: env.pools,
chains: env.chains,
extraPrefixes: env.extraPrefixes,
snarkParams: env.globalSnarks,
snarkParamsSet: env.snarkParamsSet,
supportId: this.supportId,
Expand Down Expand Up @@ -602,11 +603,12 @@ export class Account {
let totalNeededAmount = await this.getZpClient().shieldedAmountToWei(amount + feeEst.total);
if (depositScheme == DepositType.Approve) {
// check a token approvement if needed (in case of approve deposit scheme)
const currentAllowance = await this.getClient().allowance(this.getTokenAddr(), this.getPoolAddr());
const depositDestination = this.getPoolAddr();
const currentAllowance = await this.getClient().allowance(this.getTokenAddr(), depositDestination);
if (totalNeededAmount > currentAllowance) {
totalNeededAmount -= currentAllowance;
console.log(`Increasing allowance for the Pool (${this.getPoolAddr()}) to spend our tokens (+ ${await this.weiToHuman(totalNeededAmount)} ${this.tokenSymbol()})`);
await this.getClient().increaseAllowance(this.getTokenAddr(), this.getPoolAddr(), totalNeededAmount);
console.log(`Increasing allowance for the Pool contract (${depositDestination}) to spend our tokens (+ ${await this.weiToHuman(totalNeededAmount)} ${this.tokenSymbol()})`);
await this.getClient().increaseAllowance(this.getTokenAddr(), depositDestination, totalNeededAmount);
} else {
console.log(`Current allowance (${await this.weiToHuman(currentAllowance)} ${this.tokenSymbol()}) is greater or equal than needed (${await this.weiToHuman(totalNeededAmount)} ${this.tokenSymbol()}). Skipping approve`);
}
Expand Down Expand Up @@ -840,4 +842,8 @@ export class Account {
public async proverVersion(): Promise<ServiceVersion> {
return await this.getZpClient().getProverVersion();
}

public async getTokenSeller() : Promise<string> {
return await this.getZpClient().tokenSellerContract();
}
}
34 changes: 25 additions & 9 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function account(_this: any): Account {
}

export async function currentPoolEnvironment() {
const curPool = await account(this).getCurrentPool();
const curPool = account(this).getCurrentPool();
const poolEnv = env.pools[curPool];
const chainEnv = env.chains[String(poolEnv.chainId)];

Expand Down Expand Up @@ -110,13 +110,19 @@ export async function genShieldedAddressUniversal(number: string) {
}

export async function shieldedAddressInfo(shieldedAddress: string) {
this.echo('Validating ...');
const isValid = await account(this).verifyShieldedAddress(shieldedAddress);
this.update(-1, `Validating ${isValid ? '[[;green;]PASS]' : '[[;red;]ERROR]'}`)
this.echo('Checking ownable on the current pool ...');
const isOwn = await account(this).isMyAddress(shieldedAddress);
this.update(-1, `Checking ownable on the current pool ${isOwn ? '[[;green;]YES]' : '[[;red;]NO]'}`)

this.echo('Parsing address...');
try {
const components = await account(this).zkAddressInfo(shieldedAddress);
this.update(-1, 'Parsing address... [[;green;]OK]');
this.echo(`Address format: [[;white;]${components.format}]`);
this.echo(`Is it derived from my SK: ${components.derived_from_our_sk ? '[[;green;]YES]' : '[[;white;]NO]'}`);
const isValid = await account(this).verifyShieldedAddress(shieldedAddress);
this.echo(`Is it valid on current pool: ${isValid ? '[[;green;]YES]' : '[[;red;]NO]'}`);
try {
const poolId = BigInt(components.pool_id);
Expand Down Expand Up @@ -821,21 +827,31 @@ export async function getRoot(index: string) {

this.echo(`Requesting additional info...`);
this.pause();
const relayerState = account(this).getRelayerTreeState();
const relayerState = account(this).getRelayerTreeState().catch((e) => e.message);
let relayerOptimisticState;
if (idx === undefined) {
relayerOptimisticState = account(this).getRelayerOptimisticTreeState();
relayerOptimisticState = account(this).getRelayerOptimisticTreeState().catch((e) => e.message);
}
const poolState = account(this).getPoolTreeState(idx);
const poolState = account(this).getPoolTreeState(idx).catch((e) => e.message);

let promises = [relayerState, relayerOptimisticState, poolState]
Promise.all(promises).then((states) => {
const relayerState = typeof states[0] === "string" ? `[[;red;]${states[0]}]` :
`[[;white;]${states[0].root.toString()} @${states[0].index.toString()}]`;
const relayerOpState = typeof states[1] === "string" ? `[[;red;]${states[1]}]` :
`[[;white;]${states[1].root.toString()} @${states[1].index.toString()}]`;
const poolState = typeof states[2] === "string" ? `[[;red;]${states[2]}]` :
`[[;white;]${states[2].root.toString()} @${states[2].index.toString()}]`;

if (relayerOptimisticState !== undefined) {
this.update(-1, `Relayer: [[;white;]${states[0].root.toString()} @${states[0].index.toString()}]`);
this.echo(`Relayer optimistic: [[;white;]${states[1].root.toString()} @${states[1].index.toString()}]`);
this.echo(`Pool contract: [[;white;]${states[2].root.toString()} @${states[2].index.toString()}]`);
const relayerOpState = typeof states[1] === "string" ? `[[;red;]${states[1]}]` :
`[[;white;]${states[1].root.toString()} @${states[1].index.toString()}]`;

this.update(-1, `Relayer: ${relayerState}`);
this.echo(`Relayer optimistic: ${relayerOpState}`);
this.echo(`Pool contract: ${poolState}`);
} else {
this.update(-1, `Pool contract: [[;white;]${states[2].root.toString()} @${states[2].index.toString()}]`);
this.update(-1, `Pool contract: ${poolState}`);
}
}).catch((reason) => {
this.error(`Cannot fetch additional info: ${reason}`);
Expand Down
3 changes: 2 additions & 1 deletion src/environment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Chains, Pools, SnarkConfigParams, Parameters } from 'zkbob-client-js';
import { Chains, Pools, SnarkConfigParams, Parameters, ZkAddressPrefix } from 'zkbob-client-js';

export interface TokenMigrationConfig {
tokenAddress: string;
Expand All @@ -10,6 +10,7 @@ export interface ConsoleConfig {
defaultPool: string;
pools: Pools;
chains: Chains;
extraPrefixes?: ZkAddressPrefix[];
globalSnarks?: SnarkConfigParams;
snarkParamsSet?: Parameters;
blockExplorerUrls: {[chainId: string]: {tx: string, address: string} };
Expand Down
28 changes: 14 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8216,15 +8216,15 @@ levn@^0.3.0, levn@~0.3.0:
prelude-ls "~1.1.2"
type-check "~0.3.2"

libzkbob-rs-wasm-web-mt@1.5.0:
version "1.5.0"
resolved "https://registry.yarnpkg.com/libzkbob-rs-wasm-web-mt/-/libzkbob-rs-wasm-web-mt-1.5.0.tgz#6a88fe3fdfcd0fe856fd791fa0976bdde2fea34b"
integrity sha512-2uwwE5mm32ITMvYgW3uPsPXLrPVutnpYB003wzDzMbPfF2EBjP1kh+sQwPUDmEl+ic4OSTXU/q3sdkWWmhUhRQ==
libzkbob-rs-wasm-web-mt@1.6.0:
version "1.6.0"
resolved "https://registry.yarnpkg.com/libzkbob-rs-wasm-web-mt/-/libzkbob-rs-wasm-web-mt-1.6.0.tgz#9437cdd240fb1ac47e6e3fbc7e34f45ade5af19e"
integrity sha512-nAfmUh8ZrQ5WfEc3v7+vWWRWjOy3uFWn/LRdIce7zmnq1t8X91MD+RgnPcHxbgDpz5eGpSn5V/OSc3XYPwm9aw==

libzkbob-rs-wasm-web@1.5.0:
version "1.5.0"
resolved "https://registry.yarnpkg.com/libzkbob-rs-wasm-web/-/libzkbob-rs-wasm-web-1.5.0.tgz#41c2b0a51a9283a96457bd5439cfeed27f866913"
integrity sha512-QlnFMNzqjFakkIDrST4kmOdr+OikMZVZoOi2B73F/kb/3elcPSA5vAjYM/AdmB3+Ojty4ZrQW1GnsFWJrebF5w==
libzkbob-rs-wasm-web@1.6.0:
version "1.6.0"
resolved "https://registry.yarnpkg.com/libzkbob-rs-wasm-web/-/libzkbob-rs-wasm-web-1.6.0.tgz#050887671fb1af20adb22a144e95e06c59e42460"
integrity sha512-Mtpc/pqutA2tUzb8nir7Ec2oXTSPbYvjf969QsJKcdJR/JmCGbv1gmylxjVdL7QnAUTH3ldt0jj5CU8v8X6yzw==

[email protected]:
version "3.1.1"
Expand Down Expand Up @@ -13074,10 +13074,10 @@ yocto-queue@^0.1.0:
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"
integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==

zkbob-client-js@5.4.0:
version "5.4.0"
resolved "https://registry.yarnpkg.com/zkbob-client-js/-/zkbob-client-js-5.4.0.tgz#a4eb6fc03fe56aaa83038f9fb9548fb6ea13b094"
integrity sha512-kMlqGckUsr6pYLI0S+9sZI60vUkSnNHyZQfMFcZ+BT19qNOwlXu00TON7Ro2FIYDAKwKOj98Jz2ACAvEPrHvSw==
zkbob-client-js@5.5.0:
version "5.5.0"
resolved "https://registry.yarnpkg.com/zkbob-client-js/-/zkbob-client-js-5.5.0.tgz#b5811083680b47562cb5fa7de8a789d8c216fed5"
integrity sha512-KJlQ6T1iy3uyZP/BbGwQSuK8zqsw1VUcMz3aSVrqMU9hgEbOUa18vF4U6IUELMsahw4QfPE/1W0lwAYmyNZShA==
dependencies:
"@ethereumjs/util" "^8.0.2"
"@graphprotocol/client-cli" "3.0.0"
Expand All @@ -13090,8 +13090,8 @@ [email protected]:
graphql "16.7.1"
hdwallet-babyjub "^0.0.2"
idb "^7.0.0"
libzkbob-rs-wasm-web "1.5.0"
libzkbob-rs-wasm-web-mt "1.5.0"
libzkbob-rs-wasm-web "1.6.0"
libzkbob-rs-wasm-web-mt "1.6.0"
promise-retry "^2.0.1"
promise-throttle "^1.1.2"
regenerator-runtime "^0.13.9"
Expand Down

0 comments on commit a1cc05a

Please sign in to comment.