-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from terra-money/feat/tokenfactory
feat: token factory refact packaging and extend models
- Loading branch information
Showing
19 changed files
with
510 additions
and
66 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...re/wasm/msgs/tokenfactory/MsgBurn.spec.ts → src/core/tokenfactory/MsgBurn.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
src/core/wasm/msgs/tokenfactory/MsgBurn.ts → src/core/tokenfactory/MsgBurn.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
6 changes: 3 additions & 3 deletions
6
.../wasm/msgs/tokenfactory/MsgChangeAdmin.ts → src/core/tokenfactory/MsgChangeAdmin.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
6 changes: 3 additions & 3 deletions
6
.../wasm/msgs/tokenfactory/MsgCreateDenom.ts → src/core/tokenfactory/MsgCreateDenom.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
2 changes: 1 addition & 1 deletion
2
...re/wasm/msgs/tokenfactory/MsgMint.spec.ts → src/core/tokenfactory/MsgMint.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
src/core/wasm/msgs/tokenfactory/MsgMint.ts → src/core/tokenfactory/MsgMint.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.