@leather.io/sdk 1.5.26 → 1.5.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,25 +1,23 @@
1
- import { Prettify } from '@leather.io/models';
2
- import { endpoints, RpcEndpointMap, ExtractSuccessResponse, LeatherProvider } from '@leather.io/rpc';
1
+ import { ExtractSuccessResponse, LeatherProvider, RpcEndpointMap, endpoints } from "@leather.io/rpc";
2
+ import { Prettify } from "@leather.io/models";
3
3
 
4
+ //#region src/client.d.ts
4
5
  declare function isBrowser(): boolean;
5
6
  type Endpoints = typeof endpoints;
6
- type ClientEndpointMap = Prettify<{
7
- [E in keyof Endpoints]: {
8
- request: RpcEndpointMap[Endpoints[E]['method']]['request'];
9
- response: RpcEndpointMap[Endpoints[E]['method']]['response'];
10
- result: ExtractSuccessResponse<RpcEndpointMap[Endpoints[E]['method']]['response']>['result'];
11
- };
12
- }>;
13
- type ExtractResult<Method extends keyof ClientEndpointMap> = ClientEndpointMap[Method]['result'];
14
- type LeatherSdk = {
15
- [Method in keyof ClientEndpointMap]: ClientEndpointMap[Method]['request'] extends {
16
- params?: infer P;
17
- } ? object extends P ? (params?: P) => Promise<ExtractResult<Method>> : (params: P) => Promise<ExtractResult<Method>> : () => Promise<ExtractResult<Method>>;
18
- };
7
+ type ClientEndpointMap = Prettify<{ [E in keyof Endpoints]: {
8
+ request: RpcEndpointMap[Endpoints[E]['method']]['request'];
9
+ response: RpcEndpointMap[Endpoints[E]['method']]['response'];
10
+ result: ExtractSuccessResponse<RpcEndpointMap[Endpoints[E]['method']]['response']>['result'];
11
+ } }>;
12
+ type ExtractResult<Method$1 extends keyof ClientEndpointMap> = ClientEndpointMap[Method$1]['result'];
13
+ type LeatherSdk = { [Method in keyof ClientEndpointMap]: ClientEndpointMap[Method]['request'] extends {
14
+ params?: infer P;
15
+ } ? object extends P ? (params?: P) => Promise<ExtractResult<Method>> : (params: P) => Promise<ExtractResult<Method>> : () => Promise<ExtractResult<Method>> };
19
16
  interface LeatherClientConfig {
20
- getProvider?(): LeatherProvider | undefined;
21
- onProviderNotFound?(): void;
17
+ getProvider?(): LeatherProvider | undefined;
18
+ onProviderNotFound?(): void;
22
19
  }
23
20
  declare function createLeatherClient(clientConfig?: LeatherClientConfig): LeatherSdk;
24
-
25
- export { type ClientEndpointMap, type LeatherSdk, createLeatherClient, isBrowser };
21
+ //#endregion
22
+ export { ClientEndpointMap, LeatherSdk, createLeatherClient, isBrowser };
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/client.ts"],"sourcesContent":[],"mappings":";;;;iBAQgB,SAAA,CAAA;KAOX,SAAA,UAAmB;AAPR,KAWJ,iBAAA,GAAoB,QAXP,CAAA,QAOpB,MAKS,SALA,GAAU;EAIZ,OAAA,EAEC,cAFgB,CAED,SAFC,CAES,CAFT,CAAA,CAAA,QAAA,CAAA,CAAA,CAAA,SAAA,CAAA;EACf,QAAA,EAEA,cAFA,CAEe,SAFf,CAEyB,CAFzB,CAAA,CAAA,QAAA,CAAA,CAAA,CAAA,UAAA,CAAA;EACD,MAAA,EAED,sBAFC,CAEsB,cAFtB,CAEqC,SAFrC,CAE+C,CAF/C,CAAA,CAAA,QAAA,CAAA,CAAA,CAAA,UAAA,CAAA,CAAA,CAAA,QAAA,CAAA;AAAe,CAAA,EAAU,CAAA;KAMjC,aALS,CAAA,iBAAA,MAK0B,iBAL1B,CAAA,GAK+C,iBAL/C,CAKiE,QALjE,CAAA,CAAA,QAAA,CAAA;AAAe,KAOjB,UAAA,GAPiB,aAAU,MAQpB,iBARoB,GAQA,iBARA,CAQkB,MARlB,CAAA,CAAA,SAAA,CAAA,SAAA;EACJ,MAAA,CAAA,EAAA,KAAA,EAAA;AAAe,CAAA,GAAA,MAAA,SAU7B,CAV6B,GAAA,CAAA,MAAA,CAAA,EAWhC,CAXgC,EAAA,GAW1B,OAX0B,CAWlB,aAXkB,CAWJ,MAXI,CAAA,CAAA,GAAA,CAAA,MAAA,EAYjC,CAZiC,EAAA,GAY3B,OAZ2B,CAYnB,aAZmB,CAYL,MAZK,CAAA,CAAA,GAAA,GAAA,GAatC,OAbsC,CAa9B,aAb8B,CAahB,MAbgB,CAAA,CAAA,EAAU;UAgBlD,mBAAA,CAhBE;EAJoB,WAAA,GAAA,EAqBd,eArBc,GAAA,SAAA;EAAQ,kBAAA,GAAA,EAAA,IAAA;AAMrC;AAEqC,iBA0BxB,mBAAA,CA1BwB,YAAA,CAAA,EA0BW,mBA1BX,CAAA,EA0B8B,UA1B9B"}
package/dist/index.js CHANGED
@@ -1,39 +1,33 @@
1
- // src/client.ts
2
- import {
3
- endpoints
4
- } from "@leather.io/rpc";
1
+ import { endpoints } from "@leather.io/rpc";
2
+
3
+ //#region src/client.ts
5
4
  function isBrowser() {
6
- return typeof window !== "undefined" && typeof window.document !== "undefined";
5
+ return typeof window !== "undefined" && typeof window.document !== "undefined";
7
6
  }
