diff --git a/packages/cardano-services-client/test/HttpProvider.test.ts b/packages/cardano-services-client/test/HttpProvider.test.ts index 0dbd50dd041..d02a8884e9e 100644 --- a/packages/cardano-services-client/test/HttpProvider.test.ts +++ b/packages/cardano-services-client/test/HttpProvider.test.ts @@ -11,8 +11,8 @@ import path from 'path'; const packageJson = require(path.join(__dirname, '..', 'package.json')); -type ComplexArg2 = { map: Map }; -type ComplexResponse = Map[]; +type ComplexArg2 = { map: Map }; +type ComplexResponse = Map[]; interface TestProvider extends Provider { noArgsEmptyReturn(): Promise; complexArgsAndReturn({ arg1, arg2 }: { arg1: bigint; arg2: ComplexArg2 }): Promise; @@ -95,8 +95,8 @@ describe('createHttpProvider', () => { describe('method with complex args and return', () => { it('serializes args and deserializes response using core serializableObject', async () => { const arg1 = 123n; - const arg2: ComplexArg2 = { map: new Map([['key', Buffer.from('abc')]]) }; - const expectedResponse: ComplexResponse = [new Map([[1234n, Buffer.from('response data')]])]; + const arg2: ComplexArg2 = { map: new Map([['key', new Uint8Array(Buffer.from('abc'))]]) }; + const expectedResponse: ComplexResponse = [new Map([[1234n, new Uint8Array(Buffer.from('response data'))]])]; const provider = createTxSubmitProviderClient(); closeServer = await createStubHttpProviderServer(port, stubProviderPaths.complexArgsAndReturn, (req, res) => { expect(fromSerializableObject(req.body)).toEqual({ arg1, arg2 }); diff --git a/packages/ogmios/test/CardanoNode/__snapshots__/ObservableOgmiosCardanoNode.test.ts.snap b/packages/ogmios/test/CardanoNode/__snapshots__/ObservableOgmiosCardanoNode.test.ts.snap index 7709f1437ee..a74c1cc3388 100644 --- a/packages/ogmios/test/CardanoNode/__snapshots__/ObservableOgmiosCardanoNode.test.ts.snap +++ b/packages/ogmios/test/CardanoNode/__snapshots__/ObservableOgmiosCardanoNode.test.ts.snap @@ -73,21 +73,15 @@ Array [ "witness": Object { "bootstrap": Array [], "datums": Array [ - Object { - "data": Array [], - "type": "Buffer", - }, + Uint8Array [], ], "redeemers": Array [ Object { - "data": Object { - "data": Array [ - 77, - 53, - 122, - ], - "type": "Buffer", - }, + "data": Uint8Array [ + 77, + 53, + 122, + ], "executionUnits": Object { "memory": 8959327235984229000n, "steps": 4473903472119932000n, @@ -112,21 +106,15 @@ Array [ "cbor": "9f2341e14478c0fcf5ff", "items": Array [ -4n, - Object { - "data": Array [ - 225, - ], - "type": "Buffer", - }, - Object { - "data": Array [ - 120, - 192, - 252, - 245, - ], - "type": "Buffer", - }, + Uint8Array [ + 225, + ], + Uint8Array [ + 120, + 192, + 252, + 245, + ], ], }, }, @@ -137,14 +125,11 @@ Array [ "fields": Object { "cbor": "9f438002ab0104ff", "items": Array [ - Object { - "data": Array [ - 128, - 2, - 171, - ], - "type": "Buffer", - }, + Uint8Array [ + 128, + 2, + 171, + ], 1n, 4n, ], @@ -153,15 +138,12 @@ Array [ Object { "cbor": "a1448858788900", "data": Map { - Object { - "data": Array [ - 136, - 88, - 120, - 137, - ], - "type": "Buffer", - } => 0n, + Uint8Array [ + 136, + 88, + 120, + 137, + ] => 0n, }, }, ], @@ -175,10 +157,7 @@ Array [ "cbor": "a0", "data": Map {}, }, - Object { - "data": Array [], - "type": "Buffer", - }, + Uint8Array [], ], }, ], diff --git a/packages/ogmios/test/ogmiosToCore/__snapshots__/block.test.ts.snap b/packages/ogmios/test/ogmiosToCore/__snapshots__/block.test.ts.snap index 62d949eab24..b012c369323 100644 --- a/packages/ogmios/test/ogmiosToCore/__snapshots__/block.test.ts.snap +++ b/packages/ogmios/test/ogmiosToCore/__snapshots__/block.test.ts.snap @@ -138,12 +138,9 @@ Object { "data": Object { "cbor": "a34160029f20a3419c204386a48244e21bd936202004a0ffa3a4435aed90040242b07a210523409f414d429b3f0440ffa09f034001ffa222234041b4d8668218da9f2341440302413eff4204e1a1d866821901939f23ffa0", "data": Map { - Object { - "data": Array [ - 96, - ], - "type": "Buffer", - } => 2n, + Uint8Array [ + 96, + ] => 2n, Object { "cbor": "9f20a3419c204386a48244e21bd936202004a0ff", "items": Array [ @@ -151,28 +148,19 @@ Object { Object { "cbor": "a3419c204386a48244e21bd9362020", "data": Map { - Object { - "data": Array [ - 156, - ], - "type": "Buffer", - } => -1n, - Object { - "data": Array [ - 134, - 164, - 130, - ], - "type": "Buffer", - } => Object { - "data": Array [ - 226, - 27, - 217, - 54, - ], - "type": "Buffer", - }, + Uint8Array [ + 156, + ] => -1n, + Uint8Array [ + 134, + 164, + 130, + ] => Uint8Array [ + 226, + 27, + 217, + 54, + ], -1n => -1n, }, }, @@ -188,48 +176,30 @@ Object { Object { "cbor": "a4435aed90040242b07a21052340", "data": Map { - Object { - "data": Array [ - 90, - 237, - 144, - ], - "type": "Buffer", - } => 4n, - 2n => Object { - "data": Array [ - 176, - 122, - ], - "type": "Buffer", - }, + Uint8Array [ + 90, + 237, + 144, + ] => 4n, + 2n => Uint8Array [ + 176, + 122, + ], -2n => 5n, - -4n => Object { - "data": Array [], - "type": "Buffer", - }, + -4n => Uint8Array [], }, } => Object { "cbor": "9f414d429b3f0440ff", "items": Array [ - Object { - "data": Array [ - 77, - ], - "type": "Buffer", - }, - Object { - "data": Array [ - 155, - 63, - ], - "type": "Buffer", - }, + Uint8Array [ + 77, + ], + Uint8Array [ + 155, + 63, + ], 4n, - Object { - "data": Array [], - "type": "Buffer", - }, + Uint8Array [], ], }, Object { @@ -239,10 +209,7 @@ Object { "cbor": "9f034001ff", "items": Array [ 3n, - Object { - "data": Array [], - "type": "Buffer", - }, + Uint8Array [], 1n, ], }, @@ -250,15 +217,9 @@ Object { "cbor": "a222234041b4", "data": Map { -3n => -4n, - Object { - "data": Array [], - "type": "Buffer", - } => Object { - "data": Array [ - 180, - ], - "type": "Buffer", - }, + Uint8Array [] => Uint8Array [ + 180, + ], }, } => Object { "cbor": "d8668218da9f2341440302413eff", @@ -267,32 +228,23 @@ Object { "cbor": "9f2341440302413eff", "items": Array [ -4n, - Object { - "data": Array [ - 68, - ], - "type": "Buffer", - }, + Uint8Array [ + 68, + ], 3n, 2n, - Object { - "data": Array [ - 62, - ], - "type": "Buffer", - }, + Uint8Array [ + 62, + ], ], }, }, }, }, - Object { - "data": Array [ - 4, - 225, - ], - "type": "Buffer", - } => Object { + Uint8Array [ + 4, + 225, + ] => Object { "cbor": "a1d866821901939f23ffa0", "data": Map { Object { diff --git a/packages/util/src/serializableObject.ts b/packages/util/src/serializableObject.ts index d380ce617b3..01eb659e48d 100644 --- a/packages/util/src/serializableObject.ts +++ b/packages/util/src/serializableObject.ts @@ -104,7 +104,7 @@ const fromSerializableObjectUnknown = (obj: unknown, options: FromSerializableOb case 'bigint': return BigInt(docAsAny.value); case 'Buffer': - return Buffer.from(docAsAny.value, 'hex'); + return new Uint8Array(Buffer.from(docAsAny.value, 'hex')); case 'Date': return new Date(docAsAny.value); case 'Set': diff --git a/packages/util/test/serializableObject.test.ts b/packages/util/test/serializableObject.test.ts index 162f004fd7a..b8a661ed245 100644 --- a/packages/util/test/serializableObject.test.ts +++ b/packages/util/test/serializableObject.test.ts @@ -32,7 +32,7 @@ describe('serializableObject', () => { it('supports types that are used in SDK, but not natively supported in JSON', () => { const obj = { bigint: 123n, - buffer: Buffer.from('data'), + buffer: new Uint8Array(Buffer.from('data')), date: new Date(), error: new Error('error obj'), map: new Map([['key', 1n]]),