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
2 changes: 1 addition & 1 deletion .github/workflows/tests-build-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
build-js:
name: Build JS
runs-on: ubuntu-24.04
timeout-minutes: 10
timeout-minutes: 15
steps:
- uses: softwareforgood/check-artifact-v4-existence@v0
id: check-artifact
Expand Down
86 changes: 86 additions & 0 deletions packages/js-evo-sdk/src/group/facade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,92 @@ export class GroupFacade {
private sdk: EvoSDK;
constructor(sdk: EvoSDK) { this.sdk = sdk; }

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

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

async infos(contractId: string, startAtInfo?: unknown, count?: number): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getGroupInfos(contractId, startAtInfo ?? null, count ?? null);
}

async infosWithProof(contractId: string, startAtInfo?: unknown, count?: number): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getGroupInfosWithProofInfo(contractId, startAtInfo ?? null, count ?? null);
}

async members(contractId: string, groupContractPosition: number, opts: { memberIds?: string[]; startAt?: string; limit?: number } = {}): Promise<any> {
const { memberIds, startAt, limit } = opts;
const w = await this.sdk.getWasmSdkConnected();
return w.getGroupMembers(contractId, groupContractPosition, memberIds ?? null, startAt ?? null, limit ?? null);
}

async membersWithProof(contractId: string, groupContractPosition: number, opts: { memberIds?: string[]; startAt?: string; limit?: number } = {}): Promise<any> {
const { memberIds, startAt, limit } = opts;
const w = await this.sdk.getWasmSdkConnected();
return w.getGroupMembersWithProofInfo(contractId, groupContractPosition, memberIds ?? null, startAt ?? null, limit ?? null);
}

async identityGroups(identityId: string, opts: { memberDataContracts?: string[]; ownerDataContracts?: string[]; moderatorDataContracts?: string[] } = {}): Promise<any> {
const { memberDataContracts, ownerDataContracts, moderatorDataContracts } = opts;
const w = await this.sdk.getWasmSdkConnected();
return w.getIdentityGroups(
identityId,
memberDataContracts ?? null,
ownerDataContracts ?? null,
moderatorDataContracts ?? null,
);
}

async identityGroupsWithProof(identityId: string, opts: { memberDataContracts?: string[]; ownerDataContracts?: string[]; moderatorDataContracts?: string[] } = {}): Promise<any> {
const { memberDataContracts, ownerDataContracts, moderatorDataContracts } = opts;
const w = await this.sdk.getWasmSdkConnected();
return w.getIdentityGroupsWithProofInfo(
identityId,
memberDataContracts ?? null,
ownerDataContracts ?? null,
moderatorDataContracts ?? null,
);
}

async actions(contractId: string, groupContractPosition: number, status: string, opts: { startAtInfo?: unknown; count?: number } = {}): Promise<any> {
const { startAtInfo, count } = opts;
const w = await this.sdk.getWasmSdkConnected();
return w.getGroupActions(contractId, groupContractPosition, status, startAtInfo ?? null, count ?? null);
}

async actionsWithProof(contractId: string, groupContractPosition: number, status: string, opts: { startAtInfo?: unknown; count?: number } = {}): Promise<any> {
const { startAtInfo, count } = opts;
const w = await this.sdk.getWasmSdkConnected();
return w.getGroupActionsWithProofInfo(contractId, groupContractPosition, status, startAtInfo ?? null, count ?? null);
}

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

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

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

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

async contestedResources(params: { documentTypeName: string; contractId: string; indexName: string; startAtValue?: Uint8Array; limit?: number; orderAscending?: boolean }): Promise<any> {
const { documentTypeName, contractId, indexName, startAtValue, limit, orderAscending } = params;
const w = await this.sdk.getWasmSdkConnected();
Expand Down
108 changes: 108 additions & 0 deletions packages/js-evo-sdk/src/identities/facade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,114 @@ export class IdentitiesFacade {
);
}

