Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/solana-sdk-updates' into solana-…
Browse files Browse the repository at this point in the history
…sdk-updates
  • Loading branch information
gallynaut committed Jun 28, 2023
2 parents 2e96011 + cb03141 commit 63f774d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
17 changes: 13 additions & 4 deletions examples/functions/01_basic_oracle/sgx-function/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,24 @@ WORKDIR /home/root/switchboard-function/sgx-function
# cargo strip && \
# mv /home/root/switchboard-function/sgx-function/target/release/${CARGO_NAME} /sgx

RUN cargo build --release && \
RUN --mount=type=cache,target=/usr/local/cargo/registry --mount=type=cache,target=/home/root/switchboard-function/sgx-function/target \
cargo build --release && \
cargo strip && \
mv /home/root/switchboard-function/sgx-function/target/release/${CARGO_NAME} /sgx
mv target/release/basic-oracle-function /sgx/app

FROM switchboardlabs/sgx-function

# Copy the binary
WORKDIR /sgx
COPY --from=builder /sgx/${CARGO_NAME} /sgx/app
COPY --from=builder /sgx/app /sgx

# Get the measurement from the enclave
RUN /get_measurement.sh
RUN /get_measurement.sh

# COPY configs/app.manifest.template .
# COPY configs/boot.sh /boot.sh
RUN gramine-manifest /app.manifest.template > app.manifest
# RUN gramine-sgx-gen-private-key
RUN gramine-sgx-sign --manifest app.manifest --output app.manifest.sgx | tail -2 | tee /measurement.txt

ENTRYPOINT ["bash", "/boot.sh"]
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ WORKDIR /home/root/solana-sdk
COPY ./rust/switchboard-solana/Cargo.toml \
./rust/switchboard-solana/Cargo.lock \
./rust/switchboard-solana/

COPY ./examples/functions/01_basic_oracle/Cargo.toml \
./examples/functions/01_basic_oracle/Cargo.lock \
./examples/functions/01_basic_oracle/
Expand Down Expand Up @@ -40,4 +40,5 @@ WORKDIR /sgx
COPY --from=builder /sgx/${CARGO_NAME} /sgx/app

# Get the measurement from the enclave
RUN /get_measurement.sh
RUN /get_measurement.sh
ENTRYPOINT ["bash", "/boot.sh"]
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::*;
pub use switchboard_utils::reqwest;

use serde::Deserialize;
use basic_oracle::{TradingSymbol, OracleDataBorsh};

const ONE: i128 = 1000000000;

Expand All @@ -31,8 +32,8 @@ pub struct IndexData {
pub hr: Ticker,
pub d: Ticker,
}
impl Into<OracleData> for IndexData {
fn into(self) -> OracleData {
impl Into<OracleDataBorsh> for IndexData {
fn into(self) -> OracleDataBorsh {
let oracle_timestamp = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.unwrap_or_default()
Expand All @@ -48,7 +49,7 @@ impl Into<OracleData> for IndexData {
let twap_1hr = parse_string_value(self.hr.weightedAvgPrice.as_str());
let twap_24hr = parse_string_value(self.d.weightedAvgPrice.as_str());

OracleData {
OracleDataBorsh {
oracle_timestamp,
price,
volume_1hr,
Expand Down Expand Up @@ -135,7 +136,7 @@ impl Binance {
data: self.btc_usdt.clone().into(),
},
OracleDataWithTradingSymbol {
symbol: TradingSymbol::Usc,
symbol: TradingSymbol::Usdc,
data: self.usdc_usdt.clone().into(),
},
OracleDataWithTradingSymbol {
Expand Down
2 changes: 1 addition & 1 deletion examples/functions/01_basic_oracle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub use utils::*;
pub mod actions;
pub use actions::*;

declare_id!("HgVykECRLmtSfquJz7NTBg5H8SfL2ehTFZnzfDJQuxt2");
declare_id!("6tdxUefBQRpL1CbJhzXgcMtWChKqXj9P9Rz2bvTWiiar");

pub const PROGRAM_SEED: &[u8] = b"BASICORACLE";

Expand Down

0 comments on commit 63f774d

Please sign in to comment.