Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add privado Blockchain #39

Merged
merged 2 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.3.2",
"version": "1.4.0",
"description": "Low level API to create and manipulate iden3 Claims.",
"source": "./src/index.ts",
"types": "dist/types/index.d.ts",
Expand Down
9 changes: 7 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const Blockchain: { [k: string]: string } = {
Ethereum: 'eth',
Polygon: 'polygon',
ZkEVM: 'zkevm',
Privado: 'privado',
Unknown: 'unknown',
NoChain: '',
ReadOnly: 'readonly'
Expand Down Expand Up @@ -80,7 +81,9 @@ export const ChainIds: { [key: string]: number } = {
[`${Blockchain.Polygon}:${NetworkId.Mumbai}`]: 80001,
[`${Blockchain.Polygon}:${NetworkId.Amoy}`]: 80002,
[`${Blockchain.ZkEVM}:${NetworkId.Main}`]: 1101,
[`${Blockchain.ZkEVM}:${NetworkId.Test}`]: 1442
[`${Blockchain.ZkEVM}:${NetworkId.Test}`]: 1442,
[`${Blockchain.Privado}:${NetworkId.Main}`]: 21000,
[`${Blockchain.Privado}:${NetworkId.Test}`]: 21001
};

export const DidMethodByte: { [key: string]: number } = {
Expand All @@ -98,7 +101,9 @@ const blockchainNetworkMap = {
[`${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.ZkEVM}:${NetworkId.Test}`]: 0b0011_0000 | 0b0000_0010,
[`${Blockchain.Privado}:${NetworkId.Main}`]: 0b1010_0000 | 0b0000_0001,
[`${Blockchain.Privado}:${NetworkId.Test}`]: 0b1010_0000 | 0b0000_0010
};

// DIDMethodNetwork is map for did methods and their blockchain networks
Expand Down
16 changes: 15 additions & 1 deletion tests/did.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ describe('DID tests', () => {
expect(stringify).toBe(`{"field1":"${field1Val}","did":"${didStr}"}`);
});

describe('TestDID_PolygonID_Types', () => {
describe('Test DID build from types', () => {
const testCases = [
{
title: 'Polygon no chain, no network',
Expand Down Expand Up @@ -152,6 +152,20 @@ describe('DID tests', () => {
chain: Blockchain.Polygon,
net: NetworkId.Amoy,
wantDID: 'did:polygonid:polygon:amoy:2qQ68JkRcf3xrHPQPWZei3YeVzHPP58wYNxx2mEouR'
},
{
title: 'Privado chain, Main',
method: DidMethod.Iden3,
chain: Blockchain.Privado,
net: NetworkId.Main,
wantDID: 'did:iden3:privado:main:2SZDsdYordSGMMQVXTVbCb7W834NBTBpkKZUAFRoGb'
},
{
title: 'Privado chain, Test',
method: DidMethod.Iden3,
chain: Blockchain.Privado,
net: NetworkId.Test,
wantDID: 'did:iden3:privado:test:2Skqvp4vnSFtq5bgAXbDs1Fs4AA5QGpRut9mCDew5R'
}
];

Expand Down