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

fix: missing provider error in ethrDid.setAttribute #135

Merged
merged 1 commit into from
Jan 24, 2025

Conversation

humuhimi
Copy link
Contributor

@humuhimi humuhimi commented Jan 4, 2025

Description of Changes

In the EthrDID class constructor, when the following code executes:

if (conf.privateKey && typeof txSigner === 'undefined') {
    txSigner = new Wallet(conf.privateKey);
}

it causes an error if no provider is set. The issue occurs in node_modules\ethers\src.ts\providers\abstract-signer.ts at:

function checkProvider(signer: AbstractSigner, operation: string): Provider {
    if (signer.provider) { return signer.provider; }
    assert(false, "missing provider", "UNSUPPORTED_OPERATION", { operation });
}

Error Message:

Error: missing provider (operation="sendTransaction", code=UNSUPPORTED_OPERATION, version=abstract-signer/5.5.0)
reason: 'missing provider',
code: 'UNSUPPORTED_OPERATION',
operation: 'sendTransaction'

Fix:

The issue was resolved by modifying the txSigner initialization to include the provider:

txSigner = new Wallet(conf.privateKey, conf.provider || conf.web3?.currentProvider);

This ensures a valid provider is passed, preventing the error.

Related Issue

fixes #81

Copy link
Contributor

@mirceanis mirceanis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Thank you for the contribution!

@mirceanis mirceanis changed the title resolve missing provider error in ethrDid.setAttribute fix: missing provider error in ethrDid.setAttribute Jan 24, 2025
@mirceanis mirceanis merged commit a83bfcf into uport-project:master Jan 24, 2025
1 check failed
uport-automation-bot pushed a commit that referenced this pull request Jan 24, 2025
## [3.0.23](3.0.22...3.0.23) (2025-01-24)

### Bug Fixes

* missing provider error in ethrDid.setAttribute ([#135](#135)) ([a83bfcf](a83bfcf)), closes [#81](#81)
@uport-automation-bot
Copy link
Collaborator

🎉 This PR is included in version 3.0.23 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ERROR] "Missing provider" when calling ethrDid.setAttribute
3 participants