slate/pages/_/experiences/send-address-filecoin.js
2020-09-11 16:19:48 -07:00

81 lines
2.2 KiB
JavaScript

import * as React from "react";
import * as System from "~/components/system";
import SystemPage from "~/components/system/SystemPage";
import ViewSourceLink from "~/components/system/ViewSourceLink";
import CodeBlock from "~/components/system/CodeBlock";
import { dispatchCustomEvent } from "~/common/custom-events";
const EXAMPLE_CODE = `import * as React from "react";
import { SendAddressFilecoin } from "slate-react-system";
import { createPow } from "@textile/powergate-client";
const PowerGate = createPow({ host: "https://grpcweb.slate.textile.io" });
class Example extends React.Component {
componentDidMount = async () => {
const FFS = await PowerGate.ffs.create();
const token = FFS.token ? FFS.token : null;
PowerGate.setToken(token);
this.setState({ token });
};
_handleSend = async ({ source, target, amount }) => {
const response = await PowerGate.ffs.sendFil(source, target, amount);
};
render() {
return <SendAddressFilecoin onSubmit={this._handleSend} />;
}
}
`;
export default class SystemPageSendAddressFilecoin extends React.Component {
_handleSubmit = ({ source, target, amount }) => {
dispatchCustomEvent({
name: "create-alert",
detail: {
alert: {
message: JSON.stringify({ source, target, amount }),
status: "INFO",
},
},
});
};
render() {
return (
<SystemPage
title="SDS: Send Address Filecoin"
description="..."
url="https://slate.host/_/experiences/send-address-filecoin"
>
<System.H1>
Send an Address Filecoin{" "}
<ViewSourceLink file="experiences/send-address-filecoin.js" />
</System.H1>
<br />
<br />
<System.P>
Here is an example of an experience for sending a filecoin address
filecoin using{" "}
<a target="_blank" href="https://github.com/textileio/powergate/">
Textile's Powergate
</a>
</System.P>
<br />
<br />
<System.SendAddressFilecoin onSubmit={this._handleSubmit} />
<br />
<br />
<br />
<System.H2>Code</System.H2>
<hr />
<br />
<CodeBlock>{EXAMPLE_CODE}</CodeBlock>
</SystemPage>
);
}
}