@apex-pub/convector-adapter-fabric-in-chaincode 1.4.1-4-alpha.808cd029 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
<a name="1.5.0"></a>
|
|
7
|
+
# 1.5.0 (2024-07-29)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* in chaincode adapter return nothing ([7c69564](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-adapter-fabric/commit/7c69564))
|
|
13
|
+
* patch in chaincode adapter for mock ([967499d](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-adapter-fabric/commit/967499d))
|
|
14
|
+
* restore args for in-chaincode calls ([78f4dd2](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-adapter-fabric/commit/78f4dd2))
|
|
15
|
+
* throw errors for in-chaincode adapter ([c5fb921](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-adapter-fabric/commit/c5fb921))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* in-chaincode adapter with tests ([4b380af](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-adapter-fabric/commit/4b380af))
|
|
21
|
+
* raw tx result with $raw() ([3dac63c](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-adapter-fabric/commit/3dac63c))
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { ChaincodeTx } from '@apex-pub/convector-core-chaincode';
|
|
2
3
|
import { ControllerAdapter } from '@apex-pub/convector-core';
|
|
3
4
|
export interface InChaincodeAdapterConfig {
|
|
@@ -10,12 +11,12 @@ export declare class InChaincodeAdapter implements ControllerAdapter {
|
|
|
10
11
|
result: any;
|
|
11
12
|
status: number;
|
|
12
13
|
message: string;
|
|
13
|
-
payload:
|
|
14
|
+
payload: Buffer;
|
|
14
15
|
}>;
|
|
15
16
|
rawInvoke(fn: string, config?: InChaincodeAdapterConfig, ...args: any[]): Promise<{
|
|
16
17
|
result: any;
|
|
17
18
|
status: number;
|
|
18
19
|
message: string;
|
|
19
|
-
payload:
|
|
20
|
+
payload: Buffer;
|
|
20
21
|
}>;
|
|
21
22
|
}
|
|
@@ -1,41 +1,63 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
invoke(controller, name, config = {}, ...args) {
|
|
8
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
9
|
-
return this.rawInvoke(`${controller}_${name}`, config, ...args);
|
|
10
|
-
});
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
var convector_core_1 = require("@apex-pub/convector-core");
|
|
5
|
+
var InChaincodeAdapter = (function () {
|
|
6
|
+
function InChaincodeAdapter() {
|
|
11
7
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
signedProposal: stub.signedProposal,
|
|
23
|
-
txID: stub.txID,
|
|
24
|
-
transientMap: stub.transientMap,
|
|
25
|
-
args: stub.args
|
|
26
|
-
} : {};
|
|
27
|
-
const res = yield stub.invokeChaincode(config.chaincode, [fn, ...args], config.channel);
|
|
28
|
-
const storage = convector_core_1.BaseStorage.current;
|
|
29
|
-
storage.stubHelper = config.tx.stub;
|
|
30
|
-
Object.assign(stub, beforeTx);
|
|
31
|
-
if (res.status === 500) {
|
|
32
|
-
const rawMessage = res.message.toString();
|
|
33
|
-
throw rawMessage ? JSON.parse(rawMessage) : res;
|
|
34
|
-
}
|
|
35
|
-
const rawResult = res.payload.toString();
|
|
36
|
-
return Object.assign(Object.assign({}, res), { result: rawResult ? JSON.parse(rawResult) : undefined });
|
|
8
|
+
InChaincodeAdapter.prototype.invoke = function (controller, name, config) {
|
|
9
|
+
if (config === void 0) { config = {}; }
|
|
10
|
+
var args = [];
|
|
11
|
+
for (var _i = 3; _i < arguments.length; _i++) {
|
|
12
|
+
args[_i - 3] = arguments[_i];
|
|
13
|
+
}
|
|
14
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
15
|
+
return tslib_1.__generator(this, function (_a) {
|
|
16
|
+
return [2, this.rawInvoke.apply(this, [controller + "_" + name, config].concat(args))];
|
|
17
|
+
});
|
|
37
18
|
});
|
|
38
|
-
}
|
|
39
|
-
|
|
19
|
+
};
|
|
20
|
+
InChaincodeAdapter.prototype.rawInvoke = function (fn, config) {
|
|
21
|
+
if (config === void 0) { config = {}; }
|
|
22
|
+
var args = [];
|
|
23
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
24
|
+
args[_i - 2] = arguments[_i];
|
|
25
|
+
}
|
|
26
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
27
|
+
var stub, beforeTx, res, storage, rawMessage, rawResult;
|
|
28
|
+
return tslib_1.__generator(this, function (_a) {
|
|
29
|
+
switch (_a.label) {
|
|
30
|
+
case 0:
|
|
31
|
+
if (!config.tx) {
|
|
32
|
+
throw new Error('InChaincodeAdapter needs the ChaincodeTx in config');
|
|
33
|
+
}
|
|
34
|
+
if (!config.chaincode) {
|
|
35
|
+
throw new Error('InChaincodeAdapter needs a stub in config');
|
|
36
|
+
}
|
|
37
|
+
stub = config.tx.stub.getStub();
|
|
38
|
+
beforeTx = stub.constructor.name === 'ChaincodeMockStub' ? {
|
|
39
|
+
signedProposal: stub.signedProposal,
|
|
40
|
+
txID: stub.txID,
|
|
41
|
+
transientMap: stub.transientMap,
|
|
42
|
+
args: stub.args
|
|
43
|
+
} : {};
|
|
44
|
+
return [4, stub.invokeChaincode(config.chaincode, [fn].concat(args), config.channel)];
|
|
45
|
+
case 1:
|
|
46
|
+
res = _a.sent();
|
|
47
|
+
storage = convector_core_1.BaseStorage.current;
|
|
48
|
+
storage.stubHelper = config.tx.stub;
|
|
49
|
+
Object.assign(stub, beforeTx);
|
|
50
|
+
if (res.status === 500) {
|
|
51
|
+
rawMessage = res.message.toString();
|
|
52
|
+
throw rawMessage ? JSON.parse(rawMessage) : res;
|
|
53
|
+
}
|
|
54
|
+
rawResult = res.payload.toString('utf8');
|
|
55
|
+
return [2, tslib_1.__assign({}, res, { result: rawResult ? JSON.parse(rawResult) : undefined })];
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
return InChaincodeAdapter;
|
|
61
|
+
}());
|
|
40
62
|
exports.InChaincodeAdapter = InChaincodeAdapter;
|
|
41
63
|
//# sourceMappingURL=fabric-in-chaincode.controller-adapter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fabric-in-chaincode.controller-adapter.js","sourceRoot":"","sources":["../../src/fabric-in-chaincode.controller-adapter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fabric-in-chaincode.controller-adapter.js","sourceRoot":"","sources":["../../src/fabric-in-chaincode.controller-adapter.ts"],"names":[],"mappings":";;;AAEA,2DAA0E;AAQ1E;IAAA;IA2CA,CAAC;IAzCc,mCAAM,GAAnB,UAAoB,UAAkB,EAAE,IAAY,EAAE,MAAqC;QAArC,uBAAA,EAAA,WAAqC;QAAE,cAAc;aAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;YAAd,6BAAc;;;;gBACzG,WAAO,IAAI,CAAC,SAAS,OAAd,IAAI,GAAc,UAAU,SAAI,IAAM,EAAE,MAAM,SAAK,IAAI,IAAE;;;KAC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yBACjD;wBAEK,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;wBAE/C,gCACK,GAAG,IACN,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,KACrD;;;;KACH;IACH,yBAAC;AAAD,CAAC,AA3CD,IA2CC;AA3CY,gDAAkB"}
|
package/dist/src/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./fabric-in-chaincode.controller-adapter"), exports);
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apex-pub/convector-adapter-fabric-in-chaincode",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Controller adapter to inside chaincode transactions to invoke another chaincode",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -41,15 +41,24 @@
|
|
|
41
41
|
"docs:serve": "http-server docs"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"fabric-ca-client": "1.
|
|
45
|
-
"fabric-client": "1.
|
|
44
|
+
"fabric-ca-client": ">=1.1.2",
|
|
45
|
+
"fabric-client": ">=1.1.2"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@apex-pub/convector-core": "1.
|
|
49
|
-
"@apex-pub/convector-core-chaincode": "1.
|
|
50
|
-
"@apex-pub/convector-storage-stub": "1.
|
|
48
|
+
"@apex-pub/convector-core": "^1.5.0",
|
|
49
|
+
"@apex-pub/convector-core-chaincode": "^1.5.0",
|
|
50
|
+
"@apex-pub/convector-storage-stub": "^1.5.0",
|
|
51
|
+
"tslib": "^1.9.0"
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|
|
53
|
-
"@apex-pub/convector-adapter-mock": "1.
|
|
54
|
+
"@apex-pub/convector-adapter-mock": "^1.5.0",
|
|
55
|
+
"http-server": "^0.11.1",
|
|
56
|
+
"mocha": "^5.0.3",
|
|
57
|
+
"npm-scripts-watcher": "^1.0.2",
|
|
58
|
+
"rimraf": "^2.6.2",
|
|
59
|
+
"ts-node": "^6.0.3",
|
|
60
|
+
"tslint": "^5.9.1",
|
|
61
|
+
"typedoc": "^0.11.1",
|
|
62
|
+
"typescript": "2.8.3"
|
|
54
63
|
}
|
|
55
64
|
}
|