Skip to content

Commit

Permalink
made some public functions package functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Foivos committed Nov 25, 2024
1 parent d91e4b4 commit 964553d
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 31 deletions.
7 changes: 2 additions & 5 deletions move/axelar_gateway/sources/types/message.move
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public struct Message has copy, drop, store {
}

/// -----------------
/// Public Functions
/// Package Functions
/// -----------------
public fun new(
public(package) fun new(
source_chain: String,
message_id: String,
source_address: String,
Expand All @@ -36,9 +36,6 @@ public fun new(
}
}

/// -----------------
/// Package Functions
/// -----------------
public(package) fun peel(bcs: &mut BCS): Message {
// TODO: allow UTF-8 strings? Or keep it as more generic bytes?
let source_chain = bcs.peel_vec_u8().to_ascii_string();
Expand Down
15 changes: 6 additions & 9 deletions move/axelar_gateway/sources/types/proof.move
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,20 @@ const ESignerNotFound: vector<u8> =
#[error]
const ERedundantSignaturesProvided: vector<u8> =
b"redundant signatures provided";

// ----------------
// Public Functions
// ----------------
// -----------------
// Package Functions
// -----------------
/// The signers of the proof
public fun signers(proof: &Proof): &WeightedSigners {
public(package) fun signers(proof: &Proof): &WeightedSigners {
&proof.signers
}

/// The proof signatures
public fun signatures(proof: &Proof): &vector<Signature> {
public(package) fun signatures(proof: &Proof): &vector<Signature> {
&proof.signatures
}

// -----------------
// Package Functions
// -----------------
public(package) fun new_signature(bytes: vector<u8>): Signature {
assert!(bytes.length() == SIGNATURE_LENGTH, EInvalidSignatureLength);

Expand Down
7 changes: 5 additions & 2 deletions move/axelar_gateway/sources/types/weighted_signer.move
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ public struct WeightedSigner has copy, drop, store {
weight: u128,
}

public fun pub_key(self: &WeightedSigner): vector<u8> {
// -----------------
// Package Functions
// -----------------
public(package) fun pub_key(self: &WeightedSigner): vector<u8> {
self.pub_key
}

public fun weight(self: &WeightedSigner): u128 {
public(package) fun weight(self: &WeightedSigner): u128 {
self.weight
}

Expand Down
8 changes: 4 additions & 4 deletions move/gas_service/sources/versioned/gas_service_v0.move
Original file line number Diff line number Diff line change
Expand Up @@ -130,22 +130,22 @@ fun take(
// Test Only
// ---------
#[test_only]
public fun version_control_mut(self: &mut GasService_v0): &mut VersionControl {
public(package) fun version_control_mut(self: &mut GasService_v0): &mut VersionControl {
&mut self.version_control
}

#[test_only]
public fun balance(self: &GasService_v0): &Balance<SUI> {
public(package) fun balance(self: &GasService_v0): &Balance<SUI> {
&self.balance
}

#[test_only]
public fun balance_mut(self: &mut GasService_v0): &mut Balance<SUI> {
public(package) fun balance_mut(self: &mut GasService_v0): &mut Balance<SUI> {
&mut self.balance
}

#[test_only]
public fun destroy_for_testing(self: GasService_v0) {
public(package) fun destroy_for_testing(self: GasService_v0) {
let GasService_v0 { balance, version_control: _ } = self;
balance.destroy_for_testing();
}
13 changes: 5 additions & 8 deletions move/its/sources/types/address_tracker.move
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ public struct InterchainAddressTracker has store {
trusted_addresses: Table<String, String>,
}

// -------
// Getters
// -------
// -----------------
// Package Functions
// -----------------
/// Get the trusted address for a chain.
public fun trusted_address(
public(package) fun trusted_address(
self: &InterchainAddressTracker,
chain_name: String,
): &String {
Expand All @@ -36,17 +36,14 @@ public fun trusted_address(
}

/// Check if the given address is trusted for the given chain.
public fun is_trusted_address(
public(package) fun is_trusted_address(
self: &InterchainAddressTracker,
chain_name: String,
addr: String,
): bool {
self.trusted_addresses.contains(chain_name) && self.trusted_addresses[chain_name] == addr
}

// -----------------
// Package Functions
// -----------------
/// Create a new interchain address tracker.
public(package) fun new(ctx: &mut TxContext): InterchainAddressTracker {
InterchainAddressTracker {
Expand Down
5 changes: 3 additions & 2 deletions move/its/sources/types/coin_info.move
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ public fun from_metadata<T>(metadata: CoinMetadata<T>): CoinInfo<T> {
}
}

// === Views ===

// -----
// Views
// -----
public fun name<T>(self: &CoinInfo<T>): String {
self.name
}
Expand Down
5 changes: 4 additions & 1 deletion move/its/sources/types/trusted_addresses.move
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ public fun new(
}
}

public fun destroy(self: TrustedAddresses): (vector<String>, vector<String>) {
/// -----------------
/// Package Functions
/// -----------------
public(package) fun destroy(self: TrustedAddresses): (vector<String>, vector<String>) {
let TrustedAddresses { trusted_chains, trusted_addresses } = self;
(trusted_chains, trusted_addresses)
}
Expand Down

0 comments on commit 964553d

Please sign in to comment.