Skip to content

Commit

Permalink
Add Gzip for wallet connect
Browse files Browse the repository at this point in the history
  • Loading branch information
lmcmz committed Feb 13, 2023
1 parent 55357f3 commit 3937837
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@
"version": "0.3.1"
}
},
{
"package": "Gzip",
"repositoryURL": "https://github.com/1024jp/GzipSwift",
"state": {
"branch": null,
"revision": "7a7f17761c76a932662ab77028a4329f67d645a4",
"version": "5.2.0"
}
},
{
"package": "PromiseKit",
"repositoryURL": "https://github.com/mxcl/PromiseKit.git",
Expand Down
9 changes: 9 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@
"version": "0.3.1"
}
},
{
"package": "Gzip",
"repositoryURL": "https://github.com/1024jp/GzipSwift",
"state": {
"branch": null,
"revision": "7a7f17761c76a932662ab77028a4329f67d645a4",
"version": "5.2.0"
}
},
{
"package": "PromiseKit",
"repositoryURL": "https://github.com/mxcl/PromiseKit.git",
Expand Down
2 changes: 2 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ let package = Package(
.package(url: "https://github.com/outblock/flow-swift.git", .exact("0.3.1")),
.package(url: "https://github.com/daltoniam/Starscream", .exact("3.1.1")),
.package(url: "https://github.com/WalletConnect/WalletConnectSwiftV2", .exact("1.0.6")),
.package(url: "https://github.com/1024jp/GzipSwift", .exact("5.2.0")),
],
targets: [
.target(
Expand All @@ -27,6 +28,7 @@ let package = Package(
.product(name: "Starscream", package: "Starscream"),
.product(name: "WalletConnect", package: "WalletConnectSwiftV2"),
.product(name: "WalletConnectAuth", package: "WalletConnectSwiftV2"),
.product(name: "Gzip", package: "GzipSwift"),
],
path: "Sources"
),
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ SDKs are open source, and you can use them according to the licence.
This is a Swift Package, and can be installed via Xcode with the URL of this repository:

```swift
.package(name: "FCL", url: "https://github.com/outblock/fcl-swift.git", from: "0.0.9")
.package(name: "FCL", url: "https://github.com/outblock/fcl-swift.git", from: "0.1.0")
```

## Config
Expand Down
5 changes: 4 additions & 1 deletion Sources/Provider/WalletConnect/WalletConnectProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import UIKit
import WalletConnectPairing
import WalletConnectSign
import WalletConnectUtils
import Gzip

extension WebSocket: WebSocketConnecting {}

Expand Down Expand Up @@ -138,10 +139,12 @@ extension FCL {

guard let request = request,
let data = try? JSONEncoder().encode(request),
let dataString = String(data: data, encoding: .utf8)
let compressedData = try? data.gzipped(level: .bestCompression)
else {
throw FCLError.encodeFailure
}

let dataString = compressedData.base64EncodedString()

let request1 = Request(topic: sessionTopic,
method: WCMethod(service: method).rawValue,
Expand Down

0 comments on commit 3937837

Please sign in to comment.