Created
October 28, 2025 14:29
-
-
Save mgild/6a185ee72abe1c940d88efe7d5945153 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { OracleQuote } from './src/classes/oracleQuote.js'; | |
| // Your hex string | |
| const hexData = '0100100000005000000070005100000047c0a7750a1809cab7d20a63c56f4c337d4d3cbef811abc27c2d0733c9698664d0dc7526e113052843ca295575fda8375bb8c013e1e8f8522cd96acd94f8280a887d70946cbfbd9ff02d81dff0a80f74c8f6c1fc7c456fbde36784ebec8020fb5e5340cd96123980828ce60bb40ad16d805ec03b003fec50a6922a014e495a0136a820f6fe617053e0b9886e39b583fc5d904553964623d02d3e924c07670f300000e2c7cea8990d0000000000000000010a6cf36b16000000000053424f44'; | |
| // Convert hex to Buffer | |
| const buffer = Buffer.from(hexData, 'hex'); | |
| try { | |
| // Decode the instruction data | |
| const decodedQuote = OracleQuote.decode(buffer); | |
| console.log('=== Decoded Ed25519 Instruction Data ===\n'); | |
| console.log(`Number of signatures: ${decodedQuote.signatures.length}`); | |
| console.log(`Version: ${decodedQuote.version}`); | |
| console.log(`Slot: ${decodedQuote.slot}`); | |
| console.log(`Discriminator: ${decodedQuote.tailDiscriminator}`); | |
| console.log(`Signed Slothash: ${decodedQuote.signedSlothash.toString('hex')}`); | |
| console.log('\nOracle Indexes:'); | |
| decodedQuote.oracleIdxs.forEach((idx, i) => { | |
| console.log(` Oracle ${i}: index ${idx}`); | |
| }); | |
| console.log('\nSignatures:'); | |
| decodedQuote.signatures.forEach((sig, i) => { | |
| console.log(` Signature ${i}:`); | |
| console.log(` Pubkey: ${sig.pubkey.toBase58()}`); | |
| console.log(` Signature: ${sig.signature.toString('hex').slice(0, 32)}...`); | |
| console.log(` Offsets:`, sig.offsets); | |
| }); | |
| console.log('\nFeeds:'); | |
| decodedQuote.feeds.forEach((feed, i) => { | |
| console.log(` Feed ${i}:`); | |
| console.log(` Hash: ${feed.feedHash.toString('hex')}`); | |
| console.log(` Value: ${feed.value}`); | |
| console.log(` Min Oracle Samples: ${feed.minOracleSamples}`); | |
| }); | |
| // You can also use the built-in JSON representation | |
| console.log('\n=== Full JSON Output ==='); | |
| console.log(JSON.stringify(decodedQuote.toJSON(), null, 2)); | |
| } catch (error) { | |
| console.error('Failed to decode:', error); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment