web3-wizzard-lib 1.12.1__py3-none-any.whl → 1.12.3__py3-none-any.whl
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.
- web3_wizzard_lib/core/modules/nft/linea_wheel.py +146 -55
- {web3_wizzard_lib-1.12.1.dist-info → web3_wizzard_lib-1.12.3.dist-info}/METADATA +1 -1
- {web3_wizzard_lib-1.12.1.dist-info → web3_wizzard_lib-1.12.3.dist-info}/RECORD +5 -5
- {web3_wizzard_lib-1.12.1.dist-info → web3_wizzard_lib-1.12.3.dist-info}/WHEEL +0 -0
- {web3_wizzard_lib-1.12.1.dist-info → web3_wizzard_lib-1.12.3.dist-info}/top_level.txt +0 -0
@@ -1,5 +1,11 @@
|
|
1
|
+
import os
|
2
|
+
import time
|
3
|
+
import uuid
|
4
|
+
|
1
5
|
import requests
|
2
6
|
from eth_account.messages import encode_defunct
|
7
|
+
from web3 import Web3
|
8
|
+
from datetime import datetime, timezone
|
3
9
|
|
4
10
|
from sybil_engine.contract.send import Send
|
5
11
|
from sybil_engine.domain.balance.balance import NativeBalance
|
@@ -7,7 +13,9 @@ from sybil_engine.utils.web3_utils import init_web3
|
|
7
13
|
|
8
14
|
from web3_wizzard_lib.core.modules.nft.nft_submodule import NftSubmodule
|
9
15
|
|
10
|
-
|
16
|
+
# 1. Connect
|
17
|
+
# 2. Verify
|
18
|
+
# 3. Spin
|
11
19
|
class LineaWheel(NftSubmodule):
|
12
20
|
abi = '[{"inputs":[{"internalType":"address","name":"_trustedForwarderAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[],"name":"AddressZero","type":"error"},{"inputs":[],"name":"ECDSAInvalidSignature","type":"error"},{"inputs":[{"internalType":"uint256","name":"length","type":"uint256"}],"name":"ECDSAInvalidSignatureLength","type":"error"},{"inputs":[{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"ECDSAInvalidSignatureS","type":"error"},{"inputs":[],"name":"ERC20PrizeWrongParam","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"InvalidLotAmount","type":"error"},{"inputs":[{"internalType":"address","name":"prizeAddress","type":"address"}],"name":"InvalidPrize","type":"error"},{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"}],"name":"InvalidRequestId","type":"error"},{"inputs":[{"internalType":"uint256","name":"totalProbabilities","type":"uint256"}],"name":"MaxProbabilityExceeded","type":"error"},{"inputs":[{"internalType":"uint256","name":"lotAmount","type":"uint256"},{"internalType":"uint256","name":"erc721PrizeAmount","type":"uint256"}],"name":"MismatchERC721PrizeAmount","type":"error"},{"inputs":[],"name":"NativeTokenTransferFailed","type":"error"},{"inputs":[{"internalType":"uint256","name":"nonce","type":"uint256"}],"name":"NonceAlreadyUsed","type":"error"},{"inputs":[{"internalType":"address","name":"caller","type":"address"}],"name":"NotAdmin","type":"error"},{"inputs":[{"internalType":"address","name":"caller","type":"address"}],"name":"NotController","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[{"internalType":"address","name":"prizeAddress","type":"address"},{"internalType":"uint256","name":"prizeAmount","type":"uint256"},{"internalType":"uint256","name":"contractBalance","type":"uint256"}],"name":"PrizeAmountExceedsBalance","type":"error"},{"inputs":[{"internalType":"uint32","name":"prizeId","type":"uint32"},{"internalType":"address","name":"user","type":"address"}],"name":"PrizeNotWonByUser","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[{"internalType":"uint256","name":"expirationTimestamp","type":"uint256"},{"internalType":"uint256","name":"currentTimestamp","type":"uint256"}],"name":"SignatureExpired","type":"error"},{"inputs":[{"internalType":"address","name":"signer","type":"address"}],"name":"SignerNotAllowed","type":"error"},{"inputs":[{"internalType":"address","name":"prizeAddress","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"TokenNotOwnedByContract","type":"error"},{"inputs":[{"internalType":"uint256","name":"expirationTimestamp","type":"uint256"}],"name":"VrfRequestHasNotExpired","type":"error"},{"anonymous":false,"inputs":[],"name":"EIP712DomainChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"NoPrizeWon","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"requestId","type":"uint256"},{"indexed":false,"internalType":"uint64","name":"nonce","type":"uint64"},{"indexed":false,"internalType":"uint256","name":"expirationTimestamp","type":"uint256"},{"indexed":false,"internalType":"uint64","name":"boost","type":"uint64"}],"name":"Participation","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"requestId","type":"uint256"}],"name":"ParticipationCancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint32","name":"prizeId","type":"uint32"}],"name":"PrizeClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint32","name":"prizeId","type":"uint32"}],"name":"PrizeWon","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32[]","name":"newPrizeIds","type":"uint32[]"},{"components":[{"internalType":"uint32","name":"lotAmount","type":"uint32"},{"internalType":"uint64","name":"probability","type":"uint64"},{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256[]","name":"availableERC721Ids","type":"uint256[]"}],"indexed":false,"internalType":"struct ISpinGame.Prize[]","name":"prizes","type":"tuple[]"}],"name":"PrizesUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"round","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"RequestedRandomness","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"signer","type":"address"}],"name":"SignerUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"vrfOperator","type":"address"}],"name":"vrfOperatorUpdated","type":"event"},{"inputs":[],"name":"BASE_POINT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"CONTROLLER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_tokenAddress","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"adminWithdrawERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_tokenAddress","type":"address"},{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"}],"name":"adminWithdrawERC721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"adminWithdrawNative","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_requestId","type":"uint256"}],"name":"cancelParticipation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_prizeId","type":"uint32"}],"name":"claimPrize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"eip712Domain","outputs":[{"internalType":"bytes1","name":"fields","type":"bytes1"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"verifyingContract","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"uint256[]","name":"extensions","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"randomness","type":"uint256"},{"internalType":"bytes","name":"dataWithRound","type":"bytes"}],"name":"fulfillRandomness","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_prizeId","type":"uint32"}],"name":"getPrize","outputs":[{"components":[{"internalType":"uint32","name":"lotAmount","type":"uint32"},{"internalType":"uint64","name":"probability","type":"uint64"},{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256[]","name":"availableERC721Ids","type":"uint256[]"}],"internalType":"struct ISpinGame.Prize","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrizesAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32[]","name":"_prizeIds","type":"uint32[]"}],"name":"getUserPrizesWon","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint32","name":"_prizeId","type":"uint32"}],"name":"hasWonPrize","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_signer","type":"address"},{"internalType":"address","name":"_admin","type":"address"},{"internalType":"address","name":"_controller","type":"address"},{"internalType":"address","name":"_vrfOperator","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"forwarder","type":"address"}],"name":"isTrustedForwarder","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nextPrizeId","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint64","name":"nonce","type":"uint64"}],"name":"nonces","outputs":[{"internalType":"bool","name":"used","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"_nonce","type":"uint64"},{"internalType":"uint256","name":"_expirationTimestamp","type":"uint256"},{"internalType":"uint64","name":"_boost","type":"uint64"},{"components":[{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"},{"internalType":"uint8","name":"v","type":"uint8"}],"internalType":"struct ISpinGame.Signature","name":"_signature","type":"tuple"}],"name":"participate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"prizeIds","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"}],"name":"requestIdTimestamp","outputs":[{"internalType":"uint256","name":"timestamp","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"}],"name":"requestIdToUser","outputs":[{"internalType":"address","name":"user","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"requestPending","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"requestedHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint32","name":"lotAmount","type":"uint32"},{"internalType":"uint64","name":"probability","type":"uint64"},{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256[]","name":"availableERC721Ids","type":"uint256[]"}],"internalType":"struct ISpinGame.Prize[]","name":"_prizes","type":"tuple[]"}],"name":"setPrizes","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_signer","type":"address"}],"name":"setSigner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_vrfOperator","type":"address"}],"name":"setVrfOperator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"signer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalProbabilities","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"trustedForwarder","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"userToBoost","outputs":[{"internalType":"uint64","name":"boost","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vrfOperator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]'
|
13
21
|
module_name = 'LINEA_WHEEL'
|
@@ -22,9 +30,12 @@ class LineaWheel(NftSubmodule):
|
|
22
30
|
},
|
23
31
|
account.proxy
|
24
32
|
)
|
33
|
+
#sign_wheel(account)
|
25
34
|
jwt_token = get_jwt_token(account, web3)
|
35
|
+
time.sleep(1)
|
36
|
+
linea_auth(jwt_token)
|
37
|
+
time.sleep(1)
|
26
38
|
data = create_data(jwt_token, web3)
|
27
|
-
|
28
39
|
print(f"DATA {data}")
|
29
40
|
|
30
41
|
Send(
|
@@ -42,100 +53,152 @@ class LineaWheel(NftSubmodule):
|
|
42
53
|
|
43
54
|
|
44
55
|
def get_jwt_token(account, web3):
|
45
|
-
from datetime import datetime, timezone
|
46
|
-
|
47
56
|
nonce = requests.get("https://app.dynamicauth.com/api/v0/sdk/ae98b9b4-daaf-4bb3-b5e0-3f07175906ed/nonce")
|
48
|
-
print(f"NONCE {nonce.text}")
|
57
|
+
# print(f"NONCE {nonce.text}")
|
49
58
|
nonce_text = nonce.json()['nonce']
|
50
59
|
|
51
60
|
# Use current timestamp instead of hardcoded one
|
52
61
|
current_time = datetime.now(timezone.utc).strftime('%Y-%m-%dT%H:%M:%S.%f')[:-3] + 'Z'
|
53
|
-
message_to_sign =
|
54
|
-
{account.address}
|
55
|
-
|
56
|
-
Welcome to Linea Hub. Signing is the only way we can truly know that you are the owner of the wallet you are connecting. Signing is a safe, gas-less transaction that does not in any way give Linea Hub permission to perform any transactions with your wallet.
|
57
|
-
|
58
|
-
URI: https://linea.build/hub/rewards
|
59
|
-
Version: 1
|
60
|
-
Chain ID: 59144
|
61
|
-
Nonce: {nonce_text}
|
62
|
-
Issued At: {current_time}
|
63
|
-
Request ID: ae98b9b4-daaf-4bb3-b5e0-3f07175906ed"""
|
64
|
-
print(f"message to sign: {message_to_sign}")
|
62
|
+
message_to_sign = form_message_to_sign(account, current_time, nonce_text)
|
65
63
|
encoded_message_to_sign = encode_defunct(text=message_to_sign)
|
66
64
|
signed_message = web3.eth.account.sign_message(encoded_message_to_sign, private_key=account.key)
|
65
|
+
# print(f"message to sign: {message_to_sign}")
|
66
|
+
# print(f"HASH {signed_message.signature.hex()}")
|
67
67
|
|
68
|
-
print(f"HASH {signed_message.signature.hex()}")
|
69
|
-
|
70
|
-
# Try without the 0x prefix for the signature
|
71
68
|
signature_hex = signed_message.signature.hex()
|
72
|
-
|
73
|
-
|
69
|
+
|
70
|
+
session_pubkey = generate_session_pubkey()
|
71
|
+
print(f"SESSION PUBKEY {session_pubkey}")
|
74
72
|
params = {
|
75
73
|
"signedMessage": f"0x{signature_hex}",
|
76
74
|
"messageToSign": message_to_sign,
|
77
|
-
"publicWalletAddress": account.address,
|
75
|
+
"publicWalletAddress": Web3.to_checksum_address(account.address),
|
78
76
|
"chain": "EVM",
|
79
77
|
"walletName": "metamask",
|
80
78
|
"walletProvider": "browserExtension",
|
81
79
|
"network": "59144",
|
82
|
-
"additionalWalletAddresses": []
|
83
|
-
|
80
|
+
"additionalWalletAddresses": [],
|
81
|
+
"sessionPublicKey": session_pubkey
|
84
82
|
}
|
85
83
|
|
86
|
-
|
87
|
-
|
84
|
+
# Generate unique request ID
|
85
|
+
request_id = str(uuid.uuid4()).replace('-', '')
|
88
86
|
|
89
|
-
|
90
|
-
|
87
|
+
headers = {
|
88
|
+
"accept": "*/*",
|
89
|
+
"accept-language": "en-GB,en-US;q=0.9,en;q=0.8,ru;q=0.7",
|
90
|
+
"content-type": "application/json",
|
91
|
+
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:141.0) Gecko/20100101 Firefox/141.0',
|
92
|
+
"origin": "https://linea.build",
|
93
|
+
"priority": "u=1, i",
|
94
|
+
"referer": "https://linea.build/",
|
95
|
+
"sec-ch-ua-mobile": "?0",
|
96
|
+
"sec-fetch-dest": "empty",
|
97
|
+
"sec-fetch-mode": "cors",
|
98
|
+
"sec-fetch-site": "cross-site",
|
99
|
+
"x-dyn-api-version": "API/0.0.681",
|
100
|
+
"x-dyn-request-id": request_id,
|
101
|
+
}
|
91
102
|
|
92
|
-
|
103
|
+
result = requests.post(
|
104
|
+
"https://app.dynamicauth.com/api/v0/sdk/ae98b9b4-daaf-4bb3-b5e0-3f07175906ed/verify",
|
105
|
+
json=params,
|
106
|
+
headers=headers
|
107
|
+
)
|
93
108
|
|
109
|
+
print(f"JWT Auth Status Code: {result.status_code}")
|
110
|
+
print(f"JWT Auth Response: {result.text}")
|
94
111
|
|
95
|
-
|
96
|
-
|
112
|
+
if result.status_code != 200:
|
113
|
+
raise Exception(f"JWT Authentication failed: {result.text}")
|
97
114
|
|
98
|
-
|
115
|
+
response_data = result.json()
|
116
|
+
if "jwt" not in response_data:
|
117
|
+
raise Exception(f"JWT token not found in response: {response_data}")
|
118
|
+
|
119
|
+
return response_data["jwt"]
|
120
|
+
|
121
|
+
|
122
|
+
def form_message_to_sign(account, current_time, nonce_text):
|
123
|
+
return f"""linea.build wants you to sign in with your Ethereum account:
|
124
|
+
{Web3.to_checksum_address(account.address)}
|
125
|
+
|
126
|
+
Welcome to Linea Hub. Signing is the only way we can truly know that you are the owner of the wallet you are connecting. Signing is a safe, gas-less transaction that does not in any way give Linea Hub permission to perform any transactions with your wallet.
|
127
|
+
|
128
|
+
URI: https://linea.build/hub/rewards
|
129
|
+
Version: 1
|
130
|
+
Chain ID: 59144
|
131
|
+
Nonce: {nonce_text}
|
132
|
+
Issued At: {current_time}
|
133
|
+
Request ID: ae98b9b4-daaf-4bb3-b5e0-3f07175906ed"""
|
99
134
|
|
135
|
+
|
136
|
+
def linea_auth(bearer_token: str):
|
137
|
+
url = "https://hub-api.linea.build/auth"
|
100
138
|
headers = {
|
139
|
+
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:141.0) Gecko/20100101 Firefox/141.0",
|
101
140
|
"Accept": "*/*",
|
102
141
|
"Accept-Language": "en-US,en;q=0.5",
|
103
142
|
"Accept-Encoding": "gzip, deflate, br, zstd",
|
104
143
|
"Referer": "https://linea.build/",
|
105
144
|
"Content-Type": "application/json",
|
106
|
-
"Authorization": f"Bearer {
|
145
|
+
"Authorization": f"Bearer {bearer_token}",
|
107
146
|
"Origin": "https://linea.build",
|
108
147
|
"Connection": "keep-alive",
|
109
148
|
"Sec-Fetch-Dest": "empty",
|
110
149
|
"Sec-Fetch-Mode": "cors",
|
111
150
|
"Sec-Fetch-Site": "same-site",
|
112
|
-
"Priority": "u=
|
113
|
-
"
|
114
|
-
|
151
|
+
"Priority": "u=4",
|
152
|
+
"TE": "trailers",
|
153
|
+
}
|
154
|
+
|
155
|
+
response = requests.post(url, headers=headers, data=b"")
|
156
|
+
response.raise_for_status() # raise error if status != 200
|
157
|
+
return response.json()
|
158
|
+
|
159
|
+
# Example usage:
|
160
|
+
# token = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIs..."
|
161
|
+
# print(linea_auth(token))
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
def create_data(jwt_token, web3):
|
166
|
+
url = "https://hub-api.linea.build/spins"
|
167
|
+
|
168
|
+
headers = {
|
169
|
+
"Accept": "*/*",
|
170
|
+
"Accept-Language": "en-US,en;q=0.5",
|
171
|
+
"Accept-Encoding": "gzip, deflate, br, zstd",
|
172
|
+
"Referer": "https://linea.build/",
|
173
|
+
"Content-Type": "application/json",
|
174
|
+
"Authorization": f"Bearer {jwt_token}",
|
115
175
|
}
|
116
176
|
|
117
177
|
response = requests.post(url, headers=headers)
|
118
178
|
|
119
|
-
print("Status
|
120
|
-
print("Response
|
179
|
+
print(f"Spins API Status Code: {response.status_code}")
|
180
|
+
print(f"Spins API Response: {response.content}")
|
181
|
+
|
182
|
+
if response.status_code == 404:
|
183
|
+
print(f"User not found in Linea Hub system. Address may need to be registered first.")
|
184
|
+
raise Exception(f"User not found: {response.text}")
|
185
|
+
elif response.status_code != 200:
|
186
|
+
try:
|
187
|
+
error_msg = response.json().get('message', 'Unknown error')
|
188
|
+
except:
|
189
|
+
error_msg = response.text
|
190
|
+
raise Exception(f"Spins API failed with status {response.status_code}: {error_msg}")
|
121
191
|
|
122
|
-
if response.status_code != 200:
|
123
|
-
raise Exception(response.json()['message'])
|
124
|
-
|
125
192
|
# Get the JSON response data
|
126
193
|
response_data = response.json()
|
127
194
|
print(f"Response JSON: {response_data}")
|
128
|
-
|
129
|
-
|
130
|
-
abi = LineaWheel.abi
|
131
|
-
contract_address = '0xDb3a3929269281F157A58D91289185F21E30A1e0' # LineaWheel contract address
|
132
|
-
contract = web3.eth.contract(address=contract_address, abi=abi)
|
133
|
-
|
195
|
+
|
196
|
+
contract = web3.eth.contract(address=LineaWheel.nft_address, abi=LineaWheel.abi)
|
134
197
|
# Convert response data to contract function parameters
|
135
198
|
nonce = int(response_data['nonce'])
|
136
199
|
expiration_timestamp = int(response_data['expirationTimestamp'])
|
137
200
|
boost = int(response_data['boost'])
|
138
|
-
|
201
|
+
|
139
202
|
# Convert signature array to struct format
|
140
203
|
signature_array = response_data['signature']
|
141
204
|
signature_struct = {
|
@@ -143,13 +206,41 @@ def create_data(jwt_token, web3):
|
|
143
206
|
's': signature_array[1], # bytes32
|
144
207
|
'v': int(signature_array[2]) # uint8
|
145
208
|
}
|
146
|
-
|
147
|
-
|
148
|
-
encoded_data = contract.encode_abi("participate", args=(
|
209
|
+
|
210
|
+
return contract.encode_abi("participate", args=(
|
149
211
|
nonce,
|
150
|
-
expiration_timestamp,
|
212
|
+
expiration_timestamp,
|
151
213
|
boost,
|
152
214
|
signature_struct
|
153
215
|
))
|
154
|
-
|
155
|
-
|
216
|
+
|
217
|
+
|
218
|
+
def sign_wheel(account):
|
219
|
+
url = "https://app.dynamicauth.com/api/v0/sdk/ae98b9b4-daaf-4bb3-b5e0-3f07175906ed/connect"
|
220
|
+
|
221
|
+
payload = {
|
222
|
+
"address": Web3.to_checksum_address(account.address),
|
223
|
+
"chain": "EVM",
|
224
|
+
"provider": "browserExtension",
|
225
|
+
"walletName": "metamask",
|
226
|
+
"authMode": "connect-and-sign"
|
227
|
+
}
|
228
|
+
|
229
|
+
response = requests.post(url, json=payload)
|
230
|
+
print(f"REGISTER: {response.status_code} {response.content}")
|
231
|
+
|
232
|
+
|
233
|
+
def generate_session_pubkey() -> str:
|
234
|
+
# Generate a 32-byte private key
|
235
|
+
private_key_bytes = os.urandom(32)
|
236
|
+
|
237
|
+
# Create a private key object
|
238
|
+
from eth_keys import keys
|
239
|
+
|
240
|
+
private_key = keys.PrivateKey(private_key_bytes)
|
241
|
+
|
242
|
+
# Get the compressed public key (33 bytes, starts with 02 or 03)
|
243
|
+
compressed_pubkey = private_key.public_key.to_compressed_bytes()
|
244
|
+
|
245
|
+
# Return hex string
|
246
|
+
return compressed_pubkey.hex()
|
@@ -196,7 +196,7 @@ web3_wizzard_lib/core/modules/nft/linea_culture_4_6_laurent.py,sha256=aYSmG39cwh
|
|
196
196
|
web3_wizzard_lib/core/modules/nft/linea_culture_day2.py,sha256=Vb3l7kLWfHA5iqojeoGBbdfw8VnfN8NvkICkYqdQ4rU,709
|
197
197
|
web3_wizzard_lib/core/modules/nft/linea_culture_day3.py,sha256=Nlqey71z2XZoKWJfpX5lf2aIzvhq5Oa-MqzuzT0dvm0,707
|
198
198
|
web3_wizzard_lib/core/modules/nft/linea_ens_names.py,sha256=-p4uMAd2ZChqQGDWV6HwdA-wSEOoPkAyuFoVgHmipTE,3978
|
199
|
-
web3_wizzard_lib/core/modules/nft/linea_wheel.py,sha256
|
199
|
+
web3_wizzard_lib/core/modules/nft/linea_wheel.py,sha256=-cQ84tErf6gLfhEMl0aRFDW5ZH1eyhU_wWJkmc24DpQ,23619
|
200
200
|
web3_wizzard_lib/core/modules/nft/lucky_cat.py,sha256=E2NDk0ptNRUeue1ZTdlHKTEcm9BSCQ_3mfamRmrJvW4,828
|
201
201
|
web3_wizzard_lib/core/modules/nft/merkly_minter_module.py,sha256=g41FIisQX6UJ94Egb95jGA5Mil2lA7sAm4fGgiSOQ-I,753
|
202
202
|
web3_wizzard_lib/core/modules/nft/micro3.py,sha256=m6yqqIDz6wGe8W9_I7HOcfsgPVBrkQXsZ83B__8aWw8,748
|
@@ -372,7 +372,7 @@ web3_wizzard_lib/resources/main/pairs.json,sha256=uvIFvY46Ctiw8hjGd9e-1WE0qLf_du
|
|
372
372
|
web3_wizzard_lib/resources/main/tokens.json,sha256=AoZz_I6AVoZuecNdyX5L-SnGm6TREuPrsYd2i9PJr7U,5707
|
373
373
|
web3_wizzard_lib/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
374
374
|
web3_wizzard_lib/utils/debank_utils.py,sha256=CE2SUN9RpFK_j9KjJgxf7a__VRJ75tLIw9tLrVNrn3c,484
|
375
|
-
web3_wizzard_lib-1.12.
|
376
|
-
web3_wizzard_lib-1.12.
|
377
|
-
web3_wizzard_lib-1.12.
|
378
|
-
web3_wizzard_lib-1.12.
|
375
|
+
web3_wizzard_lib-1.12.3.dist-info/METADATA,sha256=oLYyzdI1AMznYdoH0eaymmzNM3fuTwzUmqDpuMupJZA,370
|
376
|
+
web3_wizzard_lib-1.12.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
377
|
+
web3_wizzard_lib-1.12.3.dist-info/top_level.txt,sha256=31sEPHxuJ1p5fpc75vHQJ8eJdSs80aCZeeT3L8YAHNg,17
|
378
|
+
web3_wizzard_lib-1.12.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|