async getKeysWithProof(args: { identityId: string; keyRequestType: 'all' | 'specific' | 'search'; specificKeyIds?: number[]; limit?: number; offset?: number }): Promise<any> {
const { identityId, keyRequestType, specificKeyIds, limit, offset } = args;
const w = await this.sdk.getWasmSdkConnected();
return w.getIdentityKeysWithProofInfo(
identityId,
keyRequestType,
specificKeyIds ? Uint32Array.from(specificKeyIds) : null,
limit ?? null,
offset ?? null,
);
}
Comment thread
shumkov marked this conversation as resolved.

async nonce(identityId: string): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getIdentityNonce(identityId);
}

async nonceWithProof(identityId: string): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getIdentityNonceWithProofInfo(identityId);
}

async contractNonce(identityId: string, contractId: string): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getIdentityContractNonce(identityId, contractId);
}

async contractNonceWithProof(identityId: string, contractId: string): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getIdentityContractNonceWithProofInfo(identityId, contractId);
}

async balance(identityId: string): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getIdentityBalance(identityId);
}

async balanceWithProof(identityId: string): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getIdentityBalanceWithProofInfo(identityId);
}

async balances(identityIds: string[]): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getIdentitiesBalances(identityIds);
}

async balancesWithProof(identityIds: string[]): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getIdentitiesBalancesWithProofInfo(identityIds);
}

async balanceAndRevision(identityId: string): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getIdentityBalanceAndRevision(identityId);
}

async balanceAndRevisionWithProof(identityId: string): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getIdentityBalanceAndRevisionWithProofInfo(identityId);
}

async byPublicKeyHash(publicKeyHash: string): Promise<wasm.IdentityWasm> {
const w = await this.sdk.getWasmSdkConnected();
return w.getIdentityByPublicKeyHash(publicKeyHash);
}

async byPublicKeyHashWithProof(publicKeyHash: string): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getIdentityByPublicKeyHashWithProofInfo(publicKeyHash);
}

async byNonUniquePublicKeyHash(publicKeyHash: string, opts: { startAfter?: string } = {}): Promise<any> {
const { startAfter } = opts;
const w = await this.sdk.getWasmSdkConnected();
return w.getIdentityByNonUniquePublicKeyHash(publicKeyHash, startAfter ?? null);
}

async byNonUniquePublicKeyHashWithProof(publicKeyHash: string, opts: { startAfter?: string } = {}): Promise<any> {
const { startAfter } = opts;
const w = await this.sdk.getWasmSdkConnected();
return w.getIdentityByNonUniquePublicKeyHashWithProofInfo(publicKeyHash, startAfter ?? null);
}

async contractKeys(args: { identityIds: string[]; contractId: string; purposes?: number[] }): Promise<any> {
const { identityIds, contractId, purposes } = args;
const purposesArray = purposes && purposes.length > 0 ? Uint32Array.from(purposes) : null;
const w = await this.sdk.getWasmSdkConnected();
return w.getIdentitiesContractKeys(identityIds, contractId, purposesArray);
}

async contractKeysWithProof(args: { identityIds: string[]; contractId: string; purposes?: number[] }): Promise<any> {
const { identityIds, contractId, purposes } = args;
const purposesArray = purposes && purposes.length > 0 ? Uint32Array.from(purposes) : null;
const w = await this.sdk.getWasmSdkConnected();
return w.getIdentitiesContractKeysWithProofInfo(identityIds, contractId, purposesArray);
}

async tokenBalances(identityId: string, tokenIds: string[]): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getIdentityTokenBalances(identityId, tokenIds);
}

async tokenBalancesWithProof(identityId: string, tokenIds: string[]): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getIdentityTokenBalancesWithProofInfo(identityId, tokenIds);
}

