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 30 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
30 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
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.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ members = [
"packages/simple-signer",
"packages/rs-json-schema-compatibility-validator",
"packages/check-features",
"packages/wallet-utils-contract"
"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
68 changes: 68 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,8 @@ 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);
}

// Proof message includes cryptographic proofs for validating responses
Expand Down Expand Up @@ -1215,3 +1217,69 @@ 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;
}
}
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