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 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, }),