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

[V7 Breaking] feat: improve WalletAccount class instantiation #1245

Closed
wants to merge 3 commits into from
Closed
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
27 changes: 1 addition & 26 deletions src/wallet/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,31 +40,15 @@ import { StarknetWalletProvider } from './types';
// TODO: Remove non address constructor in next major version
// Represent 'Selected Active' Account inside Connected Wallet
export class WalletAccount extends Account implements AccountInterface {
public address: string = '';

public walletProvider: StarknetWalletProvider;

/**
* @deprecated Use static method WalletAccount.connect or WalletAccount.connectSilent instead. Constructor {@link WalletAccount.(format:2)}.
*/
constructor(
providerOrOptions: ProviderOptions | ProviderInterface,
walletProvider: StarknetWalletProvider,
cairoVersion?: CairoVersion
);
constructor(
providerOrOptions: ProviderOptions | ProviderInterface,
walletProvider: StarknetWalletProvider,
cairoVersion?: CairoVersion,
address?: string
);
constructor(
providerOrOptions: ProviderOptions | ProviderInterface,
walletProvider: StarknetWalletProvider,
cairoVersion?: CairoVersion,
address: string = ''
) {
super(providerOrOptions, address, '', cairoVersion); // At this point unknown address
super(providerOrOptions, address, '', cairoVersion);
this.walletProvider = walletProvider;

// Update Address on change
Expand All @@ -80,15 +64,6 @@ export class WalletAccount extends Account implements AccountInterface {
// At the moment channel is stateless but it could change
this.channel.setChainId(res as StarknetChainId);
});

if (!address.length) {
console.warn(
'@deprecated Use static method WalletAccount.connect or WalletAccount.connectSilent instead. Constructor {@link WalletAccount.(format:2)}.'
);
requestAccounts(this.walletProvider).then(([accountAddress]) => {
this.address = accountAddress.toLowerCase();
});
}
}

/**
Expand Down