hashgraph / hedera-services

Crypto, token, consensus, file, and smart contract services for the Hedera public ledger
Apache License 2.0
311 stars 136 forks source link

.setAccountId does not accept EVM address based account ID #14862

Open a-ridley opened 2 months ago

a-ridley commented 2 months ago

Description

Description copied from issue: https://github.com/hashgraph/hedera-sdk-js/issues/2442

Variation 1 - EVM address as string:

const assocTx = await new TokenAssociateTransaction()
        .setAccountId('0x34fe5d75bd7ee95273ac9883c460d71edb0a2b6e')
        .setTokenIds([tokenId])
        .setNodeAccountIds([AccountId.fromString('0.0.5')])
        .freezeWith(client);

Variation 2 - account ID based on EVM address:

const assocTx = await new TokenAssociateTransaction()
        .setAccountId(AccountId.fromEvmAddress(0, 0,'0x34fe5d75bd7ee95273ac9883c460d71edb0a2b6e'))
        .setTokenIds([tokenId])
        .setNodeAccountIds([AccountId.fromString('0.0.5')])
        .freezeWith(client);

Variation 3 - Account ID in S.R.N format:

const assocTx = await new TokenAssociateTransaction()
        .setAccountId(AccountId.fromString('0.0.4654396'))
        .setTokenIds([tokenId])
        .setNodeAccountIds([AccountId.fromString('0.0.5')])
        .freezeWith(client);

This also occurs for TokenFreezeTransaction() as it was reported by a developer who is part of the Hello Future Hackathon.

Steps to reproduce

Steps to reproduce

  1. Create assocTx in each of the above variations.
  2. Sign an submit assocTx using the code below
  3. Observe that with variation 1 and 2, there is an error, but variation 3 works
    • Note that all 3 variations refer to the same account:https://hashscan.io/testnet/account/0.0.4654396
    • Note that this behaviour is inconsistent with other SDK methods, such as TransferTransaction, which do accept their own equivalents of variations 1 and 2.
    const assocTxId = assocTx.transactionId;
    logger.log('The token association transaction ID:', assocTxId.toString());

    await logger.logSectionWithWaitPrompt('Submitting token association transaction');
    const assocTxSigned = await assocTx.sign(account1Key);

    const assocTxSubmitted = await assocTxSigned.execute(client);

    const assocTxReceipt = await assocTxSubmitted.getReceipt(client);
    const assocTxStatus = assocTxReceipt.status;
    logger.log(
        'The token association transaction status is:',
        assocTxStatus.toString(),
    );

Additional context

Additional context

The error is INVALID_ACCOUNT_ID and the full output is copied below. The error occurs when getReceipt is invoked.

ReceiptStatusError: receipt for transaction 0.0.4650263@1722847623.102513022 contained error status INVALID_ACCOUNT_ID at new ReceiptStatusError (file:///Users/user/code/hedera/hedera-tokens-cyoa-tutorial/node_modules/@hashgraph/sdk/src/ReceiptStatusError.js:37:9) at TransactionReceiptQuery._mapStatusError (file:///Users/user/code/hedera/hedera-tokens-cyoa-tutorial/node_modules/@hashgraph/sdk/src/transaction/TransactionReceiptQuery.js:332:16) at TransactionReceiptQuery.execute (file:///Users/user/code/hedera/hedera-tokens-cyoa-tutorial/node_modules/@hashgraph/sdk/src/Executable.js:725:32) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async TransactionResponse.getReceipt (file:///Users/user/code/hedera/hedera-tokens-cyoa-tutorial/node_modules/@hashgraph/sdk/src/transaction/TransactionResponse.js:81:25) at async scriptTokenHts (file:///Users/user/code/hedera/hedera-tokens-cyoa-tutorial/tokenHts/script-tokenHts.js:126:28) { status: Status { _code: 15 }, transactionId: TransactionId { accountId: AccountId { shard: [Long], realm: [Long], num: [Long], aliasKey: null, evmAddress: null, _checksum: null }, validStart: Timestamp { seconds: [Long], nanos: [Long] }, scheduled: false, nonce: null }, transactionReceipt: TransactionReceipt { status: Status { _code: 15 }, accountId: null, fileId: null, contractId: null, topicId: null, tokenId: null, scheduleId: null, exchangeRate: ExchangeRate { hbars: 30000, cents: 143313, expirationTime: 2024-08-05T09:00:00.000Z, exchangeRateInCents: 4.7771 }, topicSequenceNumber: Long { low: 0, high: 0, unsigned: false }, topicRunningHash: Uint8Array(0) [], totalSupply: Long { low: 0, high: 0, unsigned: false }, scheduledTransactionId: null, serials: [], duplicates: [], children: [] } }

Hedera network

testnet

Version

2.48.1

Operating system

macOS

a-ridley commented 2 months ago

@tinker-michaelj A hacker participating in our Hello Future Hackathon has raised this issue. If you get a chance to look at this issue that would be greatly appreciated! Thank you !