[solana] Fix idl (#1279)

* Test

* Fix idl

* Cleanup

* Add the script
This commit is contained in:
guibescos 2024-02-06 11:36:19 +00:00 committed by GitHub
parent 1d0d27ab3d
commit 8f62566dbb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 81 additions and 8 deletions

View File

@ -11,3 +11,6 @@ url = "https://api.apr.dev"
[provider]
cluster = "https://api.devnet.solana.com"
wallet = "~/.config/solana/id.json"
[scripts]
export = "anchor build && ./scripts/patch_idl.sh"

View File

@ -169,7 +169,9 @@ pub mod pyth_solana_receiver {
);
let vaa_components = VaaComponents {
verification_level: VerificationLevel::Partial(vaa.signature_count()),
verification_level: VerificationLevel::Partial {
num_signatures: vaa.signature_count(),
},
emitter_address: vaa.body().emitter_address(),
emitter_chain: vaa.body().emitter_chain(),
};

View File

@ -14,7 +14,7 @@ use {
* If partial, at least config.minimum signatures have been verified, but in the case config.minimum_signatures changes in the future we also include the number of signatures that were checked */
#[derive(AnchorSerialize, AnchorDeserialize, Copy, Clone, PartialEq, BorshSchema, Debug)]
pub enum VerificationLevel {
Partial(u8),
Partial { num_signatures: u8 },
Full,
}
#[account]

View File

@ -342,7 +342,7 @@ async fn test_post_price_update_from_vaa() {
assert_eq!(price_update_account.write_authority, poster.pubkey());
assert_eq!(
price_update_account.verification_level,
VerificationLevel::Partial(13)
VerificationLevel::Partial { num_signatures: 13 }
);
assert_eq!(
Message::PriceFeedMessage(price_update_account.price_message),
@ -391,7 +391,7 @@ async fn test_post_price_update_from_vaa() {
assert_eq!(price_update_account.write_authority, poster.pubkey());
assert_eq!(
price_update_account.verification_level,
VerificationLevel::Partial(13)
VerificationLevel::Partial { num_signatures: 13 }
);
assert_eq!(
Message::PriceFeedMessage(price_update_account.price_message),
@ -444,7 +444,7 @@ async fn test_post_price_update_from_vaa() {
assert_eq!(price_update_account.write_authority, poster.pubkey());
assert_eq!(
price_update_account.verification_level,
VerificationLevel::Partial(13)
VerificationLevel::Partial { num_signatures: 13 },
);
assert_eq!(
Message::PriceFeedMessage(price_update_account.price_message),

View File

@ -94,7 +94,7 @@ async fn test_post_update_atomic() {
assert_eq!(price_update_account.write_authority, poster.pubkey());
assert_eq!(
price_update_account.verification_level,
VerificationLevel::Partial(5)
VerificationLevel::Partial { num_signatures: 5 }
);
assert_eq!(
Message::PriceFeedMessage(price_update_account.price_message),
@ -130,7 +130,7 @@ async fn test_post_update_atomic() {
assert_eq!(price_update_account.write_authority, poster.pubkey());
assert_eq!(
price_update_account.verification_level,
VerificationLevel::Partial(5)
VerificationLevel::Partial { num_signatures: 5 }
);
assert_eq!(
Message::PriceFeedMessage(price_update_account.price_message),
@ -165,7 +165,7 @@ async fn test_post_update_atomic() {
assert_eq!(price_update_account.write_authority, poster.pubkey());
assert_eq!(
price_update_account.verification_level,
VerificationLevel::Partial(5)
VerificationLevel::Partial { num_signatures: 5 }
);
assert_eq!(
Message::PriceFeedMessage(price_update_account.price_message),

View File

@ -0,0 +1,4 @@
#! /bin/bash
cat target/idl/pyth_solana_receiver.json |
# ADD EXTERNAL TYPES
jq --slurpfile external_types target/idl/external_types.json '.types += $external_types[]' > target/idl/tmp.json && mv target/idl/tmp.json target/idl/pyth_solana_receiver.json

View File

@ -0,0 +1,64 @@
[
{
"name": "PriceFeedMessage",
"type": {
"kind": "struct",
"fields": [
{
"name": "feedId",
"type": {
"array": ["u8", 32]
}
},
{
"name": "price",
"type": "i64"
},
{
"name": "conf",
"type": "u64"
},
{
"name": "exponent",
"type": "i32"
},
{
"name": "publishTime",
"type": "i64"
},
{
"name": "prevPublishTime",
"type": "i64"
},
{
"name": "emaPrice",
"type": "i64"
},
{
"name": "emaConf",
"type": "u64"
}
]
}
},
{
"name": "MerklePriceUpdate",
"type": {
"kind": "struct",
"fields": [
{
"name": "message",
"type": "bytes"
},
{
"name": "merkleProof",
"type": {
"vec": {
"array": ["u8", 20]
}
}
}
]
}
}
]