@onekeyfe/hd-core 1.0.8 → 1.0.9-alpha.1
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/dist/api/device/DeviceUploadResource.d.ts.map +1 -1
- package/dist/api/index.d.ts +3 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/ton/TonGetAddress.d.ts +18 -0
- package/dist/api/ton/TonGetAddress.d.ts.map +1 -0
- package/dist/api/ton/TonSignMessage.d.ts +15 -0
- package/dist/api/ton/TonSignMessage.d.ts.map +1 -0
- package/dist/api/ton/TonSignProof.d.ts +15 -0
- package/dist/api/ton/TonSignProof.d.ts.map +1 -0
- package/dist/index.d.ts +69 -3
- package/dist/index.js +505 -20
- package/dist/inject.d.ts.map +1 -1
- package/dist/types/api/deviceUploadResource.d.ts +1 -0
- package/dist/types/api/deviceUploadResource.d.ts.map +1 -1
- package/dist/types/api/export.d.ts +3 -0
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +6 -0
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/tonGetAddress.d.ts +21 -0
- package/dist/types/api/tonGetAddress.d.ts.map +1 -0
- package/dist/types/api/tonSignMessage.d.ts +21 -0
- package/dist/types/api/tonSignMessage.d.ts.map +1 -0
- package/dist/types/api/tonSignProof.d.ts +15 -0
- package/dist/types/api/tonSignProof.d.ts.map +1 -0
- package/dist/utils/homescreen.d.ts +13 -1
- package/dist/utils/homescreen.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/dist/utils/patch.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/device/DeviceUploadResource.ts +5 -4
- package/src/api/index.ts +4 -0
- package/src/api/ton/TonGetAddress.ts +94 -0
- package/src/api/ton/TonSignMessage.ts +74 -0
- package/src/api/ton/TonSignProof.ts +61 -0
- package/src/data/messages/messages.json +259 -0
- package/src/inject.ts +7 -0
- package/src/types/api/deviceUploadResource.ts +1 -0
- package/src/types/api/export.ts +4 -0
- package/src/types/api/index.ts +11 -0
- package/src/types/api/tonGetAddress.ts +30 -0
- package/src/types/api/tonSignMessage.ts +26 -0
- package/src/types/api/tonSignProof.ts +20 -0
- package/src/utils/homescreen.ts +89 -18
- package/src/utils/index.ts +1 -1
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { TonSignMessage as HardwareTonSignMessage } from '@onekeyfe/hd-transport';
|
|
2
|
+
|
|
3
|
+
import { UI_REQUEST } from '../../constants/ui-request';
|
|
4
|
+
import { validatePath } from '../helpers/pathUtils';
|
|
5
|
+
import { BaseMethod } from '../BaseMethod';
|
|
6
|
+
import { validateParams } from '../helpers/paramsValidator';
|
|
7
|
+
import { TonSignMessageParams } from '../../types';
|
|
8
|
+
|
|
9
|
+
export default class TonSignMessage extends BaseMethod<HardwareTonSignMessage> {
|
|
10
|
+
init() {
|
|
11
|
+
this.checkDeviceId = true;
|
|
12
|
+
this.notAllowDeviceMode = [...this.notAllowDeviceMode, UI_REQUEST.INITIALIZE];
|
|
13
|
+
|
|
14
|
+
// init params
|
|
15
|
+
|
|
16
|
+
validateParams(this.payload, [
|
|
17
|
+
{ name: 'path', required: true },
|
|
18
|
+
{ name: 'destination', type: 'string' },
|
|
19
|
+
{ name: 'jettonMasterAddress', type: 'string' },
|
|
20
|
+
{ name: 'tonAmount', type: 'number' },
|
|
21
|
+
{ name: 'jettonAmount', type: 'number' },
|
|
22
|
+
{ name: 'fwdFee', type: 'number' },
|
|
23
|
+
{ name: 'comment', type: 'string' },
|
|
24
|
+
{ name: 'mode', type: 'number' },
|
|
25
|
+
{ name: 'seqno', type: 'number' },
|
|
26
|
+
{ name: 'expireAt', type: 'number' },
|
|
27
|
+
{ name: 'walletVersion' },
|
|
28
|
+
{ name: 'walletId', type: 'number' },
|
|
29
|
+
{ name: 'workchain' },
|
|
30
|
+
{ name: 'isBounceable', type: 'boolean' },
|
|
31
|
+
{ name: 'isTestnetOnly', type: 'boolean' },
|
|
32
|
+
]);
|
|
33
|
+
|
|
34
|
+
const { path } = this.payload as TonSignMessageParams;
|
|
35
|
+
const addressN = validatePath(path, 3);
|
|
36
|
+
|
|
37
|
+
this.params = {
|
|
38
|
+
address_n: addressN,
|
|
39
|
+
destination: this.payload.destination,
|
|
40
|
+
jetton_master_address: this.payload.jettonMasterAddress,
|
|
41
|
+
ton_amount: this.payload.tonAmount,
|
|
42
|
+
jetton_amount: this.payload.jettonAmount,
|
|
43
|
+
fwd_fee: this.payload.fwdFee,
|
|
44
|
+
comment: this.payload.comment,
|
|
45
|
+
mode: this.payload.mode,
|
|
46
|
+
seqno: this.payload.seqno,
|
|
47
|
+
expire_at: this.payload.expireAt,
|
|
48
|
+
wallet_version: this.payload.walletVersion,
|
|
49
|
+
wallet_id: this.payload.walletId,
|
|
50
|
+
workchain: this.payload.workchain,
|
|
51
|
+
is_bounceable: this.payload.isBounceable,
|
|
52
|
+
is_testnet_only: this.payload.isTestnetOnly,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
getVersionRange() {
|
|
57
|
+
return {
|
|
58
|
+
model_mini: {
|
|
59
|
+
min: '3.0.0',
|
|
60
|
+
},
|
|
61
|
+
model_touch: {
|
|
62
|
+
min: '4.3.0',
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async run() {
|
|
68
|
+
const res = await this.device.commands.typedCall('TonSignMessage', 'TonSignedMessage', {
|
|
69
|
+
...this.params,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
return Promise.resolve(res.message);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { TonSignProof as HardwareTonSignProof } from '@onekeyfe/hd-transport';
|
|
2
|
+
|
|
3
|
+
import { UI_REQUEST } from '../../constants/ui-request';
|
|
4
|
+
import { validatePath } from '../helpers/pathUtils';
|
|
5
|
+
import { BaseMethod } from '../BaseMethod';
|
|
6
|
+
import { validateParams } from '../helpers/paramsValidator';
|
|
7
|
+
import { TonSignProofParams } from '../../types';
|
|
8
|
+
|
|
9
|
+
export default class TonSignProof extends BaseMethod<HardwareTonSignProof> {
|
|
10
|
+
init() {
|
|
11
|
+
this.checkDeviceId = true;
|
|
12
|
+
this.notAllowDeviceMode = [...this.notAllowDeviceMode, UI_REQUEST.INITIALIZE];
|
|
13
|
+
|
|
14
|
+
// init params
|
|
15
|
+
validateParams(this.payload, [
|
|
16
|
+
{ name: 'path', required: true },
|
|
17
|
+
{ name: 'appdomain', type: 'string' },
|
|
18
|
+
{ name: 'comment', type: 'string' },
|
|
19
|
+
{ name: 'expireAt', type: 'number' },
|
|
20
|
+
{ name: 'walletVersion' },
|
|
21
|
+
{ name: 'walletId', type: 'number' },
|
|
22
|
+
{ name: 'workchain' },
|
|
23
|
+
{ name: 'isBounceable', type: 'boolean' },
|
|
24
|
+
{ name: 'isTestnetOnly', type: 'boolean' },
|
|
25
|
+
]);
|
|
26
|
+
|
|
27
|
+
const { path } = this.payload as TonSignProofParams;
|
|
28
|
+
const addressN = validatePath(path, 3);
|
|
29
|
+
|
|
30
|
+
this.params = {
|
|
31
|
+
address_n: addressN,
|
|
32
|
+
appdomain: this.payload.appdomain,
|
|
33
|
+
comment: this.payload.comment,
|
|
34
|
+
expire_at: this.payload.expireAt,
|
|
35
|
+
wallet_version: this.payload.walletVersion,
|
|
36
|
+
wallet_id: this.payload.walletId,
|
|
37
|
+
workchain: this.payload.workchain,
|
|
38
|
+
is_bounceable: this.payload.isBounceable,
|
|
39
|
+
is_testnet_only: this.payload.isTestnetOnly,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
getVersionRange() {
|
|
44
|
+
return {
|
|
45
|
+
model_mini: {
|
|
46
|
+
min: '3.0.0',
|
|
47
|
+
},
|
|
48
|
+
model_touch: {
|
|
49
|
+
min: '4.3.0',
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async run() {
|
|
55
|
+
const res = await this.device.commands.typedCall('TonSignProof', 'TonSignedProof', {
|
|
56
|
+
...this.params,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
return Promise.resolve(res.message);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -2534,6 +2534,10 @@
|
|
|
2534
2534
|
"rule": "required",
|
|
2535
2535
|
"type": "uint32",
|
|
2536
2536
|
"id": 4
|
|
2537
|
+
},
|
|
2538
|
+
"address_type": {
|
|
2539
|
+
"type": "CardanoAddressType",
|
|
2540
|
+
"id": 5
|
|
2537
2541
|
}
|
|
2538
2542
|
}
|
|
2539
2543
|
},
|
|
@@ -10100,6 +10104,255 @@
|
|
|
10100
10104
|
}
|
|
10101
10105
|
}
|
|
10102
10106
|
},
|
|
10107
|
+
"TonWalletVersion": {
|
|
10108
|
+
"values": {
|
|
10109
|
+
"V3R1": 0,
|
|
10110
|
+
"V3R2": 1,
|
|
10111
|
+
"V4R1": 2,
|
|
10112
|
+
"V4R2": 3
|
|
10113
|
+
}
|
|
10114
|
+
},
|
|
10115
|
+
"TonWorkChain": {
|
|
10116
|
+
"values": {
|
|
10117
|
+
"BASECHAIN": 0,
|
|
10118
|
+
"MASTERCHAIN": 1
|
|
10119
|
+
}
|
|
10120
|
+
},
|
|
10121
|
+
"TonGetAddress": {
|
|
10122
|
+
"fields": {
|
|
10123
|
+
"address_n": {
|
|
10124
|
+
"rule": "repeated",
|
|
10125
|
+
"type": "uint32",
|
|
10126
|
+
"id": 1,
|
|
10127
|
+
"options": {
|
|
10128
|
+
"packed": false
|
|
10129
|
+
}
|
|
10130
|
+
},
|
|
10131
|
+
"show_display": {
|
|
10132
|
+
"type": "bool",
|
|
10133
|
+
"id": 2
|
|
10134
|
+
},
|
|
10135
|
+
"wallet_version": {
|
|
10136
|
+
"type": "TonWalletVersion",
|
|
10137
|
+
"id": 3,
|
|
10138
|
+
"options": {
|
|
10139
|
+
"default": "V3R2"
|
|
10140
|
+
}
|
|
10141
|
+
},
|
|
10142
|
+
"is_bounceable": {
|
|
10143
|
+
"type": "bool",
|
|
10144
|
+
"id": 4,
|
|
10145
|
+
"options": {
|
|
10146
|
+
"default": false
|
|
10147
|
+
}
|
|
10148
|
+
},
|
|
10149
|
+
"is_testnet_only": {
|
|
10150
|
+
"type": "bool",
|
|
10151
|
+
"id": 5,
|
|
10152
|
+
"options": {
|
|
10153
|
+
"default": false
|
|
10154
|
+
}
|
|
10155
|
+
},
|
|
10156
|
+
"workchain": {
|
|
10157
|
+
"type": "TonWorkChain",
|
|
10158
|
+
"id": 6,
|
|
10159
|
+
"options": {
|
|
10160
|
+
"default": "BASECHAIN"
|
|
10161
|
+
}
|
|
10162
|
+
},
|
|
10163
|
+
"wallet_id": {
|
|
10164
|
+
"type": "uint32",
|
|
10165
|
+
"id": 7,
|
|
10166
|
+
"options": {
|
|
10167
|
+
"default": 698983191
|
|
10168
|
+
}
|
|
10169
|
+
}
|
|
10170
|
+
}
|
|
10171
|
+
},
|
|
10172
|
+
"TonAddress": {
|
|
10173
|
+
"fields": {
|
|
10174
|
+
"public_key": {
|
|
10175
|
+
"rule": "required",
|
|
10176
|
+
"type": "bytes",
|
|
10177
|
+
"id": 1
|
|
10178
|
+
},
|
|
10179
|
+
"address": {
|
|
10180
|
+
"rule": "required",
|
|
10181
|
+
"type": "string",
|
|
10182
|
+
"id": 2
|
|
10183
|
+
}
|
|
10184
|
+
}
|
|
10185
|
+
},
|
|
10186
|
+
"TonSignMessage": {
|
|
10187
|
+
"fields": {
|
|
10188
|
+
"address_n": {
|
|
10189
|
+
"rule": "repeated",
|
|
10190
|
+
"type": "uint32",
|
|
10191
|
+
"id": 1,
|
|
10192
|
+
"options": {
|
|
10193
|
+
"packed": false
|
|
10194
|
+
}
|
|
10195
|
+
},
|
|
10196
|
+
"destination": {
|
|
10197
|
+
"rule": "required",
|
|
10198
|
+
"type": "string",
|
|
10199
|
+
"id": 2
|
|
10200
|
+
},
|
|
10201
|
+
"jetton_master_address": {
|
|
10202
|
+
"type": "string",
|
|
10203
|
+
"id": 3
|
|
10204
|
+
},
|
|
10205
|
+
"ton_amount": {
|
|
10206
|
+
"rule": "required",
|
|
10207
|
+
"type": "uint64",
|
|
10208
|
+
"id": 4
|
|
10209
|
+
},
|
|
10210
|
+
"jetton_amount": {
|
|
10211
|
+
"type": "uint64",
|
|
10212
|
+
"id": 5
|
|
10213
|
+
},
|
|
10214
|
+
"fwd_fee": {
|
|
10215
|
+
"type": "uint64",
|
|
10216
|
+
"id": 6,
|
|
10217
|
+
"options": {
|
|
10218
|
+
"default": 0
|
|
10219
|
+
}
|
|
10220
|
+
},
|
|
10221
|
+
"comment": {
|
|
10222
|
+
"type": "string",
|
|
10223
|
+
"id": 7
|
|
10224
|
+
},
|
|
10225
|
+
"mode": {
|
|
10226
|
+
"type": "uint32",
|
|
10227
|
+
"id": 8,
|
|
10228
|
+
"options": {
|
|
10229
|
+
"default": 3
|
|
10230
|
+
}
|
|
10231
|
+
},
|
|
10232
|
+
"seqno": {
|
|
10233
|
+
"rule": "required",
|
|
10234
|
+
"type": "uint32",
|
|
10235
|
+
"id": 9
|
|
10236
|
+
},
|
|
10237
|
+
"expire_at": {
|
|
10238
|
+
"rule": "required",
|
|
10239
|
+
"type": "uint64",
|
|
10240
|
+
"id": 10
|
|
10241
|
+
},
|
|
10242
|
+
"wallet_version": {
|
|
10243
|
+
"type": "TonWalletVersion",
|
|
10244
|
+
"id": 11,
|
|
10245
|
+
"options": {
|
|
10246
|
+
"default": "V4R2"
|
|
10247
|
+
}
|
|
10248
|
+
},
|
|
10249
|
+
"wallet_id": {
|
|
10250
|
+
"type": "uint32",
|
|
10251
|
+
"id": 12,
|
|
10252
|
+
"options": {
|
|
10253
|
+
"default": 698983191
|
|
10254
|
+
}
|
|
10255
|
+
},
|
|
10256
|
+
"workchain": {
|
|
10257
|
+
"type": "TonWorkChain",
|
|
10258
|
+
"id": 13,
|
|
10259
|
+
"options": {
|
|
10260
|
+
"default": "BASECHAIN"
|
|
10261
|
+
}
|
|
10262
|
+
},
|
|
10263
|
+
"is_bounceable": {
|
|
10264
|
+
"type": "bool",
|
|
10265
|
+
"id": 14,
|
|
10266
|
+
"options": {
|
|
10267
|
+
"default": false
|
|
10268
|
+
}
|
|
10269
|
+
},
|
|
10270
|
+
"is_testnet_only": {
|
|
10271
|
+
"type": "bool",
|
|
10272
|
+
"id": 15,
|
|
10273
|
+
"options": {
|
|
10274
|
+
"default": false
|
|
10275
|
+
}
|
|
10276
|
+
}
|
|
10277
|
+
}
|
|
10278
|
+
},
|
|
10279
|
+
"TonSignedMessage": {
|
|
10280
|
+
"fields": {
|
|
10281
|
+
"signature": {
|
|
10282
|
+
"type": "bytes",
|
|
10283
|
+
"id": 1
|
|
10284
|
+
}
|
|
10285
|
+
}
|
|
10286
|
+
},
|
|
10287
|
+
"TonSignProof": {
|
|
10288
|
+
"fields": {
|
|
10289
|
+
"address_n": {
|
|
10290
|
+
"rule": "repeated",
|
|
10291
|
+
"type": "uint32",
|
|
10292
|
+
"id": 1,
|
|
10293
|
+
"options": {
|
|
10294
|
+
"packed": false
|
|
10295
|
+
}
|
|
10296
|
+
},
|
|
10297
|
+
"appdomain": {
|
|
10298
|
+
"rule": "required",
|
|
10299
|
+
"type": "bytes",
|
|
10300
|
+
"id": 2
|
|
10301
|
+
},
|
|
10302
|
+
"comment": {
|
|
10303
|
+
"type": "bytes",
|
|
10304
|
+
"id": 3
|
|
10305
|
+
},
|
|
10306
|
+
"expire_at": {
|
|
10307
|
+
"rule": "required",
|
|
10308
|
+
"type": "uint64",
|
|
10309
|
+
"id": 4
|
|
10310
|
+
},
|
|
10311
|
+
"wallet_version": {
|
|
10312
|
+
"type": "TonWalletVersion",
|
|
10313
|
+
"id": 5,
|
|
10314
|
+
"options": {
|
|
10315
|
+
"default": "V4R2"
|
|
10316
|
+
}
|
|
10317
|
+
},
|
|
10318
|
+
"wallet_id": {
|
|
10319
|
+
"type": "uint32",
|
|
10320
|
+
"id": 6,
|
|
10321
|
+
"options": {
|
|
10322
|
+
"default": 698983191
|
|
10323
|
+
}
|
|
10324
|
+
},
|
|
10325
|
+
"workchain": {
|
|
10326
|
+
"type": "TonWorkChain",
|
|
10327
|
+
"id": 7,
|
|
10328
|
+
"options": {
|
|
10329
|
+
"default": "BASECHAIN"
|
|
10330
|
+
}
|
|
10331
|
+
},
|
|
10332
|
+
"is_bounceable": {
|
|
10333
|
+
"type": "bool",
|
|
10334
|
+
"id": 8,
|
|
10335
|
+
"options": {
|
|
10336
|
+
"default": false
|
|
10337
|
+
}
|
|
10338
|
+
},
|
|
10339
|
+
"is_testnet_only": {
|
|
10340
|
+
"type": "bool",
|
|
10341
|
+
"id": 9,
|
|
10342
|
+
"options": {
|
|
10343
|
+
"default": false
|
|
10344
|
+
}
|
|
10345
|
+
}
|
|
10346
|
+
}
|
|
10347
|
+
},
|
|
10348
|
+
"TonSignedProof": {
|
|
10349
|
+
"fields": {
|
|
10350
|
+
"signature": {
|
|
10351
|
+
"type": "bytes",
|
|
10352
|
+
"id": 1
|
|
10353
|
+
}
|
|
10354
|
+
}
|
|
10355
|
+
},
|
|
10103
10356
|
"TronGetAddress": {
|
|
10104
10357
|
"fields": {
|
|
10105
10358
|
"address_n": {
|
|
@@ -10943,6 +11196,12 @@
|
|
|
10943
11196
|
"MessageType_DnxInputAck": 11804,
|
|
10944
11197
|
"MessageType_DnxRTSigsRequest": 11805,
|
|
10945
11198
|
"MessageType_DnxSignedTx": 11806,
|
|
11199
|
+
"MessageType_TonGetAddress": 11901,
|
|
11200
|
+
"MessageType_TonAddress": 11902,
|
|
11201
|
+
"MessageType_TonSignMessage": 11903,
|
|
11202
|
+
"MessageType_TonSignedMessage": 11904,
|
|
11203
|
+
"MessageType_TonSignProof": 11905,
|
|
11204
|
+
"MessageType_TonSignedProof": 11906,
|
|
10946
11205
|
"MessageType_DeviceBackToBoot": 903,
|
|
10947
11206
|
"MessageType_DeviceInfoSettings": 10001,
|
|
10948
11207
|
"MessageType_GetDeviceInfo": 10002,
|
package/src/inject.ts
CHANGED
|
@@ -294,4 +294,11 @@ export const createCoreApi = (
|
|
|
294
294
|
call({ ...params, connectId, deviceId, method: 'dnxGetAddress' }),
|
|
295
295
|
dnxSignTransaction: (connectId, deviceId, params) =>
|
|
296
296
|
call({ ...params, connectId, deviceId, method: 'dnxSignTransaction' }),
|
|
297
|
+
|
|
298
|
+
tonGetAddress: (connectId, deviceId, params) =>
|
|
299
|
+
call({ ...params, connectId, deviceId, method: 'tonGetAddress' }),
|
|
300
|
+
tonSignMessage: (connectId, deviceId, params) =>
|
|
301
|
+
call({ ...params, connectId, deviceId, method: 'tonSignMessage' }),
|
|
302
|
+
tonSignProof: (connectId, deviceId, params) =>
|
|
303
|
+
call({ ...params, connectId, deviceId, method: 'tonSignProof' }),
|
|
297
304
|
});
|
package/src/types/api/export.ts
CHANGED
|
@@ -152,3 +152,7 @@ export type { NervosSignedTx, NervosSignTransactionParams } from './nervosSignTr
|
|
|
152
152
|
|
|
153
153
|
export type { DnxAddress, DnxGetAddressParams } from './dnxGetAddress';
|
|
154
154
|
export type { DnxTxKey, DnxSignTransactionParams, DnxSignature } from './dnxSignTransaction';
|
|
155
|
+
|
|
156
|
+
export type { TonAddress, TonGetAddressParams } from './tonGetAddress';
|
|
157
|
+
export type { TonSignMessageParams } from './tonSignMessage';
|
|
158
|
+
export type { TonSignProofParams } from './tonSignProof';
|
package/src/types/api/index.ts
CHANGED
|
@@ -126,6 +126,10 @@ import { nervosSignTransaction } from './nervosSignTransaction';
|
|
|
126
126
|
import { dnxGetAddress } from './dnxGetAddress';
|
|
127
127
|
import { dnxSignTransaction } from './dnxSignTransaction';
|
|
128
128
|
|
|
129
|
+
import { tonGetAddress } from './tonGetAddress';
|
|
130
|
+
import { tonSignMessage } from './tonSignMessage';
|
|
131
|
+
import { tonSignProof } from './tonSignProof';
|
|
132
|
+
|
|
129
133
|
export * from './export';
|
|
130
134
|
|
|
131
135
|
export type CoreApi = {
|
|
@@ -342,4 +346,11 @@ export type CoreApi = {
|
|
|
342
346
|
*/
|
|
343
347
|
dnxGetAddress: typeof dnxGetAddress;
|
|
344
348
|
dnxSignTransaction: typeof dnxSignTransaction;
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* TON Network
|
|
352
|
+
*/
|
|
353
|
+
tonGetAddress: typeof tonGetAddress;
|
|
354
|
+
tonSignMessage: typeof tonSignMessage;
|
|
355
|
+
tonSignProof: typeof tonSignProof;
|
|
345
356
|
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { TonWalletVersion, TonWorkChain } from '@onekeyfe/hd-transport';
|
|
2
|
+
import type { CommonParams, Response } from '../params';
|
|
3
|
+
|
|
4
|
+
export type TonAddress = {
|
|
5
|
+
path: string;
|
|
6
|
+
publicKey: string;
|
|
7
|
+
address: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type TonGetAddressParams = {
|
|
11
|
+
path: string | number[];
|
|
12
|
+
showOnOneKey?: boolean;
|
|
13
|
+
walletVersion?: TonWalletVersion;
|
|
14
|
+
isBounceable?: boolean;
|
|
15
|
+
isTestnetOnly?: boolean;
|
|
16
|
+
workchain?: TonWorkChain;
|
|
17
|
+
walletId?: number;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export declare function tonGetAddress(
|
|
21
|
+
connectId: string,
|
|
22
|
+
deviceId: string,
|
|
23
|
+
params: CommonParams & TonGetAddressParams
|
|
24
|
+
): Response<TonAddress>;
|
|
25
|
+
|
|
26
|
+
export declare function tonGetAddress(
|
|
27
|
+
connectId: string,
|
|
28
|
+
deviceId: string,
|
|
29
|
+
params: CommonParams & { bundle?: TonGetAddressParams[] }
|
|
30
|
+
): Response<Array<TonAddress>>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { TonSignedMessage, TonWalletVersion, TonWorkChain } from '@onekeyfe/hd-transport';
|
|
2
|
+
import type { CommonParams, Response } from '../params';
|
|
3
|
+
|
|
4
|
+
export type TonSignMessageParams = {
|
|
5
|
+
path: string | number[];
|
|
6
|
+
destination: string;
|
|
7
|
+
jettonMasterAddress?: string;
|
|
8
|
+
tonAmount: number;
|
|
9
|
+
jettonAmount?: number;
|
|
10
|
+
fwdFee?: number;
|
|
11
|
+
comment?: string;
|
|
12
|
+
mode?: number;
|
|
13
|
+
seqno: number;
|
|
14
|
+
expireAt: number;
|
|
15
|
+
walletVersion?: TonWalletVersion;
|
|
16
|
+
walletId?: number;
|
|
17
|
+
workchain?: TonWorkChain;
|
|
18
|
+
isBounceable?: boolean;
|
|
19
|
+
isTestnetOnly?: boolean;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export declare function tonSignMessage(
|
|
23
|
+
connectId: string,
|
|
24
|
+
deviceId: string,
|
|
25
|
+
params: CommonParams & TonSignMessageParams
|
|
26
|
+
): Response<TonSignedMessage>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { TonSignedProof, TonWalletVersion, TonWorkChain } from '@onekeyfe/hd-transport';
|
|
2
|
+
import type { CommonParams, Response } from '../params';
|
|
3
|
+
|
|
4
|
+
export type TonSignProofParams = {
|
|
5
|
+
path: string | number[];
|
|
6
|
+
appdomain: string;
|
|
7
|
+
comment?: string;
|
|
8
|
+
expireAt: number;
|
|
9
|
+
walletVersion?: TonWalletVersion;
|
|
10
|
+
walletId?: number;
|
|
11
|
+
workchain?: TonWorkChain;
|
|
12
|
+
isBounceable?: boolean;
|
|
13
|
+
isTestnetOnly?: boolean;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export declare function tonSignProof(
|
|
17
|
+
connectId: string,
|
|
18
|
+
deviceId: string,
|
|
19
|
+
params: CommonParams & TonSignProofParams
|
|
20
|
+
): Response<TonSignedProof>;
|
package/src/utils/homescreen.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { IDeviceType } from '../types';
|
|
1
|
+
import type { Features, IDeviceType } from '../types';
|
|
2
|
+
import { getDeviceType } from './deviceInfoUtils';
|
|
2
3
|
|
|
3
4
|
type IScreenData = { name: string; hex: string };
|
|
4
5
|
|
|
@@ -218,22 +219,20 @@ export const getT1Data = (): Record<string, IScreenData> => ({
|
|
|
218
219
|
});
|
|
219
220
|
|
|
220
221
|
export const getTouchData = (): Record<string, IScreenData> => ({
|
|
221
|
-
'wallpaper-1': {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
},
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
},
|
|
229
|
-
'wallpaper-3': {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
},
|
|
233
|
-
'wallpaper-
|
|
234
|
-
|
|
235
|
-
hex: '77616c6c70617065722d342e706e67',
|
|
236
|
-
},
|
|
222
|
+
'wallpaper-1': { name: 'wallpaper-1', hex: '77616c6c70617065722d312e706e67' },
|
|
223
|
+
'wallpaper-2': { name: 'wallpaper-2', hex: '77616c6c70617065722d322e706e67' },
|
|
224
|
+
'wallpaper-3': { name: 'wallpaper-3', hex: '77616c6c70617065722d332e706e67' },
|
|
225
|
+
'wallpaper-4': { name: 'wallpaper-4', hex: '77616c6c70617065722d342e706e67' },
|
|
226
|
+
});
|
|
227
|
+
export const getProData = (): Record<string, IScreenData> => ({
|
|
228
|
+
'wallpaper-1': { name: 'wallpaper-1', hex: '77616c6c70617065722d312e6a7067' },
|
|
229
|
+
'wallpaper-2': { name: 'wallpaper-2', hex: '77616c6c70617065722d322e6a7067' },
|
|
230
|
+
'wallpaper-3': { name: 'wallpaper-3', hex: '77616c6c70617065722d332e6a7067' },
|
|
231
|
+
'wallpaper-4': { name: 'wallpaper-4', hex: '77616c6c70617065722d342e6a7067' },
|
|
232
|
+
// Current version cannot be modified
|
|
233
|
+
// 'wallpaper-5': { name: 'wallpaper-5', hex: '77616c6c70617065722d352e6a7067' },
|
|
234
|
+
// 'wallpaper-6': { name: 'wallpaper-6', hex: '77616c6c70617065722d362e6a7067' },
|
|
235
|
+
// 'wallpaper-7': { name: 'wallpaper-7', hex: '77616c6c70617065722d372e6a7067' },
|
|
237
236
|
});
|
|
238
237
|
|
|
239
238
|
export const getHomeScreenHex = (deviceType: IDeviceType, name: string) => {
|
|
@@ -248,7 +247,7 @@ export const getHomeScreenHex = (deviceType: IDeviceType, name: string) => {
|
|
|
248
247
|
data = getTouchData();
|
|
249
248
|
break;
|
|
250
249
|
case 'pro':
|
|
251
|
-
data =
|
|
250
|
+
data = getProData();
|
|
252
251
|
break;
|
|
253
252
|
default:
|
|
254
253
|
data = {};
|
|
@@ -256,3 +255,75 @@ export const getHomeScreenHex = (deviceType: IDeviceType, name: string) => {
|
|
|
256
255
|
|
|
257
256
|
return data[name]?.hex ?? '';
|
|
258
257
|
};
|
|
258
|
+
|
|
259
|
+
export const getHomeScreenDefaultList = (features: Features) => {
|
|
260
|
+
let data: Record<string, IScreenData>;
|
|
261
|
+
const deviceType = getDeviceType(features);
|
|
262
|
+
|
|
263
|
+
switch (deviceType) {
|
|
264
|
+
case 'classic':
|
|
265
|
+
case 'classic1s':
|
|
266
|
+
case 'mini':
|
|
267
|
+
data = getT1Data();
|
|
268
|
+
break;
|
|
269
|
+
case 'touch':
|
|
270
|
+
data = getTouchData();
|
|
271
|
+
break;
|
|
272
|
+
case 'pro':
|
|
273
|
+
data = getProData();
|
|
274
|
+
break;
|
|
275
|
+
default:
|
|
276
|
+
data = {};
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
return Object.keys(data);
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
type SizeConfig = {
|
|
283
|
+
width: number;
|
|
284
|
+
height: number;
|
|
285
|
+
radius?: number;
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
export const getHomeScreenSize = ({
|
|
289
|
+
deviceType,
|
|
290
|
+
homeScreenType,
|
|
291
|
+
thumbnail,
|
|
292
|
+
}: {
|
|
293
|
+
deviceType: IDeviceType;
|
|
294
|
+
homeScreenType: 'WallPaper' | 'Nft';
|
|
295
|
+
thumbnail?: boolean;
|
|
296
|
+
}) => {
|
|
297
|
+
const sizes: Partial<
|
|
298
|
+
Record<
|
|
299
|
+
IDeviceType,
|
|
300
|
+
{
|
|
301
|
+
thumbnail: {
|
|
302
|
+
Nft: SizeConfig;
|
|
303
|
+
WallPaper: SizeConfig;
|
|
304
|
+
};
|
|
305
|
+
full: SizeConfig;
|
|
306
|
+
}
|
|
307
|
+
>
|
|
308
|
+
> = {
|
|
309
|
+
touch: {
|
|
310
|
+
thumbnail: {
|
|
311
|
+
Nft: { width: 238, height: 238 },
|
|
312
|
+
WallPaper: { width: 144, height: 240 },
|
|
313
|
+
},
|
|
314
|
+
full: { width: 480, height: 800 },
|
|
315
|
+
},
|
|
316
|
+
pro: {
|
|
317
|
+
thumbnail: {
|
|
318
|
+
Nft: { width: 226, height: 226, radius: 40 },
|
|
319
|
+
WallPaper: { width: 144, height: 240, radius: 40 },
|
|
320
|
+
},
|
|
321
|
+
full: { width: 480, height: 800 },
|
|
322
|
+
},
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
const deviceConfig = sizes[deviceType];
|
|
326
|
+
if (!deviceConfig) return undefined;
|
|
327
|
+
|
|
328
|
+
return thumbnail ? deviceConfig.thumbnail[homeScreenType] : deviceConfig.full;
|
|
329
|
+
};
|
package/src/utils/index.ts
CHANGED
|
@@ -29,7 +29,7 @@ export { getHDPath, getScriptType, getOutputScriptType } from '../api/helpers/pa
|
|
|
29
29
|
|
|
30
30
|
export const isBleConnect = (env: string) => env === 'react-native' || env === 'lowlevel';
|
|
31
31
|
|
|
32
|
-
export { getHomeScreenHex } from './homescreen';
|
|
32
|
+
export { getHomeScreenHex, getHomeScreenDefaultList, getHomeScreenSize } from './homescreen';
|
|
33
33
|
|
|
34
34
|
export const wait = (ms: number) =>
|
|
35
35
|
new Promise(resolve => {
|