@dashevo/wasm-dpp 0.24.0-dev.11 → 0.24.0-dev.13
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/Cargo.toml +3 -0
- package/README.md +5 -1
- package/dist/index.js +1 -1
- package/dist/index.js.LICENSE.txt +9 -0
- package/dist/lib/dpp.d.ts +9 -0
- package/dist/lib/errors/AbstractConsensusError.d.ts +10 -0
- package/dist/lib/errors/DPPError.d.ts +5 -0
- package/dist/lib/errors/patchConsensusErrors.d.ts +1 -0
- package/dist/lib/{patchIdentifier.d.ts → identifier/patchIdentifier.d.ts} +1 -1
- package/dist/{index.d.ts → lib/index.d.ts} +1 -1
- package/dist/lib/utils/extend.d.ts +1 -0
- package/dist/wasm/wasm_dpp.d.ts +1595 -518
- package/karma.conf.js +5 -0
- package/lib/dpp.ts +24 -0
- package/lib/errors/AbstractConsensusError.ts +13 -0
- package/lib/errors/DPPError.ts +15 -0
- package/lib/errors/patchConsensusErrors.ts +175 -0
- package/lib/{patchIdentifier.ts → identifier/patchIdentifier.ts} +6 -5
- package/{index.ts → lib/index.ts} +5 -4
- package/lib/test/bootstrap.js +5 -0
- package/lib/test/expect/expectError.js +4 -2
- package/lib/test/mocks/getBlsAdapterMock.js +36 -0
- package/lib/test/utils/newDocumentsContainer.js +36 -0
- package/lib/utils/extend.ts +6 -0
- package/package.json +9 -6
- package/src/bls_adapter.rs +16 -1
- package/src/data_contract/data_contract.rs +35 -7
- package/src/data_contract/errors/invalid_data_contract.rs +21 -0
- package/src/data_contract/errors/invalid_document_type.rs +1 -1
- package/src/data_contract/index.rs +56 -1
- package/src/data_contract/mod.rs +1 -0
- package/src/data_contract/state_transition/data_contract_create_transition/mod.rs +6 -8
- package/src/data_contract/state_transition/data_contract_create_transition/validation.rs +4 -4
- package/src/data_contract/state_transition/data_contract_update_transition/apply.rs +44 -0
- package/src/data_contract/state_transition/data_contract_update_transition/mod.rs +145 -0
- package/src/data_contract/state_transition/data_contract_update_transition/validation.rs +49 -0
- package/src/data_contract/state_transition/mod.rs +2 -0
- package/src/data_contract_factory/data_contract_factory.rs +25 -12
- package/src/document/errors/invalid_document_error.rs +10 -9
- package/src/document/errors/invalid_initial_revision_error.rs +1 -1
- package/src/document/errors/mismatch_owners_ids_error.rs +14 -4
- package/src/document/errors/mod.rs +17 -13
- package/src/document/errors/no_documents_supplied_error.rs +4 -4
- package/src/document/factory.rs +192 -0
- package/src/document/mod.rs +222 -30
- package/src/document/state_transition/document_batch_transition/document_transition/document_create_transition.rs +47 -1
- package/src/document/state_transition/document_batch_transition/document_transition/document_delete_transition.rs +25 -1
- package/src/document/state_transition/document_batch_transition/document_transition/document_replace_transition.rs +65 -0
- package/src/document/state_transition/document_batch_transition/document_transition/mod.rs +123 -3
- package/src/document/state_transition/document_batch_transition/mod.rs +378 -0
- package/src/document/validator.rs +30 -0
- package/src/errors/consensus/basic/data_contract/data_contract_max_depth_exceed_error.rs +5 -5
- package/src/errors/consensus/basic/document/duplicate_document_transitions_with_ids_error.rs +4 -4
- package/src/errors/consensus/basic/document/duplicate_document_transitions_with_indices_error.rs +36 -0
- package/src/errors/consensus/basic/document/missing_document_transition_type_error.rs +20 -0
- package/src/errors/consensus/basic/document/mod.rs +4 -0
- package/src/errors/consensus/basic/identity/duplicated_identity_public_key_error.rs +2 -2
- package/src/errors/consensus/basic/identity/duplicated_identity_public_key_id_error.rs +2 -2
- package/src/errors/consensus/basic/identity/identity_asset_lock_proof_locked_transaction_mismatch_error.rs +6 -2
- package/src/errors/consensus/basic/identity/identity_asset_lock_transaction_out_point_already_exists_error.rs +5 -2
- package/src/errors/consensus/basic/identity/invalid_asset_lock_proof_transaction_height_error.rs +3 -3
- package/src/errors/consensus/basic/identity/invalid_identity_public_key_security_level_error.rs +2 -2
- package/src/errors/consensus/basic/json_schema_error.rs +1 -1
- package/src/errors/consensus_error.rs +15 -8
- package/src/errors/dpp_error.rs +17 -0
- package/src/errors/from.rs +6 -1
- package/src/errors/js_conversion.rs +19 -4
- package/src/errors/mod.rs +3 -0
- package/src/errors/protocol_error.rs +15 -0
- package/src/{identifier.rs → identifier/mod.rs} +48 -3
- package/src/identity/errors/asset_lock_output_not_found_error.rs +11 -0
- package/src/identity/errors/asset_lock_transaction_is_not_found_error.rs +20 -0
- package/src/identity/errors/mod.rs +7 -0
- package/src/identity/errors/unknown_asset_lock_proof_type_error.rs +26 -0
- package/src/{identity_facade.rs → identity/identity_facade.rs} +3 -5
- package/src/{identity_public_key → identity/identity_public_key}/key_type.rs +0 -0
- package/src/{identity_public_key → identity/identity_public_key}/mod.rs +41 -10
- package/src/{identity_public_key → identity/identity_public_key}/purpose.rs +0 -0
- package/src/{identity_public_key → identity/identity_public_key}/security_level.rs +0 -0
- package/src/{identity.rs → identity/mod.rs} +20 -12
- package/src/identity/state_transition/asset_lock_proof/chain/chain_asset_lock_proof.rs +132 -0
- package/src/identity/state_transition/asset_lock_proof/chain/chain_asset_lock_proof_structure_validator.rs +72 -0
- package/src/identity/state_transition/asset_lock_proof/chain/mod.rs +4 -0
- package/src/identity/state_transition/asset_lock_proof/instant/instant_asset_lock_proof.rs +177 -0
- package/src/identity/state_transition/asset_lock_proof/instant/instant_asset_lock_proof_structure_validator.rs +72 -0
- package/src/identity/state_transition/asset_lock_proof/instant/mod.rs +4 -0
- package/src/identity/state_transition/asset_lock_proof/mod.rs +269 -0
- package/src/identity/state_transition/identity_create_transition/apply_identity_create_transition.rs +26 -0
- package/src/identity/state_transition/identity_create_transition/identity_create_transition.rs +335 -0
- package/src/identity/state_transition/identity_create_transition/identity_create_transition_basic_validator.rs +153 -0
- package/src/identity/state_transition/identity_create_transition/identity_create_transition_state_validator.rs +37 -0
- package/src/identity/state_transition/identity_create_transition/mod.rs +8 -0
- package/src/identity/state_transition/identity_create_transition/to_object.rs +46 -0
- package/src/identity/state_transition/identity_topup_transition/apply_identity_topup_transition.rs +31 -0
- package/src/identity/state_transition/identity_topup_transition/identity_topup_transition.rs +280 -0
- package/src/identity/state_transition/identity_topup_transition/identity_topup_transition_basic_validator.rs +113 -0
- package/src/identity/state_transition/identity_topup_transition/identity_topup_transition_state_validator.rs +37 -0
- package/src/identity/state_transition/identity_topup_transition/mod.rs +8 -0
- package/src/identity/state_transition/identity_topup_transition/to_object.rs +42 -0
- package/src/identity/state_transition/mod.rs +9 -0
- package/src/identity/state_transition/validate_public_key_signatures.rs +59 -0
- package/src/identity/validation/mod.rs +3 -0
- package/src/identity/validation/public_keys_validator.rs +76 -0
- package/src/identity_public_key/public_keys_validator.rs +1 -1
- package/src/lib.rs +3 -6
- package/src/lodash.rs +7 -0
- package/src/state_repository.rs +188 -36
- package/src/state_transition/mod.rs +12 -0
- package/src/utils.rs +102 -7
- package/src/validation/json_schema_validator.rs +41 -0
- package/src/validation/mod.rs +5 -0
- package/src/{validation_result.rs → validation/validation_result.rs} +23 -5
- package/src/version/mod.rs +2 -0
- package/src/version/protocol_version.rs +26 -0
- package/test/integration/dataContract/validation/validateDataContractFactory.spec.js +579 -502
- package/test/integration/identity/stateTransition/IdentityCreateTransition/validation/basic/validateIdentityCreateTransitionBasicFactory.spec.js +175 -165
- package/test/integration/identity/stateTransition/IdentityTopUpTransition/validation/basic/validateIdentityTopUpTransitionBasicFactory.spec.js +83 -114
- package/test/integration/identity/stateTransition/IdentityUpdateTransition/validation/state/validateIdentityUpdateTransitionStateFactory.spec.js +1 -1
- package/test/integration/identity/stateTransition/assetLockProof/chain/validateChainAssetLockProofStructureFactory.spec.js +82 -91
- package/test/integration/identity/stateTransition/assetLockProof/fetchAssetLockTransactionOutputFactory.spec.js +75 -31
- package/test/integration/identity/stateTransition/assetLockProof/instant/validateInstantAssetLockProofStructureFactory.spec.js +93 -148
- package/test/integration/identity/stateTransition/assetLockProof/validateAssetLockTransactionFactory.spec.js +63 -75
- package/test/integration/identity/stateTransition/validatePublicKeySignaturesFactory.spec.js +48 -19
- package/test/integration/identity/validation/validatePublicKeysFactory.spec.js +79 -114
- package/test/integration/stateTransition/AbstractStateTransitionIdentitySigned.spec.js +0 -11
- package/test/integration/stateTransition/StateTransitionFacade.spec.js +1 -1
- package/test/integration/stateTransition/calculateStateTransitionFeeFactory.spec.js +135 -0
- package/test/unit/dataContract/DataContract.spec.js +5 -9
- package/test/unit/dataContract/DataContractFactory.spec.js +13 -6
- package/test/unit/dataContract/createDataContract.spec.js +0 -1
- package/test/unit/dataContract/errors/InvalidDataContractError.spec.js +11 -3
- package/test/unit/dataContract/stateTransition/DataContractCreateTransition/DataContractCreateTransition.spec.js +3 -3
- package/test/unit/dataContract/stateTransition/DataContractCreateTransition/validation/state/validateDataContractCreateTransitionStateFactory.spec.js +20 -16
- package/test/unit/dataContract/stateTransition/DataContractUpdateTransition/DataContractUpdateTransition.spec.js +24 -60
- package/test/unit/dataContract/stateTransition/DataContractUpdateTransition/applyDataContractUpdateTransitionFactory.spec.js +27 -23
- package/test/unit/dataContract/stateTransition/DataContractUpdateTransition/validation/basic/validateIndicesAreBackwardCompatible.spec.js +29 -12
- package/test/unit/dataContract/stateTransition/DataContractUpdateTransition/validation/state/validateDataContractUpdateTransitionStateFactory.spec.js +66 -49
- package/test/unit/dataContract/validation/validateDataContractPatterns.spec.js +73 -0
- package/test/unit/decodeProtocolEntityFactory.spec.js +2 -2
- package/test/unit/document/Document.spec.js +147 -155
- package/test/unit/document/DocumentFactory.spec.js +325 -91
- package/test/unit/document/stateTransition/DocumetsBatchTransition/DocumentsBatchTransition.spec.js +142 -64
- package/test/unit/document/stateTransition/DocumetsBatchTransition/applyDocumentsBatchTransitionFactory.spec.js +1 -1
- package/test/unit/document/stateTransition/DocumetsBatchTransition/validation/state/validateDocumentsBatchTransitionStateFactory.spec.js +1 -1
- package/test/unit/identity/Identity.spec.js +2 -2
- package/test/unit/identity/IdentityPublicKey.spec.js +25 -31
- package/test/unit/identity/stateTransition/IdentityCreateTransition/IdentityCreateTransition.spec.js +69 -30
- package/test/unit/identity/stateTransition/IdentityCreateTransition/applyIdentityCreateTransitionFactory.spec.js +32 -32
- package/test/unit/identity/stateTransition/IdentityCreateTransition/validation/state/validateIdentityCreateTransitionStateFactory.spec.js +56 -25
- package/test/unit/identity/stateTransition/IdentityTopUpTransition/IdentityTopUpTransition.spec.js +36 -16
- package/test/unit/identity/stateTransition/IdentityTopUpTransition/applyIdentityTopUpTransitionFactory.spec.js +48 -46
- package/test/unit/identity/stateTransition/IdentityTopUpTransition/validation/state/validateIdentityTopUpTransitionStateFactory.spec.js +24 -6
- package/test/unit/identity/stateTransition/assetLockProof/ChainAssetLockProof.spec.js +63 -0
- package/test/unit/identity/stateTransition/assetLockProof/InstantAssetLockProof.spec.js +90 -0
- package/test/unit/identity/stateTransition/assetLockProof/createAssetLockProofInstance.spec.js +18 -3
- package/test/unit/identity/stateTransition/assetLockProof/fetchAssetLockPublicKeyHashFactory.spec.js +38 -11
- package/tsconfig.json +1 -1
- package/wasm/package.json +5 -0
- package/wasm/wasm_dpp.d.ts +1595 -518
- package/wasm/wasm_dpp.js +5007 -2172
- package/wasm/wasm_dpp_bg.js +1 -1
- package/wasm/wasm_dpp_bg.wasm +0 -0
- package/wasm/wasm_dpp_bg.wasm.d.ts +566 -365
- package/webpack.config.js +10 -1
- package/test/integration/stateTransition/calculateStateTransitionFee.spec.js +0 -32
- package/test/unit/dataContract/validation/validateDataContractMaxDepthFactory.spec.js +0 -93
- package/test/unit/dataContract/validation/validateDataContractPatternsFactory.spec.js +0 -64
package/karma.conf.js
CHANGED
package/lib/dpp.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as dpp_module from '../wasm/wasm_dpp';
|
|
2
|
+
import { patchConsensusErrors } from './errors/patchConsensusErrors';
|
|
3
|
+
|
|
4
|
+
patchConsensusErrors();
|
|
5
|
+
|
|
6
|
+
// While we declared it above, those fields do not hold any values - let's assign them.
|
|
7
|
+
// We need to suppress the compiler here, as he won't be happy about those reassignments.
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
dpp_module.IdentityPublicKey.TYPES = dpp_module.KeyType;
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
dpp_module.IdentityPublicKey.PURPOSES = dpp_module.KeyPurpose;
|
|
12
|
+
// @ts-ignore
|
|
13
|
+
dpp_module.IdentityPublicKey.SECURITY_LEVELS = dpp_module.KeySecurityLevel;
|
|
14
|
+
|
|
15
|
+
export * from '../wasm/wasm_dpp';
|
|
16
|
+
export * from './errors/AbstractConsensusError';
|
|
17
|
+
export * from './errors/DPPError';
|
|
18
|
+
|
|
19
|
+
// Declarations written prior to "export *" will overwrite exports
|
|
20
|
+
export declare class IdentityPublicKey extends dpp_module.IdentityPublicKey {
|
|
21
|
+
static TYPES: typeof dpp_module.KeyType;
|
|
22
|
+
static PURPOSES: typeof dpp_module.KeyPurpose;
|
|
23
|
+
static SECURITY_LEVELS: typeof dpp_module.KeySecurityLevel;
|
|
24
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export class DPPError extends Error {
|
|
2
|
+
name: string;
|
|
3
|
+
message: string;
|
|
4
|
+
|
|
5
|
+
constructor(message: string) {
|
|
6
|
+
super();
|
|
7
|
+
|
|
8
|
+
this.name = this.constructor.name;
|
|
9
|
+
this.message = message;
|
|
10
|
+
|
|
11
|
+
if (Error.captureStackTrace) {
|
|
12
|
+
Error.captureStackTrace(this, this.constructor);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import * as dpp_module from '../../wasm/wasm_dpp';
|
|
2
|
+
import { extend } from "../utils/extend";
|
|
3
|
+
import { AbstractConsensusError } from "./AbstractConsensusError";
|
|
4
|
+
|
|
5
|
+
const {
|
|
6
|
+
ProtocolVersionParsingError,
|
|
7
|
+
UnsupportedProtocolVersionError,
|
|
8
|
+
IncompatibleProtocolVersionError,
|
|
9
|
+
SerializedObjectParsingError,
|
|
10
|
+
JsonSchemaError,
|
|
11
|
+
InvalidIdentifierError,
|
|
12
|
+
DataContractMaxDepthExceedError,
|
|
13
|
+
DuplicateIndexError,
|
|
14
|
+
InvalidCompoundIndexError,
|
|
15
|
+
InvalidDataContractIdError,
|
|
16
|
+
InvalidIndexedPropertyConstraintError,
|
|
17
|
+
InvalidIndexPropertyTypeError,
|
|
18
|
+
SystemPropertyIndexAlreadyPresentError,
|
|
19
|
+
UndefinedIndexPropertyError,
|
|
20
|
+
UniqueIndicesLimitReachedError,
|
|
21
|
+
InconsistentCompoundIndexDataError,
|
|
22
|
+
InvalidDocumentTransitionActionError,
|
|
23
|
+
InvalidDocumentTransitionIdError,
|
|
24
|
+
DataContractNotPresentError,
|
|
25
|
+
InvalidDocumentTypeError,
|
|
26
|
+
MissingDataContractIdError,
|
|
27
|
+
MissingDocumentTransitionActionError,
|
|
28
|
+
MissingDocumentTransitionTypeError,
|
|
29
|
+
MissingDocumentTypeError,
|
|
30
|
+
DuplicatedIdentityPublicKeyError,
|
|
31
|
+
DuplicatedIdentityPublicKeyIdError,
|
|
32
|
+
MissingMasterPublicKeyError,
|
|
33
|
+
IdentityAssetLockProofLockedTransactionMismatchError,
|
|
34
|
+
IdentityAssetLockTransactionIsNotFoundError,
|
|
35
|
+
IdentityAssetLockTransactionOutPointAlreadyExistsError,
|
|
36
|
+
IdentityAssetLockTransactionOutputNotFoundError,
|
|
37
|
+
InvalidAssetLockProofCoreChainHeightError,
|
|
38
|
+
InvalidAssetLockProofTransactionHeightError,
|
|
39
|
+
InvalidIdentityAssetLockTransactionError,
|
|
40
|
+
InvalidIdentityAssetLockTransactionOutputError,
|
|
41
|
+
InvalidIdentityPublicKeyDataError,
|
|
42
|
+
InvalidIdentityPublicKeySecurityLevelError,
|
|
43
|
+
InvalidStateTransitionTypeError,
|
|
44
|
+
MissingStateTransitionTypeError,
|
|
45
|
+
StateTransitionMaxSizeExceededError,
|
|
46
|
+
IdentityNotFoundError,
|
|
47
|
+
InvalidIdentityPublicKeyTypeError,
|
|
48
|
+
InvalidStateTransitionSignatureError,
|
|
49
|
+
MissingPublicKeyError,
|
|
50
|
+
BalanceIsNotEnoughError,
|
|
51
|
+
DataContractAlreadyPresentError,
|
|
52
|
+
DataTriggerConditionError,
|
|
53
|
+
DataTriggerExecutionError,
|
|
54
|
+
DataTriggerInvalidResultError,
|
|
55
|
+
DocumentAlreadyPresentError,
|
|
56
|
+
DocumentNotFoundError,
|
|
57
|
+
DocumentOwnerIdMismatchError,
|
|
58
|
+
DocumentTimestampsMismatchError,
|
|
59
|
+
DocumentTimestampWindowViolationError,
|
|
60
|
+
DuplicateUniqueIndexError,
|
|
61
|
+
InvalidDocumentRevisionError,
|
|
62
|
+
IdentityAlreadyExistsError,
|
|
63
|
+
InvalidJsonSchemaRefError,
|
|
64
|
+
JsonSchemaCompilationError,
|
|
65
|
+
DuplicateDocumentTransitionsWithIdsError,
|
|
66
|
+
DuplicateDocumentTransitionsWithIndicesError,
|
|
67
|
+
InvalidAssetLockTransactionOutputReturnSizeError,
|
|
68
|
+
InvalidInstantAssetLockProofError,
|
|
69
|
+
InvalidInstantAssetLockProofSignatureError,
|
|
70
|
+
IncompatibleRe2PatternError,
|
|
71
|
+
InvalidDataContractVersionError,
|
|
72
|
+
IncompatibleDataContractSchemaError,
|
|
73
|
+
DataContractImmutablePropertiesUpdateError,
|
|
74
|
+
DataContractUniqueIndicesChangedError,
|
|
75
|
+
DuplicateIndexNameError,
|
|
76
|
+
DataContractInvalidIndexDefinitionUpdateError,
|
|
77
|
+
DataContractHaveNewUniqueIndexError,
|
|
78
|
+
IdentityPublicKeyDisabledAtWindowViolationError,
|
|
79
|
+
IdentityPublicKeyIsReadOnlyError,
|
|
80
|
+
InvalidIdentityPublicKeyIdError,
|
|
81
|
+
InvalidIdentityRevisionError,
|
|
82
|
+
MaxIdentityPublicKeyLimitReachedError,
|
|
83
|
+
InvalidIdentityKeySignatureError,
|
|
84
|
+
InvalidSignaturePublicKeySecurityLevelError,
|
|
85
|
+
PublicKeyIsDisabledError,
|
|
86
|
+
PublicKeySecurityLevelNotMetError,
|
|
87
|
+
WrongPublicKeyPurposeError,
|
|
88
|
+
IdentityPublicKeyIsDisabledError,
|
|
89
|
+
} = dpp_module;
|
|
90
|
+
|
|
91
|
+
export function patchConsensusErrors() {
|
|
92
|
+
extend(ProtocolVersionParsingError, AbstractConsensusError);
|
|
93
|
+
extend(UnsupportedProtocolVersionError, AbstractConsensusError);
|
|
94
|
+
extend(IncompatibleProtocolVersionError, AbstractConsensusError);
|
|
95
|
+
extend(SerializedObjectParsingError, AbstractConsensusError);
|
|
96
|
+
extend(JsonSchemaError, AbstractConsensusError);
|
|
97
|
+
extend(InvalidIdentifierError, AbstractConsensusError);
|
|
98
|
+
extend(DataContractMaxDepthExceedError, AbstractConsensusError);
|
|
99
|
+
extend(DuplicateIndexError, AbstractConsensusError);
|
|
100
|
+
extend(InvalidCompoundIndexError, AbstractConsensusError);
|
|
101
|
+
extend(InvalidDataContractIdError, AbstractConsensusError);
|
|
102
|
+
extend(InvalidIndexedPropertyConstraintError, AbstractConsensusError);
|
|
103
|
+
extend(InvalidIndexPropertyTypeError, AbstractConsensusError);
|
|
104
|
+
extend(SystemPropertyIndexAlreadyPresentError, AbstractConsensusError);
|
|
105
|
+
extend(UndefinedIndexPropertyError, AbstractConsensusError);
|
|
106
|
+
extend(UniqueIndicesLimitReachedError, AbstractConsensusError);
|
|
107
|
+
extend(InconsistentCompoundIndexDataError, AbstractConsensusError);
|
|
108
|
+
extend(InvalidDocumentTransitionActionError, AbstractConsensusError);
|
|
109
|
+
extend(InvalidDocumentTransitionIdError, AbstractConsensusError);
|
|
110
|
+
extend(DataContractNotPresentError, AbstractConsensusError);
|
|
111
|
+
extend(InvalidDocumentTypeError, AbstractConsensusError);
|
|
112
|
+
extend(MissingDataContractIdError, AbstractConsensusError);
|
|
113
|
+
extend(MissingDocumentTransitionActionError, AbstractConsensusError);
|
|
114
|
+
extend(MissingDocumentTransitionTypeError, AbstractConsensusError);
|
|
115
|
+
extend(MissingDocumentTypeError, AbstractConsensusError);
|
|
116
|
+
extend(DuplicatedIdentityPublicKeyError, AbstractConsensusError);
|
|
117
|
+
extend(DuplicatedIdentityPublicKeyIdError, AbstractConsensusError);
|
|
118
|
+
extend(MissingMasterPublicKeyError, AbstractConsensusError);
|
|
119
|
+
extend(IdentityAssetLockProofLockedTransactionMismatchError, AbstractConsensusError);
|
|
120
|
+
extend(IdentityAssetLockTransactionIsNotFoundError, AbstractConsensusError);
|
|
121
|
+
extend(IdentityAssetLockTransactionOutPointAlreadyExistsError, AbstractConsensusError);
|
|
122
|
+
extend(IdentityAssetLockTransactionOutputNotFoundError, AbstractConsensusError);
|
|
123
|
+
extend(InvalidAssetLockProofCoreChainHeightError, AbstractConsensusError);
|
|
124
|
+
extend(InvalidAssetLockProofTransactionHeightError, AbstractConsensusError);
|
|
125
|
+
extend(InvalidIdentityAssetLockTransactionError, AbstractConsensusError);
|
|
126
|
+
extend(InvalidIdentityAssetLockTransactionOutputError, AbstractConsensusError);
|
|
127
|
+
extend(InvalidIdentityPublicKeyDataError, AbstractConsensusError);
|
|
128
|
+
extend(InvalidIdentityPublicKeySecurityLevelError, AbstractConsensusError);
|
|
129
|
+
extend(InvalidStateTransitionTypeError, AbstractConsensusError);
|
|
130
|
+
extend(MissingStateTransitionTypeError, AbstractConsensusError);
|
|
131
|
+
extend(StateTransitionMaxSizeExceededError, AbstractConsensusError);
|
|
132
|
+
extend(IdentityNotFoundError, AbstractConsensusError);
|
|
133
|
+
extend(InvalidIdentityPublicKeyTypeError, AbstractConsensusError);
|
|
134
|
+
extend(InvalidStateTransitionSignatureError, AbstractConsensusError);
|
|
135
|
+
extend(MissingPublicKeyError, AbstractConsensusError);
|
|
136
|
+
extend(BalanceIsNotEnoughError, AbstractConsensusError);
|
|
137
|
+
extend(DataContractAlreadyPresentError, AbstractConsensusError);
|
|
138
|
+
extend(DataTriggerConditionError, AbstractConsensusError);
|
|
139
|
+
extend(DataTriggerExecutionError, AbstractConsensusError);
|
|
140
|
+
extend(DataTriggerInvalidResultError, AbstractConsensusError);
|
|
141
|
+
extend(DocumentAlreadyPresentError, AbstractConsensusError);
|
|
142
|
+
extend(DocumentNotFoundError, AbstractConsensusError);
|
|
143
|
+
extend(DocumentOwnerIdMismatchError, AbstractConsensusError);
|
|
144
|
+
extend(DocumentTimestampsMismatchError, AbstractConsensusError);
|
|
145
|
+
extend(DocumentTimestampWindowViolationError, AbstractConsensusError);
|
|
146
|
+
extend(DuplicateUniqueIndexError, AbstractConsensusError);
|
|
147
|
+
extend(InvalidDocumentRevisionError, AbstractConsensusError);
|
|
148
|
+
extend(IdentityAlreadyExistsError, AbstractConsensusError);
|
|
149
|
+
extend(InvalidJsonSchemaRefError, AbstractConsensusError);
|
|
150
|
+
extend(JsonSchemaCompilationError, AbstractConsensusError);
|
|
151
|
+
extend(DuplicateDocumentTransitionsWithIdsError, AbstractConsensusError);
|
|
152
|
+
extend(DuplicateDocumentTransitionsWithIndicesError, AbstractConsensusError);
|
|
153
|
+
extend(InvalidAssetLockTransactionOutputReturnSizeError, AbstractConsensusError);
|
|
154
|
+
extend(InvalidInstantAssetLockProofError, AbstractConsensusError);
|
|
155
|
+
extend(InvalidInstantAssetLockProofSignatureError, AbstractConsensusError);
|
|
156
|
+
extend(IncompatibleRe2PatternError, AbstractConsensusError);
|
|
157
|
+
extend(InvalidDataContractVersionError, AbstractConsensusError);
|
|
158
|
+
extend(IncompatibleDataContractSchemaError, AbstractConsensusError);
|
|
159
|
+
extend(DataContractImmutablePropertiesUpdateError, AbstractConsensusError);
|
|
160
|
+
extend(DataContractUniqueIndicesChangedError, AbstractConsensusError);
|
|
161
|
+
extend(DuplicateIndexNameError, AbstractConsensusError);
|
|
162
|
+
extend(DataContractInvalidIndexDefinitionUpdateError, AbstractConsensusError);
|
|
163
|
+
extend(DataContractHaveNewUniqueIndexError, AbstractConsensusError);
|
|
164
|
+
extend(IdentityPublicKeyDisabledAtWindowViolationError, AbstractConsensusError);
|
|
165
|
+
extend(IdentityPublicKeyIsReadOnlyError, AbstractConsensusError);
|
|
166
|
+
extend(InvalidIdentityPublicKeyIdError, AbstractConsensusError);
|
|
167
|
+
extend(InvalidIdentityRevisionError, AbstractConsensusError);
|
|
168
|
+
extend(MaxIdentityPublicKeyLimitReachedError, AbstractConsensusError);
|
|
169
|
+
extend(InvalidIdentityKeySignatureError, AbstractConsensusError);
|
|
170
|
+
extend(InvalidSignaturePublicKeySecurityLevelError, AbstractConsensusError);
|
|
171
|
+
extend(PublicKeyIsDisabledError, AbstractConsensusError);
|
|
172
|
+
extend(PublicKeySecurityLevelNotMetError, AbstractConsensusError);
|
|
173
|
+
extend(WrongPublicKeyPurposeError, AbstractConsensusError);
|
|
174
|
+
extend(IdentityPublicKeyIsDisabledError, AbstractConsensusError);
|
|
175
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as dpp_module from "../
|
|
1
|
+
import * as dpp_module from "../dpp";
|
|
2
2
|
// import { inspect } from 'util';
|
|
3
3
|
|
|
4
4
|
export default function (dppModule: typeof dpp_module) {
|
|
@@ -11,8 +11,8 @@ export default function (dppModule: typeof dpp_module) {
|
|
|
11
11
|
//@ts-ignore
|
|
12
12
|
Object.setPrototypeOf(Identifier.prototype, Buffer.prototype);
|
|
13
13
|
|
|
14
|
-
Identifier.prototype.valueOf = function() {
|
|
15
|
-
return Buffer.from(this.
|
|
14
|
+
Identifier.prototype.valueOf = function () {
|
|
15
|
+
return Buffer.from(this.toBytes());
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
// @ts-ignore
|
|
@@ -24,7 +24,7 @@ export default function (dppModule: typeof dpp_module) {
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
// @ts-ignore
|
|
27
|
-
Identifier.prototype.inspect = function(...args) {
|
|
27
|
+
Identifier.prototype.inspect = function (...args) {
|
|
28
28
|
return this.valueOf().inspect(...args);
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -34,4 +34,5 @@ export default function (dppModule: typeof dpp_module) {
|
|
|
34
34
|
// console.log("custom:", inspect.custom);
|
|
35
35
|
// //@ts-ignore
|
|
36
36
|
// Identifier.prototype[inspect.custom] = Identifier.prototype.inspect;
|
|
37
|
-
}
|
|
37
|
+
}
|
|
38
|
+
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import init
|
|
1
|
+
import init from '../wasm/wasm_dpp';
|
|
2
|
+
import * as dpp_module from './dpp';
|
|
2
3
|
// @ts-ignore
|
|
3
|
-
import wasmBase from '
|
|
4
|
-
import patchIdentifier from "./
|
|
4
|
+
import wasmBase from '../wasm/wasm_dpp_bg.js';
|
|
5
|
+
import patchIdentifier from "./identifier/patchIdentifier";
|
|
5
6
|
|
|
6
7
|
let isInitialized = false;
|
|
7
8
|
|
|
@@ -17,7 +18,7 @@ export default async function loadDpp() {
|
|
|
17
18
|
let wasmUrl = URL.createObjectURL(blob);
|
|
18
19
|
await init(wasmUrl);
|
|
19
20
|
isInitialized = true;
|
|
20
|
-
}
|
|
21
|
+
} else {
|
|
21
22
|
dpp_module.initSync(bytes);
|
|
22
23
|
isInitialized = true;
|
|
23
24
|
}
|
package/lib/test/bootstrap.js
CHANGED
|
@@ -5,6 +5,7 @@ const dirtyChai = require('dirty-chai');
|
|
|
5
5
|
const chaiAsPromised = require('chai-as-promised');
|
|
6
6
|
const chaiString = require('chai-string');
|
|
7
7
|
const chaiExclude = require('chai-exclude');
|
|
8
|
+
const crypto = require('crypto');
|
|
8
9
|
|
|
9
10
|
use(sinonChai);
|
|
10
11
|
use(chaiAsPromised);
|
|
@@ -12,6 +13,10 @@ use(dirtyChai);
|
|
|
12
13
|
use(chaiString);
|
|
13
14
|
use(chaiExclude);
|
|
14
15
|
|
|
16
|
+
/* eslint-disable */
|
|
17
|
+
// TODO this should be loaded with library - not with tests.
|
|
18
|
+
globalThis.crypto = crypto.webcrypto;
|
|
19
|
+
|
|
15
20
|
beforeEach(function beforeEach() {
|
|
16
21
|
if (!this.sinonSandbox) {
|
|
17
22
|
this.sinonSandbox = sinon.createSandbox();
|
|
@@ -12,12 +12,14 @@ const expectError = {
|
|
|
12
12
|
const wasmDpp = await loadWasmDpp();
|
|
13
13
|
if (!errorClass) {
|
|
14
14
|
// eslint-disable-next-line no-param-reassign
|
|
15
|
-
errorClass = wasmDpp.
|
|
15
|
+
errorClass = wasmDpp.AbstractConsensusError;
|
|
16
16
|
}
|
|
17
17
|
expect(result).to.be.an.instanceOf(wasmDpp.ValidationResult);
|
|
18
18
|
expect(result.getErrors()).to.have.lengthOf(count);
|
|
19
19
|
|
|
20
|
-
result.getErrors().forEach((error) =>
|
|
20
|
+
result.getErrors().forEach((error) => {
|
|
21
|
+
expect(error).to.be.an.instanceOf(errorClass);
|
|
22
|
+
});
|
|
21
23
|
},
|
|
22
24
|
|
|
23
25
|
/**
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const BlsSignatures = require('@dashevo/dpp/lib/bls/bls');
|
|
2
|
+
|
|
3
|
+
module.exports = async function getBlsAdapterMock() {
|
|
4
|
+
const bls = await BlsSignatures.getInstance();
|
|
5
|
+
|
|
6
|
+
const blsAdapter = {
|
|
7
|
+
validatePublicKey(publicKeyBuffer) {
|
|
8
|
+
let pk;
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
pk = bls.PublicKey.fromBytes(publicKeyBuffer);
|
|
12
|
+
} catch (e) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return Boolean(pk);
|
|
17
|
+
},
|
|
18
|
+
sign(data, key) {
|
|
19
|
+
const blsKey = bls.PrivateKey.fromBytes(key, true);
|
|
20
|
+
const signature = blsKey.sign(data);
|
|
21
|
+
return Buffer.from(signature.serialize());
|
|
22
|
+
},
|
|
23
|
+
verifySignature(signature, data, publicKey) {
|
|
24
|
+
const { PublicKey, Signature: BlsSignature, AggregationInfo } = bls;
|
|
25
|
+
|
|
26
|
+
const blsKey = PublicKey.fromBytes(publicKey);
|
|
27
|
+
|
|
28
|
+
const aggregationInfo = AggregationInfo.fromMsg(blsKey, data);
|
|
29
|
+
const blsSignature = BlsSignature.fromBytesAndAggregationInfo(signature, aggregationInfo);
|
|
30
|
+
|
|
31
|
+
return blsSignature.verify();
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return blsAdapter;
|
|
36
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const { default: loadWasmDpp } = require('../../../dist');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Creates container with documents
|
|
5
|
+
*
|
|
6
|
+
* @return {DocumentsContainer}
|
|
7
|
+
*/
|
|
8
|
+
async function newDocumentsContainer(documents) {
|
|
9
|
+
const {
|
|
10
|
+
create: createDocuments,
|
|
11
|
+
replace: replaceDocuments,
|
|
12
|
+
delete: deleteDocuments,
|
|
13
|
+
} = documents;
|
|
14
|
+
const { DocumentsContainer } = await loadWasmDpp();
|
|
15
|
+
|
|
16
|
+
const documentsContainer = new DocumentsContainer();
|
|
17
|
+
if (createDocuments != null) {
|
|
18
|
+
createDocuments.forEach((document) => {
|
|
19
|
+
documentsContainer.pushDocumentCreate(document);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
if (replaceDocuments != null) {
|
|
23
|
+
replaceDocuments.forEach((document) => {
|
|
24
|
+
documentsContainer.pushDocumentReplace(document);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
if (deleteDocuments != null) {
|
|
28
|
+
deleteDocuments.forEach((document) => {
|
|
29
|
+
documentsContainer.pushDocumentDelete(document);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return documentsContainer;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
module.exports = newDocumentsContainer;
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dashevo/wasm-dpp",
|
|
3
|
-
"version": "0.24.0-dev.
|
|
3
|
+
"version": "0.24.0-dev.13",
|
|
4
4
|
"description": "The JavaScript implementation of the Dash Platform Protocol",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
6
|
+
"types": "dist/lib/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "yarn exec scripts/build.sh && webpack",
|
|
9
9
|
"test": "yarn run test:node && yarn run test:browsers",
|
|
@@ -30,13 +30,15 @@
|
|
|
30
30
|
],
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@dashevo/bls": "~1.0.0-beta.2"
|
|
33
|
+
"@dashevo/bls": "~1.0.0-beta.2",
|
|
34
|
+
"lodash": "^4.17.21",
|
|
35
|
+
"varint": "^6.0.0"
|
|
34
36
|
},
|
|
35
37
|
"devDependencies": {
|
|
36
38
|
"@apidevtools/json-schema-ref-parser": "^8.0.0",
|
|
37
39
|
"@dashevo/dashcore-lib": "~0.19.44",
|
|
38
|
-
"@dashevo/dpns-contract": "0.24.0-dev.
|
|
39
|
-
"@dashevo/dpp": "0.24.0-dev.
|
|
40
|
+
"@dashevo/dpns-contract": "0.24.0-dev.13",
|
|
41
|
+
"@dashevo/dpp": "0.24.0-dev.13",
|
|
40
42
|
"@dashevo/wasm-re2": "~1.0.2",
|
|
41
43
|
"@types/node": "^14.6.0",
|
|
42
44
|
"ajv": "^8.6.0",
|
|
@@ -53,7 +55,7 @@
|
|
|
53
55
|
"eslint-config-airbnb-base": "^14.2.1",
|
|
54
56
|
"eslint-plugin-import": "^2.24.2",
|
|
55
57
|
"events": "^3.3.0",
|
|
56
|
-
"fast-json-patch": "^3.1.
|
|
58
|
+
"fast-json-patch": "^3.1.1",
|
|
57
59
|
"https-browserify": "^1.0.0",
|
|
58
60
|
"json-schema-diff-validator": "^0.4.1",
|
|
59
61
|
"karma": "^6.4.1",
|
|
@@ -73,6 +75,7 @@
|
|
|
73
75
|
"stream-browserify": "^3.0.0",
|
|
74
76
|
"stream-http": "^3.2.0",
|
|
75
77
|
"string_decoder": "^1.3.0",
|
|
78
|
+
"terser-webpack-plugin": "^5.3.1",
|
|
76
79
|
"ts-loader": "^8.0.2",
|
|
77
80
|
"typescript": "^3.9.5",
|
|
78
81
|
"url": "^0.11.0",
|
package/src/bls_adapter.rs
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
use dpp::dashcore::anyhow::anyhow;
|
|
2
2
|
use dpp::{BlsModule, PublicKeyValidationError};
|
|
3
3
|
use wasm_bindgen::prelude::*;
|
|
4
|
+
use wasm_bindgen::JsCast;
|
|
4
5
|
|
|
5
6
|
#[wasm_bindgen]
|
|
6
7
|
extern "C" {
|
|
8
|
+
#[derive(Clone)]
|
|
7
9
|
pub type JsBlsAdapter;
|
|
8
10
|
|
|
9
11
|
#[wasm_bindgen(method)]
|
|
@@ -66,6 +68,19 @@ impl BlsModule for BlsAdapter {
|
|
|
66
68
|
self.0
|
|
67
69
|
.sign(data, private_key)
|
|
68
70
|
.map(|arr| arr.to_vec())
|
|
69
|
-
.map_err(|
|
|
71
|
+
.map_err(|e: JsValue| {
|
|
72
|
+
let error = e.dyn_into::<js_sys::Error>();
|
|
73
|
+
|
|
74
|
+
match error {
|
|
75
|
+
Ok(e) => {
|
|
76
|
+
let message: String = e
|
|
77
|
+
.message()
|
|
78
|
+
.as_string()
|
|
79
|
+
.unwrap_or_else(|| String::from("Unknown error, can't sign"));
|
|
80
|
+
anyhow!(message).into()
|
|
81
|
+
}
|
|
82
|
+
Err(_) => anyhow!("Unknown error, can't sign").into(),
|
|
83
|
+
}
|
|
84
|
+
})
|
|
70
85
|
}
|
|
71
86
|
}
|
|
@@ -12,6 +12,7 @@ use dpp::util::string_encoding::Encoding;
|
|
|
12
12
|
|
|
13
13
|
use crate::errors::{from_dpp_err, RustConversionError};
|
|
14
14
|
use crate::metadata::MetadataWasm;
|
|
15
|
+
use crate::utils::WithJsError;
|
|
15
16
|
use crate::{bail_js, with_js_error};
|
|
16
17
|
use crate::{buffer::Buffer, identifier::IdentifierWrapper};
|
|
17
18
|
|
|
@@ -34,11 +35,16 @@ impl std::convert::Into<DataContract> for DataContractWasm {
|
|
|
34
35
|
#[derive(Debug, Serialize, Deserialize)]
|
|
35
36
|
#[serde(rename_all = "camelCase")]
|
|
36
37
|
pub(crate) struct DataContractParameters {
|
|
37
|
-
#[serde(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
#[serde(
|
|
39
|
+
rename = "$schema",
|
|
40
|
+
skip_serializing_if = "serde_json::Value::is_null",
|
|
41
|
+
default
|
|
42
|
+
)]
|
|
43
|
+
schema: serde_json::Value,
|
|
44
|
+
#[serde(rename = "$id", skip_serializing_if = "Option::is_none")]
|
|
45
|
+
id: Option<Vec<u8>>,
|
|
46
|
+
#[serde(skip_serializing_if = "Option::is_none")]
|
|
47
|
+
owner_id: Option<Vec<u8>>,
|
|
42
48
|
#[serde(skip_serializing_if = "serde_json::Value::is_null", default)]
|
|
43
49
|
documents: serde_json::Value,
|
|
44
50
|
#[serde(
|
|
@@ -47,8 +53,13 @@ pub(crate) struct DataContractParameters {
|
|
|
47
53
|
rename = "$defs"
|
|
48
54
|
)]
|
|
49
55
|
defs: serde_json::Value,
|
|
50
|
-
|
|
51
|
-
|
|
56
|
+
#[serde(skip_serializing_if = "serde_json::Value::is_null", default)]
|
|
57
|
+
protocol_version: serde_json::Value,
|
|
58
|
+
#[serde(skip_serializing_if = "serde_json::Value::is_null", default)]
|
|
59
|
+
version: serde_json::Value,
|
|
60
|
+
|
|
61
|
+
#[serde(flatten)]
|
|
62
|
+
_extras: serde_json::Value, // Captures excess fields to trigger validation failure later.
|
|
52
63
|
}
|
|
53
64
|
|
|
54
65
|
#[wasm_bindgen(js_class=DataContract)]
|
|
@@ -75,6 +86,11 @@ impl DataContractWasm {
|
|
|
75
86
|
self.0.id.clone().into()
|
|
76
87
|
}
|
|
77
88
|
|
|
89
|
+
#[wasm_bindgen(js_name=setId)]
|
|
90
|
+
pub fn set_id(&mut self, id: IdentifierWrapper) {
|
|
91
|
+
self.0.id = id.inner();
|
|
92
|
+
}
|
|
93
|
+
|
|
78
94
|
#[wasm_bindgen(js_name=getOwnerId)]
|
|
79
95
|
pub fn get_owner_id(&self) -> IdentifierWrapper {
|
|
80
96
|
self.0.owner_id.clone().into()
|
|
@@ -276,6 +292,12 @@ impl DataContractWasm {
|
|
|
276
292
|
.map_err(from_dpp_err)?
|
|
277
293
|
.into())
|
|
278
294
|
}
|
|
295
|
+
|
|
296
|
+
#[wasm_bindgen(js_name=fromBuffer)]
|
|
297
|
+
pub fn from_buffer(b: &[u8]) -> Result<DataContractWasm, JsValue> {
|
|
298
|
+
let data_contract = DataContract::from_cbor(b).with_js_error()?;
|
|
299
|
+
Ok(data_contract.into())
|
|
300
|
+
}
|
|
279
301
|
}
|
|
280
302
|
|
|
281
303
|
#[wasm_bindgen(js_name=DataContractDefaults)]
|
|
@@ -288,3 +310,9 @@ impl DataContractDefaults {
|
|
|
288
310
|
SCHEMA_URI.to_string()
|
|
289
311
|
}
|
|
290
312
|
}
|
|
313
|
+
|
|
314
|
+
impl DataContractWasm {
|
|
315
|
+
pub fn inner(&self) -> &DataContract {
|
|
316
|
+
&self.0
|
|
317
|
+
}
|
|
318
|
+
}
|
|
@@ -10,6 +10,7 @@ pub struct InvalidDataContractError {
|
|
|
10
10
|
|
|
11
11
|
#[wasm_bindgen(js_class=InvalidDataContractError)]
|
|
12
12
|
impl InvalidDataContractError {
|
|
13
|
+
#[wasm_bindgen(constructor)]
|
|
13
14
|
pub fn new(errors: Vec<JsValue>, raw_data_contract: JsValue) -> Self {
|
|
14
15
|
InvalidDataContractError {
|
|
15
16
|
errors,
|
|
@@ -26,4 +27,24 @@ impl InvalidDataContractError {
|
|
|
26
27
|
pub fn get_raw_data_contract(&self) -> JsValue {
|
|
27
28
|
self.raw_data_contract.clone()
|
|
28
29
|
}
|
|
30
|
+
|
|
31
|
+
#[wasm_bindgen(js_name=getMessage)]
|
|
32
|
+
pub fn get_message(&self) -> String {
|
|
33
|
+
let extended_message = if let Some(error_message) = self
|
|
34
|
+
.errors
|
|
35
|
+
.first()
|
|
36
|
+
.map(|e| Into::<js_sys::Error>::into(e.clone()).message())
|
|
37
|
+
{
|
|
38
|
+
let narrowed_message = if self.errors.len() > 1 {
|
|
39
|
+
format!(" and {} more", self.errors.len() - 1)
|
|
40
|
+
} else {
|
|
41
|
+
"".to_owned()
|
|
42
|
+
};
|
|
43
|
+
format!(": \"{error_message}\"{narrowed_message}")
|
|
44
|
+
} else {
|
|
45
|
+
"".to_owned()
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
format!("Data contract decode error{extended_message}")
|
|
49
|
+
}
|
|
29
50
|
}
|