Merge pull request #49 from iden3/PID-3587-add-base-networks

Add Base and BNB networks
This commit is contained in:
David Rodriguez
2025-11-24 13:27:45 +01:00
committed by GitHub
4 changed files with 44 additions and 6 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "@iden3/js-iden3-core",
"version": "1.7.1",
"version": "1.8.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@iden3/js-iden3-core",
"version": "1.7.1",
"version": "1.8.0",
"license": "MIT or Apache-2.0",
"devDependencies": {
"@cspell/eslint-plugin": "^8.14.2",

View File

@@ -1,6 +1,6 @@
{
"name": "@iden3/js-iden3-core",
"version": "1.7.1",
"version": "1.8.0",
"description": "Low level API to create and manipulate iden3 Claims.",
"source": "./src/index.ts",
"exports": {

View File

@@ -50,7 +50,9 @@ export const Blockchain: { [k: string]: string } = {
Linea: 'linea',
Unknown: 'unknown',
NoChain: '',
ReadOnly: 'readonly'
ReadOnly: 'readonly',
Base: 'base',
Bnb: 'bnb'
};
export const NetworkId: { [k: string]: string } = {
@@ -90,7 +92,11 @@ 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.Base}:${NetworkId.Main}`]: 8453,
[`${Blockchain.Base}:${NetworkId.Sepolia}`]: 84532,
[`${Blockchain.Bnb}:${NetworkId.Main}`]: 56,
[`${Blockchain.Bnb}:${NetworkId.Test}`]: 97
};
export const DidMethodByte: { [key: string]: number } = {
@@ -114,7 +120,11 @@ 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.Base}:${NetworkId.Main}`]: 0b0101_0000 | 0b0000_0001,
[`${Blockchain.Base}:${NetworkId.Sepolia}`]: 0b0101_0000 | 0b0000_0010,
[`${Blockchain.Bnb}:${NetworkId.Main}`]: 0b0110_0000 | 0b0000_0001,
[`${Blockchain.Bnb}:${NetworkId.Test}`]: 0b0110_0000 | 0b0000_0010
};
// DIDMethodNetwork is map for did methods and their blockchain networks

View File

@@ -194,6 +194,34 @@ describe('DID tests', () => {
chain: Blockchain.Linea,
net: NetworkId.Sepolia,
wantDID: 'did:iden3:linea:sepolia:28itzVLBHnMHocFAeArLFYHP59J7WN1s5JwL8yGpQw'
},
{
title: 'Base chain, Main',
method: DidMethod.Iden3,
chain: Blockchain.Base,
net: NetworkId.Main,
wantDID: 'did:iden3:base:main:2AXVV81Fe3jx79ypPoj2DHadUFBWVkhKZNFyShK2gP'
},
{
title: 'Base chain, Test',
method: DidMethod.Iden3,
chain: Blockchain.Base,
net: NetworkId.Sepolia,
wantDID: 'did:iden3:base:sepolia:2Aj7YJXNZrZaatB12speshizQNHDiaKvivrGUfYAVD'
},
{
title: 'Bnb chain, Main',
method: DidMethod.Iden3,
chain: Blockchain.Bnb,
net: NetworkId.Main,
wantDID: 'did:iden3:bnb:main:2DjSN2KAUxt1ko4kcwH8owtQQCkt2to2CMifzCwBbd'
},
{
title: 'Bnb chain, Test',
method: DidMethod.Iden3,
chain: Blockchain.Bnb,
net: NetworkId.Test,
wantDID: 'did:iden3:bnb:test:2Dw4RCqHQmheEXFwG1NmUN2mLKrbFiRdMvJy2BAKQT'
}
];