From 117a336bc381bbb49908e1568d12ae021da8899d Mon Sep 17 00:00:00 2001 From: Aleksandr Kukharenko Date: Wed, 10 Apr 2024 13:38:33 +0300 Subject: [PATCH 01/21] feat: MOR RPC base --- proxy-router/internal/morroc/mor_rpc.go | 265 +++++++++++++++++++ proxy-router/internal/morroc/mor_rpc_test.go | 71 +++++ 2 files changed, 336 insertions(+) create mode 100644 proxy-router/internal/morroc/mor_rpc.go create mode 100644 proxy-router/internal/morroc/mor_rpc_test.go diff --git a/proxy-router/internal/morroc/mor_rpc.go b/proxy-router/internal/morroc/mor_rpc.go new file mode 100644 index 00000000..eeded2e0 --- /dev/null +++ b/proxy-router/internal/morroc/mor_rpc.go @@ -0,0 +1,265 @@ +package morrpc + +import ( + "encoding/json" + "fmt" + "sort" + "time" + + "github.com/ethereum/go-ethereum/crypto" +) + +type RpcMessage struct { + Method string `json:"method"` + Params map[string]interface{} `json:"params"` +} + +// SessionReport represents the detailed session report +type SessionReport struct { + SessionID string `json:"sessionid"` + Start uint `json:"start"` + End uint `json:"end"` + Prompts uint `json:"prompts"` + Tokens uint `json:"tokens"` + Reqs []ReqObject `json:"reqs"` +} + +// ReqObject represents a request object within a session report +type ReqObject struct { + Req uint `json:"req"` + Res uint `json:"res"` + Toks uint `json:"toks"` +} + +type MorRpc struct{} + +func NewMorRpc() *MorRpc { + return &MorRpc{} +} + +// Provider Node Communication + +func (m *MorRpc) InitiateSessionResponse(providerPubKey string, userAddr string, providerPrivateKeyHex string) (RpcMessage, error) { + method := "response.success" + timestamp := m.generateTimestamp() + params := map[string]interface{}{ + "message": providerPubKey, + "timestamp": timestamp, + } + + signature, err := m.generateSignature(params, providerPrivateKeyHex) + if err != nil { + return RpcMessage{}, err + } + params["signature"] = signature + return RpcMessage{ + Method: method, + Params: params, + }, nil +} + +func (m *MorRpc) SessionPromptResponse(message string, providerPrivateKeyHex string) (RpcMessage, error) { + method := "response.inference" + timestamp := m.generateTimestamp() + params := map[string]interface{}{ + "message": message, + "timestamp": timestamp, + } + + signature, err := m.generateSignature(params, providerPrivateKeyHex) + if err != nil { + return RpcMessage{}, err + } + params["signature"] = signature + return RpcMessage{ + Method: method, + Params: params, + }, nil +} + +func (m *MorRpc) ResponseError(message string, privateKeyHex string) (RpcMessage, error) { + method := "response.error" + timestamp := m.generateTimestamp() + params := map[string]interface{}{ + "message": message, + "timestamp": timestamp, + } + + signature, err := m.generateSignature(params, privateKeyHex) + if err != nil { + return RpcMessage{}, err + } + params["signature"] = signature + return RpcMessage{ + Method: method, + Params: params, + }, nil +} + +func (m *MorRpc) AuthError(privateKeyHex string) (RpcMessage, error) { + return m.ResponseError("Failed to authenticate signature.", privateKeyHex) +} + +func (m *MorRpc) OutOfCapacityError(privateKeyHex string) (RpcMessage, error) { + return m.ResponseError("Provider at capacity", privateKeyHex) +} + +func (m *MorRpc) SessionClosedError(privateKeyHex string) (RpcMessage, error) { + return m.ResponseError("Session is closed.", privateKeyHex) +} + +func (m *MorRpc) SpendLimitError(privateKeyHex string) (RpcMessage, error) { + return m.ResponseError("Over spend limit.", privateKeyHex) +} + +// Session Report + +func (m *MorRpc) SessionReport(sessionID string, start uint, end uint, prompts uint, tokens uint, reqs []ReqObject, providerPrivateKeyHex string) (RpcMessage, error) { + method := "session.report" + + report := m.generateReport(sessionID, start, end, prompts, tokens, reqs) + reportJson, err := json.Marshal(report) + if err != nil { + return m.ResponseError("Failed to generate report.", providerPrivateKeyHex) + } + reportStr := string(reportJson) + + timestamp := m.generateTimestamp() + params := map[string]interface{}{ + "message": reportStr, + "timestamp": timestamp, + } + signature, err := m.generateSignature(params, providerPrivateKeyHex) + if err != nil { + return RpcMessage{}, err + } + params["signature"] = signature + return RpcMessage{ + Method: method, + Params: params, + }, nil +} + +func (m *MorRpc) generateReport(sessionID string, start uint, end uint, prompts uint, tokens uint, reqs []ReqObject) SessionReport { + return SessionReport{ + SessionID: sessionID, + Start: start, + End: end, + Prompts: prompts, + Tokens: tokens, + Reqs: reqs, + } +} + +// User Node Communication + +func (m *MorRpc) InitiateSessionRequest(user string, provider string, userPubKey string, spend float64, userPrivateKeyHex string) (RpcMessage, error) { + method := "session.request" + timestamp := m.generateTimestamp() + params := map[string]interface{}{ + "timestamp": timestamp, + "user": user, + "provider": provider, + "key": userPubKey, + "spend": fmt.Sprintf("%f", spend), + } + + signature, err := m.generateSignature(params, userPrivateKeyHex) + if err != nil { + return RpcMessage{}, err + } + params["signature"] = signature + return RpcMessage{ + Method: method, + Params: params, + }, nil +} + +func (m *MorRpc) SessionPromptRequest(sessionID string, prompt string, providerPubKey string, userPrivateKeyHex string) (RpcMessage, error) { + method := "session.prompt" + timestamp := m.generateTimestamp() + params := map[string]interface{}{ + "message": prompt, + "sessionid": sessionID, + "timestamp": timestamp, + } + signature, err := m.generateSignature(params, userPrivateKeyHex) + if err != nil { + return RpcMessage{}, err + } + params["signature"] = signature + return RpcMessage{ + Method: method, + Params: params, + }, nil +} + +func (m *MorRpc) SessionCloseRequest(sessionID string, userPrivateKeyHex string) (RpcMessage, error) { + method := "session.close" + timestamp := m.generateTimestamp() + params := map[string]interface{}{ + "sessionid": sessionID, + "timestamp": timestamp, + } + signature, err := m.generateSignature(params, userPrivateKeyHex) + if err != nil { + return RpcMessage{}, err + } + params["signature"] = signature + return RpcMessage{ + Method: method, + Params: params, + }, nil +} + +func (m *MorRpc) generateTimestamp() int { + now := time.Now() + return now.Nanosecond() +} + +// https://goethereumbook.org/signature-generate/ +func (m *MorRpc) generateSignature(params map[string]interface{}, privateKeyHex string) (string, error) { + result := "" + + keys := make([]string, 0) + for k, _ := range params { + keys = append(keys, k) + } + sort.Strings(keys) + + // Concatenate the parameters in the order of the sorted keys + for _, k := range keys { + result += fmt.Sprintf("%s:%v", k, params[k]) + } + + privateKey, err := crypto.HexToECDSA(privateKeyHex) + if err != nil { + return "", err + } + hash := crypto.Keccak256Hash([]byte(result)) + signature, err := crypto.Sign(hash.Bytes(), privateKey) + if err != nil { + return "", err + } + return string(signature), nil +} + +// https://goethereumbook.org/signature-verify/ +func (m *MorRpc) VerifySignature(params map[string]interface{}, signature string, publicKeyBytes []byte) bool { + result := "" + + keys := make([]string, 0) + for k, _ := range params { + keys = append(keys, k) + } + sort.Strings(keys) + + // Concatenate the parameters in the order of the sorted keys + for _, k := range keys { + result += fmt.Sprintf("%s:%v", k, params[k]) + } + + hash := crypto.Keccak256Hash([]byte(result)) + signatureNoRecoverID := signature[:len(signature)-1] // remove recovery ID + return crypto.VerifySignature(publicKeyBytes, hash.Bytes(), []byte(signatureNoRecoverID)) +} diff --git a/proxy-router/internal/morroc/mor_rpc_test.go b/proxy-router/internal/morroc/mor_rpc_test.go new file mode 100644 index 00000000..c8cebfa7 --- /dev/null +++ b/proxy-router/internal/morroc/mor_rpc_test.go @@ -0,0 +1,71 @@ +package morrpc + +import ( + "encoding/hex" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestMorRpc_generateSignature(t *testing.T) { + m := NewMorRpc() + + params := map[string]interface{}{ + "param1": "value1", + "param2": "value2", + "param3": "value3", + } + + privateKeyHex := "3ceb688d9b87c1a468a7eadde744828ec8bb2d11c9ea52a179058e47f92f25ee" + + signature, err := m.generateSignature(params, privateKeyHex) + assert.NoError(t, err) + assert.NotEmpty(t, signature) +} + +func TestMorRpc_verifySignature(t *testing.T) { + m := NewMorRpc() + + params := map[string]interface{}{ + "param1": "value1", + "param2": "value2", + "param3": "value3", + } + + privateKeyHex := "81f44a49c40f206517efbbcca783d808914841200e0ac9a769368e1b2741e227" + publicKey := "033e5e77f12aa67e52484ce64b64737d397098e78d54beba15a0bf6dcfdd5ae7e2" + + signature, err := m.generateSignature(params, privateKeyHex) + assert.NoError(t, err) + assert.NotEmpty(t, signature) + + publicKeyBytes, err := hex.DecodeString(publicKey) + assert.NoError(t, err) + + isValid := m.VerifySignature(params, signature, publicKeyBytes) + assert.True(t, isValid) +} + +func TestMorRpc_verifySignature_incorrect_params(t *testing.T) { + m := NewMorRpc() + + params := map[string]interface{}{ + "param1": "value1", + "param2": "value2", + "param3": "value3", + } + + privateKeyHex := "81f44a49c40f206517efbbcca783d808914841200e0ac9a769368e1b2741e227" + publicKey := "033e5e77f12aa67e52484ce64b64737d397098e78d54beba15a0bf6dcfdd5ae7e2" + + signature, err := m.generateSignature(params, privateKeyHex) + assert.NoError(t, err) + assert.NotEmpty(t, signature) + + publicKeyBytes, err := hex.DecodeString(publicKey) + assert.NoError(t, err) + + params["param3"] = "unknown value" + isValid := m.VerifySignature(params, signature, publicKeyBytes) + assert.False(t, isValid) +} From b61ea52a1df76515ede8b8974998da7c24fc290a Mon Sep 17 00:00:00 2001 From: Aleksandr Kukharenko Date: Wed, 10 Apr 2024 14:34:33 +0300 Subject: [PATCH 02/21] fix: timestamp in unix --- proxy-router/internal/morroc/mor_rpc.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proxy-router/internal/morroc/mor_rpc.go b/proxy-router/internal/morroc/mor_rpc.go index eeded2e0..41fde6c4 100644 --- a/proxy-router/internal/morroc/mor_rpc.go +++ b/proxy-router/internal/morroc/mor_rpc.go @@ -212,9 +212,9 @@ func (m *MorRpc) SessionCloseRequest(sessionID string, userPrivateKeyHex string) }, nil } -func (m *MorRpc) generateTimestamp() int { +func (m *MorRpc) generateTimestamp() int64 { now := time.Now() - return now.Nanosecond() + return now.UnixMilli() } // https://goethereumbook.org/signature-generate/ From 03cfeb7cef8f26adbc22228d965f1bda72b1324d Mon Sep 17 00:00:00 2001 From: Aleksandr Kukharenko Date: Wed, 10 Apr 2024 14:49:55 +0300 Subject: [PATCH 03/21] improve signature generation --- proxy-router/internal/morroc/mor_rpc.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/proxy-router/internal/morroc/mor_rpc.go b/proxy-router/internal/morroc/mor_rpc.go index 41fde6c4..ef486a52 100644 --- a/proxy-router/internal/morroc/mor_rpc.go +++ b/proxy-router/internal/morroc/mor_rpc.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "sort" + "strings" "time" "github.com/ethereum/go-ethereum/crypto" @@ -219,7 +220,7 @@ func (m *MorRpc) generateTimestamp() int64 { // https://goethereumbook.org/signature-generate/ func (m *MorRpc) generateSignature(params map[string]interface{}, privateKeyHex string) (string, error) { - result := "" + resultStr := "" keys := make([]string, 0) for k, _ := range params { @@ -228,15 +229,17 @@ func (m *MorRpc) generateSignature(params map[string]interface{}, privateKeyHex sort.Strings(keys) // Concatenate the parameters in the order of the sorted keys + key_values := make([]string, 0) for _, k := range keys { - result += fmt.Sprintf("%s:%v", k, params[k]) + key_values = append(key_values, fmt.Sprintf("%s=%v", k, params[k])) } + resultStr = strings.Join(key_values, "&") privateKey, err := crypto.HexToECDSA(privateKeyHex) if err != nil { return "", err } - hash := crypto.Keccak256Hash([]byte(result)) + hash := crypto.Keccak256Hash([]byte(resultStr)) signature, err := crypto.Sign(hash.Bytes(), privateKey) if err != nil { return "", err From 7eb65e1e8edf9f9fb8f8277d81e276dc54130714 Mon Sep 17 00:00:00 2001 From: Aleksandr Kukharenko Date: Thu, 11 Apr 2024 16:49:40 +0300 Subject: [PATCH 04/21] feat: json-rpc compatible --- .../internal/{morroc => morrpc}/mor_rpc.go | 126 +++++++++--------- .../{morroc => morrpc}/mor_rpc_test.go | 8 +- 2 files changed, 68 insertions(+), 66 deletions(-) rename proxy-router/internal/{morroc => morrpc}/mor_rpc.go (68%) rename proxy-router/internal/{morroc => morrpc}/mor_rpc_test.go (87%) diff --git a/proxy-router/internal/morroc/mor_rpc.go b/proxy-router/internal/morrpc/mor_rpc.go similarity index 68% rename from proxy-router/internal/morroc/mor_rpc.go rename to proxy-router/internal/morrpc/mor_rpc.go index ef486a52..acd80b68 100644 --- a/proxy-router/internal/morroc/mor_rpc.go +++ b/proxy-router/internal/morrpc/mor_rpc.go @@ -3,18 +3,29 @@ package morrpc import ( "encoding/json" "fmt" - "sort" - "strings" "time" "github.com/ethereum/go-ethereum/crypto" ) +type RpcError struct { + Message string `json:"message"` + Data string `json:"data"` + Code int `json:"code"` +} + type RpcMessage struct { + ID string `json:"id"` Method string `json:"method"` Params map[string]interface{} `json:"params"` } +type RpcResponse struct { + ID string `json:"id"` + Result map[string]interface{} `json:"result"` + Error RpcError `json:"error"` +} + // SessionReport represents the detailed session report type SessionReport struct { SessionID string `json:"sessionid"` @@ -40,27 +51,26 @@ func NewMorRpc() *MorRpc { // Provider Node Communication -func (m *MorRpc) InitiateSessionResponse(providerPubKey string, userAddr string, providerPrivateKeyHex string) (RpcMessage, error) { - method := "response.success" +func (m *MorRpc) InitiateSessionResponse(providerPubKey string, userAddr string, providerPrivateKeyHex string, requestId string) (RpcResponse, error) { timestamp := m.generateTimestamp() params := map[string]interface{}{ "message": providerPubKey, + "user": userAddr, "timestamp": timestamp, } signature, err := m.generateSignature(params, providerPrivateKeyHex) if err != nil { - return RpcMessage{}, err + return RpcResponse{}, err } params["signature"] = signature - return RpcMessage{ - Method: method, - Params: params, + return RpcResponse{ + ID: requestId, + Result: params, }, nil } -func (m *MorRpc) SessionPromptResponse(message string, providerPrivateKeyHex string) (RpcMessage, error) { - method := "response.inference" +func (m *MorRpc) SessionPromptResponse(message string, providerPrivateKeyHex string, requestId string) (RpcResponse, error) { timestamp := m.generateTimestamp() params := map[string]interface{}{ "message": message, @@ -69,17 +79,16 @@ func (m *MorRpc) SessionPromptResponse(message string, providerPrivateKeyHex str signature, err := m.generateSignature(params, providerPrivateKeyHex) if err != nil { - return RpcMessage{}, err + return RpcResponse{}, err } params["signature"] = signature - return RpcMessage{ - Method: method, - Params: params, + return RpcResponse{ + ID: requestId, + Result: params, }, nil } -func (m *MorRpc) ResponseError(message string, privateKeyHex string) (RpcMessage, error) { - method := "response.error" +func (m *MorRpc) ResponseError(message string, privateKeyHex string, requestId string) (RpcResponse, error) { timestamp := m.generateTimestamp() params := map[string]interface{}{ "message": message, @@ -88,40 +97,38 @@ func (m *MorRpc) ResponseError(message string, privateKeyHex string) (RpcMessage signature, err := m.generateSignature(params, privateKeyHex) if err != nil { - return RpcMessage{}, err + return RpcResponse{}, err } params["signature"] = signature - return RpcMessage{ - Method: method, - Params: params, + return RpcResponse{ + ID: requestId, + Error: RpcError{Message: message, Data: "", Code: 400}, }, nil } -func (m *MorRpc) AuthError(privateKeyHex string) (RpcMessage, error) { - return m.ResponseError("Failed to authenticate signature.", privateKeyHex) +func (m *MorRpc) AuthError(privateKeyHex string, requestId string) (RpcResponse, error) { + return m.ResponseError("Failed to authenticate signature.", privateKeyHex, requestId) } -func (m *MorRpc) OutOfCapacityError(privateKeyHex string) (RpcMessage, error) { - return m.ResponseError("Provider at capacity", privateKeyHex) +func (m *MorRpc) OutOfCapacityError(privateKeyHex string, requestId string) (RpcResponse, error) { + return m.ResponseError("Provider at capacity", privateKeyHex, requestId) } -func (m *MorRpc) SessionClosedError(privateKeyHex string) (RpcMessage, error) { - return m.ResponseError("Session is closed.", privateKeyHex) +func (m *MorRpc) SessionClosedError(privateKeyHex string, requestId string) (RpcResponse, error) { + return m.ResponseError("Session is closed.", privateKeyHex, requestId) } -func (m *MorRpc) SpendLimitError(privateKeyHex string) (RpcMessage, error) { - return m.ResponseError("Over spend limit.", privateKeyHex) +func (m *MorRpc) SpendLimitError(privateKeyHex string, requestId string) (RpcResponse, error) { + return m.ResponseError("Over spend limit.", privateKeyHex, requestId) } // Session Report -func (m *MorRpc) SessionReport(sessionID string, start uint, end uint, prompts uint, tokens uint, reqs []ReqObject, providerPrivateKeyHex string) (RpcMessage, error) { - method := "session.report" - +func (m *MorRpc) SessionReport(sessionID string, start uint, end uint, prompts uint, tokens uint, reqs []ReqObject, providerPrivateKeyHex string, requestId string) (RpcResponse, error) { report := m.generateReport(sessionID, start, end, prompts, tokens, reqs) reportJson, err := json.Marshal(report) if err != nil { - return m.ResponseError("Failed to generate report.", providerPrivateKeyHex) + return m.ResponseError("Failed to generate report.", providerPrivateKeyHex, requestId) } reportStr := string(reportJson) @@ -132,12 +139,12 @@ func (m *MorRpc) SessionReport(sessionID string, start uint, end uint, prompts u } signature, err := m.generateSignature(params, providerPrivateKeyHex) if err != nil { - return RpcMessage{}, err + return RpcResponse{}, err } params["signature"] = signature - return RpcMessage{ - Method: method, - Params: params, + return RpcResponse{ + ID: requestId, + Result: params, }, nil } @@ -154,7 +161,7 @@ func (m *MorRpc) generateReport(sessionID string, start uint, end uint, prompts // User Node Communication -func (m *MorRpc) InitiateSessionRequest(user string, provider string, userPubKey string, spend float64, userPrivateKeyHex string) (RpcMessage, error) { +func (m *MorRpc) InitiateSessionRequest(user string, provider string, userPubKey string, spend float64, userPrivateKeyHex string, requestId string) (RpcMessage, error) { method := "session.request" timestamp := m.generateTimestamp() params := map[string]interface{}{ @@ -171,12 +178,13 @@ func (m *MorRpc) InitiateSessionRequest(user string, provider string, userPubKey } params["signature"] = signature return RpcMessage{ + ID: requestId, Method: method, Params: params, }, nil } -func (m *MorRpc) SessionPromptRequest(sessionID string, prompt string, providerPubKey string, userPrivateKeyHex string) (RpcMessage, error) { +func (m *MorRpc) SessionPromptRequest(sessionID string, prompt string, providerPubKey string, userPrivateKeyHex string, requestId string) (RpcMessage, error) { method := "session.prompt" timestamp := m.generateTimestamp() params := map[string]interface{}{ @@ -190,12 +198,13 @@ func (m *MorRpc) SessionPromptRequest(sessionID string, prompt string, providerP } params["signature"] = signature return RpcMessage{ + ID: requestId, Method: method, Params: params, }, nil } -func (m *MorRpc) SessionCloseRequest(sessionID string, userPrivateKeyHex string) (RpcMessage, error) { +func (m *MorRpc) SessionCloseRequest(sessionID string, userPrivateKeyHex string, requestId string) (RpcMessage, error) { method := "session.close" timestamp := m.generateTimestamp() params := map[string]interface{}{ @@ -208,6 +217,7 @@ func (m *MorRpc) SessionCloseRequest(sessionID string, userPrivateKeyHex string) } params["signature"] = signature return RpcMessage{ + ID: requestId, Method: method, Params: params, }, nil @@ -220,21 +230,10 @@ func (m *MorRpc) generateTimestamp() int64 { // https://goethereumbook.org/signature-generate/ func (m *MorRpc) generateSignature(params map[string]interface{}, privateKeyHex string) (string, error) { - resultStr := "" - - keys := make([]string, 0) - for k, _ := range params { - keys = append(keys, k) - } - sort.Strings(keys) - - // Concatenate the parameters in the order of the sorted keys - key_values := make([]string, 0) - for _, k := range keys { - key_values = append(key_values, fmt.Sprintf("%s=%v", k, params[k])) + resultStr, err := json.Marshal(params) + if err != nil { + return "", err } - resultStr = strings.Join(key_values, "&") - privateKey, err := crypto.HexToECDSA(privateKeyHex) if err != nil { return "", err @@ -248,21 +247,20 @@ func (m *MorRpc) generateSignature(params map[string]interface{}, privateKeyHex } // https://goethereumbook.org/signature-verify/ -func (m *MorRpc) VerifySignature(params map[string]interface{}, signature string, publicKeyBytes []byte) bool { - result := "" - - keys := make([]string, 0) - for k, _ := range params { - keys = append(keys, k) +func (m *MorRpc) VerifySignature(params []byte, signature string, publicKeyBytes []byte) bool { + var jsonParams map[string]interface{} + err := json.Unmarshal([]byte(params), &jsonParams) + if err != nil { + return false } - sort.Strings(keys) + delete(jsonParams, "signature") - // Concatenate the parameters in the order of the sorted keys - for _, k := range keys { - result += fmt.Sprintf("%s:%v", k, params[k]) + resultStr, err := json.Marshal(jsonParams) + if err != nil { + return false } - hash := crypto.Keccak256Hash([]byte(result)) + hash := crypto.Keccak256Hash([]byte(resultStr)) signatureNoRecoverID := signature[:len(signature)-1] // remove recovery ID return crypto.VerifySignature(publicKeyBytes, hash.Bytes(), []byte(signatureNoRecoverID)) } diff --git a/proxy-router/internal/morroc/mor_rpc_test.go b/proxy-router/internal/morrpc/mor_rpc_test.go similarity index 87% rename from proxy-router/internal/morroc/mor_rpc_test.go rename to proxy-router/internal/morrpc/mor_rpc_test.go index c8cebfa7..0a0cdcfc 100644 --- a/proxy-router/internal/morroc/mor_rpc_test.go +++ b/proxy-router/internal/morrpc/mor_rpc_test.go @@ -2,6 +2,7 @@ package morrpc import ( "encoding/hex" + "encoding/json" "testing" "github.com/stretchr/testify/assert" @@ -42,7 +43,9 @@ func TestMorRpc_verifySignature(t *testing.T) { publicKeyBytes, err := hex.DecodeString(publicKey) assert.NoError(t, err) - isValid := m.VerifySignature(params, signature, publicKeyBytes) + paramsBytes, err := json.Marshal(params) + + isValid := m.VerifySignature(paramsBytes, signature, publicKeyBytes) assert.True(t, isValid) } @@ -66,6 +69,7 @@ func TestMorRpc_verifySignature_incorrect_params(t *testing.T) { assert.NoError(t, err) params["param3"] = "unknown value" - isValid := m.VerifySignature(params, signature, publicKeyBytes) + paramsBytes, err := json.Marshal(params) + isValid := m.VerifySignature(paramsBytes, signature, publicKeyBytes) assert.False(t, isValid) } From 90c63f3405b12760f4c52489e9c671a5463ee941 Mon Sep 17 00:00:00 2001 From: alex-sandrk <113540941+alex-sandrk@users.noreply.github.com> Date: Thu, 11 Apr 2024 18:19:26 +0300 Subject: [PATCH 05/21] Update proxy-router/internal/morrpc/mor_rpc.go Co-authored-by: lsheva --- proxy-router/internal/morrpc/mor_rpc.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proxy-router/internal/morrpc/mor_rpc.go b/proxy-router/internal/morrpc/mor_rpc.go index acd80b68..d347a8af 100644 --- a/proxy-router/internal/morrpc/mor_rpc.go +++ b/proxy-router/internal/morrpc/mor_rpc.go @@ -107,7 +107,7 @@ func (m *MorRpc) ResponseError(message string, privateKeyHex string, requestId s } func (m *MorRpc) AuthError(privateKeyHex string, requestId string) (RpcResponse, error) { - return m.ResponseError("Failed to authenticate signature.", privateKeyHex, requestId) + return m.ResponseError("Failed to authenticate signature", privateKeyHex, requestId) } func (m *MorRpc) OutOfCapacityError(privateKeyHex string, requestId string) (RpcResponse, error) { From dcf87cf29e261c2371c872c9ca891afed679dc8e Mon Sep 17 00:00:00 2001 From: Aleksandr Kukharenko Date: Thu, 11 Apr 2024 18:21:13 +0300 Subject: [PATCH 06/21] remove dots from error messages --- proxy-router/internal/morrpc/mor_rpc.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/proxy-router/internal/morrpc/mor_rpc.go b/proxy-router/internal/morrpc/mor_rpc.go index d347a8af..a9b18c43 100644 --- a/proxy-router/internal/morrpc/mor_rpc.go +++ b/proxy-router/internal/morrpc/mor_rpc.go @@ -115,11 +115,11 @@ func (m *MorRpc) OutOfCapacityError(privateKeyHex string, requestId string) (Rpc } func (m *MorRpc) SessionClosedError(privateKeyHex string, requestId string) (RpcResponse, error) { - return m.ResponseError("Session is closed.", privateKeyHex, requestId) + return m.ResponseError("Session is closed", privateKeyHex, requestId) } func (m *MorRpc) SpendLimitError(privateKeyHex string, requestId string) (RpcResponse, error) { - return m.ResponseError("Over spend limit.", privateKeyHex, requestId) + return m.ResponseError("Over spend limit", privateKeyHex, requestId) } // Session Report @@ -128,7 +128,7 @@ func (m *MorRpc) SessionReport(sessionID string, start uint, end uint, prompts u report := m.generateReport(sessionID, start, end, prompts, tokens, reqs) reportJson, err := json.Marshal(report) if err != nil { - return m.ResponseError("Failed to generate report.", providerPrivateKeyHex, requestId) + return m.ResponseError("Failed to generate report", providerPrivateKeyHex, requestId) } reportStr := string(reportJson) From dc8ad813ed634dc4a71bc4c00cff242a7f4c0119 Mon Sep 17 00:00:00 2001 From: Aleksandr Kukharenko Date: Thu, 11 Apr 2024 18:23:15 +0300 Subject: [PATCH 07/21] return pointers to structs --- proxy-router/internal/morrpc/mor_rpc.go | 54 ++++++++++++------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/proxy-router/internal/morrpc/mor_rpc.go b/proxy-router/internal/morrpc/mor_rpc.go index a9b18c43..bcc76587 100644 --- a/proxy-router/internal/morrpc/mor_rpc.go +++ b/proxy-router/internal/morrpc/mor_rpc.go @@ -51,7 +51,7 @@ func NewMorRpc() *MorRpc { // Provider Node Communication -func (m *MorRpc) InitiateSessionResponse(providerPubKey string, userAddr string, providerPrivateKeyHex string, requestId string) (RpcResponse, error) { +func (m *MorRpc) InitiateSessionResponse(providerPubKey string, userAddr string, providerPrivateKeyHex string, requestId string) (*RpcResponse, error) { timestamp := m.generateTimestamp() params := map[string]interface{}{ "message": providerPubKey, @@ -61,16 +61,16 @@ func (m *MorRpc) InitiateSessionResponse(providerPubKey string, userAddr string, signature, err := m.generateSignature(params, providerPrivateKeyHex) if err != nil { - return RpcResponse{}, err + return &RpcResponse{}, err } params["signature"] = signature - return RpcResponse{ + return &RpcResponse{ ID: requestId, Result: params, }, nil } -func (m *MorRpc) SessionPromptResponse(message string, providerPrivateKeyHex string, requestId string) (RpcResponse, error) { +func (m *MorRpc) SessionPromptResponse(message string, providerPrivateKeyHex string, requestId string) (*RpcResponse, error) { timestamp := m.generateTimestamp() params := map[string]interface{}{ "message": message, @@ -79,16 +79,16 @@ func (m *MorRpc) SessionPromptResponse(message string, providerPrivateKeyHex str signature, err := m.generateSignature(params, providerPrivateKeyHex) if err != nil { - return RpcResponse{}, err + return &RpcResponse{}, err } params["signature"] = signature - return RpcResponse{ + return &RpcResponse{ ID: requestId, Result: params, }, nil } -func (m *MorRpc) ResponseError(message string, privateKeyHex string, requestId string) (RpcResponse, error) { +func (m *MorRpc) ResponseError(message string, privateKeyHex string, requestId string) (*RpcResponse, error) { timestamp := m.generateTimestamp() params := map[string]interface{}{ "message": message, @@ -97,34 +97,34 @@ func (m *MorRpc) ResponseError(message string, privateKeyHex string, requestId s signature, err := m.generateSignature(params, privateKeyHex) if err != nil { - return RpcResponse{}, err + return &RpcResponse{}, err } params["signature"] = signature - return RpcResponse{ + return &RpcResponse{ ID: requestId, Error: RpcError{Message: message, Data: "", Code: 400}, }, nil } -func (m *MorRpc) AuthError(privateKeyHex string, requestId string) (RpcResponse, error) { +func (m *MorRpc) AuthError(privateKeyHex string, requestId string) (*RpcResponse, error) { return m.ResponseError("Failed to authenticate signature", privateKeyHex, requestId) } -func (m *MorRpc) OutOfCapacityError(privateKeyHex string, requestId string) (RpcResponse, error) { +func (m *MorRpc) OutOfCapacityError(privateKeyHex string, requestId string) (*RpcResponse, error) { return m.ResponseError("Provider at capacity", privateKeyHex, requestId) } -func (m *MorRpc) SessionClosedError(privateKeyHex string, requestId string) (RpcResponse, error) { +func (m *MorRpc) SessionClosedError(privateKeyHex string, requestId string) (*RpcResponse, error) { return m.ResponseError("Session is closed", privateKeyHex, requestId) } -func (m *MorRpc) SpendLimitError(privateKeyHex string, requestId string) (RpcResponse, error) { +func (m *MorRpc) SpendLimitError(privateKeyHex string, requestId string) (*RpcResponse, error) { return m.ResponseError("Over spend limit", privateKeyHex, requestId) } // Session Report -func (m *MorRpc) SessionReport(sessionID string, start uint, end uint, prompts uint, tokens uint, reqs []ReqObject, providerPrivateKeyHex string, requestId string) (RpcResponse, error) { +func (m *MorRpc) SessionReport(sessionID string, start uint, end uint, prompts uint, tokens uint, reqs []ReqObject, providerPrivateKeyHex string, requestId string) (*RpcResponse, error) { report := m.generateReport(sessionID, start, end, prompts, tokens, reqs) reportJson, err := json.Marshal(report) if err != nil { @@ -139,17 +139,17 @@ func (m *MorRpc) SessionReport(sessionID string, start uint, end uint, prompts u } signature, err := m.generateSignature(params, providerPrivateKeyHex) if err != nil { - return RpcResponse{}, err + return &RpcResponse{}, err } params["signature"] = signature - return RpcResponse{ + return &RpcResponse{ ID: requestId, Result: params, }, nil } -func (m *MorRpc) generateReport(sessionID string, start uint, end uint, prompts uint, tokens uint, reqs []ReqObject) SessionReport { - return SessionReport{ +func (m *MorRpc) generateReport(sessionID string, start uint, end uint, prompts uint, tokens uint, reqs []ReqObject) *SessionReport { + return &SessionReport{ SessionID: sessionID, Start: start, End: end, @@ -161,7 +161,7 @@ func (m *MorRpc) generateReport(sessionID string, start uint, end uint, prompts // User Node Communication -func (m *MorRpc) InitiateSessionRequest(user string, provider string, userPubKey string, spend float64, userPrivateKeyHex string, requestId string) (RpcMessage, error) { +func (m *MorRpc) InitiateSessionRequest(user string, provider string, userPubKey string, spend float64, userPrivateKeyHex string, requestId string) (*RpcMessage, error) { method := "session.request" timestamp := m.generateTimestamp() params := map[string]interface{}{ @@ -174,17 +174,17 @@ func (m *MorRpc) InitiateSessionRequest(user string, provider string, userPubKey signature, err := m.generateSignature(params, userPrivateKeyHex) if err != nil { - return RpcMessage{}, err + return &RpcMessage{}, err } params["signature"] = signature - return RpcMessage{ + return &RpcMessage{ ID: requestId, Method: method, Params: params, }, nil } -func (m *MorRpc) SessionPromptRequest(sessionID string, prompt string, providerPubKey string, userPrivateKeyHex string, requestId string) (RpcMessage, error) { +func (m *MorRpc) SessionPromptRequest(sessionID string, prompt string, providerPubKey string, userPrivateKeyHex string, requestId string) (*RpcMessage, error) { method := "session.prompt" timestamp := m.generateTimestamp() params := map[string]interface{}{ @@ -194,17 +194,17 @@ func (m *MorRpc) SessionPromptRequest(sessionID string, prompt string, providerP } signature, err := m.generateSignature(params, userPrivateKeyHex) if err != nil { - return RpcMessage{}, err + return &RpcMessage{}, err } params["signature"] = signature - return RpcMessage{ + return &RpcMessage{ ID: requestId, Method: method, Params: params, }, nil } -func (m *MorRpc) SessionCloseRequest(sessionID string, userPrivateKeyHex string, requestId string) (RpcMessage, error) { +func (m *MorRpc) SessionCloseRequest(sessionID string, userPrivateKeyHex string, requestId string) (*RpcMessage, error) { method := "session.close" timestamp := m.generateTimestamp() params := map[string]interface{}{ @@ -213,10 +213,10 @@ func (m *MorRpc) SessionCloseRequest(sessionID string, userPrivateKeyHex string, } signature, err := m.generateSignature(params, userPrivateKeyHex) if err != nil { - return RpcMessage{}, err + return &RpcMessage{}, err } params["signature"] = signature - return RpcMessage{ + return &RpcMessage{ ID: requestId, Method: method, Params: params, From 1b59873683284be709d1d11c81249d29f4672936 Mon Sep 17 00:00:00 2001 From: Aleksandr Kukharenko Date: Fri, 19 Apr 2024 14:48:15 +0300 Subject: [PATCH 08/21] feat: initiate session flow --- proxy-router/cmd/main.go | 11 ++- proxy-router/internal/apibus/api_bus.go | 4 + proxy-router/internal/constants.go | 4 + .../internal/handlers/httphandlers/http.go | 10 ++- .../handlers/tcphandlers/mor_rpc_handler.go | 74 +++++++++++++++ .../internal/handlers/tcphandlers/tcp.go | 39 +++++++- proxy-router/internal/lib/crypto.go | 15 ++++ proxy-router/internal/morrpc/mor_rpc.go | 31 ++++++- .../internal/proxyapi/proxy_router_api.go | 89 ++++++++++++++++++- 9 files changed, 263 insertions(+), 14 deletions(-) create mode 100644 proxy-router/internal/constants.go create mode 100644 proxy-router/internal/handlers/tcphandlers/mor_rpc_handler.go diff --git a/proxy-router/cmd/main.go b/proxy-router/cmd/main.go index 4f4db616..fbda41f8 100644 --- a/proxy-router/cmd/main.go +++ b/proxy-router/cmd/main.go @@ -17,6 +17,7 @@ import ( "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal/handlers/tcphandlers" "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal/interfaces" "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal/lib" + "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal/morrpc" "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal/proxyapi" "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal/repositories/transport" "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal/rpcproxy" @@ -184,13 +185,19 @@ func start() error { derived := new(config.DerivedConfig) derived.WalletAddress = walletAddr.String() + publicKey, err := lib.PubKeyStringFromPrivate(cfg.Marketplace.WalletPrivateKey) + if err != nil { + return err + } + tcpServer := transport.NewTCPServer(cfg.Proxy.Address, connLog.Named("TCP")) + morTcpHandler := tcphandlers.NewMorRpcHandler(cfg.Marketplace.WalletPrivateKey, publicKey, derived.WalletAddress, morrpc.NewMorRpc()) tcpHandler := tcphandlers.NewTCPHandler( - log, connLog, schedulerLogFactory, + log, connLog, schedulerLogFactory, morTcpHandler, ) tcpServer.SetConnectionHandler(tcpHandler) - proxyRouterApi := proxyapi.NewProxyRouterApi(sysConfig, publicUrl, cfg.Marketplace.WalletPrivateKey, &cfg, derived, time.Now(), contractLogStorage, log) + proxyRouterApi := proxyapi.NewProxyRouterApi(sysConfig, publicUrl, publicKey, cfg.Marketplace.WalletPrivateKey, &cfg, derived, time.Now(), contractLogStorage, log) rpcProxy := rpcproxy.NewRpcProxy(ethClient) aiEngine := aiengine.NewAiEngine() apiBus := apibus.NewApiBus(rpcProxy, aiEngine, proxyRouterApi) diff --git a/proxy-router/internal/apibus/api_bus.go b/proxy-router/internal/apibus/api_bus.go index fbb20dd5..c99ab180 100644 --- a/proxy-router/internal/apibus/api_bus.go +++ b/proxy-router/internal/apibus/api_bus.go @@ -36,6 +36,10 @@ func (apiBus *ApiBus) HealthCheck(ctx context.Context) interface{} { return apiBus.proxyRouterApi.HealthCheck(ctx) } +func (apiBus *ApiBus) InitiateSession(ctx *gin.Context) (int, interface{}) { + return apiBus.proxyRouterApi.InitiateSession(ctx) +} + // AiEngine func (apiBus *ApiBus) Prompt(ctx context.Context) (string, error) { return apiBus.aiEngine.Prompt(ctx) diff --git a/proxy-router/internal/constants.go b/proxy-router/internal/constants.go new file mode 100644 index 00000000..fc6c5e93 --- /dev/null +++ b/proxy-router/internal/constants.go @@ -0,0 +1,4 @@ +package constants + +const HTTP_STATUS_OK = 200 +const HTTP_STATUS_BAD_REQUEST = 400 diff --git a/proxy-router/internal/handlers/httphandlers/http.go b/proxy-router/internal/handlers/httphandlers/http.go index 46cdfa77..6b2abb08 100644 --- a/proxy-router/internal/handlers/httphandlers/http.go +++ b/proxy-router/internal/handlers/httphandlers/http.go @@ -3,6 +3,7 @@ package httphandlers import ( "net/http/pprof" + constants "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal" "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal/apibus" "github.com/gin-gonic/gin" ) @@ -14,16 +15,21 @@ func NewHTTPHandler(apiBus *apibus.ApiBus) *gin.Engine { r := gin.New() r.GET("/healthcheck", (func(ctx *gin.Context) { - ctx.JSON(200, apiBus.HealthCheck(ctx)) + ctx.JSON(constants.HTTP_STATUS_OK, apiBus.HealthCheck(ctx)) })) r.GET("/config", (func(ctx *gin.Context) { - ctx.JSON(200, apiBus.GetConfig(ctx)) + ctx.JSON(constants.HTTP_STATUS_OK, apiBus.GetConfig(ctx)) })) r.GET("/files", (func(ctx *gin.Context) { status, files := apiBus.GetFiles(ctx) ctx.JSON(status, files) })) + r.POST("/sessions/initiate", (func(ctx *gin.Context) { + status, response := apiBus.InitiateSession(ctx) + ctx.JSON(status, response) + })) + r.Any("/debug/pprof/*action", gin.WrapF(pprof.Index)) err := r.SetTrustedProxies(nil) diff --git a/proxy-router/internal/handlers/tcphandlers/mor_rpc_handler.go b/proxy-router/internal/handlers/tcphandlers/mor_rpc_handler.go new file mode 100644 index 00000000..5335656c --- /dev/null +++ b/proxy-router/internal/handlers/tcphandlers/mor_rpc_handler.go @@ -0,0 +1,74 @@ +package tcphandlers + +import ( + "fmt" + + "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal/interfaces" + "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal/lib" + "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal/morrpc" +) + +type MorRpcHandler struct { + privateKeyHex string + publicKeyHex string + address string + morRpc *morrpc.MorRpc +} + +func NewMorRpcHandler(privateKeyHex string, publicKeyHex string, address string, morRpc *morrpc.MorRpc) *MorRpcHandler { + return &MorRpcHandler{ + privateKeyHex: privateKeyHex, + address: address, + publicKeyHex: publicKeyHex, + morRpc: morRpc, + } +} + +func (m *MorRpcHandler) Handle(msg morrpc.RpcMessage, sourceLog interfaces.ILogger) (*morrpc.RpcResponse, error) { + switch msg.Method { + case "session.request": + requestId := fmt.Sprintf("%v", msg.ID) + signature := fmt.Sprintf("%v", msg.Params["signature"]) + userAddr := fmt.Sprintf("%v", msg.Params["user"]) + userPubKey := fmt.Sprintf("%v", msg.Params["key"]) + spend := fmt.Sprintf("%v", msg.Params["spend"]) + timeStamp := fmt.Sprintf("%v", msg.Params["timestamp"]) + sourceLog.Debugf("Received session request from %s, timestamp: %s", userAddr, timeStamp) + + isValid := m.morRpc.VerifySignature(msg.Params, signature, userPubKey, sourceLog) + if !isValid { + err := fmt.Errorf("invalid signature") + sourceLog.Error(err) + return nil, err + } + + hasCapacity := true // check if there is capacity + if !hasCapacity && spend != "" { + err := fmt.Errorf("no capacity") + sourceLog.Error(err) + return nil, err + } + + // Send response + response, err := m.morRpc.InitiateSessionResponse( + m.publicKeyHex, + userAddr, + m.privateKeyHex, + requestId, + ) + if err != nil { + err := lib.WrapError(fmt.Errorf("failed to create response"), err) + sourceLog.Error(err) + return nil, err + } + + return response, nil + case "method2": + // handle method2 + default: + err := fmt.Errorf("unknown method: %s", msg.Method) + sourceLog.Error(err) + return nil, err + } + return nil, nil +} diff --git a/proxy-router/internal/handlers/tcphandlers/tcp.go b/proxy-router/internal/handlers/tcphandlers/tcp.go index ef507d6f..00032bb0 100644 --- a/proxy-router/internal/handlers/tcphandlers/tcp.go +++ b/proxy-router/internal/handlers/tcphandlers/tcp.go @@ -1,32 +1,63 @@ package tcphandlers import ( + "bufio" "context" + "encoding/json" "net" "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal/interfaces" + "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal/morrpc" "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal/repositories/transport" ) func NewTCPHandler( log, connLog interfaces.ILogger, schedulerLogFactory func(contractID string) (interfaces.ILogger, error), + morRpcHandler *MorRpcHandler, ) transport.Handler { return func(ctx context.Context, conn net.Conn) { addr := conn.RemoteAddr().String() sourceLog := connLog.Named("SRC").With("SrcAddr", addr) - schedulerLog, err := schedulerLogFactory(addr) defer func() { - _ = schedulerLog.Close() + sourceLog.Info("Closing connection") + conn.Close() }() + msg, err := getMessage(conn) if err != nil { - sourceLog.Errorf("failed to create scheduler logger: %s", err) + sourceLog.Error("Error reading message", err) return } - defer func() { _ = schedulerLog.Sync() }() + resp, err := morRpcHandler.Handle(*msg, sourceLog) + if err != nil { + sourceLog.Error("Error handling message", err) + return + } + if resp != nil { + sendMsg(conn, resp) + } + } +} + +func sendMsg(conn net.Conn, msg *morrpc.RpcResponse) { + msgJson, err := json.Marshal(msg) + if err != nil { return } + conn.Write([]byte(msgJson)) +} + +func getMessage(conn net.Conn) (*morrpc.RpcMessage, error) { + reader := bufio.NewReader(conn) + d := json.NewDecoder(reader) + + var msg *morrpc.RpcMessage + err := d.Decode(&msg) + if err != nil { + return nil, err + } + return msg, nil } diff --git a/proxy-router/internal/lib/crypto.go b/proxy-router/internal/lib/crypto.go index ca9a082d..21a3b46e 100644 --- a/proxy-router/internal/lib/crypto.go +++ b/proxy-router/internal/lib/crypto.go @@ -82,6 +82,21 @@ func PrivKeyStringToAddr(privateKey string) (common.Address, error) { return addr, nil } +func PubKeyStringFromPrivate(privateKey string) (string, error) { + privKey, err := crypto.HexToECDSA(privateKey) + if err != nil { + return "", WrapError(ErrInvalidPrivateKey, err) + } + + pubKey := privKey.Public() + pubKeyECDSA, ok := pubKey.(*ecdsa.PublicKey) + if !ok { + return "", fmt.Errorf("error casting public key to ECDSA") + } + publicKeyBytes := crypto.FromECDSAPub(pubKeyECDSA) + return hex.EncodeToString(publicKeyBytes), nil +} + func MustPrivKeyToAddr(privateKey *ecdsa.PrivateKey) common.Address { addr, err := PrivKeyToAddr(privateKey) if err != nil { diff --git a/proxy-router/internal/morrpc/mor_rpc.go b/proxy-router/internal/morrpc/mor_rpc.go index bcc76587..8fdccfaf 100644 --- a/proxy-router/internal/morrpc/mor_rpc.go +++ b/proxy-router/internal/morrpc/mor_rpc.go @@ -1,10 +1,13 @@ package morrpc import ( + "encoding/base64" + "encoding/hex" "encoding/json" "fmt" "time" + "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal/interfaces" "github.com/ethereum/go-ethereum/crypto" ) @@ -243,11 +246,27 @@ func (m *MorRpc) generateSignature(params map[string]interface{}, privateKeyHex if err != nil { return "", err } - return string(signature), nil + base64Signature := base64.StdEncoding.EncodeToString(signature) + return base64Signature, nil +} + +func (m *MorRpc) VerifySignature(params map[string]interface{}, signature string, publicKey string, sourceLog interfaces.ILogger) bool { + delete(params, "signature") + publicKeyBytes, err := hex.DecodeString(publicKey) + if err != nil { + sourceLog.Error("Error decoding public key", err) + return false + } + paramsBytes, err := json.Marshal(params) + if err != nil { + sourceLog.Error("Error marshalling params", err) + return false + } + return m.verifySignature(paramsBytes, signature, publicKeyBytes) } // https://goethereumbook.org/signature-verify/ -func (m *MorRpc) VerifySignature(params []byte, signature string, publicKeyBytes []byte) bool { +func (m *MorRpc) verifySignature(params []byte, signature string, publicKeyBytes []byte) bool { var jsonParams map[string]interface{} err := json.Unmarshal([]byte(params), &jsonParams) if err != nil { @@ -260,7 +279,11 @@ func (m *MorRpc) VerifySignature(params []byte, signature string, publicKeyBytes return false } + signatureBytes, err := base64.StdEncoding.DecodeString(signature) + if err != nil { + return false + } hash := crypto.Keccak256Hash([]byte(resultStr)) - signatureNoRecoverID := signature[:len(signature)-1] // remove recovery ID - return crypto.VerifySignature(publicKeyBytes, hash.Bytes(), []byte(signatureNoRecoverID)) + signatureNoRecoverID := signatureBytes[:len(signatureBytes)-1] // remove recovery ID + return crypto.VerifySignature(publicKeyBytes, hash.Bytes(), signatureNoRecoverID) } diff --git a/proxy-router/internal/proxyapi/proxy_router_api.go b/proxy-router/internal/proxyapi/proxy_router_api.go index 152a6d0e..83df1870 100644 --- a/proxy-router/internal/proxyapi/proxy_router_api.go +++ b/proxy-router/internal/proxyapi/proxy_router_api.go @@ -1,17 +1,21 @@ package proxyapi import ( + "bufio" "context" "encoding/json" "fmt" "io" + "net" "net/url" "os" "time" + constants "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal" "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal/config" "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal/interfaces" "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal/lib" + "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal/morrpc" "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal/system" "github.com/gin-gonic/gin" ) @@ -31,6 +35,7 @@ type ProxyRouterApi struct { sysConfig *system.SystemConfigurator publicUrl *url.URL pubKey string + privateKey string config Sanitizable derivedConfig *config.DerivedConfig appStartTime time.Time @@ -38,11 +43,12 @@ type ProxyRouterApi struct { log interfaces.ILogger } -func NewProxyRouterApi(sysConfig *system.SystemConfigurator, publicUrl *url.URL, pubKey string, config Sanitizable, derivedConfig *config.DerivedConfig, appStartTime time.Time, logStorage *lib.Collection[*interfaces.LogStorage], log interfaces.ILogger) *ProxyRouterApi { +func NewProxyRouterApi(sysConfig *system.SystemConfigurator, publicUrl *url.URL, pubKey string, privateKey string, config Sanitizable, derivedConfig *config.DerivedConfig, appStartTime time.Time, logStorage *lib.Collection[*interfaces.LogStorage], log interfaces.ILogger) *ProxyRouterApi { return &ProxyRouterApi{ sysConfig: sysConfig, publicUrl: publicUrl, pubKey: pubKey, + privateKey: privateKey, config: config, derivedConfig: derivedConfig, appStartTime: appStartTime, @@ -68,6 +74,85 @@ func (p *ProxyRouterApi) HealthCheck(ctx context.Context) gin.H { } } +func (p *ProxyRouterApi) InitiateSession(ctx *gin.Context) (int, gin.H) { + var reqPayload map[string]interface{} + if err := ctx.ShouldBindJSON(&reqPayload); err != nil { + return constants.HTTP_STATUS_BAD_REQUEST, gin.H{"error": err.Error()} + } + + user, ok := reqPayload["user"].(string) + if !ok { + return constants.HTTP_STATUS_BAD_REQUEST, gin.H{"error": "user is required"} + } + + provider, ok := reqPayload["provider"].(string) + if !ok { + return constants.HTTP_STATUS_BAD_REQUEST, gin.H{"error": "provider is required"} + } + + spend, ok := reqPayload["spend"].(float64) + if !ok { + return constants.HTTP_STATUS_BAD_REQUEST, gin.H{"error": "spend is required"} + } + + providerUrl, ok := reqPayload["providerUrl"].(string) + if !ok { + return constants.HTTP_STATUS_BAD_REQUEST, gin.H{"error": "providerUrl is required"} + } + + requestID := "1" + + initiateSessionRequest, err := morrpc.NewMorRpc().InitiateSessionRequest(user, provider, p.pubKey, spend, p.privateKey, requestID) + if err != nil { + err = lib.WrapError(fmt.Errorf("failed to create initiate session request"), err) + p.log.Errorf("%s", err) + return constants.HTTP_STATUS_BAD_REQUEST, gin.H{"error": err.Error()} + } + + conn, err := net.Dial("tcp", providerUrl) + if err != nil { + err = lib.WrapError(fmt.Errorf("failed to connect to provider"), err) + p.log.Errorf("%s", err) + return constants.HTTP_STATUS_BAD_REQUEST, gin.H{"error": err.Error()} + } + defer conn.Close() + + msgJSON, err := json.Marshal(initiateSessionRequest) + if err != nil { + err = lib.WrapError(fmt.Errorf("failed to marshal initiate session request"), err) + p.log.Errorf("%s", err) + return constants.HTTP_STATUS_BAD_REQUEST, gin.H{"error": err.Error()} + } + conn.Write([]byte(msgJSON)) + + // read response + reader := bufio.NewReader(conn) + d := json.NewDecoder(reader) + var msg *morrpc.RpcResponse + err = d.Decode(&msg) + if err != nil { + err = lib.WrapError(fmt.Errorf("failed to decode response"), err) + p.log.Errorf("%s", err) + return constants.HTTP_STATUS_BAD_REQUEST, gin.H{"error": err.Error()} + } + + signature := fmt.Sprintf("%v", msg.Result["signature"]) + providerPubKey := fmt.Sprintf("%v", msg.Result["message"]) + p.log.Debugf("Signature: %s, Provider Pub Key: %s", signature, providerPubKey) + + isValidSignature := morrpc.NewMorRpc().VerifySignature(msg.Result, signature, providerPubKey, p.log) + p.log.Debugf("Is valid signature: %t", isValidSignature) + if !isValidSignature { + err = fmt.Errorf("invalid signature from provider") + p.log.Errorf("%s", err) + return constants.HTTP_STATUS_BAD_REQUEST, gin.H{"error": err.Error()} + } + + return constants.HTTP_STATUS_OK, gin.H{ + "response": msg, + } +} + func (p *ProxyRouterApi) GetFiles(ctx *gin.Context) (int, gin.H) { files, err := p.sysConfig.GetFileDescriptors(ctx, os.Getpid()) if err != nil { @@ -94,7 +179,7 @@ func (p *ProxyRouterApi) GetFiles(ctx *gin.Context) (int, gin.H) { _ = ctx.Error(err) ctx.Abort() } - return 200, gin.H{} + return constants.HTTP_STATUS_OK, gin.H{} } func writeFiles(writer io.Writer, files []system.FD) error { From f6f0e24f3b0a3ec8fb24885864a92c4a5a10ac0a Mon Sep 17 00:00:00 2001 From: loonerin Date: Fri, 19 Apr 2024 13:05:51 -0400 Subject: [PATCH 09/21] add a launcher --- launcher/.gitignore | 2 + launcher/Makefile | 23 ++++++++++++ launcher/cmd/main.go | 81 ++++++++++++++++++++++++++++++++++++++++ launcher/go.mod | 5 +++ launcher/go.sum | 2 + launcher/mor-launch.json | 6 +++ 6 files changed, 119 insertions(+) create mode 100644 launcher/.gitignore create mode 100644 launcher/Makefile create mode 100644 launcher/cmd/main.go create mode 100644 launcher/go.mod create mode 100644 launcher/go.sum create mode 100644 launcher/mor-launch.json diff --git a/launcher/.gitignore b/launcher/.gitignore new file mode 100644 index 00000000..600dc960 --- /dev/null +++ b/launcher/.gitignore @@ -0,0 +1,2 @@ +mor-launch +*.log diff --git a/launcher/Makefile b/launcher/Makefile new file mode 100644 index 00000000..f7ae104b --- /dev/null +++ b/launcher/Makefile @@ -0,0 +1,23 @@ +prefix = /usr/local +PROG = mor-launch + +all: $(PROG) + +$(PROG): cmd/main.go + go build -o $@ $^ + +clean: + rm -f $(PROG) + +install: $(PROG) + mkdir -p $(DESTDIR)$(prefix)/bin + cp $< $(DESTDIR)$(prefix)/bin/ + +uninstall: + rm $(DESTDIR)$(prefix)/bin/$(PROG) + +run: + go run cmd/main.go + +.PHONY: all clean install uninstall run + diff --git a/launcher/cmd/main.go b/launcher/cmd/main.go new file mode 100644 index 00000000..417217ca --- /dev/null +++ b/launcher/cmd/main.go @@ -0,0 +1,81 @@ +package main + +import ( + "encoding/json" + "path" + "log" + "io" + "os" + "os/exec" + "sync" + "github.com/google/shlex" +) + +type Config struct { + Run []string `json:"run"` +} + +func findConfig(fileName string) (string, error) { + homeFile := path.Join(os.Getenv("HOME"), fileName) + if _, err := os.Stat(fileName); err == nil { + return fileName, nil + } else if _, err := os.Stat(homeFile); err == nil { + return homeFile, nil + } else { + return "", os.ErrNotExist + } +} + +func main() { + confName := "mor-launch.json" + confFile, err := findConfig(confName) + if err != nil { + log.Fatalf("Error finding %s: %v", confName, err) + } + data, err := os.ReadFile(confFile) + if err != nil { + log.Fatalf("Error reading %s: %v", confName, err) + } + var conf Config + err = json.Unmarshal(data, &conf) + if err != nil { + log.Fatal("Error during Unmarshal(): ", err) + } + var wg sync.WaitGroup + for _, v := range conf.Run { + wg.Add(1) + go func(v string) { + defer wg.Done() + var args []string + var err error + args, err = shlex.Split(v) + if err != nil { + log.Print(err) + return + } + if len(args) == 0 { + log.Print("No args, bailing") + return + } + cmd := exec.Command(args[0], args[1:]...) + stdout, err := cmd.StdoutPipe() + if err != nil { + log.Print(err) + return + } + if err := cmd.Start(); err != nil { + log.Print(err) + return + } + if _, err := io.Copy(os.Stdout, stdout); err != nil { + log.Print(err) + return + } + if err := cmd.Wait(); err != nil { + log.Print(err) + } + }(v) + } + wg.Wait() +} + diff --git a/launcher/go.mod b/launcher/go.mod new file mode 100644 index 00000000..6e87060f --- /dev/null +++ b/launcher/go.mod @@ -0,0 +1,5 @@ +module github.com/MorpheusAIs/Morpheus-Lumerin-Node/launcher + +go 1.19 + +require github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 diff --git a/launcher/go.sum b/launcher/go.sum new file mode 100644 index 00000000..0be91573 --- /dev/null +++ b/launcher/go.sum @@ -0,0 +1,2 @@ +github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= +github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= diff --git a/launcher/mor-launch.json b/launcher/mor-launch.json new file mode 100644 index 00000000..d96436aa --- /dev/null +++ b/launcher/mor-launch.json @@ -0,0 +1,6 @@ +{ + "run":[ + "sh -c 'echo Launched'", + "server -m /tmp/models/llama2_7b_chat_uncensored.Q4_K_M.gguf" + ] +} From 9dc07227682cc119d74886c95ce80bb48fe334cc Mon Sep 17 00:00:00 2001 From: Aleksandr Kukharenko Date: Tue, 23 Apr 2024 16:48:50 +0300 Subject: [PATCH 10/21] fix: bot review + encode signature to hex instead of base64 --- proxy-router/cmd/main.go | 1 + .../internal/handlers/tcphandlers/tcp.go | 12 ++++--- proxy-router/internal/lib/crypto.go | 2 +- proxy-router/internal/morrpc/mor_rpc.go | 29 ++++++----------- proxy-router/internal/morrpc/mor_rpc_test.go | 32 ++++++++++++++----- 5 files changed, 44 insertions(+), 32 deletions(-) diff --git a/proxy-router/cmd/main.go b/proxy-router/cmd/main.go index fbda41f8..f374c242 100644 --- a/proxy-router/cmd/main.go +++ b/proxy-router/cmd/main.go @@ -187,6 +187,7 @@ func start() error { publicKey, err := lib.PubKeyStringFromPrivate(cfg.Marketplace.WalletPrivateKey) if err != nil { + appLog.Errorf("failed to get public key: %s", err) return err } diff --git a/proxy-router/internal/handlers/tcphandlers/tcp.go b/proxy-router/internal/handlers/tcphandlers/tcp.go index 00032bb0..41e2e4d6 100644 --- a/proxy-router/internal/handlers/tcphandlers/tcp.go +++ b/proxy-router/internal/handlers/tcphandlers/tcp.go @@ -37,17 +37,21 @@ func NewTCPHandler( return } if resp != nil { - sendMsg(conn, resp) + _, err := sendMsg(conn, resp) + if err != nil { + sourceLog.Error("Error sending response", err) + return + } } } } -func sendMsg(conn net.Conn, msg *morrpc.RpcResponse) { +func sendMsg(conn net.Conn, msg *morrpc.RpcResponse) (int, error) { msgJson, err := json.Marshal(msg) if err != nil { - return + return 0, err } - conn.Write([]byte(msgJson)) + return conn.Write([]byte(msgJson)) } func getMessage(conn net.Conn) (*morrpc.RpcMessage, error) { diff --git a/proxy-router/internal/lib/crypto.go b/proxy-router/internal/lib/crypto.go index 21a3b46e..df972e1a 100644 --- a/proxy-router/internal/lib/crypto.go +++ b/proxy-router/internal/lib/crypto.go @@ -91,7 +91,7 @@ func PubKeyStringFromPrivate(privateKey string) (string, error) { pubKey := privKey.Public() pubKeyECDSA, ok := pubKey.(*ecdsa.PublicKey) if !ok { - return "", fmt.Errorf("error casting public key to ECDSA") + return "", fmt.Errorf("error casting public key to ECDSA: %v", pubKeyECDSA) } publicKeyBytes := crypto.FromECDSAPub(pubKeyECDSA) return hex.EncodeToString(publicKeyBytes), nil diff --git a/proxy-router/internal/morrpc/mor_rpc.go b/proxy-router/internal/morrpc/mor_rpc.go index 8fdccfaf..b67a1261 100644 --- a/proxy-router/internal/morrpc/mor_rpc.go +++ b/proxy-router/internal/morrpc/mor_rpc.go @@ -1,7 +1,6 @@ package morrpc import ( - "encoding/base64" "encoding/hex" "encoding/json" "fmt" @@ -246,18 +245,22 @@ func (m *MorRpc) generateSignature(params map[string]interface{}, privateKeyHex if err != nil { return "", err } - base64Signature := base64.StdEncoding.EncodeToString(signature) - return base64Signature, nil + hexSignature := hex.EncodeToString(signature) + return hexSignature, nil } func (m *MorRpc) VerifySignature(params map[string]interface{}, signature string, publicKey string, sourceLog interfaces.ILogger) bool { - delete(params, "signature") + paramsCopy := make(map[string]interface{}) + for k, v := range params { + paramsCopy[k] = v + } + delete(paramsCopy, "signature") publicKeyBytes, err := hex.DecodeString(publicKey) if err != nil { sourceLog.Error("Error decoding public key", err) return false } - paramsBytes, err := json.Marshal(params) + paramsBytes, err := json.Marshal(paramsCopy) if err != nil { sourceLog.Error("Error marshalling params", err) return false @@ -267,23 +270,11 @@ func (m *MorRpc) VerifySignature(params map[string]interface{}, signature string // https://goethereumbook.org/signature-verify/ func (m *MorRpc) verifySignature(params []byte, signature string, publicKeyBytes []byte) bool { - var jsonParams map[string]interface{} - err := json.Unmarshal([]byte(params), &jsonParams) - if err != nil { - return false - } - delete(jsonParams, "signature") - - resultStr, err := json.Marshal(jsonParams) + signatureBytes, err := hex.DecodeString(signature) if err != nil { return false } - - signatureBytes, err := base64.StdEncoding.DecodeString(signature) - if err != nil { - return false - } - hash := crypto.Keccak256Hash([]byte(resultStr)) + hash := crypto.Keccak256Hash([]byte(params)) signatureNoRecoverID := signatureBytes[:len(signatureBytes)-1] // remove recovery ID return crypto.VerifySignature(publicKeyBytes, hash.Bytes(), signatureNoRecoverID) } diff --git a/proxy-router/internal/morrpc/mor_rpc_test.go b/proxy-router/internal/morrpc/mor_rpc_test.go index 0a0cdcfc..417e50f9 100644 --- a/proxy-router/internal/morrpc/mor_rpc_test.go +++ b/proxy-router/internal/morrpc/mor_rpc_test.go @@ -2,7 +2,7 @@ package morrpc import ( "encoding/hex" - "encoding/json" + "fmt" "testing" "github.com/stretchr/testify/assert" @@ -40,12 +40,9 @@ func TestMorRpc_verifySignature(t *testing.T) { assert.NoError(t, err) assert.NotEmpty(t, signature) - publicKeyBytes, err := hex.DecodeString(publicKey) assert.NoError(t, err) - paramsBytes, err := json.Marshal(params) - - isValid := m.VerifySignature(paramsBytes, signature, publicKeyBytes) + isValid := m.VerifySignature(params, signature, publicKey, nil) assert.True(t, isValid) } @@ -65,11 +62,30 @@ func TestMorRpc_verifySignature_incorrect_params(t *testing.T) { assert.NoError(t, err) assert.NotEmpty(t, signature) - publicKeyBytes, err := hex.DecodeString(publicKey) assert.NoError(t, err) params["param3"] = "unknown value" - paramsBytes, err := json.Marshal(params) - isValid := m.VerifySignature(paramsBytes, signature, publicKeyBytes) + isValid := m.VerifySignature(params, signature, publicKey, nil) assert.False(t, isValid) } + +func TestMorRpc_generate(t *testing.T) { + m := NewMorRpc() + + params := map[string]interface{}{ + "user": "2222", + "key": "033e5e77f12aa67e52484ce64b64737d397098e78d54beba15a0bf6dcfdd5ae7e2", + "spend": "10", + "provider": "1111", + "timestamp": "1234567890", + } + + privateKeyHex := "81f44a49c40f206517efbbcca783d808914841200e0ac9a769368e1b2741e227" + // publicKey := "033e5e77f12aa67e52484ce64b64737d397098e78d54beba15a0bf6dcfdd5ae7e2" + + signature, err := m.generateSignature(params, privateKeyHex) + assert.NoError(t, err) + + base64Signature := hex.EncodeToString([]byte(signature)) + fmt.Println(base64Signature) +} From 9779ac9305bbc49cb2b977f4b3c508b3f542d6ab Mon Sep 17 00:00:00 2001 From: Aleksandr Kukharenko Date: Tue, 23 Apr 2024 16:55:28 +0300 Subject: [PATCH 11/21] fix: bot review --- proxy-router/internal/morrpc/mor_rpc.go | 3 +++ proxy-router/internal/morrpc/mor_rpc_test.go | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/proxy-router/internal/morrpc/mor_rpc.go b/proxy-router/internal/morrpc/mor_rpc.go index b67a1261..7a7c3eb6 100644 --- a/proxy-router/internal/morrpc/mor_rpc.go +++ b/proxy-router/internal/morrpc/mor_rpc.go @@ -275,6 +275,9 @@ func (m *MorRpc) verifySignature(params []byte, signature string, publicKeyBytes return false } hash := crypto.Keccak256Hash([]byte(params)) + if len(signatureBytes) == 0 { + return false + } signatureNoRecoverID := signatureBytes[:len(signatureBytes)-1] // remove recovery ID return crypto.VerifySignature(publicKeyBytes, hash.Bytes(), signatureNoRecoverID) } diff --git a/proxy-router/internal/morrpc/mor_rpc_test.go b/proxy-router/internal/morrpc/mor_rpc_test.go index 417e50f9..ddcdde8e 100644 --- a/proxy-router/internal/morrpc/mor_rpc_test.go +++ b/proxy-router/internal/morrpc/mor_rpc_test.go @@ -40,8 +40,6 @@ func TestMorRpc_verifySignature(t *testing.T) { assert.NoError(t, err) assert.NotEmpty(t, signature) - assert.NoError(t, err) - isValid := m.VerifySignature(params, signature, publicKey, nil) assert.True(t, isValid) } @@ -62,8 +60,6 @@ func TestMorRpc_verifySignature_incorrect_params(t *testing.T) { assert.NoError(t, err) assert.NotEmpty(t, signature) - assert.NoError(t, err) - params["param3"] = "unknown value" isValid := m.VerifySignature(params, signature, publicKey, nil) assert.False(t, isValid) From 3d5780370cd123b686bcb2e8f6028a4fec2dc854 Mon Sep 17 00:00:00 2001 From: Aleksandr Kukharenko Date: Tue, 23 Apr 2024 17:01:43 +0300 Subject: [PATCH 12/21] refactor: rename variable --- proxy-router/internal/morrpc/mor_rpc_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proxy-router/internal/morrpc/mor_rpc_test.go b/proxy-router/internal/morrpc/mor_rpc_test.go index ddcdde8e..10a0076e 100644 --- a/proxy-router/internal/morrpc/mor_rpc_test.go +++ b/proxy-router/internal/morrpc/mor_rpc_test.go @@ -82,6 +82,6 @@ func TestMorRpc_generate(t *testing.T) { signature, err := m.generateSignature(params, privateKeyHex) assert.NoError(t, err) - base64Signature := hex.EncodeToString([]byte(signature)) - fmt.Println(base64Signature) + hexSignature := hex.EncodeToString([]byte(signature)) + fmt.Println(hexSignature) } From 30ed5748e393d6fb14c89f1359e2377d45e0a80e Mon Sep 17 00:00:00 2001 From: loonerin Date: Wed, 24 Apr 2024 16:13:49 -0400 Subject: [PATCH 13/21] add CI with manual release --- .github/workflows/build.yml | 178 ++++++++++++++++++++++++++++++++++++ 1 file changed, 178 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..cfb3e1d2 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,178 @@ +name: CI + +on: + workflow_dispatch: + inputs: + create_release: + description: 'Create new release' + required: true + type: boolean + push: + branches: + - main + paths: ['.github/workflows/**', '**/Makefile', '**/*.go'] + +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true + +defaults: + run: + shell: bash + +jobs: + Ubuntu-22-x64: + runs-on: ubuntu-22.04 + steps: + - name: Clone + uses: actions/checkout@v4 + id: checkout + + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: '1.21.x' + cache-dependency-path: launcher/go.sum + + - name: Install dependencies + run: | + cd launcher + go mod tidy + + - name: Build + id: build + run: | + cd launcher + make + + - name: Determine tag name + id: tag + run: | + SHORT_HASH="$(git rev-parse --short=7 HEAD)" + echo "name=${SHORT_HASH}" >> $GITHUB_OUTPUT + + - name: Pack artifacts + id: pack_artifacts + run: | + ARTIFACT=mor-launch-${{ steps.tag.outputs.name }}-ubuntu-x64.zip + LLAMACPP=llama-b2699-bin-ubuntu-x64.zip + MODEL=tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf + wget https://github.com/ggerganov/llama.cpp/releases/download/b2699/$LLAMACPP + wget https://huggingface.co/TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF/resolve/main/$MODEL + unzip -o -j $LLAMACPP build/bin/server + echo '{"run":["./server -m ./'$MODEL'"]}' > mor-launch.json + zip -j $ARTIFACT ./LICENSE ./launcher/mor-launch server $MODEL mor-launch.json + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + path: mor-launch-${{ steps.tag.outputs.name }}-ubuntu-x64.zip + name: mor-launch-ubuntu-x64.zip + + macOS-12-x64: + runs-on: macos-12 + steps: + - name: Clone + uses: actions/checkout@v4 + id: checkout + + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: '1.21.x' + cache-dependency-path: launcher/go.sum + + - name: Install dependencies + run: | + cd launcher + go mod tidy + + - name: Build + id: build + run: | + cd launcher + make + + - name: Determine tag name + id: tag + run: | + SHORT_HASH="$(git rev-parse --short=7 HEAD)" + echo "name=${SHORT_HASH}" >> $GITHUB_OUTPUT + + - name: Pack artifacts + id: pack_artifacts + run: | + ARTIFACT=mor-launch-${{ steps.tag.outputs.name }}-macos-x64.zip + LLAMACPP=llama-b2699-bin-macos-x64.zip + MODEL=tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf + wget https://github.com/ggerganov/llama.cpp/releases/download/b2699/$LLAMACPP + wget https://huggingface.co/TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF/resolve/main/$MODEL + unzip -o -j $LLAMACPP build/bin/server + echo '{"run":["./server -m ./'$MODEL'"]}' > mor-launch.json + zip -j $ARTIFACT ./LICENSE ./launcher/mor-launch server $MODEL mor-launch.json + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + path: mor-launch-${{ steps.tag.outputs.name }}-macos-x64.zip + name: mor-launch-macos-x64.zip + + release: + if: ${{ github.event.inputs.create_release == 'true' }} + runs-on: ubuntu-latest + needs: + - Ubuntu-22-x64 + - macOS-12-x64 + steps: + - name: Clone + id: checkout + uses: actions/checkout@v4 + + - name: Determine tag name + id: tag + run: | + SHORT_HASH="$(git rev-parse --short=7 HEAD)" + echo "name=${SHORT_HASH}" >> $GITHUB_OUTPUT + + - name: Download artifacts + id: download-artifact + uses: actions/download-artifact@v4 + with: + path: ./artifact + + - name: Move artifacts + id: move_artifacts + run: | + mkdir -p ./artifact/release + mv ./artifact/*/*.zip ./artifact/release + + - name: Create release + id: create_release + uses: anzz1/action-create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.tag.outputs.name }} + + - name: Upload release + id: upload_release + uses: actions/github-script@v3 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + const path = require('path'); + const fs = require('fs'); + const release_id = '${{ steps.create_release.outputs.id }}'; + for (let file of await fs.readdirSync('./artifact/release')) { + if (path.extname(file) === '.zip') { + console.log('uploadReleaseAsset', file); + await github.repos.uploadReleaseAsset({ + owner: context.repo.owner, + repo: context.repo.repo, + release_id: release_id, + name: file, + data: await fs.readFileSync(`./artifact/release/${file}`) + }); + } + } + From 856eb39f52bb99c04e1b1ef22a292c942acdc5c0 Mon Sep 17 00:00:00 2001 From: loonerin Date: Mon, 29 Apr 2024 12:40:21 -0400 Subject: [PATCH 14/21] CI: add proxy-router into release --- .github/workflows/build.yml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cfb3e1d2..edd64af1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -38,12 +38,16 @@ jobs: run: | cd launcher go mod tidy + cd ../proxy-router + go mod download - name: Build id: build run: | cd launcher make + cd ../proxy-router + make build - name: Determine tag name id: tag @@ -60,8 +64,9 @@ jobs: wget https://github.com/ggerganov/llama.cpp/releases/download/b2699/$LLAMACPP wget https://huggingface.co/TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF/resolve/main/$MODEL unzip -o -j $LLAMACPP build/bin/server - echo '{"run":["./server -m ./'$MODEL'"]}' > mor-launch.json - zip -j $ARTIFACT ./LICENSE ./launcher/mor-launch server $MODEL mor-launch.json + echo '{"run":["./server -m ./'$MODEL'","./proxy-router"]}' > mor-launch.json + cp ./proxy-router/.env.example .env + zip -j $ARTIFACT ./LICENSE ./launcher/mor-launch server ./proxy-router/bin/proxy-router .env $MODEL mor-launch.json - name: Upload artifacts uses: actions/upload-artifact@v4 @@ -86,12 +91,16 @@ jobs: run: | cd launcher go mod tidy + cd ../proxy-router + go mod download - name: Build id: build run: | cd launcher make + cd ../proxy-router + make build - name: Determine tag name id: tag @@ -108,8 +117,9 @@ jobs: wget https://github.com/ggerganov/llama.cpp/releases/download/b2699/$LLAMACPP wget https://huggingface.co/TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF/resolve/main/$MODEL unzip -o -j $LLAMACPP build/bin/server - echo '{"run":["./server -m ./'$MODEL'"]}' > mor-launch.json - zip -j $ARTIFACT ./LICENSE ./launcher/mor-launch server $MODEL mor-launch.json + echo '{"run":["./server -m ./'$MODEL'","./proxy-router"]}' > mor-launch.json + cp ./proxy-router/.env.example .env + zip -j $ARTIFACT ./LICENSE ./launcher/mor-launch ./proxy-router/bin/proxy-router .env server $MODEL mor-launch.json - name: Upload artifacts uses: actions/upload-artifact@v4 From 15b4a9c4bfda068b8b37dfc0ca20fced0673608b Mon Sep 17 00:00:00 2001 From: loonerin Date: Tue, 30 Apr 2024 12:24:36 -0400 Subject: [PATCH 15/21] CI: add macOS-arm64 --- .github/workflows/build.yml | 54 +++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index edd64af1..d25f9516 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -127,12 +127,66 @@ jobs: path: mor-launch-${{ steps.tag.outputs.name }}-macos-x64.zip name: mor-launch-macos-x64.zip + macOS-14-arm64: + runs-on: macos-14 + steps: + - name: Clone + uses: actions/checkout@v4 + id: checkout + + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: '1.21.x' + cache-dependency-path: launcher/go.sum + + - name: Install dependencies + run: | + cd launcher + go mod tidy + cd ../proxy-router + go mod download + + - name: Build + id: build + run: | + cd launcher + make + cd ../proxy-router + make build + + - name: Determine tag name + id: tag + run: | + SHORT_HASH="$(git rev-parse --short=7 HEAD)" + echo "name=${SHORT_HASH}" >> $GITHUB_OUTPUT + + - name: Pack artifacts + id: pack_artifacts + run: | + ARTIFACT=mor-launch-${{ steps.tag.outputs.name }}-macos-arm64.zip + LLAMACPP=llama-b2699-bin-macos-arm64.zip + MODEL=tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf + wget https://github.com/ggerganov/llama.cpp/releases/download/b2699/$LLAMACPP + wget https://huggingface.co/TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF/resolve/main/$MODEL + unzip -o -j $LLAMACPP build/bin/server + echo '{"run":["./server -m ./'$MODEL'","./proxy-router"]}' > mor-launch.json + cp ./proxy-router/.env.example .env + zip -j $ARTIFACT ./LICENSE ./launcher/mor-launch ./proxy-router/bin/proxy-router .env server $MODEL mor-launch.json + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + path: mor-launch-${{ steps.tag.outputs.name }}-macos-arm64.zip + name: mor-launch-macos-arm64.zip + release: if: ${{ github.event.inputs.create_release == 'true' }} runs-on: ubuntu-latest needs: - Ubuntu-22-x64 - macOS-12-x64 + - macOS-14-arm64 steps: - name: Clone id: checkout From eb7ed55ddb664213695d277489bba6917d2d1230 Mon Sep 17 00:00:00 2001 From: Aleksandr Kukharenko Date: Tue, 30 Apr 2024 22:04:40 +0300 Subject: [PATCH 16/21] fill .env.example --- proxy-router/.env.example | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/proxy-router/.env.example b/proxy-router/.env.example index 32eafc00..aa995529 100644 --- a/proxy-router/.env.example +++ b/proxy-router/.env.example @@ -1,27 +1,24 @@ -ETH_NODE_ADDRESS= -ETH_NODE_LEGACY_TX= -ENVIRONMENT= +ETH_NODE_ADDRESS=https://rpc.ankr.com/eth +ETH_NODE_LEGACY_TX=false +ENVIRONMENT=development -CONTRACT_MNEMONIC= WALLET_PRIVATE_KEY= -LOG_COLOR= -LOG_JSON= -LOG_LEVEL_APP= -LOG_LEVEL_CONNECTION= -LOG_LEVEL_PROXY= -LOG_LEVEL_SCHEDULER= -LOG_LEVEL_CONTRACT= +LOG_COLOR=true +LOG_LEVEL_APP=info +LOG_LEVEL_SCHEDULER=info +LOG_LEVEL_PROXY=info +LOG_LEVEL_CONNECTION=info +LOG_FOLDER_PATH=./logs/ -PROXY_ADDRESS= +PROXY_ADDRESS=0.0.0.0:3333 -SYS_ENABLE= -SYS_LOCAL_PORT_RANGE= -SYS_NET_DEV_MAX_BACKLOG= -SYS_RLIMIT_HARD= -SYS_RLIMIT_SOFT= -SYS_SOMAXCONN= -SYS_TCP_MAX_SYN_BACKLOG= +SYS_ENABLE=false +SYS_LOCAL_PORT_RANGE=1024 65535 +SYS_NET_DEV_MAX_BACKLOG=100000 +SYS_RLIMIT_HARD=524288 +SYS_RLIMIT_SOFT=524288 +SYS_SOMAXCONN=100000 +SYS_TCP_MAX_SYN_BACKLOG=100000 -WEB_ADDRESS= -WEB_PUBLIC_URL= \ No newline at end of file +WEB_ADDRESS=0.0.0.0:8080 \ No newline at end of file From cd536493e0e5c9c6e4d37237052ca6fa08da00b1 Mon Sep 17 00:00:00 2001 From: alex-sandrk <113540941+alex-sandrk@users.noreply.github.com> Date: Tue, 30 Apr 2024 23:16:06 +0300 Subject: [PATCH 17/21] feat: cherry pick proxy changes (#34) * feat: cherry pick proxy changes * draft: prompt endpoint * fix: typos --------- Co-authored-by: srt0422 --- proxy-router/.env.example | 6 +- proxy-router/cmd/main.go | 7 +- .../contracts/agentregistry/AgentRegistry.go | 1296 +++++++++++ .../contracts/marketplace/Marketplace.go | 1474 +++++++++++++ .../contracts/modelregistry/ModelRegistry.go | 1409 ++++++++++++ .../contracts/morpheustoken/MorpheusToken.go | 738 +++++++ .../providerregistry/ProviderRegistry.go | 1373 ++++++++++++ .../contracts/sessionrouter/SessionRouter.go | 1944 +++++++++++++++++ .../StakingDailyStipend.go | 1291 +++++++++++ proxy-router/internal/apibus/api_bus.go | 23 + proxy-router/internal/config/config.go | 10 +- .../internal/handlers/httphandlers/http.go | 75 +- .../handlers/tcphandlers/mor_rpc_handler.go | 31 +- .../internal/proxyapi/proxy_router_api.go | 78 + .../repositories/registries/marketplace.go | 67 + .../repositories/registries/model_registry.go | 56 + .../registries/model_registry_test.go | 44 + .../registries/provider_registry.go | 63 + proxy-router/internal/rpcproxy/rpc_proxy.go | 54 +- .../contracts/agentregistry/AgentRegistry.go | 1296 +++++++++++ .../go/contracts/marketplace/Marketplace.go | 1474 +++++++++++++ .../contracts/modelregistry/ModelRegistry.go | 1409 ++++++++++++ .../contracts/morpheustoken/MorpheusToken.go | 738 +++++++ .../providerregistry/ProviderRegistry.go | 1373 ++++++++++++ .../contracts/sessionrouter/SessionRouter.go | 1944 +++++++++++++++++ .../StakingDailyStipend.go | 1291 +++++++++++ smart-contracts/package.json | 9 +- 27 files changed, 19558 insertions(+), 15 deletions(-) create mode 100644 proxy-router/contracts/agentregistry/AgentRegistry.go create mode 100644 proxy-router/contracts/marketplace/Marketplace.go create mode 100644 proxy-router/contracts/modelregistry/ModelRegistry.go create mode 100644 proxy-router/contracts/morpheustoken/MorpheusToken.go create mode 100644 proxy-router/contracts/providerregistry/ProviderRegistry.go create mode 100644 proxy-router/contracts/sessionrouter/SessionRouter.go create mode 100644 proxy-router/contracts/stakingdailystipend/StakingDailyStipend.go create mode 100644 proxy-router/internal/repositories/registries/marketplace.go create mode 100644 proxy-router/internal/repositories/registries/model_registry.go create mode 100644 proxy-router/internal/repositories/registries/model_registry_test.go create mode 100644 proxy-router/internal/repositories/registries/provider_registry.go create mode 100644 smart-contracts/bindings/go/contracts/agentregistry/AgentRegistry.go create mode 100644 smart-contracts/bindings/go/contracts/marketplace/Marketplace.go create mode 100644 smart-contracts/bindings/go/contracts/modelregistry/ModelRegistry.go create mode 100644 smart-contracts/bindings/go/contracts/morpheustoken/MorpheusToken.go create mode 100644 smart-contracts/bindings/go/contracts/providerregistry/ProviderRegistry.go create mode 100644 smart-contracts/bindings/go/contracts/sessionrouter/SessionRouter.go create mode 100644 smart-contracts/bindings/go/contracts/stakingdailystipend/StakingDailyStipend.go diff --git a/proxy-router/.env.example b/proxy-router/.env.example index aa995529..975ea4d1 100644 --- a/proxy-router/.env.example +++ b/proxy-router/.env.example @@ -21,4 +21,8 @@ SYS_RLIMIT_SOFT=524288 SYS_SOMAXCONN=100000 SYS_TCP_MAX_SYN_BACKLOG=100000 -WEB_ADDRESS=0.0.0.0:8080 \ No newline at end of file +WEB_PUBLIC_URL= +PROVIDER_REGISTRY_ADDRESS= +MODEL_REGISTRY_ADDRESS= +MARKETPLACE_ADDRESS= +WEB_ADDRESS=0.0.0.0:8080 diff --git a/proxy-router/cmd/main.go b/proxy-router/cmd/main.go index f374c242..52600778 100644 --- a/proxy-router/cmd/main.go +++ b/proxy-router/cmd/main.go @@ -22,6 +22,7 @@ import ( "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal/repositories/transport" "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal/rpcproxy" "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal/system" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethclient" "golang.org/x/sync/errgroup" ) @@ -198,8 +199,12 @@ func start() error { ) tcpServer.SetConnectionHandler(tcpHandler) + providerRegistryAddr := common.HexToAddress(cfg.Marketplace.ProviderRegistryAddress) + modelRegistryAddr := common.HexToAddress(cfg.Marketplace.ModelRegistryAddress) + marketplaceAddr := common.HexToAddress(cfg.Marketplace.MarketplaceAddress) + proxyRouterApi := proxyapi.NewProxyRouterApi(sysConfig, publicUrl, publicKey, cfg.Marketplace.WalletPrivateKey, &cfg, derived, time.Now(), contractLogStorage, log) - rpcProxy := rpcproxy.NewRpcProxy(ethClient) + rpcProxy := rpcproxy.NewRpcProxy(ethClient, providerRegistryAddr, modelRegistryAddr, marketplaceAddr, proxyLog) aiEngine := aiengine.NewAiEngine() apiBus := apibus.NewApiBus(rpcProxy, aiEngine, proxyRouterApi) diff --git a/proxy-router/contracts/agentregistry/AgentRegistry.go b/proxy-router/contracts/agentregistry/AgentRegistry.go new file mode 100644 index 00000000..9f252d89 --- /dev/null +++ b/proxy-router/contracts/agentregistry/AgentRegistry.go @@ -0,0 +1,1296 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package agentregistry + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// AgentRegistryAgent is an auto generated low-level Go binding around an user-defined struct. +type AgentRegistryAgent struct { + AgentId [32]byte + Fee *big.Int + Stake *big.Int + Timestamp *big.Int + Owner common.Address + Name string + Tags []string +} + +// AgentRegistryMetaData contains all meta data concerning the AgentRegistry contract. +var AgentRegistryMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[],\"name\":\"KeyExists\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"KeyNotFound\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ModelNotFound\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotSenderOrOwner\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"StakeTooLow\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ZeroKey\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"agentId\",\"type\":\"bytes32\"}],\"name\":\"Deregistered\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newStake\",\"type\":\"uint256\"}],\"name\":\"MinStakeUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"agentId\",\"type\":\"bytes32\"}],\"name\":\"RegisteredUpdated\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"id\",\"type\":\"bytes32\"}],\"name\":\"deregister\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"id\",\"type\":\"bytes32\"}],\"name\":\"exists\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAll\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"agentId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"stake\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string[]\",\"name\":\"tags\",\"type\":\"string[]\"}],\"internalType\":\"structAgentRegistry.Agent[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getIds\",\"outputs\":[{\"internalType\":\"bytes32[]\",\"name\":\"\",\"type\":\"bytes32[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"map\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"agentId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"stake\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minStake\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"addStake\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"agentId\",\"type\":\"bytes32\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string[]\",\"name\":\"tags\",\"type\":\"string[]\"}],\"name\":\"register\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_minStake\",\"type\":\"uint256\"}],\"name\":\"setMinStake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"token\",\"outputs\":[{\"internalType\":\"contractERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", +} + +// AgentRegistryABI is the input ABI used to generate the binding from. +// Deprecated: Use AgentRegistryMetaData.ABI instead. +var AgentRegistryABI = AgentRegistryMetaData.ABI + +// AgentRegistry is an auto generated Go binding around an Ethereum contract. +type AgentRegistry struct { + AgentRegistryCaller // Read-only binding to the contract + AgentRegistryTransactor // Write-only binding to the contract + AgentRegistryFilterer // Log filterer for contract events +} + +// AgentRegistryCaller is an auto generated read-only Go binding around an Ethereum contract. +type AgentRegistryCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// AgentRegistryTransactor is an auto generated write-only Go binding around an Ethereum contract. +type AgentRegistryTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// AgentRegistryFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type AgentRegistryFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// AgentRegistrySession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type AgentRegistrySession struct { + Contract *AgentRegistry // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// AgentRegistryCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type AgentRegistryCallerSession struct { + Contract *AgentRegistryCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// AgentRegistryTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type AgentRegistryTransactorSession struct { + Contract *AgentRegistryTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// AgentRegistryRaw is an auto generated low-level Go binding around an Ethereum contract. +type AgentRegistryRaw struct { + Contract *AgentRegistry // Generic contract binding to access the raw methods on +} + +// AgentRegistryCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type AgentRegistryCallerRaw struct { + Contract *AgentRegistryCaller // Generic read-only contract binding to access the raw methods on +} + +// AgentRegistryTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type AgentRegistryTransactorRaw struct { + Contract *AgentRegistryTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewAgentRegistry creates a new instance of AgentRegistry, bound to a specific deployed contract. +func NewAgentRegistry(address common.Address, backend bind.ContractBackend) (*AgentRegistry, error) { + contract, err := bindAgentRegistry(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &AgentRegistry{AgentRegistryCaller: AgentRegistryCaller{contract: contract}, AgentRegistryTransactor: AgentRegistryTransactor{contract: contract}, AgentRegistryFilterer: AgentRegistryFilterer{contract: contract}}, nil +} + +// NewAgentRegistryCaller creates a new read-only instance of AgentRegistry, bound to a specific deployed contract. +func NewAgentRegistryCaller(address common.Address, caller bind.ContractCaller) (*AgentRegistryCaller, error) { + contract, err := bindAgentRegistry(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &AgentRegistryCaller{contract: contract}, nil +} + +// NewAgentRegistryTransactor creates a new write-only instance of AgentRegistry, bound to a specific deployed contract. +func NewAgentRegistryTransactor(address common.Address, transactor bind.ContractTransactor) (*AgentRegistryTransactor, error) { + contract, err := bindAgentRegistry(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &AgentRegistryTransactor{contract: contract}, nil +} + +// NewAgentRegistryFilterer creates a new log filterer instance of AgentRegistry, bound to a specific deployed contract. +func NewAgentRegistryFilterer(address common.Address, filterer bind.ContractFilterer) (*AgentRegistryFilterer, error) { + contract, err := bindAgentRegistry(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &AgentRegistryFilterer{contract: contract}, nil +} + +// bindAgentRegistry binds a generic wrapper to an already deployed contract. +func bindAgentRegistry(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := AgentRegistryMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_AgentRegistry *AgentRegistryRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _AgentRegistry.Contract.AgentRegistryCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_AgentRegistry *AgentRegistryRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _AgentRegistry.Contract.AgentRegistryTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_AgentRegistry *AgentRegistryRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _AgentRegistry.Contract.AgentRegistryTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_AgentRegistry *AgentRegistryCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _AgentRegistry.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_AgentRegistry *AgentRegistryTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _AgentRegistry.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_AgentRegistry *AgentRegistryTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _AgentRegistry.Contract.contract.Transact(opts, method, params...) +} + +// Exists is a free data retrieval call binding the contract method 0x38a699a4. +// +// Solidity: function exists(bytes32 id) view returns(bool) +func (_AgentRegistry *AgentRegistryCaller) Exists(opts *bind.CallOpts, id [32]byte) (bool, error) { + var out []interface{} + err := _AgentRegistry.contract.Call(opts, &out, "exists", id) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// Exists is a free data retrieval call binding the contract method 0x38a699a4. +// +// Solidity: function exists(bytes32 id) view returns(bool) +func (_AgentRegistry *AgentRegistrySession) Exists(id [32]byte) (bool, error) { + return _AgentRegistry.Contract.Exists(&_AgentRegistry.CallOpts, id) +} + +// Exists is a free data retrieval call binding the contract method 0x38a699a4. +// +// Solidity: function exists(bytes32 id) view returns(bool) +func (_AgentRegistry *AgentRegistryCallerSession) Exists(id [32]byte) (bool, error) { + return _AgentRegistry.Contract.Exists(&_AgentRegistry.CallOpts, id) +} + +// GetAll is a free data retrieval call binding the contract method 0x53ed5143. +// +// Solidity: function getAll() view returns((bytes32,uint256,uint256,uint256,address,string,string[])[]) +func (_AgentRegistry *AgentRegistryCaller) GetAll(opts *bind.CallOpts) ([]AgentRegistryAgent, error) { + var out []interface{} + err := _AgentRegistry.contract.Call(opts, &out, "getAll") + + if err != nil { + return *new([]AgentRegistryAgent), err + } + + out0 := *abi.ConvertType(out[0], new([]AgentRegistryAgent)).(*[]AgentRegistryAgent) + + return out0, err + +} + +// GetAll is a free data retrieval call binding the contract method 0x53ed5143. +// +// Solidity: function getAll() view returns((bytes32,uint256,uint256,uint256,address,string,string[])[]) +func (_AgentRegistry *AgentRegistrySession) GetAll() ([]AgentRegistryAgent, error) { + return _AgentRegistry.Contract.GetAll(&_AgentRegistry.CallOpts) +} + +// GetAll is a free data retrieval call binding the contract method 0x53ed5143. +// +// Solidity: function getAll() view returns((bytes32,uint256,uint256,uint256,address,string,string[])[]) +func (_AgentRegistry *AgentRegistryCallerSession) GetAll() ([]AgentRegistryAgent, error) { + return _AgentRegistry.Contract.GetAll(&_AgentRegistry.CallOpts) +} + +// GetIds is a free data retrieval call binding the contract method 0x2b105663. +// +// Solidity: function getIds() view returns(bytes32[]) +func (_AgentRegistry *AgentRegistryCaller) GetIds(opts *bind.CallOpts) ([][32]byte, error) { + var out []interface{} + err := _AgentRegistry.contract.Call(opts, &out, "getIds") + + if err != nil { + return *new([][32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([][32]byte)).(*[][32]byte) + + return out0, err + +} + +// GetIds is a free data retrieval call binding the contract method 0x2b105663. +// +// Solidity: function getIds() view returns(bytes32[]) +func (_AgentRegistry *AgentRegistrySession) GetIds() ([][32]byte, error) { + return _AgentRegistry.Contract.GetIds(&_AgentRegistry.CallOpts) +} + +// GetIds is a free data retrieval call binding the contract method 0x2b105663. +// +// Solidity: function getIds() view returns(bytes32[]) +func (_AgentRegistry *AgentRegistryCallerSession) GetIds() ([][32]byte, error) { + return _AgentRegistry.Contract.GetIds(&_AgentRegistry.CallOpts) +} + +// Map is a free data retrieval call binding the contract method 0x0ae186a8. +// +// Solidity: function map(bytes32 ) view returns(bytes32 agentId, uint256 fee, uint256 stake, uint256 timestamp, address owner, string name) +func (_AgentRegistry *AgentRegistryCaller) Map(opts *bind.CallOpts, arg0 [32]byte) (struct { + AgentId [32]byte + Fee *big.Int + Stake *big.Int + Timestamp *big.Int + Owner common.Address + Name string +}, error) { + var out []interface{} + err := _AgentRegistry.contract.Call(opts, &out, "map", arg0) + + outstruct := new(struct { + AgentId [32]byte + Fee *big.Int + Stake *big.Int + Timestamp *big.Int + Owner common.Address + Name string + }) + if err != nil { + return *outstruct, err + } + + outstruct.AgentId = *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + outstruct.Fee = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) + outstruct.Stake = *abi.ConvertType(out[2], new(*big.Int)).(**big.Int) + outstruct.Timestamp = *abi.ConvertType(out[3], new(*big.Int)).(**big.Int) + outstruct.Owner = *abi.ConvertType(out[4], new(common.Address)).(*common.Address) + outstruct.Name = *abi.ConvertType(out[5], new(string)).(*string) + + return *outstruct, err + +} + +// Map is a free data retrieval call binding the contract method 0x0ae186a8. +// +// Solidity: function map(bytes32 ) view returns(bytes32 agentId, uint256 fee, uint256 stake, uint256 timestamp, address owner, string name) +func (_AgentRegistry *AgentRegistrySession) Map(arg0 [32]byte) (struct { + AgentId [32]byte + Fee *big.Int + Stake *big.Int + Timestamp *big.Int + Owner common.Address + Name string +}, error) { + return _AgentRegistry.Contract.Map(&_AgentRegistry.CallOpts, arg0) +} + +// Map is a free data retrieval call binding the contract method 0x0ae186a8. +// +// Solidity: function map(bytes32 ) view returns(bytes32 agentId, uint256 fee, uint256 stake, uint256 timestamp, address owner, string name) +func (_AgentRegistry *AgentRegistryCallerSession) Map(arg0 [32]byte) (struct { + AgentId [32]byte + Fee *big.Int + Stake *big.Int + Timestamp *big.Int + Owner common.Address + Name string +}, error) { + return _AgentRegistry.Contract.Map(&_AgentRegistry.CallOpts, arg0) +} + +// MinStake is a free data retrieval call binding the contract method 0x375b3c0a. +// +// Solidity: function minStake() view returns(uint256) +func (_AgentRegistry *AgentRegistryCaller) MinStake(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _AgentRegistry.contract.Call(opts, &out, "minStake") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// MinStake is a free data retrieval call binding the contract method 0x375b3c0a. +// +// Solidity: function minStake() view returns(uint256) +func (_AgentRegistry *AgentRegistrySession) MinStake() (*big.Int, error) { + return _AgentRegistry.Contract.MinStake(&_AgentRegistry.CallOpts) +} + +// MinStake is a free data retrieval call binding the contract method 0x375b3c0a. +// +// Solidity: function minStake() view returns(uint256) +func (_AgentRegistry *AgentRegistryCallerSession) MinStake() (*big.Int, error) { + return _AgentRegistry.Contract.MinStake(&_AgentRegistry.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_AgentRegistry *AgentRegistryCaller) Owner(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _AgentRegistry.contract.Call(opts, &out, "owner") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_AgentRegistry *AgentRegistrySession) Owner() (common.Address, error) { + return _AgentRegistry.Contract.Owner(&_AgentRegistry.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_AgentRegistry *AgentRegistryCallerSession) Owner() (common.Address, error) { + return _AgentRegistry.Contract.Owner(&_AgentRegistry.CallOpts) +} + +// Token is a free data retrieval call binding the contract method 0xfc0c546a. +// +// Solidity: function token() view returns(address) +func (_AgentRegistry *AgentRegistryCaller) Token(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _AgentRegistry.contract.Call(opts, &out, "token") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Token is a free data retrieval call binding the contract method 0xfc0c546a. +// +// Solidity: function token() view returns(address) +func (_AgentRegistry *AgentRegistrySession) Token() (common.Address, error) { + return _AgentRegistry.Contract.Token(&_AgentRegistry.CallOpts) +} + +// Token is a free data retrieval call binding the contract method 0xfc0c546a. +// +// Solidity: function token() view returns(address) +func (_AgentRegistry *AgentRegistryCallerSession) Token() (common.Address, error) { + return _AgentRegistry.Contract.Token(&_AgentRegistry.CallOpts) +} + +// Deregister is a paid mutator transaction binding the contract method 0x20813154. +// +// Solidity: function deregister(bytes32 id) returns() +func (_AgentRegistry *AgentRegistryTransactor) Deregister(opts *bind.TransactOpts, id [32]byte) (*types.Transaction, error) { + return _AgentRegistry.contract.Transact(opts, "deregister", id) +} + +// Deregister is a paid mutator transaction binding the contract method 0x20813154. +// +// Solidity: function deregister(bytes32 id) returns() +func (_AgentRegistry *AgentRegistrySession) Deregister(id [32]byte) (*types.Transaction, error) { + return _AgentRegistry.Contract.Deregister(&_AgentRegistry.TransactOpts, id) +} + +// Deregister is a paid mutator transaction binding the contract method 0x20813154. +// +// Solidity: function deregister(bytes32 id) returns() +func (_AgentRegistry *AgentRegistryTransactorSession) Deregister(id [32]byte) (*types.Transaction, error) { + return _AgentRegistry.Contract.Deregister(&_AgentRegistry.TransactOpts, id) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc4d66de8. +// +// Solidity: function initialize(address _token) returns() +func (_AgentRegistry *AgentRegistryTransactor) Initialize(opts *bind.TransactOpts, _token common.Address) (*types.Transaction, error) { + return _AgentRegistry.contract.Transact(opts, "initialize", _token) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc4d66de8. +// +// Solidity: function initialize(address _token) returns() +func (_AgentRegistry *AgentRegistrySession) Initialize(_token common.Address) (*types.Transaction, error) { + return _AgentRegistry.Contract.Initialize(&_AgentRegistry.TransactOpts, _token) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc4d66de8. +// +// Solidity: function initialize(address _token) returns() +func (_AgentRegistry *AgentRegistryTransactorSession) Initialize(_token common.Address) (*types.Transaction, error) { + return _AgentRegistry.Contract.Initialize(&_AgentRegistry.TransactOpts, _token) +} + +// Register is a paid mutator transaction binding the contract method 0xcca4cb64. +// +// Solidity: function register(uint256 addStake, uint256 fee, address owner, bytes32 agentId, string name, string[] tags) returns() +func (_AgentRegistry *AgentRegistryTransactor) Register(opts *bind.TransactOpts, addStake *big.Int, fee *big.Int, owner common.Address, agentId [32]byte, name string, tags []string) (*types.Transaction, error) { + return _AgentRegistry.contract.Transact(opts, "register", addStake, fee, owner, agentId, name, tags) +} + +// Register is a paid mutator transaction binding the contract method 0xcca4cb64. +// +// Solidity: function register(uint256 addStake, uint256 fee, address owner, bytes32 agentId, string name, string[] tags) returns() +func (_AgentRegistry *AgentRegistrySession) Register(addStake *big.Int, fee *big.Int, owner common.Address, agentId [32]byte, name string, tags []string) (*types.Transaction, error) { + return _AgentRegistry.Contract.Register(&_AgentRegistry.TransactOpts, addStake, fee, owner, agentId, name, tags) +} + +// Register is a paid mutator transaction binding the contract method 0xcca4cb64. +// +// Solidity: function register(uint256 addStake, uint256 fee, address owner, bytes32 agentId, string name, string[] tags) returns() +func (_AgentRegistry *AgentRegistryTransactorSession) Register(addStake *big.Int, fee *big.Int, owner common.Address, agentId [32]byte, name string, tags []string) (*types.Transaction, error) { + return _AgentRegistry.Contract.Register(&_AgentRegistry.TransactOpts, addStake, fee, owner, agentId, name, tags) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_AgentRegistry *AgentRegistryTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { + return _AgentRegistry.contract.Transact(opts, "renounceOwnership") +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_AgentRegistry *AgentRegistrySession) RenounceOwnership() (*types.Transaction, error) { + return _AgentRegistry.Contract.RenounceOwnership(&_AgentRegistry.TransactOpts) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_AgentRegistry *AgentRegistryTransactorSession) RenounceOwnership() (*types.Transaction, error) { + return _AgentRegistry.Contract.RenounceOwnership(&_AgentRegistry.TransactOpts) +} + +// SetMinStake is a paid mutator transaction binding the contract method 0x8c80fd90. +// +// Solidity: function setMinStake(uint256 _minStake) returns() +func (_AgentRegistry *AgentRegistryTransactor) SetMinStake(opts *bind.TransactOpts, _minStake *big.Int) (*types.Transaction, error) { + return _AgentRegistry.contract.Transact(opts, "setMinStake", _minStake) +} + +// SetMinStake is a paid mutator transaction binding the contract method 0x8c80fd90. +// +// Solidity: function setMinStake(uint256 _minStake) returns() +func (_AgentRegistry *AgentRegistrySession) SetMinStake(_minStake *big.Int) (*types.Transaction, error) { + return _AgentRegistry.Contract.SetMinStake(&_AgentRegistry.TransactOpts, _minStake) +} + +// SetMinStake is a paid mutator transaction binding the contract method 0x8c80fd90. +// +// Solidity: function setMinStake(uint256 _minStake) returns() +func (_AgentRegistry *AgentRegistryTransactorSession) SetMinStake(_minStake *big.Int) (*types.Transaction, error) { + return _AgentRegistry.Contract.SetMinStake(&_AgentRegistry.TransactOpts, _minStake) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_AgentRegistry *AgentRegistryTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) { + return _AgentRegistry.contract.Transact(opts, "transferOwnership", newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_AgentRegistry *AgentRegistrySession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _AgentRegistry.Contract.TransferOwnership(&_AgentRegistry.TransactOpts, newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_AgentRegistry *AgentRegistryTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _AgentRegistry.Contract.TransferOwnership(&_AgentRegistry.TransactOpts, newOwner) +} + +// AgentRegistryDeregisteredIterator is returned from FilterDeregistered and is used to iterate over the raw logs and unpacked data for Deregistered events raised by the AgentRegistry contract. +type AgentRegistryDeregisteredIterator struct { + Event *AgentRegistryDeregistered // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *AgentRegistryDeregisteredIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(AgentRegistryDeregistered) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(AgentRegistryDeregistered) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *AgentRegistryDeregisteredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *AgentRegistryDeregisteredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// AgentRegistryDeregistered represents a Deregistered event raised by the AgentRegistry contract. +type AgentRegistryDeregistered struct { + Owner common.Address + AgentId [32]byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterDeregistered is a free log retrieval operation binding the contract event 0xcc0d8d49cb9a5a3eebc1e1f0b607b8aad83fbe9618e448df79b8a0cc33319472. +// +// Solidity: event Deregistered(address indexed owner, bytes32 indexed agentId) +func (_AgentRegistry *AgentRegistryFilterer) FilterDeregistered(opts *bind.FilterOpts, owner []common.Address, agentId [][32]byte) (*AgentRegistryDeregisteredIterator, error) { + + var ownerRule []interface{} + for _, ownerItem := range owner { + ownerRule = append(ownerRule, ownerItem) + } + var agentIdRule []interface{} + for _, agentIdItem := range agentId { + agentIdRule = append(agentIdRule, agentIdItem) + } + + logs, sub, err := _AgentRegistry.contract.FilterLogs(opts, "Deregistered", ownerRule, agentIdRule) + if err != nil { + return nil, err + } + return &AgentRegistryDeregisteredIterator{contract: _AgentRegistry.contract, event: "Deregistered", logs: logs, sub: sub}, nil +} + +// WatchDeregistered is a free log subscription operation binding the contract event 0xcc0d8d49cb9a5a3eebc1e1f0b607b8aad83fbe9618e448df79b8a0cc33319472. +// +// Solidity: event Deregistered(address indexed owner, bytes32 indexed agentId) +func (_AgentRegistry *AgentRegistryFilterer) WatchDeregistered(opts *bind.WatchOpts, sink chan<- *AgentRegistryDeregistered, owner []common.Address, agentId [][32]byte) (event.Subscription, error) { + + var ownerRule []interface{} + for _, ownerItem := range owner { + ownerRule = append(ownerRule, ownerItem) + } + var agentIdRule []interface{} + for _, agentIdItem := range agentId { + agentIdRule = append(agentIdRule, agentIdItem) + } + + logs, sub, err := _AgentRegistry.contract.WatchLogs(opts, "Deregistered", ownerRule, agentIdRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(AgentRegistryDeregistered) + if err := _AgentRegistry.contract.UnpackLog(event, "Deregistered", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseDeregistered is a log parse operation binding the contract event 0xcc0d8d49cb9a5a3eebc1e1f0b607b8aad83fbe9618e448df79b8a0cc33319472. +// +// Solidity: event Deregistered(address indexed owner, bytes32 indexed agentId) +func (_AgentRegistry *AgentRegistryFilterer) ParseDeregistered(log types.Log) (*AgentRegistryDeregistered, error) { + event := new(AgentRegistryDeregistered) + if err := _AgentRegistry.contract.UnpackLog(event, "Deregistered", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// AgentRegistryInitializedIterator is returned from FilterInitialized and is used to iterate over the raw logs and unpacked data for Initialized events raised by the AgentRegistry contract. +type AgentRegistryInitializedIterator struct { + Event *AgentRegistryInitialized // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *AgentRegistryInitializedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(AgentRegistryInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(AgentRegistryInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *AgentRegistryInitializedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *AgentRegistryInitializedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// AgentRegistryInitialized represents a Initialized event raised by the AgentRegistry contract. +type AgentRegistryInitialized struct { + Version uint8 + Raw types.Log // Blockchain specific contextual infos +} + +// FilterInitialized is a free log retrieval operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_AgentRegistry *AgentRegistryFilterer) FilterInitialized(opts *bind.FilterOpts) (*AgentRegistryInitializedIterator, error) { + + logs, sub, err := _AgentRegistry.contract.FilterLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return &AgentRegistryInitializedIterator{contract: _AgentRegistry.contract, event: "Initialized", logs: logs, sub: sub}, nil +} + +// WatchInitialized is a free log subscription operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_AgentRegistry *AgentRegistryFilterer) WatchInitialized(opts *bind.WatchOpts, sink chan<- *AgentRegistryInitialized) (event.Subscription, error) { + + logs, sub, err := _AgentRegistry.contract.WatchLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(AgentRegistryInitialized) + if err := _AgentRegistry.contract.UnpackLog(event, "Initialized", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseInitialized is a log parse operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_AgentRegistry *AgentRegistryFilterer) ParseInitialized(log types.Log) (*AgentRegistryInitialized, error) { + event := new(AgentRegistryInitialized) + if err := _AgentRegistry.contract.UnpackLog(event, "Initialized", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// AgentRegistryMinStakeUpdatedIterator is returned from FilterMinStakeUpdated and is used to iterate over the raw logs and unpacked data for MinStakeUpdated events raised by the AgentRegistry contract. +type AgentRegistryMinStakeUpdatedIterator struct { + Event *AgentRegistryMinStakeUpdated // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *AgentRegistryMinStakeUpdatedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(AgentRegistryMinStakeUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(AgentRegistryMinStakeUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *AgentRegistryMinStakeUpdatedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *AgentRegistryMinStakeUpdatedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// AgentRegistryMinStakeUpdated represents a MinStakeUpdated event raised by the AgentRegistry contract. +type AgentRegistryMinStakeUpdated struct { + NewStake *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterMinStakeUpdated is a free log retrieval operation binding the contract event 0x47ab46f2c8d4258304a2f5551c1cbdb6981be49631365d1ba7191288a73f39ef. +// +// Solidity: event MinStakeUpdated(uint256 newStake) +func (_AgentRegistry *AgentRegistryFilterer) FilterMinStakeUpdated(opts *bind.FilterOpts) (*AgentRegistryMinStakeUpdatedIterator, error) { + + logs, sub, err := _AgentRegistry.contract.FilterLogs(opts, "MinStakeUpdated") + if err != nil { + return nil, err + } + return &AgentRegistryMinStakeUpdatedIterator{contract: _AgentRegistry.contract, event: "MinStakeUpdated", logs: logs, sub: sub}, nil +} + +// WatchMinStakeUpdated is a free log subscription operation binding the contract event 0x47ab46f2c8d4258304a2f5551c1cbdb6981be49631365d1ba7191288a73f39ef. +// +// Solidity: event MinStakeUpdated(uint256 newStake) +func (_AgentRegistry *AgentRegistryFilterer) WatchMinStakeUpdated(opts *bind.WatchOpts, sink chan<- *AgentRegistryMinStakeUpdated) (event.Subscription, error) { + + logs, sub, err := _AgentRegistry.contract.WatchLogs(opts, "MinStakeUpdated") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(AgentRegistryMinStakeUpdated) + if err := _AgentRegistry.contract.UnpackLog(event, "MinStakeUpdated", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseMinStakeUpdated is a log parse operation binding the contract event 0x47ab46f2c8d4258304a2f5551c1cbdb6981be49631365d1ba7191288a73f39ef. +// +// Solidity: event MinStakeUpdated(uint256 newStake) +func (_AgentRegistry *AgentRegistryFilterer) ParseMinStakeUpdated(log types.Log) (*AgentRegistryMinStakeUpdated, error) { + event := new(AgentRegistryMinStakeUpdated) + if err := _AgentRegistry.contract.UnpackLog(event, "MinStakeUpdated", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// AgentRegistryOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the AgentRegistry contract. +type AgentRegistryOwnershipTransferredIterator struct { + Event *AgentRegistryOwnershipTransferred // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *AgentRegistryOwnershipTransferredIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(AgentRegistryOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(AgentRegistryOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *AgentRegistryOwnershipTransferredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *AgentRegistryOwnershipTransferredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// AgentRegistryOwnershipTransferred represents a OwnershipTransferred event raised by the AgentRegistry contract. +type AgentRegistryOwnershipTransferred struct { + PreviousOwner common.Address + NewOwner common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_AgentRegistry *AgentRegistryFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*AgentRegistryOwnershipTransferredIterator, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _AgentRegistry.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return &AgentRegistryOwnershipTransferredIterator{contract: _AgentRegistry.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil +} + +// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_AgentRegistry *AgentRegistryFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *AgentRegistryOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _AgentRegistry.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(AgentRegistryOwnershipTransferred) + if err := _AgentRegistry.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_AgentRegistry *AgentRegistryFilterer) ParseOwnershipTransferred(log types.Log) (*AgentRegistryOwnershipTransferred, error) { + event := new(AgentRegistryOwnershipTransferred) + if err := _AgentRegistry.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// AgentRegistryRegisteredUpdatedIterator is returned from FilterRegisteredUpdated and is used to iterate over the raw logs and unpacked data for RegisteredUpdated events raised by the AgentRegistry contract. +type AgentRegistryRegisteredUpdatedIterator struct { + Event *AgentRegistryRegisteredUpdated // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *AgentRegistryRegisteredUpdatedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(AgentRegistryRegisteredUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(AgentRegistryRegisteredUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *AgentRegistryRegisteredUpdatedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *AgentRegistryRegisteredUpdatedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// AgentRegistryRegisteredUpdated represents a RegisteredUpdated event raised by the AgentRegistry contract. +type AgentRegistryRegisteredUpdated struct { + Owner common.Address + AgentId [32]byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterRegisteredUpdated is a free log retrieval operation binding the contract event 0x4dffc4e92367641816479c647d1ff3f03202f6c73b97340cba51a7b577c55804. +// +// Solidity: event RegisteredUpdated(address indexed owner, bytes32 indexed agentId) +func (_AgentRegistry *AgentRegistryFilterer) FilterRegisteredUpdated(opts *bind.FilterOpts, owner []common.Address, agentId [][32]byte) (*AgentRegistryRegisteredUpdatedIterator, error) { + + var ownerRule []interface{} + for _, ownerItem := range owner { + ownerRule = append(ownerRule, ownerItem) + } + var agentIdRule []interface{} + for _, agentIdItem := range agentId { + agentIdRule = append(agentIdRule, agentIdItem) + } + + logs, sub, err := _AgentRegistry.contract.FilterLogs(opts, "RegisteredUpdated", ownerRule, agentIdRule) + if err != nil { + return nil, err + } + return &AgentRegistryRegisteredUpdatedIterator{contract: _AgentRegistry.contract, event: "RegisteredUpdated", logs: logs, sub: sub}, nil +} + +// WatchRegisteredUpdated is a free log subscription operation binding the contract event 0x4dffc4e92367641816479c647d1ff3f03202f6c73b97340cba51a7b577c55804. +// +// Solidity: event RegisteredUpdated(address indexed owner, bytes32 indexed agentId) +func (_AgentRegistry *AgentRegistryFilterer) WatchRegisteredUpdated(opts *bind.WatchOpts, sink chan<- *AgentRegistryRegisteredUpdated, owner []common.Address, agentId [][32]byte) (event.Subscription, error) { + + var ownerRule []interface{} + for _, ownerItem := range owner { + ownerRule = append(ownerRule, ownerItem) + } + var agentIdRule []interface{} + for _, agentIdItem := range agentId { + agentIdRule = append(agentIdRule, agentIdItem) + } + + logs, sub, err := _AgentRegistry.contract.WatchLogs(opts, "RegisteredUpdated", ownerRule, agentIdRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(AgentRegistryRegisteredUpdated) + if err := _AgentRegistry.contract.UnpackLog(event, "RegisteredUpdated", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseRegisteredUpdated is a log parse operation binding the contract event 0x4dffc4e92367641816479c647d1ff3f03202f6c73b97340cba51a7b577c55804. +// +// Solidity: event RegisteredUpdated(address indexed owner, bytes32 indexed agentId) +func (_AgentRegistry *AgentRegistryFilterer) ParseRegisteredUpdated(log types.Log) (*AgentRegistryRegisteredUpdated, error) { + event := new(AgentRegistryRegisteredUpdated) + if err := _AgentRegistry.contract.UnpackLog(event, "RegisteredUpdated", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/proxy-router/contracts/marketplace/Marketplace.go b/proxy-router/contracts/marketplace/Marketplace.go new file mode 100644 index 00000000..28c8ad3b --- /dev/null +++ b/proxy-router/contracts/marketplace/Marketplace.go @@ -0,0 +1,1474 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package marketplace + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// MarketplaceBid is an auto generated low-level Go binding around an user-defined struct. +type MarketplaceBid struct { + Provider common.Address + ModelAgentId [32]byte + Amount *big.Int + Nonce *big.Int + CreatedAt *big.Int + DeletedAt *big.Int +} + +// MarketplaceMetaData contains all meta data concerning the Marketplace contract. +var MarketplaceMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[],\"name\":\"ActiveBidNotFound\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"KeyExists\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"KeyNotFound\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ModelOrAgentNotFound\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotEnoughWithdrawableBalance\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotSenderOrOwner\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ZeroKey\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"modelAgentId\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"name\":\"BidDeleted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"modelAgentId\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"name\":\"BidPosted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"modelFee\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"agentFee\",\"type\":\"uint256\"}],\"name\":\"FeeUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"agentBidFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"bidId\",\"type\":\"bytes32\"}],\"name\":\"deleteModelAgentBid\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"modelAgentId\",\"type\":\"bytes32\"}],\"name\":\"getActiveBidsByModelAgent\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"modelAgentId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"createdAt\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deletedAt\",\"type\":\"uint256\"}],\"internalType\":\"structMarketplace.Bid[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"}],\"name\":\"getActiveBidsByProvider\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"modelAgentId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"createdAt\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deletedAt\",\"type\":\"uint256\"}],\"internalType\":\"structMarketplace.Bid[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"modelAgentId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"offset\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"limit\",\"type\":\"uint8\"}],\"name\":\"getBidsByModelAgent\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"modelAgentId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"createdAt\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deletedAt\",\"type\":\"uint256\"}],\"internalType\":\"structMarketplace.Bid[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"offset\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"limit\",\"type\":\"uint8\"}],\"name\":\"getBidsByProvider\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"modelAgentId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"createdAt\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deletedAt\",\"type\":\"uint256\"}],\"internalType\":\"structMarketplace.Bid[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"modelRegistryAddr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"providerRegistryAddr\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"map\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"modelAgentId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"createdAt\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deletedAt\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"modelBidFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"modelRegistry\",\"outputs\":[{\"internalType\":\"contractModelRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"providerAddr\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"modelId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"postModelBid\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"bidId\",\"type\":\"bytes32\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"providerModelAgentNonce\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"providerRegistry\",\"outputs\":[{\"internalType\":\"contractProviderRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"modelFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"agentFee\",\"type\":\"uint256\"}],\"name\":\"setBidFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"token\",\"outputs\":[{\"internalType\":\"contractERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"withdraw\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", +} + +// MarketplaceABI is the input ABI used to generate the binding from. +// Deprecated: Use MarketplaceMetaData.ABI instead. +var MarketplaceABI = MarketplaceMetaData.ABI + +// Marketplace is an auto generated Go binding around an Ethereum contract. +type Marketplace struct { + MarketplaceCaller // Read-only binding to the contract + MarketplaceTransactor // Write-only binding to the contract + MarketplaceFilterer // Log filterer for contract events +} + +// MarketplaceCaller is an auto generated read-only Go binding around an Ethereum contract. +type MarketplaceCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// MarketplaceTransactor is an auto generated write-only Go binding around an Ethereum contract. +type MarketplaceTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// MarketplaceFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type MarketplaceFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// MarketplaceSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type MarketplaceSession struct { + Contract *Marketplace // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// MarketplaceCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type MarketplaceCallerSession struct { + Contract *MarketplaceCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// MarketplaceTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type MarketplaceTransactorSession struct { + Contract *MarketplaceTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// MarketplaceRaw is an auto generated low-level Go binding around an Ethereum contract. +type MarketplaceRaw struct { + Contract *Marketplace // Generic contract binding to access the raw methods on +} + +// MarketplaceCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type MarketplaceCallerRaw struct { + Contract *MarketplaceCaller // Generic read-only contract binding to access the raw methods on +} + +// MarketplaceTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type MarketplaceTransactorRaw struct { + Contract *MarketplaceTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewMarketplace creates a new instance of Marketplace, bound to a specific deployed contract. +func NewMarketplace(address common.Address, backend bind.ContractBackend) (*Marketplace, error) { + contract, err := bindMarketplace(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &Marketplace{MarketplaceCaller: MarketplaceCaller{contract: contract}, MarketplaceTransactor: MarketplaceTransactor{contract: contract}, MarketplaceFilterer: MarketplaceFilterer{contract: contract}}, nil +} + +// NewMarketplaceCaller creates a new read-only instance of Marketplace, bound to a specific deployed contract. +func NewMarketplaceCaller(address common.Address, caller bind.ContractCaller) (*MarketplaceCaller, error) { + contract, err := bindMarketplace(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &MarketplaceCaller{contract: contract}, nil +} + +// NewMarketplaceTransactor creates a new write-only instance of Marketplace, bound to a specific deployed contract. +func NewMarketplaceTransactor(address common.Address, transactor bind.ContractTransactor) (*MarketplaceTransactor, error) { + contract, err := bindMarketplace(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &MarketplaceTransactor{contract: contract}, nil +} + +// NewMarketplaceFilterer creates a new log filterer instance of Marketplace, bound to a specific deployed contract. +func NewMarketplaceFilterer(address common.Address, filterer bind.ContractFilterer) (*MarketplaceFilterer, error) { + contract, err := bindMarketplace(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &MarketplaceFilterer{contract: contract}, nil +} + +// bindMarketplace binds a generic wrapper to an already deployed contract. +func bindMarketplace(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := MarketplaceMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_Marketplace *MarketplaceRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Marketplace.Contract.MarketplaceCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_Marketplace *MarketplaceRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Marketplace.Contract.MarketplaceTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Marketplace *MarketplaceRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Marketplace.Contract.MarketplaceTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_Marketplace *MarketplaceCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Marketplace.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_Marketplace *MarketplaceTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Marketplace.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Marketplace *MarketplaceTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Marketplace.Contract.contract.Transact(opts, method, params...) +} + +// AgentBidFee is a free data retrieval call binding the contract method 0x113d91c9. +// +// Solidity: function agentBidFee() view returns(uint256) +func (_Marketplace *MarketplaceCaller) AgentBidFee(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _Marketplace.contract.Call(opts, &out, "agentBidFee") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// AgentBidFee is a free data retrieval call binding the contract method 0x113d91c9. +// +// Solidity: function agentBidFee() view returns(uint256) +func (_Marketplace *MarketplaceSession) AgentBidFee() (*big.Int, error) { + return _Marketplace.Contract.AgentBidFee(&_Marketplace.CallOpts) +} + +// AgentBidFee is a free data retrieval call binding the contract method 0x113d91c9. +// +// Solidity: function agentBidFee() view returns(uint256) +func (_Marketplace *MarketplaceCallerSession) AgentBidFee() (*big.Int, error) { + return _Marketplace.Contract.AgentBidFee(&_Marketplace.CallOpts) +} + +// GetActiveBidsByModelAgent is a free data retrieval call binding the contract method 0x873d94d5. +// +// Solidity: function getActiveBidsByModelAgent(bytes32 modelAgentId) view returns((address,bytes32,uint256,uint256,uint256,uint256)[]) +func (_Marketplace *MarketplaceCaller) GetActiveBidsByModelAgent(opts *bind.CallOpts, modelAgentId [32]byte) ([]MarketplaceBid, error) { + var out []interface{} + err := _Marketplace.contract.Call(opts, &out, "getActiveBidsByModelAgent", modelAgentId) + + if err != nil { + return *new([]MarketplaceBid), err + } + + out0 := *abi.ConvertType(out[0], new([]MarketplaceBid)).(*[]MarketplaceBid) + + return out0, err + +} + +// GetActiveBidsByModelAgent is a free data retrieval call binding the contract method 0x873d94d5. +// +// Solidity: function getActiveBidsByModelAgent(bytes32 modelAgentId) view returns((address,bytes32,uint256,uint256,uint256,uint256)[]) +func (_Marketplace *MarketplaceSession) GetActiveBidsByModelAgent(modelAgentId [32]byte) ([]MarketplaceBid, error) { + return _Marketplace.Contract.GetActiveBidsByModelAgent(&_Marketplace.CallOpts, modelAgentId) +} + +// GetActiveBidsByModelAgent is a free data retrieval call binding the contract method 0x873d94d5. +// +// Solidity: function getActiveBidsByModelAgent(bytes32 modelAgentId) view returns((address,bytes32,uint256,uint256,uint256,uint256)[]) +func (_Marketplace *MarketplaceCallerSession) GetActiveBidsByModelAgent(modelAgentId [32]byte) ([]MarketplaceBid, error) { + return _Marketplace.Contract.GetActiveBidsByModelAgent(&_Marketplace.CallOpts, modelAgentId) +} + +// GetActiveBidsByProvider is a free data retrieval call binding the contract method 0x9fdaffd0. +// +// Solidity: function getActiveBidsByProvider(address provider) view returns((address,bytes32,uint256,uint256,uint256,uint256)[]) +func (_Marketplace *MarketplaceCaller) GetActiveBidsByProvider(opts *bind.CallOpts, provider common.Address) ([]MarketplaceBid, error) { + var out []interface{} + err := _Marketplace.contract.Call(opts, &out, "getActiveBidsByProvider", provider) + + if err != nil { + return *new([]MarketplaceBid), err + } + + out0 := *abi.ConvertType(out[0], new([]MarketplaceBid)).(*[]MarketplaceBid) + + return out0, err + +} + +// GetActiveBidsByProvider is a free data retrieval call binding the contract method 0x9fdaffd0. +// +// Solidity: function getActiveBidsByProvider(address provider) view returns((address,bytes32,uint256,uint256,uint256,uint256)[]) +func (_Marketplace *MarketplaceSession) GetActiveBidsByProvider(provider common.Address) ([]MarketplaceBid, error) { + return _Marketplace.Contract.GetActiveBidsByProvider(&_Marketplace.CallOpts, provider) +} + +// GetActiveBidsByProvider is a free data retrieval call binding the contract method 0x9fdaffd0. +// +// Solidity: function getActiveBidsByProvider(address provider) view returns((address,bytes32,uint256,uint256,uint256,uint256)[]) +func (_Marketplace *MarketplaceCallerSession) GetActiveBidsByProvider(provider common.Address) ([]MarketplaceBid, error) { + return _Marketplace.Contract.GetActiveBidsByProvider(&_Marketplace.CallOpts, provider) +} + +// GetBidsByModelAgent is a free data retrieval call binding the contract method 0xa87665ec. +// +// Solidity: function getBidsByModelAgent(bytes32 modelAgentId, uint256 offset, uint8 limit) view returns((address,bytes32,uint256,uint256,uint256,uint256)[]) +func (_Marketplace *MarketplaceCaller) GetBidsByModelAgent(opts *bind.CallOpts, modelAgentId [32]byte, offset *big.Int, limit uint8) ([]MarketplaceBid, error) { + var out []interface{} + err := _Marketplace.contract.Call(opts, &out, "getBidsByModelAgent", modelAgentId, offset, limit) + + if err != nil { + return *new([]MarketplaceBid), err + } + + out0 := *abi.ConvertType(out[0], new([]MarketplaceBid)).(*[]MarketplaceBid) + + return out0, err + +} + +// GetBidsByModelAgent is a free data retrieval call binding the contract method 0xa87665ec. +// +// Solidity: function getBidsByModelAgent(bytes32 modelAgentId, uint256 offset, uint8 limit) view returns((address,bytes32,uint256,uint256,uint256,uint256)[]) +func (_Marketplace *MarketplaceSession) GetBidsByModelAgent(modelAgentId [32]byte, offset *big.Int, limit uint8) ([]MarketplaceBid, error) { + return _Marketplace.Contract.GetBidsByModelAgent(&_Marketplace.CallOpts, modelAgentId, offset, limit) +} + +// GetBidsByModelAgent is a free data retrieval call binding the contract method 0xa87665ec. +// +// Solidity: function getBidsByModelAgent(bytes32 modelAgentId, uint256 offset, uint8 limit) view returns((address,bytes32,uint256,uint256,uint256,uint256)[]) +func (_Marketplace *MarketplaceCallerSession) GetBidsByModelAgent(modelAgentId [32]byte, offset *big.Int, limit uint8) ([]MarketplaceBid, error) { + return _Marketplace.Contract.GetBidsByModelAgent(&_Marketplace.CallOpts, modelAgentId, offset, limit) +} + +// GetBidsByProvider is a free data retrieval call binding the contract method 0x2f817685. +// +// Solidity: function getBidsByProvider(address provider, uint256 offset, uint8 limit) view returns((address,bytes32,uint256,uint256,uint256,uint256)[]) +func (_Marketplace *MarketplaceCaller) GetBidsByProvider(opts *bind.CallOpts, provider common.Address, offset *big.Int, limit uint8) ([]MarketplaceBid, error) { + var out []interface{} + err := _Marketplace.contract.Call(opts, &out, "getBidsByProvider", provider, offset, limit) + + if err != nil { + return *new([]MarketplaceBid), err + } + + out0 := *abi.ConvertType(out[0], new([]MarketplaceBid)).(*[]MarketplaceBid) + + return out0, err + +} + +// GetBidsByProvider is a free data retrieval call binding the contract method 0x2f817685. +// +// Solidity: function getBidsByProvider(address provider, uint256 offset, uint8 limit) view returns((address,bytes32,uint256,uint256,uint256,uint256)[]) +func (_Marketplace *MarketplaceSession) GetBidsByProvider(provider common.Address, offset *big.Int, limit uint8) ([]MarketplaceBid, error) { + return _Marketplace.Contract.GetBidsByProvider(&_Marketplace.CallOpts, provider, offset, limit) +} + +// GetBidsByProvider is a free data retrieval call binding the contract method 0x2f817685. +// +// Solidity: function getBidsByProvider(address provider, uint256 offset, uint8 limit) view returns((address,bytes32,uint256,uint256,uint256,uint256)[]) +func (_Marketplace *MarketplaceCallerSession) GetBidsByProvider(provider common.Address, offset *big.Int, limit uint8) ([]MarketplaceBid, error) { + return _Marketplace.Contract.GetBidsByProvider(&_Marketplace.CallOpts, provider, offset, limit) +} + +// Map is a free data retrieval call binding the contract method 0x0ae186a8. +// +// Solidity: function map(bytes32 ) view returns(address provider, bytes32 modelAgentId, uint256 amount, uint256 nonce, uint256 createdAt, uint256 deletedAt) +func (_Marketplace *MarketplaceCaller) Map(opts *bind.CallOpts, arg0 [32]byte) (struct { + Provider common.Address + ModelAgentId [32]byte + Amount *big.Int + Nonce *big.Int + CreatedAt *big.Int + DeletedAt *big.Int +}, error) { + var out []interface{} + err := _Marketplace.contract.Call(opts, &out, "map", arg0) + + outstruct := new(struct { + Provider common.Address + ModelAgentId [32]byte + Amount *big.Int + Nonce *big.Int + CreatedAt *big.Int + DeletedAt *big.Int + }) + if err != nil { + return *outstruct, err + } + + outstruct.Provider = *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + outstruct.ModelAgentId = *abi.ConvertType(out[1], new([32]byte)).(*[32]byte) + outstruct.Amount = *abi.ConvertType(out[2], new(*big.Int)).(**big.Int) + outstruct.Nonce = *abi.ConvertType(out[3], new(*big.Int)).(**big.Int) + outstruct.CreatedAt = *abi.ConvertType(out[4], new(*big.Int)).(**big.Int) + outstruct.DeletedAt = *abi.ConvertType(out[5], new(*big.Int)).(**big.Int) + + return *outstruct, err + +} + +// Map is a free data retrieval call binding the contract method 0x0ae186a8. +// +// Solidity: function map(bytes32 ) view returns(address provider, bytes32 modelAgentId, uint256 amount, uint256 nonce, uint256 createdAt, uint256 deletedAt) +func (_Marketplace *MarketplaceSession) Map(arg0 [32]byte) (struct { + Provider common.Address + ModelAgentId [32]byte + Amount *big.Int + Nonce *big.Int + CreatedAt *big.Int + DeletedAt *big.Int +}, error) { + return _Marketplace.Contract.Map(&_Marketplace.CallOpts, arg0) +} + +// Map is a free data retrieval call binding the contract method 0x0ae186a8. +// +// Solidity: function map(bytes32 ) view returns(address provider, bytes32 modelAgentId, uint256 amount, uint256 nonce, uint256 createdAt, uint256 deletedAt) +func (_Marketplace *MarketplaceCallerSession) Map(arg0 [32]byte) (struct { + Provider common.Address + ModelAgentId [32]byte + Amount *big.Int + Nonce *big.Int + CreatedAt *big.Int + DeletedAt *big.Int +}, error) { + return _Marketplace.Contract.Map(&_Marketplace.CallOpts, arg0) +} + +// ModelBidFee is a free data retrieval call binding the contract method 0x7c785e73. +// +// Solidity: function modelBidFee() view returns(uint256) +func (_Marketplace *MarketplaceCaller) ModelBidFee(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _Marketplace.contract.Call(opts, &out, "modelBidFee") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// ModelBidFee is a free data retrieval call binding the contract method 0x7c785e73. +// +// Solidity: function modelBidFee() view returns(uint256) +func (_Marketplace *MarketplaceSession) ModelBidFee() (*big.Int, error) { + return _Marketplace.Contract.ModelBidFee(&_Marketplace.CallOpts) +} + +// ModelBidFee is a free data retrieval call binding the contract method 0x7c785e73. +// +// Solidity: function modelBidFee() view returns(uint256) +func (_Marketplace *MarketplaceCallerSession) ModelBidFee() (*big.Int, error) { + return _Marketplace.Contract.ModelBidFee(&_Marketplace.CallOpts) +} + +// ModelRegistry is a free data retrieval call binding the contract method 0x2ba36f78. +// +// Solidity: function modelRegistry() view returns(address) +func (_Marketplace *MarketplaceCaller) ModelRegistry(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Marketplace.contract.Call(opts, &out, "modelRegistry") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// ModelRegistry is a free data retrieval call binding the contract method 0x2ba36f78. +// +// Solidity: function modelRegistry() view returns(address) +func (_Marketplace *MarketplaceSession) ModelRegistry() (common.Address, error) { + return _Marketplace.Contract.ModelRegistry(&_Marketplace.CallOpts) +} + +// ModelRegistry is a free data retrieval call binding the contract method 0x2ba36f78. +// +// Solidity: function modelRegistry() view returns(address) +func (_Marketplace *MarketplaceCallerSession) ModelRegistry() (common.Address, error) { + return _Marketplace.Contract.ModelRegistry(&_Marketplace.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_Marketplace *MarketplaceCaller) Owner(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Marketplace.contract.Call(opts, &out, "owner") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_Marketplace *MarketplaceSession) Owner() (common.Address, error) { + return _Marketplace.Contract.Owner(&_Marketplace.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_Marketplace *MarketplaceCallerSession) Owner() (common.Address, error) { + return _Marketplace.Contract.Owner(&_Marketplace.CallOpts) +} + +// ProviderModelAgentNonce is a free data retrieval call binding the contract method 0x93ec6bc5. +// +// Solidity: function providerModelAgentNonce(bytes32 ) view returns(uint256) +func (_Marketplace *MarketplaceCaller) ProviderModelAgentNonce(opts *bind.CallOpts, arg0 [32]byte) (*big.Int, error) { + var out []interface{} + err := _Marketplace.contract.Call(opts, &out, "providerModelAgentNonce", arg0) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// ProviderModelAgentNonce is a free data retrieval call binding the contract method 0x93ec6bc5. +// +// Solidity: function providerModelAgentNonce(bytes32 ) view returns(uint256) +func (_Marketplace *MarketplaceSession) ProviderModelAgentNonce(arg0 [32]byte) (*big.Int, error) { + return _Marketplace.Contract.ProviderModelAgentNonce(&_Marketplace.CallOpts, arg0) +} + +// ProviderModelAgentNonce is a free data retrieval call binding the contract method 0x93ec6bc5. +// +// Solidity: function providerModelAgentNonce(bytes32 ) view returns(uint256) +func (_Marketplace *MarketplaceCallerSession) ProviderModelAgentNonce(arg0 [32]byte) (*big.Int, error) { + return _Marketplace.Contract.ProviderModelAgentNonce(&_Marketplace.CallOpts, arg0) +} + +// ProviderRegistry is a free data retrieval call binding the contract method 0x545921d9. +// +// Solidity: function providerRegistry() view returns(address) +func (_Marketplace *MarketplaceCaller) ProviderRegistry(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Marketplace.contract.Call(opts, &out, "providerRegistry") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// ProviderRegistry is a free data retrieval call binding the contract method 0x545921d9. +// +// Solidity: function providerRegistry() view returns(address) +func (_Marketplace *MarketplaceSession) ProviderRegistry() (common.Address, error) { + return _Marketplace.Contract.ProviderRegistry(&_Marketplace.CallOpts) +} + +// ProviderRegistry is a free data retrieval call binding the contract method 0x545921d9. +// +// Solidity: function providerRegistry() view returns(address) +func (_Marketplace *MarketplaceCallerSession) ProviderRegistry() (common.Address, error) { + return _Marketplace.Contract.ProviderRegistry(&_Marketplace.CallOpts) +} + +// Token is a free data retrieval call binding the contract method 0xfc0c546a. +// +// Solidity: function token() view returns(address) +func (_Marketplace *MarketplaceCaller) Token(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Marketplace.contract.Call(opts, &out, "token") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Token is a free data retrieval call binding the contract method 0xfc0c546a. +// +// Solidity: function token() view returns(address) +func (_Marketplace *MarketplaceSession) Token() (common.Address, error) { + return _Marketplace.Contract.Token(&_Marketplace.CallOpts) +} + +// Token is a free data retrieval call binding the contract method 0xfc0c546a. +// +// Solidity: function token() view returns(address) +func (_Marketplace *MarketplaceCallerSession) Token() (common.Address, error) { + return _Marketplace.Contract.Token(&_Marketplace.CallOpts) +} + +// DeleteModelAgentBid is a paid mutator transaction binding the contract method 0x42856b75. +// +// Solidity: function deleteModelAgentBid(bytes32 bidId) returns() +func (_Marketplace *MarketplaceTransactor) DeleteModelAgentBid(opts *bind.TransactOpts, bidId [32]byte) (*types.Transaction, error) { + return _Marketplace.contract.Transact(opts, "deleteModelAgentBid", bidId) +} + +// DeleteModelAgentBid is a paid mutator transaction binding the contract method 0x42856b75. +// +// Solidity: function deleteModelAgentBid(bytes32 bidId) returns() +func (_Marketplace *MarketplaceSession) DeleteModelAgentBid(bidId [32]byte) (*types.Transaction, error) { + return _Marketplace.Contract.DeleteModelAgentBid(&_Marketplace.TransactOpts, bidId) +} + +// DeleteModelAgentBid is a paid mutator transaction binding the contract method 0x42856b75. +// +// Solidity: function deleteModelAgentBid(bytes32 bidId) returns() +func (_Marketplace *MarketplaceTransactorSession) DeleteModelAgentBid(bidId [32]byte) (*types.Transaction, error) { + return _Marketplace.Contract.DeleteModelAgentBid(&_Marketplace.TransactOpts, bidId) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc0c53b8b. +// +// Solidity: function initialize(address _token, address modelRegistryAddr, address providerRegistryAddr) returns() +func (_Marketplace *MarketplaceTransactor) Initialize(opts *bind.TransactOpts, _token common.Address, modelRegistryAddr common.Address, providerRegistryAddr common.Address) (*types.Transaction, error) { + return _Marketplace.contract.Transact(opts, "initialize", _token, modelRegistryAddr, providerRegistryAddr) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc0c53b8b. +// +// Solidity: function initialize(address _token, address modelRegistryAddr, address providerRegistryAddr) returns() +func (_Marketplace *MarketplaceSession) Initialize(_token common.Address, modelRegistryAddr common.Address, providerRegistryAddr common.Address) (*types.Transaction, error) { + return _Marketplace.Contract.Initialize(&_Marketplace.TransactOpts, _token, modelRegistryAddr, providerRegistryAddr) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc0c53b8b. +// +// Solidity: function initialize(address _token, address modelRegistryAddr, address providerRegistryAddr) returns() +func (_Marketplace *MarketplaceTransactorSession) Initialize(_token common.Address, modelRegistryAddr common.Address, providerRegistryAddr common.Address) (*types.Transaction, error) { + return _Marketplace.Contract.Initialize(&_Marketplace.TransactOpts, _token, modelRegistryAddr, providerRegistryAddr) +} + +// PostModelBid is a paid mutator transaction binding the contract method 0xede96bb1. +// +// Solidity: function postModelBid(address providerAddr, bytes32 modelId, uint256 amount) returns(bytes32 bidId) +func (_Marketplace *MarketplaceTransactor) PostModelBid(opts *bind.TransactOpts, providerAddr common.Address, modelId [32]byte, amount *big.Int) (*types.Transaction, error) { + return _Marketplace.contract.Transact(opts, "postModelBid", providerAddr, modelId, amount) +} + +// PostModelBid is a paid mutator transaction binding the contract method 0xede96bb1. +// +// Solidity: function postModelBid(address providerAddr, bytes32 modelId, uint256 amount) returns(bytes32 bidId) +func (_Marketplace *MarketplaceSession) PostModelBid(providerAddr common.Address, modelId [32]byte, amount *big.Int) (*types.Transaction, error) { + return _Marketplace.Contract.PostModelBid(&_Marketplace.TransactOpts, providerAddr, modelId, amount) +} + +// PostModelBid is a paid mutator transaction binding the contract method 0xede96bb1. +// +// Solidity: function postModelBid(address providerAddr, bytes32 modelId, uint256 amount) returns(bytes32 bidId) +func (_Marketplace *MarketplaceTransactorSession) PostModelBid(providerAddr common.Address, modelId [32]byte, amount *big.Int) (*types.Transaction, error) { + return _Marketplace.Contract.PostModelBid(&_Marketplace.TransactOpts, providerAddr, modelId, amount) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_Marketplace *MarketplaceTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Marketplace.contract.Transact(opts, "renounceOwnership") +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_Marketplace *MarketplaceSession) RenounceOwnership() (*types.Transaction, error) { + return _Marketplace.Contract.RenounceOwnership(&_Marketplace.TransactOpts) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_Marketplace *MarketplaceTransactorSession) RenounceOwnership() (*types.Transaction, error) { + return _Marketplace.Contract.RenounceOwnership(&_Marketplace.TransactOpts) +} + +// SetBidFee is a paid mutator transaction binding the contract method 0xcef0b7f4. +// +// Solidity: function setBidFee(uint256 modelFee, uint256 agentFee) returns() +func (_Marketplace *MarketplaceTransactor) SetBidFee(opts *bind.TransactOpts, modelFee *big.Int, agentFee *big.Int) (*types.Transaction, error) { + return _Marketplace.contract.Transact(opts, "setBidFee", modelFee, agentFee) +} + +// SetBidFee is a paid mutator transaction binding the contract method 0xcef0b7f4. +// +// Solidity: function setBidFee(uint256 modelFee, uint256 agentFee) returns() +func (_Marketplace *MarketplaceSession) SetBidFee(modelFee *big.Int, agentFee *big.Int) (*types.Transaction, error) { + return _Marketplace.Contract.SetBidFee(&_Marketplace.TransactOpts, modelFee, agentFee) +} + +// SetBidFee is a paid mutator transaction binding the contract method 0xcef0b7f4. +// +// Solidity: function setBidFee(uint256 modelFee, uint256 agentFee) returns() +func (_Marketplace *MarketplaceTransactorSession) SetBidFee(modelFee *big.Int, agentFee *big.Int) (*types.Transaction, error) { + return _Marketplace.Contract.SetBidFee(&_Marketplace.TransactOpts, modelFee, agentFee) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_Marketplace *MarketplaceTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) { + return _Marketplace.contract.Transact(opts, "transferOwnership", newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_Marketplace *MarketplaceSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _Marketplace.Contract.TransferOwnership(&_Marketplace.TransactOpts, newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_Marketplace *MarketplaceTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _Marketplace.Contract.TransferOwnership(&_Marketplace.TransactOpts, newOwner) +} + +// Withdraw is a paid mutator transaction binding the contract method 0xf3fef3a3. +// +// Solidity: function withdraw(address addr, uint256 amount) returns() +func (_Marketplace *MarketplaceTransactor) Withdraw(opts *bind.TransactOpts, addr common.Address, amount *big.Int) (*types.Transaction, error) { + return _Marketplace.contract.Transact(opts, "withdraw", addr, amount) +} + +// Withdraw is a paid mutator transaction binding the contract method 0xf3fef3a3. +// +// Solidity: function withdraw(address addr, uint256 amount) returns() +func (_Marketplace *MarketplaceSession) Withdraw(addr common.Address, amount *big.Int) (*types.Transaction, error) { + return _Marketplace.Contract.Withdraw(&_Marketplace.TransactOpts, addr, amount) +} + +// Withdraw is a paid mutator transaction binding the contract method 0xf3fef3a3. +// +// Solidity: function withdraw(address addr, uint256 amount) returns() +func (_Marketplace *MarketplaceTransactorSession) Withdraw(addr common.Address, amount *big.Int) (*types.Transaction, error) { + return _Marketplace.Contract.Withdraw(&_Marketplace.TransactOpts, addr, amount) +} + +// MarketplaceBidDeletedIterator is returned from FilterBidDeleted and is used to iterate over the raw logs and unpacked data for BidDeleted events raised by the Marketplace contract. +type MarketplaceBidDeletedIterator struct { + Event *MarketplaceBidDeleted // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *MarketplaceBidDeletedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(MarketplaceBidDeleted) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(MarketplaceBidDeleted) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *MarketplaceBidDeletedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *MarketplaceBidDeletedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// MarketplaceBidDeleted represents a BidDeleted event raised by the Marketplace contract. +type MarketplaceBidDeleted struct { + Provider common.Address + ModelAgentId [32]byte + Nonce *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterBidDeleted is a free log retrieval operation binding the contract event 0x096f970f504563bca8ac4419b4299946965221e396c34aea149ac84947b9242f. +// +// Solidity: event BidDeleted(address indexed provider, bytes32 indexed modelAgentId, uint256 nonce) +func (_Marketplace *MarketplaceFilterer) FilterBidDeleted(opts *bind.FilterOpts, provider []common.Address, modelAgentId [][32]byte) (*MarketplaceBidDeletedIterator, error) { + + var providerRule []interface{} + for _, providerItem := range provider { + providerRule = append(providerRule, providerItem) + } + var modelAgentIdRule []interface{} + for _, modelAgentIdItem := range modelAgentId { + modelAgentIdRule = append(modelAgentIdRule, modelAgentIdItem) + } + + logs, sub, err := _Marketplace.contract.FilterLogs(opts, "BidDeleted", providerRule, modelAgentIdRule) + if err != nil { + return nil, err + } + return &MarketplaceBidDeletedIterator{contract: _Marketplace.contract, event: "BidDeleted", logs: logs, sub: sub}, nil +} + +// WatchBidDeleted is a free log subscription operation binding the contract event 0x096f970f504563bca8ac4419b4299946965221e396c34aea149ac84947b9242f. +// +// Solidity: event BidDeleted(address indexed provider, bytes32 indexed modelAgentId, uint256 nonce) +func (_Marketplace *MarketplaceFilterer) WatchBidDeleted(opts *bind.WatchOpts, sink chan<- *MarketplaceBidDeleted, provider []common.Address, modelAgentId [][32]byte) (event.Subscription, error) { + + var providerRule []interface{} + for _, providerItem := range provider { + providerRule = append(providerRule, providerItem) + } + var modelAgentIdRule []interface{} + for _, modelAgentIdItem := range modelAgentId { + modelAgentIdRule = append(modelAgentIdRule, modelAgentIdItem) + } + + logs, sub, err := _Marketplace.contract.WatchLogs(opts, "BidDeleted", providerRule, modelAgentIdRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(MarketplaceBidDeleted) + if err := _Marketplace.contract.UnpackLog(event, "BidDeleted", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseBidDeleted is a log parse operation binding the contract event 0x096f970f504563bca8ac4419b4299946965221e396c34aea149ac84947b9242f. +// +// Solidity: event BidDeleted(address indexed provider, bytes32 indexed modelAgentId, uint256 nonce) +func (_Marketplace *MarketplaceFilterer) ParseBidDeleted(log types.Log) (*MarketplaceBidDeleted, error) { + event := new(MarketplaceBidDeleted) + if err := _Marketplace.contract.UnpackLog(event, "BidDeleted", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// MarketplaceBidPostedIterator is returned from FilterBidPosted and is used to iterate over the raw logs and unpacked data for BidPosted events raised by the Marketplace contract. +type MarketplaceBidPostedIterator struct { + Event *MarketplaceBidPosted // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *MarketplaceBidPostedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(MarketplaceBidPosted) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(MarketplaceBidPosted) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *MarketplaceBidPostedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *MarketplaceBidPostedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// MarketplaceBidPosted represents a BidPosted event raised by the Marketplace contract. +type MarketplaceBidPosted struct { + Provider common.Address + ModelAgentId [32]byte + Nonce *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterBidPosted is a free log retrieval operation binding the contract event 0xd138adff73af2621d26114cd9ee4f20dcd39ed78f9e0004215ed49aa22753ebe. +// +// Solidity: event BidPosted(address indexed provider, bytes32 indexed modelAgentId, uint256 nonce) +func (_Marketplace *MarketplaceFilterer) FilterBidPosted(opts *bind.FilterOpts, provider []common.Address, modelAgentId [][32]byte) (*MarketplaceBidPostedIterator, error) { + + var providerRule []interface{} + for _, providerItem := range provider { + providerRule = append(providerRule, providerItem) + } + var modelAgentIdRule []interface{} + for _, modelAgentIdItem := range modelAgentId { + modelAgentIdRule = append(modelAgentIdRule, modelAgentIdItem) + } + + logs, sub, err := _Marketplace.contract.FilterLogs(opts, "BidPosted", providerRule, modelAgentIdRule) + if err != nil { + return nil, err + } + return &MarketplaceBidPostedIterator{contract: _Marketplace.contract, event: "BidPosted", logs: logs, sub: sub}, nil +} + +// WatchBidPosted is a free log subscription operation binding the contract event 0xd138adff73af2621d26114cd9ee4f20dcd39ed78f9e0004215ed49aa22753ebe. +// +// Solidity: event BidPosted(address indexed provider, bytes32 indexed modelAgentId, uint256 nonce) +func (_Marketplace *MarketplaceFilterer) WatchBidPosted(opts *bind.WatchOpts, sink chan<- *MarketplaceBidPosted, provider []common.Address, modelAgentId [][32]byte) (event.Subscription, error) { + + var providerRule []interface{} + for _, providerItem := range provider { + providerRule = append(providerRule, providerItem) + } + var modelAgentIdRule []interface{} + for _, modelAgentIdItem := range modelAgentId { + modelAgentIdRule = append(modelAgentIdRule, modelAgentIdItem) + } + + logs, sub, err := _Marketplace.contract.WatchLogs(opts, "BidPosted", providerRule, modelAgentIdRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(MarketplaceBidPosted) + if err := _Marketplace.contract.UnpackLog(event, "BidPosted", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseBidPosted is a log parse operation binding the contract event 0xd138adff73af2621d26114cd9ee4f20dcd39ed78f9e0004215ed49aa22753ebe. +// +// Solidity: event BidPosted(address indexed provider, bytes32 indexed modelAgentId, uint256 nonce) +func (_Marketplace *MarketplaceFilterer) ParseBidPosted(log types.Log) (*MarketplaceBidPosted, error) { + event := new(MarketplaceBidPosted) + if err := _Marketplace.contract.UnpackLog(event, "BidPosted", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// MarketplaceFeeUpdatedIterator is returned from FilterFeeUpdated and is used to iterate over the raw logs and unpacked data for FeeUpdated events raised by the Marketplace contract. +type MarketplaceFeeUpdatedIterator struct { + Event *MarketplaceFeeUpdated // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *MarketplaceFeeUpdatedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(MarketplaceFeeUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(MarketplaceFeeUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *MarketplaceFeeUpdatedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *MarketplaceFeeUpdatedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// MarketplaceFeeUpdated represents a FeeUpdated event raised by the Marketplace contract. +type MarketplaceFeeUpdated struct { + ModelFee *big.Int + AgentFee *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterFeeUpdated is a free log retrieval operation binding the contract event 0x528d9479e9f9889a87a3c30c7f7ba537e5e59c4c85a37733b16e57c62df61302. +// +// Solidity: event FeeUpdated(uint256 modelFee, uint256 agentFee) +func (_Marketplace *MarketplaceFilterer) FilterFeeUpdated(opts *bind.FilterOpts) (*MarketplaceFeeUpdatedIterator, error) { + + logs, sub, err := _Marketplace.contract.FilterLogs(opts, "FeeUpdated") + if err != nil { + return nil, err + } + return &MarketplaceFeeUpdatedIterator{contract: _Marketplace.contract, event: "FeeUpdated", logs: logs, sub: sub}, nil +} + +// WatchFeeUpdated is a free log subscription operation binding the contract event 0x528d9479e9f9889a87a3c30c7f7ba537e5e59c4c85a37733b16e57c62df61302. +// +// Solidity: event FeeUpdated(uint256 modelFee, uint256 agentFee) +func (_Marketplace *MarketplaceFilterer) WatchFeeUpdated(opts *bind.WatchOpts, sink chan<- *MarketplaceFeeUpdated) (event.Subscription, error) { + + logs, sub, err := _Marketplace.contract.WatchLogs(opts, "FeeUpdated") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(MarketplaceFeeUpdated) + if err := _Marketplace.contract.UnpackLog(event, "FeeUpdated", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseFeeUpdated is a log parse operation binding the contract event 0x528d9479e9f9889a87a3c30c7f7ba537e5e59c4c85a37733b16e57c62df61302. +// +// Solidity: event FeeUpdated(uint256 modelFee, uint256 agentFee) +func (_Marketplace *MarketplaceFilterer) ParseFeeUpdated(log types.Log) (*MarketplaceFeeUpdated, error) { + event := new(MarketplaceFeeUpdated) + if err := _Marketplace.contract.UnpackLog(event, "FeeUpdated", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// MarketplaceInitializedIterator is returned from FilterInitialized and is used to iterate over the raw logs and unpacked data for Initialized events raised by the Marketplace contract. +type MarketplaceInitializedIterator struct { + Event *MarketplaceInitialized // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *MarketplaceInitializedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(MarketplaceInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(MarketplaceInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *MarketplaceInitializedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *MarketplaceInitializedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// MarketplaceInitialized represents a Initialized event raised by the Marketplace contract. +type MarketplaceInitialized struct { + Version uint8 + Raw types.Log // Blockchain specific contextual infos +} + +// FilterInitialized is a free log retrieval operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_Marketplace *MarketplaceFilterer) FilterInitialized(opts *bind.FilterOpts) (*MarketplaceInitializedIterator, error) { + + logs, sub, err := _Marketplace.contract.FilterLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return &MarketplaceInitializedIterator{contract: _Marketplace.contract, event: "Initialized", logs: logs, sub: sub}, nil +} + +// WatchInitialized is a free log subscription operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_Marketplace *MarketplaceFilterer) WatchInitialized(opts *bind.WatchOpts, sink chan<- *MarketplaceInitialized) (event.Subscription, error) { + + logs, sub, err := _Marketplace.contract.WatchLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(MarketplaceInitialized) + if err := _Marketplace.contract.UnpackLog(event, "Initialized", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseInitialized is a log parse operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_Marketplace *MarketplaceFilterer) ParseInitialized(log types.Log) (*MarketplaceInitialized, error) { + event := new(MarketplaceInitialized) + if err := _Marketplace.contract.UnpackLog(event, "Initialized", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// MarketplaceOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the Marketplace contract. +type MarketplaceOwnershipTransferredIterator struct { + Event *MarketplaceOwnershipTransferred // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *MarketplaceOwnershipTransferredIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(MarketplaceOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(MarketplaceOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *MarketplaceOwnershipTransferredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *MarketplaceOwnershipTransferredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// MarketplaceOwnershipTransferred represents a OwnershipTransferred event raised by the Marketplace contract. +type MarketplaceOwnershipTransferred struct { + PreviousOwner common.Address + NewOwner common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_Marketplace *MarketplaceFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*MarketplaceOwnershipTransferredIterator, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _Marketplace.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return &MarketplaceOwnershipTransferredIterator{contract: _Marketplace.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil +} + +// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_Marketplace *MarketplaceFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *MarketplaceOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _Marketplace.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(MarketplaceOwnershipTransferred) + if err := _Marketplace.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_Marketplace *MarketplaceFilterer) ParseOwnershipTransferred(log types.Log) (*MarketplaceOwnershipTransferred, error) { + event := new(MarketplaceOwnershipTransferred) + if err := _Marketplace.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/proxy-router/contracts/modelregistry/ModelRegistry.go b/proxy-router/contracts/modelregistry/ModelRegistry.go new file mode 100644 index 00000000..50b23bed --- /dev/null +++ b/proxy-router/contracts/modelregistry/ModelRegistry.go @@ -0,0 +1,1409 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package modelregistry + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// ModelRegistryModel is an auto generated low-level Go binding around an user-defined struct. +type ModelRegistryModel struct { + IpfsCID [32]byte + Fee *big.Int + Stake *big.Int + Owner common.Address + Name string + Tags []string + Timestamp *big.Int + IsDeleted bool +} + +// ModelRegistryMetaData contains all meta data concerning the ModelRegistry contract. +var ModelRegistryMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[],\"name\":\"KeyExists\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"KeyNotFound\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ModelNotFound\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotSenderOrOwner\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"StakeTooLow\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ZeroKey\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"modelId\",\"type\":\"bytes32\"}],\"name\":\"Deregistered\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newStake\",\"type\":\"uint256\"}],\"name\":\"MinStakeUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"modelId\",\"type\":\"bytes32\"}],\"name\":\"RegisteredUpdated\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"id\",\"type\":\"bytes32\"}],\"name\":\"deregister\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"id\",\"type\":\"bytes32\"}],\"name\":\"exists\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAll\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"ipfsCID\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"stake\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string[]\",\"name\":\"tags\",\"type\":\"string[]\"},{\"internalType\":\"uint128\",\"name\":\"timestamp\",\"type\":\"uint128\"},{\"internalType\":\"bool\",\"name\":\"isDeleted\",\"type\":\"bool\"}],\"internalType\":\"structModelRegistry.Model[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getByIndex\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"modelId\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"ipfsCID\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"stake\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string[]\",\"name\":\"tags\",\"type\":\"string[]\"},{\"internalType\":\"uint128\",\"name\":\"timestamp\",\"type\":\"uint128\"},{\"internalType\":\"bool\",\"name\":\"isDeleted\",\"type\":\"bool\"}],\"internalType\":\"structModelRegistry.Model\",\"name\":\"model\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"count\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getIds\",\"outputs\":[{\"internalType\":\"bytes32[]\",\"name\":\"\",\"type\":\"bytes32[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"map\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"ipfsCID\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"stake\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"uint128\",\"name\":\"timestamp\",\"type\":\"uint128\"},{\"internalType\":\"bool\",\"name\":\"isDeleted\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minStake\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"models\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"modelId\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"ipfsCID\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"addStake\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string[]\",\"name\":\"tags\",\"type\":\"string[]\"}],\"name\":\"register\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_minStake\",\"type\":\"uint256\"}],\"name\":\"setMinStake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"token\",\"outputs\":[{\"internalType\":\"contractERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", +} + +// ModelRegistryABI is the input ABI used to generate the binding from. +// Deprecated: Use ModelRegistryMetaData.ABI instead. +var ModelRegistryABI = ModelRegistryMetaData.ABI + +// ModelRegistry is an auto generated Go binding around an Ethereum contract. +type ModelRegistry struct { + ModelRegistryCaller // Read-only binding to the contract + ModelRegistryTransactor // Write-only binding to the contract + ModelRegistryFilterer // Log filterer for contract events +} + +// ModelRegistryCaller is an auto generated read-only Go binding around an Ethereum contract. +type ModelRegistryCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ModelRegistryTransactor is an auto generated write-only Go binding around an Ethereum contract. +type ModelRegistryTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ModelRegistryFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type ModelRegistryFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ModelRegistrySession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type ModelRegistrySession struct { + Contract *ModelRegistry // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// ModelRegistryCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type ModelRegistryCallerSession struct { + Contract *ModelRegistryCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// ModelRegistryTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type ModelRegistryTransactorSession struct { + Contract *ModelRegistryTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// ModelRegistryRaw is an auto generated low-level Go binding around an Ethereum contract. +type ModelRegistryRaw struct { + Contract *ModelRegistry // Generic contract binding to access the raw methods on +} + +// ModelRegistryCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type ModelRegistryCallerRaw struct { + Contract *ModelRegistryCaller // Generic read-only contract binding to access the raw methods on +} + +// ModelRegistryTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type ModelRegistryTransactorRaw struct { + Contract *ModelRegistryTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewModelRegistry creates a new instance of ModelRegistry, bound to a specific deployed contract. +func NewModelRegistry(address common.Address, backend bind.ContractBackend) (*ModelRegistry, error) { + contract, err := bindModelRegistry(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &ModelRegistry{ModelRegistryCaller: ModelRegistryCaller{contract: contract}, ModelRegistryTransactor: ModelRegistryTransactor{contract: contract}, ModelRegistryFilterer: ModelRegistryFilterer{contract: contract}}, nil +} + +// NewModelRegistryCaller creates a new read-only instance of ModelRegistry, bound to a specific deployed contract. +func NewModelRegistryCaller(address common.Address, caller bind.ContractCaller) (*ModelRegistryCaller, error) { + contract, err := bindModelRegistry(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &ModelRegistryCaller{contract: contract}, nil +} + +// NewModelRegistryTransactor creates a new write-only instance of ModelRegistry, bound to a specific deployed contract. +func NewModelRegistryTransactor(address common.Address, transactor bind.ContractTransactor) (*ModelRegistryTransactor, error) { + contract, err := bindModelRegistry(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &ModelRegistryTransactor{contract: contract}, nil +} + +// NewModelRegistryFilterer creates a new log filterer instance of ModelRegistry, bound to a specific deployed contract. +func NewModelRegistryFilterer(address common.Address, filterer bind.ContractFilterer) (*ModelRegistryFilterer, error) { + contract, err := bindModelRegistry(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &ModelRegistryFilterer{contract: contract}, nil +} + +// bindModelRegistry binds a generic wrapper to an already deployed contract. +func bindModelRegistry(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := ModelRegistryMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_ModelRegistry *ModelRegistryRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _ModelRegistry.Contract.ModelRegistryCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_ModelRegistry *ModelRegistryRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ModelRegistry.Contract.ModelRegistryTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_ModelRegistry *ModelRegistryRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _ModelRegistry.Contract.ModelRegistryTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_ModelRegistry *ModelRegistryCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _ModelRegistry.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_ModelRegistry *ModelRegistryTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ModelRegistry.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_ModelRegistry *ModelRegistryTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _ModelRegistry.Contract.contract.Transact(opts, method, params...) +} + +// Exists is a free data retrieval call binding the contract method 0x38a699a4. +// +// Solidity: function exists(bytes32 id) view returns(bool) +func (_ModelRegistry *ModelRegistryCaller) Exists(opts *bind.CallOpts, id [32]byte) (bool, error) { + var out []interface{} + err := _ModelRegistry.contract.Call(opts, &out, "exists", id) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// Exists is a free data retrieval call binding the contract method 0x38a699a4. +// +// Solidity: function exists(bytes32 id) view returns(bool) +func (_ModelRegistry *ModelRegistrySession) Exists(id [32]byte) (bool, error) { + return _ModelRegistry.Contract.Exists(&_ModelRegistry.CallOpts, id) +} + +// Exists is a free data retrieval call binding the contract method 0x38a699a4. +// +// Solidity: function exists(bytes32 id) view returns(bool) +func (_ModelRegistry *ModelRegistryCallerSession) Exists(id [32]byte) (bool, error) { + return _ModelRegistry.Contract.Exists(&_ModelRegistry.CallOpts, id) +} + +// GetAll is a free data retrieval call binding the contract method 0x53ed5143. +// +// Solidity: function getAll() view returns((bytes32,uint256,uint256,address,string,string[],uint128,bool)[]) +func (_ModelRegistry *ModelRegistryCaller) GetAll(opts *bind.CallOpts) ([]ModelRegistryModel, error) { + var out []interface{} + err := _ModelRegistry.contract.Call(opts, &out, "getAll") + + if err != nil { + return *new([]ModelRegistryModel), err + } + + out0 := *abi.ConvertType(out[0], new([]ModelRegistryModel)).(*[]ModelRegistryModel) + + return out0, err + +} + +// GetAll is a free data retrieval call binding the contract method 0x53ed5143. +// +// Solidity: function getAll() view returns((bytes32,uint256,uint256,address,string,string[],uint128,bool)[]) +func (_ModelRegistry *ModelRegistrySession) GetAll() ([]ModelRegistryModel, error) { + return _ModelRegistry.Contract.GetAll(&_ModelRegistry.CallOpts) +} + +// GetAll is a free data retrieval call binding the contract method 0x53ed5143. +// +// Solidity: function getAll() view returns((bytes32,uint256,uint256,address,string,string[],uint128,bool)[]) +func (_ModelRegistry *ModelRegistryCallerSession) GetAll() ([]ModelRegistryModel, error) { + return _ModelRegistry.Contract.GetAll(&_ModelRegistry.CallOpts) +} + +// GetByIndex is a free data retrieval call binding the contract method 0x2d883a73. +// +// Solidity: function getByIndex(uint256 index) view returns(bytes32 modelId, (bytes32,uint256,uint256,address,string,string[],uint128,bool) model) +func (_ModelRegistry *ModelRegistryCaller) GetByIndex(opts *bind.CallOpts, index *big.Int) (struct { + ModelId [32]byte + Model ModelRegistryModel +}, error) { + var out []interface{} + err := _ModelRegistry.contract.Call(opts, &out, "getByIndex", index) + + outstruct := new(struct { + ModelId [32]byte + Model ModelRegistryModel + }) + if err != nil { + return *outstruct, err + } + + outstruct.ModelId = *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + outstruct.Model = *abi.ConvertType(out[1], new(ModelRegistryModel)).(*ModelRegistryModel) + + return *outstruct, err + +} + +// GetByIndex is a free data retrieval call binding the contract method 0x2d883a73. +// +// Solidity: function getByIndex(uint256 index) view returns(bytes32 modelId, (bytes32,uint256,uint256,address,string,string[],uint128,bool) model) +func (_ModelRegistry *ModelRegistrySession) GetByIndex(index *big.Int) (struct { + ModelId [32]byte + Model ModelRegistryModel +}, error) { + return _ModelRegistry.Contract.GetByIndex(&_ModelRegistry.CallOpts, index) +} + +// GetByIndex is a free data retrieval call binding the contract method 0x2d883a73. +// +// Solidity: function getByIndex(uint256 index) view returns(bytes32 modelId, (bytes32,uint256,uint256,address,string,string[],uint128,bool) model) +func (_ModelRegistry *ModelRegistryCallerSession) GetByIndex(index *big.Int) (struct { + ModelId [32]byte + Model ModelRegistryModel +}, error) { + return _ModelRegistry.Contract.GetByIndex(&_ModelRegistry.CallOpts, index) +} + +// GetCount is a free data retrieval call binding the contract method 0xa87d942c. +// +// Solidity: function getCount() view returns(uint256 count) +func (_ModelRegistry *ModelRegistryCaller) GetCount(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _ModelRegistry.contract.Call(opts, &out, "getCount") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetCount is a free data retrieval call binding the contract method 0xa87d942c. +// +// Solidity: function getCount() view returns(uint256 count) +func (_ModelRegistry *ModelRegistrySession) GetCount() (*big.Int, error) { + return _ModelRegistry.Contract.GetCount(&_ModelRegistry.CallOpts) +} + +// GetCount is a free data retrieval call binding the contract method 0xa87d942c. +// +// Solidity: function getCount() view returns(uint256 count) +func (_ModelRegistry *ModelRegistryCallerSession) GetCount() (*big.Int, error) { + return _ModelRegistry.Contract.GetCount(&_ModelRegistry.CallOpts) +} + +// GetIds is a free data retrieval call binding the contract method 0x2b105663. +// +// Solidity: function getIds() view returns(bytes32[]) +func (_ModelRegistry *ModelRegistryCaller) GetIds(opts *bind.CallOpts) ([][32]byte, error) { + var out []interface{} + err := _ModelRegistry.contract.Call(opts, &out, "getIds") + + if err != nil { + return *new([][32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([][32]byte)).(*[][32]byte) + + return out0, err + +} + +// GetIds is a free data retrieval call binding the contract method 0x2b105663. +// +// Solidity: function getIds() view returns(bytes32[]) +func (_ModelRegistry *ModelRegistrySession) GetIds() ([][32]byte, error) { + return _ModelRegistry.Contract.GetIds(&_ModelRegistry.CallOpts) +} + +// GetIds is a free data retrieval call binding the contract method 0x2b105663. +// +// Solidity: function getIds() view returns(bytes32[]) +func (_ModelRegistry *ModelRegistryCallerSession) GetIds() ([][32]byte, error) { + return _ModelRegistry.Contract.GetIds(&_ModelRegistry.CallOpts) +} + +// Map is a free data retrieval call binding the contract method 0x0ae186a8. +// +// Solidity: function map(bytes32 ) view returns(bytes32 ipfsCID, uint256 fee, uint256 stake, address owner, string name, uint128 timestamp, bool isDeleted) +func (_ModelRegistry *ModelRegistryCaller) Map(opts *bind.CallOpts, arg0 [32]byte) (struct { + IpfsCID [32]byte + Fee *big.Int + Stake *big.Int + Owner common.Address + Name string + Timestamp *big.Int + IsDeleted bool +}, error) { + var out []interface{} + err := _ModelRegistry.contract.Call(opts, &out, "map", arg0) + + outstruct := new(struct { + IpfsCID [32]byte + Fee *big.Int + Stake *big.Int + Owner common.Address + Name string + Timestamp *big.Int + IsDeleted bool + }) + if err != nil { + return *outstruct, err + } + + outstruct.IpfsCID = *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + outstruct.Fee = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) + outstruct.Stake = *abi.ConvertType(out[2], new(*big.Int)).(**big.Int) + outstruct.Owner = *abi.ConvertType(out[3], new(common.Address)).(*common.Address) + outstruct.Name = *abi.ConvertType(out[4], new(string)).(*string) + outstruct.Timestamp = *abi.ConvertType(out[5], new(*big.Int)).(**big.Int) + outstruct.IsDeleted = *abi.ConvertType(out[6], new(bool)).(*bool) + + return *outstruct, err + +} + +// Map is a free data retrieval call binding the contract method 0x0ae186a8. +// +// Solidity: function map(bytes32 ) view returns(bytes32 ipfsCID, uint256 fee, uint256 stake, address owner, string name, uint128 timestamp, bool isDeleted) +func (_ModelRegistry *ModelRegistrySession) Map(arg0 [32]byte) (struct { + IpfsCID [32]byte + Fee *big.Int + Stake *big.Int + Owner common.Address + Name string + Timestamp *big.Int + IsDeleted bool +}, error) { + return _ModelRegistry.Contract.Map(&_ModelRegistry.CallOpts, arg0) +} + +// Map is a free data retrieval call binding the contract method 0x0ae186a8. +// +// Solidity: function map(bytes32 ) view returns(bytes32 ipfsCID, uint256 fee, uint256 stake, address owner, string name, uint128 timestamp, bool isDeleted) +func (_ModelRegistry *ModelRegistryCallerSession) Map(arg0 [32]byte) (struct { + IpfsCID [32]byte + Fee *big.Int + Stake *big.Int + Owner common.Address + Name string + Timestamp *big.Int + IsDeleted bool +}, error) { + return _ModelRegistry.Contract.Map(&_ModelRegistry.CallOpts, arg0) +} + +// MinStake is a free data retrieval call binding the contract method 0x375b3c0a. +// +// Solidity: function minStake() view returns(uint256) +func (_ModelRegistry *ModelRegistryCaller) MinStake(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _ModelRegistry.contract.Call(opts, &out, "minStake") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// MinStake is a free data retrieval call binding the contract method 0x375b3c0a. +// +// Solidity: function minStake() view returns(uint256) +func (_ModelRegistry *ModelRegistrySession) MinStake() (*big.Int, error) { + return _ModelRegistry.Contract.MinStake(&_ModelRegistry.CallOpts) +} + +// MinStake is a free data retrieval call binding the contract method 0x375b3c0a. +// +// Solidity: function minStake() view returns(uint256) +func (_ModelRegistry *ModelRegistryCallerSession) MinStake() (*big.Int, error) { + return _ModelRegistry.Contract.MinStake(&_ModelRegistry.CallOpts) +} + +// Models is a free data retrieval call binding the contract method 0x6a030ca9. +// +// Solidity: function models(uint256 ) view returns(bytes32) +func (_ModelRegistry *ModelRegistryCaller) Models(opts *bind.CallOpts, arg0 *big.Int) ([32]byte, error) { + var out []interface{} + err := _ModelRegistry.contract.Call(opts, &out, "models", arg0) + + if err != nil { + return *new([32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + + return out0, err + +} + +// Models is a free data retrieval call binding the contract method 0x6a030ca9. +// +// Solidity: function models(uint256 ) view returns(bytes32) +func (_ModelRegistry *ModelRegistrySession) Models(arg0 *big.Int) ([32]byte, error) { + return _ModelRegistry.Contract.Models(&_ModelRegistry.CallOpts, arg0) +} + +// Models is a free data retrieval call binding the contract method 0x6a030ca9. +// +// Solidity: function models(uint256 ) view returns(bytes32) +func (_ModelRegistry *ModelRegistryCallerSession) Models(arg0 *big.Int) ([32]byte, error) { + return _ModelRegistry.Contract.Models(&_ModelRegistry.CallOpts, arg0) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_ModelRegistry *ModelRegistryCaller) Owner(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _ModelRegistry.contract.Call(opts, &out, "owner") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_ModelRegistry *ModelRegistrySession) Owner() (common.Address, error) { + return _ModelRegistry.Contract.Owner(&_ModelRegistry.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_ModelRegistry *ModelRegistryCallerSession) Owner() (common.Address, error) { + return _ModelRegistry.Contract.Owner(&_ModelRegistry.CallOpts) +} + +// Token is a free data retrieval call binding the contract method 0xfc0c546a. +// +// Solidity: function token() view returns(address) +func (_ModelRegistry *ModelRegistryCaller) Token(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _ModelRegistry.contract.Call(opts, &out, "token") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Token is a free data retrieval call binding the contract method 0xfc0c546a. +// +// Solidity: function token() view returns(address) +func (_ModelRegistry *ModelRegistrySession) Token() (common.Address, error) { + return _ModelRegistry.Contract.Token(&_ModelRegistry.CallOpts) +} + +// Token is a free data retrieval call binding the contract method 0xfc0c546a. +// +// Solidity: function token() view returns(address) +func (_ModelRegistry *ModelRegistryCallerSession) Token() (common.Address, error) { + return _ModelRegistry.Contract.Token(&_ModelRegistry.CallOpts) +} + +// Deregister is a paid mutator transaction binding the contract method 0x20813154. +// +// Solidity: function deregister(bytes32 id) returns() +func (_ModelRegistry *ModelRegistryTransactor) Deregister(opts *bind.TransactOpts, id [32]byte) (*types.Transaction, error) { + return _ModelRegistry.contract.Transact(opts, "deregister", id) +} + +// Deregister is a paid mutator transaction binding the contract method 0x20813154. +// +// Solidity: function deregister(bytes32 id) returns() +func (_ModelRegistry *ModelRegistrySession) Deregister(id [32]byte) (*types.Transaction, error) { + return _ModelRegistry.Contract.Deregister(&_ModelRegistry.TransactOpts, id) +} + +// Deregister is a paid mutator transaction binding the contract method 0x20813154. +// +// Solidity: function deregister(bytes32 id) returns() +func (_ModelRegistry *ModelRegistryTransactorSession) Deregister(id [32]byte) (*types.Transaction, error) { + return _ModelRegistry.Contract.Deregister(&_ModelRegistry.TransactOpts, id) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc4d66de8. +// +// Solidity: function initialize(address _token) returns() +func (_ModelRegistry *ModelRegistryTransactor) Initialize(opts *bind.TransactOpts, _token common.Address) (*types.Transaction, error) { + return _ModelRegistry.contract.Transact(opts, "initialize", _token) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc4d66de8. +// +// Solidity: function initialize(address _token) returns() +func (_ModelRegistry *ModelRegistrySession) Initialize(_token common.Address) (*types.Transaction, error) { + return _ModelRegistry.Contract.Initialize(&_ModelRegistry.TransactOpts, _token) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc4d66de8. +// +// Solidity: function initialize(address _token) returns() +func (_ModelRegistry *ModelRegistryTransactorSession) Initialize(_token common.Address) (*types.Transaction, error) { + return _ModelRegistry.Contract.Initialize(&_ModelRegistry.TransactOpts, _token) +} + +// Register is a paid mutator transaction binding the contract method 0x9e4aaa05. +// +// Solidity: function register(bytes32 modelId, bytes32 ipfsCID, uint256 fee, uint256 addStake, address owner, string name, string[] tags) returns() +func (_ModelRegistry *ModelRegistryTransactor) Register(opts *bind.TransactOpts, modelId [32]byte, ipfsCID [32]byte, fee *big.Int, addStake *big.Int, owner common.Address, name string, tags []string) (*types.Transaction, error) { + return _ModelRegistry.contract.Transact(opts, "register", modelId, ipfsCID, fee, addStake, owner, name, tags) +} + +// Register is a paid mutator transaction binding the contract method 0x9e4aaa05. +// +// Solidity: function register(bytes32 modelId, bytes32 ipfsCID, uint256 fee, uint256 addStake, address owner, string name, string[] tags) returns() +func (_ModelRegistry *ModelRegistrySession) Register(modelId [32]byte, ipfsCID [32]byte, fee *big.Int, addStake *big.Int, owner common.Address, name string, tags []string) (*types.Transaction, error) { + return _ModelRegistry.Contract.Register(&_ModelRegistry.TransactOpts, modelId, ipfsCID, fee, addStake, owner, name, tags) +} + +// Register is a paid mutator transaction binding the contract method 0x9e4aaa05. +// +// Solidity: function register(bytes32 modelId, bytes32 ipfsCID, uint256 fee, uint256 addStake, address owner, string name, string[] tags) returns() +func (_ModelRegistry *ModelRegistryTransactorSession) Register(modelId [32]byte, ipfsCID [32]byte, fee *big.Int, addStake *big.Int, owner common.Address, name string, tags []string) (*types.Transaction, error) { + return _ModelRegistry.Contract.Register(&_ModelRegistry.TransactOpts, modelId, ipfsCID, fee, addStake, owner, name, tags) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_ModelRegistry *ModelRegistryTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ModelRegistry.contract.Transact(opts, "renounceOwnership") +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_ModelRegistry *ModelRegistrySession) RenounceOwnership() (*types.Transaction, error) { + return _ModelRegistry.Contract.RenounceOwnership(&_ModelRegistry.TransactOpts) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_ModelRegistry *ModelRegistryTransactorSession) RenounceOwnership() (*types.Transaction, error) { + return _ModelRegistry.Contract.RenounceOwnership(&_ModelRegistry.TransactOpts) +} + +// SetMinStake is a paid mutator transaction binding the contract method 0x8c80fd90. +// +// Solidity: function setMinStake(uint256 _minStake) returns() +func (_ModelRegistry *ModelRegistryTransactor) SetMinStake(opts *bind.TransactOpts, _minStake *big.Int) (*types.Transaction, error) { + return _ModelRegistry.contract.Transact(opts, "setMinStake", _minStake) +} + +// SetMinStake is a paid mutator transaction binding the contract method 0x8c80fd90. +// +// Solidity: function setMinStake(uint256 _minStake) returns() +func (_ModelRegistry *ModelRegistrySession) SetMinStake(_minStake *big.Int) (*types.Transaction, error) { + return _ModelRegistry.Contract.SetMinStake(&_ModelRegistry.TransactOpts, _minStake) +} + +// SetMinStake is a paid mutator transaction binding the contract method 0x8c80fd90. +// +// Solidity: function setMinStake(uint256 _minStake) returns() +func (_ModelRegistry *ModelRegistryTransactorSession) SetMinStake(_minStake *big.Int) (*types.Transaction, error) { + return _ModelRegistry.Contract.SetMinStake(&_ModelRegistry.TransactOpts, _minStake) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_ModelRegistry *ModelRegistryTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) { + return _ModelRegistry.contract.Transact(opts, "transferOwnership", newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_ModelRegistry *ModelRegistrySession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _ModelRegistry.Contract.TransferOwnership(&_ModelRegistry.TransactOpts, newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_ModelRegistry *ModelRegistryTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _ModelRegistry.Contract.TransferOwnership(&_ModelRegistry.TransactOpts, newOwner) +} + +// ModelRegistryDeregisteredIterator is returned from FilterDeregistered and is used to iterate over the raw logs and unpacked data for Deregistered events raised by the ModelRegistry contract. +type ModelRegistryDeregisteredIterator struct { + Event *ModelRegistryDeregistered // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ModelRegistryDeregisteredIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ModelRegistryDeregistered) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ModelRegistryDeregistered) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ModelRegistryDeregisteredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ModelRegistryDeregisteredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ModelRegistryDeregistered represents a Deregistered event raised by the ModelRegistry contract. +type ModelRegistryDeregistered struct { + Owner common.Address + ModelId [32]byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterDeregistered is a free log retrieval operation binding the contract event 0xcc0d8d49cb9a5a3eebc1e1f0b607b8aad83fbe9618e448df79b8a0cc33319472. +// +// Solidity: event Deregistered(address indexed owner, bytes32 indexed modelId) +func (_ModelRegistry *ModelRegistryFilterer) FilterDeregistered(opts *bind.FilterOpts, owner []common.Address, modelId [][32]byte) (*ModelRegistryDeregisteredIterator, error) { + + var ownerRule []interface{} + for _, ownerItem := range owner { + ownerRule = append(ownerRule, ownerItem) + } + var modelIdRule []interface{} + for _, modelIdItem := range modelId { + modelIdRule = append(modelIdRule, modelIdItem) + } + + logs, sub, err := _ModelRegistry.contract.FilterLogs(opts, "Deregistered", ownerRule, modelIdRule) + if err != nil { + return nil, err + } + return &ModelRegistryDeregisteredIterator{contract: _ModelRegistry.contract, event: "Deregistered", logs: logs, sub: sub}, nil +} + +// WatchDeregistered is a free log subscription operation binding the contract event 0xcc0d8d49cb9a5a3eebc1e1f0b607b8aad83fbe9618e448df79b8a0cc33319472. +// +// Solidity: event Deregistered(address indexed owner, bytes32 indexed modelId) +func (_ModelRegistry *ModelRegistryFilterer) WatchDeregistered(opts *bind.WatchOpts, sink chan<- *ModelRegistryDeregistered, owner []common.Address, modelId [][32]byte) (event.Subscription, error) { + + var ownerRule []interface{} + for _, ownerItem := range owner { + ownerRule = append(ownerRule, ownerItem) + } + var modelIdRule []interface{} + for _, modelIdItem := range modelId { + modelIdRule = append(modelIdRule, modelIdItem) + } + + logs, sub, err := _ModelRegistry.contract.WatchLogs(opts, "Deregistered", ownerRule, modelIdRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ModelRegistryDeregistered) + if err := _ModelRegistry.contract.UnpackLog(event, "Deregistered", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseDeregistered is a log parse operation binding the contract event 0xcc0d8d49cb9a5a3eebc1e1f0b607b8aad83fbe9618e448df79b8a0cc33319472. +// +// Solidity: event Deregistered(address indexed owner, bytes32 indexed modelId) +func (_ModelRegistry *ModelRegistryFilterer) ParseDeregistered(log types.Log) (*ModelRegistryDeregistered, error) { + event := new(ModelRegistryDeregistered) + if err := _ModelRegistry.contract.UnpackLog(event, "Deregistered", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// ModelRegistryInitializedIterator is returned from FilterInitialized and is used to iterate over the raw logs and unpacked data for Initialized events raised by the ModelRegistry contract. +type ModelRegistryInitializedIterator struct { + Event *ModelRegistryInitialized // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ModelRegistryInitializedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ModelRegistryInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ModelRegistryInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ModelRegistryInitializedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ModelRegistryInitializedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ModelRegistryInitialized represents a Initialized event raised by the ModelRegistry contract. +type ModelRegistryInitialized struct { + Version uint8 + Raw types.Log // Blockchain specific contextual infos +} + +// FilterInitialized is a free log retrieval operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_ModelRegistry *ModelRegistryFilterer) FilterInitialized(opts *bind.FilterOpts) (*ModelRegistryInitializedIterator, error) { + + logs, sub, err := _ModelRegistry.contract.FilterLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return &ModelRegistryInitializedIterator{contract: _ModelRegistry.contract, event: "Initialized", logs: logs, sub: sub}, nil +} + +// WatchInitialized is a free log subscription operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_ModelRegistry *ModelRegistryFilterer) WatchInitialized(opts *bind.WatchOpts, sink chan<- *ModelRegistryInitialized) (event.Subscription, error) { + + logs, sub, err := _ModelRegistry.contract.WatchLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ModelRegistryInitialized) + if err := _ModelRegistry.contract.UnpackLog(event, "Initialized", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseInitialized is a log parse operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_ModelRegistry *ModelRegistryFilterer) ParseInitialized(log types.Log) (*ModelRegistryInitialized, error) { + event := new(ModelRegistryInitialized) + if err := _ModelRegistry.contract.UnpackLog(event, "Initialized", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// ModelRegistryMinStakeUpdatedIterator is returned from FilterMinStakeUpdated and is used to iterate over the raw logs and unpacked data for MinStakeUpdated events raised by the ModelRegistry contract. +type ModelRegistryMinStakeUpdatedIterator struct { + Event *ModelRegistryMinStakeUpdated // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ModelRegistryMinStakeUpdatedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ModelRegistryMinStakeUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ModelRegistryMinStakeUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ModelRegistryMinStakeUpdatedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ModelRegistryMinStakeUpdatedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ModelRegistryMinStakeUpdated represents a MinStakeUpdated event raised by the ModelRegistry contract. +type ModelRegistryMinStakeUpdated struct { + NewStake *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterMinStakeUpdated is a free log retrieval operation binding the contract event 0x47ab46f2c8d4258304a2f5551c1cbdb6981be49631365d1ba7191288a73f39ef. +// +// Solidity: event MinStakeUpdated(uint256 newStake) +func (_ModelRegistry *ModelRegistryFilterer) FilterMinStakeUpdated(opts *bind.FilterOpts) (*ModelRegistryMinStakeUpdatedIterator, error) { + + logs, sub, err := _ModelRegistry.contract.FilterLogs(opts, "MinStakeUpdated") + if err != nil { + return nil, err + } + return &ModelRegistryMinStakeUpdatedIterator{contract: _ModelRegistry.contract, event: "MinStakeUpdated", logs: logs, sub: sub}, nil +} + +// WatchMinStakeUpdated is a free log subscription operation binding the contract event 0x47ab46f2c8d4258304a2f5551c1cbdb6981be49631365d1ba7191288a73f39ef. +// +// Solidity: event MinStakeUpdated(uint256 newStake) +func (_ModelRegistry *ModelRegistryFilterer) WatchMinStakeUpdated(opts *bind.WatchOpts, sink chan<- *ModelRegistryMinStakeUpdated) (event.Subscription, error) { + + logs, sub, err := _ModelRegistry.contract.WatchLogs(opts, "MinStakeUpdated") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ModelRegistryMinStakeUpdated) + if err := _ModelRegistry.contract.UnpackLog(event, "MinStakeUpdated", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseMinStakeUpdated is a log parse operation binding the contract event 0x47ab46f2c8d4258304a2f5551c1cbdb6981be49631365d1ba7191288a73f39ef. +// +// Solidity: event MinStakeUpdated(uint256 newStake) +func (_ModelRegistry *ModelRegistryFilterer) ParseMinStakeUpdated(log types.Log) (*ModelRegistryMinStakeUpdated, error) { + event := new(ModelRegistryMinStakeUpdated) + if err := _ModelRegistry.contract.UnpackLog(event, "MinStakeUpdated", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// ModelRegistryOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the ModelRegistry contract. +type ModelRegistryOwnershipTransferredIterator struct { + Event *ModelRegistryOwnershipTransferred // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ModelRegistryOwnershipTransferredIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ModelRegistryOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ModelRegistryOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ModelRegistryOwnershipTransferredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ModelRegistryOwnershipTransferredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ModelRegistryOwnershipTransferred represents a OwnershipTransferred event raised by the ModelRegistry contract. +type ModelRegistryOwnershipTransferred struct { + PreviousOwner common.Address + NewOwner common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_ModelRegistry *ModelRegistryFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*ModelRegistryOwnershipTransferredIterator, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _ModelRegistry.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return &ModelRegistryOwnershipTransferredIterator{contract: _ModelRegistry.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil +} + +// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_ModelRegistry *ModelRegistryFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *ModelRegistryOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _ModelRegistry.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ModelRegistryOwnershipTransferred) + if err := _ModelRegistry.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_ModelRegistry *ModelRegistryFilterer) ParseOwnershipTransferred(log types.Log) (*ModelRegistryOwnershipTransferred, error) { + event := new(ModelRegistryOwnershipTransferred) + if err := _ModelRegistry.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// ModelRegistryRegisteredUpdatedIterator is returned from FilterRegisteredUpdated and is used to iterate over the raw logs and unpacked data for RegisteredUpdated events raised by the ModelRegistry contract. +type ModelRegistryRegisteredUpdatedIterator struct { + Event *ModelRegistryRegisteredUpdated // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ModelRegistryRegisteredUpdatedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ModelRegistryRegisteredUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ModelRegistryRegisteredUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ModelRegistryRegisteredUpdatedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ModelRegistryRegisteredUpdatedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ModelRegistryRegisteredUpdated represents a RegisteredUpdated event raised by the ModelRegistry contract. +type ModelRegistryRegisteredUpdated struct { + Owner common.Address + ModelId [32]byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterRegisteredUpdated is a free log retrieval operation binding the contract event 0x4dffc4e92367641816479c647d1ff3f03202f6c73b97340cba51a7b577c55804. +// +// Solidity: event RegisteredUpdated(address indexed owner, bytes32 indexed modelId) +func (_ModelRegistry *ModelRegistryFilterer) FilterRegisteredUpdated(opts *bind.FilterOpts, owner []common.Address, modelId [][32]byte) (*ModelRegistryRegisteredUpdatedIterator, error) { + + var ownerRule []interface{} + for _, ownerItem := range owner { + ownerRule = append(ownerRule, ownerItem) + } + var modelIdRule []interface{} + for _, modelIdItem := range modelId { + modelIdRule = append(modelIdRule, modelIdItem) + } + + logs, sub, err := _ModelRegistry.contract.FilterLogs(opts, "RegisteredUpdated", ownerRule, modelIdRule) + if err != nil { + return nil, err + } + return &ModelRegistryRegisteredUpdatedIterator{contract: _ModelRegistry.contract, event: "RegisteredUpdated", logs: logs, sub: sub}, nil +} + +// WatchRegisteredUpdated is a free log subscription operation binding the contract event 0x4dffc4e92367641816479c647d1ff3f03202f6c73b97340cba51a7b577c55804. +// +// Solidity: event RegisteredUpdated(address indexed owner, bytes32 indexed modelId) +func (_ModelRegistry *ModelRegistryFilterer) WatchRegisteredUpdated(opts *bind.WatchOpts, sink chan<- *ModelRegistryRegisteredUpdated, owner []common.Address, modelId [][32]byte) (event.Subscription, error) { + + var ownerRule []interface{} + for _, ownerItem := range owner { + ownerRule = append(ownerRule, ownerItem) + } + var modelIdRule []interface{} + for _, modelIdItem := range modelId { + modelIdRule = append(modelIdRule, modelIdItem) + } + + logs, sub, err := _ModelRegistry.contract.WatchLogs(opts, "RegisteredUpdated", ownerRule, modelIdRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ModelRegistryRegisteredUpdated) + if err := _ModelRegistry.contract.UnpackLog(event, "RegisteredUpdated", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseRegisteredUpdated is a log parse operation binding the contract event 0x4dffc4e92367641816479c647d1ff3f03202f6c73b97340cba51a7b577c55804. +// +// Solidity: event RegisteredUpdated(address indexed owner, bytes32 indexed modelId) +func (_ModelRegistry *ModelRegistryFilterer) ParseRegisteredUpdated(log types.Log) (*ModelRegistryRegisteredUpdated, error) { + event := new(ModelRegistryRegisteredUpdated) + if err := _ModelRegistry.contract.UnpackLog(event, "RegisteredUpdated", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/proxy-router/contracts/morpheustoken/MorpheusToken.go b/proxy-router/contracts/morpheustoken/MorpheusToken.go new file mode 100644 index 00000000..f51909ce --- /dev/null +++ b/proxy-router/contracts/morpheustoken/MorpheusToken.go @@ -0,0 +1,738 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package morpheustoken + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// MorpheusTokenMetaData contains all meta data concerning the MorpheusToken contract. +var MorpheusTokenMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"allowance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"needed\",\"type\":\"uint256\"}],\"name\":\"ERC20InsufficientAllowance\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"needed\",\"type\":\"uint256\"}],\"name\":\"ERC20InsufficientBalance\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"approver\",\"type\":\"address\"}],\"name\":\"ERC20InvalidApprover\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"}],\"name\":\"ERC20InvalidReceiver\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"ERC20InvalidSender\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"}],\"name\":\"ERC20InvalidSpender\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", +} + +// MorpheusTokenABI is the input ABI used to generate the binding from. +// Deprecated: Use MorpheusTokenMetaData.ABI instead. +var MorpheusTokenABI = MorpheusTokenMetaData.ABI + +// MorpheusToken is an auto generated Go binding around an Ethereum contract. +type MorpheusToken struct { + MorpheusTokenCaller // Read-only binding to the contract + MorpheusTokenTransactor // Write-only binding to the contract + MorpheusTokenFilterer // Log filterer for contract events +} + +// MorpheusTokenCaller is an auto generated read-only Go binding around an Ethereum contract. +type MorpheusTokenCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// MorpheusTokenTransactor is an auto generated write-only Go binding around an Ethereum contract. +type MorpheusTokenTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// MorpheusTokenFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type MorpheusTokenFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// MorpheusTokenSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type MorpheusTokenSession struct { + Contract *MorpheusToken // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// MorpheusTokenCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type MorpheusTokenCallerSession struct { + Contract *MorpheusTokenCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// MorpheusTokenTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type MorpheusTokenTransactorSession struct { + Contract *MorpheusTokenTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// MorpheusTokenRaw is an auto generated low-level Go binding around an Ethereum contract. +type MorpheusTokenRaw struct { + Contract *MorpheusToken // Generic contract binding to access the raw methods on +} + +// MorpheusTokenCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type MorpheusTokenCallerRaw struct { + Contract *MorpheusTokenCaller // Generic read-only contract binding to access the raw methods on +} + +// MorpheusTokenTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type MorpheusTokenTransactorRaw struct { + Contract *MorpheusTokenTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewMorpheusToken creates a new instance of MorpheusToken, bound to a specific deployed contract. +func NewMorpheusToken(address common.Address, backend bind.ContractBackend) (*MorpheusToken, error) { + contract, err := bindMorpheusToken(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &MorpheusToken{MorpheusTokenCaller: MorpheusTokenCaller{contract: contract}, MorpheusTokenTransactor: MorpheusTokenTransactor{contract: contract}, MorpheusTokenFilterer: MorpheusTokenFilterer{contract: contract}}, nil +} + +// NewMorpheusTokenCaller creates a new read-only instance of MorpheusToken, bound to a specific deployed contract. +func NewMorpheusTokenCaller(address common.Address, caller bind.ContractCaller) (*MorpheusTokenCaller, error) { + contract, err := bindMorpheusToken(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &MorpheusTokenCaller{contract: contract}, nil +} + +// NewMorpheusTokenTransactor creates a new write-only instance of MorpheusToken, bound to a specific deployed contract. +func NewMorpheusTokenTransactor(address common.Address, transactor bind.ContractTransactor) (*MorpheusTokenTransactor, error) { + contract, err := bindMorpheusToken(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &MorpheusTokenTransactor{contract: contract}, nil +} + +// NewMorpheusTokenFilterer creates a new log filterer instance of MorpheusToken, bound to a specific deployed contract. +func NewMorpheusTokenFilterer(address common.Address, filterer bind.ContractFilterer) (*MorpheusTokenFilterer, error) { + contract, err := bindMorpheusToken(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &MorpheusTokenFilterer{contract: contract}, nil +} + +// bindMorpheusToken binds a generic wrapper to an already deployed contract. +func bindMorpheusToken(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := MorpheusTokenMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_MorpheusToken *MorpheusTokenRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _MorpheusToken.Contract.MorpheusTokenCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_MorpheusToken *MorpheusTokenRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _MorpheusToken.Contract.MorpheusTokenTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_MorpheusToken *MorpheusTokenRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _MorpheusToken.Contract.MorpheusTokenTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_MorpheusToken *MorpheusTokenCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _MorpheusToken.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_MorpheusToken *MorpheusTokenTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _MorpheusToken.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_MorpheusToken *MorpheusTokenTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _MorpheusToken.Contract.contract.Transact(opts, method, params...) +} + +// Allowance is a free data retrieval call binding the contract method 0xdd62ed3e. +// +// Solidity: function allowance(address owner, address spender) view returns(uint256) +func (_MorpheusToken *MorpheusTokenCaller) Allowance(opts *bind.CallOpts, owner common.Address, spender common.Address) (*big.Int, error) { + var out []interface{} + err := _MorpheusToken.contract.Call(opts, &out, "allowance", owner, spender) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// Allowance is a free data retrieval call binding the contract method 0xdd62ed3e. +// +// Solidity: function allowance(address owner, address spender) view returns(uint256) +func (_MorpheusToken *MorpheusTokenSession) Allowance(owner common.Address, spender common.Address) (*big.Int, error) { + return _MorpheusToken.Contract.Allowance(&_MorpheusToken.CallOpts, owner, spender) +} + +// Allowance is a free data retrieval call binding the contract method 0xdd62ed3e. +// +// Solidity: function allowance(address owner, address spender) view returns(uint256) +func (_MorpheusToken *MorpheusTokenCallerSession) Allowance(owner common.Address, spender common.Address) (*big.Int, error) { + return _MorpheusToken.Contract.Allowance(&_MorpheusToken.CallOpts, owner, spender) +} + +// BalanceOf is a free data retrieval call binding the contract method 0x70a08231. +// +// Solidity: function balanceOf(address account) view returns(uint256) +func (_MorpheusToken *MorpheusTokenCaller) BalanceOf(opts *bind.CallOpts, account common.Address) (*big.Int, error) { + var out []interface{} + err := _MorpheusToken.contract.Call(opts, &out, "balanceOf", account) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// BalanceOf is a free data retrieval call binding the contract method 0x70a08231. +// +// Solidity: function balanceOf(address account) view returns(uint256) +func (_MorpheusToken *MorpheusTokenSession) BalanceOf(account common.Address) (*big.Int, error) { + return _MorpheusToken.Contract.BalanceOf(&_MorpheusToken.CallOpts, account) +} + +// BalanceOf is a free data retrieval call binding the contract method 0x70a08231. +// +// Solidity: function balanceOf(address account) view returns(uint256) +func (_MorpheusToken *MorpheusTokenCallerSession) BalanceOf(account common.Address) (*big.Int, error) { + return _MorpheusToken.Contract.BalanceOf(&_MorpheusToken.CallOpts, account) +} + +// Decimals is a free data retrieval call binding the contract method 0x313ce567. +// +// Solidity: function decimals() view returns(uint8) +func (_MorpheusToken *MorpheusTokenCaller) Decimals(opts *bind.CallOpts) (uint8, error) { + var out []interface{} + err := _MorpheusToken.contract.Call(opts, &out, "decimals") + + if err != nil { + return *new(uint8), err + } + + out0 := *abi.ConvertType(out[0], new(uint8)).(*uint8) + + return out0, err + +} + +// Decimals is a free data retrieval call binding the contract method 0x313ce567. +// +// Solidity: function decimals() view returns(uint8) +func (_MorpheusToken *MorpheusTokenSession) Decimals() (uint8, error) { + return _MorpheusToken.Contract.Decimals(&_MorpheusToken.CallOpts) +} + +// Decimals is a free data retrieval call binding the contract method 0x313ce567. +// +// Solidity: function decimals() view returns(uint8) +func (_MorpheusToken *MorpheusTokenCallerSession) Decimals() (uint8, error) { + return _MorpheusToken.Contract.Decimals(&_MorpheusToken.CallOpts) +} + +// Name is a free data retrieval call binding the contract method 0x06fdde03. +// +// Solidity: function name() view returns(string) +func (_MorpheusToken *MorpheusTokenCaller) Name(opts *bind.CallOpts) (string, error) { + var out []interface{} + err := _MorpheusToken.contract.Call(opts, &out, "name") + + if err != nil { + return *new(string), err + } + + out0 := *abi.ConvertType(out[0], new(string)).(*string) + + return out0, err + +} + +// Name is a free data retrieval call binding the contract method 0x06fdde03. +// +// Solidity: function name() view returns(string) +func (_MorpheusToken *MorpheusTokenSession) Name() (string, error) { + return _MorpheusToken.Contract.Name(&_MorpheusToken.CallOpts) +} + +// Name is a free data retrieval call binding the contract method 0x06fdde03. +// +// Solidity: function name() view returns(string) +func (_MorpheusToken *MorpheusTokenCallerSession) Name() (string, error) { + return _MorpheusToken.Contract.Name(&_MorpheusToken.CallOpts) +} + +// Symbol is a free data retrieval call binding the contract method 0x95d89b41. +// +// Solidity: function symbol() view returns(string) +func (_MorpheusToken *MorpheusTokenCaller) Symbol(opts *bind.CallOpts) (string, error) { + var out []interface{} + err := _MorpheusToken.contract.Call(opts, &out, "symbol") + + if err != nil { + return *new(string), err + } + + out0 := *abi.ConvertType(out[0], new(string)).(*string) + + return out0, err + +} + +// Symbol is a free data retrieval call binding the contract method 0x95d89b41. +// +// Solidity: function symbol() view returns(string) +func (_MorpheusToken *MorpheusTokenSession) Symbol() (string, error) { + return _MorpheusToken.Contract.Symbol(&_MorpheusToken.CallOpts) +} + +// Symbol is a free data retrieval call binding the contract method 0x95d89b41. +// +// Solidity: function symbol() view returns(string) +func (_MorpheusToken *MorpheusTokenCallerSession) Symbol() (string, error) { + return _MorpheusToken.Contract.Symbol(&_MorpheusToken.CallOpts) +} + +// TotalSupply is a free data retrieval call binding the contract method 0x18160ddd. +// +// Solidity: function totalSupply() view returns(uint256) +func (_MorpheusToken *MorpheusTokenCaller) TotalSupply(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _MorpheusToken.contract.Call(opts, &out, "totalSupply") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// TotalSupply is a free data retrieval call binding the contract method 0x18160ddd. +// +// Solidity: function totalSupply() view returns(uint256) +func (_MorpheusToken *MorpheusTokenSession) TotalSupply() (*big.Int, error) { + return _MorpheusToken.Contract.TotalSupply(&_MorpheusToken.CallOpts) +} + +// TotalSupply is a free data retrieval call binding the contract method 0x18160ddd. +// +// Solidity: function totalSupply() view returns(uint256) +func (_MorpheusToken *MorpheusTokenCallerSession) TotalSupply() (*big.Int, error) { + return _MorpheusToken.Contract.TotalSupply(&_MorpheusToken.CallOpts) +} + +// Approve is a paid mutator transaction binding the contract method 0x095ea7b3. +// +// Solidity: function approve(address spender, uint256 value) returns(bool) +func (_MorpheusToken *MorpheusTokenTransactor) Approve(opts *bind.TransactOpts, spender common.Address, value *big.Int) (*types.Transaction, error) { + return _MorpheusToken.contract.Transact(opts, "approve", spender, value) +} + +// Approve is a paid mutator transaction binding the contract method 0x095ea7b3. +// +// Solidity: function approve(address spender, uint256 value) returns(bool) +func (_MorpheusToken *MorpheusTokenSession) Approve(spender common.Address, value *big.Int) (*types.Transaction, error) { + return _MorpheusToken.Contract.Approve(&_MorpheusToken.TransactOpts, spender, value) +} + +// Approve is a paid mutator transaction binding the contract method 0x095ea7b3. +// +// Solidity: function approve(address spender, uint256 value) returns(bool) +func (_MorpheusToken *MorpheusTokenTransactorSession) Approve(spender common.Address, value *big.Int) (*types.Transaction, error) { + return _MorpheusToken.Contract.Approve(&_MorpheusToken.TransactOpts, spender, value) +} + +// Transfer is a paid mutator transaction binding the contract method 0xa9059cbb. +// +// Solidity: function transfer(address to, uint256 value) returns(bool) +func (_MorpheusToken *MorpheusTokenTransactor) Transfer(opts *bind.TransactOpts, to common.Address, value *big.Int) (*types.Transaction, error) { + return _MorpheusToken.contract.Transact(opts, "transfer", to, value) +} + +// Transfer is a paid mutator transaction binding the contract method 0xa9059cbb. +// +// Solidity: function transfer(address to, uint256 value) returns(bool) +func (_MorpheusToken *MorpheusTokenSession) Transfer(to common.Address, value *big.Int) (*types.Transaction, error) { + return _MorpheusToken.Contract.Transfer(&_MorpheusToken.TransactOpts, to, value) +} + +// Transfer is a paid mutator transaction binding the contract method 0xa9059cbb. +// +// Solidity: function transfer(address to, uint256 value) returns(bool) +func (_MorpheusToken *MorpheusTokenTransactorSession) Transfer(to common.Address, value *big.Int) (*types.Transaction, error) { + return _MorpheusToken.Contract.Transfer(&_MorpheusToken.TransactOpts, to, value) +} + +// TransferFrom is a paid mutator transaction binding the contract method 0x23b872dd. +// +// Solidity: function transferFrom(address from, address to, uint256 value) returns(bool) +func (_MorpheusToken *MorpheusTokenTransactor) TransferFrom(opts *bind.TransactOpts, from common.Address, to common.Address, value *big.Int) (*types.Transaction, error) { + return _MorpheusToken.contract.Transact(opts, "transferFrom", from, to, value) +} + +// TransferFrom is a paid mutator transaction binding the contract method 0x23b872dd. +// +// Solidity: function transferFrom(address from, address to, uint256 value) returns(bool) +func (_MorpheusToken *MorpheusTokenSession) TransferFrom(from common.Address, to common.Address, value *big.Int) (*types.Transaction, error) { + return _MorpheusToken.Contract.TransferFrom(&_MorpheusToken.TransactOpts, from, to, value) +} + +// TransferFrom is a paid mutator transaction binding the contract method 0x23b872dd. +// +// Solidity: function transferFrom(address from, address to, uint256 value) returns(bool) +func (_MorpheusToken *MorpheusTokenTransactorSession) TransferFrom(from common.Address, to common.Address, value *big.Int) (*types.Transaction, error) { + return _MorpheusToken.Contract.TransferFrom(&_MorpheusToken.TransactOpts, from, to, value) +} + +// MorpheusTokenApprovalIterator is returned from FilterApproval and is used to iterate over the raw logs and unpacked data for Approval events raised by the MorpheusToken contract. +type MorpheusTokenApprovalIterator struct { + Event *MorpheusTokenApproval // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *MorpheusTokenApprovalIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(MorpheusTokenApproval) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(MorpheusTokenApproval) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *MorpheusTokenApprovalIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *MorpheusTokenApprovalIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// MorpheusTokenApproval represents a Approval event raised by the MorpheusToken contract. +type MorpheusTokenApproval struct { + Owner common.Address + Spender common.Address + Value *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterApproval is a free log retrieval operation binding the contract event 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925. +// +// Solidity: event Approval(address indexed owner, address indexed spender, uint256 value) +func (_MorpheusToken *MorpheusTokenFilterer) FilterApproval(opts *bind.FilterOpts, owner []common.Address, spender []common.Address) (*MorpheusTokenApprovalIterator, error) { + + var ownerRule []interface{} + for _, ownerItem := range owner { + ownerRule = append(ownerRule, ownerItem) + } + var spenderRule []interface{} + for _, spenderItem := range spender { + spenderRule = append(spenderRule, spenderItem) + } + + logs, sub, err := _MorpheusToken.contract.FilterLogs(opts, "Approval", ownerRule, spenderRule) + if err != nil { + return nil, err + } + return &MorpheusTokenApprovalIterator{contract: _MorpheusToken.contract, event: "Approval", logs: logs, sub: sub}, nil +} + +// WatchApproval is a free log subscription operation binding the contract event 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925. +// +// Solidity: event Approval(address indexed owner, address indexed spender, uint256 value) +func (_MorpheusToken *MorpheusTokenFilterer) WatchApproval(opts *bind.WatchOpts, sink chan<- *MorpheusTokenApproval, owner []common.Address, spender []common.Address) (event.Subscription, error) { + + var ownerRule []interface{} + for _, ownerItem := range owner { + ownerRule = append(ownerRule, ownerItem) + } + var spenderRule []interface{} + for _, spenderItem := range spender { + spenderRule = append(spenderRule, spenderItem) + } + + logs, sub, err := _MorpheusToken.contract.WatchLogs(opts, "Approval", ownerRule, spenderRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(MorpheusTokenApproval) + if err := _MorpheusToken.contract.UnpackLog(event, "Approval", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseApproval is a log parse operation binding the contract event 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925. +// +// Solidity: event Approval(address indexed owner, address indexed spender, uint256 value) +func (_MorpheusToken *MorpheusTokenFilterer) ParseApproval(log types.Log) (*MorpheusTokenApproval, error) { + event := new(MorpheusTokenApproval) + if err := _MorpheusToken.contract.UnpackLog(event, "Approval", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// MorpheusTokenTransferIterator is returned from FilterTransfer and is used to iterate over the raw logs and unpacked data for Transfer events raised by the MorpheusToken contract. +type MorpheusTokenTransferIterator struct { + Event *MorpheusTokenTransfer // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *MorpheusTokenTransferIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(MorpheusTokenTransfer) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(MorpheusTokenTransfer) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *MorpheusTokenTransferIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *MorpheusTokenTransferIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// MorpheusTokenTransfer represents a Transfer event raised by the MorpheusToken contract. +type MorpheusTokenTransfer struct { + From common.Address + To common.Address + Value *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterTransfer is a free log retrieval operation binding the contract event 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef. +// +// Solidity: event Transfer(address indexed from, address indexed to, uint256 value) +func (_MorpheusToken *MorpheusTokenFilterer) FilterTransfer(opts *bind.FilterOpts, from []common.Address, to []common.Address) (*MorpheusTokenTransferIterator, error) { + + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _MorpheusToken.contract.FilterLogs(opts, "Transfer", fromRule, toRule) + if err != nil { + return nil, err + } + return &MorpheusTokenTransferIterator{contract: _MorpheusToken.contract, event: "Transfer", logs: logs, sub: sub}, nil +} + +// WatchTransfer is a free log subscription operation binding the contract event 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef. +// +// Solidity: event Transfer(address indexed from, address indexed to, uint256 value) +func (_MorpheusToken *MorpheusTokenFilterer) WatchTransfer(opts *bind.WatchOpts, sink chan<- *MorpheusTokenTransfer, from []common.Address, to []common.Address) (event.Subscription, error) { + + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _MorpheusToken.contract.WatchLogs(opts, "Transfer", fromRule, toRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(MorpheusTokenTransfer) + if err := _MorpheusToken.contract.UnpackLog(event, "Transfer", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseTransfer is a log parse operation binding the contract event 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef. +// +// Solidity: event Transfer(address indexed from, address indexed to, uint256 value) +func (_MorpheusToken *MorpheusTokenFilterer) ParseTransfer(log types.Log) (*MorpheusTokenTransfer, error) { + event := new(MorpheusTokenTransfer) + if err := _MorpheusToken.contract.UnpackLog(event, "Transfer", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/proxy-router/contracts/providerregistry/ProviderRegistry.go b/proxy-router/contracts/providerregistry/ProviderRegistry.go new file mode 100644 index 00000000..8afa5ffa --- /dev/null +++ b/proxy-router/contracts/providerregistry/ProviderRegistry.go @@ -0,0 +1,1373 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package providerregistry + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// ProviderRegistryProvider is an auto generated low-level Go binding around an user-defined struct. +type ProviderRegistryProvider struct { + Endpoint string + Stake *big.Int + Timestamp *big.Int + IsDeleted bool +} + +// ProviderRegistryMetaData contains all meta data concerning the ProviderRegistry contract. +var ProviderRegistryMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[],\"name\":\"KeyExists\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"KeyNotFound\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotSenderOrOwner\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"StakeTooLow\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ZeroKey\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"}],\"name\":\"Deregistered\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newStake\",\"type\":\"uint256\"}],\"name\":\"MinStakeUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"}],\"name\":\"RegisteredUpdated\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"deregister\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"exists\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAll\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"endpoint\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"stake\",\"type\":\"uint256\"},{\"internalType\":\"uint128\",\"name\":\"timestamp\",\"type\":\"uint128\"},{\"internalType\":\"bool\",\"name\":\"isDeleted\",\"type\":\"bool\"}],\"internalType\":\"structProviderRegistry.Provider[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getByIndex\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"endpoint\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"stake\",\"type\":\"uint256\"},{\"internalType\":\"uint128\",\"name\":\"timestamp\",\"type\":\"uint128\"},{\"internalType\":\"bool\",\"name\":\"isDeleted\",\"type\":\"bool\"}],\"internalType\":\"structProviderRegistry.Provider\",\"name\":\"provider\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"count\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getIds\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"map\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"endpoint\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"stake\",\"type\":\"uint256\"},{\"internalType\":\"uint128\",\"name\":\"timestamp\",\"type\":\"uint128\"},{\"internalType\":\"bool\",\"name\":\"isDeleted\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minStake\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"providers\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"addStake\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"endpoint\",\"type\":\"string\"}],\"name\":\"register\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_minStake\",\"type\":\"uint256\"}],\"name\":\"setMinStake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"token\",\"outputs\":[{\"internalType\":\"contractERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", +} + +// ProviderRegistryABI is the input ABI used to generate the binding from. +// Deprecated: Use ProviderRegistryMetaData.ABI instead. +var ProviderRegistryABI = ProviderRegistryMetaData.ABI + +// ProviderRegistry is an auto generated Go binding around an Ethereum contract. +type ProviderRegistry struct { + ProviderRegistryCaller // Read-only binding to the contract + ProviderRegistryTransactor // Write-only binding to the contract + ProviderRegistryFilterer // Log filterer for contract events +} + +// ProviderRegistryCaller is an auto generated read-only Go binding around an Ethereum contract. +type ProviderRegistryCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ProviderRegistryTransactor is an auto generated write-only Go binding around an Ethereum contract. +type ProviderRegistryTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ProviderRegistryFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type ProviderRegistryFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ProviderRegistrySession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type ProviderRegistrySession struct { + Contract *ProviderRegistry // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// ProviderRegistryCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type ProviderRegistryCallerSession struct { + Contract *ProviderRegistryCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// ProviderRegistryTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type ProviderRegistryTransactorSession struct { + Contract *ProviderRegistryTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// ProviderRegistryRaw is an auto generated low-level Go binding around an Ethereum contract. +type ProviderRegistryRaw struct { + Contract *ProviderRegistry // Generic contract binding to access the raw methods on +} + +// ProviderRegistryCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type ProviderRegistryCallerRaw struct { + Contract *ProviderRegistryCaller // Generic read-only contract binding to access the raw methods on +} + +// ProviderRegistryTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type ProviderRegistryTransactorRaw struct { + Contract *ProviderRegistryTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewProviderRegistry creates a new instance of ProviderRegistry, bound to a specific deployed contract. +func NewProviderRegistry(address common.Address, backend bind.ContractBackend) (*ProviderRegistry, error) { + contract, err := bindProviderRegistry(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &ProviderRegistry{ProviderRegistryCaller: ProviderRegistryCaller{contract: contract}, ProviderRegistryTransactor: ProviderRegistryTransactor{contract: contract}, ProviderRegistryFilterer: ProviderRegistryFilterer{contract: contract}}, nil +} + +// NewProviderRegistryCaller creates a new read-only instance of ProviderRegistry, bound to a specific deployed contract. +func NewProviderRegistryCaller(address common.Address, caller bind.ContractCaller) (*ProviderRegistryCaller, error) { + contract, err := bindProviderRegistry(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &ProviderRegistryCaller{contract: contract}, nil +} + +// NewProviderRegistryTransactor creates a new write-only instance of ProviderRegistry, bound to a specific deployed contract. +func NewProviderRegistryTransactor(address common.Address, transactor bind.ContractTransactor) (*ProviderRegistryTransactor, error) { + contract, err := bindProviderRegistry(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &ProviderRegistryTransactor{contract: contract}, nil +} + +// NewProviderRegistryFilterer creates a new log filterer instance of ProviderRegistry, bound to a specific deployed contract. +func NewProviderRegistryFilterer(address common.Address, filterer bind.ContractFilterer) (*ProviderRegistryFilterer, error) { + contract, err := bindProviderRegistry(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &ProviderRegistryFilterer{contract: contract}, nil +} + +// bindProviderRegistry binds a generic wrapper to an already deployed contract. +func bindProviderRegistry(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := ProviderRegistryMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_ProviderRegistry *ProviderRegistryRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _ProviderRegistry.Contract.ProviderRegistryCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_ProviderRegistry *ProviderRegistryRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ProviderRegistry.Contract.ProviderRegistryTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_ProviderRegistry *ProviderRegistryRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _ProviderRegistry.Contract.ProviderRegistryTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_ProviderRegistry *ProviderRegistryCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _ProviderRegistry.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_ProviderRegistry *ProviderRegistryTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ProviderRegistry.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_ProviderRegistry *ProviderRegistryTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _ProviderRegistry.Contract.contract.Transact(opts, method, params...) +} + +// Exists is a free data retrieval call binding the contract method 0xf6a3d24e. +// +// Solidity: function exists(address addr) view returns(bool) +func (_ProviderRegistry *ProviderRegistryCaller) Exists(opts *bind.CallOpts, addr common.Address) (bool, error) { + var out []interface{} + err := _ProviderRegistry.contract.Call(opts, &out, "exists", addr) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// Exists is a free data retrieval call binding the contract method 0xf6a3d24e. +// +// Solidity: function exists(address addr) view returns(bool) +func (_ProviderRegistry *ProviderRegistrySession) Exists(addr common.Address) (bool, error) { + return _ProviderRegistry.Contract.Exists(&_ProviderRegistry.CallOpts, addr) +} + +// Exists is a free data retrieval call binding the contract method 0xf6a3d24e. +// +// Solidity: function exists(address addr) view returns(bool) +func (_ProviderRegistry *ProviderRegistryCallerSession) Exists(addr common.Address) (bool, error) { + return _ProviderRegistry.Contract.Exists(&_ProviderRegistry.CallOpts, addr) +} + +// GetAll is a free data retrieval call binding the contract method 0x53ed5143. +// +// Solidity: function getAll() view returns(address[], (string,uint256,uint128,bool)[]) +func (_ProviderRegistry *ProviderRegistryCaller) GetAll(opts *bind.CallOpts) ([]common.Address, []ProviderRegistryProvider, error) { + var out []interface{} + err := _ProviderRegistry.contract.Call(opts, &out, "getAll") + + if err != nil { + return *new([]common.Address), *new([]ProviderRegistryProvider), err + } + + out0 := *abi.ConvertType(out[0], new([]common.Address)).(*[]common.Address) + out1 := *abi.ConvertType(out[1], new([]ProviderRegistryProvider)).(*[]ProviderRegistryProvider) + + return out0, out1, err + +} + +// GetAll is a free data retrieval call binding the contract method 0x53ed5143. +// +// Solidity: function getAll() view returns(address[], (string,uint256,uint128,bool)[]) +func (_ProviderRegistry *ProviderRegistrySession) GetAll() ([]common.Address, []ProviderRegistryProvider, error) { + return _ProviderRegistry.Contract.GetAll(&_ProviderRegistry.CallOpts) +} + +// GetAll is a free data retrieval call binding the contract method 0x53ed5143. +// +// Solidity: function getAll() view returns(address[], (string,uint256,uint128,bool)[]) +func (_ProviderRegistry *ProviderRegistryCallerSession) GetAll() ([]common.Address, []ProviderRegistryProvider, error) { + return _ProviderRegistry.Contract.GetAll(&_ProviderRegistry.CallOpts) +} + +// GetByIndex is a free data retrieval call binding the contract method 0x2d883a73. +// +// Solidity: function getByIndex(uint256 index) view returns(address addr, (string,uint256,uint128,bool) provider) +func (_ProviderRegistry *ProviderRegistryCaller) GetByIndex(opts *bind.CallOpts, index *big.Int) (struct { + Addr common.Address + Provider ProviderRegistryProvider +}, error) { + var out []interface{} + err := _ProviderRegistry.contract.Call(opts, &out, "getByIndex", index) + + outstruct := new(struct { + Addr common.Address + Provider ProviderRegistryProvider + }) + if err != nil { + return *outstruct, err + } + + outstruct.Addr = *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + outstruct.Provider = *abi.ConvertType(out[1], new(ProviderRegistryProvider)).(*ProviderRegistryProvider) + + return *outstruct, err + +} + +// GetByIndex is a free data retrieval call binding the contract method 0x2d883a73. +// +// Solidity: function getByIndex(uint256 index) view returns(address addr, (string,uint256,uint128,bool) provider) +func (_ProviderRegistry *ProviderRegistrySession) GetByIndex(index *big.Int) (struct { + Addr common.Address + Provider ProviderRegistryProvider +}, error) { + return _ProviderRegistry.Contract.GetByIndex(&_ProviderRegistry.CallOpts, index) +} + +// GetByIndex is a free data retrieval call binding the contract method 0x2d883a73. +// +// Solidity: function getByIndex(uint256 index) view returns(address addr, (string,uint256,uint128,bool) provider) +func (_ProviderRegistry *ProviderRegistryCallerSession) GetByIndex(index *big.Int) (struct { + Addr common.Address + Provider ProviderRegistryProvider +}, error) { + return _ProviderRegistry.Contract.GetByIndex(&_ProviderRegistry.CallOpts, index) +} + +// GetCount is a free data retrieval call binding the contract method 0xa87d942c. +// +// Solidity: function getCount() view returns(uint256 count) +func (_ProviderRegistry *ProviderRegistryCaller) GetCount(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _ProviderRegistry.contract.Call(opts, &out, "getCount") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetCount is a free data retrieval call binding the contract method 0xa87d942c. +// +// Solidity: function getCount() view returns(uint256 count) +func (_ProviderRegistry *ProviderRegistrySession) GetCount() (*big.Int, error) { + return _ProviderRegistry.Contract.GetCount(&_ProviderRegistry.CallOpts) +} + +// GetCount is a free data retrieval call binding the contract method 0xa87d942c. +// +// Solidity: function getCount() view returns(uint256 count) +func (_ProviderRegistry *ProviderRegistryCallerSession) GetCount() (*big.Int, error) { + return _ProviderRegistry.Contract.GetCount(&_ProviderRegistry.CallOpts) +} + +// GetIds is a free data retrieval call binding the contract method 0x2b105663. +// +// Solidity: function getIds() view returns(address[]) +func (_ProviderRegistry *ProviderRegistryCaller) GetIds(opts *bind.CallOpts) ([]common.Address, error) { + var out []interface{} + err := _ProviderRegistry.contract.Call(opts, &out, "getIds") + + if err != nil { + return *new([]common.Address), err + } + + out0 := *abi.ConvertType(out[0], new([]common.Address)).(*[]common.Address) + + return out0, err + +} + +// GetIds is a free data retrieval call binding the contract method 0x2b105663. +// +// Solidity: function getIds() view returns(address[]) +func (_ProviderRegistry *ProviderRegistrySession) GetIds() ([]common.Address, error) { + return _ProviderRegistry.Contract.GetIds(&_ProviderRegistry.CallOpts) +} + +// GetIds is a free data retrieval call binding the contract method 0x2b105663. +// +// Solidity: function getIds() view returns(address[]) +func (_ProviderRegistry *ProviderRegistryCallerSession) GetIds() ([]common.Address, error) { + return _ProviderRegistry.Contract.GetIds(&_ProviderRegistry.CallOpts) +} + +// Map is a free data retrieval call binding the contract method 0xb721ef6e. +// +// Solidity: function map(address ) view returns(string endpoint, uint256 stake, uint128 timestamp, bool isDeleted) +func (_ProviderRegistry *ProviderRegistryCaller) Map(opts *bind.CallOpts, arg0 common.Address) (struct { + Endpoint string + Stake *big.Int + Timestamp *big.Int + IsDeleted bool +}, error) { + var out []interface{} + err := _ProviderRegistry.contract.Call(opts, &out, "map", arg0) + + outstruct := new(struct { + Endpoint string + Stake *big.Int + Timestamp *big.Int + IsDeleted bool + }) + if err != nil { + return *outstruct, err + } + + outstruct.Endpoint = *abi.ConvertType(out[0], new(string)).(*string) + outstruct.Stake = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) + outstruct.Timestamp = *abi.ConvertType(out[2], new(*big.Int)).(**big.Int) + outstruct.IsDeleted = *abi.ConvertType(out[3], new(bool)).(*bool) + + return *outstruct, err + +} + +// Map is a free data retrieval call binding the contract method 0xb721ef6e. +// +// Solidity: function map(address ) view returns(string endpoint, uint256 stake, uint128 timestamp, bool isDeleted) +func (_ProviderRegistry *ProviderRegistrySession) Map(arg0 common.Address) (struct { + Endpoint string + Stake *big.Int + Timestamp *big.Int + IsDeleted bool +}, error) { + return _ProviderRegistry.Contract.Map(&_ProviderRegistry.CallOpts, arg0) +} + +// Map is a free data retrieval call binding the contract method 0xb721ef6e. +// +// Solidity: function map(address ) view returns(string endpoint, uint256 stake, uint128 timestamp, bool isDeleted) +func (_ProviderRegistry *ProviderRegistryCallerSession) Map(arg0 common.Address) (struct { + Endpoint string + Stake *big.Int + Timestamp *big.Int + IsDeleted bool +}, error) { + return _ProviderRegistry.Contract.Map(&_ProviderRegistry.CallOpts, arg0) +} + +// MinStake is a free data retrieval call binding the contract method 0x375b3c0a. +// +// Solidity: function minStake() view returns(uint256) +func (_ProviderRegistry *ProviderRegistryCaller) MinStake(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _ProviderRegistry.contract.Call(opts, &out, "minStake") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// MinStake is a free data retrieval call binding the contract method 0x375b3c0a. +// +// Solidity: function minStake() view returns(uint256) +func (_ProviderRegistry *ProviderRegistrySession) MinStake() (*big.Int, error) { + return _ProviderRegistry.Contract.MinStake(&_ProviderRegistry.CallOpts) +} + +// MinStake is a free data retrieval call binding the contract method 0x375b3c0a. +// +// Solidity: function minStake() view returns(uint256) +func (_ProviderRegistry *ProviderRegistryCallerSession) MinStake() (*big.Int, error) { + return _ProviderRegistry.Contract.MinStake(&_ProviderRegistry.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_ProviderRegistry *ProviderRegistryCaller) Owner(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _ProviderRegistry.contract.Call(opts, &out, "owner") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_ProviderRegistry *ProviderRegistrySession) Owner() (common.Address, error) { + return _ProviderRegistry.Contract.Owner(&_ProviderRegistry.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_ProviderRegistry *ProviderRegistryCallerSession) Owner() (common.Address, error) { + return _ProviderRegistry.Contract.Owner(&_ProviderRegistry.CallOpts) +} + +// Providers is a free data retrieval call binding the contract method 0x50f3fc81. +// +// Solidity: function providers(uint256 ) view returns(address) +func (_ProviderRegistry *ProviderRegistryCaller) Providers(opts *bind.CallOpts, arg0 *big.Int) (common.Address, error) { + var out []interface{} + err := _ProviderRegistry.contract.Call(opts, &out, "providers", arg0) + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Providers is a free data retrieval call binding the contract method 0x50f3fc81. +// +// Solidity: function providers(uint256 ) view returns(address) +func (_ProviderRegistry *ProviderRegistrySession) Providers(arg0 *big.Int) (common.Address, error) { + return _ProviderRegistry.Contract.Providers(&_ProviderRegistry.CallOpts, arg0) +} + +// Providers is a free data retrieval call binding the contract method 0x50f3fc81. +// +// Solidity: function providers(uint256 ) view returns(address) +func (_ProviderRegistry *ProviderRegistryCallerSession) Providers(arg0 *big.Int) (common.Address, error) { + return _ProviderRegistry.Contract.Providers(&_ProviderRegistry.CallOpts, arg0) +} + +// Token is a free data retrieval call binding the contract method 0xfc0c546a. +// +// Solidity: function token() view returns(address) +func (_ProviderRegistry *ProviderRegistryCaller) Token(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _ProviderRegistry.contract.Call(opts, &out, "token") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Token is a free data retrieval call binding the contract method 0xfc0c546a. +// +// Solidity: function token() view returns(address) +func (_ProviderRegistry *ProviderRegistrySession) Token() (common.Address, error) { + return _ProviderRegistry.Contract.Token(&_ProviderRegistry.CallOpts) +} + +// Token is a free data retrieval call binding the contract method 0xfc0c546a. +// +// Solidity: function token() view returns(address) +func (_ProviderRegistry *ProviderRegistryCallerSession) Token() (common.Address, error) { + return _ProviderRegistry.Contract.Token(&_ProviderRegistry.CallOpts) +} + +// Deregister is a paid mutator transaction binding the contract method 0x84ac33ec. +// +// Solidity: function deregister(address addr) returns() +func (_ProviderRegistry *ProviderRegistryTransactor) Deregister(opts *bind.TransactOpts, addr common.Address) (*types.Transaction, error) { + return _ProviderRegistry.contract.Transact(opts, "deregister", addr) +} + +// Deregister is a paid mutator transaction binding the contract method 0x84ac33ec. +// +// Solidity: function deregister(address addr) returns() +func (_ProviderRegistry *ProviderRegistrySession) Deregister(addr common.Address) (*types.Transaction, error) { + return _ProviderRegistry.Contract.Deregister(&_ProviderRegistry.TransactOpts, addr) +} + +// Deregister is a paid mutator transaction binding the contract method 0x84ac33ec. +// +// Solidity: function deregister(address addr) returns() +func (_ProviderRegistry *ProviderRegistryTransactorSession) Deregister(addr common.Address) (*types.Transaction, error) { + return _ProviderRegistry.Contract.Deregister(&_ProviderRegistry.TransactOpts, addr) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc4d66de8. +// +// Solidity: function initialize(address _token) returns() +func (_ProviderRegistry *ProviderRegistryTransactor) Initialize(opts *bind.TransactOpts, _token common.Address) (*types.Transaction, error) { + return _ProviderRegistry.contract.Transact(opts, "initialize", _token) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc4d66de8. +// +// Solidity: function initialize(address _token) returns() +func (_ProviderRegistry *ProviderRegistrySession) Initialize(_token common.Address) (*types.Transaction, error) { + return _ProviderRegistry.Contract.Initialize(&_ProviderRegistry.TransactOpts, _token) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc4d66de8. +// +// Solidity: function initialize(address _token) returns() +func (_ProviderRegistry *ProviderRegistryTransactorSession) Initialize(_token common.Address) (*types.Transaction, error) { + return _ProviderRegistry.Contract.Initialize(&_ProviderRegistry.TransactOpts, _token) +} + +// Register is a paid mutator transaction binding the contract method 0xf11b1b88. +// +// Solidity: function register(address addr, uint256 addStake, string endpoint) returns() +func (_ProviderRegistry *ProviderRegistryTransactor) Register(opts *bind.TransactOpts, addr common.Address, addStake *big.Int, endpoint string) (*types.Transaction, error) { + return _ProviderRegistry.contract.Transact(opts, "register", addr, addStake, endpoint) +} + +// Register is a paid mutator transaction binding the contract method 0xf11b1b88. +// +// Solidity: function register(address addr, uint256 addStake, string endpoint) returns() +func (_ProviderRegistry *ProviderRegistrySession) Register(addr common.Address, addStake *big.Int, endpoint string) (*types.Transaction, error) { + return _ProviderRegistry.Contract.Register(&_ProviderRegistry.TransactOpts, addr, addStake, endpoint) +} + +// Register is a paid mutator transaction binding the contract method 0xf11b1b88. +// +// Solidity: function register(address addr, uint256 addStake, string endpoint) returns() +func (_ProviderRegistry *ProviderRegistryTransactorSession) Register(addr common.Address, addStake *big.Int, endpoint string) (*types.Transaction, error) { + return _ProviderRegistry.Contract.Register(&_ProviderRegistry.TransactOpts, addr, addStake, endpoint) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_ProviderRegistry *ProviderRegistryTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ProviderRegistry.contract.Transact(opts, "renounceOwnership") +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_ProviderRegistry *ProviderRegistrySession) RenounceOwnership() (*types.Transaction, error) { + return _ProviderRegistry.Contract.RenounceOwnership(&_ProviderRegistry.TransactOpts) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_ProviderRegistry *ProviderRegistryTransactorSession) RenounceOwnership() (*types.Transaction, error) { + return _ProviderRegistry.Contract.RenounceOwnership(&_ProviderRegistry.TransactOpts) +} + +// SetMinStake is a paid mutator transaction binding the contract method 0x8c80fd90. +// +// Solidity: function setMinStake(uint256 _minStake) returns() +func (_ProviderRegistry *ProviderRegistryTransactor) SetMinStake(opts *bind.TransactOpts, _minStake *big.Int) (*types.Transaction, error) { + return _ProviderRegistry.contract.Transact(opts, "setMinStake", _minStake) +} + +// SetMinStake is a paid mutator transaction binding the contract method 0x8c80fd90. +// +// Solidity: function setMinStake(uint256 _minStake) returns() +func (_ProviderRegistry *ProviderRegistrySession) SetMinStake(_minStake *big.Int) (*types.Transaction, error) { + return _ProviderRegistry.Contract.SetMinStake(&_ProviderRegistry.TransactOpts, _minStake) +} + +// SetMinStake is a paid mutator transaction binding the contract method 0x8c80fd90. +// +// Solidity: function setMinStake(uint256 _minStake) returns() +func (_ProviderRegistry *ProviderRegistryTransactorSession) SetMinStake(_minStake *big.Int) (*types.Transaction, error) { + return _ProviderRegistry.Contract.SetMinStake(&_ProviderRegistry.TransactOpts, _minStake) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_ProviderRegistry *ProviderRegistryTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) { + return _ProviderRegistry.contract.Transact(opts, "transferOwnership", newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_ProviderRegistry *ProviderRegistrySession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _ProviderRegistry.Contract.TransferOwnership(&_ProviderRegistry.TransactOpts, newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_ProviderRegistry *ProviderRegistryTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _ProviderRegistry.Contract.TransferOwnership(&_ProviderRegistry.TransactOpts, newOwner) +} + +// ProviderRegistryDeregisteredIterator is returned from FilterDeregistered and is used to iterate over the raw logs and unpacked data for Deregistered events raised by the ProviderRegistry contract. +type ProviderRegistryDeregisteredIterator struct { + Event *ProviderRegistryDeregistered // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ProviderRegistryDeregisteredIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ProviderRegistryDeregistered) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ProviderRegistryDeregistered) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ProviderRegistryDeregisteredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ProviderRegistryDeregisteredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ProviderRegistryDeregistered represents a Deregistered event raised by the ProviderRegistry contract. +type ProviderRegistryDeregistered struct { + Provider common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterDeregistered is a free log retrieval operation binding the contract event 0xafebd0f81ba8c430fcc0c6a6e7a26fd7f868af9c4e4f19db37a0f16502374fd5. +// +// Solidity: event Deregistered(address indexed provider) +func (_ProviderRegistry *ProviderRegistryFilterer) FilterDeregistered(opts *bind.FilterOpts, provider []common.Address) (*ProviderRegistryDeregisteredIterator, error) { + + var providerRule []interface{} + for _, providerItem := range provider { + providerRule = append(providerRule, providerItem) + } + + logs, sub, err := _ProviderRegistry.contract.FilterLogs(opts, "Deregistered", providerRule) + if err != nil { + return nil, err + } + return &ProviderRegistryDeregisteredIterator{contract: _ProviderRegistry.contract, event: "Deregistered", logs: logs, sub: sub}, nil +} + +// WatchDeregistered is a free log subscription operation binding the contract event 0xafebd0f81ba8c430fcc0c6a6e7a26fd7f868af9c4e4f19db37a0f16502374fd5. +// +// Solidity: event Deregistered(address indexed provider) +func (_ProviderRegistry *ProviderRegistryFilterer) WatchDeregistered(opts *bind.WatchOpts, sink chan<- *ProviderRegistryDeregistered, provider []common.Address) (event.Subscription, error) { + + var providerRule []interface{} + for _, providerItem := range provider { + providerRule = append(providerRule, providerItem) + } + + logs, sub, err := _ProviderRegistry.contract.WatchLogs(opts, "Deregistered", providerRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ProviderRegistryDeregistered) + if err := _ProviderRegistry.contract.UnpackLog(event, "Deregistered", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseDeregistered is a log parse operation binding the contract event 0xafebd0f81ba8c430fcc0c6a6e7a26fd7f868af9c4e4f19db37a0f16502374fd5. +// +// Solidity: event Deregistered(address indexed provider) +func (_ProviderRegistry *ProviderRegistryFilterer) ParseDeregistered(log types.Log) (*ProviderRegistryDeregistered, error) { + event := new(ProviderRegistryDeregistered) + if err := _ProviderRegistry.contract.UnpackLog(event, "Deregistered", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// ProviderRegistryInitializedIterator is returned from FilterInitialized and is used to iterate over the raw logs and unpacked data for Initialized events raised by the ProviderRegistry contract. +type ProviderRegistryInitializedIterator struct { + Event *ProviderRegistryInitialized // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ProviderRegistryInitializedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ProviderRegistryInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ProviderRegistryInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ProviderRegistryInitializedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ProviderRegistryInitializedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ProviderRegistryInitialized represents a Initialized event raised by the ProviderRegistry contract. +type ProviderRegistryInitialized struct { + Version uint8 + Raw types.Log // Blockchain specific contextual infos +} + +// FilterInitialized is a free log retrieval operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_ProviderRegistry *ProviderRegistryFilterer) FilterInitialized(opts *bind.FilterOpts) (*ProviderRegistryInitializedIterator, error) { + + logs, sub, err := _ProviderRegistry.contract.FilterLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return &ProviderRegistryInitializedIterator{contract: _ProviderRegistry.contract, event: "Initialized", logs: logs, sub: sub}, nil +} + +// WatchInitialized is a free log subscription operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_ProviderRegistry *ProviderRegistryFilterer) WatchInitialized(opts *bind.WatchOpts, sink chan<- *ProviderRegistryInitialized) (event.Subscription, error) { + + logs, sub, err := _ProviderRegistry.contract.WatchLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ProviderRegistryInitialized) + if err := _ProviderRegistry.contract.UnpackLog(event, "Initialized", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseInitialized is a log parse operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_ProviderRegistry *ProviderRegistryFilterer) ParseInitialized(log types.Log) (*ProviderRegistryInitialized, error) { + event := new(ProviderRegistryInitialized) + if err := _ProviderRegistry.contract.UnpackLog(event, "Initialized", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// ProviderRegistryMinStakeUpdatedIterator is returned from FilterMinStakeUpdated and is used to iterate over the raw logs and unpacked data for MinStakeUpdated events raised by the ProviderRegistry contract. +type ProviderRegistryMinStakeUpdatedIterator struct { + Event *ProviderRegistryMinStakeUpdated // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ProviderRegistryMinStakeUpdatedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ProviderRegistryMinStakeUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ProviderRegistryMinStakeUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ProviderRegistryMinStakeUpdatedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ProviderRegistryMinStakeUpdatedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ProviderRegistryMinStakeUpdated represents a MinStakeUpdated event raised by the ProviderRegistry contract. +type ProviderRegistryMinStakeUpdated struct { + NewStake *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterMinStakeUpdated is a free log retrieval operation binding the contract event 0x47ab46f2c8d4258304a2f5551c1cbdb6981be49631365d1ba7191288a73f39ef. +// +// Solidity: event MinStakeUpdated(uint256 newStake) +func (_ProviderRegistry *ProviderRegistryFilterer) FilterMinStakeUpdated(opts *bind.FilterOpts) (*ProviderRegistryMinStakeUpdatedIterator, error) { + + logs, sub, err := _ProviderRegistry.contract.FilterLogs(opts, "MinStakeUpdated") + if err != nil { + return nil, err + } + return &ProviderRegistryMinStakeUpdatedIterator{contract: _ProviderRegistry.contract, event: "MinStakeUpdated", logs: logs, sub: sub}, nil +} + +// WatchMinStakeUpdated is a free log subscription operation binding the contract event 0x47ab46f2c8d4258304a2f5551c1cbdb6981be49631365d1ba7191288a73f39ef. +// +// Solidity: event MinStakeUpdated(uint256 newStake) +func (_ProviderRegistry *ProviderRegistryFilterer) WatchMinStakeUpdated(opts *bind.WatchOpts, sink chan<- *ProviderRegistryMinStakeUpdated) (event.Subscription, error) { + + logs, sub, err := _ProviderRegistry.contract.WatchLogs(opts, "MinStakeUpdated") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ProviderRegistryMinStakeUpdated) + if err := _ProviderRegistry.contract.UnpackLog(event, "MinStakeUpdated", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseMinStakeUpdated is a log parse operation binding the contract event 0x47ab46f2c8d4258304a2f5551c1cbdb6981be49631365d1ba7191288a73f39ef. +// +// Solidity: event MinStakeUpdated(uint256 newStake) +func (_ProviderRegistry *ProviderRegistryFilterer) ParseMinStakeUpdated(log types.Log) (*ProviderRegistryMinStakeUpdated, error) { + event := new(ProviderRegistryMinStakeUpdated) + if err := _ProviderRegistry.contract.UnpackLog(event, "MinStakeUpdated", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// ProviderRegistryOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the ProviderRegistry contract. +type ProviderRegistryOwnershipTransferredIterator struct { + Event *ProviderRegistryOwnershipTransferred // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ProviderRegistryOwnershipTransferredIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ProviderRegistryOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ProviderRegistryOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ProviderRegistryOwnershipTransferredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ProviderRegistryOwnershipTransferredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ProviderRegistryOwnershipTransferred represents a OwnershipTransferred event raised by the ProviderRegistry contract. +type ProviderRegistryOwnershipTransferred struct { + PreviousOwner common.Address + NewOwner common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_ProviderRegistry *ProviderRegistryFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*ProviderRegistryOwnershipTransferredIterator, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _ProviderRegistry.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return &ProviderRegistryOwnershipTransferredIterator{contract: _ProviderRegistry.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil +} + +// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_ProviderRegistry *ProviderRegistryFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *ProviderRegistryOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _ProviderRegistry.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ProviderRegistryOwnershipTransferred) + if err := _ProviderRegistry.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_ProviderRegistry *ProviderRegistryFilterer) ParseOwnershipTransferred(log types.Log) (*ProviderRegistryOwnershipTransferred, error) { + event := new(ProviderRegistryOwnershipTransferred) + if err := _ProviderRegistry.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// ProviderRegistryRegisteredUpdatedIterator is returned from FilterRegisteredUpdated and is used to iterate over the raw logs and unpacked data for RegisteredUpdated events raised by the ProviderRegistry contract. +type ProviderRegistryRegisteredUpdatedIterator struct { + Event *ProviderRegistryRegisteredUpdated // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ProviderRegistryRegisteredUpdatedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ProviderRegistryRegisteredUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ProviderRegistryRegisteredUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ProviderRegistryRegisteredUpdatedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ProviderRegistryRegisteredUpdatedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ProviderRegistryRegisteredUpdated represents a RegisteredUpdated event raised by the ProviderRegistry contract. +type ProviderRegistryRegisteredUpdated struct { + Provider common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterRegisteredUpdated is a free log retrieval operation binding the contract event 0x0407973ec6e86eb9f260606351583a2737e1db4d6f44c2414e699bd665ae10dc. +// +// Solidity: event RegisteredUpdated(address indexed provider) +func (_ProviderRegistry *ProviderRegistryFilterer) FilterRegisteredUpdated(opts *bind.FilterOpts, provider []common.Address) (*ProviderRegistryRegisteredUpdatedIterator, error) { + + var providerRule []interface{} + for _, providerItem := range provider { + providerRule = append(providerRule, providerItem) + } + + logs, sub, err := _ProviderRegistry.contract.FilterLogs(opts, "RegisteredUpdated", providerRule) + if err != nil { + return nil, err + } + return &ProviderRegistryRegisteredUpdatedIterator{contract: _ProviderRegistry.contract, event: "RegisteredUpdated", logs: logs, sub: sub}, nil +} + +// WatchRegisteredUpdated is a free log subscription operation binding the contract event 0x0407973ec6e86eb9f260606351583a2737e1db4d6f44c2414e699bd665ae10dc. +// +// Solidity: event RegisteredUpdated(address indexed provider) +func (_ProviderRegistry *ProviderRegistryFilterer) WatchRegisteredUpdated(opts *bind.WatchOpts, sink chan<- *ProviderRegistryRegisteredUpdated, provider []common.Address) (event.Subscription, error) { + + var providerRule []interface{} + for _, providerItem := range provider { + providerRule = append(providerRule, providerItem) + } + + logs, sub, err := _ProviderRegistry.contract.WatchLogs(opts, "RegisteredUpdated", providerRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ProviderRegistryRegisteredUpdated) + if err := _ProviderRegistry.contract.UnpackLog(event, "RegisteredUpdated", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseRegisteredUpdated is a log parse operation binding the contract event 0x0407973ec6e86eb9f260606351583a2737e1db4d6f44c2414e699bd665ae10dc. +// +// Solidity: event RegisteredUpdated(address indexed provider) +func (_ProviderRegistry *ProviderRegistryFilterer) ParseRegisteredUpdated(log types.Log) (*ProviderRegistryRegisteredUpdated, error) { + event := new(ProviderRegistryRegisteredUpdated) + if err := _ProviderRegistry.contract.UnpackLog(event, "RegisteredUpdated", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/proxy-router/contracts/sessionrouter/SessionRouter.go b/proxy-router/contracts/sessionrouter/SessionRouter.go new file mode 100644 index 00000000..516bbb93 --- /dev/null +++ b/proxy-router/contracts/sessionrouter/SessionRouter.go @@ -0,0 +1,1944 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package sessionrouter + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// SessionRouterSession is an auto generated low-level Go binding around an user-defined struct. +type SessionRouterSession struct { + Id [32]byte + User common.Address + Provider common.Address + ModelAgentId [32]byte + Budget *big.Int + Price *big.Int + CloseoutReceipt []byte + CloseoutType *big.Int + OpenedAt *big.Int + ClosedAt *big.Int +} + +// SessionRouterMetaData contains all meta data concerning the SessionRouter contract. +var SessionRouterMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[],\"name\":\"BidNotFound\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidSignature\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotEnoughBalance\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotEnoughStipend\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotSenderOrOwner\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotUser\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotUserOrProvider\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SessionNotFound\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SessionTooShort\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"providerAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"ProviderClaimed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"userAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"sessionId\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"providerId\",\"type\":\"address\"}],\"name\":\"SessionClosed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"userAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"sessionId\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"providerId\",\"type\":\"address\"}],\"name\":\"SessionOpened\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"userAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Staked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"userAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Unstaked\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amountToWithdraw\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"}],\"name\":\"claimProviderBalance\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"sessionId\",\"type\":\"bytes32\"},{\"internalType\":\"bytes\",\"name\":\"receiptEncoded\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"name\":\"closeSession\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"sessionId\",\"type\":\"bytes32\"}],\"name\":\"deleteHistory\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"_encodedMessage\",\"type\":\"bytes\"}],\"name\":\"getEthSignedMessageHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"providerAddr\",\"type\":\"address\"}],\"name\":\"getProviderBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"total\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"hold\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"providerAddr\",\"type\":\"address\"}],\"name\":\"getProviderClaimBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"sessionId\",\"type\":\"bytes32\"}],\"name\":\"getSession\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"id\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"modelAgentId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"budget\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"closeoutReceipt\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"closeoutType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"openedAt\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"closedAt\",\"type\":\"uint256\"}],\"internalType\":\"structSessionRouter.Session\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_stakingDailyStipend\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_marketplace\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"map\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"marketplace\",\"outputs\":[{\"internalType\":\"contractMarketplace\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"bidId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"budget\",\"type\":\"uint256\"}],\"name\":\"openSession\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"sessionId\",\"type\":\"bytes32\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"providerOnHold\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"releaseAt\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"message\",\"type\":\"bytes32\"},{\"internalType\":\"bytes\",\"name\":\"sig\",\"type\":\"bytes\"}],\"name\":\"recoverSigner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"sessions\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"id\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"modelAgentId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"budget\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"closeoutReceipt\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"closeoutType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"openedAt\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"closedAt\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"int256\",\"name\":\"delay\",\"type\":\"int256\"}],\"name\":\"setStakeDelay\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"sig\",\"type\":\"bytes\"}],\"name\":\"splitSignature\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"stakeDelay\",\"outputs\":[{\"internalType\":\"int256\",\"name\":\"\",\"type\":\"int256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"stakingDailyStipend\",\"outputs\":[{\"internalType\":\"contractStakingDailyStipend\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"token\",\"outputs\":[{\"internalType\":\"contractIERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", +} + +// SessionRouterABI is the input ABI used to generate the binding from. +// Deprecated: Use SessionRouterMetaData.ABI instead. +var SessionRouterABI = SessionRouterMetaData.ABI + +// SessionRouter is an auto generated Go binding around an Ethereum contract. +type SessionRouter struct { + SessionRouterCaller // Read-only binding to the contract + SessionRouterTransactor // Write-only binding to the contract + SessionRouterFilterer // Log filterer for contract events +} + +// SessionRouterCaller is an auto generated read-only Go binding around an Ethereum contract. +type SessionRouterCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// SessionRouterTransactor is an auto generated write-only Go binding around an Ethereum contract. +type SessionRouterTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// SessionRouterFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type SessionRouterFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// SessionRouterSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type SessionRouterSession struct { + Contract *SessionRouter // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// SessionRouterCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type SessionRouterCallerSession struct { + Contract *SessionRouterCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// SessionRouterTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type SessionRouterTransactorSession struct { + Contract *SessionRouterTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// SessionRouterRaw is an auto generated low-level Go binding around an Ethereum contract. +type SessionRouterRaw struct { + Contract *SessionRouter // Generic contract binding to access the raw methods on +} + +// SessionRouterCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type SessionRouterCallerRaw struct { + Contract *SessionRouterCaller // Generic read-only contract binding to access the raw methods on +} + +// SessionRouterTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type SessionRouterTransactorRaw struct { + Contract *SessionRouterTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewSessionRouter creates a new instance of SessionRouter, bound to a specific deployed contract. +func NewSessionRouter(address common.Address, backend bind.ContractBackend) (*SessionRouter, error) { + contract, err := bindSessionRouter(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &SessionRouter{SessionRouterCaller: SessionRouterCaller{contract: contract}, SessionRouterTransactor: SessionRouterTransactor{contract: contract}, SessionRouterFilterer: SessionRouterFilterer{contract: contract}}, nil +} + +// NewSessionRouterCaller creates a new read-only instance of SessionRouter, bound to a specific deployed contract. +func NewSessionRouterCaller(address common.Address, caller bind.ContractCaller) (*SessionRouterCaller, error) { + contract, err := bindSessionRouter(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &SessionRouterCaller{contract: contract}, nil +} + +// NewSessionRouterTransactor creates a new write-only instance of SessionRouter, bound to a specific deployed contract. +func NewSessionRouterTransactor(address common.Address, transactor bind.ContractTransactor) (*SessionRouterTransactor, error) { + contract, err := bindSessionRouter(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &SessionRouterTransactor{contract: contract}, nil +} + +// NewSessionRouterFilterer creates a new log filterer instance of SessionRouter, bound to a specific deployed contract. +func NewSessionRouterFilterer(address common.Address, filterer bind.ContractFilterer) (*SessionRouterFilterer, error) { + contract, err := bindSessionRouter(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &SessionRouterFilterer{contract: contract}, nil +} + +// bindSessionRouter binds a generic wrapper to an already deployed contract. +func bindSessionRouter(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := SessionRouterMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_SessionRouter *SessionRouterRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _SessionRouter.Contract.SessionRouterCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_SessionRouter *SessionRouterRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _SessionRouter.Contract.SessionRouterTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_SessionRouter *SessionRouterRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _SessionRouter.Contract.SessionRouterTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_SessionRouter *SessionRouterCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _SessionRouter.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_SessionRouter *SessionRouterTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _SessionRouter.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_SessionRouter *SessionRouterTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _SessionRouter.Contract.contract.Transact(opts, method, params...) +} + +// GetEthSignedMessageHash is a free data retrieval call binding the contract method 0xf9aea466. +// +// Solidity: function getEthSignedMessageHash(bytes _encodedMessage) pure returns(bytes32) +func (_SessionRouter *SessionRouterCaller) GetEthSignedMessageHash(opts *bind.CallOpts, _encodedMessage []byte) ([32]byte, error) { + var out []interface{} + err := _SessionRouter.contract.Call(opts, &out, "getEthSignedMessageHash", _encodedMessage) + + if err != nil { + return *new([32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + + return out0, err + +} + +// GetEthSignedMessageHash is a free data retrieval call binding the contract method 0xf9aea466. +// +// Solidity: function getEthSignedMessageHash(bytes _encodedMessage) pure returns(bytes32) +func (_SessionRouter *SessionRouterSession) GetEthSignedMessageHash(_encodedMessage []byte) ([32]byte, error) { + return _SessionRouter.Contract.GetEthSignedMessageHash(&_SessionRouter.CallOpts, _encodedMessage) +} + +// GetEthSignedMessageHash is a free data retrieval call binding the contract method 0xf9aea466. +// +// Solidity: function getEthSignedMessageHash(bytes _encodedMessage) pure returns(bytes32) +func (_SessionRouter *SessionRouterCallerSession) GetEthSignedMessageHash(_encodedMessage []byte) ([32]byte, error) { + return _SessionRouter.Contract.GetEthSignedMessageHash(&_SessionRouter.CallOpts, _encodedMessage) +} + +// GetProviderBalance is a free data retrieval call binding the contract method 0x832eea0c. +// +// Solidity: function getProviderBalance(address providerAddr) view returns(uint256 total, uint256 hold) +func (_SessionRouter *SessionRouterCaller) GetProviderBalance(opts *bind.CallOpts, providerAddr common.Address) (struct { + Total *big.Int + Hold *big.Int +}, error) { + var out []interface{} + err := _SessionRouter.contract.Call(opts, &out, "getProviderBalance", providerAddr) + + outstruct := new(struct { + Total *big.Int + Hold *big.Int + }) + if err != nil { + return *outstruct, err + } + + outstruct.Total = *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + outstruct.Hold = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) + + return *outstruct, err + +} + +// GetProviderBalance is a free data retrieval call binding the contract method 0x832eea0c. +// +// Solidity: function getProviderBalance(address providerAddr) view returns(uint256 total, uint256 hold) +func (_SessionRouter *SessionRouterSession) GetProviderBalance(providerAddr common.Address) (struct { + Total *big.Int + Hold *big.Int +}, error) { + return _SessionRouter.Contract.GetProviderBalance(&_SessionRouter.CallOpts, providerAddr) +} + +// GetProviderBalance is a free data retrieval call binding the contract method 0x832eea0c. +// +// Solidity: function getProviderBalance(address providerAddr) view returns(uint256 total, uint256 hold) +func (_SessionRouter *SessionRouterCallerSession) GetProviderBalance(providerAddr common.Address) (struct { + Total *big.Int + Hold *big.Int +}, error) { + return _SessionRouter.Contract.GetProviderBalance(&_SessionRouter.CallOpts, providerAddr) +} + +// GetProviderClaimBalance is a free data retrieval call binding the contract method 0x6c98599b. +// +// Solidity: function getProviderClaimBalance(address providerAddr) view returns(uint256) +func (_SessionRouter *SessionRouterCaller) GetProviderClaimBalance(opts *bind.CallOpts, providerAddr common.Address) (*big.Int, error) { + var out []interface{} + err := _SessionRouter.contract.Call(opts, &out, "getProviderClaimBalance", providerAddr) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetProviderClaimBalance is a free data retrieval call binding the contract method 0x6c98599b. +// +// Solidity: function getProviderClaimBalance(address providerAddr) view returns(uint256) +func (_SessionRouter *SessionRouterSession) GetProviderClaimBalance(providerAddr common.Address) (*big.Int, error) { + return _SessionRouter.Contract.GetProviderClaimBalance(&_SessionRouter.CallOpts, providerAddr) +} + +// GetProviderClaimBalance is a free data retrieval call binding the contract method 0x6c98599b. +// +// Solidity: function getProviderClaimBalance(address providerAddr) view returns(uint256) +func (_SessionRouter *SessionRouterCallerSession) GetProviderClaimBalance(providerAddr common.Address) (*big.Int, error) { + return _SessionRouter.Contract.GetProviderClaimBalance(&_SessionRouter.CallOpts, providerAddr) +} + +// GetSession is a free data retrieval call binding the contract method 0x39b240bd. +// +// Solidity: function getSession(bytes32 sessionId) view returns((bytes32,address,address,bytes32,uint256,uint256,bytes,uint256,uint256,uint256)) +func (_SessionRouter *SessionRouterCaller) GetSession(opts *bind.CallOpts, sessionId [32]byte) (SessionRouterSession, error) { + var out []interface{} + err := _SessionRouter.contract.Call(opts, &out, "getSession", sessionId) + + if err != nil { + return *new(SessionRouterSession), err + } + + out0 := *abi.ConvertType(out[0], new(SessionRouterSession)).(*SessionRouterSession) + + return out0, err + +} + +// GetSession is a free data retrieval call binding the contract method 0x39b240bd. +// +// Solidity: function getSession(bytes32 sessionId) view returns((bytes32,address,address,bytes32,uint256,uint256,bytes,uint256,uint256,uint256)) +func (_SessionRouter *SessionRouterSession) GetSession(sessionId [32]byte) (SessionRouterSession, error) { + return _SessionRouter.Contract.GetSession(&_SessionRouter.CallOpts, sessionId) +} + +// GetSession is a free data retrieval call binding the contract method 0x39b240bd. +// +// Solidity: function getSession(bytes32 sessionId) view returns((bytes32,address,address,bytes32,uint256,uint256,bytes,uint256,uint256,uint256)) +func (_SessionRouter *SessionRouterCallerSession) GetSession(sessionId [32]byte) (SessionRouterSession, error) { + return _SessionRouter.Contract.GetSession(&_SessionRouter.CallOpts, sessionId) +} + +// Map is a free data retrieval call binding the contract method 0x0ae186a8. +// +// Solidity: function map(bytes32 ) view returns(uint256) +func (_SessionRouter *SessionRouterCaller) Map(opts *bind.CallOpts, arg0 [32]byte) (*big.Int, error) { + var out []interface{} + err := _SessionRouter.contract.Call(opts, &out, "map", arg0) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// Map is a free data retrieval call binding the contract method 0x0ae186a8. +// +// Solidity: function map(bytes32 ) view returns(uint256) +func (_SessionRouter *SessionRouterSession) Map(arg0 [32]byte) (*big.Int, error) { + return _SessionRouter.Contract.Map(&_SessionRouter.CallOpts, arg0) +} + +// Map is a free data retrieval call binding the contract method 0x0ae186a8. +// +// Solidity: function map(bytes32 ) view returns(uint256) +func (_SessionRouter *SessionRouterCallerSession) Map(arg0 [32]byte) (*big.Int, error) { + return _SessionRouter.Contract.Map(&_SessionRouter.CallOpts, arg0) +} + +// Marketplace is a free data retrieval call binding the contract method 0xabc8c7af. +// +// Solidity: function marketplace() view returns(address) +func (_SessionRouter *SessionRouterCaller) Marketplace(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _SessionRouter.contract.Call(opts, &out, "marketplace") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Marketplace is a free data retrieval call binding the contract method 0xabc8c7af. +// +// Solidity: function marketplace() view returns(address) +func (_SessionRouter *SessionRouterSession) Marketplace() (common.Address, error) { + return _SessionRouter.Contract.Marketplace(&_SessionRouter.CallOpts) +} + +// Marketplace is a free data retrieval call binding the contract method 0xabc8c7af. +// +// Solidity: function marketplace() view returns(address) +func (_SessionRouter *SessionRouterCallerSession) Marketplace() (common.Address, error) { + return _SessionRouter.Contract.Marketplace(&_SessionRouter.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_SessionRouter *SessionRouterCaller) Owner(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _SessionRouter.contract.Call(opts, &out, "owner") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_SessionRouter *SessionRouterSession) Owner() (common.Address, error) { + return _SessionRouter.Contract.Owner(&_SessionRouter.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_SessionRouter *SessionRouterCallerSession) Owner() (common.Address, error) { + return _SessionRouter.Contract.Owner(&_SessionRouter.CallOpts) +} + +// ProviderOnHold is a free data retrieval call binding the contract method 0xdbf7d54f. +// +// Solidity: function providerOnHold(address , uint256 ) view returns(uint256 amount, uint256 releaseAt) +func (_SessionRouter *SessionRouterCaller) ProviderOnHold(opts *bind.CallOpts, arg0 common.Address, arg1 *big.Int) (struct { + Amount *big.Int + ReleaseAt *big.Int +}, error) { + var out []interface{} + err := _SessionRouter.contract.Call(opts, &out, "providerOnHold", arg0, arg1) + + outstruct := new(struct { + Amount *big.Int + ReleaseAt *big.Int + }) + if err != nil { + return *outstruct, err + } + + outstruct.Amount = *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + outstruct.ReleaseAt = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) + + return *outstruct, err + +} + +// ProviderOnHold is a free data retrieval call binding the contract method 0xdbf7d54f. +// +// Solidity: function providerOnHold(address , uint256 ) view returns(uint256 amount, uint256 releaseAt) +func (_SessionRouter *SessionRouterSession) ProviderOnHold(arg0 common.Address, arg1 *big.Int) (struct { + Amount *big.Int + ReleaseAt *big.Int +}, error) { + return _SessionRouter.Contract.ProviderOnHold(&_SessionRouter.CallOpts, arg0, arg1) +} + +// ProviderOnHold is a free data retrieval call binding the contract method 0xdbf7d54f. +// +// Solidity: function providerOnHold(address , uint256 ) view returns(uint256 amount, uint256 releaseAt) +func (_SessionRouter *SessionRouterCallerSession) ProviderOnHold(arg0 common.Address, arg1 *big.Int) (struct { + Amount *big.Int + ReleaseAt *big.Int +}, error) { + return _SessionRouter.Contract.ProviderOnHold(&_SessionRouter.CallOpts, arg0, arg1) +} + +// RecoverSigner is a free data retrieval call binding the contract method 0x97aba7f9. +// +// Solidity: function recoverSigner(bytes32 message, bytes sig) pure returns(address) +func (_SessionRouter *SessionRouterCaller) RecoverSigner(opts *bind.CallOpts, message [32]byte, sig []byte) (common.Address, error) { + var out []interface{} + err := _SessionRouter.contract.Call(opts, &out, "recoverSigner", message, sig) + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// RecoverSigner is a free data retrieval call binding the contract method 0x97aba7f9. +// +// Solidity: function recoverSigner(bytes32 message, bytes sig) pure returns(address) +func (_SessionRouter *SessionRouterSession) RecoverSigner(message [32]byte, sig []byte) (common.Address, error) { + return _SessionRouter.Contract.RecoverSigner(&_SessionRouter.CallOpts, message, sig) +} + +// RecoverSigner is a free data retrieval call binding the contract method 0x97aba7f9. +// +// Solidity: function recoverSigner(bytes32 message, bytes sig) pure returns(address) +func (_SessionRouter *SessionRouterCallerSession) RecoverSigner(message [32]byte, sig []byte) (common.Address, error) { + return _SessionRouter.Contract.RecoverSigner(&_SessionRouter.CallOpts, message, sig) +} + +// Sessions is a free data retrieval call binding the contract method 0x83c4b7a3. +// +// Solidity: function sessions(uint256 ) view returns(bytes32 id, address user, address provider, bytes32 modelAgentId, uint256 budget, uint256 price, bytes closeoutReceipt, uint256 closeoutType, uint256 openedAt, uint256 closedAt) +func (_SessionRouter *SessionRouterCaller) Sessions(opts *bind.CallOpts, arg0 *big.Int) (struct { + Id [32]byte + User common.Address + Provider common.Address + ModelAgentId [32]byte + Budget *big.Int + Price *big.Int + CloseoutReceipt []byte + CloseoutType *big.Int + OpenedAt *big.Int + ClosedAt *big.Int +}, error) { + var out []interface{} + err := _SessionRouter.contract.Call(opts, &out, "sessions", arg0) + + outstruct := new(struct { + Id [32]byte + User common.Address + Provider common.Address + ModelAgentId [32]byte + Budget *big.Int + Price *big.Int + CloseoutReceipt []byte + CloseoutType *big.Int + OpenedAt *big.Int + ClosedAt *big.Int + }) + if err != nil { + return *outstruct, err + } + + outstruct.Id = *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + outstruct.User = *abi.ConvertType(out[1], new(common.Address)).(*common.Address) + outstruct.Provider = *abi.ConvertType(out[2], new(common.Address)).(*common.Address) + outstruct.ModelAgentId = *abi.ConvertType(out[3], new([32]byte)).(*[32]byte) + outstruct.Budget = *abi.ConvertType(out[4], new(*big.Int)).(**big.Int) + outstruct.Price = *abi.ConvertType(out[5], new(*big.Int)).(**big.Int) + outstruct.CloseoutReceipt = *abi.ConvertType(out[6], new([]byte)).(*[]byte) + outstruct.CloseoutType = *abi.ConvertType(out[7], new(*big.Int)).(**big.Int) + outstruct.OpenedAt = *abi.ConvertType(out[8], new(*big.Int)).(**big.Int) + outstruct.ClosedAt = *abi.ConvertType(out[9], new(*big.Int)).(**big.Int) + + return *outstruct, err + +} + +// Sessions is a free data retrieval call binding the contract method 0x83c4b7a3. +// +// Solidity: function sessions(uint256 ) view returns(bytes32 id, address user, address provider, bytes32 modelAgentId, uint256 budget, uint256 price, bytes closeoutReceipt, uint256 closeoutType, uint256 openedAt, uint256 closedAt) +func (_SessionRouter *SessionRouterSession) Sessions(arg0 *big.Int) (struct { + Id [32]byte + User common.Address + Provider common.Address + ModelAgentId [32]byte + Budget *big.Int + Price *big.Int + CloseoutReceipt []byte + CloseoutType *big.Int + OpenedAt *big.Int + ClosedAt *big.Int +}, error) { + return _SessionRouter.Contract.Sessions(&_SessionRouter.CallOpts, arg0) +} + +// Sessions is a free data retrieval call binding the contract method 0x83c4b7a3. +// +// Solidity: function sessions(uint256 ) view returns(bytes32 id, address user, address provider, bytes32 modelAgentId, uint256 budget, uint256 price, bytes closeoutReceipt, uint256 closeoutType, uint256 openedAt, uint256 closedAt) +func (_SessionRouter *SessionRouterCallerSession) Sessions(arg0 *big.Int) (struct { + Id [32]byte + User common.Address + Provider common.Address + ModelAgentId [32]byte + Budget *big.Int + Price *big.Int + CloseoutReceipt []byte + CloseoutType *big.Int + OpenedAt *big.Int + ClosedAt *big.Int +}, error) { + return _SessionRouter.Contract.Sessions(&_SessionRouter.CallOpts, arg0) +} + +// SplitSignature is a free data retrieval call binding the contract method 0xa7bb5803. +// +// Solidity: function splitSignature(bytes sig) pure returns(bytes32 r, bytes32 s, uint8 v) +func (_SessionRouter *SessionRouterCaller) SplitSignature(opts *bind.CallOpts, sig []byte) (struct { + R [32]byte + S [32]byte + V uint8 +}, error) { + var out []interface{} + err := _SessionRouter.contract.Call(opts, &out, "splitSignature", sig) + + outstruct := new(struct { + R [32]byte + S [32]byte + V uint8 + }) + if err != nil { + return *outstruct, err + } + + outstruct.R = *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + outstruct.S = *abi.ConvertType(out[1], new([32]byte)).(*[32]byte) + outstruct.V = *abi.ConvertType(out[2], new(uint8)).(*uint8) + + return *outstruct, err + +} + +// SplitSignature is a free data retrieval call binding the contract method 0xa7bb5803. +// +// Solidity: function splitSignature(bytes sig) pure returns(bytes32 r, bytes32 s, uint8 v) +func (_SessionRouter *SessionRouterSession) SplitSignature(sig []byte) (struct { + R [32]byte + S [32]byte + V uint8 +}, error) { + return _SessionRouter.Contract.SplitSignature(&_SessionRouter.CallOpts, sig) +} + +// SplitSignature is a free data retrieval call binding the contract method 0xa7bb5803. +// +// Solidity: function splitSignature(bytes sig) pure returns(bytes32 r, bytes32 s, uint8 v) +func (_SessionRouter *SessionRouterCallerSession) SplitSignature(sig []byte) (struct { + R [32]byte + S [32]byte + V uint8 +}, error) { + return _SessionRouter.Contract.SplitSignature(&_SessionRouter.CallOpts, sig) +} + +// StakeDelay is a free data retrieval call binding the contract method 0x946ada60. +// +// Solidity: function stakeDelay() view returns(int256) +func (_SessionRouter *SessionRouterCaller) StakeDelay(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _SessionRouter.contract.Call(opts, &out, "stakeDelay") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// StakeDelay is a free data retrieval call binding the contract method 0x946ada60. +// +// Solidity: function stakeDelay() view returns(int256) +func (_SessionRouter *SessionRouterSession) StakeDelay() (*big.Int, error) { + return _SessionRouter.Contract.StakeDelay(&_SessionRouter.CallOpts) +} + +// StakeDelay is a free data retrieval call binding the contract method 0x946ada60. +// +// Solidity: function stakeDelay() view returns(int256) +func (_SessionRouter *SessionRouterCallerSession) StakeDelay() (*big.Int, error) { + return _SessionRouter.Contract.StakeDelay(&_SessionRouter.CallOpts) +} + +// StakingDailyStipend is a free data retrieval call binding the contract method 0xfcfc2201. +// +// Solidity: function stakingDailyStipend() view returns(address) +func (_SessionRouter *SessionRouterCaller) StakingDailyStipend(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _SessionRouter.contract.Call(opts, &out, "stakingDailyStipend") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// StakingDailyStipend is a free data retrieval call binding the contract method 0xfcfc2201. +// +// Solidity: function stakingDailyStipend() view returns(address) +func (_SessionRouter *SessionRouterSession) StakingDailyStipend() (common.Address, error) { + return _SessionRouter.Contract.StakingDailyStipend(&_SessionRouter.CallOpts) +} + +// StakingDailyStipend is a free data retrieval call binding the contract method 0xfcfc2201. +// +// Solidity: function stakingDailyStipend() view returns(address) +func (_SessionRouter *SessionRouterCallerSession) StakingDailyStipend() (common.Address, error) { + return _SessionRouter.Contract.StakingDailyStipend(&_SessionRouter.CallOpts) +} + +// Token is a free data retrieval call binding the contract method 0xfc0c546a. +// +// Solidity: function token() view returns(address) +func (_SessionRouter *SessionRouterCaller) Token(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _SessionRouter.contract.Call(opts, &out, "token") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Token is a free data retrieval call binding the contract method 0xfc0c546a. +// +// Solidity: function token() view returns(address) +func (_SessionRouter *SessionRouterSession) Token() (common.Address, error) { + return _SessionRouter.Contract.Token(&_SessionRouter.CallOpts) +} + +// Token is a free data retrieval call binding the contract method 0xfc0c546a. +// +// Solidity: function token() view returns(address) +func (_SessionRouter *SessionRouterCallerSession) Token() (common.Address, error) { + return _SessionRouter.Contract.Token(&_SessionRouter.CallOpts) +} + +// ClaimProviderBalance is a paid mutator transaction binding the contract method 0xc9a93c1a. +// +// Solidity: function claimProviderBalance(uint256 amountToWithdraw, address to) returns() +func (_SessionRouter *SessionRouterTransactor) ClaimProviderBalance(opts *bind.TransactOpts, amountToWithdraw *big.Int, to common.Address) (*types.Transaction, error) { + return _SessionRouter.contract.Transact(opts, "claimProviderBalance", amountToWithdraw, to) +} + +// ClaimProviderBalance is a paid mutator transaction binding the contract method 0xc9a93c1a. +// +// Solidity: function claimProviderBalance(uint256 amountToWithdraw, address to) returns() +func (_SessionRouter *SessionRouterSession) ClaimProviderBalance(amountToWithdraw *big.Int, to common.Address) (*types.Transaction, error) { + return _SessionRouter.Contract.ClaimProviderBalance(&_SessionRouter.TransactOpts, amountToWithdraw, to) +} + +// ClaimProviderBalance is a paid mutator transaction binding the contract method 0xc9a93c1a. +// +// Solidity: function claimProviderBalance(uint256 amountToWithdraw, address to) returns() +func (_SessionRouter *SessionRouterTransactorSession) ClaimProviderBalance(amountToWithdraw *big.Int, to common.Address) (*types.Transaction, error) { + return _SessionRouter.Contract.ClaimProviderBalance(&_SessionRouter.TransactOpts, amountToWithdraw, to) +} + +// CloseSession is a paid mutator transaction binding the contract method 0x9775d1ff. +// +// Solidity: function closeSession(bytes32 sessionId, bytes receiptEncoded, bytes signature) returns() +func (_SessionRouter *SessionRouterTransactor) CloseSession(opts *bind.TransactOpts, sessionId [32]byte, receiptEncoded []byte, signature []byte) (*types.Transaction, error) { + return _SessionRouter.contract.Transact(opts, "closeSession", sessionId, receiptEncoded, signature) +} + +// CloseSession is a paid mutator transaction binding the contract method 0x9775d1ff. +// +// Solidity: function closeSession(bytes32 sessionId, bytes receiptEncoded, bytes signature) returns() +func (_SessionRouter *SessionRouterSession) CloseSession(sessionId [32]byte, receiptEncoded []byte, signature []byte) (*types.Transaction, error) { + return _SessionRouter.Contract.CloseSession(&_SessionRouter.TransactOpts, sessionId, receiptEncoded, signature) +} + +// CloseSession is a paid mutator transaction binding the contract method 0x9775d1ff. +// +// Solidity: function closeSession(bytes32 sessionId, bytes receiptEncoded, bytes signature) returns() +func (_SessionRouter *SessionRouterTransactorSession) CloseSession(sessionId [32]byte, receiptEncoded []byte, signature []byte) (*types.Transaction, error) { + return _SessionRouter.Contract.CloseSession(&_SessionRouter.TransactOpts, sessionId, receiptEncoded, signature) +} + +// DeleteHistory is a paid mutator transaction binding the contract method 0xf074ca6b. +// +// Solidity: function deleteHistory(bytes32 sessionId) returns() +func (_SessionRouter *SessionRouterTransactor) DeleteHistory(opts *bind.TransactOpts, sessionId [32]byte) (*types.Transaction, error) { + return _SessionRouter.contract.Transact(opts, "deleteHistory", sessionId) +} + +// DeleteHistory is a paid mutator transaction binding the contract method 0xf074ca6b. +// +// Solidity: function deleteHistory(bytes32 sessionId) returns() +func (_SessionRouter *SessionRouterSession) DeleteHistory(sessionId [32]byte) (*types.Transaction, error) { + return _SessionRouter.Contract.DeleteHistory(&_SessionRouter.TransactOpts, sessionId) +} + +// DeleteHistory is a paid mutator transaction binding the contract method 0xf074ca6b. +// +// Solidity: function deleteHistory(bytes32 sessionId) returns() +func (_SessionRouter *SessionRouterTransactorSession) DeleteHistory(sessionId [32]byte) (*types.Transaction, error) { + return _SessionRouter.Contract.DeleteHistory(&_SessionRouter.TransactOpts, sessionId) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc0c53b8b. +// +// Solidity: function initialize(address _token, address _stakingDailyStipend, address _marketplace) returns() +func (_SessionRouter *SessionRouterTransactor) Initialize(opts *bind.TransactOpts, _token common.Address, _stakingDailyStipend common.Address, _marketplace common.Address) (*types.Transaction, error) { + return _SessionRouter.contract.Transact(opts, "initialize", _token, _stakingDailyStipend, _marketplace) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc0c53b8b. +// +// Solidity: function initialize(address _token, address _stakingDailyStipend, address _marketplace) returns() +func (_SessionRouter *SessionRouterSession) Initialize(_token common.Address, _stakingDailyStipend common.Address, _marketplace common.Address) (*types.Transaction, error) { + return _SessionRouter.Contract.Initialize(&_SessionRouter.TransactOpts, _token, _stakingDailyStipend, _marketplace) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc0c53b8b. +// +// Solidity: function initialize(address _token, address _stakingDailyStipend, address _marketplace) returns() +func (_SessionRouter *SessionRouterTransactorSession) Initialize(_token common.Address, _stakingDailyStipend common.Address, _marketplace common.Address) (*types.Transaction, error) { + return _SessionRouter.Contract.Initialize(&_SessionRouter.TransactOpts, _token, _stakingDailyStipend, _marketplace) +} + +// OpenSession is a paid mutator transaction binding the contract method 0x48c00c90. +// +// Solidity: function openSession(bytes32 bidId, uint256 budget) returns(bytes32 sessionId) +func (_SessionRouter *SessionRouterTransactor) OpenSession(opts *bind.TransactOpts, bidId [32]byte, budget *big.Int) (*types.Transaction, error) { + return _SessionRouter.contract.Transact(opts, "openSession", bidId, budget) +} + +// OpenSession is a paid mutator transaction binding the contract method 0x48c00c90. +// +// Solidity: function openSession(bytes32 bidId, uint256 budget) returns(bytes32 sessionId) +func (_SessionRouter *SessionRouterSession) OpenSession(bidId [32]byte, budget *big.Int) (*types.Transaction, error) { + return _SessionRouter.Contract.OpenSession(&_SessionRouter.TransactOpts, bidId, budget) +} + +// OpenSession is a paid mutator transaction binding the contract method 0x48c00c90. +// +// Solidity: function openSession(bytes32 bidId, uint256 budget) returns(bytes32 sessionId) +func (_SessionRouter *SessionRouterTransactorSession) OpenSession(bidId [32]byte, budget *big.Int) (*types.Transaction, error) { + return _SessionRouter.Contract.OpenSession(&_SessionRouter.TransactOpts, bidId, budget) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_SessionRouter *SessionRouterTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { + return _SessionRouter.contract.Transact(opts, "renounceOwnership") +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_SessionRouter *SessionRouterSession) RenounceOwnership() (*types.Transaction, error) { + return _SessionRouter.Contract.RenounceOwnership(&_SessionRouter.TransactOpts) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_SessionRouter *SessionRouterTransactorSession) RenounceOwnership() (*types.Transaction, error) { + return _SessionRouter.Contract.RenounceOwnership(&_SessionRouter.TransactOpts) +} + +// SetStakeDelay is a paid mutator transaction binding the contract method 0x3cadd8bb. +// +// Solidity: function setStakeDelay(int256 delay) returns() +func (_SessionRouter *SessionRouterTransactor) SetStakeDelay(opts *bind.TransactOpts, delay *big.Int) (*types.Transaction, error) { + return _SessionRouter.contract.Transact(opts, "setStakeDelay", delay) +} + +// SetStakeDelay is a paid mutator transaction binding the contract method 0x3cadd8bb. +// +// Solidity: function setStakeDelay(int256 delay) returns() +func (_SessionRouter *SessionRouterSession) SetStakeDelay(delay *big.Int) (*types.Transaction, error) { + return _SessionRouter.Contract.SetStakeDelay(&_SessionRouter.TransactOpts, delay) +} + +// SetStakeDelay is a paid mutator transaction binding the contract method 0x3cadd8bb. +// +// Solidity: function setStakeDelay(int256 delay) returns() +func (_SessionRouter *SessionRouterTransactorSession) SetStakeDelay(delay *big.Int) (*types.Transaction, error) { + return _SessionRouter.Contract.SetStakeDelay(&_SessionRouter.TransactOpts, delay) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_SessionRouter *SessionRouterTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) { + return _SessionRouter.contract.Transact(opts, "transferOwnership", newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_SessionRouter *SessionRouterSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _SessionRouter.Contract.TransferOwnership(&_SessionRouter.TransactOpts, newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_SessionRouter *SessionRouterTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _SessionRouter.Contract.TransferOwnership(&_SessionRouter.TransactOpts, newOwner) +} + +// SessionRouterInitializedIterator is returned from FilterInitialized and is used to iterate over the raw logs and unpacked data for Initialized events raised by the SessionRouter contract. +type SessionRouterInitializedIterator struct { + Event *SessionRouterInitialized // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *SessionRouterInitializedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(SessionRouterInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(SessionRouterInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *SessionRouterInitializedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *SessionRouterInitializedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// SessionRouterInitialized represents a Initialized event raised by the SessionRouter contract. +type SessionRouterInitialized struct { + Version uint8 + Raw types.Log // Blockchain specific contextual infos +} + +// FilterInitialized is a free log retrieval operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_SessionRouter *SessionRouterFilterer) FilterInitialized(opts *bind.FilterOpts) (*SessionRouterInitializedIterator, error) { + + logs, sub, err := _SessionRouter.contract.FilterLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return &SessionRouterInitializedIterator{contract: _SessionRouter.contract, event: "Initialized", logs: logs, sub: sub}, nil +} + +// WatchInitialized is a free log subscription operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_SessionRouter *SessionRouterFilterer) WatchInitialized(opts *bind.WatchOpts, sink chan<- *SessionRouterInitialized) (event.Subscription, error) { + + logs, sub, err := _SessionRouter.contract.WatchLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(SessionRouterInitialized) + if err := _SessionRouter.contract.UnpackLog(event, "Initialized", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseInitialized is a log parse operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_SessionRouter *SessionRouterFilterer) ParseInitialized(log types.Log) (*SessionRouterInitialized, error) { + event := new(SessionRouterInitialized) + if err := _SessionRouter.contract.UnpackLog(event, "Initialized", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// SessionRouterOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the SessionRouter contract. +type SessionRouterOwnershipTransferredIterator struct { + Event *SessionRouterOwnershipTransferred // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *SessionRouterOwnershipTransferredIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(SessionRouterOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(SessionRouterOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *SessionRouterOwnershipTransferredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *SessionRouterOwnershipTransferredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// SessionRouterOwnershipTransferred represents a OwnershipTransferred event raised by the SessionRouter contract. +type SessionRouterOwnershipTransferred struct { + PreviousOwner common.Address + NewOwner common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_SessionRouter *SessionRouterFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*SessionRouterOwnershipTransferredIterator, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _SessionRouter.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return &SessionRouterOwnershipTransferredIterator{contract: _SessionRouter.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil +} + +// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_SessionRouter *SessionRouterFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *SessionRouterOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _SessionRouter.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(SessionRouterOwnershipTransferred) + if err := _SessionRouter.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_SessionRouter *SessionRouterFilterer) ParseOwnershipTransferred(log types.Log) (*SessionRouterOwnershipTransferred, error) { + event := new(SessionRouterOwnershipTransferred) + if err := _SessionRouter.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// SessionRouterProviderClaimedIterator is returned from FilterProviderClaimed and is used to iterate over the raw logs and unpacked data for ProviderClaimed events raised by the SessionRouter contract. +type SessionRouterProviderClaimedIterator struct { + Event *SessionRouterProviderClaimed // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *SessionRouterProviderClaimedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(SessionRouterProviderClaimed) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(SessionRouterProviderClaimed) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *SessionRouterProviderClaimedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *SessionRouterProviderClaimedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// SessionRouterProviderClaimed represents a ProviderClaimed event raised by the SessionRouter contract. +type SessionRouterProviderClaimed struct { + ProviderAddress common.Address + Amount *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterProviderClaimed is a free log retrieval operation binding the contract event 0x1cd322e3d02eade120b8dceb43a6c1dee437af36e7acd81726c4b54adf5584c2. +// +// Solidity: event ProviderClaimed(address indexed providerAddress, uint256 amount) +func (_SessionRouter *SessionRouterFilterer) FilterProviderClaimed(opts *bind.FilterOpts, providerAddress []common.Address) (*SessionRouterProviderClaimedIterator, error) { + + var providerAddressRule []interface{} + for _, providerAddressItem := range providerAddress { + providerAddressRule = append(providerAddressRule, providerAddressItem) + } + + logs, sub, err := _SessionRouter.contract.FilterLogs(opts, "ProviderClaimed", providerAddressRule) + if err != nil { + return nil, err + } + return &SessionRouterProviderClaimedIterator{contract: _SessionRouter.contract, event: "ProviderClaimed", logs: logs, sub: sub}, nil +} + +// WatchProviderClaimed is a free log subscription operation binding the contract event 0x1cd322e3d02eade120b8dceb43a6c1dee437af36e7acd81726c4b54adf5584c2. +// +// Solidity: event ProviderClaimed(address indexed providerAddress, uint256 amount) +func (_SessionRouter *SessionRouterFilterer) WatchProviderClaimed(opts *bind.WatchOpts, sink chan<- *SessionRouterProviderClaimed, providerAddress []common.Address) (event.Subscription, error) { + + var providerAddressRule []interface{} + for _, providerAddressItem := range providerAddress { + providerAddressRule = append(providerAddressRule, providerAddressItem) + } + + logs, sub, err := _SessionRouter.contract.WatchLogs(opts, "ProviderClaimed", providerAddressRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(SessionRouterProviderClaimed) + if err := _SessionRouter.contract.UnpackLog(event, "ProviderClaimed", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseProviderClaimed is a log parse operation binding the contract event 0x1cd322e3d02eade120b8dceb43a6c1dee437af36e7acd81726c4b54adf5584c2. +// +// Solidity: event ProviderClaimed(address indexed providerAddress, uint256 amount) +func (_SessionRouter *SessionRouterFilterer) ParseProviderClaimed(log types.Log) (*SessionRouterProviderClaimed, error) { + event := new(SessionRouterProviderClaimed) + if err := _SessionRouter.contract.UnpackLog(event, "ProviderClaimed", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// SessionRouterSessionClosedIterator is returned from FilterSessionClosed and is used to iterate over the raw logs and unpacked data for SessionClosed events raised by the SessionRouter contract. +type SessionRouterSessionClosedIterator struct { + Event *SessionRouterSessionClosed // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *SessionRouterSessionClosedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(SessionRouterSessionClosed) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(SessionRouterSessionClosed) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *SessionRouterSessionClosedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *SessionRouterSessionClosedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// SessionRouterSessionClosed represents a SessionClosed event raised by the SessionRouter contract. +type SessionRouterSessionClosed struct { + UserAddress common.Address + SessionId [32]byte + ProviderId common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterSessionClosed is a free log retrieval operation binding the contract event 0x337fbb0a41a596db800dc836595a57815f967185e3596615c646f2455ac3914a. +// +// Solidity: event SessionClosed(address indexed userAddress, bytes32 indexed sessionId, address indexed providerId) +func (_SessionRouter *SessionRouterFilterer) FilterSessionClosed(opts *bind.FilterOpts, userAddress []common.Address, sessionId [][32]byte, providerId []common.Address) (*SessionRouterSessionClosedIterator, error) { + + var userAddressRule []interface{} + for _, userAddressItem := range userAddress { + userAddressRule = append(userAddressRule, userAddressItem) + } + var sessionIdRule []interface{} + for _, sessionIdItem := range sessionId { + sessionIdRule = append(sessionIdRule, sessionIdItem) + } + var providerIdRule []interface{} + for _, providerIdItem := range providerId { + providerIdRule = append(providerIdRule, providerIdItem) + } + + logs, sub, err := _SessionRouter.contract.FilterLogs(opts, "SessionClosed", userAddressRule, sessionIdRule, providerIdRule) + if err != nil { + return nil, err + } + return &SessionRouterSessionClosedIterator{contract: _SessionRouter.contract, event: "SessionClosed", logs: logs, sub: sub}, nil +} + +// WatchSessionClosed is a free log subscription operation binding the contract event 0x337fbb0a41a596db800dc836595a57815f967185e3596615c646f2455ac3914a. +// +// Solidity: event SessionClosed(address indexed userAddress, bytes32 indexed sessionId, address indexed providerId) +func (_SessionRouter *SessionRouterFilterer) WatchSessionClosed(opts *bind.WatchOpts, sink chan<- *SessionRouterSessionClosed, userAddress []common.Address, sessionId [][32]byte, providerId []common.Address) (event.Subscription, error) { + + var userAddressRule []interface{} + for _, userAddressItem := range userAddress { + userAddressRule = append(userAddressRule, userAddressItem) + } + var sessionIdRule []interface{} + for _, sessionIdItem := range sessionId { + sessionIdRule = append(sessionIdRule, sessionIdItem) + } + var providerIdRule []interface{} + for _, providerIdItem := range providerId { + providerIdRule = append(providerIdRule, providerIdItem) + } + + logs, sub, err := _SessionRouter.contract.WatchLogs(opts, "SessionClosed", userAddressRule, sessionIdRule, providerIdRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(SessionRouterSessionClosed) + if err := _SessionRouter.contract.UnpackLog(event, "SessionClosed", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseSessionClosed is a log parse operation binding the contract event 0x337fbb0a41a596db800dc836595a57815f967185e3596615c646f2455ac3914a. +// +// Solidity: event SessionClosed(address indexed userAddress, bytes32 indexed sessionId, address indexed providerId) +func (_SessionRouter *SessionRouterFilterer) ParseSessionClosed(log types.Log) (*SessionRouterSessionClosed, error) { + event := new(SessionRouterSessionClosed) + if err := _SessionRouter.contract.UnpackLog(event, "SessionClosed", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// SessionRouterSessionOpenedIterator is returned from FilterSessionOpened and is used to iterate over the raw logs and unpacked data for SessionOpened events raised by the SessionRouter contract. +type SessionRouterSessionOpenedIterator struct { + Event *SessionRouterSessionOpened // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *SessionRouterSessionOpenedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(SessionRouterSessionOpened) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(SessionRouterSessionOpened) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *SessionRouterSessionOpenedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *SessionRouterSessionOpenedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// SessionRouterSessionOpened represents a SessionOpened event raised by the SessionRouter contract. +type SessionRouterSessionOpened struct { + UserAddress common.Address + SessionId [32]byte + ProviderId common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterSessionOpened is a free log retrieval operation binding the contract event 0x2bd7c890baf595977d256a6e784512c873ac58ba612b4895dbb7f784bfbf4839. +// +// Solidity: event SessionOpened(address indexed userAddress, bytes32 indexed sessionId, address indexed providerId) +func (_SessionRouter *SessionRouterFilterer) FilterSessionOpened(opts *bind.FilterOpts, userAddress []common.Address, sessionId [][32]byte, providerId []common.Address) (*SessionRouterSessionOpenedIterator, error) { + + var userAddressRule []interface{} + for _, userAddressItem := range userAddress { + userAddressRule = append(userAddressRule, userAddressItem) + } + var sessionIdRule []interface{} + for _, sessionIdItem := range sessionId { + sessionIdRule = append(sessionIdRule, sessionIdItem) + } + var providerIdRule []interface{} + for _, providerIdItem := range providerId { + providerIdRule = append(providerIdRule, providerIdItem) + } + + logs, sub, err := _SessionRouter.contract.FilterLogs(opts, "SessionOpened", userAddressRule, sessionIdRule, providerIdRule) + if err != nil { + return nil, err + } + return &SessionRouterSessionOpenedIterator{contract: _SessionRouter.contract, event: "SessionOpened", logs: logs, sub: sub}, nil +} + +// WatchSessionOpened is a free log subscription operation binding the contract event 0x2bd7c890baf595977d256a6e784512c873ac58ba612b4895dbb7f784bfbf4839. +// +// Solidity: event SessionOpened(address indexed userAddress, bytes32 indexed sessionId, address indexed providerId) +func (_SessionRouter *SessionRouterFilterer) WatchSessionOpened(opts *bind.WatchOpts, sink chan<- *SessionRouterSessionOpened, userAddress []common.Address, sessionId [][32]byte, providerId []common.Address) (event.Subscription, error) { + + var userAddressRule []interface{} + for _, userAddressItem := range userAddress { + userAddressRule = append(userAddressRule, userAddressItem) + } + var sessionIdRule []interface{} + for _, sessionIdItem := range sessionId { + sessionIdRule = append(sessionIdRule, sessionIdItem) + } + var providerIdRule []interface{} + for _, providerIdItem := range providerId { + providerIdRule = append(providerIdRule, providerIdItem) + } + + logs, sub, err := _SessionRouter.contract.WatchLogs(opts, "SessionOpened", userAddressRule, sessionIdRule, providerIdRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(SessionRouterSessionOpened) + if err := _SessionRouter.contract.UnpackLog(event, "SessionOpened", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseSessionOpened is a log parse operation binding the contract event 0x2bd7c890baf595977d256a6e784512c873ac58ba612b4895dbb7f784bfbf4839. +// +// Solidity: event SessionOpened(address indexed userAddress, bytes32 indexed sessionId, address indexed providerId) +func (_SessionRouter *SessionRouterFilterer) ParseSessionOpened(log types.Log) (*SessionRouterSessionOpened, error) { + event := new(SessionRouterSessionOpened) + if err := _SessionRouter.contract.UnpackLog(event, "SessionOpened", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// SessionRouterStakedIterator is returned from FilterStaked and is used to iterate over the raw logs and unpacked data for Staked events raised by the SessionRouter contract. +type SessionRouterStakedIterator struct { + Event *SessionRouterStaked // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *SessionRouterStakedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(SessionRouterStaked) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(SessionRouterStaked) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *SessionRouterStakedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *SessionRouterStakedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// SessionRouterStaked represents a Staked event raised by the SessionRouter contract. +type SessionRouterStaked struct { + UserAddress common.Address + Amount *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterStaked is a free log retrieval operation binding the contract event 0x9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d. +// +// Solidity: event Staked(address indexed userAddress, uint256 amount) +func (_SessionRouter *SessionRouterFilterer) FilterStaked(opts *bind.FilterOpts, userAddress []common.Address) (*SessionRouterStakedIterator, error) { + + var userAddressRule []interface{} + for _, userAddressItem := range userAddress { + userAddressRule = append(userAddressRule, userAddressItem) + } + + logs, sub, err := _SessionRouter.contract.FilterLogs(opts, "Staked", userAddressRule) + if err != nil { + return nil, err + } + return &SessionRouterStakedIterator{contract: _SessionRouter.contract, event: "Staked", logs: logs, sub: sub}, nil +} + +// WatchStaked is a free log subscription operation binding the contract event 0x9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d. +// +// Solidity: event Staked(address indexed userAddress, uint256 amount) +func (_SessionRouter *SessionRouterFilterer) WatchStaked(opts *bind.WatchOpts, sink chan<- *SessionRouterStaked, userAddress []common.Address) (event.Subscription, error) { + + var userAddressRule []interface{} + for _, userAddressItem := range userAddress { + userAddressRule = append(userAddressRule, userAddressItem) + } + + logs, sub, err := _SessionRouter.contract.WatchLogs(opts, "Staked", userAddressRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(SessionRouterStaked) + if err := _SessionRouter.contract.UnpackLog(event, "Staked", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseStaked is a log parse operation binding the contract event 0x9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d. +// +// Solidity: event Staked(address indexed userAddress, uint256 amount) +func (_SessionRouter *SessionRouterFilterer) ParseStaked(log types.Log) (*SessionRouterStaked, error) { + event := new(SessionRouterStaked) + if err := _SessionRouter.contract.UnpackLog(event, "Staked", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// SessionRouterUnstakedIterator is returned from FilterUnstaked and is used to iterate over the raw logs and unpacked data for Unstaked events raised by the SessionRouter contract. +type SessionRouterUnstakedIterator struct { + Event *SessionRouterUnstaked // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *SessionRouterUnstakedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(SessionRouterUnstaked) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(SessionRouterUnstaked) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *SessionRouterUnstakedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *SessionRouterUnstakedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// SessionRouterUnstaked represents a Unstaked event raised by the SessionRouter contract. +type SessionRouterUnstaked struct { + UserAddress common.Address + Amount *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterUnstaked is a free log retrieval operation binding the contract event 0x0f5bb82176feb1b5e747e28471aa92156a04d9f3ab9f45f28e2d704232b93f75. +// +// Solidity: event Unstaked(address indexed userAddress, uint256 amount) +func (_SessionRouter *SessionRouterFilterer) FilterUnstaked(opts *bind.FilterOpts, userAddress []common.Address) (*SessionRouterUnstakedIterator, error) { + + var userAddressRule []interface{} + for _, userAddressItem := range userAddress { + userAddressRule = append(userAddressRule, userAddressItem) + } + + logs, sub, err := _SessionRouter.contract.FilterLogs(opts, "Unstaked", userAddressRule) + if err != nil { + return nil, err + } + return &SessionRouterUnstakedIterator{contract: _SessionRouter.contract, event: "Unstaked", logs: logs, sub: sub}, nil +} + +// WatchUnstaked is a free log subscription operation binding the contract event 0x0f5bb82176feb1b5e747e28471aa92156a04d9f3ab9f45f28e2d704232b93f75. +// +// Solidity: event Unstaked(address indexed userAddress, uint256 amount) +func (_SessionRouter *SessionRouterFilterer) WatchUnstaked(opts *bind.WatchOpts, sink chan<- *SessionRouterUnstaked, userAddress []common.Address) (event.Subscription, error) { + + var userAddressRule []interface{} + for _, userAddressItem := range userAddress { + userAddressRule = append(userAddressRule, userAddressItem) + } + + logs, sub, err := _SessionRouter.contract.WatchLogs(opts, "Unstaked", userAddressRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(SessionRouterUnstaked) + if err := _SessionRouter.contract.UnpackLog(event, "Unstaked", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseUnstaked is a log parse operation binding the contract event 0x0f5bb82176feb1b5e747e28471aa92156a04d9f3ab9f45f28e2d704232b93f75. +// +// Solidity: event Unstaked(address indexed userAddress, uint256 amount) +func (_SessionRouter *SessionRouterFilterer) ParseUnstaked(log types.Log) (*SessionRouterUnstaked, error) { + event := new(SessionRouterUnstaked) + if err := _SessionRouter.contract.UnpackLog(event, "Unstaked", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/proxy-router/contracts/stakingdailystipend/StakingDailyStipend.go b/proxy-router/contracts/stakingdailystipend/StakingDailyStipend.go new file mode 100644 index 00000000..08a3dbdf --- /dev/null +++ b/proxy-router/contracts/stakingdailystipend/StakingDailyStipend.go @@ -0,0 +1,1291 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package stakingdailystipend + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// StakingDailyStipendMetaData contains all meta data concerning the StakingDailyStipend contract. +var StakingDailyStipendMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[],\"name\":\"NotEnoughDailyStipend\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotEnoughStake\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotSenderOrOwner\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotSessionRouterOrOwner\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"userAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Staked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"userAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Unstaked\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"userAddress\",\"type\":\"address\"}],\"name\":\"balanceOfDailyStipend\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getComputeBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"userAddress\",\"type\":\"address\"}],\"name\":\"getStakeOnHold\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getTodaysBudget\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"userAddress\",\"type\":\"address\"}],\"name\":\"getTodaysSpend\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_tokenAccount\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"returnStipend\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"sessionRouter\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"stake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"todaysSpend\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"releaseAt\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"token\",\"outputs\":[{\"internalType\":\"contractIERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"tokenAccount\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferDailyStipend\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"sendToAddr\",\"type\":\"address\"}],\"name\":\"unstake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"userStake\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"userAddress\",\"type\":\"address\"}],\"name\":\"withdrawableStakeBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", +} + +// StakingDailyStipendABI is the input ABI used to generate the binding from. +// Deprecated: Use StakingDailyStipendMetaData.ABI instead. +var StakingDailyStipendABI = StakingDailyStipendMetaData.ABI + +// StakingDailyStipend is an auto generated Go binding around an Ethereum contract. +type StakingDailyStipend struct { + StakingDailyStipendCaller // Read-only binding to the contract + StakingDailyStipendTransactor // Write-only binding to the contract + StakingDailyStipendFilterer // Log filterer for contract events +} + +// StakingDailyStipendCaller is an auto generated read-only Go binding around an Ethereum contract. +type StakingDailyStipendCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// StakingDailyStipendTransactor is an auto generated write-only Go binding around an Ethereum contract. +type StakingDailyStipendTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// StakingDailyStipendFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type StakingDailyStipendFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// StakingDailyStipendSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type StakingDailyStipendSession struct { + Contract *StakingDailyStipend // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// StakingDailyStipendCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type StakingDailyStipendCallerSession struct { + Contract *StakingDailyStipendCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// StakingDailyStipendTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type StakingDailyStipendTransactorSession struct { + Contract *StakingDailyStipendTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// StakingDailyStipendRaw is an auto generated low-level Go binding around an Ethereum contract. +type StakingDailyStipendRaw struct { + Contract *StakingDailyStipend // Generic contract binding to access the raw methods on +} + +// StakingDailyStipendCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type StakingDailyStipendCallerRaw struct { + Contract *StakingDailyStipendCaller // Generic read-only contract binding to access the raw methods on +} + +// StakingDailyStipendTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type StakingDailyStipendTransactorRaw struct { + Contract *StakingDailyStipendTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewStakingDailyStipend creates a new instance of StakingDailyStipend, bound to a specific deployed contract. +func NewStakingDailyStipend(address common.Address, backend bind.ContractBackend) (*StakingDailyStipend, error) { + contract, err := bindStakingDailyStipend(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &StakingDailyStipend{StakingDailyStipendCaller: StakingDailyStipendCaller{contract: contract}, StakingDailyStipendTransactor: StakingDailyStipendTransactor{contract: contract}, StakingDailyStipendFilterer: StakingDailyStipendFilterer{contract: contract}}, nil +} + +// NewStakingDailyStipendCaller creates a new read-only instance of StakingDailyStipend, bound to a specific deployed contract. +func NewStakingDailyStipendCaller(address common.Address, caller bind.ContractCaller) (*StakingDailyStipendCaller, error) { + contract, err := bindStakingDailyStipend(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &StakingDailyStipendCaller{contract: contract}, nil +} + +// NewStakingDailyStipendTransactor creates a new write-only instance of StakingDailyStipend, bound to a specific deployed contract. +func NewStakingDailyStipendTransactor(address common.Address, transactor bind.ContractTransactor) (*StakingDailyStipendTransactor, error) { + contract, err := bindStakingDailyStipend(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &StakingDailyStipendTransactor{contract: contract}, nil +} + +// NewStakingDailyStipendFilterer creates a new log filterer instance of StakingDailyStipend, bound to a specific deployed contract. +func NewStakingDailyStipendFilterer(address common.Address, filterer bind.ContractFilterer) (*StakingDailyStipendFilterer, error) { + contract, err := bindStakingDailyStipend(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &StakingDailyStipendFilterer{contract: contract}, nil +} + +// bindStakingDailyStipend binds a generic wrapper to an already deployed contract. +func bindStakingDailyStipend(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := StakingDailyStipendMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_StakingDailyStipend *StakingDailyStipendRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _StakingDailyStipend.Contract.StakingDailyStipendCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_StakingDailyStipend *StakingDailyStipendRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _StakingDailyStipend.Contract.StakingDailyStipendTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_StakingDailyStipend *StakingDailyStipendRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _StakingDailyStipend.Contract.StakingDailyStipendTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_StakingDailyStipend *StakingDailyStipendCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _StakingDailyStipend.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_StakingDailyStipend *StakingDailyStipendTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _StakingDailyStipend.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_StakingDailyStipend *StakingDailyStipendTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _StakingDailyStipend.Contract.contract.Transact(opts, method, params...) +} + +// BalanceOfDailyStipend is a free data retrieval call binding the contract method 0xf0612b48. +// +// Solidity: function balanceOfDailyStipend(address userAddress) view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendCaller) BalanceOfDailyStipend(opts *bind.CallOpts, userAddress common.Address) (*big.Int, error) { + var out []interface{} + err := _StakingDailyStipend.contract.Call(opts, &out, "balanceOfDailyStipend", userAddress) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// BalanceOfDailyStipend is a free data retrieval call binding the contract method 0xf0612b48. +// +// Solidity: function balanceOfDailyStipend(address userAddress) view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendSession) BalanceOfDailyStipend(userAddress common.Address) (*big.Int, error) { + return _StakingDailyStipend.Contract.BalanceOfDailyStipend(&_StakingDailyStipend.CallOpts, userAddress) +} + +// BalanceOfDailyStipend is a free data retrieval call binding the contract method 0xf0612b48. +// +// Solidity: function balanceOfDailyStipend(address userAddress) view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendCallerSession) BalanceOfDailyStipend(userAddress common.Address) (*big.Int, error) { + return _StakingDailyStipend.Contract.BalanceOfDailyStipend(&_StakingDailyStipend.CallOpts, userAddress) +} + +// GetComputeBalance is a free data retrieval call binding the contract method 0x653cdf0c. +// +// Solidity: function getComputeBalance() view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendCaller) GetComputeBalance(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _StakingDailyStipend.contract.Call(opts, &out, "getComputeBalance") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetComputeBalance is a free data retrieval call binding the contract method 0x653cdf0c. +// +// Solidity: function getComputeBalance() view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendSession) GetComputeBalance() (*big.Int, error) { + return _StakingDailyStipend.Contract.GetComputeBalance(&_StakingDailyStipend.CallOpts) +} + +// GetComputeBalance is a free data retrieval call binding the contract method 0x653cdf0c. +// +// Solidity: function getComputeBalance() view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendCallerSession) GetComputeBalance() (*big.Int, error) { + return _StakingDailyStipend.Contract.GetComputeBalance(&_StakingDailyStipend.CallOpts) +} + +// GetStakeOnHold is a free data retrieval call binding the contract method 0x9bc65da5. +// +// Solidity: function getStakeOnHold(address userAddress) view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendCaller) GetStakeOnHold(opts *bind.CallOpts, userAddress common.Address) (*big.Int, error) { + var out []interface{} + err := _StakingDailyStipend.contract.Call(opts, &out, "getStakeOnHold", userAddress) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetStakeOnHold is a free data retrieval call binding the contract method 0x9bc65da5. +// +// Solidity: function getStakeOnHold(address userAddress) view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendSession) GetStakeOnHold(userAddress common.Address) (*big.Int, error) { + return _StakingDailyStipend.Contract.GetStakeOnHold(&_StakingDailyStipend.CallOpts, userAddress) +} + +// GetStakeOnHold is a free data retrieval call binding the contract method 0x9bc65da5. +// +// Solidity: function getStakeOnHold(address userAddress) view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendCallerSession) GetStakeOnHold(userAddress common.Address) (*big.Int, error) { + return _StakingDailyStipend.Contract.GetStakeOnHold(&_StakingDailyStipend.CallOpts, userAddress) +} + +// GetTodaysBudget is a free data retrieval call binding the contract method 0xa7e7f9a9. +// +// Solidity: function getTodaysBudget() view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendCaller) GetTodaysBudget(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _StakingDailyStipend.contract.Call(opts, &out, "getTodaysBudget") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetTodaysBudget is a free data retrieval call binding the contract method 0xa7e7f9a9. +// +// Solidity: function getTodaysBudget() view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendSession) GetTodaysBudget() (*big.Int, error) { + return _StakingDailyStipend.Contract.GetTodaysBudget(&_StakingDailyStipend.CallOpts) +} + +// GetTodaysBudget is a free data retrieval call binding the contract method 0xa7e7f9a9. +// +// Solidity: function getTodaysBudget() view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendCallerSession) GetTodaysBudget() (*big.Int, error) { + return _StakingDailyStipend.Contract.GetTodaysBudget(&_StakingDailyStipend.CallOpts) +} + +// GetTodaysSpend is a free data retrieval call binding the contract method 0x02fc4ec8. +// +// Solidity: function getTodaysSpend(address userAddress) view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendCaller) GetTodaysSpend(opts *bind.CallOpts, userAddress common.Address) (*big.Int, error) { + var out []interface{} + err := _StakingDailyStipend.contract.Call(opts, &out, "getTodaysSpend", userAddress) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetTodaysSpend is a free data retrieval call binding the contract method 0x02fc4ec8. +// +// Solidity: function getTodaysSpend(address userAddress) view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendSession) GetTodaysSpend(userAddress common.Address) (*big.Int, error) { + return _StakingDailyStipend.Contract.GetTodaysSpend(&_StakingDailyStipend.CallOpts, userAddress) +} + +// GetTodaysSpend is a free data retrieval call binding the contract method 0x02fc4ec8. +// +// Solidity: function getTodaysSpend(address userAddress) view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendCallerSession) GetTodaysSpend(userAddress common.Address) (*big.Int, error) { + return _StakingDailyStipend.Contract.GetTodaysSpend(&_StakingDailyStipend.CallOpts, userAddress) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_StakingDailyStipend *StakingDailyStipendCaller) Owner(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _StakingDailyStipend.contract.Call(opts, &out, "owner") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_StakingDailyStipend *StakingDailyStipendSession) Owner() (common.Address, error) { + return _StakingDailyStipend.Contract.Owner(&_StakingDailyStipend.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_StakingDailyStipend *StakingDailyStipendCallerSession) Owner() (common.Address, error) { + return _StakingDailyStipend.Contract.Owner(&_StakingDailyStipend.CallOpts) +} + +// SessionRouter is a free data retrieval call binding the contract method 0x707ba08a. +// +// Solidity: function sessionRouter() view returns(address) +func (_StakingDailyStipend *StakingDailyStipendCaller) SessionRouter(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _StakingDailyStipend.contract.Call(opts, &out, "sessionRouter") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// SessionRouter is a free data retrieval call binding the contract method 0x707ba08a. +// +// Solidity: function sessionRouter() view returns(address) +func (_StakingDailyStipend *StakingDailyStipendSession) SessionRouter() (common.Address, error) { + return _StakingDailyStipend.Contract.SessionRouter(&_StakingDailyStipend.CallOpts) +} + +// SessionRouter is a free data retrieval call binding the contract method 0x707ba08a. +// +// Solidity: function sessionRouter() view returns(address) +func (_StakingDailyStipend *StakingDailyStipendCallerSession) SessionRouter() (common.Address, error) { + return _StakingDailyStipend.Contract.SessionRouter(&_StakingDailyStipend.CallOpts) +} + +// TodaysSpend is a free data retrieval call binding the contract method 0x9b6e4a06. +// +// Solidity: function todaysSpend(address ) view returns(uint256 amount, uint256 releaseAt) +func (_StakingDailyStipend *StakingDailyStipendCaller) TodaysSpend(opts *bind.CallOpts, arg0 common.Address) (struct { + Amount *big.Int + ReleaseAt *big.Int +}, error) { + var out []interface{} + err := _StakingDailyStipend.contract.Call(opts, &out, "todaysSpend", arg0) + + outstruct := new(struct { + Amount *big.Int + ReleaseAt *big.Int + }) + if err != nil { + return *outstruct, err + } + + outstruct.Amount = *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + outstruct.ReleaseAt = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) + + return *outstruct, err + +} + +// TodaysSpend is a free data retrieval call binding the contract method 0x9b6e4a06. +// +// Solidity: function todaysSpend(address ) view returns(uint256 amount, uint256 releaseAt) +func (_StakingDailyStipend *StakingDailyStipendSession) TodaysSpend(arg0 common.Address) (struct { + Amount *big.Int + ReleaseAt *big.Int +}, error) { + return _StakingDailyStipend.Contract.TodaysSpend(&_StakingDailyStipend.CallOpts, arg0) +} + +// TodaysSpend is a free data retrieval call binding the contract method 0x9b6e4a06. +// +// Solidity: function todaysSpend(address ) view returns(uint256 amount, uint256 releaseAt) +func (_StakingDailyStipend *StakingDailyStipendCallerSession) TodaysSpend(arg0 common.Address) (struct { + Amount *big.Int + ReleaseAt *big.Int +}, error) { + return _StakingDailyStipend.Contract.TodaysSpend(&_StakingDailyStipend.CallOpts, arg0) +} + +// Token is a free data retrieval call binding the contract method 0xfc0c546a. +// +// Solidity: function token() view returns(address) +func (_StakingDailyStipend *StakingDailyStipendCaller) Token(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _StakingDailyStipend.contract.Call(opts, &out, "token") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Token is a free data retrieval call binding the contract method 0xfc0c546a. +// +// Solidity: function token() view returns(address) +func (_StakingDailyStipend *StakingDailyStipendSession) Token() (common.Address, error) { + return _StakingDailyStipend.Contract.Token(&_StakingDailyStipend.CallOpts) +} + +// Token is a free data retrieval call binding the contract method 0xfc0c546a. +// +// Solidity: function token() view returns(address) +func (_StakingDailyStipend *StakingDailyStipendCallerSession) Token() (common.Address, error) { + return _StakingDailyStipend.Contract.Token(&_StakingDailyStipend.CallOpts) +} + +// TokenAccount is a free data retrieval call binding the contract method 0x30ddebcb. +// +// Solidity: function tokenAccount() view returns(address) +func (_StakingDailyStipend *StakingDailyStipendCaller) TokenAccount(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _StakingDailyStipend.contract.Call(opts, &out, "tokenAccount") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// TokenAccount is a free data retrieval call binding the contract method 0x30ddebcb. +// +// Solidity: function tokenAccount() view returns(address) +func (_StakingDailyStipend *StakingDailyStipendSession) TokenAccount() (common.Address, error) { + return _StakingDailyStipend.Contract.TokenAccount(&_StakingDailyStipend.CallOpts) +} + +// TokenAccount is a free data retrieval call binding the contract method 0x30ddebcb. +// +// Solidity: function tokenAccount() view returns(address) +func (_StakingDailyStipend *StakingDailyStipendCallerSession) TokenAccount() (common.Address, error) { + return _StakingDailyStipend.Contract.TokenAccount(&_StakingDailyStipend.CallOpts) +} + +// UserStake is a free data retrieval call binding the contract method 0x68e5585d. +// +// Solidity: function userStake(address ) view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendCaller) UserStake(opts *bind.CallOpts, arg0 common.Address) (*big.Int, error) { + var out []interface{} + err := _StakingDailyStipend.contract.Call(opts, &out, "userStake", arg0) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// UserStake is a free data retrieval call binding the contract method 0x68e5585d. +// +// Solidity: function userStake(address ) view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendSession) UserStake(arg0 common.Address) (*big.Int, error) { + return _StakingDailyStipend.Contract.UserStake(&_StakingDailyStipend.CallOpts, arg0) +} + +// UserStake is a free data retrieval call binding the contract method 0x68e5585d. +// +// Solidity: function userStake(address ) view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendCallerSession) UserStake(arg0 common.Address) (*big.Int, error) { + return _StakingDailyStipend.Contract.UserStake(&_StakingDailyStipend.CallOpts, arg0) +} + +// WithdrawableStakeBalance is a free data retrieval call binding the contract method 0x7594e4d9. +// +// Solidity: function withdrawableStakeBalance(address userAddress) view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendCaller) WithdrawableStakeBalance(opts *bind.CallOpts, userAddress common.Address) (*big.Int, error) { + var out []interface{} + err := _StakingDailyStipend.contract.Call(opts, &out, "withdrawableStakeBalance", userAddress) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// WithdrawableStakeBalance is a free data retrieval call binding the contract method 0x7594e4d9. +// +// Solidity: function withdrawableStakeBalance(address userAddress) view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendSession) WithdrawableStakeBalance(userAddress common.Address) (*big.Int, error) { + return _StakingDailyStipend.Contract.WithdrawableStakeBalance(&_StakingDailyStipend.CallOpts, userAddress) +} + +// WithdrawableStakeBalance is a free data retrieval call binding the contract method 0x7594e4d9. +// +// Solidity: function withdrawableStakeBalance(address userAddress) view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendCallerSession) WithdrawableStakeBalance(userAddress common.Address) (*big.Int, error) { + return _StakingDailyStipend.Contract.WithdrawableStakeBalance(&_StakingDailyStipend.CallOpts, userAddress) +} + +// Initialize is a paid mutator transaction binding the contract method 0x485cc955. +// +// Solidity: function initialize(address _token, address _tokenAccount) returns() +func (_StakingDailyStipend *StakingDailyStipendTransactor) Initialize(opts *bind.TransactOpts, _token common.Address, _tokenAccount common.Address) (*types.Transaction, error) { + return _StakingDailyStipend.contract.Transact(opts, "initialize", _token, _tokenAccount) +} + +// Initialize is a paid mutator transaction binding the contract method 0x485cc955. +// +// Solidity: function initialize(address _token, address _tokenAccount) returns() +func (_StakingDailyStipend *StakingDailyStipendSession) Initialize(_token common.Address, _tokenAccount common.Address) (*types.Transaction, error) { + return _StakingDailyStipend.Contract.Initialize(&_StakingDailyStipend.TransactOpts, _token, _tokenAccount) +} + +// Initialize is a paid mutator transaction binding the contract method 0x485cc955. +// +// Solidity: function initialize(address _token, address _tokenAccount) returns() +func (_StakingDailyStipend *StakingDailyStipendTransactorSession) Initialize(_token common.Address, _tokenAccount common.Address) (*types.Transaction, error) { + return _StakingDailyStipend.Contract.Initialize(&_StakingDailyStipend.TransactOpts, _token, _tokenAccount) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_StakingDailyStipend *StakingDailyStipendTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { + return _StakingDailyStipend.contract.Transact(opts, "renounceOwnership") +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_StakingDailyStipend *StakingDailyStipendSession) RenounceOwnership() (*types.Transaction, error) { + return _StakingDailyStipend.Contract.RenounceOwnership(&_StakingDailyStipend.TransactOpts) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_StakingDailyStipend *StakingDailyStipendTransactorSession) RenounceOwnership() (*types.Transaction, error) { + return _StakingDailyStipend.Contract.RenounceOwnership(&_StakingDailyStipend.TransactOpts) +} + +// ReturnStipend is a paid mutator transaction binding the contract method 0x93c87377. +// +// Solidity: function returnStipend(address to, uint256 amount) returns() +func (_StakingDailyStipend *StakingDailyStipendTransactor) ReturnStipend(opts *bind.TransactOpts, to common.Address, amount *big.Int) (*types.Transaction, error) { + return _StakingDailyStipend.contract.Transact(opts, "returnStipend", to, amount) +} + +// ReturnStipend is a paid mutator transaction binding the contract method 0x93c87377. +// +// Solidity: function returnStipend(address to, uint256 amount) returns() +func (_StakingDailyStipend *StakingDailyStipendSession) ReturnStipend(to common.Address, amount *big.Int) (*types.Transaction, error) { + return _StakingDailyStipend.Contract.ReturnStipend(&_StakingDailyStipend.TransactOpts, to, amount) +} + +// ReturnStipend is a paid mutator transaction binding the contract method 0x93c87377. +// +// Solidity: function returnStipend(address to, uint256 amount) returns() +func (_StakingDailyStipend *StakingDailyStipendTransactorSession) ReturnStipend(to common.Address, amount *big.Int) (*types.Transaction, error) { + return _StakingDailyStipend.Contract.ReturnStipend(&_StakingDailyStipend.TransactOpts, to, amount) +} + +// Stake is a paid mutator transaction binding the contract method 0xadc9772e. +// +// Solidity: function stake(address addr, uint256 amount) returns() +func (_StakingDailyStipend *StakingDailyStipendTransactor) Stake(opts *bind.TransactOpts, addr common.Address, amount *big.Int) (*types.Transaction, error) { + return _StakingDailyStipend.contract.Transact(opts, "stake", addr, amount) +} + +// Stake is a paid mutator transaction binding the contract method 0xadc9772e. +// +// Solidity: function stake(address addr, uint256 amount) returns() +func (_StakingDailyStipend *StakingDailyStipendSession) Stake(addr common.Address, amount *big.Int) (*types.Transaction, error) { + return _StakingDailyStipend.Contract.Stake(&_StakingDailyStipend.TransactOpts, addr, amount) +} + +// Stake is a paid mutator transaction binding the contract method 0xadc9772e. +// +// Solidity: function stake(address addr, uint256 amount) returns() +func (_StakingDailyStipend *StakingDailyStipendTransactorSession) Stake(addr common.Address, amount *big.Int) (*types.Transaction, error) { + return _StakingDailyStipend.Contract.Stake(&_StakingDailyStipend.TransactOpts, addr, amount) +} + +// TransferDailyStipend is a paid mutator transaction binding the contract method 0x93a7483a. +// +// Solidity: function transferDailyStipend(address from, address to, uint256 amount) returns() +func (_StakingDailyStipend *StakingDailyStipendTransactor) TransferDailyStipend(opts *bind.TransactOpts, from common.Address, to common.Address, amount *big.Int) (*types.Transaction, error) { + return _StakingDailyStipend.contract.Transact(opts, "transferDailyStipend", from, to, amount) +} + +// TransferDailyStipend is a paid mutator transaction binding the contract method 0x93a7483a. +// +// Solidity: function transferDailyStipend(address from, address to, uint256 amount) returns() +func (_StakingDailyStipend *StakingDailyStipendSession) TransferDailyStipend(from common.Address, to common.Address, amount *big.Int) (*types.Transaction, error) { + return _StakingDailyStipend.Contract.TransferDailyStipend(&_StakingDailyStipend.TransactOpts, from, to, amount) +} + +// TransferDailyStipend is a paid mutator transaction binding the contract method 0x93a7483a. +// +// Solidity: function transferDailyStipend(address from, address to, uint256 amount) returns() +func (_StakingDailyStipend *StakingDailyStipendTransactorSession) TransferDailyStipend(from common.Address, to common.Address, amount *big.Int) (*types.Transaction, error) { + return _StakingDailyStipend.Contract.TransferDailyStipend(&_StakingDailyStipend.TransactOpts, from, to, amount) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_StakingDailyStipend *StakingDailyStipendTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) { + return _StakingDailyStipend.contract.Transact(opts, "transferOwnership", newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_StakingDailyStipend *StakingDailyStipendSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _StakingDailyStipend.Contract.TransferOwnership(&_StakingDailyStipend.TransactOpts, newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_StakingDailyStipend *StakingDailyStipendTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _StakingDailyStipend.Contract.TransferOwnership(&_StakingDailyStipend.TransactOpts, newOwner) +} + +// Unstake is a paid mutator transaction binding the contract method 0x926e31d6. +// +// Solidity: function unstake(address addr, uint256 amount, address sendToAddr) returns() +func (_StakingDailyStipend *StakingDailyStipendTransactor) Unstake(opts *bind.TransactOpts, addr common.Address, amount *big.Int, sendToAddr common.Address) (*types.Transaction, error) { + return _StakingDailyStipend.contract.Transact(opts, "unstake", addr, amount, sendToAddr) +} + +// Unstake is a paid mutator transaction binding the contract method 0x926e31d6. +// +// Solidity: function unstake(address addr, uint256 amount, address sendToAddr) returns() +func (_StakingDailyStipend *StakingDailyStipendSession) Unstake(addr common.Address, amount *big.Int, sendToAddr common.Address) (*types.Transaction, error) { + return _StakingDailyStipend.Contract.Unstake(&_StakingDailyStipend.TransactOpts, addr, amount, sendToAddr) +} + +// Unstake is a paid mutator transaction binding the contract method 0x926e31d6. +// +// Solidity: function unstake(address addr, uint256 amount, address sendToAddr) returns() +func (_StakingDailyStipend *StakingDailyStipendTransactorSession) Unstake(addr common.Address, amount *big.Int, sendToAddr common.Address) (*types.Transaction, error) { + return _StakingDailyStipend.Contract.Unstake(&_StakingDailyStipend.TransactOpts, addr, amount, sendToAddr) +} + +// StakingDailyStipendInitializedIterator is returned from FilterInitialized and is used to iterate over the raw logs and unpacked data for Initialized events raised by the StakingDailyStipend contract. +type StakingDailyStipendInitializedIterator struct { + Event *StakingDailyStipendInitialized // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *StakingDailyStipendInitializedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(StakingDailyStipendInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(StakingDailyStipendInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *StakingDailyStipendInitializedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *StakingDailyStipendInitializedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// StakingDailyStipendInitialized represents a Initialized event raised by the StakingDailyStipend contract. +type StakingDailyStipendInitialized struct { + Version uint8 + Raw types.Log // Blockchain specific contextual infos +} + +// FilterInitialized is a free log retrieval operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_StakingDailyStipend *StakingDailyStipendFilterer) FilterInitialized(opts *bind.FilterOpts) (*StakingDailyStipendInitializedIterator, error) { + + logs, sub, err := _StakingDailyStipend.contract.FilterLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return &StakingDailyStipendInitializedIterator{contract: _StakingDailyStipend.contract, event: "Initialized", logs: logs, sub: sub}, nil +} + +// WatchInitialized is a free log subscription operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_StakingDailyStipend *StakingDailyStipendFilterer) WatchInitialized(opts *bind.WatchOpts, sink chan<- *StakingDailyStipendInitialized) (event.Subscription, error) { + + logs, sub, err := _StakingDailyStipend.contract.WatchLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(StakingDailyStipendInitialized) + if err := _StakingDailyStipend.contract.UnpackLog(event, "Initialized", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseInitialized is a log parse operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_StakingDailyStipend *StakingDailyStipendFilterer) ParseInitialized(log types.Log) (*StakingDailyStipendInitialized, error) { + event := new(StakingDailyStipendInitialized) + if err := _StakingDailyStipend.contract.UnpackLog(event, "Initialized", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// StakingDailyStipendOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the StakingDailyStipend contract. +type StakingDailyStipendOwnershipTransferredIterator struct { + Event *StakingDailyStipendOwnershipTransferred // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *StakingDailyStipendOwnershipTransferredIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(StakingDailyStipendOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(StakingDailyStipendOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *StakingDailyStipendOwnershipTransferredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *StakingDailyStipendOwnershipTransferredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// StakingDailyStipendOwnershipTransferred represents a OwnershipTransferred event raised by the StakingDailyStipend contract. +type StakingDailyStipendOwnershipTransferred struct { + PreviousOwner common.Address + NewOwner common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_StakingDailyStipend *StakingDailyStipendFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*StakingDailyStipendOwnershipTransferredIterator, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _StakingDailyStipend.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return &StakingDailyStipendOwnershipTransferredIterator{contract: _StakingDailyStipend.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil +} + +// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_StakingDailyStipend *StakingDailyStipendFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *StakingDailyStipendOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _StakingDailyStipend.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(StakingDailyStipendOwnershipTransferred) + if err := _StakingDailyStipend.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_StakingDailyStipend *StakingDailyStipendFilterer) ParseOwnershipTransferred(log types.Log) (*StakingDailyStipendOwnershipTransferred, error) { + event := new(StakingDailyStipendOwnershipTransferred) + if err := _StakingDailyStipend.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// StakingDailyStipendStakedIterator is returned from FilterStaked and is used to iterate over the raw logs and unpacked data for Staked events raised by the StakingDailyStipend contract. +type StakingDailyStipendStakedIterator struct { + Event *StakingDailyStipendStaked // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *StakingDailyStipendStakedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(StakingDailyStipendStaked) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(StakingDailyStipendStaked) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *StakingDailyStipendStakedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *StakingDailyStipendStakedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// StakingDailyStipendStaked represents a Staked event raised by the StakingDailyStipend contract. +type StakingDailyStipendStaked struct { + UserAddress common.Address + Amount *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterStaked is a free log retrieval operation binding the contract event 0x9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d. +// +// Solidity: event Staked(address indexed userAddress, uint256 amount) +func (_StakingDailyStipend *StakingDailyStipendFilterer) FilterStaked(opts *bind.FilterOpts, userAddress []common.Address) (*StakingDailyStipendStakedIterator, error) { + + var userAddressRule []interface{} + for _, userAddressItem := range userAddress { + userAddressRule = append(userAddressRule, userAddressItem) + } + + logs, sub, err := _StakingDailyStipend.contract.FilterLogs(opts, "Staked", userAddressRule) + if err != nil { + return nil, err + } + return &StakingDailyStipendStakedIterator{contract: _StakingDailyStipend.contract, event: "Staked", logs: logs, sub: sub}, nil +} + +// WatchStaked is a free log subscription operation binding the contract event 0x9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d. +// +// Solidity: event Staked(address indexed userAddress, uint256 amount) +func (_StakingDailyStipend *StakingDailyStipendFilterer) WatchStaked(opts *bind.WatchOpts, sink chan<- *StakingDailyStipendStaked, userAddress []common.Address) (event.Subscription, error) { + + var userAddressRule []interface{} + for _, userAddressItem := range userAddress { + userAddressRule = append(userAddressRule, userAddressItem) + } + + logs, sub, err := _StakingDailyStipend.contract.WatchLogs(opts, "Staked", userAddressRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(StakingDailyStipendStaked) + if err := _StakingDailyStipend.contract.UnpackLog(event, "Staked", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseStaked is a log parse operation binding the contract event 0x9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d. +// +// Solidity: event Staked(address indexed userAddress, uint256 amount) +func (_StakingDailyStipend *StakingDailyStipendFilterer) ParseStaked(log types.Log) (*StakingDailyStipendStaked, error) { + event := new(StakingDailyStipendStaked) + if err := _StakingDailyStipend.contract.UnpackLog(event, "Staked", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// StakingDailyStipendUnstakedIterator is returned from FilterUnstaked and is used to iterate over the raw logs and unpacked data for Unstaked events raised by the StakingDailyStipend contract. +type StakingDailyStipendUnstakedIterator struct { + Event *StakingDailyStipendUnstaked // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *StakingDailyStipendUnstakedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(StakingDailyStipendUnstaked) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(StakingDailyStipendUnstaked) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *StakingDailyStipendUnstakedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *StakingDailyStipendUnstakedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// StakingDailyStipendUnstaked represents a Unstaked event raised by the StakingDailyStipend contract. +type StakingDailyStipendUnstaked struct { + UserAddress common.Address + Amount *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterUnstaked is a free log retrieval operation binding the contract event 0x0f5bb82176feb1b5e747e28471aa92156a04d9f3ab9f45f28e2d704232b93f75. +// +// Solidity: event Unstaked(address indexed userAddress, uint256 amount) +func (_StakingDailyStipend *StakingDailyStipendFilterer) FilterUnstaked(opts *bind.FilterOpts, userAddress []common.Address) (*StakingDailyStipendUnstakedIterator, error) { + + var userAddressRule []interface{} + for _, userAddressItem := range userAddress { + userAddressRule = append(userAddressRule, userAddressItem) + } + + logs, sub, err := _StakingDailyStipend.contract.FilterLogs(opts, "Unstaked", userAddressRule) + if err != nil { + return nil, err + } + return &StakingDailyStipendUnstakedIterator{contract: _StakingDailyStipend.contract, event: "Unstaked", logs: logs, sub: sub}, nil +} + +// WatchUnstaked is a free log subscription operation binding the contract event 0x0f5bb82176feb1b5e747e28471aa92156a04d9f3ab9f45f28e2d704232b93f75. +// +// Solidity: event Unstaked(address indexed userAddress, uint256 amount) +func (_StakingDailyStipend *StakingDailyStipendFilterer) WatchUnstaked(opts *bind.WatchOpts, sink chan<- *StakingDailyStipendUnstaked, userAddress []common.Address) (event.Subscription, error) { + + var userAddressRule []interface{} + for _, userAddressItem := range userAddress { + userAddressRule = append(userAddressRule, userAddressItem) + } + + logs, sub, err := _StakingDailyStipend.contract.WatchLogs(opts, "Unstaked", userAddressRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(StakingDailyStipendUnstaked) + if err := _StakingDailyStipend.contract.UnpackLog(event, "Unstaked", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseUnstaked is a log parse operation binding the contract event 0x0f5bb82176feb1b5e747e28471aa92156a04d9f3ab9f45f28e2d704232b93f75. +// +// Solidity: event Unstaked(address indexed userAddress, uint256 amount) +func (_StakingDailyStipend *StakingDailyStipendFilterer) ParseUnstaked(log types.Log) (*StakingDailyStipendUnstaked, error) { + event := new(StakingDailyStipendUnstaked) + if err := _StakingDailyStipend.contract.UnpackLog(event, "Unstaked", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/proxy-router/internal/apibus/api_bus.go b/proxy-router/internal/apibus/api_bus.go index c99ab180..2e40af3f 100644 --- a/proxy-router/internal/apibus/api_bus.go +++ b/proxy-router/internal/apibus/api_bus.go @@ -2,10 +2,12 @@ package apibus import ( "context" + "math/big" "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal/aiengine" "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal/proxyapi" "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal/rpcproxy" + "github.com/ethereum/go-ethereum/common" "github.com/gin-gonic/gin" ) @@ -40,6 +42,10 @@ func (apiBus *ApiBus) InitiateSession(ctx *gin.Context) (int, interface{}) { return apiBus.proxyRouterApi.InitiateSession(ctx) } +func (apiBus *ApiBus) SendPrompt(ctx *gin.Context) (int, interface{}) { + return apiBus.proxyRouterApi.SendPrompt(ctx) +} + // AiEngine func (apiBus *ApiBus) Prompt(ctx context.Context) (string, error) { return apiBus.aiEngine.Prompt(ctx) @@ -49,3 +55,20 @@ func (apiBus *ApiBus) Prompt(ctx context.Context) (string, error) { func (apiBus *ApiBus) GetLatestBlock(ctx context.Context) (uint64, error) { return apiBus.rpcProxy.GetLatestBlock(ctx) } + +func (apiBus *ApiBus) GetAllProviders(ctx context.Context) (int, gin.H) { + return apiBus.rpcProxy.GetAllProviders(ctx) +} + +func (apiBus *ApiBus) GetAllModels(ctx context.Context) (int, gin.H) { + return apiBus.rpcProxy.GetAllModels(ctx) +} + +func (apiBus *ApiBus) GetBidsByProvider(ctx context.Context, providerAddr string, offset *big.Int, limit uint8) (int, gin.H) { + addr := common.HexToAddress(providerAddr) + return apiBus.rpcProxy.GetBidsByProvider(ctx, addr, offset, limit) +} + +func (apiBus *ApiBus) GetBidsByModelAgent(ctx context.Context, modelAgentId [32]byte, offset *big.Int, limit uint8) (int, gin.H) { + return apiBus.rpcProxy.GetBidsByModelAgent(ctx, modelAgentId, offset, limit) +} diff --git a/proxy-router/internal/config/config.go b/proxy-router/internal/config/config.go index b980a31f..08801ec1 100644 --- a/proxy-router/internal/config/config.go +++ b/proxy-router/internal/config/config.go @@ -17,9 +17,11 @@ type Config struct { } Environment string `env:"ENVIRONMENT" flag:"environment"` Marketplace struct { - CloneFactoryAddress string `env:"CLONE_FACTORY_ADDRESS" flag:"contract-address" validate:"required_if=Disable false,omitempty,eth_addr"` - Mnemonic string `env:"CONTRACT_MNEMONIC" flag:"contract-mnemonic" validate:"required_without=WalletPrivateKey|required_if=Disable false"` - WalletPrivateKey string `env:"WALLET_PRIVATE_KEY" flag:"wallet-private-key" validate:"required_without=Mnemonic|required_if=Disable false"` + ProviderRegistryAddress string `env:"PROVIDER_REGISTRY_ADDRESS" flag:"provider-registry-address" validate:"required_if=Disable false,omitempty,eth_addr"` + ModelRegistryAddress string `env:"MODEL_REGISTRY_ADDRESS" flag:"model-registry-address" validate:"required_if=Disable false,omitempty,eth_addr"` + MarketplaceAddress string `env:"MARKETPLACE_ADDRESS" flag:"marketplace-address" validate:"required_if=Disable false,omitempty,eth_addr"` + Mnemonic string `env:"CONTRACT_MNEMONIC" flag:"contract-mnemonic" validate:"required_without=WalletPrivateKey|required_if=Disable false"` + WalletPrivateKey string `env:"WALLET_PRIVATE_KEY" flag:"wallet-private-key" validate:"required_without=Mnemonic|required_if=Disable false"` } Log struct { Color bool `env:"LOG_COLOR" flag:"log-color"` @@ -135,8 +137,6 @@ func (cfg *Config) GetSanitized() interface{} { publicCfg.Blockchain.EthLegacyTx = cfg.Blockchain.EthLegacyTx publicCfg.Environment = cfg.Environment - publicCfg.Marketplace.CloneFactoryAddress = cfg.Marketplace.CloneFactoryAddress - publicCfg.Log.Color = cfg.Log.Color publicCfg.Log.FolderPath = cfg.Log.FolderPath publicCfg.Log.IsProd = cfg.Log.IsProd diff --git a/proxy-router/internal/handlers/httphandlers/http.go b/proxy-router/internal/handlers/httphandlers/http.go index 6b2abb08..38fc8bcc 100644 --- a/proxy-router/internal/handlers/httphandlers/http.go +++ b/proxy-router/internal/handlers/httphandlers/http.go @@ -1,6 +1,9 @@ package httphandlers import ( + "encoding/hex" + "fmt" + "math/big" "net/http/pprof" constants "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal" @@ -25,11 +28,56 @@ func NewHTTPHandler(apiBus *apibus.ApiBus) *gin.Engine { ctx.JSON(status, files) })) - r.POST("/sessions/initiate", (func(ctx *gin.Context) { + r.POST("/proxy/sessions/initiate", (func(ctx *gin.Context) { status, response := apiBus.InitiateSession(ctx) ctx.JSON(status, response) })) + r.POST("/proxy/sessions/:id/prompt", (func(ctx *gin.Context) { + status, response := apiBus.SendPrompt(ctx) + ctx.JSON(status, response) + })) + + r.GET("/blockchain/providers", (func(ctx *gin.Context) { + status, providers := apiBus.GetAllProviders(ctx) + ctx.JSON(status, providers) + })) + + r.GET("/blockchain/providers/:id/bids", (func(ctx *gin.Context) { + providerId := ctx.Param("id") + offset, limit := getOffsetLimit(ctx) + if offset == nil { + return + } + + status, bids := apiBus.GetBidsByProvider(ctx, providerId, offset, limit) + ctx.JSON(status, bids) + })) + + r.GET("/blockchain/models", (func(ctx *gin.Context) { + status, models := apiBus.GetAllModels(ctx) + ctx.JSON(status, models) + })) + + r.GET("/blockchain/models/:id/bids", (func(ctx *gin.Context) { + modelAgentId := ctx.Param("id") + + offset, limit := getOffsetLimit(ctx) + if offset == nil { + return + } + + id, err := hex.DecodeString(modelAgentId) + if err != nil { + ctx.JSON(constants.HTTP_STATUS_BAD_REQUEST, gin.H{"error": "invalid model agent id"}) + return + } + var idBytes [32]byte + copy(idBytes[:], id) + status, models := apiBus.GetBidsByModelAgent(ctx, idBytes, offset, limit) + ctx.JSON(status, models) + })) + r.Any("/debug/pprof/*action", gin.WrapF(pprof.Index)) err := r.SetTrustedProxies(nil) @@ -39,3 +87,28 @@ func NewHTTPHandler(apiBus *apibus.ApiBus) *gin.Engine { return r } + +func getOffsetLimit(ctx *gin.Context) (*big.Int, uint8) { + offsetStr := ctx.Query("offset") + if offsetStr == "" { + offsetStr = "0" + } + limitStr := ctx.Query("limit") + if limitStr == "" { + limitStr = "10" + } + + offset, ok := new(big.Int).SetString(offsetStr, 10) + if !ok { + ctx.JSON(constants.HTTP_STATUS_BAD_REQUEST, gin.H{"error": "invalid offset"}) + return nil, 0 + } + + var limit uint8 + _, err := fmt.Sscanf(limitStr, "%d", &limit) + if err != nil { + ctx.JSON(constants.HTTP_STATUS_BAD_REQUEST, gin.H{"error": "invalid limit"}) + return nil, 0 + } + return offset, limit +} diff --git a/proxy-router/internal/handlers/tcphandlers/mor_rpc_handler.go b/proxy-router/internal/handlers/tcphandlers/mor_rpc_handler.go index 5335656c..31f465f2 100644 --- a/proxy-router/internal/handlers/tcphandlers/mor_rpc_handler.go +++ b/proxy-router/internal/handlers/tcphandlers/mor_rpc_handler.go @@ -63,8 +63,35 @@ func (m *MorRpcHandler) Handle(msg morrpc.RpcMessage, sourceLog interfaces.ILogg } return response, nil - case "method2": - // handle method2 + case "session.prompt": + requestId := fmt.Sprintf("%v", msg.ID) + signature := fmt.Sprintf("%v", msg.Params["signature"]) + sessionId := fmt.Sprintf("%v", msg.Params["sessionid"]) + prompt := fmt.Sprintf("%v", msg.Params["message"]) + timeStamp := fmt.Sprintf("%v", msg.Params["timestamp"]) + sourceLog.Debugf("Received prompt from session %s, timestamp: %s", sessionId, timeStamp) + + userPubKey := "mocked_pub_key" // get user public key from storage for sessionId + isValid := m.morRpc.VerifySignature(msg.Params, signature, userPubKey, sourceLog) + if !isValid { + err := fmt.Errorf("invalid signature") + sourceLog.Error(err) + return nil, err + } + + // Send response + response, err := m.morRpc.SessionPromptResponse( + fmt.Sprintf("Prompt: %v, my resp: %v", prompt, "ok"), + m.privateKeyHex, + requestId, + ) + if err != nil { + err := lib.WrapError(fmt.Errorf("failed to create response"), err) + sourceLog.Error(err) + return nil, err + } + + return response, nil default: err := fmt.Errorf("unknown method: %s", msg.Method) sourceLog.Error(err) diff --git a/proxy-router/internal/proxyapi/proxy_router_api.go b/proxy-router/internal/proxyapi/proxy_router_api.go index 83df1870..d9503b0c 100644 --- a/proxy-router/internal/proxyapi/proxy_router_api.go +++ b/proxy-router/internal/proxyapi/proxy_router_api.go @@ -153,6 +153,84 @@ func (p *ProxyRouterApi) InitiateSession(ctx *gin.Context) (int, gin.H) { } } +func (p *ProxyRouterApi) SendPrompt(ctx *gin.Context) (int, gin.H) { + var reqPayload map[string]interface{} + if err := ctx.ShouldBindJSON(&reqPayload); err != nil { + return constants.HTTP_STATUS_BAD_REQUEST, gin.H{"error": err.Error()} + } + + providerPublicKey, ok := reqPayload["providerPublicKey"].(string) + if !ok { + return constants.HTTP_STATUS_BAD_REQUEST, gin.H{"error": "providerPublicKey is required"} + } + + prompt, ok := reqPayload["prompt"].(string) + if !ok { + return constants.HTTP_STATUS_BAD_REQUEST, gin.H{"error": "prompt is required"} + } + + sessionId := ctx.Param("id") + if sessionId == "" { + return constants.HTTP_STATUS_BAD_REQUEST, gin.H{"error": "sessionId is required"} + } + + providerUrl, ok := reqPayload["providerUrl"].(string) + if !ok { + return constants.HTTP_STATUS_BAD_REQUEST, gin.H{"error": "providerUrl is required"} + } + + requestID := "1" + promptRequest, err := morrpc.NewMorRpc().SessionPromptRequest(sessionId, prompt, providerPublicKey, p.privateKey, requestID) + if err != nil { + err = lib.WrapError(fmt.Errorf("failed to create session prompt request"), err) + p.log.Errorf("%s", err) + return constants.HTTP_STATUS_BAD_REQUEST, gin.H{"error": err.Error()} + } + + conn, err := net.Dial("tcp", providerUrl) + if err != nil { + err = lib.WrapError(fmt.Errorf("failed to connect to provider"), err) + p.log.Errorf("%s", err) + return constants.HTTP_STATUS_BAD_REQUEST, gin.H{"error": err.Error()} + } + defer conn.Close() + + msgJSON, err := json.Marshal(promptRequest) + if err != nil { + err = lib.WrapError(fmt.Errorf("failed to marshal initiate session request"), err) + p.log.Errorf("%s", err) + return constants.HTTP_STATUS_BAD_REQUEST, gin.H{"error": err.Error()} + } + conn.Write([]byte(msgJSON)) + + // read response + reader := bufio.NewReader(conn) + d := json.NewDecoder(reader) + var msg *morrpc.RpcResponse + err = d.Decode(&msg) + if err != nil { + err = lib.WrapError(fmt.Errorf("failed to decode response"), err) + p.log.Errorf("%s", err) + return constants.HTTP_STATUS_BAD_REQUEST, gin.H{"error": err.Error()} + } + + signature := fmt.Sprintf("%v", msg.Result["signature"]) + providerPubKey := "mock_provider_pub_key" // get provider public key from storage for sessionId + p.log.Debugf("Signature: %s, Provider Pub Key: %s", signature, providerPubKey) + + isValidSignature := morrpc.NewMorRpc().VerifySignature(msg.Result, signature, providerPubKey, p.log) + p.log.Debugf("Is valid signature: %t", isValidSignature) + if !isValidSignature { + err = fmt.Errorf("invalid signature from provider") + p.log.Errorf("%s", err) + return constants.HTTP_STATUS_BAD_REQUEST, gin.H{"error": err.Error()} + } + + return constants.HTTP_STATUS_OK, gin.H{ + "response": msg, + } +} + func (p *ProxyRouterApi) GetFiles(ctx *gin.Context) (int, gin.H) { files, err := p.sysConfig.GetFileDescriptors(ctx, os.Getpid()) if err != nil { diff --git a/proxy-router/internal/repositories/registries/marketplace.go b/proxy-router/internal/repositories/registries/marketplace.go new file mode 100644 index 00000000..b7e96e80 --- /dev/null +++ b/proxy-router/internal/repositories/registries/marketplace.go @@ -0,0 +1,67 @@ +package registries + +import ( + "context" + "math/big" + + "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/contracts/marketplace" + "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/contracts/modelregistry" + "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal/interfaces" + "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal/lib" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/ethclient" +) + +type Marketplace struct { + // config + marketplaceAddr common.Address + + // state + nonce uint64 + mutex lib.Mutex + mpABI *abi.ABI + + // deps + marketplace *marketplace.Marketplace + client *ethclient.Client + log interfaces.ILogger +} + +func NewMarketplace(marketplaceAddr common.Address, client *ethclient.Client, log interfaces.ILogger) *Marketplace { + mp, err := marketplace.NewMarketplace(marketplaceAddr, client) + if err != nil { + panic("invalid marketplace ABI") + } + mpABI, err := modelregistry.ModelRegistryMetaData.GetAbi() + if err != nil { + panic("invalid marketplace ABI: " + err.Error()) + } + return &Marketplace{ + marketplace: mp, + marketplaceAddr: marketplaceAddr, + client: client, + mpABI: mpABI, + mutex: lib.NewMutex(), + log: log, + } +} + +func (g *Marketplace) GetBidsByProvider(ctx context.Context, provider common.Address, offset *big.Int, limit uint8) ([]marketplace.MarketplaceBid, error) { + bids, err := g.marketplace.GetBidsByProvider(&bind.CallOpts{Context: ctx}, provider, offset, limit) + if err != nil { + return nil, err + } + + return bids, nil +} + +func (g *Marketplace) GetBidsByModelAgent(ctx context.Context, modelAgentId [32]byte, offset *big.Int, limit uint8) ([]marketplace.MarketplaceBid, error) { + bids, err := g.marketplace.GetBidsByModelAgent(&bind.CallOpts{Context: ctx}, modelAgentId, offset, limit) + if err != nil { + return nil, err + } + + return bids, nil +} diff --git a/proxy-router/internal/repositories/registries/model_registry.go b/proxy-router/internal/repositories/registries/model_registry.go new file mode 100644 index 00000000..e14eb09b --- /dev/null +++ b/proxy-router/internal/repositories/registries/model_registry.go @@ -0,0 +1,56 @@ +package registries + +import ( + "context" + + "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/contracts/modelregistry" + "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal/interfaces" + "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal/lib" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/ethclient" +) + +type ModelRegistry struct { + // config + modelRegistryAddr common.Address + + // state + nonce uint64 + mutex lib.Mutex + mrABI *abi.ABI + + // deps + modelRegistry *modelregistry.ModelRegistry + client *ethclient.Client + log interfaces.ILogger +} + +func NewModelRegistry(modelRegistryAddr common.Address, client *ethclient.Client, log interfaces.ILogger) *ModelRegistry { + mr, err := modelregistry.NewModelRegistry(modelRegistryAddr, client) + if err != nil { + panic("invalid model registry ABI") + } + mrABI, err := modelregistry.ModelRegistryMetaData.GetAbi() + if err != nil { + panic("invalid model registry ABI: " + err.Error()) + } + return &ModelRegistry{ + modelRegistry: mr, + modelRegistryAddr: modelRegistryAddr, + client: client, + mrABI: mrABI, + mutex: lib.NewMutex(), + log: log, + } +} + +func (g *ModelRegistry) GetAllProviders(ctx context.Context) ([]modelregistry.ModelRegistryModel, error) { + models, err := g.modelRegistry.GetAll(&bind.CallOpts{Context: ctx}) + if err != nil { + return nil, err + } + + return models, nil +} diff --git a/proxy-router/internal/repositories/registries/model_registry_test.go b/proxy-router/internal/repositories/registries/model_registry_test.go new file mode 100644 index 00000000..27eee64a --- /dev/null +++ b/proxy-router/internal/repositories/registries/model_registry_test.go @@ -0,0 +1,44 @@ +package registries + +import ( + "encoding/hex" + "fmt" + "testing" +) + +func TestMorRpc_modelAgentId_to_Hex(t *testing.T) { + modelAgentId := [32]byte{0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 105, + 112, + 102, + 115, + 58, + 47, + 47, + 105, + 112, + 102, + 115, + 97, + 100, + 100, + 114, + 101, + 115, + 115} + modelAgentIdHex := hex.EncodeToString(modelAgentId[:]) + fmt.Println(modelAgentIdHex) +} diff --git a/proxy-router/internal/repositories/registries/provider_registry.go b/proxy-router/internal/repositories/registries/provider_registry.go new file mode 100644 index 00000000..11155f85 --- /dev/null +++ b/proxy-router/internal/repositories/registries/provider_registry.go @@ -0,0 +1,63 @@ +package registries + +import ( + "context" + "fmt" + + "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/contracts/providerregistry" + "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal/interfaces" + "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal/lib" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/ethclient" +) + +type ProviderRegistry struct { + // config + providerRegistryAddr common.Address + + // state + nonce uint64 + mutex lib.Mutex + prABI *abi.ABI + + // deps + providerRegistry *providerregistry.ProviderRegistry + client *ethclient.Client + log interfaces.ILogger +} + +func NewProviderRegistry(providerRegistryAddr common.Address, client *ethclient.Client, log interfaces.ILogger) *ProviderRegistry { + pr, err := providerregistry.NewProviderRegistry(providerRegistryAddr, client) + if err != nil { + panic("invalid provider registry ABI") + } + prABI, err := providerregistry.ProviderRegistryMetaData.GetAbi() + if err != nil { + panic("invalid provider registry ABI: " + err.Error()) + } + fmt.Println(providerRegistryAddr) + return &ProviderRegistry{ + providerRegistry: pr, + providerRegistryAddr: providerRegistryAddr, + client: client, + prABI: prABI, + mutex: lib.NewMutex(), + log: log, + } +} + +func (g *ProviderRegistry) GetAllProviders(ctx context.Context) ([]string, []providerregistry.ProviderRegistryProvider, error) { + providerAddrs, providers, err := g.providerRegistry.GetAll(&bind.CallOpts{Context: ctx}) + if err != nil { + return nil, nil, err + } + + addresses := make([]string, len(providerAddrs)) + for i, address := range providerAddrs { + addresses[i] = address.Hex() + } + + return addresses, providers, nil +} diff --git a/proxy-router/internal/rpcproxy/rpc_proxy.go b/proxy-router/internal/rpcproxy/rpc_proxy.go index 4854731c..3d905dc6 100644 --- a/proxy-router/internal/rpcproxy/rpc_proxy.go +++ b/proxy-router/internal/rpcproxy/rpc_proxy.go @@ -2,20 +2,68 @@ package rpcproxy import ( "context" + "math/big" + constants "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal" + "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal/interfaces" + "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal/repositories/registries" + "github.com/gin-gonic/gin" + + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethclient" ) type RpcProxy struct { - rpcClient *ethclient.Client + rpcClient *ethclient.Client + providerRegistry *registries.ProviderRegistry + modelRegistry *registries.ModelRegistry + marketplace *registries.Marketplace } -func NewRpcProxy(rpcClient *ethclient.Client) *RpcProxy { +func NewRpcProxy(rpcClient *ethclient.Client, providerRegistryAddr common.Address, modelRegistryAddr common.Address, marketplaceAddr common.Address, log interfaces.ILogger) *RpcProxy { + providerRegistry := registries.NewProviderRegistry(providerRegistryAddr, rpcClient, log) + modelRegistry := registries.NewModelRegistry(modelRegistryAddr, rpcClient, log) + marketplace := registries.NewMarketplace(marketplaceAddr, rpcClient, log) return &RpcProxy{ - rpcClient: rpcClient, + rpcClient: rpcClient, + providerRegistry: providerRegistry, + modelRegistry: modelRegistry, + marketplace: marketplace, } } func (rpcProxy *RpcProxy) GetLatestBlock(ctx context.Context) (uint64, error) { return rpcProxy.rpcClient.BlockNumber(ctx) } + +func (rpcProxy *RpcProxy) GetAllProviders(ctx context.Context) (int, gin.H) { + addrs, providers, err := rpcProxy.providerRegistry.GetAllProviders(ctx) + if err != nil { + return constants.HTTP_STATUS_BAD_REQUEST, gin.H{"error": err.Error()} + } + return constants.HTTP_STATUS_OK, gin.H{"addresses": addrs, "providers": providers} +} + +func (rpcProxy *RpcProxy) GetAllModels(ctx context.Context) (int, gin.H) { + models, err := rpcProxy.modelRegistry.GetAllProviders(ctx) + if err != nil { + return constants.HTTP_STATUS_BAD_REQUEST, gin.H{"error": err.Error()} + } + return constants.HTTP_STATUS_OK, gin.H{"models": models} +} + +func (rpcProxy *RpcProxy) GetBidsByProdiver(ctx context.Context, providerAddr common.Address, offset *big.Int, limit uint8) (int, gin.H) { + bids, err := rpcProxy.marketplace.GetBidsByProvider(ctx, providerAddr, offset, limit) + if err != nil { + return constants.HTTP_STATUS_BAD_REQUEST, gin.H{"error": err.Error()} + } + return constants.HTTP_STATUS_OK, gin.H{"bids": bids} +} + +func (rpcProxy *RpcProxy) GetBidsByModelAgent(ctx context.Context, modelId [32]byte, offset *big.Int, limit uint8) (int, gin.H) { + bids, err := rpcProxy.marketplace.GetBidsByModelAgent(ctx, modelId, offset, limit) + if err != nil { + return constants.HTTP_STATUS_BAD_REQUEST, gin.H{"error": err.Error()} + } + return constants.HTTP_STATUS_OK, gin.H{"bids": bids} +} diff --git a/smart-contracts/bindings/go/contracts/agentregistry/AgentRegistry.go b/smart-contracts/bindings/go/contracts/agentregistry/AgentRegistry.go new file mode 100644 index 00000000..9f252d89 --- /dev/null +++ b/smart-contracts/bindings/go/contracts/agentregistry/AgentRegistry.go @@ -0,0 +1,1296 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package agentregistry + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// AgentRegistryAgent is an auto generated low-level Go binding around an user-defined struct. +type AgentRegistryAgent struct { + AgentId [32]byte + Fee *big.Int + Stake *big.Int + Timestamp *big.Int + Owner common.Address + Name string + Tags []string +} + +// AgentRegistryMetaData contains all meta data concerning the AgentRegistry contract. +var AgentRegistryMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[],\"name\":\"KeyExists\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"KeyNotFound\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ModelNotFound\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotSenderOrOwner\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"StakeTooLow\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ZeroKey\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"agentId\",\"type\":\"bytes32\"}],\"name\":\"Deregistered\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newStake\",\"type\":\"uint256\"}],\"name\":\"MinStakeUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"agentId\",\"type\":\"bytes32\"}],\"name\":\"RegisteredUpdated\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"id\",\"type\":\"bytes32\"}],\"name\":\"deregister\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"id\",\"type\":\"bytes32\"}],\"name\":\"exists\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAll\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"agentId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"stake\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string[]\",\"name\":\"tags\",\"type\":\"string[]\"}],\"internalType\":\"structAgentRegistry.Agent[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getIds\",\"outputs\":[{\"internalType\":\"bytes32[]\",\"name\":\"\",\"type\":\"bytes32[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"map\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"agentId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"stake\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timestamp\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minStake\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"addStake\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"agentId\",\"type\":\"bytes32\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string[]\",\"name\":\"tags\",\"type\":\"string[]\"}],\"name\":\"register\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_minStake\",\"type\":\"uint256\"}],\"name\":\"setMinStake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"token\",\"outputs\":[{\"internalType\":\"contractERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", +} + +// AgentRegistryABI is the input ABI used to generate the binding from. +// Deprecated: Use AgentRegistryMetaData.ABI instead. +var AgentRegistryABI = AgentRegistryMetaData.ABI + +// AgentRegistry is an auto generated Go binding around an Ethereum contract. +type AgentRegistry struct { + AgentRegistryCaller // Read-only binding to the contract + AgentRegistryTransactor // Write-only binding to the contract + AgentRegistryFilterer // Log filterer for contract events +} + +// AgentRegistryCaller is an auto generated read-only Go binding around an Ethereum contract. +type AgentRegistryCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// AgentRegistryTransactor is an auto generated write-only Go binding around an Ethereum contract. +type AgentRegistryTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// AgentRegistryFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type AgentRegistryFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// AgentRegistrySession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type AgentRegistrySession struct { + Contract *AgentRegistry // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// AgentRegistryCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type AgentRegistryCallerSession struct { + Contract *AgentRegistryCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// AgentRegistryTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type AgentRegistryTransactorSession struct { + Contract *AgentRegistryTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// AgentRegistryRaw is an auto generated low-level Go binding around an Ethereum contract. +type AgentRegistryRaw struct { + Contract *AgentRegistry // Generic contract binding to access the raw methods on +} + +// AgentRegistryCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type AgentRegistryCallerRaw struct { + Contract *AgentRegistryCaller // Generic read-only contract binding to access the raw methods on +} + +// AgentRegistryTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type AgentRegistryTransactorRaw struct { + Contract *AgentRegistryTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewAgentRegistry creates a new instance of AgentRegistry, bound to a specific deployed contract. +func NewAgentRegistry(address common.Address, backend bind.ContractBackend) (*AgentRegistry, error) { + contract, err := bindAgentRegistry(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &AgentRegistry{AgentRegistryCaller: AgentRegistryCaller{contract: contract}, AgentRegistryTransactor: AgentRegistryTransactor{contract: contract}, AgentRegistryFilterer: AgentRegistryFilterer{contract: contract}}, nil +} + +// NewAgentRegistryCaller creates a new read-only instance of AgentRegistry, bound to a specific deployed contract. +func NewAgentRegistryCaller(address common.Address, caller bind.ContractCaller) (*AgentRegistryCaller, error) { + contract, err := bindAgentRegistry(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &AgentRegistryCaller{contract: contract}, nil +} + +// NewAgentRegistryTransactor creates a new write-only instance of AgentRegistry, bound to a specific deployed contract. +func NewAgentRegistryTransactor(address common.Address, transactor bind.ContractTransactor) (*AgentRegistryTransactor, error) { + contract, err := bindAgentRegistry(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &AgentRegistryTransactor{contract: contract}, nil +} + +// NewAgentRegistryFilterer creates a new log filterer instance of AgentRegistry, bound to a specific deployed contract. +func NewAgentRegistryFilterer(address common.Address, filterer bind.ContractFilterer) (*AgentRegistryFilterer, error) { + contract, err := bindAgentRegistry(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &AgentRegistryFilterer{contract: contract}, nil +} + +// bindAgentRegistry binds a generic wrapper to an already deployed contract. +func bindAgentRegistry(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := AgentRegistryMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_AgentRegistry *AgentRegistryRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _AgentRegistry.Contract.AgentRegistryCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_AgentRegistry *AgentRegistryRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _AgentRegistry.Contract.AgentRegistryTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_AgentRegistry *AgentRegistryRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _AgentRegistry.Contract.AgentRegistryTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_AgentRegistry *AgentRegistryCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _AgentRegistry.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_AgentRegistry *AgentRegistryTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _AgentRegistry.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_AgentRegistry *AgentRegistryTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _AgentRegistry.Contract.contract.Transact(opts, method, params...) +} + +// Exists is a free data retrieval call binding the contract method 0x38a699a4. +// +// Solidity: function exists(bytes32 id) view returns(bool) +func (_AgentRegistry *AgentRegistryCaller) Exists(opts *bind.CallOpts, id [32]byte) (bool, error) { + var out []interface{} + err := _AgentRegistry.contract.Call(opts, &out, "exists", id) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// Exists is a free data retrieval call binding the contract method 0x38a699a4. +// +// Solidity: function exists(bytes32 id) view returns(bool) +func (_AgentRegistry *AgentRegistrySession) Exists(id [32]byte) (bool, error) { + return _AgentRegistry.Contract.Exists(&_AgentRegistry.CallOpts, id) +} + +// Exists is a free data retrieval call binding the contract method 0x38a699a4. +// +// Solidity: function exists(bytes32 id) view returns(bool) +func (_AgentRegistry *AgentRegistryCallerSession) Exists(id [32]byte) (bool, error) { + return _AgentRegistry.Contract.Exists(&_AgentRegistry.CallOpts, id) +} + +// GetAll is a free data retrieval call binding the contract method 0x53ed5143. +// +// Solidity: function getAll() view returns((bytes32,uint256,uint256,uint256,address,string,string[])[]) +func (_AgentRegistry *AgentRegistryCaller) GetAll(opts *bind.CallOpts) ([]AgentRegistryAgent, error) { + var out []interface{} + err := _AgentRegistry.contract.Call(opts, &out, "getAll") + + if err != nil { + return *new([]AgentRegistryAgent), err + } + + out0 := *abi.ConvertType(out[0], new([]AgentRegistryAgent)).(*[]AgentRegistryAgent) + + return out0, err + +} + +// GetAll is a free data retrieval call binding the contract method 0x53ed5143. +// +// Solidity: function getAll() view returns((bytes32,uint256,uint256,uint256,address,string,string[])[]) +func (_AgentRegistry *AgentRegistrySession) GetAll() ([]AgentRegistryAgent, error) { + return _AgentRegistry.Contract.GetAll(&_AgentRegistry.CallOpts) +} + +// GetAll is a free data retrieval call binding the contract method 0x53ed5143. +// +// Solidity: function getAll() view returns((bytes32,uint256,uint256,uint256,address,string,string[])[]) +func (_AgentRegistry *AgentRegistryCallerSession) GetAll() ([]AgentRegistryAgent, error) { + return _AgentRegistry.Contract.GetAll(&_AgentRegistry.CallOpts) +} + +// GetIds is a free data retrieval call binding the contract method 0x2b105663. +// +// Solidity: function getIds() view returns(bytes32[]) +func (_AgentRegistry *AgentRegistryCaller) GetIds(opts *bind.CallOpts) ([][32]byte, error) { + var out []interface{} + err := _AgentRegistry.contract.Call(opts, &out, "getIds") + + if err != nil { + return *new([][32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([][32]byte)).(*[][32]byte) + + return out0, err + +} + +// GetIds is a free data retrieval call binding the contract method 0x2b105663. +// +// Solidity: function getIds() view returns(bytes32[]) +func (_AgentRegistry *AgentRegistrySession) GetIds() ([][32]byte, error) { + return _AgentRegistry.Contract.GetIds(&_AgentRegistry.CallOpts) +} + +// GetIds is a free data retrieval call binding the contract method 0x2b105663. +// +// Solidity: function getIds() view returns(bytes32[]) +func (_AgentRegistry *AgentRegistryCallerSession) GetIds() ([][32]byte, error) { + return _AgentRegistry.Contract.GetIds(&_AgentRegistry.CallOpts) +} + +// Map is a free data retrieval call binding the contract method 0x0ae186a8. +// +// Solidity: function map(bytes32 ) view returns(bytes32 agentId, uint256 fee, uint256 stake, uint256 timestamp, address owner, string name) +func (_AgentRegistry *AgentRegistryCaller) Map(opts *bind.CallOpts, arg0 [32]byte) (struct { + AgentId [32]byte + Fee *big.Int + Stake *big.Int + Timestamp *big.Int + Owner common.Address + Name string +}, error) { + var out []interface{} + err := _AgentRegistry.contract.Call(opts, &out, "map", arg0) + + outstruct := new(struct { + AgentId [32]byte + Fee *big.Int + Stake *big.Int + Timestamp *big.Int + Owner common.Address + Name string + }) + if err != nil { + return *outstruct, err + } + + outstruct.AgentId = *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + outstruct.Fee = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) + outstruct.Stake = *abi.ConvertType(out[2], new(*big.Int)).(**big.Int) + outstruct.Timestamp = *abi.ConvertType(out[3], new(*big.Int)).(**big.Int) + outstruct.Owner = *abi.ConvertType(out[4], new(common.Address)).(*common.Address) + outstruct.Name = *abi.ConvertType(out[5], new(string)).(*string) + + return *outstruct, err + +} + +// Map is a free data retrieval call binding the contract method 0x0ae186a8. +// +// Solidity: function map(bytes32 ) view returns(bytes32 agentId, uint256 fee, uint256 stake, uint256 timestamp, address owner, string name) +func (_AgentRegistry *AgentRegistrySession) Map(arg0 [32]byte) (struct { + AgentId [32]byte + Fee *big.Int + Stake *big.Int + Timestamp *big.Int + Owner common.Address + Name string +}, error) { + return _AgentRegistry.Contract.Map(&_AgentRegistry.CallOpts, arg0) +} + +// Map is a free data retrieval call binding the contract method 0x0ae186a8. +// +// Solidity: function map(bytes32 ) view returns(bytes32 agentId, uint256 fee, uint256 stake, uint256 timestamp, address owner, string name) +func (_AgentRegistry *AgentRegistryCallerSession) Map(arg0 [32]byte) (struct { + AgentId [32]byte + Fee *big.Int + Stake *big.Int + Timestamp *big.Int + Owner common.Address + Name string +}, error) { + return _AgentRegistry.Contract.Map(&_AgentRegistry.CallOpts, arg0) +} + +// MinStake is a free data retrieval call binding the contract method 0x375b3c0a. +// +// Solidity: function minStake() view returns(uint256) +func (_AgentRegistry *AgentRegistryCaller) MinStake(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _AgentRegistry.contract.Call(opts, &out, "minStake") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// MinStake is a free data retrieval call binding the contract method 0x375b3c0a. +// +// Solidity: function minStake() view returns(uint256) +func (_AgentRegistry *AgentRegistrySession) MinStake() (*big.Int, error) { + return _AgentRegistry.Contract.MinStake(&_AgentRegistry.CallOpts) +} + +// MinStake is a free data retrieval call binding the contract method 0x375b3c0a. +// +// Solidity: function minStake() view returns(uint256) +func (_AgentRegistry *AgentRegistryCallerSession) MinStake() (*big.Int, error) { + return _AgentRegistry.Contract.MinStake(&_AgentRegistry.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_AgentRegistry *AgentRegistryCaller) Owner(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _AgentRegistry.contract.Call(opts, &out, "owner") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_AgentRegistry *AgentRegistrySession) Owner() (common.Address, error) { + return _AgentRegistry.Contract.Owner(&_AgentRegistry.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_AgentRegistry *AgentRegistryCallerSession) Owner() (common.Address, error) { + return _AgentRegistry.Contract.Owner(&_AgentRegistry.CallOpts) +} + +// Token is a free data retrieval call binding the contract method 0xfc0c546a. +// +// Solidity: function token() view returns(address) +func (_AgentRegistry *AgentRegistryCaller) Token(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _AgentRegistry.contract.Call(opts, &out, "token") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Token is a free data retrieval call binding the contract method 0xfc0c546a. +// +// Solidity: function token() view returns(address) +func (_AgentRegistry *AgentRegistrySession) Token() (common.Address, error) { + return _AgentRegistry.Contract.Token(&_AgentRegistry.CallOpts) +} + +// Token is a free data retrieval call binding the contract method 0xfc0c546a. +// +// Solidity: function token() view returns(address) +func (_AgentRegistry *AgentRegistryCallerSession) Token() (common.Address, error) { + return _AgentRegistry.Contract.Token(&_AgentRegistry.CallOpts) +} + +// Deregister is a paid mutator transaction binding the contract method 0x20813154. +// +// Solidity: function deregister(bytes32 id) returns() +func (_AgentRegistry *AgentRegistryTransactor) Deregister(opts *bind.TransactOpts, id [32]byte) (*types.Transaction, error) { + return _AgentRegistry.contract.Transact(opts, "deregister", id) +} + +// Deregister is a paid mutator transaction binding the contract method 0x20813154. +// +// Solidity: function deregister(bytes32 id) returns() +func (_AgentRegistry *AgentRegistrySession) Deregister(id [32]byte) (*types.Transaction, error) { + return _AgentRegistry.Contract.Deregister(&_AgentRegistry.TransactOpts, id) +} + +// Deregister is a paid mutator transaction binding the contract method 0x20813154. +// +// Solidity: function deregister(bytes32 id) returns() +func (_AgentRegistry *AgentRegistryTransactorSession) Deregister(id [32]byte) (*types.Transaction, error) { + return _AgentRegistry.Contract.Deregister(&_AgentRegistry.TransactOpts, id) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc4d66de8. +// +// Solidity: function initialize(address _token) returns() +func (_AgentRegistry *AgentRegistryTransactor) Initialize(opts *bind.TransactOpts, _token common.Address) (*types.Transaction, error) { + return _AgentRegistry.contract.Transact(opts, "initialize", _token) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc4d66de8. +// +// Solidity: function initialize(address _token) returns() +func (_AgentRegistry *AgentRegistrySession) Initialize(_token common.Address) (*types.Transaction, error) { + return _AgentRegistry.Contract.Initialize(&_AgentRegistry.TransactOpts, _token) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc4d66de8. +// +// Solidity: function initialize(address _token) returns() +func (_AgentRegistry *AgentRegistryTransactorSession) Initialize(_token common.Address) (*types.Transaction, error) { + return _AgentRegistry.Contract.Initialize(&_AgentRegistry.TransactOpts, _token) +} + +// Register is a paid mutator transaction binding the contract method 0xcca4cb64. +// +// Solidity: function register(uint256 addStake, uint256 fee, address owner, bytes32 agentId, string name, string[] tags) returns() +func (_AgentRegistry *AgentRegistryTransactor) Register(opts *bind.TransactOpts, addStake *big.Int, fee *big.Int, owner common.Address, agentId [32]byte, name string, tags []string) (*types.Transaction, error) { + return _AgentRegistry.contract.Transact(opts, "register", addStake, fee, owner, agentId, name, tags) +} + +// Register is a paid mutator transaction binding the contract method 0xcca4cb64. +// +// Solidity: function register(uint256 addStake, uint256 fee, address owner, bytes32 agentId, string name, string[] tags) returns() +func (_AgentRegistry *AgentRegistrySession) Register(addStake *big.Int, fee *big.Int, owner common.Address, agentId [32]byte, name string, tags []string) (*types.Transaction, error) { + return _AgentRegistry.Contract.Register(&_AgentRegistry.TransactOpts, addStake, fee, owner, agentId, name, tags) +} + +// Register is a paid mutator transaction binding the contract method 0xcca4cb64. +// +// Solidity: function register(uint256 addStake, uint256 fee, address owner, bytes32 agentId, string name, string[] tags) returns() +func (_AgentRegistry *AgentRegistryTransactorSession) Register(addStake *big.Int, fee *big.Int, owner common.Address, agentId [32]byte, name string, tags []string) (*types.Transaction, error) { + return _AgentRegistry.Contract.Register(&_AgentRegistry.TransactOpts, addStake, fee, owner, agentId, name, tags) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_AgentRegistry *AgentRegistryTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { + return _AgentRegistry.contract.Transact(opts, "renounceOwnership") +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_AgentRegistry *AgentRegistrySession) RenounceOwnership() (*types.Transaction, error) { + return _AgentRegistry.Contract.RenounceOwnership(&_AgentRegistry.TransactOpts) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_AgentRegistry *AgentRegistryTransactorSession) RenounceOwnership() (*types.Transaction, error) { + return _AgentRegistry.Contract.RenounceOwnership(&_AgentRegistry.TransactOpts) +} + +// SetMinStake is a paid mutator transaction binding the contract method 0x8c80fd90. +// +// Solidity: function setMinStake(uint256 _minStake) returns() +func (_AgentRegistry *AgentRegistryTransactor) SetMinStake(opts *bind.TransactOpts, _minStake *big.Int) (*types.Transaction, error) { + return _AgentRegistry.contract.Transact(opts, "setMinStake", _minStake) +} + +// SetMinStake is a paid mutator transaction binding the contract method 0x8c80fd90. +// +// Solidity: function setMinStake(uint256 _minStake) returns() +func (_AgentRegistry *AgentRegistrySession) SetMinStake(_minStake *big.Int) (*types.Transaction, error) { + return _AgentRegistry.Contract.SetMinStake(&_AgentRegistry.TransactOpts, _minStake) +} + +// SetMinStake is a paid mutator transaction binding the contract method 0x8c80fd90. +// +// Solidity: function setMinStake(uint256 _minStake) returns() +func (_AgentRegistry *AgentRegistryTransactorSession) SetMinStake(_minStake *big.Int) (*types.Transaction, error) { + return _AgentRegistry.Contract.SetMinStake(&_AgentRegistry.TransactOpts, _minStake) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_AgentRegistry *AgentRegistryTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) { + return _AgentRegistry.contract.Transact(opts, "transferOwnership", newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_AgentRegistry *AgentRegistrySession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _AgentRegistry.Contract.TransferOwnership(&_AgentRegistry.TransactOpts, newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_AgentRegistry *AgentRegistryTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _AgentRegistry.Contract.TransferOwnership(&_AgentRegistry.TransactOpts, newOwner) +} + +// AgentRegistryDeregisteredIterator is returned from FilterDeregistered and is used to iterate over the raw logs and unpacked data for Deregistered events raised by the AgentRegistry contract. +type AgentRegistryDeregisteredIterator struct { + Event *AgentRegistryDeregistered // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *AgentRegistryDeregisteredIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(AgentRegistryDeregistered) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(AgentRegistryDeregistered) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *AgentRegistryDeregisteredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *AgentRegistryDeregisteredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// AgentRegistryDeregistered represents a Deregistered event raised by the AgentRegistry contract. +type AgentRegistryDeregistered struct { + Owner common.Address + AgentId [32]byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterDeregistered is a free log retrieval operation binding the contract event 0xcc0d8d49cb9a5a3eebc1e1f0b607b8aad83fbe9618e448df79b8a0cc33319472. +// +// Solidity: event Deregistered(address indexed owner, bytes32 indexed agentId) +func (_AgentRegistry *AgentRegistryFilterer) FilterDeregistered(opts *bind.FilterOpts, owner []common.Address, agentId [][32]byte) (*AgentRegistryDeregisteredIterator, error) { + + var ownerRule []interface{} + for _, ownerItem := range owner { + ownerRule = append(ownerRule, ownerItem) + } + var agentIdRule []interface{} + for _, agentIdItem := range agentId { + agentIdRule = append(agentIdRule, agentIdItem) + } + + logs, sub, err := _AgentRegistry.contract.FilterLogs(opts, "Deregistered", ownerRule, agentIdRule) + if err != nil { + return nil, err + } + return &AgentRegistryDeregisteredIterator{contract: _AgentRegistry.contract, event: "Deregistered", logs: logs, sub: sub}, nil +} + +// WatchDeregistered is a free log subscription operation binding the contract event 0xcc0d8d49cb9a5a3eebc1e1f0b607b8aad83fbe9618e448df79b8a0cc33319472. +// +// Solidity: event Deregistered(address indexed owner, bytes32 indexed agentId) +func (_AgentRegistry *AgentRegistryFilterer) WatchDeregistered(opts *bind.WatchOpts, sink chan<- *AgentRegistryDeregistered, owner []common.Address, agentId [][32]byte) (event.Subscription, error) { + + var ownerRule []interface{} + for _, ownerItem := range owner { + ownerRule = append(ownerRule, ownerItem) + } + var agentIdRule []interface{} + for _, agentIdItem := range agentId { + agentIdRule = append(agentIdRule, agentIdItem) + } + + logs, sub, err := _AgentRegistry.contract.WatchLogs(opts, "Deregistered", ownerRule, agentIdRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(AgentRegistryDeregistered) + if err := _AgentRegistry.contract.UnpackLog(event, "Deregistered", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseDeregistered is a log parse operation binding the contract event 0xcc0d8d49cb9a5a3eebc1e1f0b607b8aad83fbe9618e448df79b8a0cc33319472. +// +// Solidity: event Deregistered(address indexed owner, bytes32 indexed agentId) +func (_AgentRegistry *AgentRegistryFilterer) ParseDeregistered(log types.Log) (*AgentRegistryDeregistered, error) { + event := new(AgentRegistryDeregistered) + if err := _AgentRegistry.contract.UnpackLog(event, "Deregistered", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// AgentRegistryInitializedIterator is returned from FilterInitialized and is used to iterate over the raw logs and unpacked data for Initialized events raised by the AgentRegistry contract. +type AgentRegistryInitializedIterator struct { + Event *AgentRegistryInitialized // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *AgentRegistryInitializedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(AgentRegistryInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(AgentRegistryInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *AgentRegistryInitializedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *AgentRegistryInitializedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// AgentRegistryInitialized represents a Initialized event raised by the AgentRegistry contract. +type AgentRegistryInitialized struct { + Version uint8 + Raw types.Log // Blockchain specific contextual infos +} + +// FilterInitialized is a free log retrieval operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_AgentRegistry *AgentRegistryFilterer) FilterInitialized(opts *bind.FilterOpts) (*AgentRegistryInitializedIterator, error) { + + logs, sub, err := _AgentRegistry.contract.FilterLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return &AgentRegistryInitializedIterator{contract: _AgentRegistry.contract, event: "Initialized", logs: logs, sub: sub}, nil +} + +// WatchInitialized is a free log subscription operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_AgentRegistry *AgentRegistryFilterer) WatchInitialized(opts *bind.WatchOpts, sink chan<- *AgentRegistryInitialized) (event.Subscription, error) { + + logs, sub, err := _AgentRegistry.contract.WatchLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(AgentRegistryInitialized) + if err := _AgentRegistry.contract.UnpackLog(event, "Initialized", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseInitialized is a log parse operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_AgentRegistry *AgentRegistryFilterer) ParseInitialized(log types.Log) (*AgentRegistryInitialized, error) { + event := new(AgentRegistryInitialized) + if err := _AgentRegistry.contract.UnpackLog(event, "Initialized", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// AgentRegistryMinStakeUpdatedIterator is returned from FilterMinStakeUpdated and is used to iterate over the raw logs and unpacked data for MinStakeUpdated events raised by the AgentRegistry contract. +type AgentRegistryMinStakeUpdatedIterator struct { + Event *AgentRegistryMinStakeUpdated // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *AgentRegistryMinStakeUpdatedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(AgentRegistryMinStakeUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(AgentRegistryMinStakeUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *AgentRegistryMinStakeUpdatedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *AgentRegistryMinStakeUpdatedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// AgentRegistryMinStakeUpdated represents a MinStakeUpdated event raised by the AgentRegistry contract. +type AgentRegistryMinStakeUpdated struct { + NewStake *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterMinStakeUpdated is a free log retrieval operation binding the contract event 0x47ab46f2c8d4258304a2f5551c1cbdb6981be49631365d1ba7191288a73f39ef. +// +// Solidity: event MinStakeUpdated(uint256 newStake) +func (_AgentRegistry *AgentRegistryFilterer) FilterMinStakeUpdated(opts *bind.FilterOpts) (*AgentRegistryMinStakeUpdatedIterator, error) { + + logs, sub, err := _AgentRegistry.contract.FilterLogs(opts, "MinStakeUpdated") + if err != nil { + return nil, err + } + return &AgentRegistryMinStakeUpdatedIterator{contract: _AgentRegistry.contract, event: "MinStakeUpdated", logs: logs, sub: sub}, nil +} + +// WatchMinStakeUpdated is a free log subscription operation binding the contract event 0x47ab46f2c8d4258304a2f5551c1cbdb6981be49631365d1ba7191288a73f39ef. +// +// Solidity: event MinStakeUpdated(uint256 newStake) +func (_AgentRegistry *AgentRegistryFilterer) WatchMinStakeUpdated(opts *bind.WatchOpts, sink chan<- *AgentRegistryMinStakeUpdated) (event.Subscription, error) { + + logs, sub, err := _AgentRegistry.contract.WatchLogs(opts, "MinStakeUpdated") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(AgentRegistryMinStakeUpdated) + if err := _AgentRegistry.contract.UnpackLog(event, "MinStakeUpdated", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseMinStakeUpdated is a log parse operation binding the contract event 0x47ab46f2c8d4258304a2f5551c1cbdb6981be49631365d1ba7191288a73f39ef. +// +// Solidity: event MinStakeUpdated(uint256 newStake) +func (_AgentRegistry *AgentRegistryFilterer) ParseMinStakeUpdated(log types.Log) (*AgentRegistryMinStakeUpdated, error) { + event := new(AgentRegistryMinStakeUpdated) + if err := _AgentRegistry.contract.UnpackLog(event, "MinStakeUpdated", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// AgentRegistryOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the AgentRegistry contract. +type AgentRegistryOwnershipTransferredIterator struct { + Event *AgentRegistryOwnershipTransferred // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *AgentRegistryOwnershipTransferredIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(AgentRegistryOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(AgentRegistryOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *AgentRegistryOwnershipTransferredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *AgentRegistryOwnershipTransferredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// AgentRegistryOwnershipTransferred represents a OwnershipTransferred event raised by the AgentRegistry contract. +type AgentRegistryOwnershipTransferred struct { + PreviousOwner common.Address + NewOwner common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_AgentRegistry *AgentRegistryFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*AgentRegistryOwnershipTransferredIterator, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _AgentRegistry.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return &AgentRegistryOwnershipTransferredIterator{contract: _AgentRegistry.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil +} + +// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_AgentRegistry *AgentRegistryFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *AgentRegistryOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _AgentRegistry.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(AgentRegistryOwnershipTransferred) + if err := _AgentRegistry.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_AgentRegistry *AgentRegistryFilterer) ParseOwnershipTransferred(log types.Log) (*AgentRegistryOwnershipTransferred, error) { + event := new(AgentRegistryOwnershipTransferred) + if err := _AgentRegistry.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// AgentRegistryRegisteredUpdatedIterator is returned from FilterRegisteredUpdated and is used to iterate over the raw logs and unpacked data for RegisteredUpdated events raised by the AgentRegistry contract. +type AgentRegistryRegisteredUpdatedIterator struct { + Event *AgentRegistryRegisteredUpdated // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *AgentRegistryRegisteredUpdatedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(AgentRegistryRegisteredUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(AgentRegistryRegisteredUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *AgentRegistryRegisteredUpdatedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *AgentRegistryRegisteredUpdatedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// AgentRegistryRegisteredUpdated represents a RegisteredUpdated event raised by the AgentRegistry contract. +type AgentRegistryRegisteredUpdated struct { + Owner common.Address + AgentId [32]byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterRegisteredUpdated is a free log retrieval operation binding the contract event 0x4dffc4e92367641816479c647d1ff3f03202f6c73b97340cba51a7b577c55804. +// +// Solidity: event RegisteredUpdated(address indexed owner, bytes32 indexed agentId) +func (_AgentRegistry *AgentRegistryFilterer) FilterRegisteredUpdated(opts *bind.FilterOpts, owner []common.Address, agentId [][32]byte) (*AgentRegistryRegisteredUpdatedIterator, error) { + + var ownerRule []interface{} + for _, ownerItem := range owner { + ownerRule = append(ownerRule, ownerItem) + } + var agentIdRule []interface{} + for _, agentIdItem := range agentId { + agentIdRule = append(agentIdRule, agentIdItem) + } + + logs, sub, err := _AgentRegistry.contract.FilterLogs(opts, "RegisteredUpdated", ownerRule, agentIdRule) + if err != nil { + return nil, err + } + return &AgentRegistryRegisteredUpdatedIterator{contract: _AgentRegistry.contract, event: "RegisteredUpdated", logs: logs, sub: sub}, nil +} + +// WatchRegisteredUpdated is a free log subscription operation binding the contract event 0x4dffc4e92367641816479c647d1ff3f03202f6c73b97340cba51a7b577c55804. +// +// Solidity: event RegisteredUpdated(address indexed owner, bytes32 indexed agentId) +func (_AgentRegistry *AgentRegistryFilterer) WatchRegisteredUpdated(opts *bind.WatchOpts, sink chan<- *AgentRegistryRegisteredUpdated, owner []common.Address, agentId [][32]byte) (event.Subscription, error) { + + var ownerRule []interface{} + for _, ownerItem := range owner { + ownerRule = append(ownerRule, ownerItem) + } + var agentIdRule []interface{} + for _, agentIdItem := range agentId { + agentIdRule = append(agentIdRule, agentIdItem) + } + + logs, sub, err := _AgentRegistry.contract.WatchLogs(opts, "RegisteredUpdated", ownerRule, agentIdRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(AgentRegistryRegisteredUpdated) + if err := _AgentRegistry.contract.UnpackLog(event, "RegisteredUpdated", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseRegisteredUpdated is a log parse operation binding the contract event 0x4dffc4e92367641816479c647d1ff3f03202f6c73b97340cba51a7b577c55804. +// +// Solidity: event RegisteredUpdated(address indexed owner, bytes32 indexed agentId) +func (_AgentRegistry *AgentRegistryFilterer) ParseRegisteredUpdated(log types.Log) (*AgentRegistryRegisteredUpdated, error) { + event := new(AgentRegistryRegisteredUpdated) + if err := _AgentRegistry.contract.UnpackLog(event, "RegisteredUpdated", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/smart-contracts/bindings/go/contracts/marketplace/Marketplace.go b/smart-contracts/bindings/go/contracts/marketplace/Marketplace.go new file mode 100644 index 00000000..28c8ad3b --- /dev/null +++ b/smart-contracts/bindings/go/contracts/marketplace/Marketplace.go @@ -0,0 +1,1474 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package marketplace + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// MarketplaceBid is an auto generated low-level Go binding around an user-defined struct. +type MarketplaceBid struct { + Provider common.Address + ModelAgentId [32]byte + Amount *big.Int + Nonce *big.Int + CreatedAt *big.Int + DeletedAt *big.Int +} + +// MarketplaceMetaData contains all meta data concerning the Marketplace contract. +var MarketplaceMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[],\"name\":\"ActiveBidNotFound\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"KeyExists\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"KeyNotFound\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ModelOrAgentNotFound\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotEnoughWithdrawableBalance\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotSenderOrOwner\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ZeroKey\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"modelAgentId\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"name\":\"BidDeleted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"modelAgentId\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"name\":\"BidPosted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"modelFee\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"agentFee\",\"type\":\"uint256\"}],\"name\":\"FeeUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"agentBidFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"bidId\",\"type\":\"bytes32\"}],\"name\":\"deleteModelAgentBid\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"modelAgentId\",\"type\":\"bytes32\"}],\"name\":\"getActiveBidsByModelAgent\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"modelAgentId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"createdAt\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deletedAt\",\"type\":\"uint256\"}],\"internalType\":\"structMarketplace.Bid[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"}],\"name\":\"getActiveBidsByProvider\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"modelAgentId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"createdAt\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deletedAt\",\"type\":\"uint256\"}],\"internalType\":\"structMarketplace.Bid[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"modelAgentId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"offset\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"limit\",\"type\":\"uint8\"}],\"name\":\"getBidsByModelAgent\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"modelAgentId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"createdAt\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deletedAt\",\"type\":\"uint256\"}],\"internalType\":\"structMarketplace.Bid[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"offset\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"limit\",\"type\":\"uint8\"}],\"name\":\"getBidsByProvider\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"modelAgentId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"createdAt\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deletedAt\",\"type\":\"uint256\"}],\"internalType\":\"structMarketplace.Bid[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"modelRegistryAddr\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"providerRegistryAddr\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"map\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"modelAgentId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"createdAt\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deletedAt\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"modelBidFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"modelRegistry\",\"outputs\":[{\"internalType\":\"contractModelRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"providerAddr\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"modelId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"postModelBid\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"bidId\",\"type\":\"bytes32\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"providerModelAgentNonce\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"providerRegistry\",\"outputs\":[{\"internalType\":\"contractProviderRegistry\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"modelFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"agentFee\",\"type\":\"uint256\"}],\"name\":\"setBidFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"token\",\"outputs\":[{\"internalType\":\"contractERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"withdraw\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", +} + +// MarketplaceABI is the input ABI used to generate the binding from. +// Deprecated: Use MarketplaceMetaData.ABI instead. +var MarketplaceABI = MarketplaceMetaData.ABI + +// Marketplace is an auto generated Go binding around an Ethereum contract. +type Marketplace struct { + MarketplaceCaller // Read-only binding to the contract + MarketplaceTransactor // Write-only binding to the contract + MarketplaceFilterer // Log filterer for contract events +} + +// MarketplaceCaller is an auto generated read-only Go binding around an Ethereum contract. +type MarketplaceCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// MarketplaceTransactor is an auto generated write-only Go binding around an Ethereum contract. +type MarketplaceTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// MarketplaceFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type MarketplaceFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// MarketplaceSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type MarketplaceSession struct { + Contract *Marketplace // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// MarketplaceCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type MarketplaceCallerSession struct { + Contract *MarketplaceCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// MarketplaceTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type MarketplaceTransactorSession struct { + Contract *MarketplaceTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// MarketplaceRaw is an auto generated low-level Go binding around an Ethereum contract. +type MarketplaceRaw struct { + Contract *Marketplace // Generic contract binding to access the raw methods on +} + +// MarketplaceCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type MarketplaceCallerRaw struct { + Contract *MarketplaceCaller // Generic read-only contract binding to access the raw methods on +} + +// MarketplaceTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type MarketplaceTransactorRaw struct { + Contract *MarketplaceTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewMarketplace creates a new instance of Marketplace, bound to a specific deployed contract. +func NewMarketplace(address common.Address, backend bind.ContractBackend) (*Marketplace, error) { + contract, err := bindMarketplace(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &Marketplace{MarketplaceCaller: MarketplaceCaller{contract: contract}, MarketplaceTransactor: MarketplaceTransactor{contract: contract}, MarketplaceFilterer: MarketplaceFilterer{contract: contract}}, nil +} + +// NewMarketplaceCaller creates a new read-only instance of Marketplace, bound to a specific deployed contract. +func NewMarketplaceCaller(address common.Address, caller bind.ContractCaller) (*MarketplaceCaller, error) { + contract, err := bindMarketplace(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &MarketplaceCaller{contract: contract}, nil +} + +// NewMarketplaceTransactor creates a new write-only instance of Marketplace, bound to a specific deployed contract. +func NewMarketplaceTransactor(address common.Address, transactor bind.ContractTransactor) (*MarketplaceTransactor, error) { + contract, err := bindMarketplace(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &MarketplaceTransactor{contract: contract}, nil +} + +// NewMarketplaceFilterer creates a new log filterer instance of Marketplace, bound to a specific deployed contract. +func NewMarketplaceFilterer(address common.Address, filterer bind.ContractFilterer) (*MarketplaceFilterer, error) { + contract, err := bindMarketplace(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &MarketplaceFilterer{contract: contract}, nil +} + +// bindMarketplace binds a generic wrapper to an already deployed contract. +func bindMarketplace(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := MarketplaceMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_Marketplace *MarketplaceRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Marketplace.Contract.MarketplaceCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_Marketplace *MarketplaceRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Marketplace.Contract.MarketplaceTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Marketplace *MarketplaceRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Marketplace.Contract.MarketplaceTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_Marketplace *MarketplaceCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Marketplace.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_Marketplace *MarketplaceTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Marketplace.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Marketplace *MarketplaceTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Marketplace.Contract.contract.Transact(opts, method, params...) +} + +// AgentBidFee is a free data retrieval call binding the contract method 0x113d91c9. +// +// Solidity: function agentBidFee() view returns(uint256) +func (_Marketplace *MarketplaceCaller) AgentBidFee(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _Marketplace.contract.Call(opts, &out, "agentBidFee") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// AgentBidFee is a free data retrieval call binding the contract method 0x113d91c9. +// +// Solidity: function agentBidFee() view returns(uint256) +func (_Marketplace *MarketplaceSession) AgentBidFee() (*big.Int, error) { + return _Marketplace.Contract.AgentBidFee(&_Marketplace.CallOpts) +} + +// AgentBidFee is a free data retrieval call binding the contract method 0x113d91c9. +// +// Solidity: function agentBidFee() view returns(uint256) +func (_Marketplace *MarketplaceCallerSession) AgentBidFee() (*big.Int, error) { + return _Marketplace.Contract.AgentBidFee(&_Marketplace.CallOpts) +} + +// GetActiveBidsByModelAgent is a free data retrieval call binding the contract method 0x873d94d5. +// +// Solidity: function getActiveBidsByModelAgent(bytes32 modelAgentId) view returns((address,bytes32,uint256,uint256,uint256,uint256)[]) +func (_Marketplace *MarketplaceCaller) GetActiveBidsByModelAgent(opts *bind.CallOpts, modelAgentId [32]byte) ([]MarketplaceBid, error) { + var out []interface{} + err := _Marketplace.contract.Call(opts, &out, "getActiveBidsByModelAgent", modelAgentId) + + if err != nil { + return *new([]MarketplaceBid), err + } + + out0 := *abi.ConvertType(out[0], new([]MarketplaceBid)).(*[]MarketplaceBid) + + return out0, err + +} + +// GetActiveBidsByModelAgent is a free data retrieval call binding the contract method 0x873d94d5. +// +// Solidity: function getActiveBidsByModelAgent(bytes32 modelAgentId) view returns((address,bytes32,uint256,uint256,uint256,uint256)[]) +func (_Marketplace *MarketplaceSession) GetActiveBidsByModelAgent(modelAgentId [32]byte) ([]MarketplaceBid, error) { + return _Marketplace.Contract.GetActiveBidsByModelAgent(&_Marketplace.CallOpts, modelAgentId) +} + +// GetActiveBidsByModelAgent is a free data retrieval call binding the contract method 0x873d94d5. +// +// Solidity: function getActiveBidsByModelAgent(bytes32 modelAgentId) view returns((address,bytes32,uint256,uint256,uint256,uint256)[]) +func (_Marketplace *MarketplaceCallerSession) GetActiveBidsByModelAgent(modelAgentId [32]byte) ([]MarketplaceBid, error) { + return _Marketplace.Contract.GetActiveBidsByModelAgent(&_Marketplace.CallOpts, modelAgentId) +} + +// GetActiveBidsByProvider is a free data retrieval call binding the contract method 0x9fdaffd0. +// +// Solidity: function getActiveBidsByProvider(address provider) view returns((address,bytes32,uint256,uint256,uint256,uint256)[]) +func (_Marketplace *MarketplaceCaller) GetActiveBidsByProvider(opts *bind.CallOpts, provider common.Address) ([]MarketplaceBid, error) { + var out []interface{} + err := _Marketplace.contract.Call(opts, &out, "getActiveBidsByProvider", provider) + + if err != nil { + return *new([]MarketplaceBid), err + } + + out0 := *abi.ConvertType(out[0], new([]MarketplaceBid)).(*[]MarketplaceBid) + + return out0, err + +} + +// GetActiveBidsByProvider is a free data retrieval call binding the contract method 0x9fdaffd0. +// +// Solidity: function getActiveBidsByProvider(address provider) view returns((address,bytes32,uint256,uint256,uint256,uint256)[]) +func (_Marketplace *MarketplaceSession) GetActiveBidsByProvider(provider common.Address) ([]MarketplaceBid, error) { + return _Marketplace.Contract.GetActiveBidsByProvider(&_Marketplace.CallOpts, provider) +} + +// GetActiveBidsByProvider is a free data retrieval call binding the contract method 0x9fdaffd0. +// +// Solidity: function getActiveBidsByProvider(address provider) view returns((address,bytes32,uint256,uint256,uint256,uint256)[]) +func (_Marketplace *MarketplaceCallerSession) GetActiveBidsByProvider(provider common.Address) ([]MarketplaceBid, error) { + return _Marketplace.Contract.GetActiveBidsByProvider(&_Marketplace.CallOpts, provider) +} + +// GetBidsByModelAgent is a free data retrieval call binding the contract method 0xa87665ec. +// +// Solidity: function getBidsByModelAgent(bytes32 modelAgentId, uint256 offset, uint8 limit) view returns((address,bytes32,uint256,uint256,uint256,uint256)[]) +func (_Marketplace *MarketplaceCaller) GetBidsByModelAgent(opts *bind.CallOpts, modelAgentId [32]byte, offset *big.Int, limit uint8) ([]MarketplaceBid, error) { + var out []interface{} + err := _Marketplace.contract.Call(opts, &out, "getBidsByModelAgent", modelAgentId, offset, limit) + + if err != nil { + return *new([]MarketplaceBid), err + } + + out0 := *abi.ConvertType(out[0], new([]MarketplaceBid)).(*[]MarketplaceBid) + + return out0, err + +} + +// GetBidsByModelAgent is a free data retrieval call binding the contract method 0xa87665ec. +// +// Solidity: function getBidsByModelAgent(bytes32 modelAgentId, uint256 offset, uint8 limit) view returns((address,bytes32,uint256,uint256,uint256,uint256)[]) +func (_Marketplace *MarketplaceSession) GetBidsByModelAgent(modelAgentId [32]byte, offset *big.Int, limit uint8) ([]MarketplaceBid, error) { + return _Marketplace.Contract.GetBidsByModelAgent(&_Marketplace.CallOpts, modelAgentId, offset, limit) +} + +// GetBidsByModelAgent is a free data retrieval call binding the contract method 0xa87665ec. +// +// Solidity: function getBidsByModelAgent(bytes32 modelAgentId, uint256 offset, uint8 limit) view returns((address,bytes32,uint256,uint256,uint256,uint256)[]) +func (_Marketplace *MarketplaceCallerSession) GetBidsByModelAgent(modelAgentId [32]byte, offset *big.Int, limit uint8) ([]MarketplaceBid, error) { + return _Marketplace.Contract.GetBidsByModelAgent(&_Marketplace.CallOpts, modelAgentId, offset, limit) +} + +// GetBidsByProvider is a free data retrieval call binding the contract method 0x2f817685. +// +// Solidity: function getBidsByProvider(address provider, uint256 offset, uint8 limit) view returns((address,bytes32,uint256,uint256,uint256,uint256)[]) +func (_Marketplace *MarketplaceCaller) GetBidsByProvider(opts *bind.CallOpts, provider common.Address, offset *big.Int, limit uint8) ([]MarketplaceBid, error) { + var out []interface{} + err := _Marketplace.contract.Call(opts, &out, "getBidsByProvider", provider, offset, limit) + + if err != nil { + return *new([]MarketplaceBid), err + } + + out0 := *abi.ConvertType(out[0], new([]MarketplaceBid)).(*[]MarketplaceBid) + + return out0, err + +} + +// GetBidsByProvider is a free data retrieval call binding the contract method 0x2f817685. +// +// Solidity: function getBidsByProvider(address provider, uint256 offset, uint8 limit) view returns((address,bytes32,uint256,uint256,uint256,uint256)[]) +func (_Marketplace *MarketplaceSession) GetBidsByProvider(provider common.Address, offset *big.Int, limit uint8) ([]MarketplaceBid, error) { + return _Marketplace.Contract.GetBidsByProvider(&_Marketplace.CallOpts, provider, offset, limit) +} + +// GetBidsByProvider is a free data retrieval call binding the contract method 0x2f817685. +// +// Solidity: function getBidsByProvider(address provider, uint256 offset, uint8 limit) view returns((address,bytes32,uint256,uint256,uint256,uint256)[]) +func (_Marketplace *MarketplaceCallerSession) GetBidsByProvider(provider common.Address, offset *big.Int, limit uint8) ([]MarketplaceBid, error) { + return _Marketplace.Contract.GetBidsByProvider(&_Marketplace.CallOpts, provider, offset, limit) +} + +// Map is a free data retrieval call binding the contract method 0x0ae186a8. +// +// Solidity: function map(bytes32 ) view returns(address provider, bytes32 modelAgentId, uint256 amount, uint256 nonce, uint256 createdAt, uint256 deletedAt) +func (_Marketplace *MarketplaceCaller) Map(opts *bind.CallOpts, arg0 [32]byte) (struct { + Provider common.Address + ModelAgentId [32]byte + Amount *big.Int + Nonce *big.Int + CreatedAt *big.Int + DeletedAt *big.Int +}, error) { + var out []interface{} + err := _Marketplace.contract.Call(opts, &out, "map", arg0) + + outstruct := new(struct { + Provider common.Address + ModelAgentId [32]byte + Amount *big.Int + Nonce *big.Int + CreatedAt *big.Int + DeletedAt *big.Int + }) + if err != nil { + return *outstruct, err + } + + outstruct.Provider = *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + outstruct.ModelAgentId = *abi.ConvertType(out[1], new([32]byte)).(*[32]byte) + outstruct.Amount = *abi.ConvertType(out[2], new(*big.Int)).(**big.Int) + outstruct.Nonce = *abi.ConvertType(out[3], new(*big.Int)).(**big.Int) + outstruct.CreatedAt = *abi.ConvertType(out[4], new(*big.Int)).(**big.Int) + outstruct.DeletedAt = *abi.ConvertType(out[5], new(*big.Int)).(**big.Int) + + return *outstruct, err + +} + +// Map is a free data retrieval call binding the contract method 0x0ae186a8. +// +// Solidity: function map(bytes32 ) view returns(address provider, bytes32 modelAgentId, uint256 amount, uint256 nonce, uint256 createdAt, uint256 deletedAt) +func (_Marketplace *MarketplaceSession) Map(arg0 [32]byte) (struct { + Provider common.Address + ModelAgentId [32]byte + Amount *big.Int + Nonce *big.Int + CreatedAt *big.Int + DeletedAt *big.Int +}, error) { + return _Marketplace.Contract.Map(&_Marketplace.CallOpts, arg0) +} + +// Map is a free data retrieval call binding the contract method 0x0ae186a8. +// +// Solidity: function map(bytes32 ) view returns(address provider, bytes32 modelAgentId, uint256 amount, uint256 nonce, uint256 createdAt, uint256 deletedAt) +func (_Marketplace *MarketplaceCallerSession) Map(arg0 [32]byte) (struct { + Provider common.Address + ModelAgentId [32]byte + Amount *big.Int + Nonce *big.Int + CreatedAt *big.Int + DeletedAt *big.Int +}, error) { + return _Marketplace.Contract.Map(&_Marketplace.CallOpts, arg0) +} + +// ModelBidFee is a free data retrieval call binding the contract method 0x7c785e73. +// +// Solidity: function modelBidFee() view returns(uint256) +func (_Marketplace *MarketplaceCaller) ModelBidFee(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _Marketplace.contract.Call(opts, &out, "modelBidFee") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// ModelBidFee is a free data retrieval call binding the contract method 0x7c785e73. +// +// Solidity: function modelBidFee() view returns(uint256) +func (_Marketplace *MarketplaceSession) ModelBidFee() (*big.Int, error) { + return _Marketplace.Contract.ModelBidFee(&_Marketplace.CallOpts) +} + +// ModelBidFee is a free data retrieval call binding the contract method 0x7c785e73. +// +// Solidity: function modelBidFee() view returns(uint256) +func (_Marketplace *MarketplaceCallerSession) ModelBidFee() (*big.Int, error) { + return _Marketplace.Contract.ModelBidFee(&_Marketplace.CallOpts) +} + +// ModelRegistry is a free data retrieval call binding the contract method 0x2ba36f78. +// +// Solidity: function modelRegistry() view returns(address) +func (_Marketplace *MarketplaceCaller) ModelRegistry(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Marketplace.contract.Call(opts, &out, "modelRegistry") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// ModelRegistry is a free data retrieval call binding the contract method 0x2ba36f78. +// +// Solidity: function modelRegistry() view returns(address) +func (_Marketplace *MarketplaceSession) ModelRegistry() (common.Address, error) { + return _Marketplace.Contract.ModelRegistry(&_Marketplace.CallOpts) +} + +// ModelRegistry is a free data retrieval call binding the contract method 0x2ba36f78. +// +// Solidity: function modelRegistry() view returns(address) +func (_Marketplace *MarketplaceCallerSession) ModelRegistry() (common.Address, error) { + return _Marketplace.Contract.ModelRegistry(&_Marketplace.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_Marketplace *MarketplaceCaller) Owner(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Marketplace.contract.Call(opts, &out, "owner") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_Marketplace *MarketplaceSession) Owner() (common.Address, error) { + return _Marketplace.Contract.Owner(&_Marketplace.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_Marketplace *MarketplaceCallerSession) Owner() (common.Address, error) { + return _Marketplace.Contract.Owner(&_Marketplace.CallOpts) +} + +// ProviderModelAgentNonce is a free data retrieval call binding the contract method 0x93ec6bc5. +// +// Solidity: function providerModelAgentNonce(bytes32 ) view returns(uint256) +func (_Marketplace *MarketplaceCaller) ProviderModelAgentNonce(opts *bind.CallOpts, arg0 [32]byte) (*big.Int, error) { + var out []interface{} + err := _Marketplace.contract.Call(opts, &out, "providerModelAgentNonce", arg0) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// ProviderModelAgentNonce is a free data retrieval call binding the contract method 0x93ec6bc5. +// +// Solidity: function providerModelAgentNonce(bytes32 ) view returns(uint256) +func (_Marketplace *MarketplaceSession) ProviderModelAgentNonce(arg0 [32]byte) (*big.Int, error) { + return _Marketplace.Contract.ProviderModelAgentNonce(&_Marketplace.CallOpts, arg0) +} + +// ProviderModelAgentNonce is a free data retrieval call binding the contract method 0x93ec6bc5. +// +// Solidity: function providerModelAgentNonce(bytes32 ) view returns(uint256) +func (_Marketplace *MarketplaceCallerSession) ProviderModelAgentNonce(arg0 [32]byte) (*big.Int, error) { + return _Marketplace.Contract.ProviderModelAgentNonce(&_Marketplace.CallOpts, arg0) +} + +// ProviderRegistry is a free data retrieval call binding the contract method 0x545921d9. +// +// Solidity: function providerRegistry() view returns(address) +func (_Marketplace *MarketplaceCaller) ProviderRegistry(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Marketplace.contract.Call(opts, &out, "providerRegistry") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// ProviderRegistry is a free data retrieval call binding the contract method 0x545921d9. +// +// Solidity: function providerRegistry() view returns(address) +func (_Marketplace *MarketplaceSession) ProviderRegistry() (common.Address, error) { + return _Marketplace.Contract.ProviderRegistry(&_Marketplace.CallOpts) +} + +// ProviderRegistry is a free data retrieval call binding the contract method 0x545921d9. +// +// Solidity: function providerRegistry() view returns(address) +func (_Marketplace *MarketplaceCallerSession) ProviderRegistry() (common.Address, error) { + return _Marketplace.Contract.ProviderRegistry(&_Marketplace.CallOpts) +} + +// Token is a free data retrieval call binding the contract method 0xfc0c546a. +// +// Solidity: function token() view returns(address) +func (_Marketplace *MarketplaceCaller) Token(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Marketplace.contract.Call(opts, &out, "token") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Token is a free data retrieval call binding the contract method 0xfc0c546a. +// +// Solidity: function token() view returns(address) +func (_Marketplace *MarketplaceSession) Token() (common.Address, error) { + return _Marketplace.Contract.Token(&_Marketplace.CallOpts) +} + +// Token is a free data retrieval call binding the contract method 0xfc0c546a. +// +// Solidity: function token() view returns(address) +func (_Marketplace *MarketplaceCallerSession) Token() (common.Address, error) { + return _Marketplace.Contract.Token(&_Marketplace.CallOpts) +} + +// DeleteModelAgentBid is a paid mutator transaction binding the contract method 0x42856b75. +// +// Solidity: function deleteModelAgentBid(bytes32 bidId) returns() +func (_Marketplace *MarketplaceTransactor) DeleteModelAgentBid(opts *bind.TransactOpts, bidId [32]byte) (*types.Transaction, error) { + return _Marketplace.contract.Transact(opts, "deleteModelAgentBid", bidId) +} + +// DeleteModelAgentBid is a paid mutator transaction binding the contract method 0x42856b75. +// +// Solidity: function deleteModelAgentBid(bytes32 bidId) returns() +func (_Marketplace *MarketplaceSession) DeleteModelAgentBid(bidId [32]byte) (*types.Transaction, error) { + return _Marketplace.Contract.DeleteModelAgentBid(&_Marketplace.TransactOpts, bidId) +} + +// DeleteModelAgentBid is a paid mutator transaction binding the contract method 0x42856b75. +// +// Solidity: function deleteModelAgentBid(bytes32 bidId) returns() +func (_Marketplace *MarketplaceTransactorSession) DeleteModelAgentBid(bidId [32]byte) (*types.Transaction, error) { + return _Marketplace.Contract.DeleteModelAgentBid(&_Marketplace.TransactOpts, bidId) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc0c53b8b. +// +// Solidity: function initialize(address _token, address modelRegistryAddr, address providerRegistryAddr) returns() +func (_Marketplace *MarketplaceTransactor) Initialize(opts *bind.TransactOpts, _token common.Address, modelRegistryAddr common.Address, providerRegistryAddr common.Address) (*types.Transaction, error) { + return _Marketplace.contract.Transact(opts, "initialize", _token, modelRegistryAddr, providerRegistryAddr) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc0c53b8b. +// +// Solidity: function initialize(address _token, address modelRegistryAddr, address providerRegistryAddr) returns() +func (_Marketplace *MarketplaceSession) Initialize(_token common.Address, modelRegistryAddr common.Address, providerRegistryAddr common.Address) (*types.Transaction, error) { + return _Marketplace.Contract.Initialize(&_Marketplace.TransactOpts, _token, modelRegistryAddr, providerRegistryAddr) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc0c53b8b. +// +// Solidity: function initialize(address _token, address modelRegistryAddr, address providerRegistryAddr) returns() +func (_Marketplace *MarketplaceTransactorSession) Initialize(_token common.Address, modelRegistryAddr common.Address, providerRegistryAddr common.Address) (*types.Transaction, error) { + return _Marketplace.Contract.Initialize(&_Marketplace.TransactOpts, _token, modelRegistryAddr, providerRegistryAddr) +} + +// PostModelBid is a paid mutator transaction binding the contract method 0xede96bb1. +// +// Solidity: function postModelBid(address providerAddr, bytes32 modelId, uint256 amount) returns(bytes32 bidId) +func (_Marketplace *MarketplaceTransactor) PostModelBid(opts *bind.TransactOpts, providerAddr common.Address, modelId [32]byte, amount *big.Int) (*types.Transaction, error) { + return _Marketplace.contract.Transact(opts, "postModelBid", providerAddr, modelId, amount) +} + +// PostModelBid is a paid mutator transaction binding the contract method 0xede96bb1. +// +// Solidity: function postModelBid(address providerAddr, bytes32 modelId, uint256 amount) returns(bytes32 bidId) +func (_Marketplace *MarketplaceSession) PostModelBid(providerAddr common.Address, modelId [32]byte, amount *big.Int) (*types.Transaction, error) { + return _Marketplace.Contract.PostModelBid(&_Marketplace.TransactOpts, providerAddr, modelId, amount) +} + +// PostModelBid is a paid mutator transaction binding the contract method 0xede96bb1. +// +// Solidity: function postModelBid(address providerAddr, bytes32 modelId, uint256 amount) returns(bytes32 bidId) +func (_Marketplace *MarketplaceTransactorSession) PostModelBid(providerAddr common.Address, modelId [32]byte, amount *big.Int) (*types.Transaction, error) { + return _Marketplace.Contract.PostModelBid(&_Marketplace.TransactOpts, providerAddr, modelId, amount) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_Marketplace *MarketplaceTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Marketplace.contract.Transact(opts, "renounceOwnership") +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_Marketplace *MarketplaceSession) RenounceOwnership() (*types.Transaction, error) { + return _Marketplace.Contract.RenounceOwnership(&_Marketplace.TransactOpts) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_Marketplace *MarketplaceTransactorSession) RenounceOwnership() (*types.Transaction, error) { + return _Marketplace.Contract.RenounceOwnership(&_Marketplace.TransactOpts) +} + +// SetBidFee is a paid mutator transaction binding the contract method 0xcef0b7f4. +// +// Solidity: function setBidFee(uint256 modelFee, uint256 agentFee) returns() +func (_Marketplace *MarketplaceTransactor) SetBidFee(opts *bind.TransactOpts, modelFee *big.Int, agentFee *big.Int) (*types.Transaction, error) { + return _Marketplace.contract.Transact(opts, "setBidFee", modelFee, agentFee) +} + +// SetBidFee is a paid mutator transaction binding the contract method 0xcef0b7f4. +// +// Solidity: function setBidFee(uint256 modelFee, uint256 agentFee) returns() +func (_Marketplace *MarketplaceSession) SetBidFee(modelFee *big.Int, agentFee *big.Int) (*types.Transaction, error) { + return _Marketplace.Contract.SetBidFee(&_Marketplace.TransactOpts, modelFee, agentFee) +} + +// SetBidFee is a paid mutator transaction binding the contract method 0xcef0b7f4. +// +// Solidity: function setBidFee(uint256 modelFee, uint256 agentFee) returns() +func (_Marketplace *MarketplaceTransactorSession) SetBidFee(modelFee *big.Int, agentFee *big.Int) (*types.Transaction, error) { + return _Marketplace.Contract.SetBidFee(&_Marketplace.TransactOpts, modelFee, agentFee) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_Marketplace *MarketplaceTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) { + return _Marketplace.contract.Transact(opts, "transferOwnership", newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_Marketplace *MarketplaceSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _Marketplace.Contract.TransferOwnership(&_Marketplace.TransactOpts, newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_Marketplace *MarketplaceTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _Marketplace.Contract.TransferOwnership(&_Marketplace.TransactOpts, newOwner) +} + +// Withdraw is a paid mutator transaction binding the contract method 0xf3fef3a3. +// +// Solidity: function withdraw(address addr, uint256 amount) returns() +func (_Marketplace *MarketplaceTransactor) Withdraw(opts *bind.TransactOpts, addr common.Address, amount *big.Int) (*types.Transaction, error) { + return _Marketplace.contract.Transact(opts, "withdraw", addr, amount) +} + +// Withdraw is a paid mutator transaction binding the contract method 0xf3fef3a3. +// +// Solidity: function withdraw(address addr, uint256 amount) returns() +func (_Marketplace *MarketplaceSession) Withdraw(addr common.Address, amount *big.Int) (*types.Transaction, error) { + return _Marketplace.Contract.Withdraw(&_Marketplace.TransactOpts, addr, amount) +} + +// Withdraw is a paid mutator transaction binding the contract method 0xf3fef3a3. +// +// Solidity: function withdraw(address addr, uint256 amount) returns() +func (_Marketplace *MarketplaceTransactorSession) Withdraw(addr common.Address, amount *big.Int) (*types.Transaction, error) { + return _Marketplace.Contract.Withdraw(&_Marketplace.TransactOpts, addr, amount) +} + +// MarketplaceBidDeletedIterator is returned from FilterBidDeleted and is used to iterate over the raw logs and unpacked data for BidDeleted events raised by the Marketplace contract. +type MarketplaceBidDeletedIterator struct { + Event *MarketplaceBidDeleted // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *MarketplaceBidDeletedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(MarketplaceBidDeleted) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(MarketplaceBidDeleted) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *MarketplaceBidDeletedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *MarketplaceBidDeletedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// MarketplaceBidDeleted represents a BidDeleted event raised by the Marketplace contract. +type MarketplaceBidDeleted struct { + Provider common.Address + ModelAgentId [32]byte + Nonce *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterBidDeleted is a free log retrieval operation binding the contract event 0x096f970f504563bca8ac4419b4299946965221e396c34aea149ac84947b9242f. +// +// Solidity: event BidDeleted(address indexed provider, bytes32 indexed modelAgentId, uint256 nonce) +func (_Marketplace *MarketplaceFilterer) FilterBidDeleted(opts *bind.FilterOpts, provider []common.Address, modelAgentId [][32]byte) (*MarketplaceBidDeletedIterator, error) { + + var providerRule []interface{} + for _, providerItem := range provider { + providerRule = append(providerRule, providerItem) + } + var modelAgentIdRule []interface{} + for _, modelAgentIdItem := range modelAgentId { + modelAgentIdRule = append(modelAgentIdRule, modelAgentIdItem) + } + + logs, sub, err := _Marketplace.contract.FilterLogs(opts, "BidDeleted", providerRule, modelAgentIdRule) + if err != nil { + return nil, err + } + return &MarketplaceBidDeletedIterator{contract: _Marketplace.contract, event: "BidDeleted", logs: logs, sub: sub}, nil +} + +// WatchBidDeleted is a free log subscription operation binding the contract event 0x096f970f504563bca8ac4419b4299946965221e396c34aea149ac84947b9242f. +// +// Solidity: event BidDeleted(address indexed provider, bytes32 indexed modelAgentId, uint256 nonce) +func (_Marketplace *MarketplaceFilterer) WatchBidDeleted(opts *bind.WatchOpts, sink chan<- *MarketplaceBidDeleted, provider []common.Address, modelAgentId [][32]byte) (event.Subscription, error) { + + var providerRule []interface{} + for _, providerItem := range provider { + providerRule = append(providerRule, providerItem) + } + var modelAgentIdRule []interface{} + for _, modelAgentIdItem := range modelAgentId { + modelAgentIdRule = append(modelAgentIdRule, modelAgentIdItem) + } + + logs, sub, err := _Marketplace.contract.WatchLogs(opts, "BidDeleted", providerRule, modelAgentIdRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(MarketplaceBidDeleted) + if err := _Marketplace.contract.UnpackLog(event, "BidDeleted", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseBidDeleted is a log parse operation binding the contract event 0x096f970f504563bca8ac4419b4299946965221e396c34aea149ac84947b9242f. +// +// Solidity: event BidDeleted(address indexed provider, bytes32 indexed modelAgentId, uint256 nonce) +func (_Marketplace *MarketplaceFilterer) ParseBidDeleted(log types.Log) (*MarketplaceBidDeleted, error) { + event := new(MarketplaceBidDeleted) + if err := _Marketplace.contract.UnpackLog(event, "BidDeleted", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// MarketplaceBidPostedIterator is returned from FilterBidPosted and is used to iterate over the raw logs and unpacked data for BidPosted events raised by the Marketplace contract. +type MarketplaceBidPostedIterator struct { + Event *MarketplaceBidPosted // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *MarketplaceBidPostedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(MarketplaceBidPosted) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(MarketplaceBidPosted) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *MarketplaceBidPostedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *MarketplaceBidPostedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// MarketplaceBidPosted represents a BidPosted event raised by the Marketplace contract. +type MarketplaceBidPosted struct { + Provider common.Address + ModelAgentId [32]byte + Nonce *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterBidPosted is a free log retrieval operation binding the contract event 0xd138adff73af2621d26114cd9ee4f20dcd39ed78f9e0004215ed49aa22753ebe. +// +// Solidity: event BidPosted(address indexed provider, bytes32 indexed modelAgentId, uint256 nonce) +func (_Marketplace *MarketplaceFilterer) FilterBidPosted(opts *bind.FilterOpts, provider []common.Address, modelAgentId [][32]byte) (*MarketplaceBidPostedIterator, error) { + + var providerRule []interface{} + for _, providerItem := range provider { + providerRule = append(providerRule, providerItem) + } + var modelAgentIdRule []interface{} + for _, modelAgentIdItem := range modelAgentId { + modelAgentIdRule = append(modelAgentIdRule, modelAgentIdItem) + } + + logs, sub, err := _Marketplace.contract.FilterLogs(opts, "BidPosted", providerRule, modelAgentIdRule) + if err != nil { + return nil, err + } + return &MarketplaceBidPostedIterator{contract: _Marketplace.contract, event: "BidPosted", logs: logs, sub: sub}, nil +} + +// WatchBidPosted is a free log subscription operation binding the contract event 0xd138adff73af2621d26114cd9ee4f20dcd39ed78f9e0004215ed49aa22753ebe. +// +// Solidity: event BidPosted(address indexed provider, bytes32 indexed modelAgentId, uint256 nonce) +func (_Marketplace *MarketplaceFilterer) WatchBidPosted(opts *bind.WatchOpts, sink chan<- *MarketplaceBidPosted, provider []common.Address, modelAgentId [][32]byte) (event.Subscription, error) { + + var providerRule []interface{} + for _, providerItem := range provider { + providerRule = append(providerRule, providerItem) + } + var modelAgentIdRule []interface{} + for _, modelAgentIdItem := range modelAgentId { + modelAgentIdRule = append(modelAgentIdRule, modelAgentIdItem) + } + + logs, sub, err := _Marketplace.contract.WatchLogs(opts, "BidPosted", providerRule, modelAgentIdRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(MarketplaceBidPosted) + if err := _Marketplace.contract.UnpackLog(event, "BidPosted", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseBidPosted is a log parse operation binding the contract event 0xd138adff73af2621d26114cd9ee4f20dcd39ed78f9e0004215ed49aa22753ebe. +// +// Solidity: event BidPosted(address indexed provider, bytes32 indexed modelAgentId, uint256 nonce) +func (_Marketplace *MarketplaceFilterer) ParseBidPosted(log types.Log) (*MarketplaceBidPosted, error) { + event := new(MarketplaceBidPosted) + if err := _Marketplace.contract.UnpackLog(event, "BidPosted", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// MarketplaceFeeUpdatedIterator is returned from FilterFeeUpdated and is used to iterate over the raw logs and unpacked data for FeeUpdated events raised by the Marketplace contract. +type MarketplaceFeeUpdatedIterator struct { + Event *MarketplaceFeeUpdated // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *MarketplaceFeeUpdatedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(MarketplaceFeeUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(MarketplaceFeeUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *MarketplaceFeeUpdatedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *MarketplaceFeeUpdatedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// MarketplaceFeeUpdated represents a FeeUpdated event raised by the Marketplace contract. +type MarketplaceFeeUpdated struct { + ModelFee *big.Int + AgentFee *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterFeeUpdated is a free log retrieval operation binding the contract event 0x528d9479e9f9889a87a3c30c7f7ba537e5e59c4c85a37733b16e57c62df61302. +// +// Solidity: event FeeUpdated(uint256 modelFee, uint256 agentFee) +func (_Marketplace *MarketplaceFilterer) FilterFeeUpdated(opts *bind.FilterOpts) (*MarketplaceFeeUpdatedIterator, error) { + + logs, sub, err := _Marketplace.contract.FilterLogs(opts, "FeeUpdated") + if err != nil { + return nil, err + } + return &MarketplaceFeeUpdatedIterator{contract: _Marketplace.contract, event: "FeeUpdated", logs: logs, sub: sub}, nil +} + +// WatchFeeUpdated is a free log subscription operation binding the contract event 0x528d9479e9f9889a87a3c30c7f7ba537e5e59c4c85a37733b16e57c62df61302. +// +// Solidity: event FeeUpdated(uint256 modelFee, uint256 agentFee) +func (_Marketplace *MarketplaceFilterer) WatchFeeUpdated(opts *bind.WatchOpts, sink chan<- *MarketplaceFeeUpdated) (event.Subscription, error) { + + logs, sub, err := _Marketplace.contract.WatchLogs(opts, "FeeUpdated") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(MarketplaceFeeUpdated) + if err := _Marketplace.contract.UnpackLog(event, "FeeUpdated", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseFeeUpdated is a log parse operation binding the contract event 0x528d9479e9f9889a87a3c30c7f7ba537e5e59c4c85a37733b16e57c62df61302. +// +// Solidity: event FeeUpdated(uint256 modelFee, uint256 agentFee) +func (_Marketplace *MarketplaceFilterer) ParseFeeUpdated(log types.Log) (*MarketplaceFeeUpdated, error) { + event := new(MarketplaceFeeUpdated) + if err := _Marketplace.contract.UnpackLog(event, "FeeUpdated", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// MarketplaceInitializedIterator is returned from FilterInitialized and is used to iterate over the raw logs and unpacked data for Initialized events raised by the Marketplace contract. +type MarketplaceInitializedIterator struct { + Event *MarketplaceInitialized // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *MarketplaceInitializedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(MarketplaceInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(MarketplaceInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *MarketplaceInitializedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *MarketplaceInitializedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// MarketplaceInitialized represents a Initialized event raised by the Marketplace contract. +type MarketplaceInitialized struct { + Version uint8 + Raw types.Log // Blockchain specific contextual infos +} + +// FilterInitialized is a free log retrieval operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_Marketplace *MarketplaceFilterer) FilterInitialized(opts *bind.FilterOpts) (*MarketplaceInitializedIterator, error) { + + logs, sub, err := _Marketplace.contract.FilterLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return &MarketplaceInitializedIterator{contract: _Marketplace.contract, event: "Initialized", logs: logs, sub: sub}, nil +} + +// WatchInitialized is a free log subscription operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_Marketplace *MarketplaceFilterer) WatchInitialized(opts *bind.WatchOpts, sink chan<- *MarketplaceInitialized) (event.Subscription, error) { + + logs, sub, err := _Marketplace.contract.WatchLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(MarketplaceInitialized) + if err := _Marketplace.contract.UnpackLog(event, "Initialized", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseInitialized is a log parse operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_Marketplace *MarketplaceFilterer) ParseInitialized(log types.Log) (*MarketplaceInitialized, error) { + event := new(MarketplaceInitialized) + if err := _Marketplace.contract.UnpackLog(event, "Initialized", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// MarketplaceOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the Marketplace contract. +type MarketplaceOwnershipTransferredIterator struct { + Event *MarketplaceOwnershipTransferred // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *MarketplaceOwnershipTransferredIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(MarketplaceOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(MarketplaceOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *MarketplaceOwnershipTransferredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *MarketplaceOwnershipTransferredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// MarketplaceOwnershipTransferred represents a OwnershipTransferred event raised by the Marketplace contract. +type MarketplaceOwnershipTransferred struct { + PreviousOwner common.Address + NewOwner common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_Marketplace *MarketplaceFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*MarketplaceOwnershipTransferredIterator, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _Marketplace.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return &MarketplaceOwnershipTransferredIterator{contract: _Marketplace.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil +} + +// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_Marketplace *MarketplaceFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *MarketplaceOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _Marketplace.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(MarketplaceOwnershipTransferred) + if err := _Marketplace.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_Marketplace *MarketplaceFilterer) ParseOwnershipTransferred(log types.Log) (*MarketplaceOwnershipTransferred, error) { + event := new(MarketplaceOwnershipTransferred) + if err := _Marketplace.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/smart-contracts/bindings/go/contracts/modelregistry/ModelRegistry.go b/smart-contracts/bindings/go/contracts/modelregistry/ModelRegistry.go new file mode 100644 index 00000000..50b23bed --- /dev/null +++ b/smart-contracts/bindings/go/contracts/modelregistry/ModelRegistry.go @@ -0,0 +1,1409 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package modelregistry + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// ModelRegistryModel is an auto generated low-level Go binding around an user-defined struct. +type ModelRegistryModel struct { + IpfsCID [32]byte + Fee *big.Int + Stake *big.Int + Owner common.Address + Name string + Tags []string + Timestamp *big.Int + IsDeleted bool +} + +// ModelRegistryMetaData contains all meta data concerning the ModelRegistry contract. +var ModelRegistryMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[],\"name\":\"KeyExists\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"KeyNotFound\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ModelNotFound\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotSenderOrOwner\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"StakeTooLow\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ZeroKey\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"modelId\",\"type\":\"bytes32\"}],\"name\":\"Deregistered\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newStake\",\"type\":\"uint256\"}],\"name\":\"MinStakeUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"modelId\",\"type\":\"bytes32\"}],\"name\":\"RegisteredUpdated\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"id\",\"type\":\"bytes32\"}],\"name\":\"deregister\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"id\",\"type\":\"bytes32\"}],\"name\":\"exists\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAll\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"ipfsCID\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"stake\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string[]\",\"name\":\"tags\",\"type\":\"string[]\"},{\"internalType\":\"uint128\",\"name\":\"timestamp\",\"type\":\"uint128\"},{\"internalType\":\"bool\",\"name\":\"isDeleted\",\"type\":\"bool\"}],\"internalType\":\"structModelRegistry.Model[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getByIndex\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"modelId\",\"type\":\"bytes32\"},{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"ipfsCID\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"stake\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string[]\",\"name\":\"tags\",\"type\":\"string[]\"},{\"internalType\":\"uint128\",\"name\":\"timestamp\",\"type\":\"uint128\"},{\"internalType\":\"bool\",\"name\":\"isDeleted\",\"type\":\"bool\"}],\"internalType\":\"structModelRegistry.Model\",\"name\":\"model\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"count\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getIds\",\"outputs\":[{\"internalType\":\"bytes32[]\",\"name\":\"\",\"type\":\"bytes32[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"map\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"ipfsCID\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"stake\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"uint128\",\"name\":\"timestamp\",\"type\":\"uint128\"},{\"internalType\":\"bool\",\"name\":\"isDeleted\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minStake\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"models\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"modelId\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"ipfsCID\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"addStake\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string[]\",\"name\":\"tags\",\"type\":\"string[]\"}],\"name\":\"register\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_minStake\",\"type\":\"uint256\"}],\"name\":\"setMinStake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"token\",\"outputs\":[{\"internalType\":\"contractERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", +} + +// ModelRegistryABI is the input ABI used to generate the binding from. +// Deprecated: Use ModelRegistryMetaData.ABI instead. +var ModelRegistryABI = ModelRegistryMetaData.ABI + +// ModelRegistry is an auto generated Go binding around an Ethereum contract. +type ModelRegistry struct { + ModelRegistryCaller // Read-only binding to the contract + ModelRegistryTransactor // Write-only binding to the contract + ModelRegistryFilterer // Log filterer for contract events +} + +// ModelRegistryCaller is an auto generated read-only Go binding around an Ethereum contract. +type ModelRegistryCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ModelRegistryTransactor is an auto generated write-only Go binding around an Ethereum contract. +type ModelRegistryTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ModelRegistryFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type ModelRegistryFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ModelRegistrySession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type ModelRegistrySession struct { + Contract *ModelRegistry // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// ModelRegistryCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type ModelRegistryCallerSession struct { + Contract *ModelRegistryCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// ModelRegistryTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type ModelRegistryTransactorSession struct { + Contract *ModelRegistryTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// ModelRegistryRaw is an auto generated low-level Go binding around an Ethereum contract. +type ModelRegistryRaw struct { + Contract *ModelRegistry // Generic contract binding to access the raw methods on +} + +// ModelRegistryCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type ModelRegistryCallerRaw struct { + Contract *ModelRegistryCaller // Generic read-only contract binding to access the raw methods on +} + +// ModelRegistryTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type ModelRegistryTransactorRaw struct { + Contract *ModelRegistryTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewModelRegistry creates a new instance of ModelRegistry, bound to a specific deployed contract. +func NewModelRegistry(address common.Address, backend bind.ContractBackend) (*ModelRegistry, error) { + contract, err := bindModelRegistry(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &ModelRegistry{ModelRegistryCaller: ModelRegistryCaller{contract: contract}, ModelRegistryTransactor: ModelRegistryTransactor{contract: contract}, ModelRegistryFilterer: ModelRegistryFilterer{contract: contract}}, nil +} + +// NewModelRegistryCaller creates a new read-only instance of ModelRegistry, bound to a specific deployed contract. +func NewModelRegistryCaller(address common.Address, caller bind.ContractCaller) (*ModelRegistryCaller, error) { + contract, err := bindModelRegistry(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &ModelRegistryCaller{contract: contract}, nil +} + +// NewModelRegistryTransactor creates a new write-only instance of ModelRegistry, bound to a specific deployed contract. +func NewModelRegistryTransactor(address common.Address, transactor bind.ContractTransactor) (*ModelRegistryTransactor, error) { + contract, err := bindModelRegistry(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &ModelRegistryTransactor{contract: contract}, nil +} + +// NewModelRegistryFilterer creates a new log filterer instance of ModelRegistry, bound to a specific deployed contract. +func NewModelRegistryFilterer(address common.Address, filterer bind.ContractFilterer) (*ModelRegistryFilterer, error) { + contract, err := bindModelRegistry(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &ModelRegistryFilterer{contract: contract}, nil +} + +// bindModelRegistry binds a generic wrapper to an already deployed contract. +func bindModelRegistry(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := ModelRegistryMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_ModelRegistry *ModelRegistryRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _ModelRegistry.Contract.ModelRegistryCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_ModelRegistry *ModelRegistryRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ModelRegistry.Contract.ModelRegistryTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_ModelRegistry *ModelRegistryRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _ModelRegistry.Contract.ModelRegistryTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_ModelRegistry *ModelRegistryCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _ModelRegistry.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_ModelRegistry *ModelRegistryTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ModelRegistry.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_ModelRegistry *ModelRegistryTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _ModelRegistry.Contract.contract.Transact(opts, method, params...) +} + +// Exists is a free data retrieval call binding the contract method 0x38a699a4. +// +// Solidity: function exists(bytes32 id) view returns(bool) +func (_ModelRegistry *ModelRegistryCaller) Exists(opts *bind.CallOpts, id [32]byte) (bool, error) { + var out []interface{} + err := _ModelRegistry.contract.Call(opts, &out, "exists", id) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// Exists is a free data retrieval call binding the contract method 0x38a699a4. +// +// Solidity: function exists(bytes32 id) view returns(bool) +func (_ModelRegistry *ModelRegistrySession) Exists(id [32]byte) (bool, error) { + return _ModelRegistry.Contract.Exists(&_ModelRegistry.CallOpts, id) +} + +// Exists is a free data retrieval call binding the contract method 0x38a699a4. +// +// Solidity: function exists(bytes32 id) view returns(bool) +func (_ModelRegistry *ModelRegistryCallerSession) Exists(id [32]byte) (bool, error) { + return _ModelRegistry.Contract.Exists(&_ModelRegistry.CallOpts, id) +} + +// GetAll is a free data retrieval call binding the contract method 0x53ed5143. +// +// Solidity: function getAll() view returns((bytes32,uint256,uint256,address,string,string[],uint128,bool)[]) +func (_ModelRegistry *ModelRegistryCaller) GetAll(opts *bind.CallOpts) ([]ModelRegistryModel, error) { + var out []interface{} + err := _ModelRegistry.contract.Call(opts, &out, "getAll") + + if err != nil { + return *new([]ModelRegistryModel), err + } + + out0 := *abi.ConvertType(out[0], new([]ModelRegistryModel)).(*[]ModelRegistryModel) + + return out0, err + +} + +// GetAll is a free data retrieval call binding the contract method 0x53ed5143. +// +// Solidity: function getAll() view returns((bytes32,uint256,uint256,address,string,string[],uint128,bool)[]) +func (_ModelRegistry *ModelRegistrySession) GetAll() ([]ModelRegistryModel, error) { + return _ModelRegistry.Contract.GetAll(&_ModelRegistry.CallOpts) +} + +// GetAll is a free data retrieval call binding the contract method 0x53ed5143. +// +// Solidity: function getAll() view returns((bytes32,uint256,uint256,address,string,string[],uint128,bool)[]) +func (_ModelRegistry *ModelRegistryCallerSession) GetAll() ([]ModelRegistryModel, error) { + return _ModelRegistry.Contract.GetAll(&_ModelRegistry.CallOpts) +} + +// GetByIndex is a free data retrieval call binding the contract method 0x2d883a73. +// +// Solidity: function getByIndex(uint256 index) view returns(bytes32 modelId, (bytes32,uint256,uint256,address,string,string[],uint128,bool) model) +func (_ModelRegistry *ModelRegistryCaller) GetByIndex(opts *bind.CallOpts, index *big.Int) (struct { + ModelId [32]byte + Model ModelRegistryModel +}, error) { + var out []interface{} + err := _ModelRegistry.contract.Call(opts, &out, "getByIndex", index) + + outstruct := new(struct { + ModelId [32]byte + Model ModelRegistryModel + }) + if err != nil { + return *outstruct, err + } + + outstruct.ModelId = *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + outstruct.Model = *abi.ConvertType(out[1], new(ModelRegistryModel)).(*ModelRegistryModel) + + return *outstruct, err + +} + +// GetByIndex is a free data retrieval call binding the contract method 0x2d883a73. +// +// Solidity: function getByIndex(uint256 index) view returns(bytes32 modelId, (bytes32,uint256,uint256,address,string,string[],uint128,bool) model) +func (_ModelRegistry *ModelRegistrySession) GetByIndex(index *big.Int) (struct { + ModelId [32]byte + Model ModelRegistryModel +}, error) { + return _ModelRegistry.Contract.GetByIndex(&_ModelRegistry.CallOpts, index) +} + +// GetByIndex is a free data retrieval call binding the contract method 0x2d883a73. +// +// Solidity: function getByIndex(uint256 index) view returns(bytes32 modelId, (bytes32,uint256,uint256,address,string,string[],uint128,bool) model) +func (_ModelRegistry *ModelRegistryCallerSession) GetByIndex(index *big.Int) (struct { + ModelId [32]byte + Model ModelRegistryModel +}, error) { + return _ModelRegistry.Contract.GetByIndex(&_ModelRegistry.CallOpts, index) +} + +// GetCount is a free data retrieval call binding the contract method 0xa87d942c. +// +// Solidity: function getCount() view returns(uint256 count) +func (_ModelRegistry *ModelRegistryCaller) GetCount(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _ModelRegistry.contract.Call(opts, &out, "getCount") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetCount is a free data retrieval call binding the contract method 0xa87d942c. +// +// Solidity: function getCount() view returns(uint256 count) +func (_ModelRegistry *ModelRegistrySession) GetCount() (*big.Int, error) { + return _ModelRegistry.Contract.GetCount(&_ModelRegistry.CallOpts) +} + +// GetCount is a free data retrieval call binding the contract method 0xa87d942c. +// +// Solidity: function getCount() view returns(uint256 count) +func (_ModelRegistry *ModelRegistryCallerSession) GetCount() (*big.Int, error) { + return _ModelRegistry.Contract.GetCount(&_ModelRegistry.CallOpts) +} + +// GetIds is a free data retrieval call binding the contract method 0x2b105663. +// +// Solidity: function getIds() view returns(bytes32[]) +func (_ModelRegistry *ModelRegistryCaller) GetIds(opts *bind.CallOpts) ([][32]byte, error) { + var out []interface{} + err := _ModelRegistry.contract.Call(opts, &out, "getIds") + + if err != nil { + return *new([][32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([][32]byte)).(*[][32]byte) + + return out0, err + +} + +// GetIds is a free data retrieval call binding the contract method 0x2b105663. +// +// Solidity: function getIds() view returns(bytes32[]) +func (_ModelRegistry *ModelRegistrySession) GetIds() ([][32]byte, error) { + return _ModelRegistry.Contract.GetIds(&_ModelRegistry.CallOpts) +} + +// GetIds is a free data retrieval call binding the contract method 0x2b105663. +// +// Solidity: function getIds() view returns(bytes32[]) +func (_ModelRegistry *ModelRegistryCallerSession) GetIds() ([][32]byte, error) { + return _ModelRegistry.Contract.GetIds(&_ModelRegistry.CallOpts) +} + +// Map is a free data retrieval call binding the contract method 0x0ae186a8. +// +// Solidity: function map(bytes32 ) view returns(bytes32 ipfsCID, uint256 fee, uint256 stake, address owner, string name, uint128 timestamp, bool isDeleted) +func (_ModelRegistry *ModelRegistryCaller) Map(opts *bind.CallOpts, arg0 [32]byte) (struct { + IpfsCID [32]byte + Fee *big.Int + Stake *big.Int + Owner common.Address + Name string + Timestamp *big.Int + IsDeleted bool +}, error) { + var out []interface{} + err := _ModelRegistry.contract.Call(opts, &out, "map", arg0) + + outstruct := new(struct { + IpfsCID [32]byte + Fee *big.Int + Stake *big.Int + Owner common.Address + Name string + Timestamp *big.Int + IsDeleted bool + }) + if err != nil { + return *outstruct, err + } + + outstruct.IpfsCID = *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + outstruct.Fee = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) + outstruct.Stake = *abi.ConvertType(out[2], new(*big.Int)).(**big.Int) + outstruct.Owner = *abi.ConvertType(out[3], new(common.Address)).(*common.Address) + outstruct.Name = *abi.ConvertType(out[4], new(string)).(*string) + outstruct.Timestamp = *abi.ConvertType(out[5], new(*big.Int)).(**big.Int) + outstruct.IsDeleted = *abi.ConvertType(out[6], new(bool)).(*bool) + + return *outstruct, err + +} + +// Map is a free data retrieval call binding the contract method 0x0ae186a8. +// +// Solidity: function map(bytes32 ) view returns(bytes32 ipfsCID, uint256 fee, uint256 stake, address owner, string name, uint128 timestamp, bool isDeleted) +func (_ModelRegistry *ModelRegistrySession) Map(arg0 [32]byte) (struct { + IpfsCID [32]byte + Fee *big.Int + Stake *big.Int + Owner common.Address + Name string + Timestamp *big.Int + IsDeleted bool +}, error) { + return _ModelRegistry.Contract.Map(&_ModelRegistry.CallOpts, arg0) +} + +// Map is a free data retrieval call binding the contract method 0x0ae186a8. +// +// Solidity: function map(bytes32 ) view returns(bytes32 ipfsCID, uint256 fee, uint256 stake, address owner, string name, uint128 timestamp, bool isDeleted) +func (_ModelRegistry *ModelRegistryCallerSession) Map(arg0 [32]byte) (struct { + IpfsCID [32]byte + Fee *big.Int + Stake *big.Int + Owner common.Address + Name string + Timestamp *big.Int + IsDeleted bool +}, error) { + return _ModelRegistry.Contract.Map(&_ModelRegistry.CallOpts, arg0) +} + +// MinStake is a free data retrieval call binding the contract method 0x375b3c0a. +// +// Solidity: function minStake() view returns(uint256) +func (_ModelRegistry *ModelRegistryCaller) MinStake(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _ModelRegistry.contract.Call(opts, &out, "minStake") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// MinStake is a free data retrieval call binding the contract method 0x375b3c0a. +// +// Solidity: function minStake() view returns(uint256) +func (_ModelRegistry *ModelRegistrySession) MinStake() (*big.Int, error) { + return _ModelRegistry.Contract.MinStake(&_ModelRegistry.CallOpts) +} + +// MinStake is a free data retrieval call binding the contract method 0x375b3c0a. +// +// Solidity: function minStake() view returns(uint256) +func (_ModelRegistry *ModelRegistryCallerSession) MinStake() (*big.Int, error) { + return _ModelRegistry.Contract.MinStake(&_ModelRegistry.CallOpts) +} + +// Models is a free data retrieval call binding the contract method 0x6a030ca9. +// +// Solidity: function models(uint256 ) view returns(bytes32) +func (_ModelRegistry *ModelRegistryCaller) Models(opts *bind.CallOpts, arg0 *big.Int) ([32]byte, error) { + var out []interface{} + err := _ModelRegistry.contract.Call(opts, &out, "models", arg0) + + if err != nil { + return *new([32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + + return out0, err + +} + +// Models is a free data retrieval call binding the contract method 0x6a030ca9. +// +// Solidity: function models(uint256 ) view returns(bytes32) +func (_ModelRegistry *ModelRegistrySession) Models(arg0 *big.Int) ([32]byte, error) { + return _ModelRegistry.Contract.Models(&_ModelRegistry.CallOpts, arg0) +} + +// Models is a free data retrieval call binding the contract method 0x6a030ca9. +// +// Solidity: function models(uint256 ) view returns(bytes32) +func (_ModelRegistry *ModelRegistryCallerSession) Models(arg0 *big.Int) ([32]byte, error) { + return _ModelRegistry.Contract.Models(&_ModelRegistry.CallOpts, arg0) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_ModelRegistry *ModelRegistryCaller) Owner(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _ModelRegistry.contract.Call(opts, &out, "owner") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_ModelRegistry *ModelRegistrySession) Owner() (common.Address, error) { + return _ModelRegistry.Contract.Owner(&_ModelRegistry.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_ModelRegistry *ModelRegistryCallerSession) Owner() (common.Address, error) { + return _ModelRegistry.Contract.Owner(&_ModelRegistry.CallOpts) +} + +// Token is a free data retrieval call binding the contract method 0xfc0c546a. +// +// Solidity: function token() view returns(address) +func (_ModelRegistry *ModelRegistryCaller) Token(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _ModelRegistry.contract.Call(opts, &out, "token") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Token is a free data retrieval call binding the contract method 0xfc0c546a. +// +// Solidity: function token() view returns(address) +func (_ModelRegistry *ModelRegistrySession) Token() (common.Address, error) { + return _ModelRegistry.Contract.Token(&_ModelRegistry.CallOpts) +} + +// Token is a free data retrieval call binding the contract method 0xfc0c546a. +// +// Solidity: function token() view returns(address) +func (_ModelRegistry *ModelRegistryCallerSession) Token() (common.Address, error) { + return _ModelRegistry.Contract.Token(&_ModelRegistry.CallOpts) +} + +// Deregister is a paid mutator transaction binding the contract method 0x20813154. +// +// Solidity: function deregister(bytes32 id) returns() +func (_ModelRegistry *ModelRegistryTransactor) Deregister(opts *bind.TransactOpts, id [32]byte) (*types.Transaction, error) { + return _ModelRegistry.contract.Transact(opts, "deregister", id) +} + +// Deregister is a paid mutator transaction binding the contract method 0x20813154. +// +// Solidity: function deregister(bytes32 id) returns() +func (_ModelRegistry *ModelRegistrySession) Deregister(id [32]byte) (*types.Transaction, error) { + return _ModelRegistry.Contract.Deregister(&_ModelRegistry.TransactOpts, id) +} + +// Deregister is a paid mutator transaction binding the contract method 0x20813154. +// +// Solidity: function deregister(bytes32 id) returns() +func (_ModelRegistry *ModelRegistryTransactorSession) Deregister(id [32]byte) (*types.Transaction, error) { + return _ModelRegistry.Contract.Deregister(&_ModelRegistry.TransactOpts, id) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc4d66de8. +// +// Solidity: function initialize(address _token) returns() +func (_ModelRegistry *ModelRegistryTransactor) Initialize(opts *bind.TransactOpts, _token common.Address) (*types.Transaction, error) { + return _ModelRegistry.contract.Transact(opts, "initialize", _token) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc4d66de8. +// +// Solidity: function initialize(address _token) returns() +func (_ModelRegistry *ModelRegistrySession) Initialize(_token common.Address) (*types.Transaction, error) { + return _ModelRegistry.Contract.Initialize(&_ModelRegistry.TransactOpts, _token) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc4d66de8. +// +// Solidity: function initialize(address _token) returns() +func (_ModelRegistry *ModelRegistryTransactorSession) Initialize(_token common.Address) (*types.Transaction, error) { + return _ModelRegistry.Contract.Initialize(&_ModelRegistry.TransactOpts, _token) +} + +// Register is a paid mutator transaction binding the contract method 0x9e4aaa05. +// +// Solidity: function register(bytes32 modelId, bytes32 ipfsCID, uint256 fee, uint256 addStake, address owner, string name, string[] tags) returns() +func (_ModelRegistry *ModelRegistryTransactor) Register(opts *bind.TransactOpts, modelId [32]byte, ipfsCID [32]byte, fee *big.Int, addStake *big.Int, owner common.Address, name string, tags []string) (*types.Transaction, error) { + return _ModelRegistry.contract.Transact(opts, "register", modelId, ipfsCID, fee, addStake, owner, name, tags) +} + +// Register is a paid mutator transaction binding the contract method 0x9e4aaa05. +// +// Solidity: function register(bytes32 modelId, bytes32 ipfsCID, uint256 fee, uint256 addStake, address owner, string name, string[] tags) returns() +func (_ModelRegistry *ModelRegistrySession) Register(modelId [32]byte, ipfsCID [32]byte, fee *big.Int, addStake *big.Int, owner common.Address, name string, tags []string) (*types.Transaction, error) { + return _ModelRegistry.Contract.Register(&_ModelRegistry.TransactOpts, modelId, ipfsCID, fee, addStake, owner, name, tags) +} + +// Register is a paid mutator transaction binding the contract method 0x9e4aaa05. +// +// Solidity: function register(bytes32 modelId, bytes32 ipfsCID, uint256 fee, uint256 addStake, address owner, string name, string[] tags) returns() +func (_ModelRegistry *ModelRegistryTransactorSession) Register(modelId [32]byte, ipfsCID [32]byte, fee *big.Int, addStake *big.Int, owner common.Address, name string, tags []string) (*types.Transaction, error) { + return _ModelRegistry.Contract.Register(&_ModelRegistry.TransactOpts, modelId, ipfsCID, fee, addStake, owner, name, tags) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_ModelRegistry *ModelRegistryTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ModelRegistry.contract.Transact(opts, "renounceOwnership") +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_ModelRegistry *ModelRegistrySession) RenounceOwnership() (*types.Transaction, error) { + return _ModelRegistry.Contract.RenounceOwnership(&_ModelRegistry.TransactOpts) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_ModelRegistry *ModelRegistryTransactorSession) RenounceOwnership() (*types.Transaction, error) { + return _ModelRegistry.Contract.RenounceOwnership(&_ModelRegistry.TransactOpts) +} + +// SetMinStake is a paid mutator transaction binding the contract method 0x8c80fd90. +// +// Solidity: function setMinStake(uint256 _minStake) returns() +func (_ModelRegistry *ModelRegistryTransactor) SetMinStake(opts *bind.TransactOpts, _minStake *big.Int) (*types.Transaction, error) { + return _ModelRegistry.contract.Transact(opts, "setMinStake", _minStake) +} + +// SetMinStake is a paid mutator transaction binding the contract method 0x8c80fd90. +// +// Solidity: function setMinStake(uint256 _minStake) returns() +func (_ModelRegistry *ModelRegistrySession) SetMinStake(_minStake *big.Int) (*types.Transaction, error) { + return _ModelRegistry.Contract.SetMinStake(&_ModelRegistry.TransactOpts, _minStake) +} + +// SetMinStake is a paid mutator transaction binding the contract method 0x8c80fd90. +// +// Solidity: function setMinStake(uint256 _minStake) returns() +func (_ModelRegistry *ModelRegistryTransactorSession) SetMinStake(_minStake *big.Int) (*types.Transaction, error) { + return _ModelRegistry.Contract.SetMinStake(&_ModelRegistry.TransactOpts, _minStake) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_ModelRegistry *ModelRegistryTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) { + return _ModelRegistry.contract.Transact(opts, "transferOwnership", newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_ModelRegistry *ModelRegistrySession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _ModelRegistry.Contract.TransferOwnership(&_ModelRegistry.TransactOpts, newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_ModelRegistry *ModelRegistryTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _ModelRegistry.Contract.TransferOwnership(&_ModelRegistry.TransactOpts, newOwner) +} + +// ModelRegistryDeregisteredIterator is returned from FilterDeregistered and is used to iterate over the raw logs and unpacked data for Deregistered events raised by the ModelRegistry contract. +type ModelRegistryDeregisteredIterator struct { + Event *ModelRegistryDeregistered // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ModelRegistryDeregisteredIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ModelRegistryDeregistered) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ModelRegistryDeregistered) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ModelRegistryDeregisteredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ModelRegistryDeregisteredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ModelRegistryDeregistered represents a Deregistered event raised by the ModelRegistry contract. +type ModelRegistryDeregistered struct { + Owner common.Address + ModelId [32]byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterDeregistered is a free log retrieval operation binding the contract event 0xcc0d8d49cb9a5a3eebc1e1f0b607b8aad83fbe9618e448df79b8a0cc33319472. +// +// Solidity: event Deregistered(address indexed owner, bytes32 indexed modelId) +func (_ModelRegistry *ModelRegistryFilterer) FilterDeregistered(opts *bind.FilterOpts, owner []common.Address, modelId [][32]byte) (*ModelRegistryDeregisteredIterator, error) { + + var ownerRule []interface{} + for _, ownerItem := range owner { + ownerRule = append(ownerRule, ownerItem) + } + var modelIdRule []interface{} + for _, modelIdItem := range modelId { + modelIdRule = append(modelIdRule, modelIdItem) + } + + logs, sub, err := _ModelRegistry.contract.FilterLogs(opts, "Deregistered", ownerRule, modelIdRule) + if err != nil { + return nil, err + } + return &ModelRegistryDeregisteredIterator{contract: _ModelRegistry.contract, event: "Deregistered", logs: logs, sub: sub}, nil +} + +// WatchDeregistered is a free log subscription operation binding the contract event 0xcc0d8d49cb9a5a3eebc1e1f0b607b8aad83fbe9618e448df79b8a0cc33319472. +// +// Solidity: event Deregistered(address indexed owner, bytes32 indexed modelId) +func (_ModelRegistry *ModelRegistryFilterer) WatchDeregistered(opts *bind.WatchOpts, sink chan<- *ModelRegistryDeregistered, owner []common.Address, modelId [][32]byte) (event.Subscription, error) { + + var ownerRule []interface{} + for _, ownerItem := range owner { + ownerRule = append(ownerRule, ownerItem) + } + var modelIdRule []interface{} + for _, modelIdItem := range modelId { + modelIdRule = append(modelIdRule, modelIdItem) + } + + logs, sub, err := _ModelRegistry.contract.WatchLogs(opts, "Deregistered", ownerRule, modelIdRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ModelRegistryDeregistered) + if err := _ModelRegistry.contract.UnpackLog(event, "Deregistered", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseDeregistered is a log parse operation binding the contract event 0xcc0d8d49cb9a5a3eebc1e1f0b607b8aad83fbe9618e448df79b8a0cc33319472. +// +// Solidity: event Deregistered(address indexed owner, bytes32 indexed modelId) +func (_ModelRegistry *ModelRegistryFilterer) ParseDeregistered(log types.Log) (*ModelRegistryDeregistered, error) { + event := new(ModelRegistryDeregistered) + if err := _ModelRegistry.contract.UnpackLog(event, "Deregistered", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// ModelRegistryInitializedIterator is returned from FilterInitialized and is used to iterate over the raw logs and unpacked data for Initialized events raised by the ModelRegistry contract. +type ModelRegistryInitializedIterator struct { + Event *ModelRegistryInitialized // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ModelRegistryInitializedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ModelRegistryInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ModelRegistryInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ModelRegistryInitializedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ModelRegistryInitializedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ModelRegistryInitialized represents a Initialized event raised by the ModelRegistry contract. +type ModelRegistryInitialized struct { + Version uint8 + Raw types.Log // Blockchain specific contextual infos +} + +// FilterInitialized is a free log retrieval operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_ModelRegistry *ModelRegistryFilterer) FilterInitialized(opts *bind.FilterOpts) (*ModelRegistryInitializedIterator, error) { + + logs, sub, err := _ModelRegistry.contract.FilterLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return &ModelRegistryInitializedIterator{contract: _ModelRegistry.contract, event: "Initialized", logs: logs, sub: sub}, nil +} + +// WatchInitialized is a free log subscription operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_ModelRegistry *ModelRegistryFilterer) WatchInitialized(opts *bind.WatchOpts, sink chan<- *ModelRegistryInitialized) (event.Subscription, error) { + + logs, sub, err := _ModelRegistry.contract.WatchLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ModelRegistryInitialized) + if err := _ModelRegistry.contract.UnpackLog(event, "Initialized", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseInitialized is a log parse operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_ModelRegistry *ModelRegistryFilterer) ParseInitialized(log types.Log) (*ModelRegistryInitialized, error) { + event := new(ModelRegistryInitialized) + if err := _ModelRegistry.contract.UnpackLog(event, "Initialized", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// ModelRegistryMinStakeUpdatedIterator is returned from FilterMinStakeUpdated and is used to iterate over the raw logs and unpacked data for MinStakeUpdated events raised by the ModelRegistry contract. +type ModelRegistryMinStakeUpdatedIterator struct { + Event *ModelRegistryMinStakeUpdated // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ModelRegistryMinStakeUpdatedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ModelRegistryMinStakeUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ModelRegistryMinStakeUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ModelRegistryMinStakeUpdatedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ModelRegistryMinStakeUpdatedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ModelRegistryMinStakeUpdated represents a MinStakeUpdated event raised by the ModelRegistry contract. +type ModelRegistryMinStakeUpdated struct { + NewStake *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterMinStakeUpdated is a free log retrieval operation binding the contract event 0x47ab46f2c8d4258304a2f5551c1cbdb6981be49631365d1ba7191288a73f39ef. +// +// Solidity: event MinStakeUpdated(uint256 newStake) +func (_ModelRegistry *ModelRegistryFilterer) FilterMinStakeUpdated(opts *bind.FilterOpts) (*ModelRegistryMinStakeUpdatedIterator, error) { + + logs, sub, err := _ModelRegistry.contract.FilterLogs(opts, "MinStakeUpdated") + if err != nil { + return nil, err + } + return &ModelRegistryMinStakeUpdatedIterator{contract: _ModelRegistry.contract, event: "MinStakeUpdated", logs: logs, sub: sub}, nil +} + +// WatchMinStakeUpdated is a free log subscription operation binding the contract event 0x47ab46f2c8d4258304a2f5551c1cbdb6981be49631365d1ba7191288a73f39ef. +// +// Solidity: event MinStakeUpdated(uint256 newStake) +func (_ModelRegistry *ModelRegistryFilterer) WatchMinStakeUpdated(opts *bind.WatchOpts, sink chan<- *ModelRegistryMinStakeUpdated) (event.Subscription, error) { + + logs, sub, err := _ModelRegistry.contract.WatchLogs(opts, "MinStakeUpdated") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ModelRegistryMinStakeUpdated) + if err := _ModelRegistry.contract.UnpackLog(event, "MinStakeUpdated", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseMinStakeUpdated is a log parse operation binding the contract event 0x47ab46f2c8d4258304a2f5551c1cbdb6981be49631365d1ba7191288a73f39ef. +// +// Solidity: event MinStakeUpdated(uint256 newStake) +func (_ModelRegistry *ModelRegistryFilterer) ParseMinStakeUpdated(log types.Log) (*ModelRegistryMinStakeUpdated, error) { + event := new(ModelRegistryMinStakeUpdated) + if err := _ModelRegistry.contract.UnpackLog(event, "MinStakeUpdated", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// ModelRegistryOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the ModelRegistry contract. +type ModelRegistryOwnershipTransferredIterator struct { + Event *ModelRegistryOwnershipTransferred // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ModelRegistryOwnershipTransferredIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ModelRegistryOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ModelRegistryOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ModelRegistryOwnershipTransferredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ModelRegistryOwnershipTransferredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ModelRegistryOwnershipTransferred represents a OwnershipTransferred event raised by the ModelRegistry contract. +type ModelRegistryOwnershipTransferred struct { + PreviousOwner common.Address + NewOwner common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_ModelRegistry *ModelRegistryFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*ModelRegistryOwnershipTransferredIterator, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _ModelRegistry.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return &ModelRegistryOwnershipTransferredIterator{contract: _ModelRegistry.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil +} + +// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_ModelRegistry *ModelRegistryFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *ModelRegistryOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _ModelRegistry.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ModelRegistryOwnershipTransferred) + if err := _ModelRegistry.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_ModelRegistry *ModelRegistryFilterer) ParseOwnershipTransferred(log types.Log) (*ModelRegistryOwnershipTransferred, error) { + event := new(ModelRegistryOwnershipTransferred) + if err := _ModelRegistry.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// ModelRegistryRegisteredUpdatedIterator is returned from FilterRegisteredUpdated and is used to iterate over the raw logs and unpacked data for RegisteredUpdated events raised by the ModelRegistry contract. +type ModelRegistryRegisteredUpdatedIterator struct { + Event *ModelRegistryRegisteredUpdated // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ModelRegistryRegisteredUpdatedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ModelRegistryRegisteredUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ModelRegistryRegisteredUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ModelRegistryRegisteredUpdatedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ModelRegistryRegisteredUpdatedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ModelRegistryRegisteredUpdated represents a RegisteredUpdated event raised by the ModelRegistry contract. +type ModelRegistryRegisteredUpdated struct { + Owner common.Address + ModelId [32]byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterRegisteredUpdated is a free log retrieval operation binding the contract event 0x4dffc4e92367641816479c647d1ff3f03202f6c73b97340cba51a7b577c55804. +// +// Solidity: event RegisteredUpdated(address indexed owner, bytes32 indexed modelId) +func (_ModelRegistry *ModelRegistryFilterer) FilterRegisteredUpdated(opts *bind.FilterOpts, owner []common.Address, modelId [][32]byte) (*ModelRegistryRegisteredUpdatedIterator, error) { + + var ownerRule []interface{} + for _, ownerItem := range owner { + ownerRule = append(ownerRule, ownerItem) + } + var modelIdRule []interface{} + for _, modelIdItem := range modelId { + modelIdRule = append(modelIdRule, modelIdItem) + } + + logs, sub, err := _ModelRegistry.contract.FilterLogs(opts, "RegisteredUpdated", ownerRule, modelIdRule) + if err != nil { + return nil, err + } + return &ModelRegistryRegisteredUpdatedIterator{contract: _ModelRegistry.contract, event: "RegisteredUpdated", logs: logs, sub: sub}, nil +} + +// WatchRegisteredUpdated is a free log subscription operation binding the contract event 0x4dffc4e92367641816479c647d1ff3f03202f6c73b97340cba51a7b577c55804. +// +// Solidity: event RegisteredUpdated(address indexed owner, bytes32 indexed modelId) +func (_ModelRegistry *ModelRegistryFilterer) WatchRegisteredUpdated(opts *bind.WatchOpts, sink chan<- *ModelRegistryRegisteredUpdated, owner []common.Address, modelId [][32]byte) (event.Subscription, error) { + + var ownerRule []interface{} + for _, ownerItem := range owner { + ownerRule = append(ownerRule, ownerItem) + } + var modelIdRule []interface{} + for _, modelIdItem := range modelId { + modelIdRule = append(modelIdRule, modelIdItem) + } + + logs, sub, err := _ModelRegistry.contract.WatchLogs(opts, "RegisteredUpdated", ownerRule, modelIdRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ModelRegistryRegisteredUpdated) + if err := _ModelRegistry.contract.UnpackLog(event, "RegisteredUpdated", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseRegisteredUpdated is a log parse operation binding the contract event 0x4dffc4e92367641816479c647d1ff3f03202f6c73b97340cba51a7b577c55804. +// +// Solidity: event RegisteredUpdated(address indexed owner, bytes32 indexed modelId) +func (_ModelRegistry *ModelRegistryFilterer) ParseRegisteredUpdated(log types.Log) (*ModelRegistryRegisteredUpdated, error) { + event := new(ModelRegistryRegisteredUpdated) + if err := _ModelRegistry.contract.UnpackLog(event, "RegisteredUpdated", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/smart-contracts/bindings/go/contracts/morpheustoken/MorpheusToken.go b/smart-contracts/bindings/go/contracts/morpheustoken/MorpheusToken.go new file mode 100644 index 00000000..f51909ce --- /dev/null +++ b/smart-contracts/bindings/go/contracts/morpheustoken/MorpheusToken.go @@ -0,0 +1,738 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package morpheustoken + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// MorpheusTokenMetaData contains all meta data concerning the MorpheusToken contract. +var MorpheusTokenMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"allowance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"needed\",\"type\":\"uint256\"}],\"name\":\"ERC20InsufficientAllowance\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"balance\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"needed\",\"type\":\"uint256\"}],\"name\":\"ERC20InsufficientBalance\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"approver\",\"type\":\"address\"}],\"name\":\"ERC20InvalidApprover\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"}],\"name\":\"ERC20InvalidReceiver\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"ERC20InvalidSender\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"}],\"name\":\"ERC20InvalidSpender\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", +} + +// MorpheusTokenABI is the input ABI used to generate the binding from. +// Deprecated: Use MorpheusTokenMetaData.ABI instead. +var MorpheusTokenABI = MorpheusTokenMetaData.ABI + +// MorpheusToken is an auto generated Go binding around an Ethereum contract. +type MorpheusToken struct { + MorpheusTokenCaller // Read-only binding to the contract + MorpheusTokenTransactor // Write-only binding to the contract + MorpheusTokenFilterer // Log filterer for contract events +} + +// MorpheusTokenCaller is an auto generated read-only Go binding around an Ethereum contract. +type MorpheusTokenCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// MorpheusTokenTransactor is an auto generated write-only Go binding around an Ethereum contract. +type MorpheusTokenTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// MorpheusTokenFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type MorpheusTokenFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// MorpheusTokenSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type MorpheusTokenSession struct { + Contract *MorpheusToken // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// MorpheusTokenCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type MorpheusTokenCallerSession struct { + Contract *MorpheusTokenCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// MorpheusTokenTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type MorpheusTokenTransactorSession struct { + Contract *MorpheusTokenTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// MorpheusTokenRaw is an auto generated low-level Go binding around an Ethereum contract. +type MorpheusTokenRaw struct { + Contract *MorpheusToken // Generic contract binding to access the raw methods on +} + +// MorpheusTokenCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type MorpheusTokenCallerRaw struct { + Contract *MorpheusTokenCaller // Generic read-only contract binding to access the raw methods on +} + +// MorpheusTokenTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type MorpheusTokenTransactorRaw struct { + Contract *MorpheusTokenTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewMorpheusToken creates a new instance of MorpheusToken, bound to a specific deployed contract. +func NewMorpheusToken(address common.Address, backend bind.ContractBackend) (*MorpheusToken, error) { + contract, err := bindMorpheusToken(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &MorpheusToken{MorpheusTokenCaller: MorpheusTokenCaller{contract: contract}, MorpheusTokenTransactor: MorpheusTokenTransactor{contract: contract}, MorpheusTokenFilterer: MorpheusTokenFilterer{contract: contract}}, nil +} + +// NewMorpheusTokenCaller creates a new read-only instance of MorpheusToken, bound to a specific deployed contract. +func NewMorpheusTokenCaller(address common.Address, caller bind.ContractCaller) (*MorpheusTokenCaller, error) { + contract, err := bindMorpheusToken(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &MorpheusTokenCaller{contract: contract}, nil +} + +// NewMorpheusTokenTransactor creates a new write-only instance of MorpheusToken, bound to a specific deployed contract. +func NewMorpheusTokenTransactor(address common.Address, transactor bind.ContractTransactor) (*MorpheusTokenTransactor, error) { + contract, err := bindMorpheusToken(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &MorpheusTokenTransactor{contract: contract}, nil +} + +// NewMorpheusTokenFilterer creates a new log filterer instance of MorpheusToken, bound to a specific deployed contract. +func NewMorpheusTokenFilterer(address common.Address, filterer bind.ContractFilterer) (*MorpheusTokenFilterer, error) { + contract, err := bindMorpheusToken(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &MorpheusTokenFilterer{contract: contract}, nil +} + +// bindMorpheusToken binds a generic wrapper to an already deployed contract. +func bindMorpheusToken(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := MorpheusTokenMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_MorpheusToken *MorpheusTokenRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _MorpheusToken.Contract.MorpheusTokenCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_MorpheusToken *MorpheusTokenRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _MorpheusToken.Contract.MorpheusTokenTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_MorpheusToken *MorpheusTokenRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _MorpheusToken.Contract.MorpheusTokenTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_MorpheusToken *MorpheusTokenCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _MorpheusToken.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_MorpheusToken *MorpheusTokenTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _MorpheusToken.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_MorpheusToken *MorpheusTokenTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _MorpheusToken.Contract.contract.Transact(opts, method, params...) +} + +// Allowance is a free data retrieval call binding the contract method 0xdd62ed3e. +// +// Solidity: function allowance(address owner, address spender) view returns(uint256) +func (_MorpheusToken *MorpheusTokenCaller) Allowance(opts *bind.CallOpts, owner common.Address, spender common.Address) (*big.Int, error) { + var out []interface{} + err := _MorpheusToken.contract.Call(opts, &out, "allowance", owner, spender) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// Allowance is a free data retrieval call binding the contract method 0xdd62ed3e. +// +// Solidity: function allowance(address owner, address spender) view returns(uint256) +func (_MorpheusToken *MorpheusTokenSession) Allowance(owner common.Address, spender common.Address) (*big.Int, error) { + return _MorpheusToken.Contract.Allowance(&_MorpheusToken.CallOpts, owner, spender) +} + +// Allowance is a free data retrieval call binding the contract method 0xdd62ed3e. +// +// Solidity: function allowance(address owner, address spender) view returns(uint256) +func (_MorpheusToken *MorpheusTokenCallerSession) Allowance(owner common.Address, spender common.Address) (*big.Int, error) { + return _MorpheusToken.Contract.Allowance(&_MorpheusToken.CallOpts, owner, spender) +} + +// BalanceOf is a free data retrieval call binding the contract method 0x70a08231. +// +// Solidity: function balanceOf(address account) view returns(uint256) +func (_MorpheusToken *MorpheusTokenCaller) BalanceOf(opts *bind.CallOpts, account common.Address) (*big.Int, error) { + var out []interface{} + err := _MorpheusToken.contract.Call(opts, &out, "balanceOf", account) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// BalanceOf is a free data retrieval call binding the contract method 0x70a08231. +// +// Solidity: function balanceOf(address account) view returns(uint256) +func (_MorpheusToken *MorpheusTokenSession) BalanceOf(account common.Address) (*big.Int, error) { + return _MorpheusToken.Contract.BalanceOf(&_MorpheusToken.CallOpts, account) +} + +// BalanceOf is a free data retrieval call binding the contract method 0x70a08231. +// +// Solidity: function balanceOf(address account) view returns(uint256) +func (_MorpheusToken *MorpheusTokenCallerSession) BalanceOf(account common.Address) (*big.Int, error) { + return _MorpheusToken.Contract.BalanceOf(&_MorpheusToken.CallOpts, account) +} + +// Decimals is a free data retrieval call binding the contract method 0x313ce567. +// +// Solidity: function decimals() view returns(uint8) +func (_MorpheusToken *MorpheusTokenCaller) Decimals(opts *bind.CallOpts) (uint8, error) { + var out []interface{} + err := _MorpheusToken.contract.Call(opts, &out, "decimals") + + if err != nil { + return *new(uint8), err + } + + out0 := *abi.ConvertType(out[0], new(uint8)).(*uint8) + + return out0, err + +} + +// Decimals is a free data retrieval call binding the contract method 0x313ce567. +// +// Solidity: function decimals() view returns(uint8) +func (_MorpheusToken *MorpheusTokenSession) Decimals() (uint8, error) { + return _MorpheusToken.Contract.Decimals(&_MorpheusToken.CallOpts) +} + +// Decimals is a free data retrieval call binding the contract method 0x313ce567. +// +// Solidity: function decimals() view returns(uint8) +func (_MorpheusToken *MorpheusTokenCallerSession) Decimals() (uint8, error) { + return _MorpheusToken.Contract.Decimals(&_MorpheusToken.CallOpts) +} + +// Name is a free data retrieval call binding the contract method 0x06fdde03. +// +// Solidity: function name() view returns(string) +func (_MorpheusToken *MorpheusTokenCaller) Name(opts *bind.CallOpts) (string, error) { + var out []interface{} + err := _MorpheusToken.contract.Call(opts, &out, "name") + + if err != nil { + return *new(string), err + } + + out0 := *abi.ConvertType(out[0], new(string)).(*string) + + return out0, err + +} + +// Name is a free data retrieval call binding the contract method 0x06fdde03. +// +// Solidity: function name() view returns(string) +func (_MorpheusToken *MorpheusTokenSession) Name() (string, error) { + return _MorpheusToken.Contract.Name(&_MorpheusToken.CallOpts) +} + +// Name is a free data retrieval call binding the contract method 0x06fdde03. +// +// Solidity: function name() view returns(string) +func (_MorpheusToken *MorpheusTokenCallerSession) Name() (string, error) { + return _MorpheusToken.Contract.Name(&_MorpheusToken.CallOpts) +} + +// Symbol is a free data retrieval call binding the contract method 0x95d89b41. +// +// Solidity: function symbol() view returns(string) +func (_MorpheusToken *MorpheusTokenCaller) Symbol(opts *bind.CallOpts) (string, error) { + var out []interface{} + err := _MorpheusToken.contract.Call(opts, &out, "symbol") + + if err != nil { + return *new(string), err + } + + out0 := *abi.ConvertType(out[0], new(string)).(*string) + + return out0, err + +} + +// Symbol is a free data retrieval call binding the contract method 0x95d89b41. +// +// Solidity: function symbol() view returns(string) +func (_MorpheusToken *MorpheusTokenSession) Symbol() (string, error) { + return _MorpheusToken.Contract.Symbol(&_MorpheusToken.CallOpts) +} + +// Symbol is a free data retrieval call binding the contract method 0x95d89b41. +// +// Solidity: function symbol() view returns(string) +func (_MorpheusToken *MorpheusTokenCallerSession) Symbol() (string, error) { + return _MorpheusToken.Contract.Symbol(&_MorpheusToken.CallOpts) +} + +// TotalSupply is a free data retrieval call binding the contract method 0x18160ddd. +// +// Solidity: function totalSupply() view returns(uint256) +func (_MorpheusToken *MorpheusTokenCaller) TotalSupply(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _MorpheusToken.contract.Call(opts, &out, "totalSupply") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// TotalSupply is a free data retrieval call binding the contract method 0x18160ddd. +// +// Solidity: function totalSupply() view returns(uint256) +func (_MorpheusToken *MorpheusTokenSession) TotalSupply() (*big.Int, error) { + return _MorpheusToken.Contract.TotalSupply(&_MorpheusToken.CallOpts) +} + +// TotalSupply is a free data retrieval call binding the contract method 0x18160ddd. +// +// Solidity: function totalSupply() view returns(uint256) +func (_MorpheusToken *MorpheusTokenCallerSession) TotalSupply() (*big.Int, error) { + return _MorpheusToken.Contract.TotalSupply(&_MorpheusToken.CallOpts) +} + +// Approve is a paid mutator transaction binding the contract method 0x095ea7b3. +// +// Solidity: function approve(address spender, uint256 value) returns(bool) +func (_MorpheusToken *MorpheusTokenTransactor) Approve(opts *bind.TransactOpts, spender common.Address, value *big.Int) (*types.Transaction, error) { + return _MorpheusToken.contract.Transact(opts, "approve", spender, value) +} + +// Approve is a paid mutator transaction binding the contract method 0x095ea7b3. +// +// Solidity: function approve(address spender, uint256 value) returns(bool) +func (_MorpheusToken *MorpheusTokenSession) Approve(spender common.Address, value *big.Int) (*types.Transaction, error) { + return _MorpheusToken.Contract.Approve(&_MorpheusToken.TransactOpts, spender, value) +} + +// Approve is a paid mutator transaction binding the contract method 0x095ea7b3. +// +// Solidity: function approve(address spender, uint256 value) returns(bool) +func (_MorpheusToken *MorpheusTokenTransactorSession) Approve(spender common.Address, value *big.Int) (*types.Transaction, error) { + return _MorpheusToken.Contract.Approve(&_MorpheusToken.TransactOpts, spender, value) +} + +// Transfer is a paid mutator transaction binding the contract method 0xa9059cbb. +// +// Solidity: function transfer(address to, uint256 value) returns(bool) +func (_MorpheusToken *MorpheusTokenTransactor) Transfer(opts *bind.TransactOpts, to common.Address, value *big.Int) (*types.Transaction, error) { + return _MorpheusToken.contract.Transact(opts, "transfer", to, value) +} + +// Transfer is a paid mutator transaction binding the contract method 0xa9059cbb. +// +// Solidity: function transfer(address to, uint256 value) returns(bool) +func (_MorpheusToken *MorpheusTokenSession) Transfer(to common.Address, value *big.Int) (*types.Transaction, error) { + return _MorpheusToken.Contract.Transfer(&_MorpheusToken.TransactOpts, to, value) +} + +// Transfer is a paid mutator transaction binding the contract method 0xa9059cbb. +// +// Solidity: function transfer(address to, uint256 value) returns(bool) +func (_MorpheusToken *MorpheusTokenTransactorSession) Transfer(to common.Address, value *big.Int) (*types.Transaction, error) { + return _MorpheusToken.Contract.Transfer(&_MorpheusToken.TransactOpts, to, value) +} + +// TransferFrom is a paid mutator transaction binding the contract method 0x23b872dd. +// +// Solidity: function transferFrom(address from, address to, uint256 value) returns(bool) +func (_MorpheusToken *MorpheusTokenTransactor) TransferFrom(opts *bind.TransactOpts, from common.Address, to common.Address, value *big.Int) (*types.Transaction, error) { + return _MorpheusToken.contract.Transact(opts, "transferFrom", from, to, value) +} + +// TransferFrom is a paid mutator transaction binding the contract method 0x23b872dd. +// +// Solidity: function transferFrom(address from, address to, uint256 value) returns(bool) +func (_MorpheusToken *MorpheusTokenSession) TransferFrom(from common.Address, to common.Address, value *big.Int) (*types.Transaction, error) { + return _MorpheusToken.Contract.TransferFrom(&_MorpheusToken.TransactOpts, from, to, value) +} + +// TransferFrom is a paid mutator transaction binding the contract method 0x23b872dd. +// +// Solidity: function transferFrom(address from, address to, uint256 value) returns(bool) +func (_MorpheusToken *MorpheusTokenTransactorSession) TransferFrom(from common.Address, to common.Address, value *big.Int) (*types.Transaction, error) { + return _MorpheusToken.Contract.TransferFrom(&_MorpheusToken.TransactOpts, from, to, value) +} + +// MorpheusTokenApprovalIterator is returned from FilterApproval and is used to iterate over the raw logs and unpacked data for Approval events raised by the MorpheusToken contract. +type MorpheusTokenApprovalIterator struct { + Event *MorpheusTokenApproval // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *MorpheusTokenApprovalIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(MorpheusTokenApproval) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(MorpheusTokenApproval) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *MorpheusTokenApprovalIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *MorpheusTokenApprovalIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// MorpheusTokenApproval represents a Approval event raised by the MorpheusToken contract. +type MorpheusTokenApproval struct { + Owner common.Address + Spender common.Address + Value *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterApproval is a free log retrieval operation binding the contract event 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925. +// +// Solidity: event Approval(address indexed owner, address indexed spender, uint256 value) +func (_MorpheusToken *MorpheusTokenFilterer) FilterApproval(opts *bind.FilterOpts, owner []common.Address, spender []common.Address) (*MorpheusTokenApprovalIterator, error) { + + var ownerRule []interface{} + for _, ownerItem := range owner { + ownerRule = append(ownerRule, ownerItem) + } + var spenderRule []interface{} + for _, spenderItem := range spender { + spenderRule = append(spenderRule, spenderItem) + } + + logs, sub, err := _MorpheusToken.contract.FilterLogs(opts, "Approval", ownerRule, spenderRule) + if err != nil { + return nil, err + } + return &MorpheusTokenApprovalIterator{contract: _MorpheusToken.contract, event: "Approval", logs: logs, sub: sub}, nil +} + +// WatchApproval is a free log subscription operation binding the contract event 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925. +// +// Solidity: event Approval(address indexed owner, address indexed spender, uint256 value) +func (_MorpheusToken *MorpheusTokenFilterer) WatchApproval(opts *bind.WatchOpts, sink chan<- *MorpheusTokenApproval, owner []common.Address, spender []common.Address) (event.Subscription, error) { + + var ownerRule []interface{} + for _, ownerItem := range owner { + ownerRule = append(ownerRule, ownerItem) + } + var spenderRule []interface{} + for _, spenderItem := range spender { + spenderRule = append(spenderRule, spenderItem) + } + + logs, sub, err := _MorpheusToken.contract.WatchLogs(opts, "Approval", ownerRule, spenderRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(MorpheusTokenApproval) + if err := _MorpheusToken.contract.UnpackLog(event, "Approval", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseApproval is a log parse operation binding the contract event 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925. +// +// Solidity: event Approval(address indexed owner, address indexed spender, uint256 value) +func (_MorpheusToken *MorpheusTokenFilterer) ParseApproval(log types.Log) (*MorpheusTokenApproval, error) { + event := new(MorpheusTokenApproval) + if err := _MorpheusToken.contract.UnpackLog(event, "Approval", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// MorpheusTokenTransferIterator is returned from FilterTransfer and is used to iterate over the raw logs and unpacked data for Transfer events raised by the MorpheusToken contract. +type MorpheusTokenTransferIterator struct { + Event *MorpheusTokenTransfer // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *MorpheusTokenTransferIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(MorpheusTokenTransfer) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(MorpheusTokenTransfer) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *MorpheusTokenTransferIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *MorpheusTokenTransferIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// MorpheusTokenTransfer represents a Transfer event raised by the MorpheusToken contract. +type MorpheusTokenTransfer struct { + From common.Address + To common.Address + Value *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterTransfer is a free log retrieval operation binding the contract event 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef. +// +// Solidity: event Transfer(address indexed from, address indexed to, uint256 value) +func (_MorpheusToken *MorpheusTokenFilterer) FilterTransfer(opts *bind.FilterOpts, from []common.Address, to []common.Address) (*MorpheusTokenTransferIterator, error) { + + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _MorpheusToken.contract.FilterLogs(opts, "Transfer", fromRule, toRule) + if err != nil { + return nil, err + } + return &MorpheusTokenTransferIterator{contract: _MorpheusToken.contract, event: "Transfer", logs: logs, sub: sub}, nil +} + +// WatchTransfer is a free log subscription operation binding the contract event 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef. +// +// Solidity: event Transfer(address indexed from, address indexed to, uint256 value) +func (_MorpheusToken *MorpheusTokenFilterer) WatchTransfer(opts *bind.WatchOpts, sink chan<- *MorpheusTokenTransfer, from []common.Address, to []common.Address) (event.Subscription, error) { + + var fromRule []interface{} + for _, fromItem := range from { + fromRule = append(fromRule, fromItem) + } + var toRule []interface{} + for _, toItem := range to { + toRule = append(toRule, toItem) + } + + logs, sub, err := _MorpheusToken.contract.WatchLogs(opts, "Transfer", fromRule, toRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(MorpheusTokenTransfer) + if err := _MorpheusToken.contract.UnpackLog(event, "Transfer", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseTransfer is a log parse operation binding the contract event 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef. +// +// Solidity: event Transfer(address indexed from, address indexed to, uint256 value) +func (_MorpheusToken *MorpheusTokenFilterer) ParseTransfer(log types.Log) (*MorpheusTokenTransfer, error) { + event := new(MorpheusTokenTransfer) + if err := _MorpheusToken.contract.UnpackLog(event, "Transfer", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/smart-contracts/bindings/go/contracts/providerregistry/ProviderRegistry.go b/smart-contracts/bindings/go/contracts/providerregistry/ProviderRegistry.go new file mode 100644 index 00000000..8afa5ffa --- /dev/null +++ b/smart-contracts/bindings/go/contracts/providerregistry/ProviderRegistry.go @@ -0,0 +1,1373 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package providerregistry + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// ProviderRegistryProvider is an auto generated low-level Go binding around an user-defined struct. +type ProviderRegistryProvider struct { + Endpoint string + Stake *big.Int + Timestamp *big.Int + IsDeleted bool +} + +// ProviderRegistryMetaData contains all meta data concerning the ProviderRegistry contract. +var ProviderRegistryMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[],\"name\":\"KeyExists\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"KeyNotFound\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotSenderOrOwner\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"StakeTooLow\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"ZeroKey\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"}],\"name\":\"Deregistered\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"newStake\",\"type\":\"uint256\"}],\"name\":\"MinStakeUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"}],\"name\":\"RegisteredUpdated\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"deregister\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"exists\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getAll\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"endpoint\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"stake\",\"type\":\"uint256\"},{\"internalType\":\"uint128\",\"name\":\"timestamp\",\"type\":\"uint128\"},{\"internalType\":\"bool\",\"name\":\"isDeleted\",\"type\":\"bool\"}],\"internalType\":\"structProviderRegistry.Provider[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getByIndex\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"components\":[{\"internalType\":\"string\",\"name\":\"endpoint\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"stake\",\"type\":\"uint256\"},{\"internalType\":\"uint128\",\"name\":\"timestamp\",\"type\":\"uint128\"},{\"internalType\":\"bool\",\"name\":\"isDeleted\",\"type\":\"bool\"}],\"internalType\":\"structProviderRegistry.Provider\",\"name\":\"provider\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"count\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getIds\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"map\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"endpoint\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"stake\",\"type\":\"uint256\"},{\"internalType\":\"uint128\",\"name\":\"timestamp\",\"type\":\"uint128\"},{\"internalType\":\"bool\",\"name\":\"isDeleted\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minStake\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"providers\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"addStake\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"endpoint\",\"type\":\"string\"}],\"name\":\"register\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_minStake\",\"type\":\"uint256\"}],\"name\":\"setMinStake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"token\",\"outputs\":[{\"internalType\":\"contractERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", +} + +// ProviderRegistryABI is the input ABI used to generate the binding from. +// Deprecated: Use ProviderRegistryMetaData.ABI instead. +var ProviderRegistryABI = ProviderRegistryMetaData.ABI + +// ProviderRegistry is an auto generated Go binding around an Ethereum contract. +type ProviderRegistry struct { + ProviderRegistryCaller // Read-only binding to the contract + ProviderRegistryTransactor // Write-only binding to the contract + ProviderRegistryFilterer // Log filterer for contract events +} + +// ProviderRegistryCaller is an auto generated read-only Go binding around an Ethereum contract. +type ProviderRegistryCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ProviderRegistryTransactor is an auto generated write-only Go binding around an Ethereum contract. +type ProviderRegistryTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ProviderRegistryFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type ProviderRegistryFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// ProviderRegistrySession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type ProviderRegistrySession struct { + Contract *ProviderRegistry // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// ProviderRegistryCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type ProviderRegistryCallerSession struct { + Contract *ProviderRegistryCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// ProviderRegistryTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type ProviderRegistryTransactorSession struct { + Contract *ProviderRegistryTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// ProviderRegistryRaw is an auto generated low-level Go binding around an Ethereum contract. +type ProviderRegistryRaw struct { + Contract *ProviderRegistry // Generic contract binding to access the raw methods on +} + +// ProviderRegistryCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type ProviderRegistryCallerRaw struct { + Contract *ProviderRegistryCaller // Generic read-only contract binding to access the raw methods on +} + +// ProviderRegistryTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type ProviderRegistryTransactorRaw struct { + Contract *ProviderRegistryTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewProviderRegistry creates a new instance of ProviderRegistry, bound to a specific deployed contract. +func NewProviderRegistry(address common.Address, backend bind.ContractBackend) (*ProviderRegistry, error) { + contract, err := bindProviderRegistry(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &ProviderRegistry{ProviderRegistryCaller: ProviderRegistryCaller{contract: contract}, ProviderRegistryTransactor: ProviderRegistryTransactor{contract: contract}, ProviderRegistryFilterer: ProviderRegistryFilterer{contract: contract}}, nil +} + +// NewProviderRegistryCaller creates a new read-only instance of ProviderRegistry, bound to a specific deployed contract. +func NewProviderRegistryCaller(address common.Address, caller bind.ContractCaller) (*ProviderRegistryCaller, error) { + contract, err := bindProviderRegistry(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &ProviderRegistryCaller{contract: contract}, nil +} + +// NewProviderRegistryTransactor creates a new write-only instance of ProviderRegistry, bound to a specific deployed contract. +func NewProviderRegistryTransactor(address common.Address, transactor bind.ContractTransactor) (*ProviderRegistryTransactor, error) { + contract, err := bindProviderRegistry(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &ProviderRegistryTransactor{contract: contract}, nil +} + +// NewProviderRegistryFilterer creates a new log filterer instance of ProviderRegistry, bound to a specific deployed contract. +func NewProviderRegistryFilterer(address common.Address, filterer bind.ContractFilterer) (*ProviderRegistryFilterer, error) { + contract, err := bindProviderRegistry(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &ProviderRegistryFilterer{contract: contract}, nil +} + +// bindProviderRegistry binds a generic wrapper to an already deployed contract. +func bindProviderRegistry(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := ProviderRegistryMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_ProviderRegistry *ProviderRegistryRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _ProviderRegistry.Contract.ProviderRegistryCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_ProviderRegistry *ProviderRegistryRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ProviderRegistry.Contract.ProviderRegistryTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_ProviderRegistry *ProviderRegistryRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _ProviderRegistry.Contract.ProviderRegistryTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_ProviderRegistry *ProviderRegistryCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _ProviderRegistry.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_ProviderRegistry *ProviderRegistryTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ProviderRegistry.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_ProviderRegistry *ProviderRegistryTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _ProviderRegistry.Contract.contract.Transact(opts, method, params...) +} + +// Exists is a free data retrieval call binding the contract method 0xf6a3d24e. +// +// Solidity: function exists(address addr) view returns(bool) +func (_ProviderRegistry *ProviderRegistryCaller) Exists(opts *bind.CallOpts, addr common.Address) (bool, error) { + var out []interface{} + err := _ProviderRegistry.contract.Call(opts, &out, "exists", addr) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// Exists is a free data retrieval call binding the contract method 0xf6a3d24e. +// +// Solidity: function exists(address addr) view returns(bool) +func (_ProviderRegistry *ProviderRegistrySession) Exists(addr common.Address) (bool, error) { + return _ProviderRegistry.Contract.Exists(&_ProviderRegistry.CallOpts, addr) +} + +// Exists is a free data retrieval call binding the contract method 0xf6a3d24e. +// +// Solidity: function exists(address addr) view returns(bool) +func (_ProviderRegistry *ProviderRegistryCallerSession) Exists(addr common.Address) (bool, error) { + return _ProviderRegistry.Contract.Exists(&_ProviderRegistry.CallOpts, addr) +} + +// GetAll is a free data retrieval call binding the contract method 0x53ed5143. +// +// Solidity: function getAll() view returns(address[], (string,uint256,uint128,bool)[]) +func (_ProviderRegistry *ProviderRegistryCaller) GetAll(opts *bind.CallOpts) ([]common.Address, []ProviderRegistryProvider, error) { + var out []interface{} + err := _ProviderRegistry.contract.Call(opts, &out, "getAll") + + if err != nil { + return *new([]common.Address), *new([]ProviderRegistryProvider), err + } + + out0 := *abi.ConvertType(out[0], new([]common.Address)).(*[]common.Address) + out1 := *abi.ConvertType(out[1], new([]ProviderRegistryProvider)).(*[]ProviderRegistryProvider) + + return out0, out1, err + +} + +// GetAll is a free data retrieval call binding the contract method 0x53ed5143. +// +// Solidity: function getAll() view returns(address[], (string,uint256,uint128,bool)[]) +func (_ProviderRegistry *ProviderRegistrySession) GetAll() ([]common.Address, []ProviderRegistryProvider, error) { + return _ProviderRegistry.Contract.GetAll(&_ProviderRegistry.CallOpts) +} + +// GetAll is a free data retrieval call binding the contract method 0x53ed5143. +// +// Solidity: function getAll() view returns(address[], (string,uint256,uint128,bool)[]) +func (_ProviderRegistry *ProviderRegistryCallerSession) GetAll() ([]common.Address, []ProviderRegistryProvider, error) { + return _ProviderRegistry.Contract.GetAll(&_ProviderRegistry.CallOpts) +} + +// GetByIndex is a free data retrieval call binding the contract method 0x2d883a73. +// +// Solidity: function getByIndex(uint256 index) view returns(address addr, (string,uint256,uint128,bool) provider) +func (_ProviderRegistry *ProviderRegistryCaller) GetByIndex(opts *bind.CallOpts, index *big.Int) (struct { + Addr common.Address + Provider ProviderRegistryProvider +}, error) { + var out []interface{} + err := _ProviderRegistry.contract.Call(opts, &out, "getByIndex", index) + + outstruct := new(struct { + Addr common.Address + Provider ProviderRegistryProvider + }) + if err != nil { + return *outstruct, err + } + + outstruct.Addr = *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + outstruct.Provider = *abi.ConvertType(out[1], new(ProviderRegistryProvider)).(*ProviderRegistryProvider) + + return *outstruct, err + +} + +// GetByIndex is a free data retrieval call binding the contract method 0x2d883a73. +// +// Solidity: function getByIndex(uint256 index) view returns(address addr, (string,uint256,uint128,bool) provider) +func (_ProviderRegistry *ProviderRegistrySession) GetByIndex(index *big.Int) (struct { + Addr common.Address + Provider ProviderRegistryProvider +}, error) { + return _ProviderRegistry.Contract.GetByIndex(&_ProviderRegistry.CallOpts, index) +} + +// GetByIndex is a free data retrieval call binding the contract method 0x2d883a73. +// +// Solidity: function getByIndex(uint256 index) view returns(address addr, (string,uint256,uint128,bool) provider) +func (_ProviderRegistry *ProviderRegistryCallerSession) GetByIndex(index *big.Int) (struct { + Addr common.Address + Provider ProviderRegistryProvider +}, error) { + return _ProviderRegistry.Contract.GetByIndex(&_ProviderRegistry.CallOpts, index) +} + +// GetCount is a free data retrieval call binding the contract method 0xa87d942c. +// +// Solidity: function getCount() view returns(uint256 count) +func (_ProviderRegistry *ProviderRegistryCaller) GetCount(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _ProviderRegistry.contract.Call(opts, &out, "getCount") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetCount is a free data retrieval call binding the contract method 0xa87d942c. +// +// Solidity: function getCount() view returns(uint256 count) +func (_ProviderRegistry *ProviderRegistrySession) GetCount() (*big.Int, error) { + return _ProviderRegistry.Contract.GetCount(&_ProviderRegistry.CallOpts) +} + +// GetCount is a free data retrieval call binding the contract method 0xa87d942c. +// +// Solidity: function getCount() view returns(uint256 count) +func (_ProviderRegistry *ProviderRegistryCallerSession) GetCount() (*big.Int, error) { + return _ProviderRegistry.Contract.GetCount(&_ProviderRegistry.CallOpts) +} + +// GetIds is a free data retrieval call binding the contract method 0x2b105663. +// +// Solidity: function getIds() view returns(address[]) +func (_ProviderRegistry *ProviderRegistryCaller) GetIds(opts *bind.CallOpts) ([]common.Address, error) { + var out []interface{} + err := _ProviderRegistry.contract.Call(opts, &out, "getIds") + + if err != nil { + return *new([]common.Address), err + } + + out0 := *abi.ConvertType(out[0], new([]common.Address)).(*[]common.Address) + + return out0, err + +} + +// GetIds is a free data retrieval call binding the contract method 0x2b105663. +// +// Solidity: function getIds() view returns(address[]) +func (_ProviderRegistry *ProviderRegistrySession) GetIds() ([]common.Address, error) { + return _ProviderRegistry.Contract.GetIds(&_ProviderRegistry.CallOpts) +} + +// GetIds is a free data retrieval call binding the contract method 0x2b105663. +// +// Solidity: function getIds() view returns(address[]) +func (_ProviderRegistry *ProviderRegistryCallerSession) GetIds() ([]common.Address, error) { + return _ProviderRegistry.Contract.GetIds(&_ProviderRegistry.CallOpts) +} + +// Map is a free data retrieval call binding the contract method 0xb721ef6e. +// +// Solidity: function map(address ) view returns(string endpoint, uint256 stake, uint128 timestamp, bool isDeleted) +func (_ProviderRegistry *ProviderRegistryCaller) Map(opts *bind.CallOpts, arg0 common.Address) (struct { + Endpoint string + Stake *big.Int + Timestamp *big.Int + IsDeleted bool +}, error) { + var out []interface{} + err := _ProviderRegistry.contract.Call(opts, &out, "map", arg0) + + outstruct := new(struct { + Endpoint string + Stake *big.Int + Timestamp *big.Int + IsDeleted bool + }) + if err != nil { + return *outstruct, err + } + + outstruct.Endpoint = *abi.ConvertType(out[0], new(string)).(*string) + outstruct.Stake = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) + outstruct.Timestamp = *abi.ConvertType(out[2], new(*big.Int)).(**big.Int) + outstruct.IsDeleted = *abi.ConvertType(out[3], new(bool)).(*bool) + + return *outstruct, err + +} + +// Map is a free data retrieval call binding the contract method 0xb721ef6e. +// +// Solidity: function map(address ) view returns(string endpoint, uint256 stake, uint128 timestamp, bool isDeleted) +func (_ProviderRegistry *ProviderRegistrySession) Map(arg0 common.Address) (struct { + Endpoint string + Stake *big.Int + Timestamp *big.Int + IsDeleted bool +}, error) { + return _ProviderRegistry.Contract.Map(&_ProviderRegistry.CallOpts, arg0) +} + +// Map is a free data retrieval call binding the contract method 0xb721ef6e. +// +// Solidity: function map(address ) view returns(string endpoint, uint256 stake, uint128 timestamp, bool isDeleted) +func (_ProviderRegistry *ProviderRegistryCallerSession) Map(arg0 common.Address) (struct { + Endpoint string + Stake *big.Int + Timestamp *big.Int + IsDeleted bool +}, error) { + return _ProviderRegistry.Contract.Map(&_ProviderRegistry.CallOpts, arg0) +} + +// MinStake is a free data retrieval call binding the contract method 0x375b3c0a. +// +// Solidity: function minStake() view returns(uint256) +func (_ProviderRegistry *ProviderRegistryCaller) MinStake(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _ProviderRegistry.contract.Call(opts, &out, "minStake") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// MinStake is a free data retrieval call binding the contract method 0x375b3c0a. +// +// Solidity: function minStake() view returns(uint256) +func (_ProviderRegistry *ProviderRegistrySession) MinStake() (*big.Int, error) { + return _ProviderRegistry.Contract.MinStake(&_ProviderRegistry.CallOpts) +} + +// MinStake is a free data retrieval call binding the contract method 0x375b3c0a. +// +// Solidity: function minStake() view returns(uint256) +func (_ProviderRegistry *ProviderRegistryCallerSession) MinStake() (*big.Int, error) { + return _ProviderRegistry.Contract.MinStake(&_ProviderRegistry.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_ProviderRegistry *ProviderRegistryCaller) Owner(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _ProviderRegistry.contract.Call(opts, &out, "owner") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_ProviderRegistry *ProviderRegistrySession) Owner() (common.Address, error) { + return _ProviderRegistry.Contract.Owner(&_ProviderRegistry.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_ProviderRegistry *ProviderRegistryCallerSession) Owner() (common.Address, error) { + return _ProviderRegistry.Contract.Owner(&_ProviderRegistry.CallOpts) +} + +// Providers is a free data retrieval call binding the contract method 0x50f3fc81. +// +// Solidity: function providers(uint256 ) view returns(address) +func (_ProviderRegistry *ProviderRegistryCaller) Providers(opts *bind.CallOpts, arg0 *big.Int) (common.Address, error) { + var out []interface{} + err := _ProviderRegistry.contract.Call(opts, &out, "providers", arg0) + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Providers is a free data retrieval call binding the contract method 0x50f3fc81. +// +// Solidity: function providers(uint256 ) view returns(address) +func (_ProviderRegistry *ProviderRegistrySession) Providers(arg0 *big.Int) (common.Address, error) { + return _ProviderRegistry.Contract.Providers(&_ProviderRegistry.CallOpts, arg0) +} + +// Providers is a free data retrieval call binding the contract method 0x50f3fc81. +// +// Solidity: function providers(uint256 ) view returns(address) +func (_ProviderRegistry *ProviderRegistryCallerSession) Providers(arg0 *big.Int) (common.Address, error) { + return _ProviderRegistry.Contract.Providers(&_ProviderRegistry.CallOpts, arg0) +} + +// Token is a free data retrieval call binding the contract method 0xfc0c546a. +// +// Solidity: function token() view returns(address) +func (_ProviderRegistry *ProviderRegistryCaller) Token(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _ProviderRegistry.contract.Call(opts, &out, "token") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Token is a free data retrieval call binding the contract method 0xfc0c546a. +// +// Solidity: function token() view returns(address) +func (_ProviderRegistry *ProviderRegistrySession) Token() (common.Address, error) { + return _ProviderRegistry.Contract.Token(&_ProviderRegistry.CallOpts) +} + +// Token is a free data retrieval call binding the contract method 0xfc0c546a. +// +// Solidity: function token() view returns(address) +func (_ProviderRegistry *ProviderRegistryCallerSession) Token() (common.Address, error) { + return _ProviderRegistry.Contract.Token(&_ProviderRegistry.CallOpts) +} + +// Deregister is a paid mutator transaction binding the contract method 0x84ac33ec. +// +// Solidity: function deregister(address addr) returns() +func (_ProviderRegistry *ProviderRegistryTransactor) Deregister(opts *bind.TransactOpts, addr common.Address) (*types.Transaction, error) { + return _ProviderRegistry.contract.Transact(opts, "deregister", addr) +} + +// Deregister is a paid mutator transaction binding the contract method 0x84ac33ec. +// +// Solidity: function deregister(address addr) returns() +func (_ProviderRegistry *ProviderRegistrySession) Deregister(addr common.Address) (*types.Transaction, error) { + return _ProviderRegistry.Contract.Deregister(&_ProviderRegistry.TransactOpts, addr) +} + +// Deregister is a paid mutator transaction binding the contract method 0x84ac33ec. +// +// Solidity: function deregister(address addr) returns() +func (_ProviderRegistry *ProviderRegistryTransactorSession) Deregister(addr common.Address) (*types.Transaction, error) { + return _ProviderRegistry.Contract.Deregister(&_ProviderRegistry.TransactOpts, addr) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc4d66de8. +// +// Solidity: function initialize(address _token) returns() +func (_ProviderRegistry *ProviderRegistryTransactor) Initialize(opts *bind.TransactOpts, _token common.Address) (*types.Transaction, error) { + return _ProviderRegistry.contract.Transact(opts, "initialize", _token) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc4d66de8. +// +// Solidity: function initialize(address _token) returns() +func (_ProviderRegistry *ProviderRegistrySession) Initialize(_token common.Address) (*types.Transaction, error) { + return _ProviderRegistry.Contract.Initialize(&_ProviderRegistry.TransactOpts, _token) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc4d66de8. +// +// Solidity: function initialize(address _token) returns() +func (_ProviderRegistry *ProviderRegistryTransactorSession) Initialize(_token common.Address) (*types.Transaction, error) { + return _ProviderRegistry.Contract.Initialize(&_ProviderRegistry.TransactOpts, _token) +} + +// Register is a paid mutator transaction binding the contract method 0xf11b1b88. +// +// Solidity: function register(address addr, uint256 addStake, string endpoint) returns() +func (_ProviderRegistry *ProviderRegistryTransactor) Register(opts *bind.TransactOpts, addr common.Address, addStake *big.Int, endpoint string) (*types.Transaction, error) { + return _ProviderRegistry.contract.Transact(opts, "register", addr, addStake, endpoint) +} + +// Register is a paid mutator transaction binding the contract method 0xf11b1b88. +// +// Solidity: function register(address addr, uint256 addStake, string endpoint) returns() +func (_ProviderRegistry *ProviderRegistrySession) Register(addr common.Address, addStake *big.Int, endpoint string) (*types.Transaction, error) { + return _ProviderRegistry.Contract.Register(&_ProviderRegistry.TransactOpts, addr, addStake, endpoint) +} + +// Register is a paid mutator transaction binding the contract method 0xf11b1b88. +// +// Solidity: function register(address addr, uint256 addStake, string endpoint) returns() +func (_ProviderRegistry *ProviderRegistryTransactorSession) Register(addr common.Address, addStake *big.Int, endpoint string) (*types.Transaction, error) { + return _ProviderRegistry.Contract.Register(&_ProviderRegistry.TransactOpts, addr, addStake, endpoint) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_ProviderRegistry *ProviderRegistryTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { + return _ProviderRegistry.contract.Transact(opts, "renounceOwnership") +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_ProviderRegistry *ProviderRegistrySession) RenounceOwnership() (*types.Transaction, error) { + return _ProviderRegistry.Contract.RenounceOwnership(&_ProviderRegistry.TransactOpts) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_ProviderRegistry *ProviderRegistryTransactorSession) RenounceOwnership() (*types.Transaction, error) { + return _ProviderRegistry.Contract.RenounceOwnership(&_ProviderRegistry.TransactOpts) +} + +// SetMinStake is a paid mutator transaction binding the contract method 0x8c80fd90. +// +// Solidity: function setMinStake(uint256 _minStake) returns() +func (_ProviderRegistry *ProviderRegistryTransactor) SetMinStake(opts *bind.TransactOpts, _minStake *big.Int) (*types.Transaction, error) { + return _ProviderRegistry.contract.Transact(opts, "setMinStake", _minStake) +} + +// SetMinStake is a paid mutator transaction binding the contract method 0x8c80fd90. +// +// Solidity: function setMinStake(uint256 _minStake) returns() +func (_ProviderRegistry *ProviderRegistrySession) SetMinStake(_minStake *big.Int) (*types.Transaction, error) { + return _ProviderRegistry.Contract.SetMinStake(&_ProviderRegistry.TransactOpts, _minStake) +} + +// SetMinStake is a paid mutator transaction binding the contract method 0x8c80fd90. +// +// Solidity: function setMinStake(uint256 _minStake) returns() +func (_ProviderRegistry *ProviderRegistryTransactorSession) SetMinStake(_minStake *big.Int) (*types.Transaction, error) { + return _ProviderRegistry.Contract.SetMinStake(&_ProviderRegistry.TransactOpts, _minStake) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_ProviderRegistry *ProviderRegistryTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) { + return _ProviderRegistry.contract.Transact(opts, "transferOwnership", newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_ProviderRegistry *ProviderRegistrySession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _ProviderRegistry.Contract.TransferOwnership(&_ProviderRegistry.TransactOpts, newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_ProviderRegistry *ProviderRegistryTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _ProviderRegistry.Contract.TransferOwnership(&_ProviderRegistry.TransactOpts, newOwner) +} + +// ProviderRegistryDeregisteredIterator is returned from FilterDeregistered and is used to iterate over the raw logs and unpacked data for Deregistered events raised by the ProviderRegistry contract. +type ProviderRegistryDeregisteredIterator struct { + Event *ProviderRegistryDeregistered // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ProviderRegistryDeregisteredIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ProviderRegistryDeregistered) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ProviderRegistryDeregistered) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ProviderRegistryDeregisteredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ProviderRegistryDeregisteredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ProviderRegistryDeregistered represents a Deregistered event raised by the ProviderRegistry contract. +type ProviderRegistryDeregistered struct { + Provider common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterDeregistered is a free log retrieval operation binding the contract event 0xafebd0f81ba8c430fcc0c6a6e7a26fd7f868af9c4e4f19db37a0f16502374fd5. +// +// Solidity: event Deregistered(address indexed provider) +func (_ProviderRegistry *ProviderRegistryFilterer) FilterDeregistered(opts *bind.FilterOpts, provider []common.Address) (*ProviderRegistryDeregisteredIterator, error) { + + var providerRule []interface{} + for _, providerItem := range provider { + providerRule = append(providerRule, providerItem) + } + + logs, sub, err := _ProviderRegistry.contract.FilterLogs(opts, "Deregistered", providerRule) + if err != nil { + return nil, err + } + return &ProviderRegistryDeregisteredIterator{contract: _ProviderRegistry.contract, event: "Deregistered", logs: logs, sub: sub}, nil +} + +// WatchDeregistered is a free log subscription operation binding the contract event 0xafebd0f81ba8c430fcc0c6a6e7a26fd7f868af9c4e4f19db37a0f16502374fd5. +// +// Solidity: event Deregistered(address indexed provider) +func (_ProviderRegistry *ProviderRegistryFilterer) WatchDeregistered(opts *bind.WatchOpts, sink chan<- *ProviderRegistryDeregistered, provider []common.Address) (event.Subscription, error) { + + var providerRule []interface{} + for _, providerItem := range provider { + providerRule = append(providerRule, providerItem) + } + + logs, sub, err := _ProviderRegistry.contract.WatchLogs(opts, "Deregistered", providerRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ProviderRegistryDeregistered) + if err := _ProviderRegistry.contract.UnpackLog(event, "Deregistered", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseDeregistered is a log parse operation binding the contract event 0xafebd0f81ba8c430fcc0c6a6e7a26fd7f868af9c4e4f19db37a0f16502374fd5. +// +// Solidity: event Deregistered(address indexed provider) +func (_ProviderRegistry *ProviderRegistryFilterer) ParseDeregistered(log types.Log) (*ProviderRegistryDeregistered, error) { + event := new(ProviderRegistryDeregistered) + if err := _ProviderRegistry.contract.UnpackLog(event, "Deregistered", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// ProviderRegistryInitializedIterator is returned from FilterInitialized and is used to iterate over the raw logs and unpacked data for Initialized events raised by the ProviderRegistry contract. +type ProviderRegistryInitializedIterator struct { + Event *ProviderRegistryInitialized // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ProviderRegistryInitializedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ProviderRegistryInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ProviderRegistryInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ProviderRegistryInitializedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ProviderRegistryInitializedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ProviderRegistryInitialized represents a Initialized event raised by the ProviderRegistry contract. +type ProviderRegistryInitialized struct { + Version uint8 + Raw types.Log // Blockchain specific contextual infos +} + +// FilterInitialized is a free log retrieval operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_ProviderRegistry *ProviderRegistryFilterer) FilterInitialized(opts *bind.FilterOpts) (*ProviderRegistryInitializedIterator, error) { + + logs, sub, err := _ProviderRegistry.contract.FilterLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return &ProviderRegistryInitializedIterator{contract: _ProviderRegistry.contract, event: "Initialized", logs: logs, sub: sub}, nil +} + +// WatchInitialized is a free log subscription operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_ProviderRegistry *ProviderRegistryFilterer) WatchInitialized(opts *bind.WatchOpts, sink chan<- *ProviderRegistryInitialized) (event.Subscription, error) { + + logs, sub, err := _ProviderRegistry.contract.WatchLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ProviderRegistryInitialized) + if err := _ProviderRegistry.contract.UnpackLog(event, "Initialized", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseInitialized is a log parse operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_ProviderRegistry *ProviderRegistryFilterer) ParseInitialized(log types.Log) (*ProviderRegistryInitialized, error) { + event := new(ProviderRegistryInitialized) + if err := _ProviderRegistry.contract.UnpackLog(event, "Initialized", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// ProviderRegistryMinStakeUpdatedIterator is returned from FilterMinStakeUpdated and is used to iterate over the raw logs and unpacked data for MinStakeUpdated events raised by the ProviderRegistry contract. +type ProviderRegistryMinStakeUpdatedIterator struct { + Event *ProviderRegistryMinStakeUpdated // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ProviderRegistryMinStakeUpdatedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ProviderRegistryMinStakeUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ProviderRegistryMinStakeUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ProviderRegistryMinStakeUpdatedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ProviderRegistryMinStakeUpdatedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ProviderRegistryMinStakeUpdated represents a MinStakeUpdated event raised by the ProviderRegistry contract. +type ProviderRegistryMinStakeUpdated struct { + NewStake *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterMinStakeUpdated is a free log retrieval operation binding the contract event 0x47ab46f2c8d4258304a2f5551c1cbdb6981be49631365d1ba7191288a73f39ef. +// +// Solidity: event MinStakeUpdated(uint256 newStake) +func (_ProviderRegistry *ProviderRegistryFilterer) FilterMinStakeUpdated(opts *bind.FilterOpts) (*ProviderRegistryMinStakeUpdatedIterator, error) { + + logs, sub, err := _ProviderRegistry.contract.FilterLogs(opts, "MinStakeUpdated") + if err != nil { + return nil, err + } + return &ProviderRegistryMinStakeUpdatedIterator{contract: _ProviderRegistry.contract, event: "MinStakeUpdated", logs: logs, sub: sub}, nil +} + +// WatchMinStakeUpdated is a free log subscription operation binding the contract event 0x47ab46f2c8d4258304a2f5551c1cbdb6981be49631365d1ba7191288a73f39ef. +// +// Solidity: event MinStakeUpdated(uint256 newStake) +func (_ProviderRegistry *ProviderRegistryFilterer) WatchMinStakeUpdated(opts *bind.WatchOpts, sink chan<- *ProviderRegistryMinStakeUpdated) (event.Subscription, error) { + + logs, sub, err := _ProviderRegistry.contract.WatchLogs(opts, "MinStakeUpdated") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ProviderRegistryMinStakeUpdated) + if err := _ProviderRegistry.contract.UnpackLog(event, "MinStakeUpdated", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseMinStakeUpdated is a log parse operation binding the contract event 0x47ab46f2c8d4258304a2f5551c1cbdb6981be49631365d1ba7191288a73f39ef. +// +// Solidity: event MinStakeUpdated(uint256 newStake) +func (_ProviderRegistry *ProviderRegistryFilterer) ParseMinStakeUpdated(log types.Log) (*ProviderRegistryMinStakeUpdated, error) { + event := new(ProviderRegistryMinStakeUpdated) + if err := _ProviderRegistry.contract.UnpackLog(event, "MinStakeUpdated", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// ProviderRegistryOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the ProviderRegistry contract. +type ProviderRegistryOwnershipTransferredIterator struct { + Event *ProviderRegistryOwnershipTransferred // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ProviderRegistryOwnershipTransferredIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ProviderRegistryOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ProviderRegistryOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ProviderRegistryOwnershipTransferredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ProviderRegistryOwnershipTransferredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ProviderRegistryOwnershipTransferred represents a OwnershipTransferred event raised by the ProviderRegistry contract. +type ProviderRegistryOwnershipTransferred struct { + PreviousOwner common.Address + NewOwner common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_ProviderRegistry *ProviderRegistryFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*ProviderRegistryOwnershipTransferredIterator, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _ProviderRegistry.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return &ProviderRegistryOwnershipTransferredIterator{contract: _ProviderRegistry.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil +} + +// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_ProviderRegistry *ProviderRegistryFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *ProviderRegistryOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _ProviderRegistry.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ProviderRegistryOwnershipTransferred) + if err := _ProviderRegistry.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_ProviderRegistry *ProviderRegistryFilterer) ParseOwnershipTransferred(log types.Log) (*ProviderRegistryOwnershipTransferred, error) { + event := new(ProviderRegistryOwnershipTransferred) + if err := _ProviderRegistry.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// ProviderRegistryRegisteredUpdatedIterator is returned from FilterRegisteredUpdated and is used to iterate over the raw logs and unpacked data for RegisteredUpdated events raised by the ProviderRegistry contract. +type ProviderRegistryRegisteredUpdatedIterator struct { + Event *ProviderRegistryRegisteredUpdated // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *ProviderRegistryRegisteredUpdatedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(ProviderRegistryRegisteredUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(ProviderRegistryRegisteredUpdated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *ProviderRegistryRegisteredUpdatedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *ProviderRegistryRegisteredUpdatedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// ProviderRegistryRegisteredUpdated represents a RegisteredUpdated event raised by the ProviderRegistry contract. +type ProviderRegistryRegisteredUpdated struct { + Provider common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterRegisteredUpdated is a free log retrieval operation binding the contract event 0x0407973ec6e86eb9f260606351583a2737e1db4d6f44c2414e699bd665ae10dc. +// +// Solidity: event RegisteredUpdated(address indexed provider) +func (_ProviderRegistry *ProviderRegistryFilterer) FilterRegisteredUpdated(opts *bind.FilterOpts, provider []common.Address) (*ProviderRegistryRegisteredUpdatedIterator, error) { + + var providerRule []interface{} + for _, providerItem := range provider { + providerRule = append(providerRule, providerItem) + } + + logs, sub, err := _ProviderRegistry.contract.FilterLogs(opts, "RegisteredUpdated", providerRule) + if err != nil { + return nil, err + } + return &ProviderRegistryRegisteredUpdatedIterator{contract: _ProviderRegistry.contract, event: "RegisteredUpdated", logs: logs, sub: sub}, nil +} + +// WatchRegisteredUpdated is a free log subscription operation binding the contract event 0x0407973ec6e86eb9f260606351583a2737e1db4d6f44c2414e699bd665ae10dc. +// +// Solidity: event RegisteredUpdated(address indexed provider) +func (_ProviderRegistry *ProviderRegistryFilterer) WatchRegisteredUpdated(opts *bind.WatchOpts, sink chan<- *ProviderRegistryRegisteredUpdated, provider []common.Address) (event.Subscription, error) { + + var providerRule []interface{} + for _, providerItem := range provider { + providerRule = append(providerRule, providerItem) + } + + logs, sub, err := _ProviderRegistry.contract.WatchLogs(opts, "RegisteredUpdated", providerRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(ProviderRegistryRegisteredUpdated) + if err := _ProviderRegistry.contract.UnpackLog(event, "RegisteredUpdated", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseRegisteredUpdated is a log parse operation binding the contract event 0x0407973ec6e86eb9f260606351583a2737e1db4d6f44c2414e699bd665ae10dc. +// +// Solidity: event RegisteredUpdated(address indexed provider) +func (_ProviderRegistry *ProviderRegistryFilterer) ParseRegisteredUpdated(log types.Log) (*ProviderRegistryRegisteredUpdated, error) { + event := new(ProviderRegistryRegisteredUpdated) + if err := _ProviderRegistry.contract.UnpackLog(event, "RegisteredUpdated", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/smart-contracts/bindings/go/contracts/sessionrouter/SessionRouter.go b/smart-contracts/bindings/go/contracts/sessionrouter/SessionRouter.go new file mode 100644 index 00000000..516bbb93 --- /dev/null +++ b/smart-contracts/bindings/go/contracts/sessionrouter/SessionRouter.go @@ -0,0 +1,1944 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package sessionrouter + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// SessionRouterSession is an auto generated low-level Go binding around an user-defined struct. +type SessionRouterSession struct { + Id [32]byte + User common.Address + Provider common.Address + ModelAgentId [32]byte + Budget *big.Int + Price *big.Int + CloseoutReceipt []byte + CloseoutType *big.Int + OpenedAt *big.Int + ClosedAt *big.Int +} + +// SessionRouterMetaData contains all meta data concerning the SessionRouter contract. +var SessionRouterMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[],\"name\":\"BidNotFound\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"InvalidSignature\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotEnoughBalance\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotEnoughStipend\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotSenderOrOwner\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotUser\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotUserOrProvider\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SessionNotFound\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"SessionTooShort\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"providerAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"ProviderClaimed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"userAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"sessionId\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"providerId\",\"type\":\"address\"}],\"name\":\"SessionClosed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"userAddress\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"sessionId\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"providerId\",\"type\":\"address\"}],\"name\":\"SessionOpened\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"userAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Staked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"userAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Unstaked\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amountToWithdraw\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"}],\"name\":\"claimProviderBalance\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"sessionId\",\"type\":\"bytes32\"},{\"internalType\":\"bytes\",\"name\":\"receiptEncoded\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"name\":\"closeSession\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"sessionId\",\"type\":\"bytes32\"}],\"name\":\"deleteHistory\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"_encodedMessage\",\"type\":\"bytes\"}],\"name\":\"getEthSignedMessageHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"providerAddr\",\"type\":\"address\"}],\"name\":\"getProviderBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"total\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"hold\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"providerAddr\",\"type\":\"address\"}],\"name\":\"getProviderClaimBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"sessionId\",\"type\":\"bytes32\"}],\"name\":\"getSession\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"id\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"modelAgentId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"budget\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"closeoutReceipt\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"closeoutType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"openedAt\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"closedAt\",\"type\":\"uint256\"}],\"internalType\":\"structSessionRouter.Session\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_stakingDailyStipend\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_marketplace\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"map\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"marketplace\",\"outputs\":[{\"internalType\":\"contractMarketplace\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"bidId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"budget\",\"type\":\"uint256\"}],\"name\":\"openSession\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"sessionId\",\"type\":\"bytes32\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"providerOnHold\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"releaseAt\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"message\",\"type\":\"bytes32\"},{\"internalType\":\"bytes\",\"name\":\"sig\",\"type\":\"bytes\"}],\"name\":\"recoverSigner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"sessions\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"id\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"provider\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"modelAgentId\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"budget\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"closeoutReceipt\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"closeoutType\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"openedAt\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"closedAt\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"int256\",\"name\":\"delay\",\"type\":\"int256\"}],\"name\":\"setStakeDelay\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"sig\",\"type\":\"bytes\"}],\"name\":\"splitSignature\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"stakeDelay\",\"outputs\":[{\"internalType\":\"int256\",\"name\":\"\",\"type\":\"int256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"stakingDailyStipend\",\"outputs\":[{\"internalType\":\"contractStakingDailyStipend\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"token\",\"outputs\":[{\"internalType\":\"contractIERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", +} + +// SessionRouterABI is the input ABI used to generate the binding from. +// Deprecated: Use SessionRouterMetaData.ABI instead. +var SessionRouterABI = SessionRouterMetaData.ABI + +// SessionRouter is an auto generated Go binding around an Ethereum contract. +type SessionRouter struct { + SessionRouterCaller // Read-only binding to the contract + SessionRouterTransactor // Write-only binding to the contract + SessionRouterFilterer // Log filterer for contract events +} + +// SessionRouterCaller is an auto generated read-only Go binding around an Ethereum contract. +type SessionRouterCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// SessionRouterTransactor is an auto generated write-only Go binding around an Ethereum contract. +type SessionRouterTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// SessionRouterFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type SessionRouterFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// SessionRouterSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type SessionRouterSession struct { + Contract *SessionRouter // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// SessionRouterCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type SessionRouterCallerSession struct { + Contract *SessionRouterCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// SessionRouterTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type SessionRouterTransactorSession struct { + Contract *SessionRouterTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// SessionRouterRaw is an auto generated low-level Go binding around an Ethereum contract. +type SessionRouterRaw struct { + Contract *SessionRouter // Generic contract binding to access the raw methods on +} + +// SessionRouterCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type SessionRouterCallerRaw struct { + Contract *SessionRouterCaller // Generic read-only contract binding to access the raw methods on +} + +// SessionRouterTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type SessionRouterTransactorRaw struct { + Contract *SessionRouterTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewSessionRouter creates a new instance of SessionRouter, bound to a specific deployed contract. +func NewSessionRouter(address common.Address, backend bind.ContractBackend) (*SessionRouter, error) { + contract, err := bindSessionRouter(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &SessionRouter{SessionRouterCaller: SessionRouterCaller{contract: contract}, SessionRouterTransactor: SessionRouterTransactor{contract: contract}, SessionRouterFilterer: SessionRouterFilterer{contract: contract}}, nil +} + +// NewSessionRouterCaller creates a new read-only instance of SessionRouter, bound to a specific deployed contract. +func NewSessionRouterCaller(address common.Address, caller bind.ContractCaller) (*SessionRouterCaller, error) { + contract, err := bindSessionRouter(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &SessionRouterCaller{contract: contract}, nil +} + +// NewSessionRouterTransactor creates a new write-only instance of SessionRouter, bound to a specific deployed contract. +func NewSessionRouterTransactor(address common.Address, transactor bind.ContractTransactor) (*SessionRouterTransactor, error) { + contract, err := bindSessionRouter(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &SessionRouterTransactor{contract: contract}, nil +} + +// NewSessionRouterFilterer creates a new log filterer instance of SessionRouter, bound to a specific deployed contract. +func NewSessionRouterFilterer(address common.Address, filterer bind.ContractFilterer) (*SessionRouterFilterer, error) { + contract, err := bindSessionRouter(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &SessionRouterFilterer{contract: contract}, nil +} + +// bindSessionRouter binds a generic wrapper to an already deployed contract. +func bindSessionRouter(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := SessionRouterMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_SessionRouter *SessionRouterRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _SessionRouter.Contract.SessionRouterCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_SessionRouter *SessionRouterRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _SessionRouter.Contract.SessionRouterTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_SessionRouter *SessionRouterRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _SessionRouter.Contract.SessionRouterTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_SessionRouter *SessionRouterCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _SessionRouter.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_SessionRouter *SessionRouterTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _SessionRouter.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_SessionRouter *SessionRouterTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _SessionRouter.Contract.contract.Transact(opts, method, params...) +} + +// GetEthSignedMessageHash is a free data retrieval call binding the contract method 0xf9aea466. +// +// Solidity: function getEthSignedMessageHash(bytes _encodedMessage) pure returns(bytes32) +func (_SessionRouter *SessionRouterCaller) GetEthSignedMessageHash(opts *bind.CallOpts, _encodedMessage []byte) ([32]byte, error) { + var out []interface{} + err := _SessionRouter.contract.Call(opts, &out, "getEthSignedMessageHash", _encodedMessage) + + if err != nil { + return *new([32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + + return out0, err + +} + +// GetEthSignedMessageHash is a free data retrieval call binding the contract method 0xf9aea466. +// +// Solidity: function getEthSignedMessageHash(bytes _encodedMessage) pure returns(bytes32) +func (_SessionRouter *SessionRouterSession) GetEthSignedMessageHash(_encodedMessage []byte) ([32]byte, error) { + return _SessionRouter.Contract.GetEthSignedMessageHash(&_SessionRouter.CallOpts, _encodedMessage) +} + +// GetEthSignedMessageHash is a free data retrieval call binding the contract method 0xf9aea466. +// +// Solidity: function getEthSignedMessageHash(bytes _encodedMessage) pure returns(bytes32) +func (_SessionRouter *SessionRouterCallerSession) GetEthSignedMessageHash(_encodedMessage []byte) ([32]byte, error) { + return _SessionRouter.Contract.GetEthSignedMessageHash(&_SessionRouter.CallOpts, _encodedMessage) +} + +// GetProviderBalance is a free data retrieval call binding the contract method 0x832eea0c. +// +// Solidity: function getProviderBalance(address providerAddr) view returns(uint256 total, uint256 hold) +func (_SessionRouter *SessionRouterCaller) GetProviderBalance(opts *bind.CallOpts, providerAddr common.Address) (struct { + Total *big.Int + Hold *big.Int +}, error) { + var out []interface{} + err := _SessionRouter.contract.Call(opts, &out, "getProviderBalance", providerAddr) + + outstruct := new(struct { + Total *big.Int + Hold *big.Int + }) + if err != nil { + return *outstruct, err + } + + outstruct.Total = *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + outstruct.Hold = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) + + return *outstruct, err + +} + +// GetProviderBalance is a free data retrieval call binding the contract method 0x832eea0c. +// +// Solidity: function getProviderBalance(address providerAddr) view returns(uint256 total, uint256 hold) +func (_SessionRouter *SessionRouterSession) GetProviderBalance(providerAddr common.Address) (struct { + Total *big.Int + Hold *big.Int +}, error) { + return _SessionRouter.Contract.GetProviderBalance(&_SessionRouter.CallOpts, providerAddr) +} + +// GetProviderBalance is a free data retrieval call binding the contract method 0x832eea0c. +// +// Solidity: function getProviderBalance(address providerAddr) view returns(uint256 total, uint256 hold) +func (_SessionRouter *SessionRouterCallerSession) GetProviderBalance(providerAddr common.Address) (struct { + Total *big.Int + Hold *big.Int +}, error) { + return _SessionRouter.Contract.GetProviderBalance(&_SessionRouter.CallOpts, providerAddr) +} + +// GetProviderClaimBalance is a free data retrieval call binding the contract method 0x6c98599b. +// +// Solidity: function getProviderClaimBalance(address providerAddr) view returns(uint256) +func (_SessionRouter *SessionRouterCaller) GetProviderClaimBalance(opts *bind.CallOpts, providerAddr common.Address) (*big.Int, error) { + var out []interface{} + err := _SessionRouter.contract.Call(opts, &out, "getProviderClaimBalance", providerAddr) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetProviderClaimBalance is a free data retrieval call binding the contract method 0x6c98599b. +// +// Solidity: function getProviderClaimBalance(address providerAddr) view returns(uint256) +func (_SessionRouter *SessionRouterSession) GetProviderClaimBalance(providerAddr common.Address) (*big.Int, error) { + return _SessionRouter.Contract.GetProviderClaimBalance(&_SessionRouter.CallOpts, providerAddr) +} + +// GetProviderClaimBalance is a free data retrieval call binding the contract method 0x6c98599b. +// +// Solidity: function getProviderClaimBalance(address providerAddr) view returns(uint256) +func (_SessionRouter *SessionRouterCallerSession) GetProviderClaimBalance(providerAddr common.Address) (*big.Int, error) { + return _SessionRouter.Contract.GetProviderClaimBalance(&_SessionRouter.CallOpts, providerAddr) +} + +// GetSession is a free data retrieval call binding the contract method 0x39b240bd. +// +// Solidity: function getSession(bytes32 sessionId) view returns((bytes32,address,address,bytes32,uint256,uint256,bytes,uint256,uint256,uint256)) +func (_SessionRouter *SessionRouterCaller) GetSession(opts *bind.CallOpts, sessionId [32]byte) (SessionRouterSession, error) { + var out []interface{} + err := _SessionRouter.contract.Call(opts, &out, "getSession", sessionId) + + if err != nil { + return *new(SessionRouterSession), err + } + + out0 := *abi.ConvertType(out[0], new(SessionRouterSession)).(*SessionRouterSession) + + return out0, err + +} + +// GetSession is a free data retrieval call binding the contract method 0x39b240bd. +// +// Solidity: function getSession(bytes32 sessionId) view returns((bytes32,address,address,bytes32,uint256,uint256,bytes,uint256,uint256,uint256)) +func (_SessionRouter *SessionRouterSession) GetSession(sessionId [32]byte) (SessionRouterSession, error) { + return _SessionRouter.Contract.GetSession(&_SessionRouter.CallOpts, sessionId) +} + +// GetSession is a free data retrieval call binding the contract method 0x39b240bd. +// +// Solidity: function getSession(bytes32 sessionId) view returns((bytes32,address,address,bytes32,uint256,uint256,bytes,uint256,uint256,uint256)) +func (_SessionRouter *SessionRouterCallerSession) GetSession(sessionId [32]byte) (SessionRouterSession, error) { + return _SessionRouter.Contract.GetSession(&_SessionRouter.CallOpts, sessionId) +} + +// Map is a free data retrieval call binding the contract method 0x0ae186a8. +// +// Solidity: function map(bytes32 ) view returns(uint256) +func (_SessionRouter *SessionRouterCaller) Map(opts *bind.CallOpts, arg0 [32]byte) (*big.Int, error) { + var out []interface{} + err := _SessionRouter.contract.Call(opts, &out, "map", arg0) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// Map is a free data retrieval call binding the contract method 0x0ae186a8. +// +// Solidity: function map(bytes32 ) view returns(uint256) +func (_SessionRouter *SessionRouterSession) Map(arg0 [32]byte) (*big.Int, error) { + return _SessionRouter.Contract.Map(&_SessionRouter.CallOpts, arg0) +} + +// Map is a free data retrieval call binding the contract method 0x0ae186a8. +// +// Solidity: function map(bytes32 ) view returns(uint256) +func (_SessionRouter *SessionRouterCallerSession) Map(arg0 [32]byte) (*big.Int, error) { + return _SessionRouter.Contract.Map(&_SessionRouter.CallOpts, arg0) +} + +// Marketplace is a free data retrieval call binding the contract method 0xabc8c7af. +// +// Solidity: function marketplace() view returns(address) +func (_SessionRouter *SessionRouterCaller) Marketplace(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _SessionRouter.contract.Call(opts, &out, "marketplace") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Marketplace is a free data retrieval call binding the contract method 0xabc8c7af. +// +// Solidity: function marketplace() view returns(address) +func (_SessionRouter *SessionRouterSession) Marketplace() (common.Address, error) { + return _SessionRouter.Contract.Marketplace(&_SessionRouter.CallOpts) +} + +// Marketplace is a free data retrieval call binding the contract method 0xabc8c7af. +// +// Solidity: function marketplace() view returns(address) +func (_SessionRouter *SessionRouterCallerSession) Marketplace() (common.Address, error) { + return _SessionRouter.Contract.Marketplace(&_SessionRouter.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_SessionRouter *SessionRouterCaller) Owner(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _SessionRouter.contract.Call(opts, &out, "owner") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_SessionRouter *SessionRouterSession) Owner() (common.Address, error) { + return _SessionRouter.Contract.Owner(&_SessionRouter.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_SessionRouter *SessionRouterCallerSession) Owner() (common.Address, error) { + return _SessionRouter.Contract.Owner(&_SessionRouter.CallOpts) +} + +// ProviderOnHold is a free data retrieval call binding the contract method 0xdbf7d54f. +// +// Solidity: function providerOnHold(address , uint256 ) view returns(uint256 amount, uint256 releaseAt) +func (_SessionRouter *SessionRouterCaller) ProviderOnHold(opts *bind.CallOpts, arg0 common.Address, arg1 *big.Int) (struct { + Amount *big.Int + ReleaseAt *big.Int +}, error) { + var out []interface{} + err := _SessionRouter.contract.Call(opts, &out, "providerOnHold", arg0, arg1) + + outstruct := new(struct { + Amount *big.Int + ReleaseAt *big.Int + }) + if err != nil { + return *outstruct, err + } + + outstruct.Amount = *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + outstruct.ReleaseAt = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) + + return *outstruct, err + +} + +// ProviderOnHold is a free data retrieval call binding the contract method 0xdbf7d54f. +// +// Solidity: function providerOnHold(address , uint256 ) view returns(uint256 amount, uint256 releaseAt) +func (_SessionRouter *SessionRouterSession) ProviderOnHold(arg0 common.Address, arg1 *big.Int) (struct { + Amount *big.Int + ReleaseAt *big.Int +}, error) { + return _SessionRouter.Contract.ProviderOnHold(&_SessionRouter.CallOpts, arg0, arg1) +} + +// ProviderOnHold is a free data retrieval call binding the contract method 0xdbf7d54f. +// +// Solidity: function providerOnHold(address , uint256 ) view returns(uint256 amount, uint256 releaseAt) +func (_SessionRouter *SessionRouterCallerSession) ProviderOnHold(arg0 common.Address, arg1 *big.Int) (struct { + Amount *big.Int + ReleaseAt *big.Int +}, error) { + return _SessionRouter.Contract.ProviderOnHold(&_SessionRouter.CallOpts, arg0, arg1) +} + +// RecoverSigner is a free data retrieval call binding the contract method 0x97aba7f9. +// +// Solidity: function recoverSigner(bytes32 message, bytes sig) pure returns(address) +func (_SessionRouter *SessionRouterCaller) RecoverSigner(opts *bind.CallOpts, message [32]byte, sig []byte) (common.Address, error) { + var out []interface{} + err := _SessionRouter.contract.Call(opts, &out, "recoverSigner", message, sig) + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// RecoverSigner is a free data retrieval call binding the contract method 0x97aba7f9. +// +// Solidity: function recoverSigner(bytes32 message, bytes sig) pure returns(address) +func (_SessionRouter *SessionRouterSession) RecoverSigner(message [32]byte, sig []byte) (common.Address, error) { + return _SessionRouter.Contract.RecoverSigner(&_SessionRouter.CallOpts, message, sig) +} + +// RecoverSigner is a free data retrieval call binding the contract method 0x97aba7f9. +// +// Solidity: function recoverSigner(bytes32 message, bytes sig) pure returns(address) +func (_SessionRouter *SessionRouterCallerSession) RecoverSigner(message [32]byte, sig []byte) (common.Address, error) { + return _SessionRouter.Contract.RecoverSigner(&_SessionRouter.CallOpts, message, sig) +} + +// Sessions is a free data retrieval call binding the contract method 0x83c4b7a3. +// +// Solidity: function sessions(uint256 ) view returns(bytes32 id, address user, address provider, bytes32 modelAgentId, uint256 budget, uint256 price, bytes closeoutReceipt, uint256 closeoutType, uint256 openedAt, uint256 closedAt) +func (_SessionRouter *SessionRouterCaller) Sessions(opts *bind.CallOpts, arg0 *big.Int) (struct { + Id [32]byte + User common.Address + Provider common.Address + ModelAgentId [32]byte + Budget *big.Int + Price *big.Int + CloseoutReceipt []byte + CloseoutType *big.Int + OpenedAt *big.Int + ClosedAt *big.Int +}, error) { + var out []interface{} + err := _SessionRouter.contract.Call(opts, &out, "sessions", arg0) + + outstruct := new(struct { + Id [32]byte + User common.Address + Provider common.Address + ModelAgentId [32]byte + Budget *big.Int + Price *big.Int + CloseoutReceipt []byte + CloseoutType *big.Int + OpenedAt *big.Int + ClosedAt *big.Int + }) + if err != nil { + return *outstruct, err + } + + outstruct.Id = *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + outstruct.User = *abi.ConvertType(out[1], new(common.Address)).(*common.Address) + outstruct.Provider = *abi.ConvertType(out[2], new(common.Address)).(*common.Address) + outstruct.ModelAgentId = *abi.ConvertType(out[3], new([32]byte)).(*[32]byte) + outstruct.Budget = *abi.ConvertType(out[4], new(*big.Int)).(**big.Int) + outstruct.Price = *abi.ConvertType(out[5], new(*big.Int)).(**big.Int) + outstruct.CloseoutReceipt = *abi.ConvertType(out[6], new([]byte)).(*[]byte) + outstruct.CloseoutType = *abi.ConvertType(out[7], new(*big.Int)).(**big.Int) + outstruct.OpenedAt = *abi.ConvertType(out[8], new(*big.Int)).(**big.Int) + outstruct.ClosedAt = *abi.ConvertType(out[9], new(*big.Int)).(**big.Int) + + return *outstruct, err + +} + +// Sessions is a free data retrieval call binding the contract method 0x83c4b7a3. +// +// Solidity: function sessions(uint256 ) view returns(bytes32 id, address user, address provider, bytes32 modelAgentId, uint256 budget, uint256 price, bytes closeoutReceipt, uint256 closeoutType, uint256 openedAt, uint256 closedAt) +func (_SessionRouter *SessionRouterSession) Sessions(arg0 *big.Int) (struct { + Id [32]byte + User common.Address + Provider common.Address + ModelAgentId [32]byte + Budget *big.Int + Price *big.Int + CloseoutReceipt []byte + CloseoutType *big.Int + OpenedAt *big.Int + ClosedAt *big.Int +}, error) { + return _SessionRouter.Contract.Sessions(&_SessionRouter.CallOpts, arg0) +} + +// Sessions is a free data retrieval call binding the contract method 0x83c4b7a3. +// +// Solidity: function sessions(uint256 ) view returns(bytes32 id, address user, address provider, bytes32 modelAgentId, uint256 budget, uint256 price, bytes closeoutReceipt, uint256 closeoutType, uint256 openedAt, uint256 closedAt) +func (_SessionRouter *SessionRouterCallerSession) Sessions(arg0 *big.Int) (struct { + Id [32]byte + User common.Address + Provider common.Address + ModelAgentId [32]byte + Budget *big.Int + Price *big.Int + CloseoutReceipt []byte + CloseoutType *big.Int + OpenedAt *big.Int + ClosedAt *big.Int +}, error) { + return _SessionRouter.Contract.Sessions(&_SessionRouter.CallOpts, arg0) +} + +// SplitSignature is a free data retrieval call binding the contract method 0xa7bb5803. +// +// Solidity: function splitSignature(bytes sig) pure returns(bytes32 r, bytes32 s, uint8 v) +func (_SessionRouter *SessionRouterCaller) SplitSignature(opts *bind.CallOpts, sig []byte) (struct { + R [32]byte + S [32]byte + V uint8 +}, error) { + var out []interface{} + err := _SessionRouter.contract.Call(opts, &out, "splitSignature", sig) + + outstruct := new(struct { + R [32]byte + S [32]byte + V uint8 + }) + if err != nil { + return *outstruct, err + } + + outstruct.R = *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + outstruct.S = *abi.ConvertType(out[1], new([32]byte)).(*[32]byte) + outstruct.V = *abi.ConvertType(out[2], new(uint8)).(*uint8) + + return *outstruct, err + +} + +// SplitSignature is a free data retrieval call binding the contract method 0xa7bb5803. +// +// Solidity: function splitSignature(bytes sig) pure returns(bytes32 r, bytes32 s, uint8 v) +func (_SessionRouter *SessionRouterSession) SplitSignature(sig []byte) (struct { + R [32]byte + S [32]byte + V uint8 +}, error) { + return _SessionRouter.Contract.SplitSignature(&_SessionRouter.CallOpts, sig) +} + +// SplitSignature is a free data retrieval call binding the contract method 0xa7bb5803. +// +// Solidity: function splitSignature(bytes sig) pure returns(bytes32 r, bytes32 s, uint8 v) +func (_SessionRouter *SessionRouterCallerSession) SplitSignature(sig []byte) (struct { + R [32]byte + S [32]byte + V uint8 +}, error) { + return _SessionRouter.Contract.SplitSignature(&_SessionRouter.CallOpts, sig) +} + +// StakeDelay is a free data retrieval call binding the contract method 0x946ada60. +// +// Solidity: function stakeDelay() view returns(int256) +func (_SessionRouter *SessionRouterCaller) StakeDelay(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _SessionRouter.contract.Call(opts, &out, "stakeDelay") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// StakeDelay is a free data retrieval call binding the contract method 0x946ada60. +// +// Solidity: function stakeDelay() view returns(int256) +func (_SessionRouter *SessionRouterSession) StakeDelay() (*big.Int, error) { + return _SessionRouter.Contract.StakeDelay(&_SessionRouter.CallOpts) +} + +// StakeDelay is a free data retrieval call binding the contract method 0x946ada60. +// +// Solidity: function stakeDelay() view returns(int256) +func (_SessionRouter *SessionRouterCallerSession) StakeDelay() (*big.Int, error) { + return _SessionRouter.Contract.StakeDelay(&_SessionRouter.CallOpts) +} + +// StakingDailyStipend is a free data retrieval call binding the contract method 0xfcfc2201. +// +// Solidity: function stakingDailyStipend() view returns(address) +func (_SessionRouter *SessionRouterCaller) StakingDailyStipend(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _SessionRouter.contract.Call(opts, &out, "stakingDailyStipend") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// StakingDailyStipend is a free data retrieval call binding the contract method 0xfcfc2201. +// +// Solidity: function stakingDailyStipend() view returns(address) +func (_SessionRouter *SessionRouterSession) StakingDailyStipend() (common.Address, error) { + return _SessionRouter.Contract.StakingDailyStipend(&_SessionRouter.CallOpts) +} + +// StakingDailyStipend is a free data retrieval call binding the contract method 0xfcfc2201. +// +// Solidity: function stakingDailyStipend() view returns(address) +func (_SessionRouter *SessionRouterCallerSession) StakingDailyStipend() (common.Address, error) { + return _SessionRouter.Contract.StakingDailyStipend(&_SessionRouter.CallOpts) +} + +// Token is a free data retrieval call binding the contract method 0xfc0c546a. +// +// Solidity: function token() view returns(address) +func (_SessionRouter *SessionRouterCaller) Token(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _SessionRouter.contract.Call(opts, &out, "token") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Token is a free data retrieval call binding the contract method 0xfc0c546a. +// +// Solidity: function token() view returns(address) +func (_SessionRouter *SessionRouterSession) Token() (common.Address, error) { + return _SessionRouter.Contract.Token(&_SessionRouter.CallOpts) +} + +// Token is a free data retrieval call binding the contract method 0xfc0c546a. +// +// Solidity: function token() view returns(address) +func (_SessionRouter *SessionRouterCallerSession) Token() (common.Address, error) { + return _SessionRouter.Contract.Token(&_SessionRouter.CallOpts) +} + +// ClaimProviderBalance is a paid mutator transaction binding the contract method 0xc9a93c1a. +// +// Solidity: function claimProviderBalance(uint256 amountToWithdraw, address to) returns() +func (_SessionRouter *SessionRouterTransactor) ClaimProviderBalance(opts *bind.TransactOpts, amountToWithdraw *big.Int, to common.Address) (*types.Transaction, error) { + return _SessionRouter.contract.Transact(opts, "claimProviderBalance", amountToWithdraw, to) +} + +// ClaimProviderBalance is a paid mutator transaction binding the contract method 0xc9a93c1a. +// +// Solidity: function claimProviderBalance(uint256 amountToWithdraw, address to) returns() +func (_SessionRouter *SessionRouterSession) ClaimProviderBalance(amountToWithdraw *big.Int, to common.Address) (*types.Transaction, error) { + return _SessionRouter.Contract.ClaimProviderBalance(&_SessionRouter.TransactOpts, amountToWithdraw, to) +} + +// ClaimProviderBalance is a paid mutator transaction binding the contract method 0xc9a93c1a. +// +// Solidity: function claimProviderBalance(uint256 amountToWithdraw, address to) returns() +func (_SessionRouter *SessionRouterTransactorSession) ClaimProviderBalance(amountToWithdraw *big.Int, to common.Address) (*types.Transaction, error) { + return _SessionRouter.Contract.ClaimProviderBalance(&_SessionRouter.TransactOpts, amountToWithdraw, to) +} + +// CloseSession is a paid mutator transaction binding the contract method 0x9775d1ff. +// +// Solidity: function closeSession(bytes32 sessionId, bytes receiptEncoded, bytes signature) returns() +func (_SessionRouter *SessionRouterTransactor) CloseSession(opts *bind.TransactOpts, sessionId [32]byte, receiptEncoded []byte, signature []byte) (*types.Transaction, error) { + return _SessionRouter.contract.Transact(opts, "closeSession", sessionId, receiptEncoded, signature) +} + +// CloseSession is a paid mutator transaction binding the contract method 0x9775d1ff. +// +// Solidity: function closeSession(bytes32 sessionId, bytes receiptEncoded, bytes signature) returns() +func (_SessionRouter *SessionRouterSession) CloseSession(sessionId [32]byte, receiptEncoded []byte, signature []byte) (*types.Transaction, error) { + return _SessionRouter.Contract.CloseSession(&_SessionRouter.TransactOpts, sessionId, receiptEncoded, signature) +} + +// CloseSession is a paid mutator transaction binding the contract method 0x9775d1ff. +// +// Solidity: function closeSession(bytes32 sessionId, bytes receiptEncoded, bytes signature) returns() +func (_SessionRouter *SessionRouterTransactorSession) CloseSession(sessionId [32]byte, receiptEncoded []byte, signature []byte) (*types.Transaction, error) { + return _SessionRouter.Contract.CloseSession(&_SessionRouter.TransactOpts, sessionId, receiptEncoded, signature) +} + +// DeleteHistory is a paid mutator transaction binding the contract method 0xf074ca6b. +// +// Solidity: function deleteHistory(bytes32 sessionId) returns() +func (_SessionRouter *SessionRouterTransactor) DeleteHistory(opts *bind.TransactOpts, sessionId [32]byte) (*types.Transaction, error) { + return _SessionRouter.contract.Transact(opts, "deleteHistory", sessionId) +} + +// DeleteHistory is a paid mutator transaction binding the contract method 0xf074ca6b. +// +// Solidity: function deleteHistory(bytes32 sessionId) returns() +func (_SessionRouter *SessionRouterSession) DeleteHistory(sessionId [32]byte) (*types.Transaction, error) { + return _SessionRouter.Contract.DeleteHistory(&_SessionRouter.TransactOpts, sessionId) +} + +// DeleteHistory is a paid mutator transaction binding the contract method 0xf074ca6b. +// +// Solidity: function deleteHistory(bytes32 sessionId) returns() +func (_SessionRouter *SessionRouterTransactorSession) DeleteHistory(sessionId [32]byte) (*types.Transaction, error) { + return _SessionRouter.Contract.DeleteHistory(&_SessionRouter.TransactOpts, sessionId) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc0c53b8b. +// +// Solidity: function initialize(address _token, address _stakingDailyStipend, address _marketplace) returns() +func (_SessionRouter *SessionRouterTransactor) Initialize(opts *bind.TransactOpts, _token common.Address, _stakingDailyStipend common.Address, _marketplace common.Address) (*types.Transaction, error) { + return _SessionRouter.contract.Transact(opts, "initialize", _token, _stakingDailyStipend, _marketplace) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc0c53b8b. +// +// Solidity: function initialize(address _token, address _stakingDailyStipend, address _marketplace) returns() +func (_SessionRouter *SessionRouterSession) Initialize(_token common.Address, _stakingDailyStipend common.Address, _marketplace common.Address) (*types.Transaction, error) { + return _SessionRouter.Contract.Initialize(&_SessionRouter.TransactOpts, _token, _stakingDailyStipend, _marketplace) +} + +// Initialize is a paid mutator transaction binding the contract method 0xc0c53b8b. +// +// Solidity: function initialize(address _token, address _stakingDailyStipend, address _marketplace) returns() +func (_SessionRouter *SessionRouterTransactorSession) Initialize(_token common.Address, _stakingDailyStipend common.Address, _marketplace common.Address) (*types.Transaction, error) { + return _SessionRouter.Contract.Initialize(&_SessionRouter.TransactOpts, _token, _stakingDailyStipend, _marketplace) +} + +// OpenSession is a paid mutator transaction binding the contract method 0x48c00c90. +// +// Solidity: function openSession(bytes32 bidId, uint256 budget) returns(bytes32 sessionId) +func (_SessionRouter *SessionRouterTransactor) OpenSession(opts *bind.TransactOpts, bidId [32]byte, budget *big.Int) (*types.Transaction, error) { + return _SessionRouter.contract.Transact(opts, "openSession", bidId, budget) +} + +// OpenSession is a paid mutator transaction binding the contract method 0x48c00c90. +// +// Solidity: function openSession(bytes32 bidId, uint256 budget) returns(bytes32 sessionId) +func (_SessionRouter *SessionRouterSession) OpenSession(bidId [32]byte, budget *big.Int) (*types.Transaction, error) { + return _SessionRouter.Contract.OpenSession(&_SessionRouter.TransactOpts, bidId, budget) +} + +// OpenSession is a paid mutator transaction binding the contract method 0x48c00c90. +// +// Solidity: function openSession(bytes32 bidId, uint256 budget) returns(bytes32 sessionId) +func (_SessionRouter *SessionRouterTransactorSession) OpenSession(bidId [32]byte, budget *big.Int) (*types.Transaction, error) { + return _SessionRouter.Contract.OpenSession(&_SessionRouter.TransactOpts, bidId, budget) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_SessionRouter *SessionRouterTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { + return _SessionRouter.contract.Transact(opts, "renounceOwnership") +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_SessionRouter *SessionRouterSession) RenounceOwnership() (*types.Transaction, error) { + return _SessionRouter.Contract.RenounceOwnership(&_SessionRouter.TransactOpts) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_SessionRouter *SessionRouterTransactorSession) RenounceOwnership() (*types.Transaction, error) { + return _SessionRouter.Contract.RenounceOwnership(&_SessionRouter.TransactOpts) +} + +// SetStakeDelay is a paid mutator transaction binding the contract method 0x3cadd8bb. +// +// Solidity: function setStakeDelay(int256 delay) returns() +func (_SessionRouter *SessionRouterTransactor) SetStakeDelay(opts *bind.TransactOpts, delay *big.Int) (*types.Transaction, error) { + return _SessionRouter.contract.Transact(opts, "setStakeDelay", delay) +} + +// SetStakeDelay is a paid mutator transaction binding the contract method 0x3cadd8bb. +// +// Solidity: function setStakeDelay(int256 delay) returns() +func (_SessionRouter *SessionRouterSession) SetStakeDelay(delay *big.Int) (*types.Transaction, error) { + return _SessionRouter.Contract.SetStakeDelay(&_SessionRouter.TransactOpts, delay) +} + +// SetStakeDelay is a paid mutator transaction binding the contract method 0x3cadd8bb. +// +// Solidity: function setStakeDelay(int256 delay) returns() +func (_SessionRouter *SessionRouterTransactorSession) SetStakeDelay(delay *big.Int) (*types.Transaction, error) { + return _SessionRouter.Contract.SetStakeDelay(&_SessionRouter.TransactOpts, delay) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_SessionRouter *SessionRouterTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) { + return _SessionRouter.contract.Transact(opts, "transferOwnership", newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_SessionRouter *SessionRouterSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _SessionRouter.Contract.TransferOwnership(&_SessionRouter.TransactOpts, newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_SessionRouter *SessionRouterTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _SessionRouter.Contract.TransferOwnership(&_SessionRouter.TransactOpts, newOwner) +} + +// SessionRouterInitializedIterator is returned from FilterInitialized and is used to iterate over the raw logs and unpacked data for Initialized events raised by the SessionRouter contract. +type SessionRouterInitializedIterator struct { + Event *SessionRouterInitialized // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *SessionRouterInitializedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(SessionRouterInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(SessionRouterInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *SessionRouterInitializedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *SessionRouterInitializedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// SessionRouterInitialized represents a Initialized event raised by the SessionRouter contract. +type SessionRouterInitialized struct { + Version uint8 + Raw types.Log // Blockchain specific contextual infos +} + +// FilterInitialized is a free log retrieval operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_SessionRouter *SessionRouterFilterer) FilterInitialized(opts *bind.FilterOpts) (*SessionRouterInitializedIterator, error) { + + logs, sub, err := _SessionRouter.contract.FilterLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return &SessionRouterInitializedIterator{contract: _SessionRouter.contract, event: "Initialized", logs: logs, sub: sub}, nil +} + +// WatchInitialized is a free log subscription operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_SessionRouter *SessionRouterFilterer) WatchInitialized(opts *bind.WatchOpts, sink chan<- *SessionRouterInitialized) (event.Subscription, error) { + + logs, sub, err := _SessionRouter.contract.WatchLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(SessionRouterInitialized) + if err := _SessionRouter.contract.UnpackLog(event, "Initialized", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseInitialized is a log parse operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_SessionRouter *SessionRouterFilterer) ParseInitialized(log types.Log) (*SessionRouterInitialized, error) { + event := new(SessionRouterInitialized) + if err := _SessionRouter.contract.UnpackLog(event, "Initialized", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// SessionRouterOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the SessionRouter contract. +type SessionRouterOwnershipTransferredIterator struct { + Event *SessionRouterOwnershipTransferred // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *SessionRouterOwnershipTransferredIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(SessionRouterOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(SessionRouterOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *SessionRouterOwnershipTransferredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *SessionRouterOwnershipTransferredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// SessionRouterOwnershipTransferred represents a OwnershipTransferred event raised by the SessionRouter contract. +type SessionRouterOwnershipTransferred struct { + PreviousOwner common.Address + NewOwner common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_SessionRouter *SessionRouterFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*SessionRouterOwnershipTransferredIterator, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _SessionRouter.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return &SessionRouterOwnershipTransferredIterator{contract: _SessionRouter.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil +} + +// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_SessionRouter *SessionRouterFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *SessionRouterOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _SessionRouter.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(SessionRouterOwnershipTransferred) + if err := _SessionRouter.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_SessionRouter *SessionRouterFilterer) ParseOwnershipTransferred(log types.Log) (*SessionRouterOwnershipTransferred, error) { + event := new(SessionRouterOwnershipTransferred) + if err := _SessionRouter.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// SessionRouterProviderClaimedIterator is returned from FilterProviderClaimed and is used to iterate over the raw logs and unpacked data for ProviderClaimed events raised by the SessionRouter contract. +type SessionRouterProviderClaimedIterator struct { + Event *SessionRouterProviderClaimed // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *SessionRouterProviderClaimedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(SessionRouterProviderClaimed) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(SessionRouterProviderClaimed) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *SessionRouterProviderClaimedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *SessionRouterProviderClaimedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// SessionRouterProviderClaimed represents a ProviderClaimed event raised by the SessionRouter contract. +type SessionRouterProviderClaimed struct { + ProviderAddress common.Address + Amount *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterProviderClaimed is a free log retrieval operation binding the contract event 0x1cd322e3d02eade120b8dceb43a6c1dee437af36e7acd81726c4b54adf5584c2. +// +// Solidity: event ProviderClaimed(address indexed providerAddress, uint256 amount) +func (_SessionRouter *SessionRouterFilterer) FilterProviderClaimed(opts *bind.FilterOpts, providerAddress []common.Address) (*SessionRouterProviderClaimedIterator, error) { + + var providerAddressRule []interface{} + for _, providerAddressItem := range providerAddress { + providerAddressRule = append(providerAddressRule, providerAddressItem) + } + + logs, sub, err := _SessionRouter.contract.FilterLogs(opts, "ProviderClaimed", providerAddressRule) + if err != nil { + return nil, err + } + return &SessionRouterProviderClaimedIterator{contract: _SessionRouter.contract, event: "ProviderClaimed", logs: logs, sub: sub}, nil +} + +// WatchProviderClaimed is a free log subscription operation binding the contract event 0x1cd322e3d02eade120b8dceb43a6c1dee437af36e7acd81726c4b54adf5584c2. +// +// Solidity: event ProviderClaimed(address indexed providerAddress, uint256 amount) +func (_SessionRouter *SessionRouterFilterer) WatchProviderClaimed(opts *bind.WatchOpts, sink chan<- *SessionRouterProviderClaimed, providerAddress []common.Address) (event.Subscription, error) { + + var providerAddressRule []interface{} + for _, providerAddressItem := range providerAddress { + providerAddressRule = append(providerAddressRule, providerAddressItem) + } + + logs, sub, err := _SessionRouter.contract.WatchLogs(opts, "ProviderClaimed", providerAddressRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(SessionRouterProviderClaimed) + if err := _SessionRouter.contract.UnpackLog(event, "ProviderClaimed", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseProviderClaimed is a log parse operation binding the contract event 0x1cd322e3d02eade120b8dceb43a6c1dee437af36e7acd81726c4b54adf5584c2. +// +// Solidity: event ProviderClaimed(address indexed providerAddress, uint256 amount) +func (_SessionRouter *SessionRouterFilterer) ParseProviderClaimed(log types.Log) (*SessionRouterProviderClaimed, error) { + event := new(SessionRouterProviderClaimed) + if err := _SessionRouter.contract.UnpackLog(event, "ProviderClaimed", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// SessionRouterSessionClosedIterator is returned from FilterSessionClosed and is used to iterate over the raw logs and unpacked data for SessionClosed events raised by the SessionRouter contract. +type SessionRouterSessionClosedIterator struct { + Event *SessionRouterSessionClosed // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *SessionRouterSessionClosedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(SessionRouterSessionClosed) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(SessionRouterSessionClosed) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *SessionRouterSessionClosedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *SessionRouterSessionClosedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// SessionRouterSessionClosed represents a SessionClosed event raised by the SessionRouter contract. +type SessionRouterSessionClosed struct { + UserAddress common.Address + SessionId [32]byte + ProviderId common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterSessionClosed is a free log retrieval operation binding the contract event 0x337fbb0a41a596db800dc836595a57815f967185e3596615c646f2455ac3914a. +// +// Solidity: event SessionClosed(address indexed userAddress, bytes32 indexed sessionId, address indexed providerId) +func (_SessionRouter *SessionRouterFilterer) FilterSessionClosed(opts *bind.FilterOpts, userAddress []common.Address, sessionId [][32]byte, providerId []common.Address) (*SessionRouterSessionClosedIterator, error) { + + var userAddressRule []interface{} + for _, userAddressItem := range userAddress { + userAddressRule = append(userAddressRule, userAddressItem) + } + var sessionIdRule []interface{} + for _, sessionIdItem := range sessionId { + sessionIdRule = append(sessionIdRule, sessionIdItem) + } + var providerIdRule []interface{} + for _, providerIdItem := range providerId { + providerIdRule = append(providerIdRule, providerIdItem) + } + + logs, sub, err := _SessionRouter.contract.FilterLogs(opts, "SessionClosed", userAddressRule, sessionIdRule, providerIdRule) + if err != nil { + return nil, err + } + return &SessionRouterSessionClosedIterator{contract: _SessionRouter.contract, event: "SessionClosed", logs: logs, sub: sub}, nil +} + +// WatchSessionClosed is a free log subscription operation binding the contract event 0x337fbb0a41a596db800dc836595a57815f967185e3596615c646f2455ac3914a. +// +// Solidity: event SessionClosed(address indexed userAddress, bytes32 indexed sessionId, address indexed providerId) +func (_SessionRouter *SessionRouterFilterer) WatchSessionClosed(opts *bind.WatchOpts, sink chan<- *SessionRouterSessionClosed, userAddress []common.Address, sessionId [][32]byte, providerId []common.Address) (event.Subscription, error) { + + var userAddressRule []interface{} + for _, userAddressItem := range userAddress { + userAddressRule = append(userAddressRule, userAddressItem) + } + var sessionIdRule []interface{} + for _, sessionIdItem := range sessionId { + sessionIdRule = append(sessionIdRule, sessionIdItem) + } + var providerIdRule []interface{} + for _, providerIdItem := range providerId { + providerIdRule = append(providerIdRule, providerIdItem) + } + + logs, sub, err := _SessionRouter.contract.WatchLogs(opts, "SessionClosed", userAddressRule, sessionIdRule, providerIdRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(SessionRouterSessionClosed) + if err := _SessionRouter.contract.UnpackLog(event, "SessionClosed", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseSessionClosed is a log parse operation binding the contract event 0x337fbb0a41a596db800dc836595a57815f967185e3596615c646f2455ac3914a. +// +// Solidity: event SessionClosed(address indexed userAddress, bytes32 indexed sessionId, address indexed providerId) +func (_SessionRouter *SessionRouterFilterer) ParseSessionClosed(log types.Log) (*SessionRouterSessionClosed, error) { + event := new(SessionRouterSessionClosed) + if err := _SessionRouter.contract.UnpackLog(event, "SessionClosed", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// SessionRouterSessionOpenedIterator is returned from FilterSessionOpened and is used to iterate over the raw logs and unpacked data for SessionOpened events raised by the SessionRouter contract. +type SessionRouterSessionOpenedIterator struct { + Event *SessionRouterSessionOpened // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *SessionRouterSessionOpenedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(SessionRouterSessionOpened) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(SessionRouterSessionOpened) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *SessionRouterSessionOpenedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *SessionRouterSessionOpenedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// SessionRouterSessionOpened represents a SessionOpened event raised by the SessionRouter contract. +type SessionRouterSessionOpened struct { + UserAddress common.Address + SessionId [32]byte + ProviderId common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterSessionOpened is a free log retrieval operation binding the contract event 0x2bd7c890baf595977d256a6e784512c873ac58ba612b4895dbb7f784bfbf4839. +// +// Solidity: event SessionOpened(address indexed userAddress, bytes32 indexed sessionId, address indexed providerId) +func (_SessionRouter *SessionRouterFilterer) FilterSessionOpened(opts *bind.FilterOpts, userAddress []common.Address, sessionId [][32]byte, providerId []common.Address) (*SessionRouterSessionOpenedIterator, error) { + + var userAddressRule []interface{} + for _, userAddressItem := range userAddress { + userAddressRule = append(userAddressRule, userAddressItem) + } + var sessionIdRule []interface{} + for _, sessionIdItem := range sessionId { + sessionIdRule = append(sessionIdRule, sessionIdItem) + } + var providerIdRule []interface{} + for _, providerIdItem := range providerId { + providerIdRule = append(providerIdRule, providerIdItem) + } + + logs, sub, err := _SessionRouter.contract.FilterLogs(opts, "SessionOpened", userAddressRule, sessionIdRule, providerIdRule) + if err != nil { + return nil, err + } + return &SessionRouterSessionOpenedIterator{contract: _SessionRouter.contract, event: "SessionOpened", logs: logs, sub: sub}, nil +} + +// WatchSessionOpened is a free log subscription operation binding the contract event 0x2bd7c890baf595977d256a6e784512c873ac58ba612b4895dbb7f784bfbf4839. +// +// Solidity: event SessionOpened(address indexed userAddress, bytes32 indexed sessionId, address indexed providerId) +func (_SessionRouter *SessionRouterFilterer) WatchSessionOpened(opts *bind.WatchOpts, sink chan<- *SessionRouterSessionOpened, userAddress []common.Address, sessionId [][32]byte, providerId []common.Address) (event.Subscription, error) { + + var userAddressRule []interface{} + for _, userAddressItem := range userAddress { + userAddressRule = append(userAddressRule, userAddressItem) + } + var sessionIdRule []interface{} + for _, sessionIdItem := range sessionId { + sessionIdRule = append(sessionIdRule, sessionIdItem) + } + var providerIdRule []interface{} + for _, providerIdItem := range providerId { + providerIdRule = append(providerIdRule, providerIdItem) + } + + logs, sub, err := _SessionRouter.contract.WatchLogs(opts, "SessionOpened", userAddressRule, sessionIdRule, providerIdRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(SessionRouterSessionOpened) + if err := _SessionRouter.contract.UnpackLog(event, "SessionOpened", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseSessionOpened is a log parse operation binding the contract event 0x2bd7c890baf595977d256a6e784512c873ac58ba612b4895dbb7f784bfbf4839. +// +// Solidity: event SessionOpened(address indexed userAddress, bytes32 indexed sessionId, address indexed providerId) +func (_SessionRouter *SessionRouterFilterer) ParseSessionOpened(log types.Log) (*SessionRouterSessionOpened, error) { + event := new(SessionRouterSessionOpened) + if err := _SessionRouter.contract.UnpackLog(event, "SessionOpened", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// SessionRouterStakedIterator is returned from FilterStaked and is used to iterate over the raw logs and unpacked data for Staked events raised by the SessionRouter contract. +type SessionRouterStakedIterator struct { + Event *SessionRouterStaked // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *SessionRouterStakedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(SessionRouterStaked) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(SessionRouterStaked) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *SessionRouterStakedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *SessionRouterStakedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// SessionRouterStaked represents a Staked event raised by the SessionRouter contract. +type SessionRouterStaked struct { + UserAddress common.Address + Amount *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterStaked is a free log retrieval operation binding the contract event 0x9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d. +// +// Solidity: event Staked(address indexed userAddress, uint256 amount) +func (_SessionRouter *SessionRouterFilterer) FilterStaked(opts *bind.FilterOpts, userAddress []common.Address) (*SessionRouterStakedIterator, error) { + + var userAddressRule []interface{} + for _, userAddressItem := range userAddress { + userAddressRule = append(userAddressRule, userAddressItem) + } + + logs, sub, err := _SessionRouter.contract.FilterLogs(opts, "Staked", userAddressRule) + if err != nil { + return nil, err + } + return &SessionRouterStakedIterator{contract: _SessionRouter.contract, event: "Staked", logs: logs, sub: sub}, nil +} + +// WatchStaked is a free log subscription operation binding the contract event 0x9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d. +// +// Solidity: event Staked(address indexed userAddress, uint256 amount) +func (_SessionRouter *SessionRouterFilterer) WatchStaked(opts *bind.WatchOpts, sink chan<- *SessionRouterStaked, userAddress []common.Address) (event.Subscription, error) { + + var userAddressRule []interface{} + for _, userAddressItem := range userAddress { + userAddressRule = append(userAddressRule, userAddressItem) + } + + logs, sub, err := _SessionRouter.contract.WatchLogs(opts, "Staked", userAddressRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(SessionRouterStaked) + if err := _SessionRouter.contract.UnpackLog(event, "Staked", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseStaked is a log parse operation binding the contract event 0x9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d. +// +// Solidity: event Staked(address indexed userAddress, uint256 amount) +func (_SessionRouter *SessionRouterFilterer) ParseStaked(log types.Log) (*SessionRouterStaked, error) { + event := new(SessionRouterStaked) + if err := _SessionRouter.contract.UnpackLog(event, "Staked", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// SessionRouterUnstakedIterator is returned from FilterUnstaked and is used to iterate over the raw logs and unpacked data for Unstaked events raised by the SessionRouter contract. +type SessionRouterUnstakedIterator struct { + Event *SessionRouterUnstaked // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *SessionRouterUnstakedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(SessionRouterUnstaked) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(SessionRouterUnstaked) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *SessionRouterUnstakedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *SessionRouterUnstakedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// SessionRouterUnstaked represents a Unstaked event raised by the SessionRouter contract. +type SessionRouterUnstaked struct { + UserAddress common.Address + Amount *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterUnstaked is a free log retrieval operation binding the contract event 0x0f5bb82176feb1b5e747e28471aa92156a04d9f3ab9f45f28e2d704232b93f75. +// +// Solidity: event Unstaked(address indexed userAddress, uint256 amount) +func (_SessionRouter *SessionRouterFilterer) FilterUnstaked(opts *bind.FilterOpts, userAddress []common.Address) (*SessionRouterUnstakedIterator, error) { + + var userAddressRule []interface{} + for _, userAddressItem := range userAddress { + userAddressRule = append(userAddressRule, userAddressItem) + } + + logs, sub, err := _SessionRouter.contract.FilterLogs(opts, "Unstaked", userAddressRule) + if err != nil { + return nil, err + } + return &SessionRouterUnstakedIterator{contract: _SessionRouter.contract, event: "Unstaked", logs: logs, sub: sub}, nil +} + +// WatchUnstaked is a free log subscription operation binding the contract event 0x0f5bb82176feb1b5e747e28471aa92156a04d9f3ab9f45f28e2d704232b93f75. +// +// Solidity: event Unstaked(address indexed userAddress, uint256 amount) +func (_SessionRouter *SessionRouterFilterer) WatchUnstaked(opts *bind.WatchOpts, sink chan<- *SessionRouterUnstaked, userAddress []common.Address) (event.Subscription, error) { + + var userAddressRule []interface{} + for _, userAddressItem := range userAddress { + userAddressRule = append(userAddressRule, userAddressItem) + } + + logs, sub, err := _SessionRouter.contract.WatchLogs(opts, "Unstaked", userAddressRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(SessionRouterUnstaked) + if err := _SessionRouter.contract.UnpackLog(event, "Unstaked", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseUnstaked is a log parse operation binding the contract event 0x0f5bb82176feb1b5e747e28471aa92156a04d9f3ab9f45f28e2d704232b93f75. +// +// Solidity: event Unstaked(address indexed userAddress, uint256 amount) +func (_SessionRouter *SessionRouterFilterer) ParseUnstaked(log types.Log) (*SessionRouterUnstaked, error) { + event := new(SessionRouterUnstaked) + if err := _SessionRouter.contract.UnpackLog(event, "Unstaked", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/smart-contracts/bindings/go/contracts/stakingdailystipend/StakingDailyStipend.go b/smart-contracts/bindings/go/contracts/stakingdailystipend/StakingDailyStipend.go new file mode 100644 index 00000000..08a3dbdf --- /dev/null +++ b/smart-contracts/bindings/go/contracts/stakingdailystipend/StakingDailyStipend.go @@ -0,0 +1,1291 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package stakingdailystipend + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription + _ = abi.ConvertType +) + +// StakingDailyStipendMetaData contains all meta data concerning the StakingDailyStipend contract. +var StakingDailyStipendMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[],\"name\":\"NotEnoughDailyStipend\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotEnoughStake\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotSenderOrOwner\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotSessionRouterOrOwner\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"userAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Staked\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"userAddress\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Unstaked\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"userAddress\",\"type\":\"address\"}],\"name\":\"balanceOfDailyStipend\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getComputeBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"userAddress\",\"type\":\"address\"}],\"name\":\"getStakeOnHold\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getTodaysBudget\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"userAddress\",\"type\":\"address\"}],\"name\":\"getTodaysSpend\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_tokenAccount\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"returnStipend\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"sessionRouter\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"stake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"todaysSpend\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"releaseAt\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"token\",\"outputs\":[{\"internalType\":\"contractIERC20\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"tokenAccount\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferDailyStipend\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"sendToAddr\",\"type\":\"address\"}],\"name\":\"unstake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"userStake\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"userAddress\",\"type\":\"address\"}],\"name\":\"withdrawableStakeBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", +} + +// StakingDailyStipendABI is the input ABI used to generate the binding from. +// Deprecated: Use StakingDailyStipendMetaData.ABI instead. +var StakingDailyStipendABI = StakingDailyStipendMetaData.ABI + +// StakingDailyStipend is an auto generated Go binding around an Ethereum contract. +type StakingDailyStipend struct { + StakingDailyStipendCaller // Read-only binding to the contract + StakingDailyStipendTransactor // Write-only binding to the contract + StakingDailyStipendFilterer // Log filterer for contract events +} + +// StakingDailyStipendCaller is an auto generated read-only Go binding around an Ethereum contract. +type StakingDailyStipendCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// StakingDailyStipendTransactor is an auto generated write-only Go binding around an Ethereum contract. +type StakingDailyStipendTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// StakingDailyStipendFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type StakingDailyStipendFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// StakingDailyStipendSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type StakingDailyStipendSession struct { + Contract *StakingDailyStipend // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// StakingDailyStipendCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type StakingDailyStipendCallerSession struct { + Contract *StakingDailyStipendCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// StakingDailyStipendTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type StakingDailyStipendTransactorSession struct { + Contract *StakingDailyStipendTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// StakingDailyStipendRaw is an auto generated low-level Go binding around an Ethereum contract. +type StakingDailyStipendRaw struct { + Contract *StakingDailyStipend // Generic contract binding to access the raw methods on +} + +// StakingDailyStipendCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type StakingDailyStipendCallerRaw struct { + Contract *StakingDailyStipendCaller // Generic read-only contract binding to access the raw methods on +} + +// StakingDailyStipendTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type StakingDailyStipendTransactorRaw struct { + Contract *StakingDailyStipendTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewStakingDailyStipend creates a new instance of StakingDailyStipend, bound to a specific deployed contract. +func NewStakingDailyStipend(address common.Address, backend bind.ContractBackend) (*StakingDailyStipend, error) { + contract, err := bindStakingDailyStipend(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &StakingDailyStipend{StakingDailyStipendCaller: StakingDailyStipendCaller{contract: contract}, StakingDailyStipendTransactor: StakingDailyStipendTransactor{contract: contract}, StakingDailyStipendFilterer: StakingDailyStipendFilterer{contract: contract}}, nil +} + +// NewStakingDailyStipendCaller creates a new read-only instance of StakingDailyStipend, bound to a specific deployed contract. +func NewStakingDailyStipendCaller(address common.Address, caller bind.ContractCaller) (*StakingDailyStipendCaller, error) { + contract, err := bindStakingDailyStipend(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &StakingDailyStipendCaller{contract: contract}, nil +} + +// NewStakingDailyStipendTransactor creates a new write-only instance of StakingDailyStipend, bound to a specific deployed contract. +func NewStakingDailyStipendTransactor(address common.Address, transactor bind.ContractTransactor) (*StakingDailyStipendTransactor, error) { + contract, err := bindStakingDailyStipend(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &StakingDailyStipendTransactor{contract: contract}, nil +} + +// NewStakingDailyStipendFilterer creates a new log filterer instance of StakingDailyStipend, bound to a specific deployed contract. +func NewStakingDailyStipendFilterer(address common.Address, filterer bind.ContractFilterer) (*StakingDailyStipendFilterer, error) { + contract, err := bindStakingDailyStipend(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &StakingDailyStipendFilterer{contract: contract}, nil +} + +// bindStakingDailyStipend binds a generic wrapper to an already deployed contract. +func bindStakingDailyStipend(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := StakingDailyStipendMetaData.GetAbi() + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_StakingDailyStipend *StakingDailyStipendRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _StakingDailyStipend.Contract.StakingDailyStipendCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_StakingDailyStipend *StakingDailyStipendRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _StakingDailyStipend.Contract.StakingDailyStipendTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_StakingDailyStipend *StakingDailyStipendRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _StakingDailyStipend.Contract.StakingDailyStipendTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_StakingDailyStipend *StakingDailyStipendCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _StakingDailyStipend.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_StakingDailyStipend *StakingDailyStipendTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _StakingDailyStipend.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_StakingDailyStipend *StakingDailyStipendTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _StakingDailyStipend.Contract.contract.Transact(opts, method, params...) +} + +// BalanceOfDailyStipend is a free data retrieval call binding the contract method 0xf0612b48. +// +// Solidity: function balanceOfDailyStipend(address userAddress) view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendCaller) BalanceOfDailyStipend(opts *bind.CallOpts, userAddress common.Address) (*big.Int, error) { + var out []interface{} + err := _StakingDailyStipend.contract.Call(opts, &out, "balanceOfDailyStipend", userAddress) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// BalanceOfDailyStipend is a free data retrieval call binding the contract method 0xf0612b48. +// +// Solidity: function balanceOfDailyStipend(address userAddress) view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendSession) BalanceOfDailyStipend(userAddress common.Address) (*big.Int, error) { + return _StakingDailyStipend.Contract.BalanceOfDailyStipend(&_StakingDailyStipend.CallOpts, userAddress) +} + +// BalanceOfDailyStipend is a free data retrieval call binding the contract method 0xf0612b48. +// +// Solidity: function balanceOfDailyStipend(address userAddress) view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendCallerSession) BalanceOfDailyStipend(userAddress common.Address) (*big.Int, error) { + return _StakingDailyStipend.Contract.BalanceOfDailyStipend(&_StakingDailyStipend.CallOpts, userAddress) +} + +// GetComputeBalance is a free data retrieval call binding the contract method 0x653cdf0c. +// +// Solidity: function getComputeBalance() view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendCaller) GetComputeBalance(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _StakingDailyStipend.contract.Call(opts, &out, "getComputeBalance") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetComputeBalance is a free data retrieval call binding the contract method 0x653cdf0c. +// +// Solidity: function getComputeBalance() view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendSession) GetComputeBalance() (*big.Int, error) { + return _StakingDailyStipend.Contract.GetComputeBalance(&_StakingDailyStipend.CallOpts) +} + +// GetComputeBalance is a free data retrieval call binding the contract method 0x653cdf0c. +// +// Solidity: function getComputeBalance() view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendCallerSession) GetComputeBalance() (*big.Int, error) { + return _StakingDailyStipend.Contract.GetComputeBalance(&_StakingDailyStipend.CallOpts) +} + +// GetStakeOnHold is a free data retrieval call binding the contract method 0x9bc65da5. +// +// Solidity: function getStakeOnHold(address userAddress) view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendCaller) GetStakeOnHold(opts *bind.CallOpts, userAddress common.Address) (*big.Int, error) { + var out []interface{} + err := _StakingDailyStipend.contract.Call(opts, &out, "getStakeOnHold", userAddress) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetStakeOnHold is a free data retrieval call binding the contract method 0x9bc65da5. +// +// Solidity: function getStakeOnHold(address userAddress) view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendSession) GetStakeOnHold(userAddress common.Address) (*big.Int, error) { + return _StakingDailyStipend.Contract.GetStakeOnHold(&_StakingDailyStipend.CallOpts, userAddress) +} + +// GetStakeOnHold is a free data retrieval call binding the contract method 0x9bc65da5. +// +// Solidity: function getStakeOnHold(address userAddress) view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendCallerSession) GetStakeOnHold(userAddress common.Address) (*big.Int, error) { + return _StakingDailyStipend.Contract.GetStakeOnHold(&_StakingDailyStipend.CallOpts, userAddress) +} + +// GetTodaysBudget is a free data retrieval call binding the contract method 0xa7e7f9a9. +// +// Solidity: function getTodaysBudget() view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendCaller) GetTodaysBudget(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _StakingDailyStipend.contract.Call(opts, &out, "getTodaysBudget") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetTodaysBudget is a free data retrieval call binding the contract method 0xa7e7f9a9. +// +// Solidity: function getTodaysBudget() view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendSession) GetTodaysBudget() (*big.Int, error) { + return _StakingDailyStipend.Contract.GetTodaysBudget(&_StakingDailyStipend.CallOpts) +} + +// GetTodaysBudget is a free data retrieval call binding the contract method 0xa7e7f9a9. +// +// Solidity: function getTodaysBudget() view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendCallerSession) GetTodaysBudget() (*big.Int, error) { + return _StakingDailyStipend.Contract.GetTodaysBudget(&_StakingDailyStipend.CallOpts) +} + +// GetTodaysSpend is a free data retrieval call binding the contract method 0x02fc4ec8. +// +// Solidity: function getTodaysSpend(address userAddress) view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendCaller) GetTodaysSpend(opts *bind.CallOpts, userAddress common.Address) (*big.Int, error) { + var out []interface{} + err := _StakingDailyStipend.contract.Call(opts, &out, "getTodaysSpend", userAddress) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetTodaysSpend is a free data retrieval call binding the contract method 0x02fc4ec8. +// +// Solidity: function getTodaysSpend(address userAddress) view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendSession) GetTodaysSpend(userAddress common.Address) (*big.Int, error) { + return _StakingDailyStipend.Contract.GetTodaysSpend(&_StakingDailyStipend.CallOpts, userAddress) +} + +// GetTodaysSpend is a free data retrieval call binding the contract method 0x02fc4ec8. +// +// Solidity: function getTodaysSpend(address userAddress) view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendCallerSession) GetTodaysSpend(userAddress common.Address) (*big.Int, error) { + return _StakingDailyStipend.Contract.GetTodaysSpend(&_StakingDailyStipend.CallOpts, userAddress) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_StakingDailyStipend *StakingDailyStipendCaller) Owner(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _StakingDailyStipend.contract.Call(opts, &out, "owner") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_StakingDailyStipend *StakingDailyStipendSession) Owner() (common.Address, error) { + return _StakingDailyStipend.Contract.Owner(&_StakingDailyStipend.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_StakingDailyStipend *StakingDailyStipendCallerSession) Owner() (common.Address, error) { + return _StakingDailyStipend.Contract.Owner(&_StakingDailyStipend.CallOpts) +} + +// SessionRouter is a free data retrieval call binding the contract method 0x707ba08a. +// +// Solidity: function sessionRouter() view returns(address) +func (_StakingDailyStipend *StakingDailyStipendCaller) SessionRouter(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _StakingDailyStipend.contract.Call(opts, &out, "sessionRouter") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// SessionRouter is a free data retrieval call binding the contract method 0x707ba08a. +// +// Solidity: function sessionRouter() view returns(address) +func (_StakingDailyStipend *StakingDailyStipendSession) SessionRouter() (common.Address, error) { + return _StakingDailyStipend.Contract.SessionRouter(&_StakingDailyStipend.CallOpts) +} + +// SessionRouter is a free data retrieval call binding the contract method 0x707ba08a. +// +// Solidity: function sessionRouter() view returns(address) +func (_StakingDailyStipend *StakingDailyStipendCallerSession) SessionRouter() (common.Address, error) { + return _StakingDailyStipend.Contract.SessionRouter(&_StakingDailyStipend.CallOpts) +} + +// TodaysSpend is a free data retrieval call binding the contract method 0x9b6e4a06. +// +// Solidity: function todaysSpend(address ) view returns(uint256 amount, uint256 releaseAt) +func (_StakingDailyStipend *StakingDailyStipendCaller) TodaysSpend(opts *bind.CallOpts, arg0 common.Address) (struct { + Amount *big.Int + ReleaseAt *big.Int +}, error) { + var out []interface{} + err := _StakingDailyStipend.contract.Call(opts, &out, "todaysSpend", arg0) + + outstruct := new(struct { + Amount *big.Int + ReleaseAt *big.Int + }) + if err != nil { + return *outstruct, err + } + + outstruct.Amount = *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + outstruct.ReleaseAt = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) + + return *outstruct, err + +} + +// TodaysSpend is a free data retrieval call binding the contract method 0x9b6e4a06. +// +// Solidity: function todaysSpend(address ) view returns(uint256 amount, uint256 releaseAt) +func (_StakingDailyStipend *StakingDailyStipendSession) TodaysSpend(arg0 common.Address) (struct { + Amount *big.Int + ReleaseAt *big.Int +}, error) { + return _StakingDailyStipend.Contract.TodaysSpend(&_StakingDailyStipend.CallOpts, arg0) +} + +// TodaysSpend is a free data retrieval call binding the contract method 0x9b6e4a06. +// +// Solidity: function todaysSpend(address ) view returns(uint256 amount, uint256 releaseAt) +func (_StakingDailyStipend *StakingDailyStipendCallerSession) TodaysSpend(arg0 common.Address) (struct { + Amount *big.Int + ReleaseAt *big.Int +}, error) { + return _StakingDailyStipend.Contract.TodaysSpend(&_StakingDailyStipend.CallOpts, arg0) +} + +// Token is a free data retrieval call binding the contract method 0xfc0c546a. +// +// Solidity: function token() view returns(address) +func (_StakingDailyStipend *StakingDailyStipendCaller) Token(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _StakingDailyStipend.contract.Call(opts, &out, "token") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Token is a free data retrieval call binding the contract method 0xfc0c546a. +// +// Solidity: function token() view returns(address) +func (_StakingDailyStipend *StakingDailyStipendSession) Token() (common.Address, error) { + return _StakingDailyStipend.Contract.Token(&_StakingDailyStipend.CallOpts) +} + +// Token is a free data retrieval call binding the contract method 0xfc0c546a. +// +// Solidity: function token() view returns(address) +func (_StakingDailyStipend *StakingDailyStipendCallerSession) Token() (common.Address, error) { + return _StakingDailyStipend.Contract.Token(&_StakingDailyStipend.CallOpts) +} + +// TokenAccount is a free data retrieval call binding the contract method 0x30ddebcb. +// +// Solidity: function tokenAccount() view returns(address) +func (_StakingDailyStipend *StakingDailyStipendCaller) TokenAccount(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _StakingDailyStipend.contract.Call(opts, &out, "tokenAccount") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// TokenAccount is a free data retrieval call binding the contract method 0x30ddebcb. +// +// Solidity: function tokenAccount() view returns(address) +func (_StakingDailyStipend *StakingDailyStipendSession) TokenAccount() (common.Address, error) { + return _StakingDailyStipend.Contract.TokenAccount(&_StakingDailyStipend.CallOpts) +} + +// TokenAccount is a free data retrieval call binding the contract method 0x30ddebcb. +// +// Solidity: function tokenAccount() view returns(address) +func (_StakingDailyStipend *StakingDailyStipendCallerSession) TokenAccount() (common.Address, error) { + return _StakingDailyStipend.Contract.TokenAccount(&_StakingDailyStipend.CallOpts) +} + +// UserStake is a free data retrieval call binding the contract method 0x68e5585d. +// +// Solidity: function userStake(address ) view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendCaller) UserStake(opts *bind.CallOpts, arg0 common.Address) (*big.Int, error) { + var out []interface{} + err := _StakingDailyStipend.contract.Call(opts, &out, "userStake", arg0) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// UserStake is a free data retrieval call binding the contract method 0x68e5585d. +// +// Solidity: function userStake(address ) view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendSession) UserStake(arg0 common.Address) (*big.Int, error) { + return _StakingDailyStipend.Contract.UserStake(&_StakingDailyStipend.CallOpts, arg0) +} + +// UserStake is a free data retrieval call binding the contract method 0x68e5585d. +// +// Solidity: function userStake(address ) view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendCallerSession) UserStake(arg0 common.Address) (*big.Int, error) { + return _StakingDailyStipend.Contract.UserStake(&_StakingDailyStipend.CallOpts, arg0) +} + +// WithdrawableStakeBalance is a free data retrieval call binding the contract method 0x7594e4d9. +// +// Solidity: function withdrawableStakeBalance(address userAddress) view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendCaller) WithdrawableStakeBalance(opts *bind.CallOpts, userAddress common.Address) (*big.Int, error) { + var out []interface{} + err := _StakingDailyStipend.contract.Call(opts, &out, "withdrawableStakeBalance", userAddress) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// WithdrawableStakeBalance is a free data retrieval call binding the contract method 0x7594e4d9. +// +// Solidity: function withdrawableStakeBalance(address userAddress) view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendSession) WithdrawableStakeBalance(userAddress common.Address) (*big.Int, error) { + return _StakingDailyStipend.Contract.WithdrawableStakeBalance(&_StakingDailyStipend.CallOpts, userAddress) +} + +// WithdrawableStakeBalance is a free data retrieval call binding the contract method 0x7594e4d9. +// +// Solidity: function withdrawableStakeBalance(address userAddress) view returns(uint256) +func (_StakingDailyStipend *StakingDailyStipendCallerSession) WithdrawableStakeBalance(userAddress common.Address) (*big.Int, error) { + return _StakingDailyStipend.Contract.WithdrawableStakeBalance(&_StakingDailyStipend.CallOpts, userAddress) +} + +// Initialize is a paid mutator transaction binding the contract method 0x485cc955. +// +// Solidity: function initialize(address _token, address _tokenAccount) returns() +func (_StakingDailyStipend *StakingDailyStipendTransactor) Initialize(opts *bind.TransactOpts, _token common.Address, _tokenAccount common.Address) (*types.Transaction, error) { + return _StakingDailyStipend.contract.Transact(opts, "initialize", _token, _tokenAccount) +} + +// Initialize is a paid mutator transaction binding the contract method 0x485cc955. +// +// Solidity: function initialize(address _token, address _tokenAccount) returns() +func (_StakingDailyStipend *StakingDailyStipendSession) Initialize(_token common.Address, _tokenAccount common.Address) (*types.Transaction, error) { + return _StakingDailyStipend.Contract.Initialize(&_StakingDailyStipend.TransactOpts, _token, _tokenAccount) +} + +// Initialize is a paid mutator transaction binding the contract method 0x485cc955. +// +// Solidity: function initialize(address _token, address _tokenAccount) returns() +func (_StakingDailyStipend *StakingDailyStipendTransactorSession) Initialize(_token common.Address, _tokenAccount common.Address) (*types.Transaction, error) { + return _StakingDailyStipend.Contract.Initialize(&_StakingDailyStipend.TransactOpts, _token, _tokenAccount) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_StakingDailyStipend *StakingDailyStipendTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { + return _StakingDailyStipend.contract.Transact(opts, "renounceOwnership") +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_StakingDailyStipend *StakingDailyStipendSession) RenounceOwnership() (*types.Transaction, error) { + return _StakingDailyStipend.Contract.RenounceOwnership(&_StakingDailyStipend.TransactOpts) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_StakingDailyStipend *StakingDailyStipendTransactorSession) RenounceOwnership() (*types.Transaction, error) { + return _StakingDailyStipend.Contract.RenounceOwnership(&_StakingDailyStipend.TransactOpts) +} + +// ReturnStipend is a paid mutator transaction binding the contract method 0x93c87377. +// +// Solidity: function returnStipend(address to, uint256 amount) returns() +func (_StakingDailyStipend *StakingDailyStipendTransactor) ReturnStipend(opts *bind.TransactOpts, to common.Address, amount *big.Int) (*types.Transaction, error) { + return _StakingDailyStipend.contract.Transact(opts, "returnStipend", to, amount) +} + +// ReturnStipend is a paid mutator transaction binding the contract method 0x93c87377. +// +// Solidity: function returnStipend(address to, uint256 amount) returns() +func (_StakingDailyStipend *StakingDailyStipendSession) ReturnStipend(to common.Address, amount *big.Int) (*types.Transaction, error) { + return _StakingDailyStipend.Contract.ReturnStipend(&_StakingDailyStipend.TransactOpts, to, amount) +} + +// ReturnStipend is a paid mutator transaction binding the contract method 0x93c87377. +// +// Solidity: function returnStipend(address to, uint256 amount) returns() +func (_StakingDailyStipend *StakingDailyStipendTransactorSession) ReturnStipend(to common.Address, amount *big.Int) (*types.Transaction, error) { + return _StakingDailyStipend.Contract.ReturnStipend(&_StakingDailyStipend.TransactOpts, to, amount) +} + +// Stake is a paid mutator transaction binding the contract method 0xadc9772e. +// +// Solidity: function stake(address addr, uint256 amount) returns() +func (_StakingDailyStipend *StakingDailyStipendTransactor) Stake(opts *bind.TransactOpts, addr common.Address, amount *big.Int) (*types.Transaction, error) { + return _StakingDailyStipend.contract.Transact(opts, "stake", addr, amount) +} + +// Stake is a paid mutator transaction binding the contract method 0xadc9772e. +// +// Solidity: function stake(address addr, uint256 amount) returns() +func (_StakingDailyStipend *StakingDailyStipendSession) Stake(addr common.Address, amount *big.Int) (*types.Transaction, error) { + return _StakingDailyStipend.Contract.Stake(&_StakingDailyStipend.TransactOpts, addr, amount) +} + +// Stake is a paid mutator transaction binding the contract method 0xadc9772e. +// +// Solidity: function stake(address addr, uint256 amount) returns() +func (_StakingDailyStipend *StakingDailyStipendTransactorSession) Stake(addr common.Address, amount *big.Int) (*types.Transaction, error) { + return _StakingDailyStipend.Contract.Stake(&_StakingDailyStipend.TransactOpts, addr, amount) +} + +// TransferDailyStipend is a paid mutator transaction binding the contract method 0x93a7483a. +// +// Solidity: function transferDailyStipend(address from, address to, uint256 amount) returns() +func (_StakingDailyStipend *StakingDailyStipendTransactor) TransferDailyStipend(opts *bind.TransactOpts, from common.Address, to common.Address, amount *big.Int) (*types.Transaction, error) { + return _StakingDailyStipend.contract.Transact(opts, "transferDailyStipend", from, to, amount) +} + +// TransferDailyStipend is a paid mutator transaction binding the contract method 0x93a7483a. +// +// Solidity: function transferDailyStipend(address from, address to, uint256 amount) returns() +func (_StakingDailyStipend *StakingDailyStipendSession) TransferDailyStipend(from common.Address, to common.Address, amount *big.Int) (*types.Transaction, error) { + return _StakingDailyStipend.Contract.TransferDailyStipend(&_StakingDailyStipend.TransactOpts, from, to, amount) +} + +// TransferDailyStipend is a paid mutator transaction binding the contract method 0x93a7483a. +// +// Solidity: function transferDailyStipend(address from, address to, uint256 amount) returns() +func (_StakingDailyStipend *StakingDailyStipendTransactorSession) TransferDailyStipend(from common.Address, to common.Address, amount *big.Int) (*types.Transaction, error) { + return _StakingDailyStipend.Contract.TransferDailyStipend(&_StakingDailyStipend.TransactOpts, from, to, amount) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_StakingDailyStipend *StakingDailyStipendTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) { + return _StakingDailyStipend.contract.Transact(opts, "transferOwnership", newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_StakingDailyStipend *StakingDailyStipendSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _StakingDailyStipend.Contract.TransferOwnership(&_StakingDailyStipend.TransactOpts, newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_StakingDailyStipend *StakingDailyStipendTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _StakingDailyStipend.Contract.TransferOwnership(&_StakingDailyStipend.TransactOpts, newOwner) +} + +// Unstake is a paid mutator transaction binding the contract method 0x926e31d6. +// +// Solidity: function unstake(address addr, uint256 amount, address sendToAddr) returns() +func (_StakingDailyStipend *StakingDailyStipendTransactor) Unstake(opts *bind.TransactOpts, addr common.Address, amount *big.Int, sendToAddr common.Address) (*types.Transaction, error) { + return _StakingDailyStipend.contract.Transact(opts, "unstake", addr, amount, sendToAddr) +} + +// Unstake is a paid mutator transaction binding the contract method 0x926e31d6. +// +// Solidity: function unstake(address addr, uint256 amount, address sendToAddr) returns() +func (_StakingDailyStipend *StakingDailyStipendSession) Unstake(addr common.Address, amount *big.Int, sendToAddr common.Address) (*types.Transaction, error) { + return _StakingDailyStipend.Contract.Unstake(&_StakingDailyStipend.TransactOpts, addr, amount, sendToAddr) +} + +// Unstake is a paid mutator transaction binding the contract method 0x926e31d6. +// +// Solidity: function unstake(address addr, uint256 amount, address sendToAddr) returns() +func (_StakingDailyStipend *StakingDailyStipendTransactorSession) Unstake(addr common.Address, amount *big.Int, sendToAddr common.Address) (*types.Transaction, error) { + return _StakingDailyStipend.Contract.Unstake(&_StakingDailyStipend.TransactOpts, addr, amount, sendToAddr) +} + +// StakingDailyStipendInitializedIterator is returned from FilterInitialized and is used to iterate over the raw logs and unpacked data for Initialized events raised by the StakingDailyStipend contract. +type StakingDailyStipendInitializedIterator struct { + Event *StakingDailyStipendInitialized // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *StakingDailyStipendInitializedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(StakingDailyStipendInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(StakingDailyStipendInitialized) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *StakingDailyStipendInitializedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *StakingDailyStipendInitializedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// StakingDailyStipendInitialized represents a Initialized event raised by the StakingDailyStipend contract. +type StakingDailyStipendInitialized struct { + Version uint8 + Raw types.Log // Blockchain specific contextual infos +} + +// FilterInitialized is a free log retrieval operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_StakingDailyStipend *StakingDailyStipendFilterer) FilterInitialized(opts *bind.FilterOpts) (*StakingDailyStipendInitializedIterator, error) { + + logs, sub, err := _StakingDailyStipend.contract.FilterLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return &StakingDailyStipendInitializedIterator{contract: _StakingDailyStipend.contract, event: "Initialized", logs: logs, sub: sub}, nil +} + +// WatchInitialized is a free log subscription operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_StakingDailyStipend *StakingDailyStipendFilterer) WatchInitialized(opts *bind.WatchOpts, sink chan<- *StakingDailyStipendInitialized) (event.Subscription, error) { + + logs, sub, err := _StakingDailyStipend.contract.WatchLogs(opts, "Initialized") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(StakingDailyStipendInitialized) + if err := _StakingDailyStipend.contract.UnpackLog(event, "Initialized", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseInitialized is a log parse operation binding the contract event 0x7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498. +// +// Solidity: event Initialized(uint8 version) +func (_StakingDailyStipend *StakingDailyStipendFilterer) ParseInitialized(log types.Log) (*StakingDailyStipendInitialized, error) { + event := new(StakingDailyStipendInitialized) + if err := _StakingDailyStipend.contract.UnpackLog(event, "Initialized", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// StakingDailyStipendOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the StakingDailyStipend contract. +type StakingDailyStipendOwnershipTransferredIterator struct { + Event *StakingDailyStipendOwnershipTransferred // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *StakingDailyStipendOwnershipTransferredIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(StakingDailyStipendOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(StakingDailyStipendOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *StakingDailyStipendOwnershipTransferredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *StakingDailyStipendOwnershipTransferredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// StakingDailyStipendOwnershipTransferred represents a OwnershipTransferred event raised by the StakingDailyStipend contract. +type StakingDailyStipendOwnershipTransferred struct { + PreviousOwner common.Address + NewOwner common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_StakingDailyStipend *StakingDailyStipendFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*StakingDailyStipendOwnershipTransferredIterator, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _StakingDailyStipend.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return &StakingDailyStipendOwnershipTransferredIterator{contract: _StakingDailyStipend.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil +} + +// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_StakingDailyStipend *StakingDailyStipendFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *StakingDailyStipendOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _StakingDailyStipend.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(StakingDailyStipendOwnershipTransferred) + if err := _StakingDailyStipend.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_StakingDailyStipend *StakingDailyStipendFilterer) ParseOwnershipTransferred(log types.Log) (*StakingDailyStipendOwnershipTransferred, error) { + event := new(StakingDailyStipendOwnershipTransferred) + if err := _StakingDailyStipend.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// StakingDailyStipendStakedIterator is returned from FilterStaked and is used to iterate over the raw logs and unpacked data for Staked events raised by the StakingDailyStipend contract. +type StakingDailyStipendStakedIterator struct { + Event *StakingDailyStipendStaked // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *StakingDailyStipendStakedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(StakingDailyStipendStaked) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(StakingDailyStipendStaked) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *StakingDailyStipendStakedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *StakingDailyStipendStakedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// StakingDailyStipendStaked represents a Staked event raised by the StakingDailyStipend contract. +type StakingDailyStipendStaked struct { + UserAddress common.Address + Amount *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterStaked is a free log retrieval operation binding the contract event 0x9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d. +// +// Solidity: event Staked(address indexed userAddress, uint256 amount) +func (_StakingDailyStipend *StakingDailyStipendFilterer) FilterStaked(opts *bind.FilterOpts, userAddress []common.Address) (*StakingDailyStipendStakedIterator, error) { + + var userAddressRule []interface{} + for _, userAddressItem := range userAddress { + userAddressRule = append(userAddressRule, userAddressItem) + } + + logs, sub, err := _StakingDailyStipend.contract.FilterLogs(opts, "Staked", userAddressRule) + if err != nil { + return nil, err + } + return &StakingDailyStipendStakedIterator{contract: _StakingDailyStipend.contract, event: "Staked", logs: logs, sub: sub}, nil +} + +// WatchStaked is a free log subscription operation binding the contract event 0x9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d. +// +// Solidity: event Staked(address indexed userAddress, uint256 amount) +func (_StakingDailyStipend *StakingDailyStipendFilterer) WatchStaked(opts *bind.WatchOpts, sink chan<- *StakingDailyStipendStaked, userAddress []common.Address) (event.Subscription, error) { + + var userAddressRule []interface{} + for _, userAddressItem := range userAddress { + userAddressRule = append(userAddressRule, userAddressItem) + } + + logs, sub, err := _StakingDailyStipend.contract.WatchLogs(opts, "Staked", userAddressRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(StakingDailyStipendStaked) + if err := _StakingDailyStipend.contract.UnpackLog(event, "Staked", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseStaked is a log parse operation binding the contract event 0x9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d. +// +// Solidity: event Staked(address indexed userAddress, uint256 amount) +func (_StakingDailyStipend *StakingDailyStipendFilterer) ParseStaked(log types.Log) (*StakingDailyStipendStaked, error) { + event := new(StakingDailyStipendStaked) + if err := _StakingDailyStipend.contract.UnpackLog(event, "Staked", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// StakingDailyStipendUnstakedIterator is returned from FilterUnstaked and is used to iterate over the raw logs and unpacked data for Unstaked events raised by the StakingDailyStipend contract. +type StakingDailyStipendUnstakedIterator struct { + Event *StakingDailyStipendUnstaked // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *StakingDailyStipendUnstakedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(StakingDailyStipendUnstaked) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(StakingDailyStipendUnstaked) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *StakingDailyStipendUnstakedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *StakingDailyStipendUnstakedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// StakingDailyStipendUnstaked represents a Unstaked event raised by the StakingDailyStipend contract. +type StakingDailyStipendUnstaked struct { + UserAddress common.Address + Amount *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterUnstaked is a free log retrieval operation binding the contract event 0x0f5bb82176feb1b5e747e28471aa92156a04d9f3ab9f45f28e2d704232b93f75. +// +// Solidity: event Unstaked(address indexed userAddress, uint256 amount) +func (_StakingDailyStipend *StakingDailyStipendFilterer) FilterUnstaked(opts *bind.FilterOpts, userAddress []common.Address) (*StakingDailyStipendUnstakedIterator, error) { + + var userAddressRule []interface{} + for _, userAddressItem := range userAddress { + userAddressRule = append(userAddressRule, userAddressItem) + } + + logs, sub, err := _StakingDailyStipend.contract.FilterLogs(opts, "Unstaked", userAddressRule) + if err != nil { + return nil, err + } + return &StakingDailyStipendUnstakedIterator{contract: _StakingDailyStipend.contract, event: "Unstaked", logs: logs, sub: sub}, nil +} + +// WatchUnstaked is a free log subscription operation binding the contract event 0x0f5bb82176feb1b5e747e28471aa92156a04d9f3ab9f45f28e2d704232b93f75. +// +// Solidity: event Unstaked(address indexed userAddress, uint256 amount) +func (_StakingDailyStipend *StakingDailyStipendFilterer) WatchUnstaked(opts *bind.WatchOpts, sink chan<- *StakingDailyStipendUnstaked, userAddress []common.Address) (event.Subscription, error) { + + var userAddressRule []interface{} + for _, userAddressItem := range userAddress { + userAddressRule = append(userAddressRule, userAddressItem) + } + + logs, sub, err := _StakingDailyStipend.contract.WatchLogs(opts, "Unstaked", userAddressRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(StakingDailyStipendUnstaked) + if err := _StakingDailyStipend.contract.UnpackLog(event, "Unstaked", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseUnstaked is a log parse operation binding the contract event 0x0f5bb82176feb1b5e747e28471aa92156a04d9f3ab9f45f28e2d704232b93f75. +// +// Solidity: event Unstaked(address indexed userAddress, uint256 amount) +func (_StakingDailyStipend *StakingDailyStipendFilterer) ParseUnstaked(log types.Log) (*StakingDailyStipendUnstaked, error) { + event := new(StakingDailyStipendUnstaked) + if err := _StakingDailyStipend.contract.UnpackLog(event, "Unstaked", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/smart-contracts/package.json b/smart-contracts/package.json index 5162c4c2..2fb98671 100644 --- a/smart-contracts/package.json +++ b/smart-contracts/package.json @@ -6,8 +6,13 @@ "scripts": { "compile": "hardhat compile", "test": "hardhat test", - "coverage": "hardhat coverage", - "verify": "hardhat verify" + "test:gas": "REPORT_GAS=true hardhat test", + "coverage": "SOLIDITY_COVERAGE=true hardhat coverage", + "report": "open ./coverage/index.html", + "verify": "hardhat verify", + "bindings-go": "hardhat gobind", + "node-local": "hardhat node", + "deploy-local": "hardhat run --network localhost scripts/deploy-local.ts" }, "devDependencies": { "@nomicfoundation/hardhat-ignition": "^0.15.0", From e5ae4865ec2d9fe980f62b140ac517d26c0b2a23 Mon Sep 17 00:00:00 2001 From: lsheva Date: Tue, 30 Apr 2024 22:18:27 +0200 Subject: [PATCH 18/21] Feat/registries (#35) * feat: introduce registries * feat: marketplace, session router * feat: improve querying and indexes * feat: improve session router, add staking * fix: update registries and add tests * feat: add golang bindings * feat: enable local node * feat: staking daily stipend contract * feat: update marketplace contract * fix: staking two times per day interval was counting only latest * feat: session router open/close session impl * feat: fix session cloesout and provider claiming * fix: refactor to use openzeppelin recover and hash utils * fix: block two sessions with the same bid * test: more test cases * feat: merge marketplace, staking and session router into a single contract * feat: rewrite contract to be a diamond * feat: fix build and local setup * fix: format contracts uniformly * fix: add format command * fix: mapping response * fix: move getSelectors to diamond.ts --------- Co-authored-by: Oleksandr Shevchuk Co-authored-by: srt0422 --- smart-contracts/.env.example | 2 + smart-contracts/.gitignore | 4 + smart-contracts/.prettierrc | 16 + smart-contracts/contracts/AppStorage.sol | 97 +++++ smart-contracts/contracts/DiamondInit.sol | 64 +++ smart-contracts/contracts/KeySet.sol | 121 ------ smart-contracts/contracts/ModelRegistry.sol | 134 ------ smart-contracts/contracts/MorpheusToken.sol | 10 +- .../contracts/ProviderRegistry.sol | 103 ----- smart-contracts/contracts/SessionRouter.sol | 106 ----- smart-contracts/contracts/diamond/Diamond.sol | 75 ++++ .../diamond/facets/DiamondCutFacet.sol | 30 ++ .../diamond/facets/DiamondLoupeFacet.sol | 180 +++++++++ .../diamond/facets/OwnershipFacet.sol | 16 + .../contracts/diamond/facets/Test1Facet.sol | 82 ++++ .../contracts/diamond/facets/Test2Facet.sol | 44 ++ .../contracts/diamond/interfaces/IDiamond.sol | 24 ++ .../diamond/interfaces/IDiamondCut.sol | 23 ++ .../diamond/interfaces/IDiamondLoupe.sol | 45 +++ .../contracts/diamond/interfaces/IERC165.sol | 12 + .../contracts/diamond/interfaces/IERC173.sol | 22 + .../diamond/libraries/LibDiamond.sol | 268 ++++++++++++ .../upgradeInitializers/DiamondMultiInit.sol | 36 ++ .../contracts/{ => facets}/AgentRegistry.sol | 50 ++- .../contracts/facets/Marketplace.sol | 201 +++++++++ .../contracts/facets/ModelRegistry.sol | 129 ++++++ .../contracts/facets/ProviderRegistry.sol | 116 ++++++ .../contracts/facets/SessionRouter.sol | 291 +++++++++++++ .../contracts/libraries/KeySet.sol | 115 ++++++ .../contracts/libraries/LibOwner.sol | 29 ++ smart-contracts/hardhat.config.ts | 26 ++ smart-contracts/libraries/diamond.ts | 93 +++++ smart-contracts/package.json | 17 +- smart-contracts/scripts/deploy-local.ts | 11 + smart-contracts/test/Marketplace.test.ts | 272 +++++++++++++ smart-contracts/test/ModelRegistry.test.ts | 319 +++++++++++++++ smart-contracts/test/ProviderRegistry.test.ts | 299 ++++++++++++++ smart-contracts/test/SessionRouter.test.ts | 313 ++++++++++++++ smart-contracts/test/SessionRouter.ts | 278 ------------- smart-contracts/test/Staking.test.ts | 184 +++++++++ smart-contracts/test/fixtures.ts | 271 +++++++++++++ smart-contracts/test/types.ts | 0 smart-contracts/test/utils.ts | 92 +++++ smart-contracts/tsconfig.json | 2 +- smart-contracts/utils/compare.ts | 25 +- smart-contracts/utils/time.ts | 5 + smart-contracts/yarn.lock | 381 ++++++++++++++++-- 47 files changed, 4211 insertions(+), 822 deletions(-) create mode 100644 smart-contracts/.env.example create mode 100644 smart-contracts/.prettierrc create mode 100644 smart-contracts/contracts/AppStorage.sol create mode 100644 smart-contracts/contracts/DiamondInit.sol delete mode 100644 smart-contracts/contracts/KeySet.sol delete mode 100644 smart-contracts/contracts/ModelRegistry.sol delete mode 100644 smart-contracts/contracts/ProviderRegistry.sol delete mode 100644 smart-contracts/contracts/SessionRouter.sol create mode 100644 smart-contracts/contracts/diamond/Diamond.sol create mode 100644 smart-contracts/contracts/diamond/facets/DiamondCutFacet.sol create mode 100644 smart-contracts/contracts/diamond/facets/DiamondLoupeFacet.sol create mode 100644 smart-contracts/contracts/diamond/facets/OwnershipFacet.sol create mode 100644 smart-contracts/contracts/diamond/facets/Test1Facet.sol create mode 100644 smart-contracts/contracts/diamond/facets/Test2Facet.sol create mode 100644 smart-contracts/contracts/diamond/interfaces/IDiamond.sol create mode 100644 smart-contracts/contracts/diamond/interfaces/IDiamondCut.sol create mode 100644 smart-contracts/contracts/diamond/interfaces/IDiamondLoupe.sol create mode 100644 smart-contracts/contracts/diamond/interfaces/IERC165.sol create mode 100644 smart-contracts/contracts/diamond/interfaces/IERC173.sol create mode 100644 smart-contracts/contracts/diamond/libraries/LibDiamond.sol create mode 100644 smart-contracts/contracts/diamond/upgradeInitializers/DiamondMultiInit.sol rename smart-contracts/contracts/{ => facets}/AgentRegistry.sol (70%) create mode 100644 smart-contracts/contracts/facets/Marketplace.sol create mode 100644 smart-contracts/contracts/facets/ModelRegistry.sol create mode 100644 smart-contracts/contracts/facets/ProviderRegistry.sol create mode 100644 smart-contracts/contracts/facets/SessionRouter.sol create mode 100644 smart-contracts/contracts/libraries/KeySet.sol create mode 100644 smart-contracts/contracts/libraries/LibOwner.sol create mode 100644 smart-contracts/libraries/diamond.ts create mode 100644 smart-contracts/scripts/deploy-local.ts create mode 100644 smart-contracts/test/Marketplace.test.ts create mode 100644 smart-contracts/test/ModelRegistry.test.ts create mode 100644 smart-contracts/test/ProviderRegistry.test.ts create mode 100644 smart-contracts/test/SessionRouter.test.ts delete mode 100644 smart-contracts/test/SessionRouter.ts create mode 100644 smart-contracts/test/Staking.test.ts create mode 100644 smart-contracts/test/fixtures.ts create mode 100644 smart-contracts/test/types.ts create mode 100644 smart-contracts/test/utils.ts create mode 100644 smart-contracts/utils/time.ts diff --git a/smart-contracts/.env.example b/smart-contracts/.env.example new file mode 100644 index 00000000..266911af --- /dev/null +++ b/smart-contracts/.env.example @@ -0,0 +1,2 @@ +ARBISCAN_API_KEY= # for coverage report to estimate deployment and calls price +COINMARKETCAP_API_KEY= # for coverage report to estimate deployment and calls price \ No newline at end of file diff --git a/smart-contracts/.gitignore b/smart-contracts/.gitignore index 9722dbfa..986344c5 100644 --- a/smart-contracts/.gitignore +++ b/smart-contracts/.gitignore @@ -12,3 +12,7 @@ node_modules # solidity-coverage files /coverage /coverage.json +/gas.json + +# generated bindings +/bindings \ No newline at end of file diff --git a/smart-contracts/.prettierrc b/smart-contracts/.prettierrc new file mode 100644 index 00000000..016b8657 --- /dev/null +++ b/smart-contracts/.prettierrc @@ -0,0 +1,16 @@ +{ + "plugins": ["prettier-plugin-solidity"], + "overrides": [ + { + "files": "*.sol", + "options": { + "parser": "solidity-parse", + "printWidth": 80, + "tabWidth": 2, + "useTabs": false, + "singleQuote": false, + "bracketSpacing": true + } + } + ] +} diff --git a/smart-contracts/contracts/AppStorage.sol b/smart-contracts/contracts/AppStorage.sol new file mode 100644 index 00000000..2ccfa7a8 --- /dev/null +++ b/smart-contracts/contracts/AppStorage.sol @@ -0,0 +1,97 @@ +//SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import { KeySet, AddressSet } from "./libraries/KeySet.sol"; +import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; + +struct Provider { + string endpoint; // example 'domain.com:1234' + uint256 stake; // stake amount + uint128 timestamp; // timestamp of the registration + bool isDeleted; +} + +struct Model { + bytes32 ipfsCID; // https://docs.ipfs.tech/concepts/content-addressing/#what-is-a-cid + uint256 fee; + uint256 stake; + address owner; + string name; // limit name length + string[] tags; // TODO: limit tags amount + uint128 timestamp; + bool isDeleted; +} + +struct Bid { + address provider; + bytes32 modelAgentId; + uint256 pricePerSecond; // hourly price + uint256 nonce; + uint256 createdAt; + uint256 deletedAt; +} + +struct Session { + bytes32 id; + address user; + address provider; + bytes32 modelAgentId; + bytes32 bidID; + uint256 stake; + uint256 pricePerSecond; + bytes closeoutReceipt; + uint256 closeoutType; + uint256 openedAt; + uint256 closedAt; +} + +struct OnHold { + uint256 amount; + uint256 releaseAt; // in epoch seconds TODO: consider using hours to reduce storage cost +} + +struct AppStorage { + IERC20 token; + // provider storage + uint256 providerMinStake; + mapping(address => Provider) providerMap; // provider address => Provider + address[] providers; // all providers ids + AddressSet.Set activeProviders; // active providers ids + // MODEL storage + uint256 modelMinStake; + mapping(bytes32 => Model) modelMap; // modelId => Model + // mapping(address => bytes32[]) public modelsByOwner; // owner to modelIds + bytes32[] models; // all model ids + KeySet.Set activeModels; // active model ids + // BID storage + uint256 bidFee; + uint256 feeBalance; + mapping(bytes32 => Bid) bidMap; // bidId = keccak256(provider, modelAgentId, nonce) => bid + mapping(bytes32 => uint256) providerModelAgentNonce; // keccak256(provider, modelAgentId) => last nonce + KeySet.Set activeBids; // all active bidIds + mapping(address => KeySet.Set) providerActiveBids; // provider => active bidIds + mapping(bytes32 => KeySet.Set) modelAgentActiveBids; // modelAgentId => active bidIds + mapping(bytes32 => bytes32[]) modelAgentBids; // keccak256(provider, modelAgentId) => all bidIds + mapping(address => bytes32[]) providerBids; // provider => all bidIds + // SESSION storage + // Number of seconds to delay the stake return when a user closes out a session using a user signed receipt. + int256 stakeDelay; + address tokenAccount; // account which stores the MOR tokens with infinite allowance for this contract + // arguments for getPeriodReward call + // address public constant distributionContractAddr = address(0x0); + // uint32 public constant distributionRewardStartTime = 1707350400; // ephochSeconds Feb 8 2024 00:00:00 + // uint8 public constant distributionPoolId = 3; + + Session[] sessions; // all sessions + mapping(bytes32 => uint256) sessionMap; // sessionId => session index + mapping(bytes32 => uint256) bidSessionMap; // bidId => session index + mapping(address => OnHold[]) providerOnHold; // provider address => balance +} + +library LibAppStorage { + function appStorage() internal pure returns (AppStorage storage ds) { + assembly { + ds.slot := 0 + } + } +} diff --git a/smart-contracts/contracts/DiamondInit.sol b/smart-contracts/contracts/DiamondInit.sol new file mode 100644 index 00000000..9e76a2c1 --- /dev/null +++ b/smart-contracts/contracts/DiamondInit.sol @@ -0,0 +1,64 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +//******************************************************************************\ +//* Author: Nick Mudge (https://twitter.com/mudgen) +//* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 +//* +//* Implementation of a diamond. +/******************************************************************************/ + +import { LibDiamond } from "./diamond/libraries/LibDiamond.sol"; +import { IDiamondLoupe } from "./diamond/interfaces/IDiamondLoupe.sol"; +import { IDiamondCut } from "./diamond/interfaces/IDiamondCut.sol"; +import { IERC173 } from "./diamond/interfaces/IERC173.sol"; +import { IERC165 } from "./diamond/interfaces/IERC165.sol"; +import { LibAppStorage, AppStorage, Session } from "./AppStorage.sol"; +import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; + +// It is expected that this contract is customized if you want to deploy your diamond +// with data from a deployment script. Use the init function to initialize state variables +// of your diamond. Add parameters to the init funciton if you need to. + +// Adding parameters to the `init` or other functions you add here can make a single deployed +// DiamondInit contract reusable accross upgrades, and can be used for multiple diamonds. + +contract DiamondInit { + // You can add parameters to this function in order to pass in + // data to set your own state variables + function init(address _token, address _tokenAccount) external { + // adding ERC165 data + LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage(); + ds.supportedInterfaces[type(IERC165).interfaceId] = true; + ds.supportedInterfaces[type(IDiamondCut).interfaceId] = true; + ds.supportedInterfaces[type(IDiamondLoupe).interfaceId] = true; + ds.supportedInterfaces[type(IERC173).interfaceId] = true; + + // add your own state variables + AppStorage storage s = LibAppStorage.appStorage(); + s.token = IERC20(_token); + + s.stakeDelay = 0; + s.tokenAccount = _tokenAccount; + s.sessions.push( + Session({ + id: bytes32(0), + user: address(0), + provider: address(0), + modelAgentId: bytes32(0), + bidID: bytes32(0), + stake: 0, + pricePerSecond: 0, + closeoutReceipt: "", + closeoutType: 0, + openedAt: 0, + closedAt: 0 + }) + ); + // EIP-2535 specifies that the `diamondCut` function takes two optional + // arguments: address _init and bytes calldata _calldata + // These arguments are used to execute an arbitrary function using delegatecall + // in order to set state variables in the diamond during deployment or an upgrade + // More info here: https://eips.ethereum.org/EIPS/eip-2535#diamond-interface + } +} diff --git a/smart-contracts/contracts/KeySet.sol b/smart-contracts/contracts/KeySet.sol deleted file mode 100644 index ae62e0f1..00000000 --- a/smart-contracts/contracts/KeySet.sol +++ /dev/null @@ -1,121 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.24; - -// inspired by https://github.com/rob-Hitchens/UnorderedKeySet/blob/master/contracts/HitchensUnorderedKeySet.sol -library KeySet { - struct Set { - mapping(bytes32 => uint) keyPointers; - bytes32[] keyList; - } - - error ZeroKey(); - error KeyExists(); - error KeyNotFound(); - - function insert(Set storage self, bytes32 key) internal { - if (key == 0x0) { - revert ZeroKey(); - } - if (exists(self, key)) { - revert KeyExists(); - } - - self.keyPointers[key] = self.keyList.length; - self.keyList.push(key); - } - - function remove(Set storage self, bytes32 key) internal { - if (!exists(self, key)) { - revert KeyNotFound(); - } - - bytes32 keyToMove = self.keyList[count(self)-1]; - uint rowToReplace = self.keyPointers[key]; - self.keyPointers[keyToMove] = rowToReplace; - self.keyList[rowToReplace] = keyToMove; - delete self.keyPointers[key]; - self.keyList.pop(); - } - - function count(Set storage self) internal view returns (uint) { - return (self.keyList.length); - } - - function exists( - Set storage self, - bytes32 key - ) internal view returns (bool) { - if (self.keyList.length == 0) return false; - return self.keyList[self.keyPointers[key]] == key; - } - - function keyAtIndex( - Set storage self, - uint index - ) internal view returns (bytes32) { - return self.keyList[index]; - } - - function keys(Set storage self) internal view returns (bytes32[] memory) { - return self.keyList; - } -} - -library AddressSet { - struct Set { - mapping(address => uint) keyPointers; - address[] keyList; - } - - error ZeroKey(); - error KeyExists(); - error KeyNotFound(); - - function insert(Set storage self, address key) internal { - if (key == address(0)) { - revert ZeroKey(); - } - if (exists(self, key)) { - revert KeyExists(); - } - - self.keyPointers[key] = self.keyList.length; - self.keyList.push(key); - } - - function remove(Set storage self, address key) internal { - if (!exists(self, key)) { - revert KeyNotFound(); - } - - address keyToMove = self.keyList[count(self)-1]; - uint rowToReplace = self.keyPointers[key]; - self.keyPointers[keyToMove] = rowToReplace; - self.keyList[rowToReplace] = keyToMove; - delete self.keyPointers[key]; - self.keyList.pop(); - } - - function count(Set storage self) internal view returns (uint) { - return (self.keyList.length); - } - - function exists( - Set storage self, - address key - ) internal view returns (bool) { - if (self.keyList.length == 0) return false; - return self.keyList[self.keyPointers[key]] == key; - } - - function keyAtIndex( - Set storage self, - uint index - ) internal view returns (address) { - return self.keyList[index]; - } - - function keys(Set storage self) internal view returns (address[] memory) { - return self.keyList; - } -} diff --git a/smart-contracts/contracts/ModelRegistry.sol b/smart-contracts/contracts/ModelRegistry.sol deleted file mode 100644 index 45b21e06..00000000 --- a/smart-contracts/contracts/ModelRegistry.sol +++ /dev/null @@ -1,134 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.24; -import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; -import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; -import {KeySet} from "./KeySet.sol"; -import "hardhat/console.sol"; - -contract ModelRegistry is OwnableUpgradeable { - using KeySet for KeySet.Set; - - struct Model { - uint256 fee; - uint256 stake; - uint256 timestamp; - bytes32 ipfsCID; // https://docs.ipfs.tech/concepts/content-addressing/#what-is-a-cid - bytes32 uuid; - address owner; - string name; // limit name length - string[] tags; // TODO: limit tags amount - } - - error StakeTooLow(); - error NotSenderOrOwner(); - error ModelNotFound(); - - event RegisteredUpdated(address indexed owner, bytes32 indexed uuid); - event Deregistered(address indexed owner, bytes32 indexed uuid); - event MinStakeUpdated(uint256 newStake); - - // state - uint256 public minStake; - ERC20 public token; - - // storage - KeySet.Set set; - mapping(bytes32 => Model) public map; - // mapping(address => bytes32[]) public modelsByOwner; // owner to uuids - - function initialize(address _token) public initializer { - token = ERC20(_token); - __Ownable_init(); - } - - function getModelIds() public view returns (bytes32[] memory){ - return set.keys(); - } - - function getCount() public view returns(uint count) { - return set.count(); - } - - function getAll() public view returns (Model[] memory){ - Model[] memory _models = new Model[](set.count()); - for (uint i = 0; i < set.count(); i++) { - _models[i] = map[set.keyAtIndex(i)]; - } - return _models; - } - - function getByIndex(uint index) public view returns(Model memory model) { - return map[set.keyAtIndex(index)]; - } - - // registers new model or updates existing - function register(uint256 addStake, uint256 fee, bytes32 ipfsCID, bytes32 uuid, address owner, string memory name, string[] memory tags) public senderOrOwner(owner){ - uint256 stake = map[uuid].stake; - uint256 newStake = stake + addStake; - if (newStake < minStake) { - revert StakeTooLow(); - } - - if (stake == 0) { - set.insert(uuid); - } else { - _senderOrOwner(map[uuid].owner); - } - - map[uuid] = Model({ - fee: fee, - stake: newStake, - timestamp: block.timestamp, - ipfsCID: ipfsCID, - uuid: uuid, - owner: owner, - name: name, - tags: tags - }); - - emit RegisteredUpdated(owner, uuid); - token.transferFrom(_msgSender(), address(this), addStake); // reverts with ERC20InsufficientAllowance - } - - function deregister(bytes32 id) public { - address owner = map[id].owner; - _senderOrOwner(owner); - - set.remove(id); - uint256 stake = map[id].stake; - delete map[id]; - - emit Deregistered(owner, id); - token.transfer(owner, stake); - } - - function setMinStake(uint256 _minStake) public onlyOwner { - minStake = _minStake; - emit MinStakeUpdated(minStake); - } - - modifier senderOrOwner(address addr) { - _senderOrOwner(addr); - _; - } - - function _senderOrOwner(address addr) internal view { - if (addr != _msgSender() && addr != owner()) { - revert NotSenderOrOwner(); - } - } - - // TODO: implement these functions - // function getModelsByOwner(address addr) public view returns (Model[] memory){ - // Model[] memory _models = new Model[](modelIds.length); - // for (uint i = 0; i < modelIds.length; i++) { - // if (models[modelIds[i]].owner == addr) { - // _models[i] = models[modelIds[i]]; - // } - // } - // return _models; - // } - - // function getModelTypes -- to be implemented when types are defined - // function getModelsByType -} \ No newline at end of file diff --git a/smart-contracts/contracts/MorpheusToken.sol b/smart-contracts/contracts/MorpheusToken.sol index c9d0a64a..8cec5bb5 100644 --- a/smart-contracts/contracts/MorpheusToken.sol +++ b/smart-contracts/contracts/MorpheusToken.sol @@ -4,9 +4,9 @@ pragma solidity ^0.8.0; import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; contract MorpheusToken is ERC20 { - uint256 constant initialSupply = 1000000 * (10**18); + uint256 constant initialSupply = 1000000 * (10 ** 18); - constructor() ERC20("Morpheus dev", "MOR") { - _mint(msg.sender, initialSupply); - } -} \ No newline at end of file + constructor() ERC20("Morpheus dev", "MOR") { + _mint(msg.sender, initialSupply); + } +} diff --git a/smart-contracts/contracts/ProviderRegistry.sol b/smart-contracts/contracts/ProviderRegistry.sol deleted file mode 100644 index 40db6cc5..00000000 --- a/smart-contracts/contracts/ProviderRegistry.sol +++ /dev/null @@ -1,103 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.24; -import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; -import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; -import {AddressSet} from "./KeySet.sol"; -import "hardhat/console.sol"; - -contract ProviderRegistry is OwnableUpgradeable { - using AddressSet for AddressSet.Set; - - struct Provider { - string endpoint; // example 'domain.com:1234' - uint256 stake; // stake amount - uint256 timestamp; // timestamp of the registration - } - - error StakeTooLow(); - error AllowanceTooLow(); - error NotSenderOrOwner(); - error ProviderNotFound(); - - event RegisteredUpdated(address indexed provider); - event Deregistered(address indexed provider); - event MinStakeUpdated(uint256 newStake); - - // state - uint256 public minStake; - ERC20 public token; - - // providers storage - AddressSet.Set set; - mapping(address => Provider) public map; - - function initialize(address _token) public initializer { - token = ERC20(_token); - __Ownable_init(); - } - - function getIds() public view returns (address[] memory) { - return set.keys(); - } - - function getCount() public view returns (uint count) { - return set.count(); - } - - function getByIndex(uint index) public view returns (Provider memory provider) { - return map[set.keyAtIndex(index)]; - } - - function getAll() public view returns (Provider[] memory) { - Provider[] memory _providers = new Provider[](set.count()); - for (uint i = 0; i < set.count(); i++) { - _providers[i] = map[set.keyAtIndex(i)]; - } - return _providers; - } - - // registers new provider or updates existing - function register(address addr, uint256 addStake, string memory endpoint) public senderOrOwner(addr) { - uint256 stake = map[addr].stake; - uint256 newStake = stake + addStake; - if (newStake < minStake) { - revert StakeTooLow(); - } - if (stake == 0) { - set.insert(addr); - } else { - _senderOrOwner(addr); - } - - map[addr] = Provider(endpoint, newStake, block.timestamp); - emit RegisteredUpdated(addr); - token.transferFrom(_msgSender(), address(this), addStake); // reverts with ERC20InsufficientAllowance - } - - // avoid loop this by using pointer pattern - function deregister(address addr) public senderOrOwner(addr) { - set.remove(addr); - - uint256 stake = map[addr].stake; - delete map[addr]; - - emit Deregistered(addr); - token.transfer(addr, stake); - } - - function setMinStake(uint256 _minStake) public onlyOwner { - minStake = _minStake; - emit MinStakeUpdated(_minStake); - } - - modifier senderOrOwner(address addr) { - _senderOrOwner(addr); - _; - } - - function _senderOrOwner(address addr) internal view { - if (addr != _msgSender() && addr != owner()) { - revert NotSenderOrOwner(); - } - } -} diff --git a/smart-contracts/contracts/SessionRouter.sol b/smart-contracts/contracts/SessionRouter.sol deleted file mode 100644 index fd009698..00000000 --- a/smart-contracts/contracts/SessionRouter.sol +++ /dev/null @@ -1,106 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.24; -import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; -import "hardhat/console.sol"; - -contract SessionRouter { - // - // structs - // - struct Provider { - address addr; - string name; - string url; - uint256 pricePerMinute; - } - - struct Session { - uint id; - address buyer; - address provider; - uint startTime; - uint endTime; - } - - // - // state - // - address payable public owner; - ERC20 public tokenMOR; - uint public constant minute = 60; // minute in seconds - - // - // mappings - // - mapping(address => Provider) public providers; - address[] public providerList; - - mapping(uint => Session) public sessions; - uint[] public sessionList; - - // - // events - // - event SessionStarted(address indexed user, uint indexed sessionId); - event SessionClosedManually(address indexed user, uint indexed sessionId); - event ProviderAdded(address indexed provider); - // event ProviderRemoved(address indexed provider); - - constructor(address _morpheusTokenAddr) payable { - owner = payable(msg.sender); - tokenMOR = ERC20(_morpheusTokenAddr); - } - - modifier onlyOwner() { - require(msg.sender == owner, "only owner can call this function"); - _; - } - - function addProvider(address _addr, string memory _name, string memory _url, uint _pricePerMinute) public onlyOwner { - require(providers[_addr].addr == address(0), "provider already exists"); - providers[_addr] = Provider(_addr, _name, _url, _pricePerMinute); - providerList.push(_addr); - emit ProviderAdded(_addr); - } - - function startSession(address _provider) public payable returns (uint) { - uint256 actualAllowance = tokenMOR.allowance(msg.sender, address(this)); - bool tokensTransfered = tokenMOR.transferFrom( - msg.sender, - address(this), - actualAllowance - ); - require(tokensTransfered, "morheus transfer failed"); - - Provider memory provider = providers[_provider]; - require(provider.addr != address(0), "provider not found"); - - uint durationSeconds = actualAllowance * minute / provider.pricePerMinute; - uint endTime = block.timestamp + durationSeconds; - - uint sessionId = sessionList.length; - sessions[sessionId] = Session(sessionId, msg.sender, _provider, block.timestamp, endTime); - sessionList.push(sessionId); - - emit SessionStarted(msg.sender, sessionId); - return sessionId; - } - - function closeSession(uint _sessionId) public { - Session storage session = sessions[_sessionId]; - require(session.buyer == msg.sender, "only user can close session"); - require(session.endTime > block.timestamp, "session already closed or expired"); - uint durationSeconds = block.timestamp - session.startTime; - - Provider memory provider = providers[session.provider]; - require(provider.addr != address(0), "provider not found"); - - uint refund = durationSeconds * provider.pricePerMinute / minute; - - tokenMOR.transfer(msg.sender, refund); - - session.endTime = block.timestamp; - console.log("close timestamp", block.timestamp); - emit SessionClosedManually(msg.sender, _sessionId); - } -} diff --git a/smart-contracts/contracts/diamond/Diamond.sol b/smart-contracts/contracts/diamond/Diamond.sol new file mode 100644 index 00000000..adca6b0f --- /dev/null +++ b/smart-contracts/contracts/diamond/Diamond.sol @@ -0,0 +1,75 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +//******************************************************************************\ +//* Author: Nick Mudge (https://twitter.com/mudgen) +//* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 +//* +//* Implementation of a diamond. +//******************************************************************************/ + +import { LibDiamond } from "./libraries/LibDiamond.sol"; +import { IDiamondCut } from "./interfaces/IDiamondCut.sol"; +import { IDiamondLoupe } from "./interfaces/IDiamondLoupe.sol"; +import { IERC173 } from "./interfaces/IERC173.sol"; +import { IERC165 } from "./interfaces/IERC165.sol"; + +// When no function exists for function called +error FunctionNotFound(bytes4 _functionSelector); + +// This is used in diamond constructor +// more arguments are added to this struct +// this avoids stack too deep errors +struct DiamondArgs { + address owner; + address init; + bytes initCalldata; +} + +contract Diamond { + constructor( + IDiamondCut.FacetCut[] memory _diamondCut, + DiamondArgs memory _args + ) payable { + LibDiamond.setContractOwner(_args.owner); + LibDiamond.diamondCut(_diamondCut, _args.init, _args.initCalldata); + + // Code can be added here to perform actions and set state variables. + } + + // Find facet for function that is called and execute the + // function if a facet is found and return any value. + fallback() external payable { + LibDiamond.DiamondStorage storage ds; + bytes32 position = LibDiamond.DIAMOND_STORAGE_POSITION; + // get diamond storage + assembly { + ds.slot := position + } + // get facet from function selector + address facet = ds.facetAddressAndSelectorPosition[msg.sig].facetAddress; + if (facet == address(0)) { + revert FunctionNotFound(msg.sig); + } + + // Execute external function from facet using delegatecall and return any value. + assembly { + // copy function selector and any arguments + calldatacopy(0, 0, calldatasize()) + // execute function call using the facet + let result := delegatecall(gas(), facet, 0, calldatasize(), 0, 0) + // get any return value + returndatacopy(0, 0, returndatasize()) + // return any return value or error back to the caller + switch result + case 0 { + revert(0, returndatasize()) + } + default { + return(0, returndatasize()) + } + } + } + + receive() external payable {} +} diff --git a/smart-contracts/contracts/diamond/facets/DiamondCutFacet.sol b/smart-contracts/contracts/diamond/facets/DiamondCutFacet.sol new file mode 100644 index 00000000..19d55846 --- /dev/null +++ b/smart-contracts/contracts/diamond/facets/DiamondCutFacet.sol @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +//******************************************************************************\ +//* Author: Nick Mudge (https://twitter.com/mudgen) +//* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 +//******************************************************************************/ + +import { IDiamondCut } from "../interfaces/IDiamondCut.sol"; +import { LibDiamond } from "../libraries/LibDiamond.sol"; + +// Remember to add the loupe functions from DiamondLoupeFacet to the diamond. +// The loupe functions are required by the EIP2535 Diamonds standard + +contract DiamondCutFacet is IDiamondCut { + /// @notice Add/replace/remove any number of functions and optionally execute + /// a function with delegatecall + /// @param _diamondCut Contains the facet addresses and function selectors + /// @param _init The address of the contract or facet to execute _calldata + /// @param _calldata A function call, including function selector and arguments + /// _calldata is executed with delegatecall on _init + function diamondCut( + FacetCut[] calldata _diamondCut, + address _init, + bytes calldata _calldata + ) external override { + LibDiamond.enforceIsContractOwner(); + LibDiamond.diamondCut(_diamondCut, _init, _calldata); + } +} diff --git a/smart-contracts/contracts/diamond/facets/DiamondLoupeFacet.sol b/smart-contracts/contracts/diamond/facets/DiamondLoupeFacet.sol new file mode 100644 index 00000000..c173df25 --- /dev/null +++ b/smart-contracts/contracts/diamond/facets/DiamondLoupeFacet.sol @@ -0,0 +1,180 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; +//******************************************************************************\ +//* Author: Nick Mudge (https://twitter.com/mudgen) +//* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 +//******************************************************************************/ + +// The functions in DiamondLoupeFacet MUST be added to a diamond. +// The EIP-2535 Diamond standard requires these functions. + +import { LibDiamond } from "../libraries/LibDiamond.sol"; +import { IDiamondLoupe } from "../interfaces/IDiamondLoupe.sol"; +import { IERC165 } from "../interfaces/IERC165.sol"; + +contract DiamondLoupeFacet is IDiamondLoupe, IERC165 { + // Diamond Loupe Functions + //////////////////////////////////////////////////////////////////// + /// These functions are expected to be called frequently by tools. + // + // struct Facet { + // address facetAddress; + // bytes4[] functionSelectors; + // } + /// @notice Gets all facets and their selectors. + /// @return facets_ Facet + function facets() external view override returns (Facet[] memory facets_) { + LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage(); + uint256 selectorCount = ds.selectors.length; + // create an array set to the maximum size possible + facets_ = new Facet[](selectorCount); + // create an array for counting the number of selectors for each facet + uint16[] memory numFacetSelectors = new uint16[](selectorCount); + // total number of facets + uint256 numFacets; + // loop through function selectors + for ( + uint256 selectorIndex; + selectorIndex < selectorCount; + selectorIndex++ + ) { + bytes4 selector = ds.selectors[selectorIndex]; + address facetAddress_ = ds + .facetAddressAndSelectorPosition[selector] + .facetAddress; + bool continueLoop = false; + // find the functionSelectors array for selector and add selector to it + for (uint256 facetIndex; facetIndex < numFacets; facetIndex++) { + if (facets_[facetIndex].facetAddress == facetAddress_) { + facets_[facetIndex].functionSelectors[ + numFacetSelectors[facetIndex] + ] = selector; + numFacetSelectors[facetIndex]++; + continueLoop = true; + break; + } + } + // if functionSelectors array exists for selector then continue loop + if (continueLoop) { + continueLoop = false; + continue; + } + // create a new functionSelectors array for selector + facets_[numFacets].facetAddress = facetAddress_; + facets_[numFacets].functionSelectors = new bytes4[](selectorCount); + facets_[numFacets].functionSelectors[0] = selector; + numFacetSelectors[numFacets] = 1; + numFacets++; + } + for (uint256 facetIndex; facetIndex < numFacets; facetIndex++) { + uint256 numSelectors = numFacetSelectors[facetIndex]; + bytes4[] memory selectors = facets_[facetIndex].functionSelectors; + // setting the number of selectors + assembly { + mstore(selectors, numSelectors) + } + } + // setting the number of facets + assembly { + mstore(facets_, numFacets) + } + } + + /// @notice Gets all the function selectors supported by a specific facet. + /// @param _facet The facet address. + /// @return _facetFunctionSelectors The selectors associated with a facet address. + function facetFunctionSelectors( + address _facet + ) external view override returns (bytes4[] memory _facetFunctionSelectors) { + LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage(); + uint256 selectorCount = ds.selectors.length; + uint256 numSelectors; + _facetFunctionSelectors = new bytes4[](selectorCount); + // loop through function selectors + for ( + uint256 selectorIndex; + selectorIndex < selectorCount; + selectorIndex++ + ) { + bytes4 selector = ds.selectors[selectorIndex]; + address facetAddress_ = ds + .facetAddressAndSelectorPosition[selector] + .facetAddress; + if (_facet == facetAddress_) { + _facetFunctionSelectors[numSelectors] = selector; + numSelectors++; + } + } + // Set the number of selectors in the array + assembly { + mstore(_facetFunctionSelectors, numSelectors) + } + } + + /// @notice Get all the facet addresses used by a diamond. + /// @return facetAddresses_ + function facetAddresses() + external + view + override + returns (address[] memory facetAddresses_) + { + LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage(); + uint256 selectorCount = ds.selectors.length; + // create an array set to the maximum size possible + facetAddresses_ = new address[](selectorCount); + uint256 numFacets; + // loop through function selectors + for ( + uint256 selectorIndex; + selectorIndex < selectorCount; + selectorIndex++ + ) { + bytes4 selector = ds.selectors[selectorIndex]; + address facetAddress_ = ds + .facetAddressAndSelectorPosition[selector] + .facetAddress; + bool continueLoop = false; + // see if we have collected the address already and break out of loop if we have + for (uint256 facetIndex; facetIndex < numFacets; facetIndex++) { + if (facetAddress_ == facetAddresses_[facetIndex]) { + continueLoop = true; + break; + } + } + // continue loop if we already have the address + if (continueLoop) { + continueLoop = false; + continue; + } + // include address + facetAddresses_[numFacets] = facetAddress_; + numFacets++; + } + // Set the number of facet addresses in the array + assembly { + mstore(facetAddresses_, numFacets) + } + } + + /// @notice Gets the facet address that supports the given selector. + /// @dev If facet is not found return address(0). + /// @param _functionSelector The function selector. + /// @return facetAddress_ The facet address. + function facetAddress( + bytes4 _functionSelector + ) external view override returns (address facetAddress_) { + LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage(); + facetAddress_ = ds + .facetAddressAndSelectorPosition[_functionSelector] + .facetAddress; + } + + // This implements ERC-165. + function supportsInterface( + bytes4 _interfaceId + ) external view override returns (bool) { + LibDiamond.DiamondStorage storage ds = LibDiamond.diamondStorage(); + return ds.supportedInterfaces[_interfaceId]; + } +} diff --git a/smart-contracts/contracts/diamond/facets/OwnershipFacet.sol b/smart-contracts/contracts/diamond/facets/OwnershipFacet.sol new file mode 100644 index 00000000..4bdf984d --- /dev/null +++ b/smart-contracts/contracts/diamond/facets/OwnershipFacet.sol @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import { LibDiamond } from "../libraries/LibDiamond.sol"; +import { IERC173 } from "../interfaces/IERC173.sol"; + +contract OwnershipFacet is IERC173 { + function transferOwnership(address _newOwner) external override { + LibDiamond.enforceIsContractOwner(); + LibDiamond.setContractOwner(_newOwner); + } + + function owner() external view override returns (address owner_) { + owner_ = LibDiamond.contractOwner(); + } +} diff --git a/smart-contracts/contracts/diamond/facets/Test1Facet.sol b/smart-contracts/contracts/diamond/facets/Test1Facet.sol new file mode 100644 index 00000000..b50b9574 --- /dev/null +++ b/smart-contracts/contracts/diamond/facets/Test1Facet.sol @@ -0,0 +1,82 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +// Example library to show a simple example of diamond storage + +library TestLib { + bytes32 constant DIAMOND_STORAGE_POSITION = + keccak256("diamond.standard.test.storage"); + + struct TestState { + address myAddress; + uint256 myNum; + } + + function diamondStorage() internal pure returns (TestState storage ds) { + bytes32 position = DIAMOND_STORAGE_POSITION; + assembly { + ds.slot := position + } + } + + function setMyAddress(address _myAddress) internal { + TestState storage testState = diamondStorage(); + testState.myAddress = _myAddress; + } + + function getMyAddress() internal view returns (address) { + TestState storage testState = diamondStorage(); + return testState.myAddress; + } +} + +contract Test1Facet { + event TestEvent(address something); + + function test1Func1() external { + TestLib.setMyAddress(address(this)); + } + + function test1Func2() external view returns (address) { + return TestLib.getMyAddress(); + } + function test1Func3() external {} + + function test1Func4() external {} + + function test1Func5() external {} + + function test1Func6() external {} + + function test1Func7() external {} + + function test1Func8() external {} + + function test1Func9() external {} + + function test1Func10() external {} + + function test1Func11() external {} + + function test1Func12() external {} + + function test1Func13() external {} + + function test1Func14() external {} + + function test1Func15() external {} + + function test1Func16() external {} + + function test1Func17() external {} + + function test1Func18() external {} + + function test1Func19() external {} + + function test1Func20() external {} + + function supportsInterface( + bytes4 _interfaceID + ) external view returns (bool) {} +} diff --git a/smart-contracts/contracts/diamond/facets/Test2Facet.sol b/smart-contracts/contracts/diamond/facets/Test2Facet.sol new file mode 100644 index 00000000..4145be99 --- /dev/null +++ b/smart-contracts/contracts/diamond/facets/Test2Facet.sol @@ -0,0 +1,44 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +contract Test2Facet { + function test2Func1() external {} + + function test2Func2() external {} + + function test2Func3() external {} + + function test2Func4() external {} + + function test2Func5() external {} + + function test2Func6() external {} + + function test2Func7() external {} + + function test2Func8() external {} + + function test2Func9() external {} + + function test2Func10() external {} + + function test2Func11() external {} + + function test2Func12() external {} + + function test2Func13() external {} + + function test2Func14() external {} + + function test2Func15() external {} + + function test2Func16() external {} + + function test2Func17() external {} + + function test2Func18() external {} + + function test2Func19() external {} + + function test2Func20() external {} +} diff --git a/smart-contracts/contracts/diamond/interfaces/IDiamond.sol b/smart-contracts/contracts/diamond/interfaces/IDiamond.sol new file mode 100644 index 00000000..58efc74a --- /dev/null +++ b/smart-contracts/contracts/diamond/interfaces/IDiamond.sol @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +//*****************************************************************************\ +//* Author: Nick Mudge (https://twitter.com/mudgen) +//* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 +//******************************************************************************/ + +interface IDiamond { + enum FacetCutAction { + Add, + Replace, + Remove + } + // Add=0, Replace=1, Remove=2 + + struct FacetCut { + address facetAddress; + FacetCutAction action; + bytes4[] functionSelectors; + } + + event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata); +} diff --git a/smart-contracts/contracts/diamond/interfaces/IDiamondCut.sol b/smart-contracts/contracts/diamond/interfaces/IDiamondCut.sol new file mode 100644 index 00000000..313fa4d0 --- /dev/null +++ b/smart-contracts/contracts/diamond/interfaces/IDiamondCut.sol @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +//******************************************************************************\ +//* Author: Nick Mudge (https://twitter.com/mudgen) +//* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 +//******************************************************************************/ + +import { IDiamond } from "./IDiamond.sol"; + +interface IDiamondCut is IDiamond { + /// @notice Add/replace/remove any number of functions and optionally execute + /// a function with delegatecall + /// @param _diamondCut Contains the facet addresses and function selectors + /// @param _init The address of the contract or facet to execute _calldata + /// @param _calldata A function call, including function selector and arguments + /// _calldata is executed with delegatecall on _init + function diamondCut( + FacetCut[] calldata _diamondCut, + address _init, + bytes calldata _calldata + ) external; +} diff --git a/smart-contracts/contracts/diamond/interfaces/IDiamondLoupe.sol b/smart-contracts/contracts/diamond/interfaces/IDiamondLoupe.sol new file mode 100644 index 00000000..b2a53cb4 --- /dev/null +++ b/smart-contracts/contracts/diamond/interfaces/IDiamondLoupe.sol @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +//******************************************************************************\ +//* Author: Nick Mudge (https://twitter.com/mudgen) +//* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 +//******************************************************************************/ + +// A loupe is a small magnifying glass used to look at diamonds. +// These functions look at diamonds +interface IDiamondLoupe { + /// These functions are expected to be called frequently + /// by tools. + + struct Facet { + address facetAddress; + bytes4[] functionSelectors; + } + + /// @notice Gets all facet addresses and their four byte function selectors. + /// @return facets_ Facet + function facets() external view returns (Facet[] memory facets_); + + /// @notice Gets all the function selectors supported by a specific facet. + /// @param _facet The facet address. + /// @return facetFunctionSelectors_ + function facetFunctionSelectors( + address _facet + ) external view returns (bytes4[] memory facetFunctionSelectors_); + + /// @notice Get all the facet addresses used by a diamond. + /// @return facetAddresses_ + function facetAddresses() + external + view + returns (address[] memory facetAddresses_); + + /// @notice Gets the facet that supports the given selector. + /// @dev If facet is not found return address(0). + /// @param _functionSelector The function selector. + /// @return facetAddress_ The facet address. + function facetAddress( + bytes4 _functionSelector + ) external view returns (address facetAddress_); +} diff --git a/smart-contracts/contracts/diamond/interfaces/IERC165.sol b/smart-contracts/contracts/diamond/interfaces/IERC165.sol new file mode 100644 index 00000000..ee6bc3e8 --- /dev/null +++ b/smart-contracts/contracts/diamond/interfaces/IERC165.sol @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +interface IERC165 { + /// @notice Query if a contract implements an interface + /// @param interfaceId The interface identifier, as specified in ERC-165 + /// @dev Interface identification is specified in ERC-165. This function + /// uses less than 30,000 gas. + /// @return `true` if the contract implements `interfaceID` and + /// `interfaceID` is not 0xffffffff, `false` otherwise + function supportsInterface(bytes4 interfaceId) external view returns (bool); +} diff --git a/smart-contracts/contracts/diamond/interfaces/IERC173.sol b/smart-contracts/contracts/diamond/interfaces/IERC173.sol new file mode 100644 index 00000000..e40ac3df --- /dev/null +++ b/smart-contracts/contracts/diamond/interfaces/IERC173.sol @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +/// @title ERC-173 Contract Ownership Standard +/// Note: the ERC-165 identifier for this interface is 0x7f5828d0 +/* is ERC165 */ +interface IERC173 { + /// @dev This emits when ownership of a contract changes. + event OwnershipTransferred( + address indexed previousOwner, + address indexed newOwner + ); + + /// @notice Get the address of the owner + /// @return owner_ The address of the owner. + function owner() external view returns (address owner_); + + /// @notice Set the address of the new owner of the contract + /// @dev Set _newOwner to address(0) to renounce any ownership. + /// @param _newOwner The address of the new owner of the contract + function transferOwnership(address _newOwner) external; +} diff --git a/smart-contracts/contracts/diamond/libraries/LibDiamond.sol b/smart-contracts/contracts/diamond/libraries/LibDiamond.sol new file mode 100644 index 00000000..68788ceb --- /dev/null +++ b/smart-contracts/contracts/diamond/libraries/LibDiamond.sol @@ -0,0 +1,268 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +//******************************************************************************\ +//* Author: Nick Mudge (https://twitter.com/mudgen) +//* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 +//******************************************************************************/ +import { IDiamond } from "../interfaces/IDiamond.sol"; +import { IDiamondCut } from "../interfaces/IDiamondCut.sol"; + +// Remember to add the loupe functions from DiamondLoupeFacet to the diamond. +// The loupe functions are required by the EIP2535 Diamonds standard + +error NoSelectorsGivenToAdd(); +error NotContractOwner(address _user, address _contractOwner); +error NoSelectorsProvidedForFacetForCut(address _facetAddress); +error CannotAddSelectorsToZeroAddress(bytes4[] _selectors); +error NoBytecodeAtAddress(address _contractAddress, string _message); +error IncorrectFacetCutAction(uint8 _action); +error CannotAddFunctionToDiamondThatAlreadyExists(bytes4 _selector); +error CannotReplaceFunctionsFromFacetWithZeroAddress(bytes4[] _selectors); +error CannotReplaceImmutableFunction(bytes4 _selector); +error CannotReplaceFunctionWithTheSameFunctionFromTheSameFacet( + bytes4 _selector +); +error CannotReplaceFunctionThatDoesNotExists(bytes4 _selector); +error RemoveFacetAddressMustBeZeroAddress(address _facetAddress); +error CannotRemoveFunctionThatDoesNotExist(bytes4 _selector); +error CannotRemoveImmutableFunction(bytes4 _selector); +error InitializationFunctionReverted( + address _initializationContractAddress, + bytes _calldata +); + +library LibDiamond { + bytes32 constant DIAMOND_STORAGE_POSITION = + keccak256("diamond.standard.diamond.storage"); + + struct FacetAddressAndSelectorPosition { + address facetAddress; + uint16 selectorPosition; + } + + struct DiamondStorage { + // function selector => facet address and selector position in selectors array + mapping(bytes4 => FacetAddressAndSelectorPosition) facetAddressAndSelectorPosition; + bytes4[] selectors; + mapping(bytes4 => bool) supportedInterfaces; + // owner of the contract + address contractOwner; + } + + function diamondStorage() internal pure returns (DiamondStorage storage ds) { + bytes32 position = DIAMOND_STORAGE_POSITION; + assembly { + ds.slot := position + } + } + + event OwnershipTransferred( + address indexed previousOwner, + address indexed newOwner + ); + + function setContractOwner(address _newOwner) internal { + DiamondStorage storage ds = diamondStorage(); + address previousOwner = ds.contractOwner; + ds.contractOwner = _newOwner; + emit OwnershipTransferred(previousOwner, _newOwner); + } + + function contractOwner() internal view returns (address contractOwner_) { + contractOwner_ = diamondStorage().contractOwner; + } + + function enforceIsContractOwner() internal view { + if (msg.sender != diamondStorage().contractOwner) { + revert NotContractOwner(msg.sender, diamondStorage().contractOwner); + } + } + + event DiamondCut( + IDiamondCut.FacetCut[] _diamondCut, + address _init, + bytes _calldata + ); + + // Internal function version of diamondCut + function diamondCut( + IDiamondCut.FacetCut[] memory _diamondCut, + address _init, + bytes memory _calldata + ) internal { + for (uint256 facetIndex; facetIndex < _diamondCut.length; facetIndex++) { + bytes4[] memory functionSelectors = _diamondCut[facetIndex] + .functionSelectors; + address facetAddress = _diamondCut[facetIndex].facetAddress; + if (functionSelectors.length == 0) { + revert NoSelectorsProvidedForFacetForCut(facetAddress); + } + IDiamondCut.FacetCutAction action = _diamondCut[facetIndex].action; + if (action == IDiamond.FacetCutAction.Add) { + addFunctions(facetAddress, functionSelectors); + } else if (action == IDiamond.FacetCutAction.Replace) { + replaceFunctions(facetAddress, functionSelectors); + } else if (action == IDiamond.FacetCutAction.Remove) { + removeFunctions(facetAddress, functionSelectors); + } else { + revert IncorrectFacetCutAction(uint8(action)); + } + } + emit DiamondCut(_diamondCut, _init, _calldata); + initializeDiamondCut(_init, _calldata); + } + + function addFunctions( + address _facetAddress, + bytes4[] memory _functionSelectors + ) internal { + if (_facetAddress == address(0)) { + revert CannotAddSelectorsToZeroAddress(_functionSelectors); + } + DiamondStorage storage ds = diamondStorage(); + uint16 selectorCount = uint16(ds.selectors.length); + enforceHasContractCode( + _facetAddress, + "LibDiamondCut: Add facet has no code" + ); + for ( + uint256 selectorIndex; + selectorIndex < _functionSelectors.length; + selectorIndex++ + ) { + bytes4 selector = _functionSelectors[selectorIndex]; + address oldFacetAddress = ds + .facetAddressAndSelectorPosition[selector] + .facetAddress; + if (oldFacetAddress != address(0)) { + revert CannotAddFunctionToDiamondThatAlreadyExists(selector); + } + ds.facetAddressAndSelectorPosition[ + selector + ] = FacetAddressAndSelectorPosition(_facetAddress, selectorCount); + ds.selectors.push(selector); + selectorCount++; + } + } + + function replaceFunctions( + address _facetAddress, + bytes4[] memory _functionSelectors + ) internal { + DiamondStorage storage ds = diamondStorage(); + if (_facetAddress == address(0)) { + revert CannotReplaceFunctionsFromFacetWithZeroAddress(_functionSelectors); + } + enforceHasContractCode( + _facetAddress, + "LibDiamondCut: Replace facet has no code" + ); + for ( + uint256 selectorIndex; + selectorIndex < _functionSelectors.length; + selectorIndex++ + ) { + bytes4 selector = _functionSelectors[selectorIndex]; + address oldFacetAddress = ds + .facetAddressAndSelectorPosition[selector] + .facetAddress; + // can't replace immutable functions -- functions defined directly in the diamond in this case + if (oldFacetAddress == address(this)) { + revert CannotReplaceImmutableFunction(selector); + } + if (oldFacetAddress == _facetAddress) { + revert CannotReplaceFunctionWithTheSameFunctionFromTheSameFacet( + selector + ); + } + if (oldFacetAddress == address(0)) { + revert CannotReplaceFunctionThatDoesNotExists(selector); + } + // replace old facet address + ds.facetAddressAndSelectorPosition[selector].facetAddress = _facetAddress; + } + } + + function removeFunctions( + address _facetAddress, + bytes4[] memory _functionSelectors + ) internal { + DiamondStorage storage ds = diamondStorage(); + uint256 selectorCount = ds.selectors.length; + if (_facetAddress != address(0)) { + revert RemoveFacetAddressMustBeZeroAddress(_facetAddress); + } + for ( + uint256 selectorIndex; + selectorIndex < _functionSelectors.length; + selectorIndex++ + ) { + bytes4 selector = _functionSelectors[selectorIndex]; + FacetAddressAndSelectorPosition + memory oldFacetAddressAndSelectorPosition = ds + .facetAddressAndSelectorPosition[selector]; + if (oldFacetAddressAndSelectorPosition.facetAddress == address(0)) { + revert CannotRemoveFunctionThatDoesNotExist(selector); + } + + // can't remove immutable functions -- functions defined directly in the diamond + if (oldFacetAddressAndSelectorPosition.facetAddress == address(this)) { + revert CannotRemoveImmutableFunction(selector); + } + // replace selector with last selector + selectorCount--; + if ( + oldFacetAddressAndSelectorPosition.selectorPosition != selectorCount + ) { + bytes4 lastSelector = ds.selectors[selectorCount]; + ds.selectors[ + oldFacetAddressAndSelectorPosition.selectorPosition + ] = lastSelector; + ds + .facetAddressAndSelectorPosition[lastSelector] + .selectorPosition = oldFacetAddressAndSelectorPosition + .selectorPosition; + } + // delete last selector + ds.selectors.pop(); + delete ds.facetAddressAndSelectorPosition[selector]; + } + } + + function initializeDiamondCut( + address _init, + bytes memory _calldata + ) internal { + if (_init == address(0)) { + return; + } + enforceHasContractCode(_init, "LibDiamondCut: _init address has no code"); + (bool success, bytes memory error) = _init.delegatecall(_calldata); + if (!success) { + if (error.length > 0) { + // bubble up error + /// @solidity memory-safe-assembly + assembly { + let returndata_size := mload(error) + revert(add(32, error), returndata_size) + } + } else { + revert InitializationFunctionReverted(_init, _calldata); + } + } + } + + function enforceHasContractCode( + address _contract, + string memory _errorMessage + ) internal view { + uint256 contractSize; + assembly { + contractSize := extcodesize(_contract) + } + if (contractSize == 0) { + revert NoBytecodeAtAddress(_contract, _errorMessage); + } + } +} diff --git a/smart-contracts/contracts/diamond/upgradeInitializers/DiamondMultiInit.sol b/smart-contracts/contracts/diamond/upgradeInitializers/DiamondMultiInit.sol new file mode 100644 index 00000000..32b7d5e5 --- /dev/null +++ b/smart-contracts/contracts/diamond/upgradeInitializers/DiamondMultiInit.sol @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +//******************************************************************************\ +//* Author: Nick Mudge (https://twitter.com/mudgen) +//* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 +//* +//* Implementation of a diamond. +//******************************************************************************/ + +import { LibDiamond } from "../libraries/LibDiamond.sol"; + +error AddressAndCalldataLengthDoNotMatch( + uint256 _addressesLength, + uint256 _calldataLength +); + +contract DiamondMultiInit { + // This function is provided in the third parameter of the `diamondCut` function. + // The `diamondCut` function executes this function to execute multiple initializer functions for a single upgrade. + + function multiInit( + address[] calldata _addresses, + bytes[] calldata _calldata + ) external { + if (_addresses.length != _calldata.length) { + revert AddressAndCalldataLengthDoNotMatch( + _addresses.length, + _calldata.length + ); + } + for (uint i; i < _addresses.length; i++) { + LibDiamond.initializeDiamondCut(_addresses[i], _calldata[i]); + } + } +} diff --git a/smart-contracts/contracts/AgentRegistry.sol b/smart-contracts/contracts/facets/AgentRegistry.sol similarity index 70% rename from smart-contracts/contracts/AgentRegistry.sol rename to smart-contracts/contracts/facets/AgentRegistry.sol index 1eb6aad9..0761778c 100644 --- a/smart-contracts/contracts/AgentRegistry.sol +++ b/smart-contracts/contracts/facets/AgentRegistry.sol @@ -2,28 +2,27 @@ pragma solidity ^0.8.24; import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; -import {KeySet} from "./KeySet.sol"; -import "hardhat/console.sol"; +import { KeySet } from "../libraries/KeySet.sol"; -contract ModelRegistry is OwnableUpgradeable { +contract AgentRegistry is OwnableUpgradeable { using KeySet for KeySet.Set; struct Agent { + bytes32 agentId; uint256 fee; uint256 stake; uint256 timestamp; address owner; - bytes32 uuid; - string name; // limit name length - string[] tags; // TODO: limit tags amount + string name; // limit name length + string[] tags; // TODO: limit tags amount } error StakeTooLow(); error NotSenderOrOwner(); error ModelNotFound(); - event RegisteredUpdated(address indexed owner, bytes32 indexed uuid); - event Deregistered(address indexed owner, bytes32 indexed uuid); + event RegisteredUpdated(address indexed owner, bytes32 indexed agentId); + event Deregistered(address indexed owner, bytes32 indexed agentId); event MinStakeUpdated(uint256 newStake); // state @@ -39,11 +38,11 @@ contract ModelRegistry is OwnableUpgradeable { __Ownable_init(); } - function getIds() public view returns (bytes32[] memory){ + function getIds() public view returns (bytes32[] memory) { return set.keys(); } - function getAll() public view returns (Agent[] memory){ + function getAll() public view returns (Agent[] memory) { Agent[] memory _agents = new Agent[](set.count()); for (uint i = 0; i < set.count(); i++) { _agents[i] = map[set.keyAtIndex(i)]; @@ -51,31 +50,42 @@ contract ModelRegistry is OwnableUpgradeable { return _agents; } + function exists(bytes32 id) public view returns (bool) { + return set.exists(id); + } + // registers new or updates existing - function register(uint256 addStake, uint256 fee, address owner, bytes32 uuid, string memory name, string[] memory tags) public senderOrOwner(owner){ - uint256 stake = map[uuid].stake; + function register( + uint256 addStake, + uint256 fee, + address owner, + bytes32 agentId, + string memory name, + string[] memory tags + ) public senderOrOwner(owner) { + uint256 stake = map[agentId].stake; uint256 newStake = stake + addStake; if (newStake < minStake) { revert StakeTooLow(); } if (stake == 0) { - set.insert(uuid); + set.insert(agentId); } else { - _senderOrOwner(map[uuid].owner); + _senderOrOwner(map[agentId].owner); } - map[uuid] = Agent({ + map[agentId] = Agent({ fee: fee, stake: newStake, timestamp: block.timestamp, owner: owner, - uuid: uuid, + agentId: agentId, name: name, tags: tags }); - emit RegisteredUpdated(owner, uuid); + emit RegisteredUpdated(owner, agentId); token.transferFrom(_msgSender(), address(this), addStake); // reverts with ERC20InsufficientAllowance } @@ -102,8 +112,8 @@ contract ModelRegistry is OwnableUpgradeable { _; } - function _senderOrOwner(address addr) internal view { - if (addr != _msgSender() && addr != owner()) { + function _senderOrOwner(address resourceOwner) internal view { + if (_msgSender() != resourceOwner && _msgSender() != owner()) { revert NotSenderOrOwner(); } } @@ -118,4 +128,4 @@ contract ModelRegistry is OwnableUpgradeable { // } // return _models; // } -} \ No newline at end of file +} diff --git a/smart-contracts/contracts/facets/Marketplace.sol b/smart-contracts/contracts/facets/Marketplace.sol new file mode 100644 index 00000000..6212573b --- /dev/null +++ b/smart-contracts/contracts/facets/Marketplace.sol @@ -0,0 +1,201 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.24; +import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; +import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; +import { MessageHashUtils } from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol"; +import { IERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; +import { ModelRegistry } from "./ModelRegistry.sol"; +import { ProviderRegistry } from "./ProviderRegistry.sol"; +import { AppStorage, Bid } from "../AppStorage.sol"; +import { KeySet } from "../libraries/KeySet.sol"; +import { LibOwner } from "../libraries/LibOwner.sol"; + +contract Marketplace { + using KeySet for KeySet.Set; + + AppStorage internal s; + + event BidPosted( + address indexed provider, + bytes32 indexed modelAgentId, + uint256 nonce + ); + event BidDeleted( + address indexed provider, + bytes32 indexed modelAgentId, + uint256 nonce + ); + event FeeUpdated(uint256 bidFee); + + error ProviderNotFound(); + error ModelOrAgentNotFound(); + error ActiveBidNotFound(); + error BidNotFound(); + error BidTaken(); + error NotEnoughBalance(); + + function bidMap(bytes32 bidId) public view returns (Bid memory) { + return s.bidMap[bidId]; + } + + function getActiveBidsByProvider( + address provider + ) public view returns (Bid[] memory) { + KeySet.Set storage providerBidsSet = s.providerActiveBids[provider]; + Bid[] memory _bids = new Bid[](providerBidsSet.count()); + for (uint i = 0; i < providerBidsSet.count(); i++) { + _bids[i] = s.bidMap[providerBidsSet.keyAtIndex(i)]; + } + return _bids; + } + + // returns active bids by model agent + function getActiveBidsByModelAgent( + bytes32 modelAgentId + ) public view returns (Bid[] memory) { + KeySet.Set storage modelAgentBidsSet = s.modelAgentActiveBids[modelAgentId]; + Bid[] memory _bids = new Bid[](modelAgentBidsSet.count()); + for (uint i = 0; i < modelAgentBidsSet.count(); i++) { + _bids[i] = s.bidMap[modelAgentBidsSet.keyAtIndex(i)]; + } + return _bids; + } + + // returns all bids by provider sorted from newest to oldest + function getBidsByProvider( + address provider, + uint256 offset, + uint8 limit + ) public view returns (Bid[] memory) { + uint256 length = s.providerBids[provider].length; + if (length < offset) { + return new Bid[](0); + } + uint8 size = offset + limit > length ? uint8(length - offset) : limit; + Bid[] memory _bids = new Bid[](size); + for (uint i = 0; i < size; i++) { + uint256 index = length - offset - i - 1; + bytes32 id = s.providerBids[provider][index]; + _bids[i] = s.bidMap[id]; + } + return _bids; + } + + // returns all bids by provider sorted from newest to oldest + function getBidsByModelAgent( + bytes32 modelAgentId, + uint256 offset, + uint8 limit + ) public view returns (Bid[] memory) { + uint256 length = s.modelAgentBids[modelAgentId].length; + if (length < offset) { + return new Bid[](0); + } + uint8 size = offset + limit > length ? uint8(length - offset) : limit; + Bid[] memory _bids = new Bid[](size); + for (uint i = 0; i < size; i++) { + uint256 index = length - offset - i - 1; + bytes32 id = s.modelAgentBids[modelAgentId][index]; + _bids[i] = s.bidMap[id]; + } + return _bids; + } + + function postModelBid( + address providerAddr, + bytes32 modelId, + uint256 pricePerSecond + ) public returns (bytes32 bidId) { + LibOwner._senderOrOwner(providerAddr); + if (s.providerMap[providerAddr].isDeleted) { + revert ProviderNotFound(); + } + if (s.modelMap[modelId].isDeleted) { + revert ModelOrAgentNotFound(); + } + + return postModelAgentBid(providerAddr, modelId, pricePerSecond); + } + + function postModelAgentBid( + address provider, + bytes32 modelAgentId, + uint256 pricePerSecond + ) internal returns (bytes32 bidId) { + // remove old bid + + // TEST IT if it increments nonce correctly + uint256 nonce = s.providerModelAgentNonce[ + keccak256(abi.encodePacked(provider, modelAgentId)) + ]++; + if (nonce > 0) { + deleteModelAgentBid( + keccak256(abi.encodePacked(provider, modelAgentId, nonce - 1)) + ); + } + + bidId = keccak256(abi.encodePacked(provider, modelAgentId, nonce)); + + s.bidMap[bidId] = Bid({ + provider: provider, + modelAgentId: modelAgentId, + pricePerSecond: pricePerSecond, + nonce: nonce, + createdAt: block.timestamp, + deletedAt: 0 + }); + + // active indexes + s.activeBids.insert(bidId); + s.providerActiveBids[provider].insert(bidId); + s.modelAgentActiveBids[modelAgentId].insert(bidId); + + // all indexes + s.providerBids[provider].push(bidId); + s.modelAgentBids[modelAgentId].push(bidId); + + emit BidPosted(provider, modelAgentId, nonce); + + s.token.transferFrom(msg.sender, address(this), s.bidFee); + s.feeBalance += s.bidFee; + + return bidId; + } + + function deleteModelAgentBid(bytes32 bidId) public { + Bid storage bid = s.bidMap[bidId]; + if (bid.createdAt == 0 || bid.deletedAt != 0) { + revert ActiveBidNotFound(); + } + + LibOwner._senderOrOwner(bid.provider); + + bid.deletedAt = block.timestamp; + // indexes update + s.activeBids.remove(bidId); + s.providerActiveBids[bid.provider].remove(bidId); + s.modelAgentActiveBids[bid.modelAgentId].remove(bidId); + + emit BidDeleted(bid.provider, bid.modelAgentId, bid.nonce); + } + + function setBidFee(uint256 _bidFee) public { + LibOwner._onlyOwner(); + s.bidFee = _bidFee; + emit FeeUpdated(_bidFee); + } + + function bidFee() public view returns (uint256) { + return s.bidFee; + } + + function withdraw(address addr, uint256 amount) public { + LibOwner._onlyOwner(); + if (amount > s.feeBalance) { + revert NotEnoughBalance(); + } + // emits ERC-20 transfer event + s.feeBalance -= amount; + s.token.transfer(addr, amount); + } +} diff --git a/smart-contracts/contracts/facets/ModelRegistry.sol b/smart-contracts/contracts/facets/ModelRegistry.sol new file mode 100644 index 00000000..15aaa55d --- /dev/null +++ b/smart-contracts/contracts/facets/ModelRegistry.sol @@ -0,0 +1,129 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.24; +import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; +import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; +import { AppStorage, Model } from "../AppStorage.sol"; +import { KeySet } from "../libraries/KeySet.sol"; +import { LibOwner } from "../libraries/LibOwner.sol"; + +contract ModelRegistry { + using KeySet for KeySet.Set; + + AppStorage internal s; + + event ModelRegisteredUpdated(address indexed owner, bytes32 indexed modelId); + event ModelDeregistered(address indexed owner, bytes32 indexed modelId); + event ModelMinStakeUpdated(uint256 newStake); + + error ModelNotFound(); + error StakeTooLow(); + + function modelMap(bytes32 id) public view returns (Model memory) { + return s.modelMap[id]; + } + + function models(uint256 index) public view returns (bytes32) { + return s.models[index]; + } + + function modelGetIds() public view returns (bytes32[] memory) { + return s.activeModels.keys(); + } + + function modelGetCount() public view returns (uint count) { + return s.activeModels.count(); + } + + function modelGetAll() public view returns (Model[] memory) { + Model[] memory _models = new Model[](s.activeModels.count()); + for (uint i = 0; i < s.activeModels.count(); i++) { + _models[i] = s.modelMap[s.activeModels.keyAtIndex(i)]; + } + return _models; + } + + function modelGetByIndex( + uint index + ) public view returns (bytes32 modelId, Model memory model) { + modelId = s.activeModels.keyAtIndex(index); + return (modelId, s.modelMap[modelId]); + } + + function modelExists(bytes32 id) public view returns (bool) { + return s.activeModels.exists(id); + } + + // registers new model or updates existing + function modelRegister( + bytes32 modelId, + bytes32 ipfsCID, + uint256 fee, + uint256 addStake, + address owner, + string memory name, + string[] memory tags + ) public { + LibOwner._senderOrOwner(owner); + Model memory model = s.modelMap[modelId]; + uint256 newStake = model.stake + addStake; + if (newStake < s.modelMinStake) { + revert StakeTooLow(); + } + if (model.stake == 0) { + s.activeModels.insert(modelId); + s.models.push(modelId); + } else { + LibOwner._senderOrOwner(s.modelMap[modelId].owner); + } + + s.modelMap[modelId] = Model({ + fee: fee, + stake: newStake, + timestamp: uint128(block.timestamp), + ipfsCID: ipfsCID, + owner: owner, + name: name, + tags: tags, + isDeleted: false + }); + + emit ModelRegisteredUpdated(owner, modelId); + s.token.transferFrom(msg.sender, address(this), addStake); // reverts with ERC20InsufficientAllowance + } + + function modelDeregister(bytes32 id) public { + Model storage model = s.modelMap[id]; + LibOwner._senderOrOwner(model.owner); + + s.activeModels.remove(id); + model.isDeleted = true; + uint256 stake = model.stake; + + emit ModelDeregistered(model.owner, id); + s.token.transfer(model.owner, stake); + } + + function modelSetMinStake(uint256 _minStake) public { + LibOwner._onlyOwner(); + s.modelMinStake = _minStake; + emit ModelMinStakeUpdated(s.modelMinStake); + } + + function modelMinStake() public view returns (uint256) { + return s.modelMinStake; + } + + // TODO: implement these functions + // function getModelsByOwner(address addr) public view returns (Model[] memory){ + // Model[] memory _models = new Model[](modelIds.length); + // for (uint i = 0; i < modelIds.length; i++) { + // if (models[modelIds[i]].owner == addr) { + // _models[i] = models[modelIds[i]]; + // } + // } + // return _models; + // } + + // function getModelTypes -- to be implemented when types are defined + // function getModelsByType +} diff --git a/smart-contracts/contracts/facets/ProviderRegistry.sol b/smart-contracts/contracts/facets/ProviderRegistry.sol new file mode 100644 index 00000000..65f2b8f9 --- /dev/null +++ b/smart-contracts/contracts/facets/ProviderRegistry.sol @@ -0,0 +1,116 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.24; +import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; +import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; +import { AddressSet } from "../libraries/KeySet.sol"; +import { AppStorage, Provider } from "../AppStorage.sol"; +import { LibOwner } from "../libraries/LibOwner.sol"; + +contract ProviderRegistry { + using AddressSet for AddressSet.Set; + + AppStorage internal s; + + event ProviderRegisteredUpdated(address indexed provider); + event ProviderDeregistered(address indexed provider); + event ProviderMinStakeUpdated(uint256 newStake); + + error StakeTooLow(); + + function providerMap(address addr) public view returns (Provider memory) { + return s.providerMap[addr]; + } + + function providers(uint256 index) public view returns (address) { + return s.providers[index]; + } + + function providerGetIds() public view returns (address[] memory) { + return s.activeProviders.keys(); + } + + function providerGetCount() public view returns (uint count) { + return s.activeProviders.count(); + } + + function providerGetByIndex( + uint index + ) public view returns (address addr, Provider memory provider) { + addr = s.activeProviders.keyAtIndex(index); + return (addr, s.providerMap[addr]); + } + + function providerGetAll() + public + view + returns (address[] memory, Provider[] memory) + { + uint256 count = s.activeProviders.count(); + address[] memory _addrs = new address[](count); + Provider[] memory _providers = new Provider[](count); + + for (uint i = 0; i < count; i++) { + address addr = s.activeProviders.keyAtIndex(i); + _addrs[i] = addr; + _providers[i] = s.providerMap[addr]; + } + + return (_addrs, _providers); + } + + // registers new provider or updates existing + function providerRegister( + address addr, + uint256 addStake, + string memory endpoint + ) public { + LibOwner._senderOrOwner(addr); + Provider memory provider = s.providerMap[addr]; + uint256 newStake = provider.stake + addStake; + if (newStake < s.providerMinStake) { + revert StakeTooLow(); + } + if (provider.timestamp == 0) { + s.activeProviders.insert(addr); + s.providers.push(addr); + } else { + LibOwner._senderOrOwner(addr); + } + + s.providerMap[addr] = Provider( + endpoint, + newStake, + uint128(block.timestamp), + false + ); + + emit ProviderRegisteredUpdated(addr); + + s.token.transferFrom(msg.sender, address(this), addStake); // reverts with ERC20InsufficientAllowance + } + + function providerDeregister(address addr) public { + LibOwner._senderOrOwner(addr); + s.activeProviders.remove(addr); + + s.providerMap[addr].isDeleted = true; + uint256 stake = s.providerMap[addr].stake; + + emit ProviderDeregistered(addr); + s.token.transfer(addr, stake); + } + + function providerSetMinStake(uint256 _minStake) public { + LibOwner._onlyOwner(); + s.providerMinStake = _minStake; + emit ProviderMinStakeUpdated(_minStake); + } + + function providrerExists(address addr) public view returns (bool) { + return s.activeProviders.exists(addr); + } + + function providerMinStake() public view returns (uint256) { + return s.providerMinStake; + } +} diff --git a/smart-contracts/contracts/facets/SessionRouter.sol b/smart-contracts/contracts/facets/SessionRouter.sol new file mode 100644 index 00000000..df349691 --- /dev/null +++ b/smart-contracts/contracts/facets/SessionRouter.sol @@ -0,0 +1,291 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.24; + +import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; +import { ECDSA } from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; +import { MessageHashUtils } from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol"; +import { IERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; +import { KeySet } from "../libraries/KeySet.sol"; +import { ModelRegistry } from "./ModelRegistry.sol"; +import { ProviderRegistry } from "./ProviderRegistry.sol"; +import { AppStorage, Session, Bid, OnHold } from "../AppStorage.sol"; +import { LibOwner } from "../libraries/LibOwner.sol"; + +contract SessionRouter { + using KeySet for KeySet.Set; + AppStorage internal s; + + // constants + uint32 constant DAY = 24 * 60 * 60; // 1 day + uint32 constant MIN_SESSION_DURATION = 5 * 60; // 5 minutes + + // events + event SessionOpened( + address indexed userAddress, + bytes32 indexed sessionId, + address indexed providerId + ); + event SessionClosed( + address indexed userAddress, + bytes32 indexed sessionId, + address indexed providerId + ); + event Staked(address indexed userAddress, uint256 amount); + event Unstaked(address indexed userAddress, uint256 amount); + event ProviderClaimed(address indexed providerAddress, uint256 amount); + + // errors + error NotUserOrProvider(); + error NotUser(); + + error NotEnoughWithdrawableBalance(); + error NotEnoughStipend(); + error NotEnoughStake(); + error NotEnoughBalance(); + + error InvalidSignature(); + error SessionTooShort(); + error SessionNotFound(); + + error BidNotFound(); + error BidTaken(); + + //=========================== + // SESSION + //=========================== + + function getSession(bytes32 sessionId) public view returns (Session memory) { + return s.sessions[s.sessionMap[sessionId]]; + } + + function openSession( + bytes32 bidId, + uint256 _stake + ) public returns (bytes32 sessionId) { + address sender = msg.sender; + + Bid memory bid = s.bidMap[bidId]; + if (bid.deletedAt != 0 || bid.createdAt == 0) { + revert BidNotFound(); + } + + if (s.bidSessionMap[bidId] != 0) { + // TODO: some bids might be already taken by other sessions + // but the session list in marketplace is ignorant of this fact. + // Marketplace and SessionRouter contracts should be merged together + // to avoid this issue and update indexes by avoiding costly intercontract calls + revert BidTaken(); + } + + uint256 duration = balanceOfSessionStipend(_stake) / bid.pricePerSecond; + if (duration < MIN_SESSION_DURATION) { + revert SessionTooShort(); + } + + sessionId = keccak256( + abi.encodePacked(sender, bid.provider, _stake, block.number) + ); + s.sessions.push( + Session({ + id: sessionId, + user: sender, + provider: bid.provider, + modelAgentId: bid.modelAgentId, + bidID: bidId, + stake: _stake, + pricePerSecond: bid.pricePerSecond, + closeoutReceipt: "", + closeoutType: 0, + openedAt: block.timestamp, + closedAt: 0 + }) + ); + + uint256 sessionIndex = s.sessions.length - 1; + s.sessionMap[sessionId] = sessionIndex; + s.bidSessionMap[bidId] = sessionIndex; // marks bid as "taken" by this session + + emit SessionOpened(sender, sessionId, bid.provider); + + s.token.transferFrom(sender, address(this), _stake); // errors with Insufficient Allowance if not approved + + return sessionId; + } + + // returns expected session duration in seconds + // should be called daily 00:00:00 UTC + // returns 24 hours if session should not be closed today + function getExpectedDuration( + uint256 _stake, + uint256 pricePerSecond + ) public view returns (uint256) { + uint256 stipend = balanceOfSessionStipend(_stake); + if (stipend > pricePerSecond) { + return DAY; + } + return (stipend / pricePerSecond) * 60 * 60; + } + + function closeSession( + bytes32 sessionId, + bytes memory receiptEncoded, + bytes memory signature + ) public { + Session storage session = s.sessions[s.sessionMap[sessionId]]; + if (session.openedAt == 0) { + revert SessionNotFound(); + } + if (session.user != msg.sender && session.provider != msg.sender) { + revert NotUserOrProvider(); + } + + s.bidSessionMap[session.bidID] = 0; // marks bid as available + session.closeoutReceipt = receiptEncoded; + session.closedAt = block.timestamp; + + uint256 durationSeconds = session.closedAt - session.openedAt; + uint256 cost = durationSeconds * session.pricePerSecond; + + // TODO: partially return stake according to the usage + // and put rest on hold for 24 hours + + if (isValidReceipt(session.provider, receiptEncoded, signature)) { + s.token.transfer(session.provider, cost); + } else { + session.closeoutType = 1; + s.providerOnHold[session.provider].push( + OnHold({ amount: cost, releaseAt: block.timestamp + DAY }) + ); + } + } + // funds related functions + + function getProviderBalance( + address providerAddr + ) public view returns (uint256 total, uint256 hold) { + OnHold[] memory onHold = s.providerOnHold[providerAddr]; + for (uint i = 0; i < onHold.length; i++) { + total += onHold[i].amount; + if (block.timestamp < onHold[i].releaseAt) { + hold += onHold[i].amount; + } + } + return (total, hold); + } + + // transfers provider claimable balance to provider address. + // set amount to 0 to claim all balance. + function claimProviderBalance(uint256 amountToWithdraw, address to) public { + uint256 balance = 0; + address sender = msg.sender; + + OnHold[] storage onHoldEntries = s.providerOnHold[sender]; + uint i = 0; + // the only loop that is not avoidable + while (i < onHoldEntries.length) { + if (block.timestamp > onHoldEntries[i].releaseAt) { + balance += onHoldEntries[i].amount; + + if (balance >= amountToWithdraw) { + uint256 delta = balance - amountToWithdraw; + onHoldEntries[i].amount = delta; + s.token.transfer(to, amountToWithdraw); + return; + } + + onHoldEntries[i] = onHoldEntries[onHoldEntries.length - 1]; + onHoldEntries.pop(); + } else { + i++; + } + } + + revert NotEnoughBalance(); + } + + function deleteHistory(bytes32 sessionId) public { + Session storage session = s.sessions[s.sessionMap[sessionId]]; + LibOwner._senderOrOwner(session.user); + session.user = address(0); + } + + function setStakeDelay(int256 delay) public { + LibOwner._onlyOwner(); + s.stakeDelay = delay; + } + + function isValidReceipt( + address signer, + bytes memory receipt, + bytes memory signature + ) public pure returns (bool) { + if (signature.length == 0) { + return false; + } + bytes32 receiptHash = MessageHashUtils.toEthSignedMessageHash( + keccak256(receipt) + ); + return ECDSA.recover(receiptHash, signature) == signer; + } + + //=========================== + // STAKING + //=========================== + + function withdrawableStakeBalance( + address userAddress + ) public view returns (uint256) { + //TODO: return user stake (on hold and withdrawable) + return 0; + } + + // return virtual MOR balance of user based on their stake + // DEPRECATED + // function balanceOfDailyStipend(address userAddress) public view returns (uint256) { + // return getTodaysBudget() * userStake[userAddress] / token.totalSupply() - getTodaysSpend(userAddress); + // } + + function balanceOfSessionStipend( + uint256 sessionStake + ) public view returns (uint256) { + return (getTodaysBudget() * sessionStake) / s.token.totalSupply(); + } + + function getTodaysSpend(address userAddress) public view returns (uint256) { + // OnHold memory spend = todaysSpend[userAddress]; + // if (block.timestamp > spend.releaseAt) { + // return 0; + // } + // return spend.amount; + // + // TODO: implement global counter of how much was spent today + return 0; + } + + function getTodaysBudget() public view returns (uint256) { + // 1% of Compute Balance + return getComputeBalance() / 100; + } + + function getComputeBalance() public view returns (uint256) { + // TODO: or call layer 1 contract to get daily compute balance contract + // + // arguments for getPeriodReward call + // address public constant distributionContractAddr = address(0x0); + // uint32 public constant distributionRewardStartTime = 1707350400; // ephochSeconds Feb 8 2024 00:00:00 + // uint8 public constant distributionPoolId = 3; + // + // return Distribution(distributionContractAddr) + // .getPeriodReward(distributionPoolId, distributionRewardStartTime, block.timestamp) + // return token.allowance(address(token), address(this)); + return 10 * 10 ** 18; // 10 tokens + } + + //=========================== + // BIDS + //=========================== + + //=========================== + // ACCESS CONTROL + //=========================== +} diff --git a/smart-contracts/contracts/libraries/KeySet.sol b/smart-contracts/contracts/libraries/KeySet.sol new file mode 100644 index 00000000..f2b55bc4 --- /dev/null +++ b/smart-contracts/contracts/libraries/KeySet.sol @@ -0,0 +1,115 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.24; + +// inspired by https://github.com/rob-Hitchens/UnorderedKeySet/blob/master/contracts/HitchensUnorderedKeySet.sol +library KeySet { + struct Set { + mapping(bytes32 => uint) keyPointers; + bytes32[] keyList; + } + + error ZeroKey(); + error KeyExists(); + error KeyNotFound(); + + function insert(Set storage self, bytes32 key) internal { + if (key == 0x0) { + revert ZeroKey(); + } + if (exists(self, key)) { + revert KeyExists(); + } + + self.keyPointers[key] = self.keyList.length; + self.keyList.push(key); + } + + function remove(Set storage self, bytes32 key) internal { + if (!exists(self, key)) { + revert KeyNotFound(); + } + + bytes32 keyToMove = self.keyList[count(self) - 1]; + uint rowToReplace = self.keyPointers[key]; + self.keyPointers[keyToMove] = rowToReplace; + self.keyList[rowToReplace] = keyToMove; + delete self.keyPointers[key]; + self.keyList.pop(); + } + + function count(Set storage self) internal view returns (uint) { + return (self.keyList.length); + } + + function exists(Set storage self, bytes32 key) internal view returns (bool) { + if (self.keyList.length == 0) return false; + return self.keyList[self.keyPointers[key]] == key; + } + + function keyAtIndex( + Set storage self, + uint index + ) internal view returns (bytes32) { + return self.keyList[index]; + } + + function keys(Set storage self) internal view returns (bytes32[] memory) { + return self.keyList; + } +} + +library AddressSet { + struct Set { + mapping(address => uint) keyPointers; + address[] keyList; + } + + error ZeroKey(); + error KeyExists(); + error KeyNotFound(); + + function insert(Set storage self, address key) internal { + if (key == address(0)) { + revert ZeroKey(); + } + if (exists(self, key)) { + revert KeyExists(); + } + + self.keyPointers[key] = self.keyList.length; + self.keyList.push(key); + } + + function remove(Set storage self, address key) internal { + if (!exists(self, key)) { + revert KeyNotFound(); + } + + address keyToMove = self.keyList[count(self) - 1]; + uint rowToReplace = self.keyPointers[key]; + self.keyPointers[keyToMove] = rowToReplace; + self.keyList[rowToReplace] = keyToMove; + delete self.keyPointers[key]; + self.keyList.pop(); + } + + function count(Set storage self) internal view returns (uint) { + return (self.keyList.length); + } + + function exists(Set storage self, address key) internal view returns (bool) { + if (self.keyList.length == 0) return false; + return self.keyList[self.keyPointers[key]] == key; + } + + function keyAtIndex( + Set storage self, + uint index + ) internal view returns (address) { + return self.keyList[index]; + } + + function keys(Set storage self) internal view returns (address[] memory) { + return self.keyList; + } +} diff --git a/smart-contracts/contracts/libraries/LibOwner.sol b/smart-contracts/contracts/libraries/LibOwner.sol new file mode 100644 index 00000000..0c161412 --- /dev/null +++ b/smart-contracts/contracts/libraries/LibOwner.sol @@ -0,0 +1,29 @@ +//SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import { LibDiamond } from "../diamond/libraries/LibDiamond.sol"; + +library LibOwner { + error NotSenderOrOwner(); + + modifier onlyOwner() { + LibDiamond.enforceIsContractOwner(); + _; + } + + modifier senderOrOwner(address addr) { + _senderOrOwner(addr); + _; + } + + function _senderOrOwner(address resourceOwner) internal view { + address owner = LibDiamond.diamondStorage().contractOwner; + if (msg.sender != resourceOwner && msg.sender != owner) { + revert NotSenderOrOwner(); + } + } + + function _onlyOwner() internal view { + LibDiamond.enforceIsContractOwner(); + } +} diff --git a/smart-contracts/hardhat.config.ts b/smart-contracts/hardhat.config.ts index 4b56e3cd..be91361b 100644 --- a/smart-contracts/hardhat.config.ts +++ b/smart-contracts/hardhat.config.ts @@ -1,8 +1,34 @@ +import "dotenv/config"; import { HardhatUserConfig } from "hardhat/config"; import "@nomicfoundation/hardhat-toolbox-viem"; +import "@solarity/hardhat-gobind"; const config: HardhatUserConfig = { solidity: "0.8.24", + mocha: { + reporter: "nyan", + }, + gasReporter: { + enabled: process.env.REPORT_GAS ? true : false, + outputJSON: true, + outputJSONFile: "gas.json", + coinmarketcap: process.env.COINMARKETCAP_API_KEY, + darkMode: true, + currency: "USD", + L2Etherscan: "E6UST5HFK6DNNTVUV1YTTRTN3BX727G8SU", + L2: "arbitrum", + L1: "ethereum", + }, + gobind: { + outdir: "./bindings/go", + onlyFiles: ["./contracts"], + skipFiles: [ + "contracts/AppStorage.sol", + "contracts/libraries", + "contracts/diamond/libraries", + "contracts/diamond/interfaces", + ], + }, }; export default config; diff --git a/smart-contracts/libraries/diamond.ts b/smart-contracts/libraries/diamond.ts new file mode 100644 index 00000000..e0c49318 --- /dev/null +++ b/smart-contracts/libraries/diamond.ts @@ -0,0 +1,93 @@ +import { Abi, AbiFunction, AbiItem, toFunctionHash } from "viem"; + +export const FacetCutAction = { + Add: 0, + Replace: 1, + Remove: 2, +}; + +export function isFunctionExceptInitAbi(abi: AbiItem): abi is AbiFunction { + return abi.type === "function" && abi.name !== "init"; +} + +// get function selectors from ABI +export function getSelectors(abi: Abi) { + return abi.filter(isFunctionExceptInitAbi).map((item) => { + const hash = toFunctionHash(item); + // return "0x" + 4 bytes of the hash + return hash.slice(0, 2 + 8); + }); +} + +// export function getSelectors(contract) { +// const signatures = Object.keys(contract.interface.functions); +// const selectors = signatures.reduce((acc, val) => { +// if (val !== "init(bytes)") { +// acc.push(contract.interface.getSighash(val)); +// } +// return acc; +// }, []); +// selectors.contract = contract; +// selectors.remove = remove; +// selectors.get = get; +// return selectors; +// } + +// get function selector from function signature +export function getSelector(func) { + const abiInterface = new ethers.utils.Interface([func]); + return abiInterface.getSighash(ethers.utils.Fragment.from(func)); +} + +// used with getSelectors to remove selectors from an array of selectors +// functionNames argument is an array of function signatures +export function remove(functionNames) { + const selectors = this.filter((v) => { + for (const functionName of functionNames) { + if (v === this.contract.interface.getSighash(functionName)) { + return false; + } + } + return true; + }); + selectors.contract = this.contract; + selectors.remove = this.remove; + selectors.get = this.get; + return selectors; +} + +// used with getSelectors to get selectors from an array of selectors +// functionNames argument is an array of function signatures +export function get(functionNames) { + const selectors = this.filter((v) => { + for (const functionName of functionNames) { + if (v === this.contract.interface.getSighash(functionName)) { + return true; + } + } + return false; + }); + selectors.contract = this.contract; + selectors.remove = this.remove; + selectors.get = this.get; + return selectors; +} + +// remove selectors using an array of signatures +export function removeSelectors(selectors, signatures) { + const iface = new ethers.utils.Interface( + signatures.map((v) => "function " + v), + ); + const removeSelectors = signatures.map((v) => iface.getSighash(v)); + selectors = selectors.filter((v) => !removeSelectors.includes(v)); + return selectors; +} + +// find a particular address position in the return value of diamondLoupeFacet.facets() +export function findAddressPositionInFacets(facetAddress, facets) { + for (let i = 0; i < facets.length; i++) { + if (facets[i].facetAddress === facetAddress) { + return i; + } + } +} diff --git a/smart-contracts/package.json b/smart-contracts/package.json index 2fb98671..ba51596c 100644 --- a/smart-contracts/package.json +++ b/smart-contracts/package.json @@ -12,7 +12,8 @@ "verify": "hardhat verify", "bindings-go": "hardhat gobind", "node-local": "hardhat node", - "deploy-local": "hardhat run --network localhost scripts/deploy-local.ts" + "deploy-local": "hardhat run --network localhost scripts/deploy-local.ts", + "format": "prettier --write \"contracts/**/*.sol\"" }, "devDependencies": { "@nomicfoundation/hardhat-ignition": "^0.15.0", @@ -22,18 +23,22 @@ "@nomicfoundation/hardhat-verify": "^2.0.0", "@nomicfoundation/hardhat-viem": "^2.0.0", "@openzeppelin/contracts": "^5.0.2", + "@solarity/hardhat-gobind": "^1.2.2", "@types/chai": "^4.2.0", "@types/chai-as-promised": "^7.1.6", + "@types/dotenv": "^8.2.0", "@types/mocha": ">=9.1.0", "@types/node": ">=18.0.0", "chai": "^4.2.0", - "hardhat": "^2.22.1", - "hardhat-gas-reporter": "^1.0.8", + "hardhat": "^2.22.3", + "hardhat-gas-reporter": "^2.1.1", "morpheus-smart-contracts": "git+ssh://github.com/MorpheusAIs/SmartContracts.git#753accd", - "solidity-coverage": "^0.8.0", + "prettier": "^3.2.5", + "prettier-plugin-solidity": "^1.3.1", + "solidity-coverage": "^0.8.12", "ts-node": ">=8.0.0", "typescript": "~5.0.4", - "viem": "^2.7.6" + "viem": "^2.9.21" }, "dependencies": {} -} +} \ No newline at end of file diff --git a/smart-contracts/scripts/deploy-local.ts b/smart-contracts/scripts/deploy-local.ts new file mode 100644 index 00000000..3444c639 --- /dev/null +++ b/smart-contracts/scripts/deploy-local.ts @@ -0,0 +1,11 @@ +import * as fixtures from "../test/fixtures"; + +async function main() { + const data = await fixtures.deploySingleBid(); + console.log(` + MOR token deployed to ${data.tokenMOR.address} + Diamond deployed to ${data.marketplace.address} + `); +} + +main(); diff --git a/smart-contracts/test/Marketplace.test.ts b/smart-contracts/test/Marketplace.test.ts new file mode 100644 index 00000000..6fe038a7 --- /dev/null +++ b/smart-contracts/test/Marketplace.test.ts @@ -0,0 +1,272 @@ +import { loadFixture } from "@nomicfoundation/hardhat-toolbox-viem/network-helpers"; +import { expect } from "chai"; +import hre from "hardhat"; +import { parseEventLogs } from "viem"; +import { deploySingleBid } from "./fixtures"; +import { expectError, getTxTimestamp } from "./utils"; + +describe("Marketplace", function () { + describe("bid actions", function () { + it("Should create a bid and query by id", async function () { + const { marketplace, expectedBid } = await loadFixture(deploySingleBid); + const data = await marketplace.read.bidMap([expectedBid.id]); + + expect(data).to.be.deep.equal({ + provider: expectedBid.providerAddr, + modelAgentId: expectedBid.modelId, + pricePerSecond: expectedBid.pricePerSecond, + nonce: expectedBid.nonce, + createdAt: expectedBid.createdAt, + deletedAt: expectedBid.deletedAt, + }); + }); + + it("Should create a bid and query by id", async function () { + const { marketplace, expectedBid } = await loadFixture(deploySingleBid); + const data = await marketplace.read.bidMap([expectedBid.id]); + + expect(data).to.be.deep.equal({ + provider: expectedBid.providerAddr, + modelAgentId: expectedBid.modelId, + pricePerSecond: expectedBid.pricePerSecond, + nonce: expectedBid.nonce, + createdAt: expectedBid.createdAt, + deletedAt: expectedBid.deletedAt, + }); + }); + + it("Should create second bid", async function () { + const { marketplace, expectedBid: expBid, publicClient } = await loadFixture(deploySingleBid); + + // create new bid with same provider and modelId + const client = await hre.viem.getWalletClient(expBid.providerAddr); + const postModelBid = await marketplace.simulate.postModelBid( + [expBid.providerAddr, expBid.modelId, expBid.pricePerSecond], + { account: expBid.providerAddr } + ); + const txHash = await client.writeContract(postModelBid.request); + const timestamp = await getTxTimestamp(publicClient, txHash); + + // check indexes are updated + const newBids1 = await marketplace.read.getActiveBidsByProvider([expBid.providerAddr]); + const newBids2 = await marketplace.read.getActiveBidsByModelAgent([expBid.modelId]); + + expect(newBids1).to.be.deep.equal(newBids2); + expect(newBids1.length).to.be.equal(1); + expect(newBids1[0]).to.be.deep.equal({ + provider: expBid.providerAddr, + modelAgentId: expBid.modelId, + pricePerSecond: expBid.pricePerSecond, + nonce: expBid.nonce + 1n, + createdAt: timestamp, + deletedAt: expBid.deletedAt, + }); + + // check old bid is deleted + const oldBid = await marketplace.read.bidMap([expBid.id]); + expect(oldBid).to.be.deep.equal({ + provider: expBid.providerAddr, + modelAgentId: expBid.modelId, + pricePerSecond: expBid.pricePerSecond, + nonce: expBid.nonce, + createdAt: expBid.createdAt, + deletedAt: timestamp, + }); + + // check old bid is still queried + const oldBids1 = await marketplace.read.getBidsByProvider([expBid.providerAddr, 0n, 100]); + const oldBids2 = await marketplace.read.getBidsByModelAgent([expBid.modelId, 0n, 100]); + expect(oldBids1).to.be.deep.equal(oldBids2); + expect(oldBids1.length).to.be.equal(2); + expect(oldBids1[1]).to.be.deep.equal({ + provider: expBid.providerAddr, + modelAgentId: expBid.modelId, + pricePerSecond: expBid.pricePerSecond, + nonce: expBid.nonce, + createdAt: expBid.createdAt, + deletedAt: timestamp, + }); + }); + + it("Should query by provider", async function () { + const { marketplace, expectedBid } = await loadFixture(deploySingleBid); + const data = await marketplace.read.getActiveBidsByProvider([expectedBid.providerAddr]); + + expect(data.length).to.equal(1); + expect(data[0]).to.deep.equal({ + provider: expectedBid.providerAddr, + modelAgentId: expectedBid.modelId, + pricePerSecond: expectedBid.pricePerSecond, + nonce: expectedBid.nonce, + createdAt: expectedBid.createdAt, + deletedAt: expectedBid.deletedAt, + }); + }); + + it("Should query by provider with pagination", async function () { + const { marketplace, expectedBid } = await loadFixture(deploySingleBid); + const data = await marketplace.read.getActiveBidsByProvider([expectedBid.providerAddr]); + + expect(data.length).to.equal(1); + expect(data[0]).to.deep.equal({ + provider: expectedBid.providerAddr, + modelAgentId: expectedBid.modelId, + pricePerSecond: expectedBid.pricePerSecond, + nonce: expectedBid.nonce, + createdAt: expectedBid.createdAt, + deletedAt: expectedBid.deletedAt, + }); + }); + + it("Should query by modelId", async function () { + const { marketplace, expectedBid } = await loadFixture(deploySingleBid); + const data = await marketplace.read.getActiveBidsByModelAgent([expectedBid.modelId]); + + expect(data.length).to.equal(1); + expect(data[0]).to.deep.equal({ + provider: expectedBid.providerAddr, + modelAgentId: expectedBid.modelId, + pricePerSecond: expectedBid.pricePerSecond, + nonce: expectedBid.nonce, + createdAt: expectedBid.createdAt, + deletedAt: expectedBid.deletedAt, + }); + }); + }); + + describe("bid fee", function () { + it("should set bid fee", async function () { + const { marketplace, owner, publicClient } = await loadFixture(deploySingleBid); + const newFee = 100n; + const txHash = await marketplace.write.setBidFee([newFee], { + account: owner.account.address, + }); + const receipt = await publicClient.waitForTransactionReceipt({ hash: txHash }); + const events = parseEventLogs({ + abi: marketplace.abi, + logs: receipt.logs, + eventName: "FeeUpdated", + }); + expect(events.length).to.be.equal(1); + expect(events[0].args).to.be.deep.equal({ bidFee: newFee }); + + const modelBidFee = await marketplace.read.bidFee(); + + expect(modelBidFee).to.be.equal(newFee); + }); + + it("should collect bid fee", async function () { + const { marketplace, owner, expectedBid, publicClient, provider, tokenMOR } = + await loadFixture(deploySingleBid); + const newFee = 100n; + await marketplace.write.setBidFee([newFee], { + account: owner.account.address, + }); + + await tokenMOR.write.transfer([expectedBid.providerAddr, 100n], { + account: owner.account, + }); + + // check balance before + const balanceBefore = await tokenMOR.read.balanceOf([marketplace.address]); + + // add bid + await tokenMOR.write.approve([marketplace.address, expectedBid.pricePerSecond + newFee], { + account: expectedBid.providerAddr, + }); + const postModelBid = await marketplace.simulate.postModelBid( + [expectedBid.providerAddr, expectedBid.modelId, expectedBid.pricePerSecond], + { account: expectedBid.providerAddr } + ); + const txHash = await provider.writeContract(postModelBid.request); + await publicClient.waitForTransactionReceipt({ hash: txHash }); + + // check balance after + const balanceAfter = await tokenMOR.read.balanceOf([marketplace.address]); + expect(balanceAfter - balanceBefore).to.be.equal(newFee); + }); + + it("should allow withdrawal by owner", async function () { + const { marketplace, owner, expectedBid, publicClient, provider, tokenMOR } = + await loadFixture(deploySingleBid); + const newFee = 100n; + await marketplace.write.setBidFee([newFee], { + account: owner.account.address, + }); + await tokenMOR.write.transfer([expectedBid.providerAddr, 100n], { + account: owner.account, + }); + + // add bid + await tokenMOR.write.approve([marketplace.address, expectedBid.pricePerSecond + newFee], { + account: expectedBid.providerAddr, + }); + const postModelBid = await marketplace.simulate.postModelBid( + [expectedBid.providerAddr, expectedBid.modelId, expectedBid.pricePerSecond], + { account: expectedBid.providerAddr } + ); + const txHash = await provider.writeContract(postModelBid.request); + await publicClient.waitForTransactionReceipt({ hash: txHash }); + + // check balance after + const balanceBefore = await tokenMOR.read.balanceOf([owner.account.address]); + await marketplace.write.withdraw([owner.account.address, newFee], { + account: owner.account.address, + }); + const balanceAfter = await tokenMOR.read.balanceOf([owner.account.address]); + + expect(balanceAfter - balanceBefore).to.be.equal(newFee); + }); + + it("should not allow withdrawal by any other account except owner", async function () { + const { marketplace, owner, expectedBid, publicClient, provider, tokenMOR } = + await loadFixture(deploySingleBid); + const newFee = 100n; + await marketplace.write.setBidFee([newFee], { + account: owner.account.address, + }); + + await tokenMOR.write.transfer([expectedBid.providerAddr, 100n], { + account: owner.account, + }); + + // add bid + await tokenMOR.write.approve([marketplace.address, expectedBid.pricePerSecond + newFee], { + account: expectedBid.providerAddr, + }); + const postModelBid = await marketplace.simulate.postModelBid( + [expectedBid.providerAddr, expectedBid.modelId, expectedBid.pricePerSecond], + { account: expectedBid.providerAddr } + ); + const txHash = await provider.writeContract(postModelBid.request); + await publicClient.waitForTransactionReceipt({ hash: txHash }); + + // check balance after + try { + await marketplace.write.withdraw([expectedBid.providerAddr, newFee], { + account: expectedBid.providerAddr, + }); + expect.fail("Should have thrown an error"); + } catch (e) { + expectError( + e, + (await hre.artifacts.readArtifact("OwnershipFacet")).abi, + "NotContractOwner" + ); + } + }); + + it("should not allow withdrawal if not enough balance", async function () { + const { marketplace, owner, tokenMOR } = await loadFixture(deploySingleBid); + + try { + await marketplace.write.withdraw([owner.account.address, 100000000n], { + account: owner.account.address, + }); + expect.fail("Should have thrown an error"); + } catch (e) { + expectError(e, marketplace.abi, "NotEnoughBalance"); + } + }); + }); +}); diff --git a/smart-contracts/test/ModelRegistry.test.ts b/smart-contracts/test/ModelRegistry.test.ts new file mode 100644 index 00000000..27c0743f --- /dev/null +++ b/smart-contracts/test/ModelRegistry.test.ts @@ -0,0 +1,319 @@ +import { loadFixture } from "@nomicfoundation/hardhat-toolbox-viem/network-helpers"; +import { expect } from "chai"; +import hre from "hardhat"; +import { getAddress } from "viem"; +import { deployDiamond, deploySingleModel } from "./fixtures"; +import { expectError, getHex, getTxTimestamp, randomAddress, randomBytes32 } from "./utils"; + +describe("Model registry", function () { + describe("Actions", function () { + it("Should count correctly", async function () { + const { modelRegistry } = await loadFixture(deployDiamond); + + expect(await modelRegistry.read.modelGetCount()).eq(0n); + }); + + it("Should register", async function () { + const { modelRegistry, expectedModel } = + await loadFixture(deploySingleModel); + const data = await modelRegistry.read.modelMap([expectedModel.modelId]); + const events = await modelRegistry.getEvents.ModelRegisteredUpdated({ + modelId: expectedModel.modelId, + owner: expectedModel.owner, + }); + + expect(await modelRegistry.read.modelGetCount()).eq(1n); + expect(await modelRegistry.read.models([0n])).eq(expectedModel.modelId); + expect(data).deep.equal({ + ipfsCID: expectedModel.ipfsCID, + fee: expectedModel.fee, + stake: expectedModel.stake, + owner: getAddress(expectedModel.owner), + name: expectedModel.name, + tags: expectedModel.tags, + timestamp: expectedModel.timestamp, + isDeleted: expectedModel.isDeleted, + }); + expect(events.length).eq(1); + }); + + it("Should error when registering with insufficient stake", async function () { + const { modelRegistry, owner } = await loadFixture(deployDiamond); + const minStake = 100n; + await modelRegistry.write.modelSetMinStake([minStake]); + try { + await modelRegistry.simulate.modelRegister([ + randomBytes32(), + randomBytes32(), + 0n, + 0n, + owner.account.address, + "a", + [], + ]); + expect.fail("Expected error"); + } catch (e) { + expectError(e, modelRegistry.abi, "StakeTooLow"); + } + }); + + it("Should error when registering with insufficient allowance", async function () { + const { modelRegistry, owner, tokenMOR } = + await loadFixture(deployDiamond); + try { + await modelRegistry.simulate.modelRegister([ + randomBytes32(), + randomBytes32(), + 0n, + 100n, + owner.account.address, + "a", + [], + ]); + expect.fail("Expected error"); + } catch (e) { + expectError(e, tokenMOR.abi, "ERC20InsufficientAllowance"); + } + }); + + it("Should error when register account doesnt match sender account", async function () { + const [, , user] = await hre.viem.getWalletClients(); + + const { modelRegistry, tokenMOR } = await loadFixture(deployDiamond); + await tokenMOR.write.approve([modelRegistry.address, 100n]); + try { + await modelRegistry.simulate.modelRegister( + [ + randomBytes32(), + randomBytes32(), + 0n, + 100n, + randomAddress(), + "a", + [], + ], + { + account: user.account.address, + }, + ); + expect.fail("Expected error"); + } catch (e) { + expectError(e, modelRegistry.abi, "NotSenderOrOwner"); + } + }); + + it("Should deregister by owner", async function () { + const { modelRegistry, owner, expectedModel } = + await loadFixture(deploySingleModel); + + await modelRegistry.write.modelDeregister([expectedModel.modelId], { + account: owner.account, + }); + const events = await modelRegistry.getEvents.ModelDeregistered({ + modelId: expectedModel.modelId, + owner: expectedModel.owner, + }); + + expect(await modelRegistry.read.modelGetCount()).eq(0n); + expect( + (await modelRegistry.read.modelMap([expectedModel.modelId])).isDeleted, + ).to.equal(true); + expect(events.length).eq(1); + await expect(modelRegistry.read.modelGetByIndex([0n])).rejectedWith( + /.*reverted with panic code 0x32 (Array accessed at an out-of-bounds or negative index)*/, + ); + expect(await modelRegistry.read.models([0n])).equals( + expectedModel.modelId, + ); + }); + + it("Should deregister by admin", async function () { + const { modelRegistry, owner, expectedModel } = + await loadFixture(deploySingleModel); + + await modelRegistry.write.modelDeregister([expectedModel.modelId], { + account: owner.account, + }); + const events = await modelRegistry.getEvents.ModelDeregistered({ + modelId: expectedModel.modelId, + }); + + expect(await modelRegistry.read.modelGetCount()).eq(0n); + expect(events.length).eq(1); + }); + + it("Should error if model not known by admin", async function () { + const { modelRegistry, owner } = await loadFixture(deploySingleModel); + try { + await modelRegistry.write.modelDeregister([randomBytes32()], { + account: owner.account, + }); + expect.fail("Expected error"); + } catch (e) { + expectError(e, modelRegistry.abi, "KeyNotFound"); + } + }); + + it("Should return stake on deregister", async function () { + const { modelRegistry, tokenMOR, expectedModel } = + await loadFixture(deploySingleModel); + + const balanceBefore = await tokenMOR.read.balanceOf([ + expectedModel.owner, + ]); + await modelRegistry.write.modelDeregister([expectedModel.modelId]); + const balanceAfter = await tokenMOR.read.balanceOf([expectedModel.owner]); + + expect(balanceAfter - balanceBefore).eq(expectedModel.stake); + }); + + it("Should update existing model", async function () { + const { + modelRegistry, + provider, + tokenMOR, + expectedModel, + publicClient, + owner, + } = await loadFixture(deploySingleModel); + const updates = { + ipfsCID: getHex(Buffer.from("ipfs://new-ipfsaddress")), + fee: expectedModel.fee * 2n, + addStake: expectedModel.stake * 2n, + owner: provider.account.address, + name: "Llama 3.0", + tags: ["llama", "smart", "angry"], + }; + await tokenMOR.write.approve([modelRegistry.address, updates.addStake], { + account: owner.account, + }); + + const txHash = await modelRegistry.write.modelRegister([ + expectedModel.modelId, + updates.ipfsCID, + updates.fee, + updates.addStake, + updates.owner, + updates.name, + updates.tags, + ]); + const timestamp = await getTxTimestamp(publicClient, txHash); + const providerData = await modelRegistry.read.modelMap([ + expectedModel.modelId, + ]); + + expect(providerData).deep.equal({ + ipfsCID: updates.ipfsCID, + fee: updates.fee, + stake: expectedModel.stake + updates.addStake, + owner: getAddress(updates.owner), + name: updates.name, + tags: updates.tags, + timestamp: timestamp, + isDeleted: expectedModel.isDeleted, + }); + }); + + it("Should emit event on update", async function () { + const { modelRegistry, provider, tokenMOR, expectedModel, owner } = + await loadFixture(deploySingleModel); + const updates = { + ipfsCID: getHex(Buffer.from("ipfs://new-ipfsaddress")), + fee: expectedModel.fee * 2n, + addStake: expectedModel.stake * 2n, + owner: provider.account.address, + name: "Llama 3.0", + tags: ["llama", "smart", "angry"], + }; + + await tokenMOR.write.approve([modelRegistry.address, updates.addStake]); + await modelRegistry.write.modelRegister([ + expectedModel.modelId, + updates.ipfsCID, + updates.fee, + updates.addStake, + updates.owner, + updates.name, + updates.tags, + ]); + + const events = await modelRegistry.getEvents.ModelRegisteredUpdated({ + modelId: expectedModel.modelId, + owner: getAddress(provider.account.address), + }); + expect(events.length).eq(1); + }); + }); + + describe("Getters", function () { + it("Should get by index", async function () { + const { modelRegistry, provider, expectedModel } = + await loadFixture(deploySingleModel); + const [modelId, providerData] = await modelRegistry.read.modelGetByIndex([ + 0n, + ]); + + expect(modelId).eq(expectedModel.modelId); + expect(providerData).deep.equal({ + ipfsCID: expectedModel.ipfsCID, + fee: expectedModel.fee, + stake: expectedModel.stake, + owner: getAddress(expectedModel.owner), + name: expectedModel.name, + tags: expectedModel.tags, + timestamp: expectedModel.timestamp, + isDeleted: expectedModel.isDeleted, + }); + }); + + it("Should get by address", async function () { + const { modelRegistry, provider, expectedModel } = + await loadFixture(deploySingleModel); + + const providerData = await modelRegistry.read.modelMap([ + expectedModel.modelId, + ]); + expect(providerData).deep.equal({ + ipfsCID: expectedModel.ipfsCID, + fee: expectedModel.fee, + stake: expectedModel.stake, + owner: getAddress(expectedModel.owner), + name: expectedModel.name, + tags: expectedModel.tags, + timestamp: expectedModel.timestamp, + isDeleted: expectedModel.isDeleted, + }); + }); + }); + + describe("Min stake", function () { + it("Should set min stake", async function () { + const { modelRegistry, owner } = await loadFixture(deployDiamond); + const minStake = 100n; + + await modelRegistry.write.modelSetMinStake([minStake], { + account: owner.account, + }); + const events = await modelRegistry.getEvents.ModelMinStakeUpdated(); + expect(await modelRegistry.read.modelMinStake()).eq(minStake); + expect(events.length).eq(1); + expect(events[0].args.newStake).eq(minStake); + }); + + it("Should error when not owner is setting min stake", async function () { + const { modelRegistry, provider } = await loadFixture(deploySingleModel); + try { + await modelRegistry.write.modelSetMinStake([100n], { + account: provider.account, + }); + expect.fail("Expected error"); + } catch (e) { + expectError( + e, + (await hre.artifacts.readArtifact("OwnershipFacet")).abi, + "NotContractOwner", + ); + } + }); + }); +}); diff --git a/smart-contracts/test/ProviderRegistry.test.ts b/smart-contracts/test/ProviderRegistry.test.ts new file mode 100644 index 00000000..0e1d9632 --- /dev/null +++ b/smart-contracts/test/ProviderRegistry.test.ts @@ -0,0 +1,299 @@ +import { loadFixture } from "@nomicfoundation/hardhat-toolbox-viem/network-helpers"; +import { expect } from "chai"; +import hre from "hardhat"; +import { getAddress } from "viem"; +import { expectError, getTxTimestamp } from "./utils"; +import { deployDiamond, deploySingleProvider } from "./fixtures"; + +describe("Provider registry", function () { + describe("Actions", function () { + it("Should count correctly", async function () { + const { providerRegistry } = await loadFixture(deployDiamond); + + expect(await providerRegistry.read.providerGetCount()).eq(0n); + }); + + it("Should register", async function () { + const { providerRegistry, provider, expectedProvider } = + await loadFixture(deploySingleProvider); + const data = await providerRegistry.read.providerMap([ + provider.account.address, + ]); + const events = await providerRegistry.getEvents.ProviderRegisteredUpdated( + { + provider: getAddress(provider.account.address), + }, + ); + + expect(await providerRegistry.read.providerGetCount()).eq(1n); + expect(await providerRegistry.read.providers([0n])).eq( + getAddress(provider.account.address), + ); + expect(data).deep.equal({ + endpoint: expectedProvider.endpoint, + stake: expectedProvider.stake, + timestamp: expectedProvider.timestamp, + isDeleted: false, + }); + expect(events.length).eq(1); + }); + + it("Should error when registering with insufficient stake", async function () { + const { providerRegistry, provider } = await loadFixture(deployDiamond); + const minStake = 100n; + await providerRegistry.write.providerSetMinStake([minStake]); + try { + await providerRegistry.simulate.providerRegister([ + provider.account.address, + minStake - 1n, + "endpoint", + ]); + expect.fail("Expected error"); + } catch (e) { + expectError(e, providerRegistry.abi, "StakeTooLow"); + } + }); + + it("Should error when registering with insufficient allowance", async function () { + const { providerRegistry, provider, tokenMOR } = + await loadFixture(deployDiamond); + try { + await providerRegistry.simulate.providerRegister([ + provider.account.address, + 100n, + "endpoint", + ]); + expect.fail("Expected error"); + } catch (e) { + expectError(e, tokenMOR.abi, "ERC20InsufficientAllowance"); + } + }); + + it("Should error when register account doesnt match sender account", async function () { + const [, , user] = await hre.viem.getWalletClients(); + + const { providerRegistry, provider, tokenMOR, owner } = + await loadFixture(deployDiamond); + try { + await providerRegistry.simulate.providerRegister( + [user.account.address, 100n, "endpoint"], + { + account: provider.account.address, + }, + ); + expect.fail("Expected error"); + } catch (e) { + expectError(e, providerRegistry.abi, "NotSenderOrOwner"); + } + }); + + it("Should deregister by provider", async function () { + const { providerRegistry, provider, expectedProvider } = + await loadFixture(deploySingleProvider); + + await providerRegistry.write.providerDeregister( + [provider.account.address], + { + account: provider.account, + }, + ); + const events = await providerRegistry.getEvents.ProviderDeregistered({ + provider: getAddress(provider.account.address), + }); + + expect(await providerRegistry.read.providerGetCount()).eq(0n); + expect( + (await providerRegistry.read.providerMap([provider.account.address])) + .isDeleted, + ).to.equal(true); + expect(events.length).eq(1); + await expect(providerRegistry.read.providerGetByIndex([0n])).rejectedWith( + /.*reverted with panic code 0x32 (Array accessed at an out-of-bounds or negative index)*/, + ); + expect(await providerRegistry.read.providers([0n])).equals( + getAddress(provider.account.address), + ); + }); + + it("Should deregister by admin", async function () { + const { providerRegistry, provider, owner } = + await loadFixture(deploySingleProvider); + + await providerRegistry.write.providerDeregister( + [provider.account.address], + { + account: owner.account, + }, + ); + const events = await providerRegistry.getEvents.ProviderDeregistered({ + provider: getAddress(provider.account.address), + }); + + expect(await providerRegistry.read.providerGetCount()).eq(0n); + expect(events.length).eq(1); + }); + + it("Should return stake on deregister", async function () { + const { providerRegistry, provider, tokenMOR, expectedProvider } = + await loadFixture(deploySingleProvider); + + const balanceBefore = await tokenMOR.read.balanceOf([ + provider.account.address, + ]); + await providerRegistry.write.providerDeregister([ + provider.account.address, + ]); + const balanceAfter = await tokenMOR.read.balanceOf([ + provider.account.address, + ]); + + expect(balanceAfter - balanceBefore).eq(expectedProvider.stake); + }); + + it("Should update stake and url", async function () { + const { + providerRegistry, + provider, + tokenMOR, + expectedProvider, + publicClient, + } = await loadFixture(deploySingleProvider); + const updates = { + addStake: expectedProvider.stake * 2n, + endpoint: "new-endpoint", + }; + await tokenMOR.write.approve( + [providerRegistry.address, updates.addStake], + { + account: provider.account, + }, + ); + + const txHash = await providerRegistry.write.providerRegister( + [provider.account.address, updates.addStake, updates.endpoint], + { account: provider.account }, + ); + const timestamp = await getTxTimestamp(publicClient, txHash); + const providerData = await providerRegistry.read.providerMap([ + provider.account.address, + ]); + + expect(providerData).deep.equal({ + endpoint: updates.endpoint, + stake: expectedProvider.stake + updates.addStake, + timestamp: timestamp, + isDeleted: expectedProvider.isDeleted, + }); + }); + + it("Should emit event on update", async function () { + const { providerRegistry, provider, tokenMOR, expectedProvider } = + await loadFixture(deploySingleProvider); + const updates = { + addStake: expectedProvider.stake * 2n, + endpoint: "new-endpoint", + }; + + await tokenMOR.write.approve( + [providerRegistry.address, updates.addStake], + { + account: provider.account, + }, + ); + await providerRegistry.write.providerRegister( + [provider.account.address, updates.addStake, updates.endpoint], + { account: provider.account }, + ); + + const events = await providerRegistry.getEvents.ProviderRegisteredUpdated( + { + provider: getAddress(provider.account.address), + }, + ); + expect(events.length).eq(1); + }); + }); + + describe("Getters", function () { + it("Should get by index", async function () { + const { providerRegistry, provider, expectedProvider } = + await loadFixture(deploySingleProvider); + const [address, providerData] = + await providerRegistry.read.providerGetByIndex([0n]); + + expect(address).eq(getAddress(provider.account.address)); + expect(providerData).deep.equal({ + endpoint: expectedProvider.endpoint, + stake: expectedProvider.stake, + timestamp: expectedProvider.timestamp, + isDeleted: expectedProvider.isDeleted, + }); + }); + + it("Should get by address", async function () { + const { providerRegistry, provider, expectedProvider } = + await loadFixture(deploySingleProvider); + + const providerData = await providerRegistry.read.providerMap([ + provider.account.address, + ]); + expect(providerData).deep.equal({ + endpoint: expectedProvider.endpoint, + stake: expectedProvider.stake, + timestamp: expectedProvider.timestamp, + isDeleted: expectedProvider.isDeleted, + }); + }); + }); + + describe("Views", function () { + it("should get all", async function () { + const { providerRegistry, expectedProvider } = + await loadFixture(deploySingleProvider); + const [ids, providers] = await providerRegistry.read.providerGetAll(); + + expect(providers.length).eq(1); + expect(ids.length).eq(1); + expect(ids[0]).eq(expectedProvider.address); + expect(providers[0]).deep.equal({ + endpoint: expectedProvider.endpoint, + stake: expectedProvider.stake, + timestamp: expectedProvider.timestamp, + isDeleted: expectedProvider.isDeleted, + }); + }); + }); + + describe("Min stake", function () { + it("Should set min stake", async function () { + const { providerRegistry, owner } = await loadFixture(deployDiamond); + const minStake = 100n; + + await providerRegistry.write.providerSetMinStake([minStake], { + account: owner.account, + }); + const events = await providerRegistry.getEvents.ProviderMinStakeUpdated(); + expect(await providerRegistry.read.providerMinStake()).eq(minStake); + expect(events.length).eq(1); + expect(events[0].args.newStake).eq(minStake); + }); + + it("Should error when not owner is setting min stake", async function () { + const { providerRegistry, provider } = + await loadFixture(deploySingleProvider); + + try { + await providerRegistry.write.providerSetMinStake([100n], { + account: provider.account, + }); + expect.fail("Expected error"); + } catch (e) { + expectError( + e, + (await hre.artifacts.readArtifact("OwnershipFacet")).abi, + "NotContractOwner", + ); + } + }); + }); +}); diff --git a/smart-contracts/test/SessionRouter.test.ts b/smart-contracts/test/SessionRouter.test.ts new file mode 100644 index 00000000..7230d1d1 --- /dev/null +++ b/smart-contracts/test/SessionRouter.test.ts @@ -0,0 +1,313 @@ +import { loadFixture, time } from "@nomicfoundation/hardhat-toolbox-viem/network-helpers"; +import { expect } from "chai"; +import hre from "hardhat"; +import { PublicClient, getAddress, keccak256, parseEventLogs } from "viem"; +import { deploySingleBid, encodedReport } from "./fixtures"; +import { expectError, getHex, getTxTimestamp, randomBytes32 } from "./utils"; +import { DAY, HOUR, MINUTE, SECOND } from "../utils/time"; +import { expectAlmostEqual } from "../utils/compare"; + +describe.skip("Session router", function () { + describe("session actions", function () { + it("should open session", async function () { + const { sessionRouter, expectedBid, user } = await loadFixture(deploySingleBid); + const budget = 100000n * 10n ** 18n; + console.log(budget); + + await sessionRouter.write.openSession([expectedBid.id, budget], { + account: user.account, + }); + }); + + it("should verify session fields after opening", async function () { + const { sessionRouter, expectedBid, user, publicClient } = await loadFixture(deploySingleBid); + const budget = 100000n * 10n ** 18n; + + const txHash = await sessionRouter.write.openSession([expectedBid.id, budget], { + account: user.account, + }); + const sessionId = await getSessionId(publicClient, txHash); + const session = await sessionRouter.read.getSession([sessionId]); + const createdAt = await getTxTimestamp(publicClient, txHash); + + expect(session).to.deep.equal({ + id: sessionId, + user: getAddress(user.account.address), + provider: getAddress(expectedBid.providerAddr), + modelAgentId: expectedBid.modelId, + bidID: expectedBid.id, + budget: budget, + price: expectedBid.pricePerSecond, + closeoutReceipt: getHex(Buffer.from(""), 0), + closeoutType: 0n, + openedAt: createdAt, + closedAt: 0n, + }); + }); + + it("should error with NotEnoughStipend when opening session with insufficient stipend", async function () { + const { sessionRouter, expectedBid, user, expectedStake } = await loadFixture( + deploySingleBid + ); + const stakeToKeep = 1n; + const stakeToUnstake = expectedStake.stakeAmount - stakeToKeep; + + await sessionRouter.write.unstake( + [user.account.address, stakeToUnstake, user.account.address], + { + account: user.account, + } + ); + + try { + await sessionRouter.write.openSession([expectedBid.id, stakeToKeep + 1n], { + account: user.account, + }); + expect.fail("Should have thrown an error"); + } catch (error) { + expectError(error, sessionRouter.abi, "NotEnoughStipend"); + } + }); + + it("should fail to open session with invalid bid", async function () { + const { sessionRouter, user } = await loadFixture(deploySingleBid); + + try { + await sessionRouter.write.openSession([randomBytes32(), 0n], { + account: user.account, + }); + expect.fail("Should have thrown an error"); + } catch (error) { + expectError(error, sessionRouter.abi, "BidNotFound"); + } + }); + + it("should fail to open session with duration less than minimum", async function () { + const { sessionRouter, expectedBid, expectedStake, user } = await loadFixture( + deploySingleBid + ); + + await sessionRouter.write.unstake( + [user.account.address, expectedStake.stakeAmount, user.account.address], + { + account: user.account, + } + ); + + try { + await sessionRouter.write.openSession([expectedBid.id, 0n], { + account: user.account, + }); + expect.fail("Should have thrown an error"); + } catch (error) { + expectError(error, sessionRouter.abi, "SessionTooShort"); + } + }); + + it("should not open session with same bid simultaneously", async function () { + const { sessionRouter, expectedBid, user } = await loadFixture(deploySingleBid); + const budget = expectedBid.pricePerSecond * BigInt(HOUR / SECOND); + + await sessionRouter.write.openSession([expectedBid.id, budget], { + account: user.account.address, + }); + + try { + await sessionRouter.write.openSession([expectedBid.id, budget], { + account: user.account.address, + }); + expect.fail("Should have thrown an error"); + } catch (error) { + expectError(error, sessionRouter.abi, "BidTaken"); + } + }); + + it("should open session with same bid after previous session is closed", async function () { + const { sessionRouter, expectedBid, user, publicClient, provider } = await loadFixture( + deploySingleBid + ); + const budget = expectedBid.pricePerSecond * BigInt(HOUR / SECOND); + + // first purchase + const openTx = await sessionRouter.write.openSession([expectedBid.id, budget], { + account: user.account.address, + }); + const sessionId = await getSessionId(publicClient, openTx); + + // first closeout + const signature = await provider.signMessage({ + message: { raw: keccak256(encodedReport) }, + }); + await sessionRouter.write.closeSession([sessionId, encodedReport, signature], { + account: user.account, + }); + + // second purchase same bidId + const openTx2 = await sessionRouter.write.openSession([expectedBid.id, budget], { + account: user.account.address, + }); + + // expect no purchase error + }); + + it("should emit session opened with session id", async function () { + const { sessionRouter, provider, expectedBid, user, publicClient, tokenMOR } = + await loadFixture(deploySingleBid); + + const budget = expectedBid.pricePerSecond * BigInt(HOUR / SECOND); + const openSession = await sessionRouter.write.openSession([expectedBid.id, budget], { + account: user.account.address, + }); + const receipt = await publicClient.waitForTransactionReceipt({ hash: openSession }); + const events = parseEventLogs({ + abi: sessionRouter.abi, + logs: receipt.logs, + eventName: "SessionOpened", + }); + const [event] = events; + + expect(events.length).to.equal(1); + expect(event.args.userAddress).to.equal(getAddress(user.account.address)); + expect(event.args.providerId).to.equal(getAddress(provider.account.address)); + + const sessionId = await getSessionId(publicClient, openSession); + expect(sessionId).to.equal(event.args.sessionId); + }); + + it("should open and close early", async function () { + const { sessionRouter, provider, expectedBid, user, publicClient, tokenMOR } = + await loadFixture(deploySingleBid); + const budget = expectedBid.pricePerSecond * BigInt(HOUR / SECOND); + + // save balance before opening session + const balanceBeforeOpen = await sessionRouter.read.balanceOfDailyStipend([ + user.account.address, + ]); + const providerBalanceBefore = await tokenMOR.read.balanceOf([provider.account.address]); + + // open session + const openTx = await sessionRouter.write.openSession([expectedBid.id, budget], { + account: user.account.address, + }); + const sessionId = await getSessionId(publicClient, openTx); + + await time.increase((30 * MINUTE) / SECOND); + const balanceBeforeClose = await sessionRouter.read.balanceOfDailyStipend([ + user.account.address, + ]); + + // close session + const signature = await provider.signMessage({ + message: { raw: keccak256(encodedReport) }, + }); + await sessionRouter.write.closeSession([sessionId, encodedReport, signature], { + account: user.account, + }); + + // verify session is closed without dispute + const session = await sessionRouter.read.getSession([sessionId]); + expect(session.closeoutType).to.equal(0n); + + // verify balances + const balanceAfterClose = await sessionRouter.read.balanceOfDailyStipend([ + user.account.address, + ]); + const providerBalanceAfter = await tokenMOR.read.balanceOf([provider.account.address]); + + const stipendLocked = balanceBeforeOpen - balanceBeforeClose; + const stipendSpent = balanceBeforeOpen - balanceAfterClose; + const providerEarned = providerBalanceAfter - providerBalanceBefore; + + expect(stipendSpent).to.equal(providerEarned); + expectAlmostEqual(stipendLocked / 2n, stipendSpent, 0.05); + }); + + it("should open and close with user report - dispute", async function () { + const { sessionRouter, provider, expectedBid, user, publicClient, tokenMOR } = + await loadFixture(deploySingleBid); + const budget = expectedBid.pricePerSecond * BigInt(HOUR / SECOND); + + // save balance before opening session + const balanceBeforeOpen = await sessionRouter.read.balanceOfDailyStipend([ + user.account.address, + ]); + const providerBalanceBefore = await tokenMOR.read.balanceOf([provider.account.address]); + + // open session + const openTx = await sessionRouter.write.openSession([expectedBid.id, budget], { + account: user.account.address, + }); + const sessionId = await getSessionId(publicClient, openTx); + + await time.increase((30 * MINUTE) / SECOND); + const balanceBeforeClose = await sessionRouter.read.balanceOfDailyStipend([ + user.account.address, + ]); + + // close session with invalid signature + const signature = getHex(Buffer.from(""), 0); + await sessionRouter.write.closeSession([sessionId, encodedReport, signature], { + account: user.account, + }); + + // verify session is closed with dispute + const session = await sessionRouter.read.getSession([sessionId]); + expect(session.closeoutType).to.equal(1n); + + // verify balances + const balanceAfterClose = await sessionRouter.read.balanceOfDailyStipend([ + user.account.address, + ]); + const providerBalanceAfter = await tokenMOR.read.balanceOf([provider.account.address]); + const [total, onHold] = await sessionRouter.read.getProviderBalance([ + provider.account.address, + ]); + + const stipendLocked = balanceBeforeOpen - balanceBeforeClose; + const stipendSpent = balanceBeforeOpen - balanceAfterClose; + const providerEarned = providerBalanceAfter - providerBalanceBefore; + + expect(providerEarned).to.equal(0n); + expect(onHold).to.equal(stipendSpent); + expectAlmostEqual(stipendLocked / 2n, stipendSpent, 0.05); + + // verify provider balance after dispute is released + await time.increase((1 * DAY) / SECOND); + const [total2, onHold2] = await sessionRouter.read.getProviderBalance([ + provider.account.address, + ]); + expect(total2).to.equal(total); + expect(onHold2).to.equal(0n); + + // verify user balance after dispute is claimable + await sessionRouter.write.claimProviderBalance([total2, provider.account.address], { + account: provider.account.address, + }); + + const [total3, onHold3] = await sessionRouter.read.getProviderBalance([ + provider.account.address, + ]); + expect(total3).to.equal(0n); + expect(onHold3).to.equal(0n); + + // verify provider balance after claim + const providerBalanceAfterClaim = await tokenMOR.read.balanceOf([provider.account.address]); + const providerClaimed = providerBalanceAfterClaim - providerBalanceAfter; + expect(providerClaimed).to.equal(total2); + }); + }); +}); + +async function getSessionId( + publicClient: PublicClient, + txHash: `0x${string}` +): Promise<`0x${string}`> { + const receipt = await publicClient.waitForTransactionReceipt({ hash: txHash }); + const artifact = await hre.artifacts.readArtifact("SessionRouter"); + const [event] = parseEventLogs({ + abi: artifact.abi, + logs: receipt.logs, + eventName: "SessionOpened", + }); + return event.args.sessionId; +} \ No newline at end of file diff --git a/smart-contracts/test/SessionRouter.ts b/smart-contracts/test/SessionRouter.ts deleted file mode 100644 index f3e39ae5..00000000 --- a/smart-contracts/test/SessionRouter.ts +++ /dev/null @@ -1,278 +0,0 @@ -import { - time, - loadFixture, -} from "@nomicfoundation/hardhat-toolbox-viem/network-helpers"; -import { expect } from "chai"; -import hre from "hardhat"; -import { getAddress, parseGwei, parseUnits } from "viem"; -import { AlmostEqual, expectAlmostEqual } from "../utils/compare"; - -describe("Session router", function () { - // We define a fixture to reuse the same setup in every test. - // We use loadFixture to run this setup once, snapshot that state, - // and reset Hardhat Network to that snapshot in every test. - async function deployMorpheusTokenAndSessionRouter() { - // Contracts are deployed using the first signer/account by default - const [owner, provider, buyer] = await hre.viem.getWalletClients(); - - const tokenMOR = await hre.viem.deployContract("MorpheusToken", []); - const sessionRouter = await hre.viem.deployContract("SessionRouter", [tokenMOR.address]); - const publicClient = await hre.viem.getPublicClient(); - const decimalsMOR = await tokenMOR.read.decimals(); - - return { - tokenMOR, - decimalsMOR, - sessionRouter, - owner, - provider, - buyer, - publicClient, - }; - } - - async function deployWithSingleProvider(){ - const {sessionRouter, owner, provider, publicClient, decimalsMOR, tokenMOR, buyer} = await deployMorpheusTokenAndSessionRouter(); - const expected = { - address: provider.account.address, - name: "Best provider", - URL: "https://bestprovider.com", - price: parseUnits("100", decimalsMOR), - } - - const buyerBalance = expected.price * 60n; - - const addProviderHash = await sessionRouter.write.addProvider([ - expected.address, - expected.name, - expected.URL, - expected.price, - ]); - await publicClient.waitForTransactionReceipt({ hash: addProviderHash }); - - const transferHash = await tokenMOR.write.transfer([buyer.account.address, buyerBalance]) - await publicClient.waitForTransactionReceipt({hash: transferHash}) - - return { - expected, - sessionRouter, - owner, - provider, - buyer, - buyerBalance, - publicClient, - tokenMOR, - } - } - - describe("Deployment", function () { - it("Should set the right owner", async function () { - const { sessionRouter, owner } = await loadFixture( - deployMorpheusTokenAndSessionRouter - ); - - expect(await sessionRouter.read.owner()).to.equal( - getAddress(owner.account.address) - ); - }); - - it("Should set the right token", async function () { - const { sessionRouter, tokenMOR } = await loadFixture( - deployMorpheusTokenAndSessionRouter - ); - - expect(await sessionRouter.read.tokenMOR()).to.equal(getAddress(tokenMOR.address)); - }); - }); - - describe("Provider actions", function () { - it("Should create a provider", async function () { - const { sessionRouter, provider, expected } = await loadFixture( - deployWithSingleProvider, - ); - - expect(await sessionRouter.read.providerList([0n])).eq(getAddress(provider.account.address)); - - const providerData = await sessionRouter.read.providers([provider.account.address]); - expect(providerData).deep.equals([ - getAddress(expected.address), - expected.name, - expected.URL, - expected.price - ]); - }) - }); - - describe("Session actions", function(){ - it("Should create session", async function(){ - const { sessionRouter, provider, buyer, tokenMOR, expected, publicClient, buyerBalance } = await loadFixture( - deployWithSingleProvider, - ); - - const approveHash = await tokenMOR.write.approve([sessionRouter.address, buyerBalance], {account: buyer.account}) - await publicClient.waitForTransactionReceipt({hash: approveHash}) - - const {request, result: sessionId} = await sessionRouter.simulate.startSession([provider.account.address], {account: buyer.account.address}) - const startSessionHash = await sessionRouter.write.startSession([provider.account.address], request) - const startSessionTx = await publicClient.waitForTransactionReceipt({hash: startSessionHash}) - - const {timestamp} = await publicClient.getBlock({blockNumber: startSessionTx.blockNumber}) - - // check balances - expect(await tokenMOR.read.balanceOf([buyer.account.address])).eq(0n); - expect(await tokenMOR.read.balanceOf([sessionRouter.address])).eq(buyerBalance); - - // check session - expect(sessionId).eq(0n); - - const expDuration = buyerBalance / expected.price * 60n; - const session = await sessionRouter.read.sessions([sessionId]) - console.log("session", session) - console.log("exp duration", expDuration) - - expect(session).to.be.deep.eq([ - sessionId, - getAddress(buyer.account.address), - getAddress(provider.account.address), - timestamp, - timestamp + buyerBalance / expected.price * 60n, - ]) - }) - - it("should close session manually and refund", async function(){ - const { sessionRouter, provider, buyer, tokenMOR, expected, publicClient, buyerBalance } = await loadFixture( - deployWithSingleProvider, - ); - - const approveHash = await tokenMOR.write.approve([sessionRouter.address, buyerBalance], {account: buyer.account}) - await publicClient.waitForTransactionReceipt({hash: approveHash}) - - const {request, result: sessionId} = await sessionRouter.simulate.startSession([provider.account.address], {account: buyer.account.address}) - const startSessionHash = await sessionRouter.write.startSession([provider.account.address], request) - const startSessionTx = await publicClient.waitForTransactionReceipt({hash: startSessionHash}) - - const {timestamp} = await publicClient.getBlock({blockNumber: startSessionTx.blockNumber}) - const progress = 1/3; - const denominator = 10**3; - const expectedSpentBalance = BigInt(Math.round(progress * denominator)) * buyerBalance / BigInt(denominator); - const expectedSpentTimeSeconds = 60n * expectedSpentBalance / expected.price - const expectedCloseTimestamp = timestamp + expectedSpentTimeSeconds; - - console.log("exp spent time", expectedSpentTimeSeconds) - console.log("exp close", expectedCloseTimestamp) - console.log("total balance", buyerBalance) - console.log("exp spent balance", expectedSpentBalance) - console.log("old buyer balance", await tokenMOR.read.balanceOf([buyer.account.address])) - console.log("old contract balance", await tokenMOR.read.balanceOf([sessionRouter.address])) - - await time.increaseTo(expectedCloseTimestamp) - - const closeSessionHash = await sessionRouter.write.closeSession([sessionId], {account: buyer.account}); - await publicClient.waitForTransactionReceipt({hash: closeSessionHash}) - const refundValue = buyerBalance - expectedSpentBalance; - - const newBuyerBalance = await tokenMOR.read.balanceOf([buyer.account.address]); - const newRouterBalance = await tokenMOR.read.balanceOf([sessionRouter.address]); - - expectAlmostEqual(refundValue, newBuyerBalance, 0.01); - expectAlmostEqual(refundValue, newRouterBalance, 0.01); - }) - }) - - // describe("Deployment", function () { - // it("Should set the right unlockTime", async function () { - // const { lock, unlockTime } = await loadFixture(deployOneYearLockFixture); - - // expect(await lock.read.unlockTime()).to.equal(unlockTime); - // }); - - // it("Should set the right owner", async function () { - // const { lock, owner } = await loadFixture(deployOneYearLockFixture); - - // expect(await lock.read.owner()).to.equal( - // getAddress(owner.account.address) - // ); - // }); - - // it("Should receive and store the funds to lock", async function () { - // const { lock, lockedAmount, publicClient } = await loadFixture( - // deployOneYearLockFixture - // ); - - // expect( - // await publicClient.getBalance({ - // address: lock.address, - // }) - // ).to.equal(lockedAmount); - // }); - - // it("Should fail if the unlockTime is not in the future", async function () { - // // We don't use the fixture here because we want a different deployment - // const latestTime = BigInt(await time.latest()); - // await expect( - // hre.viem.deployContract("Lock", [latestTime], { - // value: 1n, - // }) - // ).to.be.rejectedWith("Unlock time should be in the future"); - // }); - // }); - - // describe("Withdrawals", function () { - // describe("Validations", function () { - // it("Should revert with the right error if called too soon", async function () { - // const { lock } = await loadFixture(deployOneYearLockFixture); - - // await expect(lock.write.withdraw()).to.be.rejectedWith( - // "You can't withdraw yet" - // ); - // }); - - // it("Should revert with the right error if called from another account", async function () { - // const { lock, unlockTime, otherAccount } = await loadFixture( - // deployOneYearLockFixture - // ); - - // // We can increase the time in Hardhat Network - // await time.increaseTo(unlockTime); - - // // We retrieve the contract with a different account to send a transaction - // const lockAsOtherAccount = await hre.viem.getContractAt( - // "Lock", - // lock.address, - // { client: { wallet: otherAccount } } - // ); - // await expect(lockAsOtherAccount.write.withdraw()).to.be.rejectedWith( - // "You aren't the owner" - // ); - // }); - - // it("Shouldn't fail if the unlockTime has arrived and the owner calls it", async function () { - // const { lock, unlockTime } = await loadFixture( - // deployOneYearLockFixture - // ); - - // // Transactions are sent using the first signer by default - // await time.increaseTo(unlockTime); - - // await expect(lock.write.withdraw()).to.be.fulfilled; - // }); - // }); - - // describe("Events", function () { - // it("Should emit an event on withdrawals", async function () { - // const { lock, unlockTime, lockedAmount, publicClient } = - // await loadFixture(deployOneYearLockFixture); - - // await time.increaseTo(unlockTime); - - // const hash = await lock.write.withdraw(); - // await publicClient.waitForTransactionReceipt({ hash }); - - // // get the withdrawal events in the latest block - // const withdrawalEvents = await lock.getEvents.Withdrawal(); - // expect(withdrawalEvents).to.have.lengthOf(1); - // expect(withdrawalEvents[0].args.amount).to.equal(lockedAmount); - // }); - // }); - // }); -}); diff --git a/smart-contracts/test/Staking.test.ts b/smart-contracts/test/Staking.test.ts new file mode 100644 index 00000000..fd8cc117 --- /dev/null +++ b/smart-contracts/test/Staking.test.ts @@ -0,0 +1,184 @@ +import { loadFixture, time } from "@nomicfoundation/hardhat-toolbox-viem/network-helpers"; +import { expect } from "chai"; +import { deployDiamond } from "./fixtures"; +import { expectError } from "./utils"; +import { DAY, SECOND } from "../utils/time"; + +describe.skip("Staking", function () { + it("should stake", async function () { + const { sessionRouter, expectedStake } = await loadFixture(deployDiamond); + + expect(await sessionRouter.read.userStake([expectedStake.account])).equal( + expectedStake.stakeAmount + ); + expect(await sessionRouter.read.withdrawableStakeBalance([expectedStake.account])).equal( + expectedStake.stakeAmount + ); + }); + + it("should unstake", async function () { + const { sessionRouter, expectedStake } = await loadFixture(deployDiamond); + + await sessionRouter.write.unstake( + [expectedStake.account, expectedStake.stakeAmount, expectedStake.account], + { + account: expectedStake.account, + } + ); + + expect(await sessionRouter.read.userStake([expectedStake.account])).equal(0n); + }); + + // rewrite with real purchases + describe.skip("Stipend", function () { + it("should return daily stipend", async function () { + const { sessionRouter, expectedStake } = await loadFixture(deployDiamond); + + const balance = await sessionRouter.read.balanceOfDailyStipend([expectedStake.account]); + expect(balance).eq(expectedStake.expectedStipend); + }); + + it("should spend daily stipend", async function () { + const { sessionRouter, expectedStake, tokenMOR } = await loadFixture(deployDiamond); + + // await sessionRouter.write.transferDailyStipend( + // [expectedStake.account, expectedStake.transferTo, expectedStake.spendAmount], + // { account: expectedStake.account } + // ); + + expect(await tokenMOR.read.balanceOf([expectedStake.transferTo])).eq( + expectedStake.spendAmount + ); + expect(await sessionRouter.read.balanceOfDailyStipend([expectedStake.account])).eq( + expectedStake.expectedStipend - expectedStake.spendAmount + ); + }); + + it("should count spend amount correctly when spent second time same day", async function () { + const { sessionRouter, expectedStake, tokenMOR } = await loadFixture(deployDiamond); + + // await sessionRouter.write.transferDailyStipend( + // [expectedStake.account, expectedStake.transferTo, expectedStake.spendAmount], + // { account: expectedStake.account } + // ); + expect(await tokenMOR.read.balanceOf([expectedStake.transferTo])).eq( + expectedStake.spendAmount + ); + expect(await sessionRouter.read.balanceOfDailyStipend([expectedStake.account])).eq( + expectedStake.expectedStipend - expectedStake.spendAmount + ); + + // await sessionRouter.write.transferDailyStipend( + // [expectedStake.account, expectedStake.transferTo, expectedStake.spendAmount], + // { account: expectedStake.account } + // ); + expect(await tokenMOR.read.balanceOf([expectedStake.transferTo])).eq( + expectedStake.spendAmount * 2n + ); + expect(await sessionRouter.read.balanceOfDailyStipend([expectedStake.account])).eq( + expectedStake.expectedStipend - expectedStake.spendAmount * 2n + ); + }); + + it("should error when spending more than daily stipend", async function () { + const { sessionRouter, expectedStake } = await loadFixture(deployDiamond); + try { + // await sessionRouter.write.transferDailyStipend( + // [expectedStake.account, expectedStake.transferTo, expectedStake.expectedStipend + 1n], + // { account: expectedStake.account } + // ); + expect.fail("Should have thrown an error"); + } catch (e) { + expectError(e, sessionRouter.abi, "NotEnoughStipend"); + } + }); + + it("should reset daily stipend value on the next day", async function () { + const { sessionRouter, expectedStake, tokenMOR } = await loadFixture(deployDiamond); + + // await sessionRouter.write.transferDailyStipend( + // [expectedStake.account, expectedStake.transferTo, expectedStake.spendAmount], + // { account: expectedStake.account } + // ); + + expect(await tokenMOR.read.balanceOf([expectedStake.transferTo])).eq( + expectedStake.spendAmount + ); + expect(await sessionRouter.read.balanceOfDailyStipend([expectedStake.account])).eq( + expectedStake.expectedStipend - expectedStake.spendAmount + ); + + await time.increase(DAY / SECOND); + expect(await sessionRouter.read.balanceOfDailyStipend([expectedStake.account])).eq( + expectedStake.expectedStipend + ); + }); + + it("should lock unstaking till next day after using stipend", async function () { + const { sessionRouter, expectedStake, tokenMOR } = await loadFixture(deployDiamond); + + // await sessionRouter.write.transferDailyStipend( + // [expectedStake.account, expectedStake.transferTo, expectedStake.spendAmount], + // { account: expectedStake.account } + // ); + + expect(await sessionRouter.read.userStake([expectedStake.account])).eq( + expectedStake.stakeAmount + ); + + const withdrawableStakeBefore = await sessionRouter.read.withdrawableStakeBalance([ + expectedStake.account, + ]); + await time.increase(DAY / SECOND); + const withdrawableStakeAfter = await sessionRouter.read.withdrawableStakeBalance([ + expectedStake.account, + ]); + + expect(withdrawableStakeBefore < withdrawableStakeAfter).eq(true); + expect(withdrawableStakeAfter).eq(expectedStake.stakeAmount); + + const balanceBefore = await tokenMOR.read.balanceOf([expectedStake.account]); + await sessionRouter.write.unstake( + [expectedStake.account, expectedStake.stakeAmount, expectedStake.account], + { + account: expectedStake.account, + } + ); + const balanceAfter = await tokenMOR.read.balanceOf([expectedStake.account]); + + expect(await sessionRouter.read.userStake([expectedStake.account])).eq(0n); + expect(balanceAfter - balanceBefore).eq(expectedStake.stakeAmount); + }); + + it("should return stipend to the staking contract and increase daily stipend", async function () { + const { sessionRouter, expectedStake, tokenMOR } = await loadFixture(deployDiamond); + + const stipendBeforeTransfer = await sessionRouter.read.balanceOfDailyStipend([ + expectedStake.account, + ]); + + // await sessionRouter.write.transferDailyStipend( + // [expectedStake.account, expectedStake.transferTo, expectedStake.spendAmount], + // { account: expectedStake.account } + // ); + + const stipendAfterTransfer = await sessionRouter.read.balanceOfDailyStipend([ + expectedStake.account, + ]); + + await tokenMOR.write.approve([sessionRouter.address, expectedStake.spendAmount], { + account: expectedStake.transferTo, + }); + await sessionRouter.write.returnStipend([expectedStake.account, expectedStake.spendAmount], { + account: expectedStake.transferTo, + }); + + const stipendAfterRefund = await sessionRouter.read.balanceOfDailyStipend([ + expectedStake.account, + ]); + + expect(stipendAfterTransfer).eq(stipendBeforeTransfer - expectedStake.spendAmount); + expect(stipendBeforeTransfer).eq(stipendAfterRefund); + }); + }); +}); diff --git a/smart-contracts/test/fixtures.ts b/smart-contracts/test/fixtures.ts new file mode 100644 index 00000000..bb89b89b --- /dev/null +++ b/smart-contracts/test/fixtures.ts @@ -0,0 +1,271 @@ +import hre from "hardhat"; +import { encodeFunctionData, encodePacked, getAddress, parseUnits } from "viem/utils"; +import { getHex, getTxTimestamp, randomBytes32 } from "./utils"; +import { loadFixture } from "@nomicfoundation/hardhat-network-helpers"; +import { FacetCutAction, getSelectors } from "../libraries/diamond"; + +export async function deployMORtoken() { + const [owner] = await hre.viem.getWalletClients(); + + // Contracts are deployed using the first signer/account by default + const tokenMOR = await hre.viem.deployContract("MorpheusToken", []); + const decimalsMOR = await tokenMOR.read.decimals(); + + return { + tokenMOR, + decimalsMOR, + owner, + }; +} + +export async function deployDiamond() { + // deploy provider registry and deps + const { tokenMOR, owner, decimalsMOR } = await loadFixture(deployMORtoken); + + const [, provider, user] = await hre.viem.getWalletClients(); + const publicClient = await hre.viem.getPublicClient(); + + // 1. deploy diamont init + const diamondInit = await hre.viem.deployContract("DiamondInit", [], {}); + + // 2. deploy faucets + const FacetNames = [ + "DiamondCutFacet", + "DiamondLoupeFacet", + "OwnershipFacet", + "ModelRegistry", + "ProviderRegistry", + "Marketplace", + "SessionRouter", + ] as const; + + const facetContracts = await Promise.all( + FacetNames.map((name) => { + return hre.viem.deployContract(name as any, [], {}); + }) + ); + + // 3. deploy diamond + const facetCuts = facetContracts.map((facetContract) => ({ + facetAddress: facetContract.address, + action: FacetCutAction.Add, + functionSelectors: getSelectors(facetContract.abi), + })); + + const diamondArgs = { + owner: owner.account.address, + init: diamondInit.address, + initCalldata: encodeFunctionData({ + abi: diamondInit.abi, + functionName: "init", + args: [tokenMOR.address, owner.account.address], + }), + }; + const diamond = await hre.viem.deployContract("Diamond", [facetCuts, diamondArgs]); + + const modelRegistry = await hre.viem.getContractAt( + "contracts/facets/ModelRegistry.sol:ModelRegistry", + diamond.address + ); + const providerRegistry = await hre.viem.getContractAt( + "contracts/facets/ProviderRegistry.sol:ProviderRegistry", + diamond.address + ); + const marketplace = await hre.viem.getContractAt( + "contracts/facets/Marketplace.sol:Marketplace", + diamond.address + ); + const sessionRouter = await hre.viem.getContractAt( + "contracts/facets/SessionRouter.sol:SessionRouter", + diamond.address + ); + + return { + tokenMOR, + decimalsMOR, + diamond, + owner, + user, + provider, + publicClient, + modelRegistry, + providerRegistry, + marketplace, + sessionRouter, + }; +} + +export async function deploySingleProvider() { + const { sessionRouter, providerRegistry, owner, provider, publicClient, decimalsMOR, tokenMOR } = + await loadFixture(deployDiamond); + + const expectedProvider = { + address: getAddress(provider.account.address), + stake: parseUnits("100", decimalsMOR), + endpoint: "https://bestprovider.com", + timestamp: 0n, + isDeleted: false, + }; + + await tokenMOR.write.transfer([provider.account.address, expectedProvider.stake * 100n], { + account: owner.account, + }); + + await tokenMOR.write.approve([sessionRouter.address, expectedProvider.stake], { + account: provider.account, + }); + + const addProviderHash = await providerRegistry.write.providerRegister( + [expectedProvider.address, expectedProvider.stake, expectedProvider.endpoint], + { account: provider.account } + ); + expectedProvider.timestamp = await getTxTimestamp(publicClient, addProviderHash); + + return { + expectedProvider, + providerRegistry, + sessionRouter, + owner, + provider, + publicClient, + tokenMOR, + decimalsMOR, + }; +} + +export async function deploySingleModel() { + const { owner, provider, publicClient, tokenMOR, modelRegistry } = await loadFixture( + deployDiamond + ); + + const expectedModel = { + modelId: randomBytes32(), + ipfsCID: getHex(Buffer.from("ipfs://ipfsaddress")), + fee: 100n, + stake: 100n, + owner: owner.account.address, + name: "Llama 2.0", + timestamp: 0n, + tags: ["llama", "animal", "cute"], + isDeleted: false, + }; + + await tokenMOR.write.approve([modelRegistry.address, expectedModel.stake]); + + const addProviderHash = await modelRegistry.write.modelRegister([ + expectedModel.modelId, + expectedModel.ipfsCID, + expectedModel.fee, + expectedModel.stake, + expectedModel.owner, + expectedModel.name, + expectedModel.tags, + ]); + + expectedModel.timestamp = await getTxTimestamp(publicClient, addProviderHash); + + return { + expectedModel, + modelRegistry, + owner, + provider, + publicClient, + tokenMOR, + }; +} +export async function deploySingleBid() { + const { + owner, + provider, + publicClient, + tokenMOR, + modelRegistry, + user, + decimalsMOR, + marketplace, + sessionRouter, + } = await loadFixture(deployDiamond); + + const expectedProvider = { + address: getAddress(provider.account.address), + stake: parseUnits("100", decimalsMOR), + endpoint: "https://bestprovider.com", + timestamp: 0n, + isDeleted: false, + }; + + // add single model + const expectedModel = { + modelId: randomBytes32(), + ipfsCID: getHex(Buffer.from("ipfs://ipfsaddress")), + fee: 100n, + stake: 100n, + owner: owner.account.address, + name: "Llama 2.0", + timestamp: 0n, + tags: ["llama", "animal", "cute"], + isDeleted: false, + }; + + await tokenMOR.write.approve([modelRegistry.address, expectedModel.stake]); + const addProviderHash = await modelRegistry.write.modelRegister([ + expectedModel.modelId, + expectedModel.ipfsCID, + expectedModel.fee, + expectedModel.stake, + expectedModel.owner, + expectedModel.name, + expectedModel.tags, + ]); + + expectedModel.timestamp = await getTxTimestamp(publicClient, addProviderHash); + + await tokenMOR.write.approve([modelRegistry.address, 10000n * 10n ** 18n]); + await tokenMOR.write.transfer([user.account.address, 100000n * 10n ** 18n]); + await tokenMOR.write.approve([modelRegistry.address, 10000000n * 10n ** 18n], { + account: user.account, + }); + + // expected bid + const expectedBid = { + id: "" as `0x${string}`, + providerAddr: getAddress(expectedProvider.address), + modelId: expectedModel.modelId, + pricePerSecond: 1n, + nonce: 0n, + createdAt: 0n, + deletedAt: 0n, + }; + + // add single bid + const postBidtx = await marketplace.simulate.postModelBid( + [expectedBid.providerAddr, expectedBid.modelId, expectedBid.pricePerSecond], + { account: provider.account.address } + ); + const txHash = await provider.writeContract(postBidtx.request); + + expectedBid.id = postBidtx.result; + expectedBid.createdAt = await getTxTimestamp(publicClient, txHash); + + return { + expectedBid, + marketplace, + owner, + provider, + publicClient, + tokenMOR, + decimalsMOR, + sessionRouter, + user, + }; +} + +export const providerReport = { + ips: 128, + timestamp: 10000, +}; +export const reportAbi = ["uint32", "uint32"] as const; +export const encodedReport = encodePacked(reportAbi, [ + providerReport.ips, + providerReport.timestamp, +]); diff --git a/smart-contracts/test/types.ts b/smart-contracts/test/types.ts new file mode 100644 index 00000000..e69de29b diff --git a/smart-contracts/test/utils.ts b/smart-contracts/test/utils.ts new file mode 100644 index 00000000..bb0ddc82 --- /dev/null +++ b/smart-contracts/test/utils.ts @@ -0,0 +1,92 @@ +import { PublicClient } from "@nomicfoundation/hardhat-viem/types"; +import { + Abi, + BaseError, + ContractFunctionRevertedError, + UnknownRpcError, +} from "viem"; +import { + DecodeErrorResultReturnType, + decodeErrorResult, + padHex, +} from "viem/utils"; +import crypto from "crypto"; + +export async function getTxTimestamp( + client: PublicClient, + txHash: `0x${string}`, +): Promise { + const receipt = await client.waitForTransactionReceipt({ + hash: txHash, + timeout: 1000, + }); + const block = await client.getBlock({ blockNumber: receipt.blockNumber }); + return block.timestamp; +} + +export function expectError( + err: any, + abi: TAbi | undefined, + error: DecodeErrorResultReturnType["errorName"], +) { + if (!catchErr(err, abi, error)) { + console.error(err); + throw new Error( + `Expected blockchain custom error "${error}" was not thrown\n\n${err}`, + { + cause: err, + }, + ); + } +} + +export function catchErr( + err: any, + abi: TAbi | undefined, + error: DecodeErrorResultReturnType["errorName"], +): boolean { + if (err instanceof BaseError) { + const revertError = err.walk( + (err) => + err instanceof ContractFunctionRevertedError || + err instanceof UnknownRpcError, + ); + + // support for regular provider + if (revertError instanceof ContractFunctionRevertedError) { + const errorName = revertError.data?.errorName ?? ""; + if (errorName === error) { + return true; + } + } + + // support for hardhat node + if (revertError instanceof UnknownRpcError) { + const cause = revertError.cause as any; + if (cause.data) { + try { + const decodedError = decodeErrorResult({ abi, data: cause.data }); + if (decodedError.errorName === error) { + return true; + } + } catch (e) { + console.error(e); + return false; + } + } + } + } + return false; +} + +export const getHex = (buffer: Buffer, padding = 32): `0x${string}` => { + return padHex(`0x${buffer.toString("hex")}`, { size: padding }); +}; + +export const randomBytes32 = (): `0x${string}` => { + return getHex(crypto.randomBytes(32)); +}; + +export const randomAddress = (): `0x${string}` => { + return getHex(crypto.randomBytes(20), 20); +}; \ No newline at end of file diff --git a/smart-contracts/tsconfig.json b/smart-contracts/tsconfig.json index 574e785c..5b230643 100644 --- a/smart-contracts/tsconfig.json +++ b/smart-contracts/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "target": "es2020", + "target": "es2022", "module": "commonjs", "esModuleInterop": true, "forceConsistentCasingInFileNames": true, diff --git a/smart-contracts/utils/compare.ts b/smart-contracts/utils/compare.ts index 2dd29f25..f56b1390 100644 --- a/smart-contracts/utils/compare.ts +++ b/smart-contracts/utils/compare.ts @@ -2,17 +2,30 @@ import { expect } from "chai"; type NumberLike = number | bigint; -export const expectAlmostEqual = (expected: NumberLike, actual: NumberLike, epsilon: NumberLike, message?: string): void => { - let msg = `expected ${actual} to be within ${expected} +/- ${epsilon} epsilon`; - if (message){ +export const expectAlmostEqual = ( + expected: NumberLike, + actual: NumberLike, + epsilon: NumberLike, + message?: string +): void => { + const delta = Number(epsilon) * Number(expected); + const min = Number(expected) - delta; + const max = Number(expected) + delta; + + let msg = `expected ${actual} to be within ${expected} +/- ${epsilon} epsilon (${min} - ${max})`; + if (message) { msg += `: ${message}`; } expect(AlmostEqual(expected, actual, epsilon)).to.be.eq(true, msg); -} +}; -export const AlmostEqual = (expected: NumberLike, actual: NumberLike, epsilon: NumberLike): boolean => { +export const AlmostEqual = ( + expected: NumberLike, + actual: NumberLike, + epsilon: NumberLike +): boolean => { return RelativeError(expected, actual) <= epsilon; -} +}; export const RelativeError = (target: NumberLike, actual: NumberLike): number => { return Math.abs(Number(actual) - Number(target)) / Math.abs(Number(target)); diff --git a/smart-contracts/utils/time.ts b/smart-contracts/utils/time.ts new file mode 100644 index 00000000..af714788 --- /dev/null +++ b/smart-contracts/utils/time.ts @@ -0,0 +1,5 @@ +export const MILLISECOND = 1; +export const SECOND = 1000 * MILLISECOND; +export const MINUTE = 60 * SECOND; +export const HOUR = 60 * MINUTE; +export const DAY = 24 * HOUR; diff --git a/smart-contracts/yarn.lock b/smart-contracts/yarn.lock index 7fa580fa..48393d45 100644 --- a/smart-contracts/yarn.lock +++ b/smart-contracts/yarn.lock @@ -394,7 +394,7 @@ "@ethersproject/rlp" "^5.7.0" "@ethersproject/signing-key" "^5.7.0" -"@ethersproject/units@5.7.0": +"@ethersproject/units@5.7.0", "@ethersproject/units@^5.7.0": version "5.7.0" resolved "https://registry.yarnpkg.com/@ethersproject/units/-/units-5.7.0.tgz#637b563d7e14f42deeee39245275d477aae1d8b1" integrity sha512-pD3xLMy3SJu9kG5xDGI7+xhTEmGXlEqXU4OfNapmfnxLVY4EMSSRp7j1k7eezutBPH7RBN/7QPnwR7hzNlEFeg== @@ -451,6 +451,18 @@ resolved "https://registry.yarnpkg.com/@fastify/busboy/-/busboy-2.1.1.tgz#b9da6a878a371829a0502c9b6c1c143ef6663f4d" integrity sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA== +"@isaacs/cliui@^8.0.2": + version "8.0.2" + resolved "https://registry.yarnpkg.com/@isaacs/cliui/-/cliui-8.0.2.tgz#b37667b7bc181c168782259bab42474fbf52b550" + integrity sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA== + dependencies: + string-width "^5.1.2" + string-width-cjs "npm:string-width@^4.2.0" + strip-ansi "^7.0.1" + strip-ansi-cjs "npm:strip-ansi@^6.0.1" + wrap-ansi "^8.1.0" + wrap-ansi-cjs "npm:wrap-ansi@^7.0.0" + "@jridgewell/resolve-uri@^3.0.3": version "3.1.2" resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz#7a0ee601f60f99a20c7c7c5ff0c80388c1189bd6" @@ -571,31 +583,61 @@ resolved "https://registry.yarnpkg.com/@nomicfoundation/edr-darwin-arm64/-/edr-darwin-arm64-0.3.2.tgz#be1f696d429aecdf47d292a75958551e7cc34294" integrity sha512-l6wfSBUUbGJiCENT6272CDI8yoMuf0sZH56H5qz3HnAyVzenkOvmzyF6/lar54m986kdAQqWls4cLvDxiOuLxg== +"@nomicfoundation/edr-darwin-arm64@0.3.5": + version "0.3.5" + resolved "https://registry.yarnpkg.com/@nomicfoundation/edr-darwin-arm64/-/edr-darwin-arm64-0.3.5.tgz#3c428000ec27501617a00f7c447054a272f99177" + integrity sha512-gIXUIiPMUy6roLHpNlxf15DumU7/YhffUf7XIB+WUjMecaySfTGyZsTGnCMJZqrDyiYqWPyPKwCV/2u/jqFAUg== + "@nomicfoundation/edr-darwin-x64@0.3.2": version "0.3.2" resolved "https://registry.yarnpkg.com/@nomicfoundation/edr-darwin-x64/-/edr-darwin-x64-0.3.2.tgz#efd2a5a302dc0a806fb2439a7e2c8ed7bd482ff8" integrity sha512-OboExL7vEw+TRJQl3KkaEKU4K7PTdZPTInZ0fxMAtOpcWp7EKR+dQo68vc/iAOusB3xszHKxt7t+WpisItfdcg== +"@nomicfoundation/edr-darwin-x64@0.3.5": + version "0.3.5" + resolved "https://registry.yarnpkg.com/@nomicfoundation/edr-darwin-x64/-/edr-darwin-x64-0.3.5.tgz#fee26c4a83c9fc534bc0a719e88382fafeed69fe" + integrity sha512-0MrpOCXUK8gmplpYZ2Cy0holHEylvWoNeecFcrP2WJ5DLQzrB23U5JU2MvUzOJ7aL76Za1VXNBWi/UeTWdHM+w== + "@nomicfoundation/edr-linux-arm64-gnu@0.3.2": version "0.3.2" resolved "https://registry.yarnpkg.com/@nomicfoundation/edr-linux-arm64-gnu/-/edr-linux-arm64-gnu-0.3.2.tgz#4d7d4f28e13d426b5e3cf9731dbfed573f819245" integrity sha512-xtEK+1eg++3pHi6405NDXd80S3CGOFEGQIyVGCwjMGQFOLSzBGGCsrb/0GB4J19zd1o/8ftCd/HjZcbVAWWTLQ== +"@nomicfoundation/edr-linux-arm64-gnu@0.3.5": + version "0.3.5" + resolved "https://registry.yarnpkg.com/@nomicfoundation/edr-linux-arm64-gnu/-/edr-linux-arm64-gnu-0.3.5.tgz#c48ad44b578abb50706cd8cad607a65b1289689f" + integrity sha512-aw9f7AZMiY1dZFNePJGKho2k+nEgFgzUAyyukiKfSqUIMXoFXMf1U3Ujv848czrSq9c5XGcdDa2xnEf3daU3xg== + "@nomicfoundation/edr-linux-arm64-musl@0.3.2": version "0.3.2" resolved "https://registry.yarnpkg.com/@nomicfoundation/edr-linux-arm64-musl/-/edr-linux-arm64-musl-0.3.2.tgz#10702ae4db386cc21efef9e6276bb56a09581e0a" integrity sha512-3cIsskJOXQ1yEVsImmCacY7O03tUTiWrmd54F05PnPFrDLkjbzodQ3b2gUWzfbzUZWl67ZTJd1CvVSzpe7XGzw== +"@nomicfoundation/edr-linux-arm64-musl@0.3.5": + version "0.3.5" + resolved "https://registry.yarnpkg.com/@nomicfoundation/edr-linux-arm64-musl/-/edr-linux-arm64-musl-0.3.5.tgz#7cc1b12e2adf872e5a542647182262cc4582f8d9" + integrity sha512-cVFRQjyABBlsbDj+XTczYBfrCHprZ6YNzN8gGGSqAh+UGIJkAIRomK6ar27GyJLNx3HkgbuDoi/9kA0zOo/95w== + "@nomicfoundation/edr-linux-x64-gnu@0.3.2": version "0.3.2" resolved "https://registry.yarnpkg.com/@nomicfoundation/edr-linux-x64-gnu/-/edr-linux-x64-gnu-0.3.2.tgz#a29590bea8d490aa2129f2cb7fab1559ec9d25ee" integrity sha512-ouPdphHNsyO7wqwa4hwahC5WqBglK/fIvMmhR/SXNZ9qruIpsA8ZZKIURaHMOv/2h2BbNGcyTX9uEk6+5rK/MQ== +"@nomicfoundation/edr-linux-x64-gnu@0.3.5": + version "0.3.5" + resolved "https://registry.yarnpkg.com/@nomicfoundation/edr-linux-x64-gnu/-/edr-linux-x64-gnu-0.3.5.tgz#ae4366c6fad03ea6ec3e2f2bafe397661c11f054" + integrity sha512-CjOg85DfR1Vt0fQWn5U0qi26DATK9tVzo3YOZEyI0JBsnqvk43fUTPv3uUAWBrPIRg5O5kOc9xG13hSpCBBxBg== + "@nomicfoundation/edr-linux-x64-musl@0.3.2": version "0.3.2" resolved "https://registry.yarnpkg.com/@nomicfoundation/edr-linux-x64-musl/-/edr-linux-x64-musl-0.3.2.tgz#fe2b4c282c80c792b3a03e04d517d140a927cf92" integrity sha512-sRhwhiPbkpJMOUwXW1FZw9ks6xWyQhIhM0E8o3TXEXKSPKTE6whQLEk1R37iFITaI36vb6rSwLKTU1cb32gCoA== +"@nomicfoundation/edr-linux-x64-musl@0.3.5": + version "0.3.5" + resolved "https://registry.yarnpkg.com/@nomicfoundation/edr-linux-x64-musl/-/edr-linux-x64-musl-0.3.5.tgz#4071929fcece90f95c271f6ba455c55f35750efd" + integrity sha512-hvX8bBGpBydAVevzK8jsu2FlqVZK1RrCyTX6wGHnltgMuBaoGLHYtNHiFpteOaJw2byYMiORc2bvj+98LhJ0Ew== + "@nomicfoundation/edr-win32-arm64-msvc@0.3.2": version "0.3.2" resolved "https://registry.yarnpkg.com/@nomicfoundation/edr-win32-arm64-msvc/-/edr-win32-arm64-msvc-0.3.2.tgz#6f09cf20f7e7be3ea70f61888cde238d924ec369" @@ -611,6 +653,11 @@ resolved "https://registry.yarnpkg.com/@nomicfoundation/edr-win32-x64-msvc/-/edr-win32-x64-msvc-0.3.2.tgz#331e3cea1618134e8d9f4ccb999086af6362a3af" integrity sha512-Byn4QuWczRy/DUUQM3WjglgX/jGVUURVFaUsmIhnGg//MPlCLawubBGRqsrMuvaYedlIIJ4I2rgKvZlxdgHrqg== +"@nomicfoundation/edr-win32-x64-msvc@0.3.5": + version "0.3.5" + resolved "https://registry.yarnpkg.com/@nomicfoundation/edr-win32-x64-msvc/-/edr-win32-x64-msvc-0.3.5.tgz#6e6684e56f336c67fbda9bf75b21d7ac586631b8" + integrity sha512-IJXjW13DY5UPsx/eG5DGfXtJ7Ydwrvw/BTZ2Y93lRLHzszVpSmeVmlxjZP5IW2afTSgMLaAAsqNw4NhppRGN8A== + "@nomicfoundation/edr@^0.3.1": version "0.3.2" resolved "https://registry.yarnpkg.com/@nomicfoundation/edr/-/edr-0.3.2.tgz#a81500746f8f8c342606a9be04a9f6176f8e2d54" @@ -626,6 +673,19 @@ "@nomicfoundation/edr-win32-ia32-msvc" "0.3.2" "@nomicfoundation/edr-win32-x64-msvc" "0.3.2" +"@nomicfoundation/edr@^0.3.5": + version "0.3.5" + resolved "https://registry.yarnpkg.com/@nomicfoundation/edr/-/edr-0.3.5.tgz#04f980386f871e1c3bbc180b290d37af0336c81d" + integrity sha512-dPSM9DuI1sr71gqWUMgLo8MjHQWO4+WNDm3iWaT6P4vUFJReZX5qwA5X+3UwIPBry8GvNY084u7yWUvB3/8rqA== + optionalDependencies: + "@nomicfoundation/edr-darwin-arm64" "0.3.5" + "@nomicfoundation/edr-darwin-x64" "0.3.5" + "@nomicfoundation/edr-linux-arm64-gnu" "0.3.5" + "@nomicfoundation/edr-linux-arm64-musl" "0.3.5" + "@nomicfoundation/edr-linux-x64-gnu" "0.3.5" + "@nomicfoundation/edr-linux-x64-musl" "0.3.5" + "@nomicfoundation/edr-win32-x64-msvc" "0.3.5" + "@nomicfoundation/ethereumjs-common@4.0.4": version "4.0.4" resolved "https://registry.yarnpkg.com/@nomicfoundation/ethereumjs-common/-/ethereumjs-common-4.0.4.tgz#9901f513af2d4802da87c66d6f255b510bef5acb" @@ -921,6 +981,11 @@ proper-lockfile "^4.1.1" solidity-ast "^0.4.51" +"@pkgjs/parseargs@^0.11.0": + version "0.11.0" + resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33" + integrity sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg== + "@scure/base@~1.1.0", "@scure/base@~1.1.2", "@scure/base@~1.1.4": version "1.1.5" resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.1.5.tgz#1d85d17269fe97694b9c592552dd9e5e33552157" @@ -1052,6 +1117,13 @@ dependencies: tslib "^2.6.2" +"@solarity/hardhat-gobind@^1.2.2": + version "1.2.2" + resolved "https://registry.yarnpkg.com/@solarity/hardhat-gobind/-/hardhat-gobind-1.2.2.tgz#cc5d9789fe314f5ed675af23301e90bc3a891220" + integrity sha512-YZfpzJA4qqmNEGIu76X0ZeTwX3Q7nM8oL9rEtAbURqUm1ZgizDbg819F4CKlRcCQdaa+q/EaKqPYhamn1F0bdw== + dependencies: + lodash "4.17.21" + "@solarity/solidity-lib@2.5.9": version "2.5.9" resolved "https://registry.yarnpkg.com/@solarity/solidity-lib/-/solidity-lib-2.5.9.tgz#55dc78814dfe3467233f3b6836ab3063b038afa6" @@ -1067,6 +1139,11 @@ dependencies: antlr4ts "^0.5.0-alpha.4" +"@solidity-parser/parser@^0.17.0": + version "0.17.0" + resolved "https://registry.yarnpkg.com/@solidity-parser/parser/-/parser-0.17.0.tgz#52a2fcc97ff609f72011014e4c5b485ec52243ef" + integrity sha512-Nko8R0/kUo391jsEHHxrGM07QFdnPGvlmox4rmH0kNiNAashItAilhy4Mv4pK5gQmW5f4sXAF58fwJbmlkGcVw== + "@solidity-parser/parser@^0.18.0": version "0.18.0" resolved "https://registry.yarnpkg.com/@solidity-parser/parser/-/parser-0.18.0.tgz#8e77a02a09ecce957255a2f48c9a7178ec191908" @@ -1125,6 +1202,13 @@ dependencies: "@types/node" "*" +"@types/dotenv@^8.2.0": + version "8.2.0" + resolved "https://registry.yarnpkg.com/@types/dotenv/-/dotenv-8.2.0.tgz#5cd64710c3c98e82d9d15844375a33bf1b45d053" + integrity sha512-ylSC9GhfRH7m1EUXBXofhgx4lUWmFeQDINW5oLuS+gxWdfUeW4zJdeVTYVkexEW+e2VUvlZR2kGnGGipAWR7kw== + dependencies: + dotenv "*" + "@types/form-data@0.0.33": version "0.0.33" resolved "https://registry.yarnpkg.com/@types/form-data/-/form-data-0.0.33.tgz#c9ac85b2a5fd18435b8c85d9ecb50e6d6c893ff8" @@ -1357,6 +1441,11 @@ ansi-regex@^5.0.1: resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== +ansi-regex@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-6.0.1.tgz#3183e38fae9a65d7cb5e53945cd5897d0260a06a" + integrity sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA== + ansi-styles@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" @@ -1371,6 +1460,11 @@ ansi-styles@^4.0.0, ansi-styles@^4.1.0: dependencies: color-convert "^2.0.1" +ansi-styles@^6.1.0: + version "6.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-6.2.1.tgz#0e62320cf99c21afff3b3012192546aacbfb05c5" + integrity sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug== + antlr4ts@^0.5.0-alpha.4: version "0.5.0-alpha.4" resolved "https://registry.yarnpkg.com/antlr4ts/-/antlr4ts-0.5.0-alpha.4.tgz#71702865a87478ed0b40c0709f422cf14d51652a" @@ -1506,7 +1600,7 @@ axios@^0.21.1, axios@^0.21.2: dependencies: follow-redirects "^1.14.0" -axios@^1.4.0, axios@^1.5.1: +axios@^1.4.0, axios@^1.5.1, axios@^1.6.7: version "1.6.8" resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.8.tgz#66d294951f5d988a00e87a0ffb955316a619ea66" integrity sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ== @@ -1608,6 +1702,11 @@ brorand@^1.1.0: resolved "https://registry.yarnpkg.com/brorand/-/brorand-1.1.0.tgz#12c25efe40a45e3c323eb8675a0a0ce57b22371f" integrity sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w== +brotli-wasm@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/brotli-wasm/-/brotli-wasm-2.0.1.tgz#2b3f4dc3db0c3e60d2635c055e6bac4ddf4bd3f5" + integrity sha512-+3USgYsC7bzb5yU0/p2HnnynZl0ak0E6uoIm4UW4Aby/8s8HFCq6NCfrrf1E9c3O8OCSzq3oYO1tUVqIi61Nww== + browser-stdout@1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.1.tgz#baa559ee14ced73452229bad7326467c61fabd60" @@ -1720,6 +1819,14 @@ chai@^4.2.0: pathval "^1.1.1" type-detect "^4.0.8" +chalk@4.1.2, chalk@^4.0.0, chalk@^4.1.0, chalk@^4.1.2: + version "4.1.2" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" + integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== + dependencies: + ansi-styles "^4.1.0" + supports-color "^7.1.0" + chalk@^2.4.2: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" @@ -1729,14 +1836,6 @@ chalk@^2.4.2: escape-string-regexp "^1.0.5" supports-color "^5.3.0" -chalk@^4.0.0, chalk@^4.1.0, chalk@^4.1.2: - version "4.1.2" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" - integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== - dependencies: - ansi-styles "^4.1.0" - supports-color "^7.1.0" - "charenc@>= 0.0.1": version "0.0.2" resolved "https://registry.yarnpkg.com/charenc/-/charenc-0.0.2.tgz#c0a1d2f3a7092e03774bfa83f14c0fc5790a8667" @@ -1812,7 +1911,7 @@ cli-table3@^0.5.0: optionalDependencies: colors "^1.1.2" -cli-table3@^0.6.0: +cli-table3@^0.6.0, cli-table3@^0.6.3: version "0.6.4" resolved "https://registry.yarnpkg.com/cli-table3/-/cli-table3-0.6.4.tgz#d1c536b8a3f2e7bec58f67ac9e5769b1b30088b0" integrity sha512-Lm3L0p+/npIQWNIiyF/nAn7T5dnOwR3xNTHXYEBFBFVPXzCVNZ5lqEC/1eo/EVfpDsQ1I+TX4ORPQgp+UI0CRw== @@ -1965,6 +2064,15 @@ cross-spawn@^6.0.5: shebang-command "^1.2.0" which "^1.2.9" +cross-spawn@^7.0.0: + version "7.0.3" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" + integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== + dependencies: + path-key "^3.1.0" + shebang-command "^2.0.0" + which "^2.0.1" + "crypt@>= 0.0.1": version "0.0.2" resolved "https://registry.yarnpkg.com/crypt/-/crypt-0.0.2.tgz#88d7ff7ec0dfb86f713dc87bbb42d044d3e6c41b" @@ -2083,11 +2191,21 @@ dir-glob@^3.0.1: dependencies: path-type "^4.0.0" +dotenv@*: + version "16.4.5" + resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.4.5.tgz#cdd3b3b604cb327e286b4762e13502f717cb099f" + integrity sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg== + dotenv@^10.0.0: version "10.0.0" resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-10.0.0.tgz#3d4227b8fb95f81096cdd2b66653fb2c7085ba81" integrity sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q== +eastasianwidth@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/eastasianwidth/-/eastasianwidth-0.2.0.tgz#696ce2ec0aa0e6ea93a397ffcf24aa7840c827cb" + integrity sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA== + elliptic@6.5.4: version "6.5.4" resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.4.tgz#da37cebd31e79a1367e941b592ed1fbebd58abbb" @@ -2119,6 +2237,11 @@ emoji-regex@^8.0.0: resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== +emoji-regex@^9.2.2: + version "9.2.2" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-9.2.2.tgz#840c8803b0d8047f4ff0cf963176b32d4ef3ed72" + integrity sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg== + encode-utf8@^1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/encode-utf8/-/encode-utf8-1.0.3.tgz#f30fdd31da07fb596f281beb2f6b027851994cda" @@ -2342,7 +2465,7 @@ ethereum-cryptography@^1.0.3: "@scure/bip32" "1.1.5" "@scure/bip39" "1.1.1" -ethereum-cryptography@^2.0.0, ethereum-cryptography@^2.1.2: +ethereum-cryptography@^2.0.0, ethereum-cryptography@^2.1.2, ethereum-cryptography@^2.1.3: version "2.1.3" resolved "https://registry.yarnpkg.com/ethereum-cryptography/-/ethereum-cryptography-2.1.3.tgz#1352270ed3b339fe25af5ceeadcf1b9c8e30768a" integrity sha512-BlwbIL7/P45W8FGW2r7LGuvoEZ+7PWsniMvQ4p5s2xCyw9tmaDlpfsN9HjAucbF+t/qpVHwZUisgfK24TCW8aA== @@ -2550,6 +2673,14 @@ for-each@^0.3.3: dependencies: is-callable "^1.1.3" +foreground-child@^3.1.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/foreground-child/-/foreground-child-3.1.1.tgz#1d173e776d75d2772fed08efe4a0de1ea1b12d0d" + integrity sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg== + dependencies: + cross-spawn "^7.0.0" + signal-exit "^4.0.1" + form-data@^2.2.0: version "2.5.1" resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.5.1.tgz#f2cbec57b5e59e23716e128fe44d4e5dd23895f4" @@ -2746,6 +2877,17 @@ glob@8.1.0: minimatch "^5.0.1" once "^1.3.0" +glob@^10.3.10: + version "10.3.12" + resolved "https://registry.yarnpkg.com/glob/-/glob-10.3.12.tgz#3a65c363c2e9998d220338e88a5f6ac97302960b" + integrity sha512-TCNv8vJ+xz4QiqTpfOJA7HvYv+tNIRHKfUWw/q+v2jdgN4ebz+KY9tGx5J4rHP0o84mNP+ApH66HRX8us3Khqg== + dependencies: + foreground-child "^3.1.0" + jackspeak "^2.3.6" + minimatch "^9.0.1" + minipass "^7.0.4" + path-scurry "^1.10.2" + glob@^5.0.15: version "5.0.15" resolved "https://registry.yarnpkg.com/glob/-/glob-5.0.15.tgz#1bc936b9e02f4a603fcc222ecf7633d30b8b93b1" @@ -2872,7 +3014,7 @@ hardhat-deploy@^0.10.5: murmur-128 "^0.2.1" qs "^6.9.4" -hardhat-gas-reporter@^1.0.6, hardhat-gas-reporter@^1.0.8: +hardhat-gas-reporter@^1.0.6: version "1.0.10" resolved "https://registry.yarnpkg.com/hardhat-gas-reporter/-/hardhat-gas-reporter-1.0.10.tgz#ebe5bda5334b5def312747580cd923c2b09aef1b" integrity sha512-02N4+So/fZrzJ88ci54GqwVA3Zrf0C9duuTyGt0CFRIh/CdNwbnTgkXkRfojOMLBQ+6t+lBIkgbsOtqMvNwikA== @@ -2881,6 +3023,27 @@ hardhat-gas-reporter@^1.0.6, hardhat-gas-reporter@^1.0.8: eth-gas-reporter "^0.2.25" sha1 "^1.1.1" +hardhat-gas-reporter@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/hardhat-gas-reporter/-/hardhat-gas-reporter-2.1.1.tgz#fc91d437ee841ff32df1340025b0198201df92da" + integrity sha512-h3PAU7iDiPNqPA4i7GcKgnIZsN3UIdALM4gdJNoTtfmF9PGVne5nFZRNX1N7Y2Mx+znbBqeV1mS7o/i6T7NkTg== + dependencies: + "@ethersproject/abi" "^5.7.0" + "@ethersproject/bytes" "^5.7.0" + "@ethersproject/units" "^5.7.0" + "@solidity-parser/parser" "^0.18.0" + axios "^1.6.7" + brotli-wasm "^2.0.1" + chalk "4.1.2" + cli-table3 "^0.6.3" + ethereum-cryptography "^2.1.3" + glob "^10.3.10" + jsonschema "^1.4.1" + lodash "^4.17.21" + markdown-table "2.0.0" + sha1 "^1.1.1" + viem "2.7.14" + hardhat@^2.17.4, hardhat@^2.8.0: version "2.22.2" resolved "https://registry.yarnpkg.com/hardhat/-/hardhat-2.22.2.tgz#0cadd7ec93bf39bab09f81603e75bc5e92acea3d" @@ -2930,14 +3093,14 @@ hardhat@^2.17.4, hardhat@^2.8.0: uuid "^8.3.2" ws "^7.4.6" -hardhat@^2.22.1: - version "2.22.1" - resolved "https://registry.yarnpkg.com/hardhat/-/hardhat-2.22.1.tgz#2640ecc6ff655dea883a25a8b17f1e70e45e6756" - integrity sha512-cTWYIJc5jQ132XUI8oRI/TO9L6oavPoJRCTRU9sIjkVxvkxz0Axz0K83Z3BEdJTqBQ2W84ZRoTekti84kBwCjg== +hardhat@^2.22.3: + version "2.22.3" + resolved "https://registry.yarnpkg.com/hardhat/-/hardhat-2.22.3.tgz#50605daca6b29862397e446c42ec14c89430bec3" + integrity sha512-k8JV2ECWNchD6ahkg2BR5wKVxY0OiKot7fuxiIpRK0frRqyOljcR2vKwgWSLw6YIeDcNNA4xybj7Og7NSxr2hA== dependencies: "@ethersproject/abi" "^5.1.2" "@metamask/eth-sig-util" "^4.0.0" - "@nomicfoundation/edr" "^0.3.1" + "@nomicfoundation/edr" "^0.3.5" "@nomicfoundation/ethereumjs-common" "4.0.4" "@nomicfoundation/ethereumjs-tx" "5.0.4" "@nomicfoundation/ethereumjs-util" "9.0.4" @@ -3378,6 +3541,15 @@ isows@1.0.3: resolved "https://registry.yarnpkg.com/isows/-/isows-1.0.3.tgz#93c1cf0575daf56e7120bab5c8c448b0809d0d74" integrity sha512-2cKei4vlmg2cxEjm3wVSqn8pcoRF/LX/wpifuuNquFO4SQmPwarClT+SUCA2lt+l581tTeZIPIZuIDo2jWN1fg== +jackspeak@^2.3.6: + version "2.3.6" + resolved "https://registry.yarnpkg.com/jackspeak/-/jackspeak-2.3.6.tgz#647ecc472238aee4b06ac0e461acc21a8c505ca8" + integrity sha512-N3yCS/NegsOBokc8GAdM8UcmfsKiSS8cipheD/nivzr700H+nsMOxJjQnvwOcRYVuFkdH0wGUvW2WbXGmrZGbQ== + dependencies: + "@isaacs/cliui" "^8.0.2" + optionalDependencies: + "@pkgjs/parseargs" "^0.11.0" + js-cookie@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/js-cookie/-/js-cookie-2.2.1.tgz#69e106dc5d5806894562902aa5baec3744e9b2b8" @@ -3436,7 +3608,7 @@ jsonfile@^6.0.1: optionalDependencies: graceful-fs "^4.1.6" -jsonschema@^1.2.4: +jsonschema@^1.2.4, jsonschema@^1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/jsonschema/-/jsonschema-1.4.1.tgz#cc4c3f0077fb4542982973d8a083b6b34f482dab" integrity sha512-S6cATIPVv1z0IlxdN+zUk5EPjkGCdnhN4wVSBlvoUO1tOLJootbo9CquNJmbIh4yikWHiUedhRYrNPn1arpEmQ== @@ -3537,6 +3709,11 @@ loupe@^2.3.6: dependencies: get-func-name "^2.0.1" +lru-cache@^10.2.0: + version "10.2.0" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.2.0.tgz#0bd445ca57363465900f4d1f9bd8db343a4d95c3" + integrity sha512-2bIM8x+VAf6JT4bKAljS1qUWgMsqZRPGJS6FSahIMPVvctcNhyVp7AJu7quxOW9jwkryBReKZY5tY5JYv2n/7Q== + lru-cache@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" @@ -3554,6 +3731,13 @@ make-error@^1.1.1: resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== +markdown-table@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/markdown-table/-/markdown-table-2.0.0.tgz#194a90ced26d31fe753d8b9434430214c011865b" + integrity sha512-Ezda85ToJUBhM6WGaG6veasyym+Tbs3cMAw/ZhOPqXiYsr0jgocBV3j3nx+4lk47plLlIqjwuTm/ywVI+zjJ/A== + dependencies: + repeat-string "^1.0.0" + markdown-table@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/markdown-table/-/markdown-table-1.1.3.tgz#9fcb69bcfdb8717bfd0398c6ec2d93036ef8de60" @@ -3639,11 +3823,23 @@ minimatch@^5.0.1: dependencies: brace-expansion "^2.0.1" +minimatch@^9.0.1: + version "9.0.4" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.4.tgz#8e49c731d1749cbec05050ee5145147b32496a51" + integrity sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw== + dependencies: + brace-expansion "^2.0.1" + minimist@^1.2.5, minimist@^1.2.6, minimist@^1.2.7: version "1.2.8" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c" integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA== +"minipass@^5.0.0 || ^6.0.2 || ^7.0.0", minipass@^7.0.4: + version "7.0.4" + resolved "https://registry.yarnpkg.com/minipass/-/minipass-7.0.4.tgz#dbce03740f50a4786ba994c1fb908844d27b038c" + integrity sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ== + mkdirp@0.5.x: version "0.5.6" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.6.tgz#7def03d2432dcae4ba1d611445c48396062255f6" @@ -3942,11 +4138,24 @@ path-key@^2.0.1: resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" integrity sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw== +path-key@^3.1.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" + integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== + path-parse@^1.0.6, path-parse@^1.0.7: version "1.0.7" resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== +path-scurry@^1.10.2: + version "1.10.2" + resolved "https://registry.yarnpkg.com/path-scurry/-/path-scurry-1.10.2.tgz#8f6357eb1239d5fa1da8b9f70e9c080675458ba7" + integrity sha512-7xTavNy5RQXnsjANvVvMkEjvloOinkAjv/Z6Ildz9v2RinZ4SBKTWFOVRbaF8p0vpHnyjV/UwNDdKuUv6M5qcA== + dependencies: + lru-cache "^10.2.0" + minipass "^5.0.0 || ^6.0.2 || ^7.0.0" + path-type@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b" @@ -3988,11 +4197,25 @@ prelude-ls@~1.1.2: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" integrity sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w== +prettier-plugin-solidity@^1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/prettier-plugin-solidity/-/prettier-plugin-solidity-1.3.1.tgz#59944d3155b249f7f234dee29f433524b9a4abcf" + integrity sha512-MN4OP5I2gHAzHZG1wcuJl0FsLS3c4Cc5494bbg+6oQWBPuEamjwDvmGfFMZ6NFzsh3Efd9UUxeT7ImgjNH4ozA== + dependencies: + "@solidity-parser/parser" "^0.17.0" + semver "^7.5.4" + solidity-comments-extractor "^0.0.8" + prettier@^2.3.1: version "2.8.8" resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da" integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q== +prettier@^3.2.5: + version "3.2.5" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.2.5.tgz#e52bc3090586e824964a8813b09aba6233b28368" + integrity sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A== + process-nextick-args@~2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" @@ -4119,6 +4342,11 @@ regexp.prototype.flags@^1.5.2: es-errors "^1.3.0" set-function-name "^2.0.1" +repeat-string@^1.0.0: + version "1.6.1" + resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" + integrity sha512-PV0dzCYDNfRi1jCDbJzpW7jNNDRuCOG/jI5ctQcGKt/clZD+YcPS3yIlWuTJMmESC8aevCFmWJy5wjAFgNqN6w== + req-cwd@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/req-cwd/-/req-cwd-2.0.0.tgz#d4082b4d44598036640fb73ddea01ed53db49ebc" @@ -4291,7 +4519,7 @@ semver@^6.3.0: resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4" integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA== -semver@^7.3.4: +semver@^7.3.4, semver@^7.5.4: version "7.6.0" resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.0.tgz#1a46a4db4bffcccd97b743b5005c8325f23d4e2d" integrity sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg== @@ -4360,11 +4588,23 @@ shebang-command@^1.2.0: dependencies: shebang-regex "^1.0.0" +shebang-command@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea" + integrity sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA== + dependencies: + shebang-regex "^3.0.0" + shebang-regex@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" integrity sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ== +shebang-regex@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" + integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== + shelljs@^0.8.3: version "0.8.5" resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.8.5.tgz#de055408d8361bed66c669d2f000538ced8ee20c" @@ -4389,6 +4629,11 @@ signal-exit@^3.0.2: resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== +signal-exit@^4.0.1: + version "4.1.0" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-4.1.0.tgz#952188c1cbd546070e2dd20d0f41c0ae0530cb04" + integrity sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw== + sisteransi@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.5.tgz#134d681297756437cc05ca01370d3a7a571075ed" @@ -4435,10 +4680,15 @@ solidity-ast@^0.4.51: dependencies: array.prototype.findlast "^1.2.2" -solidity-coverage@^0.8.0: - version "0.8.11" - resolved "https://registry.yarnpkg.com/solidity-coverage/-/solidity-coverage-0.8.11.tgz#c95798f2c3e885c49dcfc9c43ee570d112214785" - integrity sha512-yy0Yk+olovBbXn0Me8BWULmmv7A69ZKkP5aTOJGOO8u61Tu2zS989erfjtFlUjDnfWtxRAVkd8BsQD704yLWHw== +solidity-comments-extractor@^0.0.8: + version "0.0.8" + resolved "https://registry.yarnpkg.com/solidity-comments-extractor/-/solidity-comments-extractor-0.0.8.tgz#f6e148ab0c49f30c1abcbecb8b8df01ed8e879f8" + integrity sha512-htM7Vn6LhHreR+EglVMd2s+sZhcXAirB1Zlyrv5zBuTxieCvjfnRpd7iZk75m/u6NOlEyQ94C6TWbBn2cY7w8g== + +solidity-coverage@^0.8.12: + version "0.8.12" + resolved "https://registry.yarnpkg.com/solidity-coverage/-/solidity-coverage-0.8.12.tgz#c4fa2f64eff8ada7a1387b235d6b5b0e6c6985ed" + integrity sha512-8cOB1PtjnjFRqOgwFiD8DaUsYJtVJ6+YdXQtSZDrLGf8cdhhh8xzTtGzVTGeBf15kTv0v7lYPJlV/az7zLEPJw== dependencies: "@ethersproject/abi" "^5.0.9" "@solidity-parser/parser" "^0.18.0" @@ -4450,7 +4700,7 @@ solidity-coverage@^0.8.0: global-modules "^2.0.0" globby "^10.0.1" jsonschema "^1.2.4" - lodash "^4.17.15" + lodash "^4.17.21" mocha "^10.2.0" node-emoji "^1.10.0" pify "^4.0.1" @@ -4509,6 +4759,15 @@ string-format@^2.0.0: resolved "https://registry.yarnpkg.com/string-format/-/string-format-2.0.0.tgz#f2df2e7097440d3b65de31b6d40d54c96eaffb9b" integrity sha512-bbEs3scLeYNXLecRRuk6uJxdXUSj6le/8rNPHChIJTn2V79aXVTR1EH2OH5zLKKoz0V02fOUKZZcw01pLUShZA== +"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3: + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + string-width@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" @@ -4517,14 +4776,14 @@ string-width@^2.1.1: is-fullwidth-code-point "^2.0.0" strip-ansi "^4.0.0" -string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3: - version "4.2.3" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" - integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== +string-width@^5.0.1, string-width@^5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794" + integrity sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA== dependencies: - emoji-regex "^8.0.0" - is-fullwidth-code-point "^3.0.0" - strip-ansi "^6.0.1" + eastasianwidth "^0.2.0" + emoji-regex "^9.2.2" + strip-ansi "^7.0.1" string.prototype.trim@^1.2.9: version "1.2.9" @@ -4568,6 +4827,13 @@ string_decoder@~1.1.1: dependencies: safe-buffer "~5.1.0" +"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + strip-ansi@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f" @@ -4575,12 +4841,12 @@ strip-ansi@^4.0.0: dependencies: ansi-regex "^3.0.0" -strip-ansi@^6.0.0, strip-ansi@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" - integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== +strip-ansi@^7.0.1: + version "7.1.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" + integrity sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ== dependencies: - ansi-regex "^5.0.1" + ansi-regex "^6.0.1" strip-hex-prefix@1.0.0: version "1.0.0" @@ -4957,10 +5223,24 @@ v8-compile-cache-lib@^3.0.1: resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz#6336e8d71965cb3d35a1bbb7868445a7c05264bf" integrity sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg== -viem@^2.7.6: - version "2.8.11" - resolved "https://registry.yarnpkg.com/viem/-/viem-2.8.11.tgz#447b90e202c263fc3e2f9df5a6477b8ef9929aaa" - integrity sha512-TMmHle2k6gZ0+LENMr5ulb/bKGMTaCFj5V3sbS52OGCnhxI4t46NDIk6RIIAiaPR4AkwZPf31LY5LORjpb02Tg== +viem@2.7.14: + version "2.7.14" + resolved "https://registry.yarnpkg.com/viem/-/viem-2.7.14.tgz#347d316cb5400f0b896b2205b1bc8073aa5e27e0" + integrity sha512-5b1KB1gXli02GOQHZIUsRluNUwssl2t4hqdFAzyWPwJ744N83jAOBOjOkrGz7K3qMIv9b0GQt3DoZIErSQTPkQ== + dependencies: + "@adraffy/ens-normalize" "1.10.0" + "@noble/curves" "1.2.0" + "@noble/hashes" "1.3.2" + "@scure/bip32" "1.3.2" + "@scure/bip39" "1.2.1" + abitype "1.0.0" + isows "1.0.3" + ws "8.13.0" + +viem@^2.9.21: + version "2.9.21" + resolved "https://registry.yarnpkg.com/viem/-/viem-2.9.21.tgz#a7dd3d4c827088e5336e5a6b35ec0283d2938595" + integrity sha512-8GtxPjPGpiN5cmr19zSX9mb1LX/eON3MPxxAd3QmyUFn69Rp566zlREOqE7zM35y5yX59fXwnz6O3X7e9+C9zg== dependencies: "@adraffy/ens-normalize" "1.10.0" "@noble/curves" "1.2.0" @@ -5027,6 +5307,13 @@ which@^1.1.1, which@^1.2.9, which@^1.3.1: dependencies: isexe "^2.0.0" +which@^2.0.1: + version "2.0.2" + resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" + integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== + dependencies: + isexe "^2.0.0" + widest-line@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/widest-line/-/widest-line-3.1.0.tgz#8292333bbf66cb45ff0de1603b136b7ae1496eca" @@ -5057,7 +5344,8 @@ workerpool@6.2.1: resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.1.tgz#46fc150c17d826b86a008e5a4508656777e9c343" integrity sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw== -wrap-ansi@^7.0.0: +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: + name wrap-ansi-cjs version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== @@ -5066,6 +5354,15 @@ wrap-ansi@^7.0.0: string-width "^4.1.0" strip-ansi "^6.0.0" +wrap-ansi@^8.1.0: + version "8.1.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214" + integrity sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ== + dependencies: + ansi-styles "^6.1.0" + string-width "^5.0.1" + strip-ansi "^7.0.1" + wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" From 8bb066f33f38cd8caf3e2ab8ac3faf16f86b011d Mon Sep 17 00:00:00 2001 From: srt0422 Date: Tue, 30 Apr 2024 13:21:08 -0700 Subject: [PATCH 19/21] Feature llm integration (#28) * init llm plugin * update model plugin initiation, add some testing, retrograde some syntax; more retro grading needed * test api call to lamma2 * fix response processing and tests for ollama ai * add modelName constant to test * add seamles ollama and model setup * add ollama client invokation for prompt api * switch api interface to openai interface * update .gitignore with dsstore files; replace ai library with openai --- .gitignore | 3 +- docker-compose-startup.sh | 14 ++ docker-compose.yaml | 17 +- proxy-router/Dockerfile | 1 + proxy-router/go.mod | 10 +- proxy-router/go.sum | 20 +- proxy-router/internal/aiengine/ai_engine.go | 35 +++- proxy-router/internal/apibus/api_bus.go | 5 +- .../internal/handlers/httphandlers/http.go | 38 +++- ui-core/package.json | 3 +- ui-core/src/plugins/llm/ollama/index.js | 25 ++- ui-core/src/plugins/llm/ollama/index.spec.js | 60 ++++-- ui-core/yarn.lock | 192 ++++++++++++------ 13 files changed, 309 insertions(+), 114 deletions(-) create mode 100755 docker-compose-startup.sh diff --git a/.gitignore b/.gitignore index 85df495e..ac5103da 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -*/**/node_modules \ No newline at end of file +*/**/node_modules +***/.DS_Store \ No newline at end of file diff --git a/docker-compose-startup.sh b/docker-compose-startup.sh new file mode 100755 index 00000000..db5dced3 --- /dev/null +++ b/docker-compose-startup.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +# Start the 'serve' command in the background +ollama serve & + +# Optionally, wait for 'serve' to be fully ready. Adjust the sleep as necessary. +sleep 10 # This is a simple way. Consider more reliable checking mechanisms. + +# Proceed with other commands +ollama pull llama2 +ollama run llama2 + +# Keep the container running by tailing a file (or another long-running command) +tail -f /dev/null \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index 8d63a415..7d89a1af 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,13 +1,26 @@ version: '3.8' services: + proxy-router: + build: + context: ./proxy-router + env_file: + - ./proxy-router/.env + ports: + - 8082:8082 + - 3333:3333 + depends_on: + - ollama ollama: image: ollama/ollama container_name: ollama + entrypoint: ["/bin/sh", "-c"] + command: ["/docker-compose-startup.sh"] volumes: - - ollama:/root/.ollama + - ollamaconfig:/root/.ollama + - ./docker-compose-startup.sh:/docker-compose-startup.sh ports: - "11434:11434" restart: unless-stopped volumes: - ollama: + ollamaconfig: diff --git a/proxy-router/Dockerfile b/proxy-router/Dockerfile index 81ee705e..35eb296b 100644 --- a/proxy-router/Dockerfile +++ b/proxy-router/Dockerfile @@ -14,6 +14,7 @@ WORKDIR /app COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ COPY --from=builder /app/bin/proxy-router /usr/bin/ COPY --from=builder /app/sh /bin/sh +COPY --from=builder /app/.env /app/.env SHELL ["/bin/sh", "-c"] EXPOSE 3333 8081 diff --git a/proxy-router/go.mod b/proxy-router/go.mod index de2a48b6..3338e8e6 100644 --- a/proxy-router/go.mod +++ b/proxy-router/go.mod @@ -5,17 +5,16 @@ go 1.19 require ( github.com/Lumerin-protocol/contracts-go v0.2.0 github.com/ethereum/go-ethereum v1.12.0 - github.com/gammazero/deque v0.2.1 github.com/gin-gonic/gin v1.9.1 github.com/go-playground/validator/v10 v10.14.0 github.com/joho/godotenv v1.5.1 github.com/omeid/uconfig v0.5.0 + github.com/sashabaranov/go-openai v1.21.0 github.com/shirou/gopsutil/v3 v3.23.11 github.com/stretchr/testify v1.8.4 - go.uber.org/atomic v1.11.0 go.uber.org/multierr v1.6.0 go.uber.org/zap v1.24.0 - golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 + golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 golang.org/x/sync v0.5.0 ) @@ -43,6 +42,8 @@ require ( github.com/leodido/go-urn v1.2.4 // indirect github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect github.com/mattn/go-isatty v0.0.19 // indirect + github.com/mattn/go-runewidth v0.0.14 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pelletier/go-toml/v2 v2.0.8 // indirect @@ -55,9 +56,10 @@ require ( github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.2.11 // indirect github.com/yusufpapurcu/wmi v1.2.3 // indirect + go.uber.org/atomic v1.11.0 // indirect golang.org/x/arch v0.3.0 // indirect golang.org/x/crypto v0.17.0 // indirect - golang.org/x/net v0.10.0 // indirect + golang.org/x/net v0.17.0 // indirect golang.org/x/sys v0.16.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/protobuf v1.30.0 // indirect diff --git a/proxy-router/go.sum b/proxy-router/go.sum index 53d6253e..99bb5a55 100644 --- a/proxy-router/go.sum +++ b/proxy-router/go.sum @@ -38,8 +38,6 @@ github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4 github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= -github.com/gammazero/deque v0.2.1 h1:qSdsbG6pgp6nL7A0+K/B7s12mcCY/5l5SIUpMOl+dC0= -github.com/gammazero/deque v0.2.1/go.mod h1:LFroj8x4cMYCukHJDbxFCkT+r9AndaJnFMuZDV34tuU= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI= github.com/getsentry/sentry-go v0.18.0 h1:MtBW5H9QgdcJabtZcuJG80BMOwaBpkRDZkxRkNC1sN0= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= @@ -104,9 +102,11 @@ github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2 github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= +github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU= +github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= -github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= @@ -127,9 +127,13 @@ github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= github.com/prometheus/common v0.39.0 h1:oOyhkDq05hPZKItWVBkJ6g6AtGxi+fy7F4JvUV8uhsI= github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= +github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= +github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= +github.com/sashabaranov/go-openai v1.21.0 h1:isAf3zPSD3VLd0pC2/2Q6ZyRK7jzPAaz+X3rjsviaYQ= +github.com/sashabaranov/go-openai v1.21.0/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg= github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU= github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil/v3 v3.23.11 h1:i3jP9NjCPUz7FiZKxlMnODZkdSIp2gnzfrvsu9CuWEQ= @@ -178,10 +182,10 @@ golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k= golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= -golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc= -golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= -golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 h1:m64FZMko/V45gv0bNmrNYoDEq8U5YUhetc9cBWKS1TQ= +golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63/go.mod h1:0v4NqG35kSWCMzLaMeX+IQrlSnVE/bqGSyC2cz/9Le8= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/proxy-router/internal/aiengine/ai_engine.go b/proxy-router/internal/aiengine/ai_engine.go index f21bb5c2..f37a39f7 100644 --- a/proxy-router/internal/aiengine/ai_engine.go +++ b/proxy-router/internal/aiengine/ai_engine.go @@ -1,6 +1,14 @@ package aiengine -import "context" +import ( + "context" + "net/http" + "os" + + "fmt" + + api "github.com/sashabaranov/go-openai" +) type AiEngine struct { } @@ -9,6 +17,27 @@ func NewAiEngine() *AiEngine { return &AiEngine{} } -func (aiEngine *AiEngine) Prompt(ctx context.Context) (string, error) { - return "Hello!", nil +func (aiEngine *AiEngine) Prompt(ctx context.Context, req interface{}) (*api.ChatCompletionResponse, error) { + request := req.(*api.ChatCompletionRequest) + client := api.NewClientWithConfig(api.ClientConfig{ + BaseURL: os.Getenv("OPENAI_BASE_URL"), + APIType: api.APITypeOpenAI, + HTTPClient: &http.Client{}, + }) + + fmt.Printf("client: %+v\r\n", *client) + fmt.Printf("base url: %+v\r\n", os.Getenv("OPENAI_BASE_URL")) + fmt.Printf("request: %+v\r\n", *request) + + response, err := client.CreateChatCompletion( + ctx, + *request, + ) + + if err != nil { + fmt.Printf("ChatCompletion error: %v\n", err) + return nil, err + } + return &response, nil } + diff --git a/proxy-router/internal/apibus/api_bus.go b/proxy-router/internal/apibus/api_bus.go index 2e40af3f..8b215c99 100644 --- a/proxy-router/internal/apibus/api_bus.go +++ b/proxy-router/internal/apibus/api_bus.go @@ -11,6 +11,7 @@ import ( "github.com/gin-gonic/gin" ) +//TODO: split implementations into separate client layer type ApiBus struct { rpcProxy *rpcproxy.RpcProxy aiEngine *aiengine.AiEngine @@ -47,8 +48,8 @@ func (apiBus *ApiBus) SendPrompt(ctx *gin.Context) (int, interface{}) { } // AiEngine -func (apiBus *ApiBus) Prompt(ctx context.Context) (string, error) { - return apiBus.aiEngine.Prompt(ctx) +func (apiBus *ApiBus) Prompt(ctx context.Context, req interface{}) (interface{}, error) { + return apiBus.aiEngine.Prompt(ctx, req) } // RpcProxy diff --git a/proxy-router/internal/handlers/httphandlers/http.go b/proxy-router/internal/handlers/httphandlers/http.go index 38fc8bcc..eadd6581 100644 --- a/proxy-router/internal/handlers/httphandlers/http.go +++ b/proxy-router/internal/handlers/httphandlers/http.go @@ -1,6 +1,10 @@ package httphandlers import ( + "errors" + "fmt" + "io" + "net/http" "encoding/hex" "fmt" "math/big" @@ -9,6 +13,13 @@ import ( constants "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal" "github.com/MorpheusAIs/Morpheus-Lumerin-Node/proxy-router/internal/internal/apibus" "github.com/gin-gonic/gin" + + openai "github.com/sashabaranov/go-openai" +) + +const ( + SUCCESS_STATUS = 200 + ERROR_STATUS = 500 ) type HTTPHandler struct{} @@ -18,15 +29,38 @@ func NewHTTPHandler(apiBus *apibus.ApiBus) *gin.Engine { r := gin.New() r.GET("/healthcheck", (func(ctx *gin.Context) { - ctx.JSON(constants.HTTP_STATUS_OK, apiBus.HealthCheck(ctx)) + ctx.JSON(SUCCESS_STATUS, apiBus.HealthCheck(ctx)) })) r.GET("/config", (func(ctx *gin.Context) { - ctx.JSON(constants.HTTP_STATUS_OK, apiBus.GetConfig(ctx)) + ctx.JSON(SUCCESS_STATUS, apiBus.GetConfig(ctx)) })) r.GET("/files", (func(ctx *gin.Context) { status, files := apiBus.GetFiles(ctx) ctx.JSON(status, files) })) + r.POST("/v1/chat/completions", (func(ctx *gin.Context) { + + var req *openai.ChatCompletionRequest + + err := ctx.ShouldBindJSON(&req) + switch { + case errors.Is(err, io.EOF): + ctx.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": "missing request body"}) + return + case err != nil: + ctx.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": err.Error()}) + return + } + + response, err := apiBus.Prompt(ctx, req) +fmt.Println("apibus prompt response: ",response) + if err != nil { + ctx.AbortWithError(ERROR_STATUS, err) + return + } + + ctx.JSON(SUCCESS_STATUS, response) + })) r.POST("/proxy/sessions/initiate", (func(ctx *gin.Context) { status, response := apiBus.InitiateSession(ctx) diff --git a/ui-core/package.json b/ui-core/package.json index d82870e4..3b23f485 100644 --- a/ui-core/package.json +++ b/ui-core/package.json @@ -52,6 +52,7 @@ "p-whilst": "2.0.0", "promise-all-props": "1.0.1", "safe-exchange-rate": "1.0.0", + "sinon": "^17.0.1", "socket.io-client": "2.1.1", "tough-cookie": "2.5.0", "web3": "^1.8.1", @@ -73,7 +74,7 @@ "eslint-plugin-promise": "5.1.0", "eslint-plugin-require-path-exists": "1.1.9", "husky": "6.0.0", - "mocha": "9.0.1", + "mocha": "9.2.2", "nock": "13.0.2", "npm-check": "5.9.2", "nyc": "15.1.0", diff --git a/ui-core/src/plugins/llm/ollama/index.js b/ui-core/src/plugins/llm/ollama/index.js index 8d4cdd8c..fe66806d 100644 --- a/ui-core/src/plugins/llm/ollama/index.js +++ b/ui-core/src/plugins/llm/ollama/index.js @@ -1,18 +1,18 @@ const axios = require('axios') -let modelName = 'llama2:70b', +let modelName = 'llama2:latest', modelUrl = '' -module.exports.init = function init(config) { +function init(config) { axios.defaults.baseURL = modelUrl = config.modelUrl modelName = config.modelName || modelName } -export const chat = { +const chat = { //TODO: map images between ollama api and openai api async createChatCompletion(chat, message) { try { - const response = await axios.post('/api/chat', { + const response = await axios.post('/v1/chat/completions', { model: modelName, messages: [ ...chat, @@ -22,15 +22,24 @@ export const chat = { }, ], }) - - return response.data + console.log("response.data: ", response.data) + return response.data.choices } catch (error) { console.log(error) throw error } }, } - -export default { +function jsonStringToArray(jsonString) { + // Split the input string by newlines to get an array of strings, each representing a JSON object + const lines = jsonString.trim().split('\n'); + // Map over each line, parsing it as JSON, and return the resulting array of objects + const jsonArray = lines.map(line => JSON.parse(line)); + + return jsonArray; +} +module.exports = { + init, chat, + modelName } diff --git a/ui-core/src/plugins/llm/ollama/index.spec.js b/ui-core/src/plugins/llm/ollama/index.spec.js index 14e8d06c..91fff83f 100644 --- a/ui-core/src/plugins/llm/ollama/index.spec.js +++ b/ui-core/src/plugins/llm/ollama/index.spec.js @@ -1,14 +1,21 @@ -import sinon from 'sinon' -import ollama from './index' -import { expect } from 'chai' +const sinon = require('sinon') +const axios = require('axios') +const ollama = require('./index') +const chai = require('chai') -describe('test ollama', () => { +const { expect } = chai +const modelName = 'llama2:latest' +const config = { + + modelUrl: 'http://localhost:8082', + modelName: modelName, +} +// TODO: fix other tests so they can be run reliably +describe.only('test ollama', function () { + this.timeout(15000) describe('api integration', () => { before('should init with config', () => { - ollama.init({ - modelUrl: 'http://localhost:11434', - modelName: null, - }); + ollama.init(config) expect(ollama.chat.createChatCompletion).is.a('function') }) @@ -17,26 +24,36 @@ describe('test ollama', () => { const chat = [] const message = 'how are you?' const response = await ollama.chat.createChatCompletion(chat, message) - expect(response.messages[0].content).toContain("I'm doing well") + + // concatenate the values of all of the content fields in all of the response elements + const contents = response.map(({ message }) => message.content) + + expect(contents.join('')).to.contain("I'm just an AI") }) }) - describe.skip('unit', () => { - let request = null, response = null; + describe('unit', () => { + let request = null, + response = null before(async () => { //mock axios request = sinon.stub(axios, 'post') response = { data: { - messages: [ + choices: [ { - role: 'bot', - content: "I'm doing well", + index: 0, + message: { + role: 'assistant', + content: `I'm just an AI assistant and do not have feelings or emotions, so I cannot answer the question "How are you?" as I am not capable of experiencing any emotional state. My purpose is to assist users like you by providing information and answering questions to the best of my abilities based on my training and knowledge. Is there anything else I can help you with?`, + }, + finish_reason: 'stop', }, ], }, } + request.returns(Promise.resolve(response)) }) @@ -44,24 +61,23 @@ describe('test ollama', () => { request.restore() }) - it('should throw error on invalid config', async () => { - await expect(() => ollama.init({})).toThrow() + it.skip('should throw error on invalid config', async () => { + await expect(() => ollama.init({})).throws() }) it('should set default model name', async () => { - ollama.init({ - modelUrl: 'http://localhost:11434', - }) + ollama.init(config) - expect(ollama.chat.createChatCompletion).toBeDefined() - expect(ollama.modelName).toEqual('llama2:70b') + expect(ollama.chat.createChatCompletion).is.a('function') + expect(ollama.modelName).to.equal('llama2:latest') }) it('should create chat completion', async () => { const chat = [] const message = 'how are you?' const response = await ollama.chat.createChatCompletion(chat, message) - expect(response.messages[0].content).toContain("I'm doing well") + + expect(response[0].message.content).to.contain("I'm just an AI") }) }) }) diff --git a/ui-core/yarn.lock b/ui-core/yarn.lock index ad585e12..1c6fdfa2 100644 --- a/ui-core/yarn.lock +++ b/ui-core/yarn.lock @@ -720,6 +720,41 @@ resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-4.6.0.tgz#3c7c9c46e678feefe7a2e5bb609d3dbd665ffb3f" integrity sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw== +"@sinonjs/commons@^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-2.0.0.tgz#fd4ca5b063554307e8327b4564bd56d3b73924a3" + integrity sha512-uLa0j859mMrg2slwQYdO/AkrOfmH+X6LTVmNTS9CqexuE2IvVORIkSpJLqePAbEnKJ77aMmCwr1NUZ57120Xcg== + dependencies: + type-detect "4.0.8" + +"@sinonjs/commons@^3.0.0": + version "3.0.1" + resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-3.0.1.tgz#1029357e44ca901a615585f6d27738dbc89084cd" + integrity sha512-K3mCHKQ9sVh8o1C9cxkwxaOmXoAMlDxC1mYyHrjqOWEcBjYr76t96zL2zlj5dUGZ3HSw240X1qgH3Mjf1yJWpQ== + dependencies: + type-detect "4.0.8" + +"@sinonjs/fake-timers@^11.2.2": + version "11.2.2" + resolved "https://registry.yarnpkg.com/@sinonjs/fake-timers/-/fake-timers-11.2.2.tgz#50063cc3574f4a27bd8453180a04171c85cc9699" + integrity sha512-G2piCSxQ7oWOxwGSAyFHfPIsyeJGXYtc6mFbnFA+kRXkiEnTl8c/8jul2S329iFBnDI9HGoeWWAZvuvOkZccgw== + dependencies: + "@sinonjs/commons" "^3.0.0" + +"@sinonjs/samsam@^8.0.0": + version "8.0.0" + resolved "https://registry.yarnpkg.com/@sinonjs/samsam/-/samsam-8.0.0.tgz#0d488c91efb3fa1442e26abea81759dfc8b5ac60" + integrity sha512-Bp8KUVlLp8ibJZrnvq2foVhP0IVX2CIprMJPK0vqGqgrDa0OHVKeZyBykqskkrdxV6yKBPmGasO8LVjAKR3Gew== + dependencies: + "@sinonjs/commons" "^2.0.0" + lodash.get "^4.4.2" + type-detect "^4.0.8" + +"@sinonjs/text-encoding@^0.7.2": + version "0.7.2" + resolved "https://registry.yarnpkg.com/@sinonjs/text-encoding/-/text-encoding-0.7.2.tgz#5981a8db18b56ba38ef0efb7d995b12aa7b51918" + integrity sha512-sXXKG+uL9IrKqViTtao2Ws6dy0znu9sOaP1di/jKGW1M6VssO8vlpXCQcpZ+jisQ1tTFAC5Jo/EOzFbggBagFQ== + "@szmarczak/http-timer@^4.0.5": version "4.0.6" resolved "https://registry.yarnpkg.com/@szmarczak/http-timer/-/http-timer-4.0.6.tgz#b4a914bb62e7c272d4e5989fe4440f812ab1d807" @@ -980,7 +1015,7 @@ ansi-styles@^4.0.0, ansi-styles@^4.1.0: dependencies: color-convert "^2.0.1" -anymatch@~3.1.1: +anymatch@~3.1.2: version "3.1.3" resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.3.tgz#790c58b19ba1720a84205b57c618d5ad8524973e" integrity sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw== @@ -1654,20 +1689,20 @@ cheerio@^1.0.0-rc.12: parse5 "^7.0.0" parse5-htmlparser2-tree-adapter "^7.0.0" -chokidar@3.5.1: - version "3.5.1" - resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.1.tgz#ee9ce7bbebd2b79f49f304799d5468e31e14e68a" - integrity sha512-9+s+Od+W0VJJzawDma/gvBNQqkTiqYTWLuZoyAsivsI4AaWTCzHG06/TMjsf1cYe9Cb97UCEhjz7HvnPk2p/tw== +chokidar@3.5.3: + version "3.5.3" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd" + integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== dependencies: - anymatch "~3.1.1" + anymatch "~3.1.2" braces "~3.0.2" - glob-parent "~5.1.0" + glob-parent "~5.1.2" is-binary-path "~2.1.0" is-glob "~4.0.1" normalize-path "~3.0.0" - readdirp "~3.5.0" + readdirp "~3.6.0" optionalDependencies: - fsevents "~2.3.1" + fsevents "~2.3.2" chownr@^1.1.4: version "1.1.4" @@ -2094,10 +2129,10 @@ debug@4.1.1: dependencies: ms "^2.1.1" -debug@4.3.1: - version "4.3.1" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.1.tgz#f0d229c505e0c6d8c49ac553d1b13dc183f6b2ee" - integrity sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ== +debug@4.3.3: + version "4.3.3" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.3.tgz#04266e0b70a98d4462e6e288e38259213332b664" + integrity sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q== dependencies: ms "2.1.2" @@ -2278,6 +2313,11 @@ diff@5.0.0: resolved "https://registry.yarnpkg.com/diff/-/diff-5.0.0.tgz#7ed6ad76d859d030787ec35855f5b1daf31d852b" integrity sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w== +diff@^5.1.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-5.2.0.tgz#26ded047cd1179b78b9537d5ef725503ce1ae531" + integrity sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A== + dir-glob@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-3.0.1.tgz#56dbf73d992a4a93ba1584f4534063fd2e41717f" @@ -3505,7 +3545,7 @@ fs.realpath@^1.0.0: resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== -fsevents@~2.3.1: +fsevents@~2.3.2: version "2.3.3" resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6" integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== @@ -3614,17 +3654,17 @@ giturl@^1.0.0: resolved "https://registry.yarnpkg.com/giturl/-/giturl-1.0.3.tgz#27f9d1f251d138eb2a5a56cc9dd8512b0fc0bbc6" integrity sha512-qVDEXufVtYUzYqI5hoDUONh9GCEPi0n+e35KNDafdsNt9fPxB0nvFW/kFiw7W42wkg8TUyhBqb+t24yyaoc87A== -glob-parent@^5.1.2, glob-parent@~5.1.0: +glob-parent@^5.1.2, glob-parent@~5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== dependencies: is-glob "^4.0.1" -glob@7.1.7: - version "7.1.7" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.7.tgz#3b193e9233f01d42d0b3f78294bbeeb418f94a90" - integrity sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ== +glob@7.2.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023" + integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q== dependencies: fs.realpath "^1.0.0" inflight "^1.0.4" @@ -4647,6 +4687,11 @@ jsprim@^1.2.2: json-schema "0.4.0" verror "1.10.0" +just-extend@^6.2.0: + version "6.2.0" + resolved "https://registry.yarnpkg.com/just-extend/-/just-extend-6.2.0.tgz#b816abfb3d67ee860482e7401564672558163947" + integrity sha512-cYofQu2Xpom82S6qD778jBDpwvvy39s1l/hrYij2u9AMdQcGRpaBu6kY4mVhuno5kJVi1DAz4aiphA2WI1/OAw== + keccak@^3.0.0: version "3.0.4" resolved "https://registry.yarnpkg.com/keccak/-/keccak-3.0.4.tgz#edc09b89e633c0549da444432ecf062ffadee86d" @@ -4744,6 +4789,11 @@ lodash.flattendeep@^4.4.0: resolved "https://registry.yarnpkg.com/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz#fb030917f86a3134e5bc9bec0d69e0013ddfedb2" integrity sha512-uHaJFihxmJcEX3kT4I23ABqKKalJ/zDrDg0lsFtc1h+3uw49SIJ5beyhx5ExVRti3AvKoOJngIj7xz3oylPdWQ== +lodash.get@^4.4.2: + version "4.4.2" + resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99" + integrity sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ== + lodash.merge@^4.6.2: version "4.6.2" resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" @@ -4962,10 +5012,10 @@ minimalistic-crypto-utils@^1.0.1: dependencies: brace-expansion "^1.1.7" -minimatch@3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" - integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== +minimatch@4.2.1: + version "4.2.1" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-4.2.1.tgz#40d9d511a46bdc4e563c22c3080cde9c0d8299b4" + integrity sha512-9Uq1ChtSZO+Mxa/CL1eGizn2vRn3MlLgzhT0Iz8zaY8NdvxvB0d5QdPFmCKf7JKA9Lerx5vRrnwO03jsSfGG9g== dependencies: brace-expansion "^1.1.7" @@ -5008,33 +5058,32 @@ mkdirp@^0.5.1, mkdirp@^0.5.5: dependencies: minimist "^1.2.6" -mocha@9.0.1: - version "9.0.1" - resolved "https://registry.yarnpkg.com/mocha/-/mocha-9.0.1.tgz#01e66b7af0012330c0a38c4b6eaa6d92b8a81bf9" - integrity sha512-9zwsavlRO+5csZu6iRtl3GHImAbhERoDsZwdRkdJ/bE+eVplmoxNKE901ZJ9LdSchYBjSCPbjKc5XvcAri2ylw== +mocha@9.2.2: + version "9.2.2" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-9.2.2.tgz#d70db46bdb93ca57402c809333e5a84977a88fb9" + integrity sha512-L6XC3EdwT6YrIk0yXpavvLkn8h+EU+Y5UcCHKECyMbdUIxyMuZj4bX4U9e1nvnvUUvQVsV2VHQr5zLdcUkhW/g== dependencies: "@ungap/promise-all-settled" "1.1.2" ansi-colors "4.1.1" browser-stdout "1.3.1" - chokidar "3.5.1" - debug "4.3.1" + chokidar "3.5.3" + debug "4.3.3" diff "5.0.0" escape-string-regexp "4.0.0" find-up "5.0.0" - glob "7.1.7" + glob "7.2.0" growl "1.10.5" he "1.2.0" js-yaml "4.1.0" log-symbols "4.1.0" - minimatch "3.0.4" + minimatch "4.2.1" ms "2.1.3" - nanoid "3.1.23" - serialize-javascript "5.0.1" + nanoid "3.3.1" + serialize-javascript "6.0.0" strip-json-comments "3.1.1" supports-color "8.1.1" which "2.0.2" - wide-align "1.1.3" - workerpool "6.1.4" + workerpool "6.2.0" yargs "16.2.0" yargs-parser "20.2.4" yargs-unparser "2.0.0" @@ -5114,10 +5163,10 @@ nano-json-stream-parser@^0.1.2: resolved "https://registry.yarnpkg.com/nano-json-stream-parser/-/nano-json-stream-parser-0.1.2.tgz#0cc8f6d0e2b622b479c40d499c46d64b755c6f5f" integrity sha512-9MqxMH/BSJC7dnLsEMPyfN5Dvoo49IsPFYMcHw3Bcfc2kN0lpHRBSzlMSVx4HGyJ7s9B31CyBTVehWJoQ8Ctew== -nanoid@3.1.23: - version "3.1.23" - resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.1.23.tgz#f744086ce7c2bc47ee0a8472574d5c78e4183a81" - integrity sha512-FiB0kzdP0FFVGDKlRLEQ1BgDzU87dy5NnzjeW9YZNt+/c3+q82EQDUwniSAUxp/F0gFNI1ZhKU1FqYsMuqZVnw== +nanoid@3.3.1: + version "3.3.1" + resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.1.tgz#6347a18cac88af88f58af0b3594b723d5e99bb35" + integrity sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw== natural-compare@^1.4.0: version "1.4.0" @@ -5134,6 +5183,17 @@ next-tick@^1.1.0: resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.1.0.tgz#1836ee30ad56d67ef281b22bd199f709449b35eb" integrity sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ== +nise@^5.1.5: + version "5.1.9" + resolved "https://registry.yarnpkg.com/nise/-/nise-5.1.9.tgz#0cb73b5e4499d738231a473cd89bd8afbb618139" + integrity sha512-qOnoujW4SV6e40dYxJOb3uvuoPHtmLzIk4TFo+j0jPJoC+5Z9xja5qH5JZobEPsa8+YYphMrOSwnrshEhG2qww== + dependencies: + "@sinonjs/commons" "^3.0.0" + "@sinonjs/fake-timers" "^11.2.2" + "@sinonjs/text-encoding" "^0.7.2" + just-extend "^6.2.0" + path-to-regexp "^6.2.1" + nock@13.0.2: version "13.0.2" resolved "https://registry.yarnpkg.com/nock/-/nock-13.0.2.tgz#3e50f88348edbb90cce1bbbf0a3ea6a068993983" @@ -5697,6 +5757,11 @@ path-to-regexp@0.1.7: resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c" integrity sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ== +path-to-regexp@^6.2.1: + version "6.2.1" + resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-6.2.1.tgz#d54934d6798eb9e5ef14e7af7962c945906918e5" + integrity sha512-JLyh7xT1kizaEvcaXOQwOc2/Yhw6KZOvPf1S8401UyLk86CU79LN3vl7ztXGm/pZ+YjoyAJ4rxmHwbkBXJX+yw== + path-type@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/path-type/-/path-type-1.1.0.tgz#59c44f7ee491da704da415da5a4070ba4f8fe441" @@ -6057,10 +6122,10 @@ readable-stream@^3.6.0: string_decoder "^1.1.1" util-deprecate "^1.0.1" -readdirp@~3.5.0: - version "3.5.0" - resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.5.0.tgz#9ba74c019b15d365278d2e91bb8c48d7b4d42c9e" - integrity sha512-cMhu7c/8rdhkHXWsY+osBhfSy0JikwpHK/5+imo+LpeasTF8ouErHrlYkwT0++njiyuDvc7OFY5T3ukvZ8qmFQ== +readdirp@~3.6.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" + integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA== dependencies: picomatch "^2.2.1" @@ -6417,10 +6482,10 @@ send@0.18.0: range-parser "~1.2.1" statuses "2.0.1" -serialize-javascript@5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-5.0.1.tgz#7886ec848049a462467a97d3d918ebb2aaf934f4" - integrity sha512-SaaNal9imEO737H2c05Og0/8LUXG7EnsZyMa8MzkmuHoELfT6txuj0cMqRj6zfPKnmQ1yasR4PCJc8x+M4JSPA== +serialize-javascript@6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.0.tgz#efae5d88f45d7924141da8b5c3a7a7e663fefeb8" + integrity sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag== dependencies: randombytes "^2.1.0" @@ -6548,6 +6613,18 @@ simple-get@^2.7.0: once "^1.3.1" simple-concat "^1.0.0" +sinon@^17.0.1: + version "17.0.1" + resolved "https://registry.yarnpkg.com/sinon/-/sinon-17.0.1.tgz#26b8ef719261bf8df43f925924cccc96748e407a" + integrity sha512-wmwE19Lie0MLT+ZYNpDymasPHUKTaZHUH/pKEubRXIzySv9Atnlw+BUMGCzWgV7b7wO+Hw6f1TEOr0IUnmU8/g== + dependencies: + "@sinonjs/commons" "^3.0.0" + "@sinonjs/fake-timers" "^11.2.2" + "@sinonjs/samsam" "^8.0.0" + diff "^5.1.0" + nise "^5.1.5" + supports-color "^7.2.0" + slash@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55" @@ -6683,7 +6760,7 @@ string-width@^1.0.1: is-fullwidth-code-point "^1.0.0" strip-ansi "^3.0.0" -"string-width@^1.0.2 || 2", string-width@^2.0.0, string-width@^2.1.1: +string-width@^2.0.0, string-width@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" integrity sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw== @@ -6837,7 +6914,7 @@ supports-color@^5.3.0: dependencies: has-flag "^3.0.0" -supports-color@^7.1.0: +supports-color@^7.1.0, supports-color@^7.2.0: version "7.2.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== @@ -7007,7 +7084,7 @@ type-check@^0.4.0, type-check@~0.4.0: dependencies: prelude-ls "^1.2.1" -type-detect@^4.0.0, type-detect@^4.0.5: +type-detect@4.0.8, type-detect@^4.0.0, type-detect@^4.0.5, type-detect@^4.0.8: version "4.0.8" resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g== @@ -7602,13 +7679,6 @@ which@^1.2.14, which@^1.2.8, which@^1.2.9: dependencies: isexe "^2.0.0" -wide-align@1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.3.tgz#ae074e6bdc0c14a431e804e624549c633b000457" - integrity sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA== - dependencies: - string-width "^1.0.2 || 2" - widest-line@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/widest-line/-/widest-line-2.0.1.tgz#7438764730ec7ef4381ce4df82fb98a53142a3fc" @@ -7616,10 +7686,10 @@ widest-line@^2.0.0: dependencies: string-width "^2.1.1" -workerpool@6.1.4: - version "6.1.4" - resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.1.4.tgz#6a972b6df82e38d50248ee2820aa98e2d0ad3090" - integrity sha512-jGWPzsUqzkow8HoAvqaPWTUPCrlPJaJ5tY8Iz7n1uCz3tTp6s3CDG0FF1NsX42WNlkRSW6Mr+CDZGnNoSsKa7g== +workerpool@6.2.0: + version "6.2.0" + resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.0.tgz#827d93c9ba23ee2019c3ffaff5c27fccea289e8b" + integrity sha512-Rsk5qQHJ9eowMH28Jwhe8HEbmdYDX4lwoMWshiCXugjtHqMD9ZbiqSDLxcsfdqsETPzVUtX5s1Z5kStiIM6l4A== wrap-ansi@^5.1.0: version "5.1.0" From 5009829af7d94c6fb6fed8eed93972cea25f13a8 Mon Sep 17 00:00:00 2001 From: srt0422 Date: Tue, 30 Apr 2024 13:21:41 -0700 Subject: [PATCH 20/21] Feature/chat page (#38) * Added intermediate step * Added chat tab with stabs --------- Co-authored-by: bohdan.konorin --- ui-desktop/package.json | 2 + ui-desktop/public/main/client/index.js | 76 +++---- ui-desktop/src/main/src/client/index.js | 64 +++--- .../main/src/client/subscriptions/index.js | 1 - .../src/client/subscriptions/single-core.js | 1 - ui-desktop/src/renderer/src/client/index.jsx | 2 +- .../src/renderer/src/components/Login.tsx | 6 +- .../src/renderer/src/components/Router.tsx | 8 +- .../renderer/src/components/agents/Agents.tsx | 10 + .../src/renderer/src/components/chat/Chat.css | 14 ++ .../src/components/chat/Chat.styles.tsx | 152 ++++++++++++++ .../src/renderer/src/components/chat/Chat.tsx | 194 ++++++++++++++++++ .../src/components/chat/ChatHistory.tsx | 28 +++ .../src/components/common/LayoutHeader.jsx | 4 +- .../components/common/TextInput.styles.jsx | 2 +- .../contracts-list/ContractsList.styles.jsx | 7 + .../contracts/contracts-list/Filter.jsx | 2 +- .../contracts/contracts-list/Header.jsx | 2 +- .../components/dashboard/tx-list/TxList.jsx | 2 +- .../renderer/src/components/models/Models.tsx | 12 ++ .../src/components/models/ModelsTable.tsx | 131 ++++++++++++ .../src/components/sidebar/PrimaryNav.jsx | 43 ++-- .../src/components/sidebar/SecondaryNav.jsx | 2 +- .../src/components/sidebar/Sidebar.jsx | 8 +- .../src/enums/contractCloseOutType.enum.jsx | 6 +- .../renderer/src/enums/contractState.enum.jsx | 6 +- ui-desktop/src/renderer/src/enums/index.jsx | 2 +- ui-desktop/yarn.lock | 35 +++- 28 files changed, 696 insertions(+), 126 deletions(-) create mode 100644 ui-desktop/src/renderer/src/components/agents/Agents.tsx create mode 100644 ui-desktop/src/renderer/src/components/chat/Chat.css create mode 100644 ui-desktop/src/renderer/src/components/chat/Chat.styles.tsx create mode 100644 ui-desktop/src/renderer/src/components/chat/Chat.tsx create mode 100644 ui-desktop/src/renderer/src/components/chat/ChatHistory.tsx create mode 100644 ui-desktop/src/renderer/src/components/models/Models.tsx create mode 100644 ui-desktop/src/renderer/src/components/models/ModelsTable.tsx diff --git a/ui-desktop/package.json b/ui-desktop/package.json index 6a5ed777..f9b94403 100644 --- a/ui-desktop/package.json +++ b/ui-desktop/package.json @@ -50,10 +50,12 @@ "react-hint": "^3.2.1", "react-hook-form": "^7.51.0", "react-modal": "^3.16.1", + "react-modern-drawer": "^1.2.2", "react-motion": "^0.5.2", "react-redux": "^9.1.0", "react-router-dom": "4.3.1", "react-select": "^5.8.0", + "react-textarea-autosize": "^8.5.3", "react-virtualized": "9.20.1", "redux": "4.2.0", "redux-actions": "2.3.0", diff --git a/ui-desktop/public/main/client/index.js b/ui-desktop/public/main/client/index.js index ace5f911..570bf735 100644 --- a/ui-desktop/public/main/client/index.js +++ b/ui-desktop/public/main/client/index.js @@ -110,44 +110,44 @@ function startCore({ chain, core, config: coreConfig }, webContent) { return false; }; - emitter.on("open-proxy-router", async ({ password }) => { - const proxyRouterUserConfig = settings.getProxyRouterConfig(); - if (!proxyRouterUserConfig.runWithoutProxyRouter) { - const { address, privateKey } = await getAddressAndPrivateKey( - { password }, - { api } - ); - - send("proxy-router-type-changed", { - isLocal: true, - }); - - const config = { - privateKey, - walletAddress: address, - ...coreConfig.chain, - ...proxyRouterUserConfig, - }; - - const isProxyHealth = await isProxyRouterHealthy( - api, - config.localProxyRouterUrl - ); - const shouldRestartProxy = shouldRestartProxyRouterAfterWalletUpdate(); - if (!isProxyHealth || shouldRestartProxy) { - logger.debug("Seller is not healhy, restart..."); - await proxyRouterApi.kill(config.proxyPort).catch(logger.error); - runProxyRouter(config); - } - - refreshProxyRouterConnection( - { - proxyNodeUrl: config.localProxyRouterUrl, - }, - { api } - ); - } - }); + // emitter.on("open-proxy-router", async ({ password }) => { + // const proxyRouterUserConfig = settings.getProxyRouterConfig(); + // if (!proxyRouterUserConfig.runWithoutProxyRouter) { + // const { address, privateKey } = await getAddressAndPrivateKey( + // { password }, + // { api } + // ); + + // send("proxy-router-type-changed", { + // isLocal: true, + // }); + + // const config = { + // privateKey, + // walletAddress: address, + // ...coreConfig.chain, + // ...proxyRouterUserConfig, + // }; + + // const isProxyHealth = await isProxyRouterHealthy( + // api, + // config.localProxyRouterUrl + // ); + // const shouldRestartProxy = shouldRestartProxyRouterAfterWalletUpdate(); + // if (!isProxyHealth || shouldRestartProxy) { + // logger.debug("Seller is not healhy, restart..."); + // await proxyRouterApi.kill(config.proxyPort).catch(logger.error); + // runProxyRouter(config); + // } + + // refreshProxyRouterConnection( + // { + // proxyNodeUrl: config.localProxyRouterUrl, + // }, + // { api } + // ); + // } + // }); return { emitter, diff --git a/ui-desktop/src/main/src/client/index.js b/ui-desktop/src/main/src/client/index.js index b4fe47d8..12f6fbf2 100644 --- a/ui-desktop/src/main/src/client/index.js +++ b/ui-desktop/src/main/src/client/index.js @@ -104,38 +104,38 @@ export function startCore({ chain, core, config: coreConfig }, webContent) { return false } - emitter.on('open-proxy-router', async ({ password }) => { - const proxyRouterUserConfig = settings.getProxyRouterConfig() - if (!proxyRouterUserConfig.runWithoutProxyRouter) { - const { address, privateKey } = await getAddressAndPrivateKey({ password }, { api }) - - send('proxy-router-type-changed', { - isLocal: true - }) - - const config = { - privateKey, - walletAddress: address, - ...coreConfig.chain, - ...proxyRouterUserConfig - } - - const isProxyHealth = await isProxyRouterHealthy(api, config.localProxyRouterUrl) - const shouldRestartProxy = shouldRestartProxyRouterAfterWalletUpdate() - if (!isProxyHealth || shouldRestartProxy) { - logger.debug('Seller is not healhy, restart...') - await proxyRouterApi.kill(config.proxyPort).catch(logger.error) - runProxyRouter(config) - } - - refreshProxyRouterConnection( - { - proxyNodeUrl: config.localProxyRouterUrl - }, - { api } - ) - } - }) + // emitter.on('open-proxy-router', async ({ password }) => { + // const proxyRouterUserConfig = settings.getProxyRouterConfig() + // if (!proxyRouterUserConfig.runWithoutProxyRouter) { + // const { address, privateKey } = await getAddressAndPrivateKey({ password }, { api }) + + // send('proxy-router-type-changed', { + // isLocal: true + // }) + + // const config = { + // privateKey, + // walletAddress: address, + // ...coreConfig.chain, + // ...proxyRouterUserConfig + // } + + // const isProxyHealth = await isProxyRouterHealthy(api, config.localProxyRouterUrl) + // const shouldRestartProxy = shouldRestartProxyRouterAfterWalletUpdate() + // if (!isProxyHealth || shouldRestartProxy) { + // logger.debug('Seller is not healhy, restart...') + // await proxyRouterApi.kill(config.proxyPort).catch(logger.error) + // runProxyRouter(config) + // } + + // refreshProxyRouterConnection( + // { + // proxyNodeUrl: config.localProxyRouterUrl + // }, + // { api } + // ) + // } + // }) return { emitter, diff --git a/ui-desktop/src/main/src/client/subscriptions/index.js b/ui-desktop/src/main/src/client/subscriptions/index.js index 63004687..89dc424b 100644 --- a/ui-desktop/src/main/src/client/subscriptions/index.js +++ b/ui-desktop/src/main/src/client/subscriptions/index.js @@ -4,7 +4,6 @@ import { subscribeSingleCore, unsubscribeSingleCore } from './single-core' import { subscribeWithoutCore, unsubscribeWithoutCore } from './no-core' function subscribe(core) { - console.log("SUBSCRIBING"); subscribeSingleCore(core) subscribeWithoutCore() } diff --git a/ui-desktop/src/main/src/client/subscriptions/single-core.js b/ui-desktop/src/main/src/client/subscriptions/single-core.js index b0fab862..57642872 100644 --- a/ui-desktop/src/main/src/client/subscriptions/single-core.js +++ b/ui-desktop/src/main/src/client/subscriptions/single-core.js @@ -42,7 +42,6 @@ export function subscribeSingleCore(core) { Object.keys(listeners).forEach(function (key) { coreListeners[core.chain][key] = withCore(core)(listeners[key]) }) - console.log("coreListeners", coreListeners); utils.subscribeTo(coreListeners[core.chain], core.chain) } diff --git a/ui-desktop/src/renderer/src/client/index.jsx b/ui-desktop/src/renderer/src/client/index.jsx index 3da2c249..e0881d0d 100644 --- a/ui-desktop/src/renderer/src/client/index.jsx +++ b/ui-desktop/src/renderer/src/client/index.jsx @@ -50,7 +50,7 @@ const createClient = function (createStore) { const onTermsLinkClick = () => window.openLink('https://github.com/Lumerin-protocol/WalletDesktop/blob/main/LICENSE') - const onHelpLinkClick = () => window.openLink('https://lumerin.gitbook.io') + const onHelpLinkClick = () => window.openLink('https://mor.org/fair-launch') const onLinkClick = (url) => window.openLink(url) diff --git a/ui-desktop/src/renderer/src/components/Login.tsx b/ui-desktop/src/renderer/src/components/Login.tsx index bff3f89a..fcff5154 100644 --- a/ui-desktop/src/renderer/src/components/Login.tsx +++ b/ui-desktop/src/renderer/src/components/Login.tsx @@ -9,9 +9,9 @@ const LoginBtn = styled(BaseBtn)` font-size: 1.5rem; font-weight: bold; height: 40px; - border-radius: 5px; - background-color: ${(p) => p.theme.colors.primary}; - color: ${(p) => p.theme.colors.light}; + border-radius: 2px; + background-color: ${(p) => p.theme.colors.morMain}; + color: black; @media (min-width: 1040px) { margin-left: 0; diff --git a/ui-desktop/src/renderer/src/components/Router.tsx b/ui-desktop/src/renderer/src/components/Router.tsx index 52858493..7d170053 100644 --- a/ui-desktop/src/renderer/src/components/Router.tsx +++ b/ui-desktop/src/renderer/src/components/Router.tsx @@ -6,6 +6,9 @@ import OfflineWarning from './OfflineWarning' import Dashboard from './dashboard/Dashboard' import Sidebar from './sidebar/Sidebar' import Marketplace from './contracts/Marketplace' +import Chat from './chat/Chat'; +import { Models } from './models/Models' +import { Agents } from './agents/Agents' // import Sockets from './sockets/Sockets' // import Reports from './reports/Reports' @@ -57,6 +60,9 @@ export const Layout = () => ( } /> + + + {/* */} @@ -67,7 +73,7 @@ export const Layout = () => ( -*/} + */} {/* */} diff --git a/ui-desktop/src/renderer/src/components/agents/Agents.tsx b/ui-desktop/src/renderer/src/components/agents/Agents.tsx new file mode 100644 index 00000000..ab66b73d --- /dev/null +++ b/ui-desktop/src/renderer/src/components/agents/Agents.tsx @@ -0,0 +1,10 @@ +import React from "react"; +import { LayoutHeader } from '../common/LayoutHeader' +import { View } from '../common/View' + +export const Agents = () => { + return ( + + + ) +} \ No newline at end of file diff --git a/ui-desktop/src/renderer/src/components/chat/Chat.css b/ui-desktop/src/renderer/src/components/chat/Chat.css new file mode 100644 index 00000000..49bf83b3 --- /dev/null +++ b/ui-desktop/src/renderer/src/components/chat/Chat.css @@ -0,0 +1,14 @@ +.history-drawer { + width: 25%!important; + min-width: 250px!important; + border-left: 1px solid rgba(255, 255, 255, 0.16)!important; + padding: 2.4rem!important; + + background-image: url("src/main.jpg")!important; + background-position: right!important; + background-repeat: no-repeat!important; + -webkit-background-size: cover!important; + -moz-background-size: cover!important; + -o-background-size: cover!important; + background-size: cover!important; +} \ No newline at end of file diff --git a/ui-desktop/src/renderer/src/components/chat/Chat.styles.tsx b/ui-desktop/src/renderer/src/components/chat/Chat.styles.tsx new file mode 100644 index 00000000..3b14d0a1 --- /dev/null +++ b/ui-desktop/src/renderer/src/components/chat/Chat.styles.tsx @@ -0,0 +1,152 @@ +import styled from 'styled-components'; +import TextareaAutosize from 'react-textarea-autosize'; + +export const View = styled.div` + height: 100vh; + max-width: 100%; + min-width: 600px; + position: relative; + padding-top: 2rem; +`; + +export const Container = styled.div` + max-width: 1120px; + height: calc(100% - 160px); + justify-content: space-between; + margin: 0 auto; + display: flex; + flex-direction: column; + padding: 20px 2.4rem 0; +` + +export const ChatBlock = styled.div` + width: 100%; + height: 100%; + overflow-y: auto; + margin-bottom: 20px; +` + +export const Control = styled.div` + height: fit-content; + position: relative; + display: flex; + flex-direction: column; + + textarea { + resize: none; + padding-right: 6rem; + } +` + +export const SendBtn = styled.div` + position: absolute; + right: 16px; + border-radius: 5px; + width: 26px; + height: 26px; + text-align: center; + bottom: 12px; + background: ${p => p.theme.colors.morMain}; +` + +export const Avatar = styled.div` + height: 36px; + min-width: 36px; + width: 36px; + display: flex; + justify-content: center; + align-items: center; + /* border: 1px solid; */ + background: ${p => p.color}; + font-weight: 400; + font-size: 15px; + border-radius: 4px; +` + +export const AvatarHeader = styled.div` + color: ${p => p.theme.colors.morMain} + font-weight: 900; + padding: 0 8px; + font-size: 18px; +` + +export const MessageBody = styled.div` + font-weight: 400; + padding: 0 8px; + font-size: 18px; +` + +export const ChatTitleContainer = styled.div` + color: ${p => p.theme.colors.morMain} + font-weight: 900; + padding: 0 8px; + font-size: 18px; + display: flex; + align-items: center; + justify-content: space-between; + padding: 12px 24px; + border-bottom: 1px solid rgba(255, 255, 255, 0.16); +` + +export const ChatAvatar = styled.div` + display: flex; + align-items: center; +` + +export const CustomTextArrea = styled(TextareaAutosize)` + background: transparent; + box-sizing: border-box; + width: 100%; + font-size: 18px; + border-radius: 12px; + color: white; + padding: 12px 16px; + + &::focus { + outline: none; + } +` + +export const ContainerTitle = styled.div` + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: center; + position: sticky; + width: 100%; + padding: 1.5rem 0; + z-index: 2; + right: 0; + left: 0; + top: 0; + border-bottom: 1px solid rgba(255, 255, 255, 0.16); + padding-bottom: 32px!important; +`; + +export const TitleRow = styled.div` + width: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-between; +`; + +export const Title = styled.label` + font-size: 2.4rem; + line-height: 3rem; + white-space: nowrap; + margin: 0; + max-width: 1120px; + font-weight: 600; + color: ${p => p.theme.colors.morMain}; + margin-bottom: 4.8px; + margin-right: 2.4rem; + cursor: default; + /* width: 100%; */ + + @media (min-width: 1140px) { + } + + @media (min-width: 1200px) { + } +`; \ No newline at end of file diff --git a/ui-desktop/src/renderer/src/components/chat/Chat.tsx b/ui-desktop/src/renderer/src/components/chat/Chat.tsx new file mode 100644 index 00000000..84784867 --- /dev/null +++ b/ui-desktop/src/renderer/src/components/chat/Chat.tsx @@ -0,0 +1,194 @@ +import React, { createRef, useContext, useRef, useState } from 'react' +// import component 👇 +import Drawer from 'react-modern-drawer' +import { IconHistory, IconArrowUp } from '@tabler/icons-react'; +import { + View, + ContainerTitle, + ChatTitleContainer, + ChatAvatar, + Avatar, + Title, + TitleRow, + AvatarHeader, + MessageBody, + Container, + ChatBlock, + CustomTextArrea, + Control, + SendBtn +} from './Chat.styles'; + +import 'react-modern-drawer/dist/index.css' +import './Chat.css' +import { ChatHistory } from './ChatHistory'; + +const lorem = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum." +const colors = [ + '#1899cb', '#da4d76', '#d66b38', '#d39d00', '#b46fc4', '#269c68', '#86858a' +]; + +const getColor = (name) => { + return colors[getHashCode(name) % colors.length] +} + +const Chat = (props) => { + const chatBlockRef = useRef(null); + + const [value, setValue] = useState(""); + + const [history, setHistory] = useState(["What is Lorem Ipsum?"]); + const [isSpinning, setIsSpinning] = useState(false); + + const user = props.chat || 'Llama GPT'; + + const [messages, setMessages] = useState([ + { user: 'Me', role: "user", text: "What is Lorem Ipsum?", icon: "M", color: getColor("Me") }, + { user: 'GPT', role: "assistant", text: lorem, icon: "GPT", color: getColor("GPT") }]); + + const [isOpen, setIsOpen] = useState(false); + const toggleDrawer = () => { + setIsOpen((prevState) => !prevState) + } + + const scrollToBottom = () => { + chatBlockRef.current?.scrollIntoView({ behavior: "smooth" }) + } + + const call = async (message) => { + try { + const response = await fetch("http://localhost:11434/v1/chat/completions", { + method: 'POST', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + model: "llama2:latest", + messages: [ + { + role: "user", + content: message + }] + }) + }); + const data = await response.json(); + setMessages([...messages, { user: 'GPT', role: "assistant", text: data.choices, icon: "GPT", color: getColor("GPT") }]); + } + catch (e) { + setMessages([...messages, { user: 'GPT', role: "assistant", text: "Ooops, cannot answer", icon: "GPT", color: getColor("GPT") }]); + } + finally { + setIsSpinning(false); + } + } + + const handleSubmit = () => { + if(!value) { + return; + } + + setIsSpinning(true); + setMessages([...messages, { user: 'Me', text: value, role: "user", icon: "M", color: colors[getHashCode("M") % colors.length] }]); + scrollToBottom(); + call(messages); + setValue(""); + } + + return ( + <> + + + + + + + Chat + + + + + + GPT + +
Llama GPT
+
+
Provider: 0x123...234
+
+
+ +
+
+
+ + + + { + messages && messages.map(x => ( + + )) + } + + + { + if (e.key === 'Enter') { + e.preventDefault(); + handleSubmit(); + } + }} + value={value} + onChange={ev => setValue(ev.target.value)} + // style={{ background: 'transparent', boxSizing: 'border-box'}} + placeholder={"Ask me anything..."} + minRows={1} + maxRows={6} /> + + + +
+ + ) +} + +const Message = ({ message }) => { + return ( +
+ + {message.icon} + +
+ {message.user} + {message.text} +
+
) +} + +function makeid(length) { + let result = ''; + const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + const charactersLength = characters.length; + let counter = 0; + while (counter < length) { + result += characters.charAt(Math.floor(Math.random() * charactersLength)); + counter += 1; + } + return result; +} + +function getHashCode(string) { + var hash = 0; + for (var i = 0; i < string.length; i++) { + var code = string.charCodeAt(i); + hash = ((hash << 5) - hash) + code; + hash = hash & hash; // Convert to 32bit integer + } + return Math.abs(hash); +} + +export default Chat; \ No newline at end of file diff --git a/ui-desktop/src/renderer/src/components/chat/ChatHistory.tsx b/ui-desktop/src/renderer/src/components/chat/ChatHistory.tsx new file mode 100644 index 00000000..1ae56a82 --- /dev/null +++ b/ui-desktop/src/renderer/src/components/chat/ChatHistory.tsx @@ -0,0 +1,28 @@ +import React from "react"; +import styled from 'styled-components'; + +const Container = styled.div` + text-align: center; +` + +const Title = styled.div` + text-align: center; + margin-bottom: 2.4rem; +` +const HistoryItem = styled.div` + color: ${p => p.theme.colors.morMain} +` +export const ChatHistory = (props: { history: string[]}) => { + return ( + + + History + + { + props.history?.length && ( + props.history.map(a => ({a})) + ) + } + + ) +} \ No newline at end of file diff --git a/ui-desktop/src/renderer/src/components/common/LayoutHeader.jsx b/ui-desktop/src/renderer/src/components/common/LayoutHeader.jsx index 77c76d2c..ca568adf 100644 --- a/ui-desktop/src/renderer/src/components/common/LayoutHeader.jsx +++ b/ui-desktop/src/renderer/src/components/common/LayoutHeader.jsx @@ -9,7 +9,7 @@ const Container = styled.div` align-items: center; position: sticky; width: 100%; - padding: 1.5rem 0; + padding: 0 0 1.5rem 0; z-index: 2; right: 0; left: 0; @@ -44,12 +44,10 @@ const Title = styled.label` `; export const LayoutHeader = ({ title, children }) => ( - <> {title} {children} - ); diff --git a/ui-desktop/src/renderer/src/components/common/TextInput.styles.jsx b/ui-desktop/src/renderer/src/components/common/TextInput.styles.jsx index 165b8a7e..6ecdefbc 100644 --- a/ui-desktop/src/renderer/src/components/common/TextInput.styles.jsx +++ b/ui-desktop/src/renderer/src/components/common/TextInput.styles.jsx @@ -11,7 +11,7 @@ export const Label = styled.label` export const Input = styled.input` border: none; display: block; - border-radius: 15px; + border-radius: 2px; padding: 0.8rem 1.6rem; background-color: ${p => p.theme.colors.lightBlue}; margin-top: 0.8rem; diff --git a/ui-desktop/src/renderer/src/components/contracts/contracts-list/ContractsList.styles.jsx b/ui-desktop/src/renderer/src/components/contracts/contracts-list/ContractsList.styles.jsx index d1c29cb0..c673eca2 100644 --- a/ui-desktop/src/renderer/src/components/contracts/contracts-list/ContractsList.styles.jsx +++ b/ui-desktop/src/renderer/src/components/contracts/contracts-list/ContractsList.styles.jsx @@ -15,6 +15,13 @@ export const Contracts = styled.div` margin: 1.6rem 0 1.6rem; border-radius: 15px; background-color: #fff; + + border-radius: 0.375rem; + + background: rgba(255,255,255, 0.04); + border-width: 1px; + border: 1px solid rgba(255, 255, 255, 0.04); + color: white; `; export const ListContainer = styled.div` diff --git a/ui-desktop/src/renderer/src/components/contracts/contracts-list/Filter.jsx b/ui-desktop/src/renderer/src/components/contracts/contracts-list/Filter.jsx index aafd699e..6a5df484 100644 --- a/ui-desktop/src/renderer/src/components/contracts/contracts-list/Filter.jsx +++ b/ui-desktop/src/renderer/src/components/contracts/contracts-list/Filter.jsx @@ -16,7 +16,7 @@ const Tab = styled.button` line-height: 1.2rem; font-size: 1.2rem; font-weight: bold; - color: ${p => p.theme.colors.primary}; + color: ${p => p.theme.colors.morMain}; letter-spacing: 1.4px; text-align: center; opacity: ${p => (p.isActive ? '1' : '0.75')}; diff --git a/ui-desktop/src/renderer/src/components/contracts/contracts-list/Header.jsx b/ui-desktop/src/renderer/src/components/contracts/contracts-list/Header.jsx index e364a55e..2b48e755 100644 --- a/ui-desktop/src/renderer/src/components/contracts/contracts-list/Header.jsx +++ b/ui-desktop/src/renderer/src/components/contracts/contracts-list/Header.jsx @@ -19,7 +19,7 @@ const Container = styled.div` // left: 0; // right: 0; z-index: 1; - + ${p => responsiveHeader('800px')} `; diff --git a/ui-desktop/src/renderer/src/components/dashboard/tx-list/TxList.jsx b/ui-desktop/src/renderer/src/components/dashboard/tx-list/TxList.jsx index 8f6b3e7b..82533484 100644 --- a/ui-desktop/src/renderer/src/components/dashboard/tx-list/TxList.jsx +++ b/ui-desktop/src/renderer/src/components/dashboard/tx-list/TxList.jsx @@ -43,7 +43,7 @@ const ListContainer = styled.div` const TxRowContainer = styled.div` &:hover { - background-color: #eaf7fc; + background-color: rgba(0,0,0,0.5); } `; diff --git a/ui-desktop/src/renderer/src/components/models/Models.tsx b/ui-desktop/src/renderer/src/components/models/Models.tsx new file mode 100644 index 00000000..efb9217a --- /dev/null +++ b/ui-desktop/src/renderer/src/components/models/Models.tsx @@ -0,0 +1,12 @@ +import React from "react"; +import { LayoutHeader } from '../common/LayoutHeader' +import { View } from '../common/View' +import ModelsTable from './ModelsTable'; + +export const Models = () => { + return ( + + + + ) +} \ No newline at end of file diff --git a/ui-desktop/src/renderer/src/components/models/ModelsTable.tsx b/ui-desktop/src/renderer/src/components/models/ModelsTable.tsx new file mode 100644 index 00000000..05a20cdc --- /dev/null +++ b/ui-desktop/src/renderer/src/components/models/ModelsTable.tsx @@ -0,0 +1,131 @@ +import React, { useState, useEffect } from 'react'; +import { List as RVList, AutoSizer } from 'react-virtualized'; +import ScanningContractsPlaceholder from '../contracts/contracts-list/ScanningContractsPlaceholder'; +import NoContractsPlaceholder from '../contracts/contracts-list/NoContractsPlaceholder'; +import { ItemFilter } from '../common'; +import Header from '../contracts/contracts-list/Header'; +import ContractsRow from '../contracts/contracts-list/Row'; +import { + Container, + ListContainer, + Contracts, + FooterLogo +} from '../contracts/contracts-list/ContractsList.styles'; +import { ContractsRowContainer } from '../contracts/contracts-list/ContractsRow.styles'; +import styled from 'styled-components'; +import { Btn } from '../common'; + +function ModelsTable({ + contracts, + syncStatus, + cancel, + deleteContract, + address, + contractsRefresh, + noContractsMessage, + allowSendTransaction, + tabs, + edit, + setEditContractData, + offset, + underProfitContracts, +} : any) { + const [selectedContracts, setSelectedContracts] = useState([]); + const [search, setSearch] = useState(''); + const [sort, setSort] = useState(null); + + const [headerOptions, setHeaderOptions] = useState({}); + + console.log("render"); + + let contractsToShow = contracts || []; + + const hasContracts = contractsToShow.length; + + const defaultTabs = [ + { value: 'name', name: 'Name', ratio: 2 }, + { value: 'size', name: 'Size', ratio: 2 }, + { value: 'ipc', name: 'IPC', ratio: 2 }, + ]; + + const tabsToShow = tabs || defaultTabs; + const ratio = tabsToShow.map(x => x.ratio); + + + const rowRenderer = (contractsList, ratio, converters) => ({ + key, + index, + style + }) => ( + + + + ); + + const filterExtractValue = ({ status }) => status; + return ( + + + + {({ filteredItems }) => ( + +
{}} + onColumnOptionChange={e => + setHeaderOptions({ + ...headerOptions, + [e.type]: e.value + }) + } + activeFilter={null} + tabs={tabsToShow} + /> + + + {!hasContracts && + (syncStatus === 'syncing' ? ( + + ) : ( + + ))} + + {({ width, height }) => ( + + )} + + + + + )} + + + + ); +} + +export default ModelsTable; diff --git a/ui-desktop/src/renderer/src/components/sidebar/PrimaryNav.jsx b/ui-desktop/src/renderer/src/components/sidebar/PrimaryNav.jsx index acfe1f66..fdc76b23 100644 --- a/ui-desktop/src/renderer/src/components/sidebar/PrimaryNav.jsx +++ b/ui-desktop/src/renderer/src/components/sidebar/PrimaryNav.jsx @@ -1,15 +1,16 @@ import React from 'react'; import { NavLink } from 'react-router-dom'; import styled from 'styled-components'; -import { IconFileReport } from '@tabler/icons-react'; +import { IconFileReport, IconMessage } from '@tabler/icons-react'; import { IconBuildingStore } from '@tabler/icons-react'; import { IconChecklist } from '@tabler/icons-react'; -import { IconWallet } from '@tabler/icons-react'; +import { IconWallet, IconMessages, IconPackages, IconUsers } from '@tabler/icons-react'; const Container = styled.div` display: flex; flex-direction: column; justify-content: space-between; + padding-left: 2.2rem; max-height: 10%; `; @@ -22,6 +23,7 @@ const Button = styled(NavLink)` padding: 1.6rem; border-top: 1px solid transparent; + &:focus { outline: none; } @@ -87,52 +89,39 @@ export default function PrimaryNav({ parent, activeIndex, setActiveIndex }) { - {/* - */} - {/* */} + + ); } diff --git a/ui-desktop/src/renderer/src/components/sidebar/SecondaryNav.jsx b/ui-desktop/src/renderer/src/components/sidebar/SecondaryNav.jsx index 2283830a..07c6f189 100644 --- a/ui-desktop/src/renderer/src/components/sidebar/SecondaryNav.jsx +++ b/ui-desktop/src/renderer/src/components/sidebar/SecondaryNav.jsx @@ -13,8 +13,8 @@ const Container = styled.div` flex-direction: column; justify-content: space-between; max-height: 10%; - border-top: 1px solid rgba(255, 255, 255, 0.16); color: ${p => p.theme.colors.morMain} + padding-left: 2.2rem; `; const Button = styled(NavLink)` diff --git a/ui-desktop/src/renderer/src/components/sidebar/Sidebar.jsx b/ui-desktop/src/renderer/src/components/sidebar/Sidebar.jsx index b2ecc5c8..a856a58f 100644 --- a/ui-desktop/src/renderer/src/components/sidebar/Sidebar.jsx +++ b/ui-desktop/src/renderer/src/components/sidebar/Sidebar.jsx @@ -22,6 +22,7 @@ const Container = styled.div` left: 0; bottom: 0; z-index: 3; + border-right: 1px solid rgba(255, 255, 255, 0.16); .sidebar-address { display: none; @@ -85,7 +86,6 @@ const NavContainer = styled.div` justify-content: space-between; flex-direction: column; height: 100%; - padding-left: 2.2rem; @media (max-width: 800px) { padding-left: 1rem; } @@ -97,8 +97,8 @@ const PrimaryNavContainer = styled.nav` ` function Sidebar(props) { - const { address, copyToClipboard } = props - const [activeIndex, setActiveIndex] = useState(0) + const { address, copyToClipboard } = props; + const [activeIndex, setActiveIndex] = useState(0); return ( @@ -117,7 +117,7 @@ function Sidebar(props) { /> -