Skip to content

Commit

Permalink
feat(js-dash-sdk): uncomment
Browse files Browse the repository at this point in the history
  • Loading branch information
pshenmic committed Jan 26, 2025
1 parent 9c9c913 commit cbc86c4
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Identity, ExtendedDocument } from '@dashevo/wasm-dpp';
import { Platform } from '../../Platform';
import broadcastStateTransition from '../../broadcastStateTransition';
import { signStateTransition } from '../../signStateTransition';
/**
* Transfer document in the platform
*
* @param {Platform} this - bound instance class
* @param {ExtendedDocument} document - document from the DAPI
* @param {Identifier} receiver - identifier of the document recipient ownership
* @param {Identifier} sender - identifier of the document owner
*/
export async function purchase(
this: Platform,
document: ExtendedDocument,
amount: number,
buyer: Identity,
seller: Identity,

Check failure on line 18 in packages/js-dash-sdk/src/SDK/Client/Platform/methods/documents/purchase.ts

View workflow job for this annotation

GitHub Actions / JS packages (dash) / Linting

'seller' is defined but never used
): Promise<any> {
this.logger.debug(`[Document#transfer] Update price for document ${document.getId().toString()} to ${amount}`);
await this.initialize();

const identityContractNonce = await this.nonceManager
.bumpIdentityContractNonce(buyer.getId(), document.getDataContractId());

const documentsBatchTransition = document
.createPurchaseStateTransition(buyer.getId(), amount, BigInt(identityContractNonce));

await signStateTransition(this, documentsBatchTransition, buyer, 1);

console.log(documentsBatchTransition.toBuffer().toString('hex'));

await broadcastStateTransition(this, documentsBatchTransition);
}

export default purchase;
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Identity, ExtendedDocument } from '@dashevo/wasm-dpp';
import { Platform } from '../../Platform';
import broadcastStateTransition from '../../broadcastStateTransition';
import { signStateTransition } from '../../signStateTransition';
/**
* Transfer document in the platform
*
* @param {Platform} this - bound instance class
* @param {ExtendedDocument} document - document from the DAPI
* @param {Identifier} receiver - identifier of the document recipient ownership
* @param {Identifier} sender - identifier of the document owner
*/
export async function updatePrice(
this: Platform,
document: ExtendedDocument,
amount: number,
identity: Identity,
): Promise<any> {
this.logger.debug(`[Document#transfer] Update price for document ${document.getId().toString()} to ${amount}`);
await this.initialize();

const identityContractNonce = await this.nonceManager
.bumpIdentityContractNonce(identity.getId(), document.getDataContractId());

const documentsBatchTransition = document
.createUpdatePriceStateTransition(amount, BigInt(identityContractNonce));

await signStateTransition(this, documentsBatchTransition, identity, 1);

await broadcastStateTransition(this, documentsBatchTransition);
}

export default updatePrice;

0 comments on commit cbc86c4

Please sign in to comment.