Skip to content

Commit 84eec72

Browse files
authored
Allow extra_conditions in make_offer (#2896)
* add extra_conditions to createOfferForIds * extra_conditions added to take_offer * add new optional param to createOfferForIds to specify coin * explicitly map to snake_case when appropriate
1 parent d4541d5 commit 84eec72

4 files changed

Lines changed: 28 additions & 4 deletions

File tree

packages/api/src/services/WalletService.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ describe('WalletService', () => {
686686
const expected = [
687687
new Message({
688688
command: 'create_offer_for_ids',
689-
data: { driver_dict: driverDict, ...restArgs },
689+
data: { driver_dict: driverDict, extra_conditions: undefined, coin_ids: undefined, ...restArgs },
690690
destination: 'chia_wallet',
691691
origin: 'test_origin' as ServiceNameValue,
692692
}),

packages/api/src/services/WalletService.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,13 @@ export default class Wallet extends Service {
265265
validateOnly?: boolean;
266266
disableJSONFormatting?: boolean;
267267
maxTime?: number;
268+
extraConditions?: any[];
269+
coinIds?: string[];
268270
}) {
269-
const { disableJSONFormatting, driverDict, ...restArgs } = args;
271+
const { disableJSONFormatting, driverDict, extraConditions, coinIds, ...restArgs } = args;
270272
return this.command<{ offer: string; tradeRecord: TradeRecord }>(
271273
'create_offer_for_ids',
272-
{ driver_dict: driverDict, ...restArgs },
274+
{ driver_dict: driverDict, extra_conditions: extraConditions, coin_ids: coinIds, ...restArgs },
273275
false,
274276
undefined,
275277
disableJSONFormatting,
@@ -284,7 +286,7 @@ export default class Wallet extends Service {
284286
return this.command<{ id: string; valid: boolean }>('check_offer_validity', args);
285287
}
286288

287-
async takeOffer(args: { offer: string; fee: number | string }) {
289+
async takeOffer(args: { offer: string; fee: number | string; extraConditions?: any[] }) {
288290
return this.command<{ tradeRecord: TradeRecord }>('take_offer', args);
289291
}
290292

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ enum WalletConnectCommandParamName {
2222
EDITION_TOTAL = 'editionTotal',
2323
END = 'end',
2424
END_HEIGHT = 'endHeight',
25+
EXTRA_CONDITIONS = 'extraConditions',
2526
FEE = 'fee',
2627
FINGERPRINT = 'fingerprint',
2728
FINGERPRINTS = 'fingerprints',

packages/gui/src/constants/WalletConnectCommands.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,20 @@ const walletConnectCommands: WalletConnectCommand[] = [
464464
type: 'BigNumber',
465465
displayComponent: (value) => <MojoToChia value={value} />,
466466
},
467+
{
468+
name: WalletConnectCommandParamName.EXTRA_CONDITIONS,
469+
label: <Trans>Extra Conditions</Trans>,
470+
isOptional: true,
471+
type: 'object',
472+
displayComponent: (value) => <>{JSON.stringify(value)}</>,
473+
},
474+
{
475+
name: WalletConnectCommandParamName.COIN_IDS,
476+
label: <Trans>Coin IDs</Trans>,
477+
isOptional: true,
478+
type: 'object',
479+
displayComponent: (value) => <>{JSON.stringify(value)}</>,
480+
},
467481
],
468482
},
469483
{
@@ -522,6 +536,13 @@ const walletConnectCommands: WalletConnectCommand[] = [
522536
type: 'BigNumber',
523537
displayComponent: (value) => <MojoToChia value={value} />,
524538
},
539+
{
540+
name: WalletConnectCommandParamName.EXTRA_CONDITIONS,
541+
label: <Trans>Extra Conditions</Trans>,
542+
isOptional: true,
543+
type: 'object',
544+
displayComponent: (value) => <>{JSON.stringify(value)}</>,
545+
},
525546
],
526547
},
527548
{

0 commit comments

Comments
 (0)