diff --git a/sdks/typescript/pmxt/client.ts b/sdks/typescript/pmxt/client.ts index 9e075bf5..75179bb3 100644 --- a/sdks/typescript/pmxt/client.ts +++ b/sdks/typescript/pmxt/client.ts @@ -2587,7 +2587,7 @@ export abstract class Exchange { if (extra["slippage_pct"] !== undefined) { body["slippage_pct"] = extra["slippage_pct"]; } - if (this.walletAddress) body["user_address"] = this.walletAddress; + body["user_address"] = resolveWalletAddress(this); return body; } diff --git a/sdks/typescript/tests/hosted-dispatch.test.ts b/sdks/typescript/tests/hosted-dispatch.test.ts index 88223938..d860b129 100644 --- a/sdks/typescript/tests/hosted-dispatch.test.ts +++ b/sdks/typescript/tests/hosted-dispatch.test.ts @@ -219,6 +219,20 @@ function buildResponsePayload(side: "buy" | "sell" = "buy"): Record { + it("buildOrder raises MissingWalletAddress locally when walletAddress is unset", async () => { + const spy = installFetchSpy(() => jsonResponse(buildResponsePayload("buy"))); + const api = makePolymarket({ withWallet: false, withSigner: true }); + await expect(api.buildOrder({ + marketId: "11111111-1111-4111-8111-111111111111", + outcomeId: "22222222-2222-4222-8222-222222222222", + side: "buy", + type: "market", + amount: 5, + denom: "usdc", + } as any)).rejects.toBeInstanceOf(MissingWalletAddress); + expect(captured(spy)).toHaveLength(0); + }); + it("buildOrder → POST /v0/trade/build-order", async () => { const spy = installFetchSpy(() => jsonResponse(buildResponsePayload("buy"))); const api = makePolymarket({ withSigner: true });