Skip to content

Commit

Permalink
Merge pull request #117 from Zondax/improve_error_code
Browse files Browse the repository at this point in the history
Improve error code
  • Loading branch information
jleni authored Dec 28, 2021
2 parents 2f2b12a + 8b0258d commit d95b54e
Show file tree
Hide file tree
Showing 26 changed files with 8,241 additions and 8,128 deletions.
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Ledger Polkadot app

[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![GithubActions](https://github.com/zondax/ledger-polkadot/actions/workflows/main.yml/badge.svg)](https://github.com/Zondax/ledger-polkadot/blob/main/.github/workflows/main.yaml)

Expand All @@ -9,8 +8,7 @@

_Please visit our website at [zondax.ch](zondax.ch)_

---

------------------
This project contains the Kusama app (https://kusama.network/) for Ledger Nano S and X.

- Ledger Nano S/X BOLOS app
Expand All @@ -27,7 +25,6 @@ Please:
- **Do not use in production**
- **Do not use a Ledger device with funds for development purposes.**
- **Have a separate and marked device that is used ONLY for development and testing**

# Polkadot 9.9140.x

## System
Expand Down Expand Up @@ -238,7 +235,7 @@ Please:
|Mint claim | | | | `EthereumAddress` who <br/>`Balance` amount <br/>`OptionTupleBalanceOfTBalanceOfTBlockNumber` vesting_schedule <br/>`OptionStatementKind` statement <br/> |
|Claim attest | | :heavy_check_mark: | | `AccountId` dest <br/>`EcdsaSignature` ethereum_signature <br/>`Bytes` statement <br/> |
|Attest | | :heavy_check_mark: | | `Bytes` statement <br/> |
|Move claim | | | | `EthereumAddress` old <br/>`EthereumAddress` new_ <br/>`OptionAccountId` maybe_preclaim <br/> |
|Move claim | | :heavy_check_mark: | | `EthereumAddress` old <br/>`EthereumAddress` new_ <br/>`OptionAccountId` maybe_preclaim <br/> |

## Vesting

Expand Down
2 changes: 1 addition & 1 deletion app/Makefile.version
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ APPVERSION_M=9
# This is the `spec_version` field of `Runtime`
APPVERSION_N=9140
# This is the patch version of this release
APPVERSION_P=0
APPVERSION_P=1
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
4 changes: 3 additions & 1 deletion app/src/parser_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,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 +318,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
34 changes: 17 additions & 17 deletions app/src/substrate_dispatch.c
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 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 @@ -29,7 +29,7 @@ parser_error_t _readMethod(
case 9:
return _readMethod_V9(c, moduleIdx, callIdx, &method->V9);
default:
return parser_not_supported;
return parser_tx_version_not_supported;
}
}

Expand All @@ -39,7 +39,7 @@ uint8_t _getMethod_NumItems(uint32_t transactionVersion, uint8_t moduleIdx, uint
case 9:
return _getMethod_NumItems_V9(moduleIdx, callIdx);
default:
return parser_not_supported;
return parser_tx_version_not_supported;
}
}

Expand Down Expand Up @@ -82,7 +82,7 @@ parser_error_t _getMethod_ItemValue(uint32_t transactionVersion, pd_Method_t* m,
return _getMethod_ItemValue_V9(&m->V9, moduleIdx, callIdx, itemIdx, outValue,
outValueLen, pageIdx, pageCount);
default:
return parser_not_supported;
return parser_tx_version_not_supported;
}
}

Expand Down
28 changes: 14 additions & 14 deletions app/src/substrate_dispatch.h
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 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 Down
76 changes: 61 additions & 15 deletions app/src/substrate_dispatch_V9.c
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 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_V9.h"
#include "substrate_strings.h"
Expand Down Expand Up @@ -670,6 +670,15 @@ __Z_INLINE parser_error_t _readMethod_claims_attest_V9(
return parser_ok;
}

