Description
Assets issued by accounts with AUTH_REQUIRED flag set require the issuer to explicitly approve each trustline before a recipient can hold the asset. The SDK does not automate the AllowTrust or SetTrustlineFlags request on behalf of issuers, leaving recipients unable to receive the asset until the issuer manually acts. An auth-required trustline handler should detect the condition, notify the issuer, and facilitate the approval transaction.
Technical Context
Add src/trustlineAuthHandler.ts. Reads issuer account flags via src/accountFlagsInspector.ts. Builds Operation.setTrustLineFlags() (protocol 18+) or Operation.allowTrust() (legacy) via @stellar/stellar-sdk. Integrates with src/preflightChecker.ts to detect when an approval is needed. Adds TrustlineAuthRequest to src/types.ts. Emits trustlineAuthRequired and trustlineAuthGranted via src/events.ts.
Acceptance Criteria
Description
Assets issued by accounts with
AUTH_REQUIREDflag set require the issuer to explicitly approve each trustline before a recipient can hold the asset. The SDK does not automate theAllowTrustorSetTrustlineFlagsrequest on behalf of issuers, leaving recipients unable to receive the asset until the issuer manually acts. An auth-required trustline handler should detect the condition, notify the issuer, and facilitate the approval transaction.Technical Context
Add
src/trustlineAuthHandler.ts. Reads issuer account flags viasrc/accountFlagsInspector.ts. BuildsOperation.setTrustLineFlags()(protocol 18+) orOperation.allowTrust()(legacy) via@stellar/stellar-sdk. Integrates withsrc/preflightChecker.tsto detect when an approval is needed. AddsTrustlineAuthRequesttosrc/types.ts. EmitstrustlineAuthRequiredandtrustlineAuthGrantedviasrc/events.ts.Acceptance Criteria
TrustlineAuthHandler.checkAndRequest(recipientId, asset): Promise<TrustlineAuthStatus>detects whether the asset requires auth and, if so, emitstrustlineAuthRequiredwith the issuer's public keyTrustlineAuthHandler.grantAuth(recipientId, asset, issuerKeypair): Promise<TransactionResult>builds and submits theSetTrustLineFlags(AUTHORIZED) operation signed by the issuerSetTrustLineFlagson protocol ≥ 18 and falls back toAllowTruston older protocol versions detected bysrc/sorobanFeatureDetector.tstrustlineAuthGrantedafter successful submissioncheckAndRequest, and asserttrustlineAuthRequiredis emitted; assertgrantAuthsubmits the correct operation type