UNPKG

@effectai/sdk

Version:

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

33 lines 1.06 kB
import { UInt128 } from "@wharfkit/antelope"; import { getIpfsResource } from "../../ipfs/getIpfsResource"; export const getCampaigns = async ({ client, page = 1, limit = 20, reverse = false, ipfsFetch = true, }) => { const { contracts } = client.network.config.efx; const provider = client.provider; const rows = []; const lowerBound = UInt128.from((page - 1) * limit); const response = (await provider.v1.chain.get_table_rows({ key_type: "i128", code: contracts.tasks, table: "campaign", scope: contracts.tasks, lower_bound: lowerBound, limit, reverse, })); for (const row of response.rows) { const campaign = row; if (ipfsFetch) { campaign.info = (await getIpfsResource({ client, hash: campaign.content.field_1, })); } rows.push(campaign); } return { rows, next_key: response.next_key, more: response.more, }; }; //# sourceMappingURL=getCampaigns.js.map