Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@unique-nft/client

Package Overview
Dependencies
Maintainers
7
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@unique-nft/client - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

194

index.d.ts

@@ -5,2 +5,5 @@ import { AxiosInstance } from 'axios';

interface TokenPropertiesResponse {
properties: TokenProperty[];
}
interface SignerPayloadJSONDto {

@@ -141,2 +144,5 @@ /**

}
interface TokenChildrenResponse {
children: TokenId[];
}
interface TokenParentResponse {

@@ -184,2 +190,5 @@ /** @example 1 */

}
interface SetTokenPropertiesParsed {
properties: TokenPropertySetEvent[];
}
interface DeleteTokenPropertiesBody {

@@ -206,2 +215,8 @@ /**

}
interface DeleteTokenPropertiesParsed {
properties: TokenPropertyDeletedEvent[];
}
interface AccountTokensResponse {
tokens: TokenId[];
}
interface TokenExistsDto {

@@ -607,2 +622,5 @@ isExists: boolean;

}
interface CollectionPropertiesResponse {
properties: CollectionProperty[];
}
interface SetCollectionPropertiesBody {

@@ -624,2 +642,5 @@ /**

}
interface SetCollectionPropertiesParsed {
properties: CollectionPropertySetEvent[];
}
interface DeleteCollectionPropertiesBody {

@@ -642,2 +663,5 @@ /**

}
interface DeleteCollectionPropertiesParsed {
properties: CollectionPropertyDeletedEvent[];
}
interface PropertyPermission {

@@ -653,2 +677,5 @@ mutable: boolean;

}
interface PropertyPermissionsResponse {
propertyPermissions: PropertyKeyPermission[];
}
interface SetPropertyPermissionsBody {

@@ -670,2 +697,5 @@ /**

}
interface SetPropertyPermissionsParsed {
propertyPermissions: PropertyPermissionSetEvent[];
}
interface SetCollectionPermissionsBody {

@@ -702,2 +732,99 @@ /** @example 1 */

}
interface AllowedResponse {
/** @example true */
isAllowed: boolean;
}
interface AdminlistResponse {
admins: string[];
}
interface AddCollectionAdminBody {
/**
* The ss-58 encoded address
* @example yGCyN3eydMkze4EPtz59Tn7obwbUbYNZCz48dp8FRdemTaLwm
*/
address: string;
/** @example 1 */
collectionId: number;
/**
* The ss-58 encoded address
* @example yGCyN3eydMkze4EPtz59Tn7obwbUbYNZCz48dp8FRdemTaLwm
*/
newAdmin: string;
}
interface AddCollectionAdminParsed {
/** @example 1 */
collectionId: number;
/**
* The ss-58 encoded address
* @example yGCyN3eydMkze4EPtz59Tn7obwbUbYNZCz48dp8FRdemTaLwm
*/
newAdmin: string;
}
interface RemoveCollectionAdminBody {
/**
* The ss-58 encoded address
* @example yGCyN3eydMkze4EPtz59Tn7obwbUbYNZCz48dp8FRdemTaLwm
*/
address: string;
/** @example 1 */
collectionId: number;
/**
* The ss-58 encoded address
* @example yGCyN3eydMkze4EPtz59Tn7obwbUbYNZCz48dp8FRdemTaLwm
*/
admin: string;
}
interface RemoveCollectionAdminParsed {
/** @example 1 */
collectionId: number;
/**
* The ss-58 encoded address
* @example yGCyN3eydMkze4EPtz59Tn7obwbUbYNZCz48dp8FRdemTaLwm
*/
admin: string;
}
interface SetSponsorshipBody {
/**
* The ss-58 encoded address
* @example yGCyN3eydMkze4EPtz59Tn7obwbUbYNZCz48dp8FRdemTaLwm
*/
address: string;
collectionId: number;
newSponsor: string;
}
interface SetSponsorshipParsed {
collectionId: number;
/**
* The ss-58 encoded address
* @example yGCyN3eydMkze4EPtz59Tn7obwbUbYNZCz48dp8FRdemTaLwm
*/
sponsor: string;
}
interface ConfirmSponsorshipBody {
/**
* The ss-58 encoded address
* @example yGCyN3eydMkze4EPtz59Tn7obwbUbYNZCz48dp8FRdemTaLwm
*/
address: string;
collectionId: number;
}
interface ConfirmSponsorshipParsed {
collectionId: number;
/**
* The ss-58 encoded address
* @example yGCyN3eydMkze4EPtz59Tn7obwbUbYNZCz48dp8FRdemTaLwm
*/
sponsor: string;
}
interface RemoveSponsorshipBody {
/**
* The ss-58 encoded address
* @example yGCyN3eydMkze4EPtz59Tn7obwbUbYNZCz48dp8FRdemTaLwm
*/
address: string;
collectionId: number;
}
interface RemoveSponsorshipParsed {
collectionId: number;
}
interface AttributeSchemaDto {

@@ -1041,2 +1168,20 @@ /** @example {"_":"Hello!","en":"Hello!","fr":"Bonjour!"} */

}
interface ChainPropertiesResponse {
/** @example 255 */
SS58Prefix: number;
/** @example QTZ */
token: string;
/** @example 18 */
decimals: number;
/** @example wss://ws-quartz.unique.network */
wsUrl: string;
/** @example 0xe9fa5b65a927e85627d87572161f0d86ef65d1432152d59b7a679fb6c7fd3b39 */
genesisHash: string;
}
interface IpfsUploadResponse {
/** File address */
cid: string;
/** IPFS gateway file URL */
fileUrl?: string;
}

