Skip to content

Commit

Permalink
release: v3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
martiliones authored Jun 19, 2024
2 parents 594df8c + 4972158 commit 0352603
Show file tree
Hide file tree
Showing 6 changed files with 264 additions and 252 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# config environment variable files
config.json
config.jsonc

# Code editors settings
.vscode
Expand Down
3 changes: 3 additions & 0 deletions bin/adamant.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ client.command('version').action(() => {
log({
success: true,
version: packageInfo.version,
config: config.configPath,
network: config.network,
account: config.accountAddress,
});
});

Expand Down
25 changes: 12 additions & 13 deletions lib/api/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,18 @@ export async function getMessage(id = requiredParam('id'), customPassphrase) {
const passphrase = customPassphrase || config.passphrase;

if (!passphrase) {
return res.data || res;
return res;
}

const { data } = res;
const { transaction, error } = res;

if (!data) {
return res;
if (error) {
return {
success: false,
error,
};
}

const { transaction } = data;

if (transaction?.type !== TransactionType.CHAT_MESSAGE) {
return {
success: false,
Expand All @@ -65,7 +66,7 @@ export async function getMessage(id = requiredParam('id'), customPassphrase) {
if (
![transaction.senderId, transaction.recipientId].includes(readerAddress)
) {
return res.data || res;
return res;
}

const recipientName =
Expand All @@ -78,18 +79,16 @@ export async function getMessage(id = requiredParam('id'), customPassphrase) {
if (publicKey) {
const decoded = decodeMessage(
transaction.asset.chat.message,
transaction.asset.chat.own_message,
keypair.privateKey,
publicKey,
keypair,
transaction.asset.chat.own_message,
);

transaction.asset.chat.message = decoded;

delete transaction.asset.chat.own_message;
transaction.decoded = decoded;
}
}

return data;
return res;
}

export async function getTransaction(id = requiredParam('id')) {
Expand Down
Loading

0 comments on commit 0352603

Please sign in to comment.