__Z_INLINE parser_error_t _readMethod_claims_move_claim_V9(
parser_context_t* c, pd_claims_move_claim_V9_t* m)
{
CHECK_ERROR(_readEthereumAddress_V9(c, &m->old))
CHECK_ERROR(_readEthereumAddress_V9(c, &m->new_))
CHECK_ERROR(_readOptionAccountId_V9(c, &m->maybe_preclaim))
return parser_ok;
}

__Z_INLINE parser_error_t _readMethod_vesting_vest_V9(
parser_context_t* c, pd_vesting_vest_V9_t* m)
{
Expand Down Expand Up @@ -1568,6 +1577,9 @@ parser_error_t _readMethod_V9(
case 6147: /* module 24 call 3 */
CHECK_ERROR(_readMethod_claims_attest_V9(c, &method->basic.claims_attest_V9))
break;
case 6148: /* module 24 call 4 */
CHECK_ERROR(_readMethod_claims_move_claim_V9(c, &method->basic.claims_move_claim_V9))
break;
case 6400: /* module 25 call 0 */
CHECK_ERROR(_readMethod_vesting_vest_V9(c, &method->basic.vesting_vest_V9))
break;
Expand Down Expand Up @@ -1822,7 +1834,7 @@ parser_error_t _readMethod_V9(
break;
#endif
default:
return parser_not_supported;
return parser_unexpected_callIndex;
}

return parser_ok;
Expand Down Expand Up @@ -2623,6 +2635,8 @@ uint8_t _getMethod_NumItems_V9(uint8_t moduleIdx, uint8_t callIdx)
return 3;
case 6147: /* module 24 call 3 */
return 1;
case 6148: /* module 24 call 4 */
return 3;
case 6400: /* module 25 call 0 */
return 0;
case 6401: /* module 25 call 1 */
Expand Down Expand Up @@ -3489,6 +3503,17 @@ const char* _getMethod_ItemName_V9(uint8_t moduleIdx, uint8_t callIdx, uint8_t i
default:
return NULL;
}
case 6148: /* module 24 call 4 */
switch (itemIdx) {
case 0:
return STR_IT_old;
case 1:
return STR_IT_new_;
case 2:
return STR_IT_maybe_preclaim;
default:
return NULL;
}
case 6400: /* module 25 call 0 */
switch (itemIdx) {
default:
Expand Down Expand Up @@ -5209,6 +5234,26 @@ parser_error_t _getMethod_ItemValue_V9(
default:
return parser_no_data;
}
case 6148: /* module 24 call 4 */
switch (itemIdx) {
case 0: /* claims_move_claim_V9 - old */;
return _toStringEthereumAddress_V9(
&m->basic.claims_move_claim_V9.old,
outValue, outValueLen,
pageIdx, pageCount);
case 1: /* claims_move_claim_V9 - new_ */;
return _toStringEthereumAddress_V9(
&m->basic.claims_move_claim_V9.new_,
outValue, outValueLen,
pageIdx, pageCount);
case 2: /* claims_move_claim_V9 - maybe_preclaim */;
return _toStringOptionAccountId_V9(
&m->basic.claims_move_claim_V9.maybe_preclaim,
outValue, outValueLen,
pageIdx, pageCount);
default:
return parser_no_data;
}
case 6400: /* module 25 call 0 */
switch (itemIdx) {
default:
Expand Down Expand Up @@ -6330,6 +6375,7 @@ bool _getMethod_IsNestingSupported_V9(uint8_t moduleIdx, uint8_t callIdx)
case 6144: // Claims:Claim
case 6146: // Claims:Claim attest
case 6147: // Claims:Attest
case 6148: // Claims:Move claim
case 6400: // Vesting:Vest
case 6401: // Vesting:Vest other
case 6404: // Vesting:Merge schedules
Expand Down
28 changes: 14 additions & 14 deletions app/src/substrate_dispatch_V9.h
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 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 Down
28 changes: 14 additions & 14 deletions app/src/substrate_functions.h
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 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 Down
28 changes: 14 additions & 14 deletions app/src/substrate_functions_V9.h
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 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 Down
Loading

0 comments on commit d95b54e

Please sign in to comment.