Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
0129f34
refactor: updating state transition functions (first round)
shumkov Dec 28, 2025
19bc8d7
refactor: use try from options
shumkov Dec 29, 2025
b814dd6
refactor: more try_from_options
shumkov Dec 29, 2025
c68afb7
refactor: update document transition methods
shumkov Dec 29, 2025
e417618
refactor: varios improvements
shumkov Dec 29, 2025
8e32ff9
Merge branch 'v3.0-dev' into refactor/state-transition-methods
shumkov Dec 29, 2025
bc038a8
refactor: more improvements
shumkov Dec 29, 2025
a5f36ee
chore: functional tests and fixes
shumkov Dec 31, 2025
56db02e
chore: update evo sdk
shumkov Dec 31, 2025
a188c8b
test: fix types
shumkov Dec 31, 2025
62a12c8
Merge branch 'v3.0-dev' into refactor/state-transition-methods
shumkov Jan 8, 2026
1c9ae19
fix: document to document wasm conversion
shumkov Jan 9, 2026
65dcb34
refactor: linting, formatting, unused deps
shumkov Jan 9, 2026
16a6811
fix: non optional context and token transfer issue
shumkov Jan 9, 2026
d8adde9
reafactor: utilize TokenPricingScheduleWasm
shumkov Jan 9, 2026
cb04a1e
fix: missing identityKey
shumkov Jan 9, 2026
da87629
fix: missing owner id in TokenSetPriceResultWasm
shumkov Jan 9, 2026
8c03483
refactor: remove unused hextToBytes
shumkov Jan 9, 2026
a08ae7e
docs: invalid comment
shumkov Jan 9, 2026
7bec821
fix: missing inputs
shumkov Jan 9, 2026
fa8a84f
fix: clippy warnings
shumkov Jan 9, 2026
e289738
fix: handle overflow
shumkov Jan 9, 2026
49c9a6e
refactor: clippy warnings
shumkov Jan 9, 2026
f4e5748
refactor: fix linter warnings
shumkov Jan 9, 2026
9d5da13
fix: missin __type for singer
shumkov Jan 9, 2026
b69ceb6
refactor: fix linter warnings
shumkov Jan 9, 2026
d02130b
test: fix token test
shumkov Jan 9, 2026
41cee81
revert: bump revision on state transition creation
shumkov Jan 9, 2026
afd724c
docs: fix misleading comment
shumkov Jan 9, 2026
e5038bb
docs: update todo
shumkov Jan 9, 2026
f259086
test: remove unnecessary assertion
shumkov Jan 9, 2026
56167b8
style: fix formatting
shumkov Jan 10, 2026
6fa3212
Merge branch 'v3.0-dev' into refactor/state-transition-methods
shumkov Jan 12, 2026
a287c2b
test: fix functional tests
shumkov Jan 12, 2026
fadc028
test: one more fix
shumkov Jan 12, 2026
0a32a6d
test: add more delays for realability
shumkov Jan 12, 2026
0474779
refactor: make credits per identity public
shumkov Jan 12, 2026
24ec409
revert: bring back some logs
shumkov Jan 12, 2026
5644520
refactor: make constant public
shumkov Jan 12, 2026
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
11 changes: 4 additions & 7 deletions packages/js-evo-sdk/src/contracts/facade.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as wasm from '../wasm.js';
import { asJsonString } from '../util.js';
import type { EvoSDK } from '../sdk.js';

