pshenmic-dpp 2.0.0-dev.8 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +164 -77
- package/dist/binaries/bindingsTypes.d.ts +903 -18
- package/dist/binaries/bindingsTypes.js +13 -0
- package/dist/binaries/memory.cjs +7 -0
- package/dist/binaries/memory.d.cts +2 -0
- package/dist/binaries/native/aarch64-apple-darwin/pshenmic_dpp.node +0 -0
- package/dist/binaries/native/aarch64-pc-windows-msvc/pshenmic_dpp.node +0 -0
- package/dist/binaries/native/aarch64-unknown-linux-gnu/pshenmic_dpp.node +0 -0
- package/dist/binaries/native/aarch64-unknown-linux-musl/pshenmic_dpp.node +0 -0
- package/dist/binaries/native/x86_64-apple-darwin/pshenmic_dpp.node +0 -0
- package/dist/binaries/native/x86_64-pc-windows-msvc/pshenmic_dpp.node +0 -0
- package/dist/binaries/native/x86_64-unknown-linux-gnu/pshenmic_dpp.node +0 -0
- package/dist/binaries/native/x86_64-unknown-linux-musl/pshenmic_dpp.node +0 -0
- package/dist/binaries/node.cjs +71 -0
- package/dist/binaries/node.d.cts +2 -0
- package/dist/binaries/pshenmic_dpp.android.node/arm64-v8a/libpshenmic_dpp.so +0 -0
- package/dist/binaries/pshenmic_dpp.apple.node/Info.plist +29 -0
- package/dist/binaries/pshenmic_dpp.apple.node/ios-arm64-simulator/libpshenmic_dpp.framework/Info.plist +24 -0
- package/dist/binaries/pshenmic_dpp.apple.node/ios-arm64-simulator/libpshenmic_dpp.framework/libpshenmic_dpp +0 -0
- package/dist/binaries/pshenmic_dpp.apple.node/react-native-node-api-module +0 -0
- package/dist/binaries/pshenmic_dpp.d.ts +60 -0
- package/dist/binaries/pshenmic_dpp.js +1 -1
- package/dist/binaries/wasm/wasmBytes.cjs +4 -0
- package/dist/binaries/wasm/wasmBytes.d.cts +2 -0
- package/dist/binaries/wasm/workerBundle.cjs +6 -0
- package/dist/binaries/wasm/workerBundle.d.cts +2 -0
- package/dist/binaries/wasm.d.ts +60 -0
- package/dist/binaries/wasm.js +2 -44
- package/dist/binaries/wasmCreation.cjs +127 -0
- package/dist/binaries/wasmCreation.d.cts +4 -0
- package/dist/src/dpp/dpp.d.ts +33 -0
- package/dist/src/dpp/dpp.js +33 -0
- 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 +3 -1
- package/dist/src/dpp/structs/AddressTransitions/AddressCreditWithdrawalTransition.js +6 -0
- package/dist/src/dpp/structs/AddressTransitions/AddressFundingFromAssetLockTransition.d.ts +2 -1
- package/dist/src/dpp/structs/AddressTransitions/AddressFundingFromAssetLockTransition.js +3 -0
- package/dist/src/dpp/structs/AddressTransitions/AddressFundsTransferTransition.d.ts +3 -1
- package/dist/src/dpp/structs/AddressTransitions/AddressFundsTransferTransition.js +6 -0
- package/dist/src/dpp/structs/AddressTransitions/IdentityCreateFromAddressesTransition.d.ts +2 -1
- package/dist/src/dpp/structs/AddressTransitions/IdentityCreateFromAddressesTransition.js +3 -0
- package/dist/src/dpp/structs/AddressTransitions/IdentityCreditTransferToAddressesTransition.d.ts +2 -1
- package/dist/src/dpp/structs/AddressTransitions/IdentityCreditTransferToAddressesTransition.js +3 -0
- package/dist/src/dpp/structs/AddressTransitions/IdentityTopUpFromAddressesTransition.d.ts +2 -1
- package/dist/src/dpp/structs/AddressTransitions/IdentityTopUpFromAddressesTransition.js +3 -0
- package/dist/src/dpp/structs/Batch/BatchTransition.d.ts +2 -1
- package/dist/src/dpp/structs/Batch/BatchTransition.js +3 -0
- package/dist/src/dpp/structs/DataContractTransitions/DataContractCreateTransition.d.ts +2 -1
- package/dist/src/dpp/structs/DataContractTransitions/DataContractCreateTransition.js +3 -0
- package/dist/src/dpp/structs/DataContractTransitions/DataContractUpdateTransition.d.ts +2 -1
- package/dist/src/dpp/structs/DataContractTransitions/DataContractUpdateTransition.js +3 -0
- package/dist/src/dpp/structs/Identifier.js +3 -0
- package/dist/src/dpp/structs/IdentityTransitions/IdentityCreateTransition.d.ts +2 -1
- package/dist/src/dpp/structs/IdentityTransitions/IdentityCreateTransition.js +3 -0
- package/dist/src/dpp/structs/IdentityTransitions/IdentityCreditTransfer.d.ts +2 -1
- package/dist/src/dpp/structs/IdentityTransitions/IdentityCreditTransfer.js +3 -0
- package/dist/src/dpp/structs/IdentityTransitions/IdentityCreditWithdrawalTransition.d.ts +2 -1
- package/dist/src/dpp/structs/IdentityTransitions/IdentityCreditWithdrawalTransition.js +3 -0
- package/dist/src/dpp/structs/IdentityTransitions/IdentityTopUpTransition.d.ts +2 -1
- package/dist/src/dpp/structs/IdentityTransitions/IdentityTopUpTransition.js +3 -0
- package/dist/src/dpp/structs/IdentityTransitions/IdentityUpdateTransition.d.ts +2 -1
- package/dist/src/dpp/structs/IdentityTransitions/IdentityUpdateTransition.js +3 -0
- package/dist/src/dpp/structs/MasternodeVote/MasternodeVoteTransition.d.ts +2 -3
- package/dist/src/dpp/structs/MasternodeVote/MasternodeVoteTransition.js +3 -6
- package/dist/src/dpp/structs/Orchard/CommitmentTree.d.ts +14 -0
- package/dist/src/dpp/structs/Orchard/CommitmentTree.js +31 -0
- package/dist/src/dpp/structs/Orchard/FullViewingKey.d.ts +27 -0
- package/dist/src/dpp/structs/Orchard/FullViewingKey.js +45 -0
- package/dist/src/dpp/structs/Orchard/IdentityCreateFromShieldedPoolResult.d.ts +21 -0
- package/dist/src/dpp/structs/Orchard/IdentityCreateFromShieldedPoolResult.js +38 -0
- package/dist/src/dpp/structs/Orchard/IncomingViewingKey.d.ts +29 -0
- package/dist/src/dpp/structs/Orchard/IncomingViewingKey.js +44 -0
- package/dist/src/dpp/structs/Orchard/MerklePath.d.ts +11 -0
- package/dist/src/dpp/structs/Orchard/MerklePath.js +25 -0
- package/dist/src/dpp/structs/Orchard/Note.d.ts +18 -0
- package/dist/src/dpp/structs/Orchard/Note.js +42 -0
- package/dist/src/dpp/structs/Orchard/OrchardAddress.d.ts +27 -0
- package/dist/src/dpp/structs/Orchard/OrchardAddress.js +45 -0
- package/dist/src/dpp/structs/Orchard/OrchardProver.d.ts +19 -0
- package/dist/src/dpp/structs/Orchard/OrchardProver.js +34 -0
- package/dist/src/dpp/structs/Orchard/RecoveredNote.d.ts +19 -0
- package/dist/src/dpp/structs/Orchard/RecoveredNote.js +32 -0
- package/dist/src/dpp/structs/Orchard/ShieldedBuilder.d.ts +64 -0
- package/dist/src/dpp/structs/Orchard/ShieldedBuilder.js +79 -0
- package/dist/src/dpp/structs/Orchard/ShieldedMemo.d.ts +11 -0
- package/dist/src/dpp/structs/Orchard/ShieldedMemo.js +25 -0
- package/dist/src/dpp/structs/Orchard/ShieldedOutput.d.ts +23 -0
- package/dist/src/dpp/structs/Orchard/ShieldedOutput.js +41 -0
- package/dist/src/dpp/structs/Orchard/ShieldedWithdrawalResult.d.ts +11 -0
- package/dist/src/dpp/structs/Orchard/ShieldedWithdrawalResult.js +18 -0
- package/dist/src/dpp/structs/Orchard/SpendableNote.d.ts +13 -0
- package/dist/src/dpp/structs/Orchard/SpendableNote.js +27 -0
- package/dist/src/dpp/structs/PlatformAddress/PlatformAddress.d.ts +9 -1
- package/dist/src/dpp/structs/PlatformAddress/PlatformAddress.js +10 -0
- package/dist/src/dpp/structs/ShieldedTransitions/IdentityCreateFromShieldedPoolTransition.d.ts +32 -0
- package/dist/src/dpp/structs/ShieldedTransitions/IdentityCreateFromShieldedPoolTransition.js +76 -0
- package/dist/src/dpp/structs/ShieldedTransitions/SerializedAction.d.ts +19 -0
- package/dist/src/dpp/structs/ShieldedTransitions/SerializedAction.js +49 -0
- package/dist/src/dpp/structs/ShieldedTransitions/ShieldFromAssetLockTransition.d.ts +31 -0
- package/dist/src/dpp/structs/ShieldedTransitions/ShieldFromAssetLockTransition.js +80 -0
- package/dist/src/dpp/structs/ShieldedTransitions/ShieldTransition.d.ts +33 -0
- package/dist/src/dpp/structs/ShieldedTransitions/ShieldTransition.js +81 -0
- package/dist/src/dpp/structs/ShieldedTransitions/ShieldedTransferTransition.d.ts +22 -0
- package/dist/src/dpp/structs/ShieldedTransitions/ShieldedTransferTransition.js +54 -0
- package/dist/src/dpp/structs/ShieldedTransitions/ShieldedWithdrawalTransition.d.ts +30 -0
- package/dist/src/dpp/structs/ShieldedTransitions/ShieldedWithdrawalTransition.js +74 -0
- package/dist/src/dpp/structs/ShieldedTransitions/UnshieldTransition.d.ts +26 -0
- package/dist/src/dpp/structs/ShieldedTransitions/UnshieldTransition.js +62 -0
- package/dist/src/dpp/structs/StateTransition.d.ts +2 -1
- package/dist/src/dpp/structs/StateTransition.js +3 -0
- package/dist/src/dpp/types.d.ts +177 -3
- package/dist/src/dpp/verify/AddressFunds/utils.d.ts +5 -0
- package/dist/src/dpp/verify/AddressFunds/utils.js +28 -0
- package/dist/src/dpp/verify/AddressFunds/verifyAddressesBranchState.d.ts +12 -0
- package/dist/src/dpp/verify/AddressFunds/verifyAddressesBranchState.js +29 -0
- package/dist/src/dpp/verify/AddressFunds/verifyAddressesTrunkState.d.ts +9 -0
- package/dist/src/dpp/verify/AddressFunds/verifyAddressesTrunkState.js +30 -0
- package/dist/src/dpp/verify/AddressFunds/verifyRecentAddressBalanceChanges.d.ts +9 -0
- package/dist/src/dpp/verify/AddressFunds/verifyRecentAddressBalanceChanges.js +24 -0
- package/dist/src/dpp/verify/AddressFunds/verifyRecentCompactedAddressBalanceChanges.d.ts +10 -0
- package/dist/src/dpp/verify/AddressFunds/verifyRecentCompactedAddressBalanceChanges.js +30 -0
- 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/Shielded/verifyMostRecentShieldedAnchorProof.d.ts +2 -0
- package/dist/src/dpp/verify/Shielded/verifyMostRecentShieldedAnchorProof.js +9 -0
- package/dist/src/dpp/verify/Shielded/verifyShieldedAnchorsProof.d.ts +2 -0
- package/dist/src/dpp/verify/Shielded/verifyShieldedAnchorsProof.js +9 -0
- package/dist/src/dpp/verify/Shielded/verifyShieldedEncryptedNotesProof.d.ts +2 -0
- package/dist/src/dpp/verify/Shielded/verifyShieldedEncryptedNotesProof.js +15 -0
- package/dist/src/dpp/verify/Shielded/verifyShieldedNotesCountProof.d.ts +2 -0
- package/dist/src/dpp/verify/Shielded/verifyShieldedNotesCountProof.js +9 -0
- package/dist/src/dpp/verify/Shielded/verifyShieldedNullifiersProof.d.ts +2 -0
- package/dist/src/dpp/verify/Shielded/verifyShieldedNullifiersProof.js +12 -0
- package/dist/src/dpp/verify/Shielded/verifyShieldedPoolStateProof.d.ts +2 -0
- package/dist/src/dpp/verify/Shielded/verifyShieldedPoolStateProof.js +9 -0
- package/dist/src/dpp/verify/StateTransition/utils.js +76 -11
- package/dist/src/dpp/verify/StateTransition/verifyStateTransitionResult.js +2 -1
- package/dist/src/dpp/verify/System/verifyFinalizedEpochInfosProof.d.ts +2 -0
- package/dist/src/dpp/verify/System/verifyFinalizedEpochInfosProof.js +27 -0
- package/dist/src/native.d.ts +3 -0
- package/dist/src/native.js +8 -0
- package/dist/utils/{base122.js → base122.cjs} +3 -1
- package/package.json +19 -29
- package/tests/unit/AddressTransitionsFees.spec.ts +274 -0
- package/tests/unit/DataContract.spec.ts +281 -0
- package/tests/unit/DynamicValue.spec.ts +2 -2
- package/tests/unit/Identifier.spec.ts +1 -1
- package/tests/unit/Identity.spec.ts +1 -1
- package/tests/unit/IdentityPublicKey.spec.ts +1 -1
- package/tests/unit/NodeApi.spec.ts +49 -0
- package/tests/unit/Shielded.spec.ts +555 -0
- package/tests/unit/ShieldedTransitions.spec.ts +877 -0
- package/tests/unit/StateTransitionFees.spec.ts +177 -0
- package/tests/unit/TokenConfiguration.spec.ts +114 -0
- package/tests/unit/WebAssembly.spec.ts +88 -0
- package/tests/unit/utils/buildTokenConfiguration.ts +66 -0
- package/dist/binaries/pshenmic_dpp.android.node/x86_64/libpshenmic_dpp.so +0 -0
- package/dist/binaries/wasm/wasmBytes.d.ts +0 -2
- package/dist/binaries/wasm/wasmBytes.js +0 -2
- /package/dist/utils/{base122.d.ts → base122.d.cts} +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { OrchardAddressNAPI } from '../../../../binaries/bindingsTypes.js';
|
|
2
|
+
import { NetworkLike, ScopeLike } from '../../types.js';
|
|
3
|
+
import { FullViewingKeyWASM } from './FullViewingKey.js';
|
|
4
|
+
import { IncomingViewingKeyWASM } from './IncomingViewingKey.js';
|
|
5
|
+
export declare class OrchardAddressWASM {
|
|
6
|
+
/** @private **/
|
|
7
|
+
_rawOrchardAddress: OrchardAddressNAPI;
|
|
8
|
+
toBech32m(network: NetworkLike): string;
|
|
9
|
+
bytes(): Uint8Array;
|
|
10
|
+
static fromBech32m(bech32m: string): OrchardAddressWASM;
|
|
11
|
+
static fromBytes(bytes: Uint8Array): OrchardAddressWASM;
|
|
12
|
+
/** Derives the address from a BIP-39 seed via ZIP-32 (m/32'/coinType'/account'). */
|
|
13
|
+
static fromSeed(seed: Uint8Array, coinType: number, account: number, diversifierIndex?: number, scope?: ScopeLike): OrchardAddressWASM;
|
|
14
|
+
/**
|
|
15
|
+
* Derives the address at `diversifierIndex` (default 0) from a full viewing
|
|
16
|
+
* key, for `scope` (default External).
|
|
17
|
+
*/
|
|
18
|
+
static fromFullViewingKey(fullViewingKey: FullViewingKeyWASM, diversifierIndex?: number, scope?: ScopeLike): OrchardAddressWASM;
|
|
19
|
+
/**
|
|
20
|
+
* Derives the address at `diversifierIndex` (default 0) from an incoming
|
|
21
|
+
* viewing key. The scope is fixed by the key itself.
|
|
22
|
+
*/
|
|
23
|
+
static fromIncomingViewingKey(incomingViewingKey: IncomingViewingKeyWASM, diversifierIndex?: number): OrchardAddressWASM;
|
|
24
|
+
static createFromRawInstance(rawInstance: OrchardAddressNAPI): OrchardAddressWASM;
|
|
25
|
+
}
|
|
26
|
+
/** Derives the sender's Orchard outgoing viewing key (32 bytes) from a BIP-39 seed. */
|
|
27
|
+
export declare function orchardOvkFromSeed(seed: Uint8Array, coinType: number, account: number): Uint8Array;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { dppProvider } from '../../provider.js';
|
|
2
|
+
import { valueToDynamicValue } from '../../utils.js';
|
|
3
|
+
export class OrchardAddressWASM {
|
|
4
|
+
/** @private **/
|
|
5
|
+
_rawOrchardAddress;
|
|
6
|
+
toBech32m(network) {
|
|
7
|
+
return this._rawOrchardAddress.toBech32m(valueToDynamicValue(network));
|
|
8
|
+
}
|
|
9
|
+
bytes() {
|
|
10
|
+
return this._rawOrchardAddress.bytes();
|
|
11
|
+
}
|
|
12
|
+
static fromBech32m(bech32m) {
|
|
13
|
+
return OrchardAddressWASM.createFromRawInstance(dppProvider.dpp.OrchardAddressNAPI.fromBech32m(bech32m));
|
|
14
|
+
}
|
|
15
|
+
static fromBytes(bytes) {
|
|
16
|
+
return OrchardAddressWASM.createFromRawInstance(dppProvider.dpp.OrchardAddressNAPI.fromBytes(bytes));
|
|
17
|
+
}
|
|
18
|
+
/** Derives the address from a BIP-39 seed via ZIP-32 (m/32'/coinType'/account'). */
|
|
19
|
+
static fromSeed(seed, coinType, account, diversifierIndex, scope) {
|
|
20
|
+
return OrchardAddressWASM.createFromRawInstance(dppProvider.dpp.OrchardAddressNAPI.fromSeed(seed, coinType, account, diversifierIndex, scope == null ? undefined : valueToDynamicValue(scope)));
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Derives the address at `diversifierIndex` (default 0) from a full viewing
|
|
24
|
+
* key, for `scope` (default External).
|
|
25
|
+
*/
|
|
26
|
+
static fromFullViewingKey(fullViewingKey, diversifierIndex, scope) {
|
|
27
|
+
return OrchardAddressWASM.createFromRawInstance(dppProvider.dpp.OrchardAddressNAPI.fromFullViewingKey(fullViewingKey._rawFullViewingKey, diversifierIndex, scope == null ? undefined : valueToDynamicValue(scope)));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Derives the address at `diversifierIndex` (default 0) from an incoming
|
|
31
|
+
* viewing key. The scope is fixed by the key itself.
|
|
32
|
+
*/
|
|
33
|
+
static fromIncomingViewingKey(incomingViewingKey, diversifierIndex) {
|
|
34
|
+
return OrchardAddressWASM.createFromRawInstance(dppProvider.dpp.OrchardAddressNAPI.fromIncomingViewingKey(incomingViewingKey._rawIncomingViewingKey, diversifierIndex));
|
|
35
|
+
}
|
|
36
|
+
static createFromRawInstance(rawInstance) {
|
|
37
|
+
const instance = Object.create(OrchardAddressWASM.prototype);
|
|
38
|
+
instance._rawOrchardAddress = rawInstance;
|
|
39
|
+
return instance;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** Derives the sender's Orchard outgoing viewing key (32 bytes) from a BIP-39 seed. */
|
|
43
|
+
export function orchardOvkFromSeed(seed, coinType, account) {
|
|
44
|
+
return dppProvider.dpp.orchardOvkFromSeed(seed, coinType, account);
|
|
45
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { OrchardProverNAPI } from '../../../../binaries/bindingsTypes.js';
|
|
2
|
+
/**
|
|
3
|
+
* Reusable Orchard prover holding the Halo 2 proving key. Building it is
|
|
4
|
+
* expensive (~seconds); construct once and reuse. (The `ShieldedBuilderWASM`
|
|
5
|
+
* already builds its own prover internally — this is exposed for standalone use.)
|
|
6
|
+
*/
|
|
7
|
+
export declare class OrchardProverWASM {
|
|
8
|
+
/** @private **/
|
|
9
|
+
_rawOrchardProver: OrchardProverNAPI;
|
|
10
|
+
/**
|
|
11
|
+
* The proving key is deterministic and expensive (~10s), so it's built
|
|
12
|
+
* once per process and shared by every prover instance. Cleared on
|
|
13
|
+
* failure so a failed init can be retried.
|
|
14
|
+
*/
|
|
15
|
+
private static _initPromise;
|
|
16
|
+
constructor();
|
|
17
|
+
init(): Promise<void>;
|
|
18
|
+
static createFromRawInstance(rawInstance: OrchardProverNAPI): OrchardProverWASM;
|
|
19
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { dppProvider } from '../../provider.js';
|
|
2
|
+
/**
|
|
3
|
+
* Reusable Orchard prover holding the Halo 2 proving key. Building it is
|
|
4
|
+
* expensive (~seconds); construct once and reuse. (The `ShieldedBuilderWASM`
|
|
5
|
+
* already builds its own prover internally — this is exposed for standalone use.)
|
|
6
|
+
*/
|
|
7
|
+
export class OrchardProverWASM {
|
|
8
|
+
/** @private **/
|
|
9
|
+
_rawOrchardProver;
|
|
10
|
+
/**
|
|
11
|
+
* The proving key is deterministic and expensive (~10s), so it's built
|
|
12
|
+
* once per process and shared by every prover instance. Cleared on
|
|
13
|
+
* failure so a failed init can be retried.
|
|
14
|
+
*/
|
|
15
|
+
static _initPromise = null;
|
|
16
|
+
constructor() {
|
|
17
|
+
// empty
|
|
18
|
+
}
|
|
19
|
+
async init() {
|
|
20
|
+
if (OrchardProverWASM._initPromise == null) {
|
|
21
|
+
OrchardProverWASM._initPromise = dppProvider.dpp.OrchardProverNAPI.init()
|
|
22
|
+
.catch((e) => {
|
|
23
|
+
OrchardProverWASM._initPromise = null;
|
|
24
|
+
throw e;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
this._rawOrchardProver = await OrchardProverWASM._initPromise;
|
|
28
|
+
}
|
|
29
|
+
static createFromRawInstance(rawInstance) {
|
|
30
|
+
const instance = Object.create(OrchardProverWASM.prototype);
|
|
31
|
+
instance._rawOrchardProver = rawInstance;
|
|
32
|
+
return instance;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { RecoveredNoteNAPI } from '../../../../binaries/bindingsTypes.js';
|
|
2
|
+
import { NoteWASM } from './Note.js';
|
|
3
|
+
import { SerializedActionWASM } from '../ShieldedTransitions/SerializedAction.js';
|
|
4
|
+
/** A note recovered from a shielded action by trial-decryption. */
|
|
5
|
+
export declare class RecoveredNoteWASM {
|
|
6
|
+
/** @private **/
|
|
7
|
+
_rawRecoveredNote: RecoveredNoteNAPI;
|
|
8
|
+
/** The action's global leaf position in the commitment tree. */
|
|
9
|
+
get index(): number;
|
|
10
|
+
get note(): NoteWASM;
|
|
11
|
+
get nullifier(): Uint8Array;
|
|
12
|
+
static createFromRawInstance(rawInstance: RecoveredNoteNAPI): RecoveredNoteWASM;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Recovers your own notes from a set of shielded actions by trial-decrypting
|
|
16
|
+
* each with the viewing key derived from `seed` (ZIP-32 m/32'/coinType'/account').
|
|
17
|
+
* Only actions addressed to you are returned; `index` is the global leaf position.
|
|
18
|
+
*/
|
|
19
|
+
export declare function recoverNotes(actions: SerializedActionWASM[], seed: Uint8Array, coinType: number, account: number): RecoveredNoteWASM[];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { dppProvider } from '../../provider.js';
|
|
2
|
+
import { NoteWASM } from './Note.js';
|
|
3
|
+
/** A note recovered from a shielded action by trial-decryption. */
|
|
4
|
+
export class RecoveredNoteWASM {
|
|
5
|
+
/** @private **/
|
|
6
|
+
_rawRecoveredNote;
|
|
7
|
+
/** The action's global leaf position in the commitment tree. */
|
|
8
|
+
get index() {
|
|
9
|
+
return this._rawRecoveredNote.index;
|
|
10
|
+
}
|
|
11
|
+
get note() {
|
|
12
|
+
return NoteWASM.createFromRawInstance(this._rawRecoveredNote.note);
|
|
13
|
+
}
|
|
14
|
+
get nullifier() {
|
|
15
|
+
return this._rawRecoveredNote.nullifier;
|
|
16
|
+
}
|
|
17
|
+
static createFromRawInstance(rawInstance) {
|
|
18
|
+
const instance = Object.create(RecoveredNoteWASM.prototype);
|
|
19
|
+
instance._rawRecoveredNote = rawInstance;
|
|
20
|
+
return instance;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Recovers your own notes from a set of shielded actions by trial-decrypting
|
|
25
|
+
* each with the viewing key derived from `seed` (ZIP-32 m/32'/coinType'/account').
|
|
26
|
+
* Only actions addressed to you are returned; `index` is the global leaf position.
|
|
27
|
+
*/
|
|
28
|
+
export function recoverNotes(actions, seed, coinType, account) {
|
|
29
|
+
return dppProvider.dpp
|
|
30
|
+
.recoverNotes(actions.map(a => a._rawSerializedAction), seed, coinType, account)
|
|
31
|
+
.map(RecoveredNoteWASM.createFromRawInstance);
|
|
32
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { PlatformVersionNAPI, ShieldedBuilderNAPI } from '../../../../binaries/bindingsTypes.js';
|
|
2
|
+
import { PlatformAddressLike, PoolingLike } from '../../types.js';
|
|
3
|
+
import { OrchardAddressWASM } from './OrchardAddress.js';
|
|
4
|
+
import { ShieldedMemoWASM } from './ShieldedMemo.js';
|
|
5
|
+
import { SpendableNoteWASM } from './SpendableNote.js';
|
|
6
|
+
import { ShieldedWithdrawalResultWASM } from './ShieldedWithdrawalResult.js';
|
|
7
|
+
import { ShieldedOutputWASM } from './ShieldedOutput.js';
|
|
8
|
+
import { AssetLockProofWASM } from '../AssetLockProof/AssetLockProof.js';
|
|
9
|
+
import { PrivateKeyWASM } from '../PrivateKey.js';
|
|
10
|
+
import { CoreScriptWASM } from '../CoreScript.js';
|
|
11
|
+
import { StateTransitionWASM } from '../StateTransition.js';
|
|
12
|
+
import { InputAddressWASM } from '../AddressTransitions/entities/InputAddress.js';
|
|
13
|
+
import { AddressFundsFeeStrategyStepWASM } from '../AddressTransitions/entities/AddressFundsFeeStrategyStep.js';
|
|
14
|
+
import { IdentityPublicKeyInCreationWASM } from '../IdentityPublicKeyInCreation.js';
|
|
15
|
+
import { IdentityCreateFromShieldedPoolResultWASM } from './IdentityCreateFromShieldedPoolResult.js';
|
|
16
|
+
/**
|
|
17
|
+
* Builds and proves shielded (Orchard) state transitions. Construction builds
|
|
18
|
+
* the Halo 2 proving key (~seconds), so create one instance and reuse it.
|
|
19
|
+
*
|
|
20
|
+
* Deposits (`shield`, `shieldFromAssetLock`) don't need pool notes. Spends
|
|
21
|
+
* (`shieldedWithdrawal`, `unshield`, `shieldedTransfer`) need a `SpendableNote`
|
|
22
|
+
* witnessed against an on-chain anchor — rebuild the tree from the full pool
|
|
23
|
+
* note set (getShieldedEncryptedNotes) with `CommitmentTreeWASM`.
|
|
24
|
+
*/
|
|
25
|
+
export declare class ShieldedBuilderWASM {
|
|
26
|
+
/** @private **/
|
|
27
|
+
_rawShieldedBuilder: ShieldedBuilderNAPI;
|
|
28
|
+
/**
|
|
29
|
+
* Building the Halo 2 proving key takes ~10s, and the key is deterministic,
|
|
30
|
+
* so it's built once per process: every builder instance shares the same
|
|
31
|
+
* raw builder. Cleared on failure so a failed init can be retried.
|
|
32
|
+
*/
|
|
33
|
+
private static _initPromise;
|
|
34
|
+
constructor();
|
|
35
|
+
init(): Promise<void>;
|
|
36
|
+
/** Asset lock -> pool (deposit). */
|
|
37
|
+
shieldFromAssetLock(recipient: OrchardAddressWASM, shieldAmount: bigint, assetLockProof: AssetLockProofWASM, privateKey: PrivateKeyWASM, memo: ShieldedMemoWASM, dummyOutputs: number, senderOvk?: Uint8Array, surplusOutput?: PlatformAddressLike, platformVersion?: PlatformVersionNAPI): Promise<StateTransitionWASM>;
|
|
38
|
+
/** Transparent platform addresses -> pool (deposit). One private key per input. */
|
|
39
|
+
shield(recipient: OrchardAddressWASM, shieldAmount: bigint, inputs: InputAddressWASM[], privateKeys: PrivateKeyWASM[], feeStrategy: AddressFundsFeeStrategyStepWASM[], userFeeIncrease: number, memo: ShieldedMemoWASM, senderOvk?: Uint8Array, platformVersion?: PlatformVersionNAPI): Promise<StateTransitionWASM>;
|
|
40
|
+
/** Pool -> core L1 (spend). */
|
|
41
|
+
shieldedWithdrawal(spends: SpendableNoteWASM[], withdrawalAmount: bigint, outputScript: CoreScriptWASM, coreFeePerByte: number, pooling: PoolingLike, changeAddress: OrchardAddressWASM, seed: Uint8Array, coinType: number, account: number, anchor: Uint8Array, memo: ShieldedMemoWASM, platformVersion?: PlatformVersionNAPI): Promise<ShieldedWithdrawalResultWASM>;
|
|
42
|
+
/** Pool -> platform identity balance (spend). */
|
|
43
|
+
unshield(spends: SpendableNoteWASM[], outputAddress: PlatformAddressLike, unshieldAmount: bigint, changeAddress: OrchardAddressWASM, seed: Uint8Array, coinType: number, account: number, anchor: Uint8Array, memo: ShieldedMemoWASM, platformVersion?: PlatformVersionNAPI): Promise<ShieldedWithdrawalResultWASM>;
|
|
44
|
+
/** Pool -> pool (spend). */
|
|
45
|
+
shieldedTransfer(spends: SpendableNoteWASM[], recipient: OrchardAddressWASM, transferAmount: bigint, changeAddress: OrchardAddressWASM, seed: Uint8Array, coinType: number, account: number, anchor: Uint8Array, memo: ShieldedMemoWASM, platformVersion?: PlatformVersionNAPI): Promise<ShieldedWithdrawalResultWASM>;
|
|
46
|
+
/**
|
|
47
|
+
* Pool -> pool, paying several Orchard addresses in one proof.
|
|
48
|
+
*
|
|
49
|
+
* The spend side matches `shieldedTransfer` — every note must belong to the
|
|
50
|
+
* `seed`/`coinType`/`account` this call derives its spend authority from, and
|
|
51
|
+
* all must be witnessed against the same `anchor`. The output side is a list,
|
|
52
|
+
* each entry carrying its own amount and memo, and the leftover always goes
|
|
53
|
+
* to `changeAddress` (a zero-value change note is still written, which keeps
|
|
54
|
+
* the fee predictable before the change amount is known).
|
|
55
|
+
*
|
|
56
|
+
* Consensus prices the fee off the bundle's action count, which Orchard sets
|
|
57
|
+
* to `max(spends, outputs + 1, 2)` and caps at 16 — so a fan-out of 15
|
|
58
|
+
* recipients is the ceiling, and each extra action adds proving time. Passing
|
|
59
|
+
* more throws before proving rather than after.
|
|
60
|
+
*/
|
|
61
|
+
shieldedTransferMulti(spends: SpendableNoteWASM[], outputs: ShieldedOutputWASM[], changeAddress: OrchardAddressWASM, seed: Uint8Array, coinType: number, account: number, anchor: Uint8Array, platformVersion?: PlatformVersionNAPI): Promise<ShieldedWithdrawalResultWASM>;
|
|
62
|
+
/** Pool -> new identity (spend). One private key per public key, same order. */
|
|
63
|
+
identityCreateFromShieldedPool(publicKeys: IdentityPublicKeyInCreationWASM[], privateKeys: PrivateKeyWASM[], denomination: bigint, sendToAddressOnCreationFailure: PlatformAddressLike, spends: SpendableNoteWASM[], changeAddress: OrchardAddressWASM, seed: Uint8Array, coinType: number, account: number, anchor: Uint8Array, memo: ShieldedMemoWASM, platformVersion?: PlatformVersionNAPI): Promise<IdentityCreateFromShieldedPoolResultWASM>;
|
|
64
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { dppProvider } from '../../provider.js';
|
|
2
|
+
import { preparePlatformAddressValue, valueToDynamicValue } from '../../utils.js';
|
|
3
|
+
import { ShieldedWithdrawalResultWASM } from './ShieldedWithdrawalResult.js';
|
|
4
|
+
import { StateTransitionWASM } from '../StateTransition.js';
|
|
5
|
+
import { IdentityCreateFromShieldedPoolResultWASM } from './IdentityCreateFromShieldedPoolResult.js';
|
|
6
|
+
/**
|
|
7
|
+
* Builds and proves shielded (Orchard) state transitions. Construction builds
|
|
8
|
+
* the Halo 2 proving key (~seconds), so create one instance and reuse it.
|
|
9
|
+
*
|
|
10
|
+
* Deposits (`shield`, `shieldFromAssetLock`) don't need pool notes. Spends
|
|
11
|
+
* (`shieldedWithdrawal`, `unshield`, `shieldedTransfer`) need a `SpendableNote`
|
|
12
|
+
* witnessed against an on-chain anchor — rebuild the tree from the full pool
|
|
13
|
+
* note set (getShieldedEncryptedNotes) with `CommitmentTreeWASM`.
|
|
14
|
+
*/
|
|
15
|
+
export class ShieldedBuilderWASM {
|
|
16
|
+
/** @private **/
|
|
17
|
+
_rawShieldedBuilder;
|
|
18
|
+
/**
|
|
19
|
+
* Building the Halo 2 proving key takes ~10s, and the key is deterministic,
|
|
20
|
+
* so it's built once per process: every builder instance shares the same
|
|
21
|
+
* raw builder. Cleared on failure so a failed init can be retried.
|
|
22
|
+
*/
|
|
23
|
+
static _initPromise = null;
|
|
24
|
+
constructor() {
|
|
25
|
+
// empty
|
|
26
|
+
}
|
|
27
|
+
async init() {
|
|
28
|
+
if (ShieldedBuilderWASM._initPromise == null) {
|
|
29
|
+
ShieldedBuilderWASM._initPromise = dppProvider.dpp.ShieldedBuilderNAPI.init()
|
|
30
|
+
.catch((e) => {
|
|
31
|
+
ShieldedBuilderWASM._initPromise = null;
|
|
32
|
+
throw e;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
this._rawShieldedBuilder = await ShieldedBuilderWASM._initPromise;
|
|
36
|
+
}
|
|
37
|
+
/** Asset lock -> pool (deposit). */
|
|
38
|
+
async shieldFromAssetLock(recipient, shieldAmount, assetLockProof, privateKey, memo, dummyOutputs, senderOvk, surplusOutput, platformVersion) {
|
|
39
|
+
return StateTransitionWASM.createFromRawInstance(await this._rawShieldedBuilder.shieldFromAssetLock(recipient._rawOrchardAddress, shieldAmount.toString(), assetLockProof._rawAssetLockProof, privateKey._rawPrivateKey, memo._rawShieldedMemo, dummyOutputs, senderOvk, surplusOutput != null ? preparePlatformAddressValue(surplusOutput) : undefined, platformVersion));
|
|
40
|
+
}
|
|
41
|
+
/** Transparent platform addresses -> pool (deposit). One private key per input. */
|
|
42
|
+
async shield(recipient, shieldAmount, inputs, privateKeys, feeStrategy, userFeeIncrease, memo, senderOvk, platformVersion) {
|
|
43
|
+
return StateTransitionWASM.createFromRawInstance(await this._rawShieldedBuilder.shield(recipient._rawOrchardAddress, shieldAmount.toString(), inputs.map(i => i._rawInputAddress), privateKeys.map(k => k._rawPrivateKey), feeStrategy.map(s => s._rawAddressFundsFeeStrategyStep), userFeeIncrease, memo._rawShieldedMemo, senderOvk, platformVersion));
|
|
44
|
+
}
|
|
45
|
+
/** Pool -> core L1 (spend). */
|
|
46
|
+
async shieldedWithdrawal(spends, withdrawalAmount, outputScript, coreFeePerByte, pooling, changeAddress, seed, coinType, account, anchor, memo, platformVersion) {
|
|
47
|
+
return ShieldedWithdrawalResultWASM.createFromRawInstance(await this._rawShieldedBuilder.shieldedWithdrawal(spends.map(s => s._rawSpendableNote), withdrawalAmount.toString(), outputScript._rawCoreScript, coreFeePerByte, valueToDynamicValue(pooling), changeAddress._rawOrchardAddress, seed, coinType, account, anchor, memo._rawShieldedMemo, platformVersion));
|
|
48
|
+
}
|
|
49
|
+
/** Pool -> platform identity balance (spend). */
|
|
50
|
+
async unshield(spends, outputAddress, unshieldAmount, changeAddress, seed, coinType, account, anchor, memo, platformVersion) {
|
|
51
|
+
return ShieldedWithdrawalResultWASM.createFromRawInstance(await this._rawShieldedBuilder.unshield(spends.map(s => s._rawSpendableNote), preparePlatformAddressValue(outputAddress), unshieldAmount.toString(), changeAddress._rawOrchardAddress, seed, coinType, account, anchor, memo._rawShieldedMemo, platformVersion));
|
|
52
|
+
}
|
|
53
|
+
/** Pool -> pool (spend). */
|
|
54
|
+
async shieldedTransfer(spends, recipient, transferAmount, changeAddress, seed, coinType, account, anchor, memo, platformVersion) {
|
|
55
|
+
return ShieldedWithdrawalResultWASM.createFromRawInstance(await this._rawShieldedBuilder.shieldedTransfer(spends.map(s => s._rawSpendableNote), recipient._rawOrchardAddress, transferAmount.toString(), changeAddress._rawOrchardAddress, seed, coinType, account, anchor, memo._rawShieldedMemo, platformVersion));
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Pool -> pool, paying several Orchard addresses in one proof.
|
|
59
|
+
*
|
|
60
|
+
* The spend side matches `shieldedTransfer` — every note must belong to the
|
|
61
|
+
* `seed`/`coinType`/`account` this call derives its spend authority from, and
|
|
62
|
+
* all must be witnessed against the same `anchor`. The output side is a list,
|
|
63
|
+
* each entry carrying its own amount and memo, and the leftover always goes
|
|
64
|
+
* to `changeAddress` (a zero-value change note is still written, which keeps
|
|
65
|
+
* the fee predictable before the change amount is known).
|
|
66
|
+
*
|
|
67
|
+
* Consensus prices the fee off the bundle's action count, which Orchard sets
|
|
68
|
+
* to `max(spends, outputs + 1, 2)` and caps at 16 — so a fan-out of 15
|
|
69
|
+
* recipients is the ceiling, and each extra action adds proving time. Passing
|
|
70
|
+
* more throws before proving rather than after.
|
|
71
|
+
*/
|
|
72
|
+
async shieldedTransferMulti(spends, outputs, changeAddress, seed, coinType, account, anchor, platformVersion) {
|
|
73
|
+
return ShieldedWithdrawalResultWASM.createFromRawInstance(await this._rawShieldedBuilder.shieldedTransferMulti(spends.map(s => s._rawSpendableNote), outputs.map(o => o._rawShieldedOutput), changeAddress._rawOrchardAddress, seed, coinType, account, anchor, platformVersion));
|
|
74
|
+
}
|
|
75
|
+
/** Pool -> new identity (spend). One private key per public key, same order. */
|
|
76
|
+
async identityCreateFromShieldedPool(publicKeys, privateKeys, denomination, sendToAddressOnCreationFailure, spends, changeAddress, seed, coinType, account, anchor, memo, platformVersion) {
|
|
77
|
+
return IdentityCreateFromShieldedPoolResultWASM.createFromRawInstance(await this._rawShieldedBuilder.identityCreateFromShieldedPool(publicKeys.map(k => k._rawKeyInCreation), privateKeys.map(k => k._rawPrivateKey), denomination.toString(), preparePlatformAddressValue(sendToAddressOnCreationFailure), spends.map(s => s._rawSpendableNote), changeAddress._rawOrchardAddress, seed, coinType, account, anchor, memo._rawShieldedMemo, platformVersion));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ShieldedMemoNAPI } from '../../../../binaries/bindingsTypes.js';
|
|
2
|
+
export declare class ShieldedMemoWASM {
|
|
3
|
+
/** @private **/
|
|
4
|
+
_rawShieldedMemo: ShieldedMemoNAPI;
|
|
5
|
+
toString(): string;
|
|
6
|
+
toBytes(): Uint8Array;
|
|
7
|
+
static empty(): ShieldedMemoWASM;
|
|
8
|
+
static fromString(value: string): ShieldedMemoWASM;
|
|
9
|
+
static other(kind: number, payload: Uint8Array): ShieldedMemoWASM;
|
|
10
|
+
static createFromRawInstance(rawInstance: ShieldedMemoNAPI): ShieldedMemoWASM;
|
|
11
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { dppProvider } from '../../provider.js';
|
|
2
|
+
export class ShieldedMemoWASM {
|
|
3
|
+
/** @private **/
|
|
4
|
+
_rawShieldedMemo;
|
|
5
|
+
toString() {
|
|
6
|
+
return this._rawShieldedMemo.toString();
|
|
7
|
+
}
|
|
8
|
+
toBytes() {
|
|
9
|
+
return this._rawShieldedMemo.toBytes();
|
|
10
|
+
}
|
|
11
|
+
static empty() {
|
|
12
|
+
return ShieldedMemoWASM.createFromRawInstance(dppProvider.dpp.ShieldedMemoNAPI.empty());
|
|
13
|
+
}
|
|
14
|
+
static fromString(value) {
|
|
15
|
+
return ShieldedMemoWASM.createFromRawInstance(dppProvider.dpp.ShieldedMemoNAPI.fromString(value));
|
|
16
|
+
}
|
|
17
|
+
static other(kind, payload) {
|
|
18
|
+
return ShieldedMemoWASM.createFromRawInstance(dppProvider.dpp.ShieldedMemoNAPI.other(kind, payload));
|
|
19
|
+
}
|
|
20
|
+
static createFromRawInstance(rawInstance) {
|
|
21
|
+
const instance = Object.create(ShieldedMemoWASM.prototype);
|
|
22
|
+
instance._rawShieldedMemo = rawInstance;
|
|
23
|
+
return instance;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ShieldedOutputNAPI } from '../../../../binaries/bindingsTypes.js';
|
|
2
|
+
import { OrchardAddressWASM } from './OrchardAddress.js';
|
|
3
|
+
import { ShieldedMemoWASM } from './ShieldedMemo.js';
|
|
4
|
+
/**
|
|
5
|
+
* One output of a multi-output shielded transfer (`shieldedTransferMulti`):
|
|
6
|
+
* who receives the note, how much, and the memo carried inside it.
|
|
7
|
+
*
|
|
8
|
+
* Each output holds its own memo — the single-recipient builders share one memo
|
|
9
|
+
* across the bundle, which has nothing sensible to say when there are several
|
|
10
|
+
* unrelated recipients.
|
|
11
|
+
*/
|
|
12
|
+
export declare class ShieldedOutputWASM {
|
|
13
|
+
/** @private **/
|
|
14
|
+
_rawShieldedOutput: ShieldedOutputNAPI;
|
|
15
|
+
constructor(address: OrchardAddressWASM, amount: bigint, memo: ShieldedMemoWASM);
|
|
16
|
+
get address(): OrchardAddressWASM;
|
|
17
|
+
set address(value: OrchardAddressWASM);
|
|
18
|
+
get amount(): bigint;
|
|
19
|
+
set amount(value: bigint);
|
|
20
|
+
get memo(): ShieldedMemoWASM;
|
|
21
|
+
set memo(value: ShieldedMemoWASM);
|
|
22
|
+
static createFromRawInstance(rawInstance: ShieldedOutputNAPI): ShieldedOutputWASM;
|
|
23
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { dppProvider } from '../../provider.js';
|
|
2
|
+
import { OrchardAddressWASM } from './OrchardAddress.js';
|
|
3
|
+
import { ShieldedMemoWASM } from './ShieldedMemo.js';
|
|
4
|
+
/**
|
|
5
|
+
* One output of a multi-output shielded transfer (`shieldedTransferMulti`):
|
|
6
|
+
* who receives the note, how much, and the memo carried inside it.
|
|
7
|
+
*
|
|
8
|
+
* Each output holds its own memo — the single-recipient builders share one memo
|
|
9
|
+
* across the bundle, which has nothing sensible to say when there are several
|
|
10
|
+
* unrelated recipients.
|
|
11
|
+
*/
|
|
12
|
+
export class ShieldedOutputWASM {
|
|
13
|
+
/** @private **/
|
|
14
|
+
_rawShieldedOutput;
|
|
15
|
+
constructor(address, amount, memo) {
|
|
16
|
+
this._rawShieldedOutput = new dppProvider.dpp.ShieldedOutputNAPI(address._rawOrchardAddress, amount.toString(), memo._rawShieldedMemo);
|
|
17
|
+
}
|
|
18
|
+
get address() {
|
|
19
|
+
return OrchardAddressWASM.createFromRawInstance(this._rawShieldedOutput.address);
|
|
20
|
+
}
|
|
21
|
+
set address(value) {
|
|
22
|
+
this._rawShieldedOutput.address = value._rawOrchardAddress;
|
|
23
|
+
}
|
|
24
|
+
get amount() {
|
|
25
|
+
return BigInt(this._rawShieldedOutput.amount);
|
|
26
|
+
}
|
|
27
|
+
set amount(value) {
|
|
28
|
+
this._rawShieldedOutput.amount = value.toString();
|
|
29
|
+
}
|
|
30
|
+
get memo() {
|
|
31
|
+
return ShieldedMemoWASM.createFromRawInstance(this._rawShieldedOutput.memo);
|
|
32
|
+
}
|
|
33
|
+
set memo(value) {
|
|
34
|
+
this._rawShieldedOutput.memo = value._rawShieldedMemo;
|
|
35
|
+
}
|
|
36
|
+
static createFromRawInstance(rawInstance) {
|
|
37
|
+
const instance = Object.create(ShieldedOutputWASM.prototype);
|
|
38
|
+
instance._rawShieldedOutput = rawInstance;
|
|
39
|
+
return instance;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ShieldedWithdrawalResultNAPI } from '../../../../binaries/bindingsTypes.js';
|
|
2
|
+
import { StateTransitionWASM } from '../StateTransition.js';
|
|
3
|
+
/** Result of a proving shielded spend (withdrawal / unshield / transfer). */
|
|
4
|
+
export declare class ShieldedWithdrawalResultWASM {
|
|
5
|
+
/** @private **/
|
|
6
|
+
_rawShieldedWithdrawalResult: ShieldedWithdrawalResultNAPI;
|
|
7
|
+
get stateTransition(): StateTransitionWASM;
|
|
8
|
+
/** The fixed shielded fee (credits) consensus charges for the spend. */
|
|
9
|
+
get fee(): bigint;
|
|
10
|
+
static createFromRawInstance(rawInstance: ShieldedWithdrawalResultNAPI): ShieldedWithdrawalResultWASM;
|
|
11
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { StateTransitionWASM } from '../StateTransition.js';
|
|
2
|
+
/** Result of a proving shielded spend (withdrawal / unshield / transfer). */
|
|
3
|
+
export class ShieldedWithdrawalResultWASM {
|
|
4
|
+
/** @private **/
|
|
5
|
+
_rawShieldedWithdrawalResult;
|
|
6
|
+
get stateTransition() {
|
|
7
|
+
return StateTransitionWASM.createFromRawInstance(this._rawShieldedWithdrawalResult.stateTransition);
|
|
8
|
+
}
|
|
9
|
+
/** The fixed shielded fee (credits) consensus charges for the spend. */
|
|
10
|
+
get fee() {
|
|
11
|
+
return BigInt(this._rawShieldedWithdrawalResult.fee);
|
|
12
|
+
}
|
|
13
|
+
static createFromRawInstance(rawInstance) {
|
|
14
|
+
const instance = Object.create(ShieldedWithdrawalResultWASM.prototype);
|
|
15
|
+
instance._rawShieldedWithdrawalResult = rawInstance;
|
|
16
|
+
return instance;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SpendableNoteNAPI } from '../../../../binaries/bindingsTypes.js';
|
|
2
|
+
import { NoteWASM } from './Note.js';
|
|
3
|
+
import { MerklePathWASM } from './MerklePath.js';
|
|
4
|
+
export declare class SpendableNoteWASM {
|
|
5
|
+
/** @private **/
|
|
6
|
+
_rawSpendableNote: SpendableNoteNAPI;
|
|
7
|
+
constructor(note: NoteWASM, merklePath: MerklePathWASM);
|
|
8
|
+
get note(): NoteWASM;
|
|
9
|
+
set note(value: NoteWASM);
|
|
10
|
+
get merklePath(): MerklePathWASM;
|
|
11
|
+
set merklePath(value: MerklePathWASM);
|
|
12
|
+
static createFromRawInstance(rawInstance: SpendableNoteNAPI): SpendableNoteWASM;
|
|
13
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { dppProvider } from '../../provider.js';
|
|
2
|
+
import { NoteWASM } from './Note.js';
|
|
3
|
+
import { MerklePathWASM } from './MerklePath.js';
|
|
4
|
+
export class SpendableNoteWASM {
|
|
5
|
+
/** @private **/
|
|
6
|
+
_rawSpendableNote;
|
|
7
|
+
constructor(note, merklePath) {
|
|
8
|
+
this._rawSpendableNote = new dppProvider.dpp.SpendableNoteNAPI(note._rawNote, merklePath._rawMerklePath);
|
|
9
|
+
}
|
|
10
|
+
get note() {
|
|
11
|
+
return NoteWASM.createFromRawInstance(this._rawSpendableNote.note);
|
|
12
|
+
}
|
|
13
|
+
set note(value) {
|
|
14
|
+
this._rawSpendableNote.note = value._rawNote;
|
|
15
|
+
}
|
|
16
|
+
get merklePath() {
|
|
17
|
+
return MerklePathWASM.createFromRawInstance(this._rawSpendableNote.merklePath);
|
|
18
|
+
}
|
|
19
|
+
set merklePath(value) {
|
|
20
|
+
this._rawSpendableNote.merklePath = value._rawMerklePath;
|
|
21
|
+
}
|
|
22
|
+
static createFromRawInstance(rawInstance) {
|
|
23
|
+
const instance = Object.create(SpendableNoteWASM.prototype);
|
|
24
|
+
instance._rawSpendableNote = rawInstance;
|
|
25
|
+
return instance;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PlatformAddressNAPI } from '../../../../binaries/bindingsTypes.js';
|
|
1
|
+
import type { PlatformAddressNAPI, PlatformVersionNAPI } from '../../../../binaries/bindingsTypes.js';
|
|
2
2
|
import { NetworkLike, PlatformAddressLike } from '../../types.js';
|
|
3
3
|
export declare class PlatformAddressWASM {
|
|
4
4
|
/** @private **/
|
|
@@ -10,6 +10,14 @@ export declare class PlatformAddressWASM {
|
|
|
10
10
|
isP2PKH(): boolean;
|
|
11
11
|
isP2SH(): boolean;
|
|
12
12
|
hash(): Uint8Array;
|
|
13
|
+
/**
|
|
14
|
+
* Storage fee charged for creating balance entries for addresses that are not in state yet.
|
|
15
|
+
*
|
|
16
|
+
* A minimum fee prices every output as a fresh address, but the fee actually charged is
|
|
17
|
+
* metered: paying an address that already exists adds no bytes, while each address created
|
|
18
|
+
* costs this much storage on top of processing.
|
|
19
|
+
*/
|
|
20
|
+
static estimateStorageFeeForNewAddresses(addressCount: number, platformVersion?: PlatformVersionNAPI): bigint;
|
|
13
21
|
static fromBech32m(bech32m: string): PlatformAddressWASM;
|
|
14
22
|
static fromBytes(bytes: Uint8Array): PlatformAddressWASM;
|
|
15
23
|
static createFromRawInstance(rawInstance: PlatformAddressNAPI): PlatformAddressWASM;
|
|
@@ -24,6 +24,16 @@ export class PlatformAddressWASM {
|
|
|
24
24
|
hash() {
|
|
25
25
|
return this._rawPlatformAddress.hash();
|
|
26
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Storage fee charged for creating balance entries for addresses that are not in state yet.
|
|
29
|
+
*
|
|
30
|
+
* A minimum fee prices every output as a fresh address, but the fee actually charged is
|
|
31
|
+
* metered: paying an address that already exists adds no bytes, while each address created
|
|
32
|
+
* costs this much storage on top of processing.
|
|
33
|
+
*/
|
|
34
|
+
static estimateStorageFeeForNewAddresses(addressCount, platformVersion) {
|
|
35
|
+
return BigInt(dppProvider.dpp.PlatformAddressNAPI.estimateStorageFeeForNewAddresses(addressCount, platformVersion));
|
|
36
|
+
}
|
|
27
37
|
static fromBech32m(bech32m) {
|
|
28
38
|
return PlatformAddressWASM.createFromRawInstance(dppProvider.dpp.PlatformAddressNAPI.fromBech32m(bech32m));
|
|
29
39
|
}
|
package/dist/src/dpp/structs/ShieldedTransitions/IdentityCreateFromShieldedPoolTransition.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { PlatformVersionNAPI, IdentityCreateFromShieldedPoolTransitionNAPI } from '../../../../binaries/bindingsTypes.js';
|
|
2
|
+
import { IdentityPublicKeyInCreationWASM } from '../IdentityPublicKeyInCreation.js';
|
|
3
|
+
import { SerializedActionWASM } from './SerializedAction.js';
|
|
4
|
+
import { PlatformAddressWASM } from '../PlatformAddress/PlatformAddress.js';
|
|
5
|
+
import { IdentifierWASM } from '../Identifier.js';
|
|
6
|
+
import { IdentifierLike, PlatformAddressLike } from '../../types.js';
|
|
7
|
+
import { StateTransitionWASM } from '../StateTransition.js';
|
|
8
|
+
export declare class IdentityCreateFromShieldedPoolTransitionWASM {
|
|
9
|
+
/** @private **/
|
|
10
|
+
_rawIdentityCreateFromShieldedPoolTransition: IdentityCreateFromShieldedPoolTransitionNAPI;
|
|
11
|
+
constructor(publicKeys: IdentityPublicKeyInCreationWASM[], denomination: bigint, actions: SerializedActionWASM[], anchor: Uint8Array, proof: Uint8Array, bindingsSignature: Uint8Array, sendToAddressOnCreationFailure: PlatformAddressLike, identityId: IdentifierLike);
|
|
12
|
+
get publicKeys(): IdentityPublicKeyInCreationWASM[];
|
|
13
|
+
set publicKeys(value: IdentityPublicKeyInCreationWASM[]);
|
|
14
|
+
get denomination(): bigint;
|
|
15
|
+
set denomination(value: bigint);
|
|
16
|
+
get actions(): SerializedActionWASM[];
|
|
17
|
+
set actions(value: SerializedActionWASM[]);
|
|
18
|
+
get anchor(): Uint8Array;
|
|
19
|
+
set anchor(value: Uint8Array);
|
|
20
|
+
get proof(): Uint8Array;
|
|
21
|
+
set proof(value: Uint8Array);
|
|
22
|
+
get bindingsSignature(): Uint8Array;
|
|
23
|
+
set bindingsSignature(value: Uint8Array);
|
|
24
|
+
get sendToAddressOnCreationFailure(): PlatformAddressWASM;
|
|
25
|
+
set sendToAddressOnCreationFailure(value: PlatformAddressLike);
|
|
26
|
+
get identityId(): IdentifierWASM;
|
|
27
|
+
set identityId(value: IdentifierLike);
|
|
28
|
+
static computeMinimumFee(numActions: number, numKeys: number, platformVersion?: PlatformVersionNAPI): bigint;
|
|
29
|
+
toStateTransition(): StateTransitionWASM;
|
|
30
|
+
static fromStateTransition(st: StateTransitionWASM): IdentityCreateFromShieldedPoolTransitionWASM;
|
|
31
|
+
static createFromRawInstance(rawInstance: IdentityCreateFromShieldedPoolTransitionNAPI): IdentityCreateFromShieldedPoolTransitionWASM;
|
|
32
|
+
}
|