xclud / web3dart

Ethereum library, written in Dart.
https://pub.dev/packages/web3dart
MIT License
170 stars 94 forks source link

Feature Addition: EthrDID Constructors #114

Closed muhammadsaddamnur closed 11 months ago

muhammadsaddamnur commented 11 months ago

Description: This Pull Request introduces new features to the EthrDID class, enhancing its capabilities for creating Decentralized Identifiers (DIDs) for Ethereum-based identities (ref: https://github.com/uport-project/ethr-did). The changes include the addition of three new factory methods that allow the creation of EthrDID instances using different inputs:

  1. fromPublicKeyEncoded: This factory method allows the creation of an EthrDID instance from an encoded public key. It takes an EthPrivateKey object and a chainNameOrId as input. The method constructs the DID by combining the chain name or ID with the hexadecimal representation of the provided encoded public key.

  2. fromEthereumAddress: With this factory method, an EthrDID instance can be created directly from an Ethereum address. It takes an EthereumAddress object and a chainNameOrId as input. The method constructs the DID using the chain name or ID and the EIP-55 encoded representation of the Ethereum address.

  3. fromIdentifier: This factory method offers flexibility by allowing the creation of an EthrDID instance from a custom identifier. It takes a String identifier and a chainNameOrId as input. The method constructs the DID using the provided identifier along with the chain name or ID. Examples of identifiers include Ethereum addresses, public keys, or even a full did:ethr representing Identity.

The new constructors provide more options for developers to create EthrDID instances based on their specific requirements, making the class more versatile and adaptable to different use cases.

Thank you for considering this Pull Request. I have tested the changes thoroughly to ensure their correctness and compatibility with existing code. Please review the changes, and I am open to any feedback or suggestions to improve the implementation further.

Let me know if you have any questions or need additional information.