@@ -1091,2 +1236,9 @@ interface IExtrinsics extends ISection {

}
interface IIpfs extends ISection {
path: string;
baseUrl: string;
uploadFile({ file: string }: {
file: any;
}): Promise<IpfsUploadResponse>;
}
interface ICollections extends ISection {

@@ -1102,12 +1254,12 @@ path: string;

collectionId: number;
}): Promise<CollectionProperty[]>;
}): Promise<CollectionPropertiesResponse>;
getLimits(args: {
collectionId: number;
}): Promise<EffectiveCollectionLimitsResponse>;
setProperties: IMutation<SetCollectionPropertiesBody, CollectionPropertySetEvent[]>;
deleteProperties: IMutation<DeleteCollectionPropertiesBody, CollectionPropertyDeletedEvent[]>;
setProperties: IMutation<SetCollectionPropertiesBody, SetCollectionPropertiesParsed>;
deleteProperties: IMutation<DeleteCollectionPropertiesBody, DeleteCollectionPropertiesParsed>;
propertyPermissions(args: {
collectionId: number;
}): Promise<PropertyKeyPermission[]>;
setPropertyPermissions: IMutation<SetPropertyPermissionsBody, PropertyPermissionSetEvent[]>;
}): Promise<PropertyPermissionsResponse>;
setPropertyPermissions: IMutation<SetPropertyPermissionsBody, SetPropertyPermissionsParsed>;
setPermissions: IMutation<SetCollectionPermissionsBody, SetCollectionPermissionsParsed>;

@@ -1117,5 +1269,17 @@ destroy: IMutation<DestroyCollectionBody, DestroyCollectionParsed>;

transfer: IMutation<TransferCollectionBody, TransferCollectionParsed>;
addAdmin: IMutation<AddCollectionAdminBody, AddCollectionAdminParsed>;
removeAdmin: IMutation<RemoveCollectionAdminBody, RemoveCollectionAdminParsed>;
admins(args: {
collectionId: number;
}): Promise<AdminlistResponse>;
lastTokenId(args: {
collectionId: number;
}): Promise<LastTokenIdResultDto>;
allowed(args: {
collectionId: number;
account: string;
}): Promise<AllowedResponse>;
setSponsorship: IMutation<SetSponsorshipBody, SetSponsorshipParsed>;
confirmSponsorship: IMutation<ConfirmSponsorshipBody, ConfirmSponsorshipParsed>;
removeSponsorship: IMutation<RemoveSponsorshipBody, RemoveSponsorshipParsed>;
}

