Skip to content

Commit 9ca3f46

Browse files
committed
Revert "refactor: import should without (=)"
This reverts commit 516c30a. TICKET: SC-2419
1 parent 516c30a commit 9ca3f46

File tree

29 files changed

+61
-45
lines changed

29 files changed

+61
-45
lines changed

examples/ts/build-message.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99

1010
import {BitGoAPI} from '@bitgo/sdk-api';
11-
import {MessageStandardType, getMidnightGlacierDropMsg} from "@bitgo/sdk-core";
11+
import {MessageStandardType, getMidnightGlacierDropClaimMsg} from "@bitgo/sdk-core";
1212
import {Hteth} from "@bitgo/sdk-coin-eth";
1313
require('dotenv').config({ path: '../../.env' });
1414

@@ -30,7 +30,7 @@ async function main() {
3030

3131
const adaTestnetDestinationAddress = 'addr_test1vz7xs7ceu4xx9n5xn57lfe86vrwddqpp77vjwq5ptlkh49cqy3wur';
3232
const allocationAmt = 12345678;
33-
const testnetMessageRaw = getMidnightGlacierDropMsg(adaTestnetDestinationAddress, allocationAmt);
33+
const testnetMessageRaw = getMidnightGlacierDropClaimMsg(adaTestnetDestinationAddress, allocationAmt);
3434

3535
const txRequest = await wallet.buildSignMessageRequest({
3636
message: {

examples/ts/sign-message.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Copyright 2025, BitGo, Inc. All Rights Reserved.
55
*/
66
import { BitGo } from 'bitgo';
7-
import { getMidnightGlacierDropMsg, MessageStandardType } from '@bitgo/sdk-core';
7+
import { getMidnightGlacierDropClaimMsg, MessageStandardType } from '@bitgo/sdk-core';
88

99
const bitgo = new BitGo({ env: 'test' });
1010

@@ -20,7 +20,7 @@ async function signMessage(): Promise<void> {
2020

2121
const adaTestnetDestinationAddress = 'addr_test1vz7xs7ceu4xx9n5xn57lfe86vrwddqpp77vjwq5ptlkh49cqy3wur';
2222
const allocationAmt = 12345678;
23-
const testnetMessageRaw = getMidnightGlacierDropMsg(adaTestnetDestinationAddress, allocationAmt);
23+
const testnetMessageRaw = getMidnightGlacierDropClaimMsg(adaTestnetDestinationAddress, allocationAmt);
2424

2525
const messageTxn = await walletInstance.signMessage({
2626
message: {

modules/abstract-eth/src/lib/messages/eip191/eip191MessageBuilder.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,10 @@ export class Eip191MessageBuilder extends BaseMessageBuilder {
2222
async buildMessage(options: MessageOptions): Promise<IMessage> {
2323
return new EIP191Message(options);
2424
}
25+
26+
protected getWhitelistedMessageTemplates(): Record<string, string> {
27+
// EIP-191 does not have whitelisted message templates
28+
// This means all messages are allowed
29+
return {};
30+
}
2531
}

modules/account-lib/src/index.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -429,15 +429,13 @@ export async function verifyMessage(
429429
try {
430430
const messageBuilderFactory = getMessageBuilderFactory(coinName);
431431
const messageBuilder = messageBuilderFactory.getMessageBuilder(messageStandardType);
432-
messageBuilder.setPayload(messageRaw);
433-
const message = await messageBuilder.build();
434-
const isValidMessageEncoded = await message.verifyEncodedPayload(messageEncoded, metadata);
435-
if (!isValidMessageEncoded) {
432+
if (!messageBuilder || !messageBuilder.isMessageWhitelisted(messageRaw)) {
436433
return false;
437434
}
438-
return messageBuilder.isMessageWhitelisted(messageRaw);
435+
messageBuilder.setPayload(messageRaw);
436+
const message = await messageBuilder.build();
437+
return await message.verifyEncodedPayload(messageEncoded, metadata);
439438
} catch (e) {
440-
console.error(`Error verifying message for coin ${coinName}:`, e);
441439
return false;
442440
}
443441
}

modules/account-lib/test/unit/utils/messages/index.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,32 @@
11
import should from 'should';
22
import {
3-
getMidnightGlacierDropMsg,
3+
getMidnightGlacierDropClaimMsg,
44
isMessageWhitelisted,
55
MIDNIGHT_GLACIER_DROP_CLAIM_MESSAGE_TEMPLATE,
66
MIDNIGHT_TNC_HASH,
77
} from '@bitgo/sdk-core';
88

99
describe('Message validation', () => {
1010
describe('isMessageWhitelisted', () => {
11-
const whitelistedMessageTemplates = [MIDNIGHT_GLACIER_DROP_CLAIM_MESSAGE_TEMPLATE];
11+
const whitelistedMessageTemplates: Record<string, string> = {
12+
midnightGDClaimMsgTemplate: MIDNIGHT_GLACIER_DROP_CLAIM_MESSAGE_TEMPLATE,
13+
};
1214

1315
const adaTestnetDestinationAddress = 'addr_test1vz7xs7ceu4xx9n5xn57lfe86vrwddqpp77vjwq5ptlkh49cqy3wur';
1416
const adaMainnetDestinationAddress =
1517
'addr1q9k6u7lhf467y2f8skr2dafldx2npsd8fymq0mslnj0t44nd4ealwnt4ug5j0pvx5m6n76v4xrq6wjfkqlhpl8y7httq2m9cmu';
1618
const allocationAmt = 100;
1719

1820
it('should validate testnet message matching the Midnight glacier drop claim template', () => {
19-
const messageRaw = getMidnightGlacierDropMsg(adaTestnetDestinationAddress, allocationAmt);
21+
const messageRaw = getMidnightGlacierDropClaimMsg(adaTestnetDestinationAddress, allocationAmt);
2022

2123
const result = isMessageWhitelisted(whitelistedMessageTemplates, messageRaw);
2224

2325
should.equal(result, true);
2426
});
2527

2628
it('should validate mainnet message matching the Midnight glacier drop claim template', () => {
27-
const messageRaw = getMidnightGlacierDropMsg(adaMainnetDestinationAddress, allocationAmt);
29+
const messageRaw = getMidnightGlacierDropClaimMsg(adaMainnetDestinationAddress, allocationAmt);
2830

2931
const result = isMessageWhitelisted(whitelistedMessageTemplates, messageRaw);
3032

modules/account-lib/test/unit/verifyMessage.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import should from 'should';
22
import * as accountLib from '../../src';
3-
import { getMidnightGlacierDropMsg, MessageStandardType } from '@bitgo/sdk-core';
3+
import { getMidnightGlacierDropClaimMsg, MessageStandardType } from '@bitgo/sdk-core';
44

55
describe('verifyMessage', () => {
66
const adaTestnetOriginAddress = 'addr_test1wz4h6068hs93n8j5ar88fgzz6sfnw8krng09xx0mmf36m8c7j9yap';
77
const adaTestnetDestinationAddress = 'addr_test1vz7xs7ceu4xx9n5xn57lfe86vrwddqpp77vjwq5ptlkh49cqy3wur';
88
const allocationAmt = 100;
9-
const testnetMessageRaw = getMidnightGlacierDropMsg(adaTestnetDestinationAddress, allocationAmt);
9+
const testnetMessageRaw = getMidnightGlacierDropClaimMsg(adaTestnetDestinationAddress, allocationAmt);
1010

1111
describe('EIP191 Message', function () {
1212
const eip191MessageBuilder = accountLib

modules/sdk-coin-ada/test/unit/ada.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @prettier
33
*/
44

5-
import should from 'should';
5+
import should = require('should');
66
import { randomBytes } from 'crypto';
77
import * as sinon from 'sinon';
88
import { TestBitGo, TestBitGoAPI } from '@bitgo/sdk-test';

modules/sdk-coin-asi/test/unit/asi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import should from 'should';
1+
import should = require('should');
22
import BigNumber from 'bignumber.js';
33
import sinon from 'sinon';
44
import { TestBitGo, TestBitGoAPI } from '@bitgo/sdk-test';

modules/sdk-coin-atom/test/unit/atom.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
wrwUser,
2020
wrwUserDkls,
2121
} from '../resources/atom';
22-
import should from 'should';
22+
import should = require('should');
2323

2424
describe('ATOM', function () {
2525
let bitgo: TestBitGoAPI;

modules/sdk-coin-baby/test/unit/baby.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import BigNumber from 'bignumber.js';
44
import sinon from 'sinon';
55
import { Baby, Tbaby } from '../../src';
66
import { TEST_SEND_MANY_TX, TEST_SEND_TX, TEST_TX_WITH_MEMO, address } from '../resources/baby';
7-
import should from 'should';
7+
import should = require('should');
88
import utils from '../../src/lib/utils';
99

1010
describe('Babylon', function () {

0 commit comments

Comments
 (0)