pshenmic-dpp 2.0.0-dev.24 → 2.0.0-dev.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/binaries/bindingsTypes.d.ts +14 -1
- package/dist/binaries/bindingsTypes.js +1 -0
- package/dist/binaries/native/aarch64-apple-darwin/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-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/pshenmic_dpp.android.node/arm64-v8a/libpshenmic_dpp.so +0 -0
- package/dist/binaries/pshenmic_dpp.apple.node/ios-arm64-simulator/libpshenmic_dpp.framework/libpshenmic_dpp +0 -0
- package/dist/binaries/wasm/wasmBytes.cjs +1 -1
- package/dist/src/dpp/structs/Orchard/RecoveredNote.d.ts +1 -0
- package/dist/src/dpp/structs/Orchard/RecoveredNote.js +3 -0
- package/dist/src/dpp/structs/ShieldedTransitions/IdentityCreateFromShieldedPoolTransition.d.ts +2 -1
- package/dist/src/dpp/structs/ShieldedTransitions/IdentityCreateFromShieldedPoolTransition.js +3 -0
- package/dist/src/dpp/structs/ShieldedTransitions/ShieldFromAssetLockTransition.d.ts +2 -1
- package/dist/src/dpp/structs/ShieldedTransitions/ShieldFromAssetLockTransition.js +3 -0
- package/dist/src/dpp/structs/ShieldedTransitions/ShieldTransition.d.ts +2 -1
- package/dist/src/dpp/structs/ShieldedTransitions/ShieldTransition.js +3 -0
- package/dist/src/dpp/structs/ShieldedTransitions/ShieldedTransferTransition.d.ts +2 -1
- package/dist/src/dpp/structs/ShieldedTransitions/ShieldedTransferTransition.js +3 -0
- package/dist/src/dpp/structs/ShieldedTransitions/ShieldedWithdrawalTransition.d.ts +2 -1
- package/dist/src/dpp/structs/ShieldedTransitions/ShieldedWithdrawalTransition.js +3 -0
- package/dist/src/dpp/structs/ShieldedTransitions/UnshieldTransition.d.ts +2 -1
- package/dist/src/dpp/structs/ShieldedTransitions/UnshieldTransition.js +3 -0
- package/dist/src/dpp/types.d.ts +6 -0
- package/dist/src/dpp/verify/StateTransition/verifyStateTransitionResult.js +2 -1
- package/package.json +1 -1
- package/tests/unit/ShieldedTransitions.spec.ts +168 -0
|
@@ -8,6 +8,7 @@ export declare class RecoveredNoteWASM {
|
|
|
8
8
|
/** The action's global leaf position in the commitment tree. */
|
|
9
9
|
get index(): number;
|
|
10
10
|
get note(): NoteWASM;
|
|
11
|
+
get nullifier(): Uint8Array;
|
|
11
12
|
static createFromRawInstance(rawInstance: RecoveredNoteNAPI): RecoveredNoteWASM;
|
|
12
13
|
}
|
|
13
14
|
/**
|
|
@@ -11,6 +11,9 @@ export class RecoveredNoteWASM {
|
|
|
11
11
|
get note() {
|
|
12
12
|
return NoteWASM.createFromRawInstance(this._rawRecoveredNote.note);
|
|
13
13
|
}
|
|
14
|
+
get nullifier() {
|
|
15
|
+
return this._rawRecoveredNote.nullifier;
|
|
16
|
+
}
|
|
14
17
|
static createFromRawInstance(rawInstance) {
|
|
15
18
|
const instance = Object.create(RecoveredNoteWASM.prototype);
|
|
16
19
|
instance._rawRecoveredNote = rawInstance;
|
package/dist/src/dpp/structs/ShieldedTransitions/IdentityCreateFromShieldedPoolTransition.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IdentityCreateFromShieldedPoolTransitionNAPI } from '../../../../binaries/bindingsTypes.js';
|
|
1
|
+
import type { PlatformVersionNAPI, IdentityCreateFromShieldedPoolTransitionNAPI } from '../../../../binaries/bindingsTypes.js';
|
|
2
2
|
import { IdentityPublicKeyInCreationWASM } from '../IdentityPublicKeyInCreation.js';
|
|
3
3
|
import { SerializedActionWASM } from './SerializedAction.js';
|
|
4
4
|
import { PlatformAddressWASM } from '../PlatformAddress/PlatformAddress.js';
|
|
@@ -25,6 +25,7 @@ export declare class IdentityCreateFromShieldedPoolTransitionWASM {
|
|
|
25
25
|
set sendToAddressOnCreationFailure(value: PlatformAddressLike);
|
|
26
26
|
get identityId(): IdentifierWASM;
|
|
27
27
|
set identityId(value: IdentifierLike);
|
|
28
|
+
static computeMinimumFee(numActions: number, numKeys: number, platformVersion?: PlatformVersionNAPI): bigint;
|
|
28
29
|
toStateTransition(): StateTransitionWASM;
|
|
29
30
|
static fromStateTransition(st: StateTransitionWASM): IdentityCreateFromShieldedPoolTransitionWASM;
|
|
30
31
|
static createFromRawInstance(rawInstance: IdentityCreateFromShieldedPoolTransitionNAPI): IdentityCreateFromShieldedPoolTransitionWASM;
|
package/dist/src/dpp/structs/ShieldedTransitions/IdentityCreateFromShieldedPoolTransition.js
CHANGED
|
@@ -59,6 +59,9 @@ export class IdentityCreateFromShieldedPoolTransitionWASM {
|
|
|
59
59
|
set identityId(value) {
|
|
60
60
|
this._rawIdentityCreateFromShieldedPoolTransition.identityId = prepareIdentifierValue(value);
|
|
61
61
|
}
|
|
62
|
+
static computeMinimumFee(numActions, numKeys, platformVersion) {
|
|
63
|
+
return BigInt(dppProvider.dpp.IdentityCreateFromShieldedPoolTransitionNAPI.computeMinimumFee(numActions, numKeys, platformVersion));
|
|
64
|
+
}
|
|
62
65
|
toStateTransition() {
|
|
63
66
|
return StateTransitionWASM.createFromRawInstance(this._rawIdentityCreateFromShieldedPoolTransition.toStateTransition());
|
|
64
67
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ShieldFromAssetLockTransitionNAPI } from '../../../../binaries/bindingsTypes.js';
|
|
1
|
+
import type { PlatformVersionNAPI, ShieldFromAssetLockTransitionNAPI } from '../../../../binaries/bindingsTypes.js';
|
|
2
2
|
import { SerializedActionWASM } from './SerializedAction.js';
|
|
3
3
|
import { AssetLockProofWASM } from '../AssetLockProof/AssetLockProof.js';
|
|
4
4
|
import { PlatformAddressWASM } from '../PlatformAddress/PlatformAddress.js';
|
|
@@ -24,6 +24,7 @@ export declare class ShieldFromAssetLockTransitionWASM {
|
|
|
24
24
|
set surplusOutput(value: PlatformAddressLike | undefined);
|
|
25
25
|
get signature(): Uint8Array;
|
|
26
26
|
set signature(value: Uint8Array);
|
|
27
|
+
static computeMinimumFee(numActions: number, platformVersion?: PlatformVersionNAPI): bigint;
|
|
27
28
|
toStateTransition(): StateTransitionWASM;
|
|
28
29
|
static fromStateTransition(st: StateTransitionWASM): ShieldFromAssetLockTransitionWASM;
|
|
29
30
|
static createFromRawInstance(rawInstance: ShieldFromAssetLockTransitionNAPI): ShieldFromAssetLockTransitionWASM;
|
|
@@ -63,6 +63,9 @@ export class ShieldFromAssetLockTransitionWASM {
|
|
|
63
63
|
set signature(value) {
|
|
64
64
|
this._rawShieldFromAssetLockTransition.signature = value;
|
|
65
65
|
}
|
|
66
|
+
static computeMinimumFee(numActions, platformVersion) {
|
|
67
|
+
return BigInt(dppProvider.dpp.ShieldFromAssetLockTransitionNAPI.computeMinimumFee(numActions, platformVersion));
|
|
68
|
+
}
|
|
66
69
|
toStateTransition() {
|
|
67
70
|
return StateTransitionWASM.createFromRawInstance(this._rawShieldFromAssetLockTransition.toStateTransition());
|
|
68
71
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ShieldTransitionNAPI } from '../../../../binaries/bindingsTypes.js';
|
|
1
|
+
import type { PlatformVersionNAPI, ShieldTransitionNAPI } from '../../../../binaries/bindingsTypes.js';
|
|
2
2
|
import { InputAddressWASM } from '../AddressTransitions/entities/InputAddress.js';
|
|
3
3
|
import { AddressFundsFeeStrategyStepWASM } from '../AddressTransitions/entities/AddressFundsFeeStrategyStep.js';
|
|
4
4
|
import { AddressWitnessWASM } from '../PlatformAddress/AddressWitness.js';
|
|
@@ -26,6 +26,7 @@ export declare class ShieldTransitionWASM {
|
|
|
26
26
|
set userFeeIncrease(value: number);
|
|
27
27
|
get inputWitnesses(): AddressWitnessWASM[];
|
|
28
28
|
set inputWitnesses(value: AddressWitnessWASM[]);
|
|
29
|
+
static computeMinimumFee(numActions: number, platformVersion?: PlatformVersionNAPI): bigint;
|
|
29
30
|
toStateTransition(): StateTransitionWASM;
|
|
30
31
|
static fromStateTransition(st: StateTransitionWASM): ShieldTransitionWASM;
|
|
31
32
|
static createFromRawInstance(rawInstance: ShieldTransitionNAPI): ShieldTransitionWASM;
|
|
@@ -64,6 +64,9 @@ export class ShieldTransitionWASM {
|
|
|
64
64
|
set inputWitnesses(value) {
|
|
65
65
|
this._rawShieldTransition.inputWitnesses = value.map(w => w._rawWitness);
|
|
66
66
|
}
|
|
67
|
+
static computeMinimumFee(numActions, platformVersion) {
|
|
68
|
+
return BigInt(dppProvider.dpp.ShieldTransitionNAPI.computeMinimumFee(numActions, platformVersion));
|
|
69
|
+
}
|
|
67
70
|
toStateTransition() {
|
|
68
71
|
return StateTransitionWASM.createFromRawInstance(this._rawShieldTransition.toStateTransition());
|
|
69
72
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ShieldedTransferTransitionNAPI } from '../../../../binaries/bindingsTypes.js';
|
|
1
|
+
import type { PlatformVersionNAPI, ShieldedTransferTransitionNAPI } from '../../../../binaries/bindingsTypes.js';
|
|
2
2
|
import { SerializedActionWASM } from './SerializedAction.js';
|
|
3
3
|
import { StateTransitionWASM } from '../StateTransition.js';
|
|
4
4
|
export declare class ShieldedTransferTransitionWASM {
|
|
@@ -15,6 +15,7 @@ export declare class ShieldedTransferTransitionWASM {
|
|
|
15
15
|
set proof(value: Uint8Array);
|
|
16
16
|
get bindingsSignature(): Uint8Array;
|
|
17
17
|
set bindingsSignature(value: Uint8Array);
|
|
18
|
+
static computeMinimumFee(numActions: number, platformVersion?: PlatformVersionNAPI): bigint;
|
|
18
19
|
toStateTransition(): StateTransitionWASM;
|
|
19
20
|
static fromStateTransition(st: StateTransitionWASM): ShieldedTransferTransitionWASM;
|
|
20
21
|
static createFromRawInstance(rawInstance: ShieldedTransferTransitionNAPI): ShieldedTransferTransitionWASM;
|
|
@@ -37,6 +37,9 @@ export class ShieldedTransferTransitionWASM {
|
|
|
37
37
|
set bindingsSignature(value) {
|
|
38
38
|
this._rawShieldedTransferTransition.bindingsSignature = value;
|
|
39
39
|
}
|
|
40
|
+
static computeMinimumFee(numActions, platformVersion) {
|
|
41
|
+
return BigInt(dppProvider.dpp.ShieldedTransferTransitionNAPI.computeMinimumFee(numActions, platformVersion));
|
|
42
|
+
}
|
|
40
43
|
toStateTransition() {
|
|
41
44
|
return StateTransitionWASM.createFromRawInstance(this._rawShieldedTransferTransition.toStateTransition());
|
|
42
45
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ShieldedWithdrawalTransitionNAPI } from '../../../../binaries/bindingsTypes.js';
|
|
1
|
+
import type { PlatformVersionNAPI, ShieldedWithdrawalTransitionNAPI } from '../../../../binaries/bindingsTypes.js';
|
|
2
2
|
import { SerializedActionWASM } from './SerializedAction.js';
|
|
3
3
|
import { CoreScriptWASM } from '../CoreScript.js';
|
|
4
4
|
import { PoolingLike } from '../../types.js';
|
|
@@ -23,6 +23,7 @@ export declare class ShieldedWithdrawalTransitionWASM {
|
|
|
23
23
|
set pooling(value: PoolingLike);
|
|
24
24
|
get outputScript(): CoreScriptWASM;
|
|
25
25
|
set outputScript(value: CoreScriptWASM);
|
|
26
|
+
static computeMinimumFee(numActions: number, platformVersion?: PlatformVersionNAPI): bigint;
|
|
26
27
|
toStateTransition(): StateTransitionWASM;
|
|
27
28
|
static fromStateTransition(st: StateTransitionWASM): ShieldedWithdrawalTransitionWASM;
|
|
28
29
|
static createFromRawInstance(rawInstance: ShieldedWithdrawalTransitionNAPI): ShieldedWithdrawalTransitionWASM;
|
|
@@ -57,6 +57,9 @@ export class ShieldedWithdrawalTransitionWASM {
|
|
|
57
57
|
set outputScript(value) {
|
|
58
58
|
this._rawShieldedWithdrawalTransition.outputScript = value._rawCoreScript;
|
|
59
59
|
}
|
|
60
|
+
static computeMinimumFee(numActions, platformVersion) {
|
|
61
|
+
return BigInt(dppProvider.dpp.ShieldedWithdrawalTransitionNAPI.computeMinimumFee(numActions, platformVersion));
|
|
62
|
+
}
|
|
60
63
|
toStateTransition() {
|
|
61
64
|
return StateTransitionWASM.createFromRawInstance(this._rawShieldedWithdrawalTransition.toStateTransition());
|
|
62
65
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { UnshieldTransitionNAPI } from '../../../../binaries/bindingsTypes.js';
|
|
1
|
+
import type { PlatformVersionNAPI, UnshieldTransitionNAPI } from '../../../../binaries/bindingsTypes.js';
|
|
2
2
|
import { SerializedActionWASM } from './SerializedAction.js';
|
|
3
3
|
import { PlatformAddressWASM } from '../PlatformAddress/PlatformAddress.js';
|
|
4
4
|
import { PlatformAddressLike } from '../../types.js';
|
|
@@ -19,6 +19,7 @@ export declare class UnshieldTransitionWASM {
|
|
|
19
19
|
set proof(value: Uint8Array);
|
|
20
20
|
get bindingsSignature(): Uint8Array;
|
|
21
21
|
set bindingsSignature(value: Uint8Array);
|
|
22
|
+
static computeMinimumFee(numActions: number, platformVersion?: PlatformVersionNAPI): bigint;
|
|
22
23
|
toStateTransition(): StateTransitionWASM;
|
|
23
24
|
static fromStateTransition(st: StateTransitionWASM): UnshieldTransitionWASM;
|
|
24
25
|
static createFromRawInstance(rawInstance: UnshieldTransitionNAPI): UnshieldTransitionWASM;
|
|
@@ -45,6 +45,9 @@ export class UnshieldTransitionWASM {
|
|
|
45
45
|
set bindingsSignature(value) {
|
|
46
46
|
this._rawUnshieldTransition.bindingsSignature = value;
|
|
47
47
|
}
|
|
48
|
+
static computeMinimumFee(numActions, platformVersion) {
|
|
49
|
+
return BigInt(dppProvider.dpp.UnshieldTransitionNAPI.computeMinimumFee(numActions, platformVersion));
|
|
50
|
+
}
|
|
48
51
|
toStateTransition() {
|
|
49
52
|
return StateTransitionWASM.createFromRawInstance(this._rawUnshieldTransition.toStateTransition());
|
|
50
53
|
}
|
package/dist/src/dpp/types.d.ts
CHANGED
|
@@ -250,6 +250,12 @@ export type VerifiedStateTransitionResultVariantsRAW = protocol.DataContractNAPI
|
|
|
250
250
|
export interface VerifiedStateTransitionResult {
|
|
251
251
|
rootHash: Uint8Array;
|
|
252
252
|
result: VerifiedStateTransitionResultVariants;
|
|
253
|
+
/**
|
|
254
|
+
* Whether the proof binds the execution of this specific state transition.
|
|
255
|
+
* When false, the result is a height-pinned snapshot of the state the
|
|
256
|
+
* transition affects, not evidence that the transition executed.
|
|
257
|
+
*/
|
|
258
|
+
isExecutionProved: boolean;
|
|
253
259
|
}
|
|
254
260
|
export type WhereOperator = '=' | '==' | '>' | '>=' | '<' | '<=' | 'Between' | 'between' | 'BetweenExcludeBounds' | 'betweenExcludeBounds' | 'betweenexcludebounds' | 'between_exclude_bounds' | 'BetweenExcludeLeft' | 'betweenExcludeLeft' | 'betweenexcludeleft' | 'between_exclude_left' | 'BetweenExcludeRight' | 'betweenExcludeRight' | 'betweenexcluderight' | 'between_exclude_right' | 'In' | 'in' | 'StartsWith' | 'startsWith' | 'startswith' | 'starts_with';
|
|
255
261
|
export type WhereClause = [
|
|
@@ -5,6 +5,7 @@ export function verifyStateTransitionResult(proof, stateTransition, blockInfo, k
|
|
|
5
5
|
const verified = dppProvider.dpp.verifyStateTransitionResult(proof, stateTransition._rawStateTransition, new dppProvider.dpp.BlockInfoNAPI(blockInfo.timeMs.toString(), blockInfo.height.toString(), blockInfo.coreHeight, blockInfo.epoch), knownContractsArray.map(contract => contract._rawDataContract), valueToDynamicValue(platformVersion));
|
|
6
6
|
return {
|
|
7
7
|
rootHash: verified.rootHash,
|
|
8
|
-
result: convertResult(verified.result)
|
|
8
|
+
result: convertResult(verified.result),
|
|
9
|
+
isExecutionProved: verified.isExecutionProved
|
|
9
10
|
};
|
|
10
11
|
}
|
package/package.json
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
Purpose,
|
|
19
19
|
SecurityLevel,
|
|
20
20
|
KeyType,
|
|
21
|
+
PlatformVersionWASM,
|
|
21
22
|
StateTransitionWASM
|
|
22
23
|
} from 'pshenmic-dpp'
|
|
23
24
|
|
|
@@ -190,6 +191,27 @@ describe('ShieldedTransferTransition', function () {
|
|
|
190
191
|
expect(restored.actions.length).toEqual(1)
|
|
191
192
|
})
|
|
192
193
|
})
|
|
194
|
+
|
|
195
|
+
describe('computeMinimumFee', function () {
|
|
196
|
+
test('should return a positive fee', function () {
|
|
197
|
+
const fee = ShieldedTransferTransitionWASM.computeMinimumFee(2)
|
|
198
|
+
|
|
199
|
+
expect(typeof fee).toEqual('bigint')
|
|
200
|
+
expect(fee).toBeGreaterThan(BigInt(0))
|
|
201
|
+
})
|
|
202
|
+
|
|
203
|
+
test('should grow with the action count', function () {
|
|
204
|
+
const oneAction = ShieldedTransferTransitionWASM.computeMinimumFee(1)
|
|
205
|
+
const twoActions = ShieldedTransferTransitionWASM.computeMinimumFee(2)
|
|
206
|
+
|
|
207
|
+
expect(twoActions).toBeGreaterThan(oneAction)
|
|
208
|
+
})
|
|
209
|
+
|
|
210
|
+
test('should default to the latest platform version', function () {
|
|
211
|
+
expect(ShieldedTransferTransitionWASM.computeMinimumFee(2))
|
|
212
|
+
.toEqual(ShieldedTransferTransitionWASM.computeMinimumFee(2, PlatformVersionWASM.PLATFORM_V12))
|
|
213
|
+
})
|
|
214
|
+
})
|
|
193
215
|
})
|
|
194
216
|
|
|
195
217
|
describe('ShieldTransition', function () {
|
|
@@ -291,6 +313,27 @@ describe('ShieldTransition', function () {
|
|
|
291
313
|
expect(restored.actions.length).toEqual(1)
|
|
292
314
|
})
|
|
293
315
|
})
|
|
316
|
+
|
|
317
|
+
describe('computeMinimumFee', function () {
|
|
318
|
+
test('should return a positive fee', function () {
|
|
319
|
+
const fee = ShieldTransitionWASM.computeMinimumFee(2)
|
|
320
|
+
|
|
321
|
+
expect(typeof fee).toEqual('bigint')
|
|
322
|
+
expect(fee).toBeGreaterThan(BigInt(0))
|
|
323
|
+
})
|
|
324
|
+
|
|
325
|
+
test('should grow with the action count', function () {
|
|
326
|
+
const oneAction = ShieldTransitionWASM.computeMinimumFee(1)
|
|
327
|
+
const twoActions = ShieldTransitionWASM.computeMinimumFee(2)
|
|
328
|
+
|
|
329
|
+
expect(twoActions).toBeGreaterThan(oneAction)
|
|
330
|
+
})
|
|
331
|
+
|
|
332
|
+
test('should default to the latest platform version', function () {
|
|
333
|
+
expect(ShieldTransitionWASM.computeMinimumFee(2))
|
|
334
|
+
.toEqual(ShieldTransitionWASM.computeMinimumFee(2, PlatformVersionWASM.PLATFORM_V12))
|
|
335
|
+
})
|
|
336
|
+
})
|
|
294
337
|
})
|
|
295
338
|
|
|
296
339
|
describe('UnshieldTransition', function () {
|
|
@@ -381,6 +424,27 @@ describe('UnshieldTransition', function () {
|
|
|
381
424
|
expect(restored.bindingsSignature).toEqual(bindingsSignature)
|
|
382
425
|
})
|
|
383
426
|
})
|
|
427
|
+
|
|
428
|
+
describe('computeMinimumFee', function () {
|
|
429
|
+
test('should return a positive fee', function () {
|
|
430
|
+
const fee = UnshieldTransitionWASM.computeMinimumFee(2)
|
|
431
|
+
|
|
432
|
+
expect(typeof fee).toEqual('bigint')
|
|
433
|
+
expect(fee).toBeGreaterThan(BigInt(0))
|
|
434
|
+
})
|
|
435
|
+
|
|
436
|
+
test('should grow with the action count', function () {
|
|
437
|
+
const oneAction = UnshieldTransitionWASM.computeMinimumFee(1)
|
|
438
|
+
const twoActions = UnshieldTransitionWASM.computeMinimumFee(2)
|
|
439
|
+
|
|
440
|
+
expect(twoActions).toBeGreaterThan(oneAction)
|
|
441
|
+
})
|
|
442
|
+
|
|
443
|
+
test('should default to the latest platform version', function () {
|
|
444
|
+
expect(UnshieldTransitionWASM.computeMinimumFee(2))
|
|
445
|
+
.toEqual(UnshieldTransitionWASM.computeMinimumFee(2, PlatformVersionWASM.PLATFORM_V12))
|
|
446
|
+
})
|
|
447
|
+
})
|
|
384
448
|
})
|
|
385
449
|
|
|
386
450
|
describe('ShieldFromAssetLockTransition', function () {
|
|
@@ -491,6 +555,27 @@ describe('ShieldFromAssetLockTransition', function () {
|
|
|
491
555
|
expect(restored.actions.length).toEqual(1)
|
|
492
556
|
})
|
|
493
557
|
})
|
|
558
|
+
|
|
559
|
+
describe('computeMinimumFee', function () {
|
|
560
|
+
test('should return a positive fee', function () {
|
|
561
|
+
const fee = ShieldFromAssetLockTransitionWASM.computeMinimumFee(2)
|
|
562
|
+
|
|
563
|
+
expect(typeof fee).toEqual('bigint')
|
|
564
|
+
expect(fee).toBeGreaterThan(BigInt(0))
|
|
565
|
+
})
|
|
566
|
+
|
|
567
|
+
test('should grow with the action count', function () {
|
|
568
|
+
const oneAction = ShieldFromAssetLockTransitionWASM.computeMinimumFee(1)
|
|
569
|
+
const twoActions = ShieldFromAssetLockTransitionWASM.computeMinimumFee(2)
|
|
570
|
+
|
|
571
|
+
expect(twoActions).toBeGreaterThan(oneAction)
|
|
572
|
+
})
|
|
573
|
+
|
|
574
|
+
test('should default to the latest platform version', function () {
|
|
575
|
+
expect(ShieldFromAssetLockTransitionWASM.computeMinimumFee(2))
|
|
576
|
+
.toEqual(ShieldFromAssetLockTransitionWASM.computeMinimumFee(2, PlatformVersionWASM.PLATFORM_V12))
|
|
577
|
+
})
|
|
578
|
+
})
|
|
494
579
|
})
|
|
495
580
|
|
|
496
581
|
describe('ShieldedWithdrawalTransition', function () {
|
|
@@ -590,6 +675,27 @@ describe('ShieldedWithdrawalTransition', function () {
|
|
|
590
675
|
expect(restored.pooling).toEqual('Never')
|
|
591
676
|
})
|
|
592
677
|
})
|
|
678
|
+
|
|
679
|
+
describe('computeMinimumFee', function () {
|
|
680
|
+
test('should return a positive fee', function () {
|
|
681
|
+
const fee = ShieldedWithdrawalTransitionWASM.computeMinimumFee(2)
|
|
682
|
+
|
|
683
|
+
expect(typeof fee).toEqual('bigint')
|
|
684
|
+
expect(fee).toBeGreaterThan(BigInt(0))
|
|
685
|
+
})
|
|
686
|
+
|
|
687
|
+
test('should grow with the action count', function () {
|
|
688
|
+
const oneAction = ShieldedWithdrawalTransitionWASM.computeMinimumFee(1)
|
|
689
|
+
const twoActions = ShieldedWithdrawalTransitionWASM.computeMinimumFee(2)
|
|
690
|
+
|
|
691
|
+
expect(twoActions).toBeGreaterThan(oneAction)
|
|
692
|
+
})
|
|
693
|
+
|
|
694
|
+
test('should default to the latest platform version', function () {
|
|
695
|
+
expect(ShieldedWithdrawalTransitionWASM.computeMinimumFee(2))
|
|
696
|
+
.toEqual(ShieldedWithdrawalTransitionWASM.computeMinimumFee(2, PlatformVersionWASM.PLATFORM_V12))
|
|
697
|
+
})
|
|
698
|
+
})
|
|
593
699
|
})
|
|
594
700
|
|
|
595
701
|
describe('IdentityCreateFromShieldedPoolTransition', function () {
|
|
@@ -706,4 +812,66 @@ describe('IdentityCreateFromShieldedPoolTransition', function () {
|
|
|
706
812
|
expect(restored.identityId.bytes()).toEqual(identityId.bytes())
|
|
707
813
|
})
|
|
708
814
|
})
|
|
815
|
+
|
|
816
|
+
describe('computeMinimumFee', function () {
|
|
817
|
+
test('should return a positive fee', function () {
|
|
818
|
+
const fee = IdentityCreateFromShieldedPoolTransitionWASM.computeMinimumFee(2, 3)
|
|
819
|
+
|
|
820
|
+
expect(typeof fee).toEqual('bigint')
|
|
821
|
+
expect(fee).toBeGreaterThan(BigInt(0))
|
|
822
|
+
})
|
|
823
|
+
|
|
824
|
+
test('should grow with the action count', function () {
|
|
825
|
+
const oneAction = IdentityCreateFromShieldedPoolTransitionWASM.computeMinimumFee(1, 3)
|
|
826
|
+
const twoActions = IdentityCreateFromShieldedPoolTransitionWASM.computeMinimumFee(2, 3)
|
|
827
|
+
|
|
828
|
+
expect(twoActions).toBeGreaterThan(oneAction)
|
|
829
|
+
})
|
|
830
|
+
|
|
831
|
+
test('should grow with the key count', function () {
|
|
832
|
+
const oneKey = IdentityCreateFromShieldedPoolTransitionWASM.computeMinimumFee(2, 1)
|
|
833
|
+
const threeKeys = IdentityCreateFromShieldedPoolTransitionWASM.computeMinimumFee(2, 3)
|
|
834
|
+
|
|
835
|
+
expect(threeKeys).toBeGreaterThan(oneKey)
|
|
836
|
+
})
|
|
837
|
+
|
|
838
|
+
test('should default to the latest platform version', function () {
|
|
839
|
+
expect(IdentityCreateFromShieldedPoolTransitionWASM.computeMinimumFee(2, 3))
|
|
840
|
+
.toEqual(IdentityCreateFromShieldedPoolTransitionWASM.computeMinimumFee(2, 3, PlatformVersionWASM.PLATFORM_V12))
|
|
841
|
+
})
|
|
842
|
+
})
|
|
843
|
+
})
|
|
844
|
+
|
|
845
|
+
describe('computeMinimumFee across shielded transitions', function () {
|
|
846
|
+
const numActions = 2
|
|
847
|
+
|
|
848
|
+
test('Shield should be the compute-only fee, without the per-action storage term', function () {
|
|
849
|
+
expect(ShieldTransitionWASM.computeMinimumFee(numActions))
|
|
850
|
+
.toBeLessThan(ShieldedTransferTransitionWASM.computeMinimumFee(numActions))
|
|
851
|
+
})
|
|
852
|
+
|
|
853
|
+
test('Shield and ShieldedTransfer should agree with no actions', function () {
|
|
854
|
+
expect(ShieldTransitionWASM.computeMinimumFee(0))
|
|
855
|
+
.toEqual(ShieldedTransferTransitionWASM.computeMinimumFee(0))
|
|
856
|
+
})
|
|
857
|
+
|
|
858
|
+
test('ShieldFromAssetLock should match ShieldedTransfer', function () {
|
|
859
|
+
expect(ShieldFromAssetLockTransitionWASM.computeMinimumFee(numActions))
|
|
860
|
+
.toEqual(ShieldedTransferTransitionWASM.computeMinimumFee(numActions))
|
|
861
|
+
})
|
|
862
|
+
|
|
863
|
+
test('Unshield should add the output address write on top of ShieldedTransfer', function () {
|
|
864
|
+
expect(UnshieldTransitionWASM.computeMinimumFee(numActions))
|
|
865
|
+
.toBeGreaterThan(ShieldedTransferTransitionWASM.computeMinimumFee(numActions))
|
|
866
|
+
})
|
|
867
|
+
|
|
868
|
+
test('ShieldedWithdrawal should add the withdrawal document write on top of Unshield', function () {
|
|
869
|
+
expect(ShieldedWithdrawalTransitionWASM.computeMinimumFee(numActions))
|
|
870
|
+
.toBeGreaterThan(UnshieldTransitionWASM.computeMinimumFee(numActions))
|
|
871
|
+
})
|
|
872
|
+
|
|
873
|
+
test('IdentityCreateFromShieldedPool should add the identity create floor on top of ShieldedTransfer', function () {
|
|
874
|
+
expect(IdentityCreateFromShieldedPoolTransitionWASM.computeMinimumFee(numActions, 1))
|
|
875
|
+
.toBeGreaterThan(ShieldedTransferTransitionWASM.computeMinimumFee(numActions))
|
|
876
|
+
})
|
|
709
877
|
})
|