Skip to content

Commit

Permalink
chore(wp): switch to new API url for create wallet
Browse files Browse the repository at this point in the history
The prev create wallet API is being deprecated in
favour of /api/v2/:coin/wallet/add

TICKET: WP-3152
  • Loading branch information
pranavjain97 committed Nov 26, 2024
1 parent a891814 commit a021bd4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
42 changes: 21 additions & 21 deletions modules/bitgo/test/v2/unit/wallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('V2 Wallets:', function () {

it('creates a paired custodial wallet', async function () {
nock(bgUrl)
.post('/api/v2/tbtc/wallet', function (body) {
.post('/api/v2/tbtc/wallet/add', function (body) {
body.isCustodial.should.be.true();
body.should.have.property('keys');
body.m.should.equal(2);
Expand All @@ -97,7 +97,7 @@ describe('V2 Wallets:', function () {
const eosWallets = eosBitGo.coin('teos').wallets();
const address = 'testeosaddre';
nock(bgUrl)
.post('/api/v2/teos/wallet', function (body) {
.post('/api/v2/teos/wallet/add', function (body) {
body.should.have.property('keys');
body.m.should.equal(2);
body.n.should.equal(3);
Expand All @@ -110,7 +110,7 @@ describe('V2 Wallets:', function () {

it('creates a single custodial wallet', async function () {
nock(bgUrl)
.post('/api/v2/tbtc/wallet', function (body) {
.post('/api/v2/tbtc/wallet/add', function (body) {
body.type.should.equal('custodial');
body.should.not.have.property('keys');
body.should.not.have.property('m');
Expand All @@ -126,7 +126,7 @@ describe('V2 Wallets:', function () {
ethBitGo.initializeTestVars();
const ethWallets = ethBitGo.coin('teth').wallets();
nock(bgUrl)
.post('/api/v2/teth/wallet', function (body) {
.post('/api/v2/teth/wallet/add', function (body) {
body.type.should.equal('custodial');
body.gasPrice.should.equal(20000000000);
body.should.not.have.property('keys');
Expand All @@ -148,7 +148,7 @@ describe('V2 Wallets:', function () {
ethBitGo.initializeTestVars();
const ethWallets = ethBitGo.coin('teth').wallets();
nock(bgUrl)
.post('/api/v2/teth/wallet', function (body) {
.post('/api/v2/teth/wallet/add', function (body) {
body.type.should.equal('custodial');
body.walletVersion.should.equal(1);
body.should.not.have.property('keys');
Expand All @@ -162,7 +162,7 @@ describe('V2 Wallets:', function () {

it('creates a new hot wallet with userKey', async function () {
nock(bgUrl)
.post('/api/v2/tbtc/wallet', function (body) {
.post('/api/v2/tbtc/wallet/add', function (body) {
body.type.should.equal('hot');
body.should.have.property('keys');
body.should.have.property('m');
Expand Down Expand Up @@ -330,7 +330,7 @@ describe('V2 Wallets:', function () {
.reply(200);

// wallet
nock(bgUrl).post('/api/v2/tbtc/wallet').reply(200);
nock(bgUrl).post('/api/v2/tbtc/wallet/add').reply(200);

await wallets.generateWallet(params);
});
Expand Down Expand Up @@ -367,7 +367,7 @@ describe('V2 Wallets:', function () {
.reply(200);

// wallet
nock(bgUrl).post('/api/v2/tbtc/wallet').reply(200);
nock(bgUrl).post('/api/v2/tbtc/wallet/add').reply(200);

await wallets.generateWallet(params);
});
Expand Down Expand Up @@ -402,7 +402,7 @@ describe('V2 Wallets:', function () {
.reply(200);

// wallet
const walletNock = nock(bgUrl).post('/api/v2/tbtc/wallet').reply(200);
const walletNock = nock(bgUrl).post('/api/v2/tbtc/wallet/add').reply(200);

await wallets.generateWallet(params);
for (const scope of [bitgoKeyNock, userKeyNock, backupKeyNock, walletNock]) {
Expand All @@ -418,7 +418,7 @@ describe('V2 Wallets:', function () {
};

const walletNock = nock(bgUrl)
.post('/api/v2/tbtc/wallet', function (body) {
.post('/api/v2/tbtc/wallet/add', function (body) {
body.type.should.equal('custodial');
should.not.exist(body.m);
should.not.exist(body.n);
Expand Down Expand Up @@ -449,7 +449,7 @@ describe('V2 Wallets:', function () {
};

const walletNock = nock(bgUrl)
.post('/api/v2/tbtc/wallet', function (body) {
.post('/api/v2/tbtc/wallet/add', function (body) {
body.type.should.equal('hot');
return true;
})
Expand Down Expand Up @@ -527,7 +527,7 @@ describe('V2 Wallets:', function () {
};
sandbox.stub(TssUtils.prototype, 'createKeychains').resolves(stubbedKeychainsTriplet);

const walletNock = nock('https://bitgo.fakeurl').post('/api/v2/tsol/wallet').reply(200);
const walletNock = nock('https://bitgo.fakeurl').post('/api/v2/tsol/wallet/add').reply(200);

const wallets = new Wallets(bitgo, tsol);

Expand Down Expand Up @@ -574,7 +574,7 @@ describe('V2 Wallets:', function () {
};
sandbox.stub(TssUtils.prototype, 'createKeychains').resolves(stubbedKeychainsTriplet);

const walletNock = nock('https://bitgo.fakeurl').post('/api/v2/tsol/wallet').reply(200);
const walletNock = nock('https://bitgo.fakeurl').post('/api/v2/tsol/wallet/add').reply(200);

const wallets = new Wallets(bitgo, tsol);

Expand Down Expand Up @@ -612,7 +612,7 @@ describe('V2 Wallets:', function () {
};
sandbox.stub(ECDSAUtils.EcdsaUtils.prototype, 'createKeychains').resolves(stubbedKeychainsTriplet);

const walletNock = nock('https://bitgo.fakeurl').post('/api/v2/tpolygon/wallet').reply(200);
const walletNock = nock('https://bitgo.fakeurl').post('/api/v2/tpolygon/wallet/add').reply(200);

const wallets = new Wallets(bitgo, tpolygon);

Expand Down Expand Up @@ -651,7 +651,7 @@ describe('V2 Wallets:', function () {
.post('/api/v2/tbtc/key', _.matches({ source: 'backup' }))
.reply(200);

nock(bgUrl).post('/api/v2/tbtc/wallet').reply(200);
nock(bgUrl).post('/api/v2/tbtc/wallet/add').reply(200);

// create a non tss wallet for coin that doesn't support tss even though multisigType is set to tss
await wallets.generateWallet({ ...params, multisigType: 'tss' });
Expand Down Expand Up @@ -688,7 +688,7 @@ describe('V2 Wallets:', function () {
};

const walletNock = nock('https://bitgo.fakeurl')
.post('/api/v2/tsol/wallet')
.post('/api/v2/tsol/wallet/add')
.times(1)
.reply(200, { ...walletParams, keys });

Expand Down Expand Up @@ -777,7 +777,7 @@ describe('V2 Wallets:', function () {
};

const walletNock = nock('https://bitgo.fakeurl')
.post('/api/v2/tsol/wallet', walletNockExpected)
.post('/api/v2/tsol/wallet/add', walletNockExpected)
.reply(200, { ...walletNockExpected, responseType: 'WalletWithKeychains' });

const wallets = new Wallets(bitgo, tsol);
Expand Down Expand Up @@ -917,7 +917,7 @@ describe('V2 Wallets:', function () {
.stub(ECDSAUtils.EcdsaMPCv2Utils.prototype, 'createKeychains')
.resolves(stubbedKeychainsTriplet);

const walletNock = nock('https://bitgo.fakeurl').post(`/api/v2/${coin}/wallet`).reply(200);
const walletNock = nock('https://bitgo.fakeurl').post(`/api/v2/${coin}/wallet/add`).reply(200);

const wallets = new Wallets(bitgo, testCoin);

Expand Down Expand Up @@ -971,7 +971,7 @@ describe('V2 Wallets:', function () {
.resolves(stubbedKeychainsTriplet);

const walletNock = nock('https://bitgo.fakeurl')
.post(`/api/v2/hteth/wallet`, (body) => {
.post(`/api/v2/hteth/wallet/add`, (body) => {
body.walletVersion.should.equal(6);
return true;
})
Expand Down Expand Up @@ -1028,7 +1028,7 @@ describe('V2 Wallets:', function () {
.resolves(stubbedKeychainsTriplet);

const walletNock = nock('https://bitgo.fakeurl')
.post(`/api/v2/hteth/wallet`, (body) => {
.post(`/api/v2/hteth/wallet/add`, (body) => {
body.walletVersion.should.equal(5);
return true;
})
Expand Down Expand Up @@ -1124,7 +1124,7 @@ describe('V2 Wallets:', function () {
};
sandbox.stub(BlsUtils.prototype, 'createKeychains').resolves(stubbedKeychainsTriplet);

const walletNock = nock('https://bitgo.fakeurl').post('/api/v2/eth2/wallet').reply(200);
const walletNock = nock('https://bitgo.fakeurl').post('/api/v2/eth2/wallet/add').reply(200);

const wallets = new Wallets(bitgo, eth2);

Expand Down
14 changes: 7 additions & 7 deletions modules/sdk-core/src/bitgo/wallet/wallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export class Wallets implements IWallets {
throw new Error('invalid argument for address - valid address string expected');
}

const newWallet = await this.bitgo.post(this.baseCoin.url('/wallet')).send(params).result();
const newWallet = await this.bitgo.post(this.baseCoin.url('/wallet/add')).send(params).result();
return {
wallet: new Wallet(this.bitgo, this.baseCoin, newWallet),
};
Expand Down Expand Up @@ -197,7 +197,7 @@ export class Wallets implements IWallets {
coinSpecific: { [this.baseCoin.getChain()]: { keys: [userAuthKeychain.id, nodeAuthKeychain.id] } },
};

const newWallet = await this.bitgo.post(this.baseCoin.url('/wallet')).send(walletParams).result();
const newWallet = await this.bitgo.post(this.baseCoin.url('/wallet/add')).send(walletParams).result();
const wallet = new Wallet(this.bitgo, this.baseCoin, newWallet);
return {
wallet,
Expand Down Expand Up @@ -466,7 +466,7 @@ export class Wallets implements IWallets {
walletParams.keys = undefined;
walletParams.keySignatures = undefined;

const newWallet = await this.bitgo.post(this.baseCoin.url('/wallet')).send(walletParams).result(); // returns the ids
const newWallet = await this.bitgo.post(this.baseCoin.url('/wallet/add')).send(walletParams).result(); // returns the ids

const userKeychain = this.baseCoin.keychains().get({ id: newWallet.keys[KeyIndices.USER], reqId });
const backupKeychain = this.baseCoin.keychains().get({ id: newWallet.keys[KeyIndices.BACKUP], reqId });
Expand Down Expand Up @@ -582,7 +582,7 @@ export class Wallets implements IWallets {
}

this.bitgo.setRequestTracer(reqId);
const newWallet = await this.bitgo.post(this.baseCoin.url('/wallet')).send(finalWalletParams).result();
const newWallet = await this.bitgo.post(this.baseCoin.url('/wallet/add')).send(finalWalletParams).result();

const result: WalletWithKeychains = {
wallet: new Wallet(this.bitgo, this.baseCoin, newWallet),
Expand Down Expand Up @@ -1010,7 +1010,7 @@ export class Wallets implements IWallets {
walletVersion,
};
const finalWalletParams = await this.baseCoin.supplementGenerateWallet(walletParams, keychains);
const newWallet = await this.bitgo.post(this.baseCoin.url('/wallet')).send(finalWalletParams).result();
const newWallet = await this.bitgo.post(this.baseCoin.url('/wallet/add')).send(finalWalletParams).result();

const result: WalletWithKeychains = {
wallet: new Wallet(this.bitgo, this.baseCoin, newWallet),
Expand Down Expand Up @@ -1094,7 +1094,7 @@ export class Wallets implements IWallets {
};

const finalWalletParams = await this.baseCoin.supplementGenerateWallet(walletParams, keychains);
const newWallet = await this.bitgo.post(this.baseCoin.url('/wallet')).send(finalWalletParams).result();
const newWallet = await this.bitgo.post(this.baseCoin.url('/wallet/add')).send(finalWalletParams).result();

const result: WalletWithKeychains = {
wallet: new Wallet(this.bitgo, this.baseCoin, newWallet),
Expand Down Expand Up @@ -1130,7 +1130,7 @@ export class Wallets implements IWallets {
};

// Create Wallet
const newWallet = await this.bitgo.post(this.baseCoin.url('/wallet')).send(finalWalletParams).result();
const newWallet = await this.bitgo.post(this.baseCoin.url('/wallet/add')).send(finalWalletParams).result();
const wallet = new Wallet(this.bitgo, this.baseCoin, newWallet);
const keychains = wallet.keyIds();
const result: WalletWithKeychains = {
Expand Down

0 comments on commit a021bd4

Please sign in to comment.