diff --git a/src/typescript/pnpm-lock.yaml b/src/typescript/pnpm-lock.yaml index b00fd6137..c5e9b9df3 100644 --- a/src/typescript/pnpm-lock.yaml +++ b/src/typescript/pnpm-lock.yaml @@ -265,6 +265,9 @@ importers: '@aptos-labs/ts-sdk': specifier: 1.27.1 version: 1.27.1 + '@econia-labs/emojicoin-sdk': + specifier: 0.3.0-rc.7 + version: 0.3.0-rc.7 '@keyvhq/core': specifier: ^2.1.1 version: 2.1.1 @@ -656,6 +659,10 @@ packages: resolution: {integrity: sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw==} engines: {node: '>=10.0.0'} + '@econia-labs/emojicoin-sdk@0.3.0-rc.7': + resolution: {integrity: sha512-OxRJah2I9Bnm7NfhQoq7xJAIxHjGdV0yGxTk6okLflcCN3YPrgNPH9AH5m2M3OIjG2k0beh+tq4vRkTMNMXdYQ==} + engines: {node: '>=v20.12.2'} + '@emnapi/runtime@1.3.0': resolution: {integrity: sha512-XMBySMuNZs3DM96xcJmLW4EfGnf+uGmFNjzpehMjuX5PLB5j87ar2Zc4e3PVeZ3I5g3tYtAqskB28manlF69Zw==} @@ -5877,6 +5884,22 @@ snapshots: '@discoveryjs/json-ext@0.5.7': {} + '@econia-labs/emojicoin-sdk@0.3.0-rc.7': + dependencies: + '@aptos-labs/ts-sdk': 1.27.1 + '@keyvhq/core': 2.1.1 + '@noble/hashes': 1.5.0 + '@supabase/postgrest-js': 1.16.2 + axios: 1.7.7 + big.js: 6.2.2 + emoji-regex: 10.3.0 + find-git-root: 1.0.4 + json-bigint: 1.0.0 + postgres: 3.4.4 + server-only: 0.0.1 + transitivePeerDependencies: + - debug + '@emnapi/runtime@1.3.0': dependencies: tslib: 2.7.0 diff --git a/src/typescript/sdk/.eslintrc.js b/src/typescript/sdk/.eslintrc.js index a5634d3e9..58255e74b 100644 --- a/src/typescript/sdk/.eslintrc.js +++ b/src/typescript/sdk/.eslintrc.js @@ -1,3 +1,5 @@ +// cspell:word tsup + module.exports = { env: { browser: true, diff --git a/src/typescript/sdk/package.json b/src/typescript/sdk/package.json index 78cd76019..fe8ecf371 100644 --- a/src/typescript/sdk/package.json +++ b/src/typescript/sdk/package.json @@ -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", @@ -57,7 +58,7 @@ "default": "./dist/esm/index.mjs" } }, - "./client": { + "./client": { "source": "./src/client/index.ts", "require": { "types": "./dist/common/client/index.d.ts", @@ -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", diff --git a/src/typescript/sdk/src/client/emojicoin-client.ts b/src/typescript/sdk/src/client/emojicoin-client.ts index a1f946ba5..b983689b2 100644 --- a/src/typescript/sdk/src/client/emojicoin-client.ts +++ b/src/typescript/sdk/src/client/emojicoin-client.ts @@ -154,6 +154,7 @@ export class EmojicoinClient { constructor(args?: { aptos?: Aptos; + aptosApiKey?: string; integrator?: AccountAddressInput; integratorFeeRateBPs?: bigint | number; minOutputAmount?: bigint | number; @@ -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); diff --git a/src/typescript/sdk/src/const.ts b/src/typescript/sdk/src/const.ts index 2cd07a3af..8a4a3db36 100644 --- a/src/typescript/sdk/src/const.ts +++ b/src/typescript/sdk/src/const.ts @@ -62,6 +62,8 @@ const serverKeys: Record = { 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 diff --git a/src/typescript/sdk/tsconfig.json b/src/typescript/sdk/tsconfig.json index 3f60935d9..6a2ac138b 100644 --- a/src/typescript/sdk/tsconfig.json +++ b/src/typescript/sdk/tsconfig.json @@ -9,7 +9,11 @@ "experimentalDecorators": true, "forceConsistentCasingInFileNames": true, "isolatedModules": true, - "lib": ["dom", "dom.iterable", "esnext"], + "lib": [ + "dom", + "dom.iterable", + "esnext" + ], "module": "esnext", "moduleDetection": "force", "moduleResolution": "bundler", @@ -17,8 +21,12 @@ "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, @@ -26,8 +34,16 @@ "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" + ] } diff --git a/src/typescript/sdk/tsup.config.ts b/src/typescript/sdk/tsup.config.ts index c75dd881e..6d8131106 100644 --- a/src/typescript/sdk/tsup.config.ts +++ b/src/typescript/sdk/tsup.config.ts @@ -1,3 +1,5 @@ +// cspell:word tsup + import { defineConfig } from "tsup"; import type { Options, Format } from "tsup";