// Copyright © Endless // Copyright © Aptos Foundation // SPDX-License-Identifier: Apache-2.0 /** * This file contains the underlying implementations for exposed API surface in * the {@link api/fungible_asset}. By moving the methods out into a separate file, * other namespaces and processes can access these methods without depending on the entire * fungible_asset namespace and without having a dependency cycle error. */ import { EndlessConfig } from "../api/endlessConfig"; import { AnyNumber, MoveAbility } from "../types"; import { AccountAddressInput } from "../core"; import { Account } from "../account"; import { EntryFunctionABI, InputGenerateTransactionOptions, parseTypeTag, TypeTagAddress, TypeTagU128, } from "../transactions"; import { generateTransaction } from "./transactionSubmission"; import { SimpleTransaction } from "../transactions/instances/simpleTransaction"; const transferFungibleAssetAbi: EntryFunctionABI = { typeParameters: [{ constraints: [MoveAbility.KEY] }], parameters: [parseTypeTag("0x1::object::Object"), new TypeTagAddress(), new TypeTagU128()], }; export async function transferFungibleAsset(args: { endlessConfig: EndlessConfig; sender: Account; fungibleAssetMetadataAddress: AccountAddressInput; recipient: AccountAddressInput; amount: AnyNumber; options?: InputGenerateTransactionOptions; }): Promise { const { endlessConfig, sender, fungibleAssetMetadataAddress, recipient, amount, options } = args; return generateTransaction({ endlessConfig, sender: sender.accountAddress, data: { function: "0x1::primary_fungible_store::transfer", typeArguments: ["0x1::fungible_asset::Metadata"], functionArguments: [fungibleAssetMetadataAddress, recipient, amount], abi: transferFungibleAssetAbi, }, options, }); }