dash-platform-sdk 1.6.0-dev.7 → 1.6.0-dev.9

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 (65) hide show
  1. package/README.md +14 -14
  2. package/bundle.min.js +1 -1
  3. package/package.json +2 -2
  4. package/proto/generated/platform.client.d.ts +10 -0
  5. package/proto/generated/platform.client.js +7 -0
  6. package/proto/generated/platform.d.ts +137 -0
  7. package/proto/generated/platform.js +279 -1
  8. package/src/QueryExecutor.d.ts +40 -4
  9. package/src/QueryExecutor.js +61 -8
  10. package/src/constants.d.ts +7 -1
  11. package/src/constants.js +9 -2
  12. package/src/contestedResources/getContestedResourceVoteState.js +14 -6
  13. package/src/contestedResources/getVotePollsByEndDate.js +7 -2
  14. package/src/dataContracts/getDataContractByIdentifier.js +3 -3
  15. package/src/documents/index.d.ts +4 -1
  16. package/src/documents/index.js +6 -2
  17. package/src/documents/query.js +4 -4
  18. package/src/documents/queryAggregate.js +2 -3
  19. package/src/documents/queryJoined.js +6 -7
  20. package/src/documents/queryRanked.js +2 -3
  21. package/src/documents/v1.d.ts +2 -2
  22. package/src/documents/v1.js +2 -3
  23. package/src/grpcConnectionPool.d.ts +9 -2
  24. package/src/grpcConnectionPool.js +7 -8
  25. package/src/identities/getIdentityBalance.js +1 -2
  26. package/src/identities/getIdentityByIdentifier.js +1 -2
  27. package/src/identities/getIdentityByNonUniquePublicKeyHash.js +2 -3
  28. package/src/identities/getIdentityByPublicKeyHash.js +1 -2
  29. package/src/identities/getIdentityContractNonce.js +1 -2
  30. package/src/identities/getIdentityNonce.js +1 -2
  31. package/src/identities/getIdentityPublicKeys.js +1 -2
  32. package/src/names/index.d.ts +1 -1
  33. package/src/names/index.js +1 -1
  34. package/src/names/registerName.js +5 -2
  35. package/src/node/epochInfos.js +1 -2
  36. package/src/node/finalizedEpochInfos.js +1 -2
  37. package/src/node/getPathElements.d.ts +4 -0
  38. package/src/node/getPathElements.js +27 -0
  39. package/src/node/getProtocolVersion.d.ts +9 -0
  40. package/src/node/getProtocolVersion.js +29 -0
  41. package/src/node/index.d.ts +20 -0
  42. package/src/node/index.js +25 -0
  43. package/src/node/totalCredits.js +3 -3
  44. package/src/platformAddresses/getAddressInfo.js +1 -2
  45. package/src/platformAddresses/getAddressesBranchState.js +1 -2
  46. package/src/platformAddresses/getAddressesInfos.js +1 -2
  47. package/src/platformAddresses/getAddressesTrunkState.js +1 -2
  48. package/src/platformAddresses/getRecentAddressBalanceChanges.js +2 -2
  49. package/src/platformAddresses/getRecentCompactedAddressBalanceChanges.js +2 -2
  50. package/src/shielded/getMostRecentShieldedAnchor.js +1 -2
  51. package/src/shielded/getShieldedAnchors.js +1 -2
  52. package/src/shielded/getShieldedEncryptedNotes.js +2 -2
  53. package/src/shielded/getShieldedNotesCount.js +1 -2
  54. package/src/shielded/getShieldedNullifiers.js +1 -2
  55. package/src/shielded/getShieldedPoolState.js +1 -2
  56. package/src/stateTransitions/waitForStateTransitionResult.js +13 -11
  57. package/src/tokens/getIdentitiesTokenBalances.js +1 -2
  58. package/src/tokens/getIdentityTokensBalances.js +1 -2
  59. package/src/tokens/getTokenContractInfo.js +1 -2
  60. package/src/tokens/getTokenDirectPurchasePrices.js +1 -2
  61. package/src/tokens/getTokenTotalSupply.js +1 -2
  62. package/test/integration/MainnetCompatibility.spec.d.ts +1 -0
  63. package/test/integration/MainnetCompatibility.spec.js +373 -0
  64. package/test/unit/Node.spec.js +17 -0
  65. package/test/unit/SDK.spec.js +38 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dash-platform-sdk",
3
- "version": "1.6.0-dev.7",
3
+ "version": "1.6.0-dev.9",
4
4
  "main": "index.js",
5
5
  "description": "Lightweight SDK for accessing Dash Platform blockchain",
6
6
  "repository": {
@@ -59,6 +59,6 @@
59
59
  "@scure/bip32": "^2.0.0",
60
60
  "@scure/bip39": "^2.0.0",
61
61
  "@scure/btc-signer": "^2.0.1",
62
- "pshenmic-dpp": "2.0.1-dev.5"
62
+ "pshenmic-dpp": "2.0.1-dev.6"
63
63
  }
