Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/story_protocol_python_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
MAX_ROYALTY_TOKEN,
ROYALTY_POLICY_LAP_ADDRESS,
ROYALTY_POLICY_LRP_ADDRESS,
WIP_TOKEN_ADDRESS,
ZERO_ADDRESS,
ZERO_FUNC,
ZERO_HASH,
Expand Down Expand Up @@ -76,4 +77,5 @@
"ZERO_FUNC",
"DEFAULT_FUNCTION_SELECTOR",
"MAX_ROYALTY_TOKEN",
"WIP_TOKEN_ADDRESS",
]
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,3 @@ def mintFee(self):

def mintFeeToken(self):
return self.contract.functions.mintFeeToken().call()

def publicMinting(self):
return self.contract.functions.publicMinting().call()
39 changes: 39 additions & 0 deletions src/story_protocol_python_sdk/abi/WrappedIP/WrappedIP_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import json
import os

from web3 import Web3


class WrappedIPClient:
def __init__(self, web3: Web3):
self.web3 = web3
# Assuming config.json is located at the root of the project
config_path = os.path.abspath(
os.path.join(
os.path.dirname(__file__), "..", "..", "scripts", "config.json"
)
)
with open(config_path, "r") as config_file:
config = json.load(config_file)
contract_address = None
for contract in config["contracts"]:
if contract["contract_name"] == "WrappedIP":
contract_address = contract["contract_address"]
break
if not contract_address:
raise ValueError("Contract address for WrappedIP not found in config.json")
abi_path = os.path.join(
os.path.dirname(__file__), "..", "..", "abi", "jsons", "WrappedIP.json"
)
with open(abi_path, "r") as abi_file:
abi = json.load(abi_file)
self.contract = self.web3.eth.contract(address=contract_address, abi=abi)

def withdraw(self, value):
return self.contract.functions.withdraw(value).transact()

def build_withdraw_transaction(self, value, tx_params):
return self.contract.functions.withdraw(value).build_transaction(tx_params)

