dash-platform-sdk 1.5.0-dev.9 → 1.5.1

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.
Files changed (72) hide show
  1. package/README.md +17 -15
  2. package/bundle.min.js +1 -1
  3. package/index.d.ts +4 -1
  4. package/index.js +3 -1
  5. package/package.json +4 -4
  6. package/proto/generated/platform.client.d.ts +10 -0
  7. package/proto/generated/platform.client.js +25 -18
  8. package/proto/generated/platform.d.ts +162 -0
  9. package/proto/generated/platform.js +351 -0
  10. package/src/DashPlatformSDK.d.ts +11 -7
  11. package/src/DashPlatformSDK.js +23 -3
  12. package/src/contestedResources/getContestedResourceVoteState.d.ts +2 -2
  13. package/src/contestedResources/index.d.ts +3 -3
  14. package/src/dataContracts/getDataContractByIdentifier.d.ts +2 -2
  15. package/src/dataContracts/index.d.ts +3 -3
  16. package/src/documents/index.d.ts +3 -3
  17. package/src/documents/query.d.ts +2 -2
  18. package/src/documents/query.js +1 -1
  19. package/src/grpcConnectionPool.d.ts +13 -2
  20. package/src/grpcConnectionPool.js +16 -13
  21. package/src/identities/getIdentityBalance.d.ts +2 -2
  22. package/src/identities/getIdentityByIdentifier.d.ts +2 -2
  23. package/src/identities/getIdentityByNonUniquePublicKeyHash.d.ts +2 -2
  24. package/src/identities/getIdentityByPublicKeyHash.d.ts +2 -2
  25. package/src/identities/getIdentityContractNonce.d.ts +2 -2
  26. package/src/identities/getIdentityNonce.d.ts +2 -2
  27. package/src/identities/getIdentityPublicKeys.d.ts +2 -2
  28. package/src/identities/index.d.ts +3 -3
  29. package/src/names/index.d.ts +3 -3
  30. package/src/names/registerName.d.ts +2 -2
  31. package/src/names/searchByIdentity.d.ts +2 -2
  32. package/src/names/searchByName.d.ts +2 -2
  33. package/src/node/epochInfos.d.ts +2 -2
  34. package/src/node/finalizedEpochInfos.d.ts +2 -2
  35. package/src/node/getCurrentQuorumsInfo.d.ts +19 -0
  36. package/src/node/getCurrentQuorumsInfo.js +31 -0
  37. package/src/node/index.d.ts +11 -3
  38. package/src/node/index.js +10 -0
  39. package/src/node/status.d.ts +2 -2
  40. package/src/node/totalCredits.d.ts +2 -2
  41. package/src/platformAddresses/getAddressInfo.d.ts +2 -2
  42. package/src/platformAddresses/getAddressesBranchState.d.ts +2 -2
  43. package/src/platformAddresses/getAddressesInfos.d.ts +2 -2
  44. package/src/platformAddresses/getAddressesTrunkState.d.ts +2 -2
  45. package/src/platformAddresses/getRecentAddressBalanceChanges.d.ts +2 -2
  46. package/src/platformAddresses/getRecentCompactedAddressBalanceChanges.d.ts +2 -2
  47. package/src/platformAddresses/index.d.ts +3 -3
  48. package/src/shielded/createStateTransition.js +5 -0
  49. package/src/shielded/getMostRecentShieldedAnchor.d.ts +2 -2
  50. package/src/shielded/getShieldedAnchors.d.ts +2 -2
  51. package/src/shielded/getShieldedEncryptedNotes.d.ts +2 -2
  52. package/src/shielded/getShieldedNotesCount.d.ts +2 -2
  53. package/src/shielded/getShieldedNullifiers.d.ts +2 -2
  54. package/src/shielded/getShieldedPoolState.d.ts +2 -2
  55. package/src/shielded/index.d.ts +7 -6
  56. package/src/shielded/index.js +4 -3
  57. package/src/stateTransitions/broadcast.d.ts +2 -2
  58. package/src/stateTransitions/index.d.ts +3 -3
  59. package/src/stateTransitions/waitForStateTransitionResult.d.ts +2 -2
  60. package/src/tokens/getIdentitiesTokenBalances.d.ts +2 -2
  61. package/src/tokens/getIdentityTokensBalances.d.ts +2 -2
  62. package/src/tokens/getTokenContractInfo.d.ts +2 -2
  63. package/src/tokens/getTokenDirectPurchasePrices.d.ts +2 -2
  64. package/src/tokens/getTokenTotalSupply.d.ts +2 -2
  65. package/src/tokens/index.d.ts +3 -3
  66. package/src/utils/fetchWithDetails.d.ts +24 -0
  67. package/src/utils/fetchWithDetails.js +71 -0
  68. package/src/utils/getQuorumPublicKey.js +2 -1
  69. package/test/unit/Node.spec.js +18 -0
  70. package/types.d.ts +6 -1
  71. package/src/utils/getEvonodeList.d.ts +0 -2
  72. package/src/utils/getEvonodeList.js +0 -12
@@ -5525,6 +5525,356 @@ class GetTotalCreditsInPlatformResponse_GetTotalCreditsInPlatformResponseV0$Type
5525
5525
  */
5526
5526
  export const GetTotalCreditsInPlatformResponse_GetTotalCreditsInPlatformResponseV0 = new GetTotalCreditsInPlatformResponse_GetTotalCreditsInPlatformResponseV0$Type();
5527
5527
  // @generated message type with reflection information, may provide speed optimized methods
