dash-platform-sdk 1.5.3 → 1.6.0-dev.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.
Files changed (60) 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/constants.d.ts +1 -1
  9. package/src/constants.js +1 -1
  10. package/src/documents/create.d.ts +1 -1
  11. package/src/documents/create.js +2 -2
  12. package/src/documents/createStateTransition.d.ts +2 -2
  13. package/src/documents/createStateTransition.js +6 -6
  14. package/src/documents/getActionFeeAgreement.d.ts +4 -0
  15. package/src/documents/getActionFeeAgreement.js +21 -0
  16. package/src/documents/index.d.ts +99 -4
  17. package/src/documents/index.js +117 -3
  18. package/src/documents/query.js +13 -52
  19. package/src/documents/queryAggregate.d.ts +4 -0
  20. package/src/documents/queryAggregate.js +32 -0
  21. package/src/documents/queryJoined.d.ts +16 -0
  22. package/src/documents/queryJoined.js +44 -0
  23. package/src/documents/queryRanked.d.ts +12 -0
  24. package/src/documents/queryRanked.js +37 -0
  25. package/src/documents/v1.d.ts +33 -0
  26. package/src/documents/v1.js +233 -0
  27. package/src/identities/getIdentityByNonUniquePublicKeyHash.js +6 -10
  28. package/src/names/index.d.ts +4 -1
  29. package/src/names/index.js +5 -2
  30. package/src/names/registerName.d.ts +1 -1
  31. package/src/names/registerName.js +55 -35
  32. package/src/shielded/getMostRecentShieldedAnchor.d.ts +2 -1
  33. package/src/shielded/getMostRecentShieldedAnchor.js +6 -4
  34. package/src/shielded/getShieldedAnchors.d.ts +2 -1
  35. package/src/shielded/getShieldedAnchors.js +6 -4
  36. package/src/shielded/getShieldedEncryptedNotes.d.ts +2 -1
  37. package/src/shielded/getShieldedEncryptedNotes.js +6 -4
  38. package/src/shielded/getShieldedNotesCount.d.ts +2 -1
  39. package/src/shielded/getShieldedNotesCount.js +6 -4
  40. package/src/shielded/getShieldedNullifiers.d.ts +2 -1
  41. package/src/shielded/getShieldedNullifiers.js +6 -4
  42. package/src/shielded/getShieldedPoolState.d.ts +2 -1
  43. package/src/shielded/getShieldedPoolState.js +6 -4
  44. package/src/shielded/index.d.ts +17 -7
  45. package/src/shielded/index.js +22 -12
  46. package/src/stateTransitions/index.d.ts +6 -2
  47. package/src/stateTransitions/index.js +5 -1
  48. package/src/stateTransitions/waitForStateTransitionResult.d.ts +1 -1
  49. package/src/stateTransitions/waitForStateTransitionResult.js +4 -2
  50. package/test/unit/DataContract.spec.js +2 -1
  51. package/test/unit/Document.spec.js +9 -9
  52. package/test/unit/DocumentActionFees.spec.d.ts +1 -0
  53. package/test/unit/DocumentActionFees.spec.js +99 -0
  54. package/test/unit/DocumentQueries.spec.d.ts +1 -0
  55. package/test/unit/DocumentQueries.spec.js +178 -0
  56. package/test/unit/DocumentsV1.spec.d.ts +1 -0
  57. package/test/unit/DocumentsV1.spec.js +75 -0
  58. package/test/unit/Names.spec.js +30 -0
  59. package/test/unit/Node.spec.js +11 -8
  60. package/types.d.ts +20 -1
