Skip to content

Commit 7d380ec

Browse files
authored
Merge pull request #1084 from crypto-com/dev
Internal Release v0.7.8
2 parents 1b838f7 + 3fb6283 commit 7d380ec

17 files changed

+117
-105
lines changed

CHANGELOG.md

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

77
*Released*
8+
## [v0.7.8] - 2022-05-10
9+
### Bug fixes
10+
- Handle Ledger Live standard support on EVM transaction signing functions
11+
- Incorrect Transaction Failed popup on Testnet due to delayed transaction receipt return
12+
- UX optimization
813
## [v0.7.7] - 2022-05-10
914
### Additions
1015
- Gas Fee option customization panel

electron/IpcMain.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ export class IpcMain {
127127
try {
128128
const signedtx = await this.ethProvider.signTx(
129129
arg.index,
130+
arg.standard,
130131
arg.chainId,
131132
arg.nonce,
132133
arg.gasLimit,
@@ -188,10 +189,10 @@ export class IpcMain {
188189
});
189190
ipcMain.on('ethSignPersonalMessage', async (event: any, arg: any) => {
190191
let ret = {};
191-
console.log('ethSignPersonalMessage, ', arg.message, ' . ', arg.index);
192+
console.log('ethSignPersonalMessage, ', arg.message, ' . ', arg.index, ' . ', arg.standard);
192193

193194
try {
194-
const sig = await this.ethProvider.signPersonalMessage(arg.message, arg.index);
195+
const sig = await this.ethProvider.signPersonalMessage(arg.message, arg.index, arg.standard);
195196
ret = {
196197
sig,
197198
success: true,
@@ -210,7 +211,7 @@ export class IpcMain {
210211
ipcMain.on('ethSignTypedDataV4', async (event: any, arg: any) => {
211212
let ret = {};
212213
try {
213-
const sig = await this.ethProvider.signTypedDataV4(arg.typedData, arg.index);
214+
const sig = await this.ethProvider.signTypedDataV4(arg.typedData, arg.index, arg.standard);
214215
ret = {
215216
sig,
216217
success: true,

electron/LedgerEthSigner.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ export class LedgerEthSigner {
126126

127127
async signTx(
128128
index: number = 0,
129+
standard: DerivationPathStandard = DerivationPathStandard.BIP44,
129130
chainId: number = 9000,
130131
nonce: number = 0,
131132
gasLimit: string = '0x5208',
@@ -136,7 +137,7 @@ export class LedgerEthSigner {
136137
): Promise<string> {
137138
try {
138139
await this.createTransport();
139-
const path: string = `44'/60'/0'/0/${index}`;
140+
const path = LedgerSigner.getDerivationPath(index, UserAssetType.EVM, standard);
140141
const signedTx = await this.doSignTx(
141142
path,
142143
chainId,
@@ -156,6 +157,7 @@ export class LedgerEthSigner {
156157
async signAndSendTx(
157158
url: string = 'http://127.0.0.1:8545',
158159
index: number = 0,
160+
standard: DerivationPathStandard = DerivationPathStandard.BIP44,
159161
chainId: number = 9000,
160162
gasLimit: string = '0x5000',
161163
gasPrice: string = '0x0400000000',
@@ -165,7 +167,7 @@ export class LedgerEthSigner {
165167
): Promise<string> {
166168
try {
167169
await this.createTransport();
168-
const path: string = `44'/60'/0'/0/${index}`;
170+
const path = LedgerSigner.getDerivationPath(index, UserAssetType.EVM, standard);
169171
const web3 = new Web3(url);
170172
const from_addr = (await this.app!.getAddress(path)).address;
171173
const nonce = await web3.eth.getTransactionCount(from_addr);
@@ -187,10 +189,10 @@ export class LedgerEthSigner {
187189
}
188190
}
189191

190-
async signPersonalMessage(msg: string, index = 0) {
192+
async signPersonalMessage(msg: string, index = 0, standard: DerivationPathStandard = DerivationPathStandard.BIP44) {
191193
try {
192194
await this.createTransport();
193-
const path: string = `44'/60'/0'/0/${index}`;
195+
const path = LedgerSigner.getDerivationPath(index, UserAssetType.EVM, standard);
194196
const sig = await this.app!.signPersonalMessage(path, Buffer.from(msg).toString('hex'));
195197
return LedgerEthSigner.getHexlifySignature(sig);
196198
} finally {
@@ -208,10 +210,10 @@ export class LedgerEthSigner {
208210
return '0x' + sig.r + sig.s + vStr;
209211
}
210212

211-
async signTypedDataV4(typedData: any, index = 0) {
213+
async signTypedDataV4(typedData: any, index = 0, standard: DerivationPathStandard = DerivationPathStandard.BIP44) {
212214
try {
213215
await this.createTransport();
214-
const path: string = `44'/60'/0'/0/${index}`;
216+
const path = LedgerSigner.getDerivationPath(index, UserAssetType.EVM, standard);
215217

216218
const data = JSON.parse(typedData);
217219

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "chain-desktop-wallet",
3-
"version": "0.7.7",
3+
"version": "0.7.8",
44
"description": "Crypto.com Chain Desktop Wallet App",
55
"repository": "github:crypto-com/chain-desktop-wallet",
66
"author": "Crypto.org <[email protected]>",

src/pages/bridge/bridge.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ const CronosBridge = props => {
438438

439439
if (isBridgeTransferSuccess) {
440440
try {
441-
const callMaxCount = 3;
441+
const callMaxCount = 6;
442442
const callTimeout = 6_000;
443443
const callInterval = 8_000;
444444
let callFailedCounts = 0;

src/pages/create/create.tsx

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -767,36 +767,39 @@ const FormCreate: React.FC<FormCreateProps> = props => {
767767
{t('create.LedgerAddressIndexBalanceTable.description')}
768768
</div>
769769
<div className="item">
770-
<Select
771-
style={{ width: '180px', textAlign: 'center' }}
772-
placeholder={`${t('general.select')} ${t(
773-
'create.LedgerAddressIndexBalanceTable.assetType.label',
774-
)}`}
775-
disabled={props.isWalletSelectFieldDisable}
776-
defaultActiveFirstOption
777-
onSelect={e => {
778-
setRecoil(ledgerIsConnectedState, LedgerConnectedApp.NOT_CONNECTED);
779-
setLedgerAddressList([]);
780-
switch (e) {
781-
case UserAssetType.TENDERMINT:
782-
setLedgerAssetType(UserAssetType.TENDERMINT);
783-
ledgerNotificationWithoutCheck(UserAssetType.TENDERMINT);
784-
break;
785-
case UserAssetType.EVM:
786-
setLedgerAssetType(UserAssetType.EVM);
787-
ledgerNotificationWithoutCheck(UserAssetType.EVM);
788-
break;
789-
default:
790-
}
791-
}}
792-
>
793-
<Select.Option key="tendermint" value={UserAssetType.TENDERMINT}>
794-
TENDERMINT
795-
</Select.Option>
796-
<Select.Option key="evm" value={UserAssetType.EVM}>
797-
EVM
798-
</Select.Option>
799-
</Select>
770+
<Form.Item name="assetType">
771+
<Select
772+
style={{ width: '180px', textAlign: 'center' }}
773+
placeholder={`${t('general.select')} ${t(
774+
'create.LedgerAddressIndexBalanceTable.assetType.label',
775+
)}`}
776+
disabled={props.isWalletSelectFieldDisable}
777+
defaultActiveFirstOption
778+
onSelect={e => {
779+
setRecoil(ledgerIsConnectedState, LedgerConnectedApp.NOT_CONNECTED);
780+
setLedgerAddressList([]);
781+
switch (e) {
782+
case UserAssetType.TENDERMINT:
783+
setLedgerAssetType(UserAssetType.TENDERMINT);
784+
ledgerNotificationWithoutCheck(UserAssetType.TENDERMINT);
785+
break;
786+
case UserAssetType.EVM:
787+
setLedgerAssetType(UserAssetType.EVM);
788+
ledgerNotificationWithoutCheck(UserAssetType.EVM);
789+
break;
790+
default:
791+
}
792+
}}
793+
>
794+
<Select.Option key="tendermint" value={UserAssetType.TENDERMINT}>
795+
TENDERMINT
796+
</Select.Option>
797+
<Select.Option key="evm" value={UserAssetType.EVM}>
798+
EVM
799+
</Select.Option>
800+
</Select>
801+
</Form.Item>
802+
800803
{ledgerAssetType ? (
801804
<LedgerAddressIndexBalanceTable
802805
addressIndexBalanceList={ledgerAddressList}
@@ -837,6 +840,9 @@ const FormCreate: React.FC<FormCreateProps> = props => {
837840
onChange={() => {
838841
setLedgerAddressList([]);
839842
setLedgerAssetType(undefined);
843+
props.form.setFieldsValue({
844+
assetType: undefined,
845+
});
840846
setDerivationPath({
841847
tendermint: LedgerSigner.getDerivationPath(
842848
props.form.getFieldValue('addressIndex'),

src/service/TransactionSenderService.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import { getCronosEvmAsset, sleep } from '../utils/utils';
4040
import { BridgeService } from './bridge/BridgeService';
4141
import { walletService } from './WalletService';
4242
import { getCronosTendermintFeeConfig } from './Gas';
43+
import { DerivationPathStandard } from './signers/LedgerSigner';
4344

4445
export class TransactionSenderService {
4546
public readonly storageService: StorageService;
@@ -68,6 +69,7 @@ export class TransactionSenderService {
6869
const currentSession = await this.storageService.retrieveCurrentSession();
6970
const fromAddress = currentSession.wallet.address;
7071
const walletAddressIndex = currentSession.wallet.addressIndex;
72+
const walletDerivationPathStandard = currentSession.wallet.derivationPathStandard ?? DerivationPathStandard.BIP44;
7173
if (!transferRequest.memo && !currentSession.wallet.config.disableDefaultClientMemo) {
7274
transferRequest.memo = DEFAULT_CLIENT_MEMO;
7375
}
@@ -125,6 +127,7 @@ export class TransactionSenderService {
125127

126128
signedTx = await device.signEthTx(
127129
walletAddressIndex,
130+
walletDerivationPathStandard,
128131
Number(transfer.asset?.config?.chainId), // chainid
129132
transfer.nonce,
130133
web3.utils.toHex(gasLimitTx) /* gas limit */,
@@ -223,6 +226,7 @@ export class TransactionSenderService {
223226

224227
signedTx = await device.signEthTx(
225228
walletAddressIndex,
229+
walletDerivationPathStandard,
226230
Number(transfer.asset?.config?.chainId), // chainid
227231
transfer.nonce,
228232
web3.utils.toHex(gasLimitTx) /* gas limit */,

src/service/bridge/BridgeService.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import {
3030
BridgeTransactionStatusResponse,
3131
} from './contracts/BridgeModels';
3232
import { getCronosTendermintFeeConfig } from '../Gas';
33+
import { DerivationPathStandard } from '../signers/LedgerSigner';
3334

3435
export class BridgeService {
3536
public readonly storageService: StorageService;
@@ -134,12 +135,14 @@ export class BridgeService {
134135
if (currentSession.wallet.walletType === LEDGER_WALLET_TYPE) {
135136
const device = createLedgerDevice();
136137
const walletAddressIndex = currentSession.wallet.addressIndex;
138+
const walletDerivationPathStandard = currentSession.wallet.derivationPathStandard ?? DerivationPathStandard.BIP44;
137139

138140
// Use fixed hard-coded max GasLimit for bridge transactions ( Known contract and predictable consumption )
139141
const gasPriceTx = web3.utils.toBN(bridgeTransaction.gasPrice);
140142

141143
signedTransactionHex = await device.signEthTx(
142144
walletAddressIndex,
145+
walletDerivationPathStandard,
143146
chainId, // chainid
144147
bridgeTransaction.nonce,
145148
web3.utils.toHex(gasLimit) /* gas limit */,

src/service/cronos/CronosClient.spec.ts

Lines changed: 7 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ describe('CronosClient', () => {
6464
status: '1',
6565
};
6666
axiosMock
67-
.onGet('/api', {
67+
.onGet('', {
6868
params: {
6969
module: 'account',
7070
action: 'txlist',
@@ -83,7 +83,7 @@ describe('CronosClient', () => {
8383

8484
const cronosClient = new CronosClient(
8585
'https://evm-t3.cronos.org:8545/',
86-
'https://cronos-chainindex.com',
86+
'https://cronos.org/explorer/testnet3/api',
8787
);
8888

8989
const txListRespone = await cronosClient.getTxsByAddress(
@@ -104,42 +104,9 @@ describe('CronosClient', () => {
104104
});
105105

106106
it('should return the `pendingTxList` from chainIndexAPI ', async () => {
107-
const txPendingListStub = {
108-
message: 'OK',
109-
result: [
110-
{
111-
contractAddress: '',
112-
cumulativeGasUsed: '52380',
113-
from: '0x5a58b4d21720a96077ef0df280d73a26249f0784',
114-
gas: '72000',
115-
gasPrice: '100',
116-
gasUsed: '1000',
117-
hash: '0xc7d45697d4f2296964500a83ca3fbcc34f6d68ba58ed6b8ea4fe93363d6dd384',
118-
input:
119-
'0xa9059cbb000000000000000000000000899c7b2a8d62c3b848c052a16a4364a091eb308b0000000000000000000000000000000000000000000000000000102e294e53fd',
120-
nonce: '2992',
121-
to: '0x95f7c0b0def5ec981709c5c47e32963e5450bf38',
122-
value: '0',
123-
},
124-
{
125-
contractAddress: '',
126-
cumulativeGasUsed: '52380',
127-
from: '0x5a58b4d21720a96077ef0df280d73a26249f0784',
128-
gas: '72000',
129-
gasPrice: '100',
130-
gasUsed: '1000',
131-
hash: '0xc7d45697d4f2296964500a83ca3fbcc34f6d68ba58ed6b8ea4fe93363d6dd384',
132-
input:
133-
'0xa9059cbb000000000000000000000000899c7b2a8d62c3b848c052a16a4364a091eb308b0000000000000000000000000000000000000000000000000000102e294e53fd',
134-
nonce: '2992',
135-
to: '0x95f7c0b0def5ec981709c5c47e32963e5450bf38',
136-
value: '0',
137-
},
138-
],
139-
status: '1',
140-
};
107+
const txPendingListStub = { message: 'No transactions found', result: [], status: '0' };
141108
axiosMock
142-
.onGet('/api', {
109+
.onGet('', {
143110
params: {
144111
module: 'account',
145112
action: 'pendingtxlist',
@@ -159,14 +126,14 @@ describe('CronosClient', () => {
159126
const cronosClient = new CronosClient(
160127
// 'https://cronos-testnet-3.crypto.org:8545/',
161128
'https://evm-t3.cronos.org:8545/',
162-
'https://cronos-chainindex.com',
129+
'https://cronos.org/explorer/testnet3/api',
163130
);
164131
const txPendingListRespone = await cronosClient.getPendingTxsByAddress(
165132
'0x95F7C0B0dEF5Ec981709c5C47E32963E5450bF38',
166133
{ page: '1', offset: '2' },
167134
);
168-
expect(txPendingListRespone.message).to.equal('OK');
169-
expect(txPendingListRespone.status).to.equal('1');
135+
expect(txPendingListRespone.message).to.equal('No transactions found');
136+
expect(txPendingListRespone.status).to.equal('0');
170137
expect(txPendingListRespone.result).to.deep.equal(txPendingListStub.result);
171138

172139
const txPendingListEmptyRespone = await cronosClient.getPendingTxsByAddress(

src/service/cronos/CronosClient.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export class CronosClient extends EVMClient implements ICronosChainIndexAPI {
5959

6060
const txListResponse: AxiosResponse<TxListAPIResponse> = await axios({
6161
baseURL: this.cronosExplorerAPIBaseURL,
62-
url: '/api',
62+
url: '',
6363
params: requestParams,
6464
});
6565

@@ -82,7 +82,7 @@ export class CronosClient extends EVMClient implements ICronosChainIndexAPI {
8282

8383
const txListResponse: AxiosResponse<PendingTxListAPIResponse> = await axios({
8484
baseURL: this.cronosExplorerAPIBaseURL,
85-
url: '/api',
85+
url: '',
8686
params: requestParams,
8787
});
8888

@@ -105,7 +105,7 @@ export class CronosClient extends EVMClient implements ICronosChainIndexAPI {
105105

106106
const txListResponse: AxiosResponse<TokenTransferEventLogsResponse> = await axios({
107107
baseURL: this.cronosExplorerAPIBaseURL,
108-
url: '/api',
108+
url: '',
109109
params: requestParams,
110110
});
111111

@@ -124,7 +124,7 @@ export class CronosClient extends EVMClient implements ICronosChainIndexAPI {
124124

125125
const txListResponse: AxiosResponse<TokensOwnedByAddressResponse> = await axios({
126126
baseURL: this.cronosExplorerAPIBaseURL,
127-
url: '/api',
127+
url: '',
128128
params: requestParams,
129129
});
130130

@@ -143,7 +143,7 @@ export class CronosClient extends EVMClient implements ICronosChainIndexAPI {
143143

144144
const txListResponse: AxiosResponse<ContractDataResponse> = await axios({
145145
baseURL: this.cronosExplorerAPIBaseURL,
146-
url: '/api',
146+
url: '',
147147
params: requestParams,
148148
});
149149

0 commit comments

Comments
 (0)