Skip to content

Commit

Permalink
Make BlobContent into enum
Browse files Browse the repository at this point in the history
  • Loading branch information
ndr-ds committed Sep 26, 2024
1 parent b75b3ed commit c5544c7
Show file tree
Hide file tree
Showing 27 changed files with 340 additions and 411 deletions.
10 changes: 6 additions & 4 deletions examples/non-fungible/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,15 @@ Type each of these in the GraphiQL interface and substitute the env variables wi
mutation {
publishDataBlob(
chainId: "$CHAIN_1",
blobContent: {
bytes: [1, 2, 3, 4]
}
bytes: [1, 2, 3, 4]
)
}
```

```bash
BLOB_HASH=$(echo "$QUERY_RESULT" | jq -r '.publishDataBlob')
```

- Navigate to `http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID`.
- To mint an NFT, run the mutation:

Expand All @@ -108,7 +110,7 @@ Type each of these in the GraphiQL interface and substitute the env variables wi
mint(
minter: "User:$OWNER_1",
name: "nft1",
blobHash: "34a20da0fdd7e24ddbff60cb7f952b053b3f0e196e622d47c3a368f690f01326",
blobHash: "$BLOB_HASH",
)
}
```
Expand Down
10 changes: 6 additions & 4 deletions examples/non-fungible/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,15 @@ Type each of these in the GraphiQL interface and substitute the env variables wi
mutation {
publishDataBlob(
chainId: "$CHAIN_1",
blobContent: {
bytes: [1, 2, 3, 4]
}
bytes: [1, 2, 3, 4]
)
}
```
```bash
BLOB_HASH=$(echo "$QUERY_RESULT" | jq -r '.publishDataBlob')
```
- Navigate to `http://localhost:8080/chains/$CHAIN_1/applications/$APP_ID`.
- To mint an NFT, run the mutation:
Expand All @@ -112,7 +114,7 @@ Type each of these in the GraphiQL interface and substitute the env variables wi
mint(
minter: "User:$OWNER_1",
name: "nft1",
blobHash: "34a20da0fdd7e24ddbff60cb7f952b053b3f0e196e622d47c3a368f690f01326",
blobHash: "$BLOB_HASH",
)
}
```
Expand Down
40 changes: 19 additions & 21 deletions examples/non-fungible/web-frontend/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ const MINT_NFT = gql`
`;

const PUBLISH_DATA_BLOB = gql`
mutation PublishDataBlob($chainId: ChainId!, $blobContent: BlobContent!) {
publishDataBlob(chainId: $chainId, blobContent: $blobContent)
mutation PublishDataBlob($chainId: ChainId!, $bytes: [Int!]!) {
publishDataBlob(chainId: $chainId, bytes: $bytes)
}
`;

Expand Down Expand Up @@ -186,9 +186,7 @@ function App({ chainId, owner }) {
publishDataBlob({
variables: {
chainId: chainId,
blobContent: {
bytes: Array.from(byteArrayFile),
},
bytes: Array.from(byteArrayFile),
},
}).then((r) => {
if ('errors' in r) {
Expand All @@ -197,7 +195,7 @@ function App({ chainId, owner }) {
);
} else {
console.log('Data Blob published: ' + JSON.stringify(r, null, 2));
const blobHash = r['data']['publishDataBlob']['hash'];
const blobHash = r['data']['publishDataBlob'];
mintNft({
variables: {
minter: `User:${owner}`,
Expand Down Expand Up @@ -380,21 +378,21 @@ function App({ chainId, owner }) {
dataSource={
ownedNftsData
? Object.entries(ownedNftsData.ownedNfts).map(
([token_id, nft]) => {
const decoder = new TextDecoder();
const deserializedImage = decoder.decode(
new Uint8Array(nft.payload)
);

return {
key: token_id,
token_id: token_id,
name: nft.name,
minter: nft.minter,
payload: deserializedImage,
};
}
)
([token_id, nft]) => {
const decoder = new TextDecoder();
const deserializedImage = decoder.decode(
new Uint8Array(nft.payload)
);

return {
key: token_id,
token_id: token_id,
name: nft.name,
minter: nft.minter,
payload: deserializedImage,
};
}
)
: []
}
/>
Expand Down
Loading

0 comments on commit c5544c7

Please sign in to comment.