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
2 changes: 1 addition & 1 deletion modules/sdk-coin-iota/src/lib/transferTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class TransferTransaction extends Transaction {
}
if (input.$kind === 'Pure' && 'bytes' in input.Pure) {
const value = fromBase64(input.Pure.bytes);
const hexValue = toHex(value);
const hexValue = '0x' + toHex(value);
if (utils.isValidAddress(hexValue)) {
receivers.push(hexValue);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ describe('Iota Transaction Builder Factory', () => {
const tx = (await txBuilder.build()) as TransferTransaction;
const rawTx = await tx.toBroadcastFormat();

// The from method should at least create a builder
// Note: Full round-trip parsing is not yet implemented
try {
const rebuiltBuilder = factory.from(rawTx);
should.exist(rebuiltBuilder);
should(rebuiltBuilder instanceof TransferBuilder).be.true();
} catch (e) {
// parseFromBroadcastTx may have issues - this is expected for now
should.exist(e);
}
const rebuiltBuilder = factory.from(rawTx);
should.exist(rebuiltBuilder);
should(rebuiltBuilder instanceof TransferBuilder).be.true();
const rebuiltTx = (await rebuiltBuilder.build()) as TransferTransaction;
rebuiltTx.sender.should.equal(testData.sender.address);
rebuiltTx.recipients.length.should.equal(testData.recipients.length);
rebuiltTx.recipients[0].address.should.equal(testData.recipients[0].address);
rebuiltTx.recipients[0].amount.should.equal(testData.recipients[0].amount);
should.exist(rebuiltTx.paymentObjects);
rebuiltTx.paymentObjects?.length.should.equal(testData.paymentObjects.length);
});

it('should handle Uint8Array format', async function () {
Expand All @@ -66,14 +66,16 @@ describe('Iota Transaction Builder Factory', () => {
const rawTx = await tx.toBroadcastFormat();
const rawTxBytes = Buffer.from(rawTx, 'base64');

try {
const rebuiltBuilder = factory.from(rawTxBytes);
should.exist(rebuiltBuilder);
should(rebuiltBuilder instanceof TransferBuilder).be.true();
} catch (e) {
// parseFromBroadcastTx may have issues - this is expected for now
should.exist(e);
}
const rebuiltBuilder = factory.from(rawTxBytes);
should.exist(rebuiltBuilder);
should(rebuiltBuilder instanceof TransferBuilder).be.true();
const rebuiltTx = (await rebuiltBuilder.build()) as TransferTransaction;
rebuiltTx.sender.should.equal(testData.sender.address);
rebuiltTx.recipients.length.should.equal(testData.recipients.length);
rebuiltTx.recipients[0].address.should.equal(testData.recipients[0].address);
rebuiltTx.recipients[0].amount.should.equal(testData.recipients[0].amount);
should.exist(rebuiltTx.paymentObjects);
rebuiltTx.paymentObjects?.length.should.equal(testData.paymentObjects.length);
});
});

Expand Down