-
Total Unlocking Fee:
+
${i18n.t('question:total_unlocking_fee', {
+ postProcess: 'capitalizeFirstChar',
+ })}
${(+buyingFees?.unlock?.fee * atAddresses?.length)?.toFixed(8)} ${buyingFees.ticker}
- This fee is an estimate based on ${atAddresses?.length} ${atAddresses?.length > 1 ? 'orders' : 'order'}, assuming a 300-byte size at a rate of ${buyingFees?.unlock?.feePerKb?.toFixed(8)} ${buyingFees.ticker} per KB.
-
-
-
Total Locking Fee:
-
${+buyingFees?.lock.fee.toFixed(8)} ${buyingFees.ticker} per kb
-
+ ${i18n.t('question:permission.buy_order_fee_estimation', {
+ quantity: atAddresses?.length,
+ fee: buyingFees?.unlock?.feePerKb?.toFixed(8),
+ ticker: buyingFees.ticker,
+ postProcess: 'capitalizeFirstChar',
+ })}
+
+
${i18n.t('question:total_locking_fee', {
+ postProcess: 'capitalizeFirstChar',
+ })}
+
${i18n.t('question:permission.buy_order_per_kb', {
+ fee: +buyingFees?.lock.fee.toFixed(8),
+ ticker: buyingFees.ticker,
+ postProcess: 'capitalizeFirstChar',
+ })}
+
`,
@@ -3701,10 +4669,19 @@ export const createBuyOrder = async (data, isFromExtension) => {
});
return resBuyOrder;
} else {
- throw new Error('User declined request');
+ throw new Error(
+ i18n.t('question:message.generic.user_declined_request', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
} catch (error) {
- throw new Error(error?.message || 'Failed to submit trade order.');
+ throw new Error(
+ error?.message ||
+ i18n.t('question:message.error.buy_order', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
};
@@ -3721,7 +4698,14 @@ const cancelTradeOfferTradeBot = async (body, keyPair) => {
body: bodyToString,
});
- if (!deleteTradeBotResponse.ok) throw new Error('Unable to update tradebot');
+ if (!deleteTradeBotResponse.ok) {
+ throw new Error(
+ i18n.t('question:message.error.update_tradebot', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
+ }
+
const unsignedTxn = await deleteTradeBotResponse.text();
const signedTxnBytes = await signTradeBotTransaction(unsignedTxn, keyPair);
const signedBytes = Base58.encode(signedTxnBytes);
@@ -3731,7 +4715,9 @@ const cancelTradeOfferTradeBot = async (body, keyPair) => {
res = await processTransactionVersion2(signedBytes);
} catch (error) {
return {
- error: 'Failed to Cancel Sell Order. Try again!',
+ error: i18n.t('question:message.error.cancel_sell_order', {
+ postProcess: 'capitalizeFirstChar',
+ }),
failedTradeBot: {
atAddress: body.atAddress,
creatorAddress: body.creatorAddress,
@@ -3740,7 +4726,9 @@ const cancelTradeOfferTradeBot = async (body, keyPair) => {
}
if (res?.error) {
return {
- error: 'Failed to Cancel Sell Order. Try again!',
+ error: i18n.t('question:message.error.cancel_sell_order', {
+ postProcess: 'capitalizeFirstChar',
+ }),
failedTradeBot: {
atAddress: body.atAddress,
creatorAddress: body.creatorAddress,
@@ -3750,7 +4738,11 @@ const cancelTradeOfferTradeBot = async (body, keyPair) => {
if (res?.signature) {
return res;
} else {
- throw new Error('Failed to Cancel Sell Order. Try again!');
+ throw new Error(
+ i18n.t('question:message.error.cancel_sell_order', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
};
const findFailedTradebot = async (createBotCreationTimestamp, body) => {
@@ -3805,7 +4797,12 @@ const tradeBotCreateRequest = async (body, keyPair) => {
},
body: bodyToString,
});
- if (!unsignedTxnResponse.ok) throw new Error('Unable to create tradebot');
+ if (!unsignedTxnResponse.ok)
+ throw new Error(
+ i18n.t('question:message.error.create_tradebot', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
const createBotCreationTimestamp = Date.now();
const unsignedTxn = await unsignedTxnResponse.text();
const signedTxnBytes = await signTradeBotTransaction(unsignedTxn, keyPair);
@@ -3820,7 +4817,9 @@ const tradeBotCreateRequest = async (body, keyPair) => {
body
);
return {
- error: 'Failed to Create Sell Order. Try again!',
+ error: i18n.t('question:message.error.create_sell_order', {
+ postProcess: 'capitalizeFirstChar',
+ }),
failedTradeBot: findFailedTradeBot,
};
}
@@ -3828,7 +4827,11 @@ const tradeBotCreateRequest = async (body, keyPair) => {
if (res?.signature) {
return res;
} else {
- throw new Error('Failed to Create Sell Order. Try again!');
+ throw new Error(
+ i18n.t('question:message.error.create_sell_order', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
};
@@ -3842,7 +4845,10 @@ export const createSellOrder = async (data, isFromExtension) => {
});
if (missingFields.length > 0) {
const missingFieldsString = missingFields.join(', ');
- const errorMsg = `Missing fields: ${missingFieldsString}`;
+ const errorMsg = i18n.t('question:message.error.missing_fields', {
+ fields: missingFieldsString,
+ postProcess: 'capitalizeFirstChar',
+ });
throw new Error(errorMsg);
}
@@ -3852,11 +4858,15 @@ export const createSellOrder = async (data, isFromExtension) => {
try {
const resPermission = await getUserPermission(
{
- text1:
- 'Do you give this application permission to perform a sell order?',
- text2: `${data.qortAmount}${' '}
- ${`QORT`}`,
- text3: `FOR ${parsedForeignAmount} ${data.foreignBlockchain}`,
+ text1: i18n.t('question:permission.sell_order', {
+ postProcess: 'capitalizeFirstChar',
+ }),
+ text2: i18n.t('question:permission.order_detail', {
+ qort_amount: data.qortAmount,
+ foreign_amount: parsedForeignAmount,
+ ticker: data.foreignBlockchain,
+ postProcess: 'capitalizeFirstChar',
+ }),
fee: '0.02',
},
isFromExtension
@@ -3887,16 +4897,26 @@ export const createSellOrder = async (data, isFromExtension) => {
return response;
} else {
- throw new Error('User declined request');
+ throw new Error(
+ i18n.t('question:message.generic.user_declined_request', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
} catch (error) {
- throw new Error(error?.message || 'Failed to submit sell order.');
+ throw new Error(
+ error?.message ||
+ i18n.t('question:message.error.submit_sell_order', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
};
export const cancelSellOrder = async (data, isFromExtension) => {
const requiredFields = ['atAddress'];
const missingFields: string[] = [];
+
requiredFields.forEach((field) => {
if (!data[field]) {
missingFields.push(field);
@@ -3904,24 +4924,38 @@ export const cancelSellOrder = async (data, isFromExtension) => {
});
if (missingFields.length > 0) {
const missingFieldsString = missingFields.join(', ');
- const errorMsg = `Missing fields: ${missingFieldsString}`;
+ const errorMsg = i18n.t('question:message.error.missing_fields', {
+ fields: missingFieldsString,
+ postProcess: 'capitalizeFirstChar',
+ });
throw new Error(errorMsg);
}
const url = await createEndpoint(`/crosschain/trade/${data.atAddress}`);
const resAddress = await fetch(url);
const resData = await resAddress.json();
- if (!resData?.qortalAtAddress) throw new Error('Cannot find AT info.');
+
+ if (!resData?.qortalAtAddress)
+ throw new Error(
+ i18n.t('question:message.error.at_info', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
+
try {
const fee = await getFee('MESSAGE');
const resPermission = await getUserPermission(
{
- text1:
- 'Do you give this application permission to perform: cancel a sell order?',
- text2: `${resData.qortAmount}${' '}
- ${`QORT`}`,
- text3: `FOR ${resData.expectedForeignAmount} ${resData.foreignBlockchain}`,
+ text1: i18n.t('question:permission.cancel_sell_order', {
+ postProcess: 'capitalizeFirstChar',
+ }),
+ text2: i18n.t('question:permission.order_detail', {
+ qort_amount: resData.qortAmount,
+ foreign_amount: resData.expectedForeignAmount,
+ ticker: resData.foreignBlockchain,
+ postProcess: 'capitalizeFirstChar',
+ }),
fee: fee.fee,
},
isFromExtension
@@ -3947,10 +4981,19 @@ export const cancelSellOrder = async (data, isFromExtension) => {
return response;
} else {
- throw new Error('User declined request');
+ throw new Error(
+ i18n.t('question:message.generic.user_declined_request', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
} catch (error) {
- throw new Error(error?.message || 'Failed to submit sell order.');
+ throw new Error(
+ error?.message ||
+ i18n.t('question:message.error.submit_sell_order', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
};
@@ -3964,19 +5007,31 @@ export const openNewTab = async (data, isFromExtension) => {
});
if (missingFields.length > 0) {
const missingFieldsString = missingFields.join(', ');
- const errorMsg = `Missing fields: ${missingFieldsString}`;
+ const errorMsg = i18n.t('question:message.error.missing_fields', {
+ fields: missingFieldsString,
+ postProcess: 'capitalizeFirstChar',
+ });
throw new Error(errorMsg);
}
const res = extractComponents(data.qortalLink);
if (res) {
const { service, name, identifier, path } = res;
- if (!service && !name) throw new Error('Invalid qortal link');
+ if (!service && !name)
+ throw new Error(
+ i18n.t('auth:message.error.invalid_qortal_link', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
executeEvent('addTab', { data: { service, name, identifier, path } });
executeEvent('open-apps-mode', {});
return true;
} else {
- throw new Error('Invalid qortal link');
+ throw new Error(
+ i18n.t('auth:message.error.invalid_qortal_link', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
};
@@ -4001,12 +5056,19 @@ export const adminAction = async (data, isFromExtension) => {
}
if (missingFields.length > 0) {
const missingFieldsString = missingFields.join(', ');
- const errorMsg = `Missing fields: ${missingFieldsString}`;
+ const errorMsg = i18n.t('question:message.error.missing_fields', {
+ fields: missingFieldsString,
+ postProcess: 'capitalizeFirstChar',
+ });
throw new Error(errorMsg);
}
const isGateway = await isRunningGateway();
if (isGateway) {
- throw new Error('This action cannot be done through a public node');
+ throw new Error(
+ i18n.t('question:message.generic.no_action_public_node', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
let apiEndpoint = '';
@@ -4048,12 +5110,26 @@ export const adminAction = async (data, isFromExtension) => {
includeValueInBody = true;
break;
default:
- throw new Error(`Unknown admin action type: ${data.type}`);
+ throw new Error(
+ i18n.t('question:message.error.unknown_admin_action_type', {
+ type: data.type,
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
// Prepare the permission prompt text
- let permissionText = `Do you give this application permission to perform the admin action: ${data.type}`;
+ let permissionText = i18n.t('question:permission.perform_admin_action', {
+ type: data.type,
+ postProcess: 'capitalizeFirstChar',
+ });
+
if (data.value) {
- permissionText += ` with value: ${data.value}`;
+ permissionText +=
+ ' ' +
+ i18n.t('question:permission.perform_admin_action_with_value', {
+ value: data.value,
+ postProcess: 'capitalizeFirstChar',
+ });
}
const resPermission = await getUserPermission(
@@ -4062,7 +5138,9 @@ export const adminAction = async (data, isFromExtension) => {
},
isFromExtension
);
+
const { accepted } = resPermission;
+
if (accepted) {
// Set up options for the API call
const options: RequestInit = {
@@ -4074,7 +5152,12 @@ export const adminAction = async (data, isFromExtension) => {
options.body = data.value;
}
const response = await fetch(apiEndpoint, options);
- if (!response.ok) throw new Error('Failed to perform request');
+ if (!response.ok)
+ throw new Error(
+ i18n.t('question:message.error.perform_request', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
let res;
try {
@@ -4084,7 +5167,11 @@ export const adminAction = async (data, isFromExtension) => {
}
return res;
} else {
- throw new Error('User declined request');
+ throw new Error(
+ i18n.t('question:message.generic.user_declined_request', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
};
@@ -4098,16 +5185,19 @@ export const signTransaction = async (data, isFromExtension) => {
});
if (missingFields.length > 0) {
const missingFieldsString = missingFields.join(', ');
- const errorMsg = `Missing fields: ${missingFieldsString}`;
+ const errorMsg = i18n.t('question:message.error.missing_fields', {
+ fields: missingFieldsString,
+ postProcess: 'capitalizeFirstChar',
+ });
throw new Error(errorMsg);
}
const shouldProcess = data?.process || false;
- let _url = await createEndpoint(
+ const _url = await createEndpoint(
'/transactions/decode?ignoreValidityChecks=false'
);
- let _body = data.unsignedBytes;
+ const _body = data.unsignedBytes;
const response = await fetch(_url, {
method: 'POST',
headers: {
@@ -4115,17 +5205,33 @@ export const signTransaction = async (data, isFromExtension) => {
},
body: _body,
});
- if (!response.ok) throw new Error('Failed to decode transaction');
+
+ if (!response.ok)
+ throw new Error(
+ i18n.t('question:message.error.decode_transaction', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
const decodedData = await response.json();
const resPermission = await getUserPermission(
{
- text1: `Do you give this application permission to ${shouldProcess ? 'SIGN and PROCESS' : 'SIGN'} a transaction?`,
- highlightedText: 'Read the transaction carefully before accepting!',
+ text1: shouldProcess
+ ? i18n.t('question:permission.sign_process_transaction', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ : i18n.t('question:permission.sign_transaction', {
+ postProcess: 'capitalizeFirstChar',
+ }),
+ highlightedText: i18n.t(
+ 'question:message.generic.read_transaction_carefully',
+ { postProcess: 'capitalizeFirstChar' }
+ ),
text2: `Tx type: ${decodedData.type}`,
json: decodedData,
},
isFromExtension
);
+
const { accepted } = resPermission;
if (accepted) {
let urlConverted = await createEndpoint('/transactions/convert');
@@ -4170,11 +5276,18 @@ export const signTransaction = async (data, isFromExtension) => {
const res = await processTransactionVersion2(signedBytesToBase58);
if (!res?.signature)
throw new Error(
- res?.message || 'Transaction was not able to be processed'
+ res?.message ||
+ i18n.t('question:message.error.process_transaction', {
+ postProcess: 'capitalizeFirstChar',
+ })
);
return res;
} else {
- throw new Error('User declined request');
+ throw new Error(
+ i18n.t('question:message.generic.user_declined_request', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
};
@@ -4187,7 +5300,10 @@ const missingFieldsFunc = (data, requiredFields) => {
});
if (missingFields.length > 0) {
const missingFieldsString = missingFields.join(', ');
- const errorMsg = `Missing fields: ${missingFieldsString}`;
+ const errorMsg = i18n.t('question:message.error.missing_fields', {
+ fields: missingFieldsString,
+ postProcess: 'capitalizeFirstChar',
+ });
throw new Error(errorMsg);
}
};
@@ -4228,7 +5344,10 @@ export const createAndCopyEmbedLink = async (data, isFromExtension) => {
});
if (missingFields.length > 0) {
const missingFieldsString = missingFields.join(', ');
- const errorMsg = `Missing fields: ${missingFieldsString}`;
+ const errorMsg = i18n.t('question:message.error.missing_fields', {
+ fields: missingFieldsString,
+ postProcess: 'capitalizeFirstChar',
+ });
throw new Error(errorMsg);
}
@@ -4246,7 +5365,11 @@ export const createAndCopyEmbedLink = async (data, isFromExtension) => {
try {
await navigator.clipboard.writeText(link);
} catch (error) {
- throw new Error('Failed to copy to clipboard.');
+ throw new Error(
+ i18n.t('question:message.error.copy_clipboard', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
return link;
}
@@ -4255,7 +5378,9 @@ export const createAndCopyEmbedLink = async (data, isFromExtension) => {
missingFieldsFunc(data, ['type', 'name', 'service', 'identifier']);
if (data?.encryptionType === 'private' && !data?.key) {
throw new Error(
- 'For an encrypted resource, you must provide the key to create the shared link'
+ i18n.t('question:message.generic.provide_key_shared_link', {
+ postProcess: 'capitalizeFirstChar',
+ })
);
}
const queryParams = buildQueryParams(data);
@@ -4265,14 +5390,22 @@ export const createAndCopyEmbedLink = async (data, isFromExtension) => {
try {
await navigator.clipboard.writeText(link);
} catch (error) {
- throw new Error('Failed to copy to clipboard.');
+ throw new Error(
+ i18n.t('question:message.error.copy_clipboard', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
return link;
}
default:
- throw new Error('Invalid type');
+ throw new Error(
+ i18n.t('question:message.error.invalid_type', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
};
@@ -4287,13 +5420,18 @@ export const registerNameRequest = async (data, isFromExtension) => {
if (missingFields.length > 0) {
const missingFieldsString = missingFields.join(', ');
- const errorMsg = `Missing fields: ${missingFieldsString}`;
+ const errorMsg = i18n.t('question:message.error.missing_fields', {
+ fields: missingFieldsString,
+ postProcess: 'capitalizeFirstChar',
+ });
throw new Error(errorMsg);
}
const fee = await getFee('REGISTER_NAME');
const resPermission = await getUserPermission(
{
- text1: `Do you give this application permission to register this name?`,
+ text1: i18n.t('question:permission.register_name', {
+ postProcess: 'capitalizeFirstChar',
+ }),
highlightedText: data.name,
text2: data?.description,
fee: fee.fee,
@@ -4307,7 +5445,11 @@ export const registerNameRequest = async (data, isFromExtension) => {
const response = await registerName({ name, description });
return response;
} else {
- throw new Error('User declined request');
+ throw new Error(
+ i18n.t('question:message.generic.user_declined_request', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
};
@@ -4321,7 +5463,10 @@ export const updateNameRequest = async (data, isFromExtension) => {
});
if (missingFields.length > 0) {
const missingFieldsString = missingFields.join(', ');
- const errorMsg = `Missing fields: ${missingFieldsString}`;
+ const errorMsg = i18n.t('question:message.error.missing_fields', {
+ fields: missingFieldsString,
+ postProcess: 'capitalizeFirstChar',
+ });
throw new Error(errorMsg);
}
const oldName = data.oldName;
@@ -4343,7 +5488,11 @@ export const updateNameRequest = async (data, isFromExtension) => {
const response = await updateName({ oldName, newName, description });
return response;
} else {
- throw new Error('User declined request');
+ throw new Error(
+ i18n.t('question:message.generic.user_declined_request', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
};
@@ -4357,7 +5506,10 @@ export const leaveGroupRequest = async (data, isFromExtension) => {
});
if (missingFields.length > 0) {
const missingFieldsString = missingFields.join(', ');
- const errorMsg = `Missing fields: ${missingFieldsString}`;
+ const errorMsg = i18n.t('question:message.error.missing_fields', {
+ fields: missingFieldsString,
+ postProcess: 'capitalizeFirstChar',
+ });
throw new Error(errorMsg);
}
const groupId = data.groupId;
@@ -4365,18 +5517,29 @@ export const leaveGroupRequest = async (data, isFromExtension) => {
try {
const url = await createEndpoint(`/groups/${groupId}`);
const response = await fetch(url);
- if (!response.ok) throw new Error('Failed to fetch group');
+ if (!response.ok)
+ throw new Error(
+ i18n.t('question:message.error.fetch_group', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
groupInfo = await response.json();
} catch (error) {
- const errorMsg = (error && error.message) || 'Group not found';
+ const errorMsg =
+ (error && error.message) ||
+ i18n.t('question:message.error.no_group_found', {
+ postProcess: 'capitalizeFirstChar',
+ });
throw new Error(errorMsg);
}
const fee = await getFee('LEAVE_GROUP');
const resPermission = await getUserPermission(
{
- text1: `Do you give this application permission to leave the following group?`,
+ text1: i18n.t('question:permission.leave_group', {
+ postProcess: 'capitalizeFirstChar',
+ }),
highlightedText: `${groupInfo.groupName}`,
fee: fee.fee,
},
@@ -4387,7 +5550,11 @@ export const leaveGroupRequest = async (data, isFromExtension) => {
const response = await leaveGroup({ groupId });
return response;
} else {
- throw new Error('User declined request');
+ throw new Error(
+ i18n.t('question:message.generic.user_declined_request', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
};
@@ -4401,7 +5568,10 @@ export const inviteToGroupRequest = async (data, isFromExtension) => {
});
if (missingFields.length > 0) {
const missingFieldsString = missingFields.join(', ');
- const errorMsg = `Missing fields: ${missingFieldsString}`;
+ const errorMsg = i18n.t('question:message.error.missing_fields', {
+ fields: missingFieldsString,
+ postProcess: 'capitalizeFirstChar',
+ });
throw new Error(errorMsg);
}
const groupId = data.groupId;
@@ -4412,11 +5582,20 @@ export const inviteToGroupRequest = async (data, isFromExtension) => {
try {
const url = await createEndpoint(`/groups/${groupId}`);
const response = await fetch(url);
- if (!response.ok) throw new Error('Failed to fetch group');
+ if (!response.ok)
+ throw new Error(
+ i18n.t('question:message.error.fetch_group', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
groupInfo = await response.json();
} catch (error) {
- const errorMsg = (error && error.message) || 'Group not found';
+ const errorMsg =
+ (error && error.message) ||
+ i18n.t('question:message.error.no_group_found', {
+ postProcess: 'capitalizeFirstChar',
+ });
throw new Error(errorMsg);
}
@@ -4425,8 +5604,14 @@ export const inviteToGroupRequest = async (data, isFromExtension) => {
const fee = await getFee('GROUP_INVITE');
const resPermission = await getUserPermission(
{
- text1: `Do you give this application permission to invite ${displayInvitee || qortalAddress}?`,
- highlightedText: `Group: ${groupInfo.groupName}`,
+ text1: i18n.t('question:permission.invite', {
+ invitee: displayInvitee || qortalAddress,
+ postProcess: 'capitalizeFirstChar',
+ }),
+ highlightedText: i18n.t('group:group.group_name', {
+ name: groupInfo?.groupName,
+ postProcess: 'capitalizeFirstChar',
+ }),
fee: fee.fee,
},
isFromExtension
@@ -4440,7 +5625,11 @@ export const inviteToGroupRequest = async (data, isFromExtension) => {
});
return response;
} else {
- throw new Error('User declined request');
+ throw new Error(
+ i18n.t('question:message.generic.user_declined_request', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
};
@@ -4454,7 +5643,10 @@ export const kickFromGroupRequest = async (data, isFromExtension) => {
});
if (missingFields.length > 0) {
const missingFieldsString = missingFields.join(', ');
- const errorMsg = `Missing fields: ${missingFieldsString}`;
+ const errorMsg = i18n.t('question:message.error.missing_fields', {
+ fields: missingFieldsString,
+ postProcess: 'capitalizeFirstChar',
+ });
throw new Error(errorMsg);
}
const groupId = data.groupId;
@@ -4465,11 +5657,20 @@ export const kickFromGroupRequest = async (data, isFromExtension) => {
try {
const url = await createEndpoint(`/groups/${groupId}`);
const response = await fetch(url);
- if (!response.ok) throw new Error('Failed to fetch group');
+ if (!response.ok)
+ throw new Error(
+ i18n.t('question:message.error.fetch_group', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
groupInfo = await response.json();
} catch (error) {
- const errorMsg = (error && error.message) || 'Group not found';
+ const errorMsg =
+ (error && error.message) ||
+ i18n.t('question:message.error.no_group_found', {
+ postProcess: 'capitalizeFirstChar',
+ });
throw new Error(errorMsg);
}
@@ -4478,8 +5679,14 @@ export const kickFromGroupRequest = async (data, isFromExtension) => {
const fee = await getFee('GROUP_KICK');
const resPermission = await getUserPermission(
{
- text1: `Do you give this application permission to kick ${displayInvitee || qortalAddress} from the group?`,
- highlightedText: `Group: ${groupInfo.groupName}`,
+ text1: i18n.t('question:permission.kick', {
+ partecipant: displayInvitee || qortalAddress,
+ postProcess: 'capitalizeFirstChar',
+ }),
+ highlightedText: i18n.t('group:group.group_name', {
+ name: groupInfo?.groupName,
+ postProcess: 'capitalizeFirstChar',
+ }),
fee: fee.fee,
},
isFromExtension
@@ -4493,7 +5700,11 @@ export const kickFromGroupRequest = async (data, isFromExtension) => {
});
return response;
} else {
- throw new Error('User declined request');
+ throw new Error(
+ i18n.t('question:message.generic.user_declined_request', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
};
@@ -4507,7 +5718,10 @@ export const banFromGroupRequest = async (data, isFromExtension) => {
});
if (missingFields.length > 0) {
const missingFieldsString = missingFields.join(', ');
- const errorMsg = `Missing fields: ${missingFieldsString}`;
+ const errorMsg = i18n.t('question:message.error.missing_fields', {
+ fields: missingFieldsString,
+ postProcess: 'capitalizeFirstChar',
+ });
throw new Error(errorMsg);
}
const groupId = data.groupId;
@@ -4518,11 +5732,20 @@ export const banFromGroupRequest = async (data, isFromExtension) => {
try {
const url = await createEndpoint(`/groups/${groupId}`);
const response = await fetch(url);
- if (!response.ok) throw new Error('Failed to fetch group');
+ if (!response.ok)
+ throw new Error(
+ i18n.t('question:message.error.fetch_group', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
groupInfo = await response.json();
} catch (error) {
- const errorMsg = (error && error.message) || 'Group not found';
+ const errorMsg =
+ (error && error.message) ||
+ i18n.t('question:message.error.no_group_found', {
+ postProcess: 'capitalizeFirstChar',
+ });
throw new Error(errorMsg);
}
@@ -4531,8 +5754,14 @@ export const banFromGroupRequest = async (data, isFromExtension) => {
const fee = await getFee('GROUP_BAN');
const resPermission = await getUserPermission(
{
- text1: `Do you give this application permission to ban ${displayInvitee || qortalAddress} from the group?`,
- highlightedText: `Group: ${groupInfo.groupName}`,
+ text1: i18n.t('question:permission.ban', {
+ partecipant: displayInvitee || qortalAddress,
+ postProcess: 'capitalizeFirstChar',
+ }),
+ highlightedText: i18n.t('group:group.group_name', {
+ name: groupInfo?.groupName,
+ postProcess: 'capitalizeFirstChar',
+ }),
fee: fee.fee,
},
isFromExtension
@@ -4547,7 +5776,11 @@ export const banFromGroupRequest = async (data, isFromExtension) => {
});
return response;
} else {
- throw new Error('User declined request');
+ throw new Error(
+ i18n.t('question:message.generic.user_declined_request', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
};
@@ -4561,7 +5794,10 @@ export const cancelGroupBanRequest = async (data, isFromExtension) => {
});
if (missingFields.length > 0) {
const missingFieldsString = missingFields.join(', ');
- const errorMsg = `Missing fields: ${missingFieldsString}`;
+ const errorMsg = i18n.t('question:message.error.missing_fields', {
+ fields: missingFieldsString,
+ postProcess: 'capitalizeFirstChar',
+ });
throw new Error(errorMsg);
}
const groupId = data.groupId;
@@ -4571,11 +5807,20 @@ export const cancelGroupBanRequest = async (data, isFromExtension) => {
try {
const url = await createEndpoint(`/groups/${groupId}`);
const response = await fetch(url);
- if (!response.ok) throw new Error('Failed to fetch group');
+ if (!response.ok)
+ throw new Error(
+ i18n.t('question:message.error.fetch_group', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
groupInfo = await response.json();
} catch (error) {
- const errorMsg = (error && error.message) || 'Group not found';
+ const errorMsg =
+ (error && error.message) ||
+ i18n.t('question:message.error.no_group_found', {
+ postProcess: 'capitalizeFirstChar',
+ });
throw new Error(errorMsg);
}
@@ -4584,8 +5829,14 @@ export const cancelGroupBanRequest = async (data, isFromExtension) => {
const fee = await getFee('CANCEL_GROUP_BAN');
const resPermission = await getUserPermission(
{
- text1: `Do you give this application permission to cancel the group ban for user ${displayInvitee || qortalAddress}?`,
- highlightedText: `Group: ${groupInfo.groupName}`,
+ text1: i18n.t('question:permission.cancel_ban', {
+ partecipant: displayInvitee || qortalAddress,
+ postProcess: 'capitalizeFirstChar',
+ }),
+ highlightedText: i18n.t('group:group.group_name', {
+ name: groupInfo?.groupName,
+ postProcess: 'capitalizeFirstChar',
+ }),
fee: fee.fee,
},
isFromExtension
@@ -4598,7 +5849,11 @@ export const cancelGroupBanRequest = async (data, isFromExtension) => {
});
return response;
} else {
- throw new Error('User declined request');
+ throw new Error(
+ i18n.t('question:message.generic.user_declined_request', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
};
@@ -4612,7 +5867,10 @@ export const addGroupAdminRequest = async (data, isFromExtension) => {
});
if (missingFields.length > 0) {
const missingFieldsString = missingFields.join(', ');
- const errorMsg = `Missing fields: ${missingFieldsString}`;
+ const errorMsg = i18n.t('question:message.error.missing_fields', {
+ fields: missingFieldsString,
+ postProcess: 'capitalizeFirstChar',
+ });
throw new Error(errorMsg);
}
const groupId = data.groupId;
@@ -4622,11 +5880,20 @@ export const addGroupAdminRequest = async (data, isFromExtension) => {
try {
const url = await createEndpoint(`/groups/${groupId}`);
const response = await fetch(url);
- if (!response.ok) throw new Error('Failed to fetch group');
+ if (!response.ok)
+ throw new Error(
+ i18n.t('question:message.error.fetch_group', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
groupInfo = await response.json();
} catch (error) {
- const errorMsg = (error && error.message) || 'Group not found';
+ const errorMsg =
+ (error && error.message) ||
+ i18n.t('question:message.error.no_group_found', {
+ postProcess: 'capitalizeFirstChar',
+ });
throw new Error(errorMsg);
}
@@ -4635,8 +5902,14 @@ export const addGroupAdminRequest = async (data, isFromExtension) => {
const fee = await getFee('ADD_GROUP_ADMIN');
const resPermission = await getUserPermission(
{
- text1: `Do you give this application permission to add user ${displayInvitee || qortalAddress} as an admin?`,
- highlightedText: `Group: ${groupInfo.groupName}`,
+ text1: i18n.t('question:permission.add_admin', {
+ invitee: displayInvitee || qortalAddress,
+ postProcess: 'capitalizeFirstChar',
+ }),
+ highlightedText: i18n.t('group:group.group_name', {
+ name: groupInfo?.groupName,
+ postProcess: 'capitalizeFirstChar',
+ }),
fee: fee.fee,
},
isFromExtension
@@ -4649,7 +5922,11 @@ export const addGroupAdminRequest = async (data, isFromExtension) => {
});
return response;
} else {
- throw new Error('User declined request');
+ throw new Error(
+ i18n.t('question:message.generic.user_declined_request', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
};
@@ -4663,7 +5940,10 @@ export const removeGroupAdminRequest = async (data, isFromExtension) => {
});
if (missingFields.length > 0) {
const missingFieldsString = missingFields.join(', ');
- const errorMsg = `Missing fields: ${missingFieldsString}`;
+ const errorMsg = i18n.t('question:message.error.missing_fields', {
+ fields: missingFieldsString,
+ postProcess: 'capitalizeFirstChar',
+ });
throw new Error(errorMsg);
}
const groupId = data.groupId;
@@ -4673,11 +5953,20 @@ export const removeGroupAdminRequest = async (data, isFromExtension) => {
try {
const url = await createEndpoint(`/groups/${groupId}`);
const response = await fetch(url);
- if (!response.ok) throw new Error('Failed to fetch group');
+ if (!response.ok)
+ throw new Error(
+ i18n.t('question:message.error.fetch_group', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
groupInfo = await response.json();
} catch (error) {
- const errorMsg = (error && error.message) || 'Group not found';
+ const errorMsg =
+ (error && error.message) ||
+ i18n.t('question:message.error.no_group_found', {
+ postProcess: 'capitalizeFirstChar',
+ });
throw new Error(errorMsg);
}
@@ -4686,8 +5975,14 @@ export const removeGroupAdminRequest = async (data, isFromExtension) => {
const fee = await getFee('REMOVE_GROUP_ADMIN');
const resPermission = await getUserPermission(
{
- text1: `Do you give this application permission to remove user ${displayInvitee || qortalAddress} as admin?`,
- highlightedText: `Group: ${groupInfo.groupName}`,
+ text1: i18n.t('question:permission.remove_admin', {
+ partecipant: displayInvitee || qortalAddress,
+ postProcess: 'capitalizeFirstChar',
+ }),
+ highlightedText: i18n.t('group:group.group_name', {
+ name: groupInfo?.groupName,
+ postProcess: 'capitalizeFirstChar',
+ }),
fee: fee.fee,
},
isFromExtension
@@ -4700,7 +5995,11 @@ export const removeGroupAdminRequest = async (data, isFromExtension) => {
});
return response;
} else {
- throw new Error('User declined request');
+ throw new Error(
+ i18n.t('question:message.generic.user_declined_request', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
};
@@ -4714,7 +6013,10 @@ export const cancelGroupInviteRequest = async (data, isFromExtension) => {
});
if (missingFields.length > 0) {
const missingFieldsString = missingFields.join(', ');
- const errorMsg = `Missing fields: ${missingFieldsString}`;
+ const errorMsg = i18n.t('question:message.error.missing_fields', {
+ fields: missingFieldsString,
+ postProcess: 'capitalizeFirstChar',
+ });
throw new Error(errorMsg);
}
const groupId = data.groupId;
@@ -4724,11 +6026,20 @@ export const cancelGroupInviteRequest = async (data, isFromExtension) => {
try {
const url = await createEndpoint(`/groups/${groupId}`);
const response = await fetch(url);
- if (!response.ok) throw new Error('Failed to fetch group');
+ if (!response.ok)
+ throw new Error(
+ i18n.t('question:message.error.fetch_group', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
groupInfo = await response.json();
} catch (error) {
- const errorMsg = (error && error.message) || 'Group not found';
+ const errorMsg =
+ (error && error.message) ||
+ i18n.t('question:message.error.no_group_found', {
+ postProcess: 'capitalizeFirstChar',
+ });
throw new Error(errorMsg);
}
@@ -4737,13 +6048,21 @@ export const cancelGroupInviteRequest = async (data, isFromExtension) => {
const fee = await getFee('CANCEL_GROUP_INVITE');
const resPermission = await getUserPermission(
{
- text1: `Do you give this application permission to cancel the group invite for ${displayInvitee || qortalAddress}?`,
- highlightedText: `Group: ${groupInfo.groupName}`,
+ text1: i18n.t('question:permission.cancel_group_invite', {
+ invitee: displayInvitee || qortalAddress,
+ postProcess: 'capitalizeFirstChar',
+ }),
+ highlightedText: i18n.t('group:group.group_name', {
+ name: groupInfo?.groupName,
+ postProcess: 'capitalizeFirstChar',
+ }),
fee: fee.fee,
},
isFromExtension
);
+
const { accepted } = resPermission;
+
if (accepted) {
const response = await cancelInvitationToGroup({
groupId,
@@ -4751,19 +6070,23 @@ export const cancelGroupInviteRequest = async (data, isFromExtension) => {
});
return response;
} else {
- throw new Error('User declined request');
+ throw new Error(
+ i18n.t('question:message.generic.user_declined_request', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
};
export const createGroupRequest = async (data, isFromExtension) => {
const requiredFields = [
- 'groupId',
- 'qortalAddress',
- 'groupName',
- 'type',
'approvalThreshold',
- 'minBlock',
+ 'groupId',
+ 'groupName',
'maxBlock',
+ 'minBlock',
+ 'qortalAddress',
+ 'type',
];
const missingFields: string[] = [];
requiredFields.forEach((field) => {
@@ -4773,7 +6096,10 @@ export const createGroupRequest = async (data, isFromExtension) => {
});
if (missingFields.length > 0) {
const missingFieldsString = missingFields.join(', ');
- const errorMsg = `Missing fields: ${missingFieldsString}`;
+ const errorMsg = i18n.t('question:message.error.missing_fields', {
+ fields: missingFieldsString,
+ postProcess: 'capitalizeFirstChar',
+ });
throw new Error(errorMsg);
}
const groupName = data.groupName;
@@ -4786,8 +6112,13 @@ export const createGroupRequest = async (data, isFromExtension) => {
const fee = await getFee('CREATE_GROUP');
const resPermission = await getUserPermission(
{
- text1: `Do you give this application permission to create a group?`,
- highlightedText: `Group name: ${groupName}`,
+ text1: i18n.t('question:permission.create_group', {
+ postProcess: 'capitalizeFirstChar',
+ }),
+ highlightedText: i18n.t('group:group.group_name', {
+ name: groupName,
+ postProcess: 'capitalizeFirstChar',
+ }),
fee: fee.fee,
},
isFromExtension
@@ -4804,7 +6135,11 @@ export const createGroupRequest = async (data, isFromExtension) => {
});
return response;
} else {
- throw new Error('User declined request');
+ throw new Error(
+ i18n.t('question:message.generic.user_declined_request', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
};
@@ -4825,7 +6160,10 @@ export const updateGroupRequest = async (data, isFromExtension) => {
});
if (missingFields.length > 0) {
const missingFieldsString = missingFields.join(', ');
- const errorMsg = `Missing fields: ${missingFieldsString}`;
+ const errorMsg = i18n.t('question:message.error.missing_fields', {
+ fields: missingFieldsString,
+ postProcess: 'capitalizeFirstChar',
+ });
throw new Error(errorMsg);
}
const groupId = +data.groupId;
@@ -4840,11 +6178,20 @@ export const updateGroupRequest = async (data, isFromExtension) => {
try {
const url = await createEndpoint(`/groups/${groupId}`);
const response = await fetch(url);
- if (!response.ok) throw new Error('Failed to fetch group');
+ if (!response.ok)
+ throw new Error(
+ i18n.t('question:message.error.fetch_group', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
groupInfo = await response.json();
} catch (error) {
- const errorMsg = (error && error.message) || 'Group not found';
+ const errorMsg =
+ (error && error.message) ||
+ i18n.t('question:message.error.no_group_found', {
+ postProcess: 'capitalizeFirstChar',
+ });
throw new Error(errorMsg);
}
@@ -4853,9 +6200,17 @@ export const updateGroupRequest = async (data, isFromExtension) => {
const fee = await getFee('CREATE_GROUP');
const resPermission = await getUserPermission(
{
- text1: `Do you give this application permission to update this group?`,
- text2: `New owner: ${displayInvitee || newOwner}`,
- highlightedText: `Group: ${groupInfo.groupName}`,
+ text1: i18n.t('question:permission.update_group', {
+ postProcess: 'capitalizeFirstChar',
+ }),
+ text2: i18n.t('question:permission.update_group_detail', {
+ owner: displayInvitee || newOwner,
+ postProcess: 'capitalizeFirstChar',
+ }),
+ highlightedText: i18n.t('group:group.group_name', {
+ name: groupInfo?.groupName,
+ postProcess: 'capitalizeFirstChar',
+ }),
fee: fee.fee,
},
isFromExtension
@@ -4873,7 +6228,11 @@ export const updateGroupRequest = async (data, isFromExtension) => {
});
return response;
} else {
- throw new Error('User declined request');
+ throw new Error(
+ i18n.t('question:message.generic.user_declined_request', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
};
@@ -4881,7 +6240,12 @@ export const decryptAESGCMRequest = async (data, isFromExtension) => {
const requiredFields = ['encryptedData', 'iv', 'senderPublicKey'];
requiredFields.forEach((field) => {
if (!data[field]) {
- throw new Error(`Missing required field: ${field}`);
+ throw new Error(
+ i18n.t('question:message.error.missing_fields', {
+ fields: field,
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
});
@@ -4918,10 +6282,18 @@ export const decryptAESGCMRequest = async (data, isFromExtension) => {
const ciphertext = base64ToUint8Array(encryptedData);
// Validate IV and key lengths
if (ivUint8Array.length !== 12) {
- throw new Error('Invalid IV: AES-GCM requires a 12-byte IV.');
+ throw new Error(
+ i18n.t('question:message.error.invalid_encryption_iv', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
if (encryptionKey.length !== 32) {
- throw new Error('Invalid key: AES-GCM requires a 256-bit key.');
+ throw new Error(
+ i18n.t('question:message.error.invalid_encryption_key', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
try {
@@ -4945,7 +6317,9 @@ export const decryptAESGCMRequest = async (data, isFromExtension) => {
} catch (error) {
console.error('Decryption failed:', error);
throw new Error(
- 'Failed to decrypt the message. Ensure the data and keys are correct.'
+ i18n.t('question:message.error.decrypt_message', {
+ postProcess: 'capitalizeFirstChar',
+ })
);
}
};
@@ -4960,7 +6334,10 @@ export const sellNameRequest = async (data, isFromExtension) => {
});
if (missingFields.length > 0) {
const missingFieldsString = missingFields.join(', ');
- const errorMsg = `Missing fields: ${missingFieldsString}`;
+ const errorMsg = i18n.t('question:message.error.missing_fields', {
+ fields: missingFieldsString,
+ postProcess: 'capitalizeFirstChar',
+ });
throw new Error(errorMsg);
}
const name = data.nameForSale;
@@ -4970,14 +6347,33 @@ export const sellNameRequest = async (data, isFromExtension) => {
const response = await fetch(validApi + '/names/' + name);
const nameData = await response.json();
- if (!nameData) throw new Error('This name does not exist');
+ if (!nameData)
+ throw new Error(
+ i18n.t('auth:message.error.name_not_existing', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
- if (nameData?.isForSale) throw new Error('This name is already for sale');
+ if (nameData?.isForSale)
+ throw new Error(
+ i18n.t('question:message.error.name_already_for_sale', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
const fee = await getFee('SELL_NAME');
const resPermission = await getUserPermission(
{
- text1: `Do you give this application permission to create a sell name transaction?`,
- highlightedText: `Sell ${name} for ${sellPrice} QORT`,
+ text1: i18n.t('question:permission.sell_name_transaction', {
+ postProcess: 'capitalizeFirstChar',
+ }),
+ highlightedText: i18n.t(
+ 'question:permission.sell_name_transaction_detail',
+ {
+ name: name,
+ price: sellPrice,
+ postProcess: 'capitalizeFirstChar',
+ }
+ ),
fee: fee.fee,
},
isFromExtension
@@ -4990,7 +6386,11 @@ export const sellNameRequest = async (data, isFromExtension) => {
});
return response;
} else {
- throw new Error('User declined request');
+ throw new Error(
+ i18n.t('question:message.generic.user_declined_request', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
};
@@ -5004,7 +6404,10 @@ export const cancelSellNameRequest = async (data, isFromExtension) => {
});
if (missingFields.length > 0) {
const missingFieldsString = missingFields.join(', ');
- const errorMsg = `Missing fields: ${missingFieldsString}`;
+ const errorMsg = i18n.t('question:message.error.missing_fields', {
+ fields: missingFieldsString,
+ postProcess: 'capitalizeFirstChar',
+ });
throw new Error(errorMsg);
}
const name = data.nameForSale;
@@ -5012,13 +6415,23 @@ export const cancelSellNameRequest = async (data, isFromExtension) => {
const response = await fetch(validApi + '/names/' + name);
const nameData = await response.json();
- if (!nameData?.isForSale) throw new Error('This name is not for sale');
+ if (!nameData?.isForSale)
+ throw new Error(
+ i18n.t('question:message.error.name_not_for_sale', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
const fee = await getFee('CANCEL_SELL_NAME');
const resPermission = await getUserPermission(
{
- text1: `Do you give this application permission to cancel the selling of a name?`,
- highlightedText: `Name: ${name}`,
+ text1: i18n.t('question:permission.sell_name_cancel', {
+ postProcess: 'capitalizeFirstChar',
+ }),
+ highlightedText: i18n.t('question:name', {
+ name: name,
+ postProcess: 'capitalizeFirstChar',
+ }),
fee: fee.fee,
},
isFromExtension
@@ -5030,7 +6443,11 @@ export const cancelSellNameRequest = async (data, isFromExtension) => {
});
return response;
} else {
- throw new Error('User declined request');
+ throw new Error(
+ i18n.t('question:message.generic.user_declined_request', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
};
@@ -5044,24 +6461,39 @@ export const buyNameRequest = async (data, isFromExtension) => {
});
if (missingFields.length > 0) {
const missingFieldsString = missingFields.join(', ');
- const errorMsg = `Missing fields: ${missingFieldsString}`;
+ const errorMsg = i18n.t('question:message.error.missing_fields', {
+ fields: missingFieldsString,
+ postProcess: 'capitalizeFirstChar',
+ });
throw new Error(errorMsg);
}
+
const name = data.nameForSale;
-
const validApi = await getBaseApi();
-
const response = await fetch(validApi + '/names/' + name);
const nameData = await response.json();
- if (!nameData?.isForSale) throw new Error('This name is not for sale');
+
+ if (!nameData?.isForSale)
+ throw new Error(
+ i18n.t('question:message.error.name_not_for_sale', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
+
const sellerAddress = nameData.owner;
const sellPrice = +nameData.salePrice;
const fee = await getFee('BUY_NAME');
const resPermission = await getUserPermission(
{
- text1: `Do you give this application permission to buy a name?`,
- highlightedText: `Buying ${name} for ${sellPrice} QORT`,
+ text1: i18n.t('question:permission.buy_name', {
+ postProcess: 'capitalizeFirstChar',
+ }),
+ highlightedText: i18n.t('question:permission.buy_name_detail', {
+ name: name,
+ price: sellPrice,
+ postProcess: 'capitalizeFirstChar',
+ }),
fee: fee.fee,
},
isFromExtension
@@ -5075,14 +6507,20 @@ export const buyNameRequest = async (data, isFromExtension) => {
});
return response;
} else {
- throw new Error('User declined request');
+ throw new Error(
+ i18n.t('question:message.generic.user_declined_request', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
};
export const signForeignFees = async (data, isFromExtension) => {
const resPermission = await getUserPermission(
{
- text1: `Do you give this application permission to sign the required fees for all your trade offers?`,
+ text1: i18n.t('question:permission.sign_fee', {
+ postProcess: 'capitalizeFirstChar',
+ }),
},
isFromExtension
);
@@ -5140,14 +6578,23 @@ export const signForeignFees = async (data, isFromExtension) => {
return true;
} else {
- throw new Error('User declined request');
+ throw new Error(
+ i18n.t('question:message.generic.user_declined_request', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
};
export const multiPaymentWithPrivateData = async (data, isFromExtension) => {
const requiredFields = ['payments', 'assetId'];
requiredFields.forEach((field) => {
if (data[field] === undefined || data[field] === null) {
- throw new Error(`Missing required field: ${field}`);
+ throw new Error(
+ i18n.t('question:message.error.missing_fields', {
+ fields: field,
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
});
const resKeyPair = await getKeyPair();
@@ -5172,13 +6619,22 @@ export const multiPaymentWithPrivateData = async (data, isFromExtension) => {
for (const field of requiredFieldsPayment) {
if (!payment[field]) {
- throw new Error(`Missing required field: ${field}`);
+ throw new Error(
+ i18n.t('question:message.error.missing_fields', {
+ fields: field,
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
}
const confirmReceiver = await getNameOrAddress(payment.recipient);
if (confirmReceiver.error) {
- throw new Error('Invalid receiver address or name');
+ throw new Error(
+ i18n.t('question:message.error.invalid_receiver', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
const receiverPublicKey = await getPublicKey(confirmReceiver);
@@ -5200,20 +6656,39 @@ export const multiPaymentWithPrivateData = async (data, isFromExtension) => {
for (const field of requiredFieldsArbitraryTx) {
if (!arbitraryTx[field]) {
- throw new Error(`Missing required field: ${field}`);
+ throw new Error(
+ i18n.t('question:message.error.missing_fields', {
+ fields: field,
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
}
if (!name) {
const getName = await getNameInfo();
- if (!getName) throw new Error('Name needed to publish');
+ if (!getName)
+ throw new Error(
+ i18n.t('question:message.error.registered_name', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
name = getName;
}
const isValid = isValidBase64WithDecode(arbitraryTx.base64);
- if (!isValid) throw new Error('Invalid base64 data');
+ if (!isValid)
+ throw new Error(
+ i18n.t('core:message.error.invalid_base64', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
if (!arbitraryTx?.service?.includes('_PRIVATE'))
- throw new Error('Please use a PRIVATE service');
+ throw new Error(
+ i18n.t('question:message.generic.private_service', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
const additionalPublicKeys = arbitraryTx?.additionalPublicKeys || [];
pendingTransactions.push({
type: 'ARBITRARY',
@@ -5239,20 +6714,39 @@ export const multiPaymentWithPrivateData = async (data, isFromExtension) => {
for (const field of requiredFieldsArbitraryTx) {
if (!arbitraryTx[field]) {
- throw new Error(`Missing required field: ${field}`);
+ throw new Error(
+ i18n.t('question:message.error.missing_fields', {
+ fields: field,
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
}
}
if (!name) {
const getName = await getNameInfo();
- if (!getName) throw new Error('Name needed to publish');
+ if (!getName)
+ throw new Error(
+ i18n.t('question:message.error.registered_name', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
name = getName;
}
const isValid = isValidBase64WithDecode(arbitraryTx.base64);
- if (!isValid) throw new Error('Invalid base64 data');
+ if (!isValid)
+ throw new Error(
+ i18n.t('core:message.error.invalid_base64', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
if (!arbitraryTx?.service?.includes('_PRIVATE'))
- throw new Error('Please use a PRIVATE service');
+ throw new Error(
+ i18n.t('question:message.generic.private_service', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
const additionalPublicKeys = arbitraryTx?.additionalPublicKeys || [];
pendingAdditionalArbitraryTxs.push({
type: 'ARBITRARY',
@@ -5267,20 +6761,38 @@ export const multiPaymentWithPrivateData = async (data, isFromExtension) => {
}
}
- if (!name) throw new Error('A name is needed to publish');
+ if (!name)
+ throw new Error(
+ i18n.t('question:message.error.registered_name', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
const balance = await getBalanceInfo();
- if (+balance < fee) throw new Error('Your QORT balance is insufficient');
+ if (+balance < fee)
+ throw new Error(
+ i18n.t('question:message.error.insufficient_balance_qort', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
const assetBalance = await getAssetBalanceInfo(assetId);
const assetInfo = await getAssetInfo(assetId);
if (assetBalance < totalAmount)
- throw new Error('Your asset balance is insufficient');
+ throw new Error(
+ i18n.t('question:message.error.insufficient_balance', {
+ postProcess: 'capitalizeFirstChar',
+ })
+ );
const resPermission = await getUserPermission(
{
- text1:
- 'Do you give this application permission to make the following payments and publishes?',
- text2: `Asset used in payments: ${assetInfo.name}`,
+ text1: i18n.t('question:permission.pay_publish', {
+ postProcess: 'capitalizeFirstChar',
+ }),
+ text2: i18n.t('question:assets_used_pay', {
+ asset: assetInfo.name,
+ postProcess: 'capitalizeFirstChar',
+ }),
html: `