Fixed function name in parsed transactions (#370).
This commit is contained in:
parent
4f6748ec4c
commit
6ca1d77298
@ -320,6 +320,7 @@ function addMethod(method: any): void {
|
|||||||
payable: (method.payable == null || !!method.payable),
|
payable: (method.payable == null || !!method.payable),
|
||||||
type: ((method.constant) ? 'call': 'transaction'),
|
type: ((method.constant) ? 'call': 'transaction'),
|
||||||
|
|
||||||
|
name: method.name,
|
||||||
signature: signature,
|
signature: signature,
|
||||||
sighash: sighash,
|
sighash: sighash,
|
||||||
});
|
});
|
||||||
@ -433,7 +434,7 @@ export class Interface {
|
|||||||
return new _TransactionDescription({
|
return new _TransactionDescription({
|
||||||
args: result,
|
args: result,
|
||||||
decode: func.decode,
|
decode: func.decode,
|
||||||
name: name,
|
name: func.name,
|
||||||
signature: func.signature,
|
signature: func.signature,
|
||||||
sighash: func.sighash,
|
sighash: func.sighash,
|
||||||
value: bigNumberify(tx.value || '0'),
|
value: bigNumberify(tx.value || '0'),
|
||||||
|
@ -231,6 +231,36 @@ describe('Test Interface Signatures', function() {
|
|||||||
'derived the correct signature hash');
|
'derived the correct signature hash');
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('derives correct description for human-readable ABI', function() {
|
||||||
|
var iface = new Interface([ "function transfer(address from, uint amount)" ]);
|
||||||
|
[
|
||||||
|
"transfer",
|
||||||
|
"transfer(address,uint256)"
|
||||||
|
].forEach(function(key) {
|
||||||
|
var descr = iface.functions[key];
|
||||||
|
assert.equal(descr.name, "transfer", "incorrect name key - " + key);
|
||||||
|
assert.equal(descr.signature, "transfer(address,uint256)", "incorrect signature key - " + key);
|
||||||
|
assert.equal(descr.sighash, "0xa9059cbb", "incorrect sighash key - " + key);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// See: https://github.com/ethers-io/ethers.js/issues/370
|
||||||
|
it ('parses transaction function', function() {
|
||||||
|
var iface = new Interface([ "function transfer(address from, uint amount)" ]);
|
||||||
|
|
||||||
|
// Transaction: 0x820cc57bc77be44d8f4f024a18e18f64a8b6e62a82a3d7897db5970dbe181ba1
|
||||||
|
var rawTx = "0xf8aa028502540be4008316e36094334eec1482109bd802d9e72a447848de3bcc106380b844a9059cbb000000000000000000000000851b9167b7cbf772d38efaf89705b35022880a070000000000000000000000000000000000000000000000000de0b6b3a764000026a03200bf26e5f10f7eda59c0aad9adc2334dda79e785b9b004342524d97a66fca9a0450b07a4dc450bb472e08f8370350fa365fcef6db1a95309ae4c06c9d0748092";
|
||||||
|
var tx = ethers.utils.parseTransaction(rawTx);
|
||||||
|
|
||||||
|
var descr = iface.parseTransaction(tx);
|
||||||
|
assert.equal(descr.args[0], '0x851b9167B7cbf772D38eFaf89705b35022880A07', 'parsed tx - args[0]');
|
||||||
|
assert.equal(descr.args[1].toString(), '1000000000000000000', 'parsed tx - args[1]');
|
||||||
|
assert.equal(descr.name, 'transfer', 'parsed tx - name');
|
||||||
|
assert.equal(descr.signature, 'transfer(address,uint256)', 'parsed tx - signature');
|
||||||
|
assert.equal(descr.sighash, '0xa9059cbb', 'parsed tx - sighash');
|
||||||
|
assert.equal(descr.value.toString(), '0', 'parsed tx - value');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Test Number Coder', function() {
|
describe('Test Number Coder', function() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user