Futureverse Asset Registry SDK
Installation
NPM:
npm install @futureverse/asset-registry-sdk --save
Yarn:
yarn add @futureverse/asset-registry-sdk
Usage
import {
AssetRegistryClientProvider,
Namespace,
useCreateShaclSchema,
} from './index'
import { render } from 'react-dom'
import { ethers } from 'ethers'
const ASSET_REGISTRY_ENDPOINT = 'http://localhost:4000/graphql'
const APP_DOMAIN = 'com.fv.app'
const WALLET_PRIVATE_KEY = ''
function App() {
return (
<AssetRegistryClientProvider
url={ASSET_REGISTRY_ENDPOINT}
domain={APP_DOMAIN}
chainId={1}
>
<CreateShaclSchemaComponent />
</AssetRegistryClientProvider>
)
}
function CreateShaclSchemaComponent() {
const wallet = new ethers.Wallet(WALLET_PRIVATE_KEY ?? '')
const origin = 'http://localhost:3000'
const id = 'foo'
const version = 1
const namespace = 'com.fv.schemas' as Namespace
const schema = '{}'
const mutation = useCreateShaclSchema({
wallet,
schema,
version,
origin,
namespace,
})
return (
<div>
{mutation.isLoading ? (
'Adding Shacl Schema...'
) : (
<>
{mutation.isError ? (
<div>An error occurred: {mutation.error as string}</div>
) : null}
{mutation.isSuccess ? <div>Shacl Schema added!</div> : null}
<button onClick={() => mutation.mutate()}>Create Shacl Schema</button>
</>
)}
</div>
)
}
render(<App />, document.getElementById('root'))
Requirements