@apex-pub/convector-adapter-fabric-in-chaincode 1.5.1 → 2.0.0-alpha.3
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.
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { ChaincodeTx } from '@apex-pub/convector-core-chaincode';
|
|
3
2
|
import { ControllerAdapter } from '@apex-pub/convector-core';
|
|
4
3
|
export interface InChaincodeAdapterConfig {
|
|
@@ -10,13 +9,13 @@ export declare class InChaincodeAdapter implements ControllerAdapter {
|
|
|
10
9
|
invoke(controller: string, name: string, config?: InChaincodeAdapterConfig, ...args: any[]): Promise<{
|
|
11
10
|
result: any;
|
|
12
11
|
status: number;
|
|
13
|
-
message
|
|
14
|
-
payload
|
|
12
|
+
message?: string;
|
|
13
|
+
payload?: Uint8Array;
|
|
15
14
|
}>;
|
|
16
15
|
rawInvoke(fn: string, config?: InChaincodeAdapterConfig, ...args: any[]): Promise<{
|
|
17
16
|
result: any;
|
|
18
17
|
status: number;
|
|
19
|
-
message
|
|
20
|
-
payload
|
|
18
|
+
message?: string;
|
|
19
|
+
payload?: Uint8Array;
|
|
21
20
|
}>;
|
|
22
21
|
}
|
|
@@ -1,63 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
exports.InChaincodeAdapter = void 0;
|
|
4
|
+
const convector_core_1 = require("@apex-pub/convector-core");
|
|
5
|
+
class InChaincodeAdapter {
|
|
6
|
+
async invoke(controller, name, config = {}, ...args) {
|
|
7
|
+
return this.rawInvoke(`${controller}_${name}`, config, ...args);
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
-
if (config
|
|
10
|
-
|
|
11
|
-
for (var _i = 3; _i < arguments.length; _i++) {
|
|
12
|
-
args[_i - 3] = arguments[_i];
|
|
9
|
+
async rawInvoke(fn, config = {}, ...args) {
|
|
10
|
+
if (!config.tx) {
|
|
11
|
+
throw new Error('InChaincodeAdapter needs the ChaincodeTx in config');
|
|
13
12
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return [2, this.rawInvoke.apply(this, [controller + "_" + name, config].concat(args))];
|
|
17
|
-
});
|
|
18
|
-
});
|
|
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];
|
|
13
|
+
if (!config.chaincode) {
|
|
14
|
+
throw new Error('InChaincodeAdapter needs a stub in config');
|
|
25
15
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
}());
|
|
16
|
+
const stub = config.tx.stub.getStub();
|
|
17
|
+
let beforeTx = stub.constructor.name === 'ChaincodeMockStub' ? {
|
|
18
|
+
signedProposal: stub.signedProposal,
|
|
19
|
+
txID: stub.txID,
|
|
20
|
+
transientMap: stub.transientMap,
|
|
21
|
+
args: stub.args
|
|
22
|
+
} : {};
|
|
23
|
+
const res = await stub.invokeChaincode(config.chaincode, [fn, ...args], config.channel);
|
|
24
|
+
const storage = convector_core_1.BaseStorage.current;
|
|
25
|
+
storage.stubHelper = config.tx.stub;
|
|
26
|
+
Object.assign(stub, beforeTx);
|
|
27
|
+
if (res.status === 500) {
|
|
28
|
+
const rawMessage = res.message.toString();
|
|
29
|
+
throw rawMessage ? JSON.parse(rawMessage) : res;
|
|
30
|
+
}
|
|
31
|
+
const rawResult = res.payload.toString();
|
|
32
|
+
return {
|
|
33
|
+
...res,
|
|
34
|
+
result: rawResult ? JSON.parse(rawResult) : undefined
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
62
38
|
exports.InChaincodeAdapter = InChaincodeAdapter;
|
|
63
39
|
//# 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":";;;AAEA,
|
|
1
|
+
{"version":3,"file":"fabric-in-chaincode.controller-adapter.js","sourceRoot":"","sources":["../../src/fabric-in-chaincode.controller-adapter.ts"],"names":[],"mappings":";;;AAEA,6DAA0E;AAQ1E,MAAa,kBAAkB;IAEtB,KAAK,CAAC,MAAM,CAAC,UAAkB,EAAE,IAAY,EAAE,SAAmC,EAAE,EAAE,GAAG,IAAW;QACzG,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,UAAU,IAAI,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;IAClE,CAAC;IAEM,KAAK,CAAC,SAAS,CAAC,EAAU,EAAE,SAAmC,EAAE,EAAE,GAAG,IAAW;QACtF,IAAI,CAAC,MAAM,CAAC,EAAE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AAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS;SACtD,CAAC;IACJ,CAAC;CACF;AA3CD,gDA2CC"}
|
package/dist/src/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
3
|
+
const 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": "
|
|
3
|
+
"version": "2.0.0-alpha.3",
|
|
4
4
|
"description": "Controller adapter to inside chaincode transactions to invoke another chaincode",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -33,32 +33,28 @@
|
|
|
33
33
|
"clean": "rimraf dist",
|
|
34
34
|
"clean:docs": "rimraf docs",
|
|
35
35
|
"build": "npm run clean && tsc",
|
|
36
|
-
"prepare": "npm run build",
|
|
37
36
|
"lint": "tslint --fix -c '../../tslint.json' -p './tsconfig.json'",
|
|
38
37
|
"test": "mocha -r ts-node/register test/**/*.spec.ts --reporter spec",
|
|
39
38
|
"predocs:generate": "npm run clean:docs",
|
|
40
39
|
"docs:generate": "typedoc src --mode file --out docs --target ES6 --excludePrivate",
|
|
41
40
|
"docs:serve": "http-server docs"
|
|
42
41
|
},
|
|
43
|
-
"peerDependencies": {
|
|
44
|
-
"fabric-ca-client": ">=1.1.2",
|
|
45
|
-
"fabric-client": ">=1.1.2"
|
|
46
|
-
},
|
|
47
42
|
"dependencies": {
|
|
48
|
-
"@apex-pub/convector-core": "^
|
|
49
|
-
"@apex-pub/convector-core-chaincode": "^
|
|
50
|
-
"@apex-pub/convector-storage-stub": "^
|
|
43
|
+
"@apex-pub/convector-core": "^2.0.0-alpha.3",
|
|
44
|
+
"@apex-pub/convector-core-chaincode": "^2.0.0-alpha.3",
|
|
45
|
+
"@apex-pub/convector-storage-stub": "^2.0.0-alpha.3",
|
|
51
46
|
"tslib": "^1.9.0"
|
|
52
47
|
},
|
|
53
48
|
"devDependencies": {
|
|
54
|
-
"@apex-pub/convector-adapter-mock": "^
|
|
49
|
+
"@apex-pub/convector-adapter-mock": "^2.0.0-alpha.3",
|
|
55
50
|
"http-server": "^0.11.1",
|
|
56
|
-
"mocha": "^
|
|
51
|
+
"mocha": "^10.8.2",
|
|
57
52
|
"npm-scripts-watcher": "^1.0.2",
|
|
58
53
|
"rimraf": "^2.6.2",
|
|
59
|
-
"ts-node": "^
|
|
60
|
-
"tslint": "^
|
|
54
|
+
"ts-node": "^10.9.2",
|
|
55
|
+
"tslint": "^6.1.3",
|
|
61
56
|
"typedoc": "^0.11.1",
|
|
62
|
-
"typescript": "
|
|
63
|
-
}
|
|
57
|
+
"typescript": "5.4.5"
|
|
58
|
+
},
|
|
59
|
+
"gitHead": "d275636ab454ac4f0c519c48695e25b36890633b"
|
|
64
60
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
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.1"></a>
|
|
7
|
-
## [1.5.1](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-adapter-fabric/compare/v1.5.0...v1.5.1) (2024-07-30)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
**Note:** Version bump only for package @apex-pub/convector-adapter-fabric-in-chaincode
|
|
13
|
-
|
|
14
|
-
<a name="1.5.0"></a>
|
|
15
|
-
# 1.5.0 (2024-07-29)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
### Bug Fixes
|
|
19
|
-
|
|
20
|
-
* in chaincode adapter return nothing ([7c69564](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-adapter-fabric/commit/7c69564))
|
|
21
|
-
* patch in chaincode adapter for mock ([967499d](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-adapter-fabric/commit/967499d))
|
|
22
|
-
* restore args for in-chaincode calls ([78f4dd2](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-adapter-fabric/commit/78f4dd2))
|
|
23
|
-
* throw errors for in-chaincode adapter ([c5fb921](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-adapter-fabric/commit/c5fb921))
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
### Features
|
|
27
|
-
|
|
28
|
-
* in-chaincode adapter with tests ([4b380af](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-adapter-fabric/commit/4b380af))
|
|
29
|
-
* raw tx result with $raw() ([3dac63c](https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-adapter-fabric/commit/3dac63c))
|