fix(near): don't block/throw wallet on account creation network call
This commit is contained in:
parent
b45f4369c0
commit
757ed43909
@ -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) {
|
||||||
|
Loading…
Reference in New Issue
Block a user