mirror of https://github.com/nucypher/nucypher.git
Adapt SubscriptionManager agent to changes in contract
In particular, new "size" parameter and different Policy struct layoutpull/2860/head
parent
5482809a70
commit
2546ee6685
|
@ -956,7 +956,7 @@ class SubscriptionManagerAgent(EthereumContractAgent):
|
|||
|
||||
@contract_api(CONTRACT_CALL)
|
||||
def rate_per_second(self) -> Wei:
|
||||
result = self.contract.functions.RATE_PER_SECOND().call()
|
||||
result = self.contract.functions.feeRate().call()
|
||||
return Wei(result)
|
||||
|
||||
@contract_api(CONTRACT_CALL)
|
||||
|
@ -969,10 +969,11 @@ class SubscriptionManagerAgent(EthereumContractAgent):
|
|||
record = self.contract.functions.policies(policy_id).call()
|
||||
policy_info = self.PolicyInfo(
|
||||
sponsor=record[0],
|
||||
start_timestamp=record[1],
|
||||
end_timestamp=record[2],
|
||||
size=record[3],
|
||||
# If the policyOwner addr is null, we return the sponsor addr instead of the owner.
|
||||
owner=record[0] if record[1] == NULL_ADDRESS else record[1],
|
||||
start_timestamp=record[2],
|
||||
end_timestamp=record[3]
|
||||
owner=record[0] if record[4] == NULL_ADDRESS else record[4]
|
||||
)
|
||||
return policy_info
|
||||
|
||||
|
@ -984,6 +985,7 @@ class SubscriptionManagerAgent(EthereumContractAgent):
|
|||
def create_policy(self,
|
||||
policy_id: bytes,
|
||||
transacting_power: TransactingPower,
|
||||
size: int,
|
||||
start_timestamp: Timestamp,
|
||||
end_timestamp: Timestamp,
|
||||
value: Wei,
|
||||
|
@ -993,6 +995,7 @@ class SubscriptionManagerAgent(EthereumContractAgent):
|
|||
contract_function: ContractFunction = self.contract.functions.createPolicy(
|
||||
policy_id,
|
||||
owner_address,
|
||||
size,
|
||||
start_timestamp,
|
||||
end_timestamp
|
||||
)
|
||||
|
|
|
@ -161,6 +161,7 @@ class SubscriptionManagerPayment(ContractPayment):
|
|||
receipt = self.agent.create_policy(
|
||||
value=policy.value, # wei
|
||||
policy_id=bytes(policy.hrac), # bytes16 _policyID
|
||||
size=len(policy.kfrags), # uint16
|
||||
start_timestamp=policy.commencement, # uint16
|
||||
end_timestamp=policy.expiration, # uint16
|
||||
transacting_power=policy.publisher.transacting_power
|
||||
|
|
Loading…
Reference in New Issue