dash-platform-sdk 1.5.2 → 1.6.0-dev.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 (89) hide show
  1. package/README.md +15 -15
  2. package/bundle.min.js +1 -1
  3. package/package.json +3 -4
  4. package/proto/generated/platform.client.d.ts +20 -60
  5. package/proto/generated/platform.client.js +41 -69
  6. package/proto/generated/platform.d.ts +2330 -1650
  7. package/proto/generated/platform.js +4992 -3467
  8. package/src/DashPlatformSDK.d.ts +0 -8
  9. package/src/DashPlatformSDK.js +0 -10
  10. package/src/constants.d.ts +1 -1
  11. package/src/constants.js +1 -1
  12. package/src/contestedResources/getContestedResourceVoteState.js +1 -1
  13. package/src/dataContracts/getDataContractByIdentifier.js +1 -1
  14. package/src/documents/createStateTransition.d.ts +2 -2
  15. package/src/documents/createStateTransition.js +6 -6
  16. package/src/documents/getActionFeeAgreement.d.ts +4 -0
  17. package/src/documents/getActionFeeAgreement.js +21 -0
  18. package/src/documents/index.d.ts +97 -3
  19. package/src/documents/index.js +114 -1
  20. package/src/documents/query.js +13 -52
  21. package/src/documents/queryAggregate.d.ts +4 -0
  22. package/src/documents/queryAggregate.js +32 -0
  23. package/src/documents/queryJoined.d.ts +16 -0
  24. package/src/documents/queryJoined.js +44 -0
  25. package/src/documents/queryRanked.d.ts +12 -0
  26. package/src/documents/queryRanked.js +37 -0
  27. package/src/documents/v1.d.ts +33 -0
  28. package/src/documents/v1.js +233 -0
  29. package/src/grpcConnectionPool.d.ts +3 -6
  30. package/src/grpcConnectionPool.js +141 -47
  31. package/src/identities/getIdentityBalance.js +1 -1
  32. package/src/identities/getIdentityByIdentifier.js +1 -1
  33. package/src/identities/getIdentityByNonUniquePublicKeyHash.js +7 -11
  34. package/src/identities/getIdentityByPublicKeyHash.js +1 -1
  35. package/src/identities/getIdentityContractNonce.js +1 -1
  36. package/src/identities/getIdentityNonce.js +1 -1
  37. package/src/identities/getIdentityPublicKeys.js +1 -1
  38. package/src/node/epochInfos.js +1 -1
  39. package/src/node/finalizedEpochInfos.js +1 -1
  40. package/src/node/getCurrentQuorumsInfo.js +1 -1
  41. package/src/node/status.js +1 -1
  42. package/src/node/totalCredits.js +1 -1
  43. package/src/platformAddresses/getAddressInfo.js +1 -1
  44. package/src/platformAddresses/getAddressesBranchState.js +1 -1
  45. package/src/platformAddresses/getAddressesInfos.js +1 -1
  46. package/src/platformAddresses/getAddressesTrunkState.js +1 -1
  47. package/src/platformAddresses/getRecentAddressBalanceChanges.js +1 -1
  48. package/src/platformAddresses/getRecentCompactedAddressBalanceChanges.js +1 -1
  49. package/src/shielded/getMostRecentShieldedAnchor.d.ts +2 -1
  50. package/src/shielded/getMostRecentShieldedAnchor.js +7 -5
  51. package/src/shielded/getShieldedAnchors.d.ts +2 -1
  52. package/src/shielded/getShieldedAnchors.js +7 -5
  53. package/src/shielded/getShieldedEncryptedNotes.d.ts +2 -1
  54. package/src/shielded/getShieldedEncryptedNotes.js +7 -5
  55. package/src/shielded/getShieldedNotesCount.d.ts +2 -1
  56. package/src/shielded/getShieldedNotesCount.js +7 -5
  57. package/src/shielded/getShieldedNullifiers.d.ts +2 -1
  58. package/src/shielded/getShieldedNullifiers.js +7 -5
  59. package/src/shielded/getShieldedPoolState.d.ts +2 -1
  60. package/src/shielded/getShieldedPoolState.js +7 -5
  61. package/src/shielded/index.d.ts +17 -7
  62. package/src/shielded/index.js +22 -12
  63. package/src/stateTransitions/broadcast.js +1 -1
  64. package/src/stateTransitions/index.d.ts +6 -2
  65. package/src/stateTransitions/index.js +5 -1
  66. package/src/stateTransitions/waitForStateTransitionResult.d.ts +1 -1
  67. package/src/stateTransitions/waitForStateTransitionResult.js +5 -3
  68. package/src/tokens/getIdentitiesTokenBalances.js +1 -1
  69. package/src/tokens/getIdentityTokensBalances.js +1 -1
  70. package/src/tokens/getTokenContractInfo.js +1 -1
  71. package/src/tokens/getTokenDirectPurchasePrices.js +1 -1
  72. package/src/tokens/getTokenTotalSupply.js +1 -1
  73. package/src/utils/verifyTenderdashProof.js +1 -1
  74. package/test/unit/ContestedResources.spec.js +0 -1
  75. package/test/unit/DataContract.spec.js +2 -2
  76. package/test/unit/Document.spec.js +0 -1
  77. package/test/unit/DocumentActionFees.spec.d.ts +1 -0
  78. package/test/unit/DocumentActionFees.spec.js +99 -0
  79. package/test/unit/DocumentQueries.spec.d.ts +1 -0
  80. package/test/unit/DocumentQueries.spec.js +178 -0
  81. package/test/unit/DocumentsV1.spec.d.ts +1 -0
  82. package/test/unit/DocumentsV1.spec.js +75 -0
  83. package/test/unit/Identity.spec.js +0 -1
  84. package/test/unit/Names.spec.js +0 -1
  85. package/test/unit/Node.spec.js +0 -1
  86. package/test/unit/PlatformAddress.spec.js +0 -1
  87. package/test/unit/Shielded.spec.js +0 -1
  88. package/test/unit/Tokens.spec.js +0 -1
  89. package/types.d.ts +20 -1
