discriminator fix
This commit is contained in:
parent
29248b787c
commit
3b62e3784e
|
@ -9,6 +9,15 @@ use basic_oracle::{TradingSymbol, OracleDataBorsh};
|
||||||
|
|
||||||
const ONE: i128 = 1000000000;
|
const ONE: i128 = 1000000000;
|
||||||
|
|
||||||
|
pub fn ix_discriminator(name: &str) -> [u8; 8] {
|
||||||
|
let preimage = format!("global:{}", name);
|
||||||
|
let mut sighash = [0u8; 8];
|
||||||
|
sighash.copy_from_slice(
|
||||||
|
&anchor_lang::solana_program::hash::hash(preimage.as_bytes()).to_bytes()[..8],
|
||||||
|
);
|
||||||
|
sighash
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
#[derive(Deserialize, Default, Clone, Debug)]
|
#[derive(Deserialize, Default, Clone, Debug)]
|
||||||
pub struct Ticker {
|
pub struct Ticker {
|
||||||
|
@ -143,14 +152,14 @@ impl Binance {
|
||||||
symbol: TradingSymbol::Eth,
|
symbol: TradingSymbol::Eth,
|
||||||
data: self.eth_usdt.clone().into(),
|
data: self.eth_usdt.clone().into(),
|
||||||
},
|
},
|
||||||
OracleDataWithTradingSymbol {
|
// OracleDataWithTradingSymbol {
|
||||||
symbol: TradingSymbol::Sol,
|
// symbol: TradingSymbol::Sol,
|
||||||
data: self.sol_usdt.clone().into(),
|
// data: self.sol_usdt.clone().into(),
|
||||||
},
|
// },
|
||||||
OracleDataWithTradingSymbol {
|
// OracleDataWithTradingSymbol {
|
||||||
symbol: TradingSymbol::Doge,
|
// symbol: TradingSymbol::Doge,
|
||||||
data: self.doge_usdt.clone().into(),
|
// data: self.doge_usdt.clone().into(),
|
||||||
},
|
// },
|
||||||
];
|
];
|
||||||
|
|
||||||
let params = RefreshPricesParams { rows };
|
let params = RefreshPricesParams { rows };
|
||||||
|
@ -190,7 +199,7 @@ impl Binance {
|
||||||
is_writable: false,
|
is_writable: false,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
data: params.try_to_vec().unwrap_or_default(),
|
data: [ix_discriminator("refresh_oracles").to_vec(), params.try_to_vec().unwrap()].concat(),
|
||||||
};
|
};
|
||||||
|
|
||||||
vec![ixn]
|
vec![ixn]
|
||||||
|
|
Loading…
Reference in New Issue