@decaf-ts/for-fabric 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/version.cjs +1 -1
- package/lib/esm/version.js +1 -1
- package/lib/types/client/FabricClientAdapter.d.cts +3 -3
- package/lib/types/client/FabricClientAdapter.d.mts +3 -3
- package/lib/types/client/FabricClientDispatch.d.cts +2 -2
- package/lib/types/client/FabricClientDispatch.d.mts +2 -2
- package/lib/types/client/FabricClientPaginator.d.cts +1 -1
- package/lib/types/client/FabricClientPaginator.d.mts +1 -1
- package/lib/types/client/FabricClientRepository.d.cts +1 -1
- package/lib/types/client/FabricClientRepository.d.mts +1 -1
- package/lib/types/client/FabricClientStatement.d.cts +2 -2
- package/lib/types/client/FabricClientStatement.d.mts +2 -2
- package/lib/types/client/collections/index.d.cts +1 -1
- package/lib/types/client/collections/index.d.mts +1 -1
- package/lib/types/client/constants.d.cts +1 -1
- package/lib/types/client/constants.d.mts +1 -1
- package/lib/types/client/erc20/FabricERC20ClientRepository.d.cts +3 -3
- package/lib/types/client/erc20/FabricERC20ClientRepository.d.mts +3 -3
- package/lib/types/client/erc20/index.d.cts +1 -1
- package/lib/types/client/erc20/index.d.mts +1 -1
- package/lib/types/client/ids/index.d.cts +1 -1
- package/lib/types/client/ids/index.d.mts +1 -1
- package/lib/types/client/index.d.cts +14 -14
- package/lib/types/client/index.d.mts +14 -14
- package/lib/types/client/indexes/index.d.cts +1 -1
- package/lib/types/client/indexes/index.d.mts +1 -1
- package/lib/types/client/services/FabricEnrollmentService.d.cts +4 -4
- package/lib/types/client/services/FabricEnrollmentService.d.mts +4 -4
- package/lib/types/client/services/FabricIdentityService.d.cts +5 -5
- package/lib/types/client/services/FabricIdentityService.d.mts +5 -5
- package/lib/types/client/services/RegistrationRequestBuilder.d.cts +1 -1
- package/lib/types/client/services/RegistrationRequestBuilder.d.mts +1 -1
- package/lib/types/client/services/index.d.cts +4 -4
- package/lib/types/client/services/index.d.mts +4 -4
- package/lib/types/client/types.d.cts +1 -1
- package/lib/types/client/types.d.mts +1 -1
- package/lib/types/client/utils.d.cts +1 -1
- package/lib/types/client/utils.d.mts +1 -1
- package/lib/types/contract/AddressContract.d.cts +2 -2
- package/lib/types/contract/AddressContract.d.mts +2 -2
- package/lib/types/contract/AuditContract.d.cts +2 -2
- package/lib/types/contract/AuditContract.d.mts +2 -2
- package/lib/types/contract/BatchContract.d.cts +2 -2
- package/lib/types/contract/BatchContract.d.mts +2 -2
- package/lib/types/contract/MarketContract.d.cts +2 -2
- package/lib/types/contract/MarketContract.d.mts +2 -2
- package/lib/types/contract/OtherAuditContract.d.cts +2 -2
- package/lib/types/contract/OtherAuditContract.d.mts +2 -2
- package/lib/types/contract/OtherBatchContract.d.cts +2 -2
- package/lib/types/contract/OtherBatchContract.d.mts +2 -2
- package/lib/types/contract/OtherMarketContract.d.cts +2 -2
- package/lib/types/contract/OtherMarketContract.d.mts +2 -2
- package/lib/types/contract/OtherProductContract.d.cts +2 -2
- package/lib/types/contract/OtherProductContract.d.mts +2 -2
- package/lib/types/contract/OtherProductImageContract.d.cts +2 -2
- package/lib/types/contract/OtherProductImageContract.d.mts +2 -2
- package/lib/types/contract/OtherProductSharedContract.d.cts +2 -2
- package/lib/types/contract/OtherProductSharedContract.d.mts +2 -2
- package/lib/types/contract/OtherProductStrengthContract.d.cts +2 -2
- package/lib/types/contract/OtherProductStrengthContract.d.mts +2 -2
- package/lib/types/contract/Product.d.cts +1 -1
- package/lib/types/contract/Product.d.mts +1 -1
- package/lib/types/contract/ProductContract.d.cts +2 -2
- package/lib/types/contract/ProductContract.d.mts +2 -2
- package/lib/types/contract/ProductStrengthContract.d.cts +2 -2
- package/lib/types/contract/ProductStrengthContract.d.mts +2 -2
- package/lib/types/contract/SegregatedPrivateDocumentContract.d.cts +2 -2
- package/lib/types/contract/SegregatedPrivateDocumentContract.d.mts +2 -2
- package/lib/types/contract/SegregatedSharedDocumentContract.d.cts +2 -2
- package/lib/types/contract/SegregatedSharedDocumentContract.d.mts +2 -2
- package/lib/types/contract/UserContract.d.cts +2 -2
- package/lib/types/contract/UserContract.d.mts +2 -2
- package/lib/types/contract/models/Audit.d.cts +2 -2
- package/lib/types/contract/models/Audit.d.mts +2 -2
- package/lib/types/contract/models/BaseIdentifiedModel.d.cts +1 -1
- package/lib/types/contract/models/BaseIdentifiedModel.d.mts +1 -1
- package/lib/types/contract/models/Batch.d.cts +1 -1
- package/lib/types/contract/models/Batch.d.mts +1 -1
- package/lib/types/contract/models/GtinOwner.d.cts +1 -1
- package/lib/types/contract/models/GtinOwner.d.mts +1 -1
- package/lib/types/contract/models/Leaflet.d.cts +1 -1
- package/lib/types/contract/models/Leaflet.d.mts +1 -1
- package/lib/types/contract/models/LeafletFile.d.cts +1 -1
- package/lib/types/contract/models/LeafletFile.d.mts +1 -1
- package/lib/types/contract/models/Market.d.cts +1 -1
- package/lib/types/contract/models/Market.d.mts +1 -1
- package/lib/types/contract/models/OtherAudit.d.cts +2 -2
- package/lib/types/contract/models/OtherAudit.d.mts +2 -2
- package/lib/types/contract/models/OtherBatchShared.d.cts +1 -1
- package/lib/types/contract/models/OtherBatchShared.d.mts +1 -1
- package/lib/types/contract/models/OtherLeaflet.d.cts +2 -2
- package/lib/types/contract/models/OtherLeaflet.d.mts +2 -2
- package/lib/types/contract/models/OtherLeafletFile.d.cts +1 -1
- package/lib/types/contract/models/OtherLeafletFile.d.mts +1 -1
- package/lib/types/contract/models/OtherMarket.d.cts +1 -1
- package/lib/types/contract/models/OtherMarket.d.mts +1 -1
- package/lib/types/contract/models/OtherProduct.d.cts +1 -1
- package/lib/types/contract/models/OtherProduct.d.mts +1 -1
- package/lib/types/contract/models/OtherProductImage.d.cts +1 -1
- package/lib/types/contract/models/OtherProductImage.d.mts +1 -1
- package/lib/types/contract/models/OtherProductShared.d.cts +4 -4
- package/lib/types/contract/models/OtherProductShared.d.mts +4 -4
- package/lib/types/contract/models/OtherProductStrength.d.cts +1 -1
- package/lib/types/contract/models/OtherProductStrength.d.mts +1 -1
- package/lib/types/contract/models/Product.d.cts +3 -3
- package/lib/types/contract/models/Product.d.mts +3 -3
- package/lib/types/contract/models/ProductStrength.d.cts +1 -1
- package/lib/types/contract/models/ProductStrength.d.mts +1 -1
- package/lib/types/contract/models/SegregatedDocument.d.cts +1 -1
- package/lib/types/contract/models/SegregatedDocument.d.mts +1 -1
- package/lib/types/contract/models/decorators-private.d.cts +2 -2
- package/lib/types/contract/models/decorators-private.d.mts +2 -2
- package/lib/types/contract/models/decorators.d.cts +2 -2
- package/lib/types/contract/models/decorators.d.mts +2 -2
- package/lib/types/contract/models/history-dec.d.cts +1 -1
- package/lib/types/contract/models/history-dec.d.mts +1 -1
- package/lib/types/contracts/ContractAdapter.d.cts +5 -5
- package/lib/types/contracts/ContractAdapter.d.mts +5 -5
- package/lib/types/contracts/ContractContext.d.cts +1 -1
- package/lib/types/contracts/ContractContext.d.mts +1 -1
- package/lib/types/contracts/FabricContractDispatch.d.cts +2 -2
- package/lib/types/contracts/FabricContractDispatch.d.mts +2 -2
- package/lib/types/contracts/FabricContractPaginator.d.cts +1 -1
- package/lib/types/contracts/FabricContractPaginator.d.mts +1 -1
- package/lib/types/contracts/FabricContractRepository.d.cts +3 -3
- package/lib/types/contracts/FabricContractRepository.d.mts +3 -3
- package/lib/types/contracts/FabricContractRepositoryObservableHandler.d.cts +1 -1
- package/lib/types/contracts/FabricContractRepositoryObservableHandler.d.mts +1 -1
- package/lib/types/contracts/FabricContractStatement.d.cts +1 -1
- package/lib/types/contracts/FabricContractStatement.d.mts +1 -1
- package/lib/types/contracts/MigrationContract.d.cts +3 -3
- package/lib/types/contracts/MigrationContract.d.mts +3 -3
- package/lib/types/contracts/auth/index.d.cts +1 -1
- package/lib/types/contracts/auth/index.d.mts +1 -1
- package/lib/types/contracts/crud/crud-contract.d.cts +5 -5
- package/lib/types/contracts/crud/crud-contract.d.mts +5 -5
- package/lib/types/contracts/crud/index.d.cts +2 -2
- package/lib/types/contracts/crud/index.d.mts +2 -2
- package/lib/types/contracts/crud/serialized-crud-contract.d.cts +1 -1
- package/lib/types/contracts/crud/serialized-crud-contract.d.mts +1 -1
- package/lib/types/contracts/erc20/erc20contract.d.cts +3 -3
- package/lib/types/contracts/erc20/erc20contract.d.mts +3 -3
- package/lib/types/contracts/erc20/index.d.cts +1 -1
- package/lib/types/contracts/erc20/index.d.mts +1 -1
- package/lib/types/contracts/index.d.cts +13 -13
- package/lib/types/contracts/index.d.mts +13 -13
- package/lib/types/contracts/types.d.cts +1 -1
- package/lib/types/contracts/types.d.mts +1 -1
- package/lib/types/index.d.cts +3 -3
- package/lib/types/index.d.mts +3 -3
- package/lib/types/shared/decorators.d.cts +3 -3
- package/lib/types/shared/decorators.d.mts +3 -3
- package/lib/types/shared/erc20/index.d.cts +1 -1
- package/lib/types/shared/erc20/index.d.mts +1 -1
- package/lib/types/shared/index.d.cts +14 -14
- package/lib/types/shared/index.d.mts +14 -14
- package/lib/types/shared/interfaces/index.d.cts +1 -1
- package/lib/types/shared/interfaces/index.d.mts +1 -1
- package/lib/types/shared/model/FabricIdentifiedBaseModel.d.cts +1 -1
- package/lib/types/shared/model/FabricIdentifiedBaseModel.d.mts +1 -1
- package/lib/types/shared/model/Identity.d.cts +2 -2
- package/lib/types/shared/model/Identity.d.mts +2 -2
- package/lib/types/shared/model/index.d.cts +4 -4
- package/lib/types/shared/model/index.d.mts +4 -4
- package/lib/types/shared/overrides/Model.d.cts +2 -2
- package/lib/types/shared/overrides/Model.d.mts +2 -2
- package/lib/types/shared/overrides/index.d.cts +2 -2
- package/lib/types/shared/overrides/index.d.mts +2 -2
- package/lib/types/version.d.cts +1 -1
- package/lib/types/version.d.mts +1 -1
- package/package.json +1 -1
- package/lib/types/bin/cli.d.ts +0 -1
- package/lib/types/cli-module.d.ts +0 -3
- package/lib/types/cli-utils.d.ts +0 -21
- package/lib/types/client/FabricClientAdapter.d.ts +0 -404
- package/lib/types/client/FabricClientDispatch.d.ts +0 -133
- package/lib/types/client/FabricClientPaginator.d.ts +0 -12
- package/lib/types/client/FabricClientRepository.d.ts +0 -71
- package/lib/types/client/FabricClientStatement.d.ts +0 -64
- package/lib/types/client/collections/generation.d.ts +0 -46
- package/lib/types/client/collections/index.d.ts +0 -1
- package/lib/types/client/constants.d.ts +0 -2
- package/lib/types/client/crypto.d.ts +0 -107
- package/lib/types/client/erc20/FabricERC20ClientRepository.d.ts +0 -254
- package/lib/types/client/erc20/index.d.ts +0 -1
- package/lib/types/client/fabric-fs.d.ts +0 -92
- package/lib/types/client/fabric-hsm.d.ts +0 -24
- package/lib/types/client/ids/id-extraction.d.ts +0 -4
- package/lib/types/client/ids/index.d.ts +0 -1
- package/lib/types/client/index.d.ts +0 -23
- package/lib/types/client/indexes/generation.d.ts +0 -10
- package/lib/types/client/indexes/index.d.ts +0 -1
- package/lib/types/client/logging.d.ts +0 -60
- package/lib/types/client/services/FabricEnrollmentService.d.ts +0 -176
- package/lib/types/client/services/FabricIdentityService.d.ts +0 -98
- package/lib/types/client/services/RegistrationRequestBuilder.d.ts +0 -19
- package/lib/types/client/services/constants.d.ts +0 -15
- package/lib/types/client/services/index.d.ts +0 -4
- package/lib/types/client/types.d.ts +0 -20
- package/lib/types/client/utils.d.ts +0 -71
- package/lib/types/contract/Address.d.ts +0 -13
- package/lib/types/contract/AddressContract.d.ts +0 -5
- package/lib/types/contract/AuditContract.d.ts +0 -5
- package/lib/types/contract/BatchContract.d.ts +0 -5
- package/lib/types/contract/MarketContract.d.ts +0 -5
- package/lib/types/contract/OtherAuditContract.d.ts +0 -5
- package/lib/types/contract/OtherBatchContract.d.ts +0 -5
- package/lib/types/contract/OtherMarketContract.d.ts +0 -5
- package/lib/types/contract/OtherProductContract.d.ts +0 -5
- package/lib/types/contract/OtherProductImageContract.d.ts +0 -5
- package/lib/types/contract/OtherProductSharedContract.d.ts +0 -5
- package/lib/types/contract/OtherProductStrengthContract.d.ts +0 -5
- package/lib/types/contract/Product.d.ts +0 -7
- package/lib/types/contract/ProductContract.d.ts +0 -5
- package/lib/types/contract/ProductStrengthContract.d.ts +0 -5
- package/lib/types/contract/SegregatedPrivateDocumentContract.d.ts +0 -5
- package/lib/types/contract/SegregatedSharedDocumentContract.d.ts +0 -5
- package/lib/types/contract/User.d.ts +0 -7
- package/lib/types/contract/UserContract.d.ts +0 -5
- package/lib/types/contract/index.d.ts +0 -2
- package/lib/types/contract/logging-context.d.ts +0 -8
- package/lib/types/contract/models/Audit.d.ts +0 -13
- package/lib/types/contract/models/BaseIdentifiedModel.d.ts +0 -7
- package/lib/types/contract/models/BaseModel.d.ts +0 -7
- package/lib/types/contract/models/Batch.d.ts +0 -18
- package/lib/types/contract/models/GtinOwner.d.ts +0 -8
- package/lib/types/contract/models/History.d.ts +0 -9
- package/lib/types/contract/models/Leaflet.d.ts +0 -12
- package/lib/types/contract/models/LeafletFile.d.ts +0 -9
- package/lib/types/contract/models/Market.d.ts +0 -12
- package/lib/types/contract/models/OtherAudit.d.ts +0 -15
- package/lib/types/contract/models/OtherBatchShared.d.ts +0 -18
- package/lib/types/contract/models/OtherLeaflet.d.ts +0 -16
- package/lib/types/contract/models/OtherLeafletFile.d.ts +0 -10
- package/lib/types/contract/models/OtherMarket.d.ts +0 -13
- package/lib/types/contract/models/OtherProduct.d.ts +0 -12
- package/lib/types/contract/models/OtherProductImage.d.ts +0 -9
- package/lib/types/contract/models/OtherProductShared.d.ts +0 -18
- package/lib/types/contract/models/OtherProductStrength.d.ts +0 -12
- package/lib/types/contract/models/Product.d.ts +0 -15
- package/lib/types/contract/models/ProductStrength.d.ts +0 -11
- package/lib/types/contract/models/SegregatedDocument.d.ts +0 -18
- package/lib/types/contract/models/constants.d.ts +0 -24
- package/lib/types/contract/models/decorators-private.d.ts +0 -16
- package/lib/types/contract/models/decorators.d.ts +0 -28
- package/lib/types/contract/models/gtin.d.ts +0 -8
- package/lib/types/contract/models/history-dec.d.ts +0 -6
- package/lib/types/contracts/ContractAdapter.d.ts +0 -287
- package/lib/types/contracts/ContractContext.d.ts +0 -89
- package/lib/types/contracts/FabricContractDispatch.d.ts +0 -7
- package/lib/types/contracts/FabricContractPaginator.d.ts +0 -105
- package/lib/types/contracts/FabricContractRepository.d.ts +0 -119
- package/lib/types/contracts/FabricContractRepositoryObservableHandler.d.ts +0 -62
- package/lib/types/contracts/FabricContractSequence.d.ts +0 -87
- package/lib/types/contracts/FabricContractStatement.d.ts +0 -36
- package/lib/types/contracts/MigrationContract.d.ts +0 -22
- package/lib/types/contracts/PrivateSequence.d.ts +0 -15
- package/lib/types/contracts/auth/decorators.d.ts +0 -6
- package/lib/types/contracts/auth/index.d.ts +0 -1
- package/lib/types/contracts/crud/crud-contract.d.ts +0 -199
- package/lib/types/contracts/crud/index.d.ts +0 -2
- package/lib/types/contracts/crud/serialized-crud-contract.d.ts +0 -42
- package/lib/types/contracts/erc20/erc20contract.d.ts +0 -152
- package/lib/types/contracts/erc20/index.d.ts +0 -2
- package/lib/types/contracts/erc20/models.d.ts +0 -114
- package/lib/types/contracts/index.d.ts +0 -20
- package/lib/types/contracts/logging.d.ts +0 -54
- package/lib/types/contracts/overrides.d.ts +0 -1
- package/lib/types/contracts/types.d.ts +0 -38
- package/lib/types/contracts/uuid.d.ts +0 -2
- package/lib/types/index.d.ts +0 -8
- package/lib/types/shared/ClientSerializer.d.ts +0 -52
- package/lib/types/shared/DeterministicSerializer.d.ts +0 -47
- package/lib/types/shared/SimpleDeterministicSerializer.d.ts +0 -7
- package/lib/types/shared/constants.d.ts +0 -35
- package/lib/types/shared/decorators.d.ts +0 -81
- package/lib/types/shared/erc20/erc20-constants.d.ts +0 -25
- package/lib/types/shared/erc20/index.d.ts +0 -1
- package/lib/types/shared/errors.d.ts +0 -140
- package/lib/types/shared/events.d.ts +0 -37
- package/lib/types/shared/fabric-types.d.ts +0 -32
- package/lib/types/shared/index.d.ts +0 -21
- package/lib/types/shared/interfaces/Checkable.d.ts +0 -23
- package/lib/types/shared/interfaces/index.d.ts +0 -1
- package/lib/types/shared/math.d.ts +0 -34
- package/lib/types/shared/model/FabricBaseModel.d.ts +0 -7
- package/lib/types/shared/model/FabricIdentifiedBaseModel.d.ts +0 -7
- package/lib/types/shared/model/Identity.d.ts +0 -42
- package/lib/types/shared/model/IdentityCredentials.d.ts +0 -41
- package/lib/types/shared/model/index.d.ts +0 -4
- package/lib/types/shared/overrides/Model.d.ts +0 -22
- package/lib/types/shared/overrides/index.d.ts +0 -2
- package/lib/types/shared/overrides/overrides.d.ts +0 -1
- package/lib/types/shared/types.d.ts +0 -125
- package/lib/types/version.d.ts +0 -2
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { BulkCrudOperationKeys, OperationKeys } from "@decaf-ts/db-decorators";
|
|
2
|
-
import { ContextualArgs, EventIds, ObserverHandler } from "@decaf-ts/core";
|
|
3
|
-
import { FabricContractContext } from "./ContractContext";
|
|
4
|
-
import { Constructor } from "@decaf-ts/decoration";
|
|
5
|
-
/**
|
|
6
|
-
* @description Observer handler for Fabric chaincode events
|
|
7
|
-
* @summary Emits events on the Fabric ledger when repository operations occur
|
|
8
|
-
* @class FabricContractRepositoryObservableHandler
|
|
9
|
-
* @extends {ObserverHandler}
|
|
10
|
-
* @example
|
|
11
|
-
* ```typescript
|
|
12
|
-
* // In a Fabric chaincode contract
|
|
13
|
-
* import { FabricContractRepositoryObservableHandler } from '@decaf-ts/for-fabric';
|
|
14
|
-
*
|
|
15
|
-
* // Create a handler with default supported events
|
|
16
|
-
* const handler = new FabricContractRepositoryObservableHandler();
|
|
17
|
-
*
|
|
18
|
-
* // Emit an event
|
|
19
|
-
* await handler.updateObservers(
|
|
20
|
-
* logger,
|
|
21
|
-
* 'assets',
|
|
22
|
-
* OperationKeys.CREATE,
|
|
23
|
-
* 'asset1',
|
|
24
|
-
* context
|
|
25
|
-
* );
|
|
26
|
-
* ```
|
|
27
|
-
* @mermaid
|
|
28
|
-
* sequenceDiagram
|
|
29
|
-
* participant Repository
|
|
30
|
-
* participant ObservableHandler
|
|
31
|
-
* participant Stub
|
|
32
|
-
* participant Ledger
|
|
33
|
-
*
|
|
34
|
-
* Repository->>ObservableHandler: updateObservers(log, table, event, id, ctx)
|
|
35
|
-
* ObservableHandler->>ObservableHandler: Check if event is supported
|
|
36
|
-
* ObservableHandler->>ObservableHandler: generateFabricEventName(table, event, owner)
|
|
37
|
-
* ObservableHandler->>Stub: setEvent(eventName, payload)
|
|
38
|
-
* Stub->>Ledger: Record event
|
|
39
|
-
*/
|
|
40
|
-
export declare class FabricContractRepositoryObservableHandler extends ObserverHandler {
|
|
41
|
-
private supportedEvents;
|
|
42
|
-
/**
|
|
43
|
-
* @description Creates a new FabricContractRepositoryObservableHandler instance
|
|
44
|
-
* @summary Initializes the handler with a list of supported events
|
|
45
|
-
* @param {Array<OperationKeys | BulkCrudOperationKeys | string>} [supportedEvents] - Events that will trigger Fabric events
|
|
46
|
-
*/
|
|
47
|
-
constructor(supportedEvents?: (OperationKeys | BulkCrudOperationKeys | string)[]);
|
|
48
|
-
/**
|
|
49
|
-
* @description Updates observers by emitting Fabric events
|
|
50
|
-
* @summary Emits events on the Fabric ledger for supported event types
|
|
51
|
-
* @param {Logger} log - Logger instance for debugging
|
|
52
|
-
* @param {string} table - The table/collection name
|
|
53
|
-
* @param {OperationKeys | BulkCrudOperationKeys | string} event - The event type
|
|
54
|
-
* @param {EventIds} id - The event identifier
|
|
55
|
-
* @param {FabricContractContext} ctx - The Fabric contract context
|
|
56
|
-
* @param {string} [owner] - Optional owner identifier for the event
|
|
57
|
-
* @param {object | string | undefined} [owner] - Optional payload for the event
|
|
58
|
-
*
|
|
59
|
-
* @return {Promise<void>} Promise that resolves when the event is emitted
|
|
60
|
-
*/
|
|
61
|
-
updateObservers(clazz: string | Constructor<any>, event: OperationKeys | BulkCrudOperationKeys | string, id: EventIds, ...args: ContextualArgs<FabricContractContext>): Promise<void>;
|
|
62
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { Adapter, Context, MaybeContextualArg, Sequence, SequenceOptions } from "@decaf-ts/core";
|
|
2
|
-
/**
|
|
3
|
-
* @description Abstract base class for sequence generation
|
|
4
|
-
* @summary Provides a framework for generating sequential values (like primary keys) in the persistence layer.
|
|
5
|
-
* Implementations of this class handle the specifics of how sequences are stored and incremented in different
|
|
6
|
-
* database systems.
|
|
7
|
-
* @param {SequenceOptions} options - Configuration options for the sequence generator
|
|
8
|
-
* @class Sequence
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* // Example implementation for a specific database
|
|
12
|
-
* class PostgresSequence extends Sequence {
|
|
13
|
-
* constructor(options: SequenceOptions) {
|
|
14
|
-
* super(options);
|
|
15
|
-
* }
|
|
16
|
-
*
|
|
17
|
-
* async next(): Promise<number> {
|
|
18
|
-
* // Implementation to get next value from PostgreSQL sequence
|
|
19
|
-
* const result = await this.options.executor.raw(`SELECT nextval('${this.options.name}')`);
|
|
20
|
-
* return parseInt(result.rows[0].nextval);
|
|
21
|
-
* }
|
|
22
|
-
*
|
|
23
|
-
* async current(): Promise<number> {
|
|
24
|
-
* // Implementation to get current value from PostgreSQL sequence
|
|
25
|
-
* const result = await this.options.executor.raw(`SELECT currval('${this.options.name}')`);
|
|
26
|
-
* return parseInt(result.rows[0].currval);
|
|
27
|
-
* }
|
|
28
|
-
*
|
|
29
|
-
* async range(count: number): Promise<number[]> {
|
|
30
|
-
* // Implementation to get a range of values
|
|
31
|
-
* const values: number[] = [];
|
|
32
|
-
* for (let i = 0; i < count; i++) {
|
|
33
|
-
* values.push(await this.next());
|
|
34
|
-
* }
|
|
35
|
-
* return values;
|
|
36
|
-
* }
|
|
37
|
-
* }
|
|
38
|
-
*
|
|
39
|
-
* // Usage
|
|
40
|
-
* const sequence = new PostgresSequence({
|
|
41
|
-
* name: 'user_id_seq',
|
|
42
|
-
* executor: dbExecutor
|
|
43
|
-
* });
|
|
44
|
-
*
|
|
45
|
-
* const nextId = await sequence.next();
|
|
46
|
-
* ```
|
|
47
|
-
*/
|
|
48
|
-
export declare class FabricContractSequence extends Sequence {
|
|
49
|
-
/**
|
|
50
|
-
* @description Creates a new sequence instance
|
|
51
|
-
* @summary Protected constructor that initializes the sequence with the provided options
|
|
52
|
-
*/
|
|
53
|
-
constructor(options: SequenceOptions, adapter: Adapter<any, any, any>);
|
|
54
|
-
/**
|
|
55
|
-
* @description Retrieves the current value of the sequence
|
|
56
|
-
* @summary Gets the current value of the sequence from storage. If the sequence
|
|
57
|
-
* doesn't exist yet, it returns the configured starting value.
|
|
58
|
-
* @return A promise that resolves to the current sequence value
|
|
59
|
-
*/
|
|
60
|
-
current(...args: MaybeContextualArg<any>): Promise<string | number | bigint>;
|
|
61
|
-
/**
|
|
62
|
-
* @description Increments the sequence value
|
|
63
|
-
* @summary Increases the current sequence value by the specified amount and persists
|
|
64
|
-
* the new value to storage. This method handles both numeric and BigInt sequence types.
|
|
65
|
-
* @param {string | number | bigint} current - The current value of the sequence
|
|
66
|
-
* @param {number} [count] - Optional amount to increment by, defaults to the sequence's incrementBy value
|
|
67
|
-
* @return A promise that resolves to the new sequence value after incrementing
|
|
68
|
-
*/
|
|
69
|
-
protected increment(count: number | undefined, ctx: Context<any>): Promise<string | number | bigint>;
|
|
70
|
-
/**
|
|
71
|
-
* @description Ensures the sequence exists and is at least a given value
|
|
72
|
-
* @summary Fabric needs to respect segregated/private/shared storage rules when creating
|
|
73
|
-
* sequences (for example for persistent @version(true) and @sequence()).
|
|
74
|
-
*/
|
|
75
|
-
ensureAtLeast(value: string | number | bigint, ...args: MaybeContextualArg<any>): Promise<string | number | bigint>;
|
|
76
|
-
/**
|
|
77
|
-
* @description Replicates the sequence to all segregated collections
|
|
78
|
-
* @summary When a model uses privateData or sharedData decorators, its sequence must be
|
|
79
|
-
* replicated to all collections the model is stored in. This ensures clients with access
|
|
80
|
-
* to only one collection can still read the model's sequence, while clients without
|
|
81
|
-
* access to any collection won't see the sequence on the public chain.
|
|
82
|
-
* @param {Context<any>} ctx - The execution context
|
|
83
|
-
* @param {SequenceModel} seq - The sequence model to replicate
|
|
84
|
-
*/
|
|
85
|
-
private writeSequenceToCollections;
|
|
86
|
-
private replicateToSegregatedCollections;
|
|
87
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { CouchDBAdapter, MangoQuery } from "@decaf-ts/for-couchdb";
|
|
2
|
-
import { Model } from "@decaf-ts/decorator-validation";
|
|
3
|
-
import { FabricContractContext } from "./ContractContext";
|
|
4
|
-
import { CouchDBStatement } from "@decaf-ts/for-couchdb";
|
|
5
|
-
import { AdapterFlags, MaybeContextualArg } from "@decaf-ts/core";
|
|
6
|
-
import { Constructor } from "@decaf-ts/decoration";
|
|
7
|
-
/**
|
|
8
|
-
* @description Statement wrapper for executing Mango queries within Fabric contracts
|
|
9
|
-
* @summary Bridges CouchDB-style queries to Fabric via the FabricContractAdapter, handling identity and primary key projection when needed.
|
|
10
|
-
* @template M - Model type this statement operates on
|
|
11
|
-
* @template R - Result type returned by the statement
|
|
12
|
-
* @param {FabricContractAdapter} adapter - The Fabric contract adapter used for raw execution
|
|
13
|
-
* @param {FabricContractContext} ctx - The Fabric contract context carrying stub and identity
|
|
14
|
-
* @return {void}
|
|
15
|
-
* @class FabricStatement
|
|
16
|
-
* @example
|
|
17
|
-
* const stmt = new FabricStatement<MyModel, MyModel[]>(adapter, ctx);
|
|
18
|
-
* const result = await stmt.raw<MyModel[]>({ selector: { type: 'MyModel' } });
|
|
19
|
-
* @mermaid
|
|
20
|
-
* sequenceDiagram
|
|
21
|
-
* participant App
|
|
22
|
-
* participant Statement
|
|
23
|
-
* participant Adapter
|
|
24
|
-
* participant Ledger
|
|
25
|
-
* App->>Statement: raw({ selector })
|
|
26
|
-
* Statement->>Adapter: adapter.raw(mango, true, ctx)
|
|
27
|
-
* Adapter->>Ledger: Evaluate query
|
|
28
|
-
* Adapter-->>Statement: rows
|
|
29
|
-
* Statement-->>App: models
|
|
30
|
-
*/
|
|
31
|
-
export declare class FabricStatement<M extends Model, R> extends CouchDBStatement<M, CouchDBAdapter<any, void, FabricContractContext>, R> {
|
|
32
|
-
constructor(adapter: CouchDBAdapter<any, void, FabricContractContext>, overrides?: Partial<AdapterFlags>);
|
|
33
|
-
protected executionPrefix(method: any, ...args: MaybeContextualArg<FabricContractContext>): Promise<[Constructor<M>, ...any[], any]>;
|
|
34
|
-
protected build(): MangoQuery;
|
|
35
|
-
execute(...args: MaybeContextualArg<FabricContractContext>): Promise<R>;
|
|
36
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Context as Ctx, Contract } from "fabric-contract-api";
|
|
2
|
-
import { MaybeContextualArg, MethodOrOperation } from "@decaf-ts/core";
|
|
3
|
-
import { FabricContextualizedArgs, FabricContractAdapter } from "./ContractAdapter";
|
|
4
|
-
import { healthcheck } from "../shared/index";
|
|
5
|
-
import { FabricContractContext } from "./ContractContext";
|
|
6
|
-
export declare class MigrationContract extends Contract {
|
|
7
|
-
private _adapter?;
|
|
8
|
-
protected initialized: boolean;
|
|
9
|
-
constructor();
|
|
10
|
-
protected get adapter(): FabricContractAdapter;
|
|
11
|
-
migrate(context: Ctx, reference: string, migrationArgs?: string): Promise<void>;
|
|
12
|
-
protected getRegisteredMigrations(context: FabricContractContext): Array<{
|
|
13
|
-
class: any;
|
|
14
|
-
reference: string;
|
|
15
|
-
flavour: string;
|
|
16
|
-
}>;
|
|
17
|
-
protected init(ctx: Ctx | FabricContractContext): Promise<void>;
|
|
18
|
-
healthcheck(ctx: Ctx | FabricContractContext): Promise<string | healthcheck>;
|
|
19
|
-
protected logCtx<ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg<FabricContractContext, ARGS>, operation: METHOD): FabricContextualizedArgs<ARGS, METHOD extends string ? true : false>;
|
|
20
|
-
protected logCtx<ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg<FabricContractContext, ARGS>, operation: METHOD, allowCreate: false): FabricContextualizedArgs<ARGS, METHOD extends string ? true : false>;
|
|
21
|
-
protected logCtx<ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg<FabricContractContext, ARGS>, operation: METHOD, allowCreate: true): Promise<FabricContextualizedArgs<ARGS, METHOD extends string ? true : false>>;
|
|
22
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { BaseModel } from "@decaf-ts/core";
|
|
2
|
-
import { type ModelArg } from "@decaf-ts/decorator-validation";
|
|
3
|
-
export declare class CustomizableSequence extends BaseModel {
|
|
4
|
-
/**
|
|
5
|
-
* @description The unique identifier for the sequence
|
|
6
|
-
* @summary Primary key for the sequence record
|
|
7
|
-
*/
|
|
8
|
-
id: string;
|
|
9
|
-
/**
|
|
10
|
-
* @description The current value of the sequence
|
|
11
|
-
* @summary Current sequence value that can be incremented
|
|
12
|
-
*/
|
|
13
|
-
current: string | number;
|
|
14
|
-
constructor(seq?: ModelArg<CustomizableSequence>);
|
|
15
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { AuthHandler, AuthorizationError } from "@decaf-ts/core";
|
|
2
|
-
export declare function hlfAllowIf(handler: AuthHandler, ...argz: any[]): (obj: object, propertyKey?: any, descriptor?: any) => void;
|
|
3
|
-
export declare function mspHandler(...args: any[]): AuthorizationError | undefined;
|
|
4
|
-
export declare function namespaceHandler(...args: any[]): AuthorizationError | undefined;
|
|
5
|
-
export declare function onlyMsp(msp: string): (obj: object, propertyKey?: any, descriptor?: any) => void;
|
|
6
|
-
export declare function onlyNamespaceRole(namespace: string, role?: string): (obj: object, propertyKey?: any, descriptor?: any) => void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./decorators";
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import "../../shared/overrides";
|
|
2
|
-
import { FabricContextualizedArgs, FabricContractAdapter } from "../ContractAdapter";
|
|
3
|
-
import { Context as Ctx, Contract } from "fabric-contract-api";
|
|
4
|
-
import { Model } from "@decaf-ts/decorator-validation";
|
|
5
|
-
import { AllOperationKeys, Condition, ContextualArgs, DirectionLimitOffset, EventIds, MaybeContextualArg, MethodOrOperation, Observer, OrderDirection, PersistenceObserver, SerializedPage } from "@decaf-ts/core";
|
|
6
|
-
import { FabricContractRepository } from "../FabricContractRepository";
|
|
7
|
-
import { DeterministicSerializer } from "../../shared/DeterministicSerializer";
|
|
8
|
-
import { MangoQuery } from "@decaf-ts/for-couchdb";
|
|
9
|
-
import { Checkable, healthcheck } from "../../shared/interfaces/Checkable";
|
|
10
|
-
import { Constructor } from "@decaf-ts/decoration";
|
|
11
|
-
import { FabricContractContext } from "../ContractContext";
|
|
12
|
-
import { PrimaryKeyType } from "@decaf-ts/db-decorators";
|
|
13
|
-
/**
|
|
14
|
-
* @description Base contract class for CRUD operations in Fabric chaincode
|
|
15
|
-
* @summary Provides standard create, read, update, and delete operations for models in Fabric chaincode
|
|
16
|
-
* @template M - Type extending Model
|
|
17
|
-
* @class FabricCrudContract
|
|
18
|
-
* @extends {Contract}
|
|
19
|
-
* @example
|
|
20
|
-
* ```typescript
|
|
21
|
-
* // Define a model
|
|
22
|
-
* @table('assets')
|
|
23
|
-
* class Asset extends Model {
|
|
24
|
-
* @id()
|
|
25
|
-
* id: string;
|
|
26
|
-
*
|
|
27
|
-
* @property()
|
|
28
|
-
* data: string;
|
|
29
|
-
* }
|
|
30
|
-
*
|
|
31
|
-
* // Create a contract that extends FabricCrudContract
|
|
32
|
-
* export class AssetContract extends FabricCrudContract<Asset> {
|
|
33
|
-
* constructor() {
|
|
34
|
-
* super('AssetContract', Asset);
|
|
35
|
-
* }
|
|
36
|
-
*
|
|
37
|
-
* // Add custom methods as needed
|
|
38
|
-
* async getAssetHistory(ctx: Context, id: string): Promise<any[]> {
|
|
39
|
-
* // Custom implementation
|
|
40
|
-
* }
|
|
41
|
-
* }
|
|
42
|
-
* ```
|
|
43
|
-
* @mermaid
|
|
44
|
-
* sequenceDiagram
|
|
45
|
-
* participant Client
|
|
46
|
-
* participant Contract
|
|
47
|
-
* participant Repository
|
|
48
|
-
* participant Adapter
|
|
49
|
-
* participant StateDB
|
|
50
|
-
*
|
|
51
|
-
* Client->>Contract: create(ctx, model)
|
|
52
|
-
* Contract->>Repository: repository(ctx)
|
|
53
|
-
* Contract->>Repository: create(model, ctx)
|
|
54
|
-
* Repository->>Adapter: create(tableName, id, record, transient, ctx)
|
|
55
|
-
* Adapter->>StateDB: putState(id, serializedData)
|
|
56
|
-
* StateDB-->>Adapter: Success
|
|
57
|
-
* Adapter-->>Repository: record
|
|
58
|
-
* Repository-->>Contract: model
|
|
59
|
-
* Contract-->>Client: model
|
|
60
|
-
*/
|
|
61
|
-
export declare abstract class FabricCrudContract<M extends Model> extends Contract implements Checkable, PersistenceObserver<FabricContractContext>, Observer<[
|
|
62
|
-
table: Constructor<M> | string,
|
|
63
|
-
event: AllOperationKeys,
|
|
64
|
-
id: EventIds,
|
|
65
|
-
...args: ContextualArgs<FabricContractContext>
|
|
66
|
-
]> {
|
|
67
|
-
protected readonly clazz: Constructor<M>;
|
|
68
|
-
/**
|
|
69
|
-
* @description Shared adapter instance for all contract instances
|
|
70
|
-
*/
|
|
71
|
-
protected static adapter: FabricContractAdapter;
|
|
72
|
-
protected static readonly serializer: DeterministicSerializer<Model<false>>;
|
|
73
|
-
protected initialized: boolean;
|
|
74
|
-
private _repo?;
|
|
75
|
-
protected get repo(): FabricContractRepository<M>;
|
|
76
|
-
/**
|
|
77
|
-
* @description Creates a new FabricCrudContract instance
|
|
78
|
-
* @summary Initializes a contract with a name and model class
|
|
79
|
-
* @param {string} name - The name of the contract
|
|
80
|
-
* @param {Constructor<M>} clazz - The model constructor
|
|
81
|
-
*/
|
|
82
|
-
protected constructor(name: string, clazz: Constructor<M>);
|
|
83
|
-
refresh(table: Constructor<M> | string, event: AllOperationKeys, id: EventIds, ...args: ContextualArgs<FabricContractContext>): Promise<void>;
|
|
84
|
-
listBy(ctx: Ctx | FabricContractContext, key: string | keyof M, order: string, ...args: any[]): Promise<M[] | string>;
|
|
85
|
-
paginateBy(ctx: Ctx | FabricContractContext, key: string | keyof M, order: string, ref?: Omit<DirectionLimitOffset, "direction"> | string, ...args: any[]): Promise<SerializedPage<M> | string>;
|
|
86
|
-
page(ctx: Ctx | FabricContractContext, value: string, direction?: string | OrderDirection, ref?: Omit<DirectionLimitOffset, "direction"> | string, ...args: any[]): Promise<SerializedPage<M> | string>;
|
|
87
|
-
findOneBy(ctx: Ctx | FabricContractContext, key: string | keyof M, value: any, ...args: any[]): Promise<M | string>;
|
|
88
|
-
statement(ctx: Ctx | FabricContractContext, method: string, ...args: any[]): Promise<any>;
|
|
89
|
-
countOf(ctx: Ctx | FabricContractContext, key?: string | keyof M, ...args: any[]): Promise<number | string>;
|
|
90
|
-
maxOf(ctx: Ctx | FabricContractContext, key: string | keyof M, ...args: any[]): Promise<M[keyof M] | string>;
|
|
91
|
-
minOf(ctx: Ctx | FabricContractContext, key: string | keyof M, ...args: any[]): Promise<M[keyof M] | string>;
|
|
92
|
-
avgOf(ctx: Ctx | FabricContractContext, key: string | keyof M, ...args: any[]): Promise<number | string>;
|
|
93
|
-
sumOf(ctx: Ctx | FabricContractContext, key: string | keyof M, ...args: any[]): Promise<number | string>;
|
|
94
|
-
distinctOf(ctx: Ctx | FabricContractContext, key: string | keyof M, ...args: any[]): Promise<M[keyof M][] | string>;
|
|
95
|
-
groupOf(ctx: Ctx | FabricContractContext, key: string | keyof M, ...args: any[]): Promise<Record<string, M[]> | string>;
|
|
96
|
-
/**
|
|
97
|
-
* @description Creates a single model in the state database
|
|
98
|
-
* @summary Delegates to the repository's create method
|
|
99
|
-
* @param {Ctx} ctx - The Fabric chaincode context
|
|
100
|
-
* @param {M} model - The model to create
|
|
101
|
-
* @param {...any[]} args - Additional arguments
|
|
102
|
-
* @return {Promise<M>} Promise resolving to the created model
|
|
103
|
-
*/
|
|
104
|
-
create(context: Ctx | FabricContractContext, model: string | M, ...args: any[]): Promise<string | M>;
|
|
105
|
-
/**
|
|
106
|
-
* @description Reads a single model from the state database
|
|
107
|
-
* @summary Delegates to the repository's read method
|
|
108
|
-
* @param {Ctx} ctx - The Fabric chaincode context
|
|
109
|
-
* @param {string | number} key - The key of the model to read
|
|
110
|
-
* @param {...any[]} args - Additional arguments
|
|
111
|
-
* @return {Promise<M>} Promise resolving to the retrieved model
|
|
112
|
-
*/
|
|
113
|
-
read(ctx: Ctx | FabricContractContext, key: PrimaryKeyType | string, ...args: any[]): Promise<M | string>;
|
|
114
|
-
protected getTransientData(ctx: FabricContractContext): any;
|
|
115
|
-
/**
|
|
116
|
-
* @description Updates a single model in the state database
|
|
117
|
-
* @summary Delegates to the repository's update method
|
|
118
|
-
* @param {Ctx} ctx - The Fabric chaincode context
|
|
119
|
-
* @param {M} model - The model to update
|
|
120
|
-
* @param {...any[]} args - Additional arguments
|
|
121
|
-
* @return {Promise<M>} Promise resolving to the updated model
|
|
122
|
-
*/
|
|
123
|
-
update(context: Ctx | FabricContractContext, model: string | M, ...args: any[]): Promise<string | M>;
|
|
124
|
-
/**
|
|
125
|
-
* @description Deletes a single model from the state database
|
|
126
|
-
* @summary Delegates to the repository's delete method
|
|
127
|
-
* @param {Ctx} ctx - The Fabric chaincode context
|
|
128
|
-
* @param {string | number} key - The key of the model to delete
|
|
129
|
-
* @param {...any[]} args - Additional arguments
|
|
130
|
-
* @return {Promise<M>} Promise resolving to the deleted model
|
|
131
|
-
*/
|
|
132
|
-
delete(ctx: Ctx | FabricContractContext, key: PrimaryKeyType | string, ...args: any[]): Promise<M | string>;
|
|
133
|
-
/**
|
|
134
|
-
* @description Deletes multiple models from the state database
|
|
135
|
-
* @summary Delegates to the repository's deleteAll method
|
|
136
|
-
* @param {string[] | number[]} keys - The keys of the models to delete
|
|
137
|
-
* @param {Ctx} ctx - The Fabric chaincode context
|
|
138
|
-
* @param {...any[]} args - Additional arguments
|
|
139
|
-
* @return {Promise<M[]>} Promise resolving to the deleted models
|
|
140
|
-
*/
|
|
141
|
-
deleteAll(ctx: Ctx | FabricContractContext, keys: PrimaryKeyType[] | string, ...args: any[]): Promise<M[] | string>;
|
|
142
|
-
/**
|
|
143
|
-
* @description Reads multiple models from the state database
|
|
144
|
-
* @summary Delegates to the repository's readAll method
|
|
145
|
-
* @param {Ctx} ctx - The Fabric chaincode context
|
|
146
|
-
* @param {string[] | number[]} keys - The keys of the models to read
|
|
147
|
-
* @param {...any[]} args - Additional arguments
|
|
148
|
-
* @return {Promise<M[]>} Promise resolving to the retrieved models
|
|
149
|
-
*/
|
|
150
|
-
readAll(ctx: Ctx | FabricContractContext, keys: PrimaryKeyType[] | string, ...args: any[]): Promise<M[] | string>;
|
|
151
|
-
/**
|
|
152
|
-
* @description Updates multiple models in the state database
|
|
153
|
-
* @summary Delegates to the repository's updateAll method
|
|
154
|
-
* @param {Ctx} ctx - The Fabric chaincode context
|
|
155
|
-
* @param {M[]} models - The models to update
|
|
156
|
-
* @param {...any[]} args - Additional arguments
|
|
157
|
-
* @return {Promise<M[]>} Promise resolving to the updated models
|
|
158
|
-
*/
|
|
159
|
-
updateAll(context: Ctx | FabricContractContext, models: string | M[], ...args: any[]): Promise<string | M[]>;
|
|
160
|
-
/**
|
|
161
|
-
* @description Executes a query with the specified conditions and options.
|
|
162
|
-
* @summary Provides a simplified way to query the database with common query parameters.
|
|
163
|
-
* @param {Condition<M>} condition - The condition to filter records.
|
|
164
|
-
* @param orderBy - The field to order results by.
|
|
165
|
-
* @param {OrderDirection} [order=OrderDirection.ASC] - The sort direction.
|
|
166
|
-
* @param {OrderDirection} [order=OrderDirection.ASC] - The sort direction.
|
|
167
|
-
* @param {number} [limit] - Optional maximum number of results to return.
|
|
168
|
-
* @param {number} [skip] - Optional number of results to skip.
|
|
169
|
-
* @return {Promise<M[]>} The query results as model instances.
|
|
170
|
-
*/
|
|
171
|
-
query(context: Ctx | FabricContractContext, condition: Condition<M> | string, orderBy: string | keyof M, order?: OrderDirection | string, limit?: number, skip?: number, ...args: any[]): Promise<M[] | string>;
|
|
172
|
-
/**
|
|
173
|
-
* @description Executes a raw query against the state database
|
|
174
|
-
* @summary Delegates to the repository's raw method
|
|
175
|
-
* @param {Ctx} ctx - The Fabric chaincode context
|
|
176
|
-
* @param {any} rawInput - The query to execute
|
|
177
|
-
* @param {boolean} docsOnly - Whether to return only documents
|
|
178
|
-
* @param {...any[]} args - Additional arguments
|
|
179
|
-
* @return {Promise<any>} Promise resolving to the query results
|
|
180
|
-
*/
|
|
181
|
-
raw(ctx: Ctx | FabricContractContext, rawInput: MangoQuery, docsOnly: boolean, ...args: any[]): Promise<any>;
|
|
182
|
-
protected serialize(model: M): string;
|
|
183
|
-
protected deserialize<M extends Model>(str: string): M;
|
|
184
|
-
protected init(ctx: Ctx | FabricContractContext): Promise<void>;
|
|
185
|
-
healthcheck(ctx: Ctx | FabricContractContext): Promise<string | healthcheck>;
|
|
186
|
-
/**
|
|
187
|
-
* @description Creates multiple models in the state database
|
|
188
|
-
* @summary Delegates to the repository's createAll method
|
|
189
|
-
* @param {Ctx} ctx - The Fabric chaincode context
|
|
190
|
-
* @param {M[]} models - The models to create
|
|
191
|
-
* @param {...any[]} args - Additional arguments
|
|
192
|
-
* @return {Promise<M[]>} Promise resolving to the created models
|
|
193
|
-
*/
|
|
194
|
-
createAll(context: Ctx | FabricContractContext, models: string | M[], ...args: any[]): Promise<string | M[]>;
|
|
195
|
-
protected ensureMirrorWritePermissions(ctx: FabricContractContext): void;
|
|
196
|
-
protected logCtx<ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg<FabricContractContext, ARGS>, operation: METHOD): FabricContextualizedArgs<ARGS, METHOD extends string ? true : false>;
|
|
197
|
-
protected logCtx<ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg<FabricContractContext, ARGS>, operation: METHOD, allowCreate: false): FabricContextualizedArgs<ARGS, METHOD extends string ? true : false>;
|
|
198
|
-
protected logCtx<ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg<FabricContractContext, ARGS>, operation: METHOD, allowCreate: true): Promise<FabricContextualizedArgs<ARGS, METHOD extends string ? true : false>>;
|
|
199
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { FabricCrudContract } from "./crud-contract";
|
|
2
|
-
import { Model } from "@decaf-ts/decorator-validation";
|
|
3
|
-
import { Context as Ctx } from "fabric-contract-api";
|
|
4
|
-
import { Constructor } from "@decaf-ts/decoration";
|
|
5
|
-
/**
|
|
6
|
-
* @description CRUD contract variant that serializes/deserializes payloads
|
|
7
|
-
* @summary Exposes the same CRUD operations as FabricCrudContract but takes and returns JSON strings to facilitate simple client interactions.
|
|
8
|
-
* @template M - Model type handled by this contract
|
|
9
|
-
* @param {string} name - The contract name
|
|
10
|
-
* @param {Constructor<M>} clazz - The model constructor used to instantiate models from JSON
|
|
11
|
-
* @return {void}
|
|
12
|
-
* @class SerializedCrudContract
|
|
13
|
-
* @example
|
|
14
|
-
* const contract = new SerializedCrudContract<MyModel>('MyModelContract', MyModel);
|
|
15
|
-
* // Client submits JSON string payloads and receives JSON string responses
|
|
16
|
-
*/
|
|
17
|
-
export declare class SerializedCrudContract<M extends Model> extends FabricCrudContract<M> {
|
|
18
|
-
constructor(name: string, clazz: Constructor<M>);
|
|
19
|
-
create(ctx: Ctx, model: string): Promise<string>;
|
|
20
|
-
read(ctx: Ctx, key: string): Promise<string>;
|
|
21
|
-
update(ctx: Ctx, model: string): Promise<string>;
|
|
22
|
-
delete(ctx: Ctx, key: string): Promise<string>;
|
|
23
|
-
deleteAll(ctx: Ctx, keys: string): Promise<string>;
|
|
24
|
-
readAll(ctx: Ctx, keys: string): Promise<string>;
|
|
25
|
-
updateAll(ctx: Ctx, models: string): Promise<string>;
|
|
26
|
-
statement(ctx: Ctx, method: string, args: string): Promise<string>;
|
|
27
|
-
listBy(ctx: Ctx, key: string, order: string): Promise<string>;
|
|
28
|
-
paginateBy(ctx: Ctx, key: string, order: string, ref: string): Promise<string>;
|
|
29
|
-
page(ctx: Ctx, value: string, direction: string, ref: string): Promise<string>;
|
|
30
|
-
findOneBy(ctx: Ctx, key: string, value: string): Promise<string>;
|
|
31
|
-
query(ctx: Ctx, condition: string, orderBy: string, order: string, limit?: number, skip?: number): Promise<string>;
|
|
32
|
-
init(ctx: Ctx): Promise<void>;
|
|
33
|
-
healthcheck(ctx: Ctx): Promise<string>;
|
|
34
|
-
createAll(context: Ctx, models: string): Promise<string>;
|
|
35
|
-
countOf(ctx: Ctx, key?: string): Promise<string>;
|
|
36
|
-
maxOf(ctx: Ctx, key: string): Promise<string>;
|
|
37
|
-
minOf(ctx: Ctx, key: string): Promise<string>;
|
|
38
|
-
avgOf(ctx: Ctx, key: string): Promise<string>;
|
|
39
|
-
sumOf(ctx: Ctx, key: string): Promise<string>;
|
|
40
|
-
distinctOf(ctx: Ctx, key: string): Promise<string>;
|
|
41
|
-
groupOf(ctx: Ctx, key: string): Promise<string>;
|
|
42
|
-
}
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { Context } from "fabric-contract-api";
|
|
2
|
-
import { Allowance, ERC20Token, ERC20Wallet } from "./models";
|
|
3
|
-
import type { FabricContractContext } from "../ContractContext";
|
|
4
|
-
import { FabricCrudContract } from "../crud/crud-contract";
|
|
5
|
-
/**
|
|
6
|
-
* @description ERC20 token contract base for Hyperledger Fabric
|
|
7
|
-
* @summary Implements ERC20-like token logic using repositories and adapters, providing standard token operations such as balance queries, transfers, approvals, minting and burning.
|
|
8
|
-
* @param {string} name - The contract name used to scope token identity
|
|
9
|
-
* @note https://eips.ethereum.org/EIPS/eip-20
|
|
10
|
-
* @return {void}
|
|
11
|
-
* @class FabricERC20Contract
|
|
12
|
-
* @example
|
|
13
|
-
* class MyTokenContract extends FabricERC20Contract {
|
|
14
|
-
* constructor() { super('MyToken'); }
|
|
15
|
-
* }
|
|
16
|
-
* // The contract exposes methods like Transfer, Approve, Mint, Burn, etc.
|
|
17
|
-
* @mermaid
|
|
18
|
-
* sequenceDiagram
|
|
19
|
-
* participant Client
|
|
20
|
-
* participant Contract
|
|
21
|
-
* participant WalletRepo
|
|
22
|
-
* participant TokenRepo
|
|
23
|
-
* participant Ledger
|
|
24
|
-
* Client->>Contract: Transfer(ctx, to, value)
|
|
25
|
-
* Contract->>WalletRepo: read(from)
|
|
26
|
-
* Contract->>WalletRepo: read(to)
|
|
27
|
-
* Contract->>Ledger: putState(updated balances)
|
|
28
|
-
* Contract-->>Client: success
|
|
29
|
-
*/
|
|
30
|
-
export declare abstract class FabricERC20Contract extends FabricCrudContract<ERC20Wallet> {
|
|
31
|
-
private walletRepository;
|
|
32
|
-
private tokenRepository;
|
|
33
|
-
private allowanceRepository;
|
|
34
|
-
protected constructor(name: string);
|
|
35
|
-
TokenName(context: Context): Promise<string>;
|
|
36
|
-
/**
|
|
37
|
-
* Return the symbol of the token. E.g. “HIX”.
|
|
38
|
-
*
|
|
39
|
-
* @param {Context} context the transaction context
|
|
40
|
-
* @returns {String} Returns the symbol of the token
|
|
41
|
-
*/
|
|
42
|
-
Symbol(context: Context): Promise<string>;
|
|
43
|
-
/**
|
|
44
|
-
* Return the number of decimals the token uses
|
|
45
|
-
* e.g. 8, means to divide the token amount by 100000000 to get its user representation.
|
|
46
|
-
*
|
|
47
|
-
* @param {Context} context the transaction context
|
|
48
|
-
* @returns {Number} Returns the number of decimals
|
|
49
|
-
*/
|
|
50
|
-
Decimals(context: Context): Promise<number>;
|
|
51
|
-
/**
|
|
52
|
-
* Return the total token supply.
|
|
53
|
-
*
|
|
54
|
-
* @param {Context} context the transaction context
|
|
55
|
-
* @returns {Number} Returns the total token supply
|
|
56
|
-
*/
|
|
57
|
-
TotalSupply(context: Context): Promise<number>;
|
|
58
|
-
/**
|
|
59
|
-
* BalanceOf returns the balance of the given account.
|
|
60
|
-
*
|
|
61
|
-
* @param {Context} ctx the transaction context
|
|
62
|
-
* @param {String} owner The owner from which the balance will be retrieved
|
|
63
|
-
* @returns {Number} Returns the account balance
|
|
64
|
-
*/
|
|
65
|
-
BalanceOf(context: Context, owner: string): Promise<number>;
|
|
66
|
-
/**
|
|
67
|
-
* @summary Transfer transfers tokens from client account to recipient account.
|
|
68
|
-
* @description recipient account must be a valid clientID as returned by the ClientAccountID() function.
|
|
69
|
-
*
|
|
70
|
-
* @param {Context} context the transaction context
|
|
71
|
-
* @param {String} to The recipient
|
|
72
|
-
* @param {number} value The amount of token to be transferred
|
|
73
|
-
*
|
|
74
|
-
* @returns {Boolean} Return whether the transfer was successful or not
|
|
75
|
-
*/
|
|
76
|
-
Transfer(context: Context, to: string, value: number): Promise<boolean>;
|
|
77
|
-
/**
|
|
78
|
-
* Transfer `value` amount of tokens from `from` to `to`.
|
|
79
|
-
*
|
|
80
|
-
* @param {Context} context the transaction context
|
|
81
|
-
* @param {String} from The sender
|
|
82
|
-
* @param {String} to The recipient
|
|
83
|
-
* @param {number} value The amount of token to be transferred
|
|
84
|
-
* @returns {Boolean} Return whether the transfer was successful or not
|
|
85
|
-
*/
|
|
86
|
-
TransferFrom(context: Context, from: string, to: string, value: number): Promise<boolean>;
|
|
87
|
-
_transfer(from: string, to: string, value: number, ctx: FabricContractContext): Promise<boolean>;
|
|
88
|
-
/**
|
|
89
|
-
* Allows `spender` to spend `value` amount of tokens from the owner. New Approve calls override the previous allowance.
|
|
90
|
-
* @note https://eips.ethereum.org/EIPS/eip-20
|
|
91
|
-
*
|
|
92
|
-
* @param {Context} ctx the transaction context
|
|
93
|
-
* @param {String} spender The spender
|
|
94
|
-
* @param {number} value The amount of tokens to be approved for transfer
|
|
95
|
-
* @returns {Boolean} Return whether the approval was successful or not
|
|
96
|
-
*/
|
|
97
|
-
Approve(context: Context, spender: string, value: number): Promise<boolean>;
|
|
98
|
-
/**
|
|
99
|
-
* Returns the amount of tokens which ` ` is allowed to withdraw from `owner`.
|
|
100
|
-
*
|
|
101
|
-
* @param {Context} ctx the transaction context
|
|
102
|
-
* @param {String} owner The owner of tokens
|
|
103
|
-
* @param {String} spender The spender who are able to transfer the tokens
|
|
104
|
-
* @returns {number} Return the amount of remaining tokens allowed to spent
|
|
105
|
-
*/
|
|
106
|
-
Allowance(context: Context, owner: string, spender: string): Promise<number>;
|
|
107
|
-
_getAllowance(owner: string, spender: string, ctx: FabricContractContext): Promise<Allowance>;
|
|
108
|
-
/**
|
|
109
|
-
* Set optional infomation for a token.
|
|
110
|
-
*
|
|
111
|
-
* @param {Context} ctx the transaction context
|
|
112
|
-
* @param {String} name The name of the token
|
|
113
|
-
* @param {String} symbol The symbol of the token
|
|
114
|
-
* @param {String} decimals The decimals of the token
|
|
115
|
-
* @param {String} totalSupply The totalSupply of the token
|
|
116
|
-
*/
|
|
117
|
-
Initialize(context: Context, token: ERC20Token): Promise<boolean>;
|
|
118
|
-
CheckInitialized(context: Context): Promise<void>;
|
|
119
|
-
/**
|
|
120
|
-
* Mint creates new tokens and adds them to minter's account balance
|
|
121
|
-
*
|
|
122
|
-
* @param {Context} context the transaction context
|
|
123
|
-
* @param {number} amount amount of tokens to be minted
|
|
124
|
-
* @returns {Object} The balance
|
|
125
|
-
*/
|
|
126
|
-
Mint(context: Context, amount: number): Promise<void>;
|
|
127
|
-
/**
|
|
128
|
-
* Burn redeem tokens from minter's account balance
|
|
129
|
-
*
|
|
130
|
-
* @param {Context} context the transaction context
|
|
131
|
-
* @param {number} amount amount of tokens to be burned
|
|
132
|
-
* @returns {Object} The balance
|
|
133
|
-
*/
|
|
134
|
-
Burn(context: Context, amount: number): Promise<void>;
|
|
135
|
-
/**
|
|
136
|
-
* BurnFrom redeem tokens from account allowence and balance
|
|
137
|
-
*
|
|
138
|
-
* @param {Context} context the transaction context
|
|
139
|
-
* @param {number} account account from where tokens will be burned
|
|
140
|
-
* @param {number} amount amount of tokens to be burned
|
|
141
|
-
* @returns {Object} The balance
|
|
142
|
-
*/
|
|
143
|
-
BurnFrom(context: Context, account: string, amount: number): Promise<void>;
|
|
144
|
-
/**
|
|
145
|
-
* ClientAccountBalance returns the balance of the requesting client's account.
|
|
146
|
-
*
|
|
147
|
-
* @param {Context} context the transaction context
|
|
148
|
-
* @returns {Number} Returns the account balance
|
|
149
|
-
*/
|
|
150
|
-
ClientAccountBalance(context: Context): Promise<number>;
|
|
151
|
-
ClientAccountID(context: Context): Promise<string>;
|
|
152
|
-
}
|