Skip to content
This repository has been archived by the owner on Mar 6, 2023. It is now read-only.

Feature/web3 provider #6

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Feature/web3 provider #6

wants to merge 5 commits into from

Conversation

ArtSuslov
Copy link
Contributor

No description provided.

@@ -171,12 +170,11 @@ describe('performs JsonApiClient request unit test', () => {
})
})

test('should return correct data', () => {
test('should return correct data', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will remove

packages/web3-provider/README.md Show resolved Hide resolved
{
"name": "@distributedlab/web3-provider",
"description": "Web3 Provider",
"version": "1.0.2",
Copy link
Contributor

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",
Copy link
Contributor

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

Copy link

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
Copy link
Contributor

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
Copy link
Contributor

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)
Copy link
Contributor

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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. wei is Eth unit not web3
  2. where is this using ?

Comment on lines +7 to +10
export function handleSolError(error: SolanaProviderRpcError) {
const errorCode = error?.error?.code || error?.code
const errorMessage = error?.error?.message || error?.message || ''

Copy link
Contributor

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 = {
Copy link
Contributor

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 */
Copy link
Contributor

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: {
Copy link
Contributor

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants