Skip to content

Commit a28159d

Browse files
chore(ffi): Add docs to remote impls (#111)
* chore(ffi): Add docs to remote impls * update bindings * add graphql client doc * bindings * add more missing comments * bindings again --------- Co-authored-by: Thibault Martinez <[email protected]>
1 parent d180d51 commit a28159d

File tree

14 files changed

+1334
-0
lines changed

14 files changed

+1334
-0
lines changed

bindings/go/iota_sdk_ffi/iota_sdk_ffi.go

Lines changed: 302 additions & 0 deletions
Large diffs are not rendered by default.

bindings/kotlin/lib/iota_sdk/iota_sdk_ffi.kt

Lines changed: 382 additions & 0 deletions
Large diffs are not rendered by default.

bindings/python/lib/iota_sdk_ffi.py

Lines changed: 422 additions & 0 deletions
Large diffs are not rendered by default.

crates/iota-sdk-ffi/src/graphql.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ use crate::{
3232
},
3333
};
3434

35+
/// The GraphQL client for interacting with the IOTA blockchain.
3536
#[derive(uniffi::Object)]
3637
pub struct GraphQLClient(RwLock<iota_graphql_client::Client>);
3738

crates/iota-sdk-ffi/src/types/checkpoint.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,17 @@ impl From<CheckpointSummary> for iota_types::CheckpointSummary {
133133
}
134134
}
135135

136+
/// A commitment made by a checkpoint.
137+
///
138+
/// # BCS
139+
///
140+
/// The BCS serialized form for this type is defined by the following ABNF:
141+
///
142+
/// ```text
143+
/// ; CheckpointCommitment is an enum and each variant is prefixed with its index
144+
/// checkpoint-commitment = ecmh-live-object-set
145+
/// ecmh-live-object-set = %x00 digest
146+
/// ```
136147
#[derive(Clone, Debug, derive_more::From, uniffi::Object)]
137148
pub struct CheckpointCommitment(pub iota_types::CheckpointCommitment);
138149

crates/iota-sdk-ffi/src/types/crypto/multisig.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,34 @@ impl MultisigMemberSignature {
9898
}
9999
}
100100

101+
/// Enum of valid public keys for multisig committee members
102+
///
103+
/// # BCS
104+
///
105+
/// The BCS serialized form for this type is defined by the following ABNF:
106+
///
107+
/// ```text
108+
/// multisig-member-public-key = ed25519-multisig-member-public-key /
109+
/// secp256k1-multisig-member-public-key /
110+
/// secp256r1-multisig-member-public-key /
111+
/// zklogin-multisig-member-public-key
112+
///
113+
/// ed25519-multisig-member-public-key = %x00 ed25519-public-key
114+
/// secp256k1-multisig-member-public-key = %x01 secp256k1-public-key
115+
/// secp256r1-multisig-member-public-key = %x02 secp256r1-public-key
116+
/// zklogin-multisig-member-public-key = %x03 zklogin-public-identifier
117+
/// ```
118+
///
119+
/// There is also a legacy encoding for this type defined as:
120+
///
121+
/// ```text
122+
/// legacy-multisig-member-public-key = string ; which is valid base64 encoded
123+
/// ; and the decoded bytes are defined
124+
/// ; by legacy-public-key
125+
/// legacy-public-key = (ed25519-flag ed25519-public-key) /
126+
/// (secp256k1-flag secp256k1-public-key) /
127+
/// (secp256r1-flag secp256r1-public-key)
128+
/// ```
101129
#[derive(Clone, Debug, derive_more::From, uniffi::Object)]
102130
pub struct MultisigMemberPublicKey(pub iota_types::MultisigMemberPublicKey);
103131

crates/iota-sdk-ffi/src/types/crypto/zklogin.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,15 @@ impl ZkLoginProof {
215215
}
216216
}
217217

218+
/// A claim of the iss in a zklogin proof
219+
///
220+
/// # BCS
221+
///
222+
/// The BCS serialized form for this type is defined by the following ABNF:
223+
///
224+
/// ```text
225+
/// zklogin-claim = string u8
226+
/// ```
218227
#[uniffi::remote(Record)]
219228
pub struct ZkLoginClaim {
220229
pub value: String,

crates/iota-sdk-ffi/src/types/execution_status.rs

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,19 +574,71 @@ impl From<MoveLocation> for iota_types::MoveLocation {
574574
}
575575
}
576576

