import * as React from "react"; import * as System from "~/components/system"; import * as Constants from "~/common/constants"; import Group from "~/components/system/Group"; import SystemPage from "~/components/system/SystemPage"; import ViewSourceLink from "~/components/system/ViewSourceLink"; import { createPow, ffsOptions } from "@textile/powergate-client"; const PowerGate = createPow({ host: "http://pow.slate.textile.io:6002" }); const EXAMPLE_CODE = `import * as React from 'react'; import { FilecoinDealsList } from 'slate-react-system'; import { createPow, ffsOptions } from "@textile/powergate-client"; const PowerGate = createPow({ host: "http://pow.slate.textile.io:6002" }); class Example extends React.Component { componentDidMount = async () => { const FFS = await PowerGate.ffs.create(); const token = FFS.token ? FFS.token : null; PowerGate.setToken(token); this.recordsList = await PowerGate.ffs.listStorageDealRecords( ffsOptions.withIncludeFinal(true), ffsOptions.withIncludePending(true) ); } render() { return ( ); } } `; export default class SystemPageStorageDeals extends React.Component { render() { const recordsList = [ { addr: "t3solnyrrblqlmvi6gmzewzvu62vs7uqvkl22yemzr63bcylbaaqsg44mnipepuafg7efzzx4zwcsi66jgze3q", dealInfo: { activationEpoch: 0, dealId: 0, duration: 1000, miner: "t0101180", msg: "", pieceCid: "b", pricePerEpoch: 1220, proposalCid: "bafyreifvjnupitsw3zwykymlnuruqqpyxhmpm5xo6cf72e7hdxscqistea", size: 0, startEpoch: 0, stateId: 0, stateName: "", }, pending: true, rootCid: "QmctRftYBfbWAtfz9svcprTnmah4eFJXdAUuBhAA6Z6c84", time: 1594960648, }, { addr: "t3solnyrrblqlmvi6gmzewzvu62vs7uqvkl22yemzr63bcylbaaqsg44mnipepuafg7efzzx4zwcsi66jgze3q", dealInfo: { activationEpoch: 0, dealId: 0, duration: 1000, miner: "t0101180", msg: "", pieceCid: "b", pricePerEpoch: 4882, proposalCid: "bafyreihej2ejt32ackx5h6n5vfgdjulya6lqtvhim22scnxbnw2kf3f6bm", size: 0, startEpoch: 0, stateId: 0, stateName: "", }, pending: true, rootCid: "QmUXsfqC1bHbZyD7T341rBXQCfDxA8UaiAmziHcwRRZHsQ", time: 1594960738, }, ]; return ( View Storage and Retrieval Deals{" "}

Here is an example of an experience for getting Filecoin Storage deals from{" "} Textile's Powergate .



Code

You must specify at least one of{" "} withIncludeFinal(true) and{" "} withIncludePending(true) to ensure you get a response. Other optional{" "} ffsOptions that can be used to specify what data you get back are noted in the table below.
To use the component for retrieval deals, simply pass in the data from{" "} listRetrievalDealRecords instead of{" "} listStorageDealRecords.

{EXAMPLE_CODE}

Accepted Options Properties

To specify what type of data you get back from{" "} listStorageDealRecords and{" "} listRetrievalDealRecords, you must pass in a destructured list of the below{" "} ffsOption functions. Each of the{" "} ffsOption functions take a parameter of their own, whose type is specified in the table below.

withIncludeFinal ), b: "boolean", c: "false", d: "Specifies whether or not to include final deals in the results. Ignored for listRetrievalDealRecords", }, { id: 2, a: ( withIncludePending ), b: "boolean", c: "false", d: "Specifies whether or not to include pending deals in the results. Ignored for listRetrievalDealRecords", }, { id: 3, a: "withDataCids", b: "...string[]", c: "null", d: "Limits the results to deals for the provided data cids", }, { id: 4, a: "withFromAddresses", b: "...string[]", c: "null", d: "Limits the results to deals initiated from the provided wallet addresses", }, { id: 5, a: "withAscending", b: "boolean", c: "false", d: "Specifies to sort the results in ascending order", }, ], }} />
); } }