64
64
  }
@@ -1,5 +1,7 @@
1
1
  import type { RpcTransport } from "@protobuf-ts/runtime-rpc";
2
2
  import type { ServiceInfo } from "@protobuf-ts/runtime-rpc";
3
+ import type { GetPathElementsResponse } from "./platform.js";
4
+ import type { GetPathElementsRequest } from "./platform.js";
3
5
  import type { GetShieldedNullifiersResponse } from "./platform.js";
4
6
  import type { GetShieldedNullifiersRequest } from "./platform.js";
5
7
  import type { GetShieldedNotesCountResponse } from "./platform.js";
@@ -216,6 +218,10 @@ export interface IPlatformClient {
216
218
  * @generated from protobuf rpc: getShieldedNullifiers
217
219
  */
218
220
  getShieldedNullifiers(input: GetShieldedNullifiersRequest, options?: RpcOptions): UnaryCall<GetShieldedNullifiersRequest, GetShieldedNullifiersResponse>;
221
+ /**
222
+ * @generated from protobuf rpc: getPathElements
223
+ */
224
+ getPathElements(input: GetPathElementsRequest, options?: RpcOptions): UnaryCall<GetPathElementsRequest, GetPathElementsResponse>;
219
225
  }
220
226
  /**
221
227
  * @generated from protobuf service org.dash.platform.dapi.v0.Platform
@@ -368,4 +374,8 @@ export declare class PlatformClient implements IPlatformClient, ServiceInfo {
368
374
  * @generated from protobuf rpc: getShieldedNullifiers
369
375
  */
370
376
  getShieldedNullifiers(input: GetShieldedNullifiersRequest, options?: RpcOptions): UnaryCall<GetShieldedNullifiersRequest, GetShieldedNullifiersResponse>;
377
+ /**
378
+ * @generated from protobuf rpc: getPathElements
379
+ */
380
+ getPathElements(input: GetPathElementsRequest, options?: RpcOptions): UnaryCall<GetPathElementsRequest, GetPathElementsResponse>;
371
381
  }
@@ -256,4 +256,11 @@ export class PlatformClient {
256
256
  const method = this.methods[34], opt = this._transport.mergeOptions(options);
257
257
  return stackIntercept("unary", this._transport, method, opt, input);
258
258
  }
259
+ /**
260
+ * @generated from protobuf rpc: getPathElements
261
+ */
262
+ getPathElements(input, options) {
263
+ const method = this.methods[35], opt = this._transport.mergeOptions(options);
264
+ return stackIntercept("unary", this._transport, method, opt, input);
265
+ }
259
266
  }
@@ -4912,6 +4912,93 @@ export interface CanonicalVote {
4912
4912
  */
4913
4913
  chainId: string;
4914
4914
  }
4915
+ /**
4916
+ * @generated from protobuf message org.dash.platform.dapi.v0.GetPathElementsRequest
4917
+ */
4918
+ export interface GetPathElementsRequest {
4919
+ /**
4920
+ * @generated from protobuf oneof: version
4921
+ */
4922
+ version: {
4923
+ oneofKind: "v0";
4924
+ /**
4925
+ * @generated from protobuf field: org.dash.platform.dapi.v0.GetPathElementsRequest.GetPathElementsRequestV0 v0 = 1
4926
+ */
4927
+ v0: GetPathElementsRequest_GetPathElementsRequestV0;
4928
+ } | {
4929
+ oneofKind: undefined;
4930
+ };
4931
+ }
4932
+ /**
4933
+ * @generated from protobuf message org.dash.platform.dapi.v0.GetPathElementsRequest.GetPathElementsRequestV0
4934
+ */
4935
+ export interface GetPathElementsRequest_GetPathElementsRequestV0 {
4936
+ /**
4937
+ * @generated from protobuf field: repeated bytes path = 1
4938
+ */
4939
+ path: Uint8Array[];
4940
+ /**
4941
+ * @generated from protobuf field: repeated bytes keys = 2
4942
+ */
4943
+ keys: Uint8Array[];
4944
+ /**
4945
+ * @generated from protobuf field: bool prove = 3
4946
+ */
4947
+ prove: boolean;
4948
+ }
4949
+ /**
4950
+ * @generated from protobuf message org.dash.platform.dapi.v0.GetPathElementsResponse
4951
+ */
4952
+ export interface GetPathElementsResponse {
4953
+ /**
4954
+ * @generated from protobuf oneof: version
4955
+ */
4956
+ version: {
4957
+ oneofKind: "v0";
4958
+ /**
4959
+ * @generated from protobuf field: org.dash.platform.dapi.v0.GetPathElementsResponse.GetPathElementsResponseV0 v0 = 1
4960
+ */
4961
+ v0: GetPathElementsResponse_GetPathElementsResponseV0;
4962
+ } | {
4963
+ oneofKind: undefined;
4964
+ };
4965
+ }
4966
+ /**
4967
+ * @generated from protobuf message org.dash.platform.dapi.v0.GetPathElementsResponse.GetPathElementsResponseV0
4968
+ */
4969
+ export interface GetPathElementsResponse_GetPathElementsResponseV0 {
4970
+ /**
4971
+ * @generated from protobuf oneof: result
4972
+ */
4973
+ result: {
4974
+ oneofKind: "elements";
4975
+ /**
4976
+ * @generated from protobuf field: org.dash.platform.dapi.v0.GetPathElementsResponse.GetPathElementsResponseV0.Elements elements = 1
4977
+ */
4978
+ elements: GetPathElementsResponse_GetPathElementsResponseV0_Elements;
4979
+ } | {
4980
+ oneofKind: "proof";
4981
+ /**
4982
+ * @generated from protobuf field: org.dash.platform.dapi.v0.Proof proof = 2
4983
+ */
4984
+ proof: Proof;
4985
+ } | {
4986
+ oneofKind: undefined;
4987
+ };
4988
+ /**
4989
+ * @generated from protobuf field: org.dash.platform.dapi.v0.ResponseMetadata metadata = 3
4990
+ */
4991
+ metadata?: ResponseMetadata;
4992
+ }
4993
+ /**
4994
+ * @generated from protobuf message org.dash.platform.dapi.v0.GetPathElementsResponse.GetPathElementsResponseV0.Elements
4995
+ */
4996
+ export interface GetPathElementsResponse_GetPathElementsResponseV0_Elements {
4997
+ /**
4998
+ * @generated from protobuf field: repeated bytes elements = 1
4999
+ */
5000
+ elements: Uint8Array[];
5001
+ }
4915
5002
  /**
4916
5003
  * @generated from protobuf enum org.dash.platform.dapi.v0.SignedMsgType
4917
5004
  */
