Skip to content

Commit 822d671

Browse files
authored
Merge branch 'main' into dependabot/npm_and_yarn/webpack-5.94.0
2 parents 479920f + f5f46d2 commit 822d671

File tree

60 files changed

+1259
-1964
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1259
-1964
lines changed

dictionary.txt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
A1
66
A2
77
ABI
8+
ABIs
89
Addons
910
addons
1011
addon
@@ -18,7 +19,10 @@ analytics
1819
async
1920
APIs
2021
AppStore
22+
Appkit
23+
AppKit
2124
auth
25+
abi-to-csharp-converter
2226
AUTH
2327
backend
2428
BalanceOf
@@ -31,6 +35,7 @@ blockchain
3135
Blockchain
3236
blockchains
3337
Blockchains
38+
blockchain-events
3439
BSC
3540
BuyItemWebGL
3641
BuyItemWebWallet
@@ -55,6 +60,8 @@ chainID
5560
ChainId
5661
chainsafe
5762
ChainSafe
63+
Chainsafe
64+
Chainsafes
5865
ChainSafe's
5966
Chainstack
6067
ChainID's
@@ -63,6 +70,7 @@ cheatsheet
6370
CLI
6471
Cloudflare
6572
config
73+
Config
6674
contract-abi-to-json-format
6775
contractAbi
6876
convert-wei-to-eth-and-eth-to-wei
@@ -77,7 +85,9 @@ DApp
7785
devs
7886
dev
7987
devsetup
88+
dropdown
8089
ECDSA
90+
Erc20Contract
8191
erc20NameOf
8292
EVM-compatible
8393
EVM-compatible
@@ -128,9 +138,11 @@ goerli
128138
Goerli
129139
goerli's
130140
GasLimit
141+
Gamers
131142
getter
132143
gamers
133144
gameplay
145+
GameObject
134146
GitHub
135147
github
136148
Goerli's
@@ -146,6 +158,7 @@ Integrable
146158
IRpcProvider
147159
IOS
148160
IDE
161+
isLightweight
149162
implementing-social-logins-to-webgl-builds
150163
importing-nfts
151164
infura
@@ -174,8 +187,11 @@ Mainnet
174187
mainnets
175188
mainnetgoerli
176189
metamask
190+
Majiick
177191
MetaMask
192+
Metamask
178193
Multicall
194+
MultiCall
179195
multicall
180196
minter-evm
181197
minting-nft
@@ -188,18 +204,22 @@ NewtonSoft
188204
newtonsoft
189205
non-EVM
190206
NFT
207+
NFTS
191208
NFTPixels
192209
nft-textures
193210
NFT's
194211
NFTPixels
195212
NFTs
213+
nfts
196214
nodeJS
197215
NodeJS
198216
npm
199217
onboarding
200218
OpenSea
201219
OPM
220+
openUPM
202221
openupm-cli
222+
OnDestroy
203223
OpenUPM
204224
prebuilt
205225
preconfigured
@@ -210,12 +230,17 @@ Rinkeby
210230
rpc
211231
RPC
212232
RPCs
233+
Reown
234+
reown
235+
react-unity-webgl
213236
SampleLoginMetamask
237+
SampleMain
214238
scalable
215239
scrollable
216240
SampleScene
217241
scriptable
218242
Scriptable
243+
ScriptableObject
219244
SDK
220245
SDK.
221246
SDK's
@@ -224,6 +249,7 @@ send-contract-through-webgl
224249
send-transaction-through-webgl
225250
sepolia
226251
Sepolia
252+
Sepolia's
227253
sha3
228254
SHA3
229255
sign-through-webgl
@@ -261,6 +287,7 @@ TypeError
261287
UI
262288
Unity3D
263289
uncomment
290+
unsubscription
264291
Uncomment
265292
UnityEnvironment
266293
UNPKG
@@ -300,8 +327,10 @@ web3auth
300327
Web3GL
301328
web3unity
302329
Web3Unity
330+
web3UnityInstance
303331
web3authwallet
304332
web3wallet
333+
Web3Initialized
305334
Web3Wallet
306335
web3wallet-mobile-and-desktop
307336
Web4GL-2020x
@@ -324,12 +353,16 @@ Web3AuthSigner
324353
Web3Builder
325354
WebGLWallet
326355
WebPageWallet
356+
WebSocket
357+
WebSockets
327358
WebAssembly
328359
xdai
329360
XDai
330361
YourGame
331362
Zenject
363+
zkDungeon
332364
localhost
365+
Localhost
333366
localhost:8000
334367
https
335368
Brotli

