Skip to content

Commit

Permalink
Final push
Browse files Browse the repository at this point in the history
  • Loading branch information
dastansam committed Mar 22, 2024
1 parent cb03208 commit 3c27d5d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ WORKDIR /app
COPY . .

# Build the substrate node
RUN cargo build --release
RUN --mount=type=cache,target=/usr/local/cargo/registry \
cargo build --release --locked --features docker

# Use a smaller base image for the final image
FROM debian:bullseye-slim
Expand Down
1 change: 1 addition & 0 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,4 @@ runtime-benchmarks = [
# Enable features that allow the runtime to be tried and debugged. Name might be subject to change
# in the near future.
try-runtime = ["iso-8583-runtime/try-runtime", "try-runtime-cli/try-runtime"]
docker = []
4 changes: 4 additions & 0 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ fn testnet_genesis(
AccountId::from_ss58check("5HRD6MDjy9XjX6gNhj7wSAinvpNw1DptfR73LZBz68zH4Gex")
.expect("valid account; qed"),
],
#[cfg(feature = "docker")]
payment_processor_url: b"http://host.docker.internal:3001".to_vec(),
#[cfg(not(feature = "docker"))]
payment_processor_url: b"http://localhost:3001".to_vec(),
},
}
}
21 changes: 20 additions & 1 deletion pallets/iso-8583/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ pub mod pallet {
#[pallet::getter(fn last_storage_key)]
pub type LastIteratedStorageKey<T: Config> = StorageValue<_, StorageKey, OptionQuery>;

/// Payment processor url
#[pallet::storage]
#[pallet::getter(fn payment_processor_url)]
pub type PaymentProcessorUrl<T> = StorageValue<_, StorageKey, ValueQuery>;

/// Events of this pallet
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
Expand Down Expand Up @@ -534,11 +539,17 @@ pub mod pallet {
pub struct GenesisConfig<T: Config> {
pub oracle_accounts: Vec<AccountIdOf<T>>,
pub accounts: Vec<AccountIdOf<T>>,
pub payment_processor_url: Vec<u8>,
}

#[pallet::genesis_build]
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
fn build(&self) {
let payment_processor_url: StorageKey =
self.payment_processor_url.clone().try_into().unwrap();

PaymentProcessorUrl::<T>::put(payment_processor_url);

for oracle_account in &self.oracle_accounts {
OracleAccounts::<T>::insert(oracle_account, ());
}
Expand Down Expand Up @@ -693,8 +704,16 @@ impl<T: Config> Pallet<T> {
])
.serialize();

let url_base = PaymentProcessorUrl::<T>::get();

let mut url = url_base.into_inner();
url.push(b'/');
url.extend_from_slice(b"balances");

let url_str = core::str::from_utf8(&url).map_err(|_| http::Error::IoError)?;

// Form the request
let request = http::Request::new("http://localhost:3001/balances")
let request = http::Request::new(url_str)
.method(http::Method::Post)
.deadline(deadline)
.body(vec![body])
Expand Down

0 comments on commit 3c27d5d

Please sign in to comment.