@@ -58,14 +58,6 @@ export declare class DashPlatformSDK {
58
58
  * @param network
59
59
  */
60
60
  _initialize(grpcPool: GRPCPool): void;
61
- /**
62
- * Waits until GRPC connection pool is initialized
63
- * (seed nodes are checked and evonodes are discovered)
64
- * SDK can be used without waiting, but requests may be sent to unavailable seed nodes until then
65
- *
66
- * @return {Promise<void>}
67
- */
68
- waitForInit(): Promise<void>;
69
61
  /**
70
62
  * Get currently used network
71
63
  *
@@ -81,16 +81,6 @@ export class DashPlatformSDK {
81
81
  this.names = new NamesController(grpcPool);
82
82
  this.keyPair = new KeyPairController();
83
83
  }
84
- /**
85
- * Waits until GRPC connection pool is initialized
86
- * (seed nodes are checked and evonodes are discovered)
87
- * SDK can be used without waiting, but requests may be sent to unavailable seed nodes until then
88
- *
89
- * @return {Promise<void>}
90
- */
91
- async waitForInit() {
92
- await this.grpcPool.waitForInit?.();
93
- }
94
84
  /**
95
85
  * Get currently used network
96
86
  *
@@ -10,4 +10,4 @@ export declare const MAINNET_ACTIVATION_HEIGHT = 2128896;
10
10
  export declare const GRPC_DEFAULT_POOL_LIMIT = 5;
11
11
  export declare const DPNS_DATA_CONTRACT_ID = "GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec";
12
12
  export declare const DPNS_DATA_CONTRACT_BYTES = "AeZoxlmvZq7h5ywYbd57W34KHXEqCcQNVyH2Ir9TxTFVAAAAAAABAQAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIGZG9tYWluFgsSEGRvY3VtZW50c011dGFibGUTABIMY2FuQmVEZWxldGVkEwESDHRyYW5zZmVyYWJsZQIBEgl0cmFkZU1vZGUCARIEdHlwZRIGb2JqZWN0EgdpbmRpY2VzFQIWBBIEbmFtZRIScGFyZW50TmFtZUFuZExhYmVsEgpwcm9wZXJ0aWVzFQIWARIabm9ybWFsaXplZFBhcmVudERvbWFpbk5hbWUSA2FzYxYBEg9ub3JtYWxpemVkTGFiZWwSA2FzYxIGdW5pcXVlEwESCWNvbnRlc3RlZBYDEgxmaWVsZE1hdGNoZXMVARYCEgVmaWVsZBIPbm9ybWFsaXplZExhYmVsEgxyZWdleFBhdHRlcm4SE15bYS16QS1aMDEtXXszLDE5fSQSCnJlc29sdXRpb24CABILZGVzY3JpcHRpb24SqklmIHRoZSBub3JtYWxpemVkIGxhYmVsIHBhcnQgb2YgdGhpcyBpbmRleCBpcyBsZXNzIHRoYW4gMjAgY2hhcmFjdGVycyAoYWxsIGFscGhhYmV0IGEteiwgQS1aLCAwLCAxLCBhbmQgLSkgdGhlbiBhIG1hc3Rlcm5vZGUgdm90ZSBjb250ZXN0IHRha2VzIHBsYWNlIHRvIGdpdmUgb3V0IHRoZSBuYW1lFgMSBG5hbWUSCmlkZW50aXR5SWQSDm51bGxTZWFyY2hhYmxlEwASCnByb3BlcnRpZXMVARYBEhByZWNvcmRzLmlkZW50aXR5EgNhc2MSCnByb3BlcnRpZXMWBxIFbGFiZWwWBhIEdHlwZRIGc3RyaW5nEgdwYXR0ZXJuEipeW2EtekEtWjAtOV1bYS16QS1aMC05LV17MCw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WJlbCArICcuJyArIG5vcm1hbGl6ZWRQYXJlbnREb21haW4gbXVzdCBub3QgYmUgbG9uZ2VyIHRoYW4gMjUzIGNoYXJzIGxlbmd0aCBhcyBkZWZpbmVkIGJ5IFJGQyAxMDM1LiBEb21haW4gZG9jdW1lbnRzIGFyZSBpbW11dGFibGU6IG1vZGlmaWNhdGlvbiBhbmQgZGVsZXRpb24gYXJlIHJlc3RyaWN0ZWQIcHJlb3JkZXIWCBIQZG9jdW1lbnRzTXV0YWJsZRMAEgxjYW5CZURlbGV0ZWQTARIEdHlwZRIGb2JqZWN0EgdpbmRpY2VzFQEWAxIEbmFtZRIKc2FsdGVkSGFzaBIKcHJvcGVydGllcxUBFgESEHNhbHRlZERvbWFpbkhhc2gSA2FzYxIGdW5pcXVlEwESCnByb3BlcnRpZXMWARIQc2FsdGVkRG9tYWluSGFzaBYGEgR0eXBlEgVhcnJheRIJYnl0ZUFycmF5EwESCG1pbkl0ZW1zAiASCG1heEl0ZW1zAiASCHBvc2l0aW9uAgASC2Rlc2NyaXB0aW9uEllEb3VibGUgc2hhLTI1NiBvZiB0aGUgY29uY2F0ZW5hdGlvbiBvZiBhIDMyIGJ5dGUgcmFuZG9tIHNhbHQgYW5kIGEgbm9ybWFsaXplZCBkb21haW4gbmFtZRIIcmVxdWlyZWQVARIQc2FsdGVkRG9tYWluSGFzaBIUYWRkaXRpb25hbFByb3BlcnRpZXMTABIIJGNvbW1lbnQSSlByZW9yZGVyIGRvY3VtZW50cyBhcmUgaW1tdXRhYmxlOiBtb2RpZmljYXRpb24gYW5kIGRlbGV0aW9uIGFyZSByZXN0cmljdGVkAAAAAAAAAAAAAA==";
13
- export declare const LATEST_PLATFORM_VERSION = PlatformVersionWASM.PLATFORM_V13;
13
+ export declare const LATEST_PLATFORM_VERSION = PlatformVersionWASM.PLATFORM_V14;
package/src/constants.js CHANGED
@@ -10,4 +10,4 @@ export const MAINNET_ACTIVATION_HEIGHT = 2128896;
10
10
  export const GRPC_DEFAULT_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hbGl6ZWRMYWJlbCArICcuJyArIG5vcm1hbGl6ZWRQYXJlbnREb21haW4gbXVzdCBub3QgYmUgbG9uZ2VyIHRoYW4gMjUzIGNoYXJzIGxlbmd0aCBhcyBkZWZpbmVkIGJ5IFJGQyAxMDM1LiBEb21haW4gZG9jdW1lbnRzIGFyZSBpbW11dGFibGU6IG1vZGlmaWNhdGlvbiBhbmQgZGVsZXRpb24gYXJlIHJlc3RyaWN0ZWQIcHJlb3JkZXIWCBIQZG9jdW1lbnRzTXV0YWJsZRMAEgxjYW5CZURlbGV0ZWQTARIEdHlwZRIGb2JqZWN0EgdpbmRpY2VzFQEWAxIEbmFtZRIKc2FsdGVkSGFzaBIKcHJvcGVydGllcxUBFgESEHNhbHRlZERvbWFpbkhhc2gSA2FzYxIGdW5pcXVlEwESCnByb3BlcnRpZXMWARIQc2FsdGVkRG9tYWluSGFzaBYGEgR0eXBlEgVhcnJheRIJYnl0ZUFycmF5EwESCG1pbkl0ZW1zAiASCG1heEl0ZW1zAiASCHBvc2l0aW9uAgASC2Rlc2NyaXB0aW9uEllEb3VibGUgc2hhLTI1NiBvZiB0aGUgY29uY2F0ZW5hdGlvbiBvZiBhIDMyIGJ5dGUgcmFuZG9tIHNhbHQgYW5kIGEgbm9ybWFsaXplZCBkb21haW4gbmFtZRIIcmVxdWlyZWQVARIQc2FsdGVkRG9tYWluSGFzaBIUYWRkaXRpb25hbFByb3BlcnRpZXMTABIIJGNvbW1lbnQSSlByZW9yZGVyIGRvY3VtZW50cyBhcmUgaW1tdXRhYmxlOiBtb2RpZmljYXRpb24gYW5kIGRlbGV0aW9uIGFyZSByZXN0cmljdGVkAAAAAAAAAAAAAA==';
13
- export const LATEST_PLATFORM_VERSION = PlatformVersionWASM.PLATFORM_V13;
13
+ export const LATEST_PLATFORM_VERSION = PlatformVersionWASM.PLATFORM_V14;
@@ -27,7 +27,7 @@ export default async function getContestedResourceVoteState(grpcPool, contract,
27
27
  }
28
28
  }
29
29
  });
30
- const { response } = await grpcPool.getClient().getContestedResourceVoteState(getContestedResourceVoteStateRequest);
30
+ const { response } = await (await grpcPool.getClient()).getContestedResourceVoteState(getContestedResourceVoteStateRequest);
31
31
  const { version } = response;
32
32
  if (version.oneofKind !== 'v0') {
33
33
  throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
@@ -18,7 +18,7 @@ export default async function getByIdentifier(grpcPool, identifier) {
18
18
  }
19
19
  }
20
20
  });
21
- const { response } = await grpcPool.getClient().getDataContract(getDataContractRequest);
21
+ const { response } = await (await grpcPool.getClient()).getDataContract(getDataContractRequest);
22
22
  const { version } = response;
23
23
  if (version.oneofKind !== 'v0') {
24
24
  throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
@@ -1,3 +1,3 @@
1
1
  import { DocumentWASM, StateTransitionWASM } from 'pshenmic-dpp';
2
- import { DocumentTransitionParams } from '../../types.js';
3
- export default function createStateTransition(document: DocumentWASM, type: 'create' | 'replace' | 'delete' | 'updatePrice' | 'transfer' | 'purchase', params: DocumentTransitionParams): StateTransitionWASM;
2
+ import { DocumentTransitionParams, DocumentTransitionType } from '../../types.js';
3
+ export default function createStateTransition(document: DocumentWASM, type: DocumentTransitionType, params: DocumentTransitionParams): StateTransitionWASM;
@@ -3,32 +3,32 @@ const documentTransitionsMap = {
3
3
  create: {
4
4
  class: DocumentCreateTransitionWASM,
5
5
  arguments: ['identityContractNonce'],
6
- optionalArguments: ['prefundedVotingBalance', 'tokenPaymentInfo']
6
+ optionalArguments: ['prefundedVotingBalance', 'tokenPaymentInfo', 'actionFeeAgreement']
7
7
  },
8
8
  replace: {
9
9
  class: DocumentReplaceTransitionWASM,
10
10
  arguments: ['identityContractNonce'],
11
- optionalArguments: ['tokenPaymentInfo']
11
+ optionalArguments: ['tokenPaymentInfo', 'actionFeeAgreement']
12
12
  },
13
13
  delete: {
14
14
  class: DocumentDeleteTransitionWASM,
15
15
  arguments: ['identityContractNonce'],
16
- optionalArguments: ['tokenPaymentInfo']
16
+ optionalArguments: ['tokenPaymentInfo', 'actionFeeAgreement']
17
17
  },
18
18
  updatePrice: {
19
19
  class: DocumentUpdatePriceTransitionWASM,
20
20
  arguments: ['identityContractNonce', 'price'],
21
- optionalArguments: ['tokenPaymentInfo']
21
+ optionalArguments: ['tokenPaymentInfo', 'actionFeeAgreement']
22
22
  },
23
23
  transfer: {
24
24
  class: DocumentTransferTransitionWASM,
25
25
  arguments: ['identityContractNonce', 'recipientId'],
26
- optionalArguments: ['tokenPaymentInfo']
26
+ optionalArguments: ['tokenPaymentInfo', 'actionFeeAgreement']
27
27
  },
28
28
  purchase: {
29
29
  class: DocumentPurchaseTransitionWASM,
30
30
  arguments: ['identityContractNonce', 'amount'],
31
- optionalArguments: ['tokenPaymentInfo']
31
+ optionalArguments: ['tokenPaymentInfo', 'actionFeeAgreement']
32
32
  }
33
33
  };
34
34
  export default function createStateTransition(document, type, params) {
@@ -0,0 +1,4 @@
1
+ import { DocumentActionFeeAgreementWASM, IdentifierLike } from 'pshenmic-dpp';
2
+ import { GRPCPool } from '../grpcConnectionPool.js';
3
+ import { DocumentTransitionType } from '../../types.js';
4
+ export default function getActionFeeAgreement(grpcPool: GRPCPool, dataContractId: IdentifierLike, documentTypeName: string, action: DocumentTransitionType, increaseTolerancePercent: number): Promise<DocumentActionFeeAgreementWASM | undefined>;
@@ -0,0 +1,21 @@
1
+ import { AgreedFeeMultiplierWASM, DocumentActionFeeAgreementWASM } from 'pshenmic-dpp';
2
+ import getDataContractByIdentifier from '../dataContracts/getDataContractByIdentifier.js';
3
+ import getEpochsInfo from '../node/epochInfos.js';
4
+ const BATCH_TYPES = {
5
+ create: 'Create',
6
+ replace: 'Replace',
7
+ delete: 'Delete',
8
+ updatePrice: 'UpdatePrice',
9
+ transfer: 'Transfer',
10
+ purchase: 'Purchase'
11
+ };
12
+ export default async function getActionFeeAgreement(grpcPool, dataContractId, documentTypeName, action, increaseTolerancePercent) {
13
+ const dataContract = await getDataContractByIdentifier(grpcPool, dataContractId);
14
+ // the current epoch: descending from the latest one
15
+ const [currentEpoch] = await getEpochsInfo(grpcPool, 1, false);
16
+ if (currentEpoch == null) {
17
+ throw new Error('Current epoch not found');
18
+ }
19
+ const feeMultiplier = new AgreedFeeMultiplierWASM(currentEpoch.feeMultiplier, increaseTolerancePercent);
20
+ return DocumentActionFeeAgreementWASM.forDocumentTypeAction(dataContract, documentTypeName, BATCH_TYPES[action], feeMultiplier);
21
+ }
@@ -1,6 +1,7 @@
1
- import { DocumentTransitionParams } from '../../types.js';
2
- import { DocumentWASM, IdentifierLike, IdentifierWASM, StateTransitionWASM, WhereClause } from 'pshenmic-dpp';
1
+ import { DocumentTransitionParams, DocumentTransitionType } from '../../types.js';
2
+ import { AggregateDocumentsQuery, AggregateProofQuery, CompositeSubQuery, DocumentActionFeeAgreementWASM, DocumentsQuery, DocumentWASM, HavingClause, IdentifierLike, IdentifierWASM, ProvenAggregate, ProvenRankedEntry, ProvenRankedPage, StateTransitionWASM, WhereClause } from 'pshenmic-dpp';
3
3
  import { GRPCPool } from '../grpcConnectionPool.js';
4
+ import { ChainedDocuments, CompositeDocuments } from './queryJoined.js';
4
5
  /**
5
6
  * Collection of methods to work with documents like creation, querying or preparing a transition action
6
7
  *
@@ -34,6 +35,84 @@ export declare class DocumentsController {
34
35
  * @param startAfter {IdentifierLike=} Same as previous, but with exclusion. Cannot be set if startAt already provided
35
36
  */
36
37
  query(dataContractId: IdentifierLike, documentType: string, where?: WhereClause[], orderBy?: string[][], limit?: number, startAt?: IdentifierWASM, startAfter?: IdentifierWASM): Promise<DocumentWASM[]>;
38
+ /**
39
+ * Counts documents matching a query. Without `groupBy` returns one entry with the total,
40
+ * with `groupBy` one entry per group
41
+ *
42
+ * @param dataContractId {IdentifierLike} Identifier of the Data Contract
43
+ * @param query {AggregateProofQuery} documentTypeName, where, orderBy, groupBy and limit of the query
44
+ *
45
+ * @return {Promise<ProvenAggregate>}
46
+ */
47
+ count(dataContractId: IdentifierLike, query: AggregateProofQuery): Promise<ProvenAggregate>;
48
+ /**
49
+ * Sums a field over documents matching a query. Without `groupBy` returns one entry with the total,
50
+ * with `groupBy` one entry per group
51
+ *
52
+ * @param dataContractId {IdentifierLike} Identifier of the Data Contract
53
+ * @param query {AggregateProofQuery} documentTypeName, where, orderBy, groupBy and limit of the query
54
+ * @param field {string} Integer field to sum
55
+ *
56
+ * @return {Promise<ProvenAggregate>}
57
+ */
58
+ sum(dataContractId: IdentifierLike, query: AggregateProofQuery, field: string): Promise<ProvenAggregate>;
59
+ /**
60
+ * Averages a field over documents matching a query. Entries carry `count` and `sum`, the average is `sum / count`.
61
+ * Without `groupBy` returns one entry with the total, with `groupBy` one entry per group
62
+ *
63
+ * @param dataContractId {IdentifierLike} Identifier of the Data Contract
64
+ * @param query {AggregateProofQuery} documentTypeName, where, orderBy, groupBy and limit of the query
65
+ * @param field {string} Integer field to average
66
+ *
67
+ * @return {Promise<ProvenAggregate>}
68
+ */
69
+ average(dataContractId: IdentifierLike, query: AggregateProofQuery, field: string): Promise<ProvenAggregate>;
70
+ /**
71
+ * Top-K query: groups of `groupBy` ranked by the selected aggregate. Order by the selected field,
72
+ * or by `$count` for count, e.g. `orderBy: [['$count', 'desc']]`. Supports `limit` and `offset`
73
+ *
74
+ * @param dataContractId {IdentifierLike} Identifier of the Data Contract
75
+ * @param query {AggregateDocumentsQuery} documentTypeName, select, groupBy, where, orderBy, limit and offset of the query
76
+ *
77
+ * @return {Promise<ProvenRankedPage>}
78
+ */
79
+ ranked(dataContractId: IdentifierLike, query: AggregateDocumentsQuery): Promise<ProvenRankedPage>;
80
+ /**
81
+ * Having query: groups of `groupBy` whose aggregate falls within the `having` bounds
82
+ *
83
+ * @param dataContractId {IdentifierLike} Identifier of the Data Contract
84
+ * @param query {AggregateDocumentsQuery & { having: HavingClause[] }} ranked query with having clauses
85
+ *
86
+ * @return {Promise<ProvenRankedEntry[]>}
87
+ */
88
+ having(dataContractId: IdentifierLike, query: AggregateDocumentsQuery & {
89
+ having: HavingClause[];
90
+ }): Promise<ProvenRankedEntry[]>;
91
+ /**
92
+ * Chained join: documents of the query, then the documents of `outerDocumentType`
93
+ * their `joinProperty` refers to
94
+ *
95
+ * @param dataContractId {IdentifierLike} Identifier of the Data Contract
96
+ * @param query {DocumentsQuery} documentTypeName, where, orderBy, limit, startAt and startAtIncluded of the inner query
97
+ * @param joinProperty {string} Property of the inner documents referring to the outer documents
98
+ * @param outerDocumentType {string} Document type of the outer documents
99
+ *
100
+ * @return {Promise<ChainedDocuments>}
101
+ */
102
+ chained(dataContractId: IdentifierLike, query: DocumentsQuery, joinProperty: string, outerDocumentType: string): Promise<ChainedDocuments>;
103
+ /**
104
+ * Composite query: a page of documents plus up to 10 sub-queries, each optionally bound
105
+ * to values the page or an earlier sub-query proved
106
+ *
107
+ * @param dataContractId {IdentifierLike} Identifier of the Data Contract
108
+ * @param query {DocumentsQuery & { offset?: number }} page query
109
+ * @param subQueries {CompositeSubQuery[]} sub-queries, `binding.source` is `'page'` or an index of an earlier sub-query
110
+ *
111
+ * @return {Promise<CompositeDocuments>}
112
+ */
113
+ composite(dataContractId: IdentifierLike, query: DocumentsQuery & {
114
+ offset?: number;
115
+ }, subQueries: CompositeSubQuery[]): Promise<CompositeDocuments>;
37
116
  /**
38
117
  * Helper function for creating {StateTransitionWASM} from documents. It may be used to create any of 6 Document Transition actions:
39
118
  *
@@ -48,5 +127,20 @@ export declare class DocumentsController {
48
127
  * @param type {string} Type of the document transition, must be a one of ('create' | 'replace' | 'delete' | 'updatePrice' |'transfer' | 'purchase')
49
128
  * @param params {DocumentTransitionParams} params
50
129
  */
51
- createStateTransition(document: DocumentWASM, type: 'create' | 'replace' | 'delete' | 'updatePrice' | 'transfer' | 'purchase', params: DocumentTransitionParams): StateTransitionWASM;
130
+ createStateTransition(document: DocumentWASM, type: DocumentTransitionType, params: DocumentTransitionParams): StateTransitionWASM;
131
+ /**
132
+ * Builds the action fee agreement a document transition must carry when its document type declares
133
+ * `actionFees` for the action (protocol v14): the fee parts the contract declares and the fee multiplier
134
+ * of the current epoch. Pass it as `actionFeeAgreement` to {@link createStateTransition}.
135
+ * Returns undefined when the action charges no fee
136
+ *
137
+ * @param dataContractId {IdentifierLike} Identifier of the Data Contract
138
+ * @param documentType {string} Document type of the data contract
139
+ * @param action {string} Type of the document transition ('create' | 'replace' | 'delete' | 'updatePrice' | 'transfer' | 'purchase')
140
+ * @param increaseTolerancePercent {number=} How far the fee multiplier may grow before execution, in percent (defaults to 0).
141
+ * The network refuses the transition when the multiplier of the executing epoch is higher
142
+ *
143
+ * @return {Promise<DocumentActionFeeAgreementWASM | undefined>}
144
+ */
145
+ getActionFeeAgreement(dataContractId: IdentifierLike, documentType: string, action: DocumentTransitionType, increaseTolerancePercent?: number): Promise<DocumentActionFeeAgreementWASM | undefined>;
52
146
  }
