From 18e5bcf6f699b081e2dddedb9eaa69393f3a70a5 Mon Sep 17 00:00:00 2001 From: Manolis Liolios Date: Tue, 22 Apr 2025 14:15:01 +0400 Subject: [PATCH 1/2] add tracking headers for mvr calls --- packages/mvr-static/src/parsing.ts | 8 ++++++-- .../src/transactions/plugins/NamedPackagesPlugin.ts | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/mvr-static/src/parsing.ts b/packages/mvr-static/src/parsing.ts index d9059be65..14fd4c1f7 100644 --- a/packages/mvr-static/src/parsing.ts +++ b/packages/mvr-static/src/parsing.ts @@ -21,6 +21,10 @@ const MAX_BATCH_SIZE = 25; // files to process per batch. const MAINNET_API_URL = 'https://mainnet.mvr.mystenlabs.com'; const TESTNET_API_URL = 'https://testnet.mvr.mystenlabs.com'; +const MVR_API_HEADER = { + 'Mvr-Source': 'ts-static-plugin', +}; + const WARNING_MESSAGE = `/** * This file is automatically generated by the mvr SDK. * You can edit this file, but it will be overwritten on the next run. @@ -158,7 +162,7 @@ async function resolvePackages(packages: string[], apiUrl: string) { batches.map(async (batch) => { const response = await fetch(`${apiUrl}/v1/resolution/bulk`, { method: 'POST', - headers: { 'Content-Type': 'application/json' }, + headers: { 'Content-Type': 'application/json', ...MVR_API_HEADER }, body: JSON.stringify({ names: batch, }), @@ -199,7 +203,7 @@ async function resolveTypes(types: string[], apiUrl: string) { batches.map(async (batch) => { const response = await fetch(`${apiUrl}/v1/struct-definition/bulk`, { method: 'POST', - headers: { 'Content-Type': 'application/json' }, + headers: { 'Content-Type': 'application/json', ...MVR_API_HEADER }, body: JSON.stringify({ types: batch, }), diff --git a/packages/typescript/src/transactions/plugins/NamedPackagesPlugin.ts b/packages/typescript/src/transactions/plugins/NamedPackagesPlugin.ts index b1ac3efe7..c0e0029c0 100644 --- a/packages/typescript/src/transactions/plugins/NamedPackagesPlugin.ts +++ b/packages/typescript/src/transactions/plugins/NamedPackagesPlugin.ts @@ -13,6 +13,10 @@ import { replaceNames, } from './utils.js'; +const MVR_API_HEADER = { + 'Mvr-Source': 'ts-sdk-plugin', +}; + export type NamedPackagesPluginOptions = { /** * The URL of the MVR API to use for resolving names. @@ -118,7 +122,7 @@ export const namedPackagesPlugin = ({ batches.map(async (batch) => { const response = await fetch(`${apiUrl}/v1/resolution/bulk`, { method: 'POST', - headers: { 'Content-Type': 'application/json' }, + headers: { 'Content-Type': 'application/json', ...MVR_API_HEADER }, body: JSON.stringify({ names: batch, }), @@ -156,7 +160,7 @@ export const namedPackagesPlugin = ({ batches.map(async (batch) => { const response = await fetch(`${apiUrl}/v1/struct-definition/bulk`, { method: 'POST', - headers: { 'Content-Type': 'application/json' }, + headers: { 'Content-Type': 'application/json', ...MVR_API_HEADER }, body: JSON.stringify({ types: batch, }), From 593720d93e93aade500f4dd499b363afbe3fe717 Mon Sep 17 00:00:00 2001 From: Manolis Liolios Date: Tue, 22 Apr 2025 14:15:48 +0400 Subject: [PATCH 2/2] Add changeset --- .changeset/hot-apricots-dress.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/hot-apricots-dress.md diff --git a/.changeset/hot-apricots-dress.md b/.changeset/hot-apricots-dress.md new file mode 100644 index 000000000..cc20c5cea --- /dev/null +++ b/.changeset/hot-apricots-dress.md @@ -0,0 +1,6 @@ +--- +'@mysten/mvr-static': patch +'@mysten/sui': patch +--- + +Adds headers to mvr api calls