diff --git a/package.json b/package.json index 2f092e8c..dff120df 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@safe-global/safe-gateway-typescript-sdk", - "version": "3.22.6", + "version": "3.22.7-beta.2", "main": "dist/index.js", "types": "dist/index.d.ts", "files": [ diff --git a/src/index.ts b/src/index.ts index 4a0b7059..0ade6438 100644 --- a/src/index.ts +++ b/src/index.ts @@ -303,13 +303,14 @@ export function proposeTransaction( export function getConfirmationView( chainId: string, safeAddress: string, + operation: operations['data_decoder']['parameters']['body']['operation'], data: operations['data_decoder']['parameters']['body']['data'], to?: operations['data_decoder']['parameters']['body']['to'], value?: operations['data_decoder']['parameters']['body']['value'], ): Promise { return postEndpoint(baseUrl, '/v1/chains/{chainId}/safes/{safe_address}/views/transaction-confirmation', { path: { chainId, safe_address: safeAddress }, - body: { data, to, value }, + body: { operation, data, to, value }, }) } @@ -319,13 +320,14 @@ export function getConfirmationView( export function getTxPreview( chainId: string, safeAddress: string, + operation: operations['data_decoder']['parameters']['body']['operation'], data: operations['data_decoder']['parameters']['body']['data'], to?: operations['data_decoder']['parameters']['body']['to'], value?: operations['data_decoder']['parameters']['body']['value'], ): Promise { return postEndpoint(baseUrl, '/v1/chains/{chainId}/transactions/{safe_address}/preview', { path: { chainId, safe_address: safeAddress }, - body: { data, to, value }, + body: { operation, data, to, value }, }) } @@ -374,12 +376,13 @@ export function getMasterCopies(chainId: string): Promise { */ export function getDecodedData( chainId: string, + operation: operations['data_decoder']['parameters']['body']['operation'], encodedData: operations['data_decoder']['parameters']['body']['data'], to?: operations['data_decoder']['parameters']['body']['to'], ): Promise { return postEndpoint(baseUrl, '/v1/chains/{chainId}/data-decoder', { path: { chainId: chainId }, - body: { data: encodedData, to }, + body: { operation, data: encodedData, to }, }) } diff --git a/src/types/decoded-data.ts b/src/types/decoded-data.ts index d5ae5d04..dc594556 100644 --- a/src/types/decoded-data.ts +++ b/src/types/decoded-data.ts @@ -11,6 +11,7 @@ export enum ConfirmationViewTypes { } export type DecodedDataRequest = { + operation: 0 | 1 data: string to?: string value?: string diff --git a/src/types/transactions.ts b/src/types/transactions.ts index 0918ec6c..71a10c39 100644 --- a/src/types/transactions.ts +++ b/src/types/transactions.ts @@ -525,6 +525,7 @@ export type TransactionDetails = { detailedExecutionInfo?: DetailedExecutionInfo txHash?: string safeAppInfo?: SafeAppInfo + note?: string | null } /* Transaction details types end */ diff --git a/tests/endpoint.test.ts b/tests/endpoint.test.ts index bcb1805b..6dbbe81c 100644 --- a/tests/endpoint.test.ts +++ b/tests/endpoint.test.ts @@ -104,35 +104,18 @@ describe('getEndpoint', () => { expect(getData).toHaveBeenCalledWith('/test-url?raw=true', undefined, undefined) }) - it('should call a data decoder POST endpoint', async () => { + it('should call a tx preview POST endpoint', async () => { await expect( - postEndpoint('https://test.test', '/v1/chains/{chainId}/data-decoder', { - path: { chainId: '4' }, - body: { data: '0x123' }, - }), - ).resolves.toEqual({ success: true }) - - expect(fetchData).toHaveBeenCalledWith( - 'https://test.test/v1/chains/4/data-decoder', - 'POST', - { data: '0x123' }, - undefined, - undefined, - ) - }) - - it('should call a data decoder confirmation view POST endpoint', async () => { - await expect( - postEndpoint('https://test.test', '/v1/chains/{chainId}/safes/{safe_address}/views/transaction-confirmation', { + postEndpoint('https://test.test', '/v1/chains/{chainId}/transactions/{safe_address}/preview', { path: { chainId: '4', safe_address: '0x123' }, - body: { data: '0x456' }, + body: { data: '0x456', operation: 0 }, }), ).resolves.toEqual({ success: true }) expect(fetchData).toHaveBeenCalledWith( - 'https://test.test/v1/chains/4/safes/0x123/views/transaction-confirmation', + 'https://test.test/v1/chains/4/transactions/0x123/preview', 'POST', - { data: '0x456' }, + { data: '0x456', operation: 0 }, undefined, undefined, )