@@ -1,7 +1,11 @@
1
1
  import createDocument from './create.js';
2
- import { IdentifierWASM, PrefundedVotingBalanceWASM, TokenPaymentInfoWASM } from 'pshenmic-dpp';
2
+ import { AgreedFeeMultiplierWASM, DocumentActionFeeAgreementWASM, IdentifierWASM, PrefundedVotingBalanceWASM, TokenPaymentInfoWASM } from 'pshenmic-dpp';
3
3
  import createStateTransition from './createStateTransition.js';
4
4
  import query from './query.js';
5
+ import getActionFeeAgreement from './getActionFeeAgreement.js';
6
+ import queryAggregate from './queryAggregate.js';
7
+ import { queryHaving, queryRanked } from './queryRanked.js';
8
+ import { queryChained, queryComposite } from './queryJoined.js';
5
9
  /**
6
10
  * Collection of methods to work with documents like creation, querying or preparing a transition action
7
11
  *
@@ -44,6 +48,94 @@ export class DocumentsController {
44
48
  }
45
49
  return await query(this.grpcPool, new IdentifierWASM(dataContractId), documentType, where, orderBy, limit ?? 100, startAt, startAfter);
46
50
  }
51
+ /**
52
+ * Counts documents matching a query. Without `groupBy` returns one entry with the total,
53
+ * with `groupBy` one entry per group
54
+ *
55
+ * @param dataContractId {IdentifierLike} Identifier of the Data Contract
56
+ * @param query {AggregateProofQuery} documentTypeName, where, orderBy, groupBy and limit of the query
57
+ *
58
+ * @return {Promise<ProvenAggregate>}
59
+ */
60
+ async count(dataContractId, query) {
61
+ return await queryAggregate(this.grpcPool, dataContractId, 'count', query);
62
+ }
63
+ /**
64
+ * Sums a field over documents matching a query. Without `groupBy` returns one entry with the total,
65
+ * with `groupBy` one entry per group
66
+ *
67
+ * @param dataContractId {IdentifierLike} Identifier of the Data Contract
68
+ * @param query {AggregateProofQuery} documentTypeName, where, orderBy, groupBy and limit of the query
69
+ * @param field {string} Integer field to sum
70
+ *
71
+ * @return {Promise<ProvenAggregate>}
72
+ */
73
+ async sum(dataContractId, query, field) {
74
+ return await queryAggregate(this.grpcPool, dataContractId, 'sum', query, field);
75
+ }
76
+ /**
77
+ * Averages a field over documents matching a query. Entries carry `count` and `sum`, the average is `sum / count`.
78
+ * Without `groupBy` returns one entry with the total, with `groupBy` one entry per group
79
+ *
80
+ * @param dataContractId {IdentifierLike} Identifier of the Data Contract
81
+ * @param query {AggregateProofQuery} documentTypeName, where, orderBy, groupBy and limit of the query
82
+ * @param field {string} Integer field to average
83
+ *
84
+ * @return {Promise<ProvenAggregate>}
85
+ */
86
+ async average(dataContractId, query, field) {
87
+ return await queryAggregate(this.grpcPool, dataContractId, 'avg', query, field);
88
+ }
89
+ /**
90
+ * Top-K query: groups of `groupBy` ranked by the selected aggregate. Order by the selected field,
91
+ * or by `$count` for count, e.g. `orderBy: [['$count', 'desc']]`. Supports `limit` and `offset`
92
+ *
93
+ * @param dataContractId {IdentifierLike} Identifier of the Data Contract
94
+ * @param query {AggregateDocumentsQuery} documentTypeName, select, groupBy, where, orderBy, limit and offset of the query
95
+ *
96
+ * @return {Promise<ProvenRankedPage>}
97
+ */
98
+ async ranked(dataContractId, query) {
99
+ return await queryRanked(this.grpcPool, dataContractId, query);
100
+ }
101
+ /**
102
+ * Having query: groups of `groupBy` whose aggregate falls within the `having` bounds
103
+ *
104
+ * @param dataContractId {IdentifierLike} Identifier of the Data Contract
105
+ * @param query {AggregateDocumentsQuery & { having: HavingClause[] }} ranked query with having clauses
106
+ *
107
+ * @return {Promise<ProvenRankedEntry[]>}
108
+ */
109
+ async having(dataContractId, query) {
110
+ return await queryHaving(this.grpcPool, dataContractId, query);
111
+ }
112
+ /**
113
+ * Chained join: documents of the query, then the documents of `outerDocumentType`
114
+ * their `joinProperty` refers to
115
+ *
116
+ * @param dataContractId {IdentifierLike} Identifier of the Data Contract
117
+ * @param query {DocumentsQuery} documentTypeName, where, orderBy, limit, startAt and startAtIncluded of the inner query
118
+ * @param joinProperty {string} Property of the inner documents referring to the outer documents
119
+ * @param outerDocumentType {string} Document type of the outer documents
120
+ *
121
+ * @return {Promise<ChainedDocuments>}
122
+ */
123
+ async chained(dataContractId, query, joinProperty, outerDocumentType) {
124
+ return await queryChained(this.grpcPool, dataContractId, query, joinProperty, outerDocumentType);
125
+ }
126
+ /**
127
+ * Composite query: a page of documents plus up to 10 sub-queries, each optionally bound
128
+ * to values the page or an earlier sub-query proved
129
+ *
130
+ * @param dataContractId {IdentifierLike} Identifier of the Data Contract
131
+ * @param query {DocumentsQuery & { offset?: number }} page query
132
+ * @param subQueries {CompositeSubQuery[]} sub-queries, `binding.source` is `'page'` or an index of an earlier sub-query
133
+ *
134
+ * @return {Promise<CompositeDocuments>}
135
+ */
136
+ async composite(dataContractId, query, subQueries) {
137
+ return await queryComposite(this.grpcPool, dataContractId, query, subQueries);
138
+ }
47
139
  /**
48
140
  * Helper function for creating {StateTransitionWASM} from documents. It may be used to create any of 6 Document Transition actions:
49
141
  *
@@ -78,6 +170,27 @@ export class DocumentsController {
78
170
  // @ts-expect-error
79
171
  params.tokenPaymentInfo = new TokenPaymentInfoWASM(new IdentifierWASM(tokenContractId), tokenContractPosition, minimumTokenCost, maximumTokenCost, gasFeesPaidBy);
80
172
  }
173
+ if (params.actionFeeAgreement != null && !(params.actionFeeAgreement instanceof DocumentActionFeeAgreementWASM)) {
174
+ const { owner, moderators, feeMultiplier } = params.actionFeeAgreement;
175
+ params.actionFeeAgreement = new DocumentActionFeeAgreementWASM(owner, moderators, feeMultiplier != null ? new AgreedFeeMultiplierWASM(feeMultiplier.knownPermille, feeMultiplier.increaseTolerancePercent) : undefined);
176
+ }
81
177
  return createStateTransition(document, type, params);
82
178
  }
179
+ /**
180
+ * Builds the action fee agreement a document transition must carry when its document type declares
181
+ * `actionFees` for the action (protocol v14): the fee parts the contract declares and the fee multiplier
182
+ * of the current epoch. Pass it as `actionFeeAgreement` to {@link createStateTransition}.
183
+ * Returns undefined when the action charges no fee
184
+ *
185
+ * @param dataContractId {IdentifierLike} Identifier of the Data Contract
186
+ * @param documentType {string} Document type of the data contract
187
+ * @param action {string} Type of the document transition ('create' | 'replace' | 'delete' | 'updatePrice' | 'transfer' | 'purchase')
188
+ * @param increaseTolerancePercent {number=} How far the fee multiplier may grow before execution, in percent (defaults to 0).
189
+ * The network refuses the transition when the multiplier of the executing epoch is higher
190
+ *
191
+ * @return {Promise<DocumentActionFeeAgreementWASM | undefined>}
192
+ */
193
+ async getActionFeeAgreement(dataContractId, documentType, action, increaseTolerancePercent) {
194
+ return await getActionFeeAgreement(this.grpcPool, dataContractId, documentType, action, increaseTolerancePercent ?? 0);
195
+ }
83
196
  }