577+
/// An error with an argument to a command
578+
///
579+
/// # BCS
580+
///
581+
/// The BCS serialized form for this type is defined by the following ABNF:
582+
///
583+
/// ```text
584+
/// command-argument-error = type-mismatch
585+
/// =/ invalid-bcs-bytes
586+
/// =/ invalid-usage-of-pure-argument
587+
/// =/ invalid-argument-to-private-entry-function
588+
/// =/ index-out-of-bounds
589+
/// =/ secondary-index-out-of-bound
590+
/// =/ invalid-result-arity
591+
/// =/ invalid-gas-coin-usage
592+
/// =/ invalid-value-usage
593+
/// =/ invalid-object-by-value
594+
/// =/ invalid-object-by-mut-ref
595+
/// =/ shared-object-operation-not-allowed
596+
///
597+
/// type-mismatch = %x00
598+
/// invalid-bcs-bytes = %x01
599+
/// invalid-usage-of-pure-argument = %x02
600+
/// invalid-argument-to-private-entry-function = %x03
601+
/// index-out-of-bounds = %x04 u16
602+
/// secondary-index-out-of-bound = %x05 u16 u16
603+
/// invalid-result-arity = %x06 u16
604+
/// invalid-gas-coin-usage = %x07
605+
/// invalid-value-usage = %x08
606+
/// invalid-object-by-value = %x09
607+
/// invalid-object-by-mut-ref = %x0a
608+
/// shared-object-operation-not-allowed = %x0b
609+
/// ```
577610
#[uniffi::remote(Enum)]
578611
pub enum CommandArgumentError {
612+
/// The type of the value does not match the expected type
579613
TypeMismatch,
614+
/// The argument cannot be deserialized into a value of the specified type
580615
InvalidBcsBytes,
616+
/// The argument cannot be instantiated from raw bytes
581617
InvalidUsageOfPureArgument,
618+
/// Invalid argument to private entry function.
619+
/// Private entry functions cannot take arguments from other Move functions.
582620
InvalidArgumentToPrivateEntryFunction,
621+
/// Out of bounds access to input or results
583622
IndexOutOfBounds { index: u16 },
623+
/// Out of bounds access to subresult
584624
SecondaryIndexOutOfBounds { result: u16, subresult: u16 },
625+
/// Invalid usage of result.
626+
/// Expected a single result but found either no return value or multiple.
585627
InvalidResultArity { result: u16 },
628+
/// Invalid usage of Gas coin.
629+
/// The Gas coin can only be used by-value with a TransferObjects command.
586630
InvalidGasCoinUsage,
631+
/// Invalid usage of move value.
632+
// Mutably borrowed values require unique usage.
633+
// Immutably borrowed values cannot be taken or borrowed mutably.
634+
// Taken values cannot be used again.
587635
InvalidValueUsage,
636+
/// Immutable objects cannot be passed by-value.
588637
InvalidObjectByValue,
638+
/// Immutable objects cannot be passed by mutable reference, &mut.
589639
InvalidObjectByMutRef,
640+
/// Shared object operations such a wrapping, freezing, or converting to
641+
/// owned are not allowed.
590642
SharedObjectOperationNotAllowed,
591643
}
592644

@@ -695,8 +747,21 @@ impl From<PackageUpgradeError> for iota_types::PackageUpgradeError {
695747
}
696748
}
697749

750+
/// An error with a type argument
751+
///
752+
/// # BCS
753+
///
754+
/// The BCS serialized form for this type is defined by the following ABNF:
755+
///
756+
/// ```text
757+
/// type-argument-error = type-not-found / constraint-not-satisfied
758+
/// type-not-found = %x00
759+
/// constraint-not-satisfied = %x01
760+
/// ```
698761
#[uniffi::remote(Enum)]
699762
pub enum TypeArgumentError {
763+
/// A type was not found in the module specified
700764
TypeNotFound,
765+
/// A type provided did not match the specified constraint
701766
ConstraintNotSatisfied,
702767
}

crates/iota-sdk-ffi/src/types/gas.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,55 @@
33

44
use iota_types::GasCostSummary;
55

6+
/// Summary of gas charges.
7+
///
8+
/// Storage is charged independently of computation.
9+
/// There are 3 parts to the storage charges:
10+
/// `storage_cost`: it is the charge of storage at the time the transaction is
11+
/// executed. The cost of storage is the number of bytes of the
12+
/// objects being mutated multiplied by a variable storage cost
13+
/// per byte `storage_rebate`: this is the amount a user gets back when
14+
/// manipulating an object. The `storage_rebate` is the
15+
/// `storage_cost` for an object minus fees. `non_refundable_storage_fee`: not
16+
/// all the value of the object storage cost is
17+
/// given back to user and there is a small fraction that
18+
/// is kept by the system. This value tracks that charge.
19+
///
20+
/// When looking at a gas cost summary the amount charged to the user is
21+
/// `computation_cost + storage_cost - storage_rebate`
22+
/// and that is the amount that is deducted from the gas coins.
23+
/// `non_refundable_storage_fee` is collected from the objects being
24+
/// mutated/deleted and it is tracked by the system in storage funds.
25+
///
26+
/// Objects deleted, including the older versions of objects mutated, have the
27+
/// storage field on the objects added up to a pool of "potential rebate". This
28+
/// rebate then is reduced by the "nonrefundable rate" such that:
29+
/// `potential_rebate(storage cost of deleted/mutated objects) =
30+
/// storage_rebate + non_refundable_storage_fee`
31+
///
32+
/// # BCS
33+
///
34+
/// The BCS serialized form for this type is defined by the following ABNF:
35+
///
36+
/// ```text
37+
/// gas-cost-summary = u64 ; computation-cost
38+
/// u64 ; storage-cost
39+
/// u64 ; storage-rebate
40+
/// u64 ; non-refundable-storage-fee
41+
/// ```
642
#[uniffi::remote(Record)]
743
pub struct GasCostSummary {
44+
/// Cost of computation/execution
845
pub computation_cost: u64,
46+
/// The burned component of the computation/execution costs
947
pub computation_cost_burned: u64,
48+
/// Storage cost, it's the sum of all storage cost for all objects created
49+
/// or mutated.
1050
pub storage_cost: u64,
51+
/// The amount of storage cost refunded to the user for all objects deleted
52+
/// or mutated in the transaction.
1153
pub storage_rebate: u64,
54+
/// The fee for the rebate. The portion of the storage rebate kept by the
55+
/// system.
1256
pub non_refundable_storage_fee: u64,
1357
}

crates/iota-sdk-ffi/src/types/graphql.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,7 @@ impl From<Validator> for iota_graphql_client::query_types::Validator {
507507
}
508508
}
509509

510+
/// The credentials related fields associated with a validator.
510511
#[uniffi::remote(Record)]
511512
pub struct ValidatorCredentials {
512513
pub authority_pub_key: Option<Base64>,

0 commit comments

Comments
 (0)