From 70066130894b18d761234e5ded97616f1d5d7424 Mon Sep 17 00:00:00 2001 From: Alia Aamir Date: Mon, 14 Sep 2026 14:23:31 -0400 Subject: [PATCH] fix(examples): standardize wallet ID env var across Go Account scripts Renames the local accountId variable to walletId in scripts that used it, matching the naming already used elsewhere, and fixes create-go-account-address.ts to read OFC_WALLET_ID instead of a hardcoded placeholder. TICKET: CAAS-2606 --- examples/ts/go-account/create-go-account-address.ts | 8 ++++++-- examples/ts/go-account/go-account-get-balance.ts | 8 ++++---- examples/ts/go-account/go-account-get-order.ts | 4 ++-- examples/ts/go-account/go-account-list-orders.ts | 8 ++++---- examples/ts/go-account/go-account-list-products.ts | 8 ++++---- examples/ts/go-account/go-account-place-order.ts | 6 +++--- 6 files changed, 23 insertions(+), 19 deletions(-) diff --git a/examples/ts/go-account/create-go-account-address.ts b/examples/ts/go-account/create-go-account-address.ts index 544dad5a25..35fd814e1e 100644 --- a/examples/ts/go-account/create-go-account-address.ts +++ b/examples/ts/go-account/create-go-account-address.ts @@ -10,6 +10,10 @@ * IMPORTANT: For Go Account (OFC) wallets, the onToken parameter is always required * when creating addresses. * + * Required environment variables (in examples/.env): + * TESTNET_ACCESS_TOKEN - your BitGo access token + * OFC_WALLET_ID - your Go Account wallet ID + * * Copyright 2025, BitGo, Inc. All Rights Reserved. */ @@ -27,8 +31,8 @@ const bitgo = new BitGoAPI({ const coin = 'ofc'; bitgo.register(coin, coins.Ofc.createInstance); -// Configuration - Update these values -const walletId = 'your_wallet_id'; // The ID of your existing Go Account wallet +// Configuration - Update these values or set them as environment variables +const walletId = process.env.OFC_WALLET_ID || 'your_wallet_id'; // The ID of your existing Go Account wallet const addressLabel = 'My New Address 2'; // Label for the new address // Token to create address for (required for OFC wallets) diff --git a/examples/ts/go-account/go-account-get-balance.ts b/examples/ts/go-account/go-account-get-balance.ts index 9edace72a5..5a034d8e48 100644 --- a/examples/ts/go-account/go-account-get-balance.ts +++ b/examples/ts/go-account/go-account-get-balance.ts @@ -33,7 +33,7 @@ const bitgo = new BitGoAPI({ // --------------------------------------------------------------------------- /** Your Go Account wallet ID */ -const accountId = process.env.OFC_WALLET_ID || 'your_wallet_id'; +const walletId = process.env.OFC_WALLET_ID || 'your_wallet_id'; /** * When true, unsettled trading balance is included in the available balance @@ -67,10 +67,10 @@ async function main() { console.log(`Include unsettled in available: ${includeUnsettledInAvailable}\n`); const url = (bitgo as any).microservicesUrl( - `/api/prime/trading/v1/accounts/${accountId}/balances` + `/api/prime/trading/v1/accounts/${walletId}/balances` ); - console.log(`Fetching balances for account ${accountId}...`); + console.log(`Fetching balances for account ${walletId}...`); const response: GetBalancesResponse = await (bitgo as any) .get(url) .query({ includeUnsettledInAvailable }) @@ -103,7 +103,7 @@ async function main() { console.log('\n' + '='.repeat(60)); console.log('SUMMARY'); console.log('='.repeat(60)); - console.log(` Account ID : ${accountId}`); + console.log(` Account ID : ${walletId}`); console.log(` Currencies held : ${balances.length}`); console.log(` Include unsettled : ${includeUnsettledInAvailable}`); for (const b of balances) { diff --git a/examples/ts/go-account/go-account-get-order.ts b/examples/ts/go-account/go-account-get-order.ts index 8a5df23942..92f9b11c89 100644 --- a/examples/ts/go-account/go-account-get-order.ts +++ b/examples/ts/go-account/go-account-get-order.ts @@ -28,7 +28,7 @@ const bitgo = new BitGoAPI({ // --------------------------------------------------------------------------- /** Your Go Account wallet ID */ -const accountId = process.env.OFC_WALLET_ID || 'your_wallet_id'; +const walletId = process.env.OFC_WALLET_ID || 'your_wallet_id'; /** The order ID returned when the order was placed */ const orderId = process.env.TRADE_ORDER_ID || 'your_order_id'; @@ -58,7 +58,7 @@ async function main() { console.log('=== Go Account — Get Trade Order ===\n'); const url = (bitgo as any).microservicesUrl( - `/api/prime/trading/v1/accounts/${accountId}/orders/${orderId}` + `/api/prime/trading/v1/accounts/${walletId}/orders/${orderId}` ); console.log(`Fetching order ${orderId}...`); diff --git a/examples/ts/go-account/go-account-list-orders.ts b/examples/ts/go-account/go-account-list-orders.ts index 52866d6543..2aefa5c3d1 100644 --- a/examples/ts/go-account/go-account-list-orders.ts +++ b/examples/ts/go-account/go-account-list-orders.ts @@ -30,7 +30,7 @@ const bitgo = new BitGoAPI({ // --------------------------------------------------------------------------- /** Your Go Account wallet ID */ -const accountId = process.env.OFC_WALLET_ID || 'your_wallet_id'; +const walletId = process.env.OFC_WALLET_ID || 'your_wallet_id'; /** Optional: filter orders by status */ const statusFilter = process.env.TRADE_ORDER_STATUS; @@ -65,7 +65,7 @@ async function main() { console.log('=== Go Account — List Trade Orders ===\n'); const url = (bitgo as any).microservicesUrl( - `/api/prime/trading/v1/accounts/${accountId}/orders` + `/api/prime/trading/v1/accounts/${walletId}/orders` ); // Build query params @@ -77,7 +77,7 @@ async function main() { query['product'] = productFilter; } - console.log(`Fetching orders for account ${accountId}...`); + console.log(`Fetching orders for account ${walletId}...`); if (statusFilter) console.log(` Status filter : ${statusFilter}`); if (productFilter) console.log(` Product filter : ${productFilter}`); console.log(''); @@ -112,7 +112,7 @@ async function main() { console.log('\n' + '='.repeat(60)); console.log('SUMMARY'); console.log('='.repeat(60)); - console.log(` Account ID : ${accountId}`); + console.log(` Account ID : ${walletId}`); console.log(` Total orders : ${orders.length}`); // Group by status diff --git a/examples/ts/go-account/go-account-list-products.ts b/examples/ts/go-account/go-account-list-products.ts index 78d2df337e..fb0696a2c3 100644 --- a/examples/ts/go-account/go-account-list-products.ts +++ b/examples/ts/go-account/go-account-list-products.ts @@ -30,7 +30,7 @@ const bitgo = new BitGoAPI({ * Your Go Account wallet ID. * Find this in the BitGo portal or from the wallet object in your API responses. */ -const accountId = process.env.OFC_WALLET_ID || 'your_wallet_id'; +const walletId = process.env.OFC_WALLET_ID || 'your_wallet_id'; // --------------------------------------------------------------------------- @@ -53,10 +53,10 @@ async function main() { console.log('=== Go Account — List Trading Products ===\n'); const url = (bitgo as any).microservicesUrl( - `/api/prime/trading/v1/accounts/${accountId}/products` + `/api/prime/trading/v1/accounts/${walletId}/products` ); - console.log(`Fetching trading products for account ${accountId}...`); + console.log(`Fetching trading products for account ${walletId}...`); const response: ListProductsResponse = await (bitgo as any).get(url).result(); const products: Product[] = response.data ?? []; @@ -99,7 +99,7 @@ async function main() { console.log('\n' + '='.repeat(60)); console.log('SUMMARY'); console.log('='.repeat(60)); - console.log(` Account ID : ${accountId}`); + console.log(` Account ID : ${walletId}`); console.log(` Total products : ${products.length}`); console.log(` Available to trade: ${availableProducts.length}`); console.log(` Disabled : ${disabledProducts.length}`); diff --git a/examples/ts/go-account/go-account-place-order.ts b/examples/ts/go-account/go-account-place-order.ts index 73f40d4c95..86222d1a7b 100644 --- a/examples/ts/go-account/go-account-place-order.ts +++ b/examples/ts/go-account/go-account-place-order.ts @@ -49,7 +49,7 @@ const bitgo = new BitGoAPI({ * Your Go Account wallet ID. * Find this in the BitGo portal or from the wallet object in your API responses. */ -const accountId = process.env.OFC_WALLET_ID || 'your_wallet_id'; +const walletId = process.env.OFC_WALLET_ID || 'your_wallet_id'; /** * Unique identifier for this order. Must be unique per account. @@ -163,7 +163,7 @@ async function main() { // Log what we are about to send console.log('Order details:'); - console.log(` Account ID : ${accountId}`); + console.log(` Account ID : ${walletId}`); console.log(` Client Order ID : ${clientOrderId}`); console.log(` Type : ${orderType}`); console.log(` Product : ${product}`); @@ -184,7 +184,7 @@ async function main() { console.log(''); const url = (bitgo as any).microservicesUrl( - `/api/prime/trading/v1/accounts/${accountId}/orders` + `/api/prime/trading/v1/accounts/${walletId}/orders` ); console.log('Placing trade order...');