SHA256
GPT: сгенерено и не проверено (смена ключей пользователя)
This commit is contained in:
@@ -25,8 +25,8 @@ function parseSolToLamports(amountSol) {
|
||||
return lamports.toString();
|
||||
}
|
||||
|
||||
function normalizeKeySource(value) {
|
||||
return String(value || '').trim().toLowerCase() === 'root' ? 'root' : 'client';
|
||||
function normalizeKeySource() {
|
||||
return 'blockchain';
|
||||
}
|
||||
|
||||
async function loadTurboLib() {
|
||||
@@ -36,14 +36,12 @@ async function loadTurboLib() {
|
||||
return turboLibPromise;
|
||||
}
|
||||
|
||||
async function getTurboWalletChoice({ login, storagePwd, keySource = 'client' } = {}) {
|
||||
async function getTurboWalletChoice({ login, storagePwd, keySource = 'blockchain' } = {}) {
|
||||
const normalizedKeySource = normalizeKeySource(keySource);
|
||||
const choices = await getStoredSolanaWalletChoices({ login, storagePwd, includeRoot: true });
|
||||
const choices = await getStoredSolanaWalletChoices({ login, storagePwd });
|
||||
const selected = choices.find((item) => item.keySource === normalizedKeySource) || choices[0] || null;
|
||||
if (!selected?.keypair) {
|
||||
throw new Error(normalizedKeySource === 'root'
|
||||
? 'На устройстве не найден root key для Turbo.'
|
||||
: 'На устройстве не найден client key для Turbo.');
|
||||
throw new Error('На устройстве не найден blockchain key для Turbo.');
|
||||
}
|
||||
return selected;
|
||||
}
|
||||
@@ -90,7 +88,7 @@ export function formatTurboCredits(value, digits = 6) {
|
||||
});
|
||||
}
|
||||
|
||||
export async function getTurboContextForStoredSolanaKey({ login, storagePwd, keySource = 'client' } = {}) {
|
||||
export async function getTurboContextForStoredSolanaKey({ login, storagePwd, keySource = 'blockchain' } = {}) {
|
||||
const choice = await getTurboWalletChoice({ login, storagePwd, keySource });
|
||||
const turbo = await createTurboClientFromWalletChoice(choice);
|
||||
return {
|
||||
@@ -103,7 +101,7 @@ export async function getTurboContextForStoredSolanaKey({ login, storagePwd, key
|
||||
};
|
||||
}
|
||||
|
||||
export async function getTurboBalanceForStoredSolanaKey({ login, storagePwd, keySource = 'client' } = {}) {
|
||||
export async function getTurboBalanceForStoredSolanaKey({ login, storagePwd, keySource = 'blockchain' } = {}) {
|
||||
const ctx = await getTurboContextForStoredSolanaKey({ login, storagePwd, keySource });
|
||||
const balance = await ctx.turbo.getBalance(ctx.address);
|
||||
const solanaBalance = await getBalanceSol({
|
||||
@@ -123,7 +121,7 @@ export async function getTurboBalanceForStoredSolanaKey({ login, storagePwd, key
|
||||
};
|
||||
}
|
||||
|
||||
export async function estimateTurboUploadPrice({ login, storagePwd, keySource = 'client', byteLength } = {}) {
|
||||
export async function estimateTurboUploadPrice({ login, storagePwd, keySource = 'blockchain', byteLength } = {}) {
|
||||
const bytes = Number(byteLength);
|
||||
if (!Number.isInteger(bytes) || bytes <= 0) {
|
||||
throw new Error('Некорректный размер файла для Turbo.');
|
||||
@@ -147,7 +145,7 @@ export async function estimateTurboUploadPrice({ login, storagePwd, keySource =
|
||||
export async function uploadFileWithTurbo({
|
||||
login,
|
||||
storagePwd,
|
||||
keySource = 'client',
|
||||
keySource = 'blockchain',
|
||||
file,
|
||||
tags = [],
|
||||
shineType = 'attachment',
|
||||
@@ -191,7 +189,7 @@ export async function uploadFileWithTurbo({
|
||||
export async function topUpTurboWithSolana({
|
||||
login,
|
||||
storagePwd,
|
||||
keySource = 'client',
|
||||
keySource = 'blockchain',
|
||||
amountSol,
|
||||
turboCreditDestinationAddress = '',
|
||||
} = {}) {
|
||||
|
||||
Reference in New Issue
Block a user