@@ -7405,6 +7492,56 @@ declare class CanonicalVote$Type extends MessageType<CanonicalVote> {
7405
7492
  * @generated MessageType for protobuf message org.dash.platform.dapi.v0.CanonicalVote
7406
7493
  */
7407
7494
  export declare const CanonicalVote: CanonicalVote$Type;
7495
+ declare class GetPathElementsRequest$Type extends MessageType<GetPathElementsRequest> {
7496
+ constructor();
7497
+ create(value?: PartialMessage<GetPathElementsRequest>): GetPathElementsRequest;
7498
+ internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: GetPathElementsRequest): GetPathElementsRequest;
7499
+ internalBinaryWrite(message: GetPathElementsRequest, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter;
7500
+ }
7501
+ /**
7502
+ * @generated MessageType for protobuf message org.dash.platform.dapi.v0.GetPathElementsRequest
7503
+ */
7504
+ export declare const GetPathElementsRequest: GetPathElementsRequest$Type;
7505
+ declare class GetPathElementsRequest_GetPathElementsRequestV0$Type extends MessageType<GetPathElementsRequest_GetPathElementsRequestV0> {
7506
+ constructor();
7507
+ create(value?: PartialMessage<GetPathElementsRequest_GetPathElementsRequestV0>): GetPathElementsRequest_GetPathElementsRequestV0;
7508
+ internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: GetPathElementsRequest_GetPathElementsRequestV0): GetPathElementsRequest_GetPathElementsRequestV0;
7509
+ internalBinaryWrite(message: GetPathElementsRequest_GetPathElementsRequestV0, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter;
7510
+ }
7511
+ /**
7512
+ * @generated MessageType for protobuf message org.dash.platform.dapi.v0.GetPathElementsRequest.GetPathElementsRequestV0
7513
+ */
7514
+ export declare const GetPathElementsRequest_GetPathElementsRequestV0: GetPathElementsRequest_GetPathElementsRequestV0$Type;
7515
+ declare class GetPathElementsResponse$Type extends MessageType<GetPathElementsResponse> {
7516
+ constructor();
7517
+ create(value?: PartialMessage<GetPathElementsResponse>): GetPathElementsResponse;
7518
+ internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: GetPathElementsResponse): GetPathElementsResponse;
7519
+ internalBinaryWrite(message: GetPathElementsResponse, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter;
7520
+ }
7521
+ /**
7522
+ * @generated MessageType for protobuf message org.dash.platform.dapi.v0.GetPathElementsResponse
7523
+ */
7524
+ export declare const GetPathElementsResponse: GetPathElementsResponse$Type;
7525
+ declare class GetPathElementsResponse_GetPathElementsResponseV0$Type extends MessageType<GetPathElementsResponse_GetPathElementsResponseV0> {
7526
+ constructor();
7527
+ create(value?: PartialMessage<GetPathElementsResponse_GetPathElementsResponseV0>): GetPathElementsResponse_GetPathElementsResponseV0;
7528
+ internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: GetPathElementsResponse_GetPathElementsResponseV0): GetPathElementsResponse_GetPathElementsResponseV0;
7529
+ internalBinaryWrite(message: GetPathElementsResponse_GetPathElementsResponseV0, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter;
7530
+ }
7531
+ /**
7532
+ * @generated MessageType for protobuf message org.dash.platform.dapi.v0.GetPathElementsResponse.GetPathElementsResponseV0
7533
+ */
7534
+ export declare const GetPathElementsResponse_GetPathElementsResponseV0: GetPathElementsResponse_GetPathElementsResponseV0$Type;
7535
+ declare class GetPathElementsResponse_GetPathElementsResponseV0_Elements$Type extends MessageType<GetPathElementsResponse_GetPathElementsResponseV0_Elements> {
7536
+ constructor();
7537
+ create(value?: PartialMessage<GetPathElementsResponse_GetPathElementsResponseV0_Elements>): GetPathElementsResponse_GetPathElementsResponseV0_Elements;
7538
+ internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: GetPathElementsResponse_GetPathElementsResponseV0_Elements): GetPathElementsResponse_GetPathElementsResponseV0_Elements;
7539
+ internalBinaryWrite(message: GetPathElementsResponse_GetPathElementsResponseV0_Elements, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter;
7540
+ }
7541
+ /**
7542
+ * @generated MessageType for protobuf message org.dash.platform.dapi.v0.GetPathElementsResponse.GetPathElementsResponseV0.Elements
7543
+ */
7544
+ export declare const GetPathElementsResponse_GetPathElementsResponseV0_Elements: GetPathElementsResponse_GetPathElementsResponseV0_Elements$Type;
7408
7545
  /**
7409
7546
  * @generated ServiceType for protobuf service org.dash.platform.dapi.v0.Platform
7410
7547
  */
@@ -15045,6 +15045,283 @@ class CanonicalVote$Type extends MessageType {
15045
15045
  * @generated MessageType for protobuf message org.dash.platform.dapi.v0.CanonicalVote
15046
15046
  */
15047
15047
  export const CanonicalVote = new CanonicalVote$Type();
15048
+ // @generated message type with reflection information, may provide speed optimized methods
15049
+ class GetPathElementsRequest$Type extends MessageType {
15050
+ constructor() {
15051
+ super("org.dash.platform.dapi.v0.GetPathElementsRequest", [
15052
+ { no: 1, name: "v0", kind: "message", oneof: "version", T: () => GetPathElementsRequest_GetPathElementsRequestV0 }
15053
+ ]);
15054
+ }
15055
+ create(value) {
15056
+ const message = globalThis.Object.create((this.messagePrototype));
15057
+ message.version = { oneofKind: undefined };
15058
+ if (value !== undefined)
15059
+ reflectionMergePartial(this, message, value);
15060
+ return message;
15061
+ }
15062
+ internalBinaryRead(reader, length, options, target) {
15063
+ let message = target ?? this.create(), end = reader.pos + length;
15064
+ while (reader.pos < end) {
15065
+ let [fieldNo, wireType] = reader.tag();
15066
+ switch (fieldNo) {
15067
+ case /* org.dash.platform.dapi.v0.GetPathElementsRequest.GetPathElementsRequestV0 v0 */ 1:
15068
+ message.version = {
15069
+ oneofKind: "v0",
15070
+ v0: GetPathElementsRequest_GetPathElementsRequestV0.internalBinaryRead(reader, reader.uint32(), options, message.version.v0)
15071
+ };
15072
+ break;
15073
+ default:
15074
+ let u = options.readUnknownField;
15075
+ if (u === "throw")
15076
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
15077
+ let d = reader.skip(wireType);
15078
+ if (u !== false)
15079
+ (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
15080
+ }
15081
+ }
15082
+ return message;
15083
+ }
15084
+ internalBinaryWrite(message, writer, options) {
15085
+ /* org.dash.platform.dapi.v0.GetPathElementsRequest.GetPathElementsRequestV0 v0 = 1; */
15086
+ if (message.version.oneofKind === "v0")
15087
+ GetPathElementsRequest_GetPathElementsRequestV0.internalBinaryWrite(message.version.v0, writer.tag(1, WireType.LengthDelimited).fork(), options).join();
15088
+ let u = options.writeUnknownFields;
15089
+ if (u !== false)
15090
+ (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
15091
+ return writer;
15092
+ }
15093
+ }
15094
+ /**
15095
+ * @generated MessageType for protobuf message org.dash.platform.dapi.v0.GetPathElementsRequest
15096
+ */
15097
+ export const GetPathElementsRequest = new GetPathElementsRequest$Type();
15098
+ // @generated message type with reflection information, may provide speed optimized methods
15099
+ class GetPathElementsRequest_GetPathElementsRequestV0$Type extends MessageType {
15100
+ constructor() {
15101
+ super("org.dash.platform.dapi.v0.GetPathElementsRequest.GetPathElementsRequestV0", [
15102
+ { no: 1, name: "path", kind: "scalar", repeat: 2 /*RepeatType.UNPACKED*/, T: 12 /*ScalarType.BYTES*/ },
15103
+ { no: 2, name: "keys", kind: "scalar", repeat: 2 /*RepeatType.UNPACKED*/, T: 12 /*ScalarType.BYTES*/ },
15104
+ { no: 3, name: "prove", kind: "scalar", T: 8 /*ScalarType.BOOL*/ }
15105
+ ]);
15106
+ }
15107
+ create(value) {
15108
+ const message = globalThis.Object.create((this.messagePrototype));
15109
+ message.path = [];
15110
+ message.keys = [];
15111
+ message.prove = false;
15112
+ if (value !== undefined)
15113
+ reflectionMergePartial(this, message, value);
15114
+ return message;
15115
+ }
15116
+ internalBinaryRead(reader, length, options, target) {
15117
+ let message = target ?? this.create(), end = reader.pos + length;
15118
+ while (reader.pos < end) {
15119
+ let [fieldNo, wireType] = reader.tag();
15120
+ switch (fieldNo) {
15121
+ case /* repeated bytes path */ 1:
15122
+ message.path.push(reader.bytes());
15123
+ break;
15124
+ case /* repeated bytes keys */ 2:
15125
+ message.keys.push(reader.bytes());
15126
+ break;
15127
+ case /* bool prove */ 3:
15128
+ message.prove = reader.bool();
15129
+ break;
15130
+ default:
15131
+ let u = options.readUnknownField;
15132
+ if (u === "throw")
15133
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
15134
+ let d = reader.skip(wireType);
15135
+ if (u !== false)
15136
+ (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
15137
+ }
15138
+ }
15139
+ return message;
15140
+ }
15141
+ internalBinaryWrite(message, writer, options) {
15142
+ /* repeated bytes path = 1; */
15143
+ for (let i = 0; i < message.path.length; i++)
15144
+ writer.tag(1, WireType.LengthDelimited).bytes(message.path[i]);
15145
+ /* repeated bytes keys = 2; */
15146
+ for (let i = 0; i < message.keys.length; i++)
15147
+ writer.tag(2, WireType.LengthDelimited).bytes(message.keys[i]);
15148
+ /* bool prove = 3; */
15149
+ if (message.prove !== false)
15150
+ writer.tag(3, WireType.Varint).bool(message.prove);
15151
+ let u = options.writeUnknownFields;
15152
+ if (u !== false)
15153
+ (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
15154
+ return writer;
15155
+ }
15156
+ }
15157
+ /**
15158
+ * @generated MessageType for protobuf message org.dash.platform.dapi.v0.GetPathElementsRequest.GetPathElementsRequestV0
15159
+ */
15160
+ export const GetPathElementsRequest_GetPathElementsRequestV0 = new GetPathElementsRequest_GetPathElementsRequestV0$Type();
15161
+ // @generated message type with reflection information, may provide speed optimized methods
15162
+ class GetPathElementsResponse$Type extends MessageType {
15163
+ constructor() {
15164
+ super("org.dash.platform.dapi.v0.GetPathElementsResponse", [
15165
+ { no: 1, name: "v0", kind: "message", oneof: "version", T: () => GetPathElementsResponse_GetPathElementsResponseV0 }
15166
+ ]);
15167
+ }
15168
+ create(value) {
15169
+ const message = globalThis.Object.create((this.messagePrototype));
15170
+ message.version = { oneofKind: undefined };
15171
+ if (value !== undefined)
15172
+ reflectionMergePartial(this, message, value);
15173
+ return message;
15174
+ }
15175
+ internalBinaryRead(reader, length, options, target) {
15176
+ let message = target ?? this.create(), end = reader.pos + length;
15177
+ while (reader.pos < end) {
15178
+ let [fieldNo, wireType] = reader.tag();
15179
+ switch (fieldNo) {
15180
+ case /* org.dash.platform.dapi.v0.GetPathElementsResponse.GetPathElementsResponseV0 v0 */ 1:
15181
+ message.version = {
15182
+ oneofKind: "v0",
15183
+ v0: GetPathElementsResponse_GetPathElementsResponseV0.internalBinaryRead(reader, reader.uint32(), options, message.version.v0)
15184
+ };
15185
+ break;
15186
+ default:
15187
+ let u = options.readUnknownField;
15188
+ if (u === "throw")
15189
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
15190
+ let d = reader.skip(wireType);
15191
+ if (u !== false)
15192
+ (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
15193
+ }
15194
+ }
15195
+ return message;
15196
+ }
15197
+ internalBinaryWrite(message, writer, options) {
15198
+ /* org.dash.platform.dapi.v0.GetPathElementsResponse.GetPathElementsResponseV0 v0 = 1; */
15199
+ if (message.version.oneofKind === "v0")
15200
+ GetPathElementsResponse_GetPathElementsResponseV0.internalBinaryWrite(message.version.v0, writer.tag(1, WireType.LengthDelimited).fork(), options).join();
15201
+ let u = options.writeUnknownFields;
15202
+ if (u !== false)
15203
+ (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
15204
+ return writer;
15205
+ }
15206
+ }
15207
+ /**
15208
+ * @generated MessageType for protobuf message org.dash.platform.dapi.v0.GetPathElementsResponse
15209
+ */
15210
+ export const GetPathElementsResponse = new GetPathElementsResponse$Type();
15211
+ // @generated message type with reflection information, may provide speed optimized methods
15212
+ class GetPathElementsResponse_GetPathElementsResponseV0$Type extends MessageType {
15213
+ constructor() {
15214
+ super("org.dash.platform.dapi.v0.GetPathElementsResponse.GetPathElementsResponseV0", [
15215
+ { no: 1, name: "elements", kind: "message", oneof: "result", T: () => GetPathElementsResponse_GetPathElementsResponseV0_Elements },
15216
+ { no: 2, name: "proof", kind: "message", oneof: "result", T: () => Proof },
15217
+ { no: 3, name: "metadata", kind: "message", T: () => ResponseMetadata }
15218
+ ]);
15219
+ }
15220
+ create(value) {
15221
+ const message = globalThis.Object.create((this.messagePrototype));
15222
+ message.result = { oneofKind: undefined };
15223
+ if (value !== undefined)
15224
+ reflectionMergePartial(this, message, value);
15225
+ return message;
15226
+ }
15227
+ internalBinaryRead(reader, length, options, target) {
15228
+ let message = target ?? this.create(), end = reader.pos + length;
15229
+ while (reader.pos < end) {
15230
+ let [fieldNo, wireType] = reader.tag();
15231
+ switch (fieldNo) {
15232
+ case /* org.dash.platform.dapi.v0.GetPathElementsResponse.GetPathElementsResponseV0.Elements elements */ 1:
15233
+ message.result = {
15234
+ oneofKind: "elements",
15235
+ elements: GetPathElementsResponse_GetPathElementsResponseV0_Elements.internalBinaryRead(reader, reader.uint32(), options, message.result.elements)
15236
+ };
15237
+ break;
15238
+ case /* org.dash.platform.dapi.v0.Proof proof */ 2:
15239
+ message.result = {
15240
+ oneofKind: "proof",
15241
+ proof: Proof.internalBinaryRead(reader, reader.uint32(), options, message.result.proof)
15242
+ };
15243
+ break;
15244
+ case /* org.dash.platform.dapi.v0.ResponseMetadata metadata */ 3:
15245
+ message.metadata = ResponseMetadata.internalBinaryRead(reader, reader.uint32(), options, message.metadata);
15246
+ break;
15247
+ default:
15248
+ let u = options.readUnknownField;
15249
+ if (u === "throw")
15250
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
15251
+ let d = reader.skip(wireType);
15252
+ if (u !== false)
15253
+ (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
15254
+ }
15255
+ }
15256
+ return message;
15257
+ }
15258
+ internalBinaryWrite(message, writer, options) {
15259
+ /* org.dash.platform.dapi.v0.GetPathElementsResponse.GetPathElementsResponseV0.Elements elements = 1; */
15260
+ if (message.result.oneofKind === "elements")
15261
+ GetPathElementsResponse_GetPathElementsResponseV0_Elements.internalBinaryWrite(message.result.elements, writer.tag(1, WireType.LengthDelimited).fork(), options).join();
15262
+ /* org.dash.platform.dapi.v0.Proof proof = 2; */
15263
+ if (message.result.oneofKind === "proof")
15264
+ Proof.internalBinaryWrite(message.result.proof, writer.tag(2, WireType.LengthDelimited).fork(), options).join();
15265
+ /* org.dash.platform.dapi.v0.ResponseMetadata metadata = 3; */
15266
+ if (message.metadata)
15267
+ ResponseMetadata.internalBinaryWrite(message.metadata, writer.tag(3, WireType.LengthDelimited).fork(), options).join();
15268
+ let u = options.writeUnknownFields;
15269
+ if (u !== false)
15270
+ (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
15271
+ return writer;
15272
+ }
15273
+ }
15274
+ /**
15275
+ * @generated MessageType for protobuf message org.dash.platform.dapi.v0.GetPathElementsResponse.GetPathElementsResponseV0
15276
+ */
15277
+ export const GetPathElementsResponse_GetPathElementsResponseV0 = new GetPathElementsResponse_GetPathElementsResponseV0$Type();
15278
+ // @generated message type with reflection information, may provide speed optimized methods
15279
+ class GetPathElementsResponse_GetPathElementsResponseV0_Elements$Type extends MessageType {
15280
+ constructor() {
15281
+ super("org.dash.platform.dapi.v0.GetPathElementsResponse.GetPathElementsResponseV0.Elements", [
15282
+ { no: 1, name: "elements", kind: "scalar", repeat: 2 /*RepeatType.UNPACKED*/, T: 12 /*ScalarType.BYTES*/ }
15283
+ ]);
15284
+ }
15285
+ create(value) {
15286
+ const message = globalThis.Object.create((this.messagePrototype));
15287
+ message.elements = [];
15288
+ if (value !== undefined)
15289
+ reflectionMergePartial(this, message, value);
15290
+ return message;
15291
+ }
15292
+ internalBinaryRead(reader, length, options, target) {
15293
+ let message = target ?? this.create(), end = reader.pos + length;
15294
+ while (reader.pos < end) {
15295
+ let [fieldNo, wireType] = reader.tag();
15296
+ switch (fieldNo) {
15297
+ case /* repeated bytes elements */ 1:
15298
+ message.elements.push(reader.bytes());
15299
+ break;
15300
+ default:
15301
+ let u = options.readUnknownField;
15302
+ if (u === "throw")
15303
+ throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
15304
+ let d = reader.skip(wireType);
15305
+ if (u !== false)
15306
+ (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
15307
+ }
15308
+ }
15309
+ return message;
15310
+ }
15311
+ internalBinaryWrite(message, writer, options) {
15312
+ /* repeated bytes elements = 1; */
15313
+ for (let i = 0; i < message.elements.length; i++)
15314
+ writer.tag(1, WireType.LengthDelimited).bytes(message.elements[i]);
15315
+ let u = options.writeUnknownFields;
15316
+ if (u !== false)
15317
+ (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
15318
+ return writer;
15319
+ }
15320
+ }
15321
+ /**
15322
+ * @generated MessageType for protobuf message org.dash.platform.dapi.v0.GetPathElementsResponse.GetPathElementsResponseV0.Elements
15323
+ */
15324
+ export const GetPathElementsResponse_GetPathElementsResponseV0_Elements = new GetPathElementsResponse_GetPathElementsResponseV0_Elements$Type();
15048
15325
  /**
15049
15326
  * @generated ServiceType for protobuf service org.dash.platform.dapi.v0.Platform
15050
15327
  */
@@ -15083,5 +15360,6 @@ export const Platform = new ServiceType("org.dash.platform.dapi.v0.Platform", [
15083
15360
  { name: "getMostRecentShieldedAnchor", options: {}, I: GetMostRecentShieldedAnchorRequest, O: GetMostRecentShieldedAnchorResponse },
15084
15361
  { name: "getShieldedPoolState", options: {}, I: GetShieldedPoolStateRequest, O: GetShieldedPoolStateResponse },
15085
15362
  { name: "getShieldedNotesCount", options: {}, I: GetShieldedNotesCountRequest, O: GetShieldedNotesCountResponse },
15086
- { name: "getShieldedNullifiers", options: {}, I: GetShieldedNullifiersRequest, O: GetShieldedNullifiersResponse }
15363
+ { name: "getShieldedNullifiers", options: {}, I: GetShieldedNullifiersRequest, O: GetShieldedNullifiersResponse },
15364
+ { name: "getPathElements", options: {}, I: GetPathElementsRequest, O: GetPathElementsResponse }
15087
15365
  ]);
@@ -2,6 +2,7 @@ import { PlatformClient } from '../proto/generated/platform.client.js';
2
2
  import { Proof, ResponseMetadata } from '../proto/generated/platform.js';
3
3
  import { GRPCPool } from './grpcConnectionPool.js';
4
4
  import { QuorumKeyProvider } from './quorumKeyProvider.js';
5
+ import { PlatformVersionWASM } from 'pshenmic-dpp';
5
6
  type SubType<Base, Condition> = Pick<Base, {
6
7
  [Key in keyof Base]: Base[Key] extends Condition ? Key : never;
7
8
  }[keyof Base]>;
@@ -15,6 +16,7 @@ export interface ResponseProof {
15
16
  }
16
17
  type MapProof<Response, P extends ResponseProof = ResponseProof> = (response: Response) => P;
17
18
  type GroveDBVerifier<Args extends unknown[], V> = (grovedbProof: Uint8Array, ...args: Args) => V;
19
+ type GetVerifierArgs<P, Args> = (responseProof: P, platformVersion: PlatformVersionWASM) => Args;
18
20
  /**
19
21
  * Body of the version (e.g. `v0`) of a versioned response, distributed over all versions
20
22
  */
@@ -39,12 +41,37 @@ export type QueryData<Response, V> = {
39
41
  proved: true;
40
42
  verified: V;
41
43
  metadata: ResponseMetadata;
44
+ /** Platform version the proof was verified with, see {getVerifierVersion} **/
45
+ platformVersion: PlatformVersionWASM;
42
46
  } | {
43
47
  proved: false;
44
48
  result: ResponseResult<Response>;
45
49
  metadata: ResponseMetadata;
50
+ /**
51
+ * Platform version to parse the response with, the protocol version of the response is used to parse it
52
+ * (like the response itself, it is not verified), but it is not learned by the pool
53
+ */
54
+ platformVersion: PlatformVersionWASM;
46
55
  };
47
56
  type MapResponse<Response, V, T> = (data: QueryData<Response, V>) => T | Promise<T>;
57
+ /**
58
+ * Returns the highest protocol version of the responses of the pool whose proof and quorum signature were verified,
59
+ * or undefined if no response was verified yet
60
+ */
61
+ export declare function getVerifiedProtocolVersion(grpcPool: GRPCPool): number | undefined;
62
+ /**
63
+ * Returns the protocol version of the pool, the lowest version the network runs if it was not learned yet
64
+ */
65
+ export declare function getPoolProtocolVersion(grpcPool: GRPCPool): PlatformVersionWASM;
66
+ /**
67
+ * Returns the platform version to verify a response signed with the given protocol version.
68
+ * A newer signed version is used (up to the latest version known to the SDK), an older one is not,
69
+ * so a node behind the network fails the verification and the request is sent to another node.
70
+ *
71
+ * Choosing the version before the quorum signature is verified is safe:
72
+ * the signature covers the protocol version, so a false version fails the verification
73
+ */
74
+ export declare function getVerifierVersion(protocolVersion: number, signedProtocolVersion: number): PlatformVersionWASM;
48
75
  /**
49
76
  * Minimal shape of a v0 response that may contain a proof
50
77
  */
@@ -68,9 +95,12 @@ export declare function getResponseProof(response: ProvedResponse): ResponseProo
68
95
  * Sends a GRPC request to a node from the pool and returns the mapped result of the response.
69
96
  *
70
97
  * Queries are requested with proofs, unless proofs are disabled in the pool (`grpcPool.proofs === false`):
71
- * - with proofs: request (`prove: true`) -> proof mapping -> GroveDB proof verification -> quorum signature verification -> mapping
98
+ * - with proofs: request (`prove: true`) -> proof mapping -> GroveDB proof verification -> quorum signature verification -> protocol version update -> mapping
72
99
  * - without proofs: request (`prove: false`) -> mapping of the response result
73
100
  *
101
+ * The protocol version of the pool is raised to the protocol version of the verified responses,
102
+ * the platform version to verify the proof with is passed to the args callback of the proof verifier, see {getVerifierVersion}
103
+ *
74
104
  * `mapResponse` handles both cases, the verified data or the response result, see {QueryData}.
75
105
  * Requests without the `prove` field are always proved
76
106
  *
@@ -80,7 +110,7 @@ export declare function getResponseProof(response: ProvedResponse): ResponseProo
80
110
  * @example
81
111
  * const balance = await QueryExecutor.build(grpcPool, quorumKeyProvider)
82
112
  * .setGrpcRequest('getIdentityBalance', request)
83
- * .setProofVerifier(verifyIdentityBalanceProof, id.bytes(), true, LATEST_PLATFORM_VERSION)
113
+ * .setProofVerifier(verifyIdentityBalanceProof, (_, platformVersion) => [id.bytes(), true, platformVersion])
84
114
  * .mapResponse(data => data.proved ? data.verified.balance : BigInt(data.result.balance))
85
115
  * .execute()
86
116
  */
@@ -102,10 +132,11 @@ export default class QueryExecutor<Response = unknown, V = unknown, T = unknown,
102
132
  mapProof<E extends ResponseProof>(mapProof: MapProof<Response, E>): QueryExecutor<Response, V, T, E>;
103
133
  /**
104
134
  * Sets the GroveDB proof verification function, which is called with the GroveDB proof of the response
105
- * followed by the given args. Args depending on the response (e.g. metadata) can be passed as a callback.
135
+ * followed by the given args. Args depending on the response (e.g. metadata) or the platform version
136
+ * to verify the proof with can be passed as a callback.
106
137
  * Failure of the verification is thrown as ProofError, so the request is retried on another node
107
138
  */
108
- setProofVerifier<Args extends unknown[] | [], U>(verify: GroveDBVerifier<Args, U>, getArgs: (responseProof: P) => NoInfer<Args>): QueryExecutor<Response, U, T, P>;
139
+ setProofVerifier<Args extends unknown[] | [], U>(verify: GroveDBVerifier<Args, U>, getArgs: GetVerifierArgs<P, NoInfer<Args>>): QueryExecutor<Response, U, T, P>;
109
140
  setProofVerifier<Args extends unknown[] | [], U>(verify: GroveDBVerifier<Args, U>, ...args: Args): QueryExecutor<Response, U, T, P>;
110
141
  /**
111
142
  * Sets the mapping of the query data to the result of the query, also the place for "not found" checks.
@@ -117,6 +148,11 @@ export default class QueryExecutor<Response = unknown, V = unknown, T = unknown,
117
148
  * e.g. if the GroveDB proof is verified against an already verified root hash
118
149
  */
119
150
  setValidateProof(validateProof: boolean): this;
151
+ /**
152
+ * Requests and verifies the proof even if proofs are disabled in the pool,
153
+ * e.g. to learn the protocol version of the network from a verified response
154
+ */
155
+ setRequireProof(requireProof: boolean): this;
120
156
  execute(): Promise<T>;
121
157
  }
122
158
  export {};