Skip to content

Commit 34d7515

Browse files
authored
Fix: null -> undefined in Transaction types (#81)
* Fix: name and logoUri in AddressEx can be undefined, not null * Bump version * Bump major version * Fix tests
1 parent 21aa186 commit 34d7515

File tree

5 files changed

+41
-42
lines changed

5 files changed

+41
-42
lines changed

e2e/propose-transaction.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ describe('proposeTransaction tests', () => {
2121
refundReceiver: '0x0000000000000000000000000000000000000000',
2222
safeTxHash: '0x98798b6d9400b25397e85eb79c444a06f93d153555c1d7fd026176f02055a824',
2323
sender: '0x474e5Ded6b5D078163BFB8F6dBa355C3aA5478C8',
24-
origin: null,
2524
})
2625
await expect(req).rejects.toThrow(
2726
'1337: {"nonFieldErrors":["Contract-transaction-hash=0xdf2c4db07ee705e94135d92f835cc241b1d4c20e10d481a4e445265851448cb3 does not match provided contract-tx-hash=0x98798b6d9400b25397e85eb79c444a06f93d153555c1d7fd026176f02055a824"]}',

e2e/safe-collectibles-list.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ describe('getCollectibles tests', () => {
1212

1313
expect(data.length).toBeGreaterThanOrEqual(1)
1414
expect(typeof data[1].address).toBe('string')
15-
expect(typeof data[0].description).toBe('string')
16-
expect(typeof data[0].name).toBe('string')
15+
expect(data[0].description).toBeDefined()
16+
expect(data[0].name).toBeDefined()
1717
expect(data[0].metadata).toBeDefined()
1818
expect(data[0].tokenName.length).toBeGreaterThan(0)
1919
expect(data[0].tokenSymbol.length).toBeGreaterThan(0)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@gnosis.pm/safe-react-gateway-sdk",
3-
"version": "3.1.4",
3+
"version": "3.2.0",
44
"main": "dist/index.min.js",
55
"types": "dist/index.d.ts",
66
"files": [

src/types/common.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { IncomingTransfer, ModuleTransaction, MultisigTransaction, Page } from '
22

33
export type AddressEx = {
44
value: string
5-
name: string | null
6-
logoUri: string | null
5+
name?: string
6+
logoUri?: string
77
}
88

99
export type SafeInfo = {
@@ -13,7 +13,7 @@ export type SafeInfo = {
1313
threshold: number
1414
owners: AddressEx[]
1515
implementation: AddressEx
16-
modules: AddressEx[]
16+
modules: AddressEx[] | null
1717
guard: AddressEx | null
1818
fallbackHandler: AddressEx
1919
version: string

src/types/transactions.ts

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ export enum Operation {
1010
export type InternalTransaction = {
1111
operation: Operation
1212
to: string
13-
value: string | null
14-
data: string | null
15-
dataDecoded: DataDecoded | null
13+
value?: string
14+
data?: string
15+
dataDecoded?: DataDecoded
1616
}
1717

1818
export type ValueDecodedType = InternalTransaction[]
@@ -21,12 +21,12 @@ export type Parameter = {
2121
name: string
2222
type: string
2323
value: ParamValue
24-
valueDecoded: ValueDecodedType | null
24+
valueDecoded?: ValueDecodedType
2525
}
2626

2727
export type DataDecoded = {
2828
method: string
29-
parameters: Parameter[] | null
29+
parameters?: Parameter[]
3030
}
3131

3232
export enum TransactionStatus {
@@ -67,20 +67,20 @@ export enum SettingsInfoType {
6767
export type Erc20Transfer = {
6868
type: TransactionTokenType.ERC20
6969
tokenAddress: string
70-
tokenName: string | null
71-
tokenSymbol: string | null
72-
logoUri: string | null
73-
decimals: number | null
70+
tokenName?: string
71+
tokenSymbol?: string
72+
logoUri?: string
73+
decimals?: number
7474
value: string
7575
}
7676

7777
export type Erc721Transfer = {
7878
type: TransactionTokenType.ERC721
7979
tokenAddress: string
8080
tokenId: string
81-
tokenName: string | null
82-
tokenSymbol: string | null
83-
logoUri: string | null
81+
tokenName?: string
82+
tokenSymbol?: string
83+
logoUri?: string
8484
}
8585

8686
export type NativeCoinTransfer = {
@@ -165,16 +165,16 @@ export type SettingsInfo =
165165
export type SettingsChange = {
166166
type: 'SettingsChange'
167167
dataDecoded: DataDecoded
168-
settingsInfo: SettingsInfo | null
168+
settingsInfo?: SettingsInfo
169169
}
170170

171171
export interface Custom {
172172
type: 'Custom'
173173
to: AddressEx
174174
dataSize: string
175175
value: string
176-
methodName: string | null
177-
actionCount: number | null
176+
methodName?: string
177+
actionCount?: number
178178
isCancellation: boolean
179179
}
180180

@@ -196,8 +196,8 @@ export type Creation = {
196196
type: 'Creation'
197197
creator: AddressEx
198198
transactionHash: string
199-
implementation: AddressEx | null
200-
factory: AddressEx | null
199+
implementation?: AddressEx
200+
factory?: AddressEx
201201
}
202202

203203
export type TransactionInfo = Transfer | SettingsChange | Custom | MultiSend | Cancellation | Creation
@@ -212,7 +212,7 @@ export type MultisigExecutionInfo = {
212212
nonce: number
213213
confirmationsRequired: number
214214
confirmationsSubmitted: number
215-
missingSigners: AddressEx[] | null
215+
missingSigners?: AddressEx[]
216216
}
217217

218218
export type ExecutionInfo = ModuleExecutionInfo | MultisigExecutionInfo
@@ -290,18 +290,18 @@ export type TransactionListPage = Page<TransactionListItem>
290290
export type MultisigTransactionRequest = {
291291
to: string
292292
value: string
293-
data: string | null
293+
data?: string
294294
nonce: string
295295
operation: Operation
296296
safeTxGas: string
297297
baseGas: string
298298
gasPrice: string
299299
gasToken: string
300-
refundReceiver: string | null
300+
refundReceiver?: string
301301
safeTxHash: string
302302
sender: string
303-
signature?: string | null
304-
origin: string | null
303+
signature?: string
304+
origin?: string
305305
}
306306

307307
/* Transaction details types */
@@ -312,12 +312,12 @@ export type SafeAppInfo = {
312312
}
313313

314314
export type TransactionData = {
315-
hexData: string | null
316-
dataDecoded: DataDecoded | null
315+
hexData?: string
316+
dataDecoded?: DataDecoded
317317
to: AddressEx
318-
value: string | null
318+
value?: string
319319
operation: Operation
320-
addressInfoIndex: { [key: string]: AddressEx } | null
320+
addressInfoIndex?: { [key: string]: AddressEx }
321321
trustedDelegateCallTarget: boolean
322322
}
323323

@@ -328,7 +328,7 @@ export type ModuleExecutionDetails = {
328328

329329
export type MultisigConfirmation = {
330330
signer: AddressEx
331-
signature: string | null
331+
signature?: string
332332
submittedAt: number
333333
}
334334

@@ -342,25 +342,25 @@ export type MultisigExecutionDetails = {
342342
gasToken: string
343343
refundReceiver: AddressEx
344344
safeTxHash: string
345-
executor: AddressEx | null
345+
executor?: AddressEx
346346
signers: AddressEx[]
347347
confirmationsRequired: number
348348
confirmations: MultisigConfirmation[]
349-
rejectors: AddressEx[] | null
350-
gasTokenInfo: TokenInfo | null
349+
rejectors?: AddressEx[]
350+
gasTokenInfo?: TokenInfo
351351
}
352352

353353
export type DetailedExecutionInfo = ModuleExecutionDetails | MultisigExecutionDetails
354354

355355
export type TransactionDetails = {
356356
txId: string
357-
executedAt: number | null
357+
executedAt?: number
358358
txStatus: TransactionStatus
359359
txInfo: TransactionInfo
360-
txData: TransactionData | null
361-
detailedExecutionInfo: DetailedExecutionInfo | null
362-
txHash: string | null
363-
safeAppInfo: SafeAppInfo | null
360+
txData?: TransactionData
361+
detailedExecutionInfo?: DetailedExecutionInfo
362+
txHash?: string
363+
safeAppInfo?: SafeAppInfo
364364
}
365365

366366
/* Transaction details types end */

0 commit comments

Comments
 (0)