Hic et Nunc Wrapper

Hic et Nunc (HEN) is an NFT marketplace on Tezos

Queries

Import Plugins

#import { Query, Connection } into Tezos from "w3://ens/tezos.web3api.eth"

Response Types

Network

enum Network {
  custom
  mainnet
  ghostnet
}

Custom Connection

type CustomConnection {
  connection: Tezos_Connection!
  contractAddress: String!
}

Get Balance Response

type GetBalanceResponse {
  owner: String!
  token_id: String! 
  balance: String!
}

Get Token Metadata Response

type GetTokenMetadataResponse {
  token_id: String! 
  ipfs_hash: String!
}

Get Token Count Response

type GetTokenCountResponse {
  tokenCount: String! 
}

Get Swaps Response

type GetSwapsResponse {
  creator: String! 
  issuer: String!
  objkt_amount: String!
  objkt_id: String!
  royalties: String!
}

Query Functions

Get Balance Of

Read the number of NFTs of a specific token_id owned by an address

  getBalanceOf(
    network: Network!
    owner: String! 
    token_id: String! 
    custom: CustomConnection
  ): GetBalanceResponse!

Get Token Metadata

Read the IPFS metadata hash for one or multiple NFTs.

  getTokenMetadata(
    network: Network!
    token_id: String!
    custom: CustomConnection
  ): GetTokenMetadataResponse!

Get Token Count Data

Read the number of NFTs minted. This information is required when minting the next NFT since token_ids are sequential.

  getTokenCountData(
    network: Network!
    custom: CustomConnection
  ): GetTokenCountResponse!

Get Swaps Data

Read active sell offers.

  getSwapsData(
    network: Network!
    swap_id: String!
    custom: CustomConnection
  ): GetSwapsResponse!
}

Wrapper Example

The Harbinger wrapper can be found in the ./tezos/hicetnunc/wrapper folder.

To get it running, first remove these lines of code from the package.json file:

“@web3api/tezos-test-env”: “0.0.1-prealpha.61”, “@web3api/tezos-plugin-js”: “0.0.1-prealpha.61”,

Now, link the wrapper to Tezos-plugin-js and tezos-test-env:

yarn link @web3api/tezos-plugin-js
yarn link @web3api/tezos-test-env

Install the node packages and build plugin-js

yarn
yarn build

Running Tests

The e2e tests can be found in the src/tests/e2e folder. Run the e2e tests as follows:

yarn test

Project Structure

Queries

Can be found in the ./src/query folder containing the index.ts file which is the AssemblyScript mutation logic and schema.graphql file which contains the graphql schemas for the functions in the query's index file.

export function getBalanceOf(input: Input_getBalanceOf): GetBalanceResponse {
    if (input.network == Network.custom && input.custom === null) {
        throw new Error(`custom network should have a valid connection and contract address`);
    }
    const connectionDetails = getConnectionDetails(input.network, input.custom, false);
    const balance = Tezos_Query.getContractStorage({
        address: connectionDetails.contractAddress,
        connection: connectionDetails.connection,
        key: "ledger",
        field: '["' + input.owner + '",' + input.token_id + ']',
    });
    return {
        owner: input.owner,
        token_id: input.token_id,
        balance: balance
    };

Tests

To test the functions in query/index.ts, e2e tests are written in the __tests__/e2e folder.

it("should return balance", async () => {
    const response = await client.query < {
        getBalanceOf: QuerySchema.GetBalanceResponse
    } > ({
        uri: ensUri,
        query: `query {
	    getBalanceOf(
	    network: mainnet,
	    owner: $owner, 
	    token_id: $token_id)
		}`,
        variables: {
            owner: "tz1UBZUkXpKGhYsP5KtzDNqLLchwF4uHrGjw",
            token_id: "152",
        }
    })

    expect(response.errors).toBeUndefined()
    expect(response.data).toBeDefined()
    expect(response.data?.getBalanceOf).toBeDefined()
    expect(response.data?.getBalanceOf.owner).toBeDefined()
    expect(response.data?.getBalanceOf.token_id).toBeDefined()
    expect(response.data?.getBalanceOf.balance).toBeDefined()
})

Last updated