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,281 @@
|
|
|
1
|
+
import {AuthorizedActionTakersWASM, ChangeControlRulesWASM, DataContractWASM,
|
|
2
|
+
DistributionFunctionWASM, IdentifierWASM, PlatformVersionWASM,
|
|
3
|
+
RewardDistributionTypeWASM, TokenConfigurationConventionWASM, TokenConfigurationLocalizationWASM,
|
|
4
|
+
TokenConfigurationWASM,
|
|
5
|
+
TokenDistributionRecipientWASM, TokenDistributionRulesWASM, TokenKeepsHistoryRulesWASM,
|
|
6
|
+
TokenMarketplaceRulesWASM, TokenPerpetualDistributionWASM,
|
|
7
|
+
TokenTradeModeWASM} from 'pshenmic-dpp'
|
|
8
|
+
import {buildTokenConfiguration} from './utils/buildTokenConfiguration.js'
|
|
9
|
+
|
|
10
|
+
const OWNER_ID_BASE58 = 'HEAmUtC72dPcZ59yyLUgfS8pfrEWqzYfDPzTofgWxXRr'
|
|
11
|
+
|
|
12
|
+
const DOCUMENT_SCHEMA = {
|
|
13
|
+
note: {
|
|
14
|
+
type: 'object',
|
|
15
|
+
properties: {
|
|
16
|
+
message: {
|
|
17
|
+
type: 'string',
|
|
18
|
+
position: 0
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
additionalProperties: false
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
describe('DataContract', function () {
|
|
26
|
+
describe('constructor', function () {
|
|
27
|
+
test('should create a contract with document schemas only', function () {
|
|
28
|
+
const contract = new DataContractWASM(
|
|
29
|
+
OWNER_ID_BASE58,
|
|
30
|
+
BigInt(1),
|
|
31
|
+
DOCUMENT_SCHEMA,
|
|
32
|
+
undefined,
|
|
33
|
+
undefined,
|
|
34
|
+
true,
|
|
35
|
+
PlatformVersionWASM.PLATFORM_V10
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
expect(contract).toBeInstanceOf(DataContractWASM)
|
|
39
|
+
expect(contract.ownerId.base58()).toEqual(OWNER_ID_BASE58)
|
|
40
|
+
expect(contract.tokens.length).toEqual(0)
|
|
41
|
+
expect(Object.keys(contract.getSchemas())).toEqual(['note'])
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
test('should create a tokens-only contract (no document schemas)', function () {
|
|
45
|
+
const tokenConfig = buildTokenConfiguration()
|
|
46
|
+
|
|
47
|
+
const contract = new DataContractWASM(
|
|
48
|
+
OWNER_ID_BASE58,
|
|
49
|
+
BigInt(1),
|
|
50
|
+
{},
|
|
51
|
+
undefined,
|
|
52
|
+
[{position: 0, tokenConfiguration: tokenConfig}],
|
|
53
|
+
true,
|
|
54
|
+
PlatformVersionWASM.PLATFORM_V10
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
expect(contract).toBeInstanceOf(DataContractWASM)
|
|
58
|
+
expect(contract.tokens.length).toEqual(1)
|
|
59
|
+
expect(contract.tokens[0].position).toEqual(0)
|
|
60
|
+
expect(contract.tokens[0].tokenConfiguration.baseSupply).toEqual(BigInt(100000))
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
test('should fail to create a contract with neither documents nor tokens', function () {
|
|
64
|
+
expect(() => new DataContractWASM(
|
|
65
|
+
OWNER_ID_BASE58,
|
|
66
|
+
BigInt(1),
|
|
67
|
+
{},
|
|
68
|
+
undefined,
|
|
69
|
+
undefined,
|
|
70
|
+
true,
|
|
71
|
+
PlatformVersionWASM.PLATFORM_V10
|
|
72
|
+
)).toThrow()
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
test('should create a contract with both documents and tokens', function () {
|
|
76
|
+
const tokenConfig = buildTokenConfiguration({baseSupply: BigInt(50)})
|
|
77
|
+
|
|
78
|
+
const contract = new DataContractWASM(
|
|
79
|
+
OWNER_ID_BASE58,
|
|
80
|
+
BigInt(1),
|
|
81
|
+
DOCUMENT_SCHEMA,
|
|
82
|
+
undefined,
|
|
83
|
+
[{position: 0, tokenConfiguration: tokenConfig}],
|
|
84
|
+
true,
|
|
85
|
+
PlatformVersionWASM.PLATFORM_V10
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
expect(contract.tokens.length).toEqual(1)
|
|
89
|
+
expect(Object.keys(contract.getSchemas())).toEqual(['note'])
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
test('should generate a deterministic id from owner id and nonce', function () {
|
|
93
|
+
const contract = new DataContractWASM(
|
|
94
|
+
OWNER_ID_BASE58,
|
|
95
|
+
BigInt(42),
|
|
96
|
+
DOCUMENT_SCHEMA,
|
|
97
|
+
undefined,
|
|
98
|
+
undefined,
|
|
99
|
+
true,
|
|
100
|
+
PlatformVersionWASM.PLATFORM_V10
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
const expectedId = DataContractWASM.generateId(OWNER_ID_BASE58, BigInt(42))
|
|
104
|
+
|
|
105
|
+
expect(contract.id.base58()).toEqual(expectedId.base58())
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
describe('serialization', function () {
|
|
110
|
+
test('should serialize / deserialize via bytes', function () {
|
|
111
|
+
const contract = new DataContractWASM(
|
|
112
|
+
OWNER_ID_BASE58,
|
|
113
|
+
BigInt(1),
|
|
114
|
+
DOCUMENT_SCHEMA,
|
|
115
|
+
undefined,
|
|
116
|
+
undefined,
|
|
117
|
+
true,
|
|
118
|
+
PlatformVersionWASM.PLATFORM_V10
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
const bytes = contract.bytes(PlatformVersionWASM.PLATFORM_V10)
|
|
122
|
+
const restored = DataContractWASM.fromBytes(bytes, true, PlatformVersionWASM.PLATFORM_V10)
|
|
123
|
+
|
|
124
|
+
expect(restored.id.base58()).toEqual(contract.id.base58())
|
|
125
|
+
expect(restored.ownerId.base58()).toEqual(contract.ownerId.base58())
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
test('should serialize / deserialize a tokens-only contract via bytes', function () {
|
|
129
|
+
const tokenConfig = buildTokenConfiguration()
|
|
130
|
+
|
|
131
|
+
const contract = new DataContractWASM(
|
|
132
|
+
OWNER_ID_BASE58,
|
|
133
|
+
BigInt(1),
|
|
134
|
+
{},
|
|
135
|
+
undefined,
|
|
136
|
+
[{position: 0, tokenConfiguration: tokenConfig}],
|
|
137
|
+
true,
|
|
138
|
+
PlatformVersionWASM.PLATFORM_V10
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
const bytes = contract.bytes(PlatformVersionWASM.PLATFORM_V10)
|
|
142
|
+
const restored = DataContractWASM.fromBytes(bytes, true, PlatformVersionWASM.PLATFORM_V10)
|
|
143
|
+
|
|
144
|
+
expect(restored.tokens.length).toEqual(1)
|
|
145
|
+
expect(restored.tokens[0].tokenConfiguration.baseSupply).toEqual(tokenConfig.baseSupply)
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
test('should round-trip via hex', function () {
|
|
149
|
+
const contract = new DataContractWASM(
|
|
150
|
+
OWNER_ID_BASE58,
|
|
151
|
+
BigInt(1),
|
|
152
|
+
DOCUMENT_SCHEMA,
|
|
153
|
+
undefined,
|
|
154
|
+
undefined,
|
|
155
|
+
true,
|
|
156
|
+
PlatformVersionWASM.PLATFORM_V10
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
const hex = contract.hex(PlatformVersionWASM.PLATFORM_V10)
|
|
160
|
+
const restored = DataContractWASM.fromHex(hex, true, PlatformVersionWASM.PLATFORM_V10)
|
|
161
|
+
|
|
162
|
+
expect(restored.id.base58()).toEqual(contract.id.base58())
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
test('should round-trip via base64', function () {
|
|
166
|
+
const contract = new DataContractWASM(
|
|
167
|
+
OWNER_ID_BASE58,
|
|
168
|
+
BigInt(1),
|
|
169
|
+
DOCUMENT_SCHEMA,
|
|
170
|
+
undefined,
|
|
171
|
+
undefined,
|
|
172
|
+
true,
|
|
173
|
+
PlatformVersionWASM.PLATFORM_V10
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
const b64 = contract.base64(PlatformVersionWASM.PLATFORM_V10)
|
|
177
|
+
const restored = DataContractWASM.fromBase64(b64, true, PlatformVersionWASM.PLATFORM_V10)
|
|
178
|
+
|
|
179
|
+
expect(restored.id.base58()).toEqual(contract.id.base58())
|
|
180
|
+
})
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
describe('mutators', function () {
|
|
184
|
+
test('should allow setting tokens after construction', function () {
|
|
185
|
+
const contract = new DataContractWASM(
|
|
186
|
+
OWNER_ID_BASE58,
|
|
187
|
+
BigInt(1),
|
|
188
|
+
DOCUMENT_SCHEMA,
|
|
189
|
+
undefined,
|
|
190
|
+
undefined,
|
|
191
|
+
true,
|
|
192
|
+
PlatformVersionWASM.PLATFORM_V10
|
|
193
|
+
)
|
|
194
|
+
|
|
195
|
+
expect(contract.tokens.length).toEqual(0)
|
|
196
|
+
|
|
197
|
+
contract.tokens = [{position: 0, tokenConfiguration: buildTokenConfiguration()}]
|
|
198
|
+
|
|
199
|
+
expect(contract.tokens.length).toEqual(1)
|
|
200
|
+
})
|
|
201
|
+
|
|
202
|
+
test('should allow setting and reading description / keywords', function () {
|
|
203
|
+
const contract = new DataContractWASM(
|
|
204
|
+
OWNER_ID_BASE58,
|
|
205
|
+
BigInt(1),
|
|
206
|
+
DOCUMENT_SCHEMA,
|
|
207
|
+
undefined,
|
|
208
|
+
undefined,
|
|
209
|
+
true,
|
|
210
|
+
PlatformVersionWASM.PLATFORM_V10
|
|
211
|
+
)
|
|
212
|
+
|
|
213
|
+
contract.description = 'test contract'
|
|
214
|
+
contract.keywords = ['alpha', 'beta']
|
|
215
|
+
|
|
216
|
+
expect(contract.description).toEqual('test contract')
|
|
217
|
+
expect(contract.keywords).toEqual(['alpha', 'beta'])
|
|
218
|
+
})
|
|
219
|
+
|
|
220
|
+
test('should allow changing the owner id', function () {
|
|
221
|
+
const contract = new DataContractWASM(
|
|
222
|
+
OWNER_ID_BASE58,
|
|
223
|
+
BigInt(1),
|
|
224
|
+
DOCUMENT_SCHEMA,
|
|
225
|
+
undefined,
|
|
226
|
+
undefined,
|
|
227
|
+
true,
|
|
228
|
+
PlatformVersionWASM.PLATFORM_V10
|
|
229
|
+
)
|
|
230
|
+
|
|
231
|
+
const newOwner = new IdentifierWASM('ckBqfQe7LU7vwrwXopyCB4n5phZShjA16BGhNGpsD5U')
|
|
232
|
+
|
|
233
|
+
contract.ownerId = newOwner
|
|
234
|
+
|
|
235
|
+
expect(contract.ownerId.base58()).toEqual(newOwner.base58())
|
|
236
|
+
})
|
|
237
|
+
})
|
|
238
|
+
|
|
239
|
+
describe('tokens', function () {
|
|
240
|
+
test('should allow setting tokens after construction', function () {
|
|
241
|
+
const owner = '8J8k9aQ5Hotx8oLdnYAhYpyBJJGg4wZALptKLuDE9Df6'
|
|
242
|
+
const taker = () => AuthorizedActionTakersWASM.ContractOwner()
|
|
243
|
+
const rule = () => new ChangeControlRulesWASM(taker(), taker(), false, false, false)
|
|
244
|
+
|
|
245
|
+
const conventions = new TokenConfigurationConventionWASM(
|
|
246
|
+
{en: new TokenConfigurationLocalizationWASM(true, 'Tok', 'Toks')}, 8)
|
|
247
|
+
|
|
248
|
+
const perpetual = new TokenPerpetualDistributionWASM(
|
|
249
|
+
RewardDistributionTypeWASM.EpochBasedDistribution(1, DistributionFunctionWASM.FixedAmountDistribution(1n)),
|
|
250
|
+
TokenDistributionRecipientWASM.Identity(IdentifierWASM.fromBase58(owner))) // <- swap to .ContractOwner() => passes
|
|
251
|
+
|
|
252
|
+
const distributionRules = new TokenDistributionRulesWASM(
|
|
253
|
+
rule(), rule(), true, rule(), rule(), perpetual, undefined, undefined)
|
|
254
|
+
|
|
255
|
+
const tokenConfiguration = new TokenConfigurationWASM(
|
|
256
|
+
conventions, rule(), 100n,
|
|
257
|
+
new TokenKeepsHistoryRulesWASM(true, true, true, true, true, true),
|
|
258
|
+
false, false, rule(), distributionRules,
|
|
259
|
+
new TokenMarketplaceRulesWASM(TokenTradeModeWASM.NotTradeable(), rule()),
|
|
260
|
+
rule(), rule(), rule(), rule(), rule(), rule(),
|
|
261
|
+
taker(), undefined, undefined, undefined)
|
|
262
|
+
|
|
263
|
+
const contract = new DataContractWASM(owner, 1n, {note: {}}, undefined,
|
|
264
|
+
[{position: 0, tokenConfiguration}], true, undefined)
|
|
265
|
+
|
|
266
|
+
expect(contract).toBeInstanceOf(DataContractWASM)
|
|
267
|
+
expect(contract.tokens.length).toEqual(1)
|
|
268
|
+
expect(contract.tokens[0].position).toEqual(0)
|
|
269
|
+
|
|
270
|
+
const perpetualDistribution = contract.tokens[0].tokenConfiguration
|
|
271
|
+
.distributionRules.perpetualDistribution
|
|
272
|
+
|
|
273
|
+
expect(perpetualDistribution).toBeDefined()
|
|
274
|
+
|
|
275
|
+
const recipient = perpetualDistribution!.distributionRecipient
|
|
276
|
+
|
|
277
|
+
expect(recipient.getType()).toEqual(`Identity(${owner})`)
|
|
278
|
+
expect(recipient.getValue()?.base58()).toEqual(owner)
|
|
279
|
+
})
|
|
280
|
+
})
|
|
281
|
+
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as dpp from "
|
|
2
|
-
import {valueFromDynamicValue, valueToDynamicValue} from "
|
|
1
|
+
import * as dpp from "pshenmic-dpp";
|
|
2
|
+
import {valueFromDynamicValue, valueToDynamicValue} from "pshenmic-dpp/wasm/utils"
|
|
3
3
|
|
|
4
4
|
describe('DynamicValue', () => {
|
|
5
5
|
beforeAll(()=>{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {IdentifierWASM, IdentityWASM, PlatformVersionWASM, IdentityPublicKeyWASM} from '
|
|
1
|
+
import {IdentifierWASM, IdentityWASM, PlatformVersionWASM, IdentityPublicKeyWASM} from 'pshenmic-dpp'
|
|
2
2
|
|
|
3
3
|
let identifierBytes: Uint8Array
|
|
4
4
|
let identifier: IdentifierWASM
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as dpp from "pshenmic-dpp/native";
|
|
2
|
+
import {IdentifierWASM} from "pshenmic-dpp/native";
|
|
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
|
+
});
|