trustbase-seller-backend 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/skills/wechatpay-payment-integration/SKILL.md +165 -0
- package/.agents/skills/wechatpay-payment-integration/references/APIv3/346/216/245/345/217/243/345/212/250/346/200/201/346/216/222/351/232/234.md +234 -0
- package/.agents/skills/wechatpay-payment-integration/references/wechatpay-dev-cli/344/275/277/347/224/250/350/257/264/346/230/216.md +74 -0
- package/.agents/skills/wechatpay-payment-integration/references//345/237/272/347/241/200/346/246/202/345/277/265/345/217/212/344/270/232/345/212/241/344/273/213/347/273/215.md +109 -0
- package/.agents/skills/wechatpay-payment-integration/references//345/246/202/344/275/225/347/220/206/350/247/243/347/224/250/346/210/267/351/227/256/351/242/230.md +55 -0
- package/.agents/skills/wechatpay-payment-integration/references//346/216/245/345/205/245/350/264/250/351/207/217/346/243/200/346/237/245/346/270/205/345/215/225.md +70 -0
- package/.agents/skills/wechatpay-payment-integration/references//346/226/207/346/241/243/346/243/200/347/264/242/344/270/216/351/227/256/347/255/224.md +99 -0
- package/.agents/skills/wechatpay-payment-integration/scripts/bash/extract_and_sign.sh +231 -0
- package/.agents/skills/wechatpay-payment-integration/scripts/powershell/extract_and_sign.ps1 +199 -0
- package/.agents/skills/wechatpay-payment-integration/scripts/wechatpay-resource-sync.py +646 -0
- package/.env.example +70 -0
- package/MERCHANT-EDITION.md +56 -0
- package/README.md +99 -0
- package/api/__tests__/test-utils.d.ts +33 -0
- package/api/__tests__/test-utils.d.ts.map +1 -0
- package/api/__tests__/test-utils.js +90 -0
- package/api/__tests__/test-utils.js.map +1 -0
- package/api/db/case-library-types.d.ts +47 -0
- package/api/db/case-library-types.d.ts.map +1 -0
- package/api/db/case-library-types.js +105 -0
- package/api/db/case-library-types.js.map +1 -0
- package/api/db/case-library.db.d.ts +5 -0
- package/api/db/case-library.db.d.ts.map +1 -0
- package/api/db/case-library.db.js +127 -0
- package/api/db/case-library.db.js.map +1 -0
- package/api/email.d.ts +56 -0
- package/api/email.d.ts.map +1 -0
- package/api/email.js +307 -0
- package/api/email.js.map +1 -0
- package/api/index.d.ts +22 -0
- package/api/index.d.ts.map +1 -0
- package/api/index.js +41 -0
- package/api/index.js.map +1 -0
- package/api/integration-helpers.d.ts +153 -0
- package/api/integration-helpers.d.ts.map +1 -0
- package/api/integration-helpers.js +361 -0
- package/api/integration-helpers.js.map +1 -0
- package/api/lib/case-summary.d.ts +10 -0
- package/api/lib/case-summary.d.ts.map +1 -0
- package/api/lib/case-summary.js +30 -0
- package/api/lib/case-summary.js.map +1 -0
- package/api/middleware/p2p-auth.d.ts +140 -0
- package/api/middleware/p2p-auth.d.ts.map +1 -0
- package/api/middleware/p2p-auth.js +510 -0
- package/api/middleware/p2p-auth.js.map +1 -0
- package/api/middleware/tool-policy.d.ts +47 -0
- package/api/middleware/tool-policy.d.ts.map +1 -0
- package/api/middleware/tool-policy.js +156 -0
- package/api/middleware/tool-policy.js.map +1 -0
- package/api/oauth-adapters.d.ts +192 -0
- package/api/oauth-adapters.d.ts.map +1 -0
- package/api/oauth-adapters.js +456 -0
- package/api/oauth-adapters.js.map +1 -0
- package/api/oauth-bridge.d.ts +56 -0
- package/api/oauth-bridge.d.ts.map +1 -0
- package/api/oauth-bridge.js +624 -0
- package/api/oauth-bridge.js.map +1 -0
- package/api/oauth-router.d.ts +36 -0
- package/api/oauth-router.d.ts.map +1 -0
- package/api/oauth-router.js +54 -0
- package/api/oauth-router.js.map +1 -0
- package/api/p2p-mcp.d.ts +69 -0
- package/api/p2p-mcp.d.ts.map +1 -0
- package/api/p2p-mcp.js +286 -0
- package/api/p2p-mcp.js.map +1 -0
- package/api/payment-store.d.ts +56 -0
- package/api/payment-store.d.ts.map +1 -0
- package/api/payment-store.js +163 -0
- package/api/payment-store.js.map +1 -0
- package/api/payment.d.ts +14 -0
- package/api/payment.d.ts.map +1 -0
- package/api/payment.js +216 -0
- package/api/payment.js.map +1 -0
- package/api/pwa-stats.d.ts +67 -0
- package/api/pwa-stats.d.ts.map +1 -0
- package/api/pwa-stats.js +269 -0
- package/api/pwa-stats.js.map +1 -0
- package/api/riskcontrol-adapters.d.ts +114 -0
- package/api/riskcontrol-adapters.d.ts.map +1 -0
- package/api/riskcontrol-adapters.js +210 -0
- package/api/riskcontrol-adapters.js.map +1 -0
- package/api/riskcontrol-event-whitelist.d.ts +81 -0
- package/api/riskcontrol-event-whitelist.d.ts.map +1 -0
- package/api/riskcontrol-event-whitelist.js +181 -0
- package/api/riskcontrol-event-whitelist.js.map +1 -0
- package/api/riskcontrol-rules.d.ts +105 -0
- package/api/riskcontrol-rules.d.ts.map +1 -0
- package/api/riskcontrol-rules.js +399 -0
- package/api/riskcontrol-rules.js.map +1 -0
- package/api/riskcontrol-scoring.d.ts +72 -0
- package/api/riskcontrol-scoring.d.ts.map +1 -0
- package/api/riskcontrol-scoring.js +335 -0
- package/api/riskcontrol-scoring.js.map +1 -0
- package/api/riskcontrol-service.d.ts +60 -0
- package/api/riskcontrol-service.d.ts.map +1 -0
- package/api/riskcontrol-service.js +206 -0
- package/api/riskcontrol-service.js.map +1 -0
- package/api/riskcontrol-stream.d.ts +112 -0
- package/api/riskcontrol-stream.d.ts.map +1 -0
- package/api/riskcontrol-stream.js +230 -0
- package/api/riskcontrol-stream.js.map +1 -0
- package/api/riskcontrol-v5-e2e-test.d.ts +15 -0
- package/api/riskcontrol-v5-e2e-test.d.ts.map +1 -0
- package/api/riskcontrol-v5-e2e-test.js +204 -0
- package/api/riskcontrol-v5-e2e-test.js.map +1 -0
- package/api/riskcontrol-v5-router.d.ts +48 -0
- package/api/riskcontrol-v5-router.d.ts.map +1 -0
- package/api/riskcontrol-v5-router.js +226 -0
- package/api/riskcontrol-v5-router.js.map +1 -0
- package/api/riskcontrol-webhook.d.ts +88 -0
- package/api/riskcontrol-webhook.d.ts.map +1 -0
- package/api/riskcontrol-webhook.js +326 -0
- package/api/riskcontrol-webhook.js.map +1 -0
- package/api/routes/case-library.d.ts +4 -0
- package/api/routes/case-library.d.ts.map +1 -0
- package/api/routes/case-library.js +91 -0
- package/api/routes/case-library.js.map +1 -0
- package/api/seller-earnings.d.ts +23 -0
- package/api/seller-earnings.d.ts.map +1 -0
- package/api/seller-earnings.js +258 -0
- package/api/seller-earnings.js.map +1 -0
- package/api/seller-orders.d.ts +25 -0
- package/api/seller-orders.d.ts.map +1 -0
- package/api/seller-orders.js +398 -0
- package/api/seller-orders.js.map +1 -0
- package/api/seller-products-chain.d.ts +31 -0
- package/api/seller-products-chain.d.ts.map +1 -0
- package/api/seller-products-chain.js +308 -0
- package/api/seller-products-chain.js.map +1 -0
- package/api/seller-products.d.ts +30 -0
- package/api/seller-products.d.ts.map +1 -0
- package/api/seller-products.js +453 -0
- package/api/seller-products.js.map +1 -0
- package/api/seller-reputation.d.ts +21 -0
- package/api/seller-reputation.d.ts.map +1 -0
- package/api/seller-reputation.js +204 -0
- package/api/seller-reputation.js.map +1 -0
- package/api/seller-router.d.ts +33 -0
- package/api/seller-router.d.ts.map +1 -0
- package/api/seller-router.js +53 -0
- package/api/seller-router.js.map +1 -0
- package/api/seller-settings.d.ts +23 -0
- package/api/seller-settings.d.ts.map +1 -0
- package/api/seller-settings.js +279 -0
- package/api/seller-settings.js.map +1 -0
- package/api/shipping-store.d.ts +44 -0
- package/api/shipping-store.d.ts.map +1 -0
- package/api/shipping-store.js +154 -0
- package/api/shipping-store.js.map +1 -0
- package/api/shipping.d.ts +16 -0
- package/api/shipping.d.ts.map +1 -0
- package/api/shipping.js +239 -0
- package/api/shipping.js.map +1 -0
- package/api/social-endpoint-verify.d.ts +8 -0
- package/api/social-endpoint-verify.d.ts.map +1 -0
- package/api/social-endpoint-verify.js +152 -0
- package/api/social-endpoint-verify.js.map +1 -0
- package/api/social-posts.d.ts +65 -0
- package/api/social-posts.d.ts.map +1 -0
- package/api/social-posts.js +534 -0
- package/api/social-posts.js.map +1 -0
- package/api/social-router.d.ts +36 -0
- package/api/social-router.d.ts.map +1 -0
- package/api/social-router.js +56 -0
- package/api/social-router.js.map +1 -0
- package/api/social-shares.d.ts +40 -0
- package/api/social-shares.d.ts.map +1 -0
- package/api/social-shares.js +379 -0
- package/api/social-shares.js.map +1 -0
- package/api/social-whitelist.d.ts +41 -0
- package/api/social-whitelist.d.ts.map +1 -0
- package/api/social-whitelist.js +261 -0
- package/api/social-whitelist.js.map +1 -0
- package/api/storefront-orders.d.ts +23 -0
- package/api/storefront-orders.d.ts.map +1 -0
- package/api/storefront-orders.js +349 -0
- package/api/storefront-orders.js.map +1 -0
- package/api/storefront-products.d.ts +21 -0
- package/api/storefront-products.d.ts.map +1 -0
- package/api/storefront-products.js +181 -0
- package/api/storefront-products.js.map +1 -0
- package/api/storefront-router.d.ts +33 -0
- package/api/storefront-router.d.ts.map +1 -0
- package/api/storefront-router.js +47 -0
- package/api/storefront-router.js.map +1 -0
- package/api/storefront-user.d.ts +23 -0
- package/api/storefront-user.d.ts.map +1 -0
- package/api/storefront-user.js +336 -0
- package/api/storefront-user.js.map +1 -0
- package/api/test-db-helper.d.ts +29 -0
- package/api/test-db-helper.d.ts.map +1 -0
- package/api/test-db-helper.js +107 -0
- package/api/test-db-helper.js.map +1 -0
- package/api/traffic.d.ts +22 -0
- package/api/traffic.d.ts.map +1 -0
- package/api/traffic.js +112 -0
- package/api/traffic.js.map +1 -0
- package/api/wc-credentials.d.ts +34 -0
- package/api/wc-credentials.d.ts.map +1 -0
- package/api/wc-credentials.js +296 -0
- package/api/wc-credentials.js.map +1 -0
- package/api/wc-tracker-receiver.d.ts +47 -0
- package/api/wc-tracker-receiver.d.ts.map +1 -0
- package/api/wc-tracker-receiver.js +264 -0
- package/api/wc-tracker-receiver.js.map +1 -0
- package/api/wc-v3.d.ts +40 -0
- package/api/wc-v3.d.ts.map +1 -0
- package/api/wc-v3.js +694 -0
- package/api/wc-v3.js.map +1 -0
- package/bin/tb-doctor.js +32 -0
- package/bin/tb-seller-backend.js +42 -0
- package/check.d.ts +2 -0
- package/check.d.ts.map +1 -0
- package/check.js +19 -0
- package/check.js.map +1 -0
- package/config/export-import.d.ts +108 -0
- package/config/export-import.d.ts.map +1 -0
- package/config/export-import.js +234 -0
- package/config/export-import.js.map +1 -0
- package/config/manager.d.ts +73 -0
- package/config/manager.d.ts.map +1 -0
- package/config/manager.js +246 -0
- package/config/manager.js.map +1 -0
- package/config/profile.d.ts +42 -0
- package/config/profile.d.ts.map +1 -0
- package/config/profile.js +111 -0
- package/config/profile.js.map +1 -0
- package/core/address.js +23 -0
- package/core/advanced-performance.d.ts +149 -0
- package/core/advanced-performance.d.ts.map +1 -0
- package/core/advanced-performance.js +374 -0
- package/core/advanced-performance.js.map +1 -0
- package/core/alerting.d.ts +91 -0
- package/core/alerting.d.ts.map +1 -0
- package/core/alerting.js +379 -0
- package/core/alerting.js.map +1 -0
- package/core/app-store.d.ts +77 -0
- package/core/app-store.d.ts.map +1 -0
- package/core/app-store.js +207 -0
- package/core/app-store.js.map +1 -0
- package/core/boot-env.js +39 -0
- package/core/business-scope-schema.d.ts +60 -0
- package/core/business-scope-schema.d.ts.map +1 -0
- package/core/business-scope-schema.js +165 -0
- package/core/business-scope-schema.js.map +1 -0
- package/core/cache.d.ts +53 -0
- package/core/cache.d.ts.map +1 -0
- package/core/cache.js +130 -0
- package/core/cache.js.map +1 -0
- package/core/chain-listener.d.ts +47 -0
- package/core/chain-listener.d.ts.map +1 -0
- package/core/chain-listener.js +254 -0
- package/core/chain-listener.js.map +1 -0
- package/core/chain-reject.js +107 -0
- package/core/chain-signer.js +258 -0
- package/core/cleanup.d.ts +42 -0
- package/core/cleanup.d.ts.map +1 -0
- package/core/cleanup.js +144 -0
- package/core/cleanup.js.map +1 -0
- package/core/cluster.d.ts +78 -0
- package/core/cluster.d.ts.map +1 -0
- package/core/cluster.js +215 -0
- package/core/cluster.js.map +1 -0
- package/core/community-review.d.ts +82 -0
- package/core/community-review.d.ts.map +1 -0
- package/core/community-review.js +201 -0
- package/core/community-review.js.map +1 -0
- package/core/connection-pool.d.ts +72 -0
- package/core/connection-pool.d.ts.map +1 -0
- package/core/connection-pool.js +173 -0
- package/core/connection-pool.js.map +1 -0
- package/core/consistency.d.ts +130 -0
- package/core/consistency.d.ts.map +1 -0
- package/core/consistency.js +340 -0
- package/core/consistency.js.map +1 -0
- package/core/content-ai.d.ts +303 -0
- package/core/content-ai.d.ts.map +1 -0
- package/core/content-ai.js +344 -0
- package/core/content-ai.js.map +1 -0
- package/core/content-backfill.d.ts +55 -0
- package/core/content-backfill.d.ts.map +1 -0
- package/core/content-backfill.js +174 -0
- package/core/content-backfill.js.map +1 -0
- package/core/conversion-rate-sync.d.ts +97 -0
- package/core/conversion-rate-sync.d.ts.map +1 -0
- package/core/conversion-rate-sync.js +195 -0
- package/core/conversion-rate-sync.js.map +1 -0
- package/core/coverage-backup.d.ts +87 -0
- package/core/coverage-backup.d.ts.map +1 -0
- package/core/coverage-backup.js +265 -0
- package/core/coverage-backup.js.map +1 -0
- package/core/db-installer.d.ts +108 -0
- package/core/db-installer.d.ts.map +1 -0
- package/core/db-installer.js +414 -0
- package/core/db-installer.js.map +1 -0
- package/core/device-analyzer.d.ts +96 -0
- package/core/device-analyzer.d.ts.map +1 -0
- package/core/device-analyzer.js +235 -0
- package/core/device-analyzer.js.map +1 -0
- package/core/discovery.d.ts +165 -0
- package/core/discovery.d.ts.map +1 -0
- package/core/discovery.js +363 -0
- package/core/discovery.js.map +1 -0
- package/core/distributed.d.ts +172 -0
- package/core/distributed.d.ts.map +1 -0
- package/core/distributed.js +422 -0
- package/core/distributed.js.map +1 -0
- package/core/doctor.js +249 -0
- package/core/enforcement.d.ts +57 -0
- package/core/enforcement.d.ts.map +1 -0
- package/core/enforcement.js +115 -0
- package/core/enforcement.js.map +1 -0
- package/core/error-handler.d.ts +131 -0
- package/core/error-handler.d.ts.map +1 -0
- package/core/error-handler.js +291 -0
- package/core/error-handler.js.map +1 -0
- package/core/federated-learning.d.ts +124 -0
- package/core/federated-learning.d.ts.map +1 -0
- package/core/federated-learning.js +338 -0
- package/core/federated-learning.js.map +1 -0
- package/core/fingerprint.d.ts +95 -0
- package/core/fingerprint.d.ts.map +1 -0
- package/core/fingerprint.js +313 -0
- package/core/fingerprint.js.map +1 -0
- package/core/geoip.d.ts +67 -0
- package/core/geoip.d.ts.map +1 -0
- package/core/geoip.js +174 -0
- package/core/geoip.js.map +1 -0
- package/core/gossip.d.ts +141 -0
- package/core/gossip.d.ts.map +1 -0
- package/core/gossip.js +372 -0
- package/core/gossip.js.map +1 -0
- package/core/governance.d.ts +147 -0
- package/core/governance.d.ts.map +1 -0
- package/core/governance.js +351 -0
- package/core/governance.js.map +1 -0
- package/core/indexer-enhancements.d.ts +164 -0
- package/core/indexer-enhancements.d.ts.map +1 -0
- package/core/indexer-enhancements.js +429 -0
- package/core/indexer-enhancements.js.map +1 -0
- package/core/intrusion-detection.d.ts +79 -0
- package/core/intrusion-detection.d.ts.map +1 -0
- package/core/intrusion-detection.js +322 -0
- package/core/intrusion-detection.js.map +1 -0
- package/core/lifecycle.d.ts +118 -0
- package/core/lifecycle.d.ts.map +1 -0
- package/core/lifecycle.js +310 -0
- package/core/lifecycle.js.map +1 -0
- package/core/location.d.ts +99 -0
- package/core/location.d.ts.map +1 -0
- package/core/location.js +219 -0
- package/core/location.js.map +1 -0
- package/core/maxmind-integration.d.ts +68 -0
- package/core/maxmind-integration.d.ts.map +1 -0
- package/core/maxmind-integration.js +245 -0
- package/core/maxmind-integration.js.map +1 -0
- package/core/migration.d.ts +58 -0
- package/core/migration.d.ts.map +1 -0
- package/core/migration.js +223 -0
- package/core/migration.js.map +1 -0
- package/core/monitoring.d.ts +153 -0
- package/core/monitoring.d.ts.map +1 -0
- package/core/monitoring.js +406 -0
- package/core/monitoring.js.map +1 -0
- package/core/offsite-backup.d.ts +71 -0
- package/core/offsite-backup.d.ts.map +1 -0
- package/core/offsite-backup.js +341 -0
- package/core/offsite-backup.js.map +1 -0
- package/core/order-intent-store.js +83 -0
- package/core/order-intent.js +273 -0
- package/core/paths.js +116 -0
- package/core/performance.d.ts +173 -0
- package/core/performance.d.ts.map +1 -0
- package/core/performance.js +386 -0
- package/core/performance.js.map +1 -0
- package/core/product-flag.d.ts +364 -0
- package/core/product-flag.d.ts.map +1 -0
- package/core/product-flag.js +465 -0
- package/core/product-flag.js.map +1 -0
- package/core/protection.d.ts +139 -0
- package/core/protection.d.ts.map +1 -0
- package/core/protection.js +327 -0
- package/core/protection.js.map +1 -0
- package/core/region-adapter.d.ts +152 -0
- package/core/region-adapter.d.ts.map +1 -0
- package/core/region-adapter.js +505 -0
- package/core/region-adapter.js.map +1 -0
- package/core/region-configs.d.ts +12 -0
- package/core/region-configs.d.ts.map +1 -0
- package/core/region-configs.js +907 -0
- package/core/region-configs.js.map +1 -0
- package/core/review-antifraud.d.ts +80 -0
- package/core/review-antifraud.d.ts.map +1 -0
- package/core/review-antifraud.js +193 -0
- package/core/review-antifraud.js.map +1 -0
- package/core/rules-updater.d.ts +89 -0
- package/core/rules-updater.d.ts.map +1 -0
- package/core/rules-updater.js +261 -0
- package/core/rules-updater.js.map +1 -0
- package/core/runtime-data.js +203 -0
- package/core/security.d.ts +144 -0
- package/core/security.d.ts.map +1 -0
- package/core/security.js +390 -0
- package/core/security.js.map +1 -0
- package/core/seller-identity.js +78 -0
- package/core/session-manager.d.ts +93 -0
- package/core/session-manager.d.ts.map +1 -0
- package/core/session-manager.js +262 -0
- package/core/session-manager.js.map +1 -0
- package/core/state-sync.d.ts +121 -0
- package/core/state-sync.d.ts.map +1 -0
- package/core/state-sync.js +287 -0
- package/core/state-sync.js.map +1 -0
- package/core/testing.d.ts +97 -0
- package/core/testing.d.ts.map +1 -0
- package/core/testing.js +361 -0
- package/core/testing.js.map +1 -0
- package/core/trust-score.d.ts +51 -0
- package/core/trust-score.d.ts.map +1 -0
- package/core/trust-score.js +188 -0
- package/core/trust-score.js.map +1 -0
- package/core/trustworthiness.d.ts +140 -0
- package/core/trustworthiness.d.ts.map +1 -0
- package/core/trustworthiness.js +375 -0
- package/core/trustworthiness.js.map +1 -0
- package/core/types.d.ts +258 -0
- package/core/types.d.ts.map +1 -0
- package/core/types.js +9 -0
- package/core/types.js.map +1 -0
- package/core/upgrade-manager.d.ts +114 -0
- package/core/upgrade-manager.d.ts.map +1 -0
- package/core/upgrade-manager.js +264 -0
- package/core/upgrade-manager.js.map +1 -0
- package/core/upgrader.d.ts +107 -0
- package/core/upgrader.d.ts.map +1 -0
- package/core/upgrader.js +389 -0
- package/core/upgrader.js.map +1 -0
- package/core/websocket.d.ts +78 -0
- package/core/websocket.d.ts.map +1 -0
- package/core/websocket.js +292 -0
- package/core/websocket.js.map +1 -0
- package/council/hidden-weight.d.ts +45 -0
- package/council/hidden-weight.d.ts.map +1 -0
- package/council/hidden-weight.js +135 -0
- package/council/hidden-weight.js.map +1 -0
- package/db/email-migrations.sql +31 -0
- package/db/oauth-migrate.d.ts +39 -0
- package/db/oauth-migrate.d.ts.map +1 -0
- package/db/oauth-migrate.js +201 -0
- package/db/oauth-migrate.js.map +1 -0
- package/db/oauth-migrations.sql +92 -0
- package/db/social-migrate.d.ts +12 -0
- package/db/social-migrate.d.ts.map +1 -0
- package/db/social-migrate.js +102 -0
- package/db/social-migrate.js.map +1 -0
- package/db/social-migrations.sql +94 -0
- package/db/store-migrate.d.ts +33 -0
- package/db/store-migrate.d.ts.map +1 -0
- package/db/store-migrate.js +149 -0
- package/db/store-migrate.js.map +1 -0
- package/db/store-migrations.sql +242 -0
- package/debug.d.ts +2 -0
- package/debug.d.ts.map +1 -0
- package/debug.js +18 -0
- package/debug.js.map +1 -0
- package/event-listener.d.ts +93 -0
- package/event-listener.d.ts.map +1 -0
- package/event-listener.js +321 -0
- package/event-listener.js.map +1 -0
- package/event-whitelist.d.ts +79 -0
- package/event-whitelist.d.ts.map +1 -0
- package/event-whitelist.js +533 -0
- package/event-whitelist.js.map +1 -0
- package/index.d.ts +45 -0
- package/index.d.ts.map +1 -0
- package/index.js +361 -0
- package/index.js.map +1 -0
- package/init-node.d.ts +9 -0
- package/init-node.d.ts.map +1 -0
- package/init-node.js +230 -0
- package/init-node.js.map +1 -0
- package/mcp/ai-tools.d.ts +2 -0
- package/mcp/ai-tools.d.ts.map +1 -0
- package/mcp/ai-tools.js +266 -0
- package/mcp/ai-tools.js.map +1 -0
- package/mcp/auto-dispatch-tools.d.ts +2 -0
- package/mcp/auto-dispatch-tools.d.ts.map +1 -0
- package/mcp/auto-dispatch-tools.js +348 -0
- package/mcp/auto-dispatch-tools.js.map +1 -0
- package/mcp/business-scope-tools.d.ts +11 -0
- package/mcp/business-scope-tools.d.ts.map +1 -0
- package/mcp/business-scope-tools.js +179 -0
- package/mcp/business-scope-tools.js.map +1 -0
- package/mcp/buyer-tools.d.ts +67 -0
- package/mcp/buyer-tools.d.ts.map +1 -0
- package/mcp/buyer-tools.js +445 -0
- package/mcp/buyer-tools.js.map +1 -0
- package/mcp/interfaces.d.ts +1058 -0
- package/mcp/interfaces.d.ts.map +1 -0
- package/mcp/interfaces.js +13 -0
- package/mcp/interfaces.js.map +1 -0
- package/mcp/m2m-chat-tool.d.ts +50 -0
- package/mcp/m2m-chat-tool.d.ts.map +1 -0
- package/mcp/m2m-chat-tool.js +432 -0
- package/mcp/m2m-chat-tool.js.map +1 -0
- package/mcp/migrations.d.ts +30 -0
- package/mcp/migrations.d.ts.map +1 -0
- package/mcp/migrations.js +391 -0
- package/mcp/migrations.js.map +1 -0
- package/mcp/peer-tools.d.ts +163 -0
- package/mcp/peer-tools.d.ts.map +1 -0
- package/mcp/peer-tools.js +532 -0
- package/mcp/peer-tools.js.map +1 -0
- package/mcp/plugin-management-tools.d.ts +2 -0
- package/mcp/plugin-management-tools.d.ts.map +1 -0
- package/mcp/plugin-management-tools.js +327 -0
- package/mcp/plugin-management-tools.js.map +1 -0
- package/mcp/product-type-tools.d.ts +2 -0
- package/mcp/product-type-tools.d.ts.map +1 -0
- package/mcp/product-type-tools.js +470 -0
- package/mcp/product-type-tools.js.map +1 -0
- package/mcp/security-tools.d.ts +2 -0
- package/mcp/security-tools.d.ts.map +1 -0
- package/mcp/security-tools.js +313 -0
- package/mcp/security-tools.js.map +1 -0
- package/mcp/seller-query-tools.d.ts +2 -0
- package/mcp/seller-query-tools.d.ts.map +1 -0
- package/mcp/seller-query-tools.js +179 -0
- package/mcp/seller-query-tools.js.map +1 -0
- package/mcp/server.d.ts +11 -0
- package/mcp/server.d.ts.map +1 -0
- package/mcp/server.js +68 -0
- package/mcp/server.js.map +1 -0
- package/mcp/standalone-server.d.ts +34 -0
- package/mcp/standalone-server.d.ts.map +1 -0
- package/mcp/standalone-server.js +261 -0
- package/mcp/standalone-server.js.map +1 -0
- package/mcp/tools-integration.d.ts +31 -0
- package/mcp/tools-integration.d.ts.map +1 -0
- package/mcp/tools-integration.js +288 -0
- package/mcp/tools-integration.js.map +1 -0
- package/mcp/web-panel.d.ts +18 -0
- package/mcp/web-panel.d.ts.map +1 -0
- package/mcp/web-panel.js +1657 -0
- package/mcp/web-panel.js.map +1 -0
- package/middleware/api-key-auth.d.ts +64 -0
- package/middleware/api-key-auth.d.ts.map +1 -0
- package/middleware/api-key-auth.js +255 -0
- package/middleware/api-key-auth.js.map +1 -0
- package/middleware/scope-auth.d.ts +54 -0
- package/middleware/scope-auth.d.ts.map +1 -0
- package/middleware/scope-auth.js +153 -0
- package/middleware/scope-auth.js.map +1 -0
- package/middleware/security.d.ts +48 -0
- package/middleware/security.d.ts.map +1 -0
- package/middleware/security.js +217 -0
- package/middleware/security.js.map +1 -0
- package/middleware/wallet-auth.d.ts +54 -0
- package/middleware/wallet-auth.d.ts.map +1 -0
- package/middleware/wallet-auth.js +158 -0
- package/middleware/wallet-auth.js.map +1 -0
- package/oauth/chain-revocation-sink.d.ts +24 -0
- package/oauth/chain-revocation-sink.d.ts.map +1 -0
- package/oauth/chain-revocation-sink.js +47 -0
- package/oauth/chain-revocation-sink.js.map +1 -0
- package/oauth/gossip-sync.d.ts +25 -0
- package/oauth/gossip-sync.d.ts.map +1 -0
- package/oauth/gossip-sync.js +62 -0
- package/oauth/gossip-sync.js.map +1 -0
- package/oauth/issuer-keys.d.ts +31 -0
- package/oauth/issuer-keys.d.ts.map +1 -0
- package/oauth/issuer-keys.js +117 -0
- package/oauth/issuer-keys.js.map +1 -0
- package/oauth/peer-resolver.d.ts +25 -0
- package/oauth/peer-resolver.d.ts.map +1 -0
- package/oauth/peer-resolver.js +81 -0
- package/oauth/peer-resolver.js.map +1 -0
- package/oauth/revocation-store.d.ts +58 -0
- package/oauth/revocation-store.d.ts.map +1 -0
- package/oauth/revocation-store.js +86 -0
- package/oauth/revocation-store.js.map +1 -0
- package/oauth/token-v2.d.ts +101 -0
- package/oauth/token-v2.d.ts.map +1 -0
- package/oauth/token-v2.js +167 -0
- package/oauth/token-v2.js.map +1 -0
- package/oracle/c5-glue.js +603 -0
- package/oracle/ops-console.js +623 -0
- package/oracle/oracle-sync.d.ts +29 -0
- package/oracle/oracle-sync.d.ts.map +1 -0
- package/oracle/oracle-sync.js +445 -0
- package/oracle/oracle-sync.js.map +1 -0
- package/oracle/registry.d.ts +30 -0
- package/oracle/registry.d.ts.map +1 -0
- package/oracle/registry.js +62 -0
- package/oracle/registry.js.map +1 -0
- package/p2p/availability.d.ts +188 -0
- package/p2p/availability.d.ts.map +1 -0
- package/p2p/availability.js +574 -0
- package/p2p/availability.js.map +1 -0
- package/p2p/bootstrap.d.ts +42 -0
- package/p2p/bootstrap.d.ts.map +1 -0
- package/p2p/bootstrap.js +146 -0
- package/p2p/bootstrap.js.map +1 -0
- package/p2p/buyer-client.d.ts +98 -0
- package/p2p/buyer-client.d.ts.map +1 -0
- package/p2p/buyer-client.js +199 -0
- package/p2p/buyer-client.js.map +1 -0
- package/p2p/cdn-ddns.d.ts +208 -0
- package/p2p/cdn-ddns.d.ts.map +1 -0
- package/p2p/cdn-ddns.js +500 -0
- package/p2p/cdn-ddns.js.map +1 -0
- package/p2p/cluster-sync.d.ts +115 -0
- package/p2p/cluster-sync.d.ts.map +1 -0
- package/p2p/cluster-sync.js +330 -0
- package/p2p/cluster-sync.js.map +1 -0
- package/p2p/consistency-check.d.ts +30 -0
- package/p2p/consistency-check.d.ts.map +1 -0
- package/p2p/consistency-check.js +168 -0
- package/p2p/consistency-check.js.map +1 -0
- package/p2p/endpoint-registry.d.ts +41 -0
- package/p2p/endpoint-registry.d.ts.map +1 -0
- package/p2p/endpoint-registry.js +128 -0
- package/p2p/endpoint-registry.js.map +1 -0
- package/p2p/ipv6.d.ts +120 -0
- package/p2p/ipv6.d.ts.map +1 -0
- package/p2p/ipv6.js +425 -0
- package/p2p/ipv6.js.map +1 -0
- package/p2p/protocol.d.ts +100 -0
- package/p2p/protocol.d.ts.map +1 -0
- package/p2p/protocol.js +330 -0
- package/p2p/protocol.js.map +1 -0
- package/p2p/reliability.d.ts +56 -0
- package/p2p/reliability.d.ts.map +1 -0
- package/p2p/reliability.js +240 -0
- package/p2p/reliability.js.map +1 -0
- package/p2p/seller-service.d.ts +53 -0
- package/p2p/seller-service.d.ts.map +1 -0
- package/p2p/seller-service.js +276 -0
- package/p2p/seller-service.js.map +1 -0
- package/p2p/signing.d.ts +31 -0
- package/p2p/signing.d.ts.map +1 -0
- package/p2p/signing.js +95 -0
- package/p2p/signing.js.map +1 -0
- package/package.json +73 -0
- package/payment/api.d.ts +9 -0
- package/payment/api.d.ts.map +1 -0
- package/payment/api.js +141 -0
- package/payment/api.js.map +1 -0
- package/payment/gateway.d.ts +114 -0
- package/payment/gateway.d.ts.map +1 -0
- package/payment/gateway.js +231 -0
- package/payment/gateway.js.map +1 -0
- package/payments/alipay/index.d.ts +18 -0
- package/payments/alipay/index.d.ts.map +1 -0
- package/payments/alipay/index.js +55 -0
- package/payments/alipay/index.js.map +1 -0
- package/payments/base.d.ts +13 -0
- package/payments/base.d.ts.map +1 -0
- package/payments/base.js +28 -0
- package/payments/base.js.map +1 -0
- package/payments/index.d.ts +18 -0
- package/payments/index.d.ts.map +1 -0
- package/payments/index.js +66 -0
- package/payments/index.js.map +1 -0
- package/payments/template/index.d.ts +18 -0
- package/payments/template/index.d.ts.map +1 -0
- package/payments/template/index.js +57 -0
- package/payments/template/index.js.map +1 -0
- package/payments/types.d.ts +42 -0
- package/payments/types.d.ts.map +1 -0
- package/payments/types.js +3 -0
- package/payments/types.js.map +1 -0
- package/payments/wechat/index.d.ts +18 -0
- package/payments/wechat/index.d.ts.map +1 -0
- package/payments/wechat/index.js +54 -0
- package/payments/wechat/index.js.map +1 -0
- package/peer/chain-signer.d.ts +74 -0
- package/peer/chain-signer.d.ts.map +1 -0
- package/peer/chain-signer.js +149 -0
- package/peer/chain-signer.js.map +1 -0
- package/peer/config.d.ts +71 -0
- package/peer/config.d.ts.map +1 -0
- package/peer/config.js +61 -0
- package/peer/config.js.map +1 -0
- package/peer/index.d.ts +12 -0
- package/peer/index.d.ts.map +1 -0
- package/peer/index.js +46 -0
- package/peer/index.js.map +1 -0
- package/peer/key-store.d.ts +66 -0
- package/peer/key-store.d.ts.map +1 -0
- package/peer/key-store.js +163 -0
- package/peer/key-store.js.map +1 -0
- package/peer/proto-codec.d.ts +103 -0
- package/peer/proto-codec.d.ts.map +1 -0
- package/peer/proto-codec.js +423 -0
- package/peer/proto-codec.js.map +1 -0
- package/peer/registrar.d.ts +88 -0
- package/peer/registrar.d.ts.map +1 -0
- package/peer/registrar.js +271 -0
- package/peer/registrar.js.map +1 -0
- package/peer/registry.d.ts +31 -0
- package/peer/registry.d.ts.map +1 -0
- package/peer/registry.js +143 -0
- package/peer/registry.js.map +1 -0
- package/plugins/auth.d.ts +193 -0
- package/plugins/auth.d.ts.map +1 -0
- package/plugins/auth.js +923 -0
- package/plugins/auth.js.map +1 -0
- package/plugins/manager.d.ts +37 -0
- package/plugins/manager.d.ts.map +1 -0
- package/plugins/manager.js +83 -0
- package/plugins/manager.js.map +1 -0
- package/plugins/oauth.d.ts +249 -0
- package/plugins/oauth.d.ts.map +1 -0
- package/plugins/oauth.js +979 -0
- package/plugins/oauth.js.map +1 -0
- package/plugins/p2p-message.d.ts +133 -0
- package/plugins/p2p-message.d.ts.map +1 -0
- package/plugins/p2p-message.js +443 -0
- package/plugins/p2p-message.js.map +1 -0
- package/plugins/postgresql.d.ts +54 -0
- package/plugins/postgresql.d.ts.map +1 -0
- package/plugins/postgresql.js +743 -0
- package/plugins/postgresql.js.map +1 -0
- package/plugins/relationship.d.ts +141 -0
- package/plugins/relationship.d.ts.map +1 -0
- package/plugins/relationship.js +395 -0
- package/plugins/relationship.js.map +1 -0
- package/plugins/sqlite.d.ts +200 -0
- package/plugins/sqlite.d.ts.map +1 -0
- package/plugins/sqlite.js +2412 -0
- package/plugins/sqlite.js.map +1 -0
- package/port-manager/disguise/ssh.d.ts +19 -0
- package/port-manager/disguise/ssh.d.ts.map +1 -0
- package/port-manager/disguise/ssh.js +104 -0
- package/port-manager/disguise/ssh.js.map +1 -0
- package/port-manager/port-manager.d.ts +65 -0
- package/port-manager/port-manager.d.ts.map +1 -0
- package/port-manager/port-manager.js +164 -0
- package/port-manager/port-manager.js.map +1 -0
- package/port-manager/port-scanner.d.ts +22 -0
- package/port-manager/port-scanner.d.ts.map +1 -0
- package/port-manager/port-scanner.js +187 -0
- package/port-manager/port-scanner.js.map +1 -0
- package/port-manager/types.d.ts +51 -0
- package/port-manager/types.d.ts.map +1 -0
- package/port-manager/types.js +6 -0
- package/port-manager/types.js.map +1 -0
- package/proto/amino/amino.proto +84 -0
- package/proto/cosmos/base/v1beta1/coin.proto +61 -0
- package/proto/cosmos/msg/v1/msg.proto +30 -0
- package/proto/cosmos_proto/cosmos.proto +112 -0
- package/proto/gogoproto/gogo.proto +145 -0
- package/proto/google/protobuf/descriptor.proto +1218 -0
- package/proto/trustchain/economy/v1/params.proto +133 -0
- package/proto/trustchain/economy/v1/tx.proto +162 -0
- package/proto/trustchain/marketplace/v1/params.proto +64 -0
- package/proto/trustchain/marketplace/v1/product.proto +21 -0
- package/proto/trustchain/marketplace/v1/tx.proto +131 -0
- package/proto/trustchain/order/v1/params.proto +94 -0
- package/proto/trustchain/order/v1/tx.proto +156 -0
- package/proto/trustchain/serviceprovider/v1/paymentfact.proto +32 -0
- package/proto/trustchain/serviceprovider/v1/serviceprovider.proto +38 -0
- package/proto/trustchain/serviceprovider/v1/tx.proto +106 -0
- package/proto/trustchain/subchain/v1/params.proto +26 -0
- package/proto/trustchain/subchain/v1/pool.proto +53 -0
- package/proto/trustchain/subchain/v1/tx.proto +159 -0
- package/proto/trustchain/trustcoin/v1/business_scope.proto +126 -0
- package/proto/trustchain/trustcoin/v1/genesis.proto +33 -0
- package/proto/trustchain/trustcoin/v1/params.proto +86 -0
- package/proto/trustchain/trustcoin/v1/query.proto +95 -0
- package/proto/trustchain/trustcoin/v1/tx.proto +160 -0
- package/proto/trustchain/verification/v1/params.proto +46 -0
- package/proto/trustchain/verification/v1/tx.proto +126 -0
- package/proto/trustchain/verification/v1/verification.proto +105 -0
- package/relationship-chain-api.d.ts +13 -0
- package/relationship-chain-api.d.ts.map +1 -0
- package/relationship-chain-api.js +139 -0
- package/relationship-chain-api.js.map +1 -0
- package/relationship-chain.d.ts +90 -0
- package/relationship-chain.d.ts.map +1 -0
- package/relationship-chain.js +201 -0
- package/relationship-chain.js.map +1 -0
- package/routes/agent-pay.js +419 -0
- package/routes/agent-serviceprovider.js +183 -0
- package/routes/ai.d.ts +54 -0
- package/routes/ai.d.ts.map +1 -0
- package/routes/ai.js +293 -0
- package/routes/ai.js.map +1 -0
- package/routes/api-keys.d.ts +12 -0
- package/routes/api-keys.d.ts.map +1 -0
- package/routes/api-keys.js +163 -0
- package/routes/api-keys.js.map +1 -0
- package/routes/app-store.d.ts +12 -0
- package/routes/app-store.d.ts.map +1 -0
- package/routes/app-store.js +207 -0
- package/routes/app-store.js.map +1 -0
- package/routes/auth-management.d.ts +17 -0
- package/routes/auth-management.d.ts.map +1 -0
- package/routes/auth-management.js +257 -0
- package/routes/auth-management.js.map +1 -0
- package/routes/auth.d.ts +9 -0
- package/routes/auth.d.ts.map +1 -0
- package/routes/auth.js +846 -0
- package/routes/auth.js.map +1 -0
- package/routes/brand.d.ts +3 -0
- package/routes/brand.d.ts.map +1 -0
- package/routes/brand.js +109 -0
- package/routes/brand.js.map +1 -0
- package/routes/chain-registry.d.ts +11 -0
- package/routes/chain-registry.d.ts.map +1 -0
- package/routes/chain-registry.js +51 -0
- package/routes/chain-registry.js.map +1 -0
- package/routes/chain-writes-insurance.d.ts +17 -0
- package/routes/chain-writes-insurance.d.ts.map +1 -0
- package/routes/chain-writes-insurance.js +69 -0
- package/routes/chain-writes-insurance.js.map +1 -0
- package/routes/chain-writes-pledge.d.ts +34 -0
- package/routes/chain-writes-pledge.d.ts.map +1 -0
- package/routes/chain-writes-pledge.js +206 -0
- package/routes/chain-writes-pledge.js.map +1 -0
- package/routes/chain-writes-products.d.ts +66 -0
- package/routes/chain-writes-products.d.ts.map +1 -0
- package/routes/chain-writes-products.js +394 -0
- package/routes/chain-writes-products.js.map +1 -0
- package/routes/chain-writes.d.ts +78 -0
- package/routes/chain-writes.d.ts.map +1 -0
- package/routes/chain-writes.js +658 -0
- package/routes/chain-writes.js.map +1 -0
- package/routes/chain.d.ts +10 -0
- package/routes/chain.d.ts.map +1 -0
- package/routes/chain.js +45 -0
- package/routes/chain.js.map +1 -0
- package/routes/compliance.d.ts +3 -0
- package/routes/compliance.d.ts.map +1 -0
- package/routes/compliance.js +53 -0
- package/routes/compliance.js.map +1 -0
- package/routes/council.d.ts +3 -0
- package/routes/council.d.ts.map +1 -0
- package/routes/council.js +477 -0
- package/routes/council.js.map +1 -0
- package/routes/crosschain.d.ts +11 -0
- package/routes/crosschain.d.ts.map +1 -0
- package/routes/crosschain.js +39 -0
- package/routes/crosschain.js.map +1 -0
- package/routes/device.d.ts +3 -0
- package/routes/device.d.ts.map +1 -0
- package/routes/device.js +73 -0
- package/routes/device.js.map +1 -0
- package/routes/devreward.d.ts +54 -0
- package/routes/devreward.d.ts.map +1 -0
- package/routes/devreward.js +129 -0
- package/routes/devreward.js.map +1 -0
- package/routes/economy.d.ts +50 -0
- package/routes/economy.d.ts.map +1 -0
- package/routes/economy.js +273 -0
- package/routes/economy.js.map +1 -0
- package/routes/flowback.d.ts +32 -0
- package/routes/flowback.d.ts.map +1 -0
- package/routes/flowback.js +97 -0
- package/routes/flowback.js.map +1 -0
- package/routes/insurance.d.ts +10 -0
- package/routes/insurance.d.ts.map +1 -0
- package/routes/insurance.js +70 -0
- package/routes/insurance.js.map +1 -0
- package/routes/m2m-viewer.js +195 -0
- package/routes/m2m.d.ts +10 -0
- package/routes/m2m.d.ts.map +1 -0
- package/routes/m2m.js +31 -0
- package/routes/m2m.js.map +1 -0
- package/routes/marketplace.d.ts +15 -0
- package/routes/marketplace.d.ts.map +1 -0
- package/routes/marketplace.js +396 -0
- package/routes/marketplace.js.map +1 -0
- package/routes/node-config.d.ts +6 -0
- package/routes/node-config.d.ts.map +1 -0
- package/routes/node-config.js +500 -0
- package/routes/node-config.js.map +1 -0
- package/routes/oauth-revocation.d.ts +42 -0
- package/routes/oauth-revocation.d.ts.map +1 -0
- package/routes/oauth-revocation.js +99 -0
- package/routes/oauth-revocation.js.map +1 -0
- package/routes/oauth.d.ts +17 -0
- package/routes/oauth.d.ts.map +1 -0
- package/routes/oauth.js +700 -0
- package/routes/oauth.js.map +1 -0
- package/routes/onboard.html +352 -0
- package/routes/onboard.js +435 -0
- package/routes/order.d.ts +8 -0
- package/routes/order.d.ts.map +1 -0
- package/routes/order.js +607 -0
- package/routes/order.js.map +1 -0
- package/routes/p2p-api.d.ts +33 -0
- package/routes/p2p-api.d.ts.map +1 -0
- package/routes/p2p-api.js +274 -0
- package/routes/p2p-api.js.map +1 -0
- package/routes/p2p-message.d.ts +20 -0
- package/routes/p2p-message.d.ts.map +1 -0
- package/routes/p2p-message.js +237 -0
- package/routes/p2p-message.js.map +1 -0
- package/routes/peer.d.ts +22 -0
- package/routes/peer.d.ts.map +1 -0
- package/routes/peer.js +220 -0
- package/routes/peer.js.map +1 -0
- package/routes/plugins.d.ts +4 -0
- package/routes/plugins.d.ts.map +1 -0
- package/routes/plugins.js +138 -0
- package/routes/plugins.js.map +1 -0
- package/routes/port-manager.d.ts +6 -0
- package/routes/port-manager.d.ts.map +1 -0
- package/routes/port-manager.js +212 -0
- package/routes/port-manager.js.map +1 -0
- package/routes/relationship.d.ts +7 -0
- package/routes/relationship.d.ts.map +1 -0
- package/routes/relationship.js +314 -0
- package/routes/relationship.js.map +1 -0
- package/routes/relay.d.ts +3 -0
- package/routes/relay.d.ts.map +1 -0
- package/routes/relay.js +182 -0
- package/routes/relay.js.map +1 -0
- package/routes/reputation.d.ts +10 -0
- package/routes/reputation.d.ts.map +1 -0
- package/routes/reputation.js +141 -0
- package/routes/reputation.js.map +1 -0
- package/routes/reward.d.ts +3 -0
- package/routes/reward.d.ts.map +1 -0
- package/routes/reward.js +130 -0
- package/routes/reward.js.map +1 -0
- package/routes/security-monitoring.d.ts +12 -0
- package/routes/security-monitoring.d.ts.map +1 -0
- package/routes/security-monitoring.js +373 -0
- package/routes/security-monitoring.js.map +1 -0
- package/routes/shop.d.ts +8 -0
- package/routes/shop.d.ts.map +1 -0
- package/routes/shop.js +164 -0
- package/routes/shop.js.map +1 -0
- package/routes/social.d.ts +22 -0
- package/routes/social.d.ts.map +1 -0
- package/routes/social.js +95 -0
- package/routes/social.js.map +1 -0
- package/routes/subchain.d.ts +18 -0
- package/routes/subchain.d.ts.map +1 -0
- package/routes/subchain.js +106 -0
- package/routes/subchain.js.map +1 -0
- package/routes/trustcoin.d.ts +17 -0
- package/routes/trustcoin.d.ts.map +1 -0
- package/routes/trustcoin.js +149 -0
- package/routes/trustcoin.js.map +1 -0
- package/routes/twofa.d.ts +7 -0
- package/routes/twofa.d.ts.map +1 -0
- package/routes/twofa.js +105 -0
- package/routes/twofa.js.map +1 -0
- package/routes/verification.d.ts +8 -0
- package/routes/verification.d.ts.map +1 -0
- package/routes/verification.js +234 -0
- package/routes/verification.js.map +1 -0
- package/routes/wallet.d.ts +4 -0
- package/routes/wallet.d.ts.map +1 -0
- package/routes/wallet.js +770 -0
- package/routes/wallet.js.map +1 -0
- package/run-auth.d.ts +8 -0
- package/run-auth.d.ts.map +1 -0
- package/run-auth.js +82 -0
- package/run-auth.js.map +1 -0
- package/run-p2p-message.d.ts +8 -0
- package/run-p2p-message.d.ts.map +1 -0
- package/run-p2p-message.js +82 -0
- package/run-p2p-message.js.map +1 -0
- package/run-relationship.d.ts +12 -0
- package/run-relationship.d.ts.map +1 -0
- package/run-relationship.js +182 -0
- package/run-relationship.js.map +1 -0
- package/run-unified.d.ts +13 -0
- package/run-unified.d.ts.map +1 -0
- package/run-unified.js +1067 -0
- package/run-unified.js.map +1 -0
- package/run.d.ts +12 -0
- package/run.d.ts.map +1 -0
- package/run.js +889 -0
- package/run.js.map +1 -0
- package/search/ranking.d.ts +55 -0
- package/search/ranking.d.ts.map +1 -0
- package/search/ranking.js +67 -0
- package/search/ranking.js.map +1 -0
- package/shipping/base.d.ts +15 -0
- package/shipping/base.d.ts.map +1 -0
- package/shipping/base.js +39 -0
- package/shipping/base.js.map +1 -0
- package/shipping/index.d.ts +19 -0
- package/shipping/index.d.ts.map +1 -0
- package/shipping/index.js +72 -0
- package/shipping/index.js.map +1 -0
- package/shipping/sf-express/index.d.ts +23 -0
- package/shipping/sf-express/index.d.ts.map +1 -0
- package/shipping/sf-express/index.js +71 -0
- package/shipping/sf-express/index.js.map +1 -0
- package/shipping/template/index.d.ts +20 -0
- package/shipping/template/index.d.ts.map +1 -0
- package/shipping/template/index.js +74 -0
- package/shipping/template/index.js.map +1 -0
- package/shipping/types.d.ts +71 -0
- package/shipping/types.d.ts.map +1 -0
- package/shipping/types.js +6 -0
- package/shipping/types.js.map +1 -0
- package/shipping/virtual/index.d.ts +19 -0
- package/shipping/virtual/index.d.ts.map +1 -0
- package/shipping/virtual/index.js +54 -0
- package/shipping/virtual/index.js.map +1 -0
- package/shipping/yto/index.d.ts +18 -0
- package/shipping/yto/index.d.ts.map +1 -0
- package/shipping/yto/index.js +59 -0
- package/shipping/yto/index.js.map +1 -0
- package/shipping/zto/index.d.ts +18 -0
- package/shipping/zto/index.d.ts.map +1 -0
- package/shipping/zto/index.js +59 -0
- package/shipping/zto/index.js.map +1 -0
- package/skills-lock.json +11 -0
- package/src/db/email-migrations.sql +31 -0
- package/src/db/oauth-migrations.sql +92 -0
- package/src/db/social-migrations.sql +94 -0
- package/src/db/store-migrations.sql +242 -0
- package/test-api-key-revoke.js +167 -0
- package/test-auth-register-ratelimit.js +132 -0
- package/test-auth-tv2.d.ts +2 -0
- package/test-auth-tv2.d.ts.map +1 -0
- package/test-auth-tv2.js +174 -0
- package/test-auth-tv2.js.map +1 -0
- package/test-canonsign-cross.d.ts +2 -0
- package/test-canonsign-cross.d.ts.map +1 -0
- package/test-canonsign-cross.js +32 -0
- package/test-canonsign-cross.js.map +1 -0
- package/test-chain-signer.js +127 -0
- package/test-env-truthy.js +50 -0
- package/test-onboard-contract.js +94 -0
- package/test-ops-console-boundary.js +147 -0
- package/test-oracle-glue.js +232 -0
- package/test-order-create-v394.js +358 -0
- package/test-order-intent.js +245 -0
- package/test-order-lifecycle-v394.js +528 -0
- package/test-p2p-message.d.ts +13 -0
- package/test-p2p-message.d.ts.map +1 -0
- package/test-p2p-message.js +106 -0
- package/test-p2p-message.js.map +1 -0
- package/test-relationship-chain.d.ts +13 -0
- package/test-relationship-chain.d.ts.map +1 -0
- package/test-relationship-chain.js +103 -0
- package/test-relationship-chain.js.map +1 -0
- package/test-runtime-data-path.js +217 -0
- package/test-seller-identity.js +74 -0
- package/test-signing-paths.js +104 -0
- package/test-token-v2.d.ts +2 -0
- package/test-token-v2.d.ts.map +1 -0
- package/test-token-v2.js +172 -0
- package/test-token-v2.js.map +1 -0
- package/test-wallet-auth-nonce.d.ts +12 -0
- package/test-wallet-auth-nonce.d.ts.map +1 -0
- package/test-wallet-auth-nonce.js +126 -0
- package/test-wallet-auth-nonce.js.map +1 -0
- package/test-wallet-submatch.d.ts +13 -0
- package/test-wallet-submatch.d.ts.map +1 -0
- package/test-wallet-submatch.js +86 -0
- package/test-wallet-submatch.js.map +1 -0
- package/tls/self-signed.d.ts +12 -0
- package/tls/self-signed.d.ts.map +1 -0
- package/tls/self-signed.js +63 -0
- package/tls/self-signed.js.map +1 -0
- package/tools/brand.d.ts +11 -0
- package/tools/brand.d.ts.map +1 -0
- package/tools/brand.js +75 -0
- package/tools/brand.js.map +1 -0
- package/tools/chainregistry.d.ts +18 -0
- package/tools/chainregistry.d.ts.map +1 -0
- package/tools/chainregistry.js +175 -0
- package/tools/chainregistry.js.map +1 -0
- package/tools/compliance.d.ts +14 -0
- package/tools/compliance.d.ts.map +1 -0
- package/tools/compliance.js +45 -0
- package/tools/compliance.js.map +1 -0
- package/tools/council.d.ts +17 -0
- package/tools/council.d.ts.map +1 -0
- package/tools/council.js +75 -0
- package/tools/council.js.map +1 -0
- package/tools/device.d.ts +13 -0
- package/tools/device.d.ts.map +1 -0
- package/tools/device.js +45 -0
- package/tools/device.js.map +1 -0
- package/tools/devreward.d.ts +15 -0
- package/tools/devreward.d.ts.map +1 -0
- package/tools/devreward.js +190 -0
- package/tools/devreward.js.map +1 -0
- package/tools/economy.d.ts +14 -0
- package/tools/economy.d.ts.map +1 -0
- package/tools/economy.js +172 -0
- package/tools/economy.js.map +1 -0
- package/tools/flowback.d.ts +14 -0
- package/tools/flowback.d.ts.map +1 -0
- package/tools/flowback.js +146 -0
- package/tools/flowback.js.map +1 -0
- package/tools/insurance.d.ts +13 -0
- package/tools/insurance.d.ts.map +1 -0
- package/tools/insurance.js +45 -0
- package/tools/insurance.js.map +1 -0
- package/tools/marketplace.d.ts +12 -0
- package/tools/marketplace.d.ts.map +1 -0
- package/tools/marketplace.js +124 -0
- package/tools/marketplace.js.map +1 -0
- package/tools/order.d.ts +12 -0
- package/tools/order.d.ts.map +1 -0
- package/tools/order.js +94 -0
- package/tools/order.js.map +1 -0
- package/tools/recovery.d.ts +14 -0
- package/tools/recovery.d.ts.map +1 -0
- package/tools/recovery.js +158 -0
- package/tools/recovery.js.map +1 -0
- package/tools/relay.d.ts +15 -0
- package/tools/relay.d.ts.map +1 -0
- package/tools/relay.js +152 -0
- package/tools/relay.js.map +1 -0
- package/tools/reputation.d.ts +20 -0
- package/tools/reputation.d.ts.map +1 -0
- package/tools/reputation.js +50 -0
- package/tools/reputation.js.map +1 -0
- package/tools/reputation_seller_credit.d.ts +16 -0
- package/tools/reputation_seller_credit.d.ts.map +1 -0
- package/tools/reputation_seller_credit.js +106 -0
- package/tools/reputation_seller_credit.js.map +1 -0
- package/tools/reward.d.ts +14 -0
- package/tools/reward.d.ts.map +1 -0
- package/tools/reward.js +76 -0
- package/tools/reward.js.map +1 -0
- package/tools/shop.d.ts +14 -0
- package/tools/shop.d.ts.map +1 -0
- package/tools/shop.js +95 -0
- package/tools/shop.js.map +1 -0
- package/tools/verification.d.ts +12 -0
- package/tools/verification.d.ts.map +1 -0
- package/tools/verification.js +89 -0
- package/tools/verification.js.map +1 -0
- package/types/store.d.ts +255 -0
- package/types/store.d.ts.map +1 -0
- package/types/store.js +19 -0
- package/types/store.js.map +1 -0
- package/utils/aes-gcm.d.ts +63 -0
- package/utils/aes-gcm.d.ts.map +1 -0
- package/utils/aes-gcm.js +179 -0
- package/utils/aes-gcm.js.map +1 -0
- package/utils/api-response.d.ts +51 -0
- package/utils/api-response.d.ts.map +1 -0
- package/utils/api-response.js +65 -0
- package/utils/api-response.js.map +1 -0
- package/utils/base32.d.ts +5 -0
- package/utils/base32.d.ts.map +1 -0
- package/utils/base32.js +20 -0
- package/utils/base32.js.map +1 -0
- package/utils/crypto.d.ts +77 -0
- package/utils/crypto.d.ts.map +1 -0
- package/utils/crypto.js +164 -0
- package/utils/crypto.js.map +1 -0
- package/utils/encryption.d.ts +81 -0
- package/utils/encryption.d.ts.map +1 -0
- package/utils/encryption.js +247 -0
- package/utils/encryption.js.map +1 -0
- package/utils/env.js +20 -0
- package/utils/jwt.d.ts +110 -0
- package/utils/jwt.d.ts.map +1 -0
- package/utils/jwt.js +275 -0
- package/utils/jwt.js.map +1 -0
- package/utils/qrcode-reader.d.ts +22 -0
- package/utils/qrcode-reader.d.ts.map +1 -0
- package/utils/qrcode-reader.js +90 -0
- package/utils/qrcode-reader.js.map +1 -0
- package/utils/qrcode.d.ts +26 -0
- package/utils/qrcode.d.ts.map +1 -0
- package/utils/qrcode.js +92 -0
- package/utils/qrcode.js.map +1 -0
- package/utils/totp.d.ts +3 -0
- package/utils/totp.d.ts.map +1 -0
- package/utils/totp.js +58 -0
- package/utils/totp.js.map +1 -0
- package/utils/two-factor-auth.d.ts +16 -0
- package/utils/two-factor-auth.d.ts.map +1 -0
- package/utils/two-factor-auth.js +150 -0
- package/utils/two-factor-auth.js.map +1 -0
- package/verifyer/hsm.d.ts +70 -0
- package/verifyer/hsm.d.ts.map +1 -0
- package/verifyer/hsm.js +482 -0
- package/verifyer/hsm.js.map +1 -0
- package/verifyer/index.d.ts +81 -0
- package/verifyer/index.d.ts.map +1 -0
- package/verifyer/index.js +372 -0
- package/verifyer/index.js.map +1 -0
- package/ws/peer-monitor-broadcaster.d.ts +24 -0
- package/ws/peer-monitor-broadcaster.d.ts.map +1 -0
- package/ws/peer-monitor-broadcaster.js +56 -0
- package/ws/peer-monitor-broadcaster.js.map +1 -0
|
@@ -0,0 +1,603 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* c5-glue.js — oracle 侧胶水: C2 引导金发放 + E6 积分结算 (v3.9.3 联调批)
|
|
4
|
+
*
|
|
5
|
+
* 跑在服务端 oracle 进程内 (oracle-sync.js 挂载), authority/oracle 私钥绝不进商家机。
|
|
6
|
+
* 签名复用 routes/chain-writes.js 的 signAndBroadcast (SIGN_MODE 语义不变:
|
|
7
|
+
* .123 上默认走 trustchaind CLI keyring, 配了 ORACLE_MNEMONIC 则 JS 直签)。
|
|
8
|
+
*
|
|
9
|
+
* C2 引导金 (实名通过 → 发 100 TCT):
|
|
10
|
+
* 步骤1 MsgSubmitVerification 的 signer=owner (商户本人, keeper 无代提交通道) —
|
|
11
|
+
* 由商家后端 JS 直签提交 (routes/onboard.js /onboard/submit-verification);
|
|
12
|
+
* oracle 侧只负责 步骤2 MsgApproveVerification (emergencyAuthority) +
|
|
13
|
+
* 步骤3 MsgDisburseBootstrap (authority, credential_hash 幂等一商户一次)。
|
|
14
|
+
* 触发: admin POST /api/oracle/bootstrap-grant {recipient, credential_hash?}
|
|
15
|
+
* (全仓库暂无微信审核状态轮询 — 摸底结论, 信号源接入后改为自动入队)。
|
|
16
|
+
*
|
|
17
|
+
* E6 积分 (支付事实 CONFIRMED → 单笔 + 里程碑):
|
|
18
|
+
* tick 轮询链上 serviceprovider facts (status=CONFIRMED) →
|
|
19
|
+
* MsgGrantCredits{issuer=oracle, recipient, amount=链上 params 读取, reason_kind, ref_id}
|
|
20
|
+
* 幂等: 链上 reason_kind+ref_id + 本地台账 PRIMARY KEY 双层。
|
|
21
|
+
* 买家/卖家地址: order_ref → 本地 agent_pay_sessions.chain_order_id → 链上 x/order 订单;
|
|
22
|
+
* 查不到买家 → 只跳过买家奖励并记录原因, 不编造地址。
|
|
23
|
+
* 额度守护: params.monthly_quota vs 本地台账本月已发, 超限跳过并告警。
|
|
24
|
+
*
|
|
25
|
+
* N13 注册 (引导金发放前置, 2026-09-23): trustcoin.Account 未注册的商户上架/下单被链拒
|
|
26
|
+
* (冒烟实测 "buyer must register a trustcoin account")。发放前先查链上 trustcoin 账户,
|
|
27
|
+
* 无则发 MsgRegisterAccount{creator=recipient, seller, CN}。
|
|
28
|
+
* ⚠️ 链侧 signer=creator 强制 (proto 注解 + SDK v0.53 ante; 2026-09-23 .123 实测
|
|
29
|
+
* "tx intended signer does not match") — oracle 代签必被拒, 只有持钥方本人能注册;
|
|
30
|
+
* 该错误入 last_error 后停试, 等商家后端自助注册流补位 (链侧放开前 N13 停在 failed)。
|
|
31
|
+
*
|
|
32
|
+
* N15 feegrant 代扣 gas (2026-09-23, xiaomu 拍板方案 A): 新商户 0 余额付不了手续费,
|
|
33
|
+
* 注册/KYC 卡死 (净室验收 oracle 人工垫 2 TCT)。审批通过 (MsgApproveVerification)
|
|
34
|
+
* 后 oracle 以 emergency-key 给商户发 AllowedMsgAllowance (防薅三道闸):
|
|
35
|
+
* 1. 触发点=审批后 (身份生成阶段不发);
|
|
36
|
+
* 2. 白名单四类 msg: 注册 / KYC 提交 / 下单 / 确认收货;
|
|
37
|
+
* 3. 总额 2 TCT + 周期 60s 内 ≤0.2 TCT (trustchaind tx feegrant grant --help 实测形状)。
|
|
38
|
+
* 幂等: LCD allowances 查已有 grant 直接跳过; 失败 warn 不阻塞后续注册/发放 (状态机无感)。
|
|
39
|
+
* 商户侧: chain-signer/chain-writes 走 FEE_GRANTER_ADDR 代付 (无 grant 自动回退自付)。
|
|
40
|
+
*
|
|
41
|
+
* N14 settle crank (2026-09-23): CONFIRMED 订单过 dispute_window (链上 order params,
|
|
42
|
+
* 默认 259200s=3 天) 后需 MsgSettleOrder 才 settled=true, 否则货款/质押/担保永卡在途。
|
|
43
|
+
* 每 tick 扫描 (无全局订单列表: 本地台账 chain_order_id + 链上 providers 的
|
|
44
|
+
* by-seller 订单列表), 到期单发 MsgSettleOrder{caller=oracle} (permissionless,
|
|
45
|
+
* 签名者=caller 即可); 每 tick 最多 5 单; 已 settled/非 CONFIRMED 的链上返回按完成处理。
|
|
46
|
+
*/
|
|
47
|
+
const crypto = require("crypto");
|
|
48
|
+
const chainWrites = require("../routes/chain-writes");
|
|
49
|
+
|
|
50
|
+
// 链上模块未上线 (v3.9.3 前) 的特征: CLI 本地解码 / CheckTx / DeliverTx / LCD 404 都覆盖
|
|
51
|
+
const MODULE_NOT_LIVE_RE = /unable to resolve type URL|unknown message type|no concrete type|unrecognized message|cannot unpack|no handler exists|not found|unknown query path/i;
|
|
52
|
+
|
|
53
|
+
// N13: trustcoin "账户已存在" (重复注册按成功) / "signer=creator 强制" (oracle 代签被拒, 停试)
|
|
54
|
+
const ALREADY_REGISTERED_RE = /account already exists|already registered/i;
|
|
55
|
+
const SIGNER_FORBIDDEN_RE = /intended signer does not match|signature verification failed|invalid signer/i;
|
|
56
|
+
|
|
57
|
+
// N14: settle 幂等 (已结算/状态已变/订单不存在 → 按完成处理, 不再重试)
|
|
58
|
+
const SETTLE_DONE_RE = /already settled|not in confirmed status|order not found/i;
|
|
59
|
+
|
|
60
|
+
function sha256Hex(s) {
|
|
61
|
+
return crypto.createHash("sha256").update(String(s)).digest("hex");
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function nowSec() { return Math.floor(Date.now() / 1000); }
|
|
65
|
+
|
|
66
|
+
/** oracle 签名配置: 复用 chain-writes cfg(), keyName 可被 ORACLE_CHAIN_KEY_NAME 覆盖 */
|
|
67
|
+
function oracleCfg() {
|
|
68
|
+
const c = chainWrites.cfg();
|
|
69
|
+
return { ...c, keyName: process.env.ORACLE_CHAIN_KEY_NAME || c.keyName };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** 默认 LCD GET (返回 null 表示失败/不存在)。注意: 不能是 async 函数, 否则返回的是 Promise */
|
|
73
|
+
function defaultLcdGet(lcdUrl) {
|
|
74
|
+
return async (p) => {
|
|
75
|
+
try {
|
|
76
|
+
const resp = await fetch(lcdUrl + p, { signal: AbortSignal.timeout(10000) });
|
|
77
|
+
if (!resp.ok) return null;
|
|
78
|
+
return await resp.json();
|
|
79
|
+
} catch (_) { return null; }
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** 默认发链: 签名地址 → LCD 查序号 → signAndBroadcast (sequence mismatch 重查重试一次) */
|
|
84
|
+
function defaultSendTx(c) {
|
|
85
|
+
return async (messages) => {
|
|
86
|
+
const addr = await chainWrites.keyAddress(c);
|
|
87
|
+
let account = await chainWrites.queryAccount(c, addr);
|
|
88
|
+
try {
|
|
89
|
+
return await chainWrites.signAndBroadcast(c, messages, account);
|
|
90
|
+
} catch (e) {
|
|
91
|
+
if (!(e instanceof chainWrites.SequenceMismatchError)) throw e;
|
|
92
|
+
console.warn("[oracle-glue] account sequence mismatch, 重查重试一次");
|
|
93
|
+
account = await chainWrites.queryAccount(c, addr);
|
|
94
|
+
return await chainWrites.signAndBroadcast(c, messages, account);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function ensureTables(db) {
|
|
100
|
+
db.exec(`
|
|
101
|
+
CREATE TABLE IF NOT EXISTS oracle_bootstrap_grants (
|
|
102
|
+
credential_hash TEXT PRIMARY KEY,
|
|
103
|
+
recipient TEXT NOT NULL,
|
|
104
|
+
verification_id TEXT DEFAULT '',
|
|
105
|
+
approve_txhash TEXT DEFAULT '',
|
|
106
|
+
disburse_txhash TEXT DEFAULT '',
|
|
107
|
+
status TEXT NOT NULL DEFAULT 'pending',
|
|
108
|
+
-- pending → awaiting_verification → approving → registering → disbursing → done / waiting_module / failed
|
|
109
|
+
-- (registering/failed: N13 注册步; signer=creator 链侧强制时 oracle 代签停在 failed, 见文件头 N13)
|
|
110
|
+
last_error TEXT DEFAULT '',
|
|
111
|
+
created_at INTEGER NOT NULL,
|
|
112
|
+
updated_at INTEGER NOT NULL
|
|
113
|
+
);
|
|
114
|
+
CREATE TABLE IF NOT EXISTS oracle_credit_grants (
|
|
115
|
+
reason_kind TEXT NOT NULL,
|
|
116
|
+
ref_id TEXT NOT NULL,
|
|
117
|
+
recipient TEXT NOT NULL,
|
|
118
|
+
amount TEXT NOT NULL,
|
|
119
|
+
txhash TEXT DEFAULT '',
|
|
120
|
+
status TEXT NOT NULL DEFAULT 'pending', -- pending/done/skipped/quota_skipped/failed
|
|
121
|
+
note TEXT DEFAULT '',
|
|
122
|
+
created_at INTEGER NOT NULL,
|
|
123
|
+
updated_at INTEGER NOT NULL,
|
|
124
|
+
PRIMARY KEY (reason_kind, ref_id)
|
|
125
|
+
);
|
|
126
|
+
`);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* 创建胶水实例。deps 可注入 (离线测试): { cfg, lcdGet, sendTx, logger }
|
|
131
|
+
*/
|
|
132
|
+
function createOracleGlue(deps) {
|
|
133
|
+
const db = deps.db;
|
|
134
|
+
const cfg = deps.cfg || oracleCfg();
|
|
135
|
+
const lcdGet = deps.lcdGet || defaultLcdGet(cfg.lcdUrl);
|
|
136
|
+
const sendTx = deps.sendTx || defaultSendTx(cfg);
|
|
137
|
+
const log = deps.logger || console.log;
|
|
138
|
+
const warn = deps.warn || console.warn;
|
|
139
|
+
ensureTables(db);
|
|
140
|
+
|
|
141
|
+
// ============================== C2 引导金 ==============================
|
|
142
|
+
|
|
143
|
+
/** 入队 (幂等: credential_hash 已存在 → 返回现状) */
|
|
144
|
+
function enqueueBootstrapGrant({ recipient, credentialHash }) {
|
|
145
|
+
const ch = credentialHash || sha256Hex(recipient);
|
|
146
|
+
const existing = db.prepare("SELECT * FROM oracle_bootstrap_grants WHERE credential_hash = ?").get(ch);
|
|
147
|
+
if (existing) return { enqueued: false, status: existing.status, credential_hash: ch };
|
|
148
|
+
db.prepare("INSERT INTO oracle_bootstrap_grants (credential_hash, recipient, status, created_at, updated_at) VALUES (?,?,?,?,?)")
|
|
149
|
+
.run(ch, recipient, "pending", nowSec(), nowSec());
|
|
150
|
+
log(`[oracle-glue] bootstrap 入队 recipient=${recipient} credential_hash=${ch.slice(0, 12)}...`);
|
|
151
|
+
return { enqueued: true, status: "pending", credential_hash: ch };
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** 查链上实名记录 (返回 {verification_id, status} 或 null) */
|
|
155
|
+
async function findVerification(recipient) {
|
|
156
|
+
const j = await lcdGet(`/oxiaom/trustchain/verification/v1/owner/${recipient}`);
|
|
157
|
+
const list = j && (j.verifications || j.verification ? [].concat(j.verifications || j.verification) : []);
|
|
158
|
+
if (!list || list.length === 0) return null;
|
|
159
|
+
const v = list[0];
|
|
160
|
+
return { verification_id: String(v.verification_id || v.id || ""), status: String(v.status || "") };
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** 查链上 trustcoin.Account (N13; 未注册/LCD 不可达都返回 null, 终审交给链上幂等) */
|
|
164
|
+
async function findTrustcoinAccount(addr) {
|
|
165
|
+
const j = await lcdGet(`/oxiaom/trustchain/trustcoin/v1/accounts/${addr}`);
|
|
166
|
+
return (j && j.account) || null;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// N15 feegrant 防薅参数 (xiaomu 2026-09-23 拍板): 总额 2 TCT 封顶 + 60s 内 ≤0.2 TCT
|
|
170
|
+
const FEEGRANT_SPEND_LIMIT = "2000000"; // utct (2 TCT)
|
|
171
|
+
const FEEGRANT_PERIOD_SECS = 60;
|
|
172
|
+
const FEEGRANT_PERIOD_LIMIT = "200000"; // utct (0.2 TCT / 60s)
|
|
173
|
+
const FEEGRANT_ALLOWED_MSGS = [
|
|
174
|
+
"/trustchain.trustcoin.v1.MsgRegisterAccount", // 自助注册
|
|
175
|
+
"/trustchain.verification.v1.MsgSubmitVerification", // KYC 提交
|
|
176
|
+
"/trustchain.order.v1.MsgCreateOrder", // 下单
|
|
177
|
+
"/trustchain.order.v1.MsgConfirmOrder", // 确认收货
|
|
178
|
+
];
|
|
179
|
+
|
|
180
|
+
/** 查 grantee 名下已有 feegrant (N15 幂等用; 无/LCD 不可达返回 null) */
|
|
181
|
+
async function findFeegrant(grantee) {
|
|
182
|
+
const j = await lcdGet(`/cosmos/feegrant/v1beta1/allowances/${grantee}`);
|
|
183
|
+
const list = (j && j.allowances) || [];
|
|
184
|
+
return list.length > 0 ? list[0] : null;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** N15: 审批通过后发 feegrant (MsgGrantAllowance, granter=oracle 自己签)。
|
|
188
|
+
* 已有 grant → 跳过; 失败 → warn 返回 false, 不阻塞后续注册/发放 (下轮重试)。 */
|
|
189
|
+
async function grantFeegrant(recipient, oracleAddr) {
|
|
190
|
+
try {
|
|
191
|
+
if (await findFeegrant(recipient)) {
|
|
192
|
+
log(`[oracle-glue] N15 feegrant 已存在, 跳过 grantee=${recipient}`);
|
|
193
|
+
return true;
|
|
194
|
+
}
|
|
195
|
+
const r = await sendTx([{
|
|
196
|
+
"@type": "/cosmos.feegrant.v1beta1.MsgGrantAllowance",
|
|
197
|
+
granter: oracleAddr,
|
|
198
|
+
grantee: recipient,
|
|
199
|
+
allowance: {
|
|
200
|
+
"@type": "/cosmos.feegrant.v1beta1.AllowedMsgAllowance",
|
|
201
|
+
allowance: {
|
|
202
|
+
"@type": "/cosmos.feegrant.v1beta1.PeriodicAllowance",
|
|
203
|
+
basic: { spend_limit: [{ denom: "utct", amount: FEEGRANT_SPEND_LIMIT }], expiration: null },
|
|
204
|
+
period: `${FEEGRANT_PERIOD_SECS}s`,
|
|
205
|
+
period_spend_limit: [{ denom: "utct", amount: FEEGRANT_PERIOD_LIMIT }],
|
|
206
|
+
},
|
|
207
|
+
allowed_messages: FEEGRANT_ALLOWED_MSGS,
|
|
208
|
+
},
|
|
209
|
+
}]);
|
|
210
|
+
if (r.code !== 0) {
|
|
211
|
+
if (/allowance exists|already exists/i.test(r.raw_log)) {
|
|
212
|
+
log(`[oracle-glue] N15 feegrant 已存在 (链上幂等命中) grantee=${recipient}`);
|
|
213
|
+
return true;
|
|
214
|
+
}
|
|
215
|
+
warn(`[oracle-glue] N15 feegrant 发放失败 grantee=${recipient} code=${r.code}: ${String(r.raw_log).slice(0, 200)} (下轮重试)`);
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
log(`[oracle-glue] N15 feegrant 已发放 grantee=${recipient} 白名单=${FEEGRANT_ALLOWED_MSGS.length}类 总额=${FEEGRANT_SPEND_LIMIT}utct 周期=${FEEGRANT_PERIOD_SECS}s/${FEEGRANT_PERIOD_LIMIT}utct tx=${r.txhash}`);
|
|
219
|
+
return true;
|
|
220
|
+
} catch (e) {
|
|
221
|
+
warn(`[oracle-glue] N15 feegrant 异常 grantee=${recipient}: ${e.message} (下轮重试)`);
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** 单条 bootstrap grant 推进一步 (每 tick 调用; 失败留状态下次重试) */
|
|
227
|
+
async function stepBootstrapGrant(row, oracleAddr) {
|
|
228
|
+
const upd = (fields) => {
|
|
229
|
+
db.prepare(`UPDATE oracle_bootstrap_grants SET ${Object.keys(fields).map((k) => k + "=?").join(", ")}, updated_at=? WHERE credential_hash=?`)
|
|
230
|
+
.run(...Object.values(fields), nowSec(), row.credential_hash);
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
// 步骤2 前置: 找链上实名记录
|
|
234
|
+
if (!row.verification_id) {
|
|
235
|
+
const v = await findVerification(row.recipient);
|
|
236
|
+
if (!v) {
|
|
237
|
+
upd({ status: "awaiting_verification", last_error: "链上暂无该商户的实名提交 (等商家后端 submit-verification)" });
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
upd({ verification_id: v.verification_id });
|
|
241
|
+
row.verification_id = v.verification_id;
|
|
242
|
+
row._chainStatus = v.status;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// 步骤2: 审批 (已 APPROVED 则跳过)
|
|
246
|
+
if (!row.approve_txhash) {
|
|
247
|
+
const v = await findVerification(row.recipient);
|
|
248
|
+
if (v && /APPROVED/i.test(v.status)) {
|
|
249
|
+
upd({ approve_txhash: "(already-approved-on-chain)" });
|
|
250
|
+
row.approve_txhash = "(already-approved-on-chain)";
|
|
251
|
+
} else {
|
|
252
|
+
upd({ status: "approving" });
|
|
253
|
+
const r = await sendTx([{
|
|
254
|
+
"@type": "/trustchain.verification.v1.MsgApproveVerification",
|
|
255
|
+
approver: oracleAddr,
|
|
256
|
+
verification_id: row.verification_id,
|
|
257
|
+
expires_at: "0",
|
|
258
|
+
}]);
|
|
259
|
+
if (r.code !== 0) {
|
|
260
|
+
if (MODULE_NOT_LIVE_RE.test(r.raw_log)) { upd({ status: "waiting_module", last_error: "链上 verification 模块未上线 (等 v3.9.3)" }); return; }
|
|
261
|
+
upd({ status: "failed", last_error: `approve code=${r.code}: ${String(r.raw_log).slice(0, 200)}` });
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
upd({ approve_txhash: r.txhash });
|
|
265
|
+
row.approve_txhash = r.txhash;
|
|
266
|
+
log(`[oracle-glue] 实名审批通过 vid=${row.verification_id} tx=${r.txhash}`);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// 步骤2.4 (N15): 审批已过 → 发 feegrant (商户此后注册/KYC 的手续费由 oracle 代付)。
|
|
271
|
+
// 失败不阻塞: 注册/发放继续, 下轮 tick 对未 done 行重试。
|
|
272
|
+
if (!row.disburse_txhash) {
|
|
273
|
+
await grantFeegrant(row.recipient, oracleAddr);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// 步骤2.5 (N13): trustcoin 账户注册 — 未注册商户收到引导金也无法上架/下单。
|
|
277
|
+
// 幂等: 链上已有账户 (LCD) 直接跳过; LCD 不可达也照发, 链上 "already exists" 按成功处理。
|
|
278
|
+
if (!row.disburse_txhash) {
|
|
279
|
+
const acc = await findTrustcoinAccount(row.recipient);
|
|
280
|
+
if (!acc) {
|
|
281
|
+
// 已知 signer=creator 强制 (上轮已拒): 停在 failed 等持钥方自助注册, 不再重试、不发放
|
|
282
|
+
if (SIGNER_FORBIDDEN_RE.test(row.last_error || "")) return;
|
|
283
|
+
upd({ status: "registering" });
|
|
284
|
+
let r;
|
|
285
|
+
try {
|
|
286
|
+
r = await sendTx([{
|
|
287
|
+
"@type": "/trustchain.trustcoin.v1.MsgRegisterAccount",
|
|
288
|
+
creator: row.recipient,
|
|
289
|
+
role: "seller",
|
|
290
|
+
region: "CN",
|
|
291
|
+
}]);
|
|
292
|
+
} catch (e) {
|
|
293
|
+
// CLI 通道在本地 sign 步就拒 ("intended signer does not match"), 到不了链上 —
|
|
294
|
+
// 链侧 signer=creator 强制, oracle 代签不可行: 停在 failed 不再重试 (文件头 N13)。
|
|
295
|
+
const raw = `${e.message} ${e.stderr || ""}`;
|
|
296
|
+
if (SIGNER_FORBIDDEN_RE.test(raw)) {
|
|
297
|
+
// last_error 内嵌 "intended signer does not match" 标记短语 — 防重试 guard 靠它匹配
|
|
298
|
+
upd({ status: "failed", last_error: `register 需 recipient 本人签名 (oracle 代签被链拒: intended signer does not match): ${String(e.message).slice(0, 120)}` });
|
|
299
|
+
warn(`[oracle-glue] ⚠️ N13 register 被链拒 recipient=${row.recipient}: 链上要求 creator 本人签名, oracle 代签不可行 — 该单停在 failed, 等商家后端自助注册 (guard 防重试)`);
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
throw e;
|
|
303
|
+
}
|
|
304
|
+
if (r.code !== 0) {
|
|
305
|
+
if (ALREADY_REGISTERED_RE.test(r.raw_log)) {
|
|
306
|
+
log(`[oracle-glue] trustcoin 账户已注册 (按成功处理) recipient=${row.recipient}`);
|
|
307
|
+
} else if (MODULE_NOT_LIVE_RE.test(r.raw_log)) {
|
|
308
|
+
upd({ status: "waiting_module", last_error: "链上 trustcoin 模块未上线 (等 v3.9.3)" });
|
|
309
|
+
return;
|
|
310
|
+
} else if (SIGNER_FORBIDDEN_RE.test(r.raw_log)) {
|
|
311
|
+
upd({ status: "failed", last_error: `register 需 recipient 本人签名 (oracle 代签被链拒): ${String(r.raw_log).slice(0, 160)}` });
|
|
312
|
+
return;
|
|
313
|
+
} else {
|
|
314
|
+
upd({ status: "failed", last_error: `register code=${r.code}: ${String(r.raw_log).slice(0, 200)}` });
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
} else {
|
|
318
|
+
log(`[oracle-glue] trustcoin 账户已注册 recipient=${row.recipient}`);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// 步骤3: 发放引导金 (链上 credential_hash 幂等, duplicate 也算成功)
|
|
324
|
+
upd({ status: "disbursing" });
|
|
325
|
+
const r = await sendTx([{
|
|
326
|
+
"@type": "/trustchain.subchain.v1.MsgDisburseBootstrap",
|
|
327
|
+
authority: oracleAddr,
|
|
328
|
+
recipient: row.recipient,
|
|
329
|
+
credential_hash: row.credential_hash,
|
|
330
|
+
}]);
|
|
331
|
+
if (r.code !== 0) {
|
|
332
|
+
if (MODULE_NOT_LIVE_RE.test(r.raw_log)) { upd({ status: "waiting_module", last_error: "链上 subchain 模块未上线 (等 v3.9.3)" }); return; }
|
|
333
|
+
upd({ status: "failed", last_error: `disburse code=${r.code}: ${String(r.raw_log).slice(0, 200)}` });
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
upd({ disburse_txhash: r.txhash, status: "done", last_error: "" });
|
|
337
|
+
log(`[oracle-glue] 引导金已发放 recipient=${row.recipient} tx=${r.txhash}`);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// ============================== E6 积分结算 ==============================
|
|
341
|
+
|
|
342
|
+
/** 链上 economy params (奖励金额/月度额度, 不读缓存, 每次结算现查) */
|
|
343
|
+
async function getEconomyParams() {
|
|
344
|
+
const j = await lcdGet("/oxiaom/trustchain/economy/v1/params");
|
|
345
|
+
const p = j && j.params;
|
|
346
|
+
if (!p) return null;
|
|
347
|
+
const num = (k, def) => {
|
|
348
|
+
const n = Number(p[k]);
|
|
349
|
+
return Number.isFinite(n) && n > 0 ? n : def;
|
|
350
|
+
};
|
|
351
|
+
return {
|
|
352
|
+
rewardSellerPerOrder: num("reward_seller_per_order", 20),
|
|
353
|
+
rewardBuyerPerOrder: num("reward_buyer_per_order", 10),
|
|
354
|
+
rewardFirstOrder: num("reward_first_order", 500),
|
|
355
|
+
rewardTenOrders: num("reward_ten_orders", 800),
|
|
356
|
+
monthlyQuota: num("monthly_quota", 100000),
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/** 本月已发额度 (本地台账 done 行求和; 额度守护数据源) */
|
|
361
|
+
function monthlyUsed() {
|
|
362
|
+
const monthStart = Math.floor(new Date(new Date().getFullYear(), new Date().getMonth(), 1).getTime() / 1000);
|
|
363
|
+
const r = db.prepare("SELECT COALESCE(SUM(CAST(amount AS INTEGER)),0) AS used FROM oracle_credit_grants WHERE status='done' AND created_at >= ?").get(monthStart);
|
|
364
|
+
return Number(r.used) || 0;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/** 记一条台账 (幂等: 同 reason_kind+ref_id 已存在 → 返回 false) */
|
|
368
|
+
function ledgerGrant(reasonKind, refId, recipient, amount, status, note) {
|
|
369
|
+
const r = db.prepare("INSERT OR IGNORE INTO oracle_credit_grants (reason_kind, ref_id, recipient, amount, status, note, created_at, updated_at) VALUES (?,?,?,?,?,?,?,?)")
|
|
370
|
+
.run(reasonKind, refId, recipient, String(amount), status, note || "", nowSec(), nowSec());
|
|
371
|
+
return r.changes > 0;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/** order_ref → {seller, buyer} (本地会话表 → 链上订单; 查不到返回 null + 原因) */
|
|
375
|
+
async function resolveOrderParties(orderRef) {
|
|
376
|
+
const sess = db.prepare("SELECT chain_order_id FROM agent_pay_sessions WHERE order_ref = ?").get(orderRef);
|
|
377
|
+
if (!sess || !sess.chain_order_id) {
|
|
378
|
+
return { seller: null, buyer: null, reason: `order_ref=${orderRef} 无本地会话或链上单号` };
|
|
379
|
+
}
|
|
380
|
+
const j = await lcdGet(`/oxiaom/trustchain/order/v1/orders/${sess.chain_order_id}`);
|
|
381
|
+
const o = j && (j.order || j.Order);
|
|
382
|
+
if (!o || !o.seller) {
|
|
383
|
+
return { seller: null, buyer: null, reason: `链上订单 ${sess.chain_order_id} 查询失败` };
|
|
384
|
+
}
|
|
385
|
+
return { seller: o.seller, buyer: o.buyer || null, reason: o.buyer ? "" : "链上订单无买家地址 (游客单)" };
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/** 单笔 CONFIRMED 事实的结算 (幂等, 额度守护) */
|
|
389
|
+
async function settleFact(fact, params, oracleAddr) {
|
|
390
|
+
const orderRef = String(fact.order_ref || "");
|
|
391
|
+
if (!orderRef) return;
|
|
392
|
+
// 已结算/已跳过 → 幂等短路
|
|
393
|
+
if (db.prepare("SELECT 1 FROM oracle_credit_grants WHERE reason_kind='order_confirmed' AND ref_id=?").get(orderRef)) return;
|
|
394
|
+
|
|
395
|
+
const parties = await resolveOrderParties(orderRef);
|
|
396
|
+
const grants = [];
|
|
397
|
+
if (!parties.seller) {
|
|
398
|
+
// 订单上下文缺失: 买卖双方都跳过, 如实记录, 不编造地址
|
|
399
|
+
ledgerGrant("order_confirmed", orderRef, "(unknown)", "0", "skipped", parties.reason);
|
|
400
|
+
warn(`[oracle-glue] E6 跳过 order_ref=${orderRef}: ${parties.reason}`);
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
grants.push({ recipient: parties.seller, amount: params.rewardSellerPerOrder, kind: "order_confirmed", refId: orderRef, role: "seller" });
|
|
404
|
+
if (parties.buyer) {
|
|
405
|
+
grants.push({ recipient: parties.buyer, amount: params.rewardBuyerPerOrder, kind: "order_confirmed", refId: orderRef + ":buyer", role: "buyer" });
|
|
406
|
+
} else {
|
|
407
|
+
ledgerGrant("order_confirmed", orderRef + ":buyer", "(unknown)", "0", "skipped", `买家地址不可得 (${parties.reason}), 买家奖励跳过`);
|
|
408
|
+
warn(`[oracle-glue] E6 order_ref=${orderRef} 买家奖励跳过: ${parties.reason}`);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
// 里程碑: 卖家累计已确认单量 (本地台账 done 的 order_confirmed 卖家行数 + 本笔)
|
|
412
|
+
const sellerDone = db.prepare("SELECT COUNT(*) AS n FROM oracle_credit_grants WHERE reason_kind='order_confirmed' AND recipient=? AND status='done'").get(parties.seller).n;
|
|
413
|
+
const totalOrders = Number(sellerDone) + grants.filter((g) => g.role === "seller").length;
|
|
414
|
+
if (totalOrders === 1) grants.push({ recipient: parties.seller, amount: params.rewardFirstOrder, kind: "milestone", refId: `first:${parties.seller}`, role: "milestone" });
|
|
415
|
+
if (totalOrders === 10) grants.push({ recipient: parties.seller, amount: params.rewardTenOrders, kind: "milestone", refId: `ten:${parties.seller}`, role: "milestone" });
|
|
416
|
+
|
|
417
|
+
// 额度守护: 本月已用 + 本批 > 链上月度额度 → 全批跳过并告警
|
|
418
|
+
const batchTotal = grants.reduce((s, g) => s + g.amount, 0);
|
|
419
|
+
const used = monthlyUsed();
|
|
420
|
+
if (used + batchTotal > params.monthlyQuota) {
|
|
421
|
+
for (const g of grants) {
|
|
422
|
+
ledgerGrant(g.kind === "milestone" ? "milestone" : "order_confirmed", g.refId, g.recipient, g.amount, "quota_skipped", `月度额度超限 (已用 ${used} + 本批 ${batchTotal} > 配额 ${params.monthlyQuota})`);
|
|
423
|
+
}
|
|
424
|
+
warn(`[oracle-glue] ⚠️ E6 额度告警: order_ref=${orderRef} 跳过 (本月已用 ${used}/${params.monthlyQuota}, 本批 ${batchTotal}) — 请检查额度或异常放量`);
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
for (const g of grants) {
|
|
429
|
+
const reasonKind = g.kind === "milestone" ? "milestone" : "order_confirmed";
|
|
430
|
+
// 链上幂等键 reason_kind+ref_id; 台账已存在说明已发/已跳过
|
|
431
|
+
if (!ledgerGrant(reasonKind, g.refId, g.recipient, g.amount, "pending", "")) continue;
|
|
432
|
+
const r = await sendTx([{
|
|
433
|
+
"@type": "/trustchain.economy.v1.MsgGrantCredits",
|
|
434
|
+
issuer: oracleAddr,
|
|
435
|
+
recipient: g.recipient,
|
|
436
|
+
amount: String(g.amount),
|
|
437
|
+
reason_kind: reasonKind,
|
|
438
|
+
ref_id: g.refId,
|
|
439
|
+
}]);
|
|
440
|
+
if (r.code !== 0) {
|
|
441
|
+
const status = MODULE_NOT_LIVE_RE.test(r.raw_log) ? "pending" : "failed";
|
|
442
|
+
db.prepare("UPDATE oracle_credit_grants SET status=?, note=?, updated_at=? WHERE reason_kind=? AND ref_id=?")
|
|
443
|
+
.run(status, `code=${r.code}: ${String(r.raw_log).slice(0, 200)}`, nowSec(), reasonKind, g.refId);
|
|
444
|
+
if (status === "pending") warn(`[oracle-glue] economy 模块未上线, ${reasonKind}/${g.refId} 留下次重试`);
|
|
445
|
+
continue;
|
|
446
|
+
}
|
|
447
|
+
db.prepare("UPDATE oracle_credit_grants SET status='done', txhash=?, updated_at=? WHERE reason_kind=? AND ref_id=?")
|
|
448
|
+
.run(r.txhash, nowSec(), reasonKind, g.refId);
|
|
449
|
+
log(`[oracle-glue] E6 已发放 ${reasonKind}/${g.refId} → ${g.recipient} +${g.amount} (tx=${r.txhash})`);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/** E6 一轮: 拉 CONFIRMED 事实 → 逐笔结算 */
|
|
454
|
+
async function settleConfirmedFacts(oracleAddr) {
|
|
455
|
+
const params = await getEconomyParams();
|
|
456
|
+
if (!params) { warn("[oracle-glue] economy params 查询失败 (模块未上线?), 本轮 E6 跳过"); return; }
|
|
457
|
+
const pj = await lcdGet("/oxiaom/trustchain/serviceprovider/v1/providers");
|
|
458
|
+
const providers = pj && (pj.providers || pj.service_providers) || [];
|
|
459
|
+
for (const p of providers) {
|
|
460
|
+
const paddr = typeof p === "string" ? p : p.address;
|
|
461
|
+
if (!paddr) continue;
|
|
462
|
+
const fj = await lcdGet(`/oxiaom/trustchain/serviceprovider/v1/facts/${paddr}`);
|
|
463
|
+
const facts = fj && (fj.facts || fj.payment_facts) || [];
|
|
464
|
+
for (const f of facts) {
|
|
465
|
+
if (String(f.status).toUpperCase() !== "CONFIRMED") continue;
|
|
466
|
+
// 支付口径双标准 (xiaomu 2026-09-22): 国内=微信支付, 国外=PayPal, 每市场唯一通道不混算。
|
|
467
|
+
// 当前 proto 无 channel 字段 — 提交口 (agent-serviceprovider) 只放行 wechat/paypal,
|
|
468
|
+
// 所以链上事实均为双标准内的口径; 下个升级 PaymentFact 加 channel 字段后在此按口径分组结算:
|
|
469
|
+
// wechat → 国内统计口径; paypal → 海外统计口径; 两者不互相混算。
|
|
470
|
+
try {
|
|
471
|
+
await settleFact(f, params, oracleAddr);
|
|
472
|
+
} catch (e) {
|
|
473
|
+
warn(`[oracle-glue] E6 结算失败 order_ref=${f.order_ref}: ${e.message} (下轮重试)`);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
// ============================== N14 settle crank ==============================
|
|
480
|
+
|
|
481
|
+
const SETTLE_MAX_PER_TICK = 5; // 每 tick 最多结算单数 (防堆积打爆串行队列)
|
|
482
|
+
const SETTLE_SELLER_SCAN_CAP = 20; // 每 tick 最多扫描的 provider (卖家) 数
|
|
483
|
+
const SETTLE_BEAT_SECS = 1800; // 无到期单时的心跳日志间隔
|
|
484
|
+
const DEFAULT_DISPUTE_WINDOW = 259200; // 3 天; 链上 order params 读取失败时的兜底
|
|
485
|
+
let lastSweepBeatAt = 0;
|
|
486
|
+
|
|
487
|
+
/** 链上 order params (dispute_window, 秒) */
|
|
488
|
+
async function getDisputeWindow() {
|
|
489
|
+
const j = await lcdGet("/oxiaom/trustchain/order/v1/params");
|
|
490
|
+
const n = Number(j && j.params && j.params.dispute_window);
|
|
491
|
+
return Number.isFinite(n) && n > 0 ? n : DEFAULT_DISPUTE_WINDOW;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
/** 单查链上订单 (返回 Order 对象或 null) */
|
|
495
|
+
async function getOrder(orderId) {
|
|
496
|
+
const j = await lcdGet(`/oxiaom/trustchain/order/v1/orders/${orderId}`);
|
|
497
|
+
return (j && (j.order || j.Order)) || null;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
/** CONFIRMED 且争议窗口已过 → 到期可结算 (status 兼容枚举名/数字两种 LCD 形态) */
|
|
501
|
+
function orderSettleEligible(o, window) {
|
|
502
|
+
const st = String(o.status || "");
|
|
503
|
+
if (!(st === "2" || /CONFIRMED$/i.test(st))) return false;
|
|
504
|
+
if (o.settled) return false;
|
|
505
|
+
const at = Number(o.confirmed_at || 0);
|
|
506
|
+
return at > 0 && at + window < nowSec();
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
/** 本地台账 chain_order_id 候选 (表由 indexer 建; 不存在时按无候选处理) */
|
|
510
|
+
function localChainOrderIds() {
|
|
511
|
+
const has = db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='agent_pay_sessions'").get();
|
|
512
|
+
if (!has) return [];
|
|
513
|
+
return db.prepare("SELECT DISTINCT chain_order_id AS id FROM agent_pay_sessions WHERE chain_order_id IS NOT NULL AND chain_order_id != ''").all();
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
/** N14 一轮: 扫到期 CONFIRMED 单 → 逐条发 MsgSettleOrder (caller=oracle, permissionless)。
|
|
517
|
+
* 候选源: 本地台账 agent_pay_sessions.chain_order_id (逐单现查) + 链上 providers
|
|
518
|
+
* 的 by-seller 订单列表 (列表自带全量字段, 免逐单查; 链上无全局订单列表查询)。 */
|
|
519
|
+
async function settleExpiredOrders(oracleAddr) {
|
|
520
|
+
const win = await getDisputeWindow();
|
|
521
|
+
const due = [];
|
|
522
|
+
const seen = new Set();
|
|
523
|
+
const consider = (o, seller) => {
|
|
524
|
+
if (!o || !o.order_id || seen.has(String(o.order_id))) return;
|
|
525
|
+
seen.add(String(o.order_id));
|
|
526
|
+
if (orderSettleEligible(o, win)) due.push({ id: String(o.order_id), seller: o.seller || seller || "", confirmedAt: Number(o.confirmed_at) });
|
|
527
|
+
};
|
|
528
|
+
for (const r of localChainOrderIds()) {
|
|
529
|
+
const id = String(r.id || "");
|
|
530
|
+
if (!/^\d+$/.test(id)) continue;
|
|
531
|
+
consider(await getOrder(id));
|
|
532
|
+
}
|
|
533
|
+
const pj = await lcdGet("/oxiaom/trustchain/serviceprovider/v1/providers");
|
|
534
|
+
const providers = pj && (pj.providers || pj.service_providers) || [];
|
|
535
|
+
for (const p of providers.slice(0, SETTLE_SELLER_SCAN_CAP)) {
|
|
536
|
+
const paddr = typeof p === "string" ? p : p.address;
|
|
537
|
+
if (!paddr) continue;
|
|
538
|
+
const oj = await lcdGet(`/oxiaom/trustchain/order/v1/sellers/${paddr}/orders`);
|
|
539
|
+
for (const o of (oj && oj.orders) || []) consider(o, paddr);
|
|
540
|
+
}
|
|
541
|
+
if (due.length === 0) {
|
|
542
|
+
if (nowSec() - lastSweepBeatAt >= SETTLE_BEAT_SECS) {
|
|
543
|
+
lastSweepBeatAt = nowSec();
|
|
544
|
+
log(`[oracle-glue] N14 settle 扫描: 无到期订单 (checked=${seen.size} window=${win}s)`);
|
|
545
|
+
}
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
due.sort((a, b) => a.confirmedAt - b.confirmedAt); // 最老的先结
|
|
549
|
+
for (const d of due.slice(0, SETTLE_MAX_PER_TICK)) {
|
|
550
|
+
let r;
|
|
551
|
+
try {
|
|
552
|
+
r = await sendTx([{
|
|
553
|
+
"@type": "/trustchain.order.v1.MsgSettleOrder",
|
|
554
|
+
caller: oracleAddr,
|
|
555
|
+
order_id: d.id,
|
|
556
|
+
}]);
|
|
557
|
+
} catch (e) {
|
|
558
|
+
warn(`[oracle-glue] N14 settle order=${d.id} 异常: ${e.message} (下轮重试)`);
|
|
559
|
+
continue;
|
|
560
|
+
}
|
|
561
|
+
if (r.code !== 0) {
|
|
562
|
+
if (SETTLE_DONE_RE.test(r.raw_log)) {
|
|
563
|
+
log(`[oracle-glue] N14 settle order=${d.id} 按完成处理 (${String(r.raw_log).slice(0, 80)})`);
|
|
564
|
+
} else if (MODULE_NOT_LIVE_RE.test(r.raw_log)) {
|
|
565
|
+
warn(`[oracle-glue] order 模块未上线, settle order=${d.id} 留待下轮`);
|
|
566
|
+
} else {
|
|
567
|
+
warn(`[oracle-glue] N14 settle order=${d.id} 失败 code=${r.code}: ${String(r.raw_log).slice(0, 200)} (下轮重试)`);
|
|
568
|
+
}
|
|
569
|
+
continue;
|
|
570
|
+
}
|
|
571
|
+
log(`[oracle-glue] N14 订单已结算 order=${d.id} seller=${d.seller} tx=${r.txhash}`);
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/** 每 tick: 推进 bootstrap 队列 + E6 结算 + N14 settle 扫描。签名地址每轮现取 (CLI/JS 通道皆可) */
|
|
576
|
+
async function tick() {
|
|
577
|
+
let oracleAddr = deps.oracleAddr;
|
|
578
|
+
if (!oracleAddr) {
|
|
579
|
+
try {
|
|
580
|
+
oracleAddr = await chainWrites.keyAddress(cfg);
|
|
581
|
+
} catch (e) {
|
|
582
|
+
warn(`[oracle-glue] 签名地址获取失败 (${e.message}), 本轮跳过`);
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
const rows = db.prepare("SELECT * FROM oracle_bootstrap_grants WHERE status NOT IN ('done')").all();
|
|
587
|
+
for (const row of rows) {
|
|
588
|
+
try {
|
|
589
|
+
await stepBootstrapGrant(row, oracleAddr);
|
|
590
|
+
} catch (e) {
|
|
591
|
+
db.prepare("UPDATE oracle_bootstrap_grants SET last_error=?, updated_at=? WHERE credential_hash=?")
|
|
592
|
+
.run(String(e.message).slice(0, 300), nowSec(), row.credential_hash);
|
|
593
|
+
warn(`[oracle-glue] bootstrap ${row.credential_hash.slice(0, 12)}... 失败: ${e.message} (下轮重试)`);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
await settleConfirmedFacts(oracleAddr);
|
|
597
|
+
await settleExpiredOrders(oracleAddr);
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
return { tick, enqueueBootstrapGrant, settleConfirmedFacts, settleExpiredOrders, stepBootstrapGrant, getEconomyParams, monthlyUsed, resolveOrderParties, settleFact, grantFeegrant, findFeegrant };
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
module.exports = { createOracleGlue, oracleCfg, sha256Hex, MODULE_NOT_LIVE_RE };
|