Skip to content

Commit

Permalink
Merge branch 'main' of github.com:klever-io/web3-hub into cardano-con…
Browse files Browse the repository at this point in the history
…nect-test
  • Loading branch information
lucasportella committed Feb 15, 2024
2 parents 0e10aab + 8d40a05 commit 91c323d
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

## Features

- 🔌 All supported networks are in [types.ts](https://github.com/klever-io/web3-hub/blob/main/src/types.ts)
- 🔌 All supported networks are in [networks.ts](https://github.com/klever-io/web3-hub/blob/main/src/networks.ts)

## Supported Chains

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
"clean": "shx rm -rf ./dist",
"lint": "eslint ./src",
"build": "pnpm clean && microbundle --tsconfig tsconfig.json --compress false --format cjs,esm",
"build:test": "microbundle --tsconfig tsconfig.json",
"test": "vitest run",
"publish:latest": "pnpm build && npm publish --tag latest --access public",
"build:test": "microbundle --tsconfig tsconfig.json"
"publish:latest": "pnpm build && npm publish --tag latest --access public"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/"
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export * from './networks'
export * from './provider'
export * from './substrate/dot/index'
export * from './substrate/ksm/index'
export * from './types'
export * from './web3-provider'

2 changes: 1 addition & 1 deletion src/substrate/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ProviderEntity } from '@/entities/provider-entity';
import type { Network } from '@/networks';
import type { Account, Address, Balance } from '@/types';
import { ApiPromise, WsProvider } from '@polkadot/api';
import type { ProviderEntity } from '../entities/provider-entity';
import { connect } from './connect';
import { getBalance } from './get-balance';
import { signMessage } from './sign-message';
Expand Down
10 changes: 5 additions & 5 deletions src/provider.spec.ts → src/web3-provider.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { describe, expect, it } from 'vitest';
import { InvalidNetworkError } from './errors/invalid-network-error';
import { Network, type NetworkData } from './networks';
import { Provider } from './provider';
import { SubstrateProvider } from './substrate';
import { Web3Provider } from './web3-provider';

describe('Provider case', () => {
it('should be able to throw error of invalid network when pass key', () => {
const network = 'invalid' as any

expect(() => new Provider(network)).toThrow(InvalidNetworkError)
expect(() => new Web3Provider(network)).toThrow(InvalidNetworkError)
})

it('should be able to throw error of invalid network when pass id', () => {
Expand All @@ -18,17 +18,17 @@ describe('Provider case', () => {
name: 'Invalid network',
}

expect(() => new Provider(networkData)).toThrow(InvalidNetworkError)
expect(() => new Web3Provider(networkData)).toThrow(InvalidNetworkError)
})

it('should be able to return valid substrate provider', () => {
const appName = 'Web3 Hub'
const rpcProvider = 'wss://rpc-provider'

const dotProvider = new Provider(Network.POLKADOT).build({ appName, rpcProvider })
const dotProvider = new Web3Provider(Network.POLKADOT).build({ appName, rpcProvider })
expect(dotProvider).toBeInstanceOf(SubstrateProvider)

const ksmProvider = new Provider(Network.KUSAMA).build({ appName, rpcProvider })
const ksmProvider = new Web3Provider(Network.KUSAMA).build({ appName, rpcProvider })
expect(ksmProvider).toBeInstanceOf(SubstrateProvider)
})
})
2 changes: 1 addition & 1 deletion src/provider.ts → src/web3-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { KusamaProvider } from './substrate/ksm';
import { CardanoProvider } from './ada';
import type { ProviderBuilderProps } from './types';

export class Provider {
export class Web3Provider {
network: NetworkKey

constructor(network: NetworkKey | NetworkData) {
Expand Down

0 comments on commit 91c323d

Please sign in to comment.