Skip to content

Commit b97847a

Browse files
vibhavgocursoragent
andcommitted
fix(sui): use live JSON-RPC nodes and surface recover errors
Sui Foundation disabled JSON-RPC on fullnode.*.sui.io, so every SDK consumer hit "Method not found" and Sui.recover() reported "no funds" because the RPC error was swallowed. Point sdk-core defaults at PublicNode for mainnet and testnet, and rethrow getBalance failures with address, index, and RPC URL so the real cause surfaces. Ticket: WCI-1455 Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent e3cd214 commit b97847a

3 files changed

Lines changed: 26 additions & 3 deletions

File tree

modules/sdk-coin-sui/src/sui.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,11 @@ export class Sui extends BaseCoin {
368368
availableBalance = new BigNumber(balanceInfo.totalBalance);
369369
fundsInAddressBalance = new BigNumber(balanceInfo.fundsInAddressBalance);
370370
} catch (e) {
371-
continue;
371+
throw new Error(
372+
`Failed to query Sui balance for address ${senderAddress} at index ${idx} via ${this.getPublicNodeUrl()}: ${
373+
(e as Error).message
374+
}`
375+
);
372376
}
373377
if (availableBalance.minus(MAX_GAS_BUDGET).toNumber() <= 0) {
374378
continue;

modules/sdk-coin-sui/test/unit/sui.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3018,6 +3018,25 @@ describe('SUI:', function () {
30183018

30193019
sandBox.assert.callCount(basecoin.getBalance, 10);
30203020
});
3021+
3022+
it('should surface RPC errors from getBalance instead of reporting no funds', async function () {
3023+
const callBack = sandBox.stub(Sui.prototype, 'getBalance' as keyof Sui);
3024+
callBack.rejects(new Error('Method not found'));
3025+
3026+
await basecoin
3027+
.recover({
3028+
userKey: keys.userKey,
3029+
backupKey: keys.backupKey,
3030+
bitgoKey: keys.bitgoKey,
3031+
recoveryDestination,
3032+
walletPassphrase,
3033+
startingScanIndex: '0',
3034+
scan: 1,
3035+
})
3036+
.should.be.rejectedWith(/Failed to query Sui balance.*Method not found/);
3037+
3038+
sandBox.assert.callCount(basecoin.getBalance, 1);
3039+
});
30213040
});
30223041

30233042
describe('Consolidation Transaction Failures:', () => {

modules/sdk-core/src/bitgo/environments.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ const mainnetBase: EnvironmentTemplate = {
210210
},
211211
hmacVerificationEnforced: true,
212212
tonNodeUrl: 'https://toncenter.com/api/v2/jsonRPC',
213-
suiNodeUrl: 'https://fullnode.mainnet.sui.io',
213+
suiNodeUrl: 'https://sui-rpc.publicnode.com',
214214
iotaNodeUrl: 'https://api.mainnet.iota.cafe',
215215
etcNodeUrl: 'https://etc.blockscout.com',
216216
coredaoExplorerBaseUrl: 'https://openapi.coredao.org',
@@ -449,7 +449,7 @@ const testnetBase: EnvironmentTemplate = {
449449
},
450450
hmacVerificationEnforced: false,
451451
tonNodeUrl: 'https://testnet.toncenter.com/api/v2/jsonRPC',
452-
suiNodeUrl: 'https://fullnode.testnet.sui.io',
452+
suiNodeUrl: 'https://sui-testnet-rpc.publicnode.com',
453453
iotaNodeUrl: 'https://api.testnet.iota.cafe',
454454
etcNodeUrl: 'https://etc-mordor.blockscout.com',
455455
coredaoExplorerBaseUrl: 'https://api.test2.btcs.network',

0 commit comments

Comments
 (0)