|
9 | 9 |
|
10 | 10 | from sentinel_sdk.querier.querier import Querier |
11 | 11 | from sentinel_sdk.transactor.transactor import Transactor |
12 | | -from sentinel_sdk.types import PageRequest, TxParams |
| 12 | +from sentinel_sdk.types import PageRequest, TxParams, RenewalPricePolicy |
13 | 13 |
|
14 | 14 |
|
15 | 15 | class SubscriptionModule(Querier, Transactor): |
@@ -162,18 +162,64 @@ def Allocate(self, address: str, bytes: str, id: int, tx_params: TxParams = TxPa |
162 | 162 | ) |
163 | 163 | return self.transaction([msg], tx_params) |
164 | 164 |
|
| 165 | + ''' |
165 | 166 | def Cancel(self, id: int, tx_params: TxParams = TxParams()): |
166 | 167 | msg = msg_pb2.MsgCancelRequest( |
167 | 168 | frm = self._account.address, |
168 | 169 | id = id, |
169 | 170 | ) |
170 | 171 | return self.transaction([msg], tx_params) |
171 | | - |
| 172 | + ''' |
| 173 | + |
| 174 | + def Cancel(self, id: int, tx_params: TxParams = TxParams()): |
| 175 | + msg = msg_pb2_3.MsgCancelSubscriptionRequest( |
| 176 | + frm = self._account.address, |
| 177 | + id = id, |
| 178 | + ) |
| 179 | + return self.transaction([msg], tx_params) |
| 180 | + |
| 181 | + # Used for plan subs |
172 | 182 | def StartSession(self, address: str, subscription_id: int, tx_params: TxParams = TxParams()): |
173 | 183 | msg = msg_pb2_3.MsgStartSessionRequest( |
174 | 184 | frm = self._account.address, |
175 | 185 | id = subscription_id, |
176 | | - address = address |
| 186 | + node_address = address |
| 187 | + ) |
| 188 | + return self.transaction([msg], tx_params) |
| 189 | + |
| 190 | + def ShareSubscription(self, subscription_id: int, wallet_address: str, bytes: str, tx_params: TxParams = TxParams()): |
| 191 | + msg = msg_pb2_3.MsgShareSubscriptionRequest( |
| 192 | + frm = self._account.address, |
| 193 | + id = subscription_id, |
| 194 | + acc_address = address, |
| 195 | + bytes = bytes, |
| 196 | + ) |
| 197 | + return self.transaction([msg], tx_params) |
| 198 | + |
| 199 | + def RenewSubscription(self, subscription_id: int, denom: str, tx_params: TxParams = TxParams()): |
| 200 | + msg = msg_pb2_3.MsgRenewSubscriptionRequest( |
| 201 | + frm = self._account.address, |
| 202 | + id = subscription_id, |
| 203 | + denom = denom, |
| 204 | + ) |
| 205 | + return self.transaction([msg], tx_params) |
| 206 | + |
| 207 | + # id is plan_id |
| 208 | + |
| 209 | + def StartSubscription(self, plan_id: int, denom: str, renewal: int = RenewalPricePolicy.RENEWAL_PRICE_POLICY_IF_LESSER_OR_EQUAL, tx_params: TxParams = TxParams()): |
| 210 | + msg = msg_pb2_3.MsgStartSubscriptionRequest( |
| 211 | + frm = self._account.address, |
| 212 | + id = plan_id, |
| 213 | + denom = denom, |
| 214 | + renewal_price_polilcy = renewal, |
| 215 | + ) |
| 216 | + return self.transaction([msg], tx_params) |
| 217 | + |
| 218 | + def UpdateSubscription(self, subscription_id: int, renewal: int = RenewalPricePolicy.RENEWAL_PRICE_POLICY_IF_LESSER_OR_EQUAL, tx_params: TxParams = TxParams()): |
| 219 | + msg = msg_pb2_3.MsgUpdateSubscriptionRequest( |
| 220 | + frm = self._account.address, |
| 221 | + id = id, |
| 222 | + renewal_price_policy = renewal, |
177 | 223 | ) |
178 | 224 | return self.transaction([msg], tx_params) |
179 | 225 | # Node subscriptions are returned by grpc querier in google's 'Any' type and need to be converted into desired protobuf type |
|
0 commit comments