-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add nostr support & fix sdk-kit e2e test (#2673)
* finish * test * fix
- Loading branch information
Showing
15 changed files
with
156 additions
and
898 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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,27 @@ | ||
// Copyright (c) RoochNetwork | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { Address } from './address.js' | ||
import { BitcoinAddress, BitcoinNetowkType } from './bitcoin.js' | ||
import { NoStrAddress } from './nostr.js' | ||
import { RoochAddress } from './rooch.js' | ||
import { Bytes } from '../types/index.js' | ||
|
||
export class AddressView implements Address { | ||
public readonly bitcoinAddress: BitcoinAddress | ||
public readonly noStrAddress: NoStrAddress | ||
public readonly roochAddress: RoochAddress | ||
|
||
constructor(publicKey: Bytes, network: BitcoinNetowkType = BitcoinNetowkType.Regtest) { | ||
this.bitcoinAddress = BitcoinAddress.fromPublicKey(publicKey, network) | ||
this.noStrAddress = new NoStrAddress(publicKey) | ||
this.roochAddress = this.bitcoinAddress.genRoochAddress() | ||
} | ||
|
||
toBytes(): Uint8Array { | ||
return this.roochAddress.toBytes() | ||
} | ||
toStr(): string { | ||
return this.roochAddress.toStr() | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright (c) RoochNetwork | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { bech32 } from '@scure/base' | ||
import { RoochAddress } from './rooch.js' | ||
import { BitcoinAddress } from './bitcoin.js' | ||
import { Bytes } from '../types/bytes.js' | ||
|
||
const PREFIX_BECH32_PUBLIC_KEY = 'npub' | ||
|
||
export class NoStrAddress { | ||
private readonly str: string | ||
private readonly bytes: Bytes | ||
|
||
constructor(input: string | Bytes) { | ||
if (typeof input === 'string') { | ||
this.str = input | ||
this.bytes = bech32.decodeToBytes(input).bytes | ||
return | ||
} | ||
|
||
this.bytes = input | ||
this.str = bech32.encode(PREFIX_BECH32_PUBLIC_KEY, bech32.toWords(input), false) | ||
} | ||
|
||
genRoochAddress(): RoochAddress { | ||
return BitcoinAddress.fromPublicKey(this.bytes).genRoochAddress() | ||
} | ||
|
||
toStr(): string { | ||
return this.str | ||
} | ||
|
||
toBytes(): Bytes { | ||
return this.bytes | ||
} | ||
} |
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
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
Oops, something went wrong.