mirror of
git://holbrook.no/eth-faucet
synced 2024-12-12 07:56:11 +01:00
Packaging, add missing period library file
This commit is contained in:
parent
68b4314ef3
commit
a5541582e1
45
python/LICENSE
Normal file
45
python/LICENSE
Normal file
@ -0,0 +1,45 @@
|
||||
Bprotocol Foundation (Bancor) LICENSE
|
||||
|
||||
1. SUBJECT TO THE PROVISIONS SET FORTH HEREIN, INCLUDING “EFFECTIVE DATE”, YOU CAN
|
||||
USE THIS CODE, FILE AND/OR SOFTWARE (“SOFTWARE”) ONLY IN CONNECTION WITH THE
|
||||
BANCOR LIQUIDITY NETWORK AND/OR THE USE OF BNT ("PERMITTED USE"). ANY OTHER USE IS
|
||||
PROHIBITED UNLESS THE USER SHALL RECEIVE AN EXPLICIT PRIOR WRITTEN APPROVAL FROM
|
||||
BPROTOCOL FOUNDATION (BANCOR) TO DO SO (PLEASE CONTACT license@bancor.network IN
|
||||
THIS REGARD), WHICH APPROVAL, IF GIVEN, MAY REQUIRE THE OBTAINMENT OF SEPARATE
|
||||
LICENSE UNDER A DIFFERENT LICENSING MODEL. USING THIS SOFTWARE NOT IN THE FRAME OF
|
||||
SUCH PERMITTED USE MAY, AMONG OTHERS, ALSO BREACH PATENT RIGHTS CONCERNING PATENTS
|
||||
WHICH ARE EMBODIED/INCORPORATED/USED IN THIS SOFTWARE.
|
||||
|
||||
2. ANY SUCH PERMITTED USE SHOULD ALSO COMPLY WITH THE TERMS BELOW.
|
||||
|
||||
3. Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
A. Redistributions of source code must retain the above copyright notice, this list
|
||||
of conditions and the following disclaimer.
|
||||
B. Redistributions in binary form must reproduce the above copyright notice, this
|
||||
list of conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
C. Neither the name of the copyright holder nor the names of its contributors may be
|
||||
used to endorse or promote products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
EFFECTIVE DATE: THIS LICENSE SHALL APPLY ONLY TO SOFTWARE (OR ANY VERSION THEREOF),
|
||||
THAT HAS BEEN PUBLISHED AFTER THE DATE AND TIME THIS LICENSE HAS BEEN FIRST PUBLISHED
|
||||
(“EFFECTIVE DATE”); Any previous versions published prior to the effective date (“Older Versions”)
|
||||
shall remain licensed under the Apache License, Version 2.0 (the "Older Versions License");
|
||||
You may obtain a copy of the Older Version License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
you may not use this file except in compliance with the Older Version License. Unless
|
||||
required by applicable law or agreed to in writing, Older Versions distributed under the
|
||||
Older Version License are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
|
||||
OF ANY KIND, either express or implied. See the Older Version License for the specific
|
||||
language governing permissions and limitations under the Older Version License.
|
1
python/MANIFEST.in
Normal file
1
python/MANIFEST.in
Normal file
@ -0,0 +1 @@
|
||||
include *requirements.txt **/data/*.json **/data/*.bin
|
1
python/eth_faucet/__init__.py
Normal file
1
python/eth_faucet/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
from .faucet import EthFaucet
|
100
python/eth_faucet/period.py
Normal file
100
python/eth_faucet/period.py
Normal file
@ -0,0 +1,100 @@
|
||||
# Author: Louis Holbrook <dev@holbrook.no> 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
# File-version: 1
|
||||
# Description: Python interface to abi and bin files for faucet contracts
|
||||
|
||||
# standard imports
|
||||
import logging
|
||||
import json
|
||||
import os
|
||||
|
||||
# external imports
|
||||
from chainlib.eth.tx import TxFactory
|
||||
from chainlib.eth.constant import ZERO_ADDRESS
|
||||
from chainlib.eth.contract import (
|
||||
abi_decode_single,
|
||||
ABIContractEncoder,
|
||||
ABIContractType,
|
||||
)
|
||||
from chainlib.eth.tx import TxFormat
|
||||
from erc20_faucet import Faucet
|
||||
from hexathon import add_0x
|
||||
|
||||
logg = logging.getLogger().getChild(__name__)
|
||||
|
||||
moddir = os.path.dirname(__file__)
|
||||
datadir = os.path.join(moddir, 'data')
|
||||
|
||||
|
||||
class PeriodSimple(Faucet):
|
||||
|
||||
__abi = None
|
||||
__bytecode = None
|
||||
__address = None
|
||||
|
||||
@staticmethod
|
||||
def abi():
|
||||
if PeriodSimple.__abi == None:
|
||||
f = open(os.path.join(datadir, 'PeriodSimple.json'), 'r')
|
||||
PeriodSimple.__abi = json.load(f)
|
||||
f.close()
|
||||
return PeriodSimple.__abi
|
||||
|
||||
|
||||
@staticmethod
|
||||
def bytecode():
|
||||
if PeriodSimple.__bytecode == None:
|
||||
f = open(os.path.join(datadir, 'PeriodSimple.bin'))
|
||||
PeriodSimple.__bytecode = f.read()
|
||||
f.close()
|
||||
return PeriodSimple.__bytecode
|
||||
|
||||
@staticmethod
|
||||
def gas(code=None):
|
||||
return 2000000
|
||||
|
||||
|
||||
# TODO: allow multiple overriders
|
||||
def constructor(self, sender_address):
|
||||
code = PeriodSimple.bytecode()
|
||||
enc = ABIContractEncoder()
|
||||
code += enc.get()
|
||||
tx = self.template(sender_address, None, use_nonce=True)
|
||||
tx = self.set_code(tx, code)
|
||||
return self.build(tx)
|
||||
|
||||
|
||||
def set_poker(self, contract_address, sender_address, poker_address, tx_format=TxFormat.JSONRPC):
|
||||
enc = ABIContractEncoder()
|
||||
enc.method('setPeriodChecker')
|
||||
enc.typ(ABIContractType.ADDRESS)
|
||||
enc.address(poker_address)
|
||||
data = enc.get()
|
||||
tx = self.template(sender_address, contract_address, use_nonce=True)
|
||||
tx = self.set_code(tx, data)
|
||||
tx = self.finalize(tx, tx_format)
|
||||
return tx
|
||||
|
||||
|
||||
def set_period(self, contract_address, sender_address, period, tx_format=TxFormat.JSONRPC):
|
||||
enc = ABIContractEncoder()
|
||||
enc.method('setPeriod')
|
||||
enc.typ(ABIContractType.UINT256)
|
||||
enc.uint256(threshold)
|
||||
data = enc.get()
|
||||
tx = self.template(sender_address, contract_address, use_nonce=True)
|
||||
tx = self.set_code(tx, data)
|
||||
tx = self.finalize(tx, tx_format)
|
||||
return tx
|
||||
|
||||
|
||||
def set_balance_threshold(self, contract_address, sender_address, threshold, tx_format=TxFormat.JSONRPC):
|
||||
enc = ABIContractEncoder()
|
||||
enc.method('setBalanceThreshold')
|
||||
enc.typ(ABIContractType.UINT256)
|
||||
enc.uint256(threshold)
|
||||
data = enc.get()
|
||||
tx = self.template(sender_address, contract_address, use_nonce=True)
|
||||
tx = self.set_code(tx, data)
|
||||
tx = self.finalize(tx, tx_format)
|
||||
return tx
|
43
python/setup.cfg
Normal file
43
python/setup.cfg
Normal file
@ -0,0 +1,43 @@
|
||||
[metadata]
|
||||
name = eth-faucet
|
||||
version = 0.1.0
|
||||
description = Gas token gifter with controls from time intervals, amounts and access.
|
||||
author = Louis Holbrook
|
||||
author_email = dev@holbrook.no
|
||||
url = https://git.grassecon.net/cicnet/eth-faucet
|
||||
keywords =
|
||||
ethereum
|
||||
classifiers =
|
||||
Programming Language :: Python :: 3
|
||||
Operating System :: OS Independent
|
||||
Development Status :: 3 - Alpha
|
||||
Environment :: No Input/Output (Daemon)
|
||||
Intended Audience :: Developers
|
||||
License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
|
||||
Topic :: Internet
|
||||
#Topic :: Blockchain :: EVM
|
||||
license = GPL3
|
||||
licence_files =
|
||||
LICENSE.txt
|
||||
|
||||
[options]
|
||||
include_package_data = True
|
||||
python_requires = >= 3.6
|
||||
packages =
|
||||
eth_accounts_index
|
||||
eth_accounts_index.runnable
|
||||
|
||||
[options.extras_require]
|
||||
testing =
|
||||
pytest==6.0.1
|
||||
eth-tester==0.5.0b2
|
||||
py-evm==0.3.0a20
|
||||
|
||||
[options.package_data]
|
||||
* =
|
||||
**/data/*.json
|
||||
**/data/*.bin
|
||||
|
||||
#[options.entry_points]
|
||||
#console_scripts =
|
||||
#eth-faucet-publish = eth_faucet.runnable.publish:main
|
32
python/setup.py
Normal file
32
python/setup.py
Normal file
@ -0,0 +1,32 @@
|
||||
from setuptools import setup
|
||||
|
||||
requirements = []
|
||||
f = open('requirements.txt', 'r')
|
||||
while True:
|
||||
l = f.readline()
|
||||
if l == '':
|
||||
break
|
||||
requirements.append(l.rstrip())
|
||||
f.close()
|
||||
|
||||
test_requirements = []
|
||||
f = open('test_requirements.txt', 'r')
|
||||
while True:
|
||||
l = f.readline()
|
||||
if l == '':
|
||||
break
|
||||
test_requirements.append(l.rstrip())
|
||||
f.close()
|
||||
|
||||
|
||||
setup(
|
||||
package_data={
|
||||
'': [
|
||||
'data/*.abi.json',
|
||||
'data/*.bin',
|
||||
],
|
||||
},
|
||||
include_package_data=True,
|
||||
install_requires=requirements,
|
||||
tests_require=test_requirements,
|
||||
)
|
Loading…
Reference in New Issue
Block a user