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
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ export class BurnNftTransaction extends Transaction {
data: this._transactionData || this.getBurnNftData(),
},
];

this._recipients = [
{
address: this._contract,
amount: '0',
},
];
}

/**
Expand Down Expand Up @@ -115,12 +122,13 @@ export class BurnNftTransaction extends Transaction {
if (this.transactionData.startsWith(BURN_NFT_METHOD_ID)) {
this.tokenId = utils.decodeBurnNftData(this.transactionData);
}

// Set sender address
if (signedTx.signature && signedTx.origin) {
this.sender = signedTx.origin.toString().toLowerCase();
}

this.loadInputsAndOutputs();

// Set signatures if present
if (signedTx.signature) {
// First signature is sender's signature
Expand Down
14 changes: 14 additions & 0 deletions modules/sdk-coin-vet/src/lib/transaction/exitDelegation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { EXIT_DELEGATION_METHOD_ID } from '../constants';
import EthereumAbi from 'ethereumjs-abi';
import { addHexPrefix } from 'ethereumjs-util';
import utils from '../utils';
import BigNumber from 'bignumber.js';

export class ExitDelegationTransaction extends Transaction {
private _tokenId: string;
Expand Down Expand Up @@ -47,6 +48,13 @@ export class ExitDelegationTransaction extends Transaction {
data: this._transactionData || this.getExitDelegationData(),
},
];

this._recipients = [
{
address: this._contract,
amount: '0',
},
];
}

/**
Expand Down Expand Up @@ -115,12 +123,18 @@ export class ExitDelegationTransaction extends Transaction {
if (this.transactionData.startsWith(EXIT_DELEGATION_METHOD_ID)) {
this.tokenId = utils.decodeExitDelegationData(this.transactionData);
}
this.recipients = body.clauses.map((clause) => ({
address: (clause.to || '0x0').toString().toLowerCase(),
amount: new BigNumber(clause.value || 0).toString(),
}));

// Set sender address
if (signedTx.signature && signedTx.origin) {
this.sender = signedTx.origin.toString().toLowerCase();
}

this.loadInputsAndOutputs();

// Set signatures if present
if (signedTx.signature) {
// First signature is sender's signature
Expand Down
24 changes: 20 additions & 4 deletions modules/sdk-coin-vet/test/transactionBuilder/burnNftBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,27 @@ describe('Vet Burn NFT Transaction', () => {
should.equal(tx.expiration, 64);
should.equal(tx.type, TransactionType.StakingWithdraw);

// Verify the transaction data contains the correct method ID
// Verify the transaction data contains the correct method ID and tokenId
tx.clauses[0].data.should.startWith(BURN_NFT_METHOD_ID);

// Verify the transaction has the correct structure
tx.clauses.length.should.equal(1);
should.equal(tx.clauses[0].to, STARGATE_NFT_ADDRESS_TESTNET);
should.equal(tx.clauses[0].value, '0x0');
should.exist(tx.clauses[0]);
should.exist(tx.clauses[0].to);
tx.clauses[0]?.to?.should.equal(STARGATE_NFT_ADDRESS_TESTNET);
should.exist(tx.clauses[0].value);
tx.clauses[0].value.should.equal('0x0');

tx.inputs.length.should.equal(1);
tx.outputs.length.should.equal(1);

should.equal(tx.inputs[0].address, testData.addresses.validAddresses[0]);
should.equal(tx.inputs[0].value, '0');
should.equal(tx.inputs[0].coin, 'tvet');

should.equal(tx.outputs[0].address, STARGATE_NFT_ADDRESS_TESTNET);
should.equal(tx.outputs[0].value, '0');
should.equal(tx.outputs[0].coin, 'tvet');
});

it('should build a burn NFT transaction with custom contract address', async function () {
Expand All @@ -59,7 +73,9 @@ describe('Vet Burn NFT Transaction', () => {
const tx = (await txBuilder.build()) as BurnNftTransaction;

should.equal(tx.contract, customContractAddress);
should.equal(tx.clauses[0].to, customContractAddress);
should.exist(tx.clauses[0]);
should.exist(tx.clauses[0].to);
tx.clauses[0]?.to?.should.equal(customContractAddress);
});

it('should deserialize and reserialize a signed burn NFT transaction', async function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ describe('Vet Exit Delegation Transaction', () => {
tx.clauses[0]?.to?.should.equal(STARGATE_DELEGATION_ADDRESS_TESTNET);
should.exist(tx.clauses[0].value);
tx.clauses[0].value.should.equal('0x0');

tx.inputs.length.should.equal(1);
tx.outputs.length.should.equal(1);

should.equal(tx.inputs[0].address, testData.addresses.validAddresses[0]);
should.equal(tx.inputs[0].value, '0');
should.equal(tx.inputs[0].coin, 'tvet');

should.equal(tx.outputs[0].address, STARGATE_DELEGATION_ADDRESS_TESTNET);
should.equal(tx.outputs[0].value, '0');
should.equal(tx.outputs[0].coin, 'tvet');
});

it('should build an exit delegation transaction with custom contract address', async function () {
Expand Down