stellar-plus
Version:
beta version of stellar-plus, an all-in-one sdk for the Stellar blockchain
77 lines (76 loc) • 3.63 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FAHError = exports.FreighterAccountHandlerErrorCodes = void 0;
const error_1 = require("../../../../stellar-plus/error");
var FreighterAccountHandlerErrorCodes;
(function (FreighterAccountHandlerErrorCodes) {
// FAH0 General
FreighterAccountHandlerErrorCodes["FAH001"] = "FAH001";
FreighterAccountHandlerErrorCodes["FAH002"] = "FAH002";
FreighterAccountHandlerErrorCodes["FAH003"] = "FAH003";
FreighterAccountHandlerErrorCodes["FAH004"] = "FAH004";
FreighterAccountHandlerErrorCodes["FAH005"] = "FAH005";
FreighterAccountHandlerErrorCodes["FAH006"] = "FAH006";
})(FreighterAccountHandlerErrorCodes || (exports.FreighterAccountHandlerErrorCodes = FreighterAccountHandlerErrorCodes = {}));
const connectedToWrongNetworkError = (targetNetworkName, error) => {
return new error_1.StellarPlusError({
code: FreighterAccountHandlerErrorCodes.FAH001,
message: 'Connected to wrong network!',
source: 'FreighterAccountHandler',
details: `The Freighter account is connected to the wrong network. Make sure that the Freighter account is connected to the ${targetNetworkName}.`,
meta: { error },
});
};
const failedToLoadPublicKeyError = (error) => {
return new error_1.StellarPlusError({
code: FreighterAccountHandlerErrorCodes.FAH002,
message: 'Failed to load public key!',
source: 'FreighterAccountHandler',
details: 'The public key could not be loaded. Make sure that the Freighter account is connected.',
meta: { error },
});
};
const failedToSignTransactionError = (error) => {
return new error_1.StellarPlusError({
code: FreighterAccountHandlerErrorCodes.FAH003,
message: 'Failed to sign transaction!',
source: 'FreighterAccountHandler',
details: 'The transaction could not be signed. Review the Freighter account.',
meta: { error },
});
};
const freighterIsNotConnectedError = (error) => {
return new error_1.StellarPlusError({
code: FreighterAccountHandlerErrorCodes.FAH004,
message: 'Freighter is not connected!',
source: 'FreighterAccountHandler',
details: 'Freighter is not connected. Make sure that the Freighter account is connected.',
meta: { error },
});
};
const failedToSignAuthEntryError = (error) => {
return new error_1.StellarPlusError({
code: FreighterAccountHandlerErrorCodes.FAH005,
message: 'Failed to sign soroban authorization entry!',
source: 'FreighterAccountHandler',
details: 'An error occurred while signing the soroban authorization entry. Review the Freighter account and meta for more details.',
meta: { error },
});
};
const cannotSignForThisNetwork = (entryNetwork, freighterNetwork, error) => {
return new error_1.StellarPlusError({
code: FreighterAccountHandlerErrorCodes.FAH006,
message: 'Failed to soroban authorization entry!',
source: 'FreighterAccountHandler',
details: `An error occurred while signing the soroban authorization entry. The network passphrase provided to sign this entry differs from the one initialized in the Freighter account handler. Entry network passphrase: ${entryNetwork}, Freighter network passphrase: ${freighterNetwork}.`,
meta: { error },
});
};
exports.FAHError = {
connectedToWrongNetworkError,
failedToLoadPublicKeyError,
failedToSignTransactionError,
freighterIsNotConnectedError,
failedToSignAuthEntryError,
cannotSignForThisNetwork,
};