UNPKG

@effectai/sdk

Version:

Effect Network Javscript/Typescript SDK (for [https://effect.network](https://effect.network))

43 lines 1.42 kB
import { Asset } from "@wharfkit/antelope"; import { SessionNotFoundError } from "../../errors"; import { useEFXContracts } from "../../utils/state"; import { getVAccounts } from "./getAccounts"; export const vTransferAction = ({ client, to_id, from_id, quantity, }) => { if (!client.session) { throw new SessionNotFoundError("Session is required for this method."); } const { actor, authorization } = client.session; const { vaccount, token } = useEFXContracts(client); return { account: vaccount, name: "vtransfer", authorization, data: { from_id, to_id, quantity: { quantity: Asset.from(quantity, "4,EFX"), contract: token, }, memo: "", payer: actor, sig: null, fee: null, }, }; }; export const vTransfer = async ({ client, from_id, to_id, quantity, }) => { if (!client.session) { throw new SessionNotFoundError("Session is required for this method."); } const { transact, actor } = client.session; const [vaccount] = await getVAccounts({ client, actor }); const transferAction = vTransferAction({ client, to_id, from_id: from_id ?? vaccount.id, quantity, }); return await transact({ action: transferAction }); }; //# sourceMappingURL=transfer.js.map