Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,12 @@
from .gateway import (
AddPoolRequest,
AddTokenRequest,
CreateWalletRequest,
GatewayBalanceRequest,
GatewayConfig,
GatewayStatus,
GatewayWalletCredential,
GatewayWalletInfo,
SendTransactionRequest,
SetDefaultWalletRequest,
ShowPrivateKeyRequest,
UpdateApiKeysRequest,
)

Expand Down Expand Up @@ -282,9 +279,6 @@
# Gateway models
"GatewayConfig",
"GatewayStatus",
"CreateWalletRequest",
"ShowPrivateKeyRequest",
"SendTransactionRequest",
"SetDefaultWalletRequest",
"GatewayWalletCredential",
"GatewayWalletInfo",
Expand Down
22 changes: 0 additions & 22 deletions models/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,6 @@ class GatewayStatus(BaseModel):
# Wallet Management Models
# ============================================

class CreateWalletRequest(BaseModel):
"""Request to create a new wallet in Gateway"""
chain: str = Field(description="Blockchain chain (e.g., 'solana', 'ethereum')")
set_default: bool = Field(default=True, description="Set as default wallet for this chain")


class ShowPrivateKeyRequest(BaseModel):
"""Request to show private key for a wallet"""
chain: str = Field(description="Blockchain chain (e.g., 'solana', 'ethereum')")
address: str = Field(description="Wallet address")
passphrase: str = Field(description="Gateway passphrase for decryption")


class SendTransactionRequest(BaseModel):
"""Request to send a native token transaction"""
chain: str = Field(description="Blockchain chain (e.g., 'solana', 'ethereum')")
network: str = Field(description="Network (e.g., 'mainnet-beta', 'mainnet')")
address: str = Field(description="Sender wallet address")
to_address: str = Field(description="Recipient address")
amount: str = Field(description="Amount to send (in native token units)")


class GatewayWalletCredential(BaseModel):
"""Credentials for adding an existing wallet to Gateway"""
chain: str = Field(description="Blockchain chain (e.g., 'solana', 'ethereum')")
Expand Down
146 changes: 0 additions & 146 deletions routers/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@
from models import (
AddPoolRequest,
AddTokenRequest,
CreateWalletRequest,
GatewayConfig,
GatewayStatus,
SendTransactionRequest,
ShowPrivateKeyRequest,
UpdateApiKeysRequest,
)
from services.accounts_service import AccountsService
Expand Down Expand Up @@ -947,146 +944,3 @@ async def delete_network_pool(
raise
except Exception as e:
raise HTTPException(status_code=500, detail=f"Error deleting pool: {str(e)}")


# ============================================
# Wallet Management
# ============================================

@router.post("/wallets/create")
async def create_wallet(
request: CreateWalletRequest,
accounts_service: AccountsService = Depends(get_accounts_service)
) -> Dict:
"""
Create a new wallet in Gateway.

Args:
request: Contains chain and set_default flag

Returns:
Dict with address and chain of the created wallet.

Example: POST /gateway/wallets/create
{
"chain": "solana",
"set_default": true
}
"""
try:
if not await accounts_service.gateway_client.ping():
raise HTTPException(status_code=503, detail="Gateway service is not available")

result = await accounts_service.gateway_client.create_wallet(
chain=request.chain,
set_default=request.set_default
)

if result is None:
raise HTTPException(status_code=502, detail="Failed to create wallet: Gateway returned no response")

if "error" in result:
raise HTTPException(status_code=400, detail=f"Failed to create wallet: {result.get('error')}")

return result

except HTTPException:
raise
except Exception as e:
raise HTTPException(status_code=500, detail=f"Error creating wallet: {str(e)}")


@router.post("/wallets/show-private-key")
async def show_private_key(
request: ShowPrivateKeyRequest,
accounts_service: AccountsService = Depends(get_accounts_service)
) -> Dict:
"""
Show private key for a wallet.

WARNING: This endpoint exposes sensitive information. Use with caution.

Args:
request: Contains chain, address, and passphrase

Returns:
Dict with privateKey field.

Example: POST /gateway/wallets/show-private-key
{
"chain": "solana",
"address": "<wallet-address>",
"passphrase": "<gateway-passphrase>"
}
"""
try:
if not await accounts_service.gateway_client.ping():
raise HTTPException(status_code=503, detail="Gateway service is not available")

result = await accounts_service.gateway_client.show_private_key(
chain=request.chain,
address=request.address,
passphrase=request.passphrase
)

if result is None:
raise HTTPException(status_code=502, detail="Failed to retrieve private key: Gateway returned no response")

if "error" in result:
raise HTTPException(status_code=400, detail=f"Failed to retrieve private key: {result.get('error')}")

return result

except HTTPException:
raise
except Exception as e:
raise HTTPException(status_code=500, detail=f"Error retrieving private key: {str(e)}")


@router.post("/wallets/send")
async def send_transaction(
request: SendTransactionRequest,
accounts_service: AccountsService = Depends(get_accounts_service)
) -> Dict:
"""
Send a native token transaction.

Args:
request: Contains chain, network, sender address, recipient address, and amount

Returns:
Dict with transaction signature/hash.

Example: POST /gateway/wallets/send
{
"chain": "solana",
"network": "mainnet-beta",
"address": "<sender-address>",
"to_address": "<recipient-address>",
"amount": "0.001"
}
"""
try:
if not await accounts_service.gateway_client.ping():
raise HTTPException(status_code=503, detail="Gateway service is not available")

result = await accounts_service.gateway_client.send_transaction(
chain=request.chain,
network=request.network,
address=request.address,
to_address=request.to_address,
amount=request.amount
)

if result is None:
raise HTTPException(status_code=502, detail="Failed to send transaction: Gateway returned no response")

if "error" in result:
raise HTTPException(status_code=400, detail=f"Failed to send transaction: {result.get('error')}")

return result

except HTTPException:
raise
except Exception as e:
raise HTTPException(status_code=500, detail=f"Error sending transaction: {str(e)}")
32 changes: 0 additions & 32 deletions services/gateway_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,38 +162,6 @@ async def add_wallet(self, chain: str, private_key: str, set_default: bool = Tru
"setDefault": set_default
})

async def create_wallet(self, chain: str, set_default: bool = True) -> Dict:
"""Create a new wallet in Gateway"""
return await self._request("POST", "wallet/create", json={
"chain": chain,
"setDefault": set_default
})

async def show_private_key(self, chain: str, address: str, passphrase: str) -> Dict:
"""Show private key for a wallet"""
return await self._request("POST", "wallet/show-private-key", json={
"chain": chain,
"address": address,
"passphrase": passphrase
})

async def send_transaction(
self,
chain: str,
network: str,
address: str,
to_address: str,
amount: str
) -> Dict:
"""Send a native token transaction"""
return await self._request("POST", "wallet/send", json={
"chain": chain,
"network": network,
"address": address,
"toAddress": to_address,
"amount": amount
})

async def remove_wallet(self, chain: str, address: str) -> Dict:
"""Remove a wallet from Gateway"""
return await self._request("DELETE", "wallet/remove", json={
Expand Down
Loading