pshenmic-dpp 2.0.0-dev.1 → 2.0.0-dev.10
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/dist/binaries/bindingsTypes.d.ts +48 -23
- package/dist/binaries/bindingsTypes.js +4 -3
- package/dist/binaries/pshenmic_dpp.android.node/x86_64/libpshenmic_dpp.so +0 -0
- package/dist/binaries/pshenmic_dpp.d.ts +6 -1
- package/dist/binaries/pshenmic_dpp.js +1 -1
- package/dist/binaries/wasm/wasmBytes.js +1 -1
- package/dist/binaries/wasm.d.ts +6 -1
- package/dist/binaries/wasm.js +1 -1
- package/dist/src/dpp/dpp.d.ts +4 -2
- package/dist/src/dpp/dpp.js +4 -2
- package/dist/src/dpp/enums.d.ts +1 -1
- package/dist/src/dpp/enums.js +1 -1
- package/dist/src/dpp/structs/AddressTransitions/AddressCreditWithdrawalTransition.d.ts +2 -2
- package/dist/src/dpp/structs/AddressTransitions/AddressCreditWithdrawalTransition.js +2 -2
- package/dist/src/dpp/structs/AddressTransitions/AddressFundingFromAssetLockTransition.d.ts +2 -2
- package/dist/src/dpp/structs/AddressTransitions/AddressFundingFromAssetLockTransition.js +3 -3
- package/dist/src/dpp/structs/AddressTransitions/AddressFundsTransferTransition.d.ts +2 -2
- package/dist/src/dpp/structs/AddressTransitions/AddressFundsTransferTransition.js +3 -3
- package/dist/src/dpp/structs/AddressTransitions/IdentityCreateFromAddressesTransition.d.ts +2 -2
- package/dist/src/dpp/structs/AddressTransitions/IdentityCreateFromAddressesTransition.js +2 -2
- package/dist/src/dpp/structs/AddressTransitions/IdentityCreditTransferToAddressesTransition.d.ts +1 -1
- package/dist/src/dpp/structs/AddressTransitions/IdentityCreditTransferToAddressesTransition.js +1 -1
- package/dist/src/dpp/structs/AddressTransitions/IdentityTopUpFromAddressesTransition.d.ts +2 -2
- package/dist/src/dpp/structs/AddressTransitions/IdentityTopUpFromAddressesTransition.js +2 -2
- package/dist/src/dpp/structs/AddressTransitions/entities/AddressFundsFeeStrategyStep.d.ts +1 -1
- package/dist/src/dpp/structs/AddressTransitions/entities/InputAddress.d.ts +5 -4
- package/dist/src/dpp/structs/AddressTransitions/entities/InputAddress.js +5 -4
- package/dist/src/dpp/structs/AddressTransitions/entities/OutputAddress.d.ts +5 -4
- package/dist/src/dpp/structs/AddressTransitions/entities/OutputAddress.js +5 -4
- package/dist/src/dpp/structs/AddressTransitions/entities/OutputAddressNullableCredits.d.ts +5 -4
- package/dist/src/dpp/structs/AddressTransitions/entities/OutputAddressNullableCredits.js +5 -4
- package/dist/src/dpp/structs/AssetLockProof/AssetLockProof.d.ts +1 -1
- package/dist/src/dpp/structs/AssetLockProof/AssetLockProof.js +2 -3
- package/dist/src/dpp/structs/AssetLockProof/ChainAssetLockProof.d.ts +1 -1
- package/dist/src/dpp/structs/AssetLockProof/ChainAssetLockProof.js +2 -2
- package/dist/src/dpp/structs/AssetLockProof/InstantAssetLockProof.d.ts +1 -1
- package/dist/src/dpp/structs/AssetLockProof/InstantAssetLockProof.js +1 -1
- package/dist/src/dpp/structs/AssetLockProof/OutPoint.d.ts +1 -1
- package/dist/src/dpp/structs/AssetLockProof/OutPoint.js +1 -1
- package/dist/src/dpp/structs/AssetLockProof/Transaction.d.ts +1 -1
- package/dist/src/dpp/structs/AssetLockProof/Transaction.js +1 -1
- package/dist/src/dpp/structs/AssetLockProof/TxIn.d.ts +1 -1
- package/dist/src/dpp/structs/AssetLockProof/TxIn.js +1 -1
- package/dist/src/dpp/structs/AssetLockProof/TxOut.d.ts +1 -1
- package/dist/src/dpp/structs/AssetLockProof/TxOut.js +1 -1
- package/dist/src/dpp/structs/AssetLockProof/Witness.d.ts +1 -1
- package/dist/src/dpp/structs/AssetLockProof/Witness.js +1 -1
- package/dist/src/dpp/structs/Batch/BatchTransition.d.ts +1 -1
- package/dist/src/dpp/structs/Batch/BatchTransition.js +1 -1
- package/dist/src/dpp/structs/Batch/BatchedTransition.d.ts +3 -2
- package/dist/src/dpp/structs/Batch/BatchedTransition.js +1 -1
- package/dist/src/dpp/structs/Batch/DocumentBaseTransition.d.ts +3 -3
- package/dist/src/dpp/structs/Batch/DocumentBaseTransition.js +3 -3
- package/dist/src/dpp/structs/Batch/DocumentTransition.d.ts +2 -1
- package/dist/src/dpp/structs/Batch/DocumentTransition.js +4 -1
- package/dist/src/dpp/structs/Batch/DocumentTransitions/DocumentCreateTransition.d.ts +2 -2
- package/dist/src/dpp/structs/Batch/DocumentTransitions/DocumentCreateTransition.js +2 -2
- package/dist/src/dpp/structs/Batch/DocumentTransitions/DocumentDeleteTransition.d.ts +1 -1
- package/dist/src/dpp/structs/Batch/DocumentTransitions/DocumentDeleteTransition.js +1 -1
- package/dist/src/dpp/structs/Batch/DocumentTransitions/DocumentPurchaseTransition.d.ts +1 -1
- package/dist/src/dpp/structs/Batch/DocumentTransitions/DocumentPurchaseTransition.js +1 -1
- package/dist/src/dpp/structs/Batch/DocumentTransitions/DocumentReplaceTransition.d.ts +2 -2
- package/dist/src/dpp/structs/Batch/DocumentTransitions/DocumentReplaceTransition.js +2 -2
- package/dist/src/dpp/structs/Batch/DocumentTransitions/DocumentTransferTransition.d.ts +1 -1
- package/dist/src/dpp/structs/Batch/DocumentTransitions/DocumentTransferTransition.js +1 -1
- package/dist/src/dpp/structs/Batch/DocumentTransitions/DocumentUpdatePriceTransition.d.ts +1 -1
- package/dist/src/dpp/structs/Batch/DocumentTransitions/DocumentUpdatePriceTransition.js +1 -1
- package/dist/src/dpp/structs/Batch/PrefundedVotingBalance.d.ts +1 -1
- package/dist/src/dpp/structs/Batch/PrefundedVotingBalance.js +1 -1
- package/dist/src/dpp/structs/Batch/TokenBaseTransition.d.ts +1 -1
- package/dist/src/dpp/structs/Batch/TokenBaseTransition.js +1 -1
- package/dist/src/dpp/structs/Batch/TokenPaymentInfo.d.ts +2 -2
- package/dist/src/dpp/structs/Batch/TokenPaymentInfo.js +2 -2
- package/dist/src/dpp/structs/Batch/TokenPricingSchedule.d.ts +1 -1
- package/dist/src/dpp/structs/Batch/TokenPricingSchedule.js +1 -1
- package/dist/src/dpp/structs/Batch/TokenTransition.d.ts +3 -2
- package/dist/src/dpp/structs/Batch/TokenTransition.js +4 -1
- package/dist/src/dpp/structs/Batch/TokenTransitions/TokenBurnTransition.d.ts +1 -1
- package/dist/src/dpp/structs/Batch/TokenTransitions/TokenBurnTransition.js +1 -1
- package/dist/src/dpp/structs/Batch/TokenTransitions/TokenClaimTransition.d.ts +1 -1
- package/dist/src/dpp/structs/Batch/TokenTransitions/TokenClaimTransition.js +1 -1
- package/dist/src/dpp/structs/Batch/TokenTransitions/TokenConfigUpdateTransition.d.ts +1 -1
- package/dist/src/dpp/structs/Batch/TokenTransitions/TokenConfigUpdateTransition.js +1 -1
- package/dist/src/dpp/structs/Batch/TokenTransitions/TokenDestroyFrozenFundsTransition.d.ts +1 -1
- package/dist/src/dpp/structs/Batch/TokenTransitions/TokenDestroyFrozenFundsTransition.js +1 -1
- package/dist/src/dpp/structs/Batch/TokenTransitions/TokenDirectPurchaseTransition.d.ts +1 -1
- package/dist/src/dpp/structs/Batch/TokenTransitions/TokenDirectPurchaseTransition.js +1 -1
- package/dist/src/dpp/structs/Batch/TokenTransitions/TokenEmergencyActionTransition.d.ts +1 -1
- package/dist/src/dpp/structs/Batch/TokenTransitions/TokenEmergencyActionTransition.js +1 -1
- package/dist/src/dpp/structs/Batch/TokenTransitions/TokenFreezeTransition.d.ts +1 -1
- package/dist/src/dpp/structs/Batch/TokenTransitions/TokenFreezeTransition.js +1 -1
- package/dist/src/dpp/structs/Batch/TokenTransitions/TokenMintTransition.d.ts +2 -2
- package/dist/src/dpp/structs/Batch/TokenTransitions/TokenMintTransition.js +2 -2
- package/dist/src/dpp/structs/Batch/TokenTransitions/TokenSetPriceForDirectPurchaseTransition.d.ts +1 -1
- package/dist/src/dpp/structs/Batch/TokenTransitions/TokenSetPriceForDirectPurchaseTransition.js +1 -1
- package/dist/src/dpp/structs/Batch/TokenTransitions/TokenTransferTransition.d.ts +4 -1
- package/dist/src/dpp/structs/Batch/TokenTransitions/TokenTransferTransition.js +8 -1
- package/dist/src/dpp/structs/Batch/TokenTransitions/TokenUnFreezeTransition.d.ts +1 -1
- package/dist/src/dpp/structs/Batch/TokenTransitions/TokenUnFreezeTransition.js +1 -1
- package/dist/src/dpp/structs/ConsensusError.d.ts +2 -2
- package/dist/src/dpp/structs/ConsensusError.js +1 -1
- package/dist/src/dpp/structs/ContractBounds.d.ts +1 -1
- package/dist/src/dpp/structs/ContractBounds.js +1 -1
- package/dist/src/dpp/structs/CoreScript.d.ts +1 -1
- package/dist/src/dpp/structs/CoreScript.js +1 -1
- package/dist/src/dpp/structs/DataContract.d.ts +9 -6
- package/dist/src/dpp/structs/DataContract.js +12 -3
- package/dist/src/dpp/structs/DataContractTransitions/DataContractCreateTransition.d.ts +1 -1
- package/dist/src/dpp/structs/DataContractTransitions/DataContractCreateTransition.js +1 -1
- package/dist/src/dpp/structs/DataContractTransitions/DataContractUpdateTransition.d.ts +1 -1
- package/dist/src/dpp/structs/DataContractTransitions/DataContractUpdateTransition.js +1 -1
- package/dist/src/dpp/structs/Document.d.ts +3 -3
- package/dist/src/dpp/structs/Document.js +3 -3
- package/dist/src/dpp/structs/EncryptedNote/PrivateEncryptedNote.d.ts +1 -1
- package/dist/src/dpp/structs/EncryptedNote/PrivateEncryptedNote.js +1 -1
- package/dist/src/dpp/structs/EncryptedNote/SharedEncryptedNote.d.ts +1 -1
- package/dist/src/dpp/structs/EncryptedNote/SharedEncryptedNote.js +1 -1
- package/dist/src/dpp/structs/GroupStateTransitionInfo.d.ts +1 -1
- package/dist/src/dpp/structs/GroupStateTransitionInfo.js +1 -1
- package/dist/src/dpp/structs/Identifier.d.ts +1 -1
- package/dist/src/dpp/structs/Identifier.js +1 -1
- package/dist/src/dpp/structs/Identity.d.ts +1 -1
- package/dist/src/dpp/structs/Identity.js +1 -1
- package/dist/src/dpp/structs/IdentityPublicKey.d.ts +2 -1
- package/dist/src/dpp/structs/IdentityPublicKey.js +6 -1
- package/dist/src/dpp/structs/IdentityPublicKeyInCreation.d.ts +2 -1
- package/dist/src/dpp/structs/IdentityPublicKeyInCreation.js +6 -1
- package/dist/src/dpp/structs/IdentityTransitions/IdentityCreateTransition.d.ts +1 -1
- package/dist/src/dpp/structs/IdentityTransitions/IdentityCreateTransition.js +1 -1
- package/dist/src/dpp/structs/IdentityTransitions/IdentityCreditTransfer.d.ts +1 -1
- package/dist/src/dpp/structs/IdentityTransitions/IdentityCreditTransfer.js +1 -1
- package/dist/src/dpp/structs/IdentityTransitions/IdentityCreditWithdrawalTransition.d.ts +2 -2
- package/dist/src/dpp/structs/IdentityTransitions/IdentityCreditWithdrawalTransition.js +1 -1
- package/dist/src/dpp/structs/IdentityTransitions/IdentityTopUpTransition.d.ts +2 -2
- package/dist/src/dpp/structs/IdentityTransitions/IdentityTopUpTransition.js +2 -2
- package/dist/src/dpp/structs/IdentityTransitions/IdentityUpdateTransition.d.ts +2 -2
- package/dist/src/dpp/structs/IdentityTransitions/IdentityUpdateTransition.js +2 -2
- package/dist/src/dpp/structs/InstantLock.d.ts +1 -1
- package/dist/src/dpp/structs/InstantLock.js +1 -1
- package/dist/src/dpp/structs/MasternodeVote/MasternodeVoteTransition.d.ts +1 -1
- package/dist/src/dpp/structs/MasternodeVote/MasternodeVoteTransition.js +1 -1
- package/dist/src/dpp/structs/MasternodeVote/ResourceVoteChoice.d.ts +1 -1
- package/dist/src/dpp/structs/MasternodeVote/Vote.d.ts +1 -1
- package/dist/src/dpp/structs/MasternodeVote/Vote.js +1 -1
- package/dist/src/dpp/structs/MasternodeVote/VotePoll.d.ts +2 -2
- package/dist/src/dpp/structs/MasternodeVote/VotePoll.js +3 -3
- package/dist/src/dpp/structs/PartialIdentity.d.ts +1 -1
- package/dist/src/dpp/structs/PartialIdentity.js +1 -1
- package/dist/src/dpp/structs/{Address → PlatformAddress}/AddressWitness.d.ts +3 -3
- package/dist/src/dpp/structs/{Address → PlatformAddress}/AddressWitness.js +2 -2
- package/dist/src/dpp/structs/{Address → PlatformAddress}/PlatformAddress.d.ts +5 -3
- package/dist/src/dpp/structs/{Address → PlatformAddress}/PlatformAddress.js +9 -3
- package/dist/src/dpp/structs/PrivateKey.d.ts +1 -1
- package/dist/src/dpp/structs/PrivateKey.js +1 -1
- package/dist/src/dpp/structs/PublicKey.d.ts +1 -1
- package/dist/src/dpp/structs/PublicKey.js +1 -1
- package/dist/src/dpp/structs/StateTransition.d.ts +2 -1
- package/dist/src/dpp/structs/StateTransition.js +3 -0
- package/dist/src/dpp/structs/TokenConfiguration/ActionTaker.d.ts +2 -2
- package/dist/src/dpp/structs/TokenConfiguration/ActionTaker.js +1 -1
- package/dist/src/dpp/structs/TokenConfiguration/AuthorizedActionTakers.d.ts +1 -1
- package/dist/src/dpp/structs/TokenConfiguration/ChangeControlRules.d.ts +1 -1
- package/dist/src/dpp/structs/TokenConfiguration/ChangeControlRules.js +1 -1
- package/dist/src/dpp/structs/TokenConfiguration/DistributionFunction.d.ts +1 -1
- package/dist/src/dpp/structs/TokenConfiguration/Group.d.ts +1 -1
- package/dist/src/dpp/structs/TokenConfiguration/Group.js +1 -1
- package/dist/src/dpp/structs/TokenConfiguration/RewardDistributionType.d.ts +1 -1
- package/dist/src/dpp/structs/TokenConfiguration/TokenConfiguration.d.ts +1 -1
- package/dist/src/dpp/structs/TokenConfiguration/TokenConfiguration.js +1 -1
- package/dist/src/dpp/structs/TokenConfiguration/TokenConfigurationChangeItem.d.ts +1 -1
- package/dist/src/dpp/structs/TokenConfiguration/TokenConfigurationConvention.d.ts +1 -1
- package/dist/src/dpp/structs/TokenConfiguration/TokenConfigurationConvention.js +1 -1
- package/dist/src/dpp/structs/TokenConfiguration/TokenConfigurationLocalization.d.ts +1 -1
- package/dist/src/dpp/structs/TokenConfiguration/TokenConfigurationLocalization.js +1 -1
- package/dist/src/dpp/structs/TokenConfiguration/TokenDistributionRecipient.d.ts +1 -1
- package/dist/src/dpp/structs/TokenConfiguration/TokenDistributionRules.d.ts +1 -1
- package/dist/src/dpp/structs/TokenConfiguration/TokenDistributionRules.js +1 -1
- package/dist/src/dpp/structs/TokenConfiguration/TokenKeepsHistoryRules.d.ts +1 -1
- package/dist/src/dpp/structs/TokenConfiguration/TokenKeepsHistoryRules.js +1 -1
- package/dist/src/dpp/structs/TokenConfiguration/TokenMarketplaceRules.d.ts +1 -1
- package/dist/src/dpp/structs/TokenConfiguration/TokenMarketplaceRules.js +1 -1
- package/dist/src/dpp/structs/TokenConfiguration/TokenPerpetualDistribution.d.ts +1 -1
- package/dist/src/dpp/structs/TokenConfiguration/TokenPerpetualDistribution.js +1 -1
- package/dist/src/dpp/structs/TokenConfiguration/TokenPreProgrammedDistribution.d.ts +1 -1
- package/dist/src/dpp/structs/TokenConfiguration/TokenPreProgrammedDistribution.js +1 -1
- package/dist/src/dpp/structs/TokenConfiguration/TokenTradeMode.d.ts +1 -1
- package/dist/src/dpp/types.d.ts +50 -40
- package/dist/src/dpp/utils.d.ts +4 -3
- package/dist/src/dpp/utils.js +38 -6
- package/dist/src/dpp/verify/Contested/verifyVotePollVoteStateProof.d.ts +1 -1
- package/dist/src/dpp/verify/Contested/verifyVotePollVoteStateProof.js +1 -1
- package/dist/src/dpp/verify/Document/verifyDocumentsProof.d.ts +1 -1
- package/dist/src/dpp/verify/Document/verifyDocumentsProof.js +1 -1
- package/dist/src/dpp/verify/PlatformAddress/verifyPlatformAddressInfo.d.ts +2 -0
- package/dist/src/dpp/verify/PlatformAddress/verifyPlatformAddressInfo.js +12 -0
- package/dist/src/dpp/verify/PlatformAddress/verifyPlatformAddressesInfos.d.ts +2 -0
- package/dist/src/dpp/verify/PlatformAddress/verifyPlatformAddressesInfos.js +14 -0
- package/dist/src/dpp/verify/StateTransition/utils.js +8 -8
- package/dist/src/dpp/verify/System/verifyEpochsInfoProof.js +1 -1
- package/dist/src/dpp/verify/Tokens/verifyTokenBalancesForIdentitiesProof.js +1 -1
- package/dist/src/dpp/verify/Tokens/verifyTokenDirectPurchasePrices.js +1 -1
- package/dist/src/dpp/verify/Tokens/verifyTokensBalancesForIdentityProof.js +1 -1
- package/package.json +3 -3
- package/tests/unit/DynamicValue.spec.ts +40 -0
package/dist/src/dpp/utils.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { dppProvider } from './provider.js';
|
|
2
2
|
import { UINT32MAX } from './constants.js';
|
|
3
3
|
import { IdentifierWASM } from './structs/Identifier.js';
|
|
4
|
+
import { PlatformAddressWASM } from './structs/PlatformAddress/PlatformAddress.js';
|
|
4
5
|
export function valueToDynamicValue(value) {
|
|
5
|
-
if (typeof value === 'bigint' || value > UINT32MAX) {
|
|
6
|
+
if (typeof value === 'bigint' || (value > UINT32MAX && typeof value !== 'string')) {
|
|
6
7
|
return dppProvider.dpp.DynamicValue.fromBigIntString(BigInt(value.toString()).toString());
|
|
7
8
|
}
|
|
8
9
|
else if (value instanceof IdentifierWASM || value instanceof dppProvider.dpp.IdentifierNAPI) {
|
|
@@ -25,25 +26,45 @@ export function valueToDynamicValue(value) {
|
|
|
25
26
|
else if (typeof value === 'function') {
|
|
26
27
|
throw new Error('Cannot parse value from function');
|
|
27
28
|
}
|
|
29
|
+
if (typeof value === 'number') {
|
|
30
|
+
// we cannot strongly pass uint or float without js layer check
|
|
31
|
+
if (Number.isInteger(value)) {
|
|
32
|
+
if (value > 4294967295 || value < 0) {
|
|
33
|
+
return dppProvider.dpp.DynamicValue.fromInt(value);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
return dppProvider.dpp.DynamicValue.fromUInt(value);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
return dppProvider.dpp.DynamicValue.fromFloat(value);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
28
43
|
else {
|
|
29
44
|
return new dppProvider.dpp.DynamicValue(value);
|
|
30
45
|
}
|
|
31
46
|
}
|
|
32
|
-
export function valueFromDynamicValue(dynamicValue) {
|
|
47
|
+
export function valueFromDynamicValue(dynamicValue, jsonLike = false) {
|
|
33
48
|
if (dynamicValue.value instanceof dppProvider.dpp.DynamicValue) {
|
|
34
|
-
return
|
|
49
|
+
return valueFromDynamicValue(dynamicValue.value, jsonLike);
|
|
35
50
|
}
|
|
36
51
|
else if (dynamicValue.isBigInt()) {
|
|
37
|
-
|
|
52
|
+
const num = BigInt(dynamicValue.value);
|
|
53
|
+
if (jsonLike && num < BigInt(Number.MAX_SAFE_INTEGER) && num > BigInt(Number.MIN_SAFE_INTEGER)) {
|
|
54
|
+
return Number(dynamicValue.value);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
return num;
|
|
58
|
+
}
|
|
38
59
|
}
|
|
39
60
|
else if (Array.isArray(dynamicValue.value)) {
|
|
40
|
-
return dynamicValue.value.map(valueFromDynamicValue);
|
|
61
|
+
return dynamicValue.value.map(v => valueFromDynamicValue(v, jsonLike));
|
|
41
62
|
}
|
|
42
63
|
else if (typeof dynamicValue.value === 'object' && !(dynamicValue.value instanceof Uint8Array) && dynamicValue.value !== null) {
|
|
43
64
|
const obj = {};
|
|
44
65
|
const keys = Object.keys(dynamicValue.value);
|
|
45
66
|
for (const key of keys) {
|
|
46
|
-
obj[key] = valueFromDynamicValue(dynamicValue.value[key]);
|
|
67
|
+
obj[key] = valueFromDynamicValue(dynamicValue.value[key], jsonLike);
|
|
47
68
|
}
|
|
48
69
|
return obj;
|
|
49
70
|
}
|
|
@@ -62,3 +83,14 @@ export function prepareIdentifierValue(identifier) {
|
|
|
62
83
|
return new dppProvider.dpp.DynamicValue(identifier);
|
|
63
84
|
}
|
|
64
85
|
}
|
|
86
|
+
export function preparePlatformAddressValue(address) {
|
|
87
|
+
if (address instanceof PlatformAddressWASM) {
|
|
88
|
+
return address._rawPlatformAddress;
|
|
89
|
+
}
|
|
90
|
+
else if (address instanceof dppProvider.dpp.PlatformAddressNAPI) {
|
|
91
|
+
return address;
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
return new dppProvider.dpp.DynamicValue(address);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { PlatformVersionLike, StartAt, VerifiedVoteState, VoteStateResultTypeLike } from '../../types.js';
|
|
2
2
|
import { DataContractWASM } from '../../structs/DataContract.js';
|
|
3
|
-
export declare function verifyVotePollVoteStateProof(proof: Uint8Array, contract: DataContractWASM, documentTypeName: string, indexName: string, indexValues:
|
|
3
|
+
export declare function verifyVotePollVoteStateProof(proof: Uint8Array, contract: DataContractWASM, documentTypeName: string, indexName: string, indexValues: Uint8Array[], resultType: VoteStateResultTypeLike, allowIncludeLockedAndAbstainingVoteTally: boolean | undefined, count: number | undefined, startAt: StartAt | undefined, platformVersion: PlatformVersionLike): VerifiedVoteState;
|
|
@@ -2,7 +2,7 @@ import { dppProvider } from '../../provider.js';
|
|
|
2
2
|
import { valueFromDynamicValue, valueToDynamicValue } from '../../utils.js';
|
|
3
3
|
import { IdentifierWASM } from '../../structs/Identifier.js';
|
|
4
4
|
export function verifyVotePollVoteStateProof(proof, contract, documentTypeName, indexName, indexValues, resultType, allowIncludeLockedAndAbstainingVoteTally, count, startAt, platformVersion) {
|
|
5
|
-
const result = dppProvider.dpp.verifyVotePollVoteStateProof(proof, contract._rawDataContract, documentTypeName, indexName,
|
|
5
|
+
const result = dppProvider.dpp.verifyVotePollVoteStateProof(proof, contract._rawDataContract, documentTypeName, indexName, indexValues, valueToDynamicValue(resultType), allowIncludeLockedAndAbstainingVoteTally ?? false, count, valueToDynamicValue(startAt), valueToDynamicValue(platformVersion));
|
|
6
6
|
const winner = valueFromDynamicValue(result.result.winner);
|
|
7
7
|
const winnerBlockInfo = winner?.blockInfo;
|
|
8
8
|
const outWinner = winner != null
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { IdentifierLike, PlatformVersionLike, VerifiedDocuments, WhereClause } from '../../types.js';
|
|
2
2
|
import { DataContractWASM } from '../../structs/DataContract.js';
|
|
3
|
-
export declare function verifyDocumentsProof(proof: Uint8Array, contract: DataContractWASM, documentTypeName: string, whereClauses: WhereClause[], orderBy: string[][], limit: number | undefined | null, startAt: IdentifierLike | undefined | null, startAtIncluded: boolean, blockTimeMs: bigint | undefined | null, platformVersion: PlatformVersionLike): VerifiedDocuments;
|
|
3
|
+
export declare function verifyDocumentsProof(proof: Uint8Array, contract: DataContractWASM, documentTypeName: string, whereClauses: WhereClause[] | undefined, orderBy: string[][] | undefined, limit: number | undefined | null, startAt: IdentifierLike | undefined | null, startAtIncluded: boolean, blockTimeMs: bigint | undefined | null, platformVersion: PlatformVersionLike): VerifiedDocuments;
|
|
@@ -2,7 +2,7 @@ import { dppProvider } from '../../provider.js';
|
|
|
2
2
|
import { DocumentWASM } from '../../structs/Document.js';
|
|
3
3
|
import { prepareIdentifierValue, valueToDynamicValue } from '../../utils.js';
|
|
4
4
|
export function verifyDocumentsProof(proof, contract, documentTypeName, whereClauses, orderBy, limit, startAt, startAtIncluded, blockTimeMs, platformVersion) {
|
|
5
|
-
const result = dppProvider.dpp.verifyDocumentsProof(proof, contract._rawDataContract, documentTypeName, valueToDynamicValue(whereClauses), orderBy, limit, startAt != null ? prepareIdentifierValue(startAt) : undefined, startAtIncluded, blockTimeMs?.toString(), valueToDynamicValue(platformVersion));
|
|
5
|
+
const result = dppProvider.dpp.verifyDocumentsProof(proof, contract._rawDataContract, documentTypeName, valueToDynamicValue(whereClauses), orderBy ?? [], limit, startAt != null ? prepareIdentifierValue(startAt) : undefined, startAtIncluded, blockTimeMs?.toString(), valueToDynamicValue(platformVersion));
|
|
6
6
|
return {
|
|
7
7
|
rootHash: result.rootHash,
|
|
8
8
|
documents: result.documents.map(DocumentWASM.createFromRawInstance)
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { PlatformAddressLike, PlatformVersionLike, VerifiedPlatformAddressInfoWithRootHash } from '../../types.js';
|
|
2
|
+
export declare function verifyPlatformAddressInfo(proof: Uint8Array, platformAddress: PlatformAddressLike, verifySubsetOfProof: boolean, platformVersion: PlatformVersionLike): VerifiedPlatformAddressInfoWithRootHash;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { dppProvider } from '../../provider.js';
|
|
2
|
+
import { preparePlatformAddressValue, valueToDynamicValue } from '../../utils.js';
|
|
3
|
+
import { PlatformAddressWASM } from '../../structs/PlatformAddress/PlatformAddress.js';
|
|
4
|
+
export function verifyPlatformAddressInfo(proof, platformAddress, verifySubsetOfProof, platformVersion) {
|
|
5
|
+
const result = dppProvider.dpp.verifyAddressInfo(proof, preparePlatformAddressValue(platformAddress), verifySubsetOfProof, valueToDynamicValue(platformVersion));
|
|
6
|
+
return {
|
|
7
|
+
rootHash: result.rootHash,
|
|
8
|
+
address: result.address != null ? PlatformAddressWASM.createFromRawInstance(result.address) : undefined,
|
|
9
|
+
balance: result.balance != null ? BigInt(result.balance) : undefined,
|
|
10
|
+
nonce: result.nonce
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { PlatformAddressLike, PlatformVersionLike, VerifiedPlatformAddressesInfosWithRootHash } from '../../types.js';
|
|
2
|
+
export declare function verifyPlatformAddressesInfos(proof: Uint8Array, platformAddresses: PlatformAddressLike[], verifySubsetOfProof: boolean, platformVersion: PlatformVersionLike): VerifiedPlatformAddressesInfosWithRootHash;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { dppProvider } from '../../provider.js';
|
|
2
|
+
import { preparePlatformAddressValue, valueToDynamicValue } from '../../utils.js';
|
|
3
|
+
import { PlatformAddressWASM } from '../../structs/PlatformAddress/PlatformAddress.js';
|
|
4
|
+
export function verifyPlatformAddressesInfos(proof, platformAddresses, verifySubsetOfProof, platformVersion) {
|
|
5
|
+
const result = dppProvider.dpp.verifyAddressesInfos(proof, platformAddresses.map(preparePlatformAddressValue), verifySubsetOfProof, valueToDynamicValue(platformVersion));
|
|
6
|
+
return {
|
|
7
|
+
rootHash: result.rootHash,
|
|
8
|
+
infos: result.infos.map(({ nonce, credits, address }) => ({
|
|
9
|
+
nonce,
|
|
10
|
+
balance: credits != null ? BigInt(credits) : undefined,
|
|
11
|
+
address: PlatformAddressWASM.createFromRawInstance(address)
|
|
12
|
+
}))
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -5,7 +5,7 @@ import { TokenPricingScheduleWASM } from '../../structs/Batch/TokenPricingSchedu
|
|
|
5
5
|
import { PartialIdentityWASM } from '../../structs/PartialIdentity.js';
|
|
6
6
|
import { VoteWASM } from '../../structs/MasternodeVote/Vote.js';
|
|
7
7
|
import { DocumentWASM } from '../../structs/Document.js';
|
|
8
|
-
import { PlatformAddressWASM } from '../../structs/
|
|
8
|
+
import { PlatformAddressWASM } from '../../structs/PlatformAddress/PlatformAddress.js';
|
|
9
9
|
import { dppProvider } from '../../provider.js';
|
|
10
10
|
const converters = () => {
|
|
11
11
|
return new Map([
|
|
@@ -15,18 +15,18 @@ const converters = () => {
|
|
|
15
15
|
[dppProvider.dpp.PartialIdentityNAPI, v => PartialIdentityWASM.createFromRawInstance(v)],
|
|
16
16
|
[dppProvider.dpp.DocumentNAPI, v => DocumentWASM.createFromRawInstance(v)],
|
|
17
17
|
[dppProvider.dpp.VoteNAPI, v => VoteWASM.createFromRawInstance(v)],
|
|
18
|
-
[dppProvider.dpp.IdentityTokenBalanceNAPI, v => ({
|
|
18
|
+
[dppProvider.dpp.IdentityTokenBalanceNAPI, (v) => ({
|
|
19
19
|
id: IdentifierWASM.createFromRawInstance(v.id),
|
|
20
20
|
balance: BigInt(v.balance)
|
|
21
21
|
})],
|
|
22
22
|
[dppProvider.dpp.VerifiedIdentityTokenInfoNAPI, (v) => ({
|
|
23
|
-
|
|
23
|
+
tokenId: IdentifierWASM.createFromRawInstance(v.id),
|
|
24
24
|
identityTokenInfo: {
|
|
25
25
|
frozen: v.identityTokenInfo.frozen
|
|
26
26
|
}
|
|
27
27
|
})],
|
|
28
28
|
[dppProvider.dpp.VerifiedTokenPricingScheduleNAPI, (v) => ({
|
|
29
|
-
|
|
29
|
+
tokenId: IdentifierWASM.createFromRawInstance(v.id),
|
|
30
30
|
pricingSchedule: v.pricingSchedule != null
|
|
31
31
|
? TokenPricingScheduleWASM.createFromRawInstance(v.pricingSchedule)
|
|
32
32
|
: undefined
|
|
@@ -62,7 +62,7 @@ const converters = () => {
|
|
|
62
62
|
infos: v.infos.map(info => ({
|
|
63
63
|
nonce: info.nonce,
|
|
64
64
|
address: PlatformAddressWASM.createFromRawInstance(info.address),
|
|
65
|
-
|
|
65
|
+
balance: info.credits != null ? BigInt(info.credits) : undefined
|
|
66
66
|
}))
|
|
67
67
|
})],
|
|
68
68
|
[dppProvider.dpp.VerifiedIdentityWithAddressInfosNAPI, (v) => ({
|
|
@@ -70,7 +70,7 @@ const converters = () => {
|
|
|
70
70
|
infos: v.infos.map(info => ({
|
|
71
71
|
nonce: info.nonce,
|
|
72
72
|
address: PlatformAddressWASM.createFromRawInstance(info.address),
|
|
73
|
-
|
|
73
|
+
balance: info.credits != null ? BigInt(info.credits) : undefined
|
|
74
74
|
}))
|
|
75
75
|
})]
|
|
76
76
|
]);
|
|
@@ -93,11 +93,11 @@ function convertArray(result) {
|
|
|
93
93
|
: undefined
|
|
94
94
|
}));
|
|
95
95
|
}
|
|
96
|
-
if (first instanceof dppProvider.dpp.
|
|
96
|
+
if (first instanceof dppProvider.dpp.PlatformAddressInfoNAPI) {
|
|
97
97
|
return result.map(item => ({
|
|
98
98
|
nonce: item.nonce,
|
|
99
99
|
address: PlatformAddressWASM.createFromRawInstance(item.address),
|
|
100
|
-
|
|
100
|
+
balance: item.credits != null ? BigInt(item.credits) : undefined
|
|
101
101
|
}));
|
|
102
102
|
}
|
|
103
103
|
throw new Error('Unknown array type');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { dppProvider } from '../../provider.js';
|
|
2
2
|
import { valueToDynamicValue } from '../../utils.js';
|
|
3
3
|
export function verifyEpochsInfoProof(proof, currentEpoch, startEpoch, count, ascending, platformVersion) {
|
|
4
|
-
const result = dppProvider.dpp.verifyEpochsInfoProof(proof, currentEpoch, startEpoch, count, ascending, valueToDynamicValue(platformVersion));
|
|
4
|
+
const result = dppProvider.dpp.verifyEpochsInfoProof(proof, currentEpoch, startEpoch, count, ascending ?? false, valueToDynamicValue(platformVersion));
|
|
5
5
|
return {
|
|
6
6
|
rootHash: result.rootHash,
|
|
7
7
|
epochsInfo: result.epochsInfo.map(info => ({
|
|
@@ -6,7 +6,7 @@ export function verifyTokenBalancesForIdentitiesProof(proof, tokenId, isProofSub
|
|
|
6
6
|
return {
|
|
7
7
|
rootHash: result.rootHash,
|
|
8
8
|
balances: result.balances.map(balance => ({
|
|
9
|
-
balance: BigInt(balance.balance),
|
|
9
|
+
balance: balance.balance != null ? BigInt(balance.balance) : undefined,
|
|
10
10
|
id: IdentifierWASM.createFromRawInstance(balance.id)
|
|
11
11
|
}))
|
|
12
12
|
};
|
|
@@ -7,7 +7,7 @@ export function verifyTokenDirectPurchasePrices(proof, tokenIds, verifySubsetOfP
|
|
|
7
7
|
return {
|
|
8
8
|
rootHash: result.rootHash,
|
|
9
9
|
prices: result.prices.map(price => ({
|
|
10
|
-
|
|
10
|
+
tokenId: IdentifierWASM.createFromRawInstance(price.id),
|
|
11
11
|
pricingSchedule: price.pricingSchedule != null ? TokenPricingScheduleWASM.createFromRawInstance(price.pricingSchedule) : undefined
|
|
12
12
|
}))
|
|
13
13
|
};
|
|
@@ -6,7 +6,7 @@ export function verifyTokensBalancesForIdentityProof(proof, tokenIds, identityId
|
|
|
6
6
|
return {
|
|
7
7
|
rootHash: result.rootHash,
|
|
8
8
|
balances: result.balances.map(balance => ({
|
|
9
|
-
balance: BigInt(balance.balance),
|
|
9
|
+
balance: balance.balance != null ? BigInt(balance.balance) : undefined,
|
|
10
10
|
id: IdentifierWASM.createFromRawInstance(balance.id)
|
|
11
11
|
}))
|
|
12
12
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pshenmic-dpp",
|
|
3
|
-
"version": "2.0.0-dev.
|
|
3
|
+
"version": "2.0.0-dev.10",
|
|
4
4
|
"main": "dist/src/wasm.js",
|
|
5
5
|
"types": "dist/src/wasm.d.ts",
|
|
6
6
|
"react-native": "./dist/src/react-native.js",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"ts-standard": "^12.0.2"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@emnapi/core": "
|
|
56
|
-
"@emnapi/runtime": "
|
|
55
|
+
"@emnapi/core": "1.9.0",
|
|
56
|
+
"@emnapi/runtime": "1.9.0",
|
|
57
57
|
"@tybys/wasm-util": "^0.10.1",
|
|
58
58
|
"fflate": "^0.8.2"
|
|
59
59
|
}
|
|
@@ -83,4 +83,44 @@ describe('DynamicValue', () => {
|
|
|
83
83
|
expect(valueFromDynamicValue(extendedArrayDynamicValue)).toStrictEqual(extendedArrayValue)
|
|
84
84
|
})
|
|
85
85
|
})
|
|
86
|
+
|
|
87
|
+
describe('number values in object', function () {
|
|
88
|
+
const mock = {
|
|
89
|
+
uint: 1999,
|
|
90
|
+
int: -293,
|
|
91
|
+
float: 2222.11231,
|
|
92
|
+
smallBigInt: BigInt(2),
|
|
93
|
+
bigBigInt: BigInt(2000000000000),
|
|
94
|
+
stringUint: '11',
|
|
95
|
+
stringInt: '-11',
|
|
96
|
+
stringFloat: '11.2',
|
|
97
|
+
bigStringNumber: '11111111111111111111111111111111'
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const dynValue = valueToDynamicValue(mock)
|
|
101
|
+
|
|
102
|
+
const result = valueFromDynamicValue(dynValue)
|
|
103
|
+
|
|
104
|
+
expect(valueFromDynamicValue(dynValue)).toStrictEqual(mock)
|
|
105
|
+
expect(dynValue.value.uint.getType()).toStrictEqual('u32')
|
|
106
|
+
expect(dynValue.value.int.getType()).toStrictEqual('i64')
|
|
107
|
+
expect(dynValue.value.float.getType()).toStrictEqual('f64')
|
|
108
|
+
expect(dynValue.value.smallBigInt.getType()).toStrictEqual('BigIntString')
|
|
109
|
+
expect(dynValue.value.bigBigInt.getType()).toStrictEqual('BigIntString')
|
|
110
|
+
expect(dynValue.value.stringUint.getType()).toStrictEqual('String')
|
|
111
|
+
expect(dynValue.value.stringInt.getType()).toStrictEqual('String')
|
|
112
|
+
expect(dynValue.value.stringFloat.getType()).toStrictEqual('String')
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
describe('should decode document from state transition in jsonLike', function () {
|
|
116
|
+
const stateTransition = dpp.StateTransitionWASM.fromBase64('AgHv88sfWzscuW2Ob/0v5d+EgqmWG7ZIvlQG7mHWBH7z9gEAAAAB7JH7W+JkM0Vne2U1zlWYVeQNzRPTpdiWRfsgfwNS2UoCCGJsb2dQb3N0KBdMgeznVQ1smUXVFNPfE2PC379wpWVH8cdu2ilzeI0Ah/i2xfrKCm5ACQAbEQkSc+GRUkdLor4Eu7Vzf6oRc9UHBmJsb2dJZAogdhC4nVm3ufPCgdfoOKXtnhqwg7O3axyTS9WB3EFvNBYPY29tbWVudHNFbmFibGVkEwEHY29udGVudAr7AUh4nM2TTWrDMBCFrxK0jkCyJMvqLnRV6A1KFhpplJgotrEVaAi+e8clpdBuvCnNcn7ezPvQ6O3G2siemKgNSGETT8ZarhUm7hpX8yStEpVCk6xlW1auA1L34Ed/GP1wpNQw9sPEnm6s4Ht57nM/UkPE5C+5UBl8OB3G/tLF37VFscvtoTtjV6iSMRU2b1nou/KZIXf3jUvrXUHRrosbv8ltKRk30JbNl2LLpnLNuPiZ5z1NOrY5jtjRqP28vbM656zTleagJHCNXnIQiUIpgozGg2/0N2s4Yji9tlN5KXj+A97FJG1AcpZ8nnANv1wHGo22ASrFXQDJde0SBzDIdQBVRQEoDDw2aLUONPkKtfF0s9bR9bqGkJW3PNYCg/FOgIqPDarWgQrRxKapBXdCJ3pR7TjUVnJrpAo6yhSc/4dv+tPu/gNBt2qtC3B1Ymxpc2hlZEF0Av0AAAGcptJlIwRzbHVnEhV0aGlzLWlzLW15LWZpcnN0LXBvc3QIc3VidGl0bGUSD1dpdGggYSBzdWJ0aXRsZQV0aXRsZRIVVGhpcyBpcyBteSBmaXJzdCBwb3N0AAABQR+H40MbUEmFXQbTPcwy9vMD8EiTwDzMpW3YIkfSIDvHij5ZIAVvqm0ZJScJzKV7EnRUi/f1tZ/wFJfd1+LDtpps')
|
|
117
|
+
|
|
118
|
+
const batch = dpp.BatchTransitionWASM.fromStateTransition(stateTransition)
|
|
119
|
+
|
|
120
|
+
const transition = batch.transitions[0].toTransition() as dpp.DocumentTransitionWASM
|
|
121
|
+
|
|
122
|
+
const publishedAt = transition.createTransition.data.publishedAt
|
|
123
|
+
|
|
124
|
+
expect(typeof publishedAt).toEqual('number')
|
|
125
|
+
})
|
|
86
126
|
})
|