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

feat(bitgo): change default testnet config to holesky #4176

Merged
merged 1 commit into from
Jan 5, 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
4 changes: 2 additions & 2 deletions modules/bitgo/test/v2/lib/recovery-nocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ module.exports.nockEthRecovery = function (bitgo, nockData = nockEthData) {
if (apiKey) {
data.params.apiKey = apiKey;
}
nock('https://api-goerli.etherscan.io').get('/api').query(data.params).reply(200, data.response);
nock('https://api-holesky.etherscan.io').get('/api').query(data.params).reply(200, data.response);
});
};

Expand All @@ -406,7 +406,7 @@ module.exports.nockEtherscanRateLimitError = function () {
address: '0x74c2137d54b0fc9f907e13f14e0dd18485fee924',
};

nock('https://api-goerli.etherscan.io').get('/api').query(params).reply(200, response);
nock('https://api-holesky.etherscan.io').get('/api').query(params).reply(200, response);
};

module.exports.nockXlmRecovery = function () {
Expand Down
5 changes: 5 additions & 0 deletions modules/bitgo/test/v2/unit/baseCoin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ describe('V2 Base Coin:', function () {
kovanToken.coin.should.equal('teth');
kovanToken.network.should.equal('Testnet');
kovanToken.getFamily().should.equal('eth');
// holesky token
const holeskyToken = bitgo.coin('bgerch');
holeskyToken.coin.should.equal('hteth');
holeskyToken.network.should.equal('Testnet');
holeskyToken.getFamily().should.equal('eth');
});
});

