Fixed RPC method calls.
This commit is contained in:
parent
5dc2621a32
commit
06281e85c4
@ -36,21 +36,32 @@ function numberOrBN(value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
function zpad(buffer, length) {
|
||||
var zero = new Buffer([0]);
|
||||
while (buffer.length < length) {
|
||||
buffer = Buffer.concat([zero, buffer]);
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
function coderNumber(size, signed) {
|
||||
return {
|
||||
encode: function(value) {
|
||||
value = numberOrBN(value)
|
||||
// if (signed) {
|
||||
return value.toTwos(32 * 8).toArrayLike(Buffer, 'be', 32);
|
||||
// } else {
|
||||
// return value.toArrayLike(Buffer, 'be', 32);
|
||||
// }
|
||||
if (signed) {
|
||||
value = value.toTwos(32 * 8);
|
||||
} else if (value < 0) {
|
||||
value = value.toTwos(size * 8);
|
||||
}
|
||||
return value.toArrayLike(Buffer, 'be', 32);
|
||||
},
|
||||
decode: function(data, offset) {
|
||||
var value = new utils.BN(data.slice(offset, offset + 32));
|
||||
// if (signed) {
|
||||
value = value.fromTwos(32 * 8);
|
||||
// }
|
||||
if (signed) {
|
||||
value = value.fromTwos(size * 8);
|
||||
} else {
|
||||
value = value.mod((new utils.BN(2)).pow(new utils.BN(size * 8)))
|
||||
}
|
||||
return {
|
||||
consumed: 32,
|
||||
value: value,
|
||||
@ -326,7 +337,7 @@ function Interface(abi) {
|
||||
return Interface.decodeParams(
|
||||
outputTypes,
|
||||
utils.hexOrBuffer(data)
|
||||
)
|
||||
);
|
||||
};
|
||||
} else {
|
||||
result.type = 'transaction';
|
||||
@ -576,8 +587,8 @@ function Contract(provider, wallet, contractAddress, contractInterface) {
|
||||
|
||||
return new Promise(function(resolve, reject) {
|
||||
Promise.all([
|
||||
provider.client.sendMessage('getTransactionCount', [wallet.address, 'pending']),
|
||||
provider.client.sendMessage('getGasPrice', []),
|
||||
provider.client.sendMessage('eth_getTransactionCount', [wallet.address, 'pending']),
|
||||
provider.client.sendMessage('eth_gasPrice', []),
|
||||
]).then(function(results) {
|
||||
if (transaction.nonce == null) {
|
||||
transaction.nonce = results[0];
|
||||
@ -591,7 +602,7 @@ function Contract(provider, wallet, contractAddress, contractInterface) {
|
||||
}
|
||||
|
||||
var signedTransaction = wallet.sign(transaction);
|
||||
provider.client.sendMessage('sendRawTransaction', [signedTransaction]).then(function(txid) {
|
||||
provider.client.sendMessage('eth_sendRawTransaction', [signedTransaction]).then(function(txid) {
|
||||
resolve(txid);
|
||||
}, function(error) {
|
||||
reject(error);
|
||||
|
Loading…
Reference in New Issue
Block a user