@luno-kit/react 0.0.7 → 0.0.8

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@luno-kit/react",
3
3
  "description": "React Hooks and Provider for Luno, enabling easy Polkadot wallet interactions in React applications.",
4
- "version": "0.0.7",
4
+ "version": "0.0.8",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -48,10 +48,10 @@
48
48
  "!dist/**/*.test.d.ts"
49
49
  ],
50
50
  "dependencies": {
51
- "@dedot/chaintypes": "0.123.0",
52
- "dedot": "0.14.1",
51
+ "@dedot/chaintypes": "0.152.0",
52
+ "dedot": "0.16.0",
53
53
  "zustand": "5.0.4",
54
- "@luno-kit/core": "0.0.7"
54
+ "@luno-kit/core": "0.0.8"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@tanstack/react-query": "5.81.5",
@@ -59,11 +59,10 @@
59
59
  "@testing-library/jest-dom": "^6.6.3",
60
60
  "@testing-library/react": "^16.3.0",
61
61
  "@testing-library/user-event": "^14.6.1",
62
- "@types/node": "^18.11.18",
62
+ "@types/node": "20.19.0",
63
63
  "@types/react": "18.2.55",
64
64
  "@types/react-dom": "18.2.19",
65
65
  "@vitest/coverage-v8": "^3.2.4",
66
- "eslint": "^8.56.0",
67
66
  "jsdom": "^26.1.0",
68
67
  "react": "18.2.0",
69
68
  "react-dom": "18.2.0",
@@ -72,9 +71,9 @@
72
71
  "vitest": "^3.2.4"
73
72
  },
74
73
  "peerDependencies": {
75
- "@dedot/chaintypes": "^0.123.0",
74
+ "@dedot/chaintypes": "^0.152.0",
76
75
  "@tanstack/react-query": ">=5.0.0",
77
- "dedot": "^0.13.2",
76
+ "dedot": "^0.16.0",
78
77
  "react": ">=18.0.0",
79
78
  "react-dom": ">=18.0.0"
80
79
  },
