Skip to content

Commit

Permalink
Merge 9720faa into 756da8b
Browse files Browse the repository at this point in the history
  • Loading branch information
smk762 authored Oct 30, 2024
2 parents 756da8b + 9720faa commit 9a20ff4
Show file tree
Hide file tree
Showing 18 changed files with 4,132 additions and 803 deletions.
33 changes: 27 additions & 6 deletions filepathSlugs.json
Original file line number Diff line number Diff line change
Expand Up @@ -2015,6 +2015,7 @@
"coin-protocol",
"coin-protocol-data",
"evm-node",
"swap-v2-contracts",
"tokens-request",
"utxo-merge-params"
],
Expand Down Expand Up @@ -2066,12 +2067,14 @@
],
"src/pages/komodo-defi-framework/api/common_structures/nfts/index.mdx": [
"non-fungible-token-structures",
"nft-info-basic",
"nft-info",
"nft-filter",
"nft-transfer",
"nft-transfer-filter",
"nft-metadata",
"withdraw-nft-data"
"withdraw-nft-data",
"nft-provider"
],
"src/pages/komodo-defi-framework/api/common_structures/orders/index.mdx": [
"order-structures",
Expand Down Expand Up @@ -2775,14 +2778,19 @@
"response",
"request-with-get-balances-set-to-false",
"response-2",
"request-including-nft-initialization",
"response-3",
"error-responses",
"error-types",
"platform-is-already-activated-error",
"platform-config-is-not-found-error",
"coin-protocol-parse-error-error",
"unexpected-platform-protocol-error",
"token-config-is-not-found-error",
"token-protocol-parse-error-error",
"unexpected-token-protocol-error"
"unexpected-token-protocol-error",
"invalid-request-error",
"transport-error"
],
"src/pages/komodo-defi-framework/api/v20/enable_slp/index.mdx": [
"enable-slp",
Expand Down Expand Up @@ -3335,7 +3343,15 @@
"example-to-clear-binance-smart-chain-and-polygon-nft-data",
"example-to-clear-all-nft-data",
"error-responses",
"unsupported-chain-type"
"unsupported-chain-type",
"invalid-request"
],
"src/pages/komodo-defi-framework/api/v20-dev/non_fungible_tokens/enable_nft/index.mdx": [
"enable-nft",
"response",
"error-platform-coin-is-not-yet-activated",
"error-token-already-activated",
"error-token-config-not-found-in-coins-file"
],
"src/pages/komodo-defi-framework/api/v20-dev/non_fungible_tokens/get_nft_list/index.mdx": [
"get-a-list-of-nfts",
Expand Down Expand Up @@ -3363,7 +3379,8 @@
"src/pages/komodo-defi-framework/api/v20-dev/non_fungible_tokens/index.mdx": [
"non-fungible-tokens-nfts",
"nft-information-methods",
"nft-transaction-methods"
"nft-transaction-methods",
"nft-utility-methods"
],
"src/pages/komodo-defi-framework/api/v20-dev/non_fungible_tokens/query_nft_database_tables/index.mdx": [
"query-nft-database-tables",
Expand All @@ -3377,12 +3394,16 @@
"src/pages/komodo-defi-framework/api/v20-dev/non_fungible_tokens/refresh_nft_metadata/index.mdx": [
"refresh-nft-metadata",
"request-parameters",
"example"
"example",
"error-responses"
],
"src/pages/komodo-defi-framework/api/v20-dev/non_fungible_tokens/update_nft/index.mdx": [
"update-nft",
"request-parameters",
"example"
"example",
"error-types",
"token-is-already-activated",
"token-is-already-activated-2"
],
"src/pages/komodo-defi-framework/api/v20-dev/non_fungible_tokens/withdraw_nft/index.mdx": [
"withdraw-nfts",
Expand Down
4,305 changes: 3,614 additions & 691 deletions postman/collections/komodo_defi.postman_collection.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/data/sidebar.json
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,10 @@
"title": "Overview",
"href": "/komodo-defi-framework/api/v20-dev/non_fungible_tokens/"
},
{
"title": "Enable NFT",
"href": "/komodo-defi-framework/api/v20-dev/non_fungible_tokens/enable_nft/"
},
{
"title": "Clear NFT Database Tables",
"href": "/komodo-defi-framework/api/v20-dev/non_fungible_tokens/clear_nft_db/"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,26 @@ The `EvmNode` object includes the following items for a given coin or token:
```
</CollapsibleSection>

### SwapV2Contracts

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

| Parameter | Type | Description |
| ------------------------------ | ------ | --------------------------------------------------------------------------------------------------------------------------------- |
| 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 |
| 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 |
| 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 |

<CollapsibleSection expandedText="Hide Example" collapsedText="Show Example">
```json
{
"maker_swap_v2_contract": "0x9130b257D37A52E52F21054c4DA3450c72f595CE",
"taker_swap_v2_contract": "0x9130b257D37A52E52F21054c4DA3450c72f595CE",
"nft_maker_swap_v2_contract": "0x9130b257D37A52E52F21054c4DA3450c72f595CE"
}
```
</CollapsibleSection>

### TokensRequest

The `TokensRequest` object includes the following items for a given coin or token:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ export const description = "Starting with version beta-2.1.3434, the Komodo DeFi

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

### NftInfoBasic

The `NftInfoBasic` object includes the following items for a given token:

| Parameter | Type | Description |
| -------------- | ------ | --------------------------------------------------------------------- |
| amount | string | The amount of this NFT the user owns (used by `ERC1155`). |
| chain | string | Chain name. One of `AVALANCHE`, `BSC`, `ETH`, `FANTOM`, or `POLYGON`. |
| contract\_type | string | The type of NFT contract standard. One of `ERC721` or `ERC1155`. |
| token\_address | string | The address of the NFT contract. |
| token\_id | string | The token ID of the NFT. |

### NftInfo

The `NftInfo` object includes the following items for a given token:
Expand Down Expand Up @@ -197,3 +209,26 @@ The `WithdrawNftData` object is used for withdrawals of NFTs on ERC721 and ERC11
Due to this difference, the `amount` and `max` fields are only used the when
the `type` value is `withdraw_erc1155`.
</Note>

### NftProvider

The `NftProvider` object is used in the 'enable\_nft' RPC method. It defines the NFT providers that are avaialable and their configuration.

| Parameter | Type | Description |
| ------------------ | ------- | ---------------------------------------------------------------------------- |
| type | string | Specifies the type of the provider. |
| info | object | Additional information about the provider |
| info.url | string | URL of the provider's endpoint |
| info.komodo\_proxy | boolean | Optional. Indicates whether proxy authentication is enabled for the endpoint |

<CollapsibleSection expandedText="Hide Example" collapsedText="Show Example">
```json
{
"type": "Moralis",
"info": {
"url": "https://moralis-proxy.komodo.earth",
"komodo_proxy": true
}
}
```
</CollapsibleSection>
1 change: 1 addition & 0 deletions src/pages/komodo-defi-framework/api/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Below is a table of the currently available legacy, v2.0 and v2.0 (Dev) methods:
| | [enable\_bch\_with\_tokens](/komodo-defi-framework/api/v20/enable_bch_with_tokens/#enable-bch-with-tokens) | |
| | [enable\_erc20](/komodo-defi-framework/api/v20/enable_erc20/#enable-erc20) | |
| | [enable\_eth\_with\_tokens](/komodo-defi-framework/api/v20/enable_eth_with_tokens/#enable-eth-with-tokens) | |
| | | [enable\_nft](/komodo-defi-framework/api/v20-dev/non_fungible_tokens/enable_nft/#enable-nft) |
| | [enable\_slp](/komodo-defi-framework/api/v20/enable_slp/#enable-slp) | |
| | [enable\_tendermint\_token](/komodo-defi-framework/api/v20/enable_tendermint_token/#enable-tendermint-token) | |
| | [enable\_tendermint\_with\_assets](/komodo-defi-framework/api/v20/enable_tendermint_with_assets/#enable-tendermint-with-assets) | |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const title = "Komodo DeFi Framework Method: Non Fungible Tokens";
export const description =
"This document describes the clear_nft_db method Komodo DeFi Framework provides to clear NFT data from your local database";
"This document describes the clear_nft_db method Komodo DeFi Framework provides to clear NFT data from your local database";

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

Expand Down Expand Up @@ -88,3 +88,17 @@ Returned when the `chains` parameter contains an unsupported network.
"id": null
}
```

#### InvalidRequest

Returned when neither the `chains` or `clear_all` parameters are present.

```json
{
"mmrpc":"2.0",
"error":"Invalid request: Nothing to clear was specified","error_path":"nft","error_trace":"nft:1512]",
"error_type":"InvalidRequest",
"error_data":"Nothing to clear was specified",
"id":null
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
export const title = "Komodo DeFi Framework Method: Enable NFT";
export const description =
"The enable_nft method allows you to activate NFT-like tokens on the platform.";

# enable\_nft

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.

| parameter | Type | Description |
| ------------------ | ------ | ------------------------------------------------------------------------------------------------ |
| ticker | string | The ticker of the NFT network, with `NFT_` as a prefix. |
| activation\_params | object | A standard [NftProvider](/komodo-defi-framework/api/common_structures/nfts/#nft-provider) object |

<CodeGroup title="" tag="POST" label="enable_nft" mm2MethodDecorate="true">
```json
{
"userpass": "RPC_UserP@SSW0RD",
"method": "enable_nft",
"mmrpc": "2.0",
"params": {
"ticker": "NFT_MATIC",
"activation_params": {
"provider": {
"type": "Moralis",
"info": {
"url": "https://moralis-proxy.komodo.earth",
"komodo_proxy": true
}
}
}
}
}
```
</CodeGroup>

## Response

```json
{
"mmrpc": "2.0",
"result": {
"nfts": {
"0xc28a19e9a663d966cf99532bdb1229df1b0e344b,1": {
"token_address": "0xc28a19e9a663d966cf99532bdb1229df1b0e344b",
"token_id": "1",
"chain": "POLYGON",
"contract_type": "ERC1155",
"amount": "1"
},
"0xd25f13e4ba534ef625c75b84934689194b7bd59e,14": {
"token_address": "0xd25f13e4ba534ef625c75b84934689194b7bd59e",
"token_id": "14",
"chain": "POLYGON",
"contract_type": "ERC721",
"amount": "1"
}
},
"platform_coin": "MATIC"
},
"id": null
}
```

## Error - Platform coin is not yet activated

```json
{
"mmrpc": "2.0",
"error": "Platform coin MATIC is not activated",
"error_path": "token.lp_coins",
"error_trace": "token:126] lp_coins:2797]",
"error_type": "PlatformCoinIsNotActivated",
"error_data": "MATIC",
"id": null
}
```

## Error - Token already activated

```json
{
"mmrpc": "2.0",
"error": "Token NFT_MATIC is already activated",
"error_path": "token",
"error_trace": "token:119]",
"error_type": "TokenIsAlreadyActivated",
"error_data": "NFT_MATIC",
"id": null
}
```

## Error - Token config not found in coins file

```json
{
"mmrpc": "2.0",
"error": "Token NFT_TESTTT config is not found",
"error_path": "token.prelude",
"error_trace": "token:122] prelude:79]",
"error_type": "TokenConfigIsNotFound",
"error_data": "NFT_TESTTT",
"id": null
}
```
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const title = "Komodo DeFi Framework Method: Non Fungible Tokens - Get NFT List";
export const description =
"This document describes all the get_nft_list method Komodo DeFi Framework provides to get a list of your wallets NFTs";
"This document describes all the get_nft_list method Komodo DeFi Framework provides to get a list of your wallets NFTs";

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

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

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

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

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

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

# Non Fungible Tokens (NFTs)

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.

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.
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).

<Note>
Before using other NFT methods, you should first call the [update\_nft](/komodo-defi-framework/api/v20-dev/non_fungible_tokens/update_nft/)
method to populate/refresh the local database.
Expand All @@ -24,6 +27,10 @@ The Komodo DeFi Framework API supports [ERC1155](https://www.nftstandards.wtf/St
* Withdraw ERC721 tokens with [withdraw\_nft](/komodo-defi-framework/api/v20-dev/non_fungible_tokens/withdraw_nft/#erc-721-withdraw-example)
* Withdraw ERC1155 tokens with [withdraw\_nft](/komodo-defi-framework/api/v20-dev/non_fungible_tokens/withdraw_nft/#erc-1155-withdraw-example)

## NFT Utility Methods

* Clear local NFT data with [clear\_nft\db](/komodo-defi-framework/api/v20-dev/non_fungible_tokens/clear_nft_db/)

<Note>
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)
</Note>
Loading

0 comments on commit 9a20ff4

Please sign in to comment.