Skip to content

Commit

Permalink
Add multisig transaction support (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xmaayan authored May 16, 2024
1 parent 109bb3c commit 69b6101
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/dry-starfishes-push.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@aptos-labs/wallet-adapter-core": minor
---

Add multisig transaction support
25 changes: 22 additions & 3 deletions packages/wallet-adapter-core/src/LegacyWalletPlugins/conversion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,25 @@ export function convertV2PayloadToV1JSONPayload(
if ("bytecode" in payload) {
// is a script payload
throw new Error("script payload not supported");
// is multisig function payload
} else if ("multisigAddress" in payload) {
const stringTypeTags: string[] | undefined = payload.typeArguments?.map(
(typeTag) => {
if (typeTag instanceof TypeTag) {
return typeTag.toString();
}
return typeTag;
}
);
const newPayload: Types.TransactionPayload = {
type: "multisig_payload",
multisig_address: payload.multisigAddress.toString(),
function: payload.function,
type_arguments: stringTypeTags || [],
arguments: payload.functionArguments,
};

return newPayload;
} else {
// is entry function payload
const stringTypeTags: string[] | undefined = payload.typeArguments?.map(
Expand All @@ -67,9 +86,9 @@ export function convertV2PayloadToV1JSONPayload(

export async function generateTransactionPayloadFromV1Input(
aptosConfig: AptosConfig,
inputV1: Types.TransactionPayload,
inputV1: Types.TransactionPayload
): Promise<TransactionPayloadEntryFunction> {
if ('function' in inputV1) {
if ("function" in inputV1) {
const inputV2: InputEntryFunctionData | InputMultiSigData = {
function: inputV1.function as MoveFunctionId,
functionArguments: inputV1.arguments,
Expand All @@ -78,7 +97,7 @@ export async function generateTransactionPayloadFromV1Input(
return generateTransactionPayload({ ...inputV2, aptosConfig });
}

throw new Error('Payload type not supported');
throw new Error("Payload type not supported");
}

export interface CompatibleTransactionOptions {
Expand Down

0 comments on commit 69b6101

Please sign in to comment.