Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 8 additions & 9 deletions packages/js-evo-sdk/src/contracts/facade.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as wasm from '../wasm.js';
import { asJsonString } from '../util.js';
import type { EvoSDK } from '../sdk.js';
import type { DataContractHistoryQuery } from '../wasm.js';

export class ContractsFacade {
private sdk: EvoSDK;
Expand All @@ -10,43 +9,43 @@ export class ContractsFacade {
this.sdk = sdk;
}

async fetch(contractId: string): Promise<wasm.DataContract | undefined> {
async fetch(contractId: wasm.IdentifierLike): Promise<wasm.DataContract | undefined> {
const w = await this.sdk.getWasmSdkConnected();
return w.getDataContract(contractId);
}

async fetchWithProof(contractId: string): Promise<any> {
async fetchWithProof(contractId: wasm.IdentifierLike): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getDataContractWithProofInfo(contractId);
}

async getHistory(query: DataContractHistoryQuery): Promise<any> {
async getHistory(query: wasm.DataContractHistoryQuery): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getDataContractHistory(query);
}

async getHistoryWithProof(query: DataContractHistoryQuery): Promise<any> {
async getHistoryWithProof(query: wasm.DataContractHistoryQuery): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getDataContractHistoryWithProofInfo(query);
}

async getMany(contractIds: string[]): Promise<any> {
async getMany(contractIds: wasm.IdentifierLike[]): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getDataContracts(contractIds);
}

async getManyWithProof(contractIds: string[]): Promise<any> {
async getManyWithProof(contractIds: wasm.IdentifierLike[]): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getDataContractsWithProofInfo(contractIds);
}

async create(args: { ownerId: string; definition: unknown; privateKeyWif: string; keyId?: number }): Promise<any> {
async create(args: { ownerId: wasm.IdentifierLike; definition: unknown; privateKeyWif: string; keyId?: number }): Promise<any> {
const { ownerId, definition, privateKeyWif, keyId } = args;
const w = await this.sdk.getWasmSdkConnected();
return w.contractCreate(ownerId, asJsonString(definition)!, privateKeyWif, keyId ?? null);
}

async update(args: { contractId: string; ownerId: string; updates: unknown; privateKeyWif: string; keyId?: number }): Promise<any> {
async update(args: { contractId: wasm.IdentifierLike; ownerId: wasm.IdentifierLike; updates: unknown; privateKeyWif: string; keyId?: number }): Promise<any> {
const { contractId, ownerId, updates, privateKeyWif, keyId } = args;
const w = await this.sdk.getWasmSdkConnected();
return w.contractUpdate(contractId, ownerId, asJsonString(updates)!, privateKeyWif, keyId ?? null);
Expand Down
28 changes: 14 additions & 14 deletions packages/js-evo-sdk/src/documents/facade.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as wasm from '../wasm.js';
import { asJsonString } from '../util.js';
import type { EvoSDK } from '../sdk.js';
import type { DocumentsQuery } from '../wasm.js';

export class DocumentsFacade {
private sdk: EvoSDK;
Expand All @@ -10,30 +10,30 @@ export class DocumentsFacade {
}

// Query many documents
async query(query: DocumentsQuery): Promise<any> {
async query(query: wasm.DocumentsQuery): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getDocuments(query);
}

async queryWithProof(query: DocumentsQuery): Promise<any> {
async queryWithProof(query: wasm.DocumentsQuery): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getDocumentsWithProofInfo(query);
}

async get(contractId: string, type: string, documentId: string): Promise<any> {
async get(contractId: wasm.IdentifierLike, type: string, documentId: wasm.IdentifierLike): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getDocument(contractId, type, documentId);
}

async getWithProof(contractId: string, type: string, documentId: string): Promise<any> {
async getWithProof(contractId: wasm.IdentifierLike, type: string, documentId: wasm.IdentifierLike): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getDocumentWithProofInfo(contractId, type, documentId);
}

async create(args: {
contractId: string;
contractId: wasm.IdentifierLike;
type: string;
ownerId: string;
ownerId: wasm.IdentifierLike;
data: unknown;
entropyHex: string;
privateKeyWif: string;
Expand All @@ -51,10 +51,10 @@ export class DocumentsFacade {
}

async replace(args: {
contractId: string;
contractId: wasm.IdentifierLike;
type: string;
documentId: string;
ownerId: string;
documentId: wasm.IdentifierLike;
ownerId: wasm.IdentifierLike;
data: unknown;
revision: number | bigint;
privateKeyWif: string;
Expand All @@ -72,25 +72,25 @@ export class DocumentsFacade {
);
}

async delete(args: { contractId: string; type: string; documentId: string; ownerId: string; privateKeyWif: string }): Promise<any> {
async delete(args: { contractId: wasm.IdentifierLike; type: string; documentId: wasm.IdentifierLike; ownerId: wasm.IdentifierLike; privateKeyWif: string }): Promise<any> {
const { contractId, type, documentId, ownerId, privateKeyWif } = args;
const w = await this.sdk.getWasmSdkConnected();
return w.documentDelete(contractId, type, documentId, ownerId, privateKeyWif);
}

async transfer(args: { contractId: string; type: string; documentId: string; ownerId: string; recipientId: string; privateKeyWif: string }): Promise<any> {
async transfer(args: { contractId: wasm.IdentifierLike; type: string; documentId: wasm.IdentifierLike; ownerId: wasm.IdentifierLike; recipientId: wasm.IdentifierLike; privateKeyWif: string }): Promise<any> {
const { contractId, type, documentId, ownerId, recipientId, privateKeyWif } = args;
const w = await this.sdk.getWasmSdkConnected();
return w.documentTransfer(contractId, type, documentId, ownerId, recipientId, privateKeyWif);
}

async purchase(args: { contractId: string; type: string; documentId: string; buyerId: string; price: number | bigint | string; privateKeyWif: string }): Promise<any> {
async purchase(args: { contractId: wasm.IdentifierLike; type: string; documentId: wasm.IdentifierLike; buyerId: wasm.IdentifierLike; price: number | bigint | string; privateKeyWif: string }): Promise<any> {
const { contractId, type, documentId, buyerId, price, privateKeyWif } = args;
const w = await this.sdk.getWasmSdkConnected();
return w.documentPurchase(contractId, type, documentId, buyerId, BigInt(price), privateKeyWif);
}

async setPrice(args: { contractId: string; type: string; documentId: string; ownerId: string; price: number | bigint | string; privateKeyWif: string }): Promise<any> {
async setPrice(args: { contractId: wasm.IdentifierLike; type: string; documentId: wasm.IdentifierLike; ownerId: wasm.IdentifierLike; price: number | bigint | string; privateKeyWif: string }): Promise<any> {
const { contractId, type, documentId, ownerId, price, privateKeyWif } = args;
const w = await this.sdk.getWasmSdkConnected();
return w.documentSetPrice(contractId, type, documentId, ownerId, BigInt(price), privateKeyWif);
Expand Down
16 changes: 7 additions & 9 deletions packages/js-evo-sdk/src/dpns/facade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,30 +33,28 @@ export class DpnsFacade {
return w.dpnsResolveName(name);
}

async registerName(args: { label: string; identityId: string; publicKeyId: number; privateKeyWif: string; onPreorder?: Function }): Promise<any> {
async registerName(args: { label: string; identityId: wasm.IdentifierLike; publicKeyId: number; privateKeyWif: string; onPreorder?: Function }): Promise<any> {
const { label, identityId, publicKeyId, privateKeyWif, onPreorder } = args;
const w = await this.sdk.getWasmSdkConnected();
return w.dpnsRegisterName(label, identityId, publicKeyId, privateKeyWif, onPreorder ?? null);
}

async usernames(identityId: string, opts: { limit?: number } = {}): Promise<any> {
const { limit } = opts;
async usernames(query: wasm.DpnsUsernamesQuery): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getDpnsUsernames(identityId, limit ?? null);
return w.getDpnsUsernames(query);
}

async username(identityId: string): Promise<any> {
async username(identityId: wasm.IdentifierLike): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getDpnsUsername(identityId);
}

async usernamesWithProof(identityId: string, opts: { limit?: number } = {}): Promise<any> {
const { limit } = opts;
async usernamesWithProof(query: wasm.DpnsUsernamesQuery): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getDpnsUsernamesWithProofInfo(identityId, limit ?? null);
return w.getDpnsUsernamesWithProofInfo(query);
}

async usernameWithProof(identityId: string): Promise<any> {
async usernameWithProof(identityId: wasm.IdentifierLike): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getDpnsUsernameWithProofInfo(identityId);
}
Expand Down
49 changes: 21 additions & 28 deletions packages/js-evo-sdk/src/group/facade.ts
Original file line number Diff line number Diff line change
@@ -1,103 +1,96 @@
import type {
ContestedResourceVotersForIdentityQuery,
GroupActionsQuery,
GroupInfosQuery,
GroupMembersQuery,
IdentityGroupsQuery,
VotePollsByDocumentTypeQuery,
} from '../wasm.js';
import * as wasm from '../wasm.js';
import type { EvoSDK } from '../sdk.js';

export class GroupFacade {
private sdk: EvoSDK;
constructor(sdk: EvoSDK) { this.sdk = sdk; }

async info(contractId: string, groupContractPosition: number): Promise<any> {
async info(contractId: wasm.IdentifierLike, groupContractPosition: number): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getGroupInfo(contractId, groupContractPosition);
}

async infoWithProof(contractId: string, groupContractPosition: number): Promise<any> {
async infoWithProof(contractId: wasm.IdentifierLike, groupContractPosition: number): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getGroupInfoWithProofInfo(contractId, groupContractPosition);
}

async infos(query: GroupInfosQuery): Promise<any> {
async infos(query: wasm.GroupInfosQuery): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getGroupInfos(query);
}

async infosWithProof(query: GroupInfosQuery): Promise<any> {
async infosWithProof(query: wasm.GroupInfosQuery): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getGroupInfosWithProofInfo(query);
}

async members(query: GroupMembersQuery): Promise<any> {
async members(query: wasm.GroupMembersQuery): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getGroupMembers(query);
}

async membersWithProof(query: GroupMembersQuery): Promise<any> {
async membersWithProof(query: wasm.GroupMembersQuery): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getGroupMembersWithProofInfo(query);
}

async identityGroups(query: IdentityGroupsQuery): Promise<any> {
async identityGroups(query: wasm.IdentityGroupsQuery): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getIdentityGroups(query);
}

async identityGroupsWithProof(query: IdentityGroupsQuery): Promise<any> {
async identityGroupsWithProof(query: wasm.IdentityGroupsQuery): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getIdentityGroupsWithProofInfo(query);
}

async actions(query: GroupActionsQuery): Promise<any> {
async actions(query: wasm.GroupActionsQuery): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getGroupActions(query);
}

async actionsWithProof(query: GroupActionsQuery): Promise<any> {
async actionsWithProof(query: wasm.GroupActionsQuery): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getGroupActionsWithProofInfo(query);
}

async actionSigners(contractId: string, groupContractPosition: number, status: string, actionId: string): Promise<any> {
async actionSigners(query: wasm.GroupActionSignersQuery): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getGroupActionSigners(contractId, groupContractPosition, status, actionId);
return w.getGroupActionSigners(query);
}

async actionSignersWithProof(contractId: string, groupContractPosition: number, status: string, actionId: string): Promise<any> {
async actionSignersWithProof(query: wasm.GroupActionSignersQuery): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getGroupActionSignersWithProofInfo(contractId, groupContractPosition, status, actionId);
return w.getGroupActionSignersWithProofInfo(query);
}

async groupsDataContracts(dataContractIds: string[]): Promise<any> {
async groupsDataContracts(dataContractIds: wasm.IdentifierLike[]): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getGroupsDataContracts(dataContractIds);
}

async groupsDataContractsWithProof(dataContractIds: string[]): Promise<any> {
async groupsDataContractsWithProof(dataContractIds: wasm.IdentifierLike[]): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getGroupsDataContractsWithProofInfo(dataContractIds);
}

async contestedResources(query: VotePollsByDocumentTypeQuery): Promise<any> {
async contestedResources(query: wasm.VotePollsByDocumentTypeQuery): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getContestedResources(query);
}

async contestedResourcesWithProof(query: VotePollsByDocumentTypeQuery): Promise<any> {
async contestedResourcesWithProof(query: wasm.VotePollsByDocumentTypeQuery): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getContestedResourcesWithProofInfo(query);
}

async contestedResourceVotersForIdentity(query: ContestedResourceVotersForIdentityQuery): Promise<any> {
async contestedResourceVotersForIdentity(query: wasm.ContestedResourceVotersForIdentityQuery): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getContestedResourceVotersForIdentity(query);
}

async contestedResourceVotersForIdentityWithProof(query: ContestedResourceVotersForIdentityQuery): Promise<any> {
async contestedResourceVotersForIdentityWithProof(query: wasm.ContestedResourceVotersForIdentityQuery): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getContestedResourceVotersForIdentityWithProofInfo(query);
}
Expand Down
Loading
Loading