@@ -1,60 +1,21 @@
1
- import { GetDocumentsRequest } from '../../proto/generated/platform.js';
2
1
  import { IdentifierWASM, verifyDocumentsProof } from 'pshenmic-dpp';
3
2
  import { DAPI_DEFAULT_LIMIT, LATEST_PLATFORM_VERSION } from '../constants.js';
4
- import { getQuorumPublicKey } from '../utils/getQuorumPublicKey.js';
5
- import bytesToHex from '../utils/bytesToHex.js';
6
- import verifyTenderdashProof from '../utils/verifyTenderdashProof.js';
7
- import { encode } from 'cbor2';
8
3
  import getDataContractByIdentifier from '../dataContracts/getDataContractByIdentifier.js';
4
+ import { getDocumentsV1Proof, toOrderClauses, toStart, toWhereClauses, verifyDocumentsV1Signature } from './v1.js';
9
5
  export default async function query(grpcPool, dataContractId, documentTypeName, where, orderBy, limit = 100, startAt, startAfter) {
10
- let start;
11
- if (startAt != null) {
12
- start = {
13
- oneofKind: 'startAt',
14
- startAt: startAt.bytes()
15
- };
16
- }
17
- if (startAfter != null) {
18
- start = {
19
- oneofKind: 'startAfter',
20
- startAfter: startAfter.bytes()
21
- };
22
- }
23
- const getDocumentsRequest = GetDocumentsRequest.create({
24
- version: {
25
- oneofKind: 'v0',
26
- v0: {
27
- dataContractId: (new IdentifierWASM(dataContractId)).bytes(),
28
- documentType: documentTypeName,
29
- where: encode(where),
30
- orderBy: encode(orderBy),
31
- limit: limit ?? DAPI_DEFAULT_LIMIT,
32
- start,
33
- prove: true
34
- }
35
- }
36
- });
37
6
  const dataContract = await getDataContractByIdentifier(grpcPool, dataContractId);
38
- const { response } = await grpcPool.getClient().getDocuments(getDocumentsRequest);
39
- const { version } = response;
40
- if (version.oneofKind !== 'v0') {
41
- throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
42
- }
43
- const { v0 } = version;
44
- if (v0.result.oneofKind !== 'proof') {
45
- throw new Error('Unexpected oneOf type returned from DAPI (must be proof)');
46
- }
47
- const { result: { proof }, metadata } = v0;
48
- if (metadata == null) {
49
- throw new Error('Metadata not found');
50
- }
51
- const startAtIncluded = startAt != null;
52
7
  const startIdentifier = startAt ?? startAfter;
53
- const { rootHash, documents } = verifyDocumentsProof(proof.grovedbProof, dataContract, documentTypeName, where, orderBy, limit, startIdentifier?.bytes(), startAtIncluded, BigInt(metadata?.timeMs), LATEST_PLATFORM_VERSION);
54
- const quorumPublicKey = await getQuorumPublicKey(grpcPool.network, proof.quorumType, bytesToHex(proof.quorumHash));
55
- const verify = await verifyTenderdashProof(proof, metadata, rootHash, quorumPublicKey);
56
- if (!verify) {
57
- throw new Error('Failed to verify query');
58
- }
8
+ const startAtIncluded = startAt != null;
9
+ const { proof, metadata } = await getDocumentsV1Proof(grpcPool, {
10
+ dataContractId: (new IdentifierWASM(dataContractId)).bytes(),
11
+ documentType: documentTypeName,
12
+ whereClauses: toWhereClauses(where),
13
+ orderBy: toOrderClauses(orderBy),
14
+ limit: limit ?? DAPI_DEFAULT_LIMIT,
15
+ start: toStart(startIdentifier, startAtIncluded)
16
+ });
17
+ const metadataTimeMs = BigInt(metadata.timeMs);
18
+ const { rootHash, documents } = verifyDocumentsProof(proof.grovedbProof, dataContract, documentTypeName, where, orderBy, limit, startIdentifier?.bytes(), startAtIncluded, metadataTimeMs, LATEST_PLATFORM_VERSION, metadataTimeMs);
19
+ await verifyDocumentsV1Signature(grpcPool, proof, metadata, rootHash);
59
20
  return documents ?? [];
60
21
  }
