Skip to content

Commit

Permalink
Update metadata for substrate wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
Thiendekaco committed Feb 16, 2024
1 parent 981a227 commit 8b18f34
Show file tree
Hide file tree
Showing 15 changed files with 227 additions and 189 deletions.
5 changes: 4 additions & 1 deletion packages/common/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { ethers } from 'ethers'
export type { TypedData as EIP712TypedData } from 'eip-712'
import type { Signer } from '@polkadot/types/types'
import type { RequestArguments } from "@walletconnect/universal-provider";
import { InjectedMetadata } from "@polkadot/extension-inject/types";

/**
* Types for request patching methods. Ethereum RPC request is mapped to
Expand Down Expand Up @@ -196,8 +197,9 @@ export interface WalletModule {
getInterface: (helpers: GetInterfaceHelpers) =>
Promise<WalletInterface | WalletInterfaceSubstrate>

signer ?: Signer | undefined
signer ?: Signer

metadata ?: InjectedMetadata
}

export type GetInterfaceHelpers = {
Expand Down Expand Up @@ -415,6 +417,7 @@ export interface EIP1193Provider extends SimpleEventEmitter {
export interface SubstrateProvider extends SimpleEventEmitter{
enable () : Promise<{
signer ?: Signer,
metadata ?: InjectedMetadata
address : AccountAddress[] } | undefined>,
signDummy( address : string, data : string ,
wallet ?: Signer ) :
Expand Down
6 changes: 4 additions & 2 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { SvelteComponent } from 'svelte'

import type { InjectedMetadata } from '@polkadot/extension-inject/types';
import type {
AppMetadata,
Device,
Expand Down Expand Up @@ -143,7 +143,8 @@ export interface WalletState {
// is connected to multiple chains at once
chains: ConnectedChain[]
instance?: unknown,
signer ?: Signer | undefined
signer ?: Signer | undefined,
metadata ?: InjectedMetadata,
type : 'evm' | 'substrate'
}

Expand Down Expand Up @@ -588,6 +589,7 @@ export type WalletPermission = {

export type WalletConnectState = {
signer ?: Signer,
metadata ?: InjectedMetadata
address : AccountAddress[]
}

Expand Down
7 changes: 4 additions & 3 deletions packages/core/src/views/connect/Index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
const { provider, label , type } = selectedWallet
cancelPreviousConnect$.next()
try {
const { address, signer } = await Promise.race([
const { address, signer, metadata } = await Promise.race([
// resolved account
type === 'evm' ? await requestAccounts(provider as EIP1193Provider) : await enable(provider as SubstrateProvider) ,
// or connect wallet is called again whilst waiting for response
Expand Down Expand Up @@ -329,11 +329,12 @@
}
}
const update: Pick<WalletState, 'accounts' | 'chains' | 'signer' > = {
const update: Pick<WalletState, 'accounts' | 'chains' | 'signer' | 'metadata'> = {
accounts: addressFilter.map((address) =>
({ address, ens: null, uns: null, balance: null })),
chains: [{ namespace: type, id: chain }],
signer : signer
signer : signer,
metadata: metadata
}
addWallet({ ...selectedWallet, ...update })
Expand Down
2 changes: 1 addition & 1 deletion packages/demo/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import React from 'react';
import { HashRouter, Route, Routes } from 'react-router-dom';

import Layout from "./components/layout/Layout";
import Welcome from './components/Welcome';
import Welcome from './pages/Welcome';
import WalletInfo from './pages/WalletInfo';

require('./App.scss');
Expand Down
35 changes: 0 additions & 35 deletions packages/demo/src/components/AccountList.scss

This file was deleted.

27 changes: 0 additions & 27 deletions packages/demo/src/components/WalletMetadata.scss

This file was deleted.

95 changes: 0 additions & 95 deletions packages/demo/src/components/WalletMetadata.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import React, {useCallback, useEffect, useState} from 'react';

import {useConnectWallet, useNotifications, useSetChain} from "@subwallet_connect/react";
import {EIP1193Provider, SubstrateProvider} from "@subwallet_connect/common";
import {GeneralEmptyList} from "./empty";
import {RequestArguments, ThemeProps} from "../types";
import {GeneralEmptyList} from "../empty";
import {RequestArguments, ThemeProps} from "../../types";
import CN from "classnames";
import styled from "styled-components";
import {Maybe} from "@metamask/providers/dist/utils";
import {evmApi} from "../utils/api/evmApi";
import {substrateApi} from "../utils/api/substrateApi";
import {NetworkInfo} from "../utils/network";
import {evmApi} from "../../utils/api/evmApi";
import {substrateApi} from "../../utils/api/substrateApi";
import {NetworkInfo} from "../../utils/network";


interface Props extends ThemeProps{};
Expand Down Expand Up @@ -165,15 +165,15 @@ function Component ({className}: Props): React.ReactElement {
</div>
<div className={'__account-item-info'}>
<Button
className={CN('__wallet-btn', 'sub-wallet-sign-btn')}
className={CN('__wallet-btn', '__sub-wallet-sign-btn')}
onClick={onSignClicked(account)}
block={true}
>
Sign Dummy
</Button>

<Button
className={CN('__wallet-btn', 'sub-wallet-transaction-btn')}
className={CN('__wallet-btn', '__sub-wallet-transaction-btn')}
onClick={onTransactionClicked(account)}
block={true}
>
Expand Down Expand Up @@ -256,7 +256,7 @@ export const AccountList = styled(Component)<Props>( ({theme: {token}}) => {
color: token.colorTextLight4
},

'.sub-wallet-transaction-btn': {
'.__sub-wallet-transaction-btn': {
backgroundColor: "#252525",

'&:hover': {
Expand Down
Loading

0 comments on commit 8b18f34

Please sign in to comment.