def balanceOf(self, owner):
return self.contract.functions.balanceOf(owner).call()
253 changes: 253 additions & 0 deletions src/story_protocol_python_sdk/abi/jsons/WrappedIP.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,253 @@
[
{ "type": "error", "inputs": [], "name": "AllowanceOverflow" },
{ "type": "error", "inputs": [], "name": "AllowanceUnderflow" },
{
"type": "error",
"inputs": [
{ "name": "receiver", "internalType": "address", "type": "address" }
],
"name": "ERC20InvalidReceiver"
},
{
"type": "error",
"inputs": [
{ "name": "spender", "internalType": "address", "type": "address" }
],
"name": "ERC20InvalidSpender"
},
{ "type": "error", "inputs": [], "name": "IPTransferFailed" },
{ "type": "error", "inputs": [], "name": "InsufficientAllowance" },
{ "type": "error", "inputs": [], "name": "InsufficientBalance" },
{ "type": "error", "inputs": [], "name": "InvalidPermit" },
{
"type": "error",
"inputs": [],
"name": "Permit2AllowanceIsFixedAtInfinity"
},
{ "type": "error", "inputs": [], "name": "PermitExpired" },
{ "type": "error", "inputs": [], "name": "TotalSupplyOverflow" },
{
"type": "event",
"anonymous": false,
"inputs": [
{
"name": "owner",
"internalType": "address",
"type": "address",
"indexed": true
},
{
"name": "spender",
"internalType": "address",
"type": "address",
"indexed": true
},
{
"name": "amount",
"internalType": "uint256",
"type": "uint256",
"indexed": false
}
],
"name": "Approval"
},
{
"type": "event",
"anonymous": false,
"inputs": [
{
"name": "from",
"internalType": "address",
"type": "address",
"indexed": true
},
{
"name": "amount",
"internalType": "uint256",
"type": "uint256",
"indexed": false
}
],
"name": "Deposit"
},
{
"type": "event",
"anonymous": false,
"inputs": [
{
"name": "from",
"internalType": "address",
"type": "address",
"indexed": true
},
{
"name": "to",
"internalType": "address",
"type": "address",
"indexed": true
},
{
"name": "amount",
"internalType": "uint256",
"type": "uint256",
"indexed": false
}
],
"name": "Transfer"
},
{
"type": "event",
"anonymous": false,
"inputs": [
{
"name": "to",
"internalType": "address",
"type": "address",
"indexed": true
},
{
"name": "amount",
"internalType": "uint256",
"type": "uint256",
"indexed": false
}
],
"name": "Withdrawal"
},
{
"type": "function",
"inputs": [],
"name": "DOMAIN_SEPARATOR",
"outputs": [
{ "name": "result", "internalType": "bytes32", "type": "bytes32" }
],
"stateMutability": "view"
},
{
"type": "function",
"inputs": [
{ "name": "owner", "internalType": "address", "type": "address" },
{ "name": "spender", "internalType": "address", "type": "address" }
],
"name": "allowance",
"outputs": [
{ "name": "result", "internalType": "uint256", "type": "uint256" }
],
"stateMutability": "view"
},
{
"type": "function",
"inputs": [
{ "name": "spender", "internalType": "address", "type": "address" },
{ "name": "amount", "internalType": "uint256", "type": "uint256" }
],
"name": "approve",
"outputs": [{ "name": "", "internalType": "bool", "type": "bool" }],
"stateMutability": "nonpayable"
},
{
"type": "function",
"inputs": [
{ "name": "owner", "internalType": "address", "type": "address" }
],
"name": "balanceOf",
"outputs": [
{ "name": "result", "internalType": "uint256", "type": "uint256" }
],
"stateMutability": "view"
},
{
"type": "function",
"inputs": [],
"name": "decimals",
"outputs": [{ "name": "", "internalType": "uint8", "type": "uint8" }],
"stateMutability": "view"
},
{
"type": "function",
"inputs": [],
"name": "deposit",
"outputs": [],
"stateMutability": "payable"
},
{
"type": "function",
"inputs": [],
"name": "name",
"outputs": [{ "name": "", "internalType": "string", "type": "string" }],
"stateMutability": "pure"
},
{
"type": "function",
"inputs": [
{ "name": "owner", "internalType": "address", "type": "address" }
],
"name": "nonces",
"outputs": [
{ "name": "result", "internalType": "uint256", "type": "uint256" }
],
"stateMutability": "view"
},
{
"type": "function",
"inputs": [
{ "name": "owner", "internalType": "address", "type": "address" },
{ "name": "spender", "internalType": "address", "type": "address" },
{ "name": "value", "internalType": "uint256", "type": "uint256" },
{ "name": "deadline", "internalType": "uint256", "type": "uint256" },
{ "name": "v", "internalType": "uint8", "type": "uint8" },
{ "name": "r", "internalType": "bytes32", "type": "bytes32" },
{ "name": "s", "internalType": "bytes32", "type": "bytes32" }
],
"name": "permit",
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "function",
"inputs": [],
"name": "symbol",
"outputs": [{ "name": "", "internalType": "string", "type": "string" }],
"stateMutability": "pure"
},
{
"type": "function",
"inputs": [],
"name": "totalSupply",
"outputs": [
{ "name": "result", "internalType": "uint256", "type": "uint256" }
],
"stateMutability": "view"
},
{
"type": "function",
"inputs": [
{ "name": "to", "internalType": "address", "type": "address" },
{ "name": "amount", "internalType": "uint256", "type": "uint256" }
],
"name": "transfer",
"outputs": [{ "name": "", "internalType": "bool", "type": "bool" }],
"stateMutability": "nonpayable"
},
{
"type": "function",
"inputs": [
{ "name": "from", "internalType": "address", "type": "address" },
{ "name": "to", "internalType": "address", "type": "address" },
{ "name": "amount", "internalType": "uint256", "type": "uint256" }
],
"name": "transferFrom",
"outputs": [{ "name": "", "internalType": "bool", "type": "bool" }],
"stateMutability": "nonpayable"
},
{
"type": "function",
"inputs": [
{ "name": "value", "internalType": "uint256", "type": "uint256" }
],
"name": "withdraw",
"outputs": [],
"stateMutability": "nonpayable"
},
{ "type": "receive", "stateMutability": "payable" }
]
4 changes: 1 addition & 3 deletions src/story_protocol_python_sdk/resources/IPAsset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1703,7 +1703,7 @@ def get_royalty_vault_address_by_ip_id(
:param ipId Address: The IP ID.
:return Address: The royalty vault address.
"""
event_signature = self.web3.keccak(
event_signature = Web3.keccak(
text="IpRoyaltyVaultDeployed(address,address)"
).hex()
for log in tx_receipt["logs"]:
Expand All @@ -1714,8 +1714,6 @@ def get_royalty_vault_address_by_ip_id(
if event_result["args"]["ipId"] == ipId:
return event_result["args"]["ipRoyaltyVault"]

raise ValueError("RoyaltyVaultDeployed event not found in transaction receipt.")

def _validate_recipient(self, recipient: Address | None) -> Address:
"""
Validate the recipient address.
Expand Down
Loading
Loading