@somnia-chain/contracts-sdk 0.1.0 → 0.3.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 +86 -23
- package/dist/abis.d.ts +52 -0
- package/dist/abis.js +42 -0
- package/dist/decode-core.d.ts +51 -0
- package/dist/decode-core.js +145 -0
- package/dist/decode.d.ts +15 -0
- package/dist/decode.js +30 -0
- package/dist/digest.d.ts +11 -0
- package/dist/digest.js +33 -0
- package/dist/enumerate.d.ts +56 -0
- package/dist/enumerate.js +70 -0
- package/dist/gen/abi/deployer-contract/ProtocolDeployer.d.ts +2 -0
- package/dist/gen/abi/deployer-contract/ProtocolDeployer.js +3 -0
- package/dist/gen/abi/somnia-accounts/CompatibilityFallbackHandler.d.ts +2 -0
- package/dist/gen/abi/somnia-accounts/CompatibilityFallbackHandler.js +3 -0
- package/dist/gen/abi/somnia-accounts/MultiSend.d.ts +2 -0
- package/dist/gen/abi/somnia-accounts/MultiSend.js +3 -0
- package/dist/gen/abi/somnia-accounts/MultiSendCallOnly.d.ts +2 -0
- package/dist/gen/abi/somnia-accounts/MultiSendCallOnly.js +3 -0
- package/dist/gen/abi/somnia-accounts/Safe.d.ts +2 -0
- package/dist/gen/abi/somnia-accounts/Safe.js +3 -0
- package/dist/gen/abi/somnia-accounts/SomniaAccountFactory.d.ts +2 -0
- package/dist/gen/abi/somnia-accounts/SomniaAccountFactory.js +3 -0
- package/dist/gen/abi/somnia-accounts/SomniaAccountFactoryImpl.d.ts +2 -0
- package/dist/gen/abi/somnia-accounts/SomniaAccountFactoryImpl.js +3 -0
- package/dist/gen/abi/somnia-accounts/SomniaAccountFactoryImplV2.d.ts +2 -0
- package/dist/gen/abi/somnia-accounts/SomniaAccountFactoryImplV2.js +3 -0
- package/dist/gen/abi/somnia-accounts/SomniaAccountFactoryImplV3.d.ts +2 -0
- package/dist/gen/abi/somnia-accounts/SomniaAccountFactoryImplV3.js +3 -0
- package/dist/gen/abi/somnia-agents/agentRegistry.d.ts +2 -0
- package/dist/gen/abi/somnia-agents/agentRegistry.js +3 -0
- package/dist/gen/abi/somnia-agents/committee.d.ts +2 -0
- package/dist/gen/abi/somnia-agents/committee.js +3 -0
- package/dist/gen/abi/somnia-agents/somniaAgents.d.ts +2 -0
- package/dist/gen/abi/somnia-agents/somniaAgents.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/agent-aggregate-oracle.SBTCD_reader.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/agent-aggregate-oracle.SBTCD_reader.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/agent-aggregate-oracle.aggregateImplementation.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/agent-aggregate-oracle.aggregateImplementation.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/agent-aggregate-oracle.aggregateOracle.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/agent-aggregate-oracle.aggregateOracle.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/agent-oracles.factory.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/agent-oracles.factory.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/binary-market-makers.accessControl.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/binary-market-makers.accessControl.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/binary-market-makers.upgradeableBeacon.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/binary-market-makers.upgradeableBeacon.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/deploy.spotPoolImplementation.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/deploy.spotPoolImplementation.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/dream-vault.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/dream-vault.implementation.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/dream-vault.implementation.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/dream-vault.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/linked-wallet-registry.registryImplementation.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/linked-wallet-registry.registryImplementation.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/manual-oracles.ADA_manual.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/manual-oracles.ADA_manual.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/manual-oracles.AVAX_manual.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/manual-oracles.AVAX_manual.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/manual-oracles.BNB_manual.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/manual-oracles.BNB_manual.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/manual-oracles.BTC_manual.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/manual-oracles.BTC_manual.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/manual-oracles.DOGE_manual.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/manual-oracles.DOGE_manual.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/manual-oracles.ETH_manual.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/manual-oracles.ETH_manual.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/manual-oracles.HYPE_manual.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/manual-oracles.HYPE_manual.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/manual-oracles.LINK_manual.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/manual-oracles.LINK_manual.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/manual-oracles.NEAR_manual.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/manual-oracles.NEAR_manual.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/manual-oracles.SOL_manual.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/manual-oracles.SOL_manual.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/manual-oracles.SUI_manual.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/manual-oracles.SUI_manual.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/manual-oracles.TAO_manual.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/manual-oracles.TAO_manual.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/manual-oracles.WLD_manual.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/manual-oracles.WLD_manual.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/manual-oracles.XLM_manual.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/manual-oracles.XLM_manual.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/manual-oracles.XRP_manual.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/manual-oracles.XRP_manual.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/market-makers.accessControl.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/market-makers.accessControl.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/market-makers.marketMakers.mm-native-usdso.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/market-makers.marketMakers.mm-native-usdso.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/market-makers.marketMakers.mm-usdce-usdso.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/market-makers.marketMakers.mm-usdce-usdso.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/market-makers.marketMakers.mm-wbtc-usdso.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/market-makers.marketMakers.mm-wbtc-usdso.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/market-makers.marketMakers.mm-weth-usdso.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/market-makers.marketMakers.mm-weth-usdso.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/market-makers.upgradeableBeacon.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/market-makers.upgradeableBeacon.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/multi-source-oracle.SBNB_incumbentRouter.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/multi-source-oracle.SBNB_incumbentRouter.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/multi-source-oracle.SBTCD_incumbentRouter.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/multi-source-oracle.SBTCD_incumbentRouter.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/multi-source-oracle.SDOGE_incumbentRouter.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/multi-source-oracle.SDOGE_incumbentRouter.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/multi-source-oracle.SETH_incumbentRouter.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/multi-source-oracle.SETH_incumbentRouter.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/multi-source-oracle.SSOL_incumbentRouter.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/multi-source-oracle.SSOL_incumbentRouter.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/multi-source-oracle.factory.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/multi-source-oracle.factory.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/operator-permissions-registry.registryImplementation.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/operator-permissions-registry.registryImplementation.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/operator-permissions-registry.registryProxy.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/operator-permissions-registry.registryProxy.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perp-liquidation-swapper.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perp-liquidation-swapper.implementation.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perp-liquidation-swapper.implementation.js +7 -0
- package/dist/gen/abi/somnia-dex-protocol/perp-liquidation-swapper.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perp-market-makers.perpMarketMakers.sim-mm-bnb-perp.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perp-market-makers.perpMarketMakers.sim-mm-bnb-perp.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perp-market-makers.perpMarketMakers.sim-mm-btc-perp.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perp-market-makers.perpMarketMakers.sim-mm-btc-perp.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perp-market-makers.perpMarketMakers.sim-mm-near-perp.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perp-market-makers.perpMarketMakers.sim-mm-near-perp.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perp-taker-3.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perp-taker-3.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.ADA-PERP_baseToken.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.ADA-PERP_baseToken.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.AVAX-PERP_baseToken.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.AVAX-PERP_baseToken.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.BNB-PERP_baseToken.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.BNB-PERP_baseToken.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.BTC-PERP_baseToken.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.BTC-PERP_baseToken.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.DOGE-PERP_baseToken.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.DOGE-PERP_baseToken.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.ETH-PERP_baseToken.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.ETH-PERP_baseToken.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.HYPE-PERP_baseToken.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.HYPE-PERP_baseToken.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.LINK-PERP_baseToken.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.LINK-PERP_baseToken.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.NEAR-PERP_baseToken.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.NEAR-PERP_baseToken.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.SBTCC-PERP_baseToken.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.SBTCC-PERP_baseToken.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.SOL-PERP_baseToken.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.SOL-PERP_baseToken.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.SSOL-PERP_baseToken.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.SSOL-PERP_baseToken.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.SUI-PERP_baseToken.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.SUI-PERP_baseToken.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.TAO-PERP_baseToken.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.TAO-PERP_baseToken.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.WLD-PERP_baseToken.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.WLD-PERP_baseToken.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.XLM-PERP_baseToken.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.XLM-PERP_baseToken.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.XRP-PERP_baseToken.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.XRP-PERP_baseToken.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.adlRanker.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.adlRanker.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.insuranceFund.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.insuranceFund.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.linkedWalletAwareAdlRanker.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.linkedWalletAwareAdlRanker.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.linkedWalletRegistry.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.linkedWalletRegistry.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.liquidationEngine.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.liquidationEngine.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.marginBank.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.marginBank.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.perpPoolFactory.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.perpPoolFactory.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.simBidder.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.simBidder.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.unlinkGuard.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.unlinkGuard.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.voucherDistributor.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps-protocol.voucherDistributor.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps.perpStopOrderRegistries.ADA.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps.perpStopOrderRegistries.ADA.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps.perpStopOrderRegistries.AVAX.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps.perpStopOrderRegistries.AVAX.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps.perpStopOrderRegistries.BNB.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps.perpStopOrderRegistries.BNB.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps.perpStopOrderRegistries.BTC.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps.perpStopOrderRegistries.BTC.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps.perpStopOrderRegistries.DOGE.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps.perpStopOrderRegistries.DOGE.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps.perpStopOrderRegistries.ETH.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps.perpStopOrderRegistries.ETH.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps.perpStopOrderRegistries.HYPE.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps.perpStopOrderRegistries.HYPE.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps.perpStopOrderRegistries.LINK.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps.perpStopOrderRegistries.LINK.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps.perpStopOrderRegistries.NEAR.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps.perpStopOrderRegistries.NEAR.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps.perpStopOrderRegistries.SOL.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps.perpStopOrderRegistries.SOL.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps.perpStopOrderRegistries.SUI.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps.perpStopOrderRegistries.SUI.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps.perpStopOrderRegistries.TAO.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps.perpStopOrderRegistries.TAO.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps.perpStopOrderRegistries.WLD.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps.perpStopOrderRegistries.WLD.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps.perpStopOrderRegistries.XLM.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps.perpStopOrderRegistries.XLM.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps.perpStopOrderRegistries.XRP.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps.perpStopOrderRegistries.XRP.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps.perpStopOrderRegistryBeacon.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps.perpStopOrderRegistryBeacon.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/perps.perpStopOrderRegistryImplementation.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/perps.perpStopOrderRegistryImplementation.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/prophecy-oracle.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/prophecy-oracle.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/router.routerImplementation.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/router.routerImplementation.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/router.routerProxy.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/router.routerProxy.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/settlement-scheduler.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/settlement-scheduler.implementation.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/settlement-scheduler.implementation.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/settlement-scheduler.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/sim-oracle-proxies.SBNB_proxy.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/sim-oracle-proxies.SBNB_proxy.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/sim-oracle-proxies.SDOGE_proxy.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/sim-oracle-proxies.SDOGE_proxy.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/sim-oracle-proxies.SETH_proxy.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/sim-oracle-proxies.SETH_proxy.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/sim-oracle-proxies.SSOL_proxy.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/sim-oracle-proxies.SSOL_proxy.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/spot-pool-registry.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/spot-pool-registry.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/spot-pool.NATIVE_TOKEN_USDso.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/spot-pool.NATIVE_TOKEN_USDso.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/spot-pool.SpotPool_Beacon.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/spot-pool.SpotPool_Beacon.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/spot-pool.SpotPool_Implementation.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/spot-pool.SpotPool_Implementation.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/spot-pool.USDC.e_USDso.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/spot-pool.USDC.e_USDso.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/spot-pool.USDT_USDso.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/spot-pool.USDT_USDso.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/spot-pool.WBTC_USDso.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/spot-pool.WBTC_USDso.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/spot-pool.WETH_USDso.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/spot-pool.WETH_USDso.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/stop-order-registries.spotStopOrderRegistryBeacon.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/stop-order-registries.spotStopOrderRegistryBeacon.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/stop-order-registries.spotStopOrderRegistryImplementation.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/stop-order-registries.spotStopOrderRegistryImplementation.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/stop-order-registries.stopOrderRegistries.NATIVE_TOKEN_USDso.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/stop-order-registries.stopOrderRegistries.NATIVE_TOKEN_USDso.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/stop-order-registries.stopOrderRegistries.USDC.e_USDso.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/stop-order-registries.stopOrderRegistries.USDC.e_USDso.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/stop-order-registries.stopOrderRegistries.WBTC_USDso.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/stop-order-registries.stopOrderRegistries.WBTC_USDso.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/stop-order-registries.stopOrderRegistries.WETH_USDso.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/stop-order-registries.stopOrderRegistries.WETH_USDso.js +3 -0
- package/dist/gen/abi/somnia-dex-protocol/stork-oracle.d.ts +2 -0
- package/dist/gen/abi/somnia-dex-protocol/stork-oracle.js +3 -0
- package/dist/gen/abi/somnia-markets/BinaryClobFactory.d.ts +2 -0
- package/dist/gen/abi/somnia-markets/BinaryClobFactory.js +3 -0
- package/dist/gen/abi/somnia-markets/BinaryMarketImpl.d.ts +2 -0
- package/dist/gen/abi/somnia-markets/BinaryMarketImpl.js +3 -0
- package/dist/gen/abi/somnia-markets/BinaryMarketsModule.d.ts +2 -0
- package/dist/gen/abi/somnia-markets/BinaryMarketsModule.js +3 -0
- package/dist/gen/abi/somnia-markets/BinaryPoolImpl.d.ts +2 -0
- package/dist/gen/abi/somnia-markets/BinaryPoolImpl.js +3 -0
- package/dist/gen/abi/somnia-markets/BinarySettlement.d.ts +2 -0
- package/dist/gen/abi/somnia-markets/BinarySettlement.js +3 -0
- package/dist/gen/abi/somnia-markets/CollateralRouter.d.ts +2 -0
- package/dist/gen/abi/somnia-markets/CollateralRouter.js +3 -0
- package/dist/gen/abi/somnia-markets/MarketCreatorFactory.d.ts +2 -0
- package/dist/gen/abi/somnia-markets/MarketCreatorFactory.js +3 -0
- package/dist/gen/abi/somnia-markets/MarketCreatorFactory.legacy1.d.ts +2 -0
- package/dist/gen/abi/somnia-markets/MarketCreatorFactory.legacy1.js +3 -0
- package/dist/gen/abi/somnia-markets/MarketsCore.d.ts +2 -0
- package/dist/gen/abi/somnia-markets/MarketsCore.js +3 -0
- package/dist/gen/abi/somnia-markets/OracleHub.d.ts +2 -0
- package/dist/gen/abi/somnia-markets/OracleHub.js +3 -0
- package/dist/gen/abi/somnia-markets/OutcomeToken6909.d.ts +2 -0
- package/dist/gen/abi/somnia-markets/OutcomeToken6909.js +3 -0
- package/dist/gen/abi/somnia-markets/venue-1.marketCreator.d.ts +2 -0
- package/dist/gen/abi/somnia-markets/venue-1.marketCreator.js +3 -0
- package/dist/gen/abi/somnia-markets/venue-1.marketCreatorPolicy.d.ts +2 -0
- package/dist/gen/abi/somnia-markets/venue-1.marketCreatorPolicy.js +3 -0
- package/dist/gen/abi/somnia-markets/venue-2.marketCreator.d.ts +2 -0
- package/dist/gen/abi/somnia-markets/venue-2.marketCreator.js +3 -0
- package/dist/gen/abi/somnia-markets/venue-2.marketCreatorPolicy.d.ts +2 -0
- package/dist/gen/abi/somnia-markets/venue-2.marketCreatorPolicy.js +3 -0
- package/dist/gen/abi/somnia-markets/venue-3.marketCreator.d.ts +2 -0
- package/dist/gen/abi/somnia-markets/venue-3.marketCreator.js +3 -0
- package/dist/gen/abi/somnia-markets/venue-3.marketCreatorPolicy.d.ts +2 -0
- package/dist/gen/abi/somnia-markets/venue-3.marketCreatorPolicy.js +3 -0
- package/dist/gen/abi/somnia-markets/venue-5.marketCreator.d.ts +2 -0
- package/dist/gen/abi/somnia-markets/venue-5.marketCreator.js +3 -0
- package/dist/gen/abi/somnia-markets/venue-5.marketCreatorPolicy.d.ts +2 -0
- package/dist/gen/abi/somnia-markets/venue-5.marketCreatorPolicy.js +3 -0
- package/dist/gen/abis/072309c539e4.d.ts +864 -0
- package/dist/gen/abis/072309c539e4.js +1114 -0
- package/dist/gen/abis/0b3cd40e0bc8.d.ts +12 -0
- package/dist/gen/abis/0b3cd40e0bc8.js +17 -0
- package/dist/gen/abis/1a2db3035880.d.ts +891 -0
- package/dist/gen/abis/1a2db3035880.js +1149 -0
- package/dist/gen/abis/1a5696b34cbf.d.ts +589 -0
- package/dist/gen/abis/1a5696b34cbf.js +763 -0
- package/dist/gen/abis/1e00c7896e9e.d.ts +342 -0
- package/dist/gen/abis/1e00c7896e9e.js +442 -0
- package/dist/gen/abis/28f7c4e190be.d.ts +56 -0
- package/dist/gen/abis/28f7c4e190be.js +76 -0
- package/dist/gen/abis/2fc4ebdf8536.d.ts +492 -0
- package/dist/gen/abis/2fc4ebdf8536.js +641 -0
- package/dist/gen/abis/3197a9b71399.d.ts +690 -0
- package/dist/gen/abis/3197a9b71399.js +896 -0
- package/dist/gen/abis/3d5f1ad25c1d.d.ts +370 -0
- package/dist/gen/abis/3d5f1ad25c1d.js +480 -0
- package/dist/gen/abis/3eafdb9c0c96.d.ts +264 -0
- package/dist/gen/abis/3eafdb9c0c96.js +345 -0
- package/dist/gen/abis/403090974089.d.ts +590 -0
- package/dist/gen/abis/403090974089.js +766 -0
- package/dist/gen/abis/4167268939aa.d.ts +306 -0
- package/dist/gen/abis/4167268939aa.js +393 -0
- package/dist/gen/abis/46a90f031627.d.ts +940 -0
- package/dist/gen/abis/46a90f031627.js +1196 -0
- package/dist/gen/abis/49cb4deac436.d.ts +2041 -0
- package/dist/gen/abis/49cb4deac436.js +2618 -0
- package/dist/gen/abis/4d8bacb29f20.d.ts +991 -0
- package/dist/gen/abis/4d8bacb29f20.js +1271 -0
- package/dist/gen/abis/69f7ea016674.d.ts +202 -0
- package/dist/gen/abis/69f7ea016674.js +265 -0
- package/dist/gen/abis/734133340224.d.ts +1371 -0
- package/dist/gen/abis/734133340224.js +1767 -0
- package/dist/gen/abis/73ce587427d9.d.ts +2509 -0
- package/dist/gen/abis/73ce587427d9.js +3227 -0
- package/dist/gen/abis/7837fce34f57.d.ts +169 -0
- package/dist/gen/abis/7837fce34f57.js +221 -0
- package/dist/gen/abis/7efe899eb023.d.ts +1005 -0
- package/dist/gen/abis/7efe899eb023.js +1283 -0
- package/dist/gen/abis/836562f8baa3.d.ts +951 -0
- package/dist/gen/abis/836562f8baa3.js +1227 -0
- package/dist/gen/abis/83cdff66efa0.d.ts +278 -0
- package/dist/gen/abis/83cdff66efa0.js +365 -0
- package/dist/gen/abis/947a1caa8a16.d.ts +59 -0
- package/dist/gen/abis/947a1caa8a16.js +80 -0
- package/dist/gen/abis/9611b42c6d5f.d.ts +452 -0
- package/dist/gen/abis/9611b42c6d5f.js +590 -0
- package/dist/gen/abis/96e8cf2c064f.d.ts +1494 -0
- package/dist/gen/abis/96e8cf2c064f.js +1927 -0
- package/dist/gen/abis/9818d0265866.d.ts +874 -0
- package/dist/gen/abis/9818d0265866.js +1115 -0
- package/dist/gen/abis/9d6d8799f16f.d.ts +457 -0
- package/dist/gen/abis/9d6d8799f16f.js +587 -0
- package/dist/gen/abis/acdb264ea8c1.d.ts +2185 -0
- package/dist/gen/abis/acdb264ea8c1.js +2817 -0
- package/dist/gen/abis/b127df9297ac.d.ts +226 -0
- package/dist/gen/abis/b127df9297ac.js +292 -0
- package/dist/gen/abis/b3a5eed8be5c.d.ts +270 -0
- package/dist/gen/abis/b3a5eed8be5c.js +356 -0
- package/dist/gen/abis/b60156cb0dcf.d.ts +287 -0
- package/dist/gen/abis/b60156cb0dcf.js +376 -0
- package/dist/gen/abis/be2135567d5c.d.ts +358 -0
- package/dist/gen/abis/be2135567d5c.js +461 -0
- package/dist/gen/abis/c76e9681cb2f.d.ts +200 -0
- package/dist/gen/abis/c76e9681cb2f.js +265 -0
- package/dist/gen/abis/c84f8d0f9550.d.ts +16 -0
- package/dist/gen/abis/c84f8d0f9550.js +22 -0
- package/dist/gen/abis/cf9c2beac210.d.ts +139 -0
- package/dist/gen/abis/cf9c2beac210.js +180 -0
- package/dist/gen/abis/d407c410234a.d.ts +490 -0
- package/dist/gen/abis/d407c410234a.js +640 -0
- package/dist/gen/abis/d898521cbf00.d.ts +1591 -0
- package/dist/gen/abis/d898521cbf00.js +2070 -0
- package/dist/gen/abis/ecc4ba1d4404.d.ts +51 -0
- package/dist/gen/abis/ecc4ba1d4404.js +69 -0
- package/dist/gen/abis/eeb301f1a74b.d.ts +1466 -0
- package/dist/gen/abis/eeb301f1a74b.js +1872 -0
- package/dist/gen/abis/f4c6a88bd236.d.ts +686 -0
- package/dist/gen/abis/f4c6a88bd236.js +884 -0
- package/dist/gen/abis/f97be7b72b2f.d.ts +633 -0
- package/dist/gen/abis/f97be7b72b2f.js +810 -0
- package/dist/gen/abis/faaa48786a09.d.ts +547 -0
- package/dist/gen/abis/faaa48786a09.js +703 -0
- package/dist/gen/abis/fd1f15294d67.d.ts +774 -0
- package/dist/gen/abis/fd1f15294d67.js +1001 -0
- package/dist/gen/abis/fea5d0628b94.d.ts +109 -0
- package/dist/gen/abis/fea5d0628b94.js +144 -0
- package/dist/gen/abis-index.d.ts +29245 -0
- package/dist/gen/abis-index.js +91 -0
- package/dist/gen/meta.d.ts +5 -0
- package/dist/gen/meta.js +6 -0
- package/dist/gen/registry.d.ts +225 -92124
- package/dist/gen/registry.js +3705 -38212
- package/dist/index.d.ts +113 -16
- package/dist/index.js +88 -37
- package/package.json +24 -1
package/README.md
CHANGED
|
@@ -8,48 +8,111 @@ reconciled against.
|
|
|
8
8
|
npm install @somnia-chain/contracts-sdk
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
The package is split by delivery mechanism, deliberately. Addresses and chain
|
|
12
|
+
information are small and change on every deploy — they live in the root
|
|
13
|
+
entry, ~170 kB of data. ABIs are megabytes that change only when contracts
|
|
14
|
+
change — they ship one module per contract, so a client bundle carries exactly
|
|
15
|
+
the ABIs it imports and a bundle that needs only addresses carries none.
|
|
16
|
+
|
|
17
|
+
## Addresses and networks — the root entry
|
|
18
|
+
|
|
11
19
|
```ts
|
|
12
|
-
import {
|
|
20
|
+
import { address, tryAddress, contracts, identify } from "@somnia-chain/contracts-sdk";
|
|
21
|
+
|
|
22
|
+
address("somnia-mainnet", "somnia-markets", "MarketsCore");
|
|
23
|
+
// throws on unknown names — the "this must exist" form; every slug and
|
|
24
|
+
// name is autocompleted and the address is a literal type
|
|
25
|
+
|
|
26
|
+
tryAddress("hideki-testnet", "somnia-markets", "MarketsCore"); // Address | null
|
|
27
|
+
// the "is it deployed here?" form — projects do not span every network
|
|
13
28
|
|
|
14
|
-
|
|
15
|
-
|
|
29
|
+
contracts("somnia-mainnet", "somnia-markets"); // enumerate, for admin screens
|
|
30
|
+
identify("somnia-mainnet", "0x1a47…"); // reverse lookup: project, name, kind
|
|
16
31
|
|
|
17
|
-
|
|
18
|
-
//
|
|
32
|
+
allContracts();
|
|
33
|
+
// every current deployment across every live network — the dashboard form.
|
|
34
|
+
// Retired networks and superseded deployments are excluded by default, so a
|
|
35
|
+
// wiped testnet's addresses cannot be rendered as current by forgetting to
|
|
36
|
+
// filter: { includeRetiredNetworks, includeSuperseded, project } to widen it.
|
|
19
37
|
```
|
|
20
38
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
(`
|
|
39
|
+
Entries carry `address`, `kind`, `status`, `version`, and `contract` — the
|
|
40
|
+
Solidity contract name, where a source stated one. `kind` and `status` are
|
|
41
|
+
unions (`DeploymentKind`, `ContractStatus`), not `string`.
|
|
24
42
|
|
|
25
|
-
|
|
26
|
-
|
|
43
|
+
Networks: `networks` (all, retired included), `network(slug)`,
|
|
44
|
+
`liveNetworks()`, and `toChain(slug, { rpcUrl })` for a viem-`Chain`-shaped
|
|
45
|
+
object — you supply the RPC URL, the registry deliberately records no public
|
|
46
|
+
endpoint. `registryVersion` says which commit the data came from.
|
|
47
|
+
|
|
48
|
+
### Chain IDs are not unique
|
|
49
|
+
|
|
50
|
+
Networks are keyed by **slug**, never by chain id: a testnet regenesis reuses
|
|
51
|
+
the chain id with none of the state, so one id can name two networks with
|
|
52
|
+
different contracts at identical addresses.
|
|
27
53
|
|
|
28
54
|
```ts
|
|
29
|
-
|
|
30
|
-
|
|
55
|
+
networksByChainId(50383); // -> both hideki testnets — an array, deliberately
|
|
56
|
+
```
|
|
31
57
|
|
|
32
|
-
|
|
33
|
-
|
|
58
|
+
## ABIs — typed per contract, or the whole corpus
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
// Build-time, typed, tree-shakeable: one module per contract.
|
|
62
|
+
import { SafeAbi } from "@somnia-chain/contracts-sdk/abi/somnia-accounts/Safe";
|
|
63
|
+
// as-const literal — viem infers function names and argument types
|
|
64
|
+
|
|
65
|
+
// Runtime, whole corpus (~1 MB — server/admin paths):
|
|
66
|
+
import { abiFor, abiByHash, verifyAbi, writeFunctions } from "@somnia-chain/contracts-sdk/abis";
|
|
67
|
+
|
|
68
|
+
abiFor("somnia-mainnet", "somnia-markets", "MarketsCore"); // Abi | null
|
|
69
|
+
abiByHash("sha256:…"); // historical ABIs too — decode an old tx correctly
|
|
70
|
+
verifyAbi("sha256:…", abi); // sha256 over key-sorted compact JSON — verify, don't trust filenames
|
|
71
|
+
writeFunctions("somnia-mainnet", "somnia-markets", "MarketsCore");
|
|
72
|
+
// all state-changing functions — allowlists are application policy, not deployment facts
|
|
73
|
+
|
|
74
|
+
allContractsWithAbi();
|
|
75
|
+
// allContracts() with each ABI resolved to `abiJson` — addresses, networks and
|
|
76
|
+
// ABIs in one call. Costs the whole corpus, which is why it lives here.
|
|
34
77
|
```
|
|
35
78
|
|
|
36
|
-
|
|
37
|
-
|
|
79
|
+
### Not every deployment has an ABI
|
|
80
|
+
|
|
81
|
+
`abiFor` returns `null`, and `abiJson` is `null`, for a real share of what the
|
|
82
|
+
registry holds — around half, concentrated in the testnets. That is a fact
|
|
83
|
+
about the records, not a gap in the package: the registry records a contract
|
|
84
|
+
name only where a broadcast log stated it or the repo declared one, and an ABI
|
|
85
|
+
is looked up by that name. Deployments created from a shared script as
|
|
86
|
+
per-asset instances — `BTC_reader`, `ADA_oracle` — name a role rather than a
|
|
87
|
+
contract, so they carry an address and no ABI. `contract` is set on exactly
|
|
88
|
+
the entries that have one, so it is the field to branch on.
|
|
38
89
|
|
|
39
|
-
##
|
|
90
|
+
## Decoding calldata
|
|
40
91
|
|
|
41
|
-
|
|
42
|
-
reuses the chain id with none of the state, so one id can name two networks
|
|
43
|
-
with different contracts at identical addresses. If an id is all you have:
|
|
92
|
+
Requires `viem` (optional peer dependency; only this entry needs it).
|
|
44
93
|
|
|
45
94
|
```ts
|
|
46
|
-
import {
|
|
95
|
+
import { decodeCall, decodeBySelector } from "@somnia-chain/contracts-sdk/decode";
|
|
47
96
|
|
|
48
|
-
|
|
97
|
+
const call = decodeCall("somnia-mainnet", to, data);
|
|
98
|
+
// identifies the target, decodes against its recorded ABI, and recurses
|
|
99
|
+
// through Safe execTransaction / MultiSend, Multicall3 and upgradeToAndCall —
|
|
100
|
+
// what a signer staring at hex actually needs
|
|
101
|
+
|
|
102
|
+
if (call.status === "decoded") call.signature; // "transfer(address,uint256)"
|
|
103
|
+
else call.selector; // undecoded is a variant, not an error
|
|
104
|
+
|
|
105
|
+
decodeBySelector(data); // 4-byte fallback across every ABI the registry holds
|
|
49
106
|
```
|
|
50
107
|
|
|
51
108
|
## Versioning
|
|
52
109
|
|
|
53
|
-
The package is a snapshot of the registry, published when
|
|
110
|
+
The package is a snapshot of the registry, and it is published when that
|
|
111
|
+
snapshot changes rather than when someone remembers to publish it. The
|
|
112
|
+
reconciliation lane compares the surface it would generate against the one the
|
|
113
|
+
last release shipped, and cuts a patch version whenever addresses, ABIs or
|
|
114
|
+
chain information moved — so a contract deployed today reaches npm on the next
|
|
115
|
+
lane run. Minor and major versions are cut by hand, for API changes.
|
|
116
|
+
|
|
54
117
|
Update the dependency to pick up newly deployed contracts — nothing is fetched
|
|
55
118
|
at runtime.
|
package/dist/abis.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { abisByHash } from "./gen/abis-index.js";
|
|
2
|
+
import { type AllContractsOptions, type ListedContract, type NetworkSlug } from "./index.js";
|
|
3
|
+
export { abisByHash };
|
|
4
|
+
export { abiDigest, verifyAbi } from "./digest.js";
|
|
5
|
+
/**
|
|
6
|
+
* Everything in this module drags the full ABI corpus (about a megabyte)
|
|
7
|
+
* into the importing bundle — that is its job; decoders need the whole
|
|
8
|
+
* corpus. A client bundle that needs one contract's ABI typed should import
|
|
9
|
+
* its `./abi/<project>/<Contract>` module instead, and one that needs only
|
|
10
|
+
* addresses should stay on the package root.
|
|
11
|
+
*/
|
|
12
|
+
export interface AbiItem {
|
|
13
|
+
type: string;
|
|
14
|
+
name?: string;
|
|
15
|
+
inputs?: readonly unknown[];
|
|
16
|
+
outputs?: readonly unknown[];
|
|
17
|
+
stateMutability?: string;
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
export type AbiFunction = AbiItem & {
|
|
21
|
+
type: "function";
|
|
22
|
+
};
|
|
23
|
+
/** The recorded ABI for one deployment, or null where the registry has none — including an unknown name, because the decoder path treats absence as an answer. For literal types, import the contract's `./abi/*` module. */
|
|
24
|
+
export declare function abiFor(net: NetworkSlug, project: string, name: string): readonly AbiItem[] | null;
|
|
25
|
+
/** Resolve a digest — including a historical one no current deployment points at — to its ABI. */
|
|
26
|
+
export declare function abiByHash(digest: string): readonly AbiItem[] | null;
|
|
27
|
+
export interface ResolvedContract extends ListedContract {
|
|
28
|
+
/**
|
|
29
|
+
* The recorded ABI, or null where the registry has none. Null is common and
|
|
30
|
+
* is a fact about the registry, not an error: an ABI is recorded only where
|
|
31
|
+
* a source named the contract, so per-asset instances deployed from a shared
|
|
32
|
+
* script — `BTC_reader`, `ADA_router` — usually carry an address and no ABI.
|
|
33
|
+
*/
|
|
34
|
+
abiJson: readonly AbiItem[] | null;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Every current deployment with its ABI already resolved — addresses,
|
|
38
|
+
* networks and ABIs in one call.
|
|
39
|
+
*
|
|
40
|
+
* This is the whole-corpus convenience, and it costs the whole corpus: it
|
|
41
|
+
* lives here rather than in the root entry so that importing it is a decision.
|
|
42
|
+
* A server or admin surface rendering every contract wants exactly this; a
|
|
43
|
+
* client bundle wants `allContracts()` from the root and a per-contract
|
|
44
|
+
* `./abi/*` module for the one ABI it actually needs.
|
|
45
|
+
*/
|
|
46
|
+
export declare function allContractsWithAbi(opts?: AllContractsOptions): ResolvedContract[];
|
|
47
|
+
/**
|
|
48
|
+
* The state-changing functions of one deployment's ABI. Deliberately the
|
|
49
|
+
* whole set: trimming it to an allowlist is operational policy, and policy
|
|
50
|
+
* belongs to the application, not to a registry of deployment facts.
|
|
51
|
+
*/
|
|
52
|
+
export declare function writeFunctions(net: NetworkSlug, project: string, name: string): AbiFunction[];
|
package/dist/abis.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { abisByHash } from "./gen/abis-index.js";
|
|
2
|
+
import { allContracts, registry, } from "./index.js";
|
|
3
|
+
export { abisByHash };
|
|
4
|
+
export { abiDigest, verifyAbi } from "./digest.js";
|
|
5
|
+
/** The recorded ABI for one deployment, or null where the registry has none — including an unknown name, because the decoder path treats absence as an answer. For literal types, import the contract's `./abi/*` module. */
|
|
6
|
+
export function abiFor(net, project, name) {
|
|
7
|
+
const book = registry[net]?.contracts;
|
|
8
|
+
const digest = book?.[project]?.[name]?.abi;
|
|
9
|
+
return digest ? abiByHash(digest) : null;
|
|
10
|
+
}
|
|
11
|
+
/** Resolve a digest — including a historical one no current deployment points at — to its ABI. */
|
|
12
|
+
export function abiByHash(digest) {
|
|
13
|
+
return abisByHash[digest] ?? null;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Every current deployment with its ABI already resolved — addresses,
|
|
17
|
+
* networks and ABIs in one call.
|
|
18
|
+
*
|
|
19
|
+
* This is the whole-corpus convenience, and it costs the whole corpus: it
|
|
20
|
+
* lives here rather than in the root entry so that importing it is a decision.
|
|
21
|
+
* A server or admin surface rendering every contract wants exactly this; a
|
|
22
|
+
* client bundle wants `allContracts()` from the root and a per-contract
|
|
23
|
+
* `./abi/*` module for the one ABI it actually needs.
|
|
24
|
+
*/
|
|
25
|
+
export function allContractsWithAbi(opts = {}) {
|
|
26
|
+
return allContracts(opts).map((entry) => ({
|
|
27
|
+
...entry,
|
|
28
|
+
abiJson: entry.abi ? abiByHash(entry.abi) : null,
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The state-changing functions of one deployment's ABI. Deliberately the
|
|
33
|
+
* whole set: trimming it to an allowlist is operational policy, and policy
|
|
34
|
+
* belongs to the application, not to a registry of deployment facts.
|
|
35
|
+
*/
|
|
36
|
+
export function writeFunctions(net, project, name) {
|
|
37
|
+
const abi = abiFor(net, project, name);
|
|
38
|
+
if (!abi)
|
|
39
|
+
return [];
|
|
40
|
+
return abi.filter((item) => item.type === "function" &&
|
|
41
|
+
(item.stateMutability === "nonpayable" || item.stateMutability === "payable"));
|
|
42
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calldata decoding against the registry's ABI corpus, engine only: the
|
|
3
|
+
* dependencies come in through `DecoderDeps`, so the engine is a pure
|
|
4
|
+
* function of them and testable without the generated data modules.
|
|
5
|
+
* `./decode` wires it to the real registry.
|
|
6
|
+
*/
|
|
7
|
+
export type Hex = `0x${string}`;
|
|
8
|
+
export interface DecodedIdentity {
|
|
9
|
+
project: string;
|
|
10
|
+
name: string;
|
|
11
|
+
kind: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Undecoded is a variant, not an error: calldata to a contract the registry
|
|
15
|
+
* has never seen is normal on a permissionless chain, and the caller's UI
|
|
16
|
+
* has to render that state either way.
|
|
17
|
+
*/
|
|
18
|
+
export type DecodedCall = {
|
|
19
|
+
status: "decoded";
|
|
20
|
+
to?: Hex;
|
|
21
|
+
contract?: DecodedIdentity;
|
|
22
|
+
functionName: string;
|
|
23
|
+
signature: string;
|
|
24
|
+
args: readonly unknown[];
|
|
25
|
+
/** Other registry signatures sharing the selector; present when the match was by selector and ambiguous. */
|
|
26
|
+
alternatives?: string[];
|
|
27
|
+
/** Nested decodes: Safe execTransaction/multiSend, Multicall3, upgradeToAndCall. */
|
|
28
|
+
calls?: DecodedCall[];
|
|
29
|
+
} | {
|
|
30
|
+
status: "undecoded";
|
|
31
|
+
to?: Hex;
|
|
32
|
+
selector: Hex | null;
|
|
33
|
+
data: Hex;
|
|
34
|
+
};
|
|
35
|
+
export interface DecoderDeps {
|
|
36
|
+
/** The recorded ABI for a deployment, or null. */
|
|
37
|
+
abiFor(net: string, project: string, name: string): readonly unknown[] | null;
|
|
38
|
+
/** Reverse lookup of an address on a network. */
|
|
39
|
+
identify(net: string, addr: string): {
|
|
40
|
+
project: string;
|
|
41
|
+
name: string;
|
|
42
|
+
kind: string;
|
|
43
|
+
} | null;
|
|
44
|
+
/** The whole ABI corpus, for the selector fallback. */
|
|
45
|
+
allAbis(): Iterable<readonly unknown[]>;
|
|
46
|
+
}
|
|
47
|
+
export interface Decoder {
|
|
48
|
+
decodeCall(net: string, to: Hex, data: Hex): DecodedCall;
|
|
49
|
+
decodeBySelector(data: Hex): DecodedCall;
|
|
50
|
+
}
|
|
51
|
+
export declare function createDecoder(deps: DecoderDeps): Decoder;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { decodeFunctionData, toFunctionSelector } from "viem";
|
|
2
|
+
export function createDecoder(deps) {
|
|
3
|
+
let selectorIndex = null;
|
|
4
|
+
function bySelector() {
|
|
5
|
+
if (selectorIndex)
|
|
6
|
+
return selectorIndex;
|
|
7
|
+
selectorIndex = new Map();
|
|
8
|
+
const seen = new Set();
|
|
9
|
+
for (const abi of deps.allAbis()) {
|
|
10
|
+
for (const item of abi) {
|
|
11
|
+
if (item.type !== "function")
|
|
12
|
+
continue;
|
|
13
|
+
let selector;
|
|
14
|
+
let signature;
|
|
15
|
+
try {
|
|
16
|
+
selector = toFunctionSelector(item);
|
|
17
|
+
signature = fnSignature(item);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
const key = `${selector} ${signature}`;
|
|
23
|
+
if (seen.has(key))
|
|
24
|
+
continue;
|
|
25
|
+
seen.add(key);
|
|
26
|
+
const list = selectorIndex.get(selector) ?? [];
|
|
27
|
+
list.push(item);
|
|
28
|
+
selectorIndex.set(selector, list);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return selectorIndex;
|
|
32
|
+
}
|
|
33
|
+
function tryDecode(abi, data) {
|
|
34
|
+
try {
|
|
35
|
+
const { functionName, args } = decodeFunctionData({ abi: abi, data });
|
|
36
|
+
const item = abi.find((i) => i.type === "function" && i.name === functionName && toFunctionSelector(i) === data.slice(0, 10));
|
|
37
|
+
return item ? { functionName, args: args ?? [], item } : null;
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function nested(net, decoded) {
|
|
44
|
+
const { functionName, args } = decoded;
|
|
45
|
+
// Safe execTransaction(to, value, data, operation, …) — one wrapped call.
|
|
46
|
+
if (functionName === "execTransaction" && args.length >= 4) {
|
|
47
|
+
return [decodeCall(net, args[0], args[2])];
|
|
48
|
+
}
|
|
49
|
+
// Safe MultiSend multiSend(bytes) — packed (operation, to, value, dataLength, data)*.
|
|
50
|
+
if (functionName === "multiSend" && typeof args[0] === "string") {
|
|
51
|
+
return decodeMultiSendBlob(net, args[0]);
|
|
52
|
+
}
|
|
53
|
+
// Multicall3: aggregate((address,bytes)[]), tryAggregate(bool,(address,bytes)[]), aggregate3((address,bool,bytes)[]), aggregate3Value(…).
|
|
54
|
+
if (/^(aggregate3?(Value)?|tryAggregate(3)?|tryBlockAndAggregate|blockAndAggregate)$/.test(functionName)) {
|
|
55
|
+
const calls = args.find(Array.isArray);
|
|
56
|
+
if (calls) {
|
|
57
|
+
return calls
|
|
58
|
+
.filter((c) => c.target !== undefined && c.callData !== undefined)
|
|
59
|
+
.map((c) => decodeCall(net, c.target, c.callData));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// ERC-1967 upgradeToAndCall(newImplementation, data) — the payload runs against the new implementation.
|
|
63
|
+
if (functionName === "upgradeToAndCall" && args.length >= 2 && typeof args[1] === "string" && args[1].length > 2) {
|
|
64
|
+
return [decodeCall(net, args[0], args[1])];
|
|
65
|
+
}
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
function decodeMultiSendBlob(net, blob) {
|
|
69
|
+
const out = [];
|
|
70
|
+
const hex = blob.slice(2);
|
|
71
|
+
let i = 0;
|
|
72
|
+
// operation: 1 byte, to: 20, value: 32, dataLength: 32, data: dataLength.
|
|
73
|
+
while (i + 170 <= hex.length) {
|
|
74
|
+
const to = `0x${hex.slice(i + 2, i + 42)}`;
|
|
75
|
+
const dataLength = parseInt(hex.slice(i + 106, i + 170), 16);
|
|
76
|
+
if (!Number.isFinite(dataLength) || i + 170 + dataLength * 2 > hex.length)
|
|
77
|
+
break;
|
|
78
|
+
const data = `0x${hex.slice(i + 170, i + 170 + dataLength * 2)}`;
|
|
79
|
+
out.push(decodeCall(net, to, data));
|
|
80
|
+
i += 170 + dataLength * 2;
|
|
81
|
+
}
|
|
82
|
+
return out;
|
|
83
|
+
}
|
|
84
|
+
function decodeCall(net, to, data) {
|
|
85
|
+
const selector = data.length >= 10 ? data.slice(0, 10) : null;
|
|
86
|
+
const identity = deps.identify(net, to);
|
|
87
|
+
if (identity) {
|
|
88
|
+
const abi = deps.abiFor(net, identity.project, identity.name);
|
|
89
|
+
if (abi) {
|
|
90
|
+
const decoded = tryDecode(abi, data);
|
|
91
|
+
if (decoded) {
|
|
92
|
+
const calls = nested(net, decoded);
|
|
93
|
+
return {
|
|
94
|
+
status: "decoded",
|
|
95
|
+
to,
|
|
96
|
+
contract: { project: identity.project, name: identity.name, kind: identity.kind },
|
|
97
|
+
functionName: decoded.functionName,
|
|
98
|
+
signature: fnSignature(decoded.item),
|
|
99
|
+
args: decoded.args,
|
|
100
|
+
...(calls ? { calls } : {}),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const fallback = decodeBySelector(data);
|
|
106
|
+
if (fallback.status === "decoded") {
|
|
107
|
+
return { ...fallback, to, ...(identity ? { contract: identity } : {}) };
|
|
108
|
+
}
|
|
109
|
+
return { status: "undecoded", to, selector, data };
|
|
110
|
+
}
|
|
111
|
+
function decodeBySelector(data) {
|
|
112
|
+
const selector = data.length >= 10 ? data.slice(0, 10) : null;
|
|
113
|
+
if (!selector)
|
|
114
|
+
return { status: "undecoded", selector: null, data };
|
|
115
|
+
const candidates = bySelector().get(selector) ?? [];
|
|
116
|
+
for (const item of candidates) {
|
|
117
|
+
const decoded = tryDecode([item], data);
|
|
118
|
+
if (!decoded)
|
|
119
|
+
continue;
|
|
120
|
+
const alternatives = candidates.filter((c) => c !== item).map(fnSignature);
|
|
121
|
+
const calls = nested("", decoded);
|
|
122
|
+
return {
|
|
123
|
+
status: "decoded",
|
|
124
|
+
functionName: decoded.functionName,
|
|
125
|
+
signature: fnSignature(item),
|
|
126
|
+
args: decoded.args,
|
|
127
|
+
...(alternatives.length > 0 ? { alternatives } : {}),
|
|
128
|
+
...(calls ? { calls } : {}),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
return { status: "undecoded", selector, data };
|
|
132
|
+
}
|
|
133
|
+
return { decodeCall, decodeBySelector };
|
|
134
|
+
}
|
|
135
|
+
function fnSignature(item) {
|
|
136
|
+
const inputs = (item.inputs ?? []).map((input) => formatParam(input));
|
|
137
|
+
return `${item.name}(${inputs.join(",")})`;
|
|
138
|
+
}
|
|
139
|
+
function formatParam(param) {
|
|
140
|
+
if (param.type.startsWith("tuple") && param.components) {
|
|
141
|
+
const inner = param.components.map((c) => formatParam(c)).join(",");
|
|
142
|
+
return `(${inner})${param.type.slice(5)}`;
|
|
143
|
+
}
|
|
144
|
+
return param.type;
|
|
145
|
+
}
|
package/dist/decode.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type NetworkSlug } from "./index.js";
|
|
2
|
+
import { createDecoder, type DecodedCall, type Decoder, type Hex } from "./decode-core.js";
|
|
3
|
+
export { createDecoder };
|
|
4
|
+
export type { DecodedCall, Decoder, Hex };
|
|
5
|
+
/**
|
|
6
|
+
* Decode calldata sent to an address on a network: reverse-lookup the
|
|
7
|
+
* contract, decode against its recorded ABI, and recurse through the
|
|
8
|
+
* wrappers a signer actually meets — Safe execTransaction and MultiSend,
|
|
9
|
+
* Multicall3 aggregates, upgradeToAndCall payloads. Falls back to a
|
|
10
|
+
* selector search across every registry ABI; an `undecoded` result is a
|
|
11
|
+
* normal variant, not an error.
|
|
12
|
+
*/
|
|
13
|
+
export declare function decodeCall(net: NetworkSlug, to: Hex, data: Hex): DecodedCall;
|
|
14
|
+
/** Decode calldata by selector alone, against every ABI the registry holds. */
|
|
15
|
+
export declare function decodeBySelector(data: Hex): DecodedCall;
|
package/dist/decode.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { abisByHash } from "./gen/abis-index.js";
|
|
2
|
+
import { abiFor } from "./abis.js";
|
|
3
|
+
import { identify, registry } from "./index.js";
|
|
4
|
+
import { createDecoder } from "./decode-core.js";
|
|
5
|
+
export { createDecoder };
|
|
6
|
+
/**
|
|
7
|
+
* The registry-wired decoder. Importing this module pulls the full ABI
|
|
8
|
+
* corpus into the bundle and requires `viem` (an optional peer dependency
|
|
9
|
+
* everywhere else in the package).
|
|
10
|
+
*/
|
|
11
|
+
const decoder = createDecoder({
|
|
12
|
+
abiFor: (net, project, name) => abiFor(net, project, name),
|
|
13
|
+
identify: (net, addr) => (net in registry ? identify(net, addr) : null),
|
|
14
|
+
allAbis: () => Object.values(abisByHash),
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* Decode calldata sent to an address on a network: reverse-lookup the
|
|
18
|
+
* contract, decode against its recorded ABI, and recurse through the
|
|
19
|
+
* wrappers a signer actually meets — Safe execTransaction and MultiSend,
|
|
20
|
+
* Multicall3 aggregates, upgradeToAndCall payloads. Falls back to a
|
|
21
|
+
* selector search across every registry ABI; an `undecoded` result is a
|
|
22
|
+
* normal variant, not an error.
|
|
23
|
+
*/
|
|
24
|
+
export function decodeCall(net, to, data) {
|
|
25
|
+
return decoder.decodeCall(net, to, data);
|
|
26
|
+
}
|
|
27
|
+
/** Decode calldata by selector alone, against every ABI the registry holds. */
|
|
28
|
+
export function decodeBySelector(data) {
|
|
29
|
+
return decoder.decodeBySelector(data);
|
|
30
|
+
}
|
package/dist/digest.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AbiDigest } from "./index.js";
|
|
2
|
+
/**
|
|
3
|
+
* The registry's canonical ABI digest: sha256 over the ABI's canonical JSON —
|
|
4
|
+
* keys recursively sorted, compact separators, UTF-8. This mirrors the
|
|
5
|
+
* registry's own `abiDigest` exactly; the sorting is the part a consumer
|
|
6
|
+
* cannot guess from the digest alone, which is why the function is exported
|
|
7
|
+
* instead of being something everyone reverse-engineers.
|
|
8
|
+
*/
|
|
9
|
+
export declare function abiDigest(abi: readonly unknown[]): AbiDigest;
|
|
10
|
+
/** Does this ABI hash to this digest? Verify instead of trusting a filename. */
|
|
11
|
+
export declare function verifyAbi(digest: string, abi: readonly unknown[]): boolean;
|
package/dist/digest.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { sha256 } from "@noble/hashes/sha2.js";
|
|
2
|
+
/**
|
|
3
|
+
* The registry's canonical ABI digest: sha256 over the ABI's canonical JSON —
|
|
4
|
+
* keys recursively sorted, compact separators, UTF-8. This mirrors the
|
|
5
|
+
* registry's own `abiDigest` exactly; the sorting is the part a consumer
|
|
6
|
+
* cannot guess from the digest alone, which is why the function is exported
|
|
7
|
+
* instead of being something everyone reverse-engineers.
|
|
8
|
+
*/
|
|
9
|
+
export function abiDigest(abi) {
|
|
10
|
+
const canonical = JSON.stringify(sortKeys(abi));
|
|
11
|
+
const bytes = sha256(new TextEncoder().encode(canonical));
|
|
12
|
+
let hex = "";
|
|
13
|
+
for (const b of bytes)
|
|
14
|
+
hex += b.toString(16).padStart(2, "0");
|
|
15
|
+
return `sha256:${hex}`;
|
|
16
|
+
}
|
|
17
|
+
/** Does this ABI hash to this digest? Verify instead of trusting a filename. */
|
|
18
|
+
export function verifyAbi(digest, abi) {
|
|
19
|
+
return abiDigest(abi) === digest;
|
|
20
|
+
}
|
|
21
|
+
// Arrays keep their order — in an ABI, parameter order is meaning.
|
|
22
|
+
function sortKeys(value) {
|
|
23
|
+
if (Array.isArray(value))
|
|
24
|
+
return value.map(sortKeys);
|
|
25
|
+
if (value && typeof value === "object" && value.constructor === Object) {
|
|
26
|
+
const out = {};
|
|
27
|
+
for (const key of Object.keys(value).sort()) {
|
|
28
|
+
out[key] = sortKeys(value[key]);
|
|
29
|
+
}
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enumeration over the address books, with no generated data in sight.
|
|
3
|
+
*
|
|
4
|
+
* Split out for the same reason `decode-core.ts` is: the generated modules are
|
|
5
|
+
* a build product, so anything that imports them cannot be tested until they
|
|
6
|
+
* exist — and the filtering here is precisely what a dashboard relies on to
|
|
7
|
+
* not render a wiped testnet's addresses as current. Structural types rather
|
|
8
|
+
* than the package's public ones, so this file depends on nothing.
|
|
9
|
+
*/
|
|
10
|
+
export interface BookEntry {
|
|
11
|
+
address: string;
|
|
12
|
+
kind: string;
|
|
13
|
+
status: string;
|
|
14
|
+
version: string;
|
|
15
|
+
contract?: string;
|
|
16
|
+
implementation?: string;
|
|
17
|
+
startBlock?: number;
|
|
18
|
+
abi?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface NetworkBook {
|
|
21
|
+
status: string;
|
|
22
|
+
contracts: Record<string, Record<string, BookEntry>>;
|
|
23
|
+
}
|
|
24
|
+
export type Books = Record<string, NetworkBook>;
|
|
25
|
+
export interface Listed extends BookEntry {
|
|
26
|
+
network: string;
|
|
27
|
+
project: string;
|
|
28
|
+
name: string;
|
|
29
|
+
}
|
|
30
|
+
export interface EnumerateOptions {
|
|
31
|
+
includeRetiredNetworks?: boolean;
|
|
32
|
+
includeSuperseded?: boolean;
|
|
33
|
+
project?: string;
|
|
34
|
+
}
|
|
35
|
+
/** One network's deployments, optionally one project's. Throws on an unknown slug. */
|
|
36
|
+
export declare function listContracts(books: Books, net: string, project?: string): Listed[];
|
|
37
|
+
/**
|
|
38
|
+
* Every current deployment across every live network.
|
|
39
|
+
*
|
|
40
|
+
* Both exclusions are defaults rather than the caller's job on purpose: a
|
|
41
|
+
* retired network's addresses answer on a chain that was wiped, and a
|
|
42
|
+
* superseded deployment is one a later release replaced. Requiring each call
|
|
43
|
+
* site to remember that is how one of them forgets.
|
|
44
|
+
*/
|
|
45
|
+
export declare function listAll(books: Books, opts?: EnumerateOptions): Listed[];
|
|
46
|
+
/**
|
|
47
|
+
* Address -> deployment, for one network.
|
|
48
|
+
*
|
|
49
|
+
* Proxy implementations resolve to their proxy's identity so that a signer
|
|
50
|
+
* looking at an implementation address learns which proxy it serves. The
|
|
51
|
+
* proxy's own entry always wins: `set` runs for every deployment first, and
|
|
52
|
+
* an implementation only claims an address nothing has claimed already.
|
|
53
|
+
*/
|
|
54
|
+
export declare function buildIdentityIndex(books: Books, net: string): Map<string, Listed & {
|
|
55
|
+
matchedBy: "address" | "implementation";
|
|
56
|
+
}>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enumeration over the address books, with no generated data in sight.
|
|
3
|
+
*
|
|
4
|
+
* Split out for the same reason `decode-core.ts` is: the generated modules are
|
|
5
|
+
* a build product, so anything that imports them cannot be tested until they
|
|
6
|
+
* exist — and the filtering here is precisely what a dashboard relies on to
|
|
7
|
+
* not render a wiped testnet's addresses as current. Structural types rather
|
|
8
|
+
* than the package's public ones, so this file depends on nothing.
|
|
9
|
+
*/
|
|
10
|
+
/** One network's deployments, optionally one project's. Throws on an unknown slug. */
|
|
11
|
+
export function listContracts(books, net, project) {
|
|
12
|
+
const book = books[net];
|
|
13
|
+
if (!book)
|
|
14
|
+
throw new Error(`unknown network: ${net}`);
|
|
15
|
+
const out = [];
|
|
16
|
+
for (const [proj, entries] of Object.entries(book.contracts)) {
|
|
17
|
+
if (project !== undefined && proj !== project)
|
|
18
|
+
continue;
|
|
19
|
+
for (const [name, entry] of Object.entries(entries)) {
|
|
20
|
+
out.push({ network: net, project: proj, name, ...entry });
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return out;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Every current deployment across every live network.
|
|
27
|
+
*
|
|
28
|
+
* Both exclusions are defaults rather than the caller's job on purpose: a
|
|
29
|
+
* retired network's addresses answer on a chain that was wiped, and a
|
|
30
|
+
* superseded deployment is one a later release replaced. Requiring each call
|
|
31
|
+
* site to remember that is how one of them forgets.
|
|
32
|
+
*/
|
|
33
|
+
export function listAll(books, opts = {}) {
|
|
34
|
+
const out = [];
|
|
35
|
+
for (const net of Object.keys(books).sort()) {
|
|
36
|
+
if (!opts.includeRetiredNetworks && books[net].status !== "live")
|
|
37
|
+
continue;
|
|
38
|
+
for (const entry of listContracts(books, net, opts.project)) {
|
|
39
|
+
if (!opts.includeSuperseded && entry.status !== "active")
|
|
40
|
+
continue;
|
|
41
|
+
out.push(entry);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return out.sort((a, b) => a.network.localeCompare(b.network) ||
|
|
45
|
+
a.project.localeCompare(b.project) ||
|
|
46
|
+
a.name.localeCompare(b.name));
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Address -> deployment, for one network.
|
|
50
|
+
*
|
|
51
|
+
* Proxy implementations resolve to their proxy's identity so that a signer
|
|
52
|
+
* looking at an implementation address learns which proxy it serves. The
|
|
53
|
+
* proxy's own entry always wins: `set` runs for every deployment first, and
|
|
54
|
+
* an implementation only claims an address nothing has claimed already.
|
|
55
|
+
*/
|
|
56
|
+
export function buildIdentityIndex(books, net) {
|
|
57
|
+
const index = new Map();
|
|
58
|
+
const entries = listContracts(books, net);
|
|
59
|
+
for (const entry of entries) {
|
|
60
|
+
index.set(entry.address.toLowerCase(), { ...entry, matchedBy: "address" });
|
|
61
|
+
}
|
|
62
|
+
for (const entry of entries) {
|
|
63
|
+
if (!entry.implementation)
|
|
64
|
+
continue;
|
|
65
|
+
const key = entry.implementation.toLowerCase();
|
|
66
|
+
if (!index.has(key))
|
|
67
|
+
index.set(key, { ...entry, matchedBy: "implementation" });
|
|
68
|
+
}
|
|
69
|
+
return index;
|
|
70
|
+
}
|