postchain-client 1.8.1 → 1.9.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/README.md +5 -7
- package/built/cjs/index.js +46 -6
- package/built/cjs/index.js.map +1 -1
- package/built/esm/index.js +126 -80
- package/built/esm/index.js.map +1 -1
- package/built/src/ICCF/IccfProofTxMaterialBuilder.js.map +1 -1
- package/built/src/ICCF/utils.js.map +1 -1
- package/built/src/blockchainClient/blockchainClient.js +17 -1
- package/built/src/blockchainClient/blockchainClient.js.map +1 -1
- package/built/src/blockchainClient/interface.d.ts +20 -2
- package/built/src/blockchainClient/types.d.ts +30 -0
- package/built/src/blockchainClient/utils.d.ts +2 -1
- package/built/src/blockchainClient/utils.js +24 -0
- package/built/src/blockchainClient/utils.js.map +1 -1
- package/built/src/chromia/chromiaClientProvider.js.map +1 -1
- package/built/src/encryption/encryption.js.map +1 -1
- package/built/src/formatter.js.map +1 -1
- package/built/src/gtx/gtx.d.ts +3 -3
- package/built/src/gtx/gtx.js +4 -4
- package/built/src/gtx/gtx.js.map +1 -1
- package/built/src/gtx/gtxclient.js.map +1 -1
- package/built/src/gtx/serialization.js.map +1 -1
- package/built/src/logger.js.map +1 -1
- package/built/src/merkle/binarytree.js.map +1 -1
- package/built/src/merkle/binarytreefactory.js.map +1 -1
- package/built/src/merkle/merkleHelper.js.map +1 -1
- package/built/src/merkle/merklehashcalculator.js.map +1 -1
- package/built/src/merkle/path.js.map +1 -1
- package/built/src/merkle/proof/merklehashcarrier.js.map +1 -1
- package/built/src/merkle/proof/merklehashsummaryfactory.js.map +1 -1
- package/built/src/merkle/proof/merkleprooftree.js.map +1 -1
- package/built/src/merkle/proof/merkleprooftreefactory.js.map +1 -1
- package/built/src/restclient/errors.js.map +1 -1
- package/built/src/restclient/failoverStrategies.js.map +1 -1
- package/built/src/restclient/httpUtil.js.map +1 -1
- package/built/src/restclient/restclient.js.map +1 -1
- package/built/src/restclient/restclientutil.js.map +1 -1
- package/built/umd/index.js +126 -80
- package/built/umd/index.js.map +1 -1
- package/changelog.md +15 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -40,7 +40,7 @@ Next, create a Chromia client instance and configure it with a specific set of b
|
|
|
40
40
|
|
|
41
41
|
```typescript
|
|
42
42
|
const chromiaClient = await createClient({
|
|
43
|
-
|
|
43
|
+
nodeUrlPool: "http://localhost:7740",
|
|
44
44
|
blockchainRid,
|
|
45
45
|
});
|
|
46
46
|
```
|
|
@@ -229,11 +229,11 @@ const tx = {
|
|
|
229
229
|
operations: [
|
|
230
230
|
{
|
|
231
231
|
name: "my_operation_1",
|
|
232
|
-
|
|
232
|
+
args: ["arg1", "arg2"],
|
|
233
233
|
},
|
|
234
234
|
{
|
|
235
235
|
name: "my_operation_2",
|
|
236
|
-
|
|
236
|
+
args: ["arg1", "arg2"],
|
|
237
237
|
},
|
|
238
238
|
],
|
|
239
239
|
signers: ["signer1", "signer2"],
|
|
@@ -245,7 +245,7 @@ You can modify the object to add operations or signers.
|
|
|
245
245
|
```typescript
|
|
246
246
|
tx.operations.push({
|
|
247
247
|
name: "my_operation_3",
|
|
248
|
-
|
|
248
|
+
args: ["arg1", "arg2"],
|
|
249
249
|
});
|
|
250
250
|
|
|
251
251
|
tx.signers.push("signer3");
|
|
@@ -289,9 +289,7 @@ This example demonstrates that you can use external signing mechanisms. It could
|
|
|
289
289
|
|
|
290
290
|
```typescript
|
|
291
291
|
function askUserBToSign(buffer) {
|
|
292
|
-
|
|
293
|
-
var digest = sha256(buffer);
|
|
294
|
-
return secp256k1.sign(digest, signerPrivKeyB).signature;
|
|
292
|
+
return Buffer.from(secp256k1.ecdsaSign(buffer, signerPrivKeyB).signature);
|
|
295
293
|
}
|
|
296
294
|
```
|
|
297
295
|
|
package/built/cjs/index.js
CHANGED
|
@@ -1733,12 +1733,12 @@ function getDigest(gtx) {
|
|
|
1733
1733
|
* @param gtx the gtx to serialize
|
|
1734
1734
|
*/
|
|
1735
1735
|
function getDigestToSign(gtx) {
|
|
1736
|
-
return gtvHash(
|
|
1736
|
+
return gtvHash(gtxToRawGtxBody(gtx));
|
|
1737
1737
|
}
|
|
1738
|
-
function
|
|
1738
|
+
function getDigestToSignFromRawGtxBody(gtxBody) {
|
|
1739
1739
|
return gtvHash(gtxBody);
|
|
1740
1740
|
}
|
|
1741
|
-
function
|
|
1741
|
+
function gtxToRawGtxBody(gtx) {
|
|
1742
1742
|
return [
|
|
1743
1743
|
gtx.blockchainRid,
|
|
1744
1744
|
gtx.operations.map((op) => [op.opName, op.args]),
|
|
@@ -1797,7 +1797,7 @@ function serialize(gtx) {
|
|
|
1797
1797
|
// the signatures attribute, so let's add that.
|
|
1798
1798
|
gtx.signatures = [];
|
|
1799
1799
|
}
|
|
1800
|
-
return encode([
|
|
1800
|
+
return encode([gtxToRawGtxBody(gtx), gtx.signatures]);
|
|
1801
1801
|
}
|
|
1802
1802
|
function deserialize(gtxBytes) {
|
|
1803
1803
|
const deserializedTx = decode(gtxBytes);
|
|
@@ -1919,9 +1919,9 @@ var gtx = /*#__PURE__*/Object.freeze({
|
|
|
1919
1919
|
emptyGtx: emptyGtx,
|
|
1920
1920
|
getDigest: getDigest,
|
|
1921
1921
|
getDigestToSign: getDigestToSign,
|
|
1922
|
-
|
|
1923
|
-
gtvTxBody: gtvTxBody,
|
|
1922
|
+
getDigestToSignFromRawGtxBody: getDigestToSignFromRawGtxBody,
|
|
1924
1923
|
gtxToRawGtx: gtxToRawGtx,
|
|
1924
|
+
gtxToRawGtxBody: gtxToRawGtxBody,
|
|
1925
1925
|
newSignatureProvider: newSignatureProvider,
|
|
1926
1926
|
rawGtvToGtx: rawGtvToGtx,
|
|
1927
1927
|
serialize: serialize,
|
|
@@ -2705,6 +2705,22 @@ function createClient(settings) {
|
|
|
2705
2705
|
});
|
|
2706
2706
|
});
|
|
2707
2707
|
},
|
|
2708
|
+
getBlocksInfo(limit = 25, beforeTime, beforeHeight, txs, callback) {
|
|
2709
|
+
return __awaiter$6(this, void 0, void 0, function* () {
|
|
2710
|
+
let filteringQueryParam = "";
|
|
2711
|
+
if (beforeTime) {
|
|
2712
|
+
filteringQueryParam = `&before-time=${beforeTime.getTime()}`;
|
|
2713
|
+
}
|
|
2714
|
+
else if (beforeHeight) {
|
|
2715
|
+
filteringQueryParam = `&before-height=${beforeHeight}`;
|
|
2716
|
+
}
|
|
2717
|
+
const shouldIncludeFullTransaction = txs ? `&txs=${txs}` : "";
|
|
2718
|
+
const { error, statusCode, rspBody } = yield requestWithRetry(Method.GET, `blocks/${this.config.blockchainRid}?limit=${limit}${filteringQueryParam}${shouldIncludeFullTransaction}`, this.config);
|
|
2719
|
+
return new Promise((resolve, reject) => {
|
|
2720
|
+
handleGetResponse(error, statusCode, statusCode === 200 ? rspBody.map(formatBlockInfoResponse) : rspBody, callbackPromiseBuilder(reject, resolve, callback));
|
|
2721
|
+
});
|
|
2722
|
+
});
|
|
2723
|
+
},
|
|
2708
2724
|
encodeTransaction(transaction) {
|
|
2709
2725
|
const gtx$1 = getGTXFromBufferOrTransactionOrOperation(transaction, this.config.blockchainRid);
|
|
2710
2726
|
return serialize(gtx$1);
|
|
@@ -2941,6 +2957,30 @@ const formatTransactionInfoResponse = (transactionInfoResponse) => {
|
|
|
2941
2957
|
txData: toBuffer(transactionInfoResponse.txData),
|
|
2942
2958
|
};
|
|
2943
2959
|
};
|
|
2960
|
+
const formatBlockInfoResponse = (blockInfoResponse) => {
|
|
2961
|
+
return {
|
|
2962
|
+
rid: toBuffer(blockInfoResponse.rid),
|
|
2963
|
+
prevBlockRid: toBuffer(blockInfoResponse.prevBlockRID),
|
|
2964
|
+
header: toBuffer(blockInfoResponse.header),
|
|
2965
|
+
transactions: blockInfoResponse.transactions.map(formatTransaction),
|
|
2966
|
+
height: blockInfoResponse.height,
|
|
2967
|
+
witness: toBuffer(blockInfoResponse.witness),
|
|
2968
|
+
witnesses: blockInfoResponse.witnesses.map((witness) => {
|
|
2969
|
+
return toBuffer(witness);
|
|
2970
|
+
}),
|
|
2971
|
+
timestamp: blockInfoResponse.timestamp,
|
|
2972
|
+
};
|
|
2973
|
+
};
|
|
2974
|
+
const formatTransaction = (transaction) => {
|
|
2975
|
+
const formattedTransaction = {
|
|
2976
|
+
rid: toBuffer(transaction.rid),
|
|
2977
|
+
hash: toBuffer(transaction.hash),
|
|
2978
|
+
};
|
|
2979
|
+
if (transaction.data !== undefined) {
|
|
2980
|
+
formattedTransaction.data = toBuffer(transaction.data);
|
|
2981
|
+
}
|
|
2982
|
+
return formattedTransaction;
|
|
2983
|
+
};
|
|
2944
2984
|
const isKeyPair = (keypair) => {
|
|
2945
2985
|
return (typeof keypair === "object" &&
|
|
2946
2986
|
keypair !== null &&
|