@@ -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 = "AeZoxlmvZq7h5ywYbd57W34KHXEqCcQNVyH2Ir9TxTFVAAAAAAABAQAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIGZG9tYWluFgsSEGRvY3VtZW50c011dGFibGUTABIMY2FuQmVEZWxldGVkEwESDHRyYW5zZmVyYWJsZQIBEgl0cmFkZU1vZGUCARIEdHlwZRIGb2JqZWN0EgdpbmRpY2VzFQ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IKc2FsdGVkSGFzaBIKcHJvcGVydGllcxUBFgESEHNhbHRlZERvbWFpbkhhc2gSA2FzYxIGdW5pcXVlEwESCnByb3BlcnRpZXMWARIQc2FsdGVkRG9tYWluSGFzaBYGEgR0eXBlEgVhcnJheRIJYnl0ZUFycmF5EwESCG1pbkl0ZW1zAiASCG1heEl0ZW1zAiASCHBvc2l0aW9uAgASC2Rlc2NyaXB0aW9uEllEb3VibGUgc2hhLTI1NiBvZiB0aGUgY29uY2F0ZW5hdGlvbiBvZiBhIDMyIGJ5dGUgcmFuZG9tIHNhbHQgYW5kIGEgbm9ybWFsaXplZCBkb21haW4gbmFtZRIIcmVxdWlyZWQVARIQc2FsdGVkRG9tYWluSGFzaBIUYWRkaXRpb25hbFByb3BlcnRpZXMTABIIJGNvbW1lbnQSSlByZW9yZGVyIGRvY3VtZW50cyBhcmUgaW1tdXRhYmxlOiBtb2RpZmljYXRpb24gYW5kIGRlbGV0aW9uIGFyZSByZXN0cmljdGVkAAAAAAAAAAAAAA==";
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_POOL_LIMIT = 5;
11
11
  export const DPNS_DATA_CONTRACT_ID = 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec';
12
12
  export const DPNS_DATA_CONTRACT_BYTES = 'AeZoxlmvZq7h5ywYbd57W34KHXEqCcQNVyH2Ir9TxTFVAAAAAAABAQAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIGZG9tYWluFgsSEGRvY3VtZW50c011dGFibGUTABIMY2FuQmVEZWxldGVkEwESDHRyYW5zZmVyYWJsZQIBEgl0cmFkZU1vZGUCARIEdHlwZRIGb2JqZWN0Egd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WAxIEbmFtZRIKc2FsdGVkSGFzaBIKcHJvcGVydGllcxUBFgESEHNhbHRlZERvbWFpbkhhc2gSA2FzYxIGdW5pcXVlEwESCnByb3BlcnRpZXMWARIQc2FsdGVkRG9tYWluSGFzaBYGEgR0eXBlEgVhcnJheRIJYnl0ZUFycmF5EwESCG1pbkl0ZW1zAiASCG1heEl0ZW1zAiASCHBvc2l0aW9uAgASC2Rlc2NyaXB0aW9uEllEb3VibGUgc2hhLTI1NiBvZiB0aGUgY29uY2F0ZW5hdGlvbiBvZiBhIDMyIGJ5dGUgcmFuZG9tIHNhbHQgYW5kIGEgbm9ybWFsaXplZCBkb21haW4gbmFtZRIIcmVxdWlyZWQVARIQc2FsdGVkRG9tYWluSGFzaBIUYWRkaXRpb25hbFByb3BlcnRpZXMTABIIJGNvbW1lbnQSSlByZW9yZGVyIGRvY3VtZW50cyBhcmUgaW1tdXRhYmxlOiBtb2RpZmljYXRpb24gYW5kIGRlbGV0aW9uIGFyZSByZXN0cmljdGVkAAAAAAAAAAAAAA==';
13
- export const LATEST_PLATFORM_VERSION = PlatformVersionWASM.PLATFORM_V13;
13
+ export const LATEST_PLATFORM_VERSION = PlatformVersionWASM.PLATFORM_V14;
@@ -1,2 +1,2 @@
1
1
  import { DocumentWASM, IdentifierLike } from 'pshenmic-dpp';
