Skip to content

Commit

Permalink
Add Linea to supported blockchains. Add ChainIDs for Polygon zkEVM an…
Browse files Browse the repository at this point in the history
…d Linea. Added parse tests for IDs on these new networks
  • Loading branch information
OBrezhniev committed Sep 11, 2024
1 parent edec342 commit 16aecb6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
4 changes: 4 additions & 0 deletions chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,14 @@ var chainIDs = map[chainIDKey]ChainID{
{Polygon, Main}: 137,
{Polygon, Mumbai}: 80001,
{Polygon, Amoy}: 80002,
{Polygon, Zkevm}: 1101,
{Polygon, Cardona}: 1442,
{ZkEVM, Main}: 1101,
{ZkEVM, Test}: 1442,
{Privado, Main}: 21000,
{Privado, Test}: 21001,
{Linea, Main}: 59144,
{Linea, Sepolia}: 59141,
}

// ChainIDfromDID returns chain name from w3c.DID
Expand Down
5 changes: 5 additions & 0 deletions did.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ const (
ZkEVM Blockchain = "zkevm"
// Privado is Privado blockchain network
Privado Blockchain = "privado"
// Linea is Linea blockchain network
Linea Blockchain = "linea"
// UnknownChain is used when it's not possible to retrieve blockchain type from identifier
UnknownChain Blockchain = "unknown"
// ReadOnly should be used for readonly identity to build readonly flag
Expand Down Expand Up @@ -220,6 +222,9 @@ var blockchainNetworkMap = map[DIDNetworkFlag]byte{

{Blockchain: Privado, NetworkID: Main}: 0b1010_0000 | 0b0000_0001,
{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
28 changes: 28 additions & 0 deletions did_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,20 @@ func TestDID_Build_From_Types(t *testing.T) {
net: Test,
wantDID: "did:polygonid:zkevm:test:2wcMpvr8NgWTfqN6ChaFEx1qRnLREXhjeoJ45pFyw5",
},
{
title: "Iden3 | Polygon chain, zkEVM chain, main",
method: DIDMethodIden3,
chain: Polygon,
net: Zkevm,
wantDID: "did:iden3:polygon:zkevm:xJa94Ky3oeawnDdQVoTotncYnBA1fCLW6C4NZVpRu",
},
{
title: "Iden3 | Polygon chain, zkEVM Cardona test",
method: DIDMethodIden3,
chain: Polygon,
net: Cardona,
wantDID: "did:iden3:polygon:cardona:xWCCEr5ycUDRWQp3Zu6UJvyUuGsEUpwfenMQXixEj",
},
{
title: "Iden3 | Privado chain, main",
method: DIDMethodIden3,
Expand All @@ -215,6 +229,20 @@ func TestDID_Build_From_Types(t *testing.T) {
net: Test,
wantDID: "did:iden3:privado:test:2Skqvp4vnSFtq5bgAXbDs1Fs4AA5QGpRut9mCDew5R",
},
{
title: "Iden3 | Linea, Main",
method: DIDMethodIden3,
chain: Linea,
net: Main,
wantDID: "did:iden3:linea:main:28vX3frJDbAvHLSMHEwxuxRk1GPpjBeUEsXdAwVxDm",
},
{
title: "Iden3 | Linea, Sepolia",
method: DIDMethodIden3,
chain: Linea,
net: Sepolia,
wantDID: "did:iden3:linea:sepolia:28itzVLBHnMHocFAeArLFYHP59J7WN1s5JwL8yGpQw",
},
}

for i := range testCases {
Expand Down

0 comments on commit 16aecb6

Please sign in to comment.