Skip to content

Commit e6814dc

Browse files
committed
feat(sdk-coin-ada): add CIP-8 message builder
TICKET: COIN-4724
1 parent 71fbabb commit e6814dc

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export * from './cip8Message';
2+
export * from './cip8MessageBuilder';
3+
export * from './messageBuilderFactory';
4+
export * from './utils';
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import should from 'should';
2+
import sinon from 'sinon';
3+
import { BaseCoin } from '@bitgo/statics';
4+
import { MessageStandardType } from '@bitgo/sdk-core';
5+
import { Cip8MessageBuilder, MessageBuilderFactory } from '../../../../src/lib/messages';
6+
7+
describe('MessageBuilderFactory', function () {
8+
let sandbox: sinon.SinonSandbox;
9+
let factory: MessageBuilderFactory;
10+
const coinConfig = { name: 'tada' } as BaseCoin;
11+
12+
beforeEach(function () {
13+
sandbox = sinon.createSandbox();
14+
factory = new MessageBuilderFactory(coinConfig);
15+
});
16+
17+
afterEach(function () {
18+
sandbox.restore();
19+
});
20+
21+
describe('getMessageBuilder', function () {
22+
it('should return CIP8 message builder for CIP8 type', function () {
23+
const builder = factory.getMessageBuilder(MessageStandardType.CIP8);
24+
should.exist(builder);
25+
builder.should.be.instanceof(Cip8MessageBuilder);
26+
});
27+
28+
it('should throw error for unsupported message type', function () {
29+
const unsupportedTypes = ['UNSUPPORTED' as MessageStandardType];
30+
31+
unsupportedTypes.forEach((type) => {
32+
should.throws(() => factory.getMessageBuilder(type), /Invalid message standard UNSUPPORTED/);
33+
});
34+
});
35+
});
36+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './cip8';

0 commit comments

Comments
 (0)