pshenmic-dpp 1.0.4 → 1.0.6

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.
Files changed (152) hide show
  1. package/.github/workflows/build.yml +9 -1
  2. package/.github/workflows/publish.yml +9 -1
  3. package/Cargo.lock +222 -76
  4. package/Cargo.toml +28 -19
  5. package/README.md +75 -23
  6. package/babel.config.json +19 -0
  7. package/dist/wasm/index.d.ts +52 -0
  8. package/dist/wasm/pshenmic_dpp.d.ts +962 -0
  9. package/dist/wasm/pshenmic_dpp.js +5565 -966
  10. package/dist/wasm/pshenmic_dpp_bg.js +1 -1
  11. package/dist/wasm/pshenmic_dpp_bg.wasm.d.ts +440 -0
  12. package/docs/AssetLockProof.md +107 -0
  13. package/docs/Building.md +50 -0
  14. package/docs/ChainLockProof.md +63 -0
  15. package/docs/CoreScript.md +17 -0
  16. package/docs/DataContract.md +192 -0
  17. package/docs/DataContractCreateTransition.md +84 -0
  18. package/docs/DataContractUpdateTransition.md +84 -0
  19. package/docs/Document.md +396 -0
  20. package/docs/DocumentBaseTransition.md +111 -0
  21. package/docs/DocumentCreateTransition.md +132 -0
  22. package/docs/DocumentDeleteTransition.md +82 -0
  23. package/docs/DocumentPurchaseTransition.md +109 -0
  24. package/docs/DocumentReplaceTransition.md +112 -0
  25. package/docs/DocumentTransferTransition.md +96 -0
  26. package/docs/DocumentTransition.md +125 -0
  27. package/docs/DocumentUpdatePriceTransition.md +109 -0
  28. package/docs/DocumentsBatch.md +133 -0
  29. package/docs/Enums.md +103 -0
  30. package/docs/Home.md +28 -0
  31. package/docs/Identifier.md +37 -0
  32. package/docs/Identity.md +140 -0
  33. package/docs/IdentityCreateTransition.md +155 -0
  34. package/docs/IdentityCreditTransfer.md +187 -0
  35. package/docs/IdentityCreditWithdrawalTransition.md +244 -0
  36. package/docs/IdentityPublicKey.md +348 -0
  37. package/docs/IdentityPublicKeyInCreation.md +141 -0
  38. package/docs/IdentityTopUpTransition.md +166 -0
  39. package/docs/IdentityUpdateTransition.md +234 -0
  40. package/docs/InstantAssetLockProof.md +117 -0
  41. package/docs/InstantLock.md +100 -0
  42. package/docs/OutPoint.md +80 -0
  43. package/docs/PrefundedVotingBalance.md +48 -0
  44. package/docs/PrivateKey.md +112 -0
  45. package/docs/TxOut.md +93 -0
  46. package/package.json +15 -8
  47. package/packages/asset_lock_proof/Cargo.toml +19 -0
  48. package/packages/asset_lock_proof/src/chain/mod.rs +79 -0
  49. package/packages/asset_lock_proof/src/instant/instant_lock.rs +111 -0
  50. package/packages/asset_lock_proof/src/instant/mod.rs +115 -0
  51. package/packages/asset_lock_proof/src/lib.rs +133 -0
  52. package/packages/asset_lock_proof/src/outpoint/mod.rs +79 -0
  53. package/packages/asset_lock_proof/src/tx_out/mod.rs +80 -0
  54. package/packages/cbor_conversation/Cargo.toml +2 -2
  55. package/packages/core_script/Cargo.toml +13 -0
  56. package/packages/core_script/src/lib.rs +69 -0
  57. package/packages/data_contract/Cargo.toml +4 -3
  58. package/packages/data_contract/src/lib.rs +209 -33
  59. package/packages/data_contract_transitions/Cargo.toml +2 -2
  60. package/packages/data_contract_transitions/src/create/mod.rs +23 -16
  61. package/packages/data_contract_transitions/src/update/mod.rs +21 -12
  62. package/packages/document/Cargo.toml +3 -2
  63. package/packages/document/src/lib.rs +14 -13
  64. package/packages/document/src/methods/mod.rs +373 -2
  65. package/packages/{document_batch → documents_batch}/Cargo.toml +7 -4
  66. package/packages/documents_batch/src/document_base_transition/mod.rs +88 -0
  67. package/packages/documents_batch/src/document_transition/mod.rs +166 -0
  68. package/packages/documents_batch/src/generators.rs +122 -0
  69. package/packages/documents_batch/src/lib.rs +195 -0
  70. package/packages/documents_batch/src/prefunded_voting_balance/mod.rs +45 -0
  71. package/packages/documents_batch/src/transitions/create/mod.rs +126 -0
  72. package/packages/documents_batch/src/transitions/delete/mod.rs +67 -0
  73. package/packages/documents_batch/src/transitions/mod.rs +6 -0
  74. package/packages/documents_batch/src/transitions/purchase/mod.rs +91 -0
  75. package/packages/documents_batch/src/transitions/replace/mod.rs +93 -0
  76. package/packages/documents_batch/src/transitions/transfer/mod.rs +84 -0
  77. package/packages/documents_batch/src/transitions/update_price/mod.rs +75 -0
  78. package/packages/enums/Cargo.toml +4 -4
  79. package/packages/enums/src/batch/batch_enum.rs +75 -10
  80. package/packages/enums/src/keys/key_type.rs +46 -0
  81. package/packages/enums/src/keys/purpose.rs +55 -0
  82. package/packages/enums/src/keys/security_level.rs +46 -0
  83. package/packages/enums/src/lib.rs +3 -0
  84. package/packages/enums/src/lock_types/mod.rs +65 -0
  85. package/packages/enums/src/network/mod.rs +67 -0
  86. package/packages/enums/src/platform/mod.rs +68 -8
  87. package/packages/enums/src/withdrawal/mod.rs +72 -0
  88. package/packages/identifier/Cargo.toml +9 -0
  89. package/packages/identifier/src/lib.rs +105 -0
  90. package/packages/identity/Cargo.toml +5 -5
  91. package/packages/identity/src/lib.rs +31 -25
  92. package/packages/{public_key → identity_public_key}/Cargo.toml +2 -2
  93. package/packages/{public_key → identity_public_key}/src/lib.rs +74 -27
  94. package/packages/identity_transitions/Cargo.toml +8 -4
  95. package/packages/identity_transitions/src/create_transition/mod.rs +102 -37
  96. package/packages/identity_transitions/src/credit_withdrawal_transition/mod.rs +212 -0
  97. package/packages/identity_transitions/src/identity_credit_transfer_transition/mod.rs +169 -0
  98. package/packages/identity_transitions/src/lib.rs +6 -1
  99. package/packages/identity_transitions/src/public_key_in_creation/mod.rs +197 -0
  100. package/packages/identity_transitions/src/top_up_transition/mod.rs +141 -0
  101. package/packages/identity_transitions/src/update_transition/mod.rs +213 -0
  102. package/packages/mock_bls/Cargo.toml +1 -1
  103. package/packages/private_key/Cargo.toml +4 -3
  104. package/packages/private_key/src/lib.rs +44 -6
  105. package/packages/state_transition/Cargo.toml +6 -4
  106. package/packages/state_transition/src/lib.rs +102 -36
  107. package/packages/utils/Cargo.toml +3 -4
  108. package/packages/utils/src/lib.rs +17 -18
  109. package/scripts/build-js.sh +22 -5
  110. package/scripts/build.sh +27 -2
  111. package/src/lib.rs +8 -1
  112. package/tests/AssetLockProof.spec.js +80 -0
  113. package/tests/ChainLockProof.spec.js +69 -0
  114. package/tests/CoreScript.spec.js +37 -0
  115. package/tests/DataContract.spec.js +178 -0
  116. package/tests/DataContractCreateStateTransition.spec.js +109 -0
  117. package/tests/DataContractUpdateStateTransition.spec.js +109 -0
  118. package/tests/Document.spec.js +238 -0
  119. package/tests/DocumentBatchTransition.spec.js +109 -0
  120. package/tests/DocumentTransition.spec.js +97 -0
  121. package/tests/DocumentsTransitions.spec.js +705 -0
  122. package/tests/Identifier.spec.js +84 -0
  123. package/tests/Identity.spec.js +113 -0
  124. package/tests/IdentityCreateTransition.spec.js +93 -0
  125. package/tests/IdentityCreditTransferTransition.spec.js +146 -0
  126. package/tests/IdentityCreditWithdrawalTransition.spec.js +192 -0
  127. package/tests/IdentityPublicKey.spec.js +132 -0
  128. package/tests/IdentityTopUpTransition.spec.js +131 -0
  129. package/tests/IdentityUpdateTransition.spec.js +147 -0
  130. package/tests/InstantLockProof.spec.js +97 -0
  131. package/tests/OutPoint.spec.js +55 -0
  132. package/tests/PrivateKey.spec.js +73 -0
  133. package/tests/PublicKeyInCreation.spec.js +258 -0
  134. package/tests/TxOut.spec.js +76 -0
  135. package/tests/mocks/DataContract/DataContract.json +153 -0
  136. package/tests/mocks/DataContract/index.js +6 -0
  137. package/tests/mocks/Document/DataContract.json +23 -0
  138. package/tests/mocks/Document/document.json +3 -0
  139. package/tests/mocks/Document/document2.json +3 -0
  140. package/tests/mocks/Document/index.js +11 -0
  141. package/tests/mocks/Identity/index.js +7 -0
  142. package/tests/mocks/Locks/index.js +5 -0
  143. package/tests/mocks/PrivateKey/index.js +5 -0
  144. package/tests/mocks/PublicKey/index.js +14 -0
  145. package/tests/utils/hex.js +15 -0
  146. package/tests/utils/wasm.js +14 -0
  147. package/typings/index.d.ts +52 -0
  148. package/packages/document/src/methods/js.rs +0 -260
  149. package/packages/document/src/methods/rust.rs +0 -92
  150. package/packages/document_batch/src/generators.rs +0 -63
  151. package/packages/document_batch/src/lib.rs +0 -228
  152. package/packages/identity_transitions/src/create_transition/public_key_in_creation/mod.rs +0 -146
