Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(wc-dapp): remove pairing check during enable, fix getUtxos params #3

Merged
merged 1 commit into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion apps/dapp/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default function Index() {
console.info('[APP] fetching address');
await timeoutPromise(
enabledApi
.getUnusedAddresses()
.getUtxos()
.then(addr => {
console.info('[APP] addr', addr);
return addr;
Expand Down
5 changes: 0 additions & 5 deletions packages/wc-dapp/src/provider/cardanoWcProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@ export class CardanoWcProvider {
async enable(sam?: boolean) {
const session = this.provider?.session;
// Edge Case: sometimes pairing is lost, so we disconnect session and reconnect
const pairingTopic = session?.pairingTopic;
const hasPairing = this.getSessionPair(pairingTopic);
if (!hasPairing && session) {
await this.disconnect();
}
if (!session) {
await this.connect({ sam });
} else {
Expand Down
13 changes: 10 additions & 3 deletions packages/wc-dapp/src/provider/enabledWalletEmulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import UniversalProvider from '@walletconnect/universal-provider';
import EventEmitter from 'events';

import { TRpc } from '../types';
import type { Cbor, DataSignature, EnabledAPI, EnabledWalletEmulatorParams } from '../types/cip30';
import type {
Cbor,
DataSignature,
EnabledAPI,
EnabledWalletEmulatorParams,
Paginate
} from '../types/cip30';
import {
CARDANO_RPC_METHODS,
CARDANO_SIGNING_METHODS,
Expand Down Expand Up @@ -67,11 +73,12 @@ export class EnabledWalletEmulator implements EnabledAPI {
return Promise.resolve(this._networkId as number);
}

async getUtxos() {
async getUtxos(amount?: Cbor<'Value'>, paginate?: Paginate) {
if (!this._sam) {
return this._provider.request<Cbor<'utxos'>[]>(
{
method: CARDANO_RPC_METHODS.CARDANO_GET_UTXOS
method: CARDANO_RPC_METHODS.CARDANO_GET_UTXOS,
params: [amount, paginate]
},
this._chain
);
Expand Down