From 4db95bff6d85c4905aaa6e65bc625da84f6124f9 Mon Sep 17 00:00:00 2001 From: Miguel Victoria Date: Mon, 7 Oct 2024 22:17:09 +0200 Subject: [PATCH] clean code on agent_verify --- go/decriptkey.go | 23 -- go/pkg/gnoindexerql/gnoindexerQL.go | 336 +----------------- .../gnoindexerql/indexer-operations.graphql | 31 +- 3 files changed, 4 insertions(+), 386 deletions(-) delete mode 100644 go/decriptkey.go diff --git a/go/decriptkey.go b/go/decriptkey.go deleted file mode 100644 index c43fe49dc0..0000000000 --- a/go/decriptkey.go +++ /dev/null @@ -1,23 +0,0 @@ -package main - -import ( - "encoding/hex" - - "github.com/gnolang/gno/gnovm/pkg/gnoenv" - "github.com/gnolang/gno/tm2/pkg/crypto/keys" -) - -const DefaultAccount_Seed = "source bonus chronic canvas draft south burst lottery vacant surface solve popular case indicate oppose farm nothing bullet exhibit title speed wink action roast" - -func main() { - // Replace this with the actual passphrase - - kb, _ := keys.NewKeyBaseFromDir(gnoenv.HomeDir()) - pass := "M3gustaladolcegusto" - signature, _, err := kb.Sign("MyKey", pass, []byte("ingest,g14vxq5e5pt5sev7rkz2ej438scmxtylnzv5vnkw,OK")) - if err != nil { - panic(err) - } - - println(hex.EncodeToString(signature)) -} diff --git a/go/pkg/gnoindexerql/gnoindexerQL.go b/go/pkg/gnoindexerql/gnoindexerQL.go index 707252df71..cb159b2dc2 100644 --- a/go/pkg/gnoindexerql/gnoindexerQL.go +++ b/go/pkg/gnoindexerql/gnoindexerQL.go @@ -422,283 +422,6 @@ func (v *GetPostTransactionsTransactionsTransactionResponse) GetInfo() string { // GetLog returns GetPostTransactionsTransactionsTransactionResponse.Log, and is useful for accessing the field via an interface. func (v *GetPostTransactionsTransactionsTransactionResponse) GetLog() string { return v.Log } -// GetValidationRequestsResponse is returned by GetValidationRequests on success. -type GetValidationRequestsResponse struct { - // Retrieves a list of Transactions that match the given filter criteria. If the result is incomplete due to errors, both partial results and errors are returned. - Transactions []GetValidationRequestsTransactionsTransaction `json:"transactions"` -} - -// GetTransactions returns GetValidationRequestsResponse.Transactions, and is useful for accessing the field via an interface. -func (v *GetValidationRequestsResponse) GetTransactions() []GetValidationRequestsTransactionsTransaction { - return v.Transactions -} - -// GetValidationRequestsTransactionsTransaction includes the requested fields of the GraphQL type Transaction. -// The GraphQL type's documentation follows. -// -// Defines a transaction within a block, detailing its execution specifics and content. -type GetValidationRequestsTransactionsTransaction struct { - // The success can determine whether the transaction succeeded or failed. - Success bool `json:"success"` - // The height of the Block in which this Transaction is included. Links the Transaction to its containing Block. - Block_height int `json:"block_height"` - // `response` is the processing result of the transaction. - // It has `log`, `info`, `error`, and `data`. - Response GetValidationRequestsTransactionsTransactionResponse `json:"response"` -} - -// GetSuccess returns GetValidationRequestsTransactionsTransaction.Success, and is useful for accessing the field via an interface. -func (v *GetValidationRequestsTransactionsTransaction) GetSuccess() bool { return v.Success } - -// GetBlock_height returns GetValidationRequestsTransactionsTransaction.Block_height, and is useful for accessing the field via an interface. -func (v *GetValidationRequestsTransactionsTransaction) GetBlock_height() int { return v.Block_height } - -// GetResponse returns GetValidationRequestsTransactionsTransaction.Response, and is useful for accessing the field via an interface. -func (v *GetValidationRequestsTransactionsTransaction) GetResponse() GetValidationRequestsTransactionsTransactionResponse { - return v.Response -} - -// GetValidationRequestsTransactionsTransactionResponse includes the requested fields of the GraphQL type TransactionResponse. -// The GraphQL type's documentation follows. -// -// `TransactionResponse` is the processing result of the transaction. -// It has `log`, `info`, `error`, and `data`. -type GetValidationRequestsTransactionsTransactionResponse struct { - // The emitted events associated with the transaction execution, if any. - Events []GetValidationRequestsTransactionsTransactionResponseEventsEvent `json:"-"` -} - -// GetEvents returns GetValidationRequestsTransactionsTransactionResponse.Events, and is useful for accessing the field via an interface. -func (v *GetValidationRequestsTransactionsTransactionResponse) GetEvents() []GetValidationRequestsTransactionsTransactionResponseEventsEvent { - return v.Events -} - -func (v *GetValidationRequestsTransactionsTransactionResponse) UnmarshalJSON(b []byte) error { - - if string(b) == "null" { - return nil - } - - var firstPass struct { - *GetValidationRequestsTransactionsTransactionResponse - Events []json.RawMessage `json:"events"` - graphql.NoUnmarshalJSON - } - firstPass.GetValidationRequestsTransactionsTransactionResponse = v - - err := json.Unmarshal(b, &firstPass) - if err != nil { - return err - } - - { - dst := &v.Events - src := firstPass.Events - *dst = make( - []GetValidationRequestsTransactionsTransactionResponseEventsEvent, - len(src)) - for i, src := range src { - dst := &(*dst)[i] - if len(src) != 0 && string(src) != "null" { - err = __unmarshalGetValidationRequestsTransactionsTransactionResponseEventsEvent( - src, dst) - if err != nil { - return fmt.Errorf( - "unable to unmarshal GetValidationRequestsTransactionsTransactionResponse.Events: %w", err) - } - } - } - } - return nil -} - -type __premarshalGetValidationRequestsTransactionsTransactionResponse struct { - Events []json.RawMessage `json:"events"` -} - -func (v *GetValidationRequestsTransactionsTransactionResponse) MarshalJSON() ([]byte, error) { - premarshaled, err := v.__premarshalJSON() - if err != nil { - return nil, err - } - return json.Marshal(premarshaled) -} - -func (v *GetValidationRequestsTransactionsTransactionResponse) __premarshalJSON() (*__premarshalGetValidationRequestsTransactionsTransactionResponse, error) { - var retval __premarshalGetValidationRequestsTransactionsTransactionResponse - - { - - dst := &retval.Events - src := v.Events - *dst = make( - []json.RawMessage, - len(src)) - for i, src := range src { - dst := &(*dst)[i] - var err error - *dst, err = __marshalGetValidationRequestsTransactionsTransactionResponseEventsEvent( - &src) - if err != nil { - return nil, fmt.Errorf( - "unable to marshal GetValidationRequestsTransactionsTransactionResponse.Events: %w", err) - } - } - } - return &retval, nil -} - -// GetValidationRequestsTransactionsTransactionResponseEventsEvent includes the requested fields of the GraphQL interface Event. -// -// GetValidationRequestsTransactionsTransactionResponseEventsEvent is implemented by the following types: -// GetValidationRequestsTransactionsTransactionResponseEventsGnoEvent -// GetValidationRequestsTransactionsTransactionResponseEventsUnknownEvent -type GetValidationRequestsTransactionsTransactionResponseEventsEvent interface { - implementsGraphQLInterfaceGetValidationRequestsTransactionsTransactionResponseEventsEvent() - // GetTypename returns the receiver's concrete GraphQL type-name (see interface doc for possible values). - GetTypename() string -} - -func (v *GetValidationRequestsTransactionsTransactionResponseEventsGnoEvent) implementsGraphQLInterfaceGetValidationRequestsTransactionsTransactionResponseEventsEvent() { -} -func (v *GetValidationRequestsTransactionsTransactionResponseEventsUnknownEvent) implementsGraphQLInterfaceGetValidationRequestsTransactionsTransactionResponseEventsEvent() { -} - -func __unmarshalGetValidationRequestsTransactionsTransactionResponseEventsEvent(b []byte, v *GetValidationRequestsTransactionsTransactionResponseEventsEvent) error { - if string(b) == "null" { - return nil - } - - var tn struct { - TypeName string `json:"__typename"` - } - err := json.Unmarshal(b, &tn) - if err != nil { - return err - } - - switch tn.TypeName { - case "GnoEvent": - *v = new(GetValidationRequestsTransactionsTransactionResponseEventsGnoEvent) - return json.Unmarshal(b, *v) - case "UnknownEvent": - *v = new(GetValidationRequestsTransactionsTransactionResponseEventsUnknownEvent) - return json.Unmarshal(b, *v) - case "": - return fmt.Errorf( - "response was missing Event.__typename") - default: - return fmt.Errorf( - `unexpected concrete type for GetValidationRequestsTransactionsTransactionResponseEventsEvent: "%v"`, tn.TypeName) - } -} - -func __marshalGetValidationRequestsTransactionsTransactionResponseEventsEvent(v *GetValidationRequestsTransactionsTransactionResponseEventsEvent) ([]byte, error) { - - var typename string - switch v := (*v).(type) { - case *GetValidationRequestsTransactionsTransactionResponseEventsGnoEvent: - typename = "GnoEvent" - - result := struct { - TypeName string `json:"__typename"` - *GetValidationRequestsTransactionsTransactionResponseEventsGnoEvent - }{typename, v} - return json.Marshal(result) - case *GetValidationRequestsTransactionsTransactionResponseEventsUnknownEvent: - typename = "UnknownEvent" - - result := struct { - TypeName string `json:"__typename"` - *GetValidationRequestsTransactionsTransactionResponseEventsUnknownEvent - }{typename, v} - return json.Marshal(result) - case nil: - return []byte("null"), nil - default: - return nil, fmt.Errorf( - `unexpected concrete type for GetValidationRequestsTransactionsTransactionResponseEventsEvent: "%T"`, v) - } -} - -// GetValidationRequestsTransactionsTransactionResponseEventsGnoEvent includes the requested fields of the GraphQL type GnoEvent. -// The GraphQL type's documentation follows. -// -// `GnoEvent` is the event information exported by the Gno VM. -// It has `type`, `pkg_path`, `func`, and `attrs`. -type GetValidationRequestsTransactionsTransactionResponseEventsGnoEvent struct { - Typename string `json:"__typename"` - // `type` is the type of transaction event emitted. - Type string `json:"type"` - // `pkg_path` is the path to the package that emitted the event. - Pkg_path string `json:"pkg_path"` - // `func` is the name of the function that emitted the event. - Func string `json:"func"` - // `attrs` is the event's attribute information. - Attrs []GetValidationRequestsTransactionsTransactionResponseEventsGnoEventAttrsGnoEventAttribute `json:"attrs"` -} - -// GetTypename returns GetValidationRequestsTransactionsTransactionResponseEventsGnoEvent.Typename, and is useful for accessing the field via an interface. -func (v *GetValidationRequestsTransactionsTransactionResponseEventsGnoEvent) GetTypename() string { - return v.Typename -} - -// GetType returns GetValidationRequestsTransactionsTransactionResponseEventsGnoEvent.Type, and is useful for accessing the field via an interface. -func (v *GetValidationRequestsTransactionsTransactionResponseEventsGnoEvent) GetType() string { - return v.Type -} - -// GetPkg_path returns GetValidationRequestsTransactionsTransactionResponseEventsGnoEvent.Pkg_path, and is useful for accessing the field via an interface. -func (v *GetValidationRequestsTransactionsTransactionResponseEventsGnoEvent) GetPkg_path() string { - return v.Pkg_path -} - -// GetFunc returns GetValidationRequestsTransactionsTransactionResponseEventsGnoEvent.Func, and is useful for accessing the field via an interface. -func (v *GetValidationRequestsTransactionsTransactionResponseEventsGnoEvent) GetFunc() string { - return v.Func -} - -// GetAttrs returns GetValidationRequestsTransactionsTransactionResponseEventsGnoEvent.Attrs, and is useful for accessing the field via an interface. -func (v *GetValidationRequestsTransactionsTransactionResponseEventsGnoEvent) GetAttrs() []GetValidationRequestsTransactionsTransactionResponseEventsGnoEventAttrsGnoEventAttribute { - return v.Attrs -} - -// GetValidationRequestsTransactionsTransactionResponseEventsGnoEventAttrsGnoEventAttribute includes the requested fields of the GraphQL type GnoEventAttribute. -// The GraphQL type's documentation follows. -// -// `GnoEventAttribute` is the attributes that the event has. -// It has `key` and `value`. -type GetValidationRequestsTransactionsTransactionResponseEventsGnoEventAttrsGnoEventAttribute struct { - // The key of the event attribute. - Key string `json:"key"` - // The value of the event attribute. - Value string `json:"value"` -} - -// GetKey returns GetValidationRequestsTransactionsTransactionResponseEventsGnoEventAttrsGnoEventAttribute.Key, and is useful for accessing the field via an interface. -func (v *GetValidationRequestsTransactionsTransactionResponseEventsGnoEventAttrsGnoEventAttribute) GetKey() string { - return v.Key -} - -// GetValue returns GetValidationRequestsTransactionsTransactionResponseEventsGnoEventAttrsGnoEventAttribute.Value, and is useful for accessing the field via an interface. -func (v *GetValidationRequestsTransactionsTransactionResponseEventsGnoEventAttrsGnoEventAttribute) GetValue() string { - return v.Value -} - -// GetValidationRequestsTransactionsTransactionResponseEventsUnknownEvent includes the requested fields of the GraphQL type UnknownEvent. -// The GraphQL type's documentation follows. -// -// `UnknownEvent` is an unknown event type. -// It has `value`. -type GetValidationRequestsTransactionsTransactionResponseEventsUnknownEvent struct { - Typename string `json:"__typename"` -} - -// GetTypename returns GetValidationRequestsTransactionsTransactionResponseEventsUnknownEvent.Typename, and is useful for accessing the field via an interface. -func (v *GetValidationRequestsTransactionsTransactionResponseEventsUnknownEvent) GetTypename() string { - return v.Typename -} - // __GetPostTransactionsInput is used internally by genqlient type __GetPostTransactionsInput struct { StartBlock int `json:"StartBlock"` @@ -711,14 +434,6 @@ func (v *__GetPostTransactionsInput) GetStartBlock() int { return v.StartBlock } // GetPkgPath returns __GetPostTransactionsInput.PkgPath, and is useful for accessing the field via an interface. func (v *__GetPostTransactionsInput) GetPkgPath() string { return v.PkgPath } -// __GetValidationRequestsInput is used internally by genqlient -type __GetValidationRequestsInput struct { - StartBlock int `json:"StartBlock"` -} - -// GetStartBlock returns __GetValidationRequestsInput.StartBlock, and is useful for accessing the field via an interface. -func (v *__GetValidationRequestsInput) GetStartBlock() int { return v.StartBlock } - func GetPostTransactions( ctx context.Context, client graphql.Client, @@ -729,7 +444,7 @@ func GetPostTransactions( OpName: "GetPostTransactions", Query: ` query GetPostTransactions ($StartBlock: Int!, $PkgPath: String!) { - transactions(filter: {success:true,messages:{vm_param:{exec:{func:"CreatePost",pkg_path:$PkgPath}}},from_block_height:$StartBlock}) { + transactions(filter: {success:true,message:{vm_param:{exec:{func:"CreatePost",pkg_path:$PkgPath}}},from_block_height:$StartBlock}) { index hash success @@ -776,51 +491,4 @@ query GetPostTransactions ($StartBlock: Int!, $PkgPath: String!) { ) return &data, err -} - -func GetValidationRequests( - ctx context.Context, - client graphql.Client, - StartBlock int, -) (*GetValidationRequestsResponse, error) { - req := &graphql.Request{ - OpName: "GetValidationRequests", - Query: ` -query GetValidationRequests ($StartBlock: Int!) { - transactions(filter: {events:{type:"verification_requested",pkg_path:"gno.land/r/teritori/ghverify"},from_block_height:$StartBlock}) { - success - block_height - response { - events { - __typename - ... on GnoEvent { - type - pkg_path - func - attrs { - key - value - } - } - } - } - } -} -`, - Variables: &__GetValidationRequestsInput{ - StartBlock: StartBlock, - }, - } - var err error - - var data GetValidationRequestsResponse - resp := &graphql.Response{Data: &data} - - err = client.MakeRequest( - ctx, - req, - resp, - ) - - return &data, err -} +} \ No newline at end of file diff --git a/go/pkg/gnoindexerql/indexer-operations.graphql b/go/pkg/gnoindexerql/indexer-operations.graphql index 0d434fc288..8957241491 100644 --- a/go/pkg/gnoindexerql/indexer-operations.graphql +++ b/go/pkg/gnoindexerql/indexer-operations.graphql @@ -2,7 +2,7 @@ query GetPostTransactions($StartBlock: Int!, $PkgPath: String!) { transactions( filter: { success: true - messages: { + message: { vm_param: { exec: { func: "CreatePost", pkg_path: $PkgPath } } } from_block_height: $StartBlock @@ -34,31 +34,4 @@ query GetPostTransactions($StartBlock: Int!, $PkgPath: String!) { log } } -} - -query GetValidationRequests( - $StartBlock: Int! -) { -transactions( - filter: { - events: {type:"verification_requested", pkg_path:"gno.land/r/teritori/ghverify"}, - from_block_height: $StartBlock - } -){ - success - block_height - response { - events { - ... on GnoEvent { - type - pkg_path - func - attrs { - key - value - } - } - } - } - } -} +} \ No newline at end of file