stellar-plus
Version:
beta version of stellar-plus, an all-in-one sdk for the Stellar blockchain
84 lines (83 loc) • 4.2 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PSAError = exports.ErrorCodesPipelineSorobanAuth = void 0;
const error_1 = require("../../../../stellar-plus/error");
const transaction_1 = require("../../../../stellar-plus/error/helpers/transaction");
var ErrorCodesPipelineSorobanAuth;
(function (ErrorCodesPipelineSorobanAuth) {
// PSA0 General
ErrorCodesPipelineSorobanAuth["PSA001"] = "PSA001";
ErrorCodesPipelineSorobanAuth["PSA002"] = "PSA002";
ErrorCodesPipelineSorobanAuth["PSA003"] = "PSA003";
ErrorCodesPipelineSorobanAuth["PSA004"] = "PSA004";
})(ErrorCodesPipelineSorobanAuth || (exports.ErrorCodesPipelineSorobanAuth = ErrorCodesPipelineSorobanAuth = {}));
const signerNotFound = (conveyorBeltErrorMeta, transaction, signers, authEntryRequiredSigner, authEntry) => {
return new error_1.StellarPlusError({
code: ErrorCodesPipelineSorobanAuth.PSA001,
message: 'The signer was not found!',
source: 'PipelineSorobanAuth',
details: `The required signer was not found in the provided signers list. The missing signer is: ${authEntryRequiredSigner}. `,
meta: {
data: { signers, authEntryRequiredSigner, authEntry: authEntry.toXDR('base64') },
transactionData: (0, transaction_1.extractTransactionData)(transaction),
conveyorBeltErrorMeta,
},
});
};
const noSignersProvided = (conveyorBeltErrorMeta) => {
return new error_1.StellarPlusError({
code: ErrorCodesPipelineSorobanAuth.PSA002,
message: 'No signers provided!',
source: 'PipelineSorobanAuth',
details: `No signers provided. Review your transaction workflow to ensure the proper signers are being provided for the transaction.`,
meta: {
conveyorBeltErrorMeta,
},
});
};
const couldntUpdateTransaction = (error, conveyorBeltErrorMeta, transaction, signedAuthEntries) => {
return new error_1.StellarPlusError({
code: ErrorCodesPipelineSorobanAuth.PSA003,
message: 'Could not update transaction!',
source: 'PipelineSorobanAuth',
details: `The transaction could not be updated with the signed authorization entries. The error '${error.message}' was caught.Review the details of the transaction and the provided signers.`,
meta: {
error,
data: { signedAuthEntries: signedAuthEntries.map((s) => s.toXDR('base64')) },
transactionData: (0, transaction_1.extractTransactionData)(transaction),
conveyorBeltErrorMeta,
},
});
};
const couldntSimulateAuthorizedTransaction = (error, conveyorBeltErrorMeta, transaction, signedAuthEntries) => {
return new error_1.StellarPlusError({
code: ErrorCodesPipelineSorobanAuth.PSA003,
message: 'Could not simulate transaction with signed soroban entries!',
source: 'PipelineSorobanAuth',
details: `The transaction was updated with the signed authorization entries, but the simulation failed. The error '${error.message}' was caught.Review the details of the transaction and the provided signers.`,
meta: {
error,
data: { signedAuthEntries: signedAuthEntries.map((s) => s.toXDR('base64')) },
transactionData: (0, transaction_1.extractTransactionData)(transaction),
conveyorBeltErrorMeta,
},
});
};
const contractAuthNotSupported = (contractId, conveyorBeltErrorMeta) => {
return new error_1.StellarPlusError({
code: ErrorCodesPipelineSorobanAuth.PSA004,
message: 'Contract authorization not supported!',
source: 'PipelineSorobanAuth',
details: `Contract authorization is not supported in the current version of Stellar Plus. This contract function is verifying against a specific contract authorization from (${contractId}) which is likely expected to be accessed as a sub-invocation instead of root invocation.`,
meta: {
conveyorBeltErrorMeta,
},
});
};
exports.PSAError = {
signerNotFound,
noSignersProvided,
couldntUpdateTransaction,
couldntSimulateAuthorizedTransaction,
contractAuthNotSupported,
};