-
Notifications
You must be signed in to change notification settings - Fork 23
Description
🐛 Bug Description
Hi guys. I have a question. So, I haven't worked on Aptos for a while, and today I realized that the package has changed a lot. I'm trying to conduct the following trasnaction:
https://explorer.aptoslabs.com/txn/1829613228/userTxnOverview?network=mainnet
The problem is, the code seems alright by Aptos SDK, I've tried every combination but the map (dict since I'm using python) gets encoded but doesn't get decoded on the network. Now, to solve this I can either figure out what is wrong with Aptos SDK, or get the exact bytes for the payload (I can deserialize it or even send it as is, because remains exactly the same). I would appropriate it if you help me with either of them.
I have tried examples, they work seamlessly, but there is no example of using map, and I think that's exactly the problem, since explorers are OK decoding everything else but a map.
How to reproduce
Code snippet to reproduce
from aptos_sdk.account import Account
from aptos_sdk.async_client import RestClient
from aptos_sdk.account_address import AccountAddress
from typing import Dict, Any
from aptos_sdk.transactions import RawTransaction, TransactionPayload, EntryFunction, ModuleId, TransactionArgument, SignedTransaction, TypeTag, StructTag
from aptos_sdk.bcs import Serializer
import time
class LaunchpadMinting:
__aptos_client: RestClient
__account: Account
def __init__(self, private_key: str, aptos_rpc: str = 'https://api.mainnet.aptoslabs.com/v1') -> None:
self.__account = Account.load_key(private_key)
self.__aptos_client = RestClient(aptos_rpc)
async def mint_token(self, collection_address: str, quantity: int):
inner_map = lambda x,y: x.map(y, key_encoder=Serializer.str, value_encoder=Serializer.str)
vec_map = lambda x,y: x.map(y, key_encoder=Serializer.str, value_encoder=Serializer.sequence_serializer(Serializer.str))
inner = TransactionArgument({'inner': collection_address}, inner_map)
vec = TransactionArgument({'vec': [str(quantity)]}, vec_map)
tx = RawTransaction(
self.__account.account_address,
await self.__aptos_client.account_sequence_number(self.__account.account_address),
TransactionPayload(
EntryFunction(
ModuleId(
AccountAddress.from_str('0x96c192a4e3c529f0f6b3567f1281676012ce65ba4bb0a9b20b46dec4e371cccd'),
'unmanaged_launchpad'
),
'mint',
[],
[
inner.encode(),
vec.encode()
]
)
),
max_gas_amount=1000,
gas_unit_price=100,
expiration_timestamps_secs=int(time.time()) + 10,
chain_id=1
)
signed_tx = SignedTransaction(tx, self.__account.sign_transaction(tx))
tx_hash = await self.__aptos_client.submit_bcs_transaction(signed_tx)
await self.__aptos_client.wait_for_transaction(tx_hash)
print("Mint TX HASH:", tx_hash)
return tx_hash
async def main():
launchpad = LaunchpadMinting(private_key='PK')
await launchpad.mint_token(collection_address="0xd42cd397c41a62eaf03e83ad0324ff6822178a3e40aa596c4b9930561d4753e5", quantity=1)
import asyncio
asyncio.run(main())Stack trace / error message
This account is what I've been conducting my tests on:
https://explorer.aptoslabs.com/account/0x71073d5ec015ceb546278fe46b5282a7c6ee59d5bf081be3e63cc6c16d141d85?network=mainnet
Expected Behavior
https://explorer.aptoslabs.com/txn/1829613228/userTxnOverview?network=mainnet
System information
System details:
- Python 3.10.12
- aptos-sdk==0.9.2