|
| 1 | +// Sinon-based stub for '@dashevo/wasm-sdk' used by unit tests |
| 2 | +// Lightweight stub for '@dashevo/wasm-sdk' used by Karma unit tests |
| 3 | +// Returns structured records and tracks calls for verification without external libs. |
| 4 | + |
| 5 | +const calls = []; |
| 6 | +const record = (name, args) => ({ __stub: true, called: name, args: Array.from(args) }); |
| 7 | + |
| 8 | +export default async function initWasmSdk() { return undefined; } |
| 9 | + |
| 10 | +export function __getCalls() { return calls.slice(); } |
| 11 | +export function __clearCalls() { calls.length = 0; } |
| 12 | + |
| 13 | +// Minimal builder used by EvoSDK.connect() |
| 14 | +export class WasmSdkBuilder { |
| 15 | + static new_testnet() { return new WasmSdkBuilder('testnet', false); } |
| 16 | + static new_mainnet() { return new WasmSdkBuilder('mainnet', false); } |
| 17 | + static new_testnet_trusted() { return new WasmSdkBuilder('testnet', true); } |
| 18 | + static new_mainnet_trusted() { return new WasmSdkBuilder('mainnet', true); } |
| 19 | + constructor(network, trusted) { this.network = network; this.trusted = trusted; } |
| 20 | + with_version() { return this; } |
| 21 | + with_proofs() { return this; } |
| 22 | + with_settings() { return this; } |
| 23 | + build() { return new WasmSdk(); } |
| 24 | +} |
| 25 | + |
| 26 | +export class WasmSdk {} |
| 27 | + |
| 28 | +// Documents |
| 29 | +export function get_documents(...args) { const r = record('get_documents', args); calls.push(r); return Promise.resolve(r); } |
| 30 | +export function get_documents_with_proof_info(...args) { const r = record('get_documents_with_proof_info', args); calls.push(r); return Promise.resolve(r); } |
| 31 | +export function get_document(...args) { const r = record('get_document', args); calls.push(r); return Promise.resolve(r); } |
| 32 | +export function get_document_with_proof_info(...args) { const r = record('get_document_with_proof_info', args); calls.push(r); return Promise.resolve(r); } |
| 33 | + |
| 34 | +// Identities |
| 35 | +export function identity_fetch(...args) { const r = record('identity_fetch', args); calls.push(r); return Promise.resolve(r); } |
| 36 | +export function identity_fetch_with_proof_info(...args) { const r = record('identity_fetch_with_proof_info', args); calls.push(r); return Promise.resolve(r); } |
| 37 | +export function identity_fetch_unproved(...args) { const r = record('identity_fetch_unproved', args); calls.push(r); return Promise.resolve(r); } |
| 38 | +export function get_identity_keys(...args) { const r = record('get_identity_keys', args); calls.push(r); return Promise.resolve(r); } |
| 39 | + |
| 40 | +// Contracts |
| 41 | +export function data_contract_fetch(...args) { const r = record('data_contract_fetch', args); calls.push(r); return Promise.resolve(r); } |
| 42 | +export function data_contract_fetch_with_proof_info(...args) { const r = record('data_contract_fetch_with_proof_info', args); calls.push(r); return Promise.resolve(r); } |
| 43 | +export function get_data_contract_history(...args) { const r = record('get_data_contract_history', args); calls.push(r); return Promise.resolve(r); } |
| 44 | +export function get_data_contract_history_with_proof_info(...args) { const r = record('get_data_contract_history_with_proof_info', args); calls.push(r); return Promise.resolve(r); } |
| 45 | +export function get_data_contracts(...args) { const r = record('get_data_contracts', args); calls.push(r); return Promise.resolve(r); } |
| 46 | +export function get_data_contracts_with_proof_info(...args) { const r = record('get_data_contracts_with_proof_info', args); calls.push(r); return Promise.resolve(r); } |
| 47 | + |
| 48 | +// Tokens (queries) |
| 49 | +export function get_token_price_by_contract(...args) { const r = record('get_token_price_by_contract', args); calls.push(r); return Promise.resolve(r); } |
| 50 | +export function get_token_total_supply(...args) { const r = record('get_token_total_supply', args); calls.push(r); return Promise.resolve(r); } |
| 51 | +export function get_token_total_supply_with_proof_info(...args) { const r = record('get_token_total_supply_with_proof_info', args); calls.push(r); return Promise.resolve(r); } |
| 52 | +export function get_token_statuses(...args) { const r = record('get_token_statuses', args); calls.push(r); return Promise.resolve(r); } |
| 53 | +export function get_token_statuses_with_proof_info(...args) { const r = record('get_token_statuses_with_proof_info', args); calls.push(r); return Promise.resolve(r); } |
| 54 | +export function get_identities_token_balances(...args) { const r = record('get_identities_token_balances', args); calls.push(r); return Promise.resolve(r); } |
| 55 | +export function get_identities_token_balances_with_proof_info(...args) { const r = record('get_identities_token_balances_with_proof_info', args); calls.push(r); return Promise.resolve(r); } |
| 56 | +export function get_identity_token_infos(...args) { const r = record('get_identity_token_infos', args); calls.push(r); return Promise.resolve(r); } |
| 57 | +export function get_identities_token_infos(...args) { const r = record('get_identities_token_infos', args); calls.push(r); return Promise.resolve(r); } |
| 58 | +export function get_identity_token_infos_with_proof_info(...args) { const r = record('get_identity_token_infos_with_proof_info', args); calls.push(r); return Promise.resolve(r); } |
| 59 | +export function get_identities_token_infos_with_proof_info(...args) { const r = record('get_identities_token_infos_with_proof_info', args); calls.push(r); return Promise.resolve(r); } |
| 60 | +export function get_token_direct_purchase_prices(...args) { const r = record('get_token_direct_purchase_prices', args); calls.push(r); return Promise.resolve(r); } |
| 61 | +export function get_token_direct_purchase_prices_with_proof_info(...args) { const r = record('get_token_direct_purchase_prices_with_proof_info', args); calls.push(r); return Promise.resolve(r); } |
| 62 | +export function get_token_contract_info(...args) { const r = record('get_token_contract_info', args); calls.push(r); return Promise.resolve(r); } |
| 63 | +export function get_token_contract_info_with_proof_info(...args) { const r = record('get_token_contract_info_with_proof_info', args); calls.push(r); return Promise.resolve(r); } |
| 64 | +export function get_token_perpetual_distribution_last_claim(...args) { const r = record('get_token_perpetual_distribution_last_claim', args); calls.push(r); return Promise.resolve(r); } |
| 65 | +export function get_token_perpetual_distribution_last_claim_with_proof_info(...args) { const r = record('get_token_perpetual_distribution_last_claim_with_proof_info', args); calls.push(r); return Promise.resolve(r); } |
| 66 | + |
| 67 | +// DPNS helpers (pure) |
| 68 | +export function dpns_convert_to_homograph_safe(input) { return String(input).toLowerCase(); } |
| 69 | +export function dpns_is_valid_username(label) { return /^[a-z0-9-_]{3,63}$/.test(String(label)); } |
| 70 | +export function dpns_is_contested_username(label) { return false; } |
| 71 | +export function dpns_is_name_available(...args) { const r = record('dpns_is_name_available', args); calls.push(r); return Promise.resolve(true); } |
| 72 | +export function dpns_resolve_name(...args) { const r = record('dpns_resolve_name', args); calls.push(r); return Promise.resolve(r); } |
| 73 | +export function dpns_register_name(...args) { const r = record('dpns_register_name', args); calls.push(r); return Promise.resolve(r); } |
| 74 | +export function get_dpns_usernames(...args) { const r = record('get_dpns_usernames', args); calls.push(r); return Promise.resolve(r); } |
| 75 | +export function get_dpns_username(...args) { const r = record('get_dpns_username', args); calls.push(r); return Promise.resolve(r); } |
| 76 | +export function get_dpns_usernames_with_proof_info(...args) { const r = record('get_dpns_usernames_with_proof_info', args); calls.push(r); return Promise.resolve(r); } |
| 77 | +export function get_dpns_username_with_proof_info(...args) { const r = record('get_dpns_username_with_proof_info', args); calls.push(r); return Promise.resolve(r); } |
| 78 | +export function get_dpns_username_by_name(...args) { const r = record('get_dpns_username_by_name', args); calls.push(r); return Promise.resolve(r); } |
| 79 | +export function get_dpns_username_by_name_with_proof_info(...args) { const r = record('get_dpns_username_by_name_with_proof_info', args); calls.push(r); return Promise.resolve(r); } |
| 80 | + |
| 81 | +// Epoch |
| 82 | +export function get_epochs_info(...args) { const r = record('get_epochs_info', args); calls.push(r); return Promise.resolve(r); } |
| 83 | +export function get_epochs_info_with_proof_info(...args) { const r = record('get_epochs_info_with_proof_info', args); calls.push(r); return Promise.resolve(r); } |
| 84 | +export function get_finalized_epoch_infos(...args) { const r = record('get_finalized_epoch_infos', args); calls.push(r); return Promise.resolve(r); } |
| 85 | +export function get_finalized_epoch_infos_with_proof_info(...args) { const r = record('get_finalized_epoch_infos_with_proof_info', args); calls.push(r); return Promise.resolve(r); } |
| 86 | +export function get_current_epoch(...args) { const r = record('get_current_epoch', args); calls.push(r); return Promise.resolve(r); } |
| 87 | +export function get_current_epoch_with_proof_info(...args) { const r = record('get_current_epoch_with_proof_info', args); calls.push(r); return Promise.resolve(r); } |
| 88 | +export function get_evonodes_proposed_epoch_blocks_by_ids(...args) { const r = record('get_evonodes_proposed_epoch_blocks_by_ids', args); calls.push(r); return Promise.resolve(r); } |
| 89 | +export function get_evonodes_proposed_epoch_blocks_by_ids_with_proof_info(...args) { const r = record('get_evonodes_proposed_epoch_blocks_by_ids_with_proof_info', args); calls.push(r); return Promise.resolve(r); } |
| 90 | +export function get_evonodes_proposed_epoch_blocks_by_range(...args) { const r = record('get_evonodes_proposed_epoch_blocks_by_range', args); calls.push(r); return Promise.resolve(r); } |
| 91 | +export function get_evonodes_proposed_epoch_blocks_by_range_with_proof_info(...args) { const r = record('get_evonodes_proposed_epoch_blocks_by_range_with_proof_info', args); calls.push(r); return Promise.resolve(r); } |
| 92 | + |
| 93 | +// Protocol |
| 94 | +export function get_protocol_version_upgrade_state(...args) { const r = record('get_protocol_version_upgrade_state', args); calls.push(r); return Promise.resolve(r); } |
| 95 | +export function get_protocol_version_upgrade_state_with_proof_info(...args) { const r = record('get_protocol_version_upgrade_state_with_proof_info', args); calls.push(r); return Promise.resolve(r); } |
| 96 | +export function get_protocol_version_upgrade_vote_status(...args) { const r = record('get_protocol_version_upgrade_vote_status', args); calls.push(r); return Promise.resolve(r); } |
| 97 | +export function get_protocol_version_upgrade_vote_status_with_proof_info(...args) { const r = record('get_protocol_version_upgrade_vote_status_with_proof_info', args); calls.push(r); return Promise.resolve(r); } |
| 98 | + |
| 99 | +// System |
| 100 | +export function get_status(...args) { const r = record('get_status', args); calls.push(r); return Promise.resolve(r); } |
| 101 | +export function get_current_quorums_info(...args) { const r = record('get_current_quorums_info', args); calls.push(r); return Promise.resolve(r); } |
| 102 | +export function get_total_credits_in_platform(...args) { const r = record('get_total_credits_in_platform', args); calls.push(r); return Promise.resolve(r); } |
| 103 | +export function get_total_credits_in_platform_with_proof_info(...args) { const r = record('get_total_credits_in_platform_with_proof_info', args); calls.push(r); return Promise.resolve(r); } |
| 104 | +export function get_prefunded_specialized_balance(...args) { const r = record('get_prefunded_specialized_balance', args); calls.push(r); return Promise.resolve(r); } |
| 105 | +export function get_prefunded_specialized_balance_with_proof_info(...args) { const r = record('get_prefunded_specialized_balance_with_proof_info', args); calls.push(r); return Promise.resolve(r); } |
| 106 | +export function wait_for_state_transition_result(...args) { const r = record('wait_for_state_transition_result', args); calls.push(r); return Promise.resolve(r); } |
| 107 | +export function get_path_elements(...args) { const r = record('get_path_elements', args); calls.push(r); return Promise.resolve(r); } |
| 108 | +export function get_path_elements_with_proof_info(...args) { const r = record('get_path_elements_with_proof_info', args); calls.push(r); return Promise.resolve(r); } |
| 109 | + |
| 110 | +// Group |
| 111 | +export function get_contested_resources(...args) { const r = record('get_contested_resources', args); calls.push(r); return Promise.resolve(r); } |
| 112 | +export function get_contested_resources_with_proof_info(...args) { const r = record('get_contested_resources_with_proof_info', args); calls.push(r); return Promise.resolve(r); } |
| 113 | +export function get_contested_resource_voters_for_identity(...args) { const r = record('get_contested_resource_voters_for_identity', args); calls.push(r); return Promise.resolve(r); } |
| 114 | +export function get_contested_resource_voters_for_identity_with_proof_info(...args) { const r = record('get_contested_resource_voters_for_identity_with_proof_info', args); calls.push(r); return Promise.resolve(r); } |
| 115 | + |
| 116 | +// Voting (queries) |
| 117 | +export function get_contested_resource_vote_state(...args) { const r = record('get_contested_resource_vote_state', args); calls.push(r); return Promise.resolve(r); } |
| 118 | +export function get_contested_resource_vote_state_with_proof_info(...args) { const r = record('get_contested_resource_vote_state_with_proof_info', args); calls.push(r); return Promise.resolve(r); } |
| 119 | +export function get_contested_resource_identity_votes(...args) { const r = record('get_contested_resource_identity_votes', args); calls.push(r); return Promise.resolve(r); } |
| 120 | +export function get_contested_resource_identity_votes_with_proof_info(...args) { const r = record('get_contested_resource_identity_votes_with_proof_info', args); calls.push(r); return Promise.resolve(r); } |
| 121 | +export function get_vote_polls_by_end_date(...args) { const r = record('get_vote_polls_by_end_date', args); calls.push(r); return Promise.resolve(r); } |
| 122 | +export function get_vote_polls_by_end_date_with_proof_info(...args) { const r = record('get_vote_polls_by_end_date_with_proof_info', args); calls.push(r); return Promise.resolve(r); } |
0 commit comments