Skip to content

Commit

Permalink
Merge pull request #42 from iden3/fix/zkevm-cardona
Browse files Browse the repository at this point in the history
Fix zkEVM blockchains and add Linea blockchains
  • Loading branch information
daveroga authored Sep 16, 2024
2 parents 47e5763 + b7950a9 commit ccf6422
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
20 changes: 13 additions & 7 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -58,6 +58,8 @@ export const NetworkId: { [k: string]: string } = {
Amoy: 'amoy',
Goerli: 'goerli',
Sepolia: 'sepolia',
Zkevm: 'zkevm',
Cardona: 'cardona',

Check warning on line 62 in src/constants.ts

View workflow job for this annotation

GitHub Actions / build

Unknown word: "Cardona"

Check warning on line 62 in src/constants.ts

View workflow job for this annotation

GitHub Actions / build

Unknown word: "cardona"

Check warning on line 62 in src/constants.ts

View workflow job for this annotation

GitHub Actions / build

Unknown word: "Cardona"

Check warning on line 62 in src/constants.ts

View workflow job for this annotation

GitHub Actions / build

Unknown word: "cardona"

Check warning on line 62 in src/constants.ts

View workflow job for this annotation

GitHub Actions / build

Unknown word: "Cardona"

Check warning on line 62 in src/constants.ts

View workflow job for this annotation

GitHub Actions / build

Unknown word: "cardona"
Test: 'test',
Unknown: 'unknown',
NoNetwork: ''
Expand All @@ -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,

Check warning on line 86 in src/constants.ts

View workflow job for this annotation

GitHub Actions / build

Unknown word: "Cardona"

Check warning on line 86 in src/constants.ts

View workflow job for this annotation

GitHub Actions / build

Unknown word: "Cardona"

Check warning on line 86 in src/constants.ts

View workflow job for this annotation

GitHub Actions / build

Unknown word: "Cardona"
[`${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 } = {
Expand All @@ -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,

Check warning on line 105 in src/constants.ts

View workflow job for this annotation

GitHub Actions / build

Unknown word: "Cardona"

Check warning on line 105 in src/constants.ts

View workflow job for this annotation

GitHub Actions / build

Unknown word: "Cardona"

Check warning on line 105 in src/constants.ts

View workflow job for this annotation

GitHub Actions / build

Unknown word: "Cardona"
[`${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
Expand Down
26 changes: 20 additions & 6 deletions tests/did.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Check warning on line 147 in tests/did.test.ts

View workflow job for this annotation

GitHub Actions / build

Unknown word: "cardona"

Check warning on line 147 in tests/did.test.ts

View workflow job for this annotation

GitHub Actions / build

Unknown word: "cardona"

Check warning on line 147 in tests/did.test.ts

View workflow job for this annotation

GitHub Actions / build

Unknown word: "cardona"
},
{
title: 'Polygon chain, Amoy',
Expand All @@ -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'
}
];

Expand Down

0 comments on commit ccf6422

Please sign in to comment.