@decaf-ts/for-fabric 0.1.16 → 0.1.18
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/bin/build-contracts2.cjs +73 -0
- package/lib/bin/build-contracts2.d.ts +1 -0
- package/lib/bin/build-contracts2.js.map +1 -0
- package/lib/bin/compile-indexes.cjs +30 -0
- package/lib/bin/compile-indexes.d.ts +1 -0
- package/lib/bin/compile-indexes.js.map +1 -0
- package/lib/cli-module.cjs +139 -0
- package/lib/cli-module.d.ts +2 -0
- package/lib/cli-module.js.map +1 -0
- package/lib/client/FabricClientAdapter.cjs +39 -40
- package/lib/client/FabricClientAdapter.d.ts +17 -13
- package/lib/client/FabricClientAdapter.js.map +1 -1
- package/lib/client/FabricClientPaginator.cjs +69 -0
- package/lib/client/FabricClientPaginator.d.ts +10 -0
- package/lib/client/FabricClientPaginator.js.map +1 -0
- package/lib/client/FabricClientRepository.cjs +36 -12
- package/lib/client/FabricClientRepository.d.ts +5 -1
- package/lib/client/FabricClientRepository.js.map +1 -1
- package/lib/client/FabricClientStatement.cjs +111 -0
- package/lib/client/FabricClientStatement.d.ts +10 -0
- package/lib/client/FabricClientStatement.js.map +1 -0
- package/lib/client/fabric-fs.d.ts +1 -1
- package/lib/client/indexes/generation.cjs +156 -0
- package/lib/client/indexes/generation.d.ts +16 -0
- package/lib/client/indexes/generation.js.map +1 -0
- package/lib/client/indexes/index.cjs +18 -0
- package/lib/client/indexes/index.d.ts +1 -0
- package/lib/client/indexes/index.js.map +1 -0
- package/lib/client/services/FabricEnrollmentService.d.ts +1 -1
- package/lib/client/types.cjs +3 -0
- package/lib/client/types.d.ts +7 -0
- package/lib/client/types.js.map +1 -0
- package/lib/contracts/ContractAdapter.cjs +54 -44
- package/lib/contracts/ContractAdapter.d.ts +20 -9
- package/lib/contracts/ContractAdapter.js.map +1 -1
- package/lib/contracts/ContractPrivateDataAdapter.cjs +0 -5
- package/lib/contracts/ContractPrivateDataAdapter.js.map +1 -1
- package/lib/contracts/FabricContractRepository.d.ts +2 -2
- package/lib/contracts/FabricContractRepository.js.map +1 -1
- package/lib/contracts/crud/crud-contract.cjs +30 -1
- package/lib/contracts/crud/crud-contract.d.ts +29 -14
- package/lib/contracts/crud/crud-contract.js.map +1 -1
- package/lib/contracts/crud/serialized-crud-contract.cjs +27 -15
- package/lib/contracts/crud/serialized-crud-contract.d.ts +9 -8
- package/lib/contracts/crud/serialized-crud-contract.js.map +1 -1
- package/lib/contracts/erc20/erc20contract.cjs +40 -34
- package/lib/contracts/erc20/erc20contract.d.ts +15 -15
- package/lib/contracts/erc20/erc20contract.js.map +1 -1
- package/lib/contracts/index.cjs +1 -2
- package/lib/contracts/index.d.ts +1 -2
- package/lib/contracts/index.js.map +1 -1
- package/lib/esm/bin/build-contracts2.d.ts +1 -0
- package/lib/esm/bin/build-contracts2.js +68 -0
- package/lib/esm/bin/build-contracts2.js.map +1 -0
- package/lib/esm/bin/compile-indexes.d.ts +1 -0
- package/lib/esm/bin/compile-indexes.js +25 -0
- package/lib/esm/bin/compile-indexes.js.map +1 -0
- package/lib/esm/cli-module.d.ts +2 -0
- package/lib/esm/cli-module.js +133 -0
- package/lib/esm/cli-module.js.map +1 -0
- package/lib/esm/client/FabricClientAdapter.d.ts +17 -13
- package/lib/esm/client/FabricClientAdapter.js +41 -42
- package/lib/esm/client/FabricClientAdapter.js.map +1 -1
- package/lib/esm/client/FabricClientPaginator.d.ts +10 -0
- package/lib/esm/client/FabricClientPaginator.js +65 -0
- package/lib/esm/client/FabricClientPaginator.js.map +1 -0
- package/lib/esm/client/FabricClientRepository.d.ts +5 -1
- package/lib/esm/client/FabricClientRepository.js +37 -13
- package/lib/esm/client/FabricClientRepository.js.map +1 -1
- package/lib/esm/client/FabricClientStatement.d.ts +10 -0
- package/lib/esm/client/FabricClientStatement.js +107 -0
- package/lib/esm/client/FabricClientStatement.js.map +1 -0
- package/lib/esm/client/fabric-fs.d.ts +1 -1
- package/lib/esm/client/indexes/generation.d.ts +16 -0
- package/lib/esm/client/indexes/generation.js +118 -0
- package/lib/esm/client/indexes/generation.js.map +1 -0
- package/lib/esm/client/indexes/index.d.ts +1 -0
- package/lib/esm/client/indexes/index.js +2 -0
- package/lib/esm/client/indexes/index.js.map +1 -0
- package/lib/esm/client/services/FabricEnrollmentService.d.ts +1 -1
- package/lib/esm/client/types.d.ts +7 -0
- package/lib/esm/client/types.js +2 -0
- package/lib/esm/client/types.js.map +1 -0
- package/lib/esm/contracts/ContractAdapter.d.ts +20 -9
- package/lib/esm/contracts/ContractAdapter.js +55 -45
- package/lib/esm/contracts/ContractAdapter.js.map +1 -1
- package/lib/esm/contracts/ContractPrivateDataAdapter.js +0 -5
- package/lib/esm/contracts/ContractPrivateDataAdapter.js.map +1 -1
- package/lib/esm/contracts/FabricContractRepository.d.ts +2 -2
- package/lib/esm/contracts/FabricContractRepository.js.map +1 -1
- package/lib/esm/contracts/crud/crud-contract.d.ts +29 -14
- package/lib/esm/contracts/crud/crud-contract.js +31 -2
- package/lib/esm/contracts/crud/crud-contract.js.map +1 -1
- package/lib/esm/contracts/crud/serialized-crud-contract.d.ts +9 -8
- package/lib/esm/contracts/crud/serialized-crud-contract.js +27 -15
- package/lib/esm/contracts/crud/serialized-crud-contract.js.map +1 -1
- package/lib/esm/contracts/erc20/erc20contract.d.ts +15 -15
- package/lib/esm/contracts/erc20/erc20contract.js +40 -34
- package/lib/esm/contracts/erc20/erc20contract.js.map +1 -1
- package/lib/esm/contracts/index.d.ts +1 -2
- package/lib/esm/contracts/index.js +1 -2
- package/lib/esm/contracts/index.js.map +1 -1
- package/lib/esm/shared/model/FabricBaseModel.d.ts +7 -0
- package/lib/esm/shared/model/FabricBaseModel.js +40 -0
- package/lib/esm/shared/model/FabricBaseModel.js.map +1 -0
- package/lib/esm/shared/model/FabricIdentifiedBaseModel.d.ts +7 -0
- package/lib/esm/shared/model/{Sequence.js → FabricIdentifiedBaseModel.js} +19 -18
- package/lib/esm/shared/model/FabricIdentifiedBaseModel.js.map +1 -0
- package/lib/esm/shared/model/Identity.js +2 -1
- package/lib/esm/shared/model/Identity.js.map +1 -1
- package/lib/esm/shared/model/index.d.ts +0 -1
- package/lib/esm/shared/model/index.js +0 -1
- package/lib/esm/shared/model/index.js.map +1 -1
- package/lib/esm/shared/utils.d.ts +1 -1
- package/lib/esm/version.d.ts +1 -1
- package/lib/esm/version.js +1 -1
- package/lib/shared/model/FabricBaseModel.cjs +43 -0
- package/lib/shared/model/FabricBaseModel.d.ts +7 -0
- package/lib/shared/model/FabricBaseModel.js.map +1 -0
- package/lib/shared/model/FabricIdentifiedBaseModel.cjs +37 -0
- package/lib/shared/model/FabricIdentifiedBaseModel.d.ts +7 -0
- package/lib/shared/model/FabricIdentifiedBaseModel.js.map +1 -0
- package/lib/shared/model/Identity.cjs +1 -0
- package/lib/shared/model/Identity.js.map +1 -1
- package/lib/shared/model/index.cjs +0 -1
- package/lib/shared/model/index.d.ts +0 -1
- package/lib/shared/model/index.js.map +1 -1
- package/lib/shared/utils.d.ts +1 -1
- package/lib/version.cjs +1 -1
- package/lib/version.d.ts +1 -1
- package/package.json +10 -6
- package/lib/contracts/FabricContractSequence.cjs +0 -119
- package/lib/contracts/FabricContractSequence.d.ts +0 -50
- package/lib/contracts/FabricContractSequence.js.map +0 -1
- package/lib/esm/contracts/FabricContractSequence.d.ts +0 -50
- package/lib/esm/contracts/FabricContractSequence.js +0 -115
- package/lib/esm/contracts/FabricContractSequence.js.map +0 -1
- package/lib/esm/shared/model/Sequence.d.ts +0 -14
- package/lib/esm/shared/model/Sequence.js.map +0 -1
- package/lib/shared/model/Sequence.cjs +0 -36
- package/lib/shared/model/Sequence.d.ts +0 -14
- package/lib/shared/model/Sequence.js.map +0 -1
|
@@ -8,6 +8,8 @@ import { MangoQuery } from "@decaf-ts/for-couchdb";
|
|
|
8
8
|
import { Checkable, healthcheck } from "../../shared/interfaces/Checkable";
|
|
9
9
|
import { Constructor } from "@decaf-ts/decoration";
|
|
10
10
|
import { FabricContractContext } from "../ContractContext";
|
|
11
|
+
import { PrimaryKeyType } from "@decaf-ts/db-decorators";
|
|
12
|
+
import { ChaincodeStub, ClientIdentity } from "fabric-shim-api";
|
|
11
13
|
/**
|
|
12
14
|
* @description Base contract class for CRUD operations in Fabric chaincode
|
|
13
15
|
* @summary Provides standard create, read, update, and delete operations for models in Fabric chaincode
|
|
@@ -72,6 +74,10 @@ export declare abstract class FabricCrudContract<M extends Model> extends Contra
|
|
|
72
74
|
* @param {Constructor<M>} clazz - The model constructor
|
|
73
75
|
*/
|
|
74
76
|
protected constructor(name: string, clazz: Constructor<M>);
|
|
77
|
+
listBy(ctx: Ctx | FabricContractContext, key: keyof M, order: string, ...args: any[]): Promise<M[]>;
|
|
78
|
+
paginateBy(ctx: Ctx | FabricContractContext, key: keyof M, order: string, size: number, ...args: any[]): Promise<import("@decaf-ts/core").Paginator<M, M[], any>>;
|
|
79
|
+
findOneBy(ctx: Ctx | FabricContractContext, key: keyof M, value: any, ...args: any[]): Promise<M[]>;
|
|
80
|
+
statement(ctx: Ctx | FabricContractContext, method: string, ...args: any[]): Promise<any>;
|
|
75
81
|
/**
|
|
76
82
|
* @description Creates a single model in the state database
|
|
77
83
|
* @summary Delegates to the repository's create method
|
|
@@ -80,7 +86,7 @@ export declare abstract class FabricCrudContract<M extends Model> extends Contra
|
|
|
80
86
|
* @param {...any[]} args - Additional arguments
|
|
81
87
|
* @return {Promise<M>} Promise resolving to the created model
|
|
82
88
|
*/
|
|
83
|
-
create(ctx: Ctx, model: string | M, ...args: any[]): Promise<string | M>;
|
|
89
|
+
create(ctx: Ctx | FabricContractContext, model: string | M, ...args: any[]): Promise<string | M>;
|
|
84
90
|
/**
|
|
85
91
|
* @description Reads a single model from the state database
|
|
86
92
|
* @summary Delegates to the repository's read method
|
|
@@ -89,8 +95,8 @@ export declare abstract class FabricCrudContract<M extends Model> extends Contra
|
|
|
89
95
|
* @param {...any[]} args - Additional arguments
|
|
90
96
|
* @return {Promise<M>} Promise resolving to the retrieved model
|
|
91
97
|
*/
|
|
92
|
-
read(ctx: Ctx, key:
|
|
93
|
-
protected getTransientData(ctx: Ctx): any;
|
|
98
|
+
read(ctx: Ctx | FabricContractContext, key: PrimaryKeyType | string, ...args: any[]): Promise<M | string>;
|
|
99
|
+
protected getTransientData(ctx: Ctx | FabricContractContext): any;
|
|
94
100
|
/**
|
|
95
101
|
* @description Updates a single model in the state database
|
|
96
102
|
* @summary Delegates to the repository's update method
|
|
@@ -99,7 +105,7 @@ export declare abstract class FabricCrudContract<M extends Model> extends Contra
|
|
|
99
105
|
* @param {...any[]} args - Additional arguments
|
|
100
106
|
* @return {Promise<M>} Promise resolving to the updated model
|
|
101
107
|
*/
|
|
102
|
-
update(ctx: Ctx, model: string | M, ...args: any[]): Promise<string | M>;
|
|
108
|
+
update(ctx: Ctx | FabricContractContext, model: string | M, ...args: any[]): Promise<string | M>;
|
|
103
109
|
/**
|
|
104
110
|
* @description Deletes a single model from the state database
|
|
105
111
|
* @summary Delegates to the repository's delete method
|
|
@@ -108,7 +114,7 @@ export declare abstract class FabricCrudContract<M extends Model> extends Contra
|
|
|
108
114
|
* @param {...any[]} args - Additional arguments
|
|
109
115
|
* @return {Promise<M>} Promise resolving to the deleted model
|
|
110
116
|
*/
|
|
111
|
-
delete(ctx: Ctx, key:
|
|
117
|
+
delete(ctx: Ctx | FabricContractContext, key: PrimaryKeyType | string, ...args: any[]): Promise<M | string>;
|
|
112
118
|
/**
|
|
113
119
|
* @description Deletes multiple models from the state database
|
|
114
120
|
* @summary Delegates to the repository's deleteAll method
|
|
@@ -117,7 +123,7 @@ export declare abstract class FabricCrudContract<M extends Model> extends Contra
|
|
|
117
123
|
* @param {...any[]} args - Additional arguments
|
|
118
124
|
* @return {Promise<M[]>} Promise resolving to the deleted models
|
|
119
125
|
*/
|
|
120
|
-
deleteAll(ctx: Ctx, keys:
|
|
126
|
+
deleteAll(ctx: Ctx | FabricContractContext, keys: PrimaryKeyType[] | string, ...args: any[]): Promise<M[] | string>;
|
|
121
127
|
/**
|
|
122
128
|
* @description Reads multiple models from the state database
|
|
123
129
|
* @summary Delegates to the repository's readAll method
|
|
@@ -126,7 +132,7 @@ export declare abstract class FabricCrudContract<M extends Model> extends Contra
|
|
|
126
132
|
* @param {...any[]} args - Additional arguments
|
|
127
133
|
* @return {Promise<M[]>} Promise resolving to the retrieved models
|
|
128
134
|
*/
|
|
129
|
-
readAll(ctx: Ctx, keys:
|
|
135
|
+
readAll(ctx: Ctx | FabricContractContext, keys: PrimaryKeyType[] | string, ...args: any[]): Promise<M[] | string>;
|
|
130
136
|
/**
|
|
131
137
|
* @description Updates multiple models in the state database
|
|
132
138
|
* @summary Delegates to the repository's updateAll method
|
|
@@ -135,7 +141,7 @@ export declare abstract class FabricCrudContract<M extends Model> extends Contra
|
|
|
135
141
|
* @param {...any[]} args - Additional arguments
|
|
136
142
|
* @return {Promise<M[]>} Promise resolving to the updated models
|
|
137
143
|
*/
|
|
138
|
-
updateAll(ctx: Ctx, models: string | M[], ...args: any[]): Promise<string | M[]>;
|
|
144
|
+
updateAll(ctx: Ctx | FabricContractContext, models: string | M[], ...args: any[]): Promise<string | M[]>;
|
|
139
145
|
/**
|
|
140
146
|
* @description Executes a raw query against the state database
|
|
141
147
|
* @summary Delegates to the repository's raw method
|
|
@@ -148,8 +154,8 @@ export declare abstract class FabricCrudContract<M extends Model> extends Contra
|
|
|
148
154
|
raw(ctx: Ctx | FabricContractContext, rawInput: MangoQuery | string, docsOnly: boolean, ...args: any[]): Promise<any | string>;
|
|
149
155
|
protected serialize(model: M): string;
|
|
150
156
|
protected deserialize<M extends Model>(str: string): M;
|
|
151
|
-
protected init(ctx: Ctx): Promise<void>;
|
|
152
|
-
healthcheck(ctx: Ctx): Promise<string | healthcheck>;
|
|
157
|
+
protected init(ctx: Ctx | FabricContractContext): Promise<void>;
|
|
158
|
+
healthcheck(ctx: Ctx | FabricContractContext): Promise<string | healthcheck>;
|
|
153
159
|
/**
|
|
154
160
|
* @description Creates multiple models in the state database
|
|
155
161
|
* @summary Delegates to the repository's createAll method
|
|
@@ -158,8 +164,17 @@ export declare abstract class FabricCrudContract<M extends Model> extends Contra
|
|
|
158
164
|
* @param {...any[]} args - Additional arguments
|
|
159
165
|
* @return {Promise<M[]>} Promise resolving to the created models
|
|
160
166
|
*/
|
|
161
|
-
createAll(ctx: Ctx, models: string | M[], ...args: any[]): Promise<string | M[]>;
|
|
162
|
-
logCtx<ARGS extends any[]>(args: ARGS, method: ((...args: any[]) => any) | string): Promise<ContextualizedArgs<FabricContractContext, ARGS
|
|
163
|
-
|
|
164
|
-
|
|
167
|
+
createAll(ctx: Ctx | FabricContractContext, models: string | M[], ...args: any[]): Promise<string | M[]>;
|
|
168
|
+
logCtx<ARGS extends any[]>(args: ARGS, method: ((...args: any[]) => any) | string): Promise<ContextualizedArgs<FabricContractContext, ARGS> & {
|
|
169
|
+
stub: ChaincodeStub;
|
|
170
|
+
identity: ClientIdentity;
|
|
171
|
+
}>;
|
|
172
|
+
protected static logCtx<ARGS extends any[]>(this: any, args: ARGS, method: string): Promise<ContextualizedArgs<FabricContractContext, ARGS> & {
|
|
173
|
+
stub: ChaincodeStub;
|
|
174
|
+
identity: ClientIdentity;
|
|
175
|
+
}>;
|
|
176
|
+
protected static logCtx<ARGS extends any[]>(this: any, args: ARGS, method: (...args: any[]) => any): Promise<ContextualizedArgs<FabricContractContext, ARGS> & {
|
|
177
|
+
stub: ChaincodeStub;
|
|
178
|
+
identity: ClientIdentity;
|
|
179
|
+
}>;
|
|
165
180
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crud-contract.js","sourceRoot":"","sources":["../../../src/contracts/crud/crud-contract.ts"],"names":[],"mappings":";;;AAAA,8DAA2D;AAC3D,6DAAwE;AACxE,yEAAmE;A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1.FabricCrudContract {
|
|
|
28
28
|
constructor(name, clazz) {
|
|
29
29
|
super(name, clazz);
|
|
30
30
|
}
|
|
31
|
-
async create(
|
|
32
|
-
const { log } = await this.logCtx([
|
|
31
|
+
async create(context, model) {
|
|
32
|
+
const { log, ctx } = await this.logCtx([context], this.create);
|
|
33
33
|
log.info(`Creating model: ${model}`);
|
|
34
34
|
const m = this.deserialize(model);
|
|
35
35
|
log.info(`Model deserialized: ${JSON.stringify(m)}`);
|
|
36
36
|
return this.serialize((await super.create(ctx, m)));
|
|
37
37
|
}
|
|
38
|
-
async read(
|
|
39
|
-
const { log } = await this.logCtx([
|
|
38
|
+
async read(context, key) {
|
|
39
|
+
const { log, ctx } = await this.logCtx([context], this.read);
|
|
40
40
|
log.info(`Reading id: ${key}`);
|
|
41
41
|
return this.serialize((await super.read(ctx, key)));
|
|
42
42
|
}
|
|
43
|
-
async update(
|
|
44
|
-
const { log } = await this.logCtx([
|
|
43
|
+
async update(context, model) {
|
|
44
|
+
const { log, ctx } = await this.logCtx([context], this.update);
|
|
45
45
|
log.info(`Updating model: ${model}`);
|
|
46
46
|
return this.serialize((await super.update(ctx, model)));
|
|
47
47
|
}
|
|
48
|
-
async delete(
|
|
49
|
-
const { log } = await this.logCtx([
|
|
48
|
+
async delete(context, key) {
|
|
49
|
+
const { log, ctx } = await this.logCtx([context], this.delete);
|
|
50
50
|
log.info(`Deleting id: ${key}`);
|
|
51
51
|
return this.serialize((await super.delete(ctx, key)));
|
|
52
52
|
}
|
|
53
|
-
async deleteAll(
|
|
53
|
+
async deleteAll(context, keys) {
|
|
54
54
|
const parsedKeys = JSON.parse(keys);
|
|
55
|
-
const { log } = await this.logCtx([
|
|
55
|
+
const { log, ctx } = await this.logCtx([context], this.deleteAll);
|
|
56
56
|
log.info(`deleting ${parsedKeys.length} entries from the table`);
|
|
57
57
|
return JSON.stringify((await super.deleteAll(ctx, parsedKeys)).map((m) => this.serialize(m)));
|
|
58
58
|
}
|
|
59
|
-
async readAll(
|
|
59
|
+
async readAll(context, keys) {
|
|
60
60
|
const parsedKeys = JSON.parse(keys);
|
|
61
|
-
const { log } = await this.logCtx([
|
|
61
|
+
const { log, ctx } = await this.logCtx([context], this.readAll);
|
|
62
62
|
log.info(`reading ${parsedKeys.length} entries from the table`);
|
|
63
63
|
return JSON.stringify((await super.readAll(ctx, parsedKeys)).map((m) => this.serialize(m)));
|
|
64
64
|
}
|
|
65
|
-
async updateAll(
|
|
66
|
-
const { log } = await this.logCtx([
|
|
65
|
+
async updateAll(context, models) {
|
|
66
|
+
const { log, ctx } = await this.logCtx([context], this.updateAll);
|
|
67
67
|
const list = JSON.parse(models);
|
|
68
68
|
const modelList = list
|
|
69
69
|
.map((m) => this.deserialize(m))
|
|
@@ -71,6 +71,10 @@ class SerializedCrudContract extends crud_contract_1.FabricCrudContract {
|
|
|
71
71
|
log.info(`Updating ${modelList.length} entries to the table`);
|
|
72
72
|
return JSON.stringify((await super.updateAll(ctx, modelList)).map((m) => this.serialize(m)));
|
|
73
73
|
}
|
|
74
|
+
async statement(context, method) {
|
|
75
|
+
const { ctx } = await this.logCtx([context], this.statement);
|
|
76
|
+
return super.statement(ctx, method);
|
|
77
|
+
}
|
|
74
78
|
async raw(context, rawInput, docsOnly) {
|
|
75
79
|
const { ctx } = await this.logCtx([context], this.raw);
|
|
76
80
|
const parsedInput = JSON.parse(rawInput);
|
|
@@ -79,7 +83,9 @@ class SerializedCrudContract extends crud_contract_1.FabricCrudContract {
|
|
|
79
83
|
async init(ctx) {
|
|
80
84
|
await super.init(ctx);
|
|
81
85
|
}
|
|
82
|
-
async healthcheck(
|
|
86
|
+
async healthcheck(context) {
|
|
87
|
+
const { log, ctx } = await this.logCtx([context], this.updateAll);
|
|
88
|
+
log.debug(`Running Healthcheck: ${this.initialized}...`);
|
|
83
89
|
//TODO: TRIM NOT WORKING CHECK LATER
|
|
84
90
|
return JSON.stringify(await super.healthcheck(ctx));
|
|
85
91
|
}
|
|
@@ -136,6 +142,12 @@ __decorate([
|
|
|
136
142
|
__metadata("design:paramtypes", [fabric_contract_api_1.Context, String]),
|
|
137
143
|
__metadata("design:returntype", Promise)
|
|
138
144
|
], SerializedCrudContract.prototype, "updateAll", null);
|
|
145
|
+
__decorate([
|
|
146
|
+
(0, fabric_contract_api_1.Transaction)(false),
|
|
147
|
+
__metadata("design:type", Function),
|
|
148
|
+
__metadata("design:paramtypes", [fabric_contract_api_1.Context, String]),
|
|
149
|
+
__metadata("design:returntype", Promise)
|
|
150
|
+
], SerializedCrudContract.prototype, "statement", null);
|
|
139
151
|
__decorate([
|
|
140
152
|
(0, fabric_contract_api_1.Transaction)(false),
|
|
141
153
|
__metadata("design:type", Function),
|
|
@@ -16,15 +16,16 @@ import { Constructor } from "@decaf-ts/decoration";
|
|
|
16
16
|
*/
|
|
17
17
|
export declare class SerializedCrudContract<M extends Model> extends FabricCrudContract<M> {
|
|
18
18
|
constructor(name: string, clazz: Constructor<M>);
|
|
19
|
-
create(
|
|
20
|
-
read(
|
|
21
|
-
update(
|
|
22
|
-
delete(
|
|
23
|
-
deleteAll(
|
|
24
|
-
readAll(
|
|
25
|
-
updateAll(
|
|
19
|
+
create(context: Ctx, model: string): Promise<string>;
|
|
20
|
+
read(context: Ctx, key: string): Promise<string>;
|
|
21
|
+
update(context: Ctx, model: string): Promise<string>;
|
|
22
|
+
delete(context: Ctx, key: string): Promise<string>;
|
|
23
|
+
deleteAll(context: Ctx, keys: string): Promise<string>;
|
|
24
|
+
readAll(context: Ctx, keys: string): Promise<string>;
|
|
25
|
+
updateAll(context: Ctx, models: string): Promise<string>;
|
|
26
|
+
statement(context: Ctx, method: string): Promise<any>;
|
|
26
27
|
raw(context: Ctx, rawInput: string, docsOnly: boolean): Promise<any>;
|
|
27
28
|
init(ctx: Ctx): Promise<void>;
|
|
28
|
-
healthcheck(
|
|
29
|
+
healthcheck(context: Ctx): Promise<string>;
|
|
29
30
|
createAll(context: Ctx, models: string): Promise<string>;
|
|
30
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialized-crud-contract.js","sourceRoot":"","sources":["../../../src/contracts/crud/serialized-crud-contract.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uDAAqD;AAGrD,6DAAkE;AAGlE;;;;;;;;;;;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,
|
|
1
|
+
{"version":3,"file":"serialized-crud-contract.js","sourceRoot":"","sources":["../../../src/contracts/crud/serialized-crud-contract.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uDAAqD;AAGrD,6DAAkE;AAGlE;;;;;;;;;;;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,OAAY,EAAE,KAAa;QAC/C,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAC/D,GAAG,CAAC,IAAI,CAAC,mBAAmB,KAAK,EAAE,CAAC,CAAC;QAErC,MAAM,CAAC,GAAG,IAAI,CAAC,WAAW,CAAI,KAAK,CAAC,CAAC;QAErC,GAAG,CAAC,IAAI,CAAC,uBAAuB,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACrD,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,KAAK,CAAC,MAAM,CAAC,GAAU,EAAE,CAAC,CAAC,CAAM,CAAC,CAAC;IAClE,CAAC;IAGc,AAAN,KAAK,CAAC,IAAI,CAAC,OAAY,EAAE,GAAW;QA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Gc;IADd,IAAA,iCAAW,GAAE;;qCACiB,6BAAG;;oDAIjC;AAGc;IADd,IAAA,iCAAW,GAAE;;qCACiB,6BAAG;;oDAIjC;AAGc;IADd,IAAA,iCAAW,GAAE;;qCACoB,6BAAG;;uDAWpC;AAGc;IADd,IAAA,iCAAW,EAAC,KAAK,CAAC;;qCACa,6BAAG;;qDAWlC;AAGc;IADd,IAAA,iCAAW,GAAE;;qCACoB,6BAAG;;uDAapC;AAGc;IADd,IAAA,iCAAW,EAAC,KAAK,CAAC;;qCACe,6BAAG;;uDAGpC;AAGc;IADd,IAAA,iCAAW,EAAC,KAAK,CAAC;;qCAER,6BAAG;;iDAOb;AAGc;IADd,IAAA,iCAAW,GAAE;;qCACW,6BAAG;;kDAE3B;AAGc;IADd,IAAA,iCAAW,EAAC,KAAK,CAAC;;qCACiB,6BAAG;;yDAKtC;AAGc;IADd,IAAA,iCAAW,GAAE;;qCACoB,6BAAG;;uDAapC"}
|
|
@@ -55,23 +55,25 @@ class FabricERC20Contract extends crud_contract_1.FabricCrudContract {
|
|
|
55
55
|
this.tokenRepository = FabricContractRepository_1.FabricContractRepository.forModel(models_1.ERC20Token, FabricERC20Contract.adapter.alias);
|
|
56
56
|
this.allowanceRepository = FabricContractRepository_1.FabricContractRepository.forModel(models_1.Allowance, FabricERC20Contract.adapter.alias);
|
|
57
57
|
}
|
|
58
|
-
async TokenName(
|
|
58
|
+
async TokenName(context) {
|
|
59
|
+
const { ctx } = await this.logCtx([context], this.TokenName);
|
|
59
60
|
// Check contract options are already set first to execute the function
|
|
60
61
|
await this.CheckInitialized(ctx);
|
|
61
|
-
const select =
|
|
62
|
+
const select = this.tokenRepository.select();
|
|
62
63
|
const token = (await select.execute(ctx))[0];
|
|
63
64
|
return token.name;
|
|
64
65
|
}
|
|
65
66
|
/**
|
|
66
67
|
* Return the symbol of the token. E.g. “HIX”.
|
|
67
68
|
*
|
|
68
|
-
* @param {Context}
|
|
69
|
+
* @param {Context} context the transaction context
|
|
69
70
|
* @returns {String} Returns the symbol of the token
|
|
70
71
|
*/
|
|
71
|
-
async Symbol(
|
|
72
|
+
async Symbol(context) {
|
|
73
|
+
const { ctx } = await this.logCtx([context], this.TokenName);
|
|
72
74
|
// Check contract options are already set first to execute the function
|
|
73
75
|
await this.CheckInitialized(ctx);
|
|
74
|
-
const select =
|
|
76
|
+
const select = this.tokenRepository.select();
|
|
75
77
|
const token = (await select.execute(ctx))[0];
|
|
76
78
|
return token.symbol;
|
|
77
79
|
}
|
|
@@ -79,26 +81,28 @@ class FabricERC20Contract extends crud_contract_1.FabricCrudContract {
|
|
|
79
81
|
* Return the number of decimals the token uses
|
|
80
82
|
* e.g. 8, means to divide the token amount by 100000000 to get its user representation.
|
|
81
83
|
*
|
|
82
|
-
* @param {Context}
|
|
84
|
+
* @param {Context} context the transaction context
|
|
83
85
|
* @returns {Number} Returns the number of decimals
|
|
84
86
|
*/
|
|
85
|
-
async Decimals(
|
|
87
|
+
async Decimals(context) {
|
|
88
|
+
const { ctx } = await this.logCtx([context], this.TokenName);
|
|
86
89
|
// Check contract options are already set first to execute the function
|
|
87
90
|
await this.CheckInitialized(ctx);
|
|
88
|
-
const select =
|
|
91
|
+
const select = this.tokenRepository.select();
|
|
89
92
|
const token = (await select.execute(ctx))[0];
|
|
90
93
|
return token.decimals;
|
|
91
94
|
}
|
|
92
95
|
/**
|
|
93
96
|
* Return the total token supply.
|
|
94
97
|
*
|
|
95
|
-
* @param {Context}
|
|
98
|
+
* @param {Context} context the transaction context
|
|
96
99
|
* @returns {Number} Returns the total token supply
|
|
97
100
|
*/
|
|
98
|
-
async TotalSupply(
|
|
101
|
+
async TotalSupply(context) {
|
|
102
|
+
const { ctx } = await this.logCtx([context], this.TokenName);
|
|
99
103
|
// Check contract options are already set first to execute the function
|
|
100
104
|
await this.CheckInitialized(ctx);
|
|
101
|
-
const select =
|
|
105
|
+
const select = this.walletRepository.select();
|
|
102
106
|
const wallets = await select.execute(ctx);
|
|
103
107
|
if (wallets.length == 0) {
|
|
104
108
|
throw new db_decorators_1.NotFoundError(`The token ${this.getName()} does not exist`);
|
|
@@ -116,7 +120,8 @@ class FabricERC20Contract extends crud_contract_1.FabricCrudContract {
|
|
|
116
120
|
* @param {String} owner The owner from which the balance will be retrieved
|
|
117
121
|
* @returns {Number} Returns the account balance
|
|
118
122
|
*/
|
|
119
|
-
async BalanceOf(
|
|
123
|
+
async BalanceOf(context, owner) {
|
|
124
|
+
const { ctx } = await this.logCtx([context], this.TokenName);
|
|
120
125
|
// Check contract options are already set first to execute the function
|
|
121
126
|
await this.CheckInitialized(ctx);
|
|
122
127
|
const wallet = await this.walletRepository.read(owner, ctx);
|
|
@@ -126,7 +131,7 @@ class FabricERC20Contract extends crud_contract_1.FabricCrudContract {
|
|
|
126
131
|
* @summary Transfer transfers tokens from client account to recipient account.
|
|
127
132
|
* @description recipient account must be a valid clientID as returned by the ClientAccountID() function.
|
|
128
133
|
*
|
|
129
|
-
* @param {Context}
|
|
134
|
+
* @param {Context} context the transaction context
|
|
130
135
|
* @param {String} to The recipient
|
|
131
136
|
* @param {number} value The amount of token to be transferred
|
|
132
137
|
*
|
|
@@ -134,8 +139,8 @@ class FabricERC20Contract extends crud_contract_1.FabricCrudContract {
|
|
|
134
139
|
*/
|
|
135
140
|
async Transfer(context, to, value) {
|
|
136
141
|
// Check contract options are already set first to execute the function
|
|
137
|
-
await this.CheckInitialized(context);
|
|
138
142
|
const { ctx } = await this.logCtx([context], this.Transfer);
|
|
143
|
+
await this.CheckInitialized(ctx);
|
|
139
144
|
const from = ctx.identity.getID();
|
|
140
145
|
const transferResp = await this._transfer(from, to, value, ctx);
|
|
141
146
|
if (!transferResp) {
|
|
@@ -146,7 +151,7 @@ class FabricERC20Contract extends crud_contract_1.FabricCrudContract {
|
|
|
146
151
|
/**
|
|
147
152
|
* Transfer `value` amount of tokens from `from` to `to`.
|
|
148
153
|
*
|
|
149
|
-
* @param {Context}
|
|
154
|
+
* @param {Context} context the transaction context
|
|
150
155
|
* @param {String} from The sender
|
|
151
156
|
* @param {String} to The recipient
|
|
152
157
|
* @param {number} value The amount of token to be transferred
|
|
@@ -154,8 +159,8 @@ class FabricERC20Contract extends crud_contract_1.FabricCrudContract {
|
|
|
154
159
|
*/
|
|
155
160
|
async TransferFrom(context, from, to, value) {
|
|
156
161
|
// Check contract options are already set first to execute the function
|
|
157
|
-
await this.CheckInitialized(context);
|
|
158
162
|
const { ctx } = await this.logCtx([context], this.BurnFrom);
|
|
163
|
+
await this.CheckInitialized(ctx);
|
|
159
164
|
// Retrieve the allowance of the spender
|
|
160
165
|
const spender = ctx.identity.getID();
|
|
161
166
|
const allowance = await this._getAllowance(from, spender, ctx);
|
|
@@ -255,9 +260,9 @@ class FabricERC20Contract extends crud_contract_1.FabricCrudContract {
|
|
|
255
260
|
* @returns {Boolean} Return whether the approval was successful or not
|
|
256
261
|
*/
|
|
257
262
|
async Approve(context, spender, value) {
|
|
258
|
-
// Check contract options are already set first to execute the function
|
|
259
|
-
await this.CheckInitialized(context);
|
|
260
263
|
const { ctx, ctxArgs } = await this.logCtx([context], this.Approve);
|
|
264
|
+
// Check contract options are already set first to execute the function
|
|
265
|
+
await this.CheckInitialized(ctx);
|
|
261
266
|
const owner = ctx.identity.getID();
|
|
262
267
|
let allowance = await this._getAllowance(owner, spender, ctx);
|
|
263
268
|
const ownerWallet = await this.walletRepository.read(owner, ...ctxArgs);
|
|
@@ -291,9 +296,9 @@ class FabricERC20Contract extends crud_contract_1.FabricCrudContract {
|
|
|
291
296
|
* @returns {number} Return the amount of remaining tokens allowed to spent
|
|
292
297
|
*/
|
|
293
298
|
async Allowance(context, owner, spender) {
|
|
294
|
-
// Check contract options are already set first to execute the function
|
|
295
|
-
await this.CheckInitialized(context);
|
|
296
299
|
const { ctx } = await this.logCtx([context], this.Allowance);
|
|
300
|
+
// Check contract options are already set first to execute the function
|
|
301
|
+
await this.CheckInitialized(ctx);
|
|
297
302
|
const allowance = await this._getAllowance(owner, spender, ctx);
|
|
298
303
|
if (!allowance) {
|
|
299
304
|
throw new errors_1.AllowanceError(`spender ${spender} has no allowance from ${owner}`);
|
|
@@ -340,14 +345,14 @@ class FabricERC20Contract extends crud_contract_1.FabricCrudContract {
|
|
|
340
345
|
/**
|
|
341
346
|
* Mint creates new tokens and adds them to minter's account balance
|
|
342
347
|
*
|
|
343
|
-
* @param {Context}
|
|
348
|
+
* @param {Context} context the transaction context
|
|
344
349
|
* @param {number} amount amount of tokens to be minted
|
|
345
350
|
* @returns {Object} The balance
|
|
346
351
|
*/
|
|
347
352
|
async Mint(context, amount) {
|
|
348
|
-
// Check contract options are already set first to execute the function
|
|
349
|
-
await this.CheckInitialized(context);
|
|
350
353
|
const { ctx } = await this.logCtx([context], this.Mint);
|
|
354
|
+
// Check contract options are already set first to execute the function
|
|
355
|
+
await this.CheckInitialized(ctx);
|
|
351
356
|
// Get ID of submitting client identity
|
|
352
357
|
const minter = ctx.identity.getID();
|
|
353
358
|
if (amount <= 0) {
|
|
@@ -390,14 +395,14 @@ class FabricERC20Contract extends crud_contract_1.FabricCrudContract {
|
|
|
390
395
|
/**
|
|
391
396
|
* Burn redeem tokens from minter's account balance
|
|
392
397
|
*
|
|
393
|
-
* @param {Context}
|
|
398
|
+
* @param {Context} context the transaction context
|
|
394
399
|
* @param {number} amount amount of tokens to be burned
|
|
395
400
|
* @returns {Object} The balance
|
|
396
401
|
*/
|
|
397
402
|
async Burn(context, amount) {
|
|
398
|
-
// Check contract options are already set first to execute the function
|
|
399
|
-
await this.CheckInitialized(context);
|
|
400
403
|
const { log, ctx } = await this.logCtx([context], this.Burn);
|
|
404
|
+
// Check contract options are already set first to execute the function
|
|
405
|
+
await this.CheckInitialized(ctx);
|
|
401
406
|
const minter = ctx.identity.getID();
|
|
402
407
|
const minterWallet = await this.walletRepository.read(minter, ctx);
|
|
403
408
|
const currentBalance = minterWallet.balance;
|
|
@@ -418,15 +423,15 @@ class FabricERC20Contract extends crud_contract_1.FabricCrudContract {
|
|
|
418
423
|
/**
|
|
419
424
|
* BurnFrom redeem tokens from account allowence and balance
|
|
420
425
|
*
|
|
421
|
-
* @param {Context}
|
|
426
|
+
* @param {Context} context the transaction context
|
|
422
427
|
* @param {number} account account from where tokens will be burned
|
|
423
428
|
* @param {number} amount amount of tokens to be burned
|
|
424
429
|
* @returns {Object} The balance
|
|
425
430
|
*/
|
|
426
431
|
async BurnFrom(context, account, amount) {
|
|
427
|
-
// Check contract options are already set first to execute the function
|
|
428
|
-
await this.CheckInitialized(context);
|
|
429
432
|
const { log, ctx } = await this.logCtx([context], this.BurnFrom);
|
|
433
|
+
// Check contract options are already set first to execute the function
|
|
434
|
+
await this.CheckInitialized(ctx);
|
|
430
435
|
const accountWallet = await this.walletRepository.read(account, ctx);
|
|
431
436
|
const currentBalance = accountWallet.balance;
|
|
432
437
|
if (currentBalance < amount) {
|
|
@@ -446,14 +451,15 @@ class FabricERC20Contract extends crud_contract_1.FabricCrudContract {
|
|
|
446
451
|
/**
|
|
447
452
|
* ClientAccountBalance returns the balance of the requesting client's account.
|
|
448
453
|
*
|
|
449
|
-
* @param {Context}
|
|
454
|
+
* @param {Context} context the transaction context
|
|
450
455
|
* @returns {Number} Returns the account balance
|
|
451
456
|
*/
|
|
452
|
-
async ClientAccountBalance(
|
|
457
|
+
async ClientAccountBalance(context) {
|
|
458
|
+
const { ctx } = await this.logCtx([context], this.TokenName);
|
|
453
459
|
// Check contract options are already set first to execute the function
|
|
454
460
|
await this.CheckInitialized(ctx);
|
|
455
461
|
// Get ID of submitting client identity
|
|
456
|
-
const clientAccountID = ctx.
|
|
462
|
+
const clientAccountID = ctx.identity.getID();
|
|
457
463
|
const clientWallet = await this.walletRepository.read(clientAccountID, ctx);
|
|
458
464
|
if (!clientWallet) {
|
|
459
465
|
throw new errors_1.BalanceError(`The account ${clientAccountID} does not exist`);
|
|
@@ -464,9 +470,9 @@ class FabricERC20Contract extends crud_contract_1.FabricCrudContract {
|
|
|
464
470
|
// In this implementation, the client account ID is the clientId itself.
|
|
465
471
|
// Users can use this function to get their own account id, which they can then give to others as the payment address
|
|
466
472
|
async ClientAccountID(context) {
|
|
467
|
-
// Check contract options are already set first to execute the function
|
|
468
|
-
await this.CheckInitialized(context);
|
|
469
473
|
const { ctx } = await this.logCtx([context], this.ClientAccountID);
|
|
474
|
+
// Check contract options are already set first to execute the function
|
|
475
|
+
await this.CheckInitialized(ctx);
|
|
470
476
|
// Get ID of submitting client identity
|
|
471
477
|
const clientAccountID = ctx.identity.getID();
|
|
472
478
|
return clientAccountID;
|
|
@@ -32,29 +32,29 @@ export declare abstract class FabricERC20Contract extends FabricCrudContract<ERC
|
|
|
32
32
|
private tokenRepository;
|
|
33
33
|
private allowanceRepository;
|
|
34
34
|
protected constructor(name: string);
|
|
35
|
-
TokenName(
|
|
35
|
+
TokenName(context: Context): Promise<string>;
|
|
36
36
|
/**
|
|
37
37
|
* Return the symbol of the token. E.g. “HIX”.
|
|
38
38
|
*
|
|
39
|
-
* @param {Context}
|
|
39
|
+
* @param {Context} context the transaction context
|
|
40
40
|
* @returns {String} Returns the symbol of the token
|
|
41
41
|
*/
|
|
42
|
-
Symbol(
|
|
42
|
+
Symbol(context: Context): Promise<string>;
|
|
43
43
|
/**
|
|
44
44
|
* Return the number of decimals the token uses
|
|
45
45
|
* e.g. 8, means to divide the token amount by 100000000 to get its user representation.
|
|
46
46
|
*
|
|
47
|
-
* @param {Context}
|
|
47
|
+
* @param {Context} context the transaction context
|
|
48
48
|
* @returns {Number} Returns the number of decimals
|
|
49
49
|
*/
|
|
50
|
-
Decimals(
|
|
50
|
+
Decimals(context: Context): Promise<number>;
|
|
51
51
|
/**
|
|
52
52
|
* Return the total token supply.
|
|
53
53
|
*
|
|
54
|
-
* @param {Context}
|
|
54
|
+
* @param {Context} context the transaction context
|
|
55
55
|
* @returns {Number} Returns the total token supply
|
|
56
56
|
*/
|
|
57
|
-
TotalSupply(
|
|
57
|
+
TotalSupply(context: Context): Promise<number>;
|
|
58
58
|
/**
|
|
59
59
|
* BalanceOf returns the balance of the given account.
|
|
60
60
|
*
|
|
@@ -62,12 +62,12 @@ export declare abstract class FabricERC20Contract extends FabricCrudContract<ERC
|
|
|
62
62
|
* @param {String} owner The owner from which the balance will be retrieved
|
|
63
63
|
* @returns {Number} Returns the account balance
|
|
64
64
|
*/
|
|
65
|
-
BalanceOf(
|
|
65
|
+
BalanceOf(context: Context, owner: string): Promise<number>;
|
|
66
66
|
/**
|
|
67
67
|
* @summary Transfer transfers tokens from client account to recipient account.
|
|
68
68
|
* @description recipient account must be a valid clientID as returned by the ClientAccountID() function.
|
|
69
69
|
*
|
|
70
|
-
* @param {Context}
|
|
70
|
+
* @param {Context} context the transaction context
|
|
71
71
|
* @param {String} to The recipient
|
|
72
72
|
* @param {number} value The amount of token to be transferred
|
|
73
73
|
*
|
|
@@ -77,7 +77,7 @@ export declare abstract class FabricERC20Contract extends FabricCrudContract<ERC
|
|
|
77
77
|
/**
|
|
78
78
|
* Transfer `value` amount of tokens from `from` to `to`.
|
|
79
79
|
*
|
|
80
|
-
* @param {Context}
|
|
80
|
+
* @param {Context} context the transaction context
|
|
81
81
|
* @param {String} from The sender
|
|
82
82
|
* @param {String} to The recipient
|
|
83
83
|
* @param {number} value The amount of token to be transferred
|
|
@@ -119,7 +119,7 @@ export declare abstract class FabricERC20Contract extends FabricCrudContract<ERC
|
|
|
119
119
|
/**
|
|
120
120
|
* Mint creates new tokens and adds them to minter's account balance
|
|
121
121
|
*
|
|
122
|
-
* @param {Context}
|
|
122
|
+
* @param {Context} context the transaction context
|
|
123
123
|
* @param {number} amount amount of tokens to be minted
|
|
124
124
|
* @returns {Object} The balance
|
|
125
125
|
*/
|
|
@@ -127,7 +127,7 @@ export declare abstract class FabricERC20Contract extends FabricCrudContract<ERC
|
|
|
127
127
|
/**
|
|
128
128
|
* Burn redeem tokens from minter's account balance
|
|
129
129
|
*
|
|
130
|
-
* @param {Context}
|
|
130
|
+
* @param {Context} context the transaction context
|
|
131
131
|
* @param {number} amount amount of tokens to be burned
|
|
132
132
|
* @returns {Object} The balance
|
|
133
133
|
*/
|
|
@@ -135,7 +135,7 @@ export declare abstract class FabricERC20Contract extends FabricCrudContract<ERC
|
|
|
135
135
|
/**
|
|
136
136
|
* BurnFrom redeem tokens from account allowence and balance
|
|
137
137
|
*
|
|
138
|
-
* @param {Context}
|
|
138
|
+
* @param {Context} context the transaction context
|
|
139
139
|
* @param {number} account account from where tokens will be burned
|
|
140
140
|
* @param {number} amount amount of tokens to be burned
|
|
141
141
|
* @returns {Object} The balance
|
|
@@ -144,9 +144,9 @@ export declare abstract class FabricERC20Contract extends FabricCrudContract<ERC
|
|
|
144
144
|
/**
|
|
145
145
|
* ClientAccountBalance returns the balance of the requesting client's account.
|
|
146
146
|
*
|
|
147
|
-
* @param {Context}
|
|
147
|
+
* @param {Context} context the transaction context
|
|
148
148
|
* @returns {Number} Returns the account balance
|
|
149
149
|
*/
|
|
150
|
-
ClientAccountBalance(
|
|
150
|
+
ClientAccountBalance(context: Context): Promise<number>;
|
|
151
151
|
ClientAccountID(context: Context): Promise<string>;
|
|
152
152
|
}
|