docs/1_chainsafe-gaming.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,20 @@ Out-of-the-box, Web3.unity comes with Unity sample scripts, scenes, prefabs & to
3434

3535
## Ready To Get Started?
3636

37-
#### Current SDK Builds (v2.x)
37+
#### Current SDK Builds (v3.x)
38+
39+
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:
40+
41+
```csharp
42+
public class ExampleClass : MonoBehaviour
43+
{
44+
public async void Start()
45+
{
46+
await Web3Unity.Instance.Initialize(false);
47+
await Web3Unity.Web3.Erc20.BalanceOf("0xd25b827D92b0fd656A1c829933e9b0b836d5C3e2");
48+
}
49+
}
50+
```
3851

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

docs/marketplace-api/spec/components/item_token.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
type: object
22
description: token structure for the NFT
33
properties:
4+
id:
5+
type: string
6+
description: id of token on indexer
47
token_id:
58
type: string
69
description: token id of nft

docs/marketplace-api/spec/paths/get_project_items.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ get:
3030
required: false
3131
schema:
3232
type: string
33+
- name: seller
34+
in: query
35+
description: Seller Address
36+
required: false
37+
schema:
38+
type: string
3339
- name: status
3440
in: query
3541
description: Status of the item

docs/marketplace-api/spec/paths/get_project_marketplace_items.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ get:
3030
required: false
3131
schema:
3232
type: string
33+
- name: seller
34+
in: query
35+
description: Seller Address
36+
required: false
37+
schema:
38+
type: string
3339
- name: status
3440
in: query
3541
description: Status of the item

docs/nft_marketplace/2_tutorial.md

Lines changed: 147 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,152 @@ Once you have created a marketplace, its time to list some NFTs for sale in the
7171
![](./assets/list_nft.gif)
7272

7373

