Skip to content
Open
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
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.7.0",
"version": "1.8.0",
"description": "Low level API to create and manipulate iden3 Claims.",
"source": "./src/index.ts",
"exports": {
Expand Down
16 changes: 14 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const Blockchain: { [k: string]: string } = {
Privado: 'privado',
Billions: 'billions',
Linea: 'linea',
Redbelly: 'redbelly',
Unknown: 'unknown',
NoChain: '',
ReadOnly: 'readonly'
Expand All @@ -62,13 +63,16 @@ export const NetworkId: { [k: string]: string } = {
Zkevm: 'zkevm',
Cardona: 'cardona',
Test: 'test',
Mainnet: 'mainnet',
Testnet: 'testnet',
Unknown: 'unknown',
NoNetwork: ''
};

export const DidMethod: { [k: string]: string } = {
Iden3: 'iden3',
PolygonId: 'polygonid',
Receptor: 'receptor',
Other: ''
};

Expand All @@ -90,12 +94,15 @@ export const ChainIds: { [key: string]: number } = {
[`${Blockchain.Linea}:${NetworkId.Main}`]: 59144,
[`${Blockchain.Linea}:${NetworkId.Sepolia}`]: 59141,
[`${Blockchain.Billions}:${NetworkId.Main}`]: 45056,
[`${Blockchain.Billions}:${NetworkId.Test}`]: 6913
[`${Blockchain.Billions}:${NetworkId.Test}`]: 6913,
[`${Blockchain.Redbelly}:${NetworkId.Mainnet}`]: 151,
[`${Blockchain.Redbelly}:${NetworkId.Testnet}`]: 153
};

export const DidMethodByte: { [key: string]: number } = {
[DidMethod.Iden3]: 0b00000001,
[DidMethod.PolygonId]: 0b00000010,
[DidMethod.Receptor]: 0b10000011,
[DidMethod.Other]: 0b11111111
};

Expand All @@ -114,7 +121,9 @@ const blockchainNetworkMap = {
[`${Blockchain.Linea}:${NetworkId.Main}`]: 0b0100_0000 | 0b0000_1001,
[`${Blockchain.Linea}:${NetworkId.Sepolia}`]: 0b0100_0000 | 0b0000_1000,
[`${Blockchain.Billions}:${NetworkId.Main}`]: 0b1011_0000 | 0b0000_0001,
[`${Blockchain.Billions}:${NetworkId.Test}`]: 0b1011_0000 | 0b0000_0010
[`${Blockchain.Billions}:${NetworkId.Test}`]: 0b1011_0000 | 0b0000_0010,
[`${Blockchain.Redbelly}:${NetworkId.Mainnet}`]: 0b01010111,
[`${Blockchain.Redbelly}:${NetworkId.Testnet}`]: 0b10000011
};

// DIDMethodNetwork is map for did methods and their blockchain networks
Expand All @@ -127,6 +136,9 @@ export const DidMethodNetwork: {
[DidMethod.PolygonId]: {
...blockchainNetworkMap
},
[DidMethod.Receptor]: {
...blockchainNetworkMap
},
[DidMethod.Other]: {
[`${Blockchain.Unknown}:${NetworkId.Unknown}`]: 0b1111_1111
}
Expand Down
14 changes: 14 additions & 0 deletions tests/did.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,20 @@ describe('DID tests', () => {
chain: Blockchain.Linea,
net: NetworkId.Sepolia,
wantDID: 'did:iden3:linea:sepolia:28itzVLBHnMHocFAeArLFYHP59J7WN1s5JwL8yGpQw'
},
{
title: 'Receptor | Redbelly, mainnet',
method: DidMethod.Receptor,
chain: Blockchain.Redbelly,
net: NetworkId.Mainnet,
wantDID: 'did:receptor:redbelly:mainnet:31A9FG7T3SZpaoU7b77yRBXt682Y8Z6vK7PHhgrUAAB'
},
{
title: 'Receptor | Redbelly, testnet',
method: DidMethod.Receptor,
chain: Blockchain.Redbelly,
net: NetworkId.Testnet,
wantDID: 'did:receptor:redbelly:testnet:31Jxbg6JJG5xFqUbfEEFEKrDyBQsQHEgzN7JdBWRkCg'
}
];

Expand Down