-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #625 from 0xPolygonID/chore_check_errors_when_regi…
…stering_networks chore: Check error when registering custom did methods.
- Loading branch information
Showing
4 changed files
with
25 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,27 @@ | ||
package services | ||
|
||
import ( | ||
"context" | ||
|
||
core "github.com/iden3/go-iden3-core/v2" | ||
|
||
"github.com/polygonid/sh-id-platform/internal/config" | ||
"github.com/polygonid/sh-id-platform/internal/log" | ||
) | ||
|
||
// RegisterCustomDIDMethods registers custom DID methods | ||
func RegisterCustomDIDMethods(customdDids []config.CustomDIDMethods) { | ||
for _, cdid := range customdDids { | ||
func RegisterCustomDIDMethods(ctx context.Context, customsDis []config.CustomDIDMethods) error { | ||
for _, cdid := range customsDis { | ||
params := core.DIDMethodNetworkParams{ | ||
Method: core.DIDMethodPolygonID, | ||
Blockchain: core.Blockchain(cdid.Blockchain), | ||
Network: core.NetworkID(cdid.Network), | ||
NetworkFlag: cdid.NetworkFlag, | ||
} | ||
core.RegisterDIDMethodNetwork(params, core.WithChainID(cdid.ChainID)) | ||
if err := core.RegisterDIDMethodNetwork(params, core.WithChainID(cdid.ChainID)); err != nil { | ||
log.Error(ctx, "cannot register custom DID method", "err", err, "customDID", cdid) | ||
return err | ||
} | ||
} | ||
return nil | ||
} |