Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/kip-87 -> release/v0.4.42 #204

Closed
wants to merge 50 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
36abaec
implement metamask send & eip712 signed transactions
tj327 Dec 20, 2023
7132c5f
upgrade interx version to v0.4.42
tj327 Dec 20, 2023
d7c8190
add comments for decode functions
tj327 Dec 20, 2023
b3f5d6b
update endpoint&fix decodeparams issue
tj327 Dec 21, 2023
f84baea
add verification of eip-712 signed transaction
tj327 Jan 5, 2024
a0e7a32
check validation of eip-712 signed tx
tj327 Jan 8, 2024
17570cf
Merge pull request #207 from KiraCore/release/v0.4.42
asmodat Jan 8, 2024
91464ea
finish validation of eip712-signed tx
tj327 Jan 9, 2024
d26bf95
fix unsupported type while unmarshalling
tj327 Jan 10, 2024
d052252
fix validation issues
tj327 Jan 11, 2024
cd4b614
make sleep interval for snapshot checksum
tj327 Jan 11, 2024
294dfc6
version update
tj327 Jan 11, 2024
d6b12b8
Merge pull request #209 from KiraCore/bugfix/performance
kmlbgn Jan 11, 2024
3448c1c
Merge pull request #210 from KiraCore/release/v0.4.43
asmodat Jan 12, 2024
4b0da1f
Merge branch 'master' into feature/kip-87
tj327 Jan 12, 2024
487eae3
pagination for tokenalias
tj327 Jan 25, 2024
0ca7eb6
add custom pagination for balance query
tj327 Jan 30, 2024
af21064
set default limit to 100 for custom pagination
tj327 Jan 30, 2024
2f99458
add derived filter and release version
tj327 Feb 1, 2024
99791e0
fix integration test
tj327 Feb 1, 2024
a9ba7dc
Merge pull request #213 from KiraCore/bugfix/pagination
tj327 Feb 1, 2024
ad319c8
pending work for geo node discovery
tj327 Feb 15, 2024
380f336
update pagination fields to string
tj327 Feb 15, 2024
af36e47
Merge pull request #217 from KiraCore/bugfix/pagination_fields_string
tj327 Feb 15, 2024
aeba211
Merge pull request #214 from KiraCore/release/v0.4.44
asmodat Feb 19, 2024
ea577cd
add release version
tj327 Feb 20, 2024
951d3fe
Merge pull request #219 from KiraCore/feature/pagination_query_release
MrLutik Feb 20, 2024
9e83167
update node discovery
tj327 Feb 22, 2024
7afb185
Merge branch 'master' of github.com:KiraCore/interx into feature/geo_…
tj327 Feb 22, 2024
6db9cea
Merge pull request #220 from KiraCore/release/v0.4.45
MrLutik Feb 22, 2024
8188d1c
Merge branch 'master' of github.com:KiraCore/interx into feature/geo_…
tj327 Feb 23, 2024
b551939
release v0.4.46
tj327 Feb 23, 2024
90897fb
Merge pull request #222 from KiraCore/feature/geo_fields
kmlbgn Feb 26, 2024
62abe5f
Merge pull request #223 from KiraCore/release/v0.4.46
MrLutik Mar 2, 2024
2dbf8b5
feat(cook_hook): Add webhook to sekin
MrLutik Mar 3, 2024
b72f0b1
feat(cook_hook): Preapare for release
MrLutik Mar 3, 2024
b38cacd
feat(cook_hook) Fix idention
MrLutik Mar 4, 2024
cf3625d
feat(cook_hook): Bump interx version
MrLutik Mar 4, 2024
05ad1a2
Merge branch 'release/v0.4.47' into feature/cook_hook
MrLutik Mar 4, 2024
a55c8bf
Merge pull request #225 from KiraCore/feature/cook_hook
MrLutik Mar 4, 2024
f8eb2ab
Merge pull request #226 from KiraCore/release/v0.4.47
MrLutik Mar 4, 2024
8d849f9
peers number count fix
tj327 Mar 6, 2024
0e022fb
feat(cook_hook) Refactor
MrLutik Mar 7, 2024
2534e75
Update RELEASE
MrLutik Mar 7, 2024
68b249c
Merge pull request #229 from KiraCore/feature/cook_hook
MrLutik Mar 7, 2024
8abe867
Merge pull request #230 from KiraCore/release/v0.4.48
MrLutik Mar 7, 2024
b69ef2d
metamask tx submission update
tj327 May 8, 2024
57e3dd7
revert sekai replace in go.mod
tj327 May 8, 2024
a21de55
Merge branch 'master' of github.com:KiraCore/interx into feature/kip-87
tj327 May 23, 2024
6f027ac
release
tj327 May 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/merge_hook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
name: Release Merged Hook

on:
pull_request:
types: [closed]
branches:
- master

jobs:
trigger-dispatch:
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/v')
runs-on: ubuntu-latest
steps:
- name: Extract Version from Branch Name
id: version-extract
run: |
VERSION=$(echo "${{ github.event.pull_request.head.ref }}" | sed 's|release/v||')
echo "VERSION=$VERSION" >> $GITHUB_ENV

- name: Trigger Repository Dispatch Event
env:
VERSION: ${{ env.VERSION }}
run: |
curl -X POST -H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${{ secrets.REPO_ACCESS }}" \
"https://api.github.com/repos/KiraCore/sekin/dispatches" \
-d @- <<EOF
{
"event_type": "release_merged",
"client_payload": {
"version": "${VERSION}",
"name": "interx",
"authors": "KIRA",
"url": "https://kira.network",
"documentation": "https://docs.kira.network",
"source": "https://github.com/KiraCore/interx",
"vendor": "KiraCore",
"licenses": "CC BY-NC-SA 4.0",
"title": "interx",
"description": "INTERX is KIRA’s Content Availability Layer. It ensures rapid, scalable queries and access to on-chain (SEKAI) and off-chain (L2) RollApp data without reliance on third-party RPC service providers such as Infura (Ethereum) and DA networks such as Celestia (Cosmos). INTERX streamlines the creation and maintenance of front-end and RollApp, eliminating the complexities associated with light clients and providing out-of-the-box support for sequencing, storage, fraud-proof generation, replication, proxy, and middleware layer load-balancing. "
}
}
EOF
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: proto-gen build publish install start test test-local network-start network-stop
.PHONY: proto-gen build build-static publish install start test test-local network-start network-stop

proto-gen:
./scripts/proto-gen.sh
Expand All @@ -10,6 +10,10 @@ install:
build:
./scripts/build.sh

build-static:
./scripts/proto-gen.sh
./scripts/sbuild.sh

start:
go run main.go

Expand All @@ -28,4 +32,4 @@ network-start:
./scripts/test-local/network-start.sh

network-stop:
./scripts/test-local/network-stop.sh
./scripts/test-local/network-stop.sh
5 changes: 2 additions & 3 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

Features:

* Add DefaultDenom and Bech32Prefix to QueryKiraTokensAliases endpoint
* Bump sekai version to v0.3.40
* Implement KIP-87 : broadcast metamask coin send transaction to sekai
* Implement KIP-87 : broadcast eip-712 signed transaction to sekai
34 changes: 29 additions & 5 deletions common/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ func GetAccountNumberSequence(gwCosmosmux *runtime.ServeMux, r *http.Request, be

type QueryAccountResponse struct {
Account struct {
Address string `json:"addresss"`
PubKey string `json:"pubKey"`
AccountNumber string `json:"accountNumber"`
Sequence string `json:"sequence"`
Address string `json:"addresss"`
PubKey interface{} `json:"pubKey"`
AccountNumber string `json:"accountNumber"`
Sequence string `json:"sequence"`
} `json:"account"`
}
result := QueryAccountResponse{}
Expand Down Expand Up @@ -331,7 +331,6 @@ func GetTokenAliases(gwCosmosmux *runtime.ServeMux, r *http.Request) ([]types.To
}

result := TokenAliasesResponse{}

err := json.NewDecoder(resp.Body).Decode(&result)
if err != nil {
GetLogger().Error("[grpc-call] Unable to decode response: ", err)
Expand All @@ -346,6 +345,31 @@ func GetTokenAliases(gwCosmosmux *runtime.ServeMux, r *http.Request) ([]types.To
return result.Data, result.DefaultDenom, result.Bech32Prefix
}

// GetAllBalances is a function to get all balances with full limitation
func GetAllBalances(gwCosmosmux *runtime.ServeMux, r *http.Request, bech32Addr string) []types.Coin {
r.URL.Path = fmt.Sprintf("/cosmos/bank/v1beta1/balances/%s", bech32Addr)
r.URL.RawQuery = "pagination.limit=100000"
r.Method = "GET"

// GetLogger().Info("[grpc-call] Entering grpc call: ", r.URL.Path)

recorder := httptest.NewRecorder()
gwCosmosmux.ServeHTTP(recorder, r)
resp := recorder.Result()

type AllBalancesResponse struct {
Balances []types.Coin `json:"balances"`
}

result := AllBalancesResponse{}
err := json.NewDecoder(resp.Body).Decode(&result)
if err != nil {
GetLogger().Error("[grpc-call] Unable to decode response: ", err)
}

return result.Balances
}

// GetTokenSupply is a function to get token supply
func GetTokenSupply(gwCosmosmux *runtime.ServeMux, r *http.Request) []types.TokenSupply {
r.URL.Path = strings.Replace(config.QueryTotalSupply, "/api/kira", "/cosmos/bank/v1beta1", -1)
Expand Down
12 changes: 10 additions & 2 deletions config/constants.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
package config

const (
InterxVersion = "v0.4.42"
SekaiVersion = "v0.3.40"
InterxVersion = "v0.4.49"
SekaiVersion = "v0.3.45"
CosmosVersion = "v0.47.6"

DefaultChainID = 8789
DefaultKiraAddrPrefix = "kira"
DefaultKiraValAddrPrefix = "kiravaloper"
DefaultKiraDenom = "ukex"

MetamaskEndpoint = "/api/kira/evm"
RegisterAddrEndpoint = "/api/kira/evm/register_address/{eth_addr}{cosmos_addr}"

QueryDashboard = "/api/dashboard"

QueryAccounts = "/api/kira/accounts/{address}"
Expand Down
3 changes: 3 additions & 0 deletions config/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ func InitConfig(
nodeDiscoveryTendermintPort string,
nodeDiscoveryTimeout string,
nodeKey string,
snapshotInterval uint64,
) {
configFromFile := defaultConfig()

Expand Down Expand Up @@ -290,6 +291,8 @@ func InitConfig(
configFromFile.Faucet.FeeAmounts[denom] = amount
}

configFromFile.SnapshotInterval = snapshotInterval

bytes, err := json.MarshalIndent(&configFromFile, "", " ")
if err != nil {
panic(err)
Expand Down
2 changes: 2 additions & 0 deletions config/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@ func LoadConfig(configFilePath string) {

Config.Evm = configFromFile.Evm
Config.Bitcoin = configFromFile.Bitcoin

Config.SnapshotInterval = configFromFile.SnapshotInterval
}

// GenPrivKey is a function to generate a privKey
Expand Down
48 changes: 25 additions & 23 deletions config/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,27 +89,28 @@ type BitcoinConfig struct {

// InterxConfig is a struct to be used for interx configuration
type InterxConfig struct {
InterxVersion string `json:"interx_version"`
SekaiVersion string `json:"sekai_version"`
ServeHTTPS bool `json:"serve_https"`
GRPC string `json:"grpc"`
RPC string `json:"rpc"`
PORT string `json:"port"`
Node types.NodeConfig `json:"node"`
Mnemonic string `json:"mnemonic"`
AddrBooks []string `json:"addrbooks"`
NodeKey *p2p.NodeKey `json:"node_key"`
TxModes []string `json:"tx_modes"`
PrivKey crypto.PrivKey `json:"privkey"`
PubKey crypto.PubKey `json:"pubkey"`
Address string `json:"address"`
NodeDiscovery NodeDiscoveryConfig `json:"node_discovery"`
Block BlockConfig `json:"block"`
Cache CacheConfig `json:"cache"`
Faucet FaucetConfig `json:"faucet"`
RPCMethods RPCConfig `json:"rpc_methods"`
Evm map[string]EVMConfig `json:"evm"`
Bitcoin map[string]BitcoinConfig `json:"bitcoin"`
InterxVersion string `json:"interx_version"`
SekaiVersion string `json:"sekai_version"`
ServeHTTPS bool `json:"serve_https"`
GRPC string `json:"grpc"`
RPC string `json:"rpc"`
PORT string `json:"port"`
Node types.NodeConfig `json:"node"`
Mnemonic string `json:"mnemonic"`
AddrBooks []string `json:"addrbooks"`
NodeKey *p2p.NodeKey `json:"node_key"`
TxModes []string `json:"tx_modes"`
PrivKey crypto.PrivKey `json:"privkey"`
PubKey crypto.PubKey `json:"pubkey"`
Address string `json:"address"`
NodeDiscovery NodeDiscoveryConfig `json:"node_discovery"`
Block BlockConfig `json:"block"`
Cache CacheConfig `json:"cache"`
Faucet FaucetConfig `json:"faucet"`
RPCMethods RPCConfig `json:"rpc_methods"`
Evm map[string]EVMConfig `json:"evm"`
Bitcoin map[string]BitcoinConfig `json:"bitcoin"`
SnapshotInterval uint64 `json:"snapshot_interval"`
}

// InterxConfigFromFile is a struct to be used for interx configuration file
Expand Down Expand Up @@ -138,6 +139,7 @@ type InterxConfigFromFile struct {
FeeAmounts map[string]string `json:"fee_amounts"`
TimeLimit int64 `json:"time_limit"`
} `json:"faucet"`
Evm map[string]EVMConfig `json:"evm"`
Bitcoin map[string]BitcoinConfig `json:"bitcoin"`
Evm map[string]EVMConfig `json:"evm"`
Bitcoin map[string]BitcoinConfig `json:"bitcoin"`
SnapshotInterval uint64 `json:"snapshot_interval"`
}
125 changes: 110 additions & 15 deletions gateway/cosmos/bank.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package cosmos
import (
"fmt"
"net/http"
"strconv"
"strings"

"github.com/KiraCore/interx/common"
"github.com/KiraCore/interx/config"
"github.com/KiraCore/interx/types"
"github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
)
Expand Down Expand Up @@ -58,26 +60,119 @@ func QuerySupplyRequest(gwCosmosmux *runtime.ServeMux, rpcAddr string) http.Hand
func queryBalancesHandle(r *http.Request, gwCosmosmux *runtime.ServeMux) (interface{}, interface{}, int) {
params := mux.Vars(r)
bech32addr := params["address"]
queries := r.URL.Query()
offset := queries["offset"]
limit := queries["limit"]
countTotal := queries["count_total"]

var events = make([]string, 0, 3)
if len(offset) == 1 {
events = append(events, fmt.Sprintf("pagination.offset=%s", offset[0]))

// request could have tokens list if so, returns those
tokensParam := r.URL.Query().Get("tokens")
excludedParam := r.URL.Query().Get("excluded")
derivedParam := r.URL.Query().Get("derived")

// use default balances query when no custom params set
if tokensParam == "" && excludedParam == "" && (derivedParam != "true" && derivedParam != "false") {
queries := r.URL.Query()
offset := queries["offset"]
limit := queries["limit"]
countTotal := queries["count_total"]
var events = make([]string, 0, 3)
if len(offset) == 1 {
events = append(events, fmt.Sprintf("pagination.offset=%s", offset[0]))
}
if len(limit) == 1 {
events = append(events, fmt.Sprintf("pagination.limit=%s", limit[0]))
}
if len(countTotal) == 1 {
events = append(events, fmt.Sprintf("pagination.count_total=%s", countTotal[0]))
} else if len(limit) == 1 { // set count_total flag to true as default when limit flag's set
events = append(events, "pagination.count_total=true")
}

r.URL.RawQuery = strings.Join(events, "&")
r.URL.Path = fmt.Sprintf("/cosmos/bank/v1beta1/balances/%s", bech32addr)
return common.ServeGRPC(r, gwCosmosmux)
}
if len(limit) == 1 {
events = append(events, fmt.Sprintf("pagination.limit=%s", limit[0]))

type Pagination struct {
NextKey string `json:"next_key"`
Total string `json:"total"`
}
if len(countTotal) == 1 {
events = append(events, fmt.Sprintf("pagination.count_total=%s", countTotal[0]))

type BalancesResult struct {
Balances []types.Coin `json:"balances"`
Pagination *Pagination `json:"pagination,omitempty"`
}

r.URL.RawQuery = strings.Join(events, "&")
allBalances := common.GetAllBalances(gwCosmosmux, r.Clone(r.Context()), bech32addr)

r.URL.Path = fmt.Sprintf("/cosmos/bank/v1beta1/balances/%s", bech32addr)
return common.ServeGRPC(r, gwCosmosmux)
data := make([]types.Coin, 0)
if tokensParam != "" {
tokensList := strings.Split(tokensParam, ",")
tokensMap := make(map[string]bool)
for _, token := range tokensList {
tokensMap[token] = true
}

for _, balance := range allBalances {
if tokensMap[balance.Denom] {
data = append(data, balance)
}
}
result := BalancesResult{
Balances: data,
}

return result, nil, http.StatusOK
}

excludedList := strings.Split(excludedParam, ",")
excludedMap := make(map[string]bool)
for _, token := range excludedList {
excludedMap[token] = true
}

filteredData := make([]types.Coin, 0)
for _, balance := range allBalances {
denom := balance.Denom
if excludedMap[denom] {
continue
}

isDerivedDenom := len(denom) > 2 && denom[0] == 'v' && strings.Contains(denom, "/")
if derivedParam == "true" && !isDerivedDenom {
continue
}
if derivedParam == "false" && isDerivedDenom {
continue
}

filteredData = append(filteredData, balance)
}

// if request does not have tokens list, return with pagination
offsetParam := r.URL.Query().Get("offset")
offset, err := strconv.Atoi(offsetParam)
if err != nil {
offset = 0
}
limitParam := r.URL.Query().Get("limit")
limit, err := strconv.Atoi(limitParam)
if err != nil {
limit = 100
}

lastIndex := offset + limit
if lastIndex > len(filteredData) {
lastIndex = len(filteredData)
}
data = filteredData[offset:lastIndex]

result := BalancesResult{
Balances: data,
Pagination: &Pagination{
NextKey: fmt.Sprintf("%d", lastIndex),
Total: fmt.Sprintf("%d", len(filteredData)),
},
}

return result, nil, http.StatusOK
}

// QueryBalancesRequest is a function to query balances.
Expand Down
Loading
Loading