-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
219 additions
and
4 deletions.
There are no files selected for viewing
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,25 @@ | ||
import { LCDClient, MsgSend, MnemonicKey } from '../src'; | ||
import { SignMode } from '@terra-money/terra.proto/cosmos/tx/signing/v1beta1/signing'; | ||
import { TxBody } from '@terra-money/terra.proto/cosmos/tx/v1beta1/tx'; | ||
|
||
async function main() { | ||
const bombay = new LCDClient({ | ||
chainID: 'bombay-12', | ||
URL: 'https://bombay-lcd.terra.dev', | ||
gasPrices: { uusd: 0.15 }, | ||
}); | ||
|
||
(await bombay.tx.txInfosByHeight(8152638)). | ||
map((tx) => { | ||
console.log(JSON.stringify(tx)); | ||
}); | ||
|
||
|
||
(await bombay.tx.txInfosByHeight(8153558)). | ||
map((tx) => { | ||
console.log(JSON.stringify(tx)); | ||
}); | ||
|
||
} | ||
|
||
main().catch(console.error); |
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,51 @@ | ||
import { MsgVerifyInvariant } from './MsgVerifyInvariant'; | ||
|
||
describe('MsgVerifyInvariant', () => { | ||
it('deserialize correctly', () => { | ||
const send = MsgVerifyInvariant.fromAmino({ | ||
type: 'crisis/MsgVerifyInvariant', | ||
value: { | ||
sender: 'terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v', | ||
invariantModuleName: 'bank', | ||
invariantRoute: 'nonnegative-outstanding-supply', | ||
}, | ||
}); | ||
|
||
expect(send).toMatchObject({ | ||
sender: 'terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v', | ||
invariantModuleName: 'bank', | ||
invariantRoute: 'nonnegative-outstanding-supply', | ||
}); | ||
|
||
expect(send.toAmino()).toMatchObject({ | ||
type: 'crisis/MsgVerifyInvariant', | ||
value: { | ||
sender: 'terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v', | ||
invariantModuleName: 'bank', | ||
invariantRoute: 'nonnegative-outstanding-supply', | ||
}, | ||
}); | ||
}); | ||
|
||
it('deserialize correctly proto', () => { | ||
const send = MsgVerifyInvariant.fromData({ | ||
'@type': '/cosmos.crisis.v1beta1.MsgVerifyInvariant', | ||
sender: 'terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v', | ||
invariantModuleName: 'bank', | ||
invariantRoute: 'nonnegative-outstanding-supply', | ||
}); | ||
|
||
expect(send).toMatchObject({ | ||
sender: 'terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v', | ||
invariantModuleName: 'bank', | ||
invariantRoute: 'nonnegative-outstanding-supply', | ||
}); | ||
|
||
expect(send.toData()).toMatchObject({ | ||
'@type': '/cosmos.crisis.v1beta1.MsgVerifyInvariant', | ||
sender: 'terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v', | ||
invariantModuleName: 'bank', | ||
invariantRoute: 'nonnegative-outstanding-supply', | ||
}); | ||
}); | ||
}); |
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,111 @@ | ||
import { JSONSerializable } from '../../util/json'; | ||
import { Any } from '@terra-money/terra.proto/google/protobuf/any'; | ||
import { MsgVerifyInvariant as MsgVerifyInvariant_pb } from '@terra-money/terra.proto/cosmos/crisis/v1beta1/tx'; | ||
import { AccAddress } from '../bech32'; | ||
|
||
/** | ||
* MsgVerifyInvariant represents a message to verify a particular invariance. | ||
*/ | ||
export class MsgVerifyInvariant extends JSONSerializable< | ||
MsgVerifyInvariant.Amino, | ||
MsgVerifyInvariant.Data, | ||
MsgVerifyInvariant.Proto | ||
> { | ||
/** | ||
* @param sender sender's address | ||
* @param invariantModuleName module name to verify invariant | ||
* @param invariantRoute route to verify | ||
*/ | ||
constructor( | ||
public sender: AccAddress, | ||
public invariantModuleName: string, | ||
public invariantRoute: string | ||
) { | ||
super(); | ||
} | ||
|
||
public static fromAmino(data: MsgVerifyInvariant.Amino): MsgVerifyInvariant { | ||
const { | ||
value: { sender, invariantModuleName, invariantRoute }, | ||
} = data; | ||
return new MsgVerifyInvariant(sender, invariantModuleName, invariantRoute); | ||
} | ||
|
||
public toAmino(): MsgVerifyInvariant.Amino { | ||
const { sender, invariantModuleName, invariantRoute } = this; | ||
return { | ||
type: 'crisis/MsgVerifyInvariant', | ||
value: { | ||
sender, | ||
invariantModuleName, | ||
invariantRoute, | ||
}, | ||
}; | ||
} | ||
|
||
public static fromData(data: MsgVerifyInvariant.Data): MsgVerifyInvariant { | ||
const { sender, invariantModuleName, invariantRoute } = data; | ||
|
||
return new MsgVerifyInvariant(sender, invariantModuleName, invariantRoute); | ||
} | ||
|
||
public toData(): MsgVerifyInvariant.Data { | ||
const { sender, invariantModuleName, invariantRoute } = this; | ||
return { | ||
'@type': '/cosmos.crisis.v1beta1.MsgVerifyInvariant', | ||
sender, | ||
invariantModuleName, | ||
invariantRoute, | ||
}; | ||
} | ||
|
||
public static fromProto(proto: MsgVerifyInvariant.Proto): MsgVerifyInvariant { | ||
return new MsgVerifyInvariant( | ||
proto.sender, | ||
proto.invariantModuleName, | ||
proto.invariantRoute | ||
); | ||
} | ||
|
||
public toProto(): MsgVerifyInvariant.Proto { | ||
const { sender, invariantModuleName, invariantRoute } = this; | ||
return MsgVerifyInvariant_pb.fromPartial({ | ||
sender, | ||
invariantModuleName, | ||
invariantRoute, | ||
}); | ||
} | ||
|
||
public packAny(): Any { | ||
return Any.fromPartial({ | ||
typeUrl: '/cosmos.crisis.v1beta1.MsgVerifyInvariant', | ||
value: MsgVerifyInvariant_pb.encode(this.toProto()).finish(), | ||
}); | ||
} | ||
|
||
public static unpackAny(msgAny: Any): MsgVerifyInvariant { | ||
return MsgVerifyInvariant.fromProto( | ||
MsgVerifyInvariant_pb.decode(msgAny.value) | ||
); | ||
} | ||
} | ||
|
||
export namespace MsgVerifyInvariant { | ||
export interface Amino { | ||
type: 'crisis/MsgVerifyInvariant'; | ||
value: { | ||
sender: AccAddress; | ||
invariantModuleName: string; | ||
invariantRoute: string; | ||
}; | ||
} | ||
|
||
export interface Data { | ||
'@type': '/cosmos.crisis.v1beta1.MsgVerifyInvariant'; | ||
sender: AccAddress; | ||
invariantModuleName: string; | ||
invariantRoute: string; | ||
} | ||
|
||
export type Proto = MsgVerifyInvariant_pb; | ||
} |
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,10 @@ | ||
import { MsgVerifyInvariant } from './MsgVerifyInvariant'; | ||
|
||
export * from './MsgVerifyInvariant'; | ||
|
||
export type CrisisMsg = MsgVerifyInvariant; | ||
export namespace CrisisMsg { | ||
export type Amino = MsgVerifyInvariant.Amino; | ||
export type Data = MsgVerifyInvariant.Data; | ||
export type Proto = MsgVerifyInvariant.Proto; | ||
} |