Created
June 1, 2020 23:56
-
-
Save blockpane/6a92e995dcbef934a2ae90ed9c01b3f8 to your computer and use it in GitHub Desktop.
search history for linked auth
This file contains hidden or 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
package main | |
import ( | |
"flag" | |
"fmt" | |
"github.com/fioprotocol/fio-go" // note: need 'go get github.com/fioprotocol/fio-go@develop' at time of writing. | |
"github.com/fioprotocol/fio-go/imports/eos-go" | |
"os" | |
) | |
func main() { | |
var ( | |
url string | |
account string | |
) | |
flag.StringVar(&url, "u", "", "url to connect to") | |
flag.StringVar(&account, "a", "", "account to print permissions for") | |
flag.Parse() | |
if url == "" || account == "" { | |
fmt.Println("Missing options. Use '-h' for help.") | |
os.Exit(1) | |
} | |
api, _, err := fio.NewConnection(nil, url) | |
if err != nil { | |
panic(err) | |
} | |
highest, err := api.GetMaxActions(eos.AccountName(account)) | |
if err != nil { | |
panic(err) | |
} | |
if highest == 0 { | |
fmt.Println("No results found. Note this requires that a v1 history node be used.") | |
} | |
for i := int64(highest); i > 0; i -= 100 { | |
pos := i - 100 | |
if pos < 0 { | |
pos = 0 | |
} | |
at, err := api.GetActionsUniq(eos.AccountName(account), 100, pos) | |
if err != nil { | |
panic(err) | |
} | |
for i := len(at) - 1; i >= 0; i-- { | |
if at[i] == nil { | |
continue | |
} | |
if at[i].Action != nil && at[i].Action.Name == "linkauth" { | |
la := at[i].Action.Data.(map[string]interface{}) | |
fmt.Printf("%s -> %s::%s (txid: %s)\n", la["requirement"], la["code"], la["type"], at[i].TransactionID.String() ) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment