Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect API warning for signAndSubmitTransaction #393

Open
gsong opened this issue Aug 6, 2024 · 1 comment
Open

Incorrect API warning for signAndSubmitTransaction #393

gsong opened this issue Aug 6, 2024 · 1 comment

Comments

@gsong
Copy link
Contributor

gsong commented Aug 6, 2024

When using the latest @aptos-labs/[email protected], this message appears in the console:

Usage of `signAndSubmitTransaction(payload)` is going to be deprecated soon. Use `signAndSubmitTransaction({ payload })` instead

However, using the recommended function signature doesn't work.

@liveseed
Copy link

liveseed commented Aug 7, 2024

Hi @gsong
It suggests that the function will soon require an object with a payload property instead of just the payload itself.

  1. Current (soon-to-be-deprecated) usage:

    await signAndSubmitTransaction(payload);
  2. Updated usage (as per the warning):

    await signAndSubmitTransaction({ payload });

However, since you mentioned that using the recommended function signature doesn't work:

  1. Check for Typographical Errors:

    Ensure that you are correctly passing the payload as an object property. It should be { payload } and not {payload} or any other variation.

  2. Verify the Payload Structure:

    Ensure that the payload you are passing is correctly structured and contains all necessary fields required by the function.

  3. Check for Package Updates:

    Sometimes, packages may release updates that fix issues or add clarity. Ensure that you have the latest version of @aptos-labs/wallet-adapter-react by running:

npm install @aptos-labs/wallet-adapter-react@latest

example

import { useWallet } from '@aptos-labs/wallet-adapter-react';

const { signAndSubmitTransaction } = useWallet();

const payload = {
  type: "entry_function_payload",
  function: "0x1::ModuleName::functionName",
  arguments: ["arg1", "arg2"],
  type_arguments: ["u8", "u64"]
};

try {
  const response = await signAndSubmitTransaction({ payload });
  console.log('Success:', response);
} catch (error) {
  console.error('Failed', error);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants