Skip to content

Commit

Permalink
Merge pull request #10736 from JohnathanWhite/feat/dynamic-card-network
Browse files Browse the repository at this point in the history
making card use a dynamic network
  • Loading branch information
cmgustavo authored Mar 19, 2020
2 parents 8b3ee86 + b883dad commit 16d7d34
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,9 @@ export class CopayApp {
if (experiment === 'enabled') {
this.NETWORK = 'testnet';
}
this.bitpayProvider.init(experiment);
this.bitpayIdProvider.init(experiment);
this.bitpayProvider.setNetwork(this.NETWORK);
this.bitpayIdProvider.setNetwork(this.NETWORK);
this.iabCardProvider.setNetwork(this.NETWORK);

this.registerIntegrations();
this.incomingDataRedirEvent();
Expand Down
4 changes: 2 additions & 2 deletions src/providers/bitpay-id/bitpay-id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export class BitPayIdProvider {
}
}

public init(status: string) {
this.NETWORK = status === 'enabled' ? 'testnet' : 'livenet';
public setNetwork(network: string) {
this.NETWORK = network;
this.BITPAY_API_URL =
this.NETWORK == 'livenet'
? 'https://bitpay.com'
Expand Down
4 changes: 2 additions & 2 deletions src/providers/bitpay/bitpay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export class BitPayProvider {
this.logger.debug('BitPayProvider initialized');
}

public init(status: string) {
this.NETWORK = status === 'enabled' ? 'testnet' : 'livenet';
public setNetwork(network: string) {
this.NETWORK = network;
this.BITPAY_API_URL =
this.NETWORK == 'livenet'
? 'https://bitpay.com'
Expand Down
13 changes: 11 additions & 2 deletions src/providers/in-app-browser/card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import { SimplexProvider } from '../simplex/simplex';
@Injectable()
export class IABCardProvider {
private cardIAB_Ref: InAppBrowserRef;
private NETWORK = Network.testnet;
private BITPAY_API_URL = 'https://test.bitpay.com';
private NETWORK: string;
private BITPAY_API_URL: string;

private _isHidden = true;
private _pausedState = false;
Expand All @@ -50,6 +50,15 @@ export class IABCardProvider {
private onGoingProcess: OnGoingProcessProvider
) {}

public setNetwork(network: string) {
this.NETWORK = network;
this.BITPAY_API_URL =
this.NETWORK == 'livenet'
? 'https://bitpay.com'
: 'https://test.bitpay.com';
this.logger.log(`card provider initialized with ${this.NETWORK}`);
}

async getCards() {
const json = {
method: 'getDebitCards'
Expand Down

0 comments on commit 16d7d34

Please sign in to comment.