-
Notifications
You must be signed in to change notification settings - Fork 2
Feature/web3 provider #6
base: main
Are you sure you want to change the base?
Conversation
@@ -171,12 +170,11 @@ describe('performs JsonApiClient request unit test', () => { | |||
}) | |||
}) | |||
|
|||
test('should return correct data', () => { | |||
test('should return correct data', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will remove
{ | ||
"name": "@distributedlab/web3-provider", | ||
"description": "Web3 Provider", | ||
"version": "1.0.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1.0.0
@@ -0,0 +1,43 @@ | |||
{ | |||
"name": "@distributedlab/web3-provider", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about rename it to @distributedlab/web3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a lib to work with providers, and web3 - is a common term and can we like web3.js, etc...
case EIP1474.jsonRpcVersionNotSupported: | ||
throw new errors.ProviderJsonRpcVersionNotSupported(message) | ||
default: | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw type error unhandled error code
|
||
export function handleEthError(error: EthProviderRpcError) { | ||
handleCommonEIPErrors(error.code, error.message) | ||
throw error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we throw two errors instead of one? let's just store the initial error in our custom error objects
const currentAccounts = await currentProvider.listAccounts() | ||
selectedAddress.value = currentAccounts[0] | ||
} catch (error) { | ||
handleEthError(error as EthProviderRpcError) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets change type of error inside of handleEthError
to unknown and check that it's instanceof EthProviderRpcError
to omit casting type of error every time in catch section
@@ -0,0 +1,3 @@ | |||
export enum WEB3_DECIMALS { | |||
WEI = 18, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- wei is Eth unit not web3
- where is this using ?
export function handleSolError(error: SolanaProviderRpcError) { | ||
const errorCode = error?.error?.code || error?.code | ||
const errorMessage = error?.error?.message || error?.message || '' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const err = error.hasOwnProperty('error') ? error.error : error
const errorMessage = error?.message || ''
/** | ||
* provider, which we've designated, it has a name and instance | ||
*/ | ||
export type DesignatedProvider = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may be ImplementedProvider or something else, Designated sounds strange
| 'signAllTransactions' | ||
| 'signMessage' | ||
|
||
/* eslint-disable @typescript-eslint/no-explicit-any */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
disable for needed line
/* eslint-enable */ | ||
|
||
export type SolanaProviderRpcError = { | ||
error: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it can be optional field
No description provided.