mirror of
https://github.com/status-im/EIPs.git
synced 2025-01-26 23:00:38 +00:00
Automatically merged updates to draft EIP(s) 1193
Hi, I'm a bot! This change was automatically merged because: - It only modifies existing Draft or Last Call EIP(s) - The PR was approved or written by at least one author of each modified EIP - The build is passing
This commit is contained in:
parent
ea9131babf
commit
07da9ea0dc
@ -149,7 +149,7 @@ web3.setProvider(ethereum);
|
||||
ethereum
|
||||
.send('eth_getBlockByNumber', ['latest', 'true'])
|
||||
.then(block => {
|
||||
console.log(`Block ${block.number}:\n${block}`);
|
||||
console.log(`Block ${block.number}:`, block);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(
|
||||
@ -167,16 +167,16 @@ ethereum
|
||||
|
||||
// Example 3: Log available accounts
|
||||
ethereum
|
||||
.send('eth_accounts')
|
||||
.then(accounts => {
|
||||
console.log(`Accounts:\n${accounts.join('\n')}`);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(
|
||||
`Error fetching accounts: ${error.message}.
|
||||
.send('eth_accounts')
|
||||
.then(accounts => {
|
||||
console.log(`Accounts:\n${accounts.join('\n')}`);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(
|
||||
`Error fetching accounts: ${error.message}.
|
||||
Code: ${error.code}. Data: ${error.data}`
|
||||
);
|
||||
});
|
||||
);
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
@ -193,14 +193,14 @@ ethereum
|
||||
.then(subscriptionId => {
|
||||
subId = subscriptionId;
|
||||
ethereum.on(subscriptionId, block => {
|
||||
if (result instanceOf Error) {
|
||||
if (block instanceof Error) {
|
||||
const error = result;
|
||||
console.error(
|
||||
`Error from newHeads subscription: ${error.message}.
|
||||
Code: ${error.code}. Data: ${error.data}`
|
||||
);
|
||||
} else {
|
||||
console.log(`New block ${block.number}:\n${block}`);
|
||||
console.log(`New block ${block.number}:`, block);
|
||||
}
|
||||
});
|
||||
})
|
||||
@ -208,7 +208,7 @@ ethereum
|
||||
console.error(
|
||||
`Error making newHeads subscription: ${error.message}.
|
||||
Code: ${error.code}. Data: ${error.data}`
|
||||
);
|
||||
);
|
||||
});
|
||||
// to unsubscribe
|
||||
ethereum
|
||||
@ -233,9 +233,7 @@ ethereum.removeListener('accountsChanged', logAccounts);
|
||||
|
||||
// Example 6: Log if connection ends
|
||||
ethereum.on('close', (code, reason) => {
|
||||
console.log(
|
||||
`Ethereum provider connection closed: ${reason}. Code: ${code}`
|
||||
);
|
||||
console.log(`Ethereum provider connection closed: ${reason}. Code: ${code}`);
|
||||
});
|
||||
```
|
||||
|
||||
@ -377,10 +375,11 @@ class EthereumProvider extends EventEmitter {
|
||||
return promise;
|
||||
}
|
||||
|
||||
subscribe(subscriptionType, subscriptionMethod, params) {
|
||||
subscribe(subscriptionType, subscriptionMethod, params = []) {
|
||||
return this.send(subscriptionType, [subscriptionMethod, ...params]).then(
|
||||
subscriptionId => {
|
||||
this._activeSubscriptions.push(subscriptionId);
|
||||
return subscriptionId;
|
||||
}
|
||||
);
|
||||
}
|
||||
@ -394,6 +393,7 @@ class EthereumProvider extends EventEmitter {
|
||||
);
|
||||
// Remove listeners on subscriptionId
|
||||
this.removeAllListeners(subscriptionId);
|
||||
return success;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user