+
Skip to content
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
16 changes: 14 additions & 2 deletions did.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ const (
Ethereum Blockchain = "eth"
// Polygon is polygon blockchain network
Polygon Blockchain = "polygon"
// ZkEVM is zkEVM blockchain network
ZkEVM Blockchain = "zkevm"
// 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 All @@ -58,18 +60,22 @@ const (
type NetworkID string

const (
// Main is ethereum main network
// Main is main network
Main NetworkID = "main"

// Mumbai is polygon mumbai test network
Mumbai NetworkID = "mumbai"

// Goerli is ethereum goerli test network
Goerli NetworkID = "goerli" // goerli
// Sepolia is ethereum Sepolia test network
Sepolia NetworkID = "sepolia"

// Test is test network
Test NetworkID = "test"

// UnknownNetwork is used when it's not possible to retrieve network from identifier
UnknownNetwork NetworkID = "unknown"

// NoNetwork should be used for readonly identity to build readonly flag
NoNetwork NetworkID = ""
)
Expand Down Expand Up @@ -98,6 +104,9 @@ var DIDMethodNetwork = map[DIDMethod]map[DIDNetworkFlag]byte{
{Blockchain: Ethereum, NetworkID: Main}: 0b00100000 | 0b00000001,
{Blockchain: Ethereum, NetworkID: Goerli}: 0b00100000 | 0b00000010,
{Blockchain: Ethereum, NetworkID: Sepolia}: 0b00100000 | 0b00000011,

{Blockchain: ZkEVM, NetworkID: Main}: 0b00110000 | 0b00000001,
{Blockchain: ZkEVM, NetworkID: Test}: 0b00110000 | 0b00000010,
},
DIDMethodPolygonID: {
{Blockchain: ReadOnly, NetworkID: NoNetwork}: 0b00000000,
Expand All @@ -108,6 +117,9 @@ var DIDMethodNetwork = map[DIDMethod]map[DIDNetworkFlag]byte{
{Blockchain: Ethereum, NetworkID: Main}: 0b00100000 | 0b00000001,
{Blockchain: Ethereum, NetworkID: Goerli}: 0b00100000 | 0b00000010,
{Blockchain: Ethereum, NetworkID: Sepolia}: 0b00100000 | 0b00000011,

{Blockchain: ZkEVM, NetworkID: Main}: 0b00110000 | 0b00000001,
{Blockchain: ZkEVM, NetworkID: Test}: 0b00110000 | 0b00000010,
},
DIDMethodOther: {
{Blockchain: UnknownChain, NetworkID: UnknownNetwork}: 0b11111111,
Expand Down
14 changes: 14 additions & 0 deletions did_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,20 @@ func TestDID_PolygonID_Types(t *testing.T) {
net: Mumbai,
wantDID: "did:polygonid:polygon:mumbai:2qCU58EJgrELNZCDkSU23dQHZsBgAFWLNpNezo1g6b",
},
{
title: "Polygon | zkEVM chain, main",
method: DIDMethodPolygonID,
chain: ZkEVM,
net: Main,
wantDID: "did:polygonid:zkevm:main:2wQjmkL1SsgqC7AuZdUcaXsUVfEi1i58VEhm3r2r8F",
},
{
title: "Polygon | zkEVM chain, test",
method: DIDMethodPolygonID,
chain: ZkEVM,
net: Test,
wantDID: "did:polygonid:zkevm:test:2wcMpvr8NgWTfqN6ChaFEx1qRnLREXhjeoJ45pFyw5",
},
}

for i := range testCases {
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载