Skip to content

Commit

Permalink
Merge pull request #15 from Zondax/main
Browse files Browse the repository at this point in the history
Polkadot v10.9160.0
  • Loading branch information
bigspider authored Feb 10, 2022
2 parents 2f81408 + 0203567 commit 49bea73
Show file tree
Hide file tree
Showing 86 changed files with 33,409 additions and 19,823 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ file(GLOB_RECURSE LIB_SRC
${CMAKE_CURRENT_SOURCE_DIR}/app/src/parser.c
${CMAKE_CURRENT_SOURCE_DIR}/app/src/parser_impl.c
${CMAKE_CURRENT_SOURCE_DIR}/app/src/parser_txdef.c
${CMAKE_CURRENT_SOURCE_DIR}/app/src/substrate*.c
${CMAKE_CURRENT_SOURCE_DIR}/app/src/substrate/substrate*.c
)

add_library(app_lib STATIC ${LIB_SRC})
Expand All @@ -127,6 +127,7 @@ target_include_directories(app_lib PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/app/src
${CMAKE_CURRENT_SOURCE_DIR}/app/src/lib
${CMAKE_CURRENT_SOURCE_DIR}/app/src/common
${CMAKE_CURRENT_SOURCE_DIR}/app/src/substrate
)

##############################################################
Expand Down
649 changes: 332 additions & 317 deletions README.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions app/Makefile.version
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This is the `transaction_version` field of `Runtime`
APPVERSION_M=9
APPVERSION_M=10
# This is the `spec_version` field of `Runtime`
APPVERSION_N=9140
APPVERSION_N=9160
# This is the patch version of this release
APPVERSION_P=0
APPVERSION_P=1
49 changes: 1 addition & 48 deletions app/src/coin.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,51 +15,4 @@
********************************************************************************/
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#define CLA 0x90

#define HDPATH_LEN_DEFAULT 5
#define HDPATH_0_DEFAULT (0x80000000 | 0x2c)
#define HDPATH_1_DEFAULT (0x80000000 | 0x162) // 354 - Polkadot
#define HDPATH_1_RECOVERY (0x80000000 | 0x1b2) // 434 - Kusama

#define SK_LEN_25519 64u
#define SCALAR_LEN_ED25519 32u
#define SIG_PLUS_TYPE_LEN 65u

#define PK_LEN_25519 32u
#define MAX_SIGN_SIZE 256u
#define BLAKE2B_DIGEST_SIZE 32u

typedef enum {
key_ed25519 = 0,

#if defined(SUPPORT_SR25519)
key_sr25519 = 1
#endif

} key_kind_e;

// Coin Specific
#define PK_ADDRESS_TYPE COIN_ADDR_TYPE_POLKADOT
#define SUPPORTED_TX_VERSION_CURRENT LEDGER_MAJOR_VERSION
#define SUPPORTED_TX_VERSION_PREVIOUS (LEDGER_MAJOR_VERSION - 1)
#define SUPPORTED_SPEC_VERSION LEDGER_MINOR_VERSION
#define SUPPORTED_MINIMUM_SPEC_VERSION 23

#define COIN_AMOUNT_DECIMAL_PLACES 10

#define COIN_GENESIS_HASH "91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3"
#define COIN_NAME "Polkadot"
#define COIN_TICKER "DOT "

#define COIN_SECRET_REQUIRED_CLICKS 10

#include "coin_standard.h"

#ifdef __cplusplus
}
#endif
#include "substrate_coin.h"
30 changes: 0 additions & 30 deletions app/src/coin_ss58.h

This file was deleted.

1 change: 1 addition & 0 deletions app/src/common/parser_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ typedef enum {
parser_unexpected_callIndex,
parser_unexpected_unparsed_bytes,
parser_print_not_supported,
parser_tx_nesting_not_supported,
parser_tx_nesting_limit_reached,
parser_tx_call_vec_too_large,
} parser_error_t;
Expand Down
1 change: 0 additions & 1 deletion app/src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include "app_mode.h"
#include "parser.h"
#include "coin.h"
#include "coin_ss58.h"
#include "substrate_dispatch.h"

