From 2e761bca2922792d99ef004e2b24cc8218f6b54a Mon Sep 17 00:00:00 2001 From: Onyx2406 Date: Fri, 3 Apr 2026 07:42:47 +0000 Subject: [PATCH] fix: fix Create Quote Bruno pre-request script The pre-request script for Create Quote tried to retrieve a stored request object from environment variables via getEnvVar, but Bruno environment variables are serialized as strings, so the object's properties (.body.query, .url) were undefined at runtime. Fix by inlining the CreateWalletAddress GraphQL mutation directly in the pre-request script and using the RafikiGraphqlHost env var for the URL. Also remove the unnecessary `setEnvVar('initialWalletAddressRequest', req)` from Create Wallet Address since the request object cannot be properly serialized to env vars. Closes #3573 --- .../Rafiki/Rafiki Admin APIs/Create Quote.bru | 42 ++++++++++++------- .../Create Wallet Address.bru | 1 - 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Create Quote.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Create Quote.bru index 8eb7adb841..037f54df4f 100644 --- a/bruno/collections/Rafiki/Rafiki Admin APIs/Create Quote.bru +++ b/bruno/collections/Rafiki/Rafiki Admin APIs/Create Quote.bru @@ -51,25 +51,34 @@ body:graphql:vars { script:pre-request { // Create an additional wallet address to represent the account that will be sending money - + const fetch = require('node-fetch'); const scripts = require('./scripts'); - + const randomInt = Math.floor(Math.random() * (1001)); - - const initialRequest = bru.getEnvVar("initialWalletAddressRequest"); - const postRequestBody = { - query: initialRequest.body.query, - variables: { - "input": { - "assetId": bru.getEnvVar("assetId"), - "url": "https://" + bru.getEnvVar("OpenPaymentsHost") + "/simon/" + randomInt, - "publicName": "Simon" + + const createWalletAddressQuery = ` + mutation CreateWalletAddress($input: CreateWalletAddressInput!) { + createWalletAddress(input: $input) { + walletAddress { + id + } } + } + `; + + const postRequestBody = { + query: createWalletAddressQuery, + variables: { + input: { + assetId: bru.getEnvVar("assetId"), + url: "https://" + bru.getEnvVar("OpenPaymentsHost") + "/simon/" + randomInt, + publicName: "Simon" } } - - const signature = scripts.generateBackendApiSignature(postRequestBody) + }; + + const signature = scripts.generateBackendApiSignature(postRequestBody); const postRequest = { method: 'post', headers: { @@ -79,11 +88,12 @@ script:pre-request { }, body: JSON.stringify(postRequestBody) }; - - const response = await fetch(`${initialRequest.url}`, postRequest); + + const graphqlUrl = bru.getEnvVar("RafikiGraphqlHost") + "/graphql"; + const response = await fetch(graphqlUrl, postRequest); const body = await response.json(); bru.setEnvVar("secondWalletAddressId", body.data.createWalletAddress.walletAddress.id); - + scripts.addApiSignatureHeader(); } diff --git a/bruno/collections/Rafiki/Rafiki Admin APIs/Create Wallet Address.bru b/bruno/collections/Rafiki/Rafiki Admin APIs/Create Wallet Address.bru index c93e99844e..2dc181e1d8 100644 --- a/bruno/collections/Rafiki/Rafiki Admin APIs/Create Wallet Address.bru +++ b/bruno/collections/Rafiki/Rafiki Admin APIs/Create Wallet Address.bru @@ -65,7 +65,6 @@ script:post-response { if (body?.data) { bru.setEnvVar("walletAddressId", body.data.createWalletAddress.walletAddress.id); bru.setEnvVar("walletAddressUrl", body.data.createWalletAddress.walletAddress.url); - bru.setEnvVar('initialWalletAddressRequest',req) } }