Skip to content

Commit

Permalink
Add new error
Browse files Browse the repository at this point in the history
  • Loading branch information
yurushao authored and 0x0ece committed Apr 7, 2024
1 parent 9e10e30 commit 4943c5a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
2 changes: 2 additions & 0 deletions anchor/programs/glam/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ pub enum InvestorError {
InvalidShareClass,
#[msg("Asset not allowed to subscribe")]
InvalidAssetSubscribe,
#[msg("Invalid oracle for asset price")]
InvalidPricingOracle,
#[msg("Invalid assets in redeem")]
InvalidAssetsRedeem,
#[msg("Invalid treasury account")]
Expand Down
11 changes: 5 additions & 6 deletions anchor/programs/glam/src/instructions/investor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn check_pricing_account(asset: &str, pricing_account: &str) -> bool {
"3NZ9JMVBmGAqocybic2c7LQCJScmgsAZ6vQqTDzcqmJh" => {
pricing_account == "GVXRSBjFk6e6J3NbVPXohDJetcTjaeeuykUpbQF8UoMU"
}
// eth mainnet
// eth
"7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs" => {
pricing_account == "JBu1AL4obBcCMqKBBxhpWCNUt136ijcuMZLFvTP7iWdB"
}
Expand All @@ -44,20 +44,19 @@ fn check_pricing_account(asset: &str, pricing_account: &str) -> bool {
#[cfg(feature = "devnet")]
fn check_pricing_account(asset: &str, pricing_account: &str) -> bool {
match asset {
// usdc devnet
// usdc
"8zGuJQqwhZafTah7Uc7Z4tXRnguqkn5KLFAP8oV6PHe2" => {
pricing_account == "5SSkXsEKQepHHAewytPVwdej4epN1nxgLVM84L4KXgy7"
}
// sol
"So11111111111111111111111111111111111111112" => {
pricing_account == "J83w4HKfqxwcq3BEMMkPFSppX3gqekLyLJBexebFVkix"
}
// btc devnet
// btc
"3BZPwbcqB5kKScF3TEXxwNfx5ipV13kbRVDvfVp5c6fv" => {
pricing_account == "HovQMDrbAgAYPCmHVSrezcSmkMtXSSUsLDFANExrZh2J"
}
// TODO: eth devnet mint?
"eth_devnet_token_mint" => {
"Ff5JqsAYUD4vAfQUtfRprT4nXu9e28tTBZTDFMnJNdvd" => {
pricing_account == "EdVCmQ9FSPcVe5YySXDPCRmc8aDQLKJ9xvYBMZPie1Vw"
}
_ => false,
Expand Down Expand Up @@ -207,7 +206,7 @@ pub fn subscribe_handler<'c: 'info, 'info>(
&ctx.accounts.asset.key().to_string(),
&pricing_account.to_account_info().key().to_string(),
),
InvestorError::InvalidAssetSubscribe
InvestorError::InvalidPricingOracle
);
subscribe_asset_price = asset_price;
subscribe_asset_expo = asset_expo;
Expand Down
3 changes: 3 additions & 0 deletions anchor/target/idl/glam.json
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,9 @@
{
"name": "InvalidAssetSubscribe"
},
{
"name": "InvalidPricingOracle"
},
{
"name": "InvalidAssetsRedeem"
},
Expand Down
6 changes: 6 additions & 0 deletions anchor/target/types/glam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,9 @@ export type Glam = {
{
"name": "InvalidAssetSubscribe"
},
{
"name": "InvalidPricingOracle"
},
{
"name": "InvalidAssetsRedeem"
},
Expand Down Expand Up @@ -1532,6 +1535,9 @@ export const IDL: Glam = {
{
"name": "InvalidAssetSubscribe"
},
{
"name": "InvalidPricingOracle"
},
{
"name": "InvalidAssetsRedeem"
},
Expand Down

0 comments on commit 4943c5a

Please sign in to comment.