Comparing version 1.8.2 to 1.8.3
@@ -7,3 +7,3 @@ module.exports = { | ||
}, | ||
ignorePatterns: ["*.js", "examples/*", "src/indexer/generated/**"], | ||
ignorePatterns: ["*.js", "examples/*", "src/indexer/generated/**", "scripts/publish_ans_contract.ts"], | ||
extends: ["airbnb-base", "airbnb-typescript/base", "prettier"], | ||
@@ -10,0 +10,0 @@ parser: "@typescript-eslint/parser", |
@@ -9,2 +9,7 @@ # Aptos TS SDK Changelog | ||
## 1.8.3 (2023-04-10) | ||
- Add `publish-ans-contract` script and pnpm command for tests | ||
- Revert User-Agent header from both `AptosClient` and `IndexerClient` due to a browser error | ||
## 1.8.2 (2023-04-06) | ||
@@ -11,0 +16,0 @@ |
@@ -26,3 +26,3 @@ { | ||
"test": "jest", | ||
"_fmt": "prettier 'src/**/*.ts' 'examples/**/*.js' 'examples/**/*.ts' '.eslintrc.js'", | ||
"_fmt": "prettier 'scripts/**/*.ts' 'src/**/*.ts' 'examples/**/*.js' 'examples/**/*.ts' '.eslintrc.js'", | ||
"fmt": "pnpm _fmt --write", | ||
@@ -34,3 +34,4 @@ "fmt:check": "pnpm _fmt --check", | ||
"generate-ts-docs": "scripts/generate_ts_docs.sh", | ||
"indexer-codegen": "graphql-codegen --config ./src/indexer/codegen.yml" | ||
"indexer-codegen": "graphql-codegen --config ./src/indexer/codegen.yml", | ||
"publish-ans-contract": "ts-node ./scripts/publish_ans_contract.ts" | ||
}, | ||
@@ -86,3 +87,3 @@ "repository": { | ||
}, | ||
"version": "1.8.2" | ||
"version": "1.8.3" | ||
} |
@@ -38,3 +38,2 @@ // Copyright © Aptos Foundation | ||
import { Ed25519PublicKey, MultiEd25519PublicKey } from "../aptos_types"; | ||
import { ProviderUtil } from "./utils"; | ||
@@ -90,4 +89,2 @@ export interface OptionalTransactionArgs { | ||
} | ||
conf.HEADERS = { ...conf.HEADERS, "User-Agent": ProviderUtil.getUserAgent() }; | ||
this.client = new Gen.AptosGeneratedClient(conf); | ||
@@ -94,0 +91,0 @@ } |
@@ -37,3 +37,2 @@ import axios from "axios"; | ||
} from "../indexer/generated/queries"; | ||
import { ProviderUtil } from "./utils"; | ||
@@ -53,6 +52,2 @@ /** | ||
const headers = { | ||
"User-Agent": ProviderUtil.getUserAgent(), | ||
}; | ||
type GraphqlQuery = { | ||
@@ -94,3 +89,3 @@ query: string; | ||
async queryIndexer<T>(graphqlQuery: GraphqlQuery): Promise<T> { | ||
const { data } = await axios.post(this.endpoint, graphqlQuery, { headers }); | ||
const { data } = await axios.post(this.endpoint, graphqlQuery); | ||
if (data.errors) { | ||
@@ -97,0 +92,0 @@ throw new Error(`Indexer data error ${JSON.stringify(data.errors, null, " ")}`); |
@@ -17,3 +17,2 @@ // Copyright © Aptos Foundation | ||
import { Ed25519PublicKey } from "../../aptos_types"; | ||
import { ProviderUtil } from "../../providers/utils"; | ||
@@ -33,9 +32,2 @@ const account = "0x1::account::Account"; | ||
test("call should include user-agent header", async () => { | ||
const client = new AptosClient(NODE_URL, { HEADERS: { my: "header" } }); | ||
const heders = client.client.request.config.HEADERS; | ||
expect(heders).toHaveProperty("User-Agent", ProviderUtil.getUserAgent()); | ||
expect(heders).toHaveProperty("my", "header"); | ||
}); | ||
test("gets genesis account", async () => { | ||
@@ -42,0 +34,0 @@ const client = new AptosClient(NODE_URL); |
@@ -9,4 +9,2 @@ import { AptosAccount } from "../../account/aptos_account"; | ||
import { Network, NetworkToIndexerAPI, NetworkToNodeAPI, sleep } from "../../utils"; | ||
import axios from "axios"; | ||
import { ProviderUtil } from "../../providers/utils"; | ||
@@ -197,18 +195,3 @@ const aptosClient = new AptosClient(NetworkToNodeAPI[Network.TESTNET]); | ||
}); | ||
test("make sure queryIndexer post call with correct User-Agent header", async () => { | ||
let mockHeaders: any = {}; | ||
// spy on axios.post and mock the response | ||
jest.spyOn(axios, "post").mockImplementation((url, query, config) => { | ||
mockHeaders["User-Agent"] = config?.headers?.["User-Agent"]; | ||
return Promise.resolve({ data: { data: {}, errors: null } }); | ||
}); | ||
// Call queryIndexer and expect it to make a request with the expected User-Agent header | ||
const expectedUserAgent = ProviderUtil.getUserAgent(); | ||
await indexerClient.queryIndexer({ query: "{ mockQuery }" }); | ||
expect(mockHeaders["User-Agent"]).toEqual(expectedUserAgent); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
3467560
39350