UNPKG

@wuwei-labs/srsly

Version:

[![npm version](https://img.shields.io/npm/v/ts-sdk-example.svg)](https://www.npmjs.com/package/ts-sdk-example)

66 lines 4.33 kB
/** * This code was AUTOGENERATED using the codama library. * Please DO NOT EDIT THIS FILE, instead use visitors * to add features, then rerun codama to update it. * * @see https://github.com/codama-idl/codama */ import { isProgramError, } from '@solana/kit'; import { SRSLY_PROGRAM_ADDRESS } from '../programs'; /** InvalidDurationMinimum: Invalid duration minimum. Must be between 1 and the duration maximum. */ export const SRSLY_ERROR__INVALID_DURATION_MINIMUM = 0x1770; // 6000 /** InvalidDurationMaximum: Invalid duration maximum. Must be greater than or equal to the duration minimum. */ export const SRSLY_ERROR__INVALID_DURATION_MAXIMUM = 0x1771; // 6001 /** InvalidRateCalculation: The contract rate multiplied by duration exceeds the payment amount. */ export const SRSLY_ERROR__INVALID_RATE_CALCULATION = 0x1772; // 6002 /** FleetAlreadyRented: Fleet is already rented (sub_profile is not empty). */ export const SRSLY_ERROR__FLEET_ALREADY_RENTED = 0x1773; // 6003 /** InvalidRate: Contract rate must be greater than or equal to 0. */ export const SRSLY_ERROR__INVALID_RATE = 0x1774; // 6004 /** InvalidPaymentFrequency: Invalid payment frequency. Must be one of: @hourly, @daily, @weekly, @monthly. */ export const SRSLY_ERROR__INVALID_PAYMENT_FREQUENCY = 0x1775; // 6005 /** InvalidSubProfileInvalidator: Invalid sub_profile invalidator. */ export const SRSLY_ERROR__INVALID_SUB_PROFILE_INVALIDATOR = 0x1776; // 6006 /** InsufficientCancellationNotice: Rental time remaining is less than minimum cancellation notice required. */ export const SRSLY_ERROR__INSUFFICIENT_CANCELLATION_NOTICE = 0x1777; // 6007 /** ContractClosed: The contract is closed. */ export const SRSLY_ERROR__CONTRACT_CLOSED = 0x1778; // 6008 /** DevOnlyFrequency: This frequency is only allowed in development. */ export const SRSLY_ERROR__DEV_ONLY_FREQUENCY = 0x1779; // 6009 /** ExpectedDailyFrequency: Expected daily frequency but contract is set differently. */ export const SRSLY_ERROR__EXPECTED_DAILY_FREQUENCY = 0x177a; // 6010 /** InvalidThreadContext: Thread has invalid context set. */ export const SRSLY_ERROR__INVALID_THREAD_CONTEXT = 0x177b; // 6011 /** RentalIsActive: Rental is still active. */ export const SRSLY_ERROR__RENTAL_IS_ACTIVE = 0x177c; // 6012 /** RentalStateExists: Rental reset requires rental state to not exist. */ export const SRSLY_ERROR__RENTAL_STATE_EXISTS = 0x177d; // 6013 let srslyErrorMessages; if (process.env.NODE_ENV !== 'production') { srslyErrorMessages = { [SRSLY_ERROR__CONTRACT_CLOSED]: `The contract is closed.`, [SRSLY_ERROR__DEV_ONLY_FREQUENCY]: `This frequency is only allowed in development.`, [SRSLY_ERROR__EXPECTED_DAILY_FREQUENCY]: `Expected daily frequency but contract is set differently.`, [SRSLY_ERROR__FLEET_ALREADY_RENTED]: `Fleet is already rented (sub_profile is not empty).`, [SRSLY_ERROR__INSUFFICIENT_CANCELLATION_NOTICE]: `Rental time remaining is less than minimum cancellation notice required.`, [SRSLY_ERROR__INVALID_DURATION_MAXIMUM]: `Invalid duration maximum. Must be greater than or equal to the duration minimum.`, [SRSLY_ERROR__INVALID_DURATION_MINIMUM]: `Invalid duration minimum. Must be between 1 and the duration maximum.`, [SRSLY_ERROR__INVALID_PAYMENT_FREQUENCY]: `Invalid payment frequency. Must be one of: @hourly, @daily, @weekly, @monthly.`, [SRSLY_ERROR__INVALID_RATE]: `Contract rate must be greater than or equal to 0.`, [SRSLY_ERROR__INVALID_RATE_CALCULATION]: `The contract rate multiplied by duration exceeds the payment amount.`, [SRSLY_ERROR__INVALID_SUB_PROFILE_INVALIDATOR]: `Invalid sub_profile invalidator.`, [SRSLY_ERROR__INVALID_THREAD_CONTEXT]: `Thread has invalid context set.`, [SRSLY_ERROR__RENTAL_IS_ACTIVE]: `Rental is still active.`, [SRSLY_ERROR__RENTAL_STATE_EXISTS]: `Rental reset requires rental state to not exist.`, }; } export function getSrslyErrorMessage(code) { if (process.env.NODE_ENV !== 'production') { return srslyErrorMessages[code]; } return 'Error message not available in production bundles.'; } export function isSrslyError(error, transactionMessage, code) { return isProgramError(error, transactionMessage, SRSLY_PROGRAM_ADDRESS, code); } //# sourceMappingURL=srsly.js.map