Skip to content

Commit

Permalink
fix: Paymaster Proxy URL (#513)
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcramer committed Jun 11, 2024
1 parent 9508542 commit 462e848
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion template/web/.env.local.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ NEXT_PUBLIC_GOOGLE_ANALYTICS_ID=
NEXT_PRIVATE_RPC_URL="GET_FROM_COINBASE_DEVELOPER_PLATFORM" # See https://www.coinbase.com/developer-platform/products/base-node?utm_source=boat
NEXT_PRIVATE_PAYMASTER_URL="GET_FROM_COINBASE_DEVELOPER_PLATFORM" # See https://www.coinbase.com/developer-platform/products/base-node?utm_source=boat
NEXT_PUBLIC_PRIVY_ID="GET_FROM_PRIVY"
ENVIRONMENT=localhost
NEXT_PUBLIC_ENVIRONMENT=localhost
4 changes: 2 additions & 2 deletions template/web/.env.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NEXT_PUBLIC_GOOGLE_ANALYTICS_ID=GA_TEST_1234567890
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=TEST_1234567890
NEXT_PRIVATE_RPC_URL=https://sepolia.base.org
ENVIRONMENT=localhost
NEXT_PUBLIC_PAYMASTER_URL=TEST_https://api.developer.coinbase.com/rpc/v1/
NEXT_PUBLIC_ENVIRONMENT=localhost
NEXT_PUBLIC_PAYMASTER_URL=TEST_https://api.developer.coinbase.com/rpc/v1/
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import isLocal from '../../../src/utils/isLocal';
import { usePaymasterBundlerContract } from '../_contracts/usePaymasterBundlerContract';
import { CallStatus } from './CallStatus';

// Use the local API URL to target the Paymaster directly without a proxy
// if running on localhost, otherwise use the Paymaster Proxy.
const paymasterURL = process.env.NEXT_PUBLIC_PAYMASTER_URL;
// Target the Paymaster directly without a proxy if running on localhost.
// Use the Paymaster Proxy when deployed.
const isLocalEnv = isLocal();
const defaultUrl = isLocalEnv ? paymasterURL : `${document.location.origin}/api/paymaster-proxy`;
const defaultUrl = isLocalEnv
? process.env.NEXT_PUBLIC_PAYMASTER_URL
: `https://${process.env.NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL}/api/paymaster-proxy`;

export default function PaymasterBundlerDemo() {
const { address } = useAccount();
Expand Down
2 changes: 1 addition & 1 deletion template/web/src/store/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export enum Environment {
}

export enum EnvironmentKeys {
environment = 'ENVIRONMENT',
environment = 'NEXT_PUBLIC_ENVIRONMENT',
}

export function getCurrentEnvironment(): Environment {
Expand Down
2 changes: 1 addition & 1 deletion template/web/src/store/test/environment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('environment', () => {

describe('EnvironmentKeys', () => {
it('should have the correct values', () => {
expect(EnvironmentKeys.environment).toEqual('ENVIRONMENT');
expect(EnvironmentKeys.environment).toEqual('NEXT_PUBLIC_ENVIRONMENT');
});
});

Expand Down

0 comments on commit 462e848

Please sign in to comment.