dash-platform-sdk 1.4.0 → 1.5.0-dev.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -15
- package/bundle.min.js +1 -21
- package/package.json +4 -3
- package/proto/generated/platform.client.d.ts +110 -0
- package/proto/generated/platform.client.js +89 -12
- package/proto/generated/platform.d.ts +1671 -0
- package/proto/generated/platform.js +3381 -1
- package/src/DashPlatformSDK.d.ts +2 -0
- package/src/DashPlatformSDK.js +3 -0
- package/src/constants.d.ts +2 -1
- package/src/constants.js +2 -1
- package/src/identities/createStateTransition.js +2 -2
- package/src/keyPair/index.d.ts +87 -0
- package/src/keyPair/index.js +128 -0
- package/src/node/{epochs.d.ts → epochInfos.d.ts} +1 -1
- package/src/node/{epochs.js → epochInfos.js} +1 -1
- package/src/node/finalizedEpochInfos.d.ts +21 -0
- package/src/node/finalizedEpochInfos.js +54 -0
- package/src/node/index.d.ts +9 -1
- package/src/node/index.js +11 -1
- package/src/platformAddresses/createStateTransition.d.ts +12 -0
- package/src/platformAddresses/createStateTransition.js +62 -0
- package/src/platformAddresses/getAddressesBranchState.d.ts +3 -0
- package/src/platformAddresses/getAddressesBranchState.js +21 -0
- package/src/platformAddresses/getAddressesTrunkState.d.ts +3 -0
- package/src/platformAddresses/getAddressesTrunkState.js +33 -0
- package/src/platformAddresses/getRecentAddressBalanceChanges.d.ts +3 -0
- package/src/platformAddresses/getRecentAddressBalanceChanges.js +38 -0
- package/src/platformAddresses/getRecentCompactedAddressBalanceChanges.d.ts +3 -0
- package/src/platformAddresses/getRecentCompactedAddressBalanceChanges.js +37 -0
- package/src/platformAddresses/index.d.ts +63 -2
- package/src/platformAddresses/index.js +76 -0
- package/src/shielded/createStateTransition.d.ts +3 -0
- package/src/shielded/createStateTransition.js +60 -0
- package/src/shielded/getMostRecentShieldedAnchor.d.ts +2 -0
- package/src/shielded/getMostRecentShieldedAnchor.js +36 -0
- package/src/shielded/getShieldedAnchors.d.ts +2 -0
- package/src/shielded/getShieldedAnchors.js +36 -0
- package/src/shielded/getShieldedEncryptedNotes.d.ts +3 -0
- package/src/shielded/getShieldedEncryptedNotes.js +43 -0
- package/src/shielded/getShieldedNotesCount.d.ts +2 -0
- package/src/shielded/getShieldedNotesCount.js +36 -0
- package/src/shielded/getShieldedNullifiers.d.ts +3 -0
- package/src/shielded/getShieldedNullifiers.js +40 -0
- package/src/shielded/getShieldedPoolState.d.ts +2 -0
- package/src/shielded/getShieldedPoolState.js +36 -0
- package/src/shielded/index.d.ts +131 -0
- package/src/shielded/index.js +188 -0
- package/src/utils/verifyTenderdashProof.js +3 -0
- package/test/unit/Identity.spec.js +1 -1
- package/test/unit/KeyPair.spec.js +80 -0
- package/test/unit/Node.spec.js +6 -0
- package/test/unit/PlatformAddress.spec.js +155 -1
- package/test/unit/Shielded.spec.d.ts +1 -0
- package/test/unit/Shielded.spec.js +237 -0
- package/types.d.ts +153 -2
- package/types.js +1 -1
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { AddressFundsFeeStrategyStepWASM, AssetLockProofWASM, CommitmentTreeWASM, CoreScriptWASM, InputAddressWASM, KeyType, NoteWASM, OrchardAddressWASM, OutPointWASM, PlatformAddressWASM, PrivateKeyWASM, Purpose, SecurityLevel, SpendableNoteWASM, StateTransitionWASM } from 'pshenmic-dpp';
|
|
2
|
+
import { DashPlatformSDK } from '../../src/DashPlatformSDK.js';
|
|
3
|
+
let sdk;
|
|
4
|
+
const COIN_TYPE = 1;
|
|
5
|
+
const ACCOUNT = 0;
|
|
6
|
+
function randomBytes(length) {
|
|
7
|
+
const bytes = new Uint8Array(length);
|
|
8
|
+
for (let i = 0; i < length; i++) {
|
|
9
|
+
bytes[i] = Math.floor(Math.random() * 256);
|
|
10
|
+
}
|
|
11
|
+
return bytes;
|
|
12
|
+
}
|
|
13
|
+
// Builds a 21-byte (version + pubkey hash) platform address.
|
|
14
|
+
function platformAddress(keyHash = randomBytes(20)) {
|
|
15
|
+
const bytes = new Uint8Array(21);
|
|
16
|
+
bytes[0] = 0x00;
|
|
17
|
+
bytes.set(keyHash, 1);
|
|
18
|
+
return PlatformAddressWASM.fromBytes(bytes);
|
|
19
|
+
}
|
|
20
|
+
// Builds a spendable note owned by `seed` and a matching anchor by inserting its
|
|
21
|
+
// commitment into a fresh commitment tree and witnessing it.
|
|
22
|
+
function makeSpendableNote(seed, value) {
|
|
23
|
+
const owner = OrchardAddressWASM.fromSeed(seed, COIN_TYPE, ACCOUNT);
|
|
24
|
+
const rho = randomBytes(32);
|
|
25
|
+
rho[31] &= 0x1f; // keep rho a valid Pallas base field element
|
|
26
|
+
const note = new NoteWASM(owner, value, rho, randomBytes(32));
|
|
27
|
+
const tree = new CommitmentTreeWASM();
|
|
28
|
+
tree.append(note.cmx, true);
|
|
29
|
+
tree.checkpoint(0);
|
|
30
|
+
const anchor = tree.anchor();
|
|
31
|
+
const merklePath = tree.witness(0, 0) ?? tree.witness(0, 1);
|
|
32
|
+
if (merklePath == null) {
|
|
33
|
+
throw new Error('failed to witness note');
|
|
34
|
+
}
|
|
35
|
+
return { spend: new SpendableNoteWASM(note, merklePath), anchor, owner };
|
|
36
|
+
}
|
|
37
|
+
describe('Shielded', () => {
|
|
38
|
+
beforeAll(async () => {
|
|
39
|
+
sdk = new DashPlatformSDK({ network: 'testnet' });
|
|
40
|
+
await sdk.shielded.init();
|
|
41
|
+
}, 60000);
|
|
42
|
+
test('getShieldedNotesCount', async () => {
|
|
43
|
+
const count = await sdk.shielded.getShieldedNotesCount();
|
|
44
|
+
expect(typeof count).toBe('bigint');
|
|
45
|
+
});
|
|
46
|
+
test('getShieldedPoolState', async () => {
|
|
47
|
+
const totalBalance = await sdk.shielded.getShieldedPoolState();
|
|
48
|
+
expect(typeof totalBalance).toBe('bigint');
|
|
49
|
+
});
|
|
50
|
+
test('getShieldedAnchors', async () => {
|
|
51
|
+
const anchors = await sdk.shielded.getShieldedAnchors();
|
|
52
|
+
expect(Array.isArray(anchors)).toBe(true);
|
|
53
|
+
for (const anchor of anchors) {
|
|
54
|
+
expect(anchor).toBeInstanceOf(Uint8Array);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
test('getMostRecentShieldedAnchor', async () => {
|
|
58
|
+
const anchor = await sdk.shielded.getMostRecentShieldedAnchor();
|
|
59
|
+
expect(anchor).toBeInstanceOf(Uint8Array);
|
|
60
|
+
});
|
|
61
|
+
test('getShieldedEncryptedNotes', async () => {
|
|
62
|
+
const count = await sdk.shielded.getShieldedNotesCount() ?? 0n;
|
|
63
|
+
const requested = Number(count > 10n ? 10n : count);
|
|
64
|
+
const notes = await sdk.shielded.getShieldedEncryptedNotes(0n, requested);
|
|
65
|
+
expect(notes).toHaveLength(requested);
|
|
66
|
+
for (const note of notes) {
|
|
67
|
+
expect(note.nullifier).toBeInstanceOf(Uint8Array);
|
|
68
|
+
expect(note.cmx).toBeInstanceOf(Uint8Array);
|
|
69
|
+
expect(note.encryptedNote).toBeInstanceOf(Uint8Array);
|
|
70
|
+
expect(note.cvNet).toBeInstanceOf(Uint8Array);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
test('getShieldedNullifiers', async () => {
|
|
74
|
+
const notes = await sdk.shielded.getShieldedEncryptedNotes(0n, 1);
|
|
75
|
+
const nullifiers = notes.map(note => note.nullifier);
|
|
76
|
+
const statuses = await sdk.shielded.getShieldedNullifiers(nullifiers);
|
|
77
|
+
expect(statuses).toHaveLength(nullifiers.length);
|
|
78
|
+
for (const status of statuses) {
|
|
79
|
+
expect(status.nullifier).toBeInstanceOf(Uint8Array);
|
|
80
|
+
expect(typeof status.isSpent).toBe('boolean');
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
test('recoverNotes', () => {
|
|
84
|
+
const seed = randomBytes(32);
|
|
85
|
+
const notes = [
|
|
86
|
+
{ nullifier: randomBytes(32), cmx: randomBytes(32), encryptedNote: randomBytes(580), cvNet: randomBytes(32) }
|
|
87
|
+
];
|
|
88
|
+
const recovered = sdk.shielded.recoverNotes(notes, seed, ACCOUNT);
|
|
89
|
+
// random notes are not addressed to this seed, so none are recovered
|
|
90
|
+
expect(Array.isArray(recovered)).toBe(true);
|
|
91
|
+
expect(recovered).toHaveLength(0);
|
|
92
|
+
});
|
|
93
|
+
test('buildSpendableNotes produces a spend usable by a transition', async () => {
|
|
94
|
+
const seed = randomBytes(32);
|
|
95
|
+
const owner = OrchardAddressWASM.fromSeed(seed, COIN_TYPE, ACCOUNT);
|
|
96
|
+
const rho = randomBytes(32);
|
|
97
|
+
rho[31] &= 0x1f;
|
|
98
|
+
const note = new NoteWASM(owner, BigInt(10000000000), rho, randomBytes(32));
|
|
99
|
+
// the on-chain note set: only `cmx` matters for rebuilding the tree
|
|
100
|
+
const notes = [
|
|
101
|
+
{ nullifier: randomBytes(32), cmx: note.cmx, encryptedNote: randomBytes(580), cvNet: randomBytes(32) }
|
|
102
|
+
];
|
|
103
|
+
// buildSpendableNotes only reads `.note` and `.index` off a recovered note
|
|
104
|
+
const recovered = [{ note, index: 0 }];
|
|
105
|
+
const { spends, anchor } = sdk.shielded.buildSpendableNotes(notes, recovered);
|
|
106
|
+
expect(spends).toHaveLength(1);
|
|
107
|
+
expect(spends[0]).toEqual(expect.any(SpendableNoteWASM));
|
|
108
|
+
expect(anchor).toBeInstanceOf(Uint8Array);
|
|
109
|
+
// the produced spend + anchor must actually prove a spend transition
|
|
110
|
+
const stateTransition = await sdk.shielded.createStateTransition('shieldedTransfer', {
|
|
111
|
+
spends,
|
|
112
|
+
recipient: OrchardAddressWASM.fromSeed(randomBytes(32), COIN_TYPE, ACCOUNT),
|
|
113
|
+
transferAmount: BigInt(1000000),
|
|
114
|
+
changeAddress: owner,
|
|
115
|
+
seed,
|
|
116
|
+
coinType: COIN_TYPE,
|
|
117
|
+
account: ACCOUNT,
|
|
118
|
+
anchor
|
|
119
|
+
});
|
|
120
|
+
expect(stateTransition).toEqual(expect.any(StateTransitionWASM));
|
|
121
|
+
}, 60000);
|
|
122
|
+
describe('should be able to create state transition', () => {
|
|
123
|
+
test('should be able to create a shield transition', async () => {
|
|
124
|
+
const seed = randomBytes(32);
|
|
125
|
+
const recipient = OrchardAddressWASM.fromSeed(seed, COIN_TYPE, ACCOUNT);
|
|
126
|
+
const privateKey = new PrivateKeyWASM(randomBytes(32), 'testnet');
|
|
127
|
+
const address = platformAddress(privateKey.getPublicKey().hash160());
|
|
128
|
+
const stateTransition = await sdk.shielded.createStateTransition('shield', {
|
|
129
|
+
recipient,
|
|
130
|
+
shieldAmount: BigInt(50000000),
|
|
131
|
+
inputs: [new InputAddressWASM(address, 0, BigInt(100000000))],
|
|
132
|
+
privateKeys: [privateKey],
|
|
133
|
+
feeStrategy: [AddressFundsFeeStrategyStepWASM.DeductFromInput(0)],
|
|
134
|
+
userFeeIncrease: 0
|
|
135
|
+
// memo omitted -> defaults to an empty memo
|
|
136
|
+
});
|
|
137
|
+
expect(stateTransition).toEqual(expect.any(StateTransitionWASM));
|
|
138
|
+
}, 60000);
|
|
139
|
+
test('should be able to create a shieldFromAssetLock transition', async () => {
|
|
140
|
+
const seed = randomBytes(32);
|
|
141
|
+
const recipient = OrchardAddressWASM.fromSeed(seed, COIN_TYPE, ACCOUNT);
|
|
142
|
+
const privateKey = PrivateKeyWASM.fromHex('edd04a71bddb31e530f6c2314fd42ada333f6656bb853ece13f0577a8fd30612', 'testnet');
|
|
143
|
+
const txid = '61aede830477254876d435a317241ad46753c4b1350dc991a45ebcf19ab80a11';
|
|
144
|
+
const assetLockProof = AssetLockProofWASM.createChainAssetLockProof(1337, new OutPointWASM(txid, 0));
|
|
145
|
+
const stateTransition = await sdk.shielded.createStateTransition('shieldFromAssetLock', {
|
|
146
|
+
recipient,
|
|
147
|
+
shieldAmount: BigInt(50000000),
|
|
148
|
+
assetLockProof,
|
|
149
|
+
privateKey,
|
|
150
|
+
memo: 'shielded-memo-padded-to-32-bytes',
|
|
151
|
+
dummyOutputs: 0
|
|
152
|
+
});
|
|
153
|
+
expect(stateTransition).toEqual(expect.any(StateTransitionWASM));
|
|
154
|
+
}, 60000);
|
|
155
|
+
test('should be able to create a shieldedTransfer transition', async () => {
|
|
156
|
+
const seed = randomBytes(32);
|
|
157
|
+
const { spend, anchor, owner } = makeSpendableNote(seed, BigInt(10000000000));
|
|
158
|
+
const recipient = OrchardAddressWASM.fromSeed(randomBytes(32), COIN_TYPE, ACCOUNT);
|
|
159
|
+
const stateTransition = await sdk.shielded.createStateTransition('shieldedTransfer', {
|
|
160
|
+
spends: [spend],
|
|
161
|
+
recipient,
|
|
162
|
+
transferAmount: BigInt(1000000),
|
|
163
|
+
changeAddress: owner,
|
|
164
|
+
seed,
|
|
165
|
+
coinType: COIN_TYPE,
|
|
166
|
+
account: ACCOUNT,
|
|
167
|
+
anchor,
|
|
168
|
+
memo: 'shielded-memo-padded-to-32-bytes'
|
|
169
|
+
});
|
|
170
|
+
expect(stateTransition).toEqual(expect.any(StateTransitionWASM));
|
|
171
|
+
}, 60000);
|
|
172
|
+
test('should be able to create an unshield transition', async () => {
|
|
173
|
+
const seed = randomBytes(32);
|
|
174
|
+
const { spend, anchor, owner } = makeSpendableNote(seed, BigInt(10000000000));
|
|
175
|
+
const stateTransition = await sdk.shielded.createStateTransition('unshield', {
|
|
176
|
+
spends: [spend],
|
|
177
|
+
outputAddress: platformAddress(),
|
|
178
|
+
unshieldAmount: BigInt(1000000),
|
|
179
|
+
changeAddress: owner,
|
|
180
|
+
seed,
|
|
181
|
+
coinType: COIN_TYPE,
|
|
182
|
+
account: ACCOUNT,
|
|
183
|
+
anchor,
|
|
184
|
+
memo: 'shielded-memo-padded-to-32-bytes'
|
|
185
|
+
});
|
|
186
|
+
expect(stateTransition).toEqual(expect.any(StateTransitionWASM));
|
|
187
|
+
}, 60000);
|
|
188
|
+
test('should be able to create a shieldedWithdrawal transition', async () => {
|
|
189
|
+
const seed = randomBytes(32);
|
|
190
|
+
const { spend, anchor, owner } = makeSpendableNote(seed, BigInt(10000000000));
|
|
191
|
+
const stateTransition = await sdk.shielded.createStateTransition('shieldedWithdrawal', {
|
|
192
|
+
spends: [spend],
|
|
193
|
+
withdrawalAmount: BigInt(1000000),
|
|
194
|
+
outputScript: CoreScriptWASM.newP2PKH(randomBytes(20)),
|
|
195
|
+
coreFeePerByte: 1,
|
|
196
|
+
pooling: 'Standard',
|
|
197
|
+
changeAddress: owner,
|
|
198
|
+
seed,
|
|
199
|
+
coinType: COIN_TYPE,
|
|
200
|
+
account: ACCOUNT,
|
|
201
|
+
anchor,
|
|
202
|
+
memo: 'shielded-memo-padded-to-32-bytes'
|
|
203
|
+
});
|
|
204
|
+
expect(stateTransition).toEqual(expect.any(StateTransitionWASM));
|
|
205
|
+
}, 60000);
|
|
206
|
+
// The proving step succeeds, but `IdentityCreateFromShieldedPoolResultWASM.identityId`
|
|
207
|
+
// (read while assembling the transition) rejects the derived id for synthetic notes.
|
|
208
|
+
// A real run needs a funded note and signed keys, so this is covered against a live pool.
|
|
209
|
+
test('should be able to create an identityCreateFromShieldedPool transition', async () => {
|
|
210
|
+
const seed = randomBytes(32);
|
|
211
|
+
const { spend, anchor, owner } = makeSpendableNote(seed, BigInt(20000000000));
|
|
212
|
+
const privateKey = PrivateKeyWASM.fromHex('a1286dd195e2b8e1f6bdc946c56a53e0c544750d6452ddc0f4c593ef311f21af', 'testnet');
|
|
213
|
+
const identityPublicKeyInCreation = {
|
|
214
|
+
id: 0,
|
|
215
|
+
purpose: Purpose.AUTHENTICATION,
|
|
216
|
+
securityLevel: SecurityLevel.MASTER,
|
|
217
|
+
keyType: KeyType.ECDSA_SECP256K1,
|
|
218
|
+
readOnly: false,
|
|
219
|
+
data: privateKey.getPublicKey().bytes()
|
|
220
|
+
};
|
|
221
|
+
const stateTransition = await sdk.shielded.createStateTransition('identityCreateFromShieldedPool', {
|
|
222
|
+
publicKeys: [identityPublicKeyInCreation],
|
|
223
|
+
privateKeys: [privateKey],
|
|
224
|
+
denomination: BigInt(10000000000),
|
|
225
|
+
sendToAddressOnCreationFailure: platformAddress(),
|
|
226
|
+
spends: [spend],
|
|
227
|
+
changeAddress: owner,
|
|
228
|
+
seed,
|
|
229
|
+
coinType: COIN_TYPE,
|
|
230
|
+
account: ACCOUNT,
|
|
231
|
+
anchor,
|
|
232
|
+
memo: 'shielded-memo-padded-to-32-bytes'
|
|
233
|
+
});
|
|
234
|
+
expect(stateTransition).toEqual(expect.any(StateTransitionWASM));
|
|
235
|
+
}, 60000);
|
|
236
|
+
});
|
|
237
|
+
});
|
package/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { CoreScriptWASM, DocumentWASM, GasFeesPaidByWASM, IdentifierLike, IdentifierWASM, KeyType, PlatformAddressWASM, Purpose, SecurityLevel, TokenEmergencyActionWASM, TokenPricingScheduleWASM } from 'pshenmic-dpp';
|
|
2
|
-
|
|
1
|
+
import { AddressFundsFeeStrategyStepWASM, AssetLockProofWASM, CoreScriptWASM, DocumentWASM, GasFeesPaidByWASM, IdentifierLike, IdentifierWASM, InputAddressWASM, KeyType, OrchardAddressWASM, PlatformAddressLike, PlatformAddressWASM, PlatformVersionWASM, PoolingLike, PrivateKeyWASM, Purpose, SecurityLevel, ShieldedOutputWASM, SpendableNoteWASM, TokenEmergencyActionWASM, TokenPricingScheduleWASM, AddressWitnessWASM, IdentityPublicKeyInCreationWASM, OutputAddressWASM, OutputAddressNullableCreditsWASM, VerifiedAddressesTrunkState } from 'pshenmic-dpp';
|
|
2
|
+
import { ResponseMetadata } from './proto/generated/platform.js';
|
|
3
|
+
export { CoreScriptWASM, DocumentWASM, GasFeesPaidByWASM, IdentifierWASM, KeyType, Purpose, SecurityLevel, TokenEmergencyActionWASM, TokenPricingScheduleWASM, StateTransitionWASM, BatchTransitionWASM, IdentityPublicKeyWASM, PrivateKeyWASM, DataContractUpdateTransitionWASM, IdentityWASM, IdentityUpdateTransitionWASM, IdentityCreditTransferWASM, MasternodeVoteTransitionWASM, IdentifierLike, PlatformAddressLike, InputAddressWASM, OutputAddressWASM, OutputAddressNullableCreditsWASM, AddressFundsFeeStrategyStepWASM, AddressWitnessWASM, IdentityPublicKeyInCreationWASM, AssetLockProofWASM, IdentityCreditTransferToAddressesTransitionWASM, IdentityCreateFromAddressesTransitionWASM, IdentityTopUpFromAddressesTransitionWASM, AddressFundsTransferTransitionWASM, AddressFundingFromAssetLockTransitionWASM, AddressCreditWithdrawalTransitionWASM } from 'pshenmic-dpp';
|
|
3
4
|
export type Network = 'mainnet' | 'testnet';
|
|
4
5
|
export { DashPlatformSDK } from './src/DashPlatformSDK.js';
|
|
5
6
|
export type MasternodeList = Record<string, MasternodeInfo>;
|
|
@@ -20,6 +21,85 @@ export interface DocumentTransitionParams {
|
|
|
20
21
|
gasFeesPaidBy: GasFeesPaidByWASM;
|
|
21
22
|
};
|
|
22
23
|
}
|
|
24
|
+
export interface ShieldedTransitionBaseParams {
|
|
25
|
+
/** version of the platform (defaults to the latest supported version) */
|
|
26
|
+
platformVersion?: PlatformVersionWASM;
|
|
27
|
+
}
|
|
28
|
+
/** Spend inputs shared by `shieldedWithdrawal`, `unshield`, `shieldedTransfer` and `identityCreateFromShieldedPool`. */
|
|
29
|
+
export interface ShieldedSpendParams extends ShieldedTransitionBaseParams {
|
|
30
|
+
spends: SpendableNoteWASM[];
|
|
31
|
+
changeAddress: OrchardAddressWASM;
|
|
32
|
+
seed: Uint8Array;
|
|
33
|
+
coinType: number;
|
|
34
|
+
account: number;
|
|
35
|
+
anchor: Uint8Array;
|
|
36
|
+
/** optional UTF-8 memo string (defaults to an empty memo) */
|
|
37
|
+
memo?: string;
|
|
38
|
+
}
|
|
39
|
+
/** Transparent platform addresses -> pool (deposit). */
|
|
40
|
+
export interface ShieldParams extends ShieldedTransitionBaseParams {
|
|
41
|
+
recipient: OrchardAddressWASM;
|
|
42
|
+
shieldAmount: bigint;
|
|
43
|
+
inputs: InputAddressWASM[];
|
|
44
|
+
privateKeys: PrivateKeyWASM[];
|
|
45
|
+
feeStrategy: AddressFundsFeeStrategyStepWASM[];
|
|
46
|
+
userFeeIncrease: number;
|
|
47
|
+
/** optional UTF-8 memo string (defaults to an empty memo) */
|
|
48
|
+
memo?: string;
|
|
49
|
+
senderOvk?: Uint8Array;
|
|
50
|
+
}
|
|
51
|
+
/** Asset lock -> pool (deposit). */
|
|
52
|
+
export interface ShieldFromAssetLockParams extends ShieldedTransitionBaseParams {
|
|
53
|
+
recipient: OrchardAddressWASM;
|
|
54
|
+
shieldAmount: bigint;
|
|
55
|
+
assetLockProof: AssetLockProofWASM;
|
|
56
|
+
privateKey: PrivateKeyWASM;
|
|
57
|
+
/** optional UTF-8 memo string (defaults to an empty memo) */
|
|
58
|
+
memo?: string;
|
|
59
|
+
dummyOutputs: number;
|
|
60
|
+
senderOvk?: Uint8Array;
|
|
61
|
+
surplusOutput?: PlatformAddressLike;
|
|
62
|
+
}
|
|
63
|
+
/** Pool -> core L1 (spend). */
|
|
64
|
+
export interface ShieldedWithdrawalParams extends ShieldedSpendParams {
|
|
65
|
+
withdrawalAmount: bigint;
|
|
66
|
+
outputScript: CoreScriptWASM;
|
|
67
|
+
coreFeePerByte: number;
|
|
68
|
+
pooling: PoolingLike;
|
|
69
|
+
}
|
|
70
|
+
/** Pool -> platform identity balance (spend). */
|
|
71
|
+
export interface UnshieldParams extends ShieldedSpendParams {
|
|
72
|
+
outputAddress: PlatformAddressLike;
|
|
73
|
+
unshieldAmount: bigint;
|
|
74
|
+
}
|
|
75
|
+
/** Pool -> pool (spend). */
|
|
76
|
+
export interface ShieldedTransferParams extends ShieldedSpendParams {
|
|
77
|
+
recipient: OrchardAddressWASM;
|
|
78
|
+
transferAmount: bigint;
|
|
79
|
+
}
|
|
80
|
+
/** Pool -> pool, several recipients (spend). Each output carries its own memo. */
|
|
81
|
+
export interface ShieldedTransferMultiParams extends Omit<ShieldedSpendParams, 'memo'> {
|
|
82
|
+
outputs: ShieldedOutputWASM[];
|
|
83
|
+
}
|
|
84
|
+
/** Pool -> new identity (spend). */
|
|
85
|
+
export interface IdentityCreateFromShieldedPoolParams extends ShieldedSpendParams {
|
|
86
|
+
publicKeys: IdentityPublicKeyInCreation[];
|
|
87
|
+
privateKeys: PrivateKeyWASM[];
|
|
88
|
+
denomination: bigint;
|
|
89
|
+
sendToAddressOnCreationFailure: PlatformAddressLike;
|
|
90
|
+
}
|
|
91
|
+
/** Maps each shielded transition type to the params it requires. */
|
|
92
|
+
export interface ShieldedTransitionParamsMap {
|
|
93
|
+
shield: ShieldParams;
|
|
94
|
+
shieldFromAssetLock: ShieldFromAssetLockParams;
|
|
95
|
+
shieldedWithdrawal: ShieldedWithdrawalParams;
|
|
96
|
+
unshield: UnshieldParams;
|
|
97
|
+
shieldedTransfer: ShieldedTransferParams;
|
|
98
|
+
shieldedTransferMulti: ShieldedTransferMultiParams;
|
|
99
|
+
identityCreateFromShieldedPool: IdentityCreateFromShieldedPoolParams;
|
|
100
|
+
}
|
|
101
|
+
export type ShieldedTransitionType = keyof ShieldedTransitionParamsMap;
|
|
102
|
+
export type ShieldedTransitionParams = ShieldedTransitionParamsMap[ShieldedTransitionType];
|
|
23
103
|
export interface MasternodeInfo {
|
|
24
104
|
proTxHash: string;
|
|
25
105
|
address: string;
|
|
@@ -210,3 +290,74 @@ export interface PlatformAddressInfo {
|
|
|
210
290
|
nonce: number;
|
|
211
291
|
balance: bigint;
|
|
212
292
|
}
|
|
293
|
+
export interface PlatformAddressesTrunkState {
|
|
294
|
+
trunk: VerifiedAddressesTrunkState;
|
|
295
|
+
metadata: ResponseMetadata;
|
|
296
|
+
}
|
|
297
|
+
export interface ShieldedEncryptedNote {
|
|
298
|
+
nullifier: Uint8Array;
|
|
299
|
+
cmx: Uint8Array;
|
|
300
|
+
encryptedNote: Uint8Array;
|
|
301
|
+
cvNet: Uint8Array;
|
|
302
|
+
}
|
|
303
|
+
export interface ShieldedNullifierStatus {
|
|
304
|
+
nullifier: Uint8Array;
|
|
305
|
+
isSpent: boolean;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Fields shared by the address-funded transitions (the ones spending platform address inputs).
|
|
309
|
+
*
|
|
310
|
+
* The `inputWitness` arrays are produced by the client application (wallet / mobile / browser
|
|
311
|
+
* extension), which is where the address private keys live. The builders only assemble the
|
|
312
|
+
* transition - they never sign or hit the network.
|
|
313
|
+
*/
|
|
314
|
+
export interface AddressFundsBaseParams {
|
|
315
|
+
inputs: InputAddressWASM[];
|
|
316
|
+
feeStrategy: AddressFundsFeeStrategyStepWASM[];
|
|
317
|
+
inputWitness: AddressWitnessWASM[];
|
|
318
|
+
userFeeIncrease?: number;
|
|
319
|
+
}
|
|
320
|
+
/** Identity -> platform addresses (transition type 9). */
|
|
321
|
+
export interface IdentityCreditTransferToAddressesParams {
|
|
322
|
+
identityId: IdentifierLike;
|
|
323
|
+
recipients: OutputAddressWASM[];
|
|
324
|
+
nonce: bigint;
|
|
325
|
+
userFeeIncrease?: number;
|
|
326
|
+
}
|
|
327
|
+
/** Platform addresses -> new identity (transition type 10). */
|
|
328
|
+
export interface IdentityCreateFromAddressesParams extends AddressFundsBaseParams {
|
|
329
|
+
publicKeys: IdentityPublicKeyInCreationWASM[];
|
|
330
|
+
output?: OutputAddressWASM;
|
|
331
|
+
}
|
|
332
|
+
/** Platform addresses -> existing identity (transition type 11). */
|
|
333
|
+
export interface IdentityTopUpFromAddressesParams extends AddressFundsBaseParams {
|
|
334
|
+
identityId: IdentifierLike;
|
|
335
|
+
output?: OutputAddressWASM;
|
|
336
|
+
}
|
|
337
|
+
/** Platform addresses -> platform addresses (transition type 12). */
|
|
338
|
+
export interface AddressFundsTransferParams extends AddressFundsBaseParams {
|
|
339
|
+
outputs: OutputAddressWASM[];
|
|
340
|
+
}
|
|
341
|
+
/** Asset lock -> platform addresses (transition type 13). */
|
|
342
|
+
export interface AddressFundingFromAssetLockParams extends AddressFundsBaseParams {
|
|
343
|
+
assetLockProof: AssetLockProofWASM;
|
|
344
|
+
outputs: OutputAddressNullableCreditsWASM[];
|
|
345
|
+
}
|
|
346
|
+
/** Platform addresses -> core L1 (transition type 14). */
|
|
347
|
+
export interface AddressCreditWithdrawalParams extends AddressFundsBaseParams {
|
|
348
|
+
coreFeePerByte: number;
|
|
349
|
+
pooling: 'Standard' | 'Never' | 'IfAvailable';
|
|
350
|
+
outputScript: CoreScriptWASM;
|
|
351
|
+
output?: OutputAddressWASM;
|
|
352
|
+
}
|
|
353
|
+
/** Maps each platform address transition type to the params it requires. */
|
|
354
|
+
export interface PlatformAddressTransitionParamsMap {
|
|
355
|
+
identityCreditTransferToAddresses: IdentityCreditTransferToAddressesParams;
|
|
356
|
+
identityCreateFromAddresses: IdentityCreateFromAddressesParams;
|
|
357
|
+
identityTopUpFromAddresses: IdentityTopUpFromAddressesParams;
|
|
358
|
+
addressFundsTransfer: AddressFundsTransferParams;
|
|
359
|
+
addressFundingFromAssetLock: AddressFundingFromAssetLockParams;
|
|
360
|
+
addressCreditWithdrawal: AddressCreditWithdrawalParams;
|
|
361
|
+
}
|
|
362
|
+
export type PlatformAddressTransitionType = keyof PlatformAddressTransitionParamsMap;
|
|
363
|
+
export type PlatformAddressTransitionParams = PlatformAddressTransitionParamsMap[PlatformAddressTransitionType];
|
package/types.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { CoreScriptWASM, DocumentWASM, GasFeesPaidByWASM, IdentifierWASM, KeyType, Purpose, SecurityLevel, TokenEmergencyActionWASM, TokenPricingScheduleWASM, StateTransitionWASM, BatchTransitionWASM, IdentityPublicKeyWASM, PrivateKeyWASM, DataContractUpdateTransitionWASM, IdentityWASM, IdentityUpdateTransitionWASM, IdentityCreditTransferWASM, MasternodeVoteTransitionWASM } from 'pshenmic-dpp';
|
|
1
|
+
export { CoreScriptWASM, DocumentWASM, GasFeesPaidByWASM, IdentifierWASM, KeyType, Purpose, SecurityLevel, TokenEmergencyActionWASM, TokenPricingScheduleWASM, StateTransitionWASM, BatchTransitionWASM, IdentityPublicKeyWASM, PrivateKeyWASM, DataContractUpdateTransitionWASM, IdentityWASM, IdentityUpdateTransitionWASM, IdentityCreditTransferWASM, MasternodeVoteTransitionWASM, InputAddressWASM, OutputAddressWASM, OutputAddressNullableCreditsWASM, AddressFundsFeeStrategyStepWASM, AddressWitnessWASM, IdentityPublicKeyInCreationWASM, AssetLockProofWASM, IdentityCreditTransferToAddressesTransitionWASM, IdentityCreateFromAddressesTransitionWASM, IdentityTopUpFromAddressesTransitionWASM, AddressFundsTransferTransitionWASM, AddressFundingFromAssetLockTransitionWASM, AddressCreditWithdrawalTransitionWASM } from 'pshenmic-dpp';
|
|
2
2
|
export { DashPlatformSDK } from './src/DashPlatformSDK.js';
|
|
3
3
|
export var ContestedStateResultType;
|
|
4
4
|
(function (ContestedStateResultType) {
|