-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat.ord_index_check
- Loading branch information
Showing
12 changed files
with
201 additions
and
38 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// Copyright (c) RoochNetwork | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
export type SupportChain = 'rooch' | 'bitcoin' | 'eth' | ||
export type SupportWallet = 'metamask' | 'unisat' | 'okx' | ||
export type SupportChain = 'rooch' | 'bitcoin' | ||
export type SupportWallet = 'unisat' | 'okx' | 'onekey' //| 'onekey-hardware' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
sdk/typescript/rooch-sdk-kit/src/wellet/onekey-hardware.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// // Copyright (c) RoochNetwork | ||
// // SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// import onekey from '@onekeyfe/hd-web-sdk' | ||
// | ||
// import { BitcoinAddress, Bytes, ThirdPartyAddress, str, bytes } from '@roochnetwork/rooch-sdk' | ||
// import { BitcoinWallet } from '../wellet/index.js' | ||
// | ||
// type Device = { | ||
// connectId: string | null | ||
// uuid: string | ||
// deviceId: string | null | ||
// deviceType: string | ||
// name: string | ||
// } | ||
// | ||
// export class OnekeyHardwareWallet extends BitcoinWallet { | ||
// devices?: Device[] | ||
// | ||
// getName(): string { | ||
// return 'onekey-hardware' | ||
// } | ||
// | ||
// async sign(msg: Bytes): Promise<Bytes> { | ||
// const msgStr = str('utf8', msg) | ||
// const sign = await this.getTarget().signMessage(msgStr) | ||
// return bytes('base64', sign).subarray(1) | ||
// } | ||
// | ||
// getTarget(): any { | ||
// return undefined | ||
// } | ||
// | ||
// async connect(): Promise<ThirdPartyAddress[]> { | ||
// if (this.devices && this.devices.length > 0 && !this.currentAddress) { | ||
// await onekey.HardwareWebSdk.init({ | ||
// debug: true, | ||
// }) | ||
// } | ||
// | ||
// const { connectId, deviceId } = this.devices![0] | ||
// | ||
// const address = await onekey.HardwareWebSdk.btcGetAddress(connectId!, deviceId!, { | ||
// path: `m/86'/0'/x'/x/x`, // taproot | ||
// coin: 'btc', | ||
// }) | ||
// if (!address.success) { | ||
// throw Error(address.payload.error) | ||
// } | ||
// | ||
// const publicKey = await onekey.HardwareWebSdk.btcGetPublicKey(connectId!, deviceId!, { | ||
// path: `m/86'/0'/x'/x/x`, | ||
// coin: 'btc', | ||
// }) | ||
// | ||
// if (!publicKey.success) { | ||
// throw Error(publicKey.payload.error) | ||
// } | ||
// | ||
// this.address = [new BitcoinAddress(address.payload.address)] | ||
// this.currentAddress = this.address[0] | ||
// this.publicKey = publicKey.payload.xpub | ||
// | ||
// return this.address | ||
// } | ||
// | ||
// switchNetwork(): void { | ||
// this.getTarget().switchNetwork() | ||
// } | ||
// | ||
// getNetwork(): string { | ||
// return this.getTarget().getNetwork() | ||
// } | ||
// | ||
// getSupportNetworks(): string[] { | ||
// return ['livenet'] | ||
// } | ||
// | ||
// onAccountsChanged(callback: (account: string[]) => void): void { | ||
// this.getTarget().on('accountsChanged', callback) | ||
// } | ||
// | ||
// removeAccountsChanged(callback: (account: string[]) => void): void { | ||
// this.getTarget().removeListener('accountsChanged', callback) | ||
// } | ||
// | ||
// onNetworkChanged(callback: (network: string) => void): void { | ||
// this.getTarget().on('networkChanged', callback) | ||
// } | ||
// | ||
// removeNetworkChanged(callback: (network: string) => void): void { | ||
// this.getTarget().removeListener('networkChanged', callback) | ||
// } | ||
// | ||
// async checkInstalled(): Promise<boolean> { | ||
// // TODO: check feature, Ignore wallets that do not support bitcoin | ||
// const devices = await onekey.HardwareWebSdk.searchDevices() | ||
// this.devices = devices.success ? (devices.payload as []) : [] | ||
// return devices.success | ||
// } | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright (c) RoochNetwork | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { BitcoinAddress, Bytes, ThirdPartyAddress, str, bytes } from '@roochnetwork/rooch-sdk' | ||
import { BitcoinWallet } from '../wellet/index.js' | ||
|
||
export class OnekeyWallet extends BitcoinWallet { | ||
getName(): string { | ||
return 'onekey' | ||
} | ||
|
||
async sign(msg: Bytes): Promise<Bytes> { | ||
const msgStr = str('utf8', msg) | ||
const sign = await this.getTarget().signMessage(msgStr) | ||
return bytes('base64', sign).subarray(1) | ||
} | ||
|
||
getTarget(): any { | ||
return (window as any).$onekey?.btc | ||
} | ||
|
||
async connect(): Promise<ThirdPartyAddress[]> { | ||
let addresses: string[] = await this.getTarget().getAccounts() | ||
|
||
if (!addresses || addresses.length === 0) { | ||
await this.getTarget().requestAccounts() | ||
return this.connect() | ||
} | ||
|
||
let publicKey = await this.getTarget().getPublicKey() | ||
|
||
this.address = addresses.map((item) => new BitcoinAddress(item)) | ||
this.currentAddress = this.address[0] | ||
this.publicKey = publicKey | ||
|
||
return this.address | ||
} | ||
|
||
switchNetwork(): void { | ||
this.getTarget().switchNetwork() | ||
} | ||
|
||
getNetwork(): string { | ||
return this.getTarget().getNetwork() | ||
} | ||
|
||
getSupportNetworks(): string[] { | ||
return ['livenet'] | ||
} | ||
|
||
onAccountsChanged(callback: (account: string[]) => void): void { | ||
this.getTarget().on('accountsChanged', callback) | ||
} | ||
|
||
removeAccountsChanged(callback: (account: string[]) => void): void { | ||
this.getTarget().removeListener('accountsChanged', callback) | ||
} | ||
|
||
onNetworkChanged(callback: (network: string) => void): void { | ||
this.getTarget().on('networkChanged', callback) | ||
} | ||
|
||
removeNetworkChanged(callback: (network: string) => void): void { | ||
this.getTarget().removeListener('networkChanged', callback) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters