This package gives access to Push Protocol (Push Nodes) APIs. Visit Developer Docs or Push.org to learn more.
// imports
import push.kotlin.sdk.channels.Channel
import push.kotlin.sdk.channels.ChannelOpt
import push.kotlin.sdk.channels.ChannelSubscriber
import push.kotlin.sdk.channels.ChannelSearch
val channelAddress = "0x2AEcb6DeE3652dA1dD6b54D5fd4f7D8F43DaEb78"
val channel:PushChannel? = Channel.getChannel(channelAddress, ENV.staging)
val channels:PushChannels? = Channel.getAllChannels(page, limit, ENV.staging)
val channels:PushChannels = ChannelSearch.searchChannels(
query = "channel name or channel address",
page = 1,
limit = 10,
order = "desc",
env = ENV.staging
)
val subscribers:Result<ChannelSubscribers> = ChannelSubscriber.getSubscribers(
channel = "0x2AEcb6DeE3652dA1dD6b54D5fd4f7D8F43DaEb78",
page = 5,
limit = 1,
env = ENV.staging
)
val res:Result<Boolean> = ChannelSubscriber.IsSubscribed(
userAddress = "0x5d73D70EB962083eDED53F03e2D4fA7d7773c4CE",
channelAddress = "0x2AEcb6DeE3652dA1dD6b54D5fd4f7D8F43DaEb78",
env = ENV.staging
)
To subscribe/unsubscribe TypedSigner
needs to be implemented.
abstract class TypedSinger{
abstract fun getEip712Signature(message: String): Result<String>
abstract fun getAddress(): Result<String>
}
message
string is message to sign containing type information, a domain separator, and data complying with WalletConnect eth_signTypedData
rpc message format.
for opt in `message` following string will be passed:
{
"types":{
"Subscribe":[
{
"name":"channel",
"type":"address"
},
{
"name":"subscriber",
"type":"address"
},
{
"name":"action",
"type":"string"
}
],
"EIP712Domain":[
{
"name":"name",
"type":"string"
},
{
"name":"chainId",
"type":"uint256"
},
{
"name":"verifyingContract",
"type":"address"
}
]
},
"primaryType":"Subscribe",
"domain":{
"name":"EPNS COMM V1",
"chainId":5,
"verifyingContract":"0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa"
},
"message":{
"channel":"Channel Address",
"subscriber":"Subscriber Address",
"action":"Subscribe"
}
}
var isSuccess:Result<Boolean> = ChannelOpt.subscribe(
channel = "0x2AEcb6DeE3652dA1dD6b54D5fd4f7D8F43DaEb78",
subscriber = userAddress,
signer = optInSigner,
env = ENV.staging
)
var isSuccess:Result<Boolean> = ChannelOpt.unsubscribe(
channel = "0x2AEcb6DeE3652dA1dD6b54D5fd4f7D8F43DaEb78",
subscriber = userAddress,
signer = optInSigner,
env = ENV.staging
)