Skip to content

Commit

Permalink
[transactions] Remove non-BCS transaction submission
Browse files Browse the repository at this point in the history
  • Loading branch information
gregnazario committed Aug 20, 2024
1 parent 96cf595 commit 01fdcca
Showing 1 changed file with 0 additions and 66 deletions.
66 changes: 0 additions & 66 deletions aptos_sdk/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import httpx
import python_graphql_client
from typing_extensions import deprecated

from .account import Account
from .account_address import AccountAddress
Expand Down Expand Up @@ -519,51 +518,6 @@ async def submit_and_wait_for_bcs_transaction(
await self.wait_for_transaction(txn_hash)
return await self.transaction_by_hash(txn_hash)

@deprecated("please use bcs_submit_transaction for better performance and security")
async def submit_transaction(self, sender: Account, payload: Dict[str, Any]) -> str:
"""
Deprecated, please use bcs_submit_transaction for better performance and security
1) Generates a transaction request
2) submits that to produce a raw transaction
3) signs the raw transaction
4) submits the signed transaction
"""

txn_request = {
"sender": f"{sender.address()}",
"sequence_number": str(
await self.account_sequence_number(sender.address())
),
"max_gas_amount": str(self.client_config.max_gas_amount),
"gas_unit_price": str(self.client_config.gas_unit_price),
"expiration_timestamp_secs": str(
int(time.time()) + self.client_config.expiration_ttl
),
"payload": payload,
}

response = await self.client.post(
f"{self.base_url}/transactions/encode_submission", json=txn_request
)
if response.status_code >= 400:
raise ApiError(response.text, response.status_code)

to_sign = bytes.fromhex(response.json()[2:])
signature = sender.sign(to_sign)
txn_request["signature"] = {
"type": "ed25519_signature",
"public_key": f"{sender.public_key()}",
"signature": f"{signature}",
}

headers = {"Content-Type": "application/json"}
response = await self.client.post(
f"{self.base_url}/transactions", headers=headers, json=txn_request
)
if response.status_code >= 400:
raise ApiError(response.text, response.status_code)
return response.json()["hash"]

async def transaction_pending(self, txn_hash: str) -> bool:
response = await self._get(endpoint=f"transactions/by_hash/{txn_hash}")
# TODO(@davidiw): consider raising a different error here, since this is an ambiguous state
Expand Down Expand Up @@ -759,26 +713,6 @@ async def create_bcs_signed_transaction(
# Transaction wrappers
#

@deprecated("please use bcs_transfer for better performance and security")
async def transfer(
self, sender: Account, recipient: AccountAddress, amount: int
) -> str:
"""
Deprecated: please use bcs_transfer for greater performance and security
Transfer a given coin amount from a given Account to the recipient's account address.
Returns the sequence number of the transaction used to transfer."""

payload = {
"type": "entry_function_payload",
"function": "0x1::aptos_account::transfer",
"type_arguments": [],
"arguments": [
f"{recipient}",
str(amount),
],
}
return await self.submit_transaction(sender, payload)

# :!:>bcs_transfer
async def bcs_transfer(
self,
Expand Down

0 comments on commit 01fdcca

Please sign in to comment.