Skip to content

Commit 0aee62d

Browse files
committed
Updated dist and added donation address to readme.
1 parent 1531793 commit 0aee62d

13 files changed

+346
-142
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ Documentation is generated using [Sphinx](http://www.sphinx-doc.org) and can be
4646

4747

4848

49+
Donations
50+
---------
51+
52+
I do this because I love it, but if you want to buy me a coffee, I won't say no. **:o)**
53+
54+
Ethereum: `0xEA517D5a070e6705Cc5467858681Ed953d285Eb9`
55+
56+
4957
License
5058
-------
5159

dist/ethers-contracts.js

Lines changed: 58 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,19 @@ function Contract(address, contractInterface, signerOrProvider) {
148148
var noncePromise = null;
149149
if (transaction.nonce) {
150150
noncePromise = Promise.resolve(transaction.nonce)
151+
} else if (signer.getTransactionCount) {
152+
noncePromise = signer.getTransactionCount;
153+
if (!(noncePromise instanceof Promise)) {
154+
noncePromise = Promise.resolve(noncePromise);
155+
}
151156
} else {
152-
noncePromise = provider.getTransactionCount(signer.address, 'pending');
157+
var addressPromise = signer.getAddress();
158+
if (!(addressPromise instanceof Promise)) {
159+
addressPromise = Promise.resolve(addressPromise);
160+
}
161+
noncePromise = addressPromise.then(function(address) {
162+
return provider.getTransactionCount(address, 'pending');
163+
});
153164
}
154165

155166
var gasPricePromise = null;
@@ -208,7 +219,7 @@ function Contract(address, contractInterface, signerOrProvider) {
208219

209220
function handleEvent(log) {
210221
try {
211-
var result = eventInfo.parse(log.data);
222+
var result = eventInfo.parse(log.topics, log.data);
212223
eventCallback.apply(log, Array.prototype.slice.call(result));
213224
} catch (error) {
214225
console.log(error);
@@ -245,7 +256,8 @@ function Contract(address, contractInterface, signerOrProvider) {
245256
}
246257

247258
utils.defineProperty(Contract, 'getDeployTransaction', function(bytecode, contractInterface) {
248-
if (typeof(contractInterface) === 'string') {
259+
260+
if (!(contractInterface instanceof Interface)) {
249261
contractInterface = new Interface(contractInterface);
250262
}
251263

@@ -708,7 +720,6 @@ function Interface(abi) {
708720
case 'event':
709721
var func = (function() {
710722
var inputTypes = getKeys(method.inputs, 'type');
711-
var inputNames = getKeys(method.inputs, 'name', true);
712723
var func = function() {
713724
var signature = method.name + '(' + getKeys(method.inputs, 'type').join(',') + ')';
714725
var result = {
@@ -717,12 +728,50 @@ function Interface(abi) {
717728
signature: signature,
718729
topics: [utils.keccak256(utils.toUtf8Bytes(signature))],
719730
};
720-
result.parse = function(data) {
721-
return Interface.decodeParams(
722-
inputNames,
723-
inputTypes,
731+
732+
result.parse = function(topics, data) {
733+
734+
// Strip the signature off of non-anonymous topics
735+
if (!method.anonymous) { topics = topics.slice(1); }
736+
737+
var inputNamesIndexed = [], inputNamesNonIndexed = [];
738+
var inputTypesIndexed = [], inputTypesNonIndexed = [];
739+
method.inputs.forEach(function(input) {
740+
if (input.indexed) {
741+
inputNamesIndexed.push(input.name);
742+
inputTypesIndexed.push(input.type);
743+
} else {
744+
inputNamesNonIndexed.push(input.name);
745+
inputTypesNonIndexed.push(input.type);
746+
}
747+
});
748+
749+
var resultIndexed = Interface.decodeParams(
750+
inputNamesIndexed,
751+
inputTypesIndexed,
752+
utils.concat(topics)
753+
);
754+
755+
var resultNonIndexed = Interface.decodeParams(
756+
inputNamesNonIndexed,
757+
inputTypesNonIndexed,
724758
utils.arrayify(data)
725759
);
760+
761+
var result = new Result();
762+
var nonIndexedIndex = 0, indexedIndex = 0;
763+
method.inputs.forEach(function(input, i) {
764+
if (input.indexed) {
765+
result[i] = resultIndexed[indexedIndex++];
766+
} else {
767+
result[i] = resultNonIndexed[nonIndexedIndex++];
768+
}
769+
if (input.name) { result[input.name] = result[i]; }
770+
});
771+
772+
result.length = method.inputs.length;
773+
774+
return result;
726775
};
727776
return populateDescription(new EventDescription(), result);
728777
}
@@ -746,7 +795,7 @@ function Interface(abi) {
746795
}
747796
};
748797

749-
abi.forEach(addMethod, this);
798+
this.abi.forEach(addMethod, this);
750799

751800
// If there wasn't a constructor, create the default constructor
752801
if (!deploy) {

dist/ethers-contracts.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ethers-providers.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ function checkLogTag(blockTag) {
8888
utils.defineProperty(EtherscanProvider.prototype, 'perform', function(method, params) {
8989
if (!params) { params = {}; }
9090

91-
var url = this.testnet ? 'https://testnet.etherscan.io': 'https://api.etherscan.io';
91+
var url = this.testnet ? 'https://ropsten.etherscan.io': 'https://api.etherscan.io';
9292

9393
var apiKey = '';
9494
if (this.apiKey) { apiKey += '&apikey=' + this.apiKey; }
@@ -5123,11 +5123,21 @@ function checkString(string) {
51235123
function checkBlockTag(blockTag) {
51245124
if (blockTag == null) { return 'latest'; }
51255125

5126-
if (utils.isHexString(blockTag)) { return blockTag; }
5126+
if (blockTag === 'earliest') { return '0x0'; }
51275127

5128-
if (blockTag === 'earliest') { blockTag = 0; }
51295128
if (typeof(blockTag) === 'number') {
5130-
return utils.hexlify(blockTag);
5129+
blockTag = utils.hexlify(blockTag);
5130+
}
5131+
5132+
if (utils.isHexString(blockTag)) {
5133+
// HACK: This seems to be a weird requirement some nodes have
5134+
// (e.g. INFURA on ropsten; INFURA on homestead is fine)
5135+
// Remove leading 0's from the hex blockTag
5136+
while (blockTag.length > 3 && blockTag.substring(0, 3) === '0x0') {
5137+
blockTag = '0x' + blockTag.substring(3);
5138+
}
5139+
5140+
return blockTag;
51315141
}
51325142

51335143
if (blockTag === 'latest' || blockTag === 'pending') {
@@ -5424,6 +5434,11 @@ function Provider(testnet, chainId) {
54245434
self.doPoll();
54255435
}
54265436

5437+
utils.defineProperty(this, 'resetEventsBlock', function(blockNumber) {
5438+
lastBlockNumber = blockNumber;
5439+
self.doPoll();
5440+
});
5441+
54275442
var poller = null;
54285443
Object.defineProperty(this, 'polling', {
54295444
get: function() { return (poller != null); },
@@ -5737,7 +5752,6 @@ utils.defineProperty(Provider.prototype, 'getEtherPrice', function() {
57375752
}
57385753
});
57395754

5740-
57415755
utils.defineProperty(Provider.prototype, 'doPoll', function() {
57425756

57435757
});

dist/ethers-providers.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)