Skip to content

Add ClaimSDK transaction-submitted callback - #63

Open
sirpy with Copilot wants to merge 17 commits into
mainfrom
copilot/claim-sdk-optional-callback
Open

sirpy with Copilot wants to merge 17 commits into
mainfrom
copilot/claim-sdk-optional-callback

Conversation

Copilot AI commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Claim consumers need to distinguish wallet signing from the pending-on-chain stage. The claim flow now exposes a reliable post-broadcast callback before receipt confirmation.

  • Claim API

    • Added claim({ onTransactionSubmitted }) for the post-submission / pre-confirmation hook.
    • Kept existing positional claim(txConfirm) support.
    • Preserved transaction hash aliases via deprecated onTxHash / onTxhash.
  • Callback behavior

    • Invokes the submitted callback once after writeContract succeeds.
    • Logs and swallows callback errors so UI handlers cannot fail the claim.
    • Applies the same safe callback path to custodial claim submission.
  • Coverage

    • Added focused ClaimSDK tests for callback ordering, single invocation, swallowed errors, aliases, and legacy txConfirm.
await claimSdk.claim({
  txConfirm: async (message) => showWalletPrompt(message),
  onTransactionSubmitted: (hash) => {
    setClaimState("pending-confirmation")
    setTxHash(hash)
  },
})

Copilot AI and others added 11 commits August 19, 2026 11:18
Co-authored-by: sirpy <671095+sirpy@users.noreply.github.com>
Co-authored-by: sirpy <671095+sirpy@users.noreply.github.com>
Co-authored-by: sirpy <671095+sirpy@users.noreply.github.com>
Co-authored-by: sirpy <671095+sirpy@users.noreply.github.com>
Co-authored-by: sirpy <671095+sirpy@users.noreply.github.com>
Co-authored-by: sirpy <671095+sirpy@users.noreply.github.com>
Co-authored-by: sirpy <671095+sirpy@users.noreply.github.com>
Co-authored-by: sirpy <671095+sirpy@users.noreply.github.com>
Co-authored-by: sirpy <671095+sirpy@users.noreply.github.com>
Co-authored-by: sirpy <671095+sirpy@users.noreply.github.com>
Co-authored-by: sirpy <671095+sirpy@users.noreply.github.com>
Copilot AI changed the title [WIP] Add optional transaction-submitted callback to Claim SDK Add ClaimSDK transaction-submitted callback Aug 19, 2026
Copilot AI requested a review from sirpy August 19, 2026 11:35
Comment on lines +76 to +92
export type ClaimTxConfirmCallback = (message: string) => void | Promise<void>

export type ClaimTransactionSubmittedCallback = (
hash: `0x${string}`,
) => void | Promise<void>

