diff --git a/package.json b/package.json index b68f9052a..635fe2628 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "platform-explorer", - "version": "1.0.11", + "version": "1.0.8", "description": "", "main": "index.js", "scripts": { diff --git a/packages/api/package.json b/packages/api/package.json index 426698a8b..07358b684 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -1,6 +1,6 @@ { "name": "api", - "version": "1.0.11", + "version": "1.0.8", "main": "index.js", "license": "MIT", "scripts": { diff --git a/packages/api/src/utils.js b/packages/api/src/utils.js index b2c92ac6f..f7003f913 100644 --- a/packages/api/src/utils.js +++ b/packages/api/src/utils.js @@ -446,7 +446,7 @@ const buildIndexBuffer = (name) => { const getAliasStateByVote = (aliasInfo, alias, identifier) => { let status = null - if (aliasInfo.contestedState === null) { + if (!aliasInfo.contestedState) { return { alias, status: 'ok', @@ -458,12 +458,12 @@ const getAliasStateByVote = (aliasInfo, alias, identifier) => { Buffer.from(aliasInfo.contestedState?.finishedVoteInfo?.wonByIdentityId ?? '', 'base64') ) - if (identifier !== bs58Identifier && bs58Identifier !== '') { + if (identifier === bs58Identifier) { + status = 'ok' + } else if (bs58Identifier !== '' || aliasInfo.contestedState?.finishedVoteInfo?.wonByIdentityId === '') { status = 'locked' } else if (aliasInfo.contestedState?.finishedVoteInfo?.wonByIdentityId === undefined) { status = 'pending' - } else { - status = 'ok' } return { diff --git a/packages/api/test/unit/utils.spec.js b/packages/api/test/unit/utils.spec.js index 8e69c8e1b..449e2ff17 100644 --- a/packages/api/test/unit/utils.spec.js +++ b/packages/api/test/unit/utils.spec.js @@ -329,4 +329,141 @@ describe('Utils', () => { }) }) }) + describe('getAliasStateByVote()', () => { + it('should return ok if our identifier equal to winner identifier', () => { + const mockVote = { + alias: 'pshenmic.dash', + contestedState: { + contendersList: [ + { + identifier: 'n4ay5zy5fRyuqEYkMwlkmmIay6RP9mlhSjLeBK3puwM=', + voteCount: 16, + document: '' + } + ], + abstainVoteTally: 0, + lockVoteTally: 0, + finishedVoteInfo: { + finishedVoteOutcome: 0, + wonByIdentityId: 'n4ay5zy5fRyuqEYkMwlkmmIay6RP9mlhSjLeBK3puwM=', + finishedAtBlockHeight: 24407, + finishedAtCoreBlockHeight: 2158202, + finishedAtBlockTimeMs: 1729411671125, + finishedAtEpoch: 5 + } + } + } + + const info = utils.getAliasStateByVote(mockVote, mockVote.alias, 'BjixEUbqeUZK7BRdqtLgjzwFBovx4BRwS2iwhMriiYqp') + + assert.deepEqual(info, { + alias: mockVote.alias, + status: 'ok', + contested: true + }) + }) + + it('should return ok if we not contested', () => { + const mockVote = { contestedState: null } + + const info = utils.getAliasStateByVote(mockVote, 'alias343', 'BjixEUbqeUZK7BRdqtLgjzwFBovx4BRwS2iwhMriiYqp') + + assert.deepEqual(info, { + alias: 'alias343', + status: 'ok', + contested: false + }) + }) + + it('should return pending if we don\'t have winner', () => { + const mockVote = { + alias: 'pshenmic.dash', + contestedState: { + contendersList: [ + { + identifier: 'n4ay5zy5fRyuqEYkMwlkmmIay6RP9mlhSjLeBK3puwM=', + voteCount: 16, + document: '' + } + ], + abstainVoteTally: 0, + lockVoteTally: 0 + } + } + + const info = utils.getAliasStateByVote(mockVote, mockVote.alias, 'BjixEUbqeUZK7BRdqtLgjzwFBovx4BRwS2iwhMriiYqp') + + assert.deepEqual(info, { + alias: mockVote.alias, + status: 'pending', + contested: true + }) + }) + + it('should return locked if our identifier not equal to winner identifier', () => { + const mockVote = { + alias: 'pshenmic.dash', + contestedState: { + contendersList: [ + { + identifier: 'n4ay5zy5fRyuqEYkMwlkmmIay6RP9mlhSjLeBK3puwM=', + voteCount: 16, + document: '' + } + ], + abstainVoteTally: 0, + lockVoteTally: 0, + finishedVoteInfo: { + finishedVoteOutcome: 0, + wonByIdentityId: 'n4ay5zy5fRyuqEYkMwlkmmIay6RP9mlhSjLeBK3puwM=', + finishedAtBlockHeight: 24407, + finishedAtCoreBlockHeight: 2158202, + finishedAtBlockTimeMs: 1729411671125, + finishedAtEpoch: 5 + } + } + } + + const info = utils.getAliasStateByVote(mockVote, mockVote.alias, 'AjixEUbqeUZK7BRdqtLgjzwFBovx4BRwS2iwhMriiYqp') + + assert.deepEqual(info, { + alias: mockVote.alias, + status: 'locked', + contested: true + }) + }) + + it('should return locked if winner identifier equal "" (empty string)', () => { + const mockVote = { + alias: 'pshenmic.dash', + contestedState: { + contendersList: [ + { + identifier: 'n4ay5zy5fRyuqEYkMwlkmmIay6RP9mlhSjLeBK3puwM=', + voteCount: 16, + document: '' + } + ], + abstainVoteTally: 0, + lockVoteTally: 0, + finishedVoteInfo: { + finishedVoteOutcome: 0, + wonByIdentityId: '', + finishedAtBlockHeight: 24407, + finishedAtCoreBlockHeight: 2158202, + finishedAtBlockTimeMs: 1729411671125, + finishedAtEpoch: 5 + } + } + } + + const info = utils.getAliasStateByVote(mockVote, mockVote.alias, 'AjixEUbqeUZK7BRdqtLgjzwFBovx4BRwS2iwhMriiYqp') + + assert.deepEqual(info, { + alias: mockVote.alias, + status: 'locked', + contested: true + }) + }) + }) }) diff --git a/packages/data-contract/package.json b/packages/data-contract/package.json index e99a8a4fe..a8e592afa 100644 --- a/packages/data-contract/package.json +++ b/packages/data-contract/package.json @@ -1,6 +1,6 @@ { "name": "data-contract", - "version": "1.0.11", + "version": "1.0.8", "main": "index.js", "scripts": { "dataContract:deploy": "node ./src/actions/deployContract.js", diff --git a/packages/frontend/package.json b/packages/frontend/package.json index d9aa9aae1..3472e708b 100644 --- a/packages/frontend/package.json +++ b/packages/frontend/package.json @@ -1,6 +1,6 @@ { "name": "frontend", - "version": "1.0.11", + "version": "1.0.8", "private": true, "dependencies": { "@chakra-ui/icons": "^2.1.1", diff --git a/packages/frontend/src/app/identities/intro.md b/packages/frontend/src/app/identities/intro.md index 21221b95e..485025a66 100644 --- a/packages/frontend/src/app/identities/intro.md +++ b/packages/frontend/src/app/identities/intro.md @@ -1,6 +1,6 @@ -Identity in the [Dash Platform](/) is a unique digital representation of an entity within the network. This could be an individual, organization, or even another program acting within the blockchain ecosystem. Identities play a crucial role in enabling verifiable, enhancing security, and fostering trust within the decentralized environment. +Identity in the [Dash Platform](/) is a unique digital representation of an entity within the network. This could be an individual, organization, or even another program acting within the blockchain ecosystem. Identities play a crucial role in enabling verification, enhancing security, and fostering trust within the decentralized environment. Each Identity contains several key pieces of information: -- Balance: The amount of digital assets or tokens by the identity; -- Identity ID: A unique identifier that distinguishes; -- Associated [Transactions](/transactions), [Data Contracts](/dataContracts) and Documents. \ No newline at end of file +- Identity ID: A unique identifier that distinguishes this identity from all other identities; +- Balance: The amount of digital assets or tokens owned by this identity; +- Associated items: [Transactions](/transactions), [Data Contracts](/dataContracts) and Documents. \ No newline at end of file diff --git a/packages/frontend/src/components/data/Alias.js b/packages/frontend/src/components/data/Alias.js index 13acacb2b..72192c689 100644 --- a/packages/frontend/src/components/data/Alias.js +++ b/packages/frontend/src/components/data/Alias.js @@ -25,8 +25,14 @@ export default function Alias ({ alias, status, children, ellipsis = true, class pending: 'Alias is pending' } + const Container = ({ children }) => ( + titles?.[status] + ? {children} + : children + ) + return ( - +
{dashIndex !== -1 @@ -43,6 +49,6 @@ export default function Alias ({ alias, status, children, ellipsis = true, class
-
+ ) } diff --git a/packages/frontend/src/components/documents/DocumentsListItem.js b/packages/frontend/src/components/documents/DocumentsListItem.js index b1fdaaa0b..6ebc63cb5 100644 --- a/packages/frontend/src/components/documents/DocumentsListItem.js +++ b/packages/frontend/src/components/documents/DocumentsListItem.js @@ -3,9 +3,12 @@ import { Identifier } from '../data' import { LinkContainer } from '../ui/containers' import Link from 'next/link' import { getTimeDelta } from '../../util' +import { useRouter } from 'next/navigation' import './DocumentsListItem.scss' function DocumentsListItem ({ document }) { + const router = useRouter() + return ( @@ -22,7 +25,14 @@ function DocumentsListItem ({ document }) { {document?.owner - ? + ? { + e.stopPropagation() + e.preventDefault() + router.push(`/identity/${document?.owner}`) + }} + > {document?.owner} : - diff --git a/packages/frontend/src/components/identities/Cards.js b/packages/frontend/src/components/identities/Cards.js index 6dd40981e..7e2ba88ba 100644 --- a/packages/frontend/src/components/identities/Cards.js +++ b/packages/frontend/src/components/identities/Cards.js @@ -25,10 +25,7 @@ function IdentityCard ({ identity, rate, loading = false }) { {(() => { const activeAlias = identity?.aliases?.find(alias => alias.status === 'ok') return activeAlias - ? + ? : {identity.identifier} diff --git a/packages/frontend/src/components/identities/IdentitiesListItem.js b/packages/frontend/src/components/identities/IdentitiesListItem.js index 40e278eda..7a4cfc4e4 100644 --- a/packages/frontend/src/components/identities/IdentitiesListItem.js +++ b/packages/frontend/src/components/identities/IdentitiesListItem.js @@ -20,7 +20,6 @@ function IdentitiesListItem ({ identity }) { ? :