project-cpu-mcp 0.12.0 → 0.12.2
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/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +7 -3
- package/dist/api/client.js.map +1 -1
- package/dist/api/types.d.ts +12 -1
- package/dist/api/types.d.ts.map +1 -1
- package/dist/api/types.js +2 -0
- package/dist/api/types.js.map +1 -1
- package/dist/contracts/approval.constants.d.ts +4 -0
- package/dist/contracts/approval.constants.d.ts.map +1 -0
- package/dist/contracts/approval.constants.js +4 -0
- package/dist/contracts/approval.constants.js.map +1 -0
- package/dist/contracts/approval.types.d.ts +9 -0
- package/dist/contracts/approval.types.d.ts.map +1 -0
- package/dist/contracts/approval.types.js +2 -0
- package/dist/contracts/approval.types.js.map +1 -0
- package/dist/contracts/approval.utils.d.ts +4 -0
- package/dist/contracts/approval.utils.d.ts.map +1 -0
- package/dist/contracts/approval.utils.js +41 -0
- package/dist/contracts/approval.utils.js.map +1 -0
- package/dist/contracts/erc721.abi.d.ts +27 -0
- package/dist/contracts/erc721.abi.d.ts.map +1 -0
- package/dist/contracts/erc721.abi.js +6 -0
- package/dist/contracts/erc721.abi.js.map +1 -0
- package/dist/contracts/seaport-events.abi.d.ts +95 -0
- package/dist/contracts/seaport-events.abi.d.ts.map +1 -0
- package/dist/contracts/seaport-events.abi.js +52 -0
- package/dist/contracts/seaport-events.abi.js.map +1 -0
- package/dist/contracts/seaport-spender.reader.d.ts +9 -0
- package/dist/contracts/seaport-spender.reader.d.ts.map +1 -0
- package/dist/contracts/seaport-spender.reader.js +101 -0
- package/dist/contracts/seaport-spender.reader.js.map +1 -0
- package/dist/contracts/seaport.constants.d.ts +136 -0
- package/dist/contracts/seaport.constants.d.ts.map +1 -0
- package/dist/contracts/seaport.constants.js +57 -0
- package/dist/contracts/seaport.constants.js.map +1 -0
- package/dist/contracts/seaport.types.d.ts +34 -0
- package/dist/contracts/seaport.types.d.ts.map +1 -0
- package/dist/contracts/seaport.types.js +24 -0
- package/dist/contracts/seaport.types.js.map +1 -0
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/dist/logger/constants.d.ts.map +1 -1
- package/dist/logger/constants.js +2 -0
- package/dist/logger/constants.js.map +1 -1
- package/dist/paybox/auth/types.d.ts +2 -2
- package/dist/paybox/auth/types.d.ts.map +1 -1
- package/dist/paybox/sdk/adapter.d.ts +2 -1
- package/dist/paybox/sdk/adapter.d.ts.map +1 -1
- package/dist/paybox/sdk/adapter.js +24 -0
- package/dist/paybox/sdk/adapter.js.map +1 -1
- package/dist/paybox/types.d.ts +20 -16
- package/dist/paybox/types.d.ts.map +1 -1
- package/dist/paybox/types.js +1 -0
- package/dist/paybox/types.js.map +1 -1
- package/dist/paybox/wallet/manager.d.ts +3 -1
- package/dist/paybox/wallet/manager.d.ts.map +1 -1
- package/dist/paybox/wallet/manager.js +16 -5
- package/dist/paybox/wallet/manager.js.map +1 -1
- package/dist/paybox/wallet/rpc.client.d.ts +1 -0
- package/dist/paybox/wallet/rpc.client.d.ts.map +1 -1
- package/dist/paybox/wallet/rpc.client.js +4 -0
- package/dist/paybox/wallet/rpc.client.js.map +1 -1
- package/dist/paybox/wallet/utils.d.ts +0 -2
- package/dist/paybox/wallet/utils.d.ts.map +1 -1
- package/dist/paybox/wallet/utils.js +2 -65
- package/dist/paybox/wallet/utils.js.map +1 -1
- package/dist/server.constants.d.ts.map +1 -1
- package/dist/server.constants.js +13 -19
- package/dist/server.constants.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +11 -5
- 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 +1 -0
- package/dist/services/app-config.utils.js.map +1 -1
- package/dist/services/auth.service.d.ts.map +1 -1
- package/dist/services/auth.service.js +16 -4
- package/dist/services/auth.service.js.map +1 -1
- package/dist/services/market/acceptance.constants.d.ts +5 -0
- package/dist/services/market/acceptance.constants.d.ts.map +1 -0
- package/dist/services/market/acceptance.constants.js +6 -0
- package/dist/services/market/acceptance.constants.js.map +1 -0
- package/dist/services/market/acceptance.service.d.ts +51 -0
- package/dist/services/market/acceptance.service.d.ts.map +1 -0
- package/dist/services/market/acceptance.service.js +595 -0
- package/dist/services/market/acceptance.service.js.map +1 -0
- package/dist/services/market/acceptance.types.d.ts +214 -0
- package/dist/services/market/acceptance.types.d.ts.map +1 -0
- package/dist/services/market/acceptance.types.js +13 -0
- package/dist/services/market/acceptance.types.js.map +1 -0
- package/dist/services/market/acceptance.utils.d.ts +7 -0
- package/dist/services/market/acceptance.utils.d.ts.map +1 -0
- package/dist/services/market/acceptance.utils.js +15 -0
- package/dist/services/market/acceptance.utils.js.map +1 -0
- package/dist/services/market/action.types.d.ts +29 -0
- package/dist/services/market/action.types.d.ts.map +1 -0
- package/dist/services/market/action.types.js +9 -0
- package/dist/services/market/action.types.js.map +1 -0
- package/dist/services/market/budget.d.ts +17 -0
- package/dist/services/market/budget.d.ts.map +1 -0
- package/dist/services/market/budget.js +52 -0
- package/dist/services/market/budget.js.map +1 -0
- package/dist/services/market/budget.scope.d.ts +4 -0
- package/dist/services/market/budget.scope.d.ts.map +1 -0
- package/dist/services/market/budget.scope.js +10 -0
- package/dist/services/market/budget.scope.js.map +1 -0
- package/dist/services/market/budget.utils.d.ts +4 -0
- package/dist/services/market/budget.utils.d.ts.map +1 -0
- package/dist/services/market/budget.utils.js +29 -0
- package/dist/services/market/budget.utils.js.map +1 -0
- package/dist/services/market/cancel.abi.d.ts +108 -0
- package/dist/services/market/cancel.abi.d.ts.map +1 -0
- package/dist/services/market/cancel.abi.js +50 -0
- package/dist/services/market/cancel.abi.js.map +1 -0
- package/dist/services/market/cancel.constants.d.ts +4 -0
- package/dist/services/market/cancel.constants.d.ts.map +1 -0
- package/dist/services/market/cancel.constants.js +5 -0
- package/dist/services/market/cancel.constants.js.map +1 -0
- package/dist/services/market/cancel.service.d.ts +34 -0
- package/dist/services/market/cancel.service.d.ts.map +1 -0
- package/dist/services/market/cancel.service.js +342 -0
- package/dist/services/market/cancel.service.js.map +1 -0
- package/dist/services/market/cancel.types.d.ts +87 -0
- package/dist/services/market/cancel.types.d.ts.map +1 -0
- package/dist/services/market/cancel.types.js +8 -0
- package/dist/services/market/cancel.types.js.map +1 -0
- package/dist/services/market/cancel.utils.d.ts +7 -0
- package/dist/services/market/cancel.utils.d.ts.map +1 -0
- package/dist/services/market/cancel.utils.js +71 -0
- package/dist/services/market/cancel.utils.js.map +1 -0
- package/dist/services/market/client.d.ts +19 -0
- package/dist/services/market/client.d.ts.map +1 -0
- package/dist/services/market/client.js +198 -0
- package/dist/services/market/client.js.map +1 -0
- package/dist/services/market/client.types.d.ts +6 -0
- package/dist/services/market/client.types.d.ts.map +1 -0
- package/dist/services/market/client.types.js +2 -0
- package/dist/services/market/client.types.js.map +1 -0
- package/dist/services/market/constants.d.ts +21 -0
- package/dist/services/market/constants.d.ts.map +1 -0
- package/dist/services/market/constants.js +36 -0
- package/dist/services/market/constants.js.map +1 -0
- package/dist/services/market/error.d.ts +10 -0
- package/dist/services/market/error.d.ts.map +1 -0
- package/dist/services/market/error.js +18 -0
- package/dist/services/market/error.js.map +1 -0
- package/dist/services/market/error.utils.d.ts +10 -0
- package/dist/services/market/error.utils.d.ts.map +1 -0
- package/dist/services/market/error.utils.js +56 -0
- package/dist/services/market/error.utils.js.map +1 -0
- package/dist/services/market/factory.d.ts +4 -0
- package/dist/services/market/factory.d.ts.map +1 -0
- package/dist/services/market/factory.js +86 -0
- package/dist/services/market/factory.js.map +1 -0
- package/dist/services/market/factory.types.d.ts +34 -0
- package/dist/services/market/factory.types.d.ts.map +1 -0
- package/dist/services/market/factory.types.js +2 -0
- package/dist/services/market/factory.types.js.map +1 -0
- package/dist/services/market/fulfilment-proof.d.ts +13 -0
- package/dist/services/market/fulfilment-proof.d.ts.map +1 -0
- package/dist/services/market/fulfilment-proof.js +116 -0
- package/dist/services/market/fulfilment-proof.js.map +1 -0
- package/dist/services/market/fulfilment-proof.reader.d.ts +8 -0
- package/dist/services/market/fulfilment-proof.reader.d.ts.map +1 -0
- package/dist/services/market/fulfilment-proof.reader.js +22 -0
- package/dist/services/market/fulfilment-proof.reader.js.map +1 -0
- package/dist/services/market/fulfilment-proof.types.d.ts +46 -0
- package/dist/services/market/fulfilment-proof.types.d.ts.map +1 -0
- package/dist/services/market/fulfilment-proof.types.js +6 -0
- package/dist/services/market/fulfilment-proof.types.js.map +1 -0
- package/dist/services/market/fulfilment-proof.utils.d.ts +19 -0
- package/dist/services/market/fulfilment-proof.utils.d.ts.map +1 -0
- package/dist/services/market/fulfilment-proof.utils.js +69 -0
- package/dist/services/market/fulfilment-proof.utils.js.map +1 -0
- package/dist/services/market/idempotency.utils.d.ts +4 -0
- package/dist/services/market/idempotency.utils.d.ts.map +1 -0
- package/dist/services/market/idempotency.utils.js +15 -0
- package/dist/services/market/idempotency.utils.js.map +1 -0
- package/dist/services/market/listing.constants.d.ts +7 -0
- package/dist/services/market/listing.constants.d.ts.map +1 -0
- package/dist/services/market/listing.constants.js +8 -0
- package/dist/services/market/listing.constants.js.map +1 -0
- package/dist/services/market/listing.service.d.ts +53 -0
- package/dist/services/market/listing.service.d.ts.map +1 -0
- package/dist/services/market/listing.service.js +671 -0
- package/dist/services/market/listing.service.js.map +1 -0
- package/dist/services/market/listing.types.d.ts +718 -0
- package/dist/services/market/listing.types.d.ts.map +1 -0
- package/dist/services/market/listing.types.js +84 -0
- package/dist/services/market/listing.types.js.map +1 -0
- package/dist/services/market/listing.utils.d.ts +12 -0
- package/dist/services/market/listing.utils.d.ts.map +1 -0
- package/dist/services/market/listing.utils.js +51 -0
- package/dist/services/market/listing.utils.js.map +1 -0
- package/dist/services/market/offer.constants.d.ts +8 -0
- package/dist/services/market/offer.constants.d.ts.map +1 -0
- package/dist/services/market/offer.constants.js +9 -0
- package/dist/services/market/offer.constants.js.map +1 -0
- package/dist/services/market/offer.service.d.ts +54 -0
- package/dist/services/market/offer.service.d.ts.map +1 -0
- package/dist/services/market/offer.service.js +757 -0
- package/dist/services/market/offer.service.js.map +1 -0
- package/dist/services/market/offer.types.d.ts +554 -0
- package/dist/services/market/offer.types.d.ts.map +1 -0
- package/dist/services/market/offer.types.js +73 -0
- package/dist/services/market/offer.types.js.map +1 -0
- package/dist/services/market/offer.utils.d.ts +7 -0
- package/dist/services/market/offer.utils.d.ts.map +1 -0
- package/dist/services/market/offer.utils.js +25 -0
- package/dist/services/market/offer.utils.js.map +1 -0
- package/dist/services/market/profile.client.d.ts +14 -0
- package/dist/services/market/profile.client.d.ts.map +1 -0
- package/dist/services/market/profile.client.js +65 -0
- package/dist/services/market/profile.client.js.map +1 -0
- package/dist/services/market/profile.schemas.d.ts +630 -0
- package/dist/services/market/profile.schemas.d.ts.map +1 -0
- package/dist/services/market/profile.schemas.js +84 -0
- package/dist/services/market/profile.schemas.js.map +1 -0
- package/dist/services/market/profile.utils.d.ts +2 -0
- package/dist/services/market/profile.utils.d.ts.map +1 -0
- package/dist/services/market/profile.utils.js +8 -0
- package/dist/services/market/profile.utils.js.map +1 -0
- package/dist/services/market/purchase.constants.d.ts +5 -0
- package/dist/services/market/purchase.constants.d.ts.map +1 -0
- package/dist/services/market/purchase.constants.js +6 -0
- package/dist/services/market/purchase.constants.js.map +1 -0
- package/dist/services/market/purchase.service.d.ts +48 -0
- package/dist/services/market/purchase.service.d.ts.map +1 -0
- package/dist/services/market/purchase.service.js +564 -0
- package/dist/services/market/purchase.service.js.map +1 -0
- package/dist/services/market/purchase.types.d.ts +207 -0
- package/dist/services/market/purchase.types.d.ts.map +1 -0
- package/dist/services/market/purchase.types.js +13 -0
- package/dist/services/market/purchase.types.js.map +1 -0
- package/dist/services/market/purchase.utils.d.ts +11 -0
- package/dist/services/market/purchase.utils.d.ts.map +1 -0
- package/dist/services/market/purchase.utils.js +29 -0
- package/dist/services/market/purchase.utils.js.map +1 -0
- package/dist/services/market/recovery.constants.d.ts +6 -0
- package/dist/services/market/recovery.constants.d.ts.map +1 -0
- package/dist/services/market/recovery.constants.js +6 -0
- package/dist/services/market/recovery.constants.js.map +1 -0
- package/dist/services/market/recovery.store.d.ts +10 -0
- package/dist/services/market/recovery.store.d.ts.map +1 -0
- package/dist/services/market/recovery.store.js +44 -0
- package/dist/services/market/recovery.store.js.map +1 -0
- package/dist/services/market/service.d.ts +11 -0
- package/dist/services/market/service.d.ts.map +1 -0
- package/dist/services/market/service.js +71 -0
- package/dist/services/market/service.js.map +1 -0
- package/dist/services/market/single-flight.d.ts +6 -0
- package/dist/services/market/single-flight.d.ts.map +1 -0
- package/dist/services/market/single-flight.js +19 -0
- package/dist/services/market/single-flight.js.map +1 -0
- package/dist/services/market/snapshot.schemas.d.ts +385 -0
- package/dist/services/market/snapshot.schemas.d.ts.map +1 -0
- package/dist/services/market/snapshot.schemas.js +67 -0
- package/dist/services/market/snapshot.schemas.js.map +1 -0
- package/dist/services/market/types.d.ts +787 -0
- package/dist/services/market/types.d.ts.map +1 -0
- package/dist/services/market/types.js +216 -0
- package/dist/services/market/types.js.map +1 -0
- package/dist/services/types.d.ts +2 -0
- package/dist/services/types.d.ts.map +1 -1
- package/dist/services/types.js.map +1 -1
- package/dist/session/jwt.utils.d.ts +1 -0
- package/dist/session/jwt.utils.d.ts.map +1 -1
- package/dist/session/jwt.utils.js +4 -0
- package/dist/session/jwt.utils.js.map +1 -1
- package/dist/session/manager.d.ts +1 -1
- package/dist/session/manager.d.ts.map +1 -1
- package/dist/session/manager.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.map +1 -1
- package/dist/tools/config/get-game-config/get-game-config.utils.js +1 -1
- package/dist/tools/config/get-game-config/get-game-config.utils.js.map +1 -1
- package/dist/tools/market/accept-offer/accept-offer.d.ts +4 -0
- package/dist/tools/market/accept-offer/accept-offer.d.ts.map +1 -0
- package/dist/tools/market/accept-offer/accept-offer.js +29 -0
- package/dist/tools/market/accept-offer/accept-offer.js.map +1 -0
- package/dist/tools/market/accept-offer/constants.d.ts +2 -0
- package/dist/tools/market/accept-offer/constants.d.ts.map +1 -0
- package/dist/tools/market/accept-offer/constants.js +27 -0
- package/dist/tools/market/accept-offer/constants.js.map +1 -0
- package/dist/tools/market/accept-offer/format.utils.d.ts +3 -0
- package/dist/tools/market/accept-offer/format.utils.d.ts.map +1 -0
- package/dist/tools/market/accept-offer/format.utils.js +22 -0
- package/dist/tools/market/accept-offer/format.utils.js.map +1 -0
- package/dist/tools/market/accept-offer/types.d.ts +9 -0
- package/dist/tools/market/accept-offer/types.d.ts.map +1 -0
- package/dist/tools/market/accept-offer/types.js +14 -0
- package/dist/tools/market/accept-offer/types.js.map +1 -0
- package/dist/tools/market/buy-cell/buy-cell.d.ts +4 -0
- package/dist/tools/market/buy-cell/buy-cell.d.ts.map +1 -0
- package/dist/tools/market/buy-cell/buy-cell.js +30 -0
- package/dist/tools/market/buy-cell/buy-cell.js.map +1 -0
- package/dist/tools/market/buy-cell/constants.d.ts +2 -0
- package/dist/tools/market/buy-cell/constants.d.ts.map +1 -0
- package/dist/tools/market/buy-cell/constants.js +23 -0
- package/dist/tools/market/buy-cell/constants.js.map +1 -0
- package/dist/tools/market/buy-cell/format.utils.d.ts +3 -0
- package/dist/tools/market/buy-cell/format.utils.d.ts.map +1 -0
- package/dist/tools/market/buy-cell/format.utils.js +17 -0
- package/dist/tools/market/buy-cell/format.utils.js.map +1 -0
- package/dist/tools/market/buy-cell/types.d.ts +6 -0
- package/dist/tools/market/buy-cell/types.d.ts.map +1 -0
- package/dist/tools/market/buy-cell/types.js +10 -0
- package/dist/tools/market/buy-cell/types.js.map +1 -0
- package/dist/tools/market/cancel-order/cancel-order.d.ts +4 -0
- package/dist/tools/market/cancel-order/cancel-order.d.ts.map +1 -0
- package/dist/tools/market/cancel-order/cancel-order.js +29 -0
- package/dist/tools/market/cancel-order/cancel-order.js.map +1 -0
- package/dist/tools/market/cancel-order/constants.d.ts +2 -0
- package/dist/tools/market/cancel-order/constants.d.ts.map +1 -0
- package/dist/tools/market/cancel-order/constants.js +22 -0
- package/dist/tools/market/cancel-order/constants.js.map +1 -0
- package/dist/tools/market/cancel-order/format.utils.d.ts +3 -0
- package/dist/tools/market/cancel-order/format.utils.d.ts.map +1 -0
- package/dist/tools/market/cancel-order/format.utils.js +13 -0
- package/dist/tools/market/cancel-order/format.utils.js.map +1 -0
- package/dist/tools/market/cancel-order/types.d.ts +8 -0
- package/dist/tools/market/cancel-order/types.d.ts.map +1 -0
- package/dist/tools/market/cancel-order/types.js +7 -0
- package/dist/tools/market/cancel-order/types.js.map +1 -0
- package/dist/tools/market/cell-market/cell-market.d.ts +4 -0
- package/dist/tools/market/cell-market/cell-market.d.ts.map +1 -0
- package/dist/tools/market/cell-market/cell-market.js +24 -0
- package/dist/tools/market/cell-market/cell-market.js.map +1 -0
- package/dist/tools/market/cell-market/constants.d.ts +2 -0
- package/dist/tools/market/cell-market/constants.d.ts.map +1 -0
- package/dist/tools/market/cell-market/constants.js +16 -0
- package/dist/tools/market/cell-market/constants.js.map +1 -0
- package/dist/tools/market/format.utils.d.ts +8 -0
- package/dist/tools/market/format.utils.d.ts.map +1 -0
- package/dist/tools/market/format.utils.js +75 -0
- package/dist/tools/market/format.utils.js.map +1 -0
- package/dist/tools/market/list-cell/constants.d.ts +2 -0
- package/dist/tools/market/list-cell/constants.d.ts.map +1 -0
- package/dist/tools/market/list-cell/constants.js +23 -0
- package/dist/tools/market/list-cell/constants.js.map +1 -0
- package/dist/tools/market/list-cell/list-cell.d.ts +4 -0
- package/dist/tools/market/list-cell/list-cell.d.ts.map +1 -0
- package/dist/tools/market/list-cell/list-cell.js +31 -0
- package/dist/tools/market/list-cell/list-cell.js.map +1 -0
- package/dist/tools/market/list-cell/types.d.ts +7 -0
- package/dist/tools/market/list-cell/types.d.ts.map +1 -0
- package/dist/tools/market/list-cell/types.js +15 -0
- package/dist/tools/market/list-cell/types.js.map +1 -0
- package/dist/tools/market/make-offer/constants.d.ts +2 -0
- package/dist/tools/market/make-offer/constants.d.ts.map +1 -0
- package/dist/tools/market/make-offer/constants.js +22 -0
- package/dist/tools/market/make-offer/constants.js.map +1 -0
- package/dist/tools/market/make-offer/format.utils.d.ts +3 -0
- package/dist/tools/market/make-offer/format.utils.d.ts.map +1 -0
- package/dist/tools/market/make-offer/format.utils.js +16 -0
- package/dist/tools/market/make-offer/format.utils.js.map +1 -0
- package/dist/tools/market/make-offer/make-offer.d.ts +4 -0
- package/dist/tools/market/make-offer/make-offer.d.ts.map +1 -0
- package/dist/tools/market/make-offer/make-offer.js +30 -0
- package/dist/tools/market/make-offer/make-offer.js.map +1 -0
- package/dist/tools/market/make-offer/types.d.ts +10 -0
- package/dist/tools/market/make-offer/types.d.ts.map +1 -0
- package/dist/tools/market/make-offer/types.js +10 -0
- package/dist/tools/market/make-offer/types.js.map +1 -0
- package/dist/tools/market/my-listings/constants.d.ts +2 -0
- package/dist/tools/market/my-listings/constants.d.ts.map +1 -0
- package/dist/tools/market/my-listings/constants.js +14 -0
- package/dist/tools/market/my-listings/constants.js.map +1 -0
- package/dist/tools/market/my-listings/my-listings.d.ts +4 -0
- package/dist/tools/market/my-listings/my-listings.d.ts.map +1 -0
- package/dist/tools/market/my-listings/my-listings.js +24 -0
- package/dist/tools/market/my-listings/my-listings.js.map +1 -0
- package/dist/tools/market/my-offers/constants.d.ts +2 -0
- package/dist/tools/market/my-offers/constants.d.ts.map +1 -0
- package/dist/tools/market/my-offers/constants.js +15 -0
- package/dist/tools/market/my-offers/constants.js.map +1 -0
- package/dist/tools/market/my-offers/my-offers.d.ts +4 -0
- package/dist/tools/market/my-offers/my-offers.d.ts.map +1 -0
- package/dist/tools/market/my-offers/my-offers.js +24 -0
- package/dist/tools/market/my-offers/my-offers.js.map +1 -0
- package/dist/tools/market/my-offers-received/constants.d.ts +2 -0
- package/dist/tools/market/my-offers-received/constants.d.ts.map +1 -0
- package/dist/tools/market/my-offers-received/constants.js +16 -0
- package/dist/tools/market/my-offers-received/constants.js.map +1 -0
- package/dist/tools/market/my-offers-received/my-offers-received.d.ts +4 -0
- package/dist/tools/market/my-offers-received/my-offers-received.d.ts.map +1 -0
- package/dist/tools/market/my-offers-received/my-offers-received.js +24 -0
- package/dist/tools/market/my-offers-received/my-offers-received.js.map +1 -0
- package/dist/tools/market/output.types.d.ts +822 -0
- package/dist/tools/market/output.types.d.ts.map +1 -0
- package/dist/tools/market/output.types.js +75 -0
- package/dist/tools/market/output.types.js.map +1 -0
- package/dist/tools/market/register.d.ts +12 -0
- package/dist/tools/market/register.d.ts.map +1 -0
- package/dist/tools/market/register.js +50 -0
- package/dist/tools/market/register.js.map +1 -0
- package/dist/tools/market/types.d.ts +16 -0
- package/dist/tools/market/types.d.ts.map +1 -0
- package/dist/tools/market/types.js +14 -0
- package/dist/tools/market/types.js.map +1 -0
- package/dist/tools/types.d.ts +6 -1
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js +5 -0
- package/dist/tools/types.js.map +1 -1
- package/dist/types.d.ts +14 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/wallet/evm.manager.d.ts +3 -1
- package/dist/wallet/evm.manager.d.ts.map +1 -1
- package/dist/wallet/evm.manager.js +12 -0
- package/dist/wallet/evm.manager.js.map +1 -1
- package/dist/wallet/evm.provider.d.ts.map +1 -1
- package/dist/wallet/evm.provider.js +0 -3
- package/dist/wallet/evm.provider.js.map +1 -1
- package/dist/wallet/types.d.ts +19 -0
- package/dist/wallet/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,757 @@
|
|
|
1
|
+
import { zeroAddress } from 'viem';
|
|
2
|
+
import { MarketActionTool, } from './action.types.js';
|
|
3
|
+
import { narrowInvocationDeadline, waitOnInvocationBudget, waitWithinInvocationBudget } from './budget.utils.js';
|
|
4
|
+
import { MARKET_RETRY_BUDGET_MS, MS_PER_SECOND, PROVEN_UNPUBLISHED_MARKET_ERROR_CODES } from './constants.js';
|
|
5
|
+
import { MarketError } from './error.js';
|
|
6
|
+
import { marketActionKey } from './idempotency.utils.js';
|
|
7
|
+
import { MarketScanOutcome } from './listing.types.js';
|
|
8
|
+
import { sameAddress, seaportSignableOrder } from './listing.utils.js';
|
|
9
|
+
import { MARKET_OFFER_PREPARE_PATH, MARKET_OFFER_SUBMIT_PATH, OFFER_NO_IDENTIFIER, OFFER_NO_VALUE, OFFER_SINGLE_UNIT, OFFER_START_TIME_SKEW_SECONDS, OFFER_SUBMIT_MAX_ATTEMPTS, } from './offer.constants.js';
|
|
10
|
+
import { prepareOfferResponseSchemaFor, submitOfferResponseSchemaFor, usdgOfferAmountSchema, } from './offer.types.js';
|
|
11
|
+
import { effectiveOfferDeadline, isEquivalentActiveOffer, offerActionInputs, orderCurrencyConsiderationTotal, } from './offer.utils.js';
|
|
12
|
+
import { MARKET_PROFILE_CACHE_MS, MARKET_RECONCILE_MAX_PAGES } from './recovery.constants.js';
|
|
13
|
+
import { cellTokenIdSchema, evmAddressSchema, MarketActionStage, MarketActionStatus, MarketErrorCode, MarketOfferKind, MarketTransactionKind, unixSecondsSchema, } from './types.js';
|
|
14
|
+
import { currencyApprovalCall } from '../../contracts/approval.utils.js';
|
|
15
|
+
import { ERC20_ABI } from '../../contracts/erc20.abi.js';
|
|
16
|
+
import { SeaportSpenderReader } from '../../contracts/seaport-spender.reader.js';
|
|
17
|
+
import { SEAPORT_ADDRESS, SEAPORT_COUNTER_ABI, SEAPORT_DOMAIN_NAME, SEAPORT_DOMAIN_VERSION, SEAPORT_ORDER_COMPONENTS_TYPES, SEAPORT_ORDER_PRIMARY_TYPE, } from '../../contracts/seaport.constants.js';
|
|
18
|
+
import { SeaportItemType, SeaportOrderType, SeaportSpenderOutcome, } from '../../contracts/seaport.types.js';
|
|
19
|
+
import { errorMessage } from '../../utils/error.utils.js';
|
|
20
|
+
import { TxStatus } from '../../wallet/types.js';
|
|
21
|
+
const SIGNABLE_OFFER_ORDER_TYPES = new Set([
|
|
22
|
+
SeaportOrderType.FullOpen,
|
|
23
|
+
SeaportOrderType.FullRestricted,
|
|
24
|
+
]);
|
|
25
|
+
export class MarketOfferService {
|
|
26
|
+
client;
|
|
27
|
+
profile;
|
|
28
|
+
appConfig;
|
|
29
|
+
wallet;
|
|
30
|
+
network;
|
|
31
|
+
singleFlight;
|
|
32
|
+
recovery;
|
|
33
|
+
logger;
|
|
34
|
+
spenders;
|
|
35
|
+
lastProfileReadAt = null;
|
|
36
|
+
constructor(options) {
|
|
37
|
+
this.spenders = new SeaportSpenderReader({ wallet: options.wallet });
|
|
38
|
+
this.client = options.client;
|
|
39
|
+
this.profile = options.profile;
|
|
40
|
+
this.appConfig = options.appConfig;
|
|
41
|
+
this.wallet = options.wallet;
|
|
42
|
+
this.network = options.network;
|
|
43
|
+
this.singleFlight = options.singleFlight;
|
|
44
|
+
this.recovery = options.recovery;
|
|
45
|
+
this.logger = options.logger;
|
|
46
|
+
}
|
|
47
|
+
async makeCellOffer(request) {
|
|
48
|
+
const validated = this.requireUsableRequest(request);
|
|
49
|
+
const key = marketActionKey({
|
|
50
|
+
wallet: this.walletAddress(),
|
|
51
|
+
network: this.network,
|
|
52
|
+
tool: MarketActionTool.MakeCellOffer,
|
|
53
|
+
inputs: offerActionInputs(validated),
|
|
54
|
+
});
|
|
55
|
+
return this.singleFlight.run(key, async () => this.publish(key, validated));
|
|
56
|
+
}
|
|
57
|
+
async publish(key, request) {
|
|
58
|
+
const unresolved = this.recovery.read(key);
|
|
59
|
+
if (unresolved !== null && unresolved.payload.prepared !== null) {
|
|
60
|
+
return this.resume(key, request, unresolved);
|
|
61
|
+
}
|
|
62
|
+
this.reserve(key, MarketActionStage.Reconcile, this.emptyPayload());
|
|
63
|
+
let payload = this.emptyPayload();
|
|
64
|
+
try {
|
|
65
|
+
const active = await this.findEquivalentActiveOffer(request);
|
|
66
|
+
if (active !== null) {
|
|
67
|
+
this.recovery.forget(key);
|
|
68
|
+
return this.result(MarketActionStatus.AlreadyCompleted, MarketActionStage.Reconcile, request, payload, active);
|
|
69
|
+
}
|
|
70
|
+
const contracts = await this.requireMarketContracts();
|
|
71
|
+
await this.requireSufficientUsdgBalance(request, contracts.usdg);
|
|
72
|
+
const prepared = await this.prepare(request, contracts);
|
|
73
|
+
payload = { prepared, signature: null, approvalTxHashes: [] };
|
|
74
|
+
this.reserve(key, MarketActionStage.Prepare, payload);
|
|
75
|
+
payload = { ...payload, approvalTxHashes: await this.broadcastApprovals(prepared) };
|
|
76
|
+
this.reserve(key, MarketActionStage.Approve, payload);
|
|
77
|
+
payload = { ...payload, signature: await this.sign(prepared) };
|
|
78
|
+
this.reserve(key, MarketActionStage.Sign, payload);
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
this.recovery.forget(key);
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
84
|
+
return this.submit(key, request, payload, false);
|
|
85
|
+
}
|
|
86
|
+
async resume(key, request, record) {
|
|
87
|
+
const payload = record.payload;
|
|
88
|
+
const prepared = payload.prepared;
|
|
89
|
+
if (prepared === null) {
|
|
90
|
+
this.recovery.forget(key);
|
|
91
|
+
return this.publish(key, request);
|
|
92
|
+
}
|
|
93
|
+
if (this.nowSeconds() >= effectiveOfferDeadline(prepared)) {
|
|
94
|
+
return this.reconcileExpired(key, request, prepared);
|
|
95
|
+
}
|
|
96
|
+
const contracts = await this.requireMarketContracts();
|
|
97
|
+
this.requireConfiguredCurrency(request, prepared, contracts.usdg);
|
|
98
|
+
await this.requireSufficientUsdgBalance(request, contracts.usdg);
|
|
99
|
+
if (payload.signature === null) {
|
|
100
|
+
const resumed = { ...payload, approvalTxHashes: await this.broadcastApprovals(prepared) };
|
|
101
|
+
const signed = { ...resumed, signature: await this.sign(prepared) };
|
|
102
|
+
this.reserve(key, MarketActionStage.Sign, signed);
|
|
103
|
+
return this.submit(key, request, signed, false);
|
|
104
|
+
}
|
|
105
|
+
return this.submit(key, request, payload, record.stage === MarketActionStage.Submit);
|
|
106
|
+
}
|
|
107
|
+
async submit(key, request, payload, submittedBefore) {
|
|
108
|
+
const prepared = this.requirePrepared(payload);
|
|
109
|
+
const startedAt = Date.now();
|
|
110
|
+
let reachedServer = submittedBefore;
|
|
111
|
+
for (let attempt = 1; attempt <= OFFER_SUBMIT_MAX_ATTEMPTS; attempt += 1) {
|
|
112
|
+
this.requireWithinDeadline(prepared, MarketActionStage.Submit);
|
|
113
|
+
const priorSubmission = reachedServer;
|
|
114
|
+
const attemptAt = Date.now();
|
|
115
|
+
reachedServer = true;
|
|
116
|
+
try {
|
|
117
|
+
const response = await this.client.sendOnce({
|
|
118
|
+
path: MARKET_OFFER_SUBMIT_PATH,
|
|
119
|
+
method: 'POST',
|
|
120
|
+
body: { prepareId: prepared.prepareId, signature: payload.signature },
|
|
121
|
+
schema: submitOfferResponseSchemaFor(this.wallet.get().getChainId()),
|
|
122
|
+
stage: MarketActionStage.Submit,
|
|
123
|
+
label: `Publishing the offer for Cell ${request.tokenId}`,
|
|
124
|
+
});
|
|
125
|
+
this.recovery.forget(key);
|
|
126
|
+
return this.result(MarketActionStatus.Completed, MarketActionStage.Submit, request, payload, response.offer);
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
if (this.provenUnpublished(error, priorSubmission)) {
|
|
130
|
+
this.recovery.forget(key);
|
|
131
|
+
throw error;
|
|
132
|
+
}
|
|
133
|
+
this.reserve(key, MarketActionStage.Submit, payload);
|
|
134
|
+
this.logger.warn('the offer submit left an uncertain outcome — reconciling before any retry', {
|
|
135
|
+
tokenId: request.tokenId,
|
|
136
|
+
attempt,
|
|
137
|
+
});
|
|
138
|
+
const published = await this.reconcile(request, prepared, MarketActionStage.Submit);
|
|
139
|
+
if (published !== null) {
|
|
140
|
+
this.recovery.forget(key);
|
|
141
|
+
return this.result(MarketActionStatus.AlreadyCompleted, MarketActionStage.Submit, request, payload, published);
|
|
142
|
+
}
|
|
143
|
+
if (error instanceof MarketError && !error.retryable) {
|
|
144
|
+
throw this.outcomeUnknown(request, MarketActionStage.Submit, null);
|
|
145
|
+
}
|
|
146
|
+
if (attempt < OFFER_SUBMIT_MAX_ATTEMPTS) {
|
|
147
|
+
await this.holdOffResubmission(error, request, attemptAt, startedAt);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
throw this.outcomeUnknown(request, MarketActionStage.Submit, null);
|
|
152
|
+
}
|
|
153
|
+
provenUnpublished(error, priorSubmission) {
|
|
154
|
+
return (!priorSubmission &&
|
|
155
|
+
error instanceof MarketError &&
|
|
156
|
+
!error.retryable &&
|
|
157
|
+
PROVEN_UNPUBLISHED_MARKET_ERROR_CODES.has(error.code));
|
|
158
|
+
}
|
|
159
|
+
async holdOffResubmission(error, request, attemptAt, startedAt) {
|
|
160
|
+
const seconds = error instanceof MarketError ? error.retryAfterSeconds : null;
|
|
161
|
+
if (seconds === null) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const owed = seconds * MS_PER_SECOND - (Date.now() - attemptAt);
|
|
165
|
+
if (owed <= 0) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
this.logger.info('waiting out the delay the marketplace asked for before repeating the submission', { owed });
|
|
169
|
+
const waited = await waitWithinInvocationBudget(owed, MARKET_RETRY_BUDGET_MS - (Date.now() - startedAt));
|
|
170
|
+
if (!waited) {
|
|
171
|
+
throw this.outcomeUnknown(request, MarketActionStage.Submit, seconds);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
async reconcileExpired(key, request, prepared) {
|
|
175
|
+
const published = await this.reconcile(request, prepared, MarketActionStage.Reconcile);
|
|
176
|
+
if (published !== null) {
|
|
177
|
+
this.recovery.forget(key);
|
|
178
|
+
return this.result(MarketActionStatus.AlreadyCompleted, MarketActionStage.Reconcile, request, { prepared, signature: null, approvalTxHashes: [] }, published);
|
|
179
|
+
}
|
|
180
|
+
this.recovery.forget(key);
|
|
181
|
+
throw new MarketError({
|
|
182
|
+
code: MarketErrorCode.PreparedIntentExpired,
|
|
183
|
+
message: `The prepared offer for Cell ${request.tokenId} ran out of time before it could be published, and ` +
|
|
184
|
+
'no matching offer is active. Call the tool again to prepare a fresh offer.',
|
|
185
|
+
retryable: false,
|
|
186
|
+
retryAfterSeconds: null,
|
|
187
|
+
stage: MarketActionStage.Reconcile,
|
|
188
|
+
txHash: null,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
async reconcile(request, prepared, stage) {
|
|
192
|
+
await this.waitForProfileCacheHorizon();
|
|
193
|
+
let scan;
|
|
194
|
+
try {
|
|
195
|
+
scan = await this.scanActiveOffers(request, prepared.offer.currency.address);
|
|
196
|
+
}
|
|
197
|
+
catch (error) {
|
|
198
|
+
this.logger.error('cannot reconcile an uncertain offer against the marketplace', {
|
|
199
|
+
tokenId: request.tokenId,
|
|
200
|
+
error,
|
|
201
|
+
});
|
|
202
|
+
throw this.outcomeUnknown(request, stage, null);
|
|
203
|
+
}
|
|
204
|
+
if (scan.outcome === MarketScanOutcome.Exhausted) {
|
|
205
|
+
this.logger.error('the active offers run past the pages this tool may read, so nothing is settled', {
|
|
206
|
+
tokenId: request.tokenId,
|
|
207
|
+
pages: MARKET_RECONCILE_MAX_PAGES,
|
|
208
|
+
});
|
|
209
|
+
throw this.outcomeUnknown(request, stage, null);
|
|
210
|
+
}
|
|
211
|
+
return scan.offer;
|
|
212
|
+
}
|
|
213
|
+
async findEquivalentActiveOffer(request) {
|
|
214
|
+
const scan = await this.scanActiveOffers(request, null);
|
|
215
|
+
if (scan.outcome === MarketScanOutcome.Exhausted) {
|
|
216
|
+
throw new MarketError({
|
|
217
|
+
code: MarketErrorCode.OutcomeUnknown,
|
|
218
|
+
message: `Your active offers run past the ${MARKET_RECONCILE_MAX_PAGES} pages this tool reads, so it ` +
|
|
219
|
+
`cannot rule out that you already offer this much for Cell ${request.tokenId}, and it will not ` +
|
|
220
|
+
'prepare another offer blindly. Cancel offers you no longer need, then call the tool again.',
|
|
221
|
+
retryable: true,
|
|
222
|
+
retryAfterSeconds: null,
|
|
223
|
+
stage: MarketActionStage.Reconcile,
|
|
224
|
+
txHash: null,
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
return scan.offer;
|
|
228
|
+
}
|
|
229
|
+
async scanActiveOffers(request, currency) {
|
|
230
|
+
const wallet = this.walletAddress();
|
|
231
|
+
let cursor = null;
|
|
232
|
+
for (let page = 0; page < MARKET_RECONCILE_MAX_PAGES; page += 1) {
|
|
233
|
+
const offers = await this.profile.getMyOffers(cursor);
|
|
234
|
+
this.lastProfileReadAt = Date.now();
|
|
235
|
+
const candidates = offers.items.filter((offer) => offer.kind === MarketOfferKind.Item &&
|
|
236
|
+
offer.tokenId === request.tokenId &&
|
|
237
|
+
offer.amount === request.amount);
|
|
238
|
+
for (const candidate of candidates) {
|
|
239
|
+
try {
|
|
240
|
+
const details = await this.profile.getOrderDetails(candidate.orderHash);
|
|
241
|
+
if (details.orderKind === 'offer' &&
|
|
242
|
+
isEquivalentActiveOffer(details.order, request, wallet, currency)) {
|
|
243
|
+
return { outcome: MarketScanOutcome.Found, offer: details.order };
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
catch (error) {
|
|
247
|
+
if (error instanceof MarketError &&
|
|
248
|
+
(error.code === MarketErrorCode.StaleListing || error.code === MarketErrorCode.StaleOffer)) {
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
throw error;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
cursor = offers.nextCursor;
|
|
255
|
+
if (cursor === null) {
|
|
256
|
+
return { outcome: MarketScanOutcome.Absent, offer: null };
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return { outcome: MarketScanOutcome.Exhausted, offer: null };
|
|
260
|
+
}
|
|
261
|
+
async waitForProfileCacheHorizon() {
|
|
262
|
+
if (this.lastProfileReadAt === null) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
const remaining = MARKET_PROFILE_CACHE_MS - (Date.now() - this.lastProfileReadAt);
|
|
266
|
+
if (remaining > 0) {
|
|
267
|
+
this.logger.info('waiting for the marketplace read snapshot to advance before reconciling', { remaining });
|
|
268
|
+
await waitOnInvocationBudget(remaining);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
async prepare(request, contracts) {
|
|
272
|
+
const counter = await this.currentCounter();
|
|
273
|
+
const prepared = await this.client.send({
|
|
274
|
+
path: MARKET_OFFER_PREPARE_PATH,
|
|
275
|
+
method: 'POST',
|
|
276
|
+
body: {
|
|
277
|
+
tokenId: request.tokenId,
|
|
278
|
+
amount: request.amount,
|
|
279
|
+
expirationTime: request.expirationTime,
|
|
280
|
+
counter,
|
|
281
|
+
},
|
|
282
|
+
schema: prepareOfferResponseSchemaFor(request, counter),
|
|
283
|
+
stage: MarketActionStage.Prepare,
|
|
284
|
+
label: `Preparing the offer for Cell ${request.tokenId}`,
|
|
285
|
+
});
|
|
286
|
+
await this.requireTrustworthyPreparation(request, prepared, counter, contracts);
|
|
287
|
+
return prepared;
|
|
288
|
+
}
|
|
289
|
+
async currentCounter() {
|
|
290
|
+
let counter;
|
|
291
|
+
try {
|
|
292
|
+
counter = await this.wallet.get().readContract({
|
|
293
|
+
address: SEAPORT_ADDRESS,
|
|
294
|
+
abi: SEAPORT_COUNTER_ABI,
|
|
295
|
+
functionName: 'getCounter',
|
|
296
|
+
args: [this.walletAddress()],
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
catch (error) {
|
|
300
|
+
throw new MarketError({
|
|
301
|
+
code: MarketErrorCode.NetworkFailure,
|
|
302
|
+
message: `The protocol contract ${SEAPORT_ADDRESS} did not answer this wallet's order counter, so an ` +
|
|
303
|
+
`offer cannot be prepared yet: ${errorMessage(error)}.`,
|
|
304
|
+
retryable: true,
|
|
305
|
+
retryAfterSeconds: null,
|
|
306
|
+
stage: MarketActionStage.Prepare,
|
|
307
|
+
txHash: null,
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
if (typeof counter !== 'bigint') {
|
|
311
|
+
throw new MarketError({
|
|
312
|
+
code: MarketErrorCode.InvalidMarketResponse,
|
|
313
|
+
message: `The protocol contract ${SEAPORT_ADDRESS} answered this wallet's order counter with something ` +
|
|
314
|
+
'that is not a whole number, so no offer may be signed against it.',
|
|
315
|
+
retryable: false,
|
|
316
|
+
retryAfterSeconds: null,
|
|
317
|
+
stage: MarketActionStage.Prepare,
|
|
318
|
+
txHash: null,
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
return counter.toString();
|
|
322
|
+
}
|
|
323
|
+
async requireMarketContracts() {
|
|
324
|
+
const config = await this.appConfig.load();
|
|
325
|
+
const collection = config.contracts.land;
|
|
326
|
+
const usdg = config.contracts.usdg;
|
|
327
|
+
if (!evmAddressSchema.safeParse(collection).success) {
|
|
328
|
+
throw new MarketError({
|
|
329
|
+
code: MarketErrorCode.InvalidMarketResponse,
|
|
330
|
+
message: 'The Cell collection contract is not configured for this network, so the order an offer asks ' +
|
|
331
|
+
'the wallet to sign cannot be checked against the collection it must ask for.',
|
|
332
|
+
retryable: false,
|
|
333
|
+
retryAfterSeconds: null,
|
|
334
|
+
stage: MarketActionStage.Prepare,
|
|
335
|
+
txHash: null,
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
if (!evmAddressSchema.safeParse(usdg).success) {
|
|
339
|
+
throw new MarketError({
|
|
340
|
+
code: MarketErrorCode.InvalidMarketResponse,
|
|
341
|
+
message: 'USDG is not configured for this network, so this wallet cannot verify the currency or fund ' +
|
|
342
|
+
'an offer safely.',
|
|
343
|
+
retryable: false,
|
|
344
|
+
retryAfterSeconds: null,
|
|
345
|
+
stage: MarketActionStage.Prepare,
|
|
346
|
+
txHash: null,
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
return { collection, usdg };
|
|
350
|
+
}
|
|
351
|
+
async requireTrustworthyPreparation(request, prepared, counter, contracts) {
|
|
352
|
+
const wallet = this.walletAddress();
|
|
353
|
+
const chainId = this.wallet.get().getChainId();
|
|
354
|
+
if (prepared.chainId !== chainId) {
|
|
355
|
+
throw this.untrustworthy(MarketErrorCode.ChainMismatch, `it targets chain ${prepared.chainId} while this wallet signs for chain ${chainId}`, request);
|
|
356
|
+
}
|
|
357
|
+
if (!sameAddress(prepared.protocolAddress, SEAPORT_ADDRESS)) {
|
|
358
|
+
throw this.untrustworthy(MarketErrorCode.ProtocolAddressMismatch, `it names protocol contract ${prepared.protocolAddress} instead of the pinned ${SEAPORT_ADDRESS}`, request);
|
|
359
|
+
}
|
|
360
|
+
if (!sameAddress(prepared.offer.maker, wallet) || !sameAddress(prepared.order.offerer, wallet)) {
|
|
361
|
+
throw this.untrustworthy(MarketErrorCode.WrongOwner, `it bids on behalf of ${prepared.offer.maker} rather than this wallet ${wallet}`, request);
|
|
362
|
+
}
|
|
363
|
+
this.requireRequestedTerms(request, prepared, counter);
|
|
364
|
+
this.requireSpendableCurrency(request, prepared);
|
|
365
|
+
this.requireConfiguredCurrency(request, prepared, contracts.usdg);
|
|
366
|
+
await this.requireCurrencyApprovalsOnly(request, prepared);
|
|
367
|
+
this.requireOfferedAmount(request, prepared);
|
|
368
|
+
this.requireRequestedCell(request, prepared, contracts.collection);
|
|
369
|
+
this.requireOrderShape(request, prepared);
|
|
370
|
+
}
|
|
371
|
+
requireRequestedTerms(request, prepared, counter) {
|
|
372
|
+
const offer = prepared.offer;
|
|
373
|
+
if (offer.kind !== MarketOfferKind.Item) {
|
|
374
|
+
throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `it is a "${offer.kind}" offer, while this tool only ever makes an item offer for one exact Cell`, request);
|
|
375
|
+
}
|
|
376
|
+
if (offer.tokenId !== request.tokenId) {
|
|
377
|
+
throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `it bids on Cell ${offer.tokenId} instead of Cell ${request.tokenId}`, request);
|
|
378
|
+
}
|
|
379
|
+
if (offer.amount !== request.amount) {
|
|
380
|
+
throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `it bids ${offer.amount} instead of the requested ${request.amount}`, request);
|
|
381
|
+
}
|
|
382
|
+
if (offer.expirationTime !== request.expirationTime) {
|
|
383
|
+
throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `it expires at ${offer.expirationTime} instead of the requested ${request.expirationTime}`, request);
|
|
384
|
+
}
|
|
385
|
+
if (offer.counter !== counter) {
|
|
386
|
+
throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `it carries order counter ${offer.counter} while this wallet's current counter is ${counter}`, request);
|
|
387
|
+
}
|
|
388
|
+
if (offer.startTime > this.nowSeconds() + OFFER_START_TIME_SKEW_SECONDS) {
|
|
389
|
+
throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `it cannot be accepted until ${offer.startTime}, so it would not be the offer you asked for now`, request);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
requireSpendableCurrency(request, prepared) {
|
|
393
|
+
if (sameAddress(prepared.offer.currency.address, zeroAddress)) {
|
|
394
|
+
throw new MarketError({
|
|
395
|
+
code: MarketErrorCode.CurrencyUnsupported,
|
|
396
|
+
message: `The prepared offer for Cell ${request.tokenId} is priced in the chain's own currency, which ` +
|
|
397
|
+
'cannot be escrowed by an off-chain offer. An offer must be made in a token the marketplace ' +
|
|
398
|
+
'can pull when a seller accepts it.',
|
|
399
|
+
retryable: false,
|
|
400
|
+
retryAfterSeconds: null,
|
|
401
|
+
stage: MarketActionStage.Prepare,
|
|
402
|
+
txHash: null,
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
requireConfiguredCurrency(request, prepared, usdg) {
|
|
407
|
+
if (!sameAddress(prepared.offer.currency.address, usdg)) {
|
|
408
|
+
throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `it is priced in ${prepared.offer.currency.address} instead of the configured USDG ${usdg}`, request);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
async requireSufficientUsdgBalance(request, usdg) {
|
|
412
|
+
const wallet = this.wallet.get();
|
|
413
|
+
let balance;
|
|
414
|
+
try {
|
|
415
|
+
balance = await wallet.readContract({
|
|
416
|
+
address: usdg,
|
|
417
|
+
abi: ERC20_ABI,
|
|
418
|
+
functionName: 'balanceOf',
|
|
419
|
+
args: [wallet.getAddress()],
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
catch (error) {
|
|
423
|
+
throw new MarketError({
|
|
424
|
+
code: MarketErrorCode.NetworkFailure,
|
|
425
|
+
message: `The USDG contract ${usdg} did not answer this wallet's balance, so the offer was not ` +
|
|
426
|
+
`prepared: ${errorMessage(error)}.`,
|
|
427
|
+
retryable: true,
|
|
428
|
+
retryAfterSeconds: null,
|
|
429
|
+
stage: MarketActionStage.Prepare,
|
|
430
|
+
txHash: null,
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
if (typeof balance !== 'bigint') {
|
|
434
|
+
throw new MarketError({
|
|
435
|
+
code: MarketErrorCode.InvalidMarketResponse,
|
|
436
|
+
message: `The USDG contract ${usdg} returned a non-integer balance, so the offer was not prepared.`,
|
|
437
|
+
retryable: false,
|
|
438
|
+
retryAfterSeconds: null,
|
|
439
|
+
stage: MarketActionStage.Prepare,
|
|
440
|
+
txHash: null,
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
const required = BigInt(request.amount);
|
|
444
|
+
if (balance < required) {
|
|
445
|
+
throw new MarketError({
|
|
446
|
+
code: MarketErrorCode.InsufficientBalance,
|
|
447
|
+
message: `The wallet has ${balance.toString()} USDG base units but needs ${request.amount} to make ` +
|
|
448
|
+
`the offer for Cell ${request.tokenId}. Nothing was approved, signed or published.`,
|
|
449
|
+
retryable: false,
|
|
450
|
+
retryAfterSeconds: null,
|
|
451
|
+
stage: MarketActionStage.Prepare,
|
|
452
|
+
txHash: null,
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
async requireCurrencyApprovalsOnly(request, prepared) {
|
|
457
|
+
const chainId = this.wallet.get().getChainId();
|
|
458
|
+
const currency = prepared.offer.currency.address;
|
|
459
|
+
const approvals = [];
|
|
460
|
+
for (const transaction of prepared.transactions) {
|
|
461
|
+
if (transaction.kind !== MarketTransactionKind.CurrencyApproval || transaction.chainId !== chainId) {
|
|
462
|
+
throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `publishing an offer may only need currency approvals, but it asks to send a ` +
|
|
463
|
+
`"${transaction.kind}" transaction on chain ${transaction.chainId}`, request);
|
|
464
|
+
}
|
|
465
|
+
if (!sameAddress(transaction.to, currency)) {
|
|
466
|
+
throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `it asks the wallet to approve ${transaction.to} instead of the offer currency ${currency}`, request);
|
|
467
|
+
}
|
|
468
|
+
if (transaction.value !== OFFER_NO_VALUE) {
|
|
469
|
+
throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `its currency approval would also send ${transaction.value} of the chain currency away`, request);
|
|
470
|
+
}
|
|
471
|
+
approvals.push(this.requireExactApprovalAmount(request, transaction));
|
|
472
|
+
}
|
|
473
|
+
await this.requireOrderSpender(request, prepared, approvals);
|
|
474
|
+
}
|
|
475
|
+
requireExactApprovalAmount(request, transaction) {
|
|
476
|
+
const approval = currencyApprovalCall(transaction.data);
|
|
477
|
+
if (approval === null) {
|
|
478
|
+
throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, 'it asks the wallet to send calldata the offer currency would not read as an approval of a single ' +
|
|
479
|
+
'exact amount', request);
|
|
480
|
+
}
|
|
481
|
+
if (approval.amount !== BigInt(request.amount)) {
|
|
482
|
+
throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `it asks the wallet to approve ${approval.amount.toString()} of the offer currency rather than ` +
|
|
483
|
+
`exactly the ${request.amount} this offer bids`, request);
|
|
484
|
+
}
|
|
485
|
+
return approval;
|
|
486
|
+
}
|
|
487
|
+
async requireOrderSpender(request, prepared, approvals) {
|
|
488
|
+
if (approvals.length === 0) {
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
const conduitKey = prepared.order.conduitKey;
|
|
492
|
+
const answer = await this.spenders.spenderForConduitKey(conduitKey);
|
|
493
|
+
const detail = answer.detail ?? `conduit key ${conduitKey} resolves to nothing`;
|
|
494
|
+
if (answer.outcome === SeaportSpenderOutcome.Unreachable) {
|
|
495
|
+
throw new MarketError({
|
|
496
|
+
code: MarketErrorCode.NetworkFailure,
|
|
497
|
+
message: `The offer for Cell ${request.tokenId} was not signed because ${detail}. Nothing was approved ` +
|
|
498
|
+
'and nothing was published.',
|
|
499
|
+
retryable: true,
|
|
500
|
+
retryAfterSeconds: null,
|
|
501
|
+
stage: MarketActionStage.Prepare,
|
|
502
|
+
txHash: null,
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
if (answer.address === null) {
|
|
506
|
+
throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `the order it asks the wallet to sign settles through a spender this client cannot justify: ` +
|
|
507
|
+
`${detail}`, request);
|
|
508
|
+
}
|
|
509
|
+
const spender = answer.address;
|
|
510
|
+
const foreign = approvals.find((approval) => !sameAddress(approval.spender, spender));
|
|
511
|
+
if (foreign !== undefined) {
|
|
512
|
+
throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `it asks the wallet to let ${foreign.spender} spend the offer currency, while the order it signs ` +
|
|
513
|
+
`is settled by ${spender}`, request);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
requireOfferedAmount(request, prepared) {
|
|
517
|
+
const order = prepared.order;
|
|
518
|
+
const currency = prepared.offer.currency.address;
|
|
519
|
+
const paid = order.offer.length === 1 ? (order.offer[0] ?? null) : null;
|
|
520
|
+
if (paid === null) {
|
|
521
|
+
throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `the order it asks the wallet to sign puts up ${order.offer.length} items rather than one amount of ` +
|
|
522
|
+
'the offer currency', request);
|
|
523
|
+
}
|
|
524
|
+
if (paid.itemType !== SeaportItemType.Erc20 || !sameAddress(paid.token, currency)) {
|
|
525
|
+
throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `the order it asks the wallet to sign puts up item type ${paid.itemType} of token ${paid.token} ` +
|
|
526
|
+
`instead of the offer currency ${currency}`, request);
|
|
527
|
+
}
|
|
528
|
+
if (paid.identifierOrCriteria !== OFFER_NO_IDENTIFIER) {
|
|
529
|
+
throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `the order it asks the wallet to sign puts up token ${paid.identifierOrCriteria} rather than a ` +
|
|
530
|
+
'plain amount', request);
|
|
531
|
+
}
|
|
532
|
+
if (paid.startAmount !== request.amount || paid.endAmount !== request.amount) {
|
|
533
|
+
throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `the order it asks the wallet to sign puts up ${paid.startAmount} rising to ${paid.endAmount} ` +
|
|
534
|
+
`instead of exactly the ${request.amount} you offered`, request);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
requireRequestedCell(request, prepared, collection) {
|
|
538
|
+
const order = prepared.order;
|
|
539
|
+
const wallet = this.walletAddress();
|
|
540
|
+
const wanted = order.consideration.filter((item) => item.itemType !== SeaportItemType.Erc20);
|
|
541
|
+
if (wanted.length !== 1) {
|
|
542
|
+
throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `the order it asks the wallet to sign asks for ${wanted.length} non-currency items rather than the ` +
|
|
543
|
+
`one Cell ${request.tokenId}`, request);
|
|
544
|
+
}
|
|
545
|
+
const cell = wanted[0];
|
|
546
|
+
if (cell === undefined || cell.itemType !== SeaportItemType.Erc721) {
|
|
547
|
+
throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `the order it asks the wallet to sign asks for item type ${cell?.itemType} rather than one exact ` +
|
|
548
|
+
'ERC-721 Cell, so it would not be an item offer', request);
|
|
549
|
+
}
|
|
550
|
+
if (!sameAddress(cell.token, collection)) {
|
|
551
|
+
throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `the order it asks the wallet to sign asks for a token of collection ${cell.token} instead of the ` +
|
|
552
|
+
`Cell collection ${collection}`, request);
|
|
553
|
+
}
|
|
554
|
+
if (cell.identifierOrCriteria !== request.tokenId) {
|
|
555
|
+
throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `the order it asks the wallet to sign asks for Cell ${cell.identifierOrCriteria} instead of Cell ` +
|
|
556
|
+
`${request.tokenId}`, request);
|
|
557
|
+
}
|
|
558
|
+
if (cell.startAmount !== OFFER_SINGLE_UNIT || cell.endAmount !== OFFER_SINGLE_UNIT) {
|
|
559
|
+
throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `the order it asks the wallet to sign asks for ${cell.startAmount} units of the Cell rather than one`, request);
|
|
560
|
+
}
|
|
561
|
+
if (!sameAddress(cell.recipient, wallet)) {
|
|
562
|
+
throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `the order it asks the wallet to sign sends the Cell to ${cell.recipient} rather than to this ` +
|
|
563
|
+
`wallet ${wallet}`, request);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
requireOrderShape(request, prepared) {
|
|
567
|
+
const order = prepared.order;
|
|
568
|
+
const currency = prepared.offer.currency.address;
|
|
569
|
+
if (!SIGNABLE_OFFER_ORDER_TYPES.has(order.orderType)) {
|
|
570
|
+
throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `the order it asks the wallet to sign is of type ${order.orderType}, which could be filled in parts ` +
|
|
571
|
+
'or by a contract rather than as the whole offer you made', request);
|
|
572
|
+
}
|
|
573
|
+
if (order.totalOriginalConsiderationItems !== order.consideration.length) {
|
|
574
|
+
throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `the order it asks the wallet to sign declares ${order.totalOriginalConsiderationItems} original ` +
|
|
575
|
+
`items while carrying ${order.consideration.length}`, request);
|
|
576
|
+
}
|
|
577
|
+
if (order.counter !== prepared.offer.counter) {
|
|
578
|
+
throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `the order it asks the wallet to sign carries counter ${order.counter} while the prepared offer ` +
|
|
579
|
+
`carries ${prepared.offer.counter}`, request);
|
|
580
|
+
}
|
|
581
|
+
if (order.startTime !== prepared.offer.startTime.toString()) {
|
|
582
|
+
throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `the order it asks the wallet to sign becomes acceptable at ${order.startTime} instead of the ` +
|
|
583
|
+
`prepared ${prepared.offer.startTime}`, request);
|
|
584
|
+
}
|
|
585
|
+
if (order.endTime !== request.expirationTime.toString()) {
|
|
586
|
+
throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `the order it asks the wallet to sign ends at ${order.endTime} instead of ${request.expirationTime}`, request);
|
|
587
|
+
}
|
|
588
|
+
for (const item of order.consideration) {
|
|
589
|
+
if (item.itemType === SeaportItemType.Erc20 && !sameAddress(item.token, currency)) {
|
|
590
|
+
throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `the order it asks the wallet to sign pays part of the offer in ${item.token} instead of the ` +
|
|
591
|
+
`offer currency ${currency}`, request);
|
|
592
|
+
}
|
|
593
|
+
if (item.itemType === SeaportItemType.Erc20 && item.startAmount !== item.endAmount) {
|
|
594
|
+
throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `the order it asks the wallet to sign starts a payment at ${item.startAmount} and ends it at ` +
|
|
595
|
+
`${item.endAmount}, so it could cost more than the amount you offered`, request);
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
const charged = orderCurrencyConsiderationTotal(order, currency);
|
|
599
|
+
if (BigInt(charged) > BigInt(request.amount)) {
|
|
600
|
+
throw this.untrustworthy(MarketErrorCode.InvalidMarketResponse, `the order it asks the wallet to sign pays out ${charged} of the currency while you only offered ` +
|
|
601
|
+
`${request.amount}`, request);
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
async broadcastApprovals(prepared) {
|
|
605
|
+
const hashes = [];
|
|
606
|
+
for (const transaction of prepared.transactions) {
|
|
607
|
+
hashes.push(await this.broadcast(transaction));
|
|
608
|
+
}
|
|
609
|
+
return hashes;
|
|
610
|
+
}
|
|
611
|
+
async broadcast(transaction) {
|
|
612
|
+
const wallet = this.wallet.get();
|
|
613
|
+
const hash = await wallet.sendTransaction({
|
|
614
|
+
to: transaction.to,
|
|
615
|
+
data: transaction.data,
|
|
616
|
+
value: BigInt(transaction.value),
|
|
617
|
+
gas: null,
|
|
618
|
+
});
|
|
619
|
+
const receipt = await wallet.waitForReceipt(hash);
|
|
620
|
+
if (receipt.status !== TxStatus.Success) {
|
|
621
|
+
throw new MarketError({
|
|
622
|
+
code: MarketErrorCode.TransactionReverted,
|
|
623
|
+
message: 'The currency approval this offer needs reverted on-chain, so the offer was never signed or ' +
|
|
624
|
+
'published.',
|
|
625
|
+
retryable: false,
|
|
626
|
+
retryAfterSeconds: null,
|
|
627
|
+
stage: MarketActionStage.Approve,
|
|
628
|
+
txHash: hash,
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
return hash;
|
|
632
|
+
}
|
|
633
|
+
async sign(prepared) {
|
|
634
|
+
this.requireWithinDeadline(prepared, MarketActionStage.Sign);
|
|
635
|
+
return this.wallet.get().signTypedData({
|
|
636
|
+
domain: {
|
|
637
|
+
name: SEAPORT_DOMAIN_NAME,
|
|
638
|
+
version: SEAPORT_DOMAIN_VERSION,
|
|
639
|
+
chainId: prepared.chainId,
|
|
640
|
+
verifyingContract: prepared.protocolAddress,
|
|
641
|
+
},
|
|
642
|
+
types: SEAPORT_ORDER_COMPONENTS_TYPES,
|
|
643
|
+
primaryType: SEAPORT_ORDER_PRIMARY_TYPE,
|
|
644
|
+
message: seaportSignableOrder(prepared.order),
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
requireWithinDeadline(prepared, stage) {
|
|
648
|
+
const deadline = effectiveOfferDeadline(prepared);
|
|
649
|
+
narrowInvocationDeadline(deadline);
|
|
650
|
+
if (this.nowSeconds() < deadline) {
|
|
651
|
+
return;
|
|
652
|
+
}
|
|
653
|
+
throw new MarketError({
|
|
654
|
+
code: MarketErrorCode.PreparedIntentExpired,
|
|
655
|
+
message: 'This prepared offer is past the earlier of its own deadline and the offer expiry, so it can no ' +
|
|
656
|
+
'longer be signed or published. Call the tool again to prepare a fresh offer.',
|
|
657
|
+
retryable: false,
|
|
658
|
+
retryAfterSeconds: null,
|
|
659
|
+
stage,
|
|
660
|
+
txHash: null,
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
requirePrepared(payload) {
|
|
664
|
+
if (payload.prepared === null) {
|
|
665
|
+
throw new MarketError({
|
|
666
|
+
code: MarketErrorCode.InvalidMarketResponse,
|
|
667
|
+
message: 'The offer has no prepared order to publish.',
|
|
668
|
+
retryable: false,
|
|
669
|
+
retryAfterSeconds: null,
|
|
670
|
+
stage: MarketActionStage.Submit,
|
|
671
|
+
txHash: null,
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
return payload.prepared;
|
|
675
|
+
}
|
|
676
|
+
requireUsableRequest(request) {
|
|
677
|
+
const tokenId = cellTokenIdSchema.safeParse(request.tokenId);
|
|
678
|
+
if (!tokenId.success) {
|
|
679
|
+
throw this.rejectedInput(`"${request.tokenId}" is not a canonical Cell token id. Pass a decimal integer with no leading ` +
|
|
680
|
+
'zeroes so that one Cell keeps one identity.');
|
|
681
|
+
}
|
|
682
|
+
const amount = usdgOfferAmountSchema.safeParse(request.amount);
|
|
683
|
+
if (!amount.success) {
|
|
684
|
+
throw this.rejectedInput(`"${request.amount}" is not a valid USDG offer amount. Pass a positive decimal integer in whole ` +
|
|
685
|
+
'cent increments: 10000 base units is $0.01.');
|
|
686
|
+
}
|
|
687
|
+
const expirationTime = unixSecondsSchema.safeParse(request.expirationTime);
|
|
688
|
+
if (!expirationTime.success || expirationTime.data <= this.nowSeconds()) {
|
|
689
|
+
throw this.rejectedInput(`${request.expirationTime} is not a future expiry. Pass the Unix second at which the offer should ` +
|
|
690
|
+
'stop being acceptable.');
|
|
691
|
+
}
|
|
692
|
+
return { tokenId: tokenId.data, amount: amount.data, expirationTime: expirationTime.data };
|
|
693
|
+
}
|
|
694
|
+
reserve(key, stage, payload) {
|
|
695
|
+
this.recovery.write(key, { tool: MarketActionTool.MakeCellOffer, stage, payload });
|
|
696
|
+
}
|
|
697
|
+
emptyPayload() {
|
|
698
|
+
return { prepared: null, signature: null, approvalTxHashes: [] };
|
|
699
|
+
}
|
|
700
|
+
result(status, stage, request, payload, offer) {
|
|
701
|
+
this.logger.info('the Cell offer is published', {
|
|
702
|
+
tokenId: request.tokenId,
|
|
703
|
+
status,
|
|
704
|
+
orderHash: offer.orderHash,
|
|
705
|
+
});
|
|
706
|
+
return {
|
|
707
|
+
status,
|
|
708
|
+
stage,
|
|
709
|
+
wallet: this.walletAddress(),
|
|
710
|
+
tokenId: request.tokenId,
|
|
711
|
+
offer,
|
|
712
|
+
amount: offer.amount,
|
|
713
|
+
currency: offer.currency,
|
|
714
|
+
approvalTxHashes: [...payload.approvalTxHashes],
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
outcomeUnknown(request, stage, retryAfterSeconds) {
|
|
718
|
+
return new MarketError({
|
|
719
|
+
code: MarketErrorCode.OutcomeUnknown,
|
|
720
|
+
message: `The offer for Cell ${request.tokenId} was submitted but its outcome could not be confirmed, and ` +
|
|
721
|
+
'the marketplace cannot be read to settle the question. The exact prepared order is kept, so ' +
|
|
722
|
+
'repeating this call republishes the same order rather than creating a second one.',
|
|
723
|
+
retryable: true,
|
|
724
|
+
retryAfterSeconds,
|
|
725
|
+
stage,
|
|
726
|
+
txHash: null,
|
|
727
|
+
});
|
|
728
|
+
}
|
|
729
|
+
untrustworthy(code, detail, request) {
|
|
730
|
+
this.logger.error('the prepared offer does not match the request', { tokenId: request.tokenId, detail });
|
|
731
|
+
return new MarketError({
|
|
732
|
+
code,
|
|
733
|
+
message: `The prepared offer for Cell ${request.tokenId} cannot be signed: ${detail}.`,
|
|
734
|
+
retryable: false,
|
|
735
|
+
retryAfterSeconds: null,
|
|
736
|
+
stage: MarketActionStage.Prepare,
|
|
737
|
+
txHash: null,
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
rejectedInput(message) {
|
|
741
|
+
return new MarketError({
|
|
742
|
+
code: MarketErrorCode.InvalidInput,
|
|
743
|
+
message,
|
|
744
|
+
retryable: false,
|
|
745
|
+
retryAfterSeconds: null,
|
|
746
|
+
stage: MarketActionStage.Prepare,
|
|
747
|
+
txHash: null,
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
walletAddress() {
|
|
751
|
+
return this.wallet.get().getAddress();
|
|
752
|
+
}
|
|
753
|
+
nowSeconds() {
|
|
754
|
+
return Math.floor(Date.now() / MS_PER_SECOND);
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
//# sourceMappingURL=offer.service.js.map
|