UNPKG

@rainfi/sdk

Version:

This package is used to interact with Rain.fi protocol on Solana

274 lines 11.5 kB
"use strict"; /** * This code was GENERATED using the solita package. * Please DO NOT EDIT THIS FILE, instead rerun solita to update it or write a wrapper to add functionality. * * See: https://github.com/metaplex-foundation/solita */ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (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; }; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.collectionGlobalOfferBeet = exports.CollectionGlobalOffer = exports.collectionGlobalOfferDiscriminator = void 0; const web3 = __importStar(require("@solana/web3.js")); const beet = __importStar(require("@metaplex-foundation/beet")); const beetSolana = __importStar(require("@metaplex-foundation/beet-solana")); const WhitelistType_1 = require("../types/WhitelistType"); exports.collectionGlobalOfferDiscriminator = [ 52, 99, 115, 67, 181, 61, 204, 121, ]; /** * Holds the data for the {@link CollectionGlobalOffer} Account and provides de/serialization * functionality for that data * * @category Accounts * @category generated */ class CollectionGlobalOffer { constructor(name /* size: 128 */, authority, creator, collection, collectionId, activeBid, volumeActiveBid, totalWhitelisted, totalVolume, totalAccepted, whitelistType, isAttributeFilteringEnabled, createdAt, updatedAt, padding /* size: 12 */) { this.name = name; this.authority = authority; this.creator = creator; this.collection = collection; this.collectionId = collectionId; this.activeBid = activeBid; this.volumeActiveBid = volumeActiveBid; this.totalWhitelisted = totalWhitelisted; this.totalVolume = totalVolume; this.totalAccepted = totalAccepted; this.whitelistType = whitelistType; this.isAttributeFilteringEnabled = isAttributeFilteringEnabled; this.createdAt = createdAt; this.updatedAt = updatedAt; this.padding = padding; } /** * Creates a {@link CollectionGlobalOffer} instance from the provided args. */ static fromArgs(args) { return new CollectionGlobalOffer(args.name, args.authority, args.creator, args.collection, args.collectionId, args.activeBid, args.volumeActiveBid, args.totalWhitelisted, args.totalVolume, args.totalAccepted, args.whitelistType, args.isAttributeFilteringEnabled, args.createdAt, args.updatedAt, args.padding); } /** * Deserializes the {@link CollectionGlobalOffer} from the data of the provided {@link web3.AccountInfo}. * @returns a tuple of the account data and the offset up to which the buffer was read to obtain it. */ static fromAccountInfo(accountInfo, offset = 0) { return CollectionGlobalOffer.deserialize(accountInfo.data, offset); } /** * Retrieves the account info from the provided address and deserializes * the {@link CollectionGlobalOffer} from its data. * * @throws Error if no account info is found at the address or if deserialization fails */ static fromAccountAddress(connection, address, commitmentOrConfig) { return __awaiter(this, void 0, void 0, function* () { const accountInfo = yield connection.getAccountInfo(address, commitmentOrConfig); if (accountInfo == null) { throw new Error(`Unable to find CollectionGlobalOffer account at ${address}`); } return CollectionGlobalOffer.fromAccountInfo(accountInfo, 0)[0]; }); } /** * Provides a {@link web3.Connection.getProgramAccounts} config builder, * to fetch accounts matching filters that can be specified via that builder. * * @param programId - the program that owns the accounts we are filtering */ static gpaBuilder(programId = new web3.PublicKey('RainEraPU5yDoJmTrHdYynK9739GkEfDsE4ffqce2BR')) { return beetSolana.GpaBuilder.fromStruct(programId, exports.collectionGlobalOfferBeet); } /** * Deserializes the {@link CollectionGlobalOffer} from the provided data Buffer. * @returns a tuple of the account data and the offset up to which the buffer was read to obtain it. */ static deserialize(buf, offset = 0) { return exports.collectionGlobalOfferBeet.deserialize(buf, offset); } /** * Serializes the {@link CollectionGlobalOffer} into a Buffer. * @returns a tuple of the created Buffer and the offset up to which the buffer was written to store it. */ serialize() { return exports.collectionGlobalOfferBeet.serialize(Object.assign({ accountDiscriminator: exports.collectionGlobalOfferDiscriminator }, this)); } /** * Returns the byteSize of a {@link Buffer} holding the serialized data of * {@link CollectionGlobalOffer} */ static get byteSize() { return exports.collectionGlobalOfferBeet.byteSize; } /** * Fetches the minimum balance needed to exempt an account holding * {@link CollectionGlobalOffer} data from rent * * @param connection used to retrieve the rent exemption information */ static getMinimumBalanceForRentExemption(connection, commitment) { return __awaiter(this, void 0, void 0, function* () { return connection.getMinimumBalanceForRentExemption(CollectionGlobalOffer.byteSize, commitment); }); } /** * Determines if the provided {@link Buffer} has the correct byte size to * hold {@link CollectionGlobalOffer} data. */ static hasCorrectByteSize(buf, offset = 0) { return buf.byteLength - offset === CollectionGlobalOffer.byteSize; } /** * Returns a readable version of {@link CollectionGlobalOffer} properties * and can be used to convert to JSON and/or logging */ pretty() { return { name: this.name, authority: this.authority.toBase58(), creator: this.creator.toBase58(), collection: this.collection.toBase58(), collectionId: this.collectionId, activeBid: (() => { const x = this.activeBid; if (typeof x.toNumber === 'function') { try { return x.toNumber(); } catch (_) { return x; } } return x; })(), volumeActiveBid: (() => { const x = this.volumeActiveBid; if (typeof x.toNumber === 'function') { try { return x.toNumber(); } catch (_) { return x; } } return x; })(), totalWhitelisted: (() => { const x = this.totalWhitelisted; if (typeof x.toNumber === 'function') { try { return x.toNumber(); } catch (_) { return x; } } return x; })(), totalVolume: (() => { const x = this.totalVolume; if (typeof x.toNumber === 'function') { try { return x.toNumber(); } catch (_) { return x; } } return x; })(), totalAccepted: (() => { const x = this.totalAccepted; if (typeof x.toNumber === 'function') { try { return x.toNumber(); } catch (_) { return x; } } return x; })(), whitelistType: 'WhitelistType.' + WhitelistType_1.WhitelistType[this.whitelistType], isAttributeFilteringEnabled: this.isAttributeFilteringEnabled, createdAt: (() => { const x = this.createdAt; if (typeof x.toNumber === 'function') { try { return x.toNumber(); } catch (_) { return x; } } return x; })(), updatedAt: (() => { const x = this.updatedAt; if (typeof x.toNumber === 'function') { try { return x.toNumber(); } catch (_) { return x; } } return x; })(), padding: this.padding, }; } } exports.CollectionGlobalOffer = CollectionGlobalOffer; /** * @category Accounts * @category generated */ exports.collectionGlobalOfferBeet = new beet.BeetStruct([ ['accountDiscriminator', beet.uniformFixedSizeArray(beet.u8, 8)], ['name', beet.uniformFixedSizeArray(beet.u8, 128)], ['authority', beetSolana.publicKey], ['creator', beetSolana.publicKey], ['collection', beetSolana.publicKey], ['collectionId', beet.u32], ['activeBid', beet.u64], ['volumeActiveBid', beet.u64], ['totalWhitelisted', beet.u64], ['totalVolume', beet.u64], ['totalAccepted', beet.u64], ['whitelistType', WhitelistType_1.whitelistTypeBeet], ['isAttributeFilteringEnabled', beet.bool], ['createdAt', beet.u64], ['updatedAt', beet.u64], ['padding', beet.uniformFixedSizeArray(beet.u64, 12)], ], CollectionGlobalOffer.fromArgs, 'CollectionGlobalOffer'); //# sourceMappingURL=CollectionGlobalOffer.js.map