Repository navigation
Add contract address validation, transaction verification, comprehensive error codes, and recovery strategies (#1065, #1066, #1067, #1068) - #1153
Open
dev-kiki0 wants to merge 1 commit into
Conversation
…s, and recovery strategies (Stellar-split#1065, Stellar-split#1066, Stellar-split#1067, Stellar-split#1068) Stellar-split#1065: Add validateContractAddress/isValidContractAddress/assertValidContractAddress\n enforcing the StrKey contract-address rules (56-char C-address, uppercase\n base32 alphabet, CRC16 checksum) with format and checksum reported apart,\n plus a typed InvalidContractAddressError.\n\n#1066: Add verifyTransaction/verifyTransactionSignatures/assertTransactionVerified\n to check transaction integrity and authenticity before submit: structure,\n fee, sequence, time bounds, ed25519 signature, and hash integrity checks,\n plus a typed TransactionVerificationError.\n\n#1067: Extend SdkErrorCode to cover every SDK failure category and add\n SDK_ERROR_CODE_DESCRIPTIONS, describeSdkErrorCode, RETRYABLE_ERROR_CODES,\n and isRetryableErrorCode. Suggestions, descriptions, and recovery\n strategies are exhaustive over the enum (compile-time enforced).\n\n#1068: Add an exhaustive RECOVERY_STRATEGY_TABLE mapping each error code to\n a recovery action, getRecoveryStrategy/getRecoveryPlan for inspecting\n remediation, executeWithRecovery for automatic retry with backoff,\n coverage for every code in getSuggestion, docs/ERROR_CODES.md, and\n examples/error-recovery-example.ts.
|
@dev-kiki0 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 branch has not been deployed
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.
What this fixes
Four related gaps in the SDK's validation and error-handling surface:
C...address only failed later, during config validation or on-chain submission.SdkErrorCodeonly covered 8 failure modes, with no per-code descriptions and no way to tell whether a failure was transient.What changed
#1065 –
src/contractAddressValidator.tsvalidateContractAddress()checks the documented StrKey rules and reportsformat(type, 56-char length,Cprefix, uppercase base32 alphabet) andchecksum(CRC16 viaStrKey.decodeContract) failures separately.isValidContractAddress()boolean shorthand andassertValidContractAddress()which throws the new typedInvalidContractAddressError(codeINVALID_CONTRACT_ADDRESS).docs/ERROR_CODES.md.#1066 –
src/transactionVerifier.tsverifyTransaction(tx, options)runs six independent checks:structure,fee(maxFee),sequence(expectedSequence),timebounds,signatures(ed25519 over the tx hash for each requiredsignerskey, plusminSignatures), andhash(expectedHash, hex or base64). Options that aren't supplied are skipped, never passed vacuously.verifyTransactionSignatures()classifies keys as valid / missing / invalid; hints are advisory only — a signature counts only when ed25519 verification succeeds.assertTransactionVerified()throws the new typedTransactionVerificationError(codeVERIFICATION_FAILED) listing the failed checks.#1067 –
src/errors.ts+src/errorSuggestions.tsSdkErrorCodeextended from 8 to 38 codes across seven categories (invoice lifecycle, accounts/funds, input validation, network, transaction lifecycle, contract execution, authorization, operational/state); all existing codes preserved.SDK_ERROR_CODE_DESCRIPTIONS,describeSdkErrorCode(), conservativeRETRYABLE_ERROR_CODES, andisRetryableErrorCode().getSuggestion()coverage extended to every code — theRecord<SdkErrorCode, string>table makes all three maps compile-time exhaustive, so future codes can't ship without descriptions, suggestions, or recovery strategies.#1068 –
src/errorRecovery.tsRECOVERY_STRATEGY_TABLEmapping every code to aRecoveryAction(retry,retry_with_backoff,refresh_and_retry,correct_input,use_fallback,wait_for_resolution,abort) withmaxAttempts/backoffMswhere retryable.getRecoveryStrategy()(code / string / Error) andgetRecoveryPlan()(strategy + human suggestion).executeWithRecovery(op)applies the mapped strategy: bounded retries with exponential backoff for transient failures, immediate rethrow for non-retryable ones, abort-signal support.examples/error-recovery-example.tsand full reference indocs/ERROR_CODES.md.Public API: all new symbols exported from
src/index.ts.Testing
npx vitest run test/contractAddressValidator.test.ts test/errorCodes.test.ts test/transactionVerifier.test.ts test/errorRecovery.test.ts test/errorSuggestions.test.ts test/sdkError.test.ts→ 6 files, 108 tests passed.StrKey.encodeContract) accepted; broken-checksum/format/case/alphabet/length/prefix mutations rejected.TransactionBuilderexercise every verification check (pass and fail paths, forged signatures, hash mismatch).npm test(core suite) → passed.npx vitest run→ 269 files: 246 passed, 21 failed, 2 skipped (3447 tests passed, 168 failed) — identical (same 21 files, same 168 tests) to a cleanupstream/mainbaseline run, i.e. all failures are pre-existing and unrelated.npm run lint(tsc --noEmit): 561 errors — identical to the pre-change baseline; zero errors in any file added or modified by this PR.Issues
closes #1065
closes #1066
closes #1067
closes #1068