fix(near): don't block/throw wallet on account creation network call

This commit is contained in:
Ben Kremer 2023-03-29 10:57:19 +02:00
parent b45f4369c0
commit 757ed43909

View File

@ -88,23 +88,21 @@ export class NearWallet {
const accountId = `dev-${Date.now()}-${randomNumber}` const accountId = `dev-${Date.now()}-${randomNumber}`
const publicKey = keyPair.getPublicKey().toString() const publicKey = keyPair.getPublicKey().toString()
return fetch(`https://helper.testnet.near.org/account`, { fetch(`https://helper.testnet.near.org/account`, {
method: 'POST', method: 'POST',
headers: { 'Content-Type': 'application/json' }, headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ body: JSON.stringify({
newAccountId: accountId, newAccountId: accountId,
newAccountPublicKey: publicKey newAccountPublicKey: publicKey
}) })
}).then(res => { }).catch(error => {
if (res.ok) { console.error('Failed to create NEAR dev account: ', error)
return {
accountId,
keyPair
}
}
throw new Error('Failed to create NEAR dev account')
}) })
return {
accountId,
keyPair
}
} }
private constructor(networkId: string, keyStore: nearKeyStores.KeyStore) { private constructor(networkId: string, keyStore: nearKeyStores.KeyStore) {