From a58ed4107aab803c9b42b2e45bf865cc6bd0ea50 Mon Sep 17 00:00:00 2001 From: Daniel Gallego Rubio Date: Wed, 17 Sep 2025 00:12:42 +0200 Subject: [PATCH 1/2] wip --- examples/rpc/withdraw_and_bridge_out.py | 2 +- sdk/reya_rpc/actions/bridge_in.py | 7 +++--- sdk/reya_rpc/actions/bridge_out.py | 32 ++++++++++++++++++++----- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/examples/rpc/withdraw_and_bridge_out.py b/examples/rpc/withdraw_and_bridge_out.py index 1cc76d43..83cd0249 100644 --- a/examples/rpc/withdraw_and_bridge_out.py +++ b/examples/rpc/withdraw_and_bridge_out.py @@ -16,7 +16,7 @@ def main(): load_dotenv() # Retrieve the margin account ID from environment variables - account_id = int(os.environ["ACCOUNT_ID"]) + account_id = 95681 # Load configuration config = get_config() diff --git a/sdk/reya_rpc/actions/bridge_in.py b/sdk/reya_rpc/actions/bridge_in.py index 44b33024..02a1a094 100644 --- a/sdk/reya_rpc/actions/bridge_in.py +++ b/sdk/reya_rpc/actions/bridge_in.py @@ -1,4 +1,5 @@ import json +import pathlib from dataclasses import dataclass from web3 import Web3 @@ -17,10 +18,10 @@ class BridgeInParams: # Load contract ABI files -with open("sdk/reya_rpc/abis/SocketVaultWithPayload.json", encoding="utf-8") as f: +with open(pathlib.Path(__file__).parent.parent/"abis/SocketVaultWithPayload.json", encoding="utf-8") as f: vault_abi = json.load(f) -with open("sdk/reya_rpc/abis/Erc20.json", encoding="utf-8") as f: +with open(pathlib.Path(__file__).parent.parent/"abis/Erc20.json", encoding="utf-8") as f: erc20_abi = json.load(f) @@ -157,7 +158,7 @@ def _build_bridge_transaction( periphery = config["w3contracts"]["periphery"] reya_usdc = config["w3contracts"]["usdc"] - periphery_calldata = periphery.encodeABI(fn_name="deposit", args=[(account.address, reya_usdc.address)]) + periphery_calldata = periphery.functions.deposit((account.address, reya_usdc.address))._encode_transaction_data() socket_bridge_options = Web3.to_bytes(hexstr=HexStr("0x")) return vault.functions.bridge( diff --git a/sdk/reya_rpc/actions/bridge_out.py b/sdk/reya_rpc/actions/bridge_out.py index 15019bb2..542b4cd6 100644 --- a/sdk/reya_rpc/actions/bridge_out.py +++ b/sdk/reya_rpc/actions/bridge_out.py @@ -115,9 +115,19 @@ def _approve_rusd_spending(config: dict, params: BridgeOutParams): periphery = config["w3contracts"]["periphery"] rusd = config["w3contracts"]["rusd"] - tx_hash = rusd.functions.approve(periphery.address, params.amount).transact({"from": account.address}) + # Build transaction + tx = rusd.functions.approve(periphery.address, params.amount).build_transaction({ + 'from': account.address, + 'nonce': w3.eth.get_transaction_count(account.address), + 'gas': 100000, # Standard gas limit for ERC20 approve + 'gasPrice': w3.eth.gas_price, + }) + + # Sign and send transaction + signed_tx = w3.eth.account.sign_transaction(tx, config["private_key"]) + tx_hash = w3.eth.send_raw_transaction(signed_tx.raw_transaction) tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash) - print(f"Approved rUSD to periphery: {tx_receipt.transactionHash.hex()}") + print(f"Approved rUSD to periphery: {tx_receipt['transactionHash'].hex()}") def _execute_bridge_out_withdrawal( @@ -129,7 +139,8 @@ def _execute_bridge_out_withdrawal( periphery = config["w3contracts"]["periphery"] rusd = config["w3contracts"]["rusd"] - tx_hash = periphery.functions.withdraw( + # Build transaction + tx = periphery.functions.withdraw( ( params.amount, rusd.address, @@ -137,10 +148,19 @@ def _execute_bridge_out_withdrawal( dest_chain_id, account.address, ) - ).transact({"from": account.address, "value": socket_fees}) - + ).build_transaction({ + 'from': account.address, + 'nonce': w3.eth.get_transaction_count(account.address), + 'gas': 500000, # Higher gas limit for bridge withdrawal + 'gasPrice': w3.eth.gas_price, + 'value': socket_fees + }) + + # Sign and send transaction + signed_tx = w3.eth.account.sign_transaction(tx, config["private_key"]) + tx_hash = w3.eth.send_raw_transaction(signed_tx.raw_transaction) tx_receipt = w3.eth.wait_for_transaction_receipt(tx_hash) - print(f"Initiated bridge out: {tx_receipt.transactionHash.hex()}") + print(f"Initiated bridge out: {tx_receipt['transactionHash'].hex()}") return tx_receipt From f40c69476294bbe715961ea2138c9be04036b68a Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Tue, 16 Sep 2025 22:15:04 +0000 Subject: [PATCH 2/2] chore: bump SDK version to 2.0.4.2 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 30785801..f95f657d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "reya-python-sdk" -version = "2.0.4.1" +version = "2.0.4.2" description = "SDK for interacting with Reya Labs APIs" authors = [ {name = "Reya Labs"}