@cheqd/sdk
Version:
A TypeScript SDK built with CosmJS to interact with the cheqd network ledger
262 lines • 14 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.FeeabstractionModule = exports.setupFeeabstractionExtension = exports.typeUrlMsgUpdateParamsResponse = exports.typeUrlMsgUpdateParams = exports.typeUrlMsgUpdateHostZoneResponse = exports.typeUrlMsgUpdateHostZone = exports.typeUrlMsgSwapCrossChainResponse = exports.typeUrlMsgSwapCrossChain = exports.typeUrlMsgSendQueryIbcDenomTWAPResponse = exports.typeUrlMsgSendQueryIbcDenomTWAP = exports.typeUrlMsgRemoveHostZoneResponse = exports.typeUrlMsgRemoveHostZone = exports.typeUrlMsgFundFeeAbsModuleAccountResponse = exports.typeUrlMsgFundFeeAbsModuleAccount = exports.typeUrlMsgAddHostZoneResponse = exports.typeUrlMsgAddHostZone = exports.protobufLiterals = exports.defaultExtensionKey = void 0;
exports.isMsgAddHostZoneEncodeObject = isMsgAddHostZoneEncodeObject;
exports.isMsgAddHostZoneResponseEncodeObject = isMsgAddHostZoneResponseEncodeObject;
exports.isMsgFundFeeAbsModuleAccountEncodeObject = isMsgFundFeeAbsModuleAccountEncodeObject;
exports.isMsgFundFeeAbsModuleAccountResponseEncodeObject = isMsgFundFeeAbsModuleAccountResponseEncodeObject;
exports.isMsgRemoveHostZoneEncodeObject = isMsgRemoveHostZoneEncodeObject;
exports.isMsgRemoveHostZoneResponseEncodeObject = isMsgRemoveHostZoneResponseEncodeObject;
exports.isMsgSendQueryIbcDenomTWAPEncodeObject = isMsgSendQueryIbcDenomTWAPEncodeObject;
exports.isMsgSendQueryIbcDenomTWAPResponseEncodeObject = isMsgSendQueryIbcDenomTWAPResponseEncodeObject;
exports.isMsgSwapCrossChainEncodeObject = isMsgSwapCrossChainEncodeObject;
exports.isMsgSwapCrossChainResponseEncodeObject = isMsgSwapCrossChainResponseEncodeObject;
exports.isMsgUpdateHostZoneEncodeObject = isMsgUpdateHostZoneEncodeObject;
exports.isMsgUpdateHostZoneResponseEncodeObject = isMsgUpdateHostZoneResponseEncodeObject;
exports.isMsgUpdateParamsEncodeObject = isMsgUpdateParamsEncodeObject;
exports.isMsgUpdateParamsResponseEncodeObject = isMsgUpdateParamsResponseEncodeObject;
const index_1 = require("@cheqd/ts-proto-cjs/feeabstraction/feeabs/v1beta1/index");
const _1 = require("./_");
const stargate_cjs_1 = require("@cosmjs/stargate-cjs");
const tx_1 = require("cosmjs-types/cosmos/gov/v1/tx");
exports.defaultExtensionKey = 'feeabs';
exports.protobufLiterals = {
MsgAddHostZone: 'MsgAddHostZone',
MsgAddHostZoneResponse: 'MsgAddHostZoneResponse',
MsgFundFeeAbsModuleAccount: 'MsgFundFeeAbsModuleAccount',
MsgFundFeeAbsModuleAccountResponse: 'MsgFundFeeAbsModuleAccountResponse',
MsgRemoveHostZone: 'MsgRemoveHostZone',
MsgRemoveHostZoneResponse: 'MsgRemoveHostZoneResponse',
MsgSendQueryIbcDenomTWAP: 'MsgSendQueryIbcDenomTWAP',
MsgSendQueryIbcDenomTWAPResponse: 'MsgSendQueryIbcDenomTWAPResponse',
MsgSwapCrossChain: 'MsgSwapCrossChain',
MsgSwapCrossChainResponse: 'MsgSwapCrossChainResponse',
MsgUpdateHostZone: 'MsgUpdateHostZone',
MsgUpdateHostZoneResponse: 'MsgUpdateHostZoneResponse',
MsgUpdateParams: 'MsgUpdateParams',
MsgUpdateParamsResponse: 'MsgUpdateParamsResponse',
};
exports.typeUrlMsgAddHostZone = `/${index_1.protobufPackage}.${exports.protobufLiterals.MsgAddHostZone}`;
exports.typeUrlMsgAddHostZoneResponse = `/${index_1.protobufPackage}.${exports.protobufLiterals.MsgAddHostZoneResponse}`;
exports.typeUrlMsgFundFeeAbsModuleAccount = `/${index_1.protobufPackage}.${exports.protobufLiterals.MsgFundFeeAbsModuleAccount}`;
exports.typeUrlMsgFundFeeAbsModuleAccountResponse = `/${index_1.protobufPackage}.${exports.protobufLiterals.MsgFundFeeAbsModuleAccountResponse}`;
exports.typeUrlMsgRemoveHostZone = `/${index_1.protobufPackage}.${exports.protobufLiterals.MsgRemoveHostZone}`;
exports.typeUrlMsgRemoveHostZoneResponse = `/${index_1.protobufPackage}.${exports.protobufLiterals.MsgRemoveHostZoneResponse}`;
exports.typeUrlMsgSendQueryIbcDenomTWAP = `/${index_1.protobufPackage}.${exports.protobufLiterals.MsgSendQueryIbcDenomTWAP}`;
exports.typeUrlMsgSendQueryIbcDenomTWAPResponse = `/${index_1.protobufPackage}.${exports.protobufLiterals.MsgSendQueryIbcDenomTWAPResponse}`;
exports.typeUrlMsgSwapCrossChain = `/${index_1.protobufPackage}.${exports.protobufLiterals.MsgSwapCrossChain}`;
exports.typeUrlMsgSwapCrossChainResponse = `/${index_1.protobufPackage}.${exports.protobufLiterals.MsgSwapCrossChainResponse}`;
exports.typeUrlMsgUpdateHostZone = `/${index_1.protobufPackage}.${exports.protobufLiterals.MsgUpdateHostZone}`;
exports.typeUrlMsgUpdateHostZoneResponse = `/${index_1.protobufPackage}.${exports.protobufLiterals.MsgUpdateHostZoneResponse}`;
exports.typeUrlMsgUpdateParams = `/${index_1.protobufPackage}.${exports.protobufLiterals.MsgUpdateParams}`;
exports.typeUrlMsgUpdateParamsResponse = `/${index_1.protobufPackage}.${exports.protobufLiterals.MsgUpdateParamsResponse}`;
function isMsgAddHostZoneEncodeObject(obj) {
return obj.typeUrl === exports.typeUrlMsgAddHostZone;
}
function isMsgAddHostZoneResponseEncodeObject(obj) {
return obj.typeUrl === exports.typeUrlMsgAddHostZoneResponse;
}
function isMsgFundFeeAbsModuleAccountEncodeObject(obj) {
return obj.typeUrl === exports.typeUrlMsgFundFeeAbsModuleAccount;
}
function isMsgFundFeeAbsModuleAccountResponseEncodeObject(obj) {
return obj.typeUrl === exports.typeUrlMsgFundFeeAbsModuleAccountResponse;
}
function isMsgRemoveHostZoneEncodeObject(obj) {
return obj.typeUrl === exports.typeUrlMsgRemoveHostZone;
}
function isMsgRemoveHostZoneResponseEncodeObject(obj) {
return obj.typeUrl === exports.typeUrlMsgRemoveHostZoneResponse;
}
function isMsgSendQueryIbcDenomTWAPEncodeObject(obj) {
return obj.typeUrl === exports.typeUrlMsgSendQueryIbcDenomTWAP;
}
function isMsgSendQueryIbcDenomTWAPResponseEncodeObject(obj) {
return obj.typeUrl === exports.typeUrlMsgSendQueryIbcDenomTWAPResponse;
}
function isMsgSwapCrossChainEncodeObject(obj) {
return obj.typeUrl === exports.typeUrlMsgSwapCrossChain;
}
function isMsgSwapCrossChainResponseEncodeObject(obj) {
return obj.typeUrl === exports.typeUrlMsgSwapCrossChainResponse;
}
function isMsgUpdateHostZoneEncodeObject(obj) {
return obj.typeUrl === exports.typeUrlMsgUpdateHostZone;
}
function isMsgUpdateHostZoneResponseEncodeObject(obj) {
return obj.typeUrl === exports.typeUrlMsgUpdateHostZoneResponse;
}
function isMsgUpdateParamsEncodeObject(obj) {
return obj.typeUrl === exports.typeUrlMsgUpdateParams;
}
function isMsgUpdateParamsResponseEncodeObject(obj) {
return obj.typeUrl === exports.typeUrlMsgUpdateParamsResponse;
}
const setupFeeabstractionExtension = (base) => {
const rpc = (0, stargate_cjs_1.createProtobufRpcClient)(base);
const queryService = new index_1.QueryClientImpl(rpc);
return {
[exports.defaultExtensionKey]: {
hostChainConfig: async (request) => {
return await queryService.HostChainConfig(request);
},
osmosisArithmeticTwap: async (request) => {
return await queryService.OsmosisArithmeticTwap(request);
},
feeabsModuleBalances: async (request) => {
return await queryService.FeeabsModuleBalances(request);
},
},
};
};
exports.setupFeeabstractionExtension = setupFeeabstractionExtension;
class FeeabstractionModule extends _1.AbstractCheqdSDKModule {
// @ts-expect-error underlying type `GeneratedType` is intentionally wider
static registryTypes = [
[exports.typeUrlMsgAddHostZone, index_1.MsgAddHostZone],
[exports.typeUrlMsgAddHostZoneResponse, index_1.MsgAddHostZoneResponse],
[exports.typeUrlMsgFundFeeAbsModuleAccount, index_1.MsgFundFeeAbsModuleAccount],
[exports.typeUrlMsgFundFeeAbsModuleAccountResponse, index_1.MsgFundFeeAbsModuleAccountResponse],
[exports.typeUrlMsgRemoveHostZone, index_1.MsgRemoveHostZone],
[exports.typeUrlMsgRemoveHostZoneResponse, index_1.MsgRemoveHostZoneResponse],
[exports.typeUrlMsgSendQueryIbcDenomTWAP, index_1.MsgSendQueryIbcDenomTWAP],
[exports.typeUrlMsgSendQueryIbcDenomTWAPResponse, index_1.MsgSendQueryIbcDenomTWAPResponse],
[exports.typeUrlMsgSwapCrossChain, index_1.MsgSwapCrossChain],
[exports.typeUrlMsgSwapCrossChainResponse, index_1.MsgSwapCrossChainResponse],
[exports.typeUrlMsgUpdateHostZone, index_1.MsgUpdateHostZone],
[exports.typeUrlMsgUpdateHostZoneResponse, index_1.MsgUpdateHostZoneResponse],
[exports.typeUrlMsgUpdateParams, index_1.MsgUpdateParams],
[exports.typeUrlMsgUpdateParamsResponse, index_1.MsgUpdateParamsResponse],
];
static querierExtensionSetup = exports.setupFeeabstractionExtension;
querier;
constructor(signer, querier) {
super(signer, querier);
this.querier = querier;
this.methods = {
addHostZoneProposal: this.addHostZoneProposal.bind(this),
fundFeeAbsModuleAccount: this.fundFeeAbsModuleAccount.bind(this),
removeHostZoneProposal: this.removeHostZoneProposal.bind(this),
sendQueryIbcDenomTWAP: this.sendQueryIbcDenomTWAP.bind(this),
swapCrossChain: this.swapCrossChain.bind(this),
updateHostZoneProposal: this.updateHostZoneProposal.bind(this),
updateParamsProposal: this.updateParamsProposal.bind(this),
};
}
getRegistryTypes() {
return FeeabstractionModule.registryTypes;
}
getQuerierExtensionSetup() {
return FeeabstractionModule.querierExtensionSetup;
}
async addHostZoneProposal(data, title, deposit, proposer, fee, memo, context) {
if (!this._signer)
this._signer = context.sdk.signer;
const proposalEncodeObject = {
typeUrl: '/cosmos.gov.v1.MsgSubmitProposal',
value: tx_1.MsgSubmitProposal.fromPartial({
messages: [
{
typeUrl: exports.typeUrlMsgAddHostZone,
value: Uint8Array.from(index_1.MsgAddHostZone.encode(data).finish()),
},
],
title,
initialDeposit: deposit,
proposer,
}),
};
return await this._signer.signAndBroadcast(proposer, [proposalEncodeObject], fee, memo);
}
async fundFeeAbsModuleAccount(sender, amount, fee, memo, context) {
if (!this._signer)
this._signer = context.sdk.signer;
const fundFeeAbsModuleAccountMsg = {
typeUrl: exports.typeUrlMsgFundFeeAbsModuleAccount,
value: {
sender,
amount,
},
};
return await this._signer.signAndBroadcast(sender, [fundFeeAbsModuleAccountMsg], fee, memo);
}
async removeHostZoneProposal(data, title, deposit, proposer, fee, memo, context) {
if (!this._signer)
this._signer = context.sdk.signer;
const proposalEncodeObject = {
typeUrl: '/cosmos.gov.v1.MsgSubmitProposal',
value: tx_1.MsgSubmitProposal.fromPartial({
messages: [
{
typeUrl: exports.typeUrlMsgRemoveHostZone,
value: Uint8Array.from(index_1.MsgRemoveHostZone.encode(data).finish()),
},
],
title,
initialDeposit: deposit,
proposer,
}),
};
return await this._signer.signAndBroadcast(proposer, [proposalEncodeObject], fee, memo);
}
async sendQueryIbcDenomTWAP(sender, data, fee, memo, context) {
if (!this._signer)
this._signer = context.sdk.signer;
const sendQueryIbcDenomTwapMsg = {
typeUrl: exports.typeUrlMsgSendQueryIbcDenomTWAP,
value: data,
};
return await this._signer.signAndBroadcast(sender, [sendQueryIbcDenomTwapMsg], fee, memo);
}
async swapCrossChain(sender, ibcDenom, fee, memo, context) {
if (!this._signer)
this._signer = context.sdk.signer;
const swapCrossChainMsg = {
typeUrl: exports.typeUrlMsgSwapCrossChain,
value: {
ibcDenom,
},
};
return await this._signer.signAndBroadcast(sender, [swapCrossChainMsg], fee, memo);
}
async updateHostZoneProposal(data, title, deposit, proposer, fee, memo, context) {
if (!this._signer)
this._signer = context.sdk.signer;
const proposalEncodeObject = {
typeUrl: '/cosmos.gov.v1.MsgSubmitProposal',
value: tx_1.MsgSubmitProposal.fromPartial({
messages: [
{
typeUrl: exports.typeUrlMsgUpdateHostZone,
value: Uint8Array.from(index_1.MsgUpdateHostZone.encode(data).finish()),
},
],
title,
initialDeposit: deposit,
proposer,
}),
};
return await this._signer.signAndBroadcast(proposer, [proposalEncodeObject], fee, memo);
}
async updateParamsProposal(data, title, deposit, proposer, fee, memo, context) {
if (!this._signer)
this._signer = context.sdk.signer;
const proposalEncodeObject = {
typeUrl: '/cosmos.gov.v1.MsgSubmitProposal',
value: tx_1.MsgSubmitProposal.fromPartial({
messages: [
{
typeUrl: exports.typeUrlMsgUpdateParams,
value: Uint8Array.from(index_1.MsgUpdateParams.encode(data).finish()),
},
],
title,
initialDeposit: deposit,
proposer,
}),
};
return await this._signer.signAndBroadcast(proposer, [proposalEncodeObject], fee, memo);
}
}
exports.FeeabstractionModule = FeeabstractionModule;
//# sourceMappingURL=feeabstraction.js.map