async create(args: { assetLockProof: unknown; assetLockPrivateKeyWif: string; publicKeys: unknown[] }): Promise<any> {
const { assetLockProof, assetLockPrivateKeyWif, publicKeys } = args;
const w = await this.sdk.getWasmSdkConnected();
Expand Down
16 changes: 14 additions & 2 deletions packages/js-evo-sdk/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export class EvoSDK {
public system!: SystemFacade;
public group!: GroupFacade;
public voting!: VotingFacade;

constructor(options: EvoSDKOptions = {}) {
// Apply defaults while preserving any future connection options
const { network = 'testnet', trusted = false, ...connection } = options;
Expand Down Expand Up @@ -113,6 +112,18 @@ export class EvoSDK {
return sdk;
}

version(): number {
return this.wasm.version();
}

static setLogLevel(levelOrFilter: string): void {
wasm.WasmSdk.setLogLevel(levelOrFilter);
}

static getLatestVersionNumber(): number {
return wasm.WasmSdkBuilder.getLatestVersionNumber();
}

// Factory helpers that return configured instances (not connected)
static testnet(options: ConnectionOptions = {}): EvoSDK { return new EvoSDK({ network: 'testnet', ...options }); }
static mainnet(options: ConnectionOptions = {}): EvoSDK { return new EvoSDK({ network: 'mainnet', ...options }); }
Expand All @@ -130,4 +141,5 @@ export { ProtocolFacade } from './protocol/facade.js';
export { SystemFacade } from './system/facade.js';
export { GroupFacade } from './group/facade.js';
export { VotingFacade } from './voting/facade.js';
// For error types, import directly from '@dashevo/wasm-sdk/errors'
export { wallet } from './wallet/functions.js';
export { verifyIdentityResponse, verifyDataContract, verifyDocuments, start } from './wasm.js';
Comment thread
shumkov marked this conversation as resolved.
15 changes: 15 additions & 0 deletions packages/js-evo-sdk/src/tokens/facade.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as wasm from '../wasm.js';
import { asJsonString } from '../util.js';
import type { EvoSDK } from '../sdk.js';

Expand All @@ -8,6 +9,10 @@ export class TokensFacade {
this.sdk = sdk;
}

calculateId(contractId: string, tokenPosition: number): string {
return wasm.WasmSdk.calculateTokenIdFromContract(contractId, tokenPosition);
}

// Queries
async priceByContract(contractId: string, tokenPosition: number): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
Expand Down Expand Up @@ -44,6 +49,16 @@ export class TokensFacade {
return w.getIdentitiesTokenBalancesWithProofInfo(identityIds, tokenId);
}

async identityBalances(identityId: string, tokenIds: string[]): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getIdentityTokenBalances(identityId, tokenIds);
}

async identityBalancesWithProof(identityId: string, tokenIds: string[]): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getIdentityTokenBalancesWithProofInfo(identityId, tokenIds);
}

async identityTokenInfos(identityId: string, tokenIds: string[], _opts: { limit?: number; offset?: number } = {}): Promise<any> {
const w = await this.sdk.getWasmSdkConnected();
return w.getIdentityTokenInfos(identityId, tokenIds);
Expand Down
99 changes: 99 additions & 0 deletions packages/js-evo-sdk/src/wallet/functions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import * as wasm from '../wasm.js';

export namespace wallet {
export function generateMnemonic(wordCount?: number, languageCode?: string): string {
return wasm.WasmSdk.generateMnemonic(wordCount ?? null, languageCode ?? null);
}

export function validateMnemonic(mnemonic: string, languageCode?: string): boolean {
return wasm.WasmSdk.validateMnemonic(mnemonic, languageCode ?? null);
}

export function mnemonicToSeed(mnemonic: string, passphrase?: string): Uint8Array {
return wasm.WasmSdk.mnemonicToSeed(mnemonic, passphrase ?? null);
}

export function deriveKeyFromSeedPhrase(mnemonic: string, passphrase: string | null | undefined, network: string): any {
return wasm.WasmSdk.deriveKeyFromSeedPhrase(mnemonic, passphrase ?? null, network);
}

export function deriveKeyFromSeedWithPath(mnemonic: string, passphrase: string | null | undefined, path: string, network: string): any {
return wasm.WasmSdk.deriveKeyFromSeedWithPath(mnemonic, passphrase ?? null, path, network);
}

export function deriveKeyFromSeedWithExtendedPath(mnemonic: string, passphrase: string | null | undefined, path: string, network: string): any {
return wasm.WasmSdk.deriveKeyFromSeedWithExtendedPath(mnemonic, passphrase ?? null, path, network);
}
Comment thread
shumkov marked this conversation as resolved.

export function deriveDashpayContactKey(mnemonic: string, passphrase: string | null | undefined, senderIdentityId: string, receiverIdentityId: string, account: number, addressIndex: number, network: string): any {
return wasm.WasmSdk.deriveDashpayContactKey(
mnemonic,
passphrase ?? null,
senderIdentityId,
receiverIdentityId,
account,
addressIndex,
network,
);
}

export function derivationPathBip44Mainnet(account: number, change: number, index: number): any {
return wasm.WasmSdk.derivationPathBip44Mainnet(account, change, index);
}

export function derivationPathBip44Testnet(account: number, change: number, index: number): any {
return wasm.WasmSdk.derivationPathBip44Testnet(account, change, index);
}

export function derivationPathDip9Mainnet(featureType: number, account: number, index: number): any {
return wasm.WasmSdk.derivationPathDip9Mainnet(featureType, account, index);
}

export function derivationPathDip9Testnet(featureType: number, account: number, index: number): any {
return wasm.WasmSdk.derivationPathDip9Testnet(featureType, account, index);
}

export function derivationPathDip13Mainnet(account: number): any {
return wasm.WasmSdk.derivationPathDip13Mainnet(account);
}

export function derivationPathDip13Testnet(account: number): any {
return wasm.WasmSdk.derivationPathDip13Testnet(account);
}

export function deriveChildPublicKey(xpub: string, index: number, hardened: boolean): string {
return wasm.WasmSdk.deriveChildPublicKey(xpub, index, hardened);
}

export function xprvToXpub(xprv: string): string {
return wasm.WasmSdk.xprvToXpub(xprv);
}

export function generateKeyPair(network: string): any {
return wasm.WasmSdk.generateKeyPair(network);
}

export function generateKeyPairs(network: string, count: number): any[] {
return wasm.WasmSdk.generateKeyPairs(network, count);
}

export function keyPairFromWif(privateKeyWif: string): any {
return wasm.WasmSdk.keyPairFromWif(privateKeyWif);
}

export function keyPairFromHex(privateKeyHex: string, network: string): any {
return wasm.WasmSdk.keyPairFromHex(privateKeyHex, network);
}

export function pubkeyToAddress(pubkeyHex: string, network: string): string {
return wasm.WasmSdk.pubkeyToAddress(pubkeyHex, network);
}

export function validateAddress(address: string, network: string): boolean {
return wasm.WasmSdk.validateAddress(address, network);
}

export function signMessage(message: string, privateKeyWif: string): string {
return wasm.WasmSdk.signMessage(message, privateKeyWif);
}
}
1 change: 0 additions & 1 deletion packages/js-evo-sdk/tests/functional/documents.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { expect } from 'chai';
import { EvoSDK } from '../../dist/evo-sdk.module.js';
import { TEST_IDS } from '../fixtures/testnet.mjs';

Expand Down
1 change: 0 additions & 1 deletion packages/js-evo-sdk/tests/functional/dpns.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { expect } from 'chai';
import { EvoSDK } from '../../dist/evo-sdk.module.js';
import { TEST_IDS } from '../fixtures/testnet.mjs';

Expand Down
1 change: 0 additions & 1 deletion packages/js-evo-sdk/tests/functional/epoch.spec.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { expect } from 'chai';
import { EvoSDK } from '../../dist/evo-sdk.module.js';
import { TEST_IDS } from '../fixtures/testnet.mjs';

Expand Down
Loading
Loading