Skip to content

Commit 0103bc4

Browse files
committed
feat: use RTK code-generation for endpoints (#22)
* feature: RTK auto-generated endpoints * chore: run prettier on the codebase * chore: run prettier on the codebase * refactor: tx pending & history tx types * fix: remove usage of safe-gateway-typscript-sdk * fix: clean up console.log * refactor: pending & history tx cleanup
1 parent 33f001d commit 0103bc4

File tree

83 files changed

+10107
-5596
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+10107
-5596
lines changed

.detoxrc.js

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,82 +2,82 @@
22
module.exports = {
33
testRunner: {
44
args: {
5-
'$0': 'jest',
6-
config: 'e2e/jest.config.js'
5+
$0: 'jest',
6+
config: 'e2e/jest.config.js',
77
},
88
jest: {
9-
setupTimeout: 120000
10-
}
9+
setupTimeout: 120000,
10+
},
1111
},
1212
apps: {
1313
'ios.debug': {
1414
type: 'ios.app',
1515
binaryPath: 'ios/build/Build/Products/Debug-iphonesimulator/safemobileapp.app',
16-
build: 'xcodebuild -workspace ios/safemobileapp.xcworkspace -scheme safemobileapp -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build'
16+
build:
17+
'xcodebuild -workspace ios/safemobileapp.xcworkspace -scheme safemobileapp -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build',
1718
},
1819
'ios.release': {
1920
type: 'ios.app',
2021
binaryPath: 'ios/build/Build/Products/Release-iphonesimulator/safemobileapp.app',
21-
build: 'xcodebuild -workspace ios/safemobileapp.xcworkspace -scheme safemobileapp -configuration Release -sdk iphonesimulator -derivedDataPath ios/build'
22+
build:
23+
'xcodebuild -workspace ios/safemobileapp.xcworkspace -scheme safemobileapp -configuration Release -sdk iphonesimulator -derivedDataPath ios/build',
2224
},
2325
'android.debug': {
2426
type: 'android.apk',
2527
binaryPath: 'android/app/build/outputs/apk/debug/app-debug.apk',
2628
build: 'cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug',
27-
reversePorts: [
28-
8081
29-
]
29+
reversePorts: [8081],
3030
},
3131
'android.release': {
3232
type: 'android.apk',
3333
binaryPath: 'android/app/build/outputs/apk/release/app-release.apk',
34-
build: 'cd android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release'
35-
}
34+
build: 'cd android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release',
35+
},
3636
},
3737
devices: {
3838
simulator: {
3939
type: 'ios.simulator',
4040
device: {
41-
type: 'iPhone 15 Pro Max'
42-
}
41+
type: 'iPhone 15 Pro Max',
42+
},
4343
},
4444
attached: {
4545
type: 'android.attached',
4646
device: {
47-
adbName: '.*'
48-
}
47+
adbName: '.*',
48+
},
4949
},
5050
emulator: {
5151
type: 'android.emulator',
5252
device: {
53-
avdName: 'Pixel_8_API_35'
54-
}
55-
}
53+
avdName: 'Pixel_8_API_35',
54+
},
55+
},
5656
},
5757
configurations: {
5858
'ios.sim.debug': {
5959
device: 'simulator',
60-
app: 'ios.debug'
60+
app: 'ios.debug',
6161
},
6262
'ios.sim.release': {
6363
device: 'simulator',
64-
app: 'ios.release'
64+
app: 'ios.release',
6565
},
6666
'android.att.debug': {
6767
device: 'attached',
68-
app: 'android.debug'
68+
app: 'android.debug',
6969
},
7070
'android.att.release': {
7171
device: 'attached',
72-
app: 'android.release'
72+
app: 'android.release',
7373
},
7474
'android.emu.debug': {
7575
device: 'emulator',
76-
app: 'android.debug'
76+
app: 'android.debug',
7777
},
7878
'android.emu.release': {
7979
device: 'emulator',
80-
app: 'android.release'
81-
}
82-
}
83-
};
80+
app: 'android.release',
81+
},
82+
},
83+
}

