@leather.io/sdk 1.1.5 → 1.2.0

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
@@ -22,4 +22,4 @@ interface LeatherClientConfig {
22
22
  }
23
23
  declare function createLeatherClient(clientConfig?: LeatherClientConfig): LeatherSdk;
24
24
 
25
- export { type ClientEndpointMap, createLeatherClient, isBrowser };
25
+ export { type ClientEndpointMap, type LeatherSdk, createLeatherClient, isBrowser };
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\ntype 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) return getProvider()?.request(endpoint.method, params);\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,OAAQ,QAAO,YAAY,GAAG,QAAQ,SAAS,QAAQ,MAAM;AACzF,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,"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) return getProvider()?.request(endpoint.method, params);\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,OAAQ,QAAO,YAAY,GAAG,QAAQ,SAAS,QAAQ,MAAM;AACzF,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":[]}
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.1.5",
5
+ "version": "1.2.0",
6
6
  "license": "MIT",
7
7
  "type": "module",
8
8
  "exports": {
@@ -11,8 +11,8 @@
11
11
  "dependencies": {
12
12
  "ts-expect": "1.3.0",
13
13
  "zod": "3.24.2",
14
- "@leather.io/models": "0.30.0",
15
- "@leather.io/rpc": "2.10.2"
14
+ "@leather.io/models": "0.31.0",
15
+ "@leather.io/rpc": "2.10.4"
16
16
  },
17
17
  "devDependencies": {
18
18
  "expect-type": "1.2.0",