@@ -86,7 +85,6 @@
86
85
  "scripts": {
87
86
  "build": "tsup",
88
87
  "dev": "tsup --watch",
89
- "lint": "eslint src",
90
88
  "test": "vitest",
91
89
  "test:coverage": "vitest run --coverage",
92
90
  "clean": "rm -rf dist"
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/createApi.ts","../src/utils/dispatchError.ts","../src/utils/sleep.ts"],"names":["createApi","config","chainId","chainConfig","c","transportConfig","apiOptions","wsProvider","newApi","LegacyClient","actualGenesisHash","error","getReadableDispatchError","api","dispatchError","errorMeta","docs","name","pallet","fields","fieldCodecs","e","index","sleep","ms","resolve"],"mappings":"6GASO,IAAMA,CAAAA,CAAY,MAAO,CAC9B,MAAA,CAAAC,CAAAA,CACA,OAAA,CAAAC,CACF,CAAA,GAA+C,CAC7C,IAAMC,CAAAA,CAAcF,CAAAA,CAAO,MAAA,CAAO,IAAA,CAAKG,GAAKA,CAAAA,CAAE,WAAA,GAAgBF,CAAO,CAAA,CAC/DG,CAAAA,CAAkBJ,CAAAA,CAAO,UAAA,CAAWC,CAAO,CAAA,CAEjD,GAAI,CAACC,CAAAA,EAAe,CAACE,CAAAA,CACnB,MAAM,IAAI,MAAM,CAAA,mCAAA,EAAsCH,CAAO,CAAA,CAAE,CAAA,CAKjE,IAAMI,CAAAA,CAAyB,CAC7B,QAAA,CAHeC,eAAAA,CAAWF,CAAe,CAAA,CAIzC,aAAA,CAAeJ,CAAAA,CAAO,aAAA,CACtB,QAAA,CAAUA,CAAAA,CAAO,SACjB,eAAA,CAAiB,CACf,GAAGA,CAAAA,CAAO,eAAA,CACV,GAAGA,CAAAA,CAAO,WACZ,CAAA,CACA,WAAA,CAAaA,CAAAA,CAAO,WAAA,CACpB,YAAA,CAAcA,CAAAA,CAAO,YACvB,CAAA,CAEMO,EAAS,IAAIC,kBAAAA,CAAaH,CAAU,CAAA,CAE1C,GAAI,CACF,MAAME,CAAAA,CAAO,OAAA,EAAQ,CAErB,IAAME,CAAAA,CAAoB,MAAMF,CAAAA,CAAO,GAAA,CAAI,kBAAA,CAA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AAA,EAAyBU,CAAAA,YAAa,KAAA,CAAQA,CAAAA,CAAE,OAAA,CAAU,eAAe,CAAA,CACtJ,SACSP,CAAAA,CAAc,IAAA,GAAS,OAAA,CAChC,OAAO,CAAA,mCAAA,EAAsCA,CAAAA,CAAc,KAAK,CAAA,CAAA,CAGlE,OAAI,OAAA,GAAWA,CAAAA,CACN,CAAA,sBAAA,EAAyBA,CAAAA,CAAc,IAAI,CAAA,QAAA,EAAWA,CAAAA,CAAc,KAAK,CAAA,CAAA,CAG3E,CAAA,6BAAA,EAAgCA,CAAAA,CAAc,IAAI,CAAA,CAC3D,CC3BO,IAAMS,CAAAA,CAAQ,CAACC,CAAAA,CAAK,GAAA,GAClB,IAAI,OAAA,CAAQC,CAAAA,EAAW,UAAA,CAAWA,CAAAA,CAASD,CAAE,CAAC","file":"chunk-74FF3SAT.cjs","sourcesContent":["import { wsProvider } from '@luno-kit/core'\nimport type { Config } from '../types'\nimport { ApiOptions, LegacyClient } from 'dedot'\n\ninterface CreateApiOptions {\n config: Config;\n chainId: string;\n}\n\nexport const createApi = async ({\n config,\n chainId,\n}: CreateApiOptions): Promise<LegacyClient> => {\n const chainConfig = config.chains.find(c => c.genesisHash === chainId);\n const transportConfig = config.transports[chainId];\n\n if (!chainConfig || !transportConfig) {\n throw new Error(`Configuration missing for chainId: ${chainId}`);\n }\n\n const provider = wsProvider(transportConfig);\n\n const apiOptions: ApiOptions = {\n provider,\n cacheMetadata: config.cacheMetadata,\n metadata: config.metadata,\n scaledResponses: {\n ...config.scaledResponses,\n ...config.customTypes,\n },\n runtimeApis: config.runtimeApis,\n cacheStorage: config.cacheStorage,\n };\n\n const newApi = new LegacyClient(apiOptions);\n\n try {\n await newApi.connect();\n\n const actualGenesisHash = await newApi.rpc.chain_getBlockHash(0);\n\n if (actualGenesisHash !== chainId) {\n await newApi.disconnect();\n throw new Error(\n `Chain genesis hash mismatch. Expected: ${chainId}, Got: ${actualGenesisHash}. ` +\n 'This might indicate connecting to the wrong network or incorrect chain configuration.'\n );\n }\n\n return newApi;\n } catch (error: any) {\n throw new Error(`Failed to connect to ${chainConfig.name}: ${error?.message || error}`);\n }\n};\n","import type { DispatchError } from 'dedot/codecs'\nimport type { LegacyClient } from 'dedot'\n\nexport function getReadableDispatchError(api: LegacyClient, dispatchError: DispatchError): string {\n if (dispatchError.type === 'Module') {\n try {\n const errorMeta = api.registry.findErrorMeta(dispatchError);\n if (errorMeta) {\n const { docs, name, pallet, fields, fieldCodecs } = errorMeta;\n return `[useSendTransaction]: ${pallet}.${name} error, ${docs.join(' ')}`;\n }\n\n return `[useSendTransaction]: Module Error (index: ${dispatchError.value.index}, error: ${dispatchError.value.error})`;\n } catch (e) {\n const { value: { error, index } } = dispatchError;\n\n return `[useSendTransaction]: Module Error (index: ${index}, error: ${error}) - Failed to decode: ${e instanceof Error ? e.message : 'Unknown error'}`;\n }\n } else if (dispatchError.type === 'Token') {\n return `[useSendTransaction]: Token Error: ${dispatchError.value}`;\n }\n\n if ('value' in dispatchError) {\n return `[useSendTransaction]: ${dispatchError.type} Error: ${dispatchError.value}`;\n }\n\n return `[useSendTransaction]: Error: ${dispatchError.type}`;\n}\n","export const sleep = (ms = 1000): Promise<void> => {\n return new Promise(resolve => setTimeout(resolve, ms));\n};\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/createApi.ts","../src/utils/dispatchError.ts","../src/utils/sleep.ts"],"names":["createApi","config","chainId","chainConfig","c","transportConfig","apiOptions","wsProvider","newApi","LegacyClient","actualGenesisHash","error","getReadableDispatchError","api","dispatchError","errorMeta","docs","name","pallet","fields","fieldCodecs","e","index","sleep","ms","resolve"],"mappings":"qUASO,IAAMA,CAAAA,CAAY,MAAO,CAC9B,MAAA,CAAAC,CAAAA,CACA,OAAA,CAAAC,CACF,CAAA,GAA+C,CAC7C,IAAMC,CAAAA,CAAcF,CAAAA,CAAO,MAAA,CAAO,IAAA,CAAKG,GAAKA,CAAAA,CAAE,WAAA,GAAgBF,CAAO,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core'\nimport type { Config } from '../types'\nimport { ApiOptions, LegacyClient } from 'dedot'\n\ninterface CreateApiOptions {\n config: Config;\n chainId: string;\n}\n\nexport const createApi = async ({\n config,\n chainId,\n}: CreateApiOptions): Promise<LegacyClient> => {\n const chainConfig = config.chains.find(c => c.genesisHash === chainId);\n const transportConfig = config.transports[chainId];\n\n if (!chainConfig || !transportConfig) {\n throw new Error(`Configuration missing for chainId: ${chainId}`);\n }\n\n const provider = wsProvider(transportConfig);\n\n const apiOptions: ApiOptions = {\n provider,\n cacheMetadata: config.cacheMetadata,\n metadata: config.metadata,\n scaledResponses: {\n ...config.scaledResponses,\n ...config.customTypes,\n },\n runtimeApis: config.runtimeApis,\n cacheStorage: config.cacheStorage,\n };\n\n const newApi = new LegacyClient(apiOptions);\n\n try {\n await newApi.connect();\n\n const actualGenesisHash = await newApi.rpc.chain_getBlockHash(0);\n\n if (actualGenesisHash !== chainId) {\n await newApi.disconnect();\n throw new Error(\n `Chain genesis hash mismatch. Expected: ${chainId}, Got: ${actualGenesisHash}. ` +\n 'This might indicate connecting to the wrong network or incorrect chain configuration.'\n );\n }\n\n return newApi;\n } catch (error: any) {\n throw new Error(`Failed to connect to ${chainConfig.name}: ${error?.message || error}`);\n }\n};\n","import type { DispatchError } from 'dedot/codecs'\nimport type { LegacyClient } from 'dedot'\n\nexport function getReadableDispatchError(api: LegacyClient, dispatchError: DispatchError): string {\n if (dispatchError.type === 'Module') {\n try {\n const errorMeta = api.registry.findErrorMeta(dispatchError);\n if (errorMeta) {\n const { docs, name, pallet, fields, fieldCodecs } = errorMeta;\n return `[useSendTransaction]: ${pallet}.${name} error, ${docs.join(' ')}`;\n }\n\n return `[useSendTransaction]: Module Error (index: ${dispatchError.value.index}, error: ${dispatchError.value.error})`;\n } catch (e) {\n const { value: { error, index } } = dispatchError;\n\n return `[useSendTransaction]: Module Error (index: ${index}, error: ${error}) - Failed to decode: ${e instanceof Error ? e.message : 'Unknown error'}`;\n }\n } else if (dispatchError.type === 'Token') {\n return `[useSendTransaction]: Token Error: ${dispatchError.value}`;\n }\n\n if ('value' in dispatchError) {\n return `[useSendTransaction]: ${dispatchError.type} Error: ${dispatchError.value}`;\n }\n\n return `[useSendTransaction]: Error: ${dispatchError.type}`;\n}\n","export const sleep = (ms = 1000): Promise<void> => {\n return new Promise(resolve => setTimeout(resolve, ms));\n};\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/types/state.ts"],"names":["ConnectionStatus"],"mappings":"uDAIO,IAAKA,CAAAA,CAAAA,CAAAA,CAAAA,GACVA,CAAAA,CAAA,aAAe,cAAA,CACfA,CAAAA,CAAA,UAAA,CAAa,YAAA,CACbA,EAAA,aAAA,CAAgB,eAAA,CAChBA,CAAAA,CAAA,SAAA,CAAY,YAJFA,CAAAA,CAAAA,EAAAA,CAAAA,EAAA,EAAA","file":"chunk-FF2XK2NN.cjs","sourcesContent":["import type { Config, Connector, Account, Chain } from '.';\nimport type { LegacyClient } from 'dedot';\nimport type { HexString } from 'dedot/utils'\n\nexport enum ConnectionStatus {\n Disconnected = 'disconnected',\n Connecting = 'connecting',\n Disconnecting = 'disconnecting',\n Connected = 'connected',\n}\n\nexport interface LunoState {\n config?: Config;\n\n\n status: ConnectionStatus;\n\n activeConnector?: Connector;\n\n accounts: Account[];\n account?: Account;\n setAccount: (accountOrPubkey?: Account | HexString) => Promise<void>;\n\n currentChainId?: string;\n currentChain?: Chain;\n currentApi?: LegacyClient;\n isApiReady: boolean;\n apiError: Error | null\n\n _setConfig: (config: Config) => Promise<void>;\n\n connect: (connectorId: string, targetChainId?: string) => Promise<void>;\n disconnect: () => Promise<void>;\n\n switchChain: (newChainId: string) => Promise<void>;\n\n _setApi: (api?: LegacyClient) => void;\n\n _setIsApiReady: (isApiReady: boolean) => void;\n _setApiError: (error: Error | null) => void\n\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/types/state.ts"],"names":["ConnectionStatus"],"mappings":"kCAIO,IAAKA,CAAAA,CAAAA,CAAAA,CAAAA,GACVA,CAAAA,CAAA,aAAe,cAAA,CACfA,CAAAA,CAAA,UAAA,CAAa,YAAA,CACbA,EAAA,aAAA,CAAgB,eAAA,CAChBA,CAAAA,CAAA,SAAA,CAAY,YAJFA,CAAAA,CAAAA,EAAAA,CAAAA,EAAA,EAAA","file":"chunk-PCTHAGIZ.js","sourcesContent":["import type { Config, Connector, Account, Chain } from '.';\nimport type { LegacyClient } from 'dedot';\nimport type { HexString } from 'dedot/utils'\n\nexport enum ConnectionStatus {\n Disconnected = 'disconnected',\n Connecting = 'connecting',\n Disconnecting = 'disconnecting',\n Connected = 'connected',\n}\n\nexport interface LunoState {\n config?: Config;\n\n\n status: ConnectionStatus;\n\n activeConnector?: Connector;\n\n accounts: Account[];\n account?: Account;\n setAccount: (accountOrPubkey?: Account | HexString) => Promise<void>;\n\n currentChainId?: string;\n currentChain?: Chain;\n currentApi?: LegacyClient;\n isApiReady: boolean;\n apiError: Error | null\n\n _setConfig: (config: Config) => Promise<void>;\n\n connect: (connectorId: string, targetChainId?: string) => Promise<void>;\n disconnect: () => Promise<void>;\n\n switchChain: (newChainId: string) => Promise<void>;\n\n _setApi: (api?: LegacyClient) => void;\n\n _setIsApiReady: (isApiReady: boolean) => void;\n _setApiError: (error: Error | null) => void\n\n}\n"]}