Skip to content

Commit

Permalink
feat(abstract-eth): add chain id as network identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
gianchandania committed Dec 29, 2023
1 parent 77492dc commit fbde1c3
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 5 deletions.
19 changes: 17 additions & 2 deletions modules/sdk-coin-etc/test/unit/transactionBuilder/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe('Etc send transaction', function () {
const sequenceId = 5;
txBuilder
.transfer()
.coin('tetc')
.amount(amount)
.to(recipient)
.expirationTime(1590066728)
Expand Down Expand Up @@ -61,14 +62,28 @@ describe('Etc send transaction', function () {

it('a send funds with amount 0 transaction', async () => {
initTxBuilder();
txBuilder.transfer().amount('0').to(testData.ACCOUNT_2).expirationTime(1590066728).contractSequenceId(5).key(key);
txBuilder
.transfer()
.coin('tetc')
.amount('0')
.to(testData.ACCOUNT_2)
.expirationTime(1590066728)
.contractSequenceId(5)
.key(key);
txBuilder.sign({ key: testData.PRIVATE_KEY_1 });
const tx = await txBuilder.build();
should.equal(tx.toBroadcastFormat(), testData.SEND_TX_AMOUNT_ZERO_BROADCAST);
});
it('unsigned transaction with final v check', async () => {
initTxBuilder();
txBuilder.transfer().amount('0').to(testData.ACCOUNT_2).expirationTime(1590066728).contractSequenceId(5).key(key);
txBuilder
.transfer()
.coin('tetc')
.amount('0')
.to(testData.ACCOUNT_2)
.expirationTime(1590066728)
.contractSequenceId(5)
.key(key);
const tx = await txBuilder.build();
should.equal(tx.toJson().v, '0xa1');
});
Expand Down
27 changes: 24 additions & 3 deletions modules/sdk-coin-rbtc/test/unit/transactionBuilder/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,14 @@ describe('Rbtc send transaction', function () {
initTxBuilder();
const recipient = testData.ACCOUNT_2;
const amount = '1000000000';
txBuilder.transfer().amount(amount).to(recipient).expirationTime(1590066728).contractSequenceId(5).key(key);
txBuilder
.transfer()
.coin('trbtc')
.amount(amount)
.to(recipient)
.expirationTime(1590066728)
.contractSequenceId(5)
.key(key);
txBuilder.sign({ key: testData.PRIVATE_KEY_1 });
const tx = await txBuilder.build();
should.equal(tx.toJson().chainId, 31);
Expand All @@ -63,14 +70,28 @@ describe('Rbtc send transaction', function () {
initTxBuilder();
const recipient = testData.ACCOUNT_2;
const amount = '1000000000';
txBuilder.transfer().amount(amount).to(recipient).expirationTime(1590066728).contractSequenceId(5).key(key);
txBuilder
.transfer()
.coin('trbtc')
.amount(amount)
.to(recipient)
.expirationTime(1590066728)
.contractSequenceId(5)
.key(key);
const tx = await txBuilder.build();
should.equal(tx.toJson().v, '0x61');
});

it('a send funds with amount 0 transaction', async () => {
initTxBuilder();
txBuilder.transfer().amount('0').to(testData.ACCOUNT_2).expirationTime(1590066728).contractSequenceId(5).key(key);
txBuilder
.transfer()
.coin('trbtc')
.amount('0')
.to(testData.ACCOUNT_2)
.expirationTime(1590066728)
.contractSequenceId(5)
.key(key);
txBuilder.sign({ key: testData.PRIVATE_KEY_1 });
const tx = await txBuilder.build();
should.equal(tx.toBroadcastFormat(), testData.SEND_TX_AMOUNT_ZERO_BROADCAST);
Expand Down

0 comments on commit fbde1c3

Please sign in to comment.