Skip to content

Commit 1a57a84

Browse files
authored
Merge pull request #5176 from BitGo/WP-3152-update-add-wallet-url
chore(sdk-core): switch to new API url for create wallet
2 parents c005bef + 0c8447e commit 1a57a84

File tree

3 files changed

+29
-29
lines changed

3 files changed

+29
-29
lines changed

modules/bitgo/test/v2/unit/lightning/lightningWallets.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ describe('Lightning wallets', function () {
165165
.reply(200, { id: 'keyId3' });
166166

167167
nock(bgUrl)
168-
.post('/api/v2/' + coinName + '/wallet', (body) => validateWalletRequest(body))
168+
.post('/api/v2/' + coinName + '/wallet/add', (body) => validateWalletRequest(body))
169169
.reply(200, { id: 'walletId' });
170170

171171
const response = await wallets.generateWallet(params);

modules/bitgo/test/v2/unit/wallets.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ describe('V2 Wallets:', function () {
8080

8181
it('creates a paired custodial wallet', async function () {
8282
nock(bgUrl)
83-
.post('/api/v2/tbtc/wallet', function (body) {
83+
.post('/api/v2/tbtc/wallet/add', function (body) {
8484
body.isCustodial.should.be.true();
8585
body.should.have.property('keys');
8686
body.m.should.equal(2);
@@ -97,7 +97,7 @@ describe('V2 Wallets:', function () {
9797
const eosWallets = eosBitGo.coin('teos').wallets();
9898
const address = 'testeosaddre';
9999
nock(bgUrl)
100-
.post('/api/v2/teos/wallet', function (body) {
100+
.post('/api/v2/teos/wallet/add', function (body) {
101101
body.should.have.property('keys');
102102
body.m.should.equal(2);
103103
body.n.should.equal(3);
@@ -110,7 +110,7 @@ describe('V2 Wallets:', function () {
110110

111111
it('creates a single custodial wallet', async function () {
112112
nock(bgUrl)
113-
.post('/api/v2/tbtc/wallet', function (body) {
113+
.post('/api/v2/tbtc/wallet/add', function (body) {
114114
body.type.should.equal('custodial');
115115
body.should.not.have.property('keys');
116116
body.should.not.have.property('m');
@@ -126,7 +126,7 @@ describe('V2 Wallets:', function () {
126126
ethBitGo.initializeTestVars();
127127
const ethWallets = ethBitGo.coin('teth').wallets();
128128
nock(bgUrl)
129-
.post('/api/v2/teth/wallet', function (body) {
129+
.post('/api/v2/teth/wallet/add', function (body) {
130130
body.type.should.equal('custodial');
131131
body.gasPrice.should.equal(20000000000);
132132
body.should.not.have.property('keys');
@@ -148,7 +148,7 @@ describe('V2 Wallets:', function () {
148148
ethBitGo.initializeTestVars();
149149
const ethWallets = ethBitGo.coin('teth').wallets();
150150
nock(bgUrl)
151-
.post('/api/v2/teth/wallet', function (body) {
151+
.post('/api/v2/teth/wallet/add', function (body) {
152152
body.type.should.equal('custodial');
153153
body.walletVersion.should.equal(1);
154154
body.should.not.have.property('keys');
@@ -162,7 +162,7 @@ describe('V2 Wallets:', function () {
162162

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

332332
// wallet
333-
nock(bgUrl).post('/api/v2/tbtc/wallet').reply(200);
333+
nock(bgUrl).post('/api/v2/tbtc/wallet/add').reply(200);
334334

335335
await wallets.generateWallet(params);
336336
});
@@ -367,7 +367,7 @@ describe('V2 Wallets:', function () {
367367
.reply(200);
368368

369369
// wallet
370-
nock(bgUrl).post('/api/v2/tbtc/wallet').reply(200);
370+
nock(bgUrl).post('/api/v2/tbtc/wallet/add').reply(200);
371371

372372
await wallets.generateWallet(params);
373373
});
@@ -402,7 +402,7 @@ describe('V2 Wallets:', function () {
402402
.reply(200);
403403

404404
// wallet
405-
const walletNock = nock(bgUrl).post('/api/v2/tbtc/wallet').reply(200);
405+
const walletNock = nock(bgUrl).post('/api/v2/tbtc/wallet/add').reply(200);
406406

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

420420
const walletNock = nock(bgUrl)
421-
.post('/api/v2/tbtc/wallet', function (body) {
421+
.post('/api/v2/tbtc/wallet/add', function (body) {
422422
body.type.should.equal('custodial');
423423
should.not.exist(body.m);
424424
should.not.exist(body.n);
@@ -449,7 +449,7 @@ describe('V2 Wallets:', function () {
449449
};
450450

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

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

532532
const wallets = new Wallets(bitgo, tsol);
533533

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

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

579579
const wallets = new Wallets(bitgo, tsol);
580580

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

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

617617
const wallets = new Wallets(bitgo, tpolygon);
618618

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

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

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

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

@@ -777,7 +777,7 @@ describe('V2 Wallets:', function () {
777777
};
778778

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

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

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

922922
const wallets = new Wallets(bitgo, testCoin);
923923

@@ -971,7 +971,7 @@ describe('V2 Wallets:', function () {
971971
.resolves(stubbedKeychainsTriplet);
972972

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

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

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

11291129
const wallets = new Wallets(bitgo, eth2);
11301130

modules/sdk-core/src/bitgo/wallet/wallets.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export class Wallets implements IWallets {
150150
throw new Error('invalid argument for address - valid address string expected');
151151
}
152152

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

200-
const newWallet = await this.bitgo.post(this.baseCoin.url('/wallet')).send(walletParams).result();
200+
const newWallet = await this.bitgo.post(this.baseCoin.url('/wallet/add')).send(walletParams).result();
201201
const wallet = new Wallet(this.bitgo, this.baseCoin, newWallet);
202202
return {
203203
wallet,
@@ -466,7 +466,7 @@ export class Wallets implements IWallets {
466466
walletParams.keys = undefined;
467467
walletParams.keySignatures = undefined;
468468

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

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

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

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

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

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

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

11321132
// Create Wallet
1133-
const newWallet = await this.bitgo.post(this.baseCoin.url('/wallet')).send(finalWalletParams).result();
1133+
const newWallet = await this.bitgo.post(this.baseCoin.url('/wallet/add')).send(finalWalletParams).result();
11341134
const wallet = new Wallet(this.bitgo, this.baseCoin, newWallet);
11351135
const keychains = wallet.keyIds();
11361136
const result: WalletWithKeychains = {

0 commit comments

Comments
 (0)