Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ton): add single nominator withdraw txn #4923

Merged
merged 1 commit into from
Sep 27, 2024

Conversation

quarterdill
Copy link
Contributor

Ticket: SC-370

Add TON single nominator withdraw transaction

@quarterdill quarterdill force-pushed the sc-370-implement-single-nominator-unstaking-txn branch 2 times, most recently from 587134c to 845ce0a Compare September 20, 2024 17:48
@quarterdill quarterdill force-pushed the sc-370-implement-single-nominator-unstaking-txn branch 6 times, most recently from 54d7e50 to a27999e Compare September 23, 2024 14:12
@quarterdill quarterdill force-pushed the sc-370-implement-single-nominator-unstaking-txn branch 2 times, most recently from f57e2bc to bb33dea Compare September 26, 2024 17:06
@quarterdill quarterdill marked this pull request as ready for review September 26, 2024 17:07
@quarterdill quarterdill requested review from a team as code owners September 26, 2024 17:07
send(recipient: Recipient): SingleNominatorWithdrawBuilder {
this.transaction.recipient = recipient;
return this;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need add a method for withdrawAmount, and build message payload internally. And return error if user is trying to set a message.

txBuilder.publicKey(testData.sender.publicKey);
txBuilder.expireTime(1234567890);
txBuilder.send(testData.recipients[0]);
txBuilder.setWithdrawMessage('1');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where to set withdraw amount

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i split the message creation into setWithdrawAmount and setWithdrawMessage functions

txBuilder.bounceable(true);
const tx = await txBuilder.build();
should.equal(tx.type, TransactionType.SingleNominatorWithdraw);
should.equal(tx.toJson().bounceable, true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tx.toJson should have a withdraw amount decoded.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added the checks

jsonTx.amount.should.equal('10000000');
jsonTx.seqno.should.equal(6);
jsonTx.expirationTime.should.equal(1695997582);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should add a withdraw amount in toJson and verify in this test.

});

it('should build a signed withdraw tx and submit onchain', async function () {
const tonweb = new TonWeb(new TonWeb.HttpProvider('https://testnet.toncenter.com/api/v2/jsonRPC'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disable this test for ci

const explainedTransaction = (await basecoin.explainTransaction({
txHex: Buffer.from(testData.signedTransferTransaction.tx, 'base64').toString('hex'),
})) as TransactionExplanation;
explainedTransaction.should.deepEqual({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need add withdraw amount to explainTransaction for single nominator transaction

@quarterdill quarterdill force-pushed the sc-370-implement-single-nominator-unstaking-txn branch from bb33dea to bc9ec3b Compare September 26, 2024 21:42
@quarterdill quarterdill force-pushed the sc-370-implement-single-nominator-unstaking-txn branch from bc9ec3b to 1a410f4 Compare September 26, 2024 22:13
@quarterdill quarterdill force-pushed the sc-370-implement-single-nominator-unstaking-txn branch from 1a410f4 to f89be52 Compare September 26, 2024 22:33
@quarterdill quarterdill merged commit 4954d06 into master Sep 27, 2024
6 checks passed
@quarterdill quarterdill deleted the sc-370-implement-single-nominator-unstaking-txn branch September 27, 2024 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants