46
46
- [ Infura Websocket interactions] ( #infura-websocket-interactions )
47
47
- [ Connect to Infura endpoint] ( #connect-to-infura-endpoint )
48
48
- [ Connect to custom Infura-like endpoint] ( #connect-to-custom-infura-like-endpoint )
49
- - [ Create a filter in the node to notify when something happened] ( #create -a-filter-in-the-node-to-notify-when-something-happened )
49
+ - [ Set a filter in the node to notify when something happened] ( #set -a-filter-in-the-node-to-notify-when-something-happened )
50
50
- [ Get new pending transactions] ( #get-new-pending-transactions )
51
51
- [ Create a new subscription over particular events] ( #create-a-new-subscription-over-particular-events )
52
52
- [ Subscribe on new pending transactions] ( #subscribe-on-new-pending-transactions )
53
+ - [Subscribe on logs](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#subscribe-on-logs)
54
+ - [Subscribe on new heads](https://github.com/matter-labs/web3swift/blob/master/Documentation/Usage.md#subscribe-on-new-heads)
53
55
- [ ENS] ( #ens )
54
56
- [ Registry] ( #registry )
55
57
- [ Resolver] ( #resolver )
@@ -181,7 +183,7 @@ if wallet.isHD {
181
183
``` swift
182
184
let password = " web3swift"
183
185
let ethereumAddress = EthereumAddress (wallet.address )!
184
- let pkData = try ! keysoreManager .UNSAFE_getPrivateKeyData (password : password, account : ethereumAddress).toHexString ()
186
+ let pkData = try ! keystoreManager .UNSAFE_getPrivateKeyData (password : password, account : ethereumAddress).toHexString ()
185
187
```
186
188
187
189
## Ethereum Endpoints interaction
@@ -421,18 +423,28 @@ socketProvider = InfuraWebsocketProvider.connectToInfuraSocket(.Mainnet, delegat
421
423
socketProvider = InfuraWebsocketProvider.connectToSocket (" ws://your.endpoint" , delegate : delegate)
422
424
```
423
425
424
- #### Create a filter in the node to notify when something happened
426
+ #### Set a filter in the node to notify when something happened
425
427
426
428
To study possible filters read [ Infura WSS filters documentation] ( https://infura.io/docs/ethereum/wss/introduction )
427
429
428
430
``` swift
429
- try ! socketProvider.filter (method : < InfuraWebsocketMethod> , params : < [Encodable]?> )
431
+ // Getting logs
432
+ try ! socketProvider.setFilterAndGetLogs (method : < InfuraWebsocketMethod> , params : < [Encodable]?> )
433
+ // Getting changes
434
+ try ! socketProvider.setFilterAndGetChanges (method : < InfuraWebsocketMethod> , params : < [Encodable]?> )
435
+ ```
436
+ Or you can provide parameters in more convenient way:
437
+ ``` swift
438
+ // Getting logs
439
+ try ! socketProvider.setFilterAndGetLogs (method : < InfuraWebsocketMethod> , address : < EthereumAddress?> , fromBlock : < BlockNumber?> , toBlock : < BlockNumber?> , topics : < [String ]?> )
440
+ // Getting changes
441
+ try ! socketProvider.setFilterAndGetChanges (method : < InfuraWebsocketMethod> , address : < EthereumAddress?> , fromBlock : < BlockNumber?> , toBlock : < BlockNumber?> , topics : < [String ]?> )
430
442
```
431
443
432
444
#### Get new pending transactions
433
445
434
446
``` swift
435
- try ! socketProvider.filter (method : .newPendingTransactionFilter )
447
+ try ! socketProvider.setFilterAndGetLogs (method : .newPendingTransactionFilter )
436
448
```
437
449
438
450
#### Create a new subscription over particular events
@@ -449,6 +461,18 @@ try! socketProvider.subscribe(params: <[Encodable]>)
449
461
try ! socketProvider.subscribeOnNewPendingTransactions ()
450
462
```
451
463
464
+ #### Subscribe on logs
465
+
466
+ ``` swift
467
+ try ! socketProvider.subscribeOnLogs (addresses : < [EthereumAddress]?> , topics : < [String ]?> )
468
+ ```
469
+
470
+ #### Subscribe on new heads
471
+
472
+ ``` swift
473
+ try ! socketProvider.subscribeOnNewHeads ()
474
+ ```
475
+
452
476
## ENS
453
477
454
478
You need ENS instance for future actions:
0 commit comments