project-cpu-mcp 0.10.0 → 0.12.0
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/README.md +111 -35
- package/dist/api/authentication-required.error.d.ts +6 -0
- package/dist/api/authentication-required.error.d.ts.map +1 -0
- package/dist/api/authentication-required.error.js +9 -0
- package/dist/api/authentication-required.error.js.map +1 -0
- package/dist/api/client.d.ts +7 -5
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +29 -14
- package/dist/api/client.js.map +1 -1
- package/dist/api/constants.d.ts +2 -0
- package/dist/api/constants.d.ts.map +1 -1
- package/dist/api/constants.js +6 -0
- package/dist/api/constants.js.map +1 -1
- package/dist/api/types.d.ts +189 -220
- package/dist/api/types.d.ts.map +1 -1
- package/dist/api/types.js +43 -29
- package/dist/api/types.js.map +1 -1
- package/dist/config/constants.d.ts +6 -2
- package/dist/config/constants.d.ts.map +1 -1
- package/dist/config/constants.js +6 -2
- package/dist/config/constants.js.map +1 -1
- package/dist/config/types.js +2 -2
- package/dist/config/types.js.map +1 -1
- package/dist/contracts/cell.abi.d.ts +26 -2
- package/dist/contracts/cell.abi.d.ts.map +1 -1
- package/dist/contracts/cell.abi.js +21 -2
- package/dist/contracts/cell.abi.js.map +1 -1
- package/dist/contracts/erc20.abi.d.ts.map +1 -1
- package/dist/contracts/erc20.abi.js +1 -2
- package/dist/contracts/erc20.abi.js.map +1 -1
- package/dist/contracts/trade.abi.d.ts +341 -0
- package/dist/contracts/trade.abi.d.ts.map +1 -1
- package/dist/contracts/trade.abi.js +163 -0
- package/dist/contracts/trade.abi.js.map +1 -1
- package/dist/contracts/trade.types.d.ts +14 -0
- package/dist/contracts/trade.types.d.ts.map +1 -0
- package/dist/contracts/trade.types.js +15 -0
- package/dist/contracts/trade.types.js.map +1 -0
- package/dist/contracts/transport.abi.d.ts +4 -0
- package/dist/contracts/transport.abi.d.ts.map +1 -1
- package/dist/contracts/transport.abi.js +1 -0
- package/dist/contracts/transport.abi.js.map +1 -1
- package/dist/index.js +40 -3
- package/dist/index.js.map +1 -1
- package/dist/logger/constants.d.ts +7 -0
- package/dist/logger/constants.d.ts.map +1 -1
- package/dist/logger/constants.js +11 -0
- package/dist/logger/constants.js.map +1 -1
- package/dist/logger/file-log.utils.d.ts +4 -0
- package/dist/logger/file-log.utils.d.ts.map +1 -0
- package/dist/logger/file-log.utils.js +23 -0
- package/dist/logger/file-log.utils.js.map +1 -0
- package/dist/logger/index.d.ts +1 -1
- package/dist/logger/index.d.ts.map +1 -1
- package/dist/logger/index.js +5 -3
- package/dist/logger/index.js.map +1 -1
- package/dist/logger/logger.d.ts +4 -0
- package/dist/logger/logger.d.ts.map +1 -1
- package/dist/logger/logger.js +48 -3
- package/dist/logger/logger.js.map +1 -1
- package/dist/logger/redact.utils.d.ts.map +1 -1
- package/dist/logger/redact.utils.js +7 -2
- package/dist/logger/redact.utils.js.map +1 -1
- package/dist/logger/types.d.ts +8 -0
- package/dist/logger/types.d.ts.map +1 -1
- package/dist/map/attention.utils.d.ts.map +1 -1
- package/dist/map/attention.utils.js +1 -0
- package/dist/map/attention.utils.js.map +1 -1
- package/dist/map/cell-view.utils.d.ts.map +1 -1
- package/dist/map/cell-view.utils.js +5 -3
- package/dist/map/cell-view.utils.js.map +1 -1
- package/dist/map/process-projection.utils.js +2 -2
- package/dist/map/process-projection.utils.js.map +1 -1
- package/dist/map/reader.utils.d.ts.map +1 -1
- package/dist/map/reader.utils.js +3 -2
- package/dist/map/reader.utils.js.map +1 -1
- package/dist/map/storage.utils.d.ts.map +1 -1
- package/dist/map/storage.utils.js +5 -1
- package/dist/map/storage.utils.js.map +1 -1
- package/dist/map/types.d.ts +21 -0
- package/dist/map/types.d.ts.map +1 -1
- package/dist/map/types.js +6 -0
- package/dist/map/types.js.map +1 -1
- package/dist/paybox/auth/authority.d.ts +46 -0
- package/dist/paybox/auth/authority.d.ts.map +1 -0
- package/dist/paybox/auth/authority.js +410 -0
- package/dist/paybox/auth/authority.js.map +1 -0
- package/dist/paybox/auth/browser-opener.d.ts +8 -0
- package/dist/paybox/auth/browser-opener.d.ts.map +1 -0
- package/dist/paybox/auth/browser-opener.js +22 -0
- package/dist/paybox/auth/browser-opener.js.map +1 -0
- package/dist/paybox/auth/browser-opener.utils.d.ts +2 -0
- package/dist/paybox/auth/browser-opener.utils.d.ts.map +1 -0
- package/dist/paybox/auth/browser-opener.utils.js +10 -0
- package/dist/paybox/auth/browser-opener.utils.js.map +1 -0
- package/dist/paybox/auth/constants.d.ts +16 -0
- package/dist/paybox/auth/constants.d.ts.map +1 -0
- package/dist/paybox/auth/constants.js +16 -0
- package/dist/paybox/auth/constants.js.map +1 -0
- package/dist/paybox/auth/coordinator.d.ts +21 -0
- package/dist/paybox/auth/coordinator.d.ts.map +1 -0
- package/dist/paybox/auth/coordinator.factory.d.ts +5 -0
- package/dist/paybox/auth/coordinator.factory.d.ts.map +1 -0
- package/dist/paybox/auth/coordinator.factory.js +5 -0
- package/dist/paybox/auth/coordinator.factory.js.map +1 -0
- package/dist/paybox/auth/coordinator.js +87 -0
- package/dist/paybox/auth/coordinator.js.map +1 -0
- package/dist/paybox/auth/coordinator.utils.d.ts +4 -0
- package/dist/paybox/auth/coordinator.utils.d.ts.map +1 -0
- package/dist/paybox/auth/coordinator.utils.js +8 -0
- package/dist/paybox/auth/coordinator.utils.js.map +1 -0
- package/dist/paybox/auth/flow-session.d.ts +24 -0
- package/dist/paybox/auth/flow-session.d.ts.map +1 -0
- package/dist/paybox/auth/flow-session.js +155 -0
- package/dist/paybox/auth/flow-session.js.map +1 -0
- package/dist/paybox/auth/loopback-flow.d.ts +49 -0
- package/dist/paybox/auth/loopback-flow.d.ts.map +1 -0
- package/dist/paybox/auth/loopback-flow.js +381 -0
- package/dist/paybox/auth/loopback-flow.js.map +1 -0
- package/dist/paybox/auth/loopback-flow.utils.d.ts +7 -0
- package/dist/paybox/auth/loopback-flow.utils.d.ts.map +1 -0
- package/dist/paybox/auth/loopback-flow.utils.js +47 -0
- package/dist/paybox/auth/loopback-flow.utils.js.map +1 -0
- package/dist/paybox/auth/loopback-page-fonts.constants.d.ts +3 -0
- package/dist/paybox/auth/loopback-page-fonts.constants.d.ts.map +1 -0
- package/dist/paybox/auth/loopback-page-fonts.constants.js +228 -0
- package/dist/paybox/auth/loopback-page-fonts.constants.js.map +1 -0
- package/dist/paybox/auth/loopback-page.utils.d.ts +4 -0
- package/dist/paybox/auth/loopback-page.utils.d.ts.map +1 -0
- package/dist/paybox/auth/loopback-page.utils.js +261 -0
- package/dist/paybox/auth/loopback-page.utils.js.map +1 -0
- package/dist/paybox/auth/provisioning.utils.d.ts +3 -0
- package/dist/paybox/auth/provisioning.utils.d.ts.map +1 -0
- package/dist/paybox/auth/provisioning.utils.js +27 -0
- package/dist/paybox/auth/provisioning.utils.js.map +1 -0
- package/dist/paybox/auth/signing-key.utils.d.ts +2 -0
- package/dist/paybox/auth/signing-key.utils.d.ts.map +1 -0
- package/dist/paybox/auth/signing-key.utils.js +14 -0
- package/dist/paybox/auth/signing-key.utils.js.map +1 -0
- package/dist/paybox/auth/types.d.ts +18 -0
- package/dist/paybox/auth/types.d.ts.map +1 -0
- package/dist/paybox/auth/types.js +6 -0
- package/dist/paybox/auth/types.js.map +1 -0
- package/dist/paybox/auth/utils.d.ts +5 -0
- package/dist/paybox/auth/utils.d.ts.map +1 -0
- package/dist/paybox/auth/utils.js +17 -0
- package/dist/paybox/auth/utils.js.map +1 -0
- package/dist/paybox/constants.d.ts +11 -0
- package/dist/paybox/constants.d.ts.map +1 -0
- package/dist/paybox/constants.js +11 -0
- package/dist/paybox/constants.js.map +1 -0
- package/dist/paybox/errors.d.ts +43 -0
- package/dist/paybox/errors.d.ts.map +1 -0
- package/dist/paybox/errors.js +141 -0
- package/dist/paybox/errors.js.map +1 -0
- package/dist/paybox/sdk/adapter.d.ts +16 -0
- package/dist/paybox/sdk/adapter.d.ts.map +1 -0
- package/dist/paybox/sdk/adapter.js +127 -0
- package/dist/paybox/sdk/adapter.js.map +1 -0
- package/dist/paybox/sdk/constants.d.ts +14 -0
- package/dist/paybox/sdk/constants.d.ts.map +1 -0
- package/dist/paybox/sdk/constants.js +23 -0
- package/dist/paybox/sdk/constants.js.map +1 -0
- package/dist/paybox/sdk/factory.d.ts +4 -0
- package/dist/paybox/sdk/factory.d.ts.map +1 -0
- package/dist/paybox/sdk/factory.js +24 -0
- package/dist/paybox/sdk/factory.js.map +1 -0
- package/dist/paybox/sdk/logging.utils.d.ts +4 -0
- package/dist/paybox/sdk/logging.utils.d.ts.map +1 -0
- package/dist/paybox/sdk/logging.utils.js +19 -0
- package/dist/paybox/sdk/logging.utils.js.map +1 -0
- package/dist/paybox/sdk/utils.d.ts +7 -0
- package/dist/paybox/sdk/utils.d.ts.map +1 -0
- package/dist/paybox/sdk/utils.js +182 -0
- package/dist/paybox/sdk/utils.js.map +1 -0
- package/dist/paybox/storage.d.ts +17 -0
- package/dist/paybox/storage.d.ts.map +1 -0
- package/dist/paybox/storage.js +87 -0
- package/dist/paybox/storage.js.map +1 -0
- package/dist/paybox/types.d.ts +481 -0
- package/dist/paybox/types.d.ts.map +1 -0
- package/dist/paybox/types.js +144 -0
- package/dist/paybox/types.js.map +1 -0
- package/dist/paybox/wallet/manager.d.ts +22 -0
- package/dist/paybox/wallet/manager.d.ts.map +1 -0
- package/dist/paybox/wallet/manager.js +111 -0
- package/dist/paybox/wallet/manager.js.map +1 -0
- package/dist/paybox/wallet/rpc.client.d.ts +16 -0
- package/dist/paybox/wallet/rpc.client.d.ts.map +1 -0
- package/dist/paybox/wallet/rpc.client.js +53 -0
- package/dist/paybox/wallet/rpc.client.js.map +1 -0
- package/dist/paybox/wallet/utils.d.ts +5 -0
- package/dist/paybox/wallet/utils.d.ts.map +1 -0
- package/dist/paybox/wallet/utils.js +82 -0
- package/dist/paybox/wallet/utils.js.map +1 -0
- package/dist/server.constants.d.ts.map +1 -1
- package/dist/server.constants.js +5 -2
- package/dist/server.constants.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +8 -2
- package/dist/server.js.map +1 -1
- package/dist/services/app-config.utils.d.ts.map +1 -1
- package/dist/services/app-config.utils.js +22 -11
- package/dist/services/app-config.utils.js.map +1 -1
- package/dist/services/auth.service.d.ts +3 -5
- package/dist/services/auth.service.d.ts.map +1 -1
- package/dist/services/auth.service.js +20 -77
- package/dist/services/auth.service.js.map +1 -1
- package/dist/services/cell.client.d.ts.map +1 -1
- package/dist/services/cell.client.js +22 -9
- package/dist/services/cell.client.js.map +1 -1
- package/dist/services/lot-return.constants.d.ts +3 -0
- package/dist/services/lot-return.constants.d.ts.map +1 -0
- package/dist/services/lot-return.constants.js +35 -0
- package/dist/services/lot-return.constants.js.map +1 -0
- package/dist/services/lot-return.service.d.ts +25 -0
- package/dist/services/lot-return.service.d.ts.map +1 -0
- package/dist/services/lot-return.service.js +151 -0
- package/dist/services/lot-return.service.js.map +1 -0
- package/dist/services/lot-return.types.d.ts +19 -0
- package/dist/services/lot-return.types.d.ts.map +1 -0
- package/dist/services/lot-return.types.js +2 -0
- package/dist/services/lot-return.types.js.map +1 -0
- package/dist/services/lot-return.utils.d.ts +33 -0
- package/dist/services/lot-return.utils.d.ts.map +1 -0
- package/dist/services/lot-return.utils.js +128 -0
- package/dist/services/lot-return.utils.js.map +1 -0
- package/dist/services/lot-terms.constants.d.ts +4 -0
- package/dist/services/lot-terms.constants.d.ts.map +1 -0
- package/dist/services/lot-terms.constants.js +5 -0
- package/dist/services/lot-terms.constants.js.map +1 -0
- package/dist/services/lot-terms.helpers.d.ts +11 -0
- package/dist/services/lot-terms.helpers.d.ts.map +1 -0
- package/dist/services/lot-terms.helpers.js +45 -0
- package/dist/services/lot-terms.helpers.js.map +1 -0
- package/dist/services/lot-terms.service.d.ts +20 -0
- package/dist/services/lot-terms.service.d.ts.map +1 -0
- package/dist/services/lot-terms.service.js +119 -0
- package/dist/services/lot-terms.service.js.map +1 -0
- package/dist/services/lot-terms.types.d.ts +25 -0
- package/dist/services/lot-terms.types.d.ts.map +1 -0
- package/dist/services/lot-terms.types.js +2 -0
- package/dist/services/lot-terms.types.js.map +1 -0
- package/dist/services/reveal-revert.utils.d.ts +1 -0
- package/dist/services/reveal-revert.utils.d.ts.map +1 -1
- package/dist/services/reveal-revert.utils.js +20 -0
- package/dist/services/reveal-revert.utils.js.map +1 -1
- package/dist/services/reveal.constants.d.ts +1 -1
- package/dist/services/reveal.constants.d.ts.map +1 -1
- package/dist/services/reveal.constants.js +1 -1
- package/dist/services/reveal.constants.js.map +1 -1
- package/dist/services/reveal.service.d.ts +4 -3
- package/dist/services/reveal.service.d.ts.map +1 -1
- package/dist/services/reveal.service.js +35 -10
- package/dist/services/reveal.service.js.map +1 -1
- package/dist/services/reveal.utils.d.ts +7 -8
- package/dist/services/reveal.utils.d.ts.map +1 -1
- package/dist/services/reveal.utils.js +15 -8
- package/dist/services/reveal.utils.js.map +1 -1
- package/dist/services/route.constants.d.ts +12 -1
- package/dist/services/route.constants.d.ts.map +1 -1
- package/dist/services/route.constants.js +66 -15
- package/dist/services/route.constants.js.map +1 -1
- package/dist/services/route.lots.d.ts +18 -0
- package/dist/services/route.lots.d.ts.map +1 -0
- package/dist/services/route.lots.js +33 -0
- package/dist/services/route.lots.js.map +1 -0
- package/dist/services/route.service.d.ts +13 -4
- package/dist/services/route.service.d.ts.map +1 -1
- package/dist/services/route.service.js +95 -13
- package/dist/services/route.service.js.map +1 -1
- package/dist/services/route.types.d.ts +76 -0
- package/dist/services/route.types.d.ts.map +1 -0
- package/dist/services/route.types.js +8 -0
- package/dist/services/route.types.js.map +1 -0
- package/dist/services/route.utils.d.ts +19 -0
- package/dist/services/route.utils.d.ts.map +1 -1
- package/dist/services/route.utils.js +35 -0
- package/dist/services/route.utils.js.map +1 -1
- package/dist/services/trade-eviction.constants.d.ts +12 -0
- package/dist/services/trade-eviction.constants.d.ts.map +1 -0
- package/dist/services/trade-eviction.constants.js +25 -0
- package/dist/services/trade-eviction.constants.js.map +1 -0
- package/dist/services/trade-eviction.service.d.ts +22 -0
- package/dist/services/trade-eviction.service.d.ts.map +1 -0
- package/dist/services/trade-eviction.service.js +101 -0
- package/dist/services/trade-eviction.service.js.map +1 -0
- package/dist/services/trade-eviction.types.d.ts +30 -0
- package/dist/services/trade-eviction.types.d.ts.map +1 -0
- package/dist/services/trade-eviction.types.js +2 -0
- package/dist/services/trade-eviction.types.js.map +1 -0
- package/dist/services/trade-eviction.utils.d.ts +9 -0
- package/dist/services/trade-eviction.utils.d.ts.map +1 -0
- package/dist/services/trade-eviction.utils.js +38 -0
- package/dist/services/trade-eviction.utils.js.map +1 -0
- package/dist/services/trade-rules.service.d.ts +15 -0
- package/dist/services/trade-rules.service.d.ts.map +1 -0
- package/dist/services/trade-rules.service.js +45 -0
- package/dist/services/trade-rules.service.js.map +1 -0
- package/dist/services/trade.client.d.ts +11 -1
- package/dist/services/trade.client.d.ts.map +1 -1
- package/dist/services/trade.client.js +87 -0
- package/dist/services/trade.client.js.map +1 -1
- package/dist/services/trade.constants.d.ts +9 -0
- package/dist/services/trade.constants.d.ts.map +1 -0
- package/dist/services/trade.constants.js +28 -0
- package/dist/services/trade.constants.js.map +1 -0
- package/dist/services/trade.helpers.d.ts +9 -1
- package/dist/services/trade.helpers.d.ts.map +1 -1
- package/dist/services/trade.helpers.js +40 -27
- package/dist/services/trade.helpers.js.map +1 -1
- package/dist/services/transport-revert.utils.d.ts +3 -0
- package/dist/services/transport-revert.utils.d.ts.map +1 -0
- package/dist/services/transport-revert.utils.js +15 -0
- package/dist/services/transport-revert.utils.js.map +1 -0
- package/dist/services/transport.client.d.ts.map +1 -1
- package/dist/services/transport.client.js +14 -6
- package/dist/services/transport.client.js.map +1 -1
- package/dist/services/types.d.ts +249 -21
- package/dist/services/types.d.ts.map +1 -1
- package/dist/services/types.js +25 -0
- package/dist/services/types.js.map +1 -1
- package/dist/services/warehouse.utils.d.ts +8 -0
- package/dist/services/warehouse.utils.d.ts.map +1 -1
- package/dist/services/warehouse.utils.js +25 -0
- package/dist/services/warehouse.utils.js.map +1 -1
- package/dist/session/manager.d.ts +1 -0
- package/dist/session/manager.d.ts.map +1 -1
- package/dist/session/manager.js +13 -0
- package/dist/session/manager.js.map +1 -1
- package/dist/session/storage.d.ts +0 -3
- package/dist/session/storage.d.ts.map +1 -1
- package/dist/session/storage.js +6 -43
- package/dist/session/storage.js.map +1 -1
- package/dist/session/types.d.ts +4 -98
- package/dist/session/types.d.ts.map +1 -1
- package/dist/session/types.js +0 -15
- package/dist/session/types.js.map +1 -1
- package/dist/tools/authenticate.d.ts +1 -1
- package/dist/tools/authenticate.d.ts.map +1 -1
- package/dist/tools/authenticate.js +19 -45
- package/dist/tools/authenticate.js.map +1 -1
- package/dist/tools/config/get-game-config/constants.d.ts +3 -0
- package/dist/tools/config/get-game-config/constants.d.ts.map +1 -1
- package/dist/tools/config/get-game-config/constants.js +13 -2
- package/dist/tools/config/get-game-config/constants.js.map +1 -1
- package/dist/tools/config/get-game-config/get-game-config.d.ts.map +1 -1
- package/dist/tools/config/get-game-config/get-game-config.js +6 -3
- package/dist/tools/config/get-game-config/get-game-config.js.map +1 -1
- package/dist/tools/config/get-game-config/get-game-config.utils.d.ts +4 -4
- package/dist/tools/config/get-game-config/get-game-config.utils.d.ts.map +1 -1
- package/dist/tools/config/get-game-config/get-game-config.utils.js +26 -9
- package/dist/tools/config/get-game-config/get-game-config.utils.js.map +1 -1
- package/dist/tools/config/get-game-config/types.d.ts +6 -2
- package/dist/tools/config/get-game-config/types.d.ts.map +1 -1
- package/dist/tools/config/resource-lens/resource-lens.utils.d.ts.map +1 -1
- package/dist/tools/config/resource-lens/resource-lens.utils.js +5 -4
- package/dist/tools/config/resource-lens/resource-lens.utils.js.map +1 -1
- package/dist/tools/map/attention/attention.d.ts.map +1 -1
- package/dist/tools/map/attention/attention.js +16 -5
- package/dist/tools/map/attention/attention.js.map +1 -1
- package/dist/tools/map/attention/constants.d.ts +6 -0
- package/dist/tools/map/attention/constants.d.ts.map +1 -1
- package/dist/tools/map/attention/constants.js +16 -2
- package/dist/tools/map/attention/constants.js.map +1 -1
- package/dist/tools/map/attention/evicted.service.d.ts +19 -0
- package/dist/tools/map/attention/evicted.service.d.ts.map +1 -0
- package/dist/tools/map/attention/evicted.service.js +73 -0
- package/dist/tools/map/attention/evicted.service.js.map +1 -0
- package/dist/tools/map/attention/evicted.utils.d.ts +16 -0
- package/dist/tools/map/attention/evicted.utils.d.ts.map +1 -0
- package/dist/tools/map/attention/evicted.utils.js +72 -0
- package/dist/tools/map/attention/evicted.utils.js.map +1 -0
- package/dist/tools/map/attention/panel.utils.d.ts.map +1 -1
- package/dist/tools/map/attention/panel.utils.js +1 -0
- package/dist/tools/map/attention/panel.utils.js.map +1 -1
- package/dist/tools/map/attention/types.d.ts +17 -0
- package/dist/tools/map/attention/types.d.ts.map +1 -1
- package/dist/tools/map/attention/types.js.map +1 -1
- package/dist/tools/map/get-map/constants.d.ts.map +1 -1
- package/dist/tools/map/get-map/constants.js +4 -2
- package/dist/tools/map/get-map/constants.js.map +1 -1
- package/dist/tools/reveal/constants.d.ts.map +1 -1
- package/dist/tools/reveal/constants.js +3 -1
- package/dist/tools/reveal/constants.js.map +1 -1
- package/dist/tools/trade/buy-lot/buy-lot.d.ts.map +1 -1
- package/dist/tools/trade/buy-lot/buy-lot.js +2 -0
- package/dist/tools/trade/buy-lot/buy-lot.js.map +1 -1
- package/dist/tools/trade/buy-lot/constants.d.ts.map +1 -1
- package/dist/tools/trade/buy-lot/constants.js +2 -0
- package/dist/tools/trade/buy-lot/constants.js.map +1 -1
- package/dist/tools/trade/buyer-guard/constants.d.ts +4 -0
- package/dist/tools/trade/buyer-guard/constants.d.ts.map +1 -0
- package/dist/tools/trade/buyer-guard/constants.js +11 -0
- package/dist/tools/trade/buyer-guard/constants.js.map +1 -0
- package/dist/tools/trade/buyer-guard/lot-open.guard.d.ts +9 -0
- package/dist/tools/trade/buyer-guard/lot-open.guard.d.ts.map +1 -0
- package/dist/tools/trade/buyer-guard/lot-open.guard.js +15 -0
- package/dist/tools/trade/buyer-guard/lot-open.guard.js.map +1 -0
- package/dist/tools/trade/buyer-guard/types.d.ts +6 -0
- package/dist/tools/trade/buyer-guard/types.d.ts.map +1 -0
- package/dist/tools/trade/buyer-guard/types.js +2 -0
- package/dist/tools/trade/buyer-guard/types.js.map +1 -0
- package/dist/tools/trade/constants.d.ts +5 -0
- package/dist/tools/trade/constants.d.ts.map +1 -0
- package/dist/tools/trade/constants.js +14 -0
- package/dist/tools/trade/constants.js.map +1 -0
- package/dist/tools/trade/create-lot/constants.d.ts.map +1 -1
- package/dist/tools/trade/create-lot/constants.js +4 -1
- package/dist/tools/trade/create-lot/constants.js.map +1 -1
- package/dist/tools/trade/create-lot/create-lot.d.ts +2 -1
- package/dist/tools/trade/create-lot/create-lot.d.ts.map +1 -1
- package/dist/tools/trade/create-lot/create-lot.js +15 -1
- package/dist/tools/trade/create-lot/create-lot.js.map +1 -1
- package/dist/tools/trade/evict-lot/constants.d.ts +4 -0
- package/dist/tools/trade/evict-lot/constants.d.ts.map +1 -0
- package/dist/tools/trade/evict-lot/constants.js +13 -0
- package/dist/tools/trade/evict-lot/constants.js.map +1 -0
- package/dist/tools/trade/evict-lot/evict-lot.d.ts +6 -0
- package/dist/tools/trade/evict-lot/evict-lot.d.ts.map +1 -0
- package/dist/tools/trade/evict-lot/evict-lot.js +35 -0
- package/dist/tools/trade/evict-lot/evict-lot.js.map +1 -0
- package/dist/tools/trade/evict-lot/format.utils.d.ts +5 -0
- package/dist/tools/trade/evict-lot/format.utils.d.ts.map +1 -0
- package/dist/tools/trade/evict-lot/format.utils.js +10 -0
- package/dist/tools/trade/evict-lot/format.utils.js.map +1 -0
- package/dist/tools/trade/evict-lot/types.d.ts +5 -0
- package/dist/tools/trade/evict-lot/types.d.ts.map +1 -0
- package/dist/tools/trade/evict-lot/types.js +8 -0
- package/dist/tools/trade/evict-lot/types.js.map +1 -0
- package/dist/tools/trade/format.utils.d.ts +2 -4
- package/dist/tools/trade/format.utils.d.ts.map +1 -1
- package/dist/tools/trade/format.utils.js +11 -13
- package/dist/tools/trade/format.utils.js.map +1 -1
- package/dist/tools/trade/get-lot/constants.d.ts.map +1 -1
- package/dist/tools/trade/get-lot/constants.js +2 -1
- package/dist/tools/trade/get-lot/constants.js.map +1 -1
- package/dist/tools/trade/list-lots/constants.d.ts +2 -0
- package/dist/tools/trade/list-lots/constants.d.ts.map +1 -1
- package/dist/tools/trade/list-lots/constants.js +5 -1
- package/dist/tools/trade/list-lots/constants.js.map +1 -1
- package/dist/tools/trade/list-lots/list-lots.d.ts.map +1 -1
- package/dist/tools/trade/list-lots/list-lots.js +2 -1
- package/dist/tools/trade/list-lots/list-lots.js.map +1 -1
- package/dist/tools/trade/list-lots/list-lots.utils.d.ts +8 -0
- package/dist/tools/trade/list-lots/list-lots.utils.d.ts.map +1 -0
- package/dist/tools/trade/list-lots/list-lots.utils.js +10 -0
- package/dist/tools/trade/list-lots/list-lots.utils.js.map +1 -0
- package/dist/tools/trade/list-mine/constants.d.ts.map +1 -1
- package/dist/tools/trade/list-mine/constants.js +3 -1
- package/dist/tools/trade/list-mine/constants.js.map +1 -1
- package/dist/tools/trade/lot-terms/constants.d.ts +5 -0
- package/dist/tools/trade/lot-terms/constants.d.ts.map +1 -0
- package/dist/tools/trade/lot-terms/constants.js +13 -0
- package/dist/tools/trade/lot-terms/constants.js.map +1 -0
- package/dist/tools/trade/lot-terms/factory.d.ts +4 -0
- package/dist/tools/trade/lot-terms/factory.d.ts.map +1 -0
- package/dist/tools/trade/lot-terms/factory.js +14 -0
- package/dist/tools/trade/lot-terms/factory.js.map +1 -0
- package/dist/tools/trade/lot-terms/format.utils.d.ts +4 -0
- package/dist/tools/trade/lot-terms/format.utils.d.ts.map +1 -0
- package/dist/tools/trade/lot-terms/format.utils.js +30 -0
- package/dist/tools/trade/lot-terms/format.utils.js.map +1 -0
- package/dist/tools/trade/lot-terms/lot-terms.d.ts +5 -0
- package/dist/tools/trade/lot-terms/lot-terms.d.ts.map +1 -0
- package/dist/tools/trade/lot-terms/lot-terms.js +23 -0
- package/dist/tools/trade/lot-terms/lot-terms.js.map +1 -0
- package/dist/tools/trade/lot-terms/types.d.ts +6 -0
- package/dist/tools/trade/lot-terms/types.d.ts.map +1 -0
- package/dist/tools/trade/lot-terms/types.js +7 -0
- package/dist/tools/trade/lot-terms/types.js.map +1 -0
- package/dist/tools/trade/market-index/constants.d.ts.map +1 -1
- package/dist/tools/trade/market-index/constants.js +2 -0
- package/dist/tools/trade/market-index/constants.js.map +1 -1
- package/dist/tools/trade/markets/constants.d.ts.map +1 -1
- package/dist/tools/trade/markets/constants.js +2 -1
- package/dist/tools/trade/markets/constants.js.map +1 -1
- package/dist/tools/trade/quote-buy/constants.d.ts.map +1 -1
- package/dist/tools/trade/quote-buy/constants.js +4 -2
- package/dist/tools/trade/quote-buy/constants.js.map +1 -1
- package/dist/tools/trade/quote-buy/quote-buy.d.ts.map +1 -1
- package/dist/tools/trade/quote-buy/quote-buy.js +2 -0
- package/dist/tools/trade/quote-buy/quote-buy.js.map +1 -1
- package/dist/tools/trade/quote-lot-return/constants.d.ts +2 -0
- package/dist/tools/trade/quote-lot-return/constants.d.ts.map +1 -0
- package/dist/tools/trade/quote-lot-return/constants.js +11 -0
- package/dist/tools/trade/quote-lot-return/constants.js.map +1 -0
- package/dist/tools/trade/quote-lot-return/quote-lot-return.d.ts +5 -0
- package/dist/tools/trade/quote-lot-return/quote-lot-return.d.ts.map +1 -0
- package/dist/tools/trade/quote-lot-return/quote-lot-return.js +20 -0
- package/dist/tools/trade/quote-lot-return/quote-lot-return.js.map +1 -0
- package/dist/tools/trade/return-lot/constants.d.ts +5 -0
- package/dist/tools/trade/return-lot/constants.d.ts.map +1 -0
- package/dist/tools/trade/return-lot/constants.js +26 -0
- package/dist/tools/trade/return-lot/constants.js.map +1 -0
- package/dist/tools/trade/return-lot/factory.d.ts +4 -0
- package/dist/tools/trade/return-lot/factory.d.ts.map +1 -0
- package/dist/tools/trade/return-lot/factory.js +18 -0
- package/dist/tools/trade/return-lot/factory.js.map +1 -0
- package/dist/tools/trade/return-lot/format.utils.d.ts +5 -0
- package/dist/tools/trade/return-lot/format.utils.d.ts.map +1 -0
- package/dist/tools/trade/return-lot/format.utils.js +39 -0
- package/dist/tools/trade/return-lot/format.utils.js.map +1 -0
- package/dist/tools/trade/return-lot/return-lot.d.ts +5 -0
- package/dist/tools/trade/return-lot/return-lot.d.ts.map +1 -0
- package/dist/tools/trade/return-lot/return-lot.js +25 -0
- package/dist/tools/trade/return-lot/return-lot.js.map +1 -0
- package/dist/tools/trade/return-lot/types.d.ts +11 -0
- package/dist/tools/trade/return-lot/types.d.ts.map +1 -0
- package/dist/tools/trade/return-lot/types.js +21 -0
- package/dist/tools/trade/return-lot/types.js.map +1 -0
- package/dist/tools/trade/types.d.ts +0 -4
- package/dist/tools/trade/types.d.ts.map +1 -1
- package/dist/tools/trade/types.js +4 -12
- package/dist/tools/trade/types.js.map +1 -1
- package/dist/tools/transport/constants.d.ts.map +1 -1
- package/dist/tools/transport/constants.js +9 -0
- package/dist/tools/transport/constants.js.map +1 -1
- package/dist/tools/transport/network/constants.d.ts +2 -0
- package/dist/tools/transport/network/constants.d.ts.map +1 -1
- package/dist/tools/transport/network/constants.js +2 -0
- package/dist/tools/transport/network/constants.js.map +1 -1
- package/dist/tools/transport/network/panel.utils.d.ts +2 -2
- package/dist/tools/transport/network/panel.utils.d.ts.map +1 -1
- package/dist/tools/transport/network/panel.utils.js +20 -0
- package/dist/tools/transport/network/panel.utils.js.map +1 -1
- package/dist/tools/transport/network/route-network.d.ts.map +1 -1
- package/dist/tools/transport/network/route-network.js +1 -1
- package/dist/tools/transport/network/route-network.js.map +1 -1
- package/dist/tools/transport/next-hops/next-hops.d.ts.map +1 -1
- package/dist/tools/transport/next-hops/next-hops.js +13 -3
- package/dist/tools/transport/next-hops/next-hops.js.map +1 -1
- package/dist/tools/transport/quote/constants.d.ts.map +1 -1
- package/dist/tools/transport/quote/constants.js +5 -3
- package/dist/tools/transport/quote/constants.js.map +1 -1
- package/dist/tools/transport/types.d.ts +2 -0
- package/dist/tools/transport/types.d.ts.map +1 -1
- package/dist/tools/transport/types.js +16 -0
- package/dist/tools/transport/types.js.map +1 -1
- package/dist/tools/types.d.ts +7 -1
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js +16 -1
- package/dist/tools/types.js.map +1 -1
- package/dist/types.d.ts +3 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/wei.constants.d.ts +6 -0
- package/dist/utils/wei.constants.d.ts.map +1 -0
- package/dist/utils/wei.constants.js +6 -0
- package/dist/utils/wei.constants.js.map +1 -0
- package/dist/wallet/index.d.ts.map +1 -1
- package/dist/wallet/index.js +2 -3
- package/dist/wallet/index.js.map +1 -1
- package/dist/wallet/types.d.ts +0 -9
- package/dist/wallet/types.d.ts.map +1 -1
- package/dist/wallet/types.js.map +1 -1
- package/package.json +2 -2
- package/dist/tools/trade/cancel-lot/cancel-lot.d.ts +0 -4
- package/dist/tools/trade/cancel-lot/cancel-lot.d.ts.map +0 -1
- package/dist/tools/trade/cancel-lot/cancel-lot.js +0 -20
- package/dist/tools/trade/cancel-lot/cancel-lot.js.map +0 -1
- package/dist/tools/trade/cancel-lot/constants.d.ts +0 -2
- package/dist/tools/trade/cancel-lot/constants.d.ts.map +0 -1
- package/dist/tools/trade/cancel-lot/constants.js +0 -8
- package/dist/tools/trade/cancel-lot/constants.js.map +0 -1
- package/dist/wallet/agw.manager.d.ts +0 -20
- package/dist/wallet/agw.manager.d.ts.map +0 -1
- package/dist/wallet/agw.manager.js +0 -90
- package/dist/wallet/agw.manager.js.map +0 -1
- package/dist/wallet/agw.provider.d.ts +0 -14
- package/dist/wallet/agw.provider.d.ts.map +0 -1
- package/dist/wallet/agw.provider.js +0 -48
- package/dist/wallet/agw.provider.js.map +0 -1
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts';
|
|
2
1
|
import { buildSiweMessage } from './siwe.utils.js';
|
|
3
|
-
import { HttpStatus
|
|
2
|
+
import { HttpStatus } from '../api/types.js';
|
|
4
3
|
import { isJwtExpired } from '../session/jwt.utils.js';
|
|
5
4
|
import { SessionStatus } from '../session/types.js';
|
|
6
|
-
import { WalletMode } from '../types.js';
|
|
7
|
-
import { sleep } from '../utils/async.utils.js';
|
|
8
5
|
export class AuthService {
|
|
9
6
|
session;
|
|
10
7
|
api;
|
|
11
8
|
wallet;
|
|
12
9
|
logger;
|
|
13
|
-
pendingAuth = null;
|
|
14
10
|
constructor(options) {
|
|
15
11
|
this.session = options.session;
|
|
16
12
|
this.api = options.api;
|
|
@@ -26,25 +22,29 @@ export class AuthService {
|
|
|
26
22
|
}
|
|
27
23
|
this.logger.info('stored JWT missing or expired — re-running SIWE login');
|
|
28
24
|
}
|
|
29
|
-
return this.login();
|
|
25
|
+
return this.login(this.wallet.get(), new AbortController().signal);
|
|
30
26
|
}
|
|
31
27
|
async reauthenticate() {
|
|
32
28
|
this.logger.info('forcing SIWE re-login');
|
|
33
|
-
return this.login();
|
|
29
|
+
return this.login(this.wallet.get(), new AbortController().signal);
|
|
34
30
|
}
|
|
35
31
|
// ---- SIWE (EVM mode) ----
|
|
36
32
|
async authenticateSiwe() {
|
|
37
|
-
return this.login();
|
|
33
|
+
return this.login(this.wallet.get(), new AbortController().signal);
|
|
38
34
|
}
|
|
39
|
-
async
|
|
40
|
-
|
|
35
|
+
async authenticateWithWallet(wallet, signal) {
|
|
36
|
+
return this.login(wallet, signal);
|
|
37
|
+
}
|
|
38
|
+
async login(wallet, signal) {
|
|
39
|
+
signal.throwIfAborted();
|
|
41
40
|
const address = wallet.getAddress();
|
|
42
41
|
const chainId = wallet.getChainId();
|
|
43
42
|
this.logger.info('starting SIWE login', { address, chainId });
|
|
44
43
|
const { data: nonce } = await this.api.request('/api/v1/auth/siwe/nonce', {
|
|
45
44
|
method: 'POST',
|
|
46
45
|
body: { address },
|
|
47
|
-
});
|
|
46
|
+
}, signal);
|
|
47
|
+
signal.throwIfAborted();
|
|
48
48
|
const message = buildSiweMessage({
|
|
49
49
|
address,
|
|
50
50
|
chainId,
|
|
@@ -54,93 +54,36 @@ export class AuthService {
|
|
|
54
54
|
expirationTime: nonce.expirationTime,
|
|
55
55
|
});
|
|
56
56
|
const signature = await wallet.signMessage(message);
|
|
57
|
+
signal.throwIfAborted();
|
|
57
58
|
const { status, data: verified } = await this.api.request('/api/v1/auth/siwe/verify', {
|
|
58
59
|
method: 'POST',
|
|
59
60
|
body: { message, signature },
|
|
60
|
-
});
|
|
61
|
+
}, signal);
|
|
61
62
|
if (status !== HttpStatus.Ok || !verified.accessToken) {
|
|
62
63
|
throw new Error(`SIWE verification failed (status ${status})`);
|
|
63
64
|
}
|
|
65
|
+
signal.throwIfAborted();
|
|
64
66
|
this.persistToken(address, verified.accessToken);
|
|
65
67
|
this.logger.info('SIWE login completed', { address });
|
|
66
68
|
return verified.accessToken;
|
|
67
69
|
}
|
|
68
70
|
persistToken(address, jwt) {
|
|
69
|
-
|
|
71
|
+
const walletMode = this.session.getWalletMode();
|
|
72
|
+
const current = this.session.getStatus() === SessionStatus.Active ? this.session.getSession() : null;
|
|
73
|
+
if (current !== null &&
|
|
74
|
+
(current.walletMode === undefined || current.walletMode === walletMode) &&
|
|
75
|
+
(current.address === undefined || current.address.toLowerCase() === address.toLowerCase())) {
|
|
70
76
|
this.session.setJwt(jwt);
|
|
71
77
|
return;
|
|
72
78
|
}
|
|
73
79
|
const now = new Date().toISOString();
|
|
74
80
|
this.session.setSession({
|
|
75
|
-
walletMode
|
|
81
|
+
walletMode,
|
|
76
82
|
address,
|
|
77
|
-
sessionPrivateKey: null,
|
|
78
83
|
jwt,
|
|
79
|
-
sessionConfig: null,
|
|
80
84
|
createdAt: now,
|
|
81
85
|
updatedAt: now,
|
|
82
86
|
});
|
|
83
87
|
}
|
|
84
|
-
// ---- Device Authorization (AGW mode) ----
|
|
85
|
-
getPendingAuth() {
|
|
86
|
-
return this.pendingAuth;
|
|
87
|
-
}
|
|
88
|
-
async authenticateDevice() {
|
|
89
|
-
const sessionPrivateKey = generatePrivateKey();
|
|
90
|
-
const account = privateKeyToAccount(sessionPrivateKey);
|
|
91
|
-
const signerAddress = account.address;
|
|
92
|
-
this.logger.info('starting device auth', { signerAddress });
|
|
93
|
-
const { data: deviceAuth } = await this.api.request('/api/v1/auth/device/start', {
|
|
94
|
-
method: 'POST',
|
|
95
|
-
body: { signerAddress },
|
|
96
|
-
});
|
|
97
|
-
const verificationUrl = `${deviceAuth.verificationUri}?code=${deviceAuth.userCode}`;
|
|
98
|
-
const result = {
|
|
99
|
-
verificationUrl,
|
|
100
|
-
userCode: deviceAuth.userCode,
|
|
101
|
-
};
|
|
102
|
-
this.pendingAuth = result;
|
|
103
|
-
this.pollUntilComplete(deviceAuth.deviceCode, deviceAuth.interval, deviceAuth.expiresIn, sessionPrivateKey, signerAddress)
|
|
104
|
-
.catch((error) => {
|
|
105
|
-
this.logger.error('device auth polling failed', {
|
|
106
|
-
error,
|
|
107
|
-
});
|
|
108
|
-
})
|
|
109
|
-
.finally(() => {
|
|
110
|
-
this.pendingAuth = null;
|
|
111
|
-
});
|
|
112
|
-
this.logger.info('device auth started — user must open URL', { url: verificationUrl });
|
|
113
|
-
return result;
|
|
114
|
-
}
|
|
115
|
-
async pollUntilComplete(deviceCode, intervalS, expiresInS, sessionPrivateKey, signerAddress) {
|
|
116
|
-
const deadline = Date.now() + expiresInS * 1000;
|
|
117
|
-
while (Date.now() < deadline) {
|
|
118
|
-
await sleep(intervalS * 1000);
|
|
119
|
-
const { status, data } = await this.api.request('/api/v1/auth/device/token', {
|
|
120
|
-
method: 'POST',
|
|
121
|
-
body: { deviceCode },
|
|
122
|
-
});
|
|
123
|
-
if (status === HttpStatus.Accepted) {
|
|
124
|
-
this.logger.debug('device auth still pending');
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
127
|
-
if (status !== HttpStatus.Ok) {
|
|
128
|
-
throw new Error(`Device auth polling failed: ${status}`);
|
|
129
|
-
}
|
|
130
|
-
const now = new Date().toISOString();
|
|
131
|
-
this.session.setSession({
|
|
132
|
-
walletMode: WalletMode.AGW,
|
|
133
|
-
address: signerAddress,
|
|
134
|
-
sessionPrivateKey,
|
|
135
|
-
jwt: null,
|
|
136
|
-
sessionConfig: data.sessionConfig,
|
|
137
|
-
createdAt: now,
|
|
138
|
-
updatedAt: now,
|
|
139
|
-
});
|
|
140
|
-
this.logger.info('device auth completed', { address: signerAddress });
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
throw new Error('Device authorization timed out. Please try again.');
|
|
144
|
-
}
|
|
145
88
|
}
|
|
146
89
|
//# sourceMappingURL=auth.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.service.js","sourceRoot":"","sources":["../../src/services/auth.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"auth.service.js","sourceRoot":"","sources":["../../src/services/auth.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGnD,OAAO,EAAE,UAAU,EAAwE,MAAM,iBAAiB,CAAC;AAEnH,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,MAAM,OAAO,WAAW;IACH,OAAO,CAAiB;IACxB,GAAG,CAAY;IACf,MAAM,CAAiB;IACvB,MAAM,CAAU;IAEjC,YAAY,OAA2B;QACnC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAA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AAC,IAAI,CAAC;IAU/C,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAerD,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAenD,KAAK,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAUzC,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;CAa9D"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { encodeFunctionData } from 'viem';
|
|
2
|
-
import { withRevealInFlightPhrase, withRevealRequestPhrase } from './reveal-revert.utils.js';
|
|
2
|
+
import { withRevealInFlightPhrase, withRevealQuotePhrase, withRevealRequestPhrase } from './reveal-revert.utils.js';
|
|
3
3
|
import { CELL_ABI } from '../contracts/cell.abi.js';
|
|
4
4
|
import { bufferedGasLimit } from '../wallet/gas.utils.js';
|
|
5
5
|
export class CellClient {
|
|
@@ -18,18 +18,31 @@ export class CellClient {
|
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
async quoteReveal(cell) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
let quote;
|
|
22
|
+
try {
|
|
23
|
+
quote = await this.contracts.read({
|
|
24
|
+
address: cell,
|
|
25
|
+
abi: CELL_ABI,
|
|
26
|
+
functionName: 'quoteReveal',
|
|
27
|
+
args: [],
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
throw withRevealQuotePhrase(error);
|
|
32
|
+
}
|
|
33
|
+
const [poolContributionWei, randomnessFeeWei, ethBudgetWei, cpuBurnWei, metadataPublicationChargeWei] = quote;
|
|
27
34
|
this.logger.info('quoted the reveal', {
|
|
28
35
|
cell,
|
|
29
|
-
|
|
36
|
+
ethBudgetWei: ethBudgetWei.toString(),
|
|
30
37
|
cpuBurnWei: cpuBurnWei.toString(),
|
|
31
38
|
});
|
|
32
|
-
return {
|
|
39
|
+
return {
|
|
40
|
+
poolContributionWei,
|
|
41
|
+
randomnessFeeWei,
|
|
42
|
+
ethBudgetWei,
|
|
43
|
+
cpuBurnWei,
|
|
44
|
+
metadataPublicationChargeWei,
|
|
45
|
+
};
|
|
33
46
|
}
|
|
34
47
|
async requestReveal(params) {
|
|
35
48
|
const data = encodeFunctionData({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cell.client.js","sourceRoot":"","sources":["../../src/services/cell.client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAA2B,MAAM,MAAM,CAAC;AAEnE,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"cell.client.js","sourceRoot":"","sources":["../../src/services/cell.client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAA2B,MAAM,MAAM,CAAC;AAEnE,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAcpH,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D,MAAM,OAAO,UAAU;IACF,SAAS,CAAkB;IAC3B,MAAM,CAAU;IAEjC,YAAY,OAA0B;QAClC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,IAAa,EAAE,OAAe;QAC7C,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAiB;YACvC,OAAO,EAAE,IAAI;YACb,GAAG,EAAE,QAAQ;YACb,YAAY,EAAE,SAAS;YACvB,IAAI,EAAE,CAAC,OAAO,CAAC;SAClB,CAAC,C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M,IAAI,GAAG,kBAAkB,CAAC;YAC5B,GAAG,EAAE,QAAQ;YACb,YAAY,EAAE,aAAa;YAC3B,IAAI,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC;SACxC,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,wBAAwB,EAAE;YACvC,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,QAAQ,EAAE;YAClC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE;SACnC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,QAAQ,CAAC,CAAC;IAC5F,CAAC;CACJ"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const LOT_RETURN_REVERT_NAMES: readonly ["FeeExceedsMax", "LotNotOpen", "LotNotEvicted", "NotSeller", "WrongHub", "NotDestOwner", "PathTooShort", "DegenerateWaypoint", "NotEligibleWaypoint", "HopOutOfRange", "NotWaypointOwner", "NotRevealed", "BelowMinAmount", "ZeroAmount"];
|
|
2
|
+
export declare const LOT_RETURN_REVERT_REASONS: Readonly<Record<(typeof LOT_RETURN_REVERT_NAMES)[number], string>>;
|
|
3
|
+
//# sourceMappingURL=lot-return.constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lot-return.constants.d.ts","sourceRoot":"","sources":["../../src/services/lot-return.constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,qPAe1B,CAAC;AAEX,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAmBxG,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export const LOT_RETURN_REVERT_NAMES = [
|
|
2
|
+
'FeeExceedsMax',
|
|
3
|
+
'LotNotOpen',
|
|
4
|
+
'LotNotEvicted',
|
|
5
|
+
'NotSeller',
|
|
6
|
+
'WrongHub',
|
|
7
|
+
'NotDestOwner',
|
|
8
|
+
'PathTooShort',
|
|
9
|
+
'DegenerateWaypoint',
|
|
10
|
+
'NotEligibleWaypoint',
|
|
11
|
+
'HopOutOfRange',
|
|
12
|
+
'NotWaypointOwner',
|
|
13
|
+
'NotRevealed',
|
|
14
|
+
'BelowMinAmount',
|
|
15
|
+
'ZeroAmount',
|
|
16
|
+
];
|
|
17
|
+
export const LOT_RETURN_REVERT_REASONS = {
|
|
18
|
+
FeeExceedsMax: 'the whole route priced out above the ceiling that travelled with the call, so the chain refused it ' +
|
|
19
|
+
'and nothing was spent — quote the return again and send it straight away',
|
|
20
|
+
LotNotOpen: 'the lot is no longer open — re-read it, then return it through the branch its state calls for',
|
|
21
|
+
LotNotEvicted: 'the lot is not evicted — re-read it, then return it through the branch its state calls for',
|
|
22
|
+
NotSeller: 'the lot is not yours to return',
|
|
23
|
+
WrongHub: "the route must start at the lot's hub",
|
|
24
|
+
NotDestOwner: 'the last cell on the route must be one you own',
|
|
25
|
+
PathTooShort: 'the route needs at least the hub and your destination cell',
|
|
26
|
+
DegenerateWaypoint: 'the route visits the same cell twice',
|
|
27
|
+
NotEligibleWaypoint: 'a waypoint on the route is not eligible — a hub on the path cannot serve as a live node right now ' +
|
|
28
|
+
'(temporarily unroutable, not frozen)',
|
|
29
|
+
HopOutOfRange: "a hop on the route is longer than transport's reach",
|
|
30
|
+
NotWaypointOwner: 'a non-hub waypoint on the route is not owned by you',
|
|
31
|
+
NotRevealed: 'a cell on the route (or the hub) is not revealed yet',
|
|
32
|
+
BelowMinAmount: "the remainder is below transport's minimum shipment",
|
|
33
|
+
ZeroAmount: 'the lot has no units left to send home',
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=lot-return.constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lot-return.constants.js","sourceRoot":"","sources":["../../src/services/lot-return.constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACnC,eAAe;IACf,YAAY;IACZ,eAAe;IACf,WAAW;IACX,UAAU;IACV,cAAc;IACd,cAAc;IACd,oBAAoB;IACpB,qBAAqB;IACrB,eAAe;IACf,kBAAkB;IAClB,aAAa;IACb,gBAAgB;IAChB,YAAY;CACN,CAAC;AAEX,MAAM,CAAC,MAAM,yBAAyB,GAAuE;IACzG,aAAa,EACT,qGAAqG;QACrG,0EAA0E;IAC9E,UAAU,EAAE,+FAA+F;IAC3G,aAAa,EAAE,4FAA4F;IAC3G,SAAS,EAAE,gCAAgC;IAC3C,QAAQ,EAAE,uCAAuC;IACjD,YAAY,EAAE,gDAAgD;IAC9D,YAAY,EAAE,4DAA4D;IAC1E,kBAAkB,EAAE,sCAAsC;IAC1D,mBAAmB,EACf,oGAAoG;QACpG,sCAAsC;IAC1C,aAAa,EAAE,qDAAqD;IACpE,gBAAgB,EAAE,qDAAqD;IACvE,WAAW,EAAE,sDAAsD;IACnE,cAAc,EAAE,qDAAqD;IACrE,UAAU,EAAE,wCAAwC;CACvD,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ILotReturnService, LotReturnServiceOptions } from './lot-return.types.js';
|
|
2
|
+
import { type LotReturnInput, type LotReturnQuote, type LotReturnQuoteInput, type LotReturnResult } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* One seller intent — send a lot's whole unsold remainder home — over the two contract branches that can
|
|
5
|
+
* carry it: `cancel` for an Open lot, `reclaim` for an Evicted one. Both are priced by `Trade.quoteReturn`
|
|
6
|
+
* and both carry the ceiling the seller passes in, never a figure this service picked for them: the route is
|
|
7
|
+
* re-priced on-chain to decide, and a fee that outgrew the seller's ceiling refuses before anything is spent.
|
|
8
|
+
*/
|
|
9
|
+
export declare class LotReturnService implements ILotReturnService {
|
|
10
|
+
private readonly wallet;
|
|
11
|
+
private readonly appConfig;
|
|
12
|
+
private readonly allowance;
|
|
13
|
+
private readonly contracts;
|
|
14
|
+
private readonly tradeClient;
|
|
15
|
+
private readonly mapReader;
|
|
16
|
+
private readonly logger;
|
|
17
|
+
constructor(options: LotReturnServiceOptions);
|
|
18
|
+
quoteReturn(input: LotReturnQuoteInput): Promise<LotReturnQuote>;
|
|
19
|
+
returnLot(input: LotReturnInput): Promise<LotReturnResult>;
|
|
20
|
+
private prepare;
|
|
21
|
+
private quoteOnChain;
|
|
22
|
+
private assessDestination;
|
|
23
|
+
private toQuoteView;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=lot-return.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lot-return.service.d.ts","sourceRoot":"","sources":["../../src/services/lot-return.service.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAexF,OAAO,EAMH,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,eAAe,EAGvB,MAAM,YAAY,CAAC;AAqBpB;;;;;GAKG;AACH,qBAAa,gBAAiB,YAAW,iBAAiB;IACtD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IACxC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAa;IACvC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAoB;IAC9C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAkB;IAC5C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAe;IAC3C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAmB;IAC7C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAU;gBAErB,OAAO,EAAE,uBAAuB;IAUtC,WAAW,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,cAAc,CAAC;IAOhE,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;YAqElD,OAAO;YAuBP,YAAY;YASZ,iBAAiB;IAmB/B,OAAO,CAAC,WAAW;CAmBtB"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { decodeDeliveryScheduled, settleTransitFees } from './delivery.helpers.js';
|
|
2
|
+
import { assertFeeWithinCeiling, assertReturnRoute, assertReturnableLot, assertRouteStartsAtHub, assertWholeRemainder, decodeReturnedUnits, describeCapacityRefusal, describeLotReturnRevert, parseFeeCeilingWei, returnBranchOf, } from './lot-return.utils.js';
|
|
3
|
+
import { preparePaidAction } from './paid-action.js';
|
|
4
|
+
import { AppContract } from './paid-action.types.js';
|
|
5
|
+
import { LotReturnBranch, } from './types.js';
|
|
6
|
+
import { assessDestinationCapacity } from './warehouse.utils.js';
|
|
7
|
+
import { toProjectionConfig } from '../map/reader.utils.js';
|
|
8
|
+
import { configuredStorageCap, usesHubShelf } from '../map/storage.utils.js';
|
|
9
|
+
import { cpuFromWei } from '../utils/format.utils.js';
|
|
10
|
+
/**
|
|
11
|
+
* One seller intent — send a lot's whole unsold remainder home — over the two contract branches that can
|
|
12
|
+
* carry it: `cancel` for an Open lot, `reclaim` for an Evicted one. Both are priced by `Trade.quoteReturn`
|
|
13
|
+
* and both carry the ceiling the seller passes in, never a figure this service picked for them: the route is
|
|
14
|
+
* re-priced on-chain to decide, and a fee that outgrew the seller's ceiling refuses before anything is spent.
|
|
15
|
+
*/
|
|
16
|
+
export class LotReturnService {
|
|
17
|
+
wallet;
|
|
18
|
+
appConfig;
|
|
19
|
+
allowance;
|
|
20
|
+
contracts;
|
|
21
|
+
tradeClient;
|
|
22
|
+
mapReader;
|
|
23
|
+
logger;
|
|
24
|
+
constructor(options) {
|
|
25
|
+
this.wallet = options.wallet;
|
|
26
|
+
this.appConfig = options.appConfig;
|
|
27
|
+
this.allowance = options.allowance;
|
|
28
|
+
this.contracts = options.contracts;
|
|
29
|
+
this.tradeClient = options.tradeClient;
|
|
30
|
+
this.mapReader = options.mapReader;
|
|
31
|
+
this.logger = options.logger;
|
|
32
|
+
}
|
|
33
|
+
async quoteReturn(input) {
|
|
34
|
+
const prepared = await this.prepare(input);
|
|
35
|
+
const quote = await this.quoteOnChain(prepared);
|
|
36
|
+
const capacity = await this.assessDestination(prepared, quote.amount);
|
|
37
|
+
return this.toQuoteView(prepared, quote, capacity);
|
|
38
|
+
}
|
|
39
|
+
async returnLot(input) {
|
|
40
|
+
const maxFee = parseFeeCeilingWei(input.maxTransitFeeWei, input.lotId);
|
|
41
|
+
const prepared = await this.prepare(input);
|
|
42
|
+
const { action, trade, lot, state, lotId, returnTokenIds } = prepared;
|
|
43
|
+
const transport = action.requireContract(AppContract.Transport, 'cannot route goods');
|
|
44
|
+
const quote = await this.quoteOnChain(prepared);
|
|
45
|
+
assertWholeRemainder(quote.amount, lot.remaining, input.lotId);
|
|
46
|
+
assertFeeWithinCeiling(quote.transitFee, maxFee, input.lotId);
|
|
47
|
+
const capacity = await this.assessDestination(prepared, quote.amount);
|
|
48
|
+
if (!capacity.fits) {
|
|
49
|
+
throw new Error(describeCapacityRefusal(capacity, prepared.destinationTokenId, input.lotId));
|
|
50
|
+
}
|
|
51
|
+
const branch = returnBranchOf(state);
|
|
52
|
+
// The price decides whether an allowance is needed at all; the ceiling only decides how much it caps.
|
|
53
|
+
// Keying this on the ceiling would send an unbounded approve for a route that costs nothing.
|
|
54
|
+
const approveTxHash = quote.transitFee === 0n
|
|
55
|
+
? null
|
|
56
|
+
: await this.allowance.ensureAllowance(action.requireContract(AppContract.CpuToken, 'cannot pay for transit'), transport, maxFee);
|
|
57
|
+
this.logger.info('returning lot', {
|
|
58
|
+
lotId: input.lotId,
|
|
59
|
+
branch,
|
|
60
|
+
maxFeeWei: maxFee.toString(),
|
|
61
|
+
quotedFeeWei: quote.transitFee.toString(),
|
|
62
|
+
amount: quote.amount.toString(),
|
|
63
|
+
});
|
|
64
|
+
let confirmed;
|
|
65
|
+
try {
|
|
66
|
+
const txHash = branch === LotReturnBranch.Reclaimed
|
|
67
|
+
? await this.tradeClient.reclaim({ trade, lotId, returnTokenIds, maxFee })
|
|
68
|
+
: await this.tradeClient.cancel({ trade, lotId, returnTokenIds, maxFee });
|
|
69
|
+
confirmed = await this.contracts.confirm(txHash, `Return lot ${input.lotId}`);
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
throw describeLotReturnRevert(error, branch);
|
|
73
|
+
}
|
|
74
|
+
const scheduled = decodeDeliveryScheduled(confirmed.logs, transport);
|
|
75
|
+
const transit = settleTransitFees(confirmed.logs, transport, quote.transitFee);
|
|
76
|
+
const returned = decodeReturnedUnits(confirmed.logs, trade, quote.amount, this.logger);
|
|
77
|
+
return {
|
|
78
|
+
lotId: input.lotId,
|
|
79
|
+
originalState: state,
|
|
80
|
+
branch,
|
|
81
|
+
hubTokenId: lot.hub.toString(),
|
|
82
|
+
resourceId: lot.resource,
|
|
83
|
+
returned: returned.toString(),
|
|
84
|
+
transitPaid: cpuFromWei(transit.transitPaid.toString()),
|
|
85
|
+
transitDiscount: cpuFromWei(transit.transitDiscount.toString()),
|
|
86
|
+
destinationTokenId: scheduled.targetId.toString(),
|
|
87
|
+
deliveryId: scheduled.deliveryId.toString(),
|
|
88
|
+
arrivalAt: Number(scheduled.arrivalAt),
|
|
89
|
+
approveTxHash,
|
|
90
|
+
txHash: confirmed.txHash,
|
|
91
|
+
status: confirmed.status,
|
|
92
|
+
blockNumber: confirmed.blockNumber,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
async prepare(input) {
|
|
96
|
+
const action = await preparePaidAction({ appConfig: this.appConfig, wallet: this.wallet });
|
|
97
|
+
const trade = action.requireContract(AppContract.Trade, 'cannot return a lot');
|
|
98
|
+
assertReturnRoute(input.chain);
|
|
99
|
+
const seller = action.wallet.getAddress();
|
|
100
|
+
const lotId = BigInt(input.lotId);
|
|
101
|
+
const lot = await this.tradeClient.getLot({ trade, lotId });
|
|
102
|
+
const state = assertReturnableLot(lot, seller, input.lotId);
|
|
103
|
+
assertRouteStartsAtHub(input.chain, lot.hub, input.lotId);
|
|
104
|
+
return {
|
|
105
|
+
action,
|
|
106
|
+
trade,
|
|
107
|
+
lot,
|
|
108
|
+
state,
|
|
109
|
+
seller,
|
|
110
|
+
lotId,
|
|
111
|
+
returnTokenIds: input.chain.map((tokenId) => BigInt(tokenId)),
|
|
112
|
+
destinationTokenId: String(input.chain[input.chain.length - 1]),
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
async quoteOnChain(prepared) {
|
|
116
|
+
return this.tradeClient.quoteReturn({
|
|
117
|
+
trade: prepared.trade,
|
|
118
|
+
lotId: prepared.lotId,
|
|
119
|
+
returnTokenIds: prepared.returnTokenIds,
|
|
120
|
+
seller: prepared.seller,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
async assessDestination(prepared, required) {
|
|
124
|
+
await this.mapReader.refresh();
|
|
125
|
+
const cell = await this.mapReader.readRevealCell(prepared.destinationTokenId);
|
|
126
|
+
if (cell === null) {
|
|
127
|
+
throw new Error(`Cell ${prepared.destinationTokenId} is not in the world map, so the room it has for the ` +
|
|
128
|
+
`remainder cannot be checked. Nothing was sent — retry shortly, or route the return to a ` +
|
|
129
|
+
`revealed cell of your own.`);
|
|
130
|
+
}
|
|
131
|
+
const projection = toProjectionConfig(prepared.action.config);
|
|
132
|
+
const emptyStorageCap = configuredStorageCap(prepared.lot.resource, usesHubShelf(cell.building, cell.ready, projection), projection);
|
|
133
|
+
return assessDestinationCapacity(cell, prepared.lot.resource, required, emptyStorageCap);
|
|
134
|
+
}
|
|
135
|
+
toQuoteView(prepared, quote, capacity) {
|
|
136
|
+
return {
|
|
137
|
+
lotId: prepared.lotId.toString(),
|
|
138
|
+
hubTokenId: prepared.lot.hub.toString(),
|
|
139
|
+
resourceId: prepared.lot.resource,
|
|
140
|
+
amount: quote.amount.toString(),
|
|
141
|
+
destinationTokenId: prepared.destinationTokenId,
|
|
142
|
+
maxTransitFee: cpuFromWei(quote.transitFee.toString()),
|
|
143
|
+
maxTransitFeeWei: quote.transitFee.toString(),
|
|
144
|
+
transitDiscount: cpuFromWei(quote.transitDiscount.toString()),
|
|
145
|
+
totalDistance: Number(quote.totalDistance),
|
|
146
|
+
arrivalAt: Number(quote.arrivalAt),
|
|
147
|
+
capacity,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=lot-return.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lot-return.service.js","sourceRoot":"","sources":["../../src/services/lot-return.service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAEnF,OAAO,EACH,sBAAsB,EACtB,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACnB,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,EAClB,cAAc,GACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,WAAW,EAA0B,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EACH,eAAe,GAWlB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAGjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE7E,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AActD;;;;;GAKG;AACH,MAAM,OAAO,gBAAgB;IACR,MAAM,CAAiB;IACvB,SAAS,CAAa;IACtB,SAAS,CAAoB;IAC7B,SAAS,CAAkB;IAC3B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AQ,EAAE;YAChC,UAAU,EAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE;YACvC,UAAU,EAAE,QAAQ,CAAC,GAAG,CAAC,QAAQ;YACjC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE;YAC/B,kBAAkB,EAAE,QAAQ,CAAC,kBAAkB;YAC/C,aAAa,EAAE,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;YACtD,gBAAgB,EAAE,KAAK,CAAC,UAAU,CAAC,QAAQ,EAAE;YAC7C,eAAe,EAAE,UAAU,CAAC,KAAK,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC;YAC7D,aAAa,EAAE,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC;YAC1C,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC;YAClC,QAAQ;SACX,CAAC;IACN,CAAC;CACJ"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { IAllowanceService, IAppConfig, ITradeClient, LotReturnInput, LotReturnQuote, LotReturnQuoteInput, LotReturnResult } from './types.js';
|
|
2
|
+
import type { ILogger } from '../logger/types.js';
|
|
3
|
+
import type { RevealCellReader } from '../map/types.js';
|
|
4
|
+
import type { IContractClient, WalletProvider } from '../wallet/types.js';
|
|
5
|
+
export interface LotReturnServiceOptions {
|
|
6
|
+
wallet: WalletProvider;
|
|
7
|
+
appConfig: IAppConfig;
|
|
8
|
+
allowance: IAllowanceService;
|
|
9
|
+
contracts: IContractClient;
|
|
10
|
+
tradeClient: ITradeClient;
|
|
11
|
+
mapReader: RevealCellReader;
|
|
12
|
+
logger: ILogger;
|
|
13
|
+
}
|
|
14
|
+
/** One player intent — send a lot's whole remainder home — quoted and then settled. */
|
|
15
|
+
export interface ILotReturnService {
|
|
16
|
+
quoteReturn(input: LotReturnQuoteInput): Promise<LotReturnQuote>;
|
|
17
|
+
returnLot(input: LotReturnInput): Promise<LotReturnResult>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=lot-return.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lot-return.types.d.ts","sourceRoot":"","sources":["../../src/services/lot-return.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,iBAAiB,EACjB,UAAU,EACV,YAAY,EACZ,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,eAAe,EAClB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAE1E,MAAM,WAAW,uBAAuB;IACpC,MAAM,EAAE,cAAc,CAAC;IACvB,SAAS,EAAE,UAAU,CAAC;IACtB,SAAS,EAAE,iBAAiB,CAAC;IAC7B,SAAS,EAAE,eAAe,CAAC;IAC3B,WAAW,EAAE,YAAY,CAAC;IAC1B,SAAS,EAAE,gBAAgB,CAAC;IAC5B,MAAM,EAAE,OAAO,CAAC;CACnB;AAED,uFAAuF;AACvF,MAAM,WAAW,iBAAiB;IAC9B,WAAW,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IACjE,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CAC9D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lot-return.types.js","sourceRoot":"","sources":["../../src/services/lot-return.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type Address, type Log } from 'viem';
|
|
2
|
+
import { LotReturnBranch, type DestinationCapacityView, type OnChainLot } from './types.js';
|
|
3
|
+
import { LotState } from '../api/types.js';
|
|
4
|
+
import type { ILogger } from '../logger/types.js';
|
|
5
|
+
export declare function assertReturnRoute(chain: Array<number>): void;
|
|
6
|
+
/**
|
|
7
|
+
* The chain is the arbiter of what a lot is: the projection can lag an eviction or a sell-out by a block,
|
|
8
|
+
* and a return sent against a stale state is a spend that reverts.
|
|
9
|
+
*/
|
|
10
|
+
export declare function assertReturnableLot(lot: OnChainLot, seller: Address, lotId: string): LotState;
|
|
11
|
+
export declare function assertRouteStartsAtHub(chain: Array<number>, hub: bigint, lotId: string): void;
|
|
12
|
+
/** A lot return is all-or-nothing; a quote for anything but the current remainder is a partial return. */
|
|
13
|
+
export declare function assertWholeRemainder(quoted: bigint, remaining: bigint, lotId: string): void;
|
|
14
|
+
/** The ceiling travels as wei precisely so nothing rounds it; a figure that is not whole wei is not a ceiling. */
|
|
15
|
+
export declare function parseFeeCeilingWei(maxTransitFeeWei: string, lotId: string): bigint;
|
|
16
|
+
/**
|
|
17
|
+
* The client half of the fee promise. Only the source hub's rate is pinned on-chain, at the figure recorded
|
|
18
|
+
* when the lot was listed, so any later waypoint can raise its own between the quote and this call. The
|
|
19
|
+
* ceiling itself does travel with the transaction and caps the whole route total there, but that backstop
|
|
20
|
+
* only fires once gas is committed: refusing here — before the allowance, before the transaction — is what
|
|
21
|
+
* makes a stale ceiling cost a re-quote instead of a reverted spend.
|
|
22
|
+
*/
|
|
23
|
+
export declare function assertFeeWithinCeiling(quotedWei: bigint, ceilingWei: bigint, lotId: string): void;
|
|
24
|
+
export declare function returnBranchOf(state: LotState): LotReturnBranch;
|
|
25
|
+
export declare function describeCapacityRefusal(capacity: DestinationCapacityView, destinationTokenId: string, lotId: string): string;
|
|
26
|
+
export declare function describeLotReturnRevert(error: unknown, branch: LotReturnBranch): unknown;
|
|
27
|
+
/**
|
|
28
|
+
* Both branches close the lot with the same lifecycle event. When a receipt carries none — a contract that
|
|
29
|
+
* settles a reclaim silently — the quote the contract itself just priced is the only honest figure left, and
|
|
30
|
+
* refusing to answer would report a settled return as a failure.
|
|
31
|
+
*/
|
|
32
|
+
export declare function decodeReturnedUnits(logs: Array<Log>, trade: Address, quoted: bigint, logger: ILogger): bigint;
|
|
33
|
+
//# sourceMappingURL=lot-return.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lot-return.utils.d.ts","sourceRoot":"","sources":["../../src/services/lot-return.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,KAAK,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AAKpF,OAAO,EAAE,eAAe,EAAE,KAAK,uBAAuB,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAC5F,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG3C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAMlD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI,CAc5D;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ,CAiB7F;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAQ7F;AAED,0GAA0G;AAC1G,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAQ3F;AAED,kHAAkH;AAClH,wBAAgB,kBAAkB,CAAC,gBAAgB,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAoBlF;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAWjG;AAED,wBAAgB,cAAc,CAAC,KA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