Skip to content
Open
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: 2 additions & 0 deletions src/initialize.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { registerWallet } from "./register.js";
import { GhostWallet } from "./wallet.js";
import { GhostWalletAccount } from "./account.js";
import type { Ghost } from "./window.js";

export type { WalletIcon } from "@wallet-standard/base";
export type { Ghost, GhostWallet };
export { GhostWalletAccount };

export function initialize(ghost: Ghost): void {
registerWallet(new GhostWallet(ghost));
Expand Down
14 changes: 8 additions & 6 deletions src/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export class GhostWallet implements Wallet {
const { transaction, account, chain, options } = inputs[0]!;
const { minContextSlot, preflightCommitment, skipPreflight, maxRetries } =
options || {};
if (account !== this.#account) throw new Error('invalid account');
if (account.address !== this.#account.address) throw new Error('invalid account');
if (!isSolanaChain(chain)) throw new Error('invalid chain');

const { signature } = await this.#implementation.signAndSendTransaction(
Expand Down Expand Up @@ -251,7 +251,7 @@ export class GhostWallet implements Wallet {

if (inputs.length === 1) {
const { transaction, account, chain } = inputs[0]!;
if (account !== this.#account) throw new Error('invalid account');
if (account.address !== this.#account.address) throw new Error('invalid account');
if (chain && !isSolanaChain(chain)) throw new Error('invalid chain');

const signedTransaction = await this.#implementation.signTransaction(
Expand All @@ -271,7 +271,7 @@ export class GhostWallet implements Wallet {
} else if (inputs.length > 1) {
let chain: SolanaChain | undefined = undefined;
for (const input of inputs) {
if (input.account !== this.#account) throw new Error('invalid account');
if (input.account.address !== this.#account.address) throw new Error('invalid account');
if (input.chain) {
if (!isSolanaChain(input.chain)) throw new Error('invalid chain');
if (chain) {
Expand Down Expand Up @@ -318,7 +318,7 @@ export class GhostWallet implements Wallet {

if (inputs.length === 1) {
const { message, account } = inputs[0]!;
if (account !== this.#account) throw new Error('invalid account');
if (account.address !== this.#account.address) throw new Error('invalid account');

const { signature } = await this.#implementation.signMessage(message);

Expand All @@ -337,10 +337,12 @@ export class GhostWallet implements Wallet {

if (inputs.length > 1) {
for (const input of inputs) {
outputs.push(await this.#implementation.signIn(input));
const output = await this.#implementation.signIn(input);
outputs.push(output);
}
} else {
return [await this.#implementation.signIn(inputs[0])];
const output = await this.#implementation.signIn(inputs[0]);
return [output];
}

return outputs;
Expand Down