UNPKG

@symmetry-hq/agents-sdk

Version:

Symmetry Agents SDK

37 lines (36 loc) 1.76 kB
"use strict"; 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.AGENTS_STATE_SIZE = void 0; exports.fetchAgentState = fetchAgentState; exports.parseAgentState = parseAgentState; const uuid_1 = require("uuid"); exports.AGENTS_STATE_SIZE = 1216; function fetchAgentState(program, agent) { return __awaiter(this, void 0, void 0, function* () { return yield program.account.agent.fetch(agent); }); } function parseAgentState(agentState) { return { agent: agentState.agentPda.toBase58(), state: agentState.ownAddress.toBase58(), uuid: (0, uuid_1.stringify)(Uint8Array.from(agentState.uuid)), creator: agentState.creator.toBase58(), hasToken: agentState.hasToken, metadata: agentState.metadata.toBase58(), mint: agentState.mint.toBase58(), balance: parseInt(agentState.balance.toString()), usdcBalance: parseInt(agentState.usdcBalance.toString()), wsolBalance: parseInt(agentState.wsolBalance.toString()), authority: agentState.authority.toBase58(), }; }