本页目录
API 参考
window.$onekey.stellar 的方法和基础类型参考。
方法
| 方法 | 描述 |
|---|---|
getAddress(params?) | 请求授权(连接)并返回当前 Stellar 地址 |
getNetwork() | 获取当前网络信息 |
signTransaction(xdr, opts?) | 签名 Stellar 交易 XDR |
signAuthEntry(authEntry, opts?) | 签名 Stellar Auth Entry(授权条目 XDR) |
signMessage(message, opts?) | 签名任意消息 |
属性
| 属性 | 类型 | 描述 |
|---|---|---|
isOneKey | boolean | OneKey 标识 |
类型
export type StellarGetAddressParams = { path?: string }
export type StellarGetAddressResponse = { address: string }
export type StellarNetworkInfo = {
network: string
networkPassphrase: string
}
export type StellarSignTransactionOpts = {
networkPassphrase?: string
address?: string
path?: string
submit?: boolean
submitUrl?: string
}
export type StellarSignTransactionResponse = {
signedTxXdr: string
signerAddress?: string
}
export type StellarSignAuthEntryOpts = {
networkPassphrase?: string
address?: string
path?: string
}
export type StellarSignAuthEntryResponse = {
signedAuthEntry: string
signerAddress?: string
}
export type StellarSignMessageOpts = {
networkPassphrase?: string
address?: string
path?: string
}
export type StellarSignMessageResponse = {
signedMessage: string
signerAddress?: string
}基础类型(仅供参考)
export type OneKeyStellarProvider = {
isOneKey: boolean
// Align with Stellar Wallets Kit (KitActions)
getAddress: (params?: StellarGetAddressParams) => Promise<StellarGetAddressResponse>
getNetwork: () => Promise<StellarNetworkInfo>
signTransaction: (
xdr: string,
opts?: StellarSignTransactionOpts
) => Promise<StellarSignTransactionResponse>
signAuthEntry: (
authEntry: string,
opts?: StellarSignAuthEntryOpts
) => Promise<StellarSignAuthEntryResponse>
signMessage: (
message: string,
opts?: StellarSignMessageOpts
) => Promise<StellarSignMessageResponse>
}所有方法均返回 Promise。请处理请求被拒绝的情况,并按可选字段处理 signerAddress,不要假定它总会出现。provider 还提供 disconnect(),并通过 accountsChanged 发出地址字符串或 null;账户变化后应清除相关状态。
最后更新于