pshenmic-dpp 2.0.0-dev.25 → 2.0.0-dev.27

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 (70) hide show
  1. package/dist/binaries/bindingsTypes.d.ts +51 -1
  2. package/dist/binaries/bindingsTypes.js +1 -0
  3. package/dist/binaries/native/aarch64-apple-darwin/pshenmic_dpp.node +0 -0
  4. package/dist/binaries/native/aarch64-pc-windows-msvc/pshenmic_dpp.node +0 -0
  5. package/dist/binaries/native/aarch64-unknown-linux-gnu/pshenmic_dpp.node +0 -0
  6. package/dist/binaries/native/aarch64-unknown-linux-musl/pshenmic_dpp.node +0 -0
  7. package/dist/binaries/native/x86_64-apple-darwin/pshenmic_dpp.node +0 -0
  8. package/dist/binaries/native/x86_64-pc-windows-msvc/pshenmic_dpp.node +0 -0
  9. package/dist/binaries/native/x86_64-unknown-linux-gnu/pshenmic_dpp.node +0 -0
  10. package/dist/binaries/native/x86_64-unknown-linux-musl/pshenmic_dpp.node +0 -0
  11. package/dist/binaries/node.cjs +42 -21
  12. package/dist/binaries/node.d.cts +2 -2
  13. package/dist/binaries/pshenmic_dpp.android.node/arm64-v8a/libpshenmic_dpp.so +0 -0
  14. package/dist/binaries/pshenmic_dpp.apple.node/ios-arm64-simulator/libpshenmic_dpp.framework/libpshenmic_dpp +0 -0
  15. package/dist/binaries/wasm/wasmBytes.cjs +1 -1
  16. package/dist/src/dpp/structs/AddressTransitions/AddressCreditWithdrawalTransition.d.ts +3 -1
  17. package/dist/src/dpp/structs/AddressTransitions/AddressCreditWithdrawalTransition.js +6 -0
  18. package/dist/src/dpp/structs/AddressTransitions/AddressFundingFromAssetLockTransition.d.ts +2 -1
  19. package/dist/src/dpp/structs/AddressTransitions/AddressFundingFromAssetLockTransition.js +3 -0
  20. package/dist/src/dpp/structs/AddressTransitions/AddressFundsTransferTransition.d.ts +3 -1
  21. package/dist/src/dpp/structs/AddressTransitions/AddressFundsTransferTransition.js +6 -0
  22. package/dist/src/dpp/structs/AddressTransitions/IdentityCreateFromAddressesTransition.d.ts +2 -1
  23. package/dist/src/dpp/structs/AddressTransitions/IdentityCreateFromAddressesTransition.js +3 -0
  24. package/dist/src/dpp/structs/AddressTransitions/IdentityCreditTransferToAddressesTransition.d.ts +2 -1
  25. package/dist/src/dpp/structs/AddressTransitions/IdentityCreditTransferToAddressesTransition.js +3 -0
  26. package/dist/src/dpp/structs/AddressTransitions/IdentityTopUpFromAddressesTransition.d.ts +2 -1
  27. package/dist/src/dpp/structs/AddressTransitions/IdentityTopUpFromAddressesTransition.js +3 -0
  28. package/dist/src/dpp/structs/Batch/BatchTransition.d.ts +2 -1
  29. package/dist/src/dpp/structs/Batch/BatchTransition.js +3 -0
  30. package/dist/src/dpp/structs/DataContractTransitions/DataContractCreateTransition.d.ts +2 -1
  31. package/dist/src/dpp/structs/DataContractTransitions/DataContractCreateTransition.js +3 -0
  32. package/dist/src/dpp/structs/DataContractTransitions/DataContractUpdateTransition.d.ts +2 -1
  33. package/dist/src/dpp/structs/DataContractTransitions/DataContractUpdateTransition.js +3 -0
  34. package/dist/src/dpp/structs/IdentityTransitions/IdentityCreateTransition.d.ts +2 -1
  35. package/dist/src/dpp/structs/IdentityTransitions/IdentityCreateTransition.js +3 -0
  36. package/dist/src/dpp/structs/IdentityTransitions/IdentityCreditTransfer.d.ts +2 -1
  37. package/dist/src/dpp/structs/IdentityTransitions/IdentityCreditTransfer.js +3 -0
  38. package/dist/src/dpp/structs/IdentityTransitions/IdentityCreditWithdrawalTransition.d.ts +2 -1
  39. package/dist/src/dpp/structs/IdentityTransitions/IdentityCreditWithdrawalTransition.js +3 -0
  40. package/dist/src/dpp/structs/IdentityTransitions/IdentityTopUpTransition.d.ts +2 -1
  41. package/dist/src/dpp/structs/IdentityTransitions/IdentityTopUpTransition.js +3 -0
  42. package/dist/src/dpp/structs/IdentityTransitions/IdentityUpdateTransition.d.ts +2 -1
  43. package/dist/src/dpp/structs/IdentityTransitions/IdentityUpdateTransition.js +3 -0
  44. package/dist/src/dpp/structs/MasternodeVote/MasternodeVoteTransition.d.ts +2 -1
  45. package/dist/src/dpp/structs/MasternodeVote/MasternodeVoteTransition.js +3 -0
  46. package/dist/src/dpp/structs/Orchard/RecoveredNote.d.ts +1 -0
  47. package/dist/src/dpp/structs/Orchard/RecoveredNote.js +3 -0
  48. package/dist/src/dpp/structs/PlatformAddress/PlatformAddress.d.ts +9 -1
  49. package/dist/src/dpp/structs/PlatformAddress/PlatformAddress.js +10 -0
  50. package/dist/src/dpp/structs/ShieldedTransitions/IdentityCreateFromShieldedPoolTransition.d.ts +2 -1
  51. package/dist/src/dpp/structs/ShieldedTransitions/IdentityCreateFromShieldedPoolTransition.js +3 -0
  52. package/dist/src/dpp/structs/ShieldedTransitions/ShieldFromAssetLockTransition.d.ts +2 -1
  53. package/dist/src/dpp/structs/ShieldedTransitions/ShieldFromAssetLockTransition.js +3 -0
  54. package/dist/src/dpp/structs/ShieldedTransitions/ShieldTransition.d.ts +2 -1
  55. package/dist/src/dpp/structs/ShieldedTransitions/ShieldTransition.js +3 -0
  56. package/dist/src/dpp/structs/ShieldedTransitions/ShieldedTransferTransition.d.ts +2 -1
  57. package/dist/src/dpp/structs/ShieldedTransitions/ShieldedTransferTransition.js +3 -0
  58. package/dist/src/dpp/structs/ShieldedTransitions/ShieldedWithdrawalTransition.d.ts +2 -1
  59. package/dist/src/dpp/structs/ShieldedTransitions/ShieldedWithdrawalTransition.js +3 -0
  60. package/dist/src/dpp/structs/ShieldedTransitions/UnshieldTransition.d.ts +2 -1
  61. package/dist/src/dpp/structs/ShieldedTransitions/UnshieldTransition.js +3 -0
  62. package/dist/src/dpp/structs/StateTransition.d.ts +2 -1
  63. package/dist/src/dpp/structs/StateTransition.js +3 -0
  64. package/dist/src/dpp/types.d.ts +6 -0
  65. package/dist/src/dpp/verify/StateTransition/verifyStateTransitionResult.js +2 -1
  66. package/package.json +1 -1
  67. package/tests/unit/AddressTransitionsFees.spec.ts +274 -0
  68. package/tests/unit/Shielded.spec.ts +37 -4
  69. package/tests/unit/ShieldedTransitions.spec.ts +168 -0
  70. package/tests/unit/StateTransitionFees.spec.ts +177 -0
