@xyo-network/xl1-protocol-sdk 1.26.12 → 1.26.13
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/simple/accountBalance/SimpleAccountBalanceViewer.d.ts +2 -2
- package/dist/neutral/simple/block/SimpleBlockViewer.d.ts +2 -2
- package/dist/neutral/simple/datalake/SimpleDataLakeRunner.d.ts +1 -1
- package/dist/neutral/simple/finalization/SimpleFinalizationViewer.d.ts +1 -1
- package/dist/neutral/simple/windowedBlock/SimpleWindowedBlockViewer.d.ts +10 -10
- package/dist/neutral/transaction/TransactionBuilder.d.ts +4 -4
- package/dist/neutral/transaction/signTransaction.d.ts +1 -1
- package/package.json +24 -14
- package/src/ChainContextHelpers.ts +0 -50
- package/src/CreatableProvider/AbstractCreatableProvider.ts +0 -97
- package/src/CreatableProvider/CreatableProvider.ts +0 -102
- package/src/CreatableProvider/CreatableProviderRegistry.ts +0 -94
- package/src/CreatableProvider/GetInstanceOptions.ts +0 -11
- package/src/CreatableProvider/LabeledCreatableProviderFactory.ts +0 -24
- package/src/CreatableProvider/ProviderFactory.ts +0 -138
- package/src/CreatableProvider/ProviderFactoryLocator.ts +0 -170
- package/src/CreatableProvider/ProviderFactoryLocatorInstance.ts +0 -70
- package/src/CreatableProvider/index.ts +0 -8
- package/src/SignedBigInt.ts +0 -59
- package/src/_internal/context/getTestProviderContext.ts +0 -13
- package/src/_internal/context/index.ts +0 -1
- package/src/_internal/index.ts +0 -2
- package/src/actor/ActorV3.ts +0 -177
- package/src/actor/index.ts +0 -1
- package/src/amount/ShiftedBigInt.ts +0 -73
- package/src/amount/XL1Amount.ts +0 -103
- package/src/amount/index.ts +0 -4
- package/src/amount/splitOnDecimal.ts +0 -6
- package/src/amount/splitOnDecimalToString.ts +0 -40
- package/src/block/hydrate/allHashesPresent.ts +0 -8
- package/src/block/hydrate/blockPayloadsFromHydratedBlock.ts +0 -12
- package/src/block/hydrate/flattenHydratedBlock.ts +0 -28
- package/src/block/hydrate/flattenHydratedBlocks.ts +0 -7
- package/src/block/hydrate/hydrateBlock.ts +0 -43
- package/src/block/hydrate/index.ts +0 -7
- package/src/block/hydrate/transactionsFromHydratedBlock.ts +0 -7
- package/src/block/hydrate/tryHydrateBlock.ts +0 -26
- package/src/block/index.ts +0 -2
- package/src/block/primitives/blockFromBlockNumber.ts +0 -69
- package/src/block/primitives/frames/calculateFramesFromRange.ts +0 -30
- package/src/block/primitives/frames/deepCalculateFramesFromRange.ts +0 -28
- package/src/block/primitives/frames/index.ts +0 -2
- package/src/block/primitives/hashFromBlockNumber.ts +0 -9
- package/src/block/primitives/index.ts +0 -7
- package/src/block/primitives/model.ts +0 -18
- package/src/block/primitives/payloads/ChainWindow.ts +0 -7
- package/src/block/primitives/payloads/index.ts +0 -1
- package/src/block/primitives/toStepIdentityString.ts +0 -6
- package/src/block/primitives/validateTransactionOpcodes.ts +0 -45
- package/src/config/Actor.ts +0 -32
- package/src/config/Actors.ts +0 -9
- package/src/config/Base.ts +0 -27
- package/src/config/Chain.ts +0 -23
- package/src/config/Config.ts +0 -24
- package/src/config/DataLake/DataLake.ts +0 -12
- package/src/config/DataLake/DataLakeRemoteConfig.ts +0 -11
- package/src/config/DataLake/RestDataLakeConfig.ts +0 -18
- package/src/config/DataLake/RouterDataLakeConfig.ts +0 -22
- package/src/config/DataLake/index.ts +0 -4
- package/src/config/DeepPartial.ts +0 -4
- package/src/config/Evm.ts +0 -38
- package/src/config/HostActor.ts +0 -32
- package/src/config/Log.ts +0 -25
- package/src/config/Provider.ts +0 -20
- package/src/config/Providers.ts +0 -9
- package/src/config/Remote.ts +0 -59
- package/src/config/Telemetry.ts +0 -49
- package/src/config/UsageMeta.ts +0 -46
- package/src/config/Validation.ts +0 -29
- package/src/config/index.ts +0 -12
- package/src/config/storage/Storage.ts +0 -16
- package/src/config/storage/driver/Mongo.ts +0 -53
- package/src/config/storage/driver/index.ts +0 -1
- package/src/config/storage/index.ts +0 -2
- package/src/constants.ts +0 -4
- package/src/context/Actor.ts +0 -20
- package/src/context/HostActor.ts +0 -20
- package/src/context/getEmptyProviderContext.ts +0 -19
- package/src/context/index.ts +0 -3
- package/src/createDeclarationPayload.ts +0 -15
- package/src/createTransferPayload.ts +0 -16
- package/src/driver/cache/LruCacheMap.ts +0 -48
- package/src/driver/cache/index.ts +0 -1
- package/src/driver/index.ts +0 -2
- package/src/driver/memory/MemoryMap.ts +0 -48
- package/src/driver/memory/index.ts +0 -1
- package/src/eip-712/Payloads/EIP712Data.ts +0 -35
- package/src/eip-712/Payloads/EIP712Signature.ts +0 -32
- package/src/eip-712/Payloads/index.ts +0 -2
- package/src/eip-712/Types.ts +0 -41
- package/src/eip-712/index.ts +0 -4
- package/src/eip-712/sign.ts +0 -19
- package/src/eip-712/spec/fixtures.ts +0 -27
- package/src/eip-712/verify.ts +0 -20
- package/src/getFileConfig.ts +0 -36
- package/src/index.ts +0 -27
- package/src/instances/Address.ts +0 -16
- package/src/instances/BoundWitness.ts +0 -13
- package/src/instances/Data.ts +0 -4
- package/src/instances/Fees.ts +0 -9
- package/src/instances/HydratedBoundWitness.ts +0 -16
- package/src/instances/Object.ts +0 -6
- package/src/instances/Payload.ts +0 -7
- package/src/instances/Signature.ts +0 -12
- package/src/instances/block/BlockFields.ts +0 -18
- package/src/instances/block/HydratedBlock.ts +0 -10
- package/src/instances/block/index.ts +0 -1
- package/src/instances/index.ts +0 -10
- package/src/instances/modifiers/BlockWindowInstance.ts +0 -8
- package/src/instances/modifiers/BlockWindowState.ts +0 -6
- package/src/instances/modifiers/Signed.ts +0 -9
- package/src/instances/modifiers/Validatable.ts +0 -6
- package/src/instances/modifiers/index.ts +0 -4
- package/src/instances/transaction/HydratedTransaction.ts +0 -9
- package/src/instances/transaction/TransactionFields.ts +0 -22
- package/src/instances/transaction/index.ts +0 -1
- package/src/isInternetAvailable.ts +0 -11
- package/src/model/ChainFork/ChainForkStatic.ts +0 -9
- package/src/model/ChainFork/index.ts +0 -1
- package/src/model/ChainIdentity.ts +0 -6
- package/src/model/ChainStore.ts +0 -16
- package/src/model/CreatableProviderContext.ts +0 -6
- package/src/model/CreatableProviderContext.zod.ts +0 -55
- package/src/model/PayloadBundle/bundledPayloadToHydratedBlock.ts +0 -15
- package/src/model/PayloadBundle/bundledPayloadToHydratedTransaction.ts +0 -15
- package/src/model/PayloadBundle/hydratedBlockToPayloadBundle.ts +0 -19
- package/src/model/PayloadBundle/hydratedTransactionToPayloadBundle.ts +0 -19
- package/src/model/PayloadBundle/index.ts +0 -4
- package/src/model/index.ts +0 -6
- package/src/multipliers.ts +0 -18
- package/src/payloads/AddressPairPayload.ts +0 -27
- package/src/payloads/index.ts +0 -4
- package/src/payloads/netBalancesForPayloads.ts +0 -24
- package/src/payloads/netSchemasForPayloads.ts +0 -24
- package/src/payloads/netTransfersForPayloads.ts +0 -27
- package/src/primitives/block/index.ts +0 -2
- package/src/primitives/block/range/blockRangeSteps.ts +0 -23
- package/src/primitives/block/range/index.ts +0 -1
- package/src/primitives/block/rate/blockRate.ts +0 -77
- package/src/primitives/block/rate/index.ts +0 -4
- package/src/primitives/block/rate/stepRate.ts +0 -37
- package/src/primitives/block/rate/timeHelpers.ts +0 -61
- package/src/primitives/block/rate/timeRate.ts +0 -121
- package/src/primitives/chain/getWindowedChain.ts +0 -50
- package/src/primitives/chain/index.ts +0 -3
- package/src/primitives/chain/step/chainStepRewardAddress.ts +0 -30
- package/src/primitives/chain/step/index.ts +0 -4
- package/src/primitives/chain/step/stepRewardBlock.ts +0 -13
- package/src/primitives/chain/step/stepRewardTotal.ts +0 -46
- package/src/primitives/chain/step/stepsRewardTotal.ts +0 -37
- package/src/primitives/chain/time/externalBlockNumberFromXL1BlockNumber.ts +0 -32
- package/src/primitives/chain/time/externalBlockRangeFromStep.ts +0 -21
- package/src/primitives/chain/time/externalBlockRangeFromXL1BlockRange.ts +0 -17
- package/src/primitives/chain/time/index.ts +0 -3
- package/src/primitives/datalake/addDataLakePayloads.ts +0 -18
- package/src/primitives/datalake/addDataLakePayloadsToPayloads.ts +0 -24
- package/src/primitives/datalake/index.ts +0 -2
- package/src/primitives/index.ts +0 -13
- package/src/primitives/mapToMapType.ts +0 -35
- package/src/primitives/payload/index.ts +0 -1
- package/src/primitives/payload/mergeTransfers.ts +0 -16
- package/src/primitives/readPayloadMapFromStore.ts +0 -58
- package/src/primitives/rewardFromBlockNumber.ts +0 -19
- package/src/primitives/rewards/index.ts +0 -1
- package/src/primitives/rewards/networkStakeStepRewardPositionWeight.ts +0 -26
- package/src/primitives/stake/activeStakeAtTimeByAddress.ts +0 -27
- package/src/primitives/stake/activeStakeAtTimeByPosition.ts +0 -25
- package/src/primitives/stake/allStakersForRange.ts +0 -32
- package/src/primitives/stake/allStakersForStep.ts +0 -24
- package/src/primitives/stake/index.ts +0 -6
- package/src/primitives/stake/mergedAddRemoveStakeEventsByPosition.ts +0 -15
- package/src/primitives/stake/mergedAddRemoveStakeEventsByStaker.ts +0 -17
- package/src/primitives/stake/weightedStakeForRangeByPosition.ts +0 -69
- package/src/primitives/state/findMostRecentBlock.ts +0 -44
- package/src/primitives/state/hydratedBlockByNumber.ts +0 -25
- package/src/primitives/state/index.ts +0 -2
- package/src/primitives/step/completedStepRewardAddress.ts +0 -10
- package/src/primitives/step/derivedReceiveAddress.ts +0 -9
- package/src/primitives/step/index.ts +0 -4
- package/src/primitives/step/stepBlockRange.ts +0 -9
- package/src/primitives/step/stepTransferIndex.ts +0 -19
- package/src/primitives/transaction/elevatedPayloads.ts +0 -24
- package/src/primitives/transaction/index.ts +0 -1
- package/src/primitives/uncle/findBestUncle.ts +0 -9
- package/src/primitives/uncle/findUncles.ts +0 -75
- package/src/primitives/uncle/index.ts +0 -3
- package/src/primitives/uncle/scoreUncle.ts +0 -7
- package/src/services/AccountTransfersService.ts +0 -13
- package/src/services/BlockProducerService.ts +0 -11
- package/src/services/Chain/BaseChainService.ts +0 -4
- package/src/services/Chain/ChainHeadService.ts +0 -8
- package/src/services/Chain/ChainService.ts +0 -6
- package/src/services/Chain/index.ts +0 -3
- package/src/services/Election.ts +0 -14
- package/src/services/NetworkStakeService.ts +0 -4
- package/src/services/Params.ts +0 -13
- package/src/services/PendingTransactionsService.ts +0 -7
- package/src/services/SchemasService.ts +0 -11
- package/src/services/StakeIntentService/ChainIndexingServiceStateSchema.ts +0 -50
- package/src/services/StakeIntentService/StakeIntentService.ts +0 -35
- package/src/services/StakeIntentService/index.ts +0 -2
- package/src/services/index.ts +0 -8
- package/src/simple/StakeEventsViewer/SimpleStakeEventsViewer.ts +0 -93
- package/src/simple/StakeEventsViewer/index.ts +0 -1
- package/src/simple/StakeTotalsViewer/SimpleStakeTotalsViewer.ts +0 -116
- package/src/simple/StakeTotalsViewer/index.ts +0 -1
- package/src/simple/StakeViewer/SimpleStakeViewer.ts +0 -164
- package/src/simple/StakeViewer/index.ts +0 -1
- package/src/simple/TransactionViewer/SimpleTransactionViewer.ts +0 -100
- package/src/simple/TransactionViewer/index.ts +0 -1
- package/src/simple/accountBalance/SimpleAccountBalanceViewer.ts +0 -271
- package/src/simple/accountBalance/index.ts +0 -1
- package/src/simple/block/SimpleBlockViewer.ts +0 -231
- package/src/simple/block/index.ts +0 -1
- package/src/simple/blockInvalidation/SimpleBlockInvalidationViewer.ts +0 -197
- package/src/simple/blockInvalidation/index.ts +0 -1
- package/src/simple/blockReward/SimpleBlockRewardViewer.ts +0 -27
- package/src/simple/blockReward/index.ts +0 -1
- package/src/simple/blockValidation/SimpleBlockValidationViewer.ts +0 -194
- package/src/simple/blockValidation/index.ts +0 -1
- package/src/simple/chainContractViewer/SimpleChainContractViewer.ts +0 -92
- package/src/simple/chainContractViewer/index.ts +0 -1
- package/src/simple/client/SimpleXyoClient.ts +0 -14
- package/src/simple/client/index.ts +0 -1
- package/src/simple/datalake/AbstractRestDataLake.ts +0 -70
- package/src/simple/datalake/AbstractSimpleDataLake.ts +0 -62
- package/src/simple/datalake/RestDataLakeRunner.ts +0 -54
- package/src/simple/datalake/RestDataLakeViewer.ts +0 -22
- package/src/simple/datalake/SimpleDataLakeRunner.ts +0 -44
- package/src/simple/datalake/SimpleDataLakeViewer.ts +0 -24
- package/src/simple/datalake/index.ts +0 -4
- package/src/simple/finalization/SimpleFinalizationRunner.ts +0 -45
- package/src/simple/finalization/SimpleFinalizationViewer.ts +0 -123
- package/src/simple/finalization/index.ts +0 -2
- package/src/simple/gateway/SimpleXyoGateway.ts +0 -30
- package/src/simple/gateway/SimpleXyoGatewayRunner.ts +0 -137
- package/src/simple/gateway/index.ts +0 -2
- package/src/simple/index.ts +0 -22
- package/src/simple/mempool/SimpleMempoolRunner.ts +0 -390
- package/src/simple/mempool/SimpleMempoolViewer.ts +0 -215
- package/src/simple/mempool/index.ts +0 -2
- package/src/simple/network/SimpleXyoNetwork.ts +0 -48
- package/src/simple/network/index.ts +0 -1
- package/src/simple/network/lib/FailedNetworkStatusPayloads.ts +0 -16
- package/src/simple/network/lib/StatusNetworks.ts +0 -32
- package/src/simple/network/lib/index.ts +0 -2
- package/src/simple/permissions/SimpleXyoPermissions.ts +0 -82
- package/src/simple/permissions/index.ts +0 -2
- package/src/simple/permissions/store/MemoryPermissions.ts +0 -32
- package/src/simple/permissions/store/PermissionsStore.ts +0 -17
- package/src/simple/permissions/store/index.ts +0 -2
- package/src/simple/runner/SimpleXyoRunner.ts +0 -41
- package/src/simple/runner/index.ts +0 -1
- package/src/simple/signer/SimpleXyoSigner.ts +0 -78
- package/src/simple/signer/index.ts +0 -1
- package/src/simple/timeSync2/SimpleTimeSyncViewer.ts +0 -132
- package/src/simple/timeSync2/index.ts +0 -1
- package/src/simple/transactionInvalidation/SimpleTransactionInvalidationViewer.ts +0 -197
- package/src/simple/transactionInvalidation/index.ts +0 -1
- package/src/simple/transactionValidation/SimpleTransactionValidationViewer.ts +0 -173
- package/src/simple/transactionValidation/index.ts +0 -1
- package/src/simple/windowedBlock/SimpleWindowedBlockViewer.ts +0 -207
- package/src/simple/windowedBlock/index.ts +0 -1
- package/src/status/RuntimeStatusMonitor.ts +0 -120
- package/src/status/ServiceStatus.ts +0 -21
- package/src/status/index.ts +0 -2
- package/src/summary/index.ts +0 -2
- package/src/summary/model/BalancesStepSummary.ts +0 -35
- package/src/summary/model/SchemasStepSummary.ts +0 -33
- package/src/summary/model/StepSummary.ts +0 -20
- package/src/summary/model/TransfersSummary.ts +0 -36
- package/src/summary/model/index.ts +0 -4
- package/src/summary/primitives/balances/balancesStepSummaryFromRange.ts +0 -94
- package/src/summary/primitives/balances/balancesSummary.ts +0 -48
- package/src/summary/primitives/balances/index.ts +0 -2
- package/src/summary/primitives/index.ts +0 -3
- package/src/summary/primitives/schemas/index.ts +0 -2
- package/src/summary/primitives/schemas/schemasStepSummaryFromRange.ts +0 -86
- package/src/summary/primitives/schemas/schemasSummary.ts +0 -44
- package/src/summary/primitives/transfers/index.ts +0 -2
- package/src/summary/primitives/transfers/transfersStepSummaryFromRange.ts +0 -109
- package/src/summary/primitives/transfers/transfersSummary.ts +0 -52
- package/src/test/BuildBlockOptions.ts +0 -81
- package/src/test/buildBlock.ts +0 -105
- package/src/test/buildGenesisBlock.ts +0 -29
- package/src/test/buildNextBlock.ts +0 -37
- package/src/test/buildRandomChain.ts +0 -92
- package/src/test/buildRandomGenesisBlock.ts +0 -47
- package/src/test/createGenesisBlock.ts +0 -41
- package/src/test/createProducerChainStakeIntentTransaction.ts +0 -48
- package/src/test/getSimpleBlockViewerLocator.ts +0 -41
- package/src/test/getTestProviderContext.ts +0 -8
- package/src/test/index.ts +0 -2
- package/src/time/index.ts +0 -1
- package/src/time/primitives/index.ts +0 -1
- package/src/time/primitives/xl1BlockNumberToEthBlockNumber.ts +0 -13
- package/src/transaction/TransactionBuilder.ts +0 -164
- package/src/transaction/buildRandomTransaction.ts +0 -38
- package/src/transaction/buildTransaction.ts +0 -68
- package/src/transaction/buildUnsignedTransaction.ts +0 -56
- package/src/transaction/confirmSubmittedTransaction.ts +0 -42
- package/src/transaction/hydrateTransaction.ts +0 -117
- package/src/transaction/index.ts +0 -9
- package/src/transaction/primitives/index.ts +0 -4
- package/src/transaction/primitives/transactionBlockByteCount.ts +0 -10
- package/src/transaction/primitives/transactionElevatedPayloads.ts +0 -18
- package/src/transaction/primitives/transactionOperations.ts +0 -13
- package/src/transaction/primitives/transactionRequiredGas.ts +0 -22
- package/src/transaction/script.ts +0 -48
- package/src/transaction/signTransaction.ts +0 -32
- package/src/utils/HydratedCache.ts +0 -39
- package/src/utils/index.ts +0 -2
- package/src/utils/isZodError.ts +0 -11
- package/src/validation/index.ts +0 -2
- package/src/validation/lib/getUrl.ts +0 -7
- package/src/validation/lib/index.ts +0 -2
- package/src/validation/lib/isLocalhost.ts +0 -9
- package/src/validation/schema/Address.ts +0 -2
- package/src/validation/schema/Mnemonic.ts +0 -21
- package/src/validation/schema/index.ts +0 -2
- package/src/wallet/generateXyoBaseWalletFromPhrase.ts +0 -13
- package/src/wallet/index.ts +0 -2
- package/src/wallet/paths.ts +0 -17
|
@@ -48,7 +48,7 @@ export declare class SimpleAccountBalanceViewer extends AbstractCreatableProvide
|
|
|
48
48
|
readonly __address: true;
|
|
49
49
|
})[];
|
|
50
50
|
payload_hashes: import("@xylabs/sdk-js").BrandedHash[];
|
|
51
|
-
payload_schemas: import("@xyo-network/
|
|
51
|
+
payload_schemas: import("@xyo-network/sdk-js").BrandedSchema<string>[];
|
|
52
52
|
previous_hashes: (import("@xylabs/sdk-js").BrandedHash | null)[];
|
|
53
53
|
$signatures: (import("@xylabs/sdk-js").BrandedHex | null)[];
|
|
54
54
|
_hash: import("@xylabs/sdk-js").BrandedHash;
|
|
@@ -71,7 +71,7 @@ export declare class SimpleAccountBalanceViewer extends AbstractCreatableProvide
|
|
|
71
71
|
readonly __address: true;
|
|
72
72
|
})[];
|
|
73
73
|
payload_hashes: import("@xylabs/sdk-js").BrandedHash[];
|
|
74
|
-
payload_schemas: import("@xyo-network/
|
|
74
|
+
payload_schemas: import("@xyo-network/sdk-js").BrandedSchema<string>[];
|
|
75
75
|
previous_hashes: (import("@xylabs/sdk-js").BrandedHash | null)[];
|
|
76
76
|
$signatures: (import("@xylabs/sdk-js").BrandedHex | null)[];
|
|
77
77
|
nbf: XL1BlockNumber;
|
|
@@ -30,7 +30,7 @@ export declare class SimpleBlockViewer extends AbstractCreatableProvider<SimpleB
|
|
|
30
30
|
readonly __address: true;
|
|
31
31
|
})[];
|
|
32
32
|
payload_hashes: import("@xylabs/sdk-js").BrandedHash[];
|
|
33
|
-
payload_schemas: import("@xyo-network/
|
|
33
|
+
payload_schemas: import("@xyo-network/sdk-js").BrandedSchema<string>[];
|
|
34
34
|
previous_hashes: (import("@xylabs/sdk-js").BrandedHash | null)[];
|
|
35
35
|
$signatures: import("@xylabs/sdk-js").BrandedHex[];
|
|
36
36
|
block: XL1BlockNumber;
|
|
@@ -49,7 +49,7 @@ export declare class SimpleBlockViewer extends AbstractCreatableProvider<SimpleB
|
|
|
49
49
|
step_hashes?: import("@xylabs/sdk-js").BrandedHash[] | undefined;
|
|
50
50
|
}, {
|
|
51
51
|
[x: string]: unknown;
|
|
52
|
-
schema: import("@xyo-network/
|
|
52
|
+
schema: import("@xyo-network/sdk-js").BrandedSchema<string>;
|
|
53
53
|
_hash: import("@xylabs/sdk-js").BrandedHash;
|
|
54
54
|
_dataHash: import("@xylabs/sdk-js").BrandedHash;
|
|
55
55
|
}[]], () => void>;
|
|
@@ -12,7 +12,7 @@ export declare class SimpleDataLakeRunner<TParams extends SimpleDataLakeRunnerPa
|
|
|
12
12
|
static readonly monikers: "DataLakeRunner"[];
|
|
13
13
|
moniker: "DataLakeRunner";
|
|
14
14
|
clear(): Promise<void>;
|
|
15
|
-
delete(hashes: Hash[]): Promise<NonNullable<import("@xyo-network/
|
|
15
|
+
delete(hashes: Hash[]): Promise<NonNullable<import("@xyo-network/sdk-js").Payload | ArrayBuffer>[]>;
|
|
16
16
|
insert(items: DataLakeData[]): Promise<(DataLakeData & {
|
|
17
17
|
[x: string]: unknown;
|
|
18
18
|
schema: import("@xyo-network/sdk-js").BrandedSchema<string>;
|
|
@@ -47,7 +47,7 @@ export declare class SimpleFinalizationViewer extends AbstractCreatableProvider<
|
|
|
47
47
|
readonly __address: true;
|
|
48
48
|
})[];
|
|
49
49
|
payload_hashes: import("@xylabs/sdk-js").BrandedHash[];
|
|
50
|
-
payload_schemas: import("@xyo-network/
|
|
50
|
+
payload_schemas: import("@xyo-network/sdk-js").BrandedSchema<string>[];
|
|
51
51
|
previous_hashes: (import("@xylabs/sdk-js").BrandedHash | null)[];
|
|
52
52
|
$signatures: import("@xylabs/sdk-js").BrandedHex[];
|
|
53
53
|
block: XL1BlockNumber;
|
|
@@ -34,7 +34,7 @@ export declare class SimpleWindowedBlockViewer extends AbstractCreatableProvider
|
|
|
34
34
|
readonly __address: true;
|
|
35
35
|
})[];
|
|
36
36
|
payload_hashes: import("@xylabs/sdk-js").BrandedHash[];
|
|
37
|
-
payload_schemas: import("@xyo-network/
|
|
37
|
+
payload_schemas: import("@xyo-network/sdk-js").BrandedSchema<string>[];
|
|
38
38
|
previous_hashes: (import("@xylabs/sdk-js").BrandedHash | null)[];
|
|
39
39
|
$signatures: import("@xylabs/sdk-js").BrandedHex[];
|
|
40
40
|
block: XL1BlockNumber;
|
|
@@ -53,7 +53,7 @@ export declare class SimpleWindowedBlockViewer extends AbstractCreatableProvider
|
|
|
53
53
|
step_hashes?: import("@xylabs/sdk-js").BrandedHash[] | undefined;
|
|
54
54
|
}, {
|
|
55
55
|
[x: string]: unknown;
|
|
56
|
-
schema: import("@xyo-network/
|
|
56
|
+
schema: import("@xyo-network/sdk-js").BrandedSchema<string>;
|
|
57
57
|
_hash: import("@xylabs/sdk-js").BrandedHash;
|
|
58
58
|
_dataHash: import("@xylabs/sdk-js").BrandedHash;
|
|
59
59
|
}[]] | null;
|
|
@@ -67,7 +67,7 @@ export declare class SimpleWindowedBlockViewer extends AbstractCreatableProvider
|
|
|
67
67
|
readonly __address: true;
|
|
68
68
|
})[];
|
|
69
69
|
payload_hashes: import("@xylabs/sdk-js").BrandedHash[];
|
|
70
|
-
payload_schemas: import("@xyo-network/
|
|
70
|
+
payload_schemas: import("@xyo-network/sdk-js").BrandedSchema<string>[];
|
|
71
71
|
previous_hashes: (import("@xylabs/sdk-js").BrandedHash | null)[];
|
|
72
72
|
$signatures: import("@xylabs/sdk-js").BrandedHex[];
|
|
73
73
|
block: XL1BlockNumber;
|
|
@@ -86,7 +86,7 @@ export declare class SimpleWindowedBlockViewer extends AbstractCreatableProvider
|
|
|
86
86
|
step_hashes?: import("@xylabs/sdk-js").BrandedHash[] | undefined;
|
|
87
87
|
}, {
|
|
88
88
|
[x: string]: unknown;
|
|
89
|
-
schema: import("@xyo-network/
|
|
89
|
+
schema: import("@xyo-network/sdk-js").BrandedSchema<string>;
|
|
90
90
|
_hash: import("@xylabs/sdk-js").BrandedHash;
|
|
91
91
|
_dataHash: import("@xylabs/sdk-js").BrandedHash;
|
|
92
92
|
}[]] | null;
|
|
@@ -104,7 +104,7 @@ export declare class SimpleWindowedBlockViewer extends AbstractCreatableProvider
|
|
|
104
104
|
readonly __address: true;
|
|
105
105
|
})[];
|
|
106
106
|
payload_hashes: import("@xylabs/sdk-js").BrandedHash[];
|
|
107
|
-
payload_schemas: import("@xyo-network/
|
|
107
|
+
payload_schemas: import("@xyo-network/sdk-js").BrandedSchema<string>[];
|
|
108
108
|
previous_hashes: (import("@xylabs/sdk-js").BrandedHash | null)[];
|
|
109
109
|
$signatures: (import("@xylabs/sdk-js").BrandedHex | null)[];
|
|
110
110
|
_hash: import("@xylabs/sdk-js").BrandedHash;
|
|
@@ -119,7 +119,7 @@ export declare class SimpleWindowedBlockViewer extends AbstractCreatableProvider
|
|
|
119
119
|
$sourceQuery?: import("@xylabs/sdk-js").BrandedHash | undefined;
|
|
120
120
|
}, {
|
|
121
121
|
[x: string]: unknown;
|
|
122
|
-
schema: import("@xyo-network/
|
|
122
|
+
schema: import("@xyo-network/sdk-js").BrandedSchema<string>;
|
|
123
123
|
_hash: import("@xylabs/sdk-js").BrandedHash;
|
|
124
124
|
_dataHash: import("@xylabs/sdk-js").BrandedHash;
|
|
125
125
|
}[]] | null>;
|
|
@@ -133,7 +133,7 @@ export declare class SimpleWindowedBlockViewer extends AbstractCreatableProvider
|
|
|
133
133
|
readonly __address: true;
|
|
134
134
|
})[];
|
|
135
135
|
payload_hashes: import("@xylabs/sdk-js").BrandedHash[];
|
|
136
|
-
payload_schemas: import("@xyo-network/
|
|
136
|
+
payload_schemas: import("@xyo-network/sdk-js").BrandedSchema<string>[];
|
|
137
137
|
previous_hashes: (import("@xylabs/sdk-js").BrandedHash | null)[];
|
|
138
138
|
$signatures: import("@xylabs/sdk-js").BrandedHex[];
|
|
139
139
|
block: XL1BlockNumber;
|
|
@@ -152,7 +152,7 @@ export declare class SimpleWindowedBlockViewer extends AbstractCreatableProvider
|
|
|
152
152
|
step_hashes?: import("@xylabs/sdk-js").BrandedHash[] | undefined;
|
|
153
153
|
}, {
|
|
154
154
|
[x: string]: unknown;
|
|
155
|
-
schema: import("@xyo-network/
|
|
155
|
+
schema: import("@xyo-network/sdk-js").BrandedSchema<string>;
|
|
156
156
|
_hash: import("@xylabs/sdk-js").BrandedHash;
|
|
157
157
|
_dataHash: import("@xylabs/sdk-js").BrandedHash;
|
|
158
158
|
}[]][];
|
|
@@ -166,7 +166,7 @@ export declare class SimpleWindowedBlockViewer extends AbstractCreatableProvider
|
|
|
166
166
|
readonly __address: true;
|
|
167
167
|
})[];
|
|
168
168
|
payload_hashes: import("@xylabs/sdk-js").BrandedHash[];
|
|
169
|
-
payload_schemas: import("@xyo-network/
|
|
169
|
+
payload_schemas: import("@xyo-network/sdk-js").BrandedSchema<string>[];
|
|
170
170
|
previous_hashes: (import("@xylabs/sdk-js").BrandedHash | null)[];
|
|
171
171
|
$signatures: import("@xylabs/sdk-js").BrandedHex[];
|
|
172
172
|
block: XL1BlockNumber;
|
|
@@ -185,7 +185,7 @@ export declare class SimpleWindowedBlockViewer extends AbstractCreatableProvider
|
|
|
185
185
|
step_hashes?: import("@xylabs/sdk-js").BrandedHash[] | undefined;
|
|
186
186
|
}, {
|
|
187
187
|
[x: string]: unknown;
|
|
188
|
-
schema: import("@xyo-network/
|
|
188
|
+
schema: import("@xyo-network/sdk-js").BrandedSchema<string>;
|
|
189
189
|
_hash: import("@xylabs/sdk-js").BrandedHash;
|
|
190
190
|
_dataHash: import("@xylabs/sdk-js").BrandedHash;
|
|
191
191
|
}[]][];
|
|
@@ -20,7 +20,7 @@ export declare class TransactionBuilder<TPayload extends Payload> extends Base<O
|
|
|
20
20
|
readonly __address: true;
|
|
21
21
|
})[];
|
|
22
22
|
payload_hashes: import("@xylabs/sdk-js").BrandedHash[];
|
|
23
|
-
payload_schemas: import("@xyo-network/
|
|
23
|
+
payload_schemas: import("@xyo-network/sdk-js").BrandedSchema<string>[];
|
|
24
24
|
previous_hashes: (import("@xylabs/sdk-js").BrandedHash | null)[];
|
|
25
25
|
$signatures: import("@xylabs/sdk-js").BrandedHex[];
|
|
26
26
|
nbf: import("@xyo-network/xl1-protocol-lib").XL1BlockNumber;
|
|
@@ -48,7 +48,7 @@ export declare class TransactionBuilder<TPayload extends Payload> extends Base<O
|
|
|
48
48
|
script?: string[] | undefined;
|
|
49
49
|
}, {
|
|
50
50
|
[x: string]: unknown;
|
|
51
|
-
schema: import("@xyo-network/
|
|
51
|
+
schema: import("@xyo-network/sdk-js").BrandedSchema<string>;
|
|
52
52
|
_hash: import("@xylabs/sdk-js").BrandedHash;
|
|
53
53
|
_dataHash: import("@xylabs/sdk-js").BrandedHash;
|
|
54
54
|
}[]]>;
|
|
@@ -63,7 +63,7 @@ export declare class TransactionBuilder<TPayload extends Payload> extends Base<O
|
|
|
63
63
|
readonly __address: true;
|
|
64
64
|
})[];
|
|
65
65
|
payload_hashes: import("@xylabs/sdk-js").BrandedHash[];
|
|
66
|
-
payload_schemas: import("@xyo-network/
|
|
66
|
+
payload_schemas: import("@xyo-network/sdk-js").BrandedSchema<string>[];
|
|
67
67
|
previous_hashes: (import("@xylabs/sdk-js").BrandedHash | null)[];
|
|
68
68
|
$signatures: import("@xylabs/sdk-js").BrandedHex[];
|
|
69
69
|
nbf: import("@xyo-network/xl1-protocol-lib").XL1BlockNumber;
|
|
@@ -91,7 +91,7 @@ export declare class TransactionBuilder<TPayload extends Payload> extends Base<O
|
|
|
91
91
|
script?: string[] | undefined;
|
|
92
92
|
}, {
|
|
93
93
|
[x: string]: unknown;
|
|
94
|
-
schema: import("@xyo-network/
|
|
94
|
+
schema: import("@xyo-network/sdk-js").BrandedSchema<string>;
|
|
95
95
|
_hash: import("@xylabs/sdk-js").BrandedHash;
|
|
96
96
|
_dataHash: import("@xylabs/sdk-js").BrandedHash;
|
|
97
97
|
}[]]>;
|
|
@@ -16,7 +16,7 @@ export declare function signTransaction(tx: UnsignedTransactionBoundWitness, acc
|
|
|
16
16
|
readonly __address: true;
|
|
17
17
|
})[];
|
|
18
18
|
payload_hashes: import("@xylabs/sdk-js").BrandedHash[];
|
|
19
|
-
payload_schemas: import("@xyo-network/
|
|
19
|
+
payload_schemas: import("@xyo-network/sdk-js").BrandedSchema<string>[];
|
|
20
20
|
previous_hashes: (import("@xylabs/sdk-js").BrandedHash | null)[];
|
|
21
21
|
$signatures: (import("@xylabs/sdk-js").BrandedHex | null)[];
|
|
22
22
|
nbf: import("@xyo-network/xl1-protocol-lib").XL1BlockNumber;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/xl1-protocol-sdk",
|
|
3
|
-
"version": "1.26.
|
|
3
|
+
"version": "1.26.13",
|
|
4
4
|
"description": "XYO Layer One SDK Protocol",
|
|
5
5
|
"homepage": "https://xylabs.com",
|
|
6
6
|
"bugs": {
|
|
@@ -22,17 +22,14 @@
|
|
|
22
22
|
"exports": {
|
|
23
23
|
".": {
|
|
24
24
|
"types": "./dist/neutral/index.d.ts",
|
|
25
|
-
"source": "./src/index.ts",
|
|
26
25
|
"default": "./dist/neutral/index.mjs"
|
|
27
26
|
},
|
|
28
27
|
"./test": {
|
|
29
28
|
"types": "./dist/neutral/test/index.d.ts",
|
|
30
|
-
"source": "./src/test/index.ts",
|
|
31
29
|
"default": "./dist/neutral/test/index.mjs"
|
|
32
30
|
},
|
|
33
31
|
"./get": {
|
|
34
32
|
"types": "./dist/neutral/getFileConfig.d.ts",
|
|
35
|
-
"source": "./src/getFileConfig.ts",
|
|
36
33
|
"default": "./dist/neutral/getFileConfig.mjs"
|
|
37
34
|
},
|
|
38
35
|
"./package.json": "./package.json"
|
|
@@ -42,37 +39,50 @@
|
|
|
42
39
|
"types": "./dist/neutral/index.d.ts",
|
|
43
40
|
"files": [
|
|
44
41
|
"dist",
|
|
45
|
-
"src",
|
|
46
42
|
"!**/*.bench.*",
|
|
47
43
|
"!**/*.spec.*",
|
|
48
44
|
"!**/*.test.*",
|
|
49
45
|
"README.md"
|
|
50
46
|
],
|
|
51
47
|
"dependencies": {
|
|
52
|
-
"@xyo-network/xl1-protocol-lib": "~1.26.
|
|
53
|
-
"@xyo-network/xl1-schema": "~1.26.
|
|
48
|
+
"@xyo-network/xl1-protocol-lib": "~1.26.13",
|
|
49
|
+
"@xyo-network/xl1-schema": "~1.26.13",
|
|
54
50
|
"async-mutex": "~0.5.0",
|
|
55
51
|
"cosmiconfig": "^9.0.1",
|
|
56
52
|
"lru-cache": "^11.2.7"
|
|
57
53
|
},
|
|
58
54
|
"devDependencies": {
|
|
55
|
+
"@firebase/app": "0.x",
|
|
56
|
+
"@firebase/app-compat": "0.x",
|
|
57
|
+
"@firebase/app-types": "0.x",
|
|
58
|
+
"@firebase/util": "1.x",
|
|
59
|
+
"@metamask/providers": "^22",
|
|
59
60
|
"@opentelemetry/api": "^1.9.1",
|
|
60
61
|
"@types/node": "^25.5.0",
|
|
62
|
+
"@xylabs/geo": "^5",
|
|
61
63
|
"@xylabs/sdk-js": "^5.0.91",
|
|
62
|
-
"@xylabs/ts-scripts-common": "~7.6.
|
|
63
|
-
"@xylabs/ts-scripts-yarn3": "~7.6.
|
|
64
|
-
"@xylabs/tsconfig": "~7.6.
|
|
64
|
+
"@xylabs/ts-scripts-common": "~7.6.13",
|
|
65
|
+
"@xylabs/ts-scripts-yarn3": "~7.6.13",
|
|
66
|
+
"@xylabs/tsconfig": "~7.6.13",
|
|
65
67
|
"@xylabs/vitest-extended": "~5.0.91",
|
|
66
|
-
"@xyo-network/sdk-js": "^5.3.
|
|
67
|
-
"@xyo-network/xl1-network-model": "~1.26.
|
|
68
|
-
"
|
|
68
|
+
"@xyo-network/sdk-js": "^5.3.22",
|
|
69
|
+
"@xyo-network/xl1-network-model": "~1.26.13",
|
|
70
|
+
"acorn": "^6.0.0 || ^7.0.0 || ^8.0.0",
|
|
71
|
+
"ajv": "^8",
|
|
72
|
+
"axios": "^1.14.0",
|
|
73
|
+
"esbuild": ">=0.18",
|
|
74
|
+
"eslint": "^6.0.0 || ^7.0.0 || >=8.0.0",
|
|
69
75
|
"ethers": "^6.16.0",
|
|
76
|
+
"firebase": "^12",
|
|
70
77
|
"ky": "^1.14.3",
|
|
78
|
+
"mapbox-gl": "^3",
|
|
71
79
|
"mongodb": "~7.1.1",
|
|
80
|
+
"rollup": "^3.29.4 || ^4",
|
|
72
81
|
"tslib": "^2.8.1",
|
|
73
82
|
"typescript": "~5.9.3",
|
|
74
|
-
"vite": "^
|
|
83
|
+
"vite": "^8.0.3",
|
|
75
84
|
"vitest": "~4.1.2",
|
|
85
|
+
"webextension-polyfill": "^0.10.0 || ^0.11.0 || ^0.12.0",
|
|
76
86
|
"zod": "~4.3.6"
|
|
77
87
|
},
|
|
78
88
|
"peerDependencies": {
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isDefined, isObject, isUndefined,
|
|
3
|
-
timeBudget,
|
|
4
|
-
} from '@xylabs/sdk-js'
|
|
5
|
-
import type { CachingContext, MapType } from '@xyo-network/xl1-protocol-lib'
|
|
6
|
-
|
|
7
|
-
import { LruCacheMap, MemoryMap } from './driver/index.ts'
|
|
8
|
-
|
|
9
|
-
/** Retrieves or creates a named cache from the caching context */
|
|
10
|
-
export function contextCache<TCacheValue>(
|
|
11
|
-
context: CachingContext,
|
|
12
|
-
name: string,
|
|
13
|
-
create?: () => MapType<string, TCacheValue>,
|
|
14
|
-
): MapType<string, TCacheValue> {
|
|
15
|
-
if (!isObject(context.caches)) {
|
|
16
|
-
throw new Error('Context does not have an appropriate caches property')
|
|
17
|
-
}
|
|
18
|
-
if (isUndefined(context.caches[name])) {
|
|
19
|
-
context.caches[name] = create?.() ?? new MemoryMap<string, TCacheValue>()
|
|
20
|
-
}
|
|
21
|
-
return context.caches[name] as MapType<string, TCacheValue>
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/** Options for the withContextCacheResponse helper */
|
|
25
|
-
export interface withContextCacheResponseOptions {
|
|
26
|
-
max?: number
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/** Executes a function with LRU caching, returning the cached result if available */
|
|
30
|
-
export async function withContextCacheResponse<T extends {} | string | number | bigint>(
|
|
31
|
-
context: CachingContext,
|
|
32
|
-
name: string,
|
|
33
|
-
key: string,
|
|
34
|
-
func: () => Promise<T extends {} | string | number | bigint ? T : never>,
|
|
35
|
-
{ max = 10_000 }: withContextCacheResponseOptions = {},
|
|
36
|
-
): Promise<T> {
|
|
37
|
-
const cache = contextCache<Promise<T>>(
|
|
38
|
-
context,
|
|
39
|
-
name,
|
|
40
|
-
() => new LruCacheMap<string, Promise<T>>({ max }),
|
|
41
|
-
)
|
|
42
|
-
const { timeBudgetLimit = 0 } = context
|
|
43
|
-
const cacheResult = await cache.get(key)
|
|
44
|
-
if (isDefined(cacheResult)) {
|
|
45
|
-
return cacheResult
|
|
46
|
-
}
|
|
47
|
-
const result = timeBudgetLimit > 0 ? timeBudget(name, context.logger, func, timeBudgetLimit) : func()
|
|
48
|
-
await cache.set(key, result)
|
|
49
|
-
return result
|
|
50
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import type { Logger } from '@xylabs/sdk-js'
|
|
2
|
-
import {
|
|
3
|
-
AbstractCreatable, assertEx, IdLogger,
|
|
4
|
-
} from '@xylabs/sdk-js'
|
|
5
|
-
import type { Provider, ProviderMoniker } from '@xyo-network/xl1-protocol-lib'
|
|
6
|
-
|
|
7
|
-
import type {
|
|
8
|
-
CreatableProvider,
|
|
9
|
-
CreatableProviderEventData, CreatableProviderInstance, CreatableProviderParams,
|
|
10
|
-
ProviderMap,
|
|
11
|
-
} from './CreatableProvider.ts'
|
|
12
|
-
import { ProviderFactory } from './ProviderFactory.ts'
|
|
13
|
-
|
|
14
|
-
/** Abstract base class for CreatableProvider implementations. */
|
|
15
|
-
export abstract class AbstractCreatableProvider<TParams extends CreatableProviderParams = CreatableProviderParams,
|
|
16
|
-
TEventData extends CreatableProviderEventData = CreatableProviderEventData> extends AbstractCreatable<TParams, TEventData>
|
|
17
|
-
implements Omit<CreatableProviderInstance, 'moniker'> {
|
|
18
|
-
dependencies: ProviderMap = {}
|
|
19
|
-
|
|
20
|
-
protected _contextCache: TParams['context'] | undefined
|
|
21
|
-
protected _logger: Logger | undefined | null
|
|
22
|
-
|
|
23
|
-
abstract readonly moniker: ProviderMoniker
|
|
24
|
-
|
|
25
|
-
override get logger() {
|
|
26
|
-
// we use null as a way to know if it has been initialized to nothing
|
|
27
|
-
if (this._logger === undefined) {
|
|
28
|
-
const providedLogger = this.params.logger ?? this.context.logger
|
|
29
|
-
this._logger = providedLogger ? new IdLogger(providedLogger, () => `${this.moniker} [${this.constructor.name}]`) : null
|
|
30
|
-
}
|
|
31
|
-
return this._logger ?? undefined
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
override get meter() {
|
|
35
|
-
return this.context.meterProvider?.getMeter(this.name) ?? super.meter
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
override get tracer() {
|
|
39
|
-
return this.context.traceProvider?.getTracer(this.name) ?? super.tracer
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
protected get config() {
|
|
43
|
-
return this.context.config!
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
protected get context() {
|
|
47
|
-
return this.params.context!
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
protected get locator() {
|
|
51
|
-
return this.context.locator!
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
static factory<TInstance extends CreatableProviderInstance, TDependencies extends ProviderMoniker[] = ProviderMoniker[]>(
|
|
55
|
-
this: CreatableProvider<TInstance>,
|
|
56
|
-
dependencies: TDependencies,
|
|
57
|
-
params: Omit<TInstance['params'], 'context'>,
|
|
58
|
-
) {
|
|
59
|
-
const factory = ProviderFactory.withParams<TInstance, TDependencies>(this, dependencies, params)
|
|
60
|
-
return factory
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
static override async paramsHandler<T extends CreatableProviderInstance>(
|
|
64
|
-
params: Partial<T['params']> = {},
|
|
65
|
-
) {
|
|
66
|
-
const context = assertEx(params.context, () => new Error('Context is required'))
|
|
67
|
-
const config = assertEx(context.config, () => new Error('Context config is required'))
|
|
68
|
-
const locator = assertEx(context.locator, () => new Error('Context locator is required'))
|
|
69
|
-
return await super.paramsHandler<T>({
|
|
70
|
-
...params,
|
|
71
|
-
statusReporter: params.statusReporter ?? context.statusReporter,
|
|
72
|
-
context: {
|
|
73
|
-
...context, config, locator,
|
|
74
|
-
},
|
|
75
|
-
name: params.name ?? (this as unknown as CreatableProvider<T>).defaultMoniker,
|
|
76
|
-
logger: params.logger ?? context.logger,
|
|
77
|
-
})
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
override async createHandler() {
|
|
81
|
-
await super.createHandler()
|
|
82
|
-
if (this.tracer === undefined) {
|
|
83
|
-
this.logger?.warn('No tracer available in context')
|
|
84
|
-
}
|
|
85
|
-
if (this.meter === undefined) {
|
|
86
|
-
this.logger?.warn('No meter available in context')
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
async locateAndCreate<TProvider extends Provider<ProviderMoniker>>(moniker: TProvider['moniker']) {
|
|
91
|
-
return await this.locator.getInstance<TProvider>(moniker)
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
async tryLocateAndCreate<TProvider extends Provider<ProviderMoniker>>(moniker: TProvider['moniker']) {
|
|
95
|
-
return await this.locator.tryGetInstance<TProvider>(moniker)
|
|
96
|
-
}
|
|
97
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
Creatable, CreatableInstance, CreatableParams,
|
|
3
|
-
EventData,
|
|
4
|
-
Labels, WithOptionalLabels,
|
|
5
|
-
} from '@xylabs/sdk-js'
|
|
6
|
-
import type { Provider, ProviderMoniker } from '@xyo-network/xl1-protocol-lib'
|
|
7
|
-
|
|
8
|
-
import type { CreatableProviderContext } from '../model/index.ts'
|
|
9
|
-
import type { GetInstanceOptions } from './GetInstanceOptions.ts'
|
|
10
|
-
import type { LabeledCreatableProviderFactory } from './LabeledCreatableProviderFactory.ts'
|
|
11
|
-
|
|
12
|
-
/** Parameters for CreatableProvider. */
|
|
13
|
-
export interface CreatableProviderParams<TContext extends CreatableProviderContext = CreatableProviderContext> extends CreatableParams {
|
|
14
|
-
context: TContext
|
|
15
|
-
}
|
|
16
|
-
/** CreatableProviderEventData interface. */
|
|
17
|
-
export interface CreatableProviderEventData extends EventData {}
|
|
18
|
-
|
|
19
|
-
/** CreatableProviderInstance type. */
|
|
20
|
-
export type CreatableProviderInstance<
|
|
21
|
-
TProvider extends Provider<ProviderMoniker> = Provider<ProviderMoniker>,
|
|
22
|
-
TDependencies extends ProviderMoniker[] = ProviderMoniker[],
|
|
23
|
-
TParams extends CreatableProviderParams = CreatableProviderParams,
|
|
24
|
-
TEventData extends CreatableProviderEventData = CreatableProviderEventData>
|
|
25
|
-
= CreatableInstance<TParams, TEventData> & TProvider & {
|
|
26
|
-
dependencies: ProviderMap<TDependencies[number]>
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/** ProviderFactoryScope type. */
|
|
30
|
-
export type ProviderFactoryScope = 'global' | 'context' | 'local'
|
|
31
|
-
|
|
32
|
-
/** CreatableProviderFactory interface. */
|
|
33
|
-
export interface CreatableProviderFactory<T extends CreatableProviderInstance = CreatableProviderInstance,
|
|
34
|
-
TDependencies extends ProviderMoniker[] = ProviderMoniker[]>
|
|
35
|
-
extends Omit<CreatableProvider<T>, 'create' | 'createHandler' | 'paramsHandler'> {
|
|
36
|
-
creatableProvider: CreatableProvider<T>
|
|
37
|
-
defaultParams: Omit<T['params'], 'context'>
|
|
38
|
-
|
|
39
|
-
readonly dependencies: TDependencies
|
|
40
|
-
|
|
41
|
-
labels?: Labels
|
|
42
|
-
providerName: string
|
|
43
|
-
resolvedMoniker: string
|
|
44
|
-
scope: ProviderFactoryScope
|
|
45
|
-
|
|
46
|
-
uniqueId: symbol
|
|
47
|
-
|
|
48
|
-
getInstance(
|
|
49
|
-
this: CreatableProviderFactory<T>,
|
|
50
|
-
params: T['params'],
|
|
51
|
-
options?: GetInstanceOptions): Promise<T>
|
|
52
|
-
|
|
53
|
-
tryGetInstance(
|
|
54
|
-
this: CreatableProviderFactory<T>,
|
|
55
|
-
params: T['params'],
|
|
56
|
-
options?: GetInstanceOptions): Promise<T | undefined>
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/** LabeledCreatableProvider interface. */
|
|
61
|
-
export interface LabeledCreatableProvider<T extends CreatableProviderInstance = CreatableProviderInstance,
|
|
62
|
-
TDependencies extends ProviderMoniker[] = ProviderMoniker[]> extends CreatableProvider<T>, WithOptionalLabels {
|
|
63
|
-
factory(dependencies: TDependencies, params: Omit<T['params'], 'context'>): LabeledCreatableProviderFactory<T>
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/** ProviderMap type. */
|
|
67
|
-
export type ProviderMap<T extends ProviderMoniker = ProviderMoniker> = Partial<Record<T, CreatableProviderInstance<Provider<T>>>>
|
|
68
|
-
|
|
69
|
-
/** CreatableProvider interface. */
|
|
70
|
-
export interface CreatableProvider<T extends CreatableProviderInstance = CreatableProviderInstance,
|
|
71
|
-
TDependencies extends ProviderMoniker[] = ProviderMoniker[]> extends Creatable<T> {
|
|
72
|
-
readonly defaultMoniker: ProviderMoniker
|
|
73
|
-
readonly dependencies: TDependencies
|
|
74
|
-
readonly monikers: ProviderMoniker[]
|
|
75
|
-
factory(dependencies: TDependencies, params: Omit<T['params'], 'context'>): CreatableProviderFactory<T>
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Class annotation to be used to decorate Providers which support
|
|
80
|
-
* an asynchronous creation pattern
|
|
81
|
-
* @returns The decorated Provider requiring it implement the members
|
|
82
|
-
* of the CreatableProvider as statics properties/methods
|
|
83
|
-
*/
|
|
84
|
-
export function creatableProvider<TProvider extends CreatableProviderInstance = CreatableProviderInstance>() {
|
|
85
|
-
return <U extends CreatableProvider<TProvider>>(constructor: U) => {
|
|
86
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
87
|
-
constructor
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Class annotation to be used to decorate Providers which support
|
|
93
|
-
* an asynchronous creation pattern
|
|
94
|
-
* @returns The decorated Provider requiring it implement the members
|
|
95
|
-
* of the CreatableProvider as statics properties/methods
|
|
96
|
-
*/
|
|
97
|
-
export function labeledCreatableProvider<TProvider extends CreatableProviderInstance = CreatableProviderInstance>() {
|
|
98
|
-
return <U extends LabeledCreatableProvider<TProvider>>(constructor: U) => {
|
|
99
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
100
|
-
constructor
|
|
101
|
-
}
|
|
102
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import type { Labels } from '@xylabs/sdk-js'
|
|
2
|
-
import { isTruthy } from '@xylabs/sdk-js'
|
|
3
|
-
import type { ProviderMoniker } from '@xyo-network/xl1-protocol-lib'
|
|
4
|
-
|
|
5
|
-
import type { CreatableProviderFactory, CreatableProviderInstance } from './CreatableProvider.ts'
|
|
6
|
-
import type { LabeledCreatableProviderFactory } from './LabeledCreatableProviderFactory.ts'
|
|
7
|
-
import { providerFactoryDescription } from './ProviderFactory.ts'
|
|
8
|
-
|
|
9
|
-
/** CreatableProviderRegistry type. */
|
|
10
|
-
export type CreatableProviderRegistry<TMonikers extends ProviderMoniker[] = ProviderMoniker[]>
|
|
11
|
-
= Record<TMonikers[number], (CreatableProviderFactory | LabeledCreatableProviderFactory)[] | undefined>
|
|
12
|
-
|
|
13
|
-
const buildProviderFactory = <TProvider extends CreatableProviderInstance>(
|
|
14
|
-
provider: CreatableProviderFactory<TProvider>,
|
|
15
|
-
defaultParams: Omit<TProvider['params'], 'context'>,
|
|
16
|
-
labels?: Labels,
|
|
17
|
-
): LabeledCreatableProviderFactory<TProvider> => {
|
|
18
|
-
const factory = {
|
|
19
|
-
monikers: provider.monikers,
|
|
20
|
-
uniqueId: Symbol(providerFactoryDescription(provider, labels)),
|
|
21
|
-
// Merge module & supplied labels
|
|
22
|
-
labels: { ...(provider as LabeledCreatableProviderFactory).labels, ...labels },
|
|
23
|
-
creatableProvider: provider.creatableProvider,
|
|
24
|
-
dependencies: provider.dependencies,
|
|
25
|
-
resolvedMoniker: provider.resolvedMoniker,
|
|
26
|
-
providerName: provider.providerName,
|
|
27
|
-
scope: provider.scope,
|
|
28
|
-
defaultParams,
|
|
29
|
-
getInstance: provider.getInstance.bind(provider) as LabeledCreatableProviderFactory<TProvider>['getInstance'],
|
|
30
|
-
tryGetInstance: provider.tryGetInstance?.bind(provider) as LabeledCreatableProviderFactory<TProvider>['tryGetInstance'],
|
|
31
|
-
defaultMoniker: provider.defaultMoniker,
|
|
32
|
-
factory: provider.factory.bind(provider) as LabeledCreatableProviderFactory<TProvider>['factory'],
|
|
33
|
-
} satisfies LabeledCreatableProviderFactory<TProvider>
|
|
34
|
-
return factory
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/** registerCreatableProviderFactory constant. */
|
|
38
|
-
export const registerCreatableProviderFactory = <TProvider extends CreatableProviderInstance>(
|
|
39
|
-
registry: CreatableProviderRegistry,
|
|
40
|
-
factory: CreatableProviderFactory<TProvider> | LabeledCreatableProviderFactory<TProvider>,
|
|
41
|
-
labels?: Labels,
|
|
42
|
-
/** register this as the primary factory for every schema it supports */
|
|
43
|
-
primary: boolean | ProviderMoniker | ProviderMoniker[] = false,
|
|
44
|
-
) => {
|
|
45
|
-
const primaryMonikers
|
|
46
|
-
= primary !== true && isTruthy(primary)
|
|
47
|
-
? Array.isArray(primary)
|
|
48
|
-
? primary
|
|
49
|
-
: [primary]
|
|
50
|
-
: []
|
|
51
|
-
|
|
52
|
-
for (const primaryMoniker of primaryMonikers) {
|
|
53
|
-
if (!factory.monikers.includes(primaryMoniker)) {
|
|
54
|
-
console.warn(`Primary moniker ${primary} not found in factory monikers`)
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const isPrimaryForMoniker = (moniker: ProviderMoniker) => {
|
|
59
|
-
switch (typeof primary) {
|
|
60
|
-
case 'boolean': {
|
|
61
|
-
return primary
|
|
62
|
-
}
|
|
63
|
-
case 'string': {
|
|
64
|
-
return moniker === primary
|
|
65
|
-
}
|
|
66
|
-
case 'object': {
|
|
67
|
-
if (Array.isArray(primary)) {
|
|
68
|
-
return primary.includes(moniker)
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
throw new Error(`Invalid primary value: ${primary}`)
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const factoryClone: LabeledCreatableProviderFactory<TProvider> = buildProviderFactory(factory, factory.defaultParams, labels)
|
|
76
|
-
|
|
77
|
-
// add this default moniker as the first entry
|
|
78
|
-
registry[factoryClone.defaultMoniker] = [factoryClone, ...(registry[factoryClone.defaultMoniker] ?? [])]
|
|
79
|
-
for (const moniker of factoryClone.monikers) {
|
|
80
|
-
registry[moniker] = isPrimaryForMoniker(moniker) ? [factoryClone, ...(registry[moniker] ?? [])] : [...(registry[moniker] ?? []), factoryClone]
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/** registerCreatableProviderFactories constant. */
|
|
85
|
-
export const registerCreatableProviderFactories = (
|
|
86
|
-
factories: (CreatableProviderFactory | LabeledCreatableProviderFactory)[],
|
|
87
|
-
registry: CreatableProviderRegistry = {},
|
|
88
|
-
primary = false,
|
|
89
|
-
) => {
|
|
90
|
-
for (const factory of factories) {
|
|
91
|
-
registerCreatableProviderFactory(registry, factory, undefined, primary)
|
|
92
|
-
}
|
|
93
|
-
return registry
|
|
94
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { Labels } from '@xylabs/sdk-js'
|
|
2
|
-
|
|
3
|
-
/** Options for GetInstance. */
|
|
4
|
-
export interface GetInstanceOptions {
|
|
5
|
-
start?: boolean
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/** Options for ProviderFactoryGetInstance. */
|
|
9
|
-
export interface ProviderFactoryGetInstanceOptions extends GetInstanceOptions {
|
|
10
|
-
labels?: Labels
|
|
11
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { WithOptionalLabels } from '@xylabs/sdk-js'
|
|
2
|
-
|
|
3
|
-
import type { CreatableProviderFactory, CreatableProviderInstance } from './CreatableProvider.ts'
|
|
4
|
-
|
|
5
|
-
/** LabeledCreatableProviderFactory type. */
|
|
6
|
-
export type LabeledCreatableProviderFactory<T extends CreatableProviderInstance = CreatableProviderInstance> = CreatableProviderFactory<T> & WithOptionalLabels
|
|
7
|
-
|
|
8
|
-
/** hasLabels constant. */
|
|
9
|
-
export const hasLabels = (factory: CreatableProviderFactory | LabeledCreatableProviderFactory): factory is LabeledCreatableProviderFactory => {
|
|
10
|
-
return (factory as LabeledCreatableProviderFactory).labels !== undefined
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Class annotation to be used to decorate Providers which support
|
|
15
|
-
* an asynchronous labeled creation factory pattern
|
|
16
|
-
* @returns The decorated Provider requiring it implement the members
|
|
17
|
-
* of the CreatableProvider as statics properties/methods
|
|
18
|
-
*/
|
|
19
|
-
export function labeledCreatableProviderFactory<TProvider extends CreatableProviderInstance = CreatableProviderInstance>() {
|
|
20
|
-
return <U extends LabeledCreatableProviderFactory<TProvider>>(constructor: U) => {
|
|
21
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
22
|
-
constructor
|
|
23
|
-
}
|
|
24
|
-
}
|