-
Notifications
You must be signed in to change notification settings - Fork 463
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: generate client constructor for apis in venus-shared (#4747)
- Loading branch information
Showing
12 changed files
with
273 additions
and
44 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"go/format" | ||
"io/ioutil" | ||
"path/filepath" | ||
"reflect" | ||
|
||
"github.com/filecoin-project/venus/venus-devtool/util" | ||
"github.com/filecoin-project/venus/venus-shared/api/messager" | ||
"github.com/filecoin-project/venus/venus-shared/api/wallet" | ||
) | ||
|
||
func init() { | ||
for _, capi := range util.ChainAPIPairs { | ||
apiTargets = append(apiTargets, capi.Venus) | ||
} | ||
|
||
apiTargets = append(apiTargets, | ||
util.APIMeta{ | ||
Type: reflect.TypeOf((*messager.IMessager)(nil)).Elem(), | ||
ParseOpt: util.InterfaceParseOption{ | ||
ImportPath: "github.com/filecoin-project/venus/venus-shared/api/messager", | ||
IncludeAll: true, | ||
}, | ||
RPCMeta: util.RPCMeta{ | ||
MethodNamespace: "Message", | ||
}, | ||
}, | ||
util.APIMeta{ | ||
Type: reflect.TypeOf((*wallet.IFullAPI)(nil)).Elem(), | ||
ParseOpt: util.InterfaceParseOption{ | ||
ImportPath: "github.com/filecoin-project/venus/venus-shared/api/wallet", | ||
IncludeAll: true, | ||
}, | ||
}, | ||
) | ||
} | ||
|
||
var apiTargets []util.APIMeta | ||
|
||
func structName(ifaceName string) string { | ||
return ifaceName + "Struct" | ||
} | ||
|
||
func outputSourceFile(location, fname string, buf *bytes.Buffer) error { | ||
formatted, err := format.Source(buf.Bytes()) | ||
if err != nil { | ||
return fmt.Errorf("format source content: %w", err) | ||
} | ||
|
||
outputFile := filepath.Join(location, fname) | ||
err = ioutil.WriteFile(outputFile, formatted, 0644) | ||
if err != nil { | ||
return fmt.Errorf("write to output %s: %w", outputFile, err) | ||
} | ||
|
||
return nil | ||
} |
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 |
---|---|---|
|
@@ -15,6 +15,7 @@ func main() { | |
Flags: []cli.Flag{}, | ||
Commands: []*cli.Command{ | ||
proxyCmd, | ||
clientCmd, | ||
}, | ||
} | ||
|
||
|
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package api | ||
|
||
const VenusAPINamespaceHeader = "X-VENUS-API-NAMESPACE" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.