mirror of
git://holbrook.no/eth-accounts-index
synced 2026-05-16 18:35:20 +02:00
Add dockerfile
This commit is contained in:
4
python/CHANGELOG
Normal file
4
python/CHANGELOG
Normal file
@@ -0,0 +1,4 @@
|
||||
- 0.0.2
|
||||
* Move deploy script to within setup
|
||||
- 0.0.1
|
||||
* Simple solidity method wrapper
|
||||
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 **/*.abi.json
|
||||
100
python/eth_accounts_index/runnable/deploy.py
Normal file
100
python/eth_accounts_index/runnable/deploy.py
Normal file
@@ -0,0 +1,100 @@
|
||||
"""Deploys accounts index, registering arbitrary number of writers
|
||||
|
||||
.. moduleauthor:: Louis Holbrook <dev@holbrook.no>
|
||||
.. pgp:: 0826EDA1702D1E87C6E2875121D2E7BB88C2A746
|
||||
|
||||
"""
|
||||
|
||||
# standard imports
|
||||
import os
|
||||
import json
|
||||
import argparse
|
||||
import logging
|
||||
|
||||
# third-party imports
|
||||
import web3
|
||||
|
||||
|
||||
logging.basicConfig(level=logging.WARNING)
|
||||
logg = logging.getLogger()
|
||||
|
||||
logging.getLogger('web3').setLevel(logging.WARNING)
|
||||
logging.getLogger('urllib3').setLevel(logging.WARNING)
|
||||
|
||||
argparser = argparse.ArgumentParser()
|
||||
argparser.add_argument('-p', '--provider', dest='p', default='http://localhost:8545', type=str, help='Web3 provider url (http only)')
|
||||
argparser.add_argument('-w', '--writer', dest='w', action='append', type=str, help='Writer to add')
|
||||
argparser.add_argument('-a', '--account', dest='a', action='append', type=str, help='Account to add')
|
||||
argparser.add_argument('-k', '--keep-sender', dest='k', action='store_true', help='If set, sender will be kept as writer')
|
||||
argparser.add_argument('--contracts-dir', dest='contracts_dir', default='.', help='Directory containing bytecode and abi')
|
||||
argparser.add_argument('-v', action='store_true', help='Be verbose')
|
||||
args = argparser.parse_args()
|
||||
|
||||
if args.v:
|
||||
logg.setLevel(logging.DEBUG)
|
||||
|
||||
def main():
|
||||
w3 = web3.Web3(web3.Web3.HTTPProvider(args.p))
|
||||
|
||||
f = open(os.path.join(args.contracts_dir, 'AccountsIndex.abi.json'), 'r')
|
||||
abi = json.load(f)
|
||||
f.close()
|
||||
|
||||
f = open(os.path.join(args.contracts_dir, 'AccountsIndex.bin'), 'r')
|
||||
bytecode = f.read()
|
||||
f.close()
|
||||
|
||||
w3.eth.defaultAccount = w3.eth.accounts[0]
|
||||
|
||||
c = w3.eth.contract(abi=abi, bytecode=bytecode)
|
||||
tx_hash = c.constructor().transact({'from': w3.eth.accounts[0]})
|
||||
|
||||
rcpt = w3.eth.getTransactionReceipt(tx_hash)
|
||||
|
||||
address = rcpt.contractAddress
|
||||
c = w3.eth.contract(abi=abi, address=address)
|
||||
|
||||
logg.debug('adding sender to write list')
|
||||
c.functions.addWriter(w3.eth.accounts[0]).transact()
|
||||
|
||||
if args.w != None:
|
||||
for w in args.w:
|
||||
logg.info('adding {} to write list'.format(w))
|
||||
c.functions.addWriter(w).transact()
|
||||
|
||||
if args.a != None:
|
||||
for a in args.a:
|
||||
logg.info('adding {} to accounts index'.format(a))
|
||||
c.functions.add(a).transact()
|
||||
|
||||
if not args.k:
|
||||
logg.debug('deleting sender for write list')
|
||||
c.functions.deleteWriter(w3.eth.accounts[0]).transact()
|
||||
|
||||
print(address)
|
||||
|
||||
# fail = False
|
||||
# try:
|
||||
# c.functions.add(w3.eth.accounts[2]).transact({'from': w3.eth.accounts[1]})
|
||||
# except:
|
||||
# fail = True
|
||||
# assert fail
|
||||
#
|
||||
# c.functions.addWriter(w3.eth.accounts[1]).transact({'from': w3.eth.accounts[0]})
|
||||
# c.functions.add(w3.eth.accounts[2]).transact({'from': w3.eth.accounts[1]})
|
||||
# c.functions.add(w3.eth.accounts[3]).transact({'from': w3.eth.accounts[1]})
|
||||
#
|
||||
# assert c.functions.count().call() == 3
|
||||
# assert c.functions.accountsIndex(w3.eth.accounts[3]).call() == 2
|
||||
# assert c.functions.accounts(2).call() == w3.eth.accounts[3]
|
||||
#
|
||||
# fail = False
|
||||
# try:
|
||||
# c.functions.add(w3.eth.accounts[3]).transact({'from': w3.eth.accounts[1]})
|
||||
# except:
|
||||
# fail = True
|
||||
# assert fail
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -1,6 +1,6 @@
|
||||
[metadata]
|
||||
name = eth-accounts-index
|
||||
version = 0.0.2
|
||||
version = 0.0.3
|
||||
description = Accounts index evm contract tooling with permissioned writes
|
||||
author = Louis Holbrook
|
||||
author_email = dev@holbrook.no
|
||||
@@ -25,9 +25,14 @@ include_package_data = True
|
||||
python_requires = >= 3.6
|
||||
packages =
|
||||
eth_accounts_index
|
||||
eth_accounts_index.runnable
|
||||
install_requires =
|
||||
confini==0.3.1
|
||||
web3==5.12.2
|
||||
|
||||
[options.package_data]
|
||||
* = **/*.abi.json
|
||||
|
||||
[options.entry_points]
|
||||
console_scripts =
|
||||
accounts-index-deploy = eth_accounts_index.runnable.deploy:main
|
||||
|
||||
Reference in New Issue
Block a user