.lintstagedrc.json

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
{
2-
"*.ts": [
3-
"prettier --write",
4-
"eslint"
5-
],
6-
"*.tsx": [
7-
"prettier --write",
8-
"eslint"
9-
],
10-
"assets/fonts/safe-icons/selection.json": [
11-
"node ./scripts/generateIconTypes.js",
12-
"git add ./src/types/iconTypes.ts"
13-
]
2+
"*.ts": ["prettier --write", "eslint"],
3+
"*.tsx": ["prettier --write", "eslint"],
4+
"assets/fonts/safe-icons/selection.json": ["node ./scripts/generateIconTypes.js", "git add ./src/types/iconTypes.ts"]
145
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ npm run test:watch
117117
```bash
118118
npm run test
119119
```
120+
120121
navigate inside the coverage folder and open the index.html file in your browser
121122

122123
## Running Eslint & Prettier

__mocks__/fileMock.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = 'test-file-stub';
1+
module.exports = 'test-file-stub'

app/_layout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import { Provider } from 'react-redux'
55
import { persistor, store } from '@/src/store'
66
import { PersistGate } from 'redux-persist/integration/react'
77
import { isStorybookEnv } from '@/src/config/constants'
8-
import { apiSliceWithChainsConfig } from '@/src/store/gateway/chains'
8+
import { apiSliceWithChainsConfig } from '@/src/store/gateway/chains/index'
99
import { GestureHandlerRootView } from 'react-native-gesture-handler'
1010

1111
function RootLayout() {
12-
store.dispatch(apiSliceWithChainsConfig.endpoints.getChainsConfig.initiate({}))
12+
store.dispatch(apiSliceWithChainsConfig.endpoints.getChainsConfig.initiate())
1313
return (
1414
<GestureHandlerRootView>
1515
<Provider store={store}>

e2e/jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ module.exports = {
99
reporters: ['detox/runners/jest/reporter'],
1010
testEnvironment: 'detox/runners/jest/testEnvironment',
1111
verbose: true,
12-
};
12+
}

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export default [
2525
'@typescript-eslint/ban-ts-comment': 'off',
2626
'@typescript-eslint/no-empty-object-type': 'off',
2727
'@typescript-eslint/no-invalid-void-type': 'off',
28+
'@typescript-eslint/consistent-type-definitions': 'off',
2829
},
2930
},
3031
]

metro.config.js

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,27 @@
1-
const path = require('path');
1+
const path = require('path')
22

33
// Learn more https://docs.expo.io/guides/customizing-metro
4-
const { getDefaultConfig } = require('expo/metro-config');
5-
const withStorybook = require('@storybook/react-native/metro/withStorybook');
4+
const { getDefaultConfig } = require('expo/metro-config')
5+
const withStorybook = require('@storybook/react-native/metro/withStorybook')
66

77
/** @type {import('expo/metro-config').MetroConfig} */
8-
const config = getDefaultConfig(__dirname);
8+
const config = getDefaultConfig(__dirname)
99

1010
config.resolver.resolveRequest = (context, moduleName, platform) => {
11-
const defaultResolveResult = context.resolveRequest(context, moduleName, platform);
11+
const defaultResolveResult = context.resolveRequest(context, moduleName, platform)
1212

13-
if (
14-
process.env.STORYBOOK_ENABLED !== 'true' &&
15-
defaultResolveResult?.filePath?.includes?.('.storybook/')
16-
) {
17-
return {
18-
type: 'empty',
19-
};
13+
if (process.env.STORYBOOK_ENABLED !== 'true' && defaultResolveResult?.filePath?.includes?.('.storybook/')) {
14+
return {
15+
type: 'empty',
2016
}
17+
}
2118

22-
return defaultResolveResult;
23-
};
19+
return defaultResolveResult
20+
}
2421

2522
module.exports = withStorybook(config, {
26-
// Set to false to remove storybook specific options
27-
enabled: true,
28-
// Path to your storybook config
29-
configPath: path.resolve(__dirname, './.storybook'),
30-
});
23+
// Set to false to remove storybook specific options
24+
enabled: true,
25+
// Path to your storybook config
26+
configPath: path.resolve(__dirname, './.storybook'),
27+
})

