Skip to content

Commit b84a7bd

Browse files
fix(sdk-core): narrow generated allocation fields
Destructure generated allocation identifiers with defaults so the prepared allocation satisfies its required submission contract after type checking. WEB-000 PT-000000
1 parent 393a9cb commit b84a7bd

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

  • modules/sdk-core/src/bitgo/trading/network

modules/sdk-core/src/bitgo/trading/network/network.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,20 +120,16 @@ export class TradingNetwork implements ITradingNetwork {
120120
*/
121121
async prepareAllocation({
122122
walletPassphrase,
123+
clientExternalId = uuidV4(),
124+
nonce = crypto.randomBytes(32).toString('hex'),
123125
...body
124126
}: PrepareNetworkAllocationParams): Promise<CreateNetworkAllocationParams> {
125-
if (!body.clientExternalId) {
126-
body.clientExternalId = uuidV4();
127-
}
128-
if (!body.nonce) {
129-
body.nonce = crypto.randomBytes(32).toString('hex');
130-
}
131-
132-
const payload = JSON.stringify(body);
127+
const allocation = { ...body, clientExternalId, nonce };
128+
const payload = JSON.stringify(allocation);
133129
const signature = await this.wallet.toTradingAccount().signPayload({ payload, walletPassphrase });
134130

135131
return {
136-
...body,
132+
...allocation,
137133
payload,
138134
signature,
139135
};

0 commit comments

Comments
 (0)