diff --git a/modules/sdk-core/src/bitgo/trading/tradingAccount.ts b/modules/sdk-core/src/bitgo/trading/tradingAccount.ts index 9133793770..410167cb0b 100644 --- a/modules/sdk-core/src/bitgo/trading/tradingAccount.ts +++ b/modules/sdk-core/src/bitgo/trading/tradingAccount.ts @@ -61,7 +61,7 @@ export class TradingAccount implements ITradingAccount { } // we do not parse the payload here, we instead sends the payload as a stringified JSON to be signed, just like how we process it locally - const url = this.wallet.url('/tx/sign'); + const url = this.bitgo.coin('ofc').url('/wallet/' + this.wallet.id() + '/tx/sign'); const payload = typeof params.payload !== 'string' ? JSON.stringify(params.payload) : params.payload; const { signature } = await this.wallet.bitgo.post(url).send({ payload }).result(); diff --git a/modules/sdk-core/test/unit/bitgo/trading/tradingAccount.ts b/modules/sdk-core/test/unit/bitgo/trading/tradingAccount.ts index 2b9a0869e4..0b1d297e7e 100644 --- a/modules/sdk-core/test/unit/bitgo/trading/tradingAccount.ts +++ b/modules/sdk-core/test/unit/bitgo/trading/tradingAccount.ts @@ -26,6 +26,9 @@ describe('TradingAccount', function () { mockBitGo = { post: sinon.stub().returns({ send: sendStub }), + coin: sinon.stub().callsFake((coin: string) => ({ + url: sinon.stub().callsFake((url: string) => `https://app.bitgo-staging.com/api/v2/${coin}${url}`), + })), decrypt: sinon .stub() .callsFake(({ input, password }) => @@ -48,7 +51,6 @@ describe('TradingAccount', function () { mockWallet = { id: sinon.stub().returns('test-wallet-id'), keyIds: sinon.stub().returns(['user-key-id', 'bitgo-key-id']), - url: sinon.stub().returns('https://example.com/wallet/test-wallet-id/tx/sign'), toJSON: sinon.stub().returns({ id: 'test-wallet-id', keys: ['user-key-id', 'backup-key-id', 'bitgo-key-id'], @@ -73,12 +75,17 @@ describe('TradingAccount', function () { }); describe('signPayload', function () { + it('should call the right url', async function () { + const expectedUrl = `https://app.bitgo-staging.com/api/v2/ofc/wallet/test-wallet-id/tx/sign`; + await tradingAccount.signPayload({ payload }); + mockBitGo.post.calledWith(expectedUrl).should.be.true(); + }); + describe('without walletPassphrase or prv (BitGo remote signing)', function () { it('should sign using the BitGo key remotely when no passphrase is provided', async function () { const result = await tradingAccount.signPayload({ payload }); mockWallet.toJSON.calledOnce.should.be.true(); - mockWallet.url.calledWith('/tx/sign').should.be.true(); mockBitGo.post.calledOnce.should.be.true(); sendStub.calledWith({ payload: JSON.stringify(payload) }).should.be.true(); result.should.equal(signature);