Skip to content

Commit

Permalink
fix(js-dash-sdk): fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
pshenmic committed Jan 30, 2025
1 parent 7940a09 commit dac6932
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 113 deletions.
9 changes: 0 additions & 9 deletions packages/js-dash-sdk/src/SDK/Client/Platform/Platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ import createAssetLockTransaction from './createAssetLockTransaction';

import broadcastDocument from './methods/documents/broadcast';

Check warning on line 10 in packages/js-dash-sdk/src/SDK/Client/Platform/Platform.ts

View workflow job for this annotation

GitHub Actions / JS packages (dash) / Linting

Dependency cycle detected
import createDocument from './methods/documents/create';

Check warning on line 11 in packages/js-dash-sdk/src/SDK/Client/Platform/Platform.ts

View workflow job for this annotation

GitHub Actions / JS packages (dash) / Linting

Dependency cycle detected
import transferDocument from './methods/documents/transfer';
import updatePriceDocument from './methods/documents/updatePrice';
import purchaseDocument from './methods/documents/purchase';
import getDocument from './methods/documents/get';

import publishContract from './methods/contracts/publish';
Expand Down Expand Up @@ -61,9 +58,6 @@ export interface PlatformOpts {
interface Records {
broadcast: Function,
create: Function,
transfer: Function,
updatePrice: Function,
purchase: Function,
get: Function,
}

Expand Down Expand Up @@ -171,9 +165,6 @@ export class Platform {
this.documents = {
broadcast: broadcastDocument.bind(this),
create: createDocument.bind(this),
transfer: transferDocument.bind(this),
updatePrice: updatePriceDocument.bind(this),
purchase: purchaseDocument.bind(this),
get: getDocument.bind(this),
};
this.contracts = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@ export default async function broadcast(
documents: {
create?: ExtendedDocument[],
replace?: ExtendedDocument[],
delete?: ExtendedDocument[]
delete?: ExtendedDocument[],
transfer?: ExtendedDocument[]
},
identity: any,
options: any,
): Promise<any> {
console.log(documents)

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

View workflow job for this annotation

GitHub Actions / JS packages (dash) / Linting

Missing semicolon
this.logger.debug('[Document#broadcast] Broadcast documents', {
create: documents.create?.length || 0,
replace: documents.replace?.length || 0,
delete: documents.delete?.length || 0,
transfer: documents.transfer?.length || 0,
});
await this.initialize();

Expand All @@ -36,20 +40,25 @@ export default async function broadcast(
...(documents.create || []),
...(documents.replace || []),
...(documents.delete || []),
...(documents.transfer || []),
][0]?.getDataContractId();

if (!dataContractId) {
throw new Error('Data contract ID is not found');
}

if (documents.transfer?.length && !options.recipient) {
throw new Error('Receiver identity is not found for transfer transition');
}

const identityContractNonce = await this.nonceManager
.bumpIdentityContractNonce(identityId, dataContractId);

const documentsBatchTransition = dpp.document.createStateTransition(documents, {
[identityId.toString()]: {
[dataContractId.toString()]: identityContractNonce,
},
});
}, options.recipient, options.price);

this.logger.silly('[Document#broadcast] Created documents batch transition');

Expand Down Expand Up @@ -79,6 +88,7 @@ export default async function broadcast(
create: documents.create?.length || 0,
replace: documents.replace?.length || 0,
delete: documents.delete?.length || 0,
transfer: documents.transfer?.length || 0,
});

return documentsBatchTransition;
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit dac6932

Please sign in to comment.