Skip to content

Commit 2981241

Browse files
authored
feature: notify rn sdk whenever chainId or account changes (#190)
* feature: notify rn sdk whenever chainId or account changes * chore: bump ios sdk version
1 parent d0d93d3 commit 2981241

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Alternatively, you can add the URL directly in your project's package file:
5454
dependencies: [
5555
.package(
5656
url: "https://github.com/MetaMask/metamask-ios-sdk",
57-
from: "0.8.8"
57+
from: "0.8.9"
5858
)
5959
]
6060
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//
2+
// Notification.swift
3+
//
4+
5+
import Foundation
6+
7+
public extension Notification.Name {
8+
static let MetaMaskAccountChanged = Notification.Name("MetaMaskAccountChanged")
9+
static let MetaMaskChainIdChanged = Notification.Name("MetaMaskChainChanged")
10+
}

Sources/metamask-ios-sdk/Classes/SDK/MetaMaskSDK.swift

+2
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,13 @@ public extension MetaMaskSDK {
214214
extension MetaMaskSDK: EthereumEventsDelegate {
215215
func chainIdChanged(_ chainId: String) {
216216
self.chainId = chainId
217+
NotificationCenter.default.post(name: .MetaMaskChainIdChanged, object: nil, userInfo: ["chainId": chainId])
217218
}
218219

219220
func accountChanged(_ account: String) {
220221
self.account = account
221222
connected = true
223+
NotificationCenter.default.post(name: .MetaMaskAccountChanged, object: nil, userInfo: ["account": account])
222224
}
223225
}
224226

metamask-ios-sdk.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'metamask-ios-sdk'
3-
s.version = '0.8.8'
3+
s.version = '0.8.9'
44
s.summary = 'Enable users to easily connect with their MetaMask Mobile wallet.'
55
s.swift_version = '5.5'
66

0 commit comments

Comments
 (0)