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

[nextjs] fix multiAgent transfer script #429

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { aptosClient, isSendableNetwork } from "@/utils";
import {
Account,
AccountAddress,
AccountAuthenticator,
AnyRawTransaction,
Ed25519Account,
parseTypeTag,
U64,
} from "@aptos-labs/ts-sdk";
import { useWallet } from "@aptos-labs/wallet-adapter-react";
import { useState } from "react";
Expand All @@ -14,6 +17,8 @@ import { useToast } from "../ui/use-toast";
import { LabelValueGrid } from "../LabelValueGrid";

const APTOS_COIN = "0x1::aptos_coin::AptosCoin";
const TRANSFER_SCRIPT =
"0xa11ceb0b0600000006010002030206040802050a10071a1d0837200000000103010100000204060c060c05030001090003060c05030d6170746f735f6163636f756e740e7472616e736665725f636f696e73000000000000000000000000000000000000000000000000000000000000000101000001050b010b020b03380002";

export function MultiAgent() {
const { toast } = useToast();
Expand Down Expand Up @@ -55,9 +60,9 @@ export function MultiAgent() {
sender: account.address,
secondarySignerAddresses: [secondarySigner.accountAddress],
data: {
function: "0x1::coin::transfer",
typeArguments: [APTOS_COIN],
functionArguments: [account.address, 1], // 1 is in Octas
bytecode: TRANSFER_SCRIPT,
typeArguments: [parseTypeTag(APTOS_COIN)],
functionArguments: [AccountAddress.fromString(account.address), new U64(1)],
},
});
return transactionToSign;
Expand All @@ -78,8 +83,16 @@ export function MultiAgent() {
if (!transactionToSubmit) {
throw new Error("No Transaction to sign");
}
if (!secondarySignerAccount) {
throw new Error("No secondarySignerAccount");
}
try {
const authenticator = await signTransaction(transactionToSubmit);
const authenticator = aptosClient(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what this change for? the idea of using this demo app is to use the wallet adapter to sign a transaction and not the sdk

network,
).sign({
signer: secondarySignerAccount ,
transaction: transactionToSubmit
}) ;
setSecondarySignerAuthenticator(authenticator);
} catch (error) {
console.error(error);
Expand Down
Loading