Skip to content

Commit c1211a2

Browse files
authored
Merge pull request #317 from KomodoPlatform/update/nft-methods
2 parents cd726bb + 450c9e4 commit c1211a2

File tree

17 files changed

+515
-112
lines changed

17 files changed

+515
-112
lines changed

filepathSlugs.json

+27-6
Original file line numberDiff line numberDiff line change
@@ -2020,6 +2020,7 @@
20202020
"tendermint-node",
20212021
"v2-1-0-current-release-2",
20222022
"v2-2-0-2",
2023+
"swap-v2-contracts",
20232024
"tokens-request",
20242025
"utxo-merge-params"
20252026
],
@@ -2071,12 +2072,14 @@
20712072
],
20722073
"src/pages/komodo-defi-framework/api/common_structures/nfts/index.mdx": [
20732074
"non-fungible-token-structures",
2075+
"nft-info-basic",
20742076
"nft-info",
20752077
"nft-filter",
20762078
"nft-transfer",
20772079
"nft-transfer-filter",
20782080
"nft-metadata",
2079-
"withdraw-nft-data"
2081+
"withdraw-nft-data",
2082+
"nft-provider"
20802083
],
20812084
"src/pages/komodo-defi-framework/api/common_structures/orders/index.mdx": [
20822085
"order-structures",
@@ -2783,14 +2786,19 @@
27832786
"response",
27842787
"request-with-get-balances-set-to-false",
27852788
"response-2",
2789+
"request-including-nft-initialization",
2790+
"response-3",
2791+
"error-responses",
27862792
"error-types",
27872793
"platform-is-already-activated-error",
27882794
"platform-config-is-not-found-error",
27892795
"coin-protocol-parse-error-error",
27902796
"unexpected-platform-protocol-error",
27912797
"token-config-is-not-found-error",
27922798
"token-protocol-parse-error-error",
2793-
"unexpected-token-protocol-error"
2799+
"unexpected-token-protocol-error",
2800+
"invalid-request-error",
2801+
"transport-error"
27942802
],
27952803
"src/pages/komodo-defi-framework/api/v20/enable_slp/index.mdx": [
27962804
"enable-slp",
@@ -3411,7 +3419,15 @@
34113419
"example-to-clear-binance-smart-chain-and-polygon-nft-data",
34123420
"example-to-clear-all-nft-data",
34133421
"error-responses",
3414-
"unsupported-chain-type"
3422+
"unsupported-chain-type",
3423+
"invalid-request"
3424+
],
3425+
"src/pages/komodo-defi-framework/api/v20-dev/non_fungible_tokens/enable_nft/index.mdx": [
3426+
"enable-nft",
3427+
"response",
3428+
"error-platform-coin-is-not-yet-activated",
3429+
"error-token-already-activated",
3430+
"error-token-config-not-found-in-coins-file"
34153431
],
34163432
"src/pages/komodo-defi-framework/api/v20-dev/non_fungible_tokens/get_nft_list/index.mdx": [
34173433
"get-a-list-of-nfts",
@@ -3439,7 +3455,8 @@
34393455
"src/pages/komodo-defi-framework/api/v20-dev/non_fungible_tokens/index.mdx": [
34403456
"non-fungible-tokens-nfts",
34413457
"nft-information-methods",
3442-
"nft-transaction-methods"
3458+
"nft-transaction-methods",
3459+
"nft-utility-methods"
34433460
],
34443461
"src/pages/komodo-defi-framework/api/v20-dev/non_fungible_tokens/query_nft_database_tables/index.mdx": [
34453462
"query-nft-database-tables",
@@ -3453,12 +3470,16 @@
34533470
"src/pages/komodo-defi-framework/api/v20-dev/non_fungible_tokens/refresh_nft_metadata/index.mdx": [
34543471
"refresh-nft-metadata",
34553472
"request-parameters",
3456-
"example"
3473+
"example",
3474+
"error-responses"
34573475
],
34583476
"src/pages/komodo-defi-framework/api/v20-dev/non_fungible_tokens/update_nft/index.mdx": [
34593477
"update-nft",
34603478
"request-parameters",
3461-
"example"
3479+
"example",
3480+
"error-types",
3481+
"token-is-already-activated",
3482+
"token-is-already-activated-2"
34623483
],
34633484
"src/pages/komodo-defi-framework/api/v20-dev/non_fungible_tokens/withdraw_nft/index.mdx": [
34643485
"withdraw-nfts",

src/data/sidebar.json

+4
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,10 @@
605605
"title": "Overview",
606606
"href": "/komodo-defi-framework/api/v20-dev/non_fungible_tokens/"
607607
},
608+
{
609+
"title": "Enable NFT",
610+
"href": "/komodo-defi-framework/api/v20-dev/non_fungible_tokens/enable_nft/"
611+
},
608612
{
609613
"title": "Clear NFT Database Tables",
610614
"href": "/komodo-defi-framework/api/v20-dev/non_fungible_tokens/clear_nft_db/"

src/pages/komodo-defi-framework/api/common_structures/activation/index.mdx

+20
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,26 @@ The `TendermintNode` object includes the following items for a given coin or tok
210210
```
211211
</CollapsibleSection>
212212

213+
### SwapV2Contracts
214+
215+
The `SwapV2Contracts` object includes the following items for a given coin or token:
216+
217+
| Parameter | Type | Description |
218+
| ------------------------------ | ------ | --------------------------------------------------------------------------------------------------------------------------------- |
219+
| maker\_swap\_v2\_contract | string | Address for the maker's new V2 swap smart contract. Must be provided if "use\_trading\_proto\_v2"is true in mm2 configuration |
220+
| taker\_swap\_v2\_contract | string | Address for the taker's new V2 swap smart contract. Must be provided if "use\_trading\_proto\_v2"is true in mm2 configuration |
221+
| nft\_maker\_swap\_v2\_contract | string | Address for the maker's new V2 NFT swap smart contract. Must be provided if "use\_trading\_proto\_v2"is true in mm2 configuration |
222+
223+
<CollapsibleSection expandedText="Hide Example" collapsedText="Show Example">
224+
```json
225+
{
226+
"maker_swap_v2_contract": "0x9130b257D37A52E52F21054c4DA3450c72f595CE",
227+
"taker_swap_v2_contract": "0x9130b257D37A52E52F21054c4DA3450c72f595CE",
228+
"nft_maker_swap_v2_contract": "0x9130b257D37A52E52F21054c4DA3450c72f595CE"
229+
}
230+
```
231+
</CollapsibleSection>
232+
213233
### TokensRequest
214234

215235
The `TokensRequest` object includes the following items for a given coin or token:

src/pages/komodo-defi-framework/api/common_structures/nfts/index.mdx

+35
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ export const description = "Starting with version beta-2.1.3434, the Komodo DeFi
55

66
The following structures are used in the Komodo DeFi SDK for non-fungible tokens (NFTs).
77

8+
### NftInfoBasic
9+
10+
The `NftInfoBasic` object includes the following items for a given token:
11+
12+
| Parameter | Type | Description |
13+
| -------------- | ------ | --------------------------------------------------------------------- |
14+
| amount | string | The amount of this NFT the user owns (used by `ERC1155`). |
15+
| chain | string | Chain name. One of `AVALANCHE`, `BSC`, `ETH`, `FANTOM`, or `POLYGON`. |
16+
| contract\_type | string | The type of NFT contract standard. One of `ERC721` or `ERC1155`. |
17+
| token\_address | string | The address of the NFT contract. |
18+
| token\_id | string | The token ID of the NFT. |
19+
820
### NftInfo
921

1022
The `NftInfo` object includes the following items for a given token:
@@ -197,3 +209,26 @@ The `WithdrawNftData` object is used for withdrawals of NFTs on ERC721 and ERC11
197209
Due to this difference, the `amount` and `max` fields are only used the when
198210
the `type` value is `withdraw_erc1155`.
199211
</Note>
212+
213+
### NftProvider
214+
215+
The `NftProvider` object is used in the 'enable\_nft' RPC method. It defines the NFT providers that are avaialable and their configuration.
216+
217+
| Parameter | Type | Description |
218+
| ------------------ | ------- | ---------------------------------------------------------------------------- |
219+
| type | string | Specifies the type of the provider. |
220+
| info | object | Additional information about the provider |
221+
| info.url | string | URL of the provider's endpoint |
222+
| info.komodo\_proxy | boolean | Optional. Indicates whether proxy authentication is enabled for the endpoint |
223+
224+
<CollapsibleSection expandedText="Hide Example" collapsedText="Show Example">
225+
```json
226+
{
227+
"type": "Moralis",
228+
"info": {
229+
"url": "https://moralis-proxy.komodo.earth",
230+
"komodo_proxy": true
231+
}
232+
}
233+
```
234+
</CollapsibleSection>

src/pages/komodo-defi-framework/api/index.mdx

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Below is a table of the currently available legacy, v2.0 and v2.0 (Dev) methods:
3232
| | [enable\_bch\_with\_tokens](/komodo-defi-framework/api/v20/enable_bch_with_tokens/#enable-bch-with-tokens) | |
3333
| | [enable\_erc20](/komodo-defi-framework/api/v20/enable_erc20/#enable-erc20) | |
3434
| | [enable\_eth\_with\_tokens](/komodo-defi-framework/api/v20/enable_eth_with_tokens/#enable-eth-with-tokens) | |
35+
| | | [enable\_nft](/komodo-defi-framework/api/v20-dev/non_fungible_tokens/enable_nft/#enable-nft) |
3536
| | [enable\_slp](/komodo-defi-framework/api/v20/enable_slp/#enable-slp) | |
3637
| | [enable\_tendermint\_token](/komodo-defi-framework/api/v20/enable_tendermint_token/#enable-tendermint-token) | |
3738
| | [enable\_tendermint\_with\_assets](/komodo-defi-framework/api/v20/enable_tendermint_with_assets/#enable-tendermint-with-assets) | |

src/pages/komodo-defi-framework/api/v20-dev/non_fungible_tokens/clear_nft_db/index.mdx

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export const title = "Komodo DeFi Framework Method: Non Fungible Tokens";
22
export const description =
3-
"This document describes the clear_nft_db method Komodo DeFi Framework provides to clear NFT data from your local database";
3+
"This document describes the clear_nft_db method Komodo DeFi Framework provides to clear NFT data from your local database";
44

55
# Clear NFT Database {{label : 'clear_nft_db', tag : 'API-v2'}}
66

@@ -88,3 +88,17 @@ Returned when the `chains` parameter contains an unsupported network.
8888
"id": null
8989
}
9090
```
91+
92+
#### InvalidRequest
93+
94+
Returned when neither the `chains` or `clear_all` parameters are present.
95+
96+
```json
97+
{
98+
"mmrpc":"2.0",
99+
"error":"Invalid request: Nothing to clear was specified","error_path":"nft","error_trace":"nft:1512]",
100+
"error_type":"InvalidRequest",
101+
"error_data":"Nothing to clear was specified",
102+
"id":null
103+
}
104+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
export const title = "Komodo DeFi Framework Method: Enable NFT";
2+
export const description =
3+
"The enable_nft method allows you to activate NFT-like tokens on the platform.";
4+
5+
# enable\_nft
6+
7+
The 'enable\_nft' method activates NFT-like tokens on the platform, if the NFT network was already activated with the [enable\_eth\_with\_tokens](/komodo-defi-framework/api/v20/enable_eth_with_tokens/) method, but without the `nft_req` parameter.
8+
9+
| parameter | Type | Description |
10+
| ------------------ | ------ | ------------------------------------------------------------------------------------------------ |
11+
| ticker | string | The ticker of the NFT network, with `NFT_` as a prefix. |
12+
| activation\_params | object | A standard [NftProvider](/komodo-defi-framework/api/common_structures/nfts/#nft-provider) object |
13+
14+
<CodeGroup title="" tag="POST" label="enable_nft" mm2MethodDecorate="true">
15+
```json
16+
{
17+
"userpass": "RPC_UserP@SSW0RD",
18+
"method": "enable_nft",
19+
"mmrpc": "2.0",
20+
"params": {
21+
"ticker": "NFT_MATIC",
22+
"activation_params": {
23+
"provider": {
24+
"type": "Moralis",
25+
"info": {
26+
"url": "https://moralis-proxy.komodo.earth",
27+
"komodo_proxy": true
28+
}
29+
}
30+
}
31+
}
32+
}
33+
```
34+
</CodeGroup>
35+
36+
## Response
37+
38+
```json
39+
{
40+
"mmrpc": "2.0",
41+
"result": {
42+
"nfts": {
43+
"0xc28a19e9a663d966cf99532bdb1229df1b0e344b,1": {
44+
"token_address": "0xc28a19e9a663d966cf99532bdb1229df1b0e344b",
45+
"token_id": "1",
46+
"chain": "POLYGON",
47+
"contract_type": "ERC1155",
48+
"amount": "1"
49+
},
50+
"0xd25f13e4ba534ef625c75b84934689194b7bd59e,14": {
51+
"token_address": "0xd25f13e4ba534ef625c75b84934689194b7bd59e",
52+
"token_id": "14",
53+
"chain": "POLYGON",
54+
"contract_type": "ERC721",
55+
"amount": "1"
56+
}
57+
},
58+
"platform_coin": "MATIC"
59+
},
60+
"id": null
61+
}
62+
```
63+
64+
## Error - Platform coin is not yet activated
65+
66+
```json
67+
{
68+
"mmrpc": "2.0",
69+
"error": "Platform coin MATIC is not activated",
70+
"error_path": "token.lp_coins",
71+
"error_trace": "token:126] lp_coins:2797]",
72+
"error_type": "PlatformCoinIsNotActivated",
73+
"error_data": "MATIC",
74+
"id": null
75+
}
76+
```
77+
78+
## Error - Token already activated
79+
80+
```json
81+
{
82+
"mmrpc": "2.0",
83+
"error": "Token NFT_MATIC is already activated",
84+
"error_path": "token",
85+
"error_trace": "token:119]",
86+
"error_type": "TokenIsAlreadyActivated",
87+
"error_data": "NFT_MATIC",
88+
"id": null
89+
}
90+
```
91+
92+
## Error - Token config not found in coins file
93+
94+
```json
95+
{
96+
"mmrpc": "2.0",
97+
"error": "Token NFT_TESTTT config is not found",
98+
"error_path": "token.prelude",
99+
"error_trace": "token:122] prelude:79]",
100+
"error_type": "TokenConfigIsNotFound",
101+
"error_data": "NFT_TESTTT",
102+
"id": null
103+
}
104+
```

src/pages/komodo-defi-framework/api/v20-dev/non_fungible_tokens/get_nft_list/index.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export const title = "Komodo DeFi Framework Method: Non Fungible Tokens - Get NFT List";
22
export const description =
3-
"This document describes all the get_nft_list method Komodo DeFi Framework provides to get a list of your wallets NFTs";
3+
"This document describes all the get_nft_list method Komodo DeFi Framework provides to get a list of your wallets NFTs";
44

55
# Get a list of NFTs {{label : 'get_nft_list', tag : 'API-v2'}}
66

src/pages/komodo-defi-framework/api/v20-dev/non_fungible_tokens/get_nft_metadata/index.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export const title = "Komodo DeFi Framework Method: Non Fungible Tokens";
22
export const description =
3-
"This document describes the get_nft_metadata method Komodo DeFi Framework provides to get metadata for your NFTs";
3+
"This document describes the get_nft_metadata method Komodo DeFi Framework provides to get metadata for your NFTs";
44

55
# Get NFT Metadata {{label : 'get_nft_metadata', tag : 'API-v2'}}
66

src/pages/komodo-defi-framework/api/v20-dev/non_fungible_tokens/get_nft_transfers/index.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export const title = "Komodo DeFi Framework Method: Non Fungible Tokens";
22
export const description =
3-
"This document describes the get_nft_transfers method Komodo DeFi Framework provides to get information about your NFT transactions";
3+
"This document describes the get_nft_transfers method Komodo DeFi Framework provides to get information about your NFT transactions";
44

55
# Get a list of NFT transfers {{label : 'get_nft_transfers', tag : 'API-v2'}}
66

src/pages/komodo-defi-framework/api/v20-dev/non_fungible_tokens/index.mdx

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
export const title = "Komodo DeFi Framework Method: Non Fungible Tokens";
22
export const description =
3-
"This document describes all the methods Komodo DeFi Framework provides to get information and transact with NFTs";
3+
"This document describes all the methods Komodo DeFi Framework provides to get information and transact with NFTs";
44

55
# Non Fungible Tokens (NFTs)
66

77
The Komodo DeFi Framework API supports [ERC1155](https://www.nftstandards.wtf/Standards/ERC1155+Multi+token) and [ERC721](https://www.nftstandards.wtf/Standards/ERC721+Non+Fungible+Standard) NFTs via the [Moralis API](https://docs.moralis.io/) on the Avalanche (AVAX), BNB Smart Chain (BNB), Ethereum (ETH), Fantom (FTM), Polygon (MATIC) networks.
88

9+
To interact with NFTs, you will first need to activate the coin for the network the NFT is on, and initialise NFT support for the network.
10+
This can be done with either the [enable\_eth\_with\_tokens](/komodo-defi-framework/api/v20/enable_eth_with_tokens/) method (if including the `nft_req` param) or the [enable\_nft](/komodo-defi-framework/api/v20-dev/non_fungible_tokens/enable_nft/) method (if the network is already activated without NFT support).
11+
912
<Note>
1013
Before using other NFT methods, you should first call the [update\_nft](/komodo-defi-framework/api/v20-dev/non_fungible_tokens/update_nft/)
1114
method to populate/refresh the local database.
@@ -24,6 +27,10 @@ The Komodo DeFi Framework API supports [ERC1155](https://www.nftstandards.wtf/St
2427
* Withdraw ERC721 tokens with [withdraw\_nft](/komodo-defi-framework/api/v20-dev/non_fungible_tokens/withdraw_nft/#erc-721-withdraw-example)
2528
* Withdraw ERC1155 tokens with [withdraw\_nft](/komodo-defi-framework/api/v20-dev/non_fungible_tokens/withdraw_nft/#erc-1155-withdraw-example)
2629

30+
## NFT Utility Methods
31+
32+
* Clear local NFT data with [clear\_nft\db](/komodo-defi-framework/api/v20-dev/non_fungible_tokens/clear_nft_db/)
33+
2734
<Note>
2835
View the source code at: [https://github.com/KomodoPlatform/komodo-defi-framework/blob/main/mm2src/coins/nft.rs](https://github.com/KomodoPlatform/komodo-defi-framework/blob/main/mm2src/coins/nft.rs)
2936
</Note>

0 commit comments

Comments
 (0)