add --contract argument

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2020-06-17 17:21:02 +02:00
parent 58f3e524f9
commit 6e9fbf0496
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
2 changed files with 8 additions and 7 deletions

13
main.py
View File

@ -12,11 +12,6 @@ from log import setup_custom_logger
from watch import ContractWatcher
from contract import StickerPackContract
SPACK_CONTRACT = "0x0577215622f43a39F4Bc9640806DFea9b10D2A36"
#SPACK_CONTRACT = "0x8cc272396Be7583c65BEe82CD7b743c69A87287D" # Goerli
with open("./abi.json", "r") as f:
STICKER_PACK_ABI = json.load(f)
HELP_DESCRIPTION='Utility for pinning images from Status Sticker packs.'
HELP_EXAMPLE='Example: ./main.py -TODO'
@ -31,6 +26,8 @@ def parse_opts():
help='If all packs should be pinned on start.')
parser.add_option('-e', '--events', default=['ContenthashChanged', 'Register'],
help='Contract events to watch for.')
parser.add_option('-c', '--contract', default='0x0577215622f43a39F4Bc9640806DFea9b10D2A36',
help='Sticker Pack contract address.')
parser.add_option('-I', '--log-level', default='INFO',
help='Level of logging.')
@ -50,8 +47,12 @@ def main():
# for talking to IPFS cluster and pinning images
ipfs = IpfsPinner(opts.ipfs_addr)
# Read Sticker Pack contract ABI
with open("./abi.json", "r") as f:
contract_abi = json.load(f)
# Get instance of sticker pack contract
contract = StickerPackContract(SPACK_CONTRACT, STICKER_PACK_ABI, w3)
contract = StickerPackContract(opts.contract, contract_abi, w3)
if opts.pin_all:
LOG.info('Pinning all existing packs...')

View File

@ -36,7 +36,7 @@ class StickerPack:
LOG.info('Pinning: %s', self)
for chash in self.image_hashes + [self.content_hash]:
LOG.debug('Pinning hash: %s', chash)
pinned = self.ipfs.pin(chash)
pinned = ipfs.pin(chash)
if pinned:
LOG.debug('Successfully pinned: %s', chash)
else: