UNPKG

@near-lake/primitives

Version:

Near Protocol primitive datatypes utilized by near-lake-framework and QueryAPI

42 lines (41 loc) 2.47 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 }); const helpers_1 = require("./helpers"); describe("Block", () => { describe("functionCalls", () => { it("gets single failed function call in 114158749", () => __awaiter(void 0, void 0, void 0, function* () { let block = yield (0, helpers_1.getBlock)(114158749); const functionCalls = block.functionCalls("*", "onlyFailed"); expect(functionCalls.length).toEqual(1); })); it("gets args for devgovgigs.near add_post to in 114158749", () => __awaiter(void 0, void 0, void 0, function* () { let block = yield (0, helpers_1.getBlock)(114158749); const functionCalls = block.functionCalls("devgovgigs.near", "all"); expect(functionCalls.length).toEqual(1); const call = functionCalls[0]; expect(call.methodName).toEqual("add_post"); const jsonArgs = call.argsAsJSON(); expect(jsonArgs).toHaveProperty("parent_id"); expect(jsonArgs).toHaveProperty("labels"); expect(jsonArgs).toHaveProperty("body"); expect(call).toEqual(block.functionCallsToReceiver("devgovgigs.near", "add_post")[0]); })); it("allows to extract ft_transfer events from function calls to token.sweat", () => __awaiter(void 0, void 0, void 0, function* () { const block = yield (0, helpers_1.getBlock)(114158749); const functionCalls = block.functionCallsToReceiver("token.sweat", "ft_transfer"); expect(functionCalls.length).toEqual(17); expect(functionCalls .flatMap((fc) => fc.events) .every((event) => event.standard === "nep141")).toBeTruthy(); })); }); });