-
Notifications
You must be signed in to change notification settings - Fork 31
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
feat: add Base chain support #515
Open
hiporox
wants to merge
1
commit into
Cypherock:main
Choose a base branch
from
hiporox:feat/add_base
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
/** | ||
* @file base_app.c | ||
* @author Cypherock X1 Team | ||
* @brief BASE application configuration and helpers | ||
* @copyright Copyright (c) 2023 HODL TECH PTE LTD | ||
* <br/> You may obtain a copy of license at <a href="https://mitcc.org/" | ||
*target=_blank>https://mitcc.org/</a> | ||
* | ||
****************************************************************************** | ||
* @attention | ||
* | ||
* (c) Copyright 2023 by HODL TECH PTE LTD | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining | ||
* a copy of this software and associated documentation files (the | ||
* "Software"), to deal in the Software without restriction, including | ||
* without limitation the rights to use, copy, modify, merge, publish, | ||
* distribute, sublicense, and/or sell copies of the Software, and to | ||
* permit persons to whom the Software is furnished to do so, subject | ||
* to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR | ||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | ||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
* | ||
* | ||
* "Commons Clause" License Condition v1.0 | ||
* | ||
* The Software is provided to you by the Licensor under the License, | ||
* as defined below, subject to the following condition. | ||
* | ||
* Without limiting other conditions in the License, the grant of | ||
* rights under the License will not include, and the License does not | ||
* grant to you, the right to Sell the Software. | ||
* | ||
* For purposes of the foregoing, "Sell" means practicing any or all | ||
* of the rights granted to you under the License to provide to third | ||
* parties, for a fee or other consideration (including without | ||
* limitation fees for hosting or consulting/ support services related | ||
* to the Software), a product or service whose value derives, entirely | ||
* or substantially, from the functionality of the Software. Any license | ||
* notice or attribution required by the License must also include | ||
* this Commons Clause License Condition notice. | ||
* | ||
* Software: All X1Wallet associated files. | ||
* License: MIT | ||
* Licensor: HODL TECH PTE LTD | ||
* | ||
****************************************************************************** | ||
*/ | ||
|
||
/***************************************************************************** | ||
* INCLUDES | ||
*****************************************************************************/ | ||
|
||
#include "base_app.h" | ||
|
||
#include <stddef.h> | ||
|
||
#include "evm_main.h" | ||
|
||
/***************************************************************************** | ||
* EXTERN VARIABLES | ||
*****************************************************************************/ | ||
|
||
/** | ||
* @brief Whitelisted contracts with respective token symbol | ||
* @details A map of Ethereum contract addresses with their token symbols. These | ||
* will enable the device to verify the ERC20 token transaction in a | ||
* user-friendly manner. | ||
* | ||
* @see erc20_contracts_t | ||
*/ | ||
extern const erc20_contracts_t base_contracts[]; | ||
|
||
/***************************************************************************** | ||
* PRIVATE MACROS AND DEFINES | ||
*****************************************************************************/ | ||
|
||
/***************************************************************************** | ||
* PRIVATE TYPEDEFS | ||
*****************************************************************************/ | ||
|
||
/***************************************************************************** | ||
* STATIC FUNCTION PROTOTYPES | ||
*****************************************************************************/ | ||
|
||
/** | ||
* @brief Checks if the provided token address is whitelisted and return the | ||
* matching contract instance. | ||
* | ||
* @param address Reference to the buffer containing the token address | ||
* @param contract Pointer to store the matched contract address instance | ||
* | ||
* @return bool Indicating if the provided token address is whitelisted | ||
* @return true If the address matches to an entry in the whitelist | ||
* @return false If the address does not match to an entry in the whitelist | ||
*/ | ||
static bool is_token_whitelisted(const uint8_t *address, | ||
const erc20_contracts_t **contract); | ||
|
||
/***************************************************************************** | ||
* STATIC VARIABLES | ||
*****************************************************************************/ | ||
|
||
static const evm_config_t base_app_config = { | ||
.lunit_name = "ETH", | ||
.name = "BASE", | ||
.chain_id = 8453, | ||
|
||
// whitelisted contracts | ||
.is_token_whitelisted = is_token_whitelisted, | ||
}; | ||
|
||
static const cy_app_desc_t base_app_desc = { | ||
.id = 18, | ||
.version = | ||
{ | ||
.major = 1, | ||
.minor = 1, | ||
.patch = 0, | ||
}, | ||
.app = evm_main, | ||
.app_config = &base_app_config}; | ||
/***************************************************************************** | ||
* GLOBAL VARIABLES | ||
*****************************************************************************/ | ||
|
||
/***************************************************************************** | ||
* STATIC FUNCTIONS | ||
*****************************************************************************/ | ||
|
||
static bool is_token_whitelisted(const uint8_t *address, | ||
const erc20_contracts_t **contract) { | ||
if (NULL != contract) { | ||
*contract = NULL; | ||
} | ||
return false; | ||
} | ||
|
||
/***************************************************************************** | ||
* GLOBAL FUNCTIONS | ||
*****************************************************************************/ | ||
|
||
const cy_app_desc_t *get_base_app_desc() { | ||
return &base_app_desc; | ||
} |
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,44 @@ | ||
/** | ||
* @file BASE_app.h | ||
* @author Cypherock X1 Team | ||
* @brief BASE application configuration | ||
* @copyright Copyright (c) 2023 HODL TECH PTE LTD | ||
* <br/> You may obtain a copy of license at <a href="https://mitcc.org/" | ||
* target=_blank>https://mitcc.org/</a> | ||
*/ | ||
#ifndef BASE_APP_H | ||
#define BASE_APP_H | ||
|
||
/***************************************************************************** | ||
* INCLUDES | ||
*****************************************************************************/ | ||
|
||
#include "app_registry.h" | ||
#include "evm_context.h" | ||
/***************************************************************************** | ||
* MACROS AND DEFINES | ||
*****************************************************************************/ | ||
|
||
/// Number of entries in whitelisted contracts list | ||
#define BASE_WHITELISTED_CONTRACTS_COUNT 0 | ||
|
||
/***************************************************************************** | ||
* TYPEDEFS | ||
*****************************************************************************/ | ||
|
||
/***************************************************************************** | ||
* EXPORTED VARIABLES | ||
*****************************************************************************/ | ||
|
||
/***************************************************************************** | ||
* GLOBAL FUNCTION PROTOTYPES | ||
*****************************************************************************/ | ||
|
||
/** | ||
* @brief Returns the config for BASE chin app descriptor | ||
* | ||
* @return A const reference to cy_app_desc_t | ||
*/ | ||
const cy_app_desc_t *get_base_app_desc(); | ||
|
||
#endif // BASE_APP_H |
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,21 @@ | ||
/** | ||
* @file base.h | ||
* @author Cypherock X1 Team | ||
* @brief BASE C-Chain network config | ||
* Place to define all values specific to BASE C-Chain | ||
* @copyright Copyright (c) 2022 HODL TECH PTE LTD | ||
* <br/> You may obtain a copy of license at <a href="https://mitcc.org/" | ||
* target=_blank>https://mitcc.org/</a> | ||
* | ||
*/ | ||
#ifndef BASE_H | ||
#define BASE_H | ||
|
||
#define BASE_COIN_VERSION 0x00000000 | ||
|
||
#define BASE_MAINNET_CHAIN 8453 | ||
|
||
#define BASE_MAINNET_NAME "Base" | ||
#define BASE_TOKEN_SYMBOL "ETH" | ||
|
||
#endif |
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
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Branch out from our repo. Re-base to the "develop" branch. Kindly follow the same for sdk and cysync.
change id to 19.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also resolve the commit checks in CI