Skip to content

Commit

Permalink
Resolve bug when transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
Thiendekaco committed Feb 27, 2024
1 parent 2492eeb commit df1119a
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 8 deletions.
5 changes: 3 additions & 2 deletions packages/core/src/preflight-notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export async function preflightNotifications(
}
}, reminderTimeout)


const eventCode = 'txRequest'
addNotification(buildNotification(eventCode, id, ''))
const resultFn = (hash_: string) => {
Expand All @@ -109,6 +110,7 @@ export async function preflightNotifications(
let hash
try {
await sendTransaction(resultFn);
removeNotification(id)
} catch (error) {
type CatchError = {
message: string
Expand All @@ -117,7 +119,6 @@ export async function preflightNotifications(
const { eventCode, errorMsg } = extractMessageFromError(error as CatchError)

addNotification(buildNotification(eventCode, id, errorMsg))
console.error(errorMsg)
return
}

Expand All @@ -141,7 +142,7 @@ const buildNotification = (
message: createMessageText(eventCode) || errorMessage,
startTime: Date.now(),
network: Object.keys(networkToChainId).find(
key => networkToChainId[key] === state.get().chains[0].id
key => networkToChainId[key] === state.get().wallets[0].chains[0].id
) as Network,
autoDismiss: 0
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ export type NotifyOptions = {
export type Notification = {
id: string
key: string
network: Network
network: Network | string
startTime?: number
/**
* to completely customize the message shown
Expand Down
35 changes: 34 additions & 1 deletion packages/core/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ export const chainIdToLabel: Record<string, string> = {
'0xa4b1': 'Arbitrum One',
'0xa4ba': 'Arbitrum Nova',
'acala' : 'Acala',
'0x507': 'Moonbase Alpha',
'0x504': 'Moonbeam',
'0x505': 'Moonriver',
'0x250': 'Astar',
'0x150': 'Shiden',
[ChainIdByGenesisHash.POLKADOT_ID] : 'Polkadot',
[ChainIdByGenesisHash.ASTAR_NETWORK_ID] : 'Astar Network',
[ChainIdByGenesisHash.CRUST_MAINET_ID] : 'Crust',
Expand All @@ -188,7 +193,35 @@ export const networkToChainId: Record<string, ChainId> = {
'bsc-main': '0x38',
'matic-main': '0x89',
'fantom-main': '0xfa',
'matic-mumbai': '0x80001'
'matic-mumbai': '0x80001',
'sepolia': '0xaa36a7',
'Fantom': '0xfa',
'optimism': '0xa',
'optimism kovan': '0x45',
'avalanche': '0xa86a',
'celo': '0xa4ec',
'base': '0x2105',
'base goerli': '0x14a33',
'harmony one': '0x63564C40',
'arbitrum one': '0xa4b1',
'arbitrum nova': '0xa4ba',
'acala' : 'Acala',
'moonbase-alpha': '0x507',
'moonbeam': '0x504',
'moonriver': '0x505',
'astar-network': '0x250',
'shiden': '0x150',
'polkadot': ChainIdByGenesisHash.POLKADOT_ID,
'kusama': ChainIdByGenesisHash.KUSAMA_ID,
'astar': ChainIdByGenesisHash.ASTAR_NETWORK_ID,
'crust': ChainIdByGenesisHash.CRUST_MAINET_ID,
'hydradx': ChainIdByGenesisHash.HYDRADX_ID,
'phala': ChainIdByGenesisHash.PHALA_ID,
'stateminte': ChainIdByGenesisHash.STATEMINT_ID,
'turing' : ChainIdByGenesisHash.TURING_ID,
'westend': ChainIdByGenesisHash.WESTEND_ID,
'rococo': ChainIdByGenesisHash.ROCOCO_ID,
'statemine': ChainIdByGenesisHash.STAEMINE_ID
}

export const chainStyles: Record<string, ChainStyle> = {
Expand Down
2 changes: 1 addition & 1 deletion packages/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"@subwallet_connect/subwallet": "^1.0.0",
"@subwallet_connect/subwallet-polkadot": "^1.0.0",
"@subwallet_connect/talisman": "^1.0.0",
"@subwallet_connect/polkadot_js": "^1.0.0",
"@subwallet_connect/polkadot-js": "^1.0.0",
"@subwallet/chain-list": "^0.2.39",
"@subwallet_connect/polkadot-vault": "^1.0.0",
"@testing-library/jest-dom": "^5.14.1",
Expand Down
1 change: 1 addition & 0 deletions packages/demo/src/components/account/AccountList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ function Component ({className, substrateProvider, evmProvider}: Props): React.R
async ( address: string)=> {
if(!wallet) return;
try{

if(wallet?.type === "evm"){
await evmProvider?.sendTransaction(address, '0x9Cd900257bFdaf6888826f131E8B0ccB54EdB0be', '1000000000000000' )
}else{
Expand Down
1 change: 0 additions & 1 deletion packages/demo/src/utils/api/evmApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export class evmApi {
to: recipientAddress,
value: amount
}

const sendTransaction = async (fn: (hash: string) => void) => {
const tx = await signer.sendTransaction(txDetails);
fn(tx.hash);
Expand Down
4 changes: 2 additions & 2 deletions packages/demo/src/web3-onboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
import injectedModule from '@subwallet_connect/injected-wallets';
import { init } from '@subwallet_connect/react';
import walletConnectPolkadotModule from '@subwallet_connect/walletconnect-polkadot';
import ledgerPolkadot from "@subwallet_connect/ledgerpolkadot";
import ledgerPolkadot from "@subwallet_connect/ledger-polkadot";
import metamaskSDK from '@subwallet_connect/metamask';
import subwalletModule from '@subwallet_connect/subwallet';
import talismanModule from '@subwallet_connect/talisman';
import polkadot_jsModule from '@subwallet_connect/polkadot_js';
import polkadot_jsModule from '@subwallet_connect/polkadot-js';
import subwalletPolkadotModule from '@subwallet_connect/subwallet-polkadot';
import polkadotVaultModule from '@subwallet_connect/polkadot-vault';
import ledgerModule from '@subwallet_connect/ledger';
Expand Down

0 comments on commit df1119a

Please sign in to comment.