Skip to content

Commit 662e131

Browse files
authored
feat(sdk): add token payment info to put_document (#2630)
1 parent fa5203c commit 662e131

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

packages/rs-dpp/src/tokens/token_payment_info/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ impl TokenPaymentInfoAccessorsV0 for TokenPaymentInfo {
8686
}
8787
}
8888

89+
fn gas_fees_paid_by(&self) -> GasFeesPaidBy {
90+
match self {
91+
TokenPaymentInfo::V0(v0) => v0.gas_fees_paid_by(),
92+
}
93+
}
94+
8995
// Setters
9096
fn set_payment_token_contract_id(&mut self, id: Option<Identifier>) {
9197
match self {
@@ -111,12 +117,6 @@ impl TokenPaymentInfoAccessorsV0 for TokenPaymentInfo {
111117
}
112118
}
113119

114-
fn gas_fees_paid_by(&self) -> GasFeesPaidBy {
115-
match self {
116-
TokenPaymentInfo::V0(v0) => v0.gas_fees_paid_by(),
117-
}
118-
}
119-
120120
fn set_gas_fees_paid_by(&mut self, payer: GasFeesPaidBy) {
121121
match self {
122122
TokenPaymentInfo::V0(v0) => v0.set_gas_fees_paid_by(payer),

packages/rs-sdk/src/platform/transition/put_document.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,34 @@ use dpp::identity::IdentityPublicKey;
1010
use dpp::state_transition::batch_transition::methods::v0::DocumentsBatchTransitionMethodsV0;
1111
use dpp::state_transition::batch_transition::BatchTransition;
1212
use dpp::state_transition::StateTransition;
13+
use dpp::tokens::token_payment_info::TokenPaymentInfo;
1314

1415
#[async_trait::async_trait]
1516
/// A trait for putting a document to platform
1617
pub trait PutDocument<S: Signer>: Waitable {
1718
/// Puts a document on platform
1819
/// setting settings to `None` sets default connection behavior
20+
#[allow(clippy::too_many_arguments)]
1921
async fn put_to_platform(
2022
&self,
2123
sdk: &Sdk,
2224
document_type: DocumentType,
2325
document_state_transition_entropy: [u8; 32],
2426
identity_public_key: IdentityPublicKey,
27+
token_payment_info: Option<TokenPaymentInfo>,
2528
signer: &S,
2629
settings: Option<PutSettings>,
2730
) -> Result<StateTransition, Error>;
2831

2932
/// Puts an identity on platform and waits for the confirmation proof
33+
#[allow(clippy::too_many_arguments)]
3034
async fn put_to_platform_and_wait_for_response(
3135
&self,
3236
sdk: &Sdk,
3337
document_type: DocumentType,
3438
document_state_transition_entropy: [u8; 32],
3539
identity_public_key: IdentityPublicKey,
40+
token_payment_info: Option<TokenPaymentInfo>,
3641
signer: &S,
3742
settings: Option<PutSettings>,
3843
) -> Result<Document, Error>;
@@ -46,6 +51,7 @@ impl<S: Signer> PutDocument<S> for Document {
4651
document_type: DocumentType,
4752
document_state_transition_entropy: [u8; 32],
4853
identity_public_key: IdentityPublicKey,
54+
token_payment_info: Option<TokenPaymentInfo>,
4955
signer: &S,
5056
settings: Option<PutSettings>,
5157
) -> Result<StateTransition, Error> {
@@ -67,7 +73,7 @@ impl<S: Signer> PutDocument<S> for Document {
6773
&identity_public_key,
6874
new_identity_contract_nonce,
6975
settings.user_fee_increase.unwrap_or_default(),
70-
None,
76+
token_payment_info,
7177
signer,
7278
sdk.version(),
7379
settings.state_transition_creation_options,
@@ -84,6 +90,7 @@ impl<S: Signer> PutDocument<S> for Document {
8490
document_type: DocumentType,
8591
document_state_transition_entropy: [u8; 32],
8692
identity_public_key: IdentityPublicKey,
93+
token_payment_info: Option<TokenPaymentInfo>,
8794
signer: &S,
8895
settings: Option<PutSettings>,
8996
) -> Result<Document, Error> {
@@ -93,6 +100,7 @@ impl<S: Signer> PutDocument<S> for Document {
93100
document_type,
94101
document_state_transition_entropy,
95102
identity_public_key,
103+
token_payment_info,
96104
signer,
97105
settings,
98106
)

0 commit comments

Comments
 (0)