subscan-essentials icon indicating copy to clipboard operation
subscan-essentials copied to clipboard

Extension of already existing plugins

Open hunte-star opened this issue 4 years ago • 4 comments

The balance plugin already creates a db table but the api just takes row and page parameter in request body. Now if I need to extend this plugins' already existing feature by adding account search how do I go about it. I tried adding a new route within the balance plugin https://github.com/itering/subscan-essentials/blob/master/plugins/balance/http/http.go#L18 but data is not being queried through and modification in one route's function affected the other.

hunte-star avatar Jan 25 '22 09:01 hunte-star

You just need to add a new route to https://github.com/itering/subscan-essentials/blob/65a62200b6277ff02d38d50bc0658cc2df3aa16c/plugins/balance/http/http.go#L20 and write the query in this handle logic

freehere107 avatar Jan 26 '22 01:01 freehere107

Yeah i tried that and wrote a query similar to this https://github.com/itering/subscan-essentials/blob/master/plugins/system/dao/dao.go#L24 db.FindBy(&accountser, map[string]interface{}{"address": address}, nil) but the data it returns is nil and due to this the other account route also returns empty json when invoked. Is the query in the above FindBy method correct or am i missing something?

hunte-star avatar Jan 27 '22 03:01 hunte-star

[Update] Both routes work separately when the other is commented out but when both are present data is not returned properly.

return []router.Http{ {"accounts", accounts}, //{"findac", findac}, }

The accounts route returns multiple db table rows while findac return only one.

hunte-star avatar Jan 27 '22 10:01 hunte-star

you can achieve this by using query parameters

andropixels avatar Jul 27 '22 14:07 andropixels