Skip to content
3 changes: 2 additions & 1 deletion client.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ function calculateChatId(to, from) {

async function queryMessages(to, from) {
try {
const res = await axios.get(`${PROTOCOL}://${HOST}/messages/${calculateChatId(USER.address, to)}`)
const res = await axios.get(`${PROTOCOL}://${HOST}/messages/${calculateChatId(USER.address, to)}/0`)
const { messages } = res.data
return messages
} catch (error) {
Expand Down Expand Up @@ -807,6 +807,7 @@ vorpal.command('email', 'registers your email address to the network').action(as
signedTx,
email: answer.email,
timestamp: Date.now(),
networkId,
}
injectTx(tx).then((res) => {
this.log(res)
Expand Down
28 changes: 23 additions & 5 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,18 +165,26 @@ Returns address information for the given name.
- `name`: Account name

### GET /account/:id/:friendId/toll
⚠️ **DEPRECATED** - Deprecated in version 2.5.0. This endpoint will be removed in a future version.

Returns toll information between two accounts.

**Parameters:**
- `id`: Account identifier
- `friendId`: Friend's account identifier

**Note:** This endpoint is deprecated because the friend functionality has been removed. Use `/account/:id/toll` instead.

### GET /account/:id/friends
⚠️ **DEPRECATED** - Deprecated in version 2.5.0. This endpoint will be removed in a future version.

Returns friends list for the given account ID.

**Parameters:**
- `id`: Account identifier

**Note:** This endpoint is deprecated because the friend functionality has been removed.

### GET /account/:id/recentMessages
Returns recent messages for the given account ID.

Expand Down Expand Up @@ -501,7 +509,9 @@ The transaction will:
2. Add amount to target account
3. Update timestamps for both accounts

#### `email`
#### `email` ⚠️ DEPRECATED
**Deprecated in version 2.5.0** - This transaction type is deprecated and will be removed in a future version. New transactions of this type will be rejected when network version >= 2.5.0.

Initiates the email verification process for an account.

**Transaction Parameters:**
Expand Down Expand Up @@ -533,7 +543,9 @@ The transaction will:
3. Store email hash and verification code hash
4. Trigger gossip_email_hash transaction

#### `gossip_email_hash`
#### `gossip_email_hash` ⚠️ DEPRECATED
**Deprecated in version 2.5.0** - This transaction type is deprecated and will be removed in a future version. New transactions of this type will be rejected when network version >= 2.5.0.

Internal transaction to propagate email verification data across nodes.

**Transaction Parameters:**
Expand All @@ -551,7 +563,9 @@ Internal transaction to propagate email verification data across nodes.

This transaction is automatically triggered by the system after an email transaction and should not be manually created.

#### `verify`
#### `verify` ⚠️ DEPRECATED
**Deprecated in version 2.5.0** - This transaction type is deprecated and will be removed in a future version. New transactions of this type will be rejected when network version >= 2.5.0.

Completes the email verification process using the code received via email.

**Transaction Parameters:**
Expand Down Expand Up @@ -655,7 +669,9 @@ The transaction will:
4. Update chat references for both users
5. Update timestamps for all affected accounts

#### `friend`
#### `friend` ⚠️ DEPRECATED
**Deprecated in version 2.5.0** - This transaction type is deprecated and will be removed in a future version. New transactions of this type will be rejected when network version >= 2.5.0.

Adds another user as a friend to avoid toll payments for messaging.

**Transaction Parameters:**
Expand Down Expand Up @@ -714,7 +730,9 @@ The transaction will:

Note: If a user has not set a toll amount, the system's default toll will be used for messages from non-friends.

#### `remove_friend`
#### `remove_friend` ⚠️ DEPRECATED
**Deprecated in version 2.5.0** - This transaction type is deprecated and will be removed in a future version. New transactions of this type will be rejected when network version >= 2.5.0.

Removes a friend from the user's friend list, requiring toll payments for future messages.

**Transaction Parameters:**
Expand Down
10 changes: 10 additions & 0 deletions src/@types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ export enum AJVSchemaEnum {
init_network = 'init_network',
network_windows = 'network_windows',
snapshot = 'snapshot',
/** @deprecated Deprecated in version 2.5.0 - will be removed in a future version */
email = 'email',
/** @deprecated Deprecated in version 2.5.0 - will be removed in a future version */
gossip_email_hash = 'gossip_email_hash',
/** @deprecated Deprecated in version 2.5.0 - will be removed in a future version */
verify = 'verify',
register = 'register',
create = 'create',
Expand All @@ -36,7 +39,9 @@ export enum AJVSchemaEnum {
update_chat_toll = 'update_chat_toll',
update_toll_required = 'update_toll_required',
toll = 'toll',
/** @deprecated Deprecated in version 2.5.0 - will be removed in a future version */
friend = 'friend',
/** @deprecated Deprecated in version 2.5.0 - will be removed in a future version */
remove_friend = 'remove_friend',
stake = 'stake',
remove_stake = 'remove_stake',
Expand Down Expand Up @@ -76,8 +81,11 @@ export enum TXTypes {
init_network = 'init_network',
network_windows = 'network_windows',
snapshot = 'snapshot',
/** @deprecated Deprecated in version 2.5.0 - will be removed in a future version */
email = 'email',
/** @deprecated Deprecated in version 2.5.0 - will be removed in a future version */
gossip_email_hash = 'gossip_email_hash',
/** @deprecated Deprecated in version 2.5.0 - will be removed in a future version */
verify = 'verify',
register = 'register',
create = 'create',
Expand All @@ -89,7 +97,9 @@ export enum TXTypes {
update_chat_toll = 'update_chat_toll',
update_toll_required = 'update_toll_required',
toll = 'toll',
/** @deprecated Deprecated in version 2.5.0 - will be removed in a future version */
friend = 'friend',
/** @deprecated Deprecated in version 2.5.0 - will be removed in a future version */
remove_friend = 'remove_friend',
stake = 'stake',
remove_stake = 'remove_stake',
Expand Down
5 changes: 5 additions & 0 deletions src/@types/transactionSchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ export const schemaDistributeTX = {
additionalProperties: false,
}

// @deprecated Deprecated in version 2.5.0 - will be removed in a future version
export const schemaEmailTX = {
type: 'object',
properties: {
Expand All @@ -171,6 +172,7 @@ export const schemaEmailTX = {
additionalProperties: false,
}

// @deprecated Deprecated in version 2.5.0 - will be removed in a future version
export const schemaFriendTX = {
type: 'object',
properties: {
Expand All @@ -183,6 +185,7 @@ export const schemaFriendTX = {
additionalProperties: false,
}

// @deprecated Deprecated in version 2.5.0 - will be removed in a future version
export const schemaGossipEmailHashTX = {
type: 'object',
properties: {
Expand Down Expand Up @@ -428,6 +431,7 @@ export const schemaRegisterTX = {
additionalProperties: false,
}

// @deprecated Deprecated in version 2.5.0 - will be removed in a future version
export const schemaRemoveFriendTX = {
type: 'object',
properties: {
Expand Down Expand Up @@ -536,6 +540,7 @@ export const schemaTollTX = {
additionalProperties: false,
}

// @deprecated Deprecated in version 2.5.0 - will be removed in a future version
export const schemaVerifyTX = {
type: 'object',
properties: {
Expand Down
17 changes: 17 additions & 0 deletions src/api/accounts/friends.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
import * as AccountsStorage from '../../storage/accountStorage'
import * as utils from '../../utils'

export const friends = dapp => async (req, res): Promise<void> => {
try {
// Deprecation check - reject when network version >= 2.5.0
// This check is disabled until network version is flipped to 2.5.0 or higher
if (
AccountsStorage?.cachedNetworkAccount &&
utils.isEqualOrNewerVersion('2.5.0', AccountsStorage.cachedNetworkAccount.current.activeVersion)
) {
res.status(410).json({
error: 'This endpoint is deprecated and no longer available',
deprecated: true,
deprecatedVersion: '2.5.0',
})
return
}

const id = req.params['id']
const account = await dapp.getLocalOrRemoteAccount(id)
if (account) {
Expand Down
14 changes: 14 additions & 0 deletions src/api/accounts/tollOfFriend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ import * as AccountsStorage from '../../storage/accountStorage'

export const tollOfFriend = dapp => async (req, res): Promise<void> => {
try {
// Deprecation check - reject when network version >= 2.5.0
// This check is disabled until network version is flipped to 2.5.0 or higher
if (
AccountsStorage?.cachedNetworkAccount &&
utils.isEqualOrNewerVersion('2.5.0', AccountsStorage.cachedNetworkAccount.current.activeVersion)
) {
res.status(410).json({
error: 'This endpoint is deprecated and no longer available',
deprecated: true,
deprecatedVersion: '2.5.0',
})
return
}

const id = req.params['id']
const friendId = req.params['friendId']
if (!id) {
Expand Down
9 changes: 9 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,15 @@ const shardusSetup = (): void => {
return validationResult
}

// 3.5. Check for deprecated transaction types (version-based deprecation >= 2.5.0)
if (AccountsStorage?.cachedNetworkAccount && utils.isEqualOrNewerVersion('2.5.0', AccountsStorage.cachedNetworkAccount.current.activeVersion)) {
const deprecatedTxTypes = [TXTypes.email, TXTypes.gossip_email_hash, TXTypes.verify, TXTypes.friend, TXTypes.remove_friend]
if (deprecatedTxTypes.includes(tx.type)) {
validationResult.reason = `Transaction type "${tx.type}" is deprecated from version 2.5.0 onwards and no longer accepted`
return validationResult
}
}

// 4. Validate the tx fields
if (LiberdusFlags.enableAJVValidation) {
const errors = verifyPayload(tx.type, tx)
Expand Down