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 Amoy network as a part of a core library #461

Merged
merged 1 commit into from
Apr 1, 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
1 change: 1 addition & 0 deletions chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ var chainIDs = map[chainIDKey]ChainID{
{Ethereum, Sepolia}: 11155111,
{Polygon, Main}: 137,
{Polygon, Mumbai}: 80001,
{Polygon, Amoy}: 80002,
{ZkEVM, Main}: 1101,
{ZkEVM, Test}: 1442,
}
Expand Down
44 changes: 19 additions & 25 deletions did.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ const (
Main NetworkID = "main"
// Mumbai is polygon mumbai test network
Mumbai NetworkID = "mumbai"
// Amoy is polygon amoy test network
Amoy NetworkID = "amoy"
// Goerli is ethereum goerli test network
Goerli NetworkID = "goerli" // goerli
// Sepolia is ethereum Sepolia test network
Expand All @@ -119,6 +121,7 @@ const (
var networks = map[NetworkID]NetworkID{
Main: Main,
Mumbai: Mumbai,
Amoy: Amoy,
Goerli: Goerli,
Sepolia: Sepolia,
Test: Test,
Expand Down Expand Up @@ -179,36 +182,27 @@ type DIDNetworkFlag struct {
NetworkID NetworkID
}

// DIDMethodNetwork is map for did methods and their blockchain networks
var DIDMethodNetwork = map[DIDMethod]map[DIDNetworkFlag]byte{
DIDMethodIden3: {
{Blockchain: ReadOnly, NetworkID: NoNetwork}: 0b00000000,

{Blockchain: Polygon, NetworkID: Main}: 0b00010000 | 0b00000001,
{Blockchain: Polygon, NetworkID: Mumbai}: 0b00010000 | 0b00000010,
var blockchainNetworkMap = map[DIDNetworkFlag]byte{
{Blockchain: ReadOnly, NetworkID: NoNetwork}: 0b0000_0000,

{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,
{Blockchain: Polygon, NetworkID: Main}: 0b0001_0000 | 0b0000_0001,
{Blockchain: Polygon, NetworkID: Mumbai}: 0b0001_0000 | 0b0000_0010,
{Blockchain: Polygon, NetworkID: Amoy}: 0b0001_0000 | 0b0000_0011,

{Blockchain: Polygon, NetworkID: Main}: 0b00010000 | 0b00000001,
{Blockchain: Polygon, NetworkID: Mumbai}: 0b00010000 | 0b00000010,
{Blockchain: Ethereum, NetworkID: Main}: 0b0010_0000 | 0b0000_0001,
{Blockchain: Ethereum, NetworkID: Goerli}: 0b0010_0000 | 0b0000_0010,
{Blockchain: Ethereum, NetworkID: Sepolia}: 0b0010_0000 | 0b0000_0011,

{Blockchain: Ethereum, NetworkID: Main}: 0b00100000 | 0b00000001,
{Blockchain: Ethereum, NetworkID: Goerli}: 0b00100000 | 0b00000010,
{Blockchain: Ethereum, NetworkID: Sepolia}: 0b00100000 | 0b00000011,
{Blockchain: ZkEVM, NetworkID: Main}: 0b0011_0000 | 0b0000_0001,
{Blockchain: ZkEVM, NetworkID: Test}: 0b0011_0000 | 0b0000_0010,
}

{Blockchain: ZkEVM, NetworkID: Main}: 0b00110000 | 0b00000001,
{Blockchain: ZkEVM, NetworkID: Test}: 0b00110000 | 0b00000010,
},
// DIDMethodNetwork is map for did methods and their blockchain networks
var DIDMethodNetwork = map[DIDMethod]map[DIDNetworkFlag]byte{
DIDMethodIden3: blockchainNetworkMap,
DIDMethodPolygonID: blockchainNetworkMap,
DIDMethodOther: {
{Blockchain: UnknownChain, NetworkID: UnknownNetwork}: 0b11111111,
{Blockchain: UnknownChain, NetworkID: UnknownNetwork}: 0b1111_1111,
},
}

Expand Down
7 changes: 7 additions & 0 deletions did_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,13 @@ func TestDID_PolygonID_Types(t *testing.T) {
net: Mumbai,
wantDID: "did:polygonid:polygon:mumbai:2qCU58EJgrELNZCDkSU23dQHZsBgAFWLNpNezo1g6b",
},
{
title: "Polygon | Polygon chain, Amoy",
method: DIDMethodPolygonID,
chain: Polygon,
net: Amoy,
wantDID: "did:polygonid:polygon:amoy:2qQ68JkRcf3xrHPQPWZei3YeVzHPP58wYNxx2mEouR",
},
{
title: "Polygon | zkEVM chain, main",
method: DIDMethodPolygonID,
Expand Down
Loading