@cyberk/hyperion-sdk
Version:
Hyperion SDK from Cyberk
56 lines • 2.4 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAddNativeTokenDecimalsMutationOptions = exports.getAddNativeTokenDecimalsQueryKey = exports.getAddNativeTokenDecimalsContractExecuteMsg = void 0;
const buildExecuteContractMsg_1 = require("../utils/buildExecuteContractMsg");
const getAddNativeTokenDecimalsContractExecuteMsg = (options) => {
const { factoryAddress, signerAddress, denom, decimals } = options;
const msg = {
add_native_token_decimals: {
denom: denom,
decimals: decimals,
},
};
// This operation typically does not require sending funds with the message itself.
return (0, buildExecuteContractMsg_1.buildExecuteContractMsg)(factoryAddress, msg, signerAddress, []);
};
exports.getAddNativeTokenDecimalsContractExecuteMsg = getAddNativeTokenDecimalsContractExecuteMsg;
const getAddNativeTokenDecimalsQueryKey = (options) => {
return [
"addNativeTokenDecimals",
options.isSimulate ? "simulate" : "execute",
options.factoryAddress,
options.denom,
options.decimals,
options.signerAddress,
];
};
exports.getAddNativeTokenDecimalsQueryKey = getAddNativeTokenDecimalsQueryKey;
const getAddNativeTokenDecimalsMutationOptions = (options) => {
return {
mutationFn: async (variables) => {
const { isSimulate = false } = options;
const { signingClient, signerAddress, fee, memo, factoryAddress, denom, decimals, } = variables;
const message = (0, exports.getAddNativeTokenDecimalsContractExecuteMsg)({
factoryAddress,
signerAddress,
denom,
decimals,
});
if (isSimulate) {
return await signingClient.simulate(signerAddress, [message], memo);
}
else {
if (!fee) {
throw new Error("Fee is required for execution");
}
return await signingClient.signAndBroadcast(signerAddress, [message], fee, memo);
}
},
mutationKey: [
"addNativeTokenDecimals",
options.isSimulate ? "simulate" : "execute",
],
};
};
exports.getAddNativeTokenDecimalsMutationOptions = getAddNativeTokenDecimalsMutationOptions;
//# sourceMappingURL=addNativeTokenDecimals.js.map