pshenmic-dpp 2.0.0-dev.2 → 2.0.0-dev.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/binaries/bindingsTypes.d.ts +507 -37
- package/dist/binaries/bindingsTypes.js +4 -3
- package/dist/binaries/native/aarch64-apple-darwin/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/node.cjs +50 -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 +42 -1
- package/dist/binaries/pshenmic_dpp.js +1 -1
- package/dist/binaries/wasm/wasmBytes.cjs +3 -0
- package/dist/binaries/wasm/wasmBytes.d.cts +1 -0
- package/dist/binaries/wasm.d.ts +42 -1
- package/dist/binaries/wasm.js +2 -44
- package/dist/binaries/wasmCreation.cjs +46 -0
- package/dist/binaries/wasmCreation.d.cts +2 -0
- package/dist/src/dpp/dpp.d.ts +28 -2
- package/dist/src/dpp/dpp.js +28 -2
- package/dist/src/dpp/structs/AddressTransitions/AddressCreditWithdrawalTransition.d.ts +1 -1
- package/dist/src/dpp/structs/AddressTransitions/AddressCreditWithdrawalTransition.js +2 -2
- package/dist/src/dpp/structs/AddressTransitions/AddressFundingFromAssetLockTransition.d.ts +1 -1
- package/dist/src/dpp/structs/AddressTransitions/AddressFundingFromAssetLockTransition.js +3 -3
- package/dist/src/dpp/structs/AddressTransitions/AddressFundsTransferTransition.d.ts +1 -1
- package/dist/src/dpp/structs/AddressTransitions/AddressFundsTransferTransition.js +3 -3
- package/dist/src/dpp/structs/AddressTransitions/IdentityCreateFromAddressesTransition.d.ts +1 -1
- package/dist/src/dpp/structs/AddressTransitions/IdentityCreateFromAddressesTransition.js +2 -2
- package/dist/src/dpp/structs/AddressTransitions/IdentityCreditTransferToAddressesTransition.js +1 -1
- package/dist/src/dpp/structs/AddressTransitions/IdentityTopUpFromAddressesTransition.d.ts +1 -1
- package/dist/src/dpp/structs/AddressTransitions/IdentityTopUpFromAddressesTransition.js +2 -2
- package/dist/src/dpp/structs/AddressTransitions/entities/InputAddress.d.ts +4 -3
- package/dist/src/dpp/structs/AddressTransitions/entities/InputAddress.js +5 -4
- package/dist/src/dpp/structs/AddressTransitions/entities/OutputAddress.d.ts +4 -3
- package/dist/src/dpp/structs/AddressTransitions/entities/OutputAddress.js +5 -4
- package/dist/src/dpp/structs/AddressTransitions/entities/OutputAddressNullableCredits.d.ts +4 -3
- package/dist/src/dpp/structs/AddressTransitions/entities/OutputAddressNullableCredits.js +5 -4
- package/dist/src/dpp/structs/AssetLockProof/AssetLockProof.js +1 -1
- package/dist/src/dpp/structs/AssetLockProof/ChainAssetLockProof.js +2 -2
- package/dist/src/dpp/structs/AssetLockProof/InstantAssetLockProof.js +1 -1
- package/dist/src/dpp/structs/AssetLockProof/OutPoint.js +1 -1
- package/dist/src/dpp/structs/AssetLockProof/Transaction.js +1 -1
- package/dist/src/dpp/structs/AssetLockProof/TxIn.js +1 -1
- package/dist/src/dpp/structs/AssetLockProof/TxOut.js +1 -1
- package/dist/src/dpp/structs/AssetLockProof/Witness.js +1 -1
- package/dist/src/dpp/structs/Batch/BatchTransition.js +1 -1
- package/dist/src/dpp/structs/Batch/BatchedTransition.js +1 -1
- package/dist/src/dpp/structs/Batch/DocumentBaseTransition.js +1 -1
- package/dist/src/dpp/structs/Batch/DocumentTransition.d.ts +1 -0
- package/dist/src/dpp/structs/Batch/DocumentTransition.js +4 -1
- package/dist/src/dpp/structs/Batch/DocumentTransitions/DocumentCreateTransition.d.ts +1 -1
- package/dist/src/dpp/structs/Batch/DocumentTransitions/DocumentCreateTransition.js +2 -2
- package/dist/src/dpp/structs/Batch/DocumentTransitions/DocumentDeleteTransition.js +1 -1
- package/dist/src/dpp/structs/Batch/DocumentTransitions/DocumentPurchaseTransition.js +1 -1
- package/dist/src/dpp/structs/Batch/DocumentTransitions/DocumentReplaceTransition.d.ts +1 -1
- package/dist/src/dpp/structs/Batch/DocumentTransitions/DocumentReplaceTransition.js +2 -2
- package/dist/src/dpp/structs/Batch/DocumentTransitions/DocumentTransferTransition.js +1 -1
- package/dist/src/dpp/structs/Batch/DocumentTransitions/DocumentUpdatePriceTransition.js +1 -1
- package/dist/src/dpp/structs/Batch/PrefundedVotingBalance.js +1 -1
- package/dist/src/dpp/structs/Batch/TokenBaseTransition.js +1 -1
- package/dist/src/dpp/structs/Batch/TokenPaymentInfo.js +1 -1
- package/dist/src/dpp/structs/Batch/TokenPricingSchedule.js +1 -1
- package/dist/src/dpp/structs/Batch/TokenTransition.d.ts +1 -0
- package/dist/src/dpp/structs/Batch/TokenTransition.js +4 -1
- package/dist/src/dpp/structs/Batch/TokenTransitions/TokenBurnTransition.js +1 -1
- package/dist/src/dpp/structs/Batch/TokenTransitions/TokenClaimTransition.js +1 -1
- package/dist/src/dpp/structs/Batch/TokenTransitions/TokenConfigUpdateTransition.js +1 -1
- package/dist/src/dpp/structs/Batch/TokenTransitions/TokenDestroyFrozenFundsTransition.js +1 -1
- package/dist/src/dpp/structs/Batch/TokenTransitions/TokenDirectPurchaseTransition.js +1 -1
- package/dist/src/dpp/structs/Batch/TokenTransitions/TokenEmergencyActionTransition.js +1 -1
- package/dist/src/dpp/structs/Batch/TokenTransitions/TokenFreezeTransition.js +1 -1
- package/dist/src/dpp/structs/Batch/TokenTransitions/TokenMintTransition.js +1 -1
- package/dist/src/dpp/structs/Batch/TokenTransitions/TokenSetPriceForDirectPurchaseTransition.js +1 -1
- package/dist/src/dpp/structs/Batch/TokenTransitions/TokenTransferTransition.d.ts +3 -0
- package/dist/src/dpp/structs/Batch/TokenTransitions/TokenTransferTransition.js +8 -1
- package/dist/src/dpp/structs/Batch/TokenTransitions/TokenUnFreezeTransition.js +1 -1
- package/dist/src/dpp/structs/ContractBounds.js +1 -1
- package/dist/src/dpp/structs/CoreScript.js +1 -1
- package/dist/src/dpp/structs/DataContract.d.ts +6 -4
- package/dist/src/dpp/structs/DataContract.js +8 -2
- package/dist/src/dpp/structs/DataContractTransitions/DataContractCreateTransition.js +1 -1
- package/dist/src/dpp/structs/DataContractTransitions/DataContractUpdateTransition.js +1 -1
- package/dist/src/dpp/structs/Document.d.ts +1 -1
- package/dist/src/dpp/structs/Document.js +1 -1
- package/dist/src/dpp/structs/EncryptedNote/PrivateEncryptedNote.js +1 -1
- package/dist/src/dpp/structs/EncryptedNote/SharedEncryptedNote.js +1 -1
- package/dist/src/dpp/structs/GroupStateTransitionInfo.js +1 -1
- package/dist/src/dpp/structs/Identifier.js +1 -1
- package/dist/src/dpp/structs/Identity.js +1 -1
- package/dist/src/dpp/structs/IdentityPublicKey.d.ts +1 -0
- package/dist/src/dpp/structs/IdentityPublicKey.js +6 -1
- package/dist/src/dpp/structs/IdentityPublicKeyInCreation.d.ts +1 -0
- package/dist/src/dpp/structs/IdentityPublicKeyInCreation.js +6 -1
- package/dist/src/dpp/structs/IdentityTransitions/IdentityCreateTransition.js +1 -1
- package/dist/src/dpp/structs/IdentityTransitions/IdentityCreditTransfer.js +1 -1
- package/dist/src/dpp/structs/IdentityTransitions/IdentityCreditWithdrawalTransition.js +1 -1
- package/dist/src/dpp/structs/IdentityTransitions/IdentityTopUpTransition.js +1 -1
- package/dist/src/dpp/structs/IdentityTransitions/IdentityUpdateTransition.js +1 -1
- package/dist/src/dpp/structs/InstantLock.js +1 -1
- package/dist/src/dpp/structs/MasternodeVote/MasternodeVoteTransition.d.ts +0 -2
- package/dist/src/dpp/structs/MasternodeVote/MasternodeVoteTransition.js +1 -7
- package/dist/src/dpp/structs/MasternodeVote/Vote.js +1 -1
- package/dist/src/dpp/structs/MasternodeVote/VotePoll.d.ts +1 -1
- package/dist/src/dpp/structs/MasternodeVote/VotePoll.js +3 -3
- 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/IdentityCreateFromShieldedPoolResult.d.ts +21 -0
- package/dist/src/dpp/structs/Orchard/IdentityCreateFromShieldedPoolResult.js +38 -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 +15 -0
- package/dist/src/dpp/structs/Orchard/OrchardAddress.js +31 -0
- package/dist/src/dpp/structs/Orchard/OrchardProver.d.ts +12 -0
- package/dist/src/dpp/structs/Orchard/OrchardProver.js +18 -0
- package/dist/src/dpp/structs/Orchard/RecoveredNote.d.ts +18 -0
- package/dist/src/dpp/structs/Orchard/RecoveredNote.js +29 -0
- package/dist/src/dpp/structs/Orchard/ShieldedBuilder.d.ts +40 -0
- package/dist/src/dpp/structs/Orchard/ShieldedBuilder.js +45 -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/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/PartialIdentity.js +1 -1
- package/dist/src/dpp/structs/{Address → PlatformAddress}/AddressWitness.d.ts +2 -2
- package/dist/src/dpp/structs/{Address → PlatformAddress}/AddressWitness.js +2 -2
- package/dist/src/dpp/structs/{Address → PlatformAddress}/PlatformAddress.d.ts +4 -2
- package/dist/src/dpp/structs/{Address → PlatformAddress}/PlatformAddress.js +9 -3
- package/dist/src/dpp/structs/PrivateKey.js +1 -1
- package/dist/src/dpp/structs/PublicKey.js +1 -1
- package/dist/src/dpp/structs/ShieldedTransitions/IdentityCreateFromShieldedPoolTransition.d.ts +31 -0
- package/dist/src/dpp/structs/ShieldedTransitions/IdentityCreateFromShieldedPoolTransition.js +73 -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 +30 -0
- package/dist/src/dpp/structs/ShieldedTransitions/ShieldFromAssetLockTransition.js +77 -0
- package/dist/src/dpp/structs/ShieldedTransitions/ShieldTransition.d.ts +32 -0
- package/dist/src/dpp/structs/ShieldedTransitions/ShieldTransition.js +78 -0
- package/dist/src/dpp/structs/ShieldedTransitions/ShieldedTransferTransition.d.ts +21 -0
- package/dist/src/dpp/structs/ShieldedTransitions/ShieldedTransferTransition.js +51 -0
- package/dist/src/dpp/structs/ShieldedTransitions/ShieldedWithdrawalTransition.d.ts +29 -0
- package/dist/src/dpp/structs/ShieldedTransitions/ShieldedWithdrawalTransition.js +71 -0
- package/dist/src/dpp/structs/ShieldedTransitions/UnshieldTransition.d.ts +25 -0
- package/dist/src/dpp/structs/ShieldedTransitions/UnshieldTransition.js +59 -0
- package/dist/src/dpp/structs/StateTransition.d.ts +1 -0
- package/dist/src/dpp/structs/StateTransition.js +3 -0
- package/dist/src/dpp/structs/TokenConfiguration/ActionTaker.js +1 -1
- package/dist/src/dpp/structs/TokenConfiguration/ChangeControlRules.js +1 -1
- package/dist/src/dpp/structs/TokenConfiguration/Group.js +1 -1
- package/dist/src/dpp/structs/TokenConfiguration/TokenConfiguration.js +1 -1
- package/dist/src/dpp/structs/TokenConfiguration/TokenConfigurationConvention.js +1 -1
- package/dist/src/dpp/structs/TokenConfiguration/TokenConfigurationLocalization.js +1 -1
- package/dist/src/dpp/structs/TokenConfiguration/TokenDistributionRules.js +1 -1
- package/dist/src/dpp/structs/TokenConfiguration/TokenKeepsHistoryRules.js +1 -1
- package/dist/src/dpp/structs/TokenConfiguration/TokenMarketplaceRules.js +1 -1
- package/dist/src/dpp/structs/TokenConfiguration/TokenPerpetualDistribution.js +1 -1
- package/dist/src/dpp/structs/TokenConfiguration/TokenPreProgrammedDistribution.js +1 -1
- package/dist/src/dpp/types.d.ts +85 -11
- package/dist/src/dpp/utils.d.ts +4 -3
- package/dist/src/dpp/utils.js +24 -6
- 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/PlatformAddress/verifyPlatformAddressInfo.d.ts +2 -0
- package/dist/src/dpp/verify/PlatformAddress/verifyPlatformAddressInfo.js +12 -0
- package/dist/src/dpp/verify/PlatformAddress/verifyPlatformAddressesInfos.d.ts +2 -0
- package/dist/src/dpp/verify/PlatformAddress/verifyPlatformAddressesInfos.js +14 -0
- 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 +80 -15
- package/dist/src/dpp/verify/System/verifyEpochsInfoProof.js +1 -1
- package/dist/src/dpp/verify/Tokens/verifyTokenBalancesForIdentitiesProof.js +1 -1
- package/dist/src/dpp/verify/Tokens/verifyTokensBalancesForIdentityProof.js +1 -1
- 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 +18 -28
- package/tests/unit/DataContract.spec.ts +281 -0
- package/tests/unit/DynamicValue.spec.ts +42 -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 +344 -0
- package/tests/unit/ShieldedTransitions.spec.ts +709 -0
- package/tests/unit/TokenConfiguration.spec.ts +114 -0
- package/tests/unit/WebAssembly.spec.ts +49 -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,114 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AuthorizedActionTakersWASM,
|
|
3
|
+
IdentifierWASM,
|
|
4
|
+
TokenConfigurationWASM
|
|
5
|
+
} from 'pshenmic-dpp'
|
|
6
|
+
import { buildTokenConfiguration } from './utils/buildTokenConfiguration'
|
|
7
|
+
|
|
8
|
+
describe('TokenConfiguration', function () {
|
|
9
|
+
describe('constructor', function () {
|
|
10
|
+
test('should build a token configuration with defaults from the helper', function () {
|
|
11
|
+
const config = buildTokenConfiguration()
|
|
12
|
+
|
|
13
|
+
expect(config).toBeInstanceOf(TokenConfigurationWASM)
|
|
14
|
+
expect(config.baseSupply).toEqual(BigInt(100000))
|
|
15
|
+
expect(config.maxSupply).toBeUndefined()
|
|
16
|
+
expect(config.description).toBeUndefined()
|
|
17
|
+
expect(config.startAsPaused).toEqual(false)
|
|
18
|
+
expect(config.isAllowedTransferToFrozenBalance).toEqual(false)
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
test('should set max supply and description when provided', function () {
|
|
22
|
+
const config = buildTokenConfiguration({
|
|
23
|
+
baseSupply: BigInt(500),
|
|
24
|
+
maxSupply: BigInt(1000),
|
|
25
|
+
description: 'hello'
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
expect(config.baseSupply).toEqual(BigInt(500))
|
|
29
|
+
expect(config.maxSupply).toEqual(BigInt(1000))
|
|
30
|
+
expect(config.description).toEqual('hello')
|
|
31
|
+
})
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
describe('getters', function () {
|
|
35
|
+
test('should expose the convention decimals', function () {
|
|
36
|
+
const config = buildTokenConfiguration()
|
|
37
|
+
|
|
38
|
+
expect(config.conventions.decimals).toEqual(8)
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
test('should default mainControlGroup to undefined', function () {
|
|
42
|
+
const config = buildTokenConfiguration()
|
|
43
|
+
|
|
44
|
+
expect(config.mainControlGroup).toBeUndefined()
|
|
45
|
+
})
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
describe('setters', function () {
|
|
49
|
+
test('should allow updating baseSupply', function () {
|
|
50
|
+
const config = buildTokenConfiguration()
|
|
51
|
+
|
|
52
|
+
config.baseSupply = BigInt(7)
|
|
53
|
+
|
|
54
|
+
expect(config.baseSupply).toEqual(BigInt(7))
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
test('should allow updating maxSupply to a value and back to undefined', function () {
|
|
58
|
+
const config = buildTokenConfiguration()
|
|
59
|
+
|
|
60
|
+
config.maxSupply = BigInt(42)
|
|
61
|
+
expect(config.maxSupply).toEqual(BigInt(42))
|
|
62
|
+
|
|
63
|
+
config.maxSupply = undefined
|
|
64
|
+
expect(config.maxSupply).toBeUndefined()
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
test('should allow updating description', function () {
|
|
68
|
+
const config = buildTokenConfiguration()
|
|
69
|
+
|
|
70
|
+
config.description = 'updated'
|
|
71
|
+
|
|
72
|
+
expect(config.description).toEqual('updated')
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
test('should allow updating startAsPaused / isAllowedTransferToFrozenBalance', function () {
|
|
76
|
+
const config = buildTokenConfiguration()
|
|
77
|
+
|
|
78
|
+
config.startAsPaused = true
|
|
79
|
+
config.isAllowedTransferToFrozenBalance = true
|
|
80
|
+
|
|
81
|
+
expect(config.startAsPaused).toEqual(true)
|
|
82
|
+
expect(config.isAllowedTransferToFrozenBalance).toEqual(true)
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
test('should allow updating mainControlGroup', function () {
|
|
86
|
+
const config = buildTokenConfiguration()
|
|
87
|
+
|
|
88
|
+
config.mainControlGroup = 3
|
|
89
|
+
|
|
90
|
+
expect(config.mainControlGroup).toEqual(3)
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
test('should allow updating mainControlGroupCanBeModified', function () {
|
|
94
|
+
const config = buildTokenConfiguration()
|
|
95
|
+
|
|
96
|
+
config.mainControlGroupCanBeModified = AuthorizedActionTakersWASM.ContractOwner()
|
|
97
|
+
|
|
98
|
+
expect(config.mainControlGroupCanBeModified).toBeDefined()
|
|
99
|
+
})
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
describe('calculateTokenId', function () {
|
|
103
|
+
test('should derive a deterministic token id from a contract id and position', function () {
|
|
104
|
+
const contractId = new IdentifierWASM('HEAmUtC72dPcZ59yyLUgfS8pfrEWqzYfDPzTofgWxXRr')
|
|
105
|
+
|
|
106
|
+
const tokenIdA = TokenConfigurationWASM.calculateTokenId(contractId, 0)
|
|
107
|
+
const tokenIdB = TokenConfigurationWASM.calculateTokenId(contractId, 0)
|
|
108
|
+
const tokenIdC = TokenConfigurationWASM.calculateTokenId(contractId, 1)
|
|
109
|
+
|
|
110
|
+
expect(tokenIdA.base58()).toEqual(tokenIdB.base58())
|
|
111
|
+
expect(tokenIdA.base58()).not.toEqual(tokenIdC.base58())
|
|
112
|
+
})
|
|
113
|
+
})
|
|
114
|
+
})
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as dpp from "pshenmic-dpp/wasm";
|
|
2
|
+
import {IdentifierWASM} from "pshenmic-dpp/wasm";
|
|
3
|
+
|
|
4
|
+
let identifierBytes: Uint8Array;
|
|
5
|
+
|
|
6
|
+
describe("dpp", function () {
|
|
7
|
+
beforeAll(async function () {
|
|
8
|
+
identifierBytes = Uint8Array.from([
|
|
9
|
+
9, 40, 40, 237, 192, 129, 211, 186, 26, 84, 240, 67, 37, 155, 148, 19,
|
|
10
|
+
104, 242, 199, 24, 136, 27, 6, 169, 211, 71, 136, 59, 33, 191, 227, 19,
|
|
11
|
+
]);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('dpp object shouldn\'t be undefined or empty', () => {
|
|
15
|
+
expect(dpp).toBeDefined();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
describe('classes accesibles', function () {
|
|
19
|
+
test("should allows to create Identifier from base58 via dpp object", function () {
|
|
20
|
+
const identifier = dpp.IdentifierWASM.fromBase58(
|
|
21
|
+
"ckBqfQe7LU7vwrwXopyCB4n5phZShjA16BGhNGpsD5U",
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
expect(identifier.bytes()).toEqual(identifierBytes);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("should allows to create Identifier from base64 via IdentifierWASM import", function () {
|
|
28
|
+
const identifier = IdentifierWASM.fromBase64(
|
|
29
|
+
"CSgo7cCB07oaVPBDJZuUE2jyxxiIGwap00eIOyG/4xM=",
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
expect(identifier.bytes()).toEqual(identifierBytes);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test("should allows to create Identifier from hex", function () {
|
|
36
|
+
const identifier = IdentifierWASM.fromHex(
|
|
37
|
+
"092828edc081d3ba1a54f043259b941368f2c718881b06a9d347883b21bfe313",
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
expect(identifier.bytes()).toEqual(identifierBytes);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test("should allows to create Identifier from bytes", function () {
|
|
44
|
+
const identifier = IdentifierWASM.fromBytes(identifierBytes);
|
|
45
|
+
|
|
46
|
+
expect(identifier.bytes()).toEqual(identifierBytes);
|
|
47
|
+
});
|
|
48
|
+
})
|
|
49
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AuthorizedActionTakersWASM,
|
|
3
|
+
ChangeControlRulesWASM,
|
|
4
|
+
TokenConfigurationConventionWASM,
|
|
5
|
+
TokenConfigurationWASM,
|
|
6
|
+
TokenDistributionRulesWASM,
|
|
7
|
+
TokenKeepsHistoryRulesWASM,
|
|
8
|
+
TokenMarketplaceRulesWASM,
|
|
9
|
+
TokenTradeModeWASM
|
|
10
|
+
} from 'pshenmic-dpp'
|
|
11
|
+
|
|
12
|
+
export function buildChangeControlRules (): ChangeControlRulesWASM {
|
|
13
|
+
return new ChangeControlRulesWASM(
|
|
14
|
+
AuthorizedActionTakersWASM.NoOne(),
|
|
15
|
+
AuthorizedActionTakersWASM.NoOne(),
|
|
16
|
+
false,
|
|
17
|
+
false,
|
|
18
|
+
false
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function buildTokenConfiguration (
|
|
23
|
+
overrides: { baseSupply?: bigint, maxSupply?: bigint, description?: string } = {}
|
|
24
|
+
): TokenConfigurationWASM {
|
|
25
|
+
const conventions = new TokenConfigurationConventionWASM({}, 8)
|
|
26
|
+
|
|
27
|
+
const keepsHistory = new TokenKeepsHistoryRulesWASM(false, false, false, false, false, false)
|
|
28
|
+
|
|
29
|
+
const distributionRules = new TokenDistributionRulesWASM(
|
|
30
|
+
buildChangeControlRules(),
|
|
31
|
+
buildChangeControlRules(),
|
|
32
|
+
false,
|
|
33
|
+
buildChangeControlRules(),
|
|
34
|
+
buildChangeControlRules(),
|
|
35
|
+
undefined,
|
|
36
|
+
undefined,
|
|
37
|
+
undefined
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
const marketplaceRules = new TokenMarketplaceRulesWASM(
|
|
41
|
+
TokenTradeModeWASM.NotTradeable(),
|
|
42
|
+
buildChangeControlRules()
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
return new TokenConfigurationWASM(
|
|
46
|
+
conventions,
|
|
47
|
+
buildChangeControlRules(),
|
|
48
|
+
overrides.baseSupply ?? BigInt(100000),
|
|
49
|
+
keepsHistory,
|
|
50
|
+
false,
|
|
51
|
+
false,
|
|
52
|
+
buildChangeControlRules(),
|
|
53
|
+
distributionRules,
|
|
54
|
+
marketplaceRules,
|
|
55
|
+
buildChangeControlRules(),
|
|
56
|
+
buildChangeControlRules(),
|
|
57
|
+
buildChangeControlRules(),
|
|
58
|
+
buildChangeControlRules(),
|
|
59
|
+
buildChangeControlRules(),
|
|
60
|
+
buildChangeControlRules(),
|
|
61
|
+
AuthorizedActionTakersWASM.NoOne(),
|
|
62
|
+
overrides.maxSupply,
|
|
63
|
+
undefined,
|
|
64
|
+
overrides.description
|
|
65
|
+
)
|
|
66
|
+
}
|
|
Binary file
|