chg: according to mango chain
MODIFY
examples/utils_hermez.js
examples/utils_hermez.js
@@ -10,7 +10,7 @@ use(Web3ClientPlugin)
const privateKey = config.user1.privateKey
const userAddress = config.user1.address
-const getHermezClient = (network = 'testnet', version = 'litchi') => {
+const getHermezClient = (network = 'testnet', version = 'mango') => {
const hermezClient = new HermezClient()
return hermezClient.init({
log: true,

MODIFY
src/hermez/bridge_util.ts
src/hermez/bridge_util.ts
@@ -36,7 +36,7 @@ interface IClaimPayload {
export class BridgeUtil {
private client_: Web3SideChainClient<IBaseClientConfig>;
- private BRIDGE_TOPIC = "0xf0b963192bdc6349c23af9bd17294b4c7b9b5a73a2a9939610ea18ffd1c5dc2a";
+ private BRIDGE_TOPIC = "0x501781209a1f8899323b96b4ef08b168df93e0a90c673d1e4cce39366cb62f9b";
constructor(client: Web3SideChainClient<IBaseClientConfig>) {
this.client_ = client;
@@ -44,14 +44,15 @@ export class BridgeUtil {
private decodedBridgeData_(data: string, isParent: boolean) {
const client = isParent ? this.client_.parent : this.client_.child;
- return this.client_.getABI("Bridge", "zkevm").then(abi => {
+ return this.client_.getABI("PolygonZkEVMBridge", "zkevm").then(abi => {
const types = abi.filter(event => event.name === "BridgeEvent");
if (!types.length) {
throw new Error("Data not decoded");
}
const decodedData = client.decodeParameters(data, types[0].inputs);
- const [originNetwork, originTokenAddress, destinationNetwork, destinationAddress, amount, metadata, depositCount] = decodedData;
+ const [leafType, originNetwork, originTokenAddress, destinationNetwork, destinationAddress, amount, metadata, depositCount] = decodedData;
return {
+ leafType,
originNetwork,
originTokenAddress,
destinationNetwork,

MODIFY
src/hermez/hermez_bridge.ts
src/hermez/hermez_bridge.ts
@@ -9,7 +9,7 @@ export class HermezBridge extends BaseToken<IHermezClientConfig> {
constructor(client_: Web3SideChainClient<IHermezClientConfig>, address: string, isParent: boolean) {
super({
address: address,
- name: 'Bridge',
+ name: 'PolygonZkEVMBridge',
bridgeType: 'zkevm',
isParent: isParent
}, client_);
@@ -43,7 +43,7 @@ export class HermezBridge extends BaseToken<IHermezClientConfig> {
option?: ITransactionOption
) {
return this.method(
- "bridge",
+ "bridgeAsset",
token,
destinationNetwork,
destinationAddress,
@@ -85,7 +85,7 @@ export class HermezBridge extends BaseToken<IHermezClientConfig> {
option: ITransactionOption
) {
return this.method(
- "claim",
+ "claimAsset",
smtProof,
index,
mainnetExitRoot,
@@ -130,11 +130,11 @@ export class HermezBridge extends BaseToken<IHermezClientConfig> {
* @returns
* @memberof HermezBridge
*/
- claimNullifier(
+ isClaimed(
index: number,
) {
return this.method(
- "claimNullifier", index
+ "isClaimed", index
).then(method => {
return this.processRead<string>(method);
});

MODIFY
src/hermez/index.ts
src/hermez/index.ts
@@ -19,8 +19,8 @@ export class HermezClient extends HermezBridgeClient<IHermezClientConfig> {
const hermezContracts = client.hermezContracts;
client.config = config = Object.assign(
{
- parentBridge: mainHermezContracts.BridgeProxy,
- childBridge: hermezContracts.Bridge,
+ parentBridge: mainHermezContracts.PolygonZkEVMBridgeProxy,
+ childBridge: hermezContracts.PolygonZkEVMBridge,
} as IHermezClientConfig,
config
);

MODIFY
src/pos/root_chain.ts
src/pos/root_chain.ts
@@ -21,7 +21,7 @@ export class RootChain extends BaseToken<IPOSClientConfig> {
getLastChildBlock() {
return this.method("getLastChildBlock").then(method => {
- return method.read<string>({}, this.client.config.rootChainDefaultBlock||'finalized');
+ return method.read<string>({}, this.client.config.rootChainDefaultBlock || 'safe');
});
}

MODIFY
src/utils/hermez_bridge_client.ts
src/utils/hermez_bridge_client.ts
@@ -54,7 +54,7 @@ export class HermezBridgeClient<T> {
return this.bridgeUtil.getBridgeLogData(
txHash, true
).then(result => {
- return this.childChainBridge.claimNullifier(result.depositCount);
+ return this.childChainBridge.isClaimed(result.depositCount);
});
}
@@ -69,7 +69,7 @@ export class HermezBridgeClient<T> {
return this.bridgeUtil.getBridgeLogData(
txHash, false
).then(result => {
- return this.rootChainBridge.claimNullifier(result.depositCount);
+ return this.rootChainBridge.isClaimed(result.depositCount);
});
}

MODIFY
src/utils/web3_side_chain_client.ts
src/utils/web3_side_chain_client.ts
@@ -9,7 +9,7 @@ const chainIdToConfigPath = {
5: 'Main',
137: 'Matic',
80001: 'Matic',
- 1402: 'Hermez'
+ 1422: 'Hermez'
};
export class Web3SideChainClient<T_CONFIG> {

MODIFY
test/config.js
test/config.js
@@ -44,7 +44,7 @@ module.exports = {
ether: '0x0000000000000000000000000000000000000000',
// erc20: '0x270969e59d170fB576cBB5E254493e9bfB13684f', // WETH
// erc20: '0x08bd5b6d0237FaAED3C5E04fB131de2f843aC756', // DAI
- erc20: '0x73DeceDCa3d3aD2fFdB7FD5afd819a11dbc297f5' // Polygon
+ erc20: '0x20359119308a1527f36458be807248CE8Fc00441' // Polygon
},
},
user1: {

MODIFY
test/debug.js
test/debug.js
@@ -146,10 +146,10 @@ const execute = async () => {
const executeHermez = async () => {
const privateKey = user1.privateKey;
- const litchiERC20 = hermez.child.erc20;
+ const mangoERC20 = hermez.child.erc20;
const goerliERC20 = hermez.parent.erc20;
- const litchiEther = hermez.child.ether;
+ const mangoEther = hermez.child.ether;
const goerliEther = hermez.parent.ether;
const client = new HermezClient();
@@ -157,7 +157,7 @@ const executeHermez = async () => {
await client.init({
log: true,
network: 'testnet',
- version: 'litchi',
+ version: 'mango',
parent: {
provider: new HDWalletProvider(privateKey, rpc.hermez.parent),
defaultConfig: {
@@ -173,10 +173,10 @@ const executeHermez = async () => {
});
console.log("init called");
- const litchiERC20Token = client.erc20(litchiERC20);
+ const mangoERC20Token = client.erc20(mangoERC20);
const goerliERC20Token = client.erc20(goerliERC20, true);
- const litchiEtherToken = client.erc20(litchiEther);
+ const mangoEtherToken = client.erc20(mangoEther);
const goerliEtherToken = client.erc20(goerliEther, true);
// setProofApi("https://bridge-api.public.zkevm-test.net/");
@@ -202,7 +202,7 @@ const executeHermez = async () => {
// return console.log('result', result);
// // getOriginTokenInfo
- // var result = await client.childChainBridge.getOriginTokenInfo(litchiERC20);
+ // var result = await client.childChainBridge.getOriginTokenInfo(mangoERC20);
// return console.log('result', result);
// // getBalance on goerli
@@ -213,8 +213,8 @@ const executeHermez = async () => {
// var result = await goerliEtherToken.getBalance("0xFd71Dc9721d9ddCF0480A582927c3dCd42f3064C");
// return console.log('result', result);
- // // getBalance on litchi
- // var result = await litchiERC20Token.getBalance("0xFd71Dc9721d9ddCF0480A582927c3dCd42f3064C");
+ // // getBalance on mango
+ // var result = await mangoERC20Token.getBalance("0xFd71Dc9721d9ddCF0480A582927c3dCd42f3064C");
// return console.log('result', result);
// // getAllowance
@@ -230,7 +230,7 @@ const executeHermez = async () => {
// return console.log("hash", tx);
// // claim Ether
- // var tx = await litchiEtherToken.depositClaim("0xd2019abfdb978346cfc886525752b3d8a5798b8c474a46a8d18ed9b293bd5862", {returnTransaction: true});
+ // var tx = await mangoEtherToken.depositClaim("0xd2019abfdb978346cfc886525752b3d8a5798b8c474a46a8d18ed9b293bd5862", {returnTransaction: true});
// return console.log("hash", tx);
// // deposit ERC20
@@ -238,7 +238,7 @@ const executeHermez = async () => {
// return console.log("hash", tx);
// // deposit claim ERC20
- // var tx = await litchiERC20Token.depositClaim("0x080b05623d70c2858cb1fc64fd76cd04bde52a0a344d3cb896d33833ef221b12", {returnTransaction: true});
+ // var tx = await mangoERC20Token.depositClaim("0x080b05623d70c2858cb1fc64fd76cd04bde52a0a344d3cb896d33833ef221b12", {returnTransaction: true});
// return console.log("hash", tx);
// // Get Permit Data
@@ -250,11 +250,11 @@ const executeHermez = async () => {
// return console.log("hash", tx);
// // withdraw Ether
- // var tx = await litchiEtherToken.withdraw("1", from, {returnTransaction: true});
+ // var tx = await mangoEtherToken.withdraw("1", from, {returnTransaction: true});
// return console.log("hash", tx);
// // withdraw ERC20
- // var tx = await litchiERC20Token.withdraw("1", from, {returnTransaction: true});
+ // var tx = await mangoERC20Token.withdraw("1", from, {returnTransaction: true});
// return console.log("hash", tx);
// // withdraw exit ERC20

MODIFY
test/ether.js
test/ether.js
@@ -60,10 +60,10 @@ const execute = async () => {
const executeHermez = async () => {
const privateKey = user1.privateKey;
- const litchiERC20 = hermez.child.erc20;
+ const mangoERC20 = hermez.child.erc20;
const goerliERC20 = hermez.parent.erc20;
- const litchiEther = hermez.child.ether;
+ const mangoEther = hermez.child.ether;
const goerliEther = hermez.parent.ether;
const parentPrivder = new providers.JsonRpcProvider(rpc.hermez.parent);
@@ -74,7 +74,7 @@ const executeHermez = async () => {
await client.init({
log: true,
network: 'testnet',
- version: 'litchi',
+ version: 'mango',
parent: {
provider: new Wallet(privateKey, parentPrivder),
defaultConfig: {
@@ -90,10 +90,10 @@ const executeHermez = async () => {
});
console.log("init called");
- const litchiERC20Token = client.erc20(litchiERC20);
+ const mangoERC20Token = client.erc20(mangoERC20);
const goerliERC20Token = client.erc20(goerliERC20, true);
- const litchiEtherToken = client.erc20(litchiEther);
+ const mangoEtherToken = client.erc20(mangoEther);
const goerliEtherToken = client.erc20(goerliEther, true);
// setProofApi("https://bridge-api.public.zkevm-test.net/");
@@ -119,7 +119,7 @@ const executeHermez = async () => {
// return console.log('result', result);
// // getOriginTokenInfo
- // var result = await client.childChainBridge.getOriginTokenInfo(litchiERC20);
+ // var result = await client.childChainBridge.getOriginTokenInfo(mangoERC20);
// return console.log('result', result);
// // getBalance on goerli
@@ -130,8 +130,8 @@ const executeHermez = async () => {
// var result = await goerliEtherToken.getBalance("0xFd71Dc9721d9ddCF0480A582927c3dCd42f3064C");
// return console.log('result', result);
- // // getBalance on litchi
- // var result = await litchiERC20Token.getBalance("0xFd71Dc9721d9ddCF0480A582927c3dCd42f3064C");
+ // // getBalance on mango
+ // var result = await mangoERC20Token.getBalance("0xFd71Dc9721d9ddCF0480A582927c3dCd42f3064C");
// return console.log('result', result);
// // getAllowance
@@ -147,7 +147,7 @@ const executeHermez = async () => {
// return console.log("hash", tx);
// // claim Ether
- // var tx = await litchiEtherToken.depositClaim("0xd2019abfdb978346cfc886525752b3d8a5798b8c474a46a8d18ed9b293bd5862", {returnTransaction: true});
+ // var tx = await mangoEtherToken.depositClaim("0xd2019abfdb978346cfc886525752b3d8a5798b8c474a46a8d18ed9b293bd5862", {returnTransaction: true});
// return console.log("hash", tx);
// // deposit ERC20
@@ -155,7 +155,7 @@ const executeHermez = async () => {
// return console.log("hash", tx);
// // deposit claim ERC20
- // var tx = await litchiERC20Token.depositClaim("0x080b05623d70c2858cb1fc64fd76cd04bde52a0a344d3cb896d33833ef221b12", {returnTransaction: true});
+ // var tx = await mangoERC20Token.depositClaim("0x080b05623d70c2858cb1fc64fd76cd04bde52a0a344d3cb896d33833ef221b12", {returnTransaction: true});
// return console.log("hash", tx);
// // Get Permit Data
@@ -167,11 +167,11 @@ const executeHermez = async () => {
// return console.log("hash", tx);
// // withdraw Ether
- // var tx = await litchiEtherToken.withdraw("1", from, {returnTransaction: true});
+ // var tx = await mangoEtherToken.withdraw("1", from, {returnTransaction: true});
// return console.log("hash", tx);
// // withdraw ERC20
- // var tx = await litchiERC20Token.withdraw("1", from, {returnTransaction: true});
+ // var tx = await mangoERC20Token.withdraw("1", from, {returnTransaction: true});
// return console.log("hash", tx);
// // withdraw exit ERC20

MODIFY
test/specs/hermez/erc20.spec.ts
test/specs/hermez/erc20.spec.ts
@@ -16,13 +16,13 @@ describe('ERC20', () => {
let etherChild = hermezClient.erc20(ether.child);
let etherParent = hermezClient.erc20(ether.parent, true);
- const abiManager = new ABIManager("testnet", "litchi");
+ const abiManager = new ABIManager("testnet", "mango");
before(() => {
return Promise.all([
hermezClient.init({
// log: true,
network: 'testnet',
- version: 'litchi',
+ version: 'mango',
parent: {
provider: new Wallet(privateKey, parentPrivder),
defaultConfig: {
@@ -39,7 +39,7 @@ describe('ERC20', () => {
hermezClientForTo.init({
// log: true,
network: 'testnet',
- version: 'litchi',
+ version: 'mango',
parent: {
provider: new Wallet(toPrivateKey, parentPrivder),
defaultConfig: {
@@ -59,17 +59,16 @@ describe('ERC20', () => {
// BALANCE
it('get erc20 balance child', async () => {
- console.log('process.env.NODE_ENV', process.env.NODE_ENV, hermezClient.client);
-
+ console.log('process.env.NODE_ENV', process.env.NODE_ENV);
const balance = await erc20Child.getBalance(from);
- console.log('balance', balance);
+ console.log('ERC20 balance child', balance);
expect(balance).to.be.an('string');
expect(Number(balance)).gte(0);
})
it('get erc20 balance parent', async () => {
const balance = await erc20Parent.getBalance(from);
- console.log('balance', balance);
+ console.log('ERC20 balance parent', balance);
expect(balance).to.be.an('string');
expect(Number(balance)).gte(0);
})
@@ -105,30 +104,30 @@ describe('ERC20', () => {
// IS DEPOSIT CLAIMABLE
it('is Deposit Claimable', async () => {
- const isDepositClaimable = await hermezClient.isDepositClaimable('0x81594c5e9a73e195c6fb13db1b25e9388407611ad4649b01f61d85c27eb86049');
+ const isDepositClaimable = await hermezClient.isDepositClaimable('0x578478b8c287b3f53795291200a9500e0c5e8644b7624cb4bc16cc45c4e00b1f');
console.log('isDepositClaimable', isDepositClaimable);
expect(isDepositClaimable).to.be.an('boolean').equal(true);
})
// IS WITHDRAW EXITABLE
it('is Withdraw Exitable', async () => {
- const isWithdrawExitable = await hermezClient.isWithdrawExitable('0x03fa162d2a5babcfe0c4d825aab60da0d4fb526d5ca7ae2bfc980bf7ceaf4c9e');
+ const isWithdrawExitable = await hermezClient.isWithdrawExitable('0x062cee7145c9fc6b815ac475949c95d531c3ce49988701af07edd79e994bd400');
console.log('isWithdrawExitable', isWithdrawExitable);
expect(isWithdrawExitable).to.be.an('boolean').equal(true);
})
// IS DEPOSITED
it('is Deposited', async () => {
- const isDeposited = await hermezClient.isDeposited('0x81594c5e9a73e195c6fb13db1b25e9388407611ad4649b01f61d85c27eb86049');
+ const isDeposited = await hermezClient.isDeposited('0x1c1b7c1faedcd38c7abd193392f86b1012642e6d5fb942b4760a0e14908377ec');
console.log('isDeposited', isDeposited);
expect(isDeposited).to.be.an('boolean').equal(true);
})
// IS EXITED
it('is Exited', async () => {
- const isExited = await hermezClient.isExited('0x03fa162d2a5babcfe0c4d825aab60da0d4fb526d5ca7ae2bfc980bf7ceaf4c9e');
+ const isExited = await hermezClient.isExited('0x062cee7145c9fc6b815ac475949c95d531c3ce49988701af07edd79e994bd400');
console.log('isExited', isExited);
- expect(isExited).to.be.an('boolean').equal(true);
+ expect(isExited).to.be.an('boolean').equal(false);
})
// TRANSFER
@@ -157,9 +156,7 @@ describe('ERC20', () => {
});
expect(result).to.have.not.property('maxFeePerGas')
expect(result).to.have.not.property('maxPriorityFeePerGas')
- // expect(result).to.have.property('gasPrice')
- // expect(result['gasPrice']).to.be.an('number').gt(0);
- expect(result).to.have.property('chainId', 1402);
+ expect(result).to.have.property('chainId', 1422);
expect(result['chainId']).to.be.an('number');
});
@@ -233,7 +230,7 @@ describe('ERC20', () => {
returnTransaction: true
});
- const bridge = await abiManager.getConfig("Main.Contracts.BridgeProxy")
+ const bridge = await abiManager.getConfig("Main.Contracts.PolygonZkEVMBridgeProxy")
expect(result['to'].toLowerCase()).equal(bridge.toLowerCase());
expect(Number(result['value'])).eq(10);
expect(result).to.have.property('data');
@@ -244,7 +241,7 @@ describe('ERC20', () => {
returnTransaction: true
});
- const bridge = await abiManager.getConfig("Main.Contracts.BridgeProxy")
+ const bridge = await abiManager.getConfig("Main.Contracts.PolygonZkEVMBridgeProxy")
expect(result['to'].toLowerCase()).equal(bridge.toLowerCase());
expect(result).to.have.property('data');
});
@@ -254,17 +251,16 @@ describe('ERC20', () => {
returnTransaction: true
});
- const bridge = await abiManager.getConfig("Main.Contracts.BridgeProxy")
+ const bridge = await abiManager.getConfig("Main.Contracts.PolygonZkEVMBridgeProxy")
expect(result['to'].toLowerCase()).equal(bridge.toLowerCase());
expect(result).to.have.property('data');
});
it('claim erc20 deposit return tx', async () => {
- const result = await erc20Child.depositClaim('0x067ed611aa63d607186dcc0d70a7b60dd909c6d91b40842f424a6dadeae21f22', {
+ const result = await erc20Child.depositClaim('0x578478b8c287b3f53795291200a9500e0c5e8644b7624cb4bc16cc45c4e00b1f', {
returnTransaction: true
});
-
- const bridge = await abiManager.getConfig("zkEVM.Contracts.Bridge")
+ const bridge = await abiManager.getConfig("zkEVM.Contracts.PolygonZkEVMBridge")
expect(result['to'].toLowerCase()).equal(bridge.toLowerCase());
expect(result).to.have.property('data');
});
@@ -275,7 +271,7 @@ describe('ERC20', () => {
returnTransaction: true
});
- const bridge = await abiManager.getConfig("zkEVM.Contracts.Bridge")
+ const bridge = await abiManager.getConfig("zkEVM.Contracts.PolygonZkEVMBridge")
expect(result['to'].toLowerCase()).equal(bridge.toLowerCase());
expect(result).to.have.property('data');
});
@@ -285,17 +281,17 @@ describe('ERC20', () => {
returnTransaction: true
});
- const bridge = await abiManager.getConfig("zkEVM.Contracts.Bridge")
+ const bridge = await abiManager.getConfig("zkEVM.Contracts.PolygonZkEVMBridge")
expect(result['to'].toLowerCase()).equal(bridge.toLowerCase());
expect(Number(result['value'])).eq(1);
expect(result).to.have.property('data');
});
it('exit return tx', async () => {
- const result = await erc20Parent.withdrawExit('0x2df7caedb9a28b3110a43d5380c19d8f7d3a177aad4c8c11a07cbc46ce377654', {
+ const result = await erc20Parent.withdrawExit('0x062cee7145c9fc6b815ac475949c95d531c3ce49988701af07edd79e994bd400', {
returnTransaction: true
});
- const bridge = await abiManager.getConfig("Main.Contracts.BridgeProxy")
+ const bridge = await abiManager.getConfig("Main.Contracts.PolygonZkEVMBridgeProxy")
expect(result['to'].toLowerCase()).equal(bridge.toLowerCase());
expect(result).to.have.property('data');
});

chg: according to mango chain