UNPKG

@effectai/sdk

Version:

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

40 lines 1.29 kB
import { Asset } from "@wharfkit/antelope"; import { SessionNotFoundError } from "../../errors"; import { useEFXContracts } from "../../utils/state"; export const depositAction = ({ client, amount, vAccountId, }) => { if (!client.session) { throw new SessionNotFoundError("Session is required for this method."); } const { actor, authorization } = client.session; const { token, vaccount } = useEFXContracts(client); if (!vAccountId) { throw new Error("No vAccount ID provided."); } return { account: token, name: "transfer", authorization, data: { from: actor, to: vaccount, quantity: Asset.from(amount, "4,EFX"), memo: `${vAccountId}`, }, }; }; export const deposit = async ({ client, vAccountId, amount }) => { try { if (!client.session) { throw new SessionNotFoundError("Session is required for this method."); } const { transact } = client.session; return await transact({ action: depositAction({ client, vAccountId, amount }), }); } catch (error) { console.error(error); throw new Error("Error depositing EFX"); } }; //# sourceMappingURL=deposit.js.map