Open
Description
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)
}
...
}
Metadata
Assignees
Labels
No labels