-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(js-dash-sdk): add NFT state transitions docs
- Loading branch information
Showing
4 changed files
with
104 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
**Usage**: `client.platform.documents.broadcast(documents, identity, options)` | ||
**Description**: This method will broadcast a purchase state transition that buys the given document from other Identity. | ||
|
||
Parameters: | ||
|
||
| parameters | type | required | Description | | ||
|------------------------|---------|------------------ |-------------------------------------------------------------------| | ||
| **documents.purchase** | ExtendedDocument[] | no | array of valid [created document](../documents/create.md) to buy | | ||
| **identity** | Identity | yes | A valid [registered identity](../identities/register.md) | | ||
| **options** | DocumentTransitionParams | no | An object with field `price` (BigInt) and `receiver` (Identifier) | | ||
|
||
**Example**: | ||
```js | ||
const identityId = '';// Your identity identifier | ||
const receiverId = ''; // Receiver identity identifier | ||
const documentId = '' // Your document id | ||
const price = BigInt(1000000) | ||
|
||
const identity = await client.platform.identities.get(identityId); | ||
const receiverIdentity = await client.platform.identities.get(receiverId); | ||
|
||
const identity = await client.platform.identities.get(identityId); | ||
|
||
const [document] = await dash.platform.documents.get( | ||
'helloWorldContract.note', | ||
{ where: [['$id', '==', documentId]] }, | ||
); | ||
|
||
await dash.platform.documents.broadcast({ updatePrice: [document], }, identity, { price, receiver: receiverIdentity.getId() }); | ||
``` | ||
**Note**: This method will change the ownership of the document to your identity, and seller identity will be credited with the amount specified in the updatePrice deducted from your balance. | ||
|
||
Returns: DocumentsBatchTransition |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
**Usage**: `client.platform.documents.broadcast(documents, identity, options)` | ||
**Description**: This method will broadcast a document transfer | ||
|
||
Parameters: | ||
|
||
| parameters | type | required | Description | | ||
|-------------------|---------|------------------ |-----------------------------------------------------------------------| | ||
| **documents.transfer** | ExtendedDocument[] | no | array of valid [created document](../documents/create.md) to transfer | | ||
| **identity** | Identity | yes | A valid [registered identity](../identities/register.md) | | ||
| **options** | DocumentTransitionParams | no | An object with `receiver` field | | ||
|
||
**Example**: | ||
```js | ||
const identityId = '';// Your identity identifier | ||
const receiverId = ''; // Receiver identity identifier | ||
const documentId = '' // Your document id | ||
|
||
const identity = await client.platform.identities.get(identityId); | ||
const receiverIdentity = await client.platform.identities.get(receiverId); | ||
|
||
const [document] = await dash.platform.documents.get( | ||
'helloWorldContract.note', | ||
{ where: [['$id', '==', documentId]] }, | ||
); | ||
|
||
await dash.platform.documents.broadcast({ transfer: [document], }, identity, { receiver: receiverIdentity.getId() }); | ||
``` | ||
|
||
**Note**: Transfer transition changes the ownership of the given document to the receiver identity | ||
|
||
Returns: DocumentsBatchTransition |
29 changes: 29 additions & 0 deletions
29
packages/js-dash-sdk/docs/platform/documents/updatePrice.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
**Usage**: `client.platform.documents.broadcast(documents, identity, options)` | ||
**Description**: This method will broadcast an update price state transition that sets a price for the given document. | ||
|
||
Parameters: | ||
|
||
| parameters | type | required | Description | | ||
|---------------------------|---------|------------------ |---------------------------------------------------------------------------| | ||
| **documents.updatePrice** | ExtendedDocument[] | no | array of valid [created document](../documents/create.md) to update price | | ||
| **identity** | Identity | yes | A valid [registered identity](../identities/register.md) | | ||
| **options** | DocumentTransitionParams | no | An object with field `price` (BigInt) | | ||
|
||
**Example**: | ||
```js | ||
const identityId = '';// Your identity identifier | ||
const documentId = '' // Your document id | ||
const price = BigInt(1000000) | ||
|
||
const identity = await client.platform.identities.get(identityId); | ||
|
||
const [document] = await dash.platform.documents.get( | ||
'helloWorldContract.note', | ||
{ where: [['$id', '==', documentId]] }, | ||
); | ||
|
||
await dash.platform.documents.broadcast({ updatePrice: [document], }, identity, { price }); | ||
``` | ||
**Note**: This method sets the same price on all documents in the batch (only one is possible right now) | ||
|
||
Returns: DocumentsBatchTransition |