Skip to content

Commit 125a7c7

Browse files
authored
Merge pull request #982 from crypto-com/dev
Internal Release v0.6.8
2 parents 1aad103 + e191a28 commit 125a7c7

26 files changed

+555
-152
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
55
*Unreleased*
66

77
*Released*
8+
## [v0.6.8] - 2022-02-11
9+
### Additions
10+
- Wrapped ETH NFT support on Crypto.org chain
11+
- Add NFT attributes display support
12+
### Bug fixes
13+
- Missing Ledger sign methods support
14+
- Fix potential app crash in Wallet Page
15+
- Align NFT minting metadata
16+
817
## [v0.6.7] - 2022-01-28
918
### Bug fixes
1019
- Incorrect delegation items

electron/IpcMain.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,5 +142,44 @@ export class IpcMain {
142142
}
143143
event.returnValue = ret;
144144
});
145+
ipcMain.on('ethSignPersonalMessage', async (event: any, arg: any) => {
146+
let ret = {};
147+
console.log('ethSignPersonalMessage, ', arg.message, ' . ', arg.index);
148+
149+
try {
150+
const sig = await this.ethProvider.signPersonalMessage(arg.message, arg.index);
151+
ret = {
152+
sig,
153+
success: true,
154+
label: 'ethSignPersonalMessage reply',
155+
};
156+
} catch (e) {
157+
ret = {
158+
success: false,
159+
error: e.toString(),
160+
};
161+
console.error('ethSignPersonalMessage error ', e);
162+
}
163+
164+
event.returnValue = ret;
165+
});
166+
ipcMain.on('ethSignTypedDataV4', async (event: any, arg: any) => {
167+
let ret = {};
168+
try {
169+
const sig = await this.ethProvider.signTypedDataV4(arg.typedData, arg.index);
170+
ret = {
171+
sig,
172+
success: true,
173+
label: 'ethSignTypedDataV4 reply',
174+
};
175+
} catch (e) {
176+
ret = {
177+
success: false,
178+
error: e.toString(),
179+
};
180+
console.error('ethSignTypedDataV4 error ' + e);
181+
}
182+
event.returnValue = ret;
183+
});
145184
}
146185
}

electron/LedgerEthSigner.ts

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1+
/* eslint-disable prefer-template */
12
import TransportHID from '@ledgerhq/hw-transport-node-hid';
23
import Eth from '@ledgerhq/hw-app-eth';
34
import { ethers } from 'ethers';
45
import Web3 from 'web3';
6+
import { TypedDataUtils } from 'eth-sig-util';
57

