diff --git a/package-lock.json b/package-lock.json index 77985c49..573b96ea 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@terra-money/feather.js", - "version": "2.0.0-beta.9", + "version": "2.0.0-beta.12", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@terra-money/feather.js", - "version": "2.0.0-beta.9", + "version": "2.0.0-beta.11", "license": "MIT", "dependencies": { "@ethersproject/bytes": "^5.7.0", diff --git a/package.json b/package.json index 6cc90f36..d7649a65 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@terra-money/feather.js", - "version": "2.0.0-beta.9", + "version": "2.0.0-beta.12", "description": "The JavaScript SDK for Terra and Feather chains", "license": "MIT", "author": "Terraform Labs, PTE.", diff --git a/src/client/lcd/api/TokenFactoryAPI.ts b/src/client/lcd/api/TokenFactoryAPI.ts index d94be4d5..2c7a664b 100644 --- a/src/client/lcd/api/TokenFactoryAPI.ts +++ b/src/client/lcd/api/TokenFactoryAPI.ts @@ -1,4 +1,3 @@ -import { APIParams } from '../APIRequester'; import { LCDClient } from '../LCDClient'; import { BaseAPI } from './BaseAPI'; import { QueryParamsResponse } from '@terra-money/terra.proto/osmosis/tokenfactory/v1beta1/query'; diff --git a/src/core/Msg.ts b/src/core/Msg.ts index f147e71c..46a1af1e 100644 --- a/src/core/Msg.ts +++ b/src/core/Msg.ts @@ -69,6 +69,14 @@ import { MsgClearContractAdmin, WasmMsg, } from './wasm/msgs'; +import { + MsgBurn, + MsgChangeAdmin, + MsgCreateDenom, + MsgMint, + MsgSetBeforeSendHook, + TokenFactoryMsg, +} from './tokenfactory'; import { JAXMsgExecuteContract, JAXMsgStoreCode, JaxMsg } from './jax/msgs'; import { MsgTransfer, IbcTransferMsg } from './ibc/applications/transfer'; import { @@ -100,10 +108,6 @@ import { } from './ibc/msgs/channel'; import { MsgVerifyInvariant, CrisisMsg } from './crisis'; import { Any } from '@terra-money/terra.proto/google/protobuf/any'; -import { MsgCreateDenom } from './wasm/msgs/tokenfactory/MsgCreateDenom'; -import { MsgBurn } from './wasm/msgs/tokenfactory/MsgBurn'; -import { MsgChangeAdmin } from './wasm/msgs/tokenfactory/MsgChangeAdmin'; -import { MsgMint } from './wasm/msgs/tokenfactory/MsgMint'; import { MsgAuctionBid } from './pob/MsgAuctionBid'; import { FeeshareMsg, @@ -116,6 +120,8 @@ import { MsgRegisterInterchainAccount, MsgSendTx, } from './ica/controller/v1/msgs'; +import { MsgForceTransfer } from './tokenfactory/MsgForceTransfer'; +import { MsgSetDenomMetadata } from './tokenfactory/MsgSetDenomMetadata'; export type Msg = | BankMsg @@ -138,7 +144,8 @@ export type Msg = | CrisisMsg | JaxMsg | MsgAuctionBid - | FeeshareMsg; + | FeeshareMsg + | TokenFactoryMsg; export namespace Msg { export type Amino = @@ -158,7 +165,8 @@ export namespace Msg { | CrisisMsg.Amino | JaxMsg.Amino | MsgAuctionBid.Amino - | FeeshareMsg.Amino; + | FeeshareMsg.Amino + | TokenFactoryMsg.Amino; export type Data = | BankMsg.Data @@ -181,7 +189,8 @@ export namespace Msg { | CrisisMsg.Data | JaxMsg.Data | MsgAuctionBid.Data - | FeeshareMsg.Data; + | FeeshareMsg.Data + | TokenFactoryMsg.Data; export type Proto = | BankMsg.Proto @@ -203,7 +212,8 @@ export namespace Msg { | CrisisMsg.Proto | JaxMsg.Proto | MsgAuctionBid.Proto - | FeeshareMsg.Proto; + | FeeshareMsg.Proto + | TokenFactoryMsg.Proto; export function fromAmino(data: Msg.Amino, isClassic?: boolean): Msg { switch (data.type) { @@ -444,6 +454,8 @@ export namespace Msg { data as MsgClearContractAdmin.Amino, isClassic ); + + //token-factory case 'osmosis/tokenfactory/create-denom': return MsgCreateDenom.fromAmino(data as MsgCreateDenom.Amino); case 'osmosis/tokenfactory/burn': @@ -452,9 +464,19 @@ export namespace Msg { return MsgChangeAdmin.fromAmino(data as MsgChangeAdmin.Amino); case 'osmosis/tokenfactory/mint': return MsgMint.fromAmino(data as MsgMint.Amino); + case 'osmosis/tokenfactory/set-beforesend-hook': + return MsgSetBeforeSendHook.fromAmino( + data as MsgSetBeforeSendHook.Amino + ); + case 'osmosis/tokenfactory/force-transfer': + return MsgForceTransfer.fromAmino(data as MsgForceTransfer.Amino); + case 'osmosis/tokenfactory/set-metadata': + return MsgSetDenomMetadata.fromAmino(data as MsgSetDenomMetadata.Amino); + // ibc-transfer case 'cosmos-sdk/MsgTransfer': return MsgTransfer.fromAmino(data as MsgTransfer.Amino, isClassic); + // crisis case 'crisis/MsgVerifyInvariant': case 'cosmos-sdk/MsgVerifyInvariant': @@ -612,6 +634,8 @@ export namespace Msg { case '/terra.wasm.v1beta1.MsgClearContractAdmin': case '/cosmwasm.wasm.v1.MsgClearAdmin': return MsgClearContractAdmin.fromData(data, isClassic); + + // token factory case '/osmosis.tokenfactory.v1beta1.MsgCreateDenom': return MsgCreateDenom.fromData(data); case '/osmosis.tokenfactory.v1beta1.MsgBurn': @@ -620,6 +644,12 @@ export namespace Msg { return MsgChangeAdmin.fromData(data); case '/osmosis.tokenfactory.v1beta1.MsgMint': return MsgMint.fromData(data); + case '/osmosis.tokenfactory.v1beta1.MsgSetBeforeSendHook': + return MsgSetBeforeSendHook.fromData(data); + case '/osmosis.tokenfactory.v1beta1.MsgForceTransfer': + return MsgForceTransfer.fromData(data); + case '/osmosis.tokenfactory.v1beta1.MsgSetDenomMetadata': + return MsgSetDenomMetadata.fromData(data); // ibc-transfer case '/ibc.applications.transfer.v1.MsgTransfer': @@ -816,6 +846,8 @@ export namespace Msg { case '/terra.wasm.v1beta1.MsgClearContractAdmin': case '/cosmwasm.wasm.v1.MsgClearAdmin': return MsgClearContractAdmin.unpackAny(proto, isClassic); + + // token factory case '/osmosis.tokenfactory.v1beta1.MsgCreateDenom': return MsgCreateDenom.unpackAny(proto, isClassic); case '/osmosis.tokenfactory.v1beta1.MsgBurn': @@ -824,6 +856,12 @@ export namespace Msg { return MsgChangeAdmin.unpackAny(proto, isClassic); case '/osmosis.tokenfactory.v1beta1.MsgMint': return MsgMint.unpackAny(proto, isClassic); + case '/osmosis.tokenfactory.v1beta1.MsgSetBeforeSendHook': + return MsgSetBeforeSendHook.unpackAny(proto); + case '/osmosis.tokenfactory.v1beta1.MsgForceTransfer': + return MsgForceTransfer.unpackAny(proto); + case '/osmosis.tokenfactory.v1beta1.MsgSetDenomMetadata': + return MsgSetDenomMetadata.unpackAny(proto); // ibc-transfer case '/ibc.applications.transfer.v1.MsgTransfer': diff --git a/src/core/index.ts b/src/core/index.ts index 1e805a24..08ab4cf5 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -109,5 +109,8 @@ export * from './ibc/applications/transfer'; // Feeshare export * from './feeshare'; +// token factory +export * from './tokenfactory'; + // bech32 types export * from './bech32'; diff --git a/src/core/wasm/msgs/tokenfactory/MsgBurn.spec.ts b/src/core/tokenfactory/MsgBurn.spec.ts similarity index 96% rename from src/core/wasm/msgs/tokenfactory/MsgBurn.spec.ts rename to src/core/tokenfactory/MsgBurn.spec.ts index 254bc7d0..6a2f8883 100644 --- a/src/core/wasm/msgs/tokenfactory/MsgBurn.spec.ts +++ b/src/core/tokenfactory/MsgBurn.spec.ts @@ -1,4 +1,4 @@ -import { Coin } from '../../../Coin'; +import { Coin } from '../Coin'; import { MsgBurn } from './MsgBurn'; describe('MsgBurn', () => { diff --git a/src/core/wasm/msgs/tokenfactory/MsgBurn.ts b/src/core/tokenfactory/MsgBurn.ts similarity index 93% rename from src/core/wasm/msgs/tokenfactory/MsgBurn.ts rename to src/core/tokenfactory/MsgBurn.ts index c7c5dbe6..2768f46d 100644 --- a/src/core/wasm/msgs/tokenfactory/MsgBurn.ts +++ b/src/core/tokenfactory/MsgBurn.ts @@ -1,8 +1,8 @@ -import { JSONSerializable } from '../../../../util/json'; -import { AccAddress } from '../../../bech32'; +import { JSONSerializable } from '../../util/json'; +import { AccAddress } from '../bech32'; import { Any } from '@terra-money/terra.proto/google/protobuf/any'; -import { MsgBurn as MsgBurn_pb } from '@terra-money/terra.proto/cosmwasm/tokenfactory/v1beta1/tx'; -import { Coin } from '../../../Coin'; +import { MsgBurn as MsgBurn_pb } from '@terra-money/terra.proto/osmosis/tokenfactory/v1beta1/tx'; +import { Coin } from '../Coin'; /** * MsgBurn is the sdk.Msg type for allowing an admin account to burn diff --git a/src/core/wasm/msgs/tokenfactory/MsgChangeAdmin.spec.ts b/src/core/tokenfactory/MsgChangeAdmin.spec.ts similarity index 100% rename from src/core/wasm/msgs/tokenfactory/MsgChangeAdmin.spec.ts rename to src/core/tokenfactory/MsgChangeAdmin.spec.ts diff --git a/src/core/wasm/msgs/tokenfactory/MsgChangeAdmin.ts b/src/core/tokenfactory/MsgChangeAdmin.ts similarity index 94% rename from src/core/wasm/msgs/tokenfactory/MsgChangeAdmin.ts rename to src/core/tokenfactory/MsgChangeAdmin.ts index 685f1dd8..9100cf1b 100644 --- a/src/core/wasm/msgs/tokenfactory/MsgChangeAdmin.ts +++ b/src/core/tokenfactory/MsgChangeAdmin.ts @@ -1,7 +1,7 @@ -import { JSONSerializable } from '../../../../util/json'; -import { AccAddress } from '../../../bech32'; +import { JSONSerializable } from '../../util/json'; +import { AccAddress } from '../bech32'; import { Any } from '@terra-money/terra.proto/google/protobuf/any'; -import { MsgChangeAdmin as MsgChangeAdmin_pb } from '@terra-money/terra.proto/cosmwasm/tokenfactory/v1beta1/tx'; +import { MsgChangeAdmin as MsgChangeAdmin_pb } from '@terra-money/terra.proto/osmosis/tokenfactory/v1beta1/tx'; // MsgChangeAdmin is the sdk.Msg type for allowing an admin account to reassign // adminship of a denom to a new account diff --git a/src/core/wasm/msgs/tokenfactory/MsgCreateDenom.spec.ts b/src/core/tokenfactory/MsgCreateDenom.spec.ts similarity index 100% rename from src/core/wasm/msgs/tokenfactory/MsgCreateDenom.spec.ts rename to src/core/tokenfactory/MsgCreateDenom.spec.ts diff --git a/src/core/wasm/msgs/tokenfactory/MsgCreateDenom.ts b/src/core/tokenfactory/MsgCreateDenom.ts similarity index 95% rename from src/core/wasm/msgs/tokenfactory/MsgCreateDenom.ts rename to src/core/tokenfactory/MsgCreateDenom.ts index 2e09be43..679e3cdd 100644 --- a/src/core/wasm/msgs/tokenfactory/MsgCreateDenom.ts +++ b/src/core/tokenfactory/MsgCreateDenom.ts @@ -1,7 +1,7 @@ -import { JSONSerializable } from '../../../../util/json'; -import { AccAddress } from '../../../bech32'; +import { JSONSerializable } from '../../util/json'; +import { AccAddress } from '../bech32'; import { Any } from '@terra-money/terra.proto/google/protobuf/any'; -import { MsgCreateDenom as MsgCreateDenom_pb } from '@terra-money/terra.proto/cosmwasm/tokenfactory/v1beta1/tx'; +import { MsgCreateDenom as MsgCreateDenom_pb } from '@terra-money/terra.proto/osmosis/tokenfactory/v1beta1/tx'; /** * MsgCreateDenom defines the message structure for the CreateDenom gRPC service diff --git a/src/core/tokenfactory/MsgForceTransfer.ts b/src/core/tokenfactory/MsgForceTransfer.ts new file mode 100644 index 00000000..6fbd34b0 --- /dev/null +++ b/src/core/tokenfactory/MsgForceTransfer.ts @@ -0,0 +1,144 @@ +import { DenomUnit } from '@terra-money/terra.proto/cosmos/bank/v1beta1/bank'; +import { JSONSerializable } from '../../util/json'; +import { AccAddress } from '../bech32'; +import { Any } from '@terra-money/terra.proto/google/protobuf/any'; +import { Metadata } from '@terra-money/terra.proto/cosmos/bank/v1beta1/bank'; +import { MsgForceTransfer as MsgForceTransfer_pb } from '@terra-money/terra.proto/osmosis/tokenfactory/v1beta1/tx'; +import { Coin } from '../Coin'; + +/** + * MsgForceTransfer allows setting the metadata + * for an already existing denom + */ +export class MsgForceTransfer extends JSONSerializable< + MsgForceTransfer.Amino, + MsgForceTransfer.Data, + MsgForceTransfer.Proto +> { + /** + * + * @param sender internal account or external sender address + * @param metadata the cosmwasm contract address + */ + constructor( + public sender: AccAddress, + public amount: Coin, + public transferFromAddress: AccAddress, + public transferToAddress: AccAddress + ) { + super(); + } + + public toAmino(_?: boolean): MsgForceTransfer.Amino { + _; + const { sender, amount, transferFromAddress, transferToAddress } = this; + + return { + type: 'osmosis/tokenfactory/force-transfer', + value: { + sender, + amount: amount.toAmino(), + transferFromAddress, + transferToAddress, + }, + }; + } + + public static fromProto( + proto: MsgForceTransfer.Proto, + _?: boolean + ): MsgForceTransfer { + _; + return new MsgForceTransfer( + proto.sender, + Coin.fromProto(proto.amount as Coin.Proto), + proto.transferFromAddress, + proto.transferToAddress + ); + } + + public toProto(_?: boolean): MsgForceTransfer.Proto { + _; + const { sender, amount, transferFromAddress, transferToAddress } = this; + return MsgForceTransfer_pb.fromPartial({ + sender, + amount: amount?.toProto(), + transferFromAddress, + transferToAddress, + }); + } + + public packAny(_?: boolean): Any { + _; + return Any.fromPartial({ + typeUrl: '/osmosis.tokenfactory.v1beta1.MsgForceTransfer', + value: MsgForceTransfer_pb.encode(this.toProto()).finish(), + }); + } + + public static unpackAny(msgAny: Any, _?: boolean): MsgForceTransfer { + _; + return MsgForceTransfer.fromProto(MsgForceTransfer_pb.decode(msgAny.value)); + } + + public static fromData( + data: MsgForceTransfer.Data, + _?: boolean + ): MsgForceTransfer { + _; + const { sender, amount, transferFromAddress, transferToAddress } = data; + return new MsgForceTransfer( + sender, + Coin.fromData(amount), + transferFromAddress, + transferToAddress + ); + } + + public toData(_?: boolean): MsgForceTransfer.Data { + _; + const { sender, amount, transferFromAddress, transferToAddress } = this; + return { + '@type': '/osmosis.tokenfactory.v1beta1.MsgForceTransfer', + sender, + amount: amount.toData(), + transferFromAddress, + transferToAddress, + }; + } + + public static fromAmino(data: MsgForceTransfer.Amino): MsgForceTransfer { + const { + value: { sender, amount, transferFromAddress, transferToAddress }, + } = data; + + return new MsgForceTransfer( + sender, + Coin.fromAmino(amount), + transferFromAddress, + transferToAddress + ); + } +} + +export namespace MsgForceTransfer { + export interface Amino { + type: 'osmosis/tokenfactory/force-transfer'; + value: { + sender: AccAddress; + amount: Coin.Amino; + transferFromAddress: AccAddress; + transferToAddress: AccAddress; + }; + } + + export interface Data { + '@type': '/osmosis.tokenfactory.v1beta1.MsgForceTransfer'; + sender: AccAddress; + amount: Coin.Data; + transferFromAddress: AccAddress; + transferToAddress: AccAddress; + } + + export type Proto = MsgForceTransfer_pb; +} diff --git a/src/core/wasm/msgs/tokenfactory/MsgMint.spec.ts b/src/core/tokenfactory/MsgMint.spec.ts similarity index 96% rename from src/core/wasm/msgs/tokenfactory/MsgMint.spec.ts rename to src/core/tokenfactory/MsgMint.spec.ts index a6fe1af3..75a84221 100644 --- a/src/core/wasm/msgs/tokenfactory/MsgMint.spec.ts +++ b/src/core/tokenfactory/MsgMint.spec.ts @@ -1,4 +1,4 @@ -import { Coin } from '../../../Coin'; +import { Coin } from '../Coin'; import { MsgMint } from './MsgMint'; describe('MsgMint', () => { diff --git a/src/core/wasm/msgs/tokenfactory/MsgMint.ts b/src/core/tokenfactory/MsgMint.ts similarity index 93% rename from src/core/wasm/msgs/tokenfactory/MsgMint.ts rename to src/core/tokenfactory/MsgMint.ts index 0cfb5547..d6357e26 100644 --- a/src/core/wasm/msgs/tokenfactory/MsgMint.ts +++ b/src/core/tokenfactory/MsgMint.ts @@ -1,8 +1,8 @@ -import { JSONSerializable } from '../../../../util/json'; -import { AccAddress } from '../../../bech32'; +import { JSONSerializable } from '../../util/json'; +import { AccAddress } from '../bech32'; import { Any } from '@terra-money/terra.proto/google/protobuf/any'; -import { MsgMint as MsgMint_pb } from '@terra-money/terra.proto/cosmwasm/tokenfactory/v1beta1/tx'; -import { Coin } from '../../../Coin'; +import { MsgMint as MsgMint_pb } from '@terra-money/terra.proto/osmosis/tokenfactory/v1beta1/tx'; +import { Coin } from '../Coin'; /** * MsgMint is the sdk.Msg type for allowing an admin account to mint diff --git a/src/core/tokenfactory/MsgSetBeforeSendHook.ts b/src/core/tokenfactory/MsgSetBeforeSendHook.ts new file mode 100644 index 00000000..e46fe84e --- /dev/null +++ b/src/core/tokenfactory/MsgSetBeforeSendHook.ts @@ -0,0 +1,125 @@ +import { JSONSerializable } from '../../util/json'; +import { AccAddress } from '../bech32'; +import { Any } from '@terra-money/terra.proto/google/protobuf/any'; +import { MsgSetBeforeSendHook as MsgSetBeforeSendHook_pb } from '@terra-money/terra.proto/osmosis/tokenfactory/v1beta1/tx'; + +/** + * MsgSetBeforeSendHook allows setting a hook for a specific denom + * to keep track of the token transfers or block specific transfers. + */ +export class MsgSetBeforeSendHook extends JSONSerializable< + MsgSetBeforeSendHook.Amino, + MsgSetBeforeSendHook.Data, + MsgSetBeforeSendHook.Proto +> { + /** + * + * @param sender internal account or external sender address + * @param denom with the format factory/terra1address/subdenom + * @param cosmwasmAddress the cosmwasm contract address + */ + constructor( + public sender: AccAddress, + public denom: string, + public cosmwasmAddress: string + ) { + super(); + } + + public toAmino(_?: boolean): MsgSetBeforeSendHook.Amino { + _; + const { sender, denom, cosmwasmAddress } = this; + + return { + type: 'osmosis/tokenfactory/set-beforesend-hook', + value: { sender, denom, cosmwasmAddress }, + }; + } + + public static fromProto( + proto: MsgSetBeforeSendHook.Proto, + _?: boolean + ): MsgSetBeforeSendHook { + _; + return new MsgSetBeforeSendHook( + proto.sender, + proto.denom, + proto.cosmwasmAddress + ); + } + + public toProto(_?: boolean): MsgSetBeforeSendHook.Proto { + _; + const { sender, denom, cosmwasmAddress } = this; + return MsgSetBeforeSendHook_pb.fromPartial({ + sender, + denom, + cosmwasmAddress, + }); + } + + public packAny(_?: boolean): Any { + _; + return Any.fromPartial({ + typeUrl: '/osmosis.tokenfactory.v1beta1.MsgSetBeforeSendHook', + value: MsgSetBeforeSendHook_pb.encode(this.toProto()).finish(), + }); + } + + public static unpackAny(msgAny: Any, _?: boolean): MsgSetBeforeSendHook { + _; + return MsgSetBeforeSendHook.fromProto( + MsgSetBeforeSendHook_pb.decode(msgAny.value) + ); + } + + public static fromData( + data: MsgSetBeforeSendHook.Data, + _?: boolean + ): MsgSetBeforeSendHook { + _; + const { sender, denom, cosmwasmAddress } = data; + return new MsgSetBeforeSendHook(sender, denom, cosmwasmAddress); + } + + public toData(_?: boolean): MsgSetBeforeSendHook.Data { + _; + const { sender, denom, cosmwasmAddress } = this; + return { + '@type': '/osmosis.tokenfactory.v1beta1.MsgSetBeforeSendHook', + sender, + denom, + cosmwasmAddress, + }; + } + + public static fromAmino( + data: MsgSetBeforeSendHook.Amino + ): MsgSetBeforeSendHook { + const { + value: { sender, denom, cosmwasmAddress }, + } = data; + + return new MsgSetBeforeSendHook(sender, denom, cosmwasmAddress); + } +} + +export namespace MsgSetBeforeSendHook { + export interface Amino { + type: 'osmosis/tokenfactory/set-beforesend-hook'; + value: { + sender: AccAddress; + denom: string; + cosmwasmAddress: string; + }; + } + + export interface Data { + '@type': '/osmosis.tokenfactory.v1beta1.MsgSetBeforeSendHook'; + sender: AccAddress; + denom: string; + cosmwasmAddress: string; + } + + export type Proto = MsgSetBeforeSendHook_pb; +} diff --git a/src/core/tokenfactory/MsgSetDenomMetadata.ts b/src/core/tokenfactory/MsgSetDenomMetadata.ts new file mode 100644 index 00000000..59129791 --- /dev/null +++ b/src/core/tokenfactory/MsgSetDenomMetadata.ts @@ -0,0 +1,114 @@ +import { DenomUnit } from '@terra-money/terra.proto/cosmos/bank/v1beta1/bank'; +import { JSONSerializable } from '../../util/json'; +import { AccAddress } from '../bech32'; +import { Any } from '@terra-money/terra.proto/google/protobuf/any'; +import { Metadata } from '@terra-money/terra.proto/cosmos/bank/v1beta1/bank'; +import { MsgSetDenomMetadata as MsgSetDenomMetadata_pb } from '@terra-money/terra.proto/osmosis/tokenfactory/v1beta1/tx'; + +/** + * MsgSetDenomMetadata allows setting the metadata + * for an already existing denom + */ +export class MsgSetDenomMetadata extends JSONSerializable< + MsgSetDenomMetadata.Amino, + MsgSetDenomMetadata.Data, + MsgSetDenomMetadata.Proto +> { + /** + * + * @param sender internal account or external sender address + * @param metadata the cosmwasm contract address + */ + constructor(public sender: AccAddress, public metadata: Metadata) { + super(); + } + + public toAmino(_?: boolean): MsgSetDenomMetadata.Amino { + _; + const { sender, metadata } = this; + + return { + type: 'osmosis/tokenfactory/set-metadata', + value: { sender, metadata }, + }; + } + + public static fromProto( + proto: MsgSetDenomMetadata.Proto, + _?: boolean + ): MsgSetDenomMetadata { + _; + return new MsgSetDenomMetadata(proto.sender, proto.metadata as Metadata); + } + + public toProto(_?: boolean): MsgSetDenomMetadata.Proto { + _; + const { sender, metadata } = this; + return MsgSetDenomMetadata_pb.fromPartial({ + sender, + metadata, + }); + } + + public packAny(_?: boolean): Any { + _; + return Any.fromPartial({ + typeUrl: '/osmosis.tokenfactory.v1beta1.MsgSetDenomMetadata', + value: MsgSetDenomMetadata_pb.encode(this.toProto()).finish(), + }); + } + + public static unpackAny(msgAny: Any, _?: boolean): MsgSetDenomMetadata { + _; + return MsgSetDenomMetadata.fromProto( + MsgSetDenomMetadata_pb.decode(msgAny.value) + ); + } + + public static fromData( + data: MsgSetDenomMetadata.Data, + _?: boolean + ): MsgSetDenomMetadata { + _; + const { sender, metadata } = data; + return new MsgSetDenomMetadata(sender, metadata); + } + + public toData(_?: boolean): MsgSetDenomMetadata.Data { + _; + const { sender, metadata } = this; + return { + '@type': '/osmosis.tokenfactory.v1beta1.MsgSetDenomMetadata', + sender, + metadata, + }; + } + + public static fromAmino( + data: MsgSetDenomMetadata.Amino + ): MsgSetDenomMetadata { + const { + value: { sender, metadata }, + } = data; + + return new MsgSetDenomMetadata(sender, metadata); + } +} + +export namespace MsgSetDenomMetadata { + export interface Amino { + type: 'osmosis/tokenfactory/set-metadata'; + value: { + sender: AccAddress; + metadata: Metadata; + }; + } + + export interface Data { + '@type': '/osmosis.tokenfactory.v1beta1.MsgSetDenomMetadata'; + sender: AccAddress; + metadata: Metadata; + } + + export type Proto = MsgSetDenomMetadata_pb; +} diff --git a/src/core/tokenfactory/index.ts b/src/core/tokenfactory/index.ts new file mode 100644 index 00000000..9cac5c93 --- /dev/null +++ b/src/core/tokenfactory/index.ts @@ -0,0 +1,55 @@ +import { MsgCreateDenom } from './MsgCreateDenom'; +import { MsgBurn } from './MsgBurn'; +import { MsgChangeAdmin } from './MsgChangeAdmin'; +import { MsgMint } from './MsgMint'; +import { MsgSetBeforeSendHook } from './MsgSetBeforeSendHook'; +import { MsgSetDenomMetadata } from './MsgSetDenomMetadata'; +import { MsgForceTransfer } from './MsgForceTransfer'; + +export * from './MsgCreateDenom'; +export * from './MsgBurn'; +export * from './MsgChangeAdmin'; +export * from './MsgMint'; +export * from './MsgSetBeforeSendHook'; + +export type TokenFactoryMsg = + | MsgCreateDenom + | MsgBurn + | MsgChangeAdmin + | MsgMint + | MsgSetBeforeSendHook + | MsgSetDenomMetadata + | MsgForceTransfer + | MsgSetDenomMetadata; + +export namespace TokenFactoryMsg { + export type Amino = + | MsgCreateDenom.Amino + | MsgBurn.Amino + | MsgChangeAdmin.Amino + | MsgMint.Amino + | MsgSetBeforeSendHook.Amino + | MsgSetDenomMetadata.Amino + | MsgForceTransfer.Amino + | MsgSetDenomMetadata.Amino; + + export type Data = + | MsgCreateDenom.Data + | MsgBurn.Data + | MsgChangeAdmin.Data + | MsgMint.Data + | MsgSetBeforeSendHook.Data + | MsgSetDenomMetadata.Data + | MsgForceTransfer.Data + | MsgSetDenomMetadata.Data; + + export type Proto = + | MsgCreateDenom.Proto + | MsgBurn.Proto + | MsgChangeAdmin.Proto + | MsgMint.Proto + | MsgSetBeforeSendHook.Proto + | MsgSetDenomMetadata.Proto + | MsgForceTransfer.Proto + | MsgSetDenomMetadata.Proto; +} diff --git a/src/core/wasm/msgs/index.ts b/src/core/wasm/msgs/index.ts index 0eebb6ff..ff0bb33b 100644 --- a/src/core/wasm/msgs/index.ts +++ b/src/core/wasm/msgs/index.ts @@ -5,11 +5,6 @@ import { MsgExecuteContract } from './MsgExecuteContract'; import { MsgMigrateContract } from './MsgMigrateContract'; import { MsgUpdateContractAdmin } from './MsgUpdateContractAdmin'; import { MsgClearContractAdmin } from './MsgClearContractAdmin'; -import { WasmTokenFactory } from './tokenfactory'; -import { MsgCreateDenom } from './tokenfactory/MsgCreateDenom'; -import { MsgMint } from './tokenfactory/MsgMint'; -import { MsgBurn } from './tokenfactory/MsgBurn'; -import { MsgChangeAdmin } from './tokenfactory/MsgChangeAdmin'; export * from './MsgStoreCode'; export * from './MsgMigrateCode'; @@ -18,7 +13,6 @@ export * from './MsgExecuteContract'; export * from './MsgMigrateContract'; export * from './MsgUpdateContractAdmin'; export * from './MsgClearContractAdmin'; -export * from './tokenfactory'; export type WasmMsg = | MsgStoreCode @@ -27,8 +21,7 @@ export type WasmMsg = | MsgExecuteContract | MsgMigrateContract | MsgUpdateContractAdmin - | MsgClearContractAdmin - | WasmTokenFactory; + | MsgClearContractAdmin; export namespace WasmMsg { export type Amino = @@ -38,11 +31,7 @@ export namespace WasmMsg { | MsgExecuteContract.Amino | MsgMigrateContract.Amino | MsgUpdateContractAdmin.Amino - | MsgClearContractAdmin.Amino - | MsgCreateDenom.Amino - | MsgBurn.Amino - | MsgChangeAdmin.Amino - | MsgMint.Amino; + | MsgClearContractAdmin.Amino; export type Data = | MsgStoreCode.Data | MsgMigrateCode.Data @@ -50,11 +39,7 @@ export namespace WasmMsg { | MsgExecuteContract.Data | MsgMigrateContract.Data | MsgUpdateContractAdmin.Data - | MsgClearContractAdmin.Data - | MsgCreateDenom.Data - | MsgBurn.Data - | MsgChangeAdmin.Data - | MsgMint.Data; + | MsgClearContractAdmin.Data; export type Proto = | MsgStoreCode.Proto | MsgMigrateCode.Proto @@ -62,9 +47,5 @@ export namespace WasmMsg { | MsgExecuteContract.Proto | MsgMigrateContract.Proto | MsgUpdateContractAdmin.Proto - | MsgClearContractAdmin.Proto - | MsgCreateDenom.Proto - | MsgBurn.Proto - | MsgChangeAdmin.Proto - | MsgMint.Proto; + | MsgClearContractAdmin.Proto; } diff --git a/src/core/wasm/msgs/tokenfactory/index.ts b/src/core/wasm/msgs/tokenfactory/index.ts deleted file mode 100644 index 5af19186..00000000 --- a/src/core/wasm/msgs/tokenfactory/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { MsgCreateDenom } from './MsgCreateDenom'; -import { MsgBurn } from './MsgBurn'; -import { MsgChangeAdmin } from './MsgChangeAdmin'; -import { MsgMint } from './MsgMint'; - -export * from './MsgCreateDenom'; -export * from './MsgBurn'; -export * from './MsgChangeAdmin'; -export * from './MsgMint'; - -export type WasmTokenFactory = - | MsgCreateDenom - | MsgBurn - | MsgChangeAdmin - | MsgMint;