@onekeyfe/hd-core 1.0.12-alpha.2 → 1.0.12

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.
@@ -1,12 +1,20 @@
1
1
  import { TonSignMessage as HardwareTonSignMessage } from '@onekeyfe/hd-transport';
2
2
  import { BaseMethod } from '../BaseMethod';
3
+ import { DeviceFirmwareRange } from '../../types';
3
4
  export default class TonSignMessage extends BaseMethod<HardwareTonSignMessage> {
4
5
  init(): void;
5
6
  getVersionRange(): {
6
7
  model_touch: {
7
8
  min: string;
8
9
  };
10
+ classic1s: {
11
+ min: string;
12
+ };
9
13
  };
14
+ getSupportJettonAmountBytesVersionRange(): DeviceFirmwareRange;
15
+ checkSupportJettonAmountBytes(): boolean;
16
+ getFixCommentErrorVersionRange(): DeviceFirmwareRange;
17
+ checkFixCommentError(): void;
10
18
  run(): Promise<{
11
19
  skip_validate: boolean;
12
20
  signature?: string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"TonSignMessage.d.ts","sourceRoot":"","sources":["../../../src/api/ton/TonSignMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,IAAI,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAIlF,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK3C,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,UAAU,CAAC,sBAAsB,CAAC;IAC5E,IAAI;IAuDJ,eAAe;;;;;IAQT,GAAG;;;;;CAUV"}
1
+ {"version":3,"file":"TonSignMessage.d.ts","sourceRoot":"","sources":["../../../src/api/ton/TonSignMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,IAAI,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAOlF,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,mBAAmB,EAA4C,MAAM,aAAa,CAAC;AAI5F,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,UAAU,CAAC,sBAAsB,CAAC;IAC5E,IAAI;IAsDJ,eAAe;;;;;;;;IAWf,uCAAuC,IAAI,mBAAmB;IAQ9D,6BAA6B;IAkB7B,8BAA8B,IAAI,mBAAmB;IAQrD,oBAAoB;IA4Bd,GAAG;;;;;CAyBV"}
package/dist/index.d.ts CHANGED
@@ -1984,21 +1984,21 @@ type TonSignMessageParams = {
1984
1984
  destination: string;
1985
1985
  jettonMasterAddress?: string;
1986
1986
  jettonWalletAddress?: string;
1987
- tonAmount: number;
1988
- jettonAmount?: number;
1989
- fwdFee?: number;
1987
+ tonAmount: UintType;
1988
+ jettonAmount?: UintType;
1989
+ fwdFee?: UintType;
1990
1990
  comment?: string;
1991
1991
  isRawData?: boolean;
1992
1992
  mode?: number;
1993
1993
  seqno: number;
1994
- expireAt: number;
1994
+ expireAt: UintType;
1995
1995
  walletVersion?: TonWalletVersion;
1996
1996
  walletId?: number;
1997
1997
  workchain?: TonWorkChain;
1998
1998
  isBounceable?: boolean;
1999
1999
  isTestnetOnly?: boolean;
2000
2000
  extDestination?: string[];
2001
- extTonAmount?: number[];
2001
+ extTonAmount?: UintType[];
2002
2002
  extPayload?: string[];
2003
2003
  };
2004
2004
  type TonSignedMessageResponse = {
@@ -2010,7 +2010,7 @@ type TonSignProofParams = {
2010
2010
  path: string | number[];
2011
2011
  appdomain: string;
2012
2012
  comment?: string;
2013
- expireAt: number;
2013
+ expireAt: UintType;
2014
2014
  walletVersion?: TonWalletVersion;
2015
2015
  walletId?: number;
2016
2016
  workchain?: TonWorkChain;
package/dist/index.js CHANGED
@@ -11782,6 +11782,10 @@ var nested$1 = {
11782
11782
  rule: "repeated",
11783
11783
  type: "string",
11784
11784
  id: 20
11785
+ },
11786
+ jetton_amount_bytes: {
11787
+ type: "bytes",
11788
+ id: 21
11785
11789
  }
11786
11790
  }
11787
11791
  },
@@ -34701,14 +34705,14 @@ class TonSignMessage extends BaseMethod {
34701
34705
  { name: 'destination', type: 'string' },
34702
34706
  { name: 'jettonMasterAddress', type: 'string' },
34703
34707
  { name: 'jettonWalletAddress', type: 'string' },
34704
- { name: 'tonAmount', type: 'number' },
34705
- { name: 'jettonAmount', type: 'number' },
34706
- { name: 'fwdFee', type: 'number' },
34708
+ { name: 'tonAmount' },
34709
+ { name: 'jettonAmount' },
34710
+ { name: 'fwdFee' },
34707
34711
  { name: 'comment', type: 'string' },
34708
34712
  { name: 'isRawData', type: 'boolean' },
34709
34713
  { name: 'mode', type: 'number' },
34710
34714
  { name: 'seqno', type: 'number' },
34711
- { name: 'expireAt', type: 'number' },
34715
+ { name: 'expireAt' },
34712
34716
  { name: 'walletVersion' },
34713
34717
  { name: 'walletId', type: 'number' },
34714
34718
  { name: 'workchain' },
@@ -34726,7 +34730,6 @@ class TonSignMessage extends BaseMethod {
34726
34730
  jetton_master_address: this.payload.jettonMasterAddress,
34727
34731
  jetton_wallet_address: this.payload.jettonWalletAddress,
34728
34732
  ton_amount: this.payload.tonAmount,
34729
- jetton_amount: this.payload.jettonAmount,
34730
34733
  fwd_fee: this.payload.fwdFee,
34731
34734
  comment: this.payload.comment,
34732
34735
  mode: this.payload.mode,
@@ -34748,10 +34751,64 @@ class TonSignMessage extends BaseMethod {
34748
34751
  model_touch: {
34749
34752
  min: '4.10.0',
34750
34753
  },
34754
+ classic1s: {
34755
+ min: '3.10.0',
34756
+ },
34757
+ };
34758
+ }
34759
+ getSupportJettonAmountBytesVersionRange() {
34760
+ return {
34761
+ pro: {
34762
+ min: '4.10.2',
34763
+ },
34764
+ };
34765
+ }
34766
+ checkSupportJettonAmountBytes() {
34767
+ var _a;
34768
+ const firmwareVersion = (_a = getDeviceFirmwareVersion(this.device.features)) === null || _a === void 0 ? void 0 : _a.join('.');
34769
+ const versionRange = getMethodVersionRange(this.device.features, type => this.getSupportJettonAmountBytesVersionRange()[type]);
34770
+ if (!versionRange) {
34771
+ return true;
34772
+ }
34773
+ if (semver__default["default"].valid(firmwareVersion) && semver__default["default"].gte(firmwareVersion, versionRange.min)) {
34774
+ return true;
34775
+ }
34776
+ return false;
34777
+ }
34778
+ getFixCommentErrorVersionRange() {
34779
+ return {
34780
+ pro: {
34781
+ min: '4.10.1',
34782
+ },
34751
34783
  };
34752
34784
  }
34785
+ checkFixCommentError() {
34786
+ var _a;
34787
+ const { comment, jettonAmount } = this.payload;
34788
+ if (lodash.isEmpty(comment) || jettonAmount === null || jettonAmount === undefined) {
34789
+ return;
34790
+ }
34791
+ const firmwareVersion = (_a = getDeviceFirmwareVersion(this.device.features)) === null || _a === void 0 ? void 0 : _a.join('.');
34792
+ const versionRange = getMethodVersionRange(this.device.features, type => this.getFixCommentErrorVersionRange()[type]);
34793
+ if (!versionRange) {
34794
+ return;
34795
+ }
34796
+ if (semver__default["default"].valid(firmwareVersion) && semver__default["default"].lt(firmwareVersion, versionRange.min)) {
34797
+ throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodNeedUpgradeFirmware, `Device firmware version is too low, please update to ${versionRange.min}`, { current: firmwareVersion, require: versionRange.min });
34798
+ }
34799
+ }
34753
34800
  run() {
34754
34801
  return __awaiter(this, void 0, void 0, function* () {
34802
+ this.checkFixCommentError();
34803
+ const { jettonAmount } = this.payload;
34804
+ if (jettonAmount) {
34805
+ if (this.checkSupportJettonAmountBytes()) {
34806
+ this.params.jetton_amount_bytes = stripHexStartZeroes(formatAnyHex(new BigNumber__default["default"](jettonAmount).toString(16)));
34807
+ }
34808
+ else {
34809
+ this.params.jetton_amount = jettonAmount;
34810
+ }
34811
+ }
34755
34812
  const deviceType = getDeviceType(this.device.features);
34756
34813
  const res = yield this.device.commands.typedCall('TonSignMessage', 'TonSignedMessage', Object.assign({}, this.params));
34757
34814
  return Promise.resolve(Object.assign(Object.assign({}, res.message), { skip_validate: DeviceModelToTypes.model_mini.includes(deviceType) }));
@@ -34767,7 +34824,7 @@ class TonSignProof extends BaseMethod {
34767
34824
  { name: 'path', required: true },
34768
34825
  { name: 'appdomain', type: 'string' },
34769
34826
  { name: 'comment', type: 'string' },
34770
- { name: 'expireAt', type: 'number' },
34827
+ { name: 'expireAt' },
34771
34828
  { name: 'walletVersion' },
34772
34829
  { name: 'walletId', type: 'number' },
34773
34830
  { name: 'workchain' },
@@ -1,25 +1,25 @@
1
- import { TonSignedMessage, TonWalletVersion, TonWorkChain } from '@onekeyfe/hd-transport';
1
+ import type { TonSignedMessage, TonWalletVersion, TonWorkChain, UintType } from '@onekeyfe/hd-transport';
2
2
  import type { CommonParams, Response } from '../params';
3
3
  export type TonSignMessageParams = {
4
4
  path: string | number[];
5
5
  destination: string;
6
6
  jettonMasterAddress?: string;
7
7
  jettonWalletAddress?: string;
8
- tonAmount: number;
9
- jettonAmount?: number;
10
- fwdFee?: number;
8
+ tonAmount: UintType;
9
+ jettonAmount?: UintType;
10
+ fwdFee?: UintType;
11
11
  comment?: string;
12
12
  isRawData?: boolean;
13
13
  mode?: number;
14
14
  seqno: number;
15
- expireAt: number;
15
+ expireAt: UintType;
16
16
  walletVersion?: TonWalletVersion;
17
17
  walletId?: number;
18
18
  workchain?: TonWorkChain;
19
19
  isBounceable?: boolean;
20
20
  isTestnetOnly?: boolean;
21
21
  extDestination?: string[];
22
- extTonAmount?: number[];
22
+ extTonAmount?: UintType[];
23
23
  extPayload?: string[];
24
24
  };
25
25
  export type TonSignedMessageResponse = {
@@ -1 +1 @@
1
- {"version":3,"file":"tonSignMessage.d.ts","sourceRoot":"","sources":["../../../src/types/api/tonSignMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC1F,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAExD,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,gBAAgB,CAAC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,aAAa,EAAE,OAAO,CAAC;CACxB,GAAG,gBAAgB,CAAC;AAErB,MAAM,CAAC,OAAO,UAAU,cAAc,CACpC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,YAAY,GAAG,oBAAoB,GAC1C,QAAQ,CAAC,wBAAwB,CAAC,CAAC"}
1
+ {"version":3,"file":"tonSignMessage.d.ts","sourceRoot":"","sources":["../../../src/types/api/tonSignMessage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACT,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAExD,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,SAAS,EAAE,QAAQ,CAAC;IACpB,YAAY,CAAC,EAAE,QAAQ,CAAC;IACxB,MAAM,CAAC,EAAE,QAAQ,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,QAAQ,CAAC;IACnB,aAAa,CAAC,EAAE,gBAAgB,CAAC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,YAAY,CAAC,EAAE,QAAQ,EAAE,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,aAAa,EAAE,OAAO,CAAC;CACxB,GAAG,gBAAgB,CAAC;AAErB,MAAM,CAAC,OAAO,UAAU,cAAc,CACpC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,YAAY,GAAG,oBAAoB,GAC1C,QAAQ,CAAC,wBAAwB,CAAC,CAAC"}
@@ -1,10 +1,10 @@
1
- import { TonSignedProof, TonWalletVersion, TonWorkChain } from '@onekeyfe/hd-transport';
1
+ import type { TonSignedProof, TonWalletVersion, TonWorkChain, UintType } from '@onekeyfe/hd-transport';
2
2
  import type { CommonParams, Response } from '../params';
3
3
  export type TonSignProofParams = {
4
4
  path: string | number[];
5
5
  appdomain: string;
6
6
  comment?: string;
7
- expireAt: number;
7
+ expireAt: UintType;
8
8
  walletVersion?: TonWalletVersion;
9
9
  walletId?: number;
10
10
  workchain?: TonWorkChain;
@@ -1 +1 @@
1
- {"version":3,"file":"tonSignProof.d.ts","sourceRoot":"","sources":["../../../src/types/api/tonSignProof.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACxF,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAExD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,gBAAgB,CAAC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,YAAY,GAAG,kBAAkB,GACxC,QAAQ,CAAC,cAAc,CAAC,CAAC"}
1
+ {"version":3,"file":"tonSignProof.d.ts","sourceRoot":"","sources":["../../../src/types/api/tonSignProof.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACT,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAExD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,QAAQ,CAAC;IACnB,aAAa,CAAC,EAAE,gBAAgB,CAAC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,YAAY,GAAG,kBAAkB,GACxC,QAAQ,CAAC,cAAc,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hd-core",
3
- "version": "1.0.12-alpha.2",
3
+ "version": "1.0.12",
4
4
  "description": "> TODO: description",
5
5
  "author": "OneKey",
6
6
  "homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
@@ -25,8 +25,8 @@
25
25
  "url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
26
26
  },
27
27
  "dependencies": {
28
- "@onekeyfe/hd-shared": "^1.0.12-alpha.2",
29
- "@onekeyfe/hd-transport": "^1.0.12-alpha.2",
28
+ "@onekeyfe/hd-shared": "^1.0.12",
29
+ "@onekeyfe/hd-transport": "^1.0.12",
30
30
  "axios": "^0.27.2",
31
31
  "bignumber.js": "^9.0.2",
32
32
  "bytebuffer": "^5.0.1",
@@ -44,5 +44,5 @@
44
44
  "@types/semver": "^7.3.9",
45
45
  "ripple-keypairs": "^1.1.4"
46
46
  },
47
- "gitHead": "237c606774a2f15823f3590c23b0dbc57114e88b"
47
+ "gitHead": "f53726e2ea18c2f0eff008b862713e72b5aa2313"
48
48
  }
@@ -1,11 +1,15 @@
1
1
  import { TonSignMessage as HardwareTonSignMessage } from '@onekeyfe/hd-transport';
2
-
2
+ import semver from 'semver';
3
+ import BigNumber from 'bignumber.js';
4
+ import { isEmpty } from 'lodash';
5
+ import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
3
6
  import { UI_REQUEST } from '../../constants/ui-request';
4
7
  import { validatePath } from '../helpers/pathUtils';
5
8
  import { BaseMethod } from '../BaseMethod';
6
9
  import { validateParams } from '../helpers/paramsValidator';
7
- import { DeviceModelToTypes, TonSignMessageParams } from '../../types';
8
- import { getDeviceType } from '../../utils';
10
+ import { DeviceFirmwareRange, DeviceModelToTypes, TonSignMessageParams } from '../../types';
11
+ import { getDeviceFirmwareVersion, getDeviceType, getMethodVersionRange } from '../../utils';
12
+ import { formatAnyHex, stripHexStartZeroes } from '../helpers/hexUtils';
9
13
 
10
14
  export default class TonSignMessage extends BaseMethod<HardwareTonSignMessage> {
11
15
  init() {
@@ -18,14 +22,14 @@ export default class TonSignMessage extends BaseMethod<HardwareTonSignMessage> {
18
22
  { name: 'destination', type: 'string' },
19
23
  { name: 'jettonMasterAddress', type: 'string' },
20
24
  { name: 'jettonWalletAddress', type: 'string' },
21
- { name: 'tonAmount', type: 'number' },
22
- { name: 'jettonAmount', type: 'number' },
23
- { name: 'fwdFee', type: 'number' },
25
+ { name: 'tonAmount' },
26
+ { name: 'jettonAmount' },
27
+ { name: 'fwdFee' },
24
28
  { name: 'comment', type: 'string' },
25
29
  { name: 'isRawData', type: 'boolean' },
26
30
  { name: 'mode', type: 'number' },
27
31
  { name: 'seqno', type: 'number' },
28
- { name: 'expireAt', type: 'number' },
32
+ { name: 'expireAt' },
29
33
  { name: 'walletVersion' },
30
34
  { name: 'walletId', type: 'number' },
31
35
  { name: 'workchain' },
@@ -45,7 +49,6 @@ export default class TonSignMessage extends BaseMethod<HardwareTonSignMessage> {
45
49
  jetton_master_address: this.payload.jettonMasterAddress,
46
50
  jetton_wallet_address: this.payload.jettonWalletAddress,
47
51
  ton_amount: this.payload.tonAmount,
48
- jetton_amount: this.payload.jettonAmount,
49
52
  fwd_fee: this.payload.fwdFee,
50
53
  comment: this.payload.comment,
51
54
  mode: this.payload.mode,
@@ -68,10 +71,90 @@ export default class TonSignMessage extends BaseMethod<HardwareTonSignMessage> {
68
71
  model_touch: {
69
72
  min: '4.10.0',
70
73
  },
74
+ classic1s: {
75
+ min: '3.10.0',
76
+ },
77
+ };
78
+ }
79
+
80
+ getSupportJettonAmountBytesVersionRange(): DeviceFirmwareRange {
81
+ return {
82
+ pro: {
83
+ min: '4.10.2',
84
+ },
85
+ };
86
+ }
87
+
88
+ checkSupportJettonAmountBytes() {
89
+ const firmwareVersion = getDeviceFirmwareVersion(this.device.features)?.join('.');
90
+ const versionRange = getMethodVersionRange(
91
+ this.device.features,
92
+ type => this.getSupportJettonAmountBytesVersionRange()[type]
93
+ );
94
+
95
+ if (!versionRange) {
96
+ // Equipment that does not need to be repaired
97
+ return true;
98
+ }
99
+
100
+ if (semver.valid(firmwareVersion) && semver.gte(firmwareVersion, versionRange.min)) {
101
+ return true;
102
+ }
103
+ return false;
104
+ }
105
+
106
+ getFixCommentErrorVersionRange(): DeviceFirmwareRange {
107
+ return {
108
+ pro: {
109
+ min: '4.10.1',
110
+ },
71
111
  };
72
112
  }
73
113
 
114
+ checkFixCommentError() {
115
+ // The issue of missing comments when transferring tokens.
116
+ const { comment, jettonAmount } = this.payload;
117
+
118
+ if (isEmpty(comment) || jettonAmount === null || jettonAmount === undefined) {
119
+ return;
120
+ }
121
+
122
+ const firmwareVersion = getDeviceFirmwareVersion(this.device.features)?.join('.');
123
+ const versionRange = getMethodVersionRange(
124
+ this.device.features,
125
+ type => this.getFixCommentErrorVersionRange()[type]
126
+ );
127
+
128
+ if (!versionRange) {
129
+ // Equipment that does not need to be repaired
130
+ return;
131
+ }
132
+
133
+ if (semver.valid(firmwareVersion) && semver.lt(firmwareVersion, versionRange.min)) {
134
+ throw ERRORS.TypedError(
135
+ HardwareErrorCode.CallMethodNeedUpgradeFirmware,
136
+ `Device firmware version is too low, please update to ${versionRange.min}`,
137
+ { current: firmwareVersion, require: versionRange.min }
138
+ );
139
+ }
140
+ }
141
+
74
142
  async run() {
143
+ // checkFixCommentError
144
+ this.checkFixCommentError();
145
+
146
+ // check jettonAmount
147
+ const { jettonAmount } = this.payload;
148
+ if (jettonAmount) {
149
+ if (this.checkSupportJettonAmountBytes()) {
150
+ this.params.jetton_amount_bytes = stripHexStartZeroes(
151
+ formatAnyHex(new BigNumber(jettonAmount).toString(16))
152
+ );
153
+ } else {
154
+ this.params.jetton_amount = jettonAmount;
155
+ }
156
+ }
157
+
75
158
  const deviceType = getDeviceType(this.device.features);
76
159
  const res = await this.device.commands.typedCall('TonSignMessage', 'TonSignedMessage', {
77
160
  ...this.params,
@@ -16,7 +16,7 @@ export default class TonSignProof extends BaseMethod<HardwareTonSignProof> {
16
16
  { name: 'path', required: true },
17
17
  { name: 'appdomain', type: 'string' },
18
18
  { name: 'comment', type: 'string' },
19
- { name: 'expireAt', type: 'number' },
19
+ { name: 'expireAt' },
20
20
  { name: 'walletVersion' },
21
21
  { name: 'walletId', type: 'number' },
22
22
  { name: 'workchain' },
@@ -10628,6 +10628,10 @@
10628
10628
  "rule": "repeated",
10629
10629
  "type": "string",
10630
10630
  "id": 20
10631
+ },
10632
+ "jetton_amount_bytes": {
10633
+ "type": "bytes",
10634
+ "id": 21
10631
10635
  }
10632
10636
  }
10633
10637
  },
@@ -1,4 +1,9 @@
1
- import { TonSignedMessage, TonWalletVersion, TonWorkChain } from '@onekeyfe/hd-transport';
1
+ import type {
2
+ TonSignedMessage,
3
+ TonWalletVersion,
4
+ TonWorkChain,
5
+ UintType,
6
+ } from '@onekeyfe/hd-transport';
2
7
  import type { CommonParams, Response } from '../params';
3
8
 
4
9
  export type TonSignMessageParams = {
@@ -6,21 +11,21 @@ export type TonSignMessageParams = {
6
11
  destination: string;
7
12
  jettonMasterAddress?: string;
8
13
  jettonWalletAddress?: string;
9
- tonAmount: number;
10
- jettonAmount?: number;
11
- fwdFee?: number;
14
+ tonAmount: UintType;
15
+ jettonAmount?: UintType;
16
+ fwdFee?: UintType;
12
17
  comment?: string;
13
18
  isRawData?: boolean;
14
19
  mode?: number;
15
20
  seqno: number;
16
- expireAt: number;
21
+ expireAt: UintType;
17
22
  walletVersion?: TonWalletVersion;
18
23
  walletId?: number;
19
24
  workchain?: TonWorkChain;
20
25
  isBounceable?: boolean;
21
26
  isTestnetOnly?: boolean;
22
27
  extDestination?: string[];
23
- extTonAmount?: number[];
28
+ extTonAmount?: UintType[];
24
29
  extPayload?: string[];
25
30
  };
26
31
 
@@ -1,11 +1,16 @@
1
- import { TonSignedProof, TonWalletVersion, TonWorkChain } from '@onekeyfe/hd-transport';
1
+ import type {
2
+ TonSignedProof,
3
+ TonWalletVersion,
4
+ TonWorkChain,
5
+ UintType,
6
+ } from '@onekeyfe/hd-transport';
2
7
  import type { CommonParams, Response } from '../params';
3
8
 
4
9
  export type TonSignProofParams = {
5
10
  path: string | number[];
6
11
  appdomain: string;
7
12
  comment?: string;
8
- expireAt: number;
13
+ expireAt: UintType;
9
14
  walletVersion?: TonWalletVersion;
10
15
  walletId?: number;
11
16
  workchain?: TonWorkChain;