diff --git a/package.json b/package.json index ba1c0a3..e4c301a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@iden3/js-iden3-core", - "version": "1.4.0", + "version": "1.4.1", "description": "Low level API to create and manipulate iden3 Claims.", "source": "./src/index.ts", "types": "dist/types/index.d.ts", diff --git a/src/constants.ts b/src/constants.ts index 5894551..d39e2f0 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -45,8 +45,8 @@ export const Constants = Object.freeze({ export const Blockchain: { [k: string]: string } = { Ethereum: 'eth', Polygon: 'polygon', - ZkEVM: 'zkevm', Privado: 'privado', + Linea: 'linea', Unknown: 'unknown', NoChain: '', ReadOnly: 'readonly' @@ -58,6 +58,8 @@ export const NetworkId: { [k: string]: string } = { Amoy: 'amoy', Goerli: 'goerli', Sepolia: 'sepolia', + Zkevm: 'zkevm', + Cardona: 'cardona', Test: 'test', Unknown: 'unknown', NoNetwork: '' @@ -80,10 +82,12 @@ export const ChainIds: { [key: string]: number } = { [`${Blockchain.Polygon}:${NetworkId.Main}`]: 137, [`${Blockchain.Polygon}:${NetworkId.Mumbai}`]: 80001, [`${Blockchain.Polygon}:${NetworkId.Amoy}`]: 80002, - [`${Blockchain.ZkEVM}:${NetworkId.Main}`]: 1101, - [`${Blockchain.ZkEVM}:${NetworkId.Test}`]: 1442, + [`${Blockchain.Polygon}:${NetworkId.Zkevm}`]: 1101, + [`${Blockchain.Polygon}:${NetworkId.Cardona}`]: 2442, [`${Blockchain.Privado}:${NetworkId.Main}`]: 21000, - [`${Blockchain.Privado}:${NetworkId.Test}`]: 21001 + [`${Blockchain.Privado}:${NetworkId.Test}`]: 21001, + [`${Blockchain.Linea}:${NetworkId.Main}`]: 59144, + [`${Blockchain.Linea}:${NetworkId.Sepolia}`]: 59141 }; export const DidMethodByte: { [key: string]: number } = { @@ -97,13 +101,15 @@ const blockchainNetworkMap = { [`${Blockchain.Polygon}:${NetworkId.Main}`]: 0b0001_0000 | 0b0000_0001, [`${Blockchain.Polygon}:${NetworkId.Mumbai}`]: 0b0001_0000 | 0b0000_0010, [`${Blockchain.Polygon}:${NetworkId.Amoy}`]: 0b0001_0000 | 0b0000_0011, + [`${Blockchain.Polygon}:${NetworkId.Zkevm}`]: 0b0001_0000 | 0b0000_0100, + [`${Blockchain.Polygon}:${NetworkId.Cardona}`]: 0b0001_0000 | 0b0000_0101, [`${Blockchain.Ethereum}:${NetworkId.Main}`]: 0b0010_0000 | 0b0000_0001, [`${Blockchain.Ethereum}:${NetworkId.Goerli}`]: 0b0010_0000 | 0b0000_0010, [`${Blockchain.Ethereum}:${NetworkId.Sepolia}`]: 0b0010_0000 | 0b0000_0011, - [`${Blockchain.ZkEVM}:${NetworkId.Main}`]: 0b0011_0000 | 0b0000_0001, - [`${Blockchain.ZkEVM}:${NetworkId.Test}`]: 0b0011_0000 | 0b0000_0010, [`${Blockchain.Privado}:${NetworkId.Main}`]: 0b1010_0000 | 0b0000_0001, - [`${Blockchain.Privado}:${NetworkId.Test}`]: 0b1010_0000 | 0b0000_0010 + [`${Blockchain.Privado}:${NetworkId.Test}`]: 0b1010_0000 | 0b0000_0010, + [`${Blockchain.Linea}:${NetworkId.Main}`]: 0b0100_0000 | 0b0000_1001, + [`${Blockchain.Linea}:${NetworkId.Sepolia}`]: 0b0100_0000 | 0b0000_1000 }; // DIDMethodNetwork is map for did methods and their blockchain networks diff --git a/tests/did.test.ts b/tests/did.test.ts index 3852f78..bb69aa9 100644 --- a/tests/did.test.ts +++ b/tests/did.test.ts @@ -135,16 +135,16 @@ describe('DID tests', () => { { title: 'Polygon | zkEVM chain, main', method: DidMethod.PolygonId, - chain: Blockchain.ZkEVM, - net: NetworkId.Main, - wantDID: 'did:polygonid:zkevm:main:2wQjmkL1SsgqC7AuZdUcaXsUVfEi1i58VEhm3r2r8F' + chain: Blockchain.Polygon, + net: NetworkId.Zkevm, + wantDID: 'did:polygonid:polygon:zkevm:2qbiBVGYYTsbL1ab2afHNTh1S7P6btmYhwZF4jTwiF' }, { title: 'Polygon | zkEVM chain, test', method: DidMethod.PolygonId, - chain: Blockchain.ZkEVM, - net: NetworkId.Test, - wantDID: 'did:polygonid:zkevm:test:2wcMpvr8NgWTfqN6ChaFEx1qRnLREXhjeoJ45pFyw5' + chain: Blockchain.Polygon, + net: NetworkId.Cardona, + wantDID: 'did:polygonid:polygon:cardona:2qoLEfnfUGhDojmmfekv2sqNNEUopiQ9sW9Y6hh5X5' }, { title: 'Polygon chain, Amoy', @@ -166,6 +166,20 @@ describe('DID tests', () => { chain: Blockchain.Privado, net: NetworkId.Test, wantDID: 'did:iden3:privado:test:2Skqvp4vnSFtq5bgAXbDs1Fs4AA5QGpRut9mCDew5R' + }, + { + title: 'Linea chain, Main', + method: DidMethod.Iden3, + chain: Blockchain.Linea, + net: NetworkId.Main, + wantDID: 'did:iden3:linea:main:28vX3frJDbAvHLSMHEwxuxRk1GPpjBeUEsXdAwVxDm' + }, + { + title: 'Linea chain, Test', + method: DidMethod.Iden3, + chain: Blockchain.Linea, + net: NetworkId.Sepolia, + wantDID: 'did:iden3:linea:sepolia:28itzVLBHnMHocFAeArLFYHP59J7WN1s5JwL8yGpQw' } ];