Skip to content

Commit

Permalink
Cspell
Browse files Browse the repository at this point in the history
Add ability to specify API key for the emojicoin client

Update pnpm lock.yaml
  • Loading branch information
xbtmatt committed Jan 31, 2025
1 parent a6bab5e commit 707a3a4
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 11 deletions.
23 changes: 23 additions & 0 deletions src/typescript/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/typescript/sdk/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// cspell:word tsup

module.exports = {
env: {
browser: true,
Expand Down
5 changes: 3 additions & 2 deletions src/typescript/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"dependencies": {
"@aptos-labs/ts-sdk": "1.27.1",
"@econia-labs/emojicoin-sdk": "0.3.0-rc.7",
"@keyvhq/core": "^2.1.1",
"@noble/hashes": "^1.5.0",
"@supabase/postgrest-js": "^1.16.2",
Expand Down Expand Up @@ -57,7 +58,7 @@
"default": "./dist/esm/index.mjs"
}
},
"./client": {
"./client": {
"source": "./src/client/index.ts",
"require": {
"types": "./dist/common/client/index.d.ts",
Expand All @@ -68,7 +69,7 @@
"default": "./dist/esm/client/index.mjs"
}
},
"./indexer-v2": {
"./indexer-v2": {
"source": "./src/indexer-v2/index.ts",
"require": {
"types": "./dist/common/indexer-v2/index.d.ts",
Expand Down
18 changes: 15 additions & 3 deletions src/typescript/sdk/src/client/emojicoin-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ export class EmojicoinClient {

constructor(args?: {
aptos?: Aptos;
aptosApiKey?: string;
integrator?: AccountAddressInput;
integratorFeeRateBPs?: bigint | number;
minOutputAmount?: bigint | number;
Expand All @@ -165,13 +166,24 @@ export class EmojicoinClient {
integratorFeeRateBPs = 0,
minOutputAmount = 1n,
alwaysWaitForIndexer = false,
aptosApiKey,
} = args ?? {};
const clientConfig = {
...aptos.config.clientConfig,
// If the Aptos API key is passed in, use it, otherwise, use the default one set by
// environment variables.
...(aptosApiKey
? {
API_KEY: aptosApiKey,
}
: APTOS_CONFIG),
};
// Create a client that always uses the static API_KEY config options.
const hardCodedConfig = new AptosConfig({
const aptosConfig = new AptosConfig({
...aptos.config,
clientConfig: { ...aptos.config.clientConfig, ...APTOS_CONFIG },
clientConfig,
});
this.aptos = new Aptos(hardCodedConfig);
this.aptos = new Aptos(aptosConfig);
this.integrator = AccountAddress.from(integrator);
this.integratorFeeRateBPs = Number(integratorFeeRateBPs);
this.minOutputAmount = BigInt(minOutputAmount);
Expand Down
2 changes: 2 additions & 0 deletions src/typescript/sdk/src/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ const serverKeys: Record<Network, string | undefined> = {
const clientApiKey = clientKeys[APTOS_NETWORK];
const serverApiKey = serverKeys[APTOS_NETWORK];

// If the server api key is available, use it. If it's not available, that means the runtime
// is in a client-side context, and it should use the API key for client-side queries.
export const getAptosApiKey = () => serverApiKey ?? clientApiKey;

// Select the API key from the list of env API keys. This means we don't have to change the env
Expand Down
28 changes: 22 additions & 6 deletions src/typescript/sdk/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,41 @@
"experimentalDecorators": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"lib": ["dom", "dom.iterable", "esnext"],
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"module": "esnext",
"moduleDetection": "force",
"moduleResolution": "bundler",
"noEmit": true,
"noImplicitAny": true,
"noImplicitThis": true,
"paths": {
"@/contract-apis": ["./src/emojicoin_dot_fun/contract-apis"],
"@/contract-apis/*": ["./src/emojicoin_dot_fun/contract-apis/*"]
"@/contract-apis": [
"./src/emojicoin_dot_fun/contract-apis"
],
"@/contract-apis/*": [
"./src/emojicoin_dot_fun/contract-apis/*"
]
},
"preserveWatchOutput": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"target": "esnext",
"types": ["node", "jest"]
"types": [
"node",
"jest"
]
},
"exclude": ["node_modules"],
"include": ["src", "tsup.config.ts"]
"exclude": [
"node_modules"
],
"include": [
"src",
"tsup.config.ts"
]
}
2 changes: 2 additions & 0 deletions src/typescript/sdk/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// cspell:word tsup

import { defineConfig } from "tsup";
import type { Options, Format } from "tsup";

Expand Down

0 comments on commit 707a3a4

Please sign in to comment.