0.28.0 • Published 2 years ago

@futureverse/asset-registry-sdk v0.28.0

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

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 (
    // Provide the client to your App
    <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

0.21.0

2 years ago

0.20.0

2 years ago

0.19.0

2 years ago

0.28.0

2 years ago

0.27.0

2 years ago

0.26.0

2 years ago

0.25.0

2 years ago

0.24.0

2 years ago

0.23.0

2 years ago

0.22.0

2 years ago

0.6.3

2 years ago

0.15.0

2 years ago

0.5.0

2 years ago

0.16.0

2 years ago

0.17.0

2 years ago

0.18.0

2 years ago

0.4.1

2 years ago

0.3.1

2 years ago