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

Wallet abstraction #2879

Open
tequdev opened this issue Jan 16, 2025 · 0 comments
Open

Wallet abstraction #2879

tequdev opened this issue Jan 16, 2025 · 0 comments

Comments

@tequdev
Copy link
Contributor

tequdev commented Jan 16, 2025

Many of the functions in xrpl.js, including the Client class, rely on the implementation of the Wallet class.

By changing this to rely on the interface for signing, developers will be able to use client.sign() and other functions using any wallet that implements this interface.

  • Wallet
interface SignResult {
  tx_blob: string
  hash: string
}

export interface SignableWallet {
  sign: (transaction: Transaction, multisign?: boolean | string) => SignResult
  get address(): string
  ...
}

// Existing wallet class
export class Wallet implements SignableWallet {
  public readonly publicKey: string
  public readonly privateKey: string
  public readonly classicAddress: string
  public readonly seed?: string
  ...
}
  • Client
class Client extends EventEmitter<EventTypes> {
...
  public async submit(
    transaction: SubmittableTransaction | string,
    opts?: {
      // If true, autofill a transaction.
      autofill?: boolean
      // If true, and the transaction fails locally, do not retry or relay the transaction to other servers.
      failHard?: boolean
      // A wallet to sign a transaction. It must be provided when submitting an unsigned transaction.
      wallet?: SignableWallet
    },
  ): Promise<SubmitResponse> {
    const signedTx = await getSignedTx(this, transaction, opts)
    return submitRequest(this, signedTx, opts?.failHard)
  }
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant