{"version":3,"file":"generated.mjs","names":[],"sources":["../../../src/predict/config/generated.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport type { AccountConfig } from '../../account.js';\nimport type { DeepbookPredictConfig } from '../../contracts/deepbook_predict/config-arguments.js';\nimport type { DeepbookPredictMathConfig } from '../../contracts/deepbook_predict_math/config-arguments.js';\nimport type { DeepbookPredictOrdersConfig } from '../../contracts/deepbook_predict_orders/config-arguments.js';\nimport { PredictInputError } from '../errors.js';\nimport type { PredictConfig } from './types.js';\n\n/**\n * The flat config slice the generated bindings resolve `options.config` against, projected from\n * the nested public `PredictConfig`. Each generated call declares only the keys it consumes, so a\n * single object carrying all of them satisfies every call site.\n *\n * Typed as the intersection of the two generated interfaces on purpose: if codegen adds, drops, or\n * renames a config key, this file stops compiling instead of silently building a PTB against the\n * wrong object.\n *\n * `predictPackageId` is narrowed to `string` because codegen types package ids as optional, while\n * this projection always supplies one. `predictPackageIdV1` separately supplies the original\n * identity for existing struct tags and dynamic-field keys. The two account ids restate a narrowing\n * `AccountConfig` already applies, so they are redundant today; they are kept so this projection\n * still compiles to plain ids if that package ever widens them back.\n */\nexport type GeneratedConfig = DeepbookPredictConfig &\n\tAccountConfig & {\n\t\tpredictPackageId: string;\n\t\tpredictPackageIdV1: string;\n\t\t/** The ORIGINAL account ID: type tags and derived addresses are built from it. */\n\t\taccountPackageId: string;\n\t\taccountRegistry: string;\n\t};\n\nexport function toGeneratedConfig(cfg: PredictConfig): GeneratedConfig {\n\treturn {\n\t\tpredictPackageId: cfg.packages.predict,\n\t\tpredictPackageIdV1: cfg.packages.predictV1 ?? cfg.packages.predict,\n\t\taccountPackageId: cfg.packages.account,\n\t\t// The account bindings call this when present (see `account-bindings/latest.ts`).\n\t\taccountPackageIdLatest: cfg.packages.accountLatest,\n\t\tprotocolConfig: cfg.objects.protocolConfig,\n\t\tpoolVault: cfg.objects.poolVault,\n\t\tregistry: cfg.objects.registry,\n\t\toracleRegistry: cfg.objects.oracleRegistry,\n\t\taccountRegistry: cfg.objects.accountRegistry,\n\t};\n}\n\n/**\n * {@link GeneratedConfig} plus the order-flow companion (`deepbook_predict_orders`) and the math\n * library: the slice the queued-order thunks and reads take. A queued order calls the companion,\n * which calls into Predict, so one object carries both packages' keys. `predictOrdersPackageIdV1`\n * is the companion's original ID, which types `OrderFlow` and the queue events.\n */\nexport type OrdersGeneratedConfig = GeneratedConfig &\n\tDeepbookPredictOrdersConfig &\n\tDeepbookPredictMathConfig & {\n\t\tpredictOrdersPackageId: string;\n\t\tpredictOrdersPackageIdV1: string;\n\t\torderDesk: string;\n\t\tqueueRegistry: string;\n\t};\n\n/**\n * Project a config that records delayed execution onto {@link OrdersGeneratedConfig}. Throws\n * `PredictInputError` while the config lacks the Predict upgrade, the companion package, its desk\n * or its queue registry: building a queued order against a guessed package would abort on chain\n * or, worse, address the wrong one.\n */\nexport function toOrdersConfig(cfg: PredictConfig): OrdersGeneratedConfig {\n\tconst { predictDelayedExecution, predictOrders, predictOrdersV1, predictMath } = cfg.packages;\n\tconst { orderDesk, queueRegistry } = cfg.objects;\n\tif (!predictDelayedExecution || !predictOrders || !orderDesk || !queueRegistry) {\n\t\tconst missing = [\n\t\t\t!predictDelayedExecution && '`packages.predictDelayedExecution`',\n\t\t\t!predictOrders && '`packages.predictOrders`',\n\t\t\t!orderDesk && '`objects.orderDesk`',\n\t\t\t!queueRegistry && '`objects.queueRegistry`',\n\t\t].filter(Boolean);\n\t\tthrow new PredictInputError(\n\t\t\t`delayed execution isn't recorded for ${cfg.network} in this SDK version (missing ` +\n\t\t\t\t`${missing.join(', ')}): pass a \\`config\\` that records the Predict upgrade, the ` +\n\t\t\t\t'`deepbook_predict_orders` package, its order desk and its queue registry',\n\t\t);\n\t}\n\treturn {\n\t\t...toGeneratedConfig(cfg),\n\t\tpredictOrdersPackageId: predictOrders,\n\t\tpredictOrdersPackageIdV1: predictOrdersV1 ?? predictOrders,\n\t\tpredictMathPackageId: predictMath,\n\t\torderDesk,\n\t\tqueueRegistry,\n\t};\n}\n"],"mappings":";;;AAiCA,SAAgB,kBAAkB,KAAqC;AACtE,QAAO;EACN,kBAAkB,IAAI,SAAS;EAC/B,oBAAoB,IAAI,SAAS,aAAa,IAAI,SAAS;EAC3D,kBAAkB,IAAI,SAAS;EAE/B,wBAAwB,IAAI,SAAS;EACrC,gBAAgB,IAAI,QAAQ;EAC5B,WAAW,IAAI,QAAQ;EACvB,UAAU,IAAI,QAAQ;EACtB,gBAAgB,IAAI,QAAQ;EAC5B,iBAAiB,IAAI,QAAQ;EAC7B;;;;;;;;AAwBF,SAAgB,eAAe,KAA2C;CACzE,MAAM,EAAE,yBAAyB,eAAe,iBAAiB,gBAAgB,IAAI;CACrF,MAAM,EAAE,WAAW,kBAAkB,IAAI;AACzC,KAAI,CAAC,2BAA2B,CAAC,iBAAiB,CAAC,aAAa,CAAC,eAAe;EAC/E,MAAM,UAAU;GACf,CAAC,2BAA2B;GAC5B,CAAC,iBAAiB;GAClB,CAAC,aAAa;GACd,CAAC,iBAAiB;GAClB,CAAC,OAAO,QAAQ;AACjB,QAAM,IAAI,kBACT,wCAAwC,IAAI,QAAQ,gCAChD,QAAQ,KAAK,KAAK,CAAC,uIAEvB;;AAEF,QAAO;EACN,GAAG,kBAAkB,IAAI;EACzB,wBAAwB;EACxB,0BAA0B,mBAAmB;EAC7C,sBAAsB;EACtB;EACA;EACA"}