UNPKG

solana-options

Version:

Minting of options contract NFTs on the Solana blockchain

74 lines (73 loc) 2.4 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.OPTION_ACCOUNT_DATA_LAYOUT = void 0; const BufferLayout = __importStar(require("buffer-layout")); /** * Layout for a public key */ const publicKey = (property = "publicKey") => { return BufferLayout.blob(32, property); }; /** * Layout for a 64bit unsigned value */ const uint64 = (property = "uint64") => { return BufferLayout.blob(8, property); }; const int64 = uint64; exports.OPTION_ACCOUNT_DATA_LAYOUT = BufferLayout.struct([ publicKey("writer_pubkey"), publicKey("ownership_nft_token"), publicKey("collateral_acc_pubkey"), publicKey("recv_acc_pubkey"), int64("expiry_date"), uint64("strike"), uint64("multiple"), BufferLayout.u8("is_expired"), BufferLayout.u8("is_initialized"), BufferLayout.u8("kind"), ]); console.log(exports.OPTION_ACCOUNT_DATA_LAYOUT.span); // /** // * The state of a greeting account managed by the hello world program // */ // class GreetingAccount { // counter = 0; // constructor(fields: {counter: number} | undefined = undefined) { // if (fields) { // this.counter = fields.counter; // } // } // } // /** // * Borsh schema definition for greeting accounts // */ // const GreetingSchema = new Map([ // [GreetingAccount, {kind: 'struct', fields: [['counter', 'u32']]}], // ]); // /** // * The expected size of each greeting account. // */ // const GREETING_SIZE = borsh.serialize( // GreetingSchema, // new GreetingAccount(), // ).length;