From 757ed43909802b47a949bc709af14fd335b4f135 Mon Sep 17 00:00:00 2001 From: Ben Kremer Date: Wed, 29 Mar 2023 10:57:19 +0200 Subject: [PATCH] fix(near): don't block/throw wallet on account creation network call --- wallets/react-wallet-v2/src/lib/NearLib.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/wallets/react-wallet-v2/src/lib/NearLib.ts b/wallets/react-wallet-v2/src/lib/NearLib.ts index b298569..73e2bcb 100644 --- a/wallets/react-wallet-v2/src/lib/NearLib.ts +++ b/wallets/react-wallet-v2/src/lib/NearLib.ts @@ -88,23 +88,21 @@ export class NearWallet { const accountId = `dev-${Date.now()}-${randomNumber}` const publicKey = keyPair.getPublicKey().toString() - return fetch(`https://helper.testnet.near.org/account`, { + fetch(`https://helper.testnet.near.org/account`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ newAccountId: accountId, newAccountPublicKey: publicKey }) - }).then(res => { - if (res.ok) { - return { - accountId, - keyPair - } - } - - throw new Error('Failed to create NEAR dev account') + }).catch(error => { + console.error('Failed to create NEAR dev account: ', error) }) + + return { + accountId, + keyPair + } } private constructor(networkId: string, keyStore: nearKeyStores.KeyStore) {