Last active
August 9, 2022 18:48
-
-
Save mertimus/ac8f2ac153042b243d255566bcabf95f to your computer and use it in GitHub Desktop.
Revisions
-
mertimus revised this gist
Aug 9, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import { Connection, PublicKey, Struct } from '@solana/web3.js'; const Base58 = require("base-58") import * as beet from '@metaplex-foundation/beet'; const url = "rpc url"; const solanaConnection = new Connection(url,'confirmed'); -
mertimus revised this gist
May 2, 2022 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -6,6 +6,8 @@ import * as beet from '@metaplex-foundation/beet'; const url = "https://green-patient-dew.solana-mainnet.quiknode.pro/babd28401fd536319c117fc2caf3a02b8f2edd67/"; const solanaConnection = new Connection(url,'confirmed'); // metaplex source: https://github.com/metaplex-foundation/metaplex-program-library/blob/master/auction-house/js/src/generated/instructions/executeSale.ts#L17 class Primitive { tradeStateBump: number; freeTradeStateBump: number; -
mertimus created this gist
Apr 24, 2022 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,56 @@ import { serialize, deserializeUnchecked } from 'borsh'; import { Connection, PublicKey, Struct } from '@solana/web3.js'; const Base58 = require("base-58") import * as beet from '@metaplex-foundation/beet'; const url = "https://green-patient-dew.solana-mainnet.quiknode.pro/babd28401fd536319c117fc2caf3a02b8f2edd67/"; const solanaConnection = new Connection(url,'confirmed'); class Primitive { tradeStateBump: number; freeTradeStateBump: number; programAsSignerBump: number; buyerPrice: beet.bignum; tokenSize: beet.bignum; constructor(args: { tradeStateBump: number; freeTradeStateBump: number; programAsSignerBump: number; buyerPrice: beet.bignum; tokenSize: beet.bignum; }) { this.tradeStateBump = args.tradeStateBump; this.freeTradeStateBump = args.freeTradeStateBump this.programAsSignerBump = args.programAsSignerBump this.buyerPrice = args.buyerPrice this.tokenSize = args.tokenSize } } const value = new Primitive({ tradeStateBump: 255, freeTradeStateBump: 254, programAsSignerBump: 255, buyerPrice: 35000000000, tokenSize: 1, }) const schema = new Map([[Primitive,{ kind: 'struct', fields: [ ['instructionDiscriminator', ['u8', 8]], ['tradeStateBump', 'u8'], ['freeTradeStateBump', 'u8'], ['programAsSignerBump', 'u8'], ['buyerPrice', 'u64'], ['tokenSize', 'u64'], ] }]]); const parser = async () => { const txn = await solanaConnection.getTransaction("4Jsmb6WeDzhLAaRF494CfbFLh6Vg2TCSfHKMWN18ueyaVzdQjf69GX4SDDdGFowey8g81DgFv7inQrTEyJiG49op"); const test = Buffer.from(Base58.decode(txn?.transaction.message.instructions[0].data)) const data = deserializeUnchecked(schema, Primitive, test) console.log("price:", data.buyerPrice.toString()) } parser()