@xyo-network/xl1-protocol-sdk 1.18.0-rc.1 → 1.18.1
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/neutral/CreatableProvider/AbstractCreatableProvider.d.ts +57 -25
- package/dist/neutral/CreatableProvider/AbstractCreatableProvider.d.ts.map +1 -1
- package/dist/neutral/CreatableProvider/CreatableProvider.d.ts +16 -11
- package/dist/neutral/CreatableProvider/CreatableProvider.d.ts.map +1 -1
- package/dist/neutral/CreatableProvider/CreatableProviderRegistry.d.ts +2 -4
- package/dist/neutral/CreatableProvider/CreatableProviderRegistry.d.ts.map +1 -1
- package/dist/neutral/CreatableProvider/ProviderFactory.d.ts +6 -4
- package/dist/neutral/CreatableProvider/ProviderFactory.d.ts.map +1 -1
- package/dist/neutral/CreatableProvider/ProviderFactoryLocator.d.ts +7 -7
- package/dist/neutral/CreatableProvider/ProviderFactoryLocator.d.ts.map +1 -1
- package/dist/neutral/CreatableProvider/ProviderFactoryLocatorInstance.d.ts +3 -2
- package/dist/neutral/CreatableProvider/ProviderFactoryLocatorInstance.d.ts.map +1 -1
- package/dist/neutral/actor/Actor.d.ts +176 -0
- package/dist/neutral/actor/Actor.d.ts.map +1 -0
- package/dist/neutral/actor/index.d.ts +2 -0
- package/dist/neutral/actor/index.d.ts.map +1 -0
- package/dist/neutral/block/hydrate/allHashesPresent.d.ts +2 -2
- package/dist/neutral/block/hydrate/allHashesPresent.d.ts.map +1 -1
- package/dist/neutral/block/hydrate/hydrateBlock.d.ts +2 -2
- package/dist/neutral/block/hydrate/hydrateBlock.d.ts.map +1 -1
- package/dist/neutral/config/Api.d.ts +1 -1
- package/dist/neutral/config/Api.d.ts.map +1 -1
- package/dist/neutral/config/Bridge.d.ts +41 -21
- package/dist/neutral/config/Bridge.d.ts.map +1 -1
- package/dist/neutral/config/Chain.d.ts +7 -3
- package/dist/neutral/config/Chain.d.ts.map +1 -1
- package/dist/neutral/config/Config.d.ts +50 -22
- package/dist/neutral/config/Config.d.ts.map +1 -1
- package/dist/neutral/config/Evm.d.ts +1 -1
- package/dist/neutral/config/Evm.d.ts.map +1 -1
- package/dist/neutral/config/Log.d.ts +2 -2
- package/dist/neutral/config/Log.d.ts.map +1 -1
- package/dist/neutral/config/Mempool.d.ts +1 -1
- package/dist/neutral/config/Mempool.d.ts.map +1 -1
- package/dist/neutral/config/Producer.d.ts +6 -2
- package/dist/neutral/config/Producer.d.ts.map +1 -1
- package/dist/neutral/config/RewardRedemptionApi.d.ts +1 -1
- package/dist/neutral/config/RewardRedemptionApi.d.ts.map +1 -1
- package/dist/neutral/config/Services.d.ts +3 -3
- package/dist/neutral/config/Services.d.ts.map +1 -1
- package/dist/neutral/config/Telemetry.d.ts +11 -4
- package/dist/neutral/config/Telemetry.d.ts.map +1 -1
- package/dist/neutral/config/UsageMeta.d.ts +1 -1
- package/dist/neutral/config/UsageMeta.d.ts.map +1 -1
- package/dist/neutral/config/Validation.d.ts +11 -3
- package/dist/neutral/config/Validation.d.ts.map +1 -1
- package/dist/neutral/config/index.d.ts +1 -0
- package/dist/neutral/config/index.d.ts.map +1 -1
- package/dist/neutral/config/storage/Storage.d.ts +1 -1
- package/dist/neutral/config/storage/Storage.d.ts.map +1 -1
- package/dist/neutral/config/storage/driver/Mongo.d.ts +1 -1
- package/dist/neutral/config/storage/driver/Mongo.d.ts.map +1 -1
- package/dist/neutral/eip-712/Payloads/EIP712Data.d.ts +4 -4
- package/dist/neutral/eip-712/Payloads/EIP712Data.d.ts.map +1 -1
- package/dist/neutral/eip-712/Payloads/EIP712Signature.d.ts +3 -3
- package/dist/neutral/eip-712/Payloads/EIP712Signature.d.ts.map +1 -1
- package/dist/neutral/eip-712/Types.d.ts +4 -4
- package/dist/neutral/eip-712/Types.d.ts.map +1 -1
- package/dist/neutral/index.d.ts +1 -0
- package/dist/neutral/index.d.ts.map +1 -1
- package/dist/neutral/index.mjs +3440 -3089
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/model/ChainQualification.d.ts +42 -0
- package/dist/neutral/model/ChainQualification.d.ts.map +1 -0
- package/dist/neutral/model/index.d.ts +1 -1
- package/dist/neutral/model/index.d.ts.map +1 -1
- package/dist/neutral/payloads/netBalancesForPayloads.d.ts +5 -2
- package/dist/neutral/payloads/netBalancesForPayloads.d.ts.map +1 -1
- package/dist/neutral/payloads/netSchemasForPayloads.d.ts +5 -2
- package/dist/neutral/payloads/netSchemasForPayloads.d.ts.map +1 -1
- package/dist/neutral/primitives/chain/getWindowedChain.d.ts +11 -0
- package/dist/neutral/primitives/chain/getWindowedChain.d.ts.map +1 -0
- package/dist/neutral/primitives/chain/index.d.ts +1 -0
- package/dist/neutral/primitives/chain/index.d.ts.map +1 -1
- package/dist/neutral/primitives/index.d.ts +1 -0
- package/dist/neutral/primitives/index.d.ts.map +1 -1
- package/dist/neutral/primitives/rewards/networkStakeStepRewardPositionWeight.d.ts +1 -1
- package/dist/neutral/primitives/rewards/networkStakeStepRewardPositionWeight.d.ts.map +1 -1
- package/dist/neutral/primitives/stake/weightedStakeForRangeByPosition.d.ts +2 -1
- package/dist/neutral/primitives/stake/weightedStakeForRangeByPosition.d.ts.map +1 -1
- package/dist/neutral/primitives/uncle/findBestUncle.d.ts +32 -0
- package/dist/neutral/primitives/uncle/findBestUncle.d.ts.map +1 -0
- package/dist/neutral/primitives/uncle/findUncles.d.ts +33 -0
- package/dist/neutral/primitives/uncle/findUncles.d.ts.map +1 -0
- package/dist/neutral/primitives/uncle/index.d.ts +4 -0
- package/dist/neutral/primitives/uncle/index.d.ts.map +1 -0
- package/dist/neutral/primitives/uncle/scoreUncle.d.ts +3 -0
- package/dist/neutral/primitives/uncle/scoreUncle.d.ts.map +1 -0
- package/dist/neutral/provider/signer/XyoSigner.d.ts +2 -0
- package/dist/neutral/provider/signer/XyoSigner.d.ts.map +1 -1
- package/dist/neutral/provider/viewer/XyoViewer.d.ts +7 -5
- package/dist/neutral/provider/viewer/XyoViewer.d.ts.map +1 -1
- package/dist/neutral/runners/Finalization.d.ts +12 -0
- package/dist/neutral/runners/Finalization.d.ts.map +1 -0
- package/dist/neutral/runners/index.d.ts +1 -0
- package/dist/neutral/runners/index.d.ts.map +1 -1
- package/dist/neutral/simple/accountBalance/SimpleAccountBalanceViewer.d.ts +96 -12
- package/dist/neutral/simple/accountBalance/SimpleAccountBalanceViewer.d.ts.map +1 -1
- package/dist/neutral/simple/block/SimpleBlockViewer.d.ts +9 -25
- package/dist/neutral/simple/block/SimpleBlockViewer.d.ts.map +1 -1
- package/dist/neutral/simple/blockReward/SimpleBlockRewardViewer.d.ts +1 -0
- package/dist/neutral/simple/blockReward/SimpleBlockRewardViewer.d.ts.map +1 -1
- package/dist/neutral/simple/blockValidation/SimpleBlockValidationViewer.d.ts +32 -0
- package/dist/neutral/simple/blockValidation/SimpleBlockValidationViewer.d.ts.map +1 -0
- package/dist/neutral/simple/blockValidation/index.d.ts +2 -0
- package/dist/neutral/simple/blockValidation/index.d.ts.map +1 -0
- package/dist/neutral/simple/chainStake/SimpleStakeViewer.d.ts +1 -0
- package/dist/neutral/simple/chainStake/SimpleStakeViewer.d.ts.map +1 -1
- package/dist/neutral/simple/datalake/AbstractSimpleDataLake.d.ts +1 -1
- package/dist/neutral/simple/datalake/AbstractSimpleDataLake.d.ts.map +1 -1
- package/dist/neutral/simple/datalake/SimpleDataLakeRunner.d.ts +1 -0
- package/dist/neutral/simple/datalake/SimpleDataLakeRunner.d.ts.map +1 -1
- package/dist/neutral/simple/datalake/SimpleDataLakeViewer.d.ts +1 -0
- package/dist/neutral/simple/datalake/SimpleDataLakeViewer.d.ts.map +1 -1
- package/dist/neutral/simple/finalization/SimpleFinalizationRunner.d.ts +21 -0
- package/dist/neutral/simple/finalization/SimpleFinalizationRunner.d.ts.map +1 -0
- package/dist/neutral/simple/finalization/SimpleFinalizationViewer.d.ts +61 -0
- package/dist/neutral/simple/finalization/SimpleFinalizationViewer.d.ts.map +1 -0
- package/dist/neutral/simple/finalization/index.d.ts +3 -0
- package/dist/neutral/simple/finalization/index.d.ts.map +1 -0
- package/dist/neutral/simple/index.d.ts +3 -0
- package/dist/neutral/simple/index.d.ts.map +1 -1
- package/dist/neutral/simple/mempool/SimpleMempoolRunner.d.ts +2 -0
- package/dist/neutral/simple/mempool/SimpleMempoolRunner.d.ts.map +1 -1
- package/dist/neutral/simple/mempool/SimpleMempoolViewer.d.ts +7 -2
- package/dist/neutral/simple/mempool/SimpleMempoolViewer.d.ts.map +1 -1
- package/dist/neutral/simple/runner/SimpleXyoRunner.d.ts +1 -0
- package/dist/neutral/simple/runner/SimpleXyoRunner.d.ts.map +1 -1
- package/dist/neutral/simple/signer/SimpleXyoSigner.d.ts +19 -3
- package/dist/neutral/simple/signer/SimpleXyoSigner.d.ts.map +1 -1
- package/dist/neutral/simple/stakeEvents/SimpleStakeEventsViewer.d.ts +1 -0
- package/dist/neutral/simple/stakeEvents/SimpleStakeEventsViewer.d.ts.map +1 -1
- package/dist/neutral/simple/timesync/SimpleTimeSyncViewer.d.ts +2 -1
- package/dist/neutral/simple/timesync/SimpleTimeSyncViewer.d.ts.map +1 -1
- package/dist/neutral/simple/windowedBlock/SimpleWindowedBlockViewer.d.ts +191 -0
- package/dist/neutral/simple/windowedBlock/SimpleWindowedBlockViewer.d.ts.map +1 -0
- package/dist/neutral/simple/windowedBlock/index.d.ts +2 -0
- package/dist/neutral/simple/windowedBlock/index.d.ts.map +1 -0
- package/dist/neutral/summary/model/summary.d.ts +3 -2
- package/dist/neutral/summary/model/summary.d.ts.map +1 -1
- package/dist/neutral/summary/primitives/balances/balancesSummary.d.ts +2 -2
- package/dist/neutral/summary/primitives/balances/balancesSummary.d.ts.map +1 -1
- package/dist/neutral/summary/primitives/schemas/schemasSummary.d.ts +2 -2
- package/dist/neutral/summary/primitives/schemas/schemasSummary.d.ts.map +1 -1
- package/dist/neutral/summary/primitives/transfers/transfersSummary.d.ts +3 -3
- package/dist/neutral/summary/primitives/transfers/transfersSummary.d.ts.map +1 -1
- package/dist/neutral/transaction/TransactionBuilder.d.ts +56 -33
- package/dist/neutral/transaction/TransactionBuilder.d.ts.map +1 -1
- package/dist/neutral/transaction/signTransaction.d.ts +24 -12
- package/dist/neutral/transaction/signTransaction.d.ts.map +1 -1
- package/dist/neutral/utils/isZodError.d.ts +1 -1
- package/dist/neutral/utils/isZodError.d.ts.map +1 -1
- package/dist/neutral/validation/schema/Mnemonic.d.ts +1 -1
- package/dist/neutral/validation/schema/Mnemonic.d.ts.map +1 -1
- package/dist/neutral/viewers/AccountBalance.d.ts +92 -44
- package/dist/neutral/viewers/AccountBalance.d.ts.map +1 -1
- package/dist/neutral/viewers/Block.d.ts +2 -2
- package/dist/neutral/viewers/Block.d.ts.map +1 -1
- package/dist/neutral/viewers/BlockValidation.d.ts +54 -0
- package/dist/neutral/viewers/BlockValidation.d.ts.map +1 -0
- package/dist/neutral/viewers/Finalization.d.ts +14 -0
- package/dist/neutral/viewers/Finalization.d.ts.map +1 -0
- package/dist/neutral/viewers/Mempool.d.ts +5 -5
- package/dist/neutral/viewers/Mempool.d.ts.map +1 -1
- package/dist/neutral/viewers/StakeIntent.d.ts +2 -2
- package/dist/neutral/viewers/StakeIntent.d.ts.map +1 -1
- package/dist/neutral/viewers/TransactionValidation.d.ts +35 -0
- package/dist/neutral/viewers/TransactionValidation.d.ts.map +1 -0
- package/dist/neutral/viewers/WindowedBlock.d.ts +14 -0
- package/dist/neutral/viewers/WindowedBlock.d.ts.map +1 -0
- package/dist/neutral/viewers/index.d.ts +4 -0
- package/dist/neutral/viewers/index.d.ts.map +1 -1
- package/package.json +25 -23
- package/src/CreatableProvider/AbstractCreatableProvider.ts +34 -12
- package/src/CreatableProvider/CreatableProvider.ts +24 -12
- package/src/CreatableProvider/CreatableProviderRegistry.ts +4 -3
- package/src/CreatableProvider/ProviderFactory.ts +21 -12
- package/src/CreatableProvider/ProviderFactoryLocator.ts +8 -6
- package/src/CreatableProvider/ProviderFactoryLocatorInstance.ts +6 -2
- package/src/actor/Actor.ts +209 -0
- package/src/actor/index.ts +1 -0
- package/src/block/hydrate/allHashesPresent.ts +2 -2
- package/src/block/hydrate/hydrateBlock.ts +2 -2
- package/src/config/Api.ts +1 -2
- package/src/config/Bridge.ts +1 -2
- package/src/config/Chain.ts +1 -2
- package/src/config/Config.ts +1 -1
- package/src/config/Evm.ts +1 -2
- package/src/config/Log.ts +1 -2
- package/src/config/Mempool.ts +1 -2
- package/src/config/Producer.ts +1 -2
- package/src/config/RewardRedemptionApi.ts +1 -2
- package/src/config/Services.ts +5 -4
- package/src/config/Telemetry.ts +10 -4
- package/src/config/UsageMeta.ts +1 -1
- package/src/config/Validation.ts +1 -2
- package/src/config/index.ts +1 -0
- package/src/config/storage/Storage.ts +1 -2
- package/src/config/storage/driver/Mongo.ts +1 -2
- package/src/eip-712/Payloads/EIP712Data.ts +1 -1
- package/src/eip-712/Payloads/EIP712Signature.ts +1 -1
- package/src/eip-712/Types.ts +1 -1
- package/src/index.ts +1 -0
- package/src/model/ChainQualification.ts +33 -0
- package/src/model/index.ts +1 -1
- package/src/primitives/chain/getWindowedChain.ts +42 -0
- package/src/primitives/chain/index.ts +1 -0
- package/src/primitives/index.ts +1 -0
- package/src/primitives/rewards/networkStakeStepRewardPositionWeight.ts +4 -3
- package/src/primitives/stake/allStakersForStep.ts +1 -1
- package/src/primitives/stake/weightedStakeForRangeByPosition.ts +10 -2
- package/src/primitives/uncle/findBestUncle.ts +8 -0
- package/src/primitives/uncle/findUncles.ts +75 -0
- package/src/primitives/uncle/index.ts +3 -0
- package/src/primitives/uncle/scoreUncle.ts +6 -0
- package/src/provider/signer/XyoSigner.ts +3 -0
- package/src/provider/viewer/XyoViewer.ts +7 -7
- package/src/runners/Finalization.ts +15 -0
- package/src/runners/index.ts +1 -0
- package/src/simple/accountBalance/SimpleAccountBalanceViewer.ts +47 -30
- package/src/simple/block/SimpleBlockViewer.ts +23 -37
- package/src/simple/blockReward/SimpleBlockRewardViewer.ts +1 -0
- package/src/simple/blockValidation/SimpleBlockValidationViewer.ts +129 -0
- package/src/simple/blockValidation/index.ts +1 -0
- package/src/simple/chainStake/SimpleStakeViewer.ts +1 -0
- package/src/simple/datalake/AbstractSimpleDataLake.ts +2 -1
- package/src/simple/datalake/SimpleDataLakeRunner.ts +1 -0
- package/src/simple/datalake/SimpleDataLakeViewer.ts +1 -1
- package/src/simple/finalization/SimpleFinalizationRunner.ts +45 -0
- package/src/simple/finalization/SimpleFinalizationViewer.ts +101 -0
- package/src/simple/finalization/index.ts +2 -0
- package/src/simple/index.ts +3 -0
- package/src/simple/mempool/SimpleMempoolRunner.ts +11 -1
- package/src/simple/mempool/SimpleMempoolViewer.ts +41 -8
- package/src/simple/runner/SimpleXyoRunner.ts +3 -1
- package/src/simple/signer/SimpleXyoSigner.ts +26 -5
- package/src/simple/stakeEvents/SimpleStakeEventsViewer.ts +1 -0
- package/src/simple/timesync/SimpleTimeSyncViewer.ts +4 -2
- package/src/simple/windowedBlock/SimpleWindowedBlockViewer.ts +208 -0
- package/src/simple/windowedBlock/index.ts +1 -0
- package/src/summary/model/summary.ts +3 -4
- package/src/summary/primitives/balances/balancesSummary.ts +12 -12
- package/src/summary/primitives/schemas/schemasSummary.ts +12 -10
- package/src/summary/primitives/transfers/transfersSummary.ts +15 -17
- package/src/utils/isZodError.ts +1 -1
- package/src/validation/schema/Mnemonic.ts +1 -1
- package/src/viewers/AccountBalance.ts +23 -15
- package/src/viewers/Block.ts +2 -2
- package/src/viewers/BlockValidation.ts +47 -0
- package/src/viewers/Finalization.ts +19 -0
- package/src/viewers/Mempool.ts +1 -1
- package/src/viewers/StakeIntent.ts +2 -2
- package/src/viewers/TransactionValidation.ts +35 -0
- package/src/viewers/WindowedBlock.ts +17 -0
- package/src/viewers/index.ts +4 -0
- package/dist/neutral/model/Qualified.d.ts +0 -6
- package/dist/neutral/model/Qualified.d.ts.map +0 -1
- package/src/model/Qualified.ts +0 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Mempool.d.ts","sourceRoot":"","sources":["../../../src/viewers/Mempool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,+BAA+B,EAAE,qCAAqC,EAAE,MAAM,2BAA2B,CAAA;AAEvH,OAAO,CAAC,MAAM,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"Mempool.d.ts","sourceRoot":"","sources":["../../../src/viewers/Mempool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,+BAA+B,EAAE,qCAAqC,EAAE,MAAM,2BAA2B,CAAA;AAEvH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAEjD,eAAO,MAAM,6BAA6B;;;;iBAIxC,CAAA;AAEF,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAA;AAEtF,eAAO,MAAM,uBAAuB;;;;iBAIlC,CAAA;AAEF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAA;AAE1E,MAAM,WAAW,oBAAoB;IACnC,aAAa,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,+BAA+B,EAAE,CAAC,CAAA;IACzF,mBAAmB,CAAC,OAAO,CAAC,EAAE,0BAA0B,GAAG,OAAO,CAAC,qCAAqC,EAAE,CAAC,CAAA;CAC5G;AAED,eAAO,MAAM,oBAAoB,EAAG,eAAwB,CAAA;AAC5D,MAAM,MAAM,oBAAoB,GAAG,OAAO,oBAAoB,CAAA;AAE9D,MAAM,WAAW,aAAc,SAAQ,oBAAoB,EAAE,QAAQ,CAAC,oBAAoB,CAAC;CAAG"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Address, Hash, Promisable } from '@xylabs/sdk-js';
|
|
2
2
|
import type { ChainStakeIntent, XL1BlockRange } from '@xyo-network/xl1-protocol';
|
|
3
|
-
import type {
|
|
3
|
+
import type { ChainQualified, Provider } from '../model/index.ts';
|
|
4
4
|
export interface StakeIntentViewerMethods {
|
|
5
|
-
qualifiedIntentByAddress(address: Address, headOrRange?: Hash | XL1BlockRange): Promisable<
|
|
5
|
+
qualifiedIntentByAddress(address: Address, headOrRange?: Hash | XL1BlockRange): Promisable<ChainQualified<ChainStakeIntent | null>>;
|
|
6
6
|
}
|
|
7
7
|
export declare const StakeIntentViewerMoniker: "StakeIntentViewer";
|
|
8
8
|
export type StakeIntentViewerMoniker = typeof StakeIntentViewerMoniker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StakeIntent.d.ts","sourceRoot":"","sources":["../../../src/viewers/StakeIntent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAAE,IAAI,EAAE,UAAU,EAC1B,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAEhF,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"StakeIntent.d.ts","sourceRoot":"","sources":["../../../src/viewers/StakeIntent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAAE,IAAI,EAAE,UAAU,EAC1B,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAEhF,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAEjE,MAAM,WAAW,wBAAwB;IACvC,wBAAwB,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE,IAAI,GAAG,aAAa,GAAG,UAAU,CAAC,cAAc,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC,CAAA;CACpI;AAED,eAAO,MAAM,wBAAwB,EAAG,mBAA4B,CAAA;AACpE,MAAM,MAAM,wBAAwB,GAAG,OAAO,wBAAwB,CAAA;AAEtE,MAAM,WAAW,iBAAkB,SAAQ,wBAAwB,EAAE,QAAQ,CAAC,wBAAwB,CAAC;IACrG,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE,IAAI,GAAG,aAAa,GAAG,UAAU,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAA;CAC3G"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type Promisable } from '@xylabs/sdk-js';
|
|
2
|
+
import { type HydratedTransaction, type ValidationError } from '@xyo-network/xl1-protocol';
|
|
3
|
+
import type { z } from 'zod';
|
|
4
|
+
import { type Provider } from '../model/index.ts';
|
|
5
|
+
export declare const TransactionValidationQualificationZod: z.ZodObject<{
|
|
6
|
+
head: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/sdk-js").BrandedHash, string>>;
|
|
7
|
+
range: z.ZodTuple<[z.ZodPipe<z.ZodNumber, z.ZodTransform<import("@xyo-network/xl1-protocol").XL1BlockNumber, number>>, z.ZodPipe<z.ZodNumber, z.ZodTransform<import("@xyo-network/xl1-protocol").XL1BlockNumber, number>>], null>;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
export type TransactionValidationQualification = z.infer<typeof TransactionValidationQualificationZod>;
|
|
10
|
+
export declare const isTransactionValidationQualification: <T>(value: T) => value is T & {
|
|
11
|
+
head: import("@xylabs/sdk-js").BrandedHash;
|
|
12
|
+
range: [import("@xyo-network/xl1-protocol").XL1BlockNumber, import("@xyo-network/xl1-protocol").XL1BlockNumber];
|
|
13
|
+
};
|
|
14
|
+
export declare const TransactionValidationConfigZod: z.ZodUnion<readonly [z.ZodObject<{
|
|
15
|
+
range: z.ZodTuple<[z.ZodPipe<z.ZodNumber, z.ZodTransform<import("@xyo-network/xl1-protocol").XL1BlockNumber, number>>, z.ZodPipe<z.ZodNumber, z.ZodTransform<import("@xyo-network/xl1-protocol").XL1BlockNumber, number>>], null>;
|
|
16
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
17
|
+
head: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/sdk-js").BrandedHash, string>>;
|
|
18
|
+
}, z.core.$strip>, z.ZodObject<{}, z.core.$strip>]>;
|
|
19
|
+
export type TransactionValidationConfig = z.infer<typeof TransactionValidationConfigZod>;
|
|
20
|
+
export declare const isTransactionValidationConfig: <T>(value: T) => value is T & ({
|
|
21
|
+
range: [import("@xyo-network/xl1-protocol").XL1BlockNumber, import("@xyo-network/xl1-protocol").XL1BlockNumber];
|
|
22
|
+
} | {
|
|
23
|
+
head: import("@xylabs/sdk-js").BrandedHash;
|
|
24
|
+
} | Record<string, never>);
|
|
25
|
+
export interface TransactionValidationViewerMethods {
|
|
26
|
+
qualifiedValidateTransactions(transactions: HydratedTransaction[], config?: TransactionValidationConfig): Promisable<[ValidationError[][], TransactionValidationQualification]>;
|
|
27
|
+
}
|
|
28
|
+
export declare const TransactionValidationViewerMoniker: "TransactionValidationViewer";
|
|
29
|
+
export type TransactionValidationViewerMoniker = typeof TransactionValidationViewerMoniker;
|
|
30
|
+
export interface TransactionValidationViewer extends TransactionValidationViewerMethods, Provider<TransactionValidationViewerMoniker> {
|
|
31
|
+
qualifiedValidateTransaction(transaction: HydratedTransaction, config?: TransactionValidationConfig): Promisable<[ValidationError[], TransactionValidationQualification]>;
|
|
32
|
+
validateTransaction(transaction: HydratedTransaction[], config?: TransactionValidationConfig): Promisable<ValidationError[]>;
|
|
33
|
+
validateTransactions(transactions: HydratedTransaction[], config?: TransactionValidationConfig): Promisable<ValidationError[][]>;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=TransactionValidation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransactionValidation.d.ts","sourceRoot":"","sources":["../../../src/viewers/TransactionValidation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEhD,OAAO,EAAE,KAAK,mBAAmB,EAAE,KAAK,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC1F,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAE5B,OAAO,EAC2C,KAAK,QAAQ,EAC9D,MAAM,mBAAmB,CAAA;AAE1B,eAAO,MAAM,qCAAqC;;;iBAAwB,CAAA;AAC1E,MAAM,MAAM,kCAAkC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qCAAqC,CAAC,CAAA;AACtG,eAAO,MAAM,oCAAoC;;;CAAsD,CAAA;AAEvG,eAAO,MAAM,8BAA8B;;;;mDAA0B,CAAA;AACrE,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAA;AACxF,eAAO,MAAM,6BAA6B;;;;0BAA+C,CAAA;AAEzF,MAAM,WAAW,kCAAkC;IACjD,6BAA6B,CAC3B,YAAY,EAAE,mBAAmB,EAAE,EACnC,MAAM,CAAC,EAAE,2BAA2B,GACnC,UAAU,CAAC,CAAC,eAAe,EAAE,EAAE,EAAE,kCAAkC,CAAC,CAAC,CAAA;CACzE;AAED,eAAO,MAAM,kCAAkC,EAAG,6BAAsC,CAAA;AACxF,MAAM,MAAM,kCAAkC,GAAG,OAAO,kCAAkC,CAAA;AAE1F,MAAM,WAAW,2BAA4B,SAAQ,kCAAkC,EAAE,QAAQ,CAAC,kCAAkC,CAAC;IACnI,4BAA4B,CAC1B,WAAW,EAAE,mBAAmB,EAChC,MAAM,CAAC,EAAE,2BAA2B,GACnC,UAAU,CAAC,CAAC,eAAe,EAAE,EAAE,kCAAkC,CAAC,CAAC,CAAA;IACtE,mBAAmB,CAAC,WAAW,EAAE,mBAAmB,EAAE,EAAE,MAAM,CAAC,EAAE,2BAA2B,GAAG,UAAU,CAAC,eAAe,EAAE,CAAC,CAAA;IAC5H,oBAAoB,CAAC,YAAY,EAAE,mBAAmB,EAAE,EAAE,MAAM,CAAC,EAAE,2BAA2B,GAAG,UAAU,CAAC,eAAe,EAAE,EAAE,CAAC,CAAA;CACjI"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Hash } from '@xylabs/hex';
|
|
2
|
+
import type { Promisable } from '@xylabs/sdk-js';
|
|
3
|
+
import type { HydratedBlockWithHashMeta } from '@xyo-network/xl1-protocol';
|
|
4
|
+
import type { Provider, ProviderMoniker } from '../model/index.ts';
|
|
5
|
+
import type { BlockViewerMethods } from './Block.ts';
|
|
6
|
+
export interface WindowedBlockViewerMethods extends BlockViewerMethods {
|
|
7
|
+
blocksByTransactionHashes(hashes: Hash[]): Promisable<HydratedBlockWithHashMeta[]>;
|
|
8
|
+
}
|
|
9
|
+
export declare const WindowedBlockViewerMoniker: "WindowedBlockViewer";
|
|
10
|
+
export type WindowedBlockViewerMoniker = typeof WindowedBlockViewerMoniker;
|
|
11
|
+
export interface WindowedBlockViewer<TMoniker extends ProviderMoniker = WindowedBlockViewerMoniker> extends WindowedBlockViewerMethods, Provider<TMoniker> {
|
|
12
|
+
blockByTransactionHash(hash: Hash): Promisable<HydratedBlockWithHashMeta | null>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=WindowedBlock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WindowedBlock.d.ts","sourceRoot":"","sources":["../../../src/viewers/WindowedBlock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAA;AAE1E,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEpD,MAAM,WAAW,0BAA2B,SAAQ,kBAAkB;IACpE,yBAAyB,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,UAAU,CAAC,yBAAyB,EAAE,CAAC,CAAA;CACnF;AAED,eAAO,MAAM,0BAA0B,EAAG,qBAA8B,CAAA;AACxE,MAAM,MAAM,0BAA0B,GAAG,OAAO,0BAA0B,CAAA;AAE1E,MAAM,WAAW,mBAAmB,CAAC,QAAQ,SAAS,eAAe,GAAG,0BAA0B,CAAE,SAAQ,0BAA0B,EAAE,QAAQ,CAAC,QAAQ,CAAC;IACxJ,sBAAsB,CAAC,IAAI,EAAE,IAAI,GAAG,UAAU,CAAC,yBAAyB,GAAG,IAAI,CAAC,CAAA;CACjF"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export * from './AccountBalance.ts';
|
|
2
2
|
export * from './Block.ts';
|
|
3
3
|
export * from './BlockReward.ts';
|
|
4
|
+
export * from './BlockValidation.ts';
|
|
4
5
|
export * from './ChainContract.ts';
|
|
5
6
|
export * from './ChainStakeViewer.ts';
|
|
7
|
+
export * from './Finalization.ts';
|
|
6
8
|
export * from './Fork.ts';
|
|
7
9
|
export * from './Mempool.ts';
|
|
8
10
|
export * from './NetworkStakeStepReward.ts';
|
|
@@ -13,5 +15,7 @@ export * from './StepStake.ts';
|
|
|
13
15
|
export * from './StepViewer.ts';
|
|
14
16
|
export * from './TimeSync.ts';
|
|
15
17
|
export * from './Transaction.ts';
|
|
18
|
+
export * from './TransactionValidation.ts';
|
|
16
19
|
export * from './TransferBalance.ts';
|
|
20
|
+
export * from './WindowedBlock.ts';
|
|
17
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/viewers/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,uBAAuB,CAAA;AACrC,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA;AAC5B,cAAc,6BAA6B,CAAA;AAC3C,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,kBAAkB,CAAA;AAChC,cAAc,sBAAsB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/viewers/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,cAAc,sBAAsB,CAAA;AACpC,cAAc,oBAAoB,CAAA;AAClC,cAAc,uBAAuB,CAAA;AACrC,cAAc,mBAAmB,CAAA;AACjC,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA;AAC5B,cAAc,6BAA6B,CAAA;AAC3C,cAAc,YAAY,CAAA;AAC1B,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,kBAAkB,CAAA;AAChC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,sBAAsB,CAAA;AACpC,cAAc,oBAAoB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@xyo-network/xl1-protocol-sdk",
|
|
4
|
-
"version": "1.18.
|
|
4
|
+
"version": "1.18.1",
|
|
5
5
|
"description": "XYO Layer One SDK Protocol",
|
|
6
6
|
"homepage": "https://xylabs.com",
|
|
7
7
|
"bugs": {
|
|
@@ -40,36 +40,39 @@
|
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@opentelemetry/api": "^1.9.0",
|
|
43
|
-
"@xylabs/hex": "~5.0.
|
|
44
|
-
"@xylabs/sdk-js": "~5.0.
|
|
45
|
-
"@
|
|
46
|
-
"@xyo-network/account
|
|
47
|
-
"@xyo-network/
|
|
48
|
-
"@xyo-network/
|
|
49
|
-
"@xyo-network/boundwitness-
|
|
50
|
-
"@xyo-network/
|
|
51
|
-
"@xyo-network/payload-
|
|
52
|
-
"@xyo-network/
|
|
53
|
-
"@xyo-network/wallet
|
|
54
|
-
"@xyo-network/
|
|
43
|
+
"@xylabs/hex": "~5.0.61",
|
|
44
|
+
"@xylabs/sdk-js": "~5.0.61",
|
|
45
|
+
"@xylabs/zod": "~5.0.61",
|
|
46
|
+
"@xyo-network/account": "~5.2.19",
|
|
47
|
+
"@xyo-network/account-model": "~5.2.19",
|
|
48
|
+
"@xyo-network/archivist-model": "~5.2.19",
|
|
49
|
+
"@xyo-network/boundwitness-builder": "~5.2.19",
|
|
50
|
+
"@xyo-network/boundwitness-model": "~5.2.19",
|
|
51
|
+
"@xyo-network/payload-builder": "~5.2.19",
|
|
52
|
+
"@xyo-network/payload-model": "~5.2.19",
|
|
53
|
+
"@xyo-network/wallet": "~5.2.19",
|
|
54
|
+
"@xyo-network/wallet-model": "~5.2.19",
|
|
55
|
+
"@xyo-network/xl1-protocol": "~1.18.1",
|
|
55
56
|
"async-mutex": "~0.5.0",
|
|
56
57
|
"ethers": "^6.16.0",
|
|
57
58
|
"lru-cache": "^11.2.4",
|
|
58
|
-
"zod": "~4.1
|
|
59
|
+
"zod": "~4.2.1"
|
|
59
60
|
},
|
|
60
61
|
"devDependencies": {
|
|
61
|
-
"@types/node": "~25.0.
|
|
62
|
-
"@xylabs/events": "~5.0.
|
|
62
|
+
"@types/node": "~25.0.3",
|
|
63
|
+
"@xylabs/events": "~5.0.61",
|
|
63
64
|
"@xylabs/ts-scripts-yarn3": "~7.2.32",
|
|
64
65
|
"@xylabs/tsconfig": "~7.2.32",
|
|
65
|
-
"@xylabs/vitest-extended": "~5.0.
|
|
66
|
-
"@xyo-network/account": "~5.2.
|
|
67
|
-
"@xyo-network/archivist-
|
|
68
|
-
"@xyo-network/
|
|
66
|
+
"@xylabs/vitest-extended": "~5.0.61",
|
|
67
|
+
"@xyo-network/account": "~5.2.19",
|
|
68
|
+
"@xyo-network/archivist-memory": "~5.2.19",
|
|
69
|
+
"@xyo-network/archivist-mongodb": "~5.2.19",
|
|
70
|
+
"@xyo-network/boundwitness-validator": "~5.2.19",
|
|
69
71
|
"axios": "^1.13.2",
|
|
70
72
|
"eslint": "^9.39.2",
|
|
73
|
+
"tslib": "^2.8.1",
|
|
71
74
|
"typescript": "~5.9.3",
|
|
72
|
-
"vitest": "~4.0.
|
|
75
|
+
"vitest": "~4.0.16"
|
|
73
76
|
},
|
|
74
77
|
"peerDependencies": {
|
|
75
78
|
"axios": "^1.13.2"
|
|
@@ -80,6 +83,5 @@
|
|
|
80
83
|
"engineStrict": true,
|
|
81
84
|
"publishConfig": {
|
|
82
85
|
"access": "public"
|
|
83
|
-
}
|
|
84
|
-
"stableVersion": "1.17.7"
|
|
86
|
+
}
|
|
85
87
|
}
|
|
@@ -3,32 +3,38 @@ import { AbstractCreatable, assertEx } from '@xylabs/sdk-js'
|
|
|
3
3
|
import type { Provider, ProviderMoniker } from '../model/index.ts'
|
|
4
4
|
import type {
|
|
5
5
|
CreatableProvider,
|
|
6
|
-
CreatableProviderEventData,
|
|
6
|
+
CreatableProviderEventData, CreatableProviderInstance, CreatableProviderParams,
|
|
7
|
+
ProviderMap,
|
|
7
8
|
} from './CreatableProvider.ts'
|
|
8
9
|
import { ProviderFactory } from './ProviderFactory.ts'
|
|
9
10
|
|
|
10
11
|
export abstract class AbstractCreatableProvider<TParams extends CreatableProviderParams = CreatableProviderParams,
|
|
11
12
|
TEventData extends CreatableProviderEventData = CreatableProviderEventData> extends AbstractCreatable<TParams, TEventData>
|
|
12
13
|
implements Omit<CreatableProviderInstance, 'moniker'> {
|
|
14
|
+
dependencies: ProviderMap = {}
|
|
15
|
+
|
|
13
16
|
protected _contextCache: TParams['context'] | undefined
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
abstract readonly moniker: ProviderMoniker
|
|
19
|
+
|
|
20
|
+
protected get config() {
|
|
21
|
+
return this.context.config!
|
|
17
22
|
}
|
|
18
23
|
|
|
19
|
-
get context() {
|
|
20
|
-
return
|
|
24
|
+
protected get context() {
|
|
25
|
+
return this.params.context!
|
|
21
26
|
}
|
|
22
27
|
|
|
23
|
-
get locator() {
|
|
24
|
-
return
|
|
28
|
+
protected get locator() {
|
|
29
|
+
return this.context.locator!
|
|
25
30
|
}
|
|
26
31
|
|
|
27
|
-
static factory<
|
|
28
|
-
this: CreatableProvider<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
static factory<TInstance extends CreatableProviderInstance, TDependencies extends ProviderMoniker[] = ProviderMoniker[]>(
|
|
33
|
+
this: CreatableProvider<TInstance>,
|
|
34
|
+
dependencies: TDependencies,
|
|
35
|
+
params?: Partial<TInstance['params']>,
|
|
36
|
+
) {
|
|
37
|
+
const factory = ProviderFactory.withParams<TInstance, TDependencies>(this, dependencies, params)
|
|
32
38
|
return factory
|
|
33
39
|
}
|
|
34
40
|
|
|
@@ -40,6 +46,22 @@ export abstract class AbstractCreatableProvider<TParams extends CreatableProvide
|
|
|
40
46
|
return instance
|
|
41
47
|
}
|
|
42
48
|
|
|
49
|
+
static override async paramsHandler<T extends CreatableProviderInstance>(
|
|
50
|
+
params: Partial<T['params']> = {},
|
|
51
|
+
) {
|
|
52
|
+
const context = assertEx(params.context, () => new Error('Context is required'))
|
|
53
|
+
const config = assertEx(context.config, () => new Error('Context config is required'))
|
|
54
|
+
const locator = assertEx(context.locator, () => new Error('Context locator is required'))
|
|
55
|
+
return await super.paramsHandler<T>({
|
|
56
|
+
...params,
|
|
57
|
+
statusReporter: params.statusReporter ?? context.statusReporter,
|
|
58
|
+
context: {
|
|
59
|
+
...context, config, locator,
|
|
60
|
+
},
|
|
61
|
+
name: params.name ?? (this as unknown as CreatableProvider<T>).defaultMoniker,
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
|
|
43
65
|
static async tryGetInstance<T extends CreatableProviderInstance>(
|
|
44
66
|
this: CreatableProvider<T>,
|
|
45
67
|
inParams: T['params'],
|
|
@@ -27,18 +27,25 @@ export interface CreatableProviderParams<TContext extends CreatableProviderConte
|
|
|
27
27
|
}
|
|
28
28
|
export interface CreatableProviderEventData extends EventData {}
|
|
29
29
|
|
|
30
|
-
export type CreatableProviderInstance<
|
|
30
|
+
export type CreatableProviderInstance<
|
|
31
|
+
TProvider extends Provider<ProviderMoniker> = Provider<ProviderMoniker>,
|
|
32
|
+
TDependencies extends ProviderMoniker[] = ProviderMoniker[],
|
|
31
33
|
TParams extends CreatableProviderParams = CreatableProviderParams,
|
|
32
34
|
TEventData extends CreatableProviderEventData = CreatableProviderEventData>
|
|
33
|
-
= CreatableInstance<TParams, TEventData> & TProvider
|
|
35
|
+
= CreatableInstance<TParams, TEventData> & TProvider & {
|
|
36
|
+
dependencies: ProviderMap<TDependencies[number]>
|
|
37
|
+
}
|
|
34
38
|
|
|
35
39
|
export type ProviderFactoryScope = 'global' | 'context' | 'local'
|
|
36
40
|
|
|
37
|
-
export interface CreatableProviderFactory<T extends CreatableProviderInstance = CreatableProviderInstance
|
|
41
|
+
export interface CreatableProviderFactory<T extends CreatableProviderInstance = CreatableProviderInstance,
|
|
42
|
+
TDependencies extends ProviderMoniker[] = ProviderMoniker[]>
|
|
38
43
|
extends Omit<CreatableProvider<T>, 'create' | 'createHandler' | 'paramsHandler'> {
|
|
39
44
|
creatableProvider: CreatableProvider<T>
|
|
40
45
|
defaultParams?: Partial<T['params']>
|
|
41
46
|
|
|
47
|
+
readonly dependencies: TDependencies
|
|
48
|
+
|
|
42
49
|
labels?: Labels
|
|
43
50
|
resolvedMoniker: string
|
|
44
51
|
scope: ProviderFactoryScope
|
|
@@ -46,26 +53,31 @@ export interface CreatableProviderFactory<T extends CreatableProviderInstance =
|
|
|
46
53
|
/** @deprecated use getInstance instead */
|
|
47
54
|
create(
|
|
48
55
|
this: CreatableProviderFactory<T>,
|
|
49
|
-
params?: Partial<T['params']>, start?: boolean): Promise<T>
|
|
56
|
+
params?: Partial<T['params'] & CreatableProviderParams>, start?: boolean): Promise<T>
|
|
50
57
|
|
|
51
58
|
getInstance(
|
|
52
59
|
this: CreatableProviderFactory<T>,
|
|
53
|
-
params: T['params'], start?: boolean): Promise<T>
|
|
60
|
+
params: T['params'] & CreatableProviderParams, start?: boolean): Promise<T>
|
|
54
61
|
|
|
55
62
|
tryGetInstance(
|
|
56
63
|
this: CreatableProviderFactory<T>,
|
|
57
|
-
params: T['params'], start?: boolean): Promise<T | undefined>
|
|
64
|
+
params: T['params'] & CreatableProviderParams, start?: boolean): Promise<T | undefined>
|
|
58
65
|
|
|
59
66
|
}
|
|
60
67
|
|
|
61
|
-
export interface LabeledCreatableProvider<T extends CreatableProviderInstance = CreatableProviderInstance
|
|
62
|
-
|
|
68
|
+
export interface LabeledCreatableProvider<T extends CreatableProviderInstance = CreatableProviderInstance,
|
|
69
|
+
TDependencies extends ProviderMoniker[] = ProviderMoniker[]> extends CreatableProvider<T>, WithOptionalLabels {
|
|
70
|
+
factory(dependencies: TDependencies, params?: Partial<T['params'] & CreatableProviderParams>): LabeledCreatableProviderFactory<T>
|
|
63
71
|
}
|
|
64
72
|
|
|
65
|
-
export
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
73
|
+
export type ProviderMap<T extends ProviderMoniker = ProviderMoniker> = Partial<Record<T, CreatableProviderInstance<Provider<T>>>>
|
|
74
|
+
|
|
75
|
+
export interface CreatableProvider<T extends CreatableProviderInstance = CreatableProviderInstance,
|
|
76
|
+
TDependencies extends ProviderMoniker[] = ProviderMoniker[]> extends Creatable<T> {
|
|
77
|
+
readonly defaultMoniker: ProviderMoniker
|
|
78
|
+
readonly dependencies: TDependencies
|
|
79
|
+
readonly monikers: ProviderMoniker[]
|
|
80
|
+
factory(dependencies: TDependencies, params?: Partial<T['params'] & CreatableProviderParams>): CreatableProviderFactory<T>
|
|
69
81
|
}
|
|
70
82
|
|
|
71
83
|
/**
|
|
@@ -5,9 +5,8 @@ import type { ProviderMoniker } from '../model/index.ts'
|
|
|
5
5
|
import type { CreatableProviderFactory, CreatableProviderInstance } from './CreatableProvider.ts'
|
|
6
6
|
import type { LabeledCreatableProviderFactory } from './LabeledCreatableProviderFactory.ts'
|
|
7
7
|
|
|
8
|
-
export
|
|
9
|
-
[
|
|
10
|
-
}
|
|
8
|
+
export type CreatableProviderRegistry<TMonikers extends ProviderMoniker[] = ProviderMoniker[]>
|
|
9
|
+
= Record<TMonikers[number], (CreatableProviderFactory | LabeledCreatableProviderFactory)[] | undefined>
|
|
11
10
|
|
|
12
11
|
const buildProviderFactory = <TProvider extends CreatableProviderInstance>(
|
|
13
12
|
provider: CreatableProviderFactory<TProvider>,
|
|
@@ -16,11 +15,13 @@ const buildProviderFactory = <TProvider extends CreatableProviderInstance>(
|
|
|
16
15
|
const factory = {
|
|
17
16
|
monikers: provider.monikers,
|
|
18
17
|
// Copy static methods
|
|
18
|
+
// eslint-disable-next-line sonarjs/deprecation
|
|
19
19
|
create: provider.create.bind(provider) as LabeledCreatableProviderFactory<TProvider>['create'],
|
|
20
20
|
|
|
21
21
|
// Merge module & supplied labels
|
|
22
22
|
labels: { ...(provider as LabeledCreatableProviderFactory).labels, ...labels },
|
|
23
23
|
creatableProvider: provider.creatableProvider,
|
|
24
|
+
dependencies: provider.dependencies,
|
|
24
25
|
resolvedMoniker: provider.resolvedMoniker,
|
|
25
26
|
scope: provider.scope,
|
|
26
27
|
getInstance: provider.getInstance.bind(provider) as LabeledCreatableProviderFactory<TProvider>['getInstance'],
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Labels, WithOptionalLabels } from '@xylabs/sdk-js'
|
|
2
2
|
import { assertEx } from '@xylabs/sdk-js'
|
|
3
3
|
|
|
4
|
+
import type { ProviderMoniker } from '../model/index.ts'
|
|
4
5
|
import type {
|
|
5
6
|
CreatableProvider, CreatableProviderFactory, CreatableProviderInstance,
|
|
6
7
|
ProviderFactoryScope,
|
|
@@ -10,13 +11,16 @@ declare global {
|
|
|
10
11
|
var xyoServiceSingletons: Record<string, unknown>
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
export class ProviderFactory<TProvider extends CreatableProviderInstance
|
|
14
|
+
export class ProviderFactory<TProvider extends CreatableProviderInstance,
|
|
15
|
+
TDependencies extends ProviderMoniker[]> implements CreatableProviderFactory<TProvider> {
|
|
14
16
|
creatableProvider: CreatableProvider<TProvider>
|
|
15
17
|
|
|
16
18
|
defaultMoniker: CreatableProvider<TProvider>['monikers'][number]
|
|
17
19
|
|
|
18
20
|
defaultParams?: Partial<TProvider['params']>
|
|
19
21
|
|
|
22
|
+
dependencies: TDependencies
|
|
23
|
+
|
|
20
24
|
labels?: Labels
|
|
21
25
|
|
|
22
26
|
monikers: CreatableProvider<TProvider>['monikers']
|
|
@@ -25,6 +29,7 @@ export class ProviderFactory<TProvider extends CreatableProviderInstance> implem
|
|
|
25
29
|
|
|
26
30
|
constructor(
|
|
27
31
|
creatableProvider: CreatableProvider<TProvider>,
|
|
32
|
+
dependencies: TDependencies,
|
|
28
33
|
params?: Partial<TProvider['params']>,
|
|
29
34
|
labels: Labels = {},
|
|
30
35
|
scope: ProviderFactoryScope = 'context',
|
|
@@ -32,6 +37,7 @@ export class ProviderFactory<TProvider extends CreatableProviderInstance> implem
|
|
|
32
37
|
this.creatableProvider = creatableProvider
|
|
33
38
|
this.defaultParams = params
|
|
34
39
|
this.defaultMoniker = creatableProvider.defaultMoniker
|
|
40
|
+
this.dependencies = dependencies
|
|
35
41
|
this.monikers = creatableProvider.monikers
|
|
36
42
|
this.scope = scope
|
|
37
43
|
assertEx(this.monikers.includes(this.defaultMoniker), () => 'defaultMoniker must be in monikers')
|
|
@@ -44,12 +50,13 @@ export class ProviderFactory<TProvider extends CreatableProviderInstance> implem
|
|
|
44
50
|
return labelString.length === 0 ? `${this.defaultMoniker}` : `${this.defaultMoniker}|${labelString}`
|
|
45
51
|
}
|
|
46
52
|
|
|
47
|
-
static withParams<
|
|
48
|
-
creatableProvider: CreatableProvider<
|
|
49
|
-
|
|
53
|
+
static withParams<TInstance extends CreatableProviderInstance, TDependencies extends ProviderMoniker[]>(
|
|
54
|
+
creatableProvider: CreatableProvider<TInstance>,
|
|
55
|
+
dependencies: TDependencies,
|
|
56
|
+
params?: Partial<TInstance['params']>,
|
|
50
57
|
labels: Labels = {},
|
|
51
58
|
) {
|
|
52
|
-
return new ProviderFactory<
|
|
59
|
+
return new ProviderFactory<TInstance, TDependencies>(creatableProvider, dependencies, params, labels)
|
|
53
60
|
}
|
|
54
61
|
|
|
55
62
|
/** @deprecated use getInstance instead */
|
|
@@ -57,12 +64,13 @@ export class ProviderFactory<TProvider extends CreatableProviderInstance> implem
|
|
|
57
64
|
return await this.getInstance(params as TProvider['params'], start)
|
|
58
65
|
}
|
|
59
66
|
|
|
60
|
-
factory<
|
|
61
|
-
this: CreatableProviderFactory<
|
|
62
|
-
|
|
67
|
+
factory<TInstance extends CreatableProviderInstance, TDependencies extends ProviderMoniker[]>(
|
|
68
|
+
this: CreatableProviderFactory<TInstance, TDependencies>,
|
|
69
|
+
dependencies: TDependencies,
|
|
70
|
+
params?: Partial<TInstance['params']>,
|
|
63
71
|
labels: Labels = {},
|
|
64
|
-
)
|
|
65
|
-
return new ProviderFactory<
|
|
72
|
+
) {
|
|
73
|
+
return new ProviderFactory<TInstance, TDependencies>(this.creatableProvider, dependencies, params, labels)
|
|
66
74
|
}
|
|
67
75
|
|
|
68
76
|
async getInstance(this: CreatableProviderFactory<TProvider>, params: TProvider['params'], start = true): Promise<TProvider> {
|
|
@@ -103,11 +111,12 @@ export class ProviderFactory<TProvider extends CreatableProviderInstance> implem
|
|
|
103
111
|
},
|
|
104
112
|
},
|
|
105
113
|
} as TProvider['params']
|
|
106
|
-
const
|
|
114
|
+
const resultPromise = scopeObject[this.resolvedMoniker] as Promise<TProvider> ?? this.creatableProvider.create<TProvider>(mergedParams)
|
|
115
|
+
scopeObject[this.resolvedMoniker] = resultPromise
|
|
116
|
+
const result = await resultPromise
|
|
107
117
|
if (start) {
|
|
108
118
|
assertEx(await result.start(), () => 'Failed to start provider instance')
|
|
109
119
|
}
|
|
110
|
-
scopeObject[this.resolvedMoniker] = result
|
|
111
120
|
return result
|
|
112
121
|
}
|
|
113
122
|
|
|
@@ -12,15 +12,16 @@ import type { ProviderFactoryLocatorInstance } from './ProviderFactoryLocatorIns
|
|
|
12
12
|
/**
|
|
13
13
|
* A class which encapsulates the Service Locator Pattern for Provider Factories
|
|
14
14
|
*/
|
|
15
|
-
export class ProviderFactoryLocator
|
|
16
|
-
|
|
17
|
-
protected readonly
|
|
15
|
+
export class ProviderFactoryLocator<TContext extends CreatableProviderContext = CreatableProviderContext,
|
|
16
|
+
TMonikers extends ProviderMoniker[] = ProviderMoniker[]> implements ProviderFactoryLocatorInstance<TContext> {
|
|
17
|
+
protected readonly _context: TContext
|
|
18
|
+
protected readonly _registry: CreatableProviderRegistry<TMonikers>
|
|
18
19
|
|
|
19
20
|
private _frozen = false
|
|
20
21
|
|
|
21
|
-
constructor(context: Omit<
|
|
22
|
+
constructor(context: Omit<TContext, 'locator'>, registry: CreatableProviderRegistry = {}) {
|
|
22
23
|
this._registry = registry
|
|
23
|
-
this._context = { ...context, locator: this }
|
|
24
|
+
this._context = { ...context, locator: this } as unknown as TContext
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
get context() {
|
|
@@ -68,7 +69,8 @@ export class ProviderFactoryLocator implements ProviderFactoryLocatorInstance {
|
|
|
68
69
|
} as CreatableProviderInstance<TProvider>['params']['context'],
|
|
69
70
|
} as CreatableProviderInstance<TProvider>['params']
|
|
70
71
|
const factory = this.locate<TProvider>(moniker, labels)
|
|
71
|
-
|
|
72
|
+
const result = await factory.getInstance(resolvedParams)
|
|
73
|
+
return result
|
|
72
74
|
}
|
|
73
75
|
|
|
74
76
|
/**
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import type { Labels } from '@xylabs/sdk-js'
|
|
2
2
|
|
|
3
3
|
import type { Provider, ProviderMoniker } from '../model/index.ts'
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
CreatableProviderContext, CreatableProviderFactory, CreatableProviderInstance,
|
|
6
|
+
} from './CreatableProvider.ts'
|
|
5
7
|
import type { CreatableProviderRegistry } from './CreatableProviderRegistry.ts'
|
|
6
8
|
import type { LabeledCreatableProviderFactory } from './LabeledCreatableProviderFactory.ts'
|
|
7
9
|
|
|
8
|
-
export interface ProviderFactoryLocatorInstance {
|
|
10
|
+
export interface ProviderFactoryLocatorInstance<T extends CreatableProviderContext = CreatableProviderContext> {
|
|
11
|
+
|
|
12
|
+
context: T
|
|
9
13
|
|
|
10
14
|
/**
|
|
11
15
|
* The current registry for the module factory
|