68
export class LedgerEthSigner {
7-
public app: any;
9+
public app: Eth | undefined;
10+
811
public transport: TransportHID | null;
12+
913
constructor() {
1014
this.transport = null;
1115
}
@@ -22,15 +26,15 @@ export class LedgerEthSigner {
2226
if (this.transport != null) {
2327
this.transport.close();
2428
this.transport = null;
25-
this.app = null;
29+
this.app = undefined;
2630
}
2731
}
2832

2933
async getAddress(index: number = 0, display: boolean): Promise<string> {
3034
try {
3135
const path: string = `44'/60'/0'/0/${index}`;
3236
await this.createTransport();
33-
const retAddress = await this.app.getAddress(path, display, false);
37+
const retAddress = await this.app!.getAddress(path, display, false);
3438
return retAddress.address;
3539
} finally {
3640
await this.closeTransport();
@@ -81,7 +85,7 @@ export class LedgerEthSigner {
8185
};
8286

8387
const unsignedTx = ethers.utils.serializeTransaction(baseTx).substring(2);
84-
const sig = await this.app.signTransaction(path, unsignedTx);
88+
const sig = await this.app!.signTransaction(path, unsignedTx);
8589
// to prevent possible padding issue
8690
const sigR = LedgerEthSigner.padZeroString(sig.r, 32);
8791
const sigS = LedgerEthSigner.padZeroString(sig.s, 32);
@@ -138,7 +142,7 @@ export class LedgerEthSigner {
138142
await this.createTransport();
139143
const path: string = `44'/60'/0'/0/${index}`;
140144
const web3 = new Web3(url);
141-
const from_addr = (await this.app.getAddress(path)).address;
145+
const from_addr = (await this.app!.getAddress(path)).address;
142146
const nonce = await web3.eth.getTransactionCount(from_addr);
143147
const signedTx = await this.doSignTx(
144148
path,
@@ -157,4 +161,48 @@ export class LedgerEthSigner {
157161
await this.closeTransport();
158162
}
159163
}
164+
165+
async signPersonalMessage(msg: string, index = 0) {
166+
try {
167+
await this.createTransport();
168+
const path: string = `44'/60'/0'/0/${index}`;
169+
const sig = await this.app!.signPersonalMessage(path, Buffer.from(msg).toString('hex'));
170+
return LedgerEthSigner.getHexlifySignature(sig);
171+
} finally {
172+
await this.closeTransport();
173+
}
174+
}
175+
176+
static getHexlifySignature(sig: { v: number; r: string; s: string }) {
177+
const v = sig.v - 27;
178+
let vStr = v.toString(16);
179+
if (vStr.length < 2) {
180+
vStr = '0' + v;
181+
}
182+
183+
return '0x' + sig.r + sig.s + vStr;
184+
}
185+
186+
async signTypedDataV4(typedData: any, index = 0) {
187+
try {
188+
await this.createTransport();
189+
const path: string = `44'/60'/0'/0/${index}`;
190+
191+
const data = JSON.parse(typedData);
192+
193+
const domainSeparator = TypedDataUtils.hashStruct('EIP712Domain', data.domain, data.types);
194+
195+
const hashedMessage = TypedDataUtils.hashStruct(data.primaryType, data.message, data.types);
196+
197+
const sig = await this.app!.signEIP712HashedMessage(
198+
path,
199+
ethers.utils.hexlify(domainSeparator),
200+
ethers.utils.hexlify(hashedMessage),
201+
);
202+
203+
return LedgerEthSigner.getHexlifySignature(sig);
204+
} finally {
205+
await this.closeTransport();
206+
}
207+
}
160208
}

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "chain-desktop-wallet",
3-
"version": "0.6.7",
3+
"version": "0.6.8",
44
"description": "Crypto.com Chain Desktop Wallet App",
55
"repository": "github:crypto-com/chain-desktop-wallet",
66
"author": "Crypto.org <[email protected]>",
@@ -18,12 +18,14 @@
1818
"@ledgerhq/hw-transport-node-hid": "^6.6.0",
1919
"@ledgerhq/hw-transport-webhid": "5.48.0",
2020
"@ledgerhq/hw-transport-webusb": "5.48.0",
21+
"@types/bluebird": "3.5.36",
2122
"antd": "4.16.0",
2223
"axios": "0.21.2",
2324
"bech32": "2.0.0",
2425
"bfj": "7.0.2",
2526
"big.js": "6.0.3",
2627
"bignumber.js": "9.0.1",
28+
"bluebird": "3.7.2",
2729
"camelcase": "6.2.0",
2830
"copyfiles": "2.4.1",
2931
"cross-env": "7.0.3",

src/config/StaticConfig.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export const NOT_KNOWN_YET_VALUE = 'TO_BE_DECIDED';
2020
export const MODERATION_CONFIG_FILE_URL =
2121
'https://raw.githubusercontent.com/crypto-com/chain-desktop-wallet/dev/config/app.moderation.json';
2222

23-
2423
export const UNBLOCKING_PERIOD_IN_DAYS = {
2524
UNDELEGATION: {
2625
MAINNET: '28',
@@ -260,6 +259,24 @@ export const NFT_VIDEO_DENOM_SCHEMA = {
260259
},
261260
},
262261
};
262+
export const NFT_WRAPPED_ETH_DENOM_SCHEMA = {
263+
title: 'Asset Metadata',
264+
type: 'Object',
265+
properties: {
266+
isExternal: {
267+
type: 'boolean',
268+
description: 'Describes whether the NFT is external or internal to the Crypto.org chain',
269+
},
270+
network: {
271+
type: 'string',
272+
description: 'Identifies the original network of the NFT',
273+
},
274+
identifier: {
275+
type: 'string',
276+
description: 'An identifier with the format: {contact_address}/{tokenID}',
277+
},
278+
},
279+
};
263280

264281
export const MAX_IMAGE_SIZE = 10 * 1024 * 1024;
265282
export const MAX_VIDEO_SIZE = 20 * 1024 * 1024;

src/language/en-US.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,9 @@
591591
"nft.nftCollection.table1.viewAction": "Action",
592592
"nft.nftCollection.table1.action1": "View",
593593
"nft.detailModal.subtitle": "Description",
594+
"nft.detailModal.attributes": "Attributes",
595+
"nft.detailModal.traitType": "Trait Type",
596+
"nft.detailModal.value": "Value",
594597
"nft.detailModal.label1": "Denom ID",
595598
"nft.detailModal.label2": "Denom Name",
596599
"nft.detailModal.label3": "Token ID",

src/language/ko-KR.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,9 @@
588588
"nft.nftCollection.table1.viewAction": "활동",
589589
"nft.nftCollection.table1.action1": "보기",
590590
"nft.detailModal.subtitle": "삭제에 대해",
591+
"nft.detailModal.attributes": "속성",
592+
"nft.detailModal.traitType": "특성",
593+
"nft.detailModal.value": "",
591594
"nft.detailModal.label1": "디놈 ID",
592595
"nft.detailModal.label2": "디놈 이름",
593596
"nft.detailModal.label3": "토큰 ID",

src/language/zh-CN.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,9 @@
591591
"nft.nftCollection.table1.viewAction": "操作",
592592
"nft.nftCollection.table1.action1": "浏览",
593593
"nft.detailModal.subtitle": "关于",
594+
"nft.detailModal.attributes": "属性",
595+
"nft.detailModal.traitType": "特征",
596+
"nft.detailModal.value": "",
594597
"nft.detailModal.label1": "系列 ID",
595598
"nft.detailModal.label2": "系列名称",
596599
"nft.detailModal.label3": "代币 ID",

src/language/zh-HK.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,9 @@
591591
"nft.nftCollection.table1.viewAction": "操作",
592592
"nft.nftCollection.table1.action1": "瀏覽",
593593
"nft.detailModal.subtitle": "關於",
594+
"nft.detailModal.attributes": "屬性",
595+
"nft.detailModal.traitType": "特徵",
596+
"nft.detailModal.value": "",
594597
"nft.detailModal.label1": "系列 ID",
595598
"nft.detailModal.label2": "系列名稱",
596599
"nft.detailModal.label3": "代幣 ID",

0 commit comments

Comments
 (0)