UNPKG

stellar-plus

Version:

beta version of stellar-plus, an all-in-one sdk for the Stellar blockchain

150 lines (149 loc) 7.44 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CEError = exports.ContractEngineErrorCodes = void 0; const error_1 = require("../../../stellar-plus/error"); var ContractEngineErrorCodes; (function (ContractEngineErrorCodes) { // CE0 General ContractEngineErrorCodes["CE001"] = "CE001"; ContractEngineErrorCodes["CE002"] = "CE002"; ContractEngineErrorCodes["CE003"] = "CE003"; ContractEngineErrorCodes["CE004"] = "CE004"; ContractEngineErrorCodes["CE005"] = "CE005"; // CE1 Meta ContractEngineErrorCodes["CE101"] = "CE101"; ContractEngineErrorCodes["CE102"] = "CE102"; ContractEngineErrorCodes["CE103"] = "CE103"; // CE2 Missing parameters ContractEngineErrorCodes["CE201"] = "CE201"; ContractEngineErrorCodes["CE202"] = "CE202"; ContractEngineErrorCodes["CE203"] = "CE203"; ContractEngineErrorCodes["CE204"] = "CE204"; ContractEngineErrorCodes["CE205"] = "CE205"; })(ContractEngineErrorCodes || (exports.ContractEngineErrorCodes = ContractEngineErrorCodes = {})); const contractIdAlreadySet = () => { return new error_1.StellarPlusError({ code: ContractEngineErrorCodes.CE001, message: 'Contract ID already set!', source: 'ContractEngine', details: 'Contract ID already set! This function requires a contract Id to be defined in this instance. You can initialize the contract engine with a contract ID or use the "deploy" function to deploy a new instance of the contract, or user the wrapAndDeployClassicAsset to wrap a classic asset with the Stellar Asset Contract.', }); }; const contractInstanceNotFound = (ledgerEntries) => { return new error_1.StellarPlusError({ code: ContractEngineErrorCodes.CE002, message: 'Contract instance not found!', source: 'ContractEngine', details: 'Contract instance not found! The contract instance could not be found on the Stellar network. Please verify the contract ID and make sure the contract instance has been deployed to the Stellar network.', meta: { data: { ledgerEntries } }, }); }; const contractInstanceMissingLiveUntilLedgerSeq = (ledgerEntries) => { return new error_1.StellarPlusError({ code: ContractEngineErrorCodes.CE003, message: 'Contract instance missing live_until_ledger_seq!', source: 'ContractEngine', details: 'Contract instance missing live_until_ledger_seq! The contract instance is missing the live_until_ledger_seq property. Please verify the contract ID and make sure the contract instance has been deployed to the Stellar network.', meta: { data: { ledgerEntries } }, }); }; const contractCodeNotFound = (ledgerEntries) => { return new error_1.StellarPlusError({ code: ContractEngineErrorCodes.CE004, message: 'Contract code not found!', source: 'ContractEngine', details: 'Contract code not found! The contract code could not be found on the Stellar network. Please verify the contract wasm hash and make sure the contract wasm has been uploaded to the Stellar network.', meta: { data: { ledgerEntries } }, }); }; const contractCodeMissingLiveUntilLedgerSeq = (ledgerEntries) => { return new error_1.StellarPlusError({ code: ContractEngineErrorCodes.CE005, message: 'Contract code missing live_until_ledger_seq!', source: 'ContractEngine', details: 'Contract code missing live_until_ledger_seq! The contract code is missing the live_until_ledger_seq property. Please verify the contract wasm hash and make sure the contract wasm has been uploaded to the Stellar network.', meta: { data: { ledgerEntries } }, }); }; const failedToUploadWasm = (error) => { return new error_1.StellarPlusError({ code: ContractEngineErrorCodes.CE101, message: 'Failed to upload wasm!', source: 'ContractEngine', details: 'The wasm file could not be uploaded. Review the meta error to identify the underlying cause for this issue.', meta: { message: error.message, error: error }, }); }; const failedToDeployContract = (error) => { return new error_1.StellarPlusError({ code: ContractEngineErrorCodes.CE102, message: 'Failed to deploy contract!', source: 'ContractEngine', details: 'The contract could not be deployed. Review the meta error to identify the underlying cause for this issue.', meta: Object.assign({ message: error.message }, error.meta), }); }; const failedToWrapAsset = (error) => { return new error_1.StellarPlusError({ code: ContractEngineErrorCodes.CE103, message: 'Failed to wrap asset!', source: 'ContractEngine', details: 'The asset could not be wrapped. Review the meta error to identify the underlying cause for this issue.', meta: Object.assign({ message: error.message }, error.meta), }); }; const missingContractId = () => { return new error_1.StellarPlusError({ code: ContractEngineErrorCodes.CE201, message: 'Missing contract ID!', source: 'ContractEngine', details: "Missing contract ID! This function requires a contract Id to be defined in this instance. You can either initialize the contract engine with a contract ID or use the 'deploy' function to deploy a new instance of the contract, which will automatically set the new contract Id for this instance.", }); }; const missingWasm = () => { return new error_1.StellarPlusError({ code: ContractEngineErrorCodes.CE202, message: 'Missing wasm!', source: 'ContractEngine', details: 'Missing wasm! This function requires a buffer of the wasm file to be defined in this instance. You need to initialize the contract engine with a wasm file buffer.', }); }; const missingWasmHash = () => { return new error_1.StellarPlusError({ code: ContractEngineErrorCodes.CE203, message: 'Missing wasm hash!', source: 'ContractEngine', details: "Missing wasm hash! This function requires a wasm hash to be defined in this instance. You can either initialize the contract engine with a wasm hash or use the 'uploadWasm' function to upload a new wasm file, which will automatically set the new wasm hash for this instance.", }); }; const missingSpec = () => { return new error_1.StellarPlusError({ code: ContractEngineErrorCodes.CE204, message: 'Missing spec!', source: 'ContractEngine', details: 'Missing spec! This function requires a spec to be defined in this instance. You need to initialize the contract engine with a spec.', }); }; const missingSpecInWasm = () => { return new error_1.StellarPlusError({ code: ContractEngineErrorCodes.CE205, message: 'Missing spec in wasm!', source: 'ContractEngine', details: 'Missing spec in wasm! The wasm file does not contain the contract spec. Verify the wasm file and make sure the contract spec was compiled correctly.', }); }; exports.CEError = { contractIdAlreadySet, contractInstanceNotFound, contractInstanceMissingLiveUntilLedgerSeq, contractCodeNotFound, contractCodeMissingLiveUntilLedgerSeq, failedToUploadWasm, failedToDeployContract, failedToWrapAsset, missingContractId, missingWasm, missingWasmHash, missingSpec, missingSpecInWasm, };