openapi-config.ts

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
import type { ConfigFile } from '@rtk-query/codegen-openapi'
2+
3+
const config: ConfigFile = {
4+
schemaFile: './src/store/gateway/api-schema/schema.json',
5+
prettierConfigFile: './.prettierrc',
6+
apiFile: './src/store/gateway/cgwClient.ts',
7+
apiImport: 'cgwClient',
8+
exportName: 'cgwApi',
9+
hooks: true,
10+
filterEndpoints: [/^(?!.*delegates).*/],
11+
tag: true,
12+
outputFiles: {
13+
'./src/store/gateway/AUTO_GENERATED/about.ts': {
14+
filterEndpoints: [/getAbout/],
15+
},
16+
'./src/store/gateway/AUTO_GENERATED/accounts.ts': {
17+
filterEndpoints: [
18+
/v1CreateAccount/,
19+
/v1GetDataTypes/,
20+
/v1GetAccountDataSettings/,
21+
/v1UpsertAccountDataSettings/,
22+
/v1GetAccount/,
23+
/v1DeleteAccount/,
24+
/v1GetCounterfactualSafe/,
25+
/v1DeleteCounterfactualSafe/,
26+
/v1GetCounterfactualSafes/,
27+
/v1CreateCounterfactualSafe/,
28+
/v1DeleteCounterfactualSafes/,
29+
],
30+
},
31+
'./src/store/gateway/AUTO_GENERATED/auth.ts': {
32+
filterEndpoints: [/v1GetNonce/, /v1Verify/],
33+
},
34+
'./src/store/gateway/AUTO_GENERATED/balances.ts': {
35+
filterEndpoints: [/v1GetBalances/, /v1GetSupportedFiatCodes/],
36+
},
37+
'./src/store/gateway/AUTO_GENERATED/chains.ts': {
38+
filterEndpoints: [
39+
/v1GetChains/,
40+
/v1GetChain/,
41+
/v1GetAboutChain/,
42+
/v1GetBackbone/,
43+
/v1GetMasterCopies/,
44+
/v1GetIndexingStatus/,
45+
],
46+
},
47+
'./src/store/gateway/AUTO_GENERATED/collectibles.ts': {
48+
filterEndpoints: [/v2GetCollectibles/],
49+
},
50+
'./src/store/gateway/AUTO_GENERATED/community.ts': {
51+
filterEndpoints: [
52+
/v1GetCampaigns/,
53+
/v1GetCampaignById/,
54+
/v1GetCampaignActivities/,
55+
/v1GetCampaignLeaderboard/,
56+
/v1GetCampaignRank/,
57+
/v1GheckEligibility/,
58+
/v1GetLeaderboard/,
59+
/v1GetLockingRank/,
60+
/v1GetLockingHistory/,
61+
],
62+
},
63+
'./src/store/gateway/AUTO_GENERATED/contracts.ts': {
64+
filterEndpoints: [/v1GetContract/],
65+
},
66+
'./src/store/gateway/AUTO_GENERATED/data-decoded.ts': {
67+
filterEndpoints: [/v1GetDataDecoded/],
68+
},
69+
'./src/store/gateway/AUTO_GENERATED/delegates.ts': {
70+
filterEndpoints: [/v2GetDelegates/, /v2PostDelegate/, /v2DeleteDelegate/],
71+
},
72+
'./src/store/gateway/AUTO_GENERATED/estimations.ts': {
73+
filterEndpoints: [/v2GetEstimation/],
74+
},
75+
'./src/store/gateway/AUTO_GENERATED/messages.ts': {
76+
filterEndpoints: [/v1GetMessageByHash/, /v1GetMessagesBySafe/, /v1CreateMessage/, /v1UpdateMessageSignature/],
77+
},
78+
'./src/store/gateway/AUTO_GENERATED/notifications.ts': {
79+
filterEndpoints: [/v1RegisterDevice/, /v1UnregisterDevice/, /v1UnregisterSafe/],
80+
},
81+
'./src/store/gateway/AUTO_GENERATED/owners.ts': {
82+
filterEndpoints: [/v1GetSafesByOwner/, /v1GetAllSafesByOwner/],
83+
},
84+
'./src/store/gateway/AUTO_GENERATED/relay.ts': {
85+
filterEndpoints: [/v1Relay/, /v1GetRelaysRemaining/],
86+
},
87+
'./src/store/gateway/AUTO_GENERATED/safe-apps.ts': {
88+
filterEndpoints: [/v1GetSafeApps/],
89+
},
90+
'./src/store/gateway/AUTO_GENERATED/safes.ts': {
91+
filterEndpoints: [/v1GetSafe/, /v1GetNonces/, /v1GetSafeOverview/],
92+
},
93+
'./src/store/gateway/AUTO_GENERATED/targeted-messages.ts': {
94+
filterEndpoints: [/v1GetSubmission/, /v1CreateSubmission/],
95+
},
96+
'./src/store/gateway/AUTO_GENERATED/transactions.ts': {
97+
filterEndpoints: [
98+
/v1GetTransactionById/,
99+
/v1GetMultisigTransactions/,
100+
/v1DeleteTransaction/,
101+
/v1GetModuleTransactions/,
102+
/v1AddConfirmation/,
103+
/v1GetIncomingTransfers/,
104+
/v1PreviewTransaction/,
105+
/v1GetTransactionQueue/,
106+
/v1GetTransactionsHistory/,
107+
/v1ProposeTransaction/,
108+
/v1GetCreationTransaction/,
109+
],
110+
},
111+
},
112+
}
113+
114+
export default config

0 commit comments

Comments
 (0)