Skip to content
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

feat: token support #2383

Draft
wants to merge 56 commits into
base: v1.8-dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
5e9c441
worked on token support
QuantumExplorer May 2, 2024
13f8674
more work
QuantumExplorer May 2, 2024
b9ed063
more work
QuantumExplorer May 2, 2024
6cc1f60
Merge branch 'v1.6-dev' into feat/tokenSupport
QuantumExplorer Nov 14, 2024
6be7906
temp work
QuantumExplorer Nov 15, 2024
2ac97bd
Merge branch 'v1.7-dev' into feat/tokenSupport
QuantumExplorer Dec 1, 2024
a34ff06
more work on tokens
QuantumExplorer Dec 1, 2024
279d16f
added burn transition
QuantumExplorer Dec 1, 2024
cf32dd5
more work on tokens
QuantumExplorer Dec 5, 2024
c72013b
Merge branch 'v1.7-dev' into feat/tokenSupport
QuantumExplorer Dec 5, 2024
71218a4
more work
QuantumExplorer Dec 9, 2024
531aab2
more work
QuantumExplorer Dec 10, 2024
b9235d2
feat(dpp): token meta schema (#2378)
shumkov Dec 10, 2024
154a0b2
more config
QuantumExplorer Dec 10, 2024
0537aa6
more work
QuantumExplorer Dec 10, 2024
148767d
chore: update tokens metaschema
shumkov Dec 10, 2024
79057d4
Merge remote-tracking branch 'origin/feat/tokenSupport' into feat/tok…
shumkov Dec 10, 2024
3049b9e
more work
QuantumExplorer Dec 12, 2024
86166f3
Merge branch 'feat/tokenSupport' of github.com:dashpay/platform into …
QuantumExplorer Dec 12, 2024
e2a5129
compiled dpp
QuantumExplorer Dec 13, 2024
f886d8d
more fixes
QuantumExplorer Dec 14, 2024
dc8e575
more work
QuantumExplorer Dec 15, 2024
b07e1a6
more token work
QuantumExplorer Dec 18, 2024
a5a16c4
tokens compiling
QuantumExplorer Dec 20, 2024
b018d31
more work on tokens
QuantumExplorer Dec 23, 2024
4ecc825
more validation work
QuantumExplorer Dec 24, 2024
4214369
a lot more validation
QuantumExplorer Dec 25, 2024
b30ba05
compiling
QuantumExplorer Dec 26, 2024
40316c0
compiling
QuantumExplorer Dec 27, 2024
e23bcda
a lot more work
QuantumExplorer Dec 28, 2024
4135031
work on group actions
QuantumExplorer Dec 30, 2024
bd541b6
more work on groups
QuantumExplorer Dec 30, 2024
712396b
basic validation of tokens
QuantumExplorer Dec 30, 2024
d3c0260
more work
QuantumExplorer Jan 1, 2025
f3f9eec
more work
QuantumExplorer Jan 1, 2025
83fff2f
tests passing
QuantumExplorer Jan 2, 2025
4712d05
some more work on deserialization of tokens
QuantumExplorer Jan 2, 2025
fbcfd6e
basic strategy structure
QuantumExplorer Jan 2, 2025
39e6d5d
more tests
QuantumExplorer Jan 2, 2025
b21024e
minting is validated
QuantumExplorer Jan 3, 2025
78394e0
more token tests
QuantumExplorer Jan 4, 2025
8379665
transfer tests
QuantumExplorer Jan 4, 2025
a4331ce
more tests
QuantumExplorer Jan 5, 2025
22814b0
group actions working
QuantumExplorer Jan 5, 2025
e5e361a
more tests
QuantumExplorer Jan 5, 2025
2d224a1
its cold
QuantumExplorer Jan 5, 2025
726c524
its cold
QuantumExplorer Jan 5, 2025
bb4e761
freeze and unfreeze validation
QuantumExplorer Jan 6, 2025
7a6202a
added info queries
QuantumExplorer Jan 6, 2025
239c2cb
more work
QuantumExplorer Jan 6, 2025
d10ffa2
Merge branch 'v1.8-dev' into feat/tokenSupport
QuantumExplorer Jan 6, 2025
da5d87a
fixes for wasm
QuantumExplorer Jan 6, 2025
e701008
more state transitions
QuantumExplorer Jan 7, 2025
084f722
more work
QuantumExplorer Jan 7, 2025
6aaadb6
more work
QuantumExplorer Jan 7, 2025
779114d
more token work
QuantumExplorer Jan 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
11 changes: 11 additions & 0 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ members = [
"packages/rs-json-schema-compatibility-validator",
"packages/check-features",
"packages/wallet-utils-contract",
"packages/token-history-contract"
]
[workspace.package]

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@
"packages/masternode-reward-shares-contract",
"packages/dash-spv",
"packages/wasm-dpp",
"packages/withdrawals-contract"
"packages/withdrawals-contract",
"packages/token-history-contract"
],
"resolutions": {
"elliptic": "6.5.7",
Expand Down
12 changes: 10 additions & 2 deletions packages/dapi-grpc/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fn configure_platform(mut platform: MappingConfig) -> MappingConfig {
// Derive features for versioned messages
//
// "GetConsensusParamsRequest" is excluded as this message does not support proofs
const VERSIONED_REQUESTS: [&str; 30] = [
const VERSIONED_REQUESTS: [&str; 34] = [
"GetDataContractHistoryRequest",
"GetDataContractRequest",
"GetDataContractsRequest",
Expand Down Expand Up @@ -78,14 +78,18 @@ fn configure_platform(mut platform: MappingConfig) -> MappingConfig {
"GetEvonodesProposedEpochBlocksByIdsRequest",
"GetEvonodesProposedEpochBlocksByRangeRequest",
"GetStatusRequest",
"GetIdentityTokenBalancesRequest",
"GetIdentitiesTokenBalancesRequest",
"GetIdentityTokenInfosRequest",
"GetIdentitiesTokenInfosRequest",
];

// The following responses are excluded as they don't support proofs:
// - "GetConsensusParamsResponse"
// - "GetStatusResponse"
//
// "GetEvonodesProposedEpochBlocksResponse" is used for 2 Requests
const VERSIONED_RESPONSES: [&str; 29] = [
const VERSIONED_RESPONSES: [&str; 33] = [
"GetDataContractHistoryResponse",
"GetDataContractResponse",
"GetDataContractsResponse",
Expand Down Expand Up @@ -115,6 +119,10 @@ fn configure_platform(mut platform: MappingConfig) -> MappingConfig {
"GetVotePollsByEndDateResponse",
"GetTotalCreditsInPlatformResponse",
"GetEvonodesProposedEpochBlocksResponse",
"GetIdentityTokenBalancesResponse",
"GetIdentitiesTokenBalancesResponse",
"GetIdentityTokenInfosResponse",
"GetIdentitiesTokenInfosResponse",
];

check_unique(&VERSIONED_REQUESTS).expect("VERSIONED_REQUESTS");
Expand Down
146 changes: 146 additions & 0 deletions packages/dapi-grpc/protos/platform/v0/platform.proto
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ service Platform {
rpc getPathElements(GetPathElementsRequest) returns (GetPathElementsResponse);
rpc getStatus(GetStatusRequest) returns (GetStatusResponse);
rpc getCurrentQuorumsInfo(GetCurrentQuorumsInfoRequest) returns (GetCurrentQuorumsInfoResponse);
rpc getIdentityTokenBalances(GetIdentityTokenBalancesRequest) returns (GetIdentityTokenBalancesResponse);
rpc getIdentitiesTokenBalances(GetIdentitiesTokenBalancesRequest) returns (GetIdentitiesTokenBalancesResponse);
rpc getIdentityTokenInfos(GetIdentityTokenInfosRequest) returns (GetIdentityTokenInfosResponse);
rpc getIdentitiesTokenInfos(GetIdentitiesTokenInfosRequest) returns (GetIdentitiesTokenInfosResponse);
}

// Proof message includes cryptographic proofs for validating responses
Expand Down Expand Up @@ -1215,3 +1219,145 @@ message GetCurrentQuorumsInfoResponse {
}
oneof version { GetCurrentQuorumsInfoResponseV0 v0 = 1; }
}

message GetIdentityTokenBalancesRequest {
message GetIdentityTokenBalancesRequestV0 {
bytes identity_id = 1; // ID of the identity
repeated bytes token_ids = 2; // List of token IDs
bool prove = 3; // Flag to request a proof as the response
}
oneof version {
GetIdentityTokenBalancesRequestV0 v0 = 1;
}
}

message GetIdentityTokenBalancesResponse {
message GetIdentityTokenBalancesResponseV0 {
message TokenBalanceEntry {
bytes token_id = 1; // Token ID
optional uint64 balance = 2; // Token balance for the contract
}

message TokenBalances {
repeated TokenBalanceEntry token_balances = 1; // List of token balances
}

oneof result {
TokenBalances token_balances = 1; // Actual token balances
Proof proof = 2; // Proof of the token balances, if requested
}
ResponseMetadata metadata = 3; // Metadata about the blockchain state
}
oneof version {
GetIdentityTokenBalancesResponseV0 v0 = 1;
}
}

message GetIdentitiesTokenBalancesRequest {
message GetIdentitiesTokenBalancesRequestV0 {
bytes token_id = 1; // Token ID
repeated bytes identity_ids = 2; // List of identity IDs
bool prove = 3; // Flag to request a proof as the response
}
oneof version {
GetIdentitiesTokenBalancesRequestV0 v0 = 1;
}
}

message GetIdentitiesTokenBalancesResponse {
message GetIdentitiesTokenBalancesResponseV0 {
message IdentityTokenBalanceEntry {
bytes identity_id = 1; // Identity ID
optional uint64 balance = 2; // Token balance for the identity
}

message IdentityTokenBalances {
repeated IdentityTokenBalanceEntry identity_token_balances = 1; // List of identity token balances
}

oneof result {
IdentityTokenBalances identity_token_balances = 1; // Actual identity token balances
Proof proof = 2; // Proof of the balances, if requested
}
ResponseMetadata metadata = 3; // Metadata about the blockchain state
}
oneof version {
GetIdentitiesTokenBalancesResponseV0 v0 = 1;
}
}



message GetIdentityTokenInfosRequest {
message GetIdentityTokenInfosRequestV0 {
bytes identity_id = 1;
repeated bytes token_ids = 2;
bool prove = 3;
}
oneof version {
GetIdentityTokenInfosRequestV0 v0 = 1;
}
}

message GetIdentityTokenInfosResponse {
message GetIdentityTokenInfosResponseV0 {
message TokenIdentityInfoEntry {
bool frozen = 1;
}

message TokenInfoEntry {
bytes token_id = 1;
optional TokenIdentityInfoEntry info = 2;
}

message TokenInfos {
repeated TokenInfoEntry token_infos = 1;
}

oneof result {
TokenInfos token_infos = 1;
Proof proof = 2;
}
ResponseMetadata metadata = 3;
}
oneof version {
GetIdentityTokenInfosResponseV0 v0 = 1;
}
}

message GetIdentitiesTokenInfosRequest {
message GetIdentitiesTokenInfosRequestV0 {
bytes token_id = 1;
repeated bytes identity_ids = 2;
bool prove = 3;
}
oneof version {
GetIdentitiesTokenInfosRequestV0 v0 = 1;
}
}

message GetIdentitiesTokenInfosResponse {
message GetIdentitiesTokenInfosResponseV0 {
message TokenIdentityInfoEntry {
bool frozen = 1;
}

message TokenInfoEntry {
bytes identity_id = 1;
optional TokenIdentityInfoEntry info = 2;
}

message IdentityTokenInfos {
repeated TokenInfoEntry token_infos = 1;
}

oneof result {
IdentityTokenInfos identity_token_infos = 1;
Proof proof = 2;
}
ResponseMetadata metadata = 3;
}
oneof version {
GetIdentitiesTokenInfosResponseV0 v0 = 1;
}
}
1 change: 1 addition & 0 deletions packages/data-contracts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ dashpay-contract = { path = "../dashpay-contract" }
feature-flags-contract = { path = "../feature-flags-contract" }
platform-value = { path = "../rs-platform-value" }
wallet-utils-contract = { path = "../wallet-utils-contract" }
token-history-contract = { path = "../token-history-contract" }
17 changes: 17 additions & 0 deletions packages/data-contracts/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,20 @@ impl From<wallet_utils_contract::Error> for Error {
}
}
}

impl From<token_history_contract::Error> for Error {
fn from(e: token_history_contract::Error) -> Self {
match e {
token_history_contract::Error::UnknownVersionMismatch {
method,
known_versions,
received,
} => Error::UnknownVersionMismatch {
method,
known_versions,
received,
},
token_history_contract::Error::InvalidSchemaJson(e) => Error::InvalidSchemaJson(e),
}
}
}
10 changes: 10 additions & 0 deletions packages/data-contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub use feature_flags_contract;
pub use masternode_reward_shares_contract;
use platform_value::Identifier;
use platform_version::version::PlatformVersion;
pub use token_history_contract;
pub use wallet_utils_contract;
pub use withdrawals_contract;

Expand All @@ -21,6 +22,7 @@ pub enum SystemDataContract {
DPNS = 3,
Dashpay = 4,
WalletUtils = 5,
TokenHistory = 6,
}

pub struct DataContractSource {
Expand All @@ -40,6 +42,7 @@ impl SystemDataContract {
SystemDataContract::DPNS => dpns_contract::ID_BYTES,
SystemDataContract::Dashpay => dashpay_contract::ID_BYTES,
SystemDataContract::WalletUtils => wallet_utils_contract::ID_BYTES,
SystemDataContract::TokenHistory => token_history_contract::ID_BYTES,
};
Identifier::new(bytes)
}
Expand Down Expand Up @@ -92,6 +95,13 @@ impl SystemDataContract {
definitions: wallet_utils_contract::load_definitions(platform_version)?,
document_schemas: wallet_utils_contract::load_documents_schemas(platform_version)?,
},
SystemDataContract::TokenHistory => DataContractSource {
id_bytes: token_history_contract::ID_BYTES,
owner_id_bytes: token_history_contract::OWNER_ID_BYTES,
version: platform_version.system_data_contracts.wallet as u32,
definitions: token_history_contract::load_definitions(platform_version)?,
document_schemas: token_history_contract::load_documents_schemas(platform_version)?,
},
};

Ok(data)
Expand Down
Loading