fbonds-core
Version:
Banx protocol sdk
28 lines (27 loc) • 1.64 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const child_process_1 = require("child_process");
const src_1 = require("src");
const helpers_1 = require("src/fbond-protocol/helpers");
const currentBranch = (0, child_process_1.execSync)('git rev-parse --abbrev-ref HEAD').toString().trim();
const expectedProgramIdDevelopment = "HucrkqPP5RPQfwdbxTSE7fkmZ96U1ghFZHKbwcgoNDX5";
const expectedProgramIdMaster = "4tdmkuY6EStxbS6Y8s5ueznL3VPMSugrvQuDeAHGZhSt";
const mainnetConnection = new src_1.anchor.web3.Connection('https://mainnet.helius-rpc.com/?api-key=0dd0537a-65dd-4d40-a7d5-97804e3caa7e', 'confirmed');
const currentProgramId = (0, helpers_1.returnAnchorProgram)(mainnetConnection);
// Проверяем соответствие programId в зависимости от текущей ветки
if (currentBranch === 'development') {
if (currentProgramId.programId.toString() !== expectedProgramIdDevelopment) {
throw new Error(`ProgramId mismatch on development branch. Expected: ${expectedProgramIdDevelopment}, but got: ${currentProgramId}`);
}
}
else if (currentBranch === 'production') {
if (currentProgramId.programId.toString() !== expectedProgramIdMaster) {
throw new Error(`ProgramId mismatch on master branch. Expected: ${expectedProgramIdMaster}, but got: ${currentProgramId}`);
}
}
else {
if (currentProgramId.programId.toString() !== expectedProgramIdDevelopment) {
throw new Error(`ProgramId mismatch on development branch. Expected: ${expectedProgramIdDevelopment}, but got: ${currentProgramId}`);
}
}
console.log('ProgramId check passed.');