chore(hdnode):fix signTransaction with chainId and truffleProvider with chainId

staking
neeboo 5 years ago
parent 504f5416d2
commit d4c82f0ef2
  1. 16
      packages/harmony-account/src/hdnode.ts
  2. 14
      packages/harmony-core/src/truffleProvider.ts

@ -49,8 +49,7 @@ export class HDNode {
public provider: HttpProvider | WSProvider;
public gasLimit: string;
public gasPrice: string;
private messenger: Messenger;
public messenger: Messenger;
private shardID: number;
private hdwallet: hdkey | undefined;
private path: string;
@ -202,7 +201,18 @@ export class HDNode {
const signerAccount = new Account(prv, this.messenger);
const tx = new Transaction(
{ ...txParams, from, to, gasLimit, gasPrice, value, nonce, data, shardID: this.shardID },
{
...txParams,
from,
to,
gasLimit,
gasPrice,
value,
nonce,
data,
shardID: this.shardID,
chainId: this.messenger.chainId,
},
this.messenger,
TxStatus.INTIALIZED,
);

@ -63,6 +63,7 @@ export class TruffleProvider extends HDNode {
}
async send(...args: [RPCRequestPayload<any>, any]) {
const { newArgs, id, params, newMethod, callback } = this.resolveArgs(...args);
console.log({ newMethod, newArgs, id, params });
switch (newMethod) {
case 'hmy_accounts': {
const accounts = this.getAccounts();
@ -120,6 +121,18 @@ export class TruffleProvider extends HDNode {
);
return this.resolveResult(result);
}
case 'net_version': {
callback(null, {
result: String(this.messenger.chainId),
id,
jsonrpc: '2.0',
});
return {
result: String(this.messenger.chainId),
id,
jsonrpc: '2.0',
};
}
case 'hmy_getBlockByNumber': {
const result = await this.provider.send(newArgs, (err: any, res: any) => {
try {
@ -149,6 +162,7 @@ export class TruffleProvider extends HDNode {
default: {
// hmy_getBlockByNumber
const result = await this.provider.send(
newArgs,
(err: any, res: ResponseMiddleware | any) => this.resolveCallback(err, res, callback),

Loading…
Cancel
Save