py-near 1.1.51__tar.gz → 1.1.52__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {py_near-1.1.51 → py_near-1.1.52}/PKG-INFO +1 -1
- {py_near-1.1.51 → py_near-1.1.52}/pyproject.toml +1 -1
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/mpc/wallet.py +48 -24
- {py_near-1.1.51 → py_near-1.1.52}/LICENSE +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/README.md +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/__init__.py +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/account.py +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/constants.py +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/dapps/__init__.py +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/dapps/__pycache__/__init__.cpython-311.pyc +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/dapps/__pycache__/core.cpython-311.pyc +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/dapps/__pycache__/fts.cpython-311.pyc +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/dapps/core.py +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/dapps/ft/__init__.py +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/dapps/ft/__pycache__/__init__.cpython-311.pyc +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/dapps/ft/__pycache__/async_client.cpython-311.pyc +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/dapps/ft/__pycache__/exceptions.cpython-311.pyc +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/dapps/ft/__pycache__/models.cpython-311.pyc +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/dapps/ft/async_client.py +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/dapps/ft/exceptions.py +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/dapps/ft/models.py +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/dapps/fts.py +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/dapps/keypom/__init__.py +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/dapps/keypom/async_client.py +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/dapps/keypom/exceptions.py +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/dapps/keypom/models.py +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/dapps/staking/__init__.py +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/dapps/staking/__pycache__/__init__.cpython-311.pyc +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/dapps/staking/__pycache__/async_client.cpython-311.pyc +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/dapps/staking/__pycache__/exceptions.cpython-311.pyc +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/dapps/staking/__pycache__/models.cpython-311.pyc +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/dapps/staking/async_client.py +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/dapps/staking/exceptions.py +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/dapps/staking/models.py +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/exceptions/__init__.py +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/exceptions/__pycache__/__init__.cpython-311.pyc +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/exceptions/__pycache__/exceptions.cpython-311.pyc +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/exceptions/__pycache__/provider.cpython-311.pyc +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/exceptions/exceptions.py +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/exceptions/provider.py +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/models.py +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/mpc/__init__.py +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/mpc/__pycache__/__init__.cpython-311.pyc +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/mpc/__pycache__/models.cpython-311.pyc +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/mpc/__pycache__/wallet.cpython-311.pyc +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/mpc/auth/__init__.py +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/mpc/auth/__pycache__/__init__.cpython-311.pyc +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/mpc/auth/__pycache__/auth_2fa.cpython-311.pyc +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/mpc/auth/__pycache__/base.cpython-311.pyc +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/mpc/auth/__pycache__/default_auth.cpython-311.pyc +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/mpc/auth/__pycache__/keys_auth.cpython-311.pyc +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/mpc/auth/auth_2fa.py +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/mpc/auth/base.py +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/mpc/auth/core.py +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/mpc/auth/default_auth.py +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/mpc/auth/keys_auth.py +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/mpc/models.py +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/providers.py +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/transactions.py +0 -0
- {py_near-1.1.51 → py_near-1.1.52}/src/py_near/utils.py +0 -0
@@ -1,3 +1,4 @@
|
|
1
|
+
import json
|
1
2
|
from hashlib import sha256
|
2
3
|
from typing import List, Optional
|
3
4
|
|
@@ -80,6 +81,25 @@ class MPCWallet:
|
|
80
81
|
return WalletModel.build(wallet.result)
|
81
82
|
|
82
83
|
async def create_wallet_with_keys_auth(self, public_key: bytes, key_gen=1):
|
84
|
+
"""
|
85
|
+
Create wallet with keys.auth.hot.tg auth method.
|
86
|
+
:param public_key: Public key for auth future signs on keys.auth.hot.tg
|
87
|
+
"""
|
88
|
+
wallet = await self.get_wallet()
|
89
|
+
if wallet and wallet.access_list[0].account_id != "default.auth.hot.tg":
|
90
|
+
raise ValueError(
|
91
|
+
"MPCWallet already exists with different auth method, please use another wallet_id"
|
92
|
+
)
|
93
|
+
auth_to_add_msg = json.dumps(
|
94
|
+
dict(public_keys=[base58.b58encode(public_key).decode()], rules=[])
|
95
|
+
).replace(" ", "")
|
96
|
+
return await self.create_wallet(
|
97
|
+
"keys.auth.hot.tg", None, auth_to_add_msg, key_gen
|
98
|
+
)
|
99
|
+
|
100
|
+
async def create_wallet(
|
101
|
+
self, auth_account_id: str, metadata: str = "", auth_to_add_msg="", key_gen=1
|
102
|
+
):
|
83
103
|
"""
|
84
104
|
Create wallet with keys.auth.hot.tg auth method.
|
85
105
|
:param public_key: Public key for auth future signs on keys.auth.hot.tg
|
@@ -90,19 +110,27 @@ class MPCWallet:
|
|
90
110
|
"MPCWallet already exists with different auth method, please use another wallet_id"
|
91
111
|
)
|
92
112
|
root_pk = self.derive_private_key(0)
|
93
|
-
proof_hash = sha256(
|
113
|
+
proof_hash = sha256(
|
114
|
+
f"CREATE_WALLET:{self.wallet_id}:{auth_account_id}:{metadata}:{auth_to_add_msg}".encode(
|
115
|
+
"utf-8"
|
116
|
+
)
|
117
|
+
).digest()
|
94
118
|
signature = base58.b58encode(root_pk.sign(proof_hash).signature).decode("utf-8")
|
95
119
|
|
96
120
|
s = await self._client.post(
|
97
121
|
f"{self.hot_rpc}/create_wallet",
|
98
122
|
json=dict(
|
99
|
-
public_key=base58.b58encode(public_key).decode(),
|
100
123
|
wallet_id=self.wallet_id,
|
101
124
|
key_gen=key_gen,
|
102
125
|
signature=signature,
|
103
126
|
wallet_derive_public_key=base58.b58encode(
|
104
127
|
root_pk.verify_key.encode()
|
105
128
|
).decode(),
|
129
|
+
auth={
|
130
|
+
"auth_account_id": auth_account_id,
|
131
|
+
"msg": auth_to_add_msg,
|
132
|
+
"metadata": metadata or None,
|
133
|
+
},
|
106
134
|
),
|
107
135
|
timeout=30,
|
108
136
|
)
|
@@ -126,7 +154,8 @@ class MPCWallet:
|
|
126
154
|
|
127
155
|
async def sign_message(
|
128
156
|
self,
|
129
|
-
|
157
|
+
msg_hash: bytes,
|
158
|
+
message_body: Optional[bytes] = None,
|
130
159
|
curve_type: CurveType = CurveType.SECP256K1,
|
131
160
|
auth_methods: List[AuthContract] = None,
|
132
161
|
):
|
@@ -134,38 +163,33 @@ class MPCWallet:
|
|
134
163
|
raise ValueError("Default auth key is required")
|
135
164
|
wallet = await self.get_wallet()
|
136
165
|
user_payloads = []
|
137
|
-
msg_hash = keccak(message_body)
|
138
166
|
if len(auth_methods) != len(wallet.access_list):
|
139
167
|
raise ValueError("Auth methods count should be equal to wallet access list")
|
140
168
|
|
141
169
|
for auth_contract, auth_method in zip(auth_methods, wallet.access_list):
|
142
|
-
auth_class = AUTH_CLASS[auth_method.account_id]
|
143
|
-
if not isinstance(auth_contract, auth_class):
|
144
|
-
raise ValueError(
|
145
|
-
f"Auth method {auth_method.account_id} is not supported for this auth class"
|
146
|
-
)
|
147
170
|
user_payloads.append(auth_contract.generate_user_payload(msg_hash))
|
148
171
|
|
149
172
|
proof = {
|
150
173
|
"auth_id": 0,
|
151
174
|
"curve_type": curve_type,
|
152
175
|
"user_payloads": user_payloads,
|
153
|
-
"message_body": message_body.hex(),
|
176
|
+
"message_body": message_body.hex() if message_body else "",
|
154
177
|
}
|
155
178
|
|
156
|
-
resp = (
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
179
|
+
resp = await self._client.post(
|
180
|
+
f"{self.hot_rpc}/sign_raw",
|
181
|
+
json=dict(
|
182
|
+
uid=self.derive.hex(),
|
183
|
+
message=msg_hash.hex(),
|
184
|
+
proof=proof,
|
185
|
+
key_type=curve_type,
|
186
|
+
),
|
187
|
+
timeout=10,
|
188
|
+
follow_redirects=True,
|
189
|
+
)
|
190
|
+
resp = resp.json()
|
191
|
+
if "Ecdsa" not in resp:
|
192
|
+
raise ValueError(f"Invalid response from server: {resp}")
|
169
193
|
resp = resp["Ecdsa"]
|
170
194
|
r = int(resp["big_r"][2:], 16)
|
171
195
|
s = int(resp["signature"], 16)
|
@@ -234,4 +258,4 @@ class MPCWallet:
|
|
234
258
|
"user_payloads": user_payloads,
|
235
259
|
},
|
236
260
|
included=True,
|
237
|
-
)
|
261
|
+
)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{py_near-1.1.51 → py_near-1.1.52}/src/py_near/dapps/ft/__pycache__/async_client.cpython-311.pyc
RENAMED
File without changes
|
{py_near-1.1.51 → py_near-1.1.52}/src/py_near/dapps/ft/__pycache__/exceptions.cpython-311.pyc
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{py_near-1.1.51 → py_near-1.1.52}/src/py_near/dapps/staking/__pycache__/__init__.cpython-311.pyc
RENAMED
File without changes
|
{py_near-1.1.51 → py_near-1.1.52}/src/py_near/dapps/staking/__pycache__/async_client.cpython-311.pyc
RENAMED
File without changes
|
{py_near-1.1.51 → py_near-1.1.52}/src/py_near/dapps/staking/__pycache__/exceptions.cpython-311.pyc
RENAMED
File without changes
|
{py_near-1.1.51 → py_near-1.1.52}/src/py_near/dapps/staking/__pycache__/models.cpython-311.pyc
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{py_near-1.1.51 → py_near-1.1.52}/src/py_near/exceptions/__pycache__/__init__.cpython-311.pyc
RENAMED
File without changes
|
{py_near-1.1.51 → py_near-1.1.52}/src/py_near/exceptions/__pycache__/exceptions.cpython-311.pyc
RENAMED
File without changes
|
{py_near-1.1.51 → py_near-1.1.52}/src/py_near/exceptions/__pycache__/provider.cpython-311.pyc
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{py_near-1.1.51 → py_near-1.1.52}/src/py_near/mpc/auth/__pycache__/default_auth.cpython-311.pyc
RENAMED
File without changes
|
{py_near-1.1.51 → py_near-1.1.52}/src/py_near/mpc/auth/__pycache__/keys_auth.cpython-311.pyc
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|