pshenmic-dpp 1.0.4 → 1.0.5
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/.github/workflows/build.yml +8 -0
- package/.github/workflows/publish.yml +8 -0
- package/Cargo.lock +79 -31
- package/Cargo.toml +20 -17
- package/README.md +66 -23
- package/babel.config.json +19 -0
- package/dist/wasm/pshenmic_dpp.js +2487 -355
- package/dist/wasm/pshenmic_dpp_bg.js +1 -1
- package/package.json +13 -6
- package/packages/cbor_conversation/Cargo.toml +1 -1
- package/packages/data_contract/Cargo.toml +2 -2
- package/packages/data_contract/src/lib.rs +195 -23
- package/packages/data_contract_transitions/Cargo.toml +1 -1
- package/packages/data_contract_transitions/src/create/mod.rs +23 -16
- package/packages/data_contract_transitions/src/update/mod.rs +21 -12
- package/packages/document/Cargo.toml +1 -1
- package/packages/document/src/lib.rs +1 -1
- package/packages/document/src/methods/mod.rs +370 -2
- package/packages/{document_batch → documents_batch}/Cargo.toml +6 -4
- package/packages/documents_batch/src/document_base_transition/mod.rs +92 -0
- package/packages/documents_batch/src/document_transition/mod.rs +166 -0
- package/packages/documents_batch/src/generators.rs +122 -0
- package/packages/documents_batch/src/lib.rs +188 -0
- package/packages/documents_batch/src/prefunded_voting_balance/mod.rs +45 -0
- package/packages/documents_batch/src/transitions/create/mod.rs +123 -0
- package/packages/documents_batch/src/transitions/delete/mod.rs +67 -0
- package/packages/documents_batch/src/transitions/mod.rs +6 -0
- package/packages/documents_batch/src/transitions/purchase/mod.rs +91 -0
- package/packages/documents_batch/src/transitions/replace/mod.rs +93 -0
- package/packages/documents_batch/src/transitions/transfer/mod.rs +86 -0
- package/packages/documents_batch/src/transitions/update_price/mod.rs +75 -0
- package/packages/enums/Cargo.toml +3 -3
- package/packages/enums/src/batch/batch_enum.rs +75 -10
- package/packages/enums/src/keys/key_type.rs +46 -0
- package/packages/enums/src/keys/purpose.rs +55 -0
- package/packages/enums/src/keys/security_level.rs +46 -0
- package/packages/enums/src/lib.rs +1 -0
- package/packages/enums/src/network/mod.rs +67 -0
- package/packages/enums/src/platform/mod.rs +66 -8
- package/packages/identity/Cargo.toml +3 -4
- package/packages/identity/src/lib.rs +25 -14
- package/packages/{public_key → identity_public_key}/Cargo.toml +1 -1
- package/packages/{public_key → identity_public_key}/src/lib.rs +74 -27
- package/packages/identity_transitions/Cargo.toml +2 -2
- package/packages/identity_transitions/src/create_transition/mod.rs +3 -1
- package/packages/identity_transitions/src/create_transition/public_key_in_creation/mod.rs +25 -21
- package/packages/mock_bls/Cargo.toml +1 -1
- package/packages/private_key/Cargo.toml +3 -2
- package/packages/private_key/src/lib.rs +44 -6
- package/packages/state_transition/Cargo.toml +5 -4
- package/packages/state_transition/src/lib.rs +101 -36
- package/packages/utils/Cargo.toml +1 -2
- package/packages/utils/src/lib.rs +17 -15
- package/scripts/build-js.sh +6 -5
- package/scripts/build.sh +22 -1
- package/src/lib.rs +7 -1
- package/tests/DataContract.spec.js +175 -0
- package/tests/DataContractCreateStateTransition.spec.js +109 -0
- package/tests/DataContractUpdateStateTransition.spec.js +109 -0
- package/tests/Document.spec.js +232 -0
- package/tests/DocumentBatchTransition.spec.js +109 -0
- package/tests/DocumentTransition.spec.js +97 -0
- package/tests/DocumentsTransitions.spec.js +705 -0
- package/tests/Identity.spec.js +113 -0
- package/tests/IdentityPublicKey.spec.js +132 -0
- package/tests/PrivateKey.spec.js +73 -0
- package/tests/mocks/DataContract/DataContract.json +153 -0
- package/tests/mocks/DataContract/index.js +6 -0
- package/tests/mocks/Document/DataContract.json +23 -0
- package/tests/mocks/Document/document.json +3 -0
- package/tests/mocks/Document/document2.json +3 -0
- package/tests/mocks/Document/index.js +11 -0
- package/tests/mocks/Identity/index.js +7 -0
- package/tests/mocks/PrivateKey/index.js +5 -0
- package/tests/mocks/PublicKey/index.js +14 -0
- package/tests/utils/hex.js +15 -0
- package/tests/utils/wasm.js +14 -0
- package/packages/document/src/methods/js.rs +0 -260
- package/packages/document/src/methods/rust.rs +0 -92
- package/packages/document_batch/src/generators.rs +0 -63
- package/packages/document_batch/src/lib.rs +0 -228
|
@@ -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(Array.from(identity.getId()), 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,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,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
|
+
})
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$format_version": "0",
|
|
3
|
+
"id": "4fJLR2GYTPFdomuTVvNy3VRrvWgvkKPzqehEBpNf2nk6",
|
|
4
|
+
"config": {
|
|
5
|
+
"$format_version": "0",
|
|
6
|
+
"canBeDeleted": false,
|
|
7
|
+
"readonly": false,
|
|
8
|
+
"keepsHistory": false,
|
|
9
|
+
"documentsKeepHistoryContractDefault": false,
|
|
10
|
+
"documentsMutableContractDefault": true,
|
|
11
|
+
"documentsCanBeDeletedContractDefault": true,
|
|
12
|
+
"requiresIdentityEncryptionBoundedKey": null,
|
|
13
|
+
"requiresIdentityDecryptionBoundedKey": null
|
|
14
|
+
},
|
|
15
|
+
"version": 1,
|
|
16
|
+
"ownerId": "11111111111111111111111111111111",
|
|
17
|
+
"schemaDefs": null,
|
|
18
|
+
"documentSchemas": {
|
|
19
|
+
"withdrawal": {
|
|
20
|
+
"description": "Withdrawal document to track underlying withdrawal transactions. Withdrawals should be created with IdentityWithdrawalTransition",
|
|
21
|
+
"creationRestrictionMode": 2,
|
|
22
|
+
"type": "object",
|
|
23
|
+
"indices": [
|
|
24
|
+
{
|
|
25
|
+
"name": "identityStatus",
|
|
26
|
+
"properties": [
|
|
27
|
+
{
|
|
28
|
+
"$ownerId": "asc"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"status": "asc"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"$createdAt": "asc"
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"unique": false
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"name": "identityRecent",
|
|
41
|
+
"properties": [
|
|
42
|
+
{
|
|
43
|
+
"$ownerId": "asc"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"$updatedAt": "asc"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"status": "asc"
|
|
50
|
+
}
|
|
51
|
+
],
|
|
52
|
+
"unique": false
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"name": "pooling",
|
|
56
|
+
"properties": [
|
|
57
|
+
{
|
|
58
|
+
"status": "asc"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"pooling": "asc"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"coreFeePerByte": "asc"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"$updatedAt": "asc"
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
"unique": false
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"name": "transaction",
|
|
74
|
+
"properties": [
|
|
75
|
+
{
|
|
76
|
+
"status": "asc"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"transactionIndex": "asc"
|
|
80
|
+
}
|
|
81
|
+
],
|
|
82
|
+
"unique": false
|
|
83
|
+
}
|
|
84
|
+
],
|
|
85
|
+
"properties": {
|
|
86
|
+
"transactionIndex": {
|
|
87
|
+
"type": "integer",
|
|
88
|
+
"description": "Sequential index of asset unlock (withdrawal) transaction. Populated when a withdrawal pooled into withdrawal transaction",
|
|
89
|
+
"minimum": 1,
|
|
90
|
+
"position": 0
|
|
91
|
+
},
|
|
92
|
+
"transactionSignHeight": {
|
|
93
|
+
"type": "integer",
|
|
94
|
+
"description": "The Core height on which transaction was signed",
|
|
95
|
+
"minimum": 1,
|
|
96
|
+
"position": 1
|
|
97
|
+
},
|
|
98
|
+
"amount": {
|
|
99
|
+
"type": "integer",
|
|
100
|
+
"description": "The amount to be withdrawn",
|
|
101
|
+
"minimum": 1000,
|
|
102
|
+
"position": 2
|
|
103
|
+
},
|
|
104
|
+
"coreFeePerByte": {
|
|
105
|
+
"type": "integer",
|
|
106
|
+
"description": "This is the fee that you are willing to spend for this transaction in Duffs/Byte",
|
|
107
|
+
"minimum": 1,
|
|
108
|
+
"maximum": 4294967295,
|
|
109
|
+
"position": 3
|
|
110
|
+
},
|
|
111
|
+
"pooling": {
|
|
112
|
+
"type": "integer",
|
|
113
|
+
"description": "This indicated the level at which Platform should try to pool this transaction",
|
|
114
|
+
"enum": [
|
|
115
|
+
0,
|
|
116
|
+
1,
|
|
117
|
+
2
|
|
118
|
+
],
|
|
119
|
+
"position": 4
|
|
120
|
+
},
|
|
121
|
+
"outputScript": {
|
|
122
|
+
"type": "array",
|
|
123
|
+
"byteArray": true,
|
|
124
|
+
"minItems": 23,
|
|
125
|
+
"maxItems": 25,
|
|
126
|
+
"position": 5
|
|
127
|
+
},
|
|
128
|
+
"status": {
|
|
129
|
+
"type": "integer",
|
|
130
|
+
"enum": [
|
|
131
|
+
0,
|
|
132
|
+
1,
|
|
133
|
+
2,
|
|
134
|
+
3,
|
|
135
|
+
4
|
|
136
|
+
],
|
|
137
|
+
"description": "0 - Pending, 1 - Signed, 2 - Broadcasted, 3 - Complete, 4 - Expired",
|
|
138
|
+
"position": 6
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
"additionalProperties": false,
|
|
142
|
+
"required": [
|
|
143
|
+
"$createdAt",
|
|
144
|
+
"$updatedAt",
|
|
145
|
+
"amount",
|
|
146
|
+
"coreFeePerByte",
|
|
147
|
+
"pooling",
|
|
148
|
+
"outputScript",
|
|
149
|
+
"status"
|
|
150
|
+
]
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
value: require('./DataContract.json'),
|
|
3
|
+
id: '4fJLR2GYTPFdomuTVvNy3VRrvWgvkKPzqehEBpNf2nk6',
|
|
4
|
+
ownerId: '11111111111111111111111111111111',
|
|
5
|
+
dataContractsBytes: ['00ea8920edea52fa400de2ccc43052b2821f45585241a2875d4250e35d4ce937c800000000000101000001ab321b19457b1c16b12762509276d47d952f582d978cbd8b50bbfc2fd8a7767d0001046e6f7465160312047479706512066f626a656374120a70726f70657274696573160112076d65737361676516021204747970651206737472696e671208706f736974696f6e030012146164646974696f6e616c50726f706572746965731300']
|
|
6
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$format_version": "0",
|
|
3
|
+
"version": 1,
|
|
4
|
+
"ownerId": "11111111111111111111111111111111",
|
|
5
|
+
"schemaDefs": null,
|
|
6
|
+
"id": "4fJLR2GYTPFdomuTVvNy3VRrvWgvkKPzqehEBpNf2nk6",
|
|
7
|
+
"documentSchemas": {
|
|
8
|
+
"note": {
|
|
9
|
+
"type": "object",
|
|
10
|
+
"properties": {
|
|
11
|
+
"author": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"position": 1
|
|
14
|
+
},
|
|
15
|
+
"message": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"position": 0
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"additionalProperties": false
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
document: require('./document.json'),
|
|
3
|
+
document2: require('./document2.json'),
|
|
4
|
+
dataContractValue: require('./DataContract.json'),
|
|
5
|
+
documentTypeName: 'note',
|
|
6
|
+
revision: BigInt(1),
|
|
7
|
+
dataContractId: 'GnXgMaiqAwTxh44ccQe8AoCgFvcseHK5CncH3sUorW4X',
|
|
8
|
+
ownerId: 'CXH2kZCATjvDTnQAPVg28EgPg9WySUvwvnR5ZkmNqY5i',
|
|
9
|
+
id: '9tSsCqKHTZ8ro16MydChSxgHBukFW36eMLJKKRtebJEn',
|
|
10
|
+
documentBytes: '00840b5cec9f0401b1950610e85dcb26829122ac8853464e1e2c7e38ed22b48903ab321b19457b1c16b12762509276d47d952f582d978cbd8b50bbfc2fd8a7767d01000001305475746f7269616c20434920546573742040205475652c203037204a616e20323032352031353a32373a353020474d5400'
|
|
11
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
identifier: 'H2pb35GtKpjLinncBYeMsXkdDYXCbsFzzVmssce6pSJ1',
|
|
3
|
+
identifierBytes: [238, 50, 96, 211, 63, 140, 169, 225, 76, 97, 8, 6, 212, 109, 184, 253, 51, 67, 82, 42, 208, 228, 72, 192, 215, 137, 161, 88, 144, 55, 244, 230],
|
|
4
|
+
balance: BigInt(100),
|
|
5
|
+
revision: BigInt(99111),
|
|
6
|
+
identityBytesWithoutKeys: [0, 238, 50, 96, 211, 63, 140, 169, 225, 76, 97, 8, 6, 212, 109, 184, 253, 51, 67, 82, 42, 208, 228, 72, 192, 215, 137, 161, 88, 144, 55, 244, 230, 0, 0, 0]
|
|
7
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const { Purpose, SecurityLevel, KeyType } = require('../../../dist/cjs/wasm/pshenmic_dpp')
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
keyId: 2,
|
|
5
|
+
purpose: Purpose.AUTHENTICATION,
|
|
6
|
+
securityLevel: SecurityLevel.CRITICAL,
|
|
7
|
+
keyType: KeyType.ECDSA_SECP256K1,
|
|
8
|
+
binaryData: '036a394312e40e81d928fde2bde7880070e4fa9c1d1d9b168da707ea468afa2b48',
|
|
9
|
+
keyIdSet: 3,
|
|
10
|
+
purposeSet: Purpose.ENCRYPTION,
|
|
11
|
+
securityLevelSet: SecurityLevel.HIGH,
|
|
12
|
+
keyTypeSet: KeyType.ECDSA_HASH160,
|
|
13
|
+
binaryDataSet: '0300000002e40e81d928fde2bde7880070e4fa9c1d1d9b168da707ea468afa2b48'
|
|
14
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
toHexString: (byteArray) => {
|
|
3
|
+
return Array.prototype.map.call(byteArray, function (byte) {
|
|
4
|
+
return ('0' + (byte & 0xFF).toString(16)).slice(-2)
|
|
5
|
+
}).join('')
|
|
6
|
+
},
|
|
7
|
+
fromHexString: (str) => {
|
|
8
|
+
const bytes = []
|
|
9
|
+
for (let i = 0; i < str.length; i += 2) {
|
|
10
|
+
bytes.push(parseInt(str.slice(i, i + 2), 16))
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return Uint8Array.from(bytes)
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const wasm = require('../../dist/cjs/wasm/pshenmic_dpp')
|
|
2
|
+
const { default: wasmBytes } = require('../../dist/cjs/wasm/pshenmic_dpp_bg')
|
|
3
|
+
|
|
4
|
+
module.exports = () => {
|
|
5
|
+
const binaryString = atob(wasmBytes)
|
|
6
|
+
const bytes = new Uint8Array(binaryString.length)
|
|
7
|
+
for (let i = 0; i < binaryString.length; i++) {
|
|
8
|
+
bytes[i] = binaryString.charCodeAt(i)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
wasm.initSync({ module: bytes.buffer })
|
|
12
|
+
|
|
13
|
+
return wasm
|
|
14
|
+
}
|