Skip to content

Commit 8b20fdf

Browse files
authored
Merge branch 'safe-global:master' into master
2 parents ab1ea78 + 0eccb7a commit 8b20fdf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1810
-445
lines changed

.github/release.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
changelog:
2+
categories:
3+
- title: 🏕 Features
4+
labels:
5+
- '*'
6+
exclude:
7+
labels:
8+
- dependencies
9+
- breaking_change
10+
- title: 🛠 Breaking Changes
11+
labels:
12+
- breaking_change
13+
- title: 👒 Dependencies
14+
labels:
15+
- dependencies

.github/workflows/codeql-analysis.yml

Lines changed: 0 additions & 71 deletions
This file was deleted.

.github/workflows/python.yml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
name: Python CI
2-
on: [push, pull_request]
2+
on:
3+
push:
4+
branches:
5+
- master
6+
- develop
7+
pull_request:
8+
release:
9+
types: [ released ]
10+
311

412
jobs:
513
linting:
@@ -14,16 +22,22 @@ jobs:
1422
uses: actions/setup-python@v4
1523
with:
1624
python-version: ${{ matrix.python-version }}
25+
cache: 'pip'
26+
cache-dependency-path: '.pre-commit-config.yaml'
27+
- uses: actions/cache@v3
28+
with:
29+
path: ~/.cache/pre-commit
30+
key: pre-commit|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
1731
- name: Install dependencies
18-
run: pip install pre-commit
32+
run: pip install -U pre-commit
1933
- name: Run pre-commit
2034
run: pre-commit run --all-files
2135

2236
test-app:
2337
runs-on: ubuntu-latest
2438
strategy:
2539
matrix:
26-
python-version: [3.7, 3.8, 3.9, "3.10"]
40+
python-version: [3.8, 3.9, "3.10"]
2741
services:
2842
postgres:
2943
image: postgres:13
@@ -53,12 +67,13 @@ jobs:
5367
env:
5468
PIP_USE_MIRRORS: true
5569
- name: Run tests and coverage
56-
run: coverage run --source=$SOURCE_FOLDER -m py.test -W ignore::DeprecationWarning -rxXs --reruns 3
70+
run: coverage run --source=$SOURCE_FOLDER -m pytest -W ignore::DeprecationWarning -rxXs --reruns 3
5771
env:
5872
SOURCE_FOLDER: gnosis
5973
DJANGO_SETTINGS_MODULE: config.settings.test
6074
ETHEREUM_MAINNET_NODE: ${{ secrets.ETHEREUM_MAINNET_NODE }}
61-
- name: Test setup.py
75+
ETHEREUM_POLYGON_NODE: ${{ secrets.ETHEREUM_POLYGON_NODE }}
76+
- name: Test packaging
6277
run: pip install -e .
6378
- name: Send results to coveralls
6479
run: coveralls --service=github
@@ -70,7 +85,7 @@ jobs:
7085
needs:
7186
- linting
7287
- test-app
73-
if: startsWith(github.ref, 'refs/tags/')
88+
if: (github.event_name == 'release' && github.event.action == 'released')
7489
steps:
7590
- uses: actions/checkout@v3
7691
- name: Set up Python

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
# See https://pre-commit.com/hooks.html for more hooks
33
repos:
44
- repo: https://github.com/PyCQA/isort
5-
rev: 5.10.1
5+
rev: 5.12.0
66
hooks:
77
- id: isort
88
- repo: https://github.com/psf/black
9-
rev: 22.6.0
9+
rev: 22.12.0
1010
hooks:
1111
- id: black
1212
- repo: https://github.com/PyCQA/flake8
13-
rev: 4.0.1
13+
rev: 6.0.0
1414
hooks:
1515
- id: flake8
1616
- repo: https://github.com/pre-commit/pre-commit-hooks
17-
rev: v4.3.0
17+
rev: v4.4.0
1818
hooks:
1919
- id: check-docstring-first
2020
- id: check-merge-conflict

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2018 Gnosis Ltd
3+
Copyright (c) 2018 Safe Ecosystem Foundation
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: '3.5'
22

33
services:
44
db:
5-
image: postgres:10-alpine
5+
image: postgres:15-alpine
66
ports:
77
- "5432:5432"
88
environment:

docs/source/gnosis.eth.eip712.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
gnosis.eth.eip712 package
2+
============================
3+
4+
Module contents
5+
---------------
6+
7+
.. automodule:: gnosis.eth.eip712
8+
:members:
9+
:undoc-members:
10+
:show-inheritance:

docs/source/quickstart.rst

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,47 @@ gnosis.eth.constants
7676
- ``SENTINEL_ADDRESS (0x000...1)``: Used for Gnosis Safe's linked lists (modules, owners...).
7777
- Maximum an minimum values for `R`, `S` and `V` in ethereum signatures.
7878

