pshenmic-dpp 2.0.0-dev.2 → 2.0.0-dev.21

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 (207) hide show
  1. package/dist/binaries/bindingsTypes.d.ts +507 -37
  2. package/dist/binaries/bindingsTypes.js +4 -3
  3. package/dist/binaries/native/aarch64-apple-darwin/pshenmic_dpp.node +0 -0
  4. package/dist/binaries/native/x86_64-apple-darwin/pshenmic_dpp.node +0 -0
  5. package/dist/binaries/native/x86_64-unknown-linux-gnu/pshenmic_dpp.node +0 -0
  6. package/dist/binaries/native/x86_64-unknown-linux-musl/pshenmic_dpp.node +0 -0
  7. package/dist/binaries/node.cjs +50 -0
  8. package/dist/binaries/node.d.cts +2 -0
  9. package/dist/binaries/pshenmic_dpp.android.node/arm64-v8a/libpshenmic_dpp.so +0 -0
  10. package/dist/binaries/pshenmic_dpp.apple.node/Info.plist +29 -0
  11. package/dist/binaries/pshenmic_dpp.apple.node/ios-arm64-simulator/libpshenmic_dpp.framework/Info.plist +24 -0
  12. package/dist/binaries/pshenmic_dpp.apple.node/ios-arm64-simulator/libpshenmic_dpp.framework/libpshenmic_dpp +0 -0
  13. package/dist/binaries/pshenmic_dpp.apple.node/react-native-node-api-module +0 -0
  14. package/dist/binaries/pshenmic_dpp.d.ts +42 -1
  15. package/dist/binaries/pshenmic_dpp.js +1 -1
  16. package/dist/binaries/wasm/wasmBytes.cjs +3 -0
  17. package/dist/binaries/wasm/wasmBytes.d.cts +1 -0
  18. package/dist/binaries/wasm.d.ts +42 -1
  19. package/dist/binaries/wasm.js +2 -44
  20. package/dist/binaries/wasmCreation.cjs +46 -0
  21. package/dist/binaries/wasmCreation.d.cts +2 -0
  22. package/dist/src/dpp/dpp.d.ts +28 -2
  23. package/dist/src/dpp/dpp.js +28 -2
  24. package/dist/src/dpp/structs/AddressTransitions/AddressCreditWithdrawalTransition.d.ts +1 -1
  25. package/dist/src/dpp/structs/AddressTransitions/AddressCreditWithdrawalTransition.js +2 -2
  26. package/dist/src/dpp/structs/AddressTransitions/AddressFundingFromAssetLockTransition.d.ts +1 -1
  27. package/dist/src/dpp/structs/AddressTransitions/AddressFundingFromAssetLockTransition.js +3 -3
  28. package/dist/src/dpp/structs/AddressTransitions/AddressFundsTransferTransition.d.ts +1 -1
  29. package/dist/src/dpp/structs/AddressTransitions/AddressFundsTransferTransition.js +3 -3
  30. package/dist/src/dpp/structs/AddressTransitions/IdentityCreateFromAddressesTransition.d.ts +1 -1
  31. package/dist/src/dpp/structs/AddressTransitions/IdentityCreateFromAddressesTransition.js +2 -2
  32. package/dist/src/dpp/structs/AddressTransitions/IdentityCreditTransferToAddressesTransition.js +1 -1
  33. package/dist/src/dpp/structs/AddressTransitions/IdentityTopUpFromAddressesTransition.d.ts +1 -1
  34. package/dist/src/dpp/structs/AddressTransitions/IdentityTopUpFromAddressesTransition.js +2 -2
  35. package/dist/src/dpp/structs/AddressTransitions/entities/InputAddress.d.ts +4 -3
  36. package/dist/src/dpp/structs/AddressTransitions/entities/InputAddress.js +5 -4
  37. package/dist/src/dpp/structs/AddressTransitions/entities/OutputAddress.d.ts +4 -3
  38. package/dist/src/dpp/structs/AddressTransitions/entities/OutputAddress.js +5 -4
  39. package/dist/src/dpp/structs/AddressTransitions/entities/OutputAddressNullableCredits.d.ts +4 -3
  40. package/dist/src/dpp/structs/AddressTransitions/entities/OutputAddressNullableCredits.js +5 -4
  41. package/dist/src/dpp/structs/AssetLockProof/AssetLockProof.js +1 -1
  42. package/dist/src/dpp/structs/AssetLockProof/ChainAssetLockProof.js +2 -2
  43. package/dist/src/dpp/structs/AssetLockProof/InstantAssetLockProof.js +1 -1
  44. package/dist/src/dpp/structs/AssetLockProof/OutPoint.js +1 -1
  45. package/dist/src/dpp/structs/AssetLockProof/Transaction.js +1 -1
  46. package/dist/src/dpp/structs/AssetLockProof/TxIn.js +1 -1
  47. package/dist/src/dpp/structs/AssetLockProof/TxOut.js +1 -1
  48. package/dist/src/dpp/structs/AssetLockProof/Witness.js +1 -1
  49. package/dist/src/dpp/structs/Batch/BatchTransition.js +1 -1
  50. package/dist/src/dpp/structs/Batch/BatchedTransition.js +1 -1
  51. package/dist/src/dpp/structs/Batch/DocumentBaseTransition.js +1 -1
  52. package/dist/src/dpp/structs/Batch/DocumentTransition.d.ts +1 -0
  53. package/dist/src/dpp/structs/Batch/DocumentTransition.js +4 -1
  54. package/dist/src/dpp/structs/Batch/DocumentTransitions/DocumentCreateTransition.d.ts +1 -1
  55. package/dist/src/dpp/structs/Batch/DocumentTransitions/DocumentCreateTransition.js +2 -2
  56. package/dist/src/dpp/structs/Batch/DocumentTransitions/DocumentDeleteTransition.js +1 -1
  57. package/dist/src/dpp/structs/Batch/DocumentTransitions/DocumentPurchaseTransition.js +1 -1
  58. package/dist/src/dpp/structs/Batch/DocumentTransitions/DocumentReplaceTransition.d.ts +1 -1
  59. package/dist/src/dpp/structs/Batch/DocumentTransitions/DocumentReplaceTransition.js +2 -2
  60. package/dist/src/dpp/structs/Batch/DocumentTransitions/DocumentTransferTransition.js +1 -1
  61. package/dist/src/dpp/structs/Batch/DocumentTransitions/DocumentUpdatePriceTransition.js +1 -1
  62. package/dist/src/dpp/structs/Batch/PrefundedVotingBalance.js +1 -1
  63. package/dist/src/dpp/structs/Batch/TokenBaseTransition.js +1 -1
  64. package/dist/src/dpp/structs/Batch/TokenPaymentInfo.js +1 -1
  65. package/dist/src/dpp/structs/Batch/TokenPricingSchedule.js +1 -1
  66. package/dist/src/dpp/structs/Batch/TokenTransition.d.ts +1 -0
  67. package/dist/src/dpp/structs/Batch/TokenTransition.js +4 -1
  68. package/dist/src/dpp/structs/Batch/TokenTransitions/TokenBurnTransition.js +1 -1
  69. package/dist/src/dpp/structs/Batch/TokenTransitions/TokenClaimTransition.js +1 -1
  70. package/dist/src/dpp/structs/Batch/TokenTransitions/TokenConfigUpdateTransition.js +1 -1
  71. package/dist/src/dpp/structs/Batch/TokenTransitions/TokenDestroyFrozenFundsTransition.js +1 -1
  72. package/dist/src/dpp/structs/Batch/TokenTransitions/TokenDirectPurchaseTransition.js +1 -1
  73. package/dist/src/dpp/structs/Batch/TokenTransitions/TokenEmergencyActionTransition.js +1 -1
  74. package/dist/src/dpp/structs/Batch/TokenTransitions/TokenFreezeTransition.js +1 -1
  75. package/dist/src/dpp/structs/Batch/TokenTransitions/TokenMintTransition.js +1 -1
  76. package/dist/src/dpp/structs/Batch/TokenTransitions/TokenSetPriceForDirectPurchaseTransition.js +1 -1
  77. package/dist/src/dpp/structs/Batch/TokenTransitions/TokenTransferTransition.d.ts +3 -0
  78. package/dist/src/dpp/structs/Batch/TokenTransitions/TokenTransferTransition.js +8 -1
  79. package/dist/src/dpp/structs/Batch/TokenTransitions/TokenUnFreezeTransition.js +1 -1
  80. package/dist/src/dpp/structs/ContractBounds.js +1 -1
  81. package/dist/src/dpp/structs/CoreScript.js +1 -1
  82. package/dist/src/dpp/structs/DataContract.d.ts +6 -4
  83. package/dist/src/dpp/structs/DataContract.js +8 -2
  84. package/dist/src/dpp/structs/DataContractTransitions/DataContractCreateTransition.js +1 -1
  85. package/dist/src/dpp/structs/DataContractTransitions/DataContractUpdateTransition.js +1 -1
  86. package/dist/src/dpp/structs/Document.d.ts +1 -1
  87. package/dist/src/dpp/structs/Document.js +1 -1
  88. package/dist/src/dpp/structs/EncryptedNote/PrivateEncryptedNote.js +1 -1
  89. package/dist/src/dpp/structs/EncryptedNote/SharedEncryptedNote.js +1 -1
  90. package/dist/src/dpp/structs/GroupStateTransitionInfo.js +1 -1
  91. package/dist/src/dpp/structs/Identifier.js +1 -1
  92. package/dist/src/dpp/structs/Identity.js +1 -1
  93. package/dist/src/dpp/structs/IdentityPublicKey.d.ts +1 -0
  94. package/dist/src/dpp/structs/IdentityPublicKey.js +6 -1
  95. package/dist/src/dpp/structs/IdentityPublicKeyInCreation.d.ts +1 -0
  96. package/dist/src/dpp/structs/IdentityPublicKeyInCreation.js +6 -1
  97. package/dist/src/dpp/structs/IdentityTransitions/IdentityCreateTransition.js +1 -1
  98. package/dist/src/dpp/structs/IdentityTransitions/IdentityCreditTransfer.js +1 -1
  99. package/dist/src/dpp/structs/IdentityTransitions/IdentityCreditWithdrawalTransition.js +1 -1
  100. package/dist/src/dpp/structs/IdentityTransitions/IdentityTopUpTransition.js +1 -1
  101. package/dist/src/dpp/structs/IdentityTransitions/IdentityUpdateTransition.js +1 -1
  102. package/dist/src/dpp/structs/InstantLock.js +1 -1
  103. package/dist/src/dpp/structs/MasternodeVote/MasternodeVoteTransition.d.ts +0 -2
  104. package/dist/src/dpp/structs/MasternodeVote/MasternodeVoteTransition.js +1 -7
  105. package/dist/src/dpp/structs/MasternodeVote/Vote.js +1 -1
  106. package/dist/src/dpp/structs/MasternodeVote/VotePoll.d.ts +1 -1
  107. package/dist/src/dpp/structs/MasternodeVote/VotePoll.js +3 -3
  108. package/dist/src/dpp/structs/Orchard/CommitmentTree.d.ts +14 -0
  109. package/dist/src/dpp/structs/Orchard/CommitmentTree.js +31 -0
  110. package/dist/src/dpp/structs/Orchard/IdentityCreateFromShieldedPoolResult.d.ts +21 -0
  111. package/dist/src/dpp/structs/Orchard/IdentityCreateFromShieldedPoolResult.js +38 -0
  112. package/dist/src/dpp/structs/Orchard/MerklePath.d.ts +11 -0
  113. package/dist/src/dpp/structs/Orchard/MerklePath.js +25 -0
  114. package/dist/src/dpp/structs/Orchard/Note.d.ts +18 -0
  115. package/dist/src/dpp/structs/Orchard/Note.js +42 -0
  116. package/dist/src/dpp/structs/Orchard/OrchardAddress.d.ts +15 -0
  117. package/dist/src/dpp/structs/Orchard/OrchardAddress.js +31 -0
  118. package/dist/src/dpp/structs/Orchard/OrchardProver.d.ts +12 -0
  119. package/dist/src/dpp/structs/Orchard/OrchardProver.js +18 -0
  120. package/dist/src/dpp/structs/Orchard/RecoveredNote.d.ts +18 -0
  121. package/dist/src/dpp/structs/Orchard/RecoveredNote.js +29 -0
  122. package/dist/src/dpp/structs/Orchard/ShieldedBuilder.d.ts +40 -0
  123. package/dist/src/dpp/structs/Orchard/ShieldedBuilder.js +45 -0
  124. package/dist/src/dpp/structs/Orchard/ShieldedMemo.d.ts +11 -0
  125. package/dist/src/dpp/structs/Orchard/ShieldedMemo.js +25 -0
  126. package/dist/src/dpp/structs/Orchard/ShieldedWithdrawalResult.d.ts +11 -0
  127. package/dist/src/dpp/structs/Orchard/ShieldedWithdrawalResult.js +18 -0
  128. package/dist/src/dpp/structs/Orchard/SpendableNote.d.ts +13 -0
  129. package/dist/src/dpp/structs/Orchard/SpendableNote.js +27 -0
  130. package/dist/src/dpp/structs/PartialIdentity.js +1 -1
  131. package/dist/src/dpp/structs/{Address → PlatformAddress}/AddressWitness.d.ts +2 -2
  132. package/dist/src/dpp/structs/{Address → PlatformAddress}/AddressWitness.js +2 -2
  133. package/dist/src/dpp/structs/{Address → PlatformAddress}/PlatformAddress.d.ts +4 -2
  134. package/dist/src/dpp/structs/{Address → PlatformAddress}/PlatformAddress.js +9 -3
  135. package/dist/src/dpp/structs/PrivateKey.js +1 -1
  136. package/dist/src/dpp/structs/PublicKey.js +1 -1
  137. package/dist/src/dpp/structs/ShieldedTransitions/IdentityCreateFromShieldedPoolTransition.d.ts +31 -0
  138. package/dist/src/dpp/structs/ShieldedTransitions/IdentityCreateFromShieldedPoolTransition.js +73 -0
  139. package/dist/src/dpp/structs/ShieldedTransitions/SerializedAction.d.ts +19 -0
  140. package/dist/src/dpp/structs/ShieldedTransitions/SerializedAction.js +49 -0
  141. package/dist/src/dpp/structs/ShieldedTransitions/ShieldFromAssetLockTransition.d.ts +30 -0
  142. package/dist/src/dpp/structs/ShieldedTransitions/ShieldFromAssetLockTransition.js +77 -0
  143. package/dist/src/dpp/structs/ShieldedTransitions/ShieldTransition.d.ts +32 -0
  144. package/dist/src/dpp/structs/ShieldedTransitions/ShieldTransition.js +78 -0
  145. package/dist/src/dpp/structs/ShieldedTransitions/ShieldedTransferTransition.d.ts +21 -0
  146. package/dist/src/dpp/structs/ShieldedTransitions/ShieldedTransferTransition.js +51 -0
  147. package/dist/src/dpp/structs/ShieldedTransitions/ShieldedWithdrawalTransition.d.ts +29 -0
  148. package/dist/src/dpp/structs/ShieldedTransitions/ShieldedWithdrawalTransition.js +71 -0
  149. package/dist/src/dpp/structs/ShieldedTransitions/UnshieldTransition.d.ts +25 -0
  150. package/dist/src/dpp/structs/ShieldedTransitions/UnshieldTransition.js +59 -0
  151. package/dist/src/dpp/structs/StateTransition.d.ts +1 -0
  152. package/dist/src/dpp/structs/StateTransition.js +3 -0
  153. package/dist/src/dpp/structs/TokenConfiguration/ActionTaker.js +1 -1
  154. package/dist/src/dpp/structs/TokenConfiguration/ChangeControlRules.js +1 -1
  155. package/dist/src/dpp/structs/TokenConfiguration/Group.js +1 -1
  156. package/dist/src/dpp/structs/TokenConfiguration/TokenConfiguration.js +1 -1
  157. package/dist/src/dpp/structs/TokenConfiguration/TokenConfigurationConvention.js +1 -1
  158. package/dist/src/dpp/structs/TokenConfiguration/TokenConfigurationLocalization.js +1 -1
  159. package/dist/src/dpp/structs/TokenConfiguration/TokenDistributionRules.js +1 -1
  160. package/dist/src/dpp/structs/TokenConfiguration/TokenKeepsHistoryRules.js +1 -1
  161. package/dist/src/dpp/structs/TokenConfiguration/TokenMarketplaceRules.js +1 -1
  162. package/dist/src/dpp/structs/TokenConfiguration/TokenPerpetualDistribution.js +1 -1
  163. package/dist/src/dpp/structs/TokenConfiguration/TokenPreProgrammedDistribution.js +1 -1
  164. package/dist/src/dpp/types.d.ts +85 -11
  165. package/dist/src/dpp/utils.d.ts +4 -3
  166. package/dist/src/dpp/utils.js +24 -6
  167. package/dist/src/dpp/verify/Contested/verifyVotePollVoteStateProof.d.ts +1 -1
  168. package/dist/src/dpp/verify/Contested/verifyVotePollVoteStateProof.js +1 -1
  169. package/dist/src/dpp/verify/PlatformAddress/verifyPlatformAddressInfo.d.ts +2 -0
  170. package/dist/src/dpp/verify/PlatformAddress/verifyPlatformAddressInfo.js +12 -0
  171. package/dist/src/dpp/verify/PlatformAddress/verifyPlatformAddressesInfos.d.ts +2 -0
  172. package/dist/src/dpp/verify/PlatformAddress/verifyPlatformAddressesInfos.js +14 -0
  173. package/dist/src/dpp/verify/Shielded/verifyMostRecentShieldedAnchorProof.d.ts +2 -0
  174. package/dist/src/dpp/verify/Shielded/verifyMostRecentShieldedAnchorProof.js +9 -0
  175. package/dist/src/dpp/verify/Shielded/verifyShieldedAnchorsProof.d.ts +2 -0
  176. package/dist/src/dpp/verify/Shielded/verifyShieldedAnchorsProof.js +9 -0
  177. package/dist/src/dpp/verify/Shielded/verifyShieldedEncryptedNotesProof.d.ts +2 -0
  178. package/dist/src/dpp/verify/Shielded/verifyShieldedEncryptedNotesProof.js +15 -0
  179. package/dist/src/dpp/verify/Shielded/verifyShieldedNotesCountProof.d.ts +2 -0
  180. package/dist/src/dpp/verify/Shielded/verifyShieldedNotesCountProof.js +9 -0
  181. package/dist/src/dpp/verify/Shielded/verifyShieldedNullifiersProof.d.ts +2 -0
  182. package/dist/src/dpp/verify/Shielded/verifyShieldedNullifiersProof.js +12 -0
  183. package/dist/src/dpp/verify/Shielded/verifyShieldedPoolStateProof.d.ts +2 -0
  184. package/dist/src/dpp/verify/Shielded/verifyShieldedPoolStateProof.js +9 -0
  185. package/dist/src/dpp/verify/StateTransition/utils.js +80 -15
  186. package/dist/src/dpp/verify/System/verifyEpochsInfoProof.js +1 -1
  187. package/dist/src/dpp/verify/Tokens/verifyTokenBalancesForIdentitiesProof.js +1 -1
  188. package/dist/src/dpp/verify/Tokens/verifyTokensBalancesForIdentityProof.js +1 -1
  189. package/dist/src/native.d.ts +3 -0
  190. package/dist/src/native.js +8 -0
  191. package/dist/utils/{base122.js → base122.cjs} +3 -1
  192. package/package.json +18 -28
  193. package/tests/unit/DataContract.spec.ts +281 -0
  194. package/tests/unit/DynamicValue.spec.ts +42 -2
  195. package/tests/unit/Identifier.spec.ts +1 -1
  196. package/tests/unit/Identity.spec.ts +1 -1
  197. package/tests/unit/IdentityPublicKey.spec.ts +1 -1
  198. package/tests/unit/NodeApi.spec.ts +49 -0
  199. package/tests/unit/Shielded.spec.ts +344 -0
  200. package/tests/unit/ShieldedTransitions.spec.ts +709 -0
  201. package/tests/unit/TokenConfiguration.spec.ts +114 -0
  202. package/tests/unit/WebAssembly.spec.ts +49 -0
  203. package/tests/unit/utils/buildTokenConfiguration.ts +66 -0
  204. package/dist/binaries/pshenmic_dpp.android.node/x86_64/libpshenmic_dpp.so +0 -0
  205. package/dist/binaries/wasm/wasmBytes.d.ts +0 -2
  206. package/dist/binaries/wasm/wasmBytes.js +0 -2
  207. /package/dist/utils/{base122.d.ts → base122.d.cts} +0 -0
