Skip to content

Commit

Permalink
fix: approve params
Browse files Browse the repository at this point in the history
  • Loading branch information
MdTeach committed Jul 13, 2023
1 parent 352fcbe commit e5b0a7f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
11 changes: 8 additions & 3 deletions Sources/Chat/Send.swift
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,16 @@ extension PushChat {
var privateKey: String
var env: ENV

public init(fromAddress: String, toAddress: String, privateKey: String, env: ENV) {
self.fromDID = walletToPCAIP10(account: fromAddress)
self.toDID = walletToPCAIP10(account: toAddress)
public init(requesterAddress: String, approverAddress: String, privateKey: String, env: ENV) {
self.fromDID = walletToPCAIP10(account: requesterAddress)
self.toDID = walletToPCAIP10(account: approverAddress)
self.privateKey = privateKey
self.env = env

if(isGroupChatId(requesterAddress)){
self.toDID = walletToPCAIP10(account: requesterAddress)
self.fromDID = walletToPCAIP10(account: approverAddress)
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions Tests/Chat/P2P/SendTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,13 @@ class SendChatsTests: XCTestCase {
// func testAcceptIntent() async throws{
// let res = try await Push.PushChat.approve(
// PushChat.ApproveOptions(
// fromAddress: "0x1D192143B92C7c03C3a2B8379Fd87CfE63Cb49E2",
// toAddress: UserAddress,
// requesterAddress: "6637eb962ed4139a97dac440f46d5f4f6098e77b81e14d8214f8d945ab108f22",
// approverAddress: UserAddress,
// privateKey: UserPrivateKey,
// env: .STAGING)
// )

// print(res)
// }

func testSendMessageEncrypted() async throws {
Expand Down
6 changes: 3 additions & 3 deletions docs/Chats.md
Original file line number Diff line number Diff line change
Expand Up @@ -810,15 +810,15 @@ Allowed Options (params with _ are mandatory)
```swift
let response:String = try await PushChat.approve(PushChat.ApproveOptions(
fromAddress: String, toAddress: String, privateKey: String, env: ENV
requesterAddress: String, approverAddress: String privateKey: String, env: ENV
));
```
Allowed Options (params with _ are mandatory)
| Param | Type | Default | Remarks |
|----------|---------|---------|--------------------------------------------|
| fromAddress | string | - | chat request sender's address or chatId of a group |
| toAddress | string | - | chat request sender's address or chatId of a group |
| requesterAddress | string | - | chat request sender's address or chatId of a group |
| approverAddress | string | - | approver address |
| privateKey | string | - | users encrtyped pgp private key|
| env | string | staging | API env - 'prod', 'staging', 'dev'|
Expand Down

0 comments on commit e5b0a7f

Please sign in to comment.