{"version":3,"file":"index.mjs","names":[],"sources":["../../src/deployments/index.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Canonical per-network deployment ids.\n *\n * Every subpath reads its slice of this one record rather than carrying its own copy, so a\n * redeploy is a single regeneration (`pnpm sync-deployment`) and the subpaths cannot end up\n * addressing different deployments. The records themselves are generated from the deploy\n * tooling's manifest — see `scripts/sync-deployment.ts`.\n */\n\nimport type { SuiClientTypes } from '@mysten/sui/client';\n\nimport {\n\tMAINNET_ACCOUNT,\n\tMAINNET_DEPLOYMENT,\n\tMAINNET_PREDICT,\n\tMAINNET_SESSIONS,\n\tMAINNET_UNITS,\n} from './mainnet.js';\nimport {\n\tTESTNET_ACCOUNT,\n\tTESTNET_DEPLOYMENT,\n\tTESTNET_PREDICT,\n\tTESTNET_SESSIONS,\n\tTESTNET_UNITS,\n} from './testnet.js';\nimport type { DeploymentInfo, DeploymentUnits } from './types.js';\n\nexport type {\n\tAccountIds,\n\tDeploymentInfo,\n\tDeploymentUnits,\n\tPredictIds,\n\tSessionsIds,\n} from './types.js';\n\nexport { TESTNET_ACCOUNT, TESTNET_DEPLOYMENT, TESTNET_PREDICT, TESTNET_SESSIONS, TESTNET_UNITS };\nexport { MAINNET_ACCOUNT, MAINNET_DEPLOYMENT, MAINNET_PREDICT, MAINNET_SESSIONS, MAINNET_UNITS };\n\n/** Networks this package carries ids for. */\nexport type DeployedNetwork = 'testnet' | 'mainnet';\n\n/**\n * Accepts the same wide network type the Sui client exposes, so `getUnits(client.network)`\n * composes. Narrowing to `DeployedNetwork` would reject that, and listing\n * `'testnet' | 'mainnet'` would be worse still: it admits exactly one value that always\n * throws while rejecting `'devnet'` at compile time.\n */\nexport type NetworkArg = SuiClientTypes.Network;\n\nfunction unrecorded(network: string, override: string): Error {\n\treturn new Error(\n\t\t`@mysten/deepbook-v3: no deployment recorded for network '${network}'. ` +\n\t\t\t'Predict, sessions and the account primitive are recorded for testnet and mainnet. ' +\n\t\t\t`For your own deployment, ${override}`,\n\t);\n}\n\n/**\n * @description Which deployment the ids on `network` came from — its name and the\n * deepbookv3 commit they were generated at. Useful when a bug report needs to say which\n * on-chain deployment an SDK build was pinned to.\n * @throws if the network has no deployment recorded, rather than returning placeholder ids.\n */\nexport function getDeployment(network: NetworkArg): DeploymentInfo {\n\tif (network === 'testnet') return TESTNET_DEPLOYMENT;\n\tif (network === 'mainnet') return MAINNET_DEPLOYMENT;\n\tthrow unrecorded(network, 'read the deployment name and commit from your own deploy manifest.');\n}\n\n/**\n * @description Scale constants for `network` — lot size, fixed-point scale, and coin\n * decimals. Deployment-wide, so any subpath formatting a custody balance can read them\n * rather than hardcoding 6.\n * @throws if the network has no recorded deployment.\n */\nexport function getUnits(network: NetworkArg): DeploymentUnits {\n\tif (network === 'testnet') return TESTNET_UNITS;\n\tif (network === 'mainnet') return MAINNET_UNITS;\n\tthrow unrecorded(network, 'read these scale constants from your own deploy manifest.');\n}\n"],"mappings":";;;;AAoDA,SAAS,WAAW,SAAiB,UAAyB;AAC7D,wBAAO,IAAI,MACV,4DAA4D,QAAQ,gHAEvC,WAC7B;;;;;;;;AASF,SAAgB,cAAc,SAAqC;AAClE,KAAI,YAAY,UAAW,QAAO;AAClC,KAAI,YAAY,UAAW,QAAO;AAClC,OAAM,WAAW,SAAS,qEAAqE;;;;;;;;AAShG,SAAgB,SAAS,SAAsC;AAC9D,KAAI,YAAY,UAAW,QAAO;AAClC,KAAI,YAAY,UAAW,QAAO;AAClC,OAAM,WAAW,SAAS,4DAA4D"}