@@ -0,0 +1,4 @@
1
+ import { AggregateProofQuery, IdentifierLike, ProvenAggregate } from 'pshenmic-dpp';
2
+ import { GRPCPool } from '../grpcConnectionPool.js';
3
+ export type DocumentsAggregateFunction = 'count' | 'sum' | 'avg';
4
+ export default function queryAggregate(grpcPool: GRPCPool, dataContractId: IdentifierLike, aggregateFunction: DocumentsAggregateFunction, query: AggregateProofQuery, field?: string): Promise<ProvenAggregate>;
@@ -0,0 +1,32 @@
1
+ import { IdentifierWASM, verifyDocumentsAverageProof, verifyDocumentsCountProof, verifyDocumentsSumProof } from 'pshenmic-dpp';
2
+ import { LATEST_PLATFORM_VERSION } from '../constants.js';
3
+ import getDataContractByIdentifier from '../dataContracts/getDataContractByIdentifier.js';
4
+ import { getDocumentsV1Proof, toOrderClauses, toSelect, toWhereClauses, verifyDocumentsV1Signature } from './v1.js';
5
+ export default async function queryAggregate(grpcPool, dataContractId, aggregateFunction, query, field) {
6
+ if (aggregateFunction !== 'count' && field == null) {
7
+ throw new Error(`Field is required for ${aggregateFunction} query`);
8
+ }
9
+ const dataContract = await getDataContractByIdentifier(grpcPool, dataContractId);
10
+ const { proof, metadata } = await getDocumentsV1Proof(grpcPool, {
11
+ dataContractId: (new IdentifierWASM(dataContractId)).bytes(),
12
+ documentType: query.documentTypeName,
13
+ whereClauses: toWhereClauses(query.where),
14
+ orderBy: toOrderClauses(query.orderBy),
15
+ limit: query.limit,
16
+ selects: toSelect({ function: aggregateFunction, field }),
17
+ groupBy: query.groupBy ?? []
18
+ });
19
+ const metadataTimeMs = BigInt(metadata.timeMs);
20
+ let verified;
21
+ if (aggregateFunction === 'count') {
22
+ verified = verifyDocumentsCountProof(proof.grovedbProof, dataContract, query, LATEST_PLATFORM_VERSION, metadataTimeMs);
23
+ }
24
+ else if (aggregateFunction === 'sum') {
25
+ verified = verifyDocumentsSumProof(proof.grovedbProof, dataContract, query, field, LATEST_PLATFORM_VERSION, metadataTimeMs);
26
+ }
27
+ else {
28
+ verified = verifyDocumentsAverageProof(proof.grovedbProof, dataContract, query, field, LATEST_PLATFORM_VERSION, metadataTimeMs);
29
+ }
30
+ await verifyDocumentsV1Signature(grpcPool, proof, metadata, verified.rootHash);
31
+ return verified.value;
32
+ }
@@ -0,0 +1,16 @@
1
+ import { CompositeSubQuery, DocumentsQuery, IdentifierLike, VerifiedChainedDocuments, VerifiedCompositeDocuments } from 'pshenmic-dpp';
2
+ import { GRPCPool } from '../grpcConnectionPool.js';
3
+ export type ChainedDocuments = Omit<VerifiedChainedDocuments, 'rootHash'>;
4
+ export type CompositeDocuments = Omit<VerifiedCompositeDocuments, 'rootHash'>;
5
+ /**
6
+ * Chained join: documents of `query`, then the documents of `outerDocumentTypeName`
7
+ * their `joinProperty` refers to
8
+ */
9
+ export declare function queryChained(grpcPool: GRPCPool, dataContractId: IdentifierLike, query: DocumentsQuery, joinProperty: string, outerDocumentTypeName: string): Promise<ChainedDocuments>;
10
+ /**
11
+ * Composite query: a page of documents plus up to 10 sub-queries, each optionally bound
12
+ * to values the page or an earlier sub-query proved
13
+ */
14
+ export declare function queryComposite(grpcPool: GRPCPool, dataContractId: IdentifierLike, query: DocumentsQuery & {
15
+ offset?: number;
16
+ }, subQueries: CompositeSubQuery[]): Promise<CompositeDocuments>;
@@ -0,0 +1,44 @@
1
+ import { IdentifierWASM, verifyChainedDocumentsProof, verifyCompositeDocumentsProof } from 'pshenmic-dpp';
2
+ import { LATEST_PLATFORM_VERSION } from '../constants.js';
3
+ import getDataContractByIdentifier from '../dataContracts/getDataContractByIdentifier.js';
4
+ import { getDocumentsV1Proof, toOrderClauses, toStart, toSubQueries, toWhereClauses, verifyDocumentsV1Signature } from './v1.js';
5
+ /**
6
+ * Chained join: documents of `query`, then the documents of `outerDocumentTypeName`
7
+ * their `joinProperty` refers to
8
+ */
9
+ export async function queryChained(grpcPool, dataContractId, query, joinProperty, outerDocumentTypeName) {
10
+ const dataContract = await getDataContractByIdentifier(grpcPool, dataContractId);
11
+ const { proof, metadata } = await getDocumentsV1Proof(grpcPool, {
12
+ dataContractId: (new IdentifierWASM(dataContractId)).bytes(),
13
+ documentType: query.documentTypeName,
14
+ whereClauses: toWhereClauses(query.where),
15
+ orderBy: toOrderClauses(query.orderBy),
16
+ limit: query.limit,
17
+ start: toStart(query.startAt, query.startAtIncluded),
18
+ chained: { joinProperty, outerDocumentType: outerDocumentTypeName }
19
+ });
20
+ const { rootHash, ...result } = verifyChainedDocumentsProof(proof.grovedbProof, dataContract, query, joinProperty, outerDocumentTypeName, LATEST_PLATFORM_VERSION);
21
+ await verifyDocumentsV1Signature(grpcPool, proof, metadata, rootHash);
22
+ return result;
23
+ }
24
+ /**
25
+ * Composite query: a page of documents plus up to 10 sub-queries, each optionally bound
26
+ * to values the page or an earlier sub-query proved
27
+ */
28
+ export async function queryComposite(grpcPool, dataContractId, query, subQueries) {
29
+ const dataContract = await getDataContractByIdentifier(grpcPool, dataContractId);
30
+ const identifier = new IdentifierWASM(dataContractId);
31
+ const { proof, metadata } = await getDocumentsV1Proof(grpcPool, {
32
+ dataContractId: identifier.bytes(),
33
+ documentType: query.documentTypeName,
34
+ whereClauses: toWhereClauses(query.where),
35
+ orderBy: toOrderClauses(query.orderBy),
36
+ limit: query.limit,
37
+ offset: query.offset,
38
+ start: toStart(query.startAt, query.startAtIncluded),
39
+ subQueries: toSubQueries(subQueries, identifier)
40
+ });
41
+ const { rootHash, ...result } = verifyCompositeDocumentsProof(proof.grovedbProof, dataContract, query, subQueries, LATEST_PLATFORM_VERSION);
42
+ await verifyDocumentsV1Signature(grpcPool, proof, metadata, rootHash);
43
+ return result;
44
+ }
@@ -0,0 +1,12 @@
1
+ import { AggregateDocumentsQuery, HavingClause, IdentifierLike, ProvenRankedEntry, ProvenRankedPage } from 'pshenmic-dpp';
2
+ import { GRPCPool } from '../grpcConnectionPool.js';
3
+ /**
4
+ * Top-K query: groups of `groupBy` ranked by the selected aggregate in the order `orderBy` names
5
+ */
6
+ export declare function queryRanked(grpcPool: GRPCPool, dataContractId: IdentifierLike, query: AggregateDocumentsQuery): Promise<ProvenRankedPage>;
7
+ /**
8
+ * Having query: groups of `groupBy` whose aggregate falls within the `having` bounds
9
+ */
10
+ export declare function queryHaving(grpcPool: GRPCPool, dataContractId: IdentifierLike, query: AggregateDocumentsQuery & {
11
+ having: HavingClause[];
12
+ }): Promise<ProvenRankedEntry[]>;