@wuwei-labs/srsly
Version:
[](https://www.npmjs.com/package/ts-sdk-example)
77 lines • 4.77 kB
JavaScript
;
/**
* 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
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.SrslyInstruction = exports.SrslyAccount = exports.SRSLY_PROGRAM_ADDRESS = void 0;
exports.identifySrslyAccount = identifySrslyAccount;
exports.identifySrslyInstruction = identifySrslyInstruction;
const kit_1 = require("@solana/kit");
exports.SRSLY_PROGRAM_ADDRESS = 'SRSLY1fq9TJqCk1gNSE7VZL2bztvTn9wm4VR8u8jMKT';
var SrslyAccount;
(function (SrslyAccount) {
SrslyAccount[SrslyAccount["ContractState"] = 0] = "ContractState";
SrslyAccount[SrslyAccount["Fleet"] = 1] = "Fleet";
SrslyAccount[SrslyAccount["RentalState"] = 2] = "RentalState";
SrslyAccount[SrslyAccount["Thread"] = 3] = "Thread";
})(SrslyAccount || (exports.SrslyAccount = SrslyAccount = {}));
function identifySrslyAccount(account) {
const data = 'data' in account ? account.data : account;
if ((0, kit_1.containsBytes)(data, (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(new Uint8Array([190, 138, 10, 223, 189, 116, 222, 115])), 0)) {
return SrslyAccount.ContractState;
}
if ((0, kit_1.containsBytes)(data, (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(new Uint8Array([109, 207, 251, 48, 106, 2, 136, 163])), 0)) {
return SrslyAccount.Fleet;
}
if ((0, kit_1.containsBytes)(data, (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(new Uint8Array([97, 162, 29, 222, 251, 251, 180, 244])), 0)) {
return SrslyAccount.RentalState;
}
if ((0, kit_1.containsBytes)(data, (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(new Uint8Array([186, 27, 154, 111, 51, 36, 159, 90])), 0)) {
return SrslyAccount.Thread;
}
throw new Error('The provided account could not be identified as a srsly account.');
}
var SrslyInstruction;
(function (SrslyInstruction) {
SrslyInstruction[SrslyInstruction["AcceptRental"] = 0] = "AcceptRental";
SrslyInstruction[SrslyInstruction["CancelRental"] = 1] = "CancelRental";
SrslyInstruction[SrslyInstruction["CloseContract"] = 2] = "CloseContract";
SrslyInstruction[SrslyInstruction["CloseRental"] = 3] = "CloseRental";
SrslyInstruction[SrslyInstruction["CreateContract"] = 4] = "CreateContract";
SrslyInstruction[SrslyInstruction["NormalizeAdmin"] = 5] = "NormalizeAdmin";
SrslyInstruction[SrslyInstruction["PayRental"] = 6] = "PayRental";
SrslyInstruction[SrslyInstruction["ResetRental"] = 7] = "ResetRental";
})(SrslyInstruction || (exports.SrslyInstruction = SrslyInstruction = {}));
function identifySrslyInstruction(instruction) {
const data = 'data' in instruction ? instruction.data : instruction;
if ((0, kit_1.containsBytes)(data, (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(new Uint8Array([192, 221, 241, 212, 141, 161, 36, 146])), 0)) {
return SrslyInstruction.AcceptRental;
}
if ((0, kit_1.containsBytes)(data, (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(new Uint8Array([97, 204, 63, 8, 84, 34, 28, 43])), 0)) {
return SrslyInstruction.CancelRental;
}
if ((0, kit_1.containsBytes)(data, (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(new Uint8Array([37, 244, 34, 168, 92, 202, 80, 106])), 0)) {
return SrslyInstruction.CloseContract;
}
if ((0, kit_1.containsBytes)(data, (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(new Uint8Array([179, 188, 113, 211, 41, 232, 51, 51])), 0)) {
return SrslyInstruction.CloseRental;
}
if ((0, kit_1.containsBytes)(data, (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(new Uint8Array([244, 48, 244, 178, 216, 88, 122, 52])), 0)) {
return SrslyInstruction.CreateContract;
}
if ((0, kit_1.containsBytes)(data, (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(new Uint8Array([26, 134, 185, 168, 82, 175, 6, 182])), 0)) {
return SrslyInstruction.NormalizeAdmin;
}
if ((0, kit_1.containsBytes)(data, (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(new Uint8Array([114, 15, 111, 207, 115, 207, 108, 169])), 0)) {
return SrslyInstruction.PayRental;
}
if ((0, kit_1.containsBytes)(data, (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(new Uint8Array([139, 185, 76, 32, 61, 143, 163, 183])), 0)) {
return SrslyInstruction.ResetRental;
}
throw new Error('The provided instruction could not be identified as a srsly instruction.');
}
//# sourceMappingURL=srsly.js.map