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,132 @@
1
+ const assert = require('assert')
2
+ const { describe, it, before } = require('mocha')
3
+ const initWasm = require('./utils/wasm')
4
+ const {
5
+ keyId, purpose, securityLevel, keyType, binaryData, securityLevelSet, keyIdSet, purposeSet,
6
+ keyTypeSet, binaryDataSet
7
+ } = require('./mocks/PublicKey')
8
+ const { wif } = require('./mocks/PrivateKey')
9
+ const { toHexString } = require('./utils/hex')
10
+
11
+ let wasm
12
+
13
+ describe('PublicKey', function () {
14
+ before(async function () {
15
+ wasm = initWasm()
16
+ })
17
+
18
+ describe('serialization / deserialization', function () {
19
+ it('should generate public key from values with type ECDSA_SECP256K1', function () {
20
+ const pubKey = new wasm.IdentityPublicKeyWASM(
21
+ keyId,
22
+ purpose,
23
+ securityLevel,
24
+ keyType,
25
+ false,
26
+ binaryData)
27
+
28
+ assert.notEqual(pubKey.__wbg_ptr, 0)
29
+ })
30
+
31
+ it('should generate public key from values with type ECDSA_SECP256K1 and generate new from self bytes', function () {
32
+ const pubKey = new wasm.IdentityPublicKeyWASM(
33
+ keyId,
34
+ purpose,
35
+ securityLevel,
36
+ keyType,
37
+ false,
38
+ binaryData)
39
+
40
+ const bytes = pubKey.toBytes()
41
+
42
+ const newPubKey = wasm.IdentityPublicKeyWASM.fromBytes(Array.from(bytes))
43
+
44
+ assert.notEqual(pubKey.__wbg_ptr, 0)
45
+ assert.notEqual(newPubKey.__wbg_ptr, 0)
46
+
47
+ assert.equal(pubKey.getKeyId(), newPubKey.getKeyId())
48
+ assert.equal(pubKey.getPurpose(), newPubKey.getPurpose())
49
+ assert.equal(pubKey.getSecurityLevel(), newPubKey.getSecurityLevel())
50
+ assert.equal(pubKey.getKeyType(), newPubKey.getKeyType())
51
+ assert.equal(pubKey.getReadOnly(), newPubKey.getReadOnly())
52
+ assert.equal(pubKey.getData(), newPubKey.getData())
53
+
54
+ assert.deepEqual(pubKey.toBytes(), newPubKey.toBytes())
55
+
56
+ assert.notEqual(pubKey.__wbg_ptr, 0)
57
+ assert.notEqual(newPubKey.__wbg_ptr, 0)
58
+ })
59
+
60
+ it('should return hash of key', function () {
61
+ const pubKey = new wasm.IdentityPublicKeyWASM(
62
+ keyId,
63
+ purpose,
64
+ securityLevel,
65
+ keyType,
66
+ false,
67
+ binaryData)
68
+
69
+ const hash = pubKey.getPublicKeyHash()
70
+
71
+ assert.deepEqual(hash, toHexString([211, 114, 240, 150, 37, 159, 114, 104, 110, 24, 102, 61, 125, 181, 248, 98, 52, 221, 111, 85]))
72
+ })
73
+ })
74
+ describe('getters', function () {
75
+ it('should generate public key from values with type ECDSA_SECP256K1 and return all fields', function () {
76
+ const pubKey = new wasm.IdentityPublicKeyWASM(
77
+ keyId,
78
+ purpose,
79
+ securityLevel,
80
+ keyType,
81
+ false,
82
+ binaryData)
83
+
84
+ assert.equal(pubKey.getKeyId(), keyId)
85
+ assert.equal(pubKey.getPurpose(), 'AUTHENTICATION')
86
+ assert.equal(pubKey.getSecurityLevel(), 'CRITICAL')
87
+ assert.equal(pubKey.getKeyType(), 'ECDSA_SECP256K1')
88
+ assert.equal(pubKey.getReadOnly(), false)
89
+ assert.equal(pubKey.getData(), binaryData)
90
+ })
91
+
92
+ it('should allow to validate private key', function () {
93
+ const pubKey = new wasm.IdentityPublicKeyWASM(
94
+ keyId,
95
+ purpose,
96
+ securityLevel,
97
+ keyType,
98
+ false,
99
+ binaryData)
100
+
101
+ const privateKey = wasm.PrivateKeyWASM.fromWIF(wif)
102
+
103
+ assert.equal(pubKey.validatePrivateKey(privateKey.getBytes(), wasm.NetworkWASM.Mainnet), false)
104
+ })
105
+ })
106
+
107
+ describe('setters', function () {
108
+ it('should generate public key from values with type ECDSA_SECP256K1 and return all fields and set another fields', function () {
109
+ const pubKey = new wasm.IdentityPublicKeyWASM(
110
+ keyId,
111
+ purpose,
112
+ securityLevel,
113
+ keyType,
114
+ false,
115
+ binaryData)
116
+
117
+ pubKey.setKeyId(keyIdSet)
118
+ pubKey.setPurpose(purposeSet)
119
+ pubKey.setSecurityLevel(securityLevelSet)
120
+ pubKey.setKeyType(keyTypeSet)
121
+ pubKey.setReadOnly(true)
122
+ pubKey.setData(binaryDataSet)
123
+
124
+ assert.equal(pubKey.getKeyId(), keyIdSet)
125
+ assert.equal(pubKey.getPurpose(), 'ENCRYPTION')
126
+ assert.equal(pubKey.getSecurityLevel(), 'HIGH')
127
+ assert.equal(pubKey.getKeyType(), 'ECDSA_HASH160')
128
+ assert.equal(pubKey.getReadOnly(), true)
129
+ assert.equal(pubKey.getData(), binaryDataSet)
130
+ })
131
+ })
132
+ })
@@ -0,0 +1,131 @@
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('IdentityTopUpTransition', function () {
8
+ before(async function () {
9
+ wasm = initWasm()
10
+ })
11
+
12
+ describe('serialization / deserialization', function () {
13
+ it('should allow to create IdentityTopUpTransition', function () {
14
+ const assetLockProof = wasm.AssetLockProofWASM.createInstantAssetLockProof(
15
+ // instant lock
16
+ [1, 1, 193, 219, 244, 102, 77, 20, 251, 187, 201, 109, 168, 125, 7, 244, 118, 119, 210, 53, 238, 105, 138, 31, 7, 73, 30, 128, 131, 175, 114, 76, 187, 37, 0, 0, 0, 0, 177, 215, 65, 96, 204, 228, 86, 13, 14, 185, 46, 65, 241, 38, 226, 172, 59, 96, 158, 15, 126, 90, 225, 3, 140, 221, 96, 131, 254, 12, 236, 26, 48, 124, 31, 23, 184, 202, 122, 231, 123, 59, 43, 118, 27, 214, 225, 58, 44, 191, 232, 10, 33, 35, 8, 113, 145, 159, 158, 88, 80, 0, 0, 0, 173, 103, 128, 160, 29, 226, 161, 219, 167, 194, 158, 38, 19, 51, 143, 248, 161, 87, 126, 32, 143, 209, 152, 44, 174, 6, 25, 210, 101, 127, 131, 65, 202, 241, 47, 166, 132, 10, 199, 15, 187, 136, 11, 217, 237, 13, 173, 64, 11, 6, 112, 188, 234, 239, 204, 29, 3, 6, 35, 154, 44, 106, 44, 183, 171, 126, 146, 240, 153, 210, 187, 56, 133, 161, 11, 4, 151, 63, 89, 20, 44, 66, 153, 242, 97, 207, 44, 110, 208, 51, 198, 113, 104, 79, 154, 19],
17
+ // transaction
18
+ [3, 0, 8, 0, 1, 193, 219, 244, 102, 77, 20, 251, 187, 201, 109, 168, 125, 7, 244, 118, 119, 210, 53, 238, 105, 138, 31, 7, 73, 30, 128, 131, 175, 114, 76, 187, 37, 0, 0, 0, 0, 106, 71, 48, 68, 2, 32, 2, 146, 73, 163, 223, 124, 140, 225, 109, 126, 239, 87, 105, 184, 118, 87, 182, 100, 182, 6, 15, 200, 26, 44, 33, 215, 165, 110, 211, 232, 245, 233, 2, 32, 69, 161, 168, 128, 101, 26, 171, 20, 63, 30, 219, 87, 23, 4, 142, 115, 73, 73, 170, 203, 46, 187, 149, 32, 210, 171, 46, 136, 253, 188, 36, 12, 1, 33, 2, 144, 231, 28, 153, 30, 92, 52, 10, 111, 47, 107, 74, 225, 237, 151, 33, 188, 184, 247, 121, 70, 135, 174, 31, 160, 16, 216, 239, 225, 103, 88, 112, 255, 255, 255, 255, 2, 64, 66, 15, 0, 0, 0, 0, 0, 2, 106, 0, 216, 154, 230, 5, 0, 0, 0, 0, 25, 118, 169, 20, 229, 154, 45, 140, 145, 114, 18, 52, 205, 13, 179, 84, 94, 174, 149, 207, 101, 115, 51, 240, 136, 172, 0, 0, 0, 0, 36, 1, 1, 64, 66, 15, 0, 0, 0, 0, 0, 25, 118, 169, 20, 176, 213, 107, 82, 203, 147, 209, 128, 255, 63, 69, 219, 41, 250, 232, 254, 185, 168, 85, 184, 136, 172],
19
+ // output index
20
+ 0
21
+ )
22
+
23
+ const transition = new wasm.IdentityTopUpTransitionWASM(assetLockProof, 'B7kcE1juMBWEWkuYRJhVdAE2e6RaevrGxRsa1DrLCpQH', 11)
24
+
25
+ assert.notEqual(transition.__wbg_ptr, 0)
26
+ assert.notEqual(assetLockProof.__wbg_ptr, 0)
27
+ })
28
+ })
29
+
30
+ describe('getters', function () {
31
+ it('should allow to return userFeeIncrease', function () {
32
+ const assetLockProof = wasm.AssetLockProofWASM.createInstantAssetLockProof(
33
+ // instant lock
34
+ [1, 1, 193, 219, 244, 102, 77, 20, 251, 187, 201, 109, 168, 125, 7, 244, 118, 119, 210, 53, 238, 105, 138, 31, 7, 73, 30, 128, 131, 175, 114, 76, 187, 37, 0, 0, 0, 0, 177, 215, 65, 96, 204, 228, 86, 13, 14, 185, 46, 65, 241, 38, 226, 172, 59, 96, 158, 15, 126, 90, 225, 3, 140, 221, 96, 131, 254, 12, 236, 26, 48, 124, 31, 23, 184, 202, 122, 231, 123, 59, 43, 118, 27, 214, 225, 58, 44, 191, 232, 10, 33, 35, 8, 113, 145, 159, 158, 88, 80, 0, 0, 0, 173, 103, 128, 160, 29, 226, 161, 219, 167, 194, 158, 38, 19, 51, 143, 248, 161, 87, 126, 32, 143, 209, 152, 44, 174, 6, 25, 210, 101, 127, 131, 65, 202, 241, 47, 166, 132, 10, 199, 15, 187, 136, 11, 217, 237, 13, 173, 64, 11, 6, 112, 188, 234, 239, 204, 29, 3, 6, 35, 154, 44, 106, 44, 183, 171, 126, 146, 240, 153, 210, 187, 56, 133, 161, 11, 4, 151, 63, 89, 20, 44, 66, 153, 242, 97, 207, 44, 110, 208, 51, 198, 113, 104, 79, 154, 19],
35
+ // transaction
36
+ [3, 0, 8, 0, 1, 193, 219, 244, 102, 77, 20, 251, 187, 201, 109, 168, 125, 7, 244, 118, 119, 210, 53, 238, 105, 138, 31, 7, 73, 30, 128, 131, 175, 114, 76, 187, 37, 0, 0, 0, 0, 106, 71, 48, 68, 2, 32, 2, 146, 73, 163, 223, 124, 140, 225, 109, 126, 239, 87, 105, 184, 118, 87, 182, 100, 182, 6, 15, 200, 26, 44, 33, 215, 165, 110, 211, 232, 245, 233, 2, 32, 69, 161, 168, 128, 101, 26, 171, 20, 63, 30, 219, 87, 23, 4, 142, 115, 73, 73, 170, 203, 46, 187, 149, 32, 210, 171, 46, 136, 253, 188, 36, 12, 1, 33, 2, 144, 231, 28, 153, 30, 92, 52, 10, 111, 47, 107, 74, 225, 237, 151, 33, 188, 184, 247, 121, 70, 135, 174, 31, 160, 16, 216, 239, 225, 103, 88, 112, 255, 255, 255, 255, 2, 64, 66, 15, 0, 0, 0, 0, 0, 2, 106, 0, 216, 154, 230, 5, 0, 0, 0, 0, 25, 118, 169, 20, 229, 154, 45, 140, 145, 114, 18, 52, 205, 13, 179, 84, 94, 174, 149, 207, 101, 115, 51, 240, 136, 172, 0, 0, 0, 0, 36, 1, 1, 64, 66, 15, 0, 0, 0, 0, 0, 25, 118, 169, 20, 176, 213, 107, 82, 203, 147, 209, 128, 255, 63, 69, 219, 41, 250, 232, 254, 185, 168, 85, 184, 136, 172],
37
+ // output index
38
+ 0
39
+ )
40
+
41
+ const transition = new wasm.IdentityTopUpTransitionWASM(assetLockProof, 'B7kcE1juMBWEWkuYRJhVdAE2e6RaevrGxRsa1DrLCpQH', 11)
42
+
43
+ assert.deepEqual(transition.userFeeIncrease, 11)
44
+ })
45
+
46
+ it('should allow to return identityIdentifier', function () {
47
+ const assetLockProof = wasm.AssetLockProofWASM.createInstantAssetLockProof(
48
+ // instant lock
49
+ [1, 1, 193, 219, 244, 102, 77, 20, 251, 187, 201, 109, 168, 125, 7, 244, 118, 119, 210, 53, 238, 105, 138, 31, 7, 73, 30, 128, 131, 175, 114, 76, 187, 37, 0, 0, 0, 0, 177, 215, 65, 96, 204, 228, 86, 13, 14, 185, 46, 65, 241, 38, 226, 172, 59, 96, 158, 15, 126, 90, 225, 3, 140, 221, 96, 131, 254, 12, 236, 26, 48, 124, 31, 23, 184, 202, 122, 231, 123, 59, 43, 118, 27, 214, 225, 58, 44, 191, 232, 10, 33, 35, 8, 113, 145, 159, 158, 88, 80, 0, 0, 0, 173, 103, 128, 160, 29, 226, 161, 219, 167, 194, 158, 38, 19, 51, 143, 248, 161, 87, 126, 32, 143, 209, 152, 44, 174, 6, 25, 210, 101, 127, 131, 65, 202, 241, 47, 166, 132, 10, 199, 15, 187, 136, 11, 217, 237, 13, 173, 64, 11, 6, 112, 188, 234, 239, 204, 29, 3, 6, 35, 154, 44, 106, 44, 183, 171, 126, 146, 240, 153, 210, 187, 56, 133, 161, 11, 4, 151, 63, 89, 20, 44, 66, 153, 242, 97, 207, 44, 110, 208, 51, 198, 113, 104, 79, 154, 19],
50
+ // transaction
51
+ [3, 0, 8, 0, 1, 193, 219, 244, 102, 77, 20, 251, 187, 201, 109, 168, 125, 7, 244, 118, 119, 210, 53, 238, 105, 138, 31, 7, 73, 30, 128, 131, 175, 114, 76, 187, 37, 0, 0, 0, 0, 106, 71, 48, 68, 2, 32, 2, 146, 73, 163, 223, 124, 140, 225, 109, 126, 239, 87, 105, 184, 118, 87, 182, 100, 182, 6, 15, 200, 26, 44, 33, 215, 165, 110, 211, 232, 245, 233, 2, 32, 69, 161, 168, 128, 101, 26, 171, 20, 63, 30, 219, 87, 23, 4, 142, 115, 73, 73, 170, 203, 46, 187, 149, 32, 210, 171, 46, 136, 253, 188, 36, 12, 1, 33, 2, 144, 231, 28, 153, 30, 92, 52, 10, 111, 47, 107, 74, 225, 237, 151, 33, 188, 184, 247, 121, 70, 135, 174, 31, 160, 16, 216, 239, 225, 103, 88, 112, 255, 255, 255, 255, 2, 64, 66, 15, 0, 0, 0, 0, 0, 2, 106, 0, 216, 154, 230, 5, 0, 0, 0, 0, 25, 118, 169, 20, 229, 154, 45, 140, 145, 114, 18, 52, 205, 13, 179, 84, 94, 174, 149, 207, 101, 115, 51, 240, 136, 172, 0, 0, 0, 0, 36, 1, 1, 64, 66, 15, 0, 0, 0, 0, 0, 25, 118, 169, 20, 176, 213, 107, 82, 203, 147, 209, 128, 255, 63, 69, 219, 41, 250, 232, 254, 185, 168, 85, 184, 136, 172],
52
+ // output index
53
+ 0
54
+ )
55
+
56
+ const transition = new wasm.IdentityTopUpTransitionWASM(assetLockProof, 'B7kcE1juMBWEWkuYRJhVdAE2e6RaevrGxRsa1DrLCpQH', 11)
57
+
58
+ assert.deepEqual(transition.identityIdentifier.base58(), 'B7kcE1juMBWEWkuYRJhVdAE2e6RaevrGxRsa1DrLCpQH')
59
+ })
60
+
61
+ it('should allow to return signature', function () {
62
+ const assetLockProof = wasm.AssetLockProofWASM.createInstantAssetLockProof(
63
+ // instant lock
64
+ [1, 1, 193, 219, 244, 102, 77, 20, 251, 187, 201, 109, 168, 125, 7, 244, 118, 119, 210, 53, 238, 105, 138, 31, 7, 73, 30, 128, 131, 175, 114, 76, 187, 37, 0, 0, 0, 0, 177, 215, 65, 96, 204, 228, 86, 13, 14, 185, 46, 65, 241, 38, 226, 172, 59, 96, 158, 15, 126, 90, 225, 3, 140, 221, 96, 131, 254, 12, 236, 26, 48, 124, 31, 23, 184, 202, 122, 231, 123, 59, 43, 118, 27, 214, 225, 58, 44, 191, 232, 10, 33, 35, 8, 113, 145, 159, 158, 88, 80, 0, 0, 0, 173, 103, 128, 160, 29, 226, 161, 219, 167, 194, 158, 38, 19, 51, 143, 248, 161, 87, 126, 32, 143, 209, 152, 44, 174, 6, 25, 210, 101, 127, 131, 65, 202, 241, 47, 166, 132, 10, 199, 15, 187, 136, 11, 217, 237, 13, 173, 64, 11, 6, 112, 188, 234, 239, 204, 29, 3, 6, 35, 154, 44, 106, 44, 183, 171, 126, 146, 240, 153, 210, 187, 56, 133, 161, 11, 4, 151, 63, 89, 20, 44, 66, 153, 242, 97, 207, 44, 110, 208, 51, 198, 113, 104, 79, 154, 19],
65
+ // transaction
66
+ [3, 0, 8, 0, 1, 193, 219, 244, 102, 77, 20, 251, 187, 201, 109, 168, 125, 7, 244, 118, 119, 210, 53, 238, 105, 138, 31, 7, 73, 30, 128, 131, 175, 114, 76, 187, 37, 0, 0, 0, 0, 106, 71, 48, 68, 2, 32, 2, 146, 73, 163, 223, 124, 140, 225, 109, 126, 239, 87, 105, 184, 118, 87, 182, 100, 182, 6, 15, 200, 26, 44, 33, 215, 165, 110, 211, 232, 245, 233, 2, 32, 69, 161, 168, 128, 101, 26, 171, 20, 63, 30, 219, 87, 23, 4, 142, 115, 73, 73, 170, 203, 46, 187, 149, 32, 210, 171, 46, 136, 253, 188, 36, 12, 1, 33, 2, 144, 231, 28, 153, 30, 92, 52, 10, 111, 47, 107, 74, 225, 237, 151, 33, 188, 184, 247, 121, 70, 135, 174, 31, 160, 16, 216, 239, 225, 103, 88, 112, 255, 255, 255, 255, 2, 64, 66, 15, 0, 0, 0, 0, 0, 2, 106, 0, 216, 154, 230, 5, 0, 0, 0, 0, 25, 118, 169, 20, 229, 154, 45, 140, 145, 114, 18, 52, 205, 13, 179, 84, 94, 174, 149, 207, 101, 115, 51, 240, 136, 172, 0, 0, 0, 0, 36, 1, 1, 64, 66, 15, 0, 0, 0, 0, 0, 25, 118, 169, 20, 176, 213, 107, 82, 203, 147, 209, 128, 255, 63, 69, 219, 41, 250, 232, 254, 185, 168, 85, 184, 136, 172],
67
+ // output index
68
+ 0
69
+ )
70
+
71
+ const transition = new wasm.IdentityTopUpTransitionWASM(assetLockProof, 'B7kcE1juMBWEWkuYRJhVdAE2e6RaevrGxRsa1DrLCpQH', 11)
72
+
73
+ assert.deepEqual(transition.signature, Uint8Array.from([]))
74
+ })
75
+ })
76
+
77
+ describe('setters', function () {
78
+ it('should allow to set userFeeIncrease', function () {
79
+ const assetLockProof = wasm.AssetLockProofWASM.createInstantAssetLockProof(
80
+ // instant lock
81
+ [1, 1, 193, 219, 244, 102, 77, 20, 251, 187, 201, 109, 168, 125, 7, 244, 118, 119, 210, 53, 238, 105, 138, 31, 7, 73, 30, 128, 131, 175, 114, 76, 187, 37, 0, 0, 0, 0, 177, 215, 65, 96, 204, 228, 86, 13, 14, 185, 46, 65, 241, 38, 226, 172, 59, 96, 158, 15, 126, 90, 225, 3, 140, 221, 96, 131, 254, 12, 236, 26, 48, 124, 31, 23, 184, 202, 122, 231, 123, 59, 43, 118, 27, 214, 225, 58, 44, 191, 232, 10, 33, 35, 8, 113, 145, 159, 158, 88, 80, 0, 0, 0, 173, 103, 128, 160, 29, 226, 161, 219, 167, 194, 158, 38, 19, 51, 143, 248, 161, 87, 126, 32, 143, 209, 152, 44, 174, 6, 25, 210, 101, 127, 131, 65, 202, 241, 47, 166, 132, 10, 199, 15, 187, 136, 11, 217, 237, 13, 173, 64, 11, 6, 112, 188, 234, 239, 204, 29, 3, 6, 35, 154, 44, 106, 44, 183, 171, 126, 146, 240, 153, 210, 187, 56, 133, 161, 11, 4, 151, 63, 89, 20, 44, 66, 153, 242, 97, 207, 44, 110, 208, 51, 198, 113, 104, 79, 154, 19],
82
+ // transaction
83
+ [3, 0, 8, 0, 1, 193, 219, 244, 102, 77, 20, 251, 187, 201, 109, 168, 125, 7, 244, 118, 119, 210, 53, 238, 105, 138, 31, 7, 73, 30, 128, 131, 175, 114, 76, 187, 37, 0, 0, 0, 0, 106, 71, 48, 68, 2, 32, 2, 146, 73, 163, 223, 124, 140, 225, 109, 126, 239, 87, 105, 184, 118, 87, 182, 100, 182, 6, 15, 200, 26, 44, 33, 215, 165, 110, 211, 232, 245, 233, 2, 32, 69, 161, 168, 128, 101, 26, 171, 20, 63, 30, 219, 87, 23, 4, 142, 115, 73, 73, 170, 203, 46, 187, 149, 32, 210, 171, 46, 136, 253, 188, 36, 12, 1, 33, 2, 144, 231, 28, 153, 30, 92, 52, 10, 111, 47, 107, 74, 225, 237, 151, 33, 188, 184, 247, 121, 70, 135, 174, 31, 160, 16, 216, 239, 225, 103, 88, 112, 255, 255, 255, 255, 2, 64, 66, 15, 0, 0, 0, 0, 0, 2, 106, 0, 216, 154, 230, 5, 0, 0, 0, 0, 25, 118, 169, 20, 229, 154, 45, 140, 145, 114, 18, 52, 205, 13, 179, 84, 94, 174, 149, 207, 101, 115, 51, 240, 136, 172, 0, 0, 0, 0, 36, 1, 1, 64, 66, 15, 0, 0, 0, 0, 0, 25, 118, 169, 20, 176, 213, 107, 82, 203, 147, 209, 128, 255, 63, 69, 219, 41, 250, 232, 254, 185, 168, 85, 184, 136, 172],
84
+ // output index
85
+ 0
86
+ )
87
+
88
+ const transition = new wasm.IdentityTopUpTransitionWASM(assetLockProof, 'B7kcE1juMBWEWkuYRJhVdAE2e6RaevrGxRsa1DrLCpQH', 11)
89
+
90
+ transition.userFeeIncrease = 21
91
+
92
+ assert.deepEqual(transition.userFeeIncrease, 21)
93
+ })
94
+
95
+ it('should allow to set identityIdentifier', function () {
96
+ const assetLockProof = wasm.AssetLockProofWASM.createInstantAssetLockProof(
97
+ // instant lock
98
+ [1, 1, 193, 219, 244, 102, 77, 20, 251, 187, 201, 109, 168, 125, 7, 244, 118, 119, 210, 53, 238, 105, 138, 31, 7, 73, 30, 128, 131, 175, 114, 76, 187, 37, 0, 0, 0, 0, 177, 215, 65, 96, 204, 228, 86, 13, 14, 185, 46, 65, 241, 38, 226, 172, 59, 96, 158, 15, 126, 90, 225, 3, 140, 221, 96, 131, 254, 12, 236, 26, 48, 124, 31, 23, 184, 202, 122, 231, 123, 59, 43, 118, 27, 214, 225, 58, 44, 191, 232, 10, 33, 35, 8, 113, 145, 159, 158, 88, 80, 0, 0, 0, 173, 103, 128, 160, 29, 226, 161, 219, 167, 194, 158, 38, 19, 51, 143, 248, 161, 87, 126, 32, 143, 209, 152, 44, 174, 6, 25, 210, 101, 127, 131, 65, 202, 241, 47, 166, 132, 10, 199, 15, 187, 136, 11, 217, 237, 13, 173, 64, 11, 6, 112, 188, 234, 239, 204, 29, 3, 6, 35, 154, 44, 106, 44, 183, 171, 126, 146, 240, 153, 210, 187, 56, 133, 161, 11, 4, 151, 63, 89, 20, 44, 66, 153, 242, 97, 207, 44, 110, 208, 51, 198, 113, 104, 79, 154, 19],
99
+ // transaction
100
+ [3, 0, 8, 0, 1, 193, 219, 244, 102, 77, 20, 251, 187, 201, 109, 168, 125, 7, 244, 118, 119, 210, 53, 238, 105, 138, 31, 7, 73, 30, 128, 131, 175, 114, 76, 187, 37, 0, 0, 0, 0, 106, 71, 48, 68, 2, 32, 2, 146, 73, 163, 223, 124, 140, 225, 109, 126, 239, 87, 105, 184, 118, 87, 182, 100, 182, 6, 15, 200, 26, 44, 33, 215, 165, 110, 211, 232, 245, 233, 2, 32, 69, 161, 168, 128, 101, 26, 171, 20, 63, 30, 219, 87, 23, 4, 142, 115, 73, 73, 170, 203, 46, 187, 149, 32, 210, 171, 46, 136, 253, 188, 36, 12, 1, 33, 2, 144, 231, 28, 153, 30, 92, 52, 10, 111, 47, 107, 74, 225, 237, 151, 33, 188, 184, 247, 121, 70, 135, 174, 31, 160, 16, 216, 239, 225, 103, 88, 112, 255, 255, 255, 255, 2, 64, 66, 15, 0, 0, 0, 0, 0, 2, 106, 0, 216, 154, 230, 5, 0, 0, 0, 0, 25, 118, 169, 20, 229, 154, 45, 140, 145, 114, 18, 52, 205, 13, 179, 84, 94, 174, 149, 207, 101, 115, 51, 240, 136, 172, 0, 0, 0, 0, 36, 1, 1, 64, 66, 15, 0, 0, 0, 0, 0, 25, 118, 169, 20, 176, 213, 107, 82, 203, 147, 209, 128, 255, 63, 69, 219, 41, 250, 232, 254, 185, 168, 85, 184, 136, 172],
101
+ // output index
102
+ 0
103
+ )
104
+
105
+ const transition = new wasm.IdentityTopUpTransitionWASM(assetLockProof, 'B7kcE1juMBWEWkuYRJhVdAE2e6RaevrGxRsa1DrLCpQH', 11)
106
+
107
+ const identifier = new wasm.IdentifierWASM('777cE1juMBWEWkuYRJhVdAE2e6RaevrGxRsa1DrLCpQH')
108
+
109
+ transition.identityIdentifier = identifier
110
+
111
+ assert.deepEqual(transition.identityIdentifier.base58(), '777cE1juMBWEWkuYRJhVdAE2e6RaevrGxRsa1DrLCpQH')
112
+ })
113
+
114
+ it('should allow to set signature', function () {
115
+ const assetLockProof = wasm.AssetLockProofWASM.createInstantAssetLockProof(
116
+ // instant lock
117
+ [1, 1, 193, 219, 244, 102, 77, 20, 251, 187, 201, 109, 168, 125, 7, 244, 118, 119, 210, 53, 238, 105, 138, 31, 7, 73, 30, 128, 131, 175, 114, 76, 187, 37, 0, 0, 0, 0, 177, 215, 65, 96, 204, 228, 86, 13, 14, 185, 46, 65, 241, 38, 226, 172, 59, 96, 158, 15, 126, 90, 225, 3, 140, 221, 96, 131, 254, 12, 236, 26, 48, 124, 31, 23, 184, 202, 122, 231, 123, 59, 43, 118, 27, 214, 225, 58, 44, 191, 232, 10, 33, 35, 8, 113, 145, 159, 158, 88, 80, 0, 0, 0, 173, 103, 128, 160, 29, 226, 161, 219, 167, 194, 158, 38, 19, 51, 143, 248, 161, 87, 126, 32, 143, 209, 152, 44, 174, 6, 25, 210, 101, 127, 131, 65, 202, 241, 47, 166, 132, 10, 199, 15, 187, 136, 11, 217, 237, 13, 173, 64, 11, 6, 112, 188, 234, 239, 204, 29, 3, 6, 35, 154, 44, 106, 44, 183, 171, 126, 146, 240, 153, 210, 187, 56, 133, 161, 11, 4, 151, 63, 89, 20, 44, 66, 153, 242, 97, 207, 44, 110, 208, 51, 198, 113, 104, 79, 154, 19],
118
+ // transaction
119
+ [3, 0, 8, 0, 1, 193, 219, 244, 102, 77, 20, 251, 187, 201, 109, 168, 125, 7, 244, 118, 119, 210, 53, 238, 105, 138, 31, 7, 73, 30, 128, 131, 175, 114, 76, 187, 37, 0, 0, 0, 0, 106, 71, 48, 68, 2, 32, 2, 146, 73, 163, 223, 124, 140, 225, 109, 126, 239, 87, 105, 184, 118, 87, 182, 100, 182, 6, 15, 200, 26, 44, 33, 215, 165, 110, 211, 232, 245, 233, 2, 32, 69, 161, 168, 128, 101, 26, 171, 20, 63, 30, 219, 87, 23, 4, 142, 115, 73, 73, 170, 203, 46, 187, 149, 32, 210, 171, 46, 136, 253, 188, 36, 12, 1, 33, 2, 144, 231, 28, 153, 30, 92, 52, 10, 111, 47, 107, 74, 225, 237, 151, 33, 188, 184, 247, 121, 70, 135, 174, 31, 160, 16, 216, 239, 225, 103, 88, 112, 255, 255, 255, 255, 2, 64, 66, 15, 0, 0, 0, 0, 0, 2, 106, 0, 216, 154, 230, 5, 0, 0, 0, 0, 25, 118, 169, 20, 229, 154, 45, 140, 145, 114, 18, 52, 205, 13, 179, 84, 94, 174, 149, 207, 101, 115, 51, 240, 136, 172, 0, 0, 0, 0, 36, 1, 1, 64, 66, 15, 0, 0, 0, 0, 0, 25, 118, 169, 20, 176, 213, 107, 82, 203, 147, 209, 128, 255, 63, 69, 219, 41, 250, 232, 254, 185, 168, 85, 184, 136, 172],
120
+ // output index
121
+ 0
122
+ )
123
+
124
+ const transition = new wasm.IdentityTopUpTransitionWASM(assetLockProof, 'B7kcE1juMBWEWkuYRJhVdAE2e6RaevrGxRsa1DrLCpQH', 11)
125
+
126
+ transition.signature = Uint8Array.from([1, 1, 1])
127
+
128
+ assert.deepEqual(transition.signature, Uint8Array.from([1, 1, 1]))
129
+ })
130
+ })
131
+ })
@@ -0,0 +1,147 @@
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('IdentityUpdateTransition', function () {
8
+ before(async function () {
9
+ wasm = initWasm()
10
+ })
11
+
12
+ describe('serialization / deserialization', function () {
13
+ it('Should create IdentityUpdateTransition', function () {
14
+ const transition = new wasm.IdentityUpdateTransitionWASM('GL2Rq8L3VuBEQfCAZykmUaiXXrsd1Bwub2gcaMmtNbn3', BigInt(1), BigInt(1), 1, [], [])
15
+
16
+ assert.notEqual(transition.__wbg_ptr, 0)
17
+ })
18
+
19
+ it('Should create IdentityUpdateTransition with key', function () {
20
+ const key = new wasm.IdentityPublicKeyInCreationWASM(
21
+ 1, 'system', 'master', 'ECDSA_SECP256K1', false, [], []
22
+ )
23
+
24
+ const transition = new wasm.IdentityUpdateTransitionWASM('GL2Rq8L3VuBEQfCAZykmUaiXXrsd1Bwub2gcaMmtNbn3', BigInt(1), BigInt(1), 1, [key], [])
25
+
26
+ assert.notEqual(transition.__wbg_ptr, 0)
27
+ assert.notEqual(key.__wbg_ptr, 0)
28
+ })
29
+ })
30
+
31
+ describe('getters', function () {
32
+ it('Should return revision', function () {
33
+ const transition = new wasm.IdentityUpdateTransitionWASM('GL2Rq8L3VuBEQfCAZykmUaiXXrsd1Bwub2gcaMmtNbn3', BigInt(1), BigInt(1), 1, [], [])
34
+
35
+ assert.deepEqual(transition.revision, BigInt(1))
36
+ })
37
+
38
+ it('Should return nonce', function () {
39
+ const transition = new wasm.IdentityUpdateTransitionWASM('GL2Rq8L3VuBEQfCAZykmUaiXXrsd1Bwub2gcaMmtNbn3', BigInt(1), BigInt(1), 1, [], [])
40
+
41
+ assert.deepEqual(transition.nonce, BigInt(1))
42
+ })
43
+
44
+ it('Should return identityIdentifier', function () {
45
+ const transition = new wasm.IdentityUpdateTransitionWASM('GL2Rq8L3VuBEQfCAZykmUaiXXrsd1Bwub2gcaMmtNbn3', BigInt(1), BigInt(1), 1, [], [])
46
+
47
+ assert.deepEqual(transition.identityIdentifier.base58(), 'GL2Rq8L3VuBEQfCAZykmUaiXXrsd1Bwub2gcaMmtNbn3')
48
+ })
49
+
50
+ it('Should return publicKeyIdsToDisable', function () {
51
+ const transition = new wasm.IdentityUpdateTransitionWASM('GL2Rq8L3VuBEQfCAZykmUaiXXrsd1Bwub2gcaMmtNbn3', BigInt(1), BigInt(1), 1, [], [11])
52
+
53
+ assert.deepEqual(Array.from(transition.publicKeyIdsToDisable), [11])
54
+ })
55
+
56
+ it('Should return publicKeyIdsToAdd', function () {
57
+ const key = new wasm.IdentityPublicKeyInCreationWASM(
58
+ 1, 'system', 'master', 'ECDSA_SECP256K1', false, [], []
59
+ )
60
+
61
+ const transition = new wasm.IdentityUpdateTransitionWASM('GL2Rq8L3VuBEQfCAZykmUaiXXrsd1Bwub2gcaMmtNbn3', BigInt(1), BigInt(1), 1, [key], [11])
62
+
63
+ assert.deepEqual(transition.publicKeyIdsToAdd.length, 1)
64
+ })
65
+
66
+ it('Should return userFeeIncrease', function () {
67
+ const transition = new wasm.IdentityUpdateTransitionWASM('GL2Rq8L3VuBEQfCAZykmUaiXXrsd1Bwub2gcaMmtNbn3', BigInt(1), BigInt(1), 1, [], [11])
68
+
69
+ assert.deepEqual(transition.userFeeIncrease, 1)
70
+ })
71
+
72
+ it('Should return signature', function () {
73
+ const transition = new wasm.IdentityUpdateTransitionWASM('GL2Rq8L3VuBEQfCAZykmUaiXXrsd1Bwub2gcaMmtNbn3', BigInt(1), BigInt(1), 1, [], [11])
74
+
75
+ assert.deepEqual(transition.signature, Uint8Array.from([]))
76
+ })
77
+
78
+ it('Should return signature public key id', function () {
79
+ const transition = new wasm.IdentityUpdateTransitionWASM('GL2Rq8L3VuBEQfCAZykmUaiXXrsd1Bwub2gcaMmtNbn3', BigInt(1), BigInt(1), 1, [], [11])
80
+
81
+ assert.deepEqual(transition.signaturePublicKeyId, 0)
82
+ })
83
+ })
84
+
85
+ describe('setters', function () {
86
+ it('Should allow to set identityIdentifier', function () {
87
+ const transition = new wasm.IdentityUpdateTransitionWASM('GL2Rq8L3VuBEQfCAZykmUaiXXrsd1Bwub2gcaMmtNbn3', BigInt(1), BigInt(1), 1, [], [11])
88
+
89
+ transition.identityIdentifier = '11Rq8L3VuBEQfCAZykmUaiXXrsd1Bwub2gcaMmtNbn3'
90
+
91
+ assert.deepEqual(transition.identityIdentifier.base58(), '11Rq8L3VuBEQfCAZykmUaiXXrsd1Bwub2gcaMmtNbn3')
92
+ })
93
+
94
+ it('Should allow to set revision', function () {
95
+ const transition = new wasm.IdentityUpdateTransitionWASM('GL2Rq8L3VuBEQfCAZykmUaiXXrsd1Bwub2gcaMmtNbn3', BigInt(1), BigInt(1), 1, [], [11])
96
+
97
+ transition.revision = BigInt(11111)
98
+
99
+ assert.deepEqual(transition.revision, BigInt(11111))
100
+ })
101
+
102
+ it('Should allow to set nonce', function () {
103
+ const transition = new wasm.IdentityUpdateTransitionWASM('GL2Rq8L3VuBEQfCAZykmUaiXXrsd1Bwub2gcaMmtNbn3', BigInt(1), BigInt(1), 1, [], [11])
104
+
105
+ transition.nonce = BigInt(11111)
106
+
107
+ assert.deepEqual(transition.nonce, BigInt(11111))
108
+ })
109
+
110
+ it('Should allow to set publicKeyIdsToDisable', function () {
111
+ const transition = new wasm.IdentityUpdateTransitionWASM('GL2Rq8L3VuBEQfCAZykmUaiXXrsd1Bwub2gcaMmtNbn3', BigInt(1), BigInt(1), 1, [], [11])
112
+
113
+ transition.publicKeyIdsToDisable = [1, 2, 3, 4]
114
+
115
+ assert.deepEqual(transition.publicKeyIdsToDisable, Uint32Array.from([1, 2, 3, 4]))
116
+ })
117
+
118
+ it('Should allow to set publicKeyIdsToAdd', function () {
119
+ const transition = new wasm.IdentityUpdateTransitionWASM('GL2Rq8L3VuBEQfCAZykmUaiXXrsd1Bwub2gcaMmtNbn3', BigInt(1), BigInt(1), 1, [], [11])
120
+
121
+ const key = new wasm.IdentityPublicKeyInCreationWASM(
122
+ 1, 'system', 'master', 'ECDSA_SECP256K1', false, [], []
123
+ )
124
+
125
+ transition.publicKeyIdsToAdd = [key, key]
126
+
127
+ assert.deepEqual(transition.publicKeyIdsToAdd.length, 2)
128
+ assert.notEqual(key.__wbg_ptr, 0)
129
+ })
130
+
131
+ it('Should allow to set signature', function () {
132
+ const transition = new wasm.IdentityUpdateTransitionWASM('GL2Rq8L3VuBEQfCAZykmUaiXXrsd1Bwub2gcaMmtNbn3', BigInt(1), BigInt(1), 1, [], [11])
133
+
134
+ transition.signature = [0, 1, 2, 3, 5]
135
+
136
+ assert.deepEqual(transition.signature, Uint8Array.from([0, 1, 2, 3, 5]))
137
+ })
138
+
139
+ it('Should allow to set signature public key id', function () {
140
+ const transition = new wasm.IdentityUpdateTransitionWASM('GL2Rq8L3VuBEQfCAZykmUaiXXrsd1Bwub2gcaMmtNbn3', BigInt(1), BigInt(1), 1, [], [11])
141
+
142
+ transition.signaturePublicKeyId = 11
143
+
144
+ assert.deepEqual(transition.signaturePublicKeyId, 11)
145
+ })
146
+ })
147
+ })
@@ -0,0 +1,97 @@
1
+ const assert = require('assert')
2
+ const { describe, it, before } = require('mocha')
3
+ const initWasm = require('./utils/wasm')
4
+ const { instantLockBytes, transactionBytes } = require('./mocks/Locks')
5
+
6
+ let wasm
7
+
8
+ describe('InstantLock', function () {
9
+ before(async function () {
10
+ wasm = initWasm()
11
+ })
12
+
13
+ describe('serialization / deserialization', function () {
14
+ it('should allow to create InstantLock from values', () => {
15
+ const instantLockProof = new wasm.InstantAssetLockProofWASM(instantLockBytes, transactionBytes, 0)
16
+
17
+ assert.notEqual(instantLockProof.__wbg_ptr, 0)
18
+ })
19
+
20
+ it('should allow to convert to object', () => {
21
+ const instantLockProof = new wasm.InstantAssetLockProofWASM(instantLockBytes, transactionBytes, 0)
22
+
23
+ const expected = {
24
+ instantLock: instantLockBytes,
25
+ transaction: transactionBytes,
26
+ outputIndex: 0
27
+ }
28
+
29
+ assert.deepEqual(instantLockProof.toObject(), expected)
30
+ })
31
+
32
+ it('should allow to create from object', () => {
33
+ const lockObject = {
34
+ instantLock: instantLockBytes,
35
+ transaction: transactionBytes,
36
+ outputIndex: 0
37
+ }
38
+
39
+ const instantLockProof = wasm.InstantAssetLockProofWASM.fromObject(lockObject)
40
+
41
+ assert.notEqual(instantLockProof.__wbg_ptr, 0)
42
+ })
43
+ })
44
+
45
+ describe('getters', function () {
46
+ it('should allow to get output', () => {
47
+ const instantLockProof = new wasm.InstantAssetLockProofWASM(instantLockBytes, transactionBytes, 0)
48
+
49
+ assert.deepEqual(instantLockProof.getOutput().constructor.name, 'TxOutWASM')
50
+ })
51
+
52
+ it('should allow to convert to get OutPoint', () => {
53
+ const instantLockProof = new wasm.InstantAssetLockProofWASM(instantLockBytes, transactionBytes, 0)
54
+
55
+ assert.deepEqual(instantLockProof.getOutPoint().constructor.name, 'OutPointWASM')
56
+ })
57
+
58
+ it('should allow to get output index', () => {
59
+ const instantLockProof = new wasm.InstantAssetLockProofWASM(instantLockBytes, transactionBytes, 0)
60
+
61
+ assert.deepEqual(instantLockProof.outputIndex, 0)
62
+ })
63
+
64
+ it('should allow to get instant lock', () => {
65
+ const instantLockProof = new wasm.InstantAssetLockProofWASM(instantLockBytes, transactionBytes, 0)
66
+
67
+ assert.deepEqual(instantLockProof.instantLock.constructor.name, 'InstantLockWASM')
68
+ })
69
+ })
70
+
71
+ describe('setters', function () {
72
+ it('should allow to set output index', () => {
73
+ const instantLockProof = new wasm.InstantAssetLockProofWASM(instantLockBytes, transactionBytes, 0)
74
+
75
+ instantLockProof.outputIndex = 12
76
+
77
+ assert.deepEqual(instantLockProof.outputIndex, 12)
78
+ })
79
+
80
+ it('should allow to set instant lock', () => {
81
+ const instantLockProof = new wasm.InstantAssetLockProofWASM(instantLockBytes, transactionBytes, 0)
82
+
83
+ const newInstantLockProof = new wasm.InstantLockWASM(
84
+ 0,
85
+ [],
86
+ 'dbdb604952d08184b55d48c915ed78aadc81dbc5cc98e8b4821abe5b4bbcbecb',
87
+ '00000000000000151e0fe3ab9a12c57402153c9f476236148364ec4337213101',
88
+ 'a9f131626c49a2f183b7a2f563ad1dc50ac8220190dbedb805209b608eb864e01d62f18bc9faa60a8b8a27f5a0c7c8b914fa3a14360a2f25558ee0e0a693b18faccbb59ec39b9b3cae430e0b76eb080752ce103df76537a1a583680a5914529d'
89
+ )
90
+
91
+ instantLockProof.instantLock = newInstantLockProof
92
+
93
+ assert.deepEqual(instantLockProof.instantLock.version, 0)
94
+ assert.notEqual(newInstantLockProof.__wbg_ptr, 0)
95
+ })
96
+ })
97
+ })
@@ -0,0 +1,55 @@
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('OutPoint', function () {
8
+ before(async function () {
9
+ wasm = initWasm()
10
+ })
11
+
12
+ describe('serialization / deserialization', function () {
13
+ it('should allow to create from values', () => {
14
+ const outpoint = new wasm.OutPointWASM('e8b43025641eea4fd21190f01bd870ef90f1a8b199d8fc3376c5b62c0b1a179d', 1)
15
+
16
+ assert.notEqual(outpoint.__wbg_ptr, 0)
17
+ })
18
+
19
+ it('should allow to create from bytes', () => {
20
+ const txIdBytes = Buffer.from('e8b43025641eea4fd21190f01bd870ef90f1a8b199d8fc3376c5b62c0b1a179d', 'hex')
21
+
22
+ // 32 bytes for txId and 4 bytes for vout
23
+ const bytes = [...txIdBytes.reverse(), ...[0, 0, 0, 1].reverse()]
24
+
25
+ const outpoint = wasm.OutPointWASM.fromBytes(bytes)
26
+
27
+ assert.notEqual(outpoint.__wbg_ptr, 0)
28
+ })
29
+ })
30
+
31
+ describe('getters', function () {
32
+ it('should allow to get txid', function () {
33
+ const outpoint = new wasm.OutPointWASM('e8b43025641eea4fd21190f01bd870ef90f1a8b199d8fc3376c5b62c0b1a179d', 1)
34
+
35
+ assert.equal(outpoint.getTXID(), 'e8b43025641eea4fd21190f01bd870ef90f1a8b199d8fc3376c5b62c0b1a179d')
36
+ })
37
+
38
+ it('should allow to get VOUT', function () {
39
+ const outpoint = new wasm.OutPointWASM('e8b43025641eea4fd21190f01bd870ef90f1a8b199d8fc3376c5b62c0b1a179d', 1)
40
+
41
+ assert.equal(outpoint.getVOUT(), 1)
42
+ })
43
+
44
+ it('should allow to get bytes', function () {
45
+ const outpoint = new wasm.OutPointWASM('e8b43025641eea4fd21190f01bd870ef90f1a8b199d8fc3376c5b62c0b1a179d', 1)
46
+
47
+ const txIdBytes = Buffer.from('e8b43025641eea4fd21190f01bd870ef90f1a8b199d8fc3376c5b62c0b1a179d', 'hex')
48
+
49
+ // 32 bytes for txId and 4 bytes for vout
50
+ const bytes = [...txIdBytes.reverse(), ...[0, 0, 0, 1].reverse()]
51
+
52
+ assert.deepEqual(outpoint.toBytes(), Uint8Array.from(bytes))
53
+ })
54
+ })
55
+ })
@@ -0,0 +1,73 @@
1
+ const assert = require('assert')
2
+ const { describe, it, before } = require('mocha')
3
+ const initWasm = require('./utils/wasm')
4
+ const { wif, bytes, publicKeyHash } = require('./mocks/PrivateKey')
5
+ const { fromHexString, toHexString } = require('./utils/hex')
6
+
7
+ let wasm
8
+
9
+ describe('PrivateKey', function () {
10
+ before(async function () {
11
+ wasm = initWasm()
12
+ })
13
+
14
+ describe('serialization / deserialization', function () {
15
+ it('should allows to create PrivateKey from wif', function () {
16
+ const pkey = wasm.PrivateKeyWASM.fromWIF(wif)
17
+
18
+ assert.notEqual(pkey.__wbg_ptr, 0)
19
+ })
20
+
21
+ it('should allows to create PrivateKey from bytes', function () {
22
+ const pkey = wasm.PrivateKeyWASM.fromBytes(fromHexString(bytes), 'Mainnet')
23
+
24
+ assert.notEqual(pkey.__wbg_ptr, 0)
25
+ })
26
+
27
+ it('should allows to create PrivateKey from hex', function () {
28
+ const pkey = wasm.PrivateKeyWASM.fromBytes(fromHexString(bytes), 'Mainnet')
29
+
30
+ const pkeyFromHex = wasm.PrivateKeyWASM.fromHex(bytes, 'Mainnet')
31
+
32
+ assert.deepEqual(pkey.getBytes(), pkeyFromHex.getBytes())
33
+ })
34
+
35
+ it('should allow to create PrivateKey from wif and read value in wif', function () {
36
+ const pkey = wasm.PrivateKeyWASM.fromWIF(wif)
37
+
38
+ assert.equal(pkey.getWIF(), wif)
39
+ })
40
+
41
+ it('should allow to create PrivateKey from wif and write value in bytes', function () {
42
+ const pkey = wasm.PrivateKeyWASM.fromWIF(wif)
43
+
44
+ assert.deepEqual(pkey.getBytes(), fromHexString(bytes))
45
+ })
46
+ })
47
+
48
+ describe('getters', function () {
49
+ it('should allow to get key wif', function () {
50
+ const pkey = wasm.PrivateKeyWASM.fromWIF(wif)
51
+
52
+ assert.equal(pkey.getWIF(), wif)
53
+ })
54
+
55
+ it('should allow to get key bytes', function () {
56
+ const pkey = wasm.PrivateKeyWASM.fromWIF(wif)
57
+
58
+ assert.equal(toHexString(pkey.getBytes()), bytes)
59
+ })
60
+
61
+ it('should allow to get key hex', function () {
62
+ const pkey = wasm.PrivateKeyWASM.fromWIF(wif)
63
+
64
+ assert.equal(pkey.getHex().toLowerCase(), bytes)
65
+ })
66
+
67
+ it('should allow to get public key hash', function () {
68
+ const pkey = wasm.PrivateKeyWASM.fromWIF(wif)
69
+
70
+ assert.deepEqual(pkey.getPublicKeyHash(), publicKeyHash)
71
+ })
72
+ })
73
+ })