Skip to content

Commit

Permalink
Merge branch 'refs/heads/develop'
Browse files Browse the repository at this point in the history
# Conflicts:
#	package.json
#	packages/api/package.json
#	packages/data-contract/package.json
#	packages/frontend/package.json
#	packages/indexer/Cargo.lock
#	packages/indexer/Cargo.toml
  • Loading branch information
pshenmic committed Dec 28, 2024
2 parents 1328829 + 21ddaa4 commit 5cfe736
Show file tree
Hide file tree
Showing 13 changed files with 171 additions and 22 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "platform-explorer",
"version": "1.0.11",
"version": "1.0.8",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "api",
"version": "1.0.11",
"version": "1.0.8",
"main": "index.js",
"license": "MIT",
"scripts": {
Expand Down
8 changes: 4 additions & 4 deletions packages/api/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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 {
Expand Down
137 changes: 137 additions & 0 deletions packages/api/test/unit/utils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
})
})
})
2 changes: 1 addition & 1 deletion packages/data-contract/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "frontend",
"version": "1.0.11",
"version": "1.0.8",
"private": true,
"dependencies": {
"@chakra-ui/icons": "^2.1.1",
Expand Down
8 changes: 4 additions & 4 deletions packages/frontend/src/app/identities/intro.md
Original file line number Diff line number Diff line change
@@ -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.
- 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.
10 changes: 8 additions & 2 deletions packages/frontend/src/components/data/Alias.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@ export default function Alias ({ alias, status, children, ellipsis = true, class
pending: 'Alias is pending'
}

const Container = ({ children }) => (
titles?.[status]
? <Tooltip content={titles?.[status]} placement={'top'}>{children}</Tooltip>
: children
)

return (
<Tooltip content={titles?.[status]} placement={'top'}>
<Container>
<div className={`Alias ${statusClasses?.[status] || ''} ${ellipsis ? 'Alias--Ellipsis' : ''} ${className || ''}`}>
<span className={'Alias__Name'}>
{dashIndex !== -1
Expand All @@ -43,6 +49,6 @@ export default function Alias ({ alias, status, children, ellipsis = true, class

<StatusIcon className={'Alias__LockedIcon'}/>
</div>
</Tooltip>
</Container>
)
}
12 changes: 11 additions & 1 deletion packages/frontend/src/components/documents/DocumentsListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Link href={`/document/${document?.identifier}`} className={'DocumentsListItem'}>
<Grid className={'DocumentsListItem__Content'}>
Expand All @@ -22,7 +25,14 @@ function DocumentsListItem ({ document }) {

<GridItem className={'DocumentsListItem__Column DocumentsListItem__Column--Owner'}>
{document?.owner
? <LinkContainer className={'DocumentsListItem__ColumnContent'} isLocal={true} href={'/identity/' + document?.owner}>
? <LinkContainer
className={'DocumentsListItem__ColumnContent'}
onClick={e => {
e.stopPropagation()
e.preventDefault()
router.push(`/identity/${document?.owner}`)
}}
>
<Identifier ellipsis={true} avatar={true} styles={['highlight-both']}>{document?.owner}</Identifier>
</LinkContainer>
: <span className={'DocumentsListItem__NotActiveText'}>-</span>
Expand Down
5 changes: 1 addition & 4 deletions packages/frontend/src/components/identities/Cards.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ function IdentityCard ({ identity, rate, loading = false }) {
{(() => {
const activeAlias = identity?.aliases?.find(alias => alias.status === 'ok')
return activeAlias
? <Alias
alias={activeAlias.alias}
status={activeAlias.status}
/>
? <Alias alias={activeAlias.alias}/>
: <Identifier styles={['highlight-both']}>
{identity.identifier}
</Identifier>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ function IdentitiesListItem ({ identity }) {
? <Alias
className={'IdentitiesListItem__Alias'}
alias={activeAlias.alias}
status={activeAlias.status}
/>
: <Identifier
className={'IdentitiesListItem__Identifier'}
Expand Down
2 changes: 1 addition & 1 deletion packages/indexer/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/indexer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "indexer"
version = "1.0.11"
version = "1.0.8"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down

0 comments on commit 5cfe736

Please sign in to comment.