79+
gnosis.eth.eip712
80+
~~~~~~~~~~~~~~~~~~~~
81+
.. code-block:: python
82+
83+
from gnosis.eth.eip712 import eip712_encode_hash
84+
85+
types = {'EIP712Domain': [{'name': 'name', 'type': 'string'},
86+
{'name': 'version', 'type': 'string'},
87+
{'name': 'chainId', 'type': 'uint256'},
88+
{'name': 'verifyingContract', 'type': 'address'}],
89+
'Mailbox': [{'name': 'owner', 'type': 'address'},
90+
{'name': 'messages', 'type': 'Message[]'}],
91+
'Message': [{'name': 'sender', 'type': 'address'},
92+
{'name': 'subject', 'type': 'string'},
93+
{'name': 'isSpam', 'type': 'bool'},
94+
{'name': 'body', 'type': 'string'}]}
95+
96+
msgs = [{'sender': ADDRESS,
97+
'subject': 'Hello World',
98+
'body': 'The sparrow flies at midnight.',
99+
'isSpam': False},
100+
{'sender': ADDRESS,
101+
'subject': 'You may have already Won! :dumb-emoji:',
102+
'body': 'Click here for sweepstakes!',
103+
'isSpam': True}]
104+
105+
mailbox = {'owner': ADDRESS,
106+
'messages': msgs}
107+
108+
payload = {'types': types,
109+
'primaryType': 'Mailbox',
110+
'domain': {'name': 'MyDApp',
111+
'version': '3.0',
112+
'chainId': 41,
113+
'verifyingContract': ADDRESS},
114+
'message': mailbox}
115+
116+
eip712_hash = eip712_encode_hash(payload)
117+
118+
119+
79120
gnosis.eth.oracles
80121
~~~~~~~~~~~~~~~~~~
81122
Price oracles for Uniswap, UniswapV2, Kyber, SushiSwap, Aave, Balancer, Curve, Mooniswap, Yearn...

gnosis/eth/clients/blockscout_client.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@ class BlockscoutClient:
2525
EthereumNetwork.ENERGY_WEB_CHAIN: "https://explorer.energyweb.org/",
2626
EthereumNetwork.VOLTA: "https://volta-explorer.energyweb.org/",
2727
EthereumNetwork.OLYMPUS: "https://explorer.polis.tech",
28+
EthereumNetwork.BOBA_NETWORK_BOBABEAM: "https://blockexplorer.bobabeam.boba.network/",
2829
EthereumNetwork.BOBA_RINKEBY: "https://blockexplorer.rinkeby.boba.network/",
2930
EthereumNetwork.BOBA: "https://blockexplorer.boba.network/",
3031
EthereumNetwork.GATHER_DEVNET: "https://devnet-explorer.gather.network/",
3132
EthereumNetwork.GATHER_TESTNET: "https://testnet-explorer.gather.network/",
3233
EthereumNetwork.GATHER_MAINNET: "https://explorer.gather.network/",
3334
EthereumNetwork.METIS_TESTNET: "https://stardust-explorer.metis.io/",
35+
EthereumNetwork.METIS_GOERLI_TESTNET: "https://goerli.explorer.metisdevops.link/",
3436
EthereumNetwork.METIS: "https://andromeda-explorer.metis.io/",
3537
EthereumNetwork.FUSE_MAINNET: "https://explorer.fuse.io/",
3638
EthereumNetwork.VELAS_MAINNET: "https://evmexplorer.velas.com/",
@@ -48,6 +50,14 @@ class BlockscoutClient:
4850
EthereumNetwork.KARURA_NETWORK_TESTNET: "https://blockscout.karura.network/",
4951
EthereumNetwork.ACALA_NETWORK_TESTNET: "https://blockscout.mandala.acala.network/",
5052
EthereumNetwork.ASTAR: "https://blockscout.com/astar/",
53+
EthereumNetwork.EVMOS_MAINNET: "https://evm.evmos.org",
54+
EthereumNetwork.EVMOS_TESTNET: "https://evm.evmos.dev",
55+
EthereumNetwork.RABBIT: "https://rabbit.analogscan.com",
56+
EthereumNetwork.KCC_MAINNET: "https://scan.kcc.io/",
57+
EthereumNetwork.KCC_TESTNET: "https://scan-testnet.kcc.network/",
58+
EthereumNetwork.ARBITRUM: "https://explorer.arbitrum.io",
59+
EthereumNetwork.ARBITRUM_NOVA: "https://nova-explorer.arbitrum.io",
60+
EthereumNetwork.ARBITRUM_GOERLI: "https://goerli-rollup-explorer.arbitrum.io",
5161
}
5262

5363
def __init__(self, network: EthereumNetwork):

gnosis/eth/clients/etherscan_client.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,36 @@ class EtherscanClient:
3232
EthereumNetwork.MATIC: "https://polygonscan.com",
3333
EthereumNetwork.OPTIMISTIC: "https://optimistic.etherscan.io",
3434
EthereumNetwork.ARBITRUM: "https://arbiscan.io",
35+
EthereumNetwork.ARBITRUM_NOVA: "https://nova.arbiscan.io",
36+
EthereumNetwork.ARBITRUM_GOERLI: "https://goerli.arbiscan.io",
3537
EthereumNetwork.AVALANCHE: "https://snowtrace.io",
3638
EthereumNetwork.MOON_MOONBEAM: "https://moonscan.io",
3739
EthereumNetwork.MOON_MOONRIVER: "https://moonriver.moonscan.io",
3840
EthereumNetwork.MOON_MOONBASE: "https://moonbase.moonscan.io",
3941
EthereumNetwork.CRONOS_MAINNET: "https://cronoscan.com",
4042
EthereumNetwork.CRONOS_TESTNET: "https://testnet.cronoscan.com",
43+
EthereumNetwork.CELO: "https://celoscan.io",
4144
}
4245

