@unique-nft/client
Advanced tools
Comparing version 0.1.1 to 0.1.2
165
index.d.ts
@@ -63,2 +63,57 @@ import { AxiosInstance } from 'axios'; | ||
} | ||
interface BurnTokenBody { | ||
/** @example 1 */ | ||
collectionId: number; | ||
/** @example 1 */ | ||
tokenId: number; | ||
/** | ||
* The ss-58 encoded address | ||
* @example yGCyN3eydMkze4EPtz59Tn7obwbUbYNZCz48dp8FRdemTaLwm | ||
*/ | ||
address: string; | ||
/** | ||
* The ss-58 encoded address | ||
* @example yGCyN3eydMkze4EPtz59Tn7obwbUbYNZCz48dp8FRdemTaLwm | ||
*/ | ||
from?: string; | ||
/** @example 1 */ | ||
value?: number; | ||
} | ||
interface BurnTokenParsed { | ||
/** @example 1 */ | ||
collectionId: number; | ||
/** @example 1 */ | ||
tokenId: number; | ||
/** | ||
* The ss-58 encoded address | ||
* @example yGCyN3eydMkze4EPtz59Tn7obwbUbYNZCz48dp8FRdemTaLwm | ||
*/ | ||
address: string; | ||
/** @example 1 */ | ||
value: number; | ||
} | ||
interface TransferTokenBody { | ||
/** @example 1 */ | ||
collectionId: number; | ||
/** @example 1 */ | ||
tokenId: number; | ||
/** @example unjKJQJrRd238pkUZZvzDQrfKuM39zBSnQ5zjAGAGcdRhaJTx */ | ||
address: string; | ||
/** @example unjKJQJrRd238pkUZZvzDQrfKuM39zBSnQ5zjAGAGcdRhaJTx */ | ||
from?: string; | ||
/** @example unhk98EgHVJ3Efjz4912GfWkMoW2GXe3SuFrQ6u2bYeWToXrE */ | ||
to: string; | ||
value?: number; | ||
} | ||
interface TransferTokenParsed { | ||
/** @example 1 */ | ||
collectionId: number; | ||
/** @example 1 */ | ||
tokenId: number; | ||
/** Sender address */ | ||
from: object; | ||
/** Recipient address */ | ||
to: object; | ||
value: number; | ||
} | ||
interface TokenId { | ||
@@ -334,2 +389,82 @@ /** @example 1 */ | ||
} | ||
interface UniqueTokenToCreateExDto { | ||
image: { | ||
urlInfix?: string; | ||
hash?: string | null; | ||
} | { | ||
url?: string; | ||
hash?: string | null; | ||
} | { | ||
ipfsCid?: string; | ||
hash?: string | null; | ||
}; | ||
/** @example {"0":0,"1":[0,1]} */ | ||
encodedAttributes: Record<string, number | number[] | { | ||
_?: string; | ||
} | { | ||
_?: string; | ||
}[] | { | ||
_?: number; | ||
} | { | ||
_?: number; | ||
}[]>; | ||
/** @example {"_":"Hello!","en":"Hello!","fr":"Bonjour!"} */ | ||
name?: { | ||
_?: string; | ||
}; | ||
audio: { | ||
urlInfix?: string; | ||
hash?: string | null; | ||
} | { | ||
url?: string; | ||
hash?: string | null; | ||
} | { | ||
ipfsCid?: string; | ||
hash?: string | null; | ||
}; | ||
/** @example {"_":"Hello!","en":"Hello!","fr":"Bonjour!"} */ | ||
description?: { | ||
_?: string; | ||
}; | ||
imagePreview: { | ||
urlInfix?: string; | ||
hash?: string | null; | ||
} | { | ||
url?: string; | ||
hash?: string | null; | ||
} | { | ||
ipfsCid?: string; | ||
hash?: string | null; | ||
}; | ||
spatialObject: { | ||
urlInfix?: string; | ||
hash?: string | null; | ||
} | { | ||
url?: string; | ||
hash?: string | null; | ||
} | { | ||
ipfsCid?: string; | ||
hash?: string | null; | ||
}; | ||
video: { | ||
urlInfix?: string; | ||
hash?: string | null; | ||
} | { | ||
url?: string; | ||
hash?: string | null; | ||
} | { | ||
ipfsCid?: string; | ||
hash?: string | null; | ||
}; | ||
/** | ||
* The ss-58 encoded address | ||
* @example yGCyN3eydMkze4EPtz59Tn7obwbUbYNZCz48dp8FRdemTaLwm | ||
*/ | ||
owner: string; | ||
} | ||
interface CreateTokensDto { | ||
address: string; | ||
collectionId: number; | ||
data: UniqueTokenToCreateExDto[]; | ||
} | ||
interface CollectionSponsorship { | ||
@@ -403,2 +538,19 @@ /** | ||
} | ||
interface SetCollectionLimitsBody { | ||
/** The collection limits */ | ||
limits: CollectionLimitsDto; | ||
/** | ||
* The ss-58 encoded address | ||
* @example unjKJQJrRd238pkUZZvzDQrfKuM39zBSnQ5zjAGAGcdRhaJTx | ||
*/ | ||
address: string; | ||
/** @example 1 */ | ||
collectionId: number; | ||
} | ||
interface SetCollectionLimitsParsed { | ||
/** @example 1 */ | ||
collectionId: number; | ||
/** The collection limits */ | ||
limits: CollectionLimitsDto; | ||
} | ||
interface CollectionProperty { | ||
@@ -693,2 +845,7 @@ /** @example example */ | ||
freeBalance: BalanceResponse; | ||
/** | ||
* The ss-58 encoded address | ||
* @example yGCyN3eydMkze4EPtz59Tn7obwbUbYNZCz48dp8FRdemTaLwm | ||
*/ | ||
address: string; | ||
} | ||
@@ -751,2 +908,3 @@ interface BalanceTransferBody { | ||
creation: IMutation<CreateCollectionNewRequest, CreateCollectionParsed>; | ||
setLimits: IMutation<SetCollectionLimitsBody, SetCollectionLimitsParsed>; | ||
get(args: { | ||
@@ -769,2 +927,3 @@ collectionId: number; | ||
create: IMutation<CreateTokenNewDto, TokenId>; | ||
createMultiple: IMutation<CreateTokensDto, TokenId[]>; | ||
get(args: TokenId): Promise<UniqueTokenDecodedResponse>; | ||
@@ -779,2 +938,8 @@ properties(args: TokenId): Promise<TokenProperty[]>; | ||
unnest: IMutation<UnnestTokenBody, TokenId>; | ||
burn: IMutation<BurnTokenBody, BurnTokenParsed>; | ||
transfer: IMutation<TransferTokenBody, TransferTokenParsed>; | ||
accountTokens(args: { | ||
collectionId: number; | ||
address: string; | ||
}): Promise<TokenId[]>; | ||
} | ||
@@ -781,0 +946,0 @@ interface ClientParameters { |
14
index.js
@@ -106,2 +106,4 @@ import Axios from 'axios'; | ||
this.creation = new Mutation(this.client, "POST", this.path); | ||
this.setLimits = new Mutation(this.client, "POST", this.path); | ||
this.destroy = new Mutation(this.client, "DELETE", this.path); | ||
} | ||
@@ -149,4 +151,7 @@ async properties({ | ||
this.create = new Mutation(this.client, "POST", this.path); | ||
this.createMultiple = new Mutation(this.client, "POST", `${this.path}/create-multiple`); | ||
this.nest = new Mutation(this.client, "POST", `${this.path}/nest`); | ||
this.unnest = new Mutation(this.client, "POST", `${this.path}/unnest`); | ||
this.burn = new Mutation(this.client, "DELETE", this.path); | ||
this.transfer = new Mutation(this.client, "PATCH", `${this.path}/transfer`); | ||
} | ||
@@ -165,2 +170,11 @@ async properties({ | ||
} | ||
async accountTokens(args) { | ||
const { data } = await this.client.instance({ | ||
method: "GET", | ||
baseURL: this.baseUrl, | ||
url: "account-tokens", | ||
params: args | ||
}); | ||
return data; | ||
} | ||
async get(args) { | ||
@@ -167,0 +181,0 @@ const response = await this.client.instance({ |
{ | ||
"name": "@unique-nft/client", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"license": "MIT", | ||
"dependencies": {}, | ||
"dependencies": { | ||
"axios": "^0.27.2" | ||
}, | ||
"description": "The @unique-nft/client package implements the SDK methods via the REST API. The package implements all the basic methods for working with the Unique Network SDK.", | ||
"keywords": [ | ||
"blockchain", | ||
"parachain", | ||
"polkadot", | ||
"unique network", | ||
"nft" | ||
], | ||
"bugs": { | ||
"url": "https://github.com/UniqueNetwork/unique-sdk/issues" | ||
}, | ||
"author": { | ||
"name": "Unique Network SDK team" | ||
}, | ||
"homepage": "https://unique.network/", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/UniqueNetwork/unique-sdk.git" | ||
}, | ||
"type": "module", | ||
@@ -7,0 +28,0 @@ "types": "index.d.ts", |
@@ -1,25 +0,70 @@ | ||
## Client | ||
<div align="center"> | ||
<img width="400px" src="https://raw.githubusercontent.com/UniqueNetwork/unique-sdk/ab6b4e524f008d5e921026599de5bc120a91e14e/doc/logo-white.svg" alt="Unique Network"> | ||
<br/> | ||
<br/> | ||
### install | ||
npm i @unique-nft/client | ||
[![polkadotjs](https://img.shields.io/badge/polkadot-js-orange?style=flat-square)](https://polkadot.js.org) | ||
[![uniquenetwork](https://img.shields.io/badge/unique-network-blue?style=flat-square)](https://unique.network/) | ||
![language](https://img.shields.io/github/languages/top/uniquenetwork/unique-sdk?style=flat-square) | ||
![license](https://img.shields.io/badge/License-Apache%202.0-blue?logo=apache&style=flat-square) | ||
![GitHub Release Date](https://img.shields.io/github/release-date/uniquenetwork/unique-sdk?style=flat-square) | ||
![GitHub](https://img.shields.io/github/v/tag/uniquenetwork/unique-sdk?style=flat-square) | ||
[![stability-alpha](https://img.shields.io/badge/stability-alpha-f4d03f.svg)](https://github.com/mkenney/software-guides/blob/master/STABILITY-BADGES.md#alpha) | ||
### Initialization in Node.js | ||
import { Client } from '@unique-nft/client'; | ||
</div> | ||
const client = new Client('http://localhost:3000/', '//Alice'); | ||
# Client | ||
### Initialization in browser | ||
# Table of Contents | ||
### balance | ||
await client.balance.get(aliceAddress); | ||
- [About Client package](#about-client-package) | ||
- [Installation](#installation) | ||
- [Initialize](#initialization) | ||
- [Method call](#method-call-examples) | ||
await client.balance.transfer( | ||
aliceAddress, | ||
bobAddress, | ||
0.001, | ||
true, | ||
); | ||
### collection | ||
await client.collection.get(collectionId); | ||
## About Client package | ||
The @unique-nft/client package implements the SDK methods via the REST API. The package implements all the basic methods for working with the SDK: | ||
- collection creating; | ||
- token minting and transferring; | ||
- balance transferring | ||
- etc. | ||
The package is under construction. Check the [SDK package methods list](../../packages/sdk/tokens) to learn more about the methods, that will be implemented in the @unique-nft/client package. | ||
## Installation | ||
### npm | ||
``` | ||
npm i @unique-nft/client | ||
``` | ||
## Initialization | ||
### Node.js | ||
``` | ||
import { Client, Options, AllBalancesResponse, ExtrinsicResultResponse, BalanceTransferParsed } from ‘@unique-nft/client’; | ||
const options: Options = { | ||
baseUrl: ‘url for rest api’ | ||
}; | ||
const client = new Client(options); | ||
``` | ||
## Method call examples | ||
``` | ||
const balanceResponse: AllBalancesResponse = await client.balance.get( | ||
{ | ||
address: ‘your address’, | ||
}); | ||
``` | ||
``` | ||
const transferResult: ExtrinsicResultResponse<BalanceTransferParsed> = await client.balance.transfer.submitWaitResult( | ||
{ | ||
address: ‘address from’, | ||
destination: ‘address to’, | ||
amount: 0.001, | ||
}); | ||
``` |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
46941
1535
1
1
71
0
1
+ Addedaxios@^0.27.2
+ Addedasynckit@0.4.0(transitive)
+ Addedaxios@0.27.2(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
+ Addedform-data@4.0.1(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)