Skip to content

Commit 70d84b4

Browse files
matt-o-howChiaMineJPgithub-actions[bot]ChiaAutomation
authored
Add new WC hooks (#2837)
* Fixed npm audit issue * Fixed eslint issue * Fixed CI test failure * Removed patch-package * A minor fix * Updated node version to 24 * New Crowdin Translations (#2848) * New Crowdin translations by GitHub Action * Compiled Translations --------- Co-authored-by: Chia Automation <automation@chia.net> * add hook for get_coin_records_by_names() * use correct func name * pluralise names consistently * re-add accidental removal * expose query * add register_remote_coins() to WC * remove unused command * add command to create RemoteWallet * ask for permission for register_remote_coins * add hooks for fetching and registering remote coin records * nicer grouping and getHeightInfo in WC * package massaging * pin nx * commit package lock * npm audit fixing * npm massaging * npm please * Removed `nx` from the root package.json --------- Co-authored-by: Izumi Hoshino <admin@chiamine.jp> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Chia Automation <automation@chia.net>
1 parent 29f11ed commit 70d84b4

13 files changed

Lines changed: 3468 additions & 2178 deletions

File tree

package-lock.json

Lines changed: 3347 additions & 2167 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
"*": "prettier --check --ignore-unknown --ignore-path .gitignore"
4343
},
4444
"dependencies": {
45-
"lerna": "8.2.1",
46-
"nx": "19.0.1"
45+
"lerna": "9.0.5",
46+
"rollup": "4.59.0"
4747
},
4848
"devDependencies": {
4949
"@typescript-eslint/eslint-plugin": "8.20.0",
@@ -78,8 +78,8 @@
7878
"tmp": "0.2.5",
7979
"qs": "6.15.0",
8080
"schema-utils": "4.3.3",
81-
"tar": "7.5.9",
82-
"minimatch@3.0.5": "3.1.4",
81+
"tar": "7.5.10",
82+
"svgo": "3.3.3",
8383
"minimatch@9.0.3": "9.0.9",
8484
"rollup": "4.59.0",
8585
"serialize-javascript": "7.0.4"

packages/api-react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"jest": "29.6.3",
4747
"react": "18.2.0",
4848
"react-redux": "8.1.2",
49-
"rollup": "4.53.3",
49+
"rollup": "4.59.0",
5050
"rollup-plugin-node-externals": "7.1.2",
5151
"typescript": "5.7.3"
5252
},

packages/api-react/src/services/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ export const {
155155
useGetTransactionsCountQuery,
156156
useGetCurrentAddressQuery,
157157
useGetNextAddressMutation,
158+
useGetCoinRecordsByNamesQuery,
159+
useLazyGetCoinRecordsByNamesQuery,
160+
useRegisterRemoteCoinsMutation,
158161
useFarmBlockMutation,
159162
useGetTimestampForHeightQuery,
160163
useLazyGetTimestampForHeightQuery,
@@ -196,6 +199,7 @@ export const {
196199

197200
// DID
198201
useCreateNewDIDWalletMutation,
202+
useCreateNewRemoteWalletMutation,
199203
useUpdateDIDRecoveryIdsMutation,
200204
useGetDIDPubKeyQuery,
201205
useGetDIDQuery,

packages/api-react/src/services/wallet.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,10 @@ export const walletApi = apiWithTag.injectEndpoints({
544544
invalidatesTags: (result, _error, { walletId }) => (result ? [{ type: 'Address', id: walletId }] : []),
545545
}),
546546

547+
getCoinRecordsByNames: query(build, WalletService, 'getCoinRecordsByNames'),
548+
549+
registerRemoteCoins: mutation(build, WalletService, 'registerRemoteCoins'),
550+
547551
farmBlock: mutation(build, WalletService, 'farmBlock'),
548552

549553
getTimestampForHeight: query(build, WalletService, 'getTimestampForHeight'),
@@ -1064,6 +1068,18 @@ export const walletApi = apiWithTag.injectEndpoints({
10641068
],
10651069
}),
10661070

1071+
createNewRemoteWallet: build.mutation({
1072+
query: () => ({
1073+
service: WalletService,
1074+
command: 'createNewWallet',
1075+
args: {
1076+
walletType: 'remote_wallet',
1077+
options: {},
1078+
},
1079+
}),
1080+
invalidatesTags: [{ type: 'Wallets', id: 'LIST' }],
1081+
}),
1082+
10671083
getDIDName: query(build, DID, 'getDidName', {
10681084
providesTags: (result, _error, { walletId }) => (result ? [{ type: 'DIDName', id: walletId }] : []),
10691085
}),
@@ -1545,6 +1561,9 @@ export const {
15451561
useGetTransactionsCountQuery,
15461562
useGetCurrentAddressQuery,
15471563
useGetNextAddressMutation,
1564+
useGetCoinRecordsByNamesQuery,
1565+
useLazyGetCoinRecordsByNamesQuery,
1566+
useRegisterRemoteCoinsMutation,
15481567
useFarmBlockMutation,
15491568
useGetTimestampForHeightQuery,
15501569
useLazyGetTimestampForHeightQuery,
@@ -1586,6 +1605,7 @@ export const {
15861605

15871606
// DID
15881607
useCreateNewDIDWalletMutation,
1608+
useCreateNewRemoteWalletMutation,
15891609
useUpdateDIDRecoveryIdsMutation,
15901610
useGetDIDPubKeyQuery,
15911611
useGetDIDQuery,

packages/api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"@types/node": "20.5.2",
4646
"concurrently": "8.2.1",
4747
"jest": "29.6.3",
48-
"rollup": "4.53.3",
48+
"rollup": "4.59.0",
4949
"rollup-plugin-node-externals": "7.1.2",
5050
"typescript": "5.7.3"
5151
}

packages/api/src/services/WalletService.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,21 @@ export default class Wallet extends Service {
4747
}>('get_transaction_memo', args);
4848
}
4949

50+
async getCoinRecordsByNames(args: {
51+
names: string[];
52+
startHeight?: number;
53+
endHeight?: number;
54+
includeSpentCoins?: boolean;
55+
}) {
56+
return this.command<{
57+
coinRecords: any[];
58+
}>('get_coin_records_by_names', args);
59+
}
60+
61+
async registerRemoteCoins(args: { walletId: number; coinIds: string[] }) {
62+
return this.command<void>('register_remote_coins', args);
63+
}
64+
5065
async getPwStatus(args: { walletId: number }) {
5166
return this.command<{ state: PoolWalletStatus; unconfirmedTransactions: Transaction[] }>('pw_status', args);
5267
}
@@ -70,7 +85,7 @@ export default class Wallet extends Service {
7085
}
7186

7287
async createNewWallet(args: {
73-
walletType: 'pool_wallet' | 'rl_wallet' | 'did_wallet' | 'cat_wallet';
88+
walletType: 'pool_wallet' | 'rl_wallet' | 'did_wallet' | 'cat_wallet' | 'remote_wallet';
7489
options: Object;
7590
}) {
7691
return this.command<WalletCreate>('create_new_wallet', {

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
"react-hook-form": "7.45.4",
101101
"react-router": "6.30.3",
102102
"react-router-dom": "6.30.3",
103-
"rollup": "4.53.3",
103+
"rollup": "4.59.0",
104104
"rollup-plugin-node-externals": "7.1.2",
105105
"styled-components": "6.0.7",
106106
"typescript": "5.7.3"

packages/gui/src/@types/WalletConnectCommandParamName.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ enum WalletConnectCommandParamName {
2121
EDITION_NUMBER = 'editionNumber',
2222
EDITION_TOTAL = 'editionTotal',
2323
END = 'end',
24+
END_HEIGHT = 'endHeight',
2425
FEE = 'fee',
2526
FINGERPRINT = 'fingerprint',
2627
FINGERPRINTS = 'fingerprints',
@@ -32,6 +33,7 @@ enum WalletConnectCommandParamName {
3233
IDS = 'ids',
3334
INCLUDE_DATA = 'includeData',
3435
INCLUDE_MY_OFFERS = 'includeMyOffers',
36+
INCLUDE_SPENT_COINS = 'includeSpentCoins',
3537
INCLUDE_TAKEN_OFFERS = 'includeTakenOffers',
3638
INDEX = 'index',
3739
INNER_ADDRESS = 'innerAddress',
@@ -51,6 +53,7 @@ enum WalletConnectCommandParamName {
5153
MINT_NUMBER_START = 'mintNumberStart',
5254
MINT_TOTAL = 'mintTotal',
5355
NAME = 'name',
56+
NAMES = 'names',
5457
NEW_ADDRESS = 'newAddress',
5558
NEW_INNERPUZHASH = 'newInnerpuzhash',
5659
NEW_LIST = 'newList',
@@ -90,6 +93,7 @@ enum WalletConnectCommandParamName {
9093
SORT_KEY = 'sortKey',
9194
SPEND_BUNDLE = 'spendBundle',
9295
START = 'start',
96+
START_HEIGHT = 'startHeight',
9397
START_INDEX = 'startIndex',
9498
STORE_ID = 'storeId',
9599
SUBMIT_ON_CHAIN = 'submitOnChain',

packages/gui/src/constants/WalletConnectCommands.tsx

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,41 @@ const walletConnectCommands: WalletConnectCommand[] = [
118118
},
119119
],
120120
},
121-
121+
{
122+
command: 'getCoinRecordsByNames',
123+
label: <Trans>Get Coin Records by Name</Trans>,
124+
description: <Trans>Requests the status of a list of coin records from the Wallet's coin store.</Trans>,
125+
service: ServiceName.WALLET,
126+
bypassConfirm: true,
127+
params: [
128+
{
129+
name: WalletConnectCommandParamName.NAMES,
130+
type: 'object', // bytes32[]
131+
label: <Trans>Names (coin ids)</Trans>,
132+
},
133+
{
134+
name: WalletConnectCommandParamName.START_HEIGHT,
135+
type: 'number',
136+
label: <Trans>Start Height</Trans>,
137+
isOptional: true,
138+
defaultValue: undefined,
139+
},
140+
{
141+
name: WalletConnectCommandParamName.END_HEIGHT,
142+
type: 'number',
143+
label: <Trans>End Height</Trans>,
144+
isOptional: true,
145+
defaultValue: undefined,
146+
},
147+
{
148+
name: WalletConnectCommandParamName.INCLUDE_SPENT_COINS,
149+
type: 'boolean',
150+
label: <Trans>Include Spent Coins</Trans>,
151+
isOptional: true,
152+
defaultValue: true,
153+
},
154+
],
155+
},
122156
{
123157
command: 'sendTransaction',
124158
label: <Trans>Send Transaction</Trans>,
@@ -318,6 +352,13 @@ const walletConnectCommands: WalletConnectCommand[] = [
318352
service: ServiceName.WALLET,
319353
bypassConfirm: true,
320354
},
355+
{
356+
command: 'getHeightInfo',
357+
label: <Trans>Get Height Info</Trans>,
358+
description: <Trans>Requests the current wallet sync height information</Trans>,
359+
service: ServiceName.WALLET,
360+
bypassConfirm: true,
361+
},
321362
{
322363
command: 'pushTx',
323364
label: <Trans>Push Transaction</Trans>,
@@ -1453,6 +1494,31 @@ const walletConnectCommands: WalletConnectCommand[] = [
14531494
],
14541495
},
14551496

1497+
// Remote Wallets
1498+
{
1499+
command: 'createNewRemoteWallet',
1500+
label: <Trans>Create new Remote Wallet</Trans>,
1501+
service: ServiceName.WALLET,
1502+
},
1503+
{
1504+
command: 'registerRemoteCoins',
1505+
label: <Trans>Register Remote Coins</Trans>,
1506+
description: <Trans>Registers a list of remote coin IDs with a remote wallet.</Trans>,
1507+
service: ServiceName.WALLET,
1508+
params: [
1509+
{
1510+
name: WalletConnectCommandParamName.WALLET_ID,
1511+
type: 'number',
1512+
label: <Trans>Wallet Id</Trans>,
1513+
},
1514+
{
1515+
name: WalletConnectCommandParamName.COIN_IDS,
1516+
type: 'object', // bytes32[]
1517+
label: <Trans>Coin Ids</Trans>,
1518+
},
1519+
],
1520+
},
1521+
14561522
// DIDs
14571523
{
14581524
command: 'createNewDIDWallet',

0 commit comments

Comments
 (0)