Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions packages/gui/src/util/walletConnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ export async function processSessionProposal(
icons?: string[];
};
};
requiredNamespaces: {
requiredNamespaces?: {
chia: {
chains: string[];
methods: string[];
};
};
optionalNamespaces?: {
chia: {
chains: string[];
methods: string[];
Expand All @@ -64,19 +70,22 @@ export async function processSessionProposal(
pairingTopic,
proposer: { metadata: proposerMetadata },
requiredNamespaces,
optionalNamespaces,
},
} = event;

if (!pairingTopic) {
throw new Error('Pairing topic not found');
}

const requiredNamespace = requiredNamespaces.chia;
if (!requiredNamespace) {
throw new Error('Missing required chia namespace');
const requiredNamespace = requiredNamespaces?.chia;
const optionalNamespace = optionalNamespaces?.chia;
const chiaNamespace = requiredNamespace || optionalNamespace; // Use optionalNamespaces if requiredNamespaces is not present
if (!chiaNamespace) {
throw new Error('Missing both required/optional chia namespace');
}

const { chains, methods } = requiredNamespace;
const { chains, methods } = chiaNamespace;
const chain = chains.find((item) => ['chia:testnet', 'chia:mainnet'].includes(item));
if (!chain) {
throw new Error('Chain not supported');
Expand Down
Loading