Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/js-evo-sdk/src/addresses/facade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* @param address - The platform address to query (PlatformAddress, Uint8Array, or bech32m string)
* @returns ProofMetadataResponse containing PlatformAddressInfo with proof information
*/
async getWithProof(address: wasm.PlatformAddressLike): Promise<wasm.ProofMetadataResponseTyped<wasm.PlatformAddressInfo>> {

Check warning on line 28 in packages/js-evo-sdk/src/addresses/facade.ts

View workflow job for this annotation

GitHub Actions / JS packages (@dashevo/evo-sdk) / Linting

This line has a length of 125. Maximum allowed is 120
const w = await this.sdk.getWasmSdkConnected();
return w.getAddressInfoWithProofInfo(address);
}
Expand Down Expand Up @@ -64,7 +64,7 @@
*
* @example
* ```typescript
* const recipientAddr = PlatformAddress.fromBech32m("tevo1...");
* const recipientAddr = PlatformAddress.fromBech32m("tdash1...");
* const privateKey = PrivateKey.fromWIF("cPrivateKeyWif...");
*
* const signer = new PlatformAddressSigner();
Expand All @@ -80,7 +80,7 @@
* });
* ```
*/
async transfer(options: wasm.AddressFundsTransferOptions): Promise<Map<wasm.PlatformAddress, wasm.PlatformAddressInfo>> {

Check warning on line 83 in packages/js-evo-sdk/src/addresses/facade.ts

View workflow job for this annotation

GitHub Actions / JS packages (@dashevo/evo-sdk) / Linting

This line has a length of 123. Maximum allowed is 120
const w = await this.sdk.getWasmSdkConnected();
return w.addressFundsTransfer(options);
}
Expand Down Expand Up @@ -142,7 +142,7 @@
* });
* ```
*/
async withdraw(options: wasm.AddressFundsWithdrawOptions): Promise<Map<wasm.PlatformAddress, wasm.PlatformAddressInfo>> {

Check warning on line 145 in packages/js-evo-sdk/src/addresses/facade.ts

View workflow job for this annotation

GitHub Actions / JS packages (@dashevo/evo-sdk) / Linting

This line has a length of 123. Maximum allowed is 120
const w = await this.sdk.getWasmSdkConnected();
return w.addressFundsWithdraw(options);
}
Expand All @@ -156,7 +156,7 @@
* @example
* ```typescript
* const identityId = Identifier.from("...");
* const recipientAddr = PlatformAddress.fromBech32m("tevo1...");
* const recipientAddr = PlatformAddress.fromBech32m("tdash1...");
* const privateKey = PrivateKey.fromWIF("cPrivateKeyWif..."); // Identity transfer key
*
* const output = new PlatformAddressOutput(recipientAddr, 100000n);
Expand All @@ -175,7 +175,7 @@
* console.log(`Updated addresses:`, result.addressInfos);
* ```
*/
async transferFromIdentity(options: wasm.IdentityTransferToAddressesOptions): Promise<wasm.IdentityTransferToAddressesResult> {

Check warning on line 178 in packages/js-evo-sdk/src/addresses/facade.ts

View workflow job for this annotation

GitHub Actions / JS packages (@dashevo/evo-sdk) / Linting

This line has a length of 129. Maximum allowed is 120
const w = await this.sdk.getWasmSdkConnected();
return w.identityTransferToAddresses(options);
}
Expand Down Expand Up @@ -211,7 +211,7 @@
* });
* ```
*/
async fundFromAssetLock(options: wasm.AddressFundingFromAssetLockOptions): Promise<Map<wasm.PlatformAddress, wasm.PlatformAddressInfo>> {

Check warning on line 214 in packages/js-evo-sdk/src/addresses/facade.ts

View workflow job for this annotation

GitHub Actions / JS packages (@dashevo/evo-sdk) / Linting

This line has a length of 139. Maximum allowed is 120
const w = await this.sdk.getWasmSdkConnected();
return w.addressFundingFromAssetLock(options);
}
Expand Down Expand Up @@ -251,7 +251,7 @@
* console.log('Updated addresses:', result.addressInfos);
* ```
*/
async createIdentity(options: wasm.IdentityCreateFromAddressesOptions): Promise<wasm.IdentityCreateFromAddressesResult> {

Check warning on line 254 in packages/js-evo-sdk/src/addresses/facade.ts

View workflow job for this annotation

GitHub Actions / JS packages (@dashevo/evo-sdk) / Linting

This line has a length of 123. Maximum allowed is 120
const w = await this.sdk.getWasmSdkConnected();
return w.identityCreateFromAddresses(options);
}
Expand Down
28 changes: 14 additions & 14 deletions packages/js-evo-sdk/tests/unit/facades/addresses.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('AddressesFacade', () => {
getAddressesInfosWithProofInfoStub = this.sinon.stub(wasmSdk, 'getAddressesInfosWithProofInfo').resolves('ok');
// Create a mock PlatformAddress for test results
const mockAddress = wasmSDKPackage.PlatformAddress.fromBytes(
new Uint8Array([0xb0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),
new Uint8Array([0x00, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),
);
addressFundsTransferStub = this.sinon.stub(wasmSdk, 'addressFundsTransfer').resolves({
type: 'VerifiedAddressInfos',
Expand All @@ -35,7 +35,7 @@ describe('AddressesFacade', () => {

describe('get()', () => {
it('should forward string address to getAddressInfo', async () => {
const address = 'tevo1qr4nl2m5z7v7g7d2c4z6k8x9w3y2f5p6h0s1t4';
const address = 'tdash1qr4nl2m5z7v7g7d2c4z6k8x9w3y2f5p6qhvmrq';
await client.addresses.get(address);
expect(getAddressInfoStub).to.be.calledOnceWithExactly(address);
});
Expand All @@ -49,7 +49,7 @@ describe('AddressesFacade', () => {

describe('getWithProof()', () => {
it('should forward address to getAddressInfoWithProofInfo', async () => {
const address = 'tevo1qr4nl2m5z7v7g7d2c4z6k8x9w3y2f5p6h0s1t4';
const address = 'tdash1qr4nl2m5z7v7g7d2c4z6k8x9w3y2f5p6qhvmrq';
await client.addresses.getWithProof(address);
expect(getAddressInfoWithProofInfoStub).to.be.calledOnceWithExactly(address);
});
Expand All @@ -58,15 +58,15 @@ describe('AddressesFacade', () => {
describe('getMany()', () => {
it('should forward array of addresses to getAddressesInfos', async () => {
const addresses = [
'tevo1qr4nl2m5z7v7g7d2c4z6k8x9w3y2f5p6h0s1t4',
'tevo1abc123def456ghi789jkl012mno345pqr678st',
'tdash1qr4nl2m5z7v7g7d2c4z6k8x9w3y2f5p6qhvmrq',
'tdash1abc123def456ghi789jkl012mno345pqr678st',
];
await client.addresses.getMany(addresses);
expect(getAddressesInfosStub).to.be.calledOnceWithExactly(addresses);
});

it('should accept mixed address formats', async () => {
const bech32Address = 'tevo1qr4nl2m5z7v7g7d2c4z6k8x9w3y2f5p6h0s1t4';
const bech32Address = 'tdash1qr4nl2m5z7v7g7d2c4z6k8x9w3y2f5p6qhvmrq';
const bytesAddress = new Uint8Array(21);
const mixedAddresses = [bech32Address, bytesAddress];
await client.addresses.getMany(mixedAddresses);
Expand All @@ -77,7 +77,7 @@ describe('AddressesFacade', () => {
describe('getManyWithProof()', () => {
it('should forward array of addresses to getAddressesInfosWithProofInfo', async () => {
const addresses = [
'tevo1qr4nl2m5z7v7g7d2c4z6k8x9w3y2f5p6h0s1t4',
'tdash1qr4nl2m5z7v7g7d2c4z6k8x9w3y2f5p6qhvmrq',
];
await client.addresses.getManyWithProof(addresses);
expect(getAddressesInfosWithProofInfoStub).to.be.calledOnceWithExactly(addresses);
Expand All @@ -88,7 +88,7 @@ describe('AddressesFacade', () => {
it('should forward options to addressFundsTransfer with PlatformAddressSigner', async () => {
// Create proper PlatformAddress objects
const recipientAddr = wasmSDKPackage.PlatformAddress.fromBytes(
new Uint8Array([0xb0, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]),
new Uint8Array([0x00, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]),
);

// Create a PrivateKey object from bytes (32 bytes for testnet)
Expand Down Expand Up @@ -123,7 +123,7 @@ describe('AddressesFacade', () => {

// Create proper PlatformAddress objects
const recipientAddr = wasmSDKPackage.PlatformAddress.fromBytes(
new Uint8Array([0xb0, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]),
new Uint8Array([0x00, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]),
);

// Create a PrivateKey object from bytes
Expand Down Expand Up @@ -153,7 +153,7 @@ describe('AddressesFacade', () => {
it('should forward options to identityTopUpFromAddresses', async function topUpTest() {
// Create mock address and result
const mockAddress = wasmSDKPackage.PlatformAddress.fromBytes(
new Uint8Array([0xb0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),
new Uint8Array([0x00, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),
);

const identityTopUpFromAddressesStub: SinonStub = this.sinon.stub(wasmSdk, 'identityTopUpFromAddresses').resolves({
Expand Down Expand Up @@ -181,7 +181,7 @@ describe('AddressesFacade', () => {
it('should forward options to addressFundsWithdraw', async function withdrawTest() {
// Create mock address and result map
const mockAddress = wasmSDKPackage.PlatformAddress.fromBytes(
new Uint8Array([0xb0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),
new Uint8Array([0x00, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),
);

const resultMap = new Map();
Expand All @@ -208,7 +208,7 @@ describe('AddressesFacade', () => {
it('should forward options to identityTransferToAddresses', async function transferFromIdentityTest() {
// Create mock address
const mockAddress = wasmSDKPackage.PlatformAddress.fromBytes(
new Uint8Array([0xb0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),
new Uint8Array([0x00, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),
);

const identityTransferToAddressesStub: SinonStub = this.sinon.stub(wasmSdk, 'identityTransferToAddresses').resolves({
Expand Down Expand Up @@ -236,7 +236,7 @@ describe('AddressesFacade', () => {
it('should forward options to addressFundingFromAssetLock', async function fundFromAssetLockTest() {
// Create mock address and result map
const mockAddress = wasmSDKPackage.PlatformAddress.fromBytes(
new Uint8Array([0xb0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),
new Uint8Array([0x00, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),
);

const resultMap = new Map();
Expand All @@ -262,7 +262,7 @@ describe('AddressesFacade', () => {
it('should forward options to identityCreateFromAddresses', async function createIdentityTest() {
// Create mock address
const mockAddress = wasmSDKPackage.PlatformAddress.fromBytes(
new Uint8Array([0xb0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),
new Uint8Array([0x00, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),
);

// Create mock identity ID
Expand Down
8 changes: 4 additions & 4 deletions packages/wasm-dpp2/src/platform_address/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const PLATFORM_ADDRESS_TS_HELPERS: &str = r#"
* A Platform address can be provided as:
* - A PlatformAddress object
* - A Uint8Array (21 bytes: type byte + 20-byte hash)
* - A bech32m string (e.g., "evo1..." or "tevo1...")
* - A bech32m string (e.g., "dash1..." or "tdash1...")
*/
export type PlatformAddressLike = PlatformAddress | Uint8Array | string;

Expand Down Expand Up @@ -135,7 +135,7 @@ impl TryFrom<&str> for PlatformAddressWasm {
type Error = WasmDppError;

fn try_from(value: &str) -> Result<Self, Self::Error> {
// Try parsing as bech32m string first (e.g., "evo1..." or "tevo1...")
// Try parsing as bech32m string first (e.g., "dash1..." or "tdash1...")
if let Ok((addr, _network)) = PlatformAddress::from_bech32m_string(value) {
return Ok(PlatformAddressWasm(addr));
}
Expand Down Expand Up @@ -228,7 +228,7 @@ impl PlatformAddressWasm {
/// Creates a new PlatformAddress from various input types.
///
/// Accepts:
/// - A bech32m string (e.g., "evo1..." or "tevo1...")
/// - A bech32m string (e.g., "dash1..." or "tdash1...")
/// - A Uint8Array (21 bytes: type byte + 20-byte hash)
/// - An existing PlatformAddress object
#[wasm_bindgen(constructor)]
Expand Down Expand Up @@ -290,7 +290,7 @@ impl PlatformAddressWasm {

/// Creates a PlatformAddress from a bech32m-encoded string.
///
/// Accepts addresses with either mainnet ("evo") or testnet ("tevo") HRP.
/// Accepts addresses with either mainnet ("dash") or testnet ("tdash") HRP.
#[wasm_bindgen(js_name = "fromBech32m")]
pub fn from_bech32m(address: &str) -> WasmDppResult<PlatformAddressWasm> {
PlatformAddress::from_bech32m_string(address)
Expand Down
50 changes: 27 additions & 23 deletions packages/wasm-dpp2/tests/unit/PlatformAddress.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ before(async () => {
describe('PlatformAddress', () => {
describe('fromBytes()', () => {
it('should create P2PKH address from bytes', () => {
// Storage format: 0x00 = P2PKH variant index
const p2pkhBytes = new Uint8Array([
0xb0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
0x00, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
]);
const addr = wasm.PlatformAddress.fromBytes(p2pkhBytes);
expect(addr).to.exist();
Expand All @@ -19,8 +20,9 @@ describe('PlatformAddress', () => {
});

it('should create P2SH address from bytes', () => {
// Storage format: 0x01 = P2SH variant index
const p2shBytes = new Uint8Array([
0x80, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
0x01, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
]);
const addr = wasm.PlatformAddress.fromBytes(p2shBytes);
expect(addr).to.exist();
Expand All @@ -30,24 +32,25 @@ describe('PlatformAddress', () => {
});

it('should reject invalid address type', () => {
// 0x02 is not a valid variant index (only 0x00 and 0x01 are valid)
const invalidBytes = new Uint8Array([
0x00, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
0x02, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
]);
try {
wasm.PlatformAddress.fromBytes(invalidBytes);
expect.fail('Should have thrown error for invalid address type');
} catch (error: unknown) {
expect((error as Error).message).to.include('type');
expect(error).to.exist();
}
});

it('should reject wrong length', () => {
const shortBytes = new Uint8Array([0xb0, 1, 2, 3, 4, 5]);
const shortBytes = new Uint8Array([0x00, 1, 2, 3, 4, 5]);
try {
wasm.PlatformAddress.fromBytes(shortBytes);
expect.fail('Should have thrown error for wrong length');
} catch (error: unknown) {
expect((error as Error).message).to.include('21');
expect(error).to.exist();
}
});
});
Expand All @@ -56,12 +59,12 @@ describe('PlatformAddress', () => {
it('should create address from testnet bech32m string', () => {
// First create an address and get its bech32m
const bytes = new Uint8Array([
0xb0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
0x00, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
]);
const originalAddr = wasm.PlatformAddress.fromBytes(bytes);
const bech32m = originalAddr.toBech32m('testnet');

expect(bech32m.startsWith('tevo1')).to.be.true();
expect(bech32m.startsWith('tdash1')).to.be.true();

// Parse it back
const parsedAddr = wasm.PlatformAddress.fromBech32m(bech32m);
Expand All @@ -71,12 +74,12 @@ describe('PlatformAddress', () => {

it('should create address from mainnet bech32m string', () => {
const bytes = new Uint8Array([
0xb0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
0x00, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
]);
const originalAddr = wasm.PlatformAddress.fromBytes(bytes);
const bech32m = originalAddr.toBech32m('mainnet');

expect(bech32m.startsWith('evo1')).to.be.true();
expect(bech32m.startsWith('dash1')).to.be.true();

const parsedAddr = wasm.PlatformAddress.fromBech32m(bech32m);
expect(parsedAddr).to.exist();
Expand All @@ -95,7 +98,8 @@ describe('PlatformAddress', () => {

describe('fromHex()', () => {
it('should create address from hex string', () => {
const hexString = `b0${'01020304050607080910111213141516171819'.padEnd(40, '0').substring(0, 40)}`;
// Storage format: 00 = P2PKH variant index
const hexString = `00${'01020304050607080910111213141516171819'.padEnd(40, '0').substring(0, 40)}`;
const addr = wasm.PlatformAddress.fromHex(hexString);
expect(addr).to.exist();
expect(addr.addressType).to.equal('P2PKH');
Expand Down Expand Up @@ -154,7 +158,7 @@ describe('PlatformAddress', () => {
describe('constructor()', () => {
it('should accept PlatformAddress object', () => {
const bytes = new Uint8Array([
0xb0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
0x00, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
]);
const original = wasm.PlatformAddress.fromBytes(bytes);
const copy = new wasm.PlatformAddress(original);
Expand All @@ -164,7 +168,7 @@ describe('PlatformAddress', () => {

it('should accept Uint8Array', () => {
const bytes = new Uint8Array([
0xb0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
0x00, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
]);
const addr = new wasm.PlatformAddress(bytes);
expect(addr).to.exist();
Expand All @@ -173,7 +177,7 @@ describe('PlatformAddress', () => {

it('should accept bech32m string', () => {
const bytes = new Uint8Array([
0xb0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
0x00, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
]);
const original = wasm.PlatformAddress.fromBytes(bytes);
const bech32m = original.toBech32m('testnet');
Expand All @@ -187,7 +191,7 @@ describe('PlatformAddress', () => {
describe('toBytes()', () => {
it('should return 21-byte array', () => {
const inputBytes = new Uint8Array([
0xb0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
0x00, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
]);
const addr = wasm.PlatformAddress.fromBytes(inputBytes);
const outputBytes = addr.toBytes();
Expand All @@ -199,7 +203,7 @@ describe('PlatformAddress', () => {
describe('toHex()', () => {
it('should return hex string', () => {
const bytes = new Uint8Array([
0xb0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
0x00, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
]);
const addr = wasm.PlatformAddress.fromBytes(bytes);
const hex = addr.toHex();
Expand All @@ -211,7 +215,7 @@ describe('PlatformAddress', () => {
describe('hash()', () => {
it('should return 20-byte hash', () => {
const bytes = new Uint8Array([
0xb0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
0x00, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
]);
const addr = wasm.PlatformAddress.fromBytes(bytes);
const hash = addr.hash();
Expand All @@ -225,7 +229,7 @@ describe('PlatformAddress', () => {
describe('hashToHex()', () => {
it('should return hex string of hash', () => {
const bytes = new Uint8Array([
0xb0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
0x00, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
]);
const addr = wasm.PlatformAddress.fromBytes(bytes);
const hashHex = addr.hashToHex();
Expand All @@ -237,27 +241,27 @@ describe('PlatformAddress', () => {
describe('toBech32m()', () => {
it('should convert to testnet bech32m', () => {
const bytes = new Uint8Array([
0xb0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
0x00, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
]);
const addr = wasm.PlatformAddress.fromBytes(bytes);
const bech32m = addr.toBech32m('testnet');
expect(bech32m).to.be.a('string');
expect(bech32m.startsWith('tevo1')).to.be.true();
expect(bech32m.startsWith('tdash1')).to.be.true();
});

it('should convert to mainnet bech32m', () => {
const bytes = new Uint8Array([
0xb0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
0x00, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
]);
const addr = wasm.PlatformAddress.fromBytes(bytes);
const bech32m = addr.toBech32m('mainnet');
expect(bech32m).to.be.a('string');
expect(bech32m.startsWith('evo1')).to.be.true();
expect(bech32m.startsWith('dash1')).to.be.true();
});

it('should roundtrip through bech32m', () => {
const originalBytes = new Uint8Array([
0xb0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
0x00, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
]);
const addr = wasm.PlatformAddress.fromBytes(originalBytes);
const bech32m = addr.toBech32m('testnet');
Expand Down
Loading
Loading