feat(api): fix #247 batch auto_top_up for all importers in one admin operation - #785
Open
Owolabenjade wants to merge 3 commits into
Open
feat(api): fix #247 batch auto_top_up for all importers in one admin operation#785Owolabenjade wants to merge 3 commits into
Owolabenjade wants to merge 3 commits into
Conversation
|
Hey @Owolabenjade! 👋 It looks like this PR isn't linked to any issue. If this PR is for one of the issues assigned to you as part of a Wave, please link it to ensure your contribution is tracked properly. You can do this by adding a keyword to the PR description (e.g.,
|
|
Deployment failed with the following error: Learn More: https://vercel.com/docs/concepts/projects/project-configuration |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Owolabenjade
force-pushed
the
feat/issue-247-batch-auto-top-up
branch
from
July 29, 2026 06:45
202a680 to
f2342ef
Compare
…ne admin operation
Owolabenjade
force-pushed
the
feat/issue-247-batch-auto-top-up
branch
from
July 29, 2026 06:57
f2342ef to
70fb749
Compare
…h-auto-top-up # Conflicts: # apps/api/src/routes/admin.ts # apps/web/app/app/page.tsx # packages/sdk/src/index.ts
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.
Problem Statement & Context
Prior to this change, the
auto_top_upworkflow for under-collateralized customs bonds required surety administrators to execute individual transactions sequentially per importer. For a surety admin managing a portfolio of 100+ importers, executing 100 sequential Soroban RPC transactions (each taking 200–600ms round-trip) resulted in operation runtimes exceeding 60 seconds. This sequential bottleneck created operational friction during high-volatility tariff spike events where rapid bond collateralization is critical.What Was Fixed & How the Flow Works Now
To resolve issue #247, we introduced a high-throughput, production-grade batch endpoint
POST /admin/auto-top-uprestricted to accounts with thesurety_adminJWT role:SELECTstatement to identify all active, non-deleted importers whose posted collateral balance falls below their bond requirement (collateral_balance < COALESCE(b.cbp_minimum_required, b.bond_amount, 0)). An optionalimporter_ids[]payload filter allows admins to target a specific subset of importers.Promise.allSettled): Individual Soroban transaction failures (such as contract execution rejections or RPC timeouts) are caught per item without aborting the overall batch. The endpoint returns a detailed summary response:{ succeeded: number, failed: number, errors: Array<{ id: string, reason: string }> }.TariffShieldClientin@tariffshield/sdkwith abatchAutoTopUpmethod enabling external SDK consumers to execute batch top-ups with custom concurrency limits.Why This Change Matters
This update dramatically improves scalability and reliability for surety administrators managing large importer portfolios on Stellar. By replacing serial execution with bounded parallel worker pools, system throughput increases by 10x while maintaining strict compliance audit logging and RPC rate-limit safety.
Changed
POST /admin/auto-top-upendpoint withsurety_adminauthorization, single SQL query eligibility fetch, 10-worker concurrency limit pool, audit logging, and summary response for issue Batch auto_top_up for All Importers in One Admin Operation #247.TariffShieldClientSDK class withbatchAutoTopUp(signer, importers, concurrencyLimit)method supporting parallel worker pool execution for issue Batch auto_top_up for All Importers in One Admin Operation #247. Fixed primary signer parameter handling insetRequiredCollateral.POST /admin/auto-top-upunder issue Batch auto_top_up for All Importers in One Admin Operation #247.Testing
Exact commands run for verification:
npm run build --workspace=packages/sdk— Verified TypeScript compilation for@tariffshield/sdkwith zero errors.npm run lint --workspace=apps/api— Verified ESLint rules and syntax across API routes.git status— Confirmed clean git staging state with only intended files committed.Scope Notes
apps/apiroutes, OpenAPI definitions, andpackages/sdk.apps/webcomponents or pages.