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.
- package/README.md +15 -15
- package/bundle.min.js +1 -1
- package/package.json +3 -4
- package/proto/generated/platform.client.d.ts +20 -60
- package/proto/generated/platform.client.js +41 -69
- package/proto/generated/platform.d.ts +2330 -1650
- package/proto/generated/platform.js +4992 -3467
- package/src/DashPlatformSDK.d.ts +0 -8
- package/src/DashPlatformSDK.js +0 -10
- package/src/constants.d.ts +1 -1
- package/src/constants.js +1 -1
- package/src/contestedResources/getContestedResourceVoteState.js +1 -1
- package/src/dataContracts/getDataContractByIdentifier.js +1 -1
- package/src/documents/createStateTransition.d.ts +2 -2
- package/src/documents/createStateTransition.js +6 -6
- package/src/documents/getActionFeeAgreement.d.ts +4 -0
- package/src/documents/getActionFeeAgreement.js +21 -0
- package/src/documents/index.d.ts +97 -3
- package/src/documents/index.js +114 -1
- package/src/documents/query.js +13 -52
- package/src/documents/queryAggregate.d.ts +4 -0
- package/src/documents/queryAggregate.js +32 -0
- package/src/documents/queryJoined.d.ts +16 -0
- package/src/documents/queryJoined.js +44 -0
- package/src/documents/queryRanked.d.ts +12 -0
- package/src/documents/queryRanked.js +37 -0
- package/src/documents/v1.d.ts +33 -0
- package/src/documents/v1.js +233 -0
- package/src/grpcConnectionPool.d.ts +3 -6
- package/src/grpcConnectionPool.js +141 -47
- package/src/identities/getIdentityBalance.js +1 -1
- package/src/identities/getIdentityByIdentifier.js +1 -1
- package/src/identities/getIdentityByNonUniquePublicKeyHash.js +7 -11
- package/src/identities/getIdentityByPublicKeyHash.js +1 -1
- package/src/identities/getIdentityContractNonce.js +1 -1
- package/src/identities/getIdentityNonce.js +1 -1
- package/src/identities/getIdentityPublicKeys.js +1 -1
- package/src/node/epochInfos.js +1 -1
- package/src/node/finalizedEpochInfos.js +1 -1
- package/src/node/getCurrentQuorumsInfo.js +1 -1
- package/src/node/status.js +1 -1
- package/src/node/totalCredits.js +1 -1
- package/src/platformAddresses/getAddressInfo.js +1 -1
- package/src/platformAddresses/getAddressesBranchState.js +1 -1
- package/src/platformAddresses/getAddressesInfos.js +1 -1
- package/src/platformAddresses/getAddressesTrunkState.js +1 -1
- package/src/platformAddresses/getRecentAddressBalanceChanges.js +1 -1
- package/src/platformAddresses/getRecentCompactedAddressBalanceChanges.js +1 -1
- package/src/shielded/getMostRecentShieldedAnchor.d.ts +2 -1
- package/src/shielded/getMostRecentShieldedAnchor.js +7 -5
- package/src/shielded/getShieldedAnchors.d.ts +2 -1
- package/src/shielded/getShieldedAnchors.js +7 -5
- package/src/shielded/getShieldedEncryptedNotes.d.ts +2 -1
- package/src/shielded/getShieldedEncryptedNotes.js +7 -5
- package/src/shielded/getShieldedNotesCount.d.ts +2 -1
- package/src/shielded/getShieldedNotesCount.js +7 -5
- package/src/shielded/getShieldedNullifiers.d.ts +2 -1
- package/src/shielded/getShieldedNullifiers.js +7 -5
- package/src/shielded/getShieldedPoolState.d.ts +2 -1
- package/src/shielded/getShieldedPoolState.js +7 -5
- package/src/shielded/index.d.ts +17 -7
- package/src/shielded/index.js +22 -12
- package/src/stateTransitions/broadcast.js +1 -1
- package/src/stateTransitions/index.d.ts +6 -2
- package/src/stateTransitions/index.js +5 -1
- package/src/stateTransitions/waitForStateTransitionResult.d.ts +1 -1
- package/src/stateTransitions/waitForStateTransitionResult.js +5 -3
- package/src/tokens/getIdentitiesTokenBalances.js +1 -1
- package/src/tokens/getIdentityTokensBalances.js +1 -1
- package/src/tokens/getTokenContractInfo.js +1 -1
- package/src/tokens/getTokenDirectPurchasePrices.js +1 -1
- package/src/tokens/getTokenTotalSupply.js +1 -1
- package/src/utils/verifyTenderdashProof.js +1 -1
- package/test/unit/ContestedResources.spec.js +0 -1
- package/test/unit/DataContract.spec.js +2 -2
- package/test/unit/Document.spec.js +0 -1
- package/test/unit/DocumentActionFees.spec.d.ts +1 -0
- package/test/unit/DocumentActionFees.spec.js +99 -0
- package/test/unit/DocumentQueries.spec.d.ts +1 -0
- package/test/unit/DocumentQueries.spec.js +178 -0
- package/test/unit/DocumentsV1.spec.d.ts +1 -0
- package/test/unit/DocumentsV1.spec.js +75 -0
- package/test/unit/Identity.spec.js +0 -1
- package/test/unit/Names.spec.js +0 -1
- package/test/unit/Node.spec.js +0 -1
- package/test/unit/PlatformAddress.spec.js +0 -1
- package/test/unit/Shielded.spec.js +0 -1
- package/test/unit/Tokens.spec.js +0 -1
- package/types.d.ts +20 -1
|
@@ -14,11 +14,12 @@ export default async function waitForStateTransitionResult(grpcPool, stateTransi
|
|
|
14
14
|
oneofKind: 'v0',
|
|
15
15
|
v0: {
|
|
16
16
|
stateTransitionHash: hexToBytes(txHash),
|
|
17
|
-
prove: true
|
|
17
|
+
prove: true,
|
|
18
|
+
requestUserBalance: false
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
});
|
|
21
|
-
const { response } = await grpcPool.getClient().waitForStateTransitionResult(waitForStateTransitionResultRequest);
|
|
22
|
+
const { response } = await (await grpcPool.getClient()).waitForStateTransitionResult(waitForStateTransitionResultRequest);
|
|
22
23
|
const { version } = response;
|
|
23
24
|
if (version.oneofKind !== 'v0') {
|
|
24
25
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
@@ -51,7 +52,7 @@ export default async function waitForStateTransitionResult(grpcPool, stateTransi
|
|
|
51
52
|
coreHeight: coreChainLockedHeight,
|
|
52
53
|
epoch
|
|
53
54
|
};
|
|
54
|
-
const { rootHash, result } = verifyStateTransitionResult(proof.grovedbProof, stateTransition, blockInfo, knownContracts, LATEST_PLATFORM_VERSION);
|
|
55
|
+
const { rootHash, result, ownerBalance } = verifyStateTransitionResult(proof.grovedbProof, stateTransition, blockInfo, knownContracts, LATEST_PLATFORM_VERSION);
|
|
55
56
|
if (result == null) {
|
|
56
57
|
throw new Error('State transition result was null');
|
|
57
58
|
}
|
|
@@ -60,6 +61,7 @@ export default async function waitForStateTransitionResult(grpcPool, stateTransi
|
|
|
60
61
|
if (!verify) {
|
|
61
62
|
throw new Error('Failed to verify wait for state transition result query');
|
|
62
63
|
}
|
|
64
|
+
return ownerBalance;
|
|
63
65
|
}
|
|
64
66
|
else if (v0.result.oneofKind === 'error') {
|
|
65
67
|
const { code, message, data } = v0.result.error;
|
|
@@ -17,7 +17,7 @@ export default async function getIdentitiesTokenBalances(grpcPool, identifiers,
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
|
-
const { response } = await grpcPool.getClient().getIdentitiesTokenBalances(getIdentitiesTokenBalancesRequest);
|
|
20
|
+
const { response } = await (await grpcPool.getClient()).getIdentitiesTokenBalances(getIdentitiesTokenBalancesRequest);
|
|
21
21
|
const { version } = response;
|
|
22
22
|
if (version.oneofKind !== 'v0') {
|
|
23
23
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
@@ -17,7 +17,7 @@ export default async function getIdentityTokensBalances(grpcPool, identifier, to
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
|
-
const { response } = await grpcPool.getClient().getIdentityTokenBalances(getIdentityTokenBalancesRequest);
|
|
20
|
+
const { response } = await (await grpcPool.getClient()).getIdentityTokenBalances(getIdentityTokenBalancesRequest);
|
|
21
21
|
const { version } = response;
|
|
22
22
|
if (version.oneofKind !== 'v0') {
|
|
23
23
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
@@ -15,7 +15,7 @@ export default async function getTokenContractInfo(grpcPool, tokenIdentifier) {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
const { response } = await grpcPool.getClient().getTokenContractInfo(getTokenContractInfoRequest);
|
|
18
|
+
const { response } = await (await grpcPool.getClient()).getTokenContractInfo(getTokenContractInfoRequest);
|
|
19
19
|
const { version } = response;
|
|
20
20
|
if (version.oneofKind !== 'v0') {
|
|
21
21
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
@@ -15,7 +15,7 @@ export default async function getTokenDirectPurchasePrices(grpcPool, tokenIdenti
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
const { response } = await grpcPool.getClient().getTokenDirectPurchasePrices(request);
|
|
18
|
+
const { response } = await (await grpcPool.getClient()).getTokenDirectPurchasePrices(request);
|
|
19
19
|
const { version } = response;
|
|
20
20
|
if (version.oneofKind !== 'v0') {
|
|
21
21
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
@@ -15,7 +15,7 @@ export default async function getTokenTotalSupply(grpcPool, tokenIdentifier) {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
const { response } = await grpcPool.getClient().getTokenTotalSupply(getTokenTotalSupplyRequest);
|
|
18
|
+
const { response } = await (await grpcPool.getClient()).getTokenTotalSupply(getTokenTotalSupplyRequest);
|
|
19
19
|
const { version } = response;
|
|
20
20
|
if (version.oneofKind !== 'v0') {
|
|
21
21
|
throw new Error('Unexpected oneOf type returned from DAPI (must be v0)');
|
|
@@ -4,7 +4,7 @@ import { calculateStateIdHash } from './calculateStateIdHash.js';
|
|
|
4
4
|
import { verifySignatureDigest } from 'pshenmic-dpp';
|
|
5
5
|
import hexToBytes from './hexToBytes.js';
|
|
6
6
|
export default async function verifyTenderdashProof(proof, metadata, rootHash, quorumPublicKey) {
|
|
7
|
-
if (
|
|
7
|
+
if (Date.now() - Number(metadata.timeMs) > 15 * 60 * 1000) {
|
|
8
8
|
throw new Error('Request is stalled (over 15 minutes)');
|
|
9
9
|
}
|
|
10
10
|
const stateId = StateId.create({
|
|
@@ -7,7 +7,6 @@ let contract;
|
|
|
7
7
|
describe('Contested Resources', () => {
|
|
8
8
|
beforeAll(async () => {
|
|
9
9
|
sdk = new DashPlatformSDK({ network: 'testnet' });
|
|
10
|
-
await sdk.waitForInit();
|
|
11
10
|
contract = new DataContractWASM('11111111111111111111111111111111', BigInt(1), {
|
|
12
11
|
domain: {
|
|
13
12
|
type: 'object',
|
|
@@ -8,7 +8,6 @@ let schema;
|
|
|
8
8
|
describe('DataContract', () => {
|
|
9
9
|
beforeAll(async () => {
|
|
10
10
|
sdk = new DashPlatformSDK({ network: 'testnet' });
|
|
11
|
-
await sdk.waitForInit();
|
|
12
11
|
ownerIdentifier = 'GARSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec';
|
|
13
12
|
identityNonce = BigInt(11);
|
|
14
13
|
config = {
|
|
@@ -62,7 +61,8 @@ describe('DataContract', () => {
|
|
|
62
61
|
test('should be able to create data contract with optional params', async () => {
|
|
63
62
|
const dataContract = sdk.dataContracts.create(ownerIdentifier, identityNonce, schema, true, undefined, config);
|
|
64
63
|
expect(dataContract).toEqual(expect.any(DataContractWASM));
|
|
65
|
-
|
|
64
|
+
// platform v14 upgrades the contract config to format version 2
|
|
65
|
+
expect(dataContract.getConfig()).toEqual({ ...config, $formatVersion: '2' });
|
|
66
66
|
});
|
|
67
67
|
test('should be able to create data contract create transition', async () => {
|
|
68
68
|
const dataContract = sdk.dataContracts.create(ownerIdentifier, identityNonce, schema);
|
|
@@ -9,7 +9,6 @@ let data;
|
|
|
9
9
|
describe('Document', () => {
|
|
10
10
|
beforeAll(async () => {
|
|
11
11
|
sdk = new DashPlatformSDK({ network: 'testnet' });
|
|
12
|
-
await sdk.waitForInit();
|
|
13
12
|
dataContract = '6QMfQTdKpC3Y9uWBcTwXeY3KdzRLDqASUsDnQ4MEc9XC';
|
|
14
13
|
identity = 'QMfCRPcjXoTnZa9sA9JR2KWgGxZXMRJ4akgS3Uia1Qv';
|
|
15
14
|
revision = BigInt(1);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { AgreedFeeMultiplierWASM, BatchTransitionWASM, DocumentActionFeeAgreementWASM } from 'pshenmic-dpp';
|
|
2
|
+
import { DashPlatformSDK } from '../../src/DashPlatformSDK.js';
|
|
3
|
+
const DPNS = 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec';
|
|
4
|
+
const owner = 'QMfCRPcjXoTnZa9sA9JR2KWgGxZXMRJ4akgS3Uia1Qv';
|
|
5
|
+
// a document type that charges the contract owner 0.0001 Dash (10000000 credits) per created note
|
|
6
|
+
// and 0.00005 Dash per purchase. Fixed pricing charges the amounts as written, `feeMultiplier`
|
|
7
|
+
// pricing (the default) scales them by the epoch fee multiplier
|
|
8
|
+
function noteSchema(pricing) {
|
|
9
|
+
return {
|
|
10
|
+
note: {
|
|
11
|
+
type: 'object',
|
|
12
|
+
properties: {
|
|
13
|
+
message: { type: 'string', maxLength: 100, position: 0 }
|
|
14
|
+
},
|
|
15
|
+
additionalProperties: false,
|
|
16
|
+
transferable: 1,
|
|
17
|
+
tradeMode: 1,
|
|
18
|
+
actionFees: {
|
|
19
|
+
pricing,
|
|
20
|
+
create: { owner: 10000000 },
|
|
21
|
+
purchase: { owner: 5000000 }
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
// reads the agreement a state transition carries
|
|
27
|
+
function agreementOf(stateTransition) {
|
|
28
|
+
const [batched] = BatchTransitionWASM.fromStateTransition(stateTransition).transitions;
|
|
29
|
+
const transition = batched.toTransition();
|
|
30
|
+
return transition.createTransition.base.actionFeeAgreement;
|
|
31
|
+
}
|
|
32
|
+
let sdk;
|
|
33
|
+
let fixedContract;
|
|
34
|
+
let multipliedContract;
|
|
35
|
+
describe('Document action fees', () => {
|
|
36
|
+
beforeAll(() => {
|
|
37
|
+
sdk = new DashPlatformSDK({ network: 'testnet' });
|
|
38
|
+
fixedContract = sdk.dataContracts.create(owner, 1n, noteSchema('fixed'));
|
|
39
|
+
multipliedContract = sdk.dataContracts.create(owner, 2n, noteSchema('feeMultiplier'));
|
|
40
|
+
});
|
|
41
|
+
test('should be able to derive the agreement to a fixed fee', () => {
|
|
42
|
+
// the fee multiplier of the current epoch (sdk.node.getEpochsInfo(1, false)), 1000 permille = x1
|
|
43
|
+
const feeMultiplier = new AgreedFeeMultiplierWASM(1000n, 0);
|
|
44
|
+
const agreement = DocumentActionFeeAgreementWASM.forDocumentTypeAction(fixedContract, 'note', 'Create', feeMultiplier);
|
|
45
|
+
expect(agreement?.owner).toEqual(10000000n);
|
|
46
|
+
expect(agreement?.moderators).toEqual(0n);
|
|
47
|
+
// a fixed fee does not follow the multiplier, so the agreement names none
|
|
48
|
+
expect(agreement?.pricing).toEqual('fixed');
|
|
49
|
+
expect(agreement?.feeMultiplier).toEqual(undefined);
|
|
50
|
+
});
|
|
51
|
+
test('should be able to derive the agreement to a fee priced by the fee multiplier', () => {
|
|
52
|
+
// accept the multiplier to grow by up to 20% before the transition executes
|
|
53
|
+
const feeMultiplier = new AgreedFeeMultiplierWASM(1000n, 20);
|
|
54
|
+
const agreement = DocumentActionFeeAgreementWASM.forDocumentTypeAction(multipliedContract, 'note', 'Purchase', feeMultiplier);
|
|
55
|
+
expect(agreement?.owner).toEqual(5000000n);
|
|
56
|
+
expect(agreement?.pricing).toEqual('feeMultiplier');
|
|
57
|
+
expect(agreement?.feeMultiplier?.knownPermille).toEqual(1000n);
|
|
58
|
+
expect(agreement?.feeMultiplier?.increaseTolerancePercent).toEqual(20);
|
|
59
|
+
});
|
|
60
|
+
test('should get no agreement for an action without a fee', () => {
|
|
61
|
+
const feeMultiplier = new AgreedFeeMultiplierWASM(1000n, 0);
|
|
62
|
+
expect(DocumentActionFeeAgreementWASM.forDocumentTypeAction(fixedContract, 'note', 'Delete', feeMultiplier)).toEqual(undefined);
|
|
63
|
+
});
|
|
64
|
+
test('should be able to check an agreement the way the network does', () => {
|
|
65
|
+
const agreement = DocumentActionFeeAgreementWASM.forDocumentTypeAction(multipliedContract, 'note', 'Create', new AgreedFeeMultiplierWASM(1000n, 20));
|
|
66
|
+
// the multiplier of the executing epoch may be up to 20% higher than the known one
|
|
67
|
+
expect(agreement.verify(multipliedContract, 'note', 'Create', 1200n)).toEqual(true);
|
|
68
|
+
expect(agreement.verify(multipliedContract, 'note', 'Create', 1201n)).toEqual(false);
|
|
69
|
+
// the agreement must name the fee the document type declares for the action
|
|
70
|
+
expect(agreement.verify(multipliedContract, 'note', 'Purchase', 1000n)).toEqual(false);
|
|
71
|
+
});
|
|
72
|
+
test('should be able to create a transition with an agreement', () => {
|
|
73
|
+
const document = sdk.documents.create(fixedContract.id, 'note', { message: 'hello' }, owner);
|
|
74
|
+
const feeMultiplier = new AgreedFeeMultiplierWASM(1000n, 0);
|
|
75
|
+
const actionFeeAgreement = DocumentActionFeeAgreementWASM.forDocumentTypeAction(fixedContract, 'note', 'Create', feeMultiplier);
|
|
76
|
+
const stateTransition = sdk.documents.createStateTransition(document, 'create', { identityContractNonce: 1n, actionFeeAgreement });
|
|
77
|
+
expect(agreementOf(stateTransition)?.owner).toEqual(10000000n);
|
|
78
|
+
});
|
|
79
|
+
test('should be able to create a transition with an agreement as a plain object', () => {
|
|
80
|
+
const document = sdk.documents.create(multipliedContract.id, 'note', { message: 'hello' }, owner);
|
|
81
|
+
const stateTransition = sdk.documents.createStateTransition(document, 'create', {
|
|
82
|
+
identityContractNonce: 1n,
|
|
83
|
+
actionFeeAgreement: {
|
|
84
|
+
owner: 10000000n,
|
|
85
|
+
moderators: 0n,
|
|
86
|
+
// omit for a fixed fee
|
|
87
|
+
feeMultiplier: { knownPermille: 1000n, increaseTolerancePercent: 10 }
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
const agreement = agreementOf(stateTransition);
|
|
91
|
+
expect(agreement?.pricing).toEqual('feeMultiplier');
|
|
92
|
+
expect(agreement?.feeMultiplier?.increaseTolerancePercent).toEqual(10);
|
|
93
|
+
});
|
|
94
|
+
test('should be able to get the agreement for a contract on the network', async () => {
|
|
95
|
+
// reads the contract and the current epoch fee multiplier, DPNS declares no action fees
|
|
96
|
+
const agreement = await sdk.documents.getActionFeeAgreement(DPNS, 'domain', 'create', 10);
|
|
97
|
+
expect(agreement).toEqual(undefined);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { DocumentWASM, IdentifierWASM } from 'pshenmic-dpp';
|
|
2
|
+
import { DashPlatformSDK } from '../../src/DashPlatformSDK.js';
|
|
3
|
+
const DOCUMENT_HISTORY = '6voHRaoiPcfmMhbqCA9dixH98xcgPQ9UEcuaXjpVu3LD';
|
|
4
|
+
const DPNS = 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec';
|
|
5
|
+
function decodeTimestampKey(key) {
|
|
6
|
+
return new DataView(key.buffer, key.byteOffset, key.byteLength).getBigUint64(0) ^ (1n << 63n);
|
|
7
|
+
}
|
|
8
|
+
let sdk;
|
|
9
|
+
describe('Document queries', () => {
|
|
10
|
+
beforeAll(async () => {
|
|
11
|
+
sdk = new DashPlatformSDK({ network: 'testnet' });
|
|
12
|
+
});
|
|
13
|
+
describe('where operators', () => {
|
|
14
|
+
test('should be able to query with `in`', async () => {
|
|
15
|
+
const documents = await sdk.documents.query(DPNS, 'domain', [['normalizedParentDomainName', '==', 'dash'], ['normalizedLabel', 'in', ['dash', 'pshenmic']]], [['normalizedLabel', 'asc']], 5);
|
|
16
|
+
expect(documents.length).toBeGreaterThan(0);
|
|
17
|
+
expect(documents[0]).toEqual(expect.any(DocumentWASM));
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
describe('count', () => {
|
|
21
|
+
test('should be able to count all documents of a type', async () => {
|
|
22
|
+
// without a where clause the count comes from the document type's primary key tree
|
|
23
|
+
const { mode, entries: [total] } = await sdk.documents.count(DOCUMENT_HISTORY, { documentTypeName: 'transfer' });
|
|
24
|
+
expect(mode).toEqual('primaryKeyTree');
|
|
25
|
+
expect(total.count).toEqual(expect.any(BigInt));
|
|
26
|
+
expect(total.key).toEqual(new Uint8Array());
|
|
27
|
+
});
|
|
28
|
+
test('should be able to count documents matching an equality', async () => {
|
|
29
|
+
// how many DPNS names were ever transferred
|
|
30
|
+
const { entries: [total] } = await sdk.documents.count(DOCUMENT_HISTORY, {
|
|
31
|
+
documentTypeName: 'transfer',
|
|
32
|
+
where: [['dataContractId', '==', DPNS]]
|
|
33
|
+
});
|
|
34
|
+
expect(total.count).toEqual(expect.any(BigInt));
|
|
35
|
+
});
|
|
36
|
+
test('should be able to count documents in a range', async () => {
|
|
37
|
+
// DPNS names transferred in the last 30 days: a range on the last property of a `rangeCountable` index
|
|
38
|
+
const monthAgo = Date.now() - 30 * 24 * 60 * 60 * 1000;
|
|
39
|
+
const { mode, entries: [total] } = await sdk.documents.count(DOCUMENT_HISTORY, {
|
|
40
|
+
documentTypeName: 'transfer',
|
|
41
|
+
where: [['dataContractId', '==', DPNS], ['$createdAt', '>', monthAgo]]
|
|
42
|
+
});
|
|
43
|
+
expect(mode).toEqual('aggregate');
|
|
44
|
+
expect(total.count).toEqual(expect.any(BigInt));
|
|
45
|
+
});
|
|
46
|
+
test('should be able to count grouped by an `in` clause', async () => {
|
|
47
|
+
// one entry per contract of the `in` list that has transfers, the contract id is the entry key
|
|
48
|
+
const { entries } = await sdk.documents.count(DOCUMENT_HISTORY, {
|
|
49
|
+
documentTypeName: 'transfer',
|
|
50
|
+
where: [['dataContractId', 'in', [DPNS, DOCUMENT_HISTORY]]],
|
|
51
|
+
groupBy: ['dataContractId']
|
|
52
|
+
});
|
|
53
|
+
const [dpns] = entries;
|
|
54
|
+
expect(new IdentifierWASM(dpns.key).base58()).toEqual(DPNS);
|
|
55
|
+
expect(dpns.count).toEqual(expect.any(BigInt));
|
|
56
|
+
});
|
|
57
|
+
test('should be able to count grouped by a range', async () => {
|
|
58
|
+
// one entry per distinct `$createdAt`, `limit` caps the amount of groups
|
|
59
|
+
const { mode, entries } = await sdk.documents.count(DOCUMENT_HISTORY, {
|
|
60
|
+
documentTypeName: 'transfer',
|
|
61
|
+
where: [['dataContractId', '==', DPNS], ['$createdAt', '>', 0]],
|
|
62
|
+
groupBy: ['$createdAt'],
|
|
63
|
+
limit: 3
|
|
64
|
+
});
|
|
65
|
+
expect(mode).toEqual('distinct');
|
|
66
|
+
expect(entries.length).toBeLessThanOrEqual(3);
|
|
67
|
+
expect(decodeTimestampKey(entries[0].key)).toBeGreaterThan(0n);
|
|
68
|
+
expect(entries[0].count).toEqual(expect.any(BigInt));
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
describe('sum and average', () => {
|
|
72
|
+
test('should be able to sum a field', async () => {
|
|
73
|
+
// total credits asked for DPNS names in all price updates
|
|
74
|
+
const { entries: [total] } = await sdk.documents.sum(DOCUMENT_HISTORY, {
|
|
75
|
+
documentTypeName: 'priceUpdate',
|
|
76
|
+
where: [['dataContractId', '==', DPNS], ['$createdAt', '>', 0]]
|
|
77
|
+
}, 'price');
|
|
78
|
+
expect(total.sum).toEqual(expect.any(BigInt));
|
|
79
|
+
});
|
|
80
|
+
test('should be able to average a field', async () => {
|
|
81
|
+
// the proof carries the count and the sum, the average is computed by the caller
|
|
82
|
+
const { entries: [total] } = await sdk.documents.average(DOCUMENT_HISTORY, {
|
|
83
|
+
documentTypeName: 'purchase',
|
|
84
|
+
where: [['dataContractId', '==', DPNS], ['$createdAt', '>', 0]]
|
|
85
|
+
}, 'price');
|
|
86
|
+
const { count, sum } = total;
|
|
87
|
+
expect(count).toBeGreaterThan(0n);
|
|
88
|
+
expect(sum / count).toEqual(expect.any(BigInt));
|
|
89
|
+
});
|
|
90
|
+
test('should be able to average grouped by an `in` clause', async () => {
|
|
91
|
+
// the `in` value of each group is returned in `inKey`
|
|
92
|
+
const { entries } = await sdk.documents.average(DOCUMENT_HISTORY, {
|
|
93
|
+
documentTypeName: 'priceUpdate',
|
|
94
|
+
where: [['dataContractId', 'in', [DPNS, DOCUMENT_HISTORY]], ['$createdAt', '>', 0]],
|
|
95
|
+
groupBy: ['dataContractId']
|
|
96
|
+
}, 'price');
|
|
97
|
+
const [dpns] = entries;
|
|
98
|
+
expect(new IdentifierWASM(dpns.inKey).base58()).toEqual(DPNS);
|
|
99
|
+
expect(dpns.count).toEqual(expect.any(BigInt));
|
|
100
|
+
expect(dpns.sum).toEqual(expect.any(BigInt));
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
describe('composite', () => {
|
|
104
|
+
test('should be able to query a page with a bound sub-query', async () => {
|
|
105
|
+
// page: three DPNS name transfers. Sub-query: purchases of the same names, the page's
|
|
106
|
+
// `documentId` values become an `in` clause on the sub-query's `documentId`
|
|
107
|
+
const { pageDocuments, subResults: [purchases] } = await sdk.documents.composite(DOCUMENT_HISTORY, {
|
|
108
|
+
documentTypeName: 'transfer',
|
|
109
|
+
where: [['dataContractId', '==', DPNS]],
|
|
110
|
+
orderBy: [['$createdAt', 'asc']],
|
|
111
|
+
limit: 3
|
|
112
|
+
}, [{
|
|
113
|
+
documentTypeName: 'purchase',
|
|
114
|
+
where: [['dataContractId', '==', DPNS]],
|
|
115
|
+
// a sub-query on a non-unique index needs a limit per bound value
|
|
116
|
+
limit: 2,
|
|
117
|
+
binding: { source: 'page', sourceProperty: 'documentId', field: 'documentId' }
|
|
118
|
+
}]);
|
|
119
|
+
expect(pageDocuments.length).toEqual(3);
|
|
120
|
+
expect(pageDocuments[0]).toEqual(expect.any(DocumentWASM));
|
|
121
|
+
expect(Array.isArray(purchases.documents)).toEqual(true);
|
|
122
|
+
expect(Array.isArray(purchases.missingIds)).toEqual(true);
|
|
123
|
+
});
|
|
124
|
+
test('should be able to bind a sub-query of another contract', async () => {
|
|
125
|
+
// page: DPNS domains. Sub-query: their transfers in `document-history`, a contract
|
|
126
|
+
// other than the page's one is passed as `dataContract`
|
|
127
|
+
const history = await sdk.dataContracts.getDataContractByIdentifier(DOCUMENT_HISTORY);
|
|
128
|
+
const { pageDocuments, subResults: [transfers] } = await sdk.documents.composite(DPNS, {
|
|
129
|
+
documentTypeName: 'domain',
|
|
130
|
+
where: [['normalizedParentDomainName', '==', 'dash']],
|
|
131
|
+
orderBy: [['normalizedLabel', 'asc']],
|
|
132
|
+
limit: 3
|
|
133
|
+
}, [{
|
|
134
|
+
dataContract: history,
|
|
135
|
+
documentTypeName: 'transfer',
|
|
136
|
+
where: [['dataContractId', '==', DPNS]],
|
|
137
|
+
limit: 2,
|
|
138
|
+
binding: { source: 'page', sourceProperty: '$id', field: 'documentId' }
|
|
139
|
+
}]);
|
|
140
|
+
expect(pageDocuments.length).toEqual(3);
|
|
141
|
+
expect(Array.isArray(transfers.documents)).toEqual(true);
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
/**
|
|
145
|
+
* No contract on testnet declares the indexes these queries need yet, so the examples below
|
|
146
|
+
* show the call and check that the node accepts the request shape and only refuses the missing index
|
|
147
|
+
*/
|
|
148
|
+
describe('ranked, having and chained', () => {
|
|
149
|
+
test('ranked: top groups by count', async () => {
|
|
150
|
+
// needs a single-property index on the `groupBy` field
|
|
151
|
+
await expect(sdk.documents.ranked(DOCUMENT_HISTORY, {
|
|
152
|
+
documentTypeName: 'transfer',
|
|
153
|
+
select: { function: 'count' },
|
|
154
|
+
groupBy: ['dataContractId'],
|
|
155
|
+
where: [['dataContractId', 'in', [DPNS, DOCUMENT_HISTORY]]],
|
|
156
|
+
// order by `$count` for count, by the aggregated field for sum and avg
|
|
157
|
+
orderBy: [['$count', 'desc']],
|
|
158
|
+
limit: 2,
|
|
159
|
+
offset: 0
|
|
160
|
+
})).rejects.toThrow(/ranked%20index|ranked index/);
|
|
161
|
+
});
|
|
162
|
+
test('having: groups whose aggregate is within bounds', async () => {
|
|
163
|
+
// needs the same index as ranked, `limit` is required (1 ..= 100)
|
|
164
|
+
await expect(sdk.documents.having(DOCUMENT_HISTORY, {
|
|
165
|
+
documentTypeName: 'transfer',
|
|
166
|
+
select: { function: 'count' },
|
|
167
|
+
groupBy: ['dataContractId'],
|
|
168
|
+
where: [['dataContractId', 'in', [DPNS, DOCUMENT_HISTORY]]],
|
|
169
|
+
having: [{ function: 'count', operator: '>=', value: 10 }],
|
|
170
|
+
limit: 10
|
|
171
|
+
})).rejects.toThrow(/ranked%20index|ranked index/);
|
|
172
|
+
});
|
|
173
|
+
test('chained: documents and the documents they refer to', async () => {
|
|
174
|
+
// the inner document type must be `indexOnly`
|
|
175
|
+
await expect(sdk.documents.chained(DPNS, { documentTypeName: 'domain', where: [['normalizedParentDomainName', '==', 'dash']], limit: 2 }, 'records.identity', 'domain')).rejects.toThrow(/indexOnly/);
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { IdentifierWASM } from 'pshenmic-dpp';
|
|
2
|
+
import { GetDocumentsRequest_GetDocumentsRequestV1_Select_Function, GetDocumentsRequest_GetDocumentsRequestV1_SubQuery_Kind, GetDocumentsRequest_HavingClause_Operator, GetDocumentsRequest_TimeRangeSelection_Selector, GetDocumentsRequest_WhereOperator } from '../../proto/generated/platform.js';
|
|
3
|
+
import { toFieldValue, toHavingClauses, toOrderClauses, toSelect, toStart, toSubQueries, toWhereClauses } from '../../src/documents/v1.js';
|
|
4
|
+
describe('Documents V1 request conversion', () => {
|
|
5
|
+
test('should convert field values', () => {
|
|
6
|
+
expect(toFieldValue(true).variant).toEqual({ oneofKind: 'boolValue', boolValue: true });
|
|
7
|
+
expect(toFieldValue(5).variant).toEqual({ oneofKind: 'uint64Value', uint64Value: '5' });
|
|
8
|
+
expect(toFieldValue(-5n).variant).toEqual({ oneofKind: 'int64Value', int64Value: '-5' });
|
|
9
|
+
expect(toFieldValue(1.5).variant).toEqual({ oneofKind: 'doubleValue', doubleValue: 1.5 });
|
|
10
|
+
expect(toFieldValue('dash').variant).toEqual({ oneofKind: 'text', text: 'dash' });
|
|
11
|
+
expect(toFieldValue(new Uint8Array([1])).variant).toEqual({ oneofKind: 'bytesValue', bytesValue: new Uint8Array([1]) });
|
|
12
|
+
expect(toFieldValue(null).variant).toEqual({ oneofKind: 'nullValue', nullValue: true });
|
|
13
|
+
expect(toFieldValue(['a', 1]).variant).toEqual({
|
|
14
|
+
oneofKind: 'list',
|
|
15
|
+
list: { values: [toFieldValue('a'), toFieldValue(1)] }
|
|
16
|
+
});
|
|
17
|
+
expect(() => toFieldValue({})).toThrow();
|
|
18
|
+
});
|
|
19
|
+
test('should convert where clauses', () => {
|
|
20
|
+
const [equal, startsWith, containsAny] = toWhereClauses([
|
|
21
|
+
['normalizedParentDomainName', '==', 'dash'],
|
|
22
|
+
['normalizedLabel', 'startsWith', 'a'],
|
|
23
|
+
['tags', 'contains_any', ['x', 'y']]
|
|
24
|
+
]);
|
|
25
|
+
expect(equal).toEqual({ field: 'normalizedParentDomainName', operator: GetDocumentsRequest_WhereOperator.EQUAL, value: toFieldValue('dash') });
|
|
26
|
+
expect(startsWith.operator).toEqual(GetDocumentsRequest_WhereOperator.STARTS_WITH);
|
|
27
|
+
expect(containsAny.operator).toEqual(GetDocumentsRequest_WhereOperator.CONTAINS_ANY);
|
|
28
|
+
expect(toWhereClauses(undefined)).toEqual([]);
|
|
29
|
+
// @ts-expect-error
|
|
30
|
+
expect(() => toWhereClauses([['a', 'like', 'b']])).toThrow();
|
|
31
|
+
});
|
|
32
|
+
test('should convert time and integer range where clauses', () => {
|
|
33
|
+
const [newest, byStart, grid, integer] = toWhereClauses([
|
|
34
|
+
['$createdAt', 'inTimeRange', 'newest'],
|
|
35
|
+
['$createdAt', 'IN_TIME_RANGE', 1700000000000n],
|
|
36
|
+
['$createdAt', 'in_time_range', { selector: 'oldest', grid: { rangeSeconds: 3600, stepSeconds: 60 } }],
|
|
37
|
+
['height', 'inIntegerRange', { start: 100, grid: { range: 10, step: 10 } }]
|
|
38
|
+
]);
|
|
39
|
+
expect(newest.operator).toEqual(GetDocumentsRequest_WhereOperator.IN_TIME_RANGE);
|
|
40
|
+
expect(newest.value).toEqual(undefined);
|
|
41
|
+
expect(newest.timeRange?.selector).toEqual(GetDocumentsRequest_TimeRangeSelection_Selector.NEWEST);
|
|
42
|
+
expect(byStart.timeRange).toEqual(expect.objectContaining({ selector: GetDocumentsRequest_TimeRangeSelection_Selector.BY_START, startMs: '1700000000000' }));
|
|
43
|
+
expect(grid.timeRange?.grid).toEqual({ range: '3600', step: '60', phase: '0' });
|
|
44
|
+
expect(integer.operator).toEqual(GetDocumentsRequest_WhereOperator.IN_INTEGER_RANGE);
|
|
45
|
+
expect(integer.integerRange).toEqual({ start: toFieldValue(100), grid: { range: '10', step: '10', phase: '0' } });
|
|
46
|
+
});
|
|
47
|
+
test('should convert order, select and having clauses', () => {
|
|
48
|
+
expect(toOrderClauses([['$count', 'desc'], ['name', 'asc']])).toEqual([
|
|
49
|
+
{ target: { oneofKind: 'field', field: '$count' }, ascending: false },
|
|
50
|
+
{ target: { oneofKind: 'field', field: 'name' }, ascending: true }
|
|
51
|
+
]);
|
|
52
|
+
expect(toSelect({ function: 'sum', field: 'amount' })).toEqual([
|
|
53
|
+
{ function: GetDocumentsRequest_GetDocumentsRequestV1_Select_Function.SUM, field: 'amount' }
|
|
54
|
+
]);
|
|
55
|
+
expect(toSelect({ function: 'count' })[0].field).toEqual('');
|
|
56
|
+
const [having] = toHavingClauses([{ function: 'count', operator: '>=', value: 10 }]);
|
|
57
|
+
expect(having.operator).toEqual(GetDocumentsRequest_HavingClause_Operator.GREATER_THAN_OR_EQUALS);
|
|
58
|
+
expect(having.right).toEqual({ oneofKind: 'value', value: toFieldValue(10) });
|
|
59
|
+
});
|
|
60
|
+
test('should convert start and sub-queries', () => {
|
|
61
|
+
const id = new IdentifierWASM('GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec');
|
|
62
|
+
expect(toStart(undefined)).toEqual({ oneofKind: undefined });
|
|
63
|
+
expect(toStart(id, true)).toEqual({ oneofKind: 'startAt', startAt: id.bytes() });
|
|
64
|
+
expect(toStart(id, false)).toEqual({ oneofKind: 'startAfter', startAfter: id.bytes() });
|
|
65
|
+
const [fromPage, fromSubQuery] = toSubQueries([
|
|
66
|
+
{ documentTypeName: 'domain', binding: { source: 'page', sourceProperty: '$ownerId', field: '$ownerId' } },
|
|
67
|
+
{ documentTypeName: 'preorder', kind: 'count', binding: { source: 0, sourceProperty: '$id', field: '$id' } }
|
|
68
|
+
], id);
|
|
69
|
+
expect(fromPage.dataContractId).toEqual(id.bytes());
|
|
70
|
+
expect(fromPage.kind).toEqual(GetDocumentsRequest_GetDocumentsRequestV1_SubQuery_Kind.DOCUMENTS);
|
|
71
|
+
expect(fromPage.bind?.source).toEqual(0);
|
|
72
|
+
expect(fromSubQuery.kind).toEqual(GetDocumentsRequest_GetDocumentsRequestV1_SubQuery_Kind.COUNT);
|
|
73
|
+
expect(fromSubQuery.bind?.source).toEqual(1);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
@@ -5,7 +5,6 @@ let sdk;
|
|
|
5
5
|
describe('Identity', () => {
|
|
6
6
|
beforeAll(async () => {
|
|
7
7
|
sdk = new DashPlatformSDK({ network: 'testnet' });
|
|
8
|
-
await sdk.waitForInit();
|
|
9
8
|
});
|
|
10
9
|
test('should be able to get identity by identifier', async () => {
|
|
11
10
|
const identifier = 'QMfCRPcjXoTnZa9sA9JR2KWgGxZXMRJ4akgS3Uia1Qv';
|
package/test/unit/Names.spec.js
CHANGED
|
@@ -9,7 +9,6 @@ let sdk;
|
|
|
9
9
|
describe('DPNS names', () => {
|
|
10
10
|
beforeAll(async () => {
|
|
11
11
|
sdk = new DashPlatformSDK({ network: 'testnet' });
|
|
12
|
-
await sdk.waitForInit();
|
|
13
12
|
// @ts-expect-error
|
|
14
13
|
sleep.mockReturnValue(Promise.resolve());
|
|
15
14
|
sdk.stateTransitions.broadcast = jest.fn();
|
package/test/unit/Node.spec.js
CHANGED
|
@@ -5,7 +5,6 @@ let sdk;
|
|
|
5
5
|
describe('PlatformAddress', () => {
|
|
6
6
|
beforeAll(async () => {
|
|
7
7
|
sdk = new DashPlatformSDK({ network: 'testnet' });
|
|
8
|
-
await sdk.waitForInit();
|
|
9
8
|
});
|
|
10
9
|
test('getAddressInfo', async () => {
|
|
11
10
|
const info = await sdk.platformAddresses.getAddressInfo('tdash1kzg5azscav69z7m6dfzr9ner0a5vt7pn9ca4sz8d');
|
|
@@ -37,7 +37,6 @@ function makeSpendableNote(seed, value) {
|
|
|
37
37
|
describe('Shielded', () => {
|
|
38
38
|
beforeAll(async () => {
|
|
39
39
|
sdk = new DashPlatformSDK({ network: 'testnet' });
|
|
40
|
-
await sdk.waitForInit();
|
|
41
40
|
await sdk.shielded.init();
|
|
42
41
|
}, 60000);
|
|
43
42
|
test('getShieldedNotesCount', async () => {
|
package/test/unit/Tokens.spec.js
CHANGED
|
@@ -4,7 +4,6 @@ let sdk;
|
|
|
4
4
|
describe('Tokens', () => {
|
|
5
5
|
beforeAll(async () => {
|
|
6
6
|
sdk = new DashPlatformSDK({ network: 'testnet' });
|
|
7
|
-
await sdk.waitForInit();
|
|
8
7
|
});
|
|
9
8
|
test('should be able to get token total supply', async () => {
|
|
10
9
|
const tokenTotalSupply = await sdk.tokens.getTokenTotalSupply('9YxdbQUjJmQsmVPen95HjAU3Esj7tVkWSY2EQWT84ZQP');
|
package/types.d.ts
CHANGED
|
@@ -1,9 +1,27 @@
|
|
|
1
|
-
import { AddressFundsFeeStrategyStepWASM, AssetLockProofWASM, CoreScriptWASM, DocumentWASM, GasFeesPaidByWASM, IdentifierLike, IdentifierWASM, InputAddressWASM, KeyType, OrchardAddressWASM, PlatformAddressLike, PlatformAddressWASM, PlatformVersionWASM, PoolingLike, PrivateKeyWASM, Purpose, SecurityLevel, ShieldedOutputWASM, SpendableNoteWASM, TokenEmergencyActionWASM, TokenPricingScheduleWASM, AddressWitnessWASM, IdentityPublicKeyInCreationWASM, OutputAddressWASM, OutputAddressNullableCreditsWASM, VerifiedAddressesTrunkState } from 'pshenmic-dpp';
|
|
1
|
+
import { AddressFundsFeeStrategyStepWASM, AssetLockProofWASM, CoreScriptWASM, DocumentActionFeeAgreementWASM, DocumentWASM, GasFeesPaidByWASM, IdentifierLike, IdentifierWASM, InputAddressWASM, KeyType, OrchardAddressWASM, PlatformAddressLike, PlatformAddressWASM, PlatformVersionWASM, PoolingLike, PrivateKeyWASM, Purpose, SecurityLevel, ShieldedOutputWASM, SpendableNoteWASM, TokenEmergencyActionWASM, TokenPricingScheduleWASM, AddressWitnessWASM, IdentityPublicKeyInCreationWASM, OutputAddressWASM, OutputAddressNullableCreditsWASM, VerifiedAddressesTrunkState } from 'pshenmic-dpp';
|
|
2
2
|
import { ResponseMetadata } from './proto/generated/platform.js';
|
|
3
3
|
export { CoreScriptWASM, DocumentWASM, GasFeesPaidByWASM, IdentifierWASM, KeyType, Purpose, SecurityLevel, TokenEmergencyActionWASM, TokenPricingScheduleWASM, StateTransitionWASM, BatchTransitionWASM, IdentityPublicKeyWASM, PrivateKeyWASM, DataContractUpdateTransitionWASM, IdentityWASM, IdentityUpdateTransitionWASM, IdentityCreditTransferWASM, MasternodeVoteTransitionWASM, IdentifierLike, PlatformAddressLike, InputAddressWASM, OutputAddressWASM, OutputAddressNullableCreditsWASM, AddressFundsFeeStrategyStepWASM, AddressWitnessWASM, IdentityPublicKeyInCreationWASM, AssetLockProofWASM, IdentityCreditTransferToAddressesTransitionWASM, IdentityCreateFromAddressesTransitionWASM, IdentityTopUpFromAddressesTransitionWASM, AddressFundsTransferTransitionWASM, AddressFundingFromAssetLockTransitionWASM, AddressCreditWithdrawalTransitionWASM } from 'pshenmic-dpp';
|
|
4
4
|
export type Network = 'mainnet' | 'testnet';
|
|
5
5
|
export { DashPlatformSDK } from './src/DashPlatformSDK.js';
|
|
6
6
|
export type MasternodeList = Record<string, MasternodeInfo>;
|
|
7
|
+
export type DocumentTransitionType = 'create' | 'replace' | 'delete' | 'updatePrice' | 'transfer' | 'purchase';
|
|
8
|
+
/**
|
|
9
|
+
* The action fee a document transition agrees to pay to the contract fee pots (protocol v14).
|
|
10
|
+
* Required when the document type declares `actionFees` for the action, ignored otherwise
|
|
11
|
+
*/
|
|
12
|
+
export interface DocumentActionFeeAgreement {
|
|
13
|
+
/** owner part the document type declares for the action, in credits */
|
|
14
|
+
owner: bigint;
|
|
15
|
+
/** moderators part the document type declares for the action, in credits */
|
|
16
|
+
moderators: bigint;
|
|
17
|
+
/** set when the fee is priced by the epoch fee multiplier, omit for a fixed fee */
|
|
18
|
+
feeMultiplier?: {
|
|
19
|
+
/** fee multiplier of the current epoch, in permille */
|
|
20
|
+
knownPermille: bigint;
|
|
21
|
+
/** how far above the known multiplier the executing epoch's one may be, in percent */
|
|
22
|
+
increaseTolerancePercent: number;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
7
25
|
export interface DocumentTransitionParams {
|
|
8
26
|
identityContractNonce: bigint;
|
|
9
27
|
amount?: bigint;
|
|
@@ -20,6 +38,7 @@ export interface DocumentTransitionParams {
|
|
|
20
38
|
maximumTokenCost?: bigint;
|
|
21
39
|
gasFeesPaidBy: GasFeesPaidByWASM;
|
|
22
40
|
};
|
|
41
|
+
actionFeeAgreement?: DocumentActionFeeAgreement | DocumentActionFeeAgreementWASM;
|
|
23
42
|
}
|
|
24
43
|
export interface ShieldedTransitionBaseParams {
|
|
25
44
|
/** version of the platform (defaults to the latest supported version) */
|