#if defined(TARGET_NANOX)
Expand Down
5 changes: 3 additions & 2 deletions app/src/parser_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "coin.h"
#include "crypto_helper.h"
#include "bignum.h"
#include "coin_ss58.h"
#include "substrate_types.h"
#include "substrate_dispatch.h"

Expand Down Expand Up @@ -85,6 +84,8 @@ const char *parser_getErrorDescription(parser_error_t err) {
return "Unexpected unparsed bytes";
case parser_print_not_supported:
return "Value cannot be printed";
case parser_tx_nesting_not_supported:
return "Call nesting not supported";
case parser_tx_nesting_limit_reached:
return "Max nested calls reached";
case parser_tx_call_vec_too_large:
Expand Down Expand Up @@ -316,7 +317,7 @@ parser_error_t _toStringCompactBalance(const pd_CompactBalance_t *v,
parser_error_t _checkVersions(parser_context_t *c) {
// Methods are not length delimited so in order to retrieve the specVersion
// it is necessary to parse from the back.
// The transaction is expect to end in
// The transaction is expected to end in
// [4 bytes] specVersion
// [4 bytes] transactionVersion
// [32 bytes] genesisHash
Expand Down
74 changes: 74 additions & 0 deletions app/src/substrate/substrate_coin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*******************************************************************************
* (c) 2019 - 2022 Zondax GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
********************************************************************************/
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#define COIN_ADDR_TYPE 0
#define CLA 0x90

#define HDPATH_LEN_DEFAULT 5
#define HDPATH_0_DEFAULT (0x80000000 | 0x2c)
#define HDPATH_1_DEFAULT (0x80000000 | 0x162)
#define HDPATH_1_RECOVERY (0x80000000 | 0x1b2)

#define HDPATH_2_DEFAULT (0x80000000u | 0u)
#define HDPATH_3_DEFAULT (0u)
#define HDPATH_4_DEFAULT (0u)

#define SK_LEN_25519 64u
#define SCALAR_LEN_ED25519 32u
#define SIG_PLUS_TYPE_LEN 65u

#define PK_LEN_25519 32u
#define MAX_SIGN_SIZE 256u
#define BLAKE2B_DIGEST_SIZE 32u

typedef enum {
key_ed25519 = 0,

#if defined(SUPPORT_SR25519)
key_sr25519 = 1
#endif

} key_kind_e;

// Coin Specific
#define PK_ADDRESS_TYPE COIN_ADDR_TYPE
#define SUPPORTED_TX_VERSION_CURRENT LEDGER_MAJOR_VERSION
#define SUPPORTED_TX_VERSION_PREVIOUS (LEDGER_MAJOR_VERSION - 1)
#define SUPPORTED_SPEC_VERSION (LEDGER_MINOR_VERSION + 0)
#define SUPPORTED_MINIMUM_SPEC_VERSION 9000

#define COIN_AMOUNT_DECIMAL_PLACES 10

#define COIN_GENESIS_HASH "91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3"
#define COIN_NAME "Polkadot"
#define COIN_TICKER "DOT "

#define COIN_SECRET_REQUIRED_CLICKS 10

#define MENU_MAIN_APP_LINE1 "Polkadot"
#define MENU_MAIN_APP_LINE2 "Ready"
#define MENU_MAIN_APP_LINE2_SECRET "DOT RECOVERY"
#define APPVERSION_LINE1 "Polkadot"
#define APPVERSION_LINE2 "v" APPVERSION

#ifdef __cplusplus
}
#endif
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/*******************************************************************************
* (c) 2019 Zondax GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
********************************************************************************/
* (c) 2019 - 2022 Zondax GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
********************************************************************************/
#include "substrate_dispatch.h"
#include "parser_impl.h"

Expand All @@ -26,26 +26,32 @@ parser_error_t _readMethod(
pd_Method_t* method)
{
switch (c->tx_obj->transactionVersion) {
case 10:
return _readMethod_V10(c, moduleIdx, callIdx, &method->V10);
case 9:
return _readMethod_V9(c, moduleIdx, callIdx, &method->V9);
default:
return parser_not_supported;
return parser_tx_version_not_supported;
}
}

uint8_t _getMethod_NumItems(uint32_t transactionVersion, uint8_t moduleIdx, uint8_t callIdx)
{
switch (transactionVersion) {
case 10:
return _getMethod_NumItems_V10(moduleIdx, callIdx);
case 9:
return _getMethod_NumItems_V9(moduleIdx, callIdx);
default:
return parser_not_supported;
return parser_tx_version_not_supported;
}
}

const char* _getMethod_ModuleName(uint32_t transactionVersion, uint8_t moduleIdx)
{
switch (transactionVersion) {
case 10:
return _getMethod_ModuleName_V10(moduleIdx);
case 9:
return _getMethod_ModuleName_V9(moduleIdx);
default:
Expand All @@ -56,6 +62,8 @@ const char* _getMethod_ModuleName(uint32_t transactionVersion, uint8_t moduleIdx
const char* _getMethod_Name(uint32_t transactionVersion, uint8_t moduleIdx, uint8_t callIdx)
{
switch (transactionVersion) {
case 10:
return _getMethod_Name_V10(moduleIdx, callIdx);
case 9:
return _getMethod_Name_V9(moduleIdx, callIdx);
default:
Expand All @@ -66,6 +74,8 @@ const char* _getMethod_Name(uint32_t transactionVersion, uint8_t moduleIdx, uint
const char* _getMethod_ItemName(uint32_t transactionVersion, uint8_t moduleIdx, uint8_t callIdx, uint8_t itemIdx)
{
switch (transactionVersion) {
case 10:
return _getMethod_ItemName_V10(moduleIdx, callIdx, itemIdx);
case 9:
return _getMethod_ItemName_V9(moduleIdx, callIdx, itemIdx);
default:
Expand All @@ -78,17 +88,22 @@ parser_error_t _getMethod_ItemValue(uint32_t transactionVersion, pd_Method_t* m,
uint8_t pageIdx, uint8_t* pageCount)
{
switch (transactionVersion) {
case 10:
return _getMethod_ItemValue_V10(&m->V10, moduleIdx, callIdx, itemIdx, outValue,
outValueLen, pageIdx, pageCount);
case 9:
return _getMethod_ItemValue_V9(&m->V9, moduleIdx, callIdx, itemIdx, outValue,
outValueLen, pageIdx, pageCount);
default:
return parser_not_supported;
return parser_tx_version_not_supported;
}
}

bool _getMethod_ItemIsExpert(uint32_t transactionVersion, uint8_t moduleIdx, uint8_t callIdx, uint8_t itemIdx)
{
switch (transactionVersion) {
case 10:
return _getMethod_ItemIsExpert_V10(moduleIdx, callIdx, itemIdx);
case 9:
return _getMethod_ItemIsExpert_V9(moduleIdx, callIdx, itemIdx);
default:
Expand All @@ -99,6 +114,8 @@ bool _getMethod_ItemIsExpert(uint32_t transactionVersion, uint8_t moduleIdx, uin
bool _getMethod_IsNestingSupported(uint32_t transactionVersion, uint8_t moduleIdx, uint8_t callIdx)
{
switch (transactionVersion) {
case 10:
return _getMethod_IsNestingSupported_V10(moduleIdx, callIdx);
case 9:
return _getMethod_IsNestingSupported_V9(moduleIdx, callIdx);
default:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/*******************************************************************************
* (c) 2019 Zondax GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
********************************************************************************/
* (c) 2019 - 2022 Zondax GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
********************************************************************************/
#pragma once

#ifdef __cplusplus
Expand All @@ -21,6 +21,7 @@ extern "C" {

#include "parser_common.h"
#include "stdbool.h"
#include "substrate_dispatch_V10.h"
#include "substrate_dispatch_V9.h"
#include <stddef.h>
#include <stdint.h>
Expand All @@ -32,6 +33,9 @@ extern "C" {
{ \
switch (txVersion) { \
\
case 10: \
return PD_CALL_##CALL##_V10; \
\
case 9: \
return PD_CALL_##CALL##_V9; \
\
Expand Down
Loading

0 comments on commit 49bea73

Please sign in to comment.