@decaf-ts/for-fabric 0.0.2
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/LICENSE.md +22 -0
- package/README.md +647 -0
- package/dist/for-fabric.cjs +6223 -0
- package/dist/for-fabric.esm.cjs +6180 -0
- package/lib/client/FabricClientAdapter.cjs +760 -0
- package/lib/client/FabricClientAdapter.d.ts +381 -0
- package/lib/client/FabricClientDispatch.cjs +186 -0
- package/lib/client/FabricClientDispatch.d.ts +125 -0
- package/lib/client/FabricClientRepository.cjs +131 -0
- package/lib/client/FabricClientRepository.d.ts +100 -0
- package/lib/client/erc20/erc20ClientRepository.cjs +343 -0
- package/lib/client/erc20/erc20ClientRepository.d.ts +254 -0
- package/lib/client/fabric-fs.cjs +234 -0
- package/lib/client/fabric-fs.d.ts +92 -0
- package/lib/client/index.cjs +30 -0
- package/lib/client/index.d.ts +13 -0
- package/lib/client/logging.cjs +102 -0
- package/lib/client/logging.d.ts +60 -0
- package/lib/client/services/LoggedService.cjs +47 -0
- package/lib/client/services/LoggedService.d.ts +42 -0
- package/lib/client/services/constants.cjs +3 -0
- package/lib/client/services/constants.d.ts +15 -0
- package/lib/client/services/enrollementService.cjs +344 -0
- package/lib/client/services/enrollementService.d.ts +176 -0
- package/lib/client/services/index.cjs +18 -0
- package/lib/client/services/index.d.ts +1 -0
- package/lib/contracts/ContractAdapter.cjs +730 -0
- package/lib/contracts/ContractAdapter.d.ts +296 -0
- package/lib/contracts/ContractContext.cjs +85 -0
- package/lib/contracts/ContractContext.d.ts +64 -0
- package/lib/contracts/ContractPrivateDataAdapter.cjs +281 -0
- package/lib/contracts/ContractPrivateDataAdapter.d.ts +74 -0
- package/lib/contracts/FabricConstruction.cjs +441 -0
- package/lib/contracts/FabricConstruction.d.ts +304 -0
- package/lib/contracts/FabricContractRepository.cjs +306 -0
- package/lib/contracts/FabricContractRepository.d.ts +162 -0
- package/lib/contracts/FabricContractRepositoryObservableHandler.cjs +85 -0
- package/lib/contracts/FabricContractRepositoryObservableHandler.d.ts +62 -0
- package/lib/contracts/FabricContractSequence.cjs +139 -0
- package/lib/contracts/FabricContractSequence.d.ts +61 -0
- package/lib/contracts/FabricContractStatement.cjs +119 -0
- package/lib/contracts/FabricContractStatement.d.ts +34 -0
- package/lib/contracts/PrivateSequence.cjs +36 -0
- package/lib/contracts/PrivateSequence.d.ts +15 -0
- package/lib/contracts/crud/crud-contract.cjs +257 -0
- package/lib/contracts/crud/crud-contract.d.ts +168 -0
- package/lib/contracts/crud/index.cjs +19 -0
- package/lib/contracts/crud/index.d.ts +2 -0
- package/lib/contracts/crud/serialized-crud-contract.cjs +172 -0
- package/lib/contracts/crud/serialized-crud-contract.d.ts +37 -0
- package/lib/contracts/erc20/erc20contract.cjs +569 -0
- package/lib/contracts/erc20/erc20contract.d.ts +151 -0
- package/lib/contracts/erc20/index.cjs +21 -0
- package/lib/contracts/erc20/index.d.ts +2 -0
- package/lib/contracts/erc20/models.cjs +209 -0
- package/lib/contracts/erc20/models.d.ts +114 -0
- package/lib/contracts/index.cjs +32 -0
- package/lib/contracts/index.d.ts +15 -0
- package/lib/contracts/logging.cjs +96 -0
- package/lib/contracts/logging.d.ts +49 -0
- package/lib/contracts/private-data.cjs +121 -0
- package/lib/contracts/private-data.d.ts +16 -0
- package/lib/contracts/types.cjs +3 -0
- package/lib/contracts/types.d.ts +26 -0
- package/lib/esm/client/FabricClientAdapter.d.ts +381 -0
- package/lib/esm/client/FabricClientAdapter.js +723 -0
- package/lib/esm/client/FabricClientDispatch.d.ts +125 -0
- package/lib/esm/client/FabricClientDispatch.js +182 -0
- package/lib/esm/client/FabricClientRepository.d.ts +100 -0
- package/lib/esm/client/FabricClientRepository.js +127 -0
- package/lib/esm/client/erc20/erc20ClientRepository.d.ts +254 -0
- package/lib/esm/client/erc20/erc20ClientRepository.js +339 -0
- package/lib/esm/client/fabric-fs.d.ts +92 -0
- package/lib/esm/client/fabric-fs.js +191 -0
- package/lib/esm/client/index.d.ts +13 -0
- package/lib/esm/client/index.js +14 -0
- package/lib/esm/client/logging.d.ts +60 -0
- package/lib/esm/client/logging.js +98 -0
- package/lib/esm/client/services/LoggedService.d.ts +42 -0
- package/lib/esm/client/services/LoggedService.js +43 -0
- package/lib/esm/client/services/constants.d.ts +15 -0
- package/lib/esm/client/services/constants.js +2 -0
- package/lib/esm/client/services/enrollementService.d.ts +176 -0
- package/lib/esm/client/services/enrollementService.js +337 -0
- package/lib/esm/client/services/index.d.ts +1 -0
- package/lib/esm/client/services/index.js +2 -0
- package/lib/esm/contracts/ContractAdapter.d.ts +296 -0
- package/lib/esm/contracts/ContractAdapter.js +724 -0
- package/lib/esm/contracts/ContractContext.d.ts +64 -0
- package/lib/esm/contracts/ContractContext.js +81 -0
- package/lib/esm/contracts/ContractPrivateDataAdapter.d.ts +74 -0
- package/lib/esm/contracts/ContractPrivateDataAdapter.js +277 -0
- package/lib/esm/contracts/FabricConstruction.d.ts +304 -0
- package/lib/esm/contracts/FabricConstruction.js +433 -0
- package/lib/esm/contracts/FabricContractRepository.d.ts +162 -0
- package/lib/esm/contracts/FabricContractRepository.js +302 -0
- package/lib/esm/contracts/FabricContractRepositoryObservableHandler.d.ts +62 -0
- package/lib/esm/contracts/FabricContractRepositoryObservableHandler.js +81 -0
- package/lib/esm/contracts/FabricContractSequence.d.ts +61 -0
- package/lib/esm/contracts/FabricContractSequence.js +135 -0
- package/lib/esm/contracts/FabricContractStatement.d.ts +34 -0
- package/lib/esm/contracts/FabricContractStatement.js +115 -0
- package/lib/esm/contracts/PrivateSequence.d.ts +15 -0
- package/lib/esm/contracts/PrivateSequence.js +33 -0
- package/lib/esm/contracts/crud/crud-contract.d.ts +168 -0
- package/lib/esm/contracts/crud/crud-contract.js +253 -0
- package/lib/esm/contracts/crud/index.d.ts +2 -0
- package/lib/esm/contracts/crud/index.js +3 -0
- package/lib/esm/contracts/crud/serialized-crud-contract.d.ts +37 -0
- package/lib/esm/contracts/crud/serialized-crud-contract.js +168 -0
- package/lib/esm/contracts/erc20/erc20contract.d.ts +151 -0
- package/lib/esm/contracts/erc20/erc20contract.js +565 -0
- package/lib/esm/contracts/erc20/index.d.ts +2 -0
- package/lib/esm/contracts/erc20/index.js +4 -0
- package/lib/esm/contracts/erc20/models.d.ts +114 -0
- package/lib/esm/contracts/erc20/models.js +206 -0
- package/lib/esm/contracts/index.d.ts +15 -0
- package/lib/esm/contracts/index.js +16 -0
- package/lib/esm/contracts/logging.d.ts +49 -0
- package/lib/esm/contracts/logging.js +92 -0
- package/lib/esm/contracts/private-data.d.ts +16 -0
- package/lib/esm/contracts/private-data.js +113 -0
- package/lib/esm/contracts/types.d.ts +26 -0
- package/lib/esm/contracts/types.js +2 -0
- package/lib/esm/index.d.ts +8 -0
- package/lib/esm/index.js +9 -0
- package/lib/esm/shared/ClientSerializer.d.ts +52 -0
- package/lib/esm/shared/ClientSerializer.js +80 -0
- package/lib/esm/shared/DeterministicSerializer.d.ts +40 -0
- package/lib/esm/shared/DeterministicSerializer.js +50 -0
- package/lib/esm/shared/SimpleDeterministicSerializer.d.ts +7 -0
- package/lib/esm/shared/SimpleDeterministicSerializer.js +42 -0
- package/lib/esm/shared/constants.d.ts +39 -0
- package/lib/esm/shared/constants.js +42 -0
- package/lib/esm/shared/crypto.d.ts +107 -0
- package/lib/esm/shared/crypto.js +331 -0
- package/lib/esm/shared/decorators.d.ts +24 -0
- package/lib/esm/shared/decorators.js +98 -0
- package/lib/esm/shared/erc20/erc20-constants.d.ts +25 -0
- package/lib/esm/shared/erc20/erc20-constants.js +27 -0
- package/lib/esm/shared/errors.d.ts +116 -0
- package/lib/esm/shared/errors.js +132 -0
- package/lib/esm/shared/events.d.ts +39 -0
- package/lib/esm/shared/events.js +47 -0
- package/lib/esm/shared/fabric-types.d.ts +33 -0
- package/lib/esm/shared/fabric-types.js +2 -0
- package/lib/esm/shared/index.d.ts +13 -0
- package/lib/esm/shared/index.js +14 -0
- package/lib/esm/shared/interfaces/Checkable.d.ts +21 -0
- package/lib/esm/shared/interfaces/Checkable.js +2 -0
- package/lib/esm/shared/math.d.ts +34 -0
- package/lib/esm/shared/math.js +61 -0
- package/lib/esm/shared/model/Identity.d.ts +42 -0
- package/lib/esm/shared/model/Identity.js +78 -0
- package/lib/esm/shared/model/IdentityCredentials.d.ts +41 -0
- package/lib/esm/shared/model/IdentityCredentials.js +74 -0
- package/lib/esm/shared/model/index.d.ts +1 -0
- package/lib/esm/shared/model/index.js +2 -0
- package/lib/esm/shared/model/utils.d.ts +60 -0
- package/lib/esm/shared/model/utils.js +108 -0
- package/lib/esm/shared/types.d.ts +79 -0
- package/lib/esm/shared/types.js +2 -0
- package/lib/esm/shared/utils.d.ts +55 -0
- package/lib/esm/shared/utils.js +148 -0
- package/lib/index.cjs +25 -0
- package/lib/index.d.ts +8 -0
- package/lib/shared/ClientSerializer.cjs +84 -0
- package/lib/shared/ClientSerializer.d.ts +52 -0
- package/lib/shared/DeterministicSerializer.cjs +54 -0
- package/lib/shared/DeterministicSerializer.d.ts +40 -0
- package/lib/shared/SimpleDeterministicSerializer.cjs +46 -0
- package/lib/shared/SimpleDeterministicSerializer.d.ts +7 -0
- package/lib/shared/constants.cjs +45 -0
- package/lib/shared/constants.d.ts +39 -0
- package/lib/shared/crypto.cjs +369 -0
- package/lib/shared/crypto.d.ts +107 -0
- package/lib/shared/decorators.cjs +105 -0
- package/lib/shared/decorators.d.ts +24 -0
- package/lib/shared/erc20/erc20-constants.cjs +30 -0
- package/lib/shared/erc20/erc20-constants.d.ts +25 -0
- package/lib/shared/errors.cjs +142 -0
- package/lib/shared/errors.d.ts +116 -0
- package/lib/shared/events.cjs +51 -0
- package/lib/shared/events.d.ts +39 -0
- package/lib/shared/fabric-types.cjs +4 -0
- package/lib/shared/fabric-types.d.ts +33 -0
- package/lib/shared/index.cjs +30 -0
- package/lib/shared/index.d.ts +13 -0
- package/lib/shared/interfaces/Checkable.cjs +3 -0
- package/lib/shared/interfaces/Checkable.d.ts +21 -0
- package/lib/shared/math.cjs +66 -0
- package/lib/shared/math.d.ts +34 -0
- package/lib/shared/model/Identity.cjs +81 -0
- package/lib/shared/model/Identity.d.ts +42 -0
- package/lib/shared/model/IdentityCredentials.cjs +77 -0
- package/lib/shared/model/IdentityCredentials.d.ts +41 -0
- package/lib/shared/model/index.cjs +18 -0
- package/lib/shared/model/index.d.ts +1 -0
- package/lib/shared/model/utils.cjs +114 -0
- package/lib/shared/model/utils.d.ts +60 -0
- package/lib/shared/types.cjs +3 -0
- package/lib/shared/types.d.ts +79 -0
- package/lib/shared/utils.cjs +185 -0
- package/lib/shared/utils.d.ts +55 -0
- package/package.json +166 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { Context } from "fabric-contract-api";
|
|
2
|
+
import { Allowance, ERC20Token, ERC20Wallet } from "./models";
|
|
3
|
+
import { FabricCrudContract } from "../crud/crud-contract";
|
|
4
|
+
/**
|
|
5
|
+
* @description ERC20 token contract base for Hyperledger Fabric
|
|
6
|
+
* @summary Implements ERC20-like token logic using repositories and adapters, providing standard token operations such as balance queries, transfers, approvals, minting and burning.
|
|
7
|
+
* @param {string} name - The contract name used to scope token identity
|
|
8
|
+
* @note https://eips.ethereum.org/EIPS/eip-20
|
|
9
|
+
* @return {void}
|
|
10
|
+
* @class FabricERC20Contract
|
|
11
|
+
* @example
|
|
12
|
+
* class MyTokenContract extends FabricERC20Contract {
|
|
13
|
+
* constructor() { super('MyToken'); }
|
|
14
|
+
* }
|
|
15
|
+
* // The contract exposes methods like Transfer, Approve, Mint, Burn, etc.
|
|
16
|
+
* @mermaid
|
|
17
|
+
* sequenceDiagram
|
|
18
|
+
* participant Client
|
|
19
|
+
* participant Contract
|
|
20
|
+
* participant WalletRepo
|
|
21
|
+
* participant TokenRepo
|
|
22
|
+
* participant Ledger
|
|
23
|
+
* Client->>Contract: Transfer(ctx, to, value)
|
|
24
|
+
* Contract->>WalletRepo: read(from)
|
|
25
|
+
* Contract->>WalletRepo: read(to)
|
|
26
|
+
* Contract->>Ledger: putState(updated balances)
|
|
27
|
+
* Contract-->>Client: success
|
|
28
|
+
*/
|
|
29
|
+
export declare abstract class FabricERC20Contract extends FabricCrudContract<ERC20Wallet> {
|
|
30
|
+
private walletRepository;
|
|
31
|
+
private tokenRepository;
|
|
32
|
+
private allowanceRepository;
|
|
33
|
+
protected constructor(name: string);
|
|
34
|
+
TokenName(ctx: Context): Promise<string>;
|
|
35
|
+
/**
|
|
36
|
+
* Return the symbol of the token. E.g. “HIX”.
|
|
37
|
+
*
|
|
38
|
+
* @param {Context} ctx the transaction context
|
|
39
|
+
* @returns {String} Returns the symbol of the token
|
|
40
|
+
*/
|
|
41
|
+
Symbol(ctx: Context): Promise<string>;
|
|
42
|
+
/**
|
|
43
|
+
* Return the number of decimals the token uses
|
|
44
|
+
* e.g. 8, means to divide the token amount by 100000000 to get its user representation.
|
|
45
|
+
*
|
|
46
|
+
* @param {Context} ctx the transaction context
|
|
47
|
+
* @returns {Number} Returns the number of decimals
|
|
48
|
+
*/
|
|
49
|
+
Decimals(ctx: Context): Promise<number>;
|
|
50
|
+
/**
|
|
51
|
+
* Return the total token supply.
|
|
52
|
+
*
|
|
53
|
+
* @param {Context} ctx the transaction context
|
|
54
|
+
* @returns {Number} Returns the total token supply
|
|
55
|
+
*/
|
|
56
|
+
TotalSupply(ctx: Context): Promise<number>;
|
|
57
|
+
/**
|
|
58
|
+
* BalanceOf returns the balance of the given account.
|
|
59
|
+
*
|
|
60
|
+
* @param {Context} ctx the transaction context
|
|
61
|
+
* @param {String} owner The owner from which the balance will be retrieved
|
|
62
|
+
* @returns {Number} Returns the account balance
|
|
63
|
+
*/
|
|
64
|
+
BalanceOf(ctx: Context, owner: string): Promise<number>;
|
|
65
|
+
/**
|
|
66
|
+
* @summary Transfer transfers tokens from client account to recipient account.
|
|
67
|
+
* @description recipient account must be a valid clientID as returned by the ClientAccountID() function.
|
|
68
|
+
*
|
|
69
|
+
* @param {Context} ctx the transaction context
|
|
70
|
+
* @param {String} to The recipient
|
|
71
|
+
* @param {number} value The amount of token to be transferred
|
|
72
|
+
*
|
|
73
|
+
* @returns {Boolean} Return whether the transfer was successful or not
|
|
74
|
+
*/
|
|
75
|
+
Transfer(ctx: Context, to: string, value: number): Promise<boolean>;
|
|
76
|
+
/**
|
|
77
|
+
* Transfer `value` amount of tokens from `from` to `to`.
|
|
78
|
+
*
|
|
79
|
+
* @param {Context} ctx the transaction context
|
|
80
|
+
* @param {String} from The sender
|
|
81
|
+
* @param {String} to The recipient
|
|
82
|
+
* @param {number} value The amount of token to be transferred
|
|
83
|
+
* @returns {Boolean} Return whether the transfer was successful or not
|
|
84
|
+
*/
|
|
85
|
+
TransferFrom(ctx: Context, from: string, to: string, value: number): Promise<boolean>;
|
|
86
|
+
_transfer(ctx: Context, from: string, to: string, value: number): Promise<boolean>;
|
|
87
|
+
/**
|
|
88
|
+
* Allows `spender` to spend `value` amount of tokens from the owner. New Approve calls override the previous allowance.
|
|
89
|
+
* @note https://eips.ethereum.org/EIPS/eip-20
|
|
90
|
+
*
|
|
91
|
+
* @param {Context} ctx the transaction context
|
|
92
|
+
* @param {String} spender The spender
|
|
93
|
+
* @param {number} value The amount of tokens to be approved for transfer
|
|
94
|
+
* @returns {Boolean} Return whether the approval was successful or not
|
|
95
|
+
*/
|
|
96
|
+
Approve(ctx: Context, spender: string, value: number): Promise<boolean>;
|
|
97
|
+
/**
|
|
98
|
+
* Returns the amount of tokens which ` ` is allowed to withdraw from `owner`.
|
|
99
|
+
*
|
|
100
|
+
* @param {Context} ctx the transaction context
|
|
101
|
+
* @param {String} owner The owner of tokens
|
|
102
|
+
* @param {String} spender The spender who are able to transfer the tokens
|
|
103
|
+
* @returns {number} Return the amount of remaining tokens allowed to spent
|
|
104
|
+
*/
|
|
105
|
+
Allowance(ctx: Context, owner: string, spender: string): Promise<number>;
|
|
106
|
+
_getAllowance(ctx: Context, owner: string, spender: string): Promise<Allowance>;
|
|
107
|
+
/**
|
|
108
|
+
* Set optional infomation for a token.
|
|
109
|
+
*
|
|
110
|
+
* @param {Context} ctx the transaction context
|
|
111
|
+
* @param {String} name The name of the token
|
|
112
|
+
* @param {String} symbol The symbol of the token
|
|
113
|
+
* @param {String} decimals The decimals of the token
|
|
114
|
+
* @param {String} totalSupply The totalSupply of the token
|
|
115
|
+
*/
|
|
116
|
+
Initialize(ctx: Context, token: ERC20Token): Promise<boolean>;
|
|
117
|
+
CheckInitialized(ctx: Context): Promise<void>;
|
|
118
|
+
/**
|
|
119
|
+
* Mint creates new tokens and adds them to minter's account balance
|
|
120
|
+
*
|
|
121
|
+
* @param {Context} ctx the transaction context
|
|
122
|
+
* @param {number} amount amount of tokens to be minted
|
|
123
|
+
* @returns {Object} The balance
|
|
124
|
+
*/
|
|
125
|
+
Mint(ctx: Context, amount: number): Promise<void>;
|
|
126
|
+
/**
|
|
127
|
+
* Burn redeem tokens from minter's account balance
|
|
128
|
+
*
|
|
129
|
+
* @param {Context} ctx the transaction context
|
|
130
|
+
* @param {number} amount amount of tokens to be burned
|
|
131
|
+
* @returns {Object} The balance
|
|
132
|
+
*/
|
|
133
|
+
Burn(ctx: Context, amount: number): Promise<void>;
|
|
134
|
+
/**
|
|
135
|
+
* BurnFrom redeem tokens from account allowence and balance
|
|
136
|
+
*
|
|
137
|
+
* @param {Context} ctx the transaction context
|
|
138
|
+
* @param {number} account account from where tokens will be burned
|
|
139
|
+
* @param {number} amount amount of tokens to be burned
|
|
140
|
+
* @returns {Object} The balance
|
|
141
|
+
*/
|
|
142
|
+
BurnFrom(ctx: Context, account: string, amount: number): Promise<void>;
|
|
143
|
+
/**
|
|
144
|
+
* ClientAccountBalance returns the balance of the requesting client's account.
|
|
145
|
+
*
|
|
146
|
+
* @param {Context} ctx the transaction context
|
|
147
|
+
* @returns {Number} Returns the account balance
|
|
148
|
+
*/
|
|
149
|
+
ClientAccountBalance(ctx: Context): Promise<number>;
|
|
150
|
+
ClientAccountID(ctx: Context): Promise<string>;
|
|
151
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.contracts = void 0;
|
|
18
|
+
const erc20contract_1 = require("./erc20contract.cjs");
|
|
19
|
+
__exportStar(require("./../FabricContractStatement.cjs"), exports);
|
|
20
|
+
exports.contracts = [erc20contract_1.FabricERC20Contract];
|
|
21
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvY29udHJhY3RzL2VyYzIwL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsdURBQXNEO0FBRXRELG1FQUEyQztBQUU5QixRQUFBLFNBQVMsR0FBVSxDQUFDLG1DQUFtQixDQUFDLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBGYWJyaWNFUkMyMENvbnRyYWN0IH0gZnJvbSBcIi4vZXJjMjBjb250cmFjdFwiO1xuXG5leHBvcnQgKiBmcm9tIFwiLi4vRmFicmljQ29udHJhY3RTdGF0ZW1lbnRcIjtcblxuZXhwb3J0IGNvbnN0IGNvbnRyYWN0czogYW55W10gPSBbRmFicmljRVJDMjBDb250cmFjdF07XG4iXX0=
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Allowance = exports.ERC20Wallet = exports.ERC20Token = void 0;
|
|
13
|
+
const core_1 = require("@decaf-ts/core");
|
|
14
|
+
const decorator_validation_1 = require("@decaf-ts/decorator-validation");
|
|
15
|
+
/**
|
|
16
|
+
* @description ERC20 token metadata model
|
|
17
|
+
* @summary Represents an ERC20 token definition within the Fabric ERC20 sample, including name, symbol, decimals, and the owning identity. Used to define the unique token managed by the contract.
|
|
18
|
+
* @param {ModelArg<ERC20Token>} [m] - Optional partial data or another instance to initialize the model
|
|
19
|
+
* @return {void}
|
|
20
|
+
* @class ERC20Token
|
|
21
|
+
* @example
|
|
22
|
+
* const token = new ERC20Token({ name: "MyToken", symbol: "MTK", decimals: 18, owner: "x509::..." });
|
|
23
|
+
* // Persist through a repository: await repo.create(token, ctx)
|
|
24
|
+
* @mermaid
|
|
25
|
+
* sequenceDiagram
|
|
26
|
+
* participant App
|
|
27
|
+
* participant Repo
|
|
28
|
+
* participant Adapter
|
|
29
|
+
* App->>Repo: create(new ERC20Token({...}), ctx)
|
|
30
|
+
* Repo->>Adapter: create(table, id=name, record, flags)
|
|
31
|
+
* Adapter-->>Repo: stored
|
|
32
|
+
* Repo-->>App: model
|
|
33
|
+
*/
|
|
34
|
+
let ERC20Token = class ERC20Token extends core_1.BaseModel {
|
|
35
|
+
constructor(m) {
|
|
36
|
+
super(m);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
exports.ERC20Token = ERC20Token;
|
|
40
|
+
__decorate([
|
|
41
|
+
(0, core_1.pk)({ type: "String" })
|
|
42
|
+
/**
|
|
43
|
+
* @description Token unique name
|
|
44
|
+
* @summary Serves as the primary key for the ERC20 token definition; typically a human-readable identifier
|
|
45
|
+
*/
|
|
46
|
+
,
|
|
47
|
+
__metadata("design:type", String)
|
|
48
|
+
], ERC20Token.prototype, "name", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, core_1.column)(),
|
|
51
|
+
(0, decorator_validation_1.required)()
|
|
52
|
+
/**
|
|
53
|
+
* @description Owning identity of the token
|
|
54
|
+
* @summary X.509 subject or MSP identity string that denotes who owns/controls the token definition
|
|
55
|
+
*/
|
|
56
|
+
,
|
|
57
|
+
__metadata("design:type", String)
|
|
58
|
+
], ERC20Token.prototype, "owner", void 0);
|
|
59
|
+
__decorate([
|
|
60
|
+
(0, core_1.column)(),
|
|
61
|
+
(0, decorator_validation_1.required)()
|
|
62
|
+
/**
|
|
63
|
+
* @description Token symbol
|
|
64
|
+
* @summary Short ticker-like symbol used to represent the token (e.g., MTK)
|
|
65
|
+
*/
|
|
66
|
+
,
|
|
67
|
+
__metadata("design:type", String)
|
|
68
|
+
], ERC20Token.prototype, "symbol", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
(0, core_1.column)(),
|
|
71
|
+
(0, decorator_validation_1.required)()
|
|
72
|
+
/**
|
|
73
|
+
* @description Decimal precision for token amounts
|
|
74
|
+
* @summary Number of digits after the decimal separator used when formatting token balances
|
|
75
|
+
*/
|
|
76
|
+
,
|
|
77
|
+
__metadata("design:type", Number)
|
|
78
|
+
], ERC20Token.prototype, "decimals", void 0);
|
|
79
|
+
exports.ERC20Token = ERC20Token = __decorate([
|
|
80
|
+
(0, core_1.table)("erc20_tokens"),
|
|
81
|
+
(0, decorator_validation_1.model)(),
|
|
82
|
+
__metadata("design:paramtypes", [Object])
|
|
83
|
+
], ERC20Token);
|
|
84
|
+
/**
|
|
85
|
+
* @description ERC20 wallet model
|
|
86
|
+
* @summary Represents a holder account for an ERC20 token within the Fabric network, tracking balance and token association.
|
|
87
|
+
* @param {ModelArg<ERC20Wallet>} [m] - Optional partial data or another instance to initialize the model
|
|
88
|
+
* @return {void}
|
|
89
|
+
* @class ERC20Wallet
|
|
90
|
+
* @example
|
|
91
|
+
* const wallet = new ERC20Wallet({ id: "acct1", token: "MyToken", balance: 1000 });
|
|
92
|
+
* // Update balance via repository: await repo.update(wallet, ctx)
|
|
93
|
+
* @mermaid
|
|
94
|
+
* sequenceDiagram
|
|
95
|
+
* participant App
|
|
96
|
+
* participant Repo
|
|
97
|
+
* App->>Repo: read("acct1", ctx)
|
|
98
|
+
* Repo-->>App: ERC20Wallet
|
|
99
|
+
*/
|
|
100
|
+
let ERC20Wallet = class ERC20Wallet extends core_1.BaseModel {
|
|
101
|
+
constructor(m) {
|
|
102
|
+
super(m);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
exports.ERC20Wallet = ERC20Wallet;
|
|
106
|
+
__decorate([
|
|
107
|
+
(0, core_1.pk)({ type: "String" })
|
|
108
|
+
/**
|
|
109
|
+
* @description Wallet unique identifier
|
|
110
|
+
* @summary Primary key for the wallet; commonly references an account or identity
|
|
111
|
+
*/
|
|
112
|
+
,
|
|
113
|
+
__metadata("design:type", String)
|
|
114
|
+
], ERC20Wallet.prototype, "id", void 0);
|
|
115
|
+
__decorate([
|
|
116
|
+
(0, core_1.column)(),
|
|
117
|
+
(0, decorator_validation_1.required)()
|
|
118
|
+
/**
|
|
119
|
+
* @description Associated token name
|
|
120
|
+
* @summary References the ERC20Token this wallet holds; maintained as a relationship for cascading updates/deletes
|
|
121
|
+
*/
|
|
122
|
+
,
|
|
123
|
+
__metadata("design:type", String)
|
|
124
|
+
], ERC20Wallet.prototype, "token", void 0);
|
|
125
|
+
__decorate([
|
|
126
|
+
(0, core_1.column)(),
|
|
127
|
+
(0, decorator_validation_1.required)()
|
|
128
|
+
/**
|
|
129
|
+
* @description Token balance for this wallet
|
|
130
|
+
* @summary Current amount of the associated token held by this wallet
|
|
131
|
+
*/
|
|
132
|
+
,
|
|
133
|
+
__metadata("design:type", Number)
|
|
134
|
+
], ERC20Wallet.prototype, "balance", void 0);
|
|
135
|
+
__decorate([
|
|
136
|
+
(0, core_1.column)()
|
|
137
|
+
/**
|
|
138
|
+
* @description Captive flag or identifier
|
|
139
|
+
* @summary Optional field used by some flows to mark non-transferable funds or managed custody
|
|
140
|
+
*/
|
|
141
|
+
,
|
|
142
|
+
__metadata("design:type", String)
|
|
143
|
+
], ERC20Wallet.prototype, "captive", void 0);
|
|
144
|
+
exports.ERC20Wallet = ERC20Wallet = __decorate([
|
|
145
|
+
(0, core_1.table)("erc20_wallets"),
|
|
146
|
+
(0, decorator_validation_1.model)(),
|
|
147
|
+
__metadata("design:paramtypes", [Object])
|
|
148
|
+
], ERC20Wallet);
|
|
149
|
+
/**
|
|
150
|
+
* @description ERC20 allowance model
|
|
151
|
+
* @summary Captures an approval relationship where an owner allows a spender to transfer up to a certain value from the owner's wallet.
|
|
152
|
+
* @param {ModelArg<Allowance>} [m] - Optional partial data or another instance to initialize the model
|
|
153
|
+
* @return {void}
|
|
154
|
+
* @class Allowance
|
|
155
|
+
* @example
|
|
156
|
+
* const allowance = new Allowance({ owner: "acct1", spender: "acct2", value: 50 });
|
|
157
|
+
* @mermaid
|
|
158
|
+
* sequenceDiagram
|
|
159
|
+
* participant App
|
|
160
|
+
* App->>App: new Allowance({ owner, spender, value })
|
|
161
|
+
*/
|
|
162
|
+
let Allowance = class Allowance extends core_1.BaseModel {
|
|
163
|
+
constructor(m) {
|
|
164
|
+
super(m);
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
exports.Allowance = Allowance;
|
|
168
|
+
__decorate([
|
|
169
|
+
(0, core_1.pk)({ type: "String" })
|
|
170
|
+
/**
|
|
171
|
+
* @description Allowance unique identifier
|
|
172
|
+
* @summary Primary key for the allowance; typically a unique identifier for the approval relationship
|
|
173
|
+
*/
|
|
174
|
+
,
|
|
175
|
+
(0, core_1.column)(),
|
|
176
|
+
(0, decorator_validation_1.required)()
|
|
177
|
+
/**
|
|
178
|
+
* @description Owner wallet identifier
|
|
179
|
+
* @summary Wallet that authorizes the allowance
|
|
180
|
+
*/
|
|
181
|
+
,
|
|
182
|
+
__metadata("design:type", String)
|
|
183
|
+
], Allowance.prototype, "owner", void 0);
|
|
184
|
+
__decorate([
|
|
185
|
+
(0, core_1.column)(),
|
|
186
|
+
(0, decorator_validation_1.required)()
|
|
187
|
+
/**
|
|
188
|
+
* @description Spender wallet identifier
|
|
189
|
+
* @summary Wallet allowed to spend up to the approved value from the owner
|
|
190
|
+
*/
|
|
191
|
+
,
|
|
192
|
+
__metadata("design:type", String)
|
|
193
|
+
], Allowance.prototype, "spender", void 0);
|
|
194
|
+
__decorate([
|
|
195
|
+
(0, core_1.column)(),
|
|
196
|
+
(0, decorator_validation_1.required)()
|
|
197
|
+
/**
|
|
198
|
+
* @description Approved value
|
|
199
|
+
* @summary Maximum token amount the spender may transfer on behalf of the owner
|
|
200
|
+
*/
|
|
201
|
+
,
|
|
202
|
+
__metadata("design:type", Number)
|
|
203
|
+
], Allowance.prototype, "value", void 0);
|
|
204
|
+
exports.Allowance = Allowance = __decorate([
|
|
205
|
+
(0, core_1.table)("erc20_allowances"),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aWZpZXJcbiAgICogQHN1bW1hcnkgV2FsbGV0IGFsbG93ZWQgdG8gc3BlbmQgdXAgdG8gdGhlIGFwcHJvdmVkIHZhbHVlIGZyb20gdGhlIG93bmVyXG4gICAqL1xuICBzcGVuZGVyITogc3RyaW5nO1xuXG4gIEBjb2x1bW4oKVxuICBAcmVxdWlyZWQoKVxuICAvKipcbiAgICogQGRlc2NyaXB0aW9uIEFwcHJvdmVkIHZhbHVlXG4gICAqIEBzdW1tYXJ5IE1heGltdW0gdG9rZW4gYW1vdW50IHRoZSBzcGVuZGVyIG1heSB0cmFuc2ZlciBvbiBiZWhhbGYgb2YgdGhlIG93bmVyXG4gICAqL1xuICB2YWx1ZSE6IG51bWJlcjtcblxuICBjb25zdHJ1Y3RvcihtPzogTW9kZWxBcmc8QWxsb3dhbmNlPikge1xuICAgIHN1cGVyKG0pO1xuICB9XG59XG4iXX0=
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { BaseModel } from "@decaf-ts/core";
|
|
2
|
+
import { type ModelArg } from "@decaf-ts/decorator-validation";
|
|
3
|
+
/**
|
|
4
|
+
* @description ERC20 token metadata model
|
|
5
|
+
* @summary Represents an ERC20 token definition within the Fabric ERC20 sample, including name, symbol, decimals, and the owning identity. Used to define the unique token managed by the contract.
|
|
6
|
+
* @param {ModelArg<ERC20Token>} [m] - Optional partial data or another instance to initialize the model
|
|
7
|
+
* @return {void}
|
|
8
|
+
* @class ERC20Token
|
|
9
|
+
* @example
|
|
10
|
+
* const token = new ERC20Token({ name: "MyToken", symbol: "MTK", decimals: 18, owner: "x509::..." });
|
|
11
|
+
* // Persist through a repository: await repo.create(token, ctx)
|
|
12
|
+
* @mermaid
|
|
13
|
+
* sequenceDiagram
|
|
14
|
+
* participant App
|
|
15
|
+
* participant Repo
|
|
16
|
+
* participant Adapter
|
|
17
|
+
* App->>Repo: create(new ERC20Token({...}), ctx)
|
|
18
|
+
* Repo->>Adapter: create(table, id=name, record, flags)
|
|
19
|
+
* Adapter-->>Repo: stored
|
|
20
|
+
* Repo-->>App: model
|
|
21
|
+
*/
|
|
22
|
+
export declare class ERC20Token extends BaseModel {
|
|
23
|
+
/**
|
|
24
|
+
* @description Token unique name
|
|
25
|
+
* @summary Serves as the primary key for the ERC20 token definition; typically a human-readable identifier
|
|
26
|
+
*/
|
|
27
|
+
name: string;
|
|
28
|
+
/**
|
|
29
|
+
* @description Owning identity of the token
|
|
30
|
+
* @summary X.509 subject or MSP identity string that denotes who owns/controls the token definition
|
|
31
|
+
*/
|
|
32
|
+
owner: string;
|
|
33
|
+
/**
|
|
34
|
+
* @description Token symbol
|
|
35
|
+
* @summary Short ticker-like symbol used to represent the token (e.g., MTK)
|
|
36
|
+
*/
|
|
37
|
+
symbol: string;
|
|
38
|
+
/**
|
|
39
|
+
* @description Decimal precision for token amounts
|
|
40
|
+
* @summary Number of digits after the decimal separator used when formatting token balances
|
|
41
|
+
*/
|
|
42
|
+
decimals: number;
|
|
43
|
+
constructor(m?: ModelArg<ERC20Wallet>);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* @description ERC20 wallet model
|
|
47
|
+
* @summary Represents a holder account for an ERC20 token within the Fabric network, tracking balance and token association.
|
|
48
|
+
* @param {ModelArg<ERC20Wallet>} [m] - Optional partial data or another instance to initialize the model
|
|
49
|
+
* @return {void}
|
|
50
|
+
* @class ERC20Wallet
|
|
51
|
+
* @example
|
|
52
|
+
* const wallet = new ERC20Wallet({ id: "acct1", token: "MyToken", balance: 1000 });
|
|
53
|
+
* // Update balance via repository: await repo.update(wallet, ctx)
|
|
54
|
+
* @mermaid
|
|
55
|
+
* sequenceDiagram
|
|
56
|
+
* participant App
|
|
57
|
+
* participant Repo
|
|
58
|
+
* App->>Repo: read("acct1", ctx)
|
|
59
|
+
* Repo-->>App: ERC20Wallet
|
|
60
|
+
*/
|
|
61
|
+
export declare class ERC20Wallet extends BaseModel {
|
|
62
|
+
/**
|
|
63
|
+
* @description Wallet unique identifier
|
|
64
|
+
* @summary Primary key for the wallet; commonly references an account or identity
|
|
65
|
+
*/
|
|
66
|
+
id: string;
|
|
67
|
+
/**
|
|
68
|
+
* @description Associated token name
|
|
69
|
+
* @summary References the ERC20Token this wallet holds; maintained as a relationship for cascading updates/deletes
|
|
70
|
+
*/
|
|
71
|
+
token: string;
|
|
72
|
+
/**
|
|
73
|
+
* @description Token balance for this wallet
|
|
74
|
+
* @summary Current amount of the associated token held by this wallet
|
|
75
|
+
*/
|
|
76
|
+
balance: number;
|
|
77
|
+
/**
|
|
78
|
+
* @description Captive flag or identifier
|
|
79
|
+
* @summary Optional field used by some flows to mark non-transferable funds or managed custody
|
|
80
|
+
*/
|
|
81
|
+
captive: string;
|
|
82
|
+
constructor(m?: ModelArg<ERC20Wallet>);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* @description ERC20 allowance model
|
|
86
|
+
* @summary Captures an approval relationship where an owner allows a spender to transfer up to a certain value from the owner's wallet.
|
|
87
|
+
* @param {ModelArg<Allowance>} [m] - Optional partial data or another instance to initialize the model
|
|
88
|
+
* @return {void}
|
|
89
|
+
* @class Allowance
|
|
90
|
+
* @example
|
|
91
|
+
* const allowance = new Allowance({ owner: "acct1", spender: "acct2", value: 50 });
|
|
92
|
+
* @mermaid
|
|
93
|
+
* sequenceDiagram
|
|
94
|
+
* participant App
|
|
95
|
+
* App->>App: new Allowance({ owner, spender, value })
|
|
96
|
+
*/
|
|
97
|
+
export declare class Allowance extends BaseModel {
|
|
98
|
+
/**
|
|
99
|
+
* @description Owner wallet identifier
|
|
100
|
+
* @summary Wallet that authorizes the allowance
|
|
101
|
+
*/
|
|
102
|
+
owner: string;
|
|
103
|
+
/**
|
|
104
|
+
* @description Spender wallet identifier
|
|
105
|
+
* @summary Wallet allowed to spend up to the approved value from the owner
|
|
106
|
+
*/
|
|
107
|
+
spender: string;
|
|
108
|
+
/**
|
|
109
|
+
* @description Approved value
|
|
110
|
+
* @summary Maximum token amount the spender may transfer on behalf of the owner
|
|
111
|
+
*/
|
|
112
|
+
value: number;
|
|
113
|
+
constructor(m?: ModelArg<Allowance>);
|
|
114
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @description Contracts submodule for Hyperledger Fabric integration
|
|
4
|
+
* @summary Aggregates chaincode-side building blocks including repositories, sequences, adapters, and ERC20 helpers. This entrypoint re-exports contract-related elements such as {@link FabricContractRepository}, {@link FabricContractSequence}, and CRUD/ERC20 utilities for composing Fabric contracts.
|
|
5
|
+
* @namespace contracts
|
|
6
|
+
* @memberOf module:for-fabric
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
__exportStar(require("./crud/index.cjs"), exports);
|
|
24
|
+
__exportStar(require("./erc20/index.cjs"), exports);
|
|
25
|
+
__exportStar(require("./ContractAdapter.cjs"), exports);
|
|
26
|
+
__exportStar(require("./ContractContext.cjs"), exports);
|
|
27
|
+
__exportStar(require("./FabricContractRepository.cjs"), exports);
|
|
28
|
+
__exportStar(require("./FabricContractRepositoryObservableHandler.cjs"), exports);
|
|
29
|
+
__exportStar(require("./FabricContractSequence.cjs"), exports);
|
|
30
|
+
__exportStar(require("./logging.cjs"), exports);
|
|
31
|
+
__exportStar(require("./types.cjs"), exports);
|
|
32
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29udHJhY3RzL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQTs7Ozs7R0FLRzs7Ozs7Ozs7Ozs7Ozs7OztBQUVILG1EQUF1QjtBQUN2QixvREFBd0I7QUFDeEIsd0RBQWtDO0FBQ2xDLHdEQUFrQztBQUNsQyxpRUFBMkM7QUFDM0Msa0ZBQTREO0FBQzVELCtEQUF5QztBQUN6QyxnREFBMEI7QUFDMUIsOENBQXdCIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBAZGVzY3JpcHRpb24gQ29udHJhY3RzIHN1Ym1vZHVsZSBmb3IgSHlwZXJsZWRnZXIgRmFicmljIGludGVncmF0aW9uXG4gKiBAc3VtbWFyeSBBZ2dyZWdhdGVzIGNoYWluY29kZS1zaWRlIGJ1aWxkaW5nIGJsb2NrcyBpbmNsdWRpbmcgcmVwb3NpdG9yaWVzLCBzZXF1ZW5jZXMsIGFkYXB0ZXJzLCBhbmQgRVJDMjAgaGVscGVycy4gVGhpcyBlbnRyeXBvaW50IHJlLWV4cG9ydHMgY29udHJhY3QtcmVsYXRlZCBlbGVtZW50cyBzdWNoIGFzIHtAbGluayBGYWJyaWNDb250cmFjdFJlcG9zaXRvcnl9LCB7QGxpbmsgRmFicmljQ29udHJhY3RTZXF1ZW5jZX0sIGFuZCBDUlVEL0VSQzIwIHV0aWxpdGllcyBmb3IgY29tcG9zaW5nIEZhYnJpYyBjb250cmFjdHMuXG4gKiBAbmFtZXNwYWNlIGNvbnRyYWN0c1xuICogQG1lbWJlck9mIG1vZHVsZTpmb3ItZmFicmljXG4gKi9cblxuZXhwb3J0ICogZnJvbSBcIi4vY3J1ZFwiO1xuZXhwb3J0ICogZnJvbSBcIi4vZXJjMjBcIjtcbmV4cG9ydCAqIGZyb20gXCIuL0NvbnRyYWN0QWRhcHRlclwiO1xuZXhwb3J0ICogZnJvbSBcIi4vQ29udHJhY3RDb250ZXh0XCI7XG5leHBvcnQgKiBmcm9tIFwiLi9GYWJyaWNDb250cmFjdFJlcG9zaXRvcnlcIjtcbmV4cG9ydCAqIGZyb20gXCIuL0ZhYnJpY0NvbnRyYWN0UmVwb3NpdG9yeU9ic2VydmFibGVIYW5kbGVyXCI7XG5leHBvcnQgKiBmcm9tIFwiLi9GYWJyaWNDb250cmFjdFNlcXVlbmNlXCI7XG5leHBvcnQgKiBmcm9tIFwiLi9sb2dnaW5nXCI7XG5leHBvcnQgKiBmcm9tIFwiLi90eXBlc1wiO1xuIl19
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Contracts submodule for Hyperledger Fabric integration
|
|
3
|
+
* @summary Aggregates chaincode-side building blocks including repositories, sequences, adapters, and ERC20 helpers. This entrypoint re-exports contract-related elements such as {@link FabricContractRepository}, {@link FabricContractSequence}, and CRUD/ERC20 utilities for composing Fabric contracts.
|
|
4
|
+
* @namespace contracts
|
|
5
|
+
* @memberOf module:for-fabric
|
|
6
|
+
*/
|
|
7
|
+
export * from "./crud";
|
|
8
|
+
export * from "./erc20";
|
|
9
|
+
export * from "./ContractAdapter";
|
|
10
|
+
export * from "./ContractContext";
|
|
11
|
+
export * from "./FabricContractRepository";
|
|
12
|
+
export * from "./FabricContractRepositoryObservableHandler";
|
|
13
|
+
export * from "./FabricContractSequence";
|
|
14
|
+
export * from "./logging";
|
|
15
|
+
export * from "./types";
|