@@ -0,0 +1,84 @@
1
+ const assert = require('assert')
2
+ const { describe, it, before } = require('mocha')
3
+ const initWasm = require('./utils/wasm')
4
+
5
+ let wasm
6
+ let identifierBytes
7
+
8
+ describe('Identifier', function () {
9
+ before(async function () {
10
+ identifierBytes = Uint8Array.from([9, 40, 40, 237, 192, 129, 211, 186, 26, 84, 240, 67, 37, 155, 148, 19, 104, 242, 199, 24, 136, 27, 6, 169, 211, 71, 136, 59, 33, 191, 227, 19])
11
+ wasm = initWasm()
12
+ })
13
+
14
+ describe('serialization / deserialization', function () {
15
+ it('should allows to create Identifier from base58', function () {
16
+ const identifier = wasm.IdentifierWASM.fromBase58('ckBqfQe7LU7vwrwXopyCB4n5phZShjA16BGhNGpsD5U')
17
+
18
+ assert.deepEqual(identifier.bytes(), identifierBytes)
19
+ })
20
+
21
+ it('should allows to create Identifier from base64', function () {
22
+ const identifier = wasm.IdentifierWASM.fromBase64('CSgo7cCB07oaVPBDJZuUE2jyxxiIGwap00eIOyG/4xM=')
23
+
24
+ assert.deepEqual(identifier.bytes(), identifierBytes)
25
+ })
26
+
27
+ it('should allows to create Identifier from hex', function () {
28
+ const identifier = wasm.IdentifierWASM.fromHex('092828edc081d3ba1a54f043259b941368f2c718881b06a9d347883b21bfe313')
29
+
30
+ assert.deepEqual(identifier.bytes(), identifierBytes)
31
+ })
32
+
33
+ it('should allows to create Identifier from bytes', function () {
34
+ const identifier = wasm.IdentifierWASM.fromBytes(identifierBytes)
35
+
36
+ assert.deepEqual(identifier.bytes(), identifierBytes)
37
+ })
38
+
39
+ it('should allows to create Identifier from Identifier', function () {
40
+ const identifier = wasm.IdentifierWASM.fromBytes(identifierBytes)
41
+ const identifier2 = new wasm.IdentifierWASM(identifier)
42
+
43
+ assert.deepEqual(identifier2.bytes(), identifierBytes)
44
+ })
45
+
46
+ it('should allows to create Identifier from bytes in constructor', function () {
47
+ const identifier = new wasm.IdentifierWASM(identifierBytes)
48
+
49
+ assert.deepEqual(identifier.bytes(), identifierBytes)
50
+ })
51
+
52
+ it('should allows to create Identifier from base58 in constructor', function () {
53
+ const identifier = new wasm.IdentifierWASM('ckBqfQe7LU7vwrwXopyCB4n5phZShjA16BGhNGpsD5U')
54
+
55
+ assert.deepEqual(identifier.bytes(), identifierBytes)
56
+ })
57
+ })
58
+
59
+ describe('getters', function () {
60
+ it('should allow to get identifier base58', function () {
61
+ const identifier = wasm.IdentifierWASM.fromBase58('ckBqfQe7LU7vwrwXopyCB4n5phZShjA16BGhNGpsD5U')
62
+
63
+ assert.equal(identifier.base58(), 'ckBqfQe7LU7vwrwXopyCB4n5phZShjA16BGhNGpsD5U')
64
+ })
65
+
66
+ it('should allow to get identifier base64', function () {
67
+ const identifier = wasm.IdentifierWASM.fromBase58('ckBqfQe7LU7vwrwXopyCB4n5phZShjA16BGhNGpsD5U')
68
+
69
+ assert.equal(identifier.base64(), 'CSgo7cCB07oaVPBDJZuUE2jyxxiIGwap00eIOyG/4xM=')
70
+ })
71
+
72
+ it('should allow to get identifier hex', function () {
73
+ const identifier = wasm.IdentifierWASM.fromBase58('ckBqfQe7LU7vwrwXopyCB4n5phZShjA16BGhNGpsD5U')
74
+
75
+ assert.equal(identifier.hex(), '092828edc081d3ba1a54f043259b941368f2c718881b06a9d347883b21bfe313')
76
+ })
77
+
78
+ it('should allow to get identifier bytes', function () {
79
+ const identifier = wasm.IdentifierWASM.fromBase58('ckBqfQe7LU7vwrwXopyCB4n5phZShjA16BGhNGpsD5U')
80
+
81
+ assert.deepEqual(identifier.bytes(), identifierBytes)
82
+ })
83
+ })
84
+ })
@@ -0,0 +1,113 @@
1
+ const assert = require('assert')
2
+ const { describe, it, before } = require('mocha')
3
+ const initWasm = require('./utils/wasm')
4
+ const { identifier, identityBytesWithoutKeys, identifierBytes, balance, revision } = require('./mocks/Identity')
5
+ const { keyId, purpose, securityLevel, keyType, binaryData } = require('./mocks/PublicKey')
6
+
7
+ let wasm
8
+
9
+ describe('Identity', function () {
10
+ before(async function () {
11
+ wasm = initWasm()
12
+ })
13
+
14
+ describe('serialization / deserialization', function () {
15
+ it('should generate identity from identifier', async function () {
16
+ const identity = new wasm.IdentityWASM(identifier)
17
+
18
+ assert.notEqual(identity.__wbg_ptr, 0)
19
+ })
20
+
21
+ it('should generate identity from identifier and return bytes', async function () {
22
+ const identity = new wasm.IdentityWASM(identifier)
23
+
24
+ assert.deepEqual(Array.from(identity.toBytes()), identityBytesWithoutKeys)
25
+
26
+ const newIdentity = wasm.IdentityWASM.fromBytes(identity.toBytes())
27
+
28
+ assert.notEqual(identity.__wbg_ptr, 0)
29
+ assert.notEqual(newIdentity.__wbg_ptr, 0)
30
+ })
31
+ })
32
+
33
+ describe('getters', function () {
34
+ it('should get id buffer', function () {
35
+ const identity = new wasm.IdentityWASM(identifier)
36
+
37
+ assert.deepEqual(identity.getId().bytes(), Uint8Array.from(identifierBytes))
38
+ })
39
+
40
+ it('should get balance', function () {
41
+ const identity = new wasm.IdentityWASM(identifier)
42
+
43
+ assert.deepEqual(identity.getBalance(), BigInt(0))
44
+ })
45
+
46
+ it('should get revision', function () {
47
+ const identity = new wasm.IdentityWASM(identifier)
48
+
49
+ assert.deepEqual(identity.getRevision(), BigInt(0))
50
+ })
51
+
52
+ it('should get public keys', function () {
53
+ const identity = new wasm.IdentityWASM(identifier)
54
+
55
+ const pubKey = new wasm.IdentityPublicKeyWASM(
56
+ keyId,
57
+ purpose,
58
+ securityLevel,
59
+ keyType,
60
+ false,
61
+ binaryData)
62
+
63
+ const pubKey2 = new wasm.IdentityPublicKeyWASM(
64
+ keyId + 1,
65
+ purpose,
66
+ securityLevel,
67
+ keyType,
68
+ false,
69
+ binaryData)
70
+
71
+ identity.addPublicKey(pubKey)
72
+ identity.addPublicKey(pubKey2)
73
+
74
+ assert.equal(identity.getPublicKeys().length, 2)
75
+ })
76
+ })
77
+
78
+ describe('setters', function () {
79
+ it('should allows to set public key', function () {
80
+ const pubKey = new wasm.IdentityPublicKeyWASM(
81
+ keyId,
82
+ purpose,
83
+ securityLevel,
84
+ keyType,
85
+ false,
86
+ binaryData)
87
+
88
+ const identity = new wasm.IdentityWASM(identifier)
89
+
90
+ identity.addPublicKey(pubKey)
91
+
92
+ assert.notEqual(identity.__wbg_ptr, 0)
93
+
94
+ assert.deepEqual(identity.getPublicKeyById(keyId).toBytes(), pubKey.toBytes())
95
+ })
96
+
97
+ it('should allows to set balance', function () {
98
+ const identity = new wasm.IdentityWASM(identifier)
99
+
100
+ identity.setBalance(balance)
101
+
102
+ assert.equal(identity.getBalance(), balance)
103
+ })
104
+
105
+ it('should allows to set revision', function () {
106
+ const identity = new wasm.IdentityWASM(identifier)
107
+
108
+ identity.setRevision(revision)
109
+
110
+ assert.equal(identity.getRevision(), revision)
111
+ })
112
+ })
113
+ })
@@ -0,0 +1,93 @@
1
+ const assert = require('assert')
2
+ const { describe, it, before } = require('mocha')
3
+ const initWasm = require('./utils/wasm')
4
+
5
+ let wasm
6
+
7
+ describe('IdentityCreateTransition', function () {
8
+ before(async function () {
9
+ wasm = initWasm()
10
+ })
11
+
12
+ describe('serialization / deserialization', function () {
13
+ it('should allow to create transition', function () {
14
+ const transition = wasm.IdentityCreateTransitionWASM.default(0)
15
+
16
+ assert.notEqual(transition.__wbg_ptr, 0)
17
+ })
18
+
19
+ it('should allow to serialize to bytes', function () {
20
+ const transition = wasm.IdentityCreateTransitionWASM.default(0)
21
+
22
+ const bytes = transition.toBytes()
23
+
24
+ assert.equal(bytes.length > 0, true)
25
+ })
26
+
27
+ it('should allow to deserialize to bytes', function () {
28
+ const bytes = [0, 0, 0, 162, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 60, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 1, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
29
+
30
+ const transition = wasm.IdentityCreateTransitionWASM.fromBytes(bytes)
31
+
32
+ assert.notEqual(transition.__wbg_ptr, 0)
33
+ })
34
+ })
35
+
36
+ describe('getters', function () {
37
+ it('should allow to get userFeeIncrease', function () {
38
+ const transition = wasm.IdentityCreateTransitionWASM.default(0)
39
+
40
+ assert.equal(transition.userFeeIncrease, 0)
41
+ })
42
+
43
+ it('should allow to get AssetLock', function () {
44
+ const transition = wasm.IdentityCreateTransitionWASM.default(0)
45
+
46
+ assert.notEqual(transition.assetLock.__wbg_ptr, 0)
47
+ })
48
+
49
+ it('should allow to get Identifier', function () {
50
+ const transition = wasm.IdentityCreateTransitionWASM.default(0)
51
+
52
+ assert.equal(transition.getIdentifier().base58(), '11111111111111111111111111111111')
53
+ })
54
+
55
+ it('should allow to get PublicKeys', function () {
56
+ const transition = wasm.IdentityCreateTransitionWASM.default(0)
57
+
58
+ assert.equal(transition.publicKeys.length, 0)
59
+ })
60
+
61
+ it('should allow to get signature', function () {
62
+ const transition = wasm.IdentityCreateTransitionWASM.default(0)
63
+
64
+ assert.deepEqual(transition.getSignature(), Uint8Array.from([]))
65
+ })
66
+
67
+ it('should allow to get signable bytes', function () {
68
+ const transition = wasm.IdentityCreateTransitionWASM.default(0)
69
+
70
+ assert.equal(transition.getSignableBytes().length, 229)
71
+ })
72
+ })
73
+
74
+ describe('setters', function () {
75
+ it('should allow to set the userFeeIncrease', function () {
76
+ const transition = wasm.IdentityCreateTransitionWASM.default(0)
77
+
78
+ transition.userFeeIncrease = 100
79
+
80
+ assert.equal(transition.userFeeIncrease, 100)
81
+ })
82
+
83
+ // TODO: Implement publickeys in creation setter
84
+ // it('should allow to set the publicKeys', function () {
85
+ //
86
+ // })
87
+
88
+ // TODO: Implement asset lock setter
89
+ // it('should allow to set the asset lock', function () {
90
+ //
91
+ // })
92
+ })
93
+ })
@@ -0,0 +1,146 @@
1
+ const assert = require('assert')
2
+ const { describe, it, before } = require('mocha')
3
+ const initWasm = require('./utils/wasm')
4
+
5
+ let wasm
6
+
7
+ describe('IdentityCreditTransferTransition', function () {
8
+ before(async function () {
9
+ wasm = initWasm()
10
+ })
11
+
12
+ describe('serialization / deserialization', function () {
13
+ it('Should create IdentityCreditTransferTransition with empty platform version', async function () {
14
+ const transition = new wasm.IdentityCreditTransferWASM(BigInt(100), '11111111111111111111111111111111', 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec', BigInt(199))
15
+
16
+ assert.notEqual(transition.__wbg_ptr, 0)
17
+ })
18
+
19
+ it('Should create IdentityCreditTransferTransition with non empty platform version', async function () {
20
+ const sender = new wasm.IdentifierWASM('11111111111111111111111111111111')
21
+ const recipient = new wasm.IdentifierWASM('GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec')
22
+
23
+ const transition = new wasm.IdentityCreditTransferWASM(BigInt(100), sender, recipient, BigInt(199), 'platform_v1')
24
+
25
+ assert.notEqual(transition.__wbg_ptr, 0)
26
+ assert.notEqual(sender.__wbg_ptr, 0)
27
+ assert.notEqual(recipient.__wbg_ptr, 0)
28
+ })
29
+ })
30
+
31
+ describe('getters', function () {
32
+ it('Should return recipientId', async function () {
33
+ const transition = new wasm.IdentityCreditTransferWASM(BigInt(100), '11111111111111111111111111111111', 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec', BigInt(199))
34
+
35
+ assert.deepEqual(transition.recipientId.base58(), 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec')
36
+ })
37
+
38
+ it('Should return senderId', async function () {
39
+ const transition = new wasm.IdentityCreditTransferWASM(BigInt(100), '11111111111111111111111111111111', 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec', BigInt(199))
40
+
41
+ assert.deepEqual(transition.senderId.base58(), '11111111111111111111111111111111')
42
+ })
43
+
44
+ it('Should return amount', async function () {
45
+ const transition = new wasm.IdentityCreditTransferWASM(BigInt(100), '11111111111111111111111111111111', 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec', BigInt(199))
46
+
47
+ assert.deepEqual(transition.amount, BigInt(100))
48
+ })
49
+
50
+ it('Should return nonce', async function () {
51
+ const transition = new wasm.IdentityCreditTransferWASM(BigInt(100), '11111111111111111111111111111111', 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec', BigInt(199))
52
+
53
+ assert.deepEqual(transition.nonce, BigInt(199))
54
+ })
55
+
56
+ it('Should return signature', async function () {
57
+ const transition = new wasm.IdentityCreditTransferWASM(BigInt(100), '11111111111111111111111111111111', 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec', BigInt(199))
58
+
59
+ assert.deepEqual(transition.signature, Uint8Array.from([]))
60
+ })
61
+
62
+ it('Should return signaturePublicKeyId', async function () {
63
+ const transition = new wasm.IdentityCreditTransferWASM(BigInt(100), '11111111111111111111111111111111', 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec', BigInt(199))
64
+
65
+ assert.deepEqual(transition.signaturePublicKeyId, 0)
66
+ })
67
+
68
+ it('Should return userFeeIncrease', async function () {
69
+ const transition = new wasm.IdentityCreditTransferWASM(BigInt(100), '11111111111111111111111111111111', 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec', BigInt(199))
70
+
71
+ assert.deepEqual(transition.userFeeIncrease, 0)
72
+ })
73
+ })
74
+
75
+ describe('setters', function () {
76
+ it('Should allow to set recipientId', async function () {
77
+ const transition = new wasm.IdentityCreditTransferWASM(BigInt(100), '11111111111111111111111111111111', 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec', BigInt(199))
78
+
79
+ const recipient = new wasm.IdentifierWASM('11111111111111111111111111111111')
80
+
81
+ transition.recipientId = recipient
82
+
83
+ assert.deepEqual(transition.recipientId.base58(), '11111111111111111111111111111111')
84
+
85
+ transition.recipientId = 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec'
86
+
87
+ assert.deepEqual(transition.recipientId.base58(), 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec')
88
+ assert.notEqual(recipient.__wbg_ptr, 0)
89
+ })
90
+
91
+ it('Should return senderId', async function () {
92
+ const transition = new wasm.IdentityCreditTransferWASM(BigInt(100), '11111111111111111111111111111111', 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec', BigInt(199))
93
+
94
+ const sender = new wasm.IdentifierWASM('GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec')
95
+
96
+ transition.senderId = sender
97
+
98
+ assert.deepEqual(transition.senderId.base58(), 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec')
99
+
100
+ transition.senderId = '11111111111111111111111111111111'
101
+
102
+ assert.notEqual(sender.__wbg_ptr, 0)
103
+ assert.deepEqual(transition.senderId.base58(), '11111111111111111111111111111111')
104
+ })
105
+
106
+ it('Should return amount', async function () {
107
+ const transition = new wasm.IdentityCreditTransferWASM(BigInt(100), '11111111111111111111111111111111', 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec', BigInt(199))
108
+
109
+ transition.amount = BigInt(199)
110
+
111
+ assert.deepEqual(transition.amount, BigInt(199))
112
+ })
113
+
114
+ it('Should return nonce', async function () {
115
+ const transition = new wasm.IdentityCreditTransferWASM(BigInt(100), '11111111111111111111111111111111', 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec', BigInt(199))
116
+
117
+ transition.nonce = BigInt(1)
118
+
119
+ assert.deepEqual(transition.nonce, BigInt(1))
120
+ })
121
+
122
+ it('Should return signature', async function () {
123
+ const transition = new wasm.IdentityCreditTransferWASM(BigInt(100), '11111111111111111111111111111111', 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec', BigInt(199))
124
+
125
+ transition.signature = [1, 1]
126
+
127
+ assert.deepEqual(transition.signature, Uint8Array.from([1, 1]))
128
+ })
129
+
130
+ it('Should return signaturePublicKeyId', async function () {
131
+ const transition = new wasm.IdentityCreditTransferWASM(BigInt(100), '11111111111111111111111111111111', 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec', BigInt(199))
132
+
133
+ transition.signaturePublicKeyId = 11
134
+
135
+ assert.deepEqual(transition.signaturePublicKeyId, 11)
136
+ })
137
+
138
+ it('Should return userFeeIncrease', async function () {
139
+ const transition = new wasm.IdentityCreditTransferWASM(BigInt(100), '11111111111111111111111111111111', 'GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec', BigInt(199))
140
+
141
+ transition.userFeeIncrease = 11
142
+
143
+ assert.deepEqual(transition.userFeeIncrease, 11)
144
+ })
145
+ })
146
+ })
@@ -0,0 +1,192 @@
1
+ const assert = require('assert')
2
+ const { describe, it, before } = require('mocha')
3
+ const initWasm = require('./utils/wasm')
4
+
5
+ let wasm
6
+
7
+ describe('IdentityCreditWithdrawalTransition', function () {
8
+ before(async function () {
9
+ wasm = initWasm()
10
+ })
11
+
12
+ describe('serialization / deserialization', function () {
13
+ it('Should allow to create IdentityCreditWithdrawalTransition', function () {
14
+ const identifier = new wasm.IdentifierWASM('GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec')
15
+ const script = wasm.CoreScriptWASM.newP2PKH([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
16
+
17
+ const transition = new wasm.IdentityCreditWithdrawalTransitionWASM(identifier, BigInt(111), 1, 'never', script, BigInt(1), 1)
18
+
19
+ assert.notEqual(identifier.__wbg_ptr, 0)
20
+ assert.notEqual(script.__wbg_ptr, 0)
21
+ assert.notEqual(transition.__wbg_ptr, 0)
22
+ })
23
+ })
24
+
25
+ describe('getters', function () {
26
+ it('Should allow to get outputScript', function () {
27
+ const identifier = new wasm.IdentifierWASM('GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec')
28
+ const script = wasm.CoreScriptWASM.newP2PKH([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
29
+
30
+ const transition = new wasm.IdentityCreditWithdrawalTransitionWASM(identifier, BigInt(111), 1, 'never', script, BigInt(1), 1)
31
+
32
+ assert.deepEqual(transition.outputScript.toString(), 'dqkUAQEBAQEBAQEBAQEBAQEBAQEBAQGIrA==')
33
+ })
34
+
35
+ it('Should allow to get pooling', function () {
36
+ const identifier = new wasm.IdentifierWASM('GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec')
37
+ const script = wasm.CoreScriptWASM.newP2PKH([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
38
+
39
+ const transition = new wasm.IdentityCreditWithdrawalTransitionWASM(identifier, BigInt(111), 1, 'never', script, BigInt(1), 1)
40
+
41
+ assert.deepEqual(transition.pooling, 'Never')
42
+ })
43
+
44
+ it('Should allow to get identityId', function () {
45
+ const identifier = new wasm.IdentifierWASM('GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec')
46
+ const script = wasm.CoreScriptWASM.newP2PKH([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
47
+
48
+ const transition = new wasm.IdentityCreditWithdrawalTransitionWASM(identifier, BigInt(111), 1, 'never', script, BigInt(1), 1)
49
+
50
+ assert.deepEqual(transition.identityId.base58(), identifier.base58())
51
+ })
52
+
53
+ it('Should allow to get userFeeIncrease', function () {
54
+ const identifier = new wasm.IdentifierWASM('GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec')
55
+ const script = wasm.CoreScriptWASM.newP2PKH([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
56
+
57
+ const transition = new wasm.IdentityCreditWithdrawalTransitionWASM(identifier, BigInt(111), 1, 'never', script, BigInt(1), 1)
58
+
59
+ assert.deepEqual(transition.userFeeIncrease, 1)
60
+ })
61
+
62
+ it('Should allow to get nonce', function () {
63
+ const identifier = new wasm.IdentifierWASM('GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec')
64
+ const script = wasm.CoreScriptWASM.newP2PKH([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
65
+
66
+ const transition = new wasm.IdentityCreditWithdrawalTransitionWASM(identifier, BigInt(111), 1, 'never', script, BigInt(1), 1)
67
+
68
+ assert.deepEqual(transition.nonce, BigInt(1))
69
+ })
70
+
71
+ it('Should allow to get amount', function () {
72
+ const identifier = new wasm.IdentifierWASM('GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec')
73
+ const script = wasm.CoreScriptWASM.newP2PKH([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
74
+
75
+ const transition = new wasm.IdentityCreditWithdrawalTransitionWASM(identifier, BigInt(111), 1, 'never', script, BigInt(1), 1)
76
+
77
+ assert.deepEqual(transition.amount, BigInt(111))
78
+ })
79
+
80
+ it('Should allow to get signature', function () {
81
+ const identifier = new wasm.IdentifierWASM('GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec')
82
+ const script = wasm.CoreScriptWASM.newP2PKH([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
83
+
84
+ const transition = new wasm.IdentityCreditWithdrawalTransitionWASM(identifier, BigInt(111), 1, 'never', script, BigInt(1), 1)
85
+
86
+ assert.deepEqual(transition.signature, Uint8Array.from([]))
87
+ })
88
+
89
+ it('Should allow to get signaturePublicKeyId', function () {
90
+ const identifier = new wasm.IdentifierWASM('GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec')
91
+ const script = wasm.CoreScriptWASM.newP2PKH([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
92
+
93
+ const transition = new wasm.IdentityCreditWithdrawalTransitionWASM(identifier, BigInt(111), 1, 'never', script, BigInt(1), 1)
94
+
95
+ assert.deepEqual(transition.signaturePublicKeyId, 0)
96
+ })
97
+ })
98
+
99
+ describe('setters', function () {
100
+ it('Should allow to set outputScript', function () {
101
+ const identifier = new wasm.IdentifierWASM('GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec')
102
+ const script = wasm.CoreScriptWASM.newP2PKH([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
103
+
104
+ const transition = new wasm.IdentityCreditWithdrawalTransitionWASM(identifier, BigInt(111), 1, 'never', script, BigInt(1), 1)
105
+
106
+ const script2 = wasm.CoreScriptWASM.newP2PKH([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
107
+
108
+ transition.outputScript = script2
109
+
110
+ assert.deepEqual(transition.outputScript.toString(), script2.toString())
111
+ })
112
+
113
+ it('Should allow to set pooling', function () {
114
+ const identifier = new wasm.IdentifierWASM('GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec')
115
+ const script = wasm.CoreScriptWASM.newP2PKH([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
116
+
117
+ const transition = new wasm.IdentityCreditWithdrawalTransitionWASM(identifier, BigInt(111), 1, 'never', script, BigInt(1), 1)
118
+
119
+ transition.pooling = 'Standard'
120
+
121
+ assert.deepEqual(transition.pooling, 'Standard')
122
+ })
123
+
124
+ it('Should allow to set identityId', function () {
125
+ const identifier = new wasm.IdentifierWASM('GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec')
126
+ const script = wasm.CoreScriptWASM.newP2PKH([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
127
+
128
+ const transition = new wasm.IdentityCreditWithdrawalTransitionWASM(identifier, BigInt(111), 1, 'never', script, BigInt(1), 1)
129
+
130
+ const identifier2 = new wasm.IdentifierWASM('11SAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec')
131
+
132
+ transition.identityId = identifier2
133
+
134
+ assert.deepEqual(transition.identityId.base58(), identifier2.base58())
135
+ })
136
+
137
+ it('Should allow to set userFeeIncrease', function () {
138
+ const identifier = new wasm.IdentifierWASM('GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec')
139
+ const script = wasm.CoreScriptWASM.newP2PKH([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
140
+
141
+ const transition = new wasm.IdentityCreditWithdrawalTransitionWASM(identifier, BigInt(111), 1, 'never', script, BigInt(1), 1)
142
+
143
+ transition.userFeeIncrease = 999
144
+
145
+ assert.deepEqual(transition.userFeeIncrease, 999)
146
+ })
147
+
148
+ it('Should allow to set nonce', function () {
149
+ const identifier = new wasm.IdentifierWASM('GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec')
150
+ const script = wasm.CoreScriptWASM.newP2PKH([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
151
+
152
+ const transition = new wasm.IdentityCreditWithdrawalTransitionWASM(identifier, BigInt(111), 1, 'never', script, BigInt(1), 1)
153
+
154
+ transition.nonce = BigInt(1111)
155
+
156
+ assert.deepEqual(transition.nonce, BigInt(1111))
157
+ })
158
+
159
+ it('Should allow to get amount', function () {
160
+ const identifier = new wasm.IdentifierWASM('GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec')
161
+ const script = wasm.CoreScriptWASM.newP2PKH([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
162
+
163
+ const transition = new wasm.IdentityCreditWithdrawalTransitionWASM(identifier, BigInt(111), 1, 'never', script, BigInt(1), 1)
164
+
165
+ transition.amount = BigInt(2222)
166
+
167
+ assert.deepEqual(transition.amount, BigInt(2222))
168
+ })
169
+
170
+ it('Should allow to get signature', function () {
171
+ const identifier = new wasm.IdentifierWASM('GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec')
172
+ const script = wasm.CoreScriptWASM.newP2PKH([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
173
+
174
+ const transition = new wasm.IdentityCreditWithdrawalTransitionWASM(identifier, BigInt(111), 1, 'never', script, BigInt(1), 1)
175
+
176
+ transition.signature = Uint8Array.from([1, 2, 3])
177
+
178
+ assert.deepEqual(transition.signature, Uint8Array.from([1, 2, 3]))
179
+ })
180
+
181
+ it('Should allow to get signaturePublicKeyId', function () {
182
+ const identifier = new wasm.IdentifierWASM('GWRSAVFMjXx8HpQFaNJMqBV7MBgMK4br5UESsB4S31Ec')
183
+ const script = wasm.CoreScriptWASM.newP2PKH([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
184
+
185
+ const transition = new wasm.IdentityCreditWithdrawalTransitionWASM(identifier, BigInt(111), 1, 'never', script, BigInt(1), 1)
186
+
187
+ transition.signaturePublicKeyId = 11
188
+
189
+ assert.deepEqual(transition.signaturePublicKeyId, 11)
190
+ })
191
+ })
192
+ })