@@ -1129,6 +1293,6 @@ interface ITokens extends ISection {

exists(args: TokenId): Promise<TokenExistsDto>;
properties(args: TokenId): Promise<TokenProperty[]>;
setProperties: IMutation<SetTokenPropertiesBody, TokenPropertySetEvent[]>;
deleteProperties: IMutation<DeleteTokenPropertiesBody, TokenPropertyDeletedEvent[]>;
children(args: TokenId): Promise<TokenId[]>;
properties(args: TokenId): Promise<TokenPropertiesResponse>;
setProperties: IMutation<SetTokenPropertiesBody, SetTokenPropertiesParsed>;
deleteProperties: IMutation<DeleteTokenPropertiesBody, DeleteTokenPropertiesParsed>;
children(args: TokenId): Promise<TokenChildrenResponse>;
parent(args: TokenId): Promise<TokenParentResponse>;

@@ -1144,3 +1308,3 @@ owner(args: TokenId): Promise<TokenOwnerResponse>;

address: string;
}): Promise<TokenId[]>;
}): Promise<AccountTokensResponse>;
}

@@ -1157,2 +1321,5 @@ interface ClientParameters {

}
interface IChain {
properties(): Promise<ChainPropertiesResponse>;
}
interface IClient {

@@ -1162,2 +1329,7 @@ instance: AxiosInstance;

balance: IBalance;
chain: IChain;
fungible: IFungible;
collections: ICollections;
tokens: ITokens;
ipfs: IIpfs;
options: Options;

@@ -1173,2 +1345,3 @@ params: ClientParameters;

instance: AxiosInstance;
readonly chain: IChain;
readonly extrinsics: IExtrinsics;

@@ -1179,2 +1352,3 @@ readonly balance: IBalance;

readonly tokens: ITokens;
readonly ipfs: IIpfs;
readonly defaults: Options;

@@ -1181,0 +1355,0 @@ readonly params: ClientParameters;

import Axios from 'axios';
import FormData from 'form-data';

@@ -111,2 +112,7 @@ const isUnsignedTxPayloadResponse = (args) => typeof args === "object" && !!args && "signerPayloadJSON" in args;

this.setPermissions = new Mutation(this.client, "POST", `${this.path}/permissions`);
this.addAdmin = new Mutation(this.client, "POST", `${this.path}/admins`);
this.removeAdmin = new Mutation(this.client, "DELETE", `${this.path}/admins`);
this.setSponsorship = new Mutation(this.client, "POST", `${this.path}/sponsorship`);
this.confirmSponsorship = new Mutation(this.client, "POST", `${this.path}/sponsorship/confirm`);
this.removeSponsorship = new Mutation(this.client, "DELETE", `${this.path}/sponsorship`);
}

@@ -194,2 +200,22 @@ async properties({

}
async allowed(args) {
const response = await this.client.instance({
method: "GET",
baseURL: this.baseUrl,
url: "allowed",
params: args
});
return response.data;
}
async admins({
collectionId
}) {
const response = await this.client.instance({
method: "GET",
baseURL: this.baseUrl,
url: "admins",
params: { collectionId }
});
return response.data;
}
}

@@ -210,2 +236,3 @@

this.transfer = new Mutation(this.client, "PATCH", `${this.path}/transfer`);
this.approve = new Mutation(this.client, "POST", `${this.path}/approve`);
}

