Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/webpack-5.94.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sneakzttv authored Dec 3, 2024
2 parents 479920f + f5f46d2 commit 822d671
Show file tree
Hide file tree
Showing 60 changed files with 1,259 additions and 1,964 deletions.
33 changes: 33 additions & 0 deletions dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
A1
A2
ABI
ABIs
Addons
addons
addon
Expand All @@ -18,7 +19,10 @@ analytics
async
APIs
AppStore
Appkit
AppKit
auth
abi-to-csharp-converter
AUTH
backend
BalanceOf
Expand All @@ -31,6 +35,7 @@ blockchain
Blockchain
blockchains
Blockchains
blockchain-events
BSC
BuyItemWebGL
BuyItemWebWallet
Expand All @@ -55,6 +60,8 @@ chainID
ChainId
chainsafe
ChainSafe
Chainsafe
Chainsafes
ChainSafe's
Chainstack
ChainID's
Expand All @@ -63,6 +70,7 @@ cheatsheet
CLI
Cloudflare
config
Config
contract-abi-to-json-format
contractAbi
convert-wei-to-eth-and-eth-to-wei
Expand All @@ -77,7 +85,9 @@ DApp
devs
dev
devsetup
dropdown
ECDSA
Erc20Contract
erc20NameOf
EVM-compatible
EVM-compatible
Expand Down Expand Up @@ -128,9 +138,11 @@ goerli
Goerli
goerli's
GasLimit
Gamers
getter
gamers
gameplay
GameObject
GitHub
github
Goerli's
Expand All @@ -146,6 +158,7 @@ Integrable
IRpcProvider
IOS
IDE
isLightweight
implementing-social-logins-to-webgl-builds
importing-nfts
infura
Expand Down Expand Up @@ -174,8 +187,11 @@ Mainnet
mainnets
mainnetgoerli
metamask
Majiick
MetaMask
Metamask
Multicall
MultiCall
multicall
minter-evm
minting-nft
Expand All @@ -188,18 +204,22 @@ NewtonSoft
newtonsoft
non-EVM
NFT
NFTS
NFTPixels
nft-textures
NFT's
NFTPixels
NFTs
nfts
nodeJS
NodeJS
npm
onboarding
OpenSea
OPM
openUPM
openupm-cli
OnDestroy
OpenUPM
prebuilt
preconfigured
Expand All @@ -210,12 +230,17 @@ Rinkeby
rpc
RPC
RPCs
Reown
reown
react-unity-webgl
SampleLoginMetamask
SampleMain
scalable
scrollable
SampleScene
scriptable
Scriptable
ScriptableObject
SDK
SDK.
SDK's
Expand All @@ -224,6 +249,7 @@ send-contract-through-webgl
send-transaction-through-webgl
sepolia
Sepolia
Sepolia's
sha3
SHA3
sign-through-webgl
Expand Down Expand Up @@ -261,6 +287,7 @@ TypeError
UI
Unity3D
uncomment
unsubscription
Uncomment
UnityEnvironment
UNPKG
Expand Down Expand Up @@ -300,8 +327,10 @@ web3auth
Web3GL
web3unity
Web3Unity
web3UnityInstance
web3authwallet
web3wallet
Web3Initialized
Web3Wallet
web3wallet-mobile-and-desktop
Web4GL-2020x
Expand All @@ -324,12 +353,16 @@ Web3AuthSigner
Web3Builder
WebGLWallet
WebPageWallet
WebSocket
WebSockets
WebAssembly
xdai
XDai
YourGame
Zenject
zkDungeon
localhost
Localhost
localhost:8000
https
Brotli
Expand Down
15 changes: 14 additions & 1 deletion docs/1_chainsafe-gaming.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,20 @@ Out-of-the-box, Web3.unity comes with Unity sample scripts, scenes, prefabs & to

## Ready To Get Started?

#### Current SDK Builds (v2.x)
#### Current SDK Builds (v3.x)

In the latest 3.0 we've significantly reduced the effort for developers to interact with the blockchain. Once you have the core package installed you can just drag and drop the Web3Unity prefab to the scene:

```csharp
public class ExampleClass : MonoBehaviour
{
public async void Start()
{
await Web3Unity.Instance.Initialize(false);
await Web3Unity.Web3.Erc20.BalanceOf("0xd25b827D92b0fd656A1c829933e9b0b836d5C3e2");
}
}
```