74-
75-
## 4. Launch Your Marketplace
76-
77-
Once you have listed NFTs for your marketplace, you can access your marketplace items via RESTful set of APIs provided by the ChainSafe.
74+
## 4. Use marketplace inside of your Unity game
75+
Add the Chainsafe marketplace package as a git package:
76+
`https://github.com/ChainSafe/web3.unity.git?path=/Packages/io.chainsafe.web3-unity.marketplace`
77+
Add Marketplace Service Adapter to the Web3Unity prefab
78+
79+
![](./assets/marketplace_sample.png)
80+
81+
Fill out the necessary details
82+
83+
84+
![](./assets/marketplace_overview.png)
85+
86+
87+
- Marketplace ID: Labeled as ID on the page of your marketplace.
88+
- Marketplace contract address: Labeled as Address on the page of your marketplace.
89+
- 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.
90+
- Marketplace ABI override: Override this if you have created a custom version of our marketplace smart contract.
91+
- Endpoint override: Override this if you are hosting marketplace somewhere else other than on the Chainsafes dashboard.
92+
93+
Once you fill out all the details you can list the items from the marketplace by simply calling
94+
95+
```csharp
96+
var marketplacePage = await Web3Unity.Web3.Marketplace().LoadPage();
97+
```
98+
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.
99+
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.
100+
```csharp
101+
namespace ChainSafe.Gaming.Marketplace.Samples
102+
{
103+
public class MarketplaceSample : MonoBehaviour
104+
{
105+
[SerializeField] private Transform parentForItems;
106+
[SerializeField] private UI_MarketplaceItem marketplaceItem;
107+
[SerializeField] private Button nextPageButton;
108+
109+
private MarketplacePage _currentPage;
110+
private async void Start()
111+
{
112+
//Always make sure to initialize the Web3Unity instance first.
113+
await Web3Unity.Instance.Initialize(false);
114+
try
115+
{
116+
LoadingOverlay.ShowLoadingOverlay();
117+
//This gets all items from the marketplace
118+
//LoadPage has a lot of parameters that you can fill out in order to filter out the results.
119+
_currentPage = await Web3Unity.Web3.Marketplace().LoadPage();
120+
121+
nextPageButton.interactable = !string.IsNullOrEmpty(_currentPage.Cursor);
122+
123+
await DisplayItems();
124+
}
125+
catch (Exception e)
126+
{
127+
Debug.LogError("Caught an exception whilst loading the marketplace page " + e.Message);
128+
}
129+
finally
130+
{
131+
LoadingOverlay.HideLoadingOverlay();
132+
}
133+
}
134+
135+
private async Task DisplayItems()
136+
{
137+
for (int i = parentForItems.childCount - 1; i >= 0; i--)
138+
{
139+
Destroy(parentForItems.GetChild(i).gameObject);
140+
}
141+
//_currentPage.Items holds the reference to all the items fetched from the marketplace
142+
foreach (var pageItem in _currentPage.Items)
143+
{
144+
var item = Instantiate(marketplaceItem, parentForItems);
145+
await item.Initialize(pageItem);
146+
}
147+
}
148+
}
149+
}
150+
151+
152+
//Monobehaviour that handles the display of the marketplace items.
153+
public class UI_MarketplaceItem : MonoBehaviour
154+
{
155+
[SerializeField] private Image marketplaceItemImage;
156+
[SerializeField] private TMP_Text type, itemId, itemPrice, itemStatus;
157+
[SerializeField] private Button button;
158+
159+
private MarketplaceItem _marketplaceItemModel;
160+
161+
private static Dictionary<string, Sprite> _spritesDict = new();
162+
163+
public async Task Initialize(MarketplaceItem model)
164+
{
165+
_marketplaceItemModel = model;
166+
button.interactable = model.Status == MarketplaceItemStatus.Listed;
167+
itemStatus.text = model.Status == MarketplaceItemStatus.Listed ? "Purchase" : model.Status.ToString();
168+
marketplaceItemImage.sprite = await GetSprite(model);
169+
type.text = model.Token.Type;
170+
itemId.text = "ID " + model.Token.Id;
171+
itemPrice.text =
172+
((decimal)BigInteger.Parse(model.Price) / (decimal)BigInteger.Pow(10, 18)).ToString("0.############",
173+
CultureInfo.InvariantCulture) + Web3Unity.Web3.ChainConfig.Symbol;
174+
button.onClick.AddListener(Purchase);
175+
}
176+
177+
private async Task<Sprite> GetSprite(MarketplaceItem model)
178+
{
179+
Sprite sprite = null;
180+
string imageUrl = (string)model.Token.Metadata["image"];
181+
//Caching data for faster retreival of the sprites.
182+
if (_spritesDict.TryGetValue(imageUrl, out sprite)) return sprite;
183+
184+
var unityWebRequest = UnityWebRequestTexture.GetTexture(imageUrl);
185+
await unityWebRequest.SendWebRequest();
186+
if (unityWebRequest.error != null)
187+
{
188+
Debug.LogError("There was an error getting the texture " + unityWebRequest.error);
189+
return null;
190+
}
191+
192+
var myTexture = ((DownloadHandlerTexture)unityWebRequest.downloadHandler).texture;
193+
194+
sprite = Sprite.Create(myTexture, new Rect(0, 0, myTexture.width, myTexture.height), Vector2.one * 0.5f);
195+
196+
return sprite;
197+
}
198+
199+
private async void Purchase()
200+
{
201+
try
202+
{
203+
await Web3Unity.Web3.Marketplace().Purchase(_marketplaceItemModel.Id, _marketplaceItemModel.Price);
204+
//After the purchase is sucsessfull, just make the button unresponsive and set the button indicator to Sold
205+
button.interactable = false;
206+
itemStatus.text = "Sold";
207+
}
208+
catch (ServiceNotBoundWeb3Exception<ISigner> _)
209+
{
210+
Debug.LogError("You wanted to purchase an item and you don't have a wallet. Please connect the wallet to make a purchase");
211+
Web3Unity.ConnectModal.Open();
212+
}
213+
}
214+
}
215+
216+
```
217+
218+
## 5. Use marketplace with the Rest API
219+
220+
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.
78221
Head over to the [Marketplace API Specification](./../marketplace-api/docs/marketplaceapi.mdx) to know more about how to interact with the marketplace items.
79222

112 KB
Loading
187 KB
Loading

docs/token-api/spec/components/token_response.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
type: object
22
properties:
3+
id:
4+
type: string
5+
description: ID of the token on the indexer
36
token_id:
47
type: string
58
description: Token ID

0 commit comments

Comments
 (0)