Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(sdk-core): switch to new API url for create wallet #5176

Merged
merged 1 commit into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/bitgo/test/v2/unit/lightning/lightningWallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ describe('Lightning wallets', function () {
.reply(200, { id: 'keyId3' });

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

const response = await wallets.generateWallet(params);
Expand Down
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