@dashevo/dapi-client 4.2.0-dev.9 → 5.0.0-beta.2

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.
@@ -8,11 +8,13 @@ class WaitForStateTransitionResultResponse extends AbstractResponse {
8
8
  * @param {Metadata} metadata
9
9
  * @param {Proof} [proof]
10
10
  * @param {ErrorResult} [error]
11
+ * @param {bigint} [ownerBalance]
11
12
  */
12
- constructor(metadata, proof = undefined, error = undefined) {
13
+ constructor(metadata, proof = undefined, error = undefined, ownerBalance = undefined) {
13
14
  super(metadata, proof);
14
15
 
15
16
  this.error = error;
17
+ this.ownerBalance = ownerBalance;
16
18
  }
17
19
 
18
20
  /**
@@ -22,6 +24,18 @@ class WaitForStateTransitionResultResponse extends AbstractResponse {
22
24
  return this.error;
23
25
  }
24
26
 
27
+ /**
28
+ * The credit balance of the transition's owner after it executed, as DAPI
29
+ * read it without a proof. Set when the request asked for the user's
30
+ * balance and for no proof; a proved response of an owned, fee-paying
31
+ * transition carries the balance inside the proof.
32
+ *
33
+ * @returns {bigint|undefined}
34
+ */
35
+ getOwnerBalance() {
36
+ return this.ownerBalance;
37
+ }
38
+
25
39
  /**
26
40
  * @param proto
27
41
  * @returns {WaitForStateTransitionResultResponse}
@@ -51,10 +65,17 @@ class WaitForStateTransitionResultResponse extends AbstractResponse {
51
65
  const metadata = proto.getV0().getMetadata()
52
66
  ? new Metadata(proto.getV0().getMetadata().toObject()) : null;
53
67
 
68
+ let ownerBalance;
69
+ const successWithOwnerBalance = proto.getV0().getSuccessWithOwnerBalance();
70
+ if (successWithOwnerBalance) {
71
+ ownerBalance = BigInt(successWithOwnerBalance.getOwnerBalance());
72
+ }
73
+
54
74
  return new WaitForStateTransitionResultResponse(
55
75
  metadata,
56
76
  proof,
57
77
  error,
78
+ ownerBalance,
58
79
  );
59
80
  }
60
81
  }
@@ -26,6 +26,7 @@ function waitForStateTransitionResultFactory(grpcTransport) {
26
26
  // Set default timeout
27
27
  timeout: 120000,
28
28
  prove: false,
29
+ requestUserBalance: false,
29
30
  retry: 0,
30
31
  throwDeadlineExceeded: true,
31
32
  ...options,
@@ -36,7 +37,8 @@ function waitForStateTransitionResultFactory(grpcTransport) {
36
37
  waitForStateTransitionResultRequest.setV0(
37
38
  new WaitForStateTransitionResultRequestV0()
38
39
  .setStateTransitionHash(stateTransitionHash)
39
- .setProve(options.prove),
40
+ .setProve(options.prove)
41
+ .setRequestUserBalance(options.requestUserBalance),
40
42
  );
41
43
 
42
44
  let lastError;
@@ -44,7 +46,6 @@ function waitForStateTransitionResultFactory(grpcTransport) {
44
46
  // TODO: simple retry before the dapi versioning is properly implemented
45
47
  for (let i = 0; i < 3; i += 1) {
46
48
  try {
47
- // eslint-disable-next-line no-await-in-loop
48
49
  const waitForStateTransitionResultResponse = await grpcTransport.request(
49
50
  PlatformPromiseClient,
50
51
  'waitForStateTransitionResult',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dashevo/dapi-client",
3
- "version": "4.2.0-dev.9",
3
+ "version": "5.0.0-beta.2",
4
4
  "description": "Client library used to access Dash DAPI endpoints",
5
5
  "main": "lib/index.js",
6
6
  "contributors": [
@@ -26,11 +26,11 @@
26
26
  }
27
27
  ],
28
28
  "dependencies": {
29
- "@dashevo/dapi-grpc": "4.2.0-dev.9",
30
- "@dashevo/dash-spv": "5.2.0-dev.9",
29
+ "@dashevo/dapi-grpc": "5.0.0-beta.2",
30
+ "@dashevo/dash-spv": "6.0.0-beta.2",
31
31
  "@dashevo/dashcore-lib": "~0.22.0",
32
- "@dashevo/grpc-common": "4.2.0-dev.9",
33
- "@dashevo/wasm-dpp": "4.2.0-dev.9",
32
+ "@dashevo/grpc-common": "5.0.0-beta.2",
33
+ "@dashevo/wasm-dpp": "5.0.0-beta.2",
34
34
  "cbor": "^8.0.0",
35
35
  "google-protobuf": "^3.12.2",
36
36
  "undici": "^6.0.0",