diff --git a/src/background-cases.ts b/src/background-cases.ts
index d4ab82a..831c032 100644
--- a/src/background-cases.ts
+++ b/src/background-cases.ts
@@ -52,26 +52,31 @@ import {
sendChatGroup,
sendChatNotification,
sendCoin,
- setChatHeads,
setGroupData,
updateThreadActivity,
walletVersion,
-} from "./background";
-import { decryptGroupEncryption, encryptAndPublishSymmetricKeyGroupChat, encryptAndPublishSymmetricKeyGroupChatForAdmins, publishGroupEncryptedResource, publishOnQDN } from "./backgroundFunctions/encryption";
-import { PUBLIC_NOTIFICATION_CODE_FIRST_SECRET_KEY } from "./constants/codes";
-import Base58 from "./deps/Base58";
-import { encryptSingle } from "./qdn/encryption/group-encryption";
-import { _createPoll, _voteOnPoll } from "./qortalRequests/get";
-import { createTransaction } from "./transactions/transactions";
-import { getData, storeData } from "./utils/chromeStorage";
+} from './background';
+import {
+ decryptGroupEncryption,
+ encryptAndPublishSymmetricKeyGroupChat,
+ encryptAndPublishSymmetricKeyGroupChatForAdmins,
+ publishGroupEncryptedResource,
+ publishOnQDN,
+} from './backgroundFunctions/encryption';
+import { PUBLIC_NOTIFICATION_CODE_FIRST_SECRET_KEY } from './constants/codes';
+import Base58 from './deps/Base58';
+import { encryptSingle } from './qdn/encryption/group-encryption';
+import { _createPoll, _voteOnPoll } from './qortalRequests/get';
+import { createTransaction } from './transactions/transactions';
+import { getData, storeData } from './utils/chromeStorage';
export function versionCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "version",
- payload: { version: "1.0" },
- type: "backgroundMessageResponse",
+ action: 'version',
+ payload: { version: '1.0' },
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -82,14 +87,14 @@ export async function getWalletInfoCase(request, event) {
const response = await getKeyPair();
try {
- const walletInfo = await getData('walletInfo').catch((error)=> null)
- if(walletInfo){
+ const walletInfo = await getData('walletInfo').catch((error) => null);
+ if (walletInfo) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "getWalletInfo",
+ action: 'getWalletInfo',
payload: { walletInfo, hasKeyPair: true },
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -97,36 +102,34 @@ export async function getWalletInfoCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "getWalletInfo",
- error: "No wallet info found",
- type: "backgroundMessageResponse",
+ action: 'getWalletInfo',
+ error: 'No wallet info found', // TODO translate
+ type: 'backgroundMessageResponse',
},
event.origin
);
}
-
} catch (error) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "getWalletInfo",
- error: "No wallet info found",
- type: "backgroundMessageResponse",
+ action: 'getWalletInfo',
+ error: 'No wallet info found',
+ type: 'backgroundMessageResponse',
},
event.origin
);
}
-
} catch (error) {
try {
- const walletInfo = await getData('walletInfo').catch((error)=> null)
- if(walletInfo){
+ const walletInfo = await getData('walletInfo').catch((error) => null);
+ if (walletInfo) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "getWalletInfo",
+ action: 'getWalletInfo',
payload: { walletInfo, hasKeyPair: false },
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -134,9 +137,9 @@ export async function getWalletInfoCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "getWalletInfo",
- error: "Wallet not authenticated",
- type: "backgroundMessageResponse",
+ action: 'getWalletInfo',
+ error: 'Wallet not authenticated',
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -145,14 +148,13 @@ export async function getWalletInfoCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "getWalletInfo",
- error: "Wallet not authenticated",
- type: "backgroundMessageResponse",
+ action: 'getWalletInfo',
+ error: 'Wallet not authenticated',
+ type: 'backgroundMessageResponse',
},
event.origin
);
}
-
}
}
@@ -163,9 +165,9 @@ export async function validApiCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "validApi",
+ action: 'validApi',
payload: usableApi,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -173,9 +175,9 @@ export async function validApiCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "validApi",
+ action: 'validApi',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -189,9 +191,9 @@ export async function nameCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "name",
+ action: 'name',
payload: response,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -199,9 +201,9 @@ export async function nameCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "name",
+ action: 'name',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -215,9 +217,9 @@ export async function userInfoCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "userInfo",
+ action: 'userInfo',
payload: response,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -225,9 +227,9 @@ export async function userInfoCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "userInfo",
- error: "User not authenticated",
- type: "backgroundMessageResponse",
+ action: 'userInfo',
+ error: 'User not authenticated',
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -235,15 +237,19 @@ export async function userInfoCase(request, event) {
}
export async function decryptWalletCase(request, event) {
- try {
+ try {
const { password, wallet } = request.payload;
- const response = await decryptWallet({password, wallet, walletVersion: wallet?.version || walletVersion});
+ const response = await decryptWallet({
+ password,
+ wallet,
+ walletVersion: wallet?.version || walletVersion,
+ });
event.source.postMessage(
{
requestId: request.requestId,
- action: "decryptWallet",
+ action: 'decryptWallet',
payload: response,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -251,9 +257,9 @@ export async function decryptWalletCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "decryptWallet",
+ action: 'decryptWallet',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -267,9 +273,9 @@ export async function balanceCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "balance",
+ action: 'balance',
payload: response,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -277,9 +283,9 @@ export async function balanceCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "balance",
+ action: 'balance',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -292,9 +298,9 @@ export async function ltcBalanceCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "ltcBalance",
+ action: 'ltcBalance',
payload: response,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -302,9 +308,9 @@ export async function ltcBalanceCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "ltcBalance",
+ action: 'ltcBalance',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -319,9 +325,9 @@ export async function sendCoinCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "sendCoin",
+ action: 'sendCoin',
error: res?.data?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -330,9 +336,9 @@ export async function sendCoinCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "sendCoin",
+ action: 'sendCoin',
payload: true,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -340,9 +346,9 @@ export async function sendCoinCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "sendCoin",
+ action: 'sendCoin',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -361,9 +367,9 @@ export async function inviteToGroupCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "inviteToGroup",
+ action: 'inviteToGroup',
payload: response,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -371,9 +377,9 @@ export async function inviteToGroupCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "inviteToGroup",
+ action: 'inviteToGroup',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -388,9 +394,9 @@ export async function saveTempPublishCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "saveTempPublish",
+ action: 'saveTempPublish',
payload: response,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -398,9 +404,9 @@ export async function saveTempPublishCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "saveTempPublish",
+ action: 'saveTempPublish',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -414,9 +420,9 @@ export async function getTempPublishCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "getTempPublish",
+ action: 'getTempPublish',
payload: response,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -424,9 +430,9 @@ export async function getTempPublishCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "getTempPublish",
+ action: 'getTempPublish',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -455,9 +461,9 @@ export async function createGroupCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "createGroup",
+ action: 'createGroup',
payload: response,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -465,9 +471,9 @@ export async function createGroupCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "createGroup",
+ action: 'createGroup',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -482,9 +488,9 @@ export async function cancelInvitationToGroupCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "cancelInvitationToGroup",
+ action: 'cancelInvitationToGroup',
payload: response,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -492,9 +498,9 @@ export async function cancelInvitationToGroupCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "cancelInvitationToGroup",
+ action: 'cancelInvitationToGroup',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -509,9 +515,9 @@ export async function leaveGroupCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "leaveGroup",
+ action: 'leaveGroup',
payload: response,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -519,9 +525,9 @@ export async function leaveGroupCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "leaveGroup",
+ action: 'leaveGroup',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -536,9 +542,9 @@ export async function joinGroupCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "joinGroup",
+ action: 'joinGroup',
payload: response,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -546,9 +552,9 @@ export async function joinGroupCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "joinGroup",
+ action: 'joinGroup',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -567,9 +573,9 @@ export async function kickFromGroupCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "kickFromGroup",
+ action: 'kickFromGroup',
payload: response,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -577,9 +583,9 @@ export async function kickFromGroupCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "kickFromGroup",
+ action: 'kickFromGroup',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -599,9 +605,9 @@ export async function banFromGroupCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "banFromGroup",
+ action: 'banFromGroup',
payload: response,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -609,9 +615,9 @@ export async function banFromGroupCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "banFromGroup",
+ action: 'banFromGroup',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -621,14 +627,14 @@ export async function banFromGroupCase(request, event) {
export async function addDataPublishesCase(request, event) {
try {
const { data, groupId, type } = request.payload;
- const response = await addDataPublishes( data, groupId, type );
+ const response = await addDataPublishes(data, groupId, type);
event.source.postMessage(
{
requestId: request.requestId,
- action: "addDataPublishes",
+ action: 'addDataPublishes',
payload: response,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -636,9 +642,9 @@ export async function addDataPublishesCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "addDataPublishes",
+ action: 'addDataPublishes',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -648,14 +654,14 @@ export async function addDataPublishesCase(request, event) {
export async function getDataPublishesCase(request, event) {
try {
const { groupId, type } = request.payload;
- const response = await getDataPublishes(groupId, type );
+ const response = await getDataPublishes(groupId, type);
event.source.postMessage(
{
requestId: request.requestId,
- action: "getDataPublishes",
+ action: 'getDataPublishes',
payload: response,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -663,9 +669,9 @@ export async function getDataPublishesCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "getDataPublishes",
+ action: 'getDataPublishes',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -679,9 +685,9 @@ export async function addUserSettingsCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "addUserSettings",
+ action: 'addUserSettings',
payload: response,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -689,9 +695,9 @@ export async function addUserSettingsCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "addUserSettings",
+ action: 'addUserSettings',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -706,9 +712,9 @@ export async function getUserSettingsCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "getUserSettings",
+ action: 'getUserSettings',
payload: response,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -716,9 +722,9 @@ export async function getUserSettingsCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "getUserSettings",
+ action: 'getUserSettings',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -733,9 +739,9 @@ export async function cancelBanCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "cancelBan",
+ action: 'cancelBan',
payload: response,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -743,9 +749,9 @@ export async function cancelBanCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "cancelBan",
+ action: 'cancelBan',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -760,9 +766,9 @@ export async function registerNameCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "registerName",
+ action: 'registerName',
payload: response,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -770,9 +776,9 @@ export async function registerNameCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "registerName",
+ action: 'registerName',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -788,15 +794,15 @@ export async function createPollCase(request, event) {
options: pollOptions,
},
true,
- true // skip permission
+ true // skip permission
);
event.source.postMessage(
{
requestId: request.requestId,
- action: "registerName",
+ action: 'registerName',
payload: resCreatePoll,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -804,9 +810,9 @@ export async function createPollCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "registerName",
+ action: 'registerName',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -816,13 +822,12 @@ export async function voteOnPollCase(request, event) {
try {
const res = await _voteOnPoll(request.payload, true, true);
-
event.source.postMessage(
{
requestId: request.requestId,
- action: "registerName",
+ action: 'registerName',
payload: res,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -830,9 +835,9 @@ export async function voteOnPollCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "registerName",
+ action: 'registerName',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -847,9 +852,9 @@ export async function makeAdminCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "makeAdmin",
+ action: 'makeAdmin',
payload: response,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -857,9 +862,9 @@ export async function makeAdminCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "makeAdmin",
+ action: 'makeAdmin',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -874,9 +879,9 @@ export async function removeAdminCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "removeAdmin",
+ action: 'removeAdmin',
payload: response,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -884,9 +889,9 @@ export async function removeAdminCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "removeAdmin",
+ action: 'removeAdmin',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -895,14 +900,14 @@ export async function removeAdminCase(request, event) {
export async function notificationCase(request, event) {
try {
- const notificationId = "chat_notification_" + Date.now(); // Create a unique ID
+ const notificationId = 'chat_notification_' + Date.now(); // Create a unique ID
// chrome.notifications.create(notificationId, {
// type: "basic",
// iconUrl: "qort.png", // Add an appropriate icon for chat notifications
// title: "New Group Message!",
// message: "You have received a new message from one of your groups",
- // priority: 2, // Use the maximum priority to ensure it's
+ // priority: 2, // Use the maximum priority to ensure it's
// });
// Set a timeout to clear the notification after 'timeout' milliseconds
// setTimeout(() => {
@@ -922,9 +927,9 @@ export async function notificationCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "notification",
- error: "Error displaying notifaction",
- type: "backgroundMessageResponse",
+ action: 'notification',
+ error: 'Error displaying notifaction',
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -939,9 +944,9 @@ export async function addTimestampEnterChatCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "addTimestampEnterChat",
+ action: 'addTimestampEnterChat',
payload: response,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -949,9 +954,9 @@ export async function addTimestampEnterChatCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "addTimestampEnterChat",
+ action: 'addTimestampEnterChat',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -961,13 +966,13 @@ export async function addTimestampEnterChatCase(request, event) {
export async function setApiKeyCase(request, event) {
try {
const payload = request.payload;
- storeData('apiKey', payload)
+ storeData('apiKey', payload);
event.source.postMessage(
{
requestId: request.requestId,
- action: "setApiKey",
+ action: 'setApiKey',
payload: true,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -975,9 +980,9 @@ export async function setApiKeyCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "setApiKey",
+ action: 'setApiKey',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -986,14 +991,14 @@ export async function setApiKeyCase(request, event) {
export async function setCustomNodesCase(request, event) {
try {
const nodes = request.payload;
- storeData('customNodes', nodes)
+ storeData('customNodes', nodes);
event.source.postMessage(
{
requestId: request.requestId,
- action: "setCustomNodes",
+ action: 'setCustomNodes',
payload: true,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -1001,9 +1006,9 @@ export async function setCustomNodesCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "setCustomNodes",
+ action: 'setCustomNodes',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -1017,9 +1022,9 @@ export async function getApiKeyCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "getApiKey",
+ action: 'getApiKey',
payload: response,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -1027,9 +1032,9 @@ export async function getApiKeyCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "getApiKey",
+ action: 'getApiKey',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -1043,9 +1048,9 @@ export async function getCustomNodesFromStorageCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "getCustomNodesFromStorage",
+ action: 'getCustomNodesFromStorage',
payload: response,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -1053,9 +1058,9 @@ export async function getCustomNodesFromStorageCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "getCustomNodesFromStorage",
+ action: 'getCustomNodesFromStorage',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -1073,9 +1078,9 @@ export async function notifyAdminRegenerateSecretKeyCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "notifyAdminRegenerateSecretKey",
+ action: 'notifyAdminRegenerateSecretKey',
payload: response,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -1083,9 +1088,9 @@ export async function notifyAdminRegenerateSecretKeyCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "notifyAdminRegenerateSecretKey",
+ action: 'notifyAdminRegenerateSecretKey',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -1098,15 +1103,15 @@ export async function addGroupNotificationTimestampCase(request, event) {
const response = await addTimestampGroupAnnouncement({
groupId,
timestamp,
- seenTimestamp: true
+ seenTimestamp: true,
});
event.source.postMessage(
{
requestId: request.requestId,
- action: "addGroupNotificationTimestamp",
+ action: 'addGroupNotificationTimestamp',
payload: response,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -1114,9 +1119,9 @@ export async function addGroupNotificationTimestampCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "addGroupNotificationTimestamp",
+ action: 'addGroupNotificationTimestamp',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -1129,9 +1134,9 @@ export async function addEnteredQmailTimestampCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "addEnteredQmailTimestamp",
+ action: 'addEnteredQmailTimestamp',
payload: response,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -1139,9 +1144,9 @@ export async function addEnteredQmailTimestampCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "addEnteredQmailTimestamp",
+ action: 'addEnteredQmailTimestamp',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -1154,9 +1159,9 @@ export async function getEnteredQmailTimestampCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "getEnteredQmailTimestamp",
- payload: {timestamp: response},
- type: "backgroundMessageResponse",
+ action: 'getEnteredQmailTimestamp',
+ payload: { timestamp: response },
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -1164,9 +1169,9 @@ export async function getEnteredQmailTimestampCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "getEnteredQmailTimestamp",
+ action: 'getEnteredQmailTimestamp',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -1180,9 +1185,9 @@ export async function clearAllNotificationsCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "clearAllNotifications",
+ action: 'clearAllNotifications',
payload: true,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -1190,9 +1195,9 @@ export async function clearAllNotificationsCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "clearAllNotifications",
+ action: 'clearAllNotifications',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -1213,9 +1218,9 @@ export async function setGroupDataCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "setGroupData",
+ action: 'setGroupData',
payload: response,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -1223,9 +1228,9 @@ export async function setGroupDataCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "setGroupData",
+ action: 'setGroupData',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -1240,9 +1245,9 @@ export async function getGroupDataSingleCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "getGroupDataSingle",
+ action: 'getGroupDataSingle',
payload: response,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -1250,9 +1255,9 @@ export async function getGroupDataSingleCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "getGroupDataSingle",
+ action: 'getGroupDataSingle',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -1266,9 +1271,9 @@ export async function getTimestampEnterChatCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "getTimestampEnterChat",
+ action: 'getTimestampEnterChat',
payload: response,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -1276,9 +1281,9 @@ export async function getTimestampEnterChatCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "getTimestampEnterChat",
+ action: 'getTimestampEnterChat',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -1288,66 +1293,66 @@ export async function getTimestampEnterChatCase(request, event) {
export async function listActionsCase(request, event) {
try {
const { type, listName = '', items = [] } = request.payload;
- let responseData
+ let responseData;
- if(type === 'get'){
+ if (type === 'get') {
const url = await createEndpoint(`/lists/${listName}`);
- const response = await fetch(url);
- if (!response.ok) throw new Error("Failed to fetch");
-
- responseData = await response.json();
- } else if(type === 'remove'){
- const url = await createEndpoint(`/lists/${listName}`);
- const body = {
- items: items ,
- };
- const bodyToString = JSON.stringify(body);
- const response = await fetch(url, {
- method: "DELETE",
- headers: {
- "Content-Type": "application/json",
- },
- body: bodyToString,
- });
+ const response = await fetch(url);
+ if (!response.ok) throw new Error('Failed to fetch');
- if (!response.ok) throw new Error("Failed to remove from list");
- let res;
- try {
- res = await response.clone().json();
- } catch (e) {
- res = await response.text();
- }
- responseData = res;
- } else if(type === 'add'){
- const url = await createEndpoint(`/lists/${listName}`);
- const body = {
- items: items ,
- };
- const bodyToString = JSON.stringify(body);
- const response = await fetch(url, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: bodyToString,
- });
-
- if (!response.ok) throw new Error("Failed to add to list");
- let res;
- try {
- res = await response.clone().json();
- } catch (e) {
- res = await response.text();
- }
- responseData = res;
- }
+ responseData = await response.json();
+ } else if (type === 'remove') {
+ const url = await createEndpoint(`/lists/${listName}`);
+ const body = {
+ items: items,
+ };
+ const bodyToString = JSON.stringify(body);
+ const response = await fetch(url, {
+ method: 'DELETE',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: bodyToString,
+ });
+
+ if (!response.ok) throw new Error('Failed to remove from list');
+ let res;
+ try {
+ res = await response.clone().json();
+ } catch (e) {
+ res = await response.text();
+ }
+ responseData = res;
+ } else if (type === 'add') {
+ const url = await createEndpoint(`/lists/${listName}`);
+ const body = {
+ items: items,
+ };
+ const bodyToString = JSON.stringify(body);
+ const response = await fetch(url, {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: bodyToString,
+ });
+
+ if (!response.ok) throw new Error('Failed to add to list');
+ let res;
+ try {
+ res = await response.clone().json();
+ } catch (e) {
+ res = await response.text();
+ }
+ responseData = res;
+ }
event.source.postMessage(
{
requestId: request.requestId,
- action: "listActions",
+ action: 'listActions',
payload: responseData,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -1355,9 +1360,9 @@ export async function listActionsCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "listActions",
+ action: 'listActions',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -1371,9 +1376,9 @@ export async function getTimestampMentionCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "getTimestampMention",
+ action: 'getTimestampMention',
payload: response,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -1381,9 +1386,9 @@ export async function getTimestampMentionCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "getTimestampMention",
+ action: 'getTimestampMention',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -1398,9 +1403,9 @@ export async function addTimestampMentionCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "addTimestampMention",
+ action: 'addTimestampMention',
payload: response,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -1408,9 +1413,9 @@ export async function addTimestampMentionCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "addTimestampMention",
+ action: 'addTimestampMention',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -1424,9 +1429,9 @@ export async function getGroupNotificationTimestampCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "getGroupNotificationTimestamp",
+ action: 'getGroupNotificationTimestamp',
payload: response,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -1434,9 +1439,9 @@ export async function getGroupNotificationTimestampCase(request, event) {
event.source.postMessage(
{
requestId: request.requestId,
- action: "getGroupNotificationTimestamp",
+ action: 'getGroupNotificationTimestamp',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -1459,24 +1464,24 @@ export async function encryptAndPublishSymmetricKeyGroupChatCase(
event.source.postMessage(
{
requestId: request.requestId,
- action: "encryptAndPublishSymmetricKeyGroupChat",
+ action: 'encryptAndPublishSymmetricKeyGroupChat',
payload: data,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
if (!previousData) {
- try {
- sendChatGroup({
- groupId,
- typeMessage: undefined,
- chatReference: undefined,
- messageText: PUBLIC_NOTIFICATION_CODE_FIRST_SECRET_KEY,
- });
- } catch (error) {
- // error in sending chat message
+ try {
+ sendChatGroup({
+ groupId,
+ typeMessage: undefined,
+ chatReference: undefined,
+ messageText: PUBLIC_NOTIFICATION_CODE_FIRST_SECRET_KEY,
+ });
+ } catch (error) {
+ // error in sending chat message
+ }
}
- }
try {
sendChatNotification(data, groupId, previousData, numberOfMembers);
} catch (error) {
@@ -1486,9 +1491,9 @@ export async function encryptAndPublishSymmetricKeyGroupChatCase(
event.source.postMessage(
{
requestId: request.requestId,
- action: "encryptAndPublishSymmetricKeyGroupChat",
+ action: 'encryptAndPublishSymmetricKeyGroupChat',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -1505,15 +1510,15 @@ export async function encryptAndPublishSymmetricKeyGroupChatForAdminsCase(
await encryptAndPublishSymmetricKeyGroupChatForAdmins({
groupId,
previousData,
- admins
+ admins,
});
event.source.postMessage(
{
requestId: request.requestId,
- action: "encryptAndPublishSymmetricKeyGroupChatForAdmins",
+ action: 'encryptAndPublishSymmetricKeyGroupChatForAdmins',
payload: data,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -1521,9 +1526,9 @@ export async function encryptAndPublishSymmetricKeyGroupChatForAdminsCase(
event.source.postMessage(
{
requestId: request.requestId,
- action: "encryptAndPublishSymmetricKeyGroupChat",
+ action: 'encryptAndPublishSymmetricKeyGroupChat',
error: error?.message,
- type: "backgroundMessageResponse",
+ type: 'backgroundMessageResponse',
},
event.origin
);
@@ -1531,588 +1536,632 @@ export async function encryptAndPublishSymmetricKeyGroupChatForAdminsCase(
}
export async function publishGroupEncryptedResourceCase(request, event) {
- try {
- const {encryptedData, identifier} = request.payload;
- const response = await publishGroupEncryptedResource({encryptedData, identifier});
-
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "publishGroupEncryptedResource",
- payload: response,
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- } catch (error) {
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "publishGroupEncryptedResource",
- error: error?.message,
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- }
- }
+ try {
+ const { encryptedData, identifier } = request.payload;
+ const response = await publishGroupEncryptedResource({
+ encryptedData,
+ identifier,
+ });
- export async function publishOnQDNCase(request, event) {
- try {
- const {data, identifier, service, title,
- description,
- category,
- tag1,
- tag2,
- tag3,
- tag4,
- tag5, uploadType} = request.payload;
- const response = await publishOnQDN({data, identifier, service, title,
- description,
- category,
- tag1,
- tag2,
- tag3,
- tag4,
- tag5, uploadType});
-
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "publishOnQDN",
- payload: response,
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- } catch (error) {
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "publishOnQDN",
- error: error?.message || 'Unable to publish',
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- }
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'publishGroupEncryptedResource',
+ payload: response,
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
+ } catch (error) {
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'publishGroupEncryptedResource',
+ error: error?.message,
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
}
+}
- export async function handleActiveGroupDataFromSocketCase(request, event) {
- try {
- const {groups, directs} = request.payload;
- const response = await handleActiveGroupDataFromSocket({groups, directs});
-
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "handleActiveGroupDataFromSocket",
- payload: true,
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- } catch (error) {
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "handleActiveGroupDataFromSocket",
- error: error?.message,
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- }
+export async function publishOnQDNCase(request, event) {
+ try {
+ const {
+ data,
+ identifier,
+ service,
+ title,
+ description,
+ category,
+ tag1,
+ tag2,
+ tag3,
+ tag4,
+ tag5,
+ uploadType,
+ } = request.payload;
+ const response = await publishOnQDN({
+ data,
+ identifier,
+ service,
+ title,
+ description,
+ category,
+ tag1,
+ tag2,
+ tag3,
+ tag4,
+ tag5,
+ uploadType,
+ });
+
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'publishOnQDN',
+ payload: response,
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
+ } catch (error) {
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'publishOnQDN',
+ error: error?.message || 'Unable to publish',
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
}
+}
- export async function getThreadActivityCase(request, event) {
- try {
- const response = await checkThreads(true)
-
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "getThreadActivity",
- payload: response,
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- } catch (error) {
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "getThreadActivity",
- error: error?.message,
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- }
+export async function handleActiveGroupDataFromSocketCase(request, event) {
+ try {
+ const { groups, directs } = request.payload;
+ const response = await handleActiveGroupDataFromSocket({ groups, directs });
+
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'handleActiveGroupDataFromSocket',
+ payload: true,
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
+ } catch (error) {
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'handleActiveGroupDataFromSocket',
+ error: error?.message,
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
}
+}
- export async function updateThreadActivityCase(request, event) {
- try {
- const { threadId, qortalName, groupId, thread} = request.payload;
- const response = await updateThreadActivity({ threadId, qortalName, groupId, thread });
-
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "updateThreadActivity",
- payload: response,
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- } catch (error) {
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "updateThreadActivity",
- error: error?.message,
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- }
+export async function getThreadActivityCase(request, event) {
+ try {
+ const response = await checkThreads(true);
+
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'getThreadActivity',
+ payload: response,
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
+ } catch (error) {
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'getThreadActivity',
+ error: error?.message,
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
}
+}
- export async function decryptGroupEncryptionCase(request, event) {
- try {
- const { data} = request.payload;
- const response = await decryptGroupEncryption({ data });
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "decryptGroupEncryption",
- payload: response,
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- } catch (error) {
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "decryptGroupEncryption",
- error: error?.message,
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- }
+export async function updateThreadActivityCase(request, event) {
+ try {
+ const { threadId, qortalName, groupId, thread } = request.payload;
+ const response = await updateThreadActivity({
+ threadId,
+ qortalName,
+ groupId,
+ thread,
+ });
+
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'updateThreadActivity',
+ payload: response,
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
+ } catch (error) {
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'updateThreadActivity',
+ error: error?.message,
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
}
+}
- export async function encryptSingleCase(request, event) {
- try {
- const { data, secretKeyObject, typeNumber} = request.payload;
- const response = await encryptSingle({ data64: data, secretKeyObject, typeNumber });
-
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "encryptSingle",
- payload: response,
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- } catch (error) {
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "encryptSingle",
- error: error?.message,
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- }
+export async function decryptGroupEncryptionCase(request, event) {
+ try {
+ const { data } = request.payload;
+ const response = await decryptGroupEncryption({ data });
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'decryptGroupEncryption',
+ payload: response,
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
+ } catch (error) {
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'decryptGroupEncryption',
+ error: error?.message,
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
}
+}
- export async function decryptSingleCase(request, event) {
- try {
- const { data, secretKeyObject, skipDecodeBase64} = request.payload;
- const response = await decryptSingleFunc({ messages: data, secretKeyObject, skipDecodeBase64 });
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "decryptSingle",
- payload: response,
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- } catch (error) {
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "decryptSingle",
- error: error?.message,
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- }
+export async function encryptSingleCase(request, event) {
+ try {
+ const { data, secretKeyObject, typeNumber } = request.payload;
+ const response = await encryptSingle({
+ data64: data,
+ secretKeyObject,
+ typeNumber,
+ });
+
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'encryptSingle',
+ payload: response,
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
+ } catch (error) {
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'encryptSingle',
+ error: error?.message,
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
}
+}
- export async function pauseAllQueuesCase(request, event) {
- try {
- await pauseAllQueues();
-
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "pauseAllQueues",
- payload: true,
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- } catch (error) {
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "pauseAllQueues",
- error: error?.message,
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- }
+export async function decryptSingleCase(request, event) {
+ try {
+ const { data, secretKeyObject, skipDecodeBase64 } = request.payload;
+ const response = await decryptSingleFunc({
+ messages: data,
+ secretKeyObject,
+ skipDecodeBase64,
+ });
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'decryptSingle',
+ payload: response,
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
+ } catch (error) {
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'decryptSingle',
+ error: error?.message,
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
}
+}
- export async function resumeAllQueuesCase(request, event) {
- try {
- await resumeAllQueues();
-
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "resumeAllQueues",
- payload: true,
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- } catch (error) {
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "resumeAllQueues",
- error: error?.message,
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- }
+export async function pauseAllQueuesCase(request, event) {
+ try {
+ await pauseAllQueues();
+
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'pauseAllQueues',
+ payload: true,
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
+ } catch (error) {
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'pauseAllQueues',
+ error: error?.message,
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
}
- export async function checkLocalCase(request, event) {
- try {
- const response = await checkLocalFunc()
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "pauseAllQueues",
- payload: response,
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- } catch (error) {
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "checkLocal",
- error: error?.message,
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- }
+}
+
+export async function resumeAllQueuesCase(request, event) {
+ try {
+ await resumeAllQueues();
+
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'resumeAllQueues',
+ payload: true,
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
+ } catch (error) {
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'resumeAllQueues',
+ error: error?.message,
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
}
-
- export async function decryptSingleForPublishesCase(request, event) {
- try {
- const { data, secretKeyObject, skipDecodeBase64} = request.payload;
- const response = await decryptSingleForPublishes({ messages: data, secretKeyObject, skipDecodeBase64 });
-
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "decryptSingleForPublishes",
- payload: response,
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- } catch (error) {
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "decryptSingle",
- error: error?.message,
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- }
+}
+export async function checkLocalCase(request, event) {
+ try {
+ const response = await checkLocalFunc();
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'pauseAllQueues',
+ payload: response,
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
+ } catch (error) {
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'checkLocal',
+ error: error?.message,
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
}
+}
- export async function decryptDirectCase(request, event) {
- try {
- const { data, involvingAddress} = request.payload;
- const response = await decryptDirectFunc({ messages: data, involvingAddress });
-
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "decryptDirect",
- payload: response,
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- } catch (error) {
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "decryptDirect",
- error: error?.message,
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- }
+export async function decryptSingleForPublishesCase(request, event) {
+ try {
+ const { data, secretKeyObject, skipDecodeBase64 } = request.payload;
+ const response = await decryptSingleForPublishes({
+ messages: data,
+ secretKeyObject,
+ skipDecodeBase64,
+ });
+
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'decryptSingleForPublishes',
+ payload: response,
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
+ } catch (error) {
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'decryptSingle',
+ error: error?.message,
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
}
- export async function sendChatGroupCase(request, event) {
- try {
- const { groupId,
- typeMessage = undefined,
- chatReference = undefined,
- messageText} = request.payload;
- const response = await sendChatGroup({ groupId, typeMessage, chatReference, messageText });
-
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "sendChatGroup",
- payload: response,
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- } catch (error) {
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "sendChatGroup",
- error: error?.message,
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- }
+}
+
+export async function decryptDirectCase(request, event) {
+ try {
+ const { data, involvingAddress } = request.payload;
+ const response = await decryptDirectFunc({
+ messages: data,
+ involvingAddress,
+ });
+
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'decryptDirect',
+ payload: response,
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
+ } catch (error) {
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'decryptDirect',
+ error: error?.message,
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
}
- export async function sendChatDirectCase(request, event) {
- try {
- const { directTo,
- typeMessage = undefined,
- chatReference = undefined,
- messageText,
- publicKeyOfRecipient,
- address,
- otherData} = request.payload;
- const response = await sendChatDirect({ directTo,
- chatReference,
- messageText,
- typeMessage,
- publicKeyOfRecipient,
- address,
- otherData });
-
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "sendChatDirect",
- payload: response,
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- } catch (error) {
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "sendChatDirect",
- error: error?.message,
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- }
+}
+export async function sendChatGroupCase(request, event) {
+ try {
+ const {
+ groupId,
+ typeMessage = undefined,
+ chatReference = undefined,
+ messageText,
+ } = request.payload;
+ const response = await sendChatGroup({
+ groupId,
+ typeMessage,
+ chatReference,
+ messageText,
+ });
+
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'sendChatGroup',
+ payload: response,
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
+ } catch (error) {
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'sendChatGroup',
+ error: error?.message,
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
}
+}
+export async function sendChatDirectCase(request, event) {
+ try {
+ const {
+ directTo,
+ typeMessage = undefined,
+ chatReference = undefined,
+ messageText,
+ publicKeyOfRecipient,
+ address,
+ otherData,
+ } = request.payload;
+ const response = await sendChatDirect({
+ directTo,
+ chatReference,
+ messageText,
+ typeMessage,
+ publicKeyOfRecipient,
+ address,
+ otherData,
+ });
- export async function setupGroupWebsocketCase(request, event) {
- try {
-
- checkNewMessages();
- checkThreads();
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "sendChatDirect",
- payload: true,
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- } catch (error) {
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "sendChatDirect",
- error: error?.message,
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- }
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'sendChatDirect',
+ payload: response,
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
+ } catch (error) {
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'sendChatDirect',
+ error: error?.message,
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
}
+}
- export async function createRewardShareCase(request, event) {
- try {
- const {recipientPublicKey} = request.payload;
- const resKeyPair = await getKeyPair();
- const parsedData = resKeyPair;
- const uint8PrivateKey = Base58.decode(parsedData.privateKey);
- const uint8PublicKey = Base58.decode(parsedData.publicKey);
- const keyPair = {
- privateKey: uint8PrivateKey,
- publicKey: uint8PublicKey,
- };
- let lastRef = await getLastRef();
-
- const tx = await createTransaction(38, keyPair, {
- recipientPublicKey,
- percentageShare: 0,
- lastReference: lastRef,
- });
-
- const signedBytes = Base58.encode(tx.signedBytes);
-
- const res = await processTransactionVersion2(signedBytes);
- if (!res?.signature)
- throw new Error("Transaction was not able to be processed");
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "createRewardShare",
- payload: res,
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- } catch (error) {
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "createRewardShare",
- error: error?.message,
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- }
+export async function setupGroupWebsocketCase(request, event) {
+ try {
+ checkNewMessages();
+ checkThreads();
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'sendChatDirect',
+ payload: true,
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
+ } catch (error) {
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'sendChatDirect',
+ error: error?.message,
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
}
+}
- export async function removeRewardShareCase(request, event) {
- try {
- const {rewardShareKeyPairPublicKey, recipient, percentageShare} = request.payload;
- const resKeyPair = await getKeyPair();
- const parsedData = resKeyPair;
- const uint8PrivateKey = Base58.decode(parsedData.privateKey);
- const uint8PublicKey = Base58.decode(parsedData.publicKey);
- const keyPair = {
- privateKey: uint8PrivateKey,
- publicKey: uint8PublicKey,
- };
- let lastRef = await getLastRef();
-
- const tx = await createTransaction(381, keyPair, {
- rewardShareKeyPairPublicKey,
- recipient,
- percentageShare,
- lastReference: lastRef,
- });
+export async function createRewardShareCase(request, event) {
+ try {
+ const { recipientPublicKey } = request.payload;
+ const resKeyPair = await getKeyPair();
+ const parsedData = resKeyPair;
+ const uint8PrivateKey = Base58.decode(parsedData.privateKey);
+ const uint8PublicKey = Base58.decode(parsedData.publicKey);
+ const keyPair = {
+ privateKey: uint8PrivateKey,
+ publicKey: uint8PublicKey,
+ };
+ let lastRef = await getLastRef();
- const signedBytes = Base58.encode(tx.signedBytes);
-
- const res = await processTransactionVersion2(signedBytes);
- if (!res?.signature)
- throw new Error("Transaction was not able to be processed");
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "removeRewardShare",
- payload: res,
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- } catch (error) {
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "removeRewardShare",
- error: error?.message,
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- }
+ const tx = await createTransaction(38, keyPair, {
+ recipientPublicKey,
+ percentageShare: 0,
+ lastReference: lastRef,
+ });
+
+ const signedBytes = Base58.encode(tx.signedBytes);
+
+ const res = await processTransactionVersion2(signedBytes);
+ if (!res?.signature)
+ throw new Error('Transaction was not able to be processed');
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'createRewardShare',
+ payload: res,
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
+ } catch (error) {
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'createRewardShare',
+ error: error?.message,
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
}
+}
- export async function getRewardSharePrivateKeyCase(request, event) {
- try {
- const {recipientPublicKey} = request.payload;
- const resKeyPair = await getKeyPair();
- const parsedData = resKeyPair;
- const uint8PrivateKey = Base58.decode(parsedData.privateKey);
- const uint8PublicKey = Base58.decode(parsedData.publicKey);
- const keyPair = {
- privateKey: uint8PrivateKey,
- publicKey: uint8PublicKey,
- };
- let lastRef = await getLastRef();
-
- const tx = await createTransaction(38, keyPair, {
- recipientPublicKey,
- percentageShare: 0,
- lastReference: lastRef,
- });
+export async function removeRewardShareCase(request, event) {
+ try {
+ const { rewardShareKeyPairPublicKey, recipient, percentageShare } =
+ request.payload;
+ const resKeyPair = await getKeyPair();
+ const parsedData = resKeyPair;
+ const uint8PrivateKey = Base58.decode(parsedData.privateKey);
+ const uint8PublicKey = Base58.decode(parsedData.publicKey);
+ const keyPair = {
+ privateKey: uint8PrivateKey,
+ publicKey: uint8PublicKey,
+ };
+ let lastRef = await getLastRef();
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "getRewardSharePrivateKey",
- payload: tx?._base58RewardShareSeed,
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- } catch (error) {
- event.source.postMessage(
- {
- requestId: request.requestId,
- action: "getRewardSharePrivateKey",
- error: error?.message,
- type: "backgroundMessageResponse",
- },
- event.origin
- );
- }
+ const tx = await createTransaction(381, keyPair, {
+ rewardShareKeyPairPublicKey,
+ recipient,
+ percentageShare,
+ lastReference: lastRef,
+ });
+
+ const signedBytes = Base58.encode(tx.signedBytes);
+
+ const res = await processTransactionVersion2(signedBytes);
+ if (!res?.signature)
+ throw new Error('Transaction was not able to be processed');
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'removeRewardShare',
+ payload: res,
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
+ } catch (error) {
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'removeRewardShare',
+ error: error?.message,
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
}
+}
-
\ No newline at end of file
+export async function getRewardSharePrivateKeyCase(request, event) {
+ try {
+ const { recipientPublicKey } = request.payload;
+ const resKeyPair = await getKeyPair();
+ const parsedData = resKeyPair;
+ const uint8PrivateKey = Base58.decode(parsedData.privateKey);
+ const uint8PublicKey = Base58.decode(parsedData.publicKey);
+ const keyPair = {
+ privateKey: uint8PrivateKey,
+ publicKey: uint8PublicKey,
+ };
+ let lastRef = await getLastRef();
+
+ const tx = await createTransaction(38, keyPair, {
+ recipientPublicKey,
+ percentageShare: 0,
+ lastReference: lastRef,
+ });
+
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'getRewardSharePrivateKey',
+ payload: tx?._base58RewardShareSeed,
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
+ } catch (error) {
+ event.source.postMessage(
+ {
+ requestId: request.requestId,
+ action: 'getRewardSharePrivateKey',
+ error: error?.message,
+ type: 'backgroundMessageResponse',
+ },
+ event.origin
+ );
+ }
+}
diff --git a/src/constants/constants.ts b/src/constants/constants.ts
index 5b5e427..ee96c68 100644
--- a/src/constants/constants.ts
+++ b/src/constants/constants.ts
@@ -1,175 +1,186 @@
-
-
// Qortal TX types
const TX_TYPES = {
- 1: "Genesis",
- 2: "Payment",
- 3: "Name registration",
- 4: "Name update",
- 5: "Sell name",
- 6: "Cancel sell name",
- 7: "Buy name",
- 8: "Create poll",
- 9: "Vote in poll",
- 10: "Arbitrary",
- 11: "Issue asset",
- 12: "Transfer asset",
- 13: "Create asset order",
- 14: "Cancel asset order",
- 15: "Multi-payment transaction",
- 16: "Deploy AT",
- 17: "Message",
- 18: "Chat",
- 19: "Publicize",
- 20: "Airdrop",
- 21: "AT",
- 22: "Create group",
- 23: "Update group",
- 24: "Add group admin",
- 25: "Remove group admin",
- 26: "Group ban",
- 27: "Cancel group ban",
- 28: "Group kick",
- 29: "Group invite",
- 30: "Cancel group invite",
- 31: "Join group",
- 32: "Leave group",
- 33: "Group approval",
- 34: "Set group",
- 35: "Update asset",
- 36: "Account flags",
- 37: "Enable forging",
- 38: "Reward share",
- 39: "Account level",
- 40: "Transfer privs",
- 41: "Presence"
-}
+ 1: 'Genesis',
+ 2: 'Payment',
+ 3: 'Name registration',
+ 4: 'Name update',
+ 5: 'Sell name',
+ 6: 'Cancel sell name',
+ 7: 'Buy name',
+ 8: 'Create poll',
+ 9: 'Vote in poll',
+ 10: 'Arbitrary',
+ 11: 'Issue asset',
+ 12: 'Transfer asset',
+ 13: 'Create asset order',
+ 14: 'Cancel asset order',
+ 15: 'Multi-payment transaction',
+ 16: 'Deploy AT',
+ 17: 'Message',
+ 18: 'Chat',
+ 19: 'Publicize',
+ 20: 'Airdrop',
+ 21: 'AT',
+ 22: 'Create group',
+ 23: 'Update group',
+ 24: 'Add group admin',
+ 25: 'Remove group admin',
+ 26: 'Group ban',
+ 27: 'Cancel group ban',
+ 28: 'Group kick',
+ 29: 'Group invite',
+ 30: 'Cancel group invite',
+ 31: 'Join group',
+ 32: 'Leave group',
+ 33: 'Group approval',
+ 34: 'Set group',
+ 35: 'Update asset',
+ 36: 'Account flags',
+ 37: 'Enable forging',
+ 38: 'Reward share',
+ 39: 'Account level',
+ 40: 'Transfer privs',
+ 41: 'Presence',
+};
// Qortal error codes
const ERROR_CODES = {
- 1: "Valid OK",
- 2: "Invalid address",
- 3: "Negative amount",
- 4: "Nagative fee",
- 5: "No balance",
- 6: "Invalid reference",
- 7: "Invalid time length",
- 8: "Invalid value length",
- 9: "Name already registered",
- 10: "Name does not exist",
- 11: "Invalid name owner",
- 12: "Name already for sale",
- 13: "Name not for sale",
- 14: "Name buyer already owner",
- 15: "Invalid amount",
- 16: "Invalid seller",
- 17: "Name not lowercase",
- 18: "Invalid description length",
- 19: "Invalid options length",
- 20: "Invalid option length",
- 21: "Duplicate option",
- 22: "Poll already created",
- 23: "Poll already has votes",
- 24: "Poll does not exist",
- 25: "Option does not exist",
- 26: "Already voted for that option",
- 27: "Invalid data length",
- 28: "Invalid quantity",
- 29: "Asset does not exist",
- 30: "Invalid return",
- 31: "Have equals want",
- 32: "Order does not exist",
- 33: "Invalid order creator",
- 34: "Invalid payments length",
- 35: "Negative price",
- 36: "Invalid creation bytes",
- 37: "Invalid tags length",
- 38: "Invalid type length",
- 39: "Invalid AT transaction",
- 40: "Insufficient fee",
- 41: "Asset does not match AT",
+ 1: 'Valid OK',
+ 2: 'Invalid address',
+ 3: 'Negative amount',
+ 4: 'Nagative fee',
+ 5: 'No balance',
+ 6: 'Invalid reference',
+ 7: 'Invalid time length',
+ 8: 'Invalid value length',
+ 9: 'Name already registered',
+ 10: 'Name does not exist',
+ 11: 'Invalid name owner',
+ 12: 'Name already for sale',
+ 13: 'Name not for sale',
+ 14: 'Name buyer already owner',
+ 15: 'Invalid amount',
+ 16: 'Invalid seller',
+ 17: 'Name not lowercase',
+ 18: 'Invalid description length',
+ 19: 'Invalid options length',
+ 20: 'Invalid option length',
+ 21: 'Duplicate option',
+ 22: 'Poll already created',
+ 23: 'Poll already has votes',
+ 24: 'Poll does not exist',
+ 25: 'Option does not exist',
+ 26: 'Already voted for that option',
+ 27: 'Invalid data length',
+ 28: 'Invalid quantity',
+ 29: 'Asset does not exist',
+ 30: 'Invalid return',
+ 31: 'Have equals want',
+ 32: 'Order does not exist',
+ 33: 'Invalid order creator',
+ 34: 'Invalid payments length',
+ 35: 'Negative price',
+ 36: 'Invalid creation bytes',
+ 37: 'Invalid tags length',
+ 38: 'Invalid type length',
+ 39: 'Invalid AT transaction',
+ 40: 'Insufficient fee',
+ 41: 'Asset does not match AT',
- 43: "Asset already exists",
- 44: "Missing creator",
- 45: "Timestamp too old",
- 46: "Timestamp too new",
- 47: "Too many unconfirmed",
- 48: "Group already exists",
- 49: "Group does not exist",
- 50: "Invalid group owner",
- 51: "Already group memeber",
- 52: "Group owner can not leave",
- 53: "Not group member",
- 54: "Already group admin",
- 55: "Not group admin",
- 56: "Invalid lifetime",
- 57: "Invite unknown",
- 58: "Ban exists",
- 59: "Ban unknown",
- 60: "Banned from group",
- 61: "Join request",
- 62: "Invalid group approval threshold",
- 63: "Group ID mismatch",
- 64: "Invalid group ID",
- 65: "Transaction unknown",
- 66: "Transaction already confirmed",
- 67: "Invalid TX group",
- 68: "TX group ID mismatch",
- 69: "Multiple names forbidden",
- 70: "Invalid asset owner",
- 71: "AT is finished",
- 72: "No flag permission",
- 73: "Not minting accout",
+ 43: 'Asset already exists',
+ 44: 'Missing creator',
+ 45: 'Timestamp too old',
+ 46: 'Timestamp too new',
+ 47: 'Too many unconfirmed',
+ 48: 'Group already exists',
+ 49: 'Group does not exist',
+ 50: 'Invalid group owner',
+ 51: 'Already group memeber',
+ 52: 'Group owner can not leave',
+ 53: 'Not group member',
+ 54: 'Already group admin',
+ 55: 'Not group admin',
+ 56: 'Invalid lifetime',
+ 57: 'Invite unknown',
+ 58: 'Ban exists',
+ 59: 'Ban unknown',
+ 60: 'Banned from group',
+ 61: 'Join request',
+ 62: 'Invalid group approval threshold',
+ 63: 'Group ID mismatch',
+ 64: 'Invalid group ID',
+ 65: 'Transaction unknown',
+ 66: 'Transaction already confirmed',
+ 67: 'Invalid TX group',
+ 68: 'TX group ID mismatch',
+ 69: 'Multiple names forbidden',
+ 70: 'Invalid asset owner',
+ 71: 'AT is finished',
+ 72: 'No flag permission',
+ 73: 'Not minting accout',
- 77: "Invalid rewardshare percent",
- 78: "Public key unknown",
- 79: "Invalid public key",
- 80: "AT unknown",
- 81: "AT already exists",
- 82: "Group approval not required",
- 83: "Group approval decided",
- 84: "Maximum reward shares",
- 85: "Transaction already exists",
- 86: "No blockchain lock",
- 87: "Order already closed",
- 88: "Clock not synced",
- 89: "Asset not spendable",
- 90: "Account can not reward share",
- 91: "Self share exists",
- 92: "Account already exists",
- 93: "Invalid group block delay",
- 94: "Incorrect nonce",
- 95: "Ivalid timestamp signature",
- 96: "Address blocked",
- 97: "Name Blocked",
- 98: "Group approval required",
- 99: "Account not transferable",
+ 77: 'Invalid rewardshare percent',
+ 78: 'Public key unknown',
+ 79: 'Invalid public key',
+ 80: 'AT unknown',
+ 81: 'AT already exists',
+ 82: 'Group approval not required',
+ 83: 'Group approval decided',
+ 84: 'Maximum reward shares',
+ 85: 'Transaction already exists',
+ 86: 'No blockchain lock',
+ 87: 'Order already closed',
+ 88: 'Clock not synced',
+ 89: 'Asset not spendable',
+ 90: 'Account can not reward share',
+ 91: 'Self share exists',
+ 92: 'Account already exists',
+ 93: 'Invalid group block delay',
+ 94: 'Incorrect nonce',
+ 95: 'Ivalid timestamp signature',
+ 96: 'Address blocked',
+ 97: 'Name Blocked',
+ 98: 'Group approval required',
+ 99: 'Account not transferable',
- 999: "Ivalid but ok",
- 1000: "Not yet released."
-}
+ 999: 'Ivalid but ok',
+ 1000: 'Not yet released.',
+};
// Qortal 8 decimals
-const QORT_DECIMALS = 1e8
+const QORT_DECIMALS = 1e8;
// Q for Qortal
-const ADDRESS_VERSION = 58
+const ADDRESS_VERSION = 58;
// Proxy for api calls
-const PROXY_URL = "/proxy/"
+const PROXY_URL = '/proxy/';
// Chat reference timestamp
-const CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP = 1674316800000
+const CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP = 1674316800000;
// Dynamic fee timestamp
-const DYNAMIC_FEE_TIMESTAMP = 1692118800000
-
+const DYNAMIC_FEE_TIMESTAMP = 1692118800000;
// Used as a salt for all Qora addresses. Salts used for storing your private keys in local storage will be randomly generated
-const STATIC_SALT = new Uint8Array([54, 190, 201, 206, 65, 29, 123, 129, 147, 231, 180, 166, 171, 45, 95, 165, 78, 200, 208, 194, 44, 207, 221, 146, 45, 238, 68, 68, 69, 102, 62, 6])
-const BCRYPT_ROUNDS = 10 // Remember that the total work spent on key derivation is BCRYPT_ROUNDS * KDF_THREADS
-const BCRYPT_VERSION = "2a"
-const STATIC_BCRYPT_SALT = `$${BCRYPT_VERSION}$${BCRYPT_ROUNDS}$IxVE941tXVUD4cW0TNVm.O`
-const KDF_THREADS = 16
+const STATIC_SALT = new Uint8Array([
+ 54, 190, 201, 206, 65, 29, 123, 129, 147, 231, 180, 166, 171, 45, 95, 165, 78,
+ 200, 208, 194, 44, 207, 221, 146, 45, 238, 68, 68, 69, 102, 62, 6,
+]);
+const BCRYPT_ROUNDS = 10; // Remember that the total work spent on key derivation is BCRYPT_ROUNDS * KDF_THREADS
+const BCRYPT_VERSION = '2a';
+const STATIC_BCRYPT_SALT = `$${BCRYPT_VERSION}$${BCRYPT_ROUNDS}$IxVE941tXVUD4cW0TNVm.O`;
+const KDF_THREADS = 16;
-export { TX_TYPES, ERROR_CODES, QORT_DECIMALS, PROXY_URL, STATIC_SALT, ADDRESS_VERSION, KDF_THREADS, STATIC_BCRYPT_SALT, CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP, DYNAMIC_FEE_TIMESTAMP }
+export {
+ TX_TYPES,
+ ERROR_CODES,
+ QORT_DECIMALS,
+ PROXY_URL,
+ STATIC_SALT,
+ ADDRESS_VERSION,
+ KDF_THREADS,
+ STATIC_BCRYPT_SALT,
+ CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP,
+ DYNAMIC_FEE_TIMESTAMP,
+};
diff --git a/src/transactions/AddGroupAdminTransaction.ts b/src/transactions/AddGroupAdminTransaction.ts
index f66f730..dd65ec4 100644
--- a/src/transactions/AddGroupAdminTransaction.ts
+++ b/src/transactions/AddGroupAdminTransaction.ts
@@ -1,37 +1,35 @@
// @ts-nocheck
-import { QORT_DECIMALS } from "../constants/constants"
-import TransactionBase from "./TransactionBase"
-
+import { QORT_DECIMALS } from '../constants/constants';
+import TransactionBase from './TransactionBase';
export default class AddGroupAdminTransaction extends TransactionBase {
- constructor() {
- super()
- this.type = 24
- }
+ constructor() {
+ super();
+ this.type = 24;
+ }
- set rGroupId(rGroupId) {
- this._rGroupId = rGroupId
- this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId)
- }
+ set rGroupId(rGroupId) {
+ this._rGroupId = rGroupId;
+ this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId);
+ }
- set recipient(recipient) {
- this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient)
- this.theRecipient = recipient
- }
+ set recipient(recipient) {
+ this._recipient =
+ recipient instanceof Uint8Array
+ ? recipient
+ : this.constructor.Base58.decode(recipient);
+ this.theRecipient = recipient;
+ }
- set fee(fee) {
- this._fee = fee * QORT_DECIMALS
- this._feeBytes = this.constructor.utils.int64ToBytes(this._fee)
- }
+ set fee(fee) {
+ this._fee = fee * QORT_DECIMALS;
+ this._feeBytes = this.constructor.utils.int64ToBytes(this._fee);
+ }
- get params() {
- const params = super.params
- params.push(
- this._rGroupIdBytes,
- this._recipient,
- this._feeBytes
- )
- return params
- }
+ get params() {
+ const params = super.params;
+ params.push(this._rGroupIdBytes, this._recipient, this._feeBytes);
+ return params;
+ }
}
diff --git a/src/transactions/BuyNameTransacion.ts b/src/transactions/BuyNameTransacion.ts
index 8c321d3..0664b1c 100644
--- a/src/transactions/BuyNameTransacion.ts
+++ b/src/transactions/BuyNameTransacion.ts
@@ -1,45 +1,48 @@
// @ts-nocheck
-import { QORT_DECIMALS } from "../constants/constants"
-import TransactionBase from "./TransactionBase"
-
-
+import { QORT_DECIMALS } from '../constants/constants';
+import TransactionBase from './TransactionBase';
export default class BuyNameTransacion extends TransactionBase {
- constructor() {
- super()
- this.type = 7
- }
+ constructor() {
+ super();
+ this.type = 7;
+ }
- set fee(fee) {
- this._fee = fee * QORT_DECIMALS
- this._feeBytes = this.constructor.utils.int64ToBytes(this._fee)
- }
+ set fee(fee) {
+ this._fee = fee * QORT_DECIMALS;
+ this._feeBytes = this.constructor.utils.int64ToBytes(this._fee);
+ }
- set name(name) {
- this.nameText = name
- this._nameBytes = this.constructor.utils.stringtoUTF8Array(name)
- this._nameLength = this.constructor.utils.int32ToBytes(this._nameBytes.length)
- }
+ set name(name) {
+ this.nameText = name;
+ this._nameBytes = this.constructor.utils.stringtoUTF8Array(name);
+ this._nameLength = this.constructor.utils.int32ToBytes(
+ this._nameBytes.length
+ );
+ }
- set sellPrice(sellPrice) {
- this._sellPrice = sellPrice * QORT_DECIMALS
- this._sellPriceBytes = this.constructor.utils.int64ToBytes(this._sellPrice)
- }
+ set sellPrice(sellPrice) {
+ this._sellPrice = sellPrice * QORT_DECIMALS;
+ this._sellPriceBytes = this.constructor.utils.int64ToBytes(this._sellPrice);
+ }
- set recipient(recipient) {
- this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient)
- this.theRecipient = recipient
- }
+ set recipient(recipient) {
+ this._recipient =
+ recipient instanceof Uint8Array
+ ? recipient
+ : this.constructor.Base58.decode(recipient);
+ this.theRecipient = recipient;
+ }
- get params() {
- const params = super.params
- params.push(
- this._nameLength,
- this._nameBytes,
- this._sellPriceBytes,
- this._recipient,
- this._feeBytes
- )
- return params
- }
+ get params() {
+ const params = super.params;
+ params.push(
+ this._nameLength,
+ this._nameBytes,
+ this._sellPriceBytes,
+ this._recipient,
+ this._feeBytes
+ );
+ return params;
+ }
}
diff --git a/src/transactions/CancelGroupBanTransaction.ts b/src/transactions/CancelGroupBanTransaction.ts
index d1bbef7..fc3ca73 100644
--- a/src/transactions/CancelGroupBanTransaction.ts
+++ b/src/transactions/CancelGroupBanTransaction.ts
@@ -1,37 +1,35 @@
// @ts-nocheck
-import { QORT_DECIMALS } from "../constants/constants"
-import TransactionBase from "./TransactionBase"
-
+import { QORT_DECIMALS } from '../constants/constants';
+import TransactionBase from './TransactionBase';
export default class CancelGroupBanTransaction extends TransactionBase {
- constructor() {
- super()
- this.type = 27
- }
+ constructor() {
+ super();
+ this.type = 27;
+ }
- set rGroupId(rGroupId) {
- this._rGroupId = rGroupId
- this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId)
- }
+ set rGroupId(rGroupId) {
+ this._rGroupId = rGroupId;
+ this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId);
+ }
- set recipient(recipient) {
- this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient)
- this.theRecipient = recipient
- }
+ set recipient(recipient) {
+ this._recipient =
+ recipient instanceof Uint8Array
+ ? recipient
+ : this.constructor.Base58.decode(recipient);
+ this.theRecipient = recipient;
+ }
- set fee(fee) {
- this._fee = fee * QORT_DECIMALS
- this._feeBytes = this.constructor.utils.int64ToBytes(this._fee)
- }
+ set fee(fee) {
+ this._fee = fee * QORT_DECIMALS;
+ this._feeBytes = this.constructor.utils.int64ToBytes(this._fee);
+ }
- get params() {
- const params = super.params
- params.push(
- this._rGroupIdBytes,
- this._recipient,
- this._feeBytes
- )
- return params
- }
+ get params() {
+ const params = super.params;
+ params.push(this._rGroupIdBytes, this._recipient, this._feeBytes);
+ return params;
+ }
}
diff --git a/src/transactions/CancelGroupInviteTransaction.ts b/src/transactions/CancelGroupInviteTransaction.ts
index b575f3e..6ece4fd 100644
--- a/src/transactions/CancelGroupInviteTransaction.ts
+++ b/src/transactions/CancelGroupInviteTransaction.ts
@@ -1,36 +1,33 @@
// @ts-nocheck
-import { QORT_DECIMALS } from "../constants/constants"
-import TransactionBase from "./TransactionBase"
-
-
+import { QORT_DECIMALS } from '../constants/constants';
+import TransactionBase from './TransactionBase';
export default class CancelGroupInviteTransaction extends TransactionBase {
- constructor() {
- super()
- this.type = 30
- }
+ constructor() {
+ super();
+ this.type = 30;
+ }
- set rGroupId(rGroupId) {
- this._rGroupId = rGroupId
- this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId)
- }
+ set rGroupId(rGroupId) {
+ this._rGroupId = rGroupId;
+ this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId);
+ }
- set recipient(recipient) {
- this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient)
- this.theRecipient = recipient
- }
+ set recipient(recipient) {
+ this._recipient =
+ recipient instanceof Uint8Array
+ ? recipient
+ : this.constructor.Base58.decode(recipient);
+ this.theRecipient = recipient;
+ }
- set fee(fee) {
- this._fee = fee * QORT_DECIMALS
- this._feeBytes = this.constructor.utils.int64ToBytes(this._fee)
- }
+ set fee(fee) {
+ this._fee = fee * QORT_DECIMALS;
+ this._feeBytes = this.constructor.utils.int64ToBytes(this._fee);
+ }
- get params() {
- const params = super.params
- params.push(
- this._rGroupIdBytes,
- this._recipient,
- this._feeBytes
- )
- return params
- }
+ get params() {
+ const params = super.params;
+ params.push(this._rGroupIdBytes, this._recipient, this._feeBytes);
+ return params;
+ }
}
diff --git a/src/transactions/CancelSellNameTransacion.ts b/src/transactions/CancelSellNameTransacion.ts
index 04296c8..28420f7 100644
--- a/src/transactions/CancelSellNameTransacion.ts
+++ b/src/transactions/CancelSellNameTransacion.ts
@@ -1,33 +1,29 @@
// @ts-nocheck
-import { QORT_DECIMALS } from "../constants/constants"
-import TransactionBase from "./TransactionBase"
-
-
+import { QORT_DECIMALS } from '../constants/constants';
+import TransactionBase from './TransactionBase';
export default class CancelSellNameTransacion extends TransactionBase {
- constructor() {
- super()
- this.type = 6
- }
+ constructor() {
+ super();
+ this.type = 6;
+ }
- set fee(fee) {
- this._fee = fee * QORT_DECIMALS
- this._feeBytes = this.constructor.utils.int64ToBytes(this._fee)
- }
+ set fee(fee) {
+ this._fee = fee * QORT_DECIMALS;
+ this._feeBytes = this.constructor.utils.int64ToBytes(this._fee);
+ }
- set name(name) {
- this.nameText = name
- this._nameBytes = this.constructor.utils.stringtoUTF8Array(name)
- this._nameLength = this.constructor.utils.int32ToBytes(this._nameBytes.length)
- }
+ set name(name) {
+ this.nameText = name;
+ this._nameBytes = this.constructor.utils.stringtoUTF8Array(name);
+ this._nameLength = this.constructor.utils.int32ToBytes(
+ this._nameBytes.length
+ );
+ }
- get params() {
- const params = super.params
- params.push(
- this._nameLength,
- this._nameBytes,
- this._feeBytes
- )
- return params
- }
+ get params() {
+ const params = super.params;
+ params.push(this._nameLength, this._nameBytes, this._feeBytes);
+ return params;
+ }
}
diff --git a/src/transactions/ChatBase.ts b/src/transactions/ChatBase.ts
index cdfacaf..c88d634 100644
--- a/src/transactions/ChatBase.ts
+++ b/src/transactions/ChatBase.ts
@@ -1,148 +1,161 @@
// @ts-nocheck
-import { QORT_DECIMALS, TX_TYPES } from '../constants/constants'
-import nacl from '../deps/nacl-fast'
-import Base58 from '../deps/Base58'
-import utils from '../utils/utils'
-
+import { QORT_DECIMALS, TX_TYPES } from '../constants/constants';
+import nacl from '../deps/nacl-fast';
+import Base58 from '../deps/Base58';
+import utils from '../utils/utils';
export default class ChatBase {
- static get utils() {
- return utils
- }
+ static get utils() {
+ return utils;
+ }
- static get nacl() {
- return nacl
- }
+ static get nacl() {
+ return nacl;
+ }
- static get Base58() {
- return Base58
- }
+ static get Base58() {
+ return Base58;
+ }
- constructor() {
-
- this.fee = 0
- this.groupID = 0
- this.tests = [
- () => {
- if (!(this._type >= 1 && this._type in TX_TYPES)) {
- return 'Invalid type: ' + this.type
- }
- return true
- },
- () => {
- if (this._fee < 0) {
- return 'Invalid fee: ' + this._fee / QORT_DECIMALS
- }
- return true
- },
- () => {
- if (this._groupID < 0 || !Number.isInteger(this._groupID)) {
- return 'Invalid groupID: ' + this._groupID
- }
- return true
- },
- () => {
- if (!(new Date(this._timestamp)).getTime() > 0) {
- return 'Invalid timestamp: ' + this._timestamp
- }
- return true
- },
- () => {
-
- if (!(this._lastReference instanceof Uint8Array && this._lastReference.byteLength == 64)) {
- return 'Invalid last reference: ' + this._lastReference
- }
- return true
- },
- () => {
- if (!(this._keyPair)) {
- return 'keyPair must be specified'
- }
- if (!(this._keyPair.publicKey instanceof Uint8Array && this._keyPair.publicKey.byteLength === 32)) {
- return 'Invalid publicKey'
- }
- if (!(this._keyPair.privateKey instanceof Uint8Array && this._keyPair.privateKey.byteLength === 64)) {
- return 'Invalid privateKey'
- }
- return true
- }
- ]
- }
+ constructor() {
+ this.fee = 0;
+ this.groupID = 0;
+ this.tests = [
+ () => {
+ if (!(this._type >= 1 && this._type in TX_TYPES)) {
+ return 'Invalid type: ' + this.type;
+ }
+ return true;
+ },
+ () => {
+ if (this._fee < 0) {
+ return 'Invalid fee: ' + this._fee / QORT_DECIMALS;
+ }
+ return true;
+ },
+ () => {
+ if (this._groupID < 0 || !Number.isInteger(this._groupID)) {
+ return 'Invalid groupID: ' + this._groupID;
+ }
+ return true;
+ },
+ () => {
+ if (!new Date(this._timestamp).getTime() > 0) {
+ return 'Invalid timestamp: ' + this._timestamp;
+ }
+ return true;
+ },
+ () => {
+ if (
+ !(
+ this._lastReference instanceof Uint8Array &&
+ this._lastReference.byteLength == 64
+ )
+ ) {
+ return 'Invalid last reference: ' + this._lastReference;
+ }
+ return true;
+ },
+ () => {
+ if (!this._keyPair) {
+ return 'keyPair must be specified';
+ }
+ if (
+ !(
+ this._keyPair.publicKey instanceof Uint8Array &&
+ this._keyPair.publicKey.byteLength === 32
+ )
+ ) {
+ return 'Invalid publicKey';
+ }
+ if (
+ !(
+ this._keyPair.privateKey instanceof Uint8Array &&
+ this._keyPair.privateKey.byteLength === 64
+ )
+ ) {
+ return 'Invalid privateKey';
+ }
+ return true;
+ },
+ ];
+ }
- set keyPair(keyPair) {
- this._keyPair = keyPair
- }
+ set keyPair(keyPair) {
+ this._keyPair = keyPair;
+ }
- set type(type) {
- this.typeText = TX_TYPES[type]
- this._type = type
- this._typeBytes = this.constructor.utils.int32ToBytes(this._type)
- }
+ set type(type) {
+ this.typeText = TX_TYPES[type];
+ this._type = type;
+ this._typeBytes = this.constructor.utils.int32ToBytes(this._type);
+ }
- set groupID(groupID) {
- this._groupID = groupID
- this._groupIDBytes = this.constructor.utils.int32ToBytes(this._groupID)
- }
+ set groupID(groupID) {
+ this._groupID = groupID;
+ this._groupIDBytes = this.constructor.utils.int32ToBytes(this._groupID);
+ }
- set timestamp(timestamp) {
- this._timestamp = timestamp
- this._timestampBytes = this.constructor.utils.int64ToBytes(this._timestamp)
- }
+ set timestamp(timestamp) {
+ this._timestamp = timestamp;
+ this._timestampBytes = this.constructor.utils.int64ToBytes(this._timestamp);
+ }
- set fee(fee) {
- this._fee = fee * QORT_DECIMALS
- this._feeBytes = this.constructor.utils.int64ToBytes(this._fee)
- }
+ set fee(fee) {
+ this._fee = fee * QORT_DECIMALS;
+ this._feeBytes = this.constructor.utils.int64ToBytes(this._fee);
+ }
- set lastReference(lastReference) {
+ set lastReference(lastReference) {
+ this._lastReference =
+ lastReference instanceof Uint8Array
+ ? lastReference
+ : this.constructor.Base58.decode(lastReference);
+ }
- this._lastReference = lastReference instanceof Uint8Array ? lastReference : this.constructor.Base58.decode(lastReference)
- }
+ get params() {
+ return [
+ this._typeBytes,
+ this._timestampBytes,
+ this._groupIDBytes,
+ this._lastReference,
+ this._keyPair.publicKey,
+ ];
+ }
- get params() {
- return [
- this._typeBytes,
- this._timestampBytes,
- this._groupIDBytes,
- this._lastReference,
- this._keyPair.publicKey
- ]
- }
+ get chatBytes() {
+ const isValid = this.validParams();
+ if (!isValid.valid) {
+ throw new Error(isValid.message);
+ }
- get chatBytes() {
- const isValid = this.validParams()
- if (!isValid.valid) {
- throw new Error(isValid.message)
- }
+ let result = new Uint8Array();
- let result = new Uint8Array()
+ this.params.forEach((item) => {
+ result = this.constructor.utils.appendBuffer(result, item);
+ });
- this.params.forEach(item => {
- result = this.constructor.utils.appendBuffer(result, item)
- })
+ this._chatBytes = result;
- this._chatBytes = result
+ return this._chatBytes;
+ }
- return this._chatBytes
- }
+ validParams() {
+ let finalResult = {
+ valid: true,
+ };
- validParams() {
- let finalResult = {
- valid: true
- }
-
- this.tests.some(test => {
- const result = test()
- if (result !== true) {
- finalResult = {
- valid: false,
- message: result
- }
- return true
- }
- })
-
- return finalResult
- }
+ this.tests.some((test) => {
+ const result = test();
+ if (result !== true) {
+ finalResult = {
+ valid: false,
+ message: result,
+ };
+ return true;
+ }
+ });
+ return finalResult;
+ }
}
diff --git a/src/transactions/ChatTransaction.ts b/src/transactions/ChatTransaction.ts
index ec30c8c..fc67531 100644
--- a/src/transactions/ChatTransaction.ts
+++ b/src/transactions/ChatTransaction.ts
@@ -1,92 +1,126 @@
// @ts-nocheck
-import ChatBase from './ChatBase'
-import nacl from '../deps/nacl-fast'
-import ed2curve from '../deps/ed2curve'
-import { Sha256 } from 'asmcrypto.js'
-import { CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP } from '../constants/constants'
-
+import ChatBase from './ChatBase';
+import nacl from '../deps/nacl-fast';
+import ed2curve from '../deps/ed2curve';
+import { Sha256 } from 'asmcrypto.js';
+import { CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP } from '../constants/constants';
export default class ChatTransaction extends ChatBase {
- constructor() {
- super()
- this.type = 18
- this.fee = 0
- }
+ constructor() {
+ super();
+ this.type = 18;
+ this.fee = 0;
+ }
- set recipientPublicKey(recipientPublicKey) {
- this._base58RecipientPublicKey = recipientPublicKey instanceof Uint8Array ? this.constructor.Base58.encode(recipientPublicKey) : recipientPublicKey
- this._recipientPublicKey = this.constructor.Base58.decode(this._base58RecipientPublicKey)
- }
+ set recipientPublicKey(recipientPublicKey) {
+ this._base58RecipientPublicKey =
+ recipientPublicKey instanceof Uint8Array
+ ? this.constructor.Base58.encode(recipientPublicKey)
+ : recipientPublicKey;
+ this._recipientPublicKey = this.constructor.Base58.decode(
+ this._base58RecipientPublicKey
+ );
+ }
- set proofOfWorkNonce(proofOfWorkNonce) {
- this._proofOfWorkNonce = this.constructor.utils.int32ToBytes(proofOfWorkNonce)
- }
+ set proofOfWorkNonce(proofOfWorkNonce) {
+ this._proofOfWorkNonce =
+ this.constructor.utils.int32ToBytes(proofOfWorkNonce);
+ }
- set recipient(recipient) {
- this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient)
- this._hasReceipient = new Uint8Array(1)
- this._hasReceipient[0] = 1
- }
+ set recipient(recipient) {
+ this._recipient =
+ recipient instanceof Uint8Array
+ ? recipient
+ : this.constructor.Base58.decode(recipient);
+ this._hasReceipient = new Uint8Array(1);
+ this._hasReceipient[0] = 1;
+ }
- set hasChatReference(hasChatReference) {
- this._hasChatReference = new Uint8Array(1)
- this._hasChatReference[0] = hasChatReference
- }
+ set hasChatReference(hasChatReference) {
+ this._hasChatReference = new Uint8Array(1);
+ this._hasChatReference[0] = hasChatReference;
+ }
- set chatReference(chatReference) {
- this._chatReference = chatReference instanceof Uint8Array ? chatReference : this.constructor.Base58.decode(chatReference)
- }
+ set chatReference(chatReference) {
+ this._chatReference =
+ chatReference instanceof Uint8Array
+ ? chatReference
+ : this.constructor.Base58.decode(chatReference);
+ }
- set message(message) {
- this.messageText = message;
- this._message = this.constructor.utils.stringtoUTF8Array(message)
- this._messageLength = this.constructor.utils.int32ToBytes(this._message.length)
- }
+ set message(message) {
+ this.messageText = message;
+ this._message = this.constructor.utils.stringtoUTF8Array(message);
+ this._messageLength = this.constructor.utils.int32ToBytes(
+ this._message.length
+ );
+ }
- set isEncrypted(isEncrypted) {
- this._isEncrypted = new Uint8Array(1)
- this._isEncrypted[0] = isEncrypted
+ set isEncrypted(isEncrypted) {
+ this._isEncrypted = new Uint8Array(1);
+ this._isEncrypted[0] = isEncrypted;
- if (isEncrypted === 1) {
- const convertedPrivateKey = ed2curve.convertSecretKey(this._keyPair.privateKey)
- const convertedPublicKey = ed2curve.convertPublicKey(this._recipientPublicKey)
- const sharedSecret = new Uint8Array(32)
- nacl.lowlevel.crypto_scalarmult(sharedSecret, convertedPrivateKey, convertedPublicKey)
+ if (isEncrypted === 1) {
+ const convertedPrivateKey = ed2curve.convertSecretKey(
+ this._keyPair.privateKey
+ );
+ const convertedPublicKey = ed2curve.convertPublicKey(
+ this._recipientPublicKey
+ );
+ const sharedSecret = new Uint8Array(32);
+ nacl.lowlevel.crypto_scalarmult(
+ sharedSecret,
+ convertedPrivateKey,
+ convertedPublicKey
+ );
- this._chatEncryptionSeed = new Sha256().process(sharedSecret).finish().result
- this._encryptedMessage = nacl.secretbox(this._message, this._lastReference.slice(0, 24), this._chatEncryptionSeed)
- }
+ this._chatEncryptionSeed = new Sha256()
+ .process(sharedSecret)
+ .finish().result;
+ this._encryptedMessage = nacl.secretbox(
+ this._message,
+ this._lastReference.slice(0, 24),
+ this._chatEncryptionSeed
+ );
+ }
- this._myMessage = isEncrypted === 1 ? this._encryptedMessage : this._message
- this._myMessageLenth = isEncrypted === 1 ? this.constructor.utils.int32ToBytes(this._myMessage.length) : this._messageLength
- }
+ this._myMessage =
+ isEncrypted === 1 ? this._encryptedMessage : this._message;
+ this._myMessageLenth =
+ isEncrypted === 1
+ ? this.constructor.utils.int32ToBytes(this._myMessage.length)
+ : this._messageLength;
+ }
- set isText(isText) {
- this._isText = new Uint8Array(1)
- this._isText[0] = isText
- }
+ set isText(isText) {
+ this._isText = new Uint8Array(1);
+ this._isText[0] = isText;
+ }
- get params() {
- const params = super.params
- params.push(
- this._proofOfWorkNonce,
- this._hasReceipient,
- this._recipient,
- this._myMessageLenth,
- this._myMessage,
- this._isEncrypted,
- this._isText,
- this._feeBytes
- )
+ get params() {
+ const params = super.params;
+ params.push(
+ this._proofOfWorkNonce,
+ this._hasReceipient,
+ this._recipient,
+ this._myMessageLenth,
+ this._myMessage,
+ this._isEncrypted,
+ this._isText,
+ this._feeBytes
+ );
- // After the feature trigger timestamp we need to include chat reference
- if (new Date(this._timestamp).getTime() >= CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP) {
- params.push(this._hasChatReference)
+ // After the feature trigger timestamp we need to include chat reference
+ if (
+ new Date(this._timestamp).getTime() >=
+ CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP
+ ) {
+ params.push(this._hasChatReference);
- if (this._hasChatReference[0] == 1) {
- params.push(this._chatReference)
- }
- }
- return params
- }
+ if (this._hasChatReference[0] == 1) {
+ params.push(this._chatReference);
+ }
+ }
+ return params;
+ }
}
diff --git a/src/transactions/CreateGroupTransaction.ts b/src/transactions/CreateGroupTransaction.ts
index a2eb7ea..24aff1e 100644
--- a/src/transactions/CreateGroupTransaction.ts
+++ b/src/transactions/CreateGroupTransaction.ts
@@ -1,64 +1,73 @@
// @ts-nocheck
-import { QORT_DECIMALS } from "../constants/constants"
-import TransactionBase from "./TransactionBase"
-
-
+import { QORT_DECIMALS } from '../constants/constants';
+import TransactionBase from './TransactionBase';
export default class CreateGroupTransaction extends TransactionBase {
- constructor() {
- super()
- this.type = 22
- }
+ constructor() {
+ super();
+ this.type = 22;
+ }
+ set fee(fee) {
+ this._fee = fee * QORT_DECIMALS;
+ this._feeBytes = this.constructor.utils.int64ToBytes(this._fee);
+ }
- set fee(fee) {
- this._fee = fee * QORT_DECIMALS
- this._feeBytes = this.constructor.utils.int64ToBytes(this._fee)
- }
+ set rGroupName(rGroupName) {
+ this._rGroupName = rGroupName;
+ this._rGroupNameBytes = this.constructor.utils.stringtoUTF8Array(
+ this._rGroupName
+ );
+ this._rGroupNameLength = this.constructor.utils.int32ToBytes(
+ this._rGroupNameBytes.length
+ );
+ }
- set rGroupName(rGroupName) {
- this._rGroupName = rGroupName
- this._rGroupNameBytes = this.constructor.utils.stringtoUTF8Array(this._rGroupName)
- this._rGroupNameLength = this.constructor.utils.int32ToBytes(this._rGroupNameBytes.length)
- }
+ set rGroupDesc(rGroupDesc) {
+ this._rGroupDesc = rGroupDesc;
+ this._rGroupDescBytes = this.constructor.utils.stringtoUTF8Array(
+ this._rGroupDesc
+ );
+ this._rGroupDescLength = this.constructor.utils.int32ToBytes(
+ this._rGroupDescBytes.length
+ );
+ }
- set rGroupDesc(rGroupDesc) {
- this._rGroupDesc = rGroupDesc
- this._rGroupDescBytes = this.constructor.utils.stringtoUTF8Array(this._rGroupDesc)
- this._rGroupDescLength = this.constructor.utils.int32ToBytes(this._rGroupDescBytes.length)
- }
+ set rGroupType(rGroupType) {
+ this._rGroupType = new Uint8Array(1);
+ this._rGroupType[0] = rGroupType;
+ }
- set rGroupType(rGroupType) {
- this._rGroupType = new Uint8Array(1)
- this._rGroupType[0] = rGroupType
- }
+ set rGroupApprovalThreshold(rGroupApprovalThreshold) {
+ this._rGroupApprovalThreshold = new Uint8Array(1);
+ this._rGroupApprovalThreshold[0] = rGroupApprovalThreshold;
+ }
- set rGroupApprovalThreshold(rGroupApprovalThreshold) {
- this._rGroupApprovalThreshold = new Uint8Array(1)
- this._rGroupApprovalThreshold[0] = rGroupApprovalThreshold
- }
+ set rGroupMinimumBlockDelay(rGroupMinimumBlockDelay) {
+ this._rGroupMinimumBlockDelayBytes = this.constructor.utils.int32ToBytes(
+ rGroupMinimumBlockDelay
+ );
+ }
- set rGroupMinimumBlockDelay(rGroupMinimumBlockDelay) {
- this._rGroupMinimumBlockDelayBytes = this.constructor.utils.int32ToBytes(rGroupMinimumBlockDelay)
- }
+ set rGroupMaximumBlockDelay(rGroupMaximumBlockDelay) {
+ this._rGroupMaximumBlockDelayBytes = this.constructor.utils.int32ToBytes(
+ rGroupMaximumBlockDelay
+ );
+ }
- set rGroupMaximumBlockDelay(rGroupMaximumBlockDelay) {
- this._rGroupMaximumBlockDelayBytes = this.constructor.utils.int32ToBytes(rGroupMaximumBlockDelay)
- }
-
- get params() {
- const params = super.params
- params.push(
- this._rGroupNameLength,
- this._rGroupNameBytes,
- this._rGroupDescLength,
- this._rGroupDescBytes,
- this._rGroupType,
- this._rGroupApprovalThreshold,
- this._rGroupMinimumBlockDelayBytes,
- this._rGroupMaximumBlockDelayBytes,
- this._feeBytes
- )
- return params
- }
+ get params() {
+ const params = super.params;
+ params.push(
+ this._rGroupNameLength,
+ this._rGroupNameBytes,
+ this._rGroupDescLength,
+ this._rGroupDescBytes,
+ this._rGroupType,
+ this._rGroupApprovalThreshold,
+ this._rGroupMinimumBlockDelayBytes,
+ this._rGroupMaximumBlockDelayBytes,
+ this._feeBytes
+ );
+ return params;
+ }
}
diff --git a/src/transactions/CreatePollTransaction.ts b/src/transactions/CreatePollTransaction.ts
index a2a9cc0..3717ba9 100644
--- a/src/transactions/CreatePollTransaction.ts
+++ b/src/transactions/CreatePollTransaction.ts
@@ -1,73 +1,84 @@
// @ts-nocheck
-import { QORT_DECIMALS } from '../constants/constants'
-import TransactionBase from './TransactionBase'
-
+import { QORT_DECIMALS } from '../constants/constants';
+import TransactionBase from './TransactionBase';
export default class CreatePollTransaction extends TransactionBase {
- constructor() {
- super()
- this.type = 8
- this._options = []
- }
+ constructor() {
+ super();
+ this.type = 8;
+ this._options = [];
+ }
- addOption(option) {
- const optionBytes = this.constructor.utils.stringtoUTF8Array(option)
- const optionLength = this.constructor.utils.int32ToBytes(optionBytes.length)
- this._options.push({ length: optionLength, bytes: optionBytes })
- }
+ addOption(option) {
+ const optionBytes = this.constructor.utils.stringtoUTF8Array(option);
+ const optionLength = this.constructor.utils.int32ToBytes(
+ optionBytes.length
+ );
+ this._options.push({ length: optionLength, bytes: optionBytes });
+ }
+ set fee(fee) {
+ this._fee = fee * QORT_DECIMALS;
+ this._feeBytes = this.constructor.utils.int64ToBytes(this._fee);
+ }
- set fee(fee) {
- this._fee = fee * QORT_DECIMALS
- this._feeBytes = this.constructor.utils.int64ToBytes(this._fee)
- }
+ set ownerAddress(ownerAddress) {
+ this._ownerAddress =
+ ownerAddress instanceof Uint8Array
+ ? ownerAddress
+ : this.constructor.Base58.decode(ownerAddress);
+ }
- set ownerAddress(ownerAddress) {
- this._ownerAddress = ownerAddress instanceof Uint8Array ? ownerAddress : this.constructor.Base58.decode(ownerAddress)
- }
+ set rPollName(rPollName) {
+ this._rPollName = rPollName;
+ this._rPollNameBytes = this.constructor.utils.stringtoUTF8Array(
+ this._rPollName
+ );
+ this._rPollNameLength = this.constructor.utils.int32ToBytes(
+ this._rPollNameBytes.length
+ );
+ }
- set rPollName(rPollName) {
- this._rPollName = rPollName
- this._rPollNameBytes = this.constructor.utils.stringtoUTF8Array(this._rPollName)
- this._rPollNameLength = this.constructor.utils.int32ToBytes(this._rPollNameBytes.length)
+ set rPollDesc(rPollDesc) {
+ this._rPollDesc = rPollDesc;
+ this._rPollDescBytes = this.constructor.utils.stringtoUTF8Array(
+ this._rPollDesc
+ );
+ this._rPollDescLength = this.constructor.utils.int32ToBytes(
+ this._rPollDescBytes.length
+ );
+ }
- }
+ set rOptions(rOptions) {
+ const optionsArray = rOptions[0].split(', ').map((opt) => opt.trim());
+ this._pollOptions = optionsArray;
- set rPollDesc(rPollDesc) {
- this._rPollDesc = rPollDesc
- this._rPollDescBytes = this.constructor.utils.stringtoUTF8Array(this._rPollDesc)
- this._rPollDescLength = this.constructor.utils.int32ToBytes(this._rPollDescBytes.length)
- }
+ for (let i = 0; i < optionsArray.length; i++) {
+ this.addOption(optionsArray[i]);
+ }
- set rOptions(rOptions) {
- const optionsArray = rOptions[0].split(', ').map(opt => opt.trim())
- this._pollOptions = optionsArray
+ this._rNumberOfOptionsBytes = this.constructor.utils.int32ToBytes(
+ optionsArray.length
+ );
+ }
- for (let i = 0; i < optionsArray.length; i++) {
- this.addOption(optionsArray[i])
- }
+ get params() {
+ const params = super.params;
+ params.push(
+ this._ownerAddress,
+ this._rPollNameLength,
+ this._rPollNameBytes,
+ this._rPollDescLength,
+ this._rPollDescBytes,
+ this._rNumberOfOptionsBytes
+ );
- this._rNumberOfOptionsBytes = this.constructor.utils.int32ToBytes(optionsArray.length)
- }
+ // Push the dynamic options
+ for (let i = 0; i < this._options.length; i++) {
+ params.push(this._options[i].length, this._options[i].bytes);
+ }
+ params.push(this._feeBytes);
- get params() {
- const params = super.params
- params.push(
- this._ownerAddress,
- this._rPollNameLength,
- this._rPollNameBytes,
- this._rPollDescLength,
- this._rPollDescBytes,
- this._rNumberOfOptionsBytes
- )
-
- // Push the dynamic options
- for (let i = 0; i < this._options.length; i++) {
- params.push(this._options[i].length, this._options[i].bytes)
- }
-
- params.push(this._feeBytes)
-
- return params
- }
+ return params;
+ }
}
diff --git a/src/transactions/DeployAtTransaction.ts b/src/transactions/DeployAtTransaction.ts
index 8a20553..698ef5a 100644
--- a/src/transactions/DeployAtTransaction.ts
+++ b/src/transactions/DeployAtTransaction.ts
@@ -1,78 +1,90 @@
// @ts-nocheck
-
-import TransactionBase from './TransactionBase'
-import { QORT_DECIMALS } from '../constants/constants'
-
+import TransactionBase from './TransactionBase';
+import { QORT_DECIMALS } from '../constants/constants';
export default class DeployAtTransaction extends TransactionBase {
- constructor() {
- super()
- this.type = 16
- }
+ constructor() {
+ super();
+ this.type = 16;
+ }
+ set fee(fee) {
+ this._fee = fee * QORT_DECIMALS;
+ this._feeBytes = this.constructor.utils.int64ToBytes(this._fee);
+ }
+ set rAmount(rAmount) {
+ this._rAmount = Math.round(rAmount * QORT_DECIMALS);
+ this._rAmountBytes = this.constructor.utils.int64ToBytes(this._rAmount);
+ }
- set fee(fee) {
- this._fee = fee * QORT_DECIMALS
- this._feeBytes = this.constructor.utils.int64ToBytes(this._fee)
- }
+ set rName(rName) {
+ this._rName = rName;
+ this._rNameBytes = this.constructor.utils.stringtoUTF8Array(
+ this._rName.toLocaleLowerCase()
+ );
+ this._rNameLength = this.constructor.utils.int32ToBytes(
+ this._rNameBytes.length
+ );
+ }
- set rAmount(rAmount) {
- this._rAmount = Math.round(rAmount * QORT_DECIMALS)
- this._rAmountBytes = this.constructor.utils.int64ToBytes(this._rAmount)
- }
+ set rDescription(rDescription) {
+ this._rDescription = rDescription;
+ this._rDescriptionBytes = this.constructor.utils.stringtoUTF8Array(
+ this._rDescription.toLocaleLowerCase()
+ );
+ this._rDescriptionLength = this.constructor.utils.int32ToBytes(
+ this._rDescriptionBytes.length
+ );
+ }
- set rName(rName) {
- this._rName = rName
- this._rNameBytes = this.constructor.utils.stringtoUTF8Array(this._rName.toLocaleLowerCase())
- this._rNameLength = this.constructor.utils.int32ToBytes(this._rNameBytes.length)
- }
+ set atType(atType) {
+ this._atType = atType;
+ this._atTypeBytes = this.constructor.utils.stringtoUTF8Array(this._atType);
+ this._atTypeLength = this.constructor.utils.int32ToBytes(
+ this._atTypeBytes.length
+ );
+ }
- set rDescription(rDescription) {
- this._rDescription = rDescription
- this._rDescriptionBytes = this.constructor.utils.stringtoUTF8Array(this._rDescription.toLocaleLowerCase())
- this._rDescriptionLength = this.constructor.utils.int32ToBytes(this._rDescriptionBytes.length)
- }
+ set rTags(rTags) {
+ this._rTags = rTags;
+ this._rTagsBytes = this.constructor.utils.stringtoUTF8Array(
+ this._rTags.toLocaleLowerCase()
+ );
+ this._rTagsLength = this.constructor.utils.int32ToBytes(
+ this._rTagsBytes.length
+ );
+ }
- set atType(atType) {
- this._atType = atType
- this._atTypeBytes = this.constructor.utils.stringtoUTF8Array(this._atType)
- this._atTypeLength = this.constructor.utils.int32ToBytes(this._atTypeBytes.length)
- }
+ set rCreationBytes(rCreationBytes) {
+ const decode = this.constructor.Base58.decode(rCreationBytes);
+ this._rCreationBytes = this.constructor.utils.stringtoUTF8Array(decode);
+ this._rCreationBytesLength = this.constructor.utils.int32ToBytes(
+ this._rCreationBytes.length
+ );
+ }
- set rTags(rTags) {
- this._rTags = rTags
- this._rTagsBytes = this.constructor.utils.stringtoUTF8Array(this._rTags.toLocaleLowerCase())
- this._rTagsLength = this.constructor.utils.int32ToBytes(this._rTagsBytes.length)
- }
+ set rAssetId(rAssetId) {
+ this._rAssetId = this.constructor.utils.int64ToBytes(rAssetId);
+ }
- set rCreationBytes(rCreationBytes) {
- const decode = this.constructor.Base58.decode(rCreationBytes)
- this._rCreationBytes = this.constructor.utils.stringtoUTF8Array(decode)
- this._rCreationBytesLength = this.constructor.utils.int32ToBytes(this._rCreationBytes.length)
- }
-
- set rAssetId(rAssetId) {
- this._rAssetId = this.constructor.utils.int64ToBytes(rAssetId)
- }
-
- get params() {
- const params = super.params
- params.push(
- this._rNameLength,
- this._rNameBytes,
- this._rDescriptionLength,
- this._rDescriptionBytes,
- this._atTypeLength,
- this._atTypeBytes,
- this._rTagsLength,
- this._rTagsBytes,
- this._rCreationBytesLength,
- this._rCreationBytes,
- this._rAmountBytes,
- this._rAssetId,
- this._feeBytes
- )
- return params
- }
+ get params() {
+ const params = super.params;
+ params.push(
+ this._rNameLength,
+ this._rNameBytes,
+ this._rDescriptionLength,
+ this._rDescriptionBytes,
+ this._atTypeLength,
+ this._atTypeBytes,
+ this._rTagsLength,
+ this._rTagsBytes,
+ this._rCreationBytesLength,
+ this._rCreationBytes,
+ this._rAmountBytes,
+ this._rAssetId,
+ this._feeBytes
+ );
+ return params;
+ }
}
diff --git a/src/transactions/GroupBanTransaction.ts b/src/transactions/GroupBanTransaction.ts
index 3eb3210..de59e74 100644
--- a/src/transactions/GroupBanTransaction.ts
+++ b/src/transactions/GroupBanTransaction.ts
@@ -1,50 +1,56 @@
// @ts-nocheck
-import { QORT_DECIMALS } from "../constants/constants"
-import TransactionBase from "./TransactionBase"
-
+import { QORT_DECIMALS } from '../constants/constants';
+import TransactionBase from './TransactionBase';
export default class GroupBanTransaction extends TransactionBase {
- constructor() {
- super()
- this.type = 26
- }
+ constructor() {
+ super();
+ this.type = 26;
+ }
- set rGroupId(rGroupId) {
- this._rGroupId = rGroupId
- this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId)
- }
+ set rGroupId(rGroupId) {
+ this._rGroupId = rGroupId;
+ this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId);
+ }
- set rBanReason(rBanReason) {
- this._rBanReason = rBanReason
- this._rBanReasonBytes = this.constructor.utils.stringtoUTF8Array(this._rBanReason)
- this._rBanReasonLength = this.constructor.utils.int32ToBytes(this._rBanReasonBytes.length)
- }
+ set rBanReason(rBanReason) {
+ this._rBanReason = rBanReason;
+ this._rBanReasonBytes = this.constructor.utils.stringtoUTF8Array(
+ this._rBanReason
+ );
+ this._rBanReasonLength = this.constructor.utils.int32ToBytes(
+ this._rBanReasonBytes.length
+ );
+ }
- set rBanTime(rBanTime) {
- this._rBanTime = rBanTime
- this._rBanTimeBytes = this.constructor.utils.int32ToBytes(this._rBanTime)
- }
+ set rBanTime(rBanTime) {
+ this._rBanTime = rBanTime;
+ this._rBanTimeBytes = this.constructor.utils.int32ToBytes(this._rBanTime);
+ }
- set recipient(recipient) {
- this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient)
- this.theRecipient = recipient
- }
+ set recipient(recipient) {
+ this._recipient =
+ recipient instanceof Uint8Array
+ ? recipient
+ : this.constructor.Base58.decode(recipient);
+ this.theRecipient = recipient;
+ }
- set fee(fee) {
- this._fee = fee * QORT_DECIMALS
- this._feeBytes = this.constructor.utils.int64ToBytes(this._fee)
- }
+ set fee(fee) {
+ this._fee = fee * QORT_DECIMALS;
+ this._feeBytes = this.constructor.utils.int64ToBytes(this._fee);
+ }
- get params() {
- const params = super.params
- params.push(
- this._rGroupIdBytes,
- this._recipient,
- this._rBanReasonLength,
- this._rBanReasonBytes,
- this._rBanTimeBytes,
- this._feeBytes
- )
- return params
- }
+ get params() {
+ const params = super.params;
+ params.push(
+ this._rGroupIdBytes,
+ this._recipient,
+ this._rBanReasonLength,
+ this._rBanReasonBytes,
+ this._rBanTimeBytes,
+ this._feeBytes
+ );
+ return params;
+ }
}
diff --git a/src/transactions/GroupChatTransaction.ts b/src/transactions/GroupChatTransaction.ts
index 1cd9d9b..1df7a4f 100644
--- a/src/transactions/GroupChatTransaction.ts
+++ b/src/transactions/GroupChatTransaction.ts
@@ -1,72 +1,79 @@
// @ts-nocheck
-
-import ChatBase from './ChatBase'
-import { CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP } from '../constants/constants'
-
+import ChatBase from './ChatBase';
+import { CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP } from '../constants/constants';
export default class GroupChatTransaction extends ChatBase {
- constructor() {
- super();
- this.type = 18
- this.fee = 0
- }
+ constructor() {
+ super();
+ this.type = 18;
+ this.fee = 0;
+ }
- set proofOfWorkNonce(proofOfWorkNonce) {
- this._proofOfWorkNonce = this.constructor.utils.int32ToBytes(proofOfWorkNonce)
- }
+ set proofOfWorkNonce(proofOfWorkNonce) {
+ this._proofOfWorkNonce =
+ this.constructor.utils.int32ToBytes(proofOfWorkNonce);
+ }
- set hasReceipient(hasReceipient) {
- this._hasReceipient = new Uint8Array(1)
- this._hasReceipient[0] = hasReceipient
- }
+ set hasReceipient(hasReceipient) {
+ this._hasReceipient = new Uint8Array(1);
+ this._hasReceipient[0] = hasReceipient;
+ }
- set message(message) {
- this.messageText = message
-
- this._message = this.constructor.utils.stringtoUTF8Array(message)
- this._messageLength = this.constructor.utils.int32ToBytes(this._message.length)
- }
+ set message(message) {
+ this.messageText = message;
- set hasChatReference(hasChatReference) {
- this._hasChatReference = new Uint8Array(1)
- this._hasChatReference[0] = hasChatReference
- }
+ this._message = this.constructor.utils.stringtoUTF8Array(message);
+ this._messageLength = this.constructor.utils.int32ToBytes(
+ this._message.length
+ );
+ }
- set chatReference(chatReference) {
- this._chatReference = chatReference instanceof Uint8Array ? chatReference : this.constructor.Base58.decode(chatReference)
- }
+ set hasChatReference(hasChatReference) {
+ this._hasChatReference = new Uint8Array(1);
+ this._hasChatReference[0] = hasChatReference;
+ }
- set isEncrypted(isEncrypted) {
- this._isEncrypted = new Uint8Array(1)
- this._isEncrypted[0] = isEncrypted
- }
+ set chatReference(chatReference) {
+ this._chatReference =
+ chatReference instanceof Uint8Array
+ ? chatReference
+ : this.constructor.Base58.decode(chatReference);
+ }
- set isText(isText) {
- this._isText = new Uint8Array(1)
- this._isText[0] = isText
- }
+ set isEncrypted(isEncrypted) {
+ this._isEncrypted = new Uint8Array(1);
+ this._isEncrypted[0] = isEncrypted;
+ }
- get params() {
- const params = super.params
- params.push(
- this._proofOfWorkNonce,
- this._hasReceipient,
- this._messageLength,
- this._message,
- this._isEncrypted,
- this._isText,
- this._feeBytes
- )
+ set isText(isText) {
+ this._isText = new Uint8Array(1);
+ this._isText[0] = isText;
+ }
- // After the feature trigger timestamp we need to include chat reference
- if (new Date(this._timestamp).getTime() >= CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP) {
- params.push(this._hasChatReference)
+ get params() {
+ const params = super.params;
+ params.push(
+ this._proofOfWorkNonce,
+ this._hasReceipient,
+ this._messageLength,
+ this._message,
+ this._isEncrypted,
+ this._isText,
+ this._feeBytes
+ );
- if (this._hasChatReference[0] == 1) {
- params.push(this._chatReference)
- }
- }
+ // After the feature trigger timestamp we need to include chat reference
+ if (
+ new Date(this._timestamp).getTime() >=
+ CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP
+ ) {
+ params.push(this._hasChatReference);
- return params
- }
+ if (this._hasChatReference[0] == 1) {
+ params.push(this._chatReference);
+ }
+ }
+
+ return params;
+ }
}
diff --git a/src/transactions/GroupInviteTransaction.ts b/src/transactions/GroupInviteTransaction.ts
index 3cbf978..448534b 100644
--- a/src/transactions/GroupInviteTransaction.ts
+++ b/src/transactions/GroupInviteTransaction.ts
@@ -1,42 +1,46 @@
// @ts-nocheck
-import { QORT_DECIMALS } from "../constants/constants"
-import TransactionBase from "./TransactionBase"
-
+import { QORT_DECIMALS } from '../constants/constants';
+import TransactionBase from './TransactionBase';
export default class GroupInviteTransaction extends TransactionBase {
- constructor() {
- super()
- this.type = 29
- }
+ constructor() {
+ super();
+ this.type = 29;
+ }
- set rGroupId(rGroupId) {
- this._rGroupId = rGroupId
- this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId)
- }
+ set rGroupId(rGroupId) {
+ this._rGroupId = rGroupId;
+ this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId);
+ }
- set rInviteTime(rInviteTime) {
- this._rInviteTime = rInviteTime
- this._rInviteTimeBytes = this.constructor.utils.int32ToBytes(this._rInviteTime)
- }
+ set rInviteTime(rInviteTime) {
+ this._rInviteTime = rInviteTime;
+ this._rInviteTimeBytes = this.constructor.utils.int32ToBytes(
+ this._rInviteTime
+ );
+ }
- set recipient(recipient) {
- this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient)
- this.theRecipient = recipient
- }
+ set recipient(recipient) {
+ this._recipient =
+ recipient instanceof Uint8Array
+ ? recipient
+ : this.constructor.Base58.decode(recipient);
+ this.theRecipient = recipient;
+ }
- set fee(fee) {
- this._fee = fee * QORT_DECIMALS
- this._feeBytes = this.constructor.utils.int64ToBytes(this._fee)
- }
+ set fee(fee) {
+ this._fee = fee * QORT_DECIMALS;
+ this._feeBytes = this.constructor.utils.int64ToBytes(this._fee);
+ }
- get params() {
- const params = super.params
- params.push(
- this._rGroupIdBytes,
- this._recipient,
- this._rInviteTimeBytes,
- this._feeBytes
- )
- return params
- }
+ get params() {
+ const params = super.params;
+ params.push(
+ this._rGroupIdBytes,
+ this._recipient,
+ this._rInviteTimeBytes,
+ this._feeBytes
+ );
+ return params;
+ }
}
diff --git a/src/transactions/GroupKickTransaction.ts b/src/transactions/GroupKickTransaction.ts
index 969380f..298ebc9 100644
--- a/src/transactions/GroupKickTransaction.ts
+++ b/src/transactions/GroupKickTransaction.ts
@@ -1,46 +1,50 @@
// @ts-nocheck
-
-import { QORT_DECIMALS } from "../constants/constants"
-import TransactionBase from "./TransactionBase"
-
-
+import { QORT_DECIMALS } from '../constants/constants';
+import TransactionBase from './TransactionBase';
export default class GroupKickTransaction extends TransactionBase {
- constructor() {
- super()
- this.type = 28
- }
+ constructor() {
+ super();
+ this.type = 28;
+ }
- set rGroupId(rGroupId) {
- this._rGroupId = rGroupId
- this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId)
- }
+ set rGroupId(rGroupId) {
+ this._rGroupId = rGroupId;
+ this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId);
+ }
- set rBanReason(rBanReason) {
- this._rBanReason = rBanReason
- this._rBanReasonBytes = this.constructor.utils.stringtoUTF8Array(this._rBanReason)
- this._rBanReasonLength = this.constructor.utils.int32ToBytes(this._rBanReasonBytes.length)
- }
+ set rBanReason(rBanReason) {
+ this._rBanReason = rBanReason;
+ this._rBanReasonBytes = this.constructor.utils.stringtoUTF8Array(
+ this._rBanReason
+ );
+ this._rBanReasonLength = this.constructor.utils.int32ToBytes(
+ this._rBanReasonBytes.length
+ );
+ }
- set recipient(recipient) {
- this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient)
- this.theRecipient = recipient
- }
+ set recipient(recipient) {
+ this._recipient =
+ recipient instanceof Uint8Array
+ ? recipient
+ : this.constructor.Base58.decode(recipient);
+ this.theRecipient = recipient;
+ }
- set fee(fee) {
- this._fee = fee * QORT_DECIMALS
- this._feeBytes = this.constructor.utils.int64ToBytes(this._fee)
- }
+ set fee(fee) {
+ this._fee = fee * QORT_DECIMALS;
+ this._feeBytes = this.constructor.utils.int64ToBytes(this._fee);
+ }
- get params() {
- const params = super.params
- params.push(
- this._rGroupIdBytes,
- this._recipient,
- this._rBanReasonLength,
- this._rBanReasonBytes,
- this._feeBytes
- )
- return params
- }
+ get params() {
+ const params = super.params;
+ params.push(
+ this._rGroupIdBytes,
+ this._recipient,
+ this._rBanReasonLength,
+ this._rBanReasonBytes,
+ this._feeBytes
+ );
+ return params;
+ }
}
diff --git a/src/transactions/JoinGroupTransaction.ts b/src/transactions/JoinGroupTransaction.ts
index 0aae8f7..dc51048 100644
--- a/src/transactions/JoinGroupTransaction.ts
+++ b/src/transactions/JoinGroupTransaction.ts
@@ -1,38 +1,33 @@
// @ts-nocheck
-import { QORT_DECIMALS } from "../constants/constants"
-import TransactionBase from "./TransactionBase"
-
-
+import { QORT_DECIMALS } from '../constants/constants';
+import TransactionBase from './TransactionBase';
export default class JoinGroupTransaction extends TransactionBase {
- constructor() {
- super()
- this.type = 31
- }
+ constructor() {
+ super();
+ this.type = 31;
+ }
+ set fee(fee) {
+ this._fee = fee * QORT_DECIMALS;
+ this._feeBytes = this.constructor.utils.int64ToBytes(this._fee);
+ }
+ set registrantAddress(registrantAddress) {
+ this._registrantAddress =
+ registrantAddress instanceof Uint8Array
+ ? registrantAddress
+ : this.constructor.Base58.decode(registrantAddress);
+ }
- set fee(fee) {
- this._fee = fee * QORT_DECIMALS
- this._feeBytes = this.constructor.utils.int64ToBytes(this._fee)
- }
+ set rGroupId(rGroupId) {
+ this._rGroupId = rGroupId;
+ this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId);
+ }
- set registrantAddress(registrantAddress) {
- this._registrantAddress = registrantAddress instanceof Uint8Array ? registrantAddress : this.constructor.Base58.decode(registrantAddress)
- }
-
- set rGroupId(rGroupId) {
- this._rGroupId = rGroupId
- this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId)
- }
-
-
- get params() {
- const params = super.params
- params.push(
- this._rGroupIdBytes,
- this._feeBytes
- )
- return params
- }
+ get params() {
+ const params = super.params;
+ params.push(this._rGroupIdBytes, this._feeBytes);
+ return params;
+ }
}
diff --git a/src/transactions/LeaveGroupTransaction.ts b/src/transactions/LeaveGroupTransaction.ts
index 222f250..85eeeec 100644
--- a/src/transactions/LeaveGroupTransaction.ts
+++ b/src/transactions/LeaveGroupTransaction.ts
@@ -1,35 +1,34 @@
// @ts-nocheck
-import { QORT_DECIMALS } from "../constants/constants"
-import TransactionBase from "./TransactionBase"
-
+import { QORT_DECIMALS } from '../constants/constants';
+import TransactionBase from './TransactionBase';
export default class LeaveGroupTransaction extends TransactionBase {
- constructor() {
- super()
- this.type = 32
- }
-
- set fee(fee) {
- this._fee = fee * QORT_DECIMALS
- this._feeBytes = this.constructor.utils.int64ToBytes(this._fee)
- }
+ constructor() {
+ super();
+ this.type = 32;
+ }
- set registrantAddress(registrantAddress) {
- this._registrantAddress = registrantAddress instanceof Uint8Array ? registrantAddress : this.constructor.Base58.decode(registrantAddress)
- }
+ set fee(fee) {
+ this._fee = fee * QORT_DECIMALS;
+ this._feeBytes = this.constructor.utils.int64ToBytes(this._fee);
+ }
- set rGroupId(rGroupId) {
- this._rGroupId = rGroupId
- this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId)
- }
+ set registrantAddress(registrantAddress) {
+ this._registrantAddress =
+ registrantAddress instanceof Uint8Array
+ ? registrantAddress
+ : this.constructor.Base58.decode(registrantAddress);
+ }
- get params() {
- const params = super.params
- params.push(
- this._rGroupIdBytes,
- this._feeBytes
- )
- return params
- }
+ set rGroupId(rGroupId) {
+ this._rGroupId = rGroupId;
+ this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId);
+ }
+
+ get params() {
+ const params = super.params;
+ params.push(this._rGroupIdBytes, this._feeBytes);
+ return params;
+ }
}
diff --git a/src/transactions/PaymentTransaction.ts b/src/transactions/PaymentTransaction.ts
index 120bbe9..af770f8 100644
--- a/src/transactions/PaymentTransaction.ts
+++ b/src/transactions/PaymentTransaction.ts
@@ -1,38 +1,36 @@
// @ts-nocheck
-import { QORT_DECIMALS } from '../constants/constants'
-import TransactionBase from './TransactionBase'
-
+import { QORT_DECIMALS } from '../constants/constants';
+import TransactionBase from './TransactionBase';
export default class PaymentTransaction extends TransactionBase {
- constructor() {
- super()
- this.type = 2
- }
+ constructor() {
+ super();
+ this.type = 2;
+ }
- set recipient(recipient) {
- this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient)
- }
+ set recipient(recipient) {
+ this._recipient =
+ recipient instanceof Uint8Array
+ ? recipient
+ : this.constructor.Base58.decode(recipient);
+ }
- set dialogto(dialogto) {
- this._dialogto = dialogto
- }
+ set dialogto(dialogto) {
+ this._dialogto = dialogto;
+ }
- set dialogamount(dialogamount) {
- this._dialogamount = dialogamount
- }
+ set dialogamount(dialogamount) {
+ this._dialogamount = dialogamount;
+ }
- set amount(amount) {
- this._amount = Math.round(amount * QORT_DECIMALS)
- this._amountBytes = this.constructor.utils.int64ToBytes(this._amount)
- }
+ set amount(amount) {
+ this._amount = Math.round(amount * QORT_DECIMALS);
+ this._amountBytes = this.constructor.utils.int64ToBytes(this._amount);
+ }
- get params() {
- const params = super.params
- params.push(
- this._recipient,
- this._amountBytes,
- this._feeBytes
- )
- return params
- }
+ get params() {
+ const params = super.params;
+ params.push(this._recipient, this._amountBytes, this._feeBytes);
+ return params;
+ }
}
diff --git a/src/transactions/RegisterNameTransaction.ts b/src/transactions/RegisterNameTransaction.ts
index 53046ee..e523f28 100644
--- a/src/transactions/RegisterNameTransaction.ts
+++ b/src/transactions/RegisterNameTransaction.ts
@@ -1,42 +1,44 @@
// @ts-nocheck
-import { QORT_DECIMALS } from "../constants/constants"
-import TransactionBase from "./TransactionBase"
-
-
+import { QORT_DECIMALS } from '../constants/constants';
+import TransactionBase from './TransactionBase';
export default class RegisterNameTransaction extends TransactionBase {
- constructor() {
- super()
- this.type = 3
- }
+ constructor() {
+ super();
+ this.type = 3;
+ }
+ set fee(fee) {
+ this._fee = fee * QORT_DECIMALS;
+ this._feeBytes = this.constructor.utils.int64ToBytes(this._fee);
+ }
- set fee(fee) {
- this._fee = fee * QORT_DECIMALS
- this._feeBytes = this.constructor.utils.int64ToBytes(this._fee)
- }
+ set name(name) {
+ this.nameText = name;
+ this._nameBytes = this.constructor.utils.stringtoUTF8Array(name);
+ this._nameLength = this.constructor.utils.int32ToBytes(
+ this._nameBytes.length
+ );
+ }
- set name(name) {
- this.nameText = name
- this._nameBytes = this.constructor.utils.stringtoUTF8Array(name)
- this._nameLength = this.constructor.utils.int32ToBytes(this._nameBytes.length)
- }
+ set value(value) {
+ this.valueText =
+ value.length === 0 ? 'Registered Name on the Qortal Chain' : value;
+ this._valueBytes = this.constructor.utils.stringtoUTF8Array(this.valueText);
+ this._valueLength = this.constructor.utils.int32ToBytes(
+ this._valueBytes.length
+ );
+ }
- set value(value) {
- this.valueText = value.length === 0 ? "Registered Name on the Qortal Chain" : value
- this._valueBytes = this.constructor.utils.stringtoUTF8Array(this.valueText)
- this._valueLength = this.constructor.utils.int32ToBytes(this._valueBytes.length)
- }
-
- get params() {
- const params = super.params
- params.push(
- this._nameLength,
- this._nameBytes,
- this._valueLength,
- this._valueBytes,
- this._feeBytes
- )
- return params
- }
+ get params() {
+ const params = super.params;
+ params.push(
+ this._nameLength,
+ this._nameBytes,
+ this._valueLength,
+ this._valueBytes,
+ this._feeBytes
+ );
+ return params;
+ }
}
diff --git a/src/transactions/RemoveGroupAdminTransaction.ts b/src/transactions/RemoveGroupAdminTransaction.ts
index 3392f79..11896be 100644
--- a/src/transactions/RemoveGroupAdminTransaction.ts
+++ b/src/transactions/RemoveGroupAdminTransaction.ts
@@ -1,38 +1,34 @@
// @ts-nocheck
-import { QORT_DECIMALS } from "../constants/constants"
-import TransactionBase from "./TransactionBase"
-
+import { QORT_DECIMALS } from '../constants/constants';
+import TransactionBase from './TransactionBase';
export default class RemoveGroupAdminTransaction extends TransactionBase {
- constructor() {
- super()
- this.type = 25
- }
+ constructor() {
+ super();
+ this.type = 25;
+ }
+ set rGroupId(rGroupId) {
+ this._rGroupId = rGroupId;
+ this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId);
+ }
+ set recipient(recipient) {
+ this._recipient =
+ recipient instanceof Uint8Array
+ ? recipient
+ : this.constructor.Base58.decode(recipient);
+ this.theRecipient = recipient;
+ }
- set rGroupId(rGroupId) {
- this._rGroupId = rGroupId
- this._rGroupIdBytes = this.constructor.utils.int32ToBytes(this._rGroupId)
- }
+ set fee(fee) {
+ this._fee = fee * QORT_DECIMALS;
+ this._feeBytes = this.constructor.utils.int64ToBytes(this._fee);
+ }
- set recipient(recipient) {
- this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient)
- this.theRecipient = recipient
- }
-
- set fee(fee) {
- this._fee = fee * QORT_DECIMALS
- this._feeBytes = this.constructor.utils.int64ToBytes(this._fee)
- }
-
- get params() {
- const params = super.params
- params.push(
- this._rGroupIdBytes,
- this._recipient,
- this._feeBytes
- )
- return params
- }
+ get params() {
+ const params = super.params;
+ params.push(this._rGroupIdBytes, this._recipient, this._feeBytes);
+ return params;
+ }
}
diff --git a/src/transactions/RemoveRewardShareTransaction.ts b/src/transactions/RemoveRewardShareTransaction.ts
index 375711a..c91d389 100644
--- a/src/transactions/RemoveRewardShareTransaction.ts
+++ b/src/transactions/RemoveRewardShareTransaction.ts
@@ -1,46 +1,50 @@
// @ts-nocheck
-import { DYNAMIC_FEE_TIMESTAMP } from "../constants/constants"
-import Base58 from "../deps/Base58"
-import publicKeyToAddress from "../utils/generateWallet/publicKeyToAddress"
-import TransactionBase from "./TransactionBase"
-
-
+import { DYNAMIC_FEE_TIMESTAMP } from '../constants/constants';
+import Base58 from '../deps/Base58';
+import publicKeyToAddress from '../utils/generateWallet/publicKeyToAddress';
+import TransactionBase from './TransactionBase';
export default class RemoveRewardShareTransaction extends TransactionBase {
- constructor() {
- super()
- this.type = 38
- }
+ constructor() {
+ super();
+ this.type = 38;
+ }
+ set rewardShareKeyPairPublicKey(rewardShareKeyPairPublicKey) {
+ this._rewardShareKeyPairPublicKey = Base58.decode(
+ rewardShareKeyPairPublicKey
+ );
+ }
- set rewardShareKeyPairPublicKey(rewardShareKeyPairPublicKey) {
- this._rewardShareKeyPairPublicKey = Base58.decode(rewardShareKeyPairPublicKey)
- }
+ set recipient(recipient) {
+ const _address = publicKeyToAddress(this._keyPair.publicKey);
+ this._recipient =
+ recipient instanceof Uint8Array
+ ? recipient
+ : this.constructor.Base58.decode(recipient);
- set recipient(recipient) {
- const _address = publicKeyToAddress(this._keyPair.publicKey)
- this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient)
+ if (new Date(this._timestamp).getTime() >= DYNAMIC_FEE_TIMESTAMP) {
+ this.fee = _address === recipient ? 0 : 0.01;
+ } else {
+ this.fee = _address === recipient ? 0 : 0.001;
+ }
+ }
- if (new Date(this._timestamp).getTime() >= DYNAMIC_FEE_TIMESTAMP) {
- this.fee = _address === recipient ? 0 : 0.01
- } else {
- this.fee = _address === recipient ? 0 : 0.001
- }
- }
+ set percentageShare(share) {
+ this._percentageShare = share * 100;
+ this._percentageShareBytes = this.constructor.utils.int64ToBytes(
+ this._percentageShare
+ );
+ }
- set percentageShare(share) {
- this._percentageShare = share * 100
- this._percentageShareBytes = this.constructor.utils.int64ToBytes(this._percentageShare)
- }
-
- get params() {
- const params = super.params
- params.push(
- this._recipient,
- this._rewardShareKeyPairPublicKey,
- this._percentageShareBytes,
- this._feeBytes
- )
- return params
- }
+ get params() {
+ const params = super.params;
+ params.push(
+ this._recipient,
+ this._rewardShareKeyPairPublicKey,
+ this._percentageShareBytes,
+ this._feeBytes
+ );
+ return params;
+ }
}
diff --git a/src/transactions/RewardShareTransaction.ts b/src/transactions/RewardShareTransaction.ts
index 8419432..67131b3 100644
--- a/src/transactions/RewardShareTransaction.ts
+++ b/src/transactions/RewardShareTransaction.ts
@@ -1,60 +1,86 @@
// @ts-nocheck
-import TransactionBase from './TransactionBase'
-
-import { Sha256 } from 'asmcrypto.js'
-import nacl from '../deps/nacl-fast'
-import ed2curve from '../deps/ed2curve'
-import { DYNAMIC_FEE_TIMESTAMP } from '../constants/constants'
-import publicKeyToAddress from '../utils/generateWallet/publicKeyToAddress'
-
+import TransactionBase from './TransactionBase';
+import { Sha256 } from 'asmcrypto.js';
+import nacl from '../deps/nacl-fast';
+import ed2curve from '../deps/ed2curve';
+import { DYNAMIC_FEE_TIMESTAMP } from '../constants/constants';
+import publicKeyToAddress from '../utils/generateWallet/publicKeyToAddress';
export default class RewardShareTransaction extends TransactionBase {
- constructor() {
- super()
- this.type = 38
- }
+ constructor() {
+ super();
+ this.type = 38;
+ }
+ set recipientPublicKey(recipientPublicKey) {
+ this._base58RecipientPublicKey =
+ recipientPublicKey instanceof Uint8Array
+ ? this.constructor.Base58.encode(recipientPublicKey)
+ : recipientPublicKey;
+ this._recipientPublicKey = this.constructor.Base58.decode(
+ this._base58RecipientPublicKey
+ );
+ this.recipient = publicKeyToAddress(this._recipientPublicKey);
+ const convertedPrivateKey = ed2curve.convertSecretKey(
+ this._keyPair.privateKey
+ );
+ const convertedPublicKey = ed2curve.convertPublicKey(
+ this._recipientPublicKey
+ );
+ const sharedSecret = new Uint8Array(32);
- set recipientPublicKey(recipientPublicKey) {
- this._base58RecipientPublicKey = recipientPublicKey instanceof Uint8Array ? this.constructor.Base58.encode(recipientPublicKey) : recipientPublicKey
- this._recipientPublicKey = this.constructor.Base58.decode(this._base58RecipientPublicKey)
- this.recipient = publicKeyToAddress(this._recipientPublicKey)
+ nacl.lowlevel.crypto_scalarmult(
+ sharedSecret,
+ convertedPrivateKey,
+ convertedPublicKey
+ );
- const convertedPrivateKey = ed2curve.convertSecretKey(this._keyPair.privateKey)
- const convertedPublicKey = ed2curve.convertPublicKey(this._recipientPublicKey)
- const sharedSecret = new Uint8Array(32)
+ this._rewardShareSeed = new Sha256().process(sharedSecret).finish().result;
+ this._base58RewardShareSeed = this.constructor.Base58.encode(
+ this._rewardShareSeed
+ );
+ this._rewardShareKeyPair = nacl.sign.keyPair.fromSeed(
+ this._rewardShareSeed
+ );
- nacl.lowlevel.crypto_scalarmult(sharedSecret, convertedPrivateKey, convertedPublicKey)
+ if (new Date(this._timestamp).getTime() >= DYNAMIC_FEE_TIMESTAMP) {
+ this.fee =
+ recipientPublicKey ===
+ this.constructor.Base58.encode(this._keyPair.publicKey)
+ ? 0
+ : 0.01;
+ } else {
+ this.fee =
+ recipientPublicKey ===
+ this.constructor.Base58.encode(this._keyPair.publicKey)
+ ? 0
+ : 0.001;
+ }
+ }
- this._rewardShareSeed = new Sha256().process(sharedSecret).finish().result
- this._base58RewardShareSeed = this.constructor.Base58.encode(this._rewardShareSeed)
- this._rewardShareKeyPair = nacl.sign.keyPair.fromSeed(this._rewardShareSeed)
+ set recipient(recipient) {
+ this._recipient =
+ recipient instanceof Uint8Array
+ ? recipient
+ : this.constructor.Base58.decode(recipient);
+ }
- if (new Date(this._timestamp).getTime() >= DYNAMIC_FEE_TIMESTAMP) {
- this.fee = (recipientPublicKey === this.constructor.Base58.encode(this._keyPair.publicKey) ? 0 : 0.01)
- } else {
- this.fee = (recipientPublicKey === this.constructor.Base58.encode(this._keyPair.publicKey) ? 0 : 0.001)
- }
- }
+ set percentageShare(share) {
+ this._percentageShare = share * 100;
+ this._percentageShareBytes = this.constructor.utils.int64ToBytes(
+ this._percentageShare
+ );
+ }
- set recipient(recipient) {
- this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient)
- }
-
- set percentageShare(share) {
- this._percentageShare = share * 100
- this._percentageShareBytes = this.constructor.utils.int64ToBytes(this._percentageShare)
- }
-
- get params() {
- const params = super.params
- params.push(
- this._recipient,
- this._rewardShareKeyPair.publicKey,
- this._percentageShareBytes,
- this._feeBytes
- )
- return params
- }
+ get params() {
+ const params = super.params;
+ params.push(
+ this._recipient,
+ this._rewardShareKeyPair.publicKey,
+ this._percentageShareBytes,
+ this._feeBytes
+ );
+ return params;
+ }
}
diff --git a/src/transactions/SellNameTransacion.ts b/src/transactions/SellNameTransacion.ts
index 3926568..2e5f15e 100644
--- a/src/transactions/SellNameTransacion.ts
+++ b/src/transactions/SellNameTransacion.ts
@@ -1,40 +1,40 @@
// @ts-nocheck
-import { QORT_DECIMALS } from "../constants/constants"
-import TransactionBase from "./TransactionBase"
-
-
+import { QORT_DECIMALS } from '../constants/constants';
+import TransactionBase from './TransactionBase';
export default class SellNameTransacion extends TransactionBase {
- constructor() {
- super()
- this.type = 5
- }
+ constructor() {
+ super();
+ this.type = 5;
+ }
- set fee(fee) {
- this._fee = fee * QORT_DECIMALS
- this._feeBytes = this.constructor.utils.int64ToBytes(this._fee)
- }
+ set fee(fee) {
+ this._fee = fee * QORT_DECIMALS;
+ this._feeBytes = this.constructor.utils.int64ToBytes(this._fee);
+ }
- set name(name) {
- this.nameText = name
- this._nameBytes = this.constructor.utils.stringtoUTF8Array(name)
- this._nameLength = this.constructor.utils.int32ToBytes(this._nameBytes.length)
- }
+ set name(name) {
+ this.nameText = name;
+ this._nameBytes = this.constructor.utils.stringtoUTF8Array(name);
+ this._nameLength = this.constructor.utils.int32ToBytes(
+ this._nameBytes.length
+ );
+ }
- set sellPrice(sellPrice) {
- this.showSellPrice = sellPrice
- this._sellPrice = sellPrice * QORT_DECIMALS
- this._sellPriceBytes = this.constructor.utils.int64ToBytes(this._sellPrice)
- }
+ set sellPrice(sellPrice) {
+ this.showSellPrice = sellPrice;
+ this._sellPrice = sellPrice * QORT_DECIMALS;
+ this._sellPriceBytes = this.constructor.utils.int64ToBytes(this._sellPrice);
+ }
- get params() {
- const params = super.params
- params.push(
- this._nameLength,
- this._nameBytes,
- this._sellPriceBytes,
- this._feeBytes
- )
- return params
- }
+ get params() {
+ const params = super.params;
+ params.push(
+ this._nameLength,
+ this._nameBytes,
+ this._sellPriceBytes,
+ this._feeBytes
+ );
+ return params;
+ }
}
diff --git a/src/transactions/TradeBotCreateRequest.ts b/src/transactions/TradeBotCreateRequest.ts
index 800ddec..fbdcdb5 100644
--- a/src/transactions/TradeBotCreateRequest.ts
+++ b/src/transactions/TradeBotCreateRequest.ts
@@ -2,64 +2,64 @@
/**
* CrossChain - TradeBot Create Request (Sell Action)
- *
+ *
* These are special types of transactions (JSON ENCODED)
*/
export default class TradeBotCreateRequest {
- constructor() {
- // ...
- }
+ constructor() {
+ // ...
+ }
- createTransaction(txnReq) {
- this.creatorPublicKey(txnReq.creatorPublicKey)
- this.qortAmount(txnReq.qortAmount)
- this.fundingQortAmount(txnReq.fundingQortAmount)
- this.foreignBlockchain(txnReq.foreignBlockchain)
- this.foreignAmount(txnReq.foreignAmount)
- this.tradeTimeout(txnReq.tradeTimeout)
- this.receivingAddress(txnReq.receivingAddress)
+ createTransaction(txnReq) {
+ this.creatorPublicKey(txnReq.creatorPublicKey);
+ this.qortAmount(txnReq.qortAmount);
+ this.fundingQortAmount(txnReq.fundingQortAmount);
+ this.foreignBlockchain(txnReq.foreignBlockchain);
+ this.foreignAmount(txnReq.foreignAmount);
+ this.tradeTimeout(txnReq.tradeTimeout);
+ this.receivingAddress(txnReq.receivingAddress);
- return this.txnRequest()
- }
+ return this.txnRequest();
+ }
- creatorPublicKey(creatorPublicKey) {
- this._creatorPublicKey = creatorPublicKey
- }
+ creatorPublicKey(creatorPublicKey) {
+ this._creatorPublicKey = creatorPublicKey;
+ }
- qortAmount(qortAmount) {
- this._qortAmount = qortAmount
- }
+ qortAmount(qortAmount) {
+ this._qortAmount = qortAmount;
+ }
- fundingQortAmount(fundingQortAmount) {
- this._fundingQortAmount = fundingQortAmount
- }
+ fundingQortAmount(fundingQortAmount) {
+ this._fundingQortAmount = fundingQortAmount;
+ }
- foreignBlockchain(foreignBlockchain) {
- this._foreignBlockchain = foreignBlockchain
- }
+ foreignBlockchain(foreignBlockchain) {
+ this._foreignBlockchain = foreignBlockchain;
+ }
- foreignAmount(foreignAmount) {
- this._foreignAmount = foreignAmount
- }
+ foreignAmount(foreignAmount) {
+ this._foreignAmount = foreignAmount;
+ }
- tradeTimeout(tradeTimeout) {
- this._tradeTimeout = tradeTimeout
- }
+ tradeTimeout(tradeTimeout) {
+ this._tradeTimeout = tradeTimeout;
+ }
- receivingAddress(receivingAddress) {
- this._receivingAddress = receivingAddress
- }
+ receivingAddress(receivingAddress) {
+ this._receivingAddress = receivingAddress;
+ }
- txnRequest() {
- return {
- creatorPublicKey: this._creatorPublicKey,
- qortAmount: this._qortAmount,
- fundingQortAmount: this._fundingQortAmount,
- foreignBlockchain: this._foreignBlockchain,
- foreignAmount: this._foreignAmount,
- tradeTimeout: this._tradeTimeout,
- receivingAddress: this._receivingAddress
- }
- }
+ txnRequest() {
+ return {
+ creatorPublicKey: this._creatorPublicKey,
+ qortAmount: this._qortAmount,
+ fundingQortAmount: this._fundingQortAmount,
+ foreignBlockchain: this._foreignBlockchain,
+ foreignAmount: this._foreignAmount,
+ tradeTimeout: this._tradeTimeout,
+ receivingAddress: this._receivingAddress,
+ };
+ }
}
diff --git a/src/transactions/TradeBotDeleteRequest.ts b/src/transactions/TradeBotDeleteRequest.ts
index cd3c1b4..1e4a69d 100644
--- a/src/transactions/TradeBotDeleteRequest.ts
+++ b/src/transactions/TradeBotDeleteRequest.ts
@@ -1,35 +1,35 @@
// @ts-nocheck
/**
- * CrossChain - DELETE TradeOffer
- *
+ * CrossChain - DELETE TradeOffer
+ *
* These are special types of transactions (JSON ENCODED)
*/
export default class DeleteTradeOffer {
- constructor() {
- // ...
- }
+ constructor() {
+ // ...
+ }
- createTransaction(txnReq) {
- this.creatorPublicKey(txnReq.creatorPublicKey)
- this.atAddress(txnReq.atAddress)
+ createTransaction(txnReq) {
+ this.creatorPublicKey(txnReq.creatorPublicKey);
+ this.atAddress(txnReq.atAddress);
- return this.txnRequest()
- }
+ return this.txnRequest();
+ }
- creatorPublicKey(creatorPublicKey) {
- this._creatorPublicKey = creatorPublicKey
- }
+ creatorPublicKey(creatorPublicKey) {
+ this._creatorPublicKey = creatorPublicKey;
+ }
- atAddress(atAddress) {
- this._atAddress = atAddress
- }
+ atAddress(atAddress) {
+ this._atAddress = atAddress;
+ }
- txnRequest() {
- return {
- creatorPublicKey: this._creatorPublicKey,
- atAddress: this._atAddress
- }
- }
+ txnRequest() {
+ return {
+ creatorPublicKey: this._creatorPublicKey,
+ atAddress: this._atAddress,
+ };
+ }
}
diff --git a/src/transactions/TradeBotRespondMultipleRequest.ts b/src/transactions/TradeBotRespondMultipleRequest.ts
index a7eb4d8..da3b93e 100644
--- a/src/transactions/TradeBotRespondMultipleRequest.ts
+++ b/src/transactions/TradeBotRespondMultipleRequest.ts
@@ -7,36 +7,35 @@
*/
export class TradeBotRespondMultipleRequest {
- constructor() {
- // ...
- }
+ constructor() {
+ // ...
+ }
- createTransaction(txnReq) {
- this.addresses(txnReq.addresses)
- this.foreignKey(txnReq.foreignKey)
- this.receivingAddress(txnReq.receivingAddress)
+ createTransaction(txnReq) {
+ this.addresses(txnReq.addresses);
+ this.foreignKey(txnReq.foreignKey);
+ this.receivingAddress(txnReq.receivingAddress);
- return this.txnRequest()
- }
+ return this.txnRequest();
+ }
- addresses(addresses) {
- this._addresses = addresses
- }
+ addresses(addresses) {
+ this._addresses = addresses;
+ }
- foreignKey(foreignKey) {
- this._foreignKey = foreignKey
- }
+ foreignKey(foreignKey) {
+ this._foreignKey = foreignKey;
+ }
- receivingAddress(receivingAddress) {
- this._receivingAddress = receivingAddress
- }
+ receivingAddress(receivingAddress) {
+ this._receivingAddress = receivingAddress;
+ }
- txnRequest() {
- return {
- addresses: this._addresses,
- foreignKey: this._foreignKey,
- receivingAddress: this._receivingAddress
- }
- }
+ txnRequest() {
+ return {
+ addresses: this._addresses,
+ foreignKey: this._foreignKey,
+ receivingAddress: this._receivingAddress,
+ };
+ }
}
-
diff --git a/src/transactions/TradeBotRespondRequest.ts b/src/transactions/TradeBotRespondRequest.ts
index fcd1af5..76f548a 100644
--- a/src/transactions/TradeBotRespondRequest.ts
+++ b/src/transactions/TradeBotRespondRequest.ts
@@ -2,40 +2,40 @@
/**
* CrossChain - TradeBot Respond Request (Buy Action)
- *
+ *
* These are special types of transactions (JSON ENCODED)
*/
export default class TradeBotRespondRequest {
- constructor() {
- // ...
- }
+ constructor() {
+ // ...
+ }
- createTransaction(txnReq) {
- this.atAddress(txnReq.atAddress)
- this.foreignKey(txnReq.foreignKey)
- this.receivingAddress(txnReq.receivingAddress)
+ createTransaction(txnReq) {
+ this.atAddress(txnReq.atAddress);
+ this.foreignKey(txnReq.foreignKey);
+ this.receivingAddress(txnReq.receivingAddress);
- return this.txnRequest()
- }
+ return this.txnRequest();
+ }
- atAddress(atAddress) {
- this._atAddress = atAddress
- }
+ atAddress(atAddress) {
+ this._atAddress = atAddress;
+ }
- foreignKey(foreignKey) {
- this._foreignKey = foreignKey
- }
+ foreignKey(foreignKey) {
+ this._foreignKey = foreignKey;
+ }
- receivingAddress(receivingAddress) {
- this._receivingAddress = receivingAddress
- }
+ receivingAddress(receivingAddress) {
+ this._receivingAddress = receivingAddress;
+ }
- txnRequest() {
- return {
- atAddress: this._atAddress,
- foreignKey: this._foreignKey,
- receivingAddress: this._receivingAddress
- }
- }
+ txnRequest() {
+ return {
+ atAddress: this._atAddress,
+ foreignKey: this._foreignKey,
+ receivingAddress: this._receivingAddress,
+ };
+ }
}
diff --git a/src/transactions/TransactionBase.ts b/src/transactions/TransactionBase.ts
index ca9e7ea..055a08b 100644
--- a/src/transactions/TransactionBase.ts
+++ b/src/transactions/TransactionBase.ts
@@ -1,165 +1,188 @@
// @ts-nocheck
-import nacl from '../deps/nacl-fast'
-import Base58 from '../deps/Base58'
-import utils from '../utils/utils'
-import { QORT_DECIMALS, TX_TYPES } from '../constants/constants.js'
-
+import nacl from '../deps/nacl-fast';
+import Base58 from '../deps/Base58';
+import utils from '../utils/utils';
+import { QORT_DECIMALS, TX_TYPES } from '../constants/constants.js';
export default class TransactionBase {
- static get utils() {
- return utils
- }
- static get nacl() {
- return nacl
- }
- static get Base58() {
- return Base58
- }
+ static get utils() {
+ return utils;
+ }
+ static get nacl() {
+ return nacl;
+ }
+ static get Base58() {
+ return Base58;
+ }
- constructor() {
- this.fee = 0
- this.groupID = 0
- this.timestamp = Date.now()
- this.tests = [
- () => {
- if (!(this._type >= 1 && this._type in TX_TYPES)) {
- return 'Invalid type: ' + this.type
- }
- return true
- },
- () => {
- if (this._fee < 0) {
- return 'Invalid fee: ' + this._fee / QORT_DECIMALS
- }
- return true
- },
- () => {
- if (this._groupID < 0 || !Number.isInteger(this._groupID)) {
- return 'Invalid groupID: ' + this._groupID
- }
- return true
- },
- () => {
- if (!(new Date(this._timestamp)).getTime() > 0) {
- return 'Invalid timestamp: ' + this._timestamp
- }
- return true
- },
- () => {
- if (!(this._lastReference instanceof Uint8Array && this._lastReference.byteLength == 64)) {
- if (this._lastReference == 0) {
- return 'Invalid last reference. Please ensure that you have at least 0.001 QORT for the transaction fee.'
- }
- return 'Invalid last reference: ' + this._lastReference
- }
- return true
- },
- () => {
- if (!(this._keyPair)) {
- return 'keyPair must be specified'
- }
- if (!(this._keyPair.publicKey instanceof Uint8Array && this._keyPair.publicKey.byteLength === 32)) {
- return 'Invalid publicKey'
- }
- if (!(this._keyPair.privateKey instanceof Uint8Array && this._keyPair.privateKey.byteLength === 64)) {
- return 'Invalid privateKey'
- }
- return true
- }
- ]
- }
+ constructor() {
+ this.fee = 0;
+ this.groupID = 0;
+ this.timestamp = Date.now();
+ this.tests = [
+ () => {
+ if (!(this._type >= 1 && this._type in TX_TYPES)) {
+ return 'Invalid type: ' + this.type;
+ }
+ return true;
+ },
+ () => {
+ if (this._fee < 0) {
+ return 'Invalid fee: ' + this._fee / QORT_DECIMALS;
+ }
+ return true;
+ },
+ () => {
+ if (this._groupID < 0 || !Number.isInteger(this._groupID)) {
+ return 'Invalid groupID: ' + this._groupID;
+ }
+ return true;
+ },
+ () => {
+ if (!new Date(this._timestamp).getTime() > 0) {
+ return 'Invalid timestamp: ' + this._timestamp;
+ }
+ return true;
+ },
+ () => {
+ if (
+ !(
+ this._lastReference instanceof Uint8Array &&
+ this._lastReference.byteLength == 64
+ )
+ ) {
+ if (this._lastReference == 0) {
+ return 'Invalid last reference. Please ensure that you have at least 0.001 QORT for the transaction fee.';
+ }
+ return 'Invalid last reference: ' + this._lastReference;
+ }
+ return true;
+ },
+ () => {
+ if (!this._keyPair) {
+ return 'keyPair must be specified';
+ }
+ if (
+ !(
+ this._keyPair.publicKey instanceof Uint8Array &&
+ this._keyPair.publicKey.byteLength === 32
+ )
+ ) {
+ return 'Invalid publicKey';
+ }
+ if (
+ !(
+ this._keyPair.privateKey instanceof Uint8Array &&
+ this._keyPair.privateKey.byteLength === 64
+ )
+ ) {
+ return 'Invalid privateKey';
+ }
+ return true;
+ },
+ ];
+ }
- set keyPair(keyPair) {
- this._keyPair = keyPair
- }
+ set keyPair(keyPair) {
+ this._keyPair = keyPair;
+ }
- set type(type) {
- this.typeText = TX_TYPES[type]
- this._type = type
- this._typeBytes = this.constructor.utils.int32ToBytes(this._type)
- }
+ set type(type) {
+ this.typeText = TX_TYPES[type];
+ this._type = type;
+ this._typeBytes = this.constructor.utils.int32ToBytes(this._type);
+ }
- set groupID(groupID) {
- this._groupID = groupID
- this._groupIDBytes = this.constructor.utils.int32ToBytes(this._groupID)
- }
+ set groupID(groupID) {
+ this._groupID = groupID;
+ this._groupIDBytes = this.constructor.utils.int32ToBytes(this._groupID);
+ }
- set timestamp(timestamp) {
- this._timestamp = timestamp
- this._timestampBytes = this.constructor.utils.int64ToBytes(this._timestamp)
- }
+ set timestamp(timestamp) {
+ this._timestamp = timestamp;
+ this._timestampBytes = this.constructor.utils.int64ToBytes(this._timestamp);
+ }
- set fee(fee) {
- this._fee = fee * QORT_DECIMALS
- this._feeBytes = this.constructor.utils.int64ToBytes(this._fee)
- }
+ set fee(fee) {
+ this._fee = fee * QORT_DECIMALS;
+ this._feeBytes = this.constructor.utils.int64ToBytes(this._fee);
+ }
- set lastReference(lastReference) {
- this._lastReference = lastReference instanceof Uint8Array ? lastReference : this.constructor.Base58.decode(lastReference)
- }
+ set lastReference(lastReference) {
+ this._lastReference =
+ lastReference instanceof Uint8Array
+ ? lastReference
+ : this.constructor.Base58.decode(lastReference);
+ }
- get params() {
- return [
- this._typeBytes,
- this._timestampBytes,
- this._groupIDBytes,
- this._lastReference,
- this._keyPair.publicKey
- ]
- }
+ get params() {
+ return [
+ this._typeBytes,
+ this._timestampBytes,
+ this._groupIDBytes,
+ this._lastReference,
+ this._keyPair.publicKey,
+ ];
+ }
- get signedBytes() {
- if (!this._signedBytes) {
- this.sign()
- }
- return this._signedBytes
- }
+ get signedBytes() {
+ if (!this._signedBytes) {
+ this.sign();
+ }
+ return this._signedBytes;
+ }
- validParams() {
- let finalResult = {
- valid: true
- }
- this.tests.some(test => {
- const result = test()
- if (result !== true) {
- finalResult = {
- valid: false,
- message: result
- }
- return true // exists the loop
- }
- })
- return finalResult
- }
+ validParams() {
+ let finalResult = {
+ valid: true,
+ };
+ this.tests.some((test) => {
+ const result = test();
+ if (result !== true) {
+ finalResult = {
+ valid: false,
+ message: result,
+ };
+ return true; // exists the loop
+ }
+ });
+ return finalResult;
+ }
- generateBase() {
- const isValid = this.validParams()
- if (!isValid.valid) {
- throw new Error(isValid.message)
- }
- let result = new Uint8Array()
+ generateBase() {
+ const isValid = this.validParams();
+ if (!isValid.valid) {
+ throw new Error(isValid.message);
+ }
+ let result = new Uint8Array();
- this.params.forEach(item => {
- result = this.constructor.utils.appendBuffer(result, item)
- })
+ this.params.forEach((item) => {
+ result = this.constructor.utils.appendBuffer(result, item);
+ });
- this._base = result
- return result
- }
+ this._base = result;
+ return result;
+ }
- sign() {
- if (!this._keyPair) {
- throw new Error('keyPair not defined')
- }
+ sign() {
+ if (!this._keyPair) {
+ throw new Error('keyPair not defined');
+ }
- if (!this._base) {
- this.generateBase()
- }
+ if (!this._base) {
+ this.generateBase();
+ }
- this._signature = this.constructor.nacl.sign.detached(this._base, this._keyPair.privateKey)
+ this._signature = this.constructor.nacl.sign.detached(
+ this._base,
+ this._keyPair.privateKey
+ );
- this._signedBytes = this.constructor.utils.appendBuffer(this._base, this._signature)
+ this._signedBytes = this.constructor.utils.appendBuffer(
+ this._base,
+ this._signature
+ );
- return this._signature
- }
+ return this._signature;
+ }
}
diff --git a/src/transactions/TransferAssetTransaction.ts b/src/transactions/TransferAssetTransaction.ts
index 9d0bedb..31bc69a 100644
--- a/src/transactions/TransferAssetTransaction.ts
+++ b/src/transactions/TransferAssetTransaction.ts
@@ -1,35 +1,37 @@
// @ts-nocheck
-import { QORT_DECIMALS } from '../constants/constants'
-import TransactionBase from './TransactionBase'
-
+import { QORT_DECIMALS } from '../constants/constants';
+import TransactionBase from './TransactionBase';
export default class TransferAssetTransaction extends TransactionBase {
constructor() {
- super()
- this.type = 12
+ super();
+ this.type = 12;
}
set recipient(recipient) {
- this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient)
+ this._recipient =
+ recipient instanceof Uint8Array
+ ? recipient
+ : this.constructor.Base58.decode(recipient);
}
set amount(amount) {
- this._amount = Math.round(amount * QORT_DECIMALS)
- this._amountBytes = this.constructor.utils.int64ToBytes(this._amount)
+ this._amount = Math.round(amount * QORT_DECIMALS);
+ this._amountBytes = this.constructor.utils.int64ToBytes(this._amount);
}
set assetId(assetId) {
- this._assetId = this.constructor.utils.int64ToBytes(assetId)
+ this._assetId = this.constructor.utils.int64ToBytes(assetId);
}
get params() {
- const params = super.params
+ const params = super.params;
params.push(
this._recipient,
this._assetId,
this._amountBytes,
this._feeBytes
- )
- return params
+ );
+ return params;
}
}
diff --git a/src/transactions/UpdateGroupTransaction.ts b/src/transactions/UpdateGroupTransaction.ts
index 9d9856b..cc0ce48 100644
--- a/src/transactions/UpdateGroupTransaction.ts
+++ b/src/transactions/UpdateGroupTransaction.ts
@@ -1,62 +1,64 @@
// @ts-nocheck
-
-import { QORT_DECIMALS } from "../constants/constants";
-import TransactionBase from "./TransactionBase";
-
+import { QORT_DECIMALS } from '../constants/constants';
+import TransactionBase from './TransactionBase';
export default class UpdateGroupTransaction extends TransactionBase {
- constructor() {
- super()
- this.type = 23
- }
+ constructor() {
+ super();
+ this.type = 23;
+ }
+ set fee(fee) {
+ this._fee = fee * QORT_DECIMALS;
+ this._feeBytes = this.constructor.utils.int64ToBytes(this._fee);
+ }
+ set newOwner(newOwner) {
+ this._newOwner =
+ newOwner instanceof Uint8Array
+ ? newOwner
+ : this.constructor.Base58.decode(newOwner);
+ }
+ set newIsOpen(newIsOpen) {
+ this._rGroupType = new Uint8Array(1);
+ this._rGroupType[0] = newIsOpen;
+ }
+ set newDescription(newDescription) {
+ this._rGroupDescBytes = this.constructor.utils.stringtoUTF8Array(
+ newDescription.toLocaleLowerCase()
+ );
+ this._rGroupDescLength = this.constructor.utils.int32ToBytes(
+ this._rGroupDescBytes.length
+ );
+ }
+ set newApprovalThreshold(newApprovalThreshold) {
+ this._rGroupApprovalThreshold = new Uint8Array(1);
+ this._rGroupApprovalThreshold[0] = newApprovalThreshold;
+ }
+ set newMinimumBlockDelay(newMinimumBlockDelay) {
+ this._rGroupMinimumBlockDelayBytes =
+ this.constructor.utils.int32ToBytes(newMinimumBlockDelay);
+ }
+ set newMaximumBlockDelay(newMaximumBlockDelay) {
+ this._rGroupMaximumBlockDelayBytes =
+ this.constructor.utils.int32ToBytes(newMaximumBlockDelay);
+ }
-
-
- set fee(fee) {
- this._fee = fee * QORT_DECIMALS
- this._feeBytes = this.constructor.utils.int64ToBytes(this._fee)
- }
- set newOwner(newOwner) {
- this._newOwner = newOwner instanceof Uint8Array ? newOwner : this.constructor.Base58.decode(newOwner)
- }
- set newIsOpen(newIsOpen) {
-
- this._rGroupType = new Uint8Array(1)
- this._rGroupType[0] = newIsOpen
- }
- set newDescription(newDescription) {
- this._rGroupDescBytes = this.constructor.utils.stringtoUTF8Array(newDescription.toLocaleLowerCase())
- this._rGroupDescLength = this.constructor.utils.int32ToBytes(this._rGroupDescBytes.length)
- }
- set newApprovalThreshold(newApprovalThreshold) {
- this._rGroupApprovalThreshold = new Uint8Array(1)
- this._rGroupApprovalThreshold[0] = newApprovalThreshold;
- }
- set newMinimumBlockDelay(newMinimumBlockDelay) {
- this._rGroupMinimumBlockDelayBytes = this.constructor.utils.int32ToBytes(newMinimumBlockDelay)
- }
- set newMaximumBlockDelay(newMaximumBlockDelay) {
-
- this._rGroupMaximumBlockDelayBytes = this.constructor.utils.int32ToBytes(newMaximumBlockDelay)
- }
-
- set _groupId(_groupId){
- this._groupBytes = this.constructor.utils.int32ToBytes(_groupId)
- }
- get params() {
- const params = super.params
- params.push(
- this._groupBytes,
- this._newOwner,
- this._rGroupDescLength,
- this._rGroupDescBytes,
- this._rGroupType,
- this._rGroupApprovalThreshold,
- this._rGroupMinimumBlockDelayBytes,
- this._rGroupMaximumBlockDelayBytes,
- this._feeBytes
- )
- return params
- }
-}
\ No newline at end of file
+ set _groupId(_groupId) {
+ this._groupBytes = this.constructor.utils.int32ToBytes(_groupId);
+ }
+ get params() {
+ const params = super.params;
+ params.push(
+ this._groupBytes,
+ this._newOwner,
+ this._rGroupDescLength,
+ this._rGroupDescBytes,
+ this._rGroupType,
+ this._rGroupApprovalThreshold,
+ this._rGroupMinimumBlockDelayBytes,
+ this._rGroupMaximumBlockDelayBytes,
+ this._feeBytes
+ );
+ return params;
+ }
+}
diff --git a/src/transactions/UpdateNameTransaction.ts b/src/transactions/UpdateNameTransaction.ts
index e90b388..1aee16e 100644
--- a/src/transactions/UpdateNameTransaction.ts
+++ b/src/transactions/UpdateNameTransaction.ts
@@ -1,51 +1,56 @@
// @ts-nocheck
-import { QORT_DECIMALS } from "../constants/constants"
-import TransactionBase from "./TransactionBase"
-
-
+import { QORT_DECIMALS } from '../constants/constants';
+import TransactionBase from './TransactionBase';
export default class UpdateNameTransaction extends TransactionBase {
- constructor() {
- super()
- this.type = 4
- }
+ constructor() {
+ super();
+ this.type = 4;
+ }
+ set fee(fee) {
+ this._fee = fee * QORT_DECIMALS;
+ this._feeBytes = this.constructor.utils.int64ToBytes(this._fee);
+ }
+ set name(name) {
+ this.nameText = name;
+ this._nameBytes = this.constructor.utils.stringtoUTF8Array(name);
+ this._nameLength = this.constructor.utils.int32ToBytes(
+ this._nameBytes.length
+ );
+ }
- set fee(fee) {
- this._fee = fee * QORT_DECIMALS
- this._feeBytes = this.constructor.utils.int64ToBytes(this._fee)
- }
+ set newName(newName) {
+ this.newNameText = newName;
+ this._newNameBytes = this.constructor.utils.stringtoUTF8Array(newName);
+ this._newNameLength = this.constructor.utils.int32ToBytes(
+ this._newNameBytes.length
+ );
+ }
- set name(name) {
- this.nameText = name
- this._nameBytes = this.constructor.utils.stringtoUTF8Array(name)
- this._nameLength = this.constructor.utils.int32ToBytes(this._nameBytes.length)
- }
+ set newData(newData) {
+ this.newDataText =
+ newData.length === 0 ? 'Registered Name on the Qortal Chain' : newData;
+ this._newDataBytes = this.constructor.utils.stringtoUTF8Array(
+ this.newDataText
+ );
+ this._newDataLength = this.constructor.utils.int32ToBytes(
+ this._newDataBytes.length
+ );
+ }
- set newName(newName) {
- this.newNameText = newName
- this._newNameBytes = this.constructor.utils.stringtoUTF8Array(newName)
- this._newNameLength = this.constructor.utils.int32ToBytes(this._newNameBytes.length)
- }
-
- set newData(newData) {
- this.newDataText = newData.length === 0 ? "Registered Name on the Qortal Chain" : newData
- this._newDataBytes = this.constructor.utils.stringtoUTF8Array(this.newDataText)
- this._newDataLength = this.constructor.utils.int32ToBytes(this._newDataBytes.length)
- }
-
- get params() {
- const params = super.params
- params.push(
- this._nameLength,
- this._nameBytes,
- this._newNameLength,
- this._newNameBytes,
- this._newDataLength,
- this._newDataBytes,
- this._feeBytes
- )
- return params
- }
+ get params() {
+ const params = super.params;
+ params.push(
+ this._nameLength,
+ this._nameBytes,
+ this._newNameLength,
+ this._newNameBytes,
+ this._newDataLength,
+ this._newDataBytes,
+ this._feeBytes
+ );
+ return params;
+ }
}
diff --git a/src/transactions/VoteOnPollTransaction.ts b/src/transactions/VoteOnPollTransaction.ts
index 327295e..5b37163 100644
--- a/src/transactions/VoteOnPollTransaction.ts
+++ b/src/transactions/VoteOnPollTransaction.ts
@@ -1,38 +1,42 @@
// @ts-nocheck
-import { QORT_DECIMALS } from '../constants/constants'
-import TransactionBase from './TransactionBase'
-
+import { QORT_DECIMALS } from '../constants/constants';
+import TransactionBase from './TransactionBase';
export default class VoteOnPollTransaction extends TransactionBase {
- constructor() {
- super()
- this.type = 9
- }
+ constructor() {
+ super();
+ this.type = 9;
+ }
+ set fee(fee) {
+ this._fee = fee * QORT_DECIMALS;
+ this._feeBytes = this.constructor.utils.int64ToBytes(this._fee);
+ }
- set fee(fee) {
- this._fee = fee * QORT_DECIMALS
- this._feeBytes = this.constructor.utils.int64ToBytes(this._fee)
- }
+ set rPollName(rPollName) {
+ this._rPollName = rPollName;
+ this._rPollNameBytes = this.constructor.utils.stringtoUTF8Array(
+ this._rPollName
+ );
+ this._rPollNameLength = this.constructor.utils.int32ToBytes(
+ this._rPollNameBytes.length
+ );
+ }
- set rPollName(rPollName) {
- this._rPollName = rPollName
- this._rPollNameBytes = this.constructor.utils.stringtoUTF8Array(this._rPollName)
- this._rPollNameLength = this.constructor.utils.int32ToBytes(this._rPollNameBytes.length)
- }
+ set rOptionIndex(rOptionIndex) {
+ this._rOptionIndex = rOptionIndex;
+ this._rOptionIndexBytes = this.constructor.utils.int32ToBytes(
+ this._rOptionIndex
+ );
+ }
- set rOptionIndex(rOptionIndex) {
- this._rOptionIndex = rOptionIndex
- this._rOptionIndexBytes = this.constructor.utils.int32ToBytes(this._rOptionIndex)
- }
-
- get params() {
- const params = super.params
- params.push(
- this._rPollNameLength,
- this._rPollNameBytes,
- this._rOptionIndexBytes,
- this._feeBytes
- )
- return params
- }
+ get params() {
+ const params = super.params;
+ params.push(
+ this._rPollNameLength,
+ this._rPollNameBytes,
+ this._rOptionIndexBytes,
+ this._feeBytes
+ );
+ return params;
+ }
}
diff --git a/src/transactions/signChat.ts b/src/transactions/signChat.ts
index 8814c2a..5995128 100644
--- a/src/transactions/signChat.ts
+++ b/src/transactions/signChat.ts
@@ -1,39 +1,40 @@
// @ts-nocheck
-import nacl from '../deps/nacl-fast'
-import utils from '../utils/utils'
+import nacl from '../deps/nacl-fast';
+import utils from '../utils/utils';
export const signChat = (chatBytes, nonce, keyPair) => {
- if (!chatBytes) {
- throw new Error('Chat Bytes not defined')
- }
+ if (!chatBytes) {
+ throw new Error('Chat Bytes not defined');
+ }
- if (!nonce) {
- throw new Error('Nonce not defined')
- }
+ if (!nonce) {
+ throw new Error('Nonce not defined');
+ }
- if (!keyPair) {
- throw new Error('keyPair not defined')
- }
+ if (!keyPair) {
+ throw new Error('keyPair not defined');
+ }
- const _nonce = utils.int32ToBytes(nonce)
+ const _nonce = utils.int32ToBytes(nonce);
- if (chatBytes.length === undefined) {
- const _chatBytesBuffer = Object.keys(chatBytes).map(function (key) { return chatBytes[key]; })
+ if (chatBytes.length === undefined) {
+ const _chatBytesBuffer = Object.keys(chatBytes).map(function (key) {
+ return chatBytes[key];
+ });
- const chatBytesBuffer = new Uint8Array(_chatBytesBuffer)
- chatBytesBuffer.set(_nonce, 112)
+ const chatBytesBuffer = new Uint8Array(_chatBytesBuffer);
+ chatBytesBuffer.set(_nonce, 112);
- const signature = nacl.sign.detached(chatBytesBuffer, keyPair.privateKey)
+ const signature = nacl.sign.detached(chatBytesBuffer, keyPair.privateKey);
- return utils.appendBuffer(chatBytesBuffer, signature)
- } else {
- const chatBytesBuffer = new Uint8Array(chatBytes)
- chatBytesBuffer.set(_nonce, 112)
+ return utils.appendBuffer(chatBytesBuffer, signature);
+ } else {
+ const chatBytesBuffer = new Uint8Array(chatBytes);
+ chatBytesBuffer.set(_nonce, 112);
- const signature = nacl.sign.detached(chatBytesBuffer, keyPair.privateKey)
-
- return utils.appendBuffer(chatBytesBuffer, signature)
- }
-}
+ const signature = nacl.sign.detached(chatBytesBuffer, keyPair.privateKey);
+ return utils.appendBuffer(chatBytesBuffer, signature);
+ }
+};
diff --git a/src/transactions/signTradeBotTransaction.ts b/src/transactions/signTradeBotTransaction.ts
index 929898f..31b7430 100644
--- a/src/transactions/signTradeBotTransaction.ts
+++ b/src/transactions/signTradeBotTransaction.ts
@@ -1,30 +1,31 @@
// @ts-nocheck
-
-import nacl from '../deps/nacl-fast'
-import Base58 from '../deps/Base58'
-import utils from '../utils/utils'
+import nacl from '../deps/nacl-fast';
+import Base58 from '../deps/Base58';
+import utils from '../utils/utils';
const signTradeBotTransaction = async (unsignedTxn, keyPair) => {
- if (!unsignedTxn) {
- throw new Error('Unsigned Transaction Bytes not defined')
- }
+ if (!unsignedTxn) {
+ throw new Error('Unsigned Transaction Bytes not defined');
+ }
- if (!keyPair) {
- throw new Error('keyPair not defined')
- }
+ if (!keyPair) {
+ throw new Error('keyPair not defined');
+ }
- const txnBuffer = Base58.decode(unsignedTxn)
+ const txnBuffer = Base58.decode(unsignedTxn);
- if (keyPair.privateKey.length === undefined) {
- const _privateKey = Object.keys(keyPair.privateKey).map(function (key) { return keyPair.privateKey[key] })
- const privateKey = new Uint8Array(_privateKey)
- const signature = nacl.sign.detached(txnBuffer, privateKey)
- return utils.appendBuffer(txnBuffer, signature)
- } else {
- const signature = nacl.sign.detached(txnBuffer, keyPair.privateKey)
- return utils.appendBuffer(txnBuffer, signature)
- }
-}
+ if (keyPair.privateKey.length === undefined) {
+ const _privateKey = Object.keys(keyPair.privateKey).map(function (key) {
+ return keyPair.privateKey[key];
+ });
+ const privateKey = new Uint8Array(_privateKey);
+ const signature = nacl.sign.detached(txnBuffer, privateKey);
+ return utils.appendBuffer(txnBuffer, signature);
+ } else {
+ const signature = nacl.sign.detached(txnBuffer, keyPair.privateKey);
+ return utils.appendBuffer(txnBuffer, signature);
+ }
+};
-export default signTradeBotTransaction
+export default signTradeBotTransaction;
diff --git a/src/transactions/transactions.ts b/src/transactions/transactions.ts
index a117560..816e2b6 100644
--- a/src/transactions/transactions.ts
+++ b/src/transactions/transactions.ts
@@ -1,68 +1,65 @@
// @ts-nocheck
-import PaymentTransaction from './PaymentTransaction.js'
-import ChatTransaction from './ChatTransaction.js'
-import GroupChatTransaction from './GroupChatTransaction.js'
-import GroupInviteTransaction from './GroupInviteTransaction.js'
-import CancelGroupInviteTransaction from './CancelGroupInviteTransaction.js'
-import GroupKickTransaction from './GroupKickTransaction.js'
-import GroupBanTransaction from './GroupBanTransaction.js'
-import CancelGroupBanTransaction from './CancelGroupBanTransaction.js'
-import CreateGroupTransaction from './CreateGroupTransaction.js'
-import LeaveGroupTransaction from './LeaveGroupTransaction.js'
-import JoinGroupTransaction from './JoinGroupTransaction.js'
-import AddGroupAdminTransaction from './AddGroupAdminTransaction.js'
-import RemoveGroupAdminTransaction from './RemoveGroupAdminTransaction.js'
-import RegisterNameTransaction from './RegisterNameTransaction.js'
-import VoteOnPollTransaction from './VoteOnPollTransaction.js'
-import CreatePollTransaction from './CreatePollTransaction.js'
-import DeployAtTransaction from './DeployAtTransaction.js'
-import RewardShareTransaction from './RewardShareTransaction.js'
-import RemoveRewardShareTransaction from './RemoveRewardShareTransaction.js'
-import UpdateNameTransaction from './UpdateNameTransaction.js'
-import UpdateGroupTransaction from './UpdateGroupTransaction.js'
-import SellNameTransacion from './SellNameTransacion.js'
-import CancelSellNameTransacion from './CancelSellNameTransacion.js'
-import BuyNameTransacion from './BuyNameTransacion.js'
-import TransferAssetTransaction from './TransferAssetTransaction.js'
-
+import PaymentTransaction from './PaymentTransaction.js';
+import ChatTransaction from './ChatTransaction.js';
+import GroupChatTransaction from './GroupChatTransaction.js';
+import GroupInviteTransaction from './GroupInviteTransaction.js';
+import CancelGroupInviteTransaction from './CancelGroupInviteTransaction.js';
+import GroupKickTransaction from './GroupKickTransaction.js';
+import GroupBanTransaction from './GroupBanTransaction.js';
+import CancelGroupBanTransaction from './CancelGroupBanTransaction.js';
+import CreateGroupTransaction from './CreateGroupTransaction.js';
+import LeaveGroupTransaction from './LeaveGroupTransaction.js';
+import JoinGroupTransaction from './JoinGroupTransaction.js';
+import AddGroupAdminTransaction from './AddGroupAdminTransaction.js';
+import RemoveGroupAdminTransaction from './RemoveGroupAdminTransaction.js';
+import RegisterNameTransaction from './RegisterNameTransaction.js';
+import VoteOnPollTransaction from './VoteOnPollTransaction.js';
+import CreatePollTransaction from './CreatePollTransaction.js';
+import DeployAtTransaction from './DeployAtTransaction.js';
+import RewardShareTransaction from './RewardShareTransaction.js';
+import RemoveRewardShareTransaction from './RemoveRewardShareTransaction.js';
+import UpdateNameTransaction from './UpdateNameTransaction.js';
+import UpdateGroupTransaction from './UpdateGroupTransaction.js';
+import SellNameTransacion from './SellNameTransacion.js';
+import CancelSellNameTransacion from './CancelSellNameTransacion.js';
+import BuyNameTransacion from './BuyNameTransacion.js';
+import TransferAssetTransaction from './TransferAssetTransaction.js';
export const transactionTypes = {
- 2: PaymentTransaction,
- 3: RegisterNameTransaction,
- 4: UpdateNameTransaction,
- 5: SellNameTransacion,
- 6: CancelSellNameTransacion,
- 7: BuyNameTransacion,
- 8: CreatePollTransaction,
- 9: VoteOnPollTransaction,
- 12: TransferAssetTransaction,
- 16: DeployAtTransaction,
- 18: ChatTransaction,
- 181: GroupChatTransaction,
- 22: CreateGroupTransaction,
- 23: UpdateGroupTransaction,
- 24: AddGroupAdminTransaction,
- 25: RemoveGroupAdminTransaction,
- 26: GroupBanTransaction,
- 27: CancelGroupBanTransaction,
- 28: GroupKickTransaction,
- 29: GroupInviteTransaction,
- 30: CancelGroupInviteTransaction,
- 31: JoinGroupTransaction,
- 32: LeaveGroupTransaction,
- 38: RewardShareTransaction,
- 381: RemoveRewardShareTransaction
-}
-
+ 2: PaymentTransaction,
+ 3: RegisterNameTransaction,
+ 4: UpdateNameTransaction,
+ 5: SellNameTransacion,
+ 6: CancelSellNameTransacion,
+ 7: BuyNameTransacion,
+ 8: CreatePollTransaction,
+ 9: VoteOnPollTransaction,
+ 12: TransferAssetTransaction,
+ 16: DeployAtTransaction,
+ 18: ChatTransaction,
+ 181: GroupChatTransaction,
+ 22: CreateGroupTransaction,
+ 23: UpdateGroupTransaction,
+ 24: AddGroupAdminTransaction,
+ 25: RemoveGroupAdminTransaction,
+ 26: GroupBanTransaction,
+ 27: CancelGroupBanTransaction,
+ 28: GroupKickTransaction,
+ 29: GroupInviteTransaction,
+ 30: CancelGroupInviteTransaction,
+ 31: JoinGroupTransaction,
+ 32: LeaveGroupTransaction,
+ 38: RewardShareTransaction,
+ 381: RemoveRewardShareTransaction,
+};
export const createTransaction = (type, keyPair, params) => {
- const tx = new transactionTypes[type]()
- tx.keyPair = keyPair
- Object.keys(params).forEach(param => {
-
- tx[param] = params[param]
- })
+ const tx = new transactionTypes[type]();
+ tx.keyPair = keyPair;
+ Object.keys(params).forEach((param) => {
+ tx[param] = params[param];
+ });
- return tx
-}
\ No newline at end of file
+ return tx;
+};
diff --git a/src/utils/decode.ts b/src/utils/decode.ts
index ba8d87d..d457cee 100644
--- a/src/utils/decode.ts
+++ b/src/utils/decode.ts
@@ -17,7 +17,6 @@ export function decodeIfEncoded(input) {
export const isValidBase64 = (str: string): boolean => {
if (typeof str !== 'string' || str.length % 4 !== 0) return false;
-
const base64Regex = /^[A-Za-z0-9+/]*={0,2}$/;
return base64Regex.test(str);
};
diff --git a/src/utils/generateWallet/generateWallet.ts b/src/utils/generateWallet/generateWallet.ts
index f05c707..ee3a683 100644
--- a/src/utils/generateWallet/generateWallet.ts
+++ b/src/utils/generateWallet/generateWallet.ts
@@ -5,119 +5,123 @@ import { doInitWorkers, kdf } from '../../deps/kdf';
import PhraseWallet from './phrase-wallet';
import * as WORDLISTS from './wordlists';
import FileSaver from 'file-saver';
-
import { Filesystem, Directory, Encoding } from '@capacitor/filesystem';
import { mimeToExtensionMap } from '../memeTypes';
-export function generateRandomSentence(template = 'adverb verb noun adjective noun adverb verb noun adjective noun adjective verbed adjective noun', maxWordLength = 0, capitalize = true) {
- const partsOfSpeechMap = {
- 'noun': 'nouns',
- 'adverb': 'adverbs',
- 'adv': 'adverbs',
- 'verb': 'verbs',
- 'interjection': 'interjections',
- 'adjective': 'adjectives',
- 'adj': 'adjectives',
- 'verbed': 'verbed'
- };
- let _wordlists = WORDLISTS;
-
- function _RNG(entropy) {
- if (entropy > 1074) {
- throw new Error('Javascript can not handle that much entropy!');
- }
- let randNum = 0;
- const crypto = window.crypto || window.msCrypto;
-
- if (crypto) {
- const entropy256 = Math.ceil(entropy / 8);
- let buffer = new Uint8Array(entropy256);
- crypto.getRandomValues(buffer);
- randNum = buffer.reduce((num, value) => num * 256 + value, 0) / Math.pow(256, entropy256);
- } else {
- console.warn('Secure RNG not found. Using Math.random');
- randNum = Math.random();
- }
- return randNum;
- }
-
- function _capitalize(str) {
- return str.charAt(0).toUpperCase() + str.slice(1);
- }
-
- function getWord(partOfSpeech) {
- let words = _wordlists[partsOfSpeechMap[partOfSpeech]];
- if (maxWordLength) {
- words = words.filter(word => word.length <= maxWordLength);
- }
- const requiredEntropy = Math.log(words.length) / Math.log(2);
- const index = Math.floor(_RNG(requiredEntropy) * words.length);
- return words[index];
- }
-
- function parse(template) {
- return template.split(/\s+/).map(token => {
- const match = token.match(/^(\w+)(.*)$/);
- if (!match) return token; // No match, return original token
-
- const [ , partOfSpeech, rest ] = match;
- if (partsOfSpeechMap[partOfSpeech]) {
- let word = getWord(partOfSpeech);
- if (capitalize && token === token[0].toUpperCase() + token.slice(1).toLowerCase()) {
- word = _capitalize(word);
- }
- return word + rest;
- }
-
- return token;
- }).join(' ');
- }
-
- return parse(template);
-}
-
-export const createAccount = async(generatedSeedPhrase)=> {
- if(!generatedSeedPhrase) throw new Error('No generated seed-phrase')
- const threads = doInitWorkers(crypto.kdfThreads)
-
- const seed = await kdf(generatedSeedPhrase, void 0, threads)
- const wallet = new PhraseWallet(seed, walletVersion)
- return wallet
-
- }
-
- const hasExtension = (filename) => {
- return filename.includes(".") && filename.split(".").pop().length > 0;
+export function generateRandomSentence(
+ template = 'adverb verb noun adjective noun adverb verb noun adjective noun adjective verbed adjective noun',
+ maxWordLength = 0,
+ capitalize = true
+) {
+ const partsOfSpeechMap = {
+ noun: 'nouns',
+ adverb: 'adverbs',
+ adv: 'adverbs',
+ verb: 'verbs',
+ interjection: 'interjections',
+ adjective: 'adjectives',
+ adj: 'adjectives',
+ verbed: 'verbed',
};
- export const saveFileToDisk = async (data, qortAddress) => {
-
- const dataString = JSON.stringify(data);
- const blob = new Blob([dataString], { type: 'application/json' });
- const fileName = "qortal_backup_" + qortAddress + ".json";
+ let _wordlists = WORDLISTS;
- await FileSaver.saveAs(blob, fileName);
-
+ function _RNG(entropy) {
+ if (entropy > 1074) {
+ throw new Error('Javascript can not handle that much entropy!');
+ }
+ let randNum = 0;
+ const crypto = window.crypto || window.msCrypto;
+
+ if (crypto) {
+ const entropy256 = Math.ceil(entropy / 8);
+ let buffer = new Uint8Array(entropy256);
+ crypto.getRandomValues(buffer);
+ randNum =
+ buffer.reduce((num, value) => num * 256 + value, 0) /
+ Math.pow(256, entropy256);
+ } else {
+ console.warn('Secure RNG not found. Using Math.random');
+ randNum = Math.random();
+ }
+ return randNum;
+ }
+
+ function _capitalize(str) {
+ return str.charAt(0).toUpperCase() + str.slice(1);
+ }
+
+ function getWord(partOfSpeech) {
+ let words = _wordlists[partsOfSpeechMap[partOfSpeech]];
+ if (maxWordLength) {
+ words = words.filter((word) => word.length <= maxWordLength);
+ }
+ const requiredEntropy = Math.log(words.length) / Math.log(2);
+ const index = Math.floor(_RNG(requiredEntropy) * words.length);
+ return words[index];
+ }
+
+ function parse(template) {
+ return template
+ .split(/\s+/)
+ .map((token) => {
+ const match = token.match(/^(\w+)(.*)$/);
+ if (!match) return token; // No match, return original token
+
+ const [, partOfSpeech, rest] = match;
+ if (partsOfSpeechMap[partOfSpeech]) {
+ let word = getWord(partOfSpeech);
+ if (
+ capitalize &&
+ token === token[0].toUpperCase() + token.slice(1).toLowerCase()
+ ) {
+ word = _capitalize(word);
+ }
+ return word + rest;
+ }
+
+ return token;
+ })
+ .join(' ');
+ }
+
+ return parse(template);
}
+export const createAccount = async (generatedSeedPhrase) => {
+ if (!generatedSeedPhrase) throw new Error('No generated seed-phrase');
+ const threads = doInitWorkers(crypto.kdfThreads);
+
+ const seed = await kdf(generatedSeedPhrase, void 0, threads);
+ const wallet = new PhraseWallet(seed, walletVersion);
+ return wallet;
+};
+
+const hasExtension = (filename) => {
+ return filename.includes('.') && filename.split('.').pop().length > 0;
+};
+
+export const saveFileToDisk = async (data, qortAddress) => {
+ const dataString = JSON.stringify(data);
+ const blob = new Blob([dataString], { type: 'application/json' });
+ const fileName = 'qortal_backup_' + qortAddress + '.json';
+
+ await FileSaver.saveAs(blob, fileName);
+};
+
export const saveFileToDiskGeneric = async (blob, filename) => {
- const timestamp = new Date()
- .toISOString()
- .replace(/:/g, "-"); // Safe timestamp for filenames
-
- const fileExtension = mimeToExtensionMap[blob.type]
-let fileName = filename || "qortal_file_" + timestamp + "." + fileExtension;
-fileName = hasExtension(fileName) ? fileName : fileName + "." + fileExtension;
+ const timestamp = new Date().toISOString().replace(/:/g, '-'); // Safe timestamp for filenames
-await FileSaver.saveAs(blob, fileName);
+ const fileExtension = mimeToExtensionMap[blob.type];
+ let fileName = filename || 'qortal_file_' + timestamp + '.' + fileExtension;
+ fileName = hasExtension(fileName) ? fileName : fileName + '.' + fileExtension;
-}
+ await FileSaver.saveAs(blob, fileName);
+};
export const saveSeedPhraseToDisk = async (data) => {
-
- const blob = new Blob([data], { type: 'text/plain;charset=utf-8' })
- const fileName = "qortal_seedphrase.txt"
+ const blob = new Blob([data], { type: 'text/plain;charset=utf-8' });
+ const fileName = 'qortal_seedphrase.txt';
-await FileSaver.saveAs(blob, fileName);
-
-}
\ No newline at end of file
+ await FileSaver.saveAs(blob, fileName);
+};
diff --git a/src/utils/generateWallet/storeWallet.ts b/src/utils/generateWallet/storeWallet.ts
index 83222ae..458543f 100644
--- a/src/utils/generateWallet/storeWallet.ts
+++ b/src/utils/generateWallet/storeWallet.ts
@@ -1,31 +1,37 @@
// @ts-nocheck
-import {AES_CBC, HmacSha512} from 'asmcrypto.js'
+import { AES_CBC, HmacSha512 } from 'asmcrypto.js';
+import Base58 from '../../deps/Base58';
+import { doInitWorkers, kdf } from '../../deps/kdf.js';
+import { crypto as cryptoVals } from '../../constants/decryptWallet.js';
-import Base58 from '../../deps/Base58'
-import { doInitWorkers, kdf } from '../../deps/kdf.js'
-import { crypto as cryptoVals } from '../../constants/decryptWallet.js'
-
-const getRandomValues = crypto ? crypto.getRandomValues.bind(crypto) : msCrypto.getRandomValues.bind(msCrypto)
+const getRandomValues = crypto
+ ? crypto.getRandomValues.bind(crypto)
+ : msCrypto.getRandomValues.bind(msCrypto);
export const generateSaveWalletData = async (wallet, password, kdfThreads) => {
- const threads = doInitWorkers(cryptoVals.kdfThreads)
+ const threads = doInitWorkers(cryptoVals.kdfThreads);
- let iv = new Uint8Array(16)
- getRandomValues(iv)
- let salt = new Uint8Array(32)
- getRandomValues(salt)
- const key = await kdf(password, salt, threads)
- const encryptionKey = key.slice(0, 32)
- const macKey = key.slice(32, 63)
- const encryptedSeed = AES_CBC.encrypt(wallet._byteSeed, encryptionKey, false, iv)
- const mac = new HmacSha512(macKey).process(encryptedSeed).finish().result
- return {
- address0: wallet._addresses[0].address,
- encryptedSeed: Base58.encode(encryptedSeed),
- salt: Base58.encode(salt),
- iv: Base58.encode(iv),
- version: wallet._walletVersion,
- mac: Base58.encode(mac),
- kdfThreads
- }
-}
+ let iv = new Uint8Array(16);
+ getRandomValues(iv);
+ let salt = new Uint8Array(32);
+ getRandomValues(salt);
+ const key = await kdf(password, salt, threads);
+ const encryptionKey = key.slice(0, 32);
+ const macKey = key.slice(32, 63);
+ const encryptedSeed = AES_CBC.encrypt(
+ wallet._byteSeed,
+ encryptionKey,
+ false,
+ iv
+ );
+ const mac = new HmacSha512(macKey).process(encryptedSeed).finish().result;
+ return {
+ address0: wallet._addresses[0].address,
+ encryptedSeed: Base58.encode(encryptedSeed),
+ salt: Base58.encode(salt),
+ iv: Base58.encode(iv),
+ version: wallet._walletVersion,
+ mac: Base58.encode(mac),
+ kdfThreads,
+ };
+};
diff --git a/src/utils/generateWallet/verb-past-tense.ts b/src/utils/generateWallet/verb-past-tense.ts
index 2e9da0c..b3b12b3 100644
--- a/src/utils/generateWallet/verb-past-tense.ts
+++ b/src/utils/generateWallet/verb-past-tense.ts
@@ -2,36 +2,36 @@
// @ts-nocheck
export const EXCEPTIONS = {
- 'are': 'were',
- 'eat': 'ate',
- 'go': 'went',
- 'have': 'had',
- 'inherit': 'inherited',
- 'is': 'was',
- 'run': 'ran',
- 'sit': 'sat',
- 'visit': 'visited'
-}
+ are: 'were',
+ eat: 'ate',
+ go: 'went',
+ have: 'had',
+ inherit: 'inherited',
+ is: 'was',
+ run: 'ran',
+ sit: 'sat',
+ visit: 'visited',
+};
export const getPastTense = (verb, exceptions = EXCEPTIONS) => {
- if (exceptions[verb]) {
- return exceptions[verb]
- }
- if ((/e$/i).test(verb)) {
- return verb + 'd'
- }
- if ((/[aeiou]c$/i).test(verb)) {
- return verb + 'ked'
- }
- // for american english only
- if ((/el$/i).test(verb)) {
- return verb + 'ed'
- }
- if ((/[aeio][aeiou][dlmnprst]$/).test(verb)) {
- return verb + 'ed'
- }
- if ((/[aeiou][bdglmnprst]$/i).test(verb)) {
- return verb.replace(/(.+[aeiou])([bdglmnprst])/, '$1$2$2ed')
- }
- return verb + 'ed'
-}
+ if (exceptions[verb]) {
+ return exceptions[verb];
+ }
+ if (/e$/i.test(verb)) {
+ return verb + 'd';
+ }
+ if (/[aeiou]c$/i.test(verb)) {
+ return verb + 'ked';
+ }
+ // for american english only
+ if (/el$/i.test(verb)) {
+ return verb + 'ed';
+ }
+ if (/[aeio][aeiou][dlmnprst]$/.test(verb)) {
+ return verb + 'ed';
+ }
+ if (/[aeiou][bdglmnprst]$/i.test(verb)) {
+ return verb.replace(/(.+[aeiou])([bdglmnprst])/, '$1$2$2ed');
+ }
+ return verb + 'ed';
+};
diff --git a/src/utils/qortalLink/index.ts b/src/utils/qortalLink/index.ts
index bc2f132..0b884d6 100644
--- a/src/utils/qortalLink/index.ts
+++ b/src/utils/qortalLink/index.ts
@@ -1,12 +1,12 @@
export function convertQortalLinks(inputHtml: string) {
- // Regular expression to match 'qortal://...' URLs.
- // This will stop at the first whitespace, comma, or HTML tag
- var regex = /(qortal:\/\/[^\s,<]+)/g;
+ // Regular expression to match 'qortal://...' URLs.
+ // This will stop at the first whitespace, comma, or HTML tag
+ var regex = /(qortal:\/\/[^\s,<]+)/g;
- // Replace matches in inputHtml with formatted anchor tag
- var outputHtml = inputHtml.replace(regex, function (match) {
- return `${match}`;
- });
+ // Replace matches in inputHtml with formatted anchor tag
+ var outputHtml = inputHtml.replace(regex, function (match) {
+ return `${match}`;
+ });
- return outputHtml;
-}
\ No newline at end of file
+ return outputHtml;
+}
diff --git a/src/utils/seedPhrase/RandomSentenceGenerator.ts b/src/utils/seedPhrase/RandomSentenceGenerator.ts
index 8fdf71d..86ba436 100644
--- a/src/utils/seedPhrase/RandomSentenceGenerator.ts
+++ b/src/utils/seedPhrase/RandomSentenceGenerator.ts
@@ -1,173 +1,182 @@
// Author: irontiga
-import { html, LitElement, css } from 'lit'
-import * as WORDLISTS from './wordList'
+import { html, LitElement, css } from 'lit';
+import * as WORDLISTS from './wordList';
class RandomSentenceGenerator extends LitElement {
- static get properties() {
- return {
- template: { type: String, attribute: 'template' },
- parsedString: { type: String },
- fetchedWordlistCount: { type: Number, value: 0 },
- capitalize: { type: Boolean },
- partsOfSpeechMap: { type: Object },
- templateEntropy: { type: Number, reflect: true, attribute: 'template-entropy' },
- maxWordLength: { type: Number, attribute: 'max-word-length' }
- }
- }
+ static get properties() {
+ return {
+ template: { type: String, attribute: 'template' },
+ parsedString: { type: String },
+ fetchedWordlistCount: { type: Number, value: 0 },
+ capitalize: { type: Boolean },
+ partsOfSpeechMap: { type: Object },
+ templateEntropy: {
+ type: Number,
+ reflect: true,
+ attribute: 'template-entropy',
+ },
+ maxWordLength: { type: Number, attribute: 'max-word-length' },
+ };
+ }
- constructor() {
- super()
- this.template = 'adjective noun verb adverb.'
- this.maxWordLength = 0
- this.parsedString = ''
- this.fetchedWordlistCount = 0
- this.capitalize = true
- this.partsOfSpeechMap = {
- 'noun': 'nouns',
- 'adverb': 'adverbs',
- 'adv': 'adverbs',
- 'verb': 'verbs',
- 'interjection': 'interjections',
- 'adjective': 'adjectives',
- 'adj': 'adjectives',
- 'verbed': 'verbed'
- }
- this.partsOfSpeech = Object.keys(this.partsOfSpeechMap)
- this._wordlists = WORDLISTS
- }
+ constructor() {
+ super();
+ this.template = 'adjective noun verb adverb.';
+ this.maxWordLength = 0;
+ this.parsedString = '';
+ this.fetchedWordlistCount = 0;
+ this.capitalize = true;
+ this.partsOfSpeechMap = {
+ noun: 'nouns',
+ adverb: 'adverbs',
+ adv: 'adverbs',
+ verb: 'verbs',
+ interjection: 'interjections',
+ adjective: 'adjectives',
+ adj: 'adjectives',
+ verbed: 'verbed',
+ };
+ this.partsOfSpeech = Object.keys(this.partsOfSpeechMap);
+ this._wordlists = WORDLISTS;
+ }
- static styles = css`
+ static styles = css`
div {
text-align: center;
- width: 100%;
- background-color: #1f2023;
- border-radius: 5px;
- padding: 10px;
+ width: 100%;
+ background-color: #1f2023;
+ border-radius: 5px;
+ padding: 10px;
}
`;
- render() {
- return html`
- ${this.parsedString}
- `
- }
+ render() {
+ return html` ${this.parsedString}
`;
+ }
-
+ firstUpdated() {
+ // ...
+ }
- firstUpdated() {
- // ...
- }
+ updated(changedProperties) {
+ let regen = false;
- updated(changedProperties) {
- let regen = false
+ if (changedProperties.has('template')) {
+ regen = true;
+ }
- if (changedProperties.has('template')) {
- regen = true
- }
+ if (changedProperties.has('maxWordLength')) {
+ console.dir(this.maxWordLength);
- if (changedProperties.has('maxWordLength')) {
- console.dir(this.maxWordLength)
+ if (this.maxWordLength) {
+ const wl = { ...this._wordlists };
- if (this.maxWordLength) {
- const wl = { ...this._wordlists }
+ for (const partOfSpeech in this._wordlists) {
+ if (Array.isArray(this._wordlists[partOfSpeech])) {
+ wl[partOfSpeech] = this._wordlists[partOfSpeech].filter(
+ (word) => word.length <= this.maxWordLength
+ );
+ }
+ }
- for (const partOfSpeech in this._wordlists) {
- if (Array.isArray(this._wordlists[partOfSpeech])) {
- wl[partOfSpeech] = this._wordlists[partOfSpeech].filter(word => word.length <= this.maxWordLength)
- }
- }
+ this._wordlists = wl;
+ }
- this._wordlists = wl
- }
+ regen = true;
+ }
- regen = true
- }
+ if (regen) this.generate();
+ }
- if (regen) this.generate()
- }
+ _RNG(entropy) {
+ if (entropy > 1074) {
+ throw new Error('Javascript can not handle that much entropy!');
+ }
- _RNG(entropy) {
- if (entropy > 1074) {
- throw new Error('Javascript can not handle that much entropy!')
- }
+ let randNum = 0;
- let randNum = 0
+ const crypto = window.crypto || window.msCrypto;
- const crypto = window.crypto || window.msCrypto
+ if (crypto) {
+ const entropy256 = Math.ceil(entropy / 8);
- if (crypto) {
- const entropy256 = Math.ceil(entropy / 8)
+ let buffer = new Uint8Array(entropy256);
- let buffer = new Uint8Array(entropy256)
+ crypto.getRandomValues(buffer);
- crypto.getRandomValues(buffer)
+ randNum =
+ buffer.reduce((num, value) => {
+ return num * value;
+ }, 1) / Math.pow(256, entropy256);
+ } else {
+ console.warn('Secure RNG not found. Using Math.random');
- randNum = buffer.reduce((num, value) => {
- return num * value
- }, 1) / Math.pow(256, entropy256)
- } else {
- console.warn('Secure RNG not found. Using Math.random')
+ randNum = Math.random();
+ }
- randNum = Math.random()
- }
+ return randNum;
+ }
- return randNum
- }
+ setRNG(fn) {
+ this._RNG = fn;
+ }
- setRNG(fn) {
- this._RNG = fn
- }
+ _captitalize(str) {
+ return str.charAt(0).toUpperCase() + str.slice(1);
+ }
- _captitalize(str) {
- return str.charAt(0).toUpperCase() + str.slice(1)
- }
+ getWord(partOfSpeech) {
+ const words = this._wordlists[this.partsOfSpeechMap[partOfSpeech]];
+ const requiredEntropy = Math.log(words.length) / Math.log(2);
+ const index = this._RNG(requiredEntropy) * words.length;
- getWord(partOfSpeech) {
- const words = this._wordlists[this.partsOfSpeechMap[partOfSpeech]]
- const requiredEntropy = Math.log(words.length) / Math.log(2)
- const index = this._RNG(requiredEntropy) * words.length
+ return {
+ word: words[Math.round(index)],
+ entropy: words.length,
+ };
+ }
- return {
- word: words[Math.round(index)],
- entropy: words.length
- }
- }
+ generate() {
+ this.parsedString = this.parse(this.template);
+ }
- generate() {
- this.parsedString = this.parse(this.template)
- }
+ parse(template) {
+ const split = template.split(/[\s]/g);
- parse(template) {
- const split = template.split(/[\s]/g)
+ let entropy = 1;
- let entropy = 1
+ const final = split.map((word) => {
+ const lower = word.toLowerCase();
- const final = split.map(word => {
- const lower = word.toLowerCase()
+ this.partsOfSpeech.some((partOfSpeech) => {
+ const partOfSpeechIndex = lower.indexOf(partOfSpeech); // Check it exists
+ const nextChar = word.charAt(partOfSpeech.length);
- this.partsOfSpeech.some(partOfSpeech => {
- const partOfSpeechIndex = lower.indexOf(partOfSpeech) // Check it exists
- const nextChar = word.charAt(partOfSpeech.length)
+ if (
+ partOfSpeechIndex === 0 &&
+ !(nextChar && nextChar.match(/[a-zA-Z]/g) != null)
+ ) {
+ const replacement = this.getWord(partOfSpeech);
+ word = replacement.word + word.slice(partOfSpeech.length); // Append the rest of the "word" (punctuation)
+ entropy = entropy * replacement.entropy;
- if (partOfSpeechIndex === 0 && !(nextChar && (nextChar.match(/[a-zA-Z]/g) != null))) {
- const replacement = this.getWord(partOfSpeech)
- word = replacement.word + word.slice(partOfSpeech.length) // Append the rest of the "word" (punctuation)
- entropy = entropy * replacement.entropy
+ return true;
+ }
+ });
- return true
- }
- })
+ return word;
+ });
- return word
- })
+ this.templateEntropy = Math.floor(Math.log(entropy) / Math.log(8));
- this.templateEntropy = Math.floor(Math.log(entropy) / Math.log(8))
-
- return final.join(' ')
- }
+ return final.join(' ');
+ }
}
-window.customElements.define('random-sentence-generator', RandomSentenceGenerator)
+window.customElements.define(
+ 'random-sentence-generator',
+ RandomSentenceGenerator
+);
-export default RandomSentenceGenerator
\ No newline at end of file
+export default RandomSentenceGenerator;
diff --git a/src/utils/seedPhrase/verb-past-tense.ts b/src/utils/seedPhrase/verb-past-tense.ts
index c5b279f..5b55086 100644
--- a/src/utils/seedPhrase/verb-past-tense.ts
+++ b/src/utils/seedPhrase/verb-past-tense.ts
@@ -1,40 +1,40 @@
export const EXCEPTIONS = {
- 'are': 'were',
- 'eat': 'ate',
- 'go': 'went',
- 'have': 'had',
- 'inherit': 'inherited',
- 'is': 'was',
- 'run': 'ran',
- 'sit': 'sat',
- 'visit': 'visited'
-}
+ are: 'were',
+ eat: 'ate',
+ go: 'went',
+ have: 'had',
+ inherit: 'inherited',
+ is: 'was',
+ run: 'ran',
+ sit: 'sat',
+ visit: 'visited',
+};
export const getPastTense = (verb, exceptions = EXCEPTIONS) => {
- if (exceptions[verb]) {
- return exceptions[verb]
- }
+ if (exceptions[verb]) {
+ return exceptions[verb];
+ }
- if ((/e$/i).test(verb)) {
- return verb + 'd'
- }
+ if (/e$/i.test(verb)) {
+ return verb + 'd';
+ }
- if ((/[aeiou]c$/i).test(verb)) {
- return verb + 'ked'
- }
+ if (/[aeiou]c$/i.test(verb)) {
+ return verb + 'ked';
+ }
- // for american english only
- if ((/el$/i).test(verb)) {
- return verb + 'ed'
- }
+ // for american english only
+ if (/el$/i.test(verb)) {
+ return verb + 'ed';
+ }
- if ((/[aeio][aeiou][dlmnprst]$/).test(verb)) {
- return verb + 'ed'
- }
+ if (/[aeio][aeiou][dlmnprst]$/.test(verb)) {
+ return verb + 'ed';
+ }
- if ((/[aeiou][bdglmnprst]$/i).test(verb)) {
- return verb.replace(/(.+[aeiou])([bdglmnprst])/, '$1$2$2ed')
- }
+ if (/[aeiou][bdglmnprst]$/i.test(verb)) {
+ return verb.replace(/(.+[aeiou])([bdglmnprst])/, '$1$2$2ed');
+ }
- return verb + 'ed'
-}
\ No newline at end of file
+ return verb + 'ed';
+};
diff --git a/src/utils/validateAddress.ts b/src/utils/validateAddress.ts
index bbab210..4238311 100644
--- a/src/utils/validateAddress.ts
+++ b/src/utils/validateAddress.ts
@@ -4,6 +4,7 @@ import Base58 from '../deps/Base58';
export const validateAddress = (address) => {
let isAddress = false;
+
try {
const decodePubKey = Base58.decode(address);