8
- var endpointEntries = Object.entries(endpoints);
9
- var defaultOptions = {
10
- getProvider() {
11
- return globalThis.LeatherProvider;
12
- },
13
- onProviderNotFound() {
14
- if (isBrowser()) console.log("Provider not found");
15
- }
7
+ const endpointEntries = Object.entries(endpoints);
8
+ const defaultOptions = {
9
+ getProvider() {
10
+ return globalThis.LeatherProvider;
11
+ },
12
+ onProviderNotFound() {
13
+ if (isBrowser()) console.log("Provider not found");
14
+ }
16
15
  };
17
16
  function createLeatherClient(clientConfig) {
18
- const { getProvider, onProviderNotFound } = { ...defaultOptions, ...clientConfig };
19
- if (isBrowser() && !getProvider()) {
20
- onProviderNotFound();
21
- }
22
- const actionMap = endpointEntries.reduce(
23
- (client, [fnName, endpoint]) => ({
24
- ...client,
25
- async [fnName](params) {
26
- if ("params" in endpoint && params)
27
- return getProvider()?.request(endpoint.method, params).then(({ result }) => result);
28
- return getProvider()?.request(endpoint.method).then(({ result }) => result);
29
- }
30
- }),
31
- {}
32
- );
33
- return actionMap;
17
+ const { getProvider, onProviderNotFound } = {
18
+ ...defaultOptions,
19
+ ...clientConfig
20
+ };
21
+ if (isBrowser() && !getProvider()) onProviderNotFound();
22
+ return endpointEntries.reduce((client, [fnName, endpoint]) => ({
23
+ ...client,
24
+ async [fnName](params) {
25
+ if ("params" in endpoint && params) return getProvider()?.request(endpoint.method, params).then(({ result }) => result);
26
+ return getProvider()?.request(endpoint.method).then(({ result }) => result);
27
+ }
28
+ }), {});
34
29
  }
35
- export {
36
- createLeatherClient,
37
- isBrowser
38
- };
30
+
31
+ //#endregion
32
+ export { createLeatherClient, isBrowser };
39
33
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/client.ts"],"sourcesContent":["import { Prettify } from '@leather.io/models';\nimport {\n ExtractSuccessResponse,\n LeatherProvider,\n RpcEndpointMap,\n endpoints,\n} from '@leather.io/rpc';\n\nexport function isBrowser() {\n return typeof window !== 'undefined' && typeof window.document !== 'undefined';\n}\n\ntype Entries<T, K extends keyof T = keyof T> = (K extends unknown ? [K, T[K]] : never)[];\nconst endpointEntries = Object.entries(endpoints) as Entries<typeof endpoints>;\n\ntype Endpoints = typeof endpoints;\n\n// Keyed by friendly function name, not exact RPC method string\n// stxSignMessage not stx_signMessage\nexport type ClientEndpointMap = Prettify<{\n [E in keyof Endpoints]: {\n request: RpcEndpointMap[Endpoints[E]['method']]['request'];\n response: RpcEndpointMap[Endpoints[E]['method']]['response'];\n result: ExtractSuccessResponse<RpcEndpointMap[Endpoints[E]['method']]['response']>['result'];\n };\n}>;\n\ntype ExtractResult<Method extends keyof ClientEndpointMap> = ClientEndpointMap[Method]['result'];\n\nexport type LeatherSdk = {\n [Method in keyof ClientEndpointMap]: ClientEndpointMap[Method]['request'] extends {\n params?: infer P;\n }\n ? object extends P\n ? (params?: P) => Promise<ExtractResult<Method>>\n : (params: P) => Promise<ExtractResult<Method>>\n : () => Promise<ExtractResult<Method>>;\n};\n\ninterface LeatherClientConfig {\n getProvider?(): LeatherProvider | undefined;\n onProviderNotFound?(): void;\n}\nconst defaultOptions = {\n getProvider() {\n return (globalThis as any).LeatherProvider as LeatherProvider;\n },\n onProviderNotFound() {\n // eslint-disable-next-line no-console\n if (isBrowser()) console.log('Provider not found');\n },\n} satisfies LeatherClientConfig;\n\nexport function createLeatherClient(clientConfig?: LeatherClientConfig) {\n const { getProvider, onProviderNotFound } = { ...defaultOptions, ...clientConfig };\n\n if (isBrowser() && !getProvider()) {\n onProviderNotFound();\n }\n\n const actionMap = endpointEntries.reduce(\n (client, [fnName, endpoint]) => ({\n ...client,\n async [fnName](params?: object) {\n if ('params' in endpoint && params)\n return getProvider()\n ?.request(endpoint.method, params)\n .then(({ result }) => result);\n return getProvider()\n ?.request(endpoint.method)\n .then(({ result }) => result);\n },\n }),\n {}\n ) as LeatherSdk;\n\n return actionMap;\n}\n"],"mappings":";AACA;AAAA,EAIE;AAAA,OACK;AAEA,SAAS,YAAY;AAC1B,SAAO,OAAO,WAAW,eAAe,OAAO,OAAO,aAAa;AACrE;AAGA,IAAM,kBAAkB,OAAO,QAAQ,SAAS;AA8BhD,IAAM,iBAAiB;AAAA,EACrB,cAAc;AACZ,WAAQ,WAAmB;AAAA,EAC7B;AAAA,EACA,qBAAqB;AAEnB,QAAI,UAAU,EAAG,SAAQ,IAAI,oBAAoB;AAAA,EACnD;AACF;AAEO,SAAS,oBAAoB,cAAoC;AACtE,QAAM,EAAE,aAAa,mBAAmB,IAAI,EAAE,GAAG,gBAAgB,GAAG,aAAa;AAEjF,MAAI,UAAU,KAAK,CAAC,YAAY,GAAG;AACjC,uBAAmB;AAAA,EACrB;AAEA,QAAM,YAAY,gBAAgB;AAAA,IAChC,CAAC,QAAQ,CAAC,QAAQ,QAAQ,OAAO;AAAA,MAC/B,GAAG;AAAA,MACH,OAAO,MAAM,EAAE,QAAiB;AAC9B,YAAI,YAAY,YAAY;AAC1B,iBAAO,YAAY,GACf,QAAQ,SAAS,QAAQ,MAAM,EAChC,KAAK,CAAC,EAAE,OAAO,MAAM,MAAM;AAChC,eAAO,YAAY,GACf,QAAQ,SAAS,MAAM,EACxB,KAAK,CAAC,EAAE,OAAO,MAAM,MAAM;AAAA,MAChC;AAAA,IACF;AAAA,IACA,CAAC;AAAA,EACH;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/client.ts"],"sourcesContent":["import { Prettify } from '@leather.io/models';\nimport {\n ExtractSuccessResponse,\n LeatherProvider,\n RpcEndpointMap,\n endpoints,\n} from '@leather.io/rpc';\n\nexport function isBrowser() {\n return typeof window !== 'undefined' && typeof window.document !== 'undefined';\n}\n\ntype Entries<T, K extends keyof T = keyof T> = (K extends unknown ? [K, T[K]] : never)[];\nconst endpointEntries = Object.entries(endpoints) as Entries<typeof endpoints>;\n\ntype Endpoints = typeof endpoints;\n\n// Keyed by friendly function name, not exact RPC method string\n// stxSignMessage not stx_signMessage\nexport type ClientEndpointMap = Prettify<{\n [E in keyof Endpoints]: {\n request: RpcEndpointMap[Endpoints[E]['method']]['request'];\n response: RpcEndpointMap[Endpoints[E]['method']]['response'];\n result: ExtractSuccessResponse<RpcEndpointMap[Endpoints[E]['method']]['response']>['result'];\n };\n}>;\n\ntype ExtractResult<Method extends keyof ClientEndpointMap> = ClientEndpointMap[Method]['result'];\n\nexport type LeatherSdk = {\n [Method in keyof ClientEndpointMap]: ClientEndpointMap[Method]['request'] extends {\n params?: infer P;\n }\n ? object extends P\n ? (params?: P) => Promise<ExtractResult<Method>>\n : (params: P) => Promise<ExtractResult<Method>>\n : () => Promise<ExtractResult<Method>>;\n};\n\ninterface LeatherClientConfig {\n getProvider?(): LeatherProvider | undefined;\n onProviderNotFound?(): void;\n}\nconst defaultOptions = {\n getProvider() {\n return (globalThis as any).LeatherProvider as LeatherProvider;\n },\n onProviderNotFound() {\n // eslint-disable-next-line no-console\n if (isBrowser()) console.log('Provider not found');\n },\n} satisfies LeatherClientConfig;\n\nexport function createLeatherClient(clientConfig?: LeatherClientConfig) {\n const { getProvider, onProviderNotFound } = { ...defaultOptions, ...clientConfig };\n\n if (isBrowser() && !getProvider()) {\n onProviderNotFound();\n }\n\n const actionMap = endpointEntries.reduce(\n (client, [fnName, endpoint]) => ({\n ...client,\n async [fnName](params?: object) {\n if ('params' in endpoint && params)\n return getProvider()\n ?.request(endpoint.method, params)\n .then(({ result }) => result);\n return getProvider()\n ?.request(endpoint.method)\n .then(({ result }) => result);\n },\n }),\n {}\n ) as LeatherSdk;\n\n return actionMap;\n}\n"],"mappings":";;;AAQA,SAAgB,YAAY;AAC1B,QAAO,OAAO,WAAW,eAAe,OAAO,OAAO,aAAa;;AAIrE,MAAM,kBAAkB,OAAO,QAAQ,UAAU;AA8BjD,MAAM,iBAAiB;CACrB,cAAc;AACZ,SAAQ,WAAmB;;CAE7B,qBAAqB;AAEnB,MAAI,WAAW,CAAE,SAAQ,IAAI,qBAAqB;;CAErD;AAED,SAAgB,oBAAoB,cAAoC;CACtE,MAAM,EAAE,aAAa,uBAAuB;EAAE,GAAG;EAAgB,GAAG;EAAc;AAElF,KAAI,WAAW,IAAI,CAAC,aAAa,CAC/B,qBAAoB;AAmBtB,QAhBkB,gBAAgB,QAC/B,QAAQ,CAAC,QAAQ,eAAe;EAC/B,GAAG;EACH,OAAO,QAAQ,QAAiB;AAC9B,OAAI,YAAY,YAAY,OAC1B,QAAO,aAAa,EAChB,QAAQ,SAAS,QAAQ,OAAO,CACjC,MAAM,EAAE,aAAa,OAAO;AACjC,UAAO,aAAa,EAChB,QAAQ,SAAS,OAAO,CACzB,MAAM,EAAE,aAAa,OAAO;;EAElC,GACD,EAAE,CACH"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@leather.io/sdk",
3
3
  "author": "leather.io",
4
4
  "description": "Leather SDK",
5
- "version": "1.5.26",
5
+ "version": "1.5.28",
6
6
  "license": "MIT",
7
7
  "type": "module",
8
8
  "exports": {
@@ -11,23 +11,29 @@
11
11
  "dependencies": {
12
12
  "ts-expect": "1.3.0",
13
13
  "zod": "4.0.17",
14
- "@leather.io/models": "0.49.0",
15
- "@leather.io/rpc": "2.21.0"
14
+ "@leather.io/models": "0.50.1",
15
+ "@leather.io/rpc": "2.21.2"
16
16
  },
17
17
  "devDependencies": {
18
18
  "expect-type": "1.2.0",
19
- "tsup": "8.4.0",
20
- "vitest": "2.1.9"
19
+ "prettier": "3.5.1",
20
+ "tsdown": "0.16.5",
21
+ "vitest": "2.1.9",
22
+ "@leather.io/prettier-config": "0.9.0",
23
+ "@leather.io/test-config": "0.1.1"
21
24
  },
22
25
  "files": [
23
26
  "dist"
24
27
  ],
28
+ "prettier": "@leather.io/prettier-config",
25
29
  "publishConfig": {
26
30
  "access": "public"
27
31
  },
28
32
  "scripts": {
29
- "build": "tsup",
30
- "build:watch": "tsup --watch --onSuccess 'tsup --dts-only'",
33
+ "build": "tsdown",
34
+ "build:watch": "tsdown --watch",
35
+ "format": "prettier . --write --ignore-path ../../.prettierignore",
36
+ "format:check": "prettier . --check --ignore-path ../../.prettierignore",
31
37
  "prepublish": "pnpm build",
32
38
  "test": "vitest run",
33
39
  "test:coverage": "vitest run --coverage",