nft-folder-blockchain-connector-besu
Version:
A NestJS-based blockchain connector that communicates with specific smart contracts from the NFT Folder project.
67 lines • 3.18 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.BLOCKCHAIN_CONFIGURATION_IDENTIFIER = void 0;
const common_1 = require("@nestjs/common");
const config_1 = require("@nestjs/config");
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
exports.BLOCKCHAIN_CONFIGURATION_IDENTIFIER = 'blockchain-configuration';
exports.default = (0, config_1.registerAs)(exports.BLOCKCHAIN_CONFIGURATION_IDENTIFIER, () => ({
port: parseInt(process.env.BCC_PORT, 10) || 4000,
logLevels: (process.env.BCC_LOG_LEVELS || 'error,log').split(','),
swaggerPath: process.env.BCC_SWAGGER_PATH || 'api',
endpointsEnabled: process.env.BCC_ENDPOINTS_ENABLED || 'false',
blockchainUrl: process.env.BCC_BLOCKCHAIN_URL || '',
blockTime: parseInt(process.env.BCC_BLOCK_TIME, 10) || 0,
privateKey: process.env.BCC_PRIVATE_KEY || '0x0000000000000000000000000000000000000000000000000000000000000001',
containerAddress: process.env.BCC_CONTAINER_ADDRESS || '0x0',
tokenAddress: process.env.BCC_TOKEN_ADDRESS || '0x0',
containerAbi: readAbiFile(process.env.BCC_CONTAINER_ABI_PATH || 'dummy-container.abi.json'),
segmentAbi: readAbiFile(process.env.BCC_SEGMENT_ABI_PATH || 'dummy-segment.abi.json'),
tokenAbi: readAbiFile(process.env.BCC_TOKEN_ABI_PATH || 'dummy-token.abi.json'),
}));
const logger = new common_1.Logger('BlockchainConfiguration');
function readAbiFile(filePath) {
try {
const absolutePath = path.resolve(process.cwd(), filePath);
return fs.readFileSync(absolutePath, 'utf8');
}
catch (error) {
logger.warn(`Failed to read the ABI file at '${filePath}'. Instead, using empty ABI for this smart contract.`, error);
return '[]';
}
}
//# sourceMappingURL=blockchain.configuration.js.map