feat(insurance): integrate external insurance providers (#250)#412
Merged
LaGodxy merged 2 commits intoMettaChain:mainfrom Apr 29, 2026
Merged
Conversation
Implement on-chain registry and hybrid coverage request flow for connecting PropChain policies to traditional insurance companies. Changes: - types.rs: CoverageRequestStatus (Pending/Confirmed/Declined/Cancelled), ExternalProvider (id, name, api_endpoint, supported_coverage_types, is_active), ExternalCoverageRequest (request + provider response fields) - errors.rs: ProviderNotFound, ProviderInactive, CoverageRequestNotFound, CoverageRequestNotPending, UnsupportedCoverageType - lib.rs: storage fields, ProviderRegistered/CoverageRequested/ CoverageResponseRecorded events, and messages: register_external_provider, deactivate_external_provider, request_external_coverage, record_coverage_response, cancel_coverage_request, get_external_provider, get_coverage_request, get_policy_coverage_requests, get_provider_count - tests.rs: 13 unit tests covering registration, deactivation, request creation, response recording (confirm/decline), cancellation, and all error paths Closes MettaChain#250
|
@Nuel-ship-it Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements an on-chain registry and hybrid coverage request flow that connects PropChain policies to traditional (off-chain) insurance companies.
Design
Because smart contracts cannot make outbound HTTP calls, the integration uses a relayer pattern:
record_coverage_responseThis keeps the contract trustless (only authorized oracles/admin can record responses) while enabling real-world API connectivity.
Changes
contracts/insurance/src/types.rsCoverageRequestStatus:Pending/Confirmed/Declined/CancelledExternalProvider: id, name, api_endpoint, supported_coverage_types, is_active, registered_atExternalCoverageRequest: request details + provider quote, reference, and response timestampcontracts/insurance/src/errors.rsProviderNotFound,ProviderInactive,CoverageRequestNotFound,CoverageRequestNotPending,UnsupportedCoverageTypecontracts/insurance/src/lib.rsStorage, events, and messages:
register_external_providerdeactivate_external_providerrequest_external_coveragerecord_coverage_responsecancel_coverage_requestget_external_providerget_coverage_requestget_policy_coverage_requestsget_provider_countcontracts/insurance/src/tests.rs13 unit tests covering: registration (happy path, unauthorized), deactivation, coverage requests (happy path, non-policyholder, inactive provider, unsupported type), response recording (confirmed, declined, unauthorized, duplicate), cancellation (happy path, non-requester), and authorized oracle recording.
Closes #250