Skip to content

Commit 06d0901

Browse files
authored
Feat: tx preview and tx notes (#209)
* Feat: tx preview and tx notes * Fix tests * Rm | null
1 parent 7b53ccf commit 06d0901

File tree

5 files changed

+14
-26
lines changed

5 files changed

+14
-26
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@safe-global/safe-gateway-typescript-sdk",
3-
"version": "3.22.6",
3+
"version": "3.22.7-beta.2",
44
"main": "dist/index.js",
55
"types": "dist/index.d.ts",
66
"files": [

src/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,13 +303,14 @@ export function proposeTransaction(
303303
export function getConfirmationView(
304304
chainId: string,
305305
safeAddress: string,
306+
operation: operations['data_decoder']['parameters']['body']['operation'],
306307
data: operations['data_decoder']['parameters']['body']['data'],
307308
to?: operations['data_decoder']['parameters']['body']['to'],
308309
value?: operations['data_decoder']['parameters']['body']['value'],
309310
): Promise<AnyConfirmationView> {
310311
return postEndpoint(baseUrl, '/v1/chains/{chainId}/safes/{safe_address}/views/transaction-confirmation', {
311312
path: { chainId, safe_address: safeAddress },
312-
body: { data, to, value },
313+
body: { operation, data, to, value },
313314
})
314315
}
315316

@@ -319,13 +320,14 @@ export function getConfirmationView(
319320
export function getTxPreview(
320321
chainId: string,
321322
safeAddress: string,
323+
operation: operations['data_decoder']['parameters']['body']['operation'],
322324
data: operations['data_decoder']['parameters']['body']['data'],
323325
to?: operations['data_decoder']['parameters']['body']['to'],
324326
value?: operations['data_decoder']['parameters']['body']['value'],
325327
): Promise<TransactionPreview> {
326328
return postEndpoint(baseUrl, '/v1/chains/{chainId}/transactions/{safe_address}/preview', {
327329
path: { chainId, safe_address: safeAddress },
328-
body: { data, to, value },
330+
body: { operation, data, to, value },
329331
})
330332
}
331333

@@ -374,12 +376,13 @@ export function getMasterCopies(chainId: string): Promise<MasterCopyReponse> {
374376
*/
375377
export function getDecodedData(
376378
chainId: string,
379+
operation: operations['data_decoder']['parameters']['body']['operation'],
377380
encodedData: operations['data_decoder']['parameters']['body']['data'],
378381
to?: operations['data_decoder']['parameters']['body']['to'],
379382
): Promise<DecodedDataResponse> {
380383
return postEndpoint(baseUrl, '/v1/chains/{chainId}/data-decoder', {
381384
path: { chainId: chainId },
382-
body: { data: encodedData, to },
385+
body: { operation, data: encodedData, to },
383386
})
384387
}
385388

src/types/decoded-data.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export enum ConfirmationViewTypes {
1111
}
1212

1313
export type DecodedDataRequest = {
14+
operation: 0 | 1
1415
data: string
1516
to?: string
1617
value?: string

src/types/transactions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@ export type TransactionDetails = {
532532
detailedExecutionInfo?: DetailedExecutionInfo
533533
txHash?: string
534534
safeAppInfo?: SafeAppInfo
535+
note?: string | null
535536
}
536537

537538
/* Transaction details types end */

tests/endpoint.test.ts

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -104,35 +104,18 @@ describe('getEndpoint', () => {
104104
expect(getData).toHaveBeenCalledWith('/test-url?raw=true', undefined, undefined)
105105
})
106106

107-
it('should call a data decoder POST endpoint', async () => {
107+
it('should call a tx preview POST endpoint', async () => {
108108
await expect(
109-
postEndpoint('https://test.test', '/v1/chains/{chainId}/data-decoder', {
110-
path: { chainId: '4' },
111-
body: { data: '0x123' },
112-
}),
113-
).resolves.toEqual({ success: true })
114-
115-
expect(fetchData).toHaveBeenCalledWith(
116-
'https://test.test/v1/chains/4/data-decoder',
117-
'POST',
118-
{ data: '0x123' },
119-
undefined,
120-
undefined,
121-
)
122-
})
123-
124-
it('should call a data decoder confirmation view POST endpoint', async () => {
125-
await expect(
126-
postEndpoint('https://test.test', '/v1/chains/{chainId}/safes/{safe_address}/views/transaction-confirmation', {
109+
postEndpoint('https://test.test', '/v1/chains/{chainId}/transactions/{safe_address}/preview', {
127110
path: { chainId: '4', safe_address: '0x123' },
128-
body: { data: '0x456' },
111+
body: { data: '0x456', operation: 0 },
129112
}),
130113
).resolves.toEqual({ success: true })
131114

132115
expect(fetchData).toHaveBeenCalledWith(
133-
'https://test.test/v1/chains/4/safes/0x123/views/transaction-confirmation',
116+
'https://test.test/v1/chains/4/transactions/0x123/preview',
134117
'POST',
135-
{ data: '0x456' },
118+
{ data: '0x456', operation: 0 },
136119
undefined,
137120
undefined,
138121
)

0 commit comments

Comments
 (0)