From b67db0e6e45544e390d2e24b06e2e21edc02627c Mon Sep 17 00:00:00 2001 From: Lucas Portella Date: Wed, 14 Feb 2024 18:46:58 -0300 Subject: [PATCH 1/9] feat: cardano implement connect --- src/networks.ts | 6 +++++ src/substrate/ada/connect.ts | 48 ++++++++++++++++++++++++++++++++++++ src/substrate/ada/index.ts | 13 ++++++++++ 3 files changed, 67 insertions(+) create mode 100644 src/substrate/ada/connect.ts create mode 100644 src/substrate/ada/index.ts diff --git a/src/networks.ts b/src/networks.ts index c6fd742..04d8fad 100644 --- a/src/networks.ts +++ b/src/networks.ts @@ -11,11 +11,17 @@ export const Networks = { name: 'Kusama', decimals: 12, }, + ada: { + id: 3, + name: 'Cardano', + decimals: 15, // review + } } export enum Network { POLKADOT = 'dot', KUSAMA = 'ksm', + CARDANO = 'ada' } export type NetworkKey = keyof typeof Networks diff --git a/src/substrate/ada/connect.ts b/src/substrate/ada/connect.ts new file mode 100644 index 0000000..9421089 --- /dev/null +++ b/src/substrate/ada/connect.ts @@ -0,0 +1,48 @@ +import { NotInjectedError } from '@/errors'; +import { NoAvailableAccountsError } from '@/errors/no-accounts-available-error'; +import { NoProviderAvailableError } from '@/errors/no-provider-available-error'; +import { Account } from '@/types'; + +interface CardanoWeb extends Window { + cardano: { + [key: string]: CardanoExtension; + }; +} + +interface CardanoInitializedExtension extends CardanoWeb { + getBalance: () => Promise + getUsedAddresses: () => Promise + getUnusedAddresses: () => Promise +} + +interface CardanoExtension { + apiVersion: string; + enable: () => Promise; + isEnabled: () => Promise; + icon: string; + name: string; +} + + +const CardanoWindow: CardanoWeb = (window as any) + +export async function connect(appName: string): Promise { + if (!(window as any).cardano) + throw new NotInjectedError() + + const isInjected = CardanoWindow.cardano[appName].name === appName + if (!isInjected) + throw new NoProviderAvailableError() + + const api: CardanoInitializedExtension = await CardanoWindow.cardano[appName].enable() + + const rawAccounts = await api.getUsedAddresses() + if (rawAccounts.length === 0) + throw new NoAvailableAccountsError() + + const accounts = rawAccounts.map((account) => ({ + address: account + })) + + return accounts +} diff --git a/src/substrate/ada/index.ts b/src/substrate/ada/index.ts new file mode 100644 index 0000000..572653b --- /dev/null +++ b/src/substrate/ada/index.ts @@ -0,0 +1,13 @@ +import { MissingPropsError } from '@/errors/missing-props-error'; +import { Network } from '@/networks'; +import { SubstrateProvider } from '@/substrate'; +import type { SubstrateProviderProps } from '@/substrate/types'; + +export class CardanoProvider extends SubstrateProvider { + constructor({ appName, rpcProvider }: SubstrateProviderProps) { + if (!appName || appName.length === 0 || !rpcProvider || rpcProvider.length === 0) + throw new MissingPropsError() + + super(Network.CARDANO, appName, rpcProvider) + } +} From 879f238d25bbf99dc117bd26ff42d8e1fa0f0154 Mon Sep 17 00:00:00 2001 From: Lucas Portella Date: Thu, 15 Feb 2024 12:17:13 -0300 Subject: [PATCH 2/9] feat: cardano add types --- src/ada/types.ts | 24 ++++++++++++++++++++++++ src/provider.ts | 2 ++ src/types.ts | 3 ++- 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/ada/types.ts diff --git a/src/ada/types.ts b/src/ada/types.ts new file mode 100644 index 0000000..066bd10 --- /dev/null +++ b/src/ada/types.ts @@ -0,0 +1,24 @@ +export interface CardanoWeb extends Window { + cardano: { + [key: string]: CardanoExtension + } +} + +export interface CardanoExtension { + apiVersion: string + enable: () => Promise + isEnabled: () => Promise + icon: string + name: string +} + +export interface CardanoInitializedExtension extends CardanoWeb { + getBalance: () => Promise + getUsedAddresses: () => Promise + getUnusedAddresses: () => Promise +} + +export interface CardanoProviderProps { + appName: string + rpcProvider: string +} diff --git a/src/provider.ts b/src/provider.ts index 788b233..bdb8211 100644 --- a/src/provider.ts +++ b/src/provider.ts @@ -4,6 +4,7 @@ import type { NetworkData, NetworkKey } from './networks'; import { getNetworkKeyById, isValidNetwork } from './networks'; import { PolkadotProvider } from './substrate/dot'; import { KusamaProvider } from './substrate/ksm'; +import { CardanoProvider } from './ada'; import type { ProviderBuilderProps } from './types'; export class Provider { @@ -25,6 +26,7 @@ export class Provider { return { dot: PolkadotProvider, ksm: KusamaProvider, + ada: CardanoProvider, } } diff --git a/src/types.ts b/src/types.ts index cf58b49..898356d 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,3 +1,4 @@ +import type { CardanoProviderProps } from './ada/types' import type { SubstrateProviderProps } from './substrate/types' export type Address = string @@ -12,4 +13,4 @@ export interface Balance { frozen: number | string } -export type ProviderBuilderProps = SubstrateProviderProps +export type ProviderBuilderProps = SubstrateProviderProps | CardanoProviderProps From 21e32de48838e7a9149c3e835eeea8237037cf20 Mon Sep 17 00:00:00 2001 From: Lucas Portella Date: Thu, 15 Feb 2024 12:24:38 -0300 Subject: [PATCH 3/9] refactor: cardano refactor and place cardano provider and connect fn in the correct folder --- src/ada/connect.ts | 28 ++++++++++++++++++++++++++++ src/ada/index.ts | 31 +++++++++++++++++++++++++++++++ src/networks.ts | 4 ++-- 3 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 src/ada/connect.ts create mode 100644 src/ada/index.ts diff --git a/src/ada/connect.ts b/src/ada/connect.ts new file mode 100644 index 0000000..cbb8dc0 --- /dev/null +++ b/src/ada/connect.ts @@ -0,0 +1,28 @@ +import { NotInjectedError } from '@/errors'; +import { NoAvailableAccountsError } from '@/errors/no-accounts-available-error'; +import { NoProviderAvailableError } from '@/errors/no-provider-available-error'; +import type { Account } from '@/types'; +import type { CardanoInitializedExtension, CardanoWeb } from '@/ada/types'; + +const CardanoWindow: CardanoWeb = (window as any) + +export async function connect(appName: string): Promise { + if (!(window as any).cardano) + throw new NotInjectedError() + + const isInjected = CardanoWindow.cardano[appName].name === appName + if (!isInjected) + throw new NoProviderAvailableError() + + const api: CardanoInitializedExtension = await CardanoWindow.cardano[appName].enable() + + const rawAccounts = await api.getUsedAddresses() + if (rawAccounts.length === 0) + throw new NoAvailableAccountsError() + + const accounts = rawAccounts.map(account => ({ + address: account, + })) + + return accounts +} diff --git a/src/ada/index.ts b/src/ada/index.ts new file mode 100644 index 0000000..db1f0bb --- /dev/null +++ b/src/ada/index.ts @@ -0,0 +1,31 @@ +import { MissingPropsError } from '@/errors/missing-props-error'; +import type { ProviderEntity } from '@/entities/provider-entity'; +import type { Account, Address, Balance } from '@/types'; +import { connect } from '@/ada/connect'; + +export class CardanoProvider implements ProviderEntity { + appName: string + constructor(appName: string) { + this.appName = appName + + if (!appName) + throw new MissingPropsError() + } + + async connect(): Promise { + const accounts = await connect(this.appName) + return accounts; + } + + async getBalance(address: Address): Promise { + throw new Error('Not yet implemented.') + } + + async signMessage(address: Address, message: string): Promise { + throw new Error('Not yet implemented.') + } + + signatureVerify(message: string, signature: string, address: string): boolean { + throw new Error('Not yet implemented.') + } +} diff --git a/src/networks.ts b/src/networks.ts index 04d8fad..2e95799 100644 --- a/src/networks.ts +++ b/src/networks.ts @@ -15,13 +15,13 @@ export const Networks = { id: 3, name: 'Cardano', decimals: 15, // review - } + }, } export enum Network { POLKADOT = 'dot', KUSAMA = 'ksm', - CARDANO = 'ada' + CARDANO = 'ada', } export type NetworkKey = keyof typeof Networks From dd132ac7acf13712d5435f3a88781216091c4e06 Mon Sep 17 00:00:00 2001 From: Lucas Portella Date: Thu, 15 Feb 2024 12:39:58 -0300 Subject: [PATCH 4/9] refactor: cardano remove outdated code --- src/substrate/ada/connect.ts | 48 ------------------------------------ src/substrate/ada/index.ts | 13 ---------- 2 files changed, 61 deletions(-) delete mode 100644 src/substrate/ada/connect.ts delete mode 100644 src/substrate/ada/index.ts diff --git a/src/substrate/ada/connect.ts b/src/substrate/ada/connect.ts deleted file mode 100644 index 9421089..0000000 --- a/src/substrate/ada/connect.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { NotInjectedError } from '@/errors'; -import { NoAvailableAccountsError } from '@/errors/no-accounts-available-error'; -import { NoProviderAvailableError } from '@/errors/no-provider-available-error'; -import { Account } from '@/types'; - -interface CardanoWeb extends Window { - cardano: { - [key: string]: CardanoExtension; - }; -} - -interface CardanoInitializedExtension extends CardanoWeb { - getBalance: () => Promise - getUsedAddresses: () => Promise - getUnusedAddresses: () => Promise -} - -interface CardanoExtension { - apiVersion: string; - enable: () => Promise; - isEnabled: () => Promise; - icon: string; - name: string; -} - - -const CardanoWindow: CardanoWeb = (window as any) - -export async function connect(appName: string): Promise { - if (!(window as any).cardano) - throw new NotInjectedError() - - const isInjected = CardanoWindow.cardano[appName].name === appName - if (!isInjected) - throw new NoProviderAvailableError() - - const api: CardanoInitializedExtension = await CardanoWindow.cardano[appName].enable() - - const rawAccounts = await api.getUsedAddresses() - if (rawAccounts.length === 0) - throw new NoAvailableAccountsError() - - const accounts = rawAccounts.map((account) => ({ - address: account - })) - - return accounts -} diff --git a/src/substrate/ada/index.ts b/src/substrate/ada/index.ts deleted file mode 100644 index 572653b..0000000 --- a/src/substrate/ada/index.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { MissingPropsError } from '@/errors/missing-props-error'; -import { Network } from '@/networks'; -import { SubstrateProvider } from '@/substrate'; -import type { SubstrateProviderProps } from '@/substrate/types'; - -export class CardanoProvider extends SubstrateProvider { - constructor({ appName, rpcProvider }: SubstrateProviderProps) { - if (!appName || appName.length === 0 || !rpcProvider || rpcProvider.length === 0) - throw new MissingPropsError() - - super(Network.CARDANO, appName, rpcProvider) - } -} From 0e10aab2e941f299431a793fa7734d2b99dcf1c8 Mon Sep 17 00:00:00 2001 From: Lucas Portella Date: Thu, 15 Feb 2024 14:26:02 -0300 Subject: [PATCH 5/9] fix: cardano add provde props to cardano constructor --- src/ada/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ada/index.ts b/src/ada/index.ts index db1f0bb..e0bc4bf 100644 --- a/src/ada/index.ts +++ b/src/ada/index.ts @@ -1,11 +1,12 @@ import { MissingPropsError } from '@/errors/missing-props-error'; import type { ProviderEntity } from '@/entities/provider-entity'; import type { Account, Address, Balance } from '@/types'; +import type { CardanoProviderProps } from './types'; import { connect } from '@/ada/connect'; export class CardanoProvider implements ProviderEntity { appName: string - constructor(appName: string) { + constructor({ appName }: CardanoProviderProps) { this.appName = appName if (!appName) From c5815165250614fa89ba015a4010b83f34034f6d Mon Sep 17 00:00:00 2001 From: Wil Macedo Date: Fri, 16 Feb 2024 10:25:17 -0300 Subject: [PATCH 6/9] feat: :sparkles: finish connect and type implementation --- src/ada/available-wallets.ts | 8 ++++++++ src/ada/connect.ts | 34 ++++++++++++++++++---------------- src/ada/index.ts | 21 ++++++++++++--------- src/ada/types.ts | 25 ++++--------------------- src/index.ts | 1 + src/networks.ts | 2 +- src/types.ts | 5 +++++ 7 files changed, 49 insertions(+), 47 deletions(-) create mode 100644 src/ada/available-wallets.ts diff --git a/src/ada/available-wallets.ts b/src/ada/available-wallets.ts new file mode 100644 index 0000000..283e492 --- /dev/null +++ b/src/ada/available-wallets.ts @@ -0,0 +1,8 @@ +// TODO: Add klever mobile app source name +export const availableWallets = ['nami'] as const + +export type AvailableWallet = typeof availableWallets[number] + +export enum CardanoWallet { + NAMI = 'nami', +} diff --git a/src/ada/connect.ts b/src/ada/connect.ts index cbb8dc0..8cea31d 100644 --- a/src/ada/connect.ts +++ b/src/ada/connect.ts @@ -1,28 +1,30 @@ import { NotInjectedError } from '@/errors'; import { NoAvailableAccountsError } from '@/errors/no-accounts-available-error'; import { NoProviderAvailableError } from '@/errors/no-provider-available-error'; -import type { Account } from '@/types'; -import type { CardanoInitializedExtension, CardanoWeb } from '@/ada/types'; +import { web3Window } from '@/web3-provider'; +import { availableWallets } from './available-wallets'; +import type { CardanoUsedAddress } from './types'; -const CardanoWindow: CardanoWeb = (window as any) - -export async function connect(appName: string): Promise { - if (!(window as any).cardano) +export async function connect(wallet?: string): Promise { + if (!web3Window.cardano) throw new NotInjectedError() - const isInjected = CardanoWindow.cardano[appName].name === appName - if (!isInjected) + let injectedWallet = wallet + if (typeof injectedWallet === 'undefined') { + for (const availableWallet of availableWallets) { + if (web3Window.cardano[availableWallet]) + injectedWallet = availableWallet + } + } + + if (typeof injectedWallet === 'undefined') throw new NoProviderAvailableError() - const api: CardanoInitializedExtension = await CardanoWindow.cardano[appName].enable() + await web3Window.cardano[injectedWallet].enable() - const rawAccounts = await api.getUsedAddresses() - if (rawAccounts.length === 0) + const usedAddresses: CardanoUsedAddress[] = await web3Window.cardano.getUsedAddresses() + if (usedAddresses.length === 0) throw new NoAvailableAccountsError() - const accounts = rawAccounts.map(account => ({ - address: account, - })) - - return accounts + return usedAddresses } diff --git a/src/ada/index.ts b/src/ada/index.ts index e0bc4bf..e219e60 100644 --- a/src/ada/index.ts +++ b/src/ada/index.ts @@ -1,21 +1,24 @@ -import { MissingPropsError } from '@/errors/missing-props-error'; +import { connect } from '@/ada/connect'; import type { ProviderEntity } from '@/entities/provider-entity'; import type { Account, Address, Balance } from '@/types'; +import { CardanoWallet } from './available-wallets'; import type { CardanoProviderProps } from './types'; -import { connect } from '@/ada/connect'; export class CardanoProvider implements ProviderEntity { - appName: string - constructor({ appName }: CardanoProviderProps) { - this.appName = appName + wallet?: CardanoWallet - if (!appName) - throw new MissingPropsError() + constructor({ wallet }: CardanoProviderProps) { + if (wallet) + this.wallet = CardanoWallet[wallet.toUpperCase() as keyof typeof CardanoWallet] } async connect(): Promise { - const accounts = await connect(this.appName) - return accounts; + const accounts = await connect(this.wallet) + + return accounts.map((account, index) => ({ + name: `Account #${index}`, + address: account, + })) } async getBalance(address: Address): Promise { diff --git a/src/ada/types.ts b/src/ada/types.ts index 066bd10..dc7ed8b 100644 --- a/src/ada/types.ts +++ b/src/ada/types.ts @@ -1,24 +1,7 @@ -export interface CardanoWeb extends Window { - cardano: { - [key: string]: CardanoExtension - } -} - -export interface CardanoExtension { - apiVersion: string - enable: () => Promise - isEnabled: () => Promise - icon: string - name: string -} - -export interface CardanoInitializedExtension extends CardanoWeb { - getBalance: () => Promise - getUsedAddresses: () => Promise - getUnusedAddresses: () => Promise -} +import type { AvailableWallet } from './available-wallets'; export interface CardanoProviderProps { - appName: string - rpcProvider: string + wallet?: AvailableWallet } + +export type CardanoUsedAddress = string diff --git a/src/index.ts b/src/index.ts index 9f7cfbf..8fa2d24 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,4 @@ +export * from './ada/index' export * from './networks' export * from './substrate/dot/index' export * from './substrate/ksm/index' diff --git a/src/networks.ts b/src/networks.ts index 2e95799..c67e67c 100644 --- a/src/networks.ts +++ b/src/networks.ts @@ -14,7 +14,7 @@ export const Networks = { ada: { id: 3, name: 'Cardano', - decimals: 15, // review + decimals: 15, // TODO: Check this value }, } diff --git a/src/types.ts b/src/types.ts index 898356d..99fd6f7 100644 --- a/src/types.ts +++ b/src/types.ts @@ -14,3 +14,8 @@ export interface Balance { } export type ProviderBuilderProps = SubstrateProviderProps | CardanoProviderProps + +export type Web3Window = { + injectedWeb3: any + cardano: any +} & Window & typeof globalThis From 9a1b626135a73fe06cdf190d83d4e4e13ead2a3b Mon Sep 17 00:00:00 2001 From: Wil Macedo Date: Fri, 16 Feb 2024 11:40:18 -0300 Subject: [PATCH 7/9] fix: :bug: fixing build props and providers --- src/types.ts | 3 ++- src/web3-provider.ts | 30 +++++++++++++++++------------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/types.ts b/src/types.ts index 99fd6f7..cc7f370 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,4 +1,5 @@ import type { CardanoProviderProps } from './ada/types' +import type { NetworkKey } from './networks' import type { SubstrateProviderProps } from './substrate/types' export type Address = string @@ -13,7 +14,7 @@ export interface Balance { frozen: number | string } -export type ProviderBuilderProps = SubstrateProviderProps | CardanoProviderProps +export type ProviderBuilderProps = T extends 'dot' | 'ksm' ? SubstrateProviderProps : T extends 'ada' ? CardanoProviderProps : never; export type Web3Window = { injectedWeb3: any diff --git a/src/web3-provider.ts b/src/web3-provider.ts index 2e9bf6c..167e919 100644 --- a/src/web3-provider.ts +++ b/src/web3-provider.ts @@ -1,11 +1,13 @@ +import { CardanoProvider } from './ada'; +import type { CardanoProviderProps } from './ada/types'; import type { ProviderEntity } from './entities/provider-entity'; import { InvalidNetworkError } from './errors/invalid-network-error'; import type { NetworkData, NetworkKey } from './networks'; import { getNetworkKeyById, isValidNetwork } from './networks'; import { PolkadotProvider } from './substrate/dot'; import { KusamaProvider } from './substrate/ksm'; -import { CardanoProvider } from './ada'; -import type { ProviderBuilderProps } from './types'; +import type { SubstrateProviderProps } from './substrate/types'; +import type { ProviderBuilderProps, Web3Window } from './types'; export class Web3Provider { network: NetworkKey @@ -22,17 +24,19 @@ export class Web3Provider { this.network = network } - private getAvailableProviders() { - return { - dot: PolkadotProvider, - ksm: KusamaProvider, - ada: CardanoProvider, + // TODO: Improve props type to avoid generic for vanilla javascript users + build(props: ProviderBuilderProps): ProviderEntity { + switch (this.network) { + case 'dot': + return new PolkadotProvider(props as SubstrateProviderProps) + case 'ksm': + return new KusamaProvider(props as SubstrateProviderProps) + case 'ada': + return new CardanoProvider(props as CardanoProviderProps) + default: + throw new InvalidNetworkError() } } - - build(props: ProviderBuilderProps): ProviderEntity { - const Provider = this.getAvailableProviders()[this.network] - - return new Provider(props) - } } + +export const web3Window = (window as Web3Window) From 7be55cc7172038247acb5eb9c90f8ae1b1f620fc Mon Sep 17 00:00:00 2001 From: Wil Macedo Date: Fri, 16 Feb 2024 11:46:12 -0300 Subject: [PATCH 8/9] bug: :fix: fix circular dependencies --- src/ada/connect.ts | 2 +- src/ada/index.ts | 2 +- src/substrate/connect.spec.ts | 5 +++-- src/substrate/connect.ts | 3 ++- src/types.ts | 2 ++ src/web3-provider.ts | 4 +--- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/ada/connect.ts b/src/ada/connect.ts index 8cea31d..de58df6 100644 --- a/src/ada/connect.ts +++ b/src/ada/connect.ts @@ -1,7 +1,7 @@ import { NotInjectedError } from '@/errors'; import { NoAvailableAccountsError } from '@/errors/no-accounts-available-error'; import { NoProviderAvailableError } from '@/errors/no-provider-available-error'; -import { web3Window } from '@/web3-provider'; +import { web3Window } from '@/types'; import { availableWallets } from './available-wallets'; import type { CardanoUsedAddress } from './types'; diff --git a/src/ada/index.ts b/src/ada/index.ts index e219e60..ca37939 100644 --- a/src/ada/index.ts +++ b/src/ada/index.ts @@ -1,7 +1,7 @@ -import { connect } from '@/ada/connect'; import type { ProviderEntity } from '@/entities/provider-entity'; import type { Account, Address, Balance } from '@/types'; import { CardanoWallet } from './available-wallets'; +import { connect } from './connect'; import type { CardanoProviderProps } from './types'; export class CardanoProvider implements ProviderEntity { diff --git a/src/substrate/connect.spec.ts b/src/substrate/connect.spec.ts index 8194982..3753a89 100644 --- a/src/substrate/connect.spec.ts +++ b/src/substrate/connect.spec.ts @@ -1,6 +1,7 @@ import { NotInjectedError } from '@/errors'; import { NoAvailableAccountsError } from '@/errors/no-accounts-available-error'; import { NoProviderAvailableError } from '@/errors/no-provider-available-error'; +import { web3Window } from '@/types'; import * as extension from '@polkadot/extension-dapp'; import { beforeEach, describe, expect, it, vi } from 'vitest'; import { connect } from './connect'; @@ -17,11 +18,11 @@ describe('Connect wallet use case', () => { vi.resetAllMocks() appName = 'Web3 Hub'; - (window as any).injectedWeb3 = {} + web3Window.injectedWeb3 = {} }) it('should be able to throw error when window dont have web3 object', async () => { - delete (window as any).injectedWeb3 + delete web3Window.injectedWeb3 await expect(connect(appName)).rejects.toThrow(NotInjectedError) }) diff --git a/src/substrate/connect.ts b/src/substrate/connect.ts index 9103197..660d749 100644 --- a/src/substrate/connect.ts +++ b/src/substrate/connect.ts @@ -1,11 +1,12 @@ import { NotInjectedError } from '@/errors'; import { NoAvailableAccountsError } from '@/errors/no-accounts-available-error'; import { NoProviderAvailableError } from '@/errors/no-provider-available-error'; +import { web3Window } from '@/types'; import { web3Accounts, web3Enable } from '@polkadot/extension-dapp'; import type { SubstrateAccountWithMeta } from './types'; export async function connect(appName: string): Promise { - if (!(window as any).injectedWeb3) + if (!web3Window.injectedWeb3) throw new NotInjectedError() const isInjected = await web3Enable(appName) diff --git a/src/types.ts b/src/types.ts index cc7f370..f612473 100644 --- a/src/types.ts +++ b/src/types.ts @@ -20,3 +20,5 @@ export type Web3Window = { injectedWeb3: any cardano: any } & Window & typeof globalThis + +export const web3Window = (window as Web3Window) diff --git a/src/web3-provider.ts b/src/web3-provider.ts index 167e919..7ea3a8a 100644 --- a/src/web3-provider.ts +++ b/src/web3-provider.ts @@ -7,7 +7,7 @@ import { getNetworkKeyById, isValidNetwork } from './networks'; import { PolkadotProvider } from './substrate/dot'; import { KusamaProvider } from './substrate/ksm'; import type { SubstrateProviderProps } from './substrate/types'; -import type { ProviderBuilderProps, Web3Window } from './types'; +import type { ProviderBuilderProps } from './types'; export class Web3Provider { network: NetworkKey @@ -38,5 +38,3 @@ export class Web3Provider { } } } - -export const web3Window = (window as Web3Window) From 502bc1b94c1e7c7bb689cc4f393469b3acc350e9 Mon Sep 17 00:00:00 2001 From: Wil Macedo Date: Fri, 16 Feb 2024 11:51:47 -0300 Subject: [PATCH 9/9] feat: :sparkles: add pr template --- .github/pull_request_template.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .github/pull_request_template.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..bf74463 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,9 @@ +## Task title + +> Description + +✨ Features: +- [ ] + +🔨 Improvements: +- [ ] \ No newline at end of file