@@ -3,21 +3,24 @@ import { MsgExecuteContract as MsgExecuteContract_legacy_pb } from '@terra-money
33import { MsgExecuteContract as MsgExecuteContract_pb } from '@terra-money/terra.proto/cosmwasm/wasm/v1/tx' ;
44
55describe ( 'MsgExecuteContract' , ( ) => {
6- it ( 'legacy: works when execute_msg is not JSON' , ( ) => {
7- const msg1 = MsgExecuteContract . fromAmino ( {
8- type : 'wasm/MsgExecuteContract' ,
9- value : {
10- sender : 'terra16xw94u0jgmuaz8zs54xn9x96lxew74gs05gs4h' ,
11- contract : 'terra15gwkyepfc6xgca5t5zefzwy42uts8l2m4g40k6' ,
12- execute_msg : {
13- transfer : {
14- recipient : 'terra13jqgrtqwucx4jdvhg0d4tc80892fscx54298yt' ,
15- amount : 10000 ,
6+ it ( 'works when execute_msg is not JSON' , ( ) => {
7+ const msg1 = MsgExecuteContract . fromAmino (
8+ {
9+ type : 'wasm/MsgExecuteContract' ,
10+ value : {
11+ sender : 'terra16xw94u0jgmuaz8zs54xn9x96lxew74gs05gs4h' ,
12+ contract : 'terra15gwkyepfc6xgca5t5zefzwy42uts8l2m4g40k6' ,
13+ msg : {
14+ transfer : {
15+ recipient : 'terra13jqgrtqwucx4jdvhg0d4tc80892fscx54298yt' ,
16+ amount : 10000 ,
17+ } ,
1618 } ,
19+ funds : [ ] ,
1720 } ,
18- coins : [ ] ,
1921 } ,
20- } , true ) ;
22+ false
23+ ) ;
2124
2225 expect ( msg1 . execute_msg ) . toMatchObject ( {
2326 transfer : {
@@ -27,10 +30,10 @@ describe('MsgExecuteContract', () => {
2730 } ) ;
2831 } ) ;
2932
30- it ( 'works when execute_msg is not JSON ' , ( ) => {
31- const msg1 = MsgExecuteContract . fromAmino ( {
32- type : 'wasm/MsgExecuteContract' ,
33- value : {
33+ it ( 'proto ' , ( ) => {
34+ const msg1 = MsgExecuteContract . fromData (
35+ {
36+ '@type' : '/cosmwasm.wasm.v1.MsgExecuteContract' ,
3437 sender : 'terra16xw94u0jgmuaz8zs54xn9x96lxew74gs05gs4h' ,
3538 contract : 'terra15gwkyepfc6xgca5t5zefzwy42uts8l2m4g40k6' ,
3639 msg : {
@@ -41,51 +44,8 @@ describe('MsgExecuteContract', () => {
4144 } ,
4245 funds : [ ] ,
4346 } ,
44- } , false ) ;
45-
46- expect ( msg1 . execute_msg ) . toMatchObject ( {
47- transfer : {
48- recipient : 'terra13jqgrtqwucx4jdvhg0d4tc80892fscx54298yt' ,
49- amount : 10000 ,
50- } ,
51- } ) ;
52- } ) ;
53-
54- it ( 'legacy proto' , ( ) => {
55- const msg1 = MsgExecuteContract . fromData ( {
56- '@type' : '/terra.wasm.v1beta1.MsgExecuteContract' ,
57- sender : 'terra16xw94u0jgmuaz8zs54xn9x96lxew74gs05gs4h' ,
58- contract : 'terra15gwkyepfc6xgca5t5zefzwy42uts8l2m4g40k6' ,
59- execute_msg : {
60- transfer : {
61- recipient : 'terra13jqgrtqwucx4jdvhg0d4tc80892fscx54298yt' ,
62- amount : 10000 ,
63- } ,
64- } ,
65- coins : [ ] ,
66- } , true ) ;
67-
68- expect ( msg1 . execute_msg ) . toMatchObject ( {
69- transfer : {
70- recipient : 'terra13jqgrtqwucx4jdvhg0d4tc80892fscx54298yt' ,
71- amount : 10000 ,
72- } ,
73- } ) ;
74- } ) ;
75-
76- it ( 'proto' , ( ) => {
77- const msg1 = MsgExecuteContract . fromData ( {
78- '@type' : '/cosmwasm.wasm.v1.MsgExecuteContract' ,
79- sender : 'terra16xw94u0jgmuaz8zs54xn9x96lxew74gs05gs4h' ,
80- contract : 'terra15gwkyepfc6xgca5t5zefzwy42uts8l2m4g40k6' ,
81- msg : {
82- transfer : {
83- recipient : 'terra13jqgrtqwucx4jdvhg0d4tc80892fscx54298yt' ,
84- amount : 10000 ,
85- } ,
86- } ,
87- funds : [ ] ,
88- } , false ) ;
47+ false
48+ ) ;
8949
9050 expect ( msg1 . execute_msg ) . toMatchObject ( {
9151 transfer : {
@@ -95,49 +55,28 @@ describe('MsgExecuteContract', () => {
9555 } ) ;
9656 } ) ;
9757
98-
99-
100- it ( 'legacy: with string msg' , ( ) => {
101- const msgWithExecuteString = new MsgExecuteContract (
102- 'terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v' ,
103- 'terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v' ,
104- 'execute_msg_as_string' ,
105- { uluna : 120400 }
106- ) ;
107- const aminoWithExecuteString = msgWithExecuteString . toAmino ( true ) as MsgExecuteContract . AminoV1 ;
108- expect ( aminoWithExecuteString . value . execute_msg ) . toEqual (
109- msgWithExecuteString . execute_msg
110- ) ;
111- const protoWithExecuteString = msgWithExecuteString . toProto ( true ) as MsgExecuteContract_legacy_pb ;
112- expect ( protoWithExecuteString . executeMsg . toString ( ) ) . toEqual (
113- JSON . stringify ( msgWithExecuteString . execute_msg )
114- ) ;
115- const dataWithExecuteString = msgWithExecuteString . toData ( true ) as MsgExecuteContract . DataV1 ;
116- expect ( dataWithExecuteString . execute_msg ) . toEqual (
117- msgWithExecuteString . execute_msg
118- ) ;
119- } ) ;
120-
12158 it ( 'with string msg' , ( ) => {
12259 const msgWithExecuteString = new MsgExecuteContract (
12360 'terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v' ,
12461 'terra1x46rqay4d3cssq8gxxvqz8xt6nwlz4td20k38v' ,
12562 'execute_msg_as_string' ,
12663 { uluna : 120400 }
12764 ) ;
128- const aminoWithExecuteString = msgWithExecuteString . toAmino ( false ) as MsgExecuteContract . AminoV2 ;
65+ const aminoWithExecuteString = msgWithExecuteString . toAmino (
66+ false
67+ ) as MsgExecuteContract . AminoV2 ;
12968 expect ( aminoWithExecuteString . value . msg ) . toEqual (
13069 msgWithExecuteString . execute_msg
13170 ) ;
132- const protoWithExecuteString = msgWithExecuteString . toProto ( false ) as MsgExecuteContract_pb ;
71+ const protoWithExecuteString = msgWithExecuteString . toProto (
72+ false
73+ ) as MsgExecuteContract_pb ;
13374 expect ( protoWithExecuteString . msg . toString ( ) ) . toEqual (
13475 JSON . stringify ( msgWithExecuteString . execute_msg )
13576 ) ;
136- const dataWithExecuteString = msgWithExecuteString . toData ( false ) as MsgExecuteContract . DataV2 ;
137- expect ( dataWithExecuteString . msg ) . toEqual (
138- msgWithExecuteString . execute_msg
139- ) ;
77+ const dataWithExecuteString = msgWithExecuteString . toData (
78+ false
79+ ) as MsgExecuteContract . DataV2 ;
80+ expect ( dataWithExecuteString . msg ) . toEqual ( msgWithExecuteString . execute_msg ) ;
14081 } ) ;
141-
142-
14382} ) ;
0 commit comments