@decaf-ts/for-fabric 0.1.50 → 0.1.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/for-fabric.cjs +1 -1
- package/dist/for-fabric.cjs.map +1 -1
- package/dist/for-fabric.js +1 -1
- package/dist/for-fabric.js.map +1 -1
- package/lib/cli-module.cjs +24 -5
- package/lib/cli-module.js.map +1 -1
- package/lib/client/FabricClientAdapter.cjs +4 -6
- package/lib/client/FabricClientAdapter.d.ts +1 -1
- package/lib/client/FabricClientAdapter.js.map +1 -1
- package/lib/client/FabricClientDispatch.cjs +2 -2
- package/lib/client/FabricClientDispatch.js.map +1 -1
- package/lib/client/FabricClientRepository.cjs +14 -18
- package/lib/client/FabricClientRepository.d.ts +1 -1
- package/lib/client/FabricClientRepository.js.map +1 -1
- package/lib/{shared → client}/crypto.js.map +1 -1
- package/lib/client/erc20/FabricERC20ClientRepository.cjs +12 -18
- package/lib/client/erc20/FabricERC20ClientRepository.d.ts +7 -7
- package/lib/client/erc20/FabricERC20ClientRepository.js.map +1 -1
- package/lib/client/index.cjs +5 -2
- package/lib/client/index.d.ts +5 -2
- package/lib/client/index.js.map +1 -1
- package/lib/client/services/FabricEnrollmentService.cjs +2 -2
- package/lib/client/services/FabricEnrollmentService.js.map +1 -1
- package/lib/client/services/FabricIdentityService.cjs +2 -2
- package/lib/client/services/FabricIdentityService.js.map +1 -1
- package/lib/{shared → client}/utils.cjs +3 -3
- package/lib/{shared → client}/utils.d.ts +1 -1
- package/lib/client/utils.js.map +1 -0
- package/lib/contracts/ContractAdapter.cjs +155 -46
- package/lib/contracts/ContractAdapter.d.ts +12 -17
- package/lib/contracts/ContractAdapter.js.map +1 -1
- package/lib/contracts/FabricContractPaginator.cjs +17 -12
- package/lib/contracts/FabricContractPaginator.d.ts +2 -2
- package/lib/contracts/FabricContractPaginator.js.map +1 -1
- package/lib/contracts/FabricContractRepository.cjs +5 -7
- package/lib/contracts/FabricContractRepository.d.ts +1 -8
- package/lib/contracts/FabricContractRepository.js.map +1 -1
- package/lib/contracts/FabricContractRepositoryObservableHandler.cjs +1 -1
- package/lib/contracts/FabricContractRepositoryObservableHandler.js.map +1 -1
- package/lib/contracts/FabricContractSequence.cjs +2 -4
- package/lib/contracts/FabricContractSequence.js.map +1 -1
- package/lib/contracts/FabricContractStatement.cjs +6 -0
- package/lib/contracts/FabricContractStatement.d.ts +3 -1
- package/lib/contracts/FabricContractStatement.js.map +1 -1
- package/lib/contracts/crud/crud-contract.cjs +31 -65
- package/lib/contracts/crud/crud-contract.d.ts +8 -17
- package/lib/contracts/crud/crud-contract.js.map +1 -1
- package/lib/contracts/crud/serialized-crud-contract.cjs +19 -56
- package/lib/contracts/crud/serialized-crud-contract.d.ts +13 -15
- package/lib/contracts/crud/serialized-crud-contract.js.map +1 -1
- package/lib/contracts/erc20/models.cjs +3 -3
- package/lib/contracts/erc20/models.js.map +1 -1
- package/lib/contracts/logging.cjs +7 -0
- package/lib/contracts/logging.js.map +1 -1
- package/lib/esm/cli-module.js +24 -5
- package/lib/esm/cli-module.js.map +1 -1
- package/lib/esm/client/FabricClientAdapter.d.ts +1 -1
- package/lib/esm/client/FabricClientAdapter.js +4 -6
- package/lib/esm/client/FabricClientAdapter.js.map +1 -1
- package/lib/esm/client/FabricClientDispatch.js +3 -3
- package/lib/esm/client/FabricClientDispatch.js.map +1 -1
- package/lib/esm/client/FabricClientRepository.d.ts +1 -1
- package/lib/esm/client/FabricClientRepository.js +15 -19
- package/lib/esm/client/FabricClientRepository.js.map +1 -1
- package/lib/esm/{shared → client}/crypto.js.map +1 -1
- package/lib/esm/client/erc20/FabricERC20ClientRepository.d.ts +7 -7
- package/lib/esm/client/erc20/FabricERC20ClientRepository.js +12 -18
- package/lib/esm/client/erc20/FabricERC20ClientRepository.js.map +1 -1
- package/lib/esm/client/index.d.ts +5 -2
- package/lib/esm/client/index.js +5 -2
- package/lib/esm/client/index.js.map +1 -1
- package/lib/esm/client/services/FabricEnrollmentService.js +2 -2
- package/lib/esm/client/services/FabricEnrollmentService.js.map +1 -1
- package/lib/esm/client/services/FabricIdentityService.js +2 -2
- package/lib/esm/client/services/FabricIdentityService.js.map +1 -1
- package/lib/esm/{shared → client}/utils.d.ts +1 -1
- package/lib/esm/{shared → client}/utils.js +2 -2
- package/lib/esm/client/utils.js.map +1 -0
- package/lib/esm/contracts/ContractAdapter.d.ts +12 -17
- package/lib/esm/contracts/ContractAdapter.js +156 -47
- package/lib/esm/contracts/ContractAdapter.js.map +1 -1
- package/lib/esm/contracts/FabricContractPaginator.d.ts +2 -2
- package/lib/esm/contracts/FabricContractPaginator.js +18 -13
- package/lib/esm/contracts/FabricContractPaginator.js.map +1 -1
- package/lib/esm/contracts/FabricContractRepository.d.ts +1 -8
- package/lib/esm/contracts/FabricContractRepository.js +6 -8
- package/lib/esm/contracts/FabricContractRepository.js.map +1 -1
- package/lib/esm/contracts/FabricContractRepositoryObservableHandler.js +1 -1
- package/lib/esm/contracts/FabricContractRepositoryObservableHandler.js.map +1 -1
- package/lib/esm/contracts/FabricContractSequence.js +3 -5
- package/lib/esm/contracts/FabricContractSequence.js.map +1 -1
- package/lib/esm/contracts/FabricContractStatement.d.ts +3 -1
- package/lib/esm/contracts/FabricContractStatement.js +8 -2
- package/lib/esm/contracts/FabricContractStatement.js.map +1 -1
- package/lib/esm/contracts/crud/crud-contract.d.ts +8 -17
- package/lib/esm/contracts/crud/crud-contract.js +34 -68
- package/lib/esm/contracts/crud/crud-contract.js.map +1 -1
- package/lib/esm/contracts/crud/serialized-crud-contract.d.ts +13 -15
- package/lib/esm/contracts/crud/serialized-crud-contract.js +19 -56
- package/lib/esm/contracts/crud/serialized-crud-contract.js.map +1 -1
- package/lib/esm/contracts/erc20/models.js +3 -3
- package/lib/esm/contracts/erc20/models.js.map +1 -1
- package/lib/esm/contracts/logging.js +7 -0
- package/lib/esm/contracts/logging.js.map +1 -1
- package/lib/esm/shared/index.d.ts +1 -2
- package/lib/esm/shared/index.js +1 -2
- package/lib/esm/shared/index.js.map +1 -1
- package/lib/esm/shared/overrides/overrides.js +10 -0
- package/lib/esm/shared/overrides/overrides.js.map +1 -1
- package/lib/esm/version.d.ts +1 -1
- package/lib/esm/version.js +1 -1
- package/lib/shared/index.cjs +1 -2
- package/lib/shared/index.d.ts +1 -2
- package/lib/shared/index.js.map +1 -1
- package/lib/shared/overrides/overrides.cjs +10 -0
- package/lib/shared/overrides/overrides.js.map +1 -1
- package/lib/version.cjs +1 -1
- package/lib/version.d.ts +1 -1
- package/package.json +2 -17
- package/lib/esm/shared/utils.js.map +0 -1
- package/lib/shared/utils.js.map +0 -1
- /package/lib/{shared → client}/crypto.cjs +0 -0
- /package/lib/{esm/shared → client}/crypto.d.ts +0 -0
- /package/lib/{shared → esm/client}/crypto.d.ts +0 -0
- /package/lib/esm/{shared → client}/crypto.js +0 -0
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FabricCrudContract = void 0;
|
|
4
|
+
require("./../../shared/overrides/index.cjs");
|
|
4
5
|
const ContractAdapter_1 = require("./../ContractAdapter.cjs");
|
|
5
6
|
const fabric_contract_api_1 = require("fabric-contract-api");
|
|
6
7
|
const decorator_validation_1 = require("@decaf-ts/decorator-validation");
|
|
7
8
|
const core_1 = require("@decaf-ts/core");
|
|
8
9
|
const DeterministicSerializer_1 = require("./../../shared/DeterministicSerializer.cjs");
|
|
9
|
-
const ContractContext_1 = require("./../ContractContext.cjs");
|
|
10
10
|
const db_decorators_1 = require("@decaf-ts/db-decorators");
|
|
11
|
-
const
|
|
12
|
-
(0,
|
|
11
|
+
const index_1 = require("./../../shared/index.cjs");
|
|
12
|
+
(0, fabric_contract_api_1.Object)()(Date);
|
|
13
13
|
/**
|
|
14
14
|
* @description Base contract class for CRUD operations in Fabric chaincode
|
|
15
15
|
* @summary Provides standard create, read, update, and delete operations for models in Fabric chaincode
|
|
@@ -75,9 +75,10 @@ class FabricCrudContract extends fabric_contract_api_1.Contract {
|
|
|
75
75
|
this.clazz = clazz;
|
|
76
76
|
this.initialized = false;
|
|
77
77
|
this.repo = core_1.Repository.forModel(clazz);
|
|
78
|
+
// prefixMethod(this);
|
|
78
79
|
}
|
|
79
80
|
async listBy(ctx, key, order, ...args) {
|
|
80
|
-
const { ctxArgs, log } = await this.logCtx([...args, ctx], this.listBy);
|
|
81
|
+
const { ctxArgs, log } = (await this.logCtx([...args, ctx], core_1.PreparedStatementKeys.LIST_BY, true)).for(this.listBy);
|
|
81
82
|
log.info(`Running listBy key ${key}, order ${order} and args ${ctxArgs}`);
|
|
82
83
|
return this.repo.listBy(key, order, ...ctxArgs);
|
|
83
84
|
}
|
|
@@ -85,17 +86,17 @@ class FabricCrudContract extends fabric_contract_api_1.Contract {
|
|
|
85
86
|
offset: 1,
|
|
86
87
|
limit: 10,
|
|
87
88
|
}, ...args) {
|
|
88
|
-
const { ctxArgs, log } = await this.logCtx([...args, ctx], this.paginateBy);
|
|
89
|
+
const { ctxArgs, log } = (await this.logCtx([...args, ctx], core_1.PreparedStatementKeys.PAGE_BY, true)).for(this.paginateBy);
|
|
89
90
|
log.info(`Running paginateBy key ${key}, order ${order} with size ${ref.limit} and args ${ctxArgs}`);
|
|
90
91
|
return this.repo.paginateBy(key, order, ref, ...ctxArgs);
|
|
91
92
|
}
|
|
92
93
|
async findOneBy(ctx, key, value, ...args) {
|
|
93
|
-
const { ctxArgs, log } = await this.logCtx([...args, ctx], this.findOneBy);
|
|
94
|
+
const { ctxArgs, log } = (await this.logCtx([...args, ctx], core_1.PreparedStatementKeys.FIND_ONE_BY, true)).for(this.findOneBy);
|
|
94
95
|
log.info(`Running findOneBy key ${key}, value: ${value} with args ${ctxArgs}`);
|
|
95
96
|
return this.repo.findOneBy(key, value, ...ctxArgs);
|
|
96
97
|
}
|
|
97
98
|
async statement(ctx, method, ...args) {
|
|
98
|
-
const { ctxArgs, log } = await this.logCtx([...args, ctx], this.statement);
|
|
99
|
+
const { ctxArgs, log } = (await this.logCtx([...args, ctx], core_1.PersistenceKeys.STATEMENT, true)).for(this.statement);
|
|
99
100
|
log.info(`Running statement ${method} with args ${ctxArgs}`);
|
|
100
101
|
return this.repo.statement(method, ...ctxArgs);
|
|
101
102
|
}
|
|
@@ -108,7 +109,7 @@ class FabricCrudContract extends fabric_contract_api_1.Contract {
|
|
|
108
109
|
* @return {Promise<M>} Promise resolving to the created model
|
|
109
110
|
*/
|
|
110
111
|
async create(ctx, model, ...args) {
|
|
111
|
-
const { log, ctxArgs } = await this.logCtx([...args, ctx], this.create);
|
|
112
|
+
const { log, ctxArgs } = (await this.logCtx([...args, ctx], db_decorators_1.OperationKeys.CREATE, true)).for(this.create);
|
|
112
113
|
log.info(`CONTRACT CREATE, ${ctxArgs}`);
|
|
113
114
|
if (typeof model === "string")
|
|
114
115
|
model = this.deserialize(model);
|
|
@@ -127,7 +128,7 @@ class FabricCrudContract extends fabric_contract_api_1.Contract {
|
|
|
127
128
|
* @return {Promise<M>} Promise resolving to the retrieved model
|
|
128
129
|
*/
|
|
129
130
|
async read(ctx, key, ...args) {
|
|
130
|
-
const { log, ctxArgs } = await this.logCtx([...args, ctx], this.
|
|
131
|
+
const { log, ctxArgs } = (await this.logCtx([...args, ctx], db_decorators_1.OperationKeys.READ, true)).for(this.create);
|
|
131
132
|
log.info(`reading entry with pk ${key} `);
|
|
132
133
|
return this.repo.read(key, ...ctxArgs);
|
|
133
134
|
}
|
|
@@ -148,7 +149,7 @@ class FabricCrudContract extends fabric_contract_api_1.Contract {
|
|
|
148
149
|
* @return {Promise<M>} Promise resolving to the updated model
|
|
149
150
|
*/
|
|
150
151
|
async update(ctx, model, ...args) {
|
|
151
|
-
const { log, ctxArgs } = await this.logCtx([...args, ctx], this.update);
|
|
152
|
+
const { log, ctxArgs } = (await this.logCtx([...args, ctx], db_decorators_1.OperationKeys.UPDATE, true)).for(this.update);
|
|
152
153
|
if (typeof model === "string")
|
|
153
154
|
model = this.deserialize(model);
|
|
154
155
|
log.info(`Updating model: ${JSON.stringify(model)}`);
|
|
@@ -166,7 +167,7 @@ class FabricCrudContract extends fabric_contract_api_1.Contract {
|
|
|
166
167
|
* @return {Promise<M>} Promise resolving to the deleted model
|
|
167
168
|
*/
|
|
168
169
|
async delete(ctx, key, ...args) {
|
|
169
|
-
const { log, ctxArgs } = await this.logCtx([...args, ctx], this.delete);
|
|
170
|
+
const { log, ctxArgs } = (await this.logCtx([...args, ctx], db_decorators_1.OperationKeys.DELETE, true)).for(this.delete);
|
|
170
171
|
log.info(`deleting entry with pk ${key} `);
|
|
171
172
|
return this.repo.delete(String(key), ...ctxArgs);
|
|
172
173
|
}
|
|
@@ -179,7 +180,7 @@ class FabricCrudContract extends fabric_contract_api_1.Contract {
|
|
|
179
180
|
* @return {Promise<M[]>} Promise resolving to the deleted models
|
|
180
181
|
*/
|
|
181
182
|
async deleteAll(ctx, keys, ...args) {
|
|
182
|
-
const { ctxArgs } = await this.logCtx([...args, ctx], this.
|
|
183
|
+
const { ctxArgs } = (await this.logCtx([...args, ctx], db_decorators_1.BulkCrudOperationKeys.DELETE_ALL, true)).for(this.deleteAll);
|
|
183
184
|
if (typeof keys === "string")
|
|
184
185
|
keys = JSON.parse(keys);
|
|
185
186
|
return this.repo.deleteAll(keys, ...ctxArgs);
|
|
@@ -193,7 +194,7 @@ class FabricCrudContract extends fabric_contract_api_1.Contract {
|
|
|
193
194
|
* @return {Promise<M[]>} Promise resolving to the retrieved models
|
|
194
195
|
*/
|
|
195
196
|
async readAll(ctx, keys, ...args) {
|
|
196
|
-
const { ctxArgs } = await this.logCtx([...args, ctx], this.
|
|
197
|
+
const { ctxArgs } = (await this.logCtx([...args, ctx], db_decorators_1.BulkCrudOperationKeys.READ_ALL, true)).for(this.create);
|
|
197
198
|
if (typeof keys === "string")
|
|
198
199
|
keys = JSON.parse(keys);
|
|
199
200
|
return this.repo.readAll(keys, ...ctxArgs);
|
|
@@ -207,7 +208,7 @@ class FabricCrudContract extends fabric_contract_api_1.Contract {
|
|
|
207
208
|
* @return {Promise<M[]>} Promise resolving to the updated models
|
|
208
209
|
*/
|
|
209
210
|
async updateAll(ctx, models, ...args) {
|
|
210
|
-
const { log, ctxArgs } = await this.logCtx([...args, ctx], this.updateAll);
|
|
211
|
+
const { log, ctxArgs } = (await this.logCtx([...args, ctx], db_decorators_1.BulkCrudOperationKeys.UPDATE_ALL, true)).for(this.updateAll);
|
|
211
212
|
if (typeof models === "string")
|
|
212
213
|
models = JSON.parse(models)
|
|
213
214
|
.map((m) => this.deserialize(m))
|
|
@@ -226,7 +227,7 @@ class FabricCrudContract extends fabric_contract_api_1.Contract {
|
|
|
226
227
|
* @return {Promise<M[]>} The query results as model instances.
|
|
227
228
|
*/
|
|
228
229
|
async query(context, condition, orderBy, order = core_1.OrderDirection.ASC, limit, skip, ...args) {
|
|
229
|
-
const { ctxArgs } = await this.logCtx([...args, context], this.
|
|
230
|
+
const { ctxArgs } = (await this.logCtx([...args, context], core_1.PersistenceKeys.QUERY, true)).for(this.create);
|
|
230
231
|
return this.repo.query(condition, orderBy, order, limit, skip, ...ctxArgs);
|
|
231
232
|
}
|
|
232
233
|
/**
|
|
@@ -239,7 +240,7 @@ class FabricCrudContract extends fabric_contract_api_1.Contract {
|
|
|
239
240
|
* @return {Promise<any>} Promise resolving to the query results
|
|
240
241
|
*/
|
|
241
242
|
async raw(ctx, rawInput, docsOnly, ...args) {
|
|
242
|
-
const { ctxArgs } = await this.logCtx([...args, ctx], this.raw);
|
|
243
|
+
const { ctxArgs } = (await this.logCtx([...args, ctx], "raw", true)).for(this.raw);
|
|
243
244
|
return FabricCrudContract.adapter.raw(rawInput, docsOnly, ...ctxArgs);
|
|
244
245
|
}
|
|
245
246
|
serialize(model) {
|
|
@@ -249,13 +250,13 @@ class FabricCrudContract extends fabric_contract_api_1.Contract {
|
|
|
249
250
|
return FabricCrudContract.serializer.deserialize(str);
|
|
250
251
|
}
|
|
251
252
|
async init(ctx) {
|
|
252
|
-
const { log } = await this.logCtx([ctx], this.init);
|
|
253
|
+
const { log, ctxArgs } = (await this.logCtx([ctx], core_1.PersistenceKeys.INITIALIZATION, true)).for(this.init);
|
|
253
254
|
log.info(`Running contract ${this.getName()} initialization...`);
|
|
254
255
|
this.initialized = true;
|
|
255
256
|
log.info(`Contract initialization completed.`);
|
|
256
257
|
}
|
|
257
258
|
async healthcheck(ctx) {
|
|
258
|
-
const { log } = await this.logCtx([ctx], this.healthcheck);
|
|
259
|
+
const { log } = (await this.logCtx([ctx], "healthcheck", true)).for(this.healthcheck);
|
|
259
260
|
log.info(`Running Healthcheck: ${this.initialized}...`);
|
|
260
261
|
return { healthcheck: this.initialized };
|
|
261
262
|
}
|
|
@@ -268,7 +269,7 @@ class FabricCrudContract extends fabric_contract_api_1.Contract {
|
|
|
268
269
|
* @return {Promise<M[]>} Promise resolving to the created models
|
|
269
270
|
*/
|
|
270
271
|
async createAll(ctx, models, ...args) {
|
|
271
|
-
const { log, ctxArgs } = await this.logCtx([...args, ctx], this.createAll);
|
|
272
|
+
const { log, ctxArgs } = (await this.logCtx([...args, ctx], db_decorators_1.BulkCrudOperationKeys.CREATE_ALL, true)).for(this.createAll);
|
|
272
273
|
if (typeof models === "string")
|
|
273
274
|
models = JSON.parse(models)
|
|
274
275
|
.map((m) => this.deserialize(m))
|
|
@@ -276,54 +277,19 @@ class FabricCrudContract extends fabric_contract_api_1.Contract {
|
|
|
276
277
|
log.info(`adding ${models.length} entries to the table`);
|
|
277
278
|
return this.repo.createAll(models, ...ctxArgs);
|
|
278
279
|
}
|
|
279
|
-
|
|
280
|
-
return FabricCrudContract.logCtx.bind(this)(args, method);
|
|
281
|
-
}
|
|
282
|
-
static async logCtx(args, method) {
|
|
283
|
-
if (args.length < 1)
|
|
284
|
-
throw new db_decorators_1.InternalError("No context provided");
|
|
280
|
+
logCtx(args, operation, allowCreate = false) {
|
|
285
281
|
const ctx = args.pop();
|
|
286
|
-
if (ctx
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
};
|
|
294
|
-
if (!(ctx instanceof fabric_contract_api_1.Context))
|
|
295
|
-
throw new db_decorators_1.InternalError("No valid context provided");
|
|
296
|
-
function getOp() {
|
|
297
|
-
if (typeof method === "string")
|
|
298
|
-
return method;
|
|
299
|
-
switch (method.name) {
|
|
300
|
-
case db_decorators_1.OperationKeys.CREATE:
|
|
301
|
-
case db_decorators_1.OperationKeys.READ:
|
|
302
|
-
case db_decorators_1.OperationKeys.UPDATE:
|
|
303
|
-
case db_decorators_1.OperationKeys.DELETE:
|
|
304
|
-
case db_decorators_1.BulkCrudOperationKeys.CREATE_ALL:
|
|
305
|
-
case db_decorators_1.BulkCrudOperationKeys.READ_ALL:
|
|
306
|
-
case db_decorators_1.BulkCrudOperationKeys.UPDATE_ALL:
|
|
307
|
-
case db_decorators_1.BulkCrudOperationKeys.DELETE_ALL:
|
|
308
|
-
return method.name;
|
|
309
|
-
default:
|
|
310
|
-
return method.name;
|
|
311
|
-
}
|
|
282
|
+
if (!ctx || !ctx.stub) {
|
|
283
|
+
throw new index_1.MissingContextError(`No valid context provided...`);
|
|
284
|
+
}
|
|
285
|
+
const contextualized = FabricCrudContract.adapter["logCtx"]([this.clazz, ...args], operation, allowCreate, ctx);
|
|
286
|
+
function squashArgs(ctx) {
|
|
287
|
+
ctx.ctxArgs.shift(); // removes added model to args
|
|
288
|
+
return ctx;
|
|
312
289
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
const context = await FabricCrudContract.adapter.context(getOp(), overrides, this.clazz, ctx);
|
|
317
|
-
const log = (this
|
|
318
|
-
? context.logger.for(this).for(method)
|
|
319
|
-
: context.logger.clear().for(this).for(method));
|
|
320
|
-
return {
|
|
321
|
-
ctx: context,
|
|
322
|
-
log: log,
|
|
323
|
-
stub: context.stub,
|
|
324
|
-
identity: context.identity,
|
|
325
|
-
ctxArgs: [...args, context],
|
|
326
|
-
};
|
|
290
|
+
if (!(contextualized instanceof Promise))
|
|
291
|
+
return squashArgs(contextualized);
|
|
292
|
+
return contextualized.then(squashArgs);
|
|
327
293
|
}
|
|
328
294
|
}
|
|
329
295
|
exports.FabricCrudContract = FabricCrudContract;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import "../../shared/overrides";
|
|
2
|
+
import { FabricContextualizedArgs, FabricContractAdapter } from "../ContractAdapter";
|
|
3
|
+
import { Context as Ctx, Contract } from "fabric-contract-api";
|
|
3
4
|
import { Model } from "@decaf-ts/decorator-validation";
|
|
4
|
-
import { Condition,
|
|
5
|
+
import { Condition, DirectionLimitOffset, MaybeContextualArg, MethodOrOperation, OrderDirection, SerializedPage } from "@decaf-ts/core";
|
|
5
6
|
import { FabricContractRepository } from "../FabricContractRepository";
|
|
6
7
|
import { DeterministicSerializer } from "../../shared/DeterministicSerializer";
|
|
7
8
|
import { MangoQuery } from "@decaf-ts/for-couchdb";
|
|
@@ -9,7 +10,6 @@ import { Checkable, healthcheck } from "../../shared/interfaces/Checkable";
|
|
|
9
10
|
import { Constructor } from "@decaf-ts/decoration";
|
|
10
11
|
import { FabricContractContext } from "../ContractContext";
|
|
11
12
|
import { PrimaryKeyType } from "@decaf-ts/db-decorators";
|
|
12
|
-
import { ChaincodeStub, ClientIdentity } from "fabric-shim-api";
|
|
13
13
|
/**
|
|
14
14
|
* @description Base contract class for CRUD operations in Fabric chaincode
|
|
15
15
|
* @summary Provides standard create, read, update, and delete operations for models in Fabric chaincode
|
|
@@ -75,7 +75,7 @@ export declare abstract class FabricCrudContract<M extends Model> extends Contra
|
|
|
75
75
|
*/
|
|
76
76
|
protected constructor(name: string, clazz: Constructor<M>);
|
|
77
77
|
listBy(ctx: Ctx | FabricContractContext, key: string | keyof M, order: string, ...args: any[]): Promise<M[] | string>;
|
|
78
|
-
paginateBy(ctx: Ctx | FabricContractContext, key: string | keyof M, order: string, ref?: Omit<DirectionLimitOffset, "direction"> | string, ...args:
|
|
78
|
+
paginateBy(ctx: Ctx | FabricContractContext, key: string | keyof M, order: string, ref?: Omit<DirectionLimitOffset, "direction"> | string, ...args: any[]): Promise<SerializedPage<M> | string>;
|
|
79
79
|
findOneBy(ctx: Ctx | FabricContractContext, key: string | keyof M, value: any, ...args: any[]): Promise<M | string>;
|
|
80
80
|
statement(ctx: Ctx | FabricContractContext, method: string, ...args: any[]): Promise<any>;
|
|
81
81
|
/**
|
|
@@ -176,16 +176,7 @@ export declare abstract class FabricCrudContract<M extends Model> extends Contra
|
|
|
176
176
|
* @return {Promise<M[]>} Promise resolving to the created models
|
|
177
177
|
*/
|
|
178
178
|
createAll(ctx: Ctx | FabricContractContext, models: string | M[], ...args: any[]): Promise<string | M[]>;
|
|
179
|
-
logCtx<ARGS extends any[]>(args:
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}>;
|
|
183
|
-
protected static logCtx<ARGS extends any[]>(this: any, args: ARGS, method: string): Promise<ContextualizedArgs<FabricContractContext, ARGS> & {
|
|
184
|
-
stub: ChaincodeStub;
|
|
185
|
-
identity: ClientIdentity;
|
|
186
|
-
}>;
|
|
187
|
-
protected static logCtx<ARGS extends any[]>(this: any, args: ARGS, method: (...args: any[]) => any): Promise<ContextualizedArgs<FabricContractContext, ARGS> & {
|
|
188
|
-
stub: ChaincodeStub;
|
|
189
|
-
identity: ClientIdentity;
|
|
190
|
-
}>;
|
|
179
|
+
protected logCtx<ARGS extends any[] = any[], METHOD extends MethodOrOperation = MethodOrOperation>(args: MaybeContextualArg<FabricContractContext, ARGS>, operation: METHOD): FabricContextualizedArgs<ARGS, METHOD extends string ? true : false>;
|
|
180
|
+
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>;
|
|
181
|
+
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>>;
|
|
191
182
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crud-contract.js","sourceRoot":"","sources":["../../../src/contracts/crud/crud-contract.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"crud-contract.js","sourceRoot":"","sources":["../../../src/contracts/crud/crud-contract.ts"],"names":[],"mappings":";;;AAAA,8CAAgC;AAChC,8DAG4B;AAC5B,6DAI6B;AAC7B,yEAAmE;AACnE,yCAUwB;AAExB,wFAA+E;AAK/E,2DAIiC;AACjC,oDAAyD;AAEzD,IAAA,4BAAY,GAAE,CAAC,IAAI,CAAC,CAAC;AACrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,MAAsB,kBACpB,SAAQ,8BAAQ;IAGhB;;OAEG;aACc,YAAO,GAA0B,IAAI,uCAAqB,EAAE,AAArD,CAAsD;aAIpD,eAAU,GAAG,IAAI,iDAAuB,EAAE,AAAhC,CAAiC;IAIrE;;;;;OAKG;IACH,YACE,IAAY,EACO,KAAqB;QAExC,KAAK,CAAC,IAAI,CAAC,CAAC;QAFO,UAAK,GAAL,KAAK,CAAgB;QAVhC,gBAAW,GAAY,KAAK,CAAC;QAarC,IAAI,CAAC,IAAI,GAAG,iBAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAEvC,sBAAsB;IACxB,CAAC;IAED,KAAK,CAAC,MAAM,CACV,GAAgC,EAChC,GAAqB,EACrB,KAAa,EACb,GAAG,IAAW;QAEd,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,CACvB,MAAM,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,CAAC,EAAE,4BAAqB,CAAC,OAAO,EAAE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,CAAC,CAAC;QAC5E,OAAO,cAAc,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACzC,CAAC;;AA5bH,gDA2hBC"}
|
|
@@ -14,7 +14,6 @@ const crud_contract_1 = require("./crud-contract.cjs");
|
|
|
14
14
|
const fabric_contract_api_1 = require("fabric-contract-api");
|
|
15
15
|
const core_1 = require("@decaf-ts/core");
|
|
16
16
|
const db_decorators_1 = require("@decaf-ts/db-decorators");
|
|
17
|
-
const ContractContext_1 = require("./../ContractContext.cjs");
|
|
18
17
|
/**
|
|
19
18
|
* @description CRUD contract variant that serializes/deserializes payloads
|
|
20
19
|
* @summary Exposes the same CRUD operations as FabricCrudContract but takes and returns JSON strings to facilitate simple client interactions.
|
|
@@ -31,55 +30,34 @@ class SerializedCrudContract extends crud_contract_1.FabricCrudContract {
|
|
|
31
30
|
constructor(name, clazz) {
|
|
32
31
|
super(name, clazz);
|
|
33
32
|
}
|
|
34
|
-
async create(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
log.info(`Model deserialized: ${JSON.stringify(m)}`);
|
|
39
|
-
const result = await super.create(ctx, m);
|
|
40
|
-
const serialized = this.serialize(result);
|
|
41
|
-
log.info(`RESULT: ${JSON.stringify(result)}`);
|
|
42
|
-
log.info(`Retuning: ${serialized}`);
|
|
43
|
-
return serialized;
|
|
44
|
-
}
|
|
45
|
-
async read(context, key) {
|
|
46
|
-
const { log, ctx } = await this.logCtx([context], this.read);
|
|
47
|
-
log.info(`Reading id: ${key}`);
|
|
33
|
+
async create(ctx, model) {
|
|
34
|
+
return this.serialize((await super.create(ctx, model)));
|
|
35
|
+
}
|
|
36
|
+
async read(ctx, key) {
|
|
48
37
|
return this.serialize((await super.read(ctx, key)));
|
|
49
38
|
}
|
|
50
|
-
async update(
|
|
51
|
-
const { log, ctx } = await this.logCtx([context], this.update);
|
|
52
|
-
log.info(`Updating model: ${model}`);
|
|
39
|
+
async update(ctx, model) {
|
|
53
40
|
return this.serialize((await super.update(ctx, model)));
|
|
54
41
|
}
|
|
55
|
-
async delete(
|
|
56
|
-
const { log, ctx } = await this.logCtx([context], this.delete);
|
|
57
|
-
log.info(`Deleting id: ${key}`);
|
|
42
|
+
async delete(ctx, key) {
|
|
58
43
|
return this.serialize((await super.delete(ctx, key)));
|
|
59
44
|
}
|
|
60
|
-
async deleteAll(
|
|
45
|
+
async deleteAll(ctx, keys) {
|
|
61
46
|
const parsedKeys = JSON.parse(keys);
|
|
62
|
-
const { log, ctx } = await this.logCtx([context], this.deleteAll);
|
|
63
|
-
log.info(`deleting ${parsedKeys.length} entries from the table`);
|
|
64
47
|
return JSON.stringify((await super.deleteAll(ctx, parsedKeys)).map((m) => this.serialize(m)));
|
|
65
48
|
}
|
|
66
|
-
async readAll(
|
|
49
|
+
async readAll(ctx, keys) {
|
|
67
50
|
const parsedKeys = JSON.parse(keys);
|
|
68
|
-
const { log, ctx } = await this.logCtx([context], this.readAll);
|
|
69
|
-
log.info(`reading ${parsedKeys.length} entries from the table`);
|
|
70
51
|
return JSON.stringify((await super.readAll(ctx, parsedKeys)).map((m) => this.serialize(m)));
|
|
71
52
|
}
|
|
72
|
-
async updateAll(
|
|
73
|
-
const { log, ctx } = await this.logCtx([context], this.updateAll);
|
|
53
|
+
async updateAll(ctx, models) {
|
|
74
54
|
const list = JSON.parse(models);
|
|
75
55
|
const modelList = list
|
|
76
56
|
.map((m) => this.deserialize(m))
|
|
77
57
|
.map((m) => new this.clazz(m));
|
|
78
|
-
log.info(`Updating ${modelList.length} entries to the table`);
|
|
79
58
|
return JSON.stringify((await super.updateAll(ctx, modelList)).map((m) => this.serialize(m)));
|
|
80
59
|
}
|
|
81
|
-
async statement(
|
|
82
|
-
const { ctx, log } = await this.logCtx([context], this.statement);
|
|
60
|
+
async statement(ctx, method, args) {
|
|
83
61
|
try {
|
|
84
62
|
args = JSON.parse(args);
|
|
85
63
|
}
|
|
@@ -88,35 +66,25 @@ class SerializedCrudContract extends crud_contract_1.FabricCrudContract {
|
|
|
88
66
|
}
|
|
89
67
|
if (!Array.isArray(args))
|
|
90
68
|
throw new db_decorators_1.SerializationError(`Invalid args: ${JSON.stringify(args)}. must be an array`);
|
|
91
|
-
log.info(`calling prepared statement ${method}`);
|
|
92
|
-
log.info(`with args ${args}`);
|
|
93
69
|
return JSON.stringify(await super.statement(ctx, method, ...args));
|
|
94
70
|
}
|
|
95
|
-
async listBy(
|
|
96
|
-
const { ctx, log } = await this.logCtx([context], this.listBy);
|
|
97
|
-
log.info(`Executing listBy with key ${key} and order ${order}`);
|
|
71
|
+
async listBy(ctx, key, order) {
|
|
98
72
|
return JSON.stringify(await super.listBy(ctx, key, order));
|
|
99
73
|
}
|
|
100
|
-
async paginateBy(
|
|
101
|
-
const { ctx, log } = await this.logCtx([...args, context], this.paginateBy);
|
|
74
|
+
async paginateBy(ctx, key, order, ref) {
|
|
102
75
|
try {
|
|
103
76
|
ref = JSON.parse(ref);
|
|
104
77
|
}
|
|
105
78
|
catch (e) {
|
|
106
79
|
throw new db_decorators_1.SerializationError(`Failed to deserialize paginateBy reference: ${e}`);
|
|
107
80
|
}
|
|
108
|
-
|
|
109
|
-
return JSON.stringify(await super.paginateBy(ctx, key, order, ref, ...args));
|
|
81
|
+
return JSON.stringify(await super.paginateBy(ctx, key, order, ref));
|
|
110
82
|
}
|
|
111
|
-
async findOneBy(
|
|
112
|
-
|
|
113
|
-
log.info(`Executing findOneBy with key ${key} and value ${value}`);
|
|
114
|
-
return JSON.stringify(await super.findOneBy(ctx, key, value, ...args));
|
|
83
|
+
async findOneBy(ctx, key, value) {
|
|
84
|
+
return JSON.stringify(await super.findOneBy(ctx, key, value));
|
|
115
85
|
}
|
|
116
86
|
// @Transaction(false)
|
|
117
|
-
async query(
|
|
118
|
-
const { ctx, log } = await this.logCtx([context], this.query);
|
|
119
|
-
log.info(`Executing query orderedBy ${orderBy} and order ${order}`);
|
|
87
|
+
async query(ctx, condition, orderBy, order, limit, skip) {
|
|
120
88
|
let cond;
|
|
121
89
|
try {
|
|
122
90
|
cond = core_1.Condition.from(JSON.parse(condition));
|
|
@@ -124,7 +92,6 @@ class SerializedCrudContract extends crud_contract_1.FabricCrudContract {
|
|
|
124
92
|
catch (e) {
|
|
125
93
|
throw new db_decorators_1.SerializationError(`Invalid condition: ${e}`);
|
|
126
94
|
}
|
|
127
|
-
log.info(`Condition: ${JSON.stringify(cond)}`);
|
|
128
95
|
return JSON.stringify(await super.query(ctx, cond, orderBy, order, limit, skip));
|
|
129
96
|
}
|
|
130
97
|
//
|
|
@@ -142,19 +109,15 @@ class SerializedCrudContract extends crud_contract_1.FabricCrudContract {
|
|
|
142
109
|
async init(ctx) {
|
|
143
110
|
await super.init(ctx);
|
|
144
111
|
}
|
|
145
|
-
async healthcheck(
|
|
146
|
-
const { log, ctx } = await this.logCtx([context], this.updateAll);
|
|
147
|
-
log.debug(`Running Healthcheck: ${this.initialized}...`);
|
|
112
|
+
async healthcheck(ctx) {
|
|
148
113
|
//TODO: TRIM NOT WORKING CHECK LATER
|
|
149
114
|
return JSON.stringify(await super.healthcheck(ctx));
|
|
150
115
|
}
|
|
151
116
|
async createAll(context, models) {
|
|
152
|
-
const { log } = await this.logCtx([context], this.createAll);
|
|
153
117
|
const list = JSON.parse(models);
|
|
154
118
|
const modelList = list
|
|
155
119
|
.map((m) => this.deserialize(m))
|
|
156
120
|
.map((m) => new this.clazz(m));
|
|
157
|
-
log.info(`Adding ${modelList.length} entries to the table`);
|
|
158
121
|
const result = (await super.createAll(context, modelList));
|
|
159
122
|
return JSON.stringify(result.map((m) => this.serialize(m)));
|
|
160
123
|
}
|
|
@@ -217,13 +180,13 @@ __decorate([
|
|
|
217
180
|
__decorate([
|
|
218
181
|
(0, fabric_contract_api_1.Transaction)(false),
|
|
219
182
|
__metadata("design:type", Function),
|
|
220
|
-
__metadata("design:paramtypes", [fabric_contract_api_1.Context, String, String, String
|
|
183
|
+
__metadata("design:paramtypes", [fabric_contract_api_1.Context, String, String, String]),
|
|
221
184
|
__metadata("design:returntype", Promise)
|
|
222
185
|
], SerializedCrudContract.prototype, "paginateBy", null);
|
|
223
186
|
__decorate([
|
|
224
187
|
(0, fabric_contract_api_1.Transaction)(false),
|
|
225
188
|
__metadata("design:type", Function),
|
|
226
|
-
__metadata("design:paramtypes", [fabric_contract_api_1.Context, String, String
|
|
189
|
+
__metadata("design:paramtypes", [fabric_contract_api_1.Context, String, String]),
|
|
227
190
|
__metadata("design:returntype", Promise)
|
|
228
191
|
], SerializedCrudContract.prototype, "findOneBy", null);
|
|
229
192
|
__decorate([
|
|
@@ -2,8 +2,6 @@ import { FabricCrudContract } from "./crud-contract";
|
|
|
2
2
|
import { Model } from "@decaf-ts/decorator-validation";
|
|
3
3
|
import { Context as Ctx } from "fabric-contract-api";
|
|
4
4
|
import { Constructor } from "@decaf-ts/decoration";
|
|
5
|
-
import { MaybeContextualArg } from "@decaf-ts/core";
|
|
6
|
-
import { FabricContractContext } from "../ContractContext";
|
|
7
5
|
/**
|
|
8
6
|
* @description CRUD contract variant that serializes/deserializes payloads
|
|
9
7
|
* @summary Exposes the same CRUD operations as FabricCrudContract but takes and returns JSON strings to facilitate simple client interactions.
|
|
@@ -18,19 +16,19 @@ import { FabricContractContext } from "../ContractContext";
|
|
|
18
16
|
*/
|
|
19
17
|
export declare class SerializedCrudContract<M extends Model> extends FabricCrudContract<M> {
|
|
20
18
|
constructor(name: string, clazz: Constructor<M>);
|
|
21
|
-
create(
|
|
22
|
-
read(
|
|
23
|
-
update(
|
|
24
|
-
delete(
|
|
25
|
-
deleteAll(
|
|
26
|
-
readAll(
|
|
27
|
-
updateAll(
|
|
28
|
-
statement(
|
|
29
|
-
listBy(
|
|
30
|
-
paginateBy(
|
|
31
|
-
findOneBy(
|
|
32
|
-
query(
|
|
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
|
+
findOneBy(ctx: Ctx, key: string, value: string): Promise<string>;
|
|
30
|
+
query(ctx: Ctx, condition: string, orderBy: string, order: string, limit?: number, skip?: number): Promise<string>;
|
|
33
31
|
init(ctx: Ctx): Promise<void>;
|
|
34
|
-
healthcheck(
|
|
32
|
+
healthcheck(ctx: Ctx): Promise<string>;
|
|
35
33
|
createAll(context: Ctx, models: string): Promise<string>;
|
|
36
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialized-crud-contract.js","sourceRoot":"","sources":["../../../src/contracts/crud/serialized-crud-contract.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uDAAqD;AAErD,6DAAkE;AAElE,
|
|
1
|
+
{"version":3,"file":"serialized-crud-contract.js","sourceRoot":"","sources":["../../../src/contracts/crud/serialized-crud-contract.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uDAAqD;AAErD,6DAAkE;AAElE,yCAA2D;AAC3D,2DAA6D;AAE7D;;;;;;;;;;;GAWG;AACH,MAAa,sBAEX,SAAQ,kCAAqB;IAC7B,YAAY,IAAY,EAAE,KAAqB;QAC7C,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACrB,CAAC;IAGc,AAAN,KAAK,CAAC,MAAM,CAAC,GAAQ,EAAE,KAAa;QAC3C,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,KAAK,CAAC,MAAM,CAAC,GAAU,EAAE,KAAK,CAAC,CAAM,CAAC,CAAC;IACtE,CA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iCAAW,GAAE;;qCACa,6BAAG;;oDAE7B;AAGc;IADd,IAAA,iCAAW,GAAE;;qCACgB,6BAAG;;uDAOhC;AAGc;IADd,IAAA,iCAAW,EAAC,KAAK,CAAC;;qCACS,6BAAG;;qDAO9B;AAGc;IADd,IAAA,iCAAW,GAAE;;qCACgB,6BAAG;;uDAWhC;AAGc;IADd,IAAA,iCAAW,EAAC,KAAK,CAAC;;qCACW,6BAAG;;uDAWhC;AAGc;IADd,IAAA,iCAAW,EAAC,KAAK,CAAC;;qCACQ,6BAAG;;oDAI7B;AAGc;IADd,IAAA,iCAAW,EAAC,KAAK,CAAC;;qCAEZ,6BAAG;;wDAeT;AAGc;IADd,IAAA,iCAAW,EAAC,KAAK,CAAC;;qCACW,6BAAG;;uDAEhC;AAoCc;IADd,IAAA,iCAAW,GAAE;;qCACW,6BAAG;;kDAE3B;AAGc;IADd,IAAA,iCAAW,EAAC,KAAK,CAAC;;qCACa,6BAAG;;yDAGlC;AAGc;IADd,IAAA,iCAAW,GAAE;;qCACoB,6BAAG;;uDAQpC"}
|
|
@@ -38,7 +38,7 @@ let ERC20Token = class ERC20Token extends core_1.BaseModel {
|
|
|
38
38
|
};
|
|
39
39
|
exports.ERC20Token = ERC20Token;
|
|
40
40
|
__decorate([
|
|
41
|
-
(0, core_1.pk)({ type:
|
|
41
|
+
(0, core_1.pk)({ type: String })
|
|
42
42
|
/**
|
|
43
43
|
* @description Token unique name
|
|
44
44
|
* @summary Serves as the primary key for the ERC20 token definition; typically a human-readable identifier
|
|
@@ -104,7 +104,7 @@ let ERC20Wallet = class ERC20Wallet extends core_1.BaseModel {
|
|
|
104
104
|
};
|
|
105
105
|
exports.ERC20Wallet = ERC20Wallet;
|
|
106
106
|
__decorate([
|
|
107
|
-
(0, core_1.pk)({ type:
|
|
107
|
+
(0, core_1.pk)({ type: String })
|
|
108
108
|
/**
|
|
109
109
|
* @description Wallet unique identifier
|
|
110
110
|
* @summary Primary key for the wallet; commonly references an account or identity
|
|
@@ -166,7 +166,7 @@ let Allowance = class Allowance extends core_1.BaseModel {
|
|
|
166
166
|
};
|
|
167
167
|
exports.Allowance = Allowance;
|
|
168
168
|
__decorate([
|
|
169
|
-
(0, core_1.pk)({ type:
|
|
169
|
+
(0, core_1.pk)({ type: String })
|
|
170
170
|
/**
|
|
171
171
|
* @description Allowance unique identifier
|
|
172
172
|
* @summary Primary key for the allowance; typically a unique identifier for the approval relationship
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../../src/contracts/erc20/models.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAA8D;AAC9D,yEAAgF;AAEhF;;;;;;;;;;;;;;;;;;GAkBG;AAGI,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,gBAAS;IA8BvC,YAAY,CAAyB;QACnC,KAAK,CAAC,CAAC,CAAC,CAAC;IACX,CAAC;CACF,CAAA;AAjCY,gCAAU;AAMrB;IALC,IAAA,SAAE,EAAC,EAAE,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../../src/contracts/erc20/models.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAA8D;AAC9D,yEAAgF;AAEhF;;;;;;;;;;;;;;;;;;GAkBG;AAGI,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,gBAAS;IA8BvC,YAAY,CAAyB;QACnC,KAAK,CAAC,CAAC,CAAC,CAAC;IACX,CAAC;CACF,CAAA;AAjCY,gCAAU;AAMrB;IALC,IAAA,SAAE,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IACrB;;;OAGG;;;wCACW;AAQd;IANC,IAAA,aAAM,GAAE;IACR,IAAA,+BAAQ,GAAE;IACX;;;OAGG;;;yCACY;AAOf;IANC,IAAA,aAAM,GAAE;IACR,IAAA,+BAAQ,GAAE;IACX;;;OAGG;;;0CACa;AAOhB;IANC,IAAA,aAAM,GAAE;IACR,IAAA,+BAA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A,4BAAK,GAAE;;GACK,SAAS,CAiCrB"}
|
|
@@ -41,6 +41,7 @@ class ContractLogger extends logging_1.MiniLogger {
|
|
|
41
41
|
}
|
|
42
42
|
else {
|
|
43
43
|
this.logger = ctx.logging.getLogger(context);
|
|
44
|
+
ctx.logging.setLevel(conf?.level || logging_1.Logging.getConfig().level);
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
/**
|
|
@@ -57,6 +58,9 @@ class ContractLogger extends logging_1.MiniLogger {
|
|
|
57
58
|
return;
|
|
58
59
|
let method;
|
|
59
60
|
switch (level) {
|
|
61
|
+
case logging_1.LogLevel.benchmark:
|
|
62
|
+
method = this.logger.verbose;
|
|
63
|
+
break;
|
|
60
64
|
case logging_1.LogLevel.info:
|
|
61
65
|
method = this.logger.info;
|
|
62
66
|
break;
|
|
@@ -69,6 +73,9 @@ class ContractLogger extends logging_1.MiniLogger {
|
|
|
69
73
|
case logging_1.LogLevel.error:
|
|
70
74
|
method = this.logger.error;
|
|
71
75
|
break;
|
|
76
|
+
case logging_1.LogLevel.trace:
|
|
77
|
+
method = this.logger.trace;
|
|
78
|
+
break;
|
|
72
79
|
case logging_1.LogLevel.warn:
|
|
73
80
|
method = this.logger.warn;
|
|
74
81
|
break;
|