aptos-labs / aptos-wallet-adapter

A monorepo modular wallet adapter for Aptos applications
https://aptos-labs.github.io/aptos-wallet-adapter/
Apache License 2.0
88 stars 97 forks source link

Handle arguments conversion when submitting a package publish transac… #432

Closed 0xmaayan closed 2 weeks ago

0xmaayan commented 2 weeks ago

…tion

The Aptos SDK expects the metadataBytes and byteCode to be Uint8Array, but in case the arguments are passed in as a string, this function converts the string to Uint8Array.

Now we can use the wallet adapter to submit a package publish transaction like

const response = await signAndSubmitTransaction({
      data: {
        function: "0x1::code::publish_package_txn",
        functionArguments: [
         "0x123",
          ["0x456"],
        ],
      },
    });

and

const response = await signAndSubmitTransaction({
      data: {
        function: "0x1::code::publish_package_txn",
        functionArguments: [
          Hex.fromHexInput( "0x123").toUint8Array(),
          [Hex.fromHexInput("0x456").toUint8Array()],
        ],
      },
    });

https://aptos-org.slack.com/archives/C05161WELKZ/p1726562237760779