@cyberk/hyperion-sdk
Version:
Hyperion SDK from Cyberk
50 lines • 1.87 kB
JavaScript
import { buildExecuteContractMsg } from "../utils/buildExecuteContractMsg";
export 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 buildExecuteContractMsg(factoryAddress, msg, signerAddress, []);
};
export const getAddNativeTokenDecimalsQueryKey = (options) => {
return [
"addNativeTokenDecimals",
options.isSimulate ? "simulate" : "execute",
options.factoryAddress,
options.denom,
options.decimals,
options.signerAddress,
];
};
export const getAddNativeTokenDecimalsMutationOptions = (options) => {
return {
mutationFn: async (variables) => {
const { isSimulate = false } = options;
const { signingClient, signerAddress, fee, memo, factoryAddress, denom, decimals, } = variables;
const message = 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",
],
};
};
//# sourceMappingURL=addNativeTokenDecimals.js.map