5528
+ class GetCurrentQuorumsInfoRequest$Type extends MessageType {
5529
+ constructor() {
5530
+ super("org.dash.platform.dapi.v0.GetCurrentQuorumsInfoRequest", [
5531
+ { no: 1, name: "v0", kind: "message", oneof: "version", T: () => GetCurrentQuorumsInfoRequest_GetCurrentQuorumsInfoRequestV0 }
5532
+ ]);
5533
+ }
5534
+ create(value) {
5535
+ const message = globalThis.Object.create((this.messagePrototype));
5536
+ message.version = { oneofKind: undefined };
5537
+ if (value !== undefined)
5538
+ reflectionMergePartial(this, message, value);
5539
+ return message;
5540
+ }
5541
+ internalBinaryRead(reader, length, options, target) {
5542
+ let message = target ?? this.create(), end = reader.pos + length;
5543
+ while (reader.pos < end) {
5544
+ let [fieldNo, wireType] = reader.tag();
5545
+ switch (fieldNo) {
5546
+ case /* org.dash.platform.dapi.v0.GetCurrentQuorumsInfoRequest.GetCurrentQuorumsInfoRequestV0 v0 */ 1:
5547
+ message.version = {
5548
+ oneofKind: "v0",
5549
+ v0: GetCurrentQuorumsInfoRequest_GetCurrentQuorumsInfoRequestV0.internalBinaryRead(reader, reader.uint32(), options, message.version.v0)
5550
+ };
5551
+ break;
5552
+ default:
5553
+ let u = options.readUnknownField;
5554
+ if (u === "throw")
5555
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
5556
+ let d = reader.skip(wireType);
5557
+ if (u !== false)
5558
+ (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
5559
+ }
5560
+ }
5561
+ return message;
5562
+ }
5563
+ internalBinaryWrite(message, writer, options) {
5564
+ /* org.dash.platform.dapi.v0.GetCurrentQuorumsInfoRequest.GetCurrentQuorumsInfoRequestV0 v0 = 1; */
5565
+ if (message.version.oneofKind === "v0")
5566
+ GetCurrentQuorumsInfoRequest_GetCurrentQuorumsInfoRequestV0.internalBinaryWrite(message.version.v0, writer.tag(1, WireType.LengthDelimited).fork(), options).join();
5567
+ let u = options.writeUnknownFields;
5568
+ if (u !== false)
5569
+ (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
5570
+ return writer;
5571
+ }
5572
+ }
5573
+ /**
5574
+ * @generated MessageType for protobuf message org.dash.platform.dapi.v0.GetCurrentQuorumsInfoRequest
5575
+ */
5576
+ export const GetCurrentQuorumsInfoRequest = new GetCurrentQuorumsInfoRequest$Type();
5577
+ // @generated message type with reflection information, may provide speed optimized methods
5578
+ class GetCurrentQuorumsInfoRequest_GetCurrentQuorumsInfoRequestV0$Type extends MessageType {
5579
+ constructor() {
5580
+ super("org.dash.platform.dapi.v0.GetCurrentQuorumsInfoRequest.GetCurrentQuorumsInfoRequestV0", []);
5581
+ }
5582
+ create(value) {
5583
+ const message = globalThis.Object.create((this.messagePrototype));
5584
+ if (value !== undefined)
5585
+ reflectionMergePartial(this, message, value);
5586
+ return message;
5587
+ }
5588
+ internalBinaryRead(reader, length, options, target) {
5589
+ let message = target ?? this.create(), end = reader.pos + length;
5590
+ while (reader.pos < end) {
5591
+ let [fieldNo, wireType] = reader.tag();
5592
+ switch (fieldNo) {
5593
+ default:
5594
+ let u = options.readUnknownField;
5595
+ if (u === "throw")
5596
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
5597
+ let d = reader.skip(wireType);
5598
+ if (u !== false)
5599
+ (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
5600
+ }
5601
+ }
5602
+ return message;
5603
+ }
5604
+ internalBinaryWrite(message, writer, options) {
5605
+ let u = options.writeUnknownFields;
5606
+ if (u !== false)
5607
+ (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
5608
+ return writer;
5609
+ }
5610
+ }
5611
+ /**
5612
+ * @generated MessageType for protobuf message org.dash.platform.dapi.v0.GetCurrentQuorumsInfoRequest.GetCurrentQuorumsInfoRequestV0
5613
+ */
5614
+ export const GetCurrentQuorumsInfoRequest_GetCurrentQuorumsInfoRequestV0 = new GetCurrentQuorumsInfoRequest_GetCurrentQuorumsInfoRequestV0$Type();
5615
+ // @generated message type with reflection information, may provide speed optimized methods
5616
+ class GetCurrentQuorumsInfoResponse$Type extends MessageType {
5617
+ constructor() {
5618
+ super("org.dash.platform.dapi.v0.GetCurrentQuorumsInfoResponse", [
5619
+ { no: 1, name: "v0", kind: "message", oneof: "version", T: () => GetCurrentQuorumsInfoResponse_GetCurrentQuorumsInfoResponseV0 }
5620
+ ]);
5621
+ }
5622
+ create(value) {
5623
+ const message = globalThis.Object.create((this.messagePrototype));
5624
+ message.version = { oneofKind: undefined };
5625
+ if (value !== undefined)
5626
+ reflectionMergePartial(this, message, value);
5627
+ return message;
5628
+ }
5629
+ internalBinaryRead(reader, length, options, target) {
5630
+ let message = target ?? this.create(), end = reader.pos + length;
5631
+ while (reader.pos < end) {
5632
+ let [fieldNo, wireType] = reader.tag();
5633
+ switch (fieldNo) {
5634
+ case /* org.dash.platform.dapi.v0.GetCurrentQuorumsInfoResponse.GetCurrentQuorumsInfoResponseV0 v0 */ 1:
5635
+ message.version = {
5636
+ oneofKind: "v0",
5637
+ v0: GetCurrentQuorumsInfoResponse_GetCurrentQuorumsInfoResponseV0.internalBinaryRead(reader, reader.uint32(), options, message.version.v0)
5638
+ };
5639
+ break;
5640
+ default:
5641
+ let u = options.readUnknownField;
5642
+ if (u === "throw")
5643
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
5644
+ let d = reader.skip(wireType);
5645
+ if (u !== false)
5646
+ (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
5647
+ }
5648
+ }
5649
+ return message;
5650
+ }
5651
+ internalBinaryWrite(message, writer, options) {
5652
+ /* org.dash.platform.dapi.v0.GetCurrentQuorumsInfoResponse.GetCurrentQuorumsInfoResponseV0 v0 = 1; */
5653
+ if (message.version.oneofKind === "v0")
5654
+ GetCurrentQuorumsInfoResponse_GetCurrentQuorumsInfoResponseV0.internalBinaryWrite(message.version.v0, writer.tag(1, WireType.LengthDelimited).fork(), options).join();
5655
+ let u = options.writeUnknownFields;
5656
+ if (u !== false)
5657
+ (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
5658
+ return writer;
5659
+ }
5660
+ }
5661
+ /**
5662
+ * @generated MessageType for protobuf message org.dash.platform.dapi.v0.GetCurrentQuorumsInfoResponse
5663
+ */
5664
+ export const GetCurrentQuorumsInfoResponse = new GetCurrentQuorumsInfoResponse$Type();
5665
+ // @generated message type with reflection information, may provide speed optimized methods
5666
+ class GetCurrentQuorumsInfoResponse_ValidatorV0$Type extends MessageType {
5667
+ constructor() {
5668
+ super("org.dash.platform.dapi.v0.GetCurrentQuorumsInfoResponse.ValidatorV0", [
5669
+ { no: 1, name: "pro_tx_hash", kind: "scalar", T: 12 /*ScalarType.BYTES*/ },
5670
+ { no: 2, name: "node_ip", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
5671
+ { no: 3, name: "is_banned", kind: "scalar", T: 8 /*ScalarType.BOOL*/ }
5672
+ ]);
5673
+ }
5674
+ create(value) {
5675
+ const message = globalThis.Object.create((this.messagePrototype));
5676
+ message.proTxHash = new Uint8Array(0);
5677
+ message.nodeIp = "";
5678
+ message.isBanned = false;
5679
+ if (value !== undefined)
5680
+ reflectionMergePartial(this, message, value);
5681
+ return message;
5682
+ }
5683
+ internalBinaryRead(reader, length, options, target) {
5684
+ let message = target ?? this.create(), end = reader.pos + length;
5685
+ while (reader.pos < end) {
5686
+ let [fieldNo, wireType] = reader.tag();
5687
+ switch (fieldNo) {
5688
+ case /* bytes pro_tx_hash */ 1:
5689
+ message.proTxHash = reader.bytes();
5690
+ break;
5691
+ case /* string node_ip */ 2:
5692
+ message.nodeIp = reader.string();
5693
+ break;
5694
+ case /* bool is_banned */ 3:
5695
+ message.isBanned = reader.bool();
5696
+ break;
5697
+ default:
5698
+ let u = options.readUnknownField;
5699
+ if (u === "throw")
5700
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
5701
+ let d = reader.skip(wireType);
5702
+ if (u !== false)
5703
+ (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
5704
+ }
5705
+ }
5706
+ return message;
5707
+ }
5708
+ internalBinaryWrite(message, writer, options) {
5709
+ /* bytes pro_tx_hash = 1; */
5710
+ if (message.proTxHash.length)
5711
+ writer.tag(1, WireType.LengthDelimited).bytes(message.proTxHash);
5712
+ /* string node_ip = 2; */
5713
+ if (message.nodeIp !== "")
5714
+ writer.tag(2, WireType.LengthDelimited).string(message.nodeIp);
5715
+ /* bool is_banned = 3; */
5716
+ if (message.isBanned !== false)
5717
+ writer.tag(3, WireType.Varint).bool(message.isBanned);
5718
+ let u = options.writeUnknownFields;
5719
+ if (u !== false)
5720
+ (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
5721
+ return writer;
5722
+ }
5723
+ }
5724
+ /**
5725
+ * @generated MessageType for protobuf message org.dash.platform.dapi.v0.GetCurrentQuorumsInfoResponse.ValidatorV0
5726
+ */
5727
+ export const GetCurrentQuorumsInfoResponse_ValidatorV0 = new GetCurrentQuorumsInfoResponse_ValidatorV0$Type();
5728
+ // @generated message type with reflection information, may provide speed optimized methods
5729
+ class GetCurrentQuorumsInfoResponse_ValidatorSetV0$Type extends MessageType {
5730
+ constructor() {
5731
+ super("org.dash.platform.dapi.v0.GetCurrentQuorumsInfoResponse.ValidatorSetV0", [
5732
+ { no: 1, name: "quorum_hash", kind: "scalar", T: 12 /*ScalarType.BYTES*/ },
5733
+ { no: 2, name: "core_height", kind: "scalar", T: 13 /*ScalarType.UINT32*/ },
5734
+ { no: 3, name: "members", kind: "message", repeat: 2 /*RepeatType.UNPACKED*/, T: () => GetCurrentQuorumsInfoResponse_ValidatorV0 },
5735
+ { no: 4, name: "threshold_public_key", kind: "scalar", T: 12 /*ScalarType.BYTES*/ }
5736
+ ]);
5737
+ }
5738
+ create(value) {
5739
+ const message = globalThis.Object.create((this.messagePrototype));
5740
+ message.quorumHash = new Uint8Array(0);
5741
+ message.coreHeight = 0;
5742
+ message.members = [];
5743
+ message.thresholdPublicKey = new Uint8Array(0);
5744
+ if (value !== undefined)
5745
+ reflectionMergePartial(this, message, value);
5746
+ return message;
5747
+ }
5748
+ internalBinaryRead(reader, length, options, target) {
5749
+ let message = target ?? this.create(), end = reader.pos + length;
5750
+ while (reader.pos < end) {
5751
+ let [fieldNo, wireType] = reader.tag();
5752
+ switch (fieldNo) {
5753
+ case /* bytes quorum_hash */ 1:
5754
+ message.quorumHash = reader.bytes();
5755
+ break;
5756
+ case /* uint32 core_height */ 2:
5757
+ message.coreHeight = reader.uint32();
5758
+ break;
5759
+ case /* repeated org.dash.platform.dapi.v0.GetCurrentQuorumsInfoResponse.ValidatorV0 members */ 3:
5760
+ message.members.push(GetCurrentQuorumsInfoResponse_ValidatorV0.internalBinaryRead(reader, reader.uint32(), options));
5761
+ break;
5762
+ case /* bytes threshold_public_key */ 4:
5763
+ message.thresholdPublicKey = reader.bytes();
5764
+ break;
5765
+ default:
5766
+ let u = options.readUnknownField;
5767
+ if (u === "throw")
5768
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
5769
+ let d = reader.skip(wireType);
5770
+ if (u !== false)
5771
+ (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
5772
+ }
5773
+ }
5774
+ return message;
5775
+ }
5776
+ internalBinaryWrite(message, writer, options) {
5777
+ /* bytes quorum_hash = 1; */
5778
+ if (message.quorumHash.length)
5779
+ writer.tag(1, WireType.LengthDelimited).bytes(message.quorumHash);
5780
+ /* uint32 core_height = 2; */
5781
+ if (message.coreHeight !== 0)
5782
+ writer.tag(2, WireType.Varint).uint32(message.coreHeight);
5783
+ /* repeated org.dash.platform.dapi.v0.GetCurrentQuorumsInfoResponse.ValidatorV0 members = 3; */
5784
+ for (let i = 0; i < message.members.length; i++)
5785
+ GetCurrentQuorumsInfoResponse_ValidatorV0.internalBinaryWrite(message.members[i], writer.tag(3, WireType.LengthDelimited).fork(), options).join();
5786
+ /* bytes threshold_public_key = 4; */
5787
+ if (message.thresholdPublicKey.length)
5788
+ writer.tag(4, WireType.LengthDelimited).bytes(message.thresholdPublicKey);
5789
+ let u = options.writeUnknownFields;
5790
+ if (u !== false)
5791
+ (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
5792
+ return writer;
5793
+ }
5794
+ }
5795
+ /**
5796
+ * @generated MessageType for protobuf message org.dash.platform.dapi.v0.GetCurrentQuorumsInfoResponse.ValidatorSetV0
5797
+ */
5798
+ export const GetCurrentQuorumsInfoResponse_ValidatorSetV0 = new GetCurrentQuorumsInfoResponse_ValidatorSetV0$Type();
5799
+ // @generated message type with reflection information, may provide speed optimized methods
5800
+ class GetCurrentQuorumsInfoResponse_GetCurrentQuorumsInfoResponseV0$Type extends MessageType {
5801
+ constructor() {
5802
+ super("org.dash.platform.dapi.v0.GetCurrentQuorumsInfoResponse.GetCurrentQuorumsInfoResponseV0", [
5803
+ { no: 1, name: "quorum_hashes", kind: "scalar", repeat: 2 /*RepeatType.UNPACKED*/, T: 12 /*ScalarType.BYTES*/ },
5804
+ { no: 2, name: "current_quorum_hash", kind: "scalar", T: 12 /*ScalarType.BYTES*/ },
5805
+ { no: 3, name: "validator_sets", kind: "message", repeat: 2 /*RepeatType.UNPACKED*/, T: () => GetCurrentQuorumsInfoResponse_ValidatorSetV0 },
5806
+ { no: 4, name: "last_block_proposer", kind: "scalar", T: 12 /*ScalarType.BYTES*/ },
5807
+ { no: 5, name: "metadata", kind: "message", T: () => ResponseMetadata }
5808
+ ]);
5809
+ }
5810
+ create(value) {
5811
+ const message = globalThis.Object.create((this.messagePrototype));
5812
+ message.quorumHashes = [];
5813
+ message.currentQuorumHash = new Uint8Array(0);
5814
+ message.validatorSets = [];
5815
+ message.lastBlockProposer = new Uint8Array(0);
5816
+ if (value !== undefined)
5817
+ reflectionMergePartial(this, message, value);
5818
+ return message;
5819
+ }
5820
+ internalBinaryRead(reader, length, options, target) {
5821
+ let message = target ?? this.create(), end = reader.pos + length;
5822
+ while (reader.pos < end) {
5823
+ let [fieldNo, wireType] = reader.tag();
5824
+ switch (fieldNo) {
5825
+ case /* repeated bytes quorum_hashes */ 1:
5826
+ message.quorumHashes.push(reader.bytes());
5827
+ break;
5828
+ case /* bytes current_quorum_hash */ 2:
5829
+ message.currentQuorumHash = reader.bytes();
5830
+ break;
5831
+ case /* repeated org.dash.platform.dapi.v0.GetCurrentQuorumsInfoResponse.ValidatorSetV0 validator_sets */ 3:
5832
+ message.validatorSets.push(GetCurrentQuorumsInfoResponse_ValidatorSetV0.internalBinaryRead(reader, reader.uint32(), options));
5833
+ break;
5834
+ case /* bytes last_block_proposer */ 4:
5835
+ message.lastBlockProposer = reader.bytes();
5836
+ break;
5837
+ case /* org.dash.platform.dapi.v0.ResponseMetadata metadata */ 5:
5838
+ message.metadata = ResponseMetadata.internalBinaryRead(reader, reader.uint32(), options, message.metadata);
5839
+ break;
5840
+ default:
5841
+ let u = options.readUnknownField;
5842
+ if (u === "throw")
5843
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
5844
+ let d = reader.skip(wireType);
5845
+ if (u !== false)
5846
+ (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
5847
+ }
5848
+ }
5849
+ return message;
5850
+ }
5851
+ internalBinaryWrite(message, writer, options) {
5852
+ /* repeated bytes quorum_hashes = 1; */
5853
+ for (let i = 0; i < message.quorumHashes.length; i++)
5854
+ writer.tag(1, WireType.LengthDelimited).bytes(message.quorumHashes[i]);
5855
+ /* bytes current_quorum_hash = 2; */
5856
+ if (message.currentQuorumHash.length)
5857
+ writer.tag(2, WireType.LengthDelimited).bytes(message.currentQuorumHash);
5858
+ /* repeated org.dash.platform.dapi.v0.GetCurrentQuorumsInfoResponse.ValidatorSetV0 validator_sets = 3; */
5859
+ for (let i = 0; i < message.validatorSets.length; i++)
5860
+ GetCurrentQuorumsInfoResponse_ValidatorSetV0.internalBinaryWrite(message.validatorSets[i], writer.tag(3, WireType.LengthDelimited).fork(), options).join();
5861
+ /* bytes last_block_proposer = 4; */
5862
+ if (message.lastBlockProposer.length)
5863
+ writer.tag(4, WireType.LengthDelimited).bytes(message.lastBlockProposer);
5864
+ /* org.dash.platform.dapi.v0.ResponseMetadata metadata = 5; */
5865
+ if (message.metadata)
5866
+ ResponseMetadata.internalBinaryWrite(message.metadata, writer.tag(5, WireType.LengthDelimited).fork(), options).join();
5867
+ let u = options.writeUnknownFields;
5868
+ if (u !== false)
5869
+ (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
5870
+ return writer;
5871
+ }
5872
+ }
5873
+ /**
5874
+ * @generated MessageType for protobuf message org.dash.platform.dapi.v0.GetCurrentQuorumsInfoResponse.GetCurrentQuorumsInfoResponseV0
5875
+ */
5876
+ export const GetCurrentQuorumsInfoResponse_GetCurrentQuorumsInfoResponseV0 = new GetCurrentQuorumsInfoResponse_GetCurrentQuorumsInfoResponseV0$Type();
5877
+ // @generated message type with reflection information, may provide speed optimized methods
5528
5878
  class GetStatusRequest$Type extends MessageType {
5529
5879
  constructor() {
5530
5880
  super("org.dash.platform.dapi.v0.GetStatusRequest", [
@@ -12461,6 +12811,7 @@ export const Platform = new ServiceType("org.dash.platform.dapi.v0.Platform", [
12461
12811
  { name: "getContestedResourceVoteState", options: {}, I: GetContestedResourceVoteStateRequest, O: GetContestedResourceVoteStateResponse },
12462
12812
  { name: "getTotalCreditsInPlatform", options: {}, I: GetTotalCreditsInPlatformRequest, O: GetTotalCreditsInPlatformResponse },
12463
12813
  { name: "getStatus", options: {}, I: GetStatusRequest, O: GetStatusResponse },
12814
+ { name: "getCurrentQuorumsInfo", options: {}, I: GetCurrentQuorumsInfoRequest, O: GetCurrentQuorumsInfoResponse },
12464
12815
  { name: "getIdentityTokenBalances", options: {}, I: GetIdentityTokenBalancesRequest, O: GetIdentityTokenBalancesResponse },
12465
12816
  { name: "getIdentitiesTokenBalances", options: {}, I: GetIdentitiesTokenBalancesRequest, O: GetIdentitiesTokenBalancesResponse },
12466
12817
  { name: "getTokenContractInfo", options: {}, I: GetTokenContractInfoRequest, O: GetTokenContractInfoResponse },
@@ -1,4 +1,4 @@
1
- import GRPCConnectionPool from './grpcConnectionPool.js';
1
+ import { GRPCOptions, GRPCPool } from './grpcConnectionPool.js';
2
2
  import { IdentitiesController } from './identities/index.js';
3
3
  import { StateTransitionsController } from './stateTransitions/index.js';
4
4
  import { DocumentsController } from './documents/index.js';
@@ -13,10 +13,7 @@ import { VotingController } from './voting/index.js';
13
13
  import { Network } from '../types.js';
14
14
  import { PlatformAddressesController } from './platformAddresses/index.js';
15
15
  import { ShieldedController } from './shielded/index.js';
16
- export interface GRPCOptions {
17
- poolLimit: 5;
18
- dapiUrl?: string | string[];
19
- }
16
+ export type { GRPCOptions, GRPCPool };
20
17
  export interface SDKOptions {
21
18
  network: Network;
22
19
  grpc?: GRPCOptions;
@@ -29,7 +26,7 @@ export interface SDKOptions {
29
26
  export declare class DashPlatformSDK {
30
27
  network: Network;
31
28
  /** @ignore **/
32
- grpcPool: GRPCConnectionPool;
29
+ grpcPool: GRPCPool;
33
30
  /** @ignore **/
34
31
  options?: SDKOptions;
35
32
  contestedResources: ContestedResourcesController;
@@ -60,7 +57,7 @@ export declare class DashPlatformSDK {
60
57
  * @param grpcPool
61
58
  * @param network
62
59
  */
63
- _initialize(grpcPool: GRPCConnectionPool): void;
60
+ _initialize(grpcPool: GRPCPool): void;
64
61
  /**
65
62
  * Get currently used network
66
63
  *
@@ -73,4 +70,11 @@ export declare class DashPlatformSDK {
73
70
  * @param network {string}
74
71
  */
75
72
  setNetwork(network: Network): void;
73
+ /**
74
+ * Replaces GRPC connection pool used by the SDK with a custom one.
75
+ * SDK network is switched to the pool's network
76
+ *
77
+ * @param grpcPool {GRPCPool}
78
+ */
79
+ setGRPCPool(grpcPool: GRPCPool): void;
76
80
  }
@@ -52,8 +52,11 @@ export class DashPlatformSDK {
52
52
  // @ts-expect-error
53
53
  this.options.grpc = { dapiUrl: options.dapiUrl };
54
54
  }
55
- this.grpcPool = new GRPCConnectionPool(this.network, this.options?.grpc);
56
- this._initialize(this.grpcPool);
55
+ const customPool = this.options?.grpc?.pool;
56
+ if (customPool != null && customPool.network !== this.network) {
57
+ throw new Error(`Custom GRPC pool network (${customPool.network}) does not match SDK network (${this.network})`);
58
+ }
59
+ this._initialize(customPool ?? new GRPCConnectionPool(this.network, this.options?.grpc));
57
60
  }
58
61
  /**
59
62
  * @private
@@ -95,8 +98,25 @@ export class DashPlatformSDK {
95
98
  if (network !== 'testnet' && network !== 'mainnet') {
96
99
  throw new Error('Unknown network, should be mainnet or testnet');
97
100
  }
101
+ const customPool = this.options?.grpc?.pool;
102
+ if (customPool != null && customPool.network !== network) {
103
+ throw new Error(`Custom GRPC pool is bound to ${customPool.network}, pass a pool for ${network} with setGRPCPool() instead`);
104
+ }
98
105
  this.network = network;
99
- const grpcPool = new GRPCConnectionPool(this.network, this.options?.grpc);
106
+ this._initialize(customPool ?? new GRPCConnectionPool(this.network, this.options?.grpc));
107
+ }
108
+ /**
109
+ * Replaces GRPC connection pool used by the SDK with a custom one.
110
+ * SDK network is switched to the pool's network
111
+ *
112
+ * @param grpcPool {GRPCPool}
113
+ */
114
+ setGRPCPool(grpcPool) {
115
+ if (grpcPool.network !== 'testnet' && grpcPool.network !== 'mainnet') {
116
+ throw new Error('Unknown GRPC pool network, should be mainnet or testnet');
117
+ }
118
+ this.network = grpcPool.network;
119
+ this.options = { ...(this.options ?? { network: grpcPool.network }), network: grpcPool.network, grpc: { ...this.options?.grpc, pool: grpcPool } };
100
120
  this._initialize(grpcPool);
101
121
  }
102
122
  }
@@ -1,6 +1,6 @@
1
1
  import { ContestedResourceVoteState, ContestedStateResultType } from '../../types.js';
2
- import GRPCConnectionPool from '../grpcConnectionPool.js';
2
+ import { GRPCPool } from '../grpcConnectionPool.js';
3
3
  import { GetContestedResourceVoteStateRequest_GetContestedResourceVoteStateRequestV0_StartAtIdentifierInfo } from '../../proto/generated/platform.js';
4
4
  import { DataContractWASM } from 'pshenmic-dpp';
5
5
  export type StartAtIdentifierInfo = GetContestedResourceVoteStateRequest_GetContestedResourceVoteStateRequestV0_StartAtIdentifierInfo;
6
- export default function getContestedResourceVoteState(grpcPool: GRPCConnectionPool, contract: DataContractWASM, documentTypeName: string, indexName: string, indexValues: Array<Uint8Array<ArrayBufferLike>>, resultType: ContestedStateResultType, allowIncludeLockedAndAbstainingVoteTally: boolean, startAtIdentifierInfo?: StartAtIdentifierInfo, count?: number): Promise<ContestedResourceVoteState>;
6
+ export default function getContestedResourceVoteState(grpcPool: GRPCPool, contract: DataContractWASM, documentTypeName: string, indexName: string, indexValues: Array<Uint8Array<ArrayBufferLike>>, resultType: ContestedStateResultType, allowIncludeLockedAndAbstainingVoteTally: boolean, startAtIdentifierInfo?: StartAtIdentifierInfo, count?: number): Promise<ContestedResourceVoteState>;
@@ -1,4 +1,4 @@
1
- import GRPCConnectionPool from '../grpcConnectionPool.js';
1
+ import { GRPCPool } from '../grpcConnectionPool.js';
2
2
  import { ContestedResourceVoteState, ContestedStateResultType } from '../../types.js';
3
3
  import { DataContractWASM } from 'pshenmic-dpp';
4
4
  import { StartAtIdentifierInfo } from './getContestedResourceVoteState.js';
@@ -9,8 +9,8 @@ import { StartAtIdentifierInfo } from './getContestedResourceVoteState.js';
9
9
  */
10
10
  export declare class ContestedResourcesController {
11
11
  /** @ignore **/
12
- grpcPool: GRPCConnectionPool;
13
- constructor(grpcPool: GRPCConnectionPool);
12
+ grpcPool: GRPCPool;
13
+ constructor(grpcPool: GRPCPool);
14
14
  /**
15
15
  * Retrieves an info about vote state for contested resource
16
16
  *
@@ -1,3 +1,3 @@
1
1
  import { DataContractWASM, IdentifierLike } from 'pshenmic-dpp';
2
- import GRPCConnectionPool from '../grpcConnectionPool.js';
3
- export default function getByIdentifier(grpcPool: GRPCConnectionPool, identifier: IdentifierLike): Promise<DataContractWASM>;
2
+ import { GRPCPool } from '../grpcConnectionPool.js';
3
+ export default function getByIdentifier(grpcPool: GRPCPool, identifier: IdentifierLike): Promise<DataContractWASM>;
@@ -1,5 +1,5 @@
1
1
  import { DataContractTokens, DataContractWASM, IdentifierLike, PlatformVersionWASM, StateTransitionWASM } from 'pshenmic-dpp';
2
- import GRPCConnectionPool from '../grpcConnectionPool.js';
2
+ import { GRPCPool } from '../grpcConnectionPool.js';
3
3
  import { DataContractConfig } from '../../types.js';
4
4
  /**
5
5
  * Collection of methods necessary to work with Data Contracts in the network,
@@ -9,8 +9,8 @@ import { DataContractConfig } from '../../types.js';
9
9
  */
10
10
  export declare class DataContractsController {
11
11
  /** @ignore */
12
- grpcPool: GRPCConnectionPool;
13
- constructor(grpcPool: GRPCConnectionPool);
12
+ grpcPool: GRPCPool;
13
+ constructor(grpcPool: GRPCPool);
14
14
  /**
15
15
  * Creates an instance of {DataContractWASM} that can be used to
16
16
  * register a data contract in the network.
@@ -1,6 +1,6 @@
1
1
  import { DocumentTransitionParams } from '../../types.js';
2
2
  import { DocumentWASM, IdentifierLike, IdentifierWASM, StateTransitionWASM, WhereClause } from 'pshenmic-dpp';
3
- import GRPCConnectionPool from '../grpcConnectionPool.js';
3
+ import { GRPCPool } from '../grpcConnectionPool.js';
4
4
  /**
5
5
  * Collection of methods to work with documents like creation, querying or preparing a transition action
6
6
  *
@@ -8,8 +8,8 @@ import GRPCConnectionPool from '../grpcConnectionPool.js';
8
8
  */
9
9
  export declare class DocumentsController {
10
10
  /** @ignore **/
11
- grpcPool: GRPCConnectionPool;
12
- constructor(grpcPool: GRPCConnectionPool);
11
+ grpcPool: GRPCPool;
12
+ constructor(grpcPool: GRPCPool);
13
13
  /**
14
14
  * Creates a {DocumentWASM} instance that can be used to submit a document in the network.
15
15
  *
@@ -1,3 +1,3 @@
1
1
  import { DocumentWASM, IdentifierLike, IdentifierWASM, WhereClause } from 'pshenmic-dpp';
2
- import GRPCConnectionPool from '../grpcConnectionPool.js';
3
- export default function query(grpcPool: GRPCConnectionPool, dataContractId: IdentifierLike, documentTypeName: string, where?: WhereClause[], orderBy?: string[][], limit?: number | undefined, startAt?: IdentifierWASM, startAfter?: IdentifierWASM): Promise<DocumentWASM[]>;
2
+ import { GRPCPool } from '../grpcConnectionPool.js';
3
+ export default function query(grpcPool: GRPCPool, dataContractId: IdentifierLike, documentTypeName: string, where?: WhereClause[], orderBy?: string[][], limit?: number | undefined, startAt?: IdentifierWASM, startAfter?: IdentifierWASM): Promise<DocumentWASM[]>;
@@ -4,7 +4,7 @@ import { DAPI_DEFAULT_LIMIT, LATEST_PLATFORM_VERSION } from '../constants.js';
4
4
  import { getQuorumPublicKey } from '../utils/getQuorumPublicKey.js';
5
5
  import bytesToHex from '../utils/bytesToHex.js';
6
6
  import verifyTenderdashProof from '../utils/verifyTenderdashProof.js';
7
- import { encode } from 'cbor-x';
7
+ import { encode } from 'cbor2';
8
8
  import getDataContractByIdentifier from '../dataContracts/getDataContractByIdentifier.js';
9
9
  export default async function query(grpcPool, dataContractId, documentTypeName, where, orderBy, limit = 100, startAt, startAfter) {
10
10
  let start;
@@ -2,8 +2,18 @@ import { PlatformClient } from '../proto/generated/platform.client.js';
2
2
  import { Network } from '../types.js';
3
3
  export type MasternodeList = Record<string, MasternodeInfo>;
4
4
  export interface GRPCOptions {
5
- poolLimit: 5;
5
+ poolLimit?: number;
6
6
  dapiUrl?: string | string[];
7
+ /** Custom connection pool, if set, `poolLimit` and `dapiUrl` are ignored **/
8
+ pool?: GRPCPool;
9
+ }
10
+ /**
11
+ * Minimal interface the SDK requires from a GRPC connection pool.
12
+ * Implement it to supply your own node selection, retries, transport options, etc.
13
+ */
14
+ export interface GRPCPool {
15
+ network: Network;
16
+ getClient: (abortController?: AbortController) => PlatformClient;
7
17
  }
8
18
  export interface MasternodeInfo {
9
19
  proTxHash: string;
@@ -23,7 +33,8 @@ export interface MasternodeInfo {
23
33
  collateraladdress: string;
24
34
  pubkeyoperator: string;
25
35
  }
26
- export default class GRPCConnectionPool {
36
+ export declare const createClient: (url: string, abortController?: AbortController) => PlatformClient;
37
+ export default class GRPCConnectionPool implements GRPCPool {
27
38
  dapiUrls: string[];
28
39
  network: Network;
29
40
  constructor(network: Network, grpcOptions?: GRPCOptions);
@@ -1,8 +1,9 @@
1
1
  import { GrpcWebFetchTransport } from '@protobuf-ts/grpcweb-transport';
2
2
  import { PlatformClient } from '../proto/generated/platform.client.js';
3
- import getEvonodeList from './utils/getEvonodeList.js';
4
3
  import { GetStatusRequest } from '../proto/generated/platform.js';
4
+ import getCurrentQuorumsInfo from './node/getCurrentQuorumsInfo.js';
5
5
  import getRandomArrayItem from './utils/getRandomArrayItem.js';
6
+ import { fetchWithDetails } from './utils/fetchWithDetails.js';
6
7
  const GRPC_DEFAULT_POOL_LIMIT = 5;
7
8
  const seedNodes = {
8
9
  testnet: [
@@ -18,10 +19,15 @@ const seedNodes = {
18
19
  // 'https://34.211.174.194'
19
20
  ]
20
21
  };
21
- const createClient = (url, abortController) => {
22
+ const DAPI_PORTS = {
23
+ testnet: 1443,
24
+ mainnet: 443
25
+ };
26
+ export const createClient = (url, abortController) => {
22
27
  return new PlatformClient(new GrpcWebFetchTransport({
23
28
  baseUrl: url,
24
- abort: abortController?.signal
29
+ abort: abortController?.signal,
30
+ fetch: fetchWithDetails
25
31
  }));
26
32
  };
27
33
  export default class GRPCConnectionPool {
@@ -45,17 +51,14 @@ export default class GRPCConnectionPool {
45
51
  throw new Error('Unrecognized DAPI URL');
46
52
  }
47
53
  // Add default seed nodes
48
- this.dapiUrls = seedNodes[network];
49
- // retrieve last evonodes list
50
- const evonodeList = await getEvonodeList(network);
54
+ this.dapiUrls = [...seedNodes[network]];
55
+ // retrieve evonodes from current validator sets
56
+ const { validatorSets } = await getCurrentQuorumsInfo(this);
51
57
  // map it to array of dapiUrls
52
- const networkDAPIUrls = Object.entries(evonodeList)
53
- .map(([, info]) => info)
54
- .filter((info) => info.status === 'ENABLED')
55
- .map((info) => {
56
- const [host] = info.address.split(':');
57
- return `https://${host}:${info.platformHTTPPort}`;
58
- });
58
+ const networkDAPIUrls = [...new Set(validatorSets
59
+ .flatMap(validatorSet => validatorSet.members)
60
+ .filter(member => !member.isBanned)
61
+ .map(member => `https://${member.nodeIp}:${DAPI_PORTS[network]}`))];
59
62
  // healthcheck nodes
60
63
  for (const url of networkDAPIUrls) {
61
64
  if (this.dapiUrls.length > poolLimit) {
@@ -1,3 +1,3 @@
1
1
  import { IdentifierLike } from 'pshenmic-dpp';
2
- import GRPCConnectionPool from '../grpcConnectionPool.js';
3
- export default function getIdentityBalance(grpcPool: GRPCConnectionPool, identifier: IdentifierLike): Promise<bigint>;
2
+ import { GRPCPool } from '../grpcConnectionPool.js';
3
+ export default function getIdentityBalance(grpcPool: GRPCPool, identifier: IdentifierLike): Promise<bigint>;
@@ -1,3 +1,3 @@
1
1
  import { IdentifierLike, IdentityWASM } from 'pshenmic-dpp';
2
- import GRPCConnectionPool from '../grpcConnectionPool.js';
3
- export default function getIdentityByIdentifier(grpcPool: GRPCConnectionPool, identifier: IdentifierLike): Promise<IdentityWASM>;
2
+ import { GRPCPool } from '../grpcConnectionPool.js';
3
+ export default function getIdentityByIdentifier(grpcPool: GRPCPool, identifier: IdentifierLike): Promise<IdentityWASM>;
@@ -1,3 +1,3 @@
1
1
  import { IdentityWASM } from 'pshenmic-dpp';
2
- import GRPCConnectionPool from '../grpcConnectionPool.js';
3
- export default function getIdentityByNonUniquePublicKeyHash(grpcPool: GRPCConnectionPool, hex: string): Promise<IdentityWASM>;
2
+ import { GRPCPool } from '../grpcConnectionPool.js';
3
+ export default function getIdentityByNonUniquePublicKeyHash(grpcPool: GRPCPool, hex: string): Promise<IdentityWASM>;