@@ -11,8 +11,8 @@ import (
1111 appstate "github.com/ovrclk/akash/state"
1212 "github.com/ovrclk/akash/types"
1313 "github.com/ovrclk/akash/types/code"
14- tmtypes "github.com/tendermint/abci/types"
15- "github.com/tendermint/tmlibs /log"
14+ abci_types "github.com/tendermint /tendermint/abci/types"
15+ "github.com/tendermint/tendermint/libs /log"
1616)
1717
1818const (
@@ -27,51 +27,51 @@ func NewApp(logger log.Logger) (apptypes.Application, error) {
2727 return & app {apptypes .NewBaseApp (Name , logger )}, nil
2828}
2929
30- func (a * app ) AcceptQuery (req tmtypes .RequestQuery ) bool {
30+ func (a * app ) AcceptQuery (req abci_types .RequestQuery ) bool {
3131 return strings .HasPrefix (req .GetPath (), appstate .AccountPath )
3232}
3333
34- func (a * app ) Query (state appstate.State , req tmtypes .RequestQuery ) tmtypes .ResponseQuery {
34+ func (a * app ) Query (state appstate.State , req abci_types .RequestQuery ) abci_types .ResponseQuery {
3535
3636 if ! a .AcceptQuery (req ) {
37- return tmtypes .ResponseQuery {
37+ return abci_types .ResponseQuery {
3838 Code : code .UNKNOWN_QUERY ,
3939 Log : "invalid key" ,
4040 }
4141 }
4242 id := strings .TrimPrefix (req .Path , appstate .AccountPath )
4343 key , err := keys .ParseAccountPath (id )
4444 if err != nil {
45- return tmtypes .ResponseQuery {
45+ return abci_types .ResponseQuery {
4646 Code : code .ERROR ,
4747 Log : err .Error (),
4848 }
4949 }
5050
5151 acct , err := state .Account ().Get (key .ID ())
5252 if err != nil {
53- return tmtypes .ResponseQuery {
53+ return abci_types .ResponseQuery {
5454 Code : code .ERROR ,
5555 Log : err .Error (),
5656 }
5757 }
5858
5959 if acct == nil {
60- return tmtypes .ResponseQuery {
60+ return abci_types .ResponseQuery {
6161 Code : code .NOT_FOUND ,
6262 Log : fmt .Sprintf ("account %x not found" , key ),
6363 }
6464 }
6565
6666 bytes , err := proto .Marshal (acct )
6767 if err != nil {
68- return tmtypes .ResponseQuery {
68+ return abci_types .ResponseQuery {
6969 Code : code .ERROR ,
7070 Log : err .Error (),
7171 }
7272 }
7373
74- return tmtypes .ResponseQuery {
74+ return abci_types .ResponseQuery {
7575 Value : bytes ,
7676 Height : state .Version (),
7777 }
@@ -85,95 +85,95 @@ func (a *app) AcceptTx(ctx apptypes.Context, tx interface{}) bool {
8585 return false
8686}
8787
88- func (a * app ) CheckTx (state appstate.State , ctx apptypes.Context , tx interface {}) tmtypes .ResponseCheckTx {
88+ func (a * app ) CheckTx (state appstate.State , ctx apptypes.Context , tx interface {}) abci_types .ResponseCheckTx {
8989 switch tx := tx .(type ) {
9090 case * types.TxPayload_TxSend :
9191 return a .doCheckTx (state , ctx , tx .TxSend )
9292 }
93- return tmtypes .ResponseCheckTx {
93+ return abci_types .ResponseCheckTx {
9494 Code : code .UNKNOWN_TRANSACTION ,
9595 Log : "unknown transaction" ,
9696 }
9797}
9898
99- func (a * app ) DeliverTx (state appstate.State , ctx apptypes.Context , tx interface {}) tmtypes .ResponseDeliverTx {
99+ func (a * app ) DeliverTx (state appstate.State , ctx apptypes.Context , tx interface {}) abci_types .ResponseDeliverTx {
100100 switch tx := tx .(type ) {
101101 case * types.TxPayload_TxSend :
102102 return a .doDeliverTx (state , ctx , tx .TxSend )
103103 }
104- return tmtypes .ResponseDeliverTx {
104+ return abci_types .ResponseDeliverTx {
105105 Code : code .UNKNOWN_TRANSACTION ,
106106 Log : "unknown transaction" ,
107107 }
108108}
109109
110- func (a * app ) doCheckTx (state appstate.State , ctx apptypes.Context , tx * types.TxSend ) tmtypes .ResponseCheckTx {
110+ func (a * app ) doCheckTx (state appstate.State , ctx apptypes.Context , tx * types.TxSend ) abci_types .ResponseCheckTx {
111111
112112 if ! bytes .Equal (ctx .Signer ().Address (), tx .From ) {
113- return tmtypes .ResponseCheckTx {
113+ return abci_types .ResponseCheckTx {
114114 Code : code .INVALID_TRANSACTION ,
115115 Log : "Not signed by sending address" ,
116116 }
117117 }
118118
119119 if bytes .Equal (tx .From , tx .To ) {
120- return tmtypes .ResponseCheckTx {
120+ return abci_types .ResponseCheckTx {
121121 Code : code .INVALID_TRANSACTION ,
122122 Log : "source and destination can't be the same address" ,
123123 }
124124 }
125125
126126 acct , err := state .Account ().Get (tx .From )
127127 if err != nil {
128- return tmtypes .ResponseCheckTx {
128+ return abci_types .ResponseCheckTx {
129129 Code : code .INVALID_TRANSACTION ,
130130 Log : err .Error (),
131131 }
132132 }
133133 if acct == nil {
134- return tmtypes .ResponseCheckTx {
134+ return abci_types .ResponseCheckTx {
135135 Code : code .INVALID_TRANSACTION ,
136136 Log : "unknown source account" ,
137137 }
138138 }
139139
140140 if acct .Balance < tx .Amount {
141- return tmtypes .ResponseCheckTx {
141+ return abci_types .ResponseCheckTx {
142142 Code : code .INVALID_TRANSACTION ,
143143 Log : "insufficient funds" ,
144144 }
145145 }
146146
147- return tmtypes .ResponseCheckTx {}
147+ return abci_types .ResponseCheckTx {}
148148}
149149
150- func (a * app ) doDeliverTx (state appstate.State , ctx apptypes.Context , tx * types.TxSend ) tmtypes .ResponseDeliverTx {
150+ func (a * app ) doDeliverTx (state appstate.State , ctx apptypes.Context , tx * types.TxSend ) abci_types .ResponseDeliverTx {
151151
152152 cresp := a .doCheckTx (state , ctx , tx )
153153 if ! cresp .IsOK () {
154- return tmtypes .ResponseDeliverTx {
154+ return abci_types .ResponseDeliverTx {
155155 Code : cresp .Code ,
156156 Log : cresp .Log ,
157157 }
158158 }
159159
160160 acct , err := state .Account ().Get (tx .From )
161161 if err != nil {
162- return tmtypes .ResponseDeliverTx {
162+ return abci_types .ResponseDeliverTx {
163163 Code : code .INVALID_TRANSACTION ,
164164 Log : err .Error (),
165165 }
166166 }
167167 if acct == nil {
168- return tmtypes .ResponseDeliverTx {
168+ return abci_types .ResponseDeliverTx {
169169 Code : code .INVALID_TRANSACTION ,
170170 Log : "unknown source account" ,
171171 }
172172 }
173173
174174 toacct , err := state .Account ().Get (tx .To )
175175 if err != nil {
176- return tmtypes .ResponseDeliverTx {
176+ return abci_types .ResponseDeliverTx {
177177 Code : code .INVALID_TRANSACTION ,
178178 Log : err .Error (),
179179 }
@@ -189,20 +189,20 @@ func (a *app) doDeliverTx(state appstate.State, ctx apptypes.Context, tx *types.
189189 toacct .Balance += tx .Amount
190190
191191 if err := state .Account ().Save (acct ); err != nil {
192- return tmtypes .ResponseDeliverTx {
192+ return abci_types .ResponseDeliverTx {
193193 Code : code .INVALID_TRANSACTION ,
194194 Log : err .Error (),
195195 }
196196 }
197197
198198 if err := state .Account ().Save (toacct ); err != nil {
199- return tmtypes .ResponseDeliverTx {
199+ return abci_types .ResponseDeliverTx {
200200 Code : code .INVALID_TRANSACTION ,
201201 Log : err .Error (),
202202 }
203203 }
204204
205- return tmtypes .ResponseDeliverTx {
205+ return abci_types .ResponseDeliverTx {
206206 Tags : apptypes .NewTags (a .Name (), apptypes .TxTypeSend ),
207207 }
208208}
0 commit comments