4346
NETWORK_WITH_API_URL = {
4447
EthereumNetwork.MAINNET: "https://api.etherscan.io",
4548
EthereumNetwork.RINKEBY: "https://api-rinkeby.etherscan.io",
4649
EthereumNetwork.ROPSTEN: "https://api-ropsten.etherscan.io",
4750
EthereumNetwork.GOERLI: "https://api-goerli.etherscan.io/",
48-
EthereumNetwork.KOVAN: "https://api-kovan.etherscan.io/",
51+
EthereumNetwork.KOVAN: "https://api-kovan.etherscan.io",
4952
EthereumNetwork.BINANCE: "https://api.bscscan.com",
5053
EthereumNetwork.MATIC: "https://api.polygonscan.com",
5154
EthereumNetwork.OPTIMISTIC: "https://api-optimistic.etherscan.io",
5255
EthereumNetwork.ARBITRUM: "https://api.arbiscan.io",
56+
EthereumNetwork.ARBITRUM_NOVA: "https://api-nova.arbiscan.io",
57+
EthereumNetwork.ARBITRUM_GOERLI: "https://api-goerli.arbiscan.io",
5358
EthereumNetwork.AVALANCHE: "https://api.snowtrace.io",
5459
EthereumNetwork.MOON_MOONBEAM: "https://api-moonbeam.moonscan.io",
5560
EthereumNetwork.MOON_MOONRIVER: "https://api-moonriver.moonscan.io",
5661
EthereumNetwork.MOON_MOONBASE: "https://api-moonbase.moonscan.io",
5762
EthereumNetwork.CRONOS_MAINNET: "https://api.cronoscan.com",
5863
EthereumNetwork.CRONOS_TESTNET: "https://api-testnet.cronoscan.com",
64+
EthereumNetwork.CELO: "https://api.celoscan.io",
5965
}
6066
HTTP_HEADERS = {
6167
"User-Agent": "curl/7.77.0",

gnosis/eth/django/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,9 @@ def get_prep_value(self, value: Union[bytes, str]) -> Optional[bytes]:
236236
if value:
237237
return self._to_bytes(value)
238238

239+
def value_to_string(self, obj):
240+
return str(self.value_from_object(obj))
241+
239242
def to_python(self, value) -> Optional[str]:
240243
if value is not None:
241244
try:

gnosis/eth/django/tests/test_models.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from django.core.exceptions import ValidationError
2+
from django.core.serializers import serialize
23
from django.db import DataError, transaction
34
from django.test import TestCase
45

@@ -146,3 +147,40 @@ def test_keccak256_field(self):
146147
):
147148
with transaction.atomic():
148149
Keccak256Hash.objects.create(value=value_hex_invalid)
150+
151+
def test_serialize_keccak256_field_to_json(self):
152+
hexvalue: str = (
153+
"0xdb5b7c6d3b0cc538a5859afc4674a785d9d111c3835390295f3d3173d41ca8ea"
154+
)
155+
Keccak256Hash.objects.create(value=hexvalue)
156+
serialized = serialize("json", Keccak256Hash.objects.all())
157+
# hexvalue should be in serialized data
158+
self.assertIn(hexvalue, serialized)
159+
160+
def test_serialize_ethereum_address_field_to_json(self):
161+
address: str = "0x5aFE3855358E112B5647B952709E6165e1c1eEEe"
162+
EthereumAddress.objects.create(value=address)
163+
serialized = serialize("json", EthereumAddress.objects.all())
164+
# address should be in serialized data
165+
self.assertIn(address, serialized)
166+
167+
def test_serialize_ethereum_address_v2_field_to_json(self):
168+
address: str = "0x5aFE3855358E112B5647B952709E6165e1c1eEEe"
169+
EthereumAddressV2.objects.create(value=address)
170+
serialized = serialize("json", EthereumAddressV2.objects.all())
171+
# address should be in serialized data
172+
self.assertIn(address, serialized)
173+
174+
def test_serialize_uint256_field_to_json(self):
175+
value = 2**260
176+
Uint256.objects.create(value=value)
177+
serialized = serialize("json", Uint256.objects.all())
178+
# value should be in serialized data
179+
self.assertIn(str(value), serialized)
180+
181+
def test_serialize_sha3_hash_to_json(self):
182+
hash = Web3.keccak(text="testSerializer")
183+
Sha3Hash.objects.create(value=hash)
184+
serialized = serialize("json", Sha3Hash.objects.all())
185+
# hash should be in serialized data
186+
self.assertIn(hash.hex(), serialized)

0 commit comments

Comments
 (0)