@@ -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) {
@@ -43,21 +44,27 @@ export function valueToDynamicValue(value) {
43
44
  return new dppProvider.dpp.DynamicValue(value);
44
45
  }
45
46
  }
46
- export function valueFromDynamicValue(dynamicValue) {
47
+ export function valueFromDynamicValue(dynamicValue, jsonLike = false) {
47
48
  if (dynamicValue.value instanceof dppProvider.dpp.DynamicValue) {
48
- return valueToDynamicValue(dynamicValue.value);
49
+ return valueFromDynamicValue(dynamicValue.value, jsonLike);
49
50
  }
50
51
  else if (dynamicValue.isBigInt()) {
51
- return BigInt(dynamicValue.value);
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
+ }
52
59
  }
53
60
  else if (Array.isArray(dynamicValue.value)) {
54
- return dynamicValue.value.map(valueFromDynamicValue);
61
+ return dynamicValue.value.map(v => valueFromDynamicValue(v, jsonLike));
55
62
  }
56
63
  else if (typeof dynamicValue.value === 'object' && !(dynamicValue.value instanceof Uint8Array) && dynamicValue.value !== null) {
57
64
  const obj = {};
58
65
  const keys = Object.keys(dynamicValue.value);
59
66
  for (const key of keys) {
60
- obj[key] = valueFromDynamicValue(dynamicValue.value[key]);
67
+ obj[key] = valueFromDynamicValue(dynamicValue.value[key], jsonLike);
61
68
  }
62
69
  return obj;
63
70
  }
@@ -76,3 +83,14 @@ export function prepareIdentifierValue(identifier) {
76
83
  return new dppProvider.dpp.DynamicValue(identifier);
77
84
  }
78
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: Uint8Array[], resultType: VoteStateResultTypeLike, allowIncludeLockedAndAbstainingVoteTally: boolean, count: number | undefined, startAt: StartAt | undefined, platformVersion: PlatformVersionLike): VerifiedVoteState;
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, indexValues, valueToDynamicValue(resultType), allowIncludeLockedAndAbstainingVoteTally, count, valueToDynamicValue(startAt), valueToDynamicValue(platformVersion));
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
@@ -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
+ }
@@ -0,0 +1,2 @@
1
+ import { PlatformVersionLike, VerifiedMostRecentShieldedAnchor } from '../../types.js';
2
+ export declare function verifyMostRecentShieldedAnchorProof(proof: Uint8Array, verifySubsetOfProof: boolean, platformVersion: PlatformVersionLike): VerifiedMostRecentShieldedAnchor;
@@ -0,0 +1,9 @@
1
+ import { dppProvider } from '../../provider.js';
2
+ import { valueToDynamicValue } from '../../utils.js';
3
+ export function verifyMostRecentShieldedAnchorProof(proof, verifySubsetOfProof, platformVersion) {
4
+ const result = dppProvider.dpp.verifyMostRecentShieldedAnchorProof(proof, verifySubsetOfProof, valueToDynamicValue(platformVersion));
5
+ return {
6
+ rootHash: result.rootHash,
7
+ anchor: result.anchor ?? undefined
8
+ };
9
+ }
@@ -0,0 +1,2 @@
1
+ import { PlatformVersionLike, VerifiedShieldedAnchors } from '../../types.js';
2
+ export declare function verifyShieldedAnchorsProof(proof: Uint8Array, verifySubsetOfProof: boolean, platformVersion: PlatformVersionLike): VerifiedShieldedAnchors;
@@ -0,0 +1,9 @@
1
+ import { dppProvider } from '../../provider.js';
2
+ import { valueToDynamicValue } from '../../utils.js';
3
+ export function verifyShieldedAnchorsProof(proof, verifySubsetOfProof, platformVersion) {
4
+ const result = dppProvider.dpp.verifyShieldedAnchorsProof(proof, verifySubsetOfProof, valueToDynamicValue(platformVersion));
5
+ return {
6
+ rootHash: result.rootHash,
7
+ anchors: result.anchors
8
+ };
9
+ }
@@ -0,0 +1,2 @@
1
+ import { PlatformVersionLike, VerifiedShieldedEncryptedNotes } from '../../types.js';
2
+ export declare function verifyShieldedEncryptedNotesProof(proof: Uint8Array, startIndex: bigint, count: number, maxElements: number, verifySubsetOfProof: boolean, platformVersion: PlatformVersionLike): VerifiedShieldedEncryptedNotes;
@@ -0,0 +1,15 @@
1
+ import { dppProvider } from '../../provider.js';
2
+ import { valueToDynamicValue } from '../../utils.js';
3
+ export function verifyShieldedEncryptedNotesProof(proof, startIndex, count, maxElements, verifySubsetOfProof, platformVersion) {
4
+ const result = dppProvider.dpp.verifyShieldedEncryptedNotesProof(proof, startIndex.toString(), count, maxElements, verifySubsetOfProof, valueToDynamicValue(platformVersion));
5
+ return {
6
+ rootHash: result.rootHash,
7
+ notes: result.notes.map((note) => ({
8
+ cmx: note.cmx,
9
+ nullifier: note.nullifier,
10
+ cvNet: note.cvNet,
11
+ encryptedNote: note.encryptedNote
12
+ })),
13
+ totalCount: BigInt(result.totalCount)
14
+ };
15
+ }
@@ -0,0 +1,2 @@
1
+ import { PlatformVersionLike, VerifiedShieldedNotesCount } from '../../types.js';
2
+ export declare function verifyShieldedNotesCountProof(proof: Uint8Array, verifySubsetOfProof: boolean, platformVersion: PlatformVersionLike): VerifiedShieldedNotesCount;
@@ -0,0 +1,9 @@
1
+ import { dppProvider } from '../../provider.js';
2
+ import { valueToDynamicValue } from '../../utils.js';
3
+ export function verifyShieldedNotesCountProof(proof, verifySubsetOfProof, platformVersion) {
4
+ const result = dppProvider.dpp.verifyShieldedNotesCountProof(proof, verifySubsetOfProof, valueToDynamicValue(platformVersion));
5
+ return {
6
+ rootHash: result.rootHash,
7
+ count: result.count != null ? BigInt(result.count) : undefined
8
+ };
9
+ }
@@ -0,0 +1,2 @@
1
+ import { PlatformVersionLike, VerifiedShieldedNullifiers } from '../../types.js';
2
+ export declare function verifyShieldedNullifiersProof(proof: Uint8Array, nullifiers: Uint8Array[], verifySubsetOfProof: boolean, platformVersion: PlatformVersionLike): VerifiedShieldedNullifiers;
@@ -0,0 +1,12 @@
1
+ import { dppProvider } from '../../provider.js';
2
+ import { valueToDynamicValue } from '../../utils.js';
3
+ export function verifyShieldedNullifiersProof(proof, nullifiers, verifySubsetOfProof, platformVersion) {
4
+ const result = dppProvider.dpp.verifyShieldedNullifiersProof(proof, nullifiers, verifySubsetOfProof, valueToDynamicValue(platformVersion));
5
+ return {
6
+ rootHash: result.rootHash,
7
+ nullifiers: result.nullifiers.map((nullifier) => ({
8
+ nullifier: nullifier.nullifier,
9
+ isSpent: nullifier.isSpent
10
+ }))
11
+ };
12
+ }
@@ -0,0 +1,2 @@
1
+ import { PlatformVersionLike, VerifiedShieldedPoolState } from '../../types.js';
2
+ export declare function verifyShieldedPoolStateProof(proof: Uint8Array, verifySubsetOfProof: boolean, platformVersion: PlatformVersionLike): VerifiedShieldedPoolState;
@@ -0,0 +1,9 @@
1
+ import { dppProvider } from '../../provider.js';
2
+ import { valueToDynamicValue } from '../../utils.js';
3
+ export function verifyShieldedPoolStateProof(proof, verifySubsetOfProof, platformVersion) {
4
+ const result = dppProvider.dpp.verifyShieldedPoolStateProof(proof, verifySubsetOfProof, valueToDynamicValue(platformVersion));
5
+ return {
6
+ rootHash: result.rootHash,
7
+ totalBalance: result.totalBalance != null ? BigInt(result.totalBalance) : undefined
8
+ };
9
+ }
@@ -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/Address/PlatformAddress.js';
8
+ import { PlatformAddressWASM } from '../../structs/PlatformAddress/PlatformAddress.js';
9
9
  import { dppProvider } from '../../provider.js';
10
10
  const converters = () => {
11
11
  return new Map([
@@ -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
- credits: info.credits != null ? BigInt(info.credits) : undefined
65
+ balance: info.credits != null ? BigInt(info.credits) : undefined
66
66
  }))
67
67
  })],
68
68
  [dppProvider.dpp.VerifiedIdentityWithAddressInfosNAPI, (v) => ({
@@ -70,11 +70,40 @@ const converters = () => {
70
70
  infos: v.infos.map(info => ({
71
71
  nonce: info.nonce,
72
72
  address: PlatformAddressWASM.createFromRawInstance(info.address),
73
- credits: info.credits != null ? BigInt(info.credits) : undefined
73
+ balance: info.credits != null ? BigInt(info.credits) : undefined
74
74
  }))
75
75
  })]
76
76
  ]);
77
77
  };
78
+ function convertPlatformAddressInfos(infos) {
79
+ return infos.map(info => ({
80
+ nonce: info.nonce,
81
+ address: PlatformAddressWASM.createFromRawInstance(info.address),
82
+ balance: info.credits != null ? BigInt(info.credits) : undefined
83
+ }));
84
+ }
85
+ function convertVerifiedDocuments(docs) {
86
+ return docs.map(item => ({
87
+ id: IdentifierWASM.createFromRawInstance(item.id),
88
+ document: item.document != null
89
+ ? DocumentWASM.createFromRawInstance(item.document)
90
+ : undefined
91
+ }));
92
+ }
93
+ function convertAssetLockValue(v) {
94
+ return {
95
+ initialCreditValue: BigInt(v.initialCreditValue),
96
+ txOutScript: v.txOutScript,
97
+ remainingCreditValue: BigInt(v.remainingCreditValue),
98
+ usedTags: v.usedTags
99
+ };
100
+ }
101
+ function convertStoredAssetLockInfo(v) {
102
+ return {
103
+ type: v.type,
104
+ value: v.value != null ? convertAssetLockValue(v.value) : undefined
105
+ };
106
+ }
78
107
  function convertArray(result) {
79
108
  const [first] = result;
80
109
  if (first == null)
@@ -86,26 +115,62 @@ function convertArray(result) {
86
115
  }));