[Click here](https://docs.gaming.chainsafe.io/current/getting-started) to open documentation for the latest version of web3.unity.

Expand Down
3 changes: 3 additions & 0 deletions docs/marketplace-api/spec/components/item_token.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
type: object
description: token structure for the NFT
properties:
id:
type: string
description: id of token on indexer
token_id:
type: string
description: token id of nft
Expand Down
6 changes: 6 additions & 0 deletions docs/marketplace-api/spec/paths/get_project_items.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ get:
required: false
schema:
type: string
- name: seller
in: query
description: Seller Address
required: false
schema:
type: string
- name: status
in: query
description: Status of the item
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ get:
required: false
schema:
type: string
- name: seller
in: query
description: Seller Address
required: false
schema:
type: string
- name: status
in: query
description: Status of the item
Expand Down
151 changes: 147 additions & 4 deletions docs/nft_marketplace/2_tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,152 @@ Once you have created a marketplace, its time to list some NFTs for sale in the
![](./assets/list_nft.gif)



## 4. Launch Your Marketplace

Once you have listed NFTs for your marketplace, you can access your marketplace items via RESTful set of APIs provided by the ChainSafe.
## 4. Use marketplace inside of your Unity game
Add the Chainsafe marketplace package as a git package:
`https://github.com/ChainSafe/web3.unity.git?path=/Packages/io.chainsafe.web3-unity.marketplace`
Add Marketplace Service Adapter to the Web3Unity prefab

![](./assets/marketplace_sample.png)

Fill out the necessary details


![](./assets/marketplace_overview.png)


- Marketplace ID: Labeled as ID on the page of your marketplace.
- Marketplace contract address: Labeled as Address on the page of your marketplace.
- Project ID override: Override this value if you want to use a project ID that is different from the one that you have in your Chainsafe SDK settings.
- Marketplace ABI override: Override this if you have created a custom version of our marketplace smart contract.
- Endpoint override: Override this if you are hosting marketplace somewhere else other than on the Chainsafes dashboard.

Once you fill out all the details you can list the items from the marketplace by simply calling

```csharp
var marketplacePage = await Web3Unity.Web3.Marketplace().LoadPage();
```
This will retrieve you a marketplace page, and not all the items that you have listed, because marketplace supports pagination, so you can add pagination support on your Unity client as well.
The basic sample can be found in the Samples section of the Marketplace package, but for the sake of simplicity I'll add the listing code snippet in here.
```csharp
namespace ChainSafe.Gaming.Marketplace.Samples
{
public class MarketplaceSample : MonoBehaviour
{
[SerializeField] private Transform parentForItems;
[SerializeField] private UI_MarketplaceItem marketplaceItem;
[SerializeField] private Button nextPageButton;

private MarketplacePage _currentPage;
private async void Start()
{
//Always make sure to initialize the Web3Unity instance first.
await Web3Unity.Instance.Initialize(false);
try
{
LoadingOverlay.ShowLoadingOverlay();
//This gets all items from the marketplace
//LoadPage has a lot of parameters that you can fill out in order to filter out the results.
_currentPage = await Web3Unity.Web3.Marketplace().LoadPage();

nextPageButton.interactable = !string.IsNullOrEmpty(_currentPage.Cursor);

await DisplayItems();
}
catch (Exception e)
{
Debug.LogError("Caught an exception whilst loading the marketplace page " + e.Message);
}
finally
{
LoadingOverlay.HideLoadingOverlay();
}
}

private async Task DisplayItems()
{
for (int i = parentForItems.childCount - 1; i >= 0; i--)
{
Destroy(parentForItems.GetChild(i).gameObject);
}
//_currentPage.Items holds the reference to all the items fetched from the marketplace
foreach (var pageItem in _currentPage.Items)
{
var item = Instantiate(marketplaceItem, parentForItems);
await item.Initialize(pageItem);
}
}
}
}


//Monobehaviour that handles the display of the marketplace items.
public class UI_MarketplaceItem : MonoBehaviour
{
[SerializeField] private Image marketplaceItemImage;
[SerializeField] private TMP_Text type, itemId, itemPrice, itemStatus;
[SerializeField] private Button button;

private MarketplaceItem _marketplaceItemModel;

private static Dictionary<string, Sprite> _spritesDict = new();

public async Task Initialize(MarketplaceItem model)
{
_marketplaceItemModel = model;
button.interactable = model.Status == MarketplaceItemStatus.Listed;
itemStatus.text = model.Status == MarketplaceItemStatus.Listed ? "Purchase" : model.Status.ToString();
marketplaceItemImage.sprite = await GetSprite(model);
type.text = model.Token.Type;
itemId.text = "ID " + model.Token.Id;
itemPrice.text =
((decimal)BigInteger.Parse(model.Price) / (decimal)BigInteger.Pow(10, 18)).ToString("0.############",
CultureInfo.InvariantCulture) + Web3Unity.Web3.ChainConfig.Symbol;
button.onClick.AddListener(Purchase);
}

private async Task<Sprite> GetSprite(MarketplaceItem model)
{
Sprite sprite = null;
string imageUrl = (string)model.Token.Metadata["image"];
//Caching data for faster retreival of the sprites.
if (_spritesDict.TryGetValue(imageUrl, out sprite)) return sprite;

var unityWebRequest = UnityWebRequestTexture.GetTexture(imageUrl);
await unityWebRequest.SendWebRequest();
if (unityWebRequest.error != null)
{
Debug.LogError("There was an error getting the texture " + unityWebRequest.error);
return null;
}

var myTexture = ((DownloadHandlerTexture)unityWebRequest.downloadHandler).texture;

sprite = Sprite.Create(myTexture, new Rect(0, 0, myTexture.width, myTexture.height), Vector2.one * 0.5f);

return sprite;
}

private async void Purchase()
{
try
{
await Web3Unity.Web3.Marketplace().Purchase(_marketplaceItemModel.Id, _marketplaceItemModel.Price);
//After the purchase is sucsessfull, just make the button unresponsive and set the button indicator to Sold
button.interactable = false;
itemStatus.text = "Sold";
}
catch (ServiceNotBoundWeb3Exception<ISigner> _)
{
Debug.LogError("You wanted to purchase an item and you don't have a wallet. Please connect the wallet to make a purchase");
Web3Unity.ConnectModal.Open();
}
}
}

```

## 5. Use marketplace with the Rest API

If you prefer to access your items without our official Marketplace plugin, once you have listed NFTs for your marketplace, you can access your marketplace items via RESTful set of APIs provided by the ChainSafe.
Head over to the [Marketplace API Specification](./../marketplace-api/docs/marketplaceapi.mdx) to know more about how to interact with the marketplace items.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/token-api/spec/components/token_response.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
type: object
properties:
id:
type: string
description: ID of the token on the indexer
token_id:
type: string
description: Token ID
Expand Down
Loading

0 comments on commit 822d671

Please sign in to comment.