Skip to content

feat(platform)!: basic nft support #1829

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 71 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
30b9a16
start on nft support
QuantumExplorer Apr 18, 2024
0b4ab9c
more work
QuantumExplorer Apr 19, 2024
eba768d
more fixes
QuantumExplorer Apr 19, 2024
d8ba10d
added some tests for document replace
QuantumExplorer Apr 19, 2024
33dd545
more tests
QuantumExplorer Apr 19, 2024
cccceda
updated sdk
QuantumExplorer Apr 20, 2024
a508942
fmt
QuantumExplorer Apr 20, 2024
b557e60
fixes
QuantumExplorer Apr 20, 2024
889f6b2
fixes
QuantumExplorer Apr 20, 2024
f22c1aa
vectors
QuantumExplorer Apr 20, 2024
d881ba8
more fixes
QuantumExplorer Apr 20, 2024
5898e74
more fixes
QuantumExplorer Apr 20, 2024
90fc5ea
more fixes
QuantumExplorer Apr 20, 2024
95dc96a
removed marketplace for now
QuantumExplorer Apr 20, 2024
80cf457
Merge branch 'v1.0-dev' into feat/transferDocument
QuantumExplorer Apr 20, 2024
d7f37a9
fmt
QuantumExplorer Apr 20, 2024
9d3c834
wasm-dpp fixes
QuantumExplorer Apr 20, 2024
6d3730b
Merge branch 'feat/transferDocument' of github.com:dashpay/platform i…
QuantumExplorer Apr 20, 2024
1b75aa8
more work on nft support
QuantumExplorer Apr 22, 2024
7ae9a4f
Update packages/rs-dpp/src/data_contract/document_type/class_methods/…
QuantumExplorer Apr 22, 2024
91aeccd
Update packages/rs-dpp/src/data_contract/document_type/v0/random_docu…
QuantumExplorer Apr 22, 2024
1ffd47d
Update packages/rs-sdk/src/platform/transition/transfer_document.rs
QuantumExplorer Apr 22, 2024
5989093
Update packages/rs-sdk/src/platform/transition/transfer_document.rs
QuantumExplorer Apr 22, 2024
1782ccf
Update packages/rs-sdk/src/platform/transition/transfer_document.rs
QuantumExplorer Apr 22, 2024
469a8aa
Update packages/strategy-tests/src/lib.rs
QuantumExplorer Apr 22, 2024
8b22da4
Update packages/rs-dpp/src/data_contract/document_type/v0/mod.rs
QuantumExplorer Apr 22, 2024
849c4d8
Update packages/rs-dpp/src/document/transfer.rs
QuantumExplorer Apr 22, 2024
053aa0d
Update packages/rs-drive-abci/src/execution/validation/state_transiti…
QuantumExplorer Apr 22, 2024
4b68f30
Update packages/rs-drive-abci/src/execution/validation/state_transiti…
QuantumExplorer Apr 22, 2024
5eaf71d
Update packages/rs-drive-abci/src/execution/validation/state_transiti…
QuantumExplorer Apr 22, 2024
9c893cb
more work
QuantumExplorer Apr 22, 2024
d5c26d9
fixes
QuantumExplorer Apr 22, 2024
c381b0d
fmt
QuantumExplorer Apr 22, 2024
66bf55b
Merge branch 'feat/transferDocument' into feat/nftSupport
QuantumExplorer Apr 22, 2024
72ad185
Merge branch 'v1.0-dev' into feat/nftSupport
QuantumExplorer Apr 22, 2024
a0dadea
fmt
QuantumExplorer Apr 22, 2024
7289ce3
fmt
QuantumExplorer Apr 22, 2024
df6d1ba
more work
QuantumExplorer Apr 22, 2024
e072dad
more fixes
QuantumExplorer Apr 22, 2024
e734abd
fixes
QuantumExplorer Apr 23, 2024
ae77e5f
added more tests and some extra validation and errors
QuantumExplorer Apr 23, 2024
a7aad9a
another fix
QuantumExplorer Apr 24, 2024
be32222
more fixes
QuantumExplorer Apr 24, 2024
6fc5376
more fixes
QuantumExplorer Apr 24, 2024
2061f5f
more updates
QuantumExplorer Apr 24, 2024
78a8ce0
final fixes
QuantumExplorer Apr 24, 2024
905ffce
fix
QuantumExplorer Apr 24, 2024
7115e7d
fix
QuantumExplorer Apr 24, 2024
a828b30
added contract update checks
QuantumExplorer Apr 24, 2024
7c74fa7
update grovedb
QuantumExplorer Apr 24, 2024
e6c6aea
fmt
QuantumExplorer Apr 24, 2024
b41ed4c
fix
QuantumExplorer Apr 24, 2024
ef63367
fix
QuantumExplorer Apr 25, 2024
854d803
fix
QuantumExplorer Apr 25, 2024
cf66688
Update packages/rs-dpp/src/data_contract/config/v0/mod.rs
QuantumExplorer Apr 25, 2024
4a26a01
Update packages/rs-dpp/src/data_contract/config/v0/mod.rs
QuantumExplorer Apr 25, 2024
5dedad3
Update packages/rs-dpp/src/data_contract/config/v0/mod.rs
QuantumExplorer Apr 25, 2024
ab6046a
Update packages/rs-dpp/src/document/v0/serialize.rs
QuantumExplorer Apr 25, 2024
6e87d5e
Update packages/rs-dpp/src/nft/mod.rs
QuantumExplorer Apr 25, 2024
7ca1cee
Update packages/rs-drive/src/drive/flags.rs
QuantumExplorer Apr 25, 2024
3e6c5aa
Update packages/rs-dpp/src/data_contract/config/v0/mod.rs
QuantumExplorer Apr 25, 2024
5fe56a0
Update packages/rs-dpp/src/data_contract/config/v0/mod.rs
QuantumExplorer Apr 25, 2024
7668c85
Update packages/rs-dpp/src/data_contract/config/v0/mod.rs
QuantumExplorer Apr 25, 2024
4078159
Update packages/rs-dpp/src/data_contract/document_type/class_methods/…
QuantumExplorer Apr 25, 2024
d8ede39
Update packages/rs-dpp/src/data_contract/document_type/restricted_cre…
QuantumExplorer Apr 25, 2024
428bb1b
fixes
QuantumExplorer Apr 25, 2024
37d3411
Merge branch 'feat/nftSupport' of github.com:dashpay/platform into fe…
QuantumExplorer Apr 25, 2024
331aa8b
fmt
QuantumExplorer Apr 25, 2024
97a54f8
fix
QuantumExplorer Apr 25, 2024
42a2884
fix
QuantumExplorer Apr 25, 2024
c0a98ef
fix
QuantumExplorer Apr 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/dashpay-contract/schema/v1/dashpay.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
},
"contactRequest": {
"documentsMutable": false,
"canBeDeleted": false,
"requiresIdentityEncryptionBoundedKey": 2,
"requiresIdentityDecryptionBoundedKey": 2,
"type": "object",
Expand Down
29 changes: 29 additions & 0 deletions packages/rs-dpp/schema/meta_schemas/document/v0/document-meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,18 @@
],
"description": "Public key security level. 0 - Master, 1 - Critical, 2 - High, 3 - Medium. If none specified, High level is used"
},
"documentsKeepHistory": {
"type": "boolean",
"description": "True if the documents keep all their history, default is false"
},
"documentsMutable": {
"type": "boolean",
"description": "True if the documents are mutable, default is true"
},
"canBeDeleted": {
"type": "boolean",
"description": "True if the documents can be deleted, default is true"
},
"transferable": {
"type": "integer",
"enum": [
Expand All @@ -489,6 +501,23 @@
],
"description": "Transferable without a marketplace sell. 0 - Never, 1 - Always"
},
"tradeMode": {
"type": "integer",
"enum": [
0,
1
],
"description": "Built in marketplace system. 0 - None, 1 - Direct purchase (The user can buy the item without the need for an approval)"
},
"creationRestrictionMode": {
"type": "integer",
"enum": [
0,
1,
2
],
"description": "Restrictions of document creation. 0 - No restrictions, 1 - Owner only, 2 - No creation (System Only)"
},
"requiresIdentityEncryptionBoundedKey": {
"type": "integer",
"enum": [
Expand Down
3 changes: 3 additions & 0 deletions packages/rs-dpp/src/data_contract/config/fields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ pub const DEFAULT_CONTRACT_CAN_BE_DELETED: bool = false;
pub const DEFAULT_CONTRACT_MUTABILITY: bool = true;
pub const DEFAULT_CONTRACT_DOCUMENTS_KEEPS_HISTORY: bool = false;
pub const DEFAULT_CONTRACT_DOCUMENT_MUTABILITY: bool = true;
pub const DEFAULT_CONTRACT_DOCUMENTS_CAN_BE_DELETED: bool = true;

pub mod property {
pub const CAN_BE_DELETED: &str = "canBeDeleted";
pub const READONLY: &str = "readonly";
pub const KEEPS_HISTORY: &str = "keepsHistory";
pub const DOCUMENTS_KEEP_HISTORY_CONTRACT_DEFAULT: &str = "documentsKeepHistoryContractDefault";
pub const DOCUMENTS_MUTABLE_CONTRACT_DEFAULT: &str = "documentsMutableContractDefault";
pub const DOCUMENTS_CAN_BE_DELETED_CONTRACT_DEFAULT: &str =
"documentsCanBeDeletedContractDefault";
pub const REQUIRES_IDENTITY_ENCRYPTION_BOUNDED_KEY: &str =
"requiresIdentityEncryptionBoundedKey";
pub const REQUIRES_IDENTITY_DECRYPTION_BOUNDED_KEY: &str =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,20 @@ impl DataContractConfig {
);
}

// Validate: Documents can be deleted contract default did not change

if new_config.documents_can_be_deleted_contract_default()
!= self.documents_can_be_deleted_contract_default()
{
return SimpleConsensusValidationResult::new_with_error(
DataContractConfigUpdateError::new(
contract_id,
"contract can not change the default of whether documents can be deleted",
)
.into(),
);
}

// Validate: Requires identity encryption bounded key did not change

if new_config.requires_identity_encryption_bounded_key()
Expand Down
12 changes: 12 additions & 0 deletions packages/rs-dpp/src/data_contract/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ impl DataContractConfigGettersV0 for DataContractConfig {
}
}

fn documents_can_be_deleted_contract_default(&self) -> bool {
match self {
DataContractConfig::V0(v0) => v0.documents_can_be_deleted_contract_default,
}
}

/// Encryption key storage requirements
fn requires_identity_encryption_bounded_key(&self) -> Option<StorageKeyRequirements> {
match self {
Expand Down Expand Up @@ -157,6 +163,12 @@ impl DataContractConfigSettersV0 for DataContractConfig {
}
}

fn set_documents_can_be_deleted_contract_default(&mut self, value: bool) {
match self {
DataContractConfig::V0(v0) => v0.documents_can_be_deleted_contract_default = value,
}
}

fn set_documents_mutable_contract_default(&mut self, value: bool) {
match self {
DataContractConfig::V0(v0) => v0.documents_mutable_contract_default = value,
Expand Down
26 changes: 20 additions & 6 deletions packages/rs-dpp/src/data_contract/config/v0/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::data_contract::config;
use crate::data_contract::config::{
DataContractConfig, DEFAULT_CONTRACT_CAN_BE_DELETED, DEFAULT_CONTRACT_DOCUMENTS_KEEPS_HISTORY,
DEFAULT_CONTRACT_DOCUMENT_MUTABILITY, DEFAULT_CONTRACT_KEEPS_HISTORY,
DEFAULT_CONTRACT_MUTABILITY,
DataContractConfig, DEFAULT_CONTRACT_CAN_BE_DELETED, DEFAULT_CONTRACT_DOCUMENTS_CAN_BE_DELETED,
DEFAULT_CONTRACT_DOCUMENTS_KEEPS_HISTORY, DEFAULT_CONTRACT_DOCUMENT_MUTABILITY,
DEFAULT_CONTRACT_KEEPS_HISTORY, DEFAULT_CONTRACT_MUTABILITY,
};
use crate::data_contract::storage_requirements::keys_for_document_type::StorageKeyRequirements;
use crate::ProtocolError;
Expand All @@ -27,10 +27,14 @@ pub struct DataContractConfigV0 {
/// Do documents in the contract keep history. This is a default for all documents in
/// the contract, but can be overridden by the document itself
pub documents_keep_history_contract_default: bool,
/// Are documents in the contract mutable. This specifies whether the document can be
/// changed or deleted. This is a default for all documents in the contract, but can be
/// overridden by the document itself
/// Are documents in the contract mutable? This specifies whether the documents can be
/// changed. This is a default for all document types in the contract, but can be
/// overridden by the document type config.
pub documents_mutable_contract_default: bool,
/// Can documents in the contract be deleted? This specifies whether the documents can be
/// deleted. This is a default for all document types in the contract, but can be
/// overridden by the document types itself.
pub documents_can_be_deleted_contract_default: bool,
/// Encryption key storage requirements
pub requires_identity_encryption_bounded_key: Option<StorageKeyRequirements>,
/// Decryption key storage requirements
Expand All @@ -53,6 +57,7 @@ pub trait DataContractConfigGettersV0 {

/// Returns whether documents in the contract are mutable by default.
fn documents_mutable_contract_default(&self) -> bool;
fn documents_can_be_deleted_contract_default(&self) -> bool;

/// Encryption key storage requirements
fn requires_identity_encryption_bounded_key(&self) -> Option<StorageKeyRequirements>;
Expand All @@ -78,6 +83,9 @@ pub trait DataContractConfigSettersV0 {
/// Sets whether documents in the contract are mutable by default.
fn set_documents_mutable_contract_default(&mut self, value: bool);

/// Sets whether documents in the contract can be deleted by default.
fn set_documents_can_be_deleted_contract_default(&mut self, value: bool);

/// Sets Encryption key storage requirements.
fn set_requires_identity_encryption_bounded_key(
&mut self,
Expand All @@ -99,6 +107,7 @@ impl std::default::Default for DataContractConfigV0 {
keeps_history: DEFAULT_CONTRACT_KEEPS_HISTORY,
documents_keep_history_contract_default: DEFAULT_CONTRACT_DOCUMENTS_KEEPS_HISTORY,
documents_mutable_contract_default: DEFAULT_CONTRACT_DOCUMENT_MUTABILITY,
documents_can_be_deleted_contract_default: DEFAULT_CONTRACT_DOCUMENTS_CAN_BE_DELETED,
requires_identity_encryption_bounded_key: None,
requires_identity_decryption_bounded_key: None,
}
Expand Down Expand Up @@ -157,6 +166,10 @@ impl DataContractConfigV0 {
.get_optional_bool(config::property::DOCUMENTS_MUTABLE_CONTRACT_DEFAULT)?
.unwrap_or(DEFAULT_CONTRACT_DOCUMENT_MUTABILITY);

let documents_can_be_deleted_contract_default = contract
.get_optional_bool(config::property::DOCUMENTS_CAN_BE_DELETED_CONTRACT_DEFAULT)?
.unwrap_or(DEFAULT_CONTRACT_DOCUMENTS_CAN_BE_DELETED);

let requires_identity_encryption_bounded_key = contract
.get_optional_integer::<u8>(config::property::REQUIRES_IDENTITY_ENCRYPTION_BOUNDED_KEY)?
.map(|int| int.try_into())
Expand All @@ -173,6 +186,7 @@ impl DataContractConfigV0 {
keeps_history,
documents_keep_history_contract_default,
documents_mutable_contract_default,
documents_can_be_deleted_contract_default,
requires_identity_encryption_bounded_key,
requires_identity_decryption_bounded_key,
})
Expand Down
56 changes: 56 additions & 0 deletions packages/rs-dpp/src/data_contract/document_type/accessors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ use crate::data_contract::document_type::{DocumentType, DocumentTypeMutRef, Docu

use platform_value::{Identifier, Value};

use crate::data_contract::document_type::restricted_creation::CreationRestrictionMode;
use crate::data_contract::storage_requirements::keys_for_document_type::StorageKeyRequirements;
use crate::document::transfer::Transferable;
use crate::identity::SecurityLevel;
use crate::nft::TradeMode;
use indexmap::IndexMap;
use std::collections::BTreeSet;
pub use v0::*;
Expand Down Expand Up @@ -87,6 +89,24 @@ impl DocumentTypeV0Getters for DocumentType {
}
}

fn documents_can_be_deleted(&self) -> bool {
match self {
DocumentType::V0(v0) => v0.documents_can_be_deleted(),
}
}

fn trade_mode(&self) -> TradeMode {
match self {
DocumentType::V0(v0) => v0.trade_mode(),
}
}

fn creation_restriction_mode(&self) -> CreationRestrictionMode {
match self {
DocumentType::V0(v0) => v0.creation_restriction_mode(),
}
}

fn documents_transferable(&self) -> Transferable {
match self {
DocumentType::V0(v0) => v0.documents_transferable(),
Expand Down Expand Up @@ -191,12 +211,30 @@ impl<'a> DocumentTypeV0Getters for DocumentTypeRef<'a> {
}
}

fn documents_can_be_deleted(&self) -> bool {
match self {
DocumentTypeRef::V0(v0) => v0.documents_can_be_deleted(),
}
}

fn documents_transferable(&self) -> Transferable {
match self {
DocumentTypeRef::V0(v0) => v0.documents_transferable(),
}
}

fn trade_mode(&self) -> TradeMode {
match self {
DocumentTypeRef::V0(v0) => v0.trade_mode(),
}
}

fn creation_restriction_mode(&self) -> CreationRestrictionMode {
match self {
DocumentTypeRef::V0(v0) => v0.creation_restriction_mode(),
}
}

fn data_contract_id(&self) -> Identifier {
match self {
DocumentTypeRef::V0(v0) => v0.data_contract_id(),
Expand Down Expand Up @@ -295,12 +333,30 @@ impl<'a> DocumentTypeV0Getters for DocumentTypeMutRef<'a> {
}
}

fn documents_can_be_deleted(&self) -> bool {
match self {
DocumentTypeMutRef::V0(v0) => v0.documents_can_be_deleted(),
}
}

fn documents_transferable(&self) -> Transferable {
match self {
DocumentTypeMutRef::V0(v0) => v0.documents_transferable(),
}
}

fn trade_mode(&self) -> TradeMode {
match self {
DocumentTypeMutRef::V0(v0) => v0.trade_mode(),
}
}

fn creation_restriction_mode(&self) -> CreationRestrictionMode {
match self {
DocumentTypeMutRef::V0(v0) => v0.creation_restriction_mode(),
}
}

fn data_contract_id(&self) -> Identifier {
match self {
DocumentTypeMutRef::V0(v0) => v0.data_contract_id(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ use crate::data_contract::document_type::property::DocumentProperty;

use platform_value::{Identifier, Value};

use crate::data_contract::document_type::restricted_creation::CreationRestrictionMode;
use crate::data_contract::storage_requirements::keys_for_document_type::StorageKeyRequirements;
use crate::document::transfer::Transferable;
use crate::identity::SecurityLevel;
use crate::nft::TradeMode;
use indexmap::IndexMap;
use std::collections::BTreeSet;

Expand Down Expand Up @@ -45,9 +47,18 @@ pub trait DocumentTypeV0Getters {
/// Returns the documents mutable flag of the document type.
fn documents_mutable(&self) -> bool;

/// Returns the documents can be deleted flag of the document type.
fn documents_can_be_deleted(&self) -> bool;

/// Returns the documents transferable flag of the document type.
fn documents_transferable(&self) -> Transferable;

/// Returns the documents trade mode flag of the document type.
fn trade_mode(&self) -> TradeMode;

/// Returns the creation restriction mode.
fn creation_restriction_mode(&self) -> CreationRestrictionMode;

/// Returns the data contract id of the document type.
fn data_contract_id(&self) -> Identifier;

Expand Down
Loading