Skip to content

Integrate InviteSDK rewards flow into citizen claim widget#91

Draft
L03TJ3 with Copilot wants to merge 3 commits into
mainfrom
copilot/integrate-invite-sdk-into-widget
Draft

Integrate InviteSDK rewards flow into citizen claim widget#91
L03TJ3 with Copilot wants to merge 3 commits into
mainfrom
copilot/integrate-invite-sdk-into-widget

Conversation

Copilot AI commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Adds @goodsdks/invite-sdk@1.0.1 to the citizen claim widget and replaces the Invite Rewards placeholder with a provider-first, viem-backed invite lifecycle. Claim and Invite Rewards now share invite validation, joining, and refresh state without changing claim behavior.

  • Shared invite runtime

    • Initializes InviteSDK only for Celo/XDC and delegates reads, simulations, writes, error mapping, and collection to the SDK.
    • Loads invite user, level, invitees, pending invitees, and eligibility diagnostics.
    • Supports retryable loading, unsupported-network, disconnected, join, collection, and mutation-error states.
  • Invite code and joining

    • Implements GoodWallet’s Base58 shortest-unused-prefix algorithm using InviteSDK.resolveCode.
    • Validates unknown, self, and already-joined invite codes before joining.
    • Exposes the same pending-safe join action from both Claim and Invite Rewards.
  • Rewards experience

    • Adds reward education, verified-code creation, current-page sharing, pending/approved invitee status, diagnostics, and batch collection.
    • Shares the exact current page URL without host callback, route, or destination configuration.
const message =
  `Claim GoodDollar with me. Open this page and use my invite code: ${code}\n` +
  window.location.href
  • Coverage and documentation
    • Adds Invite Rewards tab smoke coverage and updated screenshot evidence.
    • Documents supported networks, environment behavior, sharing contract, code generation, and collection lifecycle.

Copilot AI linked an issue Jul 16, 2026 that may be closed by this pull request
12 tasks
Co-authored-by: L03TJ3 <6606028+L03TJ3@users.noreply.github.com>
Copilot AI changed the title [WIP] Integrate invite SDK into citizen-claim-widget Integrate InviteSDK rewards flow into citizen claim widget Jul 16, 2026
Copilot AI requested a review from L03TJ3 July 16, 2026 05:08
@L03TJ3

L03TJ3 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

@copilot

Please update the direct dependency to @goodsdks/invite-sdk@1.0.3 and refresh pnpm-lock.yaml.

Then wire only these two SDK capabilities. No broader Invite Rewards redesign, copy pass, or documentation work is needed in this follow-up.

  1. Deferred inviter attachment

The contract and InviteSDK 1.0.3 support this valid flow:

await sdk.join(myCode, zeroHash)     // personal code was registered earlier
await sdk.join(myCode, inviterCode)  // attach one valid inviter later

Update the widget so a user who already has user.inviteCode may still enter an inviter code when:

user.inviteCode !== zeroHash &&
user.invitedBy === zeroAddress &&
!user.bountyPaid

Use the existing user.inviteCode as myCode in sdk.join; only run generateInviteCode for a user with no code yet. Remove the widget-level joinedAt > 0n rejection and change the join-card visibility predicate to the rule above. Keep the SDK typed errors as the final guard.

Important protocol boundary: an ordinary UBI claim does not prevent this. A paid invite bounty or an already attached inviter does; show the normal SDK error in those cases.

  1. Pending invitees that can be collected

Use the new SDK helper in 1.0.3:

const collectableInvitees = await sdk.getCollectableInvitees(address)

Keep getPendingInvitees(address) for showing the full pending-address list. Store collectableInvitees in the invite runtime and enable "Collect eligible rewards" only when that array is non-empty. actions.collectAll can continue to call sdk.collectAllBounties(); the contract already safely skips pending invitees that are not eligible.

This replaces the current details.isActive check, which is not an eligibility check. Do not add per-invitee diagnostic logic beyond what is already present.

Please add focused tests for:

  • a code-only registered user attaching a valid inviter later, using the original code;
  • a paid/already-attached user not seeing or completing that flow;
  • collect enabled only when getCollectableInvitees is non-empty.

Co-authored-by: L03TJ3 <6606028+L03TJ3@users.noreply.github.com>

Copilot AI commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

@copilot

Please update the direct dependency to @goodsdks/invite-sdk@1.0.3 and refresh pnpm-lock.yaml....

Addressed in 573f1c1: upgraded to InviteSDK 1.0.3, reuses registered codes for deferred inviter attachment, gates collection through getCollectableInvitees, and adds focused coverage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[PLAN] Integrate invite SDK into citizen-claim-widget

2 participants