web3-wizzard-lib 1.12.1__py3-none-any.whl → 1.12.2__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 +143 -55
- {web3_wizzard_lib-1.12.1.dist-info → web3_wizzard_lib-1.12.2.dist-info}/METADATA +1 -1
- {web3_wizzard_lib-1.12.1.dist-info → web3_wizzard_lib-1.12.2.dist-info}/RECORD +5 -5
- {web3_wizzard_lib-1.12.1.dist-info → web3_wizzard_lib-1.12.2.dist-info}/WHEEL +0 -0
- {web3_wizzard_lib-1.12.1.dist-info → web3_wizzard_lib-1.12.2.dist-info}/top_level.txt +0 -0
@@ -1,5 +1,10 @@
|
|
1
|
+
import os
|
2
|
+
import uuid
|
3
|
+
|
1
4
|
import requests
|
2
5
|
from eth_account.messages import encode_defunct
|
6
|
+
from web3 import Web3
|
7
|
+
from datetime import datetime, timezone
|
3
8
|
|
4
9
|
from sybil_engine.contract.send import Send
|
5
10
|
from sybil_engine.domain.balance.balance import NativeBalance
|
@@ -7,7 +12,9 @@ from sybil_engine.utils.web3_utils import init_web3
|
|
7
12
|
|
8
13
|
from web3_wizzard_lib.core.modules.nft.nft_submodule import NftSubmodule
|
9
14
|
|
10
|
-
|
15
|
+
# 1. Connect
|
16
|
+
# 2. Verify
|
17
|
+
# 3. Spin
|
11
18
|
class LineaWheel(NftSubmodule):
|
12
19
|
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
20
|
module_name = 'LINEA_WHEEL'
|
@@ -22,9 +29,10 @@ class LineaWheel(NftSubmodule):
|
|
22
29
|
},
|
23
30
|
account.proxy
|
24
31
|
)
|
32
|
+
#sign_wheel(account)
|
25
33
|
jwt_token = get_jwt_token(account, web3)
|
34
|
+
linea_auth(jwt_token)
|
26
35
|
data = create_data(jwt_token, web3)
|
27
|
-
|
28
36
|
print(f"DATA {data}")
|
29
37
|
|
30
38
|
Send(
|
@@ -42,100 +50,152 @@ class LineaWheel(NftSubmodule):
|
|
42
50
|
|
43
51
|
|
44
52
|
def get_jwt_token(account, web3):
|
45
|
-
from datetime import datetime, timezone
|
46
|
-
|
47
53
|
nonce = requests.get("https://app.dynamicauth.com/api/v0/sdk/ae98b9b4-daaf-4bb3-b5e0-3f07175906ed/nonce")
|
48
|
-
print(f"NONCE {nonce.text}")
|
54
|
+
# print(f"NONCE {nonce.text}")
|
49
55
|
nonce_text = nonce.json()['nonce']
|
50
56
|
|
51
57
|
# Use current timestamp instead of hardcoded one
|
52
58
|
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}")
|
59
|
+
message_to_sign = form_message_to_sign(account, current_time, nonce_text)
|
65
60
|
encoded_message_to_sign = encode_defunct(text=message_to_sign)
|
66
61
|
signed_message = web3.eth.account.sign_message(encoded_message_to_sign, private_key=account.key)
|
62
|
+
# print(f"message to sign: {message_to_sign}")
|
63
|
+
# print(f"HASH {signed_message.signature.hex()}")
|
67
64
|
|
68
|
-
print(f"HASH {signed_message.signature.hex()}")
|
69
|
-
|
70
|
-
# Try without the 0x prefix for the signature
|
71
65
|
signature_hex = signed_message.signature.hex()
|
72
|
-
|
73
|
-
|
66
|
+
|
67
|
+
session_pubkey = generate_session_pubkey()
|
68
|
+
print(f"SESSION PUBKEY {session_pubkey}")
|
74
69
|
params = {
|
75
70
|
"signedMessage": f"0x{signature_hex}",
|
76
71
|
"messageToSign": message_to_sign,
|
77
|
-
"publicWalletAddress": account.address,
|
72
|
+
"publicWalletAddress": Web3.to_checksum_address(account.address),
|
78
73
|
"chain": "EVM",
|
79
74
|
"walletName": "metamask",
|
80
75
|
"walletProvider": "browserExtension",
|
81
76
|
"network": "59144",
|
82
|
-
"additionalWalletAddresses": []
|
83
|
-
|
77
|
+
"additionalWalletAddresses": [],
|
78
|
+
"sessionPublicKey": session_pubkey
|
84
79
|
}
|
85
80
|
|
86
|
-
|
87
|
-
|
81
|
+
# Generate unique request ID
|
82
|
+
request_id = str(uuid.uuid4()).replace('-', '')
|
88
83
|
|
89
|
-
|
90
|
-
|
84
|
+
headers = {
|
85
|
+
"accept": "*/*",
|
86
|
+
"accept-language": "en-GB,en-US;q=0.9,en;q=0.8,ru;q=0.7",
|
87
|
+
"content-type": "application/json",
|
88
|
+
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:141.0) Gecko/20100101 Firefox/141.0',
|
89
|
+
"origin": "https://linea.build",
|
90
|
+
"priority": "u=1, i",
|
91
|
+
"referer": "https://linea.build/",
|
92
|
+
"sec-ch-ua-mobile": "?0",
|
93
|
+
"sec-fetch-dest": "empty",
|
94
|
+
"sec-fetch-mode": "cors",
|
95
|
+
"sec-fetch-site": "cross-site",
|
96
|
+
"x-dyn-api-version": "API/0.0.681",
|
97
|
+
"x-dyn-request-id": request_id,
|
98
|
+
}
|
91
99
|
|
92
|
-
|
100
|
+
result = requests.post(
|
101
|
+
"https://app.dynamicauth.com/api/v0/sdk/ae98b9b4-daaf-4bb3-b5e0-3f07175906ed/verify",
|
102
|
+
json=params,
|
103
|
+
headers=headers
|
104
|
+
)
|
93
105
|
|
106
|
+
print(f"JWT Auth Status Code: {result.status_code}")
|
107
|
+
print(f"JWT Auth Response: {result.text}")
|
94
108
|
|
95
|
-
|
96
|
-
|
109
|
+
if result.status_code != 200:
|
110
|
+
raise Exception(f"JWT Authentication failed: {result.text}")
|
97
111
|
|
98
|
-
|
112
|
+
response_data = result.json()
|
113
|
+
if "jwt" not in response_data:
|
114
|
+
raise Exception(f"JWT token not found in response: {response_data}")
|
115
|
+
|
116
|
+
return response_data["jwt"]
|
117
|
+
|
118
|
+
|
119
|
+
def form_message_to_sign(account, current_time, nonce_text):
|
120
|
+
return f"""linea.build wants you to sign in with your Ethereum account:
|
121
|
+
{Web3.to_checksum_address(account.address)}
|
122
|
+
|
123
|
+
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.
|
124
|
+
|
125
|
+
URI: https://linea.build/hub/rewards
|
126
|
+
Version: 1
|
127
|
+
Chain ID: 59144
|
128
|
+
Nonce: {nonce_text}
|
129
|
+
Issued At: {current_time}
|
130
|
+
Request ID: ae98b9b4-daaf-4bb3-b5e0-3f07175906ed"""
|
99
131
|
|
132
|
+
|
133
|
+
def linea_auth(bearer_token: str):
|
134
|
+
url = "https://hub-api.linea.build/auth"
|
100
135
|
headers = {
|
136
|
+
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:141.0) Gecko/20100101 Firefox/141.0",
|
101
137
|
"Accept": "*/*",
|
102
138
|
"Accept-Language": "en-US,en;q=0.5",
|
103
139
|
"Accept-Encoding": "gzip, deflate, br, zstd",
|
104
140
|
"Referer": "https://linea.build/",
|
105
141
|
"Content-Type": "application/json",
|
106
|
-
"Authorization": f"Bearer {
|
142
|
+
"Authorization": f"Bearer {bearer_token}",
|
107
143
|
"Origin": "https://linea.build",
|
108
144
|
"Connection": "keep-alive",
|
109
145
|
"Sec-Fetch-Dest": "empty",
|
110
146
|
"Sec-Fetch-Mode": "cors",
|
111
147
|
"Sec-Fetch-Site": "same-site",
|
112
|
-
"Priority": "u=
|
113
|
-
"
|
114
|
-
|
148
|
+
"Priority": "u=4",
|
149
|
+
"TE": "trailers",
|
150
|
+
}
|
151
|
+
|
152
|
+
response = requests.post(url, headers=headers, data=b"")
|
153
|
+
response.raise_for_status() # raise error if status != 200
|
154
|
+
return response.json()
|
155
|
+
|
156
|
+
# Example usage:
|
157
|
+
# token = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIs..."
|
158
|
+
# print(linea_auth(token))
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
def create_data(jwt_token, web3):
|
163
|
+
url = "https://hub-api.linea.build/spins"
|
164
|
+
|
165
|
+
headers = {
|
166
|
+
"Accept": "*/*",
|
167
|
+
"Accept-Language": "en-US,en;q=0.5",
|
168
|
+
"Accept-Encoding": "gzip, deflate, br, zstd",
|
169
|
+
"Referer": "https://linea.build/",
|
170
|
+
"Content-Type": "application/json",
|
171
|
+
"Authorization": f"Bearer {jwt_token}",
|
115
172
|
}
|
116
173
|
|
117
174
|
response = requests.post(url, headers=headers)
|
118
175
|
|
119
|
-
print("Status
|
120
|
-
print("Response
|
176
|
+
print(f"Spins API Status Code: {response.status_code}")
|
177
|
+
print(f"Spins API Response: {response.content}")
|
178
|
+
|
179
|
+
if response.status_code == 404:
|
180
|
+
print(f"User not found in Linea Hub system. Address may need to be registered first.")
|
181
|
+
raise Exception(f"User not found: {response.text}")
|
182
|
+
elif response.status_code != 200:
|
183
|
+
try:
|
184
|
+
error_msg = response.json().get('message', 'Unknown error')
|
185
|
+
except:
|
186
|
+
error_msg = response.text
|
187
|
+
raise Exception(f"Spins API failed with status {response.status_code}: {error_msg}")
|
121
188
|
|
122
|
-
if response.status_code != 200:
|
123
|
-
raise Exception(response.json()['message'])
|
124
|
-
|
125
189
|
# Get the JSON response data
|
126
190
|
response_data = response.json()
|
127
191
|
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
|
-
|
192
|
+
|
193
|
+
contract = web3.eth.contract(address=LineaWheel.nft_address, abi=LineaWheel.abi)
|
134
194
|
# Convert response data to contract function parameters
|
135
195
|
nonce = int(response_data['nonce'])
|
136
196
|
expiration_timestamp = int(response_data['expirationTimestamp'])
|
137
197
|
boost = int(response_data['boost'])
|
138
|
-
|
198
|
+
|
139
199
|
# Convert signature array to struct format
|
140
200
|
signature_array = response_data['signature']
|
141
201
|
signature_struct = {
|
@@ -143,13 +203,41 @@ def create_data(jwt_token, web3):
|
|
143
203
|
's': signature_array[1], # bytes32
|
144
204
|
'v': int(signature_array[2]) # uint8
|
145
205
|
}
|
146
|
-
|
147
|
-
|
148
|
-
encoded_data = contract.encode_abi("participate", args=(
|
206
|
+
|
207
|
+
return contract.encode_abi("participate", args=(
|
149
208
|
nonce,
|
150
|
-
expiration_timestamp,
|
209
|
+
expiration_timestamp,
|
151
210
|
boost,
|
152
211
|
signature_struct
|
153
212
|
))
|
154
|
-
|
155
|
-
|
213
|
+
|
214
|
+
|
215
|
+
def sign_wheel(account):
|
216
|
+
url = "https://app.dynamicauth.com/api/v0/sdk/ae98b9b4-daaf-4bb3-b5e0-3f07175906ed/connect"
|
217
|
+
|
218
|
+
payload = {
|
219
|
+
"address": Web3.to_checksum_address(account.address),
|
220
|
+
"chain": "EVM",
|
221
|
+
"provider": "browserExtension",
|
222
|
+
"walletName": "metamask",
|
223
|
+
"authMode": "connect-and-sign"
|
224
|
+
}
|
225
|
+
|
226
|
+
response = requests.post(url, json=payload)
|
227
|
+
print(f"REGISTER: {response.status_code} {response.content}")
|
228
|
+
|
229
|
+
|
230
|
+
def generate_session_pubkey() -> str:
|
231
|
+
# Generate a 32-byte private key
|
232
|
+
private_key_bytes = os.urandom(32)
|
233
|
+
|
234
|
+
# Create a private key object
|
235
|
+
from eth_keys import keys
|
236
|
+
|
237
|
+
private_key = keys.PrivateKey(private_key_bytes)
|
238
|
+
|
239
|
+
# Get the compressed public key (33 bytes, starts with 02 or 03)
|
240
|
+
compressed_pubkey = private_key.public_key.to_compressed_bytes()
|
241
|
+
|
242
|
+
# Return hex string
|
243
|
+
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=-Z_Zpr7Va5FL89JTb-l8lIlsSUiLjZV2EDA_Jdlyn5o,23563
|
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.2.dist-info/METADATA,sha256=ISVgusMRbNmwGd7l2UMKM6vYDuHHX0tw1HBMxOCEU54,370
|
376
|
+
web3_wizzard_lib-1.12.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
377
|
+
web3_wizzard_lib-1.12.2.dist-info/top_level.txt,sha256=31sEPHxuJ1p5fpc75vHQJ8eJdSs80aCZeeT3L8YAHNg,17
|
378
|
+
web3_wizzard_lib-1.12.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|