@@ -31,6 +31,8 @@ export declare class AddressCreditWithdrawalTransitionNAPI {
31
31
  set feeStrategy(jsFeeStrategy: Array<AddressFundsFeeStrategyStepNAPI>);
32
32
  set userFeeIncrease(userFeeIncrease: number);
33
33
  set inputWitness(jsInputWitnesses: Array<AddressWitnessNAPI>);
34
+ static estimateMinFee(jsInputCount: number, jsHasChangeOutput: boolean, jsPlatformVersion?: PlatformVersionNAPI | undefined | null): BigIntString;
35
+ calculateMinRequiredFee(jsPlatformVersion?: PlatformVersionNAPI | undefined | null): BigIntString;
34
36
  bytes(): Uint8Array;
35
37
  hex(): string;
36
38
  base64(): string;
@@ -56,6 +58,7 @@ export declare class AddressFundingFromAssetLockTransitionNAPI {
56
58
  set feeStrategy(jsFeeStrategy: Array<AddressFundsFeeStrategyStepNAPI>);
57
59
  set userFeeIncrease(userFeeIncrease: number);
58
60
  set inputWitness(jsInputWitnesses: Array<AddressWitnessNAPI>);
61
+ calculateMinRequiredFee(jsPlatformVersion?: PlatformVersionNAPI | undefined | null): BigIntString;
59
62
  bytes(): Uint8Array;
60
63
  hex(): string;
61
64
  base64(): string;
@@ -84,6 +87,8 @@ export declare class AddressFundsTransferTransitionNAPI {
84
87
  set feeStrategy(jsFeeStrategy: Array<AddressFundsFeeStrategyStepNAPI>);
85
88
  set userFeeIncrease(userFeeIncrease: number);
86
89
  set inputWitness(jsInputWitnesses: Array<AddressWitnessNAPI>);
90
+ static estimateMinFee(jsInputCount: number, jsOutputCount: number, jsPlatformVersion?: PlatformVersionNAPI | undefined | null): BigIntString;
91
+ calculateMinRequiredFee(jsPlatformVersion?: PlatformVersionNAPI | undefined | null): BigIntString;
87
92
  bytes(): Uint8Array;
88
93
  hex(): string;
89
94
  base64(): string;
@@ -148,6 +153,7 @@ export declare class BatchTransitionNAPI {
148
153
  setIdentityContractNonce(nonce: BigIntString): void;
149
154
  toStateTransition(): StateTransitionNAPI;
150
155
  static fromStateTransition(stateTransition: StateTransitionNAPI): BatchTransitionNAPI;
156
+ calculateMinRequiredFee(jsPlatformVersion?: PlatformVersionNAPI | undefined | null): BigIntString;
151
157
  bytes(): Uint8Array;
152
158
  hex(): string;
153
159
  base64(): string;
@@ -285,6 +291,7 @@ export declare class DataContractCreateTransitionNAPI {
285
291
  static fromBytes(bytes: Uint8Array): DataContractCreateTransitionNAPI;
286
292
  static fromHex(hex: string): DataContractCreateTransitionNAPI;
287
293
  static fromBase64(base64: string): DataContractCreateTransitionNAPI;
294
+ calculateMinRequiredFee(jsPlatformVersion?: PlatformVersionNAPI | undefined | null): BigIntString;
288
295
  bytes(): Uint8Array;
289
296
  hex(): string;
290
297
  base64(): string;
@@ -334,6 +341,7 @@ export declare class DataContractUpdateTransitionNAPI {
334
341
  static fromBytes(bytes: Uint8Array): DataContractUpdateTransitionNAPI;
335
342
  static fromHex(hex: string): DataContractUpdateTransitionNAPI;
336
343
  static fromBase64(base64: string): DataContractUpdateTransitionNAPI;
344
+ calculateMinRequiredFee(jsPlatformVersion?: PlatformVersionNAPI | undefined | null): BigIntString;
337
345
  bytes(): Uint8Array;
338
346
  hex(): string;
339
347
  base64(): string;
@@ -576,6 +584,7 @@ export declare class IdentityCreateFromAddressesTransitionNAPI {
576
584
  set feeStrategy(jsFeeStrategy: Array<AddressFundsFeeStrategyStepNAPI>);
577
585
  set userFeeIncrease(userFeeIncrease: number);
578
586
  set inputWitness(jsInputWitnesses: Array<AddressWitnessNAPI>);
587
+ calculateMinRequiredFee(jsPlatformVersion?: PlatformVersionNAPI | undefined | null): BigIntString;
579
588
  bytes(): Uint8Array;
580
589
  hex(): string;
581
590
  base64(): string;
@@ -617,6 +626,7 @@ export declare class IdentityCreateFromShieldedPoolTransitionNAPI {
617
626
  set bindingsSignature(jsBindingsSignature: Uint8Array);
618
627
  set sendToAddressOnCreationFailure(jsAddress: PlatformAddressLikeNAPI);
619
628
  set identityId(jsId: IdentifierLikeNAPI);
629
+ static computeMinimumFee(jsNumActions: number, jsNumKeys: number, jsPlatformVersion?: PlatformVersionNAPI | undefined | null): BigIntString;
620
630
  toStateTransition(): StateTransitionNAPI;
621
631
  static fromStateTransition(st: StateTransitionNAPI): IdentityCreateFromShieldedPoolTransitionNAPI;
622
632
  }
@@ -625,6 +635,7 @@ export declare class IdentityCreateTransitionNAPI {
625
635
  static default(jsPlatformVersion: DynamicValue): IdentityCreateTransitionNAPI;
626
636
  static fromHex(hex: string): IdentityCreateTransitionNAPI;
627
637
  static fromBase64(base64: string): IdentityCreateTransitionNAPI;
638
+ calculateMinRequiredFee(jsPlatformVersion?: PlatformVersionNAPI | undefined | null): BigIntString;
628
639
  bytes(): Uint8Array;
629
640
  static fromBytes(bytes: Uint8Array): IdentityCreateTransitionNAPI;
630
641
  get publicKeys(): Array<IdentityPublicKeyInCreationNAPI>;
@@ -642,6 +653,7 @@ export declare class IdentityCreateTransitionNAPI {
642
653
  }
643
654
  export declare class IdentityCreditTransferNAPI {
644
655
  constructor(jsSender: IdentifierLikeNAPI, amount: BigIntString, jsRecipient: IdentifierLikeNAPI, nonce: BigIntString, userFeeIncrease?: number | undefined | null);
656
+ calculateMinRequiredFee(jsPlatformVersion?: PlatformVersionNAPI | undefined | null): BigIntString;
645
657
  bytes(): Uint8Array;
646
658
  hex(): string;
647
659
  base64(): string;
@@ -680,6 +692,7 @@ export declare class IdentityCreditTransferToAddressesTransitionNAPI {
680
692
  set userFeeIncrease(userFeeIncrease: number);
681
693
  set signaturePublicKeyId(keyId: number);
682
694
  set signature(signature: Uint8Array);
695
+ calculateMinRequiredFee(jsPlatformVersion?: PlatformVersionNAPI | undefined | null): BigIntString;
683
696
  bytes(): Uint8Array;
684
697
  hex(): string;
685
698
  base64(): string;
@@ -715,6 +728,7 @@ export declare class IdentityCreditWithdrawalTransitionNAPI {
715
728
  set signaturePublicKeyId(signaturePublicKeyId: number);
716
729
  static fromHex(hex: string): IdentityCreditWithdrawalTransitionNAPI;
717
730
  static fromBase64(base64: string): IdentityCreditWithdrawalTransitionNAPI;
731
+ calculateMinRequiredFee(jsPlatformVersion?: PlatformVersionNAPI | undefined | null): BigIntString;
718
732
  bytes(): Uint8Array;
719
733
  hex(): string;
720
734
  base64(): string;
@@ -822,6 +836,7 @@ export declare class IdentityTopUpFromAddressesTransitionNAPI {
822
836
  set feeStrategy(jsFeeStrategy: Array<AddressFundsFeeStrategyStepNAPI>);
823
837
  set userFeeIncrease(userFeeIncrease: number);
824
838
  set inputWitness(jsInputWitnesses: Array<AddressWitnessNAPI>);
839
+ calculateMinRequiredFee(jsPlatformVersion?: PlatformVersionNAPI | undefined | null): BigIntString;
825
840
  bytes(): Uint8Array;
826
841
  hex(): string;
827
842
  base64(): string;
@@ -844,6 +859,7 @@ export declare class IdentityTopUpTransitionNAPI {
844
859
  get signature(): Uint8Array;
845
860
  getSignableBytes(): Uint8Array;
846
861
  set signature(signature: Uint8Array);
862
+ calculateMinRequiredFee(jsPlatformVersion?: PlatformVersionNAPI | undefined | null): BigIntString;
847
863
  bytes(): Uint8Array;
848
864
  hex(): string;
849
865
  base64(): string;
@@ -877,6 +893,7 @@ export declare class IdentityUpdateTransitionNAPI {
877
893
  set signaturePublicKeyId(signaturePublicKeyId: number);
878
894
  static fromHex(hex: string): IdentityUpdateTransitionNAPI;
879
895
  static fromBase64(base64: string): IdentityUpdateTransitionNAPI;
896
+ calculateMinRequiredFee(jsPlatformVersion?: PlatformVersionNAPI | undefined | null): BigIntString;
880
897
  bytes(): Uint8Array;
881
898
  hex(): string;
882
899
  base64(): string;
@@ -935,6 +952,7 @@ export declare class MasternodeVoteTransitionNAPI {
935
952
  set signature(signature: Uint8Array);
936
953
  static fromHex(hex: string): MasternodeVoteTransitionNAPI;
937
954
  static fromBase64(base64: string): MasternodeVoteTransitionNAPI;
955
+ calculateMinRequiredFee(jsPlatformVersion?: PlatformVersionNAPI | undefined | null): BigIntString;
938
956
  bytes(): Uint8Array;
939
957
  hex(): string;
940
958
  base64(): string;
@@ -1038,6 +1056,17 @@ export declare class PlatformAddressInfoNAPI {
1038
1056
  export declare class PlatformAddressNAPI {
1039
1057
  constructor(address: PlatformAddressLikeNAPI);
1040
1058
  bytes(): Uint8Array;
1059
+ /**
1060
+ * Storage fee GroveDB charges for creating balance entries for addresses that are not in
1061
+ * state yet.
1062
+ *
1063
+ * Minimum fees price a transition as if every one of its outputs pays a fresh address, but
1064
+ * the fee actually charged is metered: paying an address that already exists writes no new
1065
+ * bytes and costs (close to) nothing in storage, while every address created costs
1066
+ * `PLATFORM_ADDRESS_STORAGE_BYTES` at the disk rate. Add this to a processing estimate when
1067
+ * you know how many of your outputs are new.
1068
+ */
1069
+ static estimateStorageFeeForNewAddresses(jsAddressCount: number, jsPlatformVersion?: PlatformVersionNAPI | undefined | null): BigIntString;
1041
1070
  toAddress(jsNetwork: DynamicValue): string;
1042
1071
  toBech32m(jsNetwork: DynamicValue): string;
1043
1072
  isP2PKH(): boolean;
@@ -1254,6 +1283,7 @@ export declare class ShieldedTransferTransitionNAPI {
1254
1283
  set anchor(jsAnchor: Uint8Array);
1255
1284
  set proof(proof: Uint8Array);
1256
1285
  set bindingsSignature(jsBindingsSignature: Uint8Array);
1286
+ static computeMinimumFee(jsNumActions: number, jsPlatformVersion?: PlatformVersionNAPI | undefined | null): BigIntString;
1257
1287
  toStateTransition(): StateTransitionNAPI;
1258
1288
  static fromStateTransition(st: StateTransitionNAPI): ShieldedTransferTransitionNAPI;
1259
1289
  }
@@ -1284,6 +1314,7 @@ export declare class ShieldedWithdrawalTransitionNAPI {
1284
1314
  set coreFeePerByte(coreFeePerByte: number);
1285
1315
  set pooling(jsPooling: DynamicValue);
1286
1316
  set outputScript(outputScript: CoreScriptNAPI);
1317
+ static computeMinimumFee(jsNumActions: number, jsPlatformVersion?: PlatformVersionNAPI | undefined | null): BigIntString;
1287
1318
  toStateTransition(): StateTransitionNAPI;
1288
1319
  static fromStateTransition(st: StateTransitionNAPI): ShieldedWithdrawalTransitionNAPI;
1289
1320
  }
@@ -1305,6 +1336,7 @@ export declare class ShieldFromAssetLockTransitionNAPI {
1305
1336
  set bindingsSignature(jsBindingsSignature: Uint8Array);
1306
1337
  set surplusOutput(jsSurplusOutput: PlatformAddressLikeNAPI | undefined | null);
1307
1338
  set signature(signature: Uint8Array);
1339
+ static computeMinimumFee(jsNumActions: number, jsPlatformVersion?: PlatformVersionNAPI | undefined | null): BigIntString;
1308
1340
  toStateTransition(): StateTransitionNAPI;
1309
1341
  static fromStateTransition(st: StateTransitionNAPI): ShieldFromAssetLockTransitionNAPI;
1310
1342
  }
@@ -1328,6 +1360,7 @@ export declare class ShieldTransitionNAPI {
1328
1360
  set feeStrategy(feeStrategy: Array<AddressFundsFeeStrategyStepNAPI>);
1329
1361
  set userFeeIncrease(userFeeIncrease: number);
1330
1362
  set inputWitnesses(jsInputWitnesses: Array<AddressWitnessNAPI>);
1363
+ static computeMinimumFee(jsNumActions: number, jsPlatformVersion?: PlatformVersionNAPI | undefined | null): BigIntString;
1331
1364
  toStateTransition(): StateTransitionNAPI;
1332
1365
  static fromStateTransition(st: StateTransitionNAPI): ShieldTransitionNAPI;
1333
1366
  }
@@ -1354,6 +1387,15 @@ export declare class StateTransitionNAPI {
1354
1387
  static fromBase64(base64: string): StateTransitionNAPI;
1355
1388
  hash(skipSignature: boolean): string;
1356
1389
  getActionName(): string;
1390
+ /**
1391
+ * The minimum fee the network requires for this transition to be accepted.
1392
+ *
1393
+ * This is the same value the node checks the payer balance against before execution.
1394
+ * The fee actually charged is metered during execution and depends on state (for
1395
+ * example, paying an address that does not exist yet adds storage cost), so it can
1396
+ * be higher than this minimum.
1397
+ */
1398
+ calculateMinRequiredFee(jsPlatformVersion?: PlatformVersionNAPI | undefined | null): BigIntString;
1357
1399
  getActionType(): string;
1358
1400
  getActionTypeNumber(): number;
1359
1401
  getOwnerId(): IdentifierNAPI | null;
@@ -1755,6 +1797,7 @@ export declare class UnshieldTransitionNAPI {
1755
1797
  set anchor(jsAnchor: Uint8Array);
1756
1798
  set proof(proof: Uint8Array);
1757
1799
  set bindingsSignature(jsBindingsSignature: Uint8Array);
1800
+ static computeMinimumFee(jsNumActions: number, jsPlatformVersion?: PlatformVersionNAPI | undefined | null): BigIntString;
1758
1801
  toStateTransition(): StateTransitionNAPI;
1759
1802
  static fromStateTransition(st: StateTransitionNAPI): UnshieldTransitionNAPI;
1760
1803
  }
@@ -1878,6 +1921,12 @@ export declare class VerifiedShieldedPoolStateNAPI {
1878
1921
  export declare class VerifiedStateTransitionResultNAPI {
1879
1922
  rootHash: Uint8Array;
1880
1923
  get result(): DataContractNAPI | IdentityNAPI | IdentifierNAPI | VerifiedIdentityBalanceNAPI | VerifiedIdentityTokenInfoNAPI | VerifiedTokenPricingScheduleNAPI | TokenStatusNAPI | Array<VerifiedIdentityBalanceNAPI> | PartialIdentityNAPI | VerifiedBalanceTransferNAPI | Array<VerifiedDocumentNAPI> | DocumentNAPI | VerifiedTokenGroupActionWithDocumentNAPI | VerifiedTokenGroupActionWithTokenBalanceNAPI | VerifiedTokenGroupActionWithTokenIdentityInfoNAPI | VerifiedTokenGroupActionWithTokenPricingScheduleNAPI | VoteNAPI | Array<PlatformAddressInfoNAPI> | VerifiedIdentityFullWithAddressInfosNAPI | VerifiedIdentityWithAddressInfosNAPI | StoredAssetLockInfoNAPI | Array<[Uint8Array, boolean]> | [Array<[Uint8Array, boolean]>, Array<PlatformAddressInfoNAPI>] | [Array<[Uint8Array, boolean]>, Array<VerifiedDocumentNAPI>] | [StoredAssetLockInfoNAPI, Array<PlatformAddressInfoNAPI>] | [IdentityNAPI, Array<[Uint8Array, boolean]>];
1924
+ /**
1925
+ * Whether the proof binds the execution of this specific state transition.
1926
+ * When false the result is a height-pinned snapshot of the affected state,
1927
+ * not evidence that the transition executed.
1928
+ */
1929
+ get isExecutionProved(): boolean;
1881
1930
  }
1882
1931
  export declare class VerifiedTokenBalancesForIdentitiesNAPI {
1883
1932
  rootHash: Uint8Array;
@@ -2108,7 +2157,8 @@ export declare enum PlatformVersionNAPI {
2108
2157
  PLATFORM_V9 = 9,
2109
2158
  PLATFORM_V10 = 10,
2110
2159
  PLATFORM_V11 = 11,
2111
- PLATFORM_V12 = 12
2160
+ PLATFORM_V12 = 12,
2161
+ PLATFORM_V13 = 13
2112
2162
  }
2113
2163
  export declare enum PoolingNAPI {
2114
2164
  Never = 0,
@@ -58,6 +58,7 @@ export var PlatformVersionNAPI;
58
58
  PlatformVersionNAPI[PlatformVersionNAPI["PLATFORM_V10"] = 10] = "PLATFORM_V10";
59
59
  PlatformVersionNAPI[PlatformVersionNAPI["PLATFORM_V11"] = 11] = "PLATFORM_V11";
60
60
  PlatformVersionNAPI[PlatformVersionNAPI["PLATFORM_V12"] = 12] = "PLATFORM_V12";
61
+ PlatformVersionNAPI[PlatformVersionNAPI["PLATFORM_V13"] = 13] = "PLATFORM_V13";
61
62
  })(PlatformVersionNAPI || (PlatformVersionNAPI = {}));
62
63
  export var PoolingNAPI;
63
64
  (function (PoolingNAPI) {
@@ -3,10 +3,17 @@ const path = require('node:path');
3
3
  function isMusl() {
4
4
  if (process.platform !== 'linux')
5
5
  return false;
6
- const report = process.report?.getReport?.();
7
- return !report?.header?.glibcVersionRuntime;
6
+ try {
7
+ const report = process.report?.getReport?.();
8
+ return !report?.header?.glibcVersionRuntime;
9
+ }
10
+ catch {
11
+ // getReport() is unavailable in some embedders/worker contexts; assume
12
+ // glibc, and let the require below fall back to WebAssembly if wrong.
13
+ return false;
14
+ }
8
15
  }
9
- function getBinaryPath() {
16
+ function getTarget() {
10
17
  const platform = process.platform;
11
18
  const arch = process.arch;
12
19
  let target = '';
@@ -24,27 +31,41 @@ function getBinaryPath() {
24
31
  target = `x86_64-unknown-linux-${libc}`;
25
32
  }
26
33
  }
27
- // else if (platform === 'win32') {
28
- // if (arch === 'arm64') {
29
- // target = 'aarch64-pc-windows-msvc';
30
- // }
31
- // else {
32
- // target = 'x86_64-pc-windows-msvc';
33
- // }
34
- // }
34
+ else if (platform === 'win32') {
35
+ if (arch === 'arm64') {
36
+ target = 'aarch64-pc-windows-msvc';
37
+ }
38
+ else {
39
+ target = 'x86_64-pc-windows-msvc';
40
+ }
41
+ }
35
42
  else {
36
43
  console.error(`Unsupported platform: ${platform} ${arch}. Using WebAssembly instead Node-API`);
37
44
  return null;
38
45
  }
39
- console.log(`running on native dpp (${target})`);
40
- return path.join('native', target, 'pshenmic_dpp.node');
41
- }
42
- const binaryPath = getBinaryPath();
43
- let exportedModule;
44
- if (binaryPath !== null) {
45
- exportedModule = require(`./${binaryPath}`);
46
+ return target;
46
47
  }
47
- else {
48
- exportedModule = require('./wasmCreation.cjs');
48
+ // The native addon can be unusable even on a supported platform: the binary may
49
+ // be missing from the package, built for another libc/arch, or fail to link
50
+ // against a system dependency (e.g. the VC++ runtime on Windows). None of that
51
+ // should be fatal — WebAssembly is a complete fallback, so any load failure
52
+ // degrades to it instead of taking the whole import down.
53
+ function loadNative() {
54
+ const target = getTarget();
55
+ if (target === null) {
56
+ return null;
57
+ }
58
+ try {
59
+ const nativeModule = require(`./${path.join('native', target, 'pshenmic_dpp.node')}`);
60
+ console.log(`running on native dpp (${target})`);
61
+ return nativeModule;
62
+ }
63
+ catch (error) {
64
+ // Only the first line: node appends a multi-line "Require stack" to
65
+ // MODULE_NOT_FOUND messages, which buries the actual reason.
66
+ const reason = String(error?.message ?? error).split('\n')[0];
67
+ console.error(`Failed to load native dpp (${target}): ${reason}. Using WebAssembly instead Node-API`);
68
+ return null;
69
+ }
49
70
  }
50
- module.exports = exportedModule;
71
+ module.exports = loadNative() ?? require('./wasmCreation.cjs');
@@ -1,2 +1,2 @@
1
- export = exportedModule;
2
- declare let exportedModule: any;
1
+ declare const _exports: any;
2
+ export = _exports;