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 Jan 2, 2024
1 parent f4507ee commit 4154e06
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion modules/abstract-eth/src/lib/transferBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export class TransferBuilder {
if (this._signKey) {
this._signature = this.ethSignMsgHash();
}
return this._signature as string;
return this._signature!;
}

protected ethSignMsgHash(): string {
Expand Down
24 changes: 14 additions & 10 deletions modules/abstract-eth/test/unit/transferBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ describe('Eth send multi sig builder', function () {
'xprv9s21ZrQH143K3D8TXfvAJgHVfTEeQNW5Ys9wZtnUZkqPzFzSjbEJrWC1vZ4GnXCvR7rQL2UFX3RSuYeU9MrERm1XBvACow7c36vnz5iYyj2';
const key = new KeyPair({ prv: xprv }).getKeys().prv as string;
const amount = '100000000000000000'; // equivalent to 0.1 ether
const ethLikeCoins = ['hteth', 'tarbeth', 'topeth', 'zketh'];

describe('should fail', () => {
it('should fail if a coin does not exists in @bitgo/statics', () => {
Expand All @@ -16,16 +17,19 @@ describe('Eth send multi sig builder', function () {
}).throw();
});

it('should fail with an invalid key', () => {
const builder = new TransferBuilder()
.expirationTime(1590078260)
.amount(amount)
.to(toAddress)
.contractSequenceId(2)
.key('invalidkey');
should(() => {
builder.signAndBuild();
}).throw('private key length is invalid');
ethLikeCoins.forEach((coin) => {
it('should fail with an invalid key', () => {
const builder = new TransferBuilder()
.coin(coin)
.expirationTime(1590078260)
.amount(amount)
.to(toAddress)
.contractSequenceId(2)
.key('invalidkey');
should(() => {
builder.signAndBuild();
}).throw('private key length is invalid');
});
});

it('should fail with an invalid sequence id', () => {
Expand Down

0 comments on commit 4154e06

Please sign in to comment.