NEAR Price:
All Filters
Txns
Blocks
Addresses
Tokens
MT Tokens
NFT Tokens
Access Keys
Receipts
Switch Network
Toggle Theme
Home
Blockchain
Tokens
Developers
Languages
Toggle Menu
Transaction Details
API
Overview
Execution Plan
Enhanced Plan
Tree Plan
Receipts Summary
Output
Inspect
Result:
Logs:
NEAR Price:
$1.88
(+4.94%)
set
TRANSFER
Hide 8002 bytes
JSON
UTF-8
Hex
Base64
Raw
{
"data"
:
{
"chatter.cheddar.near"
:
{
"widget"
:
{
"lib.upVotes"
:
{
""
:
"const { getFromIndex } = VM.require(\\n \\\'chatter.cheddar.near/widget/lib.socialDbIndex\\\'\\n) || { getFromIndex: () => {} }\\nconst { generateMetadata, updateMetadata, buildDeleteMetadata } = VM.require(\\n \\\'chatter.cheddar.near/widget/lib.metadata\\\'\\n) || {\\n generateMetadata: () => {},\\n updateMetadata: () => {},\\n buildDeleteMetadata: () => {},\\n}\\n\\nconst { getNotificationData } = VM.require(\\n \\\'chatter.cheddar.near/widget/lib.notifications\\\'\\n) || { getNotificationData: () => {} }\\n\\nlet config = {}\\nconst ID_PREFIX = \\\'upVote\\\'\\nconst currentVersion = \\\'v0.0.1\\\'\\n\\nfunction setConfig(value) {\\n config = value\\n}\\n\\nfunction getConfig() {\\n return config\\n}\\n\\nfunction normalizeOldToV_0_0_1(upVote) {\\n return upVote\\n}\\n\\nfunction normalizeFromV0_0_1ToV0_0_2(upVote) {\\n upVote.sbts = [\\\'public\\\']\\n return upVote\\n}\\n\\nfunction normalizeFromV0_0_2ToV0_0_3(upVote) {\\n const now = Date.now()\\n if (upVote.value.isDelete) {\\n upVote.value.metadata = {\\n id,\\n isDelete: true,\\n deleteTimestamp: now,\\n }\\n delete upVote.value.isDelete\\n return upVote\\n }\\n\\n const author = (upVote.value.upVoteId ?? \\\'\\\').split(\\\'/\\\')[1]\\n upVote.value.metadata = {\\n id: upVote.value.upVoteId,\\n author,\\n createdTimestamp: now,\\n lastEditTimestamp: now,\\n versionKey: \\\'v0.0.3\\\',\\n }\\n delete upVote.value.upVoteId\\n delete upVote.value.sbts\\n return upVote\\n}\\n\\nfunction normalizeFromV0_0_3ToV0_0_4(upVote) {\\n return upVote\\n}\\n\\nconst versions = {\\n old: {\\n normalizationFunction: normalizeOldToV_0_0_1,\\n actionSuffix: \\\'\\\',\\n },\\n \\\'v0.0.1\\\': {\\n normalizationFunction: (upVote) => upVote,\\n actionSuffix: `-v0.0.1`,\\n },\\n \\\'v0.0.2\\\': {\\n normalizationFunction: normalizeFromV0_0_2ToV0_0_3,\\n actionSuffix: `_v0.0.2`,\\n },\\n \\\'v0.0.3\\\': {\\n normalizationFunction: normalizeFromV0_0_3ToV0_0_4,\\n actionSuffix: `_v0.0.3`,\\n },\\n}\\n\\nasync function getUpVotesData(action, id) {\\n return getFromIndex(action, id)\\n}\\n\\nfunction fillAction(version) {\\n const baseAction = getConfig().baseActions.upVote\\n const filledAction = baseAction + version.actionSuffix\\n return getConfig().isTest ? `test_${filledAction}` : filledAction\\n}\\n\\nfunction getUpVoteBlackListByBlockHeight() {\\n return []\\n}\\n\\nfunction getLatestEdits(upVotes) {\\n return upVotes.filter((obj) => {\\n const userLatestInteraction = upVotes.find(\\n (vote) => vote.accountId === obj.accountId\\n )\\n return JSON.stringify(userLatestInteraction) === JSON.stringify(obj)\\n })\\n}\\n\\nfunction filterInvalidUpVotes(upVotes) {\\n return (upVotes ?? [])\\n .filter((upVote) => upVote.value.metadata.id) // Has id\\n .filter(\\n (upVote) =>\\n !getUpVoteBlackListByBlockHeight().includes(upVote.blockHeight) // Blockheight is not in blacklist\\n )\\n}\\n\\nfunction normalizeUpVote(upVote, versionsIndex) {\\n const versionsKeys = Object.keys(versions)\\n for (let i = versionsIndex; i < versionsKeys.length; i++) {\\n const version = versions[versionsKeys[i]]\\n upVote = version.normalizationFunction(upVote)\\n }\\n return upVote\\n}\\n\\nfunction isActive(upVote) {\\n return upVote.value.metadata && !upVote.value.metadata.isDelete\\n}\\n\\nasync function getUpVotes(config, articleId) {\\n setConfig(config)\\n const upVotesByVersionPromise = Object.keys(versions).map(\\n (version, versionIndex, arr) => {\\n const action = fillAction(versions[version])\\n\\n return getUpVotesData(action, articleId).then((upVotes) => {\\n const validUpVotes = filterInvalidUpVotes(upVotes)\\n const latestUpVotes = getLatestEdits(validUpVotes)\\n\\n const activeUpVotes = latestUpVotes.filter(isActive)\\n\\n const normalizedVotes = activeUpVotes.map((upVote) =>\\n normalizeUpVote(upVote, versionIndex)\\n )\\n\\n return normalizedVotes\\n })\\n }\\n )\\n return Promise.all(upVotesByVersionPromise).then((upVotesByVersion) => {\\n return upVotesByVersion.flat()\\n })\\n}\\n\\nfunction getAction(version) {\\n const baseAction = getConfig().baseActions.upVote\\n const versionData = version ? versions[version] : versions[currentVersion]\\n const action = baseAction + versionData.actionSuffix\\n return getConfig().isTest ? `test_${action}` : action\\n}\\n\\nfunction composeData(upVote) {\\n //version and config are optative for testing\\n let data = {\\n index: {\\n [getAction()]: JSON.stringify({\\n key: upVote.metadata.articleId,\\n value: {\\n ...upVote,\\n },\\n }),\\n },\\n }\\n\\n if (upVote.metadata.isDelete) return data\\n\\n const articleIdSplitted = upVote.metadata.articleId.split(\\\'/\\\')\\n const articleAuthor = articleIdSplitted[1]\\n\\n const dataToAdd = getNotificationData(\\n getConfig(),\\n \\\'upVote\\\',\\n [],\\n upVote.metadata,\\n { author: articleAuthor }\\n )\\n\\n data.post = dataToAdd.post\\n data.index.notify = dataToAdd.index.notify\\n\\n return data\\n}\\n\\nfunction executeSaveUpVote(upVote, onCommit, onCancel) {\\n //version and config are optative for testing\\n const newData = composeData(upVote)\\n Social.set(newData, {\\n force: true,\\n onCommit,\\n onCancel,\\n })\\n}\\n\\nfunction createUpVote(config, articleId, author, onCommit, onCancel) {\\n setConfig(config)\\n\\n const metadataHelper = {\\n author,\\n idPrefix: ID_PREFIX,\\n versionKey: currentVersion,\\n }\\n\\n const metadata = generateMetadata(metadataHelper)\\n\\n const upVote = {\\n metadata: {\\n ...metadata,\\n articleId,\\n },\\n }\\n const result = executeSaveUpVote(upVote, onCommit, onCancel)\\n return { error: false, data: result }\\n}\\n\\nfunction deleteUpVote(config, articleId, upVoteId, onCommit, onCancel) {\\n setConfig(config)\\n\\n const deleteMetadata = buildDeleteMetadata(upVoteId)\\n const upVote = {\\n metadata: {\\n ...deleteMetadata,\\n articleId,\\n },\\n }\\n executeSaveUpVote(upVote, onCommit, onCancel)\\n}\\n\\nreturn {\\n getUpVotes,\\n createUpVote,\\n deleteUpVote,\\n functionsToTest: {\\n normalizeOldToV_0_0_1,\\n normalizeFromV0_0_1ToV0_0_2,\\n normalizeFromV0_0_2ToV0_0_3,\\n getUpVotesData,\\n fillAction,\\n getUpVoteBlackListByBlockHeight,\\n getLatestEdits,\\n filterInvalidUpVotes,\\n normalizeUpVote,\\n composeData,\\n executeSaveUpVote,\\n createUpVote,\\n deleteUpVote,\\n },\\n}\\n"
}
}
}
}
}
Output
Inspect
Result:
Hide 33 bytes
JSON
UTF-8
Hex
Base64
{
"block_height"
:
"127797017"
}
Logs:
No Logs