diff --git a/package.json b/package.json index 507b9a6..93fb6c6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lum-network/sdk-javascript", - "version": "0.7.3", + "version": "0.7.4", "license": "Apache-2.0", "description": "Javascript SDK library for NodeJS and Web browsers to interact with the Lum Network.", "homepage": "https://github.com/lum-network/sdk-javascript#readme", diff --git a/src/messages/ibc/MsgAcknowledgement.ts b/src/messages/ibc/MsgAcknowledgement.ts new file mode 100644 index 0000000..de8057b --- /dev/null +++ b/src/messages/ibc/MsgAcknowledgement.ts @@ -0,0 +1,19 @@ +import { Message } from '../Message'; +import { MsgAcknowledgement } from '../../codec/ibc/core/channel/v1/tx'; +import { Packet } from '../../codec/ibc/core/channel/v1/channel'; +import { Height } from '../../codec/ibc/core/client/v1/client'; + +export const MsgAcknowledgementUrl = '/ibc.core.channel.v1.MsgAcknowledgement'; + +export const BuildMsgAcknowledgement = (acknowledgement: Uint8Array, proofAcked: Uint8Array, signer: string, packet?: Packet, proofHeight?: Height): Message => { + return { + typeUrl: MsgAcknowledgementUrl, + value: { + acknowledgement, + proofAcked, + signer, + packet, + proofHeight, + } as MsgAcknowledgement, + }; +}; diff --git a/src/messages/ibc/MsgChannelCloseConfirm.ts b/src/messages/ibc/MsgChannelCloseConfirm.ts new file mode 100644 index 0000000..ca99f1a --- /dev/null +++ b/src/messages/ibc/MsgChannelCloseConfirm.ts @@ -0,0 +1,18 @@ +import { Message } from '../Message'; +import { MsgChannelCloseConfirm } from '../../codec/ibc/core/channel/v1/tx'; +import { Height } from '../../codec/ibc/core/client/v1/client'; + +export const MsgChannelCloseConfirmUrl = '/ibc.core.channel.v1.MsgChannelCloseConfirm'; + +export const BuildMsgChannelCloseConfirm = (channelId: string, portId: string, signer: string, proofInit: Uint8Array, proofHeight?: Height): Message => { + return { + typeUrl: MsgChannelCloseConfirmUrl, + value: { + channelId, + portId, + signer, + proofInit, + proofHeight, + } as MsgChannelCloseConfirm, + }; +}; diff --git a/src/messages/ibc/MsgChannelCloseInit.ts b/src/messages/ibc/MsgChannelCloseInit.ts new file mode 100644 index 0000000..a0b6893 --- /dev/null +++ b/src/messages/ibc/MsgChannelCloseInit.ts @@ -0,0 +1,15 @@ +import { Message } from '../Message'; +import { MsgChannelCloseInit } from '../../codec/ibc/core/channel/v1/tx'; + +export const MsgChannelCloseInitUrl = '/ibc.core.channel.v1.MsgChannelCloseInit'; + +export const BuildMsgChannelCloseInit = (channelId: string, signer: string, portId: string): Message => { + return { + typeUrl: MsgChannelCloseInitUrl, + value: { + channelId, + signer, + portId, + } as MsgChannelCloseInit, + }; +}; diff --git a/src/messages/ibc/MsgChannelOpenAck.ts b/src/messages/ibc/MsgChannelOpenAck.ts new file mode 100644 index 0000000..a5550c6 --- /dev/null +++ b/src/messages/ibc/MsgChannelOpenAck.ts @@ -0,0 +1,28 @@ +import { Message } from '../Message'; +import { MsgChannelOpenAck } from '../../codec/ibc/core/channel/v1/tx'; +import { Height } from '../../codec/ibc/core/client/v1/client'; + +export const MsgChannelOpenAckUrl = '/ibc.core.channel.v1.MsgChannelOpenAck'; + +export const BuildMsgChannelOpenAck = ( + portId: string, + channelId: string, + counterpartyChannelId: string, + counterpartyVersion: string, + signer: string, + proofTry: Uint8Array, + proofHeight?: Height, +): Message => { + return { + typeUrl: MsgChannelOpenAckUrl, + value: { + portId, + channelId, + counterpartyChannelId, + counterpartyVersion, + signer, + proofTry, + proofHeight, + } as MsgChannelOpenAck, + }; +}; diff --git a/src/messages/ibc/MsgChannelOpenConfirm.ts b/src/messages/ibc/MsgChannelOpenConfirm.ts new file mode 100644 index 0000000..09a9b3c --- /dev/null +++ b/src/messages/ibc/MsgChannelOpenConfirm.ts @@ -0,0 +1,18 @@ +import { Message } from '../Message'; +import { MsgChannelOpenConfirm } from '../../codec/ibc/core/channel/v1/tx'; +import { Height } from '../../codec/ibc/core/client/v1/client'; + +export const MsgChannelOpenConfirmUrl = '/ibc.core.channel.v1.MsgChannelOpenConfirm'; + +export const BuildMsgChannelOpenConfirm = (channelId: string, portId: string, signer: string, proofAck: Uint8Array, proofHeight?: Height): Message => { + return { + typeUrl: MsgChannelOpenConfirmUrl, + value: { + channelId, + portId, + signer, + proofAck, + proofHeight, + } as MsgChannelOpenConfirm, + }; +}; diff --git a/src/messages/ibc/MsgChannelOpenInit.ts b/src/messages/ibc/MsgChannelOpenInit.ts new file mode 100644 index 0000000..9320f76 --- /dev/null +++ b/src/messages/ibc/MsgChannelOpenInit.ts @@ -0,0 +1,16 @@ +import { Message } from '../Message'; +import { MsgChannelOpenInit } from '../../codec/ibc/core/channel/v1/tx'; +import { Channel } from '../../codec/ibc/core/channel/v1/channel'; + +export const MsgChannelOpenInitUrl = '/ibc.core.channel.v1.MsgChannelOpenInit'; + +export const BuildMsgChannelOpenInit = (portId: string, signer: string, channel?: Channel): Message => { + return { + typeUrl: MsgChannelOpenInitUrl, + value: { + portId, + signer, + channel, + } as MsgChannelOpenInit, + }; +}; diff --git a/src/messages/ibc/MsgChannelOpenTry.ts b/src/messages/ibc/MsgChannelOpenTry.ts new file mode 100644 index 0000000..4e11450 --- /dev/null +++ b/src/messages/ibc/MsgChannelOpenTry.ts @@ -0,0 +1,29 @@ +import { Message } from '../Message'; +import { MsgChannelOpenTry } from '../../codec/ibc/core/channel/v1/tx'; +import { Channel } from '../../codec/ibc/core/channel/v1/channel'; +import { Height } from '../../codec/ibc/core/client/v1/client'; + +export const MsgChannelOpenTryUrl = '/ibc.core.channel.v1.MsgChannelOpenTry'; + +export const BuildMsgChannelOpenTry = ( + portId: string, + previousChannelId: string, + counterpartyVersion: string, + signer: string, + proofInit: Uint8Array, + channel?: Channel, + proofHeight?: Height, +): Message => { + return { + typeUrl: MsgChannelOpenTryUrl, + value: { + portId, + previousChannelId, + counterpartyVersion, + signer, + proofInit, + channel, + proofHeight, + } as MsgChannelOpenTry, + }; +}; diff --git a/src/messages/ibc/MsgConnectionOpenAck.ts b/src/messages/ibc/MsgConnectionOpenAck.ts new file mode 100644 index 0000000..e32dcc8 --- /dev/null +++ b/src/messages/ibc/MsgConnectionOpenAck.ts @@ -0,0 +1,36 @@ +import { Message } from '../Message'; +import { MsgConnectionOpenAck } from '../../codec/ibc/core/connection/v1/tx'; +import { Any } from '../../codec/google/protobuf/any'; +import { Height } from '../../codec/ibc/core/client/v1/client'; +import { Version } from '../../codec/ibc/core/connection/v1/connection'; + +export const MsgConnectionOpenAckUrl = '/ibc.core.connection.v1.MsgConnectionOpenAck'; + +export const BuildMsgConnectionOpenAck = ( + connectionId: string, + signer: string, + counterpartyConnectionId: string, + proofClient: Uint8Array, + proofConsensus: Uint8Array, + proofTry: Uint8Array, + clientState?: Any, + proofHeight?: Height, + consensusHeight?: Height, + version?: Version, +): Message => { + return { + typeUrl: MsgConnectionOpenAckUrl, + value: { + connectionId, + signer, + counterpartyConnectionId, + proofClient, + proofConsensus, + proofTry, + clientState, + proofHeight, + consensusHeight, + version, + } as MsgConnectionOpenAck, + }; +}; diff --git a/src/messages/ibc/MsgConnectionOpenConfirm.ts b/src/messages/ibc/MsgConnectionOpenConfirm.ts new file mode 100644 index 0000000..7a90dfd --- /dev/null +++ b/src/messages/ibc/MsgConnectionOpenConfirm.ts @@ -0,0 +1,17 @@ +import { Message } from '../Message'; +import { MsgConnectionOpenConfirm } from '../../codec/ibc/core/connection/v1/tx'; +import { Height } from '../../codec/ibc/core/client/v1/client'; + +export const MsgConnectionOpenConfirmUrl = '/ibc.core.connection.v1.MsgConnectionOpenConfirm'; + +export const BuildMsgConnectionOpenConfirm = (connectionId: string, signer: string, proofAck: Uint8Array, proofHeight?: Height): Message => { + return { + typeUrl: MsgConnectionOpenConfirmUrl, + value: { + connectionId, + signer, + proofAck, + proofHeight, + } as MsgConnectionOpenConfirm, + }; +}; diff --git a/src/messages/ibc/MsgConnectionOpenInit.ts b/src/messages/ibc/MsgConnectionOpenInit.ts new file mode 100644 index 0000000..085a022 --- /dev/null +++ b/src/messages/ibc/MsgConnectionOpenInit.ts @@ -0,0 +1,19 @@ +import { Message } from '../Message'; +import { MsgConnectionOpenInit } from '../../codec/ibc/core/connection/v1/tx'; +import Long from 'long'; +import { Version, Counterparty } from '../../codec/ibc/core/connection/v1/connection'; + +export const MsgConnectionOpenInitUrl = '/ibc.core.connection.v1.MsgConnectionOpenInit'; + +export const BuildMsgConnectionOpenInit = (clientId: string, signer: string, delayPeriod: Long.Long, counterparty?: Counterparty, version?: Version): Message => { + return { + typeUrl: MsgConnectionOpenInitUrl, + value: { + clientId, + signer, + delayPeriod, + counterparty, + version, + } as MsgConnectionOpenInit, + }; +}; diff --git a/src/messages/ibc/MsgConnectionOpenTry.ts b/src/messages/ibc/MsgConnectionOpenTry.ts new file mode 100644 index 0000000..9ff28fb --- /dev/null +++ b/src/messages/ibc/MsgConnectionOpenTry.ts @@ -0,0 +1,41 @@ +import { Message } from '../Message'; +import { MsgConnectionOpenTry } from '../../codec/ibc/core/connection/v1/tx'; +import Long from 'long'; +import { Counterparty, Version } from '../../codec/ibc/core/connection/v1/connection'; +import { Any } from '../../codec/google/protobuf/any'; +import { Height } from '../../codec/ibc/core/client/v1/client'; + +export const MsgConnectionOpenTryUrl = '/ibc.core.connection.v1.MsgConnectionOpenTry'; + +export const BuildMsgConnectionOpenTry = ( + signer: string, + clientId: string, + previousConnectionId: string, + delayPeriod: Long.Long, + counterpartyVersions: Version[], + proofClient: Uint8Array, + proofConsensus: Uint8Array, + proofInit: Uint8Array, + clientState?: Any, + proofHeight?: Height, + consensusHeight?: Height, + counterparty?: Counterparty, +): Message => { + return { + typeUrl: MsgConnectionOpenTryUrl, + value: { + signer, + clientId, + previousConnectionId, + delayPeriod, + counterpartyVersions, + proofClient, + proofConsensus, + proofInit, + clientState, + proofHeight, + consensusHeight, + counterparty, + } as MsgConnectionOpenTry, + }; +}; diff --git a/src/messages/ibc/MsgCreateClient.ts b/src/messages/ibc/MsgCreateClient.ts new file mode 100644 index 0000000..2b3aef6 --- /dev/null +++ b/src/messages/ibc/MsgCreateClient.ts @@ -0,0 +1,16 @@ +import { Message } from '../Message'; +import { MsgCreateClient } from '../../codec/ibc/core/client/v1/tx'; +import { Any } from '../../codec/google/protobuf/any'; + +export const MsgCreateClientUrl = '/ibc.core.client.v1.MsgCreateClient'; + +export const BuildMsgCreateClient = (signer: string, clientState?: Any, consensusState?: Any): Message => { + return { + typeUrl: MsgCreateClientUrl, + value: { + signer, + clientState, + consensusState, + } as MsgCreateClient, + }; +}; diff --git a/src/messages/ibc/MsgRecvPacket.ts b/src/messages/ibc/MsgRecvPacket.ts new file mode 100644 index 0000000..229a4d6 --- /dev/null +++ b/src/messages/ibc/MsgRecvPacket.ts @@ -0,0 +1,18 @@ +import { Message } from '../Message'; +import { MsgRecvPacket } from '../../codec/ibc/core/channel/v1/tx'; +import { Packet } from '../../codec/ibc/core/channel/v1/channel'; +import { Height } from '../../codec/ibc/core/client/v1/client'; + +export const MsgRecvPacketUrl = '/ibc.core.channel.v1.MsgRecvPacket'; + +export const BuildMsgRecvPacket = (signer: string, proofCommitment: Uint8Array, packet?: Packet, proofHeight?: Height): Message => { + return { + typeUrl: MsgRecvPacketUrl, + value: { + signer, + proofCommitment, + packet, + proofHeight, + } as MsgRecvPacket, + }; +}; diff --git a/src/messages/ibc/MsgSubmitMisbehaviour.ts b/src/messages/ibc/MsgSubmitMisbehaviour.ts new file mode 100644 index 0000000..10cb30c --- /dev/null +++ b/src/messages/ibc/MsgSubmitMisbehaviour.ts @@ -0,0 +1,16 @@ +import { Message } from '../Message'; +import { MsgSubmitMisbehaviour } from '../../codec/ibc/core/client/v1/tx'; +import { Any } from '../../codec/google/protobuf/any'; + +export const MsgSubmitMisbehaviourUrl = '/ibc.core.client.v1.MsgSubmitMisbehaviour'; + +export const BuildMsgSubmitMisbehaviour = (signer: string, clientId: string, misbehaviour?: Any): Message => { + return { + typeUrl: MsgSubmitMisbehaviourUrl, + value: { + signer, + clientId, + misbehaviour, + } as MsgSubmitMisbehaviour, + }; +}; diff --git a/src/messages/ibc/MsgTimeout.ts b/src/messages/ibc/MsgTimeout.ts new file mode 100644 index 0000000..115706e --- /dev/null +++ b/src/messages/ibc/MsgTimeout.ts @@ -0,0 +1,20 @@ +import { Message } from '../Message'; +import { MsgTimeout } from '../../codec/ibc/core/channel/v1/tx'; +import Long from 'long'; +import { Packet } from '../../codec/ibc/core/channel/v1/channel'; +import { Height } from '../../codec/ibc/core/client/v1/client'; + +export const MsgTimeoutUrl = '/ibc.core.channel.v1.MsgTimeout'; + +export const BuildMsgTimeout = (nextSequenceRecv: Long.Long, proofUnreceived: Uint8Array, signer: string, packet?: Packet, proofHeight?: Height): Message => { + return { + typeUrl: MsgTimeoutUrl, + value: { + nextSequenceRecv, + packet, + proofHeight, + proofUnreceived, + signer, + } as MsgTimeout, + }; +}; diff --git a/src/messages/ibc/MsgTimeoutOnClose.ts b/src/messages/ibc/MsgTimeoutOnClose.ts new file mode 100644 index 0000000..ff16b2e --- /dev/null +++ b/src/messages/ibc/MsgTimeoutOnClose.ts @@ -0,0 +1,21 @@ +import { Message } from '../Message'; +import { MsgTimeoutOnClose } from '../../codec/ibc/core/channel/v1/tx'; +import Long from 'long'; +import { Packet } from '../../codec/ibc/core/channel/v1/channel'; +import { Height } from '../../codec/ibc/core/client/v1/client'; + +export const MsgTimeoutOnCloseUrl = '/ibc.core.channel.v1.MsgTimeoutOnClose'; + +export const BuildMsgTimeoutOnClose = (nextSequenceRecv: Long.Long, signer: string, proofClose: Uint8Array, proofUnreceived: Uint8Array, packet?: Packet, proofHeight?: Height): Message => { + return { + typeUrl: MsgTimeoutOnCloseUrl, + value: { + nextSequenceRecv, + signer, + proofClose, + proofUnreceived, + packet, + proofHeight, + } as MsgTimeoutOnClose, + }; +}; diff --git a/src/messages/ibc/MsgTransfer.ts b/src/messages/ibc/MsgTransfer.ts new file mode 100644 index 0000000..67ef540 --- /dev/null +++ b/src/messages/ibc/MsgTransfer.ts @@ -0,0 +1,22 @@ +import { Message } from '../Message'; +import { MsgTransfer } from '../../codec/ibc/applications/transfer/v1/tx'; +import Long from 'long'; +import { Height } from '../../codec/ibc/core/client/v1/client'; +import { Coin } from '../../types'; + +export const MsgTransferUrl = '/ibc.applications.transfer.v1.MsgTransfer'; + +export const BuildMsgTransfer = (receiver: string, sender: string, sourceChannel: string, sourcePort: string, timeoutTimestamp: Long.Long, timeoutHeight?: Height, token?: Coin): Message => { + return { + typeUrl: MsgTransferUrl, + value: { + receiver, + sender, + sourceChannel, + sourcePort, + timeoutTimestamp, + timeoutHeight, + token, + } as MsgTransfer, + }; +}; diff --git a/src/messages/ibc/MsgUpdateClient.ts b/src/messages/ibc/MsgUpdateClient.ts new file mode 100644 index 0000000..94b6cd5 --- /dev/null +++ b/src/messages/ibc/MsgUpdateClient.ts @@ -0,0 +1,16 @@ +import { Message } from '../Message'; +import { MsgUpdateClient } from '../../codec/ibc/core/client/v1/tx'; +import { Any } from '../../codec/google/protobuf/any'; + +export const MsgUpdateClientUrl = '/ibc.core.client.v1.MsgUpdateClient'; + +export const BuildMsgUpdateClient = (clientId: string, signer: string, header?: Any): Message => { + return { + typeUrl: MsgUpdateClientUrl, + value: { + clientId, + signer, + header, + } as MsgUpdateClient, + }; +}; diff --git a/src/messages/ibc/MsgUpgradeClient.ts b/src/messages/ibc/MsgUpgradeClient.ts new file mode 100644 index 0000000..52e7ef8 --- /dev/null +++ b/src/messages/ibc/MsgUpgradeClient.ts @@ -0,0 +1,19 @@ +import { Message } from '../Message'; +import { MsgUpgradeClient } from '../../codec/ibc/core/client/v1/tx'; +import { Any } from '../../codec/google/protobuf/any'; + +export const MsgUpgradeClientUrl = '/ibc.core.client.v1.MsgUpgradeClient'; + +export const BuildMsgUpgradeClient = (clientId: string, proofUpgradeClient: Uint8Array, signer: string, proofUpgradeConsensusState: Uint8Array, clientState?: Any, consensusState?: Any): Message => { + return { + typeUrl: MsgUpgradeClientUrl, + value: { + clientId, + proofUpgradeClient, + signer, + proofUpgradeConsensusState, + clientState, + consensusState, + } as MsgUpgradeClient, + }; +}; diff --git a/src/messages/ibc/index.ts b/src/messages/ibc/index.ts new file mode 100644 index 0000000..2bebc98 --- /dev/null +++ b/src/messages/ibc/index.ts @@ -0,0 +1,19 @@ +export * from './MsgTimeout'; +export * from './MsgUpdateClient'; +export * from './MsgAcknowledgement'; +export * from './MsgTransfer'; +export * from './MsgChannelOpenInit'; +export * from './MsgChannelOpenTry'; +export * from './MsgChannelOpenAck'; +export * from './MsgChannelOpenConfirm'; +export * from './MsgChannelCloseInit'; +export * from './MsgChannelCloseConfirm'; +export * from './MsgRecvPacket'; +export * from './MsgTimeoutOnClose'; +export * from './MsgCreateClient'; +export * from './MsgUpgradeClient'; +export * from './MsgSubmitMisbehaviour'; +export * from './MsgConnectionOpenInit'; +export * from './MsgConnectionOpenTry'; +export * from './MsgConnectionOpenAck'; +export * from './MsgConnectionOpenAck'; diff --git a/src/messages/index.ts b/src/messages/index.ts index 5e1c9b7..6696bab 100644 --- a/src/messages/index.ts +++ b/src/messages/index.ts @@ -8,3 +8,4 @@ export * from './authz'; export * from './feegrant'; export * from './slashing'; export * from './vesting'; +export * from './ibc';