export class ContractsFacade {
Expand Down Expand Up @@ -39,15 +38,13 @@ export class ContractsFacade {
return w.getDataContractsWithProofInfo(contractIds);
}

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

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

export class DocumentsFacade {
Expand Down Expand Up @@ -30,69 +29,33 @@ export class DocumentsFacade {
return w.getDocumentWithProofInfo(contractId, type, documentId);
}

async create(args: {
contractId: wasm.IdentifierLike;
type: string;
ownerId: wasm.IdentifierLike;
data: unknown;
entropyHex: string;
privateKeyWif: string;
}): Promise<any> {
const { contractId, type, ownerId, data, entropyHex, privateKeyWif } = args;
async create(options: wasm.DocumentCreateOptions): Promise<void> {
const w = await this.sdk.getWasmSdkConnected();
return w.documentCreate(
contractId,
type,
ownerId,
asJsonString(data)!,
entropyHex,
privateKeyWif,
);
return w.documentCreate(options);
}

async replace(args: {
contractId: wasm.IdentifierLike;
type: string;
documentId: wasm.IdentifierLike;
ownerId: wasm.IdentifierLike;
data: unknown;
revision: number | bigint;
privateKeyWif: string;
}): Promise<any> {
const { contractId, type, documentId, ownerId, data, revision, privateKeyWif } = args;
async replace(options: wasm.DocumentReplaceOptions): Promise<void> {
const w = await this.sdk.getWasmSdkConnected();
return w.documentReplace(
contractId,
type,
documentId,
ownerId,
asJsonString(data)!,
BigInt(revision),
privateKeyWif,
);
return w.documentReplace(options);
}

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;
async delete(options: wasm.DocumentDeleteOptions): Promise<void> {
const w = await this.sdk.getWasmSdkConnected();
return w.documentDelete(contractId, type, documentId, ownerId, privateKeyWif);
return w.documentDelete(options);
}

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;
async transfer(options: wasm.DocumentTransferOptions): Promise<void> {
const w = await this.sdk.getWasmSdkConnected();
return w.documentTransfer(contractId, type, documentId, ownerId, recipientId, privateKeyWif);
return w.documentTransfer(options);
}

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;
async purchase(options: wasm.DocumentPurchaseOptions): Promise<void> {
const w = await this.sdk.getWasmSdkConnected();
return w.documentPurchase(contractId, type, documentId, buyerId, BigInt(price), privateKeyWif);
return w.documentPurchase(options);
}

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;
async setPrice(options: wasm.DocumentSetPriceOptions): Promise<void> {
const w = await this.sdk.getWasmSdkConnected();
return w.documentSetPrice(contractId, type, documentId, ownerId, BigInt(price), privateKeyWif);
return w.documentSetPrice(options);
}
}
31 changes: 10 additions & 21 deletions packages/js-evo-sdk/src/identities/facade.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as wasm from '../wasm.js';
import { asJsonString } from '../util.js';
import type { EvoSDK } from '../sdk.js';

export class IdentitiesFacade {
Expand Down Expand Up @@ -124,38 +123,28 @@ export class IdentitiesFacade {
return w.getIdentityTokenBalancesWithProofInfo(identityId, tokenIds);
}

async create(args: { assetLockProof: unknown; assetLockPrivateKeyWif: string; publicKeys: unknown[] }): Promise<any> {
const { assetLockProof, assetLockPrivateKeyWif, publicKeys } = args;
async create(options: wasm.IdentityCreateOptions): Promise<void> {
const w = await this.sdk.getWasmSdkConnected();
return w.identityCreate(asJsonString(assetLockProof)!, assetLockPrivateKeyWif, asJsonString(publicKeys)!);
return w.identityCreate(options);
}

async topUp(args: { identityId: wasm.IdentifierLike; assetLockProof: unknown; assetLockPrivateKeyWif: string }): Promise<any> {
const { identityId, assetLockProof, assetLockPrivateKeyWif } = args;
async topUp(options: wasm.IdentityTopUpOptions): Promise<bigint> {
const w = await this.sdk.getWasmSdkConnected();
return w.identityTopUp(identityId, asJsonString(assetLockProof)!, assetLockPrivateKeyWif);
return w.identityTopUp(options);
}

async creditTransfer(args: { senderId: wasm.IdentifierLike; recipientId: wasm.IdentifierLike; amount: number | bigint | string; privateKeyWif: string; keyId?: number }): Promise<any> {
const { senderId, recipientId, amount, privateKeyWif, keyId } = args;
async creditTransfer(options: wasm.IdentityCreditTransferOptions): Promise<wasm.IdentityCreditTransferResult> {
const w = await this.sdk.getWasmSdkConnected();
return w.identityCreditTransfer(senderId, recipientId, BigInt(amount), privateKeyWif, keyId ?? null);
return w.identityCreditTransfer(options);
}

async creditWithdrawal(args: { identityId: wasm.IdentifierLike; toAddress: string; amount: number | bigint | string; coreFeePerByte?: number; privateKeyWif: string; keyId?: number }): Promise<any> {
const { identityId, toAddress, amount, coreFeePerByte = 1, privateKeyWif, keyId } = args;
async creditWithdrawal(options: wasm.IdentityCreditWithdrawalOptions): Promise<bigint> {
const w = await this.sdk.getWasmSdkConnected();
return w.identityCreditWithdrawal(identityId, toAddress, BigInt(amount), coreFeePerByte ?? null, privateKeyWif, keyId ?? null);
return w.identityCreditWithdrawal(options);
}

async update(args: { identityId: wasm.IdentifierLike; addPublicKeys?: unknown[]; disablePublicKeyIds?: number[]; privateKeyWif: string }): Promise<any> {
const { identityId, addPublicKeys, disablePublicKeyIds, privateKeyWif } = args;
async update(options: wasm.IdentityUpdateOptions): Promise<void> {
const w = await this.sdk.getWasmSdkConnected();
return w.identityUpdate(
identityId,
addPublicKeys ? asJsonString(addPublicKeys)! : null,
disablePublicKeyIds ? Uint32Array.from(disablePublicKeyIds) : null,
privateKeyWif,
);
return w.identityUpdate(options);
}
}
51 changes: 20 additions & 31 deletions packages/js-evo-sdk/src/tokens/facade.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as wasm from '../wasm.js';
import { asJsonString } from '../util.js';
import type { EvoSDK } from '../sdk.js';

export class TokensFacade {
Expand Down Expand Up @@ -111,63 +110,53 @@ export class TokensFacade {
}

// Transitions
async mint(args: { contractId: wasm.IdentifierLike; tokenPosition: number; amount: number | string | bigint; identityId: wasm.IdentifierLike; privateKeyWif: string; recipientId?: wasm.IdentifierLike; publicNote?: string }): Promise<any> {
const { contractId, tokenPosition, amount, identityId, privateKeyWif, recipientId, publicNote } = args;
async mint(options: wasm.TokenMintOptions): Promise<wasm.TokenMintResult> {
const w = await this.sdk.getWasmSdkConnected();
return w.tokenMint(contractId, tokenPosition, String(amount), identityId, privateKeyWif, recipientId, publicNote ?? null);
return w.tokenMint(options);
}

async burn(args: { contractId: wasm.IdentifierLike; tokenPosition: number; amount: number | string | bigint; identityId: wasm.IdentifierLike; privateKeyWif: string; publicNote?: string }): Promise<any> {
const { contractId, tokenPosition, amount, identityId, privateKeyWif, publicNote } = args;
async burn(options: wasm.TokenBurnOptions): Promise<wasm.TokenBurnResult> {
const w = await this.sdk.getWasmSdkConnected();
return w.tokenBurn(contractId, tokenPosition, String(amount), identityId, privateKeyWif, publicNote ?? null);
return w.tokenBurn(options);
}

async transfer(args: { contractId: wasm.IdentifierLike; tokenPosition: number; amount: number | string | bigint; senderId: wasm.IdentifierLike; recipientId: wasm.IdentifierLike; privateKeyWif: string; publicNote?: string }): Promise<any> {
const { contractId, tokenPosition, amount, senderId, recipientId, privateKeyWif, publicNote } = args;
async transfer(options: wasm.TokenTransferOptions): Promise<wasm.TokenTransferResult> {
const w = await this.sdk.getWasmSdkConnected();
return w.tokenTransfer(contractId, tokenPosition, String(amount), senderId, recipientId, privateKeyWif, publicNote ?? null);
return w.tokenTransfer(options);
}

async freeze(args: { contractId: wasm.IdentifierLike; tokenPosition: number; identityToFreeze: wasm.IdentifierLike; freezerId: wasm.IdentifierLike; privateKeyWif: string; publicNote?: string }): Promise<any> {
const { contractId, tokenPosition, identityToFreeze, freezerId, privateKeyWif, publicNote } = args;
async freeze(options: wasm.TokenFreezeOptions): Promise<wasm.TokenFreezeResult> {
const w = await this.sdk.getWasmSdkConnected();
return w.tokenFreeze(contractId, tokenPosition, identityToFreeze, freezerId, privateKeyWif, publicNote ?? null);
return w.tokenFreeze(options);
}

async unfreeze(args: { contractId: wasm.IdentifierLike; tokenPosition: number; identityToUnfreeze: wasm.IdentifierLike; unfreezerId: wasm.IdentifierLike; privateKeyWif: string; publicNote?: string }): Promise<any> {
const { contractId, tokenPosition, identityToUnfreeze, unfreezerId, privateKeyWif, publicNote } = args;
async unfreeze(options: wasm.TokenUnfreezeOptions): Promise<wasm.TokenUnfreezeResult> {
const w = await this.sdk.getWasmSdkConnected();
return w.tokenUnfreeze(contractId, tokenPosition, identityToUnfreeze, unfreezerId, privateKeyWif, publicNote ?? null);
return w.tokenUnfreeze(options);
}

async destroyFrozen(args: { contractId: wasm.IdentifierLike; tokenPosition: number; identityId: wasm.IdentifierLike; destroyerId: wasm.IdentifierLike; privateKeyWif: string; publicNote?: string }): Promise<any> {
const { contractId, tokenPosition, identityId, destroyerId, privateKeyWif, publicNote } = args;
async destroyFrozen(options: wasm.TokenDestroyFrozenOptions): Promise<wasm.TokenDestroyFrozenResult> {
const w = await this.sdk.getWasmSdkConnected();
return w.tokenDestroyFrozen(contractId, tokenPosition, identityId, destroyerId, privateKeyWif, publicNote ?? null);
return w.tokenDestroyFrozen(options);
}

async setPriceForDirectPurchase(args: { contractId: wasm.IdentifierLike; tokenPosition: number; identityId: wasm.IdentifierLike; priceType: string; priceData: unknown; privateKeyWif: string; publicNote?: string }): Promise<any> {
const { contractId, tokenPosition, identityId, priceType, priceData, privateKeyWif, publicNote } = args;
async emergencyAction(options: wasm.TokenEmergencyActionOptions): Promise<wasm.TokenEmergencyActionResult> {
const w = await this.sdk.getWasmSdkConnected();
return w.tokenSetPriceForDirectPurchase(contractId, tokenPosition, identityId, priceType, asJsonString(priceData)!, privateKeyWif, publicNote ?? null);
return w.tokenEmergencyAction(options);
}

async directPurchase(args: { contractId: wasm.IdentifierLike; tokenPosition: number; amount: number | string | bigint; identityId: wasm.IdentifierLike; totalAgreedPrice?: number | string | bigint | null; privateKeyWif: string }): Promise<any> {
const { contractId, tokenPosition, amount, identityId, totalAgreedPrice, privateKeyWif } = args;
async setPrice(options: wasm.TokenSetPriceOptions): Promise<wasm.TokenSetPriceResult> {
const w = await this.sdk.getWasmSdkConnected();
return w.tokenDirectPurchase(contractId, tokenPosition, String(amount), identityId, totalAgreedPrice != null ? String(totalAgreedPrice) : null, privateKeyWif);
return w.tokenSetPrice(options);
}

async claim(args: { contractId: wasm.IdentifierLike; tokenPosition: number; distributionType: string; identityId: wasm.IdentifierLike; privateKeyWif: string; publicNote?: string }): Promise<any> {
const { contractId, tokenPosition, distributionType, identityId, privateKeyWif, publicNote } = args;
async directPurchase(options: wasm.TokenDirectPurchaseOptions): Promise<wasm.TokenDirectPurchaseResult> {
const w = await this.sdk.getWasmSdkConnected();
return w.tokenClaim(contractId, tokenPosition, distributionType, identityId, privateKeyWif, publicNote ?? null);
return w.tokenDirectPurchase(options);
}

async configUpdate(args: { contractId: wasm.IdentifierLike; tokenPosition: number; configItemType: string; configValue: unknown; identityId: wasm.IdentifierLike; privateKeyWif: string; publicNote?: string }): Promise<any> {
const { contractId, tokenPosition, configItemType, configValue, identityId, privateKeyWif, publicNote } = args;
async claim(options: wasm.TokenClaimOptions): Promise<wasm.TokenClaimResult> {
const w = await this.sdk.getWasmSdkConnected();
return w.tokenConfigUpdate(contractId, tokenPosition, configItemType, asJsonString(configValue)!, identityId, privateKeyWif, publicNote ?? null);
return w.tokenClaim(options);
}
}
5 changes: 0 additions & 5 deletions packages/js-evo-sdk/src/util.ts

This file was deleted.

7 changes: 2 additions & 5 deletions packages/js-evo-sdk/src/voting/facade.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as wasm from '../wasm.js';
import { asJsonString } from '../util.js';
import type { EvoSDK } from '../sdk.js';

export class VotingFacade {
Expand Down Expand Up @@ -38,10 +37,8 @@ export class VotingFacade {
return w.getVotePollsByEndDateWithProofInfo(query ?? null);
}

async masternodeVote(args: { masternodeProTxHash: string; contractId: wasm.IdentifierLike; documentTypeName: string; indexName: string; indexValues: string | any[]; voteChoice: string; votingKeyWif: string }): Promise<any> {
const { masternodeProTxHash, contractId, documentTypeName, indexName, indexValues, voteChoice, votingKeyWif } = args;
const indexValuesStr = typeof indexValues === 'string' ? indexValues : asJsonString(indexValues)!;
async masternodeVote(options: wasm.MasternodeVoteOptions): Promise<void> {
const w = await this.sdk.getWasmSdkConnected();
return w.masternodeVote(masternodeProTxHash, contractId, documentTypeName, indexName, indexValuesStr, voteChoice, votingKeyWif);
return w.masternodeVote(options);
}
}
10 changes: 5 additions & 5 deletions packages/js-evo-sdk/tests/unit/facades/addresses.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ describe('AddressesFacade', () => {
expect(result.message).to.include('successfully');
});

it('topUpIdentity() forwards options to identityTopUpFromAddresses', async function () {
it('topUpIdentity() forwards options to identityTopUpFromAddresses', async function topUpTest() {
// Create mock address and result
const mockAddress = wasmSDKPackage.PlatformAddress.fromBytes(
new Uint8Array([0x00, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),
Expand All @@ -157,7 +157,7 @@ describe('AddressesFacade', () => {
expect(result.newBalance).to.equal(150000n);
});

it('withdraw() forwards options to addressFundsWithdraw', async function () {
it('withdraw() forwards options to addressFundsWithdraw', async function withdrawTest() {
// Create mock address and result map
const mockAddress = wasmSDKPackage.PlatformAddress.fromBytes(
new Uint8Array([0x00, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),
Expand Down Expand Up @@ -185,7 +185,7 @@ describe('AddressesFacade', () => {
expect(result).to.be.instanceOf(Map);
});

it('transferFromIdentity() forwards options to identityTransferToAddresses', async function () {
it('transferFromIdentity() forwards options to identityTransferToAddresses', async function transferFromIdentityTest() {
// Create mock address
const mockAddress = wasmSDKPackage.PlatformAddress.fromBytes(
new Uint8Array([0x00, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),
Expand All @@ -211,7 +211,7 @@ describe('AddressesFacade', () => {
expect(result.newBalance).to.equal(400000n);
});

it('fundFromAssetLock() forwards options to addressFundingFromAssetLock', async function () {
it('fundFromAssetLock() forwards options to addressFundingFromAssetLock', async function fundFromAssetLockTest() {
// Create mock address and result map
const mockAddress = wasmSDKPackage.PlatformAddress.fromBytes(
new Uint8Array([0x00, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),
Expand All @@ -235,7 +235,7 @@ describe('AddressesFacade', () => {
expect(result).to.be.instanceOf(Map);
});

it('createIdentity() forwards options to identityCreateFromAddresses', async function () {
it('createIdentity() forwards options to identityCreateFromAddresses', async function createIdentityTest() {
// Create mock address
const mockAddress = wasmSDKPackage.PlatformAddress.fromBytes(
new Uint8Array([0x00, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),
Expand Down
Loading
Loading