Skip to content

Commit

Permalink
patch rust bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
0o-de-lally committed Nov 14, 2023
1 parent dc73cfb commit dbfb256
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 35 deletions.
48 changes: 24 additions & 24 deletions framework/cached-packages/src/libra_framework_sdk_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,17 +258,17 @@ pub enum EntryFunctionCall {

/// Only callable in tests and testnets where the core resources account exists.
/// Claim the delegated mint capability and destroy the delegated token.
GasCoinClaimMintCapability {},
LibraCoinClaimMintCapability {},

/// Only callable in tests and testnets where the core resources account exists.
/// Create delegated token for the address so the account could claim MintCapability later.
GasCoinDelegateMintCapability {
LibraCoinDelegateMintCapability {
to: AccountAddress,
},

/// Root account can mint to an address. Only used for genesis and tests.
/// The "root" account in smoke tests has some privileges.
GasCoinMintToImpl {
LibraCoinMintToImpl {
dst_addr: AccountAddress,
amount: u64,
},
Expand Down Expand Up @@ -705,9 +705,9 @@ impl EntryFunctionCall {
id,
} => donor_voice_vote_veto_tx(multisig_address, id),
JailUnjailByVoucher { addr } => jail_unjail_by_voucher(addr),
GasCoinClaimMintCapability {} => gas_coin_claim_mint_capability(),
GasCoinDelegateMintCapability { to } => gas_coin_delegate_mint_capability(to),
GasCoinMintToImpl { dst_addr, amount } => gas_coin_mint_to_impl(dst_addr, amount),
LibraCoinClaimMintCapability {} => libra_coin_claim_mint_capability(),
LibraCoinDelegateMintCapability { to } => libra_coin_delegate_mint_capability(to),
LibraCoinMintToImpl { dst_addr, amount } => libra_coin_mint_to_impl(dst_addr, amount),
MultisigAccountAddOwner { new_owner } => multisig_account_add_owner(new_owner),
MultisigAccountAddOwners { new_owners } => multisig_account_add_owners(new_owners),
MultisigAccountApproveTransaction {
Expand Down Expand Up @@ -1515,14 +1515,14 @@ pub fn jail_unjail_by_voucher(addr: AccountAddress) -> TransactionPayload {

/// Only callable in tests and testnets where the core resources account exists.
/// Claim the delegated mint capability and destroy the delegated token.
pub fn gas_coin_claim_mint_capability() -> TransactionPayload {
pub fn libra_coin_claim_mint_capability() -> TransactionPayload {
TransactionPayload::EntryFunction(EntryFunction::new(
ModuleId::new(
AccountAddress::new([
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1,
]),
ident_str!("gas_coin").to_owned(),
ident_str!("libra_coin").to_owned(),
),
ident_str!("claim_mint_capability").to_owned(),
vec![],
Expand All @@ -1532,14 +1532,14 @@ pub fn gas_coin_claim_mint_capability() -> TransactionPayload {

/// Only callable in tests and testnets where the core resources account exists.
/// Create delegated token for the address so the account could claim MintCapability later.
pub fn gas_coin_delegate_mint_capability(to: AccountAddress) -> TransactionPayload {
pub fn libra_coin_delegate_mint_capability(to: AccountAddress) -> TransactionPayload {
TransactionPayload::EntryFunction(EntryFunction::new(
ModuleId::new(
AccountAddress::new([
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1,
]),
ident_str!("gas_coin").to_owned(),
ident_str!("libra_coin").to_owned(),
),
ident_str!("delegate_mint_capability").to_owned(),
vec![],
Expand All @@ -1549,14 +1549,14 @@ pub fn gas_coin_delegate_mint_capability(to: AccountAddress) -> TransactionPaylo

/// Root account can mint to an address. Only used for genesis and tests.
/// The "root" account in smoke tests has some privileges.
pub fn gas_coin_mint_to_impl(dst_addr: AccountAddress, amount: u64) -> TransactionPayload {
pub fn libra_coin_mint_to_impl(dst_addr: AccountAddress, amount: u64) -> TransactionPayload {
TransactionPayload::EntryFunction(EntryFunction::new(
ModuleId::new(
AccountAddress::new([
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1,
]),
ident_str!("gas_coin").to_owned(),
ident_str!("libra_coin").to_owned(),
),
ident_str!("mint_to_impl").to_owned(),
vec![],
Expand Down Expand Up @@ -2723,31 +2723,31 @@ mod decoder {
}
}

pub fn gas_coin_claim_mint_capability(
pub fn libra_coin_claim_mint_capability(
payload: &TransactionPayload,
) -> Option<EntryFunctionCall> {
if let TransactionPayload::EntryFunction(_script) = payload {
Some(EntryFunctionCall::GasCoinClaimMintCapability {})
Some(EntryFunctionCall::LibraCoinClaimMintCapability {})
} else {
None
}
}

pub fn gas_coin_delegate_mint_capability(
pub fn libra_coin_delegate_mint_capability(
payload: &TransactionPayload,
) -> Option<EntryFunctionCall> {
if let TransactionPayload::EntryFunction(script) = payload {
Some(EntryFunctionCall::GasCoinDelegateMintCapability {
Some(EntryFunctionCall::LibraCoinDelegateMintCapability {
to: bcs::from_bytes(script.args().get(0)?).ok()?,
})
} else {
None
}
}

pub fn gas_coin_mint_to_impl(payload: &TransactionPayload) -> Option<EntryFunctionCall> {
pub fn libra_coin_mint_to_impl(payload: &TransactionPayload) -> Option<EntryFunctionCall> {
if let TransactionPayload::EntryFunction(script) = payload {
Some(EntryFunctionCall::GasCoinMintToImpl {
Some(EntryFunctionCall::LibraCoinMintToImpl {
dst_addr: bcs::from_bytes(script.args().get(0)?).ok()?,
amount: bcs::from_bytes(script.args().get(1)?).ok()?,
})
Expand Down Expand Up @@ -3335,16 +3335,16 @@ static SCRIPT_FUNCTION_DECODER_MAP: once_cell::sync::Lazy<EntryFunctionDecoderMa
Box::new(decoder::jail_unjail_by_voucher),
);
map.insert(
"gas_coin_claim_mint_capability".to_string(),
Box::new(decoder::gas_coin_claim_mint_capability),
"libra_coin_claim_mint_capability".to_string(),
Box::new(decoder::libra_coin_claim_mint_capability),
);
map.insert(
"gas_coin_delegate_mint_capability".to_string(),
Box::new(decoder::gas_coin_delegate_mint_capability),
"libra_coin_delegate_mint_capability".to_string(),
Box::new(decoder::libra_coin_delegate_mint_capability),
);
map.insert(
"gas_coin_mint_to_impl".to_string(),
Box::new(decoder::gas_coin_mint_to_impl),
"libra_coin_mint_to_impl".to_string(),
Box::new(decoder::libra_coin_mint_to_impl),
);
map.insert(
"multisig_account_add_owner".to_string(),
Expand Down
Binary file modified framework/releases/head.mrb
Binary file not shown.
2 changes: 1 addition & 1 deletion smoke-tests/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub async fn mint_libra(
) -> anyhow::Result<()> {
let payload = public_info
.transaction_factory()
.payload(libra_stdlib::gas_coin_mint_to_impl(addr, amount));
.payload(libra_stdlib::libra_coin_mint_to_impl(addr, amount));

let mint_txn = public_info
.root_account()
Expand Down
2 changes: 1 addition & 1 deletion tools/genesis/src/genesis_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ pub fn set_final_supply(session: &mut SessionExt, supply_settings: &SupplySettin

exec_function(
session,
"gas_coin",
"libra_coin",
"genesis_set_final_supply",
vec![],
serialized_values,
Expand Down
2 changes: 1 addition & 1 deletion tools/query/tests/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ async fn libra_view_test() {
let c = s.client();

let q = QueryType::View {
function_id: "0x1::gas_coin::supply".to_string(),
function_id: "0x1::libra_coin::supply".to_string(),
type_args: None,
args: None,
};
Expand Down
2 changes: 1 addition & 1 deletion types/src/move_resource/gas_coin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::ONCHAIN_DECIMAL_PRECISION;
pub static GAS_COIN_TYPE: Lazy<TypeTag> = Lazy::new(|| {
TypeTag::Struct(Box::new(StructTag {
address: AccountAddress::ONE,
module: ident_str!("gas_coin").to_owned(),
module: ident_str!("libra_coin").to_owned(),
name: ident_str!("LibraCoin").to_owned(),
type_params: vec![],
}))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ use crate::ONCHAIN_DECIMAL_PRECISION;
/// The balance resource held under an account.
#[derive(Debug, Serialize, Deserialize)]
// #[cfg_attr(any(test, feature = "fuzzing"), derive(Arbitrary))]
pub struct GasCoinStoreResource {
pub struct LibraCoinStoreResource {
coin: u64,
frozen: bool,
deposit_events: EventHandle,
withdraw_events: EventHandle,
}

impl GasCoinStoreResource {
impl LibraCoinStoreResource {
pub fn new(
coin: u64,
frozen: bool,
Expand Down Expand Up @@ -54,7 +53,7 @@ impl GasCoinStoreResource {
}
}

impl MoveStructType for GasCoinStoreResource {
impl MoveStructType for LibraCoinStoreResource {
const MODULE_NAME: &'static IdentStr = ident_str!("coin");
const STRUCT_NAME: &'static IdentStr = ident_str!("CoinStore");

Expand All @@ -63,12 +62,12 @@ impl MoveStructType for GasCoinStoreResource {
}
}

impl MoveResource for GasCoinStoreResource {}
impl MoveResource for LibraCoinStoreResource {}

// TODO: This might break reading from API maybe it must be diem_api_types::U64;

#[derive(Debug, Serialize, Deserialize)]
pub struct GasCoin {
pub struct LibraCoin {
pub value: u64,
}

Expand Down Expand Up @@ -106,7 +105,7 @@ impl SlowWalletBalance {
}

/// This is the same shape as Slow Wallet balance, except that it is scaled.
/// The slow wallet struct contains the coin value as it exists in the database which is without decimals. The decimal precision for GasCoin is 6. So we need to scale it for human consumption.
/// The slow wallet struct contains the coin value as it exists in the database which is without decimals. The decimal precision for LibraCoin is 6. So we need to scale it for human consumption.
#[derive(Debug, Serialize, Deserialize)]

pub struct LibraBalanceDisplay {
Expand Down

0 comments on commit dbfb256

Please sign in to comment.