From 55ac60aabbb1c61e07d634d28ca5e648dd7f1cfa Mon Sep 17 00:00:00 2001 From: pasta Date: Thu, 16 Apr 2026 08:57:29 -0500 Subject: [PATCH 1/3] fix: add deadlines to platform funding transitions --- src/platform/identity.ts | 45 +++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/src/platform/identity.ts b/src/platform/identity.ts index f4aa33d..79b088f 100644 --- a/src/platform/identity.ts +++ b/src/platform/identity.ts @@ -41,6 +41,31 @@ function base64ToBytes(base64: string): Uint8Array { return bytes; } +const PLATFORM_REQUEST_SETTINGS = { + connectTimeoutMs: 10000, + timeoutMs: 20000, + retries: 2, + banFailedAddress: true, +} as const; + +const PLATFORM_PUT_SETTINGS = { + ...PLATFORM_REQUEST_SETTINGS, + waitTimeoutMs: 45000, +} as const; + +function createPlatformSdk( + network: 'testnet' | 'mainnet', + trusted: boolean +): EvoSDK { + const options = { settings: PLATFORM_REQUEST_SETTINGS }; + + if (network === 'mainnet') { + return trusted ? EvoSDK.mainnetTrusted(options) : EvoSDK.mainnet(options); + } + + return trusted ? EvoSDK.testnetTrusted(options) : EvoSDK.testnet(options); +} + /** * Identity key types as defined by Dash Platform */ @@ -150,9 +175,7 @@ export async function registerIdentity( retryOptions?: RetryOptions ): Promise<{ identityId: string; balance: number; revision: number }> { // Initialize SDK for the target network - const sdk = network === 'mainnet' - ? EvoSDK.mainnetTrusted() - : EvoSDK.testnetTrusted(); + const sdk = createPlatformSdk(network, true); // Connect to the network with retry console.log(`Connecting to ${network}...`); @@ -195,6 +218,7 @@ export async function registerIdentity( assetLockProof: proof, assetLockPrivateKey, signer, + settings: PLATFORM_PUT_SETTINGS, }), retryOptions ); @@ -231,9 +255,7 @@ export async function topUpIdentity( retryOptions?: RetryOptions ): Promise<{ success: boolean; balance?: number }> { // Initialize SDK for the target network (trusted mode required for identity fetch) - const sdk = network === 'mainnet' - ? EvoSDK.mainnetTrusted() - : EvoSDK.testnetTrusted(); + const sdk = createPlatformSdk(network, true); // Connect to the network with retry console.log(`Connecting to ${network}...`); @@ -261,6 +283,7 @@ export async function topUpIdentity( identity, assetLockProof: proof, assetLockPrivateKey, + settings: PLATFORM_PUT_SETTINGS, }), retryOptions ); @@ -309,9 +332,7 @@ export async function updateIdentity( retryOptions?: RetryOptions ): Promise<{ success: boolean; error?: string }> { // Initialize SDK for the target network (trusted mode required for identity fetch) - const sdk = network === 'mainnet' - ? EvoSDK.mainnetTrusted() - : EvoSDK.testnetTrusted(); + const sdk = createPlatformSdk(network, true); console.log(`Connecting to ${network}...`); await withRetry(() => sdk.connect(), retryOptions); @@ -378,6 +399,7 @@ export async function updateIdentity( disablePublicKeys: disablePublicKeyIds.length > 0 ? disablePublicKeyIds : undefined, + settings: PLATFORM_PUT_SETTINGS, }), retryOptions ); @@ -412,9 +434,7 @@ export async function sendToPlatformAddress( network: 'testnet' | 'mainnet', retryOptions?: RetryOptions ): Promise<{ success: boolean; recipientAddress: string }> { - const sdk = network === 'mainnet' - ? EvoSDK.mainnet() - : EvoSDK.testnet(); + const sdk = createPlatformSdk(network, false); console.log(`Connecting to ${network}...`); await withRetry(() => sdk.connect(), retryOptions); @@ -444,6 +464,7 @@ export async function sendToPlatformAddress( outputs: [{ address: recipientAddress }] as any, signer, feeStrategy: [{ type: 'reduceOutput', index: 0 }] as any, + settings: PLATFORM_PUT_SETTINGS, }), retryOptions ); From cfbc28b5ca7afa9b6f61214b6d1d179862a2c3c4 Mon Sep 17 00:00:00 2001 From: pasta Date: Thu, 16 Apr 2026 09:02:14 -0500 Subject: [PATCH 2/3] fix: align platform request timeout with server wait window --- src/platform/identity.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/platform/identity.ts b/src/platform/identity.ts index 79b088f..2eaa952 100644 --- a/src/platform/identity.ts +++ b/src/platform/identity.ts @@ -43,13 +43,17 @@ function base64ToBytes(base64: string): Uint8Array { const PLATFORM_REQUEST_SETTINGS = { connectTimeoutMs: 10000, - timeoutMs: 20000, + // wait_for_state_transition_result uses a 30s server-side wait window, + // so client-side request timeout must exceed that on runtimes that honor it. + timeoutMs: 40000, retries: 2, banFailedAddress: true, } as const; const PLATFORM_PUT_SETTINGS = { ...PLATFORM_REQUEST_SETTINGS, + // Browser wasm transport currently needs an outer watchdog because fetch-level + // timeouts are not wired through by the SDK transport. waitTimeoutMs: 45000, } as const; From 837694fb4bca096faea7de110fd00858332152ed Mon Sep 17 00:00:00 2001 From: pasta Date: Thu, 16 Apr 2026 09:19:43 -0500 Subject: [PATCH 3/3] fix: force trusted sdk for bridge platform calls --- src/platform/identity.ts | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/platform/identity.ts b/src/platform/identity.ts index 2eaa952..38b49aa 100644 --- a/src/platform/identity.ts +++ b/src/platform/identity.ts @@ -57,17 +57,14 @@ const PLATFORM_PUT_SETTINGS = { waitTimeoutMs: 45000, } as const; -function createPlatformSdk( - network: 'testnet' | 'mainnet', - trusted: boolean -): EvoSDK { +function createPlatformSdk(network: 'testnet' | 'mainnet'): EvoSDK { const options = { settings: PLATFORM_REQUEST_SETTINGS }; if (network === 'mainnet') { - return trusted ? EvoSDK.mainnetTrusted(options) : EvoSDK.mainnet(options); + return EvoSDK.mainnetTrusted(options); } - return trusted ? EvoSDK.testnetTrusted(options) : EvoSDK.testnet(options); + return EvoSDK.testnetTrusted(options); } /** @@ -179,7 +176,7 @@ export async function registerIdentity( retryOptions?: RetryOptions ): Promise<{ identityId: string; balance: number; revision: number }> { // Initialize SDK for the target network - const sdk = createPlatformSdk(network, true); + const sdk = createPlatformSdk(network); // Connect to the network with retry console.log(`Connecting to ${network}...`); @@ -259,7 +256,7 @@ export async function topUpIdentity( retryOptions?: RetryOptions ): Promise<{ success: boolean; balance?: number }> { // Initialize SDK for the target network (trusted mode required for identity fetch) - const sdk = createPlatformSdk(network, true); + const sdk = createPlatformSdk(network); // Connect to the network with retry console.log(`Connecting to ${network}...`); @@ -336,7 +333,7 @@ export async function updateIdentity( retryOptions?: RetryOptions ): Promise<{ success: boolean; error?: string }> { // Initialize SDK for the target network (trusted mode required for identity fetch) - const sdk = createPlatformSdk(network, true); + const sdk = createPlatformSdk(network); console.log(`Connecting to ${network}...`); await withRetry(() => sdk.connect(), retryOptions); @@ -438,7 +435,7 @@ export async function sendToPlatformAddress( network: 'testnet' | 'mainnet', retryOptions?: RetryOptions ): Promise<{ success: boolean; recipientAddress: string }> { - const sdk = createPlatformSdk(network, false); + const sdk = createPlatformSdk(network); console.log(`Connecting to ${network}...`); await withRetry(() => sdk.connect(), retryOptions);