export interface ClaimOptions {
/** Called during the balance check step to confirm faucet or retry actions. */
txConfirm?: ClaimTxConfirmCallback
/** Called once after the claim transaction is broadcast and before receipt confirmation. */
onTransactionSubmitted?: ClaimTransactionSubmittedCallback
/** @deprecated Use onTransactionSubmitted for the post-broadcast, pre-confirmation stage. */
onTxHash?: ClaimTransactionSubmittedCallback
/** @deprecated Use onTransactionSubmitted; this alias preserves integrations that used the lowercase-h spelling. */
onTxhash?: ClaimTransactionSubmittedCallback
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

not required

@sirpy

sirpy commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

@copilot fix review comments

Co-authored-by: sirpy <671095+sirpy@users.noreply.github.com>
Copilot AI and others added 3 commits August 19, 2026 12:39
Co-authored-by: sirpy <671095+sirpy@users.noreply.github.com>
Co-authored-by: sirpy <671095+sirpy@users.noreply.github.com>
Co-authored-by: sirpy <671095+sirpy@users.noreply.github.com>

Copilot AI commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

@copilot fix review comments

Addressed in 28f5ce9, d75d22c, and 0376129. Automated code review and CodeQL are now clean.

@sirpy
sirpy requested a review from blueogin August 30, 2026 11:36
@sirpy

sirpy commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

@blueogin


const hash = await this.walletClient.writeContract(request)
onHash?.(hash)
await safeInvokeSubmittedCallback(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Awaited callback can hang claim()
The submitted callback is now awaited. A consumer callback that resolves slowly or never (rare cases) blocks the 5s sleep and waitForTransactionReceipt, so claim() hangs even after the tx confirms.
Worth either keeping it fire-and-forget or wrapping it in a timeout.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

fixed

const onClaimSubmitted = vi.fn(() => {
events.push("submitted")
})
vi.spyOn(sdk, "submitAndWait").mockImplementation(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The test mocks out submitAndWait and invokes the callback itself, so the real callback-before-confirmation ordering inside ClaimSDK.submitAndWait is never exercised. A regression there wouldn't fail the suite.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

fixed

@sirpy

sirpy commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

@copilot evaluate the latest review comments by @blueogin
are they valid? if so suggest fixes

@sirpy

sirpy commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

@copilot evaluate the latest review comments by @blueogin
are they valid? if so suggest fixes

@blueogin

Copy link
Copy Markdown
Collaborator

@sirpy
copilot seems not working

@sirpy

sirpy commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

@copilot evaluate the latest review comments by @blueogin
are they valid? if so suggest fixes

Copilot AI commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

@sirpy The model claude-haiku-5.5 is not available for your account. This can happen if the model was disabled by your organization's policy or if your Copilot plan doesn't include access to it.

You can try again without specifying a model (just @copilot) to use the default, or choose a different model from the model picker.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: bd183f74-8df6-495a-824c-1a8d1c187e56

3 similar comments

Copilot AI commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

@sirpy The model claude-haiku-5.5 is not available for your account. This can happen if the model was disabled by your organization's policy or if your Copilot plan doesn't include access to it.

You can try again without specifying a model (just @copilot) to use the default, or choose a different model from the model picker.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: bd183f74-8df6-495a-824c-1a8d1c187e56

Copilot AI commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

@sirpy The model claude-haiku-5.5 is not available for your account. This can happen if the model was disabled by your organization's policy or if your Copilot plan doesn't include access to it.

You can try again without specifying a model (just @copilot) to use the default, or choose a different model from the model picker.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: bd183f74-8df6-495a-824c-1a8d1c187e56

Copilot AI commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

@sirpy The model claude-haiku-5.5 is not available for your account. This can happen if the model was disabled by your organization's policy or if your Copilot plan doesn't include access to it.

You can try again without specifying a model (just @copilot) to use the default, or choose a different model from the model picker.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: bd183f74-8df6-495a-824c-1a8d1c187e56

@sirpy

sirpy commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

@copilot evaluate the latest review comments by @blueogin
are they valid? if so suggest fixes

Copilot AI commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

@sirpy The model claude-haiku-5.5 is not available for your account. This can happen if the model was disabled by your organization's policy or if your Copilot plan doesn't include access to it.

You can try again without specifying a model (just @copilot) to use the default, or choose a different model from the model picker.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: bd183f74-8df6-495a-824c-1a8d1c187e56

1 similar comment

Copilot AI commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

@sirpy The model claude-haiku-5.5 is not available for your account. This can happen if the model was disabled by your organization's policy or if your Copilot plan doesn't include access to it.

You can try again without specifying a model (just @copilot) to use the default, or choose a different model from the model picker.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: bd183f74-8df6-495a-824c-1a8d1c187e56

…ring

Co-authored-by: sirpy <671095+sirpy@users.noreply.github.com>

This branch was successfully deployed

2 active deployments
preview — 40543fdc Deployed Oct 30, 2026 by Copilot via preview #278
internal — 40543fdc Deployed Oct 30, 2026 by Copilot via authorize #278
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.

ClaimSDK: support optional transaction-submitted callback before confirmation

3 participants