Skip to content

Commit

Permalink
feat(interchain-token): update interchain token (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahramy authored Dec 3, 2024
1 parent 442c42a commit 6440cf8
Show file tree
Hide file tree
Showing 14 changed files with 939 additions and 51 deletions.
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.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ rust-version = "1.81.0"

[workspace.dependencies]
soroban-sdk = { version = "22.0.0-rc.3" }
soroban-token-sdk = { version = "22.0.0-rc.3" }
cfg-if = { version = "1.0" }
axelar-soroban-std = { version = "^0.1.0", path = "packages/axelar-soroban-std" }
axelar-gas-service = { version = "^0.1.0", path = "contracts/axelar-gas-service" }
Expand Down
10 changes: 1 addition & 9 deletions contracts/axelar-gateway/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,13 @@ use crate::types::{CommandType, Message, Proof, WeightedSigners};
use crate::{auth, event};
use axelar_soroban_std::shared_interfaces::{migrate, UpgradableInterface};
use axelar_soroban_std::shared_interfaces::{MigratableInterface, OwnableInterface};
use axelar_soroban_std::ttl::{INSTANCE_TTL_EXTEND_TO, INSTANCE_TTL_THRESHOLD};
use axelar_soroban_std::{ensure, shared_interfaces};
use soroban_sdk::xdr::ToXdr;
use soroban_sdk::{contract, contractimpl, Address, Bytes, BytesN, Env, String, Vec};

const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION");

/// Parameters for extending the contract instance and its instance storage.
///
/// If the instance's time to live falls below 14 days, it will be extended by 60 days.
///
/// If at least one message is approved every 14 days, the instance should never be archived.
const LEDGERS_PER_DAY: u32 = (24 * 3600) / 5;
const INSTANCE_TTL_THRESHOLD: u32 = 14 * LEDGERS_PER_DAY;
const INSTANCE_TTL_EXTEND_TO: u32 = 60 * LEDGERS_PER_DAY;

#[contract]
pub struct AxelarGateway;

Expand Down
12 changes: 6 additions & 6 deletions contracts/axelar-operators/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl AxelarOperators {
pub fn is_operator(env: Env, account: Address) -> bool {
let key = DataKey::Operators(account);

env.storage().persistent().has(&key)
env.storage().instance().has(&key)
}

/// Add an address as an operator.
Expand All @@ -43,11 +43,11 @@ impl AxelarOperators {
let key = DataKey::Operators(account.clone());

ensure!(
!env.storage().persistent().has(&key),
!env.storage().instance().has(&key),
ContractError::OperatorAlreadyAdded
);

env.storage().persistent().set(&key, &true);
env.storage().instance().set(&key, &true);

event::add_operator(&env, account);
Ok(())
Expand All @@ -62,11 +62,11 @@ impl AxelarOperators {
let key = DataKey::Operators(account.clone());

ensure!(
env.storage().persistent().has(&key),
env.storage().instance().has(&key),
ContractError::NotAnOperator
);

env.storage().persistent().remove(&key);
env.storage().instance().remove(&key);

event::remove_operator(&env, account);
Ok(())
Expand All @@ -85,7 +85,7 @@ impl AxelarOperators {
let key = DataKey::Operators(operator);

ensure!(
env.storage().persistent().has(&key),
env.storage().instance().has(&key),
ContractError::NotAnOperator
);

Expand Down
6 changes: 6 additions & 0 deletions contracts/interchain-token/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,25 @@
name = "interchain-token"
version = "0.1.0"
edition = { workspace = true }
description = "Contract related to Interchain Token."
license = "MIT"
publish = true

[lib]
crate-type = ["cdylib", "rlib"]

[dependencies]
axelar-soroban-std = { workspace = true }
cfg-if = { workspace = true }
soroban-sdk = { workspace = true }
soroban-token-sdk = { workspace = true }

[dev-dependencies]
axelar-soroban-std = { workspace = true, features = ["testutils"] }
soroban-sdk = { workspace = true, features = ["testutils"] }

[features]
library = [] # Only export the contract interface
testutils = ["soroban-sdk/testutils", "axelar-soroban-std/testutils"]

[lints]
Expand Down
Loading

0 comments on commit 6440cf8

Please sign in to comment.