gamechanger-dapp-cli
Version:
Command line interface for creating ready to use dApps for Cardano with GameChanger Wallet (https://gamechanger.finance/)
37 lines • 1.25 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const json_url_1 = __importDefault(require("json-url"));
const codec = (0, json_url_1.default)('lzw');
exports.default = ({ network, inputData }) => {
let jsoned;
try {
if (!inputData)
throw new Error('Empty GCScript provided');
jsoned = JSON.parse(inputData);
}
catch (err) {
if (err instanceof Error) {
throw new Error('Invalid GCScript. ' + err.message);
}
}
return codec
.compress(jsoned)
.then((gcscript) => {
let url;
if (network === 'mainnet')
url = 'https://wallet.gamechanger.finance/api/1/tx/' + gcscript;
else if (network === 'testnet')
url = 'https://testnet-wallet.gamechanger.finance/api/1/tx/' + gcscript;
else
throw new Error('Unknown Cardano network specification');
console.info(url);
return url;
})
.catch((err) => {
throw new Error('URL generation failed.' + err.message);
});
};
//# sourceMappingURL=url.js.map