@rango-dev/provider-trezor 0.3.1-next.1 → 0.3.1-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/provider-trezor",
3
- "version": "0.3.1-next.1",
3
+ "version": "0.3.1-next.3",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
@@ -25,7 +25,7 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "@rango-dev/signer-evm": "^0.29.1-next.0",
28
- "@rango-dev/wallets-shared": "^0.36.1-next.0",
28
+ "@rango-dev/wallets-shared": "^0.36.1-next.1",
29
29
  "@trezor/connect-web": "^9.2.4",
30
30
  "ethers": "^6.11.1",
31
31
  "rango-types": "^0.1.59"
@@ -33,4 +33,4 @@
33
33
  "publishConfig": {
34
34
  "access": "public"
35
35
  }
36
- }
36
+ }
package/src/helpers.ts CHANGED
@@ -5,6 +5,10 @@ import { ETHEREUM_CHAIN_ID, Networks } from '@rango-dev/wallets-shared';
5
5
 
6
6
  import { getDerivationPath } from './state.js';
7
7
 
8
+ export const trezorErrorMessages: { [statusCode: string]: string } = {
9
+ Failure_ActionCancelled: 'User rejected the transaction.',
10
+ };
11
+
8
12
  // `@trezor/connect-web` is commonjs, when we are importing it dynamically, it has some differences in different tooling. for example vite (you can check widget-examples), goes throw error. this is a workaround for solving this interop issue.
9
13
  export async function getTrezorModule() {
10
14
  const mod = await import('@trezor/connect-web');
@@ -7,6 +7,7 @@ import { type GenericSigner } from 'rango-types';
7
7
  import {
8
8
  getTrezorErrorMessage,
9
9
  getTrezorModule,
10
+ trezorErrorMessages,
10
11
  valueToHex,
11
12
  } from '../helpers.js';
12
13
  import { getDerivationPath } from '../state.js';
@@ -69,8 +70,11 @@ export class EthereumSigner implements GenericSigner<EvmTransaction> {
69
70
  path: getDerivationPath(),
70
71
  transaction,
71
72
  });
73
+
72
74
  if (!success) {
73
- throw new Error(payload.error);
75
+ const errorMessage =
76
+ trezorErrorMessages[payload?.code || ''] || payload.error;
77
+ throw new Error(errorMessage);
74
78
  }
75
79
  const { r, s, v } = payload;
76
80