87
116
  }
88
117
  if (first instanceof dppProvider.dpp.VerifiedDocumentNAPI) {
89
- return result.map(item => ({
90
- id: IdentifierWASM.createFromRawInstance(item.id),
91
- document: item.document != null
92
- ? DocumentWASM.createFromRawInstance(item.document)
93
- : undefined
94
- }));
118
+ return convertVerifiedDocuments(result);
95
119
  }
96
- if (first instanceof dppProvider.dpp.VerifiedAddressInfosNAPI) {
97
- return result.map(item => ({
98
- nonce: item.nonce,
99
- address: PlatformAddressWASM.createFromRawInstance(item.address),
100
- credits: item.credits != null ? BigInt(item.credits) : undefined
101
- }));
120
+ if (first instanceof dppProvider.dpp.PlatformAddressInfoNAPI) {
121
+ return convertPlatformAddressInfos(result);
102
122
  }
103
123
  throw new Error('Unknown array type');
104
124
  }
125
+ function convertTuple(result) {
126
+ const [first, second] = result;
127
+ if (first instanceof dppProvider.dpp.StoredAssetLockInfoNAPI) {
128
+ return {
129
+ storedAssetLockInfo: convertStoredAssetLockInfo(first),
130
+ infos: convertPlatformAddressInfos(second)
131
+ };
132
+ }
133
+ if (first instanceof dppProvider.dpp.IdentityNAPI) {
134
+ return {
135
+ identity: IdentityWASM.createFromRawInstance(first),
136
+ nullifiers: second
137
+ };
138
+ }
139
+ if (Array.isArray(first) && Array.isArray(second)) {
140
+ const secondFirst = second[0];
141
+ if (secondFirst != null && secondFirst instanceof dppProvider.dpp.VerifiedDocumentNAPI) {
142
+ return {
143
+ nullifiers: first,
144
+ documents: convertVerifiedDocuments(second)
145
+ };
146
+ }
147
+ return {
148
+ nullifiers: first,
149
+ infos: secondFirst != null ? convertPlatformAddressInfos(second) : []
150
+ };
151
+ }
152
+ throw new Error('Unknown tuple type');
153
+ }
105
154
  export function convertResult(result) {
106
155
  if (Array.isArray(result)) {
156
+ if (result.length === 2) {
157
+ const [first] = result;
158
+ if (first instanceof dppProvider.dpp.StoredAssetLockInfoNAPI || first instanceof dppProvider.dpp.IdentityNAPI) {
159
+ return convertTuple(result);
160
+ }
161
+ if (Array.isArray(first) && (first.length === 0 || Array.isArray(first[0]))) {
162
+ return convertTuple(result);
163
+ }
164
+ }
165
+ const [first] = result;
166
+ if (first != null && Array.isArray(first) && first[0] instanceof Uint8Array) {
167
+ return result;
168
+ }
107
169
  return convertArray(result);
108
170
  }
171
+ if (result instanceof dppProvider.dpp.StoredAssetLockInfoNAPI) {
172
+ return convertStoredAssetLockInfo(result);
173
+ }
109
174
  for (const [Type, handler] of converters()) {
110
175
  if (result instanceof Type) {
111
176
  return handler(result);
@@ -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
  };
@@ -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
  };
@@ -0,0 +1,3 @@
1
+ export * from './dpp/enums.js';
2
+ export * from './dpp/dpp.js';
3
+ export * from './dpp/types.js';
@@ -0,0 +1,8 @@
1
+ // @ts-ignore
2
+ import protocol from '../binaries/node.cjs';
3
+ import { dppProvider } from './dpp/provider.js';
4
+ // @ts-ignore
5
+ dppProvider.setDpp(protocol);
6
+ export * from './dpp/enums.js';
7
+ export * from './dpp/dpp.js';
8
+ export * from './dpp/types.js';
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  // Original code: https://github.com/kevinAlbs/Base122
2
3
  // Provides functions for encoding/decoding data to and from base-122.
3
4
  const kIllegals = [
@@ -15,7 +16,7 @@ const kShortened = 0b111; // Uses the illegal index to signify the last two-byte
15
16
  * with raw data bytes or a string of bytes (i.e. the type of argument to btoa())
16
17
  * @returns {Uint8Array} The data in a regular array representing byte values.
17
18
  */
18
- export function decode(base122Data) {
19
+ function decode(base122Data) {
19
20
  const strData = typeof (base122Data) === 'string' ? base122Data : utf8DataToString(base122Data);
20
21
  const decoded = [];
21
22
  let curByte = 0;
@@ -61,3 +62,4 @@ export function decode(base122Data) {
61
62
  function utf8DataToString(data) {
62
63
  return new TextDecoder().decode(data);
63
64
  }
65
+ module.exports = { decode };
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "pshenmic-dpp",
3
- "version": "2.0.0-dev.2",
3
+ "version": "2.0.0-dev.21",
4
4
  "main": "dist/src/wasm.js",
5
5
  "types": "dist/src/wasm.d.ts",
6
6
  "react-native": "./dist/src/react-native.js",
7
7
  "type": "module",
8
8
  "repository": {
9
9
  "type": "git",
10
- "url": "https://github.com/owl352/pshenmic-dpp"
10
+ "url": "git+https://github.com/owl352/pshenmic-dpp.git"
11
11
  },
12
12
  "scripts": {
13
13
  "build:bin": "node build.cjs",
14
- "build:ts": "tsc && cp -R pkg/**/*.*.node dist/binaries/",
14
+ "build:ts": "tsc && cp -R pkg/**/*.*.node dist/binaries/ && cp -R pkg/binaries/native dist/binaries/",
15
15
  "build:full": "npm run build:bin && npm run build:ts",
16
16
  "ferric:build": "ferric build",
17
17
  "bundle": "rollup -c",
@@ -20,40 +20,30 @@
20
20
  "lint:rust": "cargo fmt",
21
21
  "lint:src": "ts-standard --fix ./pkg/src",
22
22
  "lint:tests": "ts-standard --fix ./pkg/src",
23
- "lint": "npm run lint:rust && npm run lint:src && npm run lint:tests"
23
+ "lint": "npm run lint:rust && npm run lint:src && npm run lint:tests",
24
+ "prepack": "npm pkg delete devDependencies"
24
25
  },
25
26
  "files": [
26
27
  "dist/",
27
28
  "tests/"
28
29
  ],
30
+ "exports": {
31
+ ".": {
32
+ "browser": "./dist/src/wasm.js",
33
+ "node": "./dist/src/native.js",
34
+ "react-native": "./dist/src/react-native.js",
35
+ "default": "./dist/src/wasm.js"
36
+ },
37
+ "./wasm": "./dist/src/wasm.js",
38
+ "./wasm/utils": "./dist/src/dpp/utils.js",
39
+ "./native": "./dist/src/native.js"
40
+ },
29
41
  "author": "owl352",
30
42
  "license": "ISC",
31
43
  "description": "",
32
- "devDependencies": {
33
- "@babel/core": "^7.28.5",
34
- "@babel/preset-env": "^7.28.5",
35
- "@babel/preset-typescript": "^7.28.5",
36
- "@scure/base": "^1.2.4",
37
- "@types/jest": "^30.0.0",
38
- "@types/node": "^24.0.13",
39
- "babel": "^6.23.0",
40
- "babel-jest": "^30.2.0",
41
- "core-js": "^3.41.0",
42
- "ferric-cli": "0.3.9",
43
- "jest": "^30.2.0",
44
- "mocha": "^11.1.0",
45
- "node-addon-api": "^8.5.0",
46
- "path": "^0.12.7",
47
- "toml": "^3.0.0",
48
- "ts-morph": "^26.0.0",
49
- "tsx": "^4.20.6",
50
- "typedoc": "^0.28.7",
51
- "typescript": "^5.8.3",
52
- "ts-standard": "^12.0.2"
53
- },
54
44
  "dependencies": {
55
- "@emnapi/core": "^1.7.0",
56
- "@emnapi/runtime": "^1.7.0",
45
+ "@emnapi/core": "1.9.0",
46
+ "@emnapi/runtime": "1.9.0",
57
47
  "@tybys/wasm-util": "^0.10.1",
58
48
  "fflate": "^0.8.2"
59
49
  }