2
- export default function createDocument(dataContractId: IdentifierLike, documentType: string, data: object, owner: IdentifierLike, revision?: bigint, documentId?: IdentifierLike): DocumentWASM;
2
+ export default function createDocument(dataContractId: IdentifierLike, documentType: string, data: object, owner: IdentifierLike, identityContractNonce: bigint, revision?: bigint, documentId?: IdentifierLike): DocumentWASM;
@@ -1,4 +1,4 @@
1
1
  import { DocumentWASM } from 'pshenmic-dpp';
2
- export default function createDocument(dataContractId, documentType, data, owner, revision, documentId) {
3
- return new DocumentWASM(data, documentType, revision ?? BigInt(1), dataContractId, owner, documentId, owner);
2
+ export default function createDocument(dataContractId, documentType, data, owner, identityContractNonce, revision, documentId) {
3
+ return new DocumentWASM(data, documentType, revision ?? BigInt(1), dataContractId, owner, documentId, owner, identityContractNonce);
4
4
  }
@@ -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
  *
@@ -17,11 +18,12 @@ export declare class DocumentsController {
17
18
  * @param documentType {string} Document type as string
18
19
  * @param data {object} Data as JSON object
19
20
  * @param owner {IdentifierLike} Identifier of the document's owner
21
+ * @param identityContractNonce {bigint} Identity contract nonce of the transition that will create the document, used for document id generation
20
22
  * @param revision {bigint=} revision (optional)
21
23
  *
22
24
  * @return {DataContractWASM}
23
25
  */
24
- create(dataContractId: IdentifierLike, documentType: string, data: object, owner: IdentifierLike, revision?: bigint): DocumentWASM;
26
+ create(dataContractId: IdentifierLike, documentType: string, data: object, owner: IdentifierLike, identityContractNonce: bigint, revision?: bigint): DocumentWASM;
25
27
  /**
26
28
  * Make a query for documents retrieval from the network.
27
29
  *
@@ -34,6 +36,84 @@ export declare class DocumentsController {
34
36
  * @param startAfter {IdentifierLike=} Same as previous, but with exclusion. Cannot be set if startAt already provided
35
37
  */
36
38
  query(dataContractId: IdentifierLike, documentType: string, where?: WhereClause[], orderBy?: string[][], limit?: number, startAt?: IdentifierWASM, startAfter?: IdentifierWASM): Promise<DocumentWASM[]>;
39
+ /**
40
+ * Counts documents matching a query. Without `groupBy` returns one entry with the total,
41
+ * with `groupBy` one entry per group
42
+ *
43
+ * @param dataContractId {IdentifierLike} Identifier of the Data Contract
44
+ * @param query {AggregateProofQuery} documentTypeName, where, orderBy, groupBy and limit of the query
45
+ *
46
+ * @return {Promise<ProvenAggregate>}
47
+ */
48
+ count(dataContractId: IdentifierLike, query: AggregateProofQuery): Promise<ProvenAggregate>;
49
+ /**
50
+ * Sums a field over documents matching a query. Without `groupBy` returns one entry with the total,
51
+ * with `groupBy` one entry per group
52
+ *
53
+ * @param dataContractId {IdentifierLike} Identifier of the Data Contract
54
+ * @param query {AggregateProofQuery} documentTypeName, where, orderBy, groupBy and limit of the query
55
+ * @param field {string} Integer field to sum
56
+ *
57
+ * @return {Promise<ProvenAggregate>}
58
+ */
59
+ sum(dataContractId: IdentifierLike, query: AggregateProofQuery, field: string): Promise<ProvenAggregate>;
60
+ /**
61
+ * Averages a field over documents matching a query. Entries carry `count` and `sum`, the average is `sum / count`.
62
+ * Without `groupBy` returns one entry with the total, with `groupBy` one entry per group
63
+ *
64
+ * @param dataContractId {IdentifierLike} Identifier of the Data Contract
65
+ * @param query {AggregateProofQuery} documentTypeName, where, orderBy, groupBy and limit of the query
66
+ * @param field {string} Integer field to average
67
+ *
68
+ * @return {Promise<ProvenAggregate>}
69
+ */
70
+ average(dataContractId: IdentifierLike, query: AggregateProofQuery, field: string): Promise<ProvenAggregate>;
71
+ /**
72
+ * Top-K query: groups of `groupBy` ranked by the selected aggregate. Order by the selected field,
73
+ * or by `$count` for count, e.g. `orderBy: [['$count', 'desc']]`. Supports `limit` and `offset`
74
+ *
75
+ * @param dataContractId {IdentifierLike} Identifier of the Data Contract
76
+ * @param query {AggregateDocumentsQuery} documentTypeName, select, groupBy, where, orderBy, limit and offset of the query
77
+ *
78
+ * @return {Promise<ProvenRankedPage>}
79
+ */
80
+ ranked(dataContractId: IdentifierLike, query: AggregateDocumentsQuery): Promise<ProvenRankedPage>;
81
+ /**
82
+ * Having query: groups of `groupBy` whose aggregate falls within the `having` bounds
83
+ *
84
+ * @param dataContractId {IdentifierLike} Identifier of the Data Contract
85
+ * @param query {AggregateDocumentsQuery & { having: HavingClause[] }} ranked query with having clauses
86
+ *
87
+ * @return {Promise<ProvenRankedEntry[]>}
88
+ */
89
+ having(dataContractId: IdentifierLike, query: AggregateDocumentsQuery & {
90
+ having: HavingClause[];
91
+ }): Promise<ProvenRankedEntry[]>;
92
+ /**
93
+ * Chained join: documents of the query, then the documents of `outerDocumentType`
94
+ * their `joinProperty` refers to
95
+ *
96
+ * @param dataContractId {IdentifierLike} Identifier of the Data Contract
97
+ * @param query {DocumentsQuery} documentTypeName, where, orderBy, limit, startAt and startAtIncluded of the inner query
98
+ * @param joinProperty {string} Property of the inner documents referring to the outer documents
99
+ * @param outerDocumentType {string} Document type of the outer documents
100
+ *
101
+ * @return {Promise<ChainedDocuments>}
102
+ */
103
+ chained(dataContractId: IdentifierLike, query: DocumentsQuery, joinProperty: string, outerDocumentType: string): Promise<ChainedDocuments>;
104
+ /**
105
+ * Composite query: a page of documents plus up to 10 sub-queries, each optionally bound
106
+ * to values the page or an earlier sub-query proved
107
+ *
108
+ * @param dataContractId {IdentifierLike} Identifier of the Data Contract
109
+ * @param query {DocumentsQuery & { offset?: number }} page query
110
+ * @param subQueries {CompositeSubQuery[]} sub-queries, `binding.source` is `'page'` or an index of an earlier sub-query
111
+ *
112
+ * @return {Promise<CompositeDocuments>}
113
+ */
114
+ composite(dataContractId: IdentifierLike, query: DocumentsQuery & {
115
+ offset?: number;
116
+ }, subQueries: CompositeSubQuery[]): Promise<CompositeDocuments>;
37
117
  /**
38
118
  * Helper function for creating {StateTransitionWASM} from documents. It may be used to create any of 6 Document Transition actions:
39
119
  *
@@ -48,5 +128,20 @@ export declare class DocumentsController {
48
128
  * @param type {string} Type of the document transition, must be a one of ('create' | 'replace' | 'delete' | 'updatePrice' |'transfer' | 'purchase')
49
129
  * @param params {DocumentTransitionParams} params
50
130
  */
51
- createStateTransition(document: DocumentWASM, type: 'create' | 'replace' | 'delete' | 'updatePrice' | 'transfer' | 'purchase', params: DocumentTransitionParams): StateTransitionWASM;
131
+ createStateTransition(document: DocumentWASM, type: DocumentTransitionType, params: DocumentTransitionParams): StateTransitionWASM;
132
+ /**
133
+ * Builds the action fee agreement a document transition must carry when its document type declares
134
+ * `actionFees` for the action (protocol v14): the fee parts the contract declares and the fee multiplier
135
+ * of the current epoch. Pass it as `actionFeeAgreement` to {@link createStateTransition}.
136
+ * Returns undefined when the action charges no fee
137
+ *
138
+ * @param dataContractId {IdentifierLike} Identifier of the Data Contract
139
+ * @param documentType {string} Document type of the data contract
140
+ * @param action {string} Type of the document transition ('create' | 'replace' | 'delete' | 'updatePrice' | 'transfer' | 'purchase')
141
+ * @param increaseTolerancePercent {number=} How far the fee multiplier may grow before execution, in percent (defaults to 0).
142
+ * The network refuses the transition when the multiplier of the executing epoch is higher
143
+ *
144
+ * @return {Promise<DocumentActionFeeAgreementWASM | undefined>}
145
+ */
146
+ getActionFeeAgreement(dataContractId: IdentifierLike, documentType: string, action: DocumentTransitionType, increaseTolerancePercent?: number): Promise<DocumentActionFeeAgreementWASM | undefined>;
52
147
  }
@@ -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
  *
@@ -20,12 +24,13 @@ export class DocumentsController {
20
24
  * @param documentType {string} Document type as string
21
25
  * @param data {object} Data as JSON object
22
26
  * @param owner {IdentifierLike} Identifier of the document's owner
27
+ * @param identityContractNonce {bigint} Identity contract nonce of the transition that will create the document, used for document id generation
23
28
  * @param revision {bigint=} revision (optional)
24
29
  *
25
30
  * @return {DataContractWASM}
26
31
  */
27
- create(dataContractId, documentType, data, owner, revision) {
28
- return createDocument(new IdentifierWASM(dataContractId), documentType, data, new IdentifierWASM(owner), revision);
32
+ create(dataContractId, documentType, data, owner, identityContractNonce, revision) {
33
+ return createDocument(new IdentifierWASM(dataContractId), documentType, data, new IdentifierWASM(owner), identityContractNonce, revision);
29
34
  }
30
35
  /**
31
36
  * Make a query for documents retrieval from the network.
@@ -44,6 +49,94 @@ export class DocumentsController {
44
49
  }
45
50
  return await query(this.grpcPool, new IdentifierWASM(dataContractId), documentType, where, orderBy, limit ?? 100, startAt, startAfter);
46
51
  }
52
+ /**
53
+ * Counts documents matching a query. Without `groupBy` returns one entry with the total,
54
+ * with `groupBy` one entry per group
55
+ *
56
+ * @param dataContractId {IdentifierLike} Identifier of the Data Contract
57
+ * @param query {AggregateProofQuery} documentTypeName, where, orderBy, groupBy and limit of the query
58
+ *
59
+ * @return {Promise<ProvenAggregate>}
60
+ */
61
+ async count(dataContractId, query) {
62
+ return await queryAggregate(this.grpcPool, dataContractId, 'count', query);
63
+ }
64
+ /**
65
+ * Sums a field over documents matching a query. Without `groupBy` returns one entry with the total,
66
+ * with `groupBy` one entry per group
67
+ *
68
+ * @param dataContractId {IdentifierLike} Identifier of the Data Contract
69
+ * @param query {AggregateProofQuery} documentTypeName, where, orderBy, groupBy and limit of the query
70
+ * @param field {string} Integer field to sum
71
+ *
72
+ * @return {Promise<ProvenAggregate>}
73
+ */
74
+ async sum(dataContractId, query, field) {
75
+ return await queryAggregate(this.grpcPool, dataContractId, 'sum', query, field);
76
+ }
77
+ /**
78
+ * Averages a field over documents matching a query. Entries carry `count` and `sum`, the average is `sum / count`.
79
+ * Without `groupBy` returns one entry with the total, with `groupBy` one entry per group
80
+ *
81
+ * @param dataContractId {IdentifierLike} Identifier of the Data Contract
82
+ * @param query {AggregateProofQuery} documentTypeName, where, orderBy, groupBy and limit of the query
83
+ * @param field {string} Integer field to average
84
+ *
85
+ * @return {Promise<ProvenAggregate>}
86
+ */
87
+ async average(dataContractId, query, field) {
88
+ return await queryAggregate(this.grpcPool, dataContractId, 'avg', query, field);
89
+ }
90
+ /**
91
+ * Top-K query: groups of `groupBy` ranked by the selected aggregate. Order by the selected field,
92
+ * or by `$count` for count, e.g. `orderBy: [['$count', 'desc']]`. Supports `limit` and `offset`
93
+ *
94
+ * @param dataContractId {IdentifierLike} Identifier of the Data Contract
95
+ * @param query {AggregateDocumentsQuery} documentTypeName, select, groupBy, where, orderBy, limit and offset of the query
96
+ *
97
+ * @return {Promise<ProvenRankedPage>}
98
+ */
99
+ async ranked(dataContractId, query) {
100
+ return await queryRanked(this.grpcPool, dataContractId, query);
101
+ }
102
+ /**
103
+ * Having query: groups of `groupBy` whose aggregate falls within the `having` bounds
104
+ *
105
+ * @param dataContractId {IdentifierLike} Identifier of the Data Contract
106
+ * @param query {AggregateDocumentsQuery & { having: HavingClause[] }} ranked query with having clauses
107
+ *
108
+ * @return {Promise<ProvenRankedEntry[]>}
109
+ */
110
+ async having(dataContractId, query) {
111
+ return await queryHaving(this.grpcPool, dataContractId, query);
112
+ }
113
+ /**
114
+ * Chained join: documents of the query, then the documents of `outerDocumentType`
115
+ * their `joinProperty` refers to
116
+ *
117
+ * @param dataContractId {IdentifierLike} Identifier of the Data Contract
118
+ * @param query {DocumentsQuery} documentTypeName, where, orderBy, limit, startAt and startAtIncluded of the inner query
119
+ * @param joinProperty {string} Property of the inner documents referring to the outer documents
120
+ * @param outerDocumentType {string} Document type of the outer documents
121
+ *
122
+ * @return {Promise<ChainedDocuments>}
123
+ */
124
+ async chained(dataContractId, query, joinProperty, outerDocumentType) {
125
+ return await queryChained(this.grpcPool, dataContractId, query, joinProperty, outerDocumentType);
126
+ }
127
+ /**
128
+ * Composite query: a page of documents plus up to 10 sub-queries, each optionally bound
129
+ * to values the page or an earlier sub-query proved
130
+ *
131
+ * @param dataContractId {IdentifierLike} Identifier of the Data Contract
132
+ * @param query {DocumentsQuery & { offset?: number }} page query
133
+ * @param subQueries {CompositeSubQuery[]} sub-queries, `binding.source` is `'page'` or an index of an earlier sub-query
134
+ *
135
+ * @return {Promise<CompositeDocuments>}
136
+ */
137
+ async composite(dataContractId, query, subQueries) {
138
+ return await queryComposite(this.grpcPool, dataContractId, query, subQueries);
139
+ }
47
140
  /**
48
141
  * Helper function for creating {StateTransitionWASM} from documents. It may be used to create any of 6 Document Transition actions:
49
142
  *
@@ -78,6 +171,27 @@ export class DocumentsController {
78
171
  // @ts-expect-error
79
172
  params.tokenPaymentInfo = new TokenPaymentInfoWASM(new IdentifierWASM(tokenContractId), tokenContractPosition, minimumTokenCost, maximumTokenCost, gasFeesPaidBy);
80
173
  }
174
+ if (params.actionFeeAgreement != null && !(params.actionFeeAgreement instanceof DocumentActionFeeAgreementWASM)) {
175
+ const { owner, moderators, feeMultiplier } = params.actionFeeAgreement;
176
+ params.actionFeeAgreement = new DocumentActionFeeAgreementWASM(owner, moderators, feeMultiplier != null ? new AgreedFeeMultiplierWASM(feeMultiplier.knownPermille, feeMultiplier.increaseTolerancePercent) : undefined);
177
+ }
81
178
  return createStateTransition(document, type, params);
82
179
  }
180
+ /**
181
+ * Builds the action fee agreement a document transition must carry when its document type declares
182
+ * `actionFees` for the action (protocol v14): the fee parts the contract declares and the fee multiplier
183
+ * of the current epoch. Pass it as `actionFeeAgreement` to {@link createStateTransition}.
184
+ * Returns undefined when the action charges no fee
185
+ *
186
+ * @param dataContractId {IdentifierLike} Identifier of the Data Contract
187
+ * @param documentType {string} Document type of the data contract
188
+ * @param action {string} Type of the document transition ('create' | 'replace' | 'delete' | 'updatePrice' | 'transfer' | 'purchase')
189
+ * @param increaseTolerancePercent {number=} How far the fee multiplier may grow before execution, in percent (defaults to 0).
190
+ * The network refuses the transition when the multiplier of the executing epoch is higher
191
+ *
192
+ * @return {Promise<DocumentActionFeeAgreementWASM | undefined>}
193
+ */
194
+ async getActionFeeAgreement(dataContractId, documentType, action, increaseTolerancePercent) {
195
+ return await getActionFeeAgreement(this.grpcPool, dataContractId, documentType, action, increaseTolerancePercent ?? 0);
196
+ }
83
197
  }
@@ -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 (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[]>;
@@ -0,0 +1,37 @@
1
+ import { IdentifierWASM, verifyHavingDocumentsProof, verifyRankedDocumentsProof } from 'pshenmic-dpp';
2
+ import { LATEST_PLATFORM_VERSION } from '../constants.js';
3
+ import getDataContractByIdentifier from '../dataContracts/getDataContractByIdentifier.js';
4
+ import { getDocumentsV1Proof, toHavingClauses, toOrderClauses, toSelect, toWhereClauses, verifyDocumentsV1Signature } from './v1.js';
5
+ async function getRankedProof(grpcPool, dataContractId, query, having) {
6
+ return await getDocumentsV1Proof(grpcPool, {
7
+ dataContractId: (new IdentifierWASM(dataContractId)).bytes(),
8
+ documentType: query.documentTypeName,
9
+ whereClauses: toWhereClauses(query.where),
10
+ orderBy: toOrderClauses(query.orderBy),
11
+ limit: query.limit,
12
+ offset: query.offset,
13
+ selects: toSelect(query.select),
14
+ groupBy: query.groupBy,
15
+ having: toHavingClauses(having)
16
+ });
17
+ }
18
+ /**
19
+ * Top-K query: groups of `groupBy` ranked by the selected aggregate in the order `orderBy` names
20
+ */
21
+ export async function queryRanked(grpcPool, dataContractId, query) {
22
+ const dataContract = await getDataContractByIdentifier(grpcPool, dataContractId);
23
+ const { proof, metadata } = await getRankedProof(grpcPool, dataContractId, query, []);
24
+ const { rootHash, value } = verifyRankedDocumentsProof(proof.grovedbProof, dataContract, query, LATEST_PLATFORM_VERSION, BigInt(metadata.timeMs));
25
+ await verifyDocumentsV1Signature(grpcPool, proof, metadata, rootHash);
26
+ return value;
27
+ }
28
+ /**
29
+ * Having query: groups of `groupBy` whose aggregate falls within the `having` bounds
30
+ */
31
+ export async function queryHaving(grpcPool, dataContractId, query) {
32
+ const dataContract = await getDataContractByIdentifier(grpcPool, dataContractId);
33
+ const { proof, metadata } = await getRankedProof(grpcPool, dataContractId, query, query.having);
34
+ const { rootHash, value } = verifyHavingDocumentsProof(proof.grovedbProof, dataContract, query, LATEST_PLATFORM_VERSION, BigInt(metadata.timeMs));
35
+ await verifyDocumentsV1Signature(grpcPool, proof, metadata, rootHash);
36
+ return value;
37
+ }