Expand Down
12 changes: 6 additions & 6 deletions modules/bitgo/test/v2/unit/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3794,7 +3794,7 @@ describe('V2 Wallet:', function () {
before(async function () {
const walletData = {
id: '598f606cd8fc24710d2ebadb1d9459bb',
coin: 'gteth',
coin: 'hteth',
keys: [
'598f606cd8fc24710d2ebad89dce86c2',
'598f606cc8e43aef09fcb785221d9dd2',
Expand All @@ -3805,7 +3805,7 @@ describe('V2 Wallet:', function () {
baseAddress: '0xdf07117705a9f8dc4c2a78de66b7f1797dba9d4e',
},
};
ethWallet = new Wallet(bitgo, bitgo.coin('gteth'), walletData);
ethWallet = new Wallet(bitgo, bitgo.coin('hteth'), walletData);
});

afterEach(async function () {
Expand All @@ -3814,7 +3814,7 @@ describe('V2 Wallet:', function () {

it('Should return all nfts in the wallet', async function () {
const getTokenBalanceNock = nock(bgUrl)
.get(`/api/v2/gteth/wallet/${ethWallet.id()}?allTokens=true`)
.get(`/api/v2/hteth/wallet/${ethWallet.id()}?allTokens=true`)
.reply(200, {
...walletData,
...nftResponse,
Expand All @@ -3839,7 +3839,7 @@ describe('V2 Wallet:', function () {

it('Should throw when attempting to transfer a nft collection not in the wallet', async function () {
const getTokenBalanceNock = nock(bgUrl)
.get(`/api/v2/gteth/wallet/${ethWallet.id()}?allTokens=true`)
.get(`/api/v2/hteth/wallet/${ethWallet.id()}?allTokens=true`)
.reply(200, {
...walletData,
...nftResponse,
Expand All @@ -3864,7 +3864,7 @@ describe('V2 Wallet:', function () {

it('Should throw when attempting to transfer a ERC-721 nft not owned by the wallet', async function () {
const getTokenBalanceNock = nock(bgUrl)
.get(`/api/v2/gteth/wallet/${ethWallet.id()}?allTokens=true`)
.get(`/api/v2/hteth/wallet/${ethWallet.id()}?allTokens=true`)
.reply(200, {
...walletData,
...nftResponse,
Expand Down Expand Up @@ -3892,7 +3892,7 @@ describe('V2 Wallet:', function () {

it('Should throw when attempting to transfer ERC-1155 tokens when the amount transferred is more than the spendable balance', async function () {
const getTokenBalanceNock = nock(bgUrl)
.get(`/api/v2/gteth/wallet/${ethWallet.id()}?allTokens=true`)
.get(`/api/v2/hteth/wallet/${ethWallet.id()}?allTokens=true`)
.reply(200, {
...walletData,
...{
Expand Down
6 changes: 3 additions & 3 deletions modules/sdk-core/src/bitgo/environments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const testnetBase: EnvironmentTemplate = {
serverXpub: hardcodedPublicKeys.serverXpub.test,
hsmXpub: hardcodedPublicKeys.hsmXpub.test,
btcExplorerBaseUrl: 'https://blockstream.info/testnet/api',
etherscanBaseUrl: 'https://api-goerli.etherscan.io',
etherscanBaseUrl: 'https://api-holesky.etherscan.io',
dpkjnr marked this conversation as resolved.
Show resolved Hide resolved
etherscanApiToken: process.env.ETHERSCAN_API_TOKEN,
avaxcNetworkBaseUrl: 'https://api.avax-test.network',
eth2ExplorerBaseUrl: 'https://beaconscan.com/api',
Expand Down Expand Up @@ -218,7 +218,7 @@ export const Environments: Environments = {
mock: Object.assign({}, devBase, {
uri: 'https://bitgo.fakeurl',
stellarFederationServerUrl: 'https://bitgo.fakeurl/api/v2/txlm/federation',
etherscanBaseUrl: 'https://api-goerli.etherscan.fakeurl',
etherscanBaseUrl: 'https://api-holesky.etherscan.fakeurl',
etherscanApiToken: process.env.ETHERSCAN_API_TOKEN,
avaxcNetworkBaseUrl: 'https://api.avax-test.network.fakeurl',
eth2ExplorerBaseUrl: 'https://beaconscan.com/api',
Expand Down Expand Up @@ -251,7 +251,7 @@ export const Environments: Environments = {
: 'https://blockstream.info/api',
etherscanBaseUrl:
process.env.BITGO_CUSTOM_ETHEREUM_NETWORK !== 'ethereum'
? 'https://api-goerli.etherscan.io'
? 'https://api-holesky.etherscan.io'
: 'https://api.etherscan.io',
stellarFederationServerUrl:
process.env.BITGO_CUSTOM_STELLAR_NETWORK !== 'stellar'
Expand Down
20 changes: 10 additions & 10 deletions modules/sdk-test/src/bitgo/lib/test_bitgo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -409,21 +409,21 @@ export class TestBitGo {
await this.authenticateTestUser(this.testUserOTP());
const testWalletId = TestBitGo.V2.TEST_ETH_WALLET_ID;

const { gtethWallet, tbtcWallet, unspentWallet, sweep1Wallet }: any = await promiseProps({
gtethWallet: this.coin('gteth').wallets().get({ id: testWalletId }),
const { htethWallet, tbtcWallet, unspentWallet, sweep1Wallet }: any = await promiseProps({
htethWallet: this.coin('hteth').wallets().get({ id: testWalletId }),
tbtcWallet: this.coin('tbtc').wallets().getWallet({ id: TestBitGo.V2.TEST_WALLET1_ID }),
unspentWallet: this.coin('tbtc').wallets().getWallet({ id: TestBitGo.V2.TEST_WALLET2_UNSPENTS_ID }),
sweep1Wallet: this.coin('tbtc').wallets().getWallet({ id: TestBitGo.V2.TEST_SWEEP1_ID }),
});

const spendableBalance = gtethWallet.spendableBalanceString;
const spendableBalance = htethWallet.spendableBalanceString;

let balance = new BigNumber(spendableBalance);

// Check our balance is over 60000 (we spend 50000, add some cushion)
if (balance.lt(60000)) {
throw new Error(
`The GTETH wallet ${testWalletId} does not have enough funds to run the test suite. The current balance is ${balance}. Please fund this wallet!`
`The HTETH wallet ${testWalletId} does not have enough funds to run the test suite. The current balance is ${balance}. Please fund this wallet!`
);
}

Expand Down Expand Up @@ -474,7 +474,7 @@ export class TestBitGo {
permissions: [Object],
},
],
coin: 'gteth',
coin: 'hteth',
label: 'my test ether wallet',
m: 2,
n: 3,
Expand Down Expand Up @@ -515,7 +515,7 @@ export class TestBitGo {
address: '0xa7f9ca5c1268b0082db1833d30f33d3cfd4286d8',
chain: 0,
index: 701,
coin: 'gteth',
coin: 'hteth',
lastNonce: 0,
wallet: '598f606cd8fc24710d2ebadb1d9459bb',
coinSpecific: {
Expand All @@ -529,20 +529,20 @@ export class TestBitGo {
pendingApprovals: [],
};

const wallet = new Wallet(this, this.coin('gteth'), walletData);
const wallet = new Wallet(this, this.coin('hteth'), walletData);

// Nock calls to platform for building transactions and getting user key
// Should be OK to persist these since they are wallet specific data reads
nock(this._baseUrl)
.persist()
.filteringRequestBody(() => '*')
.post(`/api/v2/gteth/wallet/${wallet.id()}/tx/build`, '*')
.post(`/api/v2/hteth/wallet/${wallet.id()}/tx/build`, '*')
.reply(200, {
gasLimit: 500000,
gasPrice: 20000000000,
nextContractSequenceId: 101,
})
.get(`/api/v2/gteth/key/${wallet.keyIds()[KeyIndices.USER]}`)
.get(`/api/v2/hteth/key/${wallet.keyIds()[KeyIndices.USER]}`)
.reply(200, {
id: '598f606cd8fc24710d2ebad89dce86c2',
users: ['543c11ed356d00cb7600000b98794503'],
Expand All @@ -564,7 +564,7 @@ export class TestBitGo {
}

// Nock tokens stuck on the wallet
nock('https://api-goerli.etherscan.io')
nock('https://api-holesky.etherscan.io')
.get('/api')
.query(params)
.reply(200, { status: '1', message: 'OK', result: '2400' });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class EcdsaEVMUnifiedWallets extends UnifiedWallets {
coinName = 'eth';
break;
default:
coinName = 'gteth';
coinName = 'hteth';
}
return coinName;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { coins } from '@bitgo/statics';

export const supportedCoins: string[] = [coins.get('eth').name, coins.get('polygon').name].map((e) => e.toLowerCase());
export const supportedTestCoins: string[] = [coins.get('gteth').name, coins.get('tpolygon').name].map((e) =>
e.toLowerCase()
);
export const supportedTestCoins: string[] = [
coins.get('gteth').name,
coins.get('hteth').name,
coins.get('tpolygon').name,
].map((e) => e.toLowerCase());
2 changes: 1 addition & 1 deletion modules/sdk-unified-wallet/src/unifiedWallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export abstract class UnifiedWallets implements IUnifiedWallets {
if (isEmpty(this.coinIdMapping) || !Object.keys(this.coinIdMapping).includes(coinName)) {
let coinWalletId;
for (const wallet of this.unifiedWallet.wallets) {
if (wallet.coin == coinName) {
if (wallet.coin === coinName) {
coinWalletId = wallet.walletId;
break;
}
Expand Down
13 changes: 8 additions & 5 deletions modules/sdk-unified-wallet/test/unit/ecdsaUnifiedWallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('EVM Wallets:', function () {
const expected: UnifiedWallet = {
id: 'great unified wallet',
wallets: [
{ coin: 'gteth', walletId: ethWalletId, address: ethAddress },
{ coin: 'hteth', walletId: ethWalletId, address: ethAddress },
{ coin: 'tpolygon', walletId: polygonWalletId, address: ethAddress },
],
curve: 'ecdsa',
Expand All @@ -29,6 +29,7 @@ describe('EVM Wallets:', function () {

before(function () {
bitgo.safeRegister('gteth', Gteth.createInstance);
bitgo.safeRegister('hteth', Gteth.createInstance);
bitgo.safeRegister('tpolygon', Tpolygon.createInstance);
bitgo.initializeTestVars();
evmWallets = new EcdsaEVMUnifiedWallets(bitgo);
Expand Down Expand Up @@ -106,6 +107,7 @@ describe('EVM Wallets:', function () {
it('should correctly generate wallet', async function () {
sandbox.stub(UnifiedWallets.prototype, 'generateKeychainsTriplet').resolves(keyTriplet);
nock(bgUrl).post('/api/v2/gteth/wallet').reply(200, ethWalletData);
nock(bgUrl).post('/api/v2/hteth/wallet').reply(200, ethWalletData);
nock(bgUrl).post('/api/v2/tpolygon/wallet').reply(200, polygonWalletData);
nock(bgUrl).post('/api/v2/wallet/evm').reply(200, expected);
params = {
Expand All @@ -125,6 +127,7 @@ describe('EVM Wallets:', function () {
walletVersion: 3,
passphrase: 'test123',
};
nock(bgUrl).post('/api/v2/hteth/wallet').reply(200, ethWalletData);
nock(bgUrl).post('/api/v2/gteth/wallet').reply(200, ethWalletData);
nock(bgUrl).post('/api/v2/tpolygon/wallet').reply(200, polygonWalletData);
nock(bgUrl).post('/api/v2/wallet/evm').reply(200, expected);
Expand Down Expand Up @@ -176,15 +179,15 @@ describe('EVM Wallets:', function () {
it('should return valid coin wallet', async function () {
const expectedEthWallet = {
bitgo,
coin: bitgo.coin('gteth'),
coin: bitgo.coin('hteth'),
};
nock(bgUrl)
.get('/api/v2/wallet/evm')
.query({ evmWalletId })
.reply(200, { result: [expected] });
nock(bgUrl).get('/api/v2/gteth/wallet/eth-123-eth').reply(200, expectedEthWallet);
const result = await evmWallets.getCoinWalletById(evmWalletId, 'gteth');
result.baseCoin.getFullName().should.equal('Goerli Testnet Ethereum');
nock(bgUrl).get('/api/v2/hteth/wallet/eth-123-eth').reply(200, expectedEthWallet);
const result = await evmWallets.getCoinWalletById(evmWalletId, 'hteth');
result.baseCoin.getFullName().should.equal('Holesky Testnet Ethereum');
});
});
});
Expand Down
8 changes: 4 additions & 4 deletions modules/statics/src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ export function erc721(
* @param features? Features of this coin. Defaults to the DEFAULT_FEATURES defined in `AccountCoin`
* @param prefix? Optional token prefix. Defaults to empty string
* @param suffix? Optional token suffix. Defaults to token name.
* @param network? Optional token network. Defaults to Goerli test network.
* @param network? Optional token network. Defaults to Holesky test network.
* @param primaryKeyCurve The elliptic curve for this chain/token
*/
export function terc721(
Expand All @@ -625,7 +625,7 @@ export function terc721(
features: CoinFeature[] = AccountCoin.DEFAULT_FEATURES,
prefix = '',
suffix: string = name.toUpperCase(),
network: EthereumNetwork = Networks.test.goerli,
network: EthereumNetwork = Networks.test.holesky,
primaryKeyCurve: KeyCurve = KeyCurve.Secp256k1
) {
return erc721(id, name, fullName, contractAddress, features, prefix, suffix, network, primaryKeyCurve);
Expand Down Expand Up @@ -729,7 +729,7 @@ export function erc1155(
* @param features? Features of this coin. Defaults to the DEFAULT_FEATURES defined in `AccountCoin`
* @param prefix? Optional token prefix. Defaults to empty string
* @param suffix? Optional token suffix. Defaults to token name.
* @param network? Optional token network. Defaults to Goerli test network.
* @param network? Optional token network. Defaults to Holesky test network.
* @param primaryKeyCurve The elliptic curve for this chain/token
*/
export function terc1155(
Expand All @@ -740,7 +740,7 @@ export function terc1155(
features: CoinFeature[] = AccountCoin.DEFAULT_FEATURES,
prefix = '',
suffix: string = name.toUpperCase(),
network: EthereumNetwork = Networks.test.goerli,
network: EthereumNetwork = Networks.test.holesky,
primaryKeyCurve: KeyCurve = KeyCurve.Secp256k1
) {
return erc1155(id, name, fullName, contractAddress, features, prefix, suffix, network, primaryKeyCurve);
Expand Down
Loading