@@ -251,3 +278,6 @@ async properties({

}
async children({ collectionId, tokenId }) {
async children({
collectionId,
tokenId
}) {
const response = await this.client.instance({

@@ -294,2 +324,11 @@ method: "GET",

}
async allowance(args) {
const response = await this.client.instance({
method: "GET",
baseURL: this.baseUrl,
url: "allowance",
params: args
});
return response.data;
}
}

@@ -376,5 +415,60 @@

class Ipfs extends Section {
constructor() {
super(...arguments);
this.path = "ipfs";
this.baseUrl = `${this.client.options.baseUrl}/${this.path}`;
}
async uploadFile({
file
}) {
const form = new FormData();
form.append("file", file, "file");
const response = await this.client.instance({
method: "post",
url: `${this.baseUrl}/upload-file`,
data: form,
headers: {
"Content-Type": `multipart/form-data`
}
});
return response.data;
}
async uploadZip({
file
}) {
const form = new FormData();
form.append("file", file, "file");
const response = await this.client.instance({
method: "post",
url: `${this.baseUrl}/upload-zip`,
data: form,
headers: {
"Content-Type": `multipart/form-data`
}
});
return response.data;
}
}
class Chain extends Section {
constructor() {
super(...arguments);
this.path = "chain";
this.baseUrl = `${this.client.options.baseUrl}/${this.path}`;
}
async properties() {
const response = await this.client.instance({
method: "GET",
baseURL: this.baseUrl,
url: "properties"
});
return response.data;
}
}
class Client {
constructor(options) {
this.options = options;
this.chain = new Chain(this);
this.extrinsics = new Extrinsics(this);

@@ -385,2 +479,3 @@ this.balance = new Balance(this);

this.tokens = new Tokens(this);
this.ipfs = new Ipfs(this);
this.defaults = {

@@ -387,0 +482,0 @@ baseUrl: "",

5

package.json
{
"name": "@unique-nft/client",
"version": "0.1.4",
"version": "0.1.5",
"license": "MIT",
"dependencies": {
"axios": "^0.27.2"
"axios": "^0.27.2",
"form-data": "^4.0.0"
},

@@ -8,0 +9,0 @@ "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.",

@@ -30,14 +30,14 @@ <div align="center">

- collection creating;
- token minting and transferring;
- balance transferring
- [collection creating;](../sdk/tokens#collection-methods)
- [token minting and transferring;](../sdk/tokens#token-methods)
- [balance transferring](../sdk/balance)
- 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.
The package is under construction. Check the [SDK package methods list](../sdk/tokens) to learn more about the methods, that will be implemented in the @unique-nft/client package.
## Installation
### npm
```shell
npm install @unique-nft/client
```
npm i @unique-nft/client
```

@@ -47,26 +47,66 @@ ## Initialization

### Node.js
```
import { Client, Options, AllBalancesResponse, ExtrinsicResultResponse, BalanceTransferParsed } from ‘@unique-nft/client’;
```typescript
import { Client, Options } from '@unique-nft/client';
const options: Options = {
baseUrl: ‘url for rest api’
baseUrl: '<REST API URL>'
};
const client = new Client(options);
```
In the `baseUrl` parameter, you must pass one of the paths to the [`Unique Network`](../web)
## Method call examples
#### Opal
```shell
https://web-opal.unique.network
```
#### Quartz
```shell
https://web-quartz.unique.network
```
const balanceResponse: AllBalancesResponse = await client.balance.get(
{
address: ‘your address’,
});
#### Unique
```shell
https://web-unique.unique.network
```
### Set a signer
To be able to sign extrinsics, you need to install the [`Accounts`](../accounts) package
```shell
npm install @unique-nft/accounts
```
const transferResult: ExtrinsicResultResponse<BalanceTransferParsed> = await client.balance.transfer.submitWaitResult(
Pass the `singer` in the parameters when creating the `Client` object
```typescript
import { KeyringProvider } from '@unique-nft/accounts/keyring';
import { Client } from "@unique-nft/client";
const options = {
type: 'sr25519',
};
const provider = new KeyringProvider(options);
await provider.init();
const account = provider.addSeed('<seed of account>');
const signer = account.getSigner();
const clientOptions = {
baseUrl: 'REST API URL',
signer
};
const client = new Client(clientOptions);
```
## Method call examples
```typescript
const balanceResponse = await client.balance.get({ address: '<address>' });
```
```typescript
const { parsed } = await client.balance.transfer.submitWaitResult(
{
address: ‘address from’,
destination: ‘address to’,
amount: 0.001,
address: '<address from>',
destination: '<address to>',
amount: 0.01
});
```

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc