-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e049870
commit 069138a
Showing
15 changed files
with
187 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
hasura/metadata/databases/bdjuno/tables/public_bridge_chains.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
table: | ||
name: bridge_chains | ||
schema: public | ||
select_permissions: | ||
- permission: | ||
allow_aggregations: false | ||
columns: | ||
- id | ||
- chain_type | ||
- bridge_address | ||
- operator | ||
filter: {} | ||
limit: 100 | ||
role: anonymous |
2 changes: 1 addition & 1 deletion
2
...ases/bdjuno/tables/public_token_info.yaml → ...juno/tables/public_bridge_token_info.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
table: | ||
name: tokens_info | ||
name: bridge_tokens_info | ||
schema: public | ||
select_permissions: | ||
- permission: | ||
|
2 changes: 1 addition & 1 deletion
2
.../bdjuno/tables/public_token_metadata.yaml → .../tables/public_bridge_token_metadata.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
table: | ||
name: token_metadata | ||
name: bridge_token_metadata | ||
schema: public | ||
select_permissions: | ||
- permission: | ||
|
6 changes: 3 additions & 3 deletions
6
...atabases/bdjuno/tables/public_tokens.yaml → ...s/bdjuno/tables/public_bridge_tokens.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ses/bdjuno/tables/public_transaction.yaml → ...uno/tables/public_bridge_transaction.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
table: | ||
name: transaction | ||
name: bridge_transaction | ||
schema: public | ||
object_relationships: | ||
- name: block | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package bridge | ||
|
||
import ( | ||
"encoding/json" | ||
bridgetypes "github.com/hyle-team/bridgeless-core/v12/x/bridge/types" | ||
"github.com/pkg/errors" | ||
tmtypes "github.com/tendermint/tendermint/types" | ||
|
||
"github.com/rs/zerolog/log" | ||
) | ||
|
||
// HandleGenesis implements modules.Module | ||
func (m *Module) HandleGenesis(doc *tmtypes.GenesisDoc, appState map[string]json.RawMessage) error { | ||
log.Debug().Str("module", "bridge").Msg("parsing genesis") | ||
|
||
// Read the genesis state | ||
var genState bridgetypes.GenesisState | ||
err := m.cdc.UnmarshalJSON(appState[bridgetypes.ModuleName], &genState) | ||
if err != nil { | ||
return errors.Wrap(err, "error while reading bridge genesis data") | ||
} | ||
|
||
// Save tokens | ||
for _, token := range genState.Tokens { | ||
err = m.db.SaveBridgeTokenMetadata(token.Id, token.Metadata.Name, token.Metadata.Symbol, token.Metadata.Uri) | ||
if err != nil { | ||
return errors.Wrap(err, "error while storing genesis token metadata") | ||
} | ||
for _, tokenInfo := range token.Info { | ||
tokenInfoId, err := m.db.SaveBridgeTokenInfo(tokenInfo.Address, tokenInfo.Decimals, tokenInfo.ChainId, tokenInfo.TokenId, tokenInfo.IsWrapped) | ||
if err != nil { | ||
return errors.Wrap(err, "error while storing genesis token info") | ||
} | ||
if err = m.db.SaveBridgeToken(tokenInfoId, token.Id); err != nil { | ||
return errors.Wrap(err, "error while storing genesis token") | ||
} | ||
} | ||
} | ||
|
||
for _, chain := range genState.Chains { | ||
if err = m.db.SaveBridgeChain(chain.Id, int32(chain.Type), chain.BridgeAddress, chain.Operator); err != nil { | ||
return errors.Wrap(err, "error while storing genesis chain") | ||
} | ||
} | ||
|
||
for _, tx := range genState.Transactions { | ||
if err = m.db.SaveBridgeTransaction(tx); err != nil { | ||
return errors.Wrap(err, "error while storing genesis transaction") | ||
} | ||
} | ||
return nil | ||
} |
Oops, something went wrong.