Skip to content

Commit daea736

Browse files
committed
feat: internal transfer
1 parent 6f58680 commit daea736

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

src/deltadefi/clients/accounts.py

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717
SubmitDepositTransactionResponse,
1818
SubmitWithdrawalTransactionResponse,
1919
)
20-
from deltadefi.responses.accounts import GetOperationKeyResponse
20+
from deltadefi.responses.accounts import (
21+
BuildTransferalTransactionResponse,
22+
GetOperationKeyResponse,
23+
SubmitTransferalTransactionResponse,
24+
)
2125

2226

2327
class Accounts(API):
@@ -147,6 +151,31 @@ def build_withdrawal_transaction(
147151
url_path = "/withdrawal/build"
148152
return self.send_request("POST", self.group_url_path + url_path, payload)
149153

154+
def build_transferal_transaction(
155+
self, transferal_amount: List[Asset], to_address: str, **kwargs
156+
) -> BuildTransferalTransactionResponse:
157+
"""
158+
Build a transferal transaction.
159+
160+
Args:
161+
data: A BuildTransferalTransactionRequest object containing the transferal transaction details.
162+
163+
Returns:
164+
A BuildTransferalTransactionResponse object containing the built transferal transaction.
165+
"""
166+
167+
check_required_parameter(
168+
transferal_amount, "transferal_amount", to_address, "to_address"
169+
)
170+
payload = {
171+
"transferal_amount": transferal_amount,
172+
"to_address": to_address,
173+
**kwargs,
174+
}
175+
176+
url_path = "/transferal/build"
177+
return self.send_request("POST", self.group_url_path + url_path, payload)
178+
150179
def submit_deposit_transaction(
151180
self, signed_tx: str, **kwargs
152181
) -> SubmitDepositTransactionResponse:
@@ -184,3 +213,22 @@ def submit_withdrawal_transaction(
184213

185214
url_path = "/withdrawal/submit"
186215
return self.send_request("POST", self.group_url_path + url_path, payload)
216+
217+
def submit_transferal_transaction(
218+
self, signed_tx: str, **kwargs
219+
) -> SubmitTransferalTransactionResponse:
220+
"""
221+
Submit a transferal transaction.
222+
223+
Args:
224+
data: A SubmitTransferalTransactionRequest object containing the transferal transaction details.
225+
226+
Returns:
227+
A SubmitTransferalTransactionResponse object containing the submitted transferal transaction.
228+
"""
229+
230+
check_required_parameter(signed_tx, "signed_tx")
231+
payload = {"signed_tx": signed_tx, **kwargs}
232+
233+
url_path = "/transferal/submit"
234+
return self.send_request("POST", self.group_url_path + url_path, payload)

src/deltadefi/responses/accounts.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,21 @@ class BuildWithdrawalTransactionResponse(TypedDict):
5252
tx_hex: str
5353

5454

55+
@dataclass
56+
class BuildTransferalTransactionResponse(TypedDict):
57+
tx_hex: str
58+
59+
5560
@dataclass
5661
class SubmitWithdrawalTransactionResponse(TypedDict):
5762
tx_hash: str
5863

5964

65+
@dataclass
66+
class SubmitTransferalTransactionResponse(TypedDict):
67+
tx_hash: str
68+
69+
6070
@dataclass
6171
class GetAccountInfoResponse(TypedDict):
6272
api_key: str

0 commit comments

Comments
 (0)