MCPcopy Create free account
hub / github.com/ethstorage/es-node / GetContractVersion

Method GetContractVersion

ethstorage/eth/polling_client.go:366–380  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

364}
365
366func (w *PollingClient) GetContractVersion() (string, error) {
367 bs, err := w.ReadContractField("version", nil)
368 if err != nil {
369 return "", fmt.Errorf("failed to get version from contract: %v", err)
370 }
371 versionStr, err := decodeString(bs)
372 if err != nil {
373 return "", fmt.Errorf("failed to decode version string: %v", err)
374 }
375 version := "v" + versionStr
376 if !semver.IsValid(version) {
377 return "", fmt.Errorf("invalid version string: %s", versionStr)
378 }
379 return version, nil
380}
381
382func decodeString(data []byte) (string, error) {
383 if len(data) < 64 {

Callers 1

CheckMinerRoleMethod · 0.80

Calls 2

ReadContractFieldMethod